This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 2.x development tree".
The branch, master has been updated via 33513817fa4eac7007fc4e39c348d7fffdfac20a (commit) via dd676ffb49f9b5b6c9fe4178f86cd048fb789593 (commit) via d731b1f9914738ba8c76f7724b7915c941d3e336 (commit) via ee1148d12a32988f3ae8c75f7c4a4b31883dc674 (commit) via 96e31c9817f1ee3bec3fe33ecae7a84ff7e4ffff (commit) via 8a148bbc5a9de80edb36fad91cd3f0e6ca3155a1 (commit) via 01ddfa0d6f1483071fd87e9f6c77085b174a1b14 (commit) via 224401de72e7e08403cd07774d4f311d2e86c3a7 (commit) via 8649a31ed040795b09228c8f3fa181d001614541 (commit) via f08c14477ed0f875a86d01c1d11bc234766953aa (commit) via 6fa34327dd38412820e9654df69d48995b02906a (commit) via 1775dbd2c6dc36e26712bbffa593e12af475c6a2 (commit) via 46ce813e330925e0ab5969cf3e34c9e49fb9df88 (commit) via 9ef4bbf7032d6727a6debc10702e9beacd0b097d (commit) via 8c1cf3b1f929ecd085827469ccb02ab9459de711 (commit) via cb679b1eb965e0df188b50ab0337cf1687ed70cb (commit) via 03022f412ef2d4cfd0bad133988f2cc3312728d1 (commit) via 593e2eeb0320285c309686668b73744973d0a944 (commit) via 88cc99094805eb3133cac3eec0005844f5904721 (commit) via f83c50537bcb4b74bebcff83f86f69b60def544f (commit) via 822b4313d1029bcfa19ec6cc2f36da128001ab24 (commit) via 4f472f86f854a5460c4fa8eb63fd1a4393d6099d (commit) via 4a6cfe51a16575c7100862e2cc6f959bc48c6628 (commit) via 64835e022c52d24432d201bd4d57f1aa962c1f90 (commit) via a6cd8b9b5d903da27fef106329c892e372753e5f (commit) via 3b9815eb87e83a1b24e85ce0eab14a962b62ccd0 (commit) via 43747fae333273890aadb66b72d911efaa4c2086 (commit) via 5f39eb211974f1fa21c1f769f62b779f85ffbdf4 (commit) via 77c48fbe35e59957036b9533db0ec5b88a7a1e3d (commit) via f443b4cba7fbd22723e1716355ee921e289907ab (commit) via 962fade2d4714d4c8d5e26b841e4a87c96f92845 (commit) via 28ef7a6a9e782410811e7733f27ec85b4ba0fe19 (commit) via 86b759785b24acd678450f639424b81798e329ab (commit) via efd02229ae5402bad762a20c9ce75607267e3309 (commit) via 920f1950959bb1500847eb3e3eaebbe88ce08163 (commit) via c83d16146342d2a0d6ad8c101c82de71ab40d9e3 (commit) via 38956241bb0644480887aeb9a399e3d9ba2fc3f4 (commit) via ee552b7e1a8238b620b557f16baf2131cbafc104 (commit) via 802b916d10aa314ae878ec633e7c3bbd2adaba7e (commit) via 879458d41f95578cd35e0f8e9f9e5078aa8dccbb (commit) via fd3b90c8751df6db7a99bcf3181cef608bb72417 (commit) via e039df8613b4f51b58ca249998ef66fc7bb76758 (commit) via a760a5cfa96c9f383bf3244e07a34d13f97cbc63 (commit) via 7b757df70fb4caa70eb0f3a0e0cd1af7c9adaea1 (commit) via c1bf984e05ff9c523121d459cd58154d3d37a34a (commit) via 8260fb7e0eac021a9be1c120d39ecb8e4a76c2a2 (commit) via c9ed30440afb129925fd05692a1c403db3831a43 (commit) via 9dc6723a0a677ad84f8bc40679d963bcf8704f71 (commit) via 067db4d53abbaeaaaaf46515ee834c78f1bf235b (commit) via d651e48f708182ade9669a5119cc63300b70d2d3 (commit) via 645378fbb9f8540ace66bd3a9be70583b6e15a6f (commit) via ff43197b01d45dd6119fb15586c2ce29bd4f8cb3 (commit) via 0aa71600efb5dcff104135ed4bf621a23ee19ced (commit) via 552fb4b8b5aa738959848dafc20d41e6fdbdbe4e (commit) via a06723b1f4e87ee5b31dbc59e7b21a9e57750989 (commit) via f83b3c65a34b5e66255c77140724db684e3e460b (commit) via 57d98918a1a11077d8d3e3caeaca9d85e4200ea5 (commit) via 35b24ff8a933e2ab8614c4f9b7c27c25c6f95473 (commit) via 78574c184666087272235ceeafceaf585cff96ba (commit) via a6c71642778020a832bb5da67db8ebd004d85bad (commit) via eb2f4a4d2623d8e3646156126884dd78b8357dc7 (commit) via ecd50190976df0b55c912ee4b2eb004652cd3b4d (commit) via 6fa8a1a9cc50d2df78650f1fc0f8f6f3b9111398 (commit) via 235888599a4afa54d54421328733bf003c45711a (commit) via 8998dde892d3e515747ee9a2e6e3fdf04ae607b9 (commit) via 00ee4eb13ce2f3cdd7deee08b6487145b46b28bb (commit) via 02a60a9b9e99f1a8aa20b1deefa2b622ba99a5c6 (commit) via cf82da6b376e4c7456a0690968ad2e879029a70c (commit) via c97698a8f4b2520e198521c3d67a25efc3ad3776 (commit) via 665f79926d025fec413531c397ccd6998583237e (commit) via 92e4521572f0a5a6411ce74a7a70b9b65dcebb26 (commit) via 20b27af8634b88fa400b1779415fc92888fbb1d8 (commit) via 2775ab9cc63708ea0370d5220d5ee13a4f94142b (commit) via 8a1a3bf3934c8a92c605135ee13db466ea3dcbf4 (commit) via 41410d197b3dbf75dfd05376ed623857adac8977 (commit) via 22a504c69cb578f6e34928f3d862beac635e5224 (commit) via 928eba27a5e15074d8e5b7d8b9f6892d122bf40f (commit) via bcb30674e2f7f3fe4989bffe5fbc43d44be86633 (commit) via 857b2c795e2c982cb5967725ba01a1e3c29d43f5 (commit) via cc9f461f74525fa3f7300a86676634780c884a21 (commit) via 037cf8d20dd5d754c89c8d267d9fd6384061d170 (commit) via 43e5fe9ded9899276a338476ba8a2974055ca222 (commit) via 64285d23eb9003efd7a2273d61814d4cd144431d (commit) via 9b4f0e639705d87708b67038e11fc4f10cbe81e5 (commit) via 3da3ac98564bc97ba96bc2e10d5d6acb746a33de (commit) via 8f2ac12a87a1308c5e9adc7e7adb7150d5a1b364 (commit) via 6e96dd142aa6a54f970968c8a1bb2087aa8c6147 (commit) via 905d1afd4e7d30b9088e8c214248a76f5ff4ae72 (commit) via cfdeb28050cac9c87d7be896378f2f53d722ff7d (commit) via db017b4b6ef9ccf32f7e9a2c22f58c3f339e98ad (commit) via c1de76704acbb06bffbb4e6b15f66892db93c525 (commit) via b75b6382ab1a3a71bb434932623a396b106d6925 (commit) via 1d9be34e2a617efa19135b646914fb1ef507a8b9 (commit) via 43638be58b2ae99bd07a420c5f340222e2744feb (commit) via cec5c724f5b1cb4c989c0832cc63c733d7c2b107 (commit) via 16260e2c695021795a06941781f9ef86af6305ec (commit) via 1b5b6c91dae0316c9453fe7560c1d39fc453ebcb (commit) via a249e865bd15f8f9041db8e3894cdae4dc4b25ca (commit) via 764a3f1ff2384f34c592c311f5435a24eb6a53c8 (commit) via 2eb67894efaf650494cc5dafb73ca7ce144fe088 (commit) via f97c6774ef3e4bd4cf77b5e6ff1870bc0f7e271b (commit) via 9877d28d9e2daf49324cbf2120d00ab7169da0d3 (commit) via 820a4ab564b1bd437d27becede5defb000c06c50 (commit) via f81e27e1c8c47fefdc78b22ecb0bb5122ea0b304 (commit) via b0a014b7f83f160c036d8910e90d1262321e2d12 (commit) via 9a09d94ee3eb6097897f31dc236dc0c2aaea677b (commit) via 84032d0845148505c230db0f391e524146835a9c (commit) via 964700d414ca841ca0d3e98329c179b4cb62e36e (commit) via 9977da131b2d2e560057b79db714a987977026b4 (commit) via 21ac63688a76cefccf4796fe608fae436c38d5c8 (commit) via c3b4c861f5531712b6579cae839ea621f5336950 (commit) via 2135528774a66fa30143c024993054aed0f60c5a (commit) via 4df3276bb43bfb77e570b8c329da3885f644dabb (commit) via b94e0ffc689e6a659809fb874b6c18053faf1f48 (commit) via b37e91c3b5527527ae354e66d91f6912e6e534de (commit) via eddda7f9bd4489e6c5e37bf88eac83196210616b (commit) via f25314afd71657a51e1dc02759edaf99c22bb270 (commit) via aa6684235847375033842ab4ed99e22bcd9a13c2 (commit) via 98b8cabf4d80909b636e56a59091665798043f61 (commit) via 6138d53bdd9df4a007361c3e63ab602e2c2de443 (commit) via 3b7808295e2627ac9a0c8a79a793262ac6cd545a (commit) via ffea9709f83fae4f9b7e249d7f5cdc2501259607 (commit) via a7b0967db425d27b349d436bf83e4a18143f6fe3 (commit) via f295ca0cf75d0b475303a9db905e3ab082290997 (commit) via 21819b545a1451f557ea924b0dcdb5ab24b59a86 (commit) via 9f0f7c50cd2a4040a7ba26358e5d956e2168d0a8 (commit) via a9fd97961920a89c87217f89c14fa2d4234a393d (commit) via 8675b78af98432f327adcb7d35c614cb2ce7dfb6 (commit) via 9098b1e1c0f170b51620b8bc63118b89a038dfc6 (commit) via bdfd41c4f18fa85b9cc392354c0e1d73b7735651 (commit) via 9753936f4cfcde7ff310bb9d9f31c6c3d5caff79 (commit) via d31345a50bed70c4d2197e1294f5490be839dff2 (commit) via ea155e2d2b337366b04979b375251fdac724fcc6 (commit) via c15da8c3b5f94d3ced94166eefb9392b86dc9d80 (commit) via 6b86307cac1ed49a3d88836fc5fa90eef98a33ca (commit) via 63fd135400da8e15a1a0519f377c20bad67a6d0e (commit) via 53a6b00c4fc7e863b8a1b22cc01f90b016184363 (commit) via 2c4b9c5004f0db606612eba3965846d4a2623296 (commit) via e2c723627c587275e274948d026ac41a80a1705a (commit) via c8f8bf328f4dd6567513f942c9c1db1dcf73ef93 (commit) via 50354ffe3a946f314b5bf4f8648fa14d14c14667 (commit) via a93bf696170d32a45ccc76b29f68ca9b4df9ddb3 (commit) via d57c6162cb2d00fd4a4989fa3fe6924db528bce1 (commit) via 4071b2d61bdf3e284395d80a06189d5ae7752c5b (commit) via 0f5350608ed5790101caf94c19bf08a0a0c2118f (commit) via a235f229527896f76ffa9404f6b8fb75f19d522b (commit) via b1109b8af5f0a5e3ab7f0b68211d63ab0594c0ac (commit) from 75ad2e4e885992c9b17c2d7b722dd3ac3875a7f0 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 33513817fa4eac7007fc4e39c348d7fffdfac20a Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sun Mar 20 09:36:33 2016 +0100
set version to IPFire 2.19 core100
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit dd676ffb49f9b5b6c9fe4178f86cd048fb789593 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Mar 19 21:56:30 2016 +0100
core100: add changes to updater
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit d731b1f9914738ba8c76f7724b7915c941d3e336 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Mar 19 12:54:12 2016 +0100
mt7601u-firmware: added
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit ee1148d12a32988f3ae8c75f7c4a4b31883dc674 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Mar 19 12:46:38 2016 +0100
ath10k-firmware: added
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 96e31c9817f1ee3bec3fe33ecae7a84ff7e4ffff Author: Arne Fitzenreiter arne_f@ipfire.org Date: Fri Mar 18 19:26:39 2016 +0100
ntp: wait for connection if dhcpcd is running
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 8a148bbc5a9de80edb36fad91cd3f0e6ca3155a1 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Mar 17 23:04:54 2016 +0100
Config: update sourcecode upload url
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 01ddfa0d6f1483071fd87e9f6c77085b174a1b14 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Mar 17 23:00:46 2016 +0100
kernel: update to 3.14.65
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 224401de72e7e08403cd07774d4f311d2e86c3a7 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Mar 16 23:05:06 2016 +0100
linux-pae: add root (hd0) to grub.conf for virt install.
jiffybox will not load the kernel without this entry. not tested on citrix yet.
commit 8649a31ed040795b09228c8f3fa181d001614541 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Mar 16 22:58:21 2016 +0100
u-boot: fix fat16 reader
commit f08c14477ed0f875a86d01c1d11bc234766953aa Author: Arne Fitzenreiter arne_f@ipfire.org Date: Mon Mar 14 18:34:45 2016 +0100
core100: touch arm kernel and initrd before unpack.
this is a workaround for a uboot bug that not find all files.
commit 6fa34327dd38412820e9654df69d48995b02906a Author: Arne Fitzenreiter arne_f@ipfire.org Date: Mon Mar 14 18:04:38 2016 +0100
kernel: enable NFS_DEBUG
fixes #11053
commit 1775dbd2c6dc36e26712bbffa593e12af475c6a2 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Mar 10 22:29:02 2016 +0100
kernel: update to 3.14.64
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 46ce813e330925e0ab5969cf3e34c9e49fb9df88 Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Mar 10 19:22:04 2016 +0000
setup: Fix segmentation fault with more than four NICs found
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 9ef4bbf7032d6727a6debc10702e9beacd0b097d Merge: cb679b1 8c1cf3b Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Mar 8 22:45:04 2016 +0000
Merge branch 'bird' into next
commit 8c1cf3b1f929ecd085827469ccb02ab9459de711 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Mar 8 22:44:01 2016 +0000
bird: New package
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit cb679b1eb965e0df188b50ab0337cf1687ed70cb Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Mar 8 21:32:29 2016 +0100
core100: add missing openssl rootfile to updater
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 03022f412ef2d4cfd0bad133988f2cc3312728d1 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Mar 8 20:29:59 2016 +0100
core100: ship openssl (build with new gcc)
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 593e2eeb0320285c309686668b73744973d0a944 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Mar 8 20:28:12 2016 +0100
core100: ship glibc (build with new gcc)
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 88cc99094805eb3133cac3eec0005844f5904721 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Mar 8 20:01:49 2016 +0100
core100: add kernel to updater
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit f83c50537bcb4b74bebcff83f86f69b60def544f Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Mar 8 19:31:49 2016 +0100
core100: add function to set last correct installed core on update.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 822b4313d1029bcfa19ec6cc2f36da128001ab24 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Mar 5 17:09:32 2016 +0100
kernel: update to 3.14.63
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 4f472f86f854a5460c4fa8eb63fd1a4393d6099d Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Mar 5 17:07:23 2016 +0100
flash-images: copy kernel and initrd first
there is a u-boot bug that not find all files if the directory entries was splittet to more sectors so copy the important files first.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 4a6cfe51a16575c7100862e2cc6f959bc48c6628 Merge: 64835e0 75ad2e4 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Fri Mar 4 07:09:02 2016 +0100
Merge remote-tracking branch 'origin/master' into next
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 64835e022c52d24432d201bd4d57f1aa962c1f90 Author: Michael Tremer michael.tremer@ipfire.org Date: Sun Feb 28 12:27:06 2016 -0800
udev: Fix calling VLAN script
The VLAN hotplugging script was called with a wrong parameter that should just be used to rename devices. Hence the script was not correctly executed and did not create the virtual devices.
Fixes: #11009
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit a6cd8b9b5d903da27fef106329c892e372753e5f Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sat Feb 27 16:29:45 2016 +0100
dnsmasq: 2.76test10 with latest patch (005) and some fixes
1. Added patch 005 because of the discussion on the dnsmasq-list: "I've noticed that replies which get their TTL from the dhcp-ttl option always get the TTL specified in dhcp-ttl. I'd prefer something like max(0, min(<dhcp-ttl>, <lease-expire-time> - <now>)). Otherwise, dns might hand out a high TTL for a dhcp-lease which expires one second later. ... Seems a sensible addition.
Cheers,
Simon."
2. Fixed several line numbers and patch lines in 'dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch'. On the last build I got some "Hunk failed" messages. Patches are now applied exactly at the given lines.
3. Nevertheless, I still get some warnings: ... dnsmasq.c: In function 'main': dnsmasq.c:55:7: warning: unused variable 'did_bind' [-Wunused-variable] int did_bind = 0; ^ dnsmasq.c:54:9: warning: unused variable 'bound_device' [-Wunused-variable] char *bound_device = NULL; ^ ... isc.c: In function 'dhcp_lease_new': isc.c:40:3: warning: ignoring return value of 'asprintf', declared with attribute warn_unused_result [-Wunused-result] asprintf(&lease->fqdn, "%s.%s", hostname, daemon->domain_suffix); ^
Asking about these warnings in the dnsmasq-list showed no reaction - no one answered.
Best, Matthias
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 3b9815eb87e83a1b24e85ce0eab14a962b62ccd0 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Fri Feb 26 18:29:28 2016 +0100
dnsmasq: 2.76test10 with latest patches (001-004)
This is 'dnsmasq 2.76test10', based on current 'next', containing latest patches.
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 43747fae333273890aadb66b72d911efaa4c2086 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Fri Feb 26 13:43:33 2016 +0100
kernel: update to 3.14.62
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 5f39eb211974f1fa21c1f769f62b779f85ffbdf4 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Fri Feb 26 07:27:09 2016 +0100
rename core99 to core100 for inserting another OpenSSL Security update
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 77c48fbe35e59957036b9533db0ec5b88a7a1e3d Author: Michael Tremer michael.tremer@ipfire.org Date: Wed Feb 24 22:13:36 2016 -0800
core99: Ship updated xz
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit f443b4cba7fbd22723e1716355ee921e289907ab Author: Marcel Lorenz lorenz.marcel@web.de Date: Tue Feb 23 08:49:27 2016 +0100
bison: update to 3.0.4
Update bison to the last version from Linux from Scratch.
Signed-off-by: Marcel Lorenz marcel.lorenz@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 962fade2d4714d4c8d5e26b841e4a87c96f92845 Author: Marcel Lorenz lorenz.marcel@web.de Date: Tue Feb 23 09:37:28 2016 +0100
xz: update to 5.2.2
Update xz to last version from Linux from Scratch.
Signed-off-by: Marcel Lorenz marcel.lorenz@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 28ef7a6a9e782410811e7733f27ec85b4ba0fe19 Author: Marcel Lorenz lorenz.marcel@web.de Date: Tue Feb 23 08:46:23 2016 +0100
m4: update to 1.4.17
Update m4 to last version from Linux from Scratch.
Signed-off-by: Marcel Lorenz marcel.lorenz@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 86b759785b24acd678450f639424b81798e329ab Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Feb 23 09:44:40 2016 -0800
make.sh: Update source upload URL
There is no longer a SSH service on source.ipfire.org.
The usual login on git.ipfire.org should be used instead.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit efd02229ae5402bad762a20c9ce75607267e3309 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Feb 24 16:01:33 2016 +0100
flash-images: change root uuid replacer sed
i cannot really test this on my systems.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 920f1950959bb1500847eb3e3eaebbe88ce08163 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Feb 23 20:08:25 2016 +0100
flash-image: set RAMDISK_MODE=2
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit c83d16146342d2a0d6ad8c101c82de71ab40d9e3 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Feb 23 20:01:30 2016 +0100
init-functions: enable autoramdisk with 400MB
The 512MB raspberry pi reserve some memory for buffers and gpu so there are a bit less than 490 MB free.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 38956241bb0644480887aeb9a399e3d9ba2fc3f4 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Feb 23 19:49:49 2016 +0100
flash-image: fix root uuid on some build machines.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit ee552b7e1a8238b620b557f16baf2131cbafc104 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Fri Feb 19 07:18:29 2016 +0100
kernel: update to 3.14.61
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 802b916d10aa314ae878ec633e7c3bbd2adaba7e Merge: 879458d 1ffbca6 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Feb 17 19:45:08 2016 +0100
Merge remote-tracking branch 'origin/master' into next
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
Conflicts: make.sh
commit 879458d41f95578cd35e0f8e9f9e5078aa8dccbb Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Feb 17 10:10:19 2016 +0100
rename core98 to 99 for glibc security update
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit fd3b90c8751df6db7a99bcf3181cef608bb72417 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sat Feb 13 08:29:39 2016 +0100
squid 3.4.14: Bugfix for #4431 (C code is not compiled with CFLAGS)
For details see: http://bugs.squid-cache.org/show_bug.cgi?id=4431
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit e039df8613b4f51b58ca249998ef66fc7bb76758 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Feb 10 08:36:17 2016 +0100
backports: remove all old media modules.
more modules are renamed or merged into other modules.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit a760a5cfa96c9f383bf3244e07a34d13f97cbc63 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Mon Feb 8 13:53:13 2016 +0100
dracut: remove marvell sdio modules from initrd.
this allows to switch to uap module on dreamplug.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 7b757df70fb4caa70eb0f3a0e0cd1af7c9adaea1 Author: Michael Tremer michael.tremer@ipfire.org Date: Mon Feb 8 01:52:18 2016 +0000
core98: Ship changed /etc/ppp/ip-up
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit c1bf984e05ff9c523121d459cd58154d3d37a34a Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sun Feb 7 13:45:32 2016 +0100
New IP-address of 'ping.ipfire.org'
Telekom gateways (e.g.) don't answer 'pings', therefor '/etc/ppp/ip-up' uses 'ping.ipfire.org' for the 'gateway Graph' in 'Status / Network (other'. After moving the infrastructure, several IP addresses were changed. '178.63.73.246' doesn't work anymore for 'ping.ipfire.org', its now '81.3.27.38'.
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 8260fb7e0eac021a9be1c120d39ecb8e4a76c2a2 Author: Michael Tremer michael.tremer@ipfire.org Date: Mon Feb 8 01:40:35 2016 +0000
core98: Ship recently updated grep and sed
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit c9ed30440afb129925fd05692a1c403db3831a43 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sun Jan 31 14:49:17 2016 +0100
grep: Update to 2.22
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 9dc6723a0a677ad84f8bc40679d963bcf8704f71 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sun Jan 31 14:44:05 2016 +0100
sed: Update to 4.2.2
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 067db4d53abbaeaaaaf46515ee834c78f1bf235b Merge: 645378f d651e48 Author: Michael Tremer michael.tremer@ipfire.org Date: Mon Feb 8 01:33:15 2016 +0000
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
commit d651e48f708182ade9669a5119cc63300b70d2d3 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sun Feb 7 09:38:20 2016 +0100
kernel: disable grsecurity KSTACKOVERFLOW.
this is the reason for crashes usb lan dongles and media devices.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 645378fbb9f8540ace66bd3a9be70583b6e15a6f Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Feb 5 10:24:03 2016 +0000
firewall: Fix MAC filter
Packets destined for the firewall coming in from the blue device where accepted too early to be processed by the firewall input chain rules.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit ff43197b01d45dd6119fb15586c2ce29bd4f8cb3 Merge: 0aa7160 552fb4b Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Feb 4 14:35:55 2016 +0000
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
commit 0aa71600efb5dcff104135ed4bf621a23ee19ced Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Feb 4 14:31:53 2016 +0000
wirelessctrl: Remove some unused code
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 552fb4b8b5aa738959848dafc20d41e6fdbdbe4e Author: Arne Fitzenreiter arne_f@ipfire.org Date: Mon Feb 1 07:28:03 2016 +0100
dhcpcd: rework mtu handling on buggy nic's
some nic's loose the carrier after setting new mtu.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit a06723b1f4e87ee5b31dbc59e7b21a9e57750989 Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Jan 30 16:37:21 2016 +0000
core98: Ship updated tzdata
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit f83b3c65a34b5e66255c77140724db684e3e460b Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sat Jan 30 11:07:46 2016 +0100
tzdata: Update to 2016a
Fixes https://bugzilla.ipfire.org/show_bug.cgi?id=11034
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 57d98918a1a11077d8d3e3caeaca9d85e4200ea5 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Fri Jan 29 14:25:25 2016 +0100
kernel: update to 3.14.60
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 35b24ff8a933e2ab8614c4f9b7c27c25c6f95473 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 28 22:08:08 2016 +0100
set core to 98 and move 97 to oldcore
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 78574c184666087272235ceeafceaf585cff96ba Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 28 16:20:16 2016 +0100
finish core97
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit a6c71642778020a832bb5da67db8ebd004d85bad Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 28 15:58:46 2016 +0100
openssl: security update to 1.0.2f
changes: * DH small subgroups - CVE-2016-0701 * SSLv2 doesn't block disabled ciphers - CVE-2015-3197 * Reject DH handshakes with parameters shorter than 1024 bits
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit eb2f4a4d2623d8e3646156126884dd78b8357dc7 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 28 13:24:50 2016 +0100
hwdate: update databases
pci.ids: 2016.01.28 usb.ids: 2015.12.17
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit ecd50190976df0b55c912ee4b2eb004652cd3b4d Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 28 13:08:59 2016 +0100
core97: prepare new core97 with openssl and openssh update.
the update itself has to be done...
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 6fa8a1a9cc50d2df78650f1fc0f8f6f3b9111398 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 28 13:03:39 2016 +0100
rename core97 to 98 because we have to insert OpenSSL security update
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 235888599a4afa54d54421328733bf003c45711a Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 28 13:02:09 2016 +0100
backports: update to 4.2.6
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 8998dde892d3e515747ee9a2e6e3fdf04ae607b9 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Tue Jan 26 18:02:00 2016 +0100
rsync: update to 3.1.2
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 00ee4eb13ce2f3cdd7deee08b6487145b46b28bb Author: Arne Fitzenreiter arne_f@ipfire.org Date: Mon Jan 25 20:15:06 2016 +0100
kernel: update to 3.14.59
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 02a60a9b9e99f1a8aa20b1deefa2b622ba99a5c6 Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Jan 23 01:46:42 2016 +0000
squid: Actually make --with-filedescriptors work
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit cf82da6b376e4c7456a0690968ad2e879029a70c Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Jan 23 00:41:02 2016 +0000
core97: Ship updated CGI files
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit c97698a8f4b2520e198521c3d67a25efc3ad3776 Merge: 665f799 43638be Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Jan 23 00:39:24 2016 +0000
Merge remote-tracking branch 'meitelwein/web-gui-ipv6' into next
commit 665f79926d025fec413531c397ccd6998583237e Merge: 92e4521 c26171b Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Jan 23 00:39:19 2016 +0000
Merge remote-tracking branch 'origin/master' into next
commit 92e4521572f0a5a6411ce74a7a70b9b65dcebb26 Author: Daniel Weismüller daniel.weismueller@ipfire.org Date: Fri Jan 22 12:10:19 2016 +0100
cmake: Disable parallelism
Building cmake uses a high amount of memory (>2G) and fails to build on my system. Using less processes reduces memory usage and lets the build succeed.
Signed-off-by: Daniel Weismüller daniel.weismueller@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 20b27af8634b88fa400b1779415fc92888fbb1d8 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Jan 22 00:55:46 2016 +0000
Update translations
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 2775ab9cc63708ea0370d5220d5ee13a4f94142b Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Jan 22 00:55:25 2016 +0000
core97: Ship iptables conntrack changes
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 8a1a3bf3934c8a92c605135ee13db466ea3dcbf4 Merge: 41410d1 6b86307 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Jan 22 00:54:14 2016 +0000
Merge remote-tracking branch 'ms/iptables-conntrack' into next
commit 41410d197b3dbf75dfd05376ed623857adac8977 Merge: 22a504c a7b0967 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Jan 22 00:49:15 2016 +0000
Merge branch 'hyper-v-fixes' into next
commit 22a504c69cb578f6e34928f3d862beac635e5224 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Jan 20 19:28:56 2016 +0100
toolchain: fix build on hosts that not support strong stackprotect
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 928eba27a5e15074d8e5b7d8b9f6892d122bf40f Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Jan 19 00:07:07 2016 +0000
core97: Ship updated webaccess.cgi
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit bcb30674e2f7f3fe4989bffe5fbc43d44be86633 Author: Erik Kapfer erik.kapfer@ipfire.org Date: Mon Jan 18 10:14:10 2016 +0100
webaccess.cgi: Fixed language settings.
Fix for #10879. Added also use strict.
Signed-off-by: Erik Kapfer erik.kapfer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 857b2c795e2c982cb5967725ba01a1e3c29d43f5 Author: Michael Tremer michael.tremer@ipfire.org Date: Mon Jan 18 22:26:23 2016 +0000
Improve hardening by using -fstack-protector-strong
This functionality is now available for us since we updated to GCC 4.9 and just improves the stack smashing protector in GCC.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit cc9f461f74525fa3f7300a86676634780c884a21 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Tue Jan 12 18:46:52 2016 +0100
nano: Update to 2.5.1
Excerpt form 'NEWS': "It includes fixes for a syntax-highlighting bug and a positionlog bug, it disables a time-eating multiline regex in the C syntax, and it adds an escape hatch to the WriteOut menu when --tempfile is used: the discardbuffer command, ^Q. It also has translation updates for fifteen languages, and a small fix in the softwrap code."
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 037cf8d20dd5d754c89c8d267d9fd6384061d170 Author: Michael Tremer michael.tremer@ipfire.org Date: Sun Jan 17 18:51:47 2016 +0000
core97: Ship updated openssh
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 43e5fe9ded9899276a338476ba8a2974055ca222 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Fri Jan 15 17:43:50 2016 +0100
openssh: Update to 7.1p2
Fixes CVE-2016-0777
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 64285d23eb9003efd7a2273d61814d4cd144431d Merge: cfdeb28 9b4f0e6 Author: Michael Tremer michael.tremer@ipfire.org Date: Sun Jan 17 18:49:03 2016 +0000
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
commit 9b4f0e639705d87708b67038e11fc4f10cbe81e5 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Fri Jan 15 07:20:34 2016 +0100
toolchain: bump version number
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 3da3ac98564bc97ba96bc2e10d5d6acb746a33de Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 14 16:08:24 2016 +0100
gcc: remove gdb python files also in root build.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 8f2ac12a87a1308c5e9adc7e7adb7150d5a1b364 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 14 03:55:54 2016 +0100
toolchain: move *.py remove to correct pass.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 6e96dd142aa6a54f970968c8a1bb2087aa8c6147 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Jan 13 19:04:56 2016 +0100
toolchain: enable bootstrap and remove *.py files from lib.
only with bootstrap the gcc pass2 build works on arm.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 905d1afd4e7d30b9088e8c214248a76f5ff4ae72 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Jan 13 07:24:34 2016 +0100
kernel: disable RANDSTRUCT
RANDSRUCT is incompatible with ccache build.
fixes #10905 fixes #11012
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit cfdeb28050cac9c87d7be896378f2f53d722ff7d Author: Michael Tremer michael.tremer@ipfire.org Date: Sun Jan 10 21:20:49 2016 +0000
core97: Ship updated ntp
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit db017b4b6ef9ccf32f7e9a2c22f58c3f339e98ad Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sat Jan 9 20:39:45 2016 +0100
ntp 4.2.8p5: removed obsolete patch file
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit c1de76704acbb06bffbb4e6b15f66892db93c525 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sat Jan 9 20:29:41 2016 +0100
ntp: Update to 4.2.8p5
"...addresses 1 medium-severity security issue, 14 bugfixes, and contains other improvements over 4.2.8p4."
For a complete list, see: http://support.ntp.org/bin/view/Main/SecurityNotice#Recent_Vulnerabilities
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit b75b6382ab1a3a71bb434932623a396b106d6925 Author: Michael Tremer michael.tremer@ipfire.org Date: Sun Jan 10 19:35:42 2016 +0000
grub: Disable hardening for grub-script-check
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 1d9be34e2a617efa19135b646914fb1ef507a8b9 Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Jan 9 19:48:21 2016 +0000
ccache: Include hash of compiler specs in hashing
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 43638be58b2ae99bd07a420c5f340222e2744feb Author: Michael Eitelwein michael@eitelwein.net Date: Sat Jan 9 20:09:58 2016 +0100
No code changes, fixed formatting by replacing spaces with tabs
commit cec5c724f5b1cb4c989c0832cc63c733d7c2b107 Merge: 820a4ab 16260e2 Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Jan 9 14:56:33 2016 +0000
Merge branch 'next' of ssh://git.ipfire.org/pub/git/ipfire-2.x into next
commit 16260e2c695021795a06941781f9ef86af6305ec Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Jan 7 23:47:39 2016 +0000
timectrl: Stop ntp daemon when disabled
Fixes #11000
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 1b5b6c91dae0316c9453fe7560c1d39fc453ebcb Author: Michael Eitelwein michael@eitelwein.net Date: Thu Jan 7 19:40:24 2016 +0100
Fixed detection of firewall chain when bridge is used for ipv6
Signed-off-by: Michael Eitelwein michael@eitelwein.net
commit a249e865bd15f8f9041db8e3894cdae4dc4b25ca Author: Michael Eitelwein michael@eitelwein.net Date: Thu Jan 7 16:55:11 2016 +0100
Firewall chain was not extracted correctly when ipv6 uses bridge
Signed-off-by: Michael Eitelwein michael@eitelwein.net
commit 764a3f1ff2384f34c592c311f5435a24eb6a53c8 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 7 17:41:43 2016 +0100
toolchain: fix full toolchain crossbuild
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit 2eb67894efaf650494cc5dafb73ca7ce144fe088 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Thu Jan 7 17:41:16 2016 +0100
binutils: update to 2.24
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit f97c6774ef3e4bd4cf77b5e6ff1870bc0f7e271b Author: Michael Eitelwein michael@eitelwein.net Date: Thu Jan 7 15:24:13 2016 +0100
Fix regex to extract firewall chain for ipv6 in showrequestfrom*.dat
If bridged ipv6 is used, $iface is taken from PHYSIN In the log line the order of fields is "... IN=XY OUT=XY PHYSIN=XY ..."
Signed-off-by: Michael Eitelwein michael@eitelwein.net
commit 9877d28d9e2daf49324cbf2120d00ab7169da0d3 Author: Michael Eitelwein michael@eitelwein.net Date: Thu Jan 7 14:00:01 2016 +0100
Enable correct display of ipv6 entries in Firewall log pages of web UI.
3 main changes: - Fill $iface and $out from PHYSIN and PHYSOUT when looking at bridged packets, othwerwise fill from IN and OUT - Recognize ipv4 and ipv6 address style for $srcaddr and $dstaddr - Match color coding of tables to pie charts (see seperate patch sent earlier)
I am using the bridged ipv6 setup as proposed in the wiki. I do not think this breaks anything when not using ipv6. So it would be nice to include this even if ipv6 is not officially supported yet. It is quite useful when using the ipv6 setup.
Signed-off-by: Michael Eitelwein michael@eitelwein.net ---
commit 820a4ab564b1bd437d27becede5defb000c06c50 Author: Daniel Weismüller daniel.weismueller@ipfire.org Date: Wed Jan 6 14:56:18 2016 +0100
owncloud: updated to version 7.0.11
Signed-off-by: Daniel Weismüller daniel.weismueller@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit f81e27e1c8c47fefdc78b22ecb0bb5122ea0b304 Author: Michael Tremer michael.tremer@ipfire.org Date: Wed Jan 6 15:05:37 2016 +0000
dnsdist: Don't build on ARM
There seem to be some serious C++ issues in this so that it won't build on ARM.
At the moment I do not have any resources to look further into this, so I just disable building this package for all ARM architectures.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit b0a014b7f83f160c036d8910e90d1262321e2d12 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Jan 5 21:00:19 2016 +0000
QoS: Improve saving enabled/disable state
It was reported that the QoS did not stop when the user clicked the "stop" button. This patch fixes that.
Fixes #10664
Signed-off-by: Michael Tremer michael.tremer@ipfire.org Acked-by: Arne Fitzenreiter arne.fitzenreiter@ipfire.org
commit 9a09d94ee3eb6097897f31dc236dc0c2aaea677b Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Jan 5 20:44:26 2016 +0000
qosctrl: Cleanup code by replacing hardcoded paths
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 84032d0845148505c230db0f391e524146835a9c Author: Michael Tremer michael.tremer@ipfire.org Date: Mon Jan 4 22:46:13 2016 +0000
core97: Ship updated openvpn package
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 964700d414ca841ca0d3e98329c179b4cb62e36e Author: Erik Kapfer erik.kapfer@ipfire.org Date: Tue Jul 7 13:13:35 2015 +0200
openvpn: Update to version 2.3.7, added --verify-x509-name directive.
The tls-remote directive is deprecated and will be removed with OpenVPN version 2.4 . Added instead --verify-x509-name HOST name into ovpnmain.cgi.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 9977da131b2d2e560057b79db714a987977026b4 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sun Dec 27 00:20:13 2015 +0100
bind: Update to 9.10.3-P2
Changelog:
[security] Update allowed OpenSSL versions as named is potentially vulnerable to CVE-2015-3193.
[maint] H.ROOT-SERVERS.NET is 198.97.190.53 and 2001:500:1::53. [RT #40556]
[security] Insufficient testing when parsing a message allowed records with an incorrect class to be be accepted, triggering a REQUIRE failure when those records were subsequently cached. (CVE-2015-8000) [RT #40987]
[security] Address fetch context reference count handling error on socket error. (CVE-2015-8461) [RT#40945]
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 21ac63688a76cefccf4796fe608fae436c38d5c8 Author: Michael Tremer michael.tremer@ipfire.org Date: Mon Dec 28 15:37:02 2015 +0100
core97: Ship dnsmasq
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit c3b4c861f5531712b6579cae839ea621f5336950 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Thu Dec 24 10:17:16 2015 +0100
dnsmasq 2.75: latest patches from upstream
Same procedure as... :-)
Best to all for xmas and 2016!
Matthias
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 2135528774a66fa30143c024993054aed0f60c5a Author: Michael Tremer michael.tremer@ipfire.org Date: Mon Dec 28 15:30:13 2015 +0100
core97: Ship pgrep with the updater
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 4df3276bb43bfb77e570b8c329da3885f644dabb Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Dec 26 17:37:53 2015 +0100
ncurses: rootfile update.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit b94e0ffc689e6a659809fb874b6c18053faf1f48 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Dec 26 17:34:13 2015 +0100
dnsdist: rootfile update.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit b37e91c3b5527527ae354e66d91f6912e6e534de Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Dec 26 17:33:30 2015 +0100
diffutils: rootfile update.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit eddda7f9bd4489e6c5e37bf88eac83196210616b Author: Arne Fitzenreiter arne_f@ipfire.org Date: Sat Dec 26 13:16:59 2015 +0100
gcc: include libstdc++ to rootfile
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit f25314afd71657a51e1dc02759edaf99c22bb270 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Fri Dec 25 12:45:05 2015 +0100
vdr_eepg: fix source download.
the external server has changed the compression so the md5 has changed. Always use the IPFire server as primary download source.
Signed-off-by: Arne Fitzenreiter arne_f@ipfire.org
commit aa6684235847375033842ab4ed99e22bcd9a13c2 Author: Arne Fitzenreiter arne_f@ipfire.org Date: Wed Dec 23 10:14:26 2015 +0100
kernel: apply arm-multi grsecurity fixes only at arm-multi build
commit 98b8cabf4d80909b636e56a59091665798043f61 Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Dec 10 21:25:27 2015 +0000
dnsdist: New package
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 6138d53bdd9df4a007361c3e63ab602e2c2de443 Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Dec 10 21:10:06 2015 +0000
lua: New package
Simple scripting language. Supposed to be fast. Needed for dnsdist.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 3b7808295e2627ac9a0c8a79a793262ac6cd545a Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Dec 22 22:27:10 2015 +0000
Disable packaging mediatomb
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit ffea9709f83fae4f9b7e249d7f5cdc2501259607 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Dec 22 22:25:18 2015 +0000
linux: Fix build of kernel and headers package
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit a7b0967db425d27b349d436bf83e4a18143f6fe3 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Dec 15 18:30:56 2015 +0000
linux: Backport Hyper-V network driver
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit f295ca0cf75d0b475303a9db905e3ab082290997 Author: Michael Tremer michael.tremer@ipfire.org Date: Sat Dec 12 15:31:33 2015 +0000
kernel: Add grsecurity compile fix
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 21819b545a1451f557ea924b0dcdb5ab24b59a86 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Dec 4 22:11:49 2015 +0000
mediatomb: Disable build because it FTBFS
The upstream project seems to be dead
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 9f0f7c50cd2a4040a7ba26358e5d956e2168d0a8 Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Dec 10 17:47:33 2015 +0000
gcc: Update armv5tel rootfile
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit a9fd97961920a89c87217f89c14fa2d4234a393d Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Dec 10 14:40:36 2015 +0000
gcc: Update x86_64 rootfile
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 8675b78af98432f327adcb7d35c614cb2ce7dfb6 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Dec 4 21:24:14 2015 +0000
gcc: Update to version 4.9.3
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 9098b1e1c0f170b51620b8bc63118b89a038dfc6 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Dec 4 21:22:30 2015 +0000
glibc: Fix headers to build with new GCC
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit bdfd41c4f18fa85b9cc392354c0e1d73b7735651 Author: Michael Tremer michael.tremer@ipfire.org Date: Fri Dec 4 21:21:32 2015 +0000
libmpc: New package
A dependency for GCC
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 9753936f4cfcde7ff310bb9d9f31c6c3d5caff79 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Dec 22 12:34:59 2015 +0000
core97: Ship updated bind package
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit d31345a50bed70c4d2197e1294f5490be839dff2 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Dec 22 12:34:18 2015 +0000
Create Core Update 97
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit ea155e2d2b337366b04979b375251fdac724fcc6 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Dec 22 11:11:24 2015 +0000
Move Core Update 96 to oldcore
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit c15da8c3b5f94d3ced94166eefb9392b86dc9d80 Author: Matthias Fischer matthias.fischer@ipfire.org Date: Sat Nov 7 07:33:57 2015 +0100
bind: Update to 9.10.3
bind: Update to 9.10.3
Security fixes: An incorrect boundary check in the OPENPGPKEY rdatatype could trigger an assertion failure. This flaw is disclosed in CVE-2015-5986. [RT #40286]
A buffer accounting error could trigger an assertion failure when parsing certain malformed DNSSEC keys. This flaw was discovered by Hanno Böck of the Fuzzing Project, and is disclosed in CVE-2015-5722. [RT #40212]
A specially crafted query could trigger an assertion failure in message.c. This flaw was discovered by Jonathan Foote, and is disclosed in CVE-2015-5477. [RT #40046]
On servers configured to perform DNSSEC validation, an assertion failure could be triggered on answers from a specially configured server. This flaw was discovered by Breno Silveira Soares, and is disclosed in CVE-2015-4620. [RT #39795]
Bug fixes: Asynchronous zone loads were not handled correctly when the zone load was already in progress; this could trigger a crash in zt.c. [RT #37573]
A race during shutdown or reconfiguration could cause an assertion failure in mem.c. [RT #38979]
Some answer formatting options didn't work correctly with dig +short. [RT #39291]
Malformed records of some types, including NSAP and UNSPEC, could trigger assertion failures when loading text zone files. [RT #40274] [RT #40285]
Fixed a possible crash in ratelimiter.c caused by NOTIFY messages being removed from the wrong rate limiter queue. [RT #40350]
The default rrset-order of random was inconsistently applied. [RT #40456]
BADVERS responses from broken authoritative name servers were not handled correctly. [RT #40427]
Several bugs have been fixed in the RPZ implementation.
For a complete list, see: https://kb.isc.org/article/AA-01306/0/BIND-9.10.3-Release-Notes.html
Regards, Matthias
Signed-off-by: Matthias Fischer matthias.fischer@ipfire.org Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 6b86307cac1ed49a3d88836fc5fa90eef98a33ca Author: Michael Tremer michael.tremer@ipfire.org Date: Thu Aug 20 23:05:40 2015 +0100
firewall options: Fix translation and spelling of new ALG section
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 63fd135400da8e15a1a0519f377c20bad67a6d0e Author: Alexander Marx alexander.marx@ipfire.org Date: Thu Aug 20 10:56:54 2015 +0200
BUG10844 add new options to firewalloptions for conntrack
simple changes, so far no languagefile changes because of simple protocol names. should be clear in all languages.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 53a6b00c4fc7e863b8a1b22cc01f90b016184363 Author: Michael Tremer michael.tremer@ipfire.org Date: Wed Aug 12 12:46:07 2015 +0100
firewall: Disable the PPTP and AMANDA conntrack helpers by default
These do not seem to work at the moment.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit 2c4b9c5004f0db606612eba3965846d4a2623296 Author: Michael Tremer michael.tremer@ipfire.org Date: Wed Aug 12 12:44:26 2015 +0100
firewall: Fix amanda helper
This helper requires setting a layer 4 protocol.
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit e2c723627c587275e274948d026ac41a80a1705a Author: Michael Tremer michael.tremer@ipfire.org Date: Wed Aug 12 12:18:18 2015 +0100
firewall: Fix H.323 helpers
Signed-off-by: Michael Tremer michael.tremer@ipfire.org
commit c8f8bf328f4dd6567513f942c9c1db1dcf73ef93 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue May 12 13:33:08 2015 +0200
firewall: Add H.323 to the conntrack helpers
commit 50354ffe3a946f314b5bf4f8648fa14d14c14667 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue May 12 13:27:24 2015 +0200
firewall: Add IRC to the conntrack helpers
commit a93bf696170d32a45ccc76b29f68ca9b4df9ddb3 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue May 12 13:25:04 2015 +0200
firewall: Add amanda to the conntrack helpers
commit d57c6162cb2d00fd4a4989fa3fe6924db528bce1 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue May 12 13:16:40 2015 +0200
firewall: Make conntrack helpers configurable
commit 4071b2d61bdf3e284395d80a06189d5ae7752c5b Author: Michael Tremer michael.tremer@ipfire.org Date: Mon May 11 13:04:14 2015 +0200
firewall: iptables will load the conntrack modules automatically
commit 0f5350608ed5790101caf94c19bf08a0a0c2118f Author: Michael Tremer michael.tremer@ipfire.org Date: Mon May 11 13:00:34 2015 +0200
firewall: Accept related ICMP packets again
This rule is required to forward ICMP error messages for aborted TCP connections and the like.
commit a235f229527896f76ffa9404f6b8fb75f19d522b Author: Michael Tremer michael.tremer@ipfire.org Date: Wed Apr 22 18:13:56 2015 +0200
firewall: Remove option to disable the SIP ALG
commit b1109b8af5f0a5e3ab7f0b68211d63ab0594c0ac Author: Michael Tremer michael.tremer@ipfire.org Date: Wed Apr 22 18:10:59 2015 +0200
Enhance the security of the netfilter conntrack helpers
This is suggested here https://home.regit.org/netfilter-en/secure-use-of-helpers/ and deprecated in the kernel (#10665).
-----------------------------------------------------------------------
Summary of changes: config/dhcpc/dhcpcd-hooks/10-mtu | 31 + config/dracut/dracut.conf | 3 + config/etc/modprobe.d/nf_conntrack.conf | 2 + config/firewall/firewall-policy | 5 + .../kernel/kernel.config.armv5tel-ipfire-kirkwood | 12 +- config/kernel/kernel.config.armv5tel-ipfire-multi | 12 +- config/kernel/kernel.config.armv5tel-ipfire-rpi | 12 +- config/kernel/kernel.config.i586-ipfire | 12 +- config/kernel/kernel.config.i586-ipfire-pae | 12 +- config/kernel/kernel.config.x86_64-ipfire | 14 +- config/rootfiles/common/armv5tel/binutils | 4 +- config/rootfiles/common/armv5tel/gcc | 1814 +++++++----- config/rootfiles/common/armv5tel/initscripts | 1 + config/rootfiles/common/ath10k-firmware | 23 + config/rootfiles/common/bison | 21 + config/rootfiles/common/diffutils | 2 + config/rootfiles/common/i586/binutils | 4 +- config/rootfiles/common/i586/gcc | 1917 +++++++----- config/rootfiles/common/i586/initscripts | 1 + config/rootfiles/common/libmpc | 7 + config/rootfiles/common/lua | 14 + config/rootfiles/common/mt7601u-firmware | 1 + config/rootfiles/common/ncurses | 3 + config/rootfiles/common/ntp | 2 + config/rootfiles/common/stage2 | 1 + config/rootfiles/common/tzdata | 3 + config/rootfiles/common/x86_64/binutils | 4 +- config/rootfiles/common/x86_64/gcc | 1929 +++++++----- config/rootfiles/common/x86_64/initscripts | 1 + config/rootfiles/common/xz | 2 +- config/rootfiles/core/{96 => 100}/exclude | 0 .../77 => core/100}/filelists/armv5tel/binutils | 0 .../77 => core/100}/filelists/armv5tel/gcc | 0 .../core/{98 => 100}/filelists/armv5tel/glibc | 0 .../100}/filelists/armv5tel/linux-kirkwood | 0 .../95 => core/100}/filelists/armv5tel/linux-multi | 0 .../95 => core/100}/filelists/armv5tel/linux-rpi | 0 .../rootfiles/core/100/filelists/ath10k-firmware | 1 + .../{oldcore/94 => core/100}/filelists/bind | 0 config/rootfiles/core/100/filelists/diffutils | 1 + .../rootfiles/core/{96 => 100}/filelists/dnsmasq | 0 config/rootfiles/core/100/filelists/files | 31 + .../{oldcore/89 => core/100}/filelists/grep | 0 .../77 => core/100}/filelists/i586/binutils | 0 .../{oldcore/77 => core/100}/filelists/i586/gcc | 0 .../core/{98 => 100}/filelists/i586/glibc | 0 .../rootfiles/core/{96 => 100}/filelists/i586/grub | 0 .../{oldcore/95 => core/100}/filelists/i586/linux | 0 .../95 => core/100}/filelists/i586/linux-initrd | 0 .../core/{97 => 100}/filelists/i586/openssl-sse2 | 0 config/rootfiles/core/100/filelists/libmpc | 1 + config/rootfiles/core/100/filelists/lua | 1 + .../rootfiles/core/100/filelists/mt7601u-firmware | 1 + .../{oldcore/66 => core/100}/filelists/ncurses | 0 config/rootfiles/core/{96 => 100}/filelists/ntp | 0 .../rootfiles/core/{97 => 100}/filelists/openssh | 0 .../rootfiles/core/{97 => 100}/filelists/openssl | 0 .../{oldcore/87 => core/100}/filelists/openvpn | 0 .../{oldcore/66 => core/100}/filelists/sed | 0 .../{oldcore/94 => core/100}/filelists/squid | 0 .../{oldcore/90 => core/100}/filelists/tzdata | 0 .../rootfiles/core/100/filelists/x86_64/binutils | 1 + config/rootfiles/core/100/filelists/x86_64/gcc | 1 + .../core/{98 => 100}/filelists/x86_64/glibc | 0 .../core/{96 => 100}/filelists/x86_64/grub | 0 .../95 => core/100}/filelists/x86_64/linux | 0 .../95 => core/100}/filelists/x86_64/linux-initrd | 0 .../{oldcore/90 => core/100}/filelists/xz | 0 config/rootfiles/core/{98 => 100}/meta | 0 config/rootfiles/core/100/update.sh | 259 ++ config/rootfiles/core/97/filelists/files | 2 - config/rootfiles/{core/98 => oldcore/96}/exclude | 0 .../rootfiles/{core => oldcore}/96/filelists/curl | 0 .../rootfiles/{core => oldcore}/96/filelists/dma | 0 .../rootfiles/oldcore/{94 => 96}/filelists/dnsmasq | 0 .../rootfiles/{core => oldcore}/96/filelists/files | 0 .../oldcore/{87 => 96}/filelists/i586/grub | 0 .../96/filelists/i586/openssl-sse2 | 0 .../96/filelists/i586/strongswan-padlock | 0 .../{core => oldcore}/96/filelists/libnet | 0 .../rootfiles/{core => oldcore}/96/filelists/mdadm | 0 config/rootfiles/oldcore/{95 => 96}/filelists/ntp | 0 .../{core => oldcore}/96/filelists/openssl | 0 .../{core => oldcore}/96/filelists/rrdtool | 0 .../{core => oldcore}/96/filelists/strongswan | 0 .../{core => oldcore}/96/filelists/x86_64/grub | 0 config/rootfiles/{core/97 => oldcore/96}/meta | 0 config/rootfiles/{core => oldcore}/96/update.sh | 0 config/rootfiles/{core => oldcore}/97/exclude | 0 config/rootfiles/oldcore/97/filelists/files | 18 + .../{core => oldcore}/97/filelists/hwdata | 0 .../oldcore/{91 => 97}/filelists/i586/openssl-sse2 | 0 .../rootfiles/oldcore/{94 => 97}/filelists/openssh | 0 .../rootfiles/oldcore/{92 => 97}/filelists/openssl | 0 config/rootfiles/{core/96 => oldcore/97}/meta | 0 config/rootfiles/{core => oldcore}/97/update.sh | 0 config/rootfiles/{core/99 => oldcore/98}/exclude | 0 .../oldcore/{94 => 98}/filelists/armv5tel/glibc | 0 .../rootfiles/{core => oldcore}/98/filelists/files | 0 .../oldcore/{94 => 98}/filelists/i586/glibc | 0 .../{core => oldcore}/98/filelists/x86_64/glibc | 0 config/rootfiles/oldcore/{95 => 98}/meta | 0 config/rootfiles/{core => oldcore}/98/update.sh | 0 config/rootfiles/packages/bird | 4 + config/rootfiles/packages/dnsdist | 3 + .../packages/{mediatomb => mediatomb.off} | 0 config/rootfiles/packages/nano | 2 + config/rootfiles/packages/owncloud | 653 ++--- config/udev/60-net.rules | 2 +- config/xen-image/xen-image-maker.sh | 1 + doc/language_issues.de | 2 - doc/language_issues.en | 2 - doc/language_issues.es | 3 +- doc/language_issues.fr | 3 +- doc/language_issues.it | 3 +- doc/language_issues.nl | 3 +- doc/language_issues.pl | 3 +- doc/language_issues.ru | 3 +- doc/language_issues.tr | 3 +- doc/language_missings | 4 + html/cgi-bin/logs.cgi/firewalllog.dat | 492 ++-- html/cgi-bin/logs.cgi/firewalllogcountry.dat | 520 ++-- html/cgi-bin/logs.cgi/firewalllogip.dat | 435 ++- html/cgi-bin/logs.cgi/firewalllogport.dat | 405 ++- html/cgi-bin/logs.cgi/showrequestfromcountry.dat | 378 +-- html/cgi-bin/logs.cgi/showrequestfromip.dat | 300 +- html/cgi-bin/logs.cgi/showrequestfromport.dat | 302 +- html/cgi-bin/optionsfw.cgi | 32 +- html/cgi-bin/ovpnmain.cgi | 2 +- html/cgi-bin/qos.cgi | 9 +- html/cgi-bin/webaccess.cgi | 25 +- langs/de/cgi-bin/de.pl | 1 + langs/en/cgi-bin/en.pl | 1 + lfs/Config | 5 +- lfs/{xz => ath10k-firmware} | 24 +- lfs/backports | 32 +- lfs/bind | 4 +- lfs/binutils | 21 +- lfs/{cmake => bird} | 29 +- lfs/bison | 12 +- lfs/ccache | 3 +- lfs/cleanup-toolchain | 1 - lfs/cmake | 4 +- lfs/configroot | 10 + lfs/dhcpcd | 4 +- lfs/{cmake => dnsdist} | 30 +- lfs/dnsmasq | 35 +- lfs/flash-images | 15 +- lfs/gcc | 113 +- lfs/glibc | 4 +- lfs/grep | 6 +- lfs/grub | 1 + lfs/{bison => libmpc} | 16 +- lfs/linux | 49 +- lfs/{bison => lua} | 19 +- lfs/m4 | 12 +- lfs/{xz => mt7601u-firmware} | 24 +- lfs/nano | 8 +- lfs/ntp | 7 +- lfs/openvpn | 6 +- lfs/owncloud | 6 +- lfs/rsync | 8 +- lfs/sed | 6 +- lfs/squid | 5 + lfs/tzdata | 8 +- lfs/u-boot | 2 + lfs/xz | 5 +- make.sh | 19 +- src/initscripts/init.d/dnsdist | 46 + src/initscripts/init.d/firewall | 85 +- src/initscripts/init.d/functions | 2 +- src/initscripts/init.d/networking/dhcpcd.exe | 7 - src/initscripts/init.d/ntp | 4 +- src/misc-progs/qosctrl.c | 42 +- src/misc-progs/timectrl.c | 2 +- src/misc-progs/wirelessctrl.c | 15 +- src/pakfire/pakfire.conf | 2 +- src/paks/linux-pae/install.sh | 1 + ...ot-v2-fs-fat-read-fix-fat16-ls-read-issue.patch | 128 + src/patches/arm-multi-grsec-compile-fixes.patch | 23 + ... => backports-4.2.6-1-add_usbnet_modules.patch} | 3067 +++++++++----------- ...ty.patch => backports-4.2.6-1-grsecurity.patch} | 1095 ++++--- .../backports-4.2.6-1-mt7601_upstream_fixes.patch | 441 +++ .../binutils-2.22-pt-pax-flags-20111121.patch | 1859 ------------ .../binutils-2.24-pt-pax-flags-20131231.patch | 1030 +++++++ ...q-Add-support-to-read-ISC-DHCP-lease-file.patch | 14 +- ...TL_parameter_to_--host-record_and_--cname.patch | 265 ++ ...01-include_0_0_0_0_8_in_DNS_rebind_checks.patch | 41 - .../dnsmasq/002-Add_--dhcp-ttl_option.patch | 117 + ...subnet_to_allow_arbitary_subnet_addresses.patch | 271 -- src/patches/dnsmasq/003-Update_CHANGELOG.patch | 17 + ...h_zones_locally_when_localise_queries_set.patch | 34 - .../dnsmasq/004-Add_--tftp-mtu_option.patch | 136 + .../004-fix_behaviour_of_empty_dhcp-option.patch | 38 - ...ease_length_to_TTL_when_--dhcp-ttl_in_use.patch | 37 + ...ution_to_ENOMEM_error_with_IPv6_multicast.patch | 50 - ...page_on_RDNSS_set_in_router_advertisement.patch | 35 - ...gned_dangling_CNAME_replies_to_DS_queries.patch | 30 - ...6_option_56_does_not_hold_an_address_list.patch | 25 - ...pect_the_--no_resolv_flag_in_inotify_code.patch | 47 - ..._5e3e464ac4022ee0b3794513abe510817e2cf3ca.patch | 26 - ...11-Catch_errors_from_sendmsg_in_DHCP_code.patch | 32 - ...12-Update_list_of_subnet_for_--bogus-priv.patch | 48 - ...y_address_from_DNS_overlays_A_record_from.patch | 43 - ...14-Handle_unknown_DS_hash_algos_correctly.patch | 39 - .../015-Fix_crash_at_start_up_with_conf-dir.patch | 38 - ...ajor_rationalisation_of_DNSSEC_validation.patch | 2209 -------------- ...hing_RRSIGs_and_returning_them_from_cache.patch | 612 ---- ...caches_DS_records_to_a_more_logical_place.patch | 269 -- ...lise_RR-filtering_code_for_use_with_EDNS0.patch | 755 ----- .../dnsmasq/020-DNSSEC_validation_tweak.patch | 134 - ...1-Tweaks_to_EDNS0_handling_in_DNS_replies.patch | 133 - ..._code_Check_zone_status_is_NSEC_proof_bad.patch | 409 --- ...023-Fix_brace_botch_in_dnssec_validate_ds.patch | 98 - ...ning_which_DNSSEC_sig_algos_are_supported.patch | 145 - src/patches/gcc/gcc-fix-inlining-issues.patch | 1064 +++++++ src/patches/gcc/gcc44-build-id.patch | 52 - src/patches/gcc/gcc44-c++-builtin-redecl.patch | 102 - src/patches/gcc/gcc44-i386-libgomp.patch | 61 - src/patches/gcc/gcc44-no-add-needed.patch | 52 - src/patches/gcc/gcc44-pr33763.patch | 153 - src/patches/gcc/gcc44-rh330771.patch | 34 - src/patches/gcc/gcc44-rh533181.patch | 153 - src/patches/gcc/gcc44-rh610785.patch | 74 - src/patches/gcc/gcc44-unwind-debug-hook.patch | 51 - src/patches/gcc/gcc49-i386-libgomp.patch | 11 + ...no-rpath.patch => gcc49-libtool-no-rpath.patch} | 0 src/patches/gcc/gcc49-no-add-needed.patch | 50 + src/patches/gcc/gcc49-pr38757.patch | 106 + src/patches/gcc/gcc49-pr64336.patch | 17 + src/patches/glibc/glibc-mq_open.patch | 34 + src/patches/linux-3.10-dvb_tevi_s482.patch | 240 -- ...-hyperv-Get-rid-of-the-rndis_filter_packe.patch | 129 + ...support-for-virtual-Receive-Side-Scaling-.patch | 917 ++++++ ...ivers-net-hyperv-Cleanup-the-receive-path.patch | 112 + ...0002-hyperv-Remove-recv_pkt_list-and-lock.patch | 384 +++ ...-hyperv-Cleanup-the-netvsc-receive-callba.patch | 101 + ...rv-Simplify-the-send_completion-variables.patch | 105 + ...latest-NetVSP-versions-to-auto-negotiatio.patch | 171 ++ ...Enable-sendbuf-mechanism-on-the-send-path.patch | 407 +++ ...-for-netvsc-build-without-CONFIG_SYSFS-fl.patch | 42 + ...vers-net-hyperv-Enable-scatter-gather-I-O.patch | 212 ++ ...-Drivers-net-hyperv-Cleanup-the-send-path.patch | 266 ++ .../0006-net-get-rid-of-SET_ETHTOOL_OPS.patch | 44 + ...rs-net-hyperv-Enable-offloads-on-the-host.patch | 196 ++ ...Add-hash-value-into-RNDIS-Per-packet-info.patch | 93 + ...-hyperv-Enable-receive-side-IP-checksum-o.patch | 147 + ...apparent-cut-n-paste-error-in-send-path-t.patch | 32 + ...-hyperv-Enable-send-side-checksum-offload.patch | 140 + ...-Fix-error-return-code-in-netvsc_init_buf.patch | 34 + ...vers-net-hyperv-Enable-large-send-offload.patch | 153 + ...010-hyperv-Fix-a-bug-in-netvsc_start_xmit.patch | 47 + ...e-the-receive-buffer-size-for-legacy-hos.patch} | 14 +- .../0011-hyperv-Fix-a-bug-in-netvsc_send.patch | 68 + ...-hyperv-Allocate-memory-for-all-possible-.patch | 34 + ...-hyperv-Negotiate-suitable-ndis-version-f.patch | 32 + ...rs-net-hyperv-Address-UDP-checksum-issues.patch | 111 + ...5-hyperv-Properly-handle-checksum-offload.patch | 42 + ...support-for-virtual-Receive-Side-Scaling-.patch | 917 ++++++ ...0017-hyperv-Remove-recv_pkt_list-and-lock.patch | 384 +++ ...rv-Simplify-the-send_completion-variables.patch | 105 + ...Enable-sendbuf-mechanism-on-the-send-path.patch | 407 +++ ...-for-netvsc-build-without-CONFIG_SYSFS-fl.patch | 42 + ...Add-hash-value-into-RNDIS-Per-packet-info.patch | 93 + ...apparent-cut-n-paste-error-in-send-path-t.patch | 32 + ...-Fix-error-return-code-in-netvsc_init_buf.patch | 34 + .../0024-hyperv-Fix-a-bug-in-netvsc_send.patch | 68 + ...hv-vmbus-Support-per-channel-driver-state.patch | 51 + src/patches/lua-5.3.0-autotoolize.patch | 192 ++ src/patches/ntp-fix-sycing-with-local-clock.patch | 23 - src/patches/squid-3.4-13230.patch | 44 + .../squid-3.4.14-fix-max-file-descriptors.patch | 21 + src/ppp/ip-up | 2 +- src/scripts/backupiso | 4 +- src/setup/netstuff.c | 8 +- src/setup/setup.h | 2 + tools/make-functions | 8 +- 277 files changed, 18042 insertions(+), 15013 deletions(-) create mode 100644 config/dhcpc/dhcpcd-hooks/10-mtu create mode 100644 config/etc/modprobe.d/nf_conntrack.conf create mode 100644 config/rootfiles/common/ath10k-firmware create mode 100644 config/rootfiles/common/libmpc create mode 100644 config/rootfiles/common/lua create mode 100644 config/rootfiles/common/mt7601u-firmware rename config/rootfiles/core/{96 => 100}/exclude (100%) copy config/rootfiles/{oldcore/77 => core/100}/filelists/armv5tel/binutils (100%) copy config/rootfiles/{oldcore/77 => core/100}/filelists/armv5tel/gcc (100%) rename config/rootfiles/core/{98 => 100}/filelists/armv5tel/glibc (100%) copy config/rootfiles/{oldcore/95 => core/100}/filelists/armv5tel/linux-kirkwood (100%) copy config/rootfiles/{oldcore/95 => core/100}/filelists/armv5tel/linux-multi (100%) copy config/rootfiles/{oldcore/95 => core/100}/filelists/armv5tel/linux-rpi (100%) create mode 120000 config/rootfiles/core/100/filelists/ath10k-firmware copy config/rootfiles/{oldcore/94 => core/100}/filelists/bind (100%) create mode 120000 config/rootfiles/core/100/filelists/diffutils rename config/rootfiles/core/{96 => 100}/filelists/dnsmasq (100%) create mode 100644 config/rootfiles/core/100/filelists/files copy config/rootfiles/{oldcore/89 => core/100}/filelists/grep (100%) copy config/rootfiles/{oldcore/77 => core/100}/filelists/i586/binutils (100%) copy config/rootfiles/{oldcore/77 => core/100}/filelists/i586/gcc (100%) rename config/rootfiles/core/{98 => 100}/filelists/i586/glibc (100%) rename config/rootfiles/core/{96 => 100}/filelists/i586/grub (100%) copy config/rootfiles/{oldcore/95 => core/100}/filelists/i586/linux (100%) copy config/rootfiles/{oldcore/95 => core/100}/filelists/i586/linux-initrd (100%) rename config/rootfiles/core/{97 => 100}/filelists/i586/openssl-sse2 (100%) create mode 120000 config/rootfiles/core/100/filelists/libmpc create mode 120000 config/rootfiles/core/100/filelists/lua create mode 120000 config/rootfiles/core/100/filelists/mt7601u-firmware copy config/rootfiles/{oldcore/66 => core/100}/filelists/ncurses (100%) rename config/rootfiles/core/{96 => 100}/filelists/ntp (100%) rename config/rootfiles/core/{97 => 100}/filelists/openssh (100%) rename config/rootfiles/core/{97 => 100}/filelists/openssl (100%) copy config/rootfiles/{oldcore/87 => core/100}/filelists/openvpn (100%) copy config/rootfiles/{oldcore/66 => core/100}/filelists/sed (100%) copy config/rootfiles/{oldcore/94 => core/100}/filelists/squid (100%) copy config/rootfiles/{oldcore/90 => core/100}/filelists/tzdata (100%) create mode 120000 config/rootfiles/core/100/filelists/x86_64/binutils create mode 120000 config/rootfiles/core/100/filelists/x86_64/gcc copy config/rootfiles/core/{98 => 100}/filelists/x86_64/glibc (100%) copy config/rootfiles/core/{96 => 100}/filelists/x86_64/grub (100%) copy config/rootfiles/{oldcore/95 => core/100}/filelists/x86_64/linux (100%) copy config/rootfiles/{oldcore/95 => core/100}/filelists/x86_64/linux-initrd (100%) copy config/rootfiles/{oldcore/90 => core/100}/filelists/xz (100%) rename config/rootfiles/core/{98 => 100}/meta (100%) create mode 100644 config/rootfiles/core/100/update.sh delete mode 100644 config/rootfiles/core/97/filelists/files rename config/rootfiles/{core/98 => oldcore/96}/exclude (100%) rename config/rootfiles/{core => oldcore}/96/filelists/curl (100%) rename config/rootfiles/{core => oldcore}/96/filelists/dma (100%) copy config/rootfiles/oldcore/{94 => 96}/filelists/dnsmasq (100%) rename config/rootfiles/{core => oldcore}/96/filelists/files (100%) copy config/rootfiles/oldcore/{87 => 96}/filelists/i586/grub (100%) rename config/rootfiles/{core => oldcore}/96/filelists/i586/openssl-sse2 (100%) rename config/rootfiles/{core => oldcore}/96/filelists/i586/strongswan-padlock (100%) rename config/rootfiles/{core => oldcore}/96/filelists/libnet (100%) rename config/rootfiles/{core => oldcore}/96/filelists/mdadm (100%) copy config/rootfiles/oldcore/{95 => 96}/filelists/ntp (100%) rename config/rootfiles/{core => oldcore}/96/filelists/openssl (100%) rename config/rootfiles/{core => oldcore}/96/filelists/rrdtool (100%) rename config/rootfiles/{core => oldcore}/96/filelists/strongswan (100%) rename config/rootfiles/{core => oldcore}/96/filelists/x86_64/grub (100%) rename config/rootfiles/{core/97 => oldcore/96}/meta (100%) rename config/rootfiles/{core => oldcore}/96/update.sh (100%) rename config/rootfiles/{core => oldcore}/97/exclude (100%) create mode 100644 config/rootfiles/oldcore/97/filelists/files rename config/rootfiles/{core => oldcore}/97/filelists/hwdata (100%) copy config/rootfiles/oldcore/{91 => 97}/filelists/i586/openssl-sse2 (100%) copy config/rootfiles/oldcore/{94 => 97}/filelists/openssh (100%) copy config/rootfiles/oldcore/{92 => 97}/filelists/openssl (100%) rename config/rootfiles/{core/96 => oldcore/97}/meta (100%) rename config/rootfiles/{core => oldcore}/97/update.sh (100%) copy config/rootfiles/{core/99 => oldcore/98}/exclude (100%) copy config/rootfiles/oldcore/{94 => 98}/filelists/armv5tel/glibc (100%) rename config/rootfiles/{core => oldcore}/98/filelists/files (100%) copy config/rootfiles/oldcore/{94 => 98}/filelists/i586/glibc (100%) rename config/rootfiles/{core => oldcore}/98/filelists/x86_64/glibc (100%) copy config/rootfiles/oldcore/{95 => 98}/meta (100%) rename config/rootfiles/{core => oldcore}/98/update.sh (100%) create mode 100644 config/rootfiles/packages/bird create mode 100644 config/rootfiles/packages/dnsdist rename config/rootfiles/packages/{mediatomb => mediatomb.off} (100%) copy lfs/{xz => ath10k-firmware} (83%) copy lfs/{cmake => bird} (89%) copy lfs/{cmake => dnsdist} (87%) copy lfs/{bison => libmpc} (88%) copy lfs/{bison => lua} (86%) copy lfs/{xz => mt7601u-firmware} (83%) create mode 100644 src/initscripts/init.d/dnsdist create mode 100644 src/patches/U-Boot-v2-fs-fat-read-fix-fat16-ls-read-issue.patch create mode 100644 src/patches/arm-multi-grsec-compile-fixes.patch rename src/patches/{backports-3.18.1-1-add_usbnet_modules.patch => backports-4.2.6-1-add_usbnet_modules.patch} (93%) rename src/patches/{backports-3.18.1-1-grsecurity.patch => backports-4.2.6-1-grsecurity.patch} (72%) create mode 100644 src/patches/backports-4.2.6-1-mt7601_upstream_fixes.patch delete mode 100644 src/patches/binutils-2.22-pt-pax-flags-20111121.patch create mode 100644 src/patches/binutils-2.24-pt-pax-flags-20131231.patch create mode 100644 src/patches/dnsmasq/001-Add_TTL_parameter_to_--host-record_and_--cname.patch delete mode 100644 src/patches/dnsmasq/001-include_0_0_0_0_8_in_DNS_rebind_checks.patch create mode 100644 src/patches/dnsmasq/002-Add_--dhcp-ttl_option.patch delete mode 100644 src/patches/dnsmasq/002-enhance_add_subnet_to_allow_arbitary_subnet_addresses.patch create mode 100644 src/patches/dnsmasq/003-Update_CHANGELOG.patch delete mode 100644 src/patches/dnsmasq/003-dont_answer_non_auth_queries_for_auth_zones_locally_when_localise_queries_set.patch create mode 100644 src/patches/dnsmasq/004-Add_--tftp-mtu_option.patch delete mode 100644 src/patches/dnsmasq/004-fix_behaviour_of_empty_dhcp-option.patch create mode 100644 src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch delete mode 100644 src/patches/dnsmasq/005-suggest_solution_to_ENOMEM_error_with_IPv6_multicast.patch delete mode 100644 src/patches/dnsmasq/006-clarify_man_page_on_RDNSS_set_in_router_advertisement.patch delete mode 100644 src/patches/dnsmasq/007-handle_signed_dangling_CNAME_replies_to_DS_queries.patch delete mode 100644 src/patches/dnsmasq/008-DHCPv6_option_56_does_not_hold_an_address_list.patch delete mode 100644 src/patches/dnsmasq/009-Respect_the_--no_resolv_flag_in_inotify_code.patch delete mode 100644 src/patches/dnsmasq/010-Rationalise_5e3e464ac4022ee0b3794513abe510817e2cf3ca.patch delete mode 100644 src/patches/dnsmasq/011-Catch_errors_from_sendmsg_in_DHCP_code.patch delete mode 100644 src/patches/dnsmasq/012-Update_list_of_subnet_for_--bogus-priv.patch delete mode 100644 src/patches/dnsmasq/013-Fix_crash_when_empty_address_from_DNS_overlays_A_record_from.patch delete mode 100644 src/patches/dnsmasq/014-Handle_unknown_DS_hash_algos_correctly.patch delete mode 100644 src/patches/dnsmasq/015-Fix_crash_at_start_up_with_conf-dir.patch delete mode 100644 src/patches/dnsmasq/016-Major_rationalisation_of_DNSSEC_validation.patch delete mode 100644 src/patches/dnsmasq/017-Abandon_caching_RRSIGs_and_returning_them_from_cache.patch delete mode 100644 src/patches/dnsmasq/018-Move_code_which_caches_DS_records_to_a_more_logical_place.patch delete mode 100644 src/patches/dnsmasq/019-Generalise_RR-filtering_code_for_use_with_EDNS0.patch delete mode 100644 src/patches/dnsmasq/020-DNSSEC_validation_tweak.patch delete mode 100644 src/patches/dnsmasq/021-Tweaks_to_EDNS0_handling_in_DNS_replies.patch delete mode 100644 src/patches/dnsmasq/022-Tidy_up_DNSSEC_non-existence_code_Check_zone_status_is_NSEC_proof_bad.patch delete mode 100644 src/patches/dnsmasq/023-Fix_brace_botch_in_dnssec_validate_ds.patch delete mode 100644 src/patches/dnsmasq/024-Do_a_better_job_of_determining_which_DNSSEC_sig_algos_are_supported.patch create mode 100644 src/patches/gcc/gcc-fix-inlining-issues.patch delete mode 100644 src/patches/gcc/gcc44-build-id.patch delete mode 100644 src/patches/gcc/gcc44-c++-builtin-redecl.patch delete mode 100644 src/patches/gcc/gcc44-i386-libgomp.patch delete mode 100644 src/patches/gcc/gcc44-no-add-needed.patch delete mode 100644 src/patches/gcc/gcc44-pr33763.patch delete mode 100644 src/patches/gcc/gcc44-rh330771.patch delete mode 100644 src/patches/gcc/gcc44-rh533181.patch delete mode 100644 src/patches/gcc/gcc44-rh610785.patch delete mode 100644 src/patches/gcc/gcc44-unwind-debug-hook.patch create mode 100644 src/patches/gcc/gcc49-i386-libgomp.patch rename src/patches/gcc/{gcc44-libtool-no-rpath.patch => gcc49-libtool-no-rpath.patch} (100%) create mode 100644 src/patches/gcc/gcc49-no-add-needed.patch create mode 100644 src/patches/gcc/gcc49-pr38757.patch create mode 100644 src/patches/gcc/gcc49-pr64336.patch create mode 100644 src/patches/glibc/glibc-mq_open.patch delete mode 100644 src/patches/linux-3.10-dvb_tevi_s482.patch create mode 100644 src/patches/linux/0001-Drivers-net-hyperv-Get-rid-of-the-rndis_filter_packe.patch create mode 100644 src/patches/linux/0001-hyperv-Add-support-for-virtual-Receive-Side-Scaling-.patch create mode 100644 src/patches/linux/0002-Drivers-net-hyperv-Cleanup-the-receive-path.patch create mode 100644 src/patches/linux/0002-hyperv-Remove-recv_pkt_list-and-lock.patch create mode 100644 src/patches/linux/0003-Drivers-net-hyperv-Cleanup-the-netvsc-receive-callba.patch create mode 100644 src/patches/linux/0003-hyperv-Simplify-the-send_completion-variables.patch create mode 100644 src/patches/linux/0004-hyperv-Add-latest-NetVSP-versions-to-auto-negotiatio.patch create mode 100644 src/patches/linux/0004-hyperv-Enable-sendbuf-mechanism-on-the-send-path.patch create mode 100644 src/patches/linux/0005-Add-support-for-netvsc-build-without-CONFIG_SYSFS-fl.patch create mode 100644 src/patches/linux/0005-Drivers-net-hyperv-Enable-scatter-gather-I-O.patch create mode 100644 src/patches/linux/0006-Drivers-net-hyperv-Cleanup-the-send-path.patch create mode 100644 src/patches/linux/0006-net-get-rid-of-SET_ETHTOOL_OPS.patch create mode 100644 src/patches/linux/0007-Drivers-net-hyperv-Enable-offloads-on-the-host.patch create mode 100644 src/patches/linux/0007-hyperv-Add-hash-value-into-RNDIS-Per-packet-info.patch create mode 100644 src/patches/linux/0008-Drivers-net-hyperv-Enable-receive-side-IP-checksum-o.patch create mode 100644 src/patches/linux/0008-hyperv-fix-apparent-cut-n-paste-error-in-send-path-t.patch create mode 100644 src/patches/linux/0009-Drivers-net-hyperv-Enable-send-side-checksum-offload.patch create mode 100644 src/patches/linux/0009-hyperv-Fix-error-return-code-in-netvsc_init_buf.patch create mode 100644 src/patches/linux/0010-Drivers-net-hyperv-Enable-large-send-offload.patch create mode 100644 src/patches/linux/0010-hyperv-Fix-a-bug-in-netvsc_start_xmit.patch rename src/patches/{linux-3.14.x-hyperv-2008-fix.patch => linux/0011-hyperv-Change-the-receive-buffer-size-for-legacy-hos.patch} (81%) create mode 100644 src/patches/linux/0011-hyperv-Fix-a-bug-in-netvsc_send.patch create mode 100644 src/patches/linux/0012-Drivers-net-hyperv-Allocate-memory-for-all-possible-.patch create mode 100644 src/patches/linux/0013-Drivers-net-hyperv-Negotiate-suitable-ndis-version-f.patch create mode 100644 src/patches/linux/0014-Drivers-net-hyperv-Address-UDP-checksum-issues.patch create mode 100644 src/patches/linux/0015-hyperv-Properly-handle-checksum-offload.patch create mode 100644 src/patches/linux/0016-hyperv-Add-support-for-virtual-Receive-Side-Scaling-.patch create mode 100644 src/patches/linux/0017-hyperv-Remove-recv_pkt_list-and-lock.patch create mode 100644 src/patches/linux/0018-hyperv-Simplify-the-send_completion-variables.patch create mode 100644 src/patches/linux/0019-hyperv-Enable-sendbuf-mechanism-on-the-send-path.patch create mode 100644 src/patches/linux/0020-Add-support-for-netvsc-build-without-CONFIG_SYSFS-fl.patch create mode 100644 src/patches/linux/0021-hyperv-Add-hash-value-into-RNDIS-Per-packet-info.patch create mode 100644 src/patches/linux/0022-hyperv-fix-apparent-cut-n-paste-error-in-send-path-t.patch create mode 100644 src/patches/linux/0023-hyperv-Fix-error-return-code-in-netvsc_init_buf.patch create mode 100644 src/patches/linux/0024-hyperv-Fix-a-bug-in-netvsc_send.patch create mode 100644 src/patches/linux/0025-Drivers-hv-vmbus-Support-per-channel-driver-state.patch create mode 100644 src/patches/lua-5.3.0-autotoolize.patch delete mode 100644 src/patches/ntp-fix-sycing-with-local-clock.patch create mode 100644 src/patches/squid-3.4-13230.patch create mode 100644 src/patches/squid-3.4.14-fix-max-file-descriptors.patch
Difference in files: diff --git a/config/dhcpc/dhcpcd-hooks/10-mtu b/config/dhcpc/dhcpcd-hooks/10-mtu new file mode 100644 index 0000000..49e0519 --- /dev/null +++ b/config/dhcpc/dhcpcd-hooks/10-mtu @@ -0,0 +1,31 @@ +# Configure the MTU for the interface + +eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) + +set_mtu() +{ + local mtu=$1 + ip link set "$interface" mtu "$mtu" + + # test for buggy nic that lose link at mtu set... + carrier=`cat /sys/class/net/$interface/carrier` + if [ "$carrier" == "0" ]; then + syslog info "Warning! Carrier loss after MTU set. Reinit ..." + ip link set "$interface" down + ip link set "$interface" up + fi +} +if [ -n "$new_interface_mtu" ] && $if_up; then + if [ $RED_DHCP_FORCE_MTU -ge 576 ]; then + new_interface_mtu=$RED_DHCP_FORCE_MTU + fi + if [ ! "$new_interface_mtu" == "$ifmtu" ]; then + # The smalled MTU dhcpcd can work with is 576 + if [ "$new_interface_mtu" -gt 576 ]; then + if set_mtu "$new_interface_mtu"; then + syslog info "MTU set to $new_interface_mtu" + fi + fi + fi +fi + diff --git a/config/dracut/dracut.conf b/config/dracut/dracut.conf index 34e6a66..52bba9c 100644 --- a/config/dracut/dracut.conf +++ b/config/dracut/dracut.conf @@ -21,6 +21,9 @@ # additional kernel modules to the default #add_drivers+=""
+# skip kernel modules (marvell sdio and compat from backports) +omit_drivers+="libertas libertas_sdio mwifiex mwifiex_sdio compat" + # list of kernel filesystem modules to be included in the generic initramfs filesystems+="reiserfs vfat xfs"
diff --git a/config/etc/modprobe.d/nf_conntrack.conf b/config/etc/modprobe.d/nf_conntrack.conf new file mode 100644 index 0000000..d5a1813 --- /dev/null +++ b/config/etc/modprobe.d/nf_conntrack.conf @@ -0,0 +1,2 @@ +# Disable automatic conntrack helper assignment +options nf_conntrack nf_conntrack_helper=0 diff --git a/config/firewall/firewall-policy b/config/firewall/firewall-policy index 4ba1ace..cbba3b0 100755 --- a/config/firewall/firewall-policy +++ b/config/firewall/firewall-policy @@ -60,6 +60,11 @@ HAVE_OPENVPN="true" # Allow access from GREEN iptables -A POLICYIN -i "${GREEN_DEV}" -j ACCEPT
+# Allow access from BLUE +if [ "${HAVE_BLUE}" = "true" ] && [ -n "${BLUE_DEV}" ]; then + iptables -A POLICYIN -i "${BLUE_DEV}" -j ACCEPT +fi + # IPsec INPUT case "${HAVE_IPSEC},${POLICY}" in true,MODE1) ;; diff --git a/config/kernel/kernel.config.armv5tel-ipfire-kirkwood b/config/kernel/kernel.config.armv5tel-ipfire-kirkwood index 325add2..91f90c6 100644 --- a/config/kernel/kernel.config.armv5tel-ipfire-kirkwood +++ b/config/kernel/kernel.config.armv5tel-ipfire-kirkwood @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 3.14.53 Kernel Configuration +# Linux/arm 3.14.64 Kernel Configuration # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -196,8 +196,8 @@ CONFIG_SECCOMP_FILTER=y CONFIG_HAVE_CC_STACKPROTECTOR=y CONFIG_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR_NONE is not set -CONFIG_CC_STACKPROTECTOR_REGULAR=y -# CONFIG_CC_STACKPROTECTOR_STRONG is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y CONFIG_HAVE_CONTEXT_TRACKING=y CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y @@ -4922,6 +4922,7 @@ CONFIG_NFS_V4_SECURITY_LABEL=y CONFIG_NFS_FSCACHE=y # CONFIG_NFS_USE_LEGACY_DNS is not set CONFIG_NFS_USE_KERNEL_DNS=y +CONFIG_NFS_DEBUG=y CONFIG_NFSD=m CONFIG_NFSD_V2_ACL=y CONFIG_NFSD_V3=y @@ -4937,7 +4938,7 @@ CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m CONFIG_SUNRPC_BACKCHANNEL=y CONFIG_RPCSEC_GSS_KRB5=m -# CONFIG_SUNRPC_DEBUG is not set +CONFIG_SUNRPC_DEBUG=y # CONFIG_CEPH_FS is not set CONFIG_CIFS=m CONFIG_CIFS_STATS=y @@ -5238,8 +5239,7 @@ CONFIG_GRKERNSEC_PROC_MEMMAP=y CONFIG_GRKERNSEC_BRUTE=y CONFIG_GRKERNSEC_MODHARDEN=y CONFIG_GRKERNSEC_HIDESYM=y -CONFIG_GRKERNSEC_RANDSTRUCT=y -CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE=y +# CONFIG_GRKERNSEC_RANDSTRUCT is not set CONFIG_GRKERNSEC_KERN_LOCKOUT=y
# diff --git a/config/kernel/kernel.config.armv5tel-ipfire-multi b/config/kernel/kernel.config.armv5tel-ipfire-multi index 9729903..0bb4a76 100644 --- a/config/kernel/kernel.config.armv5tel-ipfire-multi +++ b/config/kernel/kernel.config.armv5tel-ipfire-multi @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 3.14.53 Kernel Configuration +# Linux/arm 3.14.64 Kernel Configuration # CONFIG_ARM=y CONFIG_MIGHT_HAVE_PCI=y @@ -219,8 +219,8 @@ CONFIG_HAVE_ARCH_SECCOMP_FILTER=y CONFIG_HAVE_CC_STACKPROTECTOR=y CONFIG_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR_NONE is not set -CONFIG_CC_STACKPROTECTOR_REGULAR=y -# CONFIG_CC_STACKPROTECTOR_STRONG is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y CONFIG_HAVE_CONTEXT_TRACKING=y CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y @@ -5410,6 +5410,7 @@ CONFIG_NFS_V4_SECURITY_LABEL=y CONFIG_NFS_FSCACHE=y # CONFIG_NFS_USE_LEGACY_DNS is not set CONFIG_NFS_USE_KERNEL_DNS=y +CONFIG_NFS_DEBUG=y CONFIG_NFSD=m CONFIG_NFSD_V2_ACL=y CONFIG_NFSD_V3=y @@ -5425,7 +5426,7 @@ CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m CONFIG_SUNRPC_BACKCHANNEL=y CONFIG_RPCSEC_GSS_KRB5=m -# CONFIG_SUNRPC_DEBUG is not set +CONFIG_SUNRPC_DEBUG=y # CONFIG_CEPH_FS is not set CONFIG_CIFS=m CONFIG_CIFS_STATS=y @@ -5726,8 +5727,7 @@ CONFIG_GRKERNSEC_PROC_MEMMAP=y CONFIG_GRKERNSEC_BRUTE=y CONFIG_GRKERNSEC_MODHARDEN=y CONFIG_GRKERNSEC_HIDESYM=y -CONFIG_GRKERNSEC_RANDSTRUCT=y -CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE=y +# CONFIG_GRKERNSEC_RANDSTRUCT is not set CONFIG_GRKERNSEC_KERN_LOCKOUT=y CONFIG_GRKERNSEC_OLD_ARM_USERLAND=y
diff --git a/config/kernel/kernel.config.armv5tel-ipfire-rpi b/config/kernel/kernel.config.armv5tel-ipfire-rpi index 6e584cb..989b2d6 100644 --- a/config/kernel/kernel.config.armv5tel-ipfire-rpi +++ b/config/kernel/kernel.config.armv5tel-ipfire-rpi @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 3.14.53 Kernel Configuration +# Linux/arm 3.14.64 Kernel Configuration # CONFIG_ARM=y CONFIG_SYS_SUPPORTS_APM_EMULATION=y @@ -196,8 +196,8 @@ CONFIG_SECCOMP_FILTER=y CONFIG_HAVE_CC_STACKPROTECTOR=y CONFIG_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR_NONE is not set -CONFIG_CC_STACKPROTECTOR_REGULAR=y -# CONFIG_CC_STACKPROTECTOR_STRONG is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y CONFIG_HAVE_CONTEXT_TRACKING=y CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y @@ -3526,6 +3526,7 @@ CONFIG_NFS_V4=m # CONFIG_NFS_FSCACHE is not set # CONFIG_NFS_USE_LEGACY_DNS is not set CONFIG_NFS_USE_KERNEL_DNS=y +CONFIG_NFS_DEBUG=y CONFIG_NFSD=m CONFIG_NFSD_V2_ACL=y CONFIG_NFSD_V3=y @@ -3540,7 +3541,7 @@ CONFIG_NFS_COMMON=y CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m CONFIG_RPCSEC_GSS_KRB5=m -# CONFIG_SUNRPC_DEBUG is not set +CONFIG_SUNRPC_DEBUG=y # CONFIG_CEPH_FS is not set CONFIG_CIFS=m CONFIG_CIFS_STATS=y @@ -3820,8 +3821,7 @@ CONFIG_GRKERNSEC_PROC_MEMMAP=y CONFIG_GRKERNSEC_BRUTE=y CONFIG_GRKERNSEC_MODHARDEN=y CONFIG_GRKERNSEC_HIDESYM=y -CONFIG_GRKERNSEC_RANDSTRUCT=y -CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE=y +# CONFIG_GRKERNSEC_RANDSTRUCT is not set CONFIG_GRKERNSEC_KERN_LOCKOUT=y CONFIG_GRKERNSEC_OLD_ARM_USERLAND=y
diff --git a/config/kernel/kernel.config.i586-ipfire b/config/kernel/kernel.config.i586-ipfire index 734bea6..b0d78e1 100644 --- a/config/kernel/kernel.config.i586-ipfire +++ b/config/kernel/kernel.config.i586-ipfire @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86 3.14.57 Kernel Configuration +# Linux/x86 3.14.64 Kernel Configuration # # CONFIG_64BIT is not set CONFIG_X86_32=y @@ -247,8 +247,8 @@ CONFIG_SECCOMP_FILTER=y CONFIG_HAVE_CC_STACKPROTECTOR=y CONFIG_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR_NONE is not set -CONFIG_CC_STACKPROTECTOR_REGULAR=y -# CONFIG_CC_STACKPROTECTOR_STRONG is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y CONFIG_HAVE_ARCH_SOFT_DIRTY=y @@ -5374,6 +5374,7 @@ CONFIG_NFS_V4_SECURITY_LABEL=y CONFIG_NFS_FSCACHE=y # CONFIG_NFS_USE_LEGACY_DNS is not set CONFIG_NFS_USE_KERNEL_DNS=y +CONFIG_NFS_DEBUG=y CONFIG_NFSD=m CONFIG_NFSD_V2_ACL=y CONFIG_NFSD_V3=y @@ -5389,7 +5390,7 @@ CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m CONFIG_SUNRPC_BACKCHANNEL=y CONFIG_RPCSEC_GSS_KRB5=m -# CONFIG_SUNRPC_DEBUG is not set +CONFIG_SUNRPC_DEBUG=y # CONFIG_CEPH_FS is not set CONFIG_CIFS=m CONFIG_CIFS_STATS=y @@ -5731,8 +5732,7 @@ CONFIG_GRKERNSEC_PROC_MEMMAP=y CONFIG_GRKERNSEC_BRUTE=y CONFIG_GRKERNSEC_MODHARDEN=y CONFIG_GRKERNSEC_HIDESYM=y -CONFIG_GRKERNSEC_RANDSTRUCT=y -CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE=y +# CONFIG_GRKERNSEC_RANDSTRUCT is not set CONFIG_GRKERNSEC_KERN_LOCKOUT=y
# diff --git a/config/kernel/kernel.config.i586-ipfire-pae b/config/kernel/kernel.config.i586-ipfire-pae index d6b5a7f..6272579 100644 --- a/config/kernel/kernel.config.i586-ipfire-pae +++ b/config/kernel/kernel.config.i586-ipfire-pae @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86 3.14.57 Kernel Configuration +# Linux/x86 3.14.64 Kernel Configuration # # CONFIG_64BIT is not set CONFIG_X86_32=y @@ -246,8 +246,8 @@ CONFIG_SECCOMP_FILTER=y CONFIG_HAVE_CC_STACKPROTECTOR=y CONFIG_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR_NONE is not set -CONFIG_CC_STACKPROTECTOR_REGULAR=y -# CONFIG_CC_STACKPROTECTOR_STRONG is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y CONFIG_HAVE_ARCH_TRANSPARENT_HUGEPAGE=y CONFIG_HAVE_ARCH_SOFT_DIRTY=y @@ -5417,6 +5417,7 @@ CONFIG_NFS_V4_SECURITY_LABEL=y CONFIG_NFS_FSCACHE=y # CONFIG_NFS_USE_LEGACY_DNS is not set CONFIG_NFS_USE_KERNEL_DNS=y +CONFIG_NFS_DEBUG=y CONFIG_NFSD=m CONFIG_NFSD_V2_ACL=y CONFIG_NFSD_V3=y @@ -5432,7 +5433,7 @@ CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m CONFIG_SUNRPC_BACKCHANNEL=y CONFIG_RPCSEC_GSS_KRB5=m -# CONFIG_SUNRPC_DEBUG is not set +CONFIG_SUNRPC_DEBUG=y # CONFIG_CEPH_FS is not set CONFIG_CIFS=m CONFIG_CIFS_STATS=y @@ -5772,8 +5773,7 @@ CONFIG_GRKERNSEC_PROC_MEMMAP=y CONFIG_GRKERNSEC_BRUTE=y CONFIG_GRKERNSEC_MODHARDEN=y CONFIG_GRKERNSEC_HIDESYM=y -CONFIG_GRKERNSEC_RANDSTRUCT=y -CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE=y +# CONFIG_GRKERNSEC_RANDSTRUCT is not set CONFIG_GRKERNSEC_KERN_LOCKOUT=y
# diff --git a/config/kernel/kernel.config.x86_64-ipfire b/config/kernel/kernel.config.x86_64-ipfire index 09503d7..b5e1575 100644 --- a/config/kernel/kernel.config.x86_64-ipfire +++ b/config/kernel/kernel.config.x86_64-ipfire @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86 3.14.57 Kernel Configuration +# Linux/x86 3.14.64 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y @@ -253,8 +253,8 @@ CONFIG_SECCOMP_FILTER=y CONFIG_HAVE_CC_STACKPROTECTOR=y CONFIG_CC_STACKPROTECTOR=y # CONFIG_CC_STACKPROTECTOR_NONE is not set -CONFIG_CC_STACKPROTECTOR_REGULAR=y -# CONFIG_CC_STACKPROTECTOR_STRONG is not set +# CONFIG_CC_STACKPROTECTOR_REGULAR is not set +CONFIG_CC_STACKPROTECTOR_STRONG=y CONFIG_HAVE_CONTEXT_TRACKING=y CONFIG_HAVE_VIRT_CPU_ACCOUNTING_GEN=y CONFIG_HAVE_IRQ_TIME_ACCOUNTING=y @@ -5235,6 +5235,7 @@ CONFIG_NFS_V4_SECURITY_LABEL=y CONFIG_NFS_FSCACHE=y # CONFIG_NFS_USE_LEGACY_DNS is not set CONFIG_NFS_USE_KERNEL_DNS=y +CONFIG_NFS_DEBUG=y CONFIG_NFSD=m CONFIG_NFSD_V2_ACL=y CONFIG_NFSD_V3=y @@ -5250,7 +5251,7 @@ CONFIG_SUNRPC=m CONFIG_SUNRPC_GSS=m CONFIG_SUNRPC_BACKCHANNEL=y CONFIG_RPCSEC_GSS_KRB5=m -# CONFIG_SUNRPC_DEBUG is not set +CONFIG_SUNRPC_DEBUG=y # CONFIG_CEPH_FS is not set CONFIG_CIFS=m CONFIG_CIFS_STATS=y @@ -5586,12 +5587,11 @@ CONFIG_GRKERNSEC_JIT_HARDEN=y # CONFIG_GRKERNSEC_PERF_HARDEN is not set CONFIG_GRKERNSEC_RAND_THREADSTACK=y CONFIG_GRKERNSEC_PROC_MEMMAP=y -CONFIG_GRKERNSEC_KSTACKOVERFLOW=y +# CONFIG_GRKERNSEC_KSTACKOVERFLOW is not set CONFIG_GRKERNSEC_BRUTE=y CONFIG_GRKERNSEC_MODHARDEN=y CONFIG_GRKERNSEC_HIDESYM=y -CONFIG_GRKERNSEC_RANDSTRUCT=y -CONFIG_GRKERNSEC_RANDSTRUCT_PERFORMANCE=y +# CONFIG_GRKERNSEC_RANDSTRUCT is not set CONFIG_GRKERNSEC_KERN_LOCKOUT=y
# diff --git a/config/rootfiles/common/armv5tel/binutils b/config/rootfiles/common/armv5tel/binutils index b3d281d..ba64237 100644 --- a/config/rootfiles/common/armv5tel/binutils +++ b/config/rootfiles/common/armv5tel/binutils @@ -47,12 +47,12 @@ #usr/lib/ldscripts/armelfb_linux_eabi.xsw #usr/lib/ldscripts/armelfb_linux_eabi.xu #usr/lib/ldscripts/armelfb_linux_eabi.xw -usr/lib/libbfd-2.22.so +usr/lib/libbfd-2.24.so #usr/lib/libbfd.a #usr/lib/libbfd.la #usr/lib/libbfd.so #usr/lib/libiberty.a -usr/lib/libopcodes-2.22.so +usr/lib/libopcodes-2.24.so #usr/lib/libopcodes.a #usr/lib/libopcodes.la #usr/lib/libopcodes.so diff --git a/config/rootfiles/common/armv5tel/gcc b/config/rootfiles/common/armv5tel/gcc index ee9d800..121ac17 100644 --- a/config/rootfiles/common/armv5tel/gcc +++ b/config/rootfiles/common/armv5tel/gcc @@ -2,762 +2,1054 @@ #usr/bin/armv5tel-unknown-linux-gnueabi-c++ #usr/bin/armv5tel-unknown-linux-gnueabi-g++ #usr/bin/armv5tel-unknown-linux-gnueabi-gcc -#usr/bin/armv5tel-unknown-linux-gnueabi-gcc-4.4.7 +#usr/bin/armv5tel-unknown-linux-gnueabi-gcc-4.9.3 +#usr/bin/armv5tel-unknown-linux-gnueabi-gcc-ar +#usr/bin/armv5tel-unknown-linux-gnueabi-gcc-nm +#usr/bin/armv5tel-unknown-linux-gnueabi-gcc-ranlib #usr/bin/c++ #usr/bin/cc #usr/bin/cpp #usr/bin/g++ #usr/bin/gcc -#usr/bin/gccbug +#usr/bin/gcc-ar +#usr/bin/gcc-nm +#usr/bin/gcc-ranlib #usr/bin/gcov #usr/include/c++ -#usr/include/c++/4.4.7 -#usr/include/c++/4.4.7/algorithm -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/atomic_word.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/basic_file.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/c++allocator.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/c++config.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/c++io.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/c++locale.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/cpu_defines.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/ctype_base.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/ctype_inline.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/ctype_noninline.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/cxxabi_tweaks.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/error_constants.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/extc++.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/gthr-default.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/gthr-posix.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/gthr-single.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/gthr-tpf.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/gthr.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/messages_members.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/os_defines.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/stdc++.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/stdtr1c++.h -#usr/include/c++/4.4.7/armv5tel-unknown-linux-gnueabi/bits/time_members.h -#usr/include/c++/4.4.7/array -#usr/include/c++/4.4.7/backward -#usr/include/c++/4.4.7/backward/auto_ptr.h -#usr/include/c++/4.4.7/backward/backward_warning.h -#usr/include/c++/4.4.7/backward/binders.h -#usr/include/c++/4.4.7/backward/hash_fun.h -#usr/include/c++/4.4.7/backward/hash_map -#usr/include/c++/4.4.7/backward/hash_set -#usr/include/c++/4.4.7/backward/hashtable.h -#usr/include/c++/4.4.7/backward/strstream -#usr/include/c++/4.4.7/bits -#usr/include/c++/4.4.7/bits/algorithmfwd.h -#usr/include/c++/4.4.7/bits/allocator.h -#usr/include/c++/4.4.7/bits/atomic_0.h -#usr/include/c++/4.4.7/bits/atomic_2.h -#usr/include/c++/4.4.7/bits/atomicfwd_c.h -#usr/include/c++/4.4.7/bits/atomicfwd_cxx.h -#usr/include/c++/4.4.7/bits/basic_ios.h -#usr/include/c++/4.4.7/bits/basic_ios.tcc -#usr/include/c++/4.4.7/bits/basic_string.h -#usr/include/c++/4.4.7/bits/basic_string.tcc -#usr/include/c++/4.4.7/bits/boost_concept_check.h -#usr/include/c++/4.4.7/bits/char_traits.h -#usr/include/c++/4.4.7/bits/cmath.tcc -#usr/include/c++/4.4.7/bits/codecvt.h -#usr/include/c++/4.4.7/bits/concept_check.h -#usr/include/c++/4.4.7/bits/cpp_type_traits.h -#usr/include/c++/4.4.7/bits/deque.tcc -#usr/include/c++/4.4.7/bits/forward_list.h -#usr/include/c++/4.4.7/bits/forward_list.tcc -#usr/include/c++/4.4.7/bits/fstream.tcc -#usr/include/c++/4.4.7/bits/functexcept.h -#usr/include/c++/4.4.7/bits/functional_hash.h -#usr/include/c++/4.4.7/bits/gslice.h -#usr/include/c++/4.4.7/bits/gslice_array.h -#usr/include/c++/4.4.7/bits/hashtable.h -#usr/include/c++/4.4.7/bits/indirect_array.h -#usr/include/c++/4.4.7/bits/ios_base.h -#usr/include/c++/4.4.7/bits/istream.tcc -#usr/include/c++/4.4.7/bits/list.tcc -#usr/include/c++/4.4.7/bits/locale_classes.h -#usr/include/c++/4.4.7/bits/locale_classes.tcc -#usr/include/c++/4.4.7/bits/locale_facets.h -#usr/include/c++/4.4.7/bits/locale_facets.tcc -#usr/include/c++/4.4.7/bits/locale_facets_nonio.h -#usr/include/c++/4.4.7/bits/locale_facets_nonio.tcc -#usr/include/c++/4.4.7/bits/localefwd.h -#usr/include/c++/4.4.7/bits/mask_array.h -#usr/include/c++/4.4.7/bits/move.h -#usr/include/c++/4.4.7/bits/ostream.tcc -#usr/include/c++/4.4.7/bits/ostream_insert.h -#usr/include/c++/4.4.7/bits/postypes.h -#usr/include/c++/4.4.7/bits/shared_ptr.h -#usr/include/c++/4.4.7/bits/slice_array.h -#usr/include/c++/4.4.7/bits/sstream.tcc -#usr/include/c++/4.4.7/bits/stl_algo.h -#usr/include/c++/4.4.7/bits/stl_algobase.h -#usr/include/c++/4.4.7/bits/stl_bvector.h -#usr/include/c++/4.4.7/bits/stl_construct.h -#usr/include/c++/4.4.7/bits/stl_deque.h -#usr/include/c++/4.4.7/bits/stl_function.h -#usr/include/c++/4.4.7/bits/stl_heap.h -#usr/include/c++/4.4.7/bits/stl_iterator.h -#usr/include/c++/4.4.7/bits/stl_iterator_base_funcs.h -#usr/include/c++/4.4.7/bits/stl_iterator_base_types.h -#usr/include/c++/4.4.7/bits/stl_list.h -#usr/include/c++/4.4.7/bits/stl_map.h -#usr/include/c++/4.4.7/bits/stl_multimap.h -#usr/include/c++/4.4.7/bits/stl_multiset.h -#usr/include/c++/4.4.7/bits/stl_numeric.h -#usr/include/c++/4.4.7/bits/stl_pair.h -#usr/include/c++/4.4.7/bits/stl_queue.h -#usr/include/c++/4.4.7/bits/stl_raw_storage_iter.h -#usr/include/c++/4.4.7/bits/stl_relops.h -#usr/include/c++/4.4.7/bits/stl_set.h -#usr/include/c++/4.4.7/bits/stl_stack.h -#usr/include/c++/4.4.7/bits/stl_tempbuf.h -#usr/include/c++/4.4.7/bits/stl_tree.h -#usr/include/c++/4.4.7/bits/stl_uninitialized.h -#usr/include/c++/4.4.7/bits/stl_vector.h -#usr/include/c++/4.4.7/bits/stream_iterator.h -#usr/include/c++/4.4.7/bits/streambuf.tcc -#usr/include/c++/4.4.7/bits/streambuf_iterator.h -#usr/include/c++/4.4.7/bits/stringfwd.h -#usr/include/c++/4.4.7/bits/unique_ptr.h -#usr/include/c++/4.4.7/bits/valarray_after.h -#usr/include/c++/4.4.7/bits/valarray_array.h -#usr/include/c++/4.4.7/bits/valarray_array.tcc -#usr/include/c++/4.4.7/bits/valarray_before.h -#usr/include/c++/4.4.7/bits/vector.tcc -#usr/include/c++/4.4.7/bitset -#usr/include/c++/4.4.7/c++0x_warning.h -#usr/include/c++/4.4.7/cassert -#usr/include/c++/4.4.7/ccomplex -#usr/include/c++/4.4.7/cctype -#usr/include/c++/4.4.7/cerrno -#usr/include/c++/4.4.7/cfenv -#usr/include/c++/4.4.7/cfloat -#usr/include/c++/4.4.7/chrono -#usr/include/c++/4.4.7/cinttypes -#usr/include/c++/4.4.7/ciso646 -#usr/include/c++/4.4.7/climits -#usr/include/c++/4.4.7/clocale -#usr/include/c++/4.4.7/cmath -#usr/include/c++/4.4.7/complex -#usr/include/c++/4.4.7/complex.h -#usr/include/c++/4.4.7/condition_variable -#usr/include/c++/4.4.7/csetjmp -#usr/include/c++/4.4.7/csignal -#usr/include/c++/4.4.7/cstdarg -#usr/include/c++/4.4.7/cstdatomic -#usr/include/c++/4.4.7/cstdbool -#usr/include/c++/4.4.7/cstddef -#usr/include/c++/4.4.7/cstdint -#usr/include/c++/4.4.7/cstdio -#usr/include/c++/4.4.7/cstdlib -#usr/include/c++/4.4.7/cstring -#usr/include/c++/4.4.7/ctgmath -#usr/include/c++/4.4.7/ctime -#usr/include/c++/4.4.7/cwchar -#usr/include/c++/4.4.7/cwctype -#usr/include/c++/4.4.7/cxxabi-forced.h -#usr/include/c++/4.4.7/cxxabi.h -#usr/include/c++/4.4.7/debug -#usr/include/c++/4.4.7/debug/bitset -#usr/include/c++/4.4.7/debug/debug.h -#usr/include/c++/4.4.7/debug/deque -#usr/include/c++/4.4.7/debug/formatter.h -#usr/include/c++/4.4.7/debug/functions.h -#usr/include/c++/4.4.7/debug/list -#usr/include/c++/4.4.7/debug/macros.h -#usr/include/c++/4.4.7/debug/map -#usr/include/c++/4.4.7/debug/map.h -#usr/include/c++/4.4.7/debug/multimap.h -#usr/include/c++/4.4.7/debug/multiset.h -#usr/include/c++/4.4.7/debug/safe_base.h -#usr/include/c++/4.4.7/debug/safe_iterator.h -#usr/include/c++/4.4.7/debug/safe_iterator.tcc -#usr/include/c++/4.4.7/debug/safe_sequence.h -#usr/include/c++/4.4.7/debug/set -#usr/include/c++/4.4.7/debug/set.h -#usr/include/c++/4.4.7/debug/string -#usr/include/c++/4.4.7/debug/unordered_map -#usr/include/c++/4.4.7/debug/unordered_set -#usr/include/c++/4.4.7/debug/vector -#usr/include/c++/4.4.7/deque -#usr/include/c++/4.4.7/exception -#usr/include/c++/4.4.7/exception_defines.h -#usr/include/c++/4.4.7/exception_ptr.h -#usr/include/c++/4.4.7/ext -#usr/include/c++/4.4.7/ext/algorithm -#usr/include/c++/4.4.7/ext/array_allocator.h -#usr/include/c++/4.4.7/ext/atomicity.h -#usr/include/c++/4.4.7/ext/bitmap_allocator.h -#usr/include/c++/4.4.7/ext/cast.h -#usr/include/c++/4.4.7/ext/codecvt_specializations.h -#usr/include/c++/4.4.7/ext/concurrence.h -#usr/include/c++/4.4.7/ext/debug_allocator.h -#usr/include/c++/4.4.7/ext/enc_filebuf.h -#usr/include/c++/4.4.7/ext/extptr_allocator.h -#usr/include/c++/4.4.7/ext/functional -#usr/include/c++/4.4.7/ext/hash_map -#usr/include/c++/4.4.7/ext/hash_set -#usr/include/c++/4.4.7/ext/iterator -#usr/include/c++/4.4.7/ext/malloc_allocator.h -#usr/include/c++/4.4.7/ext/memory -#usr/include/c++/4.4.7/ext/mt_allocator.h -#usr/include/c++/4.4.7/ext/new_allocator.h -#usr/include/c++/4.4.7/ext/numeric -#usr/include/c++/4.4.7/ext/numeric_traits.h -#usr/include/c++/4.4.7/ext/pb_ds -#usr/include/c++/4.4.7/ext/pb_ds/assoc_container.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_types.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/entry_pred.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/resize_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cond_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/container_base_dispatch.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/debug_map_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn/eq_by_less.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/lu_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/child_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/head.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/internal_node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/leaf.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_metadata_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/point_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/priority_queue_base_dispatch.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/null_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_trace_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/null_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/sample_trie_e_access_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/string_trie_e_access_traits_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/type_utils.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/types_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/exception.hpp -#usr/include/c++/4.4.7/ext/pb_ds/hash_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/list_update_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/priority_queue.hpp -#usr/include/c++/4.4.7/ext/pb_ds/tag_and_trait.hpp -#usr/include/c++/4.4.7/ext/pb_ds/tree_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/trie_policy.hpp -#usr/include/c++/4.4.7/ext/pod_char_traits.h -#usr/include/c++/4.4.7/ext/pointer.h -#usr/include/c++/4.4.7/ext/pool_allocator.h -#usr/include/c++/4.4.7/ext/rb_tree -#usr/include/c++/4.4.7/ext/rc_string_base.h -#usr/include/c++/4.4.7/ext/rope -#usr/include/c++/4.4.7/ext/ropeimpl.h -#usr/include/c++/4.4.7/ext/slist -#usr/include/c++/4.4.7/ext/sso_string_base.h -#usr/include/c++/4.4.7/ext/stdio_filebuf.h -#usr/include/c++/4.4.7/ext/stdio_sync_filebuf.h -#usr/include/c++/4.4.7/ext/string_conversions.h -#usr/include/c++/4.4.7/ext/throw_allocator.h -#usr/include/c++/4.4.7/ext/type_traits.h -#usr/include/c++/4.4.7/ext/typelist.h -#usr/include/c++/4.4.7/ext/vstring.h -#usr/include/c++/4.4.7/ext/vstring.tcc -#usr/include/c++/4.4.7/ext/vstring_fwd.h -#usr/include/c++/4.4.7/ext/vstring_util.h -#usr/include/c++/4.4.7/fenv.h -#usr/include/c++/4.4.7/forward_list -#usr/include/c++/4.4.7/fstream -#usr/include/c++/4.4.7/functional -#usr/include/c++/4.4.7/initializer_list -#usr/include/c++/4.4.7/iomanip -#usr/include/c++/4.4.7/ios -#usr/include/c++/4.4.7/iosfwd -#usr/include/c++/4.4.7/iostream -#usr/include/c++/4.4.7/istream -#usr/include/c++/4.4.7/iterator -#usr/include/c++/4.4.7/limits -#usr/include/c++/4.4.7/list -#usr/include/c++/4.4.7/locale -#usr/include/c++/4.4.7/map -#usr/include/c++/4.4.7/memory -#usr/include/c++/4.4.7/mutex -#usr/include/c++/4.4.7/new -#usr/include/c++/4.4.7/numeric -#usr/include/c++/4.4.7/ostream -#usr/include/c++/4.4.7/parallel -#usr/include/c++/4.4.7/parallel/algo.h -#usr/include/c++/4.4.7/parallel/algobase.h -#usr/include/c++/4.4.7/parallel/algorithm -#usr/include/c++/4.4.7/parallel/algorithmfwd.h -#usr/include/c++/4.4.7/parallel/balanced_quicksort.h -#usr/include/c++/4.4.7/parallel/base.h -#usr/include/c++/4.4.7/parallel/basic_iterator.h -#usr/include/c++/4.4.7/parallel/checkers.h -#usr/include/c++/4.4.7/parallel/compatibility.h -#usr/include/c++/4.4.7/parallel/compiletime_settings.h -#usr/include/c++/4.4.7/parallel/equally_split.h -#usr/include/c++/4.4.7/parallel/features.h -#usr/include/c++/4.4.7/parallel/find.h -#usr/include/c++/4.4.7/parallel/find_selectors.h -#usr/include/c++/4.4.7/parallel/for_each.h -#usr/include/c++/4.4.7/parallel/for_each_selectors.h -#usr/include/c++/4.4.7/parallel/iterator.h -#usr/include/c++/4.4.7/parallel/list_partition.h -#usr/include/c++/4.4.7/parallel/losertree.h -#usr/include/c++/4.4.7/parallel/merge.h -#usr/include/c++/4.4.7/parallel/multiseq_selection.h -#usr/include/c++/4.4.7/parallel/multiway_merge.h -#usr/include/c++/4.4.7/parallel/multiway_mergesort.h -#usr/include/c++/4.4.7/parallel/numeric -#usr/include/c++/4.4.7/parallel/numericfwd.h -#usr/include/c++/4.4.7/parallel/omp_loop.h -#usr/include/c++/4.4.7/parallel/omp_loop_static.h -#usr/include/c++/4.4.7/parallel/par_loop.h -#usr/include/c++/4.4.7/parallel/parallel.h -#usr/include/c++/4.4.7/parallel/partial_sum.h -#usr/include/c++/4.4.7/parallel/partition.h -#usr/include/c++/4.4.7/parallel/queue.h -#usr/include/c++/4.4.7/parallel/quicksort.h -#usr/include/c++/4.4.7/parallel/random_number.h -#usr/include/c++/4.4.7/parallel/random_shuffle.h -#usr/include/c++/4.4.7/parallel/search.h -#usr/include/c++/4.4.7/parallel/set_operations.h -#usr/include/c++/4.4.7/parallel/settings.h -#usr/include/c++/4.4.7/parallel/sort.h -#usr/include/c++/4.4.7/parallel/tags.h -#usr/include/c++/4.4.7/parallel/types.h -#usr/include/c++/4.4.7/parallel/unique_copy.h -#usr/include/c++/4.4.7/parallel/workstealing.h -#usr/include/c++/4.4.7/queue -#usr/include/c++/4.4.7/random -#usr/include/c++/4.4.7/ratio -#usr/include/c++/4.4.7/regex -#usr/include/c++/4.4.7/set -#usr/include/c++/4.4.7/sstream -#usr/include/c++/4.4.7/stack -#usr/include/c++/4.4.7/stdatomic.h -#usr/include/c++/4.4.7/stdexcept -#usr/include/c++/4.4.7/streambuf -#usr/include/c++/4.4.7/string -#usr/include/c++/4.4.7/system_error -#usr/include/c++/4.4.7/tgmath.h -#usr/include/c++/4.4.7/thread -#usr/include/c++/4.4.7/tr1 -#usr/include/c++/4.4.7/tr1/array -#usr/include/c++/4.4.7/tr1/bessel_function.tcc -#usr/include/c++/4.4.7/tr1/beta_function.tcc -#usr/include/c++/4.4.7/tr1/ccomplex -#usr/include/c++/4.4.7/tr1/cctype -#usr/include/c++/4.4.7/tr1/cfenv -#usr/include/c++/4.4.7/tr1/cfloat -#usr/include/c++/4.4.7/tr1/cinttypes -#usr/include/c++/4.4.7/tr1/climits -#usr/include/c++/4.4.7/tr1/cmath -#usr/include/c++/4.4.7/tr1/complex -#usr/include/c++/4.4.7/tr1/complex.h -#usr/include/c++/4.4.7/tr1/cstdarg -#usr/include/c++/4.4.7/tr1/cstdbool -#usr/include/c++/4.4.7/tr1/cstdint -#usr/include/c++/4.4.7/tr1/cstdio -#usr/include/c++/4.4.7/tr1/cstdlib -#usr/include/c++/4.4.7/tr1/ctgmath -#usr/include/c++/4.4.7/tr1/ctime -#usr/include/c++/4.4.7/tr1/ctype.h -#usr/include/c++/4.4.7/tr1/cwchar -#usr/include/c++/4.4.7/tr1/cwctype -#usr/include/c++/4.4.7/tr1/ell_integral.tcc -#usr/include/c++/4.4.7/tr1/exp_integral.tcc -#usr/include/c++/4.4.7/tr1/fenv.h -#usr/include/c++/4.4.7/tr1/float.h -#usr/include/c++/4.4.7/tr1/functional -#usr/include/c++/4.4.7/tr1/functional_hash.h -#usr/include/c++/4.4.7/tr1/gamma.tcc -#usr/include/c++/4.4.7/tr1/hashtable.h -#usr/include/c++/4.4.7/tr1/hypergeometric.tcc -#usr/include/c++/4.4.7/tr1/inttypes.h -#usr/include/c++/4.4.7/tr1/legendre_function.tcc -#usr/include/c++/4.4.7/tr1/limits.h -#usr/include/c++/4.4.7/tr1/math.h -#usr/include/c++/4.4.7/tr1/memory -#usr/include/c++/4.4.7/tr1/modified_bessel_func.tcc -#usr/include/c++/4.4.7/tr1/poly_hermite.tcc -#usr/include/c++/4.4.7/tr1/poly_laguerre.tcc -#usr/include/c++/4.4.7/tr1/random -#usr/include/c++/4.4.7/tr1/regex -#usr/include/c++/4.4.7/tr1/riemann_zeta.tcc -#usr/include/c++/4.4.7/tr1/shared_ptr.h -#usr/include/c++/4.4.7/tr1/special_function_util.h -#usr/include/c++/4.4.7/tr1/stdarg.h -#usr/include/c++/4.4.7/tr1/stdbool.h -#usr/include/c++/4.4.7/tr1/stdint.h -#usr/include/c++/4.4.7/tr1/stdio.h -#usr/include/c++/4.4.7/tr1/stdlib.h -#usr/include/c++/4.4.7/tr1/tgmath.h -#usr/include/c++/4.4.7/tr1/tuple -#usr/include/c++/4.4.7/tr1/type_traits -#usr/include/c++/4.4.7/tr1/unordered_map -#usr/include/c++/4.4.7/tr1/unordered_set -#usr/include/c++/4.4.7/tr1/utility -#usr/include/c++/4.4.7/tr1/wchar.h -#usr/include/c++/4.4.7/tr1/wctype.h -#usr/include/c++/4.4.7/tr1_impl -#usr/include/c++/4.4.7/tr1_impl/array -#usr/include/c++/4.4.7/tr1_impl/boost_sp_counted_base.h -#usr/include/c++/4.4.7/tr1_impl/cctype -#usr/include/c++/4.4.7/tr1_impl/cfenv -#usr/include/c++/4.4.7/tr1_impl/cinttypes -#usr/include/c++/4.4.7/tr1_impl/cmath -#usr/include/c++/4.4.7/tr1_impl/complex -#usr/include/c++/4.4.7/tr1_impl/cstdint -#usr/include/c++/4.4.7/tr1_impl/cstdio -#usr/include/c++/4.4.7/tr1_impl/cstdlib -#usr/include/c++/4.4.7/tr1_impl/cwchar -#usr/include/c++/4.4.7/tr1_impl/cwctype -#usr/include/c++/4.4.7/tr1_impl/functional -#usr/include/c++/4.4.7/tr1_impl/functional_hash.h -#usr/include/c++/4.4.7/tr1_impl/hashtable -#usr/include/c++/4.4.7/tr1_impl/hashtable_policy.h -#usr/include/c++/4.4.7/tr1_impl/random -#usr/include/c++/4.4.7/tr1_impl/random.tcc -#usr/include/c++/4.4.7/tr1_impl/regex -#usr/include/c++/4.4.7/tr1_impl/type_traits -#usr/include/c++/4.4.7/tr1_impl/unordered_map -#usr/include/c++/4.4.7/tr1_impl/unordered_set -#usr/include/c++/4.4.7/tr1_impl/utility -#usr/include/c++/4.4.7/tuple -#usr/include/c++/4.4.7/type_traits -#usr/include/c++/4.4.7/typeinfo -#usr/include/c++/4.4.7/unordered_map -#usr/include/c++/4.4.7/unordered_set -#usr/include/c++/4.4.7/utility -#usr/include/c++/4.4.7/valarray -#usr/include/c++/4.4.7/vector -#usr/info -#usr/info/cpp.info -#usr/info/cppinternals.info -#usr/info/dir -#usr/info/gcc.info -#usr/info/gccinstall.info -#usr/info/gccint.info -#usr/info/libgomp.info +#usr/include/c++/4.9.3 +#usr/include/c++/4.9.3/algorithm +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/atomic_word.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/basic_file.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/c++allocator.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/c++config.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/c++io.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/c++locale.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/cpu_defines.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/ctype_base.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/ctype_inline.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/cxxabi_tweaks.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/error_constants.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/extc++.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/gthr-default.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/gthr-posix.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/gthr-single.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/gthr.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/messages_members.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/opt_random.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/os_defines.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/stdc++.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/stdtr1c++.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/bits/time_members.h +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/ext +#usr/include/c++/4.9.3/armv5tel-unknown-linux-gnueabi/ext/opt_random.h +#usr/include/c++/4.9.3/array +#usr/include/c++/4.9.3/atomic +#usr/include/c++/4.9.3/backward +#usr/include/c++/4.9.3/backward/auto_ptr.h +#usr/include/c++/4.9.3/backward/backward_warning.h +#usr/include/c++/4.9.3/backward/binders.h +#usr/include/c++/4.9.3/backward/hash_fun.h +#usr/include/c++/4.9.3/backward/hash_map +#usr/include/c++/4.9.3/backward/hash_set +#usr/include/c++/4.9.3/backward/hashtable.h +#usr/include/c++/4.9.3/backward/strstream +#usr/include/c++/4.9.3/bits +#usr/include/c++/4.9.3/bits/algorithmfwd.h +#usr/include/c++/4.9.3/bits/alloc_traits.h +#usr/include/c++/4.9.3/bits/allocator.h +#usr/include/c++/4.9.3/bits/atomic_base.h +#usr/include/c++/4.9.3/bits/atomic_lockfree_defines.h +#usr/include/c++/4.9.3/bits/basic_ios.h +#usr/include/c++/4.9.3/bits/basic_ios.tcc +#usr/include/c++/4.9.3/bits/basic_string.h +#usr/include/c++/4.9.3/bits/basic_string.tcc +#usr/include/c++/4.9.3/bits/boost_concept_check.h +#usr/include/c++/4.9.3/bits/c++0x_warning.h +#usr/include/c++/4.9.3/bits/c++14_warning.h +#usr/include/c++/4.9.3/bits/char_traits.h +#usr/include/c++/4.9.3/bits/codecvt.h +#usr/include/c++/4.9.3/bits/concept_check.h +#usr/include/c++/4.9.3/bits/cpp_type_traits.h +#usr/include/c++/4.9.3/bits/cxxabi_forced.h +#usr/include/c++/4.9.3/bits/deque.tcc +#usr/include/c++/4.9.3/bits/enable_special_members.h +#usr/include/c++/4.9.3/bits/exception_defines.h +#usr/include/c++/4.9.3/bits/exception_ptr.h +#usr/include/c++/4.9.3/bits/forward_list.h +#usr/include/c++/4.9.3/bits/forward_list.tcc +#usr/include/c++/4.9.3/bits/fstream.tcc +#usr/include/c++/4.9.3/bits/functexcept.h +#usr/include/c++/4.9.3/bits/functional_hash.h +#usr/include/c++/4.9.3/bits/gslice.h +#usr/include/c++/4.9.3/bits/gslice_array.h +#usr/include/c++/4.9.3/bits/hash_bytes.h +#usr/include/c++/4.9.3/bits/hashtable.h +#usr/include/c++/4.9.3/bits/hashtable_policy.h +#usr/include/c++/4.9.3/bits/indirect_array.h +#usr/include/c++/4.9.3/bits/ios_base.h +#usr/include/c++/4.9.3/bits/istream.tcc +#usr/include/c++/4.9.3/bits/list.tcc +#usr/include/c++/4.9.3/bits/locale_classes.h +#usr/include/c++/4.9.3/bits/locale_classes.tcc +#usr/include/c++/4.9.3/bits/locale_facets.h +#usr/include/c++/4.9.3/bits/locale_facets.tcc +#usr/include/c++/4.9.3/bits/locale_facets_nonio.h +#usr/include/c++/4.9.3/bits/locale_facets_nonio.tcc +#usr/include/c++/4.9.3/bits/localefwd.h +#usr/include/c++/4.9.3/bits/mask_array.h +#usr/include/c++/4.9.3/bits/memoryfwd.h +#usr/include/c++/4.9.3/bits/move.h +#usr/include/c++/4.9.3/bits/nested_exception.h +#usr/include/c++/4.9.3/bits/ostream.tcc +#usr/include/c++/4.9.3/bits/ostream_insert.h +#usr/include/c++/4.9.3/bits/parse_numbers.h +#usr/include/c++/4.9.3/bits/postypes.h +#usr/include/c++/4.9.3/bits/predefined_ops.h +#usr/include/c++/4.9.3/bits/ptr_traits.h +#usr/include/c++/4.9.3/bits/random.h +#usr/include/c++/4.9.3/bits/random.tcc +#usr/include/c++/4.9.3/bits/range_access.h +#usr/include/c++/4.9.3/bits/regex.h +#usr/include/c++/4.9.3/bits/regex.tcc +#usr/include/c++/4.9.3/bits/regex_automaton.h +#usr/include/c++/4.9.3/bits/regex_automaton.tcc +#usr/include/c++/4.9.3/bits/regex_compiler.h +#usr/include/c++/4.9.3/bits/regex_compiler.tcc +#usr/include/c++/4.9.3/bits/regex_constants.h +#usr/include/c++/4.9.3/bits/regex_error.h +#usr/include/c++/4.9.3/bits/regex_executor.h +#usr/include/c++/4.9.3/bits/regex_executor.tcc +#usr/include/c++/4.9.3/bits/regex_scanner.h +#usr/include/c++/4.9.3/bits/regex_scanner.tcc +#usr/include/c++/4.9.3/bits/shared_ptr.h +#usr/include/c++/4.9.3/bits/shared_ptr_base.h +#usr/include/c++/4.9.3/bits/slice_array.h +#usr/include/c++/4.9.3/bits/sstream.tcc +#usr/include/c++/4.9.3/bits/stl_algo.h +#usr/include/c++/4.9.3/bits/stl_algobase.h +#usr/include/c++/4.9.3/bits/stl_bvector.h +#usr/include/c++/4.9.3/bits/stl_construct.h +#usr/include/c++/4.9.3/bits/stl_deque.h +#usr/include/c++/4.9.3/bits/stl_function.h +#usr/include/c++/4.9.3/bits/stl_heap.h +#usr/include/c++/4.9.3/bits/stl_iterator.h +#usr/include/c++/4.9.3/bits/stl_iterator_base_funcs.h +#usr/include/c++/4.9.3/bits/stl_iterator_base_types.h +#usr/include/c++/4.9.3/bits/stl_list.h +#usr/include/c++/4.9.3/bits/stl_map.h +#usr/include/c++/4.9.3/bits/stl_multimap.h +#usr/include/c++/4.9.3/bits/stl_multiset.h +#usr/include/c++/4.9.3/bits/stl_numeric.h +#usr/include/c++/4.9.3/bits/stl_pair.h +#usr/include/c++/4.9.3/bits/stl_queue.h +#usr/include/c++/4.9.3/bits/stl_raw_storage_iter.h +#usr/include/c++/4.9.3/bits/stl_relops.h +#usr/include/c++/4.9.3/bits/stl_set.h +#usr/include/c++/4.9.3/bits/stl_stack.h +#usr/include/c++/4.9.3/bits/stl_tempbuf.h +#usr/include/c++/4.9.3/bits/stl_tree.h +#usr/include/c++/4.9.3/bits/stl_uninitialized.h +#usr/include/c++/4.9.3/bits/stl_vector.h +#usr/include/c++/4.9.3/bits/stream_iterator.h +#usr/include/c++/4.9.3/bits/streambuf.tcc +#usr/include/c++/4.9.3/bits/streambuf_iterator.h +#usr/include/c++/4.9.3/bits/stringfwd.h +#usr/include/c++/4.9.3/bits/unique_ptr.h +#usr/include/c++/4.9.3/bits/unordered_map.h +#usr/include/c++/4.9.3/bits/unordered_set.h +#usr/include/c++/4.9.3/bits/uses_allocator.h +#usr/include/c++/4.9.3/bits/valarray_after.h +#usr/include/c++/4.9.3/bits/valarray_array.h +#usr/include/c++/4.9.3/bits/valarray_array.tcc +#usr/include/c++/4.9.3/bits/valarray_before.h +#usr/include/c++/4.9.3/bits/vector.tcc +#usr/include/c++/4.9.3/bitset +#usr/include/c++/4.9.3/cassert +#usr/include/c++/4.9.3/ccomplex +#usr/include/c++/4.9.3/cctype +#usr/include/c++/4.9.3/cerrno +#usr/include/c++/4.9.3/cfenv +#usr/include/c++/4.9.3/cfloat +#usr/include/c++/4.9.3/chrono +#usr/include/c++/4.9.3/cinttypes +#usr/include/c++/4.9.3/ciso646 +#usr/include/c++/4.9.3/climits +#usr/include/c++/4.9.3/clocale +#usr/include/c++/4.9.3/cmath +#usr/include/c++/4.9.3/complex +#usr/include/c++/4.9.3/complex.h +#usr/include/c++/4.9.3/condition_variable +#usr/include/c++/4.9.3/csetjmp +#usr/include/c++/4.9.3/csignal +#usr/include/c++/4.9.3/cstdalign +#usr/include/c++/4.9.3/cstdarg +#usr/include/c++/4.9.3/cstdbool +#usr/include/c++/4.9.3/cstddef +#usr/include/c++/4.9.3/cstdint +#usr/include/c++/4.9.3/cstdio +#usr/include/c++/4.9.3/cstdlib +#usr/include/c++/4.9.3/cstring +#usr/include/c++/4.9.3/ctgmath +#usr/include/c++/4.9.3/ctime +#usr/include/c++/4.9.3/cwchar +#usr/include/c++/4.9.3/cwctype +#usr/include/c++/4.9.3/cxxabi.h +#usr/include/c++/4.9.3/debug +#usr/include/c++/4.9.3/debug/array +#usr/include/c++/4.9.3/debug/bitset +#usr/include/c++/4.9.3/debug/debug.h +#usr/include/c++/4.9.3/debug/deque +#usr/include/c++/4.9.3/debug/formatter.h +#usr/include/c++/4.9.3/debug/forward_list +#usr/include/c++/4.9.3/debug/functions.h +#usr/include/c++/4.9.3/debug/list +#usr/include/c++/4.9.3/debug/macros.h +#usr/include/c++/4.9.3/debug/map +#usr/include/c++/4.9.3/debug/map.h +#usr/include/c++/4.9.3/debug/multimap.h +#usr/include/c++/4.9.3/debug/multiset.h +#usr/include/c++/4.9.3/debug/safe_base.h +#usr/include/c++/4.9.3/debug/safe_iterator.h +#usr/include/c++/4.9.3/debug/safe_iterator.tcc +#usr/include/c++/4.9.3/debug/safe_local_iterator.h +#usr/include/c++/4.9.3/debug/safe_local_iterator.tcc +#usr/include/c++/4.9.3/debug/safe_sequence.h +#usr/include/c++/4.9.3/debug/safe_sequence.tcc +#usr/include/c++/4.9.3/debug/safe_unordered_base.h +#usr/include/c++/4.9.3/debug/safe_unordered_container.h +#usr/include/c++/4.9.3/debug/safe_unordered_container.tcc +#usr/include/c++/4.9.3/debug/set +#usr/include/c++/4.9.3/debug/set.h +#usr/include/c++/4.9.3/debug/string +#usr/include/c++/4.9.3/debug/unordered_map +#usr/include/c++/4.9.3/debug/unordered_set +#usr/include/c++/4.9.3/debug/vector +#usr/include/c++/4.9.3/decimal +#usr/include/c++/4.9.3/decimal/decimal +#usr/include/c++/4.9.3/decimal/decimal.h +#usr/include/c++/4.9.3/deque +#usr/include/c++/4.9.3/exception +#usr/include/c++/4.9.3/experimental +#usr/include/c++/4.9.3/experimental/optional +#usr/include/c++/4.9.3/experimental/string_view +#usr/include/c++/4.9.3/experimental/string_view.tcc +#usr/include/c++/4.9.3/ext +#usr/include/c++/4.9.3/ext/algorithm +#usr/include/c++/4.9.3/ext/aligned_buffer.h +#usr/include/c++/4.9.3/ext/alloc_traits.h +#usr/include/c++/4.9.3/ext/array_allocator.h +#usr/include/c++/4.9.3/ext/atomicity.h +#usr/include/c++/4.9.3/ext/bitmap_allocator.h +#usr/include/c++/4.9.3/ext/cast.h +#usr/include/c++/4.9.3/ext/cmath +#usr/include/c++/4.9.3/ext/codecvt_specializations.h +#usr/include/c++/4.9.3/ext/concurrence.h +#usr/include/c++/4.9.3/ext/debug_allocator.h +#usr/include/c++/4.9.3/ext/enc_filebuf.h +#usr/include/c++/4.9.3/ext/extptr_allocator.h +#usr/include/c++/4.9.3/ext/functional +#usr/include/c++/4.9.3/ext/hash_map +#usr/include/c++/4.9.3/ext/hash_set +#usr/include/c++/4.9.3/ext/iterator +#usr/include/c++/4.9.3/ext/malloc_allocator.h +#usr/include/c++/4.9.3/ext/memory +#usr/include/c++/4.9.3/ext/mt_allocator.h +#usr/include/c++/4.9.3/ext/new_allocator.h +#usr/include/c++/4.9.3/ext/numeric +#usr/include/c++/4.9.3/ext/numeric_traits.h +#usr/include/c++/4.9.3/ext/pb_ds +#usr/include/c++/4.9.3/ext/pb_ds/assoc_container.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/entry_pred.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/resize_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/branch_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/null_node_metadata.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cond_dealtor.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/container_base_dispatch.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/debug_map_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn/eq_by_less.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/lu_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/priority_queue_base_dispatch.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/standard_policies.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_trace_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/sample_trie_access_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/type_utils.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/types_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/exception.hpp +#usr/include/c++/4.9.3/ext/pb_ds/hash_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/list_update_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/priority_queue.hpp +#usr/include/c++/4.9.3/ext/pb_ds/tag_and_trait.hpp +#usr/include/c++/4.9.3/ext/pb_ds/tree_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/trie_policy.hpp +#usr/include/c++/4.9.3/ext/pod_char_traits.h +#usr/include/c++/4.9.3/ext/pointer.h +#usr/include/c++/4.9.3/ext/pool_allocator.h +#usr/include/c++/4.9.3/ext/random +#usr/include/c++/4.9.3/ext/random.tcc +#usr/include/c++/4.9.3/ext/rb_tree +#usr/include/c++/4.9.3/ext/rc_string_base.h +#usr/include/c++/4.9.3/ext/rope +#usr/include/c++/4.9.3/ext/ropeimpl.h +#usr/include/c++/4.9.3/ext/slist +#usr/include/c++/4.9.3/ext/sso_string_base.h +#usr/include/c++/4.9.3/ext/stdio_filebuf.h +#usr/include/c++/4.9.3/ext/stdio_sync_filebuf.h +#usr/include/c++/4.9.3/ext/string_conversions.h +#usr/include/c++/4.9.3/ext/throw_allocator.h +#usr/include/c++/4.9.3/ext/type_traits.h +#usr/include/c++/4.9.3/ext/typelist.h +#usr/include/c++/4.9.3/ext/vstring.h +#usr/include/c++/4.9.3/ext/vstring.tcc +#usr/include/c++/4.9.3/ext/vstring_fwd.h +#usr/include/c++/4.9.3/ext/vstring_util.h +#usr/include/c++/4.9.3/fenv.h +#usr/include/c++/4.9.3/forward_list +#usr/include/c++/4.9.3/fstream +#usr/include/c++/4.9.3/functional +#usr/include/c++/4.9.3/future +#usr/include/c++/4.9.3/initializer_list +#usr/include/c++/4.9.3/iomanip +#usr/include/c++/4.9.3/ios +#usr/include/c++/4.9.3/iosfwd +#usr/include/c++/4.9.3/iostream +#usr/include/c++/4.9.3/istream +#usr/include/c++/4.9.3/iterator +#usr/include/c++/4.9.3/limits +#usr/include/c++/4.9.3/list +#usr/include/c++/4.9.3/locale +#usr/include/c++/4.9.3/map +#usr/include/c++/4.9.3/memory +#usr/include/c++/4.9.3/mutex +#usr/include/c++/4.9.3/new +#usr/include/c++/4.9.3/numeric +#usr/include/c++/4.9.3/ostream +#usr/include/c++/4.9.3/parallel +#usr/include/c++/4.9.3/parallel/algo.h +#usr/include/c++/4.9.3/parallel/algobase.h +#usr/include/c++/4.9.3/parallel/algorithm +#usr/include/c++/4.9.3/parallel/algorithmfwd.h +#usr/include/c++/4.9.3/parallel/balanced_quicksort.h +#usr/include/c++/4.9.3/parallel/base.h +#usr/include/c++/4.9.3/parallel/basic_iterator.h +#usr/include/c++/4.9.3/parallel/checkers.h +#usr/include/c++/4.9.3/parallel/compatibility.h +#usr/include/c++/4.9.3/parallel/compiletime_settings.h +#usr/include/c++/4.9.3/parallel/equally_split.h +#usr/include/c++/4.9.3/parallel/features.h +#usr/include/c++/4.9.3/parallel/find.h +#usr/include/c++/4.9.3/parallel/find_selectors.h +#usr/include/c++/4.9.3/parallel/for_each.h +#usr/include/c++/4.9.3/parallel/for_each_selectors.h +#usr/include/c++/4.9.3/parallel/iterator.h +#usr/include/c++/4.9.3/parallel/list_partition.h +#usr/include/c++/4.9.3/parallel/losertree.h +#usr/include/c++/4.9.3/parallel/merge.h +#usr/include/c++/4.9.3/parallel/multiseq_selection.h +#usr/include/c++/4.9.3/parallel/multiway_merge.h +#usr/include/c++/4.9.3/parallel/multiway_mergesort.h +#usr/include/c++/4.9.3/parallel/numeric +#usr/include/c++/4.9.3/parallel/numericfwd.h +#usr/include/c++/4.9.3/parallel/omp_loop.h +#usr/include/c++/4.9.3/parallel/omp_loop_static.h +#usr/include/c++/4.9.3/parallel/par_loop.h +#usr/include/c++/4.9.3/parallel/parallel.h +#usr/include/c++/4.9.3/parallel/partial_sum.h +#usr/include/c++/4.9.3/parallel/partition.h +#usr/include/c++/4.9.3/parallel/queue.h +#usr/include/c++/4.9.3/parallel/quicksort.h +#usr/include/c++/4.9.3/parallel/random_number.h +#usr/include/c++/4.9.3/parallel/random_shuffle.h +#usr/include/c++/4.9.3/parallel/search.h +#usr/include/c++/4.9.3/parallel/set_operations.h +#usr/include/c++/4.9.3/parallel/settings.h +#usr/include/c++/4.9.3/parallel/sort.h +#usr/include/c++/4.9.3/parallel/tags.h +#usr/include/c++/4.9.3/parallel/types.h +#usr/include/c++/4.9.3/parallel/unique_copy.h +#usr/include/c++/4.9.3/parallel/workstealing.h +#usr/include/c++/4.9.3/profile +#usr/include/c++/4.9.3/profile/array +#usr/include/c++/4.9.3/profile/base.h +#usr/include/c++/4.9.3/profile/bitset +#usr/include/c++/4.9.3/profile/deque +#usr/include/c++/4.9.3/profile/forward_list +#usr/include/c++/4.9.3/profile/impl +#usr/include/c++/4.9.3/profile/impl/profiler.h +#usr/include/c++/4.9.3/profile/impl/profiler_algos.h +#usr/include/c++/4.9.3/profile/impl/profiler_container_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_hash_func.h +#usr/include/c++/4.9.3/profile/impl/profiler_hashtable_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_list_to_slist.h +#usr/include/c++/4.9.3/profile/impl/profiler_list_to_vector.h +#usr/include/c++/4.9.3/profile/impl/profiler_map_to_unordered_map.h +#usr/include/c++/4.9.3/profile/impl/profiler_node.h +#usr/include/c++/4.9.3/profile/impl/profiler_state.h +#usr/include/c++/4.9.3/profile/impl/profiler_trace.h +#usr/include/c++/4.9.3/profile/impl/profiler_vector_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_vector_to_list.h +#usr/include/c++/4.9.3/profile/iterator_tracker.h +#usr/include/c++/4.9.3/profile/list +#usr/include/c++/4.9.3/profile/map +#usr/include/c++/4.9.3/profile/map.h +#usr/include/c++/4.9.3/profile/multimap.h +#usr/include/c++/4.9.3/profile/multiset.h +#usr/include/c++/4.9.3/profile/set +#usr/include/c++/4.9.3/profile/set.h +#usr/include/c++/4.9.3/profile/unordered_base.h +#usr/include/c++/4.9.3/profile/unordered_map +#usr/include/c++/4.9.3/profile/unordered_set +#usr/include/c++/4.9.3/profile/vector +#usr/include/c++/4.9.3/queue +#usr/include/c++/4.9.3/random +#usr/include/c++/4.9.3/ratio +#usr/include/c++/4.9.3/regex +#usr/include/c++/4.9.3/scoped_allocator +#usr/include/c++/4.9.3/set +#usr/include/c++/4.9.3/shared_mutex +#usr/include/c++/4.9.3/sstream +#usr/include/c++/4.9.3/stack +#usr/include/c++/4.9.3/stdexcept +#usr/include/c++/4.9.3/streambuf +#usr/include/c++/4.9.3/string +#usr/include/c++/4.9.3/system_error +#usr/include/c++/4.9.3/tgmath.h +#usr/include/c++/4.9.3/thread +#usr/include/c++/4.9.3/tr1 +#usr/include/c++/4.9.3/tr1/array +#usr/include/c++/4.9.3/tr1/bessel_function.tcc +#usr/include/c++/4.9.3/tr1/beta_function.tcc +#usr/include/c++/4.9.3/tr1/ccomplex +#usr/include/c++/4.9.3/tr1/cctype +#usr/include/c++/4.9.3/tr1/cfenv +#usr/include/c++/4.9.3/tr1/cfloat +#usr/include/c++/4.9.3/tr1/cinttypes +#usr/include/c++/4.9.3/tr1/climits +#usr/include/c++/4.9.3/tr1/cmath +#usr/include/c++/4.9.3/tr1/complex +#usr/include/c++/4.9.3/tr1/complex.h +#usr/include/c++/4.9.3/tr1/cstdarg +#usr/include/c++/4.9.3/tr1/cstdbool +#usr/include/c++/4.9.3/tr1/cstdint +#usr/include/c++/4.9.3/tr1/cstdio +#usr/include/c++/4.9.3/tr1/cstdlib +#usr/include/c++/4.9.3/tr1/ctgmath +#usr/include/c++/4.9.3/tr1/ctime +#usr/include/c++/4.9.3/tr1/ctype.h +#usr/include/c++/4.9.3/tr1/cwchar +#usr/include/c++/4.9.3/tr1/cwctype +#usr/include/c++/4.9.3/tr1/ell_integral.tcc +#usr/include/c++/4.9.3/tr1/exp_integral.tcc +#usr/include/c++/4.9.3/tr1/fenv.h +#usr/include/c++/4.9.3/tr1/float.h +#usr/include/c++/4.9.3/tr1/functional +#usr/include/c++/4.9.3/tr1/functional_hash.h +#usr/include/c++/4.9.3/tr1/gamma.tcc +#usr/include/c++/4.9.3/tr1/hashtable.h +#usr/include/c++/4.9.3/tr1/hashtable_policy.h +#usr/include/c++/4.9.3/tr1/hypergeometric.tcc +#usr/include/c++/4.9.3/tr1/inttypes.h +#usr/include/c++/4.9.3/tr1/legendre_function.tcc +#usr/include/c++/4.9.3/tr1/limits.h +#usr/include/c++/4.9.3/tr1/math.h +#usr/include/c++/4.9.3/tr1/memory +#usr/include/c++/4.9.3/tr1/modified_bessel_func.tcc +#usr/include/c++/4.9.3/tr1/poly_hermite.tcc +#usr/include/c++/4.9.3/tr1/poly_laguerre.tcc +#usr/include/c++/4.9.3/tr1/random +#usr/include/c++/4.9.3/tr1/random.h +#usr/include/c++/4.9.3/tr1/random.tcc +#usr/include/c++/4.9.3/tr1/regex +#usr/include/c++/4.9.3/tr1/riemann_zeta.tcc +#usr/include/c++/4.9.3/tr1/shared_ptr.h +#usr/include/c++/4.9.3/tr1/special_function_util.h +#usr/include/c++/4.9.3/tr1/stdarg.h +#usr/include/c++/4.9.3/tr1/stdbool.h +#usr/include/c++/4.9.3/tr1/stdint.h +#usr/include/c++/4.9.3/tr1/stdio.h +#usr/include/c++/4.9.3/tr1/stdlib.h +#usr/include/c++/4.9.3/tr1/tgmath.h +#usr/include/c++/4.9.3/tr1/tuple +#usr/include/c++/4.9.3/tr1/type_traits +#usr/include/c++/4.9.3/tr1/unordered_map +#usr/include/c++/4.9.3/tr1/unordered_map.h +#usr/include/c++/4.9.3/tr1/unordered_set +#usr/include/c++/4.9.3/tr1/unordered_set.h +#usr/include/c++/4.9.3/tr1/utility +#usr/include/c++/4.9.3/tr1/wchar.h +#usr/include/c++/4.9.3/tr1/wctype.h +#usr/include/c++/4.9.3/tr2 +#usr/include/c++/4.9.3/tr2/bool_set +#usr/include/c++/4.9.3/tr2/bool_set.tcc +#usr/include/c++/4.9.3/tr2/dynamic_bitset +#usr/include/c++/4.9.3/tr2/dynamic_bitset.tcc +#usr/include/c++/4.9.3/tr2/ratio +#usr/include/c++/4.9.3/tr2/type_traits +#usr/include/c++/4.9.3/tuple +#usr/include/c++/4.9.3/type_traits +#usr/include/c++/4.9.3/typeindex +#usr/include/c++/4.9.3/typeinfo +#usr/include/c++/4.9.3/unordered_map +#usr/include/c++/4.9.3/unordered_set +#usr/include/c++/4.9.3/utility +#usr/include/c++/4.9.3/valarray +#usr/include/c++/4.9.3/vector #usr/lib/gcc #usr/lib/gcc/armv5tel-unknown-linux-gnueabi -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7 -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/cc1 -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/cc1plus -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/collect2 -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/crtbegin.o -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/crtbeginS.o -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/crtbeginT.o -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/crtend.o -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/crtendS.o -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/finclude -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include-fixed -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include-fixed/README -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include-fixed/limits.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include-fixed/syslimits.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/arm_neon.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/float.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/iso646.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/mf-runtime.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/mmintrin.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/omp.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/ssp -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/ssp/ssp.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/ssp/stdio.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/ssp/string.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/ssp/unistd.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/stdarg.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/stdbool.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/stddef.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/stdfix.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/unwind.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/include/varargs.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/fixinc.sh -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/fixinc_list -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/fixincl -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/gsyslimits.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/include -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/include/README -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/include/limits.h -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/macro_list -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/mkheaders -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/mkheaders.conf -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/install-tools/mkinstalldirs -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/libgcc.a -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/libgcc_eh.a -#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.4.7/libgcov.a +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3 +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/cc1 +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/cc1plus +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/collect2 +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/crtbegin.o +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/crtbeginS.o +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/crtbeginT.o +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/crtend.o +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/crtendS.o +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/finclude +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include-fixed +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include-fixed/README +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include-fixed/limits.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include-fixed/syslimits.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/arm_acle.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/arm_neon.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/float.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/iso646.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/mmintrin.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/omp.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/sanitizer +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/sanitizer/asan_interface.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/sanitizer/common_interface_defs.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/sanitizer/lsan_interface.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/ssp +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/ssp/ssp.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/ssp/stdio.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/ssp/string.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/ssp/unistd.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stdalign.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stdarg.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stdatomic.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stdbool.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stddef.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stdfix.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stdint-gcc.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stdint.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/stdnoreturn.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/unwind-arm-common.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/unwind.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/include/varargs.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/fixinc.sh +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/fixinc_list +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/fixincl +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/gsyslimits.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/include +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/include/README +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/include/limits.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/macro_list +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/mkheaders +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/mkheaders.conf +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/install-tools/mkinstalldirs +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/libgcc.a +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/libgcc_eh.a +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/libgcov.a +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/liblto_plugin.la +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/liblto_plugin.so +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/liblto_plugin.so.0 +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/liblto_plugin.so.0.0.0 +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/lto-wrapper +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/lto1 +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/gengtype +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/gtype.state +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ada +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ada/gcc-interface +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ada/gcc-interface/ada-tree.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/alias.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/all-tree.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/alloc-pool.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ansidecl.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/attribs.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/auto-host.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/b-header-vars +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/basic-block.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/bitmap.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/builtins.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/bversion.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/c-family +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/c-family/c-common.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/c-family/c-common.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/c-family/c-objc.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/c-family/c-pragma.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/c-family/c-pretty-print.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/c-tree.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/calls.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cfg-flags.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cfgexpand.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cfghooks.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cfgloop.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cgraph.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cif-code.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cilk-builtins.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cilkplus.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/aarch-common-protos.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/aout.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/arm-cores.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/arm-opts.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/arm-protos.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/arm.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/bpabi.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/elf.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/linux-eabi.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/linux-elf.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/arm/linux-gas.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/dbxelf.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/elfos.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/glibc-stdint.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/gnu-user.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/initfini-array.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/linux-android.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/linux-protos.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/linux.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/config/vxworks-dummy.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/configargs.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/context.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/coretypes.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cp +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cp/cp-tree.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cp/cp-tree.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cp/cxx-pretty-print.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cp/name-lookup.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cp/type-utils.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cppdefault.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/cpplib.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/debug.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/defaults.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/df.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/diagnostic-color.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/diagnostic-core.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/diagnostic.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/diagnostic.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/double-int.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/dumpfile.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/emit-rtl.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/except.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/filenames.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/fixed-value.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/flag-types.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/flags.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/fold-const.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/function.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gcc-plugin.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gcc-symtab.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/genrtl.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ggc.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple-builder.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple-expr.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple-fold.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple-iterator.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple-low.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple-pretty-print.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple-ssa.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple-walk.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimple.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimplify-me.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gimplify.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gsstruct.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gtm-builtins.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/gtype-desc.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/hard-reg-set.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/hash-table.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/hashtab.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/highlev-plugin-common.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/hwint.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/incpath.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/input.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/insn-codes.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/insn-constants.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/insn-flags.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/insn-modes.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/insn-notes.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/internal-fn.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/internal-fn.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/intl.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ipa-prop.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ipa-ref-inline.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ipa-ref.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ipa-reference.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ipa-utils.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/is-a.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/java +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/java/java-tree.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/langhooks.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/libiberty.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/line-map.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/machmode.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/md5.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/mode-classes.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/objc +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/objc/objc-tree.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/obstack.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/omp-builtins.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/options.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/opts.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/output.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/params.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/params.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/pass-instances.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/pass_manager.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/plugin-api.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/plugin-version.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/plugin.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/plugin.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/pointer-set.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/predict.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/predict.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/prefix.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/pretty-print.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/print-rtl.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/print-tree.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/real.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/realmpfr.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/reg-notes.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/regset.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/resource.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/rtl.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/rtl.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/safe-ctype.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/sanitizer.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/sbitmap.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/splay-tree.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/ssa-iterators.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/statistics.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/stmt.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/stor-layout.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/stringpool.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/symtab.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/sync-builtins.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/system.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/target-hooks-macros.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/target.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/target.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/timevar.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/timevar.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tm-preds.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tm.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tm_p.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/toplev.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-cfg.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-cfgcleanup.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-check.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-core.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-dfa.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-dump.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-eh.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-hasher.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-inline.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-into-ssa.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-iterator.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-nested.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-object-size.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-outof-ssa.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-parloops.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-pass.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-phinodes.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-pretty-print.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-address.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-alias.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-coalesce.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-dom.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-loop-ivopts.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-loop-manip.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-loop-niter.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-loop.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-operands.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-sccvn.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-ter.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-threadedge.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa-threadupdate.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssa.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree-ssanames.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/tree.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/treestruct.def +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/varasm.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/vec.h +#usr/lib/gcc/armv5tel-unknown-linux-gnueabi/4.9.3/plugin/include/version.h +#usr/lib/libasan.a +#usr/lib/libasan.la +#usr/lib/libasan.so +usr/lib/libasan.so.1 +usr/lib/libasan.so.1.0.0 +#usr/lib/libasan_preinit.o +#usr/lib/libatomic.a +#usr/lib/libatomic.la +#usr/lib/libatomic.so +usr/lib/libatomic.so.1 +usr/lib/libatomic.so.1.1.0 #usr/lib/libgomp.a #usr/lib/libgomp.la #usr/lib/libgomp.so usr/lib/libgomp.so.1 usr/lib/libgomp.so.1.0.0 #usr/lib/libgomp.spec -#usr/lib/libmudflap.a -#usr/lib/libmudflap.la -#usr/lib/libmudflap.so -usr/lib/libmudflap.so.0 -usr/lib/libmudflap.so.0.0.0 -#usr/lib/libmudflapth.a -#usr/lib/libmudflapth.la -#usr/lib/libmudflapth.so -usr/lib/libmudflapth.so.0 -usr/lib/libmudflapth.so.0.0.0 +#usr/lib/libitm.a +#usr/lib/libitm.la +#usr/lib/libitm.so +usr/lib/libitm.so.1 +usr/lib/libitm.so.1.0.0 +#usr/lib/libitm.spec +#usr/lib/libsanitizer.spec #usr/lib/libssp.a #usr/lib/libssp.la #usr/lib/libssp.so @@ -766,16 +1058,34 @@ usr/lib/libssp.so.0.0.0 #usr/lib/libssp_nonshared.a #usr/lib/libssp_nonshared.la #usr/lib/libstdc++.a -usr/lib/libstdc++.so.6.0.13 +usr/lib/libstdc++.so.6.0.20 +#usr/lib/libstdc++.so.6.0.20-gdb.py #usr/lib/libsupc++.a #usr/lib/libsupc++.la -#usr/man -#usr/man/man1 -#usr/man/man1/cpp.1 -#usr/man/man1/g++.1 -#usr/man/man1/gcc.1 -#usr/man/man1/gcov.1 -#usr/man/man7 -#usr/man/man7/fsf-funding.7 -#usr/man/man7/gfdl.7 -#usr/man/man7/gpl.7 +#usr/lib/libubsan.a +#usr/lib/libubsan.la +#usr/lib/libubsan.so +usr/lib/libubsan.so.0 +usr/lib/libubsan.so.0.0.0 +#usr/share/gcc-4.9.3 +#usr/share/gcc-4.9.3/python +#usr/share/gcc-4.9.3/python/libstdcxx +#usr/share/gcc-4.9.3/python/libstdcxx/__init__.py +#usr/share/gcc-4.9.3/python/libstdcxx/v6 +#usr/share/gcc-4.9.3/python/libstdcxx/v6/__init__.py +#usr/share/gcc-4.9.3/python/libstdcxx/v6/printers.py +#usr/share/info/cpp.info +#usr/share/info/cppinternals.info +#usr/share/info/gcc.info +#usr/share/info/gccinstall.info +#usr/share/info/gccint.info +#usr/share/info/libgomp.info +#usr/share/info/libitm.info +#usr/share/info/libquadmath.info +#usr/share/man/man1/cpp.1 +#usr/share/man/man1/g++.1 +#usr/share/man/man1/gcc.1 +#usr/share/man/man1/gcov.1 +#usr/share/man/man7/fsf-funding.7 +#usr/share/man/man7/gfdl.7 +#usr/share/man/man7/gpl.7 diff --git a/config/rootfiles/common/armv5tel/initscripts b/config/rootfiles/common/armv5tel/initscripts index a2a2ea0..e6d328b 100644 --- a/config/rootfiles/common/armv5tel/initscripts +++ b/config/rootfiles/common/armv5tel/initscripts @@ -25,6 +25,7 @@ etc/rc.d/init.d/console #etc/rc.d/init.d/cyrus-sasl etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay +#etc/rc.d/init.d/dnsdist etc/rc.d/init.d/dnsmasq etc/rc.d/init.d/fcron #etc/rc.d/init.d/fetchmail diff --git a/config/rootfiles/common/ath10k-firmware b/config/rootfiles/common/ath10k-firmware new file mode 100644 index 0000000..4f55cd5 --- /dev/null +++ b/config/rootfiles/common/ath10k-firmware @@ -0,0 +1,23 @@ +lib/firmware/LICENSE.QualcommAtheros_ath10k +#lib/firmware/ath10k +#lib/firmware/ath10k/QCA6174 +#lib/firmware/ath10k/QCA6174/hw2.1 +lib/firmware/ath10k/QCA6174/hw2.1/board.bin +lib/firmware/ath10k/QCA6174/hw2.1/firmware-5.bin +lib/firmware/ath10k/QCA6174/hw2.1/notice_ath10k_firmware-5.txt +#lib/firmware/ath10k/QCA6174/hw3.0 +lib/firmware/ath10k/QCA6174/hw3.0/board.bin +lib/firmware/ath10k/QCA6174/hw3.0/firmware-4.bin +lib/firmware/ath10k/QCA6174/hw3.0/notice_ath10k_firmware-4.txt +#lib/firmware/ath10k/QCA988X +#lib/firmware/ath10k/QCA988X/hw2.0 +lib/firmware/ath10k/QCA988X/hw2.0/board.bin +lib/firmware/ath10k/QCA988X/hw2.0/firmware-4.bin +lib/firmware/ath10k/QCA988X/hw2.0/firmware-5.bin +lib/firmware/ath10k/QCA988X/hw2.0/notice_ath10k_firmware-4.txt +lib/firmware/ath10k/QCA988X/hw2.0/notice_ath10k_firmware-5.txt +#lib/firmware/ath10k/QCA99X0 +#lib/firmware/ath10k/QCA99X0/hw2.0 +lib/firmware/ath10k/QCA99X0/hw2.0/board.bin +lib/firmware/ath10k/QCA99X0/hw2.0/firmware-5.bin +lib/firmware/ath10k/QCA99X0/hw2.0/notice_ath10k_firmware-5.txt diff --git a/config/rootfiles/common/bison b/config/rootfiles/common/bison index ca8d5ee..2304eca 100644 --- a/config/rootfiles/common/bison +++ b/config/rootfiles/common/bison @@ -8,6 +8,7 @@ #usr/share/bison/bison.m4 #usr/share/bison/c++-skel.m4 #usr/share/bison/c++.m4 +#usr/share/bison/c-like.m4 #usr/share/bison/c-skel.m4 #usr/share/bison/c.m4 #usr/share/bison/glr.c @@ -21,12 +22,32 @@ #usr/share/bison/m4sugar/foreach.m4 #usr/share/bison/m4sugar/m4sugar.m4 #usr/share/bison/stack.hh +#usr/share/bison/variant.hh #usr/share/bison/xslt #usr/share/bison/xslt/bison.xsl #usr/share/bison/xslt/xml2dot.xsl #usr/share/bison/xslt/xml2text.xsl #usr/share/bison/xslt/xml2xhtml.xsl #usr/share/bison/yacc.c +#usr/share/doc/bison-3.0.4 +#usr/share/doc/bison-3.0.4/AUTHORS +#usr/share/doc/bison-3.0.4/COPYING +#usr/share/doc/bison-3.0.4/NEWS +#usr/share/doc/bison-3.0.4/README +#usr/share/doc/bison-3.0.4/THANKS +#usr/share/doc/bison-3.0.4/TODO +#usr/share/doc/bison-3.0.4/examples +#usr/share/doc/bison-3.0.4/examples/calc++ +#usr/share/doc/bison-3.0.4/examples/calc++/calc++-driver.cc +#usr/share/doc/bison-3.0.4/examples/calc++/calc++-driver.hh +#usr/share/doc/bison-3.0.4/examples/calc++/calc++-parser.yy +#usr/share/doc/bison-3.0.4/examples/calc++/calc++-scanner.ll +#usr/share/doc/bison-3.0.4/examples/calc++/calc++.cc +#usr/share/doc/bison-3.0.4/examples/mfcalc +#usr/share/doc/bison-3.0.4/examples/mfcalc/calc.h +#usr/share/doc/bison-3.0.4/examples/mfcalc/mfcalc.y +#usr/share/doc/bison-3.0.4/examples/rpcalc +#usr/share/doc/bison-3.0.4/examples/rpcalc/rpcalc.y #usr/share/info/bison.info #usr/share/man/man1/bison.1 #usr/share/man/man1/yacc.1 diff --git a/config/rootfiles/common/diffutils b/config/rootfiles/common/diffutils index 9fe53d1..b00abdb 100644 --- a/config/rootfiles/common/diffutils +++ b/config/rootfiles/common/diffutils @@ -2,7 +2,9 @@ usr/bin/cmp usr/bin/diff #usr/bin/diff3 #usr/bin/sdiff +#usr/info #usr/info/diff.info +#usr/info/dir #usr/man/man1/cmp.1 #usr/man/man1/diff.1 #usr/man/man1/diff3.1 diff --git a/config/rootfiles/common/i586/binutils b/config/rootfiles/common/i586/binutils index d0997bf..fd5bfb8 100644 --- a/config/rootfiles/common/i586/binutils +++ b/config/rootfiles/common/i586/binutils @@ -91,12 +91,12 @@ #usr/lib/ldscripts/i386linux.xn #usr/lib/ldscripts/i386linux.xr #usr/lib/ldscripts/i386linux.xu -usr/lib/libbfd-2.22.so +usr/lib/libbfd-2.24.so #usr/lib/libbfd.a #usr/lib/libbfd.la #usr/lib/libbfd.so #usr/lib/libiberty.a -usr/lib/libopcodes-2.22.so +usr/lib/libopcodes-2.24.so #usr/lib/libopcodes.a #usr/lib/libopcodes.la #usr/lib/libopcodes.so diff --git a/config/rootfiles/common/i586/gcc b/config/rootfiles/common/i586/gcc index 10c712a..0e4b5c7 100644 --- a/config/rootfiles/common/i586/gcc +++ b/config/rootfiles/common/i586/gcc @@ -4,780 +4,1130 @@ #usr/bin/cpp #usr/bin/g++ #usr/bin/gcc -#usr/bin/gccbug +#usr/bin/gcc-ar +#usr/bin/gcc-nm +#usr/bin/gcc-ranlib #usr/bin/gcov #usr/bin/i586-pc-linux-gnu-c++ #usr/bin/i586-pc-linux-gnu-g++ #usr/bin/i586-pc-linux-gnu-gcc -#usr/bin/i586-pc-linux-gnu-gcc-4.4.7 +#usr/bin/i586-pc-linux-gnu-gcc-4.9.3 +#usr/bin/i586-pc-linux-gnu-gcc-ar +#usr/bin/i586-pc-linux-gnu-gcc-nm +#usr/bin/i586-pc-linux-gnu-gcc-ranlib #usr/include/c++ -#usr/include/c++/4.4.7 -#usr/include/c++/4.4.7/algorithm -#usr/include/c++/4.4.7/array -#usr/include/c++/4.4.7/backward -#usr/include/c++/4.4.7/backward/auto_ptr.h -#usr/include/c++/4.4.7/backward/backward_warning.h -#usr/include/c++/4.4.7/backward/binders.h -#usr/include/c++/4.4.7/backward/hash_fun.h -#usr/include/c++/4.4.7/backward/hash_map -#usr/include/c++/4.4.7/backward/hash_set -#usr/include/c++/4.4.7/backward/hashtable.h -#usr/include/c++/4.4.7/backward/strstream -#usr/include/c++/4.4.7/bits -#usr/include/c++/4.4.7/bits/algorithmfwd.h -#usr/include/c++/4.4.7/bits/allocator.h -#usr/include/c++/4.4.7/bits/atomic_0.h -#usr/include/c++/4.4.7/bits/atomic_2.h -#usr/include/c++/4.4.7/bits/atomicfwd_c.h -#usr/include/c++/4.4.7/bits/atomicfwd_cxx.h -#usr/include/c++/4.4.7/bits/basic_ios.h -#usr/include/c++/4.4.7/bits/basic_ios.tcc -#usr/include/c++/4.4.7/bits/basic_string.h -#usr/include/c++/4.4.7/bits/basic_string.tcc -#usr/include/c++/4.4.7/bits/boost_concept_check.h -#usr/include/c++/4.4.7/bits/char_traits.h -#usr/include/c++/4.4.7/bits/cmath.tcc -#usr/include/c++/4.4.7/bits/codecvt.h -#usr/include/c++/4.4.7/bits/concept_check.h -#usr/include/c++/4.4.7/bits/cpp_type_traits.h -#usr/include/c++/4.4.7/bits/deque.tcc -#usr/include/c++/4.4.7/bits/forward_list.h -#usr/include/c++/4.4.7/bits/forward_list.tcc -#usr/include/c++/4.4.7/bits/fstream.tcc -#usr/include/c++/4.4.7/bits/functexcept.h -#usr/include/c++/4.4.7/bits/functional_hash.h -#usr/include/c++/4.4.7/bits/gslice.h -#usr/include/c++/4.4.7/bits/gslice_array.h -#usr/include/c++/4.4.7/bits/hashtable.h -#usr/include/c++/4.4.7/bits/indirect_array.h -#usr/include/c++/4.4.7/bits/ios_base.h -#usr/include/c++/4.4.7/bits/istream.tcc -#usr/include/c++/4.4.7/bits/list.tcc -#usr/include/c++/4.4.7/bits/locale_classes.h -#usr/include/c++/4.4.7/bits/locale_classes.tcc -#usr/include/c++/4.4.7/bits/locale_facets.h -#usr/include/c++/4.4.7/bits/locale_facets.tcc -#usr/include/c++/4.4.7/bits/locale_facets_nonio.h -#usr/include/c++/4.4.7/bits/locale_facets_nonio.tcc -#usr/include/c++/4.4.7/bits/localefwd.h -#usr/include/c++/4.4.7/bits/mask_array.h -#usr/include/c++/4.4.7/bits/move.h -#usr/include/c++/4.4.7/bits/ostream.tcc -#usr/include/c++/4.4.7/bits/ostream_insert.h -#usr/include/c++/4.4.7/bits/postypes.h -#usr/include/c++/4.4.7/bits/shared_ptr.h -#usr/include/c++/4.4.7/bits/slice_array.h -#usr/include/c++/4.4.7/bits/sstream.tcc -#usr/include/c++/4.4.7/bits/stl_algo.h -#usr/include/c++/4.4.7/bits/stl_algobase.h -#usr/include/c++/4.4.7/bits/stl_bvector.h -#usr/include/c++/4.4.7/bits/stl_construct.h -#usr/include/c++/4.4.7/bits/stl_deque.h -#usr/include/c++/4.4.7/bits/stl_function.h -#usr/include/c++/4.4.7/bits/stl_heap.h -#usr/include/c++/4.4.7/bits/stl_iterator.h -#usr/include/c++/4.4.7/bits/stl_iterator_base_funcs.h -#usr/include/c++/4.4.7/bits/stl_iterator_base_types.h -#usr/include/c++/4.4.7/bits/stl_list.h -#usr/include/c++/4.4.7/bits/stl_map.h -#usr/include/c++/4.4.7/bits/stl_multimap.h -#usr/include/c++/4.4.7/bits/stl_multiset.h -#usr/include/c++/4.4.7/bits/stl_numeric.h -#usr/include/c++/4.4.7/bits/stl_pair.h -#usr/include/c++/4.4.7/bits/stl_queue.h -#usr/include/c++/4.4.7/bits/stl_raw_storage_iter.h -#usr/include/c++/4.4.7/bits/stl_relops.h -#usr/include/c++/4.4.7/bits/stl_set.h -#usr/include/c++/4.4.7/bits/stl_stack.h -#usr/include/c++/4.4.7/bits/stl_tempbuf.h -#usr/include/c++/4.4.7/bits/stl_tree.h -#usr/include/c++/4.4.7/bits/stl_uninitialized.h -#usr/include/c++/4.4.7/bits/stl_vector.h -#usr/include/c++/4.4.7/bits/stream_iterator.h -#usr/include/c++/4.4.7/bits/streambuf.tcc -#usr/include/c++/4.4.7/bits/streambuf_iterator.h -#usr/include/c++/4.4.7/bits/stringfwd.h -#usr/include/c++/4.4.7/bits/unique_ptr.h -#usr/include/c++/4.4.7/bits/valarray_after.h -#usr/include/c++/4.4.7/bits/valarray_array.h -#usr/include/c++/4.4.7/bits/valarray_array.tcc -#usr/include/c++/4.4.7/bits/valarray_before.h -#usr/include/c++/4.4.7/bits/vector.tcc -#usr/include/c++/4.4.7/bitset -#usr/include/c++/4.4.7/c++0x_warning.h -#usr/include/c++/4.4.7/cassert -#usr/include/c++/4.4.7/ccomplex -#usr/include/c++/4.4.7/cctype -#usr/include/c++/4.4.7/cerrno -#usr/include/c++/4.4.7/cfenv -#usr/include/c++/4.4.7/cfloat -#usr/include/c++/4.4.7/chrono -#usr/include/c++/4.4.7/cinttypes -#usr/include/c++/4.4.7/ciso646 -#usr/include/c++/4.4.7/climits -#usr/include/c++/4.4.7/clocale -#usr/include/c++/4.4.7/cmath -#usr/include/c++/4.4.7/complex -#usr/include/c++/4.4.7/complex.h -#usr/include/c++/4.4.7/condition_variable -#usr/include/c++/4.4.7/csetjmp -#usr/include/c++/4.4.7/csignal -#usr/include/c++/4.4.7/cstdarg -#usr/include/c++/4.4.7/cstdatomic -#usr/include/c++/4.4.7/cstdbool -#usr/include/c++/4.4.7/cstddef -#usr/include/c++/4.4.7/cstdint -#usr/include/c++/4.4.7/cstdio -#usr/include/c++/4.4.7/cstdlib -#usr/include/c++/4.4.7/cstring -#usr/include/c++/4.4.7/ctgmath -#usr/include/c++/4.4.7/ctime -#usr/include/c++/4.4.7/cwchar -#usr/include/c++/4.4.7/cwctype -#usr/include/c++/4.4.7/cxxabi-forced.h -#usr/include/c++/4.4.7/cxxabi.h -#usr/include/c++/4.4.7/debug -#usr/include/c++/4.4.7/debug/bitset -#usr/include/c++/4.4.7/debug/debug.h -#usr/include/c++/4.4.7/debug/deque -#usr/include/c++/4.4.7/debug/formatter.h -#usr/include/c++/4.4.7/debug/functions.h -#usr/include/c++/4.4.7/debug/list -#usr/include/c++/4.4.7/debug/macros.h -#usr/include/c++/4.4.7/debug/map -#usr/include/c++/4.4.7/debug/map.h -#usr/include/c++/4.4.7/debug/multimap.h -#usr/include/c++/4.4.7/debug/multiset.h -#usr/include/c++/4.4.7/debug/safe_base.h -#usr/include/c++/4.4.7/debug/safe_iterator.h -#usr/include/c++/4.4.7/debug/safe_iterator.tcc -#usr/include/c++/4.4.7/debug/safe_sequence.h -#usr/include/c++/4.4.7/debug/set -#usr/include/c++/4.4.7/debug/set.h -#usr/include/c++/4.4.7/debug/string -#usr/include/c++/4.4.7/debug/unordered_map -#usr/include/c++/4.4.7/debug/unordered_set -#usr/include/c++/4.4.7/debug/vector -#usr/include/c++/4.4.7/deque -#usr/include/c++/4.4.7/exception -#usr/include/c++/4.4.7/exception_defines.h -#usr/include/c++/4.4.7/exception_ptr.h -#usr/include/c++/4.4.7/ext -#usr/include/c++/4.4.7/ext/algorithm -#usr/include/c++/4.4.7/ext/array_allocator.h -#usr/include/c++/4.4.7/ext/atomicity.h -#usr/include/c++/4.4.7/ext/bitmap_allocator.h -#usr/include/c++/4.4.7/ext/cast.h -#usr/include/c++/4.4.7/ext/codecvt_specializations.h -#usr/include/c++/4.4.7/ext/concurrence.h -#usr/include/c++/4.4.7/ext/debug_allocator.h -#usr/include/c++/4.4.7/ext/enc_filebuf.h -#usr/include/c++/4.4.7/ext/extptr_allocator.h -#usr/include/c++/4.4.7/ext/functional -#usr/include/c++/4.4.7/ext/hash_map -#usr/include/c++/4.4.7/ext/hash_set -#usr/include/c++/4.4.7/ext/iterator -#usr/include/c++/4.4.7/ext/malloc_allocator.h -#usr/include/c++/4.4.7/ext/memory -#usr/include/c++/4.4.7/ext/mt_allocator.h -#usr/include/c++/4.4.7/ext/new_allocator.h -#usr/include/c++/4.4.7/ext/numeric -#usr/include/c++/4.4.7/ext/numeric_traits.h -#usr/include/c++/4.4.7/ext/pb_ds -#usr/include/c++/4.4.7/ext/pb_ds/assoc_container.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_types.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/entry_pred.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/resize_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cond_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/container_base_dispatch.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/debug_map_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn/eq_by_less.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/lu_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/child_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/head.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/internal_node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/leaf.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_metadata_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/point_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/priority_queue_base_dispatch.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/null_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_trace_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/null_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/sample_trie_e_access_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/string_trie_e_access_traits_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/type_utils.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/types_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/exception.hpp -#usr/include/c++/4.4.7/ext/pb_ds/hash_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/list_update_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/priority_queue.hpp -#usr/include/c++/4.4.7/ext/pb_ds/tag_and_trait.hpp -#usr/include/c++/4.4.7/ext/pb_ds/tree_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/trie_policy.hpp -#usr/include/c++/4.4.7/ext/pod_char_traits.h -#usr/include/c++/4.4.7/ext/pointer.h -#usr/include/c++/4.4.7/ext/pool_allocator.h -#usr/include/c++/4.4.7/ext/rb_tree -#usr/include/c++/4.4.7/ext/rc_string_base.h -#usr/include/c++/4.4.7/ext/rope -#usr/include/c++/4.4.7/ext/ropeimpl.h -#usr/include/c++/4.4.7/ext/slist -#usr/include/c++/4.4.7/ext/sso_string_base.h -#usr/include/c++/4.4.7/ext/stdio_filebuf.h -#usr/include/c++/4.4.7/ext/stdio_sync_filebuf.h -#usr/include/c++/4.4.7/ext/string_conversions.h -#usr/include/c++/4.4.7/ext/throw_allocator.h -#usr/include/c++/4.4.7/ext/type_traits.h -#usr/include/c++/4.4.7/ext/typelist.h -#usr/include/c++/4.4.7/ext/vstring.h -#usr/include/c++/4.4.7/ext/vstring.tcc -#usr/include/c++/4.4.7/ext/vstring_fwd.h -#usr/include/c++/4.4.7/ext/vstring_util.h -#usr/include/c++/4.4.7/fenv.h -#usr/include/c++/4.4.7/forward_list -#usr/include/c++/4.4.7/fstream -#usr/include/c++/4.4.7/functional -#usr/include/c++/4.4.7/i586-pc-linux-gnu -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/atomic_word.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/basic_file.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/c++allocator.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/c++config.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/c++io.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/c++locale.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/cpu_defines.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/ctype_base.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/ctype_inline.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/ctype_noninline.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/cxxabi_tweaks.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/error_constants.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/extc++.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/gthr-default.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/gthr-posix.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/gthr-single.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/gthr-tpf.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/gthr.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/messages_members.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/os_defines.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/stdc++.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/stdtr1c++.h -#usr/include/c++/4.4.7/i586-pc-linux-gnu/bits/time_members.h -#usr/include/c++/4.4.7/initializer_list -#usr/include/c++/4.4.7/iomanip -#usr/include/c++/4.4.7/ios -#usr/include/c++/4.4.7/iosfwd -#usr/include/c++/4.4.7/iostream -#usr/include/c++/4.4.7/istream -#usr/include/c++/4.4.7/iterator -#usr/include/c++/4.4.7/limits -#usr/include/c++/4.4.7/list -#usr/include/c++/4.4.7/locale -#usr/include/c++/4.4.7/map -#usr/include/c++/4.4.7/memory -#usr/include/c++/4.4.7/mutex -#usr/include/c++/4.4.7/new -#usr/include/c++/4.4.7/numeric -#usr/include/c++/4.4.7/ostream -#usr/include/c++/4.4.7/parallel -#usr/include/c++/4.4.7/parallel/algo.h -#usr/include/c++/4.4.7/parallel/algobase.h -#usr/include/c++/4.4.7/parallel/algorithm -#usr/include/c++/4.4.7/parallel/algorithmfwd.h -#usr/include/c++/4.4.7/parallel/balanced_quicksort.h -#usr/include/c++/4.4.7/parallel/base.h -#usr/include/c++/4.4.7/parallel/basic_iterator.h -#usr/include/c++/4.4.7/parallel/checkers.h -#usr/include/c++/4.4.7/parallel/compatibility.h -#usr/include/c++/4.4.7/parallel/compiletime_settings.h -#usr/include/c++/4.4.7/parallel/equally_split.h -#usr/include/c++/4.4.7/parallel/features.h -#usr/include/c++/4.4.7/parallel/find.h -#usr/include/c++/4.4.7/parallel/find_selectors.h -#usr/include/c++/4.4.7/parallel/for_each.h -#usr/include/c++/4.4.7/parallel/for_each_selectors.h -#usr/include/c++/4.4.7/parallel/iterator.h -#usr/include/c++/4.4.7/parallel/list_partition.h -#usr/include/c++/4.4.7/parallel/losertree.h -#usr/include/c++/4.4.7/parallel/merge.h -#usr/include/c++/4.4.7/parallel/multiseq_selection.h -#usr/include/c++/4.4.7/parallel/multiway_merge.h -#usr/include/c++/4.4.7/parallel/multiway_mergesort.h -#usr/include/c++/4.4.7/parallel/numeric -#usr/include/c++/4.4.7/parallel/numericfwd.h -#usr/include/c++/4.4.7/parallel/omp_loop.h -#usr/include/c++/4.4.7/parallel/omp_loop_static.h -#usr/include/c++/4.4.7/parallel/par_loop.h -#usr/include/c++/4.4.7/parallel/parallel.h -#usr/include/c++/4.4.7/parallel/partial_sum.h -#usr/include/c++/4.4.7/parallel/partition.h -#usr/include/c++/4.4.7/parallel/queue.h -#usr/include/c++/4.4.7/parallel/quicksort.h -#usr/include/c++/4.4.7/parallel/random_number.h -#usr/include/c++/4.4.7/parallel/random_shuffle.h -#usr/include/c++/4.4.7/parallel/search.h -#usr/include/c++/4.4.7/parallel/set_operations.h -#usr/include/c++/4.4.7/parallel/settings.h -#usr/include/c++/4.4.7/parallel/sort.h -#usr/include/c++/4.4.7/parallel/tags.h -#usr/include/c++/4.4.7/parallel/types.h -#usr/include/c++/4.4.7/parallel/unique_copy.h -#usr/include/c++/4.4.7/parallel/workstealing.h -#usr/include/c++/4.4.7/queue -#usr/include/c++/4.4.7/random -#usr/include/c++/4.4.7/ratio -#usr/include/c++/4.4.7/regex -#usr/include/c++/4.4.7/set -#usr/include/c++/4.4.7/sstream -#usr/include/c++/4.4.7/stack -#usr/include/c++/4.4.7/stdatomic.h -#usr/include/c++/4.4.7/stdexcept -#usr/include/c++/4.4.7/streambuf -#usr/include/c++/4.4.7/string -#usr/include/c++/4.4.7/system_error -#usr/include/c++/4.4.7/tgmath.h -#usr/include/c++/4.4.7/thread -#usr/include/c++/4.4.7/tr1 -#usr/include/c++/4.4.7/tr1/array -#usr/include/c++/4.4.7/tr1/bessel_function.tcc -#usr/include/c++/4.4.7/tr1/beta_function.tcc -#usr/include/c++/4.4.7/tr1/ccomplex -#usr/include/c++/4.4.7/tr1/cctype -#usr/include/c++/4.4.7/tr1/cfenv -#usr/include/c++/4.4.7/tr1/cfloat -#usr/include/c++/4.4.7/tr1/cinttypes -#usr/include/c++/4.4.7/tr1/climits -#usr/include/c++/4.4.7/tr1/cmath -#usr/include/c++/4.4.7/tr1/complex -#usr/include/c++/4.4.7/tr1/complex.h -#usr/include/c++/4.4.7/tr1/cstdarg -#usr/include/c++/4.4.7/tr1/cstdbool -#usr/include/c++/4.4.7/tr1/cstdint -#usr/include/c++/4.4.7/tr1/cstdio -#usr/include/c++/4.4.7/tr1/cstdlib -#usr/include/c++/4.4.7/tr1/ctgmath -#usr/include/c++/4.4.7/tr1/ctime -#usr/include/c++/4.4.7/tr1/ctype.h -#usr/include/c++/4.4.7/tr1/cwchar -#usr/include/c++/4.4.7/tr1/cwctype -#usr/include/c++/4.4.7/tr1/ell_integral.tcc -#usr/include/c++/4.4.7/tr1/exp_integral.tcc -#usr/include/c++/4.4.7/tr1/fenv.h -#usr/include/c++/4.4.7/tr1/float.h -#usr/include/c++/4.4.7/tr1/functional -#usr/include/c++/4.4.7/tr1/functional_hash.h -#usr/include/c++/4.4.7/tr1/gamma.tcc -#usr/include/c++/4.4.7/tr1/hashtable.h -#usr/include/c++/4.4.7/tr1/hypergeometric.tcc -#usr/include/c++/4.4.7/tr1/inttypes.h -#usr/include/c++/4.4.7/tr1/legendre_function.tcc -#usr/include/c++/4.4.7/tr1/limits.h -#usr/include/c++/4.4.7/tr1/math.h -#usr/include/c++/4.4.7/tr1/memory -#usr/include/c++/4.4.7/tr1/modified_bessel_func.tcc -#usr/include/c++/4.4.7/tr1/poly_hermite.tcc -#usr/include/c++/4.4.7/tr1/poly_laguerre.tcc -#usr/include/c++/4.4.7/tr1/random -#usr/include/c++/4.4.7/tr1/regex -#usr/include/c++/4.4.7/tr1/riemann_zeta.tcc -#usr/include/c++/4.4.7/tr1/shared_ptr.h -#usr/include/c++/4.4.7/tr1/special_function_util.h -#usr/include/c++/4.4.7/tr1/stdarg.h -#usr/include/c++/4.4.7/tr1/stdbool.h -#usr/include/c++/4.4.7/tr1/stdint.h -#usr/include/c++/4.4.7/tr1/stdio.h -#usr/include/c++/4.4.7/tr1/stdlib.h -#usr/include/c++/4.4.7/tr1/tgmath.h -#usr/include/c++/4.4.7/tr1/tuple -#usr/include/c++/4.4.7/tr1/type_traits -#usr/include/c++/4.4.7/tr1/unordered_map -#usr/include/c++/4.4.7/tr1/unordered_set -#usr/include/c++/4.4.7/tr1/utility -#usr/include/c++/4.4.7/tr1/wchar.h -#usr/include/c++/4.4.7/tr1/wctype.h -#usr/include/c++/4.4.7/tr1_impl -#usr/include/c++/4.4.7/tr1_impl/array -#usr/include/c++/4.4.7/tr1_impl/boost_sp_counted_base.h -#usr/include/c++/4.4.7/tr1_impl/cctype -#usr/include/c++/4.4.7/tr1_impl/cfenv -#usr/include/c++/4.4.7/tr1_impl/cinttypes -#usr/include/c++/4.4.7/tr1_impl/cmath -#usr/include/c++/4.4.7/tr1_impl/complex -#usr/include/c++/4.4.7/tr1_impl/cstdint -#usr/include/c++/4.4.7/tr1_impl/cstdio -#usr/include/c++/4.4.7/tr1_impl/cstdlib -#usr/include/c++/4.4.7/tr1_impl/cwchar -#usr/include/c++/4.4.7/tr1_impl/cwctype -#usr/include/c++/4.4.7/tr1_impl/functional -#usr/include/c++/4.4.7/tr1_impl/functional_hash.h -#usr/include/c++/4.4.7/tr1_impl/hashtable -#usr/include/c++/4.4.7/tr1_impl/hashtable_policy.h -#usr/include/c++/4.4.7/tr1_impl/random -#usr/include/c++/4.4.7/tr1_impl/random.tcc -#usr/include/c++/4.4.7/tr1_impl/regex -#usr/include/c++/4.4.7/tr1_impl/type_traits -#usr/include/c++/4.4.7/tr1_impl/unordered_map -#usr/include/c++/4.4.7/tr1_impl/unordered_set -#usr/include/c++/4.4.7/tr1_impl/utility -#usr/include/c++/4.4.7/tuple -#usr/include/c++/4.4.7/type_traits -#usr/include/c++/4.4.7/typeinfo -#usr/include/c++/4.4.7/unordered_map -#usr/include/c++/4.4.7/unordered_set -#usr/include/c++/4.4.7/utility -#usr/include/c++/4.4.7/valarray -#usr/include/c++/4.4.7/vector -#usr/info -#usr/info/cpp.info -#usr/info/cppinternals.info -#usr/info/dir -#usr/info/gcc.info -#usr/info/gccinstall.info -#usr/info/gccint.info -#usr/info/libgomp.info +#usr/include/c++/4.9.3 +#usr/include/c++/4.9.3/algorithm +#usr/include/c++/4.9.3/array +#usr/include/c++/4.9.3/atomic +#usr/include/c++/4.9.3/backward +#usr/include/c++/4.9.3/backward/auto_ptr.h +#usr/include/c++/4.9.3/backward/backward_warning.h +#usr/include/c++/4.9.3/backward/binders.h +#usr/include/c++/4.9.3/backward/hash_fun.h +#usr/include/c++/4.9.3/backward/hash_map +#usr/include/c++/4.9.3/backward/hash_set +#usr/include/c++/4.9.3/backward/hashtable.h +#usr/include/c++/4.9.3/backward/strstream +#usr/include/c++/4.9.3/bits +#usr/include/c++/4.9.3/bits/algorithmfwd.h +#usr/include/c++/4.9.3/bits/alloc_traits.h +#usr/include/c++/4.9.3/bits/allocator.h +#usr/include/c++/4.9.3/bits/atomic_base.h +#usr/include/c++/4.9.3/bits/atomic_lockfree_defines.h +#usr/include/c++/4.9.3/bits/basic_ios.h +#usr/include/c++/4.9.3/bits/basic_ios.tcc +#usr/include/c++/4.9.3/bits/basic_string.h +#usr/include/c++/4.9.3/bits/basic_string.tcc +#usr/include/c++/4.9.3/bits/boost_concept_check.h +#usr/include/c++/4.9.3/bits/c++0x_warning.h +#usr/include/c++/4.9.3/bits/c++14_warning.h +#usr/include/c++/4.9.3/bits/char_traits.h +#usr/include/c++/4.9.3/bits/codecvt.h +#usr/include/c++/4.9.3/bits/concept_check.h +#usr/include/c++/4.9.3/bits/cpp_type_traits.h +#usr/include/c++/4.9.3/bits/cxxabi_forced.h +#usr/include/c++/4.9.3/bits/deque.tcc +#usr/include/c++/4.9.3/bits/enable_special_members.h +#usr/include/c++/4.9.3/bits/exception_defines.h +#usr/include/c++/4.9.3/bits/exception_ptr.h +#usr/include/c++/4.9.3/bits/forward_list.h +#usr/include/c++/4.9.3/bits/forward_list.tcc +#usr/include/c++/4.9.3/bits/fstream.tcc +#usr/include/c++/4.9.3/bits/functexcept.h +#usr/include/c++/4.9.3/bits/functional_hash.h +#usr/include/c++/4.9.3/bits/gslice.h +#usr/include/c++/4.9.3/bits/gslice_array.h +#usr/include/c++/4.9.3/bits/hash_bytes.h +#usr/include/c++/4.9.3/bits/hashtable.h +#usr/include/c++/4.9.3/bits/hashtable_policy.h +#usr/include/c++/4.9.3/bits/indirect_array.h +#usr/include/c++/4.9.3/bits/ios_base.h +#usr/include/c++/4.9.3/bits/istream.tcc +#usr/include/c++/4.9.3/bits/list.tcc +#usr/include/c++/4.9.3/bits/locale_classes.h +#usr/include/c++/4.9.3/bits/locale_classes.tcc +#usr/include/c++/4.9.3/bits/locale_facets.h +#usr/include/c++/4.9.3/bits/locale_facets.tcc +#usr/include/c++/4.9.3/bits/locale_facets_nonio.h +#usr/include/c++/4.9.3/bits/locale_facets_nonio.tcc +#usr/include/c++/4.9.3/bits/localefwd.h +#usr/include/c++/4.9.3/bits/mask_array.h +#usr/include/c++/4.9.3/bits/memoryfwd.h +#usr/include/c++/4.9.3/bits/move.h +#usr/include/c++/4.9.3/bits/nested_exception.h +#usr/include/c++/4.9.3/bits/ostream.tcc +#usr/include/c++/4.9.3/bits/ostream_insert.h +#usr/include/c++/4.9.3/bits/parse_numbers.h +#usr/include/c++/4.9.3/bits/postypes.h +#usr/include/c++/4.9.3/bits/predefined_ops.h +#usr/include/c++/4.9.3/bits/ptr_traits.h +#usr/include/c++/4.9.3/bits/random.h +#usr/include/c++/4.9.3/bits/random.tcc +#usr/include/c++/4.9.3/bits/range_access.h +#usr/include/c++/4.9.3/bits/regex.h +#usr/include/c++/4.9.3/bits/regex.tcc +#usr/include/c++/4.9.3/bits/regex_automaton.h +#usr/include/c++/4.9.3/bits/regex_automaton.tcc +#usr/include/c++/4.9.3/bits/regex_compiler.h +#usr/include/c++/4.9.3/bits/regex_compiler.tcc +#usr/include/c++/4.9.3/bits/regex_constants.h +#usr/include/c++/4.9.3/bits/regex_error.h +#usr/include/c++/4.9.3/bits/regex_executor.h +#usr/include/c++/4.9.3/bits/regex_executor.tcc +#usr/include/c++/4.9.3/bits/regex_scanner.h +#usr/include/c++/4.9.3/bits/regex_scanner.tcc +#usr/include/c++/4.9.3/bits/shared_ptr.h +#usr/include/c++/4.9.3/bits/shared_ptr_base.h +#usr/include/c++/4.9.3/bits/slice_array.h +#usr/include/c++/4.9.3/bits/sstream.tcc +#usr/include/c++/4.9.3/bits/stl_algo.h +#usr/include/c++/4.9.3/bits/stl_algobase.h +#usr/include/c++/4.9.3/bits/stl_bvector.h +#usr/include/c++/4.9.3/bits/stl_construct.h +#usr/include/c++/4.9.3/bits/stl_deque.h +#usr/include/c++/4.9.3/bits/stl_function.h +#usr/include/c++/4.9.3/bits/stl_heap.h +#usr/include/c++/4.9.3/bits/stl_iterator.h +#usr/include/c++/4.9.3/bits/stl_iterator_base_funcs.h +#usr/include/c++/4.9.3/bits/stl_iterator_base_types.h +#usr/include/c++/4.9.3/bits/stl_list.h +#usr/include/c++/4.9.3/bits/stl_map.h +#usr/include/c++/4.9.3/bits/stl_multimap.h +#usr/include/c++/4.9.3/bits/stl_multiset.h +#usr/include/c++/4.9.3/bits/stl_numeric.h +#usr/include/c++/4.9.3/bits/stl_pair.h +#usr/include/c++/4.9.3/bits/stl_queue.h +#usr/include/c++/4.9.3/bits/stl_raw_storage_iter.h +#usr/include/c++/4.9.3/bits/stl_relops.h +#usr/include/c++/4.9.3/bits/stl_set.h +#usr/include/c++/4.9.3/bits/stl_stack.h +#usr/include/c++/4.9.3/bits/stl_tempbuf.h +#usr/include/c++/4.9.3/bits/stl_tree.h +#usr/include/c++/4.9.3/bits/stl_uninitialized.h +#usr/include/c++/4.9.3/bits/stl_vector.h +#usr/include/c++/4.9.3/bits/stream_iterator.h +#usr/include/c++/4.9.3/bits/streambuf.tcc +#usr/include/c++/4.9.3/bits/streambuf_iterator.h +#usr/include/c++/4.9.3/bits/stringfwd.h +#usr/include/c++/4.9.3/bits/unique_ptr.h +#usr/include/c++/4.9.3/bits/unordered_map.h +#usr/include/c++/4.9.3/bits/unordered_set.h +#usr/include/c++/4.9.3/bits/uses_allocator.h +#usr/include/c++/4.9.3/bits/valarray_after.h +#usr/include/c++/4.9.3/bits/valarray_array.h +#usr/include/c++/4.9.3/bits/valarray_array.tcc +#usr/include/c++/4.9.3/bits/valarray_before.h +#usr/include/c++/4.9.3/bits/vector.tcc +#usr/include/c++/4.9.3/bitset +#usr/include/c++/4.9.3/cassert +#usr/include/c++/4.9.3/ccomplex +#usr/include/c++/4.9.3/cctype +#usr/include/c++/4.9.3/cerrno +#usr/include/c++/4.9.3/cfenv +#usr/include/c++/4.9.3/cfloat +#usr/include/c++/4.9.3/chrono +#usr/include/c++/4.9.3/cinttypes +#usr/include/c++/4.9.3/ciso646 +#usr/include/c++/4.9.3/climits +#usr/include/c++/4.9.3/clocale +#usr/include/c++/4.9.3/cmath +#usr/include/c++/4.9.3/complex +#usr/include/c++/4.9.3/complex.h +#usr/include/c++/4.9.3/condition_variable +#usr/include/c++/4.9.3/csetjmp +#usr/include/c++/4.9.3/csignal +#usr/include/c++/4.9.3/cstdalign +#usr/include/c++/4.9.3/cstdarg +#usr/include/c++/4.9.3/cstdbool +#usr/include/c++/4.9.3/cstddef +#usr/include/c++/4.9.3/cstdint +#usr/include/c++/4.9.3/cstdio +#usr/include/c++/4.9.3/cstdlib +#usr/include/c++/4.9.3/cstring +#usr/include/c++/4.9.3/ctgmath +#usr/include/c++/4.9.3/ctime +#usr/include/c++/4.9.3/cwchar +#usr/include/c++/4.9.3/cwctype +#usr/include/c++/4.9.3/cxxabi.h +#usr/include/c++/4.9.3/debug +#usr/include/c++/4.9.3/debug/array +#usr/include/c++/4.9.3/debug/bitset +#usr/include/c++/4.9.3/debug/debug.h +#usr/include/c++/4.9.3/debug/deque +#usr/include/c++/4.9.3/debug/formatter.h +#usr/include/c++/4.9.3/debug/forward_list +#usr/include/c++/4.9.3/debug/functions.h +#usr/include/c++/4.9.3/debug/list +#usr/include/c++/4.9.3/debug/macros.h +#usr/include/c++/4.9.3/debug/map +#usr/include/c++/4.9.3/debug/map.h +#usr/include/c++/4.9.3/debug/multimap.h +#usr/include/c++/4.9.3/debug/multiset.h +#usr/include/c++/4.9.3/debug/safe_base.h +#usr/include/c++/4.9.3/debug/safe_iterator.h +#usr/include/c++/4.9.3/debug/safe_iterator.tcc +#usr/include/c++/4.9.3/debug/safe_local_iterator.h +#usr/include/c++/4.9.3/debug/safe_local_iterator.tcc +#usr/include/c++/4.9.3/debug/safe_sequence.h +#usr/include/c++/4.9.3/debug/safe_sequence.tcc +#usr/include/c++/4.9.3/debug/safe_unordered_base.h +#usr/include/c++/4.9.3/debug/safe_unordered_container.h +#usr/include/c++/4.9.3/debug/safe_unordered_container.tcc +#usr/include/c++/4.9.3/debug/set +#usr/include/c++/4.9.3/debug/set.h +#usr/include/c++/4.9.3/debug/string +#usr/include/c++/4.9.3/debug/unordered_map +#usr/include/c++/4.9.3/debug/unordered_set +#usr/include/c++/4.9.3/debug/vector +#usr/include/c++/4.9.3/decimal +#usr/include/c++/4.9.3/decimal/decimal +#usr/include/c++/4.9.3/decimal/decimal.h +#usr/include/c++/4.9.3/deque +#usr/include/c++/4.9.3/exception +#usr/include/c++/4.9.3/experimental +#usr/include/c++/4.9.3/experimental/optional +#usr/include/c++/4.9.3/experimental/string_view +#usr/include/c++/4.9.3/experimental/string_view.tcc +#usr/include/c++/4.9.3/ext +#usr/include/c++/4.9.3/ext/algorithm +#usr/include/c++/4.9.3/ext/aligned_buffer.h +#usr/include/c++/4.9.3/ext/alloc_traits.h +#usr/include/c++/4.9.3/ext/array_allocator.h +#usr/include/c++/4.9.3/ext/atomicity.h +#usr/include/c++/4.9.3/ext/bitmap_allocator.h +#usr/include/c++/4.9.3/ext/cast.h +#usr/include/c++/4.9.3/ext/cmath +#usr/include/c++/4.9.3/ext/codecvt_specializations.h +#usr/include/c++/4.9.3/ext/concurrence.h +#usr/include/c++/4.9.3/ext/debug_allocator.h +#usr/include/c++/4.9.3/ext/enc_filebuf.h +#usr/include/c++/4.9.3/ext/extptr_allocator.h +#usr/include/c++/4.9.3/ext/functional +#usr/include/c++/4.9.3/ext/hash_map +#usr/include/c++/4.9.3/ext/hash_set +#usr/include/c++/4.9.3/ext/iterator +#usr/include/c++/4.9.3/ext/malloc_allocator.h +#usr/include/c++/4.9.3/ext/memory +#usr/include/c++/4.9.3/ext/mt_allocator.h +#usr/include/c++/4.9.3/ext/new_allocator.h +#usr/include/c++/4.9.3/ext/numeric +#usr/include/c++/4.9.3/ext/numeric_traits.h +#usr/include/c++/4.9.3/ext/pb_ds +#usr/include/c++/4.9.3/ext/pb_ds/assoc_container.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/entry_pred.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/resize_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/branch_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/null_node_metadata.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cond_dealtor.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/container_base_dispatch.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/debug_map_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn/eq_by_less.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/lu_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/priority_queue_base_dispatch.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/standard_policies.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_trace_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/sample_trie_access_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/type_utils.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/types_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/exception.hpp +#usr/include/c++/4.9.3/ext/pb_ds/hash_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/list_update_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/priority_queue.hpp +#usr/include/c++/4.9.3/ext/pb_ds/tag_and_trait.hpp +#usr/include/c++/4.9.3/ext/pb_ds/tree_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/trie_policy.hpp +#usr/include/c++/4.9.3/ext/pod_char_traits.h +#usr/include/c++/4.9.3/ext/pointer.h +#usr/include/c++/4.9.3/ext/pool_allocator.h +#usr/include/c++/4.9.3/ext/random +#usr/include/c++/4.9.3/ext/random.tcc +#usr/include/c++/4.9.3/ext/rb_tree +#usr/include/c++/4.9.3/ext/rc_string_base.h +#usr/include/c++/4.9.3/ext/rope +#usr/include/c++/4.9.3/ext/ropeimpl.h +#usr/include/c++/4.9.3/ext/slist +#usr/include/c++/4.9.3/ext/sso_string_base.h +#usr/include/c++/4.9.3/ext/stdio_filebuf.h +#usr/include/c++/4.9.3/ext/stdio_sync_filebuf.h +#usr/include/c++/4.9.3/ext/string_conversions.h +#usr/include/c++/4.9.3/ext/throw_allocator.h +#usr/include/c++/4.9.3/ext/type_traits.h +#usr/include/c++/4.9.3/ext/typelist.h +#usr/include/c++/4.9.3/ext/vstring.h +#usr/include/c++/4.9.3/ext/vstring.tcc +#usr/include/c++/4.9.3/ext/vstring_fwd.h +#usr/include/c++/4.9.3/ext/vstring_util.h +#usr/include/c++/4.9.3/fenv.h +#usr/include/c++/4.9.3/forward_list +#usr/include/c++/4.9.3/fstream +#usr/include/c++/4.9.3/functional +#usr/include/c++/4.9.3/future +#usr/include/c++/4.9.3/i586-pc-linux-gnu +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/atomic_word.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/basic_file.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/c++allocator.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/c++config.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/c++io.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/c++locale.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/cpu_defines.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/ctype_base.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/ctype_inline.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/cxxabi_tweaks.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/error_constants.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/extc++.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/gthr-default.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/gthr-posix.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/gthr-single.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/gthr.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/messages_members.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/opt_random.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/os_defines.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/stdc++.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/stdtr1c++.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/bits/time_members.h +#usr/include/c++/4.9.3/i586-pc-linux-gnu/ext +#usr/include/c++/4.9.3/i586-pc-linux-gnu/ext/opt_random.h +#usr/include/c++/4.9.3/initializer_list +#usr/include/c++/4.9.3/iomanip +#usr/include/c++/4.9.3/ios +#usr/include/c++/4.9.3/iosfwd +#usr/include/c++/4.9.3/iostream +#usr/include/c++/4.9.3/istream +#usr/include/c++/4.9.3/iterator +#usr/include/c++/4.9.3/limits +#usr/include/c++/4.9.3/list +#usr/include/c++/4.9.3/locale +#usr/include/c++/4.9.3/map +#usr/include/c++/4.9.3/memory +#usr/include/c++/4.9.3/mutex +#usr/include/c++/4.9.3/new +#usr/include/c++/4.9.3/numeric +#usr/include/c++/4.9.3/ostream +#usr/include/c++/4.9.3/parallel +#usr/include/c++/4.9.3/parallel/algo.h +#usr/include/c++/4.9.3/parallel/algobase.h +#usr/include/c++/4.9.3/parallel/algorithm +#usr/include/c++/4.9.3/parallel/algorithmfwd.h +#usr/include/c++/4.9.3/parallel/balanced_quicksort.h +#usr/include/c++/4.9.3/parallel/base.h +#usr/include/c++/4.9.3/parallel/basic_iterator.h +#usr/include/c++/4.9.3/parallel/checkers.h +#usr/include/c++/4.9.3/parallel/compatibility.h +#usr/include/c++/4.9.3/parallel/compiletime_settings.h +#usr/include/c++/4.9.3/parallel/equally_split.h +#usr/include/c++/4.9.3/parallel/features.h +#usr/include/c++/4.9.3/parallel/find.h +#usr/include/c++/4.9.3/parallel/find_selectors.h +#usr/include/c++/4.9.3/parallel/for_each.h +#usr/include/c++/4.9.3/parallel/for_each_selectors.h +#usr/include/c++/4.9.3/parallel/iterator.h +#usr/include/c++/4.9.3/parallel/list_partition.h +#usr/include/c++/4.9.3/parallel/losertree.h +#usr/include/c++/4.9.3/parallel/merge.h +#usr/include/c++/4.9.3/parallel/multiseq_selection.h +#usr/include/c++/4.9.3/parallel/multiway_merge.h +#usr/include/c++/4.9.3/parallel/multiway_mergesort.h +#usr/include/c++/4.9.3/parallel/numeric +#usr/include/c++/4.9.3/parallel/numericfwd.h +#usr/include/c++/4.9.3/parallel/omp_loop.h +#usr/include/c++/4.9.3/parallel/omp_loop_static.h +#usr/include/c++/4.9.3/parallel/par_loop.h +#usr/include/c++/4.9.3/parallel/parallel.h +#usr/include/c++/4.9.3/parallel/partial_sum.h +#usr/include/c++/4.9.3/parallel/partition.h +#usr/include/c++/4.9.3/parallel/queue.h +#usr/include/c++/4.9.3/parallel/quicksort.h +#usr/include/c++/4.9.3/parallel/random_number.h +#usr/include/c++/4.9.3/parallel/random_shuffle.h +#usr/include/c++/4.9.3/parallel/search.h +#usr/include/c++/4.9.3/parallel/set_operations.h +#usr/include/c++/4.9.3/parallel/settings.h +#usr/include/c++/4.9.3/parallel/sort.h +#usr/include/c++/4.9.3/parallel/tags.h +#usr/include/c++/4.9.3/parallel/types.h +#usr/include/c++/4.9.3/parallel/unique_copy.h +#usr/include/c++/4.9.3/parallel/workstealing.h +#usr/include/c++/4.9.3/profile +#usr/include/c++/4.9.3/profile/array +#usr/include/c++/4.9.3/profile/base.h +#usr/include/c++/4.9.3/profile/bitset +#usr/include/c++/4.9.3/profile/deque +#usr/include/c++/4.9.3/profile/forward_list +#usr/include/c++/4.9.3/profile/impl +#usr/include/c++/4.9.3/profile/impl/profiler.h +#usr/include/c++/4.9.3/profile/impl/profiler_algos.h +#usr/include/c++/4.9.3/profile/impl/profiler_container_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_hash_func.h +#usr/include/c++/4.9.3/profile/impl/profiler_hashtable_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_list_to_slist.h +#usr/include/c++/4.9.3/profile/impl/profiler_list_to_vector.h +#usr/include/c++/4.9.3/profile/impl/profiler_map_to_unordered_map.h +#usr/include/c++/4.9.3/profile/impl/profiler_node.h +#usr/include/c++/4.9.3/profile/impl/profiler_state.h +#usr/include/c++/4.9.3/profile/impl/profiler_trace.h +#usr/include/c++/4.9.3/profile/impl/profiler_vector_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_vector_to_list.h +#usr/include/c++/4.9.3/profile/iterator_tracker.h +#usr/include/c++/4.9.3/profile/list +#usr/include/c++/4.9.3/profile/map +#usr/include/c++/4.9.3/profile/map.h +#usr/include/c++/4.9.3/profile/multimap.h +#usr/include/c++/4.9.3/profile/multiset.h +#usr/include/c++/4.9.3/profile/set +#usr/include/c++/4.9.3/profile/set.h +#usr/include/c++/4.9.3/profile/unordered_base.h +#usr/include/c++/4.9.3/profile/unordered_map +#usr/include/c++/4.9.3/profile/unordered_set +#usr/include/c++/4.9.3/profile/vector +#usr/include/c++/4.9.3/queue +#usr/include/c++/4.9.3/random +#usr/include/c++/4.9.3/ratio +#usr/include/c++/4.9.3/regex +#usr/include/c++/4.9.3/scoped_allocator +#usr/include/c++/4.9.3/set +#usr/include/c++/4.9.3/shared_mutex +#usr/include/c++/4.9.3/sstream +#usr/include/c++/4.9.3/stack +#usr/include/c++/4.9.3/stdexcept +#usr/include/c++/4.9.3/streambuf +#usr/include/c++/4.9.3/string +#usr/include/c++/4.9.3/system_error +#usr/include/c++/4.9.3/tgmath.h +#usr/include/c++/4.9.3/thread +#usr/include/c++/4.9.3/tr1 +#usr/include/c++/4.9.3/tr1/array +#usr/include/c++/4.9.3/tr1/bessel_function.tcc +#usr/include/c++/4.9.3/tr1/beta_function.tcc +#usr/include/c++/4.9.3/tr1/ccomplex +#usr/include/c++/4.9.3/tr1/cctype +#usr/include/c++/4.9.3/tr1/cfenv +#usr/include/c++/4.9.3/tr1/cfloat +#usr/include/c++/4.9.3/tr1/cinttypes +#usr/include/c++/4.9.3/tr1/climits +#usr/include/c++/4.9.3/tr1/cmath +#usr/include/c++/4.9.3/tr1/complex +#usr/include/c++/4.9.3/tr1/complex.h +#usr/include/c++/4.9.3/tr1/cstdarg +#usr/include/c++/4.9.3/tr1/cstdbool +#usr/include/c++/4.9.3/tr1/cstdint +#usr/include/c++/4.9.3/tr1/cstdio +#usr/include/c++/4.9.3/tr1/cstdlib +#usr/include/c++/4.9.3/tr1/ctgmath +#usr/include/c++/4.9.3/tr1/ctime +#usr/include/c++/4.9.3/tr1/ctype.h +#usr/include/c++/4.9.3/tr1/cwchar +#usr/include/c++/4.9.3/tr1/cwctype +#usr/include/c++/4.9.3/tr1/ell_integral.tcc +#usr/include/c++/4.9.3/tr1/exp_integral.tcc +#usr/include/c++/4.9.3/tr1/fenv.h +#usr/include/c++/4.9.3/tr1/float.h +#usr/include/c++/4.9.3/tr1/functional +#usr/include/c++/4.9.3/tr1/functional_hash.h +#usr/include/c++/4.9.3/tr1/gamma.tcc +#usr/include/c++/4.9.3/tr1/hashtable.h +#usr/include/c++/4.9.3/tr1/hashtable_policy.h +#usr/include/c++/4.9.3/tr1/hypergeometric.tcc +#usr/include/c++/4.9.3/tr1/inttypes.h +#usr/include/c++/4.9.3/tr1/legendre_function.tcc +#usr/include/c++/4.9.3/tr1/limits.h +#usr/include/c++/4.9.3/tr1/math.h +#usr/include/c++/4.9.3/tr1/memory +#usr/include/c++/4.9.3/tr1/modified_bessel_func.tcc +#usr/include/c++/4.9.3/tr1/poly_hermite.tcc +#usr/include/c++/4.9.3/tr1/poly_laguerre.tcc +#usr/include/c++/4.9.3/tr1/random +#usr/include/c++/4.9.3/tr1/random.h +#usr/include/c++/4.9.3/tr1/random.tcc +#usr/include/c++/4.9.3/tr1/regex +#usr/include/c++/4.9.3/tr1/riemann_zeta.tcc +#usr/include/c++/4.9.3/tr1/shared_ptr.h +#usr/include/c++/4.9.3/tr1/special_function_util.h +#usr/include/c++/4.9.3/tr1/stdarg.h +#usr/include/c++/4.9.3/tr1/stdbool.h +#usr/include/c++/4.9.3/tr1/stdint.h +#usr/include/c++/4.9.3/tr1/stdio.h +#usr/include/c++/4.9.3/tr1/stdlib.h +#usr/include/c++/4.9.3/tr1/tgmath.h +#usr/include/c++/4.9.3/tr1/tuple +#usr/include/c++/4.9.3/tr1/type_traits +#usr/include/c++/4.9.3/tr1/unordered_map +#usr/include/c++/4.9.3/tr1/unordered_map.h +#usr/include/c++/4.9.3/tr1/unordered_set +#usr/include/c++/4.9.3/tr1/unordered_set.h +#usr/include/c++/4.9.3/tr1/utility +#usr/include/c++/4.9.3/tr1/wchar.h +#usr/include/c++/4.9.3/tr1/wctype.h +#usr/include/c++/4.9.3/tr2 +#usr/include/c++/4.9.3/tr2/bool_set +#usr/include/c++/4.9.3/tr2/bool_set.tcc +#usr/include/c++/4.9.3/tr2/dynamic_bitset +#usr/include/c++/4.9.3/tr2/dynamic_bitset.tcc +#usr/include/c++/4.9.3/tr2/ratio +#usr/include/c++/4.9.3/tr2/type_traits +#usr/include/c++/4.9.3/tuple +#usr/include/c++/4.9.3/type_traits +#usr/include/c++/4.9.3/typeindex +#usr/include/c++/4.9.3/typeinfo +#usr/include/c++/4.9.3/unordered_map +#usr/include/c++/4.9.3/unordered_set +#usr/include/c++/4.9.3/utility +#usr/include/c++/4.9.3/valarray +#usr/include/c++/4.9.3/vector #usr/lib/gcc #usr/lib/gcc/i586-pc-linux-gnu -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7 -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/cc1 -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/cc1plus -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/collect2 -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtbegin.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtbeginS.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtbeginT.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtend.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtendS.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtfastmath.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtprec32.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtprec64.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/crtprec80.o -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/finclude -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include-fixed -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include-fixed/README -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include-fixed/limits.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include-fixed/syslimits.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/ammintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/avxintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/bmmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/cpuid.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/cross-stdarg.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/emmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/float.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/immintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/iso646.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/mf-runtime.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/mm3dnow.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/mm_malloc.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/mmintrin-common.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/mmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/nmmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/omp.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/pmmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/smmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/ssp -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/ssp/ssp.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/ssp/stdio.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/ssp/string.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/ssp/unistd.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/stdarg.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/stdbool.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/stddef.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/stdfix.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/tmmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/unwind.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/varargs.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/wmmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/x86intrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/include/xmmintrin.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/fixinc.sh -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/fixinc_list -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/fixincl -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/gsyslimits.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/include -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/include/README -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/include/limits.h -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/macro_list -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/mkheaders -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/mkheaders.conf -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/install-tools/mkinstalldirs -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/libgcc.a -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/libgcc_eh.a -#usr/lib/gcc/i586-pc-linux-gnu/4.4.7/libgcov.a +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3 +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/cc1 +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/cc1plus +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/collect2 +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtbegin.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtbeginS.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtbeginT.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtend.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtendS.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtfastmath.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtprec32.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtprec64.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/crtprec80.o +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/finclude +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include-fixed +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include-fixed/README +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include-fixed/limits.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include-fixed/syslimits.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/adxintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/ammintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/avx2intrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/avx512cdintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/avx512erintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/avx512fintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/avx512pfintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/avxintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/bmi2intrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/bmiintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/bmmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/cilk.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/cilk_api.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/cilk_api_linux.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/cilk_stub.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/cilk_undocumented.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/common.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/holder.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/hyperobject_base.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/metaprogramming.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_file.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_list.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_max.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_min.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_min_max.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_opadd.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_opand.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_opmul.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_opor.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_opxor.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_ostream.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cilk/reducer_string.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cpuid.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/cross-stdarg.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/emmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/f16cintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/float.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/fma4intrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/fmaintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/fxsrintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/ia32intrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/immintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/iso646.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/lwpintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/lzcntintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/mm3dnow.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/mm_malloc.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/mmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/nmmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/omp.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/pmmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/popcntintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/prfchwintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/quadmath.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/quadmath_weak.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/rdseedintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/rtmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/sanitizer +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/sanitizer/asan_interface.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/sanitizer/common_interface_defs.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/sanitizer/lsan_interface.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/shaintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/smmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/ssp +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/ssp/ssp.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/ssp/stdio.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/ssp/string.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/ssp/unistd.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stdalign.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stdarg.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stdatomic.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stdbool.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stddef.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stdfix.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stdint-gcc.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stdint.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/stdnoreturn.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/tbmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/tmmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/unwind.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/varargs.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/wmmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/x86intrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/xmmintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/xopintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/xsaveintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/xsaveoptintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/include/xtestintrin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/fixinc.sh +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/fixinc_list +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/fixincl +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/gsyslimits.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/include +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/include/README +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/include/limits.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/macro_list +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/mkheaders +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/mkheaders.conf +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/install-tools/mkinstalldirs +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/libgcc.a +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/libgcc_eh.a +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/libgcov.a +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/liblto_plugin.la +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/liblto_plugin.so +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/liblto_plugin.so.0 +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/liblto_plugin.so.0.0.0 +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/lto-wrapper +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/lto1 +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/gengtype +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/gtype.state +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ada +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ada/gcc-interface +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ada/gcc-interface/ada-tree.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/alias.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/all-tree.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/alloc-pool.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ansidecl.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/attribs.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/auto-host.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/b-header-vars +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/basic-block.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/bitmap.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/builtins.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/bversion.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/c-family +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/c-family/c-common.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/c-family/c-common.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/c-family/c-objc.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/c-family/c-pragma.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/c-family/c-pretty-print.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/c-tree.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/calls.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cfg-flags.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cfgexpand.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cfghooks.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cfgloop.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cgraph.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cif-code.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cilk-builtins.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cilkplus.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/dbxelf.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/elfos.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/glibc-stdint.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/gnu-user.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386 +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/att.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/gnu-user-common.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/gnu-user.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/i386-opts.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/i386-protos.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/i386.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/linux-common.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/linux.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/stringop.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/unix.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/i386/x86-tune.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/initfini-array.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/linux-android.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/linux-protos.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/linux.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/config/vxworks-dummy.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/configargs.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/context.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/coretypes.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cp +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cp/cp-tree.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cp/cp-tree.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cp/cxx-pretty-print.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cp/name-lookup.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cp/type-utils.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cppdefault.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/cpplib.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/debug.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/defaults.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/df.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/diagnostic-color.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/diagnostic-core.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/diagnostic.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/diagnostic.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/double-int.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/dumpfile.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/emit-rtl.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/except.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/filenames.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/fixed-value.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/flag-types.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/flags.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/fold-const.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/function.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gcc-plugin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gcc-symtab.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/genrtl.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ggc.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple-builder.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple-expr.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple-fold.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple-iterator.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple-low.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple-pretty-print.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple-ssa.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple-walk.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimple.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimplify-me.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gimplify.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gsstruct.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gtm-builtins.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/gtype-desc.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/hard-reg-set.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/hash-table.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/hashtab.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/highlev-plugin-common.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/hwint.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/incpath.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/input.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/insn-codes.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/insn-constants.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/insn-flags.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/insn-modes.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/insn-notes.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/internal-fn.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/internal-fn.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/intl.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ipa-prop.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ipa-ref-inline.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ipa-ref.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ipa-reference.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ipa-utils.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/is-a.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/java +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/java/java-tree.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/langhooks.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/libiberty.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/line-map.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/machmode.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/md5.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/mode-classes.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/objc +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/objc/objc-tree.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/obstack.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/omp-builtins.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/options.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/opts.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/output.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/params.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/params.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/pass-instances.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/pass_manager.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/plugin-api.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/plugin-version.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/plugin.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/plugin.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/pointer-set.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/predict.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/predict.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/prefix.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/pretty-print.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/print-rtl.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/print-tree.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/real.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/realmpfr.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/reg-notes.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/regset.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/resource.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/rtl.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/rtl.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/safe-ctype.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/sanitizer.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/sbitmap.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/splay-tree.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/ssa-iterators.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/statistics.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/stmt.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/stor-layout.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/stringpool.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/symtab.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/sync-builtins.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/system.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/target-hooks-macros.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/target.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/target.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/timevar.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/timevar.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tm-preds.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tm.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tm_p.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/toplev.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-cfg.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-cfgcleanup.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-check.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-core.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-dfa.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-dump.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-eh.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-hasher.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-inline.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-into-ssa.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-iterator.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-nested.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-object-size.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-outof-ssa.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-parloops.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-pass.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-phinodes.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-pretty-print.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-address.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-alias.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-coalesce.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-dom.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-loop-ivopts.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-loop-manip.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-loop-niter.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-loop.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-operands.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-sccvn.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-ter.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-threadedge.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa-threadupdate.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssa.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree-ssanames.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/tree.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/treestruct.def +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/varasm.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/vec.h +#usr/lib/gcc/i586-pc-linux-gnu/4.9.3/plugin/include/version.h +#usr/lib/libasan.a +#usr/lib/libasan.la +#usr/lib/libasan.so +usr/lib/libasan.so.1 +usr/lib/libasan.so.1.0.0 +usr/lib/libasan_preinit.o +#usr/lib/libatomic.a +#usr/lib/libatomic.la +usr/lib/libatomic.so +usr/lib/libatomic.so.1 +usr/lib/libatomic.so.1.1.0 +#usr/lib/libcilkrts.a +#usr/lib/libcilkrts.la +#usr/lib/libcilkrts.so +usr/lib/libcilkrts.so.5 +usr/lib/libcilkrts.so.5.0.0 +#usr/lib/libcilkrts.spec #usr/lib/libgomp.a #usr/lib/libgomp.la #usr/lib/libgomp.so usr/lib/libgomp.so.1 usr/lib/libgomp.so.1.0.0 #usr/lib/libgomp.spec -#usr/lib/libmudflap.a -#usr/lib/libmudflap.la -#usr/lib/libmudflap.so -usr/lib/libmudflap.so.0 -usr/lib/libmudflap.so.0.0.0 -#usr/lib/libmudflapth.a -#usr/lib/libmudflapth.la -#usr/lib/libmudflapth.so -usr/lib/libmudflapth.so.0 -usr/lib/libmudflapth.so.0.0.0 +#usr/lib/libitm.a +#usr/lib/libitm.la +#usr/lib/libitm.so +usr/lib/libitm.so.1 +usr/lib/libitm.so.1.0.0 +#usr/lib/libitm.spec +#usr/lib/libquadmath.a +#usr/lib/libquadmath.la +#usr/lib/libquadmath.so +usr/lib/libquadmath.so.0 +usr/lib/libquadmath.so.0.0.0 +#usr/lib/libsanitizer.spec #usr/lib/libssp.a #usr/lib/libssp.la #usr/lib/libssp.so @@ -786,16 +1136,39 @@ usr/lib/libssp.so.0.0.0 #usr/lib/libssp_nonshared.a #usr/lib/libssp_nonshared.la #usr/lib/libstdc++.a -usr/lib/libstdc++.so.6.0.13 +usr/lib/libstdc++.so.6.0.20 +#usr/lib/libstdc++.so.6.0.20-gdb.py #usr/lib/libsupc++.a #usr/lib/libsupc++.la -#usr/man -#usr/man/man1 -#usr/man/man1/cpp.1 -#usr/man/man1/g++.1 -#usr/man/man1/gcc.1 -#usr/man/man1/gcov.1 -#usr/man/man7 -#usr/man/man7/fsf-funding.7 -#usr/man/man7/gfdl.7 -#usr/man/man7/gpl.7 +#usr/lib/libubsan.a +#usr/lib/libubsan.la +#usr/lib/libubsan.so +usr/lib/libubsan.so.0 +usr/lib/libubsan.so.0.0.0 +#usr/lib/libvtv.a +#usr/lib/libvtv.la +#usr/lib/libvtv.so +usr/lib/libvtv.so.0 +usr/lib/libvtv.so.0.0.0 +#usr/share/gcc-4.9.3 +#usr/share/gcc-4.9.3/python +#usr/share/gcc-4.9.3/python/libstdcxx +#usr/share/gcc-4.9.3/python/libstdcxx/__init__.py +#usr/share/gcc-4.9.3/python/libstdcxx/v6 +#usr/share/gcc-4.9.3/python/libstdcxx/v6/__init__.py +#usr/share/gcc-4.9.3/python/libstdcxx/v6/printers.py +#usr/share/info/cpp.info +#usr/share/info/cppinternals.info +#usr/share/info/gcc.info +#usr/share/info/gccinstall.info +#usr/share/info/gccint.info +#usr/share/info/libgomp.info +#usr/share/info/libitm.info +#usr/share/info/libquadmath.info +#usr/share/man/man1/cpp.1 +#usr/share/man/man1/g++.1 +#usr/share/man/man1/gcc.1 +#usr/share/man/man1/gcov.1 +#usr/share/man/man7/fsf-funding.7 +#usr/share/man/man7/gfdl.7 +#usr/share/man/man7/gpl.7 diff --git a/config/rootfiles/common/i586/initscripts b/config/rootfiles/common/i586/initscripts index aabc8a6..80ae0dd 100644 --- a/config/rootfiles/common/i586/initscripts +++ b/config/rootfiles/common/i586/initscripts @@ -27,6 +27,7 @@ etc/rc.d/init.d/console #etc/rc.d/init.d/cyrus-sasl etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay +#etc/rc.d/init.d/dnsdist etc/rc.d/init.d/dnsmasq etc/rc.d/init.d/fcron #etc/rc.d/init.d/fetchmail diff --git a/config/rootfiles/common/libmpc b/config/rootfiles/common/libmpc new file mode 100644 index 0000000..c8684ce --- /dev/null +++ b/config/rootfiles/common/libmpc @@ -0,0 +1,7 @@ +#usr/include/mpc.h +#usr/lib/libmpc.a +#usr/lib/libmpc.la +#usr/lib/libmpc.so +usr/lib/libmpc.so.3 +usr/lib/libmpc.so.3.0.0 +#usr/share/info/mpc.info diff --git a/config/rootfiles/common/lua b/config/rootfiles/common/lua new file mode 100644 index 0000000..15d5995 --- /dev/null +++ b/config/rootfiles/common/lua @@ -0,0 +1,14 @@ +usr/bin/lua +usr/bin/luac +#usr/include/lauxlib.h +#usr/include/lua.h +#usr/include/lua.hpp +#usr/include/luaconf.h +#usr/include/lualib.h +usr/lib/liblua-5.3.so +#usr/lib/liblua.a +#usr/lib/liblua.la +usr/lib/liblua.so +#usr/lib/pkgconfig/lua.pc +#usr/share/man/man1/lua.1 +#usr/share/man/man1/luac.1 diff --git a/config/rootfiles/common/mt7601u-firmware b/config/rootfiles/common/mt7601u-firmware new file mode 100644 index 0000000..ebae229 --- /dev/null +++ b/config/rootfiles/common/mt7601u-firmware @@ -0,0 +1 @@ +lib/firmware/mt7601u.bin diff --git a/config/rootfiles/common/ncurses b/config/rootfiles/common/ncurses index 46b3bd9..da434e9 100644 --- a/config/rootfiles/common/ncurses +++ b/config/rootfiles/common/ncurses @@ -77,6 +77,8 @@ usr/lib/libtic.so.5.9 usr/lib/libtinfo.so.5 usr/lib/libtinfo.so.5.9 #usr/lib/terminfo +#usr/man +#usr/man/man1 #usr/man/man1/captoinfo.1m #usr/man/man1/clear.1 #usr/man/man1/infocmp.1m @@ -941,6 +943,7 @@ usr/lib/libtinfo.so.5.9 #usr/man/man5 #usr/man/man5/term.5 #usr/man/man5/terminfo.5 +#usr/man/man7 #usr/man/man7/term.7 #usr/share/tabset #usr/share/tabset/std diff --git a/config/rootfiles/common/ntp b/config/rootfiles/common/ntp index c6b95a5..fd1262e 100644 --- a/config/rootfiles/common/ntp +++ b/config/rootfiles/common/ntp @@ -10,6 +10,7 @@ usr/bin/ntpd usr/bin/ntpdate usr/bin/ntpdc usr/bin/ntpq +#usr/bin/ntpsnmpd usr/bin/ntptime usr/bin/ntptrace usr/bin/sntp @@ -276,6 +277,7 @@ usr/bin/update-leap #usr/share/man/man1/ntpdc.1 #usr/share/man/man1/ntpq.1 #usr/share/man/man1/ntptrace.1 +#usr/share/man/man1/ntpsnmpd.1 #usr/share/man/man1/sntp.1 #usr/share/man/man1/update-leap.1 #usr/share/man/man5/ntp.conf.5 diff --git a/config/rootfiles/common/stage2 b/config/rootfiles/common/stage2 index 5b763fd..07446b7 100644 --- a/config/rootfiles/common/stage2 +++ b/config/rootfiles/common/stage2 @@ -22,6 +22,7 @@ etc/mime.types etc/modprobe.d etc/modprobe.d/btmrvl_sdio.conf etc/modprobe.d/cfg80211.conf +etc/modprobe.d/nf_conntrack.conf etc/modprobe.d/pcspeaker.conf etc/modules.conf etc/mtab diff --git a/config/rootfiles/common/tzdata b/config/rootfiles/common/tzdata index a18ba0a..86b1e27 100644 --- a/config/rootfiles/common/tzdata +++ b/config/rootfiles/common/tzdata @@ -113,6 +113,7 @@ usr/share/zoneinfo #usr/share/zoneinfo/America/Eirunepe #usr/share/zoneinfo/America/El_Salvador #usr/share/zoneinfo/America/Ensenada +#usr/share/zoneinfo/America/Fort_Nelson #usr/share/zoneinfo/America/Fort_Wayne #usr/share/zoneinfo/America/Fortaleza #usr/share/zoneinfo/America/Glace_Bay @@ -717,6 +718,7 @@ usr/share/zoneinfo #usr/share/zoneinfo/posix/America/Eirunepe #usr/share/zoneinfo/posix/America/El_Salvador #usr/share/zoneinfo/posix/America/Ensenada +#usr/share/zoneinfo/posix/America/Fort_Nelson #usr/share/zoneinfo/posix/America/Fort_Wayne #usr/share/zoneinfo/posix/America/Fortaleza #usr/share/zoneinfo/posix/America/Glace_Bay @@ -1321,6 +1323,7 @@ usr/share/zoneinfo #usr/share/zoneinfo/right/America/Eirunepe #usr/share/zoneinfo/right/America/El_Salvador #usr/share/zoneinfo/right/America/Ensenada +#usr/share/zoneinfo/right/America/Fort_Nelson #usr/share/zoneinfo/right/America/Fort_Wayne #usr/share/zoneinfo/right/America/Fortaleza #usr/share/zoneinfo/right/America/Glace_Bay diff --git a/config/rootfiles/common/x86_64/binutils b/config/rootfiles/common/x86_64/binutils index ce6a6fe..b1f819c 100644 --- a/config/rootfiles/common/x86_64/binutils +++ b/config/rootfiles/common/x86_64/binutils @@ -91,12 +91,12 @@ #usr/lib/ldscripts/i386linux.xn #usr/lib/ldscripts/i386linux.xr #usr/lib/ldscripts/i386linux.xu -#usr/lib/libbfd-2.22.so +#usr/lib/libbfd-2.24.so #usr/lib/libbfd.a #usr/lib/libbfd.la #usr/lib/libbfd.so #usr/lib/libiberty.a -#usr/lib/libopcodes-2.22.so +#usr/lib/libopcodes-2.24.so #usr/lib/libopcodes.a #usr/lib/libopcodes.la #usr/lib/libopcodes.so diff --git a/config/rootfiles/common/x86_64/gcc b/config/rootfiles/common/x86_64/gcc index 3c1a63f..e378d93 100644 --- a/config/rootfiles/common/x86_64/gcc +++ b/config/rootfiles/common/x86_64/gcc @@ -4,780 +4,1137 @@ #usr/bin/cpp #usr/bin/g++ #usr/bin/gcc -#usr/bin/gccbug +#usr/bin/gcc-ar +#usr/bin/gcc-nm +#usr/bin/gcc-ranlib #usr/bin/gcov #usr/bin/x86_64-unknown-linux-gnu-c++ #usr/bin/x86_64-unknown-linux-gnu-g++ #usr/bin/x86_64-unknown-linux-gnu-gcc -#usr/bin/x86_64-unknown-linux-gnu-gcc-4.4.7 +#usr/bin/x86_64-unknown-linux-gnu-gcc-4.9.3 +#usr/bin/x86_64-unknown-linux-gnu-gcc-ar +#usr/bin/x86_64-unknown-linux-gnu-gcc-nm +#usr/bin/x86_64-unknown-linux-gnu-gcc-ranlib #usr/include/c++ -#usr/include/c++/4.4.7 -#usr/include/c++/4.4.7/algorithm -#usr/include/c++/4.4.7/array -#usr/include/c++/4.4.7/backward -#usr/include/c++/4.4.7/backward/auto_ptr.h -#usr/include/c++/4.4.7/backward/backward_warning.h -#usr/include/c++/4.4.7/backward/binders.h -#usr/include/c++/4.4.7/backward/hash_fun.h -#usr/include/c++/4.4.7/backward/hash_map -#usr/include/c++/4.4.7/backward/hash_set -#usr/include/c++/4.4.7/backward/hashtable.h -#usr/include/c++/4.4.7/backward/strstream -#usr/include/c++/4.4.7/bits -#usr/include/c++/4.4.7/bits/algorithmfwd.h -#usr/include/c++/4.4.7/bits/allocator.h -#usr/include/c++/4.4.7/bits/atomic_0.h -#usr/include/c++/4.4.7/bits/atomic_2.h -#usr/include/c++/4.4.7/bits/atomicfwd_c.h -#usr/include/c++/4.4.7/bits/atomicfwd_cxx.h -#usr/include/c++/4.4.7/bits/basic_ios.h -#usr/include/c++/4.4.7/bits/basic_ios.tcc -#usr/include/c++/4.4.7/bits/basic_string.h -#usr/include/c++/4.4.7/bits/basic_string.tcc -#usr/include/c++/4.4.7/bits/boost_concept_check.h -#usr/include/c++/4.4.7/bits/char_traits.h -#usr/include/c++/4.4.7/bits/cmath.tcc -#usr/include/c++/4.4.7/bits/codecvt.h -#usr/include/c++/4.4.7/bits/concept_check.h -#usr/include/c++/4.4.7/bits/cpp_type_traits.h -#usr/include/c++/4.4.7/bits/deque.tcc -#usr/include/c++/4.4.7/bits/forward_list.h -#usr/include/c++/4.4.7/bits/forward_list.tcc -#usr/include/c++/4.4.7/bits/fstream.tcc -#usr/include/c++/4.4.7/bits/functexcept.h -#usr/include/c++/4.4.7/bits/functional_hash.h -#usr/include/c++/4.4.7/bits/gslice.h -#usr/include/c++/4.4.7/bits/gslice_array.h -#usr/include/c++/4.4.7/bits/hashtable.h -#usr/include/c++/4.4.7/bits/indirect_array.h -#usr/include/c++/4.4.7/bits/ios_base.h -#usr/include/c++/4.4.7/bits/istream.tcc -#usr/include/c++/4.4.7/bits/list.tcc -#usr/include/c++/4.4.7/bits/locale_classes.h -#usr/include/c++/4.4.7/bits/locale_classes.tcc -#usr/include/c++/4.4.7/bits/locale_facets.h -#usr/include/c++/4.4.7/bits/locale_facets.tcc -#usr/include/c++/4.4.7/bits/locale_facets_nonio.h -#usr/include/c++/4.4.7/bits/locale_facets_nonio.tcc -#usr/include/c++/4.4.7/bits/localefwd.h -#usr/include/c++/4.4.7/bits/mask_array.h -#usr/include/c++/4.4.7/bits/move.h -#usr/include/c++/4.4.7/bits/ostream.tcc -#usr/include/c++/4.4.7/bits/ostream_insert.h -#usr/include/c++/4.4.7/bits/postypes.h -#usr/include/c++/4.4.7/bits/shared_ptr.h -#usr/include/c++/4.4.7/bits/slice_array.h -#usr/include/c++/4.4.7/bits/sstream.tcc -#usr/include/c++/4.4.7/bits/stl_algo.h -#usr/include/c++/4.4.7/bits/stl_algobase.h -#usr/include/c++/4.4.7/bits/stl_bvector.h -#usr/include/c++/4.4.7/bits/stl_construct.h -#usr/include/c++/4.4.7/bits/stl_deque.h -#usr/include/c++/4.4.7/bits/stl_function.h -#usr/include/c++/4.4.7/bits/stl_heap.h -#usr/include/c++/4.4.7/bits/stl_iterator.h -#usr/include/c++/4.4.7/bits/stl_iterator_base_funcs.h -#usr/include/c++/4.4.7/bits/stl_iterator_base_types.h -#usr/include/c++/4.4.7/bits/stl_list.h -#usr/include/c++/4.4.7/bits/stl_map.h -#usr/include/c++/4.4.7/bits/stl_multimap.h -#usr/include/c++/4.4.7/bits/stl_multiset.h -#usr/include/c++/4.4.7/bits/stl_numeric.h -#usr/include/c++/4.4.7/bits/stl_pair.h -#usr/include/c++/4.4.7/bits/stl_queue.h -#usr/include/c++/4.4.7/bits/stl_raw_storage_iter.h -#usr/include/c++/4.4.7/bits/stl_relops.h -#usr/include/c++/4.4.7/bits/stl_set.h -#usr/include/c++/4.4.7/bits/stl_stack.h -#usr/include/c++/4.4.7/bits/stl_tempbuf.h -#usr/include/c++/4.4.7/bits/stl_tree.h -#usr/include/c++/4.4.7/bits/stl_uninitialized.h -#usr/include/c++/4.4.7/bits/stl_vector.h -#usr/include/c++/4.4.7/bits/stream_iterator.h -#usr/include/c++/4.4.7/bits/streambuf.tcc -#usr/include/c++/4.4.7/bits/streambuf_iterator.h -#usr/include/c++/4.4.7/bits/stringfwd.h -#usr/include/c++/4.4.7/bits/unique_ptr.h -#usr/include/c++/4.4.7/bits/valarray_after.h -#usr/include/c++/4.4.7/bits/valarray_array.h -#usr/include/c++/4.4.7/bits/valarray_array.tcc -#usr/include/c++/4.4.7/bits/valarray_before.h -#usr/include/c++/4.4.7/bits/vector.tcc -#usr/include/c++/4.4.7/bitset -#usr/include/c++/4.4.7/c++0x_warning.h -#usr/include/c++/4.4.7/cassert -#usr/include/c++/4.4.7/ccomplex -#usr/include/c++/4.4.7/cctype -#usr/include/c++/4.4.7/cerrno -#usr/include/c++/4.4.7/cfenv -#usr/include/c++/4.4.7/cfloat -#usr/include/c++/4.4.7/chrono -#usr/include/c++/4.4.7/cinttypes -#usr/include/c++/4.4.7/ciso646 -#usr/include/c++/4.4.7/climits -#usr/include/c++/4.4.7/clocale -#usr/include/c++/4.4.7/cmath -#usr/include/c++/4.4.7/complex -#usr/include/c++/4.4.7/complex.h -#usr/include/c++/4.4.7/condition_variable -#usr/include/c++/4.4.7/csetjmp -#usr/include/c++/4.4.7/csignal -#usr/include/c++/4.4.7/cstdarg -#usr/include/c++/4.4.7/cstdatomic -#usr/include/c++/4.4.7/cstdbool -#usr/include/c++/4.4.7/cstddef -#usr/include/c++/4.4.7/cstdint -#usr/include/c++/4.4.7/cstdio -#usr/include/c++/4.4.7/cstdlib -#usr/include/c++/4.4.7/cstring -#usr/include/c++/4.4.7/ctgmath -#usr/include/c++/4.4.7/ctime -#usr/include/c++/4.4.7/cwchar -#usr/include/c++/4.4.7/cwctype -#usr/include/c++/4.4.7/cxxabi-forced.h -#usr/include/c++/4.4.7/cxxabi.h -#usr/include/c++/4.4.7/debug -#usr/include/c++/4.4.7/debug/bitset -#usr/include/c++/4.4.7/debug/debug.h -#usr/include/c++/4.4.7/debug/deque -#usr/include/c++/4.4.7/debug/formatter.h -#usr/include/c++/4.4.7/debug/functions.h -#usr/include/c++/4.4.7/debug/list -#usr/include/c++/4.4.7/debug/macros.h -#usr/include/c++/4.4.7/debug/map -#usr/include/c++/4.4.7/debug/map.h -#usr/include/c++/4.4.7/debug/multimap.h -#usr/include/c++/4.4.7/debug/multiset.h -#usr/include/c++/4.4.7/debug/safe_base.h -#usr/include/c++/4.4.7/debug/safe_iterator.h -#usr/include/c++/4.4.7/debug/safe_iterator.tcc -#usr/include/c++/4.4.7/debug/safe_sequence.h -#usr/include/c++/4.4.7/debug/set -#usr/include/c++/4.4.7/debug/set.h -#usr/include/c++/4.4.7/debug/string -#usr/include/c++/4.4.7/debug/unordered_map -#usr/include/c++/4.4.7/debug/unordered_set -#usr/include/c++/4.4.7/debug/vector -#usr/include/c++/4.4.7/deque -#usr/include/c++/4.4.7/exception -#usr/include/c++/4.4.7/exception_defines.h -#usr/include/c++/4.4.7/exception_ptr.h -#usr/include/c++/4.4.7/ext -#usr/include/c++/4.4.7/ext/algorithm -#usr/include/c++/4.4.7/ext/array_allocator.h -#usr/include/c++/4.4.7/ext/atomicity.h -#usr/include/c++/4.4.7/ext/bitmap_allocator.h -#usr/include/c++/4.4.7/ext/cast.h -#usr/include/c++/4.4.7/ext/codecvt_specializations.h -#usr/include/c++/4.4.7/ext/concurrence.h -#usr/include/c++/4.4.7/ext/debug_allocator.h -#usr/include/c++/4.4.7/ext/enc_filebuf.h -#usr/include/c++/4.4.7/ext/extptr_allocator.h -#usr/include/c++/4.4.7/ext/functional -#usr/include/c++/4.4.7/ext/hash_map -#usr/include/c++/4.4.7/ext/hash_set -#usr/include/c++/4.4.7/ext/iterator -#usr/include/c++/4.4.7/ext/malloc_allocator.h -#usr/include/c++/4.4.7/ext/memory -#usr/include/c++/4.4.7/ext/mt_allocator.h -#usr/include/c++/4.4.7/ext/new_allocator.h -#usr/include/c++/4.4.7/ext/numeric -#usr/include/c++/4.4.7/ext/numeric_traits.h -#usr/include/c++/4.4.7/ext/pb_ds -#usr/include/c++/4.4.7/ext/pb_ds/assoc_container.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/basic_tree_policy_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/null_node_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_tree_policy/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/basic_types.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/cond_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/cond_key_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/bin_search_tree_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/entry_pred.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/resize_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/cond_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/container_base_dispatch.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/debug_map_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn/eq_by_less.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/lu_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/counter_lu_metadata.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/counter_lu_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/mtf_lu_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/cond_dtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/ov_tree_map_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/child_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/cond_dtor_entry_dealtor.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/const_child_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/head.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/internal_node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/leaf.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/node_metadata_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/point_iterators.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/split_join_branch_bag.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/synth_e_access_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/priority_queue_base_dispatch.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rb_tree_map_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/node.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/splay_tree_/traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/standard_policies.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_ -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/null_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/tree_trace_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/null_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/sample_trie_e_access_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/string_trie_e_access_traits_imp.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/type_utils.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/types_traits.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/const_point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp -#usr/include/c++/4.4.7/ext/pb_ds/exception.hpp -#usr/include/c++/4.4.7/ext/pb_ds/hash_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/list_update_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/priority_queue.hpp -#usr/include/c++/4.4.7/ext/pb_ds/tag_and_trait.hpp -#usr/include/c++/4.4.7/ext/pb_ds/tree_policy.hpp -#usr/include/c++/4.4.7/ext/pb_ds/trie_policy.hpp -#usr/include/c++/4.4.7/ext/pod_char_traits.h -#usr/include/c++/4.4.7/ext/pointer.h -#usr/include/c++/4.4.7/ext/pool_allocator.h -#usr/include/c++/4.4.7/ext/rb_tree -#usr/include/c++/4.4.7/ext/rc_string_base.h -#usr/include/c++/4.4.7/ext/rope -#usr/include/c++/4.4.7/ext/ropeimpl.h -#usr/include/c++/4.4.7/ext/slist -#usr/include/c++/4.4.7/ext/sso_string_base.h -#usr/include/c++/4.4.7/ext/stdio_filebuf.h -#usr/include/c++/4.4.7/ext/stdio_sync_filebuf.h -#usr/include/c++/4.4.7/ext/string_conversions.h -#usr/include/c++/4.4.7/ext/throw_allocator.h -#usr/include/c++/4.4.7/ext/type_traits.h -#usr/include/c++/4.4.7/ext/typelist.h -#usr/include/c++/4.4.7/ext/vstring.h -#usr/include/c++/4.4.7/ext/vstring.tcc -#usr/include/c++/4.4.7/ext/vstring_fwd.h -#usr/include/c++/4.4.7/ext/vstring_util.h -#usr/include/c++/4.4.7/fenv.h -#usr/include/c++/4.4.7/forward_list -#usr/include/c++/4.4.7/fstream -#usr/include/c++/4.4.7/functional -#usr/include/c++/4.4.7/initializer_list -#usr/include/c++/4.4.7/iomanip -#usr/include/c++/4.4.7/ios -#usr/include/c++/4.4.7/iosfwd -#usr/include/c++/4.4.7/iostream -#usr/include/c++/4.4.7/istream -#usr/include/c++/4.4.7/iterator -#usr/include/c++/4.4.7/limits -#usr/include/c++/4.4.7/list -#usr/include/c++/4.4.7/locale -#usr/include/c++/4.4.7/map -#usr/include/c++/4.4.7/memory -#usr/include/c++/4.4.7/mutex -#usr/include/c++/4.4.7/new -#usr/include/c++/4.4.7/numeric -#usr/include/c++/4.4.7/ostream -#usr/include/c++/4.4.7/parallel -#usr/include/c++/4.4.7/parallel/algo.h -#usr/include/c++/4.4.7/parallel/algobase.h -#usr/include/c++/4.4.7/parallel/algorithm -#usr/include/c++/4.4.7/parallel/algorithmfwd.h -#usr/include/c++/4.4.7/parallel/balanced_quicksort.h -#usr/include/c++/4.4.7/parallel/base.h -#usr/include/c++/4.4.7/parallel/basic_iterator.h -#usr/include/c++/4.4.7/parallel/checkers.h -#usr/include/c++/4.4.7/parallel/compatibility.h -#usr/include/c++/4.4.7/parallel/compiletime_settings.h -#usr/include/c++/4.4.7/parallel/equally_split.h -#usr/include/c++/4.4.7/parallel/features.h -#usr/include/c++/4.4.7/parallel/find.h -#usr/include/c++/4.4.7/parallel/find_selectors.h -#usr/include/c++/4.4.7/parallel/for_each.h -#usr/include/c++/4.4.7/parallel/for_each_selectors.h -#usr/include/c++/4.4.7/parallel/iterator.h -#usr/include/c++/4.4.7/parallel/list_partition.h -#usr/include/c++/4.4.7/parallel/losertree.h -#usr/include/c++/4.4.7/parallel/merge.h -#usr/include/c++/4.4.7/parallel/multiseq_selection.h -#usr/include/c++/4.4.7/parallel/multiway_merge.h -#usr/include/c++/4.4.7/parallel/multiway_mergesort.h -#usr/include/c++/4.4.7/parallel/numeric -#usr/include/c++/4.4.7/parallel/numericfwd.h -#usr/include/c++/4.4.7/parallel/omp_loop.h -#usr/include/c++/4.4.7/parallel/omp_loop_static.h -#usr/include/c++/4.4.7/parallel/par_loop.h -#usr/include/c++/4.4.7/parallel/parallel.h -#usr/include/c++/4.4.7/parallel/partial_sum.h -#usr/include/c++/4.4.7/parallel/partition.h -#usr/include/c++/4.4.7/parallel/queue.h -#usr/include/c++/4.4.7/parallel/quicksort.h -#usr/include/c++/4.4.7/parallel/random_number.h -#usr/include/c++/4.4.7/parallel/random_shuffle.h -#usr/include/c++/4.4.7/parallel/search.h -#usr/include/c++/4.4.7/parallel/set_operations.h -#usr/include/c++/4.4.7/parallel/settings.h -#usr/include/c++/4.4.7/parallel/sort.h -#usr/include/c++/4.4.7/parallel/tags.h -#usr/include/c++/4.4.7/parallel/types.h -#usr/include/c++/4.4.7/parallel/unique_copy.h -#usr/include/c++/4.4.7/parallel/workstealing.h -#usr/include/c++/4.4.7/queue -#usr/include/c++/4.4.7/random -#usr/include/c++/4.4.7/ratio -#usr/include/c++/4.4.7/regex -#usr/include/c++/4.4.7/set -#usr/include/c++/4.4.7/sstream -#usr/include/c++/4.4.7/stack -#usr/include/c++/4.4.7/stdatomic.h -#usr/include/c++/4.4.7/stdexcept -#usr/include/c++/4.4.7/streambuf -#usr/include/c++/4.4.7/string -#usr/include/c++/4.4.7/system_error -#usr/include/c++/4.4.7/tgmath.h -#usr/include/c++/4.4.7/thread -#usr/include/c++/4.4.7/tr1 -#usr/include/c++/4.4.7/tr1/array -#usr/include/c++/4.4.7/tr1/bessel_function.tcc -#usr/include/c++/4.4.7/tr1/beta_function.tcc -#usr/include/c++/4.4.7/tr1/ccomplex -#usr/include/c++/4.4.7/tr1/cctype -#usr/include/c++/4.4.7/tr1/cfenv -#usr/include/c++/4.4.7/tr1/cfloat -#usr/include/c++/4.4.7/tr1/cinttypes -#usr/include/c++/4.4.7/tr1/climits -#usr/include/c++/4.4.7/tr1/cmath -#usr/include/c++/4.4.7/tr1/complex -#usr/include/c++/4.4.7/tr1/complex.h -#usr/include/c++/4.4.7/tr1/cstdarg -#usr/include/c++/4.4.7/tr1/cstdbool -#usr/include/c++/4.4.7/tr1/cstdint -#usr/include/c++/4.4.7/tr1/cstdio -#usr/include/c++/4.4.7/tr1/cstdlib -#usr/include/c++/4.4.7/tr1/ctgmath -#usr/include/c++/4.4.7/tr1/ctime -#usr/include/c++/4.4.7/tr1/ctype.h -#usr/include/c++/4.4.7/tr1/cwchar -#usr/include/c++/4.4.7/tr1/cwctype -#usr/include/c++/4.4.7/tr1/ell_integral.tcc -#usr/include/c++/4.4.7/tr1/exp_integral.tcc -#usr/include/c++/4.4.7/tr1/fenv.h -#usr/include/c++/4.4.7/tr1/float.h -#usr/include/c++/4.4.7/tr1/functional -#usr/include/c++/4.4.7/tr1/functional_hash.h -#usr/include/c++/4.4.7/tr1/gamma.tcc -#usr/include/c++/4.4.7/tr1/hashtable.h -#usr/include/c++/4.4.7/tr1/hypergeometric.tcc -#usr/include/c++/4.4.7/tr1/inttypes.h -#usr/include/c++/4.4.7/tr1/legendre_function.tcc -#usr/include/c++/4.4.7/tr1/limits.h -#usr/include/c++/4.4.7/tr1/math.h -#usr/include/c++/4.4.7/tr1/memory -#usr/include/c++/4.4.7/tr1/modified_bessel_func.tcc -#usr/include/c++/4.4.7/tr1/poly_hermite.tcc -#usr/include/c++/4.4.7/tr1/poly_laguerre.tcc -#usr/include/c++/4.4.7/tr1/random -#usr/include/c++/4.4.7/tr1/regex -#usr/include/c++/4.4.7/tr1/riemann_zeta.tcc -#usr/include/c++/4.4.7/tr1/shared_ptr.h -#usr/include/c++/4.4.7/tr1/special_function_util.h -#usr/include/c++/4.4.7/tr1/stdarg.h -#usr/include/c++/4.4.7/tr1/stdbool.h -#usr/include/c++/4.4.7/tr1/stdint.h -#usr/include/c++/4.4.7/tr1/stdio.h -#usr/include/c++/4.4.7/tr1/stdlib.h -#usr/include/c++/4.4.7/tr1/tgmath.h -#usr/include/c++/4.4.7/tr1/tuple -#usr/include/c++/4.4.7/tr1/type_traits -#usr/include/c++/4.4.7/tr1/unordered_map -#usr/include/c++/4.4.7/tr1/unordered_set -#usr/include/c++/4.4.7/tr1/utility -#usr/include/c++/4.4.7/tr1/wchar.h -#usr/include/c++/4.4.7/tr1/wctype.h -#usr/include/c++/4.4.7/tr1_impl -#usr/include/c++/4.4.7/tr1_impl/array -#usr/include/c++/4.4.7/tr1_impl/boost_sp_counted_base.h -#usr/include/c++/4.4.7/tr1_impl/cctype -#usr/include/c++/4.4.7/tr1_impl/cfenv -#usr/include/c++/4.4.7/tr1_impl/cinttypes -#usr/include/c++/4.4.7/tr1_impl/cmath -#usr/include/c++/4.4.7/tr1_impl/complex -#usr/include/c++/4.4.7/tr1_impl/cstdint -#usr/include/c++/4.4.7/tr1_impl/cstdio -#usr/include/c++/4.4.7/tr1_impl/cstdlib -#usr/include/c++/4.4.7/tr1_impl/cwchar -#usr/include/c++/4.4.7/tr1_impl/cwctype -#usr/include/c++/4.4.7/tr1_impl/functional -#usr/include/c++/4.4.7/tr1_impl/functional_hash.h -#usr/include/c++/4.4.7/tr1_impl/hashtable -#usr/include/c++/4.4.7/tr1_impl/hashtable_policy.h -#usr/include/c++/4.4.7/tr1_impl/random -#usr/include/c++/4.4.7/tr1_impl/random.tcc -#usr/include/c++/4.4.7/tr1_impl/regex -#usr/include/c++/4.4.7/tr1_impl/type_traits -#usr/include/c++/4.4.7/tr1_impl/unordered_map -#usr/include/c++/4.4.7/tr1_impl/unordered_set -#usr/include/c++/4.4.7/tr1_impl/utility -#usr/include/c++/4.4.7/tuple -#usr/include/c++/4.4.7/type_traits -#usr/include/c++/4.4.7/typeinfo -#usr/include/c++/4.4.7/unordered_map -#usr/include/c++/4.4.7/unordered_set -#usr/include/c++/4.4.7/utility -#usr/include/c++/4.4.7/valarray -#usr/include/c++/4.4.7/vector -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/atomic_word.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/basic_file.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/c++allocator.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/c++config.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/c++io.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/c++locale.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/cpu_defines.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/ctype_base.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/ctype_inline.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/ctype_noninline.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/cxxabi_tweaks.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/error_constants.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/extc++.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/gthr-default.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/gthr-posix.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/gthr-single.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/gthr-tpf.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/gthr.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/messages_members.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/os_defines.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/stdc++.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/stdtr1c++.h -#usr/include/c++/4.4.7/x86_64-unknown-linux-gnu/bits/time_members.h -#usr/info -#usr/info/cpp.info -#usr/info/cppinternals.info -#usr/info/dir -#usr/info/gcc.info -#usr/info/gccinstall.info -#usr/info/gccint.info -#usr/info/libgomp.info +#usr/include/c++/4.9.3 +#usr/include/c++/4.9.3/algorithm +#usr/include/c++/4.9.3/array +#usr/include/c++/4.9.3/atomic +#usr/include/c++/4.9.3/backward +#usr/include/c++/4.9.3/backward/auto_ptr.h +#usr/include/c++/4.9.3/backward/backward_warning.h +#usr/include/c++/4.9.3/backward/binders.h +#usr/include/c++/4.9.3/backward/hash_fun.h +#usr/include/c++/4.9.3/backward/hash_map +#usr/include/c++/4.9.3/backward/hash_set +#usr/include/c++/4.9.3/backward/hashtable.h +#usr/include/c++/4.9.3/backward/strstream +#usr/include/c++/4.9.3/bits +#usr/include/c++/4.9.3/bits/algorithmfwd.h +#usr/include/c++/4.9.3/bits/alloc_traits.h +#usr/include/c++/4.9.3/bits/allocator.h +#usr/include/c++/4.9.3/bits/atomic_base.h +#usr/include/c++/4.9.3/bits/atomic_lockfree_defines.h +#usr/include/c++/4.9.3/bits/basic_ios.h +#usr/include/c++/4.9.3/bits/basic_ios.tcc +#usr/include/c++/4.9.3/bits/basic_string.h +#usr/include/c++/4.9.3/bits/basic_string.tcc +#usr/include/c++/4.9.3/bits/boost_concept_check.h +#usr/include/c++/4.9.3/bits/c++0x_warning.h +#usr/include/c++/4.9.3/bits/c++14_warning.h +#usr/include/c++/4.9.3/bits/char_traits.h +#usr/include/c++/4.9.3/bits/codecvt.h +#usr/include/c++/4.9.3/bits/concept_check.h +#usr/include/c++/4.9.3/bits/cpp_type_traits.h +#usr/include/c++/4.9.3/bits/cxxabi_forced.h +#usr/include/c++/4.9.3/bits/deque.tcc +#usr/include/c++/4.9.3/bits/enable_special_members.h +#usr/include/c++/4.9.3/bits/exception_defines.h +#usr/include/c++/4.9.3/bits/exception_ptr.h +#usr/include/c++/4.9.3/bits/forward_list.h +#usr/include/c++/4.9.3/bits/forward_list.tcc +#usr/include/c++/4.9.3/bits/fstream.tcc +#usr/include/c++/4.9.3/bits/functexcept.h +#usr/include/c++/4.9.3/bits/functional_hash.h +#usr/include/c++/4.9.3/bits/gslice.h +#usr/include/c++/4.9.3/bits/gslice_array.h +#usr/include/c++/4.9.3/bits/hash_bytes.h +#usr/include/c++/4.9.3/bits/hashtable.h +#usr/include/c++/4.9.3/bits/hashtable_policy.h +#usr/include/c++/4.9.3/bits/indirect_array.h +#usr/include/c++/4.9.3/bits/ios_base.h +#usr/include/c++/4.9.3/bits/istream.tcc +#usr/include/c++/4.9.3/bits/list.tcc +#usr/include/c++/4.9.3/bits/locale_classes.h +#usr/include/c++/4.9.3/bits/locale_classes.tcc +#usr/include/c++/4.9.3/bits/locale_facets.h +#usr/include/c++/4.9.3/bits/locale_facets.tcc +#usr/include/c++/4.9.3/bits/locale_facets_nonio.h +#usr/include/c++/4.9.3/bits/locale_facets_nonio.tcc +#usr/include/c++/4.9.3/bits/localefwd.h +#usr/include/c++/4.9.3/bits/mask_array.h +#usr/include/c++/4.9.3/bits/memoryfwd.h +#usr/include/c++/4.9.3/bits/move.h +#usr/include/c++/4.9.3/bits/nested_exception.h +#usr/include/c++/4.9.3/bits/ostream.tcc +#usr/include/c++/4.9.3/bits/ostream_insert.h +#usr/include/c++/4.9.3/bits/parse_numbers.h +#usr/include/c++/4.9.3/bits/postypes.h +#usr/include/c++/4.9.3/bits/predefined_ops.h +#usr/include/c++/4.9.3/bits/ptr_traits.h +#usr/include/c++/4.9.3/bits/random.h +#usr/include/c++/4.9.3/bits/random.tcc +#usr/include/c++/4.9.3/bits/range_access.h +#usr/include/c++/4.9.3/bits/regex.h +#usr/include/c++/4.9.3/bits/regex.tcc +#usr/include/c++/4.9.3/bits/regex_automaton.h +#usr/include/c++/4.9.3/bits/regex_automaton.tcc +#usr/include/c++/4.9.3/bits/regex_compiler.h +#usr/include/c++/4.9.3/bits/regex_compiler.tcc +#usr/include/c++/4.9.3/bits/regex_constants.h +#usr/include/c++/4.9.3/bits/regex_error.h +#usr/include/c++/4.9.3/bits/regex_executor.h +#usr/include/c++/4.9.3/bits/regex_executor.tcc +#usr/include/c++/4.9.3/bits/regex_scanner.h +#usr/include/c++/4.9.3/bits/regex_scanner.tcc +#usr/include/c++/4.9.3/bits/shared_ptr.h +#usr/include/c++/4.9.3/bits/shared_ptr_base.h +#usr/include/c++/4.9.3/bits/slice_array.h +#usr/include/c++/4.9.3/bits/sstream.tcc +#usr/include/c++/4.9.3/bits/stl_algo.h +#usr/include/c++/4.9.3/bits/stl_algobase.h +#usr/include/c++/4.9.3/bits/stl_bvector.h +#usr/include/c++/4.9.3/bits/stl_construct.h +#usr/include/c++/4.9.3/bits/stl_deque.h +#usr/include/c++/4.9.3/bits/stl_function.h +#usr/include/c++/4.9.3/bits/stl_heap.h +#usr/include/c++/4.9.3/bits/stl_iterator.h +#usr/include/c++/4.9.3/bits/stl_iterator_base_funcs.h +#usr/include/c++/4.9.3/bits/stl_iterator_base_types.h +#usr/include/c++/4.9.3/bits/stl_list.h +#usr/include/c++/4.9.3/bits/stl_map.h +#usr/include/c++/4.9.3/bits/stl_multimap.h +#usr/include/c++/4.9.3/bits/stl_multiset.h +#usr/include/c++/4.9.3/bits/stl_numeric.h +#usr/include/c++/4.9.3/bits/stl_pair.h +#usr/include/c++/4.9.3/bits/stl_queue.h +#usr/include/c++/4.9.3/bits/stl_raw_storage_iter.h +#usr/include/c++/4.9.3/bits/stl_relops.h +#usr/include/c++/4.9.3/bits/stl_set.h +#usr/include/c++/4.9.3/bits/stl_stack.h +#usr/include/c++/4.9.3/bits/stl_tempbuf.h +#usr/include/c++/4.9.3/bits/stl_tree.h +#usr/include/c++/4.9.3/bits/stl_uninitialized.h +#usr/include/c++/4.9.3/bits/stl_vector.h +#usr/include/c++/4.9.3/bits/stream_iterator.h +#usr/include/c++/4.9.3/bits/streambuf.tcc +#usr/include/c++/4.9.3/bits/streambuf_iterator.h +#usr/include/c++/4.9.3/bits/stringfwd.h +#usr/include/c++/4.9.3/bits/unique_ptr.h +#usr/include/c++/4.9.3/bits/unordered_map.h +#usr/include/c++/4.9.3/bits/unordered_set.h +#usr/include/c++/4.9.3/bits/uses_allocator.h +#usr/include/c++/4.9.3/bits/valarray_after.h +#usr/include/c++/4.9.3/bits/valarray_array.h +#usr/include/c++/4.9.3/bits/valarray_array.tcc +#usr/include/c++/4.9.3/bits/valarray_before.h +#usr/include/c++/4.9.3/bits/vector.tcc +#usr/include/c++/4.9.3/bitset +#usr/include/c++/4.9.3/cassert +#usr/include/c++/4.9.3/ccomplex +#usr/include/c++/4.9.3/cctype +#usr/include/c++/4.9.3/cerrno +#usr/include/c++/4.9.3/cfenv +#usr/include/c++/4.9.3/cfloat +#usr/include/c++/4.9.3/chrono +#usr/include/c++/4.9.3/cinttypes +#usr/include/c++/4.9.3/ciso646 +#usr/include/c++/4.9.3/climits +#usr/include/c++/4.9.3/clocale +#usr/include/c++/4.9.3/cmath +#usr/include/c++/4.9.3/complex +#usr/include/c++/4.9.3/complex.h +#usr/include/c++/4.9.3/condition_variable +#usr/include/c++/4.9.3/csetjmp +#usr/include/c++/4.9.3/csignal +#usr/include/c++/4.9.3/cstdalign +#usr/include/c++/4.9.3/cstdarg +#usr/include/c++/4.9.3/cstdbool +#usr/include/c++/4.9.3/cstddef +#usr/include/c++/4.9.3/cstdint +#usr/include/c++/4.9.3/cstdio +#usr/include/c++/4.9.3/cstdlib +#usr/include/c++/4.9.3/cstring +#usr/include/c++/4.9.3/ctgmath +#usr/include/c++/4.9.3/ctime +#usr/include/c++/4.9.3/cwchar +#usr/include/c++/4.9.3/cwctype +#usr/include/c++/4.9.3/cxxabi.h +#usr/include/c++/4.9.3/debug +#usr/include/c++/4.9.3/debug/array +#usr/include/c++/4.9.3/debug/bitset +#usr/include/c++/4.9.3/debug/debug.h +#usr/include/c++/4.9.3/debug/deque +#usr/include/c++/4.9.3/debug/formatter.h +#usr/include/c++/4.9.3/debug/forward_list +#usr/include/c++/4.9.3/debug/functions.h +#usr/include/c++/4.9.3/debug/list +#usr/include/c++/4.9.3/debug/macros.h +#usr/include/c++/4.9.3/debug/map +#usr/include/c++/4.9.3/debug/map.h +#usr/include/c++/4.9.3/debug/multimap.h +#usr/include/c++/4.9.3/debug/multiset.h +#usr/include/c++/4.9.3/debug/safe_base.h +#usr/include/c++/4.9.3/debug/safe_iterator.h +#usr/include/c++/4.9.3/debug/safe_iterator.tcc +#usr/include/c++/4.9.3/debug/safe_local_iterator.h +#usr/include/c++/4.9.3/debug/safe_local_iterator.tcc +#usr/include/c++/4.9.3/debug/safe_sequence.h +#usr/include/c++/4.9.3/debug/safe_sequence.tcc +#usr/include/c++/4.9.3/debug/safe_unordered_base.h +#usr/include/c++/4.9.3/debug/safe_unordered_container.h +#usr/include/c++/4.9.3/debug/safe_unordered_container.tcc +#usr/include/c++/4.9.3/debug/set +#usr/include/c++/4.9.3/debug/set.h +#usr/include/c++/4.9.3/debug/string +#usr/include/c++/4.9.3/debug/unordered_map +#usr/include/c++/4.9.3/debug/unordered_set +#usr/include/c++/4.9.3/debug/vector +#usr/include/c++/4.9.3/decimal +#usr/include/c++/4.9.3/decimal/decimal +#usr/include/c++/4.9.3/decimal/decimal.h +#usr/include/c++/4.9.3/deque +#usr/include/c++/4.9.3/exception +#usr/include/c++/4.9.3/experimental +#usr/include/c++/4.9.3/experimental/optional +#usr/include/c++/4.9.3/experimental/string_view +#usr/include/c++/4.9.3/experimental/string_view.tcc +#usr/include/c++/4.9.3/ext +#usr/include/c++/4.9.3/ext/algorithm +#usr/include/c++/4.9.3/ext/aligned_buffer.h +#usr/include/c++/4.9.3/ext/alloc_traits.h +#usr/include/c++/4.9.3/ext/array_allocator.h +#usr/include/c++/4.9.3/ext/atomicity.h +#usr/include/c++/4.9.3/ext/bitmap_allocator.h +#usr/include/c++/4.9.3/ext/cast.h +#usr/include/c++/4.9.3/ext/cmath +#usr/include/c++/4.9.3/ext/codecvt_specializations.h +#usr/include/c++/4.9.3/ext/concurrence.h +#usr/include/c++/4.9.3/ext/debug_allocator.h +#usr/include/c++/4.9.3/ext/enc_filebuf.h +#usr/include/c++/4.9.3/ext/extptr_allocator.h +#usr/include/c++/4.9.3/ext/functional +#usr/include/c++/4.9.3/ext/hash_map +#usr/include/c++/4.9.3/ext/hash_set +#usr/include/c++/4.9.3/ext/iterator +#usr/include/c++/4.9.3/ext/malloc_allocator.h +#usr/include/c++/4.9.3/ext/memory +#usr/include/c++/4.9.3/ext/mt_allocator.h +#usr/include/c++/4.9.3/ext/new_allocator.h +#usr/include/c++/4.9.3/ext/numeric +#usr/include/c++/4.9.3/ext/numeric_traits.h +#usr/include/c++/4.9.3/ext/pb_ds +#usr/include/c++/4.9.3/ext/pb_ds/assoc_container.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/point_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/r_erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/rotate_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/bin_search_tree_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/entry_pred.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/resize_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binary_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/binomial_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/branch_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/null_node_metadata.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/branch_policy/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cmp_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/cond_key_dtor_entry_dealtor.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/debug_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/entry_list_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/erase_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/find_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/insert_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/resize_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/size_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cc_hash_table_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/cond_dealtor.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/container_base_dispatch.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/debug_map_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn/eq_by_less.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/constructor_destructor_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/debug_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/erase_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/find_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/insert_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/iterator_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_no_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/resize_store_hash_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/gp_hash_table_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/direct_mask_range_hashing_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/direct_mod_range_hashing_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/linear_probe_fn_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/mask_based_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/mod_based_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/probe_fn_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/quadratic_probe_fn_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_range_hashing.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_ranged_hash_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/hash_fn/sample_ranged_probe_fn.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/left_child_next_sibling_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/constructor_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/entry_metadata_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/lu_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_map_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/list_update_policy/sample_update_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/ov_tree_map_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pairing_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/insert_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/iterators_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/policy_access_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/r_erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/rotate_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/split_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/pat_trie_/update_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/priority_queue_base_dispatch.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/rb_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rb_tree_map_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/rc_binomial_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/cc_hash_max_collision_check_resize_trigger_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_exponential_size_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_load_check_resize_trigger_size_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_prime_size_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/hash_standard_resize_policy_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_resize_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_resize_trigger.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/resize_policy/sample_size_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/info_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/node.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/splay_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/splay_tree_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/splay_tree_/traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/standard_policies.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_ +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/constructors_destructor_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/debug_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/erase_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/find_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/insert_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/split_join_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/thin_heap_/trace_fn_imps.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/node_metadata_selector.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/order_statistics_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_policy/sample_tree_node_update.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/tree_trace_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/node_metadata_selector.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/order_statistics_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/prefix_search_node_update_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/sample_trie_access_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/sample_trie_node_update.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/trie_policy_base.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/trie_policy/trie_string_access_traits_imp.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/type_utils.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/types_traits.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/point_const_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/detail/unordered_iterator/point_iterator.hpp +#usr/include/c++/4.9.3/ext/pb_ds/exception.hpp +#usr/include/c++/4.9.3/ext/pb_ds/hash_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/list_update_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/priority_queue.hpp +#usr/include/c++/4.9.3/ext/pb_ds/tag_and_trait.hpp +#usr/include/c++/4.9.3/ext/pb_ds/tree_policy.hpp +#usr/include/c++/4.9.3/ext/pb_ds/trie_policy.hpp +#usr/include/c++/4.9.3/ext/pod_char_traits.h +#usr/include/c++/4.9.3/ext/pointer.h +#usr/include/c++/4.9.3/ext/pool_allocator.h +#usr/include/c++/4.9.3/ext/random +#usr/include/c++/4.9.3/ext/random.tcc +#usr/include/c++/4.9.3/ext/rb_tree +#usr/include/c++/4.9.3/ext/rc_string_base.h +#usr/include/c++/4.9.3/ext/rope +#usr/include/c++/4.9.3/ext/ropeimpl.h +#usr/include/c++/4.9.3/ext/slist +#usr/include/c++/4.9.3/ext/sso_string_base.h +#usr/include/c++/4.9.3/ext/stdio_filebuf.h +#usr/include/c++/4.9.3/ext/stdio_sync_filebuf.h +#usr/include/c++/4.9.3/ext/string_conversions.h +#usr/include/c++/4.9.3/ext/throw_allocator.h +#usr/include/c++/4.9.3/ext/type_traits.h +#usr/include/c++/4.9.3/ext/typelist.h +#usr/include/c++/4.9.3/ext/vstring.h +#usr/include/c++/4.9.3/ext/vstring.tcc +#usr/include/c++/4.9.3/ext/vstring_fwd.h +#usr/include/c++/4.9.3/ext/vstring_util.h +#usr/include/c++/4.9.3/fenv.h +#usr/include/c++/4.9.3/forward_list +#usr/include/c++/4.9.3/fstream +#usr/include/c++/4.9.3/functional +#usr/include/c++/4.9.3/future +#usr/include/c++/4.9.3/initializer_list +#usr/include/c++/4.9.3/iomanip +#usr/include/c++/4.9.3/ios +#usr/include/c++/4.9.3/iosfwd +#usr/include/c++/4.9.3/iostream +#usr/include/c++/4.9.3/istream +#usr/include/c++/4.9.3/iterator +#usr/include/c++/4.9.3/limits +#usr/include/c++/4.9.3/list +#usr/include/c++/4.9.3/locale +#usr/include/c++/4.9.3/map +#usr/include/c++/4.9.3/memory +#usr/include/c++/4.9.3/mutex +#usr/include/c++/4.9.3/new +#usr/include/c++/4.9.3/numeric +#usr/include/c++/4.9.3/ostream +#usr/include/c++/4.9.3/parallel +#usr/include/c++/4.9.3/parallel/algo.h +#usr/include/c++/4.9.3/parallel/algobase.h +#usr/include/c++/4.9.3/parallel/algorithm +#usr/include/c++/4.9.3/parallel/algorithmfwd.h +#usr/include/c++/4.9.3/parallel/balanced_quicksort.h +#usr/include/c++/4.9.3/parallel/base.h +#usr/include/c++/4.9.3/parallel/basic_iterator.h +#usr/include/c++/4.9.3/parallel/checkers.h +#usr/include/c++/4.9.3/parallel/compatibility.h +#usr/include/c++/4.9.3/parallel/compiletime_settings.h +#usr/include/c++/4.9.3/parallel/equally_split.h +#usr/include/c++/4.9.3/parallel/features.h +#usr/include/c++/4.9.3/parallel/find.h +#usr/include/c++/4.9.3/parallel/find_selectors.h +#usr/include/c++/4.9.3/parallel/for_each.h +#usr/include/c++/4.9.3/parallel/for_each_selectors.h +#usr/include/c++/4.9.3/parallel/iterator.h +#usr/include/c++/4.9.3/parallel/list_partition.h +#usr/include/c++/4.9.3/parallel/losertree.h +#usr/include/c++/4.9.3/parallel/merge.h +#usr/include/c++/4.9.3/parallel/multiseq_selection.h +#usr/include/c++/4.9.3/parallel/multiway_merge.h +#usr/include/c++/4.9.3/parallel/multiway_mergesort.h +#usr/include/c++/4.9.3/parallel/numeric +#usr/include/c++/4.9.3/parallel/numericfwd.h +#usr/include/c++/4.9.3/parallel/omp_loop.h +#usr/include/c++/4.9.3/parallel/omp_loop_static.h +#usr/include/c++/4.9.3/parallel/par_loop.h +#usr/include/c++/4.9.3/parallel/parallel.h +#usr/include/c++/4.9.3/parallel/partial_sum.h +#usr/include/c++/4.9.3/parallel/partition.h +#usr/include/c++/4.9.3/parallel/queue.h +#usr/include/c++/4.9.3/parallel/quicksort.h +#usr/include/c++/4.9.3/parallel/random_number.h +#usr/include/c++/4.9.3/parallel/random_shuffle.h +#usr/include/c++/4.9.3/parallel/search.h +#usr/include/c++/4.9.3/parallel/set_operations.h +#usr/include/c++/4.9.3/parallel/settings.h +#usr/include/c++/4.9.3/parallel/sort.h +#usr/include/c++/4.9.3/parallel/tags.h +#usr/include/c++/4.9.3/parallel/types.h +#usr/include/c++/4.9.3/parallel/unique_copy.h +#usr/include/c++/4.9.3/parallel/workstealing.h +#usr/include/c++/4.9.3/profile +#usr/include/c++/4.9.3/profile/array +#usr/include/c++/4.9.3/profile/base.h +#usr/include/c++/4.9.3/profile/bitset +#usr/include/c++/4.9.3/profile/deque +#usr/include/c++/4.9.3/profile/forward_list +#usr/include/c++/4.9.3/profile/impl +#usr/include/c++/4.9.3/profile/impl/profiler.h +#usr/include/c++/4.9.3/profile/impl/profiler_algos.h +#usr/include/c++/4.9.3/profile/impl/profiler_container_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_hash_func.h +#usr/include/c++/4.9.3/profile/impl/profiler_hashtable_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_list_to_slist.h +#usr/include/c++/4.9.3/profile/impl/profiler_list_to_vector.h +#usr/include/c++/4.9.3/profile/impl/profiler_map_to_unordered_map.h +#usr/include/c++/4.9.3/profile/impl/profiler_node.h +#usr/include/c++/4.9.3/profile/impl/profiler_state.h +#usr/include/c++/4.9.3/profile/impl/profiler_trace.h +#usr/include/c++/4.9.3/profile/impl/profiler_vector_size.h +#usr/include/c++/4.9.3/profile/impl/profiler_vector_to_list.h +#usr/include/c++/4.9.3/profile/iterator_tracker.h +#usr/include/c++/4.9.3/profile/list +#usr/include/c++/4.9.3/profile/map +#usr/include/c++/4.9.3/profile/map.h +#usr/include/c++/4.9.3/profile/multimap.h +#usr/include/c++/4.9.3/profile/multiset.h +#usr/include/c++/4.9.3/profile/set +#usr/include/c++/4.9.3/profile/set.h +#usr/include/c++/4.9.3/profile/unordered_base.h +#usr/include/c++/4.9.3/profile/unordered_map +#usr/include/c++/4.9.3/profile/unordered_set +#usr/include/c++/4.9.3/profile/vector +#usr/include/c++/4.9.3/queue +#usr/include/c++/4.9.3/random +#usr/include/c++/4.9.3/ratio +#usr/include/c++/4.9.3/regex +#usr/include/c++/4.9.3/scoped_allocator +#usr/include/c++/4.9.3/set +#usr/include/c++/4.9.3/shared_mutex +#usr/include/c++/4.9.3/sstream +#usr/include/c++/4.9.3/stack +#usr/include/c++/4.9.3/stdexcept +#usr/include/c++/4.9.3/streambuf +#usr/include/c++/4.9.3/string +#usr/include/c++/4.9.3/system_error +#usr/include/c++/4.9.3/tgmath.h +#usr/include/c++/4.9.3/thread +#usr/include/c++/4.9.3/tr1 +#usr/include/c++/4.9.3/tr1/array +#usr/include/c++/4.9.3/tr1/bessel_function.tcc +#usr/include/c++/4.9.3/tr1/beta_function.tcc +#usr/include/c++/4.9.3/tr1/ccomplex +#usr/include/c++/4.9.3/tr1/cctype +#usr/include/c++/4.9.3/tr1/cfenv +#usr/include/c++/4.9.3/tr1/cfloat +#usr/include/c++/4.9.3/tr1/cinttypes +#usr/include/c++/4.9.3/tr1/climits +#usr/include/c++/4.9.3/tr1/cmath +#usr/include/c++/4.9.3/tr1/complex +#usr/include/c++/4.9.3/tr1/complex.h +#usr/include/c++/4.9.3/tr1/cstdarg +#usr/include/c++/4.9.3/tr1/cstdbool +#usr/include/c++/4.9.3/tr1/cstdint +#usr/include/c++/4.9.3/tr1/cstdio +#usr/include/c++/4.9.3/tr1/cstdlib +#usr/include/c++/4.9.3/tr1/ctgmath +#usr/include/c++/4.9.3/tr1/ctime +#usr/include/c++/4.9.3/tr1/ctype.h +#usr/include/c++/4.9.3/tr1/cwchar +#usr/include/c++/4.9.3/tr1/cwctype +#usr/include/c++/4.9.3/tr1/ell_integral.tcc +#usr/include/c++/4.9.3/tr1/exp_integral.tcc +#usr/include/c++/4.9.3/tr1/fenv.h +#usr/include/c++/4.9.3/tr1/float.h +#usr/include/c++/4.9.3/tr1/functional +#usr/include/c++/4.9.3/tr1/functional_hash.h +#usr/include/c++/4.9.3/tr1/gamma.tcc +#usr/include/c++/4.9.3/tr1/hashtable.h +#usr/include/c++/4.9.3/tr1/hashtable_policy.h +#usr/include/c++/4.9.3/tr1/hypergeometric.tcc +#usr/include/c++/4.9.3/tr1/inttypes.h +#usr/include/c++/4.9.3/tr1/legendre_function.tcc +#usr/include/c++/4.9.3/tr1/limits.h +#usr/include/c++/4.9.3/tr1/math.h +#usr/include/c++/4.9.3/tr1/memory +#usr/include/c++/4.9.3/tr1/modified_bessel_func.tcc +#usr/include/c++/4.9.3/tr1/poly_hermite.tcc +#usr/include/c++/4.9.3/tr1/poly_laguerre.tcc +#usr/include/c++/4.9.3/tr1/random +#usr/include/c++/4.9.3/tr1/random.h +#usr/include/c++/4.9.3/tr1/random.tcc +#usr/include/c++/4.9.3/tr1/regex +#usr/include/c++/4.9.3/tr1/riemann_zeta.tcc +#usr/include/c++/4.9.3/tr1/shared_ptr.h +#usr/include/c++/4.9.3/tr1/special_function_util.h +#usr/include/c++/4.9.3/tr1/stdarg.h +#usr/include/c++/4.9.3/tr1/stdbool.h +#usr/include/c++/4.9.3/tr1/stdint.h +#usr/include/c++/4.9.3/tr1/stdio.h +#usr/include/c++/4.9.3/tr1/stdlib.h +#usr/include/c++/4.9.3/tr1/tgmath.h +#usr/include/c++/4.9.3/tr1/tuple +#usr/include/c++/4.9.3/tr1/type_traits +#usr/include/c++/4.9.3/tr1/unordered_map +#usr/include/c++/4.9.3/tr1/unordered_map.h +#usr/include/c++/4.9.3/tr1/unordered_set +#usr/include/c++/4.9.3/tr1/unordered_set.h +#usr/include/c++/4.9.3/tr1/utility +#usr/include/c++/4.9.3/tr1/wchar.h +#usr/include/c++/4.9.3/tr1/wctype.h +#usr/include/c++/4.9.3/tr2 +#usr/include/c++/4.9.3/tr2/bool_set +#usr/include/c++/4.9.3/tr2/bool_set.tcc +#usr/include/c++/4.9.3/tr2/dynamic_bitset +#usr/include/c++/4.9.3/tr2/dynamic_bitset.tcc +#usr/include/c++/4.9.3/tr2/ratio +#usr/include/c++/4.9.3/tr2/type_traits +#usr/include/c++/4.9.3/tuple +#usr/include/c++/4.9.3/type_traits +#usr/include/c++/4.9.3/typeindex +#usr/include/c++/4.9.3/typeinfo +#usr/include/c++/4.9.3/unordered_map +#usr/include/c++/4.9.3/unordered_set +#usr/include/c++/4.9.3/utility +#usr/include/c++/4.9.3/valarray +#usr/include/c++/4.9.3/vector +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/atomic_word.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/basic_file.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/c++allocator.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/c++config.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/c++io.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/c++locale.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/cpu_defines.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/ctype_base.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/ctype_inline.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/cxxabi_tweaks.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/error_constants.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/extc++.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/gthr-default.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/gthr-posix.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/gthr-single.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/gthr.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/messages_members.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/opt_random.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/os_defines.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/stdc++.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/stdtr1c++.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/bits/time_members.h +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/ext +#usr/include/c++/4.9.3/x86_64-unknown-linux-gnu/ext/opt_random.h #usr/lib/gcc #usr/lib/gcc/x86_64-unknown-linux-gnu -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7 -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/cc1 -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/cc1plus -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/collect2 -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtbegin.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtbeginS.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtbeginT.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtend.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtendS.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtfastmath.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtprec32.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtprec64.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/crtprec80.o -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/finclude -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include-fixed -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include-fixed/README -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include-fixed/limits.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include-fixed/syslimits.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/ammintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/avxintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/bmmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/cpuid.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/cross-stdarg.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/emmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/float.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/immintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/iso646.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/mf-runtime.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/mm3dnow.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/mm_malloc.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/mmintrin-common.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/mmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/nmmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/omp.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/pmmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/smmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/ssp -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/ssp/ssp.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/ssp/stdio.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/ssp/string.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/ssp/unistd.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/stdarg.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/stdbool.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/stddef.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/stdfix.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/tmmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/unwind.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/varargs.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/wmmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/x86intrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/include/xmmintrin.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/fixinc.sh -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/fixinc_list -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/fixincl -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/gsyslimits.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/include -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/include/README -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/include/limits.h -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/macro_list -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/mkheaders -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/mkheaders.conf -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/install-tools/mkinstalldirs -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/libgcc.a -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/libgcc_eh.a -#usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.7/libgcov.a +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3 +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/cc1 +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/cc1plus +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/collect2 +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtbegin.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtbeginS.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtbeginT.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtend.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtendS.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtfastmath.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtprec32.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtprec64.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/crtprec80.o +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/finclude +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include-fixed +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include-fixed/README +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include-fixed/limits.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include-fixed/syslimits.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/adxintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/ammintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/avx2intrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/avx512cdintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/avx512erintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/avx512fintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/avx512pfintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/avxintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/bmi2intrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/bmiintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/bmmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/cilk.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/cilk_api.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/cilk_api_linux.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/cilk_stub.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/cilk_undocumented.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/common.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/holder.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/hyperobject_base.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/metaprogramming.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_file.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_list.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_max.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_min.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_min_max.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_opadd.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_opand.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_opmul.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_opor.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_opxor.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_ostream.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cilk/reducer_string.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cpuid.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/cross-stdarg.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/emmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/f16cintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/float.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/fma4intrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/fmaintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/fxsrintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/ia32intrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/immintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/iso646.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/lwpintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/lzcntintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/mm3dnow.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/mm_malloc.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/mmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/nmmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/omp.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/pmmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/popcntintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/prfchwintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/quadmath.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/quadmath_weak.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/rdseedintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/rtmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/sanitizer +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/sanitizer/asan_interface.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/sanitizer/common_interface_defs.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/sanitizer/lsan_interface.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/shaintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/smmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/ssp +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/ssp/ssp.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/ssp/stdio.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/ssp/string.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/ssp/unistd.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stdalign.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stdarg.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stdatomic.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stdbool.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stddef.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stdfix.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stdint-gcc.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stdint.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/stdnoreturn.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/tbmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/tmmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/unwind.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/varargs.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/wmmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/x86intrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/xmmintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/xopintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/xsaveintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/xsaveoptintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/include/xtestintrin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/fixinc.sh +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/fixinc_list +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/fixincl +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/gsyslimits.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/include +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/include/README +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/include/limits.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/macro_list +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/mkheaders +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/mkheaders.conf +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/install-tools/mkinstalldirs +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/libgcc.a +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/libgcc_eh.a +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/libgcov.a +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/liblto_plugin.la +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/liblto_plugin.so +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/liblto_plugin.so.0 +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/liblto_plugin.so.0.0.0 +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/lto-wrapper +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/lto1 +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/gengtype +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/gtype.state +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ada +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ada/gcc-interface +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ada/gcc-interface/ada-tree.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/alias.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/all-tree.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/alloc-pool.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ansidecl.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/attribs.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/auto-host.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/b-header-vars +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/basic-block.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/bitmap.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/builtins.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/bversion.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/c-family +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/c-family/c-common.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/c-family/c-common.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/c-family/c-objc.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/c-family/c-pragma.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/c-family/c-pretty-print.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/c-tree.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/calls.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cfg-flags.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cfgexpand.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cfghooks.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cfgloop.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cgraph.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cif-code.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cilk-builtins.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cilkplus.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/dbxelf.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/elfos.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/glibc-stdint.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/gnu-user.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386 +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/att.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/biarch64.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/gnu-user-common.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/gnu-user64.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/i386-opts.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/i386-protos.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/i386.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/linux-common.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/linux64.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/stringop.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/unix.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/x86-64.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/i386/x86-tune.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/initfini-array.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/linux-android.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/linux-protos.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/linux.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/config/vxworks-dummy.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/configargs.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/context.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/coretypes.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cp +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cp/cp-tree.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cp/cp-tree.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cp/cxx-pretty-print.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cp/name-lookup.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cp/type-utils.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cppdefault.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/cpplib.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/debug.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/defaults.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/df.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/diagnostic-color.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/diagnostic-core.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/diagnostic.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/diagnostic.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/double-int.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/dumpfile.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/emit-rtl.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/except.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/filenames.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/fixed-value.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/flag-types.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/flags.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/fold-const.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/function.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gcc-plugin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gcc-symtab.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/genrtl.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ggc.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple-builder.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple-expr.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple-fold.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple-iterator.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple-low.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple-pretty-print.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple-ssa.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple-walk.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimple.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimplify-me.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gimplify.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gsstruct.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gtm-builtins.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/gtype-desc.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/hard-reg-set.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/hash-table.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/hashtab.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/highlev-plugin-common.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/hwint.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/incpath.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/input.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/insn-codes.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/insn-constants.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/insn-flags.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/insn-modes.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/insn-notes.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/internal-fn.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/internal-fn.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/intl.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ipa-prop.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ipa-ref-inline.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ipa-ref.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ipa-reference.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ipa-utils.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/is-a.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/java +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/java/java-tree.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/langhooks.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/libiberty.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/line-map.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/machmode.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/md5.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/mode-classes.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/objc +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/objc/objc-tree.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/obstack.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/omp-builtins.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/options.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/opts.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/output.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/params.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/params.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/pass-instances.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/pass_manager.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/plugin-api.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/plugin-version.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/plugin.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/plugin.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/pointer-set.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/predict.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/predict.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/prefix.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/pretty-print.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/print-rtl.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/print-tree.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/real.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/realmpfr.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/reg-notes.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/regset.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/resource.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/rtl.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/rtl.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/safe-ctype.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/sanitizer.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/sbitmap.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/splay-tree.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/ssa-iterators.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/statistics.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/stmt.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/stor-layout.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/stringpool.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/symtab.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/sync-builtins.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/system.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/target-hooks-macros.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/target.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/target.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/timevar.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/timevar.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tm-preds.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tm.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tm_p.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/toplev.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-cfg.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-cfgcleanup.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-check.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-core.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-dfa.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-dump.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-eh.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-hasher.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-inline.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-into-ssa.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-iterator.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-nested.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-object-size.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-outof-ssa.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-parloops.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-pass.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-phinodes.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-pretty-print.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-address.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-alias.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-coalesce.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-dom.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-loop-ivopts.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-loop-manip.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-loop-niter.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-loop.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-operands.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-sccvn.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-ter.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-threadedge.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa-threadupdate.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssa.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree-ssanames.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/tree.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/treestruct.def +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/varasm.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/vec.h +#usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.3/plugin/include/version.h +#usr/lib/libasan.a +#usr/lib/libasan.la +#usr/lib/libasan.so +usr/lib/libasan.so.1 +usr/lib/libasan.so.1.0.0 +#usr/lib/libasan_preinit.o +#usr/lib/libatomic.a +#usr/lib/libatomic.la +#usr/lib/libatomic.so +usr/lib/libatomic.so.1 +usr/lib/libatomic.so.1.1.0 +#usr/lib/libcilkrts.a +#usr/lib/libcilkrts.la +#usr/lib/libcilkrts.so +usr/lib/libcilkrts.so.5 +usr/lib/libcilkrts.so.5.0.0 +#usr/lib/libcilkrts.spec #usr/lib/libgomp.a #usr/lib/libgomp.la #usr/lib/libgomp.so usr/lib/libgomp.so.1 usr/lib/libgomp.so.1.0.0 #usr/lib/libgomp.spec -#usr/lib/libmudflap.a -#usr/lib/libmudflap.la -#usr/lib/libmudflap.so -usr/lib/libmudflap.so.0 -usr/lib/libmudflap.so.0.0.0 -#usr/lib/libmudflapth.a -#usr/lib/libmudflapth.la -#usr/lib/libmudflapth.so -usr/lib/libmudflapth.so.0 -usr/lib/libmudflapth.so.0.0.0 +#usr/lib/libitm.a +#usr/lib/libitm.la +#usr/lib/libitm.so +usr/lib/libitm.so.1 +usr/lib/libitm.so.1.0.0 +#usr/lib/libitm.spec +#usr/lib/liblsan.a +#usr/lib/liblsan.la +#usr/lib/liblsan.so +usr/lib/liblsan.so.0 +usr/lib/liblsan.so.0.0.0 +#usr/lib/libquadmath.a +#usr/lib/libquadmath.la +#usr/lib/libquadmath.so +usr/lib/libquadmath.so.0 +usr/lib/libquadmath.so.0.0.0 +#usr/lib/libsanitizer.spec #usr/lib/libssp.a #usr/lib/libssp.la #usr/lib/libssp.so @@ -786,16 +1143,44 @@ usr/lib/libmudflapth.so.0.0.0 #usr/lib/libssp_nonshared.a #usr/lib/libssp_nonshared.la #usr/lib/libstdc++.a -usr/lib/libstdc++.so.6.0.13 +usr/lib/libstdc++.so.6.0.20 +#usr/lib/libstdc++.so.6.0.20-gdb.py #usr/lib/libsupc++.a #usr/lib/libsupc++.la -#usr/man -#usr/man/man1 -#usr/man/man1/cpp.1 -#usr/man/man1/g++.1 -#usr/man/man1/gcc.1 -#usr/man/man1/gcov.1 -#usr/man/man7 -#usr/man/man7/fsf-funding.7 -#usr/man/man7/gfdl.7 -#usr/man/man7/gpl.7 +#usr/lib/libtsan.a +#usr/lib/libtsan.la +#usr/lib/libtsan.so +usr/lib/libtsan.so.0 +usr/lib/libtsan.so.0.0.0 +#usr/lib/libubsan.a +#usr/lib/libubsan.la +#usr/lib/libubsan.so +usr/lib/libubsan.so.0 +usr/lib/libubsan.so.0.0.0 +#usr/lib/libvtv.a +#usr/lib/libvtv.la +#usr/lib/libvtv.so +usr/lib/libvtv.so.0 +usr/lib/libvtv.so.0.0.0 +#usr/share/gcc-4.9.3 +#usr/share/gcc-4.9.3/python +#usr/share/gcc-4.9.3/python/libstdcxx +#usr/share/gcc-4.9.3/python/libstdcxx/__init__.py +#usr/share/gcc-4.9.3/python/libstdcxx/v6 +#usr/share/gcc-4.9.3/python/libstdcxx/v6/__init__.py +#usr/share/gcc-4.9.3/python/libstdcxx/v6/printers.py +#usr/share/info/cpp.info +#usr/share/info/cppinternals.info +#usr/share/info/gcc.info +#usr/share/info/gccinstall.info +#usr/share/info/gccint.info +#usr/share/info/libgomp.info +#usr/share/info/libitm.info +#usr/share/info/libquadmath.info +#usr/share/man/man1/cpp.1 +#usr/share/man/man1/g++.1 +#usr/share/man/man1/gcc.1 +#usr/share/man/man1/gcov.1 +#usr/share/man/man7/fsf-funding.7 +#usr/share/man/man7/gfdl.7 +#usr/share/man/man7/gpl.7 diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index aabc8a6..80ae0dd 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -27,6 +27,7 @@ etc/rc.d/init.d/console #etc/rc.d/init.d/cyrus-sasl etc/rc.d/init.d/dhcp etc/rc.d/init.d/dhcrelay +#etc/rc.d/init.d/dnsdist etc/rc.d/init.d/dnsmasq etc/rc.d/init.d/fcron #etc/rc.d/init.d/fetchmail diff --git a/config/rootfiles/common/xz b/config/rootfiles/common/xz index b4053d9..8b71758 100644 --- a/config/rootfiles/common/xz +++ b/config/rootfiles/common/xz @@ -41,7 +41,7 @@ usr/bin/xzmore #usr/lib/liblzma.la usr/lib/liblzma.so usr/lib/liblzma.so.5 -usr/lib/liblzma.so.5.2.1 +usr/lib/liblzma.so.5.2.2 #usr/lib/pkgconfig/liblzma.pc #usr/share/doc/xz #usr/share/doc/xz/AUTHORS diff --git a/config/rootfiles/core/100/exclude b/config/rootfiles/core/100/exclude new file mode 100644 index 0000000..8e446ce --- /dev/null +++ b/config/rootfiles/core/100/exclude @@ -0,0 +1,26 @@ +boot/config.txt +etc/alternatives +etc/collectd.custom +etc/default/grub +etc/ipsec.conf +etc/ipsec.secrets +etc/ipsec.user.conf +etc/ipsec.user.secrets +etc/localtime +etc/shadow +etc/snort/snort.conf +etc/ssh/ssh_config +etc/ssh/sshd_config +etc/ssl/openssl.cnf +etc/sudoers +etc/sysconfig/firewall.local +etc/sysconfig/rc.local +etc/udev/rules.d/30-persistent-network.rules +srv/web/ipfire/html/proxy.pac +var/ipfire/dma +var/ipfire/time +var/ipfire/ovpn +var/lib/alternatives +var/log/cache +var/state/dhcp/dhcpd.leases +var/updatecache diff --git a/config/rootfiles/core/100/filelists/armv5tel/binutils b/config/rootfiles/core/100/filelists/armv5tel/binutils new file mode 120000 index 0000000..ac971f9 --- /dev/null +++ b/config/rootfiles/core/100/filelists/armv5tel/binutils @@ -0,0 +1 @@ +../../../../common/armv5tel/binutils \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/armv5tel/gcc b/config/rootfiles/core/100/filelists/armv5tel/gcc new file mode 120000 index 0000000..84f7b93 --- /dev/null +++ b/config/rootfiles/core/100/filelists/armv5tel/gcc @@ -0,0 +1 @@ +../../../../common/armv5tel/gcc \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/armv5tel/glibc b/config/rootfiles/core/100/filelists/armv5tel/glibc new file mode 120000 index 0000000..4c70d72 --- /dev/null +++ b/config/rootfiles/core/100/filelists/armv5tel/glibc @@ -0,0 +1 @@ +../../../../common/armv5tel/glibc \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/armv5tel/linux-kirkwood b/config/rootfiles/core/100/filelists/armv5tel/linux-kirkwood new file mode 120000 index 0000000..7217107 --- /dev/null +++ b/config/rootfiles/core/100/filelists/armv5tel/linux-kirkwood @@ -0,0 +1 @@ +../../../../common/armv5tel/linux-kirkwood \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/armv5tel/linux-multi b/config/rootfiles/core/100/filelists/armv5tel/linux-multi new file mode 120000 index 0000000..204eb4c --- /dev/null +++ b/config/rootfiles/core/100/filelists/armv5tel/linux-multi @@ -0,0 +1 @@ +../../../../common/armv5tel/linux-multi \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/armv5tel/linux-rpi b/config/rootfiles/core/100/filelists/armv5tel/linux-rpi new file mode 120000 index 0000000..a651a49 --- /dev/null +++ b/config/rootfiles/core/100/filelists/armv5tel/linux-rpi @@ -0,0 +1 @@ +../../../../common/armv5tel/linux-rpi \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/ath10k-firmware b/config/rootfiles/core/100/filelists/ath10k-firmware new file mode 120000 index 0000000..e7e87c2 --- /dev/null +++ b/config/rootfiles/core/100/filelists/ath10k-firmware @@ -0,0 +1 @@ +../../../common/ath10k-firmware \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/bind b/config/rootfiles/core/100/filelists/bind new file mode 120000 index 0000000..48a0eba --- /dev/null +++ b/config/rootfiles/core/100/filelists/bind @@ -0,0 +1 @@ +../../../common/bind \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/diffutils b/config/rootfiles/core/100/filelists/diffutils new file mode 120000 index 0000000..a5c02f3 --- /dev/null +++ b/config/rootfiles/core/100/filelists/diffutils @@ -0,0 +1 @@ +../../../common/diffutils \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/dnsmasq b/config/rootfiles/core/100/filelists/dnsmasq new file mode 120000 index 0000000..d469c74 --- /dev/null +++ b/config/rootfiles/core/100/filelists/dnsmasq @@ -0,0 +1 @@ +../../../common/dnsmasq \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/files b/config/rootfiles/core/100/filelists/files new file mode 100644 index 0000000..c75a26d --- /dev/null +++ b/config/rootfiles/core/100/filelists/files @@ -0,0 +1,31 @@ +etc/system-release +etc/issue +etc/dracut.conf +etc/ppp/ip-up +etc/rc.d/init.d/firewall +etc/rc.d/init.d/functions +etc/rc.d/init.d/networking/dhcpcd.exe +etc/rc.d/init.d/ntp +etc/modprobe.d/nf_conntrack.conf +lib/udev/rules.d/60-net.rules +opt/pakfire/etc/pakfire.conf +srv/web/ipfire/cgi-bin/logs.cgi/firewalllog.dat +srv/web/ipfire/cgi-bin/logs.cgi/firewalllogcountry.dat +srv/web/ipfire/cgi-bin/logs.cgi/firewalllogip.dat +srv/web/ipfire/cgi-bin/logs.cgi/firewalllogport.dat +srv/web/ipfire/cgi-bin/logs.cgi/showrequestfromcountry.dat +srv/web/ipfire/cgi-bin/logs.cgi/showrequestfromip.dat +srv/web/ipfire/cgi-bin/logs.cgi/showrequestfromport.dat +srv/web/ipfire/cgi-bin/optionsfw.cgi +srv/web/ipfire/cgi-bin/ovpnmain.cgi +srv/web/ipfire/cgi-bin/qos.cgi +srv/web/ipfire/cgi-bin/webaccess.cgi +usr/bin/pgrep +usr/local/bin/backupiso +usr/local/bin/qosctrl +usr/local/bin/timectrl +usr/local/bin/wirelessctrl +usr/sbin/firewall-policy +usr/sbin/setup +var/ipfire/dhcpc/dhcpcd-hooks/10-mtu +var/ipfire/langs diff --git a/config/rootfiles/core/100/filelists/grep b/config/rootfiles/core/100/filelists/grep new file mode 120000 index 0000000..ab5ef8b --- /dev/null +++ b/config/rootfiles/core/100/filelists/grep @@ -0,0 +1 @@ +../../../common/grep \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/i586/binutils b/config/rootfiles/core/100/filelists/i586/binutils new file mode 120000 index 0000000..78695d7 --- /dev/null +++ b/config/rootfiles/core/100/filelists/i586/binutils @@ -0,0 +1 @@ +../../../../common/i586/binutils \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/i586/gcc b/config/rootfiles/core/100/filelists/i586/gcc new file mode 120000 index 0000000..ba328e3 --- /dev/null +++ b/config/rootfiles/core/100/filelists/i586/gcc @@ -0,0 +1 @@ +../../../../common/i586/gcc \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/i586/glibc b/config/rootfiles/core/100/filelists/i586/glibc new file mode 120000 index 0000000..943021f --- /dev/null +++ b/config/rootfiles/core/100/filelists/i586/glibc @@ -0,0 +1 @@ +../../../../common/i586/glibc \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/i586/grub b/config/rootfiles/core/100/filelists/i586/grub new file mode 120000 index 0000000..feb236a --- /dev/null +++ b/config/rootfiles/core/100/filelists/i586/grub @@ -0,0 +1 @@ +../../../../common/i586/grub \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/i586/linux b/config/rootfiles/core/100/filelists/i586/linux new file mode 120000 index 0000000..693ec4b --- /dev/null +++ b/config/rootfiles/core/100/filelists/i586/linux @@ -0,0 +1 @@ +../../../../common/i586/linux \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/i586/linux-initrd b/config/rootfiles/core/100/filelists/i586/linux-initrd new file mode 120000 index 0000000..32a03e6 --- /dev/null +++ b/config/rootfiles/core/100/filelists/i586/linux-initrd @@ -0,0 +1 @@ +../../../../common/i586/linux-initrd \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/i586/openssl-sse2 b/config/rootfiles/core/100/filelists/i586/openssl-sse2 new file mode 120000 index 0000000..f424713 --- /dev/null +++ b/config/rootfiles/core/100/filelists/i586/openssl-sse2 @@ -0,0 +1 @@ +../../../../common/i586/openssl-sse2 \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/libmpc b/config/rootfiles/core/100/filelists/libmpc new file mode 120000 index 0000000..88840fc --- /dev/null +++ b/config/rootfiles/core/100/filelists/libmpc @@ -0,0 +1 @@ +../../../common/libmpc \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/lua b/config/rootfiles/core/100/filelists/lua new file mode 120000 index 0000000..951f661 --- /dev/null +++ b/config/rootfiles/core/100/filelists/lua @@ -0,0 +1 @@ +../../../common/lua \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/mt7601u-firmware b/config/rootfiles/core/100/filelists/mt7601u-firmware new file mode 120000 index 0000000..300ac04 --- /dev/null +++ b/config/rootfiles/core/100/filelists/mt7601u-firmware @@ -0,0 +1 @@ +../../../common/mt7601u-firmware \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/ncurses b/config/rootfiles/core/100/filelists/ncurses new file mode 120000 index 0000000..512faef --- /dev/null +++ b/config/rootfiles/core/100/filelists/ncurses @@ -0,0 +1 @@ +../../../common/ncurses \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/ntp b/config/rootfiles/core/100/filelists/ntp new file mode 120000 index 0000000..7542d86 --- /dev/null +++ b/config/rootfiles/core/100/filelists/ntp @@ -0,0 +1 @@ +../../../common/ntp \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/openssh b/config/rootfiles/core/100/filelists/openssh new file mode 120000 index 0000000..d8c77fd --- /dev/null +++ b/config/rootfiles/core/100/filelists/openssh @@ -0,0 +1 @@ +../../../common/openssh \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/openssl b/config/rootfiles/core/100/filelists/openssl new file mode 120000 index 0000000..e011a92 --- /dev/null +++ b/config/rootfiles/core/100/filelists/openssl @@ -0,0 +1 @@ +../../../common/openssl \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/openvpn b/config/rootfiles/core/100/filelists/openvpn new file mode 120000 index 0000000..493f3f7 --- /dev/null +++ b/config/rootfiles/core/100/filelists/openvpn @@ -0,0 +1 @@ +../../../common/openvpn \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/sed b/config/rootfiles/core/100/filelists/sed new file mode 120000 index 0000000..fc5f5c6 --- /dev/null +++ b/config/rootfiles/core/100/filelists/sed @@ -0,0 +1 @@ +../../../common/sed \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/squid b/config/rootfiles/core/100/filelists/squid new file mode 120000 index 0000000..2dc8372 --- /dev/null +++ b/config/rootfiles/core/100/filelists/squid @@ -0,0 +1 @@ +../../../common/squid \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/tzdata b/config/rootfiles/core/100/filelists/tzdata new file mode 120000 index 0000000..5a6e325 --- /dev/null +++ b/config/rootfiles/core/100/filelists/tzdata @@ -0,0 +1 @@ +../../../common/tzdata \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/x86_64/binutils b/config/rootfiles/core/100/filelists/x86_64/binutils new file mode 120000 index 0000000..7d0fda5 --- /dev/null +++ b/config/rootfiles/core/100/filelists/x86_64/binutils @@ -0,0 +1 @@ +../../../../common/x86_64/binutils \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/x86_64/gcc b/config/rootfiles/core/100/filelists/x86_64/gcc new file mode 120000 index 0000000..d1616d3 --- /dev/null +++ b/config/rootfiles/core/100/filelists/x86_64/gcc @@ -0,0 +1 @@ +../../../../common/x86_64/gcc \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/x86_64/glibc b/config/rootfiles/core/100/filelists/x86_64/glibc new file mode 120000 index 0000000..1119099 --- /dev/null +++ b/config/rootfiles/core/100/filelists/x86_64/glibc @@ -0,0 +1 @@ +../../../../common/x86_64/glibc \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/x86_64/grub b/config/rootfiles/core/100/filelists/x86_64/grub new file mode 120000 index 0000000..78d3bd7 --- /dev/null +++ b/config/rootfiles/core/100/filelists/x86_64/grub @@ -0,0 +1 @@ +../../../../common/x86_64/grub \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/x86_64/linux b/config/rootfiles/core/100/filelists/x86_64/linux new file mode 120000 index 0000000..0615b5b --- /dev/null +++ b/config/rootfiles/core/100/filelists/x86_64/linux @@ -0,0 +1 @@ +../../../../common/x86_64/linux \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/x86_64/linux-initrd b/config/rootfiles/core/100/filelists/x86_64/linux-initrd new file mode 120000 index 0000000..1b9fff7 --- /dev/null +++ b/config/rootfiles/core/100/filelists/x86_64/linux-initrd @@ -0,0 +1 @@ +../../../../common/x86_64/linux-initrd \ No newline at end of file diff --git a/config/rootfiles/core/100/filelists/xz b/config/rootfiles/core/100/filelists/xz new file mode 120000 index 0000000..734e926 --- /dev/null +++ b/config/rootfiles/core/100/filelists/xz @@ -0,0 +1 @@ +../../../common/xz \ No newline at end of file diff --git a/config/rootfiles/core/100/meta b/config/rootfiles/core/100/meta new file mode 100644 index 0000000..d547fa8 --- /dev/null +++ b/config/rootfiles/core/100/meta @@ -0,0 +1 @@ +DEPS="" diff --git a/config/rootfiles/core/100/update.sh b/config/rootfiles/core/100/update.sh new file mode 100644 index 0000000..9e48d3a --- /dev/null +++ b/config/rootfiles/core/100/update.sh @@ -0,0 +1,259 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 3 of the License, or # +# (at your option) any later version. # +# # +# IPFire 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2016 IPFire-Team info@ipfire.org. # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh +/usr/local/bin/backupctrl exclude >/dev/null 2>&1 + +function find_device() { + local mountpoint="${1}" + + local root + local dev mp fs flags rest + while read -r dev mp fs flags rest; do + # Skip unwanted entries + [ "${dev}" = "rootfs" ] && continue + + if [ "${mp}" = "${mountpoint}" ] && [ -b "${dev}" ]; then + root="$(basename "${dev}")" + break + fi + done < /proc/mounts + + # Get the actual device from the partition that holds / + while [ -n "${root}" ]; do + if [ -e "/sys/block/${root}" ]; then + echo "${root}" + return 0 + fi + + # Remove last character + root="${root::-1}" + done + + return 1 +} + + +core=100 + +function exit_with_error() { + # Set last succesfull installed core. + echo $(($core-1)) > /opt/pakfire/db/core/mine + /usr/bin/logger -p syslog.emerg -t ipfire \ + "core-update-${core}: $1" + exit $2 +} + +# Remove old core updates from pakfire cache to save space... +for (( i=1; i<=$core; i++ )) +do + rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire +done + +# +# Do some sanity checks. +case $(uname -r) in + *-ipfire* ) + # Ok. + ;; + * ) + exit_with_error "ERROR cannot update. No IPFire Kernel." 1 + ;; +esac + + +# +# +KVER="xxxKVERxxx" + +# Check diskspace on root +ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` + +if [ $ROOTSPACE -lt 100000 ]; then + exit_with_error "ERROR cannot update because not enough free space on root." 2 + exit 2 +fi + +echo +echo Update Kernel to $KVER ... +# +# Remove old kernel, configs, initrd, modules, dtb's ... +# +rm -rf /boot/System.map-* +rm -rf /boot/config-* +rm -rf /boot/ipfirerd-* +rm -rf /boot/initramfs-* +rm -rf /boot/vmlinuz-* +rm -rf /boot/uImage-ipfire-* +rm -rf /boot/zImage-ipfire-* +rm -rf /boot/uInit-ipfire-* +rm -rf /boot/dtb-*-ipfire-* +rm -rf /lib/modules + +case "$(uname -m)" in + armv*) + # Backup uEnv.txt if exist + if [ -e /boot/uEnv.txt ]; then + cp -vf /boot/uEnv.txt /boot/uEnv.txt.org + fi + + # work around the u-boot folder detection bug + mkdir -pv /boot/dtb-$KVER-ipfire-kirkwood + mkdir -pv /boot/dtb-$KVER-ipfire-multi + touch /boot/uImage-ipfire-kirkwood + touch /boot/zImage-ipfire-multi + touch /boot/uIinit-ipfire-kirkwood + touch /boot/uIinit-ipfire-multi + ;; +esac + +# Stop services +/etc/init.d/snort stop +/etc/init.d/squid stop +/etc/init.d/dnsmasq stop +/etc/init.d/ipsec stop +/etc/init.d/ntp stop +/etc/init.d/apache stop + + +# Extract files +tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p --numeric-owner -C / + + + +# Check diskspace on boot +BOOTSPACE=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` + +if [ $BOOTSPACE -lt 1000 ]; then + case $(uname -r) in + *-ipfire-kirkwood ) + # Special handling for old kirkwood images. + # (install only kirkwood kernel) + rm -rf /boot/* + # work around the u-boot folder detection bug + mkdir -pv /boot/dtb-$KVER-ipfire-kirkwood + tar xavf /opt/pakfire/tmp/files* --no-overwrite-dir -p \ + --numeric-owner -C / --wildcards 'boot/*-kirkwood*' + ;; + * ) + /etc/init.d/apache start + exit_with_error "FATAL-ERROR space run out on boot. System is not bootable..." 4 + ;; + esac +fi + +# restart init because the glibc was updated. +telinit u + +# Fix hardening flags in grub +paxctl -mpexs /usr/bin/grub-script-check + +# Regenerate IPsec configuration +sudo -u nobody /srv/web/ipfire/cgi-bin/vpnmain.cgi + +# Update Language cache +/usr/local/bin/update-lang-cache + +# +# Start services +# +/etc/init.d/apache start +/etc/init.d/ntp start +/etc/init.d/dnsmasq start +/etc/init.d/sshd restart +/etc/init.d/squid start +/etc/init.d/snort start +if [ `grep "ENABLED=on" /var/ipfire/vpn/settings` ]; then + /etc/init.d/ipsec start +fi + +# Delete old QoS enabled indicator +rm -f /var/ipfire/qos/enable + +# Upadate Kernel version uEnv.txt +if [ -e /boot/uEnv.txt ]; then + sed -i -e "s/KVER=.*/KVER=${KVER}/g" /boot/uEnv.txt +fi + +# call user update script (needed for some arm boards) +if [ -e /boot/pakfire-kernel-update ]; then + /boot/pakfire-kernel-update ${KVER} +fi + +case "$(uname -m)" in + i?86) + # Force (re)install pae kernel if pae is supported + rm -rf /opt/pakfire/db/installed/meta-linux-pae + if [ ! "$(grep "^flags.* pae " /proc/cpuinfo)" == "" ]; then + ROOTSPACE=`df / -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` + BOOTSPACE=`df /boot -Pk | sed "s| * | |g" | cut -d" " -f4 | tail -n 1` + if [ $BOOTSPACE -lt 12000 -o $ROOTSPACE -lt 90000 ]; then + /usr/bin/logger -p syslog.emerg -t ipfire \ + "core-update-${core}: WARNING not enough space for pae kernel." + else + echo "Name: linux-pae" > /opt/pakfire/db/installed/meta-linux-pae + echo "ProgVersion: 0" >> /opt/pakfire/db/installed/meta-linux-pae + echo "Release: 0" >> /opt/pakfire/db/installed/meta-linux-pae + fi + fi + ;; +esac +# +# After pakfire has ended run it again and update the lists and do upgrade +# +echo '#!/bin/bash' > /tmp/pak_update +echo 'while [ "$(ps -A | grep " update.sh")" != "" ]; do' >> /tmp/pak_update +echo ' sleep 1' >> /tmp/pak_update +echo 'done' >> /tmp/pak_update +echo 'while [ "$(ps -A | grep " pakfire")" != "" ]; do' >> /tmp/pak_update +echo ' sleep 1' >> /tmp/pak_update +echo 'done' >> /tmp/pak_update +echo '/opt/pakfire/pakfire update -y --force' >> /tmp/pak_update +echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update +echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update +echo '/opt/pakfire/pakfire upgrade -y' >> /tmp/pak_update +echo '/usr/bin/logger -p syslog.emerg -t ipfire "Core-upgrade finished. If you use a customized grub/uboot config"' >> /tmp/pak_update +echo '/usr/bin/logger -p syslog.emerg -t ipfire "Check it before reboot !!!"' >> /tmp/pak_update +echo '/usr/bin/logger -p syslog.emerg -t ipfire " *** Please reboot... *** "' >> /tmp/pak_update +echo 'touch /var/run/need_reboot ' >> /tmp/pak_update +# +killall -KILL pak_update +chmod +x /tmp/pak_update +/tmp/pak_update & + +sync + +# This update need a reboot... +touch /var/run/need_reboot + +# Finish +/etc/init.d/fireinfo start +sendprofile +# Update grub config to display new core version +if [ -e /boot/grub/grub.cfg ]; then + grub-mkconfig -o /boot/grub/grub.cfg +fi +sync + +# Don't report the exitcode last command +exit 0 diff --git a/config/rootfiles/core/96/exclude b/config/rootfiles/core/96/exclude deleted file mode 100644 index 8e446ce..0000000 --- a/config/rootfiles/core/96/exclude +++ /dev/null @@ -1,26 +0,0 @@ -boot/config.txt -etc/alternatives -etc/collectd.custom -etc/default/grub -etc/ipsec.conf -etc/ipsec.secrets -etc/ipsec.user.conf -etc/ipsec.user.secrets -etc/localtime -etc/shadow -etc/snort/snort.conf -etc/ssh/ssh_config -etc/ssh/sshd_config -etc/ssl/openssl.cnf -etc/sudoers -etc/sysconfig/firewall.local -etc/sysconfig/rc.local -etc/udev/rules.d/30-persistent-network.rules -srv/web/ipfire/html/proxy.pac -var/ipfire/dma -var/ipfire/time -var/ipfire/ovpn -var/lib/alternatives -var/log/cache -var/state/dhcp/dhcpd.leases -var/updatecache diff --git a/config/rootfiles/core/96/filelists/curl b/config/rootfiles/core/96/filelists/curl deleted file mode 120000 index 4b84bef..0000000 --- a/config/rootfiles/core/96/filelists/curl +++ /dev/null @@ -1 +0,0 @@ -../../../common/curl \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/dma b/config/rootfiles/core/96/filelists/dma deleted file mode 120000 index 60f4682..0000000 --- a/config/rootfiles/core/96/filelists/dma +++ /dev/null @@ -1 +0,0 @@ -../../../common/dma \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/dnsmasq b/config/rootfiles/core/96/filelists/dnsmasq deleted file mode 120000 index d469c74..0000000 --- a/config/rootfiles/core/96/filelists/dnsmasq +++ /dev/null @@ -1 +0,0 @@ -../../../common/dnsmasq \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/files b/config/rootfiles/core/96/filelists/files deleted file mode 100644 index 85fb05a..0000000 --- a/config/rootfiles/core/96/filelists/files +++ /dev/null @@ -1,17 +0,0 @@ -etc/system-release -etc/issue -etc/rc.d/init.d/snort -etc/vnstat.conf -etc/rc.d/init.d/cleanfs -etc/rc.d/init.d/collectd -etc/rc.d/init.d/functions -etc/rc.d/init.d/vnstat -etc/rc.d/rc0.d/K51vnstat -etc/rc.d/rc3.d/S01vnstat -etc/rc.d/rc6.d/K51vnstat -opt/pakfire/lib/functions.pl -srv/web/ipfire/cgi-bin/connections.cgi -srv/web/ipfire/cgi-bin/routing.cgi -usr/lib/firewall/rules.pl -usr/sbin/convert-portfw -var/ipfire/general-functions.pl diff --git a/config/rootfiles/core/96/filelists/i586/grub b/config/rootfiles/core/96/filelists/i586/grub deleted file mode 120000 index feb236a..0000000 --- a/config/rootfiles/core/96/filelists/i586/grub +++ /dev/null @@ -1 +0,0 @@ -../../../../common/i586/grub \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/i586/openssl-sse2 b/config/rootfiles/core/96/filelists/i586/openssl-sse2 deleted file mode 120000 index f424713..0000000 --- a/config/rootfiles/core/96/filelists/i586/openssl-sse2 +++ /dev/null @@ -1 +0,0 @@ -../../../../common/i586/openssl-sse2 \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/i586/strongswan-padlock b/config/rootfiles/core/96/filelists/i586/strongswan-padlock deleted file mode 120000 index 2412824..0000000 --- a/config/rootfiles/core/96/filelists/i586/strongswan-padlock +++ /dev/null @@ -1 +0,0 @@ -../../../../common/i586/strongswan-padlock \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/libnet b/config/rootfiles/core/96/filelists/libnet deleted file mode 120000 index 26e5f79..0000000 --- a/config/rootfiles/core/96/filelists/libnet +++ /dev/null @@ -1 +0,0 @@ -../../../common/libnet \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/mdadm b/config/rootfiles/core/96/filelists/mdadm deleted file mode 120000 index 465808b..0000000 --- a/config/rootfiles/core/96/filelists/mdadm +++ /dev/null @@ -1 +0,0 @@ -../../../common/mdadm \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/ntp b/config/rootfiles/core/96/filelists/ntp deleted file mode 120000 index 7542d86..0000000 --- a/config/rootfiles/core/96/filelists/ntp +++ /dev/null @@ -1 +0,0 @@ -../../../common/ntp \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/openssl b/config/rootfiles/core/96/filelists/openssl deleted file mode 120000 index e011a92..0000000 --- a/config/rootfiles/core/96/filelists/openssl +++ /dev/null @@ -1 +0,0 @@ -../../../common/openssl \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/rrdtool b/config/rootfiles/core/96/filelists/rrdtool deleted file mode 120000 index 7a82e41..0000000 --- a/config/rootfiles/core/96/filelists/rrdtool +++ /dev/null @@ -1 +0,0 @@ -../../../common/rrdtool \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/strongswan b/config/rootfiles/core/96/filelists/strongswan deleted file mode 120000 index 90c727e..0000000 --- a/config/rootfiles/core/96/filelists/strongswan +++ /dev/null @@ -1 +0,0 @@ -../../../common/strongswan \ No newline at end of file diff --git a/config/rootfiles/core/96/filelists/x86_64/grub b/config/rootfiles/core/96/filelists/x86_64/grub deleted file mode 120000 index 78d3bd7..0000000 --- a/config/rootfiles/core/96/filelists/x86_64/grub +++ /dev/null @@ -1 +0,0 @@ -../../../../common/x86_64/grub \ No newline at end of file diff --git a/config/rootfiles/core/96/meta b/config/rootfiles/core/96/meta deleted file mode 100644 index d547fa8..0000000 --- a/config/rootfiles/core/96/meta +++ /dev/null @@ -1 +0,0 @@ -DEPS="" diff --git a/config/rootfiles/core/96/update.sh b/config/rootfiles/core/96/update.sh deleted file mode 100644 index fa53cea..0000000 --- a/config/rootfiles/core/96/update.sh +++ /dev/null @@ -1,107 +0,0 @@ -#!/bin/bash -############################################################################ -# # -# This file is part of the IPFire Firewall. # -# # -# IPFire is free software; you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation; either version 3 of the License, or # -# (at your option) any later version. # -# # -# IPFire 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. # -# # -# You should have received a copy of the GNU General Public License # -# along with IPFire; if not, write to the Free Software # -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# # -# Copyright (C) 2015 IPFire-Team info@ipfire.org. # -# # -############################################################################ -# -. /opt/pakfire/lib/functions.sh -/usr/local/bin/backupctrl exclude >/dev/null 2>&1 - -# Remove old core updates from pakfire cache to save space... -core=96 -for (( i=1; i<=$core; i++ )) -do - rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire -done - -# Stop services -/etc/init.d/fcron stop -/etc/init.d/collectd stop -/usr/local/bin/qosctrl stop - -# Backup RRDs -if [ -d "/var/log/rrd.bak" ]; then - # Umount ramdisk - umount -l "/var/log/rrd" - rm -rf "/var/log/rrd" - - mv "/var/log/rrd.bak/vnstat" "/var/log/vnstat" - mv "/var/log/rrd.bak" "/var/log/rrd" -fi - -# Remove old scripts -rm -f /etc/rc.d/init.d/tmpfs \ - /etc/rc.d/rc0.d/K85tmpfs \ - /etc/rc.d/rc3.d/S01tmpfs \ - /etc/rc.d/rc6.d/K85tmpfs - -# Extract files -extract_files - -# Update Language cache -/usr/local/bin/update-lang-cache - -# Remove Ramdisk entry from fstab -sed -i -e "s|^none\s/var/log/rrd.*||g" /etc/fstab - -# Keep (almost) old ramdisk behaviour -if [ ! -e "/etc/sysconfig/ramdisk" ]; then - echo "RAMDISK_MODE=2" > /etc/sysconfig/ramdisk -fi - -if [ -L "/var/spool/cron" ]; then - rm -f /var/spool/cron - mv /var/log/rrd/cron /var/spool/cron - chown cron:cron /var/spool/cron - - # Add new crontab entries - sed -i /var/spool/cron/root.orig -e "/tmpfs backup/d" - grep -q "collectd backup" /var/spool/cron/root.orig || cat <<EOF >> /var/spool/cron/root.orig -# Backup ramdisks if necessary -%nightly,random * 23-4 /etc/init.d/collectd backup &>/dev/null -%nightly,random * 23-4 /etc/init.d/vnstat backup &>/dev/null -EOF - fcrontab -z -fi - -# Start services -/etc/init.d/collectd start -/etc/init.d/vnstat start -/etc/init.d/fcron start -/etc/init.d/dnsmasq restart -/usr/local/bin/qosctrl start - -# Disable loading of cryptodev -sed -e "s/^cryptodev/# &/g" -i /etc/sysconfig/modules - -# This update need a reboot... -#touch /var/run/need_reboot - -# Finish -/etc/init.d/fireinfo start -sendprofile -# Update grub config to display new core version -if [ -e /boot/grub/grub.cfg ]; then - grub-mkconfig -o /boot/grub/grub.cfg -fi -sync - -# Don't report the exitcode last command -exit 0 diff --git a/config/rootfiles/core/97/exclude b/config/rootfiles/core/97/exclude deleted file mode 100644 index d87f175..0000000 --- a/config/rootfiles/core/97/exclude +++ /dev/null @@ -1,25 +0,0 @@ -boot/config.txt -etc/alternatives -etc/collectd.custom -etc/ipsec.conf -etc/ipsec.secrets -etc/ipsec.user.conf -etc/ipsec.user.secrets -etc/localtime -etc/shadow -etc/snort/snort.conf -etc/ssh/ssh_config -etc/ssh/sshd_config -etc/ssl/openssl.cnf -etc/sudoers -etc/sysconfig/firewall.local -etc/sysconfig/rc.local -etc/udev/rules.d/30-persistent-network.rules -srv/web/ipfire/html/proxy.pac -var/ipfire/dma -var/ipfire/time -var/ipfire/ovpn -var/lib/alternatives -var/log/cache -var/state/dhcp/dhcpd.leases -var/updatecache diff --git a/config/rootfiles/core/97/filelists/files b/config/rootfiles/core/97/filelists/files deleted file mode 100644 index 409e5fe..0000000 --- a/config/rootfiles/core/97/filelists/files +++ /dev/null @@ -1,2 +0,0 @@ -etc/system-release -etc/issue diff --git a/config/rootfiles/core/97/filelists/hwdata b/config/rootfiles/core/97/filelists/hwdata deleted file mode 100644 index 5a9672f..0000000 --- a/config/rootfiles/core/97/filelists/hwdata +++ /dev/null @@ -1,2 +0,0 @@ -usr/share/hwdata/pci.ids -usr/share/hwdata/usb.ids diff --git a/config/rootfiles/core/97/filelists/i586/openssl-sse2 b/config/rootfiles/core/97/filelists/i586/openssl-sse2 deleted file mode 120000 index f424713..0000000 --- a/config/rootfiles/core/97/filelists/i586/openssl-sse2 +++ /dev/null @@ -1 +0,0 @@ -../../../../common/i586/openssl-sse2 \ No newline at end of file diff --git a/config/rootfiles/core/97/filelists/openssh b/config/rootfiles/core/97/filelists/openssh deleted file mode 120000 index d8c77fd..0000000 --- a/config/rootfiles/core/97/filelists/openssh +++ /dev/null @@ -1 +0,0 @@ -../../../common/openssh \ No newline at end of file diff --git a/config/rootfiles/core/97/filelists/openssl b/config/rootfiles/core/97/filelists/openssl deleted file mode 120000 index e011a92..0000000 --- a/config/rootfiles/core/97/filelists/openssl +++ /dev/null @@ -1 +0,0 @@ -../../../common/openssl \ No newline at end of file diff --git a/config/rootfiles/core/97/meta b/config/rootfiles/core/97/meta deleted file mode 100644 index d547fa8..0000000 --- a/config/rootfiles/core/97/meta +++ /dev/null @@ -1 +0,0 @@ -DEPS="" diff --git a/config/rootfiles/core/97/update.sh b/config/rootfiles/core/97/update.sh deleted file mode 100644 index be240fa..0000000 --- a/config/rootfiles/core/97/update.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/bash -############################################################################ -# # -# This file is part of the IPFire Firewall. # -# # -# IPFire is free software; you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation; either version 3 of the License, or # -# (at your option) any later version. # -# # -# IPFire 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. # -# # -# You should have received a copy of the GNU General Public License # -# along with IPFire; if not, write to the Free Software # -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# # -# Copyright (C) 2016 IPFire-Team info@ipfire.org. # -# # -############################################################################ -# -. /opt/pakfire/lib/functions.sh -/usr/local/bin/backupctrl exclude >/dev/null 2>&1 - -# Remove old core updates from pakfire cache to save space... -core=97 -for (( i=1; i<=$core; i++ )) -do - rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire -done - -# Stop services - -# Extract files -extract_files - -# Update Language cache -# /usr/local/bin/update-lang-cache - -# Start services -/etc/init.d/sshd restart -/etc/init.d/apace restart - -# This update need a reboot... -touch /var/run/need_reboot - -# Finish -/etc/init.d/fireinfo start -sendprofile -# Update grub config to display new core version -if [ -e /boot/grub/grub.cfg ]; then - grub-mkconfig -o /boot/grub/grub.cfg -fi -sync - -# Don't report the exitcode last command -exit 0 diff --git a/config/rootfiles/core/98/exclude b/config/rootfiles/core/98/exclude deleted file mode 100644 index d87f175..0000000 --- a/config/rootfiles/core/98/exclude +++ /dev/null @@ -1,25 +0,0 @@ -boot/config.txt -etc/alternatives -etc/collectd.custom -etc/ipsec.conf -etc/ipsec.secrets -etc/ipsec.user.conf -etc/ipsec.user.secrets -etc/localtime -etc/shadow -etc/snort/snort.conf -etc/ssh/ssh_config -etc/ssh/sshd_config -etc/ssl/openssl.cnf -etc/sudoers -etc/sysconfig/firewall.local -etc/sysconfig/rc.local -etc/udev/rules.d/30-persistent-network.rules -srv/web/ipfire/html/proxy.pac -var/ipfire/dma -var/ipfire/time -var/ipfire/ovpn -var/lib/alternatives -var/log/cache -var/state/dhcp/dhcpd.leases -var/updatecache diff --git a/config/rootfiles/core/98/filelists/armv5tel/glibc b/config/rootfiles/core/98/filelists/armv5tel/glibc deleted file mode 120000 index 4c70d72..0000000 --- a/config/rootfiles/core/98/filelists/armv5tel/glibc +++ /dev/null @@ -1 +0,0 @@ -../../../../common/armv5tel/glibc \ No newline at end of file diff --git a/config/rootfiles/core/98/filelists/files b/config/rootfiles/core/98/filelists/files deleted file mode 100644 index 409e5fe..0000000 --- a/config/rootfiles/core/98/filelists/files +++ /dev/null @@ -1,2 +0,0 @@ -etc/system-release -etc/issue diff --git a/config/rootfiles/core/98/filelists/i586/glibc b/config/rootfiles/core/98/filelists/i586/glibc deleted file mode 120000 index 943021f..0000000 --- a/config/rootfiles/core/98/filelists/i586/glibc +++ /dev/null @@ -1 +0,0 @@ -../../../../common/i586/glibc \ No newline at end of file diff --git a/config/rootfiles/core/98/filelists/x86_64/glibc b/config/rootfiles/core/98/filelists/x86_64/glibc deleted file mode 120000 index 1119099..0000000 --- a/config/rootfiles/core/98/filelists/x86_64/glibc +++ /dev/null @@ -1 +0,0 @@ -../../../../common/x86_64/glibc \ No newline at end of file diff --git a/config/rootfiles/core/98/meta b/config/rootfiles/core/98/meta deleted file mode 100644 index d547fa8..0000000 --- a/config/rootfiles/core/98/meta +++ /dev/null @@ -1 +0,0 @@ -DEPS="" diff --git a/config/rootfiles/core/98/update.sh b/config/rootfiles/core/98/update.sh deleted file mode 100644 index 7e0cc2d..0000000 --- a/config/rootfiles/core/98/update.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -############################################################################ -# # -# This file is part of the IPFire Firewall. # -# # -# IPFire is free software; you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation; either version 3 of the License, or # -# (at your option) any later version. # -# # -# IPFire 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. # -# # -# You should have received a copy of the GNU General Public License # -# along with IPFire; if not, write to the Free Software # -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # -# # -# Copyright (C) 2016 IPFire-Team info@ipfire.org. # -# # -############################################################################ -# -. /opt/pakfire/lib/functions.sh -/usr/local/bin/backupctrl exclude >/dev/null 2>&1 - -# Remove old core updates from pakfire cache to save space... -core=98 -for (( i=1; i<=$core; i++ )) -do - rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire -done - -# Stop services - -# Extract files -extract_files - -# Bugfixes for core96 updater bugs... -if [ -e /boot/grub/grub.conf ]; then - # legacy grub config on xen or citrix conflicts with grub2 config - # and core96 contains an empty file - if [ ! -s /boot/grub/grub.cfg ]; then - rm /boot/grub/grub.cfg - fi -fi - -if [ -e /boot/grub/grub.cfg ]; then - # test if serial console is enabled - grep "^7:2345" /etc/inittab > /dev/null - if [ "${?}" == "0" ]; then - # Fix grub config for serial console - sed -i /etc/default/grub \ - -e "s|"panic=10"|"panic=10 console=ttyS0,115200n8"|g" - sed -i /etc/default/grub \ - -e "s|^GRUB_TERMINAL=.*||g" - sed -i /etc/default/grub \ - -e "s|^GRUB_SERIAL_COMMAND=.*||g" - echo "GRUB_TERMINAL="serial"" >> /etc/default/grub - echo "GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"" >> /etc/default/grub - fi -fi - - -# Update Language cache -# /usr/local/bin/update-lang-cache - -# restart init after glibc update -telinit u - -# Start services - -# This update need a reboot... -touch /var/run/need_reboot - -# Finish -/etc/init.d/fireinfo start -sendprofile -# Update grub config to display new core version -if [ -e /boot/grub/grub.cfg ]; then - grub-mkconfig -o /boot/grub/grub.cfg -fi -sync - -# Don't report the exitcode last command -exit 0 diff --git a/config/rootfiles/oldcore/96/exclude b/config/rootfiles/oldcore/96/exclude new file mode 100644 index 0000000..d87f175 --- /dev/null +++ b/config/rootfiles/oldcore/96/exclude @@ -0,0 +1,25 @@ +boot/config.txt +etc/alternatives +etc/collectd.custom +etc/ipsec.conf +etc/ipsec.secrets +etc/ipsec.user.conf +etc/ipsec.user.secrets +etc/localtime +etc/shadow +etc/snort/snort.conf +etc/ssh/ssh_config +etc/ssh/sshd_config +etc/ssl/openssl.cnf +etc/sudoers +etc/sysconfig/firewall.local +etc/sysconfig/rc.local +etc/udev/rules.d/30-persistent-network.rules +srv/web/ipfire/html/proxy.pac +var/ipfire/dma +var/ipfire/time +var/ipfire/ovpn +var/lib/alternatives +var/log/cache +var/state/dhcp/dhcpd.leases +var/updatecache diff --git a/config/rootfiles/oldcore/96/filelists/curl b/config/rootfiles/oldcore/96/filelists/curl new file mode 120000 index 0000000..4b84bef --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/curl @@ -0,0 +1 @@ +../../../common/curl \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/dma b/config/rootfiles/oldcore/96/filelists/dma new file mode 120000 index 0000000..60f4682 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/dma @@ -0,0 +1 @@ +../../../common/dma \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/dnsmasq b/config/rootfiles/oldcore/96/filelists/dnsmasq new file mode 120000 index 0000000..d469c74 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/dnsmasq @@ -0,0 +1 @@ +../../../common/dnsmasq \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/files b/config/rootfiles/oldcore/96/filelists/files new file mode 100644 index 0000000..85fb05a --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/files @@ -0,0 +1,17 @@ +etc/system-release +etc/issue +etc/rc.d/init.d/snort +etc/vnstat.conf +etc/rc.d/init.d/cleanfs +etc/rc.d/init.d/collectd +etc/rc.d/init.d/functions +etc/rc.d/init.d/vnstat +etc/rc.d/rc0.d/K51vnstat +etc/rc.d/rc3.d/S01vnstat +etc/rc.d/rc6.d/K51vnstat +opt/pakfire/lib/functions.pl +srv/web/ipfire/cgi-bin/connections.cgi +srv/web/ipfire/cgi-bin/routing.cgi +usr/lib/firewall/rules.pl +usr/sbin/convert-portfw +var/ipfire/general-functions.pl diff --git a/config/rootfiles/oldcore/96/filelists/i586/grub b/config/rootfiles/oldcore/96/filelists/i586/grub new file mode 120000 index 0000000..feb236a --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/i586/grub @@ -0,0 +1 @@ +../../../../common/i586/grub \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/i586/openssl-sse2 b/config/rootfiles/oldcore/96/filelists/i586/openssl-sse2 new file mode 120000 index 0000000..f424713 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/i586/openssl-sse2 @@ -0,0 +1 @@ +../../../../common/i586/openssl-sse2 \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/i586/strongswan-padlock b/config/rootfiles/oldcore/96/filelists/i586/strongswan-padlock new file mode 120000 index 0000000..2412824 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/i586/strongswan-padlock @@ -0,0 +1 @@ +../../../../common/i586/strongswan-padlock \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/libnet b/config/rootfiles/oldcore/96/filelists/libnet new file mode 120000 index 0000000..26e5f79 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/libnet @@ -0,0 +1 @@ +../../../common/libnet \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/mdadm b/config/rootfiles/oldcore/96/filelists/mdadm new file mode 120000 index 0000000..465808b --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/mdadm @@ -0,0 +1 @@ +../../../common/mdadm \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/ntp b/config/rootfiles/oldcore/96/filelists/ntp new file mode 120000 index 0000000..7542d86 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/ntp @@ -0,0 +1 @@ +../../../common/ntp \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/openssl b/config/rootfiles/oldcore/96/filelists/openssl new file mode 120000 index 0000000..e011a92 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/openssl @@ -0,0 +1 @@ +../../../common/openssl \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/rrdtool b/config/rootfiles/oldcore/96/filelists/rrdtool new file mode 120000 index 0000000..7a82e41 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/rrdtool @@ -0,0 +1 @@ +../../../common/rrdtool \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/strongswan b/config/rootfiles/oldcore/96/filelists/strongswan new file mode 120000 index 0000000..90c727e --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/strongswan @@ -0,0 +1 @@ +../../../common/strongswan \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/filelists/x86_64/grub b/config/rootfiles/oldcore/96/filelists/x86_64/grub new file mode 120000 index 0000000..78d3bd7 --- /dev/null +++ b/config/rootfiles/oldcore/96/filelists/x86_64/grub @@ -0,0 +1 @@ +../../../../common/x86_64/grub \ No newline at end of file diff --git a/config/rootfiles/oldcore/96/meta b/config/rootfiles/oldcore/96/meta new file mode 100644 index 0000000..d547fa8 --- /dev/null +++ b/config/rootfiles/oldcore/96/meta @@ -0,0 +1 @@ +DEPS="" diff --git a/config/rootfiles/oldcore/96/update.sh b/config/rootfiles/oldcore/96/update.sh new file mode 100644 index 0000000..fa53cea --- /dev/null +++ b/config/rootfiles/oldcore/96/update.sh @@ -0,0 +1,107 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 3 of the License, or # +# (at your option) any later version. # +# # +# IPFire 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2015 IPFire-Team info@ipfire.org. # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh +/usr/local/bin/backupctrl exclude >/dev/null 2>&1 + +# Remove old core updates from pakfire cache to save space... +core=96 +for (( i=1; i<=$core; i++ )) +do + rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire +done + +# Stop services +/etc/init.d/fcron stop +/etc/init.d/collectd stop +/usr/local/bin/qosctrl stop + +# Backup RRDs +if [ -d "/var/log/rrd.bak" ]; then + # Umount ramdisk + umount -l "/var/log/rrd" + rm -rf "/var/log/rrd" + + mv "/var/log/rrd.bak/vnstat" "/var/log/vnstat" + mv "/var/log/rrd.bak" "/var/log/rrd" +fi + +# Remove old scripts +rm -f /etc/rc.d/init.d/tmpfs \ + /etc/rc.d/rc0.d/K85tmpfs \ + /etc/rc.d/rc3.d/S01tmpfs \ + /etc/rc.d/rc6.d/K85tmpfs + +# Extract files +extract_files + +# Update Language cache +/usr/local/bin/update-lang-cache + +# Remove Ramdisk entry from fstab +sed -i -e "s|^none\s/var/log/rrd.*||g" /etc/fstab + +# Keep (almost) old ramdisk behaviour +if [ ! -e "/etc/sysconfig/ramdisk" ]; then + echo "RAMDISK_MODE=2" > /etc/sysconfig/ramdisk +fi + +if [ -L "/var/spool/cron" ]; then + rm -f /var/spool/cron + mv /var/log/rrd/cron /var/spool/cron + chown cron:cron /var/spool/cron + + # Add new crontab entries + sed -i /var/spool/cron/root.orig -e "/tmpfs backup/d" + grep -q "collectd backup" /var/spool/cron/root.orig || cat <<EOF >> /var/spool/cron/root.orig +# Backup ramdisks if necessary +%nightly,random * 23-4 /etc/init.d/collectd backup &>/dev/null +%nightly,random * 23-4 /etc/init.d/vnstat backup &>/dev/null +EOF + fcrontab -z +fi + +# Start services +/etc/init.d/collectd start +/etc/init.d/vnstat start +/etc/init.d/fcron start +/etc/init.d/dnsmasq restart +/usr/local/bin/qosctrl start + +# Disable loading of cryptodev +sed -e "s/^cryptodev/# &/g" -i /etc/sysconfig/modules + +# This update need a reboot... +#touch /var/run/need_reboot + +# Finish +/etc/init.d/fireinfo start +sendprofile +# Update grub config to display new core version +if [ -e /boot/grub/grub.cfg ]; then + grub-mkconfig -o /boot/grub/grub.cfg +fi +sync + +# Don't report the exitcode last command +exit 0 diff --git a/config/rootfiles/oldcore/97/exclude b/config/rootfiles/oldcore/97/exclude new file mode 100644 index 0000000..d87f175 --- /dev/null +++ b/config/rootfiles/oldcore/97/exclude @@ -0,0 +1,25 @@ +boot/config.txt +etc/alternatives +etc/collectd.custom +etc/ipsec.conf +etc/ipsec.secrets +etc/ipsec.user.conf +etc/ipsec.user.secrets +etc/localtime +etc/shadow +etc/snort/snort.conf +etc/ssh/ssh_config +etc/ssh/sshd_config +etc/ssl/openssl.cnf +etc/sudoers +etc/sysconfig/firewall.local +etc/sysconfig/rc.local +etc/udev/rules.d/30-persistent-network.rules +srv/web/ipfire/html/proxy.pac +var/ipfire/dma +var/ipfire/time +var/ipfire/ovpn +var/lib/alternatives +var/log/cache +var/state/dhcp/dhcpd.leases +var/updatecache diff --git a/config/rootfiles/oldcore/97/filelists/files b/config/rootfiles/oldcore/97/filelists/files new file mode 100644 index 0000000..8586e6a --- /dev/null +++ b/config/rootfiles/oldcore/97/filelists/files @@ -0,0 +1,18 @@ +etc/system-release +etc/issue +etc/rc.d/init.d/firewall +etc/modprobe.d/nf_conntrack.conf +srv/web/ipfire/cgi-bin/logs.cgi/firewalllog.dat +srv/web/ipfire/cgi-bin/logs.cgi/firewalllogcountry.dat +srv/web/ipfire/cgi-bin/logs.cgi/firewalllogip.dat +srv/web/ipfire/cgi-bin/logs.cgi/firewalllogport.dat +srv/web/ipfire/cgi-bin/logs.cgi/showrequestfromcountry.dat +srv/web/ipfire/cgi-bin/logs.cgi/showrequestfromip.dat +srv/web/ipfire/cgi-bin/logs.cgi/showrequestfromport.dat +srv/web/ipfire/cgi-bin/optionsfw.cgi +srv/web/ipfire/cgi-bin/ovpnmain.cgi +srv/web/ipfire/cgi-bin/qos.cgi +srv/web/ipfire/cgi-bin/webaccess.cgi +usr/bin/pgrep +usr/local/bin/qosctrl +usr/local/bin/timectrl diff --git a/config/rootfiles/oldcore/97/filelists/hwdata b/config/rootfiles/oldcore/97/filelists/hwdata new file mode 100644 index 0000000..5a9672f --- /dev/null +++ b/config/rootfiles/oldcore/97/filelists/hwdata @@ -0,0 +1,2 @@ +usr/share/hwdata/pci.ids +usr/share/hwdata/usb.ids diff --git a/config/rootfiles/oldcore/97/filelists/i586/openssl-sse2 b/config/rootfiles/oldcore/97/filelists/i586/openssl-sse2 new file mode 120000 index 0000000..f424713 --- /dev/null +++ b/config/rootfiles/oldcore/97/filelists/i586/openssl-sse2 @@ -0,0 +1 @@ +../../../../common/i586/openssl-sse2 \ No newline at end of file diff --git a/config/rootfiles/oldcore/97/filelists/openssh b/config/rootfiles/oldcore/97/filelists/openssh new file mode 120000 index 0000000..d8c77fd --- /dev/null +++ b/config/rootfiles/oldcore/97/filelists/openssh @@ -0,0 +1 @@ +../../../common/openssh \ No newline at end of file diff --git a/config/rootfiles/oldcore/97/filelists/openssl b/config/rootfiles/oldcore/97/filelists/openssl new file mode 120000 index 0000000..e011a92 --- /dev/null +++ b/config/rootfiles/oldcore/97/filelists/openssl @@ -0,0 +1 @@ +../../../common/openssl \ No newline at end of file diff --git a/config/rootfiles/oldcore/97/meta b/config/rootfiles/oldcore/97/meta new file mode 100644 index 0000000..d547fa8 --- /dev/null +++ b/config/rootfiles/oldcore/97/meta @@ -0,0 +1 @@ +DEPS="" diff --git a/config/rootfiles/oldcore/97/update.sh b/config/rootfiles/oldcore/97/update.sh new file mode 100644 index 0000000..be240fa --- /dev/null +++ b/config/rootfiles/oldcore/97/update.sh @@ -0,0 +1,59 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 3 of the License, or # +# (at your option) any later version. # +# # +# IPFire 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2016 IPFire-Team info@ipfire.org. # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh +/usr/local/bin/backupctrl exclude >/dev/null 2>&1 + +# Remove old core updates from pakfire cache to save space... +core=97 +for (( i=1; i<=$core; i++ )) +do + rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire +done + +# Stop services + +# Extract files +extract_files + +# Update Language cache +# /usr/local/bin/update-lang-cache + +# Start services +/etc/init.d/sshd restart +/etc/init.d/apace restart + +# This update need a reboot... +touch /var/run/need_reboot + +# Finish +/etc/init.d/fireinfo start +sendprofile +# Update grub config to display new core version +if [ -e /boot/grub/grub.cfg ]; then + grub-mkconfig -o /boot/grub/grub.cfg +fi +sync + +# Don't report the exitcode last command +exit 0 diff --git a/config/rootfiles/oldcore/98/exclude b/config/rootfiles/oldcore/98/exclude new file mode 100644 index 0000000..d87f175 --- /dev/null +++ b/config/rootfiles/oldcore/98/exclude @@ -0,0 +1,25 @@ +boot/config.txt +etc/alternatives +etc/collectd.custom +etc/ipsec.conf +etc/ipsec.secrets +etc/ipsec.user.conf +etc/ipsec.user.secrets +etc/localtime +etc/shadow +etc/snort/snort.conf +etc/ssh/ssh_config +etc/ssh/sshd_config +etc/ssl/openssl.cnf +etc/sudoers +etc/sysconfig/firewall.local +etc/sysconfig/rc.local +etc/udev/rules.d/30-persistent-network.rules +srv/web/ipfire/html/proxy.pac +var/ipfire/dma +var/ipfire/time +var/ipfire/ovpn +var/lib/alternatives +var/log/cache +var/state/dhcp/dhcpd.leases +var/updatecache diff --git a/config/rootfiles/oldcore/98/filelists/armv5tel/glibc b/config/rootfiles/oldcore/98/filelists/armv5tel/glibc new file mode 120000 index 0000000..4c70d72 --- /dev/null +++ b/config/rootfiles/oldcore/98/filelists/armv5tel/glibc @@ -0,0 +1 @@ +../../../../common/armv5tel/glibc \ No newline at end of file diff --git a/config/rootfiles/oldcore/98/filelists/files b/config/rootfiles/oldcore/98/filelists/files new file mode 100644 index 0000000..409e5fe --- /dev/null +++ b/config/rootfiles/oldcore/98/filelists/files @@ -0,0 +1,2 @@ +etc/system-release +etc/issue diff --git a/config/rootfiles/oldcore/98/filelists/i586/glibc b/config/rootfiles/oldcore/98/filelists/i586/glibc new file mode 120000 index 0000000..943021f --- /dev/null +++ b/config/rootfiles/oldcore/98/filelists/i586/glibc @@ -0,0 +1 @@ +../../../../common/i586/glibc \ No newline at end of file diff --git a/config/rootfiles/oldcore/98/filelists/x86_64/glibc b/config/rootfiles/oldcore/98/filelists/x86_64/glibc new file mode 120000 index 0000000..1119099 --- /dev/null +++ b/config/rootfiles/oldcore/98/filelists/x86_64/glibc @@ -0,0 +1 @@ +../../../../common/x86_64/glibc \ No newline at end of file diff --git a/config/rootfiles/oldcore/98/meta b/config/rootfiles/oldcore/98/meta new file mode 100644 index 0000000..d547fa8 --- /dev/null +++ b/config/rootfiles/oldcore/98/meta @@ -0,0 +1 @@ +DEPS="" diff --git a/config/rootfiles/oldcore/98/update.sh b/config/rootfiles/oldcore/98/update.sh new file mode 100644 index 0000000..7e0cc2d --- /dev/null +++ b/config/rootfiles/oldcore/98/update.sh @@ -0,0 +1,86 @@ +#!/bin/bash +############################################################################ +# # +# This file is part of the IPFire Firewall. # +# # +# IPFire is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 3 of the License, or # +# (at your option) any later version. # +# # +# IPFire 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with IPFire; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +# Copyright (C) 2016 IPFire-Team info@ipfire.org. # +# # +############################################################################ +# +. /opt/pakfire/lib/functions.sh +/usr/local/bin/backupctrl exclude >/dev/null 2>&1 + +# Remove old core updates from pakfire cache to save space... +core=98 +for (( i=1; i<=$core; i++ )) +do + rm -f /var/cache/pakfire/core-upgrade-*-$i.ipfire +done + +# Stop services + +# Extract files +extract_files + +# Bugfixes for core96 updater bugs... +if [ -e /boot/grub/grub.conf ]; then + # legacy grub config on xen or citrix conflicts with grub2 config + # and core96 contains an empty file + if [ ! -s /boot/grub/grub.cfg ]; then + rm /boot/grub/grub.cfg + fi +fi + +if [ -e /boot/grub/grub.cfg ]; then + # test if serial console is enabled + grep "^7:2345" /etc/inittab > /dev/null + if [ "${?}" == "0" ]; then + # Fix grub config for serial console + sed -i /etc/default/grub \ + -e "s|"panic=10"|"panic=10 console=ttyS0,115200n8"|g" + sed -i /etc/default/grub \ + -e "s|^GRUB_TERMINAL=.*||g" + sed -i /etc/default/grub \ + -e "s|^GRUB_SERIAL_COMMAND=.*||g" + echo "GRUB_TERMINAL="serial"" >> /etc/default/grub + echo "GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"" >> /etc/default/grub + fi +fi + + +# Update Language cache +# /usr/local/bin/update-lang-cache + +# restart init after glibc update +telinit u + +# Start services + +# This update need a reboot... +touch /var/run/need_reboot + +# Finish +/etc/init.d/fireinfo start +sendprofile +# Update grub config to display new core version +if [ -e /boot/grub/grub.cfg ]; then + grub-mkconfig -o /boot/grub/grub.cfg +fi +sync + +# Don't report the exitcode last command +exit 0 diff --git a/config/rootfiles/packages/bird b/config/rootfiles/packages/bird new file mode 100644 index 0000000..fd2b8ec --- /dev/null +++ b/config/rootfiles/packages/bird @@ -0,0 +1,4 @@ +etc/bird.conf +usr/sbin/bird +usr/sbin/birdc +usr/sbin/birdcl diff --git a/config/rootfiles/packages/dnsdist b/config/rootfiles/packages/dnsdist new file mode 100644 index 0000000..ba7381f --- /dev/null +++ b/config/rootfiles/packages/dnsdist @@ -0,0 +1,3 @@ +usr/bin/dnsdist +#usr/share/man/man1/dnsdist.1 +etc/rc.d/init.d/dnsdist diff --git a/config/rootfiles/packages/mediatomb b/config/rootfiles/packages/mediatomb deleted file mode 100644 index fd72752..0000000 --- a/config/rootfiles/packages/mediatomb +++ /dev/null @@ -1,104 +0,0 @@ -usr/bin/mediatomb -#usr/share/man/man1/mediatomb.1 -#usr/share/mediatomb -#usr/share/mediatomb/js -usr/share/mediatomb/js/common.js -usr/share/mediatomb/js/import.js -usr/share/mediatomb/js/playlists.js -usr/share/mediatomb/mappings.xml -usr/share/mediatomb/mysql.sql -usr/share/mediatomb/sqlite3.sql -#usr/share/mediatomb/web -usr/share/mediatomb/web/cds.xml -usr/share/mediatomb/web/cm.xml -usr/share/mediatomb/web/disabled.html -usr/share/mediatomb/web/favicon.ico -#usr/share/mediatomb/web/icons -usr/share/mediatomb/web/icons/add_as_autoscan.png -usr/share/mediatomb/web/icons/autoscan_inotify_config_folder_open.png -usr/share/mediatomb/web/icons/autoscan_inotify_folder_open.png -usr/share/mediatomb/web/icons/autoscan_timed_config_folder_open.png -usr/share/mediatomb/web/icons/autoscan_timed_folder_open.png -usr/share/mediatomb/web/icons/blank.gif -usr/share/mediatomb/web/icons/blank.png -usr/share/mediatomb/web/icons/document-new.png -usr/share/mediatomb/web/icons/film.png -usr/share/mediatomb/web/icons/folder_new.png -usr/share/mediatomb/web/icons/folder_open.png -usr/share/mediatomb/web/icons/go-first.png -usr/share/mediatomb/web/icons/go-last.png -usr/share/mediatomb/web/icons/go-next.png -usr/share/mediatomb/web/icons/go-previous.png -usr/share/mediatomb/web/icons/mediatomb.png -usr/share/mediatomb/web/icons/mt-icon120.bmp -usr/share/mediatomb/web/icons/mt-icon120.jpg -usr/share/mediatomb/web/icons/mt-icon120.png -usr/share/mediatomb/web/icons/mt-icon32.bmp -usr/share/mediatomb/web/icons/mt-icon32.jpg -usr/share/mediatomb/web/icons/mt-icon32.png -usr/share/mediatomb/web/icons/mt-icon48.bmp -usr/share/mediatomb/web/icons/mt-icon48.jpg -usr/share/mediatomb/web/icons/mt-icon48.png -#usr/share/mediatomb/web/icons/nanotree -#usr/share/mediatomb/web/icons/nanotree/images -usr/share/mediatomb/web/icons/nanotree/images/autoscan_inotify_config_folder_closed.png -usr/share/mediatomb/web/icons/nanotree/images/autoscan_inotify_config_folder_open.png -usr/share/mediatomb/web/icons/nanotree/images/autoscan_inotify_folder_closed.png -usr/share/mediatomb/web/icons/nanotree/images/autoscan_inotify_folder_open.png -usr/share/mediatomb/web/icons/nanotree/images/autoscan_timed_config_folder_closed.png -usr/share/mediatomb/web/icons/nanotree/images/autoscan_timed_config_folder_open.png -usr/share/mediatomb/web/icons/nanotree/images/autoscan_timed_folder_closed.png -usr/share/mediatomb/web/icons/nanotree/images/autoscan_timed_folder_open.png -usr/share/mediatomb/web/icons/nanotree/images/folder_closed.png -usr/share/mediatomb/web/icons/nanotree/images/folder_open.png -usr/share/mediatomb/web/icons/nanotree/images/lastnode.png -usr/share/mediatomb/web/icons/nanotree/images/line.png -usr/share/mediatomb/web/icons/nanotree/images/minus.png -usr/share/mediatomb/web/icons/nanotree/images/minus_last.png -usr/share/mediatomb/web/icons/nanotree/images/minus_last_no_root.png -usr/share/mediatomb/web/icons/nanotree/images/minus_no_root.png -usr/share/mediatomb/web/icons/nanotree/images/plus.png -usr/share/mediatomb/web/icons/nanotree/images/plus_last.png -usr/share/mediatomb/web/icons/nanotree/images/plus_last_no_root.png -usr/share/mediatomb/web/icons/nanotree/images/plus_no_root.png -usr/share/mediatomb/web/icons/nanotree/images/t.png -usr/share/mediatomb/web/icons/nanotree/images/t_no_root.png -usr/share/mediatomb/web/icons/nanotree/images/white.png -usr/share/mediatomb/web/icons/remove_all.png -usr/share/mediatomb/web/icons/remove_autoscan.png -usr/share/mediatomb/web/icons/remove_this.png -usr/share/mediatomb/web/icons/status.png -usr/share/mediatomb/web/icons/status_loading.png -usr/share/mediatomb/web/icons/status_updates_pending.png -usr/share/mediatomb/web/icons/stock-add.png -usr/share/mediatomb/web/icons/stock_edit.png -usr/share/mediatomb/web/icons/stock_exit.png -usr/share/mediatomb/web/index.html -#usr/share/mediatomb/web/js -usr/share/mediatomb/web/js/auth.js -usr/share/mediatomb/web/js/autoscan.js -usr/share/mediatomb/web/js/icons.js -usr/share/mediatomb/web/js/iepngfix.htc -usr/share/mediatomb/web/js/items.js -usr/share/mediatomb/web/js/md5.js -usr/share/mediatomb/web/js/nanotree.js -usr/share/mediatomb/web/js/prototype.js -usr/share/mediatomb/web/js/tasks.js -usr/share/mediatomb/web/js/tools.js -usr/share/mediatomb/web/js/tree.js -usr/share/mediatomb/web/left.html -usr/share/mediatomb/web/main.css -usr/share/mediatomb/web/mr_reg.xml -usr/share/mediatomb/web/right.html -usr/share/mediatomb/web/std_treelook.css -usr/share/mediatomb/web/top.html -usr/share/mediatomb/web/topleft.html -usr/share/mediatomb/web/topright.html -var/ipfire/backup/addons/includes/mediatomb -var/ipfire/mediatomb -#var/ipfire/mediatomb/config.xml -etc/rc.d/init.d/mediatomb -etc/rc.d/rc0.d/K02mediatomb -etc/rc.d/rc6.d/K02mediatomb -etc/rc.d/rc3.d/S98mediatomb -var/mp3/info diff --git a/config/rootfiles/packages/mediatomb.off b/config/rootfiles/packages/mediatomb.off new file mode 100644 index 0000000..fd72752 --- /dev/null +++ b/config/rootfiles/packages/mediatomb.off @@ -0,0 +1,104 @@ +usr/bin/mediatomb +#usr/share/man/man1/mediatomb.1 +#usr/share/mediatomb +#usr/share/mediatomb/js +usr/share/mediatomb/js/common.js +usr/share/mediatomb/js/import.js +usr/share/mediatomb/js/playlists.js +usr/share/mediatomb/mappings.xml +usr/share/mediatomb/mysql.sql +usr/share/mediatomb/sqlite3.sql +#usr/share/mediatomb/web +usr/share/mediatomb/web/cds.xml +usr/share/mediatomb/web/cm.xml +usr/share/mediatomb/web/disabled.html +usr/share/mediatomb/web/favicon.ico +#usr/share/mediatomb/web/icons +usr/share/mediatomb/web/icons/add_as_autoscan.png +usr/share/mediatomb/web/icons/autoscan_inotify_config_folder_open.png +usr/share/mediatomb/web/icons/autoscan_inotify_folder_open.png +usr/share/mediatomb/web/icons/autoscan_timed_config_folder_open.png +usr/share/mediatomb/web/icons/autoscan_timed_folder_open.png +usr/share/mediatomb/web/icons/blank.gif +usr/share/mediatomb/web/icons/blank.png +usr/share/mediatomb/web/icons/document-new.png +usr/share/mediatomb/web/icons/film.png +usr/share/mediatomb/web/icons/folder_new.png +usr/share/mediatomb/web/icons/folder_open.png +usr/share/mediatomb/web/icons/go-first.png +usr/share/mediatomb/web/icons/go-last.png +usr/share/mediatomb/web/icons/go-next.png +usr/share/mediatomb/web/icons/go-previous.png +usr/share/mediatomb/web/icons/mediatomb.png +usr/share/mediatomb/web/icons/mt-icon120.bmp +usr/share/mediatomb/web/icons/mt-icon120.jpg +usr/share/mediatomb/web/icons/mt-icon120.png +usr/share/mediatomb/web/icons/mt-icon32.bmp +usr/share/mediatomb/web/icons/mt-icon32.jpg +usr/share/mediatomb/web/icons/mt-icon32.png +usr/share/mediatomb/web/icons/mt-icon48.bmp +usr/share/mediatomb/web/icons/mt-icon48.jpg +usr/share/mediatomb/web/icons/mt-icon48.png +#usr/share/mediatomb/web/icons/nanotree +#usr/share/mediatomb/web/icons/nanotree/images +usr/share/mediatomb/web/icons/nanotree/images/autoscan_inotify_config_folder_closed.png +usr/share/mediatomb/web/icons/nanotree/images/autoscan_inotify_config_folder_open.png +usr/share/mediatomb/web/icons/nanotree/images/autoscan_inotify_folder_closed.png +usr/share/mediatomb/web/icons/nanotree/images/autoscan_inotify_folder_open.png +usr/share/mediatomb/web/icons/nanotree/images/autoscan_timed_config_folder_closed.png +usr/share/mediatomb/web/icons/nanotree/images/autoscan_timed_config_folder_open.png +usr/share/mediatomb/web/icons/nanotree/images/autoscan_timed_folder_closed.png +usr/share/mediatomb/web/icons/nanotree/images/autoscan_timed_folder_open.png +usr/share/mediatomb/web/icons/nanotree/images/folder_closed.png +usr/share/mediatomb/web/icons/nanotree/images/folder_open.png +usr/share/mediatomb/web/icons/nanotree/images/lastnode.png +usr/share/mediatomb/web/icons/nanotree/images/line.png +usr/share/mediatomb/web/icons/nanotree/images/minus.png +usr/share/mediatomb/web/icons/nanotree/images/minus_last.png +usr/share/mediatomb/web/icons/nanotree/images/minus_last_no_root.png +usr/share/mediatomb/web/icons/nanotree/images/minus_no_root.png +usr/share/mediatomb/web/icons/nanotree/images/plus.png +usr/share/mediatomb/web/icons/nanotree/images/plus_last.png +usr/share/mediatomb/web/icons/nanotree/images/plus_last_no_root.png +usr/share/mediatomb/web/icons/nanotree/images/plus_no_root.png +usr/share/mediatomb/web/icons/nanotree/images/t.png +usr/share/mediatomb/web/icons/nanotree/images/t_no_root.png +usr/share/mediatomb/web/icons/nanotree/images/white.png +usr/share/mediatomb/web/icons/remove_all.png +usr/share/mediatomb/web/icons/remove_autoscan.png +usr/share/mediatomb/web/icons/remove_this.png +usr/share/mediatomb/web/icons/status.png +usr/share/mediatomb/web/icons/status_loading.png +usr/share/mediatomb/web/icons/status_updates_pending.png +usr/share/mediatomb/web/icons/stock-add.png +usr/share/mediatomb/web/icons/stock_edit.png +usr/share/mediatomb/web/icons/stock_exit.png +usr/share/mediatomb/web/index.html +#usr/share/mediatomb/web/js +usr/share/mediatomb/web/js/auth.js +usr/share/mediatomb/web/js/autoscan.js +usr/share/mediatomb/web/js/icons.js +usr/share/mediatomb/web/js/iepngfix.htc +usr/share/mediatomb/web/js/items.js +usr/share/mediatomb/web/js/md5.js +usr/share/mediatomb/web/js/nanotree.js +usr/share/mediatomb/web/js/prototype.js +usr/share/mediatomb/web/js/tasks.js +usr/share/mediatomb/web/js/tools.js +usr/share/mediatomb/web/js/tree.js +usr/share/mediatomb/web/left.html +usr/share/mediatomb/web/main.css +usr/share/mediatomb/web/mr_reg.xml +usr/share/mediatomb/web/right.html +usr/share/mediatomb/web/std_treelook.css +usr/share/mediatomb/web/top.html +usr/share/mediatomb/web/topleft.html +usr/share/mediatomb/web/topright.html +var/ipfire/backup/addons/includes/mediatomb +var/ipfire/mediatomb +#var/ipfire/mediatomb/config.xml +etc/rc.d/init.d/mediatomb +etc/rc.d/rc0.d/K02mediatomb +etc/rc.d/rc6.d/K02mediatomb +etc/rc.d/rc3.d/S98mediatomb +var/mp3/info diff --git a/config/rootfiles/packages/nano b/config/rootfiles/packages/nano index d31753c..3582f36 100644 --- a/config/rootfiles/packages/nano +++ b/config/rootfiles/packages/nano @@ -14,6 +14,7 @@ usr/bin/rnano #usr/share/man/man5/nanorc.5 #usr/share/nano usr/share/nano/asm.nanorc +usr/share/nano/autoconf.nanorc usr/share/nano/awk.nanorc usr/share/nano/c.nanorc #usr/share/nano/changelog.nanorc @@ -37,6 +38,7 @@ usr/share/nano/man.nanorc usr/share/nano/mgp.nanorc usr/share/nano/mutt.nanorc usr/share/nano/nanorc.nanorc +usr/share/nano/nftables.nanorc usr/share/nano/objc.nanorc usr/share/nano/ocaml.nanorc usr/share/nano/patch.nanorc diff --git a/config/rootfiles/packages/owncloud b/config/rootfiles/packages/owncloud index 5ce7789..9ea21e3 100644 --- a/config/rootfiles/packages/owncloud +++ b/config/rootfiles/packages/owncloud @@ -8,7 +8,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/Console/Getopt.php #srv/web/owncloud/3rdparty/Jcrop #srv/web/owncloud/3rdparty/Jcrop/MIT-LICENSE.txt -#srv/web/owncloud/3rdparty/Jcrop/README.md #srv/web/owncloud/3rdparty/Jcrop/css #srv/web/owncloud/3rdparty/Jcrop/css/Jcrop.gif #srv/web/owncloud/3rdparty/Jcrop/css/jquery.Jcrop.css @@ -220,7 +219,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/Patchwork/PHP/Shim/unidata/compatibilityDecomposition.ser #srv/web/owncloud/3rdparty/Patchwork/PHP/Shim/unidata/lowerCase.ser #srv/web/owncloud/3rdparty/Patchwork/PHP/Shim/unidata/upperCase.ser -#srv/web/owncloud/3rdparty/Patchwork/README.md #srv/web/owncloud/3rdparty/Patchwork/Utf8 #srv/web/owncloud/3rdparty/Patchwork/Utf8.php #srv/web/owncloud/3rdparty/Patchwork/Utf8/Bootup @@ -253,13 +251,11 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/css/chosen/chosen.css #srv/web/owncloud/3rdparty/css/strengthify #srv/web/owncloud/3rdparty/css/strengthify/LICENSE -#srv/web/owncloud/3rdparty/css/strengthify/README.md #srv/web/owncloud/3rdparty/css/strengthify/strengthify.css #srv/web/owncloud/3rdparty/doctrine #srv/web/owncloud/3rdparty/doctrine/common #srv/web/owncloud/3rdparty/doctrine/common/.gitmodules #srv/web/owncloud/3rdparty/doctrine/common/LICENSE -#srv/web/owncloud/3rdparty/doctrine/common/README.md #srv/web/owncloud/3rdparty/doctrine/common/UPGRADE_TO_2_1 #srv/web/owncloud/3rdparty/doctrine/common/UPGRADE_TO_2_2 #srv/web/owncloud/3rdparty/doctrine/common/build.properties @@ -498,7 +494,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/doctrine/dbal #srv/web/owncloud/3rdparty/doctrine/dbal/.gitmodules #srv/web/owncloud/3rdparty/doctrine/dbal/LICENSE -#srv/web/owncloud/3rdparty/doctrine/dbal/README.md #srv/web/owncloud/3rdparty/doctrine/dbal/UPGRADE #srv/web/owncloud/3rdparty/doctrine/dbal/bin #srv/web/owncloud/3rdparty/doctrine/dbal/bin/doctrine-dbal @@ -512,7 +507,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/doctrine/dbal/docs/design/SHARDING.md #srv/web/owncloud/3rdparty/doctrine/dbal/docs/examples #srv/web/owncloud/3rdparty/doctrine/dbal/docs/examples/sharding -#srv/web/owncloud/3rdparty/doctrine/dbal/docs/examples/sharding/README.md #srv/web/owncloud/3rdparty/doctrine/dbal/docs/examples/sharding/bootstrap.php #srv/web/owncloud/3rdparty/doctrine/dbal/docs/examples/sharding/composer.json #srv/web/owncloud/3rdparty/doctrine/dbal/docs/examples/sharding/create_schema.php @@ -847,7 +841,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/doctrine/dbal/tests/travis/pgsql.travis.xml #srv/web/owncloud/3rdparty/doctrine/dbal/tests/travis/sqlite.travis.xml #srv/web/owncloud/3rdparty/fontawesome -#srv/web/owncloud/3rdparty/fontawesome/README.md #srv/web/owncloud/3rdparty/fontawesome/css #srv/web/owncloud/3rdparty/fontawesome/css/font-awesome-ie7.min.css #srv/web/owncloud/3rdparty/fontawesome/css/font-awesome.css @@ -970,7 +963,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/james-heinrich #srv/web/owncloud/3rdparty/james-heinrich/getid3 #srv/web/owncloud/3rdparty/james-heinrich/getid3/.gitattributes -#srv/web/owncloud/3rdparty/james-heinrich/getid3/README.md #srv/web/owncloud/3rdparty/james-heinrich/getid3/changelog.txt #srv/web/owncloud/3rdparty/james-heinrich/getid3/composer.json #srv/web/owncloud/3rdparty/james-heinrich/getid3/dependencies.txt @@ -1061,19 +1053,16 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/js #srv/web/owncloud/3rdparty/js/chosen #srv/web/owncloud/3rdparty/js/chosen/LICENSE.md -#srv/web/owncloud/3rdparty/js/chosen/README.md #srv/web/owncloud/3rdparty/js/chosen/VERSION #srv/web/owncloud/3rdparty/js/chosen/chosen.jquery.js #srv/web/owncloud/3rdparty/js/chosen/chosen.jquery.min.js #srv/web/owncloud/3rdparty/js/chosen/chosen.proto.js #srv/web/owncloud/3rdparty/js/chosen/chosen.proto.min.js #srv/web/owncloud/3rdparty/js/md5 -#srv/web/owncloud/3rdparty/js/md5/README.md #srv/web/owncloud/3rdparty/js/md5/md5.js #srv/web/owncloud/3rdparty/js/md5/md5.min.js #srv/web/owncloud/3rdparty/js/strengthify #srv/web/owncloud/3rdparty/js/strengthify/LICENSE -#srv/web/owncloud/3rdparty/js/strengthify/README.md #srv/web/owncloud/3rdparty/js/strengthify/jquery.strengthify.js #srv/web/owncloud/3rdparty/kriswallsmith #srv/web/owncloud/3rdparty/kriswallsmith/assetic @@ -1083,7 +1072,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/kriswallsmith/assetic/CHANGELOG-1.2.md #srv/web/owncloud/3rdparty/kriswallsmith/assetic/Gemfile #srv/web/owncloud/3rdparty/kriswallsmith/assetic/LICENSE -#srv/web/owncloud/3rdparty/kriswallsmith/assetic/README.md #srv/web/owncloud/3rdparty/kriswallsmith/assetic/composer.json #srv/web/owncloud/3rdparty/kriswallsmith/assetic/docs #srv/web/owncloud/3rdparty/kriswallsmith/assetic/docs/en @@ -1400,7 +1388,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/mcnetic #srv/web/owncloud/3rdparty/mcnetic/phpzipstreamer #srv/web/owncloud/3rdparty/mcnetic/phpzipstreamer/COPYING -#srv/web/owncloud/3rdparty/mcnetic/phpzipstreamer/README.md #srv/web/owncloud/3rdparty/mcnetic/phpzipstreamer/ZipStreamer.php #srv/web/owncloud/3rdparty/miniColors #srv/web/owncloud/3rdparty/miniColors/GPL-LICENSE.txt @@ -1421,7 +1408,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/phpmailer/phpmailer #srv/web/owncloud/3rdparty/phpmailer/phpmailer/LICENSE #srv/web/owncloud/3rdparty/phpmailer/phpmailer/PHPMailerAutoload.php -#srv/web/owncloud/3rdparty/phpmailer/phpmailer/README.md #srv/web/owncloud/3rdparty/phpmailer/phpmailer/changelog.md #srv/web/owncloud/3rdparty/phpmailer/phpmailer/class.phpmailer.php #srv/web/owncloud/3rdparty/phpmailer/phpmailer/class.pop3.php @@ -1538,7 +1524,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/phpseclib/phpseclib/.gitattributes #srv/web/owncloud/3rdparty/phpseclib/phpseclib/AUTHORS #srv/web/owncloud/3rdparty/phpseclib/phpseclib/LICENSE -#srv/web/owncloud/3rdparty/phpseclib/phpseclib/README.md #srv/web/owncloud/3rdparty/phpseclib/phpseclib/build #srv/web/owncloud/3rdparty/phpseclib/phpseclib/build/code-sniffer-ruleset-tests.xml #srv/web/owncloud/3rdparty/phpseclib/phpseclib/build/code-sniffer-ruleset.xml @@ -1606,7 +1591,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/rackspace/php-opencloud/.coveralls.yml #srv/web/owncloud/3rdparty/rackspace/php-opencloud/CONTRIBUTING.md #srv/web/owncloud/3rdparty/rackspace/php-opencloud/LICENSE -#srv/web/owncloud/3rdparty/rackspace/php-opencloud/README.md #srv/web/owncloud/3rdparty/rackspace/php-opencloud/composer.json #srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs #srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs/changelog @@ -1647,7 +1631,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs/userguide/Identity/Users.md #srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs/userguide/Iterators.md #srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs/userguide/LoadBalancer -#srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs/userguide/LoadBalancer/README.md #srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs/userguide/LoadBalancer/USERGUIDE.md #srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs/userguide/ObjectStore #srv/web/owncloud/3rdparty/rackspace/php-opencloud/docs/userguide/ObjectStore/Access.md @@ -2186,7 +2169,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/sabre/dav #srv/web/owncloud/3rdparty/sabre/dav/ChangeLog #srv/web/owncloud/3rdparty/sabre/dav/LICENSE -#srv/web/owncloud/3rdparty/sabre/dav/README.md #srv/web/owncloud/3rdparty/sabre/dav/bin #srv/web/owncloud/3rdparty/sabre/dav/bin/googlecode_upload.py #srv/web/owncloud/3rdparty/sabre/dav/bin/migrateto17.php @@ -2645,7 +2627,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/sabre/vobject #srv/web/owncloud/3rdparty/sabre/vobject/ChangeLog #srv/web/owncloud/3rdparty/sabre/vobject/LICENSE -#srv/web/owncloud/3rdparty/sabre/vobject/README.md #srv/web/owncloud/3rdparty/sabre/vobject/bin #srv/web/owncloud/3rdparty/sabre/vobject/bin/bench.php #srv/web/owncloud/3rdparty/sabre/vobject/bin/generateicalendardata.php @@ -2786,7 +2767,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Output/Output.php #srv/web/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Output/OutputInterface.php #srv/web/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Output/StreamOutput.php -#srv/web/owncloud/3rdparty/symfony/console/Symfony/Component/Console/README.md #srv/web/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Shell.php #srv/web/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Tester #srv/web/owncloud/3rdparty/symfony/console/Symfony/Component/Console/Tester/ApplicationTester.php @@ -2939,7 +2919,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php #srv/web/owncloud/3rdparty/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php #srv/web/owncloud/3rdparty/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE -#srv/web/owncloud/3rdparty/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md #srv/web/owncloud/3rdparty/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests #srv/web/owncloud/3rdparty/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php #srv/web/owncloud/3rdparty/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug @@ -2973,7 +2952,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/symfony/process/Symfony/Component/Process/ProcessBuilder.php #srv/web/owncloud/3rdparty/symfony/process/Symfony/Component/Process/ProcessPipes.php #srv/web/owncloud/3rdparty/symfony/process/Symfony/Component/Process/ProcessUtils.php -#srv/web/owncloud/3rdparty/symfony/process/Symfony/Component/Process/README.md #srv/web/owncloud/3rdparty/symfony/process/Symfony/Component/Process/Tests #srv/web/owncloud/3rdparty/symfony/process/Symfony/Component/Process/Tests/AbstractProcessTest.php #srv/web/owncloud/3rdparty/symfony/process/Symfony/Component/Process/Tests/NonStopableProcess.php @@ -3034,7 +3012,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/symfony/routing/Symfony/Component/Routing/Matcher/RedirectableUrlMatcherInterface.php #srv/web/owncloud/3rdparty/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcher.php #srv/web/owncloud/3rdparty/symfony/routing/Symfony/Component/Routing/Matcher/UrlMatcherInterface.php -#srv/web/owncloud/3rdparty/symfony/routing/Symfony/Component/Routing/README.md #srv/web/owncloud/3rdparty/symfony/routing/Symfony/Component/Routing/RequestContext.php #srv/web/owncloud/3rdparty/symfony/routing/Symfony/Component/Routing/RequestContextAwareInterface.php #srv/web/owncloud/3rdparty/symfony/routing/Symfony/Component/Routing/Route.php @@ -3107,7 +3084,6 @@ srv/web/owncloud #srv/web/owncloud/3rdparty/timepicker/releases.txt #srv/web/owncloud/3rdparty/zxcvbn #srv/web/owncloud/3rdparty/zxcvbn/LICENSE.txt -#srv/web/owncloud/3rdparty/zxcvbn/README.md #srv/web/owncloud/3rdparty/zxcvbn/js #srv/web/owncloud/3rdparty/zxcvbn/js/zxcvbn.js #srv/web/owncloud/3rdparty/zxcvbn/js/zxcvbn.min.js @@ -3115,7 +3091,6 @@ srv/web/owncloud #srv/web/owncloud/COPYING-AGPL #srv/web/owncloud/apps #srv/web/owncloud/apps/activity -#srv/web/owncloud/apps/activity/README.md #srv/web/owncloud/apps/activity/ajax #srv/web/owncloud/apps/activity/ajax/fetch.php #srv/web/owncloud/apps/activity/ajax/rssfeed.php @@ -3124,6 +3099,7 @@ srv/web/owncloud #srv/web/owncloud/apps/activity/appinfo/app.php #srv/web/owncloud/apps/activity/appinfo/database.xml #srv/web/owncloud/apps/activity/appinfo/info.xml +#srv/web/owncloud/apps/activity/appinfo/preupdate.php #srv/web/owncloud/apps/activity/appinfo/routes.php #srv/web/owncloud/apps/activity/appinfo/update.php #srv/web/owncloud/apps/activity/appinfo/version @@ -3296,78 +3272,6 @@ srv/web/owncloud #srv/web/owncloud/apps/activity/tests/parameterhelpertest.php #srv/web/owncloud/apps/activity/tests/phpunit.xml #srv/web/owncloud/apps/activity/tests/usersettingstest.php -#srv/web/owncloud/apps/admin_dependencies_chk -#srv/web/owncloud/apps/admin_dependencies_chk/appinfo -#srv/web/owncloud/apps/admin_dependencies_chk/appinfo/app.php -#srv/web/owncloud/apps/admin_dependencies_chk/appinfo/info.xml -#srv/web/owncloud/apps/admin_dependencies_chk/appinfo/version -#srv/web/owncloud/apps/admin_dependencies_chk/css -#srv/web/owncloud/apps/admin_dependencies_chk/css/style.css -#srv/web/owncloud/apps/admin_dependencies_chk/l10n -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ar.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ast.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/bg_BG.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/bn_BD.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ca.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/cs_CZ.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/da.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/de.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/de_CH.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/de_DE.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/el.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/en_GB.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/eo.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/es.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/es_AR.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/es_CL.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/es_MX.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/et_EE.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/eu.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/eu_ES.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/fa.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/fi_FI.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/fr.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/gl.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/hu_HU.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/id.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/is.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/it.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ja.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ja_JP.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/jv.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ka_GE.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/km.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ko.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/lb.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/lt_LT.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/lv.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/mk.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/nb_NO.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/nl.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/nn_NO.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/pl.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/pt_BR.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/pt_PT.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ro.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ru.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/si_LK.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/sk_SK.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/sl.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/sq.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/sr.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/sr@latin.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/sv.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ta_LK.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/th_TH.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/tr.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/ug.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/uk.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/vi.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/zh_CN.php -#srv/web/owncloud/apps/admin_dependencies_chk/l10n/zh_TW.php -#srv/web/owncloud/apps/admin_dependencies_chk/settings.php -#srv/web/owncloud/apps/admin_dependencies_chk/templates -#srv/web/owncloud/apps/admin_dependencies_chk/templates/settings.php #srv/web/owncloud/apps/bookmarks #srv/web/owncloud/apps/bookmarks/3rdparty #srv/web/owncloud/apps/bookmarks/3rdparty/css @@ -3375,7 +3279,6 @@ srv/web/owncloud #srv/web/owncloud/apps/bookmarks/3rdparty/js #srv/web/owncloud/apps/bookmarks/3rdparty/js/js_tpl.js #srv/web/owncloud/apps/bookmarks/3rdparty/js/tag-it.js -#srv/web/owncloud/apps/bookmarks/README.md #srv/web/owncloud/apps/bookmarks/addBm.php #srv/web/owncloud/apps/bookmarks/ajax #srv/web/owncloud/apps/bookmarks/ajax/delBookmark.php @@ -3640,7 +3543,6 @@ srv/web/owncloud #srv/web/owncloud/apps/calendar/3rdparty/fullcalendar/js/fullcalendar.js #srv/web/owncloud/apps/calendar/3rdparty/fullcalendar/js/fullcalendar.min.js #srv/web/owncloud/apps/calendar/3rdparty/fullcalendar/js/gcal.js -#srv/web/owncloud/apps/calendar/README.md #srv/web/owncloud/apps/calendar/ajax #srv/web/owncloud/apps/calendar/ajax/cache #srv/web/owncloud/apps/calendar/ajax/cache/rescan.php @@ -4073,10 +3975,8 @@ srv/web/owncloud #srv/web/owncloud/apps/calendar/tests #srv/web/owncloud/apps/calendar/tests/calendar.php #srv/web/owncloud/apps/contacts -#srv/web/owncloud/apps/contacts/.jshintrc #srv/web/owncloud/apps/contacts/COPYING-README #srv/web/owncloud/apps/contacts/Changelog -#srv/web/owncloud/apps/contacts/README.md #srv/web/owncloud/apps/contacts/admin.php #srv/web/owncloud/apps/contacts/appinfo #srv/web/owncloud/apps/contacts/appinfo/app.php @@ -4551,7 +4451,6 @@ srv/web/owncloud #srv/web/owncloud/apps/contacts/tests/preseed-config.php #srv/web/owncloud/apps/contacts/tests/setup_owncloud.sh #srv/web/owncloud/apps/documents -#srv/web/owncloud/apps/documents/README.md #srv/web/owncloud/apps/documents/admin.php #srv/web/owncloud/apps/documents/ajax #srv/web/owncloud/apps/documents/ajax/admin.php @@ -5154,6 +5053,8 @@ srv/web/owncloud #srv/web/owncloud/apps/documents/js/3rdparty/resources/dojo/resources/images/dndNoCopy.png #srv/web/owncloud/apps/documents/js/3rdparty/resources/dojo/resources/images/dndNoMove.png #srv/web/owncloud/apps/documents/js/3rdparty/resources/dojox +#srv/web/owncloud/apps/documents/js/3rdparty/resources/dojox/html +#srv/web/owncloud/apps/documents/js/3rdparty/resources/dojox/html/entities.js #srv/web/owncloud/apps/documents/js/3rdparty/resources/dojox/layout #srv/web/owncloud/apps/documents/js/3rdparty/resources/dojox/layout/resources #srv/web/owncloud/apps/documents/js/3rdparty/resources/dojox/layout/resources/DndGridContainer.css @@ -6008,6 +5909,7 @@ srv/web/owncloud #srv/web/owncloud/apps/files_encryption/tests/proxy.php #srv/web/owncloud/apps/files_encryption/tests/share.php #srv/web/owncloud/apps/files_encryption/tests/stream.php +#srv/web/owncloud/apps/files_encryption/tests/testcase.php #srv/web/owncloud/apps/files_encryption/tests/trashbin.php #srv/web/owncloud/apps/files_encryption/tests/util.php #srv/web/owncloud/apps/files_encryption/tests/webdav.php @@ -6028,7 +5930,6 @@ srv/web/owncloud #srv/web/owncloud/apps/files_external/3rdparty/Dropbox/OAuth/Consumer #srv/web/owncloud/apps/files_external/3rdparty/Dropbox/OAuth/Consumer/Dropbox.php #srv/web/owncloud/apps/files_external/3rdparty/Dropbox/OAuth/Curl.php -#srv/web/owncloud/apps/files_external/3rdparty/Dropbox/README.md #srv/web/owncloud/apps/files_external/3rdparty/Dropbox/autoload.php #srv/web/owncloud/apps/files_external/3rdparty/aws-sdk-php #srv/web/owncloud/apps/files_external/3rdparty/aws-sdk-php/Aws @@ -7142,7 +7043,6 @@ srv/web/owncloud #srv/web/owncloud/apps/files_pdfviewer/3rdparty/pdfjs/pdf.worker.js #srv/web/owncloud/apps/files_pdfviewer/3rdparty/pdfjs/viewer.css #srv/web/owncloud/apps/files_pdfviewer/3rdparty/pdfjs/viewer.js -#srv/web/owncloud/apps/files_pdfviewer/README.md #srv/web/owncloud/apps/files_pdfviewer/appinfo #srv/web/owncloud/apps/files_pdfviewer/appinfo/app.php #srv/web/owncloud/apps/files_pdfviewer/appinfo/info.xml @@ -7281,6 +7181,7 @@ srv/web/owncloud #srv/web/owncloud/apps/files_sharing/lib/proxy.php #srv/web/owncloud/apps/files_sharing/lib/readonlycache.php #srv/web/owncloud/apps/files_sharing/lib/readonlywrapper.php +#srv/web/owncloud/apps/files_sharing/lib/scanner.php #srv/web/owncloud/apps/files_sharing/lib/share #srv/web/owncloud/apps/files_sharing/lib/share/file.php #srv/web/owncloud/apps/files_sharing/lib/share/folder.php @@ -7310,6 +7211,7 @@ srv/web/owncloud #srv/web/owncloud/apps/files_sharing/tests/js/shareSpec.js #srv/web/owncloud/apps/files_sharing/tests/js/sharedfilelistSpec.js #srv/web/owncloud/apps/files_sharing/tests/permissions.php +#srv/web/owncloud/apps/files_sharing/tests/propagation.php #srv/web/owncloud/apps/files_sharing/tests/proxy.php #srv/web/owncloud/apps/files_sharing/tests/share.php #srv/web/owncloud/apps/files_sharing/tests/sharedmount.php @@ -7318,7 +7220,6 @@ srv/web/owncloud #srv/web/owncloud/apps/files_sharing/tests/updater.php #srv/web/owncloud/apps/files_sharing/tests/watcher.php #srv/web/owncloud/apps/files_texteditor -#srv/web/owncloud/apps/files_texteditor/README.md #srv/web/owncloud/apps/files_texteditor/ajax #srv/web/owncloud/apps/files_texteditor/ajax/loadfile.php #srv/web/owncloud/apps/files_texteditor/ajax/savefile.php @@ -7677,6 +7578,7 @@ srv/web/owncloud #srv/web/owncloud/apps/files_trashbin/appinfo/app.php #srv/web/owncloud/apps/files_trashbin/appinfo/database.xml #srv/web/owncloud/apps/files_trashbin/appinfo/info.xml +#srv/web/owncloud/apps/files_trashbin/appinfo/preupdate.php #srv/web/owncloud/apps/files_trashbin/appinfo/routes.php #srv/web/owncloud/apps/files_trashbin/appinfo/update.php #srv/web/owncloud/apps/files_trashbin/appinfo/version @@ -7923,7 +7825,6 @@ srv/web/owncloud #srv/web/owncloud/apps/files_videoviewer/src/silverlight/SilverlightMediaElement.csproj.user #srv/web/owncloud/apps/files_videoviewer/src/silverlight/SilverlightMediaElement.sln #srv/web/owncloud/apps/firstrunwizard -#srv/web/owncloud/apps/firstrunwizard/README.md #srv/web/owncloud/apps/firstrunwizard/ajax #srv/web/owncloud/apps/firstrunwizard/ajax/disable.php #srv/web/owncloud/apps/firstrunwizard/ajax/enable.php @@ -8016,7 +7917,6 @@ srv/web/owncloud #srv/web/owncloud/apps/firstrunwizard/templates/wizard.php #srv/web/owncloud/apps/firstrunwizard/wizard.php #srv/web/owncloud/apps/gallery -#srv/web/owncloud/apps/gallery/README.md #srv/web/owncloud/apps/gallery/ajax #srv/web/owncloud/apps/gallery/ajax/gallery.php #srv/web/owncloud/apps/gallery/ajax/getimages.php @@ -8696,7 +8596,6 @@ srv/web/owncloud #srv/web/owncloud/apps/templateeditor/templates/settings-admin.php #srv/web/owncloud/apps/updater #srv/web/owncloud/apps/updater/COPYING-AGPL -#srv/web/owncloud/apps/updater/README.md #srv/web/owncloud/apps/updater/admin.php #srv/web/owncloud/apps/updater/ajax #srv/web/owncloud/apps/updater/ajax/backup @@ -8817,7 +8716,6 @@ srv/web/owncloud #srv/web/owncloud/apps/updater/templates/update.php #srv/web/owncloud/apps/updater/update.php #srv/web/owncloud/apps/user_external -#srv/web/owncloud/apps/user_external/README.md #srv/web/owncloud/apps/user_external/appinfo #srv/web/owncloud/apps/user_external/appinfo/app.php #srv/web/owncloud/apps/user_external/appinfo/database.xml @@ -8851,8 +8749,11 @@ srv/web/owncloud #srv/web/owncloud/apps/user_ldap/appinfo/update.php #srv/web/owncloud/apps/user_ldap/appinfo/version #srv/web/owncloud/apps/user_ldap/command +#srv/web/owncloud/apps/user_ldap/command/checkuser.php +#srv/web/owncloud/apps/user_ldap/command/search.php #srv/web/owncloud/apps/user_ldap/command/setconfig.php #srv/web/owncloud/apps/user_ldap/command/showconfig.php +#srv/web/owncloud/apps/user_ldap/command/showremnants.php #srv/web/owncloud/apps/user_ldap/command/testconfig.php #srv/web/owncloud/apps/user_ldap/css #srv/web/owncloud/apps/user_ldap/css/settings.css @@ -8986,14 +8887,18 @@ srv/web/owncloud #srv/web/owncloud/apps/user_ldap/lib/filesystemhelper.php #srv/web/owncloud/apps/user_ldap/lib/helper.php #srv/web/owncloud/apps/user_ldap/lib/ildapwrapper.php +#srv/web/owncloud/apps/user_ldap/lib/jobs #srv/web/owncloud/apps/user_ldap/lib/jobs.php +#srv/web/owncloud/apps/user_ldap/lib/jobs/cleanup.php #srv/web/owncloud/apps/user_ldap/lib/ldap.php #srv/web/owncloud/apps/user_ldap/lib/ldaputility.php #srv/web/owncloud/apps/user_ldap/lib/logwrapper.php #srv/web/owncloud/apps/user_ldap/lib/proxy.php #srv/web/owncloud/apps/user_ldap/lib/user +#srv/web/owncloud/apps/user_ldap/lib/user/deletedusersindex.php #srv/web/owncloud/apps/user_ldap/lib/user/iusertools.php #srv/web/owncloud/apps/user_ldap/lib/user/manager.php +#srv/web/owncloud/apps/user_ldap/lib/user/offlineuser.php #srv/web/owncloud/apps/user_ldap/lib/user/user.php #srv/web/owncloud/apps/user_ldap/lib/wizard.php #srv/web/owncloud/apps/user_ldap/lib/wizardresult.php @@ -9009,10 +8914,10 @@ srv/web/owncloud #srv/web/owncloud/apps/user_ldap/tests #srv/web/owncloud/apps/user_ldap/tests/access.php #srv/web/owncloud/apps/user_ldap/tests/connection.php -#srv/web/owncloud/apps/user_ldap/tests/data -#srv/web/owncloud/apps/user_ldap/tests/data/sid.dat #srv/web/owncloud/apps/user_ldap/tests/group_ldap.php #srv/web/owncloud/apps/user_ldap/tests/helper.php +#srv/web/owncloud/apps/user_ldap/tests/jobs +#srv/web/owncloud/apps/user_ldap/tests/jobs/cleanup.php #srv/web/owncloud/apps/user_ldap/tests/user #srv/web/owncloud/apps/user_ldap/tests/user/manager.php #srv/web/owncloud/apps/user_ldap/tests/user/user.php @@ -9132,6 +9037,7 @@ srv/web/owncloud #srv/web/owncloud/core/command/status.php #srv/web/owncloud/core/command/upgrade.php #srv/web/owncloud/core/command/user +#srv/web/owncloud/core/command/user/delete.php #srv/web/owncloud/core/command/user/lastseen.php #srv/web/owncloud/core/command/user/report.php #srv/web/owncloud/core/command/user/resetpassword.php @@ -9170,243 +9076,277 @@ srv/web/owncloud #srv/web/owncloud/core/css/styles.css #srv/web/owncloud/core/doc #srv/web/owncloud/core/doc/admin -#srv/web/owncloud/core/doc/admin/_images -#srv/web/owncloud/core/doc/admin/_images/antivirus-app.png -#srv/web/owncloud/core/doc/admin/_images/antivirus-config.png -#srv/web/owncloud/core/doc/admin/_images/antivirus-daemon-socket.png -#srv/web/owncloud/core/doc/admin/_images/antivirus-executable.png -#srv/web/owncloud/core/doc/admin/_images/antivirus-logging.png -#srv/web/owncloud/core/doc/admin/_images/create_public_share.png -#srv/web/owncloud/core/doc/admin/_images/documents_app_enable.png -#srv/web/owncloud/core/doc/admin/_images/encryption1.png -#srv/web/owncloud/core/doc/admin/_images/encryption2.png -#srv/web/owncloud/core/doc/admin/_images/encryption3.png -#srv/web/owncloud/core/doc/admin/_images/encryption4.png -#srv/web/owncloud/core/doc/admin/_images/encryption5.png -#srv/web/owncloud/core/doc/admin/_images/encryption6.png -#srv/web/owncloud/core/doc/admin/_images/encryption7.png -#srv/web/owncloud/core/doc/admin/_images/encryption8.png -#srv/web/owncloud/core/doc/admin/_images/encryption9.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-amazons3.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-app-add.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-app-enable.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-app-local.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-app-usermounts.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-dropbox-allowshare.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-dropbox-app.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-dropbox-configapp.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-dropbox-oc.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-dropbox.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-ftp.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive-0auth.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive-9.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive-sdk.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive1.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive2.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive5.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive7.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-google-drive8.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-smb.png -#srv/web/owncloud/core/doc/admin/_images/external-storage-webdav.png -#srv/web/owncloud/core/doc/admin/_images/install-wizard-advanced.png -#srv/web/owncloud/core/doc/admin/_images/install-wizard.png -#srv/web/owncloud/core/doc/admin/_images/ldap-advanced-1-connection.png -#srv/web/owncloud/core/doc/admin/_images/ldap-advanced-2-directory.png -#srv/web/owncloud/core/doc/admin/_images/ldap-advanced-3-attributes.png -#srv/web/owncloud/core/doc/admin/_images/ldap-expert.png -#srv/web/owncloud/core/doc/admin/_images/ldap-fetched-avatar.png -#srv/web/owncloud/core/doc/admin/_images/ldap-settings-invalid-oc45.png -#srv/web/owncloud/core/doc/admin/_images/ldap-settings-valid-oc45.png -#srv/web/owncloud/core/doc/admin/_images/ldap-wizard-1-server.png -#srv/web/owncloud/core/doc/admin/_images/ldap-wizard-2-user.png -#srv/web/owncloud/core/doc/admin/_images/ldap-wizard-3-login.png -#srv/web/owncloud/core/doc/admin/_images/ldap-wizard-4-group.png -#srv/web/owncloud/core/doc/admin/_images/lucene-search-enable.png -#srv/web/owncloud/core/doc/admin/_images/lucene-search-user.png -#srv/web/owncloud/core/doc/admin/_images/oc_admin_app_page.png -#srv/web/owncloud/core/doc/admin/_images/preview_images.png -#srv/web/owncloud/core/doc/admin/_images/remote_shares.png -#srv/web/owncloud/core/doc/admin/_images/sharing-admin.png -#srv/web/owncloud/core/doc/admin/_images/sharing-user-local.png -#srv/web/owncloud/core/doc/admin/_images/sharing-user.png -#srv/web/owncloud/core/doc/admin/_images/smtp-config-php-sendmail.png -#srv/web/owncloud/core/doc/admin/_images/smtp-config-smtp.png -#srv/web/owncloud/core/doc/admin/_images/smtp-config-wizard.png -#srv/web/owncloud/core/doc/admin/_images/ucs-app-center-install.png -#srv/web/owncloud/core/doc/admin/_images/ucs-app-center-module.png -#srv/web/owncloud/core/doc/admin/_images/ucsint.png -#srv/web/owncloud/core/doc/admin/_images/ucsint1.png -#srv/web/owncloud/core/doc/admin/_images/ucsint2.png -#srv/web/owncloud/core/doc/admin/_images/untrusted-domain.png -#srv/web/owncloud/core/doc/admin/_images/updater-1.png -#srv/web/owncloud/core/doc/admin/_images/updater-2.png -#srv/web/owncloud/core/doc/admin/_images/updater-3.png -#srv/web/owncloud/core/doc/admin/_images/updater-4.png -#srv/web/owncloud/core/doc/admin/_images/updater-5.png -#srv/web/owncloud/core/doc/admin/_images/updater-6.png -#srv/web/owncloud/core/doc/admin/_images/updater-7.png -#srv/web/owncloud/core/doc/admin/_images/users-config.png -#srv/web/owncloud/core/doc/admin/_images/users-create.png -#srv/web/owncloud/core/doc/admin/_images/users-groups.png -#srv/web/owncloud/core/doc/admin/_images/win7features.jpg -#srv/web/owncloud/core/doc/admin/_images/winserverroles.jpg -#srv/web/owncloud/core/doc/admin/_sources -#srv/web/owncloud/core/doc/admin/_sources/configuration -#srv/web/owncloud/core/doc/admin/_sources/configuration/auth_ldap.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/background_jobs.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration-antivirus.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_3rdparty.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_apps.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_assets.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_automation.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_config_sample_php.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_custom_clients.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_database.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_encryption.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_file_sharing.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_files_locking.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_knowledgebase.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_language.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_logging.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_mail.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_preview.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_reverseproxy.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuration_users.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuring_big_file_upload.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuring_documents.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/configuring_search.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/custom_mount_config.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/custom_mount_config_gui.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/custom_user_backend.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/index.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/server_to_server_managing.txt -#srv/web/owncloud/core/doc/admin/_sources/configuration/xsendfile.txt -#srv/web/owncloud/core/doc/admin/_sources/contents.txt -#srv/web/owncloud/core/doc/admin/_sources/index.txt -#srv/web/owncloud/core/doc/admin/_sources/installation -#srv/web/owncloud/core/doc/admin/_sources/installation/configuration_hiawatha.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/configuration_lighttpd.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/configuration_nginx.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/configuration_yaws.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/index.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/installation_appliance.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/installation_linux.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/installation_macos.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/installation_others.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/installation_source.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/installation_ucs.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/installation_windows.txt -#srv/web/owncloud/core/doc/admin/_sources/installation/installation_wizard.txt -#srv/web/owncloud/core/doc/admin/_sources/issues -#srv/web/owncloud/core/doc/admin/_sources/issues/index.txt -#srv/web/owncloud/core/doc/admin/_sources/maintenance -#srv/web/owncloud/core/doc/admin/_sources/maintenance/backup.txt -#srv/web/owncloud/core/doc/admin/_sources/maintenance/convert_db.txt -#srv/web/owncloud/core/doc/admin/_sources/maintenance/enable_maintenance.txt -#srv/web/owncloud/core/doc/admin/_sources/maintenance/index.txt -#srv/web/owncloud/core/doc/admin/_sources/maintenance/migrating.txt -#srv/web/owncloud/core/doc/admin/_sources/maintenance/restore.txt -#srv/web/owncloud/core/doc/admin/_sources/maintenance/update.txt -#srv/web/owncloud/core/doc/admin/_sources/maintenance/upgrade.txt -#srv/web/owncloud/core/doc/admin/_sources/whats_new_admin.txt -#srv/web/owncloud/core/doc/admin/_static -#srv/web/owncloud/core/doc/admin/_static/ajax-loader.gif -#srv/web/owncloud/core/doc/admin/_static/basic.css -#srv/web/owncloud/core/doc/admin/_static/bootstrap-responsive.css -#srv/web/owncloud/core/doc/admin/_static/bootstrap-sphinx.css -#srv/web/owncloud/core/doc/admin/_static/bootstrap.css -#srv/web/owncloud/core/doc/admin/_static/bootstrap.js -#srv/web/owncloud/core/doc/admin/_static/comment-bright.png -#srv/web/owncloud/core/doc/admin/_static/comment-close.png -#srv/web/owncloud/core/doc/admin/_static/comment.png -#srv/web/owncloud/core/doc/admin/_static/doctools.js -#srv/web/owncloud/core/doc/admin/_static/down-pressed.png -#srv/web/owncloud/core/doc/admin/_static/down.png -#srv/web/owncloud/core/doc/admin/_static/file.png -#srv/web/owncloud/core/doc/admin/_static/img -#srv/web/owncloud/core/doc/admin/_static/img/glyphicons-halflings-white.png -#srv/web/owncloud/core/doc/admin/_static/img/glyphicons-halflings.png -#srv/web/owncloud/core/doc/admin/_static/img/note.svg -#srv/web/owncloud/core/doc/admin/_static/img/todo.svg -#srv/web/owncloud/core/doc/admin/_static/jquery.js -#srv/web/owncloud/core/doc/admin/_static/logo-blue.pdf -#srv/web/owncloud/core/doc/admin/_static/logo-blue.png -#srv/web/owncloud/core/doc/admin/_static/minus.png -#srv/web/owncloud/core/doc/admin/_static/plus.png -#srv/web/owncloud/core/doc/admin/_static/pygments.css -#srv/web/owncloud/core/doc/admin/_static/searchtools.js -#srv/web/owncloud/core/doc/admin/_static/style.css -#srv/web/owncloud/core/doc/admin/_static/underscore.js -#srv/web/owncloud/core/doc/admin/_static/up-pressed.png -#srv/web/owncloud/core/doc/admin/_static/up.png -#srv/web/owncloud/core/doc/admin/_static/websupport.js -#srv/web/owncloud/core/doc/admin/configuration -#srv/web/owncloud/core/doc/admin/configuration/auth_ldap.html -#srv/web/owncloud/core/doc/admin/configuration/background_jobs.html -#srv/web/owncloud/core/doc/admin/configuration/configuration-antivirus.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_3rdparty.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_apps.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_assets.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_automation.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_config_sample_php.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_custom_clients.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_database.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_encryption.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_file_sharing.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_files_locking.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_knowledgebase.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_language.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_logging.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_mail.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_preview.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_reverseproxy.html -#srv/web/owncloud/core/doc/admin/configuration/configuration_users.html -#srv/web/owncloud/core/doc/admin/configuration/configuring_big_file_upload.html -#srv/web/owncloud/core/doc/admin/configuration/configuring_documents.html -#srv/web/owncloud/core/doc/admin/configuration/configuring_search.html -#srv/web/owncloud/core/doc/admin/configuration/custom_mount_config.html -#srv/web/owncloud/core/doc/admin/configuration/custom_mount_config_gui.html -#srv/web/owncloud/core/doc/admin/configuration/custom_user_backend.html -#srv/web/owncloud/core/doc/admin/configuration/index.html -#srv/web/owncloud/core/doc/admin/configuration/server_to_server_managing.html -#srv/web/owncloud/core/doc/admin/configuration/xsendfile.html -#srv/web/owncloud/core/doc/admin/contents.html -#srv/web/owncloud/core/doc/admin/genindex.html #srv/web/owncloud/core/doc/admin/index.html -#srv/web/owncloud/core/doc/admin/installation -#srv/web/owncloud/core/doc/admin/installation/configuration_hiawatha.html -#srv/web/owncloud/core/doc/admin/installation/configuration_lighttpd.html -#srv/web/owncloud/core/doc/admin/installation/configuration_nginx.html -#srv/web/owncloud/core/doc/admin/installation/configuration_yaws.html -#srv/web/owncloud/core/doc/admin/installation/index.html -#srv/web/owncloud/core/doc/admin/installation/installation_appliance.html -#srv/web/owncloud/core/doc/admin/installation/installation_linux.html -#srv/web/owncloud/core/doc/admin/installation/installation_macos.html -#srv/web/owncloud/core/doc/admin/installation/installation_others.html -#srv/web/owncloud/core/doc/admin/installation/installation_source.html -#srv/web/owncloud/core/doc/admin/installation/installation_ucs.html -#srv/web/owncloud/core/doc/admin/installation/installation_windows.html -#srv/web/owncloud/core/doc/admin/installation/installation_wizard.html -#srv/web/owncloud/core/doc/admin/issues -#srv/web/owncloud/core/doc/admin/issues/index.html -#srv/web/owncloud/core/doc/admin/maintenance -#srv/web/owncloud/core/doc/admin/maintenance/backup.html -#srv/web/owncloud/core/doc/admin/maintenance/convert_db.html -#srv/web/owncloud/core/doc/admin/maintenance/enable_maintenance.html -#srv/web/owncloud/core/doc/admin/maintenance/index.html -#srv/web/owncloud/core/doc/admin/maintenance/migrating.html -#srv/web/owncloud/core/doc/admin/maintenance/restore.html -#srv/web/owncloud/core/doc/admin/maintenance/update.html -#srv/web/owncloud/core/doc/admin/maintenance/upgrade.html -#srv/web/owncloud/core/doc/admin/objects.inv -#srv/web/owncloud/core/doc/admin/search.html -#srv/web/owncloud/core/doc/admin/searchindex.js -#srv/web/owncloud/core/doc/admin/whats_new_admin.html +#srv/web/owncloud/core/doc/admin/release +#srv/web/owncloud/core/doc/admin/release/.buildinfo +#srv/web/owncloud/core/doc/admin/release/_images +#srv/web/owncloud/core/doc/admin/release/_images/antivirus-app.png +#srv/web/owncloud/core/doc/admin/release/_images/antivirus-config.png +#srv/web/owncloud/core/doc/admin/release/_images/antivirus-daemon-socket.png +#srv/web/owncloud/core/doc/admin/release/_images/antivirus-executable.png +#srv/web/owncloud/core/doc/admin/release/_images/antivirus-logging.png +#srv/web/owncloud/core/doc/admin/release/_images/create_public_share.png +#srv/web/owncloud/core/doc/admin/release/_images/documents_app_enable.png +#srv/web/owncloud/core/doc/admin/release/_images/documents_apply_test.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption1.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption2.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption3.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption4.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption5.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption6.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption7.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption8.png +#srv/web/owncloud/core/doc/admin/release/_images/encryption9.png +#srv/web/owncloud/core/doc/admin/release/_images/external-sites-1.png +#srv/web/owncloud/core/doc/admin/release/_images/external-sites-2.png +#srv/web/owncloud/core/doc/admin/release/_images/external-sites-3.png +#srv/web/owncloud/core/doc/admin/release/_images/external-sites-4.png +#srv/web/owncloud/core/doc/admin/release/_images/external-sites-5.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-amazons3.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-app-add.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-app-enable.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-app-local.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-app-usermounts.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-dropbox-allowshare.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-dropbox-app.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-dropbox-configapp.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-dropbox-oc.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-dropbox.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-ftp.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive-0auth.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive-9.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive-sdk.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive1.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive2.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive5.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive7.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-google-drive8.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-smb.png +#srv/web/owncloud/core/doc/admin/release/_images/external-storage-webdav.png +#srv/web/owncloud/core/doc/admin/release/_images/install-wizard-advanced.png +#srv/web/owncloud/core/doc/admin/release/_images/install-wizard.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-advanced-1-connection.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-advanced-2-directory.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-advanced-3-attributes.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-expert.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-fetched-avatar.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-settings-invalid-oc45.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-settings-valid-oc45.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-wizard-1-server.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-wizard-2-user.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-wizard-3-login.png +#srv/web/owncloud/core/doc/admin/release/_images/ldap-wizard-4-group.png +#srv/web/owncloud/core/doc/admin/release/_images/lucene-search-enable.png +#srv/web/owncloud/core/doc/admin/release/_images/lucene-search-user.png +#srv/web/owncloud/core/doc/admin/release/_images/oc-video-1.png +#srv/web/owncloud/core/doc/admin/release/_images/oc-video-2.png +#srv/web/owncloud/core/doc/admin/release/_images/oc_admin_app_page.png +#srv/web/owncloud/core/doc/admin/release/_images/preview_images.png +#srv/web/owncloud/core/doc/admin/release/_images/remote_shares.png +#srv/web/owncloud/core/doc/admin/release/_images/sharing-admin.png +#srv/web/owncloud/core/doc/admin/release/_images/sharing-user-local.png +#srv/web/owncloud/core/doc/admin/release/_images/sharing-user.png +#srv/web/owncloud/core/doc/admin/release/_images/smtp-config-php-sendmail.png +#srv/web/owncloud/core/doc/admin/release/_images/smtp-config-smtp.png +#srv/web/owncloud/core/doc/admin/release/_images/smtp-config-wizard.png +#srv/web/owncloud/core/doc/admin/release/_images/ucs-app-center-install.png +#srv/web/owncloud/core/doc/admin/release/_images/ucs-app-center-module.png +#srv/web/owncloud/core/doc/admin/release/_images/ucsint.png +#srv/web/owncloud/core/doc/admin/release/_images/ucsint1.png +#srv/web/owncloud/core/doc/admin/release/_images/ucsint2.png +#srv/web/owncloud/core/doc/admin/release/_images/untrusted-domain.png +#srv/web/owncloud/core/doc/admin/release/_images/updater-1.png +#srv/web/owncloud/core/doc/admin/release/_images/updater-2.png +#srv/web/owncloud/core/doc/admin/release/_images/updater-3.png +#srv/web/owncloud/core/doc/admin/release/_images/updater-4.png +#srv/web/owncloud/core/doc/admin/release/_images/updater-5.png +#srv/web/owncloud/core/doc/admin/release/_images/updater-6.png +#srv/web/owncloud/core/doc/admin/release/_images/updater-7.png +#srv/web/owncloud/core/doc/admin/release/_images/users-config.png +#srv/web/owncloud/core/doc/admin/release/_images/users-create.png +#srv/web/owncloud/core/doc/admin/release/_images/users-groups.png +#srv/web/owncloud/core/doc/admin/release/_images/win7features.jpg +#srv/web/owncloud/core/doc/admin/release/_images/winserverroles.jpg +#srv/web/owncloud/core/doc/admin/release/_sources +#srv/web/owncloud/core/doc/admin/release/_sources/configuration +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/activity_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/antivirus_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/automatic_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/background_jobs_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/big_file_upload_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/collaborative_documents_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/config_sample_php_parameters.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/custom_client_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/database_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/email_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/encryption_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/external_sites.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/external_storage_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/external_storage_configuration_gui.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/file_sharing_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/files_locking_enabling.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/harden_server.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/index.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/js_css_asset_management_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/knowledgebase_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/language_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/logging_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/occ_command.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/performance_tips.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/previews_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/reset_admin_password.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/reverse_proxy_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/search_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/server_to_server_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/serving_static_files_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/thirdparty_php_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/user_auth_ftp_smb_imap.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/user_auth_ldap.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/user_auth_ldap_cleanup.txt +#srv/web/owncloud/core/doc/admin/release/_sources/configuration/user_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/contents.txt +#srv/web/owncloud/core/doc/admin/release/_sources/index.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation +#srv/web/owncloud/core/doc/admin/release/_sources/installation/appliance_installation.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/apps_management_installation.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/hiawatha_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/index.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/installation_wizard.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/lighttpd_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/linux_installation.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/macos_installation.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/nginx_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/others_installation.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/selinux_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/source_installation.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/ucs_installation.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/windows_installation.txt +#srv/web/owncloud/core/doc/admin/release/_sources/installation/yaws_configuration.txt +#srv/web/owncloud/core/doc/admin/release/_sources/issues +#srv/web/owncloud/core/doc/admin/release/_sources/issues/index.txt +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance/backup.txt +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance/convert_db.txt +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance/enable_maintenance.txt +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance/index.txt +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance/migrating.txt +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance/restore.txt +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance/update.txt +#srv/web/owncloud/core/doc/admin/release/_sources/maintenance/upgrade.txt +#srv/web/owncloud/core/doc/admin/release/_sources/release_notes.txt +#srv/web/owncloud/core/doc/admin/release/_sources/videos.txt +#srv/web/owncloud/core/doc/admin/release/_sources/whats_new_admin.txt +#srv/web/owncloud/core/doc/admin/release/_static +#srv/web/owncloud/core/doc/admin/release/_static/ajax-loader.gif +#srv/web/owncloud/core/doc/admin/release/_static/basic.css +#srv/web/owncloud/core/doc/admin/release/_static/bootstrap-responsive.css +#srv/web/owncloud/core/doc/admin/release/_static/bootstrap-sphinx.css +#srv/web/owncloud/core/doc/admin/release/_static/bootstrap.css +#srv/web/owncloud/core/doc/admin/release/_static/bootstrap.js +#srv/web/owncloud/core/doc/admin/release/_static/comment-bright.png +#srv/web/owncloud/core/doc/admin/release/_static/comment-close.png +#srv/web/owncloud/core/doc/admin/release/_static/comment.png +#srv/web/owncloud/core/doc/admin/release/_static/doctools.js +#srv/web/owncloud/core/doc/admin/release/_static/down-pressed.png +#srv/web/owncloud/core/doc/admin/release/_static/down.png +#srv/web/owncloud/core/doc/admin/release/_static/file.png +#srv/web/owncloud/core/doc/admin/release/_static/img +#srv/web/owncloud/core/doc/admin/release/_static/img/glyphicons-halflings-white.png +#srv/web/owncloud/core/doc/admin/release/_static/img/glyphicons-halflings.png +#srv/web/owncloud/core/doc/admin/release/_static/img/note.svg +#srv/web/owncloud/core/doc/admin/release/_static/img/todo.svg +#srv/web/owncloud/core/doc/admin/release/_static/jquery.js +#srv/web/owncloud/core/doc/admin/release/_static/logo-blue.pdf +#srv/web/owncloud/core/doc/admin/release/_static/logo-blue.png +#srv/web/owncloud/core/doc/admin/release/_static/minus.png +#srv/web/owncloud/core/doc/admin/release/_static/plus.png +#srv/web/owncloud/core/doc/admin/release/_static/pygments.css +#srv/web/owncloud/core/doc/admin/release/_static/searchtools.js +#srv/web/owncloud/core/doc/admin/release/_static/style.css +#srv/web/owncloud/core/doc/admin/release/_static/underscore.js +#srv/web/owncloud/core/doc/admin/release/_static/up-pressed.png +#srv/web/owncloud/core/doc/admin/release/_static/up.png +#srv/web/owncloud/core/doc/admin/release/_static/websupport.js +#srv/web/owncloud/core/doc/admin/release/configuration +#srv/web/owncloud/core/doc/admin/release/configuration/activity_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/antivirus_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/automatic_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/background_jobs_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/big_file_upload_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/collaborative_documents_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/config_sample_php_parameters.html +#srv/web/owncloud/core/doc/admin/release/configuration/custom_client_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/database_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/email_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/encryption_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/external_sites.html +#srv/web/owncloud/core/doc/admin/release/configuration/external_storage_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/external_storage_configuration_gui.html +#srv/web/owncloud/core/doc/admin/release/configuration/file_sharing_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/files_locking_enabling.html +#srv/web/owncloud/core/doc/admin/release/configuration/harden_server.html +#srv/web/owncloud/core/doc/admin/release/configuration/index.html +#srv/web/owncloud/core/doc/admin/release/configuration/js_css_asset_management_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/knowledgebase_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/language_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/logging_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/occ_command.html +#srv/web/owncloud/core/doc/admin/release/configuration/performance_tips.html +#srv/web/owncloud/core/doc/admin/release/configuration/previews_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/reset_admin_password.html +#srv/web/owncloud/core/doc/admin/release/configuration/reverse_proxy_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/search_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/server_to_server_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/serving_static_files_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/thirdparty_php_configuration.html +#srv/web/owncloud/core/doc/admin/release/configuration/user_auth_ftp_smb_imap.html +#srv/web/owncloud/core/doc/admin/release/configuration/user_auth_ldap.html +#srv/web/owncloud/core/doc/admin/release/configuration/user_auth_ldap_cleanup.html +#srv/web/owncloud/core/doc/admin/release/configuration/user_configuration.html +#srv/web/owncloud/core/doc/admin/release/contents.html +#srv/web/owncloud/core/doc/admin/release/genindex.html +#srv/web/owncloud/core/doc/admin/release/index.html +#srv/web/owncloud/core/doc/admin/release/installation +#srv/web/owncloud/core/doc/admin/release/installation/appliance_installation.html +#srv/web/owncloud/core/doc/admin/release/installation/apps_management_installation.html +#srv/web/owncloud/core/doc/admin/release/installation/hiawatha_configuration.html +#srv/web/owncloud/core/doc/admin/release/installation/index.html +#srv/web/owncloud/core/doc/admin/release/installation/installation_wizard.html +#srv/web/owncloud/core/doc/admin/release/installation/lighttpd_configuration.html +#srv/web/owncloud/core/doc/admin/release/installation/linux_installation.html +#srv/web/owncloud/core/doc/admin/release/installation/macos_installation.html +#srv/web/owncloud/core/doc/admin/release/installation/nginx_configuration.html +#srv/web/owncloud/core/doc/admin/release/installation/others_installation.html +#srv/web/owncloud/core/doc/admin/release/installation/selinux_configuration.html +#srv/web/owncloud/core/doc/admin/release/installation/source_installation.html +#srv/web/owncloud/core/doc/admin/release/installation/ucs_installation.html +#srv/web/owncloud/core/doc/admin/release/installation/windows_installation.html +#srv/web/owncloud/core/doc/admin/release/installation/yaws_configuration.html +#srv/web/owncloud/core/doc/admin/release/issues +#srv/web/owncloud/core/doc/admin/release/issues/index.html +#srv/web/owncloud/core/doc/admin/release/maintenance +#srv/web/owncloud/core/doc/admin/release/maintenance/backup.html +#srv/web/owncloud/core/doc/admin/release/maintenance/convert_db.html +#srv/web/owncloud/core/doc/admin/release/maintenance/enable_maintenance.html +#srv/web/owncloud/core/doc/admin/release/maintenance/index.html +#srv/web/owncloud/core/doc/admin/release/maintenance/migrating.html +#srv/web/owncloud/core/doc/admin/release/maintenance/restore.html +#srv/web/owncloud/core/doc/admin/release/maintenance/update.html +#srv/web/owncloud/core/doc/admin/release/maintenance/upgrade.html +#srv/web/owncloud/core/doc/admin/release/objects.inv +#srv/web/owncloud/core/doc/admin/release/release_notes.html +#srv/web/owncloud/core/doc/admin/release/search.html +#srv/web/owncloud/core/doc/admin/release/searchindex.js +#srv/web/owncloud/core/doc/admin/release/videos.html +#srv/web/owncloud/core/doc/admin/release/whats_new_admin.html #srv/web/owncloud/core/doc/user #srv/web/owncloud/core/doc/user/_images #srv/web/owncloud/core/doc/user/_images/bookmark_addurl.png #srv/web/owncloud/core/doc/user/_images/bookmark_setting.png +#srv/web/owncloud/core/doc/user/_images/calendar_caldav_icon.png +#srv/web/owncloud/core/doc/user/_images/calendar_caldav_ios.png +#srv/web/owncloud/core/doc/user/_images/calendar_caldav_link.png #srv/web/owncloud/core/doc/user/_images/calendar_create_event.png #srv/web/owncloud/core/doc/user/_images/calendar_create_event_repeat.png #srv/web/owncloud/core/doc/user/_images/calendar_create_event_share.png @@ -9431,9 +9371,7 @@ srv/web/owncloud #srv/web/owncloud/core/doc/user/_images/contact_vcfpick.jpg #srv/web/owncloud/core/doc/user/_images/contacts_empty.png #srv/web/owncloud/core/doc/user/_images/contacts_settings.png -#srv/web/owncloud/core/doc/user/_images/deleted_files.png #srv/web/owncloud/core/doc/user/_images/documents_personal_settings.png -#srv/web/owncloud/core/doc/user/_images/dolphin_webdav.png #srv/web/owncloud/core/doc/user/_images/download.png #srv/web/owncloud/core/doc/user/_images/email_address_personal_settings.png #srv/web/owncloud/core/doc/user/_images/encryption1.png @@ -9444,7 +9382,7 @@ srv/web/owncloud #srv/web/owncloud/core/doc/user/_images/explorer_webdav.png #srv/web/owncloud/core/doc/user/_images/files_versioning.png #srv/web/owncloud/core/doc/user/_images/full_name.png -#srv/web/owncloud/core/doc/user/_images/gnome3_nautilus_webdav.png +#srv/web/owncloud/core/doc/user/_images/gear.png #srv/web/owncloud/core/doc/user/_images/kdes.png #srv/web/owncloud/core/doc/user/_images/kdes1.png #srv/web/owncloud/core/doc/user/_images/kdes2.png @@ -9484,6 +9422,10 @@ srv/web/owncloud #srv/web/owncloud/core/doc/user/_images/users-share-local.png #srv/web/owncloud/core/doc/user/_images/users-share-local2.png #srv/web/owncloud/core/doc/user/_images/users-share-public.png +#srv/web/owncloud/core/doc/user/_images/users-share-public2.jpg +#srv/web/owncloud/core/doc/user/_images/users-share-public3.jpg +#srv/web/owncloud/core/doc/user/_images/webdav_dolphin.png +#srv/web/owncloud/core/doc/user/_images/webdav_gnome3_nautilus.png #srv/web/owncloud/core/doc/user/_sources #srv/web/owncloud/core/doc/user/_sources/bookmarks.txt #srv/web/owncloud/core/doc/user/_sources/contents.txt @@ -9502,7 +9444,6 @@ srv/web/owncloud #srv/web/owncloud/core/doc/user/_sources/files/sync.txt #srv/web/owncloud/core/doc/user/_sources/files/versioncontrol.txt #srv/web/owncloud/core/doc/user/_sources/index.txt -#srv/web/owncloud/core/doc/user/_sources/installing_apps.txt #srv/web/owncloud/core/doc/user/_sources/pim #srv/web/owncloud/core/doc/user/_sources/pim/calendar.txt #srv/web/owncloud/core/doc/user/_sources/pim/contacts.txt @@ -9564,7 +9505,6 @@ srv/web/owncloud #srv/web/owncloud/core/doc/user/files/versioncontrol.html #srv/web/owncloud/core/doc/user/genindex.html #srv/web/owncloud/core/doc/user/index.html -#srv/web/owncloud/core/doc/user/installing_apps.html #srv/web/owncloud/core/doc/user/objects.inv #srv/web/owncloud/core/doc/user/pim #srv/web/owncloud/core/doc/user/pim/calendar.html @@ -9840,7 +9780,6 @@ srv/web/owncloud #srv/web/owncloud/core/js/placeholders.js #srv/web/owncloud/core/js/select2 #srv/web/owncloud/core/js/select2/LICENSE -#srv/web/owncloud/core/js/select2/README.md #srv/web/owncloud/core/js/select2/bower.json #srv/web/owncloud/core/js/select2/component.json #srv/web/owncloud/core/js/select2/composer.json @@ -10083,6 +10022,8 @@ srv/web/owncloud #srv/web/owncloud/core/templates/untrustedDomain.php #srv/web/owncloud/core/templates/update.admin.php #srv/web/owncloud/core/templates/update.user.php +#srv/web/owncloud/core/user +#srv/web/owncloud/core/user/controller.php #srv/web/owncloud/cron.php #srv/web/owncloud/data #srv/web/owncloud/db_structure.xml @@ -11650,7 +11591,6 @@ srv/web/owncloud #srv/web/owncloud/lib/l10n/tzm.php #srv/web/owncloud/lib/l10n/ug.php #srv/web/owncloud/lib/l10n/uk.php -#srv/web/owncloud/lib/l10n/ur.php #srv/web/owncloud/lib/l10n/ur_PK.php #srv/web/owncloud/lib/l10n/uz.php #srv/web/owncloud/lib/l10n/vi.php @@ -11897,7 +11837,7 @@ srv/web/owncloud #srv/web/owncloud/lib/private/preview #srv/web/owncloud/lib/private/preview.php #srv/web/owncloud/lib/private/preview/image.php -#srv/web/owncloud/lib/private/preview/movies.php +#srv/web/owncloud/lib/private/preview/movie.php #srv/web/owncloud/lib/private/preview/mp3.php #srv/web/owncloud/lib/private/preview/office-cl.php #srv/web/owncloud/lib/private/preview/office.php @@ -11923,7 +11863,11 @@ srv/web/owncloud #srv/web/owncloud/lib/private/search/result/file.php #srv/web/owncloud/lib/private/search/result/folder.php #srv/web/owncloud/lib/private/search/result/image.php +#srv/web/owncloud/lib/private/security +#srv/web/owncloud/lib/private/security/crypto.php +#srv/web/owncloud/lib/private/security/stringutils.php #srv/web/owncloud/lib/private/server.php +#srv/web/owncloud/lib/private/servernotavailableexception.php #srv/web/owncloud/lib/private/serviceunavailableexception.php #srv/web/owncloud/lib/private/session #srv/web/owncloud/lib/private/session/internal.php @@ -11956,6 +11900,7 @@ srv/web/owncloud #srv/web/owncloud/lib/private/template/resourcelocator.php #srv/web/owncloud/lib/private/template/templatefilelocator.php #srv/web/owncloud/lib/private/templatelayout.php +#srv/web/owncloud/lib/private/tempmanager.php #srv/web/owncloud/lib/private/updater.php #srv/web/owncloud/lib/private/urlgenerator.php #srv/web/owncloud/lib/private/user @@ -11967,6 +11912,7 @@ srv/web/owncloud #srv/web/owncloud/lib/private/user/http.php #srv/web/owncloud/lib/private/user/interface.php #srv/web/owncloud/lib/private/user/manager.php +#srv/web/owncloud/lib/private/user/nouserexception.php #srv/web/owncloud/lib/private/user/session.php #srv/web/owncloud/lib/private/user/user.php #srv/web/owncloud/lib/private/util.php @@ -12057,6 +12003,7 @@ srv/web/owncloud #srv/web/owncloud/lib/public/isession.php #srv/web/owncloud/lib/public/itagmanager.php #srv/web/owncloud/lib/public/itags.php +#srv/web/owncloud/lib/public/itempmanager.php #srv/web/owncloud/lib/public/iurlgenerator.php #srv/web/owncloud/lib/public/iuser.php #srv/web/owncloud/lib/public/iusermanager.php @@ -12069,6 +12016,9 @@ srv/web/owncloud #srv/web/owncloud/lib/public/search #srv/web/owncloud/lib/public/search/provider.php #srv/web/owncloud/lib/public/search/result.php +#srv/web/owncloud/lib/public/security +#srv/web/owncloud/lib/public/security/icrypto.php +#srv/web/owncloud/lib/public/security/stringutils.php #srv/web/owncloud/lib/public/share.php #srv/web/owncloud/lib/public/template.php #srv/web/owncloud/lib/public/user.php @@ -12078,6 +12028,7 @@ srv/web/owncloud #srv/web/owncloud/lib/repair/collation.php #srv/web/owncloud/lib/repair/innodb.php #srv/web/owncloud/lib/repair/preview.php +#srv/web/owncloud/lib/repair/repairconfig.php #srv/web/owncloud/lib/repair/repairmimetypes.php #srv/web/owncloud/lib/repair/searchlucenetables.php #srv/web/owncloud/occ diff --git a/config/udev/60-net.rules b/config/udev/60-net.rules index dc39ff0..e82320c 100644 --- a/config/udev/60-net.rules +++ b/config/udev/60-net.rules @@ -4,4 +4,4 @@ ACTION=="add", SUBSYSTEM=="net", PROGRAM="/lib/udev/network-hotplug-rename", RES
# Call a script that will create all virtual devices for a parent device # that has just come up. -ACTION=="add", SUBSYSTEM=="net", PROGRAM="/lib/udev/network-hotplug-vlan" +ACTION=="add", SUBSYSTEM=="net", RUN+="/lib/udev/network-hotplug-vlan" diff --git a/config/xen-image/xen-image-maker.sh b/config/xen-image/xen-image-maker.sh index 28f005d..07414f7 100644 --- a/config/xen-image/xen-image-maker.sh +++ b/config/xen-image/xen-image-maker.sh @@ -130,6 +130,7 @@ mkdir $MNThdd/boot/grub echo "timeout 10" > $MNThdd/boot/grub/grub.conf echo "default 0" >> $MNThdd/boot/grub/grub.conf echo "title IPFire ($KERN_TYPE-kernel)" >> $MNThdd/boot/grub/grub.conf +echo " root (hd0) >> $MNThdd/boot/grub/grub.conf echo " kernel /vmlinuz-$KVER-ipfire-$KERN_TYPE root=/dev/$P3 rootdelay=10 panic=10 console=$CONSOLE" \ >> $MNThdd/boot/grub/grub.conf echo " initrd /initramfs-$KVER-ipfire-$KERN_TYPE.img" >> $MNThdd/boot/grub/grub.conf diff --git a/doc/language_issues.de b/doc/language_issues.de index 3660356..421c40e 100644 --- a/doc/language_issues.de +++ b/doc/language_issues.de @@ -34,13 +34,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update notification WARNING: translation string unused: again diff --git a/doc/language_issues.en b/doc/language_issues.en index a419afa..0a1756f 100644 --- a/doc/language_issues.en +++ b/doc/language_issues.en @@ -33,13 +33,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update information WARNING: translation string unused: advproxy update notification diff --git a/doc/language_issues.es b/doc/language_issues.es index d375f69..17347f6 100644 --- a/doc/language_issues.es +++ b/doc/language_issues.es @@ -33,13 +33,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update information WARNING: translation string unused: advproxy update notification @@ -640,6 +638,7 @@ WARNING: untranslated string: advproxy group access control WARNING: untranslated string: advproxy group required WARNING: untranslated string: advproxy proxy port transparent WARNING: untranslated string: age second +WARNING: untranslated string: application layer gateways WARNING: untranslated string: atm device WARNING: untranslated string: attention WARNING: untranslated string: bit diff --git a/doc/language_issues.fr b/doc/language_issues.fr index f0f5ec4..a93453f 100644 --- a/doc/language_issues.fr +++ b/doc/language_issues.fr @@ -33,13 +33,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update information WARNING: translation string unused: advproxy update notification @@ -647,6 +645,7 @@ WARNING: untranslated string: advproxy group access control WARNING: untranslated string: advproxy group required WARNING: untranslated string: advproxy proxy port transparent WARNING: untranslated string: age second +WARNING: untranslated string: application layer gateways WARNING: untranslated string: atm device WARNING: untranslated string: attention WARNING: untranslated string: bit diff --git a/doc/language_issues.it b/doc/language_issues.it index 65643e8..776b932 100644 --- a/doc/language_issues.it +++ b/doc/language_issues.it @@ -33,13 +33,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update information WARNING: translation string unused: advproxy update notification @@ -700,6 +698,7 @@ WARNING: untranslated string: advproxy AUTH method ntlm auth WARNING: untranslated string: advproxy basic authentication WARNING: untranslated string: advproxy group access control WARNING: untranslated string: advproxy group required +WARNING: untranslated string: application layer gateways WARNING: untranslated string: bytes WARNING: untranslated string: check all WARNING: untranslated string: dhcp dns enable update diff --git a/doc/language_issues.nl b/doc/language_issues.nl index 3b57bdf..77fa1f5 100644 --- a/doc/language_issues.nl +++ b/doc/language_issues.nl @@ -33,13 +33,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update information WARNING: translation string unused: advproxy update notification @@ -697,6 +695,7 @@ WARNING: untranslated string: advproxy AUTH method ntlm auth WARNING: untranslated string: advproxy basic authentication WARNING: untranslated string: advproxy group access control WARNING: untranslated string: advproxy group required +WARNING: untranslated string: application layer gateways WARNING: untranslated string: atm device WARNING: untranslated string: bytes WARNING: untranslated string: capabilities diff --git a/doc/language_issues.pl b/doc/language_issues.pl index d375f69..17347f6 100644 --- a/doc/language_issues.pl +++ b/doc/language_issues.pl @@ -33,13 +33,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update information WARNING: translation string unused: advproxy update notification @@ -640,6 +638,7 @@ WARNING: untranslated string: advproxy group access control WARNING: untranslated string: advproxy group required WARNING: untranslated string: advproxy proxy port transparent WARNING: untranslated string: age second +WARNING: untranslated string: application layer gateways WARNING: untranslated string: atm device WARNING: untranslated string: attention WARNING: untranslated string: bit diff --git a/doc/language_issues.ru b/doc/language_issues.ru index 05d9e91..6446a74 100644 --- a/doc/language_issues.ru +++ b/doc/language_issues.ru @@ -33,13 +33,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update information WARNING: translation string unused: advproxy update notification @@ -640,6 +638,7 @@ WARNING: untranslated string: advproxy group access control WARNING: untranslated string: advproxy group required WARNING: untranslated string: advproxy proxy port transparent WARNING: untranslated string: age second +WARNING: untranslated string: application layer gateways WARNING: untranslated string: atm device WARNING: untranslated string: attention WARNING: untranslated string: bit diff --git a/doc/language_issues.tr b/doc/language_issues.tr index a419afa..5479859 100644 --- a/doc/language_issues.tr +++ b/doc/language_issues.tr @@ -33,13 +33,11 @@ WARNING: translation string unused: advproxy chgwebpwd new password WARNING: translation string unused: advproxy chgwebpwd new password confirm WARNING: translation string unused: advproxy chgwebpwd old password WARNING: translation string unused: advproxy chgwebpwd username -WARNING: translation string unused: advproxy cre disabled WARNING: translation string unused: advproxy errmsg change fail WARNING: translation string unused: advproxy errmsg change success WARNING: translation string unused: advproxy errmsg invalid user WARNING: translation string unused: advproxy errmsg no password WARNING: translation string unused: advproxy errmsg password incorrect -WARNING: translation string unused: advproxy no cre groups WARNING: translation string unused: advproxy ssadvanced proxy WARNING: translation string unused: advproxy update information WARNING: translation string unused: advproxy update notification @@ -703,6 +701,7 @@ WARNING: translation string unused: xtaccess bad transfert WARNING: translation string unused: year-graph WARNING: translation string unused: yearly firewallhits WARNING: untranslated string: Scan for Songs +WARNING: untranslated string: application layer gateways WARNING: untranslated string: bytes WARNING: untranslated string: fwhost cust geoipgrp WARNING: untranslated string: fwhost err hostip diff --git a/doc/language_missings b/doc/language_missings index c490f2d..32e1e48 100644 --- a/doc/language_missings +++ b/doc/language_missings @@ -26,6 +26,7 @@ < age shour < age sminute < age ssecond +< application layer gateways < atm device < attention < bit @@ -636,6 +637,7 @@ < age shour < age sminute < age ssecond +< application layer gateways < Async logging enabled < atm device < attention @@ -1229,6 +1231,7 @@ < age shour < age sminute < age ssecond +< application layer gateways < atm device < attention < bit @@ -1808,6 +1811,7 @@ < age shour < age sminute < age ssecond +< application layer gateways < atm device < attention < bit diff --git a/html/cgi-bin/logs.cgi/firewalllog.dat b/html/cgi-bin/logs.cgi/firewalllog.dat index 5a584d6..5c9722b 100644 --- a/html/cgi-bin/logs.cgi/firewalllog.dat +++ b/html/cgi-bin/logs.cgi/firewalllog.dat @@ -41,11 +41,11 @@ my %logsettings=(); my $errormessage = '';
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', - 'Sep', 'Oct', 'Nov', 'Dec' ); + 'Sep', 'Oct', 'Nov', 'Dec' ); my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'}, - $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'}, - $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, - $Lang::tr{'december'} ); + $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'}, + $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, + $Lang::tr{'december'} );
my @now = localtime(); my $dow = $now[6]; @@ -66,55 +66,55 @@ my $start = ($logsettings{'LOGVIEW_REVERSE'} eq 'on') ? 0x7FFFF000 : 0; #index o
if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) { - my @temp = split(',',$ENV{'QUERY_STRING'}); - $start = $temp[0]; - $cgiparams{'MONTH'} = $temp[1]; - $cgiparams{'DAY'} = $temp[2]; + my @temp = split(',',$ENV{'QUERY_STRING'}); + $start = $temp[0]; + $cgiparams{'MONTH'} = $temp[1]; + $cgiparams{'DAY'} = $temp[2]; }
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || - !($cgiparams{'DAY'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) + !($cgiparams{'DAY'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) { - $cgiparams{'DAY'} = $now[3]; - $cgiparams{'MONTH'} = $now[4]; + $cgiparams{'DAY'} = $now[3]; + $cgiparams{'MONTH'} = $now[4]; } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - if ($cgiparams{'DAY'}) { - @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day + - ## 86400 seconds in a day - } else { - $temp_now[3] = 1; - $temp_now[4] = ($temp_now[4]+1) %12; - @temp_then = localtime(POSIX::mktime(@temp_now) ); - $temp_then[3] = 0; - } - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + if ($cgiparams{'DAY'}) { + @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day + + ## 86400 seconds in a day + } else { + $temp_now[3] = 1; + $temp_now[4] = ($temp_now[4]+1) %12; + @temp_then = localtime(POSIX::mktime(@temp_now) ); + $temp_then[3] = 0; + } + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - if ($cgiparams{'DAY'}) { - @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - } else { - $temp_now[3] = 1; - $temp_now[4] = ($temp_now[4]-1) %12; - @temp_then = localtime(POSIX::mktime(@temp_now) ); - $temp_then[3] = 0; - } - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + if ($cgiparams{'DAY'}) { + @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + } else { + $temp_now[3] = 1; + $temp_now[4] = ($temp_now[4]-1) %12; + @temp_then = localtime(POSIX::mktime(@temp_now) ); + $temp_then[3] = 0; + } + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; }
# Find in which file.gz is the log. Can be calculated because WEEKLY ROTATING of access.log @@ -122,104 +122,104 @@ my $gzindex; my $date = $cgiparams{'DAY'} == 0 ? '' : $cgiparams{'DAY'} <= 9 ? "0$cgiparams{'DAY'}" : "$cgiparams{'DAY'}";
{ - my $xday; - - # Calculate time. If future date, calculate for past year !!! - if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - $xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 ); - $date = "$longmonths[$cgiparams{'MONTH'}] $date, ". int($year-1); - } else { - $xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 ); - $date = "$longmonths[$cgiparams{'MONTH'}] $date, $year"; - } - - # calculate end of active week (saturday 23H59) - my @then = (); - @then = localtime(time()); - my $sunday = POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]); - $sunday += (6-$then[6]) * 86400; - - # Convert delta in second to full weeks - $gzindex = int (($sunday-$xday)/604800 ); + my $xday; + + # Calculate time. If future date, calculate for past year !!! + if (( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + $xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 ); + $date = "$longmonths[$cgiparams{'MONTH'}] $date, ". int($year-1); + } else { + $xday = POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 ); + $date = "$longmonths[$cgiparams{'MONTH'}] $date, $year"; + } + + # calculate end of active week (saturday 23H59) + my @then = (); + @then = localtime(time()); + my $sunday = POSIX::mktime( 0, 0, 0, @then[3], @then[4], @then[5]); + $sunday += (6-$then[6]) * 86400; + + # Convert delta in second to full weeks + $gzindex = int (($sunday-$xday)/604800 ); } - + my $monthstr = $shortmonths[$cgiparams{'MONTH'}]; my $daystr = $cgiparams{'DAY'} == 0 ? '..' : $cgiparams{'DAY'} <= 9 ? " $cgiparams{'DAY'}" : "$cgiparams{'DAY'}"; - + my $lines = 0; my @log=();
my $loop = 1; my $filestr = 0; -my $lastdatetime; # for debug +my $lastdatetime; # for debug my $search_for_end = 0; - + while ($gzindex >=0 && $loop) { - # calculate file name - if ($gzindex == 0) { - $filestr = "/var/log/messages"; - } else { - $filestr = "/var/log/messages.$gzindex"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; - } - # now read file if existing - if (open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))) { - #&General::log("reading $filestr"); - READ:while (<FILE>) { - my $line = $_; - if ($line =~ /^${monthstr} ${daystr} ..:..:.. [\w-]+ kernel:.*IN=.*$/) { - # when standart viewing, just keep in memory the correct slice - # it starts a '$start' and size is $viewport - # If export, then keep all lines... - if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){ - $log[$lines++] = "$line"; - } else { - if ($lines++ < ($start + $Header::viewsize)) { - push(@log,"$line"); - if (@log > $Header::viewsize) { - shift (@log); - } - #} else { dont do this optimisation, need to count lines ! - # $datetime = $maxtime; # we have read viewsize lines, stop main loop - # last READ; # exit read file - } - } - $search_for_end = 1; # we find the start of slice, can look for end now - } else { - if ($search_for_end == 1) { - #finish read files when date is over (test month equality only) - $line =~ /^(...) (..) ..:..:..*$/; - $loop = 0 if ( ($1 ne $monthstr) || ( ($daystr ne '..') && ($daystr ne $2) ) ); - } - } - } - close (FILE); - } - $gzindex--; # will try next gz file eg 40,39,38,.... because it may have holes when ipcop stopped - # for a long time + # calculate file name + if ($gzindex == 0) { + $filestr = "/var/log/messages"; + } else { + $filestr = "/var/log/messages.$gzindex"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; + } + # now read file if existing + if (open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr))) { + #&General::log("reading $filestr"); + READ:while (<FILE>) { + my $line = $_; + if ($line =~ /^${monthstr} ${daystr} ..:..:.. [\w-]+ kernel:.*IN=.*$/) { + # when standart viewing, just keep in memory the correct slice + # it starts a '$start' and size is $viewport + # If export, then keep all lines... + if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}){ + $log[$lines++] = "$line"; + } else { + if ($lines++ < ($start + $Header::viewsize)) { + push(@log,"$line"); + if (@log > $Header::viewsize) { + shift (@log); + } + #} else { dont do this optimisation, need to count lines ! + # $datetime = $maxtime; # we have read viewsize lines, stop main loop + # last READ; # exit read file + } + } + $search_for_end = 1; # we find the start of slice, can look for end now + } else { + if ($search_for_end == 1) { + #finish read files when date is over (test month equality only) + $line =~ /^(...) (..) ..:..:..*$/; + $loop = 0 if ( ($1 ne $monthstr) || ( ($daystr ne '..') && ($daystr ne $2) ) ); + } + } + } + close (FILE); + } + $gzindex--; # will try next gz file eg 40,39,38,.... because it may have holes when ipcop stopped + # for a long time }# while
# $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}";
if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}) { - print "Content-type: text/plain\n\n"; - print "IPFire firewall log\r\n"; - print "$Lang::{'date'}: $date\r\n\r\n"; - - if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; } - - foreach $_ (@log) - { - /^... (..) (..:..:..) [\w-]+ kernel:.*(IN=.*)$/; - my $day = $1; - $day =~ tr / /0/; - my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ; - print "$time $3\r\n"; - - } - exit 0; + print "Content-type: text/plain\n\n"; + print "IPFire firewall log\r\n"; + print "$Lang::{'date'}: $date\r\n\r\n"; + + if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; } + + foreach $_ (@log) + { + /^... (..) (..:..:..) [\w-]+ kernel:.*(IN=.*)$/; + my $day = $1; + $day =~ tr / /0/; + my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ; + print "$time $3\r\n"; + + } + exit 0; }
&Header::showhttpheaders(); @@ -229,9 +229,9 @@ if ($cgiparams{'ACTION'} eq $Lang::tr{'export'}) &Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "<font class='base'>$errormessage </font>\n"; - &Header::closebox(); + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "<font class='base'>$errormessage </font>\n"; + &Header::closebox(); }
&Header::openbox('100%', 'left', "$Lang::tr{'settings'}"); @@ -240,33 +240,35 @@ print <<END <form method='post' action='$ENV{'SCRIPT_NAME'}'> <table width='100%'> <tr> - <td width='10%' class='base'>$Lang::tr{'month'}: </td> - <td width='10%'> - <select name='MONTH'> + <td width='10%' class='base'>$Lang::tr{'month'}: </td> + <td width='10%'> + <select name='MONTH'> END ; for (my $month = 0; $month < 12; $month++) { - print "\t<option "; - if ($month == $cgiparams{'MONTH'}) { - print "selected='selected' "; } - print "value='$month'>$longmonths[$month]</option>\n"; + print "\t<option "; + if ($month == $cgiparams{'MONTH'}) { + print "selected='selected' "; + } + print "value='$month'>$longmonths[$month]</option>\n"; } print <<END - </select> - </td> - <td width='10%' class='base' align='right'> $Lang::tr{'day'}: </td> - <td width='40%'> - <select name='DAY'> + </select> + </td> + <td width='10%' class='base' align='right'> $Lang::tr{'day'}: </td> + <td width='40%'> + <select name='DAY'> END ; print "<option value='0'>$Lang::tr{'all'}</option>\n"; for (my $day = 1; $day <= 31; $day++) { - print "\t<option "; - if ($day == $cgiparams{'DAY'}) { - print "selected='selected' "; } - print "value='$day'>$day</option>\n"; + print "\t<option "; + if ($day == $cgiparams{'DAY'}) { + print "selected='selected' "; + } + print "value='$day'>$day</option>\n"; } print <<END </select> @@ -291,20 +293,20 @@ $start = $lastPageIndex if ($start >= $lastPageIndex); $start = 0 if ($start < 0);
my $prev; - if ($start == 0) { - $prev = -1; - } else { - $prev = $start - ${Header::viewsize}; - $prev = 0 if ( $prev < 0); - } - +if ($start == 0) { + $prev = -1; +} else { + $prev = $start - ${Header::viewsize}; + $prev = 0 if ( $prev < 0); +} + my $next; - if ($start == $lastPageIndex) { - $next = -1; - } else { - $next = $start + ${Header::viewsize}; - $next = $lines - ${Header::viewsize} if ($next >= $lines - ${Header::viewsize}); - } +if ($start == $lastPageIndex) { + $next = -1; +} else { + $next = $start + ${Header::viewsize}; + $next = $lines - ${Header::viewsize} if ($next >= $lines - ${Header::viewsize}); +}
if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @log = reverse @log; } if ($lines != 0) { &oldernewer(); } @@ -312,14 +314,14 @@ if ($lines != 0) { &oldernewer(); } print <<END <table width='100%' class='tbl'> <tr> - <th align='center' class='boldbase'><b>$Lang::tr{'time'}</b></th> - <th align='center' class='boldbase'><b>$Lang::tr{'chain'}</b></th> - <th align='center' class='boldbase'><b>$Lang::tr{'iface'}</b></th> - <th align='center' class='boldbase'><b>$Lang::tr{'proto'}</b></th> - <th align='center' class='boldbase'><b>$Lang::tr{'source'}<br/>$Lang::tr{'destination'}</b></th> - <th align='center' class='boldbase'><b>$Lang::tr{'src port'}<br />$Lang::tr{'dst port'}</b></th> - <th align='center' class='boldbase'><b>$Lang::tr{'country'}</b></th> - <th align='center' class='boldbase'><b>$Lang::tr{'mac address'}</b></th> + <th align='center' class='boldbase'><b>$Lang::tr{'time'}</b></th> + <th align='center' class='boldbase'><b>$Lang::tr{'chain'}</b></th> + <th align='center' class='boldbase'><b>$Lang::tr{'iface'}</b></th> + <th align='center' class='boldbase'><b>$Lang::tr{'proto'}</b></th> + <th align='center' class='boldbase'><b>$Lang::tr{'source'}<br/>$Lang::tr{'destination'}</b></th> + <th align='center' class='boldbase'><b>$Lang::tr{'src port'}<br />$Lang::tr{'dst port'}</b></th> + <th align='center' class='boldbase'><b>$Lang::tr{'country'}</b></th> + <th align='center' class='boldbase'><b>$Lang::tr{'mac address'}</b></th> </tr> END ; @@ -328,66 +330,76 @@ END $lines = 0; foreach $_ (@log) { - /^... (..) (..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/; - my $day = $1; - $day =~ tr / /0/; - my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ; - my $comment = $3; - my $packet = $4; - - my ($iface, $srcaddr, $dstaddr, $macaddr, $proto, $srcport, $dstport); - $iface=$1 if $packet =~ /IN=(\w+)/; - $srcaddr=$1 if $packet =~ /SRC=([\d.]+)/; - $dstaddr=$1 if $packet =~ /DST=([\d.]+)/; - $macaddr=$1 if $packet =~ /MAC=([\w+:]+)/; - $proto=$1 if $packet =~ /PROTO=(\w+)/; - $srcport=$1 if $packet =~ /SPT=(\d+)/; - $dstport=$1 if $packet =~ /DPT=(\d+)/; - - my $gi = Geo::IP::PurePerl->new(); - my $ccode = $gi->country_code_by_name($srcaddr); - my $fcode = lc($ccode); - - my $servi = uc(getservbyport($srcport, lc($proto))); - if ($servi ne '' && $srcport < 1024) { - $srcport = "$srcport($servi)"; } - $servi = uc(getservbyport($dstport, lc($proto))); - if ($servi ne '' && $dstport < 1024) { - $dstport = "$dstport($servi)";} - my @mactemp = split(/:/,$macaddr); - $macaddr = "$mactemp[6]:$mactemp[7]:$mactemp[8]:$mactemp[9]:$mactemp[10]:$mactemp[11]"; - my $col=""; - if ($lines % 2) { - print "<tr>"; - $col="bgcolor='$color{'color20'}'"; } - else { - print "<tr>"; - $col="bgcolor='$color{'color22'}'"; } - print <<END - - <td align='center' $col>$time</td> - <td align='center' $col>$comment</td> - <td align='center' $col>$iface</td> - <td align='center' $col>$proto</td> - <td align='center' $col><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a><br /><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td> - <td align='center' $col>$srcport<br/>$dstport</td> + # If ipv6 uses a bridge, PHYSIN= contains the relevant iface information + # otherwise use IN= + my $packet = ''; + if ($_ =~ /^... (..) (..:..:..) [\w-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) { $packet = $5; } + elsif ($_ =~ /^... (..) (..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/) { $packet = $4; } + my $day = $1; + $day =~ tr / /0/; + my $time = $cgiparams{'DAY'} ? "$2" : "$day/$2" ; + my $chain = $3; + + my ($iface, $srcaddr, $dstaddr, $macaddr, $proto, $srcport, $dstport); + if ($packet =~ /PHYSIN=(\w+)/) { $iface=$1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; } + # Identify whether ipv4 or ipv6. Both are mutally exclusive. + if ($packet =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) { $srcaddr=$1; } + if ($packet =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/) { $srcaddr=$1; } + if ($packet =~ /DST=(([\d]{1,3})(.([\d]{1,3})){3})/) { $dstaddr=$1; } + if ($packet =~ /DST=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/) { $dstaddr=$1; } + $macaddr=$1 if $packet =~ /MAC=([\w+:]+)/; + $proto=$1 if $packet =~ /PROTO=(\w+)/; + $srcport=$1 if $packet =~ /SPT=(\d+)/; + $dstport=$1 if $packet =~ /DPT=(\d+)/; + + my $gi = Geo::IP::PurePerl->new(); + my $ccode = $gi->country_code_by_name($srcaddr); + my $fcode = lc($ccode); + + my $servi = uc(getservbyport($srcport, lc($proto))); + if ($servi ne '' && $srcport < 1024) { + $srcport = "$srcport($servi)"; + } + $servi = uc(getservbyport($dstport, lc($proto))); + if ($servi ne '' && $dstport < 1024) { + $dstport = "$dstport($servi)"; + } + my @mactemp = split(/:/,$macaddr); + $macaddr = "$mactemp[6]:$mactemp[7]:$mactemp[8]:$mactemp[9]:$mactemp[10]:$mactemp[11]"; + my $col=""; + if ($lines % 2) { + print "<tr>"; + $col="bgcolor='$color{'color20'}'"; + } + else { + print "<tr>"; + $col="bgcolor='$color{'color22'}'"; + } + print <<END + + <td align='center' $col>$time</td> + <td align='center' $col>$chain</td> + <td align='center' $col>$iface</td> + <td align='center' $col>$proto</td> + <td align='center' $col><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a><br /><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td> + <td align='center' $col>$srcport<br/>$dstport</td> END -; + ; # Get flag icon for of the country. my $flag_icon = &GeoIP::get_flag_icon($fcode);
- if ( $flag_icon) { + if ( $flag_icon) { print "<td align='center' $col><a href='../country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode'></a></td>"; } else { print "<td align='center' $col></td>"; }
- print <<END - <td align='center' $col>$macaddr</td> -</tr> + print <<END + <td align='center' $col>$macaddr</td> + </tr> END - ; - $lines++; + ; + $lines++; }
print "</table>"; @@ -402,32 +414,36 @@ print "</table>";
sub oldernewer { -print <<END -<table width='100%'> -<tr> + print <<END + <table width='100%'> + <tr> END -; + ;
-print "<td align='center' width='50%'>"; -if ($prev != -1) { - print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?0,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'first'}</a> "; - print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'older'}</a>"; } -else { - print "$Lang::tr{'first'} $Lang::tr{'older'}"; } -print "</td>\n"; - -print "<td align='center' width='50%'>"; -if ($next >= 0) { - print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'newer'}</a> "; - print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$lastPageIndex,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'last'}</a>"; } -else { - print "$Lang::tr{'newer'} $Lang::tr{'last'} "; } -print "</td>\n"; + print "<td align='center' width='50%'>"; + if ($prev != -1) { + print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?0,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'first'}</a> "; + print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'older'}</a>"; + } + else { + print "$Lang::tr{'first'} $Lang::tr{'older'}"; + } + print "</td>\n";
-print <<END -</tr> -</table> + print "<td align='center' width='50%'>"; + if ($next >= 0) { + print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'newer'}</a> "; + print "<a href='/cgi-bin/logs.cgi/firewalllog.dat?$lastPageIndex,$cgiparams{'MONTH'},$cgiparams{'DAY'}'>$Lang::tr{'last'}</a>"; + } + else { + print "$Lang::tr{'newer'} $Lang::tr{'last'} "; + } + print "</td>\n"; + + print <<END + </tr> + </table> END -; + ; }
diff --git a/html/cgi-bin/logs.cgi/firewalllogcountry.dat b/html/cgi-bin/logs.cgi/firewalllogcountry.dat index f998a62..26920b5 100644 --- a/html/cgi-bin/logs.cgi/firewalllogcountry.dat +++ b/html/cgi-bin/logs.cgi/firewalllogcountry.dat @@ -8,7 +8,7 @@ # page inspired from the initial firewalllog.dat # # Modified for IPFire by Christian Schmidt -# and Michael Tremer (www.ipfire.org) +# and Michael Tremer (www.ipfire.org)
use strict; use Geo::IP::PurePerl; @@ -39,11 +39,11 @@ $cgiparams{'showpie'} = 1; $cgiparams{'sortcolumn'} = 1;
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', - 'Sep', 'Oct', 'Nov', 'Dec' ); + 'Sep', 'Oct', 'Nov', 'Dec' ); my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'}, - $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'}, - $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, - $Lang::tr{'december'} ); + $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'}, + $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, + $Lang::tr{'december'} );
my @now = localtime(); my $dow = $now[6]; @@ -69,81 +69,81 @@ if ($cgiparams{'sortcolumn'} != 0) { $settings{'sortcolumn'} = $cgiparams{'sortc
if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) { - &General::writehash("${General::swroot}/fwlogs/ipsettings", %settings); + &General::writehash("${General::swroot}/fwlogs/ipsettings", %settings); }
my $start = -1; if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) { - my @temp = split(',',$ENV{'QUERY_STRING'}); - $start = $temp[0]; - $cgiparams{'MONTH'} = $temp[1]; - $cgiparams{'DAY'} = $temp[2]; + my @temp = split(',',$ENV{'QUERY_STRING'}); + $start = $temp[0]; + $cgiparams{'MONTH'} = $temp[1]; + $cgiparams{'DAY'} = $temp[2]; }
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || !($cgiparams{'DAY'} =~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) { - $cgiparams{'DAY'} = $now[3]; - $cgiparams{'MONTH'} = $now[4]; + $cgiparams{'DAY'} = $now[3]; + $cgiparams{'MONTH'} = $now[4]; } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; }
if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then = (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy = $then[7]; - my $lastleap=($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap == 0 && $tdoy < 60) { - $doy=$tdoy+366; - } else { - $doy=$doy+365; - } - } + my @then = (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); + } else { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); + } + $tdoy = $then[7]; + my $lastleap=($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap == 0 && $tdoy < 60) { + $doy=$tdoy+366; + } else { + $doy=$doy+365; + } + } }
my $datediff=0; my $dowd=0; my $multifile=0; if ($tdoy ne $doy) { - $datediff=int(($doy-$tdoy)/7); - $dowd=($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=$datediff+1; - } - if (($dow-$dowd)==0) { - $multifile=1; - } + $datediff=int(($doy-$tdoy)/7); + $dowd=($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=$datediff+1; + } + if (($dow-$dowd)==0) { + $multifile=1; + } }
my $monthstr = $shortmonths[$cgiparams{'MONTH'}]; @@ -151,62 +151,63 @@ my $longmonthstr = $longmonths[$cgiparams{'MONTH'}]; my $day = $cgiparams{'DAY'}; my $daystr=''; if ($day <= 9) { - $daystr = " $day"; } + $daystr = " $day"; +} else { - $daystr = $day; + $daystr = $day; }
my $skip=0; my $filestr=''; if ($datediff==0) { - $filestr="/var/log/messages"; + $filestr="/var/log/messages"; } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; }
if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - # Note: This is in case the log does not exist for that date + $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + # Note: This is in case the log does not exist for that date } my $lines = 0; my @log=();
if (!$skip) { - while (<FILE>) - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - $log[$lines] = $_; - $lines++; - } - } - close (FILE); + while (<FILE>) + { + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + $log[$lines] = $_; + $lines++; + } + } + close (FILE); }
$skip=0; if ($multifile) { - $datediff=$datediff-1; - if ($datediff==0) { - $filestr="/var/log/messages"; - } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - } - if (!$skip) { - while (<FILE>) { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - $log[$lines] = $_; - $lines++; - } - } - close (FILE); - } + $datediff=$datediff-1; + if ($datediff==0) { + $filestr="/var/log/messages"; + } else { + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { + $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + } + if (!$skip) { + while (<FILE>) { + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + $log[$lines] = $_; + $lines++; + } + } + close (FILE); + } }
my $MODNAME="fwlogs"; @@ -217,9 +218,9 @@ my $MODNAME="fwlogs";
if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "<font class='base'>$errormessage </font>\n"; - &Header::closebox(); + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "<font class='base'>$errormessage </font>\n"; + &Header::closebox(); }
&Header::openbox('100%', 'left', "$Lang::tr{'settings'}"); @@ -228,40 +229,39 @@ print <<END <form method='post' action='$ENV{'SCRIPT_NAME'}'> <table width='100%'> <tr> - <td width='10%' class='base'>$Lang::tr{'month'}: </td> - <td width='10%'> - <select name='MONTH'> + <td width='10%' class='base'>$Lang::tr{'month'}: </td> + <td width='10%'> + <select name='MONTH'> END ; my $month; for ($month = 0; $month < 12; $month++) { - print "\t<option "; - if ($month == $cgiparams{'MONTH'}) { - print "selected='selected' "; } - print "value='$month'>$longmonths[$month]</option>\n"; + print "\t<option "; + if ($month == $cgiparams{'MONTH'}) { + print "selected='selected' "; } + print "value='$month'>$longmonths[$month]</option>\n"; } print <<END - </select> - </td> - <td width='10%' class='base' align='right'> $Lang::tr{'day'}: </td> - <td width='40%'> - <select name='DAY'> + </select> + </td> + <td width='10%' class='base' align='right'> $Lang::tr{'day'}: </td> + <td width='40%'> + <select name='DAY'> END ; for ($day = 1; $day <= 31; $day++) { - print "\t<option "; - if ($day == $cgiparams{'DAY'}) { - print "selected='selected' "; } - print "value='$day'>$day</option>\n"; + print "\t<option "; + if ($day == $cgiparams{'DAY'}) { + print "selected='selected' "; } + print "value='$day'>$day</option>\n"; }
if( $cgiparams{'pienumber'} != 0){$pienumber=$cgiparams{'pienumber'};} if( $cgiparams{'otherspie'} != 0){$otherspie=$cgiparams{'otherspie'};} if( $cgiparams{'showpie'} != 0){$showpie=$cgiparams{'showpie'};} if( $cgiparams{'sortcolumn'} != 0){$sortcolumn=$cgiparams{'sortcolumn'};} - print <<END </select> </td> @@ -294,29 +294,43 @@ $lines = 0;
foreach $_ (@log) { - /^... (..) (..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/; - my $packet = $4; - $packet =~ /IN=(\w+)/; my $iface=$1; if ( $1 =~ /2./ ){ $iface="";} - $packet =~ /SRC=([\d.]+)/; my $srcaddr=$1; - - if($iface eq $red_interface) { - if($srcaddr ne '') { - my $ccode = $gi->country_code_by_name($srcaddr); - if( $ccode eq '') { - $ccode = 'unknown'; - } - $tabjc{$ccode} = $tabjc{$ccode} + 1 ; - if(($tabjc{$ccode} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } - $linesjc++; - } - } - else { - if($iface ne '') { - $tabjc{$iface} = $tabjc{$iface} + 1 ; - if(($tabjc{$iface} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } - $linesjc++; - } - } + # If ipv6 uses bridge, use PHYSIN for iface, otherwise IN + if (/^... (..) (..:..:..) [\w-]+ kernel:(.*)(PHYSIN=.*)$/) {} + elsif (/^... (..) (..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/) {} + my $packet = $4; + my $iface = ''; + if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; } + if ( $1 =~ /2./ ) { $iface=''; } + my $srcaddr = ''; + # Find ipv4 and ipv6 addresses + if ($packet =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) { $srcaddr = $1; } + elsif ($packet =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/) { $srcaddr = $1; } + + if($iface eq $red_interface) { + # Traffic from red + if($srcaddr ne '') { + # srcaddr is set + my $ccode = $gi->country_code_by_name($srcaddr); + if ($ccode eq '') { + $ccode = 'unknown'; + } + $tabjc{$ccode} = $tabjc{$ccode} + 1; + if(($tabjc{$ccode} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } + $linesjc++; + } + } + else { + # Traffic not from red + if($iface ne '') { + $tabjc{$iface} = $tabjc{$iface} + 1 ; + if(($tabjc{$iface} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } + $linesjc++; + } + else { + # What to do with empty iface lines? + # This probably is traffic from ipfire itself (IN= OUT=XY)? + } + } }
$pienumber = $lines; @@ -336,13 +350,11 @@ my @value; my $indice=0; my @tabjc2;
-if ($sortcolumn == 1) -{ - @tabjc2 = sort { $b <=> $a } values (%tabjc); +if ($sortcolumn == 1) { + @tabjc2 = sort { $b <=> $a } values (%tabjc); } -else -{ - @tabjc2 = sort { $a <=> $b } keys (%tabjc); +else { + @tabjc2 = sort { $a <=> $b } keys (%tabjc); }
my $colour=1; @@ -354,19 +366,17 @@ use GD::Graph::colour; #ips sort by hits number my $v;
-if ($sortcolumn == 1) -{ - for ($v=0;$v<$pienumber;$v++){ - findkey($tabjc2[$v]); - } +if ($sortcolumn == 1) { + for ($v=0;$v<$pienumber;$v++){ + findkey($tabjc2[$v]); + } } -else -{ - foreach $v (@tabjc2) { - $key[$indice] = $v; - $value[$indice] = $tabjc{$v}; - $indice++; - } +else { + foreach $v (@tabjc2) { + $key[$indice] = $v; + $value[$indice] = $tabjc{$v}; + $indice++; + } }
my @ips; @@ -379,15 +389,15 @@ my $o;
if($cgiparams{'otherspie'} == 2 ){} else{ - my $numothers; - for($o=0;$o<$pienumber;$o++){ - $numothers = $numothers + $numb[$o]; - } - $numothers = $linesjc - $numothers; - if ($numothers > 0) { - $ips[$pienumber]="$Lang::tr{'otherip'}"; - $numb[$pienumber] = $numothers; - } + my $numothers; + for($o=0;$o<$pienumber;$o++){ + $numothers = $numothers + $numb[$o]; + } + $numothers = $linesjc - $numothers; + if ($numothers > 0) { + $ips[$pienumber]="$Lang::tr{'otherip'}"; + $numb[$pienumber] = $numothers; + } }
my @data = (@ips,@numb); @@ -400,30 +410,29 @@ my %mainsettings = (); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", %color);
if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) { - my $mygraph = GD::Graph::pie->new(500, 350); - $mygraph->set( - 'title' => '', - 'pie_height' => 50, - 'start_angle' => 89 - ) or warn $mygraph->error; - - $mygraph->set_value_font(GD::gdMediumBoldFont); - $mygraph->set( dclrs => [ "$color{'color1'}" , "$color{'color2'}" , "$color{'color3'}" , "$color{'color4'}" , "$color{'color5'}" , "$color{'color6'}" , "$color{'color7'}" , "$color{'color8'}" , "$color{'color9'}" , "$color{'color10'}" ] ); - my $myimage = $mygraph->plot(@data) or die $mygraph->error; - - my @filenames = glob("/srv/web/ipfire/html/graphs/fwlog-country*.png"); - unlink(@filenames); - my $imagerandom = rand(1000000); - my $imagename = "/srv/web/ipfire/html/graphs/fwlog-country$imagerandom.png"; - open(FILE,">$imagename"); - print FILE $myimage->png; - close(FILE); - ##################################################### - print "<div style='text-align:center;'>"; - print "<img src='/graphs/fwlog-country$imagerandom.png'>"; - print "</div>"; + my $mygraph = GD::Graph::pie->new(500, 350); + $mygraph->set( + 'title' => '', + 'pie_height' => 50, + 'start_angle' => 89 + ) or warn $mygraph->error; + + $mygraph->set_value_font(GD::gdMediumBoldFont); + $mygraph->set( dclrs => [ "$color{'color1'}" , "$color{'color2'}" , "$color{'color3'}" , "$color{'color4'}" , "$color{'color5'}" , "$color{'color6'}" , "$color{'color7'}" , "$color{'color8'}" , "$color{'color9'}" , "$color{'color10'}" ] ); + my $myimage = $mygraph->plot(@data) or die $mygraph->error; + + my @filenames = glob("/srv/web/ipfire/html/graphs/fwlog-country*.png"); + unlink(@filenames); + my $imagerandom = rand(1000000); + my $imagename = "/srv/web/ipfire/html/graphs/fwlog-country$imagerandom.png"; + open(FILE,">$imagename"); + print FILE $myimage->png; + close(FILE); + ##################################################### + print "<div style='text-align:center;'>"; + print "<img src='/graphs/fwlog-country$imagerandom.png'>"; + print "</div>"; } - print <<END <table width='100%' class='tbl'> <tr> @@ -444,73 +453,72 @@ my $col="";
for($s=0;$s<$lines;$s++) { - $show++; - $percent = $value[$s] * 100 / $linesjc; - $percent = sprintf("%.f", $percent); - $total = $total + $value[$s]; - my $colorIndex = $color % 10; - if($colorIndex == 0) { - $colorIndex = 10; - } - $col="bgcolor='$color{"color$colorIndex"}'"; - $color++; - print "<tr>"; - - print "<td align='center' $col>"; - - # Dont show details button for "unknown" location. - if ($key[$s] ne 'unknown') { - print"<form method='post' action='showrequestfromcountry.dat'>"; - print"<input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'>"; - print"<input type='hidden' name='DAY' value='$cgiparams{'DAY'}'>"; - print"<input type='hidden' name='country' value='$key[$s]'>"; - print"<input type='submit' value='details'></form>"; - } - - if($key[$s] eq 'blue0' || $key[$s] eq 'green0' || $key[$s] eq 'orange0') { - print "<td align='center' $col>$key[$s]</td>"; - } - else { - my $fcode = lc($key[$s]); - - # Get flag icon for of the country. - my $flag_icon = &GeoIP::get_flag_icon($fcode); - - if($flag_icon) { - print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$key[$s]' title='$key[$s]'></a></td>"; - } else { + $show++; + $percent = $value[$s] * 100 / $linesjc; + $percent = sprintf("%.f", $percent); + $total = $total + $value[$s]; + # colors are numbered 1 to 10 + my $colorIndex = ($color % 10) + 1; + $col="bgcolor='$color{"color$colorIndex"}'"; + $color++; + print "<tr>"; + + print "<td align='center' $col>"; + + # Dont show details button for "unknown" location. + if ($key[$s] ne 'unknown') { + print"<form method='post' action='showrequestfromcountry.dat'>"; + print"<input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'>"; + print"<input type='hidden' name='DAY' value='$cgiparams{'DAY'}'>"; + print"<input type='hidden' name='country' value='$key[$s]'>"; + print"<input type='submit' value='details'></form>"; + } + elsif ($key[$s] eq 'unknown') { + print "unknown"; + } + # Looks dangerous to use hardcoded interface names here. Probably needs fixing. + if ($key[$s] eq 'blue0' || $key[$s] eq 'green0' || $key[$s] eq 'orange0' ) { print "<td align='center' $col>$key[$s]</td>"; - } - } - print "<td align='center' $col>$value[$s]</td>"; - print "<td align='center' $col>$percent</td>"; - print "</tr>"; + } + else { + my $fcode = lc($key[$s]); + + # Get flag icon for of the country. + my $flag_icon = &GeoIP::get_flag_icon($fcode); + + if($flag_icon) { + print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$key[$s]' title='$key[$s]'></a></td>"; + } else { + print "<td align='center' $col>$key[$s]</td>"; + } + } + print "<td align='center' $col>$value[$s]</td>"; + print "<td align='center' $col>$percent</td>"; + print "</tr>"; }
if($cgiparams{'otherspie'} == 2 ){} else{ - my $colorIndex = $color % 10; - if($colorIndex == 0) { - $colorIndex = 10; - } - $col="bgcolor='$color{"color$colorIndex"}'"; - print "<tr>"; - -if ( $linesjc ne "0") -{ -my $dif; -$dif = $linesjc - $total; -$percent = $dif * 100 / $linesjc; -$percent = sprintf("%.f", $percent); -print <<END -<td align='center' $col></TD> -<td align='center' $col>$Lang::tr{'other countries'}</td> -<td align='center' $col>$dif</TD> -<td align='center' $col>$percent</TD> -</tr> + # colors are numbered 1 to 10 + my $colorIndex = ($color % 10) + 1; + $col="bgcolor='$color{"color$colorIndex"}'"; + print "<tr>"; + + if ( $linesjc ne "0") + { + my $dif; + $dif = $linesjc - $total; + $percent = $dif * 100 / $linesjc; + $percent = sprintf("%.f", $percent); + print <<END + <td align='center' $col></TD> + <td align='center' $col>$Lang::tr{'other countries'}</td> + <td align='center' $col>$dif</TD> + <td align='center' $col>$percent</TD> + </tr> END -; -} + ; + } } print <<END </TABLE> @@ -522,19 +530,19 @@ END &Header::closepage();
sub findkey { - my $v; - foreach $v (@keytabjc) { - if ($tabjc{$v} eq $_[0]) { - delete $tabjc{$v}; - $key[$indice] = "$v"; - $value[$indice] = $_[0]; - $indice++; - last; - } - } + my $v; + foreach $v (@keytabjc) { + if ($tabjc{$v} eq $_[0]) { + delete $tabjc{$v}; + $key[$indice] = "$v"; + $value[$indice] = $_[0]; + $indice++; + last; + } + } } sub checkversion { - #Automatic Updates is disabled - return "0","0"; + #Automatic Updates is disabled + return "0","0"; }
diff --git a/html/cgi-bin/logs.cgi/firewalllogip.dat b/html/cgi-bin/logs.cgi/firewalllogip.dat index 7d82d20..08ef1c4 100644 --- a/html/cgi-bin/logs.cgi/firewalllogip.dat +++ b/html/cgi-bin/logs.cgi/firewalllogip.dat @@ -8,7 +8,7 @@ # page inspired from the initial firewalllog.dat # # Modified for IPFire by Christian Schmidt -# and Michael Tremer (www.ipfire.org) +# and Michael Tremer (www.ipfire.org)
use strict; use Geo::IP::PurePerl; @@ -39,11 +39,11 @@ $cgiparams{'showpie'} = 1; $cgiparams{'sortcolumn'} = 1;
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', - 'Sep', 'Oct', 'Nov', 'Dec' ); + 'Sep', 'Oct', 'Nov', 'Dec' ); my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'}, - $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'}, - $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, - $Lang::tr{'december'} ); + $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'}, + $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, + $Lang::tr{'december'} );
my @now = localtime(); my $dow = $now[6]; @@ -69,81 +69,81 @@ if ($cgiparams{'sortcolumn'} != 0) { $settings{'sortcolumn'} = $cgiparams{'sortc
if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) { - &General::writehash("${General::swroot}/fwlogs/ipsettings", %settings); + &General::writehash("${General::swroot}/fwlogs/ipsettings", %settings); }
my $start = -1; if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) { - my @temp = split(',',$ENV{'QUERY_STRING'}); - $start = $temp[0]; - $cgiparams{'MONTH'} = $temp[1]; - $cgiparams{'DAY'} = $temp[2]; + my @temp = split(',',$ENV{'QUERY_STRING'}); + $start = $temp[0]; + $cgiparams{'MONTH'} = $temp[1]; + $cgiparams{'DAY'} = $temp[2]; }
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || !($cgiparams{'DAY'} =~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) { - $cgiparams{'DAY'} = $now[3]; - $cgiparams{'MONTH'} = $now[4]; + $cgiparams{'DAY'} = $now[3]; + $cgiparams{'MONTH'} = $now[4]; } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; }
if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then = (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy = $then[7]; - my $lastleap=($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap == 0 && $tdoy < 60) { - $doy=$tdoy+366; - } else { - $doy=$doy+365; - } - } + my @then = (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); + } else { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); + } + $tdoy = $then[7]; + my $lastleap=($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap == 0 && $tdoy < 60) { + $doy=$tdoy+366; + } else { + $doy=$doy+365; + } + } }
my $datediff=0; my $dowd=0; my $multifile=0; if ($tdoy ne $doy) { - $datediff=int(($doy-$tdoy)/7); - $dowd=($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=$datediff+1; - } - if (($dow-$dowd)==0) { - $multifile=1; - } + $datediff=int(($doy-$tdoy)/7); + $dowd=($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=$datediff+1; + } + if (($dow-$dowd)==0) { + $multifile=1; + } }
my $monthstr = $shortmonths[$cgiparams{'MONTH'}]; @@ -151,62 +151,62 @@ my $longmonthstr = $longmonths[$cgiparams{'MONTH'}]; my $day = $cgiparams{'DAY'}; my $daystr=''; if ($day <= 9) { - $daystr = " $day"; } + $daystr = " $day"; } else { - $daystr = $day; + $daystr = $day; }
my $skip=0; my $filestr=''; if ($datediff==0) { - $filestr="/var/log/messages"; + $filestr="/var/log/messages"; } else { $filestr="/var/log/messages.$datediff"; $filestr = "$filestr.gz" if -f "$filestr.gz"; }
if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - # Note: This is in case the log does not exist for that date + $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + # Note: This is in case the log does not exist for that date } my $lines = 0; my @log=();
if (!$skip) { - while (<FILE>) - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - $log[$lines] = $_; - $lines++; - } - } - close (FILE); + while (<FILE>) + { + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + $log[$lines] = $_; + $lines++; + } + } + close (FILE); }
$skip=0; if ($multifile) { - $datediff=$datediff-1; - if ($datediff==0) { - $filestr="/var/log/messages"; - } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - } - if (!$skip) { - while (<FILE>) { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - $log[$lines] = $_; - $lines++; - } - } - close (FILE); - } + $datediff=$datediff-1; + if ($datediff==0) { + $filestr="/var/log/messages"; + } else { + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { + $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + } + if (!$skip) { + while (<FILE>) { + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + $log[$lines] = $_; + $lines++; + } + } + close (FILE); + } }
my $MODNAME="fwlogs"; @@ -217,9 +217,9 @@ my $MODNAME="fwlogs";
if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "<font class='base'>$errormessage </font>\n"; - &Header::closebox(); + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "<font class='base'>$errormessage </font>\n"; + &Header::closebox(); }
&Header::openbox('100%', 'left', "$Lang::tr{'settings'}"); @@ -228,33 +228,35 @@ print <<END <form method='post' action='$ENV{'SCRIPT_NAME'}'> <table width='100%'> <tr> - <td width='10%' class='base'>$Lang::tr{'month'}: </td> - <td width='10%'> - <select name='MONTH'> + <td width='10%' class='base'>$Lang::tr{'month'}: </td> + <td width='10%'> + <select name='MONTH'> END ; my $month; for ($month = 0; $month < 12; $month++) { - print "\t<option "; - if ($month == $cgiparams{'MONTH'}) { - print "selected='selected' "; } - print "value='$month'>$longmonths[$month]</option>\n"; + print "\t<option "; + if ($month == $cgiparams{'MONTH'}) { + print "selected='selected' "; + } + print "value='$month'>$longmonths[$month]</option>\n"; } print <<END - </select> - </td> - <td width='10%' class='base' align='right'> $Lang::tr{'day'}: </td> - <td width='40%'> - <select name='DAY'> + </select> + </td> + <td width='10%' class='base' align='right'> $Lang::tr{'day'}: </td> + <td width='40%'> + <select name='DAY'> END ; for ($day = 1; $day <= 31; $day++) { - print "\t<option "; - if ($day == $cgiparams{'DAY'}) { - print "selected='selected' "; } - print "value='$day'>$day</option>\n"; + print "\t<option "; + if ($day == $cgiparams{'DAY'}) { + print "selected='selected' "; + } + print "value='$day'>$day</option>\n"; }
if( $cgiparams{'pienumber'} != 0){$pienumber=$cgiparams{'pienumber'};} @@ -291,11 +293,12 @@ if ($pienumber == -1 || $pienumber > $lines || $sortcolumn == 2) { $pienumber = $lines = 0; foreach $_ (@log) { - if($_ =~ /SRC=([\d.]+)/){ - $tabjc{$1} = $tabjc{$1} + 1 ; - if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } - $linesjc++; - } + # Extract ipv4 or ipv6 address + if (($_ =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($_ =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { + $tabjc{$1} = $tabjc{$1} + 1 ; + if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } + $linesjc++; + } }
$pienumber = $lines; @@ -317,11 +320,11 @@ my @tabjc2;
if ($sortcolumn == 1) { - @tabjc2 = sort { $b <=> $a } values (%tabjc); + @tabjc2 = sort { $b <=> $a } values (%tabjc); } else { - @tabjc2 = sort { $a <=> $b } keys (%tabjc); + @tabjc2 = sort { $a <=> $b } keys (%tabjc); }
my $colour=1; @@ -335,17 +338,17 @@ my $v;
if ($sortcolumn == 1) { - for ($v=0;$v<$pienumber;$v++){ - findkey($tabjc2[$v]); - } + for ($v=0;$v<$pienumber;$v++){ + findkey($tabjc2[$v]); + } } else { - foreach $v (@tabjc2) { - $key[$indice] = $v; - $value[$indice] = $tabjc{$v}; - $indice++; - } + foreach $v (@tabjc2) { + $key[$indice] = $v; + $value[$indice] = $tabjc{$v}; + $indice++; + } }
my @ips; @@ -358,15 +361,15 @@ my $o;
if($cgiparams{'otherspie'} == 2 ){} else{ - my $numothers; - for($o=0;$o<$pienumber;$o++){ - $numothers = $numothers + $numb[$o]; - } - $numothers = $linesjc - $numothers; - if ($numothers > 0) { - $ips[$pienumber]="$Lang::tr{'otherip'}"; - $numb[$pienumber] = $numothers; - } + my $numothers; + for($o=0;$o<$pienumber;$o++){ + $numothers = $numothers + $numb[$o]; + } + $numothers = $linesjc - $numothers; + if ($numothers > 0) { + $ips[$pienumber]="$Lang::tr{'otherip'}"; + $numb[$pienumber] = $numothers; + } }
my @data = (@ips,@numb); @@ -379,28 +382,28 @@ my %mainsettings = (); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", %color);
if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) { - my $mygraph = GD::Graph::pie->new(500, 350); - $mygraph->set( - 'title' => '', - 'pie_height' => 50, - 'start_angle' => 89 - ) or warn $mygraph->error; - - $mygraph->set_value_font(GD::gdMediumBoldFont); - $mygraph->set( dclrs => [ "$color{'color1'}" , "$color{'color2'}" , "$color{'color3'}" , "$color{'color4'}" , "$color{'color5'}" , "$color{'color6'}" , "$color{'color7'}" , "$color{'color8'}" , "$color{'color9'}" , "$color{'color10'}" ] ); - my $myimage = $mygraph->plot(@data) or die $mygraph->error; - - my @filenames = glob("/srv/web/ipfire/html/graphs/fwlog-ip*.png"); - unlink(@filenames); - my $imagerandom = rand(1000000); - my $imagename = "/srv/web/ipfire/html/graphs/fwlog-ip$imagerandom.png"; - open(FILE,">$imagename"); - print FILE $myimage->png; - close(FILE); - ##################################################### - print "<div style='text-align:center'>"; - print "<img src='/graphs/fwlog-ip$imagerandom.png'>"; - print "</div>"; + my $mygraph = GD::Graph::pie->new(500, 350); + $mygraph->set( + 'title' => '', + 'pie_height' => 50, + 'start_angle' => 89 + ) or warn $mygraph->error; + + $mygraph->set_value_font(GD::gdMediumBoldFont); + $mygraph->set( dclrs => [ "$color{'color1'}" , "$color{'color2'}" , "$color{'color3'}" , "$color{'color4'}" , "$color{'color5'}" , "$color{'color6'}" , "$color{'color7'}" , "$color{'color8'}" , "$color{'color9'}" , "$color{'color10'}" ] ); + my $myimage = $mygraph->plot(@data) or die $mygraph->error; + + my @filenames = glob("/srv/web/ipfire/html/graphs/fwlog-ip*.png"); + unlink(@filenames); + my $imagerandom = rand(1000000); + my $imagename = "/srv/web/ipfire/html/graphs/fwlog-ip$imagerandom.png"; + open(FILE,">$imagename"); + print FILE $myimage->png; + close(FILE); + ##################################################### + print "<div style='text-align:center'>"; + print "<img src='/graphs/fwlog-ip$imagerandom.png'>"; + print "</div>"; }
print <<END @@ -424,64 +427,60 @@ my $col="";
for($s=0;$s<$lines;$s++) { - $show++; - $percent = $value[$s] * 100 / $linesjc; - $percent = sprintf("%.f", $percent); - $total = $total + $value[$s]; - my $colorIndex = $color % 10; - if($colorIndex == 0) { - $colorIndex = 10; - } - $col="bgcolor='$color{"color$colorIndex"}'"; - print "<tr>"; + $show++; + $percent = $value[$s] * 100 / $linesjc; + $percent = sprintf("%.f", $percent); + $total = $total + $value[$s]; + # colors are numbered 1 to 10 + my $colorIndex = ($color % 10) + 1; + $col="bgcolor='$color{"color$colorIndex"}'"; + print "<tr>"; + + my $gi = Geo::IP::PurePerl->new(); + my $ccode = $gi->country_code_by_name($key[$s]); + my $fcode = lc($ccode);
- my $gi = Geo::IP::PurePerl->new(); - my $ccode = $gi->country_code_by_name($key[$s]); - my $fcode = lc($ccode); - - $color++; - print "<td align='center' $col><form method='post' action='showrequestfromip.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='ip' value='$key[$s]'> <input type='submit' value='$Lang::tr{'details'}'></form></td>"; - print "<td align='center' $col><a href='/cgi-bin/ipinfo.cgi?ip=$key[$s]'>$key[$s]</a></td>"; - - # Get flag icon for of the country. - my $flag_icon = &GeoIP::get_flag_icon($ccode); - - if ( $flag_icon ) { - print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode' title='$ccode'></a></td>"; - } else { - print "<td align='center' $col></td>"; - } - - print "<td align='center' $col>$value[$s]</td>"; - print "<td align='center' $col>$percent</td>"; - print "</tr>"; - } + $color++; + print "<td align='center' $col><form method='post' action='showrequestfromip.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='ip' value='$key[$s]'> <input type='submit' value='$Lang::tr{'details'}'></form></td>"; + print "<td align='center' $col><a href='/cgi-bin/ipinfo.cgi?ip=$key[$s]'>$key[$s]</a></td>"; + + # Get flag icon for of the country. + my $flag_icon = &GeoIP::get_flag_icon($ccode); + + if ( $flag_icon ) { + print "<td align='center' $col><a href='/cgi-bin/country.cgi#$fcode'><img src='$flag_icon' border='0' align='absmiddle' alt='$ccode' title='$ccode'></a></td>"; + } else { + print "<td align='center' $col></td>"; + } + + print "<td align='center' $col>$value[$s]</td>"; + print "<td align='center' $col>$percent</td>"; + print "</tr>"; +}
if($cgiparams{'otherspie'} == 2 ){} else{ - my $colorIndex = $color % 10; - if($colorIndex == 0) { - $colorIndex = 10; - } - $col="bgcolor='$color{"color$colorIndex"}'"; - print "<tr>"; - -if ( $linesjc ne "0") -{ -my $dif; -$dif = $linesjc - $total; -$percent = $dif * 100 / $linesjc; -$percent = sprintf("%.f", $percent); -print <<END -<td align='center' $col></td> -<td align='center' $col>$Lang::tr{'otherip'}</td> -<td align='center' $col></td> -<td align='center' $col>$dif</td> -<td align='center' $col>$percent</td> -</tr> + # colors are numbered 1 to 10 + my $colorIndex = ($color % 10) + 1; + $col="bgcolor='$color{"color$colorIndex"}'"; + print "<tr>"; + + if ( $linesjc ne "0") + { + my $dif; + $dif = $linesjc - $total; + $percent = $dif * 100 / $linesjc; + $percent = sprintf("%.f", $percent); + print <<END + <td align='center' $col></td> + <td align='center' $col>$Lang::tr{'otherip'}</td> + <td align='center' $col></td> + <td align='center' $col>$dif</td> + <td align='center' $col>$percent</td> + </tr> END -; -} + ; + } } print <<END </table> @@ -493,20 +492,20 @@ END &Header::closepage();
sub findkey { - my $v; - foreach $v (@keytabjc) { - if ($tabjc{$v} eq $_[0]) { - delete $tabjc{$v}; - $key[$indice] = "$v"; - $value[$indice] = $_[0]; - $indice++; - last; - } - } + my $v; + foreach $v (@keytabjc) { + if ($tabjc{$v} eq $_[0]) { + delete $tabjc{$v}; + $key[$indice] = "$v"; + $value[$indice] = $_[0]; + $indice++; + last; + } + } }
sub checkversion { - #Automatic Updates is disabled - return "0","0"; + #Automatic Updates is disabled + return "0","0"; }
diff --git a/html/cgi-bin/logs.cgi/firewalllogport.dat b/html/cgi-bin/logs.cgi/firewalllogport.dat index 5b0db62..fbc92e4 100644 --- a/html/cgi-bin/logs.cgi/firewalllogport.dat +++ b/html/cgi-bin/logs.cgi/firewalllogport.dat @@ -8,7 +8,7 @@ # page inspired from the initial firewalllog.dat # # Modified for IPFire by Christian Schmidt -# and Michael Tremer (www.ipfire.org) +# and Michael Tremer (www.ipfire.org)
use strict;
@@ -40,11 +40,11 @@ $cgiparams{'showpie'} = 1; $cgiparams{'sortcolumn'} = 1;
my @shortmonths = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', - 'Sep', 'Oct', 'Nov', 'Dec' ); + 'Sep', 'Oct', 'Nov', 'Dec' ); my @longmonths = ( $Lang::tr{'january'}, $Lang::tr{'february'}, $Lang::tr{'march'}, - $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'}, - $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, - $Lang::tr{'december'} ); + $Lang::tr{'april'}, $Lang::tr{'may'}, $Lang::tr{'june'}, $Lang::tr{'july'}, $Lang::tr{'august'}, + $Lang::tr{'september'}, $Lang::tr{'october'}, $Lang::tr{'november'}, + $Lang::tr{'december'} );
my @now = localtime(); my $dow = $now[6]; @@ -70,81 +70,81 @@ if ($cgiparams{'sortcolumn'} != 0) { $settings{'sortcolumn'} = $cgiparams{'sortc
if ($cgiparams{'ACTION'} eq $Lang::tr{'save'}) { - &General::writehash("${General::swroot}/fwlogs/portsettings", %settings); + &General::writehash("${General::swroot}/fwlogs/portsettings", %settings); }
my $start = -1; if ($ENV{'QUERY_STRING'} && $cgiparams{'ACTION'} ne $Lang::tr{'update'}) { - my @temp = split(',',$ENV{'QUERY_STRING'}); - $start = $temp[0]; - $cgiparams{'MONTH'} = $temp[1]; - $cgiparams{'DAY'} = $temp[2]; + my @temp = split(',',$ENV{'QUERY_STRING'}); + $start = $temp[0]; + $cgiparams{'MONTH'} = $temp[1]; + $cgiparams{'DAY'} = $temp[2]; }
if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || !($cgiparams{'DAY'} =~ /^(1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31)$/)) { - $cgiparams{'DAY'} = $now[3]; - $cgiparams{'MONTH'} = $now[4]; + $cgiparams{'DAY'} = $now[3]; + $cgiparams{'MONTH'} = $now[4]; } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; }
if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then = (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy = $then[7]; - my $lastleap=($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap == 0 && $tdoy < 60) { - $doy=$tdoy+366; - } else { - $doy=$doy+365; - } - } + my @then = (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); + } else { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); + } + $tdoy = $then[7]; + my $lastleap=($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap == 0 && $tdoy < 60) { + $doy=$tdoy+366; + } else { + $doy=$doy+365; + } + } }
my $datediff=0; my $dowd=0; my $multifile=0; if ($tdoy ne $doy) { - $datediff=int(($doy-$tdoy)/7); - $dowd=($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=$datediff+1; - } - if (($dow-$dowd)==0) { - $multifile=1; - } + $datediff=int(($doy-$tdoy)/7); + $dowd=($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=$datediff+1; + } + if (($dow-$dowd)==0) { + $multifile=1; + } }
my $monthstr = $shortmonths[$cgiparams{'MONTH'}]; @@ -152,62 +152,62 @@ my $longmonthstr = $longmonths[$cgiparams{'MONTH'}]; my $day = $cgiparams{'DAY'}; my $daystr=''; if ($day <= 9) { - $daystr = " $day"; } + $daystr = " $day"; } else { - $daystr = $day; + $daystr = $day; }
my $skip=0; my $filestr=''; if ($datediff==0) { - $filestr="/var/log/messages"; + $filestr="/var/log/messages"; } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; }
if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - # Note: This is in case the log does not exist for that date + $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + # Note: This is in case the log does not exist for that date } my $lines = 0; my @log=();
if (!$skip) { - while (<FILE>) - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - $log[$lines] = $_; - $lines++; - } - } - close (FILE); + while (<FILE>) + { + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + $log[$lines] = $_; + $lines++; + } + } + close (FILE); }
$skip=0; if ($multifile) { - $datediff=$datediff-1; - if ($datediff==0) { - $filestr="/var/log/messages"; - } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - } - if (!$skip) { - while (<FILE>) { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - $log[$lines] = $_; - $lines++; - } - } - close (FILE); - } + $datediff=$datediff-1; + if ($datediff==0) { + $filestr="/var/log/messages"; + } else { + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { + $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + } + if (!$skip) { + while (<FILE>) { + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + $log[$lines] = $_; + $lines++; + } + } + close (FILE); + } }
my $MODNAME="fwlogs"; @@ -217,9 +217,9 @@ my $MODNAME="fwlogs"; &Header::openbigbox('100%', 'left', '', $errormessage);
if ($errormessage) { - &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); - print "<font class='base'>$errormessage </font>\n"; - &Header::closebox(); + &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); + print "<font class='base'>$errormessage </font>\n"; + &Header::closebox(); }
&Header::openbox('100%', 'left', "$Lang::tr{'settings'}"); @@ -228,33 +228,33 @@ print <<END <form method='post' action='$ENV{'SCRIPT_NAME'}'> <table width='100%'> <tr> - <td width='10%' class='base'>$Lang::tr{'month'}: </td> - <td width='10%'> - <select name='MONTH'> + <td width='10%' class='base'>$Lang::tr{'month'}: </td> + <td width='10%'> + <select name='MONTH'> END ; my $month; for ($month = 0; $month < 12; $month++) { - print "\t<option "; - if ($month == $cgiparams{'MONTH'}) { - print "selected='selected' "; } - print "value='$month'>$longmonths[$month]</option>\n"; + print "\t<option "; + if ($month == $cgiparams{'MONTH'}) { + print "selected='selected' "; } + print "value='$month'>$longmonths[$month]</option>\n"; } print <<END - </select> - </td> - <td width='10%' class='base' align='right'> $Lang::tr{'day'}: </td> - <td width='40%'> - <select name='DAY'> + </select> + </td> + <td width='10%' class='base' align='right'> $Lang::tr{'day'}: </td> + <td width='40%'> + <select name='DAY'> END ; for ($day = 1; $day <= 31; $day++) { - print "\t<option "; - if ($day == $cgiparams{'DAY'}) { - print "selected='selected' "; } - print "value='$day'>$day</option>\n"; + print "\t<option "; + if ($day == $cgiparams{'DAY'}) { + print "selected='selected' "; } + print "value='$day'>$day</option>\n"; }
if( $cgiparams{'pienumber'} != 0){$pienumber=$cgiparams{'pienumber'};} @@ -291,11 +291,11 @@ if ($pienumber == -1 || $pienumber > $lines || $sortcolumn == 2) { $pienumber = $lines = 0; foreach $_ (@log) { - if($_ =~ /DPT=([\d.]+)/){ - $tabjc{$1} = $tabjc{$1} + 1 ; - if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } - $linesjc++; - } + if($_ =~ /DPT=([\d.]+)/){ + $tabjc{$1} = $tabjc{$1} + 1 ; + if(($tabjc{$1} == 1) && ($lines < $pienumber)) { $lines = $lines + 1; } + $linesjc++; + } }
$pienumber = $lines; @@ -317,11 +317,11 @@ my @tabjc2;
if ($sortcolumn == 1) { - @tabjc2 = sort { $b <=> $a } values (%tabjc); + @tabjc2 = sort { $b <=> $a } values (%tabjc); } else { - @tabjc2 = sort { $a <=> $b } keys (%tabjc); + @tabjc2 = sort { $a <=> $b } keys (%tabjc); }
my $color=10; @@ -338,17 +338,17 @@ my $v;
if ($sortcolumn == 1) { - for ($v=0;$v<$pienumber;$v++){ - findkey($tabjc2[$v]); - } + for ($v=0;$v<$pienumber;$v++){ + findkey($tabjc2[$v]); + } } else { - foreach $v (@tabjc2) { - $key[$indice] = $v; - $value[$indice] = $tabjc{$v}; - $indice++; - } + foreach $v (@tabjc2) { + $key[$indice] = $v; + $value[$indice] = $tabjc{$v}; + $indice++; + } }
my @ports; @@ -361,15 +361,15 @@ my $o;
if($cgiparams{'otherspie'} == 2 ){} else{ - my $numothers; - for($o=0;$o<$pienumber;$o++){ - $numothers = $numothers + $numb[$o]; - } - $numothers = $linesjc - $numothers; - if ($numothers > 0) { - $ports[$pienumber]="$Lang::tr{'otherport'}"; - $numb[$pienumber] = $numothers; - } + my $numothers; + for($o=0;$o<$pienumber;$o++){ + $numothers = $numothers + $numb[$o]; + } + $numothers = $linesjc - $numothers; + if ($numothers > 0) { + $ports[$pienumber]="$Lang::tr{'otherport'}"; + $numb[$pienumber] = $numothers; + } }
my @data = (@ports,@numb); @@ -381,28 +381,28 @@ my %mainsettings = (); &General::readhash("/srv/web/ipfire/html/themes/".$mainsettings{'THEME'}."/include/colors.txt", %color);
if ($showpie != 2 && $pienumber <= 50 && $pienumber != 0) { - my $mygraph = GD::Graph::pie->new(500, 350); - $mygraph->set( - 'title' => '', - 'pie_height' => 50, - 'start_angle' => 89 - ) or warn $mygraph->error; - - $mygraph->set_value_font(GD::gdMediumBoldFont); - $mygraph->set( dclrs => [ "$color{'color1'}" , "$color{'color2'}" , "$color{'color3'}" , "$color{'color4'}" , "$color{'color5'}" , "$color{'color6'}" , "$color{'color7'}" , "$color{'color8'}" , "$color{'color9'}" , "$color{'color10'}" ] ); - my $myimage = $mygraph->plot(@data) or die $mygraph->error; - - my @filenames = glob("/srv/web/ipfire/html/graphs/fwlog-port*.png"); - unlink(@filenames); - my $imagerandom = rand(1000000); - my $imagename = "/srv/web/ipfire/html/graphs/fwlog-port$imagerandom.png"; - open(FILE,">$imagename"); - print FILE $myimage->png; - close(FILE); - ##################################################### - print "<div style='text-align:center'>"; - print "<img src='/graphs/fwlog-port$imagerandom.png'>"; - print "</div>"; + my $mygraph = GD::Graph::pie->new(500, 350); + $mygraph->set( + 'title' => '', + 'pie_height' => 50, + 'start_angle' => 89 + ) or warn $mygraph->error; + + $mygraph->set_value_font(GD::gdMediumBoldFont); + $mygraph->set( dclrs => [ "$color{'color1'}" , "$color{'color2'}" , "$color{'color3'}" , "$color{'color4'}" , "$color{'color5'}" , "$color{'color6'}" , "$color{'color7'}" , "$color{'color8'}" , "$color{'color9'}" , "$color{'color10'}" ] ); + my $myimage = $mygraph->plot(@data) or die $mygraph->error; + + my @filenames = glob("/srv/web/ipfire/html/graphs/fwlog-port*.png"); + unlink(@filenames); + my $imagerandom = rand(1000000); + my $imagename = "/srv/web/ipfire/html/graphs/fwlog-port$imagerandom.png"; + open(FILE,">$imagename"); + print FILE $myimage->png; + close(FILE); + ##################################################### + print "<div style='text-align:center'>"; + print "<img src='/graphs/fwlog-port$imagerandom.png'>"; + print "</div>"; }
print <<END @@ -425,49 +425,44 @@ my $col="";
for($s=0;$s<$lines;$s++) { - $show++; - $percent = $value[$s] * 100 / $linesjc; - $percent = sprintf("%.f", $percent); - $total = $total + $value[$s]; - my $colorIndex = $color % 10; - if($colorIndex == 0) { - $colorIndex = 10; - } - $col="bgcolor='$color{"color$colorIndex"}'"; - print "<tr>"; - - $color++; - print "<td align='center' $col><form method='post' action='showrequestfromport.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='port' value='$key[$s]'> <input type='submit' value='$Lang::tr{'details'}'></form></td>"; - print "<td align='center' $col>$key[$s]</td>"; - print "<td align='center' $col>$value[$s]</td>"; - print "<td align='center' $col>$percent</td>"; - print "</tr>"; + $show++; + $percent = $value[$s] * 100 / $linesjc; + $percent = sprintf("%.f", $percent); + $total = $total + $value[$s]; + # colors are numbered 1 to 10 + my $colorIndex = ($color % 10) + 1; + $col="bgcolor='$color{"color$colorIndex"}'"; + print "<tr>"; + + $color++; + print "<td align='center' $col><form method='post' action='showrequestfromport.dat'><input type='hidden' name='MONTH' value='$cgiparams{'MONTH'}'> <input type='hidden' name='DAY' value='$cgiparams{'DAY'}'> <input type='hidden' name='port' value='$key[$s]'> <input type='submit' value='$Lang::tr{'details'}'></form></td>"; + print "<td align='center' $col>$key[$s]</td>"; + print "<td align='center' $col>$value[$s]</td>"; + print "<td align='center' $col>$percent</td>"; + print "</tr>"; }
if($cgiparams{'otherspie'} == 2 ){} else{ - my $colorIndex = $color % 10; - if($colorIndex == 0) { - $colorIndex = 10; - } - $col="bgcolor='$color{"color$colorIndex"}'"; - print "<tr>"; - -if ( $linesjc ne "0") -{ -my $dif; -$dif = $linesjc - $total; -$percent = $dif * 100 / $linesjc; -$percent = sprintf("%.f", $percent); -print <<END -<td align='center' $col></td> -<td align='center' $col>$Lang::tr{'otherport'}</td> -<td align='center' $col>$dif</td> -<td align='center' $col>$percent</td> -</tr> + # colors are numbered 1 to 10 + my $colorIndex = ($color % 10) + 1; + $col="bgcolor='$color{"color$colorIndex"}'"; + print "<tr>"; + + if ( $linesjc ne "0") { + my $dif; + $dif = $linesjc - $total; + $percent = $dif * 100 / $linesjc; + $percent = sprintf("%.f", $percent); + print <<END + <td align='center' $col></td> + <td align='center' $col>$Lang::tr{'otherport'}</td> + <td align='center' $col>$dif</td> + <td align='center' $col>$percent</td> + </tr> END -; -} + ; + } } print <<END </table> @@ -479,20 +474,20 @@ END &Header::closepage();
sub findkey { - my $v; - foreach $v (@keytabjc) { - if ($tabjc{$v} eq $_[0]) { - delete $tabjc{$v}; - $key[$indice] = "$v"; - $value[$indice] = $_[0]; - $indice++; - last; - } - } + my $v; + foreach $v (@keytabjc) { + if ($tabjc{$v} eq $_[0]) { + delete $tabjc{$v}; + $key[$indice] = "$v"; + $value[$indice] = $_[0]; + $indice++; + last; + } + } }
sub checkversion { - #Automatic Updates is disabled - return "0","0"; + #Automatic Updates is disabled + return "0","0"; }
diff --git a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat index 5283c42..cd97f87 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromcountry.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromcountry.dat @@ -69,60 +69,60 @@ if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; }
if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then = (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy = $then[7]; - my $lastleap=($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap == 0 && $tdoy < 60) { - $doy=$tdoy+366; - } else { - $doy=$doy+365; - } - } + my @then = (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); + } else { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); + } + $tdoy = $then[7]; + my $lastleap=($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap == 0 && $tdoy < 60) { + $doy=$tdoy+366; + } else { + $doy=$doy+365; + } + } } my $datediff=0; my $dowd=0; my $multifile=0; if ($tdoy ne $doy) { - $datediff=int(($doy-$tdoy)/7); - $dowd=($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=$datediff+1; - } - if (($dow-$dowd)==0) { - $multifile=1; - } + $datediff=int(($doy-$tdoy)/7); + $dowd=($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=$datediff+1; + } + if (($dow-$dowd)==0) { + $multifile=1; + } }
my $monthstr = $shortmonths[$cgiparams{'MONTH'}]; @@ -138,16 +138,16 @@ else { my $skip=0; my $filestr=''; if ($datediff==0) { - $filestr="/var/log/messages"; + $filestr="/var/log/messages"; } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; }
if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - # Note: This is in case the log does not exist for that date + $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + # Note: This is in case the log does not exist for that date } my $lines = 0; my @log=(); @@ -156,24 +156,35 @@ my $gi = Geo::IP::PurePerl->new();
if (!$skip) { - while (<FILE>) - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - my $packet = $2; - $packet =~ /IN=(\w+)/; my $iface=$1; if ( $1 =~ /2./ ){ $iface="";} - $packet =~ /SRC=([\d.]+)/; my $srcaddr=$1; - - if($iface eq $country) { - $log[$lines] = $_; - $lines++; - } - elsif($srcaddr ne '') { - my $ccode = $gi->country_code_by_name($srcaddr); - if($ccode eq $country){ - $log[$lines] = $_; - $lines++; - } - } + while (<FILE>) { + # First check whether valid log line (date, day) + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + # If ipv6 uses bridge, then use PHYSIN otherwise use IN + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(PHYSIN=.*)$/) {} + elsif (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) {} + my $packet = $2; + my $iface = ''; + my $srcaddr = ''; + # If ipv6 uses bridge, use PHYSIN otherwise IN + if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; } + # Extract ipv4 and ipv6 addresses + if (($packet =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($packet =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { + $srcaddr = $1; + } + + if($iface eq $country) { + # iface matches country code + $log[$lines] = $_; + $lines++; + } + elsif($srcaddr ne '') { + # or srcaddr matches country code + my $ccode = $gi->country_code_by_name($srcaddr); + if($ccode eq uc($country)){ + $log[$lines] = $_; + $lines++; + } + } } } close (FILE); @@ -181,28 +192,40 @@ if (!$skip)
$skip=0; if ($multifile) { - $datediff=$datediff-1; - if ($datediff==0) { - $filestr="/var/log/messages"; - } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - } - if (!$skip) { + $datediff=$datediff-1; + if ($datediff==0) { + $filestr="/var/log/messages"; + } else { + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { + $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + } + if (!$skip) { while (<FILE>) { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - if($_ =~ /SRC=([\d.]+)/){ - my $srcaddr=$1; - my $ccode = $gi->country_code_by_name($srcaddr); - if($ccode eq $country){ - $log[$lines] = $_; - $lines++; - } - } + # Check if valid log line (date, day) + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + my $iface = ''; + # If ipv6 uses bridge, then use PHYSIN otherwise IN + if ($_ =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($_ =~ /IN=(\w+)/) { $iface = $1; } + + if($iface eq $country) { + # iface matches country code + $log[$lines] = $_; + $lines++; + } + # extract ipv4 and ipv6 address + elsif (($_ =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($_ =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { + my $srcaddr=$1; + my $ccode = $gi->country_code_by_name($srcaddr); + if($ccode eq uc($country)){ + # or srcaddr matches country code + $log[$lines] = $_; + $lines++; + } + } } } close (FILE); @@ -235,7 +258,8 @@ for ($month = 0; $month < 12; $month++) { print "\t<option "; if ($month == $cgiparams{'MONTH'}) { - print "selected='selected' "; } + print "selected='selected' "; + } print "value='$month'>$longmonths[$month]</option>\n"; } print <<END @@ -272,7 +296,8 @@ END print "<p><b>$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines</b></p>";
if ($start == -1) { - $start = $lines - ${Header::viewsize}; } + $start = $lines - ${Header::viewsize}; +} if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; }; if ($start < 0) { $start = 0; }
@@ -307,65 +332,80 @@ if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = reverse @slice; } $lines = 0; foreach $_ (@slice) { - $a = $_; - /^... (..) (..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/; - my $packet = $4; - $packet =~ /IN=(\w+)/; my $iface=$1; if ( $1 =~ /2./ ){ $iface="";} - $packet =~ /SRC=([\d.]+)/; my $srcaddr=$1; - - if($iface eq $country || $srcaddr ne '') { - my $ccode; - if($iface ne $country) { - $ccode = $gi->country_code_by_name($srcaddr); - } - if($iface eq $country || $ccode eq $country) { - my $chain = ''; - my $in = '-'; my $out = '-'; - my $srcaddr = ''; my $dstaddr = ''; - my $protostr = ''; - my $srcport = ''; my $dstport = ''; - - $_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/; - my $timestamp = $1; my $chain = $2; my $packet = $3; - $timestamp =~ /(...) (..) (..:..:..)/; - my $month = $1; my $day = $2; my $time = $3; - - if ($a =~ /IN=(\w+)/) { $iface = $1; } - if ($a =~ /OUT=(\w+)/) { $out = $1; } - if ($a =~ /SRC=([\d.]+)/) { $srcaddr = $1; } - if ($a =~ /DST=([\d.]+)/) { $dstaddr = $1; } - if ($a =~ /PROTO=(\w+)/) { $protostr = $1; } - my $protostrlc = lc($protostr); - if ($a =~ /SPT=([\d.]+)/){ $srcport = $1; } - if ($a =~ /DPT=([\d.]+)/){ $dstport = $1; } - - if ($lines % 2) { - print "<tr bgcolor='${Header::table1colour}'>\n"; } - else { - print "<tr bgcolor='${Header::table2colour}'>\n"; } - print <<END - <td align='center'>$time</td> - <td align='center'>$chain</td> - <td align='center'>$iface</td> - <td align='center'>$protostr</td> - <td align='center'> - <table width='100%' cellpadding='0' cellspacing='0'><tr> - <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td> - </tr></table> - </td> - <td align='center'>$srcport</td> - <td align='center'> - <table width='100%' cellpadding='0' cellspacing='0'><tr> - <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td> - </tr></table> - </td> - <td align='center'>$dstport</td> - </tr> + $a = $_; + # If ipv6 uses bridge, use PHYSIN otherwise use IN + if (/^... (..) (..:..:..) [\w-]+ kernel:(.*)(PHYSIN=.*)$/) {} + elsif (/^... (..) (..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/) {}; + my $packet = $4; + my $iface = ''; + # If ipv6 uses bridge, use PHYSIN otherwise use IN + if ($packet =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($packet =~ /IN=(\w+)/) { $iface = $1; } + if ( $1 =~ /2./ ){ $iface=""; } + my $srcaddr = ''; + # Extract ipv4 and ipv6 addresses + if (($packet =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($packet =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { + $srcaddr = $1; + }; + + if($iface eq $country || $srcaddr ne '') { + my $ccode=''; + if($iface ne $country) { + $ccode = $gi->country_code_by_name($srcaddr); + } + if($iface eq $country || $ccode eq uc($country)) { + my $chain = ''; + my $in = '-'; my $out = '-'; + my $srcaddr = ''; my $dstaddr = ''; + my $protostr = ''; + my $srcport = ''; my $dstport = ''; + + # If ipv6 uses bridge, the use PHYSIN otherwise use IN + if ($_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {} + elsif ($_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/) {} + my $timestamp = $1; my $chain = $2; my $packet = $3; + $timestamp =~ /(...) (..) (..:..:..)/; + my $month = $1; my $day = $2; my $time = $3; + + # If ipv6 uses bridge, use PHYSIN and PHYSOUT, otherwise use IN and OUT + if ($a =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($a =~ /IN=(\w+)/) { $iface = $1; } + if ($a =~ /PHYSOUT=(\w+)/) { $out = $1; } elsif ($a =~ /OUT=(\w+)/) { $out = $1; } + # Extract ipv4 and ipv6 addresses + if (($a =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($a =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; } + if (($a =~ /DST=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($a =~ /DST=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; } + if ($a =~ /PROTO=(\w+)/) { $protostr = $1; } + my $protostrlc = lc($protostr); + if ($a =~ /SPT=([\d.]+)/){ $srcport = $1; } + if ($a =~ /DPT=([\d.]+)/){ $dstport = $1; } + + if ($lines % 2) { + print "<tr bgcolor='${Header::table1colour}'>\n"; + } + else { + print "<tr bgcolor='${Header::table2colour}'>\n"; + } + print <<END + <td align='center'>$time</td> + <td align='center'>$chain</td> + <td align='center'>$iface</td> + <td align='center'>$protostr</td> + <td align='center'> + <table width='100%' cellpadding='0' cellspacing='0'><tr> + <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td> + </tr></table> + </td> + <td align='center'>$srcport</td> + <td align='center'> + <table width='100%' cellpadding='0' cellspacing='0'><tr> + <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td> + </tr></table> + </td> + <td align='center'>$dstport</td> + </tr> END - ; - $lines++; - } - } + ; + $lines++; + } + } }
print <<END @@ -383,30 +423,34 @@ END
sub oldernewer { - print <<END - <table width='100%'> - <tr> + print <<END + <table width='100%'> + <tr> END -; + ;
- print "<td align='center' width='50%'>"; - if ($prev != -1) { - print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'older'}</a>"; } - else { - print "$Lang::tr{'older'}"; } - print "</td>\n"; + print "<td align='center' width='50%'>"; + if ($prev != -1) { + print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'older'}</a>"; + } + else { + print "$Lang::tr{'older'}"; + } + print "</td>\n";
- print "<td align='center' width='50%'>"; - if ($next != -1) { - print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'newer'}</a>"; } - else { - print "$Lang::tr{'newer'}"; } - print "</td>\n"; + print "<td align='center' width='50%'>"; + if ($next != -1) { + print "<a href='/cgi-bin/logs.cgi/showrequestfromcountry.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{country}'>$Lang::tr{'newer'}</a>"; + } + else { + print "$Lang::tr{'newer'}"; + }
-print <<END - </tr> - </table> + print "</td>\n"; + print <<END + </tr> + </table> END -; + ; }
diff --git a/html/cgi-bin/logs.cgi/showrequestfromip.dat b/html/cgi-bin/logs.cgi/showrequestfromip.dat index 09a60b5..154fa40 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromip.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromip.dat @@ -66,60 +66,60 @@ if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; }
if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then = (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy = $then[7]; - my $lastleap=($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap == 0 && $tdoy < 60) { - $doy=$tdoy+366; - } else { - $doy=$doy+365; - } - } + my @then = (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); + } else { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); + } + $tdoy = $then[7]; + my $lastleap=($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap == 0 && $tdoy < 60) { + $doy=$tdoy+366; + } else { + $doy=$doy+365; + } + } } my $datediff=0; my $dowd=0; my $multifile=0; if ($tdoy ne $doy) { - $datediff=int(($doy-$tdoy)/7); - $dowd=($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=$datediff+1; - } - if (($dow-$dowd)==0) { - $multifile=1; - } + $datediff=int(($doy-$tdoy)/7); + $dowd=($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=$datediff+1; + } + if (($dow-$dowd)==0) { + $multifile=1; + } }
my $monthstr = $shortmonths[$cgiparams{'MONTH'}]; @@ -135,16 +135,16 @@ else { my $skip=0; my $filestr=''; if ($datediff==0) { - $filestr="/var/log/messages"; + $filestr="/var/log/messages"; } else { $filestr="/var/log/messages.$datediff"; $filestr = "$filestr.gz" if -f "$filestr.gz"; }
if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - # Note: This is in case the log does not exist for that date + $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + # Note: This is in case the log does not exist for that date } my $lines = 0; my @log=(); @@ -152,15 +152,14 @@ my $ip = $cgiparams{ip};
if (!$skip) { - while (<FILE>) - { + while (<FILE>) { if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - if($_ =~ /SRC=([\d.]+)/){ - if($1 eq $ip){ - $log[$lines] = $_; - $lines++; - } - } + if (($_ =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($_ =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { + if($1 eq $ip){ + $log[$lines] = $_; + $lines++; + } + } } } close (FILE); @@ -168,26 +167,26 @@ if (!$skip)
$skip=0; if ($multifile) { - $datediff=$datediff-1; - if ($datediff==0) { - $filestr="/var/log/messages"; - } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - } - if (!$skip) { + $datediff=$datediff-1; + if ($datediff==0) { + $filestr="/var/log/messages"; + } else { + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { + $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + } + if (!$skip) { while (<FILE>) { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - if($_ =~ /SRC=([\d.]+)/){ - if($1 eq $ip){ - $log[$lines] = $_; - $lines++; - } - } + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + if (($_ =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($_ =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { + if($1 eq $ip){ + $log[$lines] = $_; + $lines++; + } + } } } close (FILE); @@ -257,7 +256,8 @@ END print "<p><b>$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines</b></p>";
if ($start == -1) { - $start = $lines - ${Header::viewsize}; } + $start = $lines - ${Header::viewsize}; +} if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; }; if ($start < 0) { $start = 0; }
@@ -290,58 +290,64 @@ my @slice = splice(@log, $start, ${Header::viewsize}); if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = reverse @slice; }
$lines = 0; -foreach $_ (@slice) -{ - $a = $_; - if($_ =~ /SRC=([\d.]+)/){ - if($1 eq $ip){ - my $chain = ''; - my $in = '-'; my $out = '-'; - my $srcaddr = ''; my $dstaddr = ''; - my $protostr = ''; - my $srcport = ''; my $dstport = ''; - - $_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/; - my $timestamp = $1; my $chain = $2; my $packet = $3; - $timestamp =~ /(...) (..) (..:..:..)/; - my $month = $1; my $day = $2; my $time = $3; - - if ($a =~ /IN=(\w+)/) { $iface = $1; } - if ($a =~ /OUT=(\w+)/) { $out = $1; } - if ($a =~ /SRC=([\d.]+)/) { $srcaddr = $1; } - if ($a =~ /DST=([\d.]+)/) { $dstaddr = $1; } - if ($a =~ /PROTO=(\w+)/) { $protostr = $1; } - my $protostrlc = lc($protostr); - if ($a =~ /SPT=([\d.]+)/){ $srcport = $1; } - if ($a =~ /DPT=([\d.]+)/){ $dstport = $1; } - - if ($lines % 2) { - print "<tr bgcolor='${Header::table1colour}'>\n"; } - else { - print "<tr bgcolor='${Header::table2colour}'>\n"; } - print <<END - <td align='center'>$time</td> - <td align='center'>$chain</td> - <td align='center'>$iface</td> - <td align='center'>$protostr</td> - <td align='center'> - <table width='100%' cellpadding='0' cellspacing='0'><tr> - <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td> - </tr></table> - </td> - <td align='center'>$srcport</td> - <td align='center'> - <table width='100%' cellpadding='0' cellspacing='0'><tr> - <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td> - </tr></table> - </td> - <td align='center'>$dstport</td> -</tr> +foreach $_ (@slice) { + $a = $_; + # Check whether valid ipv4 or ipv6 address + if (($_ =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($_ =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { + if($1 eq $ip) { + my $chain = ''; + my $in = '-'; my $out = '-'; + my $srcaddr = ''; my $dstaddr = ''; + my $protostr = ''; + my $srcport = ''; my $dstport = ''; + + # If ipv6 uses bridge, the use PHYSIN, otherwise use IN + if ($_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {} + elsif ($_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/) {} + my $timestamp = $1; my $chain = $2; my $packet = $3; + $timestamp =~ /(...) (..) (..:..:..)/; + my $month = $1; my $day = $2; my $time = $3; + + # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use IN and OUT + if ($a =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($a =~ /IN=(\w+)/) { $iface = $1; } + if ($a =~ /PHYSOUT=(\w+)/) { $out = $1; } elsif ($a =~ /OUT=(\w+)/) { $out = $1; } + # Detect ipv4 and ipv6 addresses + if (($a =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($a =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; } + if (($a =~ /DST=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($a =~ /DST=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; } + if ($a =~ /PROTO=(\w+)/) { $protostr = $1; } + my $protostrlc = lc($protostr); + if ($a =~ /SPT=([\d.]+)/){ $srcport = $1; } + if ($a =~ /DPT=([\d.]+)/){ $dstport = $1; } + + if ($lines % 2) { + print "<tr bgcolor='${Header::table1colour}'>\n"; + } + else { + print "<tr bgcolor='${Header::table2colour}'>\n"; + } + print <<END + <td align='center'>$time</td> + <td align='center'>$chain</td> + <td align='center'>$iface</td> + <td align='center'>$protostr</td> + <td align='center'> + <table width='100%' cellpadding='0' cellspacing='0'><tr> + <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td> + </tr></table> + </td> + <td align='center'>$srcport</td> + <td align='center'> + <table width='100%' cellpadding='0' cellspacing='0'><tr> + <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td> + </tr></table> + </td> + <td align='center'>$dstport</td> + </tr> END - ; - $lines++; - } - } + ; + $lines++; + } + } }
print <<END @@ -359,29 +365,33 @@ END
sub oldernewer { -print <<END -<table width='100%'> -<tr> + print <<END + <table width='100%'> + <tr> END -; + ;
-print "<td align='center' width='50%'>"; -if ($prev != -1) { - print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'older'}</a>"; } -else { - print "$Lang::tr{'older'}"; } -print "</td>\n"; + print "<td align='center' width='50%'>"; + if ($prev != -1) { + print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'older'}</a>"; + } + else { + print "$Lang::tr{'older'}"; + } + print "</td>\n";
-print "<td align='center' width='50%'>"; -if ($next != -1) { - print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'newer'}</a>"; } -else { - print "$Lang::tr{'newer'}"; } -print "</td>\n"; + print "<td align='center' width='50%'>"; + if ($next != -1) { + print "<a href='/cgi-bin/logs.cgi/showrequestfromip.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{ip}'>$Lang::tr{'newer'}</a>"; + } + else { + print "$Lang::tr{'newer'}"; + } + print "</td>\n";
-print <<END -</tr> -</table> + print <<END + </tr> + </table> END -; + ; } diff --git a/html/cgi-bin/logs.cgi/showrequestfromport.dat b/html/cgi-bin/logs.cgi/showrequestfromport.dat index ad9823c..e1f00ae 100644 --- a/html/cgi-bin/logs.cgi/showrequestfromport.dat +++ b/html/cgi-bin/logs.cgi/showrequestfromport.dat @@ -73,60 +73,60 @@ if (!($cgiparams{'MONTH'} =~ /^(0|1|2|3|4|5|6|7|8|9|10|11)$/) || } elsif($cgiparams{'ACTION'} eq '>>') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); - ## Retrieve the same time on the next day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) + 86400); + ## Retrieve the same time on the next day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; } elsif($cgiparams{'ACTION'} eq '<<') { - my @temp_then=(); - my @temp_now = localtime(time); - $temp_now[4] = $cgiparams{'MONTH'}; - $temp_now[3] = $cgiparams{'DAY'}; - @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); - ## Retrieve the same time on the previous day - - ## 86400 seconds in a day - $cgiparams{'MONTH'} = $temp_then[4]; - $cgiparams{'DAY'} = $temp_then[3]; + my @temp_then=(); + my @temp_now = localtime(time); + $temp_now[4] = $cgiparams{'MONTH'}; + $temp_now[3] = $cgiparams{'DAY'}; + @temp_then = localtime(POSIX::mktime(@temp_now) - 86400); + ## Retrieve the same time on the previous day - + ## 86400 seconds in a day + $cgiparams{'MONTH'} = $temp_then[4]; + $cgiparams{'DAY'} = $temp_then[3]; }
if (($cgiparams{'DAY'} ne $now[3]) || ($cgiparams{'MONTH'} ne $now[4])) { - my @then = (); - if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || - ( $cgiparams{'MONTH'} > $now[4] ) ) { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); - } else { - @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); - } - $tdoy = $then[7]; - my $lastleap=($year-1)%4; - if ($tdoy>$doy) { - if ($lastleap == 0 && $tdoy < 60) { - $doy=$tdoy+366; - } else { - $doy=$doy+365; - } - } + my @then = (); + if ( ( $cgiparams{'MONTH'} eq $now[4]) && ($cgiparams{'DAY'} > $now[3]) || + ( $cgiparams{'MONTH'} > $now[4] ) ) { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1901 )); + } else { + @then = localtime(POSIX::mktime( 0, 0, 0, $cgiparams{'DAY'}, $cgiparams{'MONTH'}, $year - 1900 )); + } + $tdoy = $then[7]; + my $lastleap=($year-1)%4; + if ($tdoy>$doy) { + if ($lastleap == 0 && $tdoy < 60) { + $doy=$tdoy+366; + } else { + $doy=$doy+365; + } + } } my $datediff=0; my $dowd=0; my $multifile=0; if ($tdoy ne $doy) { - $datediff=int(($doy-$tdoy)/7); - $dowd=($doy-$tdoy)%7; - if (($dow-$dowd)<1) { - $datediff=$datediff+1; - } - if (($dow-$dowd)==0) { - $multifile=1; - } + $datediff=int(($doy-$tdoy)/7); + $dowd=($doy-$tdoy)%7; + if (($dow-$dowd)<1) { + $datediff=$datediff+1; + } + if (($dow-$dowd)==0) { + $multifile=1; + } }
my $monthstr = $shortmonths[$cgiparams{'MONTH'}]; @@ -142,16 +142,16 @@ else { my $skip=0; my $filestr=''; if ($datediff==0) { - $filestr="/var/log/messages"; + $filestr="/var/log/messages"; } else { $filestr="/var/log/messages.$datediff"; $filestr = "$filestr.gz" if -f "$filestr.gz"; }
if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - # Note: This is in case the log does not exist for that date + $errormessage = "$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + # Note: This is in case the log does not exist for that date } my $lines = 0; my @log=(); @@ -159,15 +159,15 @@ my $port = $cgiparams{port};
if (!$skip) { - while (<FILE>) - { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - if($_ =~ /DPT=([\d.]+)/){ - if($1 eq $port){ - $log[$lines] = $_; - $lines++; - } - } + while (<FILE>) + { + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + if($_ =~ /DPT=([\d.]+)/){ + if($1 eq $port){ + $log[$lines] = $_; + $lines++; + } + } } } close (FILE); @@ -175,26 +175,26 @@ if (!$skip)
$skip=0; if ($multifile) { - $datediff=$datediff-1; - if ($datediff==0) { - $filestr="/var/log/messages"; - } else { - $filestr="/var/log/messages.$datediff"; - $filestr = "$filestr.gz" if -f "$filestr.gz"; - } - if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { - $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; - $skip=1; - } - if (!$skip) { + $datediff=$datediff-1; + if ($datediff==0) { + $filestr="/var/log/messages"; + } else { + $filestr="/var/log/messages.$datediff"; + $filestr = "$filestr.gz" if -f "$filestr.gz"; + } + if (!(open (FILE,($filestr =~ /.gz$/ ? "gzip -dc $filestr |" : $filestr)))) { + $errormessage="$Lang::tr{'date not in logs'}: $filestr $Lang::tr{'could not be opened'}"; + $skip=1; + } + if (!$skip) { while (<FILE>) { - if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { - if($_ =~ /DPT=([\d.]+)/){ - if($1 eq $port){ - $log[$lines] = $_; - $lines++; - } - } + if (/(^${monthstr} ${daystr} ..:..:..) [\w-]+ kernel:.*(IN=.*)$/) { + if($_ =~ /DPT=([\d.]+)/){ + if($1 eq $port){ + $log[$lines] = $_; + $lines++; + } + } } } close (FILE); @@ -264,7 +264,8 @@ END print "<p><b>$Lang::tr{'firewall hits'} $longmonthstr $daystr: $lines</b></p>";
if ($start == -1) { - $start = $lines - ${Header::viewsize}; } + $start = $lines - ${Header::viewsize}; +} if ($start >= $lines - ${Header::viewsize}) { $start = $lines - ${Header::viewsize}; }; if ($start < 0) { $start = 0; }
@@ -298,56 +299,65 @@ if ($logsettings{'LOGVIEW_REVERSE'} eq 'on') { @slice = reverse @slice; } $lines = 0; foreach $_ (@slice) { - $a = $_; - if($_ =~ /DPT=([\d.]+)/){ - if($1 eq $port){ - my $chain = ''; - my $in = '-'; my $out = '-'; - my $srcaddr = ''; my $dstaddr = ''; - my $protostr = ''; - my $srcport = ''; my $dstport = ''; - - $_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/; - my $timestamp = $1; my $chain = $2; my $packet = $3; - $timestamp =~ /(...) (..) (..:..:..)/; - my $month = $1; my $day = $2; my $time = $3; my $iface; - - if ($a =~ /IN=(\w+)/) { $iface = $1; } - if ($a =~ /OUT=(\w+)/) { $out = $1; } - if ($a =~ /SRC=([\d.]+)/) { $srcaddr = $1; } - if ($a =~ /DST=([\d.]+)/) { $dstaddr = $1; } - if ($a =~ /PROTO=(\w+)/) { $protostr = $1; } - my $protostrlc = lc($protostr); - if ($a =~ /SPT=([\d.]+)/){ $srcport = $1; } - if ($a =~ /DPT=([\d.]+)/){ $dstport = $1; } - - if ($lines % 2) { - print "<tr bgcolor='${Header::table1colour}'>\n"; } - else { - print "<tr bgcolor='${Header::table2colour}'>\n"; } - print <<END - <td align='center'>$time</td> - <td align='center'>$chain</td> - <td align='center'>$iface</td> - <td align='center'>$protostr</td> - <td align='center'> - <table width='100%' cellpadding='0' cellspacing='0'><tr> - <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td> - </tr></table> - </td> - <td align='center'>$srcport</td> - <td align='center'> - <table width='100%' cellpadding='0' cellspacing='0'><tr> - <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td> - </tr></table> - </td> - <td align='center'>$dstport</td> -</tr> + $a = $_; + if($_ =~ /DPT=([\d.]+)/){ + if($1 eq $port){ + my $chain = ''; + my $in = '-'; + my $out = '-'; + my $srcaddr = ''; + my $dstaddr = ''; + my $protostr = ''; + my $srcport = ''; + my $dstport = ''; + + # If ipv6 uses bridge, the use PHYSIN, otherwise use IN + if ($_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)(PHYSIN=.*)$/) {} + elsif ($_ =~ /(^.* ..:..:..) [\w-]+ kernel:(.*)(IN=.*)$/) {} + my $timestamp = $1; my $chain = $2; my $packet = $3; + $timestamp =~ /(...) (..) (..:..:..)/; + my $month = $1; my $day = $2; my $time = $3; my $iface; + + # If ipv6 uses bridge, the use PHYSIN and PHYSOUT, otherwise use IN and OUT + if ($a =~ /PHYSIN=(\w+)/) { $iface = $1; } elsif ($a =~ /IN=(\w+)/) { $iface = $1; } + if ($a =~ /PHYSOUT=(\w+)/) { $out = $1; } elsif ($a =~ /OUT=(\w+)/) { $out = $1; } + # Detect ipv4 and ipv6 addresses + if (($a =~ /SRC=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($a =~ /SRC=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { $srcaddr = $1; } + if (($a =~ /DST=(([\d]{1,3})(.([\d]{1,3})){3})/) or ($a =~ /DST=(([0-9a-fA-F]{0,4})(:([0-9a-fA-F]{0,4})){2,7})/)) { $dstaddr = $1; } + if ($a =~ /PROTO=(\w+)/) { $protostr = $1; } + my $protostrlc = lc($protostr); + if ($a =~ /SPT=([\d.]+)/){ $srcport = $1; } + if ($a =~ /DPT=([\d.]+)/){ $dstport = $1; } + + if ($lines % 2) { + print "<tr bgcolor='${Header::table1colour}'>\n"; + } + else { + print "<tr bgcolor='${Header::table2colour}'>\n"; + } + print <<END + <td align='center'>$time</td> + <td align='center'>$chain</td> + <td align='center'>$iface</td> + <td align='center'>$protostr</td> + <td align='center'> + <table width='100%' cellpadding='0' cellspacing='0'><tr> + <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$srcaddr'>$srcaddr</a></td> + </tr></table> + </td> + <td align='center'>$srcport</td> + <td align='center'> + <table width='100%' cellpadding='0' cellspacing='0'><tr> + <td align='center'><a href='/cgi-bin/ipinfo.cgi?ip=$dstaddr'>$dstaddr</a></td> + </tr></table> + </td> + <td align='center'>$dstport</td> + </tr> END - ; - $lines++; - } - } + ; + $lines++; + } + } }
print <<END @@ -365,30 +375,34 @@ END
sub oldernewer { -print <<END -<table width='100%'> -<tr> + print <<END + <table width='100%'> + <tr> END -; + ;
-print "<td align='center' width='50%'>"; -if ($prev != -1) { - print "<a href='/cgi-bin/logs.cgi/showrequestfromport.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{port}'>$Lang::tr{'older'}</a>"; } -else { - print "$Lang::tr{'older'}"; } -print "</td>\n"; + print "<td align='center' width='50%'>"; + if ($prev != -1) { + print "<a href='/cgi-bin/logs.cgi/showrequestfromport.dat?$prev,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{port}'>$Lang::tr{'older'}</a>"; + } + else { + print "$Lang::tr{'older'}"; + } + print "</td>\n";
-print "<td align='center' width='50%'>"; -if ($next != -1) { - print "<a href='/cgi-bin/logs.cgi/showrequestfromport.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{port}'>$Lang::tr{'newer'}</a>"; } -else { - print "$Lang::tr{'newer'}"; } -print "</td>\n"; + print "<td align='center' width='50%'>"; + if ($next != -1) { + print "<a href='/cgi-bin/logs.cgi/showrequestfromport.dat?$next,$cgiparams{'MONTH'},$cgiparams{'DAY'},$cgiparams{port}'>$Lang::tr{'newer'}</a>"; + } + else { + print "$Lang::tr{'newer'}"; + } + print "</td>\n";
-print <<END -</tr> -</table> + print <<END + </tr> + </table> END -; + ; }
diff --git a/html/cgi-bin/optionsfw.cgi b/html/cgi-bin/optionsfw.cgi index 34e0cdc..7a0e8e0 100644 --- a/html/cgi-bin/optionsfw.cgi +++ b/html/cgi-bin/optionsfw.cgi @@ -120,6 +120,21 @@ $checked{'SHOWTABLES'}{$settings{'SHOWTABLES'}} = "checked='checked'"; $checked{'SHOWDROPDOWN'}{'off'} = ''; $checked{'SHOWDROPDOWN'}{'on'} = ''; $checked{'SHOWDROPDOWN'}{$settings{'SHOWDROPDOWN'}} = "checked='checked'"; +$checked{'CONNTRACK_FTP'}{'off'} = ''; +$checked{'CONNTRACK_FTP'}{'on'} = ''; +$checked{'CONNTRACK_FTP'}{$settings{'CONNTRACK_FTP'}} = "checked='checked'"; +$checked{'CONNTRACK_H323'}{'off'} = ''; +$checked{'CONNTRACK_H323'}{'on'} = ''; +$checked{'CONNTRACK_H323'}{$settings{'CONNTRACK_H323'}} = "checked='checked'"; +$checked{'CONNTRACK_IRC'}{'off'} = ''; +$checked{'CONNTRACK_IRC'}{'on'} = ''; +$checked{'CONNTRACK_IRC'}{$settings{'CONNTRACK_IRC'}} = "checked='checked'"; +$checked{'CONNTRACK_SIP'}{'off'} = ''; +$checked{'CONNTRACK_SIP'}{'on'} = ''; +$checked{'CONNTRACK_SIP'}{$settings{'CONNTRACK_SIP'}} = "checked='checked'"; +$checked{'CONNTRACK_TFTP'}{'off'} = ''; +$checked{'CONNTRACK_TFTP'}{'on'} = ''; +$checked{'CONNTRACK_TFTP'}{$settings{'CONNTRACK_TFTP'}} = "checked='checked'"; $selected{'FWPOLICY'}{$settings{'FWPOLICY'}}= 'selected'; $selected{'FWPOLICY1'}{$settings{'FWPOLICY1'}}= 'selected'; $selected{'FWPOLICY2'}{$settings{'FWPOLICY2'}}= 'selected'; @@ -223,7 +238,22 @@ END <input type='radio' name='SHOWTABLES' value='off' $checked{'SHOWTABLES'}{'off'} /> off</td></tr> <tr><td align='left' width='60%'>$Lang::tr{'fw settings dropdown'}</td><td align='left'>on <input type='radio' name='SHOWDROPDOWN' value='on' $checked{'SHOWDROPDOWN'}{'on'} />/ <input type='radio' name='SHOWDROPDOWN' value='off' $checked{'SHOWDROPDOWN'}{'off'} /> off</td></tr> -</table> +</table> +<br /> +<table width='95%' cellspacing='0'> +<tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'application layer gateways'}</b></td></tr> +<tr><td align='left' width='60%'>FTP</td><td align='left'>on <input type='radio' name='CONNTRACK_FTP' value='on' $checked{'CONNTRACK_FTP'}{'on'} />/ + <input type='radio' name='CONNTRACK_FTP' value='off' $checked{'CONNTRACK_FTP'}{'off'} /> off</td></tr> +<tr><td align='left' width='60%'>H.323</td><td align='left'>on <input type='radio' name='CONNTRACK_H323' value='on' $checked{'CONNTRACK_H323'}{'on'} />/ + <input type='radio' name='CONNTRACK_H323' value='off' $checked{'CONNTRACK_H323'}{'off'} /> off</td></tr> +<tr><td align='left' width='60%'>IRC</td><td align='left'>on <input type='radio' name='CONNTRACK_IRC' value='on' $checked{'CONNTRACK_IRC'}{'on'} />/ + <input type='radio' name='CONNTRACK_IRC' value='off' $checked{'CONNTRACK_IRC'}{'off'} /> off</td></tr> +<tr><td align='left' width='60%'>SIP</td><td align='left'>on <input type='radio' name='CONNTRACK_SIP' value='on' $checked{'CONNTRACK_SIP'}{'on'} />/ + <input type='radio' name='CONNTRACK_SIP' value='off' $checked{'CONNTRACK_SIP'}{'off'} /> off</td></tr> +<tr><td align='left' width='60%'>TFTP</td><td align='left'>on <input type='radio' name='CONNTRACK_TFTP' value='on' $checked{'CONNTRACK_TFTP'}{'on'} />/ + <input type='radio' name='CONNTRACK_TFTP' value='off' $checked{'CONNTRACK_TFTP'}{'off'} /> off</td></tr> + +</table> <br /> <table width='95%' cellspacing='0'> <tr bgcolor='$color{'color20'}'><td colspan='2' align='left'><b>$Lang::tr{'fw default drop'}</b></td></tr> diff --git a/html/cgi-bin/ovpnmain.cgi b/html/cgi-bin/ovpnmain.cgi index 62af54e..037894d 100644 --- a/html/cgi-bin/ovpnmain.cgi +++ b/html/cgi-bin/ovpnmain.cgi @@ -2333,7 +2333,7 @@ else } print CLIENTCONF "verb 3\r\n"; print CLIENTCONF "ns-cert-type server\r\n"; - print CLIENTCONF "tls-remote $vpnsettings{ROOTCERT_HOSTNAME}\r\n"; + print CLIENTCONF "verify-x509-name $vpnsettings{ROOTCERT_HOSTNAME} name\r\n"; if ($vpnsettings{MSSFIX} eq 'on') { print CLIENTCONF "mssfix\r\n"; } diff --git a/html/cgi-bin/qos.cgi b/html/cgi-bin/qos.cgi index 39c3ed8..590ad15 100644 --- a/html/cgi-bin/qos.cgi +++ b/html/cgi-bin/qos.cgi @@ -463,18 +463,16 @@ if ($qossettings{'ACTION'} eq $Lang::tr{'start'}) $qossettings{'ENABLED'} = 'on'; &General::writehash("${General::swroot}/qos/settings", %qossettings); system("/usr/local/bin/qosctrl generate >/dev/null 2>&1"); - system("/usr/bin/touch /var/ipfire/qos/enable"); system("/usr/local/bin/qosctrl start >/dev/null 2>&1"); system("logger -t ipfire 'QoS started'"); } elsif ($qossettings{'ACTION'} eq $Lang::tr{'stop'}) { - system("/usr/local/bin/qosctrl stop >/dev/null 2>&1"); - unlink "/var/ipfire/qos/bin/qos.sh"; - unlink "/var/ipfire/qos/enable"; - system("logger -t ipfire 'QoS stopped'"); $qossettings{'ENABLED'} = 'off'; &General::writehash("${General::swroot}/qos/settings", %qossettings); + system("/usr/local/bin/qosctrl stop >/dev/null 2>&1"); + system("/usr/local/bin/qosctrl generate >/dev/null 2>&1"); + system("logger -t ipfire 'QoS stopped'"); } elsif ($qossettings{'ACTION'} eq $Lang::tr{'restart'}) { @@ -587,7 +585,6 @@ END $qossettings{'ENABLED'} = 'on'; &General::writehash("${General::swroot}/qos/settings", %qossettings); system("/usr/local/bin/qosctrl generate >/dev/null 2>&1"); - system("/usr/bin/touch /var/ipfire/qos/enable"); system("/usr/local/bin/qosctrl start >/dev/null 2>&1"); system("logger -t ipfire 'QoS started'"); } else { diff --git a/html/cgi-bin/webaccess.cgi b/html/cgi-bin/webaccess.cgi index afa3770..0d50f01 100644 --- a/html/cgi-bin/webaccess.cgi +++ b/html/cgi-bin/webaccess.cgi @@ -19,8 +19,18 @@ # # ###############################################################################
+use strict; + +#usable only the following on debugging purpose +#use warnings; +#use CGI::Carp 'fatalsToBrowser'; use CGI;
+require '/var/ipfire/general-functions.pl'; +require "${General::swroot}/lang.pl"; +require "${General::swroot}/header.pl"; + + my $swroot = "/var/ipfire"; my $apdir = "$swroot/proxy/advanced"; my $group_def_file = "$apdir/cre/classrooms"; @@ -31,6 +41,7 @@ my $acl_src_noaccess_mac = "$apdir/acls/src_noaccess_mac.acl"; my $banner = "A D V A N C E D P R O X Y - W E B A C C E S S M A N A G E R"; my %cgiparams; my %proxysettings; +my %temp;
my %acl=(); my @group_defs=(); @@ -49,8 +60,8 @@ require "${swroot}/lang.pl";
foreach (@groups) { - if ($cgiparams{$_} eq $tr{'advproxy mode deny'}) { $acl{$_}='on'; } - if ($cgiparams{$_} eq $tr{'advproxy mode allow'}) { $acl{$_}='off'; } + if ($cgiparams{$_} eq $Lang::tr{'advproxy mode deny'}) { $acl{$_}='on'; } + if ($cgiparams{$_} eq $Lang::tr{'advproxy mode allow'}) { $acl{$_}='off'; } }
&read_all_groups; @@ -144,7 +155,7 @@ if (($is_supervisor) && ((defined($proxysettings{'SUPERVISOR_PASSWORD'})) && (!( { print <<END <td align='center'> - <font face='verdana,arial,helvetica' color='#000000' size='2'>$tr{'advproxy supervisor password'}:</font> + <font face='verdana,arial,helvetica' color='#000000' size='2'>$Lang::tr{'advproxy supervisor password'}:</font> </td> <td align='center'><input type='password' name='PASSWORD' size='15'></td> END @@ -176,11 +187,11 @@ END if ((defined($acl{$_})) && ($acl{$_} eq 'on')) { print "</td><td width='120' align='center'>"; - print "<input type='submit' name='$_' value=' $tr{'advproxy mode allow'} '>"; + print "<input type='submit' name='$_' value=' $Lang::tr{'advproxy mode allow'} '>"; print "</td><td width='16' bgcolor='#D00000'> </td>\n"; } else { print "</td><td width='120' align='center'>"; - print "<input type='submit' name='$_' value=' $tr{'advproxy mode deny'} '>"; + print "<input type='submit' name='$_' value=' $Lang::tr{'advproxy mode deny'} '>"; print "</td><td width='16' bgcolor='#00A000'> </td>\n"; } } @@ -199,14 +210,14 @@ END } else { print " <tr>\n"; print " <td align='center'>\n"; - print " <font face='verdana,arial,helvetica' color='#000000' size='2'>$tr{'advproxy no cre groups'}</font>\n"; + print " <font face='verdana,arial,helvetica' color='#000000' size='2'>$Lang::tr{'advproxy no cre groups'}</font>\n"; print " </td>\n"; print " </tr>\n"; } } else { print " <tr>\n"; print " <td align='center'>\n"; - print " <font face='verdana,arial,helvetica' color='#000000' size='2'>$tr{'advproxy cre disabled'}</font>\n"; + print " <font face='verdana,arial,helvetica' color='#000000' size='2'>$Lang::tr{'advproxy cre disabled'}</font>\n"; print " </td>\n"; print " </tr>\n"; } diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 2bca854..7c330bb 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -367,6 +367,7 @@ 'alt vpn' => 'VPNs', 'and' => 'Und', 'apcupsd' => 'APC-UPS Status', +'application layer gateways' => 'Application-Layer-Gateways', 'apply' => 'Jetzt anwenden', 'april' => 'April', 'archive not exist' => 'Konfigurationsarchiv existiert nicht', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index 4c52392..23f6310 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -369,6 +369,7 @@ 'and' => 'And', 'ansi t1.483' => 'TO BE REMOVED', 'apcupsd' => 'APC-UPS status', +'application layer gateways' => 'Application Layer Gateways', 'apply' => 'Apply now', 'april' => 'April', 'archive not exist' => 'Configuration archive does not exist', diff --git a/lfs/Config b/lfs/Config index a65b0cf..4de8bd3 100644 --- a/lfs/Config +++ b/lfs/Config @@ -35,7 +35,7 @@ # URL_IPFIRE = http://source.ipfire.org/source-2.x URL_TOOLCHAIN = http://source.ipfire.org/toolchains -URL_SOURCE = source.ipfire.org:/pub/source/source-2.x +URL_SOURCE = git.ipfire.org:/pub/sources/source-2.x
# Don't change this; it will be overridden by other makefiles where necessary. # @@ -57,6 +57,9 @@ DIR_CONF = $(LFS_BASEDIR)/config DIR_INFO = $(LFS_BASEDIR)/log DIR_TMP = /tmp
+# Add the compiler location and version and specs to the ccache hash +CCACHE_COMPILERCHECK += $(shell gcc -dumpspecs 2>/dev/null | md5sum | cut -d ' ' -f1) + ############################################################################### # Common Macro Definitions ############################################################################### diff --git a/lfs/ath10k-firmware b/lfs/ath10k-firmware new file mode 100644 index 0000000..cf01943 --- /dev/null +++ b/lfs/ath10k-firmware @@ -0,0 +1,72 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 20160319 + +THISAPP = ath10k-firmware-$(VER) +DL_FILE = $(THISAPP).tar.xz +DL_FROM = $(URL_IPFIRE) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = 207fc1b8a9b74392952d6662df0c03d3 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @cd /lib/firmware && tar axf $(DIR_DL)/$(DL_FILE) + @$(POSTBUILD) diff --git a/lfs/backports b/lfs/backports index ab6fbdc..39fa9b2 100644 --- a/lfs/backports +++ b/lfs/backports @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2015 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -26,7 +26,7 @@ include Config
VERSUFIX = ipfire$(KCFG)
-VER = 3.18.1-1 +VER = 4.2.6-1
THISAPP = backports-$(VER) DL_FILE = $(THISAPP).tar.xz @@ -46,7 +46,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 6cef5f2c800e12441d2cba9fa42b6a5b +$(DL_FILE)_MD5 = 3f978eb56473d9289cf21ebbcb5aa80b
install : $(TARGET)
@@ -78,23 +78,28 @@ $(subst %,%_MD5,$(objects)) :
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) + + # remove replaced kernel modules + rm -rf /lib/modules/$(KVER)-$(VERSUFIX)/kernel/drivers/net/wireless/rtl818x/rtl8180/rtl8180.ko + rm -rf /lib/modules/$(KVER)-$(VERSUFIX)/kernel/drivers/media + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar Jxf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-3.18.1-1-ipfire-build.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-3.18.1-1-grsecurity.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-3.18.1-1-add_usbnet_modules.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-4.2.6-1-grsecurity.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-4.2.6-1-add_usbnet_modules.patch ifeq "$(MACHINE)" "x86_64" cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-3.18.1-1_no_dma_sgtable_on_x86_64.patch endif
# DVB patches cd $(DIR_APP) && patch -Np2 < $(DIR_SRC)/src/patches/v4l-dvb_fix_tua6034_pll.patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10-dvb_tevi_s482.patch
# Wlan patches cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/compat-drivers-3.8.3-ath_ignore_eeprom_regdomain.patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.22-iwlwifi-noibss_only_on_radar_chan.patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.10.37-rt2800usb_add_dlink_dwa137_usbid.patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-3.18.1-1_rt2x00usb_suppress_queue_warnings.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-4.2.6-1-mt7601_upstream_fixes.patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/backports-3.18.1-1_add_libertas_uap.patch
# smsc mac address patch for pandaboard and raspberry pi @@ -110,9 +115,6 @@ endif
# Disable some settings cd $(DIR_APP) && sed -i -e "s/CPTCFG_CFG80211_DEVELOPER_WARNINGS=y/# CPTCFG_CFG80211_DEVELOPER_WARNINGS is not set/g" .config - cd $(DIR_APP) && sed -i -e "s/CPTCFG_CFG80211_CERTIFICATION_ONUS=y/# CPTCFG_CFG80211_CERTIFICATION_ONUS is not set/g" .config - cd $(DIR_APP) && sed -i -e "s/CPTCFG_CFG80211_REG_CELLULAR_HINTS=y/# CPTCFG_CFG80211_REG_CELLULAR_HINTS is not set/g" .config - cd $(DIR_APP) && sed -i -e "s/CPTCFG_CFG80211_REG_RELAX_NO_IR=y/# CPTCFG_CFG80211_REG_RELAX_NO_IR is not set/g" .config cd $(DIR_APP) && sed -i -e "s/CPTCFG_CFG80211_INTERNAL_REGDB=y/# CPTCFG_CFG80211_INTERNAL_REGDB is not set/g" .config cd $(DIR_APP) && sed -i -e "s/CPTCFG_CFG80211_DEFAULT_PS=y/# CPTCFG_CFG80211_DEFAULT_PS is not set/g" .config cd $(DIR_APP) && sed -i -e "s/CPTCFG_NFC=m/# CPTCFG_NFC is not set/g" .config @@ -121,21 +123,19 @@ ifeq "$(MACHINE)" "x86_64" cd $(DIR_APP) && sed -i -e "s/CPTCFG_LIBERTAS_UAP=m/# CPTCFG_LIBERTAS_UAP is not set/g" .config endif
- # Disable some modules (build fail) + # Disable some modules (build fail/missing symbols) + cd $(DIR_APP) && sed -i -e "s/CPTCFG_VIDEO_AM437X_VPFE=m/# CPTCFG_VIDEO_AM437X_VPFE is not set/g" .config cd $(DIR_APP) && sed -i -e "s/CPTCFG_VIDEO_VIA_CAMERA=m/# CPTCFG_VIDEO_VIA_CAMERA is not set/g" .config + cd $(DIR_APP) && sed -i -e "s/CPTCFG_VIDEO_XILINX=m/# CPTCFG_VIDEO_XILINX is not set/g" .config + cd $(DIR_APP) && sed -i -e "s/CPTCFG_IR_SUNXI=m/# CPTCFG_IR_SUNXI is not set/g" .config + cd $(DIR_APP) && sed -i -e "s/CPTCFG_BT_6LOWPAN=m/# CPTCFG_BT_6LOWPAN is not set/g" .config
# Disable DEBUG cd $(DIR_APP) && sed -i -e "s/.*DEBUG=y/# & is not set/g" .config cd $(DIR_APP) && sed -i -e "s/.*DEBUGFS=y/# & is not set/g" .config cd $(DIR_APP) && sed -i -e "s/=y is not set/ is not set/g" .config
- # Disable OF_GRAPH (not supported by kernel 3.14) - cd $(DIR_APP) && sed -i -e "s/CONFIG_OF/CONFIG_OF_IGNORE/g" include/linux/of_graph.h - cd $(DIR_APP) && make $(MAKETUNING) KLIB=/lib/modules/$(KVER)-$(VERSUFIX)/ install
- # Remove vsp1 module (not mach to our platforms) - rm -rf /lib/modules/$(KVER)-$(VERSUFIX)/kernel/drivers/media/platform/vsp1 - @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/bind b/lfs/bind index 0814cde..b0d5185 100644 --- a/lfs/bind +++ b/lfs/bind @@ -25,7 +25,7 @@
include Config
-VER = 9.10.2-P4 +VER = 9.10.3-P2
THISAPP = bind-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -43,7 +43,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 8b1f5064837756c938eadc1537dec5c7 +$(DL_FILE)_MD5 = 672dd3c2796b12ac8440f55bcaecfa82
install : $(TARGET)
diff --git a/lfs/binutils b/lfs/binutils index 27c83fb..5afaeec 100644 --- a/lfs/binutils +++ b/lfs/binutils @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2015 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 2.22 +VER = 2.24
THISAPP = binutils-$(VER) DL_FILE = $(THISAPP).tar.bz2 @@ -38,17 +38,21 @@ ifeq "$(ROOT)" "" EXTRA_CONFIG = \ --prefix=/usr \ --enable-shared \ - --disable-nls + --disable-nls \ + --disable-werror EXTRA_MAKE = tooldir=/usr EXTRA_INSTALL = tooldir=/usr else ifeq "$(PASS)" "1" CFLAGS := $(patsubst -march=%,,$(CFLAGS)) CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS)) + CFLAGS := $(patsubst -fstack-protector-strong,-fstack-protector-all,$(CFLAGS)) TARGET = $(DIR_INFO)/$(THISAPP)-tools1 EXTRA_CONFIG = \ --target=$(CROSSTARGET) \ --prefix=/tools \ + --with-sysroot=$(ROOT) \ + --with-lib-path=/tools/lib \ --disable-nls \ --disable-werror EXTRA_MAKE = @@ -64,7 +68,8 @@ else --build=$(BUILDTARGET) \ --prefix=/tools \ --with-lib-path=/tools/lib \ - --disable-nls + --disable-nls \ + --disable-werror EXTRA_MAKE = EXTRA_INSTALL = endif @@ -87,7 +92,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = ee0f10756c84979622b992a4a61ea3f5 +$(DL_FILE)_MD5 = e0f71a7b2ddab0f8612336ac81d9636b
install : $(TARGET)
@@ -117,11 +122,7 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) $(DIR_SRC)/binutils-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/binutils-2.22-pt-pax-flags-20111121.patch - - # texinfo 5 syntax-fix. - cd $(DIR_APP) && sed -i -e "s/@colophon/@@colophon/" \ - -e "s/doc@cygnus/doc@@cygnus/" bfd/doc/bfd.texinfo + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/binutils-2.24-pt-pax-flags-20131231.patch
@mkdir $(DIR_SRC)/binutils-build
diff --git a/lfs/bird b/lfs/bird new file mode 100644 index 0000000..27f3556 --- /dev/null +++ b/lfs/bird @@ -0,0 +1,89 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2015 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 1.5.0 + +THISAPP = bird-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) +PROG = bird +PAK_VER = 1 + +DEPS = "" + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = 330bde6372afa106abfe5a9737e471c1 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +dist: + @$(PAK) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && \ + ./configure \ + --prefix=/usr \ + --sysconfdir=/etc \ + --localstatedir=/var + cd $(DIR_APP) && make $(MAKETUNING) + cd $(DIR_APP) && make install + @rm -rf $(DIR_APP) + @$(POSTBUILD) + diff --git a/lfs/bison b/lfs/bison index 6b84f41..322dd26 100644 --- a/lfs/bison +++ b/lfs/bison @@ -24,10 +24,10 @@
include Config
-VER = 2.5.1 +VER = 3.0.4
THISAPP = bison-$(VER) -DL_FILE = $(THISAPP).tar.gz +DL_FILE = $(THISAPP).tar.xz DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) @@ -40,7 +40,7 @@ objects =$(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 8fedf916f1aa2c4a31441d8f8bbc603c +$(DL_FILE)_MD5 = c342201de104cc9ce0a21e0ad10d4021
install : $(TARGET)
@@ -69,10 +69,8 @@ $(subst %,%_MD5,$(objects)) :
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && ./configure --prefix=/usr --disable-nls - # Disable NLS - #cd $(DIR_APP) && echo '#define YYENABLE_NLS 1' >> config.h + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && ./configure --prefix=/usr --disable-nls --docdir=/usr/share/doc/$(THISAPP) cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make $(EXTRA_INSTALL) install @rm -rf $(DIR_APP) diff --git a/lfs/ccache b/lfs/ccache index 64b09d1..682f499 100644 --- a/lfs/ccache +++ b/lfs/ccache @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2010 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -35,6 +35,7 @@ TARGET = $(DIR_INFO)/$(THISAPP)-pass$(PASS) ifeq "$(PASS)" "1" CFLAGS := $(patsubst -march=%,,$(CFLAGS)) CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS)) + CFLAGS := $(patsubst -fstack-protector-strong,-fstack-protector-all,$(CFLAGS)) endif
# Set max cache size to 5GB diff --git a/lfs/cleanup-toolchain b/lfs/cleanup-toolchain index 0b3252f..9036988 100644 --- a/lfs/cleanup-toolchain +++ b/lfs/cleanup-toolchain @@ -54,7 +54,6 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) ifeq "$(PASS)" "1" SPECS=$$(dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name))/specs; \ /tools/bin/$(CROSSTARGET)-gcc -dumpspecs | sed \ - -e 's@/lib(64)?/ld@/tools&@g' \ -e "/^*cpp:$$/{n;s,$$, -isystem /tools/include,}" > $$SPECS endif
diff --git a/lfs/cmake b/lfs/cmake index e3d2119..a9ada50 100644 --- a/lfs/cmake +++ b/lfs/cmake @@ -32,9 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP)
-ifeq "$(MACHINE)" "armv5tel" - MAKETUNING = -j2 -endif +MAKETUNING = -j2
############################################################################### # Top-level Rules diff --git a/lfs/configroot b/lfs/configroot index cb74996..f8e9ce4 100644 --- a/lfs/configroot +++ b/lfs/configroot @@ -135,6 +135,16 @@ $(TARGET) : echo "POLICY=MODE2" >> $(CONFIG_ROOT)/firewall/settings echo "POLICY1=MODE2" >> $(CONFIG_ROOT)/firewall/settings
+ # Add conntrack helper default settings + for proto in FTP H323 IRC SIP TFTP; do \ + echo "CONNTRACK_$${proto}=on" >> $(CONFIG_ROOT)/optionsfw/settings; \ + done + + # Do not enable these by default because these are broken + for proto in AMANDA PPTP; do \ + echo "CONNTRACK_$${proto}=off" >> $(CONFIG_ROOT)/optionsfw/settings; \ + done + # set converters executable chmod 755 /usr/sbin/convert-*
diff --git a/lfs/dhcpcd b/lfs/dhcpcd index ff31821..3b9a094 100644 --- a/lfs/dhcpcd +++ b/lfs/dhcpcd @@ -85,9 +85,9 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) rm -f $(CONFIG_ROOT)/dhcpc/dhcpcd-hooks/50-yp.conf rm -f $(CONFIG_ROOT)/dhcpc/dhcpcd-hooks/50-ypbind
- sed -i -e "s|-ge 576|-gt 576|g" $(CONFIG_ROOT)/dhcpc/dhcpcd-hooks/10-mtu - install -m 644 $(DIR_SRC)/config/dhcpc/dhcpcd.conf $(CONFIG_ROOT)/dhcpc/ + install -m 444 $(DIR_SRC)/config/dhcpc/dhcpcd-hooks/10-mtu $(CONFIG_ROOT)/dhcpc/dhcpcd-hooks + chown root:root $(CONFIG_ROOT)/dhcpc/dhcpcd.conf
@rm -rf $(DIR_APP) diff --git a/lfs/dnsdist b/lfs/dnsdist new file mode 100644 index 0000000..62c17cf --- /dev/null +++ b/lfs/dnsdist @@ -0,0 +1,86 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2015 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 0.0.498gac688af + +THISAPP = dnsdist-$(VER) +DL_FILE = $(THISAPP).tar.bz2 +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) +SUP_ARCH = x86_64 i586 +PROG = dnsdist +PAK_VER = 1 + +DEPS = "" + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = b1bc53b3a35aef7006b74086919847bf + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +dist: + @$(PAK) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && ./configure --prefix=/usr --sysconfdir=/etc + cd $(DIR_APP) && make $(MAKETUNING) + cd $(DIR_APP) && make install + @rm -rf $(DIR_APP) + @$(POSTBUILD) + diff --git a/lfs/dnsmasq b/lfs/dnsmasq index c8fd7db..84585c1 100644 --- a/lfs/dnsmasq +++ b/lfs/dnsmasq @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2015 Michael Tremer & Christian Schmidt # +# Copyright (C) 2016 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 2.75 +VER = 2.76test10
THISAPP = dnsmasq-$(VER) DL_FILE = $(THISAPP).tar.xz @@ -43,7 +43,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 887236f1ddde6eb57cdb9d01916c9f72 +$(DL_FILE)_MD5 = 4b51474ed6081b18c61407077f254cf7
install : $(TARGET)
@@ -73,30 +73,11 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/001-include_0_0_0_0_8_in_DNS_rebind_checks.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/002-enhance_add_subnet_to_allow_arbitary_subnet_addresses.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/003-dont_answer_non_auth_queries_for_auth_zones_locally_when_localise_queries_set.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/004-fix_behaviour_of_empty_dhcp-option.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/005-suggest_solution_to_ENOMEM_error_with_IPv6_multicast.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/006-clarify_man_page_on_RDNSS_set_in_router_advertisement.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/007-handle_signed_dangling_CNAME_replies_to_DS_queries.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/008-DHCPv6_option_56_does_not_hold_an_address_list.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/009-Respect_the_--no_resolv_flag_in_inotify_code.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/010-Rationalise_5e3e464ac4022ee0b3794513abe510817e2cf3ca.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/011-Catch_errors_from_sendmsg_in_DHCP_code.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/012-Update_list_of_subnet_for_--bogus-priv.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/013-Fix_crash_when_empty_address_from_DNS_overlays_A_record_from.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/014-Handle_unknown_DS_hash_algos_correctly.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/015-Fix_crash_at_start_up_with_conf-dir.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/016-Major_rationalisation_of_DNSSEC_validation.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/017-Abandon_caching_RRSIGs_and_returning_them_from_cache.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/018-Move_code_which_caches_DS_records_to_a_more_logical_place.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/019-Generalise_RR-filtering_code_for_use_with_EDNS0.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/020-DNSSEC_validation_tweak.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/021-Tweaks_to_EDNS0_handling_in_DNS_replies.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/022-Tidy_up_DNSSEC_non-existence_code_Check_zone_status_is_NSEC_proof_bad.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/023-Fix_brace_botch_in_dnssec_validate_ds.patch - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/024-Do_a_better_job_of_determining_which_DNSSEC_sig_algos_are_supported.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/001-Add_TTL_parameter_to_--host-record_and_--cname.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/002-Add_--dhcp-ttl_option.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/003-Update_CHANGELOG.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/004-Add_--tftp-mtu_option.patch + cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch
cd $(DIR_APP) && sed -i src/config.h \ diff --git a/lfs/flash-images b/lfs/flash-images index 530bf33..d10fc9b 100644 --- a/lfs/flash-images +++ b/lfs/flash-images @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2014 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -121,9 +121,14 @@ ifeq "$(MACHINE_TYPE)" "arm" cp -v /boot/MLO $(MNThdd)/boot/ cp -v /boot/u-boot.img $(MNThdd)/boot/ cp -v /boot/zImage-ipfire-multi $(MNThdd)/boot/ + cp -v /boot/uInit-ipfire-multi $(MNThdd)/boot/ + cp -v /boot/uImage-ipfire-kirkwood $(MNThdd)/boot/ + cp -v /boot/uInit-ipfire-kirkwood $(MNThdd)/boot/ + cp -v /boot/uEnv.txt $(MNThdd)/boot/ # work around a u-boot bug not find the folders sometimes mkdir -pv $(MNThdd)/boot/dtb-$(KVER)-ipfire-multi mkdir -pv $(MNThdd)/boot/dtb-$(KVER)-ipfire-kirkwood + sync umount $(MNThdd)/boot mount $(PART_BOOT) $(MNThdd)/boot @@ -182,15 +187,19 @@ endif mkdir -pv $(MNThdd)/boot/grub chroot $(MNThdd) grub-mkconfig -o /boot/grub/grub.cfg
- # Insert the UUID because grub-mkconfig fails to detect that correctly + # Insert the UUID because grub-mkconfig often fails to + # detect that correctly sed -i $(MNThdd)/boot/grub/grub.cfg \ - -e "s/root=[a-z0-9/]*/root=UUID=$$(blkid -o value -s UUID $(PART_ROOT))/g" + -e "s/root=[A-Za-z0-9/=-]*/root=UUID=$$(blkid -o value -s UUID $(PART_ROOT))/g"
# Install GRUB grub-install --force --recheck --no-floppy \ --root-directory=$(MNThdd) $(DEVICE) endif
+ # Set ramdisk mode to automatic + echo RAMDISK_MODE=2 > $(MNThdd)/etc/sysconfig/ramdisk + # Automatically resize the root partition to its maximum size at first boot touch $(MNThdd)/.partresize
diff --git a/lfs/gcc b/lfs/gcc index ff8723a..52d1dae 100644 --- a/lfs/gcc +++ b/lfs/gcc @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2011 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,22 +24,22 @@
include Config
-VER = 4.4.7 +VER = 4.9.3
GMP_VER = 5.0.5 MPFR_VER = 2.4.2 +MPC_VER = 1.0.3
THISAPP = gcc-$(VER) -DL_FILE = $(THISAPP).tar.bz2 +DL_FILE = $(THISAPP).tar.gz DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP)
CFLAGS := $(patsubst -march=%,,$(CFLAGS)) CFLAGS := $(patsubst -mtune=%,,$(CFLAGS)) CFLAGS := $(patsubst -mfloat-abi=%,,$(CFLAGS)) - -# https://bugzilla.redhat.com/show_bug.cgi?id=476370 -CFLAGS += -fgnu89-inline +CFLAGS := $(filter-out -fexceptions,$(CFLAGS)) +CXXFLAGS := $(CFLAGS)
# Normal build or /tools build. # @@ -59,29 +59,40 @@ ifeq "$(ROOT)" "" EXTRA_INSTALL = else ifeq "$(PASS)" "1" + CFLAGS := $(patsubst -fstack-protector-strong,-fstack-protector-all,$(CFLAGS)) + CXXFLAGS := $(patsubst -fstack-protector-strong,-fstack-protector-all,$(CXXFLAGS)) TARGET = $(DIR_INFO)/$(THISAPP)-tools1 EXTRA_CONFIG = \ --target=$(CROSSTARGET) \ --prefix=/tools \ + --with-sysroot=$(ROOT) \ --disable-nls \ --disable-shared \ --disable-decimal-float \ --disable-threads \ + --disable-libatomic \ --disable-libmudflap \ --disable-libssp \ --disable-libgomp \ --disable-libquadmath \ + --disable-libstdc++-v3 \ + --disable-libvtv \ + --disable-libcilkrts \ + --disable-libitm \ + --disable-libsanitizer \ --with-newlib \ --without-headers \ --without-ppl \ --without-cloog \ - --enable-languages=c + --enable-languages=c,c++ EXTRA_MAKE = EXTRA_INSTALL = else +ifeq "$(PASS)" "2" TARGET = $(DIR_INFO)/$(THISAPP)-tools2 EXTRA_ENV = \ CC="$(CROSSTARGET)-gcc -B/tools/lib/" \ + CXX="$(CROSSTARGET)-g++" \ AR="$(CROSSTARGET)-ar" \ RANLIB="$(CROSSTARGET)-ranlib" EXTRA_CONFIG = \ @@ -90,16 +101,36 @@ else --target=$(BUILDTARGET) \ --prefix=/tools \ --with-local-prefix=/tools \ + --with-native-system-header-dir=/tools/include \ --enable-clocale=gnu \ --enable-shared \ --enable-threads=posix \ --enable-__cxa_atexit \ --enable-languages=c,c++ \ --disable-libstdcxx-pch \ - --disable-bootstrap + --enable-bootstrap + EXTRA_MAKE = + EXTRA_INSTALL = +else + # PASS=L # libstdc++-v3 + TARGET = $(DIR_INFO)/$(THISAPP)-libstdc++ + EXTRA_ENV = \ + CC="$(CROSSTARGET)-gcc -B/tools/lib/" \ + AR="$(CROSSTARGET)-ar" \ + RANLIB="$(CROSSTARGET)-ranlib" + EXTRA_CONFIG = \ + --host=$(CROSSTARGET) \ + --prefix=/tools \ + --with-sysroot=$(ROOT) \ + --disable-shared \ + --disable-nls \ + --disable-libstdcxx-threads \ + --disable-libstdcxx-pch \ + --with-gxx-include-dir=/tools/$(CROSSTARGET)/include/c++/$(VER) EXTRA_MAKE = EXTRA_INSTALL = endif +endif
# Disable stack protection in toolchain. CFLAGS += -fno-stack-protector @@ -136,15 +167,18 @@ export TCFLAGS = $(CFLAGS)
objects = $(DL_FILE) \ gmp-$(GMP_VER).tar.bz2 \ - mpfr-$(MPFR_VER).tar.bz2 + mpfr-$(MPFR_VER).tar.bz2 \ + mpc-$(MPC_VER).tar.gz
$(DL_FILE) = $(DL_FROM)/$(DL_FILE) gmp-$(GMP_VER).tar.bz2 = $(DL_FROM)/gmp-$(GMP_VER).tar.bz2 mpfr-$(MPFR_VER).tar.bz2 = $(DL_FROM)/mpfr-$(MPFR_VER).tar.bz2 +mpc-$(MPC_VER).tar.gz = $(DL_FROM)/mpc-$(MPC_VER).tar.gz
-$(DL_FILE)_MD5 = 295709feb4441b04e87dea3f1bab4281 +$(DL_FILE)_MD5 = 648bfba342bb41a4b5350fb685f85bc5 gmp-$(GMP_VER).tar.bz2_MD5 = 041487d25e9c230b0c42b106361055fe mpfr-$(MPFR_VER).tar.bz2_MD5 = 89e59fe665e2b3ad44a6789f40b059a0 +mpc-$(MPC_VER).tar.gz_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26
install : $(TARGET)
@@ -173,23 +207,16 @@ $(subst %,%_MD5,$(objects)) :
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) @mkdir $(DIR_SRC)/gcc-build
# Apply patches. - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-build-id.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-c++-builtin-redecl.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-i386-libgomp.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-libtool-no-rpath.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-no-add-needed.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-pr33763.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh330771.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh533181.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-rh610785.patch - cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc44-unwind-debug-hook.patch - - # texinfo 5 syntax-fixes - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc-4.4.7-texinfo-5.patch + cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-i386-libgomp.patch + cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-libtool-no-rpath.patch + cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-no-add-needed.patch + cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-pr38757.patch + cd $(DIR_APP) && patch -Np0 < $(DIR_SRC)/src/patches/gcc/gcc49-pr64336.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/gcc/gcc-fix-inlining-issues.patch
ifneq "$(ROOT)" "" # Build gmp and mpfr internally in toolchain. @@ -197,25 +224,39 @@ ifneq "$(ROOT)" "" cd $(DIR_APP) && mv -v gmp-$(GMP_VER) gmp cd $(DIR_APP) && tar xfa $(DIR_DL)/mpfr-$(MPFR_VER).tar.bz2 cd $(DIR_APP) && mv -v mpfr-$(MPFR_VER) mpfr + cd $(DIR_APP) && tar xfa $(DIR_DL)/mpc-$(MPC_VER).tar.gz + cd $(DIR_APP) && mv -v mpc-$(MPC_VER) mpc
ifeq "$(PASS)" "1" # GCC does not detect stack protection correctly, which causes problems # for the build of libresolv_pic.a. cd $(DIR_APP) && sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure + + for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \ + -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \ + echo "Processing $${file}..."; \ + sed -i $${file} \ + -e 's@/lib(64)?(32)?/ld@/tools&@g' \ + -e 's@/usr@/tools@g'; \ + echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \ + echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \ + echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \ + echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \ + done endif
ifeq "$(PASS)" "2" - cd $(DIR_APP) && patch -Np1 -i $(DIR_SRC)/src/patches/gcc-4.4.3-startfiles_fix-1.patch - + cd $(DIR_APP) && cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \ + `dirname $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name)`/include-fixed/limits.h for file in $$(find $(DIR_APP)/gcc/config -name linux64.h -o -name linux.h \ -o -name sysv4.h -o -name linux-eabi.h -o -name linux-elf.h); do \ echo "Processing $${file}..."; \ sed -i $${file} \ -e 's@/lib(64)?(32)?/ld@/tools&@g' \ -e 's@/usr@/tools@g'; \ - echo '#undef STANDARD_INCLUDE_DIR' >> $${file}; \ - echo '#define STANDARD_INCLUDE_DIR 0' >> $${file}; \ - echo '#define STANDARD_STARTFILE_PREFIX_1 ""' >> $${file}; \ + echo '#undef STANDARD_STARTFILE_PREFIX_1' >> $${file}; \ + echo '#undef STANDARD_STARTFILE_PREFIX_2' >> $${file}; \ + echo '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"' >> $${file}; \ echo '#define STANDARD_STARTFILE_PREFIX_2 ""' >> $${file}; \ done endif @@ -226,6 +267,15 @@ endif -e 's@./fixinc.sh@-c true@' \ -e 's/^T_CFLAGS =$$/& -fomit-frame-pointer/'
+ifeq "$(PASS)" "L" + # libstdc++ pass + cd $(DIR_SRC)/gcc-build && \ + $(EXTRA_ENV) \ + $(DIR_APP)/libstdc++-v3/configure \ + $(EXTRA_CONFIG) + cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE) + cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install +else # The actual build. cd $(DIR_SRC)/gcc-build && \ $(EXTRA_ENV) \ @@ -233,15 +283,20 @@ endif $(EXTRA_CONFIG) cd $(DIR_SRC)/gcc-build && make $(MAKETUNING) $(EXTRA_MAKE) cd $(DIR_SRC)/gcc-build && make $(EXTRA_INSTALL) install +endif
ifeq "$(ROOT)" "" ln -svf ../usr/bin/cpp /lib ln -svf gcc /usr/bin/cc + # remove gdb python files from libdir + rm -rf /usr/lib/*-gdb.py else ifeq "$(PASS)" "1" ln -svf libgcc.a $$(/tools/bin/$(CROSSTARGET)-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/') else ln -svf gcc /tools/bin/cc + # remove gdb python files from libdir + rm -rf /tools/lib/*-gdb.py endif endif @rm -rf $(DIR_APP) $(DIR_SRC)/gcc-build diff --git a/lfs/glibc b/lfs/glibc index 7c8ed5e..c0af6fc 100644 --- a/lfs/glibc +++ b/lfs/glibc @@ -51,7 +51,8 @@ else --with-headers=/tools/include \ libc_cv_forced_unwind=yes \ libc_cv_ctors_header=yes \ - libc_cv_c_cleanup=yes + libc_cv_c_cleanup=yes \ + CC=/tools/bin/$(CROSSTARGET)-gcc EXTRA_MAKE = EXTRA_INSTALL = endif @@ -358,6 +359,7 @@ endif
cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/glibc-test-installation.pl-libgcc_s.patch cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/glibc-2.12-accept-make-versions-4.0-and-greater.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/glibc/glibc-mq_open.patch
# Fixes: # Makefile:235: *** mixed implicit and normal rules. Stop. diff --git a/lfs/grep b/lfs/grep index ac20161..d22b359 100644 --- a/lfs/grep +++ b/lfs/grep @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2016 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 2.21 +VER = 2.22
THISAPP = grep-$(VER) DL_FILE = $(THISAPP).tar.xz @@ -54,7 +54,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 43c48064d6409862b8a850db83c8038a +$(DL_FILE)_MD5 = e1015e951a49a82b02e38891026ef5df
install : $(TARGET)
diff --git a/lfs/grub b/lfs/grub index 3e613a8..ba74408 100644 --- a/lfs/grub +++ b/lfs/grub @@ -101,6 +101,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
# Disable hardening. paxctl -mpes /usr/sbin/grub-bios-setup /usr/sbin/grub-probe + paxctl -mpexs /usr/bin/grub-script-check
# We don't need to install unifont just to generate a grub2 compatible # font archive for the graphical boot menu. The following command only diff --git a/lfs/libmpc b/lfs/libmpc new file mode 100644 index 0000000..5aa43d9 --- /dev/null +++ b/lfs/libmpc @@ -0,0 +1,77 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 1.0.3 + +THISAPP = mpc-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = d6a1d5f8ddea3abd2cc3e98f58352d26 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && ./configure --prefix=/usr + cd $(DIR_APP) && make $(MAKETUNING) + cd $(DIR_APP) && make install + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/lfs/linux b/lfs/linux index 829b21e..125228a 100644 --- a/lfs/linux +++ b/lfs/linux @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2015 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,10 +24,10 @@
include Config
-VER = 3.14.57 -RPI_PATCHES = 3.14.57-grsec-ipfire1 -A7M_PATCHES = 3.14.57-grsec-ipfire1 -GRS_PATCHES = grsecurity-3.1ipfire-3.14.57-v1.patch.xz +VER = 3.14.65 +RPI_PATCHES = 3.14.65-grsec-ipfire1 +A7M_PATCHES = 3.14.65-grsec-ipfire1 +GRS_PATCHES = grsecurity-3.1ipfire-3.14.65-v1.patch.xz
THISAPP = linux-$(VER) @@ -37,7 +37,7 @@ DIR_APP = $(DIR_SRC)/$(THISAPP) CFLAGS = CXXFLAGS =
-PAK_VER = 64 +PAK_VER = 65 DEPS = ""
KERNEL_ARCH = $(MACHINE) @@ -83,10 +83,10 @@ rpi-patches-$(RPI_PATCHES).patch.xz = $(URL_IPFIRE)/rpi-patches-$(RPI_PATCHES). arm7-multi-patches-$(A7M_PATCHES).patch.xz = $(URL_IPFIRE)/arm7-multi-patches-$(A7M_PATCHES).patch.xz $(GRS_PATCHES) = $(URL_IPFIRE)/$(GRS_PATCHES)
-$(DL_FILE)_MD5 = b7e254c83a0324852c8ccc4ed1b5377d -rpi-patches-$(RPI_PATCHES).patch.xz_MD5 = 4ab53e184441c895adf318a1c2874d43 -arm7-multi-patches-$(A7M_PATCHES).patch.xz_MD5 = f29bd5c156384b0a4bb7c6e2c973ea06 -$(GRS_PATCHES)_MD5 = de603c5cb2e38ee308f1647ad3bd24cf +$(DL_FILE)_MD5 = cfc70821a04acb80ded45e408e9faf36 +rpi-patches-$(RPI_PATCHES).patch.xz_MD5 = 0d1059c18f4810abbe9aafb6beab445b +arm7-multi-patches-$(A7M_PATCHES).patch.xz_MD5 = 589eb8703fa2ba2944b2f925b7f7ffb3 +$(GRS_PATCHES)_MD5 = 548571a2c70219cce9728eb8b8949030
install : $(TARGET)
@@ -170,8 +170,32 @@ endif # update the queued trim blacklist from kernel 4.2rc1 cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.43_new_qtrim_blacklist.patch
- # HyperV 2008 patch - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-3.14.x-hyperv-2008-fix.patch + # Hyper-V patches + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0001-Drivers-net-hyperv-Get-rid-of-the-rndis_filter_packe.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0002-Drivers-net-hyperv-Cleanup-the-receive-path.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0003-Drivers-net-hyperv-Cleanup-the-netvsc-receive-callba.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0004-hyperv-Add-latest-NetVSP-versions-to-auto-negotiatio.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0005-Drivers-net-hyperv-Enable-scatter-gather-I-O.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0006-Drivers-net-hyperv-Cleanup-the-send-path.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0007-Drivers-net-hyperv-Enable-offloads-on-the-host.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0008-Drivers-net-hyperv-Enable-receive-side-IP-checksum-o.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0009-Drivers-net-hyperv-Enable-send-side-checksum-offload.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0010-Drivers-net-hyperv-Enable-large-send-offload.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0011-hyperv-Change-the-receive-buffer-size-for-legacy-hos.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0012-Drivers-net-hyperv-Allocate-memory-for-all-possible-.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0013-Drivers-net-hyperv-Negotiate-suitable-ndis-version-f.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0014-Drivers-net-hyperv-Address-UDP-checksum-issues.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0015-hyperv-Properly-handle-checksum-offload.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0016-hyperv-Add-support-for-virtual-Receive-Side-Scaling-.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0017-hyperv-Remove-recv_pkt_list-and-lock.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0018-hyperv-Simplify-the-send_completion-variables.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0019-hyperv-Enable-sendbuf-mechanism-on-the-send-path.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0020-Add-support-for-netvsc-build-without-CONFIG_SYSFS-fl.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0021-hyperv-Add-hash-value-into-RNDIS-Per-packet-info.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0022-hyperv-fix-apparent-cut-n-paste-error-in-send-path-t.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0023-hyperv-Fix-error-return-code-in-netvsc_init_buf.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0024-hyperv-Fix-a-bug-in-netvsc_send.patch + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux/0025-Drivers-hv-vmbus-Support-per-channel-driver-state.patch
# fix empty symbol crc's cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/linux-genksyms_fix_typeof_handling.patch @@ -186,6 +210,7 @@ ifeq "$(KCFG)" "-multi"
# Apply Arm7-multiarch kernel patches. cd $(DIR_APP) && xzcat $(DIR_DL)/arm7-multi-patches-$(A7M_PATCHES).patch.xz | patch -Np1 + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/arm-multi-grsec-compile-fixes.patch
# Install switch api userspace header cd $(DIR_APP) && install -v -m644 include/uapi/linux/switch.h /usr/include/linux/ diff --git a/lfs/lua b/lfs/lua new file mode 100644 index 0000000..6a6a959 --- /dev/null +++ b/lfs/lua @@ -0,0 +1,80 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 5.3.0 + +THISAPP = lua-$(VER) +DL_FILE = $(THISAPP).tar.gz +DL_FROM = $(URL_IPFIRE) +DIR_APP = $(DIR_SRC)/$(THISAPP) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = a1b0a7e92d0c85bbff7a8d27bf29f8af + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && cp -v src/luaconf.h src/luaconf.h.template.in + cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/lua-5.3.0-autotoolize.patch + cd $(DIR_APP) && autoreconf -vfi + cd $(DIR_APP) && ./configure --prefix=/usr + cd $(DIR_APP) && make $(MAKETUNING) + cd $(DIR_APP) && make install + @rm -rf $(DIR_APP) + @$(POSTBUILD) diff --git a/lfs/m4 b/lfs/m4 index 4620221..932cb6d 100644 --- a/lfs/m4 +++ b/lfs/m4 @@ -24,10 +24,10 @@
include Config
-VER = 1.4.16 +VER = 1.4.17
THISAPP = m4-$(VER) -DL_FILE = $(THISAPP).tar.bz2 +DL_FILE = $(THISAPP).tar.xz DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP)
@@ -37,12 +37,10 @@ ifeq "$(ROOT)" "" TARGET = $(DIR_INFO)/$(THISAPP) EXTRA_CONFIG = --prefix=/usr --disable-nls EXTRA_MAKE = - EXTRA_INSTALL = else TARGET = $(DIR_INFO)/$(THISAPP)-tools EXTRA_CONFIG = --prefix=/tools --disable-nls EXTRA_MAKE = - EXTRA_INSTALL = endif
############################################################################### @@ -53,7 +51,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 8a7cef47fecab6272eb86a6be6363b2f +$(DL_FILE)_MD5 = 12a3c829301a4fd6586a57d3fcf196dc
install : $(TARGET)
@@ -82,9 +80,9 @@ $(subst %,%_MD5,$(objects)) :
$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) - @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar jxf $(DIR_DL)/$(DL_FILE) + @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && ./configure $(EXTRA_CONFIG) cd $(DIR_APP) && make $(MAKETUNING) $(EXTRA_MAKE) - cd $(DIR_APP) && make $(EXTRA_INSTALL) install + cd $(DIR_APP) && make install @rm -rf $(DIR_APP) @$(POSTBUILD) diff --git a/lfs/mt7601u-firmware b/lfs/mt7601u-firmware new file mode 100644 index 0000000..6d6724b --- /dev/null +++ b/lfs/mt7601u-firmware @@ -0,0 +1,72 @@ +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2017 IPFire Team info@ipfire.org # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# 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. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see http://www.gnu.org/licenses/. # +# # +############################################################################### + +############################################################################### +# Definitions +############################################################################### + +include Config + +VER = 20160319 + +THISAPP = mt7601u-firmware-$(VER) +DL_FILE = $(THISAPP).tar.xz +DL_FROM = $(URL_IPFIRE) +TARGET = $(DIR_INFO)/$(THISAPP) + +############################################################################### +# Top-level Rules +############################################################################### + +objects = $(DL_FILE) + +$(DL_FILE) = $(DL_FROM)/$(DL_FILE) + +$(DL_FILE)_MD5 = 3bfc6e63ceac64521f1de40ae93613d4 + +install : $(TARGET) + +check : $(patsubst %,$(DIR_CHK)/%,$(objects)) + +download :$(patsubst %,$(DIR_DL)/%,$(objects)) + +md5 : $(subst %,%_MD5,$(objects)) + +############################################################################### +# Downloading, checking, md5sum +############################################################################### + +$(patsubst %,$(DIR_CHK)/%,$(objects)) : + @$(CHECK) + +$(patsubst %,$(DIR_DL)/%,$(objects)) : + @$(LOAD) + +$(subst %,%_MD5,$(objects)) : + @$(MD5) + +############################################################################### +# Installation Details +############################################################################### + +$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) + @$(PREBUILD) + @cd /lib/firmware && tar axf $(DIR_DL)/$(DL_FILE) + @$(POSTBUILD) diff --git a/lfs/nano b/lfs/nano index c08ec88..0d92c6b 100644 --- a/lfs/nano +++ b/lfs/nano @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2015 Michael Tremer & Christian Schmidt # +# Copyright (C) 2016 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 2.5.0 +VER = 2.5.1
THISAPP = nano-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = nano -PAK_VER = 7 +PAK_VER = 8
DEPS = ""
@@ -44,7 +44,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 751ed96457017572bab15be18cb873ba +$(DL_FILE)_MD5 = f25c7da9813ae5f1df7e5dd1072de4ce
install : $(TARGET)
diff --git a/lfs/ntp b/lfs/ntp index 2d04b17..3393f90 100644 --- a/lfs/ntp +++ b/lfs/ntp @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2015 Michael Tremer & Christian Schmidt # +# Copyright (C) 2016 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 4.2.8p4 +VER = 4.2.8p5
THISAPP = ntp-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -40,7 +40,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 6af96862b09324a8ef965ca76b759c8b +$(DL_FILE)_MD5 = 9f02b2a0acc1617ce2716d529a58d2d8
install : $(TARGET)
@@ -70,7 +70,6 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE) - cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/ntp-fix-sycing-with-local-clock.patch cd $(DIR_APP) && \ ./configure \ --prefix=/usr \ diff --git a/lfs/openvpn b/lfs/openvpn index a19ac1f..96e37f7 100644 --- a/lfs/openvpn +++ b/lfs/openvpn @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2014 IPFire Team info@ipfire.org # +# Copyright (C) 2015 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 2.3.6 +VER = 2.3.7
THISAPP = openvpn-$(VER) DL_FILE = $(THISAPP).tar.xz @@ -40,7 +40,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = bcc30c296566df14feebdd8aa0e408ca +$(DL_FILE)_MD5 = 5b819f7cd0b875f55f20a947224967aa
install : $(TARGET)
diff --git a/lfs/owncloud b/lfs/owncloud index 88c5f45..e021a4c 100644 --- a/lfs/owncloud +++ b/lfs/owncloud @@ -24,7 +24,7 @@
include Config
-VER = 7.0.3 +VER = 7.0.11
THISAPP = owncloud-$(VER) DL_FILE = $(THISAPP).tar.bz2 @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = owncloud -PAK_VER = 4 +PAK_VER = 6
DEPS = ""
@@ -44,7 +44,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = d5d2ad068046e6ddb322cf001a9bb3d5 +$(DL_FILE)_MD5 = 1f4839e43bc910a9acd8700fb9923b3a
install : $(TARGET)
diff --git a/lfs/rsync b/lfs/rsync index 8899ec0..ce8c652 100644 --- a/lfs/rsync +++ b/lfs/rsync @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2013 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 3.1.1 +VER = 3.1.2
THISAPP = rsync-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -32,7 +32,7 @@ DL_FROM = $(URL_IPFIRE) DIR_APP = $(DIR_SRC)/$(THISAPP) TARGET = $(DIR_INFO)/$(THISAPP) PROG = rsync -PAK_VER = 9 +PAK_VER = 10
DEPS = ""
@@ -44,7 +44,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = 43bd6676f0b404326eee2d63be3cdcfe +$(DL_FILE)_MD5 = 0f758d7e000c0f7f7d3792610fad70cb
install : $(TARGET)
diff --git a/lfs/sed b/lfs/sed index 8904fd4..77eba0b 100644 --- a/lfs/sed +++ b/lfs/sed @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007 Michael Tremer & Christian Schmidt # +# Copyright (C) 2016 Michael Tremer & Christian Schmidt # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 4.2.1 +VER = 4.2.2
THISAPP = sed-$(VER) DL_FILE = $(THISAPP).tar.gz @@ -53,7 +53,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = f0fd4d7da574d4707e442285fd2d3b86 +$(DL_FILE)_MD5 = 4111de4faa3b9848a0686b2f260c5056
install : $(TARGET)
diff --git a/lfs/squid b/lfs/squid index de6c87d..997c660 100644 --- a/lfs/squid +++ b/lfs/squid @@ -71,6 +71,11 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar xaf $(DIR_DL)/$(DL_FILE) cd $(DIR_APP) && patch -Np0 -i $(DIR_SRC)/src/patches/squid-3.4-13228.patch + cd $(DIR_APP) && patch -Np0 -i $(DIR_SRC)/src/patches/squid-3.4.14-fix-max-file-descriptors.patch + cd $(DIR_APP) && patch -Np0 -i $(DIR_SRC)/src/patches/squid-3.4-13230.patch + cd $(DIR_APP) && autoreconf -vfi + cd $(DIR_APP)/libltdl && autoreconf -vfi + cd $(DIR_APP) && ./configure \ --prefix=/usr \ --sysconfdir=/etc/squid \ diff --git a/lfs/tzdata b/lfs/tzdata index dfb54e6..5cc3fc8 100644 --- a/lfs/tzdata +++ b/lfs/tzdata @@ -1,7 +1,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2011 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2016 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -24,7 +24,7 @@
include Config
-VER = 2015d +VER = 2016a TZDATA_VER = $(VER) TZCODE_VER = $(VER)
@@ -45,8 +45,8 @@ objects = tzdata$(TZDATA_VER).tar.gz tzcode$(TZCODE_VER).tar.gz tzdata$(TZDATA_VER).tar.gz = $(DL_FROM)/tzdata$(TZDATA_VER).tar.gz tzcode$(TZCODE_VER).tar.gz = $(DL_FROM)/tzcode$(TZCODE_VER).tar.gz
-tzdata$(TZDATA_VER).tar.gz_MD5 = b595bdc4474b8fc1a15cffc67c66025b -tzcode$(TZCODE_VER).tar.gz_MD5 = 4008a3abc025a398697b2587c48258b9 +tzdata$(TZDATA_VER).tar.gz_MD5 = 0d3123eb1b453ec0620822bd65be4c42 +tzcode$(TZCODE_VER).tar.gz_MD5 = f5e0299925631da7cf82d8ce1205111d
install : $(TARGET)
diff --git a/lfs/u-boot b/lfs/u-boot index 28f6508..3b3fbf2 100644 --- a/lfs/u-boot +++ b/lfs/u-boot @@ -75,6 +75,8 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE)
+ cd $(DIR_APP) && patch -Np1 < $(DIR_SRC)/src/patches/U-Boot-v2-fs-fat-read-fix-fat16-ls-read-issue.patch + # Pandaboard -mkdir -pv /usr/share/u-boot/pandaboard cd $(DIR_APP) && make CROSS_COMPILE="" omap4_panda_config diff --git a/lfs/xz b/lfs/xz index c1d3ef7..c09cb34 100644 --- a/lfs/xz +++ b/lfs/xz @@ -24,7 +24,7 @@
include Config
-VER = 5.2.1 +VER = 5.2.2
THISAPP = xz-$(VER) DL_FILE = $(THISAPP).tar.xz @@ -47,7 +47,7 @@ objects = $(DL_FILE)
$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
-$(DL_FILE)_MD5 = b5e2dd95dc8498cea5354377ed89aa65 +$(DL_FILE)_MD5 = e26772b69940085c0632589ab1d52e64
install : $(TARGET)
@@ -77,6 +77,7 @@ $(subst %,%_MD5,$(objects)) : $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects)) @$(PREBUILD) @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar axf $(DIR_DL)/$(DL_FILE) + cd $(DIR_APP) && sed -e '/mf.buffer = NULL/a next->coder->mf.size = 0;' -i src/liblzma/lz/lz_encoder.c cd $(DIR_APP) && ./configure --prefix=$(PREFIX) cd $(DIR_APP) && make $(MAKETUNING) cd $(DIR_APP) && make install diff --git a/make.sh b/make.sh index 08178b4..da4bf16 100755 --- a/make.sh +++ b/make.sh @@ -24,9 +24,9 @@
NAME="IPFire" # Software name SNAME="ipfire" # Short name -VERSION="2.17" # Version number -CORE="99" # Core Level (Filename) -PAKFIRE_CORE="99" # Core Level (PAKFIRE) +VERSION="2.19" # Version number +CORE="100" # Core Level (Filename) +PAKFIRE_CORE="100" # Core Level (PAKFIRE) GIT_BRANCH=`git rev-parse --abbrev-ref HEAD` # Git Branch SLOGAN="www.ipfire.org" # Software slogan CONFIG_ROOT=/var/ipfire # Configuration rootdir @@ -36,7 +36,7 @@ BUILD_IMAGES=1 # Flash and Xen Downloader KVER=`grep --max-count=1 VER lfs/linux | awk '{ print $3 }'` GIT_TAG=$(git tag | tail -1) # Git Tag GIT_LASTCOMMIT=$(git log | head -n1 | cut -d" " -f2 |head -c8) # Last commit -TOOLCHAINVER=10 +TOOLCHAINVER=11
# New architecture variables BUILD_ARCH="$(uname -m)" @@ -221,7 +221,7 @@ prepareenv() { # Run LFS static binary creation scripts one by one export CCACHE_DIR=$BASEDIR/ccache export CCACHE_COMPRESS=1 - export CCACHE_COMPILERCHECK="string:toolchain-${TOOLCHAINVER}:${TARGET_ARCH}" + export CCACHE_COMPILERCHECK="string:toolchain-${TOOLCHAINVER} ${TARGET_ARCH}"
# Remove pre-install list of installed files in case user erase some files before rebuild rm -f $BASEDIR/build/usr/src/lsalr 2>/dev/null @@ -287,6 +287,7 @@ buildtoolchain() { lfsmake1 linux TOOLS=1 KCFG="-headers" lfsmake1 glibc lfsmake1 cleanup-toolchain PASS=1 + lfsmake1 gcc PASS=L lfsmake1 binutils PASS=2 lfsmake1 gcc PASS=2 lfsmake1 ccache PASS=2 @@ -330,6 +331,7 @@ buildbase() { lfsmake2 gmp lfsmake2 gmp-compat lfsmake2 mpfr + lfsmake2 libmpc lfsmake2 file lfsmake2 gcc lfsmake2 sed @@ -398,7 +400,9 @@ buildipfire() { ipfiremake unzip ipfiremake which ipfiremake linux-firmware + ipfiremake ath10k-firmware ipfiremake dvb-firmwares + ipfiremake mt7601u-firmware ipfiremake zd1211-firmware ipfiremake rpi-firmware ipfiremake bc @@ -746,7 +750,7 @@ buildipfire() { ipfiremake streamripper ipfiremake sshfs ipfiremake taglib - ipfiremake mediatomb + #ipfiremake mediatomb ipfiremake sslh ipfiremake perl-gettext ipfiremake perl-Sort-Naturally @@ -844,6 +848,9 @@ buildipfire() { ipfiremake swconfig ipfiremake haproxy ipfiremake ipset + ipfiremake lua + ipfiremake dnsdist + ipfiremake bird }
buildinstaller() { diff --git a/src/initscripts/init.d/dnsdist b/src/initscripts/init.d/dnsdist new file mode 100644 index 0000000..03e6ab8 --- /dev/null +++ b/src/initscripts/init.d/dnsdist @@ -0,0 +1,46 @@ +#!/bin/sh +######################################################################## +# Begin $rc_base/init.d/dnsdist +# +# Description : dnsdist - A DNS load-balancer and more +# +######################################################################## + +. /etc/sysconfig/rc +. ${rc_functions} + +[ -r "/etc/sysconfig/dnsdist" ] && . /etc/sysconfig/dnsdist + +case "${1}" in + start) + boot_mesg "Starting dnsdist..." + loadproc /usr/bin/dnsdist -d ${ARGS} + ;; + + stop) + boot_mesg "Stopping dnsdist..." + killproc /usr/bin/dnsdist + ;; + + reload) + boot_mesg "Reloading dnsdist..." + reloadproc /usr/bin/dnsdist + ;; + + restart) + ${0} stop + sleep 1 + ${0} start + ;; + + status) + statusproc /usr/bin/dnsdist + ;; + + *) + echo "Usage: ${0} {start|stop|reload|restart|status}" + exit 1 + ;; +esac + +# End $rc_base/init.d/dnsdist diff --git a/src/initscripts/init.d/firewall b/src/initscripts/init.d/firewall index 6622071..cb52670 100644 --- a/src/initscripts/init.d/firewall +++ b/src/initscripts/init.d/firewall @@ -21,9 +21,11 @@ iptables_init() { iptables -F iptables -t nat -F iptables -t mangle -F + iptables -t raw -F iptables -X iptables -t nat -X iptables -t mangle -X + iptables -t raw -X
# Set up policies iptables -P INPUT DROP @@ -84,10 +86,71 @@ iptables_init() { iptables -A INPUT -p tcp -j BADTCP iptables -A FORWARD -p tcp -j BADTCP
- # Connection tracking chain + # Connection tracking chains iptables -N CONNTRACK - iptables -A CONNTRACK -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT + iptables -A CONNTRACK -m conntrack --ctstate ESTABLISHED -j ACCEPT iptables -A CONNTRACK -m conntrack --ctstate INVALID -j DROP + iptables -A CONNTRACK -p icmp -m conntrack --ctstate RELATED -j ACCEPT + iptables -t raw -N CONNTRACK + iptables -t raw -A PREROUTING -j CONNTRACK + + # Conntrack helpers (https://home.regit.org/netfilter-en/secure-use-of-helpers/) + + # SIP + if [ "${CONNTRACK_SIP}" = "on" ]; then + iptables -A CONNTRACK -m conntrack --ctstate RELATED \ + -m helper --helper sip -j ACCEPT + for proto in udp tcp; do + iptables -t raw -A CONNTRACK -p "${proto}" --dport 5060 -j CT --helper sip + done + fi + + # H.323 + if [ "${CONNTRACK_H323}" = "on" ]; then + iptables -A CONNTRACK -m conntrack --ctstate RELATED \ + -m helper --helper h323 -j ACCEPT + + # Gatekeeper RAS + iptables -t raw -A CONNTRACK -p udp --dport 1719 -j CT --helper RAS + + # Q.931 + iptables -t raw -A CONNTRACK -p tcp --dport 1720 -j CT --helper Q.931 + fi + + # FTP + if [ "${CONNTRACK_FTP}" = "on" ]; then + iptables -A CONNTRACK -m conntrack --ctstate RELATED \ + -m helper --helper ftp -p tcp --dport 1024: -j ACCEPT + iptables -t raw -A CONNTRACK -p tcp --dport 21 -j CT --helper ftp + fi + + # PPTP + if [ "${CONNTRACK_PPTP}" = "on" ]; then + iptables -A CONNTRACK -m conntrack --ctstate RELATED \ + -m helper --helper pptp -j ACCEPT + iptables -t raw -A CONNTRACK -p udp --dport 1723 -j CT --helper pptp + fi + + # TFTP + if [ "${CONNTRACK_TFTP}" = "on" ]; then + iptables -A CONNTRACK -m conntrack --ctstate RELATED \ + -m helper --helper tftp -j ACCEPT + iptables -t raw -A CONNTRACK -p udp --dport 69 -j CT --helper tftp + fi + + # IRC + if [ "${CONNTRACK_IRC}" = "on" ]; then + iptables -A CONNTRACK -m conntrack --ctstate RELATED \ + -m helper --helper irc -j ACCEPT + iptables -t raw -A CONNTRACK -p tcp --dport 6667 -j CT --helper irc + fi + + # Amanda + if [ "${CONNTRACK_AMANDA}" = "on" ]; then + iptables -A CONNTRACK -m conntrack --ctstate RELATED \ + -m helper --helper amanda -j ACCEPT + iptables -t raw -A CONNTRACK -p tcp -j CT --helper amanda + fi
# Fix for braindead ISP's iptables -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu @@ -400,24 +463,6 @@ iptables_red_down() { # See how we were called. case "$1" in start) - boot_mesg "Loading firewall modules into the kernel" - modprobe iptable_nat || failed=1 - for i in $(find /lib/modules/$(uname -r) -name nf_conntrack*); do - modprobe $(basename $i | cut -d. -f1) || failed=1 - done - for i in $(find /lib/modules/$(uname -r) -name nf_nat*); do - modprobe $(basename $i | cut -d. -f1) || failed=1 - done - (exit ${failed}) - evaluate_retval - - if [ -e /var/ipfire/main/disable_nf_sip ]; then - rmmod nf_nat_sip - rmmod nf_conntrack_sip - rmmod nf_nat_h323 - rmmod nf_conntrack_h323 - fi - boot_mesg "Setting up firewall" iptables_init evaluate_retval diff --git a/src/initscripts/init.d/functions b/src/initscripts/init.d/functions index 0d9b013..c00f659 100644 --- a/src/initscripts/init.d/functions +++ b/src/initscripts/init.d/functions @@ -728,7 +728,7 @@ use_ramdisk() { 2) local mem_avail="$(mem_amount)"
- if [ ${mem_avail} -ge 490 ]; then + if [ ${mem_avail} -ge 400 ]; then return 0 else return 1 diff --git a/src/initscripts/init.d/networking/dhcpcd.exe b/src/initscripts/init.d/networking/dhcpcd.exe index a7bad47..a2cdc66 100644 --- a/src/initscripts/init.d/networking/dhcpcd.exe +++ b/src/initscripts/init.d/networking/dhcpcd.exe @@ -31,13 +31,6 @@ dhcpcd_up() # Only if RED_TYPE=DHCP update /var/ipfire/red if [ "$RED_TYPE" == "DHCP" ]; then
- #Force MTU option for KabelDeutschland because this ISP - #set the MTU to 576 instead of the supportet 1500 - if [ $RED_DHCP_FORCE_MTU -ge 576 ]; then - logger -p local0.info -t dhcpcd.exe[$$] "Force mtu to $RED_DHCP_FORCE_MTU" - ip link set $interface mtu $RED_DHCP_FORCE_MTU - fi - #Check if we have to restart the services at update [ ! -e "/var/ipfire/red/active" ] && update=1; if [ "$old_domain_name_service" != "$new_domain_name_service" ]; then diff --git a/src/initscripts/init.d/ntp b/src/initscripts/init.d/ntp index 548b4c4..a746c1e 100644 --- a/src/initscripts/init.d/ntp +++ b/src/initscripts/init.d/ntp @@ -10,10 +10,10 @@ case "$1" in start) if [ "$ENABLESETONBOOT" == "on" ]; then boot_mesg -n "Setting time on boot..." - if [ $(pidof wpa_supplicant) ]; then + if [ $(pidof wpa_supplicant dhcpcd) ]; then if [ ! -e /var/ipfire/red/active ]; then boot_mesg "" - boot_mesg -n "Wait for wlan" + boot_mesg -n "Waiting for red connection" for (( i=30; i>1; i-- )) do if [ -e /var/ipfire/red/active ]; then break; diff --git a/src/misc-progs/qosctrl.c b/src/misc-progs/qosctrl.c index 5e1420b..c00dbcf 100644 --- a/src/misc-progs/qosctrl.c +++ b/src/misc-progs/qosctrl.c @@ -12,10 +12,14 @@ #include <sys/types.h> #include <fcntl.h> #include "setuid.h" +#include "libsmooth.h"
-int main(int argc, char *argv[]) { +#define QOS_SH "/var/ipfire/qos/bin/qos.sh"
+int main(int argc, char *argv[]) { + struct keyvalue* kv = NULL; int fd = -1; + int r = 0;
if (!(initsetuid())) exit(1); @@ -26,30 +30,48 @@ int main(int argc, char *argv[]) { }
if (strcmp(argv[1], "generate") == 0) { - safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > /var/ipfire/qos/bin/qos.sh"); + kv = initkeyvalues(); + if (!readkeyvalues(kv, CONFIG_ROOT "/qos/settings")) { + fprintf(stderr, "Cannot read QoS settings\n"); + r = 1; + goto END; + } + + char enabled[STRING_SIZE]; + if (!findkey(kv, "ENABLED", enabled)) + strcpy(enabled, "off"); + + if (strcmp(enabled, "on") == 0) + safe_system("/usr/bin/perl /var/ipfire/qos/bin/makeqosscripts.pl > " QOS_SH); + else + unlink(QOS_SH); }
- if ((fd = open("/var/ipfire/qos/bin/qos.sh", O_RDONLY)) != -1) { + if ((fd = open(QOS_SH, O_RDONLY)) != -1) { close(fd); } else { // If there is no qos.sh do nothing. - exit(0); + goto END; }
- safe_system("chmod 755 /var/ipfire/qos/bin/qos.sh &>/dev/null"); + safe_system("chmod 755 " QOS_SH " &>/dev/null"); if (strcmp(argv[1], "start") == 0) { - safe_system("/var/ipfire/qos/bin/qos.sh start"); + safe_system(QOS_SH " start"); } else if (strcmp(argv[1], "stop") == 0) { - safe_system("/var/ipfire/qos/bin/qos.sh clear"); + safe_system(QOS_SH " clear"); } else if (strcmp(argv[1], "status") == 0) { - safe_system("/var/ipfire/qos/bin/qos.sh status"); + safe_system(QOS_SH " status"); } else if (strcmp(argv[1], "restart") == 0) { - safe_system("/var/ipfire/qos/bin/qos.sh restart"); + safe_system(QOS_SH " restart"); } else { if (strcmp(argv[1], "generate") == 0) {exit(0);} fprintf(stderr, "\nBad argument given.\n\nqosctrl (start|stop|restart|status|generate)\n\n"); exit(1); }
- return 0; +END: + if (kv) + freekeyvalues(kv); + + return r; } diff --git a/src/misc-progs/timectrl.c b/src/misc-progs/timectrl.c index 48b0978..109d267 100644 --- a/src/misc-progs/timectrl.c +++ b/src/misc-progs/timectrl.c @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) { safe_system("ln -fs ../init.d/ntp /etc/rc.d/rc6.d/K46ntpd >/dev/null 2>&1"); safe_system("/etc/rc.d/init.d/ntp start"); } else if (strcmp(argv[1], "disable") == 0) { - safe_system("/etc/rc.d/init.d/ntpd stop"); + safe_system("/etc/rc.d/init.d/ntp stop"); safe_system("rm -f /etc/rc.d/rc*.d/*ntpd >/dev/null 2>&1"); } else { fprintf(stderr, "\nBad argument given.\n\ntimectrl (start|stop|restart)\n\n"); diff --git a/src/misc-progs/wirelessctrl.c b/src/misc-progs/wirelessctrl.c index 4a2e6dc..1e166eb 100644 --- a/src/misc-progs/wirelessctrl.c +++ b/src/misc-progs/wirelessctrl.c @@ -39,7 +39,6 @@ void exithandler(void) { }
int main(void) { - char green_dev[STRING_SIZE] = ""; char buffer[STRING_SIZE]; char *index, *ipaddress, *macaddress, *enabled; struct keyvalue *kv = NULL; @@ -68,14 +67,6 @@ int main(void) { exit(1); }
- /* Get the GREEN interface details */ - if (findkey(kv, "GREEN_DEV", green_dev) > 0) { - if (!VALID_DEVICE(green_dev)) { - fprintf(stderr, "Bad GREEN_DEV: %s\n", green_dev); - exit(1); - } - } - /* Get the BLUE interface details */ if (findkey(kv, "BLUE_DEV", blue_dev) > 0) { if ((strlen(blue_dev) > 0) && !VALID_DEVICE(blue_dev)) { @@ -135,21 +126,21 @@ int main(void) { if (strcmp(enabled, "on") == 0) { /* both specified, added security */ if ((strlen(macaddress) == 17) && (VALID_IP_AND_MASK(ipaddress))) { - snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSINPUT -m mac --mac-source %s -s %s -i %s -j ACCEPT", macaddress, ipaddress, blue_dev); + snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSINPUT -m mac --mac-source %s -s %s -i %s -j RETURN", macaddress, ipaddress, blue_dev); safe_system(command); snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSFORWARD -m mac --mac-source %s -s %s -i %s -j RETURN", macaddress, ipaddress, blue_dev); safe_system(command); } else { /* correctly formed mac address is 17 chars */ if (strlen(macaddress) == 17) { - snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSINPUT -m mac --mac-source %s -i %s -j ACCEPT", macaddress, blue_dev); + snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSINPUT -m mac --mac-source %s -i %s -j RETURN", macaddress, blue_dev); safe_system(command); snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSFORWARD -m mac --mac-source %s -i %s -j RETURN", macaddress, blue_dev); safe_system(command); }
if (VALID_IP_AND_MASK(ipaddress)) { - snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSINPUT -s %s -i %s -j ACCEPT", ipaddress, blue_dev); + snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSINPUT -s %s -i %s -j RETURN", ipaddress, blue_dev); safe_system(command); snprintf(command, STRING_SIZE-1, "/sbin/iptables --wait -A WIRELESSFORWARD -s %s -i %s -j RETURN", ipaddress, blue_dev); safe_system(command); diff --git a/src/pakfire/pakfire.conf b/src/pakfire/pakfire.conf index 1c74f3c..2f8f9cd 100644 --- a/src/pakfire/pakfire.conf +++ b/src/pakfire/pakfire.conf @@ -2,7 +2,7 @@ ############################################################################### # # # IPFire.org - A linux based firewall # -# Copyright (C) 2007-2013 IPFire Team info@ipfire.org # +# Copyright (C) 2007-2017 IPFire Team info@ipfire.org # # # # This program is free software: you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # diff --git a/src/paks/linux-pae/install.sh b/src/paks/linux-pae/install.sh index 4ebb38b..58a9c1c 100644 --- a/src/paks/linux-pae/install.sh +++ b/src/paks/linux-pae/install.sh @@ -67,6 +67,7 @@ else echo "timeout 10" > /boot/grub/grub.conf echo "default 0" >> /boot/grub/grub.conf echo "title IPFire (pae-kernel)" >> /boot/grub/grub.conf + echo " root (hd0)" >> /boot/grub/grub.conf echo " kernel /vmlinuz-$KVER-ipfire-pae root=/dev/$ROOT rootdelay=10 panic=10 console=hvc0" \ >> /boot/grub/grub.conf echo " initrd /initramfs-$KVER-ipfire-pae.img" >> /boot/grub/grub.conf diff --git a/src/patches/U-Boot-v2-fs-fat-read-fix-fat16-ls-read-issue.patch b/src/patches/U-Boot-v2-fs-fat-read-fix-fat16-ls-read-issue.patch new file mode 100644 index 0000000..39acf14 --- /dev/null +++ b/src/patches/U-Boot-v2-fs-fat-read-fix-fat16-ls-read-issue.patch @@ -0,0 +1,128 @@ +diff --git a/fs/fat/fat.c b/fs/fat/fat.c +index 04a51db..bccc3e3 100644 +--- a/fs/fat/fat.c ++++ b/fs/fat/fat.c +@@ -823,8 +823,11 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer, + int ret = -1; + int firsttime; + __u32 root_cluster = 0; ++ __u32 read_blk; + int rootdir_size = 0; +- int j; ++ int buffer_blk_cnt; ++ int do_read; ++ __u8 *dir_ptr; + + if (read_bootsectandvi(&bs, &volinfo, &mydata->fatsize)) { + debug("Error: reading boot sector\n"); +@@ -909,24 +912,54 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer, + isdir = 1; + } + +- j = 0; ++ buffer_blk_cnt = 0; ++ firsttime = 1; + while (1) { + int i; + +- if (j == 0) { +- debug("FAT read sect=%d, clust_size=%d, DIRENTSPERBLOCK=%zd\n", +- cursect, mydata->clust_size, DIRENTSPERBLOCK); ++ if (mydata->fatsize == 32 || firsttime) { ++ dir_ptr = do_fat_read_at_block; ++ firsttime = 0; ++ } else { ++ /** ++ * FAT16 sector buffer modification: ++ * Each loop, the second buffered block is moved to ++ * the buffer begin, and two next sectors are read ++ * next to the previously moved one. So the sector ++ * buffer keeps always 3 sectors for fat16. ++ * And the current sector is the buffer second sector ++ * beside the "firsttime" read, when it is the first one. ++ * ++ * PREFETCH_BLOCKS is 2 for FAT16 == loop[0:1] ++ * n = computed root dir sector ++ * loop | cursect-1 | cursect | cursect+1 | ++ * 0 | sector n+0 | sector n+1 | none | ++ * 1 | none | sector n+0 | sector n+1 | ++ * 0 | sector n+1 | sector n+2 | sector n+3 | ++ * 1 | sector n+3 | ... ++ */ ++ dir_ptr = (do_fat_read_at_block + mydata->sect_size); ++ memcpy(do_fat_read_at_block, dir_ptr, mydata->sect_size); ++ } ++ ++ do_read = 1; ++ ++ if (mydata->fatsize == 32 && buffer_blk_cnt) ++ do_read = 0; ++ ++ if (do_read) { ++ read_blk = (mydata->fatsize == 32) ? ++ mydata->clust_size : PREFETCH_BLOCKS; ++ ++ debug("FAT read(sect=%d, cnt:%d), clust_size=%d, DIRENTSPERBLOCK=%zd\n", ++ cursect, read_blk, mydata->clust_size, DIRENTSPERBLOCK); + +- if (disk_read(cursect, +- (mydata->fatsize == 32) ? +- (mydata->clust_size) : +- PREFETCH_BLOCKS, +- do_fat_read_at_block) < 0) { ++ if (disk_read(cursect, read_blk, dir_ptr) < 0) { + debug("Error: reading rootdir block\n"); + goto exit; + } + +- dentptr = (dir_entry *) do_fat_read_at_block; ++ dentptr = (dir_entry *)dir_ptr; + } + + for (i = 0; i < DIRENTSPERBLOCK; i++) { +@@ -951,7 +984,7 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer, + + get_vfatname(mydata, + root_cluster, +- do_fat_read_at_block, ++ dir_ptr, + dentptr, l_name); + + if (dols == LS_ROOT) { +@@ -1062,7 +1095,7 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer, + + goto rootdir_done; /* We got a match */ + } +- debug("END LOOP: j=%d clust_size=%d\n", j, ++ debug("END LOOP: buffer_blk_cnt=%d clust_size=%d\n", buffer_blk_cnt, + mydata->clust_size); + + /* +@@ -1070,10 +1103,10 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer, + * root directory clusters when a cluster has been + * completely processed. + */ +- ++j; ++ ++buffer_blk_cnt; + int rootdir_end = 0; + if (mydata->fatsize == 32) { +- if (j == mydata->clust_size) { ++ if (buffer_blk_cnt == mydata->clust_size) { + int nxtsect = 0; + int nxt_clust = 0; + +@@ -1086,11 +1119,11 @@ int do_fat_read_at(const char *filename, loff_t pos, void *buffer, + root_cluster = nxt_clust; + + cursect = nxtsect; +- j = 0; ++ buffer_blk_cnt = 0; + } + } else { +- if (j == PREFETCH_BLOCKS) +- j = 0; ++ if (buffer_blk_cnt == PREFETCH_BLOCKS) ++ buffer_blk_cnt = 0; + + rootdir_end = (++cursect - mydata->rootdir_sect >= + rootdir_size); diff --git a/src/patches/arm-multi-grsec-compile-fixes.patch b/src/patches/arm-multi-grsec-compile-fixes.patch new file mode 100644 index 0000000..fb0d39b --- /dev/null +++ b/src/patches/arm-multi-grsec-compile-fixes.patch @@ -0,0 +1,23 @@ +--- a/arch/arm/mach-omap2/cclock3xxx_data.c~ 2015-12-12 11:00:10.474423373 +0000 ++++ b/arch/arm/mach-omap2/cclock3xxx_data.c 2015-12-12 11:30:31.198452547 +0000 +@@ -250,7 +250,7 @@ + + static struct clk dpll1_ck; + +-static struct clk_ops dpll1_ck_ops; ++static clk_ops_no_const dpll1_ck_ops; + + static struct clk_ops dpll1_ck_ops_34xx __initdata = { + .init = &omap2_init_clk_clkdm, +diff -Naur linux-3.14.63-org/net/ipv6/addrconf.c linux-3.14.63/net/ipv6/addrconf.c +--- linux-3.14.63-org/net/ipv6/addrconf.c 2016-03-04 22:56:07.375481749 +0100 ++++ linux-3.14.63/net/ipv6/addrconf.c 2016-03-04 23:08:34.285482105 +0100 +@@ -4818,7 +4818,7 @@ + { + struct inet6_dev *idev = ctl->extra1; + int min_mtu = IPV6_MIN_MTU; +- struct ctl_table lctl; ++ ctl_table_no_const lctl; + + lctl = *ctl; + lctl.extra1 = &min_mtu; diff --git a/src/patches/backports-3.18.1-1-add_usbnet_modules.patch b/src/patches/backports-3.18.1-1-add_usbnet_modules.patch deleted file mode 100644 index 11b9638..0000000 --- a/src/patches/backports-3.18.1-1-add_usbnet_modules.patch +++ /dev/null @@ -1,29383 +0,0 @@ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/asix_common.c backports-3.18.1-1/drivers/net/usb/asix_common.c ---- backports-3.18.1-1.org/drivers/net/usb/asix_common.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/asix_common.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,582 @@ -+/* -+ * ASIX AX8817X based USB 2.0 Ethernet Devices -+ * Copyright (C) 2003-2006 David Hollis dhollis@davehollis.com -+ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net -+ * Copyright (C) 2006 James Painter jamie.painter@iname.com -+ * Copyright (c) 2002-2003 TiVo Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include "asix.h" -+ -+int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data) -+{ -+ int ret; -+ ret = usbnet_read_cmd(dev, cmd, -+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ value, index, data, size); -+ -+ if (ret != size && ret >= 0) -+ return -EINVAL; -+ return ret; -+} -+ -+int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data) -+{ -+ return usbnet_write_cmd(dev, cmd, -+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ value, index, data, size); -+} -+ -+void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data) -+{ -+ usbnet_write_cmd_async(dev, cmd, -+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ value, index, data, size); -+} -+ -+int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb, -+ struct asix_rx_fixup_info *rx) -+{ -+ int offset = 0; -+ -+ while (offset + sizeof(u16) <= skb->len) { -+ u16 remaining = 0; -+ unsigned char *data; -+ -+ if (!rx->size) { -+ if ((skb->len - offset == sizeof(u16)) || -+ rx->split_head) { -+ if(!rx->split_head) { -+ rx->header = get_unaligned_le16( -+ skb->data + offset); -+ rx->split_head = true; -+ offset += sizeof(u16); -+ break; -+ } else { -+ rx->header |= (get_unaligned_le16( -+ skb->data + offset) -+ << 16); -+ rx->split_head = false; -+ offset += sizeof(u16); -+ } -+ } else { -+ rx->header = get_unaligned_le32(skb->data + -+ offset); -+ offset += sizeof(u32); -+ } -+ -+ /* get the packet length */ -+ rx->size = (u16) (rx->header & 0x7ff); -+ if (rx->size != ((~rx->header >> 16) & 0x7ff)) { -+ netdev_err(dev->net, "asix_rx_fixup() Bad Header Length 0x%x, offset %d\n", -+ rx->header, offset); -+ rx->size = 0; -+ return 0; -+ } -+ rx->ax_skb = netdev_alloc_skb_ip_align(dev->net, -+ rx->size); -+ if (!rx->ax_skb) -+ return 0; -+ } -+ -+ if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) { -+ netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n", -+ rx->size); -+ kfree_skb(rx->ax_skb); -+ rx->ax_skb = NULL; -+ rx->size = 0U; -+ -+ return 0; -+ } -+ -+ if (rx->size > skb->len - offset) { -+ remaining = rx->size - (skb->len - offset); -+ rx->size = skb->len - offset; -+ } -+ -+ data = skb_put(rx->ax_skb, rx->size); -+ memcpy(data, skb->data + offset, rx->size); -+ if (!remaining) -+ usbnet_skb_return(dev, rx->ax_skb); -+ -+ offset += (rx->size + 1) & 0xfffe; -+ rx->size = remaining; -+ } -+ -+ if (skb->len != offset) { -+ netdev_err(dev->net, "asix_rx_fixup() Bad SKB Length %d, %d\n", -+ skb->len, offset); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb) -+{ -+ struct asix_common_private *dp = dev->driver_priv; -+ struct asix_rx_fixup_info *rx = &dp->rx_fixup_info; -+ -+ return asix_rx_fixup_internal(dev, skb, rx); -+} -+ -+struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb, -+ gfp_t flags) -+{ -+ int padlen; -+ int headroom = skb_headroom(skb); -+ int tailroom = skb_tailroom(skb); -+ u32 packet_len; -+ u32 padbytes = 0xffff0000; -+ -+ padlen = ((skb->len + 4) & (dev->maxpacket - 1)) ? 0 : 4; -+ -+ /* We need to push 4 bytes in front of frame (packet_len) -+ * and maybe add 4 bytes after the end (if padlen is 4) -+ * -+ * Avoid skb_copy_expand() expensive call, using following rules : -+ * - We are allowed to push 4 bytes in headroom if skb_header_cloned() -+ * is false (and if we have 4 bytes of headroom) -+ * - We are allowed to put 4 bytes at tail if skb_cloned() -+ * is false (and if we have 4 bytes of tailroom) -+ * -+ * TCP packets for example are cloned, but skb_header_release() -+ * was called in tcp stack, allowing us to use headroom for our needs. -+ */ -+ if (!skb_header_cloned(skb) && -+ !(padlen && skb_cloned(skb)) && -+ headroom + tailroom >= 4 + padlen) { -+ /* following should not happen, but better be safe */ -+ if (headroom < 4 || -+ tailroom < padlen) { -+ skb->data = memmove(skb->head + 4, skb->data, skb->len); -+ skb_set_tail_pointer(skb, skb->len); -+ } -+ } else { -+ struct sk_buff *skb2; -+ -+ skb2 = skb_copy_expand(skb, 4, padlen, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (!skb) -+ return NULL; -+ } -+ -+ packet_len = ((skb->len ^ 0x0000ffff) << 16) + skb->len; -+ skb_push(skb, 4); -+ cpu_to_le32s(&packet_len); -+ skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len)); -+ -+ if (padlen) { -+ cpu_to_le32s(&padbytes); -+ memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes)); -+ skb_put(skb, sizeof(padbytes)); -+ } -+ return skb; -+} -+ -+int asix_set_sw_mii(struct usbnet *dev) -+{ -+ int ret; -+ ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to enable software MII access\n"); -+ return ret; -+} -+ -+int asix_set_hw_mii(struct usbnet *dev) -+{ -+ int ret; -+ ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to enable hardware MII access\n"); -+ return ret; -+} -+ -+int asix_read_phy_addr(struct usbnet *dev, int internal) -+{ -+ int offset = (internal ? 1 : 0); -+ u8 buf[2]; -+ int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf); -+ -+ netdev_dbg(dev->net, "asix_get_phy_addr()\n"); -+ -+ if (ret < 0) { -+ netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret); -+ goto out; -+ } -+ netdev_dbg(dev->net, "asix_get_phy_addr() returning 0x%04x\n", -+ *((__le16 *)buf)); -+ ret = buf[offset]; -+ -+out: -+ return ret; -+} -+ -+int asix_get_phy_addr(struct usbnet *dev) -+{ -+ /* return the address of the internal phy */ -+ return asix_read_phy_addr(dev, 1); -+} -+ -+ -+int asix_sw_reset(struct usbnet *dev, u8 flags) -+{ -+ int ret; -+ -+ ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to send software reset: %02x\n", ret); -+ -+ return ret; -+} -+ -+u16 asix_read_rx_ctl(struct usbnet *dev) -+{ -+ __le16 v; -+ int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v); -+ -+ if (ret < 0) { -+ netdev_err(dev->net, "Error reading RX_CTL register: %02x\n", ret); -+ goto out; -+ } -+ ret = le16_to_cpu(v); -+out: -+ return ret; -+} -+ -+int asix_write_rx_ctl(struct usbnet *dev, u16 mode) -+{ -+ int ret; -+ -+ netdev_dbg(dev->net, "asix_write_rx_ctl() - mode = 0x%04x\n", mode); -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to write RX_CTL mode to 0x%04x: %02x\n", -+ mode, ret); -+ -+ return ret; -+} -+ -+u16 asix_read_medium_status(struct usbnet *dev) -+{ -+ __le16 v; -+ int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v); -+ -+ if (ret < 0) { -+ netdev_err(dev->net, "Error reading Medium Status register: %02x\n", -+ ret); -+ return ret; /* TODO: callers not checking for error ret */ -+ } -+ -+ return le16_to_cpu(v); -+ -+} -+ -+int asix_write_medium_mode(struct usbnet *dev, u16 mode) -+{ -+ int ret; -+ -+ netdev_dbg(dev->net, "asix_write_medium_mode() - mode = 0x%04x\n", mode); -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to write Medium Mode mode to 0x%04x: %02x\n", -+ mode, ret); -+ -+ return ret; -+} -+ -+int asix_write_gpio(struct usbnet *dev, u16 value, int sleep) -+{ -+ int ret; -+ -+ netdev_dbg(dev->net, "asix_write_gpio() - value = 0x%04x\n", value); -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to write GPIO value 0x%04x: %02x\n", -+ value, ret); -+ -+ if (sleep) -+ msleep(sleep); -+ -+ return ret; -+} -+ -+/* -+ * AX88772 & AX88178 have a 16-bit RX_CTL value -+ */ -+void asix_set_multicast(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ u16 rx_ctl = AX_DEFAULT_RX_CTL; -+ -+ if (net->flags & IFF_PROMISC) { -+ rx_ctl |= AX_RX_CTL_PRO; -+ } else if (net->flags & IFF_ALLMULTI || -+ netdev_mc_count(net) > AX_MAX_MCAST) { -+ rx_ctl |= AX_RX_CTL_AMALL; -+ } else if (netdev_mc_empty(net)) { -+ /* just broadcast and directed */ -+ } else { -+ /* We use the 20 byte dev->data -+ * for our 8 byte filter buffer -+ * to avoid allocating memory that -+ * is tricky to free later */ -+ struct netdev_hw_addr *ha; -+ u32 crc_bits; -+ -+ memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); -+ -+ /* Build the multicast hash filter. */ -+ netdev_for_each_mc_addr(ha, net) { -+ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; -+ data->multi_filter[crc_bits >> 3] |= -+ 1 << (crc_bits & 7); -+ } -+ -+ asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, -+ AX_MCAST_FILTER_SIZE, data->multi_filter); -+ -+ rx_ctl |= AX_RX_CTL_AM; -+ } -+ -+ asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); -+} -+ -+int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ __le16 res; -+ -+ mutex_lock(&dev->phy_mutex); -+ asix_set_sw_mii(dev); -+ asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, -+ (__u16)loc, 2, &res); -+ asix_set_hw_mii(dev); -+ mutex_unlock(&dev->phy_mutex); -+ -+ netdev_dbg(dev->net, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", -+ phy_id, loc, le16_to_cpu(res)); -+ -+ return le16_to_cpu(res); -+} -+ -+void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ __le16 res = cpu_to_le16(val); -+ -+ netdev_dbg(dev->net, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", -+ phy_id, loc, val); -+ mutex_lock(&dev->phy_mutex); -+ asix_set_sw_mii(dev); -+ asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); -+ asix_set_hw_mii(dev); -+ mutex_unlock(&dev->phy_mutex); -+} -+ -+void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u8 opt; -+ -+ if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) { -+ wolinfo->supported = 0; -+ wolinfo->wolopts = 0; -+ return; -+ } -+ wolinfo->supported = WAKE_PHY | WAKE_MAGIC; -+ wolinfo->wolopts = 0; -+ if (opt & AX_MONITOR_LINK) -+ wolinfo->wolopts |= WAKE_PHY; -+ if (opt & AX_MONITOR_MAGIC) -+ wolinfo->wolopts |= WAKE_MAGIC; -+} -+ -+int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u8 opt = 0; -+ -+ if (wolinfo->wolopts & WAKE_PHY) -+ opt |= AX_MONITOR_LINK; -+ if (wolinfo->wolopts & WAKE_MAGIC) -+ opt |= AX_MONITOR_MAGIC; -+ -+ if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, -+ opt, 0, 0, NULL) < 0) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+int asix_get_eeprom_len(struct net_device *net) -+{ -+ return AX_EEPROM_LEN; -+} -+ -+int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, -+ u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u16 *eeprom_buff; -+ int first_word, last_word; -+ int i; -+ -+ if (eeprom->len == 0) -+ return -EINVAL; -+ -+ eeprom->magic = AX_EEPROM_MAGIC; -+ -+ first_word = eeprom->offset >> 1; -+ last_word = (eeprom->offset + eeprom->len - 1) >> 1; -+ -+ eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), -+ GFP_KERNEL); -+ if (!eeprom_buff) -+ return -ENOMEM; -+ -+ /* ax8817x returns 2 bytes from eeprom on read */ -+ for (i = first_word; i <= last_word; i++) { -+ if (asix_read_cmd(dev, AX_CMD_READ_EEPROM, i, 0, 2, -+ &(eeprom_buff[i - first_word])) < 0) { -+ kfree(eeprom_buff); -+ return -EIO; -+ } -+ } -+ -+ memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); -+ kfree(eeprom_buff); -+ return 0; -+} -+ -+int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, -+ u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u16 *eeprom_buff; -+ int first_word, last_word; -+ int i; -+ int ret; -+ -+ netdev_dbg(net, "write EEPROM len %d, offset %d, magic 0x%x\n", -+ eeprom->len, eeprom->offset, eeprom->magic); -+ -+ if (eeprom->len == 0) -+ return -EINVAL; -+ -+ if (eeprom->magic != AX_EEPROM_MAGIC) -+ return -EINVAL; -+ -+ first_word = eeprom->offset >> 1; -+ last_word = (eeprom->offset + eeprom->len - 1) >> 1; -+ -+ eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), -+ GFP_KERNEL); -+ if (!eeprom_buff) -+ return -ENOMEM; -+ -+ /* align data to 16 bit boundaries, read the missing data from -+ the EEPROM */ -+ if (eeprom->offset & 1) { -+ ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, first_word, 0, 2, -+ &(eeprom_buff[0])); -+ if (ret < 0) { -+ netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word); -+ goto free; -+ } -+ } -+ -+ if ((eeprom->offset + eeprom->len) & 1) { -+ ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, last_word, 0, 2, -+ &(eeprom_buff[last_word - first_word])); -+ if (ret < 0) { -+ netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word); -+ goto free; -+ } -+ } -+ -+ memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len); -+ -+ /* write data to EEPROM */ -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0x0000, 0, 0, NULL); -+ if (ret < 0) { -+ netdev_err(net, "Failed to enable EEPROM write\n"); -+ goto free; -+ } -+ msleep(20); -+ -+ for (i = first_word; i <= last_word; i++) { -+ netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n", -+ i, eeprom_buff[i - first_word]); -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_EEPROM, i, -+ eeprom_buff[i - first_word], 0, NULL); -+ if (ret < 0) { -+ netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", -+ i); -+ goto free; -+ } -+ msleep(20); -+ } -+ -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0x0000, 0, 0, NULL); -+ if (ret < 0) { -+ netdev_err(net, "Failed to disable EEPROM write\n"); -+ goto free; -+ } -+ -+ ret = 0; -+free: -+ kfree(eeprom_buff); -+ return ret; -+} -+ -+void asix_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info) -+{ -+ /* Inherit standard device info */ -+ usbnet_get_drvinfo(net, info); -+ strlcpy(info->driver, DRIVER_NAME, sizeof(info->driver)); -+ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); -+ info->eedump_len = AX_EEPROM_LEN; -+} -+ -+int asix_set_mac_address(struct net_device *net, void *p) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ struct sockaddr *addr = p; -+ -+ if (netif_running(net)) -+ return -EBUSY; -+ if (!is_valid_ether_addr(addr->sa_data)) -+ return -EADDRNOTAVAIL; -+ -+ memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); -+ -+ /* We use the 20 byte dev->data -+ * for our 6 byte mac buffer -+ * to avoid allocating memory that -+ * is tricky to free later */ -+ memcpy(data->mac_addr, addr->sa_data, ETH_ALEN); -+ asix_write_cmd_async(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, -+ data->mac_addr); -+ -+ return 0; -+} -diff -Naur backports-3.18.1-1.org/drivers/net/usb/asix_devices.c backports-3.18.1-1/drivers/net/usb/asix_devices.c ---- backports-3.18.1-1.org/drivers/net/usb/asix_devices.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/asix_devices.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,1104 @@ -+/* -+ * ASIX AX8817X based USB 2.0 Ethernet Devices -+ * Copyright (C) 2003-2006 David Hollis dhollis@davehollis.com -+ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net -+ * Copyright (C) 2006 James Painter jamie.painter@iname.com -+ * Copyright (c) 2002-2003 TiVo Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include "asix.h" -+ -+#define PHY_MODE_MARVELL 0x0000 -+#define MII_MARVELL_LED_CTRL 0x0018 -+#define MII_MARVELL_STATUS 0x001b -+#define MII_MARVELL_CTRL 0x0014 -+ -+#define MARVELL_LED_MANUAL 0x0019 -+ -+#define MARVELL_STATUS_HWCFG 0x0004 -+ -+#define MARVELL_CTRL_TXDELAY 0x0002 -+#define MARVELL_CTRL_RXDELAY 0x0080 -+ -+#define PHY_MODE_RTL8211CL 0x000C -+ -+struct ax88172_int_data { -+ __le16 res1; -+ u8 link; -+ __le16 res2; -+ u8 status; -+ __le16 res3; -+} __packed; -+ -+static void asix_status(struct usbnet *dev, struct urb *urb) -+{ -+ struct ax88172_int_data *event; -+ int link; -+ -+ if (urb->actual_length < 8) -+ return; -+ -+ event = urb->transfer_buffer; -+ link = event->link & 0x01; -+ if (netif_carrier_ok(dev->net) != link) { -+ usbnet_link_change(dev, link, 1); -+ netdev_dbg(dev->net, "Link Status is: %d\n", link); -+ } -+} -+ -+static void asix_set_netdev_dev_addr(struct usbnet *dev, u8 *addr) -+{ -+ if (is_valid_ether_addr(addr)) { -+ memcpy(dev->net->dev_addr, addr, ETH_ALEN); -+ } else { -+ netdev_info(dev->net, "invalid hw address, using random\n"); -+ eth_hw_addr_random(dev->net); -+ } -+} -+ -+/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ -+static u32 asix_get_phyid(struct usbnet *dev) -+{ -+ int phy_reg; -+ u32 phy_id; -+ int i; -+ -+ /* Poll for the rare case the FW or phy isn't ready yet. */ -+ for (i = 0; i < 100; i++) { -+ phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1); -+ if (phy_reg != 0 && phy_reg != 0xFFFF) -+ break; -+ mdelay(1); -+ } -+ -+ if (phy_reg <= 0 || phy_reg == 0xFFFF) -+ return 0; -+ -+ phy_id = (phy_reg & 0xffff) << 16; -+ -+ phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2); -+ if (phy_reg < 0) -+ return 0; -+ -+ phy_id |= (phy_reg & 0xffff); -+ -+ return phy_id; -+} -+ -+static u32 asix_get_link(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ return mii_link_ok(&dev->mii); -+} -+ -+static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -+} -+ -+/* We need to override some ethtool_ops so we require our -+ own structure so we don't interfere with other usbnet -+ devices that may be connected at the same time. */ -+static const struct ethtool_ops ax88172_ethtool_ops = { -+ .get_drvinfo = asix_get_drvinfo, -+ .get_link = asix_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_wol = asix_get_wol, -+ .set_wol = asix_set_wol, -+ .get_eeprom_len = asix_get_eeprom_len, -+ .get_eeprom = asix_get_eeprom, -+ .set_eeprom = asix_set_eeprom, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .nway_reset = usbnet_nway_reset, -+}; -+ -+static void ax88172_set_multicast(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ u8 rx_ctl = 0x8c; -+ -+ if (net->flags & IFF_PROMISC) { -+ rx_ctl |= 0x01; -+ } else if (net->flags & IFF_ALLMULTI || -+ netdev_mc_count(net) > AX_MAX_MCAST) { -+ rx_ctl |= 0x02; -+ } else if (netdev_mc_empty(net)) { -+ /* just broadcast and directed */ -+ } else { -+ /* We use the 20 byte dev->data -+ * for our 8 byte filter buffer -+ * to avoid allocating memory that -+ * is tricky to free later */ -+ struct netdev_hw_addr *ha; -+ u32 crc_bits; -+ -+ memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); -+ -+ /* Build the multicast hash filter. */ -+ netdev_for_each_mc_addr(ha, net) { -+ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; -+ data->multi_filter[crc_bits >> 3] |= -+ 1 << (crc_bits & 7); -+ } -+ -+ asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, -+ AX_MCAST_FILTER_SIZE, data->multi_filter); -+ -+ rx_ctl |= 0x10; -+ } -+ -+ asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); -+} -+ -+static int ax88172_link_reset(struct usbnet *dev) -+{ -+ u8 mode; -+ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; -+ -+ mii_check_media(&dev->mii, 1, 1); -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ mode = AX88172_MEDIUM_DEFAULT; -+ -+ if (ecmd.duplex != DUPLEX_FULL) -+ mode |= ~AX88172_MEDIUM_FD; -+ -+ netdev_dbg(dev->net, "ax88172_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", -+ ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); -+ -+ asix_write_medium_mode(dev, mode); -+ -+ return 0; -+} -+ -+static const struct net_device_ops ax88172_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_set_mac_address = eth_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = asix_ioctl, -+ .ndo_set_rx_mode = ax88172_set_multicast, -+}; -+ -+static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int ret = 0; -+ u8 buf[ETH_ALEN]; -+ int i; -+ unsigned long gpio_bits = dev->driver_info->data; -+ -+ usbnet_get_endpoints(dev,intf); -+ -+ /* Toggle the GPIOs in a manufacturer/model specific way */ -+ for (i = 2; i >= 0; i--) { -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, -+ (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL); -+ if (ret < 0) -+ goto out; -+ msleep(5); -+ } -+ -+ ret = asix_write_rx_ctl(dev, 0x80); -+ if (ret < 0) -+ goto out; -+ -+ /* Get the MAC address */ -+ ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "read AX_CMD_READ_NODE_ID failed: %d\n", -+ ret); -+ goto out; -+ } -+ -+ asix_set_netdev_dev_addr(dev, buf); -+ -+ /* Initialize MII structure */ -+ dev->mii.dev = dev->net; -+ dev->mii.mdio_read = asix_mdio_read; -+ dev->mii.mdio_write = asix_mdio_write; -+ dev->mii.phy_id_mask = 0x3f; -+ dev->mii.reg_num_mask = 0x1f; -+ dev->mii.phy_id = asix_get_phy_addr(dev); -+ -+ dev->net->netdev_ops = &ax88172_netdev_ops; -+ dev->net->ethtool_ops = &ax88172_ethtool_ops; -+ dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */ -+ dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */ -+ -+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); -+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, -+ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); -+ mii_nway_restart(&dev->mii); -+ -+ return 0; -+ -+out: -+ return ret; -+} -+ -+static const struct ethtool_ops ax88772_ethtool_ops = { -+ .get_drvinfo = asix_get_drvinfo, -+ .get_link = asix_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_wol = asix_get_wol, -+ .set_wol = asix_set_wol, -+ .get_eeprom_len = asix_get_eeprom_len, -+ .get_eeprom = asix_get_eeprom, -+ .set_eeprom = asix_set_eeprom, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .nway_reset = usbnet_nway_reset, -+}; -+ -+static int ax88772_link_reset(struct usbnet *dev) -+{ -+ u16 mode; -+ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; -+ -+ mii_check_media(&dev->mii, 1, 1); -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ mode = AX88772_MEDIUM_DEFAULT; -+ -+ if (ethtool_cmd_speed(&ecmd) != SPEED_100) -+ mode &= ~AX_MEDIUM_PS; -+ -+ if (ecmd.duplex != DUPLEX_FULL) -+ mode &= ~AX_MEDIUM_FD; -+ -+ netdev_dbg(dev->net, "ax88772_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", -+ ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); -+ -+ asix_write_medium_mode(dev, mode); -+ -+ return 0; -+} -+ -+static int ax88772_reset(struct usbnet *dev) -+{ -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ int ret, embd_phy; -+ u16 rx_ctl; -+ -+ ret = asix_write_gpio(dev, -+ AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5); -+ if (ret < 0) -+ goto out; -+ -+ embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0); -+ -+ ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); -+ goto out; -+ } -+ -+ ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL); -+ if (ret < 0) -+ goto out; -+ -+ msleep(150); -+ -+ ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); -+ if (ret < 0) -+ goto out; -+ -+ msleep(150); -+ -+ if (embd_phy) { -+ ret = asix_sw_reset(dev, AX_SWRESET_IPRL); -+ if (ret < 0) -+ goto out; -+ } else { -+ ret = asix_sw_reset(dev, AX_SWRESET_PRTE); -+ if (ret < 0) -+ goto out; -+ } -+ -+ msleep(150); -+ rx_ctl = asix_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); -+ ret = asix_write_rx_ctl(dev, 0x0000); -+ if (ret < 0) -+ goto out; -+ -+ rx_ctl = asix_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); -+ -+ ret = asix_sw_reset(dev, AX_SWRESET_PRL); -+ if (ret < 0) -+ goto out; -+ -+ msleep(150); -+ -+ ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL); -+ if (ret < 0) -+ goto out; -+ -+ msleep(150); -+ -+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); -+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, -+ ADVERTISE_ALL | ADVERTISE_CSMA); -+ mii_nway_restart(&dev->mii); -+ -+ ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT); -+ if (ret < 0) -+ goto out; -+ -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, -+ AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, -+ AX88772_IPG2_DEFAULT, 0, NULL); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); -+ goto out; -+ } -+ -+ /* Rewrite MAC address */ -+ memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, -+ data->mac_addr); -+ if (ret < 0) -+ goto out; -+ -+ /* Set RX_CTL to default values with 2k buffer, and enable cactus */ -+ ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); -+ if (ret < 0) -+ goto out; -+ -+ rx_ctl = asix_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", -+ rx_ctl); -+ -+ rx_ctl = asix_read_medium_status(dev); -+ netdev_dbg(dev->net, -+ "Medium Status is 0x%04x after all initializations\n", -+ rx_ctl); -+ -+ return 0; -+ -+out: -+ return ret; -+ -+} -+ -+static const struct net_device_ops ax88772_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_set_mac_address = asix_set_mac_address, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = asix_ioctl, -+ .ndo_set_rx_mode = asix_set_multicast, -+}; -+ -+static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int ret, embd_phy, i; -+ u8 buf[ETH_ALEN]; -+ u32 phyid; -+ -+ usbnet_get_endpoints(dev,intf); -+ -+ /* Get the MAC address */ -+ if (dev->driver_info->data & FLAG_EEPROM_MAC) { -+ for (i = 0; i < (ETH_ALEN >> 1); i++) { -+ ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i, -+ 0, 2, buf + i * 2); -+ if (ret < 0) -+ break; -+ } -+ } else { -+ ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, -+ 0, 0, ETH_ALEN, buf); -+ } -+ -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); -+ return ret; -+ } -+ -+ asix_set_netdev_dev_addr(dev, buf); -+ -+ /* Initialize MII structure */ -+ dev->mii.dev = dev->net; -+ dev->mii.mdio_read = asix_mdio_read; -+ dev->mii.mdio_write = asix_mdio_write; -+ dev->mii.phy_id_mask = 0x1f; -+ dev->mii.reg_num_mask = 0x1f; -+ dev->mii.phy_id = asix_get_phy_addr(dev); -+ -+ dev->net->netdev_ops = &ax88772_netdev_ops; -+ dev->net->ethtool_ops = &ax88772_ethtool_ops; -+ dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */ -+ dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */ -+ -+ embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0); -+ -+ /* Reset the PHY to normal operation mode */ -+ ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); -+ return ret; -+ } -+ -+ ax88772_reset(dev); -+ -+ /* Read PHYID register *AFTER* the PHY was reset properly */ -+ phyid = asix_get_phyid(dev); -+ netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid); -+ -+ /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ -+ if (dev->driver_info->flags & FLAG_FRAMING_AX) { -+ /* hard_mtu is still the default - the device does not support -+ jumbo eth frames */ -+ dev->rx_urb_size = 2048; -+ } -+ -+ dev->driver_priv = kzalloc(sizeof(struct asix_common_private), GFP_KERNEL); -+ if (!dev->driver_priv) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ if (dev->driver_priv) -+ kfree(dev->driver_priv); -+} -+ -+static const struct ethtool_ops ax88178_ethtool_ops = { -+ .get_drvinfo = asix_get_drvinfo, -+ .get_link = asix_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_wol = asix_get_wol, -+ .set_wol = asix_set_wol, -+ .get_eeprom_len = asix_get_eeprom_len, -+ .get_eeprom = asix_get_eeprom, -+ .set_eeprom = asix_set_eeprom, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .nway_reset = usbnet_nway_reset, -+}; -+ -+static int marvell_phy_init(struct usbnet *dev) -+{ -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ u16 reg; -+ -+ netdev_dbg(dev->net, "marvell_phy_init()\n"); -+ -+ reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS); -+ netdev_dbg(dev->net, "MII_MARVELL_STATUS = 0x%04x\n", reg); -+ -+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL, -+ MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY); -+ -+ if (data->ledmode) { -+ reg = asix_mdio_read(dev->net, dev->mii.phy_id, -+ MII_MARVELL_LED_CTRL); -+ netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (1) = 0x%04x\n", reg); -+ -+ reg &= 0xf8ff; -+ reg |= (1 + 0x0100); -+ asix_mdio_write(dev->net, dev->mii.phy_id, -+ MII_MARVELL_LED_CTRL, reg); -+ -+ reg = asix_mdio_read(dev->net, dev->mii.phy_id, -+ MII_MARVELL_LED_CTRL); -+ netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (2) = 0x%04x\n", reg); -+ reg &= 0xfc0f; -+ } -+ -+ return 0; -+} -+ -+static int rtl8211cl_phy_init(struct usbnet *dev) -+{ -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ -+ netdev_dbg(dev->net, "rtl8211cl_phy_init()\n"); -+ -+ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0005); -+ asix_mdio_write (dev->net, dev->mii.phy_id, 0x0c, 0); -+ asix_mdio_write (dev->net, dev->mii.phy_id, 0x01, -+ asix_mdio_read (dev->net, dev->mii.phy_id, 0x01) | 0x0080); -+ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0); -+ -+ if (data->ledmode == 12) { -+ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0002); -+ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1a, 0x00cb); -+ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0); -+ } -+ -+ return 0; -+} -+ -+static int marvell_led_status(struct usbnet *dev, u16 speed) -+{ -+ u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL); -+ -+ netdev_dbg(dev->net, "marvell_led_status() read 0x%04x\n", reg); -+ -+ /* Clear out the center LED bits - 0x03F0 */ -+ reg &= 0xfc0f; -+ -+ switch (speed) { -+ case SPEED_1000: -+ reg |= 0x03e0; -+ break; -+ case SPEED_100: -+ reg |= 0x03b0; -+ break; -+ default: -+ reg |= 0x02f0; -+ } -+ -+ netdev_dbg(dev->net, "marvell_led_status() writing 0x%04x\n", reg); -+ asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg); -+ -+ return 0; -+} -+ -+static int ax88178_reset(struct usbnet *dev) -+{ -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ int ret; -+ __le16 eeprom; -+ u8 status; -+ int gpio0 = 0; -+ u32 phyid; -+ -+ asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status); -+ netdev_dbg(dev->net, "GPIO Status: 0x%04x\n", status); -+ -+ asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL); -+ asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom); -+ asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL); -+ -+ netdev_dbg(dev->net, "EEPROM index 0x17 is 0x%04x\n", eeprom); -+ -+ if (eeprom == cpu_to_le16(0xffff)) { -+ data->phymode = PHY_MODE_MARVELL; -+ data->ledmode = 0; -+ gpio0 = 1; -+ } else { -+ data->phymode = le16_to_cpu(eeprom) & 0x7F; -+ data->ledmode = le16_to_cpu(eeprom) >> 8; -+ gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1; -+ } -+ netdev_dbg(dev->net, "GPIO0: %d, PhyMode: %d\n", gpio0, data->phymode); -+ -+ /* Power up external GigaPHY through AX88178 GPIO pin */ -+ asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40); -+ if ((le16_to_cpu(eeprom) >> 8) != 1) { -+ asix_write_gpio(dev, 0x003c, 30); -+ asix_write_gpio(dev, 0x001c, 300); -+ asix_write_gpio(dev, 0x003c, 30); -+ } else { -+ netdev_dbg(dev->net, "gpio phymode == 1 path\n"); -+ asix_write_gpio(dev, AX_GPIO_GPO1EN, 30); -+ asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30); -+ } -+ -+ /* Read PHYID register *AFTER* powering up PHY */ -+ phyid = asix_get_phyid(dev); -+ netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid); -+ -+ /* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */ -+ asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL); -+ -+ asix_sw_reset(dev, 0); -+ msleep(150); -+ -+ asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD); -+ msleep(150); -+ -+ asix_write_rx_ctl(dev, 0); -+ -+ if (data->phymode == PHY_MODE_MARVELL) { -+ marvell_phy_init(dev); -+ msleep(60); -+ } else if (data->phymode == PHY_MODE_RTL8211CL) -+ rtl8211cl_phy_init(dev); -+ -+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, -+ BMCR_RESET | BMCR_ANENABLE); -+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, -+ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); -+ asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000, -+ ADVERTISE_1000FULL); -+ -+ mii_nway_restart(&dev->mii); -+ -+ ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT); -+ if (ret < 0) -+ return ret; -+ -+ /* Rewrite MAC address */ -+ memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, -+ data->mac_addr); -+ if (ret < 0) -+ return ret; -+ -+ ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); -+ if (ret < 0) -+ return ret; -+ -+ return 0; -+} -+ -+static int ax88178_link_reset(struct usbnet *dev) -+{ -+ u16 mode; -+ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ u32 speed; -+ -+ netdev_dbg(dev->net, "ax88178_link_reset()\n"); -+ -+ mii_check_media(&dev->mii, 1, 1); -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ mode = AX88178_MEDIUM_DEFAULT; -+ speed = ethtool_cmd_speed(&ecmd); -+ -+ if (speed == SPEED_1000) -+ mode |= AX_MEDIUM_GM; -+ else if (speed == SPEED_100) -+ mode |= AX_MEDIUM_PS; -+ else -+ mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM); -+ -+ mode |= AX_MEDIUM_ENCK; -+ -+ if (ecmd.duplex == DUPLEX_FULL) -+ mode |= AX_MEDIUM_FD; -+ else -+ mode &= ~AX_MEDIUM_FD; -+ -+ netdev_dbg(dev->net, "ax88178_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", -+ speed, ecmd.duplex, mode); -+ -+ asix_write_medium_mode(dev, mode); -+ -+ if (data->phymode == PHY_MODE_MARVELL && data->ledmode) -+ marvell_led_status(dev, speed); -+ -+ return 0; -+} -+ -+static void ax88178_set_mfb(struct usbnet *dev) -+{ -+ u16 mfb = AX_RX_CTL_MFB_16384; -+ u16 rxctl; -+ u16 medium; -+ int old_rx_urb_size = dev->rx_urb_size; -+ -+ if (dev->hard_mtu < 2048) { -+ dev->rx_urb_size = 2048; -+ mfb = AX_RX_CTL_MFB_2048; -+ } else if (dev->hard_mtu < 4096) { -+ dev->rx_urb_size = 4096; -+ mfb = AX_RX_CTL_MFB_4096; -+ } else if (dev->hard_mtu < 8192) { -+ dev->rx_urb_size = 8192; -+ mfb = AX_RX_CTL_MFB_8192; -+ } else if (dev->hard_mtu < 16384) { -+ dev->rx_urb_size = 16384; -+ mfb = AX_RX_CTL_MFB_16384; -+ } -+ -+ rxctl = asix_read_rx_ctl(dev); -+ asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb); -+ -+ medium = asix_read_medium_status(dev); -+ if (dev->net->mtu > 1500) -+ medium |= AX_MEDIUM_JFE; -+ else -+ medium &= ~AX_MEDIUM_JFE; -+ asix_write_medium_mode(dev, medium); -+ -+ if (dev->rx_urb_size > old_rx_urb_size) -+ usbnet_unlink_rx_urbs(dev); -+} -+ -+static int ax88178_change_mtu(struct net_device *net, int new_mtu) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ int ll_mtu = new_mtu + net->hard_header_len + 4; -+ -+ netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu); -+ -+ if (new_mtu <= 0 || ll_mtu > 16384) -+ return -EINVAL; -+ -+ if ((ll_mtu % dev->maxpacket) == 0) -+ return -EDOM; -+ -+ net->mtu = new_mtu; -+ dev->hard_mtu = net->mtu + net->hard_header_len; -+ ax88178_set_mfb(dev); -+ -+ /* max qlen depend on hard_mtu and rx_urb_size */ -+ usbnet_update_max_qlen(dev); -+ -+ return 0; -+} -+ -+static const struct net_device_ops ax88178_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_set_mac_address = asix_set_mac_address, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_set_rx_mode = asix_set_multicast, -+ .ndo_do_ioctl = asix_ioctl, -+ .ndo_change_mtu = ax88178_change_mtu, -+}; -+ -+static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int ret; -+ u8 buf[ETH_ALEN]; -+ -+ usbnet_get_endpoints(dev,intf); -+ -+ /* Get the MAC address */ -+ ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); -+ return ret; -+ } -+ -+ asix_set_netdev_dev_addr(dev, buf); -+ -+ /* Initialize MII structure */ -+ dev->mii.dev = dev->net; -+ dev->mii.mdio_read = asix_mdio_read; -+ dev->mii.mdio_write = asix_mdio_write; -+ dev->mii.phy_id_mask = 0x1f; -+ dev->mii.reg_num_mask = 0xff; -+ dev->mii.supports_gmii = 1; -+ dev->mii.phy_id = asix_get_phy_addr(dev); -+ -+ dev->net->netdev_ops = &ax88178_netdev_ops; -+ dev->net->ethtool_ops = &ax88178_ethtool_ops; -+ -+ /* Blink LEDS so users know driver saw dongle */ -+ asix_sw_reset(dev, 0); -+ msleep(150); -+ -+ asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD); -+ msleep(150); -+ -+ /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ -+ if (dev->driver_info->flags & FLAG_FRAMING_AX) { -+ /* hard_mtu is still the default - the device does not support -+ jumbo eth frames */ -+ dev->rx_urb_size = 2048; -+ } -+ -+ dev->driver_priv = kzalloc(sizeof(struct asix_common_private), GFP_KERNEL); -+ if (!dev->driver_priv) -+ return -ENOMEM; -+ -+ return 0; -+} -+ -+static const struct driver_info ax8817x_info = { -+ .description = "ASIX AX8817x USB 2.0 Ethernet", -+ .bind = ax88172_bind, -+ .status = asix_status, -+ .link_reset = ax88172_link_reset, -+ .reset = ax88172_link_reset, -+ .flags = FLAG_ETHER | FLAG_LINK_INTR, -+ .data = 0x00130103, -+}; -+ -+static const struct driver_info dlink_dub_e100_info = { -+ .description = "DLink DUB-E100 USB Ethernet", -+ .bind = ax88172_bind, -+ .status = asix_status, -+ .link_reset = ax88172_link_reset, -+ .reset = ax88172_link_reset, -+ .flags = FLAG_ETHER | FLAG_LINK_INTR, -+ .data = 0x009f9d9f, -+}; -+ -+static const struct driver_info netgear_fa120_info = { -+ .description = "Netgear FA-120 USB Ethernet", -+ .bind = ax88172_bind, -+ .status = asix_status, -+ .link_reset = ax88172_link_reset, -+ .reset = ax88172_link_reset, -+ .flags = FLAG_ETHER | FLAG_LINK_INTR, -+ .data = 0x00130103, -+}; -+ -+static const struct driver_info hawking_uf200_info = { -+ .description = "Hawking UF200 USB Ethernet", -+ .bind = ax88172_bind, -+ .status = asix_status, -+ .link_reset = ax88172_link_reset, -+ .reset = ax88172_link_reset, -+ .flags = FLAG_ETHER | FLAG_LINK_INTR, -+ .data = 0x001f1d1f, -+}; -+ -+static const struct driver_info ax88772_info = { -+ .description = "ASIX AX88772 USB 2.0 Ethernet", -+ .bind = ax88772_bind, -+ .unbind = ax88772_unbind, -+ .status = asix_status, -+ .link_reset = ax88772_link_reset, -+ .reset = ax88772_link_reset, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET, -+ .rx_fixup = asix_rx_fixup_common, -+ .tx_fixup = asix_tx_fixup, -+}; -+ -+static const struct driver_info ax88772b_info = { -+ .description = "ASIX AX88772B USB 2.0 Ethernet", -+ .bind = ax88772_bind, -+ .unbind = ax88772_unbind, -+ .status = asix_status, -+ .link_reset = ax88772_link_reset, -+ .reset = ax88772_reset, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | -+ FLAG_MULTI_PACKET, -+ .rx_fixup = asix_rx_fixup_common, -+ .tx_fixup = asix_tx_fixup, -+ .data = FLAG_EEPROM_MAC, -+}; -+ -+static const struct driver_info ax88178_info = { -+ .description = "ASIX AX88178 USB 2.0 Ethernet", -+ .bind = ax88178_bind, -+ .unbind = ax88772_unbind, -+ .status = asix_status, -+ .link_reset = ax88178_link_reset, -+ .reset = ax88178_reset, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | -+ FLAG_MULTI_PACKET, -+ .rx_fixup = asix_rx_fixup_common, -+ .tx_fixup = asix_tx_fixup, -+}; -+ -+/* -+ * USBLINK 20F9 "USB 2.0 LAN" USB ethernet adapter, typically found in -+ * no-name packaging. -+ * USB device strings are: -+ * 1: Manufacturer: USBLINK -+ * 2: Product: HG20F9 USB2.0 -+ * 3: Serial: 000003 -+ * Appears to be compatible with Asix 88772B. -+ */ -+static const struct driver_info hg20f9_info = { -+ .description = "HG20F9 USB 2.0 Ethernet", -+ .bind = ax88772_bind, -+ .unbind = ax88772_unbind, -+ .status = asix_status, -+ .link_reset = ax88772_link_reset, -+ .reset = ax88772_reset, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | -+ FLAG_MULTI_PACKET, -+ .rx_fixup = asix_rx_fixup_common, -+ .tx_fixup = asix_tx_fixup, -+ .data = FLAG_EEPROM_MAC, -+}; -+ -+static const struct usb_device_id products [] = { -+{ -+ // Linksys USB200M -+ USB_DEVICE (0x077b, 0x2226), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // Netgear FA120 -+ USB_DEVICE (0x0846, 0x1040), -+ .driver_info = (unsigned long) &netgear_fa120_info, -+}, { -+ // DLink DUB-E100 -+ USB_DEVICE (0x2001, 0x1a00), -+ .driver_info = (unsigned long) &dlink_dub_e100_info, -+}, { -+ // Intellinet, ST Lab USB Ethernet -+ USB_DEVICE (0x0b95, 0x1720), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // Hawking UF200, TrendNet TU2-ET100 -+ USB_DEVICE (0x07b8, 0x420a), -+ .driver_info = (unsigned long) &hawking_uf200_info, -+}, { -+ // Billionton Systems, USB2AR -+ USB_DEVICE (0x08dd, 0x90ff), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // ATEN UC210T -+ USB_DEVICE (0x0557, 0x2009), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // Buffalo LUA-U2-KTX -+ USB_DEVICE (0x0411, 0x003d), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // Buffalo LUA-U2-GT 10/100/1000 -+ USB_DEVICE (0x0411, 0x006e), -+ .driver_info = (unsigned long) &ax88178_info, -+}, { -+ // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter" -+ USB_DEVICE (0x6189, 0x182d), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // Sitecom LN-031 "USB 2.0 10/100/1000 Ethernet adapter" -+ USB_DEVICE (0x0df6, 0x0056), -+ .driver_info = (unsigned long) &ax88178_info, -+}, { -+ // corega FEther USB2-TX -+ USB_DEVICE (0x07aa, 0x0017), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // Surecom EP-1427X-2 -+ USB_DEVICE (0x1189, 0x0893), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // goodway corp usb gwusb2e -+ USB_DEVICE (0x1631, 0x6200), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // JVC MP-PRX1 Port Replicator -+ USB_DEVICE (0x04f1, 0x3008), -+ .driver_info = (unsigned long) &ax8817x_info, -+}, { -+ // Lenovo U2L100P 10/100 -+ USB_DEVICE (0x17ef, 0x7203), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // ASIX AX88772B 10/100 -+ USB_DEVICE (0x0b95, 0x772b), -+ .driver_info = (unsigned long) &ax88772b_info, -+}, { -+ // ASIX AX88772 10/100 -+ USB_DEVICE (0x0b95, 0x7720), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // ASIX AX88178 10/100/1000 -+ USB_DEVICE (0x0b95, 0x1780), -+ .driver_info = (unsigned long) &ax88178_info, -+}, { -+ // Logitec LAN-GTJ/U2A -+ USB_DEVICE (0x0789, 0x0160), -+ .driver_info = (unsigned long) &ax88178_info, -+}, { -+ // Linksys USB200M Rev 2 -+ USB_DEVICE (0x13b1, 0x0018), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // 0Q0 cable ethernet -+ USB_DEVICE (0x1557, 0x7720), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // DLink DUB-E100 H/W Ver B1 -+ USB_DEVICE (0x07d1, 0x3c05), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // DLink DUB-E100 H/W Ver B1 Alternate -+ USB_DEVICE (0x2001, 0x3c05), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // DLink DUB-E100 H/W Ver C1 -+ USB_DEVICE (0x2001, 0x1a02), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // Linksys USB1000 -+ USB_DEVICE (0x1737, 0x0039), -+ .driver_info = (unsigned long) &ax88178_info, -+}, { -+ // IO-DATA ETG-US2 -+ USB_DEVICE (0x04bb, 0x0930), -+ .driver_info = (unsigned long) &ax88178_info, -+}, { -+ // Belkin F5D5055 -+ USB_DEVICE(0x050d, 0x5055), -+ .driver_info = (unsigned long) &ax88178_info, -+}, { -+ // Apple USB Ethernet Adapter -+ USB_DEVICE(0x05ac, 0x1402), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // Cables-to-Go USB Ethernet Adapter -+ USB_DEVICE(0x0b95, 0x772a), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // ABOCOM for pci -+ USB_DEVICE(0x14ea, 0xab11), -+ .driver_info = (unsigned long) &ax88178_info, -+}, { -+ // ASIX 88772a -+ USB_DEVICE(0x0db0, 0xa877), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ // Asus USB Ethernet Adapter -+ USB_DEVICE (0x0b95, 0x7e2b), -+ .driver_info = (unsigned long) &ax88772_info, -+}, { -+ /* ASIX 88172a demo board */ -+ USB_DEVICE(0x0b95, 0x172a), -+ .driver_info = (unsigned long) &ax88172a_info, -+}, { -+ /* -+ * USBLINK HG20F9 "USB 2.0 LAN" -+ * Appears to have gazumped Linksys's manufacturer ID but -+ * doesn't (yet) conflict with any known Linksys product. -+ */ -+ USB_DEVICE(0x066b, 0x20f9), -+ .driver_info = (unsigned long) &hg20f9_info, -+}, -+ { }, // END -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver asix_driver = { -+ .name = DRIVER_NAME, -+ .id_table = products, -+ .probe = usbnet_probe, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disconnect = usbnet_disconnect, -+ .supports_autosuspend = 1, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(asix_driver); -+ -+MODULE_AUTHOR("David Hollis"); -+MODULE_VERSION(DRIVER_VERSION); -+MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices"); -+MODULE_LICENSE("GPL"); -+ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/asix.h backports-3.18.1-1/drivers/net/usb/asix.h ---- backports-3.18.1-1.org/drivers/net/usb/asix.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/asix.h 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,234 @@ -+/* -+ * ASIX AX8817X based USB 2.0 Ethernet Devices -+ * Copyright (C) 2003-2006 David Hollis dhollis@davehollis.com -+ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net -+ * Copyright (C) 2006 James Painter jamie.painter@iname.com -+ * Copyright (c) 2002-2003 TiVo Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#ifndef _ASIX_H -+#define _ASIX_H -+ -+// #define DEBUG // error path messages, extra info -+// #define VERBOSE // more; success messages -+ -+#include <linux/module.h> -+#include <linux/kmod.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/crc32.h> -+#include <linux/usb/usbnet.h> -+#include <linux/slab.h> -+#include <linux/if_vlan.h> -+ -+#define DRIVER_VERSION "22-Dec-2011" -+#define DRIVER_NAME "asix" -+ -+/* ASIX AX8817X based USB 2.0 Ethernet Devices */ -+ -+#define AX_CMD_SET_SW_MII 0x06 -+#define AX_CMD_READ_MII_REG 0x07 -+#define AX_CMD_WRITE_MII_REG 0x08 -+#define AX_CMD_SET_HW_MII 0x0a -+#define AX_CMD_READ_EEPROM 0x0b -+#define AX_CMD_WRITE_EEPROM 0x0c -+#define AX_CMD_WRITE_ENABLE 0x0d -+#define AX_CMD_WRITE_DISABLE 0x0e -+#define AX_CMD_READ_RX_CTL 0x0f -+#define AX_CMD_WRITE_RX_CTL 0x10 -+#define AX_CMD_READ_IPG012 0x11 -+#define AX_CMD_WRITE_IPG0 0x12 -+#define AX_CMD_WRITE_IPG1 0x13 -+#define AX_CMD_READ_NODE_ID 0x13 -+#define AX_CMD_WRITE_NODE_ID 0x14 -+#define AX_CMD_WRITE_IPG2 0x14 -+#define AX_CMD_WRITE_MULTI_FILTER 0x16 -+#define AX88172_CMD_READ_NODE_ID 0x17 -+#define AX_CMD_READ_PHY_ID 0x19 -+#define AX_CMD_READ_MEDIUM_STATUS 0x1a -+#define AX_CMD_WRITE_MEDIUM_MODE 0x1b -+#define AX_CMD_READ_MONITOR_MODE 0x1c -+#define AX_CMD_WRITE_MONITOR_MODE 0x1d -+#define AX_CMD_READ_GPIOS 0x1e -+#define AX_CMD_WRITE_GPIOS 0x1f -+#define AX_CMD_SW_RESET 0x20 -+#define AX_CMD_SW_PHY_STATUS 0x21 -+#define AX_CMD_SW_PHY_SELECT 0x22 -+ -+#define AX_PHY_SELECT_MASK (BIT(3) | BIT(2)) -+#define AX_PHY_SELECT_INTERNAL 0 -+#define AX_PHY_SELECT_EXTERNAL BIT(2) -+ -+#define AX_MONITOR_MODE 0x01 -+#define AX_MONITOR_LINK 0x02 -+#define AX_MONITOR_MAGIC 0x04 -+#define AX_MONITOR_HSFS 0x10 -+ -+/* AX88172 Medium Status Register values */ -+#define AX88172_MEDIUM_FD 0x02 -+#define AX88172_MEDIUM_TX 0x04 -+#define AX88172_MEDIUM_FC 0x10 -+#define AX88172_MEDIUM_DEFAULT \ -+ ( AX88172_MEDIUM_FD | AX88172_MEDIUM_TX | AX88172_MEDIUM_FC ) -+ -+#define AX_MCAST_FILTER_SIZE 8 -+#define AX_MAX_MCAST 64 -+ -+#define AX_SWRESET_CLEAR 0x00 -+#define AX_SWRESET_RR 0x01 -+#define AX_SWRESET_RT 0x02 -+#define AX_SWRESET_PRTE 0x04 -+#define AX_SWRESET_PRL 0x08 -+#define AX_SWRESET_BZ 0x10 -+#define AX_SWRESET_IPRL 0x20 -+#define AX_SWRESET_IPPD 0x40 -+ -+#define AX88772_IPG0_DEFAULT 0x15 -+#define AX88772_IPG1_DEFAULT 0x0c -+#define AX88772_IPG2_DEFAULT 0x12 -+ -+/* AX88772 & AX88178 Medium Mode Register */ -+#define AX_MEDIUM_PF 0x0080 -+#define AX_MEDIUM_JFE 0x0040 -+#define AX_MEDIUM_TFC 0x0020 -+#define AX_MEDIUM_RFC 0x0010 -+#define AX_MEDIUM_ENCK 0x0008 -+#define AX_MEDIUM_AC 0x0004 -+#define AX_MEDIUM_FD 0x0002 -+#define AX_MEDIUM_GM 0x0001 -+#define AX_MEDIUM_SM 0x1000 -+#define AX_MEDIUM_SBP 0x0800 -+#define AX_MEDIUM_PS 0x0200 -+#define AX_MEDIUM_RE 0x0100 -+ -+#define AX88178_MEDIUM_DEFAULT \ -+ (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \ -+ AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \ -+ AX_MEDIUM_RE) -+ -+#define AX88772_MEDIUM_DEFAULT \ -+ (AX_MEDIUM_FD | AX_MEDIUM_RFC | \ -+ AX_MEDIUM_TFC | AX_MEDIUM_PS | \ -+ AX_MEDIUM_AC | AX_MEDIUM_RE) -+ -+/* AX88772 & AX88178 RX_CTL values */ -+#define AX_RX_CTL_SO 0x0080 -+#define AX_RX_CTL_AP 0x0020 -+#define AX_RX_CTL_AM 0x0010 -+#define AX_RX_CTL_AB 0x0008 -+#define AX_RX_CTL_SEP 0x0004 -+#define AX_RX_CTL_AMALL 0x0002 -+#define AX_RX_CTL_PRO 0x0001 -+#define AX_RX_CTL_MFB_2048 0x0000 -+#define AX_RX_CTL_MFB_4096 0x0100 -+#define AX_RX_CTL_MFB_8192 0x0200 -+#define AX_RX_CTL_MFB_16384 0x0300 -+ -+#define AX_DEFAULT_RX_CTL (AX_RX_CTL_SO | AX_RX_CTL_AB) -+ -+/* GPIO 0 .. 2 toggles */ -+#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */ -+#define AX_GPIO_GPO_0 0x02 /* GPIO0 Output value */ -+#define AX_GPIO_GPO1EN 0x04 /* GPIO1 Output enable */ -+#define AX_GPIO_GPO_1 0x08 /* GPIO1 Output value */ -+#define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */ -+#define AX_GPIO_GPO_2 0x20 /* GPIO2 Output value */ -+#define AX_GPIO_RESERVED 0x40 /* Reserved */ -+#define AX_GPIO_RSE 0x80 /* Reload serial EEPROM */ -+ -+#define AX_EEPROM_MAGIC 0xdeadbeef -+#define AX_EEPROM_LEN 0x200 -+ -+/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ -+struct asix_data { -+ u8 multi_filter[AX_MCAST_FILTER_SIZE]; -+ u8 mac_addr[ETH_ALEN]; -+ u8 phymode; -+ u8 ledmode; -+ u8 res; -+}; -+ -+struct asix_rx_fixup_info { -+ struct sk_buff *ax_skb; -+ u32 header; -+ u16 size; -+ bool split_head; -+}; -+ -+struct asix_common_private { -+ struct asix_rx_fixup_info rx_fixup_info; -+}; -+ -+extern const struct driver_info ax88172a_info; -+ -+/* ASIX specific flags */ -+#define FLAG_EEPROM_MAC (1UL << 0) /* init device MAC from eeprom */ -+ -+int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data); -+ -+int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data); -+ -+void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, -+ u16 index, u16 size, void *data); -+ -+int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb, -+ struct asix_rx_fixup_info *rx); -+int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb); -+ -+struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb, -+ gfp_t flags); -+ -+int asix_set_sw_mii(struct usbnet *dev); -+int asix_set_hw_mii(struct usbnet *dev); -+ -+int asix_read_phy_addr(struct usbnet *dev, int internal); -+int asix_get_phy_addr(struct usbnet *dev); -+ -+int asix_sw_reset(struct usbnet *dev, u8 flags); -+ -+u16 asix_read_rx_ctl(struct usbnet *dev); -+int asix_write_rx_ctl(struct usbnet *dev, u16 mode); -+ -+u16 asix_read_medium_status(struct usbnet *dev); -+int asix_write_medium_mode(struct usbnet *dev, u16 mode); -+ -+int asix_write_gpio(struct usbnet *dev, u16 value, int sleep); -+ -+void asix_set_multicast(struct net_device *net); -+ -+int asix_mdio_read(struct net_device *netdev, int phy_id, int loc); -+void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val); -+ -+void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo); -+int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo); -+ -+int asix_get_eeprom_len(struct net_device *net); -+int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, -+ u8 *data); -+int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, -+ u8 *data); -+ -+void asix_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info); -+ -+int asix_set_mac_address(struct net_device *net, void *p); -+ -+#endif /* _ASIX_H */ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/ax88172a.c backports-3.18.1-1/drivers/net/usb/ax88172a.c ---- backports-3.18.1-1.org/drivers/net/usb/ax88172a.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/ax88172a.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,422 @@ -+/* -+ * ASIX AX88172A based USB 2.0 Ethernet Devices -+ * Copyright (C) 2012 OMICRON electronics GmbH -+ * -+ * Supports external PHYs via phylib. Based on the driver for the -+ * AX88772. Original copyrights follow: -+ * -+ * Copyright (C) 2003-2006 David Hollis dhollis@davehollis.com -+ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net -+ * Copyright (C) 2006 James Painter jamie.painter@iname.com -+ * Copyright (c) 2002-2003 TiVo Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include "asix.h" -+#include <linux/phy.h> -+ -+struct ax88172a_private { -+ struct mii_bus *mdio; -+ struct phy_device *phydev; -+ char phy_name[20]; -+ u16 phy_addr; -+ u16 oldmode; -+ int use_embdphy; -+ struct asix_rx_fixup_info rx_fixup_info; -+}; -+ -+/* MDIO read and write wrappers for phylib */ -+static int asix_mdio_bus_read(struct mii_bus *bus, int phy_id, int regnum) -+{ -+ return asix_mdio_read(((struct usbnet *)bus->priv)->net, phy_id, -+ regnum); -+} -+ -+static int asix_mdio_bus_write(struct mii_bus *bus, int phy_id, int regnum, -+ u16 val) -+{ -+ asix_mdio_write(((struct usbnet *)bus->priv)->net, phy_id, regnum, val); -+ return 0; -+} -+ -+static int ax88172a_ioctl(struct net_device *net, struct ifreq *rq, int cmd) -+{ -+ if (!netif_running(net)) -+ return -EINVAL; -+ -+ if (!net->phydev) -+ return -ENODEV; -+ -+ return phy_mii_ioctl(net->phydev, rq, cmd); -+} -+ -+/* set MAC link settings according to information from phylib */ -+static void ax88172a_adjust_link(struct net_device *netdev) -+{ -+ struct phy_device *phydev = netdev->phydev; -+ struct usbnet *dev = netdev_priv(netdev); -+ struct ax88172a_private *priv = dev->driver_priv; -+ u16 mode = 0; -+ -+ if (phydev->link) { -+ mode = AX88772_MEDIUM_DEFAULT; -+ -+ if (phydev->duplex == DUPLEX_HALF) -+ mode &= ~AX_MEDIUM_FD; -+ -+ if (phydev->speed != SPEED_100) -+ mode &= ~AX_MEDIUM_PS; -+ } -+ -+ if (mode != priv->oldmode) { -+ asix_write_medium_mode(dev, mode); -+ priv->oldmode = mode; -+ netdev_dbg(netdev, "speed %u duplex %d, setting mode to 0x%04x\n", -+ phydev->speed, phydev->duplex, mode); -+ phy_print_status(phydev); -+ } -+} -+ -+static void ax88172a_status(struct usbnet *dev, struct urb *urb) -+{ -+ /* link changes are detected by polling the phy */ -+} -+ -+/* use phylib infrastructure */ -+static int ax88172a_init_mdio(struct usbnet *dev) -+{ -+ struct ax88172a_private *priv = dev->driver_priv; -+ int ret, i; -+ -+ priv->mdio = mdiobus_alloc(); -+ if (!priv->mdio) { -+ netdev_err(dev->net, "Could not allocate MDIO bus\n"); -+ return -ENOMEM; -+ } -+ -+ priv->mdio->priv = (void *)dev; -+ priv->mdio->read = &asix_mdio_bus_read; -+ priv->mdio->write = &asix_mdio_bus_write; -+ priv->mdio->name = "Asix MDIO Bus"; -+ /* mii bus name is usb-<usb bus number>-<usb device number> */ -+ snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "usb-%03d:%03d", -+ dev->udev->bus->busnum, dev->udev->devnum); -+ -+ priv->mdio->irq = kzalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); -+ if (!priv->mdio->irq) { -+ ret = -ENOMEM; -+ goto mfree; -+ } -+ for (i = 0; i < PHY_MAX_ADDR; i++) -+ priv->mdio->irq[i] = PHY_POLL; -+ -+ ret = mdiobus_register(priv->mdio); -+ if (ret) { -+ netdev_err(dev->net, "Could not register MDIO bus\n"); -+ goto ifree; -+ } -+ -+ netdev_info(dev->net, "registered mdio bus %s\n", priv->mdio->id); -+ return 0; -+ -+ifree: -+ kfree(priv->mdio->irq); -+mfree: -+ mdiobus_free(priv->mdio); -+ return ret; -+} -+ -+static void ax88172a_remove_mdio(struct usbnet *dev) -+{ -+ struct ax88172a_private *priv = dev->driver_priv; -+ -+ netdev_info(dev->net, "deregistering mdio bus %s\n", priv->mdio->id); -+ mdiobus_unregister(priv->mdio); -+ kfree(priv->mdio->irq); -+ mdiobus_free(priv->mdio); -+} -+ -+static const struct net_device_ops ax88172a_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_set_mac_address = asix_set_mac_address, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = ax88172a_ioctl, -+ .ndo_set_rx_mode = asix_set_multicast, -+}; -+ -+static int ax88172a_get_settings(struct net_device *net, -+ struct ethtool_cmd *cmd) -+{ -+ if (!net->phydev) -+ return -ENODEV; -+ -+ return phy_ethtool_gset(net->phydev, cmd); -+} -+ -+static int ax88172a_set_settings(struct net_device *net, -+ struct ethtool_cmd *cmd) -+{ -+ if (!net->phydev) -+ return -ENODEV; -+ -+ return phy_ethtool_sset(net->phydev, cmd); -+} -+ -+static int ax88172a_nway_reset(struct net_device *net) -+{ -+ if (!net->phydev) -+ return -ENODEV; -+ -+ return phy_start_aneg(net->phydev); -+} -+ -+static const struct ethtool_ops ax88172a_ethtool_ops = { -+ .get_drvinfo = asix_get_drvinfo, -+ .get_link = usbnet_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_wol = asix_get_wol, -+ .set_wol = asix_set_wol, -+ .get_eeprom_len = asix_get_eeprom_len, -+ .get_eeprom = asix_get_eeprom, -+ .set_eeprom = asix_set_eeprom, -+ .get_settings = ax88172a_get_settings, -+ .set_settings = ax88172a_set_settings, -+ .nway_reset = ax88172a_nway_reset, -+}; -+ -+static int ax88172a_reset_phy(struct usbnet *dev, int embd_phy) -+{ -+ int ret; -+ -+ ret = asix_sw_reset(dev, AX_SWRESET_IPPD); -+ if (ret < 0) -+ goto err; -+ -+ msleep(150); -+ ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); -+ if (ret < 0) -+ goto err; -+ -+ msleep(150); -+ -+ ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_IPPD); -+ if (ret < 0) -+ goto err; -+ -+ return 0; -+ -+err: -+ return ret; -+} -+ -+ -+static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int ret; -+ u8 buf[ETH_ALEN]; -+ struct ax88172a_private *priv; -+ -+ usbnet_get_endpoints(dev, intf); -+ -+ priv = kzalloc(sizeof(*priv), GFP_KERNEL); -+ if (!priv) -+ return -ENOMEM; -+ -+ dev->driver_priv = priv; -+ -+ /* Get the MAC address */ -+ ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); -+ if (ret < 0) { -+ netdev_err(dev->net, "Failed to read MAC address: %d\n", ret); -+ goto free; -+ } -+ memcpy(dev->net->dev_addr, buf, ETH_ALEN); -+ -+ dev->net->netdev_ops = &ax88172a_netdev_ops; -+ dev->net->ethtool_ops = &ax88172a_ethtool_ops; -+ -+ /* are we using the internal or the external phy? */ -+ ret = asix_read_cmd(dev, AX_CMD_SW_PHY_STATUS, 0, 0, 1, buf); -+ if (ret < 0) { -+ netdev_err(dev->net, "Failed to read software interface selection register: %d\n", -+ ret); -+ goto free; -+ } -+ -+ netdev_dbg(dev->net, "AX_CMD_SW_PHY_STATUS = 0x%02x\n", buf[0]); -+ switch (buf[0] & AX_PHY_SELECT_MASK) { -+ case AX_PHY_SELECT_INTERNAL: -+ netdev_dbg(dev->net, "use internal phy\n"); -+ priv->use_embdphy = 1; -+ break; -+ case AX_PHY_SELECT_EXTERNAL: -+ netdev_dbg(dev->net, "use external phy\n"); -+ priv->use_embdphy = 0; -+ break; -+ default: -+ netdev_err(dev->net, "Interface mode not supported by driver\n"); -+ ret = -ENOTSUPP; -+ goto free; -+ } -+ -+ priv->phy_addr = asix_read_phy_addr(dev, priv->use_embdphy); -+ ax88172a_reset_phy(dev, priv->use_embdphy); -+ -+ /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ -+ if (dev->driver_info->flags & FLAG_FRAMING_AX) { -+ /* hard_mtu is still the default - the device does not support -+ jumbo eth frames */ -+ dev->rx_urb_size = 2048; -+ } -+ -+ /* init MDIO bus */ -+ ret = ax88172a_init_mdio(dev); -+ if (ret) -+ goto free; -+ -+ return 0; -+ -+free: -+ kfree(priv); -+ return ret; -+} -+ -+static int ax88172a_stop(struct usbnet *dev) -+{ -+ struct ax88172a_private *priv = dev->driver_priv; -+ -+ netdev_dbg(dev->net, "Stopping interface\n"); -+ -+ if (priv->phydev) { -+ netdev_info(dev->net, "Disconnecting from phy %s\n", -+ priv->phy_name); -+ phy_stop(priv->phydev); -+ phy_disconnect(priv->phydev); -+ } -+ -+ return 0; -+} -+ -+static void ax88172a_unbind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ struct ax88172a_private *priv = dev->driver_priv; -+ -+ ax88172a_remove_mdio(dev); -+ kfree(priv); -+} -+ -+static int ax88172a_reset(struct usbnet *dev) -+{ -+ struct asix_data *data = (struct asix_data *)&dev->data; -+ struct ax88172a_private *priv = dev->driver_priv; -+ int ret; -+ u16 rx_ctl; -+ -+ ax88172a_reset_phy(dev, priv->use_embdphy); -+ -+ msleep(150); -+ rx_ctl = asix_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); -+ ret = asix_write_rx_ctl(dev, 0x0000); -+ if (ret < 0) -+ goto out; -+ -+ rx_ctl = asix_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); -+ -+ msleep(150); -+ -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, -+ AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, -+ AX88772_IPG2_DEFAULT, 0, NULL); -+ if (ret < 0) { -+ netdev_err(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); -+ goto out; -+ } -+ -+ /* Rewrite MAC address */ -+ memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); -+ ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, -+ data->mac_addr); -+ if (ret < 0) -+ goto out; -+ -+ /* Set RX_CTL to default values with 2k buffer, and enable cactus */ -+ ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); -+ if (ret < 0) -+ goto out; -+ -+ rx_ctl = asix_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", -+ rx_ctl); -+ -+ rx_ctl = asix_read_medium_status(dev); -+ netdev_dbg(dev->net, "Medium Status is 0x%04x after all initializations\n", -+ rx_ctl); -+ -+ /* Connect to PHY */ -+ snprintf(priv->phy_name, 20, PHY_ID_FMT, -+ priv->mdio->id, priv->phy_addr); -+ -+ priv->phydev = phy_connect(dev->net, priv->phy_name, -+ &ax88172a_adjust_link, -+ PHY_INTERFACE_MODE_MII); -+ if (IS_ERR(priv->phydev)) { -+ netdev_err(dev->net, "Could not connect to PHY device %s\n", -+ priv->phy_name); -+ ret = PTR_ERR(priv->phydev); -+ goto out; -+ } -+ -+ netdev_info(dev->net, "Connected to phy %s\n", priv->phy_name); -+ -+ /* During power-up, the AX88172A set the power down (BMCR_PDOWN) -+ * bit of the PHY. Bring the PHY up again. -+ */ -+ genphy_resume(priv->phydev); -+ phy_start(priv->phydev); -+ -+ return 0; -+ -+out: -+ return ret; -+ -+} -+ -+static int ax88172a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ struct ax88172a_private *dp = dev->driver_priv; -+ struct asix_rx_fixup_info *rx = &dp->rx_fixup_info; -+ -+ return asix_rx_fixup_internal(dev, skb, rx); -+} -+ -+const struct driver_info ax88172a_info = { -+ .description = "ASIX AX88172A USB 2.0 Ethernet", -+ .bind = ax88172a_bind, -+ .reset = ax88172a_reset, -+ .stop = ax88172a_stop, -+ .unbind = ax88172a_unbind, -+ .status = ax88172a_status, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | -+ FLAG_MULTI_PACKET, -+ .rx_fixup = ax88172a_rx_fixup, -+ .tx_fixup = asix_tx_fixup, -+}; -diff -Naur backports-3.18.1-1.org/drivers/net/usb/ax88179_178a.c backports-3.18.1-1/drivers/net/usb/ax88179_178a.c ---- backports-3.18.1-1.org/drivers/net/usb/ax88179_178a.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/ax88179_178a.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,1756 @@ -+/* -+ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices -+ * -+ * Copyright (C) 2011-2013 ASIX -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2 -+ * of the License, or (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include <linux/module.h> -+#include <linux/etherdevice.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/crc32.h> -+#include <linux/usb/usbnet.h> -+#include <uapi/linux/mdio.h> -+#include <linux/mdio.h> -+ -+#define AX88179_PHY_ID 0x03 -+#define AX_EEPROM_LEN 0x100 -+#define AX88179_EEPROM_MAGIC 0x17900b95 -+#define AX_MCAST_FLTSIZE 8 -+#define AX_MAX_MCAST 64 -+#define AX_INT_PPLS_LINK ((u32)BIT(16)) -+#define AX_RXHDR_L4_TYPE_MASK 0x1c -+#define AX_RXHDR_L4_TYPE_UDP 4 -+#define AX_RXHDR_L4_TYPE_TCP 16 -+#define AX_RXHDR_L3CSUM_ERR 2 -+#define AX_RXHDR_L4CSUM_ERR 1 -+#define AX_RXHDR_CRC_ERR ((u32)BIT(29)) -+#define AX_RXHDR_DROP_ERR ((u32)BIT(31)) -+#define AX_ACCESS_MAC 0x01 -+#define AX_ACCESS_PHY 0x02 -+#define AX_ACCESS_EEPROM 0x04 -+#define AX_ACCESS_EFUS 0x05 -+#define AX_PAUSE_WATERLVL_HIGH 0x54 -+#define AX_PAUSE_WATERLVL_LOW 0x55 -+ -+#define PHYSICAL_LINK_STATUS 0x02 -+ #define AX_USB_SS 0x04 -+ #define AX_USB_HS 0x02 -+ -+#define GENERAL_STATUS 0x03 -+/* Check AX88179 version. UA1:Bit2 = 0, UA2:Bit2 = 1 */ -+ #define AX_SECLD 0x04 -+ -+#define AX_SROM_ADDR 0x07 -+#define AX_SROM_CMD 0x0a -+ #define EEP_RD 0x04 -+ #define EEP_BUSY 0x10 -+ -+#define AX_SROM_DATA_LOW 0x08 -+#define AX_SROM_DATA_HIGH 0x09 -+ -+#define AX_RX_CTL 0x0b -+ #define AX_RX_CTL_DROPCRCERR 0x0100 -+ #define AX_RX_CTL_IPE 0x0200 -+ #define AX_RX_CTL_START 0x0080 -+ #define AX_RX_CTL_AP 0x0020 -+ #define AX_RX_CTL_AM 0x0010 -+ #define AX_RX_CTL_AB 0x0008 -+ #define AX_RX_CTL_AMALL 0x0002 -+ #define AX_RX_CTL_PRO 0x0001 -+ #define AX_RX_CTL_STOP 0x0000 -+ -+#define AX_NODE_ID 0x10 -+#define AX_MULFLTARY 0x16 -+ -+#define AX_MEDIUM_STATUS_MODE 0x22 -+ #define AX_MEDIUM_GIGAMODE 0x01 -+ #define AX_MEDIUM_FULL_DUPLEX 0x02 -+ #define AX_MEDIUM_EN_125MHZ 0x08 -+ #define AX_MEDIUM_RXFLOW_CTRLEN 0x10 -+ #define AX_MEDIUM_TXFLOW_CTRLEN 0x20 -+ #define AX_MEDIUM_RECEIVE_EN 0x100 -+ #define AX_MEDIUM_PS 0x200 -+ #define AX_MEDIUM_JUMBO_EN 0x8040 -+ -+#define AX_MONITOR_MOD 0x24 -+ #define AX_MONITOR_MODE_RWLC 0x02 -+ #define AX_MONITOR_MODE_RWMP 0x04 -+ #define AX_MONITOR_MODE_PMEPOL 0x20 -+ #define AX_MONITOR_MODE_PMETYPE 0x40 -+ -+#define AX_GPIO_CTRL 0x25 -+ #define AX_GPIO_CTRL_GPIO3EN 0x80 -+ #define AX_GPIO_CTRL_GPIO2EN 0x40 -+ #define AX_GPIO_CTRL_GPIO1EN 0x20 -+ -+#define AX_PHYPWR_RSTCTL 0x26 -+ #define AX_PHYPWR_RSTCTL_BZ 0x0010 -+ #define AX_PHYPWR_RSTCTL_IPRL 0x0020 -+ #define AX_PHYPWR_RSTCTL_AT 0x1000 -+ -+#define AX_RX_BULKIN_QCTRL 0x2e -+#define AX_CLK_SELECT 0x33 -+ #define AX_CLK_SELECT_BCS 0x01 -+ #define AX_CLK_SELECT_ACS 0x02 -+ #define AX_CLK_SELECT_ULR 0x08 -+ -+#define AX_RXCOE_CTL 0x34 -+ #define AX_RXCOE_IP 0x01 -+ #define AX_RXCOE_TCP 0x02 -+ #define AX_RXCOE_UDP 0x04 -+ #define AX_RXCOE_TCPV6 0x20 -+ #define AX_RXCOE_UDPV6 0x40 -+ -+#define AX_TXCOE_CTL 0x35 -+ #define AX_TXCOE_IP 0x01 -+ #define AX_TXCOE_TCP 0x02 -+ #define AX_TXCOE_UDP 0x04 -+ #define AX_TXCOE_TCPV6 0x20 -+ #define AX_TXCOE_UDPV6 0x40 -+ -+#define AX_LEDCTRL 0x73 -+ -+#define GMII_PHY_PHYSR 0x11 -+ #define GMII_PHY_PHYSR_SMASK 0xc000 -+ #define GMII_PHY_PHYSR_GIGA 0x8000 -+ #define GMII_PHY_PHYSR_100 0x4000 -+ #define GMII_PHY_PHYSR_FULL 0x2000 -+ #define GMII_PHY_PHYSR_LINK 0x400 -+ -+#define GMII_LED_ACT 0x1a -+ #define GMII_LED_ACTIVE_MASK 0xff8f -+ #define GMII_LED0_ACTIVE BIT(4) -+ #define GMII_LED1_ACTIVE BIT(5) -+ #define GMII_LED2_ACTIVE BIT(6) -+ -+#define GMII_LED_LINK 0x1c -+ #define GMII_LED_LINK_MASK 0xf888 -+ #define GMII_LED0_LINK_10 BIT(0) -+ #define GMII_LED0_LINK_100 BIT(1) -+ #define GMII_LED0_LINK_1000 BIT(2) -+ #define GMII_LED1_LINK_10 BIT(4) -+ #define GMII_LED1_LINK_100 BIT(5) -+ #define GMII_LED1_LINK_1000 BIT(6) -+ #define GMII_LED2_LINK_10 BIT(8) -+ #define GMII_LED2_LINK_100 BIT(9) -+ #define GMII_LED2_LINK_1000 BIT(10) -+ #define LED0_ACTIVE BIT(0) -+ #define LED0_LINK_10 BIT(1) -+ #define LED0_LINK_100 BIT(2) -+ #define LED0_LINK_1000 BIT(3) -+ #define LED0_FD BIT(4) -+ #define LED0_USB3_MASK 0x001f -+ #define LED1_ACTIVE BIT(5) -+ #define LED1_LINK_10 BIT(6) -+ #define LED1_LINK_100 BIT(7) -+ #define LED1_LINK_1000 BIT(8) -+ #define LED1_FD BIT(9) -+ #define LED1_USB3_MASK 0x03e0 -+ #define LED2_ACTIVE BIT(10) -+ #define LED2_LINK_1000 BIT(13) -+ #define LED2_LINK_100 BIT(12) -+ #define LED2_LINK_10 BIT(11) -+ #define LED2_FD BIT(14) -+ #define LED_VALID BIT(15) -+ #define LED2_USB3_MASK 0x7c00 -+ -+#define GMII_PHYPAGE 0x1e -+#define GMII_PHY_PAGE_SELECT 0x1f -+ #define GMII_PHY_PGSEL_EXT 0x0007 -+ #define GMII_PHY_PGSEL_PAGE0 0x0000 -+ #define GMII_PHY_PGSEL_PAGE3 0x0003 -+ #define GMII_PHY_PGSEL_PAGE5 0x0005 -+ -+struct ax88179_data { -+ u8 eee_enabled; -+ u8 eee_active; -+ u16 rxctl; -+ u16 reserved; -+}; -+ -+struct ax88179_int_data { -+ __le32 intdata1; -+ __le32 intdata2; -+}; -+ -+static const struct { -+ unsigned char ctrl, timer_l, timer_h, size, ifg; -+} AX88179_BULKIN_SIZE[] = { -+ {7, 0x4f, 0, 0x12, 0xff}, -+ {7, 0x20, 3, 0x16, 0xff}, -+ {7, 0xae, 7, 0x18, 0xff}, -+ {7, 0xcc, 0x4c, 0x18, 8}, -+}; -+ -+static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data, int in_pm) -+{ -+ int ret; -+ int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); -+ -+ BUG_ON(!dev); -+ -+ if (!in_pm) -+ fn = usbnet_read_cmd; -+ else -+ fn = usbnet_read_cmd_nopm; -+ -+ ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ value, index, data, size); -+ -+ if (unlikely(ret < 0)) -+ netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", -+ index, ret); -+ -+ return ret; -+} -+ -+static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data, int in_pm) -+{ -+ int ret; -+ int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); -+ -+ BUG_ON(!dev); -+ -+ if (!in_pm) -+ fn = usbnet_write_cmd; -+ else -+ fn = usbnet_write_cmd_nopm; -+ -+ ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ value, index, data, size); -+ -+ if (unlikely(ret < 0)) -+ netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n", -+ index, ret); -+ -+ return ret; -+} -+ -+static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, -+ u16 index, u16 size, void *data) -+{ -+ u16 buf; -+ -+ if (2 == size) { -+ buf = *((u16 *)data); -+ cpu_to_le16s(&buf); -+ usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | -+ USB_RECIP_DEVICE, value, index, &buf, -+ size); -+ } else { -+ usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | -+ USB_RECIP_DEVICE, value, index, data, -+ size); -+ } -+} -+ -+static int ax88179_read_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, -+ u16 index, u16 size, void *data) -+{ -+ int ret; -+ -+ if (2 == size) { -+ u16 buf; -+ ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 1); -+ le16_to_cpus(&buf); -+ *((u16 *)data) = buf; -+ } else if (4 == size) { -+ u32 buf; -+ ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 1); -+ le32_to_cpus(&buf); -+ *((u32 *)data) = buf; -+ } else { -+ ret = __ax88179_read_cmd(dev, cmd, value, index, size, data, 1); -+ } -+ -+ return ret; -+} -+ -+static int ax88179_write_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, -+ u16 index, u16 size, void *data) -+{ -+ int ret; -+ -+ if (2 == size) { -+ u16 buf; -+ buf = *((u16 *)data); -+ cpu_to_le16s(&buf); -+ ret = __ax88179_write_cmd(dev, cmd, value, index, -+ size, &buf, 1); -+ } else { -+ ret = __ax88179_write_cmd(dev, cmd, value, index, -+ size, data, 1); -+ } -+ -+ return ret; -+} -+ -+static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data) -+{ -+ int ret; -+ -+ if (2 == size) { -+ u16 buf; -+ ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0); -+ le16_to_cpus(&buf); -+ *((u16 *)data) = buf; -+ } else if (4 == size) { -+ u32 buf; -+ ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0); -+ le32_to_cpus(&buf); -+ *((u32 *)data) = buf; -+ } else { -+ ret = __ax88179_read_cmd(dev, cmd, value, index, size, data, 0); -+ } -+ -+ return ret; -+} -+ -+static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data) -+{ -+ int ret; -+ -+ if (2 == size) { -+ u16 buf; -+ buf = *((u16 *)data); -+ cpu_to_le16s(&buf); -+ ret = __ax88179_write_cmd(dev, cmd, value, index, -+ size, &buf, 0); -+ } else { -+ ret = __ax88179_write_cmd(dev, cmd, value, index, -+ size, data, 0); -+ } -+ -+ return ret; -+} -+ -+static void ax88179_status(struct usbnet *dev, struct urb *urb) -+{ -+ struct ax88179_int_data *event; -+ u32 link; -+ -+ if (urb->actual_length < 8) -+ return; -+ -+ event = urb->transfer_buffer; -+ le32_to_cpus((void *)&event->intdata1); -+ -+ link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16; -+ -+ if (netif_carrier_ok(dev->net) != link) { -+ usbnet_link_change(dev, link, 1); -+ netdev_info(dev->net, "ax88179 - Link status is: %d\n", link); -+ } -+} -+ -+static int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u16 res; -+ -+ ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); -+ return res; -+} -+ -+static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, -+ int val) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u16 res = (u16) val; -+ -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); -+} -+ -+static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad, -+ u16 devad) -+{ -+ u16 tmp16; -+ int ret; -+ -+ tmp16 = devad; -+ ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ MII_MMD_CTRL, 2, &tmp16); -+ -+ tmp16 = prtad; -+ ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ MII_MMD_DATA, 2, &tmp16); -+ -+ tmp16 = devad | MII_MMD_CTRL_NOINCR; -+ ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ MII_MMD_CTRL, 2, &tmp16); -+ -+ return ret; -+} -+ -+static int -+ax88179_phy_read_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad) -+{ -+ int ret; -+ u16 tmp16; -+ -+ ax88179_phy_mmd_indirect(dev, prtad, devad); -+ -+ ret = ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ MII_MMD_DATA, 2, &tmp16); -+ if (ret < 0) -+ return ret; -+ -+ return tmp16; -+} -+ -+static int -+ax88179_phy_write_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad, -+ u16 data) -+{ -+ int ret; -+ -+ ax88179_phy_mmd_indirect(dev, prtad, devad); -+ -+ ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ MII_MMD_DATA, 2, &data); -+ -+ if (ret < 0) -+ return ret; -+ -+ return 0; -+} -+ -+static int ax88179_suspend(struct usb_interface *intf, pm_message_t message) -+{ -+ struct usbnet *dev = usb_get_intfdata(intf); -+ u16 tmp16; -+ u8 tmp8; -+ -+ usbnet_suspend(intf, message); -+ -+ /* Disable RX path */ -+ ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &tmp16); -+ tmp16 &= ~AX_MEDIUM_RECEIVE_EN; -+ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &tmp16); -+ -+ /* Force bulk-in zero length */ -+ ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, -+ 2, 2, &tmp16); -+ -+ tmp16 |= AX_PHYPWR_RSTCTL_BZ | AX_PHYPWR_RSTCTL_IPRL; -+ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, -+ 2, 2, &tmp16); -+ -+ /* change clock */ -+ tmp8 = 0; -+ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); -+ -+ /* Configure RX control register => stop operation */ -+ tmp16 = AX_RX_CTL_STOP; -+ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); -+ -+ return 0; -+} -+ -+/* This function is used to enable the autodetach function. */ -+/* This function is determined by offset 0x43 of EEPROM */ -+static int ax88179_auto_detach(struct usbnet *dev, int in_pm) -+{ -+ u16 tmp16; -+ u8 tmp8; -+ int (*fnr)(struct usbnet *, u8, u16, u16, u16, void *); -+ int (*fnw)(struct usbnet *, u8, u16, u16, u16, void *); -+ -+ if (!in_pm) { -+ fnr = ax88179_read_cmd; -+ fnw = ax88179_write_cmd; -+ } else { -+ fnr = ax88179_read_cmd_nopm; -+ fnw = ax88179_write_cmd_nopm; -+ } -+ -+ if (fnr(dev, AX_ACCESS_EEPROM, 0x43, 1, 2, &tmp16) < 0) -+ return 0; -+ -+ if ((tmp16 == 0xFFFF) || (!(tmp16 & 0x0100))) -+ return 0; -+ -+ /* Enable Auto Detach bit */ -+ tmp8 = 0; -+ fnr(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); -+ tmp8 |= AX_CLK_SELECT_ULR; -+ fnw(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); -+ -+ fnr(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); -+ tmp16 |= AX_PHYPWR_RSTCTL_AT; -+ fnw(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); -+ -+ return 0; -+} -+ -+static int ax88179_resume(struct usb_interface *intf) -+{ -+ struct usbnet *dev = usb_get_intfdata(intf); -+ u16 tmp16; -+ u8 tmp8; -+ -+ usbnet_link_change(dev, 0, 0); -+ -+ /* Power up ethernet PHY */ -+ tmp16 = 0; -+ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, -+ 2, 2, &tmp16); -+ udelay(1000); -+ -+ tmp16 = AX_PHYPWR_RSTCTL_IPRL; -+ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, -+ 2, 2, &tmp16); -+ msleep(200); -+ -+ /* Ethernet PHY Auto Detach*/ -+ ax88179_auto_detach(dev, 1); -+ -+ /* Enable clock */ -+ ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); -+ tmp8 |= AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; -+ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); -+ msleep(100); -+ -+ /* Configure RX control register => start operation */ -+ tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | -+ AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; -+ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); -+ -+ return usbnet_resume(intf); -+} -+ -+static void -+ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u8 opt; -+ -+ if (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, -+ 1, 1, &opt) < 0) { -+ wolinfo->supported = 0; -+ wolinfo->wolopts = 0; -+ return; -+ } -+ -+ wolinfo->supported = WAKE_PHY | WAKE_MAGIC; -+ wolinfo->wolopts = 0; -+ if (opt & AX_MONITOR_MODE_RWLC) -+ wolinfo->wolopts |= WAKE_PHY; -+ if (opt & AX_MONITOR_MODE_RWMP) -+ wolinfo->wolopts |= WAKE_MAGIC; -+} -+ -+static int -+ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u8 opt = 0; -+ -+ if (wolinfo->wolopts & WAKE_PHY) -+ opt |= AX_MONITOR_MODE_RWLC; -+ if (wolinfo->wolopts & WAKE_MAGIC) -+ opt |= AX_MONITOR_MODE_RWMP; -+ -+ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, -+ 1, 1, &opt) < 0) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static int ax88179_get_eeprom_len(struct net_device *net) -+{ -+ return AX_EEPROM_LEN; -+} -+ -+static int -+ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, -+ u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u16 *eeprom_buff; -+ int first_word, last_word; -+ int i, ret; -+ -+ if (eeprom->len == 0) -+ return -EINVAL; -+ -+ eeprom->magic = AX88179_EEPROM_MAGIC; -+ -+ first_word = eeprom->offset >> 1; -+ last_word = (eeprom->offset + eeprom->len - 1) >> 1; -+ eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), -+ GFP_KERNEL); -+ if (!eeprom_buff) -+ return -ENOMEM; -+ -+ /* ax88179/178A returns 2 bytes from eeprom on read */ -+ for (i = first_word; i <= last_word; i++) { -+ ret = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2, -+ &eeprom_buff[i - first_word], -+ 0); -+ if (ret < 0) { -+ kfree(eeprom_buff); -+ return -EIO; -+ } -+ } -+ -+ memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); -+ kfree(eeprom_buff); -+ return 0; -+} -+ -+static int ax88179_get_settings(struct net_device *net, struct ethtool_cmd *cmd) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ return mii_ethtool_gset(&dev->mii, cmd); -+} -+ -+static int ax88179_set_settings(struct net_device *net, struct ethtool_cmd *cmd) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ return mii_ethtool_sset(&dev->mii, cmd); -+} -+ -+static int -+ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_eee *data) -+{ -+ int val; -+ -+ /* Get Supported EEE */ -+ val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE, -+ MDIO_MMD_PCS); -+ if (val < 0) -+ return val; -+ data->supported = mmd_eee_cap_to_ethtool_sup_t(val); -+ -+ /* Get advertisement EEE */ -+ val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV, -+ MDIO_MMD_AN); -+ if (val < 0) -+ return val; -+ data->advertised = mmd_eee_adv_to_ethtool_adv_t(val); -+ -+ /* Get LP advertisement EEE */ -+ val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE, -+ MDIO_MMD_AN); -+ if (val < 0) -+ return val; -+ data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val); -+ -+ return 0; -+} -+ -+static int -+ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_eee *data) -+{ -+ u16 tmp16 = ethtool_adv_to_mmd_eee_adv_t(data->advertised); -+ -+ return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV, -+ MDIO_MMD_AN, tmp16); -+} -+ -+static int ax88179_chk_eee(struct usbnet *dev) -+{ -+ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; -+ struct ax88179_data *priv = (struct ax88179_data *)dev->data; -+ -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ -+ if (ecmd.duplex & DUPLEX_FULL) { -+ int eee_lp, eee_cap, eee_adv; -+ u32 lp, cap, adv, supported = 0; -+ -+ eee_cap = ax88179_phy_read_mmd_indirect(dev, -+ MDIO_PCS_EEE_ABLE, -+ MDIO_MMD_PCS); -+ if (eee_cap < 0) { -+ priv->eee_active = 0; -+ return false; -+ } -+ -+ cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap); -+ if (!cap) { -+ priv->eee_active = 0; -+ return false; -+ } -+ -+ eee_lp = ax88179_phy_read_mmd_indirect(dev, -+ MDIO_AN_EEE_LPABLE, -+ MDIO_MMD_AN); -+ if (eee_lp < 0) { -+ priv->eee_active = 0; -+ return false; -+ } -+ -+ eee_adv = ax88179_phy_read_mmd_indirect(dev, -+ MDIO_AN_EEE_ADV, -+ MDIO_MMD_AN); -+ -+ if (eee_adv < 0) { -+ priv->eee_active = 0; -+ return false; -+ } -+ -+ adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv); -+ lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp); -+ supported = (ecmd.speed == SPEED_1000) ? -+ SUPPORTED_1000baseT_Full : -+ SUPPORTED_100baseT_Full; -+ -+ if (!(lp & adv & supported)) { -+ priv->eee_active = 0; -+ return false; -+ } -+ -+ priv->eee_active = 1; -+ return true; -+ } -+ -+ priv->eee_active = 0; -+ return false; -+} -+ -+static void ax88179_disable_eee(struct usbnet *dev) -+{ -+ u16 tmp16; -+ -+ tmp16 = GMII_PHY_PGSEL_PAGE3; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHY_PAGE_SELECT, 2, &tmp16); -+ -+ tmp16 = 0x3246; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ MII_PHYADDR, 2, &tmp16); -+ -+ tmp16 = GMII_PHY_PGSEL_PAGE0; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHY_PAGE_SELECT, 2, &tmp16); -+} -+ -+static void ax88179_enable_eee(struct usbnet *dev) -+{ -+ u16 tmp16; -+ -+ tmp16 = GMII_PHY_PGSEL_PAGE3; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHY_PAGE_SELECT, 2, &tmp16); -+ -+ tmp16 = 0x3247; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ MII_PHYADDR, 2, &tmp16); -+ -+ tmp16 = GMII_PHY_PGSEL_PAGE5; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHY_PAGE_SELECT, 2, &tmp16); -+ -+ tmp16 = 0x0680; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ MII_BMSR, 2, &tmp16); -+ -+ tmp16 = GMII_PHY_PGSEL_PAGE0; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHY_PAGE_SELECT, 2, &tmp16); -+} -+ -+static int ax88179_get_eee(struct net_device *net, struct ethtool_eee *edata) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct ax88179_data *priv = (struct ax88179_data *)dev->data; -+ -+ edata->eee_enabled = priv->eee_enabled; -+ edata->eee_active = priv->eee_active; -+ -+ return ax88179_ethtool_get_eee(dev, edata); -+} -+ -+static int ax88179_set_eee(struct net_device *net, struct ethtool_eee *edata) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct ax88179_data *priv = (struct ax88179_data *)dev->data; -+ int ret = -EOPNOTSUPP; -+ -+ priv->eee_enabled = edata->eee_enabled; -+ if (!priv->eee_enabled) { -+ ax88179_disable_eee(dev); -+ } else { -+ priv->eee_enabled = ax88179_chk_eee(dev); -+ if (!priv->eee_enabled) -+ return -EOPNOTSUPP; -+ -+ ax88179_enable_eee(dev); -+ } -+ -+ ret = ax88179_ethtool_set_eee(dev, edata); -+ if (ret) -+ return ret; -+ -+ mii_nway_restart(&dev->mii); -+ -+ usbnet_link_change(dev, 0, 0); -+ -+ return ret; -+} -+ -+static int ax88179_ioctl(struct net_device *net, struct ifreq *rq, int cmd) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -+} -+ -+static const struct ethtool_ops ax88179_ethtool_ops = { -+ .get_link = ethtool_op_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_wol = ax88179_get_wol, -+ .set_wol = ax88179_set_wol, -+ .get_eeprom_len = ax88179_get_eeprom_len, -+ .get_eeprom = ax88179_get_eeprom, -+ .get_settings = ax88179_get_settings, -+ .set_settings = ax88179_set_settings, -+ .get_eee = ax88179_get_eee, -+ .set_eee = ax88179_set_eee, -+ .nway_reset = usbnet_nway_reset, -+}; -+ -+static void ax88179_set_multicast(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct ax88179_data *data = (struct ax88179_data *)dev->data; -+ u8 *m_filter = ((u8 *)dev->data) + 12; -+ -+ data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE); -+ -+ if (net->flags & IFF_PROMISC) { -+ data->rxctl |= AX_RX_CTL_PRO; -+ } else if (net->flags & IFF_ALLMULTI || -+ netdev_mc_count(net) > AX_MAX_MCAST) { -+ data->rxctl |= AX_RX_CTL_AMALL; -+ } else if (netdev_mc_empty(net)) { -+ /* just broadcast and directed */ -+ } else { -+ /* We use the 20 byte dev->data for our 8 byte filter buffer -+ * to avoid allocating memory that is tricky to free later -+ */ -+ u32 crc_bits; -+ struct netdev_hw_addr *ha; -+ -+ memset(m_filter, 0, AX_MCAST_FLTSIZE); -+ -+ netdev_for_each_mc_addr(ha, net) { -+ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; -+ *(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7)); -+ } -+ -+ ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY, -+ AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE, -+ m_filter); -+ -+ data->rxctl |= AX_RX_CTL_AM; -+ } -+ -+ ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, -+ 2, 2, &data->rxctl); -+} -+ -+static int -+ax88179_set_features(struct net_device *net, netdev_features_t features) -+{ -+ u8 tmp; -+ struct usbnet *dev = netdev_priv(net); -+ netdev_features_t changed = net->features ^ features; -+ -+ if (changed & NETIF_F_IP_CSUM) { -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); -+ tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); -+ } -+ -+ if (changed & NETIF_F_IPV6_CSUM) { -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); -+ tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); -+ } -+ -+ if (changed & NETIF_F_RXCSUM) { -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); -+ tmp ^= AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | -+ AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); -+ } -+ -+ return 0; -+} -+ -+static int ax88179_change_mtu(struct net_device *net, int new_mtu) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u16 tmp16; -+ -+ if (new_mtu <= 0 || new_mtu > 4088) -+ return -EINVAL; -+ -+ net->mtu = new_mtu; -+ dev->hard_mtu = net->mtu + net->hard_header_len; -+ -+ if (net->mtu > 1500) { -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &tmp16); -+ tmp16 |= AX_MEDIUM_JUMBO_EN; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &tmp16); -+ } else { -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &tmp16); -+ tmp16 &= ~AX_MEDIUM_JUMBO_EN; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &tmp16); -+ } -+ -+ /* max qlen depend on hard_mtu and rx_urb_size */ -+ usbnet_update_max_qlen(dev); -+ -+ return 0; -+} -+ -+static int ax88179_set_mac_addr(struct net_device *net, void *p) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct sockaddr *addr = p; -+ int ret; -+ -+ if (netif_running(net)) -+ return -EBUSY; -+ if (!is_valid_ether_addr(addr->sa_data)) -+ return -EADDRNOTAVAIL; -+ -+ memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); -+ -+ /* Set the MAC address */ -+ ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, -+ ETH_ALEN, net->dev_addr); -+ if (ret < 0) -+ return ret; -+ -+ return 0; -+} -+ -+static const struct net_device_ops ax88179_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = ax88179_change_mtu, -+ .ndo_set_mac_address = ax88179_set_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = ax88179_ioctl, -+ .ndo_set_rx_mode = ax88179_set_multicast, -+ .ndo_set_features = ax88179_set_features, -+}; -+ -+static int ax88179_check_eeprom(struct usbnet *dev) -+{ -+ u8 i, buf, eeprom[20]; -+ u16 csum, delay = HZ / 10; -+ unsigned long jtimeout; -+ -+ /* Read EEPROM content */ -+ for (i = 0; i < 6; i++) { -+ buf = i; -+ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, -+ 1, 1, &buf) < 0) -+ return -EINVAL; -+ -+ buf = EEP_RD; -+ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, -+ 1, 1, &buf) < 0) -+ return -EINVAL; -+ -+ jtimeout = jiffies + delay; -+ do { -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, -+ 1, 1, &buf); -+ -+ if (time_after(jiffies, jtimeout)) -+ return -EINVAL; -+ -+ } while (buf & EEP_BUSY); -+ -+ __ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, -+ 2, 2, &eeprom[i * 2], 0); -+ -+ if ((i == 0) && (eeprom[0] == 0xFF)) -+ return -EINVAL; -+ } -+ -+ csum = eeprom[6] + eeprom[7] + eeprom[8] + eeprom[9]; -+ csum = (csum >> 8) + (csum & 0xff); -+ if ((csum + eeprom[10]) != 0xff) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static int ax88179_check_efuse(struct usbnet *dev, u16 *ledmode) -+{ -+ u8 i; -+ u8 efuse[64]; -+ u16 csum = 0; -+ -+ if (ax88179_read_cmd(dev, AX_ACCESS_EFUS, 0, 64, 64, efuse) < 0) -+ return -EINVAL; -+ -+ if (*efuse == 0xFF) -+ return -EINVAL; -+ -+ for (i = 0; i < 64; i++) -+ csum = csum + efuse[i]; -+ -+ while (csum > 255) -+ csum = (csum & 0x00FF) + ((csum >> 8) & 0x00FF); -+ -+ if (csum != 0xFF) -+ return -EINVAL; -+ -+ *ledmode = (efuse[51] << 8) | efuse[52]; -+ -+ return 0; -+} -+ -+static int ax88179_convert_old_led(struct usbnet *dev, u16 *ledvalue) -+{ -+ u16 led; -+ -+ /* Loaded the old eFuse LED Mode */ -+ if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM, 0x3C, 1, 2, &led) < 0) -+ return -EINVAL; -+ -+ led >>= 8; -+ switch (led) { -+ case 0xFF: -+ led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | -+ LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | -+ LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; -+ break; -+ case 0xFE: -+ led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | LED_VALID; -+ break; -+ case 0xFD: -+ led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | -+ LED2_LINK_10 | LED_VALID; -+ break; -+ case 0xFC: -+ led = LED0_ACTIVE | LED1_ACTIVE | LED1_LINK_1000 | LED2_ACTIVE | -+ LED2_LINK_100 | LED2_LINK_10 | LED_VALID; -+ break; -+ default: -+ led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | -+ LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | -+ LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; -+ break; -+ } -+ -+ *ledvalue = led; -+ -+ return 0; -+} -+ -+static int ax88179_led_setting(struct usbnet *dev) -+{ -+ u8 ledfd, value = 0; -+ u16 tmp, ledact, ledlink, ledvalue = 0, delay = HZ / 10; -+ unsigned long jtimeout; -+ -+ /* Check AX88179 version. UA1 or UA2*/ -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, GENERAL_STATUS, 1, 1, &value); -+ -+ if (!(value & AX_SECLD)) { /* UA1 */ -+ value = AX_GPIO_CTRL_GPIO3EN | AX_GPIO_CTRL_GPIO2EN | -+ AX_GPIO_CTRL_GPIO1EN; -+ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_GPIO_CTRL, -+ 1, 1, &value) < 0) -+ return -EINVAL; -+ } -+ -+ /* Check EEPROM */ -+ if (!ax88179_check_eeprom(dev)) { -+ value = 0x42; -+ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, -+ 1, 1, &value) < 0) -+ return -EINVAL; -+ -+ value = EEP_RD; -+ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, -+ 1, 1, &value) < 0) -+ return -EINVAL; -+ -+ jtimeout = jiffies + delay; -+ do { -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, -+ 1, 1, &value); -+ -+ if (time_after(jiffies, jtimeout)) -+ return -EINVAL; -+ -+ } while (value & EEP_BUSY); -+ -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_HIGH, -+ 1, 1, &value); -+ ledvalue = (value << 8); -+ -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, -+ 1, 1, &value); -+ ledvalue |= value; -+ -+ /* load internal ROM for defaule setting */ -+ if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) -+ ax88179_convert_old_led(dev, &ledvalue); -+ -+ } else if (!ax88179_check_efuse(dev, &ledvalue)) { -+ if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) -+ ax88179_convert_old_led(dev, &ledvalue); -+ } else { -+ ax88179_convert_old_led(dev, &ledvalue); -+ } -+ -+ tmp = GMII_PHY_PGSEL_EXT; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHY_PAGE_SELECT, 2, &tmp); -+ -+ tmp = 0x2c; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHYPAGE, 2, &tmp); -+ -+ ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_LED_ACT, 2, &ledact); -+ -+ ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_LED_LINK, 2, &ledlink); -+ -+ ledact &= GMII_LED_ACTIVE_MASK; -+ ledlink &= GMII_LED_LINK_MASK; -+ -+ if (ledvalue & LED0_ACTIVE) -+ ledact |= GMII_LED0_ACTIVE; -+ -+ if (ledvalue & LED1_ACTIVE) -+ ledact |= GMII_LED1_ACTIVE; -+ -+ if (ledvalue & LED2_ACTIVE) -+ ledact |= GMII_LED2_ACTIVE; -+ -+ if (ledvalue & LED0_LINK_10) -+ ledlink |= GMII_LED0_LINK_10; -+ -+ if (ledvalue & LED1_LINK_10) -+ ledlink |= GMII_LED1_LINK_10; -+ -+ if (ledvalue & LED2_LINK_10) -+ ledlink |= GMII_LED2_LINK_10; -+ -+ if (ledvalue & LED0_LINK_100) -+ ledlink |= GMII_LED0_LINK_100; -+ -+ if (ledvalue & LED1_LINK_100) -+ ledlink |= GMII_LED1_LINK_100; -+ -+ if (ledvalue & LED2_LINK_100) -+ ledlink |= GMII_LED2_LINK_100; -+ -+ if (ledvalue & LED0_LINK_1000) -+ ledlink |= GMII_LED0_LINK_1000; -+ -+ if (ledvalue & LED1_LINK_1000) -+ ledlink |= GMII_LED1_LINK_1000; -+ -+ if (ledvalue & LED2_LINK_1000) -+ ledlink |= GMII_LED2_LINK_1000; -+ -+ tmp = ledact; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_LED_ACT, 2, &tmp); -+ -+ tmp = ledlink; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_LED_LINK, 2, &tmp); -+ -+ tmp = GMII_PHY_PGSEL_PAGE0; -+ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHY_PAGE_SELECT, 2, &tmp); -+ -+ /* LED full duplex setting */ -+ ledfd = 0; -+ if (ledvalue & LED0_FD) -+ ledfd |= 0x01; -+ else if ((ledvalue & LED0_USB3_MASK) == 0) -+ ledfd |= 0x02; -+ -+ if (ledvalue & LED1_FD) -+ ledfd |= 0x04; -+ else if ((ledvalue & LED1_USB3_MASK) == 0) -+ ledfd |= 0x08; -+ -+ if (ledvalue & LED2_FD) -+ ledfd |= 0x10; -+ else if ((ledvalue & LED2_USB3_MASK) == 0) -+ ledfd |= 0x20; -+ -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_LEDCTRL, 1, 1, &ledfd); -+ -+ return 0; -+} -+ -+static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ u8 buf[5]; -+ u16 *tmp16; -+ u8 *tmp; -+ struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; -+ struct ethtool_eee eee_data; -+ -+ usbnet_get_endpoints(dev, intf); -+ -+ tmp16 = (u16 *)buf; -+ tmp = (u8 *)buf; -+ -+ memset(ax179_data, 0, sizeof(*ax179_data)); -+ -+ /* Power up ethernet PHY */ -+ *tmp16 = 0; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); -+ *tmp16 = AX_PHYPWR_RSTCTL_IPRL; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); -+ msleep(200); -+ -+ *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp); -+ msleep(100); -+ -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, -+ ETH_ALEN, dev->net->dev_addr); -+ memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN); -+ -+ /* RX bulk configuration */ -+ memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); -+ -+ dev->rx_urb_size = 1024 * 20; -+ -+ *tmp = 0x34; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp); -+ -+ *tmp = 0x52; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, -+ 1, 1, tmp); -+ -+ dev->net->netdev_ops = &ax88179_netdev_ops; -+ dev->net->ethtool_ops = &ax88179_ethtool_ops; -+ dev->net->needed_headroom = 8; -+ -+ /* Initialize MII structure */ -+ dev->mii.dev = dev->net; -+ dev->mii.mdio_read = ax88179_mdio_read; -+ dev->mii.mdio_write = ax88179_mdio_write; -+ dev->mii.phy_id_mask = 0xff; -+ dev->mii.reg_num_mask = 0xff; -+ dev->mii.phy_id = 0x03; -+ dev->mii.supports_gmii = 1; -+ -+ dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | -+ NETIF_F_RXCSUM; -+ -+ dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | -+ NETIF_F_RXCSUM; -+ -+ /* Enable checksum offload */ -+ *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | -+ AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp); -+ -+ *tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP | -+ AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp); -+ -+ /* Configure RX control register => start operation */ -+ *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | -+ AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); -+ -+ *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | -+ AX_MONITOR_MODE_RWMP; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp); -+ -+ /* Configure default medium type => giga */ -+ *tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | -+ AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX | -+ AX_MEDIUM_GIGAMODE; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, tmp16); -+ -+ ax88179_led_setting(dev); -+ -+ ax179_data->eee_enabled = 0; -+ ax179_data->eee_active = 0; -+ -+ ax88179_disable_eee(dev); -+ -+ ax88179_ethtool_get_eee(dev, &eee_data); -+ eee_data.advertised = 0; -+ ax88179_ethtool_set_eee(dev, &eee_data); -+ -+ /* Restart autoneg */ -+ mii_nway_restart(&dev->mii); -+ -+ usbnet_link_change(dev, 0, 0); -+ -+ return 0; -+} -+ -+static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ u16 tmp16; -+ -+ /* Configure RX control register => stop operation */ -+ tmp16 = AX_RX_CTL_STOP; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); -+ -+ tmp16 = 0; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp16); -+ -+ /* Power down ethernet PHY */ -+ tmp16 = 0; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); -+} -+ -+static void -+ax88179_rx_checksum(struct sk_buff *skb, u32 *pkt_hdr) -+{ -+ skb->ip_summed = CHECKSUM_NONE; -+ -+ /* checksum error bit is set */ -+ if ((*pkt_hdr & AX_RXHDR_L3CSUM_ERR) || -+ (*pkt_hdr & AX_RXHDR_L4CSUM_ERR)) -+ return; -+ -+ /* It must be a TCP or UDP packet with a valid checksum */ -+ if (((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_TCP) || -+ ((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_UDP)) -+ skb->ip_summed = CHECKSUM_UNNECESSARY; -+} -+ -+static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ struct sk_buff *ax_skb; -+ int pkt_cnt; -+ u32 rx_hdr; -+ u16 hdr_off; -+ u32 *pkt_hdr; -+ -+ /* This check is no longer done by usbnet */ -+ if (skb->len < dev->net->hard_header_len) -+ return 0; -+ -+ skb_trim(skb, skb->len - 4); -+ memcpy(&rx_hdr, skb_tail_pointer(skb), 4); -+ le32_to_cpus(&rx_hdr); -+ -+ pkt_cnt = (u16)rx_hdr; -+ hdr_off = (u16)(rx_hdr >> 16); -+ pkt_hdr = (u32 *)(skb->data + hdr_off); -+ -+ while (pkt_cnt--) { -+ u16 pkt_len; -+ -+ le32_to_cpus(pkt_hdr); -+ pkt_len = (*pkt_hdr >> 16) & 0x1fff; -+ -+ /* Check CRC or runt packet */ -+ if ((*pkt_hdr & AX_RXHDR_CRC_ERR) || -+ (*pkt_hdr & AX_RXHDR_DROP_ERR)) { -+ skb_pull(skb, (pkt_len + 7) & 0xFFF8); -+ pkt_hdr++; -+ continue; -+ } -+ -+ if (pkt_cnt == 0) { -+ /* Skip IP alignment psudo header */ -+ skb_pull(skb, 2); -+ skb->len = pkt_len; -+ skb_set_tail_pointer(skb, pkt_len); -+ skb->truesize = pkt_len + sizeof(struct sk_buff); -+ ax88179_rx_checksum(skb, pkt_hdr); -+ return 1; -+ } -+ -+ ax_skb = skb_clone(skb, GFP_ATOMIC); -+ if (ax_skb) { -+ ax_skb->len = pkt_len; -+ ax_skb->data = skb->data + 2; -+ skb_set_tail_pointer(ax_skb, pkt_len); -+ ax_skb->truesize = pkt_len + sizeof(struct sk_buff); -+ ax88179_rx_checksum(ax_skb, pkt_hdr); -+ usbnet_skb_return(dev, ax_skb); -+ } else { -+ return 0; -+ } -+ -+ skb_pull(skb, (pkt_len + 7) & 0xFFF8); -+ pkt_hdr++; -+ } -+ return 1; -+} -+ -+static struct sk_buff * -+ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) -+{ -+ u32 tx_hdr1, tx_hdr2; -+ int frame_size = dev->maxpacket; -+ int mss = skb_shinfo(skb)->gso_size; -+ int headroom; -+ -+ tx_hdr1 = skb->len; -+ tx_hdr2 = mss; -+ if (((skb->len + 8) % frame_size) == 0) -+ tx_hdr2 |= 0x80008000; /* Enable padding */ -+ -+ headroom = skb_headroom(skb) - 8; -+ -+ if ((skb_header_cloned(skb) || headroom < 0) && -+ pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) { -+ dev_kfree_skb_any(skb); -+ return NULL; -+ } -+ -+ skb_push(skb, 4); -+ cpu_to_le32s(&tx_hdr2); -+ skb_copy_to_linear_data(skb, &tx_hdr2, 4); -+ -+ skb_push(skb, 4); -+ cpu_to_le32s(&tx_hdr1); -+ skb_copy_to_linear_data(skb, &tx_hdr1, 4); -+ -+ return skb; -+} -+ -+static int ax88179_link_reset(struct usbnet *dev) -+{ -+ struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; -+ u8 tmp[5], link_sts; -+ u16 mode, tmp16, delay = HZ / 10; -+ u32 tmp32 = 0x40000000; -+ unsigned long jtimeout; -+ -+ jtimeout = jiffies + delay; -+ while (tmp32 & 0x40000000) { -+ mode = 0; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &mode); -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, -+ &ax179_data->rxctl); -+ -+ /*link up, check the usb device control TX FIFO full or empty*/ -+ ax88179_read_cmd(dev, 0x81, 0x8c, 0, 4, &tmp32); -+ -+ if (time_after(jiffies, jtimeout)) -+ return 0; -+ } -+ -+ mode = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | -+ AX_MEDIUM_RXFLOW_CTRLEN; -+ -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, -+ 1, 1, &link_sts); -+ -+ ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, -+ GMII_PHY_PHYSR, 2, &tmp16); -+ -+ if (!(tmp16 & GMII_PHY_PHYSR_LINK)) { -+ return 0; -+ } else if (GMII_PHY_PHYSR_GIGA == (tmp16 & GMII_PHY_PHYSR_SMASK)) { -+ mode |= AX_MEDIUM_GIGAMODE | AX_MEDIUM_EN_125MHZ; -+ if (dev->net->mtu > 1500) -+ mode |= AX_MEDIUM_JUMBO_EN; -+ -+ if (link_sts & AX_USB_SS) -+ memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); -+ else if (link_sts & AX_USB_HS) -+ memcpy(tmp, &AX88179_BULKIN_SIZE[1], 5); -+ else -+ memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); -+ } else if (GMII_PHY_PHYSR_100 == (tmp16 & GMII_PHY_PHYSR_SMASK)) { -+ mode |= AX_MEDIUM_PS; -+ -+ if (link_sts & (AX_USB_SS | AX_USB_HS)) -+ memcpy(tmp, &AX88179_BULKIN_SIZE[2], 5); -+ else -+ memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); -+ } else { -+ memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); -+ } -+ -+ /* RX bulk configuration */ -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); -+ -+ dev->rx_urb_size = (1024 * (tmp[3] + 2)); -+ -+ if (tmp16 & GMII_PHY_PHYSR_FULL) -+ mode |= AX_MEDIUM_FULL_DUPLEX; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &mode); -+ -+ ax179_data->eee_enabled = ax88179_chk_eee(dev); -+ -+ netif_carrier_on(dev->net); -+ -+ return 0; -+} -+ -+static int ax88179_reset(struct usbnet *dev) -+{ -+ u8 buf[5]; -+ u16 *tmp16; -+ u8 *tmp; -+ struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; -+ struct ethtool_eee eee_data; -+ -+ tmp16 = (u16 *)buf; -+ tmp = (u8 *)buf; -+ -+ /* Power up ethernet PHY */ -+ *tmp16 = 0; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); -+ -+ *tmp16 = AX_PHYPWR_RSTCTL_IPRL; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); -+ msleep(200); -+ -+ *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp); -+ msleep(100); -+ -+ /* Ethernet PHY Auto Detach*/ -+ ax88179_auto_detach(dev, 0); -+ -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN, -+ dev->net->dev_addr); -+ memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN); -+ -+ /* RX bulk configuration */ -+ memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); -+ -+ dev->rx_urb_size = 1024 * 20; -+ -+ *tmp = 0x34; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp); -+ -+ *tmp = 0x52; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, -+ 1, 1, tmp); -+ -+ dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | -+ NETIF_F_RXCSUM; -+ -+ dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | -+ NETIF_F_RXCSUM; -+ -+ /* Enable checksum offload */ -+ *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | -+ AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp); -+ -+ *tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP | -+ AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp); -+ -+ /* Configure RX control register => start operation */ -+ *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | -+ AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); -+ -+ *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | -+ AX_MONITOR_MODE_RWMP; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp); -+ -+ /* Configure default medium type => giga */ -+ *tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | -+ AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX | -+ AX_MEDIUM_GIGAMODE; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, tmp16); -+ -+ ax88179_led_setting(dev); -+ -+ ax179_data->eee_enabled = 0; -+ ax179_data->eee_active = 0; -+ -+ ax88179_disable_eee(dev); -+ -+ ax88179_ethtool_get_eee(dev, &eee_data); -+ eee_data.advertised = 0; -+ ax88179_ethtool_set_eee(dev, &eee_data); -+ -+ /* Restart autoneg */ -+ mii_nway_restart(&dev->mii); -+ -+ usbnet_link_change(dev, 0, 0); -+ -+ return 0; -+} -+ -+static int ax88179_stop(struct usbnet *dev) -+{ -+ u16 tmp16; -+ -+ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &tmp16); -+ tmp16 &= ~AX_MEDIUM_RECEIVE_EN; -+ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, -+ 2, 2, &tmp16); -+ -+ return 0; -+} -+ -+static const struct driver_info ax88179_info = { -+ .description = "ASIX AX88179 USB 3.0 Gigabit Ethernet", -+ .bind = ax88179_bind, -+ .unbind = ax88179_unbind, -+ .status = ax88179_status, -+ .link_reset = ax88179_link_reset, -+ .reset = ax88179_reset, -+ .stop = ax88179_stop, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX, -+ .rx_fixup = ax88179_rx_fixup, -+ .tx_fixup = ax88179_tx_fixup, -+}; -+ -+static const struct driver_info ax88178a_info = { -+ .description = "ASIX AX88178A USB 2.0 Gigabit Ethernet", -+ .bind = ax88179_bind, -+ .unbind = ax88179_unbind, -+ .status = ax88179_status, -+ .link_reset = ax88179_link_reset, -+ .reset = ax88179_reset, -+ .stop = ax88179_stop, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX, -+ .rx_fixup = ax88179_rx_fixup, -+ .tx_fixup = ax88179_tx_fixup, -+}; -+ -+static const struct driver_info dlink_dub1312_info = { -+ .description = "D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter", -+ .bind = ax88179_bind, -+ .unbind = ax88179_unbind, -+ .status = ax88179_status, -+ .link_reset = ax88179_link_reset, -+ .reset = ax88179_reset, -+ .stop = ax88179_stop, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX, -+ .rx_fixup = ax88179_rx_fixup, -+ .tx_fixup = ax88179_tx_fixup, -+}; -+ -+static const struct driver_info sitecom_info = { -+ .description = "Sitecom USB 3.0 to Gigabit Adapter", -+ .bind = ax88179_bind, -+ .unbind = ax88179_unbind, -+ .status = ax88179_status, -+ .link_reset = ax88179_link_reset, -+ .reset = ax88179_reset, -+ .stop = ax88179_stop, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX, -+ .rx_fixup = ax88179_rx_fixup, -+ .tx_fixup = ax88179_tx_fixup, -+}; -+ -+static const struct driver_info samsung_info = { -+ .description = "Samsung USB Ethernet Adapter", -+ .bind = ax88179_bind, -+ .unbind = ax88179_unbind, -+ .status = ax88179_status, -+ .link_reset = ax88179_link_reset, -+ .reset = ax88179_reset, -+ .stop = ax88179_stop, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX, -+ .rx_fixup = ax88179_rx_fixup, -+ .tx_fixup = ax88179_tx_fixup, -+}; -+ -+static const struct driver_info lenovo_info = { -+ .description = "Lenovo OneLinkDock Gigabit LAN", -+ .bind = ax88179_bind, -+ .unbind = ax88179_unbind, -+ .status = ax88179_status, -+ .link_reset = ax88179_link_reset, -+ .reset = ax88179_reset, -+ .stop = ax88179_stop, -+ .flags = FLAG_ETHER | FLAG_FRAMING_AX, -+ .rx_fixup = ax88179_rx_fixup, -+ .tx_fixup = ax88179_tx_fixup, -+}; -+ -+static const struct usb_device_id products[] = { -+{ -+ /* ASIX AX88179 10/100/1000 */ -+ USB_DEVICE(0x0b95, 0x1790), -+ .driver_info = (unsigned long)&ax88179_info, -+}, { -+ /* ASIX AX88178A 10/100/1000 */ -+ USB_DEVICE(0x0b95, 0x178a), -+ .driver_info = (unsigned long)&ax88178a_info, -+}, { -+ /* D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter */ -+ USB_DEVICE(0x2001, 0x4a00), -+ .driver_info = (unsigned long)&dlink_dub1312_info, -+}, { -+ /* Sitecom USB 3.0 to Gigabit Adapter */ -+ USB_DEVICE(0x0df6, 0x0072), -+ .driver_info = (unsigned long)&sitecom_info, -+}, { -+ /* Samsung USB Ethernet Adapter */ -+ USB_DEVICE(0x04e8, 0xa100), -+ .driver_info = (unsigned long)&samsung_info, -+}, { -+ /* Lenovo OneLinkDock Gigabit LAN */ -+ USB_DEVICE(0x17ef, 0x304b), -+ .driver_info = (unsigned long)&lenovo_info, -+}, -+ { }, -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver ax88179_178a_driver = { -+ .name = "ax88179_178a", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .suspend = ax88179_suspend, -+ .resume = ax88179_resume, -+ .reset_resume = ax88179_resume, -+ .disconnect = usbnet_disconnect, -+ .supports_autosuspend = 1, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(ax88179_178a_driver); -+ -+MODULE_DESCRIPTION("ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/catc.c backports-3.18.1-1/drivers/net/usb/catc.c ---- backports-3.18.1-1.org/drivers/net/usb/catc.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/catc.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,965 @@ -+/* -+ * Copyright (c) 2001 Vojtech Pavlik -+ * -+ * CATC EL1210A NetMate USB Ethernet driver -+ * -+ * Sponsored by SuSE -+ * -+ * Based on the work of -+ * Donald Becker -+ * -+ * Old chipset support added by Simon Evans spse@secret.org.uk 2002 -+ * - adds support for Belkin F5U011 -+ */ -+ -+/* -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ * -+ * Should you need to contact me, the author, you can do so either by -+ * e-mail - mail your message to vojtech@suse.cz, or by paper mail: -+ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic -+ */ -+ -+#include <linux/module.h> -+#include <linux/kernel.h> -+#include <linux/string.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/skbuff.h> -+#include <linux/spinlock.h> -+#include <linux/ethtool.h> -+#include <linux/crc32.h> -+#include <linux/bitops.h> -+#include <linux/gfp.h> -+#include <asm/uaccess.h> -+ -+#undef DEBUG -+ -+#include <linux/usb.h> -+ -+/* -+ * Version information. -+ */ -+ -+#define DRIVER_VERSION "v2.8" -+#define DRIVER_AUTHOR "Vojtech Pavlik vojtech@suse.cz" -+#define DRIVER_DESC "CATC EL1210A NetMate USB Ethernet driver" -+#define SHORT_DRIVER_DESC "EL1210A NetMate USB Ethernet" -+ -+MODULE_AUTHOR(DRIVER_AUTHOR); -+MODULE_DESCRIPTION(DRIVER_DESC); -+MODULE_LICENSE("GPL"); -+ -+static const char driver_name[] = "catc"; -+ -+/* -+ * Some defines. -+ */ -+ -+#define STATS_UPDATE (HZ) /* Time between stats updates */ -+#define TX_TIMEOUT (5*HZ) /* Max time the queue can be stopped */ -+#define PKT_SZ 1536 /* Max Ethernet packet size */ -+#define RX_MAX_BURST 15 /* Max packets per rx buffer (> 0, < 16) */ -+#define TX_MAX_BURST 15 /* Max full sized packets per tx buffer (> 0) */ -+#define CTRL_QUEUE 16 /* Max control requests in flight (power of two) */ -+#define RX_PKT_SZ 1600 /* Max size of receive packet for F5U011 */ -+ -+/* -+ * Control requests. -+ */ -+ -+enum control_requests { -+ ReadMem = 0xf1, -+ GetMac = 0xf2, -+ Reset = 0xf4, -+ SetMac = 0xf5, -+ SetRxMode = 0xf5, /* F5U011 only */ -+ WriteROM = 0xf8, -+ SetReg = 0xfa, -+ GetReg = 0xfb, -+ WriteMem = 0xfc, -+ ReadROM = 0xfd, -+}; -+ -+/* -+ * Registers. -+ */ -+ -+enum register_offsets { -+ TxBufCount = 0x20, -+ RxBufCount = 0x21, -+ OpModes = 0x22, -+ TxQed = 0x23, -+ RxQed = 0x24, -+ MaxBurst = 0x25, -+ RxUnit = 0x60, -+ EthStatus = 0x61, -+ StationAddr0 = 0x67, -+ EthStats = 0x69, -+ LEDCtrl = 0x81, -+}; -+ -+enum eth_stats { -+ TxSingleColl = 0x00, -+ TxMultiColl = 0x02, -+ TxExcessColl = 0x04, -+ RxFramErr = 0x06, -+}; -+ -+enum op_mode_bits { -+ Op3MemWaits = 0x03, -+ OpLenInclude = 0x08, -+ OpRxMerge = 0x10, -+ OpTxMerge = 0x20, -+ OpWin95bugfix = 0x40, -+ OpLoopback = 0x80, -+}; -+ -+enum rx_filter_bits { -+ RxEnable = 0x01, -+ RxPolarity = 0x02, -+ RxForceOK = 0x04, -+ RxMultiCast = 0x08, -+ RxPromisc = 0x10, -+ AltRxPromisc = 0x20, /* F5U011 uses different bit */ -+}; -+ -+enum led_values { -+ LEDFast = 0x01, -+ LEDSlow = 0x02, -+ LEDFlash = 0x03, -+ LEDPulse = 0x04, -+ LEDLink = 0x08, -+}; -+ -+enum link_status { -+ LinkNoChange = 0, -+ LinkGood = 1, -+ LinkBad = 2 -+}; -+ -+/* -+ * The catc struct. -+ */ -+ -+#define CTRL_RUNNING 0 -+#define RX_RUNNING 1 -+#define TX_RUNNING 2 -+ -+struct catc { -+ struct net_device *netdev; -+ struct usb_device *usbdev; -+ -+ unsigned long flags; -+ -+ unsigned int tx_ptr, tx_idx; -+ unsigned int ctrl_head, ctrl_tail; -+ spinlock_t tx_lock, ctrl_lock; -+ -+ u8 tx_buf[2][TX_MAX_BURST * (PKT_SZ + 2)]; -+ u8 rx_buf[RX_MAX_BURST * (PKT_SZ + 2)]; -+ u8 irq_buf[2]; -+ u8 ctrl_buf[64]; -+ struct usb_ctrlrequest ctrl_dr; -+ -+ struct timer_list timer; -+ u8 stats_buf[8]; -+ u16 stats_vals[4]; -+ unsigned long last_stats; -+ -+ u8 multicast[64]; -+ -+ struct ctrl_queue { -+ u8 dir; -+ u8 request; -+ u16 value; -+ u16 index; -+ void *buf; -+ int len; -+ void (*callback)(struct catc *catc, struct ctrl_queue *q); -+ } ctrl_queue[CTRL_QUEUE]; -+ -+ struct urb *tx_urb, *rx_urb, *irq_urb, *ctrl_urb; -+ -+ u8 is_f5u011; /* Set if device is an F5U011 */ -+ u8 rxmode[2]; /* Used for F5U011 */ -+ atomic_t recq_sz; /* Used for F5U011 - counter of waiting rx packets */ -+}; -+ -+/* -+ * Useful macros. -+ */ -+ -+#define catc_get_mac(catc, mac) catc_ctrl_msg(catc, USB_DIR_IN, GetMac, 0, 0, mac, 6) -+#define catc_reset(catc) catc_ctrl_msg(catc, USB_DIR_OUT, Reset, 0, 0, NULL, 0) -+#define catc_set_reg(catc, reg, val) catc_ctrl_msg(catc, USB_DIR_OUT, SetReg, val, reg, NULL, 0) -+#define catc_get_reg(catc, reg, buf) catc_ctrl_msg(catc, USB_DIR_IN, GetReg, 0, reg, buf, 1) -+#define catc_write_mem(catc, addr, buf, size) catc_ctrl_msg(catc, USB_DIR_OUT, WriteMem, 0, addr, buf, size) -+#define catc_read_mem(catc, addr, buf, size) catc_ctrl_msg(catc, USB_DIR_IN, ReadMem, 0, addr, buf, size) -+ -+#define f5u011_rxmode(catc, rxmode) catc_ctrl_msg(catc, USB_DIR_OUT, SetRxMode, 0, 1, rxmode, 2) -+#define f5u011_rxmode_async(catc, rxmode) catc_ctrl_async(catc, USB_DIR_OUT, SetRxMode, 0, 1, &rxmode, 2, NULL) -+#define f5u011_mchash_async(catc, hash) catc_ctrl_async(catc, USB_DIR_OUT, SetRxMode, 0, 2, &hash, 8, NULL) -+ -+#define catc_set_reg_async(catc, reg, val) catc_ctrl_async(catc, USB_DIR_OUT, SetReg, val, reg, NULL, 0, NULL) -+#define catc_get_reg_async(catc, reg, cb) catc_ctrl_async(catc, USB_DIR_IN, GetReg, 0, reg, NULL, 1, cb) -+#define catc_write_mem_async(catc, addr, buf, size) catc_ctrl_async(catc, USB_DIR_OUT, WriteMem, 0, addr, buf, size, NULL) -+ -+/* -+ * Receive routines. -+ */ -+ -+static void catc_rx_done(struct urb *urb) -+{ -+ struct catc *catc = urb->context; -+ u8 *pkt_start = urb->transfer_buffer; -+ struct sk_buff *skb; -+ int pkt_len, pkt_offset = 0; -+ int status = urb->status; -+ -+ if (!catc->is_f5u011) { -+ clear_bit(RX_RUNNING, &catc->flags); -+ pkt_offset = 2; -+ } -+ -+ if (status) { -+ dev_dbg(&urb->dev->dev, "rx_done, status %d, length %d\n", -+ status, urb->actual_length); -+ return; -+ } -+ -+ do { -+ if(!catc->is_f5u011) { -+ pkt_len = le16_to_cpup((__le16*)pkt_start); -+ if (pkt_len > urb->actual_length) { -+ catc->netdev->stats.rx_length_errors++; -+ catc->netdev->stats.rx_errors++; -+ break; -+ } -+ } else { -+ pkt_len = urb->actual_length; -+ } -+ -+ if (!(skb = dev_alloc_skb(pkt_len))) -+ return; -+ -+ skb_copy_to_linear_data(skb, pkt_start + pkt_offset, pkt_len); -+ skb_put(skb, pkt_len); -+ -+ skb->protocol = eth_type_trans(skb, catc->netdev); -+ netif_rx(skb); -+ -+ catc->netdev->stats.rx_packets++; -+ catc->netdev->stats.rx_bytes += pkt_len; -+ -+ /* F5U011 only does one packet per RX */ -+ if (catc->is_f5u011) -+ break; -+ pkt_start += (((pkt_len + 1) >> 6) + 1) << 6; -+ -+ } while (pkt_start - (u8 *) urb->transfer_buffer < urb->actual_length); -+ -+ if (catc->is_f5u011) { -+ if (atomic_read(&catc->recq_sz)) { -+ int state; -+ atomic_dec(&catc->recq_sz); -+ netdev_dbg(catc->netdev, "getting extra packet\n"); -+ urb->dev = catc->usbdev; -+ if ((state = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { -+ netdev_dbg(catc->netdev, -+ "submit(rx_urb) status %d\n", state); -+ } -+ } else { -+ clear_bit(RX_RUNNING, &catc->flags); -+ } -+ } -+} -+ -+static void catc_irq_done(struct urb *urb) -+{ -+ struct catc *catc = urb->context; -+ u8 *data = urb->transfer_buffer; -+ int status = urb->status; -+ unsigned int hasdata = 0, linksts = LinkNoChange; -+ int res; -+ -+ if (!catc->is_f5u011) { -+ hasdata = data[1] & 0x80; -+ if (data[1] & 0x40) -+ linksts = LinkGood; -+ else if (data[1] & 0x20) -+ linksts = LinkBad; -+ } else { -+ hasdata = (unsigned int)(be16_to_cpup((__be16*)data) & 0x0fff); -+ if (data[0] == 0x90) -+ linksts = LinkGood; -+ else if (data[0] == 0xA0) -+ linksts = LinkBad; -+ } -+ -+ switch (status) { -+ case 0: /* success */ -+ break; -+ case -ECONNRESET: /* unlink */ -+ case -ENOENT: -+ case -ESHUTDOWN: -+ return; -+ /* -EPIPE: should clear the halt */ -+ default: /* error */ -+ dev_dbg(&urb->dev->dev, -+ "irq_done, status %d, data %02x %02x.\n", -+ status, data[0], data[1]); -+ goto resubmit; -+ } -+ -+ if (linksts == LinkGood) { -+ netif_carrier_on(catc->netdev); -+ netdev_dbg(catc->netdev, "link ok\n"); -+ } -+ -+ if (linksts == LinkBad) { -+ netif_carrier_off(catc->netdev); -+ netdev_dbg(catc->netdev, "link bad\n"); -+ } -+ -+ if (hasdata) { -+ if (test_and_set_bit(RX_RUNNING, &catc->flags)) { -+ if (catc->is_f5u011) -+ atomic_inc(&catc->recq_sz); -+ } else { -+ catc->rx_urb->dev = catc->usbdev; -+ if ((res = usb_submit_urb(catc->rx_urb, GFP_ATOMIC)) < 0) { -+ dev_err(&catc->usbdev->dev, -+ "submit(rx_urb) status %d\n", res); -+ } -+ } -+ } -+resubmit: -+ res = usb_submit_urb (urb, GFP_ATOMIC); -+ if (res) -+ dev_err(&catc->usbdev->dev, -+ "can't resubmit intr, %s-%s, status %d\n", -+ catc->usbdev->bus->bus_name, -+ catc->usbdev->devpath, res); -+} -+ -+/* -+ * Transmit routines. -+ */ -+ -+static int catc_tx_run(struct catc *catc) -+{ -+ int status; -+ -+ if (catc->is_f5u011) -+ catc->tx_ptr = (catc->tx_ptr + 63) & ~63; -+ -+ catc->tx_urb->transfer_buffer_length = catc->tx_ptr; -+ catc->tx_urb->transfer_buffer = catc->tx_buf[catc->tx_idx]; -+ catc->tx_urb->dev = catc->usbdev; -+ -+ if ((status = usb_submit_urb(catc->tx_urb, GFP_ATOMIC)) < 0) -+ dev_err(&catc->usbdev->dev, "submit(tx_urb), status %d\n", -+ status); -+ -+ catc->tx_idx = !catc->tx_idx; -+ catc->tx_ptr = 0; -+ -+ catc->netdev->trans_start = jiffies; -+ return status; -+} -+ -+static void catc_tx_done(struct urb *urb) -+{ -+ struct catc *catc = urb->context; -+ unsigned long flags; -+ int r, status = urb->status; -+ -+ if (status == -ECONNRESET) { -+ dev_dbg(&urb->dev->dev, "Tx Reset.\n"); -+ urb->status = 0; -+ catc->netdev->trans_start = jiffies; -+ catc->netdev->stats.tx_errors++; -+ clear_bit(TX_RUNNING, &catc->flags); -+ netif_wake_queue(catc->netdev); -+ return; -+ } -+ -+ if (status) { -+ dev_dbg(&urb->dev->dev, "tx_done, status %d, length %d\n", -+ status, urb->actual_length); -+ return; -+ } -+ -+ spin_lock_irqsave(&catc->tx_lock, flags); -+ -+ if (catc->tx_ptr) { -+ r = catc_tx_run(catc); -+ if (unlikely(r < 0)) -+ clear_bit(TX_RUNNING, &catc->flags); -+ } else { -+ clear_bit(TX_RUNNING, &catc->flags); -+ } -+ -+ netif_wake_queue(catc->netdev); -+ -+ spin_unlock_irqrestore(&catc->tx_lock, flags); -+} -+ -+static netdev_tx_t catc_start_xmit(struct sk_buff *skb, -+ struct net_device *netdev) -+{ -+ struct catc *catc = netdev_priv(netdev); -+ unsigned long flags; -+ int r = 0; -+ char *tx_buf; -+ -+ spin_lock_irqsave(&catc->tx_lock, flags); -+ -+ catc->tx_ptr = (((catc->tx_ptr - 1) >> 6) + 1) << 6; -+ tx_buf = catc->tx_buf[catc->tx_idx] + catc->tx_ptr; -+ if (catc->is_f5u011) -+ *(__be16 *)tx_buf = cpu_to_be16(skb->len); -+ else -+ *(__le16 *)tx_buf = cpu_to_le16(skb->len); -+ skb_copy_from_linear_data(skb, tx_buf + 2, skb->len); -+ catc->tx_ptr += skb->len + 2; -+ -+ if (!test_and_set_bit(TX_RUNNING, &catc->flags)) { -+ r = catc_tx_run(catc); -+ if (r < 0) -+ clear_bit(TX_RUNNING, &catc->flags); -+ } -+ -+ if ((catc->is_f5u011 && catc->tx_ptr) || -+ (catc->tx_ptr >= ((TX_MAX_BURST - 1) * (PKT_SZ + 2)))) -+ netif_stop_queue(netdev); -+ -+ spin_unlock_irqrestore(&catc->tx_lock, flags); -+ -+ if (r >= 0) { -+ catc->netdev->stats.tx_bytes += skb->len; -+ catc->netdev->stats.tx_packets++; -+ } -+ -+ dev_kfree_skb(skb); -+ -+ return NETDEV_TX_OK; -+} -+ -+static void catc_tx_timeout(struct net_device *netdev) -+{ -+ struct catc *catc = netdev_priv(netdev); -+ -+ dev_warn(&netdev->dev, "Transmit timed out.\n"); -+ usb_unlink_urb(catc->tx_urb); -+} -+ -+/* -+ * Control messages. -+ */ -+ -+static int catc_ctrl_msg(struct catc *catc, u8 dir, u8 request, u16 value, u16 index, void *buf, int len) -+{ -+ int retval = usb_control_msg(catc->usbdev, -+ dir ? usb_rcvctrlpipe(catc->usbdev, 0) : usb_sndctrlpipe(catc->usbdev, 0), -+ request, 0x40 | dir, value, index, buf, len, 1000); -+ return retval < 0 ? retval : 0; -+} -+ -+static void catc_ctrl_run(struct catc *catc) -+{ -+ struct ctrl_queue *q = catc->ctrl_queue + catc->ctrl_tail; -+ struct usb_device *usbdev = catc->usbdev; -+ struct urb *urb = catc->ctrl_urb; -+ struct usb_ctrlrequest *dr = &catc->ctrl_dr; -+ int status; -+ -+ dr->bRequest = q->request; -+ dr->bRequestType = 0x40 | q->dir; -+ dr->wValue = cpu_to_le16(q->value); -+ dr->wIndex = cpu_to_le16(q->index); -+ dr->wLength = cpu_to_le16(q->len); -+ -+ urb->pipe = q->dir ? usb_rcvctrlpipe(usbdev, 0) : usb_sndctrlpipe(usbdev, 0); -+ urb->transfer_buffer_length = q->len; -+ urb->transfer_buffer = catc->ctrl_buf; -+ urb->setup_packet = (void *) dr; -+ urb->dev = usbdev; -+ -+ if (!q->dir && q->buf && q->len) -+ memcpy(catc->ctrl_buf, q->buf, q->len); -+ -+ if ((status = usb_submit_urb(catc->ctrl_urb, GFP_ATOMIC))) -+ dev_err(&catc->usbdev->dev, "submit(ctrl_urb) status %d\n", -+ status); -+} -+ -+static void catc_ctrl_done(struct urb *urb) -+{ -+ struct catc *catc = urb->context; -+ struct ctrl_queue *q; -+ unsigned long flags; -+ int status = urb->status; -+ -+ if (status) -+ dev_dbg(&urb->dev->dev, "ctrl_done, status %d, len %d.\n", -+ status, urb->actual_length); -+ -+ spin_lock_irqsave(&catc->ctrl_lock, flags); -+ -+ q = catc->ctrl_queue + catc->ctrl_tail; -+ -+ if (q->dir) { -+ if (q->buf && q->len) -+ memcpy(q->buf, catc->ctrl_buf, q->len); -+ else -+ q->buf = catc->ctrl_buf; -+ } -+ -+ if (q->callback) -+ q->callback(catc, q); -+ -+ catc->ctrl_tail = (catc->ctrl_tail + 1) & (CTRL_QUEUE - 1); -+ -+ if (catc->ctrl_head != catc->ctrl_tail) -+ catc_ctrl_run(catc); -+ else -+ clear_bit(CTRL_RUNNING, &catc->flags); -+ -+ spin_unlock_irqrestore(&catc->ctrl_lock, flags); -+} -+ -+static int catc_ctrl_async(struct catc *catc, u8 dir, u8 request, u16 value, -+ u16 index, void *buf, int len, void (*callback)(struct catc *catc, struct ctrl_queue *q)) -+{ -+ struct ctrl_queue *q; -+ int retval = 0; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&catc->ctrl_lock, flags); -+ -+ q = catc->ctrl_queue + catc->ctrl_head; -+ -+ q->dir = dir; -+ q->request = request; -+ q->value = value; -+ q->index = index; -+ q->buf = buf; -+ q->len = len; -+ q->callback = callback; -+ -+ catc->ctrl_head = (catc->ctrl_head + 1) & (CTRL_QUEUE - 1); -+ -+ if (catc->ctrl_head == catc->ctrl_tail) { -+ dev_err(&catc->usbdev->dev, "ctrl queue full\n"); -+ catc->ctrl_tail = (catc->ctrl_tail + 1) & (CTRL_QUEUE - 1); -+ retval = -1; -+ } -+ -+ if (!test_and_set_bit(CTRL_RUNNING, &catc->flags)) -+ catc_ctrl_run(catc); -+ -+ spin_unlock_irqrestore(&catc->ctrl_lock, flags); -+ -+ return retval; -+} -+ -+/* -+ * Statistics. -+ */ -+ -+static void catc_stats_done(struct catc *catc, struct ctrl_queue *q) -+{ -+ int index = q->index - EthStats; -+ u16 data, last; -+ -+ catc->stats_buf[index] = *((char *)q->buf); -+ -+ if (index & 1) -+ return; -+ -+ data = ((u16)catc->stats_buf[index] << 8) | catc->stats_buf[index + 1]; -+ last = catc->stats_vals[index >> 1]; -+ -+ switch (index) { -+ case TxSingleColl: -+ case TxMultiColl: -+ catc->netdev->stats.collisions += data - last; -+ break; -+ case TxExcessColl: -+ catc->netdev->stats.tx_aborted_errors += data - last; -+ catc->netdev->stats.tx_errors += data - last; -+ break; -+ case RxFramErr: -+ catc->netdev->stats.rx_frame_errors += data - last; -+ catc->netdev->stats.rx_errors += data - last; -+ break; -+ } -+ -+ catc->stats_vals[index >> 1] = data; -+} -+ -+static void catc_stats_timer(unsigned long data) -+{ -+ struct catc *catc = (void *) data; -+ int i; -+ -+ for (i = 0; i < 8; i++) -+ catc_get_reg_async(catc, EthStats + 7 - i, catc_stats_done); -+ -+ mod_timer(&catc->timer, jiffies + STATS_UPDATE); -+} -+ -+/* -+ * Receive modes. Broadcast, Multicast, Promisc. -+ */ -+ -+static void catc_multicast(unsigned char *addr, u8 *multicast) -+{ -+ u32 crc; -+ -+ crc = ether_crc_le(6, addr); -+ multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7); -+} -+ -+static void catc_set_multicast_list(struct net_device *netdev) -+{ -+ struct catc *catc = netdev_priv(netdev); -+ struct netdev_hw_addr *ha; -+ u8 broadcast[ETH_ALEN]; -+ u8 rx = RxEnable | RxPolarity | RxMultiCast; -+ -+ memset(broadcast, 0xff, ETH_ALEN); -+ memset(catc->multicast, 0, 64); -+ -+ catc_multicast(broadcast, catc->multicast); -+ catc_multicast(netdev->dev_addr, catc->multicast); -+ -+ if (netdev->flags & IFF_PROMISC) { -+ memset(catc->multicast, 0xff, 64); -+ rx |= (!catc->is_f5u011) ? RxPromisc : AltRxPromisc; -+ } -+ -+ if (netdev->flags & IFF_ALLMULTI) { -+ memset(catc->multicast, 0xff, 64); -+ } else { -+ netdev_for_each_mc_addr(ha, netdev) { -+ u32 crc = ether_crc_le(6, ha->addr); -+ if (!catc->is_f5u011) { -+ catc->multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7); -+ } else { -+ catc->multicast[7-(crc >> 29)] |= 1 << ((crc >> 26) & 7); -+ } -+ } -+ } -+ if (!catc->is_f5u011) { -+ catc_set_reg_async(catc, RxUnit, rx); -+ catc_write_mem_async(catc, 0xfa80, catc->multicast, 64); -+ } else { -+ f5u011_mchash_async(catc, catc->multicast); -+ if (catc->rxmode[0] != rx) { -+ catc->rxmode[0] = rx; -+ netdev_dbg(catc->netdev, -+ "Setting RX mode to %2.2X %2.2X\n", -+ catc->rxmode[0], catc->rxmode[1]); -+ f5u011_rxmode_async(catc, catc->rxmode); -+ } -+ } -+} -+ -+static void catc_get_drvinfo(struct net_device *dev, -+ struct ethtool_drvinfo *info) -+{ -+ struct catc *catc = netdev_priv(dev); -+ strlcpy(info->driver, driver_name, sizeof(info->driver)); -+ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); -+ usb_make_path(catc->usbdev, info->bus_info, sizeof(info->bus_info)); -+} -+ -+static int catc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) -+{ -+ struct catc *catc = netdev_priv(dev); -+ if (!catc->is_f5u011) -+ return -EOPNOTSUPP; -+ -+ cmd->supported = SUPPORTED_10baseT_Half | SUPPORTED_TP; -+ cmd->advertising = ADVERTISED_10baseT_Half | ADVERTISED_TP; -+ ethtool_cmd_speed_set(cmd, SPEED_10); -+ cmd->duplex = DUPLEX_HALF; -+ cmd->port = PORT_TP; -+ cmd->phy_address = 0; -+ cmd->transceiver = XCVR_INTERNAL; -+ cmd->autoneg = AUTONEG_DISABLE; -+ cmd->maxtxpkt = 1; -+ cmd->maxrxpkt = 1; -+ return 0; -+} -+ -+static const struct ethtool_ops ops = { -+ .get_drvinfo = catc_get_drvinfo, -+ .get_settings = catc_get_settings, -+ .get_link = ethtool_op_get_link -+}; -+ -+/* -+ * Open, close. -+ */ -+ -+static int catc_open(struct net_device *netdev) -+{ -+ struct catc *catc = netdev_priv(netdev); -+ int status; -+ -+ catc->irq_urb->dev = catc->usbdev; -+ if ((status = usb_submit_urb(catc->irq_urb, GFP_KERNEL)) < 0) { -+ dev_err(&catc->usbdev->dev, "submit(irq_urb) status %d\n", -+ status); -+ return -1; -+ } -+ -+ netif_start_queue(netdev); -+ -+ if (!catc->is_f5u011) -+ mod_timer(&catc->timer, jiffies + STATS_UPDATE); -+ -+ return 0; -+} -+ -+static int catc_stop(struct net_device *netdev) -+{ -+ struct catc *catc = netdev_priv(netdev); -+ -+ netif_stop_queue(netdev); -+ -+ if (!catc->is_f5u011) -+ del_timer_sync(&catc->timer); -+ -+ usb_kill_urb(catc->rx_urb); -+ usb_kill_urb(catc->tx_urb); -+ usb_kill_urb(catc->irq_urb); -+ usb_kill_urb(catc->ctrl_urb); -+ -+ return 0; -+} -+ -+static const struct net_device_ops catc_netdev_ops = { -+ .ndo_open = catc_open, -+ .ndo_stop = catc_stop, -+ .ndo_start_xmit = catc_start_xmit, -+ -+ .ndo_tx_timeout = catc_tx_timeout, -+ .ndo_set_rx_mode = catc_set_multicast_list, -+ .ndo_change_mtu = eth_change_mtu, -+ .ndo_set_mac_address = eth_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+}; -+ -+/* -+ * USB probe, disconnect. -+ */ -+ -+static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id) -+{ -+ struct device *dev = &intf->dev; -+ struct usb_device *usbdev = interface_to_usbdev(intf); -+ struct net_device *netdev; -+ struct catc *catc; -+ u8 broadcast[ETH_ALEN]; -+ int i, pktsz; -+ -+ if (usb_set_interface(usbdev, -+ intf->altsetting->desc.bInterfaceNumber, 1)) { -+ dev_err(dev, "Can't set altsetting 1.\n"); -+ return -EIO; -+ } -+ -+ netdev = alloc_etherdev(sizeof(struct catc)); -+ if (!netdev) -+ return -ENOMEM; -+ -+ catc = netdev_priv(netdev); -+ -+ netdev->netdev_ops = &catc_netdev_ops; -+ netdev->watchdog_timeo = TX_TIMEOUT; -+ netdev->ethtool_ops = &ops; -+ -+ catc->usbdev = usbdev; -+ catc->netdev = netdev; -+ -+ spin_lock_init(&catc->tx_lock); -+ spin_lock_init(&catc->ctrl_lock); -+ -+ init_timer(&catc->timer); -+ catc->timer.data = (long) catc; -+ catc->timer.function = catc_stats_timer; -+ -+ catc->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL); -+ catc->tx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ catc->rx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ catc->irq_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if ((!catc->ctrl_urb) || (!catc->tx_urb) || -+ (!catc->rx_urb) || (!catc->irq_urb)) { -+ dev_err(&intf->dev, "No free urbs available.\n"); -+ usb_free_urb(catc->ctrl_urb); -+ usb_free_urb(catc->tx_urb); -+ usb_free_urb(catc->rx_urb); -+ usb_free_urb(catc->irq_urb); -+ free_netdev(netdev); -+ return -ENOMEM; -+ } -+ -+ /* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */ -+ if (le16_to_cpu(usbdev->descriptor.idVendor) == 0x0423 && -+ le16_to_cpu(usbdev->descriptor.idProduct) == 0xa && -+ le16_to_cpu(catc->usbdev->descriptor.bcdDevice) == 0x0130) { -+ dev_dbg(dev, "Testing for f5u011\n"); -+ catc->is_f5u011 = 1; -+ atomic_set(&catc->recq_sz, 0); -+ pktsz = RX_PKT_SZ; -+ } else { -+ pktsz = RX_MAX_BURST * (PKT_SZ + 2); -+ } -+ -+ usb_fill_control_urb(catc->ctrl_urb, usbdev, usb_sndctrlpipe(usbdev, 0), -+ NULL, NULL, 0, catc_ctrl_done, catc); -+ -+ usb_fill_bulk_urb(catc->tx_urb, usbdev, usb_sndbulkpipe(usbdev, 1), -+ NULL, 0, catc_tx_done, catc); -+ -+ usb_fill_bulk_urb(catc->rx_urb, usbdev, usb_rcvbulkpipe(usbdev, 1), -+ catc->rx_buf, pktsz, catc_rx_done, catc); -+ -+ usb_fill_int_urb(catc->irq_urb, usbdev, usb_rcvintpipe(usbdev, 2), -+ catc->irq_buf, 2, catc_irq_done, catc, 1); -+ -+ if (!catc->is_f5u011) { -+ dev_dbg(dev, "Checking memory size\n"); -+ -+ i = 0x12345678; -+ catc_write_mem(catc, 0x7a80, &i, 4); -+ i = 0x87654321; -+ catc_write_mem(catc, 0xfa80, &i, 4); -+ catc_read_mem(catc, 0x7a80, &i, 4); -+ -+ switch (i) { -+ case 0x12345678: -+ catc_set_reg(catc, TxBufCount, 8); -+ catc_set_reg(catc, RxBufCount, 32); -+ dev_dbg(dev, "64k Memory\n"); -+ break; -+ default: -+ dev_warn(&intf->dev, -+ "Couldn't detect memory size, assuming 32k\n"); -+ case 0x87654321: -+ catc_set_reg(catc, TxBufCount, 4); -+ catc_set_reg(catc, RxBufCount, 16); -+ dev_dbg(dev, "32k Memory\n"); -+ break; -+ } -+ -+ dev_dbg(dev, "Getting MAC from SEEROM.\n"); -+ -+ catc_get_mac(catc, netdev->dev_addr); -+ -+ dev_dbg(dev, "Setting MAC into registers.\n"); -+ -+ for (i = 0; i < 6; i++) -+ catc_set_reg(catc, StationAddr0 - i, netdev->dev_addr[i]); -+ -+ dev_dbg(dev, "Filling the multicast list.\n"); -+ -+ memset(broadcast, 0xff, ETH_ALEN); -+ catc_multicast(broadcast, catc->multicast); -+ catc_multicast(netdev->dev_addr, catc->multicast); -+ catc_write_mem(catc, 0xfa80, catc->multicast, 64); -+ -+ dev_dbg(dev, "Clearing error counters.\n"); -+ -+ for (i = 0; i < 8; i++) -+ catc_set_reg(catc, EthStats + i, 0); -+ catc->last_stats = jiffies; -+ -+ dev_dbg(dev, "Enabling.\n"); -+ -+ catc_set_reg(catc, MaxBurst, RX_MAX_BURST); -+ catc_set_reg(catc, OpModes, OpTxMerge | OpRxMerge | OpLenInclude | Op3MemWaits); -+ catc_set_reg(catc, LEDCtrl, LEDLink); -+ catc_set_reg(catc, RxUnit, RxEnable | RxPolarity | RxMultiCast); -+ } else { -+ dev_dbg(dev, "Performing reset\n"); -+ catc_reset(catc); -+ catc_get_mac(catc, netdev->dev_addr); -+ -+ dev_dbg(dev, "Setting RX Mode\n"); -+ catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast; -+ catc->rxmode[1] = 0; -+ f5u011_rxmode(catc, catc->rxmode); -+ } -+ dev_dbg(dev, "Init done.\n"); -+ printk(KERN_INFO "%s: %s USB Ethernet at usb-%s-%s, %pM.\n", -+ netdev->name, (catc->is_f5u011) ? "Belkin F5U011" : "CATC EL1210A NetMate", -+ usbdev->bus->bus_name, usbdev->devpath, netdev->dev_addr); -+ usb_set_intfdata(intf, catc); -+ -+ SET_NETDEV_DEV(netdev, &intf->dev); -+ if (register_netdev(netdev) != 0) { -+ usb_set_intfdata(intf, NULL); -+ usb_free_urb(catc->ctrl_urb); -+ usb_free_urb(catc->tx_urb); -+ usb_free_urb(catc->rx_urb); -+ usb_free_urb(catc->irq_urb); -+ free_netdev(netdev); -+ return -EIO; -+ } -+ return 0; -+} -+ -+static void catc_disconnect(struct usb_interface *intf) -+{ -+ struct catc *catc = usb_get_intfdata(intf); -+ -+ usb_set_intfdata(intf, NULL); -+ if (catc) { -+ unregister_netdev(catc->netdev); -+ usb_free_urb(catc->ctrl_urb); -+ usb_free_urb(catc->tx_urb); -+ usb_free_urb(catc->rx_urb); -+ usb_free_urb(catc->irq_urb); -+ free_netdev(catc->netdev); -+ } -+} -+ -+/* -+ * Module functions and tables. -+ */ -+ -+static struct usb_device_id catc_id_table [] = { -+ { USB_DEVICE(0x0423, 0xa) }, /* CATC Netmate, Belkin F5U011 */ -+ { USB_DEVICE(0x0423, 0xc) }, /* CATC Netmate II, Belkin F5U111 */ -+ { USB_DEVICE(0x08d1, 0x1) }, /* smartBridges smartNIC */ -+ { } -+}; -+ -+MODULE_DEVICE_TABLE(usb, catc_id_table); -+ -+static struct usb_driver catc_driver = { -+ .name = driver_name, -+ .probe = catc_probe, -+ .disconnect = catc_disconnect, -+ .id_table = catc_id_table, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(catc_driver); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/cdc_eem.c backports-3.18.1-1/drivers/net/usb/cdc_eem.c ---- backports-3.18.1-1.org/drivers/net/usb/cdc_eem.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/cdc_eem.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,381 @@ -+/* -+ * USB CDC EEM network interface driver -+ * Copyright (C) 2009 Oberthur Technologies -+ * by Omar Laazimani, Olivier Condemine -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ctype.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/crc32.h> -+#include <linux/usb/cdc.h> -+#include <linux/usb/usbnet.h> -+#include <linux/gfp.h> -+#include <linux/if_vlan.h> -+ -+ -+/* -+ * This driver is an implementation of the CDC "Ethernet Emulation -+ * Model" (EEM) specification, which encapsulates Ethernet frames -+ * for transport over USB using a simpler USB device model than the -+ * previous CDC "Ethernet Control Model" (ECM, or "CDC Ethernet"). -+ * -+ * For details, see www.usb.org/developers/devclass_docs/CDC_EEM10.pdf -+ * -+ * This version has been tested with GIGAntIC WuaoW SIM Smart Card on 2.6.24, -+ * 2.6.27 and 2.6.30rc2 kernel. -+ * It has also been validated on Openmoko Om 2008.12 (based on 2.6.24 kernel). -+ * build on 23-April-2009 -+ */ -+ -+#define EEM_HEAD 2 /* 2 byte header */ -+ -+/*-------------------------------------------------------------------------*/ -+ -+static void eem_linkcmd_complete(struct urb *urb) -+{ -+ dev_kfree_skb(urb->context); -+ usb_free_urb(urb); -+} -+ -+static void eem_linkcmd(struct usbnet *dev, struct sk_buff *skb) -+{ -+ struct urb *urb; -+ int status; -+ -+ urb = usb_alloc_urb(0, GFP_ATOMIC); -+ if (!urb) -+ goto fail; -+ -+ usb_fill_bulk_urb(urb, dev->udev, dev->out, -+ skb->data, skb->len, eem_linkcmd_complete, skb); -+ -+ status = usb_submit_urb(urb, GFP_ATOMIC); -+ if (status) { -+ usb_free_urb(urb); -+fail: -+ dev_kfree_skb(skb); -+ netdev_warn(dev->net, "link cmd failure\n"); -+ return; -+ } -+} -+ -+static int eem_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int status = 0; -+ -+ status = usbnet_get_endpoints(dev, intf); -+ if (status < 0) { -+ usb_set_intfdata(intf, NULL); -+ usb_driver_release_interface(driver_of(intf), intf); -+ return status; -+ } -+ -+ /* no jumbogram (16K) support for now */ -+ -+ dev->net->hard_header_len += EEM_HEAD + ETH_FCS_LEN + VLAN_HLEN; -+ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; -+ -+ return 0; -+} -+ -+/* -+ * EEM permits packing multiple Ethernet frames into USB transfers -+ * (a "bundle"), but for TX we don't try to do that. -+ */ -+static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb, -+ gfp_t flags) -+{ -+ struct sk_buff *skb2 = NULL; -+ u16 len = skb->len; -+ u32 crc = 0; -+ int padlen = 0; -+ -+ /* When ((len + EEM_HEAD + ETH_FCS_LEN) % dev->maxpacket) is -+ * zero, stick two bytes of zero length EEM packet on the end. -+ * Else the framework would add invalid single byte padding, -+ * since it can't know whether ZLPs will be handled right by -+ * all the relevant hardware and software. -+ */ -+ if (!((len + EEM_HEAD + ETH_FCS_LEN) % dev->maxpacket)) -+ padlen += 2; -+ -+ if (!skb_cloned(skb)) { -+ int headroom = skb_headroom(skb); -+ int tailroom = skb_tailroom(skb); -+ -+ if ((tailroom >= ETH_FCS_LEN + padlen) && -+ (headroom >= EEM_HEAD)) -+ goto done; -+ -+ if ((headroom + tailroom) -+ > (EEM_HEAD + ETH_FCS_LEN + padlen)) { -+ skb->data = memmove(skb->head + -+ EEM_HEAD, -+ skb->data, -+ skb->len); -+ skb_set_tail_pointer(skb, len); -+ goto done; -+ } -+ } -+ -+ skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags); -+ if (!skb2) -+ return NULL; -+ -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ -+done: -+ /* we don't use the "no Ethernet CRC" option */ -+ crc = crc32_le(~0, skb->data, skb->len); -+ crc = ~crc; -+ -+ put_unaligned_le32(crc, skb_put(skb, 4)); -+ -+ /* EEM packet header format: -+ * b0..13: length of ethernet frame -+ * b14: bmCRC (1 == valid Ethernet CRC) -+ * b15: bmType (0 == data) -+ */ -+ len = skb->len; -+ put_unaligned_le16(BIT(14) | len, skb_push(skb, 2)); -+ -+ /* Bundle a zero length EEM packet if needed */ -+ if (padlen) -+ put_unaligned_le16(0, skb_put(skb, 2)); -+ -+ return skb; -+} -+ -+static int eem_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ /* -+ * Our task here is to strip off framing, leaving skb with one -+ * data frame for the usbnet framework code to process. But we -+ * may have received multiple EEM payloads, or command payloads. -+ * So we must process _everything_ as if it's a header, except -+ * maybe the last data payload -+ * -+ * REVISIT the framework needs updating so that when we consume -+ * all payloads (the last or only message was a command, or a -+ * zero length EEM packet) that is not accounted as an rx_error. -+ */ -+ do { -+ struct sk_buff *skb2 = NULL; -+ u16 header; -+ u16 len = 0; -+ -+ /* incomplete EEM header? */ -+ if (skb->len < EEM_HEAD) -+ return 0; -+ -+ /* -+ * EEM packet header format: -+ * b0..14: EEM type dependent (Data or Command) -+ * b15: bmType -+ */ -+ header = get_unaligned_le16(skb->data); -+ skb_pull(skb, EEM_HEAD); -+ -+ /* -+ * The bmType bit helps to denote when EEM -+ * packet is data or command : -+ * bmType = 0 : EEM data payload -+ * bmType = 1 : EEM (link) command -+ */ -+ if (header & BIT(15)) { -+ u16 bmEEMCmd; -+ -+ /* -+ * EEM (link) command packet: -+ * b0..10: bmEEMCmdParam -+ * b11..13: bmEEMCmd -+ * b14: bmReserved (must be 0) -+ * b15: 1 (EEM command) -+ */ -+ if (header & BIT(14)) { -+ netdev_dbg(dev->net, "reserved command %04x\n", -+ header); -+ continue; -+ } -+ -+ bmEEMCmd = (header >> 11) & 0x7; -+ switch (bmEEMCmd) { -+ -+ /* Responding to echo requests is mandatory. */ -+ case 0: /* Echo command */ -+ len = header & 0x7FF; -+ -+ /* bogus command? */ -+ if (skb->len < len) -+ return 0; -+ -+ skb2 = skb_clone(skb, GFP_ATOMIC); -+ if (unlikely(!skb2)) -+ goto next; -+ skb_trim(skb2, len); -+ put_unaligned_le16(BIT(15) | (1 << 11) | len, -+ skb_push(skb2, 2)); -+ eem_linkcmd(dev, skb2); -+ break; -+ -+ /* -+ * Host may choose to ignore hints. -+ * - suspend: peripheral ready to suspend -+ * - response: suggest N millisec polling -+ * - response complete: suggest N sec polling -+ * -+ * Suspend is reported and maybe heeded. -+ */ -+ case 2: /* Suspend hint */ -+ usbnet_device_suggests_idle(dev); -+ continue; -+ case 3: /* Response hint */ -+ case 4: /* Response complete hint */ -+ continue; -+ -+ /* -+ * Hosts should never receive host-to-peripheral -+ * or reserved command codes; or responses to an -+ * echo command we didn't send. -+ */ -+ case 1: /* Echo response */ -+ case 5: /* Tickle */ -+ default: /* reserved */ -+ netdev_warn(dev->net, -+ "unexpected link command %d\n", -+ bmEEMCmd); -+ continue; -+ } -+ -+ } else { -+ u32 crc, crc2; -+ int is_last; -+ -+ /* zero length EEM packet? */ -+ if (header == 0) -+ continue; -+ -+ /* -+ * EEM data packet header : -+ * b0..13: length of ethernet frame -+ * b14: bmCRC -+ * b15: 0 (EEM data) -+ */ -+ len = header & 0x3FFF; -+ -+ /* bogus EEM payload? */ -+ if (skb->len < len) -+ return 0; -+ -+ /* bogus ethernet frame? */ -+ if (len < (ETH_HLEN + ETH_FCS_LEN)) -+ goto next; -+ -+ /* -+ * Treat the last payload differently: framework -+ * code expects our "fixup" to have stripped off -+ * headers, so "skb" is a data packet (or error). -+ * Else if it's not the last payload, keep "skb" -+ * for further processing. -+ */ -+ is_last = (len == skb->len); -+ if (is_last) -+ skb2 = skb; -+ else { -+ skb2 = skb_clone(skb, GFP_ATOMIC); -+ if (unlikely(!skb2)) -+ return 0; -+ } -+ -+ /* -+ * The bmCRC helps to denote when the CRC field in -+ * the Ethernet frame contains a calculated CRC: -+ * bmCRC = 1 : CRC is calculated -+ * bmCRC = 0 : CRC = 0xDEADBEEF -+ */ -+ if (header & BIT(14)) { -+ crc = get_unaligned_le32(skb2->data -+ + len - ETH_FCS_LEN); -+ crc2 = ~crc32_le(~0, skb2->data, skb2->len -+ - ETH_FCS_LEN); -+ } else { -+ crc = get_unaligned_be32(skb2->data -+ + len - ETH_FCS_LEN); -+ crc2 = 0xdeadbeef; -+ } -+ skb_trim(skb2, len - ETH_FCS_LEN); -+ -+ if (is_last) -+ return crc == crc2; -+ -+ if (unlikely(crc != crc2)) { -+ dev->net->stats.rx_errors++; -+ dev_kfree_skb_any(skb2); -+ } else -+ usbnet_skb_return(dev, skb2); -+ } -+ -+next: -+ skb_pull(skb, len); -+ } while (skb->len); -+ -+ return 1; -+} -+ -+static const struct driver_info eem_info = { -+ .description = "CDC EEM Device", -+ .flags = FLAG_ETHER | FLAG_POINTTOPOINT, -+ .bind = eem_bind, -+ .rx_fixup = eem_rx_fixup, -+ .tx_fixup = eem_tx_fixup, -+}; -+ -+/*-------------------------------------------------------------------------*/ -+ -+static const struct usb_device_id products[] = { -+{ -+ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_EEM, -+ USB_CDC_PROTO_EEM), -+ .driver_info = (unsigned long) &eem_info, -+}, -+{ -+ /* EMPTY == end of list */ -+}, -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver eem_driver = { -+ .name = "cdc_eem", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(eem_driver); -+ -+MODULE_AUTHOR("Omar Laazimani omar.oberthur@gmail.com"); -+MODULE_DESCRIPTION("USB CDC EEM"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/cdc-phonet.c backports-3.18.1-1/drivers/net/usb/cdc-phonet.c ---- backports-3.18.1-1.org/drivers/net/usb/cdc-phonet.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/cdc-phonet.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,466 @@ -+/* -+ * phonet.c -- USB CDC Phonet host driver -+ * -+ * Copyright (C) 2008-2009 Nokia Corporation. All rights reserved. -+ * -+ * Author: Rémi Denis-Courmont -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA -+ * 02110-1301 USA -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/mm.h> -+#include <linux/module.h> -+#include <linux/gfp.h> -+#include <linux/usb.h> -+#include <linux/usb/cdc.h> -+#include <linux/netdevice.h> -+#include <linux/if_arp.h> -+#include <linux/if_phonet.h> -+#include <linux/phonet.h> -+ -+#define PN_MEDIA_USB 0x1B -+ -+static const unsigned rxq_size = 17; -+ -+struct usbpn_dev { -+ struct net_device *dev; -+ -+ struct usb_interface *intf, *data_intf; -+ struct usb_device *usb; -+ unsigned int tx_pipe, rx_pipe; -+ u8 active_setting; -+ u8 disconnected; -+ -+ unsigned tx_queue; -+ spinlock_t tx_lock; -+ -+ spinlock_t rx_lock; -+ struct sk_buff *rx_skb; -+ struct urb *urbs[0]; -+}; -+ -+static void tx_complete(struct urb *req); -+static void rx_complete(struct urb *req); -+ -+/* -+ * Network device callbacks -+ */ -+static netdev_tx_t usbpn_xmit(struct sk_buff *skb, struct net_device *dev) -+{ -+ struct usbpn_dev *pnd = netdev_priv(dev); -+ struct urb *req = NULL; -+ unsigned long flags; -+ int err; -+ -+ if (skb->protocol != htons(ETH_P_PHONET)) -+ goto drop; -+ -+ req = usb_alloc_urb(0, GFP_ATOMIC); -+ if (!req) -+ goto drop; -+ usb_fill_bulk_urb(req, pnd->usb, pnd->tx_pipe, skb->data, skb->len, -+ tx_complete, skb); -+ req->transfer_flags = URB_ZERO_PACKET; -+ err = usb_submit_urb(req, GFP_ATOMIC); -+ if (err) { -+ usb_free_urb(req); -+ goto drop; -+ } -+ -+ spin_lock_irqsave(&pnd->tx_lock, flags); -+ pnd->tx_queue++; -+ if (pnd->tx_queue >= dev->tx_queue_len) -+ netif_stop_queue(dev); -+ spin_unlock_irqrestore(&pnd->tx_lock, flags); -+ return NETDEV_TX_OK; -+ -+drop: -+ dev_kfree_skb(skb); -+ dev->stats.tx_dropped++; -+ return NETDEV_TX_OK; -+} -+ -+static void tx_complete(struct urb *req) -+{ -+ struct sk_buff *skb = req->context; -+ struct net_device *dev = skb->dev; -+ struct usbpn_dev *pnd = netdev_priv(dev); -+ int status = req->status; -+ -+ switch (status) { -+ case 0: -+ dev->stats.tx_bytes += skb->len; -+ break; -+ -+ case -ENOENT: -+ case -ECONNRESET: -+ case -ESHUTDOWN: -+ dev->stats.tx_aborted_errors++; -+ default: -+ dev->stats.tx_errors++; -+ dev_dbg(&dev->dev, "TX error (%d)\n", status); -+ } -+ dev->stats.tx_packets++; -+ -+ spin_lock(&pnd->tx_lock); -+ pnd->tx_queue--; -+ netif_wake_queue(dev); -+ spin_unlock(&pnd->tx_lock); -+ -+ dev_kfree_skb_any(skb); -+ usb_free_urb(req); -+} -+ -+static int rx_submit(struct usbpn_dev *pnd, struct urb *req, gfp_t gfp_flags) -+{ -+ struct net_device *dev = pnd->dev; -+ struct page *page; -+ int err; -+ -+ page = __skb_alloc_page(gfp_flags | __GFP_NOMEMALLOC, NULL); -+ if (!page) -+ return -ENOMEM; -+ -+ usb_fill_bulk_urb(req, pnd->usb, pnd->rx_pipe, page_address(page), -+ PAGE_SIZE, rx_complete, dev); -+ req->transfer_flags = 0; -+ err = usb_submit_urb(req, gfp_flags); -+ if (unlikely(err)) { -+ dev_dbg(&dev->dev, "RX submit error (%d)\n", err); -+ put_page(page); -+ } -+ return err; -+} -+ -+static void rx_complete(struct urb *req) -+{ -+ struct net_device *dev = req->context; -+ struct usbpn_dev *pnd = netdev_priv(dev); -+ struct page *page = virt_to_page(req->transfer_buffer); -+ struct sk_buff *skb; -+ unsigned long flags; -+ int status = req->status; -+ -+ switch (status) { -+ case 0: -+ spin_lock_irqsave(&pnd->rx_lock, flags); -+ skb = pnd->rx_skb; -+ if (!skb) { -+ skb = pnd->rx_skb = netdev_alloc_skb(dev, 12); -+ if (likely(skb)) { -+ /* Can't use pskb_pull() on page in IRQ */ -+ memcpy(skb_put(skb, 1), page_address(page), 1); -+ skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, -+ page, 1, req->actual_length, -+ PAGE_SIZE); -+ page = NULL; -+ } -+ } else { -+ skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, -+ page, 0, req->actual_length, -+ PAGE_SIZE); -+ page = NULL; -+ } -+ if (req->actual_length < PAGE_SIZE) -+ pnd->rx_skb = NULL; /* Last fragment */ -+ else -+ skb = NULL; -+ spin_unlock_irqrestore(&pnd->rx_lock, flags); -+ if (skb) { -+ skb->protocol = htons(ETH_P_PHONET); -+ skb_reset_mac_header(skb); -+ __skb_pull(skb, 1); -+ skb->dev = dev; -+ dev->stats.rx_packets++; -+ dev->stats.rx_bytes += skb->len; -+ -+ netif_rx(skb); -+ } -+ goto resubmit; -+ -+ case -ENOENT: -+ case -ECONNRESET: -+ case -ESHUTDOWN: -+ req = NULL; -+ break; -+ -+ case -EOVERFLOW: -+ dev->stats.rx_over_errors++; -+ dev_dbg(&dev->dev, "RX overflow\n"); -+ break; -+ -+ case -EILSEQ: -+ dev->stats.rx_crc_errors++; -+ break; -+ } -+ -+ dev->stats.rx_errors++; -+resubmit: -+ if (page) -+ put_page(page); -+ if (req) -+ rx_submit(pnd, req, GFP_ATOMIC | __GFP_COLD); -+} -+ -+static int usbpn_close(struct net_device *dev); -+ -+static int usbpn_open(struct net_device *dev) -+{ -+ struct usbpn_dev *pnd = netdev_priv(dev); -+ int err; -+ unsigned i; -+ unsigned num = pnd->data_intf->cur_altsetting->desc.bInterfaceNumber; -+ -+ err = usb_set_interface(pnd->usb, num, pnd->active_setting); -+ if (err) -+ return err; -+ -+ for (i = 0; i < rxq_size; i++) { -+ struct urb *req = usb_alloc_urb(0, GFP_KERNEL); -+ -+ if (!req || rx_submit(pnd, req, GFP_KERNEL | __GFP_COLD)) { -+ usb_free_urb(req); -+ usbpn_close(dev); -+ return -ENOMEM; -+ } -+ pnd->urbs[i] = req; -+ } -+ -+ netif_wake_queue(dev); -+ return 0; -+} -+ -+static int usbpn_close(struct net_device *dev) -+{ -+ struct usbpn_dev *pnd = netdev_priv(dev); -+ unsigned i; -+ unsigned num = pnd->data_intf->cur_altsetting->desc.bInterfaceNumber; -+ -+ netif_stop_queue(dev); -+ -+ for (i = 0; i < rxq_size; i++) { -+ struct urb *req = pnd->urbs[i]; -+ -+ if (!req) -+ continue; -+ usb_kill_urb(req); -+ usb_free_urb(req); -+ pnd->urbs[i] = NULL; -+ } -+ -+ return usb_set_interface(pnd->usb, num, !pnd->active_setting); -+} -+ -+static int usbpn_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -+{ -+ struct if_phonet_req *req = (struct if_phonet_req *)ifr; -+ -+ switch (cmd) { -+ case SIOCPNGAUTOCONF: -+ req->ifr_phonet_autoconf.device = PN_DEV_PC; -+ return 0; -+ } -+ return -ENOIOCTLCMD; -+} -+ -+static int usbpn_set_mtu(struct net_device *dev, int new_mtu) -+{ -+ if ((new_mtu < PHONET_MIN_MTU) || (new_mtu > PHONET_MAX_MTU)) -+ return -EINVAL; -+ -+ dev->mtu = new_mtu; -+ return 0; -+} -+ -+static const struct net_device_ops usbpn_ops = { -+ .ndo_open = usbpn_open, -+ .ndo_stop = usbpn_close, -+ .ndo_start_xmit = usbpn_xmit, -+ .ndo_do_ioctl = usbpn_ioctl, -+ .ndo_change_mtu = usbpn_set_mtu, -+}; -+ -+static void usbpn_setup(struct net_device *dev) -+{ -+ dev->features = 0; -+ dev->netdev_ops = &usbpn_ops, -+ dev->header_ops = &phonet_header_ops; -+ dev->type = ARPHRD_PHONET; -+ dev->flags = IFF_POINTOPOINT | IFF_NOARP; -+ dev->mtu = PHONET_MAX_MTU; -+ dev->hard_header_len = 1; -+ dev->dev_addr[0] = PN_MEDIA_USB; -+ dev->addr_len = 1; -+ dev->tx_queue_len = 3; -+ -+ dev->destructor = free_netdev; -+} -+ -+/* -+ * USB driver callbacks -+ */ -+static struct usb_device_id usbpn_ids[] = { -+ { -+ .match_flags = USB_DEVICE_ID_MATCH_VENDOR -+ | USB_DEVICE_ID_MATCH_INT_CLASS -+ | USB_DEVICE_ID_MATCH_INT_SUBCLASS, -+ .idVendor = 0x0421, /* Nokia */ -+ .bInterfaceClass = USB_CLASS_COMM, -+ .bInterfaceSubClass = 0xFE, -+ }, -+ { }, -+}; -+ -+MODULE_DEVICE_TABLE(usb, usbpn_ids); -+ -+static struct usb_driver usbpn_driver; -+ -+static int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *id) -+{ -+ static const char ifname[] = "usbpn%d"; -+ const struct usb_cdc_union_desc *union_header = NULL; -+ const struct usb_host_interface *data_desc; -+ struct usb_interface *data_intf; -+ struct usb_device *usbdev = interface_to_usbdev(intf); -+ struct net_device *dev; -+ struct usbpn_dev *pnd; -+ u8 *data; -+ int phonet = 0; -+ int len, err; -+ -+ data = intf->altsetting->extra; -+ len = intf->altsetting->extralen; -+ while (len >= 3) { -+ u8 dlen = data[0]; -+ if (dlen < 3) -+ return -EINVAL; -+ -+ /* bDescriptorType */ -+ if (data[1] == USB_DT_CS_INTERFACE) { -+ /* bDescriptorSubType */ -+ switch (data[2]) { -+ case USB_CDC_UNION_TYPE: -+ if (union_header || dlen < 5) -+ break; -+ union_header = -+ (struct usb_cdc_union_desc *)data; -+ break; -+ case 0xAB: -+ phonet = 1; -+ break; -+ } -+ } -+ data += dlen; -+ len -= dlen; -+ } -+ -+ if (!union_header || !phonet) -+ return -EINVAL; -+ -+ data_intf = usb_ifnum_to_if(usbdev, union_header->bSlaveInterface0); -+ if (data_intf == NULL) -+ return -ENODEV; -+ /* Data interface has one inactive and one active setting */ -+ if (data_intf->num_altsetting != 2) -+ return -EINVAL; -+ if (data_intf->altsetting[0].desc.bNumEndpoints == 0 && -+ data_intf->altsetting[1].desc.bNumEndpoints == 2) -+ data_desc = data_intf->altsetting + 1; -+ else -+ if (data_intf->altsetting[0].desc.bNumEndpoints == 2 && -+ data_intf->altsetting[1].desc.bNumEndpoints == 0) -+ data_desc = data_intf->altsetting; -+ else -+ return -EINVAL; -+ -+ dev = alloc_netdev(sizeof(*pnd) + sizeof(pnd->urbs[0]) * rxq_size, -+ ifname, NET_NAME_UNKNOWN, usbpn_setup); -+ if (!dev) -+ return -ENOMEM; -+ -+ pnd = netdev_priv(dev); -+ SET_NETDEV_DEV(dev, &intf->dev); -+ -+ pnd->dev = dev; -+ pnd->usb = usbdev; -+ pnd->intf = intf; -+ pnd->data_intf = data_intf; -+ spin_lock_init(&pnd->tx_lock); -+ spin_lock_init(&pnd->rx_lock); -+ /* Endpoints */ -+ if (usb_pipein(data_desc->endpoint[0].desc.bEndpointAddress)) { -+ pnd->rx_pipe = usb_rcvbulkpipe(usbdev, -+ data_desc->endpoint[0].desc.bEndpointAddress); -+ pnd->tx_pipe = usb_sndbulkpipe(usbdev, -+ data_desc->endpoint[1].desc.bEndpointAddress); -+ } else { -+ pnd->rx_pipe = usb_rcvbulkpipe(usbdev, -+ data_desc->endpoint[1].desc.bEndpointAddress); -+ pnd->tx_pipe = usb_sndbulkpipe(usbdev, -+ data_desc->endpoint[0].desc.bEndpointAddress); -+ } -+ pnd->active_setting = data_desc - data_intf->altsetting; -+ -+ err = usb_driver_claim_interface(&usbpn_driver, data_intf, pnd); -+ if (err) -+ goto out; -+ -+ /* Force inactive mode until the network device is brought UP */ -+ usb_set_interface(usbdev, union_header->bSlaveInterface0, -+ !pnd->active_setting); -+ usb_set_intfdata(intf, pnd); -+ -+ err = register_netdev(dev); -+ if (err) { -+ usb_driver_release_interface(&usbpn_driver, data_intf); -+ goto out; -+ } -+ -+ dev_dbg(&dev->dev, "USB CDC Phonet device found\n"); -+ return 0; -+ -+out: -+ usb_set_intfdata(intf, NULL); -+ free_netdev(dev); -+ return err; -+} -+ -+static void usbpn_disconnect(struct usb_interface *intf) -+{ -+ struct usbpn_dev *pnd = usb_get_intfdata(intf); -+ -+ if (pnd->disconnected) -+ return; -+ -+ pnd->disconnected = 1; -+ usb_driver_release_interface(&usbpn_driver, -+ (pnd->intf == intf) ? pnd->data_intf : pnd->intf); -+ unregister_netdev(pnd->dev); -+} -+ -+static struct usb_driver usbpn_driver = { -+ .name = "cdc_phonet", -+ .probe = usbpn_probe, -+ .disconnect = usbpn_disconnect, -+ .id_table = usbpn_ids, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(usbpn_driver); -+ -+MODULE_AUTHOR("Remi Denis-Courmont"); -+MODULE_DESCRIPTION("USB CDC Phonet host interface"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/cdc_subset.c backports-3.18.1-1/drivers/net/usb/cdc_subset.c ---- backports-3.18.1-1.org/drivers/net/usb/cdc_subset.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/cdc_subset.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,369 @@ -+/* -+ * Simple "CDC Subset" USB Networking Links -+ * Copyright (C) 2000-2005 by David Brownell -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include <linux/module.h> -+#include <linux/kmod.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/usb/usbnet.h> -+ -+ -+/* -+ * This supports simple USB network links that don't require any special -+ * framing or hardware control operations. The protocol used here is a -+ * strict subset of CDC Ethernet, with three basic differences reflecting -+ * the goal that almost any hardware should run it: -+ * -+ * - Minimal runtime control: one interface, no altsettings, and -+ * no vendor or class specific control requests. If a device is -+ * configured, it is allowed to exchange packets with the host. -+ * Fancier models would mean not working on some hardware. -+ * -+ * - Minimal manufacturing control: no IEEE "Organizationally -+ * Unique ID" required, or an EEPROMs to store one. Each host uses -+ * one random "locally assigned" Ethernet address instead, which can -+ * of course be overridden using standard tools like "ifconfig". -+ * (With 2^46 such addresses, same-net collisions are quite rare.) -+ * -+ * - There is no additional framing data for USB. Packets are written -+ * exactly as in CDC Ethernet, starting with an Ethernet header and -+ * terminated by a short packet. However, the host will never send a -+ * zero length packet; some systems can't handle those robustly. -+ * -+ * Anything that can transmit and receive USB bulk packets can implement -+ * this protocol. That includes both smart peripherals and quite a lot -+ * of "host-to-host" USB cables (which embed two devices back-to-back). -+ * -+ * Note that although Linux may use many of those host-to-host links -+ * with this "cdc_subset" framing, that doesn't mean there may not be a -+ * better approach. Handling the "other end unplugs/replugs" scenario -+ * well tends to require chip-specific vendor requests. Also, Windows -+ * peers at the other end of host-to-host cables may expect their own -+ * framing to be used rather than this "cdc_subset" model. -+ */ -+ -+#if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX) -+/* PDA style devices are always connected if present */ -+static int always_connected (struct usbnet *dev) -+{ -+ return 0; -+} -+#endif -+ -+#ifdef CONFIG_USB_ALI_M5632 -+#define HAVE_HARDWARE -+ -+/*------------------------------------------------------------------------- -+ * -+ * ALi M5632 driver ... does high speed -+ * -+ * NOTE that the MS-Windows drivers for this chip use some funky and -+ * (naturally) undocumented 7-byte prefix to each packet, so this is a -+ * case where we don't currently interoperate. Also, once you unplug -+ * one end of the cable, you need to replug the other end too ... since -+ * chip docs are unavailable, there's no way to reset the relevant state -+ * short of a power cycle. -+ * -+ *-------------------------------------------------------------------------*/ -+ -+static void m5632_recover(struct usbnet *dev) -+{ -+ struct usb_device *udev = dev->udev; -+ struct usb_interface *intf = dev->intf; -+ int r; -+ -+ r = usb_lock_device_for_reset(udev, intf); -+ if (r < 0) -+ return; -+ -+ usb_reset_device(udev); -+ usb_unlock_device(udev); -+} -+ -+static const struct driver_info ali_m5632_info = { -+ .description = "ALi M5632", -+ .flags = FLAG_POINTTOPOINT, -+ .recover = m5632_recover, -+}; -+ -+#endif -+ -+#ifdef CONFIG_USB_AN2720 -+#define HAVE_HARDWARE -+ -+/*------------------------------------------------------------------------- -+ * -+ * AnchorChips 2720 driver ... http://www.cypress.com -+ * -+ * This doesn't seem to have a way to detect whether the peer is -+ * connected, or need any reset handshaking. It's got pretty big -+ * internal buffers (handles most of a frame's worth of data). -+ * Chip data sheets don't describe any vendor control messages. -+ * -+ *-------------------------------------------------------------------------*/ -+ -+static const struct driver_info an2720_info = { -+ .description = "AnchorChips/Cypress 2720", -+ .flags = FLAG_POINTTOPOINT, -+ // no reset available! -+ // no check_connect available! -+ -+ .in = 2, .out = 2, // direction distinguishes these -+}; -+ -+#endif /* CONFIG_USB_AN2720 */ -+ -+ -+#ifdef CONFIG_USB_BELKIN -+#define HAVE_HARDWARE -+ -+/*------------------------------------------------------------------------- -+ * -+ * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller -+ * -+ * ... also two eTEK designs, including one sold as "Advance USBNET" -+ * -+ *-------------------------------------------------------------------------*/ -+ -+static const struct driver_info belkin_info = { -+ .description = "Belkin, eTEK, or compatible", -+ .flags = FLAG_POINTTOPOINT, -+}; -+ -+#endif /* CONFIG_USB_BELKIN */ -+ -+ -+ -+#ifdef CONFIG_USB_EPSON2888 -+#define HAVE_HARDWARE -+ -+/*------------------------------------------------------------------------- -+ * -+ * EPSON USB clients -+ * -+ * This is the same idea as Linux PDAs (below) except the firmware in the -+ * device might not be Tux-powered. Epson provides reference firmware that -+ * implements this interface. Product developers can reuse or modify that -+ * code, such as by using their own product and vendor codes. -+ * -+ * Support was from Juro Bystricky bystricky.juro@erd.epson.com -+ * -+ *-------------------------------------------------------------------------*/ -+ -+static const struct driver_info epson2888_info = { -+ .description = "Epson USB Device", -+ .check_connect = always_connected, -+ .flags = FLAG_POINTTOPOINT, -+ -+ .in = 4, .out = 3, -+}; -+ -+#endif /* CONFIG_USB_EPSON2888 */ -+ -+ -+/*------------------------------------------------------------------------- -+ * -+ * info from Jonathan McDowell noodles@earth.li -+ * -+ *-------------------------------------------------------------------------*/ -+#ifdef CONFIG_USB_KC2190 -+#define HAVE_HARDWARE -+static const struct driver_info kc2190_info = { -+ .description = "KC Technology KC-190", -+ .flags = FLAG_POINTTOPOINT, -+}; -+#endif /* CONFIG_USB_KC2190 */ -+ -+ -+#ifdef CONFIG_USB_ARMLINUX -+#define HAVE_HARDWARE -+ -+/*------------------------------------------------------------------------- -+ * -+ * Intel's SA-1100 chip integrates basic USB support, and is used -+ * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. -+ * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to -+ * network using minimal USB framing data. -+ * -+ * This describes the driver currently in standard ARM Linux kernels. -+ * The Zaurus uses a different driver (see later). -+ * -+ * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support -+ * and different USB endpoint numbering than the SA1100 devices. The -+ * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 -+ * so we rely on the endpoint descriptors. -+ * -+ *-------------------------------------------------------------------------*/ -+ -+static const struct driver_info linuxdev_info = { -+ .description = "Linux Device", -+ .check_connect = always_connected, -+ .flags = FLAG_POINTTOPOINT, -+}; -+ -+static const struct driver_info yopy_info = { -+ .description = "Yopy", -+ .check_connect = always_connected, -+ .flags = FLAG_POINTTOPOINT, -+}; -+ -+static const struct driver_info blob_info = { -+ .description = "Boot Loader OBject", -+ .check_connect = always_connected, -+ .flags = FLAG_POINTTOPOINT, -+}; -+ -+#endif /* CONFIG_USB_ARMLINUX */ -+ -+ -+/*-------------------------------------------------------------------------*/ -+ -+#ifndef HAVE_HARDWARE -+#warning You need to configure some hardware for this driver -+#endif -+ -+/* -+ * chip vendor names won't normally be on the cables, and -+ * may not be on the device. -+ */ -+ -+static const struct usb_device_id products [] = { -+ -+#ifdef CONFIG_USB_ALI_M5632 -+{ -+ USB_DEVICE (0x0402, 0x5632), // ALi defaults -+ .driver_info = (unsigned long) &ali_m5632_info, -+}, -+{ -+ USB_DEVICE (0x182d,0x207c), // SiteCom CN-124 -+ .driver_info = (unsigned long) &ali_m5632_info, -+}, -+#endif -+ -+#ifdef CONFIG_USB_AN2720 -+{ -+ USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults -+ .driver_info = (unsigned long) &an2720_info, -+}, { -+ USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET -+ .driver_info = (unsigned long) &an2720_info, -+}, -+#endif -+ -+#ifdef CONFIG_USB_BELKIN -+{ -+ USB_DEVICE (0x050d, 0x0004), // Belkin -+ .driver_info = (unsigned long) &belkin_info, -+}, { -+ USB_DEVICE (0x056c, 0x8100), // eTEK -+ .driver_info = (unsigned long) &belkin_info, -+}, { -+ USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) -+ .driver_info = (unsigned long) &belkin_info, -+}, -+#endif -+ -+#ifdef CONFIG_USB_EPSON2888 -+{ -+ USB_DEVICE (0x0525, 0x2888), // EPSON USB client -+ .driver_info = (unsigned long) &epson2888_info, -+}, -+#endif -+ -+#ifdef CONFIG_USB_KC2190 -+{ -+ USB_DEVICE (0x050f, 0x0190), // KC-190 -+ .driver_info = (unsigned long) &kc2190_info, -+}, -+#endif -+ -+#ifdef CONFIG_USB_ARMLINUX -+/* -+ * SA-1100 using standard ARM Linux kernels, or compatible. -+ * Often used when talking to Linux PDAs (iPaq, Yopy, etc). -+ * The sa-1100 "usb-eth" driver handles the basic framing. -+ * -+ * PXA25x or PXA210 ... these use a "usb-eth" driver much like -+ * the sa1100 one, but hardware uses different endpoint numbers. -+ * -+ * Or the Linux "Ethernet" gadget on hardware that can't talk -+ * CDC Ethernet (e.g., no altsettings), in either of two modes: -+ * - acting just like the old "usb-eth" firmware, though -+ * the implementation is different -+ * - supporting RNDIS as the first/default configuration for -+ * MS-Windows interop; Linux needs to use the other config -+ */ -+{ -+ // 1183 = 0x049F, both used as hex values? -+ // Compaq "Itsy" vendor/product id -+ USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible -+ .driver_info = (unsigned long) &linuxdev_info, -+}, { -+ USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" -+ .driver_info = (unsigned long) &yopy_info, -+}, { -+ USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader -+ .driver_info = (unsigned long) &blob_info, -+}, { -+ USB_DEVICE (0x1286, 0x8001), // "blob" bootloader -+ .driver_info = (unsigned long) &blob_info, -+}, { -+ // Linux Ethernet/RNDIS gadget, mostly on PXA, second config -+ // e.g. Gumstix, current OpenZaurus, ... or anything else -+ // that just enables this gadget option. -+ USB_DEVICE (0x0525, 0xa4a2), -+ .driver_info = (unsigned long) &linuxdev_info, -+}, -+#endif -+ -+ { }, // END -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+/*-------------------------------------------------------------------------*/ -+static int dummy_prereset(struct usb_interface *intf) -+{ -+ return 0; -+} -+ -+static int dummy_postreset(struct usb_interface *intf) -+{ -+ return 0; -+} -+ -+static struct usb_driver cdc_subset_driver = { -+ .name = "cdc_subset", -+ .probe = usbnet_probe, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .pre_reset = dummy_prereset, -+ .post_reset = dummy_postreset, -+ .disconnect = usbnet_disconnect, -+ .id_table = products, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(cdc_subset_driver); -+ -+MODULE_AUTHOR("David Brownell"); -+MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/cx82310_eth.c backports-3.18.1-1/drivers/net/usb/cx82310_eth.c ---- backports-3.18.1-1.org/drivers/net/usb/cx82310_eth.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/cx82310_eth.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,326 @@ -+/* -+ * Driver for USB ethernet port of Conexant CX82310-based ADSL routers -+ * Copyright (C) 2010 by Ondrej Zary -+ * some parts inspired by the cxacru driver -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/usb/usbnet.h> -+ -+enum cx82310_cmd { -+ CMD_START = 0x84, /* no effect? */ -+ CMD_STOP = 0x85, /* no effect? */ -+ CMD_GET_STATUS = 0x90, /* returns nothing? */ -+ CMD_GET_MAC_ADDR = 0x91, /* read MAC address */ -+ CMD_GET_LINK_STATUS = 0x92, /* not useful, link is always up */ -+ CMD_ETHERNET_MODE = 0x99, /* unknown, needed during init */ -+}; -+ -+enum cx82310_status { -+ STATUS_UNDEFINED, -+ STATUS_SUCCESS, -+ STATUS_ERROR, -+ STATUS_UNSUPPORTED, -+ STATUS_UNIMPLEMENTED, -+ STATUS_PARAMETER_ERROR, -+ STATUS_DBG_LOOPBACK, -+}; -+ -+#define CMD_PACKET_SIZE 64 -+/* first command after power on can take around 8 seconds */ -+#define CMD_TIMEOUT 15000 -+#define CMD_REPLY_RETRY 5 -+ -+#define CX82310_MTU 1514 -+#define CMD_EP 0x01 -+ -+/* -+ * execute control command -+ * - optionally send some data (command parameters) -+ * - optionally wait for the reply -+ * - optionally read some data from the reply -+ */ -+static int cx82310_cmd(struct usbnet *dev, enum cx82310_cmd cmd, bool reply, -+ u8 *wdata, int wlen, u8 *rdata, int rlen) -+{ -+ int actual_len, retries, ret; -+ struct usb_device *udev = dev->udev; -+ u8 *buf = kzalloc(CMD_PACKET_SIZE, GFP_KERNEL); -+ -+ if (!buf) -+ return -ENOMEM; -+ -+ /* create command packet */ -+ buf[0] = cmd; -+ if (wdata) -+ memcpy(buf + 4, wdata, min_t(int, wlen, CMD_PACKET_SIZE - 4)); -+ -+ /* send command packet */ -+ ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, CMD_EP), buf, -+ CMD_PACKET_SIZE, &actual_len, CMD_TIMEOUT); -+ if (ret < 0) { -+ dev_err(&dev->udev->dev, "send command %#x: error %d\n", -+ cmd, ret); -+ goto end; -+ } -+ -+ if (reply) { -+ /* wait for reply, retry if it's empty */ -+ for (retries = 0; retries < CMD_REPLY_RETRY; retries++) { -+ ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, CMD_EP), -+ buf, CMD_PACKET_SIZE, &actual_len, -+ CMD_TIMEOUT); -+ if (ret < 0) { -+ dev_err(&dev->udev->dev, -+ "reply receive error %d\n", ret); -+ goto end; -+ } -+ if (actual_len > 0) -+ break; -+ } -+ if (actual_len == 0) { -+ dev_err(&dev->udev->dev, "no reply to command %#x\n", -+ cmd); -+ ret = -EIO; -+ goto end; -+ } -+ if (buf[0] != cmd) { -+ dev_err(&dev->udev->dev, -+ "got reply to command %#x, expected: %#x\n", -+ buf[0], cmd); -+ ret = -EIO; -+ goto end; -+ } -+ if (buf[1] != STATUS_SUCCESS) { -+ dev_err(&dev->udev->dev, "command %#x failed: %#x\n", -+ cmd, buf[1]); -+ ret = -EIO; -+ goto end; -+ } -+ if (rdata) -+ memcpy(rdata, buf + 4, -+ min_t(int, rlen, CMD_PACKET_SIZE - 4)); -+ } -+end: -+ kfree(buf); -+ return ret; -+} -+ -+#define partial_len data[0] /* length of partial packet data */ -+#define partial_rem data[1] /* remaining (missing) data length */ -+#define partial_data data[2] /* partial packet data */ -+ -+static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int ret; -+ char buf[15]; -+ struct usb_device *udev = dev->udev; -+ -+ /* avoid ADSL modems - continue only if iProduct is "USB NET CARD" */ -+ if (usb_string(udev, udev->descriptor.iProduct, buf, sizeof(buf)) > 0 -+ && strcmp(buf, "USB NET CARD")) { -+ dev_info(&udev->dev, "ignoring: probably an ADSL modem\n"); -+ return -ENODEV; -+ } -+ -+ ret = usbnet_get_endpoints(dev, intf); -+ if (ret) -+ return ret; -+ -+ /* -+ * this must not include ethernet header as the device can send partial -+ * packets with no header (and sometimes even empty URBs) -+ */ -+ dev->net->hard_header_len = 0; -+ /* we can send at most 1514 bytes of data (+ 2-byte header) per URB */ -+ dev->hard_mtu = CX82310_MTU + 2; -+ /* we can receive URBs up to 4KB from the device */ -+ dev->rx_urb_size = 4096; -+ -+ dev->partial_data = (unsigned long) kmalloc(dev->hard_mtu, GFP_KERNEL); -+ if (!dev->partial_data) -+ return -ENOMEM; -+ -+ /* enable ethernet mode (?) */ -+ ret = cx82310_cmd(dev, CMD_ETHERNET_MODE, true, "\x01", 1, NULL, 0); -+ if (ret) { -+ dev_err(&udev->dev, "unable to enable ethernet mode: %d\n", -+ ret); -+ goto err; -+ } -+ -+ /* get the MAC address */ -+ ret = cx82310_cmd(dev, CMD_GET_MAC_ADDR, true, NULL, 0, -+ dev->net->dev_addr, ETH_ALEN); -+ if (ret) { -+ dev_err(&udev->dev, "unable to read MAC address: %d\n", ret); -+ goto err; -+ } -+ -+ /* start (does not seem to have any effect?) */ -+ ret = cx82310_cmd(dev, CMD_START, false, NULL, 0, NULL, 0); -+ if (ret) -+ goto err; -+ -+ return 0; -+err: -+ kfree((void *)dev->partial_data); -+ return ret; -+} -+ -+static void cx82310_unbind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ kfree((void *)dev->partial_data); -+} -+ -+/* -+ * RX is NOT easy - we can receive multiple packets per skb, each having 2-byte -+ * packet length at the beginning. -+ * The last packet might be incomplete (when it crosses the 4KB URB size), -+ * continuing in the next skb (without any headers). -+ * If a packet has odd length, there is one extra byte at the end (before next -+ * packet or at the end of the URB). -+ */ -+static int cx82310_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ int len; -+ struct sk_buff *skb2; -+ -+ /* -+ * If the last skb ended with an incomplete packet, this skb contains -+ * end of that packet at the beginning. -+ */ -+ if (dev->partial_rem) { -+ len = dev->partial_len + dev->partial_rem; -+ skb2 = alloc_skb(len, GFP_ATOMIC); -+ if (!skb2) -+ return 0; -+ skb_put(skb2, len); -+ memcpy(skb2->data, (void *)dev->partial_data, -+ dev->partial_len); -+ memcpy(skb2->data + dev->partial_len, skb->data, -+ dev->partial_rem); -+ usbnet_skb_return(dev, skb2); -+ skb_pull(skb, (dev->partial_rem + 1) & ~1); -+ dev->partial_rem = 0; -+ if (skb->len < 2) -+ return 1; -+ } -+ -+ /* a skb can contain multiple packets */ -+ while (skb->len > 1) { -+ /* first two bytes are packet length */ -+ len = skb->data[0] | (skb->data[1] << 8); -+ skb_pull(skb, 2); -+ -+ /* if last packet in the skb, let usbnet to process it */ -+ if (len == skb->len || len + 1 == skb->len) { -+ skb_trim(skb, len); -+ break; -+ } -+ -+ if (len > CX82310_MTU) { -+ dev_err(&dev->udev->dev, "RX packet too long: %d B\n", -+ len); -+ return 0; -+ } -+ -+ /* incomplete packet, save it for the next skb */ -+ if (len > skb->len) { -+ dev->partial_len = skb->len; -+ dev->partial_rem = len - skb->len; -+ memcpy((void *)dev->partial_data, skb->data, -+ dev->partial_len); -+ skb_pull(skb, skb->len); -+ break; -+ } -+ -+ skb2 = alloc_skb(len, GFP_ATOMIC); -+ if (!skb2) -+ return 0; -+ skb_put(skb2, len); -+ memcpy(skb2->data, skb->data, len); -+ /* process the packet */ -+ usbnet_skb_return(dev, skb2); -+ -+ skb_pull(skb, (len + 1) & ~1); -+ } -+ -+ /* let usbnet process the last packet */ -+ return 1; -+} -+ -+/* TX is easy, just add 2 bytes of length at the beginning */ -+static struct sk_buff *cx82310_tx_fixup(struct usbnet *dev, struct sk_buff *skb, -+ gfp_t flags) -+{ -+ int len = skb->len; -+ -+ if (skb_headroom(skb) < 2) { -+ struct sk_buff *skb2 = skb_copy_expand(skb, 2, 0, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (!skb) -+ return NULL; -+ } -+ skb_push(skb, 2); -+ -+ skb->data[0] = len; -+ skb->data[1] = len >> 8; -+ -+ return skb; -+} -+ -+ -+static const struct driver_info cx82310_info = { -+ .description = "Conexant CX82310 USB ethernet", -+ .flags = FLAG_ETHER, -+ .bind = cx82310_bind, -+ .unbind = cx82310_unbind, -+ .rx_fixup = cx82310_rx_fixup, -+ .tx_fixup = cx82310_tx_fixup, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ USB_DEVICE_AND_INTERFACE_INFO(0x0572, 0xcb01, 0xff, 0, 0), -+ .driver_info = (unsigned long) &cx82310_info -+ }, -+ { }, -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver cx82310_driver = { -+ .name = "cx82310_eth", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(cx82310_driver); -+ -+MODULE_AUTHOR("Ondrej Zary"); -+MODULE_DESCRIPTION("Conexant CX82310-based ADSL router USB ethernet driver"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/dm9601.c backports-3.18.1-1/drivers/net/usb/dm9601.c ---- backports-3.18.1-1.org/drivers/net/usb/dm9601.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/dm9601.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,647 @@ -+/* -+ * Davicom DM96xx USB 10/100Mbps ethernet devices -+ * -+ * Peter Korsgaard jacmet@sunsite.dk -+ * -+ * This file is licensed under the terms of the GNU General Public License -+ * version 2. This program is licensed "as is" without any warranty of any -+ * kind, whether express or implied. -+ */ -+ -+//#define DEBUG -+ -+#include <linux/module.h> -+#include <linux/sched.h> -+#include <linux/stddef.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/crc32.h> -+#include <linux/usb/usbnet.h> -+#include <linux/slab.h> -+ -+/* datasheet: -+ http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914... -+*/ -+ -+/* control requests */ -+#define DM_READ_REGS 0x00 -+#define DM_WRITE_REGS 0x01 -+#define DM_READ_MEMS 0x02 -+#define DM_WRITE_REG 0x03 -+#define DM_WRITE_MEMS 0x05 -+#define DM_WRITE_MEM 0x07 -+ -+/* registers */ -+#define DM_NET_CTRL 0x00 -+#define DM_RX_CTRL 0x05 -+#define DM_SHARED_CTRL 0x0b -+#define DM_SHARED_ADDR 0x0c -+#define DM_SHARED_DATA 0x0d /* low + high */ -+#define DM_PHY_ADDR 0x10 /* 6 bytes */ -+#define DM_MCAST_ADDR 0x16 /* 8 bytes */ -+#define DM_GPR_CTRL 0x1e -+#define DM_GPR_DATA 0x1f -+#define DM_CHIP_ID 0x2c -+#define DM_MODE_CTRL 0x91 /* only on dm9620 */ -+ -+/* chip id values */ -+#define ID_DM9601 0 -+#define ID_DM9620 1 -+ -+#define DM_MAX_MCAST 64 -+#define DM_MCAST_SIZE 8 -+#define DM_EEPROM_LEN 256 -+#define DM_TX_OVERHEAD 2 /* 2 byte header */ -+#define DM_RX_OVERHEAD 7 /* 3 byte header + 4 byte crc tail */ -+#define DM_TIMEOUT 1000 -+ -+static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data) -+{ -+ int err; -+ err = usbnet_read_cmd(dev, DM_READ_REGS, -+ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ 0, reg, data, length); -+ if(err != length && err >= 0) -+ err = -EINVAL; -+ return err; -+} -+ -+static int dm_read_reg(struct usbnet *dev, u8 reg, u8 *value) -+{ -+ return dm_read(dev, reg, 1, value); -+} -+ -+static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data) -+{ -+ int err; -+ err = usbnet_write_cmd(dev, DM_WRITE_REGS, -+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ 0, reg, data, length); -+ -+ if (err >= 0 && err < length) -+ err = -EINVAL; -+ return err; -+} -+ -+static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value) -+{ -+ return usbnet_write_cmd(dev, DM_WRITE_REG, -+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ value, reg, NULL, 0); -+} -+ -+static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data) -+{ -+ usbnet_write_cmd_async(dev, DM_WRITE_REGS, -+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ 0, reg, data, length); -+} -+ -+static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value) -+{ -+ usbnet_write_cmd_async(dev, DM_WRITE_REG, -+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ value, reg, NULL, 0); -+} -+ -+static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *value) -+{ -+ int ret, i; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); -+ dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0xc : 0x4); -+ -+ for (i = 0; i < DM_TIMEOUT; i++) { -+ u8 tmp = 0; -+ -+ udelay(1); -+ ret = dm_read_reg(dev, DM_SHARED_CTRL, &tmp); -+ if (ret < 0) -+ goto out; -+ -+ /* ready */ -+ if ((tmp & 1) == 0) -+ break; -+ } -+ -+ if (i == DM_TIMEOUT) { -+ netdev_err(dev->net, "%s read timed out!\n", phy ? "phy" : "eeprom"); -+ ret = -EIO; -+ goto out; -+ } -+ -+ dm_write_reg(dev, DM_SHARED_CTRL, 0x0); -+ ret = dm_read(dev, DM_SHARED_DATA, 2, value); -+ -+ netdev_dbg(dev->net, "read shared %d 0x%02x returned 0x%04x, %d\n", -+ phy, reg, *value, ret); -+ -+ out: -+ mutex_unlock(&dev->phy_mutex); -+ return ret; -+} -+ -+static int dm_write_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 value) -+{ -+ int ret, i; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ ret = dm_write(dev, DM_SHARED_DATA, 2, &value); -+ if (ret < 0) -+ goto out; -+ -+ dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); -+ dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0x1a : 0x12); -+ -+ for (i = 0; i < DM_TIMEOUT; i++) { -+ u8 tmp = 0; -+ -+ udelay(1); -+ ret = dm_read_reg(dev, DM_SHARED_CTRL, &tmp); -+ if (ret < 0) -+ goto out; -+ -+ /* ready */ -+ if ((tmp & 1) == 0) -+ break; -+ } -+ -+ if (i == DM_TIMEOUT) { -+ netdev_err(dev->net, "%s write timed out!\n", phy ? "phy" : "eeprom"); -+ ret = -EIO; -+ goto out; -+ } -+ -+ dm_write_reg(dev, DM_SHARED_CTRL, 0x0); -+ -+out: -+ mutex_unlock(&dev->phy_mutex); -+ return ret; -+} -+ -+static int dm_read_eeprom_word(struct usbnet *dev, u8 offset, void *value) -+{ -+ return dm_read_shared_word(dev, 0, offset, value); -+} -+ -+ -+ -+static int dm9601_get_eeprom_len(struct net_device *dev) -+{ -+ return DM_EEPROM_LEN; -+} -+ -+static int dm9601_get_eeprom(struct net_device *net, -+ struct ethtool_eeprom *eeprom, u8 * data) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ __le16 *ebuf = (__le16 *) data; -+ int i; -+ -+ /* access is 16bit */ -+ if ((eeprom->offset % 2) || (eeprom->len % 2)) -+ return -EINVAL; -+ -+ for (i = 0; i < eeprom->len / 2; i++) { -+ if (dm_read_eeprom_word(dev, eeprom->offset / 2 + i, -+ &ebuf[i]) < 0) -+ return -EINVAL; -+ } -+ return 0; -+} -+ -+static int dm9601_mdio_read(struct net_device *netdev, int phy_id, int loc) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ -+ __le16 res; -+ -+ if (phy_id) { -+ netdev_dbg(dev->net, "Only internal phy supported\n"); -+ return 0; -+ } -+ -+ dm_read_shared_word(dev, 1, loc, &res); -+ -+ netdev_dbg(dev->net, -+ "dm9601_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", -+ phy_id, loc, le16_to_cpu(res)); -+ -+ return le16_to_cpu(res); -+} -+ -+static void dm9601_mdio_write(struct net_device *netdev, int phy_id, int loc, -+ int val) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ __le16 res = cpu_to_le16(val); -+ -+ if (phy_id) { -+ netdev_dbg(dev->net, "Only internal phy supported\n"); -+ return; -+ } -+ -+ netdev_dbg(dev->net, "dm9601_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", -+ phy_id, loc, val); -+ -+ dm_write_shared_word(dev, 1, loc, res); -+} -+ -+static void dm9601_get_drvinfo(struct net_device *net, -+ struct ethtool_drvinfo *info) -+{ -+ /* Inherit standard device info */ -+ usbnet_get_drvinfo(net, info); -+ info->eedump_len = DM_EEPROM_LEN; -+} -+ -+static u32 dm9601_get_link(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ return mii_link_ok(&dev->mii); -+} -+ -+static int dm9601_ioctl(struct net_device *net, struct ifreq *rq, int cmd) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -+} -+ -+static const struct ethtool_ops dm9601_ethtool_ops = { -+ .get_drvinfo = dm9601_get_drvinfo, -+ .get_link = dm9601_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_eeprom_len = dm9601_get_eeprom_len, -+ .get_eeprom = dm9601_get_eeprom, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .nway_reset = usbnet_nway_reset, -+}; -+ -+static void dm9601_set_multicast(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ /* We use the 20 byte dev->data for our 8 byte filter buffer -+ * to avoid allocating memory that is tricky to free later */ -+ u8 *hashes = (u8 *) & dev->data; -+ u8 rx_ctl = 0x31; -+ -+ memset(hashes, 0x00, DM_MCAST_SIZE); -+ hashes[DM_MCAST_SIZE - 1] |= 0x80; /* broadcast address */ -+ -+ if (net->flags & IFF_PROMISC) { -+ rx_ctl |= 0x02; -+ } else if (net->flags & IFF_ALLMULTI || -+ netdev_mc_count(net) > DM_MAX_MCAST) { -+ rx_ctl |= 0x08; -+ } else if (!netdev_mc_empty(net)) { -+ struct netdev_hw_addr *ha; -+ -+ netdev_for_each_mc_addr(ha, net) { -+ u32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26; -+ hashes[crc >> 3] |= 1 << (crc & 0x7); -+ } -+ } -+ -+ dm_write_async(dev, DM_MCAST_ADDR, DM_MCAST_SIZE, hashes); -+ dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl); -+} -+ -+static void __dm9601_set_mac_address(struct usbnet *dev) -+{ -+ dm_write_async(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr); -+} -+ -+static int dm9601_set_mac_address(struct net_device *net, void *p) -+{ -+ struct sockaddr *addr = p; -+ struct usbnet *dev = netdev_priv(net); -+ -+ if (!is_valid_ether_addr(addr->sa_data)) { -+ dev_err(&net->dev, "not setting invalid mac address %pM\n", -+ addr->sa_data); -+ return -EINVAL; -+ } -+ -+ memcpy(net->dev_addr, addr->sa_data, net->addr_len); -+ __dm9601_set_mac_address(dev); -+ -+ return 0; -+} -+ -+static const struct net_device_ops dm9601_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = dm9601_ioctl, -+ .ndo_set_rx_mode = dm9601_set_multicast, -+ .ndo_set_mac_address = dm9601_set_mac_address, -+}; -+ -+static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int ret; -+ u8 mac[ETH_ALEN], id; -+ -+ ret = usbnet_get_endpoints(dev, intf); -+ if (ret) -+ goto out; -+ -+ dev->net->netdev_ops = &dm9601_netdev_ops; -+ dev->net->ethtool_ops = &dm9601_ethtool_ops; -+ dev->net->hard_header_len += DM_TX_OVERHEAD; -+ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; -+ -+ /* dm9620/21a require room for 4 byte padding, even in dm9601 -+ * mode, so we need +1 to be able to receive full size -+ * ethernet frames. -+ */ -+ dev->rx_urb_size = dev->net->mtu + ETH_HLEN + DM_RX_OVERHEAD + 1; -+ -+ dev->mii.dev = dev->net; -+ dev->mii.mdio_read = dm9601_mdio_read; -+ dev->mii.mdio_write = dm9601_mdio_write; -+ dev->mii.phy_id_mask = 0x1f; -+ dev->mii.reg_num_mask = 0x1f; -+ -+ /* reset */ -+ dm_write_reg(dev, DM_NET_CTRL, 1); -+ udelay(20); -+ -+ /* read MAC */ -+ if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, mac) < 0) { -+ printk(KERN_ERR "Error reading MAC address\n"); -+ ret = -ENODEV; -+ goto out; -+ } -+ -+ /* -+ * Overwrite the auto-generated address only with good ones. -+ */ -+ if (is_valid_ether_addr(mac)) -+ memcpy(dev->net->dev_addr, mac, ETH_ALEN); -+ else { -+ printk(KERN_WARNING -+ "dm9601: No valid MAC address in EEPROM, using %pM\n", -+ dev->net->dev_addr); -+ __dm9601_set_mac_address(dev); -+ } -+ -+ if (dm_read_reg(dev, DM_CHIP_ID, &id) < 0) { -+ netdev_err(dev->net, "Error reading chip ID\n"); -+ ret = -ENODEV; -+ goto out; -+ } -+ -+ /* put dm9620 devices in dm9601 mode */ -+ if (id == ID_DM9620) { -+ u8 mode; -+ -+ if (dm_read_reg(dev, DM_MODE_CTRL, &mode) < 0) { -+ netdev_err(dev->net, "Error reading MODE_CTRL\n"); -+ ret = -ENODEV; -+ goto out; -+ } -+ dm_write_reg(dev, DM_MODE_CTRL, mode & 0x7f); -+ } -+ -+ /* power up phy */ -+ dm_write_reg(dev, DM_GPR_CTRL, 1); -+ dm_write_reg(dev, DM_GPR_DATA, 0); -+ -+ /* receive broadcast packets */ -+ dm9601_set_multicast(dev->net); -+ -+ dm9601_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); -+ dm9601_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, -+ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); -+ mii_nway_restart(&dev->mii); -+ -+out: -+ return ret; -+} -+ -+static int dm9601_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ u8 status; -+ int len; -+ -+ /* format: -+ b1: rx status -+ b2: packet length (incl crc) low -+ b3: packet length (incl crc) high -+ b4..n-4: packet data -+ bn-3..bn: ethernet crc -+ */ -+ -+ if (unlikely(skb->len < DM_RX_OVERHEAD)) { -+ dev_err(&dev->udev->dev, "unexpected tiny rx frame\n"); -+ return 0; -+ } -+ -+ status = skb->data[0]; -+ len = (skb->data[1] | (skb->data[2] << 8)) - 4; -+ -+ if (unlikely(status & 0xbf)) { -+ if (status & 0x01) dev->net->stats.rx_fifo_errors++; -+ if (status & 0x02) dev->net->stats.rx_crc_errors++; -+ if (status & 0x04) dev->net->stats.rx_frame_errors++; -+ if (status & 0x20) dev->net->stats.rx_missed_errors++; -+ if (status & 0x90) dev->net->stats.rx_length_errors++; -+ return 0; -+ } -+ -+ skb_pull(skb, 3); -+ skb_trim(skb, len); -+ -+ return 1; -+} -+ -+static struct sk_buff *dm9601_tx_fixup(struct usbnet *dev, struct sk_buff *skb, -+ gfp_t flags) -+{ -+ int len, pad; -+ -+ /* format: -+ b1: packet length low -+ b2: packet length high -+ b3..n: packet data -+ */ -+ -+ len = skb->len + DM_TX_OVERHEAD; -+ -+ /* workaround for dm962x errata with tx fifo getting out of -+ * sync if a USB bulk transfer retry happens right after a -+ * packet with odd / maxpacket length by adding up to 3 bytes -+ * padding. -+ */ -+ while ((len & 1) || !(len % dev->maxpacket)) -+ len++; -+ -+ len -= DM_TX_OVERHEAD; /* hw header doesn't count as part of length */ -+ pad = len - skb->len; -+ -+ if (skb_headroom(skb) < DM_TX_OVERHEAD || skb_tailroom(skb) < pad) { -+ struct sk_buff *skb2; -+ -+ skb2 = skb_copy_expand(skb, DM_TX_OVERHEAD, pad, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (!skb) -+ return NULL; -+ } -+ -+ __skb_push(skb, DM_TX_OVERHEAD); -+ -+ if (pad) { -+ memset(skb->data + skb->len, 0, pad); -+ __skb_put(skb, pad); -+ } -+ -+ skb->data[0] = len; -+ skb->data[1] = len >> 8; -+ -+ return skb; -+} -+ -+static void dm9601_status(struct usbnet *dev, struct urb *urb) -+{ -+ int link; -+ u8 *buf; -+ -+ /* format: -+ b0: net status -+ b1: tx status 1 -+ b2: tx status 2 -+ b3: rx status -+ b4: rx overflow -+ b5: rx count -+ b6: tx count -+ b7: gpr -+ */ -+ -+ if (urb->actual_length < 8) -+ return; -+ -+ buf = urb->transfer_buffer; -+ -+ link = !!(buf[0] & 0x40); -+ if (netif_carrier_ok(dev->net) != link) { -+ usbnet_link_change(dev, link, 1); -+ netdev_dbg(dev->net, "Link Status is: %d\n", link); -+ } -+} -+ -+static int dm9601_link_reset(struct usbnet *dev) -+{ -+ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; -+ -+ mii_check_media(&dev->mii, 1, 1); -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ -+ netdev_dbg(dev->net, "link_reset() speed: %u duplex: %d\n", -+ ethtool_cmd_speed(&ecmd), ecmd.duplex); -+ -+ return 0; -+} -+ -+static const struct driver_info dm9601_info = { -+ .description = "Davicom DM96xx USB 10/100 Ethernet", -+ .flags = FLAG_ETHER | FLAG_LINK_INTR, -+ .bind = dm9601_bind, -+ .rx_fixup = dm9601_rx_fixup, -+ .tx_fixup = dm9601_tx_fixup, -+ .status = dm9601_status, -+ .link_reset = dm9601_link_reset, -+ .reset = dm9601_link_reset, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ USB_DEVICE(0x07aa, 0x9601), /* Corega FEther USB-TXC */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x9601), /* Davicom USB-100 */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x6688), /* ZT6688 USB NIC */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x0268), /* ShanTou ST268 USB NIC */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x8515), /* ADMtek ADM8515 USB NIC */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a47, 0x9601), /* Hirose USB-100 */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0fe6, 0x8101), /* DM9601 USB to Fast Ethernet Adapter */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0fe6, 0x9700), /* DM9601 USB to Fast Ethernet Adapter */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x9000), /* DM9000E */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x9620), /* DM9620 USB to Fast Ethernet Adapter */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x9621), /* DM9621A USB to Fast Ethernet Adapter */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x9622), /* DM9622 USB to Fast Ethernet Adapter */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x0269), /* DM962OA USB to Fast Ethernet Adapter */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ { -+ USB_DEVICE(0x0a46, 0x1269), /* DM9621A USB to Fast Ethernet Adapter */ -+ .driver_info = (unsigned long)&dm9601_info, -+ }, -+ {}, // END -+}; -+ -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver dm9601_driver = { -+ .name = "dm9601", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(dm9601_driver); -+ -+MODULE_AUTHOR("Peter Korsgaard jacmet@sunsite.dk"); -+MODULE_DESCRIPTION("Davicom DM96xx USB 10/100 ethernet devices"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/gl620a.c backports-3.18.1-1/drivers/net/usb/gl620a.c ---- backports-3.18.1-1.org/drivers/net/usb/gl620a.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/gl620a.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,242 @@ -+/* -+ * GeneSys GL620USB-A based links -+ * Copyright (C) 2001 by Jiun-Jie Huang huangjj@genesyslogic.com.tw -+ * Copyright (C) 2001 by Stanislav Brabec utx@penguin.cz -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+// #define DEBUG // error path messages, extra info -+// #define VERBOSE // more; success messages -+ -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/usb/usbnet.h> -+#include <linux/gfp.h> -+ -+ -+/* -+ * GeneSys GL620USB-A (www.genesyslogic.com.tw) -+ * -+ * ... should partially interop with the Win32 driver for this hardware. -+ * The GeneSys docs imply there's some NDIS issue motivating this framing. -+ * -+ * Some info from GeneSys: -+ * - GL620USB-A is full duplex; GL620USB is only half duplex for bulk. -+ * (Some cables, like the BAFO-100c, use the half duplex version.) -+ * - For the full duplex model, the low bit of the version code says -+ * which side is which ("left/right"). -+ * - For the half duplex type, a control/interrupt handshake settles -+ * the transfer direction. (That's disabled here, partially coded.) -+ * A control URB would block until other side writes an interrupt. -+ * -+ * Original code from Jiun-Jie Huang huangjj@genesyslogic.com.tw -+ * and merged into "usbnet" by Stanislav Brabec utx@penguin.cz. -+ */ -+ -+// control msg write command -+#define GENELINK_CONNECT_WRITE 0xF0 -+// interrupt pipe index -+#define GENELINK_INTERRUPT_PIPE 0x03 -+// interrupt read buffer size -+#define INTERRUPT_BUFSIZE 0x08 -+// interrupt pipe interval value -+#define GENELINK_INTERRUPT_INTERVAL 0x10 -+// max transmit packet number per transmit -+#define GL_MAX_TRANSMIT_PACKETS 32 -+// max packet length -+#define GL_MAX_PACKET_LEN 1514 -+// max receive buffer size -+#define GL_RCV_BUF_SIZE \ -+ (((GL_MAX_PACKET_LEN + 4) * GL_MAX_TRANSMIT_PACKETS) + 4) -+ -+struct gl_packet { -+ __le32 packet_length; -+ char packet_data [1]; -+}; -+ -+struct gl_header { -+ __le32 packet_count; -+ struct gl_packet packets; -+}; -+ -+static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ struct gl_header *header; -+ struct gl_packet *packet; -+ struct sk_buff *gl_skb; -+ u32 size; -+ u32 count; -+ -+ /* This check is no longer done by usbnet */ -+ if (skb->len < dev->net->hard_header_len) -+ return 0; -+ -+ header = (struct gl_header *) skb->data; -+ -+ // get the packet count of the received skb -+ count = le32_to_cpu(header->packet_count); -+ if (count > GL_MAX_TRANSMIT_PACKETS) { -+ netdev_dbg(dev->net, -+ "genelink: invalid received packet count %u\n", -+ count); -+ return 0; -+ } -+ -+ // set the current packet pointer to the first packet -+ packet = &header->packets; -+ -+ // decrement the length for the packet count size 4 bytes -+ skb_pull(skb, 4); -+ -+ while (count > 1) { -+ // get the packet length -+ size = le32_to_cpu(packet->packet_length); -+ -+ // this may be a broken packet -+ if (size > GL_MAX_PACKET_LEN) { -+ netdev_dbg(dev->net, "genelink: invalid rx length %d\n", -+ size); -+ return 0; -+ } -+ -+ // allocate the skb for the individual packet -+ gl_skb = alloc_skb(size, GFP_ATOMIC); -+ if (gl_skb) { -+ -+ // copy the packet data to the new skb -+ memcpy(skb_put(gl_skb, size), -+ packet->packet_data, size); -+ usbnet_skb_return(dev, gl_skb); -+ } -+ -+ // advance to the next packet -+ packet = (struct gl_packet *)&packet->packet_data[size]; -+ count--; -+ -+ // shift the data pointer to the next gl_packet -+ skb_pull(skb, size + 4); -+ } -+ -+ // skip the packet length field 4 bytes -+ skb_pull(skb, 4); -+ -+ if (skb->len > GL_MAX_PACKET_LEN) { -+ netdev_dbg(dev->net, "genelink: invalid rx length %d\n", -+ skb->len); -+ return 0; -+ } -+ return 1; -+} -+ -+static struct sk_buff * -+genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) -+{ -+ int padlen; -+ int length = skb->len; -+ int headroom = skb_headroom(skb); -+ int tailroom = skb_tailroom(skb); -+ __le32 *packet_count; -+ __le32 *packet_len; -+ -+ // FIXME: magic numbers, bleech -+ padlen = ((skb->len + (4 + 4*1)) % 64) ? 0 : 1; -+ -+ if ((!skb_cloned(skb)) -+ && ((headroom + tailroom) >= (padlen + (4 + 4*1)))) { -+ if ((headroom < (4 + 4*1)) || (tailroom < padlen)) { -+ skb->data = memmove(skb->head + (4 + 4*1), -+ skb->data, skb->len); -+ skb_set_tail_pointer(skb, skb->len); -+ } -+ } else { -+ struct sk_buff *skb2; -+ skb2 = skb_copy_expand(skb, (4 + 4*1) , padlen, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (!skb) -+ return NULL; -+ } -+ -+ // attach the packet count to the header -+ packet_count = (__le32 *) skb_push(skb, (4 + 4*1)); -+ packet_len = packet_count + 1; -+ -+ *packet_count = cpu_to_le32(1); -+ *packet_len = cpu_to_le32(length); -+ -+ // add padding byte -+ if ((skb->len % dev->maxpacket) == 0) -+ skb_put(skb, 1); -+ -+ return skb; -+} -+ -+static int genelink_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ dev->hard_mtu = GL_RCV_BUF_SIZE; -+ dev->net->hard_header_len += 4; -+ dev->in = usb_rcvbulkpipe(dev->udev, dev->driver_info->in); -+ dev->out = usb_sndbulkpipe(dev->udev, dev->driver_info->out); -+ return 0; -+} -+ -+static const struct driver_info genelink_info = { -+ .description = "Genesys GeneLink", -+ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_GL | FLAG_NO_SETINT, -+ .bind = genelink_bind, -+ .rx_fixup = genelink_rx_fixup, -+ .tx_fixup = genelink_tx_fixup, -+ -+ .in = 1, .out = 2, -+ -+#ifdef GENELINK_ACK -+ .check_connect =genelink_check_connect, -+#endif -+}; -+ -+static const struct usb_device_id products [] = { -+ -+{ -+ USB_DEVICE(0x05e3, 0x0502), // GL620USB-A -+ .driver_info = (unsigned long) &genelink_info, -+}, -+ /* NOT: USB_DEVICE(0x05e3, 0x0501), // GL620USB -+ * that's half duplex, not currently supported -+ */ -+ { }, // END -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver gl620a_driver = { -+ .name = "gl620a", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(gl620a_driver); -+ -+MODULE_AUTHOR("Jiun-Jie Huang"); -+MODULE_DESCRIPTION("GL620-USB-A Host-to-Host Link cables"); -+MODULE_LICENSE("GPL"); -+ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/hso.c backports-3.18.1-1/drivers/net/usb/hso.c ---- backports-3.18.1-1.org/drivers/net/usb/hso.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/hso.c 2015-01-03 13:42:25.000000000 +0100 -@@ -0,0 +1,3326 @@ -+/****************************************************************************** -+ * -+ * Driver for Option High Speed Mobile Devices. -+ * -+ * Copyright (C) 2008 Option International -+ * Filip Aben f.aben@option.com -+ * Denis Joseph Barrow d.barow@option.com -+ * Jan Dumon j.dumon@option.com -+ * Copyright (C) 2007 Andrew Bird (Sphere Systems Ltd) -+ * ajb@spheresystems.co.uk -+ * Copyright (C) 2008 Greg Kroah-Hartman gregkh@suse.de -+ * Copyright (C) 2008 Novell, Inc. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, write to the Free Software -+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -+ * USA -+ * -+ * -+ *****************************************************************************/ -+ -+/****************************************************************************** -+ * -+ * Description of the device: -+ * -+ * Interface 0: Contains the IP network interface on the bulk end points. -+ * The multiplexed serial ports are using the interrupt and -+ * control endpoints. -+ * Interrupt contains a bitmap telling which multiplexed -+ * serialport needs servicing. -+ * -+ * Interface 1: Diagnostics port, uses bulk only, do not submit urbs until the -+ * port is opened, as this have a huge impact on the network port -+ * throughput. -+ * -+ * Interface 2: Standard modem interface - circuit switched interface, this -+ * can be used to make a standard ppp connection however it -+ * should not be used in conjunction with the IP network interface -+ * enabled for USB performance reasons i.e. if using this set -+ * ideally disable_net=1. -+ * -+ *****************************************************************************/ -+ -+#include <linux/sched.h> -+#include <linux/slab.h> -+#include <linux/init.h> -+#include <linux/delay.h> -+#include <linux/netdevice.h> -+#include <linux/module.h> -+#include <linux/ethtool.h> -+#include <linux/usb.h> -+#include <linux/timer.h> -+#include <linux/tty.h> -+#include <linux/tty_driver.h> -+#include <linux/tty_flip.h> -+#include <linux/kmod.h> -+#include <linux/rfkill.h> -+#include <linux/ip.h> -+#include <linux/uaccess.h> -+#include <linux/usb/cdc.h> -+#include <net/arp.h> -+#include <asm/byteorder.h> -+#include <linux/serial_core.h> -+#include <linux/serial.h> -+#include <asm/local.h> -+ -+#define MOD_AUTHOR "Option Wireless" -+#define MOD_DESCRIPTION "USB High Speed Option driver" -+#define MOD_LICENSE "GPL" -+ -+#define HSO_MAX_NET_DEVICES 10 -+#define HSO__MAX_MTU 2048 -+#define DEFAULT_MTU 1500 -+#define DEFAULT_MRU 1500 -+ -+#define CTRL_URB_RX_SIZE 1024 -+#define CTRL_URB_TX_SIZE 64 -+ -+#define BULK_URB_RX_SIZE 4096 -+#define BULK_URB_TX_SIZE 8192 -+ -+#define MUX_BULK_RX_BUF_SIZE HSO__MAX_MTU -+#define MUX_BULK_TX_BUF_SIZE HSO__MAX_MTU -+#define MUX_BULK_RX_BUF_COUNT 4 -+#define USB_TYPE_OPTION_VENDOR 0x20 -+ -+/* These definitions are used with the struct hso_net flags element */ -+/* - use *_bit operations on it. (bit indices not values.) */ -+#define HSO_NET_RUNNING 0 -+ -+#define HSO_NET_TX_TIMEOUT (HZ*10) -+ -+#define HSO_SERIAL_MAGIC 0x48534f31 -+ -+/* Number of ttys to handle */ -+#define HSO_SERIAL_TTY_MINORS 256 -+ -+#define MAX_RX_URBS 2 -+ -+/*****************************************************************************/ -+/* Debugging functions */ -+/*****************************************************************************/ -+#define D__(lvl_, fmt, arg...) \ -+ do { \ -+ printk(lvl_ "[%d:%s]: " fmt "\n", \ -+ __LINE__, __func__, ## arg); \ -+ } while (0) -+ -+#define D_(lvl, args...) \ -+ do { \ -+ if (lvl & debug) \ -+ D__(KERN_INFO, args); \ -+ } while (0) -+ -+#define D1(args...) D_(0x01, ##args) -+#define D2(args...) D_(0x02, ##args) -+#define D3(args...) D_(0x04, ##args) -+#define D4(args...) D_(0x08, ##args) -+#define D5(args...) D_(0x10, ##args) -+ -+/*****************************************************************************/ -+/* Enumerators */ -+/*****************************************************************************/ -+enum pkt_parse_state { -+ WAIT_IP, -+ WAIT_DATA, -+ WAIT_SYNC -+}; -+ -+/*****************************************************************************/ -+/* Structs */ -+/*****************************************************************************/ -+ -+struct hso_shared_int { -+ struct usb_endpoint_descriptor *intr_endp; -+ void *shared_intr_buf; -+ struct urb *shared_intr_urb; -+ struct usb_device *usb; -+ int use_count; -+ int ref_count; -+ struct mutex shared_int_lock; -+}; -+ -+struct hso_net { -+ struct hso_device *parent; -+ struct net_device *net; -+ struct rfkill *rfkill; -+ -+ struct usb_endpoint_descriptor *in_endp; -+ struct usb_endpoint_descriptor *out_endp; -+ -+ struct urb *mux_bulk_rx_urb_pool[MUX_BULK_RX_BUF_COUNT]; -+ struct urb *mux_bulk_tx_urb; -+ void *mux_bulk_rx_buf_pool[MUX_BULK_RX_BUF_COUNT]; -+ void *mux_bulk_tx_buf; -+ -+ struct sk_buff *skb_rx_buf; -+ struct sk_buff *skb_tx_buf; -+ -+ enum pkt_parse_state rx_parse_state; -+ spinlock_t net_lock; -+ -+ unsigned short rx_buf_size; -+ unsigned short rx_buf_missing; -+ struct iphdr rx_ip_hdr; -+ -+ unsigned long flags; -+}; -+ -+enum rx_ctrl_state{ -+ RX_IDLE, -+ RX_SENT, -+ RX_PENDING -+}; -+ -+#define BM_REQUEST_TYPE (0xa1) -+#define B_NOTIFICATION (0x20) -+#define W_VALUE (0x0) -+#define W_LENGTH (0x2) -+ -+#define B_OVERRUN (0x1<<6) -+#define B_PARITY (0x1<<5) -+#define B_FRAMING (0x1<<4) -+#define B_RING_SIGNAL (0x1<<3) -+#define B_BREAK (0x1<<2) -+#define B_TX_CARRIER (0x1<<1) -+#define B_RX_CARRIER (0x1<<0) -+ -+struct hso_serial_state_notification { -+ u8 bmRequestType; -+ u8 bNotification; -+ u16 wValue; -+ u16 wIndex; -+ u16 wLength; -+ u16 UART_state_bitmap; -+} __packed; -+ -+struct hso_tiocmget { -+ struct mutex mutex; -+ wait_queue_head_t waitq; -+ int intr_completed; -+ struct usb_endpoint_descriptor *endp; -+ struct urb *urb; -+ struct hso_serial_state_notification serial_state_notification; -+ u16 prev_UART_state_bitmap; -+ struct uart_icount icount; -+}; -+ -+ -+struct hso_serial { -+ struct hso_device *parent; -+ int magic; -+ u8 minor; -+ -+ struct hso_shared_int *shared_int; -+ -+ /* rx/tx urb could be either a bulk urb or a control urb depending -+ on which serial port it is used on. */ -+ struct urb *rx_urb[MAX_RX_URBS]; -+ u8 num_rx_urbs; -+ u8 *rx_data[MAX_RX_URBS]; -+ u16 rx_data_length; /* should contain allocated length */ -+ -+ struct urb *tx_urb; -+ u8 *tx_data; -+ u8 *tx_buffer; -+ u16 tx_data_length; /* should contain allocated length */ -+ u16 tx_data_count; -+ u16 tx_buffer_count; -+ struct usb_ctrlrequest ctrl_req_tx; -+ struct usb_ctrlrequest ctrl_req_rx; -+ -+ struct usb_endpoint_descriptor *in_endp; -+ struct usb_endpoint_descriptor *out_endp; -+ -+ enum rx_ctrl_state rx_state; -+ u8 rts_state; -+ u8 dtr_state; -+ unsigned tx_urb_used:1; -+ -+ struct tty_port port; -+ /* from usb_serial_port */ -+ spinlock_t serial_lock; -+ -+ int (*write_data) (struct hso_serial *serial); -+ struct hso_tiocmget *tiocmget; -+ /* Hacks required to get flow control -+ * working on the serial receive buffers -+ * so as not to drop characters on the floor. -+ */ -+ int curr_rx_urb_idx; -+ u8 rx_urb_filled[MAX_RX_URBS]; -+ struct tasklet_struct unthrottle_tasklet; -+}; -+ -+struct hso_device { -+ union { -+ struct hso_serial *dev_serial; -+ struct hso_net *dev_net; -+ } port_data; -+ -+ u32 port_spec; -+ -+ u8 is_active; -+ u8 usb_gone; -+ struct work_struct async_get_intf; -+ struct work_struct async_put_intf; -+ struct work_struct reset_device; -+ -+ struct usb_device *usb; -+ struct usb_interface *interface; -+ -+ struct device *dev; -+ struct kref ref; -+ struct mutex mutex; -+}; -+ -+/* Type of interface */ -+#define HSO_INTF_MASK 0xFF00 -+#define HSO_INTF_MUX 0x0100 -+#define HSO_INTF_BULK 0x0200 -+ -+/* Type of port */ -+#define HSO_PORT_MASK 0xFF -+#define HSO_PORT_NO_PORT 0x0 -+#define HSO_PORT_CONTROL 0x1 -+#define HSO_PORT_APP 0x2 -+#define HSO_PORT_GPS 0x3 -+#define HSO_PORT_PCSC 0x4 -+#define HSO_PORT_APP2 0x5 -+#define HSO_PORT_GPS_CONTROL 0x6 -+#define HSO_PORT_MSD 0x7 -+#define HSO_PORT_VOICE 0x8 -+#define HSO_PORT_DIAG2 0x9 -+#define HSO_PORT_DIAG 0x10 -+#define HSO_PORT_MODEM 0x11 -+#define HSO_PORT_NETWORK 0x12 -+ -+/* Additional device info */ -+#define HSO_INFO_MASK 0xFF000000 -+#define HSO_INFO_CRC_BUG 0x01000000 -+ -+/*****************************************************************************/ -+/* Prototypes */ -+/*****************************************************************************/ -+/* Serial driver functions */ -+static int hso_serial_tiocmset(struct tty_struct *tty, -+ unsigned int set, unsigned int clear); -+static void ctrl_callback(struct urb *urb); -+static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial); -+static void hso_kick_transmit(struct hso_serial *serial); -+/* Helper functions */ -+static int hso_mux_submit_intr_urb(struct hso_shared_int *mux_int, -+ struct usb_device *usb, gfp_t gfp); -+static void handle_usb_error(int status, const char *function, -+ struct hso_device *hso_dev); -+static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *intf, -+ int type, int dir); -+static int hso_get_mux_ports(struct usb_interface *intf, unsigned char *ports); -+static void hso_free_interface(struct usb_interface *intf); -+static int hso_start_serial_device(struct hso_device *hso_dev, gfp_t flags); -+static int hso_stop_serial_device(struct hso_device *hso_dev); -+static int hso_start_net_device(struct hso_device *hso_dev); -+static void hso_free_shared_int(struct hso_shared_int *shared_int); -+static int hso_stop_net_device(struct hso_device *hso_dev); -+static void hso_serial_ref_free(struct kref *ref); -+static void hso_std_serial_read_bulk_callback(struct urb *urb); -+static int hso_mux_serial_read(struct hso_serial *serial); -+static void async_get_intf(struct work_struct *data); -+static void async_put_intf(struct work_struct *data); -+static int hso_put_activity(struct hso_device *hso_dev); -+static int hso_get_activity(struct hso_device *hso_dev); -+static void tiocmget_intr_callback(struct urb *urb); -+static void reset_device(struct work_struct *data); -+/*****************************************************************************/ -+/* Helping functions */ -+/*****************************************************************************/ -+ -+/* #define DEBUG */ -+ -+static inline struct hso_net *dev2net(struct hso_device *hso_dev) -+{ -+ return hso_dev->port_data.dev_net; -+} -+ -+static inline struct hso_serial *dev2ser(struct hso_device *hso_dev) -+{ -+ return hso_dev->port_data.dev_serial; -+} -+ -+/* Debugging functions */ -+#ifdef DEBUG -+static void dbg_dump(int line_count, const char *func_name, unsigned char *buf, -+ unsigned int len) -+{ -+ static char name[255]; -+ -+ sprintf(name, "hso[%d:%s]", line_count, func_name); -+ print_hex_dump_bytes(name, DUMP_PREFIX_NONE, buf, len); -+} -+ -+#define DUMP(buf_, len_) \ -+ dbg_dump(__LINE__, __func__, (unsigned char *)buf_, len_) -+ -+#define DUMP1(buf_, len_) \ -+ do { \ -+ if (0x01 & debug) \ -+ DUMP(buf_, len_); \ -+ } while (0) -+#else -+#define DUMP(buf_, len_) -+#define DUMP1(buf_, len_) -+#endif -+ -+/* module parameters */ -+static int debug; -+static int tty_major; -+static int disable_net; -+ -+/* driver info */ -+static const char driver_name[] = "hso"; -+static const char tty_filename[] = "ttyHS"; -+static const char *version = __FILE__ ": " MOD_AUTHOR; -+/* the usb driver itself (registered in hso_init) */ -+static struct usb_driver hso_driver; -+/* serial structures */ -+static struct tty_driver *tty_drv; -+static struct hso_device *serial_table[HSO_SERIAL_TTY_MINORS]; -+static struct hso_device *network_table[HSO_MAX_NET_DEVICES]; -+static spinlock_t serial_table_lock; -+ -+static const s32 default_port_spec[] = { -+ HSO_INTF_MUX | HSO_PORT_NETWORK, -+ HSO_INTF_BULK | HSO_PORT_DIAG, -+ HSO_INTF_BULK | HSO_PORT_MODEM, -+ 0 -+}; -+ -+static const s32 icon321_port_spec[] = { -+ HSO_INTF_MUX | HSO_PORT_NETWORK, -+ HSO_INTF_BULK | HSO_PORT_DIAG2, -+ HSO_INTF_BULK | HSO_PORT_MODEM, -+ HSO_INTF_BULK | HSO_PORT_DIAG, -+ 0 -+}; -+ -+#define default_port_device(vendor, product) \ -+ USB_DEVICE(vendor, product), \ -+ .driver_info = (kernel_ulong_t)default_port_spec -+ -+#define icon321_port_device(vendor, product) \ -+ USB_DEVICE(vendor, product), \ -+ .driver_info = (kernel_ulong_t)icon321_port_spec -+ -+/* list of devices we support */ -+static const struct usb_device_id hso_ids[] = { -+ {default_port_device(0x0af0, 0x6711)}, -+ {default_port_device(0x0af0, 0x6731)}, -+ {default_port_device(0x0af0, 0x6751)}, -+ {default_port_device(0x0af0, 0x6771)}, -+ {default_port_device(0x0af0, 0x6791)}, -+ {default_port_device(0x0af0, 0x6811)}, -+ {default_port_device(0x0af0, 0x6911)}, -+ {default_port_device(0x0af0, 0x6951)}, -+ {default_port_device(0x0af0, 0x6971)}, -+ {default_port_device(0x0af0, 0x7011)}, -+ {default_port_device(0x0af0, 0x7031)}, -+ {default_port_device(0x0af0, 0x7051)}, -+ {default_port_device(0x0af0, 0x7071)}, -+ {default_port_device(0x0af0, 0x7111)}, -+ {default_port_device(0x0af0, 0x7211)}, -+ {default_port_device(0x0af0, 0x7251)}, -+ {default_port_device(0x0af0, 0x7271)}, -+ {default_port_device(0x0af0, 0x7311)}, -+ {default_port_device(0x0af0, 0xc031)}, /* Icon-Edge */ -+ {icon321_port_device(0x0af0, 0xd013)}, /* Module HSxPA */ -+ {icon321_port_device(0x0af0, 0xd031)}, /* Icon-321 */ -+ {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */ -+ {USB_DEVICE(0x0af0, 0x7301)}, /* GE40x */ -+ {USB_DEVICE(0x0af0, 0x7361)}, /* GE40x */ -+ {USB_DEVICE(0x0af0, 0x7381)}, /* GE40x */ -+ {USB_DEVICE(0x0af0, 0x7401)}, /* GI 0401 */ -+ {USB_DEVICE(0x0af0, 0x7501)}, /* GTM 382 */ -+ {USB_DEVICE(0x0af0, 0x7601)}, /* GE40x */ -+ {USB_DEVICE(0x0af0, 0x7701)}, -+ {USB_DEVICE(0x0af0, 0x7706)}, -+ {USB_DEVICE(0x0af0, 0x7801)}, -+ {USB_DEVICE(0x0af0, 0x7901)}, -+ {USB_DEVICE(0x0af0, 0x7A01)}, -+ {USB_DEVICE(0x0af0, 0x7A05)}, -+ {USB_DEVICE(0x0af0, 0x8200)}, -+ {USB_DEVICE(0x0af0, 0x8201)}, -+ {USB_DEVICE(0x0af0, 0x8300)}, -+ {USB_DEVICE(0x0af0, 0x8302)}, -+ {USB_DEVICE(0x0af0, 0x8304)}, -+ {USB_DEVICE(0x0af0, 0x8400)}, -+ {USB_DEVICE(0x0af0, 0x8600)}, -+ {USB_DEVICE(0x0af0, 0x8800)}, -+ {USB_DEVICE(0x0af0, 0x8900)}, -+ {USB_DEVICE(0x0af0, 0x9000)}, -+ {USB_DEVICE(0x0af0, 0x9200)}, /* Option GTM671WFS */ -+ {USB_DEVICE(0x0af0, 0xd035)}, -+ {USB_DEVICE(0x0af0, 0xd055)}, -+ {USB_DEVICE(0x0af0, 0xd155)}, -+ {USB_DEVICE(0x0af0, 0xd255)}, -+ {USB_DEVICE(0x0af0, 0xd057)}, -+ {USB_DEVICE(0x0af0, 0xd157)}, -+ {USB_DEVICE(0x0af0, 0xd257)}, -+ {USB_DEVICE(0x0af0, 0xd357)}, -+ {USB_DEVICE(0x0af0, 0xd058)}, -+ {USB_DEVICE(0x0af0, 0xc100)}, -+ {} -+}; -+MODULE_DEVICE_TABLE(usb, hso_ids); -+ -+/* Sysfs attribute */ -+static ssize_t hso_sysfs_show_porttype(struct device *dev, -+ struct device_attribute *attr, -+ char *buf) -+{ -+ struct hso_device *hso_dev = dev_get_drvdata(dev); -+ char *port_name; -+ -+ if (!hso_dev) -+ return 0; -+ -+ switch (hso_dev->port_spec & HSO_PORT_MASK) { -+ case HSO_PORT_CONTROL: -+ port_name = "Control"; -+ break; -+ case HSO_PORT_APP: -+ port_name = "Application"; -+ break; -+ case HSO_PORT_APP2: -+ port_name = "Application2"; -+ break; -+ case HSO_PORT_GPS: -+ port_name = "GPS"; -+ break; -+ case HSO_PORT_GPS_CONTROL: -+ port_name = "GPS Control"; -+ break; -+ case HSO_PORT_PCSC: -+ port_name = "PCSC"; -+ break; -+ case HSO_PORT_DIAG: -+ port_name = "Diagnostic"; -+ break; -+ case HSO_PORT_DIAG2: -+ port_name = "Diagnostic2"; -+ break; -+ case HSO_PORT_MODEM: -+ port_name = "Modem"; -+ break; -+ case HSO_PORT_NETWORK: -+ port_name = "Network"; -+ break; -+ default: -+ port_name = "Unknown"; -+ break; -+ } -+ -+ return sprintf(buf, "%s\n", port_name); -+} -+static DEVICE_ATTR(hsotype, S_IRUGO, hso_sysfs_show_porttype, NULL); -+ -+static int hso_urb_to_index(struct hso_serial *serial, struct urb *urb) -+{ -+ int idx; -+ -+ for (idx = 0; idx < serial->num_rx_urbs; idx++) -+ if (serial->rx_urb[idx] == urb) -+ return idx; -+ dev_err(serial->parent->dev, "hso_urb_to_index failed\n"); -+ return -1; -+} -+ -+/* converts mux value to a port spec value */ -+static u32 hso_mux_to_port(int mux) -+{ -+ u32 result; -+ -+ switch (mux) { -+ case 0x1: -+ result = HSO_PORT_CONTROL; -+ break; -+ case 0x2: -+ result = HSO_PORT_APP; -+ break; -+ case 0x4: -+ result = HSO_PORT_PCSC; -+ break; -+ case 0x8: -+ result = HSO_PORT_GPS; -+ break; -+ case 0x10: -+ result = HSO_PORT_APP2; -+ break; -+ default: -+ result = HSO_PORT_NO_PORT; -+ } -+ return result; -+} -+ -+/* converts port spec value to a mux value */ -+static u32 hso_port_to_mux(int port) -+{ -+ u32 result; -+ -+ switch (port & HSO_PORT_MASK) { -+ case HSO_PORT_CONTROL: -+ result = 0x0; -+ break; -+ case HSO_PORT_APP: -+ result = 0x1; -+ break; -+ case HSO_PORT_PCSC: -+ result = 0x2; -+ break; -+ case HSO_PORT_GPS: -+ result = 0x3; -+ break; -+ case HSO_PORT_APP2: -+ result = 0x4; -+ break; -+ default: -+ result = 0x0; -+ } -+ return result; -+} -+ -+static struct hso_serial *get_serial_by_shared_int_and_type( -+ struct hso_shared_int *shared_int, -+ int mux) -+{ -+ int i, port; -+ -+ port = hso_mux_to_port(mux); -+ -+ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { -+ if (serial_table[i] && -+ (dev2ser(serial_table[i])->shared_int == shared_int) && -+ ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) { -+ return dev2ser(serial_table[i]); -+ } -+ } -+ -+ return NULL; -+} -+ -+static struct hso_serial *get_serial_by_index(unsigned index) -+{ -+ struct hso_serial *serial = NULL; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&serial_table_lock, flags); -+ if (serial_table[index]) -+ serial = dev2ser(serial_table[index]); -+ spin_unlock_irqrestore(&serial_table_lock, flags); -+ -+ return serial; -+} -+ -+static int get_free_serial_index(void) -+{ -+ int index; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&serial_table_lock, flags); -+ for (index = 0; index < HSO_SERIAL_TTY_MINORS; index++) { -+ if (serial_table[index] == NULL) { -+ spin_unlock_irqrestore(&serial_table_lock, flags); -+ return index; -+ } -+ } -+ spin_unlock_irqrestore(&serial_table_lock, flags); -+ -+ printk(KERN_ERR "%s: no free serial devices in table\n", __func__); -+ return -1; -+} -+ -+static void set_serial_by_index(unsigned index, struct hso_serial *serial) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&serial_table_lock, flags); -+ if (serial) -+ serial_table[index] = serial->parent; -+ else -+ serial_table[index] = NULL; -+ spin_unlock_irqrestore(&serial_table_lock, flags); -+} -+ -+static void handle_usb_error(int status, const char *function, -+ struct hso_device *hso_dev) -+{ -+ char *explanation; -+ -+ switch (status) { -+ case -ENODEV: -+ explanation = "no device"; -+ break; -+ case -ENOENT: -+ explanation = "endpoint not enabled"; -+ break; -+ case -EPIPE: -+ explanation = "endpoint stalled"; -+ break; -+ case -ENOSPC: -+ explanation = "not enough bandwidth"; -+ break; -+ case -ESHUTDOWN: -+ explanation = "device disabled"; -+ break; -+ case -EHOSTUNREACH: -+ explanation = "device suspended"; -+ break; -+ case -EINVAL: -+ case -EAGAIN: -+ case -EFBIG: -+ case -EMSGSIZE: -+ explanation = "internal error"; -+ break; -+ case -EILSEQ: -+ case -EPROTO: -+ case -ETIME: -+ case -ETIMEDOUT: -+ explanation = "protocol error"; -+ if (hso_dev) -+ schedule_work(&hso_dev->reset_device); -+ break; -+ default: -+ explanation = "unknown status"; -+ break; -+ } -+ -+ /* log a meaningful explanation of an USB status */ -+ D1("%s: received USB status - %s (%d)", function, explanation, status); -+} -+ -+/* Network interface functions */ -+ -+/* called when net interface is brought up by ifconfig */ -+static int hso_net_open(struct net_device *net) -+{ -+ struct hso_net *odev = netdev_priv(net); -+ unsigned long flags = 0; -+ -+ if (!odev) { -+ dev_err(&net->dev, "No net device !\n"); -+ return -ENODEV; -+ } -+ -+ odev->skb_tx_buf = NULL; -+ -+ /* setup environment */ -+ spin_lock_irqsave(&odev->net_lock, flags); -+ odev->rx_parse_state = WAIT_IP; -+ odev->rx_buf_size = 0; -+ odev->rx_buf_missing = sizeof(struct iphdr); -+ spin_unlock_irqrestore(&odev->net_lock, flags); -+ -+ /* We are up and running. */ -+ set_bit(HSO_NET_RUNNING, &odev->flags); -+ hso_start_net_device(odev->parent); -+ -+ /* Tell the kernel we are ready to start receiving from it */ -+ netif_start_queue(net); -+ -+ return 0; -+} -+ -+/* called when interface is brought down by ifconfig */ -+static int hso_net_close(struct net_device *net) -+{ -+ struct hso_net *odev = netdev_priv(net); -+ -+ /* we don't need the queue anymore */ -+ netif_stop_queue(net); -+ /* no longer running */ -+ clear_bit(HSO_NET_RUNNING, &odev->flags); -+ -+ hso_stop_net_device(odev->parent); -+ -+ /* done */ -+ return 0; -+} -+ -+/* USB tells is xmit done, we should start the netqueue again */ -+static void write_bulk_callback(struct urb *urb) -+{ -+ struct hso_net *odev = urb->context; -+ int status = urb->status; -+ -+ /* Sanity check */ -+ if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { -+ dev_err(&urb->dev->dev, "%s: device not running\n", __func__); -+ return; -+ } -+ -+ /* Do we still have a valid kernel network device? */ -+ if (!netif_device_present(odev->net)) { -+ dev_err(&urb->dev->dev, "%s: net device not present\n", -+ __func__); -+ return; -+ } -+ -+ /* log status, but don't act on it, we don't need to resubmit anything -+ * anyhow */ -+ if (status) -+ handle_usb_error(status, __func__, odev->parent); -+ -+ hso_put_activity(odev->parent); -+ -+ /* Tell the network interface we are ready for another frame */ -+ netif_wake_queue(odev->net); -+} -+ -+/* called by kernel when we need to transmit a packet */ -+static netdev_tx_t hso_net_start_xmit(struct sk_buff *skb, -+ struct net_device *net) -+{ -+ struct hso_net *odev = netdev_priv(net); -+ int result; -+ -+ /* Tell the kernel, "No more frames 'til we are done with this one." */ -+ netif_stop_queue(net); -+ if (hso_get_activity(odev->parent) == -EAGAIN) { -+ odev->skb_tx_buf = skb; -+ return NETDEV_TX_OK; -+ } -+ -+ /* log if asked */ -+ DUMP1(skb->data, skb->len); -+ /* Copy it from kernel memory to OUR memory */ -+ memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len); -+ D1("len: %d/%d", skb->len, MUX_BULK_TX_BUF_SIZE); -+ -+ /* Fill in the URB for shipping it out. */ -+ usb_fill_bulk_urb(odev->mux_bulk_tx_urb, -+ odev->parent->usb, -+ usb_sndbulkpipe(odev->parent->usb, -+ odev->out_endp-> -+ bEndpointAddress & 0x7F), -+ odev->mux_bulk_tx_buf, skb->len, write_bulk_callback, -+ odev); -+ -+ /* Deal with the Zero Length packet problem, I hope */ -+ odev->mux_bulk_tx_urb->transfer_flags |= URB_ZERO_PACKET; -+ -+ /* Send the URB on its merry way. */ -+ result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); -+ if (result) { -+ dev_warn(&odev->parent->interface->dev, -+ "failed mux_bulk_tx_urb %d\n", result); -+ net->stats.tx_errors++; -+ netif_start_queue(net); -+ } else { -+ net->stats.tx_packets++; -+ net->stats.tx_bytes += skb->len; -+ } -+ dev_kfree_skb(skb); -+ /* we're done */ -+ return NETDEV_TX_OK; -+} -+ -+static const struct ethtool_ops ops = { -+ .get_link = ethtool_op_get_link -+}; -+ -+/* called when a packet did not ack after watchdogtimeout */ -+static void hso_net_tx_timeout(struct net_device *net) -+{ -+ struct hso_net *odev = netdev_priv(net); -+ -+ if (!odev) -+ return; -+ -+ /* Tell syslog we are hosed. */ -+ dev_warn(&net->dev, "Tx timed out.\n"); -+ -+ /* Tear the waiting frame off the list */ -+ if (odev->mux_bulk_tx_urb && -+ (odev->mux_bulk_tx_urb->status == -EINPROGRESS)) -+ usb_unlink_urb(odev->mux_bulk_tx_urb); -+ -+ /* Update statistics */ -+ net->stats.tx_errors++; -+} -+ -+/* make a real packet from the received USB buffer */ -+static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt, -+ unsigned int count, unsigned char is_eop) -+{ -+ unsigned short temp_bytes; -+ unsigned short buffer_offset = 0; -+ unsigned short frame_len; -+ unsigned char *tmp_rx_buf; -+ -+ /* log if needed */ -+ D1("Rx %d bytes", count); -+ DUMP(ip_pkt, min(128, (int)count)); -+ -+ while (count) { -+ switch (odev->rx_parse_state) { -+ case WAIT_IP: -+ /* waiting for IP header. */ -+ /* wanted bytes - size of ip header */ -+ temp_bytes = -+ (count < -+ odev->rx_buf_missing) ? count : odev-> -+ rx_buf_missing; -+ -+ memcpy(((unsigned char *)(&odev->rx_ip_hdr)) + -+ odev->rx_buf_size, ip_pkt + buffer_offset, -+ temp_bytes); -+ -+ odev->rx_buf_size += temp_bytes; -+ buffer_offset += temp_bytes; -+ odev->rx_buf_missing -= temp_bytes; -+ count -= temp_bytes; -+ -+ if (!odev->rx_buf_missing) { -+ /* header is complete allocate an sk_buffer and -+ * continue to WAIT_DATA */ -+ frame_len = ntohs(odev->rx_ip_hdr.tot_len); -+ -+ if ((frame_len > DEFAULT_MRU) || -+ (frame_len < sizeof(struct iphdr))) { -+ dev_err(&odev->net->dev, -+ "Invalid frame (%d) length\n", -+ frame_len); -+ odev->rx_parse_state = WAIT_SYNC; -+ continue; -+ } -+ /* Allocate an sk_buff */ -+ odev->skb_rx_buf = netdev_alloc_skb(odev->net, -+ frame_len); -+ if (!odev->skb_rx_buf) { -+ /* We got no receive buffer. */ -+ D1("could not allocate memory"); -+ odev->rx_parse_state = WAIT_SYNC; -+ return; -+ } -+ -+ /* Copy what we got so far. make room for iphdr -+ * after tail. */ -+ tmp_rx_buf = -+ skb_put(odev->skb_rx_buf, -+ sizeof(struct iphdr)); -+ memcpy(tmp_rx_buf, (char *)&(odev->rx_ip_hdr), -+ sizeof(struct iphdr)); -+ -+ /* ETH_HLEN */ -+ odev->rx_buf_size = sizeof(struct iphdr); -+ -+ /* Filip actually use .tot_len */ -+ odev->rx_buf_missing = -+ frame_len - sizeof(struct iphdr); -+ odev->rx_parse_state = WAIT_DATA; -+ } -+ break; -+ -+ case WAIT_DATA: -+ temp_bytes = (count < odev->rx_buf_missing) -+ ? count : odev->rx_buf_missing; -+ -+ /* Copy the rest of the bytes that are left in the -+ * buffer into the waiting sk_buf. */ -+ /* Make room for temp_bytes after tail. */ -+ tmp_rx_buf = skb_put(odev->skb_rx_buf, temp_bytes); -+ memcpy(tmp_rx_buf, ip_pkt + buffer_offset, temp_bytes); -+ -+ odev->rx_buf_missing -= temp_bytes; -+ count -= temp_bytes; -+ buffer_offset += temp_bytes; -+ odev->rx_buf_size += temp_bytes; -+ if (!odev->rx_buf_missing) { -+ /* Packet is complete. Inject into stack. */ -+ /* We have IP packet here */ -+ odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); -+ skb_reset_mac_header(odev->skb_rx_buf); -+ -+ /* Ship it off to the kernel */ -+ netif_rx(odev->skb_rx_buf); -+ /* No longer our buffer. */ -+ odev->skb_rx_buf = NULL; -+ -+ /* update out statistics */ -+ odev->net->stats.rx_packets++; -+ -+ odev->net->stats.rx_bytes += odev->rx_buf_size; -+ -+ odev->rx_buf_size = 0; -+ odev->rx_buf_missing = sizeof(struct iphdr); -+ odev->rx_parse_state = WAIT_IP; -+ } -+ break; -+ -+ case WAIT_SYNC: -+ D1(" W_S"); -+ count = 0; -+ break; -+ default: -+ D1(" "); -+ count--; -+ break; -+ } -+ } -+ -+ /* Recovery mechanism for WAIT_SYNC state. */ -+ if (is_eop) { -+ if (odev->rx_parse_state == WAIT_SYNC) { -+ odev->rx_parse_state = WAIT_IP; -+ odev->rx_buf_size = 0; -+ odev->rx_buf_missing = sizeof(struct iphdr); -+ } -+ } -+} -+ -+static void fix_crc_bug(struct urb *urb, __le16 max_packet_size) -+{ -+ static const u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; -+ u32 rest = urb->actual_length % le16_to_cpu(max_packet_size); -+ -+ if (((rest == 5) || (rest == 6)) && -+ !memcmp(((u8 *)urb->transfer_buffer) + urb->actual_length - 4, -+ crc_check, 4)) { -+ urb->actual_length -= 4; -+ } -+} -+ -+/* Moving data from usb to kernel (in interrupt state) */ -+static void read_bulk_callback(struct urb *urb) -+{ -+ struct hso_net *odev = urb->context; -+ struct net_device *net; -+ int result; -+ int status = urb->status; -+ -+ /* is al ok? (Filip: Who's Al ?) */ -+ if (status) { -+ handle_usb_error(status, __func__, odev->parent); -+ return; -+ } -+ -+ /* Sanity check */ -+ if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { -+ D1("BULK IN callback but driver is not active!"); -+ return; -+ } -+ usb_mark_last_busy(urb->dev); -+ -+ net = odev->net; -+ -+ if (!netif_device_present(net)) { -+ /* Somebody killed our network interface... */ -+ return; -+ } -+ -+ if (odev->parent->port_spec & HSO_INFO_CRC_BUG) -+ fix_crc_bug(urb, odev->in_endp->wMaxPacketSize); -+ -+ /* do we even have a packet? */ -+ if (urb->actual_length) { -+ /* Handle the IP stream, add header and push it onto network -+ * stack if the packet is complete. */ -+ spin_lock(&odev->net_lock); -+ packetizeRx(odev, urb->transfer_buffer, urb->actual_length, -+ (urb->transfer_buffer_length > -+ urb->actual_length) ? 1 : 0); -+ spin_unlock(&odev->net_lock); -+ } -+ -+ /* We are done with this URB, resubmit it. Prep the USB to wait for -+ * another frame. Reuse same as received. */ -+ usb_fill_bulk_urb(urb, -+ odev->parent->usb, -+ usb_rcvbulkpipe(odev->parent->usb, -+ odev->in_endp-> -+ bEndpointAddress & 0x7F), -+ urb->transfer_buffer, MUX_BULK_RX_BUF_SIZE, -+ read_bulk_callback, odev); -+ -+ /* Give this to the USB subsystem so it can tell us when more data -+ * arrives. */ -+ result = usb_submit_urb(urb, GFP_ATOMIC); -+ if (result) -+ dev_warn(&odev->parent->interface->dev, -+ "%s failed submit mux_bulk_rx_urb %d\n", __func__, -+ result); -+} -+ -+/* Serial driver functions */ -+ -+static void hso_init_termios(struct ktermios *termios) -+{ -+ /* -+ * The default requirements for this device are: -+ */ -+ termios->c_iflag &= -+ ~(IGNBRK /* disable ignore break */ -+ | BRKINT /* disable break causes interrupt */ -+ | PARMRK /* disable mark parity errors */ -+ | ISTRIP /* disable clear high bit of input characters */ -+ | INLCR /* disable translate NL to CR */ -+ | IGNCR /* disable ignore CR */ -+ | ICRNL /* disable translate CR to NL */ -+ | IXON); /* disable enable XON/XOFF flow control */ -+ -+ /* disable postprocess output characters */ -+ termios->c_oflag &= ~OPOST; -+ -+ termios->c_lflag &= -+ ~(ECHO /* disable echo input characters */ -+ | ECHONL /* disable echo new line */ -+ | ICANON /* disable erase, kill, werase, and rprnt -+ special characters */ -+ | ISIG /* disable interrupt, quit, and suspend special -+ characters */ -+ | IEXTEN); /* disable non-POSIX special characters */ -+ -+ termios->c_cflag &= -+ ~(CSIZE /* no size */ -+ | PARENB /* disable parity bit */ -+ | CBAUD /* clear current baud rate */ -+ | CBAUDEX); /* clear current buad rate */ -+ -+ termios->c_cflag |= CS8; /* character size 8 bits */ -+ -+ /* baud rate 115200 */ -+ tty_termios_encode_baud_rate(termios, 115200, 115200); -+} -+ -+static void _hso_serial_set_termios(struct tty_struct *tty, -+ struct ktermios *old) -+{ -+ struct hso_serial *serial = tty->driver_data; -+ -+ if (!serial) { -+ printk(KERN_ERR "%s: no tty structures", __func__); -+ return; -+ } -+ -+ D4("port %d", serial->minor); -+ -+ /* -+ * Fix up unsupported bits -+ */ -+ tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ -+ -+ tty->termios.c_cflag &= -+ ~(CSIZE /* no size */ -+ | PARENB /* disable parity bit */ -+ | CBAUD /* clear current baud rate */ -+ | CBAUDEX); /* clear current buad rate */ -+ -+ tty->termios.c_cflag |= CS8; /* character size 8 bits */ -+ -+ /* baud rate 115200 */ -+ tty_encode_baud_rate(tty, 115200, 115200); -+} -+ -+static void hso_resubmit_rx_bulk_urb(struct hso_serial *serial, struct urb *urb) -+{ -+ int result; -+ /* We are done with this URB, resubmit it. Prep the USB to wait for -+ * another frame */ -+ usb_fill_bulk_urb(urb, serial->parent->usb, -+ usb_rcvbulkpipe(serial->parent->usb, -+ serial->in_endp-> -+ bEndpointAddress & 0x7F), -+ urb->transfer_buffer, serial->rx_data_length, -+ hso_std_serial_read_bulk_callback, serial); -+ /* Give this to the USB subsystem so it can tell us when more data -+ * arrives. */ -+ result = usb_submit_urb(urb, GFP_ATOMIC); -+ if (result) { -+ dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d\n", -+ __func__, result); -+ } -+} -+ -+ -+ -+ -+static void put_rxbuf_data_and_resubmit_bulk_urb(struct hso_serial *serial) -+{ -+ int count; -+ struct urb *curr_urb; -+ -+ while (serial->rx_urb_filled[serial->curr_rx_urb_idx]) { -+ curr_urb = serial->rx_urb[serial->curr_rx_urb_idx]; -+ count = put_rxbuf_data(curr_urb, serial); -+ if (count == -1) -+ return; -+ if (count == 0) { -+ serial->curr_rx_urb_idx++; -+ if (serial->curr_rx_urb_idx >= serial->num_rx_urbs) -+ serial->curr_rx_urb_idx = 0; -+ hso_resubmit_rx_bulk_urb(serial, curr_urb); -+ } -+ } -+} -+ -+static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial) -+{ -+ int count = 0; -+ struct urb *urb; -+ -+ urb = serial->rx_urb[0]; -+ if (atomic_read(&serial->port.count) > 0) { -+ count = put_rxbuf_data(urb, serial); -+ if (count == -1) -+ return; -+ } -+ /* Re issue a read as long as we receive data. */ -+ -+ if (count == 0 && ((urb->actual_length != 0) || -+ (serial->rx_state == RX_PENDING))) { -+ serial->rx_state = RX_SENT; -+ hso_mux_serial_read(serial); -+ } else -+ serial->rx_state = RX_IDLE; -+} -+ -+ -+/* read callback for Diag and CS port */ -+static void hso_std_serial_read_bulk_callback(struct urb *urb) -+{ -+ struct hso_serial *serial = urb->context; -+ int status = urb->status; -+ -+ D4("\n--- Got serial_read_bulk callback %02x ---", status); -+ -+ /* sanity check */ -+ if (!serial) { -+ D1("serial == NULL"); -+ return; -+ } -+ if (status) { -+ handle_usb_error(status, __func__, serial->parent); -+ return; -+ } -+ -+ D1("Actual length = %d\n", urb->actual_length); -+ DUMP1(urb->transfer_buffer, urb->actual_length); -+ -+ /* Anyone listening? */ -+ if (atomic_read(&serial->port.count) == 0) -+ return; -+ -+ if (serial->parent->port_spec & HSO_INFO_CRC_BUG) -+ fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); -+ /* Valid data, handle RX data */ -+ spin_lock(&serial->serial_lock); -+ serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; -+ put_rxbuf_data_and_resubmit_bulk_urb(serial); -+ spin_unlock(&serial->serial_lock); -+} -+ -+/* -+ * This needs to be a tasklet otherwise we will -+ * end up recursively calling this function. -+ */ -+static void hso_unthrottle_tasklet(struct hso_serial *serial) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&serial->serial_lock, flags); -+ if ((serial->parent->port_spec & HSO_INTF_MUX)) -+ put_rxbuf_data_and_resubmit_ctrl_urb(serial); -+ else -+ put_rxbuf_data_and_resubmit_bulk_urb(serial); -+ spin_unlock_irqrestore(&serial->serial_lock, flags); -+} -+ -+static void hso_unthrottle(struct tty_struct *tty) -+{ -+ struct hso_serial *serial = tty->driver_data; -+ -+ tasklet_hi_schedule(&serial->unthrottle_tasklet); -+} -+ -+/* open the requested serial port */ -+static int hso_serial_open(struct tty_struct *tty, struct file *filp) -+{ -+ struct hso_serial *serial = get_serial_by_index(tty->index); -+ int result; -+ -+ /* sanity check */ -+ if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) { -+ WARN_ON(1); -+ tty->driver_data = NULL; -+ D1("Failed to open port"); -+ return -ENODEV; -+ } -+ -+ mutex_lock(&serial->parent->mutex); -+ result = usb_autopm_get_interface(serial->parent->interface); -+ if (result < 0) -+ goto err_out; -+ -+ D1("Opening %d", serial->minor); -+ kref_get(&serial->parent->ref); -+ -+ /* setup */ -+ tty->driver_data = serial; -+ tty_port_tty_set(&serial->port, tty); -+ -+ /* check for port already opened, if not set the termios */ -+ if (atomic_inc_return(&serial->port.count) == 1) { -+ serial->rx_state = RX_IDLE; -+ /* Force default termio settings */ -+ _hso_serial_set_termios(tty, NULL); -+ tasklet_init(&serial->unthrottle_tasklet, -+ (void (*)(unsigned long))hso_unthrottle_tasklet, -+ (unsigned long)serial); -+ result = hso_start_serial_device(serial->parent, GFP_KERNEL); -+ if (result) { -+ hso_stop_serial_device(serial->parent); -+ atomic_dec(&serial->port.count); -+ kref_put(&serial->parent->ref, hso_serial_ref_free); -+ } -+ } else { -+ D1("Port was already open"); -+ } -+ -+ usb_autopm_put_interface(serial->parent->interface); -+ -+ /* done */ -+ if (result) -+ hso_serial_tiocmset(tty, TIOCM_RTS | TIOCM_DTR, 0); -+err_out: -+ mutex_unlock(&serial->parent->mutex); -+ return result; -+} -+ -+/* close the requested serial port */ -+static void hso_serial_close(struct tty_struct *tty, struct file *filp) -+{ -+ struct hso_serial *serial = tty->driver_data; -+ u8 usb_gone; -+ -+ D1("Closing serial port"); -+ -+ /* Open failed, no close cleanup required */ -+ if (serial == NULL) -+ return; -+ -+ mutex_lock(&serial->parent->mutex); -+ usb_gone = serial->parent->usb_gone; -+ -+ if (!usb_gone) -+ usb_autopm_get_interface(serial->parent->interface); -+ -+ /* reset the rts and dtr */ -+ /* do the actual close */ -+ atomic_dec(&serial->port.count); -+ -+ if (atomic_read(&serial->port.count) <= 0) { -+ atomic_set(&serial->port.count, 0); -+ tty_port_tty_set(&serial->port, NULL); -+ if (!usb_gone) -+ hso_stop_serial_device(serial->parent); -+ tasklet_kill(&serial->unthrottle_tasklet); -+ } -+ -+ if (!usb_gone) -+ usb_autopm_put_interface(serial->parent->interface); -+ -+ mutex_unlock(&serial->parent->mutex); -+ -+ kref_put(&serial->parent->ref, hso_serial_ref_free); -+} -+ -+/* close the requested serial port */ -+static int hso_serial_write(struct tty_struct *tty, const unsigned char *buf, -+ int count) -+{ -+ struct hso_serial *serial = tty->driver_data; -+ int space, tx_bytes; -+ unsigned long flags; -+ -+ /* sanity check */ -+ if (serial == NULL) { -+ printk(KERN_ERR "%s: serial is NULL\n", __func__); -+ return -ENODEV; -+ } -+ -+ spin_lock_irqsave(&serial->serial_lock, flags); -+ -+ space = serial->tx_data_length - serial->tx_buffer_count; -+ tx_bytes = (count < space) ? count : space; -+ -+ if (!tx_bytes) -+ goto out; -+ -+ memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); -+ serial->tx_buffer_count += tx_bytes; -+ -+out: -+ spin_unlock_irqrestore(&serial->serial_lock, flags); -+ -+ hso_kick_transmit(serial); -+ /* done */ -+ return tx_bytes; -+} -+ -+/* how much room is there for writing */ -+static int hso_serial_write_room(struct tty_struct *tty) -+{ -+ struct hso_serial *serial = tty->driver_data; -+ int room; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&serial->serial_lock, flags); -+ room = serial->tx_data_length - serial->tx_buffer_count; -+ spin_unlock_irqrestore(&serial->serial_lock, flags); -+ -+ /* return free room */ -+ return room; -+} -+ -+/* setup the term */ -+static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old) -+{ -+ struct hso_serial *serial = tty->driver_data; -+ unsigned long flags; -+ -+ if (old) -+ D5("Termios called with: cflags new[%d] - old[%d]", -+ tty->termios.c_cflag, old->c_cflag); -+ -+ /* the actual setup */ -+ spin_lock_irqsave(&serial->serial_lock, flags); -+ if (atomic_read(&serial->port.count)) -+ _hso_serial_set_termios(tty, old); -+ else -+ tty->termios = *old; -+ spin_unlock_irqrestore(&serial->serial_lock, flags); -+ -+ /* done */ -+} -+ -+/* how many characters in the buffer */ -+static int hso_serial_chars_in_buffer(struct tty_struct *tty) -+{ -+ struct hso_serial *serial = tty->driver_data; -+ int chars; -+ unsigned long flags; -+ -+ /* sanity check */ -+ if (serial == NULL) -+ return 0; -+ -+ spin_lock_irqsave(&serial->serial_lock, flags); -+ chars = serial->tx_buffer_count; -+ spin_unlock_irqrestore(&serial->serial_lock, flags); -+ -+ return chars; -+} -+static int tiocmget_submit_urb(struct hso_serial *serial, -+ struct hso_tiocmget *tiocmget, -+ struct usb_device *usb) -+{ -+ int result; -+ -+ if (serial->parent->usb_gone) -+ return -ENODEV; -+ usb_fill_int_urb(tiocmget->urb, usb, -+ usb_rcvintpipe(usb, -+ tiocmget->endp-> -+ bEndpointAddress & 0x7F), -+ &tiocmget->serial_state_notification, -+ sizeof(struct hso_serial_state_notification), -+ tiocmget_intr_callback, serial, -+ tiocmget->endp->bInterval); -+ result = usb_submit_urb(tiocmget->urb, GFP_ATOMIC); -+ if (result) { -+ dev_warn(&usb->dev, "%s usb_submit_urb failed %d\n", __func__, -+ result); -+ } -+ return result; -+ -+} -+ -+static void tiocmget_intr_callback(struct urb *urb) -+{ -+ struct hso_serial *serial = urb->context; -+ struct hso_tiocmget *tiocmget; -+ int status = urb->status; -+ u16 UART_state_bitmap, prev_UART_state_bitmap; -+ struct uart_icount *icount; -+ struct hso_serial_state_notification *serial_state_notification; -+ struct usb_device *usb; -+ int if_num; -+ -+ /* Sanity checks */ -+ if (!serial) -+ return; -+ if (status) { -+ handle_usb_error(status, __func__, serial->parent); -+ return; -+ } -+ -+ /* tiocmget is only supported on HSO_PORT_MODEM */ -+ tiocmget = serial->tiocmget; -+ if (!tiocmget) -+ return; -+ BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM); -+ -+ usb = serial->parent->usb; -+ if_num = serial->parent->interface->altsetting->desc.bInterfaceNumber; -+ -+ /* wIndex should be the USB interface number of the port to which the -+ * notification applies, which should always be the Modem port. -+ */ -+ serial_state_notification = &tiocmget->serial_state_notification; -+ if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || -+ serial_state_notification->bNotification != B_NOTIFICATION || -+ le16_to_cpu(serial_state_notification->wValue) != W_VALUE || -+ le16_to_cpu(serial_state_notification->wIndex) != if_num || -+ le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) { -+ dev_warn(&usb->dev, -+ "hso received invalid serial state notification\n"); -+ DUMP(serial_state_notification, -+ sizeof(struct hso_serial_state_notification)); -+ } else { -+ -+ UART_state_bitmap = le16_to_cpu(serial_state_notification-> -+ UART_state_bitmap); -+ prev_UART_state_bitmap = tiocmget->prev_UART_state_bitmap; -+ icount = &tiocmget->icount; -+ spin_lock(&serial->serial_lock); -+ if ((UART_state_bitmap & B_OVERRUN) != -+ (prev_UART_state_bitmap & B_OVERRUN)) -+ icount->parity++; -+ if ((UART_state_bitmap & B_PARITY) != -+ (prev_UART_state_bitmap & B_PARITY)) -+ icount->parity++; -+ if ((UART_state_bitmap & B_FRAMING) != -+ (prev_UART_state_bitmap & B_FRAMING)) -+ icount->frame++; -+ if ((UART_state_bitmap & B_RING_SIGNAL) && -+ !(prev_UART_state_bitmap & B_RING_SIGNAL)) -+ icount->rng++; -+ if ((UART_state_bitmap & B_BREAK) != -+ (prev_UART_state_bitmap & B_BREAK)) -+ icount->brk++; -+ if ((UART_state_bitmap & B_TX_CARRIER) != -+ (prev_UART_state_bitmap & B_TX_CARRIER)) -+ icount->dsr++; -+ if ((UART_state_bitmap & B_RX_CARRIER) != -+ (prev_UART_state_bitmap & B_RX_CARRIER)) -+ icount->dcd++; -+ tiocmget->prev_UART_state_bitmap = UART_state_bitmap; -+ spin_unlock(&serial->serial_lock); -+ tiocmget->intr_completed = 1; -+ wake_up_interruptible(&tiocmget->waitq); -+ } -+ memset(serial_state_notification, 0, -+ sizeof(struct hso_serial_state_notification)); -+ tiocmget_submit_urb(serial, -+ tiocmget, -+ serial->parent->usb); -+} -+ -+/* -+ * next few functions largely stolen from drivers/serial/serial_core.c -+ */ -+/* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change -+ * - mask passed in arg for lines of interest -+ * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) -+ * Caller should use TIOCGICOUNT to see which one it was -+ */ -+static int -+hso_wait_modem_status(struct hso_serial *serial, unsigned long arg) -+{ -+ DECLARE_WAITQUEUE(wait, current); -+ struct uart_icount cprev, cnow; -+ struct hso_tiocmget *tiocmget; -+ int ret; -+ -+ tiocmget = serial->tiocmget; -+ if (!tiocmget) -+ return -ENOENT; -+ /* -+ * note the counters on entry -+ */ -+ spin_lock_irq(&serial->serial_lock); -+ memcpy(&cprev, &tiocmget->icount, sizeof(struct uart_icount)); -+ spin_unlock_irq(&serial->serial_lock); -+ add_wait_queue(&tiocmget->waitq, &wait); -+ for (;;) { -+ spin_lock_irq(&serial->serial_lock); -+ memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); -+ spin_unlock_irq(&serial->serial_lock); -+ set_current_state(TASK_INTERRUPTIBLE); -+ if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || -+ ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || -+ ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd))) { -+ ret = 0; -+ break; -+ } -+ schedule(); -+ /* see if a signal did it */ -+ if (signal_pending(current)) { -+ ret = -ERESTARTSYS; -+ break; -+ } -+ cprev = cnow; -+ } -+ current->state = TASK_RUNNING; -+ remove_wait_queue(&tiocmget->waitq, &wait); -+ -+ return ret; -+} -+ -+/* -+ * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) -+ * Return: write counters to the user passed counter struct -+ * NB: both 1->0 and 0->1 transitions are counted except for -+ * RI where only 0->1 is counted. -+ */ -+static int hso_get_count(struct tty_struct *tty, -+ struct serial_icounter_struct *icount) -+{ -+ struct uart_icount cnow; -+ struct hso_serial *serial = tty->driver_data; -+ struct hso_tiocmget *tiocmget = serial->tiocmget; -+ -+ memset(icount, 0, sizeof(struct serial_icounter_struct)); -+ -+ if (!tiocmget) -+ return -ENOENT; -+ spin_lock_irq(&serial->serial_lock); -+ memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); -+ spin_unlock_irq(&serial->serial_lock); -+ -+ icount->cts = cnow.cts; -+ icount->dsr = cnow.dsr; -+ icount->rng = cnow.rng; -+ icount->dcd = cnow.dcd; -+ icount->rx = cnow.rx; -+ icount->tx = cnow.tx; -+ icount->frame = cnow.frame; -+ icount->overrun = cnow.overrun; -+ icount->parity = cnow.parity; -+ icount->brk = cnow.brk; -+ icount->buf_overrun = cnow.buf_overrun; -+ -+ return 0; -+} -+ -+ -+static int hso_serial_tiocmget(struct tty_struct *tty) -+{ -+ int retval; -+ struct hso_serial *serial = tty->driver_data; -+ struct hso_tiocmget *tiocmget; -+ u16 UART_state_bitmap; -+ -+ /* sanity check */ -+ if (!serial) { -+ D1("no tty structures"); -+ return -EINVAL; -+ } -+ spin_lock_irq(&serial->serial_lock); -+ retval = ((serial->rts_state) ? TIOCM_RTS : 0) | -+ ((serial->dtr_state) ? TIOCM_DTR : 0); -+ tiocmget = serial->tiocmget; -+ if (tiocmget) { -+ -+ UART_state_bitmap = le16_to_cpu( -+ tiocmget->prev_UART_state_bitmap); -+ if (UART_state_bitmap & B_RING_SIGNAL) -+ retval |= TIOCM_RNG; -+ if (UART_state_bitmap & B_RX_CARRIER) -+ retval |= TIOCM_CD; -+ if (UART_state_bitmap & B_TX_CARRIER) -+ retval |= TIOCM_DSR; -+ } -+ spin_unlock_irq(&serial->serial_lock); -+ return retval; -+} -+ -+static int hso_serial_tiocmset(struct tty_struct *tty, -+ unsigned int set, unsigned int clear) -+{ -+ int val = 0; -+ unsigned long flags; -+ int if_num; -+ struct hso_serial *serial = tty->driver_data; -+ -+ /* sanity check */ -+ if (!serial) { -+ D1("no tty structures"); -+ return -EINVAL; -+ } -+ -+ if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM) -+ return -EINVAL; -+ -+ if_num = serial->parent->interface->altsetting->desc.bInterfaceNumber; -+ -+ spin_lock_irqsave(&serial->serial_lock, flags); -+ if (set & TIOCM_RTS) -+ serial->rts_state = 1; -+ if (set & TIOCM_DTR) -+ serial->dtr_state = 1; -+ -+ if (clear & TIOCM_RTS) -+ serial->rts_state = 0; -+ if (clear & TIOCM_DTR) -+ serial->dtr_state = 0; -+ -+ if (serial->dtr_state) -+ val |= 0x01; -+ if (serial->rts_state) -+ val |= 0x02; -+ -+ spin_unlock_irqrestore(&serial->serial_lock, flags); -+ -+ return usb_control_msg(serial->parent->usb, -+ usb_rcvctrlpipe(serial->parent->usb, 0), 0x22, -+ 0x21, val, if_num, NULL, 0, -+ USB_CTRL_SET_TIMEOUT); -+} -+ -+static int hso_serial_ioctl(struct tty_struct *tty, -+ unsigned int cmd, unsigned long arg) -+{ -+ struct hso_serial *serial = tty->driver_data; -+ int ret = 0; -+ D4("IOCTL cmd: %d, arg: %ld", cmd, arg); -+ -+ if (!serial) -+ return -ENODEV; -+ switch (cmd) { -+ case TIOCMIWAIT: -+ ret = hso_wait_modem_status(serial, arg); -+ break; -+ default: -+ ret = -ENOIOCTLCMD; -+ break; -+ } -+ return ret; -+} -+ -+ -+/* starts a transmit */ -+static void hso_kick_transmit(struct hso_serial *serial) -+{ -+ u8 *temp; -+ unsigned long flags; -+ int res; -+ -+ spin_lock_irqsave(&serial->serial_lock, flags); -+ if (!serial->tx_buffer_count) -+ goto out; -+ -+ if (serial->tx_urb_used) -+ goto out; -+ -+ /* Wakeup USB interface if necessary */ -+ if (hso_get_activity(serial->parent) == -EAGAIN) -+ goto out; -+ -+ /* Switch pointers around to avoid memcpy */ -+ temp = serial->tx_buffer; -+ serial->tx_buffer = serial->tx_data; -+ serial->tx_data = temp; -+ serial->tx_data_count = serial->tx_buffer_count; -+ serial->tx_buffer_count = 0; -+ -+ /* If temp is set, it means we switched buffers */ -+ if (temp && serial->write_data) { -+ res = serial->write_data(serial); -+ if (res >= 0) -+ serial->tx_urb_used = 1; -+ } -+out: -+ spin_unlock_irqrestore(&serial->serial_lock, flags); -+} -+ -+/* make a request (for reading and writing data to muxed serial port) */ -+static int mux_device_request(struct hso_serial *serial, u8 type, u16 port, -+ struct urb *ctrl_urb, -+ struct usb_ctrlrequest *ctrl_req, -+ u8 *ctrl_urb_data, u32 size) -+{ -+ int result; -+ int pipe; -+ -+ /* Sanity check */ -+ if (!serial || !ctrl_urb || !ctrl_req) { -+ printk(KERN_ERR "%s: Wrong arguments\n", __func__); -+ return -EINVAL; -+ } -+ -+ /* initialize */ -+ ctrl_req->wValue = 0; -+ ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port)); -+ ctrl_req->wLength = cpu_to_le16(size); -+ -+ if (type == USB_CDC_GET_ENCAPSULATED_RESPONSE) { -+ /* Reading command */ -+ ctrl_req->bRequestType = USB_DIR_IN | -+ USB_TYPE_OPTION_VENDOR | -+ USB_RECIP_INTERFACE; -+ ctrl_req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; -+ pipe = usb_rcvctrlpipe(serial->parent->usb, 0); -+ } else { -+ /* Writing command */ -+ ctrl_req->bRequestType = USB_DIR_OUT | -+ USB_TYPE_OPTION_VENDOR | -+ USB_RECIP_INTERFACE; -+ ctrl_req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND; -+ pipe = usb_sndctrlpipe(serial->parent->usb, 0); -+ } -+ /* syslog */ -+ D2("%s command (%02x) len: %d, port: %d", -+ type == USB_CDC_GET_ENCAPSULATED_RESPONSE ? "Read" : "Write", -+ ctrl_req->bRequestType, ctrl_req->wLength, port); -+ -+ /* Load ctrl urb */ -+ ctrl_urb->transfer_flags = 0; -+ usb_fill_control_urb(ctrl_urb, -+ serial->parent->usb, -+ pipe, -+ (u8 *) ctrl_req, -+ ctrl_urb_data, size, ctrl_callback, serial); -+ /* Send it on merry way */ -+ result = usb_submit_urb(ctrl_urb, GFP_ATOMIC); -+ if (result) { -+ dev_err(&ctrl_urb->dev->dev, -+ "%s failed submit ctrl_urb %d type %d\n", __func__, -+ result, type); -+ return result; -+ } -+ -+ /* done */ -+ return size; -+} -+ -+/* called by intr_callback when read occurs */ -+static int hso_mux_serial_read(struct hso_serial *serial) -+{ -+ if (!serial) -+ return -EINVAL; -+ -+ /* clean data */ -+ memset(serial->rx_data[0], 0, CTRL_URB_RX_SIZE); -+ /* make the request */ -+ -+ if (serial->num_rx_urbs != 1) { -+ dev_err(&serial->parent->interface->dev, -+ "ERROR: mux'd reads with multiple buffers " -+ "not possible\n"); -+ return 0; -+ } -+ return mux_device_request(serial, -+ USB_CDC_GET_ENCAPSULATED_RESPONSE, -+ serial->parent->port_spec & HSO_PORT_MASK, -+ serial->rx_urb[0], -+ &serial->ctrl_req_rx, -+ serial->rx_data[0], serial->rx_data_length); -+} -+ -+/* used for muxed serial port callback (muxed serial read) */ -+static void intr_callback(struct urb *urb) -+{ -+ struct hso_shared_int *shared_int = urb->context; -+ struct hso_serial *serial; -+ unsigned char *port_req; -+ int status = urb->status; -+ int i; -+ -+ usb_mark_last_busy(urb->dev); -+ -+ /* sanity check */ -+ if (!shared_int) -+ return; -+ -+ /* status check */ -+ if (status) { -+ handle_usb_error(status, __func__, NULL); -+ return; -+ } -+ D4("\n--- Got intr callback 0x%02X ---", status); -+ -+ /* what request? */ -+ port_req = urb->transfer_buffer; -+ D4(" port_req = 0x%.2X\n", *port_req); -+ /* loop over all muxed ports to find the one sending this */ -+ for (i = 0; i < 8; i++) { -+ /* max 8 channels on MUX */ -+ if (*port_req & (1 << i)) { -+ serial = get_serial_by_shared_int_and_type(shared_int, -+ (1 << i)); -+ if (serial != NULL) { -+ D1("Pending read interrupt on port %d\n", i); -+ spin_lock(&serial->serial_lock); -+ if (serial->rx_state == RX_IDLE && -+ atomic_read(&serial->port.count) > 0) { -+ /* Setup and send a ctrl req read on -+ * port i */ -+ if (!serial->rx_urb_filled[0]) { -+ serial->rx_state = RX_SENT; -+ hso_mux_serial_read(serial); -+ } else -+ serial->rx_state = RX_PENDING; -+ } else { -+ D1("Already a read pending on " -+ "port %d or port not open\n", i); -+ } -+ spin_unlock(&serial->serial_lock); -+ } -+ } -+ } -+ /* Resubmit interrupt urb */ -+ hso_mux_submit_intr_urb(shared_int, urb->dev, GFP_ATOMIC); -+} -+ -+/* called for writing to muxed serial port */ -+static int hso_mux_serial_write_data(struct hso_serial *serial) -+{ -+ if (NULL == serial) -+ return -EINVAL; -+ -+ return mux_device_request(serial, -+ USB_CDC_SEND_ENCAPSULATED_COMMAND, -+ serial->parent->port_spec & HSO_PORT_MASK, -+ serial->tx_urb, -+ &serial->ctrl_req_tx, -+ serial->tx_data, serial->tx_data_count); -+} -+ -+/* write callback for Diag and CS port */ -+static void hso_std_serial_write_bulk_callback(struct urb *urb) -+{ -+ struct hso_serial *serial = urb->context; -+ int status = urb->status; -+ -+ /* sanity check */ -+ if (!serial) { -+ D1("serial == NULL"); -+ return; -+ } -+ -+ spin_lock(&serial->serial_lock); -+ serial->tx_urb_used = 0; -+ spin_unlock(&serial->serial_lock); -+ if (status) { -+ handle_usb_error(status, __func__, serial->parent); -+ return; -+ } -+ hso_put_activity(serial->parent); -+ tty_port_tty_wakeup(&serial->port); -+ hso_kick_transmit(serial); -+ -+ D1(" "); -+} -+ -+/* called for writing diag or CS serial port */ -+static int hso_std_serial_write_data(struct hso_serial *serial) -+{ -+ int count = serial->tx_data_count; -+ int result; -+ -+ usb_fill_bulk_urb(serial->tx_urb, -+ serial->parent->usb, -+ usb_sndbulkpipe(serial->parent->usb, -+ serial->out_endp-> -+ bEndpointAddress & 0x7F), -+ serial->tx_data, serial->tx_data_count, -+ hso_std_serial_write_bulk_callback, serial); -+ -+ result = usb_submit_urb(serial->tx_urb, GFP_ATOMIC); -+ if (result) { -+ dev_warn(&serial->parent->usb->dev, -+ "Failed to submit urb - res %d\n", result); -+ return result; -+ } -+ -+ return count; -+} -+ -+/* callback after read or write on muxed serial port */ -+static void ctrl_callback(struct urb *urb) -+{ -+ struct hso_serial *serial = urb->context; -+ struct usb_ctrlrequest *req; -+ int status = urb->status; -+ -+ /* sanity check */ -+ if (!serial) -+ return; -+ -+ spin_lock(&serial->serial_lock); -+ serial->tx_urb_used = 0; -+ spin_unlock(&serial->serial_lock); -+ if (status) { -+ handle_usb_error(status, __func__, serial->parent); -+ return; -+ } -+ -+ /* what request? */ -+ req = (struct usb_ctrlrequest *)(urb->setup_packet); -+ D4("\n--- Got muxed ctrl callback 0x%02X ---", status); -+ D4("Actual length of urb = %d\n", urb->actual_length); -+ DUMP1(urb->transfer_buffer, urb->actual_length); -+ -+ if (req->bRequestType == -+ (USB_DIR_IN | USB_TYPE_OPTION_VENDOR | USB_RECIP_INTERFACE)) { -+ /* response to a read command */ -+ serial->rx_urb_filled[0] = 1; -+ spin_lock(&serial->serial_lock); -+ put_rxbuf_data_and_resubmit_ctrl_urb(serial); -+ spin_unlock(&serial->serial_lock); -+ } else { -+ hso_put_activity(serial->parent); -+ tty_port_tty_wakeup(&serial->port); -+ /* response to a write command */ -+ hso_kick_transmit(serial); -+ } -+} -+ -+/* handle RX data for serial port */ -+static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) -+{ -+ struct tty_struct *tty; -+ int count; -+ -+ /* Sanity check */ -+ if (urb == NULL || serial == NULL) { -+ D1("serial = NULL"); -+ return -2; -+ } -+ -+ tty = tty_port_tty_get(&serial->port); -+ -+ if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { -+ tty_kref_put(tty); -+ return -1; -+ } -+ -+ /* Push data to tty */ -+ D1("data to push to tty"); -+ count = tty_buffer_request_room(&serial->port, urb->actual_length); -+ if (count >= urb->actual_length) { -+ tty_insert_flip_string(&serial->port, urb->transfer_buffer, -+ urb->actual_length); -+ tty_flip_buffer_push(&serial->port); -+ } else { -+ dev_warn(&serial->parent->usb->dev, -+ "dropping data, %d bytes lost\n", urb->actual_length); -+ } -+ -+ tty_kref_put(tty); -+ -+ serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; -+ -+ return 0; -+} -+ -+ -+/* Base driver functions */ -+ -+static void hso_log_port(struct hso_device *hso_dev) -+{ -+ char *port_type; -+ char port_dev[20]; -+ -+ switch (hso_dev->port_spec & HSO_PORT_MASK) { -+ case HSO_PORT_CONTROL: -+ port_type = "Control"; -+ break; -+ case HSO_PORT_APP: -+ port_type = "Application"; -+ break; -+ case HSO_PORT_GPS: -+ port_type = "GPS"; -+ break; -+ case HSO_PORT_GPS_CONTROL: -+ port_type = "GPS control"; -+ break; -+ case HSO_PORT_APP2: -+ port_type = "Application2"; -+ break; -+ case HSO_PORT_PCSC: -+ port_type = "PCSC"; -+ break; -+ case HSO_PORT_DIAG: -+ port_type = "Diagnostic"; -+ break; -+ case HSO_PORT_DIAG2: -+ port_type = "Diagnostic2"; -+ break; -+ case HSO_PORT_MODEM: -+ port_type = "Modem"; -+ break; -+ case HSO_PORT_NETWORK: -+ port_type = "Network"; -+ break; -+ default: -+ port_type = "Unknown"; -+ break; -+ } -+ if ((hso_dev->port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { -+ sprintf(port_dev, "%s", dev2net(hso_dev)->net->name); -+ } else -+ sprintf(port_dev, "/dev/%s%d", tty_filename, -+ dev2ser(hso_dev)->minor); -+ -+ dev_dbg(&hso_dev->interface->dev, "HSO: Found %s port %s\n", -+ port_type, port_dev); -+} -+ -+static int hso_start_net_device(struct hso_device *hso_dev) -+{ -+ int i, result = 0; -+ struct hso_net *hso_net = dev2net(hso_dev); -+ -+ if (!hso_net) -+ return -ENODEV; -+ -+ /* send URBs for all read buffers */ -+ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { -+ -+ /* Prep a receive URB */ -+ usb_fill_bulk_urb(hso_net->mux_bulk_rx_urb_pool[i], -+ hso_dev->usb, -+ usb_rcvbulkpipe(hso_dev->usb, -+ hso_net->in_endp-> -+ bEndpointAddress & 0x7F), -+ hso_net->mux_bulk_rx_buf_pool[i], -+ MUX_BULK_RX_BUF_SIZE, read_bulk_callback, -+ hso_net); -+ -+ /* Put it out there so the device can send us stuff */ -+ result = usb_submit_urb(hso_net->mux_bulk_rx_urb_pool[i], -+ GFP_NOIO); -+ if (result) -+ dev_warn(&hso_dev->usb->dev, -+ "%s failed mux_bulk_rx_urb[%d] %d\n", __func__, -+ i, result); -+ } -+ -+ return result; -+} -+ -+static int hso_stop_net_device(struct hso_device *hso_dev) -+{ -+ int i; -+ struct hso_net *hso_net = dev2net(hso_dev); -+ -+ if (!hso_net) -+ return -ENODEV; -+ -+ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { -+ if (hso_net->mux_bulk_rx_urb_pool[i]) -+ usb_kill_urb(hso_net->mux_bulk_rx_urb_pool[i]); -+ -+ } -+ if (hso_net->mux_bulk_tx_urb) -+ usb_kill_urb(hso_net->mux_bulk_tx_urb); -+ -+ return 0; -+} -+ -+static int hso_start_serial_device(struct hso_device *hso_dev, gfp_t flags) -+{ -+ int i, result = 0; -+ struct hso_serial *serial = dev2ser(hso_dev); -+ -+ if (!serial) -+ return -ENODEV; -+ -+ /* If it is not the MUX port fill in and submit a bulk urb (already -+ * allocated in hso_serial_start) */ -+ if (!(serial->parent->port_spec & HSO_INTF_MUX)) { -+ for (i = 0; i < serial->num_rx_urbs; i++) { -+ usb_fill_bulk_urb(serial->rx_urb[i], -+ serial->parent->usb, -+ usb_rcvbulkpipe(serial->parent->usb, -+ serial->in_endp-> -+ bEndpointAddress & -+ 0x7F), -+ serial->rx_data[i], -+ serial->rx_data_length, -+ hso_std_serial_read_bulk_callback, -+ serial); -+ result = usb_submit_urb(serial->rx_urb[i], flags); -+ if (result) { -+ dev_warn(&serial->parent->usb->dev, -+ "Failed to submit urb - res %d\n", -+ result); -+ break; -+ } -+ } -+ } else { -+ mutex_lock(&serial->shared_int->shared_int_lock); -+ if (!serial->shared_int->use_count) { -+ result = -+ hso_mux_submit_intr_urb(serial->shared_int, -+ hso_dev->usb, flags); -+ } -+ serial->shared_int->use_count++; -+ mutex_unlock(&serial->shared_int->shared_int_lock); -+ } -+ if (serial->tiocmget) -+ tiocmget_submit_urb(serial, -+ serial->tiocmget, -+ serial->parent->usb); -+ return result; -+} -+ -+static int hso_stop_serial_device(struct hso_device *hso_dev) -+{ -+ int i; -+ struct hso_serial *serial = dev2ser(hso_dev); -+ struct hso_tiocmget *tiocmget; -+ -+ if (!serial) -+ return -ENODEV; -+ -+ for (i = 0; i < serial->num_rx_urbs; i++) { -+ if (serial->rx_urb[i]) { -+ usb_kill_urb(serial->rx_urb[i]); -+ serial->rx_urb_filled[i] = 0; -+ } -+ } -+ serial->curr_rx_urb_idx = 0; -+ -+ if (serial->tx_urb) -+ usb_kill_urb(serial->tx_urb); -+ -+ if (serial->shared_int) { -+ mutex_lock(&serial->shared_int->shared_int_lock); -+ if (serial->shared_int->use_count && -+ (--serial->shared_int->use_count == 0)) { -+ struct urb *urb; -+ -+ urb = serial->shared_int->shared_intr_urb; -+ if (urb) -+ usb_kill_urb(urb); -+ } -+ mutex_unlock(&serial->shared_int->shared_int_lock); -+ } -+ tiocmget = serial->tiocmget; -+ if (tiocmget) { -+ wake_up_interruptible(&tiocmget->waitq); -+ usb_kill_urb(tiocmget->urb); -+ } -+ -+ return 0; -+} -+ -+static void hso_serial_common_free(struct hso_serial *serial) -+{ -+ int i; -+ -+ if (serial->parent->dev) -+ device_remove_file(serial->parent->dev, &dev_attr_hsotype); -+ -+ tty_unregister_device(tty_drv, serial->minor); -+ -+ for (i = 0; i < serial->num_rx_urbs; i++) { -+ /* unlink and free RX URB */ -+ usb_free_urb(serial->rx_urb[i]); -+ /* free the RX buffer */ -+ kfree(serial->rx_data[i]); -+ } -+ -+ /* unlink and free TX URB */ -+ usb_free_urb(serial->tx_urb); -+ kfree(serial->tx_data); -+ tty_port_destroy(&serial->port); -+} -+ -+static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, -+ int rx_size, int tx_size) -+{ -+ struct device *dev; -+ int minor; -+ int i; -+ -+ tty_port_init(&serial->port); -+ -+ minor = get_free_serial_index(); -+ if (minor < 0) -+ goto exit; -+ -+ /* register our minor number */ -+ serial->parent->dev = tty_port_register_device(&serial->port, tty_drv, -+ minor, &serial->parent->interface->dev); -+ dev = serial->parent->dev; -+ dev_set_drvdata(dev, serial->parent); -+ i = device_create_file(dev, &dev_attr_hsotype); -+ -+ /* fill in specific data for later use */ -+ serial->minor = minor; -+ serial->magic = HSO_SERIAL_MAGIC; -+ spin_lock_init(&serial->serial_lock); -+ serial->num_rx_urbs = num_urbs; -+ -+ /* RX, allocate urb and initialize */ -+ -+ /* prepare our RX buffer */ -+ serial->rx_data_length = rx_size; -+ for (i = 0; i < serial->num_rx_urbs; i++) { -+ serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); -+ if (!serial->rx_urb[i]) { -+ dev_err(dev, "Could not allocate urb?\n"); -+ goto exit; -+ } -+ serial->rx_urb[i]->transfer_buffer = NULL; -+ serial->rx_urb[i]->transfer_buffer_length = 0; -+ serial->rx_data[i] = kzalloc(serial->rx_data_length, -+ GFP_KERNEL); -+ if (!serial->rx_data[i]) -+ goto exit; -+ } -+ -+ /* TX, allocate urb and initialize */ -+ serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!serial->tx_urb) { -+ dev_err(dev, "Could not allocate urb?\n"); -+ goto exit; -+ } -+ serial->tx_urb->transfer_buffer = NULL; -+ serial->tx_urb->transfer_buffer_length = 0; -+ /* prepare our TX buffer */ -+ serial->tx_data_count = 0; -+ serial->tx_buffer_count = 0; -+ serial->tx_data_length = tx_size; -+ serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); -+ if (!serial->tx_data) -+ goto exit; -+ -+ serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); -+ if (!serial->tx_buffer) -+ goto exit; -+ -+ return 0; -+exit: -+ hso_serial_common_free(serial); -+ return -1; -+} -+ -+/* Creates a general hso device */ -+static struct hso_device *hso_create_device(struct usb_interface *intf, -+ int port_spec) -+{ -+ struct hso_device *hso_dev; -+ -+ hso_dev = kzalloc(sizeof(*hso_dev), GFP_ATOMIC); -+ if (!hso_dev) -+ return NULL; -+ -+ hso_dev->port_spec = port_spec; -+ hso_dev->usb = interface_to_usbdev(intf); -+ hso_dev->interface = intf; -+ kref_init(&hso_dev->ref); -+ mutex_init(&hso_dev->mutex); -+ -+ INIT_WORK(&hso_dev->async_get_intf, async_get_intf); -+ INIT_WORK(&hso_dev->async_put_intf, async_put_intf); -+ INIT_WORK(&hso_dev->reset_device, reset_device); -+ -+ return hso_dev; -+} -+ -+/* Removes a network device in the network device table */ -+static int remove_net_device(struct hso_device *hso_dev) -+{ -+ int i; -+ -+ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { -+ if (network_table[i] == hso_dev) { -+ network_table[i] = NULL; -+ break; -+ } -+ } -+ if (i == HSO_MAX_NET_DEVICES) -+ return -1; -+ return 0; -+} -+ -+/* Frees our network device */ -+static void hso_free_net_device(struct hso_device *hso_dev) -+{ -+ int i; -+ struct hso_net *hso_net = dev2net(hso_dev); -+ -+ if (!hso_net) -+ return; -+ -+ remove_net_device(hso_net->parent); -+ -+ if (hso_net->net) -+ unregister_netdev(hso_net->net); -+ -+ /* start freeing */ -+ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { -+ usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); -+ kfree(hso_net->mux_bulk_rx_buf_pool[i]); -+ hso_net->mux_bulk_rx_buf_pool[i] = NULL; -+ } -+ usb_free_urb(hso_net->mux_bulk_tx_urb); -+ kfree(hso_net->mux_bulk_tx_buf); -+ hso_net->mux_bulk_tx_buf = NULL; -+ -+ if (hso_net->net) -+ free_netdev(hso_net->net); -+ -+ kfree(hso_dev); -+} -+ -+static const struct net_device_ops hso_netdev_ops = { -+ .ndo_open = hso_net_open, -+ .ndo_stop = hso_net_close, -+ .ndo_start_xmit = hso_net_start_xmit, -+ .ndo_tx_timeout = hso_net_tx_timeout, -+}; -+ -+/* initialize the network interface */ -+static void hso_net_init(struct net_device *net) -+{ -+ struct hso_net *hso_net = netdev_priv(net); -+ -+ D1("sizeof hso_net is %d", (int)sizeof(*hso_net)); -+ -+ /* fill in the other fields */ -+ net->netdev_ops = &hso_netdev_ops; -+ net->watchdog_timeo = HSO_NET_TX_TIMEOUT; -+ net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; -+ net->type = ARPHRD_NONE; -+ net->mtu = DEFAULT_MTU - 14; -+ net->tx_queue_len = 10; -+ net->ethtool_ops = &ops; -+ -+ /* and initialize the semaphore */ -+ spin_lock_init(&hso_net->net_lock); -+} -+ -+/* Adds a network device in the network device table */ -+static int add_net_device(struct hso_device *hso_dev) -+{ -+ int i; -+ -+ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { -+ if (network_table[i] == NULL) { -+ network_table[i] = hso_dev; -+ break; -+ } -+ } -+ if (i == HSO_MAX_NET_DEVICES) -+ return -1; -+ return 0; -+} -+ -+static int hso_rfkill_set_block(void *data, bool blocked) -+{ -+ struct hso_device *hso_dev = data; -+ int enabled = !blocked; -+ int rv; -+ -+ mutex_lock(&hso_dev->mutex); -+ if (hso_dev->usb_gone) -+ rv = 0; -+ else -+ rv = usb_control_msg(hso_dev->usb, usb_rcvctrlpipe(hso_dev->usb, 0), -+ enabled ? 0x82 : 0x81, 0x40, 0, 0, NULL, 0, -+ USB_CTRL_SET_TIMEOUT); -+ mutex_unlock(&hso_dev->mutex); -+ return rv; -+} -+ -+static const struct rfkill_ops hso_rfkill_ops = { -+ .set_block = hso_rfkill_set_block, -+}; -+ -+/* Creates and sets up everything for rfkill */ -+static void hso_create_rfkill(struct hso_device *hso_dev, -+ struct usb_interface *interface) -+{ -+ struct hso_net *hso_net = dev2net(hso_dev); -+ struct device *dev = &hso_net->net->dev; -+ char *rfkn; -+ -+ rfkn = kzalloc(20, GFP_KERNEL); -+ if (!rfkn) -+ dev_err(dev, "%s - Out of memory\n", __func__); -+ -+ snprintf(rfkn, 20, "hso-%d", -+ interface->altsetting->desc.bInterfaceNumber); -+ -+ hso_net->rfkill = rfkill_alloc(rfkn, -+ &interface_to_usbdev(interface)->dev, -+ RFKILL_TYPE_WWAN, -+ &hso_rfkill_ops, hso_dev); -+ if (!hso_net->rfkill) { -+ dev_err(dev, "%s - Out of memory\n", __func__); -+ kfree(rfkn); -+ return; -+ } -+ if (rfkill_register(hso_net->rfkill) < 0) { -+ rfkill_destroy(hso_net->rfkill); -+ kfree(rfkn); -+ hso_net->rfkill = NULL; -+ dev_err(dev, "%s - Failed to register rfkill\n", __func__); -+ return; -+ } -+} -+ -+static struct device_type hso_type = { -+ .name = "wwan", -+}; -+ -+/* Creates our network device */ -+static struct hso_device *hso_create_net_device(struct usb_interface *interface, -+ int port_spec) -+{ -+ int result, i; -+ struct net_device *net; -+ struct hso_net *hso_net; -+ struct hso_device *hso_dev; -+ -+ hso_dev = hso_create_device(interface, port_spec); -+ if (!hso_dev) -+ return NULL; -+ -+ /* allocate our network device, then we can put in our private data */ -+ /* call hso_net_init to do the basic initialization */ -+ net = alloc_netdev(sizeof(struct hso_net), "hso%d", NET_NAME_UNKNOWN, -+ hso_net_init); -+ if (!net) { -+ dev_err(&interface->dev, "Unable to create ethernet device\n"); -+ goto exit; -+ } -+ -+ hso_net = netdev_priv(net); -+ -+ hso_dev->port_data.dev_net = hso_net; -+ hso_net->net = net; -+ hso_net->parent = hso_dev; -+ -+ hso_net->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, -+ USB_DIR_IN); -+ if (!hso_net->in_endp) { -+ dev_err(&interface->dev, "Can't find BULK IN endpoint\n"); -+ goto exit; -+ } -+ hso_net->out_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, -+ USB_DIR_OUT); -+ if (!hso_net->out_endp) { -+ dev_err(&interface->dev, "Can't find BULK OUT endpoint\n"); -+ goto exit; -+ } -+ SET_NETDEV_DEV(net, &interface->dev); -+ SET_NETDEV_DEVTYPE(net, &hso_type); -+ -+ /* registering our net device */ -+ result = register_netdev(net); -+ if (result) { -+ dev_err(&interface->dev, "Failed to register device\n"); -+ goto exit; -+ } -+ -+ /* start allocating */ -+ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { -+ hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL); -+ if (!hso_net->mux_bulk_rx_urb_pool[i]) { -+ dev_err(&interface->dev, "Could not allocate rx urb\n"); -+ goto exit; -+ } -+ hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE, -+ GFP_KERNEL); -+ if (!hso_net->mux_bulk_rx_buf_pool[i]) -+ goto exit; -+ } -+ hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!hso_net->mux_bulk_tx_urb) { -+ dev_err(&interface->dev, "Could not allocate tx urb\n"); -+ goto exit; -+ } -+ hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL); -+ if (!hso_net->mux_bulk_tx_buf) -+ goto exit; -+ -+ add_net_device(hso_dev); -+ -+ hso_log_port(hso_dev); -+ -+ hso_create_rfkill(hso_dev, interface); -+ -+ return hso_dev; -+exit: -+ hso_free_net_device(hso_dev); -+ return NULL; -+} -+ -+static void hso_free_tiomget(struct hso_serial *serial) -+{ -+ struct hso_tiocmget *tiocmget; -+ if (!serial) -+ return; -+ tiocmget = serial->tiocmget; -+ if (tiocmget) { -+ usb_free_urb(tiocmget->urb); -+ tiocmget->urb = NULL; -+ serial->tiocmget = NULL; -+ kfree(tiocmget); -+ } -+} -+ -+/* Frees an AT channel ( goes for both mux and non-mux ) */ -+static void hso_free_serial_device(struct hso_device *hso_dev) -+{ -+ struct hso_serial *serial = dev2ser(hso_dev); -+ -+ if (!serial) -+ return; -+ set_serial_by_index(serial->minor, NULL); -+ -+ hso_serial_common_free(serial); -+ -+ if (serial->shared_int) { -+ mutex_lock(&serial->shared_int->shared_int_lock); -+ if (--serial->shared_int->ref_count == 0) -+ hso_free_shared_int(serial->shared_int); -+ else -+ mutex_unlock(&serial->shared_int->shared_int_lock); -+ } -+ hso_free_tiomget(serial); -+ kfree(serial); -+ kfree(hso_dev); -+} -+ -+/* Creates a bulk AT channel */ -+static struct hso_device *hso_create_bulk_serial_device( -+ struct usb_interface *interface, int port) -+{ -+ struct hso_device *hso_dev; -+ struct hso_serial *serial; -+ int num_urbs; -+ struct hso_tiocmget *tiocmget; -+ -+ hso_dev = hso_create_device(interface, port); -+ if (!hso_dev) -+ return NULL; -+ -+ serial = kzalloc(sizeof(*serial), GFP_KERNEL); -+ if (!serial) -+ goto exit; -+ -+ serial->parent = hso_dev; -+ hso_dev->port_data.dev_serial = serial; -+ -+ if ((port & HSO_PORT_MASK) == HSO_PORT_MODEM) { -+ num_urbs = 2; -+ serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), -+ GFP_KERNEL); -+ /* it isn't going to break our heart if serial->tiocmget -+ * allocation fails don't bother checking this. -+ */ -+ if (serial->tiocmget) { -+ tiocmget = serial->tiocmget; -+ tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (tiocmget->urb) { -+ mutex_init(&tiocmget->mutex); -+ init_waitqueue_head(&tiocmget->waitq); -+ tiocmget->endp = hso_get_ep( -+ interface, -+ USB_ENDPOINT_XFER_INT, -+ USB_DIR_IN); -+ } else -+ hso_free_tiomget(serial); -+ } -+ } -+ else -+ num_urbs = 1; -+ -+ if (hso_serial_common_create(serial, num_urbs, BULK_URB_RX_SIZE, -+ BULK_URB_TX_SIZE)) -+ goto exit; -+ -+ serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, -+ USB_DIR_IN); -+ if (!serial->in_endp) { -+ dev_err(&interface->dev, "Failed to find BULK IN ep\n"); -+ goto exit2; -+ } -+ -+ if (! -+ (serial->out_endp = -+ hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) { -+ dev_err(&interface->dev, "Failed to find BULK IN ep\n"); -+ goto exit2; -+ } -+ -+ serial->write_data = hso_std_serial_write_data; -+ -+ /* and record this serial */ -+ set_serial_by_index(serial->minor, serial); -+ -+ /* setup the proc dirs and files if needed */ -+ hso_log_port(hso_dev); -+ -+ /* done, return it */ -+ return hso_dev; -+ -+exit2: -+ hso_serial_common_free(serial); -+exit: -+ hso_free_tiomget(serial); -+ kfree(serial); -+ kfree(hso_dev); -+ return NULL; -+} -+ -+/* Creates a multiplexed AT channel */ -+static -+struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface, -+ int port, -+ struct hso_shared_int *mux) -+{ -+ struct hso_device *hso_dev; -+ struct hso_serial *serial; -+ int port_spec; -+ -+ port_spec = HSO_INTF_MUX; -+ port_spec &= ~HSO_PORT_MASK; -+ -+ port_spec |= hso_mux_to_port(port); -+ if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NO_PORT) -+ return NULL; -+ -+ hso_dev = hso_create_device(interface, port_spec); -+ if (!hso_dev) -+ return NULL; -+ -+ serial = kzalloc(sizeof(*serial), GFP_KERNEL); -+ if (!serial) -+ goto exit; -+ -+ hso_dev->port_data.dev_serial = serial; -+ serial->parent = hso_dev; -+ -+ if (hso_serial_common_create -+ (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE)) -+ goto exit; -+ -+ serial->tx_data_length--; -+ serial->write_data = hso_mux_serial_write_data; -+ -+ serial->shared_int = mux; -+ mutex_lock(&serial->shared_int->shared_int_lock); -+ serial->shared_int->ref_count++; -+ mutex_unlock(&serial->shared_int->shared_int_lock); -+ -+ /* and record this serial */ -+ set_serial_by_index(serial->minor, serial); -+ -+ /* setup the proc dirs and files if needed */ -+ hso_log_port(hso_dev); -+ -+ /* done, return it */ -+ return hso_dev; -+ -+exit: -+ if (serial) { -+ tty_unregister_device(tty_drv, serial->minor); -+ kfree(serial); -+ } -+ if (hso_dev) -+ kfree(hso_dev); -+ return NULL; -+ -+} -+ -+static void hso_free_shared_int(struct hso_shared_int *mux) -+{ -+ usb_free_urb(mux->shared_intr_urb); -+ kfree(mux->shared_intr_buf); -+ mutex_unlock(&mux->shared_int_lock); -+ kfree(mux); -+} -+ -+static -+struct hso_shared_int *hso_create_shared_int(struct usb_interface *interface) -+{ -+ struct hso_shared_int *mux = kzalloc(sizeof(*mux), GFP_KERNEL); -+ -+ if (!mux) -+ return NULL; -+ -+ mux->intr_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_INT, -+ USB_DIR_IN); -+ if (!mux->intr_endp) { -+ dev_err(&interface->dev, "Can't find INT IN endpoint\n"); -+ goto exit; -+ } -+ -+ mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!mux->shared_intr_urb) { -+ dev_err(&interface->dev, "Could not allocate intr urb?\n"); -+ goto exit; -+ } -+ mux->shared_intr_buf = -+ kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize), -+ GFP_KERNEL); -+ if (!mux->shared_intr_buf) -+ goto exit; -+ -+ mutex_init(&mux->shared_int_lock); -+ -+ return mux; -+ -+exit: -+ kfree(mux->shared_intr_buf); -+ usb_free_urb(mux->shared_intr_urb); -+ kfree(mux); -+ return NULL; -+} -+ -+/* Gets the port spec for a certain interface */ -+static int hso_get_config_data(struct usb_interface *interface) -+{ -+ struct usb_device *usbdev = interface_to_usbdev(interface); -+ u8 *config_data = kmalloc(17, GFP_KERNEL); -+ u32 if_num = interface->altsetting->desc.bInterfaceNumber; -+ s32 result; -+ -+ if (!config_data) -+ return -ENOMEM; -+ if (usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), -+ 0x86, 0xC0, 0, 0, config_data, 17, -+ USB_CTRL_SET_TIMEOUT) != 0x11) { -+ kfree(config_data); -+ return -EIO; -+ } -+ -+ switch (config_data[if_num]) { -+ case 0x0: -+ result = 0; -+ break; -+ case 0x1: -+ result = HSO_PORT_DIAG; -+ break; -+ case 0x2: -+ result = HSO_PORT_GPS; -+ break; -+ case 0x3: -+ result = HSO_PORT_GPS_CONTROL; -+ break; -+ case 0x4: -+ result = HSO_PORT_APP; -+ break; -+ case 0x5: -+ result = HSO_PORT_APP2; -+ break; -+ case 0x6: -+ result = HSO_PORT_CONTROL; -+ break; -+ case 0x7: -+ result = HSO_PORT_NETWORK; -+ break; -+ case 0x8: -+ result = HSO_PORT_MODEM; -+ break; -+ case 0x9: -+ result = HSO_PORT_MSD; -+ break; -+ case 0xa: -+ result = HSO_PORT_PCSC; -+ break; -+ case 0xb: -+ result = HSO_PORT_VOICE; -+ break; -+ default: -+ result = 0; -+ } -+ -+ if (result) -+ result |= HSO_INTF_BULK; -+ -+ if (config_data[16] & 0x1) -+ result |= HSO_INFO_CRC_BUG; -+ -+ kfree(config_data); -+ return result; -+} -+ -+/* called once for each interface upon device insertion */ -+static int hso_probe(struct usb_interface *interface, -+ const struct usb_device_id *id) -+{ -+ int mux, i, if_num, port_spec; -+ unsigned char port_mask; -+ struct hso_device *hso_dev = NULL; -+ struct hso_shared_int *shared_int; -+ struct hso_device *tmp_dev = NULL; -+ -+ if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { -+ dev_err(&interface->dev, "Not our interface\n"); -+ return -ENODEV; -+ } -+ -+ if_num = interface->altsetting->desc.bInterfaceNumber; -+ -+ /* Get the interface/port specification from either driver_info or from -+ * the device itself */ -+ if (id->driver_info) -+ port_spec = ((u32 *)(id->driver_info))[if_num]; -+ else -+ port_spec = hso_get_config_data(interface); -+ -+ /* Check if we need to switch to alt interfaces prior to port -+ * configuration */ -+ if (interface->num_altsetting > 1) -+ usb_set_interface(interface_to_usbdev(interface), if_num, 1); -+ interface->needs_remote_wakeup = 1; -+ -+ /* Allocate new hso device(s) */ -+ switch (port_spec & HSO_INTF_MASK) { -+ case HSO_INTF_MUX: -+ if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { -+ /* Create the network device */ -+ if (!disable_net) { -+ hso_dev = hso_create_net_device(interface, -+ port_spec); -+ if (!hso_dev) -+ goto exit; -+ tmp_dev = hso_dev; -+ } -+ } -+ -+ if (hso_get_mux_ports(interface, &port_mask)) -+ /* TODO: de-allocate everything */ -+ goto exit; -+ -+ shared_int = hso_create_shared_int(interface); -+ if (!shared_int) -+ goto exit; -+ -+ for (i = 1, mux = 0; i < 0x100; i = i << 1, mux++) { -+ if (port_mask & i) { -+ hso_dev = hso_create_mux_serial_device( -+ interface, i, shared_int); -+ if (!hso_dev) -+ goto exit; -+ } -+ } -+ -+ if (tmp_dev) -+ hso_dev = tmp_dev; -+ break; -+ -+ case HSO_INTF_BULK: -+ /* It's a regular bulk interface */ -+ if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { -+ if (!disable_net) -+ hso_dev = -+ hso_create_net_device(interface, port_spec); -+ } else { -+ hso_dev = -+ hso_create_bulk_serial_device(interface, port_spec); -+ } -+ if (!hso_dev) -+ goto exit; -+ break; -+ default: -+ goto exit; -+ } -+ -+ /* save our data pointer in this device */ -+ usb_set_intfdata(interface, hso_dev); -+ -+ /* done */ -+ return 0; -+exit: -+ hso_free_interface(interface); -+ return -ENODEV; -+} -+ -+/* device removed, cleaning up */ -+static void hso_disconnect(struct usb_interface *interface) -+{ -+ hso_free_interface(interface); -+ -+ /* remove reference of our private data */ -+ usb_set_intfdata(interface, NULL); -+} -+ -+static void async_get_intf(struct work_struct *data) -+{ -+ struct hso_device *hso_dev = -+ container_of(data, struct hso_device, async_get_intf); -+ usb_autopm_get_interface(hso_dev->interface); -+} -+ -+static void async_put_intf(struct work_struct *data) -+{ -+ struct hso_device *hso_dev = -+ container_of(data, struct hso_device, async_put_intf); -+ usb_autopm_put_interface(hso_dev->interface); -+} -+ -+static int hso_get_activity(struct hso_device *hso_dev) -+{ -+ if (hso_dev->usb->state == USB_STATE_SUSPENDED) { -+ if (!hso_dev->is_active) { -+ hso_dev->is_active = 1; -+ schedule_work(&hso_dev->async_get_intf); -+ } -+ } -+ -+ if (hso_dev->usb->state != USB_STATE_CONFIGURED) -+ return -EAGAIN; -+ -+ usb_mark_last_busy(hso_dev->usb); -+ -+ return 0; -+} -+ -+static int hso_put_activity(struct hso_device *hso_dev) -+{ -+ if (hso_dev->usb->state != USB_STATE_SUSPENDED) { -+ if (hso_dev->is_active) { -+ hso_dev->is_active = 0; -+ schedule_work(&hso_dev->async_put_intf); -+ return -EAGAIN; -+ } -+ } -+ hso_dev->is_active = 0; -+ return 0; -+} -+ -+/* called by kernel when we need to suspend device */ -+static int hso_suspend(struct usb_interface *iface, pm_message_t message) -+{ -+ int i, result; -+ -+ /* Stop all serial ports */ -+ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { -+ if (serial_table[i] && (serial_table[i]->interface == iface)) { -+ result = hso_stop_serial_device(serial_table[i]); -+ if (result) -+ goto out; -+ } -+ } -+ -+ /* Stop all network ports */ -+ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { -+ if (network_table[i] && -+ (network_table[i]->interface == iface)) { -+ result = hso_stop_net_device(network_table[i]); -+ if (result) -+ goto out; -+ } -+ } -+ -+out: -+ return 0; -+} -+ -+/* called by kernel when we need to resume device */ -+static int hso_resume(struct usb_interface *iface) -+{ -+ int i, result = 0; -+ struct hso_net *hso_net; -+ -+ /* Start all serial ports */ -+ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { -+ if (serial_table[i] && (serial_table[i]->interface == iface)) { -+ if (atomic_read(&dev2ser(serial_table[i])->port.count)) { -+ result = -+ hso_start_serial_device(serial_table[i], GFP_NOIO); -+ hso_kick_transmit(dev2ser(serial_table[i])); -+ if (result) -+ goto out; -+ } -+ } -+ } -+ -+ /* Start all network ports */ -+ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { -+ if (network_table[i] && -+ (network_table[i]->interface == iface)) { -+ hso_net = dev2net(network_table[i]); -+ if (hso_net->flags & IFF_UP) { -+ /* First transmit any lingering data, -+ then restart the device. */ -+ if (hso_net->skb_tx_buf) { -+ dev_dbg(&iface->dev, -+ "Transmitting" -+ " lingering data\n"); -+ hso_net_start_xmit(hso_net->skb_tx_buf, -+ hso_net->net); -+ hso_net->skb_tx_buf = NULL; -+ } -+ result = hso_start_net_device(network_table[i]); -+ if (result) -+ goto out; -+ } -+ } -+ } -+ -+out: -+ return result; -+} -+ -+static void reset_device(struct work_struct *data) -+{ -+ struct hso_device *hso_dev = -+ container_of(data, struct hso_device, reset_device); -+ struct usb_device *usb = hso_dev->usb; -+ int result; -+ -+ if (hso_dev->usb_gone) { -+ D1("No reset during disconnect\n"); -+ } else { -+ result = usb_lock_device_for_reset(usb, hso_dev->interface); -+ if (result < 0) -+ D1("unable to lock device for reset: %d\n", result); -+ else { -+ usb_reset_device(usb); -+ usb_unlock_device(usb); -+ } -+ } -+} -+ -+static void hso_serial_ref_free(struct kref *ref) -+{ -+ struct hso_device *hso_dev = container_of(ref, struct hso_device, ref); -+ -+ hso_free_serial_device(hso_dev); -+} -+ -+static void hso_free_interface(struct usb_interface *interface) -+{ -+ struct hso_serial *hso_dev; -+ int i; -+ -+ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { -+ if (serial_table[i] && -+ (serial_table[i]->interface == interface)) { -+ hso_dev = dev2ser(serial_table[i]); -+ tty_port_tty_hangup(&hso_dev->port, false); -+ mutex_lock(&hso_dev->parent->mutex); -+ hso_dev->parent->usb_gone = 1; -+ mutex_unlock(&hso_dev->parent->mutex); -+ kref_put(&serial_table[i]->ref, hso_serial_ref_free); -+ } -+ } -+ -+ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { -+ if (network_table[i] && -+ (network_table[i]->interface == interface)) { -+ struct rfkill *rfk = dev2net(network_table[i])->rfkill; -+ /* hso_stop_net_device doesn't stop the net queue since -+ * traffic needs to start it again when suspended */ -+ netif_stop_queue(dev2net(network_table[i])->net); -+ hso_stop_net_device(network_table[i]); -+ cancel_work_sync(&network_table[i]->async_put_intf); -+ cancel_work_sync(&network_table[i]->async_get_intf); -+ if (rfk) { -+ rfkill_unregister(rfk); -+ rfkill_destroy(rfk); -+ } -+ hso_free_net_device(network_table[i]); -+ } -+ } -+} -+ -+/* Helper functions */ -+ -+/* Get the endpoint ! */ -+static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *intf, -+ int type, int dir) -+{ -+ int i; -+ struct usb_host_interface *iface = intf->cur_altsetting; -+ struct usb_endpoint_descriptor *endp; -+ -+ for (i = 0; i < iface->desc.bNumEndpoints; i++) { -+ endp = &iface->endpoint[i].desc; -+ if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) && -+ (usb_endpoint_type(endp) == type)) -+ return endp; -+ } -+ -+ return NULL; -+} -+ -+/* Get the byte that describes which ports are enabled */ -+static int hso_get_mux_ports(struct usb_interface *intf, unsigned char *ports) -+{ -+ int i; -+ struct usb_host_interface *iface = intf->cur_altsetting; -+ -+ if (iface->extralen == 3) { -+ *ports = iface->extra[2]; -+ return 0; -+ } -+ -+ for (i = 0; i < iface->desc.bNumEndpoints; i++) { -+ if (iface->endpoint[i].extralen == 3) { -+ *ports = iface->endpoint[i].extra[2]; -+ return 0; -+ } -+ } -+ -+ return -1; -+} -+ -+/* interrupt urb needs to be submitted, used for serial read of muxed port */ -+static int hso_mux_submit_intr_urb(struct hso_shared_int *shared_int, -+ struct usb_device *usb, gfp_t gfp) -+{ -+ int result; -+ -+ usb_fill_int_urb(shared_int->shared_intr_urb, usb, -+ usb_rcvintpipe(usb, -+ shared_int->intr_endp->bEndpointAddress & 0x7F), -+ shared_int->shared_intr_buf, -+ 1, -+ intr_callback, shared_int, -+ shared_int->intr_endp->bInterval); -+ -+ result = usb_submit_urb(shared_int->shared_intr_urb, gfp); -+ if (result) -+ dev_warn(&usb->dev, "%s failed mux_intr_urb %d\n", __func__, -+ result); -+ -+ return result; -+} -+ -+/* operations setup of the serial interface */ -+static const struct tty_operations hso_serial_ops = { -+ .open = hso_serial_open, -+ .close = hso_serial_close, -+ .write = hso_serial_write, -+ .write_room = hso_serial_write_room, -+ .ioctl = hso_serial_ioctl, -+ .set_termios = hso_serial_set_termios, -+ .chars_in_buffer = hso_serial_chars_in_buffer, -+ .tiocmget = hso_serial_tiocmget, -+ .tiocmset = hso_serial_tiocmset, -+ .get_icount = hso_get_count, -+ .unthrottle = hso_unthrottle -+}; -+ -+static struct usb_driver hso_driver = { -+ .name = driver_name, -+ .probe = hso_probe, -+ .disconnect = hso_disconnect, -+ .id_table = hso_ids, -+ .suspend = hso_suspend, -+ .resume = hso_resume, -+ .reset_resume = hso_resume, -+ .supports_autosuspend = 1, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+static int __init hso_init(void) -+{ -+ int i; -+ int result; -+ -+ /* put it in the log */ -+ printk(KERN_INFO "hso: %s\n", version); -+ -+ /* Initialise the serial table semaphore and table */ -+ spin_lock_init(&serial_table_lock); -+ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) -+ serial_table[i] = NULL; -+ -+ /* allocate our driver using the proper amount of supported minors */ -+ tty_drv = alloc_tty_driver(HSO_SERIAL_TTY_MINORS); -+ if (!tty_drv) -+ return -ENOMEM; -+ -+ /* fill in all needed values */ -+ tty_drv->driver_name = driver_name; -+ tty_drv->name = tty_filename; -+ -+ /* if major number is provided as parameter, use that one */ -+ if (tty_major) -+ tty_drv->major = tty_major; -+ -+ tty_drv->minor_start = 0; -+ tty_drv->type = TTY_DRIVER_TYPE_SERIAL; -+ tty_drv->subtype = SERIAL_TYPE_NORMAL; -+ tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; -+ tty_drv->init_termios = tty_std_termios; -+ hso_init_termios(&tty_drv->init_termios); -+ tty_set_operations(tty_drv, &hso_serial_ops); -+ -+ /* register the tty driver */ -+ result = tty_register_driver(tty_drv); -+ if (result) { -+ printk(KERN_ERR "%s - tty_register_driver failed(%d)\n", -+ __func__, result); -+ goto err_free_tty; -+ } -+ -+ /* register this module as an usb driver */ -+ result = usb_register(&hso_driver); -+ if (result) { -+ printk(KERN_ERR "Could not register hso driver? error: %d\n", -+ result); -+ goto err_unreg_tty; -+ } -+ -+ /* done */ -+ return 0; -+err_unreg_tty: -+ tty_unregister_driver(tty_drv); -+err_free_tty: -+ put_tty_driver(tty_drv); -+ return result; -+} -+ -+static void __exit hso_exit(void) -+{ -+ printk(KERN_INFO "hso: unloaded\n"); -+ -+ tty_unregister_driver(tty_drv); -+ put_tty_driver(tty_drv); -+ /* deregister the usb driver */ -+ usb_deregister(&hso_driver); -+} -+ -+/* Module definitions */ -+module_init(hso_init); -+module_exit(hso_exit); -+ -+MODULE_AUTHOR(MOD_AUTHOR); -+MODULE_DESCRIPTION(MOD_DESCRIPTION); -+MODULE_LICENSE(MOD_LICENSE); -+ -+/* change the debug level (eg: insmod hso.ko debug=0x04) */ -+MODULE_PARM_DESC(debug, "Level of debug [0x01 | 0x02 | 0x04 | 0x08 | 0x10]"); -+module_param(debug, int, S_IRUGO | S_IWUSR); -+ -+/* set the major tty number (eg: insmod hso.ko tty_major=245) */ -+MODULE_PARM_DESC(tty_major, "Set the major tty number"); -+module_param(tty_major, int, S_IRUGO | S_IWUSR); -+ -+/* disable network interface (eg: insmod hso.ko disable_net=1) */ -+MODULE_PARM_DESC(disable_net, "Disable the network interface"); -+module_param(disable_net, int, S_IRUGO | S_IWUSR); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/huawei_cdc_ncm.c backports-3.18.1-1/drivers/net/usb/huawei_cdc_ncm.c ---- backports-3.18.1-1.org/drivers/net/usb/huawei_cdc_ncm.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/huawei_cdc_ncm.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,221 @@ -+/* huawei_cdc_ncm.c - handles Huawei devices using the CDC NCM protocol as -+ * transport layer. -+ * Copyright (C) 2013 Enrico Mioso mrkiko.rs@gmail.com -+ * -+ * -+ * ABSTRACT: -+ * This driver handles devices resembling the CDC NCM standard, but -+ * encapsulating another protocol inside it. An example are some Huawei 3G -+ * devices, exposing an embedded AT channel where you can set up the NCM -+ * connection. -+ * This code has been heavily inspired by the cdc_mbim.c driver, which is -+ * Copyright (c) 2012 Smith Micro Software, Inc. -+ * Copyright (c) 2012 Bjørn Mork bjorn@mork.no -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ */ -+ -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/ethtool.h> -+#include <linux/if_vlan.h> -+#include <linux/ip.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/usb/cdc.h> -+#include <linux/usb/usbnet.h> -+#include <linux/usb/cdc-wdm.h> -+#include <linux/usb/cdc_ncm.h> -+ -+/* Driver data */ -+struct huawei_cdc_ncm_state { -+ struct cdc_ncm_ctx *ctx; -+ atomic_t pmcount; -+ struct usb_driver *subdriver; -+ struct usb_interface *control; -+ struct usb_interface *data; -+}; -+ -+static int huawei_cdc_ncm_manage_power(struct usbnet *usbnet_dev, int on) -+{ -+ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; -+ int rv; -+ -+ if ((on && atomic_add_return(1, &drvstate->pmcount) == 1) || -+ (!on && atomic_dec_and_test(&drvstate->pmcount))) { -+ rv = usb_autopm_get_interface(usbnet_dev->intf); -+ usbnet_dev->intf->needs_remote_wakeup = on; -+ if (!rv) -+ usb_autopm_put_interface(usbnet_dev->intf); -+ } -+ return 0; -+} -+ -+static int huawei_cdc_ncm_wdm_manage_power(struct usb_interface *intf, -+ int status) -+{ -+ struct usbnet *usbnet_dev = usb_get_intfdata(intf); -+ -+ /* can be called while disconnecting */ -+ if (!usbnet_dev) -+ return 0; -+ -+ return huawei_cdc_ncm_manage_power(usbnet_dev, status); -+} -+ -+ -+static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev, -+ struct usb_interface *intf) -+{ -+ struct cdc_ncm_ctx *ctx; -+ struct usb_driver *subdriver = ERR_PTR(-ENODEV); -+ int ret = -ENODEV; -+ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; -+ -+ /* altsetting should always be 1 for NCM devices - so we hard-coded -+ * it here -+ */ -+ ret = cdc_ncm_bind_common(usbnet_dev, intf, 1); -+ if (ret) -+ goto err; -+ -+ ctx = drvstate->ctx; -+ -+ if (usbnet_dev->status) -+ /* The wMaxCommand buffer must be big enough to hold -+ * any message from the modem. Experience has shown -+ * that some replies are more than 256 bytes long -+ */ -+ subdriver = usb_cdc_wdm_register(ctx->control, -+ &usbnet_dev->status->desc, -+ 1024, /* wMaxCommand */ -+ huawei_cdc_ncm_wdm_manage_power); -+ if (IS_ERR(subdriver)) { -+ ret = PTR_ERR(subdriver); -+ cdc_ncm_unbind(usbnet_dev, intf); -+ goto err; -+ } -+ -+ /* Prevent usbnet from using the status descriptor */ -+ usbnet_dev->status = NULL; -+ -+ drvstate->subdriver = subdriver; -+ -+err: -+ return ret; -+} -+ -+static void huawei_cdc_ncm_unbind(struct usbnet *usbnet_dev, -+ struct usb_interface *intf) -+{ -+ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; -+ struct cdc_ncm_ctx *ctx = drvstate->ctx; -+ -+ if (drvstate->subdriver && drvstate->subdriver->disconnect) -+ drvstate->subdriver->disconnect(ctx->control); -+ drvstate->subdriver = NULL; -+ -+ cdc_ncm_unbind(usbnet_dev, intf); -+} -+ -+static int huawei_cdc_ncm_suspend(struct usb_interface *intf, -+ pm_message_t message) -+{ -+ int ret = 0; -+ struct usbnet *usbnet_dev = usb_get_intfdata(intf); -+ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; -+ struct cdc_ncm_ctx *ctx = drvstate->ctx; -+ -+ if (ctx == NULL) { -+ ret = -ENODEV; -+ goto error; -+ } -+ -+ ret = usbnet_suspend(intf, message); -+ if (ret < 0) -+ goto error; -+ -+ if (intf == ctx->control && -+ drvstate->subdriver && -+ drvstate->subdriver->suspend) -+ ret = drvstate->subdriver->suspend(intf, message); -+ if (ret < 0) -+ usbnet_resume(intf); -+ -+error: -+ return ret; -+} -+ -+static int huawei_cdc_ncm_resume(struct usb_interface *intf) -+{ -+ int ret = 0; -+ struct usbnet *usbnet_dev = usb_get_intfdata(intf); -+ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; -+ bool callsub; -+ struct cdc_ncm_ctx *ctx = drvstate->ctx; -+ -+ /* should we call subdriver's resume function? */ -+ callsub = -+ (intf == ctx->control && -+ drvstate->subdriver && -+ drvstate->subdriver->resume); -+ -+ if (callsub) -+ ret = drvstate->subdriver->resume(intf); -+ if (ret < 0) -+ goto err; -+ ret = usbnet_resume(intf); -+ if (ret < 0 && callsub) -+ drvstate->subdriver->suspend(intf, PMSG_SUSPEND); -+err: -+ return ret; -+} -+ -+static const struct driver_info huawei_cdc_ncm_info = { -+ .description = "Huawei CDC NCM device", -+ .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN, -+ .bind = huawei_cdc_ncm_bind, -+ .unbind = huawei_cdc_ncm_unbind, -+ .manage_power = huawei_cdc_ncm_manage_power, -+ .rx_fixup = cdc_ncm_rx_fixup, -+ .tx_fixup = cdc_ncm_tx_fixup, -+}; -+ -+static const struct usb_device_id huawei_cdc_ncm_devs[] = { -+ /* Huawei NCM devices disguised as vendor specific */ -+ { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16), -+ .driver_info = (unsigned long)&huawei_cdc_ncm_info, -+ }, -+ { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x46), -+ .driver_info = (unsigned long)&huawei_cdc_ncm_info, -+ }, -+ { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x76), -+ .driver_info = (unsigned long)&huawei_cdc_ncm_info, -+ }, -+ { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x03, 0x16), -+ .driver_info = (unsigned long)&huawei_cdc_ncm_info, -+ }, -+ -+ /* Terminating entry */ -+ { -+ }, -+}; -+MODULE_DEVICE_TABLE(usb, huawei_cdc_ncm_devs); -+ -+static struct usb_driver huawei_cdc_ncm_driver = { -+ .name = "huawei_cdc_ncm", -+ .id_table = huawei_cdc_ncm_devs, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = huawei_cdc_ncm_suspend, -+ .resume = huawei_cdc_ncm_resume, -+ .reset_resume = huawei_cdc_ncm_resume, -+ .supports_autosuspend = 1, -+ .disable_hub_initiated_lpm = 1, -+}; -+module_usb_driver(huawei_cdc_ncm_driver); -+MODULE_AUTHOR("Enrico Mioso mrkiko.rs@gmail.com"); -+MODULE_DESCRIPTION("USB CDC NCM host driver with encapsulated protocol support"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/int51x1.c backports-3.18.1-1/drivers/net/usb/int51x1.c ---- backports-3.18.1-1.org/drivers/net/usb/int51x1.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/int51x1.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,199 @@ -+/* -+ * Copyright (c) 2009 Peter Holik -+ * -+ * Intellon usb PLC (Powerline Communications) usb net driver -+ * -+ * http://www.tandel.be/downloads/INT51X1_Datasheet.pdf -+ * -+ * Based on the work of Jan 'RedBully' Seiffert -+ */ -+ -+/* -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or. -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include <linux/module.h> -+#include <linux/ctype.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/slab.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/usb/usbnet.h> -+ -+#define INT51X1_VENDOR_ID 0x09e1 -+#define INT51X1_PRODUCT_ID 0x5121 -+ -+#define INT51X1_HEADER_SIZE 2 /* 2 byte header */ -+ -+#define PACKET_TYPE_PROMISCUOUS (1 << 0) -+#define PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */ -+#define PACKET_TYPE_DIRECTED (1 << 2) -+#define PACKET_TYPE_BROADCAST (1 << 3) -+#define PACKET_TYPE_MULTICAST (1 << 4) /* filtered */ -+ -+#define SET_ETHERNET_PACKET_FILTER 0x43 -+ -+static int int51x1_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ int len; -+ -+ if (!(pskb_may_pull(skb, INT51X1_HEADER_SIZE))) { -+ netdev_err(dev->net, "unexpected tiny rx frame\n"); -+ return 0; -+ } -+ -+ len = le16_to_cpu(*(__le16 *)&skb->data[skb->len - 2]); -+ -+ skb_trim(skb, len); -+ -+ return 1; -+} -+ -+static struct sk_buff *int51x1_tx_fixup(struct usbnet *dev, -+ struct sk_buff *skb, gfp_t flags) -+{ -+ int pack_len = skb->len; -+ int pack_with_header_len = pack_len + INT51X1_HEADER_SIZE; -+ int headroom = skb_headroom(skb); -+ int tailroom = skb_tailroom(skb); -+ int need_tail = 0; -+ __le16 *len; -+ -+ /* if packet and our header is smaler than 64 pad to 64 (+ ZLP) */ -+ if ((pack_with_header_len) < dev->maxpacket) -+ need_tail = dev->maxpacket - pack_with_header_len + 1; -+ /* -+ * usbnet would send a ZLP if packetlength mod urbsize == 0 for us, -+ * but we need to know ourself, because this would add to the length -+ * we send down to the device... -+ */ -+ else if (!(pack_with_header_len % dev->maxpacket)) -+ need_tail = 1; -+ -+ if (!skb_cloned(skb) && -+ (headroom + tailroom >= need_tail + INT51X1_HEADER_SIZE)) { -+ if (headroom < INT51X1_HEADER_SIZE || tailroom < need_tail) { -+ skb->data = memmove(skb->head + INT51X1_HEADER_SIZE, -+ skb->data, skb->len); -+ skb_set_tail_pointer(skb, skb->len); -+ } -+ } else { -+ struct sk_buff *skb2; -+ -+ skb2 = skb_copy_expand(skb, -+ INT51X1_HEADER_SIZE, -+ need_tail, -+ flags); -+ dev_kfree_skb_any(skb); -+ if (!skb2) -+ return NULL; -+ skb = skb2; -+ } -+ -+ pack_len += need_tail; -+ pack_len &= 0x07ff; -+ -+ len = (__le16 *) __skb_push(skb, INT51X1_HEADER_SIZE); -+ *len = cpu_to_le16(pack_len); -+ -+ if(need_tail) -+ memset(__skb_put(skb, need_tail), 0, need_tail); -+ -+ return skb; -+} -+ -+static void int51x1_set_multicast(struct net_device *netdev) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u16 filter = PACKET_TYPE_DIRECTED | PACKET_TYPE_BROADCAST; -+ -+ if (netdev->flags & IFF_PROMISC) { -+ /* do not expect to see traffic of other PLCs */ -+ filter |= PACKET_TYPE_PROMISCUOUS; -+ netdev_info(dev->net, "promiscuous mode enabled\n"); -+ } else if (!netdev_mc_empty(netdev) || -+ (netdev->flags & IFF_ALLMULTI)) { -+ filter |= PACKET_TYPE_ALL_MULTICAST; -+ netdev_dbg(dev->net, "receive all multicast enabled\n"); -+ } else { -+ /* ~PROMISCUOUS, ~MULTICAST */ -+ netdev_dbg(dev->net, "receive own packets only\n"); -+ } -+ -+ usbnet_write_cmd_async(dev, SET_ETHERNET_PACKET_FILTER, -+ USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, -+ filter, 0, NULL, 0); -+} -+ -+static const struct net_device_ops int51x1_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_set_mac_address = eth_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_set_rx_mode = int51x1_set_multicast, -+}; -+ -+static int int51x1_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int status = usbnet_get_ethernet_addr(dev, 3); -+ -+ if (status) -+ return status; -+ -+ dev->net->hard_header_len += INT51X1_HEADER_SIZE; -+ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; -+ dev->net->netdev_ops = &int51x1_netdev_ops; -+ -+ return usbnet_get_endpoints(dev, intf); -+} -+ -+static const struct driver_info int51x1_info = { -+ .description = "Intellon usb powerline adapter", -+ .bind = int51x1_bind, -+ .rx_fixup = int51x1_rx_fixup, -+ .tx_fixup = int51x1_tx_fixup, -+ .in = 1, -+ .out = 2, -+ .flags = FLAG_ETHER, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ USB_DEVICE(INT51X1_VENDOR_ID, INT51X1_PRODUCT_ID), -+ .driver_info = (unsigned long) &int51x1_info, -+ }, -+ {}, -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver int51x1_driver = { -+ .name = "int51x1", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(int51x1_driver); -+ -+MODULE_AUTHOR("Peter Holik"); -+MODULE_DESCRIPTION("Intellon usb powerline adapter"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/ipheth.c backports-3.18.1-1/drivers/net/usb/ipheth.c ---- backports-3.18.1-1.org/drivers/net/usb/ipheth.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/ipheth.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,588 @@ -+/* -+ * ipheth.c - Apple iPhone USB Ethernet driver -+ * -+ * Copyright (c) 2009 Diego Giagio diego@giagio.com -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions -+ * are met: -+ * 1. Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * 2. Redistributions in binary form must reproduce the above copyright -+ * notice, this list of conditions and the following disclaimer in the -+ * documentation and/or other materials provided with the distribution. -+ * 3. Neither the name of GIAGIO.COM nor the names of its contributors -+ * may be used to endorse or promote products derived from this software -+ * without specific prior written permission. -+ * -+ * Alternatively, provided that this notice is retained in full, this -+ * software may be distributed under the terms of the GNU General -+ * Public License ("GPL") version 2, in which case the provisions of the -+ * GPL apply INSTEAD OF those given above. -+ * -+ * The provided data structures and external interfaces from this code -+ * are not restricted to be used by modules with a GPL compatible license. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH -+ * DAMAGE. -+ * -+ * -+ * Attention: iPhone device must be paired, otherwise it won't respond to our -+ * driver. For more info: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver -+ * -+ */ -+ -+#include <linux/kernel.h> -+#include <linux/errno.h> -+#include <linux/slab.h> -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/usb.h> -+#include <linux/workqueue.h> -+ -+#define USB_VENDOR_APPLE 0x05ac -+#define USB_PRODUCT_IPHONE 0x1290 -+#define USB_PRODUCT_IPHONE_3G 0x1292 -+#define USB_PRODUCT_IPHONE_3GS 0x1294 -+#define USB_PRODUCT_IPHONE_4 0x1297 -+#define USB_PRODUCT_IPAD 0x129a -+#define USB_PRODUCT_IPAD_2 0x12a2 -+#define USB_PRODUCT_IPAD_3 0x12a6 -+#define USB_PRODUCT_IPAD_MINI 0x12ab -+#define USB_PRODUCT_IPHONE_4_VZW 0x129c -+#define USB_PRODUCT_IPHONE_4S 0x12a0 -+#define USB_PRODUCT_IPHONE_5 0x12a8 -+ -+#define IPHETH_USBINTF_CLASS 255 -+#define IPHETH_USBINTF_SUBCLASS 253 -+#define IPHETH_USBINTF_PROTO 1 -+ -+#define IPHETH_BUF_SIZE 1516 -+#define IPHETH_IP_ALIGN 2 /* padding at front of URB */ -+#define IPHETH_TX_TIMEOUT (5 * HZ) -+ -+#define IPHETH_INTFNUM 2 -+#define IPHETH_ALT_INTFNUM 1 -+ -+#define IPHETH_CTRL_ENDP 0x00 -+#define IPHETH_CTRL_BUF_SIZE 0x40 -+#define IPHETH_CTRL_TIMEOUT (5 * HZ) -+ -+#define IPHETH_CMD_GET_MACADDR 0x00 -+#define IPHETH_CMD_CARRIER_CHECK 0x45 -+ -+#define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ) -+#define IPHETH_CARRIER_ON 0x04 -+ -+static struct usb_device_id ipheth_table[] = { -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPAD, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_2, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_3, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_MINI, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4_VZW, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { USB_DEVICE_AND_INTERFACE_INFO( -+ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5, -+ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, -+ IPHETH_USBINTF_PROTO) }, -+ { } -+}; -+MODULE_DEVICE_TABLE(usb, ipheth_table); -+ -+struct ipheth_device { -+ struct usb_device *udev; -+ struct usb_interface *intf; -+ struct net_device *net; -+ struct sk_buff *tx_skb; -+ struct urb *tx_urb; -+ struct urb *rx_urb; -+ unsigned char *tx_buf; -+ unsigned char *rx_buf; -+ unsigned char *ctrl_buf; -+ u8 bulk_in; -+ u8 bulk_out; -+ struct delayed_work carrier_work; -+}; -+ -+static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags); -+ -+static int ipheth_alloc_urbs(struct ipheth_device *iphone) -+{ -+ struct urb *tx_urb = NULL; -+ struct urb *rx_urb = NULL; -+ u8 *tx_buf = NULL; -+ u8 *rx_buf = NULL; -+ -+ tx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (tx_urb == NULL) -+ goto error_nomem; -+ -+ rx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (rx_urb == NULL) -+ goto free_tx_urb; -+ -+ tx_buf = usb_alloc_coherent(iphone->udev, IPHETH_BUF_SIZE, -+ GFP_KERNEL, &tx_urb->transfer_dma); -+ if (tx_buf == NULL) -+ goto free_rx_urb; -+ -+ rx_buf = usb_alloc_coherent(iphone->udev, IPHETH_BUF_SIZE, -+ GFP_KERNEL, &rx_urb->transfer_dma); -+ if (rx_buf == NULL) -+ goto free_tx_buf; -+ -+ -+ iphone->tx_urb = tx_urb; -+ iphone->rx_urb = rx_urb; -+ iphone->tx_buf = tx_buf; -+ iphone->rx_buf = rx_buf; -+ return 0; -+ -+free_tx_buf: -+ usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, tx_buf, -+ tx_urb->transfer_dma); -+free_rx_urb: -+ usb_free_urb(rx_urb); -+free_tx_urb: -+ usb_free_urb(tx_urb); -+error_nomem: -+ return -ENOMEM; -+} -+ -+static void ipheth_free_urbs(struct ipheth_device *iphone) -+{ -+ usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, iphone->rx_buf, -+ iphone->rx_urb->transfer_dma); -+ usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, iphone->tx_buf, -+ iphone->tx_urb->transfer_dma); -+ usb_free_urb(iphone->rx_urb); -+ usb_free_urb(iphone->tx_urb); -+} -+ -+static void ipheth_kill_urbs(struct ipheth_device *dev) -+{ -+ usb_kill_urb(dev->tx_urb); -+ usb_kill_urb(dev->rx_urb); -+} -+ -+static void ipheth_rcvbulk_callback(struct urb *urb) -+{ -+ struct ipheth_device *dev; -+ struct sk_buff *skb; -+ int status; -+ char *buf; -+ int len; -+ -+ dev = urb->context; -+ if (dev == NULL) -+ return; -+ -+ status = urb->status; -+ switch (status) { -+ case -ENOENT: -+ case -ECONNRESET: -+ case -ESHUTDOWN: -+ return; -+ case 0: -+ break; -+ default: -+ dev_err(&dev->intf->dev, "%s: urb status: %d\n", -+ __func__, status); -+ return; -+ } -+ -+ if (urb->actual_length <= IPHETH_IP_ALIGN) { -+ dev->net->stats.rx_length_errors++; -+ return; -+ } -+ len = urb->actual_length - IPHETH_IP_ALIGN; -+ buf = urb->transfer_buffer + IPHETH_IP_ALIGN; -+ -+ skb = dev_alloc_skb(len); -+ if (!skb) { -+ dev_err(&dev->intf->dev, "%s: dev_alloc_skb: -ENOMEM\n", -+ __func__); -+ dev->net->stats.rx_dropped++; -+ return; -+ } -+ -+ memcpy(skb_put(skb, len), buf, len); -+ skb->dev = dev->net; -+ skb->protocol = eth_type_trans(skb, dev->net); -+ -+ dev->net->stats.rx_packets++; -+ dev->net->stats.rx_bytes += len; -+ -+ netif_rx(skb); -+ ipheth_rx_submit(dev, GFP_ATOMIC); -+} -+ -+static void ipheth_sndbulk_callback(struct urb *urb) -+{ -+ struct ipheth_device *dev; -+ int status = urb->status; -+ -+ dev = urb->context; -+ if (dev == NULL) -+ return; -+ -+ if (status != 0 && -+ status != -ENOENT && -+ status != -ECONNRESET && -+ status != -ESHUTDOWN) -+ dev_err(&dev->intf->dev, "%s: urb status: %d\n", -+ __func__, status); -+ -+ dev_kfree_skb_irq(dev->tx_skb); -+ netif_wake_queue(dev->net); -+} -+ -+static int ipheth_carrier_set(struct ipheth_device *dev) -+{ -+ struct usb_device *udev = dev->udev; -+ int retval; -+ -+ retval = usb_control_msg(udev, -+ usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), -+ IPHETH_CMD_CARRIER_CHECK, /* request */ -+ 0xc0, /* request type */ -+ 0x00, /* value */ -+ 0x02, /* index */ -+ dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE, -+ IPHETH_CTRL_TIMEOUT); -+ if (retval < 0) { -+ dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n", -+ __func__, retval); -+ return retval; -+ } -+ -+ if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON) -+ netif_carrier_on(dev->net); -+ else -+ netif_carrier_off(dev->net); -+ -+ return 0; -+} -+ -+static void ipheth_carrier_check_work(struct work_struct *work) -+{ -+ struct ipheth_device *dev = container_of(work, struct ipheth_device, -+ carrier_work.work); -+ -+ ipheth_carrier_set(dev); -+ schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); -+} -+ -+static int ipheth_get_macaddr(struct ipheth_device *dev) -+{ -+ struct usb_device *udev = dev->udev; -+ struct net_device *net = dev->net; -+ int retval; -+ -+ retval = usb_control_msg(udev, -+ usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), -+ IPHETH_CMD_GET_MACADDR, /* request */ -+ 0xc0, /* request type */ -+ 0x00, /* value */ -+ 0x02, /* index */ -+ dev->ctrl_buf, -+ IPHETH_CTRL_BUF_SIZE, -+ IPHETH_CTRL_TIMEOUT); -+ if (retval < 0) { -+ dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n", -+ __func__, retval); -+ } else if (retval < ETH_ALEN) { -+ dev_err(&dev->intf->dev, -+ "%s: usb_control_msg: short packet: %d bytes\n", -+ __func__, retval); -+ retval = -EINVAL; -+ } else { -+ memcpy(net->dev_addr, dev->ctrl_buf, ETH_ALEN); -+ retval = 0; -+ } -+ -+ return retval; -+} -+ -+static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags) -+{ -+ struct usb_device *udev = dev->udev; -+ int retval; -+ -+ usb_fill_bulk_urb(dev->rx_urb, udev, -+ usb_rcvbulkpipe(udev, dev->bulk_in), -+ dev->rx_buf, IPHETH_BUF_SIZE, -+ ipheth_rcvbulk_callback, -+ dev); -+ dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; -+ -+ retval = usb_submit_urb(dev->rx_urb, mem_flags); -+ if (retval) -+ dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n", -+ __func__, retval); -+ return retval; -+} -+ -+static int ipheth_open(struct net_device *net) -+{ -+ struct ipheth_device *dev = netdev_priv(net); -+ struct usb_device *udev = dev->udev; -+ int retval = 0; -+ -+ usb_set_interface(udev, IPHETH_INTFNUM, IPHETH_ALT_INTFNUM); -+ -+ retval = ipheth_carrier_set(dev); -+ if (retval) -+ return retval; -+ -+ retval = ipheth_rx_submit(dev, GFP_KERNEL); -+ if (retval) -+ return retval; -+ -+ schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); -+ netif_start_queue(net); -+ return retval; -+} -+ -+static int ipheth_close(struct net_device *net) -+{ -+ struct ipheth_device *dev = netdev_priv(net); -+ -+ cancel_delayed_work_sync(&dev->carrier_work); -+ netif_stop_queue(net); -+ return 0; -+} -+ -+static int ipheth_tx(struct sk_buff *skb, struct net_device *net) -+{ -+ struct ipheth_device *dev = netdev_priv(net); -+ struct usb_device *udev = dev->udev; -+ int retval; -+ -+ /* Paranoid */ -+ if (skb->len > IPHETH_BUF_SIZE) { -+ WARN(1, "%s: skb too large: %d bytes\n", __func__, skb->len); -+ dev->net->stats.tx_dropped++; -+ dev_kfree_skb_irq(skb); -+ return NETDEV_TX_OK; -+ } -+ -+ memcpy(dev->tx_buf, skb->data, skb->len); -+ if (skb->len < IPHETH_BUF_SIZE) -+ memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len); -+ -+ usb_fill_bulk_urb(dev->tx_urb, udev, -+ usb_sndbulkpipe(udev, dev->bulk_out), -+ dev->tx_buf, IPHETH_BUF_SIZE, -+ ipheth_sndbulk_callback, -+ dev); -+ dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; -+ -+ retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC); -+ if (retval) { -+ dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n", -+ __func__, retval); -+ dev->net->stats.tx_errors++; -+ dev_kfree_skb_irq(skb); -+ } else { -+ dev->tx_skb = skb; -+ -+ dev->net->stats.tx_packets++; -+ dev->net->stats.tx_bytes += skb->len; -+ netif_stop_queue(net); -+ } -+ -+ return NETDEV_TX_OK; -+} -+ -+static void ipheth_tx_timeout(struct net_device *net) -+{ -+ struct ipheth_device *dev = netdev_priv(net); -+ -+ dev_err(&dev->intf->dev, "%s: TX timeout\n", __func__); -+ dev->net->stats.tx_errors++; -+ usb_unlink_urb(dev->tx_urb); -+} -+ -+static u32 ipheth_ethtool_op_get_link(struct net_device *net) -+{ -+ struct ipheth_device *dev = netdev_priv(net); -+ return netif_carrier_ok(dev->net); -+} -+ -+static const struct ethtool_ops ops = { -+ .get_link = ipheth_ethtool_op_get_link -+}; -+ -+static const struct net_device_ops ipheth_netdev_ops = { -+ .ndo_open = ipheth_open, -+ .ndo_stop = ipheth_close, -+ .ndo_start_xmit = ipheth_tx, -+ .ndo_tx_timeout = ipheth_tx_timeout, -+}; -+ -+static int ipheth_probe(struct usb_interface *intf, -+ const struct usb_device_id *id) -+{ -+ struct usb_device *udev = interface_to_usbdev(intf); -+ struct usb_host_interface *hintf; -+ struct usb_endpoint_descriptor *endp; -+ struct ipheth_device *dev; -+ struct net_device *netdev; -+ int i; -+ int retval; -+ -+ netdev = alloc_etherdev(sizeof(struct ipheth_device)); -+ if (!netdev) -+ return -ENOMEM; -+ -+ netdev->netdev_ops = &ipheth_netdev_ops; -+ netdev->watchdog_timeo = IPHETH_TX_TIMEOUT; -+ strcpy(netdev->name, "eth%d"); -+ -+ dev = netdev_priv(netdev); -+ dev->udev = udev; -+ dev->net = netdev; -+ dev->intf = intf; -+ -+ /* Set up endpoints */ -+ hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM); -+ if (hintf == NULL) { -+ retval = -ENODEV; -+ dev_err(&intf->dev, "Unable to find alternate settings interface\n"); -+ goto err_endpoints; -+ } -+ -+ for (i = 0; i < hintf->desc.bNumEndpoints; i++) { -+ endp = &hintf->endpoint[i].desc; -+ if (usb_endpoint_is_bulk_in(endp)) -+ dev->bulk_in = endp->bEndpointAddress; -+ else if (usb_endpoint_is_bulk_out(endp)) -+ dev->bulk_out = endp->bEndpointAddress; -+ } -+ if (!(dev->bulk_in && dev->bulk_out)) { -+ retval = -ENODEV; -+ dev_err(&intf->dev, "Unable to find endpoints\n"); -+ goto err_endpoints; -+ } -+ -+ dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL); -+ if (dev->ctrl_buf == NULL) { -+ retval = -ENOMEM; -+ goto err_alloc_ctrl_buf; -+ } -+ -+ retval = ipheth_get_macaddr(dev); -+ if (retval) -+ goto err_get_macaddr; -+ -+ INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work); -+ -+ retval = ipheth_alloc_urbs(dev); -+ if (retval) { -+ dev_err(&intf->dev, "error allocating urbs: %d\n", retval); -+ goto err_alloc_urbs; -+ } -+ -+ usb_set_intfdata(intf, dev); -+ -+ SET_NETDEV_DEV(netdev, &intf->dev); -+ netdev->ethtool_ops = &ops; -+ -+ retval = register_netdev(netdev); -+ if (retval) { -+ dev_err(&intf->dev, "error registering netdev: %d\n", retval); -+ retval = -EIO; -+ goto err_register_netdev; -+ } -+ -+ dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n"); -+ return 0; -+ -+err_register_netdev: -+ ipheth_free_urbs(dev); -+err_alloc_urbs: -+err_get_macaddr: -+err_alloc_ctrl_buf: -+ kfree(dev->ctrl_buf); -+err_endpoints: -+ free_netdev(netdev); -+ return retval; -+} -+ -+static void ipheth_disconnect(struct usb_interface *intf) -+{ -+ struct ipheth_device *dev; -+ -+ dev = usb_get_intfdata(intf); -+ if (dev != NULL) { -+ unregister_netdev(dev->net); -+ ipheth_kill_urbs(dev); -+ ipheth_free_urbs(dev); -+ kfree(dev->ctrl_buf); -+ free_netdev(dev->net); -+ } -+ usb_set_intfdata(intf, NULL); -+ dev_info(&intf->dev, "Apple iPhone USB Ethernet now disconnected\n"); -+} -+ -+static struct usb_driver ipheth_driver = { -+ .name = "ipheth", -+ .probe = ipheth_probe, -+ .disconnect = ipheth_disconnect, -+ .id_table = ipheth_table, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(ipheth_driver); -+ -+MODULE_AUTHOR("Diego Giagio diego@giagio.com"); -+MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver"); -+MODULE_LICENSE("Dual BSD/GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/kalmia.c backports-3.18.1-1/drivers/net/usb/kalmia.c ---- backports-3.18.1-1.org/drivers/net/usb/kalmia.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/kalmia.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,366 @@ -+/* -+ * USB network interface driver for Samsung Kalmia based LTE USB modem like the -+ * Samsung GT-B3730 and GT-B3710. -+ * -+ * Copyright (C) 2011 Marius Bjoernstad Kotsbak marius@kotsbak.com -+ * -+ * Sponsored by Quicklink Video Distribution Services Ltd. -+ * -+ * Based on the cdc_eem module. -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ */ -+ -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ctype.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/crc32.h> -+#include <linux/usb/cdc.h> -+#include <linux/usb/usbnet.h> -+#include <linux/gfp.h> -+ -+/* -+ * The Samsung Kalmia based LTE USB modems have a CDC ACM port for modem control -+ * handled by the "option" module and an ethernet data port handled by this -+ * module. -+ * -+ * The stick must first be switched into modem mode by usb_modeswitch -+ * or similar tool. Then the modem gets sent two initialization packets by -+ * this module, which gives the MAC address of the device. User space can then -+ * connect the modem using AT commands through the ACM port and then use -+ * DHCP on the network interface exposed by this module. Network packets are -+ * sent to and from the modem in a proprietary format discovered after watching -+ * the behavior of the windows driver for the modem. -+ * -+ * More information about the use of the modem is available in usb_modeswitch -+ * forum and the project page: -+ * -+ * http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=465 -+ * https://github.com/mkotsbak/Samsung-GT-B3730-linux-driver -+ */ -+ -+/* #define DEBUG */ -+/* #define VERBOSE */ -+ -+#define KALMIA_HEADER_LENGTH 6 -+#define KALMIA_ALIGN_SIZE 4 -+#define KALMIA_USB_TIMEOUT 10000 -+ -+/*-------------------------------------------------------------------------*/ -+ -+static int -+kalmia_send_init_packet(struct usbnet *dev, u8 *init_msg, u8 init_msg_len, -+ u8 *buffer, u8 expected_len) -+{ -+ int act_len; -+ int status; -+ -+ netdev_dbg(dev->net, "Sending init packet"); -+ -+ status = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 0x02), -+ init_msg, init_msg_len, &act_len, KALMIA_USB_TIMEOUT); -+ if (status != 0) { -+ netdev_err(dev->net, -+ "Error sending init packet. Status %i, length %i\n", -+ status, act_len); -+ return status; -+ } -+ else if (act_len != init_msg_len) { -+ netdev_err(dev->net, -+ "Did not send all of init packet. Bytes sent: %i", -+ act_len); -+ } -+ else { -+ netdev_dbg(dev->net, "Successfully sent init packet."); -+ } -+ -+ status = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, 0x81), -+ buffer, expected_len, &act_len, KALMIA_USB_TIMEOUT); -+ -+ if (status != 0) -+ netdev_err(dev->net, -+ "Error receiving init result. Status %i, length %i\n", -+ status, act_len); -+ else if (act_len != expected_len) -+ netdev_err(dev->net, "Unexpected init result length: %i\n", -+ act_len); -+ -+ return status; -+} -+ -+static int -+kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr) -+{ -+ static const char init_msg_1[] = -+ { 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, -+ 0x00, 0x00 }; -+ static const char init_msg_2[] = -+ { 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf4, -+ 0x00, 0x00 }; -+ static const int buflen = 28; -+ char *usb_buf; -+ int status; -+ -+ usb_buf = kmalloc(buflen, GFP_DMA | GFP_KERNEL); -+ if (!usb_buf) -+ return -ENOMEM; -+ -+ memcpy(usb_buf, init_msg_1, 12); -+ status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_1) -+ / sizeof(init_msg_1[0]), usb_buf, 24); -+ if (status != 0) -+ return status; -+ -+ memcpy(usb_buf, init_msg_2, 12); -+ status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_2) -+ / sizeof(init_msg_2[0]), usb_buf, 28); -+ if (status != 0) -+ return status; -+ -+ memcpy(ethernet_addr, usb_buf + 10, ETH_ALEN); -+ -+ kfree(usb_buf); -+ return status; -+} -+ -+static int -+kalmia_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int status; -+ u8 ethernet_addr[ETH_ALEN]; -+ -+ /* Don't bind to AT command interface */ -+ if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC) -+ return -EINVAL; -+ -+ dev->in = usb_rcvbulkpipe(dev->udev, 0x81 & USB_ENDPOINT_NUMBER_MASK); -+ dev->out = usb_sndbulkpipe(dev->udev, 0x02 & USB_ENDPOINT_NUMBER_MASK); -+ dev->status = NULL; -+ -+ dev->net->hard_header_len += KALMIA_HEADER_LENGTH; -+ dev->hard_mtu = 1400; -+ dev->rx_urb_size = dev->hard_mtu * 10; // Found as optimal after testing -+ -+ status = kalmia_init_and_get_ethernet_addr(dev, ethernet_addr); -+ -+ if (status < 0) { -+ usb_set_intfdata(intf, NULL); -+ usb_driver_release_interface(driver_of(intf), intf); -+ return status; -+ } -+ -+ memcpy(dev->net->dev_addr, ethernet_addr, ETH_ALEN); -+ -+ return status; -+} -+ -+static struct sk_buff * -+kalmia_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) -+{ -+ struct sk_buff *skb2 = NULL; -+ u16 content_len; -+ unsigned char *header_start; -+ unsigned char ether_type_1, ether_type_2; -+ u8 remainder, padlen = 0; -+ -+ if (!skb_cloned(skb)) { -+ int headroom = skb_headroom(skb); -+ int tailroom = skb_tailroom(skb); -+ -+ if ((tailroom >= KALMIA_ALIGN_SIZE) && (headroom -+ >= KALMIA_HEADER_LENGTH)) -+ goto done; -+ -+ if ((headroom + tailroom) > (KALMIA_HEADER_LENGTH -+ + KALMIA_ALIGN_SIZE)) { -+ skb->data = memmove(skb->head + KALMIA_HEADER_LENGTH, -+ skb->data, skb->len); -+ skb_set_tail_pointer(skb, skb->len); -+ goto done; -+ } -+ } -+ -+ skb2 = skb_copy_expand(skb, KALMIA_HEADER_LENGTH, -+ KALMIA_ALIGN_SIZE, flags); -+ if (!skb2) -+ return NULL; -+ -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ -+done: -+ header_start = skb_push(skb, KALMIA_HEADER_LENGTH); -+ ether_type_1 = header_start[KALMIA_HEADER_LENGTH + 12]; -+ ether_type_2 = header_start[KALMIA_HEADER_LENGTH + 13]; -+ -+ netdev_dbg(dev->net, "Sending etherType: %02x%02x", ether_type_1, -+ ether_type_2); -+ -+ /* According to empiric data for data packages */ -+ header_start[0] = 0x57; -+ header_start[1] = 0x44; -+ content_len = skb->len - KALMIA_HEADER_LENGTH; -+ -+ put_unaligned_le16(content_len, &header_start[2]); -+ header_start[4] = ether_type_1; -+ header_start[5] = ether_type_2; -+ -+ /* Align to 4 bytes by padding with zeros */ -+ remainder = skb->len % KALMIA_ALIGN_SIZE; -+ if (remainder > 0) { -+ padlen = KALMIA_ALIGN_SIZE - remainder; -+ memset(skb_put(skb, padlen), 0, padlen); -+ } -+ -+ netdev_dbg(dev->net, -+ "Sending package with length %i and padding %i. Header: %6phC.", -+ content_len, padlen, header_start); -+ -+ return skb; -+} -+ -+static int -+kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ /* -+ * Our task here is to strip off framing, leaving skb with one -+ * data frame for the usbnet framework code to process. -+ */ -+ static const u8 HEADER_END_OF_USB_PACKET[] = -+ { 0x57, 0x5a, 0x00, 0x00, 0x08, 0x00 }; -+ static const u8 EXPECTED_UNKNOWN_HEADER_1[] = -+ { 0x57, 0x43, 0x1e, 0x00, 0x15, 0x02 }; -+ static const u8 EXPECTED_UNKNOWN_HEADER_2[] = -+ { 0x57, 0x50, 0x0e, 0x00, 0x00, 0x00 }; -+ int i = 0; -+ -+ /* incomplete header? */ -+ if (skb->len < KALMIA_HEADER_LENGTH) -+ return 0; -+ -+ do { -+ struct sk_buff *skb2 = NULL; -+ u8 *header_start; -+ u16 usb_packet_length, ether_packet_length; -+ int is_last; -+ -+ header_start = skb->data; -+ -+ if (unlikely(header_start[0] != 0x57 || header_start[1] != 0x44)) { -+ if (!memcmp(header_start, EXPECTED_UNKNOWN_HEADER_1, -+ sizeof(EXPECTED_UNKNOWN_HEADER_1)) || !memcmp( -+ header_start, EXPECTED_UNKNOWN_HEADER_2, -+ sizeof(EXPECTED_UNKNOWN_HEADER_2))) { -+ netdev_dbg(dev->net, -+ "Received expected unknown frame header: %6phC. Package length: %i\n", -+ header_start, -+ skb->len - KALMIA_HEADER_LENGTH); -+ } -+ else { -+ netdev_err(dev->net, -+ "Received unknown frame header: %6phC. Package length: %i\n", -+ header_start, -+ skb->len - KALMIA_HEADER_LENGTH); -+ return 0; -+ } -+ } -+ else -+ netdev_dbg(dev->net, -+ "Received header: %6phC. Package length: %i\n", -+ header_start, skb->len - KALMIA_HEADER_LENGTH); -+ -+ /* subtract start header and end header */ -+ usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH); -+ ether_packet_length = get_unaligned_le16(&header_start[2]); -+ skb_pull(skb, KALMIA_HEADER_LENGTH); -+ -+ /* Some small packets misses end marker */ -+ if (usb_packet_length < ether_packet_length) { -+ ether_packet_length = usb_packet_length -+ + KALMIA_HEADER_LENGTH; -+ is_last = true; -+ } -+ else { -+ netdev_dbg(dev->net, "Correct package length #%i", i -+ + 1); -+ -+ is_last = (memcmp(skb->data + ether_packet_length, -+ HEADER_END_OF_USB_PACKET, -+ sizeof(HEADER_END_OF_USB_PACKET)) == 0); -+ if (!is_last) { -+ header_start = skb->data + ether_packet_length; -+ netdev_dbg(dev->net, -+ "End header: %6phC. Package length: %i\n", -+ header_start, -+ skb->len - KALMIA_HEADER_LENGTH); -+ } -+ } -+ -+ if (is_last) { -+ skb2 = skb; -+ } -+ else { -+ skb2 = skb_clone(skb, GFP_ATOMIC); -+ if (unlikely(!skb2)) -+ return 0; -+ } -+ -+ skb_trim(skb2, ether_packet_length); -+ -+ if (is_last) { -+ return 1; -+ } -+ else { -+ usbnet_skb_return(dev, skb2); -+ skb_pull(skb, ether_packet_length); -+ } -+ -+ i++; -+ } -+ while (skb->len); -+ -+ return 1; -+} -+ -+static const struct driver_info kalmia_info = { -+ .description = "Samsung Kalmia LTE USB dongle", -+ .flags = FLAG_WWAN, -+ .bind = kalmia_bind, -+ .rx_fixup = kalmia_rx_fixup, -+ .tx_fixup = kalmia_tx_fixup -+}; -+ -+/*-------------------------------------------------------------------------*/ -+ -+static const struct usb_device_id products[] = { -+ /* The unswitched USB ID, to get the module auto loaded: */ -+ { USB_DEVICE(0x04e8, 0x689a) }, -+ /* The stick swithed into modem (by e.g. usb_modeswitch): */ -+ { USB_DEVICE(0x04e8, 0x6889), -+ .driver_info = (unsigned long) &kalmia_info, }, -+ { /* EMPTY == end of list */} }; -+MODULE_DEVICE_TABLE( usb, products); -+ -+static struct usb_driver kalmia_driver = { -+ .name = "kalmia", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(kalmia_driver); -+ -+MODULE_AUTHOR("Marius Bjoernstad Kotsbak marius@kotsbak.com"); -+MODULE_DESCRIPTION("Samsung Kalmia USB network driver"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/kaweth.c backports-3.18.1-1/drivers/net/usb/kaweth.c ---- backports-3.18.1-1.org/drivers/net/usb/kaweth.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/kaweth.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,1331 @@ -+/**************************************************************** -+ * -+ * kaweth.c - driver for KL5KUSB101 based USB->Ethernet -+ * -+ * (c) 2000 Interlan Communications -+ * (c) 2000 Stephane Alnet -+ * (C) 2001 Brad Hards -+ * (C) 2002 Oliver Neukum -+ * -+ * Original author: The Zapman zapman@interlan.net -+ * Inspired by, and much credit goes to Michael Rothwell -+ * rothwell@interlan.net for the test equipment, help, and patience -+ * Based off of (and with thanks to) Petko Manolov's pegaus.c driver. -+ * Also many thanks to Joel Silverman and Ed Surprenant at Kawasaki -+ * for providing the firmware and driver resources. -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License as -+ * published by the Free Software Foundation; either version 2, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ * -+ ****************************************************************/ -+ -+/* TODO: -+ * Develop test procedures for USB net interfaces -+ * Run test procedures -+ * Fix bugs from previous two steps -+ * Snoop other OSs for any tricks we're not doing -+ * Reduce arbitrary timeouts -+ * Smart multicast support -+ * Temporary MAC change support -+ * Tunable SOFs parameter - ioctl()? -+ * Ethernet stats collection -+ * Code formatting improvements -+ */ -+ -+#include <linux/module.h> -+#include <linux/slab.h> -+#include <linux/string.h> -+#include <linux/delay.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/usb.h> -+#include <linux/types.h> -+#include <linux/ethtool.h> -+#include <linux/dma-mapping.h> -+#include <linux/wait.h> -+#include <linux/firmware.h> -+#include <asm/uaccess.h> -+#include <asm/byteorder.h> -+ -+#undef DEBUG -+ -+#define KAWETH_MTU 1514 -+#define KAWETH_BUF_SIZE 1664 -+#define KAWETH_TX_TIMEOUT (5 * HZ) -+#define KAWETH_SCRATCH_SIZE 32 -+#define KAWETH_FIRMWARE_BUF_SIZE 4096 -+#define KAWETH_CONTROL_TIMEOUT (30000) -+ -+#define KAWETH_STATUS_BROKEN 0x0000001 -+#define KAWETH_STATUS_CLOSING 0x0000002 -+#define KAWETH_STATUS_SUSPENDING 0x0000004 -+ -+#define KAWETH_STATUS_BLOCKED (KAWETH_STATUS_CLOSING | KAWETH_STATUS_SUSPENDING) -+ -+#define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01 -+#define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02 -+#define KAWETH_PACKET_FILTER_DIRECTED 0x04 -+#define KAWETH_PACKET_FILTER_BROADCAST 0x08 -+#define KAWETH_PACKET_FILTER_MULTICAST 0x10 -+ -+/* Table 7 */ -+#define KAWETH_COMMAND_GET_ETHERNET_DESC 0x00 -+#define KAWETH_COMMAND_MULTICAST_FILTERS 0x01 -+#define KAWETH_COMMAND_SET_PACKET_FILTER 0x02 -+#define KAWETH_COMMAND_STATISTICS 0x03 -+#define KAWETH_COMMAND_SET_TEMP_MAC 0x06 -+#define KAWETH_COMMAND_GET_TEMP_MAC 0x07 -+#define KAWETH_COMMAND_SET_URB_SIZE 0x08 -+#define KAWETH_COMMAND_SET_SOFS_WAIT 0x09 -+#define KAWETH_COMMAND_SCAN 0xFF -+ -+#define KAWETH_SOFS_TO_WAIT 0x05 -+ -+#define INTBUFFERSIZE 4 -+ -+#define STATE_OFFSET 0 -+#define STATE_MASK 0x40 -+#define STATE_SHIFT 5 -+ -+#define IS_BLOCKED(s) (s & KAWETH_STATUS_BLOCKED) -+ -+ -+MODULE_AUTHOR("Michael Zappe zapman@interlan.net, Stephane Alnet stephane@u-picardie.fr, Brad Hards bhards@bigpond.net.au and Oliver Neukum oliver@neukum.org"); -+MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver"); -+MODULE_LICENSE("GPL"); -+MODULE_FIRMWARE("kaweth/new_code.bin"); -+MODULE_FIRMWARE("kaweth/new_code_fix.bin"); -+MODULE_FIRMWARE("kaweth/trigger_code.bin"); -+MODULE_FIRMWARE("kaweth/trigger_code_fix.bin"); -+ -+static const char driver_name[] = "kaweth"; -+ -+static int kaweth_probe( -+ struct usb_interface *intf, -+ const struct usb_device_id *id /* from id_table */ -+ ); -+static void kaweth_disconnect(struct usb_interface *intf); -+static int kaweth_internal_control_msg(struct usb_device *usb_dev, -+ unsigned int pipe, -+ struct usb_ctrlrequest *cmd, void *data, -+ int len, int timeout); -+static int kaweth_suspend(struct usb_interface *intf, pm_message_t message); -+static int kaweth_resume(struct usb_interface *intf); -+ -+/**************************************************************** -+ * usb_device_id -+ ****************************************************************/ -+static struct usb_device_id usb_klsi_table[] = { -+ { USB_DEVICE(0x03e8, 0x0008) }, /* AOX Endpoints USB Ethernet */ -+ { USB_DEVICE(0x04bb, 0x0901) }, /* I-O DATA USB-ET/T */ -+ { USB_DEVICE(0x0506, 0x03e8) }, /* 3Com 3C19250 */ -+ { USB_DEVICE(0x0506, 0x11f8) }, /* 3Com 3C460 */ -+ { USB_DEVICE(0x0557, 0x2002) }, /* ATEN USB Ethernet */ -+ { USB_DEVICE(0x0557, 0x4000) }, /* D-Link DSB-650C */ -+ { USB_DEVICE(0x0565, 0x0002) }, /* Peracom Enet */ -+ { USB_DEVICE(0x0565, 0x0003) }, /* Optus@Home UEP1045A */ -+ { USB_DEVICE(0x0565, 0x0005) }, /* Peracom Enet2 */ -+ { USB_DEVICE(0x05e9, 0x0008) }, /* KLSI KL5KUSB101B */ -+ { USB_DEVICE(0x05e9, 0x0009) }, /* KLSI KL5KUSB101B (Board change) */ -+ { USB_DEVICE(0x066b, 0x2202) }, /* Linksys USB10T */ -+ { USB_DEVICE(0x06e1, 0x0008) }, /* ADS USB-10BT */ -+ { USB_DEVICE(0x06e1, 0x0009) }, /* ADS USB-10BT */ -+ { USB_DEVICE(0x0707, 0x0100) }, /* SMC 2202USB */ -+ { USB_DEVICE(0x07aa, 0x0001) }, /* Correga K.K. */ -+ { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */ -+ { USB_DEVICE(0x07c9, 0xb010) }, /* Allied Telesyn AT-USB10 USB Ethernet Adapter */ -+ { USB_DEVICE(0x0846, 0x1001) }, /* NetGear EA-101 */ -+ { USB_DEVICE(0x0846, 0x1002) }, /* NetGear EA-101 */ -+ { USB_DEVICE(0x085a, 0x0008) }, /* PortGear Ethernet Adapter */ -+ { USB_DEVICE(0x085a, 0x0009) }, /* PortGear Ethernet Adapter */ -+ { USB_DEVICE(0x087d, 0x5704) }, /* Jaton USB Ethernet Device Adapter */ -+ { USB_DEVICE(0x0951, 0x0008) }, /* Kingston Technology USB Ethernet Adapter */ -+ { USB_DEVICE(0x095a, 0x3003) }, /* Portsmith Express Ethernet Adapter */ -+ { USB_DEVICE(0x10bd, 0x1427) }, /* ASANTE USB To Ethernet Adapter */ -+ { USB_DEVICE(0x1342, 0x0204) }, /* Mobility USB-Ethernet Adapter */ -+ { USB_DEVICE(0x13d2, 0x0400) }, /* Shark Pocket Adapter */ -+ { USB_DEVICE(0x1485, 0x0001) }, /* Silicom U2E */ -+ { USB_DEVICE(0x1485, 0x0002) }, /* Psion Dacom Gold Port Ethernet */ -+ { USB_DEVICE(0x1645, 0x0005) }, /* Entrega E45 */ -+ { USB_DEVICE(0x1645, 0x0008) }, /* Entrega USB Ethernet Adapter */ -+ { USB_DEVICE(0x1645, 0x8005) }, /* PortGear Ethernet Adapter */ -+ { USB_DEVICE(0x1668, 0x0323) }, /* Actiontec USB Ethernet */ -+ { USB_DEVICE(0x2001, 0x4000) }, /* D-link DSB-650C */ -+ {} /* Null terminator */ -+}; -+ -+MODULE_DEVICE_TABLE (usb, usb_klsi_table); -+ -+/**************************************************************** -+ * kaweth_driver -+ ****************************************************************/ -+static struct usb_driver kaweth_driver = { -+ .name = driver_name, -+ .probe = kaweth_probe, -+ .disconnect = kaweth_disconnect, -+ .suspend = kaweth_suspend, -+ .resume = kaweth_resume, -+ .id_table = usb_klsi_table, -+ .supports_autosuspend = 1, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+typedef __u8 eth_addr_t[6]; -+ -+/**************************************************************** -+ * usb_eth_dev -+ ****************************************************************/ -+struct usb_eth_dev { -+ char *name; -+ __u16 vendor; -+ __u16 device; -+ void *pdata; -+}; -+ -+/**************************************************************** -+ * kaweth_ethernet_configuration -+ * Refer Table 8 -+ ****************************************************************/ -+struct kaweth_ethernet_configuration -+{ -+ __u8 size; -+ __u8 reserved1; -+ __u8 reserved2; -+ eth_addr_t hw_addr; -+ __u32 statistics_mask; -+ __le16 segment_size; -+ __u16 max_multicast_filters; -+ __u8 reserved3; -+} __packed; -+ -+/**************************************************************** -+ * kaweth_device -+ ****************************************************************/ -+struct kaweth_device -+{ -+ spinlock_t device_lock; -+ -+ __u32 status; -+ int end; -+ int suspend_lowmem_rx; -+ int suspend_lowmem_ctrl; -+ int linkstate; -+ int opened; -+ struct delayed_work lowmem_work; -+ -+ struct usb_device *dev; -+ struct usb_interface *intf; -+ struct net_device *net; -+ wait_queue_head_t term_wait; -+ -+ struct urb *rx_urb; -+ struct urb *tx_urb; -+ struct urb *irq_urb; -+ -+ dma_addr_t intbufferhandle; -+ __u8 *intbuffer; -+ dma_addr_t rxbufferhandle; -+ __u8 *rx_buf; -+ -+ -+ struct sk_buff *tx_skb; -+ -+ __u8 *firmware_buf; -+ __u8 scratch[KAWETH_SCRATCH_SIZE]; -+ __u16 packet_filter_bitmap; -+ -+ struct kaweth_ethernet_configuration configuration; -+ -+ struct net_device_stats stats; -+}; -+ -+/**************************************************************** -+ * kaweth_control -+ ****************************************************************/ -+static int kaweth_control(struct kaweth_device *kaweth, -+ unsigned int pipe, -+ __u8 request, -+ __u8 requesttype, -+ __u16 value, -+ __u16 index, -+ void *data, -+ __u16 size, -+ int timeout) -+{ -+ struct usb_ctrlrequest *dr; -+ int retval; -+ -+ netdev_dbg(kaweth->net, "kaweth_control()\n"); -+ -+ if(in_interrupt()) { -+ netdev_dbg(kaweth->net, "in_interrupt()\n"); -+ return -EBUSY; -+ } -+ -+ dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); -+ if (!dr) -+ return -ENOMEM; -+ -+ dr->bRequestType = requesttype; -+ dr->bRequest = request; -+ dr->wValue = cpu_to_le16(value); -+ dr->wIndex = cpu_to_le16(index); -+ dr->wLength = cpu_to_le16(size); -+ -+ retval = kaweth_internal_control_msg(kaweth->dev, -+ pipe, -+ dr, -+ data, -+ size, -+ timeout); -+ -+ kfree(dr); -+ return retval; -+} -+ -+/**************************************************************** -+ * kaweth_read_configuration -+ ****************************************************************/ -+static int kaweth_read_configuration(struct kaweth_device *kaweth) -+{ -+ int retval; -+ -+ netdev_dbg(kaweth->net, "Reading kaweth configuration\n"); -+ -+ retval = kaweth_control(kaweth, -+ usb_rcvctrlpipe(kaweth->dev, 0), -+ KAWETH_COMMAND_GET_ETHERNET_DESC, -+ USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, -+ 0, -+ 0, -+ (void *)&kaweth->configuration, -+ sizeof(kaweth->configuration), -+ KAWETH_CONTROL_TIMEOUT); -+ -+ return retval; -+} -+ -+/**************************************************************** -+ * kaweth_set_urb_size -+ ****************************************************************/ -+static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size) -+{ -+ int retval; -+ -+ netdev_dbg(kaweth->net, "Setting URB size to %d\n", (unsigned)urb_size); -+ -+ retval = kaweth_control(kaweth, -+ usb_sndctrlpipe(kaweth->dev, 0), -+ KAWETH_COMMAND_SET_URB_SIZE, -+ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, -+ urb_size, -+ 0, -+ (void *)&kaweth->scratch, -+ 0, -+ KAWETH_CONTROL_TIMEOUT); -+ -+ return retval; -+} -+ -+/**************************************************************** -+ * kaweth_set_sofs_wait -+ ****************************************************************/ -+static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait) -+{ -+ int retval; -+ -+ netdev_dbg(kaweth->net, "Set SOFS wait to %d\n", (unsigned)sofs_wait); -+ -+ retval = kaweth_control(kaweth, -+ usb_sndctrlpipe(kaweth->dev, 0), -+ KAWETH_COMMAND_SET_SOFS_WAIT, -+ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, -+ sofs_wait, -+ 0, -+ (void *)&kaweth->scratch, -+ 0, -+ KAWETH_CONTROL_TIMEOUT); -+ -+ return retval; -+} -+ -+/**************************************************************** -+ * kaweth_set_receive_filter -+ ****************************************************************/ -+static int kaweth_set_receive_filter(struct kaweth_device *kaweth, -+ __u16 receive_filter) -+{ -+ int retval; -+ -+ netdev_dbg(kaweth->net, "Set receive filter to %d\n", -+ (unsigned)receive_filter); -+ -+ retval = kaweth_control(kaweth, -+ usb_sndctrlpipe(kaweth->dev, 0), -+ KAWETH_COMMAND_SET_PACKET_FILTER, -+ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, -+ receive_filter, -+ 0, -+ (void *)&kaweth->scratch, -+ 0, -+ KAWETH_CONTROL_TIMEOUT); -+ -+ return retval; -+} -+ -+/**************************************************************** -+ * kaweth_download_firmware -+ ****************************************************************/ -+static int kaweth_download_firmware(struct kaweth_device *kaweth, -+ const char *fwname, -+ __u8 interrupt, -+ __u8 type) -+{ -+ const struct firmware *fw; -+ int data_len; -+ int ret; -+ -+ ret = request_firmware(&fw, fwname, &kaweth->dev->dev); -+ if (ret) { -+ dev_err(&kaweth->intf->dev, "Firmware request failed\n"); -+ return ret; -+ } -+ -+ if (fw->size > KAWETH_FIRMWARE_BUF_SIZE) { -+ dev_err(&kaweth->intf->dev, "Firmware too big: %zu\n", -+ fw->size); -+ release_firmware(fw); -+ return -ENOSPC; -+ } -+ data_len = fw->size; -+ memcpy(kaweth->firmware_buf, fw->data, fw->size); -+ -+ release_firmware(fw); -+ -+ kaweth->firmware_buf[2] = (data_len & 0xFF) - 7; -+ kaweth->firmware_buf[3] = data_len >> 8; -+ kaweth->firmware_buf[4] = type; -+ kaweth->firmware_buf[5] = interrupt; -+ -+ netdev_dbg(kaweth->net, "High: %i, Low:%i\n", kaweth->firmware_buf[3], -+ kaweth->firmware_buf[2]); -+ -+ netdev_dbg(kaweth->net, -+ "Downloading firmware at %p to kaweth device at %p\n", -+ kaweth->firmware_buf, kaweth); -+ netdev_dbg(kaweth->net, "Firmware length: %d\n", data_len); -+ -+ return kaweth_control(kaweth, -+ usb_sndctrlpipe(kaweth->dev, 0), -+ KAWETH_COMMAND_SCAN, -+ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, -+ 0, -+ 0, -+ (void *)kaweth->firmware_buf, -+ data_len, -+ KAWETH_CONTROL_TIMEOUT); -+} -+ -+/**************************************************************** -+ * kaweth_trigger_firmware -+ ****************************************************************/ -+static int kaweth_trigger_firmware(struct kaweth_device *kaweth, -+ __u8 interrupt) -+{ -+ kaweth->firmware_buf[0] = 0xB6; -+ kaweth->firmware_buf[1] = 0xC3; -+ kaweth->firmware_buf[2] = 0x01; -+ kaweth->firmware_buf[3] = 0x00; -+ kaweth->firmware_buf[4] = 0x06; -+ kaweth->firmware_buf[5] = interrupt; -+ kaweth->firmware_buf[6] = 0x00; -+ kaweth->firmware_buf[7] = 0x00; -+ -+ netdev_dbg(kaweth->net, "Triggering firmware\n"); -+ -+ return kaweth_control(kaweth, -+ usb_sndctrlpipe(kaweth->dev, 0), -+ KAWETH_COMMAND_SCAN, -+ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, -+ 0, -+ 0, -+ (void *)kaweth->firmware_buf, -+ 8, -+ KAWETH_CONTROL_TIMEOUT); -+} -+ -+/**************************************************************** -+ * kaweth_reset -+ ****************************************************************/ -+static int kaweth_reset(struct kaweth_device *kaweth) -+{ -+ int result; -+ -+ netdev_dbg(kaweth->net, "kaweth_reset(%p)\n", kaweth); -+ result = usb_reset_configuration(kaweth->dev); -+ mdelay(10); -+ -+ netdev_dbg(kaweth->net, "kaweth_reset() returns %d.\n", result); -+ -+ return result; -+} -+ -+static void kaweth_usb_receive(struct urb *); -+static int kaweth_resubmit_rx_urb(struct kaweth_device *, gfp_t); -+ -+/**************************************************************** -+ int_callback -+*****************************************************************/ -+ -+static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf) -+{ -+ int status; -+ -+ status = usb_submit_urb (kaweth->irq_urb, mf); -+ if (unlikely(status == -ENOMEM)) { -+ kaweth->suspend_lowmem_ctrl = 1; -+ schedule_delayed_work(&kaweth->lowmem_work, HZ/4); -+ } else { -+ kaweth->suspend_lowmem_ctrl = 0; -+ } -+ -+ if (status) -+ dev_err(&kaweth->intf->dev, -+ "can't resubmit intr, %s-%s, status %d\n", -+ kaweth->dev->bus->bus_name, -+ kaweth->dev->devpath, status); -+} -+ -+static void int_callback(struct urb *u) -+{ -+ struct kaweth_device *kaweth = u->context; -+ int act_state; -+ int status = u->status; -+ -+ switch (status) { -+ case 0: /* success */ -+ break; -+ case -ECONNRESET: /* unlink */ -+ case -ENOENT: -+ case -ESHUTDOWN: -+ return; -+ /* -EPIPE: should clear the halt */ -+ default: /* error */ -+ goto resubmit; -+ } -+ -+ /* we check the link state to report changes */ -+ if (kaweth->linkstate != (act_state = ( kaweth->intbuffer[STATE_OFFSET] | STATE_MASK) >> STATE_SHIFT)) { -+ if (act_state) -+ netif_carrier_on(kaweth->net); -+ else -+ netif_carrier_off(kaweth->net); -+ -+ kaweth->linkstate = act_state; -+ } -+resubmit: -+ kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); -+} -+ -+static void kaweth_resubmit_tl(struct work_struct *work) -+{ -+ struct kaweth_device *kaweth = -+ container_of(work, struct kaweth_device, lowmem_work.work); -+ -+ if (IS_BLOCKED(kaweth->status)) -+ return; -+ -+ if (kaweth->suspend_lowmem_rx) -+ kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); -+ -+ if (kaweth->suspend_lowmem_ctrl) -+ kaweth_resubmit_int_urb(kaweth, GFP_NOIO); -+} -+ -+ -+/**************************************************************** -+ * kaweth_resubmit_rx_urb -+ ****************************************************************/ -+static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, -+ gfp_t mem_flags) -+{ -+ int result; -+ -+ usb_fill_bulk_urb(kaweth->rx_urb, -+ kaweth->dev, -+ usb_rcvbulkpipe(kaweth->dev, 1), -+ kaweth->rx_buf, -+ KAWETH_BUF_SIZE, -+ kaweth_usb_receive, -+ kaweth); -+ kaweth->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; -+ kaweth->rx_urb->transfer_dma = kaweth->rxbufferhandle; -+ -+ if((result = usb_submit_urb(kaweth->rx_urb, mem_flags))) { -+ if (result == -ENOMEM) { -+ kaweth->suspend_lowmem_rx = 1; -+ schedule_delayed_work(&kaweth->lowmem_work, HZ/4); -+ } -+ dev_err(&kaweth->intf->dev, "resubmitting rx_urb %d failed\n", -+ result); -+ } else { -+ kaweth->suspend_lowmem_rx = 0; -+ } -+ -+ return result; -+} -+ -+static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth); -+ -+/**************************************************************** -+ * kaweth_usb_receive -+ ****************************************************************/ -+static void kaweth_usb_receive(struct urb *urb) -+{ -+ struct device *dev = &urb->dev->dev; -+ struct kaweth_device *kaweth = urb->context; -+ struct net_device *net = kaweth->net; -+ int status = urb->status; -+ -+ int count = urb->actual_length; -+ int count2 = urb->transfer_buffer_length; -+ -+ __u16 pkt_len = le16_to_cpup((__le16 *)kaweth->rx_buf); -+ -+ struct sk_buff *skb; -+ -+ if (unlikely(status == -EPIPE)) { -+ kaweth->stats.rx_errors++; -+ kaweth->end = 1; -+ wake_up(&kaweth->term_wait); -+ dev_dbg(dev, "Status was -EPIPE.\n"); -+ return; -+ } -+ if (unlikely(status == -ECONNRESET || status == -ESHUTDOWN)) { -+ /* we are killed - set a flag and wake the disconnect handler */ -+ kaweth->end = 1; -+ wake_up(&kaweth->term_wait); -+ dev_dbg(dev, "Status was -ECONNRESET or -ESHUTDOWN.\n"); -+ return; -+ } -+ if (unlikely(status == -EPROTO || status == -ETIME || -+ status == -EILSEQ)) { -+ kaweth->stats.rx_errors++; -+ dev_dbg(dev, "Status was -EPROTO, -ETIME, or -EILSEQ.\n"); -+ return; -+ } -+ if (unlikely(status == -EOVERFLOW)) { -+ kaweth->stats.rx_errors++; -+ dev_dbg(dev, "Status was -EOVERFLOW.\n"); -+ } -+ spin_lock(&kaweth->device_lock); -+ if (IS_BLOCKED(kaweth->status)) { -+ spin_unlock(&kaweth->device_lock); -+ return; -+ } -+ spin_unlock(&kaweth->device_lock); -+ -+ if(status && status != -EREMOTEIO && count != 1) { -+ dev_err(&kaweth->intf->dev, -+ "%s RX status: %d count: %d packet_len: %d\n", -+ net->name, status, count, (int)pkt_len); -+ kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); -+ return; -+ } -+ -+ if(kaweth->net && (count > 2)) { -+ if(pkt_len > (count - 2)) { -+ dev_err(&kaweth->intf->dev, -+ "Packet length too long for USB frame (pkt_len: %x, count: %x)\n", -+ pkt_len, count); -+ dev_err(&kaweth->intf->dev, "Packet len & 2047: %x\n", -+ pkt_len & 2047); -+ dev_err(&kaweth->intf->dev, "Count 2: %x\n", count2); -+ kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); -+ return; -+ } -+ -+ if(!(skb = dev_alloc_skb(pkt_len+2))) { -+ kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); -+ return; -+ } -+ -+ skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ -+ -+ skb_copy_to_linear_data(skb, kaweth->rx_buf + 2, pkt_len); -+ -+ skb_put(skb, pkt_len); -+ -+ skb->protocol = eth_type_trans(skb, net); -+ -+ netif_rx(skb); -+ -+ kaweth->stats.rx_packets++; -+ kaweth->stats.rx_bytes += pkt_len; -+ } -+ -+ kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); -+} -+ -+/**************************************************************** -+ * kaweth_open -+ ****************************************************************/ -+static int kaweth_open(struct net_device *net) -+{ -+ struct kaweth_device *kaweth = netdev_priv(net); -+ int res; -+ -+ netdev_dbg(kaweth->net, "Opening network device.\n"); -+ -+ res = usb_autopm_get_interface(kaweth->intf); -+ if (res) { -+ dev_err(&kaweth->intf->dev, "Interface cannot be resumed.\n"); -+ return -EIO; -+ } -+ res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); -+ if (res) -+ goto err_out; -+ -+ usb_fill_int_urb( -+ kaweth->irq_urb, -+ kaweth->dev, -+ usb_rcvintpipe(kaweth->dev, 3), -+ kaweth->intbuffer, -+ INTBUFFERSIZE, -+ int_callback, -+ kaweth, -+ 250); /* overriding the descriptor */ -+ kaweth->irq_urb->transfer_dma = kaweth->intbufferhandle; -+ kaweth->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; -+ -+ res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL); -+ if (res) { -+ usb_kill_urb(kaweth->rx_urb); -+ goto err_out; -+ } -+ kaweth->opened = 1; -+ -+ netif_start_queue(net); -+ -+ kaweth_async_set_rx_mode(kaweth); -+ return 0; -+ -+err_out: -+ usb_autopm_put_interface(kaweth->intf); -+ return -EIO; -+} -+ -+/**************************************************************** -+ * kaweth_kill_urbs -+ ****************************************************************/ -+static void kaweth_kill_urbs(struct kaweth_device *kaweth) -+{ -+ usb_kill_urb(kaweth->irq_urb); -+ usb_kill_urb(kaweth->rx_urb); -+ usb_kill_urb(kaweth->tx_urb); -+ -+ cancel_delayed_work_sync(&kaweth->lowmem_work); -+ -+ /* a scheduled work may have resubmitted, -+ we hit them again */ -+ usb_kill_urb(kaweth->irq_urb); -+ usb_kill_urb(kaweth->rx_urb); -+} -+ -+/**************************************************************** -+ * kaweth_close -+ ****************************************************************/ -+static int kaweth_close(struct net_device *net) -+{ -+ struct kaweth_device *kaweth = netdev_priv(net); -+ -+ netif_stop_queue(net); -+ kaweth->opened = 0; -+ -+ kaweth->status |= KAWETH_STATUS_CLOSING; -+ -+ kaweth_kill_urbs(kaweth); -+ -+ kaweth->status &= ~KAWETH_STATUS_CLOSING; -+ -+ usb_autopm_put_interface(kaweth->intf); -+ -+ return 0; -+} -+ -+static u32 kaweth_get_link(struct net_device *dev) -+{ -+ struct kaweth_device *kaweth = netdev_priv(dev); -+ -+ return kaweth->linkstate; -+} -+ -+static const struct ethtool_ops ops = { -+ .get_link = kaweth_get_link -+}; -+ -+/**************************************************************** -+ * kaweth_usb_transmit_complete -+ ****************************************************************/ -+static void kaweth_usb_transmit_complete(struct urb *urb) -+{ -+ struct kaweth_device *kaweth = urb->context; -+ struct sk_buff *skb = kaweth->tx_skb; -+ int status = urb->status; -+ -+ if (unlikely(status != 0)) -+ if (status != -ENOENT) -+ dev_dbg(&urb->dev->dev, "%s: TX status %d.\n", -+ kaweth->net->name, status); -+ -+ netif_wake_queue(kaweth->net); -+ dev_kfree_skb_irq(skb); -+} -+ -+/**************************************************************** -+ * kaweth_start_xmit -+ ****************************************************************/ -+static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, -+ struct net_device *net) -+{ -+ struct kaweth_device *kaweth = netdev_priv(net); -+ __le16 *private_header; -+ -+ int res; -+ -+ spin_lock_irq(&kaweth->device_lock); -+ -+ kaweth_async_set_rx_mode(kaweth); -+ netif_stop_queue(net); -+ if (IS_BLOCKED(kaweth->status)) { -+ goto skip; -+ } -+ -+ /* We now decide whether we can put our special header into the sk_buff */ -+ if (skb_cloned(skb) || skb_headroom(skb) < 2) { -+ /* no such luck - we make our own */ -+ struct sk_buff *copied_skb; -+ copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); -+ dev_kfree_skb_irq(skb); -+ skb = copied_skb; -+ if (!copied_skb) { -+ kaweth->stats.tx_errors++; -+ netif_start_queue(net); -+ spin_unlock_irq(&kaweth->device_lock); -+ return NETDEV_TX_OK; -+ } -+ } -+ -+ private_header = (__le16 *)__skb_push(skb, 2); -+ *private_header = cpu_to_le16(skb->len-2); -+ kaweth->tx_skb = skb; -+ -+ usb_fill_bulk_urb(kaweth->tx_urb, -+ kaweth->dev, -+ usb_sndbulkpipe(kaweth->dev, 2), -+ private_header, -+ skb->len, -+ kaweth_usb_transmit_complete, -+ kaweth); -+ kaweth->end = 0; -+ -+ if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) -+ { -+ dev_warn(&net->dev, "kaweth failed tx_urb %d\n", res); -+skip: -+ kaweth->stats.tx_errors++; -+ -+ netif_start_queue(net); -+ dev_kfree_skb_irq(skb); -+ } -+ else -+ { -+ kaweth->stats.tx_packets++; -+ kaweth->stats.tx_bytes += skb->len; -+ } -+ -+ spin_unlock_irq(&kaweth->device_lock); -+ -+ return NETDEV_TX_OK; -+} -+ -+/**************************************************************** -+ * kaweth_set_rx_mode -+ ****************************************************************/ -+static void kaweth_set_rx_mode(struct net_device *net) -+{ -+ struct kaweth_device *kaweth = netdev_priv(net); -+ -+ __u16 packet_filter_bitmap = KAWETH_PACKET_FILTER_DIRECTED | -+ KAWETH_PACKET_FILTER_BROADCAST | -+ KAWETH_PACKET_FILTER_MULTICAST; -+ -+ netdev_dbg(net, "Setting Rx mode to %d\n", packet_filter_bitmap); -+ -+ netif_stop_queue(net); -+ -+ if (net->flags & IFF_PROMISC) { -+ packet_filter_bitmap |= KAWETH_PACKET_FILTER_PROMISCUOUS; -+ } -+ else if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI)) { -+ packet_filter_bitmap |= KAWETH_PACKET_FILTER_ALL_MULTICAST; -+ } -+ -+ kaweth->packet_filter_bitmap = packet_filter_bitmap; -+ netif_wake_queue(net); -+} -+ -+/**************************************************************** -+ * kaweth_async_set_rx_mode -+ ****************************************************************/ -+static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth) -+{ -+ int result; -+ __u16 packet_filter_bitmap = kaweth->packet_filter_bitmap; -+ -+ kaweth->packet_filter_bitmap = 0; -+ if (packet_filter_bitmap == 0) -+ return; -+ -+ if (in_interrupt()) -+ return; -+ -+ result = kaweth_control(kaweth, -+ usb_sndctrlpipe(kaweth->dev, 0), -+ KAWETH_COMMAND_SET_PACKET_FILTER, -+ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, -+ packet_filter_bitmap, -+ 0, -+ (void *)&kaweth->scratch, -+ 0, -+ KAWETH_CONTROL_TIMEOUT); -+ -+ if(result < 0) { -+ dev_err(&kaweth->intf->dev, "Failed to set Rx mode: %d\n", -+ result); -+ } -+ else { -+ netdev_dbg(kaweth->net, "Set Rx mode to %d\n", -+ packet_filter_bitmap); -+ } -+} -+ -+/**************************************************************** -+ * kaweth_netdev_stats -+ ****************************************************************/ -+static struct net_device_stats *kaweth_netdev_stats(struct net_device *dev) -+{ -+ struct kaweth_device *kaweth = netdev_priv(dev); -+ return &kaweth->stats; -+} -+ -+/**************************************************************** -+ * kaweth_tx_timeout -+ ****************************************************************/ -+static void kaweth_tx_timeout(struct net_device *net) -+{ -+ struct kaweth_device *kaweth = netdev_priv(net); -+ -+ dev_warn(&net->dev, "%s: Tx timed out. Resetting.\n", net->name); -+ kaweth->stats.tx_errors++; -+ net->trans_start = jiffies; -+ -+ usb_unlink_urb(kaweth->tx_urb); -+} -+ -+/**************************************************************** -+ * kaweth_suspend -+ ****************************************************************/ -+static int kaweth_suspend(struct usb_interface *intf, pm_message_t message) -+{ -+ struct kaweth_device *kaweth = usb_get_intfdata(intf); -+ unsigned long flags; -+ -+ dev_dbg(&intf->dev, "Suspending device\n"); -+ spin_lock_irqsave(&kaweth->device_lock, flags); -+ kaweth->status |= KAWETH_STATUS_SUSPENDING; -+ spin_unlock_irqrestore(&kaweth->device_lock, flags); -+ -+ kaweth_kill_urbs(kaweth); -+ return 0; -+} -+ -+/**************************************************************** -+ * kaweth_resume -+ ****************************************************************/ -+static int kaweth_resume(struct usb_interface *intf) -+{ -+ struct kaweth_device *kaweth = usb_get_intfdata(intf); -+ unsigned long flags; -+ -+ dev_dbg(&intf->dev, "Resuming device\n"); -+ spin_lock_irqsave(&kaweth->device_lock, flags); -+ kaweth->status &= ~KAWETH_STATUS_SUSPENDING; -+ spin_unlock_irqrestore(&kaweth->device_lock, flags); -+ -+ if (!kaweth->opened) -+ return 0; -+ kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); -+ kaweth_resubmit_int_urb(kaweth, GFP_NOIO); -+ -+ return 0; -+} -+ -+/**************************************************************** -+ * kaweth_probe -+ ****************************************************************/ -+ -+ -+static const struct net_device_ops kaweth_netdev_ops = { -+ .ndo_open = kaweth_open, -+ .ndo_stop = kaweth_close, -+ .ndo_start_xmit = kaweth_start_xmit, -+ .ndo_tx_timeout = kaweth_tx_timeout, -+ .ndo_set_rx_mode = kaweth_set_rx_mode, -+ .ndo_get_stats = kaweth_netdev_stats, -+ .ndo_change_mtu = eth_change_mtu, -+ .ndo_set_mac_address = eth_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+}; -+ -+static int kaweth_probe( -+ struct usb_interface *intf, -+ const struct usb_device_id *id /* from id_table */ -+ ) -+{ -+ struct device *dev = &intf->dev; -+ struct usb_device *udev = interface_to_usbdev(intf); -+ struct kaweth_device *kaweth; -+ struct net_device *netdev; -+ const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; -+ int result = 0; -+ -+ dev_dbg(dev, -+ "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n", -+ udev->devnum, le16_to_cpu(udev->descriptor.idVendor), -+ le16_to_cpu(udev->descriptor.idProduct), -+ le16_to_cpu(udev->descriptor.bcdDevice)); -+ -+ dev_dbg(dev, "Device at %p\n", udev); -+ -+ dev_dbg(dev, "Descriptor length: %x type: %x\n", -+ (int)udev->descriptor.bLength, -+ (int)udev->descriptor.bDescriptorType); -+ -+ netdev = alloc_etherdev(sizeof(*kaweth)); -+ if (!netdev) -+ return -ENOMEM; -+ -+ kaweth = netdev_priv(netdev); -+ kaweth->dev = udev; -+ kaweth->net = netdev; -+ -+ spin_lock_init(&kaweth->device_lock); -+ init_waitqueue_head(&kaweth->term_wait); -+ -+ dev_dbg(dev, "Resetting.\n"); -+ -+ kaweth_reset(kaweth); -+ -+ /* -+ * If high byte of bcdDevice is nonzero, firmware is already -+ * downloaded. Don't try to do it again, or we'll hang the device. -+ */ -+ -+ if (le16_to_cpu(udev->descriptor.bcdDevice) >> 8) { -+ dev_info(dev, "Firmware present in device.\n"); -+ } else { -+ /* Download the firmware */ -+ dev_info(dev, "Downloading firmware...\n"); -+ kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); -+ if ((result = kaweth_download_firmware(kaweth, -+ "kaweth/new_code.bin", -+ 100, -+ 2)) < 0) { -+ dev_err(dev, "Error downloading firmware (%d)\n", -+ result); -+ goto err_fw; -+ } -+ -+ if ((result = kaweth_download_firmware(kaweth, -+ "kaweth/new_code_fix.bin", -+ 100, -+ 3)) < 0) { -+ dev_err(dev, "Error downloading firmware fix (%d)\n", -+ result); -+ goto err_fw; -+ } -+ -+ if ((result = kaweth_download_firmware(kaweth, -+ "kaweth/trigger_code.bin", -+ 126, -+ 2)) < 0) { -+ dev_err(dev, "Error downloading trigger code (%d)\n", -+ result); -+ goto err_fw; -+ -+ } -+ -+ if ((result = kaweth_download_firmware(kaweth, -+ "kaweth/trigger_code_fix.bin", -+ 126, -+ 3)) < 0) { -+ dev_err(dev, "Error downloading trigger code fix (%d)\n", result); -+ goto err_fw; -+ } -+ -+ -+ if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { -+ dev_err(dev, "Error triggering firmware (%d)\n", result); -+ goto err_fw; -+ } -+ -+ /* Device will now disappear for a moment... */ -+ dev_info(dev, "Firmware loaded. I'll be back...\n"); -+err_fw: -+ free_page((unsigned long)kaweth->firmware_buf); -+ free_netdev(netdev); -+ return -EIO; -+ } -+ -+ result = kaweth_read_configuration(kaweth); -+ -+ if(result < 0) { -+ dev_err(dev, "Error reading configuration (%d), no net device created\n", result); -+ goto err_free_netdev; -+ } -+ -+ dev_info(dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); -+ dev_info(dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); -+ dev_info(dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); -+ dev_info(dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr); -+ -+ if(!memcmp(&kaweth->configuration.hw_addr, -+ &bcast_addr, -+ sizeof(bcast_addr))) { -+ dev_err(dev, "Firmware not functioning properly, no net device created\n"); -+ goto err_free_netdev; -+ } -+ -+ if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { -+ dev_dbg(dev, "Error setting URB size\n"); -+ goto err_free_netdev; -+ } -+ -+ if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { -+ dev_err(dev, "Error setting SOFS wait\n"); -+ goto err_free_netdev; -+ } -+ -+ result = kaweth_set_receive_filter(kaweth, -+ KAWETH_PACKET_FILTER_DIRECTED | -+ KAWETH_PACKET_FILTER_BROADCAST | -+ KAWETH_PACKET_FILTER_MULTICAST); -+ -+ if(result < 0) { -+ dev_err(dev, "Error setting receive filter\n"); -+ goto err_free_netdev; -+ } -+ -+ dev_dbg(dev, "Initializing net device.\n"); -+ -+ kaweth->intf = intf; -+ -+ kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!kaweth->tx_urb) -+ goto err_free_netdev; -+ kaweth->rx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!kaweth->rx_urb) -+ goto err_only_tx; -+ kaweth->irq_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!kaweth->irq_urb) -+ goto err_tx_and_rx; -+ -+ kaweth->intbuffer = usb_alloc_coherent( kaweth->dev, -+ INTBUFFERSIZE, -+ GFP_KERNEL, -+ &kaweth->intbufferhandle); -+ if (!kaweth->intbuffer) -+ goto err_tx_and_rx_and_irq; -+ kaweth->rx_buf = usb_alloc_coherent( kaweth->dev, -+ KAWETH_BUF_SIZE, -+ GFP_KERNEL, -+ &kaweth->rxbufferhandle); -+ if (!kaweth->rx_buf) -+ goto err_all_but_rxbuf; -+ -+ memcpy(netdev->broadcast, &bcast_addr, sizeof(bcast_addr)); -+ memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr, -+ sizeof(kaweth->configuration.hw_addr)); -+ -+ netdev->netdev_ops = &kaweth_netdev_ops; -+ netdev->watchdog_timeo = KAWETH_TX_TIMEOUT; -+ netdev->mtu = le16_to_cpu(kaweth->configuration.segment_size); -+ netdev->ethtool_ops = &ops; -+ -+ /* kaweth is zeroed as part of alloc_netdev */ -+ INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl); -+ usb_set_intfdata(intf, kaweth); -+ -+#if 0 -+// dma_supported() is deeply broken on almost all architectures -+ if (dma_supported (dev, 0xffffffffffffffffULL)) -+ kaweth->net->features |= NETIF_F_HIGHDMA; -+#endif -+ -+ SET_NETDEV_DEV(netdev, dev); -+ if (register_netdev(netdev) != 0) { -+ dev_err(dev, "Error registering netdev.\n"); -+ goto err_intfdata; -+ } -+ -+ dev_info(dev, "kaweth interface created at %s\n", -+ kaweth->net->name); -+ -+ dev_dbg(dev, "Kaweth probe returning.\n"); -+ -+ return 0; -+ -+err_intfdata: -+ usb_set_intfdata(intf, NULL); -+ usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); -+err_all_but_rxbuf: -+ usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); -+err_tx_and_rx_and_irq: -+ usb_free_urb(kaweth->irq_urb); -+err_tx_and_rx: -+ usb_free_urb(kaweth->rx_urb); -+err_only_tx: -+ usb_free_urb(kaweth->tx_urb); -+err_free_netdev: -+ free_netdev(netdev); -+ -+ return -EIO; -+} -+ -+/**************************************************************** -+ * kaweth_disconnect -+ ****************************************************************/ -+static void kaweth_disconnect(struct usb_interface *intf) -+{ -+ struct kaweth_device *kaweth = usb_get_intfdata(intf); -+ struct net_device *netdev; -+ -+ dev_info(&intf->dev, "Unregistering\n"); -+ -+ usb_set_intfdata(intf, NULL); -+ if (!kaweth) { -+ dev_warn(&intf->dev, "unregistering non-existent device\n"); -+ return; -+ } -+ netdev = kaweth->net; -+ -+ netdev_dbg(kaweth->net, "Unregistering net device\n"); -+ unregister_netdev(netdev); -+ -+ usb_free_urb(kaweth->rx_urb); -+ usb_free_urb(kaweth->tx_urb); -+ usb_free_urb(kaweth->irq_urb); -+ -+ usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); -+ usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); -+ -+ free_netdev(netdev); -+} -+ -+ -+// FIXME this completion stuff is a modified clone of -+// an OLD version of some stuff in usb.c ... -+struct usb_api_data { -+ wait_queue_head_t wqh; -+ int done; -+}; -+ -+/*-------------------------------------------------------------------* -+ * completion handler for compatibility wrappers (sync control/bulk) * -+ *-------------------------------------------------------------------*/ -+static void usb_api_blocking_completion(struct urb *urb) -+{ -+ struct usb_api_data *awd = (struct usb_api_data *)urb->context; -+ -+ awd->done=1; -+ wake_up(&awd->wqh); -+} -+ -+/*-------------------------------------------------------------------* -+ * COMPATIBILITY STUFF * -+ *-------------------------------------------------------------------*/ -+ -+// Starts urb and waits for completion or timeout -+static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length) -+{ -+ struct usb_api_data awd; -+ int status; -+ -+ init_waitqueue_head(&awd.wqh); -+ awd.done = 0; -+ -+ urb->context = &awd; -+ status = usb_submit_urb(urb, GFP_NOIO); -+ if (status) { -+ // something went wrong -+ usb_free_urb(urb); -+ return status; -+ } -+ -+ if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { -+ // timeout -+ dev_warn(&urb->dev->dev, "usb_control/bulk_msg: timeout\n"); -+ usb_kill_urb(urb); // remove urb safely -+ status = -ETIMEDOUT; -+ } -+ else { -+ status = urb->status; -+ } -+ -+ if (actual_length) { -+ *actual_length = urb->actual_length; -+ } -+ -+ usb_free_urb(urb); -+ return status; -+} -+ -+/*-------------------------------------------------------------------*/ -+// returns status (negative) or length (positive) -+static int kaweth_internal_control_msg(struct usb_device *usb_dev, -+ unsigned int pipe, -+ struct usb_ctrlrequest *cmd, void *data, -+ int len, int timeout) -+{ -+ struct urb *urb; -+ int retv; -+ int length = 0; /* shut up GCC */ -+ -+ urb = usb_alloc_urb(0, GFP_ATOMIC); -+ if (!urb) -+ return -ENOMEM; -+ -+ usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char*)cmd, data, -+ len, usb_api_blocking_completion, NULL); -+ -+ retv = usb_start_wait_urb(urb, timeout, &length); -+ if (retv < 0) { -+ return retv; -+ } -+ else { -+ return length; -+ } -+} -+ -+module_usb_driver(kaweth_driver); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/Kconfig backports-3.18.1-1/drivers/net/usb/Kconfig ---- backports-3.18.1-1.org/drivers/net/usb/Kconfig 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/Kconfig 2015-01-03 15:19:02.310281530 +0100 -@@ -13,7 +13,6 @@ - if USB_NET_DRIVERS - - config USB_CATC -- depends on n - tristate "USB CATC NetMate-based Ethernet device support" - depends on m - depends on CRC32 -@@ -34,7 +33,6 @@ - module will be called catc. - - config USB_KAWETH -- depends on n - tristate "USB KLSI KL5USB101-based ethernet device support" - depends on m - ---help--- -@@ -75,7 +73,6 @@ - module will be called kaweth. - - config USB_PEGASUS -- depends on n - tristate "USB Pegasus/Pegasus-II based ethernet device support" - depends on m - select BACKPORT_MII -@@ -92,7 +89,6 @@ - module will be called pegasus. - - config USB_RTL8150 -- depends on n - tristate "USB RTL8150 based ethernet device support" - depends on m - select BACKPORT_MII -@@ -105,7 +101,6 @@ - module will be called rtl8150. - - config USB_RTL8152 -- depends on n - tristate "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters" - depends on m - select BACKPORT_MII -@@ -153,7 +148,6 @@ - module will be called usbnet. - - config USB_NET_AX8817X -- depends on n - tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" - depends on m - depends on USB_USBNET -@@ -183,7 +177,6 @@ - what other networking devices you have in use. - - config USB_NET_AX88179_178A -- depends on n - tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet" - depends on m - depends on USB_USBNET -@@ -232,7 +225,6 @@ - name is used instead. - - config USB_NET_CDC_EEM -- depends on n - tristate "CDC EEM support" - depends on m - depends on USB_USBNET -@@ -268,7 +260,6 @@ - * Ericsson F5521gw Mobile Broadband Module - - config USB_NET_HUAWEI_CDC_NCM -- depends on n - tristate "Huawei NCM embedded AT channel support" - depends on m - depends on USB_USBNET -@@ -304,7 +295,6 @@ - module will be called cdc_mbim. - - config USB_NET_DM9601 -- depends on n - tristate "Davicom DM96xx based USB 10/100 ethernet devices" - depends on m - depends on USB_USBNET -@@ -314,7 +304,6 @@ - based USB 10/100 Ethernet adapters. - - config USB_NET_SR9700 -- depends on n - tristate "CoreChip-sz SR9700 based USB 1.1 10/100 ethernet devices" - depends on m - depends on USB_USBNET -@@ -324,7 +313,6 @@ - 10/100 Ethernet adapters. - - config USB_NET_SR9800 -- depends on n - tristate "CoreChip-sz SR9800 based USB 2.0 10/100 ethernet devices" - depends on m - depends on USB_USBNET -@@ -341,7 +329,6 @@ - module will be called sr9800. - - config USB_NET_SMSC75XX -- depends on n - tristate "SMSC LAN75XX based USB 2.0 gigabit ethernet devices" - depends on m - depends on USB_USBNET -@@ -353,7 +340,6 @@ - Gigabit Ethernet adapters. - - config USB_NET_SMSC95XX -- depends on n - tristate "SMSC LAN95XX based USB 2.0 10/100 ethernet devices" - depends on m - depends on USB_USBNET -@@ -365,7 +351,6 @@ - 10/100 Ethernet adapters. - - config USB_NET_GL620A -- depends on n - tristate "GeneSys GL620USB-A based cables" - depends on m - depends on USB_USBNET -@@ -376,7 +361,6 @@ - Note that the half-duplex "GL620USB" is not supported. - - config USB_NET_NET1080 -- depends on n - tristate "NetChip 1080 based cables (Laplink, ...)" - depends on m - default y -@@ -387,7 +371,6 @@ - optionally with LEDs that indicate traffic - - config USB_NET_PLUSB -- depends on n - tristate "Prolific PL-2301/2302/25A1 based cables" - depends on m - # if the handshake/init/reset problems, from original 'plusb', -@@ -398,7 +381,6 @@ - with one of these chips. - - config USB_NET_MCS7830 -- depends on n - tristate "MosChip MCS7830 based Ethernet adapters" - depends on m - depends on USB_USBNET -@@ -424,7 +406,6 @@ - (and for) Microsoft; it isn't an "Open" ecosystem or market. - - config USB_NET_CDC_SUBSET -- depends on n - tristate "Simple USB Network Links (CDC Ethernet subset)" - depends on m - depends on USB_USBNET -@@ -496,7 +477,6 @@ - with one of these chips. - - config USB_NET_ZAURUS -- depends on n - tristate "Sharp Zaurus (stock ROMs) and compatible" - depends on m - depends on USB_USBNET -@@ -516,7 +496,6 @@ - some cases CDC MDLM) protocol, not "g_ether". - - config USB_NET_CX82310_ETH -- depends on n - tristate "Conexant CX82310 USB ethernet port" - depends on m - depends on USB_USBNET -@@ -526,7 +505,6 @@ - it will not work with ADSL modems (use cxacru driver instead). - - config USB_NET_KALMIA -- depends on n - tristate "Samsung Kalmia based LTE USB modem" - depends on m - depends on USB_USBNET -@@ -561,7 +539,6 @@ - module will be called qmi_wwan. - - config USB_HSO -- depends on n - tristate "Option USB High Speed Mobile Devices" - depends on m - depends on USB && RFKILL && TTY -@@ -574,7 +551,6 @@ - module will be called hso. - - config USB_NET_INT51X1 -- depends on n - tristate "Intellon PLC based usb adapter" - depends on m - depends on USB_USBNET -@@ -584,7 +560,6 @@ - INT51x1/INT5200 chip, like the "devolo dLan duo". - - config USB_CDC_PHONET -- depends on n - tristate "CDC Phonet support" - depends on m - depends on PHONET -@@ -594,7 +569,6 @@ - "PC suite" USB profile. - - config USB_IPHETH -- depends on n - tristate "Apple iPhone USB Ethernet driver" - depends on m - default n -@@ -618,11 +592,10 @@ - module will be called sierra_net. - - config USB_VL600 -- depends on n - tristate "LG VL600 modem dongle" - depends on m - depends on USB_NET_CDCETHER && TTY -- select USB_ACM -+# depends on USB_ACM - help - Select this if you want to use an LG Electronics 4G/LTE usb modem - called VL600. This driver only handles the ethernet -diff -Naur backports-3.18.1-1.org/drivers/net/usb/lg-vl600.c backports-3.18.1-1/drivers/net/usb/lg-vl600.c ---- backports-3.18.1-1.org/drivers/net/usb/lg-vl600.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/lg-vl600.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,353 @@ -+/* -+ * Ethernet interface part of the LG VL600 LTE modem (4G dongle) -+ * -+ * Copyright (C) 2011 Intel Corporation -+ * Author: Andrzej Zaborowski balrogg@gmail.com -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/usb/cdc.h> -+#include <linux/usb/usbnet.h> -+#include <linux/if_ether.h> -+#include <linux/if_arp.h> -+#include <linux/inetdevice.h> -+#include <linux/module.h> -+ -+/* -+ * The device has a CDC ACM port for modem control (it claims to be -+ * CDC ACM anyway) and a CDC Ethernet port for actual network data. -+ * It will however ignore data on both ports that is not encapsulated -+ * in a specific way, any data returned is also encapsulated the same -+ * way. The headers don't seem to follow any popular standard. -+ * -+ * This driver adds and strips these headers from the ethernet frames -+ * sent/received from the CDC Ethernet port. The proprietary header -+ * replaces the standard ethernet header in a packet so only actual -+ * ethernet frames are allowed. The headers allow some form of -+ * multiplexing by using non standard values of the .h_proto field. -+ * Windows/Mac drivers do send a couple of such frames to the device -+ * during initialisation, with protocol set to 0x0906 or 0x0b06 and (what -+ * seems to be) a flag in the .dummy_flags. This doesn't seem necessary -+ * for modem operation but can possibly be used for GPS or other funcitons. -+ */ -+ -+struct vl600_frame_hdr { -+ __le32 len; -+ __le32 serial; -+ __le32 pkt_cnt; -+ __le32 dummy_flags; -+ __le32 dummy; -+ __le32 magic; -+} __attribute__((packed)); -+ -+struct vl600_pkt_hdr { -+ __le32 dummy[2]; -+ __le32 len; -+ __be16 h_proto; -+} __attribute__((packed)); -+ -+struct vl600_state { -+ struct sk_buff *current_rx_buf; -+}; -+ -+static int vl600_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ int ret; -+ struct vl600_state *s = kzalloc(sizeof(struct vl600_state), GFP_KERNEL); -+ -+ if (!s) -+ return -ENOMEM; -+ -+ ret = usbnet_cdc_bind(dev, intf); -+ if (ret) { -+ kfree(s); -+ return ret; -+ } -+ -+ dev->driver_priv = s; -+ -+ /* ARP packets don't go through, but they're also of no use. The -+ * subnet has only two hosts anyway: us and the gateway / DHCP -+ * server (probably simulated by modem firmware or network operator) -+ * whose address changes everytime we connect to the intarwebz and -+ * who doesn't bother answering ARP requests either. So hardware -+ * addresses have no meaning, the destination and the source of every -+ * packet depend only on whether it is on the IN or OUT endpoint. */ -+ dev->net->flags |= IFF_NOARP; -+ /* IPv6 NDP relies on multicast. Enable it by default. */ -+ dev->net->flags |= IFF_MULTICAST; -+ -+ return ret; -+} -+ -+static void vl600_unbind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ struct vl600_state *s = dev->driver_priv; -+ -+ if (s->current_rx_buf) -+ dev_kfree_skb(s->current_rx_buf); -+ -+ kfree(s); -+ -+ return usbnet_cdc_unbind(dev, intf); -+} -+ -+static int vl600_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ struct vl600_frame_hdr *frame; -+ struct vl600_pkt_hdr *packet; -+ struct ethhdr *ethhdr; -+ int packet_len, count; -+ struct sk_buff *buf = skb; -+ struct sk_buff *clone; -+ struct vl600_state *s = dev->driver_priv; -+ -+ /* Frame lengths are generally 4B multiplies but every couple of -+ * hours there's an odd number of bytes sized yet correct frame, -+ * so don't require this. */ -+ -+ /* Allow a packet (or multiple packets batched together) to be -+ * split across many frames. We don't allow a new batch to -+ * begin in the same frame another one is ending however, and no -+ * leading or trailing pad bytes. */ -+ if (s->current_rx_buf) { -+ frame = (struct vl600_frame_hdr *) s->current_rx_buf->data; -+ if (skb->len + s->current_rx_buf->len > -+ le32_to_cpup(&frame->len)) { -+ netif_err(dev, ifup, dev->net, "Fragment too long\n"); -+ dev->net->stats.rx_length_errors++; -+ goto error; -+ } -+ -+ buf = s->current_rx_buf; -+ memcpy(skb_put(buf, skb->len), skb->data, skb->len); -+ } else if (skb->len < 4) { -+ netif_err(dev, ifup, dev->net, "Frame too short\n"); -+ dev->net->stats.rx_length_errors++; -+ goto error; -+ } -+ -+ frame = (struct vl600_frame_hdr *) buf->data; -+ /* Yes, check that frame->magic == 0x53544448 (or 0x44544d48), -+ * otherwise we may run out of memory w/a bad packet */ -+ if (ntohl(frame->magic) != 0x53544448 && -+ ntohl(frame->magic) != 0x44544d48) -+ goto error; -+ -+ if (buf->len < sizeof(*frame) || -+ buf->len != le32_to_cpup(&frame->len)) { -+ /* Save this fragment for later assembly */ -+ if (s->current_rx_buf) -+ return 0; -+ -+ s->current_rx_buf = skb_copy_expand(skb, 0, -+ le32_to_cpup(&frame->len), GFP_ATOMIC); -+ if (!s->current_rx_buf) { -+ netif_err(dev, ifup, dev->net, "Reserving %i bytes " -+ "for packet assembly failed.\n", -+ le32_to_cpup(&frame->len)); -+ dev->net->stats.rx_errors++; -+ } -+ -+ return 0; -+ } -+ -+ count = le32_to_cpup(&frame->pkt_cnt); -+ -+ skb_pull(buf, sizeof(*frame)); -+ -+ while (count--) { -+ if (buf->len < sizeof(*packet)) { -+ netif_err(dev, ifup, dev->net, "Packet too short\n"); -+ goto error; -+ } -+ -+ packet = (struct vl600_pkt_hdr *) buf->data; -+ packet_len = sizeof(*packet) + le32_to_cpup(&packet->len); -+ if (packet_len > buf->len) { -+ netif_err(dev, ifup, dev->net, -+ "Bad packet length stored in header\n"); -+ goto error; -+ } -+ -+ /* Packet header is same size as the ethernet header -+ * (sizeof(*packet) == sizeof(*ethhdr)), additionally -+ * the h_proto field is in the same place so we just leave it -+ * alone and fill in the remaining fields. -+ */ -+ ethhdr = (struct ethhdr *) skb->data; -+ if (be16_to_cpup(ðhdr->h_proto) == ETH_P_ARP && -+ buf->len > 0x26) { -+ /* Copy the addresses from packet contents */ -+ memcpy(ethhdr->h_source, -+ &buf->data[sizeof(*ethhdr) + 0x8], -+ ETH_ALEN); -+ memcpy(ethhdr->h_dest, -+ &buf->data[sizeof(*ethhdr) + 0x12], -+ ETH_ALEN); -+ } else { -+ memset(ethhdr->h_source, 0, ETH_ALEN); -+ memcpy(ethhdr->h_dest, dev->net->dev_addr, ETH_ALEN); -+ -+ /* Inbound IPv6 packets have an IPv4 ethertype (0x800) -+ * for some reason. Peek at the L3 header to check -+ * for IPv6 packets, and set the ethertype to IPv6 -+ * (0x86dd) so Linux can understand it. -+ */ -+ if ((buf->data[sizeof(*ethhdr)] & 0xf0) == 0x60) -+ ethhdr->h_proto = htons(ETH_P_IPV6); -+ } -+ -+ if (count) { -+ /* Not the last packet in this batch */ -+ clone = skb_clone(buf, GFP_ATOMIC); -+ if (!clone) -+ goto error; -+ -+ skb_trim(clone, packet_len); -+ usbnet_skb_return(dev, clone); -+ -+ skb_pull(buf, (packet_len + 3) & ~3); -+ } else { -+ skb_trim(buf, packet_len); -+ -+ if (s->current_rx_buf) { -+ usbnet_skb_return(dev, buf); -+ s->current_rx_buf = NULL; -+ return 0; -+ } -+ -+ return 1; -+ } -+ } -+ -+error: -+ if (s->current_rx_buf) { -+ dev_kfree_skb_any(s->current_rx_buf); -+ s->current_rx_buf = NULL; -+ } -+ dev->net->stats.rx_errors++; -+ return 0; -+} -+ -+static struct sk_buff *vl600_tx_fixup(struct usbnet *dev, -+ struct sk_buff *skb, gfp_t flags) -+{ -+ struct sk_buff *ret; -+ struct vl600_frame_hdr *frame; -+ struct vl600_pkt_hdr *packet; -+ static uint32_t serial = 1; -+ int orig_len = skb->len - sizeof(struct ethhdr); -+ int full_len = (skb->len + sizeof(struct vl600_frame_hdr) + 3) & ~3; -+ -+ frame = (struct vl600_frame_hdr *) skb->data; -+ if (skb->len > sizeof(*frame) && skb->len == le32_to_cpup(&frame->len)) -+ return skb; /* Already encapsulated? */ -+ -+ if (skb->len < sizeof(struct ethhdr)) -+ /* Drop, device can only deal with ethernet packets */ -+ return NULL; -+ -+ if (!skb_cloned(skb)) { -+ int headroom = skb_headroom(skb); -+ int tailroom = skb_tailroom(skb); -+ -+ if (tailroom >= full_len - skb->len - sizeof(*frame) && -+ headroom >= sizeof(*frame)) -+ /* There's enough head and tail room */ -+ goto encapsulate; -+ -+ if (headroom + tailroom + skb->len >= full_len) { -+ /* There's enough total room, just readjust */ -+ skb->data = memmove(skb->head + sizeof(*frame), -+ skb->data, skb->len); -+ skb_set_tail_pointer(skb, skb->len); -+ goto encapsulate; -+ } -+ } -+ -+ /* Alloc a new skb with the required size */ -+ ret = skb_copy_expand(skb, sizeof(struct vl600_frame_hdr), full_len - -+ skb->len - sizeof(struct vl600_frame_hdr), flags); -+ dev_kfree_skb_any(skb); -+ if (!ret) -+ return ret; -+ skb = ret; -+ -+encapsulate: -+ /* Packet header is same size as ethernet packet header -+ * (sizeof(*packet) == sizeof(struct ethhdr)), additionally the -+ * h_proto field is in the same place so we just leave it alone and -+ * overwrite the remaining fields. -+ */ -+ packet = (struct vl600_pkt_hdr *) skb->data; -+ /* The VL600 wants IPv6 packets to have an IPv4 ethertype -+ * Since this modem only supports IPv4 and IPv6, just set all -+ * frames to 0x0800 (ETH_P_IP) -+ */ -+ packet->h_proto = htons(ETH_P_IP); -+ memset(&packet->dummy, 0, sizeof(packet->dummy)); -+ packet->len = cpu_to_le32(orig_len); -+ -+ frame = (struct vl600_frame_hdr *) skb_push(skb, sizeof(*frame)); -+ memset(frame, 0, sizeof(*frame)); -+ frame->len = cpu_to_le32(full_len); -+ frame->serial = cpu_to_le32(serial++); -+ frame->pkt_cnt = cpu_to_le32(1); -+ -+ if (skb->len < full_len) /* Pad */ -+ skb_put(skb, full_len - skb->len); -+ -+ return skb; -+} -+ -+static const struct driver_info vl600_info = { -+ .description = "LG VL600 modem", -+ .flags = FLAG_RX_ASSEMBLE | FLAG_WWAN, -+ .bind = vl600_bind, -+ .unbind = vl600_unbind, -+ .status = usbnet_cdc_status, -+ .rx_fixup = vl600_rx_fixup, -+ .tx_fixup = vl600_tx_fixup, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, -+ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), -+ .driver_info = (unsigned long) &vl600_info, -+ }, -+ {}, /* End */ -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver lg_vl600_driver = { -+ .name = "lg-vl600", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(lg_vl600_driver); -+ -+MODULE_AUTHOR("Anrzej Zaborowski"); -+MODULE_DESCRIPTION("LG-VL600 modem's ethernet link"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/Makefile backports-3.18.1-1/drivers/net/usb/Makefile ---- backports-3.18.1-1.org/drivers/net/usb/Makefile 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/Makefile 2015-01-03 13:49:51.269970813 +0100 -@@ -1,39 +1,35 @@ --# --# Makefile for USB Network drivers --# --# --#obj-$(CPTCFG_USB_CATC) += catc.o --#obj-$(CPTCFG_USB_KAWETH) += kaweth.o --#obj-$(CPTCFG_USB_PEGASUS) += pegasus.o --#obj-$(CPTCFG_USB_RTL8150) += rtl8150.o --#obj-$(CPTCFG_USB_RTL8152) += r8152.o --#obj-$(CPTCFG_USB_HSO) += hso.o --#obj-$(CPTCFG_USB_NET_AX8817X) += asix.o --#obj-$(CPTCFG_USB_NET_AX88179_178A) += ax88179_178a.o -+obj-$(CPTCFG_USB_CATC) += catc.o -+obj-$(CPTCFG_USB_KAWETH) += kaweth.o -+obj-$(CPTCFG_USB_PEGASUS) += pegasus.o -+obj-$(CPTCFG_USB_RTL8150) += rtl8150.o -+obj-$(CPTCFG_USB_RTL8152) += r8152.o -+obj-$(CPTCFG_USB_HSO) += hso.o -+obj-$(CPTCFG_USB_NET_AX8817X) += asix.o -+asix-y := asix_devices.o asix_common.o ax88172a.o -+obj-$(CPTCFG_USB_NET_AX88179_178A) += ax88179_178a.o - obj-$(CPTCFG_USB_NET_CDCETHER) += cdc_ether.o --#obj-$(CPTCFG_USB_NET_CDC_EEM) += cdc_eem.o --#obj-$(CPTCFG_USB_NET_DM9601) += dm9601.o --#obj-$(CPTCFG_USB_NET_SR9700) += sr9700.o --#obj-$(CPTCFG_USB_NET_SR9800) += sr9800.o --#obj-$(CPTCFG_USB_NET_SMSC75XX) += smsc75xx.o --#obj-$(CPTCFG_USB_NET_SMSC95XX) += smsc95xx.o --#obj-$(CPTCFG_USB_NET_GL620A) += gl620a.o --#obj-$(CPTCFG_USB_NET_NET1080) += net1080.o --#obj-$(CPTCFG_USB_NET_PLUSB) += plusb.o -+obj-$(CPTCFG_USB_NET_CDC_EEM) += cdc_eem.o -+obj-$(CPTCFG_USB_NET_DM9601) += dm9601.o -+obj-$(CPTCFG_USB_NET_SR9700) += sr9700.o -+obj-$(CPTCFG_USB_NET_SR9800) += sr9800.o -+obj-$(CPTCFG_USB_NET_SMSC75XX) += smsc75xx.o -+obj-$(CPTCFG_USB_NET_SMSC95XX) += smsc95xx.o -+obj-$(CPTCFG_USB_NET_GL620A) += gl620a.o -+obj-$(CPTCFG_USB_NET_NET1080) += net1080.o -+obj-$(CPTCFG_USB_NET_PLUSB) += plusb.o - obj-$(CPTCFG_USB_NET_RNDIS_HOST) += rndis_host.o --#obj-$(CPTCFG_USB_NET_CDC_SUBSET) += cdc_subset.o --#obj-$(CPTCFG_USB_NET_ZAURUS) += zaurus.o --#obj-$(CPTCFG_USB_NET_MCS7830) += mcs7830.o -+obj-$(CPTCFG_USB_NET_CDC_SUBSET) += cdc_subset.o -+obj-$(CPTCFG_USB_NET_ZAURUS) += zaurus.o -+obj-$(CPTCFG_USB_NET_MCS7830) += mcs7830.o - obj-$(CPTCFG_USB_USBNET) += usbnet.o --#obj-$(CPTCFG_USB_NET_INT51X1) += int51x1.o --#obj-$(CPTCFG_USB_CDC_PHONET) += cdc-phonet.o --#obj-$(CPTCFG_USB_NET_KALMIA) += kalmia.o --#obj-$(CPTCFG_USB_IPHETH) += ipheth.o -+obj-$(CPTCFG_USB_NET_INT51X1) += int51x1.o -+obj-$(CPTCFG_USB_CDC_PHONET) += cdc-phonet.o -+obj-$(CPTCFG_USB_NET_KALMIA) += kalmia.o -+obj-$(CPTCFG_USB_IPHETH) += ipheth.o - obj-$(CPTCFG_USB_SIERRA_NET) += sierra_net.o --#obj-$(CPTCFG_USB_NET_CX82310_ETH) += cx82310_eth.o -+obj-$(CPTCFG_USB_NET_CX82310_ETH) += cx82310_eth.o - obj-$(CPTCFG_USB_NET_CDC_NCM) += cdc_ncm.o --#obj-$(CPTCFG_USB_NET_HUAWEI_CDC_NCM) += huawei_cdc_ncm.o --#obj-$(CPTCFG_USB_VL600) += lg-vl600.o -+obj-$(CPTCFG_USB_NET_HUAWEI_CDC_NCM) += huawei_cdc_ncm.o -+obj-$(CPTCFG_USB_VL600) += lg-vl600.o - obj-$(CPTCFG_USB_NET_QMI_WWAN) += qmi_wwan.o - obj-$(CPTCFG_USB_NET_CDC_MBIM) += cdc_mbim.o -- -diff -Naur backports-3.18.1-1.org/drivers/net/usb/mcs7830.c backports-3.18.1-1/drivers/net/usb/mcs7830.c ---- backports-3.18.1-1.org/drivers/net/usb/mcs7830.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/mcs7830.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,643 @@ -+/* -+ * MOSCHIP MCS7830 based (7730/7830/7832) USB 2.0 Ethernet Devices -+ * -+ * based on usbnet.c, asix.c and the vendor provided mcs7830 driver -+ * -+ * Copyright (C) 2010 Andreas Mohr andi@lisas.de -+ * Copyright (C) 2006 Arnd Bergmann arnd@arndb.de -+ * Copyright (C) 2003-2005 David Hollis dhollis@davehollis.com -+ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net -+ * Copyright (c) 2002-2003 TiVo Inc. -+ * -+ * Definitions gathered from MOSCHIP, Data Sheet_7830DA.pdf (thanks!). -+ * -+ * 2010-12-19: add 7832 USB PID ("functionality same as MCS7830"), -+ * per active notification by manufacturer -+ * -+ * TODO: -+ * - support HIF_REG_CONFIG_SLEEPMODE/HIF_REG_CONFIG_TXENABLE (via autopm?) -+ * - implement ethtool_ops get_pauseparam/set_pauseparam -+ * via HIF_REG_PAUSE_THRESHOLD (>= revision C only!) -+ * - implement get_eeprom/[set_eeprom] -+ * - switch PHY on/off on ifup/ifdown (perhaps in usbnet.c, via MII) -+ * - mcs7830_get_regs() handling is weird: for rev 2 we return 32 regs, -+ * can access only ~ 24, remaining user buffer is uninitialized garbage -+ * - anything else? -+ * -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+#include <linux/crc32.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/mii.h> -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/slab.h> -+#include <linux/usb.h> -+#include <linux/usb/usbnet.h> -+ -+/* requests */ -+#define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \ -+ USB_RECIP_DEVICE) -+#define MCS7830_WR_BMREQ (USB_DIR_OUT | USB_TYPE_VENDOR | \ -+ USB_RECIP_DEVICE) -+#define MCS7830_RD_BREQ 0x0E -+#define MCS7830_WR_BREQ 0x0D -+ -+#define MCS7830_CTRL_TIMEOUT 1000 -+#define MCS7830_MAX_MCAST 64 -+ -+#define MCS7830_VENDOR_ID 0x9710 -+#define MCS7832_PRODUCT_ID 0x7832 -+#define MCS7830_PRODUCT_ID 0x7830 -+#define MCS7730_PRODUCT_ID 0x7730 -+ -+#define SITECOM_VENDOR_ID 0x0DF6 -+#define LN_030_PRODUCT_ID 0x0021 -+ -+#define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \ -+ ADVERTISE_100HALF | ADVERTISE_10FULL | \ -+ ADVERTISE_10HALF | ADVERTISE_CSMA) -+ -+/* HIF_REG_XX corresponding index value */ -+enum { -+ HIF_REG_MULTICAST_HASH = 0x00, -+ HIF_REG_PACKET_GAP1 = 0x08, -+ HIF_REG_PACKET_GAP2 = 0x09, -+ HIF_REG_PHY_DATA = 0x0a, -+ HIF_REG_PHY_CMD1 = 0x0c, -+ HIF_REG_PHY_CMD1_READ = 0x40, -+ HIF_REG_PHY_CMD1_WRITE = 0x20, -+ HIF_REG_PHY_CMD1_PHYADDR = 0x01, -+ HIF_REG_PHY_CMD2 = 0x0d, -+ HIF_REG_PHY_CMD2_PEND_FLAG_BIT = 0x80, -+ HIF_REG_PHY_CMD2_READY_FLAG_BIT = 0x40, -+ HIF_REG_CONFIG = 0x0e, -+ /* hmm, spec sez: "R/W", "Except bit 3" (likely TXENABLE). */ -+ HIF_REG_CONFIG_CFG = 0x80, -+ HIF_REG_CONFIG_SPEED100 = 0x40, -+ HIF_REG_CONFIG_FULLDUPLEX_ENABLE = 0x20, -+ HIF_REG_CONFIG_RXENABLE = 0x10, -+ HIF_REG_CONFIG_TXENABLE = 0x08, -+ HIF_REG_CONFIG_SLEEPMODE = 0x04, -+ HIF_REG_CONFIG_ALLMULTICAST = 0x02, -+ HIF_REG_CONFIG_PROMISCUOUS = 0x01, -+ HIF_REG_ETHERNET_ADDR = 0x0f, -+ HIF_REG_FRAME_DROP_COUNTER = 0x15, /* 0..ff; reset: 0 */ -+ HIF_REG_PAUSE_THRESHOLD = 0x16, -+ HIF_REG_PAUSE_THRESHOLD_DEFAULT = 0, -+}; -+ -+/* Trailing status byte in Ethernet Rx frame */ -+enum { -+ MCS7830_RX_SHORT_FRAME = 0x01, /* < 64 bytes */ -+ MCS7830_RX_LENGTH_ERROR = 0x02, /* framelen != Ethernet length field */ -+ MCS7830_RX_ALIGNMENT_ERROR = 0x04, /* non-even number of nibbles */ -+ MCS7830_RX_CRC_ERROR = 0x08, -+ MCS7830_RX_LARGE_FRAME = 0x10, /* > 1518 bytes */ -+ MCS7830_RX_FRAME_CORRECT = 0x20, /* frame is correct */ -+ /* [7:6] reserved */ -+}; -+ -+struct mcs7830_data { -+ u8 multi_filter[8]; -+ u8 config; -+}; -+ -+static const char driver_name[] = "MOSCHIP usb-ethernet driver"; -+ -+static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data) -+{ -+ return usbnet_read_cmd(dev, MCS7830_RD_BREQ, MCS7830_RD_BMREQ, -+ 0x0000, index, data, size); -+} -+ -+static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data) -+{ -+ return usbnet_write_cmd(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ, -+ 0x0000, index, data, size); -+} -+ -+static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data) -+{ -+ usbnet_write_cmd_async(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ, -+ 0x0000, index, data, size); -+} -+ -+static int mcs7830_hif_get_mac_address(struct usbnet *dev, unsigned char *addr) -+{ -+ int ret = mcs7830_get_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr); -+ if (ret < 0) -+ return ret; -+ return 0; -+} -+ -+static int mcs7830_hif_set_mac_address(struct usbnet *dev, unsigned char *addr) -+{ -+ int ret = mcs7830_set_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr); -+ -+ if (ret < 0) -+ return ret; -+ return 0; -+} -+ -+static int mcs7830_set_mac_address(struct net_device *netdev, void *p) -+{ -+ int ret; -+ struct usbnet *dev = netdev_priv(netdev); -+ struct sockaddr *addr = p; -+ -+ if (netif_running(netdev)) -+ return -EBUSY; -+ -+ if (!is_valid_ether_addr(addr->sa_data)) -+ return -EADDRNOTAVAIL; -+ -+ ret = mcs7830_hif_set_mac_address(dev, addr->sa_data); -+ -+ if (ret < 0) -+ return ret; -+ -+ /* it worked --> adopt it on netdev side */ -+ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); -+ -+ return 0; -+} -+ -+static int mcs7830_read_phy(struct usbnet *dev, u8 index) -+{ -+ int ret; -+ int i; -+ __le16 val; -+ -+ u8 cmd[2] = { -+ HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR, -+ HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index, -+ }; -+ -+ mutex_lock(&dev->phy_mutex); -+ /* write the MII command */ -+ ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); -+ if (ret < 0) -+ goto out; -+ -+ /* wait for the data to become valid, should be within < 1ms */ -+ for (i = 0; i < 10; i++) { -+ ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); -+ if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT)) -+ break; -+ ret = -EIO; -+ msleep(1); -+ } -+ if (ret < 0) -+ goto out; -+ -+ /* read actual register contents */ -+ ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val); -+ if (ret < 0) -+ goto out; -+ ret = le16_to_cpu(val); -+ dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n", -+ index, val, i); -+out: -+ mutex_unlock(&dev->phy_mutex); -+ return ret; -+} -+ -+static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val) -+{ -+ int ret; -+ int i; -+ __le16 le_val; -+ -+ u8 cmd[2] = { -+ HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR, -+ HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F), -+ }; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ /* write the new register contents */ -+ le_val = cpu_to_le16(val); -+ ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val); -+ if (ret < 0) -+ goto out; -+ -+ /* write the MII command */ -+ ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); -+ if (ret < 0) -+ goto out; -+ -+ /* wait for the command to be accepted by the PHY */ -+ for (i = 0; i < 10; i++) { -+ ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); -+ if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT)) -+ break; -+ ret = -EIO; -+ msleep(1); -+ } -+ if (ret < 0) -+ goto out; -+ -+ ret = 0; -+ dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n", -+ index, val, i); -+out: -+ mutex_unlock(&dev->phy_mutex); -+ return ret; -+} -+ -+/* -+ * This algorithm comes from the original mcs7830 version 1.4 driver, -+ * not sure if it is needed. -+ */ -+static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode) -+{ -+ int ret; -+ /* Enable all media types */ -+ ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE); -+ -+ /* First reset BMCR */ -+ if (!ret) -+ ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000); -+ /* Enable Auto Neg */ -+ if (!ret) -+ ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE); -+ /* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */ -+ if (!ret) -+ ret = mcs7830_write_phy(dev, MII_BMCR, -+ BMCR_ANENABLE | BMCR_ANRESTART ); -+ return ret; -+} -+ -+ -+/* -+ * if we can read register 22, the chip revision is C or higher -+ */ -+static int mcs7830_get_rev(struct usbnet *dev) -+{ -+ u8 dummy[2]; -+ int ret; -+ ret = mcs7830_get_reg(dev, HIF_REG_FRAME_DROP_COUNTER, 2, dummy); -+ if (ret > 0) -+ return 2; /* Rev C or later */ -+ return 1; /* earlier revision */ -+} -+ -+/* -+ * On rev. C we need to set the pause threshold -+ */ -+static void mcs7830_rev_C_fixup(struct usbnet *dev) -+{ -+ u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT; -+ int retry; -+ -+ for (retry = 0; retry < 2; retry++) { -+ if (mcs7830_get_rev(dev) == 2) { -+ dev_info(&dev->udev->dev, "applying rev.C fixup\n"); -+ mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD, -+ 1, &pause_threshold); -+ } -+ msleep(1); -+ } -+} -+ -+static int mcs7830_mdio_read(struct net_device *netdev, int phy_id, -+ int location) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ return mcs7830_read_phy(dev, location); -+} -+ -+static void mcs7830_mdio_write(struct net_device *netdev, int phy_id, -+ int location, int val) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ mcs7830_write_phy(dev, location, val); -+} -+ -+static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -+} -+ -+static inline struct mcs7830_data *mcs7830_get_data(struct usbnet *dev) -+{ -+ return (struct mcs7830_data *)&dev->data; -+} -+ -+static void mcs7830_hif_update_multicast_hash(struct usbnet *dev) -+{ -+ struct mcs7830_data *data = mcs7830_get_data(dev); -+ mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH, -+ sizeof data->multi_filter, -+ data->multi_filter); -+} -+ -+static void mcs7830_hif_update_config(struct usbnet *dev) -+{ -+ /* implementation specific to data->config -+ (argument needs to be heap-based anyway - USB DMA!) */ -+ struct mcs7830_data *data = mcs7830_get_data(dev); -+ mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config); -+} -+ -+static void mcs7830_data_set_multicast(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct mcs7830_data *data = mcs7830_get_data(dev); -+ -+ memset(data->multi_filter, 0, sizeof data->multi_filter); -+ -+ data->config = HIF_REG_CONFIG_TXENABLE; -+ -+ /* this should not be needed, but it doesn't work otherwise */ -+ data->config |= HIF_REG_CONFIG_ALLMULTICAST; -+ -+ if (net->flags & IFF_PROMISC) { -+ data->config |= HIF_REG_CONFIG_PROMISCUOUS; -+ } else if (net->flags & IFF_ALLMULTI || -+ netdev_mc_count(net) > MCS7830_MAX_MCAST) { -+ data->config |= HIF_REG_CONFIG_ALLMULTICAST; -+ } else if (netdev_mc_empty(net)) { -+ /* just broadcast and directed */ -+ } else { -+ /* We use the 20 byte dev->data -+ * for our 8 byte filter buffer -+ * to avoid allocating memory that -+ * is tricky to free later */ -+ struct netdev_hw_addr *ha; -+ u32 crc_bits; -+ -+ /* Build the multicast hash filter. */ -+ netdev_for_each_mc_addr(ha, net) { -+ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; -+ data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7); -+ } -+ } -+} -+ -+static int mcs7830_apply_base_config(struct usbnet *dev) -+{ -+ int ret; -+ -+ /* re-configure known MAC (suspend case etc.) */ -+ ret = mcs7830_hif_set_mac_address(dev, dev->net->dev_addr); -+ if (ret) { -+ dev_info(&dev->udev->dev, "Cannot set MAC address\n"); -+ goto out; -+ } -+ -+ /* Set up PHY */ -+ ret = mcs7830_set_autoneg(dev, 0); -+ if (ret) { -+ dev_info(&dev->udev->dev, "Cannot set autoneg\n"); -+ goto out; -+ } -+ -+ mcs7830_hif_update_multicast_hash(dev); -+ mcs7830_hif_update_config(dev); -+ -+ mcs7830_rev_C_fixup(dev); -+ ret = 0; -+out: -+ return ret; -+} -+ -+/* credits go to asix_set_multicast */ -+static void mcs7830_set_multicast(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ mcs7830_data_set_multicast(net); -+ -+ mcs7830_hif_update_multicast_hash(dev); -+ mcs7830_hif_update_config(dev); -+} -+ -+static int mcs7830_get_regs_len(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ switch (mcs7830_get_rev(dev)) { -+ case 1: -+ return 21; -+ case 2: -+ return 32; -+ } -+ return 0; -+} -+ -+static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo) -+{ -+ usbnet_get_drvinfo(net, drvinfo); -+ drvinfo->regdump_len = mcs7830_get_regs_len(net); -+} -+ -+static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ regs->version = mcs7830_get_rev(dev); -+ mcs7830_get_reg(dev, 0, regs->len, data); -+} -+ -+static const struct ethtool_ops mcs7830_ethtool_ops = { -+ .get_drvinfo = mcs7830_get_drvinfo, -+ .get_regs_len = mcs7830_get_regs_len, -+ .get_regs = mcs7830_get_regs, -+ -+ /* common usbnet calls */ -+ .get_link = usbnet_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .nway_reset = usbnet_nway_reset, -+}; -+ -+static const struct net_device_ops mcs7830_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = mcs7830_ioctl, -+ .ndo_set_rx_mode = mcs7830_set_multicast, -+ .ndo_set_mac_address = mcs7830_set_mac_address, -+}; -+ -+static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev) -+{ -+ struct net_device *net = dev->net; -+ int ret; -+ int retry; -+ -+ /* Initial startup: Gather MAC address setting from EEPROM */ -+ ret = -EINVAL; -+ for (retry = 0; retry < 5 && ret; retry++) -+ ret = mcs7830_hif_get_mac_address(dev, net->dev_addr); -+ if (ret) { -+ dev_warn(&dev->udev->dev, "Cannot read MAC address\n"); -+ goto out; -+ } -+ -+ mcs7830_data_set_multicast(net); -+ -+ ret = mcs7830_apply_base_config(dev); -+ if (ret) -+ goto out; -+ -+ net->ethtool_ops = &mcs7830_ethtool_ops; -+ net->netdev_ops = &mcs7830_netdev_ops; -+ -+ /* reserve space for the status byte on rx */ -+ dev->rx_urb_size = ETH_FRAME_LEN + 1; -+ -+ dev->mii.mdio_read = mcs7830_mdio_read; -+ dev->mii.mdio_write = mcs7830_mdio_write; -+ dev->mii.dev = net; -+ dev->mii.phy_id_mask = 0x3f; -+ dev->mii.reg_num_mask = 0x1f; -+ dev->mii.phy_id = *((u8 *) net->dev_addr + 1); -+ -+ ret = usbnet_get_endpoints(dev, udev); -+out: -+ return ret; -+} -+ -+/* The chip always appends a status byte that we need to strip */ -+static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ u8 status; -+ -+ /* This check is no longer done by usbnet */ -+ if (skb->len < dev->net->hard_header_len) { -+ dev_err(&dev->udev->dev, "unexpected tiny rx frame\n"); -+ return 0; -+ } -+ -+ skb_trim(skb, skb->len - 1); -+ status = skb->data[skb->len]; -+ -+ if (status != MCS7830_RX_FRAME_CORRECT) { -+ dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status); -+ -+ /* hmm, perhaps usbnet.c already sees a globally visible -+ frame error and increments rx_errors on its own already? */ -+ dev->net->stats.rx_errors++; -+ -+ if (status & (MCS7830_RX_SHORT_FRAME -+ |MCS7830_RX_LENGTH_ERROR -+ |MCS7830_RX_LARGE_FRAME)) -+ dev->net->stats.rx_length_errors++; -+ if (status & MCS7830_RX_ALIGNMENT_ERROR) -+ dev->net->stats.rx_frame_errors++; -+ if (status & MCS7830_RX_CRC_ERROR) -+ dev->net->stats.rx_crc_errors++; -+ } -+ -+ return skb->len > 0; -+} -+ -+static void mcs7830_status(struct usbnet *dev, struct urb *urb) -+{ -+ u8 *buf = urb->transfer_buffer; -+ bool link, link_changed; -+ -+ if (urb->actual_length < 16) -+ return; -+ -+ link = !(buf[1] == 0x20); -+ link_changed = netif_carrier_ok(dev->net) != link; -+ if (link_changed) { -+ usbnet_link_change(dev, link, 0); -+ netdev_dbg(dev->net, "Link Status is: %d\n", link); -+ } -+} -+ -+static const struct driver_info moschip_info = { -+ .description = "MOSCHIP 7830/7832/7730 usb-NET adapter", -+ .bind = mcs7830_bind, -+ .rx_fixup = mcs7830_rx_fixup, -+ .flags = FLAG_ETHER | FLAG_LINK_INTR, -+ .status = mcs7830_status, -+ .in = 1, -+ .out = 2, -+}; -+ -+static const struct driver_info sitecom_info = { -+ .description = "Sitecom LN-30 usb-NET adapter", -+ .bind = mcs7830_bind, -+ .rx_fixup = mcs7830_rx_fixup, -+ .flags = FLAG_ETHER | FLAG_LINK_INTR, -+ .status = mcs7830_status, -+ .in = 1, -+ .out = 2, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ USB_DEVICE(MCS7830_VENDOR_ID, MCS7832_PRODUCT_ID), -+ .driver_info = (unsigned long) &moschip_info, -+ }, -+ { -+ USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID), -+ .driver_info = (unsigned long) &moschip_info, -+ }, -+ { -+ USB_DEVICE(MCS7830_VENDOR_ID, MCS7730_PRODUCT_ID), -+ .driver_info = (unsigned long) &moschip_info, -+ }, -+ { -+ USB_DEVICE(SITECOM_VENDOR_ID, LN_030_PRODUCT_ID), -+ .driver_info = (unsigned long) &sitecom_info, -+ }, -+ {}, -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static int mcs7830_reset_resume (struct usb_interface *intf) -+{ -+ /* YES, this function is successful enough that ethtool -d -+ does show same output pre-/post-suspend */ -+ -+ struct usbnet *dev = usb_get_intfdata(intf); -+ -+ mcs7830_apply_base_config(dev); -+ -+ usbnet_resume(intf); -+ -+ return 0; -+} -+ -+static struct usb_driver mcs7830_driver = { -+ .name = driver_name, -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .reset_resume = mcs7830_reset_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(mcs7830_driver); -+ -+MODULE_DESCRIPTION("USB to network adapter MCS7830)"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/net1080.c backports-3.18.1-1/drivers/net/usb/net1080.c ---- backports-3.18.1-1.org/drivers/net/usb/net1080.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/net1080.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,544 @@ -+/* -+ * Net1080 based USB host-to-host cables -+ * Copyright (C) 2000-2005 by David Brownell -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+// #define DEBUG // error path messages, extra info -+// #define VERBOSE // more; success messages -+ -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/usb/usbnet.h> -+#include <linux/slab.h> -+ -+#include <asm/unaligned.h> -+ -+ -+/* -+ * Netchip 1080 driver ... http://www.netchip.com -+ * (Sept 2004: End-of-life announcement has been sent.) -+ * Used in (some) LapLink cables -+ */ -+ -+#define frame_errors data[1] -+ -+/* -+ * NetChip framing of ethernet packets, supporting additional error -+ * checks for links that may drop bulk packets from inside messages. -+ * Odd USB length == always short read for last usb packet. -+ * - nc_header -+ * - Ethernet header (14 bytes) -+ * - payload -+ * - (optional padding byte, if needed so length becomes odd) -+ * - nc_trailer -+ * -+ * This framing is to be avoided for non-NetChip devices. -+ */ -+ -+struct nc_header { // packed: -+ __le16 hdr_len; // sizeof nc_header (LE, all) -+ __le16 packet_len; // payload size (including ethhdr) -+ __le16 packet_id; // detects dropped packets -+#define MIN_HEADER 6 -+ -+ // all else is optional, and must start with: -+ // __le16 vendorId; // from usb-if -+ // __le16 productId; -+} __packed; -+ -+#define PAD_BYTE ((unsigned char)0xAC) -+ -+struct nc_trailer { -+ __le16 packet_id; -+} __packed; -+ -+// packets may use FLAG_FRAMING_NC and optional pad -+#define FRAMED_SIZE(mtu) (sizeof (struct nc_header) \ -+ + sizeof (struct ethhdr) \ -+ + (mtu) \ -+ + 1 \ -+ + sizeof (struct nc_trailer)) -+ -+#define MIN_FRAMED FRAMED_SIZE(0) -+ -+/* packets _could_ be up to 64KB... */ -+#define NC_MAX_PACKET 32767 -+ -+ -+/* -+ * Zero means no timeout; else, how long a 64 byte bulk packet may be queued -+ * before the hardware drops it. If that's done, the driver will need to -+ * frame network packets to guard against the dropped USB packets. The win32 -+ * driver sets this for both sides of the link. -+ */ -+#define NC_READ_TTL_MS ((u8)255) // ms -+ -+/* -+ * We ignore most registers and EEPROM contents. -+ */ -+#define REG_USBCTL ((u8)0x04) -+#define REG_TTL ((u8)0x10) -+#define REG_STATUS ((u8)0x11) -+ -+/* -+ * Vendor specific requests to read/write data -+ */ -+#define REQUEST_REGISTER ((u8)0x10) -+#define REQUEST_EEPROM ((u8)0x11) -+ -+static int -+nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr) -+{ -+ int status = usbnet_read_cmd(dev, req, -+ USB_DIR_IN | USB_TYPE_VENDOR | -+ USB_RECIP_DEVICE, -+ 0, regnum, retval_ptr, -+ sizeof *retval_ptr); -+ if (status > 0) -+ status = 0; -+ if (!status) -+ le16_to_cpus(retval_ptr); -+ return status; -+} -+ -+static inline int -+nc_register_read(struct usbnet *dev, u8 regnum, u16 *retval_ptr) -+{ -+ return nc_vendor_read(dev, REQUEST_REGISTER, regnum, retval_ptr); -+} -+ -+// no retval ... can become async, usable in_interrupt() -+static void -+nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value) -+{ -+ usbnet_write_cmd(dev, req, -+ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ value, regnum, NULL, 0); -+} -+ -+static inline void -+nc_register_write(struct usbnet *dev, u8 regnum, u16 value) -+{ -+ nc_vendor_write(dev, REQUEST_REGISTER, regnum, value); -+} -+ -+ -+#if 0 -+static void nc_dump_registers(struct usbnet *dev) -+{ -+ u8 reg; -+ u16 *vp = kmalloc(sizeof (u16)); -+ -+ if (!vp) -+ return; -+ -+ netdev_dbg(dev->net, "registers:\n"); -+ for (reg = 0; reg < 0x20; reg++) { -+ int retval; -+ -+ // reading some registers is trouble -+ if (reg >= 0x08 && reg <= 0xf) -+ continue; -+ if (reg >= 0x12 && reg <= 0x1e) -+ continue; -+ -+ retval = nc_register_read(dev, reg, vp); -+ if (retval < 0) -+ netdev_dbg(dev->net, "reg [0x%x] ==> error %d\n", -+ reg, retval); -+ else -+ netdev_dbg(dev->net, "reg [0x%x] = 0x%x\n", reg, *vp); -+ } -+ kfree(vp); -+} -+#endif -+ -+ -+/*-------------------------------------------------------------------------*/ -+ -+/* -+ * Control register -+ */ -+ -+#define USBCTL_WRITABLE_MASK 0x1f0f -+// bits 15-13 reserved, r/o -+#define USBCTL_ENABLE_LANG (1 << 12) -+#define USBCTL_ENABLE_MFGR (1 << 11) -+#define USBCTL_ENABLE_PROD (1 << 10) -+#define USBCTL_ENABLE_SERIAL (1 << 9) -+#define USBCTL_ENABLE_DEFAULTS (1 << 8) -+// bits 7-4 reserved, r/o -+#define USBCTL_FLUSH_OTHER (1 << 3) -+#define USBCTL_FLUSH_THIS (1 << 2) -+#define USBCTL_DISCONN_OTHER (1 << 1) -+#define USBCTL_DISCONN_THIS (1 << 0) -+ -+static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl) -+{ -+ netif_dbg(dev, link, dev->net, -+ "net1080 %s-%s usbctl 0x%x:%s%s%s%s%s; this%s%s; other%s%s; r/o 0x%x\n", -+ dev->udev->bus->bus_name, dev->udev->devpath, -+ usbctl, -+ (usbctl & USBCTL_ENABLE_LANG) ? " lang" : "", -+ (usbctl & USBCTL_ENABLE_MFGR) ? " mfgr" : "", -+ (usbctl & USBCTL_ENABLE_PROD) ? " prod" : "", -+ (usbctl & USBCTL_ENABLE_SERIAL) ? " serial" : "", -+ (usbctl & USBCTL_ENABLE_DEFAULTS) ? " defaults" : "", -+ -+ (usbctl & USBCTL_FLUSH_THIS) ? " FLUSH" : "", -+ (usbctl & USBCTL_DISCONN_THIS) ? " DIS" : "", -+ -+ (usbctl & USBCTL_FLUSH_OTHER) ? " FLUSH" : "", -+ (usbctl & USBCTL_DISCONN_OTHER) ? " DIS" : "", -+ -+ usbctl & ~USBCTL_WRITABLE_MASK); -+} -+ -+/*-------------------------------------------------------------------------*/ -+ -+/* -+ * Status register -+ */ -+ -+#define STATUS_PORT_A (1 << 15) -+ -+#define STATUS_CONN_OTHER (1 << 14) -+#define STATUS_SUSPEND_OTHER (1 << 13) -+#define STATUS_MAILBOX_OTHER (1 << 12) -+#define STATUS_PACKETS_OTHER(n) (((n) >> 8) & 0x03) -+ -+#define STATUS_CONN_THIS (1 << 6) -+#define STATUS_SUSPEND_THIS (1 << 5) -+#define STATUS_MAILBOX_THIS (1 << 4) -+#define STATUS_PACKETS_THIS(n) (((n) >> 0) & 0x03) -+ -+#define STATUS_UNSPEC_MASK 0x0c8c -+#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) -+ -+ -+static inline void nc_dump_status(struct usbnet *dev, u16 status) -+{ -+ netif_dbg(dev, link, dev->net, -+ "net1080 %s-%s status 0x%x: this (%c) PKT=%d%s%s%s; other PKT=%d%s%s%s; unspec 0x%x\n", -+ dev->udev->bus->bus_name, dev->udev->devpath, -+ status, -+ -+ // XXX the packet counts don't seem right -+ // (1 at reset, not 0); maybe UNSPEC too -+ -+ (status & STATUS_PORT_A) ? 'A' : 'B', -+ STATUS_PACKETS_THIS(status), -+ (status & STATUS_CONN_THIS) ? " CON" : "", -+ (status & STATUS_SUSPEND_THIS) ? " SUS" : "", -+ (status & STATUS_MAILBOX_THIS) ? " MBOX" : "", -+ -+ STATUS_PACKETS_OTHER(status), -+ (status & STATUS_CONN_OTHER) ? " CON" : "", -+ (status & STATUS_SUSPEND_OTHER) ? " SUS" : "", -+ (status & STATUS_MAILBOX_OTHER) ? " MBOX" : "", -+ -+ status & STATUS_UNSPEC_MASK); -+} -+ -+/*-------------------------------------------------------------------------*/ -+ -+/* -+ * TTL register -+ */ -+ -+#define TTL_THIS(ttl) (0x00ff & ttl) -+#define TTL_OTHER(ttl) (0x00ff & (ttl >> 8)) -+#define MK_TTL(this,other) ((u16)(((other)<<8)|(0x00ff&(this)))) -+ -+static inline void nc_dump_ttl(struct usbnet *dev, u16 ttl) -+{ -+ netif_dbg(dev, link, dev->net, "net1080 %s-%s ttl 0x%x this = %d, other = %d\n", -+ dev->udev->bus->bus_name, dev->udev->devpath, -+ ttl, TTL_THIS(ttl), TTL_OTHER(ttl)); -+} -+ -+/*-------------------------------------------------------------------------*/ -+ -+static int net1080_reset(struct usbnet *dev) -+{ -+ u16 usbctl, status, ttl; -+ u16 vp; -+ int retval; -+ -+ // nc_dump_registers(dev); -+ -+ if ((retval = nc_register_read(dev, REG_STATUS, &vp)) < 0) { -+ netdev_dbg(dev->net, "can't read %s-%s status: %d\n", -+ dev->udev->bus->bus_name, dev->udev->devpath, retval); -+ goto done; -+ } -+ status = vp; -+ nc_dump_status(dev, status); -+ -+ if ((retval = nc_register_read(dev, REG_USBCTL, &vp)) < 0) { -+ netdev_dbg(dev->net, "can't read USBCTL, %d\n", retval); -+ goto done; -+ } -+ usbctl = vp; -+ nc_dump_usbctl(dev, usbctl); -+ -+ nc_register_write(dev, REG_USBCTL, -+ USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER); -+ -+ if ((retval = nc_register_read(dev, REG_TTL, &vp)) < 0) { -+ netdev_dbg(dev->net, "can't read TTL, %d\n", retval); -+ goto done; -+ } -+ ttl = vp; -+ // nc_dump_ttl(dev, ttl); -+ -+ nc_register_write(dev, REG_TTL, -+ MK_TTL(NC_READ_TTL_MS, TTL_OTHER(ttl)) ); -+ netdev_dbg(dev->net, "assigned TTL, %d ms\n", NC_READ_TTL_MS); -+ -+ netif_info(dev, link, dev->net, "port %c, peer %sconnected\n", -+ (status & STATUS_PORT_A) ? 'A' : 'B', -+ (status & STATUS_CONN_OTHER) ? "" : "dis"); -+ retval = 0; -+ -+done: -+ return retval; -+} -+ -+static int net1080_check_connect(struct usbnet *dev) -+{ -+ int retval; -+ u16 status; -+ u16 vp; -+ -+ retval = nc_register_read(dev, REG_STATUS, &vp); -+ status = vp; -+ if (retval != 0) { -+ netdev_dbg(dev->net, "net1080_check_conn read - %d\n", retval); -+ return retval; -+ } -+ if ((status & STATUS_CONN_OTHER) != STATUS_CONN_OTHER) -+ return -ENOLINK; -+ return 0; -+} -+ -+static void nc_ensure_sync(struct usbnet *dev) -+{ -+ if (++dev->frame_errors <= 5) -+ return; -+ -+ if (usbnet_write_cmd_async(dev, REQUEST_REGISTER, -+ USB_DIR_OUT | USB_TYPE_VENDOR | -+ USB_RECIP_DEVICE, -+ USBCTL_FLUSH_THIS | -+ USBCTL_FLUSH_OTHER, -+ REG_USBCTL, NULL, 0)) -+ return; -+ -+ netif_dbg(dev, rx_err, dev->net, -+ "flush net1080; too many framing errors\n"); -+ dev->frame_errors = 0; -+} -+ -+static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ struct nc_header *header; -+ struct nc_trailer *trailer; -+ u16 hdr_len, packet_len; -+ -+ /* This check is no longer done by usbnet */ -+ if (skb->len < dev->net->hard_header_len) -+ return 0; -+ -+ if (!(skb->len & 0x01)) { -+ netdev_dbg(dev->net, "rx framesize %d range %d..%d mtu %d\n", -+ skb->len, dev->net->hard_header_len, dev->hard_mtu, -+ dev->net->mtu); -+ dev->net->stats.rx_frame_errors++; -+ nc_ensure_sync(dev); -+ return 0; -+ } -+ -+ header = (struct nc_header *) skb->data; -+ hdr_len = le16_to_cpup(&header->hdr_len); -+ packet_len = le16_to_cpup(&header->packet_len); -+ if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) { -+ dev->net->stats.rx_frame_errors++; -+ netdev_dbg(dev->net, "packet too big, %d\n", packet_len); -+ nc_ensure_sync(dev); -+ return 0; -+ } else if (hdr_len < MIN_HEADER) { -+ dev->net->stats.rx_frame_errors++; -+ netdev_dbg(dev->net, "header too short, %d\n", hdr_len); -+ nc_ensure_sync(dev); -+ return 0; -+ } else if (hdr_len > MIN_HEADER) { -+ // out of band data for us? -+ netdev_dbg(dev->net, "header OOB, %d bytes\n", hdr_len - MIN_HEADER); -+ nc_ensure_sync(dev); -+ // switch (vendor/product ids) { ... } -+ } -+ skb_pull(skb, hdr_len); -+ -+ trailer = (struct nc_trailer *) -+ (skb->data + skb->len - sizeof *trailer); -+ skb_trim(skb, skb->len - sizeof *trailer); -+ -+ if ((packet_len & 0x01) == 0) { -+ if (skb->data [packet_len] != PAD_BYTE) { -+ dev->net->stats.rx_frame_errors++; -+ netdev_dbg(dev->net, "bad pad\n"); -+ return 0; -+ } -+ skb_trim(skb, skb->len - 1); -+ } -+ if (skb->len != packet_len) { -+ dev->net->stats.rx_frame_errors++; -+ netdev_dbg(dev->net, "bad packet len %d (expected %d)\n", -+ skb->len, packet_len); -+ nc_ensure_sync(dev); -+ return 0; -+ } -+ if (header->packet_id != get_unaligned(&trailer->packet_id)) { -+ dev->net->stats.rx_fifo_errors++; -+ netdev_dbg(dev->net, "(2+ dropped) rx packet_id mismatch 0x%x 0x%x\n", -+ le16_to_cpu(header->packet_id), -+ le16_to_cpu(trailer->packet_id)); -+ return 0; -+ } -+#if 0 -+ netdev_dbg(dev->net, "frame <rx h %d p %d id %d\n", header->hdr_len, -+ header->packet_len, header->packet_id); -+#endif -+ dev->frame_errors = 0; -+ return 1; -+} -+ -+static struct sk_buff * -+net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) -+{ -+ struct sk_buff *skb2; -+ struct nc_header *header = NULL; -+ struct nc_trailer *trailer = NULL; -+ int padlen = sizeof (struct nc_trailer); -+ int len = skb->len; -+ -+ if (!((len + padlen + sizeof (struct nc_header)) & 0x01)) -+ padlen++; -+ if (!skb_cloned(skb)) { -+ int headroom = skb_headroom(skb); -+ int tailroom = skb_tailroom(skb); -+ -+ if (padlen <= tailroom && -+ sizeof(struct nc_header) <= headroom) -+ /* There's enough head and tail room */ -+ goto encapsulate; -+ -+ if ((sizeof (struct nc_header) + padlen) < -+ (headroom + tailroom)) { -+ /* There's enough total room, so just readjust */ -+ skb->data = memmove(skb->head -+ + sizeof (struct nc_header), -+ skb->data, skb->len); -+ skb_set_tail_pointer(skb, len); -+ goto encapsulate; -+ } -+ } -+ -+ /* Create a new skb to use with the correct size */ -+ skb2 = skb_copy_expand(skb, -+ sizeof (struct nc_header), -+ padlen, -+ flags); -+ dev_kfree_skb_any(skb); -+ if (!skb2) -+ return skb2; -+ skb = skb2; -+ -+encapsulate: -+ /* header first */ -+ header = (struct nc_header *) skb_push(skb, sizeof *header); -+ header->hdr_len = cpu_to_le16(sizeof (*header)); -+ header->packet_len = cpu_to_le16(len); -+ header->packet_id = cpu_to_le16((u16)dev->xid++); -+ -+ /* maybe pad; then trailer */ -+ if (!((skb->len + sizeof *trailer) & 0x01)) -+ *skb_put(skb, 1) = PAD_BYTE; -+ trailer = (struct nc_trailer *) skb_put(skb, sizeof *trailer); -+ put_unaligned(header->packet_id, &trailer->packet_id); -+#if 0 -+ netdev_dbg(dev->net, "frame >tx h %d p %d id %d\n", -+ header->hdr_len, header->packet_len, -+ header->packet_id); -+#endif -+ return skb; -+} -+ -+static int net1080_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ unsigned extra = sizeof (struct nc_header) -+ + 1 -+ + sizeof (struct nc_trailer); -+ -+ dev->net->hard_header_len += extra; -+ dev->rx_urb_size = dev->net->hard_header_len + dev->net->mtu; -+ dev->hard_mtu = NC_MAX_PACKET; -+ return usbnet_get_endpoints (dev, intf); -+} -+ -+static const struct driver_info net1080_info = { -+ .description = "NetChip TurboCONNECT", -+ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_NC, -+ .bind = net1080_bind, -+ .reset = net1080_reset, -+ .check_connect = net1080_check_connect, -+ .rx_fixup = net1080_rx_fixup, -+ .tx_fixup = net1080_tx_fixup, -+}; -+ -+static const struct usb_device_id products [] = { -+{ -+ USB_DEVICE(0x0525, 0x1080), // NetChip ref design -+ .driver_info = (unsigned long) &net1080_info, -+}, { -+ USB_DEVICE(0x06D0, 0x0622), // Laplink Gold -+ .driver_info = (unsigned long) &net1080_info, -+}, -+ { }, // END -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver net1080_driver = { -+ .name = "net1080", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(net1080_driver); -+ -+MODULE_AUTHOR("David Brownell"); -+MODULE_DESCRIPTION("NetChip 1080 based USB Host-to-Host Links"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/pegasus.c backports-3.18.1-1/drivers/net/usb/pegasus.c ---- backports-3.18.1-1.org/drivers/net/usb/pegasus.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/pegasus.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,1335 @@ -+/* -+ * Copyright (c) 1999-2013 Petko Manolov (petkan@nucleusys.com) -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as -+ * published by the Free Software Foundation. -+ * -+ * ChangeLog: -+ * .... Most of the time spent on reading sources & docs. -+ * v0.2.x First official release for the Linux kernel. -+ * v0.3.0 Beutified and structured, some bugs fixed. -+ * v0.3.x URBifying bulk requests and bugfixing. First relatively -+ * stable release. Still can touch device's registers only -+ * from top-halves. -+ * v0.4.0 Control messages remained unurbified are now URBs. -+ * Now we can touch the HW at any time. -+ * v0.4.9 Control urbs again use process context to wait. Argh... -+ * Some long standing bugs (enable_net_traffic) fixed. -+ * Also nasty trick about resubmiting control urb from -+ * interrupt context used. Please let me know how it -+ * behaves. Pegasus II support added since this version. -+ * TODO: suppressing HCD warnings spewage on disconnect. -+ * v0.4.13 Ethernet address is now set at probe(), not at open() -+ * time as this seems to break dhcpd. -+ * v0.5.0 branch to 2.5.x kernels -+ * v0.5.1 ethtool support added -+ * v0.5.5 rx socket buffers are in a pool and the their allocation -+ * is out of the interrupt routine. -+ * ... -+ * v0.9.3 simplified [get|set]_register(s), async update registers -+ * logic revisited, receive skb_pool removed. -+ */ -+ -+#include <linux/sched.h> -+#include <linux/slab.h> -+#include <linux/init.h> -+#include <linux/delay.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/module.h> -+#include <asm/byteorder.h> -+#include <asm/uaccess.h> -+#include "pegasus.h" -+ -+/* -+ * Version Information -+ */ -+#define DRIVER_VERSION "v0.9.3 (2013/04/25)" -+#define DRIVER_AUTHOR "Petko Manolov petkan@nucleusys.com" -+#define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver" -+ -+static const char driver_name[] = "pegasus"; -+ -+#undef PEGASUS_WRITE_EEPROM -+#define BMSR_MEDIA (BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | \ -+ BMSR_100FULL | BMSR_ANEGCAPABLE) -+ -+static bool loopback; -+static bool mii_mode; -+static char *devid; -+ -+static struct usb_eth_dev usb_dev_id[] = { -+#define PEGASUS_DEV(pn, vid, pid, flags) \ -+ {.name = pn, .vendor = vid, .device = pid, .private = flags}, -+#define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \ -+ PEGASUS_DEV(pn, vid, pid, flags) -+#include "pegasus.h" -+#undef PEGASUS_DEV -+#undef PEGASUS_DEV_CLASS -+ {NULL, 0, 0, 0}, -+ {NULL, 0, 0, 0} -+}; -+ -+static struct usb_device_id pegasus_ids[] = { -+#define PEGASUS_DEV(pn, vid, pid, flags) \ -+ {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid}, -+/* -+ * The Belkin F8T012xx1 bluetooth adaptor has the same vendor and product -+ * IDs as the Belkin F5D5050, so we need to teach the pegasus driver to -+ * ignore adaptors belonging to the "Wireless" class 0xE0. For this one -+ * case anyway, seeing as the pegasus is for "Wired" adaptors. -+ */ -+#define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \ -+ {.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS), \ -+ .idVendor = vid, .idProduct = pid, .bDeviceClass = dclass}, -+#include "pegasus.h" -+#undef PEGASUS_DEV -+#undef PEGASUS_DEV_CLASS -+ {}, -+ {} -+}; -+ -+MODULE_AUTHOR(DRIVER_AUTHOR); -+MODULE_DESCRIPTION(DRIVER_DESC); -+MODULE_LICENSE("GPL"); -+module_param(loopback, bool, 0); -+module_param(mii_mode, bool, 0); -+module_param(devid, charp, 0); -+MODULE_PARM_DESC(loopback, "Enable MAC loopback mode (bit 0)"); -+MODULE_PARM_DESC(mii_mode, "Enable HomePNA mode (bit 0),default=MII mode = 0"); -+MODULE_PARM_DESC(devid, "The format is: 'DEV_name:VendorID:DeviceID:Flags'"); -+ -+/* use ethtool to change the level for any given device */ -+static int msg_level = -1; -+module_param(msg_level, int, 0); -+MODULE_PARM_DESC(msg_level, "Override default message level"); -+ -+MODULE_DEVICE_TABLE(usb, pegasus_ids); -+static const struct net_device_ops pegasus_netdev_ops; -+ -+/*****/ -+ -+static void async_ctrl_callback(struct urb *urb) -+{ -+ struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context; -+ int status = urb->status; -+ -+ if (status < 0) -+ dev_dbg(&urb->dev->dev, "%s failed with %d", __func__, status); -+ kfree(req); -+ usb_free_urb(urb); -+} -+ -+static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) -+{ -+ int ret; -+ -+ ret = usb_control_msg(pegasus->usb, usb_rcvctrlpipe(pegasus->usb, 0), -+ PEGASUS_REQ_GET_REGS, PEGASUS_REQT_READ, 0, -+ indx, data, size, 1000); -+ if (ret < 0) -+ netif_dbg(pegasus, drv, pegasus->net, -+ "%s returned %d\n", __func__, ret); -+ return ret; -+} -+ -+static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) -+{ -+ int ret; -+ -+ ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), -+ PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0, -+ indx, data, size, 100); -+ if (ret < 0) -+ netif_dbg(pegasus, drv, pegasus->net, -+ "%s returned %d\n", __func__, ret); -+ return ret; -+} -+ -+static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data) -+{ -+ int ret; -+ -+ ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), -+ PEGASUS_REQ_SET_REG, PEGASUS_REQT_WRITE, data, -+ indx, &data, 1, 1000); -+ if (ret < 0) -+ netif_dbg(pegasus, drv, pegasus->net, -+ "%s returned %d\n", __func__, ret); -+ return ret; -+} -+ -+static int update_eth_regs_async(pegasus_t *pegasus) -+{ -+ int ret = -ENOMEM; -+ struct urb *async_urb; -+ struct usb_ctrlrequest *req; -+ -+ req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); -+ if (req == NULL) -+ return ret; -+ -+ async_urb = usb_alloc_urb(0, GFP_ATOMIC); -+ if (async_urb == NULL) { -+ kfree(req); -+ return ret; -+ } -+ req->bRequestType = PEGASUS_REQT_WRITE; -+ req->bRequest = PEGASUS_REQ_SET_REGS; -+ req->wValue = cpu_to_le16(0); -+ req->wIndex = cpu_to_le16(EthCtrl0); -+ req->wLength = cpu_to_le16(3); -+ -+ usb_fill_control_urb(async_urb, pegasus->usb, -+ usb_sndctrlpipe(pegasus->usb, 0), (void *)req, -+ pegasus->eth_regs, 3, async_ctrl_callback, req); -+ -+ ret = usb_submit_urb(async_urb, GFP_ATOMIC); -+ if (ret) { -+ if (ret == -ENODEV) -+ netif_device_detach(pegasus->net); -+ netif_err(pegasus, drv, pegasus->net, -+ "%s returned %d\n", __func__, ret); -+ } -+ return ret; -+} -+ -+static int __mii_op(pegasus_t *p, __u8 phy, __u8 indx, __u16 *regd, __u8 cmd) -+{ -+ int i; -+ __u8 data[4] = { phy, 0, 0, indx }; -+ __le16 regdi; -+ int ret = -ETIMEDOUT; -+ -+ if (cmd & PHY_WRITE) { -+ __le16 *t = (__le16 *) & data[1]; -+ *t = cpu_to_le16(*regd); -+ } -+ set_register(p, PhyCtrl, 0); -+ set_registers(p, PhyAddr, sizeof(data), data); -+ set_register(p, PhyCtrl, (indx | cmd)); -+ for (i = 0; i < REG_TIMEOUT; i++) { -+ ret = get_registers(p, PhyCtrl, 1, data); -+ if (ret < 0) -+ goto fail; -+ if (data[0] & PHY_DONE) -+ break; -+ } -+ if (i >= REG_TIMEOUT) -+ goto fail; -+ if (cmd & PHY_READ) { -+ ret = get_registers(p, PhyData, 2, ®di); -+ *regd = le16_to_cpu(regdi); -+ return ret; -+ } -+ return 0; -+fail: -+ netif_dbg(p, drv, p->net, "%s failed\n", __func__); -+ return ret; -+} -+ -+/* Returns non-negative int on success, error on failure */ -+static int read_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd) -+{ -+ return __mii_op(pegasus, phy, indx, regd, PHY_READ); -+} -+ -+/* Returns zero on success, error on failure */ -+static int write_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd) -+{ -+ return __mii_op(pegasus, phy, indx, regd, PHY_WRITE); -+} -+ -+static int mdio_read(struct net_device *dev, int phy_id, int loc) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ u16 res; -+ -+ read_mii_word(pegasus, phy_id, loc, &res); -+ return (int)res; -+} -+ -+static void mdio_write(struct net_device *dev, int phy_id, int loc, int val) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ u16 data = val; -+ -+ write_mii_word(pegasus, phy_id, loc, &data); -+} -+ -+static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata) -+{ -+ int i; -+ __u8 tmp; -+ __le16 retdatai; -+ int ret; -+ -+ set_register(pegasus, EpromCtrl, 0); -+ set_register(pegasus, EpromOffset, index); -+ set_register(pegasus, EpromCtrl, EPROM_READ); -+ -+ for (i = 0; i < REG_TIMEOUT; i++) { -+ ret = get_registers(pegasus, EpromCtrl, 1, &tmp); -+ if (tmp & EPROM_DONE) -+ break; -+ if (ret == -ESHUTDOWN) -+ goto fail; -+ } -+ if (i >= REG_TIMEOUT) -+ goto fail; -+ -+ ret = get_registers(pegasus, EpromData, 2, &retdatai); -+ *retdata = le16_to_cpu(retdatai); -+ return ret; -+ -+fail: -+ netif_warn(pegasus, drv, pegasus->net, "%s failed\n", __func__); -+ return -ETIMEDOUT; -+} -+ -+#ifdef PEGASUS_WRITE_EEPROM -+static inline void enable_eprom_write(pegasus_t *pegasus) -+{ -+ __u8 tmp; -+ -+ get_registers(pegasus, EthCtrl2, 1, &tmp); -+ set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE); -+} -+ -+static inline void disable_eprom_write(pegasus_t *pegasus) -+{ -+ __u8 tmp; -+ -+ get_registers(pegasus, EthCtrl2, 1, &tmp); -+ set_register(pegasus, EpromCtrl, 0); -+ set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE); -+} -+ -+static int write_eprom_word(pegasus_t *pegasus, __u8 index, __u16 data) -+{ -+ int i; -+ __u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE }; -+ int ret; -+ __le16 le_data = cpu_to_le16(data); -+ -+ set_registers(pegasus, EpromOffset, 4, d); -+ enable_eprom_write(pegasus); -+ set_register(pegasus, EpromOffset, index); -+ set_registers(pegasus, EpromData, 2, &le_data); -+ set_register(pegasus, EpromCtrl, EPROM_WRITE); -+ -+ for (i = 0; i < REG_TIMEOUT; i++) { -+ ret = get_registers(pegasus, EpromCtrl, 1, &tmp); -+ if (ret == -ESHUTDOWN) -+ goto fail; -+ if (tmp & EPROM_DONE) -+ break; -+ } -+ disable_eprom_write(pegasus); -+ if (i >= REG_TIMEOUT) -+ goto fail; -+ -+ return ret; -+ -+fail: -+ netif_warn(pegasus, drv, pegasus->net, "%s failed\n", __func__); -+ return -ETIMEDOUT; -+} -+#endif /* PEGASUS_WRITE_EEPROM */ -+ -+static inline void get_node_id(pegasus_t *pegasus, __u8 *id) -+{ -+ int i; -+ __u16 w16; -+ -+ for (i = 0; i < 3; i++) { -+ read_eprom_word(pegasus, i, &w16); -+ ((__le16 *) id)[i] = cpu_to_le16(w16); -+ } -+} -+ -+static void set_ethernet_addr(pegasus_t *pegasus) -+{ -+ __u8 node_id[6]; -+ -+ if (pegasus->features & PEGASUS_II) { -+ get_registers(pegasus, 0x10, sizeof(node_id), node_id); -+ } else { -+ get_node_id(pegasus, node_id); -+ set_registers(pegasus, EthID, sizeof(node_id), node_id); -+ } -+ memcpy(pegasus->net->dev_addr, node_id, sizeof(node_id)); -+} -+ -+static inline int reset_mac(pegasus_t *pegasus) -+{ -+ __u8 data = 0x8; -+ int i; -+ -+ set_register(pegasus, EthCtrl1, data); -+ for (i = 0; i < REG_TIMEOUT; i++) { -+ get_registers(pegasus, EthCtrl1, 1, &data); -+ if (~data & 0x08) { -+ if (loopback) -+ break; -+ if (mii_mode && (pegasus->features & HAS_HOME_PNA)) -+ set_register(pegasus, Gpio1, 0x34); -+ else -+ set_register(pegasus, Gpio1, 0x26); -+ set_register(pegasus, Gpio0, pegasus->features); -+ set_register(pegasus, Gpio0, DEFAULT_GPIO_SET); -+ break; -+ } -+ } -+ if (i == REG_TIMEOUT) -+ return -ETIMEDOUT; -+ -+ if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS || -+ usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) { -+ set_register(pegasus, Gpio0, 0x24); -+ set_register(pegasus, Gpio0, 0x26); -+ } -+ if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_ELCON) { -+ __u16 auxmode; -+ read_mii_word(pegasus, 3, 0x1b, &auxmode); -+ auxmode |= 4; -+ write_mii_word(pegasus, 3, 0x1b, &auxmode); -+ } -+ -+ return 0; -+} -+ -+static int enable_net_traffic(struct net_device *dev, struct usb_device *usb) -+{ -+ __u16 linkpart; -+ __u8 data[4]; -+ pegasus_t *pegasus = netdev_priv(dev); -+ int ret; -+ -+ read_mii_word(pegasus, pegasus->phy, MII_LPA, &linkpart); -+ data[0] = 0xc9; -+ data[1] = 0; -+ if (linkpart & (ADVERTISE_100FULL | ADVERTISE_10FULL)) -+ data[1] |= 0x20; /* set full duplex */ -+ if (linkpart & (ADVERTISE_100FULL | ADVERTISE_100HALF)) -+ data[1] |= 0x10; /* set 100 Mbps */ -+ if (mii_mode) -+ data[1] = 0; -+ data[2] = loopback ? 0x09 : 0x01; -+ -+ memcpy(pegasus->eth_regs, data, sizeof(data)); -+ ret = set_registers(pegasus, EthCtrl0, 3, data); -+ -+ if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS || -+ usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS2 || -+ usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) { -+ u16 auxmode; -+ read_mii_word(pegasus, 0, 0x1b, &auxmode); -+ auxmode |= 4; -+ write_mii_word(pegasus, 0, 0x1b, &auxmode); -+ } -+ -+ return ret; -+} -+ -+static void read_bulk_callback(struct urb *urb) -+{ -+ pegasus_t *pegasus = urb->context; -+ struct net_device *net; -+ int rx_status, count = urb->actual_length; -+ int status = urb->status; -+ u8 *buf = urb->transfer_buffer; -+ __u16 pkt_len; -+ -+ if (!pegasus) -+ return; -+ -+ net = pegasus->net; -+ if (!netif_device_present(net) || !netif_running(net)) -+ return; -+ -+ switch (status) { -+ case 0: -+ break; -+ case -ETIME: -+ netif_dbg(pegasus, rx_err, net, "reset MAC\n"); -+ pegasus->flags &= ~PEGASUS_RX_BUSY; -+ break; -+ case -EPIPE: /* stall, or disconnect from TT */ -+ /* FIXME schedule work to clear the halt */ -+ netif_warn(pegasus, rx_err, net, "no rx stall recovery\n"); -+ return; -+ case -ENOENT: -+ case -ECONNRESET: -+ case -ESHUTDOWN: -+ netif_dbg(pegasus, ifdown, net, "rx unlink, %d\n", status); -+ return; -+ default: -+ netif_dbg(pegasus, rx_err, net, "RX status %d\n", status); -+ goto goon; -+ } -+ -+ if (!count || count < 4) -+ goto goon; -+ -+ rx_status = buf[count - 2]; -+ if (rx_status & 0x1e) { -+ netif_dbg(pegasus, rx_err, net, -+ "RX packet error %x\n", rx_status); -+ pegasus->stats.rx_errors++; -+ if (rx_status & 0x06) /* long or runt */ -+ pegasus->stats.rx_length_errors++; -+ if (rx_status & 0x08) -+ pegasus->stats.rx_crc_errors++; -+ if (rx_status & 0x10) /* extra bits */ -+ pegasus->stats.rx_frame_errors++; -+ goto goon; -+ } -+ if (pegasus->chip == 0x8513) { -+ pkt_len = le32_to_cpu(*(__le32 *)urb->transfer_buffer); -+ pkt_len &= 0x0fff; -+ pegasus->rx_skb->data += 2; -+ } else { -+ pkt_len = buf[count - 3] << 8; -+ pkt_len += buf[count - 4]; -+ pkt_len &= 0xfff; -+ pkt_len -= 8; -+ } -+ -+ /* -+ * If the packet is unreasonably long, quietly drop it rather than -+ * kernel panicing by calling skb_put. -+ */ -+ if (pkt_len > PEGASUS_MTU) -+ goto goon; -+ -+ /* -+ * at this point we are sure pegasus->rx_skb != NULL -+ * so we go ahead and pass up the packet. -+ */ -+ skb_put(pegasus->rx_skb, pkt_len); -+ pegasus->rx_skb->protocol = eth_type_trans(pegasus->rx_skb, net); -+ netif_rx(pegasus->rx_skb); -+ pegasus->stats.rx_packets++; -+ pegasus->stats.rx_bytes += pkt_len; -+ -+ if (pegasus->flags & PEGASUS_UNPLUG) -+ return; -+ -+ pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net, PEGASUS_MTU, -+ GFP_ATOMIC); -+ -+ if (pegasus->rx_skb == NULL) -+ goto tl_sched; -+goon: -+ usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, -+ usb_rcvbulkpipe(pegasus->usb, 1), -+ pegasus->rx_skb->data, PEGASUS_MTU + 8, -+ read_bulk_callback, pegasus); -+ rx_status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC); -+ if (rx_status == -ENODEV) -+ netif_device_detach(pegasus->net); -+ else if (rx_status) { -+ pegasus->flags |= PEGASUS_RX_URB_FAIL; -+ goto tl_sched; -+ } else { -+ pegasus->flags &= ~PEGASUS_RX_URB_FAIL; -+ } -+ -+ return; -+ -+tl_sched: -+ tasklet_schedule(&pegasus->rx_tl); -+} -+ -+static void rx_fixup(unsigned long data) -+{ -+ pegasus_t *pegasus; -+ int status; -+ -+ pegasus = (pegasus_t *) data; -+ if (pegasus->flags & PEGASUS_UNPLUG) -+ return; -+ -+ if (pegasus->flags & PEGASUS_RX_URB_FAIL) -+ if (pegasus->rx_skb) -+ goto try_again; -+ if (pegasus->rx_skb == NULL) -+ pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net, -+ PEGASUS_MTU, -+ GFP_ATOMIC); -+ if (pegasus->rx_skb == NULL) { -+ netif_warn(pegasus, rx_err, pegasus->net, "low on memory\n"); -+ tasklet_schedule(&pegasus->rx_tl); -+ return; -+ } -+ usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, -+ usb_rcvbulkpipe(pegasus->usb, 1), -+ pegasus->rx_skb->data, PEGASUS_MTU + 8, -+ read_bulk_callback, pegasus); -+try_again: -+ status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC); -+ if (status == -ENODEV) -+ netif_device_detach(pegasus->net); -+ else if (status) { -+ pegasus->flags |= PEGASUS_RX_URB_FAIL; -+ tasklet_schedule(&pegasus->rx_tl); -+ } else { -+ pegasus->flags &= ~PEGASUS_RX_URB_FAIL; -+ } -+} -+ -+static void write_bulk_callback(struct urb *urb) -+{ -+ pegasus_t *pegasus = urb->context; -+ struct net_device *net; -+ int status = urb->status; -+ -+ if (!pegasus) -+ return; -+ -+ net = pegasus->net; -+ -+ if (!netif_device_present(net) || !netif_running(net)) -+ return; -+ -+ switch (status) { -+ case -EPIPE: -+ /* FIXME schedule_work() to clear the tx halt */ -+ netif_stop_queue(net); -+ netif_warn(pegasus, tx_err, net, "no tx stall recovery\n"); -+ return; -+ case -ENOENT: -+ case -ECONNRESET: -+ case -ESHUTDOWN: -+ netif_dbg(pegasus, ifdown, net, "tx unlink, %d\n", status); -+ return; -+ default: -+ netif_info(pegasus, tx_err, net, "TX status %d\n", status); -+ /* FALL THROUGH */ -+ case 0: -+ break; -+ } -+ -+ net->trans_start = jiffies; /* prevent tx timeout */ -+ netif_wake_queue(net); -+} -+ -+static void intr_callback(struct urb *urb) -+{ -+ pegasus_t *pegasus = urb->context; -+ struct net_device *net; -+ int res, status = urb->status; -+ -+ if (!pegasus) -+ return; -+ net = pegasus->net; -+ -+ switch (status) { -+ case 0: -+ break; -+ case -ECONNRESET: /* unlink */ -+ case -ENOENT: -+ case -ESHUTDOWN: -+ return; -+ default: -+ /* some Pegasus-I products report LOTS of data -+ * toggle errors... avoid log spamming -+ */ -+ netif_dbg(pegasus, timer, net, "intr status %d\n", status); -+ } -+ -+ if (urb->actual_length >= 6) { -+ u8 *d = urb->transfer_buffer; -+ -+ /* byte 0 == tx_status1, reg 2B */ -+ if (d[0] & (TX_UNDERRUN|EXCESSIVE_COL -+ |LATE_COL|JABBER_TIMEOUT)) { -+ pegasus->stats.tx_errors++; -+ if (d[0] & TX_UNDERRUN) -+ pegasus->stats.tx_fifo_errors++; -+ if (d[0] & (EXCESSIVE_COL | JABBER_TIMEOUT)) -+ pegasus->stats.tx_aborted_errors++; -+ if (d[0] & LATE_COL) -+ pegasus->stats.tx_window_errors++; -+ } -+ -+ /* d[5].LINK_STATUS lies on some adapters. -+ * d[0].NO_CARRIER kicks in only with failed TX. -+ * ... so monitoring with MII may be safest. -+ */ -+ -+ /* bytes 3-4 == rx_lostpkt, reg 2E/2F */ -+ pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4]; -+ } -+ -+ res = usb_submit_urb(urb, GFP_ATOMIC); -+ if (res == -ENODEV) -+ netif_device_detach(pegasus->net); -+ if (res) -+ netif_err(pegasus, timer, net, -+ "can't resubmit interrupt urb, %d\n", res); -+} -+ -+static void pegasus_tx_timeout(struct net_device *net) -+{ -+ pegasus_t *pegasus = netdev_priv(net); -+ netif_warn(pegasus, timer, net, "tx timeout\n"); -+ usb_unlink_urb(pegasus->tx_urb); -+ pegasus->stats.tx_errors++; -+} -+ -+static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb, -+ struct net_device *net) -+{ -+ pegasus_t *pegasus = netdev_priv(net); -+ int count = ((skb->len + 2) & 0x3f) ? skb->len + 2 : skb->len + 3; -+ int res; -+ __u16 l16 = skb->len; -+ -+ netif_stop_queue(net); -+ -+ ((__le16 *) pegasus->tx_buff)[0] = cpu_to_le16(l16); -+ skb_copy_from_linear_data(skb, pegasus->tx_buff + 2, skb->len); -+ usb_fill_bulk_urb(pegasus->tx_urb, pegasus->usb, -+ usb_sndbulkpipe(pegasus->usb, 2), -+ pegasus->tx_buff, count, -+ write_bulk_callback, pegasus); -+ if ((res = usb_submit_urb(pegasus->tx_urb, GFP_ATOMIC))) { -+ netif_warn(pegasus, tx_err, net, "fail tx, %d\n", res); -+ switch (res) { -+ case -EPIPE: /* stall, or disconnect from TT */ -+ /* cleanup should already have been scheduled */ -+ break; -+ case -ENODEV: /* disconnect() upcoming */ -+ case -EPERM: -+ netif_device_detach(pegasus->net); -+ break; -+ default: -+ pegasus->stats.tx_errors++; -+ netif_start_queue(net); -+ } -+ } else { -+ pegasus->stats.tx_packets++; -+ pegasus->stats.tx_bytes += skb->len; -+ } -+ dev_kfree_skb(skb); -+ -+ return NETDEV_TX_OK; -+} -+ -+static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev) -+{ -+ return &((pegasus_t *) netdev_priv(dev))->stats; -+} -+ -+static inline void disable_net_traffic(pegasus_t *pegasus) -+{ -+ __le16 tmp = cpu_to_le16(0); -+ -+ set_registers(pegasus, EthCtrl0, sizeof(tmp), &tmp); -+} -+ -+static inline void get_interrupt_interval(pegasus_t *pegasus) -+{ -+ u16 data; -+ u8 interval; -+ -+ read_eprom_word(pegasus, 4, &data); -+ interval = data >> 8; -+ if (pegasus->usb->speed != USB_SPEED_HIGH) { -+ if (interval < 0x80) { -+ netif_info(pegasus, timer, pegasus->net, -+ "intr interval changed from %ums to %ums\n", -+ interval, 0x80); -+ interval = 0x80; -+ data = (data & 0x00FF) | ((u16)interval << 8); -+#ifdef PEGASUS_WRITE_EEPROM -+ write_eprom_word(pegasus, 4, data); -+#endif -+ } -+ } -+ pegasus->intr_interval = interval; -+} -+ -+static void set_carrier(struct net_device *net) -+{ -+ pegasus_t *pegasus = netdev_priv(net); -+ u16 tmp; -+ -+ if (read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp)) -+ return; -+ -+ if (tmp & BMSR_LSTATUS) -+ netif_carrier_on(net); -+ else -+ netif_carrier_off(net); -+} -+ -+static void free_all_urbs(pegasus_t *pegasus) -+{ -+ usb_free_urb(pegasus->intr_urb); -+ usb_free_urb(pegasus->tx_urb); -+ usb_free_urb(pegasus->rx_urb); -+} -+ -+static void unlink_all_urbs(pegasus_t *pegasus) -+{ -+ usb_kill_urb(pegasus->intr_urb); -+ usb_kill_urb(pegasus->tx_urb); -+ usb_kill_urb(pegasus->rx_urb); -+} -+ -+static int alloc_urbs(pegasus_t *pegasus) -+{ -+ int res = -ENOMEM; -+ -+ pegasus->rx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!pegasus->rx_urb) { -+ return res; -+ } -+ pegasus->tx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!pegasus->tx_urb) { -+ usb_free_urb(pegasus->rx_urb); -+ return res; -+ } -+ pegasus->intr_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!pegasus->intr_urb) { -+ usb_free_urb(pegasus->tx_urb); -+ usb_free_urb(pegasus->rx_urb); -+ return res; -+ } -+ -+ return 0; -+} -+ -+static int pegasus_open(struct net_device *net) -+{ -+ pegasus_t *pegasus = netdev_priv(net); -+ int res=-ENOMEM; -+ -+ if (pegasus->rx_skb == NULL) -+ pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net, -+ PEGASUS_MTU, -+ GFP_KERNEL); -+ if (!pegasus->rx_skb) -+ goto exit; -+ -+ res = set_registers(pegasus, EthID, 6, net->dev_addr); -+ -+ usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, -+ usb_rcvbulkpipe(pegasus->usb, 1), -+ pegasus->rx_skb->data, PEGASUS_MTU + 8, -+ read_bulk_callback, pegasus); -+ if ((res = usb_submit_urb(pegasus->rx_urb, GFP_KERNEL))) { -+ if (res == -ENODEV) -+ netif_device_detach(pegasus->net); -+ netif_dbg(pegasus, ifup, net, "failed rx_urb, %d\n", res); -+ goto exit; -+ } -+ -+ usb_fill_int_urb(pegasus->intr_urb, pegasus->usb, -+ usb_rcvintpipe(pegasus->usb, 3), -+ pegasus->intr_buff, sizeof(pegasus->intr_buff), -+ intr_callback, pegasus, pegasus->intr_interval); -+ if ((res = usb_submit_urb(pegasus->intr_urb, GFP_KERNEL))) { -+ if (res == -ENODEV) -+ netif_device_detach(pegasus->net); -+ netif_dbg(pegasus, ifup, net, "failed intr_urb, %d\n", res); -+ usb_kill_urb(pegasus->rx_urb); -+ goto exit; -+ } -+ res = enable_net_traffic(net, pegasus->usb); -+ if (res < 0) { -+ netif_dbg(pegasus, ifup, net, -+ "can't enable_net_traffic() - %d\n", res); -+ res = -EIO; -+ usb_kill_urb(pegasus->rx_urb); -+ usb_kill_urb(pegasus->intr_urb); -+ goto exit; -+ } -+ set_carrier(net); -+ netif_start_queue(net); -+ netif_dbg(pegasus, ifup, net, "open\n"); -+ res = 0; -+exit: -+ return res; -+} -+ -+static int pegasus_close(struct net_device *net) -+{ -+ pegasus_t *pegasus = netdev_priv(net); -+ -+ netif_stop_queue(net); -+ if (!(pegasus->flags & PEGASUS_UNPLUG)) -+ disable_net_traffic(pegasus); -+ tasklet_kill(&pegasus->rx_tl); -+ unlink_all_urbs(pegasus); -+ -+ return 0; -+} -+ -+static void pegasus_get_drvinfo(struct net_device *dev, -+ struct ethtool_drvinfo *info) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ -+ strlcpy(info->driver, driver_name, sizeof(info->driver)); -+ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); -+ usb_make_path(pegasus->usb, info->bus_info, sizeof(info->bus_info)); -+} -+ -+/* also handles three patterns of some kind in hardware */ -+#define WOL_SUPPORTED (WAKE_MAGIC|WAKE_PHY) -+ -+static void -+pegasus_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ -+ wol->supported = WAKE_MAGIC | WAKE_PHY; -+ wol->wolopts = pegasus->wolopts; -+} -+ -+static int -+pegasus_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ u8 reg78 = 0x04; -+ int ret; -+ -+ if (wol->wolopts & ~WOL_SUPPORTED) -+ return -EINVAL; -+ -+ if (wol->wolopts & WAKE_MAGIC) -+ reg78 |= 0x80; -+ if (wol->wolopts & WAKE_PHY) -+ reg78 |= 0x40; -+ /* FIXME this 0x10 bit still needs to get set in the chip... */ -+ if (wol->wolopts) -+ pegasus->eth_regs[0] |= 0x10; -+ else -+ pegasus->eth_regs[0] &= ~0x10; -+ pegasus->wolopts = wol->wolopts; -+ -+ ret = set_register(pegasus, WakeupControl, reg78); -+ if (!ret) -+ ret = device_set_wakeup_enable(&pegasus->usb->dev, -+ wol->wolopts); -+ return ret; -+} -+ -+static inline void pegasus_reset_wol(struct net_device *dev) -+{ -+ struct ethtool_wolinfo wol; -+ -+ memset(&wol, 0, sizeof wol); -+ (void) pegasus_set_wol(dev, &wol); -+} -+ -+static int -+pegasus_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) -+{ -+ pegasus_t *pegasus; -+ -+ pegasus = netdev_priv(dev); -+ mii_ethtool_gset(&pegasus->mii, ecmd); -+ return 0; -+} -+ -+static int -+pegasus_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ return mii_ethtool_sset(&pegasus->mii, ecmd); -+} -+ -+static int pegasus_nway_reset(struct net_device *dev) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ return mii_nway_restart(&pegasus->mii); -+} -+ -+static u32 pegasus_get_link(struct net_device *dev) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ return mii_link_ok(&pegasus->mii); -+} -+ -+static u32 pegasus_get_msglevel(struct net_device *dev) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ return pegasus->msg_enable; -+} -+ -+static void pegasus_set_msglevel(struct net_device *dev, u32 v) -+{ -+ pegasus_t *pegasus = netdev_priv(dev); -+ pegasus->msg_enable = v; -+} -+ -+static const struct ethtool_ops ops = { -+ .get_drvinfo = pegasus_get_drvinfo, -+ .get_settings = pegasus_get_settings, -+ .set_settings = pegasus_set_settings, -+ .nway_reset = pegasus_nway_reset, -+ .get_link = pegasus_get_link, -+ .get_msglevel = pegasus_get_msglevel, -+ .set_msglevel = pegasus_set_msglevel, -+ .get_wol = pegasus_get_wol, -+ .set_wol = pegasus_set_wol, -+}; -+ -+static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd) -+{ -+ __u16 *data = (__u16 *) &rq->ifr_ifru; -+ pegasus_t *pegasus = netdev_priv(net); -+ int res; -+ -+ switch (cmd) { -+ case SIOCDEVPRIVATE: -+ data[0] = pegasus->phy; -+ case SIOCDEVPRIVATE + 1: -+ read_mii_word(pegasus, data[0], data[1] & 0x1f, &data[3]); -+ res = 0; -+ break; -+ case SIOCDEVPRIVATE + 2: -+ if (!capable(CAP_NET_ADMIN)) -+ return -EPERM; -+ write_mii_word(pegasus, pegasus->phy, data[1] & 0x1f, &data[2]); -+ res = 0; -+ break; -+ default: -+ res = -EOPNOTSUPP; -+ } -+ return res; -+} -+ -+static void pegasus_set_multicast(struct net_device *net) -+{ -+ pegasus_t *pegasus = netdev_priv(net); -+ -+ if (net->flags & IFF_PROMISC) { -+ pegasus->eth_regs[EthCtrl2] |= RX_PROMISCUOUS; -+ netif_info(pegasus, link, net, "Promiscuous mode enabled\n"); -+ } else if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI)) { -+ pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST; -+ pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; -+ netif_dbg(pegasus, link, net, "set allmulti\n"); -+ } else { -+ pegasus->eth_regs[EthCtrl0] &= ~RX_MULTICAST; -+ pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; -+ } -+ update_eth_regs_async(pegasus); -+} -+ -+static __u8 mii_phy_probe(pegasus_t *pegasus) -+{ -+ int i; -+ __u16 tmp; -+ -+ for (i = 0; i < 32; i++) { -+ read_mii_word(pegasus, i, MII_BMSR, &tmp); -+ if (tmp == 0 || tmp == 0xffff || (tmp & BMSR_MEDIA) == 0) -+ continue; -+ else -+ return i; -+ } -+ -+ return 0xff; -+} -+ -+static inline void setup_pegasus_II(pegasus_t *pegasus) -+{ -+ __u8 data = 0xa5; -+ -+ set_register(pegasus, Reg1d, 0); -+ set_register(pegasus, Reg7b, 1); -+ mdelay(100); -+ if ((pegasus->features & HAS_HOME_PNA) && mii_mode) -+ set_register(pegasus, Reg7b, 0); -+ else -+ set_register(pegasus, Reg7b, 2); -+ -+ set_register(pegasus, 0x83, data); -+ get_registers(pegasus, 0x83, 1, &data); -+ -+ if (data == 0xa5) -+ pegasus->chip = 0x8513; -+ else -+ pegasus->chip = 0; -+ -+ set_register(pegasus, 0x80, 0xc0); -+ set_register(pegasus, 0x83, 0xff); -+ set_register(pegasus, 0x84, 0x01); -+ -+ if (pegasus->features & HAS_HOME_PNA && mii_mode) -+ set_register(pegasus, Reg81, 6); -+ else -+ set_register(pegasus, Reg81, 2); -+} -+ -+ -+static int pegasus_count; -+static struct workqueue_struct *pegasus_workqueue; -+#define CARRIER_CHECK_DELAY (2 * HZ) -+ -+static void check_carrier(struct work_struct *work) -+{ -+ pegasus_t *pegasus = container_of(work, pegasus_t, carrier_check.work); -+ set_carrier(pegasus->net); -+ if (!(pegasus->flags & PEGASUS_UNPLUG)) { -+ queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, -+ CARRIER_CHECK_DELAY); -+ } -+} -+ -+static int pegasus_blacklisted(struct usb_device *udev) -+{ -+ struct usb_device_descriptor *udd = &udev->descriptor; -+ -+ /* Special quirk to keep the driver from handling the Belkin Bluetooth -+ * dongle which happens to have the same ID. -+ */ -+ if ((udd->idVendor == cpu_to_le16(VENDOR_BELKIN)) && -+ (udd->idProduct == cpu_to_le16(0x0121)) && -+ (udd->bDeviceClass == USB_CLASS_WIRELESS_CONTROLLER) && -+ (udd->bDeviceProtocol == 1)) -+ return 1; -+ -+ return 0; -+} -+ -+/* we rely on probe() and remove() being serialized so we -+ * don't need extra locking on pegasus_count. -+ */ -+static void pegasus_dec_workqueue(void) -+{ -+ pegasus_count--; -+ if (pegasus_count == 0) { -+ destroy_workqueue(pegasus_workqueue); -+ pegasus_workqueue = NULL; -+ } -+} -+ -+static int pegasus_probe(struct usb_interface *intf, -+ const struct usb_device_id *id) -+{ -+ struct usb_device *dev = interface_to_usbdev(intf); -+ struct net_device *net; -+ pegasus_t *pegasus; -+ int dev_index = id - pegasus_ids; -+ int res = -ENOMEM; -+ -+ if (pegasus_blacklisted(dev)) -+ return -ENODEV; -+ -+ if (pegasus_count == 0) { -+ pegasus_workqueue = create_singlethread_workqueue("pegasus"); -+ if (!pegasus_workqueue) -+ return -ENOMEM; -+ } -+ pegasus_count++; -+ -+ net = alloc_etherdev(sizeof(struct pegasus)); -+ if (!net) -+ goto out; -+ -+ pegasus = netdev_priv(net); -+ pegasus->dev_index = dev_index; -+ -+ res = alloc_urbs(pegasus); -+ if (res < 0) { -+ dev_err(&intf->dev, "can't allocate %s\n", "urbs"); -+ goto out1; -+ } -+ -+ tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus); -+ -+ INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier); -+ -+ pegasus->intf = intf; -+ pegasus->usb = dev; -+ pegasus->net = net; -+ -+ -+ net->watchdog_timeo = PEGASUS_TX_TIMEOUT; -+ net->netdev_ops = &pegasus_netdev_ops; -+ net->ethtool_ops = &ops; -+ pegasus->mii.dev = net; -+ pegasus->mii.mdio_read = mdio_read; -+ pegasus->mii.mdio_write = mdio_write; -+ pegasus->mii.phy_id_mask = 0x1f; -+ pegasus->mii.reg_num_mask = 0x1f; -+ pegasus->msg_enable = netif_msg_init(msg_level, NETIF_MSG_DRV -+ | NETIF_MSG_PROBE | NETIF_MSG_LINK); -+ -+ pegasus->features = usb_dev_id[dev_index].private; -+ get_interrupt_interval(pegasus); -+ if (reset_mac(pegasus)) { -+ dev_err(&intf->dev, "can't reset MAC\n"); -+ res = -EIO; -+ goto out2; -+ } -+ set_ethernet_addr(pegasus); -+ if (pegasus->features & PEGASUS_II) { -+ dev_info(&intf->dev, "setup Pegasus II specific registers\n"); -+ setup_pegasus_II(pegasus); -+ } -+ pegasus->phy = mii_phy_probe(pegasus); -+ if (pegasus->phy == 0xff) { -+ dev_warn(&intf->dev, "can't locate MII phy, using default\n"); -+ pegasus->phy = 1; -+ } -+ pegasus->mii.phy_id = pegasus->phy; -+ usb_set_intfdata(intf, pegasus); -+ SET_NETDEV_DEV(net, &intf->dev); -+ pegasus_reset_wol(net); -+ res = register_netdev(net); -+ if (res) -+ goto out3; -+ queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, -+ CARRIER_CHECK_DELAY); -+ dev_info(&intf->dev, "%s, %s, %pM\n", net->name, -+ usb_dev_id[dev_index].name, net->dev_addr); -+ return 0; -+ -+out3: -+ usb_set_intfdata(intf, NULL); -+out2: -+ free_all_urbs(pegasus); -+out1: -+ free_netdev(net); -+out: -+ pegasus_dec_workqueue(); -+ return res; -+} -+ -+static void pegasus_disconnect(struct usb_interface *intf) -+{ -+ struct pegasus *pegasus = usb_get_intfdata(intf); -+ -+ usb_set_intfdata(intf, NULL); -+ if (!pegasus) { -+ dev_dbg(&intf->dev, "unregistering non-bound device?\n"); -+ return; -+ } -+ -+ pegasus->flags |= PEGASUS_UNPLUG; -+ cancel_delayed_work(&pegasus->carrier_check); -+ unregister_netdev(pegasus->net); -+ unlink_all_urbs(pegasus); -+ free_all_urbs(pegasus); -+ if (pegasus->rx_skb != NULL) { -+ dev_kfree_skb(pegasus->rx_skb); -+ pegasus->rx_skb = NULL; -+ } -+ free_netdev(pegasus->net); -+ pegasus_dec_workqueue(); -+} -+ -+static int pegasus_suspend(struct usb_interface *intf, pm_message_t message) -+{ -+ struct pegasus *pegasus = usb_get_intfdata(intf); -+ -+ netif_device_detach(pegasus->net); -+ cancel_delayed_work(&pegasus->carrier_check); -+ if (netif_running(pegasus->net)) { -+ usb_kill_urb(pegasus->rx_urb); -+ usb_kill_urb(pegasus->intr_urb); -+ } -+ return 0; -+} -+ -+static int pegasus_resume(struct usb_interface *intf) -+{ -+ struct pegasus *pegasus = usb_get_intfdata(intf); -+ -+ netif_device_attach(pegasus->net); -+ if (netif_running(pegasus->net)) { -+ pegasus->rx_urb->status = 0; -+ pegasus->rx_urb->actual_length = 0; -+ read_bulk_callback(pegasus->rx_urb); -+ -+ pegasus->intr_urb->status = 0; -+ pegasus->intr_urb->actual_length = 0; -+ intr_callback(pegasus->intr_urb); -+ } -+ queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, -+ CARRIER_CHECK_DELAY); -+ return 0; -+} -+ -+static const struct net_device_ops pegasus_netdev_ops = { -+ .ndo_open = pegasus_open, -+ .ndo_stop = pegasus_close, -+ .ndo_do_ioctl = pegasus_ioctl, -+ .ndo_start_xmit = pegasus_start_xmit, -+ .ndo_set_rx_mode = pegasus_set_multicast, -+ .ndo_get_stats = pegasus_netdev_stats, -+ .ndo_tx_timeout = pegasus_tx_timeout, -+ .ndo_change_mtu = eth_change_mtu, -+ .ndo_set_mac_address = eth_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+}; -+ -+static struct usb_driver pegasus_driver = { -+ .name = driver_name, -+ .probe = pegasus_probe, -+ .disconnect = pegasus_disconnect, -+ .id_table = pegasus_ids, -+ .suspend = pegasus_suspend, -+ .resume = pegasus_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+static void __init parse_id(char *id) -+{ -+ unsigned int vendor_id = 0, device_id = 0, flags = 0, i = 0; -+ char *token, *name = NULL; -+ -+ if ((token = strsep(&id, ":")) != NULL) -+ name = token; -+ /* name now points to a null terminated string*/ -+ if ((token = strsep(&id, ":")) != NULL) -+ vendor_id = simple_strtoul(token, NULL, 16); -+ if ((token = strsep(&id, ":")) != NULL) -+ device_id = simple_strtoul(token, NULL, 16); -+ flags = simple_strtoul(id, NULL, 16); -+ pr_info("%s: new device %s, vendor ID 0x%04x, device ID 0x%04x, flags: 0x%x\n", -+ driver_name, name, vendor_id, device_id, flags); -+ -+ if (vendor_id > 0x10000 || vendor_id == 0) -+ return; -+ if (device_id > 0x10000 || device_id == 0) -+ return; -+ -+ for (i = 0; usb_dev_id[i].name; i++); -+ usb_dev_id[i].name = name; -+ usb_dev_id[i].vendor = vendor_id; -+ usb_dev_id[i].device = device_id; -+ usb_dev_id[i].private = flags; -+ pegasus_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE; -+ pegasus_ids[i].idVendor = vendor_id; -+ pegasus_ids[i].idProduct = device_id; -+} -+ -+static int __init pegasus_init(void) -+{ -+ pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION); -+ if (devid) -+ parse_id(devid); -+ return usb_register(&pegasus_driver); -+} -+ -+static void __exit pegasus_exit(void) -+{ -+ usb_deregister(&pegasus_driver); -+} -+ -+module_init(pegasus_init); -+module_exit(pegasus_exit); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/pegasus.h backports-3.18.1-1/drivers/net/usb/pegasus.h ---- backports-3.18.1-1.org/drivers/net/usb/pegasus.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/pegasus.h 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,308 @@ -+/* -+ * Copyright (c) 1999-2013 Petko Manolov (petkan@nucleusys.com) -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License version 2 as published -+ * by the Free Software Foundation. -+ */ -+ -+ -+#ifndef PEGASUS_DEV -+ -+#define PEGASUS_II 0x80000000 -+#define HAS_HOME_PNA 0x40000000 -+ -+#define PEGASUS_MTU 1536 -+ -+#define EPROM_WRITE 0x01 -+#define EPROM_READ 0x02 -+#define EPROM_DONE 0x04 -+#define EPROM_WR_ENABLE 0x10 -+#define EPROM_LOAD 0x20 -+ -+#define PHY_DONE 0x80 -+#define PHY_READ 0x40 -+#define PHY_WRITE 0x20 -+#define DEFAULT_GPIO_RESET 0x24 -+#define DEFAULT_GPIO_SET 0x26 -+ -+#define PEGASUS_PRESENT 0x00000001 -+#define PEGASUS_TX_BUSY 0x00000004 -+#define PEGASUS_RX_BUSY 0x00000008 -+#define CTRL_URB_RUNNING 0x00000010 -+#define CTRL_URB_SLEEP 0x00000020 -+#define PEGASUS_UNPLUG 0x00000040 -+#define PEGASUS_RX_URB_FAIL 0x00000080 -+ -+#define RX_MULTICAST 2 -+#define RX_PROMISCUOUS 4 -+ -+#define REG_TIMEOUT (HZ) -+#define PEGASUS_TX_TIMEOUT (HZ*10) -+ -+#define TX_UNDERRUN 0x80 -+#define EXCESSIVE_COL 0x40 -+#define LATE_COL 0x20 -+#define NO_CARRIER 0x10 -+#define LOSS_CARRIER 0x08 -+#define JABBER_TIMEOUT 0x04 -+ -+#define LINK_STATUS 0x01 -+ -+#define PEGASUS_REQT_READ 0xc0 -+#define PEGASUS_REQT_WRITE 0x40 -+#define PEGASUS_REQ_GET_REGS 0xf0 -+#define PEGASUS_REQ_SET_REGS 0xf1 -+#define PEGASUS_REQ_SET_REG PEGASUS_REQ_SET_REGS -+ -+enum pegasus_registers { -+ EthCtrl0 = 0, -+ EthCtrl1 = 1, -+ EthCtrl2 = 2, -+ EthID = 0x10, -+ Reg1d = 0x1d, -+ EpromOffset = 0x20, -+ EpromData = 0x21, /* 0x21 low, 0x22 high byte */ -+ EpromCtrl = 0x23, -+ PhyAddr = 0x25, -+ PhyData = 0x26, /* 0x26 low, 0x27 high byte */ -+ PhyCtrl = 0x28, -+ UsbStst = 0x2a, -+ EthTxStat0 = 0x2b, -+ EthTxStat1 = 0x2c, -+ EthRxStat = 0x2d, -+ WakeupControl = 0x78, -+ Reg7b = 0x7b, -+ Gpio0 = 0x7e, -+ Gpio1 = 0x7f, -+ Reg81 = 0x81, -+}; -+ -+ -+typedef struct pegasus { -+ struct usb_device *usb; -+ struct usb_interface *intf; -+ struct net_device *net; -+ struct net_device_stats stats; -+ struct mii_if_info mii; -+ unsigned flags; -+ unsigned features; -+ u32 msg_enable; -+ u32 wolopts; -+ int dev_index; -+ int intr_interval; -+ struct tasklet_struct rx_tl; -+ struct delayed_work carrier_check; -+ struct urb *rx_urb, *tx_urb, *intr_urb; -+ struct sk_buff *rx_skb; -+ int chip; -+ unsigned char intr_buff[8]; -+ __u8 tx_buff[PEGASUS_MTU]; -+ __u8 eth_regs[4]; -+ __u8 phy; -+ __u8 gpio_res; -+} pegasus_t; -+ -+ -+struct usb_eth_dev { -+ char *name; -+ __u16 vendor; -+ __u16 device; -+ __u32 private; /* LSB is gpio reset value */ -+}; -+ -+#define VENDOR_3COM 0x0506 -+#define VENDOR_ABOCOM 0x07b8 -+#define VENDOR_ACCTON 0x083a -+#define VENDOR_ADMTEK 0x07a6 -+#define VENDOR_AEILAB 0x3334 -+#define VENDOR_ALLIEDTEL 0x07c9 -+#define VENDOR_ATEN 0x0557 -+#define VENDOR_BELKIN 0x050d -+#define VENDOR_BILLIONTON 0x08dd -+#define VENDOR_COMPAQ 0x049f -+#define VENDOR_COREGA 0x07aa -+#define VENDOR_DLINK 0x2001 -+#define VENDOR_ELCON 0x0db7 -+#define VENDOR_ELECOM 0x056e -+#define VENDOR_ELSA 0x05cc -+#define VENDOR_GIGABYTE 0x1044 -+#define VENDOR_HAWKING 0x0e66 -+#define VENDOR_HP 0x03f0 -+#define VENDOR_IODATA 0x04bb -+#define VENDOR_KINGSTON 0x0951 -+#define VENDOR_LANEED 0x056e -+#define VENDOR_LINKSYS 0x066b -+#define VENDOR_LINKSYS2 0x077b -+#define VENDOR_MELCO 0x0411 -+#define VENDOR_MICROSOFT 0x045e -+#define VENDOR_MOBILITY 0x1342 -+#define VENDOR_NETGEAR 0x0846 -+#define VENDOR_OCT 0x0b39 -+#define VENDOR_SMARTBRIDGES 0x08d1 -+#define VENDOR_SMC 0x0707 -+#define VENDOR_SOHOWARE 0x15e8 -+#define VENDOR_SIEMENS 0x067c -+ -+ -+#else /* PEGASUS_DEV */ -+ -+PEGASUS_DEV("3Com USB Ethernet 3C460B", VENDOR_3COM, 0x4601, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("ATEN USB Ethernet UC-110T", VENDOR_ATEN, 0x2007, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("USB HPNA/Ethernet", VENDOR_ABOCOM, 0x110c, -+ DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA) -+PEGASUS_DEV("USB HPNA/Ethernet", VENDOR_ABOCOM, 0x4104, -+ DEFAULT_GPIO_RESET | HAS_HOME_PNA) -+PEGASUS_DEV("USB HPNA/Ethernet", VENDOR_ABOCOM, 0x4004, -+ DEFAULT_GPIO_RESET | HAS_HOME_PNA) -+PEGASUS_DEV("USB HPNA/Ethernet", VENDOR_ABOCOM, 0x4007, -+ DEFAULT_GPIO_RESET | HAS_HOME_PNA) -+PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x4102, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x4002, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x400b, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x400c, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0xabc1, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x200c, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Accton USB 10/100 Ethernet Adapter", VENDOR_ACCTON, 0x1046, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Philips USB 10/100 Ethernet", VENDOR_ACCTON, 0xb004, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("ADMtek ADM8511 "Pegasus II" USB Ethernet", -+ VENDOR_ADMTEK, 0x8511, -+ DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA) -+PEGASUS_DEV("ADMtek ADM8513 "Pegasus II" USB Ethernet", -+ VENDOR_ADMTEK, 0x8513, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("ADMtek ADM8515 "Pegasus II" USB-2.0 Ethernet", -+ VENDOR_ADMTEK, 0x8515, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("ADMtek AN986 "Pegasus" USB Ethernet (evaluation board)", -+ VENDOR_ADMTEK, 0x0986, -+ DEFAULT_GPIO_RESET | HAS_HOME_PNA) -+PEGASUS_DEV("AN986A USB MAC", VENDOR_ADMTEK, 1986, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("AEI USB Fast Ethernet Adapter", VENDOR_AEILAB, 0x1701, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+/* -+ * Distinguish between this Belkin adaptor and the Belkin bluetooth adaptors -+ * with the same product IDs by checking the device class too. -+ */ -+PEGASUS_DEV_CLASS("Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, 0x00, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Belkin F5U122 10/100 USB Ethernet", VENDOR_BELKIN, 0x0122, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Billionton USB-100", VENDOR_BILLIONTON, 0x0986, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("Billionton USBLP-100", VENDOR_BILLIONTON, 0x0987, -+ DEFAULT_GPIO_RESET | HAS_HOME_PNA) -+PEGASUS_DEV("iPAQ Networking 10/100 USB", VENDOR_COMPAQ, 0x8511, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Billionton USBEL-100", VENDOR_BILLIONTON, 0x0988, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("Billionton USBE-100", VENDOR_BILLIONTON, 0x8511, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Corega FEther USB-TX", VENDOR_COREGA, 0x0004, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("Corega FEther USB-TXS", VENDOR_COREGA, 0x000d, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x4001, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x4002, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x4102, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x400b, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x200c, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("D-Link DSB-650TX(PNA)", VENDOR_DLINK, 0x4003, -+ DEFAULT_GPIO_RESET | HAS_HOME_PNA) -+PEGASUS_DEV("D-Link DSB-650", VENDOR_DLINK, 0xabc1, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("GOLDPFEIL USB Adapter", VENDOR_ELCON, 0x0002, -+ DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA) -+PEGASUS_DEV("ELECOM USB Ethernet LD-USB20", VENDOR_ELECOM, 0x4010, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("EasiDock Ethernet", VENDOR_MOBILITY, 0x0304, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("Elsa Micolink USB2Ethernet", VENDOR_ELSA, 0x3000, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("GIGABYTE GN-BR402W Wireless Router", VENDOR_GIGABYTE, 0x8002, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("Hawking UF100 10/100 Ethernet", VENDOR_HAWKING, 0x400c, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("HP hn210c Ethernet USB", VENDOR_HP, 0x811c, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("IO DATA USB ET/TX", VENDOR_IODATA, 0x0904, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("IO DATA USB ETX-US2", VENDOR_IODATA, 0x093a, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Kingston KNU101TX Ethernet", VENDOR_KINGSTON, 0x000a, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x4002, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("LANEED USB Ethernet LD-USBL/TX", VENDOR_LANEED, 0x4005, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x400b, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("LANEED USB Ethernet LD-USB/T", VENDOR_LANEED, 0xabc1, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x200c, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Linksys USB10TX", VENDOR_LINKSYS, 0x2202, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("Linksys USB100TX", VENDOR_LINKSYS, 0x2203, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("Linksys USB100TX", VENDOR_LINKSYS, 0x2204, -+ DEFAULT_GPIO_RESET | HAS_HOME_PNA) -+PEGASUS_DEV("Linksys USB10T Ethernet Adapter", VENDOR_LINKSYS, 0x2206, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Linksys USBVPN1", VENDOR_LINKSYS2, 0x08b4, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("Linksys USB USB100TX", VENDOR_LINKSYS, 0x400b, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Linksys USB10TX", VENDOR_LINKSYS, 0x200c, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("MELCO/BUFFALO LUA-TX", VENDOR_MELCO, 0x0001, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("MELCO/BUFFALO LUA-TX", VENDOR_MELCO, 0x0005, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("MELCO/BUFFALO LUA2-TX", VENDOR_MELCO, 0x0009, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("Microsoft MN-110", VENDOR_MICROSOFT, 0x007a, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("NETGEAR FA101", VENDOR_NETGEAR, 0x1020, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("OCT Inc.", VENDOR_OCT, 0x0109, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("OCT USB TO Ethernet", VENDOR_OCT, 0x0901, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("smartNIC 2 PnP Adapter", VENDOR_SMARTBRIDGES, 0x0003, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("SMC 202 USB Ethernet", VENDOR_SMC, 0x0200, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("SMC 2206 USB Ethernet", VENDOR_SMC, 0x0201, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("SOHOware NUB100 Ethernet", VENDOR_SOHOWARE, 0x9100, -+ DEFAULT_GPIO_RESET) -+PEGASUS_DEV("SOHOware NUB110 Ethernet", VENDOR_SOHOWARE, 0x9110, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+PEGASUS_DEV("SpeedStream USB 10/100 Ethernet", VENDOR_SIEMENS, 0x1001, -+ DEFAULT_GPIO_RESET | PEGASUS_II) -+ -+ -+#endif /* PEGASUS_DEV */ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/plusb.c backports-3.18.1-1/drivers/net/usb/plusb.c ---- backports-3.18.1-1.org/drivers/net/usb/plusb.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/plusb.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,157 @@ -+/* -+ * PL-2301/2302 USB host-to-host link cables -+ * Copyright (C) 2000-2005 by David Brownell -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+// #define DEBUG // error path messages, extra info -+// #define VERBOSE // more; success messages -+ -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/usb/usbnet.h> -+ -+ -+/* -+ * Prolific PL-2301/PL-2302 driver ... http://www.prolific.com.tw/ -+ * -+ * The protocol and handshaking used here should be bug-compatible -+ * with the Linux 2.2 "plusb" driver, by Deti Fliegl. -+ * -+ * HEADS UP: this handshaking isn't all that robust. This driver -+ * gets confused easily if you unplug one end of the cable then -+ * try to connect it again; you'll need to restart both ends. The -+ * "naplink" software (used by some PlayStation/2 deveopers) does -+ * the handshaking much better! Also, sometimes this hardware -+ * seems to get wedged under load. Prolific docs are weak, and -+ * don't identify differences between PL2301 and PL2302, much less -+ * anything to explain the different PL2302 versions observed. -+ * -+ * NOTE: pl2501 has several modes, including pl2301 and pl2302 -+ * compatibility. Some docs suggest the difference between 2301 -+ * and 2302 is only to make MS-Windows use a different driver... -+ * -+ * pl25a1 glue based on patch from Tony Gibbs. Prolific "docs" on -+ * this chip are as usual incomplete about what control messages -+ * are supported. -+ */ -+ -+/* -+ * Bits 0-4 can be used for software handshaking; they're set from -+ * one end, cleared from the other, "read" with the interrupt byte. -+ */ -+#define PL_S_EN (1<<7) /* (feature only) suspend enable */ -+/* reserved bit -- rx ready (6) ? */ -+#define PL_TX_READY (1<<5) /* (interrupt only) transmit ready */ -+#define PL_RESET_OUT (1<<4) /* reset output pipe */ -+#define PL_RESET_IN (1<<3) /* reset input pipe */ -+#define PL_TX_C (1<<2) /* transmission complete */ -+#define PL_TX_REQ (1<<1) /* transmission received */ -+#define PL_PEER_E (1<<0) /* peer exists */ -+ -+static inline int -+pl_vendor_req(struct usbnet *dev, u8 req, u8 val, u8 index) -+{ -+ return usbnet_read_cmd(dev, req, -+ USB_DIR_IN | USB_TYPE_VENDOR | -+ USB_RECIP_DEVICE, -+ val, index, NULL, 0); -+} -+ -+static inline int -+pl_clear_QuickLink_features(struct usbnet *dev, int val) -+{ -+ return pl_vendor_req(dev, 1, (u8) val, 0); -+} -+ -+static inline int -+pl_set_QuickLink_features(struct usbnet *dev, int val) -+{ -+ return pl_vendor_req(dev, 3, (u8) val, 0); -+} -+ -+static int pl_reset(struct usbnet *dev) -+{ -+ int status; -+ -+ /* some units seem to need this reset, others reject it utterly. -+ * FIXME be more like "naplink" or windows drivers. -+ */ -+ status = pl_set_QuickLink_features(dev, -+ PL_S_EN|PL_RESET_OUT|PL_RESET_IN|PL_PEER_E); -+ if (status != 0 && netif_msg_probe(dev)) -+ netif_dbg(dev, link, dev->net, "pl_reset --> %d\n", status); -+ return 0; -+} -+ -+static const struct driver_info prolific_info = { -+ .description = "Prolific PL-2301/PL-2302/PL-25A1", -+ .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT, -+ /* some PL-2302 versions seem to fail usb_set_interface() */ -+ .reset = pl_reset, -+}; -+ -+ -+/*-------------------------------------------------------------------------*/ -+ -+/* -+ * Proilific's name won't normally be on the cables, and -+ * may not be on the device. -+ */ -+ -+static const struct usb_device_id products [] = { -+ -+/* full speed cables */ -+{ -+ USB_DEVICE(0x067b, 0x0000), // PL-2301 -+ .driver_info = (unsigned long) &prolific_info, -+}, { -+ USB_DEVICE(0x067b, 0x0001), // PL-2302 -+ .driver_info = (unsigned long) &prolific_info, -+}, -+ -+/* high speed cables */ -+{ -+ USB_DEVICE(0x067b, 0x25a1), /* PL-25A1, no eeprom */ -+ .driver_info = (unsigned long) &prolific_info, -+}, { -+ USB_DEVICE(0x050d, 0x258a), /* Belkin F5U258/F5U279 (PL-25A1) */ -+ .driver_info = (unsigned long) &prolific_info, -+}, -+ -+ { }, // END -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver plusb_driver = { -+ .name = "plusb", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(plusb_driver); -+ -+MODULE_AUTHOR("David Brownell"); -+MODULE_DESCRIPTION("Prolific PL-2301/2302/25A1 USB Host to Host Link Driver"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/r8152.c backports-3.18.1-1/drivers/net/usb/r8152.c ---- backports-3.18.1-1.org/drivers/net/usb/r8152.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/r8152.c 2015-01-03 13:42:25.000000000 +0100 -@@ -0,0 +1,3913 @@ -+/* -+ * Copyright (c) 2014 Realtek Semiconductor Corp. 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 as published by the Free Software Foundation. -+ * -+ */ -+ -+#include <linux/signal.h> -+#include <linux/slab.h> -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/mii.h> -+#include <linux/ethtool.h> -+#include <linux/usb.h> -+#include <linux/crc32.h> -+#include <linux/if_vlan.h> -+#include <linux/uaccess.h> -+#include <linux/list.h> -+#include <linux/ip.h> -+#include <linux/ipv6.h> -+#include <net/ip6_checksum.h> -+#include <uapi/linux/mdio.h> -+#include <linux/mdio.h> -+ -+/* Version Information */ -+#define DRIVER_VERSION "v1.07.0 (2014/10/09)" -+#define DRIVER_AUTHOR "Realtek linux nic maintainers nic_swsd@realtek.com" -+#define DRIVER_DESC "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters" -+#define MODULENAME "r8152" -+ -+#define R8152_PHY_ID 32 -+ -+#define PLA_IDR 0xc000 -+#define PLA_RCR 0xc010 -+#define PLA_RMS 0xc016 -+#define PLA_RXFIFO_CTRL0 0xc0a0 -+#define PLA_RXFIFO_CTRL1 0xc0a4 -+#define PLA_RXFIFO_CTRL2 0xc0a8 -+#define PLA_FMC 0xc0b4 -+#define PLA_CFG_WOL 0xc0b6 -+#define PLA_TEREDO_CFG 0xc0bc -+#define PLA_MAR 0xcd00 -+#define PLA_BACKUP 0xd000 -+#define PAL_BDC_CR 0xd1a0 -+#define PLA_TEREDO_TIMER 0xd2cc -+#define PLA_REALWOW_TIMER 0xd2e8 -+#define PLA_LEDSEL 0xdd90 -+#define PLA_LED_FEATURE 0xdd92 -+#define PLA_PHYAR 0xde00 -+#define PLA_BOOT_CTRL 0xe004 -+#define PLA_GPHY_INTR_IMR 0xe022 -+#define PLA_EEE_CR 0xe040 -+#define PLA_EEEP_CR 0xe080 -+#define PLA_MAC_PWR_CTRL 0xe0c0 -+#define PLA_MAC_PWR_CTRL2 0xe0ca -+#define PLA_MAC_PWR_CTRL3 0xe0cc -+#define PLA_MAC_PWR_CTRL4 0xe0ce -+#define PLA_WDT6_CTRL 0xe428 -+#define PLA_TCR0 0xe610 -+#define PLA_TCR1 0xe612 -+#define PLA_MTPS 0xe615 -+#define PLA_TXFIFO_CTRL 0xe618 -+#define PLA_RSTTALLY 0xe800 -+#define PLA_CR 0xe813 -+#define PLA_CRWECR 0xe81c -+#define PLA_CONFIG12 0xe81e /* CONFIG1, CONFIG2 */ -+#define PLA_CONFIG34 0xe820 /* CONFIG3, CONFIG4 */ -+#define PLA_CONFIG5 0xe822 -+#define PLA_PHY_PWR 0xe84c -+#define PLA_OOB_CTRL 0xe84f -+#define PLA_CPCR 0xe854 -+#define PLA_MISC_0 0xe858 -+#define PLA_MISC_1 0xe85a -+#define PLA_OCP_GPHY_BASE 0xe86c -+#define PLA_TALLYCNT 0xe890 -+#define PLA_SFF_STS_7 0xe8de -+#define PLA_PHYSTATUS 0xe908 -+#define PLA_BP_BA 0xfc26 -+#define PLA_BP_0 0xfc28 -+#define PLA_BP_1 0xfc2a -+#define PLA_BP_2 0xfc2c -+#define PLA_BP_3 0xfc2e -+#define PLA_BP_4 0xfc30 -+#define PLA_BP_5 0xfc32 -+#define PLA_BP_6 0xfc34 -+#define PLA_BP_7 0xfc36 -+#define PLA_BP_EN 0xfc38 -+ -+#define USB_U2P3_CTRL 0xb460 -+#define USB_DEV_STAT 0xb808 -+#define USB_USB_CTRL 0xd406 -+#define USB_PHY_CTRL 0xd408 -+#define USB_TX_AGG 0xd40a -+#define USB_RX_BUF_TH 0xd40c -+#define USB_USB_TIMER 0xd428 -+#define USB_RX_EARLY_AGG 0xd42c -+#define USB_PM_CTRL_STATUS 0xd432 -+#define USB_TX_DMA 0xd434 -+#define USB_TOLERANCE 0xd490 -+#define USB_LPM_CTRL 0xd41a -+#define USB_UPS_CTRL 0xd800 -+#define USB_MISC_0 0xd81a -+#define USB_POWER_CUT 0xd80a -+#define USB_AFE_CTRL2 0xd824 -+#define USB_WDT11_CTRL 0xe43c -+#define USB_BP_BA 0xfc26 -+#define USB_BP_0 0xfc28 -+#define USB_BP_1 0xfc2a -+#define USB_BP_2 0xfc2c -+#define USB_BP_3 0xfc2e -+#define USB_BP_4 0xfc30 -+#define USB_BP_5 0xfc32 -+#define USB_BP_6 0xfc34 -+#define USB_BP_7 0xfc36 -+#define USB_BP_EN 0xfc38 -+ -+/* OCP Registers */ -+#define OCP_ALDPS_CONFIG 0x2010 -+#define OCP_EEE_CONFIG1 0x2080 -+#define OCP_EEE_CONFIG2 0x2092 -+#define OCP_EEE_CONFIG3 0x2094 -+#define OCP_BASE_MII 0xa400 -+#define OCP_EEE_AR 0xa41a -+#define OCP_EEE_DATA 0xa41c -+#define OCP_PHY_STATUS 0xa420 -+#define OCP_POWER_CFG 0xa430 -+#define OCP_EEE_CFG 0xa432 -+#define OCP_SRAM_ADDR 0xa436 -+#define OCP_SRAM_DATA 0xa438 -+#define OCP_DOWN_SPEED 0xa442 -+#define OCP_EEE_ABLE 0xa5c4 -+#define OCP_EEE_ADV 0xa5d0 -+#define OCP_EEE_LPABLE 0xa5d2 -+#define OCP_ADC_CFG 0xbc06 -+ -+/* SRAM Register */ -+#define SRAM_LPF_CFG 0x8012 -+#define SRAM_10M_AMP1 0x8080 -+#define SRAM_10M_AMP2 0x8082 -+#define SRAM_IMPEDANCE 0x8084 -+ -+/* PLA_RCR */ -+#define RCR_AAP 0x00000001 -+#define RCR_APM 0x00000002 -+#define RCR_AM 0x00000004 -+#define RCR_AB 0x00000008 -+#define RCR_ACPT_ALL (RCR_AAP | RCR_APM | RCR_AM | RCR_AB) -+ -+/* PLA_RXFIFO_CTRL0 */ -+#define RXFIFO_THR1_NORMAL 0x00080002 -+#define RXFIFO_THR1_OOB 0x01800003 -+ -+/* PLA_RXFIFO_CTRL1 */ -+#define RXFIFO_THR2_FULL 0x00000060 -+#define RXFIFO_THR2_HIGH 0x00000038 -+#define RXFIFO_THR2_OOB 0x0000004a -+#define RXFIFO_THR2_NORMAL 0x00a0 -+ -+/* PLA_RXFIFO_CTRL2 */ -+#define RXFIFO_THR3_FULL 0x00000078 -+#define RXFIFO_THR3_HIGH 0x00000048 -+#define RXFIFO_THR3_OOB 0x0000005a -+#define RXFIFO_THR3_NORMAL 0x0110 -+ -+/* PLA_TXFIFO_CTRL */ -+#define TXFIFO_THR_NORMAL 0x00400008 -+#define TXFIFO_THR_NORMAL2 0x01000008 -+ -+/* PLA_FMC */ -+#define FMC_FCR_MCU_EN 0x0001 -+ -+/* PLA_EEEP_CR */ -+#define EEEP_CR_EEEP_TX 0x0002 -+ -+/* PLA_WDT6_CTRL */ -+#define WDT6_SET_MODE 0x0010 -+ -+/* PLA_TCR0 */ -+#define TCR0_TX_EMPTY 0x0800 -+#define TCR0_AUTO_FIFO 0x0080 -+ -+/* PLA_TCR1 */ -+#define VERSION_MASK 0x7cf0 -+ -+/* PLA_MTPS */ -+#define MTPS_JUMBO (12 * 1024 / 64) -+#define MTPS_DEFAULT (6 * 1024 / 64) -+ -+/* PLA_RSTTALLY */ -+#define TALLY_RESET 0x0001 -+ -+/* PLA_CR */ -+#define CR_RST 0x10 -+#define CR_RE 0x08 -+#define CR_TE 0x04 -+ -+/* PLA_CRWECR */ -+#define CRWECR_NORAML 0x00 -+#define CRWECR_CONFIG 0xc0 -+ -+/* PLA_OOB_CTRL */ -+#define NOW_IS_OOB 0x80 -+#define TXFIFO_EMPTY 0x20 -+#define RXFIFO_EMPTY 0x10 -+#define LINK_LIST_READY 0x02 -+#define DIS_MCU_CLROOB 0x01 -+#define FIFO_EMPTY (TXFIFO_EMPTY | RXFIFO_EMPTY) -+ -+/* PLA_MISC_1 */ -+#define RXDY_GATED_EN 0x0008 -+ -+/* PLA_SFF_STS_7 */ -+#define RE_INIT_LL 0x8000 -+#define MCU_BORW_EN 0x4000 -+ -+/* PLA_CPCR */ -+#define CPCR_RX_VLAN 0x0040 -+ -+/* PLA_CFG_WOL */ -+#define MAGIC_EN 0x0001 -+ -+/* PLA_TEREDO_CFG */ -+#define TEREDO_SEL 0x8000 -+#define TEREDO_WAKE_MASK 0x7f00 -+#define TEREDO_RS_EVENT_MASK 0x00fe -+#define OOB_TEREDO_EN 0x0001 -+ -+/* PAL_BDC_CR */ -+#define ALDPS_PROXY_MODE 0x0001 -+ -+/* PLA_CONFIG34 */ -+#define LINK_ON_WAKE_EN 0x0010 -+#define LINK_OFF_WAKE_EN 0x0008 -+ -+/* PLA_CONFIG5 */ -+#define BWF_EN 0x0040 -+#define MWF_EN 0x0020 -+#define UWF_EN 0x0010 -+#define LAN_WAKE_EN 0x0002 -+ -+/* PLA_LED_FEATURE */ -+#define LED_MODE_MASK 0x0700 -+ -+/* PLA_PHY_PWR */ -+#define TX_10M_IDLE_EN 0x0080 -+#define PFM_PWM_SWITCH 0x0040 -+ -+/* PLA_MAC_PWR_CTRL */ -+#define D3_CLK_GATED_EN 0x00004000 -+#define MCU_CLK_RATIO 0x07010f07 -+#define MCU_CLK_RATIO_MASK 0x0f0f0f0f -+#define ALDPS_SPDWN_RATIO 0x0f87 -+ -+/* PLA_MAC_PWR_CTRL2 */ -+#define EEE_SPDWN_RATIO 0x8007 -+ -+/* PLA_MAC_PWR_CTRL3 */ -+#define PKT_AVAIL_SPDWN_EN 0x0100 -+#define SUSPEND_SPDWN_EN 0x0004 -+#define U1U2_SPDWN_EN 0x0002 -+#define L1_SPDWN_EN 0x0001 -+ -+/* PLA_MAC_PWR_CTRL4 */ -+#define PWRSAVE_SPDWN_EN 0x1000 -+#define RXDV_SPDWN_EN 0x0800 -+#define TX10MIDLE_EN 0x0100 -+#define TP100_SPDWN_EN 0x0020 -+#define TP500_SPDWN_EN 0x0010 -+#define TP1000_SPDWN_EN 0x0008 -+#define EEE_SPDWN_EN 0x0001 -+ -+/* PLA_GPHY_INTR_IMR */ -+#define GPHY_STS_MSK 0x0001 -+#define SPEED_DOWN_MSK 0x0002 -+#define SPDWN_RXDV_MSK 0x0004 -+#define SPDWN_LINKCHG_MSK 0x0008 -+ -+/* PLA_PHYAR */ -+#define PHYAR_FLAG 0x80000000 -+ -+/* PLA_EEE_CR */ -+#define EEE_RX_EN 0x0001 -+#define EEE_TX_EN 0x0002 -+ -+/* PLA_BOOT_CTRL */ -+#define AUTOLOAD_DONE 0x0002 -+ -+/* USB_DEV_STAT */ -+#define STAT_SPEED_MASK 0x0006 -+#define STAT_SPEED_HIGH 0x0000 -+#define STAT_SPEED_FULL 0x0002 -+ -+/* USB_TX_AGG */ -+#define TX_AGG_MAX_THRESHOLD 0x03 -+ -+/* USB_RX_BUF_TH */ -+#define RX_THR_SUPPER 0x0c350180 -+#define RX_THR_HIGH 0x7a120180 -+#define RX_THR_SLOW 0xffff0180 -+ -+/* USB_TX_DMA */ -+#define TEST_MODE_DISABLE 0x00000001 -+#define TX_SIZE_ADJUST1 0x00000100 -+ -+/* USB_UPS_CTRL */ -+#define POWER_CUT 0x0100 -+ -+/* USB_PM_CTRL_STATUS */ -+#define RESUME_INDICATE 0x0001 -+ -+/* USB_USB_CTRL */ -+#define RX_AGG_DISABLE 0x0010 -+ -+/* USB_U2P3_CTRL */ -+#define U2P3_ENABLE 0x0001 -+ -+/* USB_POWER_CUT */ -+#define PWR_EN 0x0001 -+#define PHASE2_EN 0x0008 -+ -+/* USB_MISC_0 */ -+#define PCUT_STATUS 0x0001 -+ -+/* USB_RX_EARLY_AGG */ -+#define EARLY_AGG_SUPPER 0x0e832981 -+#define EARLY_AGG_HIGH 0x0e837a12 -+#define EARLY_AGG_SLOW 0x0e83ffff -+ -+/* USB_WDT11_CTRL */ -+#define TIMER11_EN 0x0001 -+ -+/* USB_LPM_CTRL */ -+#define LPM_TIMER_MASK 0x0c -+#define LPM_TIMER_500MS 0x04 /* 500 ms */ -+#define LPM_TIMER_500US 0x0c /* 500 us */ -+ -+/* USB_AFE_CTRL2 */ -+#define SEN_VAL_MASK 0xf800 -+#define SEN_VAL_NORMAL 0xa000 -+#define SEL_RXIDLE 0x0100 -+ -+/* OCP_ALDPS_CONFIG */ -+#define ENPWRSAVE 0x8000 -+#define ENPDNPS 0x0200 -+#define LINKENA 0x0100 -+#define DIS_SDSAVE 0x0010 -+ -+/* OCP_PHY_STATUS */ -+#define PHY_STAT_MASK 0x0007 -+#define PHY_STAT_LAN_ON 3 -+#define PHY_STAT_PWRDN 5 -+ -+/* OCP_POWER_CFG */ -+#define EEE_CLKDIV_EN 0x8000 -+#define EN_ALDPS 0x0004 -+#define EN_10M_PLLOFF 0x0001 -+ -+/* OCP_EEE_CONFIG1 */ -+#define RG_TXLPI_MSK_HFDUP 0x8000 -+#define RG_MATCLR_EN 0x4000 -+#define EEE_10_CAP 0x2000 -+#define EEE_NWAY_EN 0x1000 -+#define TX_QUIET_EN 0x0200 -+#define RX_QUIET_EN 0x0100 -+#define sd_rise_time_mask 0x0070 -+#define sd_rise_time(x) (min(x, 7) << 4) /* bit 4 ~ 6 */ -+#define RG_RXLPI_MSK_HFDUP 0x0008 -+#define SDFALLTIME 0x0007 /* bit 0 ~ 2 */ -+ -+/* OCP_EEE_CONFIG2 */ -+#define RG_LPIHYS_NUM 0x7000 /* bit 12 ~ 15 */ -+#define RG_DACQUIET_EN 0x0400 -+#define RG_LDVQUIET_EN 0x0200 -+#define RG_CKRSEL 0x0020 -+#define RG_EEEPRG_EN 0x0010 -+ -+/* OCP_EEE_CONFIG3 */ -+#define fast_snr_mask 0xff80 -+#define fast_snr(x) (min(x, 0x1ff) << 7) /* bit 7 ~ 15 */ -+#define RG_LFS_SEL 0x0060 /* bit 6 ~ 5 */ -+#define MSK_PH 0x0006 /* bit 0 ~ 3 */ -+ -+/* OCP_EEE_AR */ -+/* bit[15:14] function */ -+#define FUN_ADDR 0x0000 -+#define FUN_DATA 0x4000 -+/* bit[4:0] device addr */ -+ -+/* OCP_EEE_CFG */ -+#define CTAP_SHORT_EN 0x0040 -+#define EEE10_EN 0x0010 -+ -+/* OCP_DOWN_SPEED */ -+#define EN_10M_BGOFF 0x0080 -+ -+/* OCP_ADC_CFG */ -+#define CKADSEL_L 0x0100 -+#define ADC_EN 0x0080 -+#define EN_EMI_L 0x0040 -+ -+/* SRAM_LPF_CFG */ -+#define LPF_AUTO_TUNE 0x8000 -+ -+/* SRAM_10M_AMP1 */ -+#define GDAC_IB_UPALL 0x0008 -+ -+/* SRAM_10M_AMP2 */ -+#define AMP_DN 0x0200 -+ -+/* SRAM_IMPEDANCE */ -+#define RX_DRIVING_MASK 0x6000 -+ -+enum rtl_register_content { -+ _1000bps = 0x10, -+ _100bps = 0x08, -+ _10bps = 0x04, -+ LINK_STATUS = 0x02, -+ FULL_DUP = 0x01, -+}; -+ -+#define RTL8152_MAX_TX 4 -+#define RTL8152_MAX_RX 10 -+#define INTBUFSIZE 2 -+#define CRC_SIZE 4 -+#define TX_ALIGN 4 -+#define RX_ALIGN 8 -+ -+#define INTR_LINK 0x0004 -+ -+#define RTL8152_REQT_READ 0xc0 -+#define RTL8152_REQT_WRITE 0x40 -+#define RTL8152_REQ_GET_REGS 0x05 -+#define RTL8152_REQ_SET_REGS 0x05 -+ -+#define BYTE_EN_DWORD 0xff -+#define BYTE_EN_WORD 0x33 -+#define BYTE_EN_BYTE 0x11 -+#define BYTE_EN_SIX_BYTES 0x3f -+#define BYTE_EN_START_MASK 0x0f -+#define BYTE_EN_END_MASK 0xf0 -+ -+#define RTL8153_MAX_PACKET 9216 /* 9K */ -+#define RTL8153_MAX_MTU (RTL8153_MAX_PACKET - VLAN_ETH_HLEN - VLAN_HLEN) -+#define RTL8152_RMS (VLAN_ETH_FRAME_LEN + VLAN_HLEN) -+#define RTL8153_RMS RTL8153_MAX_PACKET -+#define RTL8152_TX_TIMEOUT (5 * HZ) -+ -+/* rtl8152 flags */ -+enum rtl8152_flags { -+ RTL8152_UNPLUG = 0, -+ RTL8152_SET_RX_MODE, -+ WORK_ENABLE, -+ RTL8152_LINK_CHG, -+ SELECTIVE_SUSPEND, -+ PHY_RESET, -+ SCHEDULE_TASKLET, -+}; -+ -+/* Define these values to match your device */ -+#define VENDOR_ID_REALTEK 0x0bda -+#define PRODUCT_ID_RTL8152 0x8152 -+#define PRODUCT_ID_RTL8153 0x8153 -+ -+#define VENDOR_ID_SAMSUNG 0x04e8 -+#define PRODUCT_ID_SAMSUNG 0xa101 -+ -+#define MCU_TYPE_PLA 0x0100 -+#define MCU_TYPE_USB 0x0000 -+ -+#define REALTEK_USB_DEVICE(vend, prod) \ -+ USB_DEVICE_INTERFACE_CLASS(vend, prod, USB_CLASS_VENDOR_SPEC) -+ -+struct tally_counter { -+ __le64 tx_packets; -+ __le64 rx_packets; -+ __le64 tx_errors; -+ __le32 rx_errors; -+ __le16 rx_missed; -+ __le16 align_errors; -+ __le32 tx_one_collision; -+ __le32 tx_multi_collision; -+ __le64 rx_unicast; -+ __le64 rx_broadcast; -+ __le32 rx_multicast; -+ __le16 tx_aborted; -+ __le16 tx_underun; -+}; -+ -+struct rx_desc { -+ __le32 opts1; -+#define RX_LEN_MASK 0x7fff -+ -+ __le32 opts2; -+#define RD_UDP_CS (1 << 23) -+#define RD_TCP_CS (1 << 22) -+#define RD_IPV6_CS (1 << 20) -+#define RD_IPV4_CS (1 << 19) -+ -+ __le32 opts3; -+#define IPF (1 << 23) /* IP checksum fail */ -+#define UDPF (1 << 22) /* UDP checksum fail */ -+#define TCPF (1 << 21) /* TCP checksum fail */ -+#define RX_VLAN_TAG (1 << 16) -+ -+ __le32 opts4; -+ __le32 opts5; -+ __le32 opts6; -+}; -+ -+struct tx_desc { -+ __le32 opts1; -+#define TX_FS (1 << 31) /* First segment of a packet */ -+#define TX_LS (1 << 30) /* Final segment of a packet */ -+#define GTSENDV4 (1 << 28) -+#define GTSENDV6 (1 << 27) -+#define GTTCPHO_SHIFT 18 -+#define GTTCPHO_MAX 0x7fU -+#define TX_LEN_MAX 0x3ffffU -+ -+ __le32 opts2; -+#define UDP_CS (1 << 31) /* Calculate UDP/IP checksum */ -+#define TCP_CS (1 << 30) /* Calculate TCP/IP checksum */ -+#define IPV4_CS (1 << 29) /* Calculate IPv4 checksum */ -+#define IPV6_CS (1 << 28) /* Calculate IPv6 checksum */ -+#define MSS_SHIFT 17 -+#define MSS_MAX 0x7ffU -+#define TCPHO_SHIFT 17 -+#define TCPHO_MAX 0x7ffU -+#define TX_VLAN_TAG (1 << 16) -+}; -+ -+struct r8152; -+ -+struct rx_agg { -+ struct list_head list; -+ struct urb *urb; -+ struct r8152 *context; -+ void *buffer; -+ void *head; -+}; -+ -+struct tx_agg { -+ struct list_head list; -+ struct urb *urb; -+ struct r8152 *context; -+ void *buffer; -+ void *head; -+ u32 skb_num; -+ u32 skb_len; -+}; -+ -+struct r8152 { -+ unsigned long flags; -+ struct usb_device *udev; -+ struct tasklet_struct tl; -+ struct usb_interface *intf; -+ struct net_device *netdev; -+ struct urb *intr_urb; -+ struct tx_agg tx_info[RTL8152_MAX_TX]; -+ struct rx_agg rx_info[RTL8152_MAX_RX]; -+ struct list_head rx_done, tx_free; -+ struct sk_buff_head tx_queue; -+ spinlock_t rx_lock, tx_lock; -+ struct delayed_work schedule; -+ struct mii_if_info mii; -+ struct mutex control; /* use for hw setting */ -+ -+ struct rtl_ops { -+ void (*init)(struct r8152 *); -+ int (*enable)(struct r8152 *); -+ void (*disable)(struct r8152 *); -+ void (*up)(struct r8152 *); -+ void (*down)(struct r8152 *); -+ void (*unload)(struct r8152 *); -+ int (*eee_get)(struct r8152 *, struct ethtool_eee *); -+ int (*eee_set)(struct r8152 *, struct ethtool_eee *); -+ } __no_const rtl_ops; -+ -+ int intr_interval; -+ u32 saved_wolopts; -+ u32 msg_enable; -+ u32 tx_qlen; -+ u16 ocp_base; -+ u8 *intr_buff; -+ u8 version; -+ u8 speed; -+}; -+ -+enum rtl_version { -+ RTL_VER_UNKNOWN = 0, -+ RTL_VER_01, -+ RTL_VER_02, -+ RTL_VER_03, -+ RTL_VER_04, -+ RTL_VER_05, -+ RTL_VER_MAX -+}; -+ -+enum tx_csum_stat { -+ TX_CSUM_SUCCESS = 0, -+ TX_CSUM_TSO, -+ TX_CSUM_NONE -+}; -+ -+/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). -+ * The RTL chips use a 64 element hash table based on the Ethernet CRC. -+ */ -+static const int multicast_filter_limit = 32; -+static unsigned int agg_buf_sz = 16384; -+ -+#define RTL_LIMITED_TSO_SIZE (agg_buf_sz - sizeof(struct tx_desc) - \ -+ VLAN_ETH_HLEN - VLAN_HLEN) -+ -+static -+int get_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) -+{ -+ int ret; -+ void *tmp; -+ -+ tmp = kmalloc(size, GFP_KERNEL); -+ if (!tmp) -+ return -ENOMEM; -+ -+ ret = usb_control_msg(tp->udev, usb_rcvctrlpipe(tp->udev, 0), -+ RTL8152_REQ_GET_REGS, RTL8152_REQT_READ, -+ value, index, tmp, size, 500); -+ -+ memcpy(data, tmp, size); -+ kfree(tmp); -+ -+ return ret; -+} -+ -+static -+int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) -+{ -+ int ret; -+ void *tmp; -+ -+ tmp = kmemdup(data, size, GFP_KERNEL); -+ if (!tmp) -+ return -ENOMEM; -+ -+ ret = usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0), -+ RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE, -+ value, index, tmp, size, 500); -+ -+ kfree(tmp); -+ -+ return ret; -+} -+ -+static int generic_ocp_read(struct r8152 *tp, u16 index, u16 size, -+ void *data, u16 type) -+{ -+ u16 limit = 64; -+ int ret = 0; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return -ENODEV; -+ -+ /* both size and indix must be 4 bytes align */ -+ if ((size & 3) || !size || (index & 3) || !data) -+ return -EPERM; -+ -+ if ((u32)index + (u32)size > 0xffff) -+ return -EPERM; -+ -+ while (size) { -+ if (size > limit) { -+ ret = get_registers(tp, index, type, limit, data); -+ if (ret < 0) -+ break; -+ -+ index += limit; -+ data += limit; -+ size -= limit; -+ } else { -+ ret = get_registers(tp, index, type, size, data); -+ if (ret < 0) -+ break; -+ -+ index += size; -+ data += size; -+ size = 0; -+ break; -+ } -+ } -+ -+ return ret; -+} -+ -+static int generic_ocp_write(struct r8152 *tp, u16 index, u16 byteen, -+ u16 size, void *data, u16 type) -+{ -+ int ret; -+ u16 byteen_start, byteen_end, byen; -+ u16 limit = 512; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return -ENODEV; -+ -+ /* both size and indix must be 4 bytes align */ -+ if ((size & 3) || !size || (index & 3) || !data) -+ return -EPERM; -+ -+ if ((u32)index + (u32)size > 0xffff) -+ return -EPERM; -+ -+ byteen_start = byteen & BYTE_EN_START_MASK; -+ byteen_end = byteen & BYTE_EN_END_MASK; -+ -+ byen = byteen_start | (byteen_start << 4); -+ ret = set_registers(tp, index, type | byen, 4, data); -+ if (ret < 0) -+ goto error1; -+ -+ index += 4; -+ data += 4; -+ size -= 4; -+ -+ if (size) { -+ size -= 4; -+ -+ while (size) { -+ if (size > limit) { -+ ret = set_registers(tp, index, -+ type | BYTE_EN_DWORD, -+ limit, data); -+ if (ret < 0) -+ goto error1; -+ -+ index += limit; -+ data += limit; -+ size -= limit; -+ } else { -+ ret = set_registers(tp, index, -+ type | BYTE_EN_DWORD, -+ size, data); -+ if (ret < 0) -+ goto error1; -+ -+ index += size; -+ data += size; -+ size = 0; -+ break; -+ } -+ } -+ -+ byen = byteen_end | (byteen_end >> 4); -+ ret = set_registers(tp, index, type | byen, 4, data); -+ if (ret < 0) -+ goto error1; -+ } -+ -+error1: -+ return ret; -+} -+ -+static inline -+int pla_ocp_read(struct r8152 *tp, u16 index, u16 size, void *data) -+{ -+ return generic_ocp_read(tp, index, size, data, MCU_TYPE_PLA); -+} -+ -+static inline -+int pla_ocp_write(struct r8152 *tp, u16 index, u16 byteen, u16 size, void *data) -+{ -+ return generic_ocp_write(tp, index, byteen, size, data, MCU_TYPE_PLA); -+} -+ -+static inline -+int usb_ocp_read(struct r8152 *tp, u16 index, u16 size, void *data) -+{ -+ return generic_ocp_read(tp, index, size, data, MCU_TYPE_USB); -+} -+ -+static inline -+int usb_ocp_write(struct r8152 *tp, u16 index, u16 byteen, u16 size, void *data) -+{ -+ return generic_ocp_write(tp, index, byteen, size, data, MCU_TYPE_USB); -+} -+ -+static u32 ocp_read_dword(struct r8152 *tp, u16 type, u16 index) -+{ -+ __le32 data; -+ -+ generic_ocp_read(tp, index, sizeof(data), &data, type); -+ -+ return __le32_to_cpu(data); -+} -+ -+static void ocp_write_dword(struct r8152 *tp, u16 type, u16 index, u32 data) -+{ -+ __le32 tmp = __cpu_to_le32(data); -+ -+ generic_ocp_write(tp, index, BYTE_EN_DWORD, sizeof(tmp), &tmp, type); -+} -+ -+static u16 ocp_read_word(struct r8152 *tp, u16 type, u16 index) -+{ -+ u32 data; -+ __le32 tmp; -+ u8 shift = index & 2; -+ -+ index &= ~3; -+ -+ generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); -+ -+ data = __le32_to_cpu(tmp); -+ data >>= (shift * 8); -+ data &= 0xffff; -+ -+ return (u16)data; -+} -+ -+static void ocp_write_word(struct r8152 *tp, u16 type, u16 index, u32 data) -+{ -+ u32 mask = 0xffff; -+ __le32 tmp; -+ u16 byen = BYTE_EN_WORD; -+ u8 shift = index & 2; -+ -+ data &= mask; -+ -+ if (index & 2) { -+ byen <<= shift; -+ mask <<= (shift * 8); -+ data <<= (shift * 8); -+ index &= ~3; -+ } -+ -+ generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); -+ -+ data |= __le32_to_cpu(tmp) & ~mask; -+ tmp = __cpu_to_le32(data); -+ -+ generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); -+} -+ -+static u8 ocp_read_byte(struct r8152 *tp, u16 type, u16 index) -+{ -+ u32 data; -+ __le32 tmp; -+ u8 shift = index & 3; -+ -+ index &= ~3; -+ -+ generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); -+ -+ data = __le32_to_cpu(tmp); -+ data >>= (shift * 8); -+ data &= 0xff; -+ -+ return (u8)data; -+} -+ -+static void ocp_write_byte(struct r8152 *tp, u16 type, u16 index, u32 data) -+{ -+ u32 mask = 0xff; -+ __le32 tmp; -+ u16 byen = BYTE_EN_BYTE; -+ u8 shift = index & 3; -+ -+ data &= mask; -+ -+ if (index & 3) { -+ byen <<= shift; -+ mask <<= (shift * 8); -+ data <<= (shift * 8); -+ index &= ~3; -+ } -+ -+ generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); -+ -+ data |= __le32_to_cpu(tmp) & ~mask; -+ tmp = __cpu_to_le32(data); -+ -+ generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); -+} -+ -+static u16 ocp_reg_read(struct r8152 *tp, u16 addr) -+{ -+ u16 ocp_base, ocp_index; -+ -+ ocp_base = addr & 0xf000; -+ if (ocp_base != tp->ocp_base) { -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, ocp_base); -+ tp->ocp_base = ocp_base; -+ } -+ -+ ocp_index = (addr & 0x0fff) | 0xb000; -+ return ocp_read_word(tp, MCU_TYPE_PLA, ocp_index); -+} -+ -+static void ocp_reg_write(struct r8152 *tp, u16 addr, u16 data) -+{ -+ u16 ocp_base, ocp_index; -+ -+ ocp_base = addr & 0xf000; -+ if (ocp_base != tp->ocp_base) { -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, ocp_base); -+ tp->ocp_base = ocp_base; -+ } -+ -+ ocp_index = (addr & 0x0fff) | 0xb000; -+ ocp_write_word(tp, MCU_TYPE_PLA, ocp_index, data); -+} -+ -+static inline void r8152_mdio_write(struct r8152 *tp, u32 reg_addr, u32 value) -+{ -+ ocp_reg_write(tp, OCP_BASE_MII + reg_addr * 2, value); -+} -+ -+static inline int r8152_mdio_read(struct r8152 *tp, u32 reg_addr) -+{ -+ return ocp_reg_read(tp, OCP_BASE_MII + reg_addr * 2); -+} -+ -+static void sram_write(struct r8152 *tp, u16 addr, u16 data) -+{ -+ ocp_reg_write(tp, OCP_SRAM_ADDR, addr); -+ ocp_reg_write(tp, OCP_SRAM_DATA, data); -+} -+ -+static u16 sram_read(struct r8152 *tp, u16 addr) -+{ -+ ocp_reg_write(tp, OCP_SRAM_ADDR, addr); -+ return ocp_reg_read(tp, OCP_SRAM_DATA); -+} -+ -+static int read_mii_word(struct net_device *netdev, int phy_id, int reg) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ int ret; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return -ENODEV; -+ -+ if (phy_id != R8152_PHY_ID) -+ return -EINVAL; -+ -+ ret = r8152_mdio_read(tp, reg); -+ -+ return ret; -+} -+ -+static -+void write_mii_word(struct net_device *netdev, int phy_id, int reg, int val) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ if (phy_id != R8152_PHY_ID) -+ return; -+ -+ r8152_mdio_write(tp, reg, val); -+} -+ -+static int -+r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags); -+ -+static int rtl8152_set_mac_address(struct net_device *netdev, void *p) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ struct sockaddr *addr = p; -+ int ret = -EADDRNOTAVAIL; -+ -+ if (!is_valid_ether_addr(addr->sa_data)) -+ goto out1; -+ -+ ret = usb_autopm_get_interface(tp->intf); -+ if (ret < 0) -+ goto out1; -+ -+ mutex_lock(&tp->control); -+ -+ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); -+ -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG); -+ pla_ocp_write(tp, PLA_IDR, BYTE_EN_SIX_BYTES, 8, addr->sa_data); -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+out1: -+ return ret; -+} -+ -+static int set_ethernet_addr(struct r8152 *tp) -+{ -+ struct net_device *dev = tp->netdev; -+ struct sockaddr sa; -+ int ret; -+ -+ if (tp->version == RTL_VER_01) -+ ret = pla_ocp_read(tp, PLA_IDR, 8, sa.sa_data); -+ else -+ ret = pla_ocp_read(tp, PLA_BACKUP, 8, sa.sa_data); -+ -+ if (ret < 0) { -+ netif_err(tp, probe, dev, "Get ether addr fail\n"); -+ } else if (!is_valid_ether_addr(sa.sa_data)) { -+ netif_err(tp, probe, dev, "Invalid ether addr %pM\n", -+ sa.sa_data); -+ eth_hw_addr_random(dev); -+ ether_addr_copy(sa.sa_data, dev->dev_addr); -+ ret = rtl8152_set_mac_address(dev, &sa); -+ netif_info(tp, probe, dev, "Random ether addr %pM\n", -+ sa.sa_data); -+ } else { -+ if (tp->version == RTL_VER_01) -+ ether_addr_copy(dev->dev_addr, sa.sa_data); -+ else -+ ret = rtl8152_set_mac_address(dev, &sa); -+ } -+ -+ return ret; -+} -+ -+static void read_bulk_callback(struct urb *urb) -+{ -+ struct net_device *netdev; -+ int status = urb->status; -+ struct rx_agg *agg; -+ struct r8152 *tp; -+ int result; -+ -+ agg = urb->context; -+ if (!agg) -+ return; -+ -+ tp = agg->context; -+ if (!tp) -+ return; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ if (!test_bit(WORK_ENABLE, &tp->flags)) -+ return; -+ -+ netdev = tp->netdev; -+ -+ /* When link down, the driver would cancel all bulks. */ -+ /* This avoid the re-submitting bulk */ -+ if (!netif_carrier_ok(netdev)) -+ return; -+ -+ usb_mark_last_busy(tp->udev); -+ -+ switch (status) { -+ case 0: -+ if (urb->actual_length < ETH_ZLEN) -+ break; -+ -+ spin_lock(&tp->rx_lock); -+ list_add_tail(&agg->list, &tp->rx_done); -+ spin_unlock(&tp->rx_lock); -+ tasklet_schedule(&tp->tl); -+ return; -+ case -ESHUTDOWN: -+ set_bit(RTL8152_UNPLUG, &tp->flags); -+ netif_device_detach(tp->netdev); -+ return; -+ case -ENOENT: -+ return; /* the urb is in unlink state */ -+ case -ETIME: -+ if (net_ratelimit()) -+ netdev_warn(netdev, "maybe reset is needed?\n"); -+ break; -+ default: -+ if (net_ratelimit()) -+ netdev_warn(netdev, "Rx status %d\n", status); -+ break; -+ } -+ -+ result = r8152_submit_rx(tp, agg, GFP_ATOMIC); -+ if (result == -ENODEV) { -+ netif_device_detach(tp->netdev); -+ } else if (result) { -+ spin_lock(&tp->rx_lock); -+ list_add_tail(&agg->list, &tp->rx_done); -+ spin_unlock(&tp->rx_lock); -+ tasklet_schedule(&tp->tl); -+ } -+} -+ -+static void write_bulk_callback(struct urb *urb) -+{ -+ struct net_device_stats *stats; -+ struct net_device *netdev; -+ struct tx_agg *agg; -+ struct r8152 *tp; -+ int status = urb->status; -+ -+ agg = urb->context; -+ if (!agg) -+ return; -+ -+ tp = agg->context; -+ if (!tp) -+ return; -+ -+ netdev = tp->netdev; -+ stats = &netdev->stats; -+ if (status) { -+ if (net_ratelimit()) -+ netdev_warn(netdev, "Tx status %d\n", status); -+ stats->tx_errors += agg->skb_num; -+ } else { -+ stats->tx_packets += agg->skb_num; -+ stats->tx_bytes += agg->skb_len; -+ } -+ -+ spin_lock(&tp->tx_lock); -+ list_add_tail(&agg->list, &tp->tx_free); -+ spin_unlock(&tp->tx_lock); -+ -+ usb_autopm_put_interface_async(tp->intf); -+ -+ if (!netif_carrier_ok(netdev)) -+ return; -+ -+ if (!test_bit(WORK_ENABLE, &tp->flags)) -+ return; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ if (!skb_queue_empty(&tp->tx_queue)) -+ tasklet_schedule(&tp->tl); -+} -+ -+static void intr_callback(struct urb *urb) -+{ -+ struct r8152 *tp; -+ __le16 *d; -+ int status = urb->status; -+ int res; -+ -+ tp = urb->context; -+ if (!tp) -+ return; -+ -+ if (!test_bit(WORK_ENABLE, &tp->flags)) -+ return; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ switch (status) { -+ case 0: /* success */ -+ break; -+ case -ECONNRESET: /* unlink */ -+ case -ESHUTDOWN: -+ netif_device_detach(tp->netdev); -+ case -ENOENT: -+ case -EPROTO: -+ netif_info(tp, intr, tp->netdev, -+ "Stop submitting intr, status %d\n", status); -+ return; -+ case -EOVERFLOW: -+ netif_info(tp, intr, tp->netdev, "intr status -EOVERFLOW\n"); -+ goto resubmit; -+ /* -EPIPE: should clear the halt */ -+ default: -+ netif_info(tp, intr, tp->netdev, "intr status %d\n", status); -+ goto resubmit; -+ } -+ -+ d = urb->transfer_buffer; -+ if (INTR_LINK & __le16_to_cpu(d[0])) { -+ if (!(tp->speed & LINK_STATUS)) { -+ set_bit(RTL8152_LINK_CHG, &tp->flags); -+ schedule_delayed_work(&tp->schedule, 0); -+ } -+ } else { -+ if (tp->speed & LINK_STATUS) { -+ set_bit(RTL8152_LINK_CHG, &tp->flags); -+ schedule_delayed_work(&tp->schedule, 0); -+ } -+ } -+ -+resubmit: -+ res = usb_submit_urb(urb, GFP_ATOMIC); -+ if (res == -ENODEV) -+ netif_device_detach(tp->netdev); -+ else if (res) -+ netif_err(tp, intr, tp->netdev, -+ "can't resubmit intr, status %d\n", res); -+} -+ -+static inline void *rx_agg_align(void *data) -+{ -+ return (void *)ALIGN((uintptr_t)data, RX_ALIGN); -+} -+ -+static inline void *tx_agg_align(void *data) -+{ -+ return (void *)ALIGN((uintptr_t)data, TX_ALIGN); -+} -+ -+static void free_all_mem(struct r8152 *tp) -+{ -+ int i; -+ -+ for (i = 0; i < RTL8152_MAX_RX; i++) { -+ usb_free_urb(tp->rx_info[i].urb); -+ tp->rx_info[i].urb = NULL; -+ -+ kfree(tp->rx_info[i].buffer); -+ tp->rx_info[i].buffer = NULL; -+ tp->rx_info[i].head = NULL; -+ } -+ -+ for (i = 0; i < RTL8152_MAX_TX; i++) { -+ usb_free_urb(tp->tx_info[i].urb); -+ tp->tx_info[i].urb = NULL; -+ -+ kfree(tp->tx_info[i].buffer); -+ tp->tx_info[i].buffer = NULL; -+ tp->tx_info[i].head = NULL; -+ } -+ -+ usb_free_urb(tp->intr_urb); -+ tp->intr_urb = NULL; -+ -+ kfree(tp->intr_buff); -+ tp->intr_buff = NULL; -+} -+ -+static int alloc_all_mem(struct r8152 *tp) -+{ -+ struct net_device *netdev = tp->netdev; -+ struct usb_interface *intf = tp->intf; -+ struct usb_host_interface *alt = intf->cur_altsetting; -+ struct usb_host_endpoint *ep_intr = alt->endpoint + 2; -+ struct urb *urb; -+ int node, i; -+ u8 *buf; -+ -+ node = netdev->dev.parent ? dev_to_node(netdev->dev.parent) : -1; -+ -+ spin_lock_init(&tp->rx_lock); -+ spin_lock_init(&tp->tx_lock); -+ INIT_LIST_HEAD(&tp->rx_done); -+ INIT_LIST_HEAD(&tp->tx_free); -+ skb_queue_head_init(&tp->tx_queue); -+ -+ for (i = 0; i < RTL8152_MAX_RX; i++) { -+ buf = kmalloc_node(agg_buf_sz, GFP_KERNEL, node); -+ if (!buf) -+ goto err1; -+ -+ if (buf != rx_agg_align(buf)) { -+ kfree(buf); -+ buf = kmalloc_node(agg_buf_sz + RX_ALIGN, GFP_KERNEL, -+ node); -+ if (!buf) -+ goto err1; -+ } -+ -+ urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!urb) { -+ kfree(buf); -+ goto err1; -+ } -+ -+ INIT_LIST_HEAD(&tp->rx_info[i].list); -+ tp->rx_info[i].context = tp; -+ tp->rx_info[i].urb = urb; -+ tp->rx_info[i].buffer = buf; -+ tp->rx_info[i].head = rx_agg_align(buf); -+ } -+ -+ for (i = 0; i < RTL8152_MAX_TX; i++) { -+ buf = kmalloc_node(agg_buf_sz, GFP_KERNEL, node); -+ if (!buf) -+ goto err1; -+ -+ if (buf != tx_agg_align(buf)) { -+ kfree(buf); -+ buf = kmalloc_node(agg_buf_sz + TX_ALIGN, GFP_KERNEL, -+ node); -+ if (!buf) -+ goto err1; -+ } -+ -+ urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!urb) { -+ kfree(buf); -+ goto err1; -+ } -+ -+ INIT_LIST_HEAD(&tp->tx_info[i].list); -+ tp->tx_info[i].context = tp; -+ tp->tx_info[i].urb = urb; -+ tp->tx_info[i].buffer = buf; -+ tp->tx_info[i].head = tx_agg_align(buf); -+ -+ list_add_tail(&tp->tx_info[i].list, &tp->tx_free); -+ } -+ -+ tp->intr_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!tp->intr_urb) -+ goto err1; -+ -+ tp->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL); -+ if (!tp->intr_buff) -+ goto err1; -+ -+ tp->intr_interval = (int)ep_intr->desc.bInterval; -+ usb_fill_int_urb(tp->intr_urb, tp->udev, usb_rcvintpipe(tp->udev, 3), -+ tp->intr_buff, INTBUFSIZE, intr_callback, -+ tp, tp->intr_interval); -+ -+ return 0; -+ -+err1: -+ free_all_mem(tp); -+ return -ENOMEM; -+} -+ -+static struct tx_agg *r8152_get_tx_agg(struct r8152 *tp) -+{ -+ struct tx_agg *agg = NULL; -+ unsigned long flags; -+ -+ if (list_empty(&tp->tx_free)) -+ return NULL; -+ -+ spin_lock_irqsave(&tp->tx_lock, flags); -+ if (!list_empty(&tp->tx_free)) { -+ struct list_head *cursor; -+ -+ cursor = tp->tx_free.next; -+ list_del_init(cursor); -+ agg = list_entry(cursor, struct tx_agg, list); -+ } -+ spin_unlock_irqrestore(&tp->tx_lock, flags); -+ -+ return agg; -+} -+ -+static inline __be16 get_protocol(struct sk_buff *skb) -+{ -+ __be16 protocol; -+ -+ if (skb->protocol == htons(ETH_P_8021Q)) -+ protocol = vlan_eth_hdr(skb)->h_vlan_encapsulated_proto; -+ else -+ protocol = skb->protocol; -+ -+ return protocol; -+} -+ -+/* r8152_csum_workaround() -+ * The hw limites the value the transport offset. When the offset is out of the -+ * range, calculate the checksum by sw. -+ */ -+static void r8152_csum_workaround(struct r8152 *tp, struct sk_buff *skb, -+ struct sk_buff_head *list) -+{ -+ if (skb_shinfo(skb)->gso_size) { -+ netdev_features_t features = tp->netdev->features; -+ struct sk_buff_head seg_list; -+ struct sk_buff *segs, *nskb; -+ -+ features &= ~(NETIF_F_SG | NETIF_F_IPV6_CSUM | NETIF_F_TSO6); -+ segs = skb_gso_segment(skb, features); -+ if (IS_ERR(segs) || !segs) -+ goto drop; -+ -+ __skb_queue_head_init(&seg_list); -+ -+ do { -+ nskb = segs; -+ segs = segs->next; -+ nskb->next = NULL; -+ __skb_queue_tail(&seg_list, nskb); -+ } while (segs); -+ -+ skb_queue_splice(&seg_list, list); -+ dev_kfree_skb(skb); -+ } else if (skb->ip_summed == CHECKSUM_PARTIAL) { -+ if (skb_checksum_help(skb) < 0) -+ goto drop; -+ -+ __skb_queue_head(list, skb); -+ } else { -+ struct net_device_stats *stats; -+ -+drop: -+ stats = &tp->netdev->stats; -+ stats->tx_dropped++; -+ dev_kfree_skb(skb); -+ } -+} -+ -+/* msdn_giant_send_check() -+ * According to the document of microsoft, the TCP Pseudo Header excludes the -+ * packet length for IPv6 TCP large packets. -+ */ -+static int msdn_giant_send_check(struct sk_buff *skb) -+{ -+ const struct ipv6hdr *ipv6h; -+ struct tcphdr *th; -+ int ret; -+ -+ ret = skb_cow_head(skb, 0); -+ if (ret) -+ return ret; -+ -+ ipv6h = ipv6_hdr(skb); -+ th = tcp_hdr(skb); -+ -+ th->check = 0; -+ th->check = ~tcp_v6_check(0, &ipv6h->saddr, &ipv6h->daddr, 0); -+ -+ return ret; -+} -+ -+static inline void rtl_tx_vlan_tag(struct tx_desc *desc, struct sk_buff *skb) -+{ -+ if (vlan_tx_tag_present(skb)) { -+ u32 opts2; -+ -+ opts2 = TX_VLAN_TAG | swab16(vlan_tx_tag_get(skb)); -+ desc->opts2 |= cpu_to_le32(opts2); -+ } -+} -+ -+static inline void rtl_rx_vlan_tag(struct rx_desc *desc, struct sk_buff *skb) -+{ -+ u32 opts2 = le32_to_cpu(desc->opts2); -+ -+ if (opts2 & RX_VLAN_TAG) -+ __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), -+ swab16(opts2 & 0xffff)); -+} -+ -+static int r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, -+ struct sk_buff *skb, u32 len, u32 transport_offset) -+{ -+ u32 mss = skb_shinfo(skb)->gso_size; -+ u32 opts1, opts2 = 0; -+ int ret = TX_CSUM_SUCCESS; -+ -+ WARN_ON_ONCE(len > TX_LEN_MAX); -+ -+ opts1 = len | TX_FS | TX_LS; -+ -+ if (mss) { -+ if (transport_offset > GTTCPHO_MAX) { -+ netif_warn(tp, tx_err, tp->netdev, -+ "Invalid transport offset 0x%x for TSO\n", -+ transport_offset); -+ ret = TX_CSUM_TSO; -+ goto unavailable; -+ } -+ -+ switch (get_protocol(skb)) { -+ case htons(ETH_P_IP): -+ opts1 |= GTSENDV4; -+ break; -+ -+ case htons(ETH_P_IPV6): -+ if (msdn_giant_send_check(skb)) { -+ ret = TX_CSUM_TSO; -+ goto unavailable; -+ } -+ opts1 |= GTSENDV6; -+ break; -+ -+ default: -+ WARN_ON_ONCE(1); -+ break; -+ } -+ -+ opts1 |= transport_offset << GTTCPHO_SHIFT; -+ opts2 |= min(mss, MSS_MAX) << MSS_SHIFT; -+ } else if (skb->ip_summed == CHECKSUM_PARTIAL) { -+ u8 ip_protocol; -+ -+ if (transport_offset > TCPHO_MAX) { -+ netif_warn(tp, tx_err, tp->netdev, -+ "Invalid transport offset 0x%x\n", -+ transport_offset); -+ ret = TX_CSUM_NONE; -+ goto unavailable; -+ } -+ -+ switch (get_protocol(skb)) { -+ case htons(ETH_P_IP): -+ opts2 |= IPV4_CS; -+ ip_protocol = ip_hdr(skb)->protocol; -+ break; -+ -+ case htons(ETH_P_IPV6): -+ opts2 |= IPV6_CS; -+ ip_protocol = ipv6_hdr(skb)->nexthdr; -+ break; -+ -+ default: -+ ip_protocol = IPPROTO_RAW; -+ break; -+ } -+ -+ if (ip_protocol == IPPROTO_TCP) -+ opts2 |= TCP_CS; -+ else if (ip_protocol == IPPROTO_UDP) -+ opts2 |= UDP_CS; -+ else -+ WARN_ON_ONCE(1); -+ -+ opts2 |= transport_offset << TCPHO_SHIFT; -+ } -+ -+ desc->opts2 = cpu_to_le32(opts2); -+ desc->opts1 = cpu_to_le32(opts1); -+ -+unavailable: -+ return ret; -+} -+ -+static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg) -+{ -+ struct sk_buff_head skb_head, *tx_queue = &tp->tx_queue; -+ int remain, ret; -+ u8 *tx_data; -+ -+ __skb_queue_head_init(&skb_head); -+ spin_lock(&tx_queue->lock); -+ skb_queue_splice_init(tx_queue, &skb_head); -+ spin_unlock(&tx_queue->lock); -+ -+ tx_data = agg->head; -+ agg->skb_num = 0; -+ agg->skb_len = 0; -+ remain = agg_buf_sz; -+ -+ while (remain >= ETH_ZLEN + sizeof(struct tx_desc)) { -+ struct tx_desc *tx_desc; -+ struct sk_buff *skb; -+ unsigned int len; -+ u32 offset; -+ -+ skb = __skb_dequeue(&skb_head); -+ if (!skb) -+ break; -+ -+ len = skb->len + sizeof(*tx_desc); -+ -+ if (len > remain) { -+ __skb_queue_head(&skb_head, skb); -+ break; -+ } -+ -+ tx_data = tx_agg_align(tx_data); -+ tx_desc = (struct tx_desc *)tx_data; -+ -+ offset = (u32)skb_transport_offset(skb); -+ -+ if (r8152_tx_csum(tp, tx_desc, skb, skb->len, offset)) { -+ r8152_csum_workaround(tp, skb, &skb_head); -+ continue; -+ } -+ -+ rtl_tx_vlan_tag(tx_desc, skb); -+ -+ tx_data += sizeof(*tx_desc); -+ -+ len = skb->len; -+ if (skb_copy_bits(skb, 0, tx_data, len) < 0) { -+ struct net_device_stats *stats = &tp->netdev->stats; -+ -+ stats->tx_dropped++; -+ dev_kfree_skb_any(skb); -+ tx_data -= sizeof(*tx_desc); -+ continue; -+ } -+ -+ tx_data += len; -+ agg->skb_len += len; -+ agg->skb_num++; -+ -+ dev_kfree_skb_any(skb); -+ -+ remain = agg_buf_sz - (int)(tx_agg_align(tx_data) - agg->head); -+ } -+ -+ if (!skb_queue_empty(&skb_head)) { -+ spin_lock(&tx_queue->lock); -+ skb_queue_splice(&skb_head, tx_queue); -+ spin_unlock(&tx_queue->lock); -+ } -+ -+ netif_tx_lock(tp->netdev); -+ -+ if (netif_queue_stopped(tp->netdev) && -+ skb_queue_len(&tp->tx_queue) < tp->tx_qlen) -+ netif_wake_queue(tp->netdev); -+ -+ netif_tx_unlock(tp->netdev); -+ -+ ret = usb_autopm_get_interface_async(tp->intf); -+ if (ret < 0) -+ goto out_tx_fill; -+ -+ usb_fill_bulk_urb(agg->urb, tp->udev, usb_sndbulkpipe(tp->udev, 2), -+ agg->head, (int)(tx_data - (u8 *)agg->head), -+ (usb_complete_t)write_bulk_callback, agg); -+ -+ ret = usb_submit_urb(agg->urb, GFP_ATOMIC); -+ if (ret < 0) -+ usb_autopm_put_interface_async(tp->intf); -+ -+out_tx_fill: -+ return ret; -+} -+ -+static u8 r8152_rx_csum(struct r8152 *tp, struct rx_desc *rx_desc) -+{ -+ u8 checksum = CHECKSUM_NONE; -+ u32 opts2, opts3; -+ -+ if (tp->version == RTL_VER_01) -+ goto return_result; -+ -+ opts2 = le32_to_cpu(rx_desc->opts2); -+ opts3 = le32_to_cpu(rx_desc->opts3); -+ -+ if (opts2 & RD_IPV4_CS) { -+ if (opts3 & IPF) -+ checksum = CHECKSUM_NONE; -+ else if ((opts2 & RD_UDP_CS) && (opts3 & UDPF)) -+ checksum = CHECKSUM_NONE; -+ else if ((opts2 & RD_TCP_CS) && (opts3 & TCPF)) -+ checksum = CHECKSUM_NONE; -+ else -+ checksum = CHECKSUM_UNNECESSARY; -+ } else if (RD_IPV6_CS) { -+ if ((opts2 & RD_UDP_CS) && !(opts3 & UDPF)) -+ checksum = CHECKSUM_UNNECESSARY; -+ else if ((opts2 & RD_TCP_CS) && !(opts3 & TCPF)) -+ checksum = CHECKSUM_UNNECESSARY; -+ } -+ -+return_result: -+ return checksum; -+} -+ -+static void rx_bottom(struct r8152 *tp) -+{ -+ unsigned long flags; -+ struct list_head *cursor, *next, rx_queue; -+ -+ if (list_empty(&tp->rx_done)) -+ return; -+ -+ INIT_LIST_HEAD(&rx_queue); -+ spin_lock_irqsave(&tp->rx_lock, flags); -+ list_splice_init(&tp->rx_done, &rx_queue); -+ spin_unlock_irqrestore(&tp->rx_lock, flags); -+ -+ list_for_each_safe(cursor, next, &rx_queue) { -+ struct rx_desc *rx_desc; -+ struct rx_agg *agg; -+ int len_used = 0; -+ struct urb *urb; -+ u8 *rx_data; -+ int ret; -+ -+ list_del_init(cursor); -+ -+ agg = list_entry(cursor, struct rx_agg, list); -+ urb = agg->urb; -+ if (urb->actual_length < ETH_ZLEN) -+ goto submit; -+ -+ rx_desc = agg->head; -+ rx_data = agg->head; -+ len_used += sizeof(struct rx_desc); -+ -+ while (urb->actual_length > len_used) { -+ struct net_device *netdev = tp->netdev; -+ struct net_device_stats *stats = &netdev->stats; -+ unsigned int pkt_len; -+ struct sk_buff *skb; -+ -+ pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK; -+ if (pkt_len < ETH_ZLEN) -+ break; -+ -+ len_used += pkt_len; -+ if (urb->actual_length < len_used) -+ break; -+ -+ pkt_len -= CRC_SIZE; -+ rx_data += sizeof(struct rx_desc); -+ -+ skb = netdev_alloc_skb_ip_align(netdev, pkt_len); -+ if (!skb) { -+ stats->rx_dropped++; -+ goto find_next_rx; -+ } -+ -+ skb->ip_summed = r8152_rx_csum(tp, rx_desc); -+ memcpy(skb->data, rx_data, pkt_len); -+ skb_put(skb, pkt_len); -+ skb->protocol = eth_type_trans(skb, netdev); -+ rtl_rx_vlan_tag(rx_desc, skb); -+ netif_receive_skb(skb); -+ stats->rx_packets++; -+ stats->rx_bytes += pkt_len; -+ -+find_next_rx: -+ rx_data = rx_agg_align(rx_data + pkt_len + CRC_SIZE); -+ rx_desc = (struct rx_desc *)rx_data; -+ len_used = (int)(rx_data - (u8 *)agg->head); -+ len_used += sizeof(struct rx_desc); -+ } -+ -+submit: -+ ret = r8152_submit_rx(tp, agg, GFP_ATOMIC); -+ if (ret && ret != -ENODEV) { -+ spin_lock_irqsave(&tp->rx_lock, flags); -+ list_add_tail(&agg->list, &tp->rx_done); -+ spin_unlock_irqrestore(&tp->rx_lock, flags); -+ tasklet_schedule(&tp->tl); -+ } -+ } -+} -+ -+static void tx_bottom(struct r8152 *tp) -+{ -+ int res; -+ -+ do { -+ struct tx_agg *agg; -+ -+ if (skb_queue_empty(&tp->tx_queue)) -+ break; -+ -+ agg = r8152_get_tx_agg(tp); -+ if (!agg) -+ break; -+ -+ res = r8152_tx_agg_fill(tp, agg); -+ if (res) { -+ struct net_device *netdev = tp->netdev; -+ -+ if (res == -ENODEV) { -+ netif_device_detach(netdev); -+ } else { -+ struct net_device_stats *stats = &netdev->stats; -+ unsigned long flags; -+ -+ netif_warn(tp, tx_err, netdev, -+ "failed tx_urb %d\n", res); -+ stats->tx_dropped += agg->skb_num; -+ -+ spin_lock_irqsave(&tp->tx_lock, flags); -+ list_add_tail(&agg->list, &tp->tx_free); -+ spin_unlock_irqrestore(&tp->tx_lock, flags); -+ } -+ } -+ } while (res == 0); -+} -+ -+static void bottom_half(unsigned long data) -+{ -+ struct r8152 *tp; -+ -+ tp = (struct r8152 *)data; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ if (!test_bit(WORK_ENABLE, &tp->flags)) -+ return; -+ -+ /* When link down, the driver would cancel all bulks. */ -+ /* This avoid the re-submitting bulk */ -+ if (!netif_carrier_ok(tp->netdev)) -+ return; -+ -+ rx_bottom(tp); -+ tx_bottom(tp); -+} -+ -+static -+int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags) -+{ -+ usb_fill_bulk_urb(agg->urb, tp->udev, usb_rcvbulkpipe(tp->udev, 1), -+ agg->head, agg_buf_sz, -+ (usb_complete_t)read_bulk_callback, agg); -+ -+ return usb_submit_urb(agg->urb, mem_flags); -+} -+ -+static void rtl_drop_queued_tx(struct r8152 *tp) -+{ -+ struct net_device_stats *stats = &tp->netdev->stats; -+ struct sk_buff_head skb_head, *tx_queue = &tp->tx_queue; -+ struct sk_buff *skb; -+ -+ if (skb_queue_empty(tx_queue)) -+ return; -+ -+ __skb_queue_head_init(&skb_head); -+ spin_lock_bh(&tx_queue->lock); -+ skb_queue_splice_init(tx_queue, &skb_head); -+ spin_unlock_bh(&tx_queue->lock); -+ -+ while ((skb = __skb_dequeue(&skb_head))) { -+ dev_kfree_skb(skb); -+ stats->tx_dropped++; -+ } -+} -+ -+static void rtl8152_tx_timeout(struct net_device *netdev) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ int i; -+ -+ netif_warn(tp, tx_err, netdev, "Tx timeout\n"); -+ for (i = 0; i < RTL8152_MAX_TX; i++) -+ usb_unlink_urb(tp->tx_info[i].urb); -+} -+ -+static void rtl8152_set_rx_mode(struct net_device *netdev) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ -+ if (tp->speed & LINK_STATUS) { -+ set_bit(RTL8152_SET_RX_MODE, &tp->flags); -+ schedule_delayed_work(&tp->schedule, 0); -+ } -+} -+ -+static void _rtl8152_set_rx_mode(struct net_device *netdev) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ u32 mc_filter[2]; /* Multicast hash filter */ -+ __le32 tmp[2]; -+ u32 ocp_data; -+ -+ clear_bit(RTL8152_SET_RX_MODE, &tp->flags); -+ netif_stop_queue(netdev); -+ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); -+ ocp_data &= ~RCR_ACPT_ALL; -+ ocp_data |= RCR_AB | RCR_APM; -+ -+ if (netdev->flags & IFF_PROMISC) { -+ /* Unconditionally log net taps. */ -+ netif_notice(tp, link, netdev, "Promiscuous mode enabled\n"); -+ ocp_data |= RCR_AM | RCR_AAP; -+ mc_filter[1] = 0xffffffff; -+ mc_filter[0] = 0xffffffff; -+ } else if ((netdev_mc_count(netdev) > multicast_filter_limit) || -+ (netdev->flags & IFF_ALLMULTI)) { -+ /* Too many to filter perfectly -- accept all multicasts. */ -+ ocp_data |= RCR_AM; -+ mc_filter[1] = 0xffffffff; -+ mc_filter[0] = 0xffffffff; -+ } else { -+ struct netdev_hw_addr *ha; -+ -+ mc_filter[1] = 0; -+ mc_filter[0] = 0; -+ netdev_for_each_mc_addr(ha, netdev) { -+ int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; -+ -+ mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); -+ ocp_data |= RCR_AM; -+ } -+ } -+ -+ tmp[0] = __cpu_to_le32(swab32(mc_filter[1])); -+ tmp[1] = __cpu_to_le32(swab32(mc_filter[0])); -+ -+ pla_ocp_write(tp, PLA_MAR, BYTE_EN_DWORD, sizeof(tmp), tmp); -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); -+ netif_wake_queue(netdev); -+} -+ -+static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb, -+ struct net_device *netdev) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ -+ skb_tx_timestamp(skb); -+ -+ skb_queue_tail(&tp->tx_queue, skb); -+ -+ if (!list_empty(&tp->tx_free)) { -+ if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { -+ set_bit(SCHEDULE_TASKLET, &tp->flags); -+ schedule_delayed_work(&tp->schedule, 0); -+ } else { -+ usb_mark_last_busy(tp->udev); -+ tasklet_schedule(&tp->tl); -+ } -+ } else if (skb_queue_len(&tp->tx_queue) > tp->tx_qlen) { -+ netif_stop_queue(netdev); -+ } -+ -+ return NETDEV_TX_OK; -+} -+ -+static void r8152b_reset_packet_filter(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_FMC); -+ ocp_data &= ~FMC_FCR_MCU_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_FMC, ocp_data); -+ ocp_data |= FMC_FCR_MCU_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_FMC, ocp_data); -+} -+ -+static void rtl8152_nic_reset(struct r8152 *tp) -+{ -+ int i; -+ -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, CR_RST); -+ -+ for (i = 0; i < 1000; i++) { -+ if (!(ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CR) & CR_RST)) -+ break; -+ usleep_range(100, 400); -+ } -+} -+ -+static void set_tx_qlen(struct r8152 *tp) -+{ -+ struct net_device *netdev = tp->netdev; -+ -+ tp->tx_qlen = agg_buf_sz / (netdev->mtu + VLAN_ETH_HLEN + VLAN_HLEN + -+ sizeof(struct tx_desc)); -+} -+ -+static inline u8 rtl8152_get_speed(struct r8152 *tp) -+{ -+ return ocp_read_byte(tp, MCU_TYPE_PLA, PLA_PHYSTATUS); -+} -+ -+static void rtl_set_eee_plus(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ u8 speed; -+ -+ speed = rtl8152_get_speed(tp); -+ if (speed & _10bps) { -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR); -+ ocp_data |= EEEP_CR_EEEP_TX; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data); -+ } else { -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR); -+ ocp_data &= ~EEEP_CR_EEEP_TX; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data); -+ } -+} -+ -+static void rxdy_gated_en(struct r8152 *tp, bool enable) -+{ -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MISC_1); -+ if (enable) -+ ocp_data |= RXDY_GATED_EN; -+ else -+ ocp_data &= ~RXDY_GATED_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MISC_1, ocp_data); -+} -+ -+static int rtl_start_rx(struct r8152 *tp) -+{ -+ int i, ret = 0; -+ -+ INIT_LIST_HEAD(&tp->rx_done); -+ for (i = 0; i < RTL8152_MAX_RX; i++) { -+ INIT_LIST_HEAD(&tp->rx_info[i].list); -+ ret = r8152_submit_rx(tp, &tp->rx_info[i], GFP_KERNEL); -+ if (ret) -+ break; -+ } -+ -+ return ret; -+} -+ -+static int rtl_stop_rx(struct r8152 *tp) -+{ -+ int i; -+ -+ for (i = 0; i < RTL8152_MAX_RX; i++) -+ usb_kill_urb(tp->rx_info[i].urb); -+ -+ return 0; -+} -+ -+static int rtl_enable(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ -+ r8152b_reset_packet_filter(tp); -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CR); -+ ocp_data |= CR_RE | CR_TE; -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, ocp_data); -+ -+ rxdy_gated_en(tp, false); -+ -+ return rtl_start_rx(tp); -+} -+ -+static int rtl8152_enable(struct r8152 *tp) -+{ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return -ENODEV; -+ -+ set_tx_qlen(tp); -+ rtl_set_eee_plus(tp); -+ -+ return rtl_enable(tp); -+} -+ -+static void r8153_set_rx_agg(struct r8152 *tp) -+{ -+ u8 speed; -+ -+ speed = rtl8152_get_speed(tp); -+ if (speed & _1000bps) { -+ if (tp->udev->speed == USB_SPEED_SUPER) { -+ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, -+ RX_THR_SUPPER); -+ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_EARLY_AGG, -+ EARLY_AGG_SUPPER); -+ } else { -+ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, -+ RX_THR_HIGH); -+ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_EARLY_AGG, -+ EARLY_AGG_HIGH); -+ } -+ } else { -+ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, RX_THR_SLOW); -+ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_EARLY_AGG, -+ EARLY_AGG_SLOW); -+ } -+} -+ -+static int rtl8153_enable(struct r8152 *tp) -+{ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return -ENODEV; -+ -+ set_tx_qlen(tp); -+ rtl_set_eee_plus(tp); -+ r8153_set_rx_agg(tp); -+ -+ return rtl_enable(tp); -+} -+ -+static void rtl_disable(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ int i; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) { -+ rtl_drop_queued_tx(tp); -+ return; -+ } -+ -+ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); -+ ocp_data &= ~RCR_ACPT_ALL; -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); -+ -+ rtl_drop_queued_tx(tp); -+ -+ for (i = 0; i < RTL8152_MAX_TX; i++) -+ usb_kill_urb(tp->tx_info[i].urb); -+ -+ rxdy_gated_en(tp, true); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if ((ocp_data & FIFO_EMPTY) == FIFO_EMPTY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ for (i = 0; i < 1000; i++) { -+ if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0) & TCR0_TX_EMPTY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ rtl_stop_rx(tp); -+ -+ rtl8152_nic_reset(tp); -+} -+ -+static void r8152_power_cut_en(struct r8152 *tp, bool enable) -+{ -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_UPS_CTRL); -+ if (enable) -+ ocp_data |= POWER_CUT; -+ else -+ ocp_data &= ~POWER_CUT; -+ ocp_write_word(tp, MCU_TYPE_USB, USB_UPS_CTRL, ocp_data); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS); -+ ocp_data &= ~RESUME_INDICATE; -+ ocp_write_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS, ocp_data); -+} -+ -+static void rtl_rx_vlan_en(struct r8152 *tp, bool enable) -+{ -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CPCR); -+ if (enable) -+ ocp_data |= CPCR_RX_VLAN; -+ else -+ ocp_data &= ~CPCR_RX_VLAN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CPCR, ocp_data); -+} -+ -+static int rtl8152_set_features(struct net_device *dev, -+ netdev_features_t features) -+{ -+ netdev_features_t changed = features ^ dev->features; -+ struct r8152 *tp = netdev_priv(dev); -+ int ret; -+ -+ ret = usb_autopm_get_interface(tp->intf); -+ if (ret < 0) -+ goto out; -+ -+ mutex_lock(&tp->control); -+ -+ if (changed & NETIF_F_HW_VLAN_CTAG_RX) { -+ if (features & NETIF_F_HW_VLAN_CTAG_RX) -+ rtl_rx_vlan_en(tp, true); -+ else -+ rtl_rx_vlan_en(tp, false); -+ } -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+ -+out: -+ return ret; -+} -+ -+#define WAKE_ANY (WAKE_PHY | WAKE_MAGIC | WAKE_UCAST | WAKE_BCAST | WAKE_MCAST) -+ -+static u32 __rtl_get_wol(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ u32 wolopts = 0; -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CONFIG5); -+ if (!(ocp_data & LAN_WAKE_EN)) -+ return 0; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CONFIG34); -+ if (ocp_data & LINK_ON_WAKE_EN) -+ wolopts |= WAKE_PHY; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CONFIG5); -+ if (ocp_data & UWF_EN) -+ wolopts |= WAKE_UCAST; -+ if (ocp_data & BWF_EN) -+ wolopts |= WAKE_BCAST; -+ if (ocp_data & MWF_EN) -+ wolopts |= WAKE_MCAST; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CFG_WOL); -+ if (ocp_data & MAGIC_EN) -+ wolopts |= WAKE_MAGIC; -+ -+ return wolopts; -+} -+ -+static void __rtl_set_wol(struct r8152 *tp, u32 wolopts) -+{ -+ u32 ocp_data; -+ -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CONFIG34); -+ ocp_data &= ~LINK_ON_WAKE_EN; -+ if (wolopts & WAKE_PHY) -+ ocp_data |= LINK_ON_WAKE_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CONFIG34, ocp_data); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CONFIG5); -+ ocp_data &= ~(UWF_EN | BWF_EN | MWF_EN | LAN_WAKE_EN); -+ if (wolopts & WAKE_UCAST) -+ ocp_data |= UWF_EN; -+ if (wolopts & WAKE_BCAST) -+ ocp_data |= BWF_EN; -+ if (wolopts & WAKE_MCAST) -+ ocp_data |= MWF_EN; -+ if (wolopts & WAKE_ANY) -+ ocp_data |= LAN_WAKE_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CONFIG5, ocp_data); -+ -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CFG_WOL); -+ ocp_data &= ~MAGIC_EN; -+ if (wolopts & WAKE_MAGIC) -+ ocp_data |= MAGIC_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CFG_WOL, ocp_data); -+ -+ if (wolopts & WAKE_ANY) -+ device_set_wakeup_enable(&tp->udev->dev, true); -+ else -+ device_set_wakeup_enable(&tp->udev->dev, false); -+} -+ -+static void rtl_runtime_suspend_enable(struct r8152 *tp, bool enable) -+{ -+ if (enable) { -+ u32 ocp_data; -+ -+ __rtl_set_wol(tp, WAKE_ANY); -+ -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CONFIG34); -+ ocp_data |= LINK_OFF_WAKE_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CONFIG34, ocp_data); -+ -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); -+ } else { -+ __rtl_set_wol(tp, tp->saved_wolopts); -+ } -+} -+ -+static void rtl_phy_reset(struct r8152 *tp) -+{ -+ u16 data; -+ int i; -+ -+ clear_bit(PHY_RESET, &tp->flags); -+ -+ data = r8152_mdio_read(tp, MII_BMCR); -+ -+ /* don't reset again before the previous one complete */ -+ if (data & BMCR_RESET) -+ return; -+ -+ data |= BMCR_RESET; -+ r8152_mdio_write(tp, MII_BMCR, data); -+ -+ for (i = 0; i < 50; i++) { -+ msleep(20); -+ if ((r8152_mdio_read(tp, MII_BMCR) & BMCR_RESET) == 0) -+ break; -+ } -+} -+ -+static void r8153_teredo_off(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG); -+ ocp_data &= ~(TEREDO_SEL | TEREDO_RS_EVENT_MASK | OOB_TEREDO_EN); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG, ocp_data); -+ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_WDT6_CTRL, WDT6_SET_MODE); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_REALWOW_TIMER, 0); -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TEREDO_TIMER, 0); -+} -+ -+static void r8152b_disable_aldps(struct r8152 *tp) -+{ -+ ocp_reg_write(tp, OCP_ALDPS_CONFIG, ENPDNPS | LINKENA | DIS_SDSAVE); -+ msleep(20); -+} -+ -+static inline void r8152b_enable_aldps(struct r8152 *tp) -+{ -+ ocp_reg_write(tp, OCP_ALDPS_CONFIG, ENPWRSAVE | ENPDNPS | -+ LINKENA | DIS_SDSAVE); -+} -+ -+static void rtl8152_disable(struct r8152 *tp) -+{ -+ r8152b_disable_aldps(tp); -+ rtl_disable(tp); -+ r8152b_enable_aldps(tp); -+} -+ -+static void r8152b_hw_phy_cfg(struct r8152 *tp) -+{ -+ u16 data; -+ -+ data = r8152_mdio_read(tp, MII_BMCR); -+ if (data & BMCR_PDOWN) { -+ data &= ~BMCR_PDOWN; -+ r8152_mdio_write(tp, MII_BMCR, data); -+ } -+ -+ set_bit(PHY_RESET, &tp->flags); -+} -+ -+static void r8152b_exit_oob(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ int i; -+ -+ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); -+ ocp_data &= ~RCR_ACPT_ALL; -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); -+ -+ rxdy_gated_en(tp, true); -+ r8153_teredo_off(tp); -+ r8152b_hw_phy_cfg(tp); -+ -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, 0x00); -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ ocp_data &= ~NOW_IS_OOB; -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); -+ ocp_data &= ~MCU_BORW_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if (ocp_data & LINK_LIST_READY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); -+ ocp_data |= RE_INIT_LL; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if (ocp_data & LINK_LIST_READY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ rtl8152_nic_reset(tp); -+ -+ /* rx share fifo credit full threshold */ -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_NORMAL); -+ -+ if (tp->udev->speed == USB_SPEED_FULL || -+ tp->udev->speed == USB_SPEED_LOW) { -+ /* rx share fifo credit near full threshold */ -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, -+ RXFIFO_THR2_FULL); -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, -+ RXFIFO_THR3_FULL); -+ } else { -+ /* rx share fifo credit near full threshold */ -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, -+ RXFIFO_THR2_HIGH); -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, -+ RXFIFO_THR3_HIGH); -+ } -+ -+ /* TX share fifo free credit full threshold */ -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TXFIFO_CTRL, TXFIFO_THR_NORMAL); -+ -+ ocp_write_byte(tp, MCU_TYPE_USB, USB_TX_AGG, TX_AGG_MAX_THRESHOLD); -+ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, RX_THR_HIGH); -+ ocp_write_dword(tp, MCU_TYPE_USB, USB_TX_DMA, -+ TEST_MODE_DISABLE | TX_SIZE_ADJUST1); -+ -+ rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); -+ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8152_RMS); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0); -+ ocp_data |= TCR0_AUTO_FIFO; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_TCR0, ocp_data); -+} -+ -+static void r8152b_enter_oob(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ int i; -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ ocp_data &= ~NOW_IS_OOB; -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); -+ -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_OOB); -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB); -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB); -+ -+ rtl_disable(tp); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if (ocp_data & LINK_LIST_READY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); -+ ocp_data |= RE_INIT_LL; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if (ocp_data & LINK_LIST_READY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8152_RMS); -+ -+ rtl_rx_vlan_en(tp, true); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PAL_BDC_CR); -+ ocp_data |= ALDPS_PROXY_MODE; -+ ocp_write_word(tp, MCU_TYPE_PLA, PAL_BDC_CR, ocp_data); -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB; -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); -+ -+ rxdy_gated_en(tp, false); -+ -+ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); -+ ocp_data |= RCR_APM | RCR_AM | RCR_AB; -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); -+} -+ -+static void r8153_hw_phy_cfg(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ u16 data; -+ -+ ocp_reg_write(tp, OCP_ADC_CFG, CKADSEL_L | ADC_EN | EN_EMI_L); -+ data = r8152_mdio_read(tp, MII_BMCR); -+ if (data & BMCR_PDOWN) { -+ data &= ~BMCR_PDOWN; -+ r8152_mdio_write(tp, MII_BMCR, data); -+ } -+ -+ if (tp->version == RTL_VER_03) { -+ data = ocp_reg_read(tp, OCP_EEE_CFG); -+ data &= ~CTAP_SHORT_EN; -+ ocp_reg_write(tp, OCP_EEE_CFG, data); -+ } -+ -+ data = ocp_reg_read(tp, OCP_POWER_CFG); -+ data |= EEE_CLKDIV_EN; -+ ocp_reg_write(tp, OCP_POWER_CFG, data); -+ -+ data = ocp_reg_read(tp, OCP_DOWN_SPEED); -+ data |= EN_10M_BGOFF; -+ ocp_reg_write(tp, OCP_DOWN_SPEED, data); -+ data = ocp_reg_read(tp, OCP_POWER_CFG); -+ data |= EN_10M_PLLOFF; -+ ocp_reg_write(tp, OCP_POWER_CFG, data); -+ data = sram_read(tp, SRAM_IMPEDANCE); -+ data &= ~RX_DRIVING_MASK; -+ sram_write(tp, SRAM_IMPEDANCE, data); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR); -+ ocp_data |= PFM_PWM_SWITCH; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR, ocp_data); -+ -+ data = sram_read(tp, SRAM_LPF_CFG); -+ data |= LPF_AUTO_TUNE; -+ sram_write(tp, SRAM_LPF_CFG, data); -+ -+ data = sram_read(tp, SRAM_10M_AMP1); -+ data |= GDAC_IB_UPALL; -+ sram_write(tp, SRAM_10M_AMP1, data); -+ data = sram_read(tp, SRAM_10M_AMP2); -+ data |= AMP_DN; -+ sram_write(tp, SRAM_10M_AMP2, data); -+ -+ set_bit(PHY_RESET, &tp->flags); -+} -+ -+static void r8153_u1u2en(struct r8152 *tp, bool enable) -+{ -+ u8 u1u2[8]; -+ -+ if (enable) -+ memset(u1u2, 0xff, sizeof(u1u2)); -+ else -+ memset(u1u2, 0x00, sizeof(u1u2)); -+ -+ usb_ocp_write(tp, USB_TOLERANCE, BYTE_EN_SIX_BYTES, sizeof(u1u2), u1u2); -+} -+ -+static void r8153_u2p3en(struct r8152 *tp, bool enable) -+{ -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL); -+ if (enable) -+ ocp_data |= U2P3_ENABLE; -+ else -+ ocp_data &= ~U2P3_ENABLE; -+ ocp_write_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL, ocp_data); -+} -+ -+static void r8153_power_cut_en(struct r8152 *tp, bool enable) -+{ -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_POWER_CUT); -+ if (enable) -+ ocp_data |= PWR_EN | PHASE2_EN; -+ else -+ ocp_data &= ~(PWR_EN | PHASE2_EN); -+ ocp_write_word(tp, MCU_TYPE_USB, USB_POWER_CUT, ocp_data); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0); -+ ocp_data &= ~PCUT_STATUS; -+ ocp_write_word(tp, MCU_TYPE_USB, USB_MISC_0, ocp_data); -+} -+ -+static void r8153_first_init(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ int i; -+ -+ rxdy_gated_en(tp, true); -+ r8153_teredo_off(tp); -+ -+ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); -+ ocp_data &= ~RCR_ACPT_ALL; -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); -+ -+ r8153_hw_phy_cfg(tp); -+ -+ rtl8152_nic_reset(tp); -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ ocp_data &= ~NOW_IS_OOB; -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); -+ ocp_data &= ~MCU_BORW_EN; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if (ocp_data & LINK_LIST_READY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); -+ ocp_data |= RE_INIT_LL; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if (ocp_data & LINK_LIST_READY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ rtl_rx_vlan_en(tp, tp->netdev->features & NETIF_F_HW_VLAN_CTAG_RX); -+ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS); -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_MTPS, MTPS_JUMBO); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0); -+ ocp_data |= TCR0_AUTO_FIFO; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_TCR0, ocp_data); -+ -+ rtl8152_nic_reset(tp); -+ -+ /* rx share fifo credit full threshold */ -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_NORMAL); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_NORMAL); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_NORMAL); -+ /* TX share fifo free credit full threshold */ -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TXFIFO_CTRL, TXFIFO_THR_NORMAL2); -+ -+ /* rx aggregation */ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL); -+ ocp_data &= ~RX_AGG_DISABLE; -+ ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data); -+} -+ -+static void r8153_enter_oob(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ int i; -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ ocp_data &= ~NOW_IS_OOB; -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); -+ -+ rtl_disable(tp); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if (ocp_data & LINK_LIST_READY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); -+ ocp_data |= RE_INIT_LL; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); -+ -+ for (i = 0; i < 1000; i++) { -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ if (ocp_data & LINK_LIST_READY) -+ break; -+ usleep_range(1000, 2000); -+ } -+ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8153_RMS); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG); -+ ocp_data &= ~TEREDO_WAKE_MASK; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG, ocp_data); -+ -+ rtl_rx_vlan_en(tp, true); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PAL_BDC_CR); -+ ocp_data |= ALDPS_PROXY_MODE; -+ ocp_write_word(tp, MCU_TYPE_PLA, PAL_BDC_CR, ocp_data); -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); -+ ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB; -+ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); -+ -+ rxdy_gated_en(tp, false); -+ -+ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); -+ ocp_data |= RCR_APM | RCR_AM | RCR_AB; -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); -+} -+ -+static void r8153_disable_aldps(struct r8152 *tp) -+{ -+ u16 data; -+ -+ data = ocp_reg_read(tp, OCP_POWER_CFG); -+ data &= ~EN_ALDPS; -+ ocp_reg_write(tp, OCP_POWER_CFG, data); -+ msleep(20); -+} -+ -+static void r8153_enable_aldps(struct r8152 *tp) -+{ -+ u16 data; -+ -+ data = ocp_reg_read(tp, OCP_POWER_CFG); -+ data |= EN_ALDPS; -+ ocp_reg_write(tp, OCP_POWER_CFG, data); -+} -+ -+static void rtl8153_disable(struct r8152 *tp) -+{ -+ r8153_disable_aldps(tp); -+ rtl_disable(tp); -+ r8153_enable_aldps(tp); -+} -+ -+static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) -+{ -+ u16 bmcr, anar, gbcr; -+ int ret = 0; -+ -+ cancel_delayed_work_sync(&tp->schedule); -+ anar = r8152_mdio_read(tp, MII_ADVERTISE); -+ anar &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL | -+ ADVERTISE_100HALF | ADVERTISE_100FULL); -+ if (tp->mii.supports_gmii) { -+ gbcr = r8152_mdio_read(tp, MII_CTRL1000); -+ gbcr &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); -+ } else { -+ gbcr = 0; -+ } -+ -+ if (autoneg == AUTONEG_DISABLE) { -+ if (speed == SPEED_10) { -+ bmcr = 0; -+ anar |= ADVERTISE_10HALF | ADVERTISE_10FULL; -+ } else if (speed == SPEED_100) { -+ bmcr = BMCR_SPEED100; -+ anar |= ADVERTISE_100HALF | ADVERTISE_100FULL; -+ } else if (speed == SPEED_1000 && tp->mii.supports_gmii) { -+ bmcr = BMCR_SPEED1000; -+ gbcr |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; -+ } else { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ if (duplex == DUPLEX_FULL) -+ bmcr |= BMCR_FULLDPLX; -+ } else { -+ if (speed == SPEED_10) { -+ if (duplex == DUPLEX_FULL) -+ anar |= ADVERTISE_10HALF | ADVERTISE_10FULL; -+ else -+ anar |= ADVERTISE_10HALF; -+ } else if (speed == SPEED_100) { -+ if (duplex == DUPLEX_FULL) { -+ anar |= ADVERTISE_10HALF | ADVERTISE_10FULL; -+ anar |= ADVERTISE_100HALF | ADVERTISE_100FULL; -+ } else { -+ anar |= ADVERTISE_10HALF; -+ anar |= ADVERTISE_100HALF; -+ } -+ } else if (speed == SPEED_1000 && tp->mii.supports_gmii) { -+ if (duplex == DUPLEX_FULL) { -+ anar |= ADVERTISE_10HALF | ADVERTISE_10FULL; -+ anar |= ADVERTISE_100HALF | ADVERTISE_100FULL; -+ gbcr |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; -+ } else { -+ anar |= ADVERTISE_10HALF; -+ anar |= ADVERTISE_100HALF; -+ gbcr |= ADVERTISE_1000HALF; -+ } -+ } else { -+ ret = -EINVAL; -+ goto out; -+ } -+ -+ bmcr = BMCR_ANENABLE | BMCR_ANRESTART; -+ } -+ -+ if (test_bit(PHY_RESET, &tp->flags)) -+ bmcr |= BMCR_RESET; -+ -+ if (tp->mii.supports_gmii) -+ r8152_mdio_write(tp, MII_CTRL1000, gbcr); -+ -+ r8152_mdio_write(tp, MII_ADVERTISE, anar); -+ r8152_mdio_write(tp, MII_BMCR, bmcr); -+ -+ if (test_bit(PHY_RESET, &tp->flags)) { -+ int i; -+ -+ clear_bit(PHY_RESET, &tp->flags); -+ for (i = 0; i < 50; i++) { -+ msleep(20); -+ if ((r8152_mdio_read(tp, MII_BMCR) & BMCR_RESET) == 0) -+ break; -+ } -+ } -+ -+out: -+ -+ return ret; -+} -+ -+static void rtl8152_up(struct r8152 *tp) -+{ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ r8152b_disable_aldps(tp); -+ r8152b_exit_oob(tp); -+ r8152b_enable_aldps(tp); -+} -+ -+static void rtl8152_down(struct r8152 *tp) -+{ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) { -+ rtl_drop_queued_tx(tp); -+ return; -+ } -+ -+ r8152_power_cut_en(tp, false); -+ r8152b_disable_aldps(tp); -+ r8152b_enter_oob(tp); -+ r8152b_enable_aldps(tp); -+} -+ -+static void rtl8153_up(struct r8152 *tp) -+{ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ r8153_disable_aldps(tp); -+ r8153_first_init(tp); -+ r8153_enable_aldps(tp); -+} -+ -+static void rtl8153_down(struct r8152 *tp) -+{ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) { -+ rtl_drop_queued_tx(tp); -+ return; -+ } -+ -+ r8153_u1u2en(tp, false); -+ r8153_power_cut_en(tp, false); -+ r8153_disable_aldps(tp); -+ r8153_enter_oob(tp); -+ r8153_enable_aldps(tp); -+} -+ -+static void set_carrier(struct r8152 *tp) -+{ -+ struct net_device *netdev = tp->netdev; -+ u8 speed; -+ -+ clear_bit(RTL8152_LINK_CHG, &tp->flags); -+ speed = rtl8152_get_speed(tp); -+ -+ if (speed & LINK_STATUS) { -+ if (!(tp->speed & LINK_STATUS)) { -+ tp->rtl_ops.enable(tp); -+ set_bit(RTL8152_SET_RX_MODE, &tp->flags); -+ netif_carrier_on(netdev); -+ } -+ } else { -+ if (tp->speed & LINK_STATUS) { -+ netif_carrier_off(netdev); -+ tasklet_disable(&tp->tl); -+ tp->rtl_ops.disable(tp); -+ tasklet_enable(&tp->tl); -+ } -+ } -+ tp->speed = speed; -+} -+ -+static void rtl_work_func_t(struct work_struct *work) -+{ -+ struct r8152 *tp = container_of(work, struct r8152, schedule.work); -+ -+ if (usb_autopm_get_interface(tp->intf) < 0) -+ return; -+ -+ if (!test_bit(WORK_ENABLE, &tp->flags)) -+ goto out1; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ goto out1; -+ -+ if (!mutex_trylock(&tp->control)) { -+ schedule_delayed_work(&tp->schedule, 0); -+ goto out1; -+ } -+ -+ if (test_bit(RTL8152_LINK_CHG, &tp->flags)) -+ set_carrier(tp); -+ -+ if (test_bit(RTL8152_SET_RX_MODE, &tp->flags)) -+ _rtl8152_set_rx_mode(tp->netdev); -+ -+ if (test_bit(SCHEDULE_TASKLET, &tp->flags) && -+ (tp->speed & LINK_STATUS)) { -+ clear_bit(SCHEDULE_TASKLET, &tp->flags); -+ tasklet_schedule(&tp->tl); -+ } -+ -+ if (test_bit(PHY_RESET, &tp->flags)) -+ rtl_phy_reset(tp); -+ -+ mutex_unlock(&tp->control); -+ -+out1: -+ usb_autopm_put_interface(tp->intf); -+} -+ -+static int rtl8152_open(struct net_device *netdev) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ int res = 0; -+ -+ res = alloc_all_mem(tp); -+ if (res) -+ goto out; -+ -+ /* set speed to 0 to avoid autoresume try to submit rx */ -+ tp->speed = 0; -+ -+ res = usb_autopm_get_interface(tp->intf); -+ if (res < 0) { -+ free_all_mem(tp); -+ goto out; -+ } -+ -+ mutex_lock(&tp->control); -+ -+ /* The WORK_ENABLE may be set when autoresume occurs */ -+ if (test_bit(WORK_ENABLE, &tp->flags)) { -+ clear_bit(WORK_ENABLE, &tp->flags); -+ usb_kill_urb(tp->intr_urb); -+ cancel_delayed_work_sync(&tp->schedule); -+ -+ /* disable the tx/rx, if the workqueue has enabled them. */ -+ if (tp->speed & LINK_STATUS) -+ tp->rtl_ops.disable(tp); -+ } -+ -+ tp->rtl_ops.up(tp); -+ -+ rtl8152_set_speed(tp, AUTONEG_ENABLE, -+ tp->mii.supports_gmii ? SPEED_1000 : SPEED_100, -+ DUPLEX_FULL); -+ tp->speed = 0; -+ netif_carrier_off(netdev); -+ netif_start_queue(netdev); -+ set_bit(WORK_ENABLE, &tp->flags); -+ -+ res = usb_submit_urb(tp->intr_urb, GFP_KERNEL); -+ if (res) { -+ if (res == -ENODEV) -+ netif_device_detach(tp->netdev); -+ netif_warn(tp, ifup, netdev, "intr_urb submit failed: %d\n", -+ res); -+ free_all_mem(tp); -+ } -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+ -+out: -+ return res; -+} -+ -+static int rtl8152_close(struct net_device *netdev) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ int res = 0; -+ -+ clear_bit(WORK_ENABLE, &tp->flags); -+ usb_kill_urb(tp->intr_urb); -+ cancel_delayed_work_sync(&tp->schedule); -+ netif_stop_queue(netdev); -+ -+ res = usb_autopm_get_interface(tp->intf); -+ if (res < 0) { -+ rtl_drop_queued_tx(tp); -+ } else { -+ mutex_lock(&tp->control); -+ -+ /* The autosuspend may have been enabled and wouldn't -+ * be disable when autoresume occurs, because the -+ * netif_running() would be false. -+ */ -+ rtl_runtime_suspend_enable(tp, false); -+ -+ tasklet_disable(&tp->tl); -+ tp->rtl_ops.down(tp); -+ tasklet_enable(&tp->tl); -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+ } -+ -+ free_all_mem(tp); -+ -+ return res; -+} -+ -+static inline void r8152_mmd_indirect(struct r8152 *tp, u16 dev, u16 reg) -+{ -+ ocp_reg_write(tp, OCP_EEE_AR, FUN_ADDR | dev); -+ ocp_reg_write(tp, OCP_EEE_DATA, reg); -+ ocp_reg_write(tp, OCP_EEE_AR, FUN_DATA | dev); -+} -+ -+static u16 r8152_mmd_read(struct r8152 *tp, u16 dev, u16 reg) -+{ -+ u16 data; -+ -+ r8152_mmd_indirect(tp, dev, reg); -+ data = ocp_reg_read(tp, OCP_EEE_DATA); -+ ocp_reg_write(tp, OCP_EEE_AR, 0x0000); -+ -+ return data; -+} -+ -+static void r8152_mmd_write(struct r8152 *tp, u16 dev, u16 reg, u16 data) -+{ -+ r8152_mmd_indirect(tp, dev, reg); -+ ocp_reg_write(tp, OCP_EEE_DATA, data); -+ ocp_reg_write(tp, OCP_EEE_AR, 0x0000); -+} -+ -+static void r8152_eee_en(struct r8152 *tp, bool enable) -+{ -+ u16 config1, config2, config3; -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEE_CR); -+ config1 = ocp_reg_read(tp, OCP_EEE_CONFIG1) & ~sd_rise_time_mask; -+ config2 = ocp_reg_read(tp, OCP_EEE_CONFIG2); -+ config3 = ocp_reg_read(tp, OCP_EEE_CONFIG3) & ~fast_snr_mask; -+ -+ if (enable) { -+ ocp_data |= EEE_RX_EN | EEE_TX_EN; -+ config1 |= EEE_10_CAP | EEE_NWAY_EN | TX_QUIET_EN | RX_QUIET_EN; -+ config1 |= sd_rise_time(1); -+ config2 |= RG_DACQUIET_EN | RG_LDVQUIET_EN; -+ config3 |= fast_snr(42); -+ } else { -+ ocp_data &= ~(EEE_RX_EN | EEE_TX_EN); -+ config1 &= ~(EEE_10_CAP | EEE_NWAY_EN | TX_QUIET_EN | -+ RX_QUIET_EN); -+ config1 |= sd_rise_time(7); -+ config2 &= ~(RG_DACQUIET_EN | RG_LDVQUIET_EN); -+ config3 |= fast_snr(511); -+ } -+ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEE_CR, ocp_data); -+ ocp_reg_write(tp, OCP_EEE_CONFIG1, config1); -+ ocp_reg_write(tp, OCP_EEE_CONFIG2, config2); -+ ocp_reg_write(tp, OCP_EEE_CONFIG3, config3); -+} -+ -+static void r8152b_enable_eee(struct r8152 *tp) -+{ -+ r8152_eee_en(tp, true); -+ r8152_mmd_write(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV, MDIO_EEE_100TX); -+} -+ -+static void r8153_eee_en(struct r8152 *tp, bool enable) -+{ -+ u32 ocp_data; -+ u16 config; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEE_CR); -+ config = ocp_reg_read(tp, OCP_EEE_CFG); -+ -+ if (enable) { -+ ocp_data |= EEE_RX_EN | EEE_TX_EN; -+ config |= EEE10_EN; -+ } else { -+ ocp_data &= ~(EEE_RX_EN | EEE_TX_EN); -+ config &= ~EEE10_EN; -+ } -+ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEE_CR, ocp_data); -+ ocp_reg_write(tp, OCP_EEE_CFG, config); -+} -+ -+static void r8153_enable_eee(struct r8152 *tp) -+{ -+ r8153_eee_en(tp, true); -+ ocp_reg_write(tp, OCP_EEE_ADV, MDIO_EEE_1000T | MDIO_EEE_100TX); -+} -+ -+static void r8152b_enable_fc(struct r8152 *tp) -+{ -+ u16 anar; -+ -+ anar = r8152_mdio_read(tp, MII_ADVERTISE); -+ anar |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM; -+ r8152_mdio_write(tp, MII_ADVERTISE, anar); -+} -+ -+static void rtl_tally_reset(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY); -+ ocp_data |= TALLY_RESET; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RSTTALLY, ocp_data); -+} -+ -+static void r8152b_init(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ r8152b_disable_aldps(tp); -+ -+ if (tp->version == RTL_VER_01) { -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); -+ ocp_data &= ~LED_MODE_MASK; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE, ocp_data); -+ } -+ -+ r8152_power_cut_en(tp, false); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR); -+ ocp_data |= TX_10M_IDLE_EN | PFM_PWM_SWITCH; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR, ocp_data); -+ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL); -+ ocp_data &= ~MCU_CLK_RATIO_MASK; -+ ocp_data |= MCU_CLK_RATIO | D3_CLK_GATED_EN; -+ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, ocp_data); -+ ocp_data = GPHY_STS_MSK | SPEED_DOWN_MSK | -+ SPDWN_RXDV_MSK | SPDWN_LINKCHG_MSK; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_GPHY_INTR_IMR, ocp_data); -+ -+ r8152b_enable_eee(tp); -+ r8152b_enable_aldps(tp); -+ r8152b_enable_fc(tp); -+ rtl_tally_reset(tp); -+ -+ /* enable rx aggregation */ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL); -+ ocp_data &= ~RX_AGG_DISABLE; -+ ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data); -+} -+ -+static void r8153_init(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ int i; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ r8153_disable_aldps(tp); -+ r8153_u1u2en(tp, false); -+ -+ for (i = 0; i < 500; i++) { -+ if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) & -+ AUTOLOAD_DONE) -+ break; -+ msleep(20); -+ } -+ -+ for (i = 0; i < 500; i++) { -+ ocp_data = ocp_reg_read(tp, OCP_PHY_STATUS) & PHY_STAT_MASK; -+ if (ocp_data == PHY_STAT_LAN_ON || ocp_data == PHY_STAT_PWRDN) -+ break; -+ msleep(20); -+ } -+ -+ r8153_u2p3en(tp, false); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_WDT11_CTRL); -+ ocp_data &= ~TIMER11_EN; -+ ocp_write_word(tp, MCU_TYPE_USB, USB_WDT11_CTRL, ocp_data); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); -+ ocp_data &= ~LED_MODE_MASK; -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE, ocp_data); -+ -+ ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_LPM_CTRL); -+ ocp_data &= ~LPM_TIMER_MASK; -+ if (tp->udev->speed == USB_SPEED_SUPER) -+ ocp_data |= LPM_TIMER_500US; -+ else -+ ocp_data |= LPM_TIMER_500MS; -+ ocp_write_byte(tp, MCU_TYPE_USB, USB_LPM_CTRL, ocp_data); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_AFE_CTRL2); -+ ocp_data &= ~SEN_VAL_MASK; -+ ocp_data |= SEN_VAL_NORMAL | SEL_RXIDLE; -+ ocp_write_word(tp, MCU_TYPE_USB, USB_AFE_CTRL2, ocp_data); -+ -+ r8153_power_cut_en(tp, false); -+ r8153_u1u2en(tp, true); -+ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, ALDPS_SPDWN_RATIO); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, EEE_SPDWN_RATIO); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, -+ PKT_AVAIL_SPDWN_EN | SUSPEND_SPDWN_EN | -+ U1U2_SPDWN_EN | L1_SPDWN_EN); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, -+ PWRSAVE_SPDWN_EN | RXDV_SPDWN_EN | TX10MIDLE_EN | -+ TP100_SPDWN_EN | TP500_SPDWN_EN | TP1000_SPDWN_EN | -+ EEE_SPDWN_EN); -+ -+ r8153_enable_eee(tp); -+ r8153_enable_aldps(tp); -+ r8152b_enable_fc(tp); -+ rtl_tally_reset(tp); -+} -+ -+static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message) -+{ -+ struct r8152 *tp = usb_get_intfdata(intf); -+ struct net_device *netdev = tp->netdev; -+ int ret = 0; -+ -+ mutex_lock(&tp->control); -+ -+ if (PMSG_IS_AUTO(message)) { -+ if (netif_running(netdev) && work_busy(&tp->schedule.work)) { -+ ret = -EBUSY; -+ goto out1; -+ } -+ -+ set_bit(SELECTIVE_SUSPEND, &tp->flags); -+ } else { -+ netif_device_detach(netdev); -+ } -+ -+ if (netif_running(netdev) && test_bit(WORK_ENABLE, &tp->flags)) { -+ clear_bit(WORK_ENABLE, &tp->flags); -+ usb_kill_urb(tp->intr_urb); -+ tasklet_disable(&tp->tl); -+ if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { -+ rtl_stop_rx(tp); -+ rtl_runtime_suspend_enable(tp, true); -+ } else { -+ cancel_delayed_work_sync(&tp->schedule); -+ tp->rtl_ops.down(tp); -+ } -+ tasklet_enable(&tp->tl); -+ } -+out1: -+ mutex_unlock(&tp->control); -+ -+ return ret; -+} -+ -+static int rtl8152_resume(struct usb_interface *intf) -+{ -+ struct r8152 *tp = usb_get_intfdata(intf); -+ -+ mutex_lock(&tp->control); -+ -+ if (!test_bit(SELECTIVE_SUSPEND, &tp->flags)) { -+ tp->rtl_ops.init(tp); -+ netif_device_attach(tp->netdev); -+ } -+ -+ if (netif_running(tp->netdev)) { -+ if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { -+ rtl_runtime_suspend_enable(tp, false); -+ clear_bit(SELECTIVE_SUSPEND, &tp->flags); -+ set_bit(WORK_ENABLE, &tp->flags); -+ if (tp->speed & LINK_STATUS) -+ rtl_start_rx(tp); -+ } else { -+ tp->rtl_ops.up(tp); -+ rtl8152_set_speed(tp, AUTONEG_ENABLE, -+ tp->mii.supports_gmii ? -+ SPEED_1000 : SPEED_100, -+ DUPLEX_FULL); -+ tp->speed = 0; -+ netif_carrier_off(tp->netdev); -+ set_bit(WORK_ENABLE, &tp->flags); -+ } -+ usb_submit_urb(tp->intr_urb, GFP_KERNEL); -+ } else if (test_bit(SELECTIVE_SUSPEND, &tp->flags)) { -+ clear_bit(SELECTIVE_SUSPEND, &tp->flags); -+ } -+ -+ mutex_unlock(&tp->control); -+ -+ return 0; -+} -+ -+static void rtl8152_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) -+{ -+ struct r8152 *tp = netdev_priv(dev); -+ -+ if (usb_autopm_get_interface(tp->intf) < 0) -+ return; -+ -+ mutex_lock(&tp->control); -+ -+ wol->supported = WAKE_ANY; -+ wol->wolopts = __rtl_get_wol(tp); -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+} -+ -+static int rtl8152_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) -+{ -+ struct r8152 *tp = netdev_priv(dev); -+ int ret; -+ -+ ret = usb_autopm_get_interface(tp->intf); -+ if (ret < 0) -+ goto out_set_wol; -+ -+ mutex_lock(&tp->control); -+ -+ __rtl_set_wol(tp, wol->wolopts); -+ tp->saved_wolopts = wol->wolopts & WAKE_ANY; -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+ -+out_set_wol: -+ return ret; -+} -+ -+static u32 rtl8152_get_msglevel(struct net_device *dev) -+{ -+ struct r8152 *tp = netdev_priv(dev); -+ -+ return tp->msg_enable; -+} -+ -+static void rtl8152_set_msglevel(struct net_device *dev, u32 value) -+{ -+ struct r8152 *tp = netdev_priv(dev); -+ -+ tp->msg_enable = value; -+} -+ -+static void rtl8152_get_drvinfo(struct net_device *netdev, -+ struct ethtool_drvinfo *info) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ -+ strlcpy(info->driver, MODULENAME, sizeof(info->driver)); -+ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); -+ usb_make_path(tp->udev, info->bus_info, sizeof(info->bus_info)); -+} -+ -+static -+int rtl8152_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ int ret; -+ -+ if (!tp->mii.mdio_read) -+ return -EOPNOTSUPP; -+ -+ ret = usb_autopm_get_interface(tp->intf); -+ if (ret < 0) -+ goto out; -+ -+ mutex_lock(&tp->control); -+ -+ ret = mii_ethtool_gset(&tp->mii, cmd); -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+ -+out: -+ return ret; -+} -+ -+static int rtl8152_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) -+{ -+ struct r8152 *tp = netdev_priv(dev); -+ int ret; -+ -+ ret = usb_autopm_get_interface(tp->intf); -+ if (ret < 0) -+ goto out; -+ -+ mutex_lock(&tp->control); -+ -+ ret = rtl8152_set_speed(tp, cmd->autoneg, cmd->speed, cmd->duplex); -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+ -+out: -+ return ret; -+} -+ -+static const char rtl8152_gstrings[][ETH_GSTRING_LEN] = { -+ "tx_packets", -+ "rx_packets", -+ "tx_errors", -+ "rx_errors", -+ "rx_missed", -+ "align_errors", -+ "tx_single_collisions", -+ "tx_multi_collisions", -+ "rx_unicast", -+ "rx_broadcast", -+ "rx_multicast", -+ "tx_aborted", -+ "tx_underrun", -+}; -+ -+static int rtl8152_get_sset_count(struct net_device *dev, int sset) -+{ -+ switch (sset) { -+ case ETH_SS_STATS: -+ return ARRAY_SIZE(rtl8152_gstrings); -+ default: -+ return -EOPNOTSUPP; -+ } -+} -+ -+static void rtl8152_get_ethtool_stats(struct net_device *dev, -+ struct ethtool_stats *stats, u64 *data) -+{ -+ struct r8152 *tp = netdev_priv(dev); -+ struct tally_counter tally; -+ -+ if (usb_autopm_get_interface(tp->intf) < 0) -+ return; -+ -+ generic_ocp_read(tp, PLA_TALLYCNT, sizeof(tally), &tally, MCU_TYPE_PLA); -+ -+ usb_autopm_put_interface(tp->intf); -+ -+ data[0] = le64_to_cpu(tally.tx_packets); -+ data[1] = le64_to_cpu(tally.rx_packets); -+ data[2] = le64_to_cpu(tally.tx_errors); -+ data[3] = le32_to_cpu(tally.rx_errors); -+ data[4] = le16_to_cpu(tally.rx_missed); -+ data[5] = le16_to_cpu(tally.align_errors); -+ data[6] = le32_to_cpu(tally.tx_one_collision); -+ data[7] = le32_to_cpu(tally.tx_multi_collision); -+ data[8] = le64_to_cpu(tally.rx_unicast); -+ data[9] = le64_to_cpu(tally.rx_broadcast); -+ data[10] = le32_to_cpu(tally.rx_multicast); -+ data[11] = le16_to_cpu(tally.tx_aborted); -+ data[12] = le16_to_cpu(tally.tx_underun); -+} -+ -+static void rtl8152_get_strings(struct net_device *dev, u32 stringset, u8 *data) -+{ -+ switch (stringset) { -+ case ETH_SS_STATS: -+ memcpy(data, *rtl8152_gstrings, sizeof(rtl8152_gstrings)); -+ break; -+ } -+} -+ -+static int r8152_get_eee(struct r8152 *tp, struct ethtool_eee *eee) -+{ -+ u32 ocp_data, lp, adv, supported = 0; -+ u16 val; -+ -+ val = r8152_mmd_read(tp, MDIO_MMD_PCS, MDIO_PCS_EEE_ABLE); -+ supported = mmd_eee_cap_to_ethtool_sup_t(val); -+ -+ val = r8152_mmd_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV); -+ adv = mmd_eee_adv_to_ethtool_adv_t(val); -+ -+ val = r8152_mmd_read(tp, MDIO_MMD_AN, MDIO_AN_EEE_LPABLE); -+ lp = mmd_eee_adv_to_ethtool_adv_t(val); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEE_CR); -+ ocp_data &= EEE_RX_EN | EEE_TX_EN; -+ -+ eee->eee_enabled = !!ocp_data; -+ eee->eee_active = !!(supported & adv & lp); -+ eee->supported = supported; -+ eee->advertised = adv; -+ eee->lp_advertised = lp; -+ -+ return 0; -+} -+ -+static int r8152_set_eee(struct r8152 *tp, struct ethtool_eee *eee) -+{ -+ u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised); -+ -+ r8152_eee_en(tp, eee->eee_enabled); -+ -+ if (!eee->eee_enabled) -+ val = 0; -+ -+ r8152_mmd_write(tp, MDIO_MMD_AN, MDIO_AN_EEE_ADV, val); -+ -+ return 0; -+} -+ -+static int r8153_get_eee(struct r8152 *tp, struct ethtool_eee *eee) -+{ -+ u32 ocp_data, lp, adv, supported = 0; -+ u16 val; -+ -+ val = ocp_reg_read(tp, OCP_EEE_ABLE); -+ supported = mmd_eee_cap_to_ethtool_sup_t(val); -+ -+ val = ocp_reg_read(tp, OCP_EEE_ADV); -+ adv = mmd_eee_adv_to_ethtool_adv_t(val); -+ -+ val = ocp_reg_read(tp, OCP_EEE_LPABLE); -+ lp = mmd_eee_adv_to_ethtool_adv_t(val); -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEE_CR); -+ ocp_data &= EEE_RX_EN | EEE_TX_EN; -+ -+ eee->eee_enabled = !!ocp_data; -+ eee->eee_active = !!(supported & adv & lp); -+ eee->supported = supported; -+ eee->advertised = adv; -+ eee->lp_advertised = lp; -+ -+ return 0; -+} -+ -+static int r8153_set_eee(struct r8152 *tp, struct ethtool_eee *eee) -+{ -+ u16 val = ethtool_adv_to_mmd_eee_adv_t(eee->advertised); -+ -+ r8153_eee_en(tp, eee->eee_enabled); -+ -+ if (!eee->eee_enabled) -+ val = 0; -+ -+ ocp_reg_write(tp, OCP_EEE_ADV, val); -+ -+ return 0; -+} -+ -+static int -+rtl_ethtool_get_eee(struct net_device *net, struct ethtool_eee *edata) -+{ -+ struct r8152 *tp = netdev_priv(net); -+ int ret; -+ -+ ret = usb_autopm_get_interface(tp->intf); -+ if (ret < 0) -+ goto out; -+ -+ mutex_lock(&tp->control); -+ -+ ret = tp->rtl_ops.eee_get(tp, edata); -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+ -+out: -+ return ret; -+} -+ -+static int -+rtl_ethtool_set_eee(struct net_device *net, struct ethtool_eee *edata) -+{ -+ struct r8152 *tp = netdev_priv(net); -+ int ret; -+ -+ ret = usb_autopm_get_interface(tp->intf); -+ if (ret < 0) -+ goto out; -+ -+ mutex_lock(&tp->control); -+ -+ ret = tp->rtl_ops.eee_set(tp, edata); -+ if (!ret) -+ ret = mii_nway_restart(&tp->mii); -+ -+ mutex_unlock(&tp->control); -+ -+ usb_autopm_put_interface(tp->intf); -+ -+out: -+ return ret; -+} -+ -+static struct ethtool_ops ops = { -+ .get_drvinfo = rtl8152_get_drvinfo, -+ .get_settings = rtl8152_get_settings, -+ .set_settings = rtl8152_set_settings, -+ .get_link = ethtool_op_get_link, -+ .get_msglevel = rtl8152_get_msglevel, -+ .set_msglevel = rtl8152_set_msglevel, -+ .get_wol = rtl8152_get_wol, -+ .set_wol = rtl8152_set_wol, -+ .get_strings = rtl8152_get_strings, -+ .get_sset_count = rtl8152_get_sset_count, -+ .get_ethtool_stats = rtl8152_get_ethtool_stats, -+ .get_eee = rtl_ethtool_get_eee, -+ .set_eee = rtl_ethtool_set_eee, -+}; -+ -+static int rtl8152_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) -+{ -+ struct r8152 *tp = netdev_priv(netdev); -+ struct mii_ioctl_data *data = if_mii(rq); -+ int res; -+ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return -ENODEV; -+ -+ res = usb_autopm_get_interface(tp->intf); -+ if (res < 0) -+ goto out; -+ -+ switch (cmd) { -+ case SIOCGMIIPHY: -+ data->phy_id = R8152_PHY_ID; /* Internal PHY */ -+ break; -+ -+ case SIOCGMIIREG: -+ mutex_lock(&tp->control); -+ data->val_out = r8152_mdio_read(tp, data->reg_num); -+ mutex_unlock(&tp->control); -+ break; -+ -+ case SIOCSMIIREG: -+ if (!capable(CAP_NET_ADMIN)) { -+ res = -EPERM; -+ break; -+ } -+ mutex_lock(&tp->control); -+ r8152_mdio_write(tp, data->reg_num, data->val_in); -+ mutex_unlock(&tp->control); -+ break; -+ -+ default: -+ res = -EOPNOTSUPP; -+ } -+ -+ usb_autopm_put_interface(tp->intf); -+ -+out: -+ return res; -+} -+ -+static int rtl8152_change_mtu(struct net_device *dev, int new_mtu) -+{ -+ struct r8152 *tp = netdev_priv(dev); -+ -+ switch (tp->version) { -+ case RTL_VER_01: -+ case RTL_VER_02: -+ return eth_change_mtu(dev, new_mtu); -+ default: -+ break; -+ } -+ -+ if (new_mtu < 68 || new_mtu > RTL8153_MAX_MTU) -+ return -EINVAL; -+ -+ dev->mtu = new_mtu; -+ -+ return 0; -+} -+ -+static const struct net_device_ops rtl8152_netdev_ops = { -+ .ndo_open = rtl8152_open, -+ .ndo_stop = rtl8152_close, -+ .ndo_do_ioctl = rtl8152_ioctl, -+ .ndo_start_xmit = rtl8152_start_xmit, -+ .ndo_tx_timeout = rtl8152_tx_timeout, -+ .ndo_set_features = rtl8152_set_features, -+ .ndo_set_rx_mode = rtl8152_set_rx_mode, -+ .ndo_set_mac_address = rtl8152_set_mac_address, -+ .ndo_change_mtu = rtl8152_change_mtu, -+ .ndo_validate_addr = eth_validate_addr, -+}; -+ -+static void r8152b_get_version(struct r8152 *tp) -+{ -+ u32 ocp_data; -+ u16 version; -+ -+ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR1); -+ version = (u16)(ocp_data & VERSION_MASK); -+ -+ switch (version) { -+ case 0x4c00: -+ tp->version = RTL_VER_01; -+ break; -+ case 0x4c10: -+ tp->version = RTL_VER_02; -+ break; -+ case 0x5c00: -+ tp->version = RTL_VER_03; -+ tp->mii.supports_gmii = 1; -+ break; -+ case 0x5c10: -+ tp->version = RTL_VER_04; -+ tp->mii.supports_gmii = 1; -+ break; -+ case 0x5c20: -+ tp->version = RTL_VER_05; -+ tp->mii.supports_gmii = 1; -+ break; -+ default: -+ netif_info(tp, probe, tp->netdev, -+ "Unknown version 0x%04x\n", version); -+ break; -+ } -+} -+ -+static void rtl8152_unload(struct r8152 *tp) -+{ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ if (tp->version != RTL_VER_01) -+ r8152_power_cut_en(tp, true); -+} -+ -+static void rtl8153_unload(struct r8152 *tp) -+{ -+ if (test_bit(RTL8152_UNPLUG, &tp->flags)) -+ return; -+ -+ r8153_power_cut_en(tp, false); -+} -+ -+static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id) -+{ -+ struct rtl_ops *ops = &tp->rtl_ops; -+ int ret = -ENODEV; -+ -+ switch (id->idVendor) { -+ case VENDOR_ID_REALTEK: -+ switch (id->idProduct) { -+ case PRODUCT_ID_RTL8152: -+ ops->init = r8152b_init; -+ ops->enable = rtl8152_enable; -+ ops->disable = rtl8152_disable; -+ ops->up = rtl8152_up; -+ ops->down = rtl8152_down; -+ ops->unload = rtl8152_unload; -+ ops->eee_get = r8152_get_eee; -+ ops->eee_set = r8152_set_eee; -+ ret = 0; -+ break; -+ case PRODUCT_ID_RTL8153: -+ ops->init = r8153_init; -+ ops->enable = rtl8153_enable; -+ ops->disable = rtl8153_disable; -+ ops->up = rtl8153_up; -+ ops->down = rtl8153_down; -+ ops->unload = rtl8153_unload; -+ ops->eee_get = r8153_get_eee; -+ ops->eee_set = r8153_set_eee; -+ ret = 0; -+ break; -+ default: -+ break; -+ } -+ break; -+ -+ case VENDOR_ID_SAMSUNG: -+ switch (id->idProduct) { -+ case PRODUCT_ID_SAMSUNG: -+ ops->init = r8153_init; -+ ops->enable = rtl8153_enable; -+ ops->disable = rtl8153_disable; -+ ops->up = rtl8153_up; -+ ops->down = rtl8153_down; -+ ops->unload = rtl8153_unload; -+ ops->eee_get = r8153_get_eee; -+ ops->eee_set = r8153_set_eee; -+ ret = 0; -+ break; -+ default: -+ break; -+ } -+ break; -+ -+ default: -+ break; -+ } -+ -+ if (ret) -+ netif_err(tp, probe, tp->netdev, "Unknown Device\n"); -+ -+ return ret; -+} -+ -+static int rtl8152_probe(struct usb_interface *intf, -+ const struct usb_device_id *id) -+{ -+ struct usb_device *udev = interface_to_usbdev(intf); -+ struct r8152 *tp; -+ struct net_device *netdev; -+ int ret; -+ -+ if (udev->actconfig->desc.bConfigurationValue != 1) { -+ usb_driver_set_configuration(udev, 1); -+ return -ENODEV; -+ } -+ -+ usb_reset_device(udev); -+ netdev = alloc_etherdev(sizeof(struct r8152)); -+ if (!netdev) { -+ dev_err(&intf->dev, "Out of memory\n"); -+ return -ENOMEM; -+ } -+ -+ SET_NETDEV_DEV(netdev, &intf->dev); -+ tp = netdev_priv(netdev); -+ tp->msg_enable = 0x7FFF; -+ -+ tp->udev = udev; -+ tp->netdev = netdev; -+ tp->intf = intf; -+ -+ ret = rtl_ops_init(tp, id); -+ if (ret) -+ goto out; -+ -+ tasklet_init(&tp->tl, bottom_half, (unsigned long)tp); -+ mutex_init(&tp->control); -+ INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t); -+ -+ netdev->netdev_ops = &rtl8152_netdev_ops; -+ netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; -+ -+ netdev->features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | -+ NETIF_F_TSO | NETIF_F_FRAGLIST | NETIF_F_IPV6_CSUM | -+ NETIF_F_TSO6 | NETIF_F_HW_VLAN_CTAG_RX | -+ NETIF_F_HW_VLAN_CTAG_TX; -+ netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM | NETIF_F_SG | -+ NETIF_F_TSO | NETIF_F_FRAGLIST | -+ NETIF_F_IPV6_CSUM | NETIF_F_TSO6 | -+ NETIF_F_HW_VLAN_CTAG_RX | -+ NETIF_F_HW_VLAN_CTAG_TX; -+ netdev->vlan_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_TSO | -+ NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | -+ NETIF_F_IPV6_CSUM | NETIF_F_TSO6; -+ -+ netdev->ethtool_ops = &ops; -+ netif_set_gso_max_size(netdev, RTL_LIMITED_TSO_SIZE); -+ -+ tp->mii.dev = netdev; -+ tp->mii.mdio_read = read_mii_word; -+ tp->mii.mdio_write = write_mii_word; -+ tp->mii.phy_id_mask = 0x3f; -+ tp->mii.reg_num_mask = 0x1f; -+ tp->mii.phy_id = R8152_PHY_ID; -+ tp->mii.supports_gmii = 0; -+ -+ intf->needs_remote_wakeup = 1; -+ -+ r8152b_get_version(tp); -+ tp->rtl_ops.init(tp); -+ set_ethernet_addr(tp); -+ -+ usb_set_intfdata(intf, tp); -+ -+ ret = register_netdev(netdev); -+ if (ret != 0) { -+ netif_err(tp, probe, netdev, "couldn't register the device\n"); -+ goto out1; -+ } -+ -+ tp->saved_wolopts = __rtl_get_wol(tp); -+ if (tp->saved_wolopts) -+ device_set_wakeup_enable(&udev->dev, true); -+ else -+ device_set_wakeup_enable(&udev->dev, false); -+ -+ netif_info(tp, probe, netdev, "%s\n", DRIVER_VERSION); -+ -+ return 0; -+ -+out1: -+ usb_set_intfdata(intf, NULL); -+out: -+ free_netdev(netdev); -+ return ret; -+} -+ -+static void rtl8152_disconnect(struct usb_interface *intf) -+{ -+ struct r8152 *tp = usb_get_intfdata(intf); -+ -+ usb_set_intfdata(intf, NULL); -+ if (tp) { -+ struct usb_device *udev = tp->udev; -+ -+ if (udev->state == USB_STATE_NOTATTACHED) -+ set_bit(RTL8152_UNPLUG, &tp->flags); -+ -+ tasklet_kill(&tp->tl); -+ unregister_netdev(tp->netdev); -+ tp->rtl_ops.unload(tp); -+ free_netdev(tp->netdev); -+ } -+} -+ -+/* table of devices that work with this driver */ -+static struct usb_device_id rtl8152_table[] = { -+ {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8152)}, -+ {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8153)}, -+ {USB_DEVICE(VENDOR_ID_SAMSUNG, PRODUCT_ID_SAMSUNG)}, -+ {} -+}; -+ -+MODULE_DEVICE_TABLE(usb, rtl8152_table); -+ -+static struct usb_driver rtl8152_driver = { -+ .name = MODULENAME, -+ .id_table = rtl8152_table, -+ .probe = rtl8152_probe, -+ .disconnect = rtl8152_disconnect, -+ .suspend = rtl8152_suspend, -+ .resume = rtl8152_resume, -+ .reset_resume = rtl8152_resume, -+ .supports_autosuspend = 1, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(rtl8152_driver); -+ -+MODULE_AUTHOR(DRIVER_AUTHOR); -+MODULE_DESCRIPTION(DRIVER_DESC); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/rtl8150.c backports-3.18.1-1/drivers/net/usb/rtl8150.c ---- backports-3.18.1-1.org/drivers/net/usb/rtl8150.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/rtl8150.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,950 @@ -+/* -+ * Copyright (c) 2002 Petko Manolov (petkan@users.sourceforge.net) -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ */ -+ -+#include <linux/signal.h> -+#include <linux/slab.h> -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/mii.h> -+#include <linux/ethtool.h> -+#include <linux/usb.h> -+#include <asm/uaccess.h> -+ -+/* Version Information */ -+#define DRIVER_VERSION "v0.6.2 (2004/08/27)" -+#define DRIVER_AUTHOR "Petko Manolov petkan@users.sourceforge.net" -+#define DRIVER_DESC "rtl8150 based usb-ethernet driver" -+ -+#define IDR 0x0120 -+#define MAR 0x0126 -+#define CR 0x012e -+#define TCR 0x012f -+#define RCR 0x0130 -+#define TSR 0x0132 -+#define RSR 0x0133 -+#define CON0 0x0135 -+#define CON1 0x0136 -+#define MSR 0x0137 -+#define PHYADD 0x0138 -+#define PHYDAT 0x0139 -+#define PHYCNT 0x013b -+#define GPPC 0x013d -+#define BMCR 0x0140 -+#define BMSR 0x0142 -+#define ANAR 0x0144 -+#define ANLP 0x0146 -+#define AER 0x0148 -+#define CSCR 0x014C /* This one has the link status */ -+#define CSCR_LINK_STATUS (1 << 3) -+ -+#define IDR_EEPROM 0x1202 -+ -+#define PHY_READ 0 -+#define PHY_WRITE 0x20 -+#define PHY_GO 0x40 -+ -+#define MII_TIMEOUT 10 -+#define INTBUFSIZE 8 -+ -+#define RTL8150_REQT_READ 0xc0 -+#define RTL8150_REQT_WRITE 0x40 -+#define RTL8150_REQ_GET_REGS 0x05 -+#define RTL8150_REQ_SET_REGS 0x05 -+ -+ -+/* Transmit status register errors */ -+#define TSR_ECOL (1<<5) -+#define TSR_LCOL (1<<4) -+#define TSR_LOSS_CRS (1<<3) -+#define TSR_JBR (1<<2) -+#define TSR_ERRORS (TSR_ECOL | TSR_LCOL | TSR_LOSS_CRS | TSR_JBR) -+/* Receive status register errors */ -+#define RSR_CRC (1<<2) -+#define RSR_FAE (1<<1) -+#define RSR_ERRORS (RSR_CRC | RSR_FAE) -+ -+/* Media status register definitions */ -+#define MSR_DUPLEX (1<<4) -+#define MSR_SPEED (1<<3) -+#define MSR_LINK (1<<2) -+ -+/* Interrupt pipe data */ -+#define INT_TSR 0x00 -+#define INT_RSR 0x01 -+#define INT_MSR 0x02 -+#define INT_WAKSR 0x03 -+#define INT_TXOK_CNT 0x04 -+#define INT_RXLOST_CNT 0x05 -+#define INT_CRERR_CNT 0x06 -+#define INT_COL_CNT 0x07 -+ -+ -+#define RTL8150_MTU 1540 -+#define RTL8150_TX_TIMEOUT (HZ) -+#define RX_SKB_POOL_SIZE 4 -+ -+/* rtl8150 flags */ -+#define RTL8150_HW_CRC 0 -+#define RX_REG_SET 1 -+#define RTL8150_UNPLUG 2 -+#define RX_URB_FAIL 3 -+ -+/* Define these values to match your device */ -+#define VENDOR_ID_REALTEK 0x0bda -+#define VENDOR_ID_MELCO 0x0411 -+#define VENDOR_ID_MICRONET 0x3980 -+#define VENDOR_ID_LONGSHINE 0x07b8 -+#define VENDOR_ID_OQO 0x1557 -+#define VENDOR_ID_ZYXEL 0x0586 -+ -+#define PRODUCT_ID_RTL8150 0x8150 -+#define PRODUCT_ID_LUAKTX 0x0012 -+#define PRODUCT_ID_LCS8138TX 0x401a -+#define PRODUCT_ID_SP128AR 0x0003 -+#define PRODUCT_ID_PRESTIGE 0x401a -+ -+#undef EEPROM_WRITE -+ -+/* table of devices that work with this driver */ -+static struct usb_device_id rtl8150_table[] = { -+ {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8150)}, -+ {USB_DEVICE(VENDOR_ID_MELCO, PRODUCT_ID_LUAKTX)}, -+ {USB_DEVICE(VENDOR_ID_MICRONET, PRODUCT_ID_SP128AR)}, -+ {USB_DEVICE(VENDOR_ID_LONGSHINE, PRODUCT_ID_LCS8138TX)}, -+ {USB_DEVICE(VENDOR_ID_OQO, PRODUCT_ID_RTL8150)}, -+ {USB_DEVICE(VENDOR_ID_ZYXEL, PRODUCT_ID_PRESTIGE)}, -+ {} -+}; -+ -+MODULE_DEVICE_TABLE(usb, rtl8150_table); -+ -+struct rtl8150 { -+ unsigned long flags; -+ struct usb_device *udev; -+ struct tasklet_struct tl; -+ struct net_device *netdev; -+ struct urb *rx_urb, *tx_urb, *intr_urb; -+ struct sk_buff *tx_skb, *rx_skb; -+ struct sk_buff *rx_skb_pool[RX_SKB_POOL_SIZE]; -+ spinlock_t rx_pool_lock; -+ struct usb_ctrlrequest dr; -+ int intr_interval; -+ u8 *intr_buff; -+ u8 phy; -+}; -+ -+typedef struct rtl8150 rtl8150_t; -+ -+struct async_req { -+ struct usb_ctrlrequest dr; -+ u16 rx_creg; -+}; -+ -+static const char driver_name [] = "rtl8150"; -+ -+/* -+** -+** device related part of the code -+** -+*/ -+static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) -+{ -+ return usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), -+ RTL8150_REQ_GET_REGS, RTL8150_REQT_READ, -+ indx, 0, data, size, 500); -+} -+ -+static int set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) -+{ -+ return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), -+ RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE, -+ indx, 0, data, size, 500); -+} -+ -+static void async_set_reg_cb(struct urb *urb) -+{ -+ struct async_req *req = (struct async_req *)urb->context; -+ int status = urb->status; -+ -+ if (status < 0) -+ dev_dbg(&urb->dev->dev, "%s failed with %d", __func__, status); -+ kfree(req); -+ usb_free_urb(urb); -+} -+ -+static int async_set_registers(rtl8150_t *dev, u16 indx, u16 size, u16 reg) -+{ -+ int res = -ENOMEM; -+ struct urb *async_urb; -+ struct async_req *req; -+ -+ req = kmalloc(sizeof(struct async_req), GFP_ATOMIC); -+ if (req == NULL) -+ return res; -+ async_urb = usb_alloc_urb(0, GFP_ATOMIC); -+ if (async_urb == NULL) { -+ kfree(req); -+ return res; -+ } -+ req->rx_creg = cpu_to_le16(reg); -+ req->dr.bRequestType = RTL8150_REQT_WRITE; -+ req->dr.bRequest = RTL8150_REQ_SET_REGS; -+ req->dr.wIndex = 0; -+ req->dr.wValue = cpu_to_le16(indx); -+ req->dr.wLength = cpu_to_le16(size); -+ usb_fill_control_urb(async_urb, dev->udev, -+ usb_sndctrlpipe(dev->udev, 0), (void *)&req->dr, -+ &req->rx_creg, size, async_set_reg_cb, req); -+ res = usb_submit_urb(async_urb, GFP_ATOMIC); -+ if (res) { -+ if (res == -ENODEV) -+ netif_device_detach(dev->netdev); -+ dev_err(&dev->udev->dev, "%s failed with %d\n", __func__, res); -+ } -+ return res; -+} -+ -+static int read_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 * reg) -+{ -+ int i; -+ u8 data[3], tmp; -+ -+ data[0] = phy; -+ data[1] = data[2] = 0; -+ tmp = indx | PHY_READ | PHY_GO; -+ i = 0; -+ -+ set_registers(dev, PHYADD, sizeof(data), data); -+ set_registers(dev, PHYCNT, 1, &tmp); -+ do { -+ get_registers(dev, PHYCNT, 1, data); -+ } while ((data[0] & PHY_GO) && (i++ < MII_TIMEOUT)); -+ -+ if (i <= MII_TIMEOUT) { -+ get_registers(dev, PHYDAT, 2, data); -+ *reg = data[0] | (data[1] << 8); -+ return 0; -+ } else -+ return 1; -+} -+ -+static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg) -+{ -+ int i; -+ u8 data[3], tmp; -+ -+ data[0] = phy; -+ data[1] = reg & 0xff; -+ data[2] = (reg >> 8) & 0xff; -+ tmp = indx | PHY_WRITE | PHY_GO; -+ i = 0; -+ -+ set_registers(dev, PHYADD, sizeof(data), data); -+ set_registers(dev, PHYCNT, 1, &tmp); -+ do { -+ get_registers(dev, PHYCNT, 1, data); -+ } while ((data[0] & PHY_GO) && (i++ < MII_TIMEOUT)); -+ -+ if (i <= MII_TIMEOUT) -+ return 0; -+ else -+ return 1; -+} -+ -+static inline void set_ethernet_addr(rtl8150_t * dev) -+{ -+ u8 node_id[6]; -+ -+ get_registers(dev, IDR, sizeof(node_id), node_id); -+ memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id)); -+} -+ -+static int rtl8150_set_mac_address(struct net_device *netdev, void *p) -+{ -+ struct sockaddr *addr = p; -+ rtl8150_t *dev = netdev_priv(netdev); -+ -+ if (netif_running(netdev)) -+ return -EBUSY; -+ -+ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); -+ netdev_dbg(netdev, "Setting MAC address to %pM\n", netdev->dev_addr); -+ /* Set the IDR registers. */ -+ set_registers(dev, IDR, netdev->addr_len, netdev->dev_addr); -+#ifdef EEPROM_WRITE -+ { -+ int i; -+ u8 cr; -+ /* Get the CR contents. */ -+ get_registers(dev, CR, 1, &cr); -+ /* Set the WEPROM bit (eeprom write enable). */ -+ cr |= 0x20; -+ set_registers(dev, CR, 1, &cr); -+ /* Write the MAC address into eeprom. Eeprom writes must be word-sized, -+ so we need to split them up. */ -+ for (i = 0; i * 2 < netdev->addr_len; i++) { -+ set_registers(dev, IDR_EEPROM + (i * 2), 2, -+ netdev->dev_addr + (i * 2)); -+ } -+ /* Clear the WEPROM bit (preventing accidental eeprom writes). */ -+ cr &= 0xdf; -+ set_registers(dev, CR, 1, &cr); -+ } -+#endif -+ return 0; -+} -+ -+static int rtl8150_reset(rtl8150_t * dev) -+{ -+ u8 data = 0x10; -+ int i = HZ; -+ -+ set_registers(dev, CR, 1, &data); -+ do { -+ get_registers(dev, CR, 1, &data); -+ } while ((data & 0x10) && --i); -+ -+ return (i > 0) ? 1 : 0; -+} -+ -+static int alloc_all_urbs(rtl8150_t * dev) -+{ -+ dev->rx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!dev->rx_urb) -+ return 0; -+ dev->tx_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!dev->tx_urb) { -+ usb_free_urb(dev->rx_urb); -+ return 0; -+ } -+ dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); -+ if (!dev->intr_urb) { -+ usb_free_urb(dev->rx_urb); -+ usb_free_urb(dev->tx_urb); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static void free_all_urbs(rtl8150_t * dev) -+{ -+ usb_free_urb(dev->rx_urb); -+ usb_free_urb(dev->tx_urb); -+ usb_free_urb(dev->intr_urb); -+} -+ -+static void unlink_all_urbs(rtl8150_t * dev) -+{ -+ usb_kill_urb(dev->rx_urb); -+ usb_kill_urb(dev->tx_urb); -+ usb_kill_urb(dev->intr_urb); -+} -+ -+static inline struct sk_buff *pull_skb(rtl8150_t *dev) -+{ -+ struct sk_buff *skb; -+ int i; -+ -+ for (i = 0; i < RX_SKB_POOL_SIZE; i++) { -+ if (dev->rx_skb_pool[i]) { -+ skb = dev->rx_skb_pool[i]; -+ dev->rx_skb_pool[i] = NULL; -+ return skb; -+ } -+ } -+ return NULL; -+} -+ -+static void read_bulk_callback(struct urb *urb) -+{ -+ rtl8150_t *dev; -+ unsigned pkt_len, res; -+ struct sk_buff *skb; -+ struct net_device *netdev; -+ u16 rx_stat; -+ int status = urb->status; -+ int result; -+ -+ dev = urb->context; -+ if (!dev) -+ return; -+ if (test_bit(RTL8150_UNPLUG, &dev->flags)) -+ return; -+ netdev = dev->netdev; -+ if (!netif_device_present(netdev)) -+ return; -+ -+ switch (status) { -+ case 0: -+ break; -+ case -ENOENT: -+ return; /* the urb is in unlink state */ -+ case -ETIME: -+ if (printk_ratelimit()) -+ dev_warn(&urb->dev->dev, "may be reset is needed?..\n"); -+ goto goon; -+ default: -+ if (printk_ratelimit()) -+ dev_warn(&urb->dev->dev, "Rx status %d\n", status); -+ goto goon; -+ } -+ -+ if (!dev->rx_skb) -+ goto resched; -+ /* protect against short packets (tell me why we got some?!?) */ -+ if (urb->actual_length < 4) -+ goto goon; -+ -+ res = urb->actual_length; -+ rx_stat = le16_to_cpu(*(__le16 *)(urb->transfer_buffer + res - 4)); -+ pkt_len = res - 4; -+ -+ skb_put(dev->rx_skb, pkt_len); -+ dev->rx_skb->protocol = eth_type_trans(dev->rx_skb, netdev); -+ netif_rx(dev->rx_skb); -+ netdev->stats.rx_packets++; -+ netdev->stats.rx_bytes += pkt_len; -+ -+ spin_lock(&dev->rx_pool_lock); -+ skb = pull_skb(dev); -+ spin_unlock(&dev->rx_pool_lock); -+ if (!skb) -+ goto resched; -+ -+ dev->rx_skb = skb; -+goon: -+ usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), -+ dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); -+ result = usb_submit_urb(dev->rx_urb, GFP_ATOMIC); -+ if (result == -ENODEV) -+ netif_device_detach(dev->netdev); -+ else if (result) { -+ set_bit(RX_URB_FAIL, &dev->flags); -+ goto resched; -+ } else { -+ clear_bit(RX_URB_FAIL, &dev->flags); -+ } -+ -+ return; -+resched: -+ tasklet_schedule(&dev->tl); -+} -+ -+static void write_bulk_callback(struct urb *urb) -+{ -+ rtl8150_t *dev; -+ int status = urb->status; -+ -+ dev = urb->context; -+ if (!dev) -+ return; -+ dev_kfree_skb_irq(dev->tx_skb); -+ if (!netif_device_present(dev->netdev)) -+ return; -+ if (status) -+ dev_info(&urb->dev->dev, "%s: Tx status %d\n", -+ dev->netdev->name, status); -+ dev->netdev->trans_start = jiffies; -+ netif_wake_queue(dev->netdev); -+} -+ -+static void intr_callback(struct urb *urb) -+{ -+ rtl8150_t *dev; -+ __u8 *d; -+ int status = urb->status; -+ int res; -+ -+ dev = urb->context; -+ if (!dev) -+ return; -+ switch (status) { -+ case 0: /* success */ -+ break; -+ case -ECONNRESET: /* unlink */ -+ case -ENOENT: -+ case -ESHUTDOWN: -+ return; -+ /* -EPIPE: should clear the halt */ -+ default: -+ dev_info(&urb->dev->dev, "%s: intr status %d\n", -+ dev->netdev->name, status); -+ goto resubmit; -+ } -+ -+ d = urb->transfer_buffer; -+ if (d[0] & TSR_ERRORS) { -+ dev->netdev->stats.tx_errors++; -+ if (d[INT_TSR] & (TSR_ECOL | TSR_JBR)) -+ dev->netdev->stats.tx_aborted_errors++; -+ if (d[INT_TSR] & TSR_LCOL) -+ dev->netdev->stats.tx_window_errors++; -+ if (d[INT_TSR] & TSR_LOSS_CRS) -+ dev->netdev->stats.tx_carrier_errors++; -+ } -+ /* Report link status changes to the network stack */ -+ if ((d[INT_MSR] & MSR_LINK) == 0) { -+ if (netif_carrier_ok(dev->netdev)) { -+ netif_carrier_off(dev->netdev); -+ netdev_dbg(dev->netdev, "%s: LINK LOST\n", __func__); -+ } -+ } else { -+ if (!netif_carrier_ok(dev->netdev)) { -+ netif_carrier_on(dev->netdev); -+ netdev_dbg(dev->netdev, "%s: LINK CAME BACK\n", __func__); -+ } -+ } -+ -+resubmit: -+ res = usb_submit_urb (urb, GFP_ATOMIC); -+ if (res == -ENODEV) -+ netif_device_detach(dev->netdev); -+ else if (res) -+ dev_err(&dev->udev->dev, -+ "can't resubmit intr, %s-%s/input0, status %d\n", -+ dev->udev->bus->bus_name, dev->udev->devpath, res); -+} -+ -+static int rtl8150_suspend(struct usb_interface *intf, pm_message_t message) -+{ -+ rtl8150_t *dev = usb_get_intfdata(intf); -+ -+ netif_device_detach(dev->netdev); -+ -+ if (netif_running(dev->netdev)) { -+ usb_kill_urb(dev->rx_urb); -+ usb_kill_urb(dev->intr_urb); -+ } -+ return 0; -+} -+ -+static int rtl8150_resume(struct usb_interface *intf) -+{ -+ rtl8150_t *dev = usb_get_intfdata(intf); -+ -+ netif_device_attach(dev->netdev); -+ if (netif_running(dev->netdev)) { -+ dev->rx_urb->status = 0; -+ dev->rx_urb->actual_length = 0; -+ read_bulk_callback(dev->rx_urb); -+ -+ dev->intr_urb->status = 0; -+ dev->intr_urb->actual_length = 0; -+ intr_callback(dev->intr_urb); -+ } -+ return 0; -+} -+ -+/* -+** -+** network related part of the code -+** -+*/ -+ -+static void fill_skb_pool(rtl8150_t *dev) -+{ -+ struct sk_buff *skb; -+ int i; -+ -+ for (i = 0; i < RX_SKB_POOL_SIZE; i++) { -+ if (dev->rx_skb_pool[i]) -+ continue; -+ skb = dev_alloc_skb(RTL8150_MTU + 2); -+ if (!skb) { -+ return; -+ } -+ skb_reserve(skb, 2); -+ dev->rx_skb_pool[i] = skb; -+ } -+} -+ -+static void free_skb_pool(rtl8150_t *dev) -+{ -+ int i; -+ -+ for (i = 0; i < RX_SKB_POOL_SIZE; i++) -+ if (dev->rx_skb_pool[i]) -+ dev_kfree_skb(dev->rx_skb_pool[i]); -+} -+ -+static void rx_fixup(unsigned long data) -+{ -+ struct rtl8150 *dev = (struct rtl8150 *)data; -+ struct sk_buff *skb; -+ int status; -+ -+ spin_lock_irq(&dev->rx_pool_lock); -+ fill_skb_pool(dev); -+ spin_unlock_irq(&dev->rx_pool_lock); -+ if (test_bit(RX_URB_FAIL, &dev->flags)) -+ if (dev->rx_skb) -+ goto try_again; -+ spin_lock_irq(&dev->rx_pool_lock); -+ skb = pull_skb(dev); -+ spin_unlock_irq(&dev->rx_pool_lock); -+ if (skb == NULL) -+ goto tlsched; -+ dev->rx_skb = skb; -+ usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), -+ dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); -+try_again: -+ status = usb_submit_urb(dev->rx_urb, GFP_ATOMIC); -+ if (status == -ENODEV) { -+ netif_device_detach(dev->netdev); -+ } else if (status) { -+ set_bit(RX_URB_FAIL, &dev->flags); -+ goto tlsched; -+ } else { -+ clear_bit(RX_URB_FAIL, &dev->flags); -+ } -+ -+ return; -+tlsched: -+ tasklet_schedule(&dev->tl); -+} -+ -+static int enable_net_traffic(rtl8150_t * dev) -+{ -+ u8 cr, tcr, rcr, msr; -+ -+ if (!rtl8150_reset(dev)) { -+ dev_warn(&dev->udev->dev, "device reset failed\n"); -+ } -+ /* RCR bit7=1 attach Rx info at the end; =0 HW CRC (which is broken) */ -+ rcr = 0x9e; -+ tcr = 0xd8; -+ cr = 0x0c; -+ if (!(rcr & 0x80)) -+ set_bit(RTL8150_HW_CRC, &dev->flags); -+ set_registers(dev, RCR, 1, &rcr); -+ set_registers(dev, TCR, 1, &tcr); -+ set_registers(dev, CR, 1, &cr); -+ get_registers(dev, MSR, 1, &msr); -+ -+ return 0; -+} -+ -+static void disable_net_traffic(rtl8150_t * dev) -+{ -+ u8 cr; -+ -+ get_registers(dev, CR, 1, &cr); -+ cr &= 0xf3; -+ set_registers(dev, CR, 1, &cr); -+} -+ -+static void rtl8150_tx_timeout(struct net_device *netdev) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ dev_warn(&netdev->dev, "Tx timeout.\n"); -+ usb_unlink_urb(dev->tx_urb); -+ netdev->stats.tx_errors++; -+} -+ -+static void rtl8150_set_multicast(struct net_device *netdev) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ u16 rx_creg = 0x9e; -+ -+ netif_stop_queue(netdev); -+ if (netdev->flags & IFF_PROMISC) { -+ rx_creg |= 0x0001; -+ dev_info(&netdev->dev, "%s: promiscuous mode\n", netdev->name); -+ } else if (!netdev_mc_empty(netdev) || -+ (netdev->flags & IFF_ALLMULTI)) { -+ rx_creg &= 0xfffe; -+ rx_creg |= 0x0002; -+ dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name); -+ } else { -+ /* ~RX_MULTICAST, ~RX_PROMISCUOUS */ -+ rx_creg &= 0x00fc; -+ } -+ async_set_registers(dev, RCR, sizeof(rx_creg), rx_creg); -+ netif_wake_queue(netdev); -+} -+ -+static netdev_tx_t rtl8150_start_xmit(struct sk_buff *skb, -+ struct net_device *netdev) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ int count, res; -+ -+ netif_stop_queue(netdev); -+ count = (skb->len < 60) ? 60 : skb->len; -+ count = (count & 0x3f) ? count : count + 1; -+ dev->tx_skb = skb; -+ usb_fill_bulk_urb(dev->tx_urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), -+ skb->data, count, write_bulk_callback, dev); -+ if ((res = usb_submit_urb(dev->tx_urb, GFP_ATOMIC))) { -+ /* Can we get/handle EPIPE here? */ -+ if (res == -ENODEV) -+ netif_device_detach(dev->netdev); -+ else { -+ dev_warn(&netdev->dev, "failed tx_urb %d\n", res); -+ netdev->stats.tx_errors++; -+ netif_start_queue(netdev); -+ } -+ } else { -+ netdev->stats.tx_packets++; -+ netdev->stats.tx_bytes += skb->len; -+ netdev->trans_start = jiffies; -+ } -+ -+ return NETDEV_TX_OK; -+} -+ -+ -+static void set_carrier(struct net_device *netdev) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ short tmp; -+ -+ get_registers(dev, CSCR, 2, &tmp); -+ if (tmp & CSCR_LINK_STATUS) -+ netif_carrier_on(netdev); -+ else -+ netif_carrier_off(netdev); -+} -+ -+static int rtl8150_open(struct net_device *netdev) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ int res; -+ -+ if (dev->rx_skb == NULL) -+ dev->rx_skb = pull_skb(dev); -+ if (!dev->rx_skb) -+ return -ENOMEM; -+ -+ set_registers(dev, IDR, 6, netdev->dev_addr); -+ -+ usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), -+ dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); -+ if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) { -+ if (res == -ENODEV) -+ netif_device_detach(dev->netdev); -+ dev_warn(&netdev->dev, "rx_urb submit failed: %d\n", res); -+ return res; -+ } -+ usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3), -+ dev->intr_buff, INTBUFSIZE, intr_callback, -+ dev, dev->intr_interval); -+ if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL))) { -+ if (res == -ENODEV) -+ netif_device_detach(dev->netdev); -+ dev_warn(&netdev->dev, "intr_urb submit failed: %d\n", res); -+ usb_kill_urb(dev->rx_urb); -+ return res; -+ } -+ enable_net_traffic(dev); -+ set_carrier(netdev); -+ netif_start_queue(netdev); -+ -+ return res; -+} -+ -+static int rtl8150_close(struct net_device *netdev) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ int res = 0; -+ -+ netif_stop_queue(netdev); -+ if (!test_bit(RTL8150_UNPLUG, &dev->flags)) -+ disable_net_traffic(dev); -+ unlink_all_urbs(dev); -+ -+ return res; -+} -+ -+static void rtl8150_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ -+ strlcpy(info->driver, driver_name, sizeof(info->driver)); -+ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); -+ usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info)); -+} -+ -+static int rtl8150_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ short lpa, bmcr; -+ -+ ecmd->supported = (SUPPORTED_10baseT_Half | -+ SUPPORTED_10baseT_Full | -+ SUPPORTED_100baseT_Half | -+ SUPPORTED_100baseT_Full | -+ SUPPORTED_Autoneg | -+ SUPPORTED_TP | SUPPORTED_MII); -+ ecmd->port = PORT_TP; -+ ecmd->transceiver = XCVR_INTERNAL; -+ ecmd->phy_address = dev->phy; -+ get_registers(dev, BMCR, 2, &bmcr); -+ get_registers(dev, ANLP, 2, &lpa); -+ if (bmcr & BMCR_ANENABLE) { -+ u32 speed = ((lpa & (LPA_100HALF | LPA_100FULL)) ? -+ SPEED_100 : SPEED_10); -+ ethtool_cmd_speed_set(ecmd, speed); -+ ecmd->autoneg = AUTONEG_ENABLE; -+ if (speed == SPEED_100) -+ ecmd->duplex = (lpa & LPA_100FULL) ? -+ DUPLEX_FULL : DUPLEX_HALF; -+ else -+ ecmd->duplex = (lpa & LPA_10FULL) ? -+ DUPLEX_FULL : DUPLEX_HALF; -+ } else { -+ ecmd->autoneg = AUTONEG_DISABLE; -+ ethtool_cmd_speed_set(ecmd, ((bmcr & BMCR_SPEED100) ? -+ SPEED_100 : SPEED_10)); -+ ecmd->duplex = (bmcr & BMCR_FULLDPLX) ? -+ DUPLEX_FULL : DUPLEX_HALF; -+ } -+ return 0; -+} -+ -+static const struct ethtool_ops ops = { -+ .get_drvinfo = rtl8150_get_drvinfo, -+ .get_settings = rtl8150_get_settings, -+ .get_link = ethtool_op_get_link -+}; -+ -+static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) -+{ -+ rtl8150_t *dev = netdev_priv(netdev); -+ u16 *data = (u16 *) & rq->ifr_ifru; -+ int res = 0; -+ -+ switch (cmd) { -+ case SIOCDEVPRIVATE: -+ data[0] = dev->phy; -+ case SIOCDEVPRIVATE + 1: -+ read_mii_word(dev, dev->phy, (data[1] & 0x1f), &data[3]); -+ break; -+ case SIOCDEVPRIVATE + 2: -+ if (!capable(CAP_NET_ADMIN)) -+ return -EPERM; -+ write_mii_word(dev, dev->phy, (data[1] & 0x1f), data[2]); -+ break; -+ default: -+ res = -EOPNOTSUPP; -+ } -+ -+ return res; -+} -+ -+static const struct net_device_ops rtl8150_netdev_ops = { -+ .ndo_open = rtl8150_open, -+ .ndo_stop = rtl8150_close, -+ .ndo_do_ioctl = rtl8150_ioctl, -+ .ndo_start_xmit = rtl8150_start_xmit, -+ .ndo_tx_timeout = rtl8150_tx_timeout, -+ .ndo_set_rx_mode = rtl8150_set_multicast, -+ .ndo_set_mac_address = rtl8150_set_mac_address, -+ -+ .ndo_change_mtu = eth_change_mtu, -+ .ndo_validate_addr = eth_validate_addr, -+}; -+ -+static int rtl8150_probe(struct usb_interface *intf, -+ const struct usb_device_id *id) -+{ -+ struct usb_device *udev = interface_to_usbdev(intf); -+ rtl8150_t *dev; -+ struct net_device *netdev; -+ -+ netdev = alloc_etherdev(sizeof(rtl8150_t)); -+ if (!netdev) -+ return -ENOMEM; -+ -+ dev = netdev_priv(netdev); -+ -+ dev->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL); -+ if (!dev->intr_buff) { -+ free_netdev(netdev); -+ return -ENOMEM; -+ } -+ -+ tasklet_init(&dev->tl, rx_fixup, (unsigned long)dev); -+ spin_lock_init(&dev->rx_pool_lock); -+ -+ dev->udev = udev; -+ dev->netdev = netdev; -+ netdev->netdev_ops = &rtl8150_netdev_ops; -+ netdev->watchdog_timeo = RTL8150_TX_TIMEOUT; -+ netdev->ethtool_ops = &ops; -+ dev->intr_interval = 100; /* 100ms */ -+ -+ if (!alloc_all_urbs(dev)) { -+ dev_err(&intf->dev, "out of memory\n"); -+ goto out; -+ } -+ if (!rtl8150_reset(dev)) { -+ dev_err(&intf->dev, "couldn't reset the device\n"); -+ goto out1; -+ } -+ fill_skb_pool(dev); -+ set_ethernet_addr(dev); -+ -+ usb_set_intfdata(intf, dev); -+ SET_NETDEV_DEV(netdev, &intf->dev); -+ if (register_netdev(netdev) != 0) { -+ dev_err(&intf->dev, "couldn't register the device\n"); -+ goto out2; -+ } -+ -+ dev_info(&intf->dev, "%s: rtl8150 is detected\n", netdev->name); -+ -+ return 0; -+ -+out2: -+ usb_set_intfdata(intf, NULL); -+ free_skb_pool(dev); -+out1: -+ free_all_urbs(dev); -+out: -+ kfree(dev->intr_buff); -+ free_netdev(netdev); -+ return -EIO; -+} -+ -+static void rtl8150_disconnect(struct usb_interface *intf) -+{ -+ rtl8150_t *dev = usb_get_intfdata(intf); -+ -+ usb_set_intfdata(intf, NULL); -+ if (dev) { -+ set_bit(RTL8150_UNPLUG, &dev->flags); -+ tasklet_kill(&dev->tl); -+ unregister_netdev(dev->netdev); -+ unlink_all_urbs(dev); -+ free_all_urbs(dev); -+ free_skb_pool(dev); -+ if (dev->rx_skb) -+ dev_kfree_skb(dev->rx_skb); -+ kfree(dev->intr_buff); -+ free_netdev(dev->netdev); -+ } -+} -+ -+static struct usb_driver rtl8150_driver = { -+ .name = driver_name, -+ .probe = rtl8150_probe, -+ .disconnect = rtl8150_disconnect, -+ .id_table = rtl8150_table, -+ .suspend = rtl8150_suspend, -+ .resume = rtl8150_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(rtl8150_driver); -+ -+MODULE_AUTHOR(DRIVER_AUTHOR); -+MODULE_DESCRIPTION(DRIVER_DESC); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/smsc75xx.c backports-3.18.1-1/drivers/net/usb/smsc75xx.c ---- backports-3.18.1-1.org/drivers/net/usb/smsc75xx.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/smsc75xx.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,2286 @@ -+ /*************************************************************************** -+ * -+ * Copyright (C) 2007-2010 SMSC -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2 -+ * of the License, or (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ * -+ *****************************************************************************/ -+ -+#include <linux/module.h> -+#include <linux/kmod.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/bitrev.h> -+#include <linux/crc16.h> -+#include <linux/crc32.h> -+#include <linux/usb/usbnet.h> -+#include <linux/slab.h> -+#include "smsc75xx.h" -+ -+#define SMSC_CHIPNAME "smsc75xx" -+#define SMSC_DRIVER_VERSION "1.0.0" -+#define HS_USB_PKT_SIZE (512) -+#define FS_USB_PKT_SIZE (64) -+#define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE) -+#define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE) -+#define DEFAULT_BULK_IN_DELAY (0x00002000) -+#define MAX_SINGLE_PACKET_SIZE (9000) -+#define LAN75XX_EEPROM_MAGIC (0x7500) -+#define EEPROM_MAC_OFFSET (0x01) -+#define DEFAULT_TX_CSUM_ENABLE (true) -+#define DEFAULT_RX_CSUM_ENABLE (true) -+#define SMSC75XX_INTERNAL_PHY_ID (1) -+#define SMSC75XX_TX_OVERHEAD (8) -+#define MAX_RX_FIFO_SIZE (20 * 1024) -+#define MAX_TX_FIFO_SIZE (12 * 1024) -+#define USB_VENDOR_ID_SMSC (0x0424) -+#define USB_PRODUCT_ID_LAN7500 (0x7500) -+#define USB_PRODUCT_ID_LAN7505 (0x7505) -+#define RXW_PADDING 2 -+#define SUPPORTED_WAKE (WAKE_PHY | WAKE_UCAST | WAKE_BCAST | \ -+ WAKE_MCAST | WAKE_ARP | WAKE_MAGIC) -+ -+#define SUSPEND_SUSPEND0 (0x01) -+#define SUSPEND_SUSPEND1 (0x02) -+#define SUSPEND_SUSPEND2 (0x04) -+#define SUSPEND_SUSPEND3 (0x08) -+#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \ -+ SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3) -+ -+struct smsc75xx_priv { -+ struct usbnet *dev; -+ u32 rfe_ctl; -+ u32 wolopts; -+ u32 multicast_hash_table[DP_SEL_VHF_HASH_LEN]; -+ struct mutex dataport_mutex; -+ spinlock_t rfe_ctl_lock; -+ struct work_struct set_multicast; -+ u8 suspend_flags; -+}; -+ -+struct usb_context { -+ struct usb_ctrlrequest req; -+ struct usbnet *dev; -+}; -+ -+static bool turbo_mode = true; -+module_param(turbo_mode, bool, 0644); -+MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); -+ -+static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index, -+ u32 *data, int in_pm) -+{ -+ u32 buf; -+ int ret; -+ int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); -+ -+ BUG_ON(!dev); -+ -+ if (!in_pm) -+ fn = usbnet_read_cmd; -+ else -+ fn = usbnet_read_cmd_nopm; -+ -+ ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN -+ | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ 0, index, &buf, 4); -+ if (unlikely(ret < 0)) -+ netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n", -+ index, ret); -+ -+ le32_to_cpus(&buf); -+ *data = buf; -+ -+ return ret; -+} -+ -+static int __must_check __smsc75xx_write_reg(struct usbnet *dev, u32 index, -+ u32 data, int in_pm) -+{ -+ u32 buf; -+ int ret; -+ int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); -+ -+ BUG_ON(!dev); -+ -+ if (!in_pm) -+ fn = usbnet_write_cmd; -+ else -+ fn = usbnet_write_cmd_nopm; -+ -+ buf = data; -+ cpu_to_le32s(&buf); -+ -+ ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, USB_DIR_OUT -+ | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ 0, index, &buf, 4); -+ if (unlikely(ret < 0)) -+ netdev_warn(dev->net, "Failed to write reg index 0x%08x: %d\n", -+ index, ret); -+ -+ return ret; -+} -+ -+static int __must_check smsc75xx_read_reg_nopm(struct usbnet *dev, u32 index, -+ u32 *data) -+{ -+ return __smsc75xx_read_reg(dev, index, data, 1); -+} -+ -+static int __must_check smsc75xx_write_reg_nopm(struct usbnet *dev, u32 index, -+ u32 data) -+{ -+ return __smsc75xx_write_reg(dev, index, data, 1); -+} -+ -+static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index, -+ u32 *data) -+{ -+ return __smsc75xx_read_reg(dev, index, data, 0); -+} -+ -+static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index, -+ u32 data) -+{ -+ return __smsc75xx_write_reg(dev, index, data, 0); -+} -+ -+/* Loop until the read is completed with timeout -+ * called with phy_mutex held */ -+static __must_check int __smsc75xx_phy_wait_not_busy(struct usbnet *dev, -+ int in_pm) -+{ -+ unsigned long start_time = jiffies; -+ u32 val; -+ int ret; -+ -+ do { -+ ret = __smsc75xx_read_reg(dev, MII_ACCESS, &val, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading MII_ACCESS\n"); -+ return ret; -+ } -+ -+ if (!(val & MII_ACCESS_BUSY)) -+ return 0; -+ } while (!time_after(jiffies, start_time + HZ)); -+ -+ return -EIO; -+} -+ -+static int __smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx, -+ int in_pm) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u32 val, addr; -+ int ret; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ /* confirm MII not busy */ -+ ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "MII is busy in smsc75xx_mdio_read\n"); -+ goto done; -+ } -+ -+ /* set the address, index & direction (read from PHY) */ -+ phy_id &= dev->mii.phy_id_mask; -+ idx &= dev->mii.reg_num_mask; -+ addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR) -+ | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR) -+ | MII_ACCESS_READ | MII_ACCESS_BUSY; -+ ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing MII_ACCESS\n"); -+ goto done; -+ } -+ -+ ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx); -+ goto done; -+ } -+ -+ ret = __smsc75xx_read_reg(dev, MII_DATA, &val, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading MII_DATA\n"); -+ goto done; -+ } -+ -+ ret = (u16)(val & 0xFFFF); -+ -+done: -+ mutex_unlock(&dev->phy_mutex); -+ return ret; -+} -+ -+static void __smsc75xx_mdio_write(struct net_device *netdev, int phy_id, -+ int idx, int regval, int in_pm) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u32 val, addr; -+ int ret; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ /* confirm MII not busy */ -+ ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "MII is busy in smsc75xx_mdio_write\n"); -+ goto done; -+ } -+ -+ val = regval; -+ ret = __smsc75xx_write_reg(dev, MII_DATA, val, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing MII_DATA\n"); -+ goto done; -+ } -+ -+ /* set the address, index & direction (write to PHY) */ -+ phy_id &= dev->mii.phy_id_mask; -+ idx &= dev->mii.reg_num_mask; -+ addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR) -+ | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR) -+ | MII_ACCESS_WRITE | MII_ACCESS_BUSY; -+ ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing MII_ACCESS\n"); -+ goto done; -+ } -+ -+ ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx); -+ goto done; -+ } -+ -+done: -+ mutex_unlock(&dev->phy_mutex); -+} -+ -+static int smsc75xx_mdio_read_nopm(struct net_device *netdev, int phy_id, -+ int idx) -+{ -+ return __smsc75xx_mdio_read(netdev, phy_id, idx, 1); -+} -+ -+static void smsc75xx_mdio_write_nopm(struct net_device *netdev, int phy_id, -+ int idx, int regval) -+{ -+ __smsc75xx_mdio_write(netdev, phy_id, idx, regval, 1); -+} -+ -+static int smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx) -+{ -+ return __smsc75xx_mdio_read(netdev, phy_id, idx, 0); -+} -+ -+static void smsc75xx_mdio_write(struct net_device *netdev, int phy_id, int idx, -+ int regval) -+{ -+ __smsc75xx_mdio_write(netdev, phy_id, idx, regval, 0); -+} -+ -+static int smsc75xx_wait_eeprom(struct usbnet *dev) -+{ -+ unsigned long start_time = jiffies; -+ u32 val; -+ int ret; -+ -+ do { -+ ret = smsc75xx_read_reg(dev, E2P_CMD, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading E2P_CMD\n"); -+ return ret; -+ } -+ -+ if (!(val & E2P_CMD_BUSY) || (val & E2P_CMD_TIMEOUT)) -+ break; -+ udelay(40); -+ } while (!time_after(jiffies, start_time + HZ)); -+ -+ if (val & (E2P_CMD_TIMEOUT | E2P_CMD_BUSY)) { -+ netdev_warn(dev->net, "EEPROM read operation timeout\n"); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ -+static int smsc75xx_eeprom_confirm_not_busy(struct usbnet *dev) -+{ -+ unsigned long start_time = jiffies; -+ u32 val; -+ int ret; -+ -+ do { -+ ret = smsc75xx_read_reg(dev, E2P_CMD, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading E2P_CMD\n"); -+ return ret; -+ } -+ -+ if (!(val & E2P_CMD_BUSY)) -+ return 0; -+ -+ udelay(40); -+ } while (!time_after(jiffies, start_time + HZ)); -+ -+ netdev_warn(dev->net, "EEPROM is busy\n"); -+ return -EIO; -+} -+ -+static int smsc75xx_read_eeprom(struct usbnet *dev, u32 offset, u32 length, -+ u8 *data) -+{ -+ u32 val; -+ int i, ret; -+ -+ BUG_ON(!dev); -+ BUG_ON(!data); -+ -+ ret = smsc75xx_eeprom_confirm_not_busy(dev); -+ if (ret) -+ return ret; -+ -+ for (i = 0; i < length; i++) { -+ val = E2P_CMD_BUSY | E2P_CMD_READ | (offset & E2P_CMD_ADDR); -+ ret = smsc75xx_write_reg(dev, E2P_CMD, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing E2P_CMD\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_wait_eeprom(dev); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc75xx_read_reg(dev, E2P_DATA, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading E2P_DATA\n"); -+ return ret; -+ } -+ -+ data[i] = val & 0xFF; -+ offset++; -+ } -+ -+ return 0; -+} -+ -+static int smsc75xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length, -+ u8 *data) -+{ -+ u32 val; -+ int i, ret; -+ -+ BUG_ON(!dev); -+ BUG_ON(!data); -+ -+ ret = smsc75xx_eeprom_confirm_not_busy(dev); -+ if (ret) -+ return ret; -+ -+ /* Issue write/erase enable command */ -+ val = E2P_CMD_BUSY | E2P_CMD_EWEN; -+ ret = smsc75xx_write_reg(dev, E2P_CMD, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing E2P_CMD\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_wait_eeprom(dev); -+ if (ret < 0) -+ return ret; -+ -+ for (i = 0; i < length; i++) { -+ -+ /* Fill data register */ -+ val = data[i]; -+ ret = smsc75xx_write_reg(dev, E2P_DATA, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing E2P_DATA\n"); -+ return ret; -+ } -+ -+ /* Send "write" command */ -+ val = E2P_CMD_BUSY | E2P_CMD_WRITE | (offset & E2P_CMD_ADDR); -+ ret = smsc75xx_write_reg(dev, E2P_CMD, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing E2P_CMD\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_wait_eeprom(dev); -+ if (ret < 0) -+ return ret; -+ -+ offset++; -+ } -+ -+ return 0; -+} -+ -+static int smsc75xx_dataport_wait_not_busy(struct usbnet *dev) -+{ -+ int i, ret; -+ -+ for (i = 0; i < 100; i++) { -+ u32 dp_sel; -+ ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading DP_SEL\n"); -+ return ret; -+ } -+ -+ if (dp_sel & DP_SEL_DPRDY) -+ return 0; -+ -+ udelay(40); -+ } -+ -+ netdev_warn(dev->net, "smsc75xx_dataport_wait_not_busy timed out\n"); -+ -+ return -EIO; -+} -+ -+static int smsc75xx_dataport_write(struct usbnet *dev, u32 ram_select, u32 addr, -+ u32 length, u32 *buf) -+{ -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ u32 dp_sel; -+ int i, ret; -+ -+ mutex_lock(&pdata->dataport_mutex); -+ -+ ret = smsc75xx_dataport_wait_not_busy(dev); -+ if (ret < 0) { -+ netdev_warn(dev->net, "smsc75xx_dataport_write busy on entry\n"); -+ goto done; -+ } -+ -+ ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading DP_SEL\n"); -+ goto done; -+ } -+ -+ dp_sel &= ~DP_SEL_RSEL; -+ dp_sel |= ram_select; -+ ret = smsc75xx_write_reg(dev, DP_SEL, dp_sel); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing DP_SEL\n"); -+ goto done; -+ } -+ -+ for (i = 0; i < length; i++) { -+ ret = smsc75xx_write_reg(dev, DP_ADDR, addr + i); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing DP_ADDR\n"); -+ goto done; -+ } -+ -+ ret = smsc75xx_write_reg(dev, DP_DATA, buf[i]); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing DP_DATA\n"); -+ goto done; -+ } -+ -+ ret = smsc75xx_write_reg(dev, DP_CMD, DP_CMD_WRITE); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing DP_CMD\n"); -+ goto done; -+ } -+ -+ ret = smsc75xx_dataport_wait_not_busy(dev); -+ if (ret < 0) { -+ netdev_warn(dev->net, "smsc75xx_dataport_write timeout\n"); -+ goto done; -+ } -+ } -+ -+done: -+ mutex_unlock(&pdata->dataport_mutex); -+ return ret; -+} -+ -+/* returns hash bit number for given MAC address */ -+static u32 smsc75xx_hash(char addr[ETH_ALEN]) -+{ -+ return (ether_crc(ETH_ALEN, addr) >> 23) & 0x1ff; -+} -+ -+static void smsc75xx_deferred_multicast_write(struct work_struct *param) -+{ -+ struct smsc75xx_priv *pdata = -+ container_of(param, struct smsc75xx_priv, set_multicast); -+ struct usbnet *dev = pdata->dev; -+ int ret; -+ -+ netif_dbg(dev, drv, dev->net, "deferred multicast write 0x%08x\n", -+ pdata->rfe_ctl); -+ -+ smsc75xx_dataport_write(dev, DP_SEL_VHF, DP_SEL_VHF_VLAN_LEN, -+ DP_SEL_VHF_HASH_LEN, pdata->multicast_hash_table); -+ -+ ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); -+ if (ret < 0) -+ netdev_warn(dev->net, "Error writing RFE_CRL\n"); -+} -+ -+static void smsc75xx_set_multicast(struct net_device *netdev) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ unsigned long flags; -+ int i; -+ -+ spin_lock_irqsave(&pdata->rfe_ctl_lock, flags); -+ -+ pdata->rfe_ctl &= -+ ~(RFE_CTL_AU | RFE_CTL_AM | RFE_CTL_DPF | RFE_CTL_MHF); -+ pdata->rfe_ctl |= RFE_CTL_AB; -+ -+ for (i = 0; i < DP_SEL_VHF_HASH_LEN; i++) -+ pdata->multicast_hash_table[i] = 0; -+ -+ if (dev->net->flags & IFF_PROMISC) { -+ netif_dbg(dev, drv, dev->net, "promiscuous mode enabled\n"); -+ pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_AU; -+ } else if (dev->net->flags & IFF_ALLMULTI) { -+ netif_dbg(dev, drv, dev->net, "receive all multicast enabled\n"); -+ pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_DPF; -+ } else if (!netdev_mc_empty(dev->net)) { -+ struct netdev_hw_addr *ha; -+ -+ netif_dbg(dev, drv, dev->net, "receive multicast hash filter\n"); -+ -+ pdata->rfe_ctl |= RFE_CTL_MHF | RFE_CTL_DPF; -+ -+ netdev_for_each_mc_addr(ha, netdev) { -+ u32 bitnum = smsc75xx_hash(ha->addr); -+ pdata->multicast_hash_table[bitnum / 32] |= -+ (1 << (bitnum % 32)); -+ } -+ } else { -+ netif_dbg(dev, drv, dev->net, "receive own packets only\n"); -+ pdata->rfe_ctl |= RFE_CTL_DPF; -+ } -+ -+ spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags); -+ -+ /* defer register writes to a sleepable context */ -+ schedule_work(&pdata->set_multicast); -+} -+ -+static int smsc75xx_update_flowcontrol(struct usbnet *dev, u8 duplex, -+ u16 lcladv, u16 rmtadv) -+{ -+ u32 flow = 0, fct_flow = 0; -+ int ret; -+ -+ if (duplex == DUPLEX_FULL) { -+ u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); -+ -+ if (cap & FLOW_CTRL_TX) { -+ flow = (FLOW_TX_FCEN | 0xFFFF); -+ /* set fct_flow thresholds to 20% and 80% */ -+ fct_flow = (8 << 8) | 32; -+ } -+ -+ if (cap & FLOW_CTRL_RX) -+ flow |= FLOW_RX_FCEN; -+ -+ netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s\n", -+ (cap & FLOW_CTRL_RX ? "enabled" : "disabled"), -+ (cap & FLOW_CTRL_TX ? "enabled" : "disabled")); -+ } else { -+ netif_dbg(dev, link, dev->net, "half duplex\n"); -+ } -+ -+ ret = smsc75xx_write_reg(dev, FLOW, flow); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing FLOW\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_write_reg(dev, FCT_FLOW, fct_flow); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing FCT_FLOW\n"); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int smsc75xx_link_reset(struct usbnet *dev) -+{ -+ struct mii_if_info *mii = &dev->mii; -+ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; -+ u16 lcladv, rmtadv; -+ int ret; -+ -+ /* write to clear phy interrupt status */ -+ smsc75xx_mdio_write(dev->net, mii->phy_id, PHY_INT_SRC, -+ PHY_INT_SRC_CLEAR_ALL); -+ -+ ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing INT_STS\n"); -+ return ret; -+ } -+ -+ mii_check_media(mii, 1, 1); -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ lcladv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); -+ rmtadv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_LPA); -+ -+ netif_dbg(dev, link, dev->net, "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n", -+ ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv); -+ -+ return smsc75xx_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); -+} -+ -+static void smsc75xx_status(struct usbnet *dev, struct urb *urb) -+{ -+ u32 intdata; -+ -+ if (urb->actual_length != 4) { -+ netdev_warn(dev->net, "unexpected urb length %d\n", -+ urb->actual_length); -+ return; -+ } -+ -+ memcpy(&intdata, urb->transfer_buffer, 4); -+ le32_to_cpus(&intdata); -+ -+ netif_dbg(dev, link, dev->net, "intdata: 0x%08X\n", intdata); -+ -+ if (intdata & INT_ENP_PHY_INT) -+ usbnet_defer_kevent(dev, EVENT_LINK_RESET); -+ else -+ netdev_warn(dev->net, "unexpected interrupt, intdata=0x%08X\n", -+ intdata); -+} -+ -+static int smsc75xx_ethtool_get_eeprom_len(struct net_device *net) -+{ -+ return MAX_EEPROM_SIZE; -+} -+ -+static int smsc75xx_ethtool_get_eeprom(struct net_device *netdev, -+ struct ethtool_eeprom *ee, u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ -+ ee->magic = LAN75XX_EEPROM_MAGIC; -+ -+ return smsc75xx_read_eeprom(dev, ee->offset, ee->len, data); -+} -+ -+static int smsc75xx_ethtool_set_eeprom(struct net_device *netdev, -+ struct ethtool_eeprom *ee, u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ -+ if (ee->magic != LAN75XX_EEPROM_MAGIC) { -+ netdev_warn(dev->net, "EEPROM: magic value mismatch: 0x%x\n", -+ ee->magic); -+ return -EINVAL; -+ } -+ -+ return smsc75xx_write_eeprom(dev, ee->offset, ee->len, data); -+} -+ -+static void smsc75xx_ethtool_get_wol(struct net_device *net, -+ struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ -+ wolinfo->supported = SUPPORTED_WAKE; -+ wolinfo->wolopts = pdata->wolopts; -+} -+ -+static int smsc75xx_ethtool_set_wol(struct net_device *net, -+ struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ int ret; -+ -+ pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; -+ -+ ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); -+ if (ret < 0) -+ netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret); -+ -+ return ret; -+} -+ -+static const struct ethtool_ops smsc75xx_ethtool_ops = { -+ .get_link = usbnet_get_link, -+ .nway_reset = usbnet_nway_reset, -+ .get_drvinfo = usbnet_get_drvinfo, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .get_eeprom_len = smsc75xx_ethtool_get_eeprom_len, -+ .get_eeprom = smsc75xx_ethtool_get_eeprom, -+ .set_eeprom = smsc75xx_ethtool_set_eeprom, -+ .get_wol = smsc75xx_ethtool_get_wol, -+ .set_wol = smsc75xx_ethtool_set_wol, -+}; -+ -+static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ -+ if (!netif_running(netdev)) -+ return -EINVAL; -+ -+ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -+} -+ -+static void smsc75xx_init_mac_address(struct usbnet *dev) -+{ -+ /* try reading mac address from EEPROM */ -+ if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, -+ dev->net->dev_addr) == 0) { -+ if (is_valid_ether_addr(dev->net->dev_addr)) { -+ /* eeprom values are valid so use them */ -+ netif_dbg(dev, ifup, dev->net, -+ "MAC address read from EEPROM\n"); -+ return; -+ } -+ } -+ -+ /* no eeprom, or eeprom values are invalid. generate random MAC */ -+ eth_hw_addr_random(dev->net); -+ netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n"); -+} -+ -+static int smsc75xx_set_mac_address(struct usbnet *dev) -+{ -+ u32 addr_lo = dev->net->dev_addr[0] | dev->net->dev_addr[1] << 8 | -+ dev->net->dev_addr[2] << 16 | dev->net->dev_addr[3] << 24; -+ u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8; -+ -+ int ret = smsc75xx_write_reg(dev, RX_ADDRH, addr_hi); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write RX_ADDRH: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_write_reg(dev, RX_ADDRL, addr_lo); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write RX_ADDRL: %d\n", ret); -+ return ret; -+ } -+ -+ addr_hi |= ADDR_FILTX_FB_VALID; -+ ret = smsc75xx_write_reg(dev, ADDR_FILTX, addr_hi); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write ADDR_FILTX: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_write_reg(dev, ADDR_FILTX + 4, addr_lo); -+ if (ret < 0) -+ netdev_warn(dev->net, "Failed to write ADDR_FILTX+4: %d\n", ret); -+ -+ return ret; -+} -+ -+static int smsc75xx_phy_initialize(struct usbnet *dev) -+{ -+ int bmcr, ret, timeout = 0; -+ -+ /* Initialize MII structure */ -+ dev->mii.dev = dev->net; -+ dev->mii.mdio_read = smsc75xx_mdio_read; -+ dev->mii.mdio_write = smsc75xx_mdio_write; -+ dev->mii.phy_id_mask = 0x1f; -+ dev->mii.reg_num_mask = 0x1f; -+ dev->mii.supports_gmii = 1; -+ dev->mii.phy_id = SMSC75XX_INTERNAL_PHY_ID; -+ -+ /* reset phy and wait for reset to complete */ -+ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); -+ -+ do { -+ msleep(10); -+ bmcr = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); -+ if (bmcr < 0) { -+ netdev_warn(dev->net, "Error reading MII_BMCR\n"); -+ return bmcr; -+ } -+ timeout++; -+ } while ((bmcr & BMCR_RESET) && (timeout < 100)); -+ -+ if (timeout >= 100) { -+ netdev_warn(dev->net, "timeout on PHY Reset\n"); -+ return -EIO; -+ } -+ -+ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, -+ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | -+ ADVERTISE_PAUSE_ASYM); -+ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000, -+ ADVERTISE_1000FULL); -+ -+ /* read and write to clear phy interrupt status */ -+ ret = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PHY_INT_SRC\n"); -+ return ret; -+ } -+ -+ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_SRC, 0xffff); -+ -+ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, -+ PHY_INT_MASK_DEFAULT); -+ mii_nway_restart(&dev->mii); -+ -+ netif_dbg(dev, ifup, dev->net, "phy initialised successfully\n"); -+ return 0; -+} -+ -+static int smsc75xx_set_rx_max_frame_length(struct usbnet *dev, int size) -+{ -+ int ret = 0; -+ u32 buf; -+ bool rxenabled; -+ -+ ret = smsc75xx_read_reg(dev, MAC_RX, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret); -+ return ret; -+ } -+ -+ rxenabled = ((buf & MAC_RX_RXEN) != 0); -+ -+ if (rxenabled) { -+ buf &= ~MAC_RX_RXEN; -+ ret = smsc75xx_write_reg(dev, MAC_RX, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); -+ return ret; -+ } -+ } -+ -+ /* add 4 to size for FCS */ -+ buf &= ~MAC_RX_MAX_SIZE; -+ buf |= (((size + 4) << MAC_RX_MAX_SIZE_SHIFT) & MAC_RX_MAX_SIZE); -+ -+ ret = smsc75xx_write_reg(dev, MAC_RX, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); -+ return ret; -+ } -+ -+ if (rxenabled) { -+ buf |= MAC_RX_RXEN; -+ ret = smsc75xx_write_reg(dev, MAC_RX, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); -+ return ret; -+ } -+ } -+ -+ return 0; -+} -+ -+static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ int ret; -+ -+ if (new_mtu > MAX_SINGLE_PACKET_SIZE) -+ return -EINVAL; -+ -+ ret = smsc75xx_set_rx_max_frame_length(dev, new_mtu + ETH_HLEN); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to set mac rx frame length\n"); -+ return ret; -+ } -+ -+ return usbnet_change_mtu(netdev, new_mtu); -+} -+ -+/* Enable or disable Rx checksum offload engine */ -+static int smsc75xx_set_features(struct net_device *netdev, -+ netdev_features_t features) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ unsigned long flags; -+ int ret; -+ -+ spin_lock_irqsave(&pdata->rfe_ctl_lock, flags); -+ -+ if (features & NETIF_F_RXCSUM) -+ pdata->rfe_ctl |= RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM; -+ else -+ pdata->rfe_ctl &= ~(RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM); -+ -+ spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags); -+ /* it's racing here! */ -+ -+ ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); -+ if (ret < 0) -+ netdev_warn(dev->net, "Error writing RFE_CTL\n"); -+ -+ return ret; -+} -+ -+static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm) -+{ -+ int timeout = 0; -+ -+ do { -+ u32 buf; -+ int ret; -+ -+ ret = __smsc75xx_read_reg(dev, PMT_CTL, &buf, in_pm); -+ -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ if (buf & PMT_CTL_DEV_RDY) -+ return 0; -+ -+ msleep(10); -+ timeout++; -+ } while (timeout < 100); -+ -+ netdev_warn(dev->net, "timeout waiting for device ready\n"); -+ return -EIO; -+} -+ -+static int smsc75xx_reset(struct usbnet *dev) -+{ -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ u32 buf; -+ int ret = 0, timeout; -+ -+ netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset\n"); -+ -+ ret = smsc75xx_wait_ready(dev, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "device not ready in smsc75xx_reset\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ buf |= HW_CFG_LRST; -+ -+ ret = smsc75xx_write_reg(dev, HW_CFG, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ timeout = 0; -+ do { -+ msleep(10); -+ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); -+ return ret; -+ } -+ timeout++; -+ } while ((buf & HW_CFG_LRST) && (timeout < 100)); -+ -+ if (timeout >= 100) { -+ netdev_warn(dev->net, "timeout on completion of Lite Reset\n"); -+ return -EIO; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "Lite reset complete, resetting PHY\n"); -+ -+ ret = smsc75xx_read_reg(dev, PMT_CTL, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ buf |= PMT_CTL_PHY_RST; -+ -+ ret = smsc75xx_write_reg(dev, PMT_CTL, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ timeout = 0; -+ do { -+ msleep(10); -+ ret = smsc75xx_read_reg(dev, PMT_CTL, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret); -+ return ret; -+ } -+ timeout++; -+ } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100)); -+ -+ if (timeout >= 100) { -+ netdev_warn(dev->net, "timeout waiting for PHY Reset\n"); -+ return -EIO; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "PHY reset complete\n"); -+ -+ ret = smsc75xx_set_mac_address(dev); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to set mac address\n"); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "MAC Address: %pM\n", -+ dev->net->dev_addr); -+ -+ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n", -+ buf); -+ -+ buf |= HW_CFG_BIR; -+ -+ ret = smsc75xx_write_reg(dev, HW_CFG, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG after writing HW_CFG_BIR: 0x%08x\n", -+ buf); -+ -+ if (!turbo_mode) { -+ buf = 0; -+ dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE; -+ } else if (dev->udev->speed == USB_SPEED_HIGH) { -+ buf = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE; -+ dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE; -+ } else { -+ buf = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE; -+ dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "rx_urb_size=%ld\n", -+ (ulong)dev->rx_urb_size); -+ -+ ret = smsc75xx_write_reg(dev, BURST_CAP, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write BURST_CAP: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, BURST_CAP, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read BURST_CAP: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, -+ "Read Value from BURST_CAP after writing: 0x%08x\n", buf); -+ -+ ret = smsc75xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write BULK_IN_DLY: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, BULK_IN_DLY, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read BULK_IN_DLY: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, -+ "Read Value from BULK_IN_DLY after writing: 0x%08x\n", buf); -+ -+ if (turbo_mode) { -+ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf); -+ -+ buf |= (HW_CFG_MEF | HW_CFG_BCE); -+ -+ ret = smsc75xx_write_reg(dev, HW_CFG, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf); -+ } -+ -+ /* set FIFO sizes */ -+ buf = (MAX_RX_FIFO_SIZE - 512) / 512; -+ ret = smsc75xx_write_reg(dev, FCT_RX_FIFO_END, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write FCT_RX_FIFO_END: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "FCT_RX_FIFO_END set to 0x%08x\n", buf); -+ -+ buf = (MAX_TX_FIFO_SIZE - 512) / 512; -+ ret = smsc75xx_write_reg(dev, FCT_TX_FIFO_END, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write FCT_TX_FIFO_END: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "FCT_TX_FIFO_END set to 0x%08x\n", buf); -+ -+ ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write INT_STS: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, ID_REV, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read ID_REV: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", buf); -+ -+ ret = smsc75xx_read_reg(dev, E2P_CMD, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read E2P_CMD: %d\n", ret); -+ return ret; -+ } -+ -+ /* only set default GPIO/LED settings if no EEPROM is detected */ -+ if (!(buf & E2P_CMD_LOADED)) { -+ ret = smsc75xx_read_reg(dev, LED_GPIO_CFG, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read LED_GPIO_CFG: %d\n", ret); -+ return ret; -+ } -+ -+ buf &= ~(LED_GPIO_CFG_LED2_FUN_SEL | LED_GPIO_CFG_LED10_FUN_SEL); -+ buf |= LED_GPIO_CFG_LEDGPIO_EN | LED_GPIO_CFG_LED2_FUN_SEL; -+ -+ ret = smsc75xx_write_reg(dev, LED_GPIO_CFG, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write LED_GPIO_CFG: %d\n", ret); -+ return ret; -+ } -+ } -+ -+ ret = smsc75xx_write_reg(dev, FLOW, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write FLOW: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_write_reg(dev, FCT_FLOW, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write FCT_FLOW: %d\n", ret); -+ return ret; -+ } -+ -+ /* Don't need rfe_ctl_lock during initialisation */ -+ ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read RFE_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ pdata->rfe_ctl |= RFE_CTL_AB | RFE_CTL_DPF; -+ -+ ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write RFE_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read RFE_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "RFE_CTL set to 0x%08x\n", -+ pdata->rfe_ctl); -+ -+ /* Enable or disable checksum offload engines */ -+ smsc75xx_set_features(dev->net, dev->net->features); -+ -+ smsc75xx_set_multicast(dev->net); -+ -+ ret = smsc75xx_phy_initialize(dev); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to initialize PHY: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, INT_EP_CTL, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read INT_EP_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ /* enable PHY interrupts */ -+ buf |= INT_ENP_PHY_INT; -+ -+ ret = smsc75xx_write_reg(dev, INT_EP_CTL, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write INT_EP_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ /* allow mac to detect speed and duplex from phy */ -+ ret = smsc75xx_read_reg(dev, MAC_CR, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read MAC_CR: %d\n", ret); -+ return ret; -+ } -+ -+ buf |= (MAC_CR_ADD | MAC_CR_ASD); -+ ret = smsc75xx_write_reg(dev, MAC_CR, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write MAC_CR: %d\n", ret); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, MAC_TX, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read MAC_TX: %d\n", ret); -+ return ret; -+ } -+ -+ buf |= MAC_TX_TXEN; -+ -+ ret = smsc75xx_write_reg(dev, MAC_TX, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write MAC_TX: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "MAC_TX set to 0x%08x\n", buf); -+ -+ ret = smsc75xx_read_reg(dev, FCT_TX_CTL, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read FCT_TX_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ buf |= FCT_TX_CTL_EN; -+ -+ ret = smsc75xx_write_reg(dev, FCT_TX_CTL, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write FCT_TX_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "FCT_TX_CTL set to 0x%08x\n", buf); -+ -+ ret = smsc75xx_set_rx_max_frame_length(dev, dev->net->mtu + ETH_HLEN); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to set max rx frame length\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_read_reg(dev, MAC_RX, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret); -+ return ret; -+ } -+ -+ buf |= MAC_RX_RXEN; -+ -+ ret = smsc75xx_write_reg(dev, MAC_RX, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "MAC_RX set to 0x%08x\n", buf); -+ -+ ret = smsc75xx_read_reg(dev, FCT_RX_CTL, &buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read FCT_RX_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ buf |= FCT_RX_CTL_EN; -+ -+ ret = smsc75xx_write_reg(dev, FCT_RX_CTL, buf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write FCT_RX_CTL: %d\n", ret); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "FCT_RX_CTL set to 0x%08x\n", buf); -+ -+ netif_dbg(dev, ifup, dev->net, "smsc75xx_reset, return 0\n"); -+ return 0; -+} -+ -+static const struct net_device_ops smsc75xx_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = smsc75xx_change_mtu, -+ .ndo_set_mac_address = eth_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = smsc75xx_ioctl, -+ .ndo_set_rx_mode = smsc75xx_set_multicast, -+ .ndo_set_features = smsc75xx_set_features, -+}; -+ -+static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ struct smsc75xx_priv *pdata = NULL; -+ int ret; -+ -+ printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); -+ -+ ret = usbnet_get_endpoints(dev, intf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret); -+ return ret; -+ } -+ -+ dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc75xx_priv), -+ GFP_KERNEL); -+ -+ pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ if (!pdata) -+ return -ENOMEM; -+ -+ pdata->dev = dev; -+ -+ spin_lock_init(&pdata->rfe_ctl_lock); -+ mutex_init(&pdata->dataport_mutex); -+ -+ INIT_WORK(&pdata->set_multicast, smsc75xx_deferred_multicast_write); -+ -+ if (DEFAULT_TX_CSUM_ENABLE) -+ dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; -+ -+ if (DEFAULT_RX_CSUM_ENABLE) -+ dev->net->features |= NETIF_F_RXCSUM; -+ -+ dev->net->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | -+ NETIF_F_RXCSUM; -+ -+ ret = smsc75xx_wait_ready(dev, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "device not ready in smsc75xx_bind\n"); -+ return ret; -+ } -+ -+ smsc75xx_init_mac_address(dev); -+ -+ /* Init all registers */ -+ ret = smsc75xx_reset(dev); -+ if (ret < 0) { -+ netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret); -+ return ret; -+ } -+ -+ dev->net->netdev_ops = &smsc75xx_netdev_ops; -+ dev->net->ethtool_ops = &smsc75xx_ethtool_ops; -+ dev->net->flags |= IFF_MULTICAST; -+ dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD; -+ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; -+ return 0; -+} -+ -+static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ if (pdata) { -+ netif_dbg(dev, ifdown, dev->net, "free pdata\n"); -+ kfree(pdata); -+ pdata = NULL; -+ dev->data[0] = 0; -+ } -+} -+ -+static u16 smsc_crc(const u8 *buffer, size_t len) -+{ -+ return bitrev16(crc16(0xFFFF, buffer, len)); -+} -+ -+static int smsc75xx_write_wuff(struct usbnet *dev, int filter, u32 wuf_cfg, -+ u32 wuf_mask1) -+{ -+ int cfg_base = WUF_CFGX + filter * 4; -+ int mask_base = WUF_MASKX + filter * 16; -+ int ret; -+ -+ ret = smsc75xx_write_reg(dev, cfg_base, wuf_cfg); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUF_CFGX\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_write_reg(dev, mask_base, wuf_mask1); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUF_MASKX\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_write_reg(dev, mask_base + 4, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUF_MASKX\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_write_reg(dev, mask_base + 8, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUF_MASKX\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_write_reg(dev, mask_base + 12, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUF_MASKX\n"); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int smsc75xx_enter_suspend0(struct usbnet *dev) -+{ -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ u32 val; -+ int ret; -+ -+ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PMT_CTL\n"); -+ return ret; -+ } -+ -+ val &= (~(PMT_CTL_SUS_MODE | PMT_CTL_PHY_RST)); -+ val |= PMT_CTL_SUS_MODE_0 | PMT_CTL_WOL_EN | PMT_CTL_WUPS; -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ return ret; -+ } -+ -+ pdata->suspend_flags |= SUSPEND_SUSPEND0; -+ -+ return 0; -+} -+ -+static int smsc75xx_enter_suspend1(struct usbnet *dev) -+{ -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ u32 val; -+ int ret; -+ -+ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PMT_CTL\n"); -+ return ret; -+ } -+ -+ val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); -+ val |= PMT_CTL_SUS_MODE_1; -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ return ret; -+ } -+ -+ /* clear wol status, enable energy detection */ -+ val &= ~PMT_CTL_WUPS; -+ val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN); -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ return ret; -+ } -+ -+ pdata->suspend_flags |= SUSPEND_SUSPEND1; -+ -+ return 0; -+} -+ -+static int smsc75xx_enter_suspend2(struct usbnet *dev) -+{ -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ u32 val; -+ int ret; -+ -+ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PMT_CTL\n"); -+ return ret; -+ } -+ -+ val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); -+ val |= PMT_CTL_SUS_MODE_2; -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ return ret; -+ } -+ -+ pdata->suspend_flags |= SUSPEND_SUSPEND2; -+ -+ return 0; -+} -+ -+static int smsc75xx_enter_suspend3(struct usbnet *dev) -+{ -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ u32 val; -+ int ret; -+ -+ ret = smsc75xx_read_reg_nopm(dev, FCT_RX_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading FCT_RX_CTL\n"); -+ return ret; -+ } -+ -+ if (val & FCT_RX_CTL_RXUSED) { -+ netdev_dbg(dev->net, "rx fifo not empty in autosuspend\n"); -+ return -EBUSY; -+ } -+ -+ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PMT_CTL\n"); -+ return ret; -+ } -+ -+ val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); -+ val |= PMT_CTL_SUS_MODE_3 | PMT_CTL_RES_CLR_WKP_EN; -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ return ret; -+ } -+ -+ /* clear wol status */ -+ val &= ~PMT_CTL_WUPS; -+ val |= PMT_CTL_WUPS_WOL; -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ return ret; -+ } -+ -+ pdata->suspend_flags |= SUSPEND_SUSPEND3; -+ -+ return 0; -+} -+ -+static int smsc75xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) -+{ -+ struct mii_if_info *mii = &dev->mii; -+ int ret; -+ -+ netdev_dbg(dev->net, "enabling PHY wakeup interrupts\n"); -+ -+ /* read to clear */ -+ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PHY_INT_SRC\n"); -+ return ret; -+ } -+ -+ /* enable interrupt source */ -+ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PHY_INT_MASK\n"); -+ return ret; -+ } -+ -+ ret |= mask; -+ -+ smsc75xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_INT_MASK, ret); -+ -+ return 0; -+} -+ -+static int smsc75xx_link_ok_nopm(struct usbnet *dev) -+{ -+ struct mii_if_info *mii = &dev->mii; -+ int ret; -+ -+ /* first, a dummy read, needed to latch some MII phys */ -+ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading MII_BMSR\n"); -+ return ret; -+ } -+ -+ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading MII_BMSR\n"); -+ return ret; -+ } -+ -+ return !!(ret & BMSR_LSTATUS); -+} -+ -+static int smsc75xx_autosuspend(struct usbnet *dev, u32 link_up) -+{ -+ int ret; -+ -+ if (!netif_running(dev->net)) { -+ /* interface is ifconfig down so fully power down hw */ -+ netdev_dbg(dev->net, "autosuspend entering SUSPEND2\n"); -+ return smsc75xx_enter_suspend2(dev); -+ } -+ -+ if (!link_up) { -+ /* link is down so enter EDPD mode */ -+ netdev_dbg(dev->net, "autosuspend entering SUSPEND1\n"); -+ -+ /* enable PHY wakeup events for if cable is attached */ -+ ret = smsc75xx_enable_phy_wakeup_interrupts(dev, -+ PHY_INT_MASK_ANEG_COMP); -+ if (ret < 0) { -+ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); -+ return ret; -+ } -+ -+ netdev_info(dev->net, "entering SUSPEND1 mode\n"); -+ return smsc75xx_enter_suspend1(dev); -+ } -+ -+ /* enable PHY wakeup events so we remote wakeup if cable is pulled */ -+ ret = smsc75xx_enable_phy_wakeup_interrupts(dev, -+ PHY_INT_MASK_LINK_DOWN); -+ if (ret < 0) { -+ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); -+ return ret; -+ } -+ -+ netdev_dbg(dev->net, "autosuspend entering SUSPEND3\n"); -+ return smsc75xx_enter_suspend3(dev); -+} -+ -+static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message) -+{ -+ struct usbnet *dev = usb_get_intfdata(intf); -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ u32 val, link_up; -+ int ret; -+ -+ ret = usbnet_suspend(intf, message); -+ if (ret < 0) { -+ netdev_warn(dev->net, "usbnet_suspend error\n"); -+ return ret; -+ } -+ -+ if (pdata->suspend_flags) { -+ netdev_warn(dev->net, "error during last resume\n"); -+ pdata->suspend_flags = 0; -+ } -+ -+ /* determine if link is up using only _nopm functions */ -+ link_up = smsc75xx_link_ok_nopm(dev); -+ -+ if (message.event == PM_EVENT_AUTO_SUSPEND) { -+ ret = smsc75xx_autosuspend(dev, link_up); -+ goto done; -+ } -+ -+ /* if we get this far we're not autosuspending */ -+ /* if no wol options set, or if link is down and we're not waking on -+ * PHY activity, enter lowest power SUSPEND2 mode -+ */ -+ if (!(pdata->wolopts & SUPPORTED_WAKE) || -+ !(link_up || (pdata->wolopts & WAKE_PHY))) { -+ netdev_info(dev->net, "entering SUSPEND2 mode\n"); -+ -+ /* disable energy detect (link up) & wake up events */ -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ goto done; -+ } -+ -+ val &= ~(WUCSR_MPEN | WUCSR_WUEN); -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ goto done; -+ } -+ -+ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PMT_CTL\n"); -+ goto done; -+ } -+ -+ val &= ~(PMT_CTL_ED_EN | PMT_CTL_WOL_EN); -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ goto done; -+ } -+ -+ ret = smsc75xx_enter_suspend2(dev); -+ goto done; -+ } -+ -+ if (pdata->wolopts & WAKE_PHY) { -+ ret = smsc75xx_enable_phy_wakeup_interrupts(dev, -+ (PHY_INT_MASK_ANEG_COMP | PHY_INT_MASK_LINK_DOWN)); -+ if (ret < 0) { -+ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); -+ goto done; -+ } -+ -+ /* if link is down then configure EDPD and enter SUSPEND1, -+ * otherwise enter SUSPEND0 below -+ */ -+ if (!link_up) { -+ struct mii_if_info *mii = &dev->mii; -+ netdev_info(dev->net, "entering SUSPEND1 mode\n"); -+ -+ /* enable energy detect power-down mode */ -+ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, -+ PHY_MODE_CTRL_STS); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PHY_MODE_CTRL_STS\n"); -+ goto done; -+ } -+ -+ ret |= MODE_CTRL_STS_EDPWRDOWN; -+ -+ smsc75xx_mdio_write_nopm(dev->net, mii->phy_id, -+ PHY_MODE_CTRL_STS, ret); -+ -+ /* enter SUSPEND1 mode */ -+ ret = smsc75xx_enter_suspend1(dev); -+ goto done; -+ } -+ } -+ -+ if (pdata->wolopts & (WAKE_MCAST | WAKE_ARP)) { -+ int i, filter = 0; -+ -+ /* disable all filters */ -+ for (i = 0; i < WUF_NUM; i++) { -+ ret = smsc75xx_write_reg_nopm(dev, WUF_CFGX + i * 4, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUF_CFGX\n"); -+ goto done; -+ } -+ } -+ -+ if (pdata->wolopts & WAKE_MCAST) { -+ const u8 mcast[] = {0x01, 0x00, 0x5E}; -+ netdev_info(dev->net, "enabling multicast detection\n"); -+ -+ val = WUF_CFGX_EN | WUF_CFGX_ATYPE_MULTICAST -+ | smsc_crc(mcast, 3); -+ ret = smsc75xx_write_wuff(dev, filter++, val, 0x0007); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing wakeup filter\n"); -+ goto done; -+ } -+ } -+ -+ if (pdata->wolopts & WAKE_ARP) { -+ const u8 arp[] = {0x08, 0x06}; -+ netdev_info(dev->net, "enabling ARP detection\n"); -+ -+ val = WUF_CFGX_EN | WUF_CFGX_ATYPE_ALL | (0x0C << 16) -+ | smsc_crc(arp, 2); -+ ret = smsc75xx_write_wuff(dev, filter++, val, 0x0003); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing wakeup filter\n"); -+ goto done; -+ } -+ } -+ -+ /* clear any pending pattern match packet status */ -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ goto done; -+ } -+ -+ val |= WUCSR_WUFR; -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ goto done; -+ } -+ -+ netdev_info(dev->net, "enabling packet match detection\n"); -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ goto done; -+ } -+ -+ val |= WUCSR_WUEN; -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ goto done; -+ } -+ } else { -+ netdev_info(dev->net, "disabling packet match detection\n"); -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ goto done; -+ } -+ -+ val &= ~WUCSR_WUEN; -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ goto done; -+ } -+ } -+ -+ /* disable magic, bcast & unicast wakeup sources */ -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ goto done; -+ } -+ -+ val &= ~(WUCSR_MPEN | WUCSR_BCST_EN | WUCSR_PFDA_EN); -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ goto done; -+ } -+ -+ if (pdata->wolopts & WAKE_PHY) { -+ netdev_info(dev->net, "enabling PHY wakeup\n"); -+ -+ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PMT_CTL\n"); -+ goto done; -+ } -+ -+ /* clear wol status, enable energy detection */ -+ val &= ~PMT_CTL_WUPS; -+ val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN); -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ goto done; -+ } -+ } -+ -+ if (pdata->wolopts & WAKE_MAGIC) { -+ netdev_info(dev->net, "enabling magic packet wakeup\n"); -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ goto done; -+ } -+ -+ /* clear any pending magic packet status */ -+ val |= WUCSR_MPR | WUCSR_MPEN; -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ goto done; -+ } -+ } -+ -+ if (pdata->wolopts & WAKE_BCAST) { -+ netdev_info(dev->net, "enabling broadcast detection\n"); -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ goto done; -+ } -+ -+ val |= WUCSR_BCAST_FR | WUCSR_BCST_EN; -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ goto done; -+ } -+ } -+ -+ if (pdata->wolopts & WAKE_UCAST) { -+ netdev_info(dev->net, "enabling unicast detection\n"); -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ goto done; -+ } -+ -+ val |= WUCSR_WUFR | WUCSR_PFDA_EN; -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ goto done; -+ } -+ } -+ -+ /* enable receiver to enable frame reception */ -+ ret = smsc75xx_read_reg_nopm(dev, MAC_RX, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret); -+ goto done; -+ } -+ -+ val |= MAC_RX_RXEN; -+ -+ ret = smsc75xx_write_reg_nopm(dev, MAC_RX, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); -+ goto done; -+ } -+ -+ /* some wol options are enabled, so enter SUSPEND0 */ -+ netdev_info(dev->net, "entering SUSPEND0 mode\n"); -+ ret = smsc75xx_enter_suspend0(dev); -+ -+done: -+ /* -+ * TODO: resume() might need to handle the suspend failure -+ * in system sleep -+ */ -+ if (ret && PMSG_IS_AUTO(message)) -+ usbnet_resume(intf); -+ return ret; -+} -+ -+static int smsc75xx_resume(struct usb_interface *intf) -+{ -+ struct usbnet *dev = usb_get_intfdata(intf); -+ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); -+ u8 suspend_flags = pdata->suspend_flags; -+ int ret; -+ u32 val; -+ -+ netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags); -+ -+ /* do this first to ensure it's cleared even in error case */ -+ pdata->suspend_flags = 0; -+ -+ if (suspend_flags & SUSPEND_ALLMODES) { -+ /* Disable wakeup sources */ -+ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading WUCSR\n"); -+ return ret; -+ } -+ -+ val &= ~(WUCSR_WUEN | WUCSR_MPEN | WUCSR_PFDA_EN -+ | WUCSR_BCST_EN); -+ -+ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing WUCSR\n"); -+ return ret; -+ } -+ -+ /* clear wake-up status */ -+ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PMT_CTL\n"); -+ return ret; -+ } -+ -+ val &= ~PMT_CTL_WOL_EN; -+ val |= PMT_CTL_WUPS; -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ return ret; -+ } -+ } -+ -+ if (suspend_flags & SUSPEND_SUSPEND2) { -+ netdev_info(dev->net, "resuming from SUSPEND2\n"); -+ -+ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading PMT_CTL\n"); -+ return ret; -+ } -+ -+ val |= PMT_CTL_PHY_PWRUP; -+ -+ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing PMT_CTL\n"); -+ return ret; -+ } -+ } -+ -+ ret = smsc75xx_wait_ready(dev, 1); -+ if (ret < 0) { -+ netdev_warn(dev->net, "device not ready in smsc75xx_resume\n"); -+ return ret; -+ } -+ -+ return usbnet_resume(intf); -+} -+ -+static void smsc75xx_rx_csum_offload(struct usbnet *dev, struct sk_buff *skb, -+ u32 rx_cmd_a, u32 rx_cmd_b) -+{ -+ if (!(dev->net->features & NETIF_F_RXCSUM) || -+ unlikely(rx_cmd_a & RX_CMD_A_LCSM)) { -+ skb->ip_summed = CHECKSUM_NONE; -+ } else { -+ skb->csum = ntohs((u16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT)); -+ skb->ip_summed = CHECKSUM_COMPLETE; -+ } -+} -+ -+static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ /* This check is no longer done by usbnet */ -+ if (skb->len < dev->net->hard_header_len) -+ return 0; -+ -+ while (skb->len > 0) { -+ u32 rx_cmd_a, rx_cmd_b, align_count, size; -+ struct sk_buff *ax_skb; -+ unsigned char *packet; -+ -+ memcpy(&rx_cmd_a, skb->data, sizeof(rx_cmd_a)); -+ le32_to_cpus(&rx_cmd_a); -+ skb_pull(skb, 4); -+ -+ memcpy(&rx_cmd_b, skb->data, sizeof(rx_cmd_b)); -+ le32_to_cpus(&rx_cmd_b); -+ skb_pull(skb, 4 + RXW_PADDING); -+ -+ packet = skb->data; -+ -+ /* get the packet length */ -+ size = (rx_cmd_a & RX_CMD_A_LEN) - RXW_PADDING; -+ align_count = (4 - ((size + RXW_PADDING) % 4)) % 4; -+ -+ if (unlikely(rx_cmd_a & RX_CMD_A_RED)) { -+ netif_dbg(dev, rx_err, dev->net, -+ "Error rx_cmd_a=0x%08x\n", rx_cmd_a); -+ dev->net->stats.rx_errors++; -+ dev->net->stats.rx_dropped++; -+ -+ if (rx_cmd_a & RX_CMD_A_FCS) -+ dev->net->stats.rx_crc_errors++; -+ else if (rx_cmd_a & (RX_CMD_A_LONG | RX_CMD_A_RUNT)) -+ dev->net->stats.rx_frame_errors++; -+ } else { -+ /* MAX_SINGLE_PACKET_SIZE + 4(CRC) + 2(COE) + 4(Vlan) */ -+ if (unlikely(size > (MAX_SINGLE_PACKET_SIZE + ETH_HLEN + 12))) { -+ netif_dbg(dev, rx_err, dev->net, -+ "size err rx_cmd_a=0x%08x\n", -+ rx_cmd_a); -+ return 0; -+ } -+ -+ /* last frame in this batch */ -+ if (skb->len == size) { -+ smsc75xx_rx_csum_offload(dev, skb, rx_cmd_a, -+ rx_cmd_b); -+ -+ skb_trim(skb, skb->len - 4); /* remove fcs */ -+ skb->truesize = size + sizeof(struct sk_buff); -+ -+ return 1; -+ } -+ -+ ax_skb = skb_clone(skb, GFP_ATOMIC); -+ if (unlikely(!ax_skb)) { -+ netdev_warn(dev->net, "Error allocating skb\n"); -+ return 0; -+ } -+ -+ ax_skb->len = size; -+ ax_skb->data = packet; -+ skb_set_tail_pointer(ax_skb, size); -+ -+ smsc75xx_rx_csum_offload(dev, ax_skb, rx_cmd_a, -+ rx_cmd_b); -+ -+ skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */ -+ ax_skb->truesize = size + sizeof(struct sk_buff); -+ -+ usbnet_skb_return(dev, ax_skb); -+ } -+ -+ skb_pull(skb, size); -+ -+ /* padding bytes before the next frame starts */ -+ if (skb->len) -+ skb_pull(skb, align_count); -+ } -+ -+ if (unlikely(skb->len < 0)) { -+ netdev_warn(dev->net, "invalid rx length<0 %d\n", skb->len); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev, -+ struct sk_buff *skb, gfp_t flags) -+{ -+ u32 tx_cmd_a, tx_cmd_b; -+ -+ if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) { -+ struct sk_buff *skb2 = -+ skb_copy_expand(skb, SMSC75XX_TX_OVERHEAD, 0, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (!skb) -+ return NULL; -+ } -+ -+ tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS; -+ -+ if (skb->ip_summed == CHECKSUM_PARTIAL) -+ tx_cmd_a |= TX_CMD_A_IPE | TX_CMD_A_TPE; -+ -+ if (skb_is_gso(skb)) { -+ u16 mss = max(skb_shinfo(skb)->gso_size, TX_MSS_MIN); -+ tx_cmd_b = (mss << TX_CMD_B_MSS_SHIFT) & TX_CMD_B_MSS; -+ -+ tx_cmd_a |= TX_CMD_A_LSO; -+ } else { -+ tx_cmd_b = 0; -+ } -+ -+ skb_push(skb, 4); -+ cpu_to_le32s(&tx_cmd_b); -+ memcpy(skb->data, &tx_cmd_b, 4); -+ -+ skb_push(skb, 4); -+ cpu_to_le32s(&tx_cmd_a); -+ memcpy(skb->data, &tx_cmd_a, 4); -+ -+ return skb; -+} -+ -+static int smsc75xx_manage_power(struct usbnet *dev, int on) -+{ -+ dev->intf->needs_remote_wakeup = on; -+ return 0; -+} -+ -+static const struct driver_info smsc75xx_info = { -+ .description = "smsc75xx USB 2.0 Gigabit Ethernet", -+ .bind = smsc75xx_bind, -+ .unbind = smsc75xx_unbind, -+ .link_reset = smsc75xx_link_reset, -+ .reset = smsc75xx_reset, -+ .rx_fixup = smsc75xx_rx_fixup, -+ .tx_fixup = smsc75xx_tx_fixup, -+ .status = smsc75xx_status, -+ .manage_power = smsc75xx_manage_power, -+ .flags = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ /* SMSC7500 USB Gigabit Ethernet Device */ -+ USB_DEVICE(USB_VENDOR_ID_SMSC, USB_PRODUCT_ID_LAN7500), -+ .driver_info = (unsigned long) &smsc75xx_info, -+ }, -+ { -+ /* SMSC7500 USB Gigabit Ethernet Device */ -+ USB_DEVICE(USB_VENDOR_ID_SMSC, USB_PRODUCT_ID_LAN7505), -+ .driver_info = (unsigned long) &smsc75xx_info, -+ }, -+ { }, /* END */ -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver smsc75xx_driver = { -+ .name = SMSC_CHIPNAME, -+ .id_table = products, -+ .probe = usbnet_probe, -+ .suspend = smsc75xx_suspend, -+ .resume = smsc75xx_resume, -+ .reset_resume = smsc75xx_resume, -+ .disconnect = usbnet_disconnect, -+ .disable_hub_initiated_lpm = 1, -+ .supports_autosuspend = 1, -+}; -+ -+module_usb_driver(smsc75xx_driver); -+ -+MODULE_AUTHOR("Nancy Lin"); -+MODULE_AUTHOR("Steve Glendinning steve.glendinning@shawell.net"); -+MODULE_DESCRIPTION("SMSC75XX USB 2.0 Gigabit Ethernet Devices"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/smsc75xx.h backports-3.18.1-1/drivers/net/usb/smsc75xx.h ---- backports-3.18.1-1.org/drivers/net/usb/smsc75xx.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/smsc75xx.h 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,421 @@ -+ /*************************************************************************** -+ * -+ * Copyright (C) 2007-2010 SMSC -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2 -+ * of the License, or (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ * -+ *****************************************************************************/ -+ -+#ifndef _SMSC75XX_H -+#define _SMSC75XX_H -+ -+/* Tx command words */ -+#define TX_CMD_A_LSO (0x08000000) -+#define TX_CMD_A_IPE (0x04000000) -+#define TX_CMD_A_TPE (0x02000000) -+#define TX_CMD_A_IVTG (0x01000000) -+#define TX_CMD_A_RVTG (0x00800000) -+#define TX_CMD_A_FCS (0x00400000) -+#define TX_CMD_A_LEN (0x000FFFFF) -+ -+#define TX_CMD_B_MSS (0x3FFF0000) -+#define TX_CMD_B_MSS_SHIFT (16) -+#define TX_MSS_MIN ((u16)8) -+#define TX_CMD_B_VTAG (0x0000FFFF) -+ -+/* Rx command words */ -+#define RX_CMD_A_ICE (0x80000000) -+#define RX_CMD_A_TCE (0x40000000) -+#define RX_CMD_A_IPV (0x20000000) -+#define RX_CMD_A_PID (0x18000000) -+#define RX_CMD_A_PID_NIP (0x00000000) -+#define RX_CMD_A_PID_TCP (0x08000000) -+#define RX_CMD_A_PID_UDP (0x10000000) -+#define RX_CMD_A_PID_PP (0x18000000) -+#define RX_CMD_A_PFF (0x04000000) -+#define RX_CMD_A_BAM (0x02000000) -+#define RX_CMD_A_MAM (0x01000000) -+#define RX_CMD_A_FVTG (0x00800000) -+#define RX_CMD_A_RED (0x00400000) -+#define RX_CMD_A_RWT (0x00200000) -+#define RX_CMD_A_RUNT (0x00100000) -+#define RX_CMD_A_LONG (0x00080000) -+#define RX_CMD_A_RXE (0x00040000) -+#define RX_CMD_A_DRB (0x00020000) -+#define RX_CMD_A_FCS (0x00010000) -+#define RX_CMD_A_UAM (0x00008000) -+#define RX_CMD_A_LCSM (0x00004000) -+#define RX_CMD_A_LEN (0x00003FFF) -+ -+#define RX_CMD_B_CSUM (0xFFFF0000) -+#define RX_CMD_B_CSUM_SHIFT (16) -+#define RX_CMD_B_VTAG (0x0000FFFF) -+ -+/* SCSRs */ -+#define ID_REV (0x0000) -+ -+#define FPGA_REV (0x0004) -+ -+#define BOND_CTL (0x0008) -+ -+#define INT_STS (0x000C) -+#define INT_STS_RDFO_INT (0x00400000) -+#define INT_STS_TXE_INT (0x00200000) -+#define INT_STS_MACRTO_INT (0x00100000) -+#define INT_STS_TX_DIS_INT (0x00080000) -+#define INT_STS_RX_DIS_INT (0x00040000) -+#define INT_STS_PHY_INT_ (0x00020000) -+#define INT_STS_MAC_ERR_INT (0x00008000) -+#define INT_STS_TDFU (0x00004000) -+#define INT_STS_TDFO (0x00002000) -+#define INT_STS_GPIOS (0x00000FFF) -+#define INT_STS_CLEAR_ALL (0xFFFFFFFF) -+ -+#define HW_CFG (0x0010) -+#define HW_CFG_SMDET_STS (0x00008000) -+#define HW_CFG_SMDET_EN (0x00004000) -+#define HW_CFG_EEM (0x00002000) -+#define HW_CFG_RST_PROTECT (0x00001000) -+#define HW_CFG_PORT_SWAP (0x00000800) -+#define HW_CFG_PHY_BOOST (0x00000600) -+#define HW_CFG_PHY_BOOST_NORMAL (0x00000000) -+#define HW_CFG_PHY_BOOST_4 (0x00002000) -+#define HW_CFG_PHY_BOOST_8 (0x00004000) -+#define HW_CFG_PHY_BOOST_12 (0x00006000) -+#define HW_CFG_LEDB (0x00000100) -+#define HW_CFG_BIR (0x00000080) -+#define HW_CFG_SBP (0x00000040) -+#define HW_CFG_IME (0x00000020) -+#define HW_CFG_MEF (0x00000010) -+#define HW_CFG_ETC (0x00000008) -+#define HW_CFG_BCE (0x00000004) -+#define HW_CFG_LRST (0x00000002) -+#define HW_CFG_SRST (0x00000001) -+ -+#define PMT_CTL (0x0014) -+#define PMT_CTL_PHY_PWRUP (0x00000400) -+#define PMT_CTL_RES_CLR_WKP_EN (0x00000100) -+#define PMT_CTL_DEV_RDY (0x00000080) -+#define PMT_CTL_SUS_MODE (0x00000060) -+#define PMT_CTL_SUS_MODE_0 (0x00000000) -+#define PMT_CTL_SUS_MODE_1 (0x00000020) -+#define PMT_CTL_SUS_MODE_2 (0x00000040) -+#define PMT_CTL_SUS_MODE_3 (0x00000060) -+#define PMT_CTL_PHY_RST (0x00000010) -+#define PMT_CTL_WOL_EN (0x00000008) -+#define PMT_CTL_ED_EN (0x00000004) -+#define PMT_CTL_WUPS (0x00000003) -+#define PMT_CTL_WUPS_NO (0x00000000) -+#define PMT_CTL_WUPS_ED (0x00000001) -+#define PMT_CTL_WUPS_WOL (0x00000002) -+#define PMT_CTL_WUPS_MULTI (0x00000003) -+ -+#define LED_GPIO_CFG (0x0018) -+#define LED_GPIO_CFG_LED2_FUN_SEL (0x80000000) -+#define LED_GPIO_CFG_LED10_FUN_SEL (0x40000000) -+#define LED_GPIO_CFG_LEDGPIO_EN (0x0000F000) -+#define LED_GPIO_CFG_LEDGPIO_EN_0 (0x00001000) -+#define LED_GPIO_CFG_LEDGPIO_EN_1 (0x00002000) -+#define LED_GPIO_CFG_LEDGPIO_EN_2 (0x00004000) -+#define LED_GPIO_CFG_LEDGPIO_EN_3 (0x00008000) -+#define LED_GPIO_CFG_GPBUF (0x00000F00) -+#define LED_GPIO_CFG_GPBUF_0 (0x00000100) -+#define LED_GPIO_CFG_GPBUF_1 (0x00000200) -+#define LED_GPIO_CFG_GPBUF_2 (0x00000400) -+#define LED_GPIO_CFG_GPBUF_3 (0x00000800) -+#define LED_GPIO_CFG_GPDIR (0x000000F0) -+#define LED_GPIO_CFG_GPDIR_0 (0x00000010) -+#define LED_GPIO_CFG_GPDIR_1 (0x00000020) -+#define LED_GPIO_CFG_GPDIR_2 (0x00000040) -+#define LED_GPIO_CFG_GPDIR_3 (0x00000080) -+#define LED_GPIO_CFG_GPDATA (0x0000000F) -+#define LED_GPIO_CFG_GPDATA_0 (0x00000001) -+#define LED_GPIO_CFG_GPDATA_1 (0x00000002) -+#define LED_GPIO_CFG_GPDATA_2 (0x00000004) -+#define LED_GPIO_CFG_GPDATA_3 (0x00000008) -+ -+#define GPIO_CFG (0x001C) -+#define GPIO_CFG_SHIFT (24) -+#define GPIO_CFG_GPEN (0xFF000000) -+#define GPIO_CFG_GPBUF (0x00FF0000) -+#define GPIO_CFG_GPDIR (0x0000FF00) -+#define GPIO_CFG_GPDATA (0x000000FF) -+ -+#define GPIO_WAKE (0x0020) -+#define GPIO_WAKE_PHY_LINKUP_EN (0x80000000) -+#define GPIO_WAKE_POL (0x0FFF0000) -+#define GPIO_WAKE_POL_SHIFT (16) -+#define GPIO_WAKE_WK (0x00000FFF) -+ -+#define DP_SEL (0x0024) -+#define DP_SEL_DPRDY (0x80000000) -+#define DP_SEL_RSEL (0x0000000F) -+#define DP_SEL_URX (0x00000000) -+#define DP_SEL_VHF (0x00000001) -+#define DP_SEL_VHF_HASH_LEN (16) -+#define DP_SEL_VHF_VLAN_LEN (128) -+#define DP_SEL_LSO_HEAD (0x00000002) -+#define DP_SEL_FCT_RX (0x00000003) -+#define DP_SEL_FCT_TX (0x00000004) -+#define DP_SEL_DESCRIPTOR (0x00000005) -+#define DP_SEL_WOL (0x00000006) -+ -+#define DP_CMD (0x0028) -+#define DP_CMD_WRITE (0x01) -+#define DP_CMD_READ (0x00) -+ -+#define DP_ADDR (0x002C) -+ -+#define DP_DATA (0x0030) -+ -+#define BURST_CAP (0x0034) -+#define BURST_CAP_MASK (0x0000000F) -+ -+#define INT_EP_CTL (0x0038) -+#define INT_EP_CTL_INTEP_ON (0x80000000) -+#define INT_EP_CTL_RDFO_EN (0x00400000) -+#define INT_EP_CTL_TXE_EN (0x00200000) -+#define INT_EP_CTL_MACROTO_EN (0x00100000) -+#define INT_EP_CTL_TX_DIS_EN (0x00080000) -+#define INT_EP_CTL_RX_DIS_EN (0x00040000) -+#define INT_EP_CTL_PHY_EN_ (0x00020000) -+#define INT_EP_CTL_MAC_ERR_EN (0x00008000) -+#define INT_EP_CTL_TDFU_EN (0x00004000) -+#define INT_EP_CTL_TDFO_EN (0x00002000) -+#define INT_EP_CTL_RX_FIFO_EN (0x00001000) -+#define INT_EP_CTL_GPIOX_EN (0x00000FFF) -+ -+#define BULK_IN_DLY (0x003C) -+#define BULK_IN_DLY_MASK (0xFFFF) -+ -+#define E2P_CMD (0x0040) -+#define E2P_CMD_BUSY (0x80000000) -+#define E2P_CMD_MASK (0x70000000) -+#define E2P_CMD_READ (0x00000000) -+#define E2P_CMD_EWDS (0x10000000) -+#define E2P_CMD_EWEN (0x20000000) -+#define E2P_CMD_WRITE (0x30000000) -+#define E2P_CMD_WRAL (0x40000000) -+#define E2P_CMD_ERASE (0x50000000) -+#define E2P_CMD_ERAL (0x60000000) -+#define E2P_CMD_RELOAD (0x70000000) -+#define E2P_CMD_TIMEOUT (0x00000400) -+#define E2P_CMD_LOADED (0x00000200) -+#define E2P_CMD_ADDR (0x000001FF) -+ -+#define MAX_EEPROM_SIZE (512) -+ -+#define E2P_DATA (0x0044) -+#define E2P_DATA_MASK_ (0x000000FF) -+ -+#define RFE_CTL (0x0060) -+#define RFE_CTL_TCPUDP_CKM (0x00001000) -+#define RFE_CTL_IP_CKM (0x00000800) -+#define RFE_CTL_AB (0x00000400) -+#define RFE_CTL_AM (0x00000200) -+#define RFE_CTL_AU (0x00000100) -+#define RFE_CTL_VS (0x00000080) -+#define RFE_CTL_UF (0x00000040) -+#define RFE_CTL_VF (0x00000020) -+#define RFE_CTL_SPF (0x00000010) -+#define RFE_CTL_MHF (0x00000008) -+#define RFE_CTL_DHF (0x00000004) -+#define RFE_CTL_DPF (0x00000002) -+#define RFE_CTL_RST_RF (0x00000001) -+ -+#define VLAN_TYPE (0x0064) -+#define VLAN_TYPE_MASK (0x0000FFFF) -+ -+#define FCT_RX_CTL (0x0090) -+#define FCT_RX_CTL_EN (0x80000000) -+#define FCT_RX_CTL_RST (0x40000000) -+#define FCT_RX_CTL_SBF (0x02000000) -+#define FCT_RX_CTL_OVERFLOW (0x01000000) -+#define FCT_RX_CTL_FRM_DROP (0x00800000) -+#define FCT_RX_CTL_RX_NOT_EMPTY (0x00400000) -+#define FCT_RX_CTL_RX_EMPTY (0x00200000) -+#define FCT_RX_CTL_RX_DISABLED (0x00100000) -+#define FCT_RX_CTL_RXUSED (0x0000FFFF) -+ -+#define FCT_TX_CTL (0x0094) -+#define FCT_TX_CTL_EN (0x80000000) -+#define FCT_TX_CTL_RST (0x40000000) -+#define FCT_TX_CTL_TX_NOT_EMPTY (0x00400000) -+#define FCT_TX_CTL_TX_EMPTY (0x00200000) -+#define FCT_TX_CTL_TX_DISABLED (0x00100000) -+#define FCT_TX_CTL_TXUSED (0x0000FFFF) -+ -+#define FCT_RX_FIFO_END (0x0098) -+#define FCT_RX_FIFO_END_MASK (0x0000007F) -+ -+#define FCT_TX_FIFO_END (0x009C) -+#define FCT_TX_FIFO_END_MASK (0x0000003F) -+ -+#define FCT_FLOW (0x00A0) -+#define FCT_FLOW_THRESHOLD_OFF (0x00007F00) -+#define FCT_FLOW_THRESHOLD_OFF_SHIFT (8) -+#define FCT_FLOW_THRESHOLD_ON (0x0000007F) -+ -+/* MAC CSRs */ -+#define MAC_CR (0x100) -+#define MAC_CR_ADP (0x00002000) -+#define MAC_CR_ADD (0x00001000) -+#define MAC_CR_ASD (0x00000800) -+#define MAC_CR_INT_LOOP (0x00000400) -+#define MAC_CR_BOLMT (0x000000C0) -+#define MAC_CR_FDPX (0x00000008) -+#define MAC_CR_CFG (0x00000006) -+#define MAC_CR_CFG_10 (0x00000000) -+#define MAC_CR_CFG_100 (0x00000002) -+#define MAC_CR_CFG_1000 (0x00000004) -+#define MAC_CR_RST (0x00000001) -+ -+#define MAC_RX (0x104) -+#define MAC_RX_MAX_SIZE (0x3FFF0000) -+#define MAC_RX_MAX_SIZE_SHIFT (16) -+#define MAC_RX_FCS_STRIP (0x00000010) -+#define MAC_RX_FSE (0x00000004) -+#define MAC_RX_RXD (0x00000002) -+#define MAC_RX_RXEN (0x00000001) -+ -+#define MAC_TX (0x108) -+#define MAC_TX_BFCS (0x00000004) -+#define MAC_TX_TXD (0x00000002) -+#define MAC_TX_TXEN (0x00000001) -+ -+#define FLOW (0x10C) -+#define FLOW_FORCE_FC (0x80000000) -+#define FLOW_TX_FCEN (0x40000000) -+#define FLOW_RX_FCEN (0x20000000) -+#define FLOW_FPF (0x10000000) -+#define FLOW_PAUSE_TIME (0x0000FFFF) -+ -+#define RAND_SEED (0x110) -+#define RAND_SEED_MASK (0x0000FFFF) -+ -+#define ERR_STS (0x114) -+#define ERR_STS_FCS_ERR (0x00000100) -+#define ERR_STS_LFRM_ERR (0x00000080) -+#define ERR_STS_RUNT_ERR (0x00000040) -+#define ERR_STS_COLLISION_ERR (0x00000010) -+#define ERR_STS_ALIGN_ERR (0x00000008) -+#define ERR_STS_URUN_ERR (0x00000004) -+ -+#define RX_ADDRH (0x118) -+#define RX_ADDRH_MASK (0x0000FFFF) -+ -+#define RX_ADDRL (0x11C) -+ -+#define MII_ACCESS (0x120) -+#define MII_ACCESS_PHY_ADDR (0x0000F800) -+#define MII_ACCESS_PHY_ADDR_SHIFT (11) -+#define MII_ACCESS_REG_ADDR (0x000007C0) -+#define MII_ACCESS_REG_ADDR_SHIFT (6) -+#define MII_ACCESS_READ (0x00000000) -+#define MII_ACCESS_WRITE (0x00000002) -+#define MII_ACCESS_BUSY (0x00000001) -+ -+#define MII_DATA (0x124) -+#define MII_DATA_MASK (0x0000FFFF) -+ -+#define WUCSR (0x140) -+#define WUCSR_PFDA_FR (0x00000080) -+#define WUCSR_WUFR (0x00000040) -+#define WUCSR_MPR (0x00000020) -+#define WUCSR_BCAST_FR (0x00000010) -+#define WUCSR_PFDA_EN (0x00000008) -+#define WUCSR_WUEN (0x00000004) -+#define WUCSR_MPEN (0x00000002) -+#define WUCSR_BCST_EN (0x00000001) -+ -+#define WUF_CFGX (0x144) -+#define WUF_CFGX_EN (0x80000000) -+#define WUF_CFGX_ATYPE (0x03000000) -+#define WUF_CFGX_ATYPE_UNICAST (0x00000000) -+#define WUF_CFGX_ATYPE_MULTICAST (0x02000000) -+#define WUF_CFGX_ATYPE_ALL (0x03000000) -+#define WUF_CFGX_PATTERN_OFFSET (0x007F0000) -+#define WUF_CFGX_PATTERN_OFFSET_SHIFT (16) -+#define WUF_CFGX_CRC16 (0x0000FFFF) -+#define WUF_NUM (8) -+ -+#define WUF_MASKX (0x170) -+#define WUF_MASKX_AVALID (0x80000000) -+#define WUF_MASKX_ATYPE (0x40000000) -+ -+#define ADDR_FILTX (0x300) -+#define ADDR_FILTX_FB_VALID (0x80000000) -+#define ADDR_FILTX_FB_TYPE (0x40000000) -+#define ADDR_FILTX_FB_ADDRHI (0x0000FFFF) -+#define ADDR_FILTX_SB_ADDRLO (0xFFFFFFFF) -+ -+#define WUCSR2 (0x500) -+#define WUCSR2_NS_RCD (0x00000040) -+#define WUCSR2_ARP_RCD (0x00000020) -+#define WUCSR2_TCPSYN_RCD (0x00000010) -+#define WUCSR2_NS_OFFLOAD (0x00000004) -+#define WUCSR2_ARP_OFFLOAD (0x00000002) -+#define WUCSR2_TCPSYN_OFFLOAD (0x00000001) -+ -+#define WOL_FIFO_STS (0x504) -+ -+#define IPV6_ADDRX (0x510) -+ -+#define IPV4_ADDRX (0x590) -+ -+ -+/* Vendor-specific PHY Definitions */ -+ -+/* Mode Control/Status Register */ -+#define PHY_MODE_CTRL_STS (17) -+#define MODE_CTRL_STS_EDPWRDOWN ((u16)0x2000) -+#define MODE_CTRL_STS_ENERGYON ((u16)0x0002) -+ -+#define PHY_INT_SRC (29) -+#define PHY_INT_SRC_ENERGY_ON ((u16)0x0080) -+#define PHY_INT_SRC_ANEG_COMP ((u16)0x0040) -+#define PHY_INT_SRC_REMOTE_FAULT ((u16)0x0020) -+#define PHY_INT_SRC_LINK_DOWN ((u16)0x0010) -+#define PHY_INT_SRC_CLEAR_ALL ((u16)0xffff) -+ -+#define PHY_INT_MASK (30) -+#define PHY_INT_MASK_ENERGY_ON ((u16)0x0080) -+#define PHY_INT_MASK_ANEG_COMP ((u16)0x0040) -+#define PHY_INT_MASK_REMOTE_FAULT ((u16)0x0020) -+#define PHY_INT_MASK_LINK_DOWN ((u16)0x0010) -+#define PHY_INT_MASK_DEFAULT (PHY_INT_MASK_ANEG_COMP | \ -+ PHY_INT_MASK_LINK_DOWN) -+ -+#define PHY_SPECIAL (31) -+#define PHY_SPECIAL_SPD ((u16)0x001C) -+#define PHY_SPECIAL_SPD_10HALF ((u16)0x0004) -+#define PHY_SPECIAL_SPD_10FULL ((u16)0x0014) -+#define PHY_SPECIAL_SPD_100HALF ((u16)0x0008) -+#define PHY_SPECIAL_SPD_100FULL ((u16)0x0018) -+ -+/* USB Vendor Requests */ -+#define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0 -+#define USB_VENDOR_REQUEST_READ_REGISTER 0xA1 -+#define USB_VENDOR_REQUEST_GET_STATS 0xA2 -+ -+/* Interrupt Endpoint status word bitfields */ -+#define INT_ENP_RDFO_INT ((u32)BIT(22)) -+#define INT_ENP_TXE_INT ((u32)BIT(21)) -+#define INT_ENP_TX_DIS_INT ((u32)BIT(19)) -+#define INT_ENP_RX_DIS_INT ((u32)BIT(18)) -+#define INT_ENP_PHY_INT ((u32)BIT(17)) -+#define INT_ENP_MAC_ERR_INT ((u32)BIT(15)) -+#define INT_ENP_RX_FIFO_DATA_INT ((u32)BIT(12)) -+ -+#endif /* _SMSC75XX_H */ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/smsc95xx.c backports-3.18.1-1/drivers/net/usb/smsc95xx.c ---- backports-3.18.1-1.org/drivers/net/usb/smsc95xx.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/smsc95xx.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,2030 @@ -+ /*************************************************************************** -+ * -+ * Copyright (C) 2007-2008 SMSC -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2 -+ * of the License, or (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ * -+ *****************************************************************************/ -+ -+#include <linux/module.h> -+#include <linux/kmod.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/bitrev.h> -+#include <linux/crc16.h> -+#include <linux/crc32.h> -+#include <linux/usb/usbnet.h> -+#include <linux/slab.h> -+#include "smsc95xx.h" -+ -+#define SMSC_CHIPNAME "smsc95xx" -+#define SMSC_DRIVER_VERSION "1.0.4" -+#define HS_USB_PKT_SIZE (512) -+#define FS_USB_PKT_SIZE (64) -+#define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE) -+#define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE) -+#define DEFAULT_BULK_IN_DELAY (0x00002000) -+#define MAX_SINGLE_PACKET_SIZE (2048) -+#define LAN95XX_EEPROM_MAGIC (0x9500) -+#define EEPROM_MAC_OFFSET (0x01) -+#define DEFAULT_TX_CSUM_ENABLE (true) -+#define DEFAULT_RX_CSUM_ENABLE (true) -+#define SMSC95XX_INTERNAL_PHY_ID (1) -+#define SMSC95XX_TX_OVERHEAD (8) -+#define SMSC95XX_TX_OVERHEAD_CSUM (12) -+#define SUPPORTED_WAKE (WAKE_PHY | WAKE_UCAST | WAKE_BCAST | \ -+ WAKE_MCAST | WAKE_ARP | WAKE_MAGIC) -+ -+#define FEATURE_8_WAKEUP_FILTERS (0x01) -+#define FEATURE_PHY_NLP_CROSSOVER (0x02) -+#define FEATURE_REMOTE_WAKEUP (0x04) -+ -+#define SUSPEND_SUSPEND0 (0x01) -+#define SUSPEND_SUSPEND1 (0x02) -+#define SUSPEND_SUSPEND2 (0x04) -+#define SUSPEND_SUSPEND3 (0x08) -+#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \ -+ SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3) -+ -+struct smsc95xx_priv { -+ u32 mac_cr; -+ u32 hash_hi; -+ u32 hash_lo; -+ u32 wolopts; -+ spinlock_t mac_cr_lock; -+ u8 features; -+ u8 suspend_flags; -+}; -+ -+static bool turbo_mode = true; -+module_param(turbo_mode, bool, 0644); -+MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); -+ -+static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, -+ u32 *data, int in_pm) -+{ -+ u32 buf; -+ int ret; -+ int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); -+ -+ BUG_ON(!dev); -+ -+ if (!in_pm) -+ fn = usbnet_read_cmd; -+ else -+ fn = usbnet_read_cmd_nopm; -+ -+ ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN -+ | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ 0, index, &buf, 4); -+ if (unlikely(ret < 0)) -+ netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n", -+ index, ret); -+ -+ le32_to_cpus(&buf); -+ *data = buf; -+ -+ return ret; -+} -+ -+static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, -+ u32 data, int in_pm) -+{ -+ u32 buf; -+ int ret; -+ int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); -+ -+ BUG_ON(!dev); -+ -+ if (!in_pm) -+ fn = usbnet_write_cmd; -+ else -+ fn = usbnet_write_cmd_nopm; -+ -+ buf = data; -+ cpu_to_le32s(&buf); -+ -+ ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, USB_DIR_OUT -+ | USB_TYPE_VENDOR | USB_RECIP_DEVICE, -+ 0, index, &buf, 4); -+ if (unlikely(ret < 0)) -+ netdev_warn(dev->net, "Failed to write reg index 0x%08x: %d\n", -+ index, ret); -+ -+ return ret; -+} -+ -+static int __must_check smsc95xx_read_reg_nopm(struct usbnet *dev, u32 index, -+ u32 *data) -+{ -+ return __smsc95xx_read_reg(dev, index, data, 1); -+} -+ -+static int __must_check smsc95xx_write_reg_nopm(struct usbnet *dev, u32 index, -+ u32 data) -+{ -+ return __smsc95xx_write_reg(dev, index, data, 1); -+} -+ -+static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index, -+ u32 *data) -+{ -+ return __smsc95xx_read_reg(dev, index, data, 0); -+} -+ -+static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index, -+ u32 data) -+{ -+ return __smsc95xx_write_reg(dev, index, data, 0); -+} -+ -+/* Loop until the read is completed with timeout -+ * called with phy_mutex held */ -+static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev, -+ int in_pm) -+{ -+ unsigned long start_time = jiffies; -+ u32 val; -+ int ret; -+ -+ do { -+ ret = __smsc95xx_read_reg(dev, MII_ADDR, &val, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading MII_ACCESS\n"); -+ return ret; -+ } -+ -+ if (!(val & MII_BUSY_)) -+ return 0; -+ } while (!time_after(jiffies, start_time + HZ)); -+ -+ return -EIO; -+} -+ -+static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx, -+ int in_pm) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u32 val, addr; -+ int ret; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ /* confirm MII not busy */ -+ ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_read\n"); -+ goto done; -+ } -+ -+ /* set the address, index & direction (read from PHY) */ -+ phy_id &= dev->mii.phy_id_mask; -+ idx &= dev->mii.reg_num_mask; -+ addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_; -+ ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing MII_ADDR\n"); -+ goto done; -+ } -+ -+ ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx); -+ goto done; -+ } -+ -+ ret = __smsc95xx_read_reg(dev, MII_DATA, &val, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading MII_DATA\n"); -+ goto done; -+ } -+ -+ ret = (u16)(val & 0xFFFF); -+ -+done: -+ mutex_unlock(&dev->phy_mutex); -+ return ret; -+} -+ -+static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, -+ int idx, int regval, int in_pm) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u32 val, addr; -+ int ret; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ /* confirm MII not busy */ -+ ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_write\n"); -+ goto done; -+ } -+ -+ val = regval; -+ ret = __smsc95xx_write_reg(dev, MII_DATA, val, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing MII_DATA\n"); -+ goto done; -+ } -+ -+ /* set the address, index & direction (write to PHY) */ -+ phy_id &= dev->mii.phy_id_mask; -+ idx &= dev->mii.reg_num_mask; -+ addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_; -+ ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing MII_ADDR\n"); -+ goto done; -+ } -+ -+ ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx); -+ goto done; -+ } -+ -+done: -+ mutex_unlock(&dev->phy_mutex); -+} -+ -+static int smsc95xx_mdio_read_nopm(struct net_device *netdev, int phy_id, -+ int idx) -+{ -+ return __smsc95xx_mdio_read(netdev, phy_id, idx, 1); -+} -+ -+static void smsc95xx_mdio_write_nopm(struct net_device *netdev, int phy_id, -+ int idx, int regval) -+{ -+ __smsc95xx_mdio_write(netdev, phy_id, idx, regval, 1); -+} -+ -+static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) -+{ -+ return __smsc95xx_mdio_read(netdev, phy_id, idx, 0); -+} -+ -+static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx, -+ int regval) -+{ -+ __smsc95xx_mdio_write(netdev, phy_id, idx, regval, 0); -+} -+ -+static int __must_check smsc95xx_wait_eeprom(struct usbnet *dev) -+{ -+ unsigned long start_time = jiffies; -+ u32 val; -+ int ret; -+ -+ do { -+ ret = smsc95xx_read_reg(dev, E2P_CMD, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading E2P_CMD\n"); -+ return ret; -+ } -+ -+ if (!(val & E2P_CMD_BUSY_) || (val & E2P_CMD_TIMEOUT_)) -+ break; -+ udelay(40); -+ } while (!time_after(jiffies, start_time + HZ)); -+ -+ if (val & (E2P_CMD_TIMEOUT_ | E2P_CMD_BUSY_)) { -+ netdev_warn(dev->net, "EEPROM read operation timeout\n"); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ -+static int __must_check smsc95xx_eeprom_confirm_not_busy(struct usbnet *dev) -+{ -+ unsigned long start_time = jiffies; -+ u32 val; -+ int ret; -+ -+ do { -+ ret = smsc95xx_read_reg(dev, E2P_CMD, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading E2P_CMD\n"); -+ return ret; -+ } -+ -+ if (!(val & E2P_CMD_BUSY_)) -+ return 0; -+ -+ udelay(40); -+ } while (!time_after(jiffies, start_time + HZ)); -+ -+ netdev_warn(dev->net, "EEPROM is busy\n"); -+ return -EIO; -+} -+ -+static int smsc95xx_read_eeprom(struct usbnet *dev, u32 offset, u32 length, -+ u8 *data) -+{ -+ u32 val; -+ int i, ret; -+ -+ BUG_ON(!dev); -+ BUG_ON(!data); -+ -+ ret = smsc95xx_eeprom_confirm_not_busy(dev); -+ if (ret) -+ return ret; -+ -+ for (i = 0; i < length; i++) { -+ val = E2P_CMD_BUSY_ | E2P_CMD_READ_ | (offset & E2P_CMD_ADDR_); -+ ret = smsc95xx_write_reg(dev, E2P_CMD, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing E2P_CMD\n"); -+ return ret; -+ } -+ -+ ret = smsc95xx_wait_eeprom(dev); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_read_reg(dev, E2P_DATA, &val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error reading E2P_DATA\n"); -+ return ret; -+ } -+ -+ data[i] = val & 0xFF; -+ offset++; -+ } -+ -+ return 0; -+} -+ -+static int smsc95xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length, -+ u8 *data) -+{ -+ u32 val; -+ int i, ret; -+ -+ BUG_ON(!dev); -+ BUG_ON(!data); -+ -+ ret = smsc95xx_eeprom_confirm_not_busy(dev); -+ if (ret) -+ return ret; -+ -+ /* Issue write/erase enable command */ -+ val = E2P_CMD_BUSY_ | E2P_CMD_EWEN_; -+ ret = smsc95xx_write_reg(dev, E2P_CMD, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing E2P_DATA\n"); -+ return ret; -+ } -+ -+ ret = smsc95xx_wait_eeprom(dev); -+ if (ret < 0) -+ return ret; -+ -+ for (i = 0; i < length; i++) { -+ -+ /* Fill data register */ -+ val = data[i]; -+ ret = smsc95xx_write_reg(dev, E2P_DATA, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing E2P_DATA\n"); -+ return ret; -+ } -+ -+ /* Send "write" command */ -+ val = E2P_CMD_BUSY_ | E2P_CMD_WRITE_ | (offset & E2P_CMD_ADDR_); -+ ret = smsc95xx_write_reg(dev, E2P_CMD, val); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Error writing E2P_CMD\n"); -+ return ret; -+ } -+ -+ ret = smsc95xx_wait_eeprom(dev); -+ if (ret < 0) -+ return ret; -+ -+ offset++; -+ } -+ -+ return 0; -+} -+ -+static int __must_check smsc95xx_write_reg_async(struct usbnet *dev, u16 index, -+ u32 data) -+{ -+ const u16 size = 4; -+ u32 buf; -+ int ret; -+ -+ buf = data; -+ cpu_to_le32s(&buf); -+ -+ ret = usbnet_write_cmd_async(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, -+ USB_DIR_OUT | USB_TYPE_VENDOR | -+ USB_RECIP_DEVICE, -+ 0, index, &buf, size); -+ if (ret < 0) -+ netdev_warn(dev->net, "Error write async cmd, sts=%d\n", -+ ret); -+ return ret; -+} -+ -+/* returns hash bit number for given MAC address -+ * example: -+ * 01 00 5E 00 00 01 -> returns bit number 31 */ -+static unsigned int smsc95xx_hash(char addr[ETH_ALEN]) -+{ -+ return (ether_crc(ETH_ALEN, addr) >> 26) & 0x3f; -+} -+ -+static void smsc95xx_set_multicast(struct net_device *netdev) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ unsigned long flags; -+ int ret; -+ -+ pdata->hash_hi = 0; -+ pdata->hash_lo = 0; -+ -+ spin_lock_irqsave(&pdata->mac_cr_lock, flags); -+ -+ if (dev->net->flags & IFF_PROMISC) { -+ netif_dbg(dev, drv, dev->net, "promiscuous mode enabled\n"); -+ pdata->mac_cr |= MAC_CR_PRMS_; -+ pdata->mac_cr &= ~(MAC_CR_MCPAS_ | MAC_CR_HPFILT_); -+ } else if (dev->net->flags & IFF_ALLMULTI) { -+ netif_dbg(dev, drv, dev->net, "receive all multicast enabled\n"); -+ pdata->mac_cr |= MAC_CR_MCPAS_; -+ pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_HPFILT_); -+ } else if (!netdev_mc_empty(dev->net)) { -+ struct netdev_hw_addr *ha; -+ -+ pdata->mac_cr |= MAC_CR_HPFILT_; -+ pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_); -+ -+ netdev_for_each_mc_addr(ha, netdev) { -+ u32 bitnum = smsc95xx_hash(ha->addr); -+ u32 mask = 0x01 << (bitnum & 0x1F); -+ if (bitnum & 0x20) -+ pdata->hash_hi |= mask; -+ else -+ pdata->hash_lo |= mask; -+ } -+ -+ netif_dbg(dev, drv, dev->net, "HASHH=0x%08X, HASHL=0x%08X\n", -+ pdata->hash_hi, pdata->hash_lo); -+ } else { -+ netif_dbg(dev, drv, dev->net, "receive own packets only\n"); -+ pdata->mac_cr &= -+ ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_ | MAC_CR_HPFILT_); -+ } -+ -+ spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); -+ -+ /* Initiate async writes, as we can't wait for completion here */ -+ ret = smsc95xx_write_reg_async(dev, HASHH, pdata->hash_hi); -+ if (ret < 0) -+ netdev_warn(dev->net, "failed to initiate async write to HASHH\n"); -+ -+ ret = smsc95xx_write_reg_async(dev, HASHL, pdata->hash_lo); -+ if (ret < 0) -+ netdev_warn(dev->net, "failed to initiate async write to HASHL\n"); -+ -+ ret = smsc95xx_write_reg_async(dev, MAC_CR, pdata->mac_cr); -+ if (ret < 0) -+ netdev_warn(dev->net, "failed to initiate async write to MAC_CR\n"); -+} -+ -+static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, -+ u16 lcladv, u16 rmtadv) -+{ -+ u32 flow, afc_cfg = 0; -+ -+ int ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg); -+ if (ret < 0) -+ return ret; -+ -+ if (duplex == DUPLEX_FULL) { -+ u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); -+ -+ if (cap & FLOW_CTRL_RX) -+ flow = 0xFFFF0002; -+ else -+ flow = 0; -+ -+ if (cap & FLOW_CTRL_TX) -+ afc_cfg |= 0xF; -+ else -+ afc_cfg &= ~0xF; -+ -+ netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s\n", -+ cap & FLOW_CTRL_RX ? "enabled" : "disabled", -+ cap & FLOW_CTRL_TX ? "enabled" : "disabled"); -+ } else { -+ netif_dbg(dev, link, dev->net, "half duplex\n"); -+ flow = 0; -+ afc_cfg |= 0xF; -+ } -+ -+ ret = smsc95xx_write_reg(dev, FLOW, flow); -+ if (ret < 0) -+ return ret; -+ -+ return smsc95xx_write_reg(dev, AFC_CFG, afc_cfg); -+} -+ -+static int smsc95xx_link_reset(struct usbnet *dev) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ struct mii_if_info *mii = &dev->mii; -+ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; -+ unsigned long flags; -+ u16 lcladv, rmtadv; -+ int ret; -+ -+ /* clear interrupt status */ -+ ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_); -+ if (ret < 0) -+ return ret; -+ -+ mii_check_media(mii, 1, 1); -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ lcladv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); -+ rmtadv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_LPA); -+ -+ netif_dbg(dev, link, dev->net, -+ "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n", -+ ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv); -+ -+ spin_lock_irqsave(&pdata->mac_cr_lock, flags); -+ if (ecmd.duplex != DUPLEX_FULL) { -+ pdata->mac_cr &= ~MAC_CR_FDPX_; -+ pdata->mac_cr |= MAC_CR_RCVOWN_; -+ } else { -+ pdata->mac_cr &= ~MAC_CR_RCVOWN_; -+ pdata->mac_cr |= MAC_CR_FDPX_; -+ } -+ spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); -+ -+ ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_phy_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); -+ if (ret < 0) -+ netdev_warn(dev->net, "Error updating PHY flow control\n"); -+ -+ return ret; -+} -+ -+static void smsc95xx_status(struct usbnet *dev, struct urb *urb) -+{ -+ u32 intdata; -+ -+ if (urb->actual_length != 4) { -+ netdev_warn(dev->net, "unexpected urb length %d\n", -+ urb->actual_length); -+ return; -+ } -+ -+ memcpy(&intdata, urb->transfer_buffer, 4); -+ le32_to_cpus(&intdata); -+ -+ netif_dbg(dev, link, dev->net, "intdata: 0x%08X\n", intdata); -+ -+ if (intdata & INT_ENP_PHY_INT_) -+ usbnet_defer_kevent(dev, EVENT_LINK_RESET); -+ else -+ netdev_warn(dev->net, "unexpected interrupt, intdata=0x%08X\n", -+ intdata); -+} -+ -+/* Enable or disable Tx & Rx checksum offload engines */ -+static int smsc95xx_set_features(struct net_device *netdev, -+ netdev_features_t features) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u32 read_buf; -+ int ret; -+ -+ ret = smsc95xx_read_reg(dev, COE_CR, &read_buf); -+ if (ret < 0) -+ return ret; -+ -+ if (features & NETIF_F_HW_CSUM) -+ read_buf |= Tx_COE_EN_; -+ else -+ read_buf &= ~Tx_COE_EN_; -+ -+ if (features & NETIF_F_RXCSUM) -+ read_buf |= Rx_COE_EN_; -+ else -+ read_buf &= ~Rx_COE_EN_; -+ -+ ret = smsc95xx_write_reg(dev, COE_CR, read_buf); -+ if (ret < 0) -+ return ret; -+ -+ netif_dbg(dev, hw, dev->net, "COE_CR = 0x%08x\n", read_buf); -+ return 0; -+} -+ -+static int smsc95xx_ethtool_get_eeprom_len(struct net_device *net) -+{ -+ return MAX_EEPROM_SIZE; -+} -+ -+static int smsc95xx_ethtool_get_eeprom(struct net_device *netdev, -+ struct ethtool_eeprom *ee, u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ -+ ee->magic = LAN95XX_EEPROM_MAGIC; -+ -+ return smsc95xx_read_eeprom(dev, ee->offset, ee->len, data); -+} -+ -+static int smsc95xx_ethtool_set_eeprom(struct net_device *netdev, -+ struct ethtool_eeprom *ee, u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ -+ if (ee->magic != LAN95XX_EEPROM_MAGIC) { -+ netdev_warn(dev->net, "EEPROM: magic value mismatch, magic = 0x%x\n", -+ ee->magic); -+ return -EINVAL; -+ } -+ -+ return smsc95xx_write_eeprom(dev, ee->offset, ee->len, data); -+} -+ -+static int smsc95xx_ethtool_getregslen(struct net_device *netdev) -+{ -+ /* all smsc95xx registers */ -+ return COE_CR - ID_REV + sizeof(u32); -+} -+ -+static void -+smsc95xx_ethtool_getregs(struct net_device *netdev, struct ethtool_regs *regs, -+ void *buf) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ unsigned int i, j; -+ int retval; -+ u32 *data = buf; -+ -+ retval = smsc95xx_read_reg(dev, ID_REV, ®s->version); -+ if (retval < 0) { -+ netdev_warn(netdev, "REGS: cannot read ID_REV\n"); -+ return; -+ } -+ -+ for (i = ID_REV, j = 0; i <= COE_CR; i += (sizeof(u32)), j++) { -+ retval = smsc95xx_read_reg(dev, i, &data[j]); -+ if (retval < 0) { -+ netdev_warn(netdev, "REGS: cannot read reg[%x]\n", i); -+ return; -+ } -+ } -+} -+ -+static void smsc95xx_ethtool_get_wol(struct net_device *net, -+ struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ -+ wolinfo->supported = SUPPORTED_WAKE; -+ wolinfo->wolopts = pdata->wolopts; -+} -+ -+static int smsc95xx_ethtool_set_wol(struct net_device *net, -+ struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ int ret; -+ -+ pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; -+ -+ ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); -+ if (ret < 0) -+ netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret); -+ -+ return ret; -+} -+ -+static const struct ethtool_ops smsc95xx_ethtool_ops = { -+ .get_link = usbnet_get_link, -+ .nway_reset = usbnet_nway_reset, -+ .get_drvinfo = usbnet_get_drvinfo, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .get_eeprom_len = smsc95xx_ethtool_get_eeprom_len, -+ .get_eeprom = smsc95xx_ethtool_get_eeprom, -+ .set_eeprom = smsc95xx_ethtool_set_eeprom, -+ .get_regs_len = smsc95xx_ethtool_getregslen, -+ .get_regs = smsc95xx_ethtool_getregs, -+ .get_wol = smsc95xx_ethtool_get_wol, -+ .set_wol = smsc95xx_ethtool_set_wol, -+}; -+ -+static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ -+ if (!netif_running(netdev)) -+ return -EINVAL; -+ -+ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -+} -+ -+static void smsc95xx_init_mac_address(struct usbnet *dev) -+{ -+ /* try reading mac address from EEPROM */ -+ if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, -+ dev->net->dev_addr) == 0) { -+ if (is_valid_ether_addr(dev->net->dev_addr)) { -+ /* eeprom values are valid so use them */ -+ netif_dbg(dev, ifup, dev->net, "MAC address read from EEPROM\n"); -+ return; -+ } -+ } -+ -+ /* no eeprom, or eeprom values are invalid. generate random MAC */ -+ eth_hw_addr_random(dev->net); -+ netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n"); -+} -+ -+static int smsc95xx_set_mac_address(struct usbnet *dev) -+{ -+ u32 addr_lo = dev->net->dev_addr[0] | dev->net->dev_addr[1] << 8 | -+ dev->net->dev_addr[2] << 16 | dev->net->dev_addr[3] << 24; -+ u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8; -+ int ret; -+ -+ ret = smsc95xx_write_reg(dev, ADDRL, addr_lo); -+ if (ret < 0) -+ return ret; -+ -+ return smsc95xx_write_reg(dev, ADDRH, addr_hi); -+} -+ -+/* starts the TX path */ -+static int smsc95xx_start_tx_path(struct usbnet *dev) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ unsigned long flags; -+ int ret; -+ -+ /* Enable Tx at MAC */ -+ spin_lock_irqsave(&pdata->mac_cr_lock, flags); -+ pdata->mac_cr |= MAC_CR_TXEN_; -+ spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); -+ -+ ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); -+ if (ret < 0) -+ return ret; -+ -+ /* Enable Tx at SCSRs */ -+ return smsc95xx_write_reg(dev, TX_CFG, TX_CFG_ON_); -+} -+ -+/* Starts the Receive path */ -+static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ unsigned long flags; -+ -+ spin_lock_irqsave(&pdata->mac_cr_lock, flags); -+ pdata->mac_cr |= MAC_CR_RXEN_; -+ spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); -+ -+ return __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr, in_pm); -+} -+ -+static int smsc95xx_phy_initialize(struct usbnet *dev) -+{ -+ int bmcr, ret, timeout = 0; -+ -+ /* Initialize MII structure */ -+ dev->mii.dev = dev->net; -+ dev->mii.mdio_read = smsc95xx_mdio_read; -+ dev->mii.mdio_write = smsc95xx_mdio_write; -+ dev->mii.phy_id_mask = 0x1f; -+ dev->mii.reg_num_mask = 0x1f; -+ dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID; -+ -+ /* reset phy and wait for reset to complete */ -+ smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); -+ -+ do { -+ msleep(10); -+ bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); -+ timeout++; -+ } while ((bmcr & BMCR_RESET) && (timeout < 100)); -+ -+ if (timeout >= 100) { -+ netdev_warn(dev->net, "timeout on PHY Reset"); -+ return -EIO; -+ } -+ -+ smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, -+ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | -+ ADVERTISE_PAUSE_ASYM); -+ -+ /* read to clear */ -+ ret = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to read PHY_INT_SRC during init\n"); -+ return ret; -+ } -+ -+ smsc95xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, -+ PHY_INT_MASK_DEFAULT_); -+ mii_nway_restart(&dev->mii); -+ -+ netif_dbg(dev, ifup, dev->net, "phy initialised successfully\n"); -+ return 0; -+} -+ -+static int smsc95xx_reset(struct usbnet *dev) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ u32 read_buf, write_buf, burst_cap; -+ int ret = 0, timeout; -+ -+ netif_dbg(dev, ifup, dev->net, "entering smsc95xx_reset\n"); -+ -+ ret = smsc95xx_write_reg(dev, HW_CFG, HW_CFG_LRST_); -+ if (ret < 0) -+ return ret; -+ -+ timeout = 0; -+ do { -+ msleep(10); -+ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); -+ if (ret < 0) -+ return ret; -+ timeout++; -+ } while ((read_buf & HW_CFG_LRST_) && (timeout < 100)); -+ -+ if (timeout >= 100) { -+ netdev_warn(dev->net, "timeout waiting for completion of Lite Reset\n"); -+ return ret; -+ } -+ -+ ret = smsc95xx_write_reg(dev, PM_CTRL, PM_CTL_PHY_RST_); -+ if (ret < 0) -+ return ret; -+ -+ timeout = 0; -+ do { -+ msleep(10); -+ ret = smsc95xx_read_reg(dev, PM_CTRL, &read_buf); -+ if (ret < 0) -+ return ret; -+ timeout++; -+ } while ((read_buf & PM_CTL_PHY_RST_) && (timeout < 100)); -+ -+ if (timeout >= 100) { -+ netdev_warn(dev->net, "timeout waiting for PHY Reset\n"); -+ return ret; -+ } -+ -+ ret = smsc95xx_set_mac_address(dev); -+ if (ret < 0) -+ return ret; -+ -+ netif_dbg(dev, ifup, dev->net, "MAC Address: %pM\n", -+ dev->net->dev_addr); -+ -+ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); -+ if (ret < 0) -+ return ret; -+ -+ netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n", -+ read_buf); -+ -+ read_buf |= HW_CFG_BIR_; -+ -+ ret = smsc95xx_write_reg(dev, HW_CFG, read_buf); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); -+ if (ret < 0) -+ return ret; -+ -+ netif_dbg(dev, ifup, dev->net, -+ "Read Value from HW_CFG after writing HW_CFG_BIR_: 0x%08x\n", -+ read_buf); -+ -+ if (!turbo_mode) { -+ burst_cap = 0; -+ dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE; -+ } else if (dev->udev->speed == USB_SPEED_HIGH) { -+ burst_cap = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE; -+ dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE; -+ } else { -+ burst_cap = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE; -+ dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "rx_urb_size=%ld\n", -+ (ulong)dev->rx_urb_size); -+ -+ ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_read_reg(dev, BURST_CAP, &read_buf); -+ if (ret < 0) -+ return ret; -+ -+ netif_dbg(dev, ifup, dev->net, -+ "Read Value from BURST_CAP after writing: 0x%08x\n", -+ read_buf); -+ -+ ret = smsc95xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_read_reg(dev, BULK_IN_DLY, &read_buf); -+ if (ret < 0) -+ return ret; -+ -+ netif_dbg(dev, ifup, dev->net, -+ "Read Value from BULK_IN_DLY after writing: 0x%08x\n", -+ read_buf); -+ -+ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); -+ if (ret < 0) -+ return ret; -+ -+ netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG: 0x%08x\n", -+ read_buf); -+ -+ if (turbo_mode) -+ read_buf |= (HW_CFG_MEF_ | HW_CFG_BCE_); -+ -+ read_buf &= ~HW_CFG_RXDOFF_; -+ -+ /* set Rx data offset=2, Make IP header aligns on word boundary. */ -+ read_buf |= NET_IP_ALIGN << 9; -+ -+ ret = smsc95xx_write_reg(dev, HW_CFG, read_buf); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); -+ if (ret < 0) -+ return ret; -+ -+ netif_dbg(dev, ifup, dev->net, -+ "Read Value from HW_CFG after writing: 0x%08x\n", read_buf); -+ -+ ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_read_reg(dev, ID_REV, &read_buf); -+ if (ret < 0) -+ return ret; -+ netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", read_buf); -+ -+ /* Configure GPIO pins as LED outputs */ -+ write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED | -+ LED_GPIO_CFG_FDX_LED; -+ ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf); -+ if (ret < 0) -+ return ret; -+ -+ /* Init Tx */ -+ ret = smsc95xx_write_reg(dev, FLOW, 0); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_write_reg(dev, AFC_CFG, AFC_CFG_DEFAULT); -+ if (ret < 0) -+ return ret; -+ -+ /* Don't need mac_cr_lock during initialisation */ -+ ret = smsc95xx_read_reg(dev, MAC_CR, &pdata->mac_cr); -+ if (ret < 0) -+ return ret; -+ -+ /* Init Rx */ -+ /* Set Vlan */ -+ ret = smsc95xx_write_reg(dev, VLAN1, (u32)ETH_P_8021Q); -+ if (ret < 0) -+ return ret; -+ -+ /* Enable or disable checksum offload engines */ -+ ret = smsc95xx_set_features(dev->net, dev->net->features); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to set checksum offload features\n"); -+ return ret; -+ } -+ -+ smsc95xx_set_multicast(dev->net); -+ -+ ret = smsc95xx_phy_initialize(dev); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to init PHY\n"); -+ return ret; -+ } -+ -+ ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf); -+ if (ret < 0) -+ return ret; -+ -+ /* enable PHY interrupts */ -+ read_buf |= INT_EP_CTL_PHY_INT_; -+ -+ ret = smsc95xx_write_reg(dev, INT_EP_CTL, read_buf); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_start_tx_path(dev); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to start TX path\n"); -+ return ret; -+ } -+ -+ ret = smsc95xx_start_rx_path(dev, 0); -+ if (ret < 0) { -+ netdev_warn(dev->net, "Failed to start RX path\n"); -+ return ret; -+ } -+ -+ netif_dbg(dev, ifup, dev->net, "smsc95xx_reset, return 0\n"); -+ return 0; -+} -+ -+static const struct net_device_ops smsc95xx_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_set_mac_address = eth_mac_addr, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = smsc95xx_ioctl, -+ .ndo_set_rx_mode = smsc95xx_set_multicast, -+ .ndo_set_features = smsc95xx_set_features, -+}; -+ -+static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ struct smsc95xx_priv *pdata = NULL; -+ u32 val; -+ int ret; -+ -+ printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); -+ -+ ret = usbnet_get_endpoints(dev, intf); -+ if (ret < 0) { -+ netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret); -+ return ret; -+ } -+ -+ dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc95xx_priv), -+ GFP_KERNEL); -+ -+ pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ if (!pdata) -+ return -ENOMEM; -+ -+ spin_lock_init(&pdata->mac_cr_lock); -+ -+ if (DEFAULT_TX_CSUM_ENABLE) -+ dev->net->features |= NETIF_F_HW_CSUM; -+ if (DEFAULT_RX_CSUM_ENABLE) -+ dev->net->features |= NETIF_F_RXCSUM; -+ -+ dev->net->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM; -+ -+ smsc95xx_init_mac_address(dev); -+ -+ /* Init all registers */ -+ ret = smsc95xx_reset(dev); -+ -+ /* detect device revision as different features may be available */ -+ ret = smsc95xx_read_reg(dev, ID_REV, &val); -+ if (ret < 0) -+ return ret; -+ val >>= 16; -+ -+ if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9530_) || -+ (val == ID_REV_CHIP_ID_89530_) || (val == ID_REV_CHIP_ID_9730_)) -+ pdata->features = (FEATURE_8_WAKEUP_FILTERS | -+ FEATURE_PHY_NLP_CROSSOVER | -+ FEATURE_REMOTE_WAKEUP); -+ else if (val == ID_REV_CHIP_ID_9512_) -+ pdata->features = FEATURE_8_WAKEUP_FILTERS; -+ -+ dev->net->netdev_ops = &smsc95xx_netdev_ops; -+ dev->net->ethtool_ops = &smsc95xx_ethtool_ops; -+ dev->net->flags |= IFF_MULTICAST; -+ dev->net->hard_header_len += SMSC95XX_TX_OVERHEAD_CSUM; -+ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; -+ return 0; -+} -+ -+static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ if (pdata) { -+ netif_dbg(dev, ifdown, dev->net, "free pdata\n"); -+ kfree(pdata); -+ pdata = NULL; -+ dev->data[0] = 0; -+ } -+} -+ -+static u32 smsc_crc(const u8 *buffer, size_t len, int filter) -+{ -+ u32 crc = bitrev16(crc16(0xFFFF, buffer, len)); -+ return crc << ((filter % 2) * 16); -+} -+ -+static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) -+{ -+ struct mii_if_info *mii = &dev->mii; -+ int ret; -+ -+ netdev_dbg(dev->net, "enabling PHY wakeup interrupts\n"); -+ -+ /* read to clear */ -+ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC); -+ if (ret < 0) -+ return ret; -+ -+ /* enable interrupt source */ -+ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK); -+ if (ret < 0) -+ return ret; -+ -+ ret |= mask; -+ -+ smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_INT_MASK, ret); -+ -+ return 0; -+} -+ -+static int smsc95xx_link_ok_nopm(struct usbnet *dev) -+{ -+ struct mii_if_info *mii = &dev->mii; -+ int ret; -+ -+ /* first, a dummy read, needed to latch some MII phys */ -+ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); -+ if (ret < 0) -+ return ret; -+ -+ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); -+ if (ret < 0) -+ return ret; -+ -+ return !!(ret & BMSR_LSTATUS); -+} -+ -+static int smsc95xx_enter_suspend0(struct usbnet *dev) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ u32 val; -+ int ret; -+ -+ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); -+ if (ret < 0) -+ return ret; -+ -+ val &= (~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_)); -+ val |= PM_CTL_SUS_MODE_0; -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ return ret; -+ -+ /* clear wol status */ -+ val &= ~PM_CTL_WUPS_; -+ val |= PM_CTL_WUPS_WOL_; -+ -+ /* enable energy detection */ -+ if (pdata->wolopts & WAKE_PHY) -+ val |= PM_CTL_WUPS_ED_; -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ return ret; -+ -+ /* read back PM_CTRL */ -+ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); -+ if (ret < 0) -+ return ret; -+ -+ pdata->suspend_flags |= SUSPEND_SUSPEND0; -+ -+ return 0; -+} -+ -+static int smsc95xx_enter_suspend1(struct usbnet *dev) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ struct mii_if_info *mii = &dev->mii; -+ u32 val; -+ int ret; -+ -+ /* reconfigure link pulse detection timing for -+ * compatibility with non-standard link partners -+ */ -+ if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) -+ smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_EDPD_CONFIG, -+ PHY_EDPD_CONFIG_DEFAULT); -+ -+ /* enable energy detect power-down mode */ -+ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS); -+ if (ret < 0) -+ return ret; -+ -+ ret |= MODE_CTRL_STS_EDPWRDOWN_; -+ -+ smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS, ret); -+ -+ /* enter SUSPEND1 mode */ -+ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); -+ if (ret < 0) -+ return ret; -+ -+ val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); -+ val |= PM_CTL_SUS_MODE_1; -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ return ret; -+ -+ /* clear wol status, enable energy detection */ -+ val &= ~PM_CTL_WUPS_; -+ val |= (PM_CTL_WUPS_ED_ | PM_CTL_ED_EN_); -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ return ret; -+ -+ pdata->suspend_flags |= SUSPEND_SUSPEND1; -+ -+ return 0; -+} -+ -+static int smsc95xx_enter_suspend2(struct usbnet *dev) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ u32 val; -+ int ret; -+ -+ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); -+ if (ret < 0) -+ return ret; -+ -+ val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); -+ val |= PM_CTL_SUS_MODE_2; -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ return ret; -+ -+ pdata->suspend_flags |= SUSPEND_SUSPEND2; -+ -+ return 0; -+} -+ -+static int smsc95xx_enter_suspend3(struct usbnet *dev) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ u32 val; -+ int ret; -+ -+ ret = smsc95xx_read_reg_nopm(dev, RX_FIFO_INF, &val); -+ if (ret < 0) -+ return ret; -+ -+ if (val & 0xFFFF) { -+ netdev_info(dev->net, "rx fifo not empty in autosuspend\n"); -+ return -EBUSY; -+ } -+ -+ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); -+ if (ret < 0) -+ return ret; -+ -+ val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); -+ val |= PM_CTL_SUS_MODE_3 | PM_CTL_RES_CLR_WKP_STS; -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ return ret; -+ -+ /* clear wol status */ -+ val &= ~PM_CTL_WUPS_; -+ val |= PM_CTL_WUPS_WOL_; -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ return ret; -+ -+ pdata->suspend_flags |= SUSPEND_SUSPEND3; -+ -+ return 0; -+} -+ -+static int smsc95xx_autosuspend(struct usbnet *dev, u32 link_up) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ int ret; -+ -+ if (!netif_running(dev->net)) { -+ /* interface is ifconfig down so fully power down hw */ -+ netdev_dbg(dev->net, "autosuspend entering SUSPEND2\n"); -+ return smsc95xx_enter_suspend2(dev); -+ } -+ -+ if (!link_up) { -+ /* link is down so enter EDPD mode, but only if device can -+ * reliably resume from it. This check should be redundant -+ * as current FEATURE_REMOTE_WAKEUP parts also support -+ * FEATURE_PHY_NLP_CROSSOVER but it's included for clarity */ -+ if (!(pdata->features & FEATURE_PHY_NLP_CROSSOVER)) { -+ netdev_warn(dev->net, "EDPD not supported\n"); -+ return -EBUSY; -+ } -+ -+ netdev_dbg(dev->net, "autosuspend entering SUSPEND1\n"); -+ -+ /* enable PHY wakeup events for if cable is attached */ -+ ret = smsc95xx_enable_phy_wakeup_interrupts(dev, -+ PHY_INT_MASK_ANEG_COMP_); -+ if (ret < 0) { -+ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); -+ return ret; -+ } -+ -+ netdev_info(dev->net, "entering SUSPEND1 mode\n"); -+ return smsc95xx_enter_suspend1(dev); -+ } -+ -+ /* enable PHY wakeup events so we remote wakeup if cable is pulled */ -+ ret = smsc95xx_enable_phy_wakeup_interrupts(dev, -+ PHY_INT_MASK_LINK_DOWN_); -+ if (ret < 0) { -+ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); -+ return ret; -+ } -+ -+ netdev_dbg(dev->net, "autosuspend entering SUSPEND3\n"); -+ return smsc95xx_enter_suspend3(dev); -+} -+ -+static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) -+{ -+ struct usbnet *dev = usb_get_intfdata(intf); -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ u32 val, link_up; -+ int ret; -+ -+ ret = usbnet_suspend(intf, message); -+ if (ret < 0) { -+ netdev_warn(dev->net, "usbnet_suspend error\n"); -+ return ret; -+ } -+ -+ if (pdata->suspend_flags) { -+ netdev_warn(dev->net, "error during last resume\n"); -+ pdata->suspend_flags = 0; -+ } -+ -+ /* determine if link is up using only _nopm functions */ -+ link_up = smsc95xx_link_ok_nopm(dev); -+ -+ if (message.event == PM_EVENT_AUTO_SUSPEND && -+ (pdata->features & FEATURE_REMOTE_WAKEUP)) { -+ ret = smsc95xx_autosuspend(dev, link_up); -+ goto done; -+ } -+ -+ /* if we get this far we're not autosuspending */ -+ /* if no wol options set, or if link is down and we're not waking on -+ * PHY activity, enter lowest power SUSPEND2 mode -+ */ -+ if (!(pdata->wolopts & SUPPORTED_WAKE) || -+ !(link_up || (pdata->wolopts & WAKE_PHY))) { -+ netdev_info(dev->net, "entering SUSPEND2 mode\n"); -+ -+ /* disable energy detect (link up) & wake up events */ -+ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) -+ goto done; -+ -+ val &= ~(WUCSR_MPEN_ | WUCSR_WAKE_EN_); -+ -+ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) -+ goto done; -+ -+ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); -+ if (ret < 0) -+ goto done; -+ -+ val &= ~(PM_CTL_ED_EN_ | PM_CTL_WOL_EN_); -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ goto done; -+ -+ ret = smsc95xx_enter_suspend2(dev); -+ goto done; -+ } -+ -+ if (pdata->wolopts & WAKE_PHY) { -+ ret = smsc95xx_enable_phy_wakeup_interrupts(dev, -+ (PHY_INT_MASK_ANEG_COMP_ | PHY_INT_MASK_LINK_DOWN_)); -+ if (ret < 0) { -+ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); -+ goto done; -+ } -+ -+ /* if link is down then configure EDPD and enter SUSPEND1, -+ * otherwise enter SUSPEND0 below -+ */ -+ if (!link_up) { -+ netdev_info(dev->net, "entering SUSPEND1 mode\n"); -+ ret = smsc95xx_enter_suspend1(dev); -+ goto done; -+ } -+ } -+ -+ if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { -+ u32 *filter_mask = kzalloc(sizeof(u32) * 32, GFP_KERNEL); -+ u32 command[2]; -+ u32 offset[2]; -+ u32 crc[4]; -+ int wuff_filter_count = -+ (pdata->features & FEATURE_8_WAKEUP_FILTERS) ? -+ LAN9500A_WUFF_NUM : LAN9500_WUFF_NUM; -+ int i, filter = 0; -+ -+ if (!filter_mask) { -+ netdev_warn(dev->net, "Unable to allocate filter_mask\n"); -+ ret = -ENOMEM; -+ goto done; -+ } -+ -+ memset(command, 0, sizeof(command)); -+ memset(offset, 0, sizeof(offset)); -+ memset(crc, 0, sizeof(crc)); -+ -+ if (pdata->wolopts & WAKE_BCAST) { -+ const u8 bcast[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; -+ netdev_info(dev->net, "enabling broadcast detection\n"); -+ filter_mask[filter * 4] = 0x003F; -+ filter_mask[filter * 4 + 1] = 0x00; -+ filter_mask[filter * 4 + 2] = 0x00; -+ filter_mask[filter * 4 + 3] = 0x00; -+ command[filter/4] |= 0x05UL << ((filter % 4) * 8); -+ offset[filter/4] |= 0x00 << ((filter % 4) * 8); -+ crc[filter/2] |= smsc_crc(bcast, 6, filter); -+ filter++; -+ } -+ -+ if (pdata->wolopts & WAKE_MCAST) { -+ const u8 mcast[] = {0x01, 0x00, 0x5E}; -+ netdev_info(dev->net, "enabling multicast detection\n"); -+ filter_mask[filter * 4] = 0x0007; -+ filter_mask[filter * 4 + 1] = 0x00; -+ filter_mask[filter * 4 + 2] = 0x00; -+ filter_mask[filter * 4 + 3] = 0x00; -+ command[filter/4] |= 0x09UL << ((filter % 4) * 8); -+ offset[filter/4] |= 0x00 << ((filter % 4) * 8); -+ crc[filter/2] |= smsc_crc(mcast, 3, filter); -+ filter++; -+ } -+ -+ if (pdata->wolopts & WAKE_ARP) { -+ const u8 arp[] = {0x08, 0x06}; -+ netdev_info(dev->net, "enabling ARP detection\n"); -+ filter_mask[filter * 4] = 0x0003; -+ filter_mask[filter * 4 + 1] = 0x00; -+ filter_mask[filter * 4 + 2] = 0x00; -+ filter_mask[filter * 4 + 3] = 0x00; -+ command[filter/4] |= 0x05UL << ((filter % 4) * 8); -+ offset[filter/4] |= 0x0C << ((filter % 4) * 8); -+ crc[filter/2] |= smsc_crc(arp, 2, filter); -+ filter++; -+ } -+ -+ if (pdata->wolopts & WAKE_UCAST) { -+ netdev_info(dev->net, "enabling unicast detection\n"); -+ filter_mask[filter * 4] = 0x003F; -+ filter_mask[filter * 4 + 1] = 0x00; -+ filter_mask[filter * 4 + 2] = 0x00; -+ filter_mask[filter * 4 + 3] = 0x00; -+ command[filter/4] |= 0x01UL << ((filter % 4) * 8); -+ offset[filter/4] |= 0x00 << ((filter % 4) * 8); -+ crc[filter/2] |= smsc_crc(dev->net->dev_addr, ETH_ALEN, filter); -+ filter++; -+ } -+ -+ for (i = 0; i < (wuff_filter_count * 4); i++) { -+ ret = smsc95xx_write_reg_nopm(dev, WUFF, filter_mask[i]); -+ if (ret < 0) { -+ kfree(filter_mask); -+ goto done; -+ } -+ } -+ kfree(filter_mask); -+ -+ for (i = 0; i < (wuff_filter_count / 4); i++) { -+ ret = smsc95xx_write_reg_nopm(dev, WUFF, command[i]); -+ if (ret < 0) -+ goto done; -+ } -+ -+ for (i = 0; i < (wuff_filter_count / 4); i++) { -+ ret = smsc95xx_write_reg_nopm(dev, WUFF, offset[i]); -+ if (ret < 0) -+ goto done; -+ } -+ -+ for (i = 0; i < (wuff_filter_count / 2); i++) { -+ ret = smsc95xx_write_reg_nopm(dev, WUFF, crc[i]); -+ if (ret < 0) -+ goto done; -+ } -+ -+ /* clear any pending pattern match packet status */ -+ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) -+ goto done; -+ -+ val |= WUCSR_WUFR_; -+ -+ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) -+ goto done; -+ } -+ -+ if (pdata->wolopts & WAKE_MAGIC) { -+ /* clear any pending magic packet status */ -+ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) -+ goto done; -+ -+ val |= WUCSR_MPR_; -+ -+ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) -+ goto done; -+ } -+ -+ /* enable/disable wakeup sources */ -+ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) -+ goto done; -+ -+ if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { -+ netdev_info(dev->net, "enabling pattern match wakeup\n"); -+ val |= WUCSR_WAKE_EN_; -+ } else { -+ netdev_info(dev->net, "disabling pattern match wakeup\n"); -+ val &= ~WUCSR_WAKE_EN_; -+ } -+ -+ if (pdata->wolopts & WAKE_MAGIC) { -+ netdev_info(dev->net, "enabling magic packet wakeup\n"); -+ val |= WUCSR_MPEN_; -+ } else { -+ netdev_info(dev->net, "disabling magic packet wakeup\n"); -+ val &= ~WUCSR_MPEN_; -+ } -+ -+ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) -+ goto done; -+ -+ /* enable wol wakeup source */ -+ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); -+ if (ret < 0) -+ goto done; -+ -+ val |= PM_CTL_WOL_EN_; -+ -+ /* phy energy detect wakeup source */ -+ if (pdata->wolopts & WAKE_PHY) -+ val |= PM_CTL_ED_EN_; -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ goto done; -+ -+ /* enable receiver to enable frame reception */ -+ smsc95xx_start_rx_path(dev, 1); -+ -+ /* some wol options are enabled, so enter SUSPEND0 */ -+ netdev_info(dev->net, "entering SUSPEND0 mode\n"); -+ ret = smsc95xx_enter_suspend0(dev); -+ -+done: -+ /* -+ * TODO: resume() might need to handle the suspend failure -+ * in system sleep -+ */ -+ if (ret && PMSG_IS_AUTO(message)) -+ usbnet_resume(intf); -+ return ret; -+} -+ -+static int smsc95xx_resume(struct usb_interface *intf) -+{ -+ struct usbnet *dev = usb_get_intfdata(intf); -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ u8 suspend_flags = pdata->suspend_flags; -+ int ret; -+ u32 val; -+ -+ BUG_ON(!dev); -+ -+ netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags); -+ -+ /* do this first to ensure it's cleared even in error case */ -+ pdata->suspend_flags = 0; -+ -+ if (suspend_flags & SUSPEND_ALLMODES) { -+ /* clear wake-up sources */ -+ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); -+ if (ret < 0) -+ return ret; -+ -+ val &= ~(WUCSR_WAKE_EN_ | WUCSR_MPEN_); -+ -+ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); -+ if (ret < 0) -+ return ret; -+ -+ /* clear wake-up status */ -+ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); -+ if (ret < 0) -+ return ret; -+ -+ val &= ~PM_CTL_WOL_EN_; -+ val |= PM_CTL_WUPS_; -+ -+ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); -+ if (ret < 0) -+ return ret; -+ } -+ -+ ret = usbnet_resume(intf); -+ if (ret < 0) -+ netdev_warn(dev->net, "usbnet_resume error\n"); -+ -+ return ret; -+} -+ -+static int smsc95xx_reset_resume(struct usb_interface *intf) -+{ -+ struct usbnet *dev = usb_get_intfdata(intf); -+ int ret; -+ -+ ret = smsc95xx_reset(dev); -+ if (ret < 0) -+ return ret; -+ -+ return smsc95xx_resume(intf); -+} -+ -+static void smsc95xx_rx_csum_offload(struct sk_buff *skb) -+{ -+ skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2); -+ skb->ip_summed = CHECKSUM_COMPLETE; -+ skb_trim(skb, skb->len - 2); -+} -+ -+static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ /* This check is no longer done by usbnet */ -+ if (skb->len < dev->net->hard_header_len) -+ return 0; -+ -+ while (skb->len > 0) { -+ u32 header, align_count; -+ struct sk_buff *ax_skb; -+ unsigned char *packet; -+ u16 size; -+ -+ memcpy(&header, skb->data, sizeof(header)); -+ le32_to_cpus(&header); -+ skb_pull(skb, 4 + NET_IP_ALIGN); -+ packet = skb->data; -+ -+ /* get the packet length */ -+ size = (u16)((header & RX_STS_FL_) >> 16); -+ align_count = (4 - ((size + NET_IP_ALIGN) % 4)) % 4; -+ -+ if (unlikely(header & RX_STS_ES_)) { -+ netif_dbg(dev, rx_err, dev->net, -+ "Error header=0x%08x\n", header); -+ dev->net->stats.rx_errors++; -+ dev->net->stats.rx_dropped++; -+ -+ if (header & RX_STS_CRC_) { -+ dev->net->stats.rx_crc_errors++; -+ } else { -+ if (header & (RX_STS_TL_ | RX_STS_RF_)) -+ dev->net->stats.rx_frame_errors++; -+ -+ if ((header & RX_STS_LE_) && -+ (!(header & RX_STS_FT_))) -+ dev->net->stats.rx_length_errors++; -+ } -+ } else { -+ /* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */ -+ if (unlikely(size > (ETH_FRAME_LEN + 12))) { -+ netif_dbg(dev, rx_err, dev->net, -+ "size err header=0x%08x\n", header); -+ return 0; -+ } -+ -+ /* last frame in this batch */ -+ if (skb->len == size) { -+ if (dev->net->features & NETIF_F_RXCSUM) -+ smsc95xx_rx_csum_offload(skb); -+ skb_trim(skb, skb->len - 4); /* remove fcs */ -+ skb->truesize = size + sizeof(struct sk_buff); -+ -+ return 1; -+ } -+ -+ ax_skb = skb_clone(skb, GFP_ATOMIC); -+ if (unlikely(!ax_skb)) { -+ netdev_warn(dev->net, "Error allocating skb\n"); -+ return 0; -+ } -+ -+ ax_skb->len = size; -+ ax_skb->data = packet; -+ skb_set_tail_pointer(ax_skb, size); -+ -+ if (dev->net->features & NETIF_F_RXCSUM) -+ smsc95xx_rx_csum_offload(ax_skb); -+ skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */ -+ ax_skb->truesize = size + sizeof(struct sk_buff); -+ -+ usbnet_skb_return(dev, ax_skb); -+ } -+ -+ skb_pull(skb, size); -+ -+ /* padding bytes before the next frame starts */ -+ if (skb->len) -+ skb_pull(skb, align_count); -+ } -+ -+ if (unlikely(skb->len < 0)) { -+ netdev_warn(dev->net, "invalid rx length<0 %d\n", skb->len); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static u32 smsc95xx_calc_csum_preamble(struct sk_buff *skb) -+{ -+ u16 low_16 = (u16)skb_checksum_start_offset(skb); -+ u16 high_16 = low_16 + skb->csum_offset; -+ return (high_16 << 16) | low_16; -+} -+ -+static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, -+ struct sk_buff *skb, gfp_t flags) -+{ -+ bool csum = skb->ip_summed == CHECKSUM_PARTIAL; -+ int overhead = csum ? SMSC95XX_TX_OVERHEAD_CSUM : SMSC95XX_TX_OVERHEAD; -+ u32 tx_cmd_a, tx_cmd_b; -+ -+ /* We do not advertise SG, so skbs should be already linearized */ -+ BUG_ON(skb_shinfo(skb)->nr_frags); -+ -+ if (skb_headroom(skb) < overhead) { -+ struct sk_buff *skb2 = skb_copy_expand(skb, -+ overhead, 0, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (!skb) -+ return NULL; -+ } -+ -+ if (csum) { -+ if (skb->len <= 45) { -+ /* workaround - hardware tx checksum does not work -+ * properly with extremely small packets */ -+ long csstart = skb_checksum_start_offset(skb); -+ __wsum calc = csum_partial(skb->data + csstart, -+ skb->len - csstart, 0); -+ *((__sum16 *)(skb->data + csstart -+ + skb->csum_offset)) = csum_fold(calc); -+ -+ csum = false; -+ } else { -+ u32 csum_preamble = smsc95xx_calc_csum_preamble(skb); -+ skb_push(skb, 4); -+ cpu_to_le32s(&csum_preamble); -+ memcpy(skb->data, &csum_preamble, 4); -+ } -+ } -+ -+ skb_push(skb, 4); -+ tx_cmd_b = (u32)(skb->len - 4); -+ if (csum) -+ tx_cmd_b |= TX_CMD_B_CSUM_ENABLE; -+ cpu_to_le32s(&tx_cmd_b); -+ memcpy(skb->data, &tx_cmd_b, 4); -+ -+ skb_push(skb, 4); -+ tx_cmd_a = (u32)(skb->len - 8) | TX_CMD_A_FIRST_SEG_ | -+ TX_CMD_A_LAST_SEG_; -+ cpu_to_le32s(&tx_cmd_a); -+ memcpy(skb->data, &tx_cmd_a, 4); -+ -+ return skb; -+} -+ -+static int smsc95xx_manage_power(struct usbnet *dev, int on) -+{ -+ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); -+ -+ dev->intf->needs_remote_wakeup = on; -+ -+ if (pdata->features & FEATURE_REMOTE_WAKEUP) -+ return 0; -+ -+ /* this chip revision isn't capable of remote wakeup */ -+ netdev_info(dev->net, "hardware isn't capable of remote wakeup\n"); -+ -+ if (on) -+ usb_autopm_get_interface_no_resume(dev->intf); -+ else -+ usb_autopm_put_interface(dev->intf); -+ -+ return 0; -+} -+ -+static const struct driver_info smsc95xx_info = { -+ .description = "smsc95xx USB 2.0 Ethernet", -+ .bind = smsc95xx_bind, -+ .unbind = smsc95xx_unbind, -+ .link_reset = smsc95xx_link_reset, -+ .reset = smsc95xx_reset, -+ .rx_fixup = smsc95xx_rx_fixup, -+ .tx_fixup = smsc95xx_tx_fixup, -+ .status = smsc95xx_status, -+ .manage_power = smsc95xx_manage_power, -+ .flags = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ /* SMSC9500 USB Ethernet Device */ -+ USB_DEVICE(0x0424, 0x9500), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9505 USB Ethernet Device */ -+ USB_DEVICE(0x0424, 0x9505), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9500A USB Ethernet Device */ -+ USB_DEVICE(0x0424, 0x9E00), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9505A USB Ethernet Device */ -+ USB_DEVICE(0x0424, 0x9E01), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9512/9514 USB Hub & Ethernet Device */ -+ USB_DEVICE(0x0424, 0xec00), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9500 USB Ethernet Device (SAL10) */ -+ USB_DEVICE(0x0424, 0x9900), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9505 USB Ethernet Device (SAL10) */ -+ USB_DEVICE(0x0424, 0x9901), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9500A USB Ethernet Device (SAL10) */ -+ USB_DEVICE(0x0424, 0x9902), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9505A USB Ethernet Device (SAL10) */ -+ USB_DEVICE(0x0424, 0x9903), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9512/9514 USB Hub & Ethernet Device (SAL10) */ -+ USB_DEVICE(0x0424, 0x9904), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9500A USB Ethernet Device (HAL) */ -+ USB_DEVICE(0x0424, 0x9905), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9505A USB Ethernet Device (HAL) */ -+ USB_DEVICE(0x0424, 0x9906), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9500 USB Ethernet Device (Alternate ID) */ -+ USB_DEVICE(0x0424, 0x9907), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9500A USB Ethernet Device (Alternate ID) */ -+ USB_DEVICE(0x0424, 0x9908), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC9512/9514 USB Hub & Ethernet Device (Alternate ID) */ -+ USB_DEVICE(0x0424, 0x9909), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC LAN9530 USB Ethernet Device */ -+ USB_DEVICE(0x0424, 0x9530), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC LAN9730 USB Ethernet Device */ -+ USB_DEVICE(0x0424, 0x9730), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { -+ /* SMSC LAN89530 USB Ethernet Device */ -+ USB_DEVICE(0x0424, 0x9E08), -+ .driver_info = (unsigned long) &smsc95xx_info, -+ }, -+ { }, /* END */ -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver smsc95xx_driver = { -+ .name = "smsc95xx", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .suspend = smsc95xx_suspend, -+ .resume = smsc95xx_resume, -+ .reset_resume = smsc95xx_reset_resume, -+ .disconnect = usbnet_disconnect, -+ .disable_hub_initiated_lpm = 1, -+ .supports_autosuspend = 1, -+}; -+ -+module_usb_driver(smsc95xx_driver); -+ -+MODULE_AUTHOR("Nancy Lin"); -+MODULE_AUTHOR("Steve Glendinning steve.glendinning@shawell.net"); -+MODULE_DESCRIPTION("SMSC95XX USB 2.0 Ethernet Devices"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/smsc95xx.h backports-3.18.1-1/drivers/net/usb/smsc95xx.h ---- backports-3.18.1-1.org/drivers/net/usb/smsc95xx.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/smsc95xx.h 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,290 @@ -+ /*************************************************************************** -+ * -+ * Copyright (C) 2007-2008 SMSC -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * as published by the Free Software Foundation; either version 2 -+ * of the License, or (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ * -+ *****************************************************************************/ -+ -+#ifndef _SMSC95XX_H -+#define _SMSC95XX_H -+ -+/* Tx command words */ -+#define TX_CMD_A_DATA_OFFSET_ (0x001F0000) -+#define TX_CMD_A_FIRST_SEG_ (0x00002000) -+#define TX_CMD_A_LAST_SEG_ (0x00001000) -+#define TX_CMD_A_BUF_SIZE_ (0x000007FF) -+ -+#define TX_CMD_B_CSUM_ENABLE (0x00004000) -+#define TX_CMD_B_ADD_CRC_DISABLE_ (0x00002000) -+#define TX_CMD_B_DISABLE_PADDING_ (0x00001000) -+#define TX_CMD_B_PKT_BYTE_LENGTH_ (0x000007FF) -+ -+/* Rx status word */ -+#define RX_STS_FF_ (0x40000000) /* Filter Fail */ -+#define RX_STS_FL_ (0x3FFF0000) /* Frame Length */ -+#define RX_STS_ES_ (0x00008000) /* Error Summary */ -+#define RX_STS_BF_ (0x00002000) /* Broadcast Frame */ -+#define RX_STS_LE_ (0x00001000) /* Length Error */ -+#define RX_STS_RF_ (0x00000800) /* Runt Frame */ -+#define RX_STS_MF_ (0x00000400) /* Multicast Frame */ -+#define RX_STS_TL_ (0x00000080) /* Frame too long */ -+#define RX_STS_CS_ (0x00000040) /* Collision Seen */ -+#define RX_STS_FT_ (0x00000020) /* Frame Type */ -+#define RX_STS_RW_ (0x00000010) /* Receive Watchdog */ -+#define RX_STS_ME_ (0x00000008) /* Mii Error */ -+#define RX_STS_DB_ (0x00000004) /* Dribbling */ -+#define RX_STS_CRC_ (0x00000002) /* CRC Error */ -+ -+/* SCSRs */ -+#define ID_REV (0x00) -+#define ID_REV_CHIP_ID_MASK_ (0xFFFF0000) -+#define ID_REV_CHIP_REV_MASK_ (0x0000FFFF) -+#define ID_REV_CHIP_ID_9500_ (0x9500) -+#define ID_REV_CHIP_ID_9500A_ (0x9E00) -+#define ID_REV_CHIP_ID_9512_ (0xEC00) -+#define ID_REV_CHIP_ID_9530_ (0x9530) -+#define ID_REV_CHIP_ID_89530_ (0x9E08) -+#define ID_REV_CHIP_ID_9730_ (0x9730) -+ -+#define INT_STS (0x08) -+#define INT_STS_TX_STOP_ (0x00020000) -+#define INT_STS_RX_STOP_ (0x00010000) -+#define INT_STS_PHY_INT_ (0x00008000) -+#define INT_STS_TXE_ (0x00004000) -+#define INT_STS_TDFU_ (0x00002000) -+#define INT_STS_TDFO_ (0x00001000) -+#define INT_STS_RXDF_ (0x00000800) -+#define INT_STS_GPIOS_ (0x000007FF) -+#define INT_STS_CLEAR_ALL_ (0xFFFFFFFF) -+ -+#define RX_CFG (0x0C) -+#define RX_FIFO_FLUSH_ (0x00000001) -+ -+#define TX_CFG (0x10) -+#define TX_CFG_ON_ (0x00000004) -+#define TX_CFG_STOP_ (0x00000002) -+#define TX_CFG_FIFO_FLUSH_ (0x00000001) -+ -+#define HW_CFG (0x14) -+#define HW_CFG_BIR_ (0x00001000) -+#define HW_CFG_LEDB_ (0x00000800) -+#define HW_CFG_RXDOFF_ (0x00000600) -+#define HW_CFG_DRP_ (0x00000040) -+#define HW_CFG_MEF_ (0x00000020) -+#define HW_CFG_LRST_ (0x00000008) -+#define HW_CFG_PSEL_ (0x00000004) -+#define HW_CFG_BCE_ (0x00000002) -+#define HW_CFG_SRST_ (0x00000001) -+ -+#define RX_FIFO_INF (0x18) -+ -+#define PM_CTRL (0x20) -+#define PM_CTL_RES_CLR_WKP_STS (0x00000200) -+#define PM_CTL_DEV_RDY_ (0x00000080) -+#define PM_CTL_SUS_MODE_ (0x00000060) -+#define PM_CTL_SUS_MODE_0 (0x00000000) -+#define PM_CTL_SUS_MODE_1 (0x00000020) -+#define PM_CTL_SUS_MODE_2 (0x00000040) -+#define PM_CTL_SUS_MODE_3 (0x00000060) -+#define PM_CTL_PHY_RST_ (0x00000010) -+#define PM_CTL_WOL_EN_ (0x00000008) -+#define PM_CTL_ED_EN_ (0x00000004) -+#define PM_CTL_WUPS_ (0x00000003) -+#define PM_CTL_WUPS_NO_ (0x00000000) -+#define PM_CTL_WUPS_ED_ (0x00000001) -+#define PM_CTL_WUPS_WOL_ (0x00000002) -+#define PM_CTL_WUPS_MULTI_ (0x00000003) -+ -+#define LED_GPIO_CFG (0x24) -+#define LED_GPIO_CFG_SPD_LED (0x01000000) -+#define LED_GPIO_CFG_LNK_LED (0x00100000) -+#define LED_GPIO_CFG_FDX_LED (0x00010000) -+ -+#define GPIO_CFG (0x28) -+ -+#define AFC_CFG (0x2C) -+ -+/* Hi watermark = 15.5Kb (~10 mtu pkts) */ -+/* low watermark = 3k (~2 mtu pkts) */ -+/* backpressure duration = ~ 350us */ -+/* Apply FC on any frame. */ -+#define AFC_CFG_DEFAULT (0x00F830A1) -+ -+#define E2P_CMD (0x30) -+#define E2P_CMD_BUSY_ (0x80000000) -+#define E2P_CMD_MASK_ (0x70000000) -+#define E2P_CMD_READ_ (0x00000000) -+#define E2P_CMD_EWDS_ (0x10000000) -+#define E2P_CMD_EWEN_ (0x20000000) -+#define E2P_CMD_WRITE_ (0x30000000) -+#define E2P_CMD_WRAL_ (0x40000000) -+#define E2P_CMD_ERASE_ (0x50000000) -+#define E2P_CMD_ERAL_ (0x60000000) -+#define E2P_CMD_RELOAD_ (0x70000000) -+#define E2P_CMD_TIMEOUT_ (0x00000400) -+#define E2P_CMD_LOADED_ (0x00000200) -+#define E2P_CMD_ADDR_ (0x000001FF) -+ -+#define MAX_EEPROM_SIZE (512) -+ -+#define E2P_DATA (0x34) -+#define E2P_DATA_MASK_ (0x000000FF) -+ -+#define BURST_CAP (0x38) -+ -+#define GPIO_WAKE (0x64) -+ -+#define INT_EP_CTL (0x68) -+#define INT_EP_CTL_INTEP_ (0x80000000) -+#define INT_EP_CTL_MACRTO_ (0x00080000) -+#define INT_EP_CTL_TX_STOP_ (0x00020000) -+#define INT_EP_CTL_RX_STOP_ (0x00010000) -+#define INT_EP_CTL_PHY_INT_ (0x00008000) -+#define INT_EP_CTL_TXE_ (0x00004000) -+#define INT_EP_CTL_TDFU_ (0x00002000) -+#define INT_EP_CTL_TDFO_ (0x00001000) -+#define INT_EP_CTL_RXDF_ (0x00000800) -+#define INT_EP_CTL_GPIOS_ (0x000007FF) -+ -+#define BULK_IN_DLY (0x6C) -+ -+/* MAC CSRs */ -+#define MAC_CR (0x100) -+#define MAC_CR_RXALL_ (0x80000000) -+#define MAC_CR_RCVOWN_ (0x00800000) -+#define MAC_CR_LOOPBK_ (0x00200000) -+#define MAC_CR_FDPX_ (0x00100000) -+#define MAC_CR_MCPAS_ (0x00080000) -+#define MAC_CR_PRMS_ (0x00040000) -+#define MAC_CR_INVFILT_ (0x00020000) -+#define MAC_CR_PASSBAD_ (0x00010000) -+#define MAC_CR_HFILT_ (0x00008000) -+#define MAC_CR_HPFILT_ (0x00002000) -+#define MAC_CR_LCOLL_ (0x00001000) -+#define MAC_CR_BCAST_ (0x00000800) -+#define MAC_CR_DISRTY_ (0x00000400) -+#define MAC_CR_PADSTR_ (0x00000100) -+#define MAC_CR_BOLMT_MASK (0x000000C0) -+#define MAC_CR_DFCHK_ (0x00000020) -+#define MAC_CR_TXEN_ (0x00000008) -+#define MAC_CR_RXEN_ (0x00000004) -+ -+#define ADDRH (0x104) -+ -+#define ADDRL (0x108) -+ -+#define HASHH (0x10C) -+ -+#define HASHL (0x110) -+ -+#define MII_ADDR (0x114) -+#define MII_WRITE_ (0x02) -+#define MII_BUSY_ (0x01) -+#define MII_READ_ (0x00) /* ~of MII Write bit */ -+ -+#define MII_DATA (0x118) -+ -+#define FLOW (0x11C) -+#define FLOW_FCPT_ (0xFFFF0000) -+#define FLOW_FCPASS_ (0x00000004) -+#define FLOW_FCEN_ (0x00000002) -+#define FLOW_FCBSY_ (0x00000001) -+ -+#define VLAN1 (0x120) -+ -+#define VLAN2 (0x124) -+ -+#define WUFF (0x128) -+#define LAN9500_WUFF_NUM (4) -+#define LAN9500A_WUFF_NUM (8) -+ -+#define WUCSR (0x12C) -+#define WUCSR_WFF_PTR_RST_ (0x80000000) -+#define WUCSR_GUE_ (0x00000200) -+#define WUCSR_WUFR_ (0x00000040) -+#define WUCSR_MPR_ (0x00000020) -+#define WUCSR_WAKE_EN_ (0x00000004) -+#define WUCSR_MPEN_ (0x00000002) -+ -+#define COE_CR (0x130) -+#define Tx_COE_EN_ (0x00010000) -+#define Rx_COE_MODE_ (0x00000002) -+#define Rx_COE_EN_ (0x00000001) -+ -+/* Vendor-specific PHY Definitions */ -+ -+/* EDPD NLP / crossover time configuration (LAN9500A only) */ -+#define PHY_EDPD_CONFIG (16) -+#define PHY_EDPD_CONFIG_TX_NLP_EN_ ((u16)0x8000) -+#define PHY_EDPD_CONFIG_TX_NLP_1000_ ((u16)0x0000) -+#define PHY_EDPD_CONFIG_TX_NLP_768_ ((u16)0x2000) -+#define PHY_EDPD_CONFIG_TX_NLP_512_ ((u16)0x4000) -+#define PHY_EDPD_CONFIG_TX_NLP_256_ ((u16)0x6000) -+#define PHY_EDPD_CONFIG_RX_1_NLP_ ((u16)0x1000) -+#define PHY_EDPD_CONFIG_RX_NLP_64_ ((u16)0x0000) -+#define PHY_EDPD_CONFIG_RX_NLP_256_ ((u16)0x0400) -+#define PHY_EDPD_CONFIG_RX_NLP_512_ ((u16)0x0800) -+#define PHY_EDPD_CONFIG_RX_NLP_1000_ ((u16)0x0C00) -+#define PHY_EDPD_CONFIG_EXT_CROSSOVER_ ((u16)0x0001) -+#define PHY_EDPD_CONFIG_DEFAULT (PHY_EDPD_CONFIG_TX_NLP_EN_ | \ -+ PHY_EDPD_CONFIG_TX_NLP_768_ | \ -+ PHY_EDPD_CONFIG_RX_1_NLP_) -+ -+/* Mode Control/Status Register */ -+#define PHY_MODE_CTRL_STS (17) -+#define MODE_CTRL_STS_EDPWRDOWN_ ((u16)0x2000) -+#define MODE_CTRL_STS_ENERGYON_ ((u16)0x0002) -+ -+#define SPECIAL_CTRL_STS (27) -+#define SPECIAL_CTRL_STS_OVRRD_AMDIX_ ((u16)0x8000) -+#define SPECIAL_CTRL_STS_AMDIX_ENABLE_ ((u16)0x4000) -+#define SPECIAL_CTRL_STS_AMDIX_STATE_ ((u16)0x2000) -+ -+#define PHY_INT_SRC (29) -+#define PHY_INT_SRC_ENERGY_ON_ ((u16)0x0080) -+#define PHY_INT_SRC_ANEG_COMP_ ((u16)0x0040) -+#define PHY_INT_SRC_REMOTE_FAULT_ ((u16)0x0020) -+#define PHY_INT_SRC_LINK_DOWN_ ((u16)0x0010) -+ -+#define PHY_INT_MASK (30) -+#define PHY_INT_MASK_ENERGY_ON_ ((u16)0x0080) -+#define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040) -+#define PHY_INT_MASK_REMOTE_FAULT_ ((u16)0x0020) -+#define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010) -+#define PHY_INT_MASK_DEFAULT_ (PHY_INT_MASK_ANEG_COMP_ | \ -+ PHY_INT_MASK_LINK_DOWN_) -+ -+#define PHY_SPECIAL (31) -+#define PHY_SPECIAL_SPD_ ((u16)0x001C) -+#define PHY_SPECIAL_SPD_10HALF_ ((u16)0x0004) -+#define PHY_SPECIAL_SPD_10FULL_ ((u16)0x0014) -+#define PHY_SPECIAL_SPD_100HALF_ ((u16)0x0008) -+#define PHY_SPECIAL_SPD_100FULL_ ((u16)0x0018) -+ -+/* USB Vendor Requests */ -+#define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0 -+#define USB_VENDOR_REQUEST_READ_REGISTER 0xA1 -+#define USB_VENDOR_REQUEST_GET_STATS 0xA2 -+ -+/* Interrupt Endpoint status word bitfields */ -+#define INT_ENP_TX_STOP_ ((u32)BIT(17)) -+#define INT_ENP_RX_STOP_ ((u32)BIT(16)) -+#define INT_ENP_PHY_INT_ ((u32)BIT(15)) -+#define INT_ENP_TXE_ ((u32)BIT(14)) -+#define INT_ENP_TDFU_ ((u32)BIT(13)) -+#define INT_ENP_TDFO_ ((u32)BIT(12)) -+#define INT_ENP_RXDF_ ((u32)BIT(11)) -+ -+#endif /* _SMSC95XX_H */ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/sr9700.c backports-3.18.1-1/drivers/net/usb/sr9700.c ---- backports-3.18.1-1.org/drivers/net/usb/sr9700.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/sr9700.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,559 @@ -+/* -+ * CoreChip-sz SR9700 one chip USB 1.1 Ethernet Devices -+ * -+ * Author : Liu Junliang liujunliang_ljl@163.com -+ * -+ * Based on dm9601.c -+ * -+ * This file is licensed under the terms of the GNU General Public License -+ * version 2. This program is licensed "as is" without any warranty of any -+ * kind, whether express or implied. -+ */ -+ -+#include <linux/module.h> -+#include <linux/sched.h> -+#include <linux/stddef.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/crc32.h> -+#include <linux/usb/usbnet.h> -+ -+#include "sr9700.h" -+ -+static int sr_read(struct usbnet *dev, u8 reg, u16 length, void *data) -+{ -+ int err; -+ -+ err = usbnet_read_cmd(dev, SR_RD_REGS, SR_REQ_RD_REG, 0, reg, data, -+ length); -+ if ((err != length) && (err >= 0)) -+ err = -EINVAL; -+ return err; -+} -+ -+static int sr_write(struct usbnet *dev, u8 reg, u16 length, void *data) -+{ -+ int err; -+ -+ err = usbnet_write_cmd(dev, SR_WR_REGS, SR_REQ_WR_REG, 0, reg, data, -+ length); -+ if ((err >= 0) && (err < length)) -+ err = -EINVAL; -+ return err; -+} -+ -+static int sr_read_reg(struct usbnet *dev, u8 reg, u8 *value) -+{ -+ return sr_read(dev, reg, 1, value); -+} -+ -+static int sr_write_reg(struct usbnet *dev, u8 reg, u8 value) -+{ -+ return usbnet_write_cmd(dev, SR_WR_REGS, SR_REQ_WR_REG, -+ value, reg, NULL, 0); -+} -+ -+static void sr_write_async(struct usbnet *dev, u8 reg, u16 length, void *data) -+{ -+ usbnet_write_cmd_async(dev, SR_WR_REGS, SR_REQ_WR_REG, -+ 0, reg, data, length); -+} -+ -+static void sr_write_reg_async(struct usbnet *dev, u8 reg, u8 value) -+{ -+ usbnet_write_cmd_async(dev, SR_WR_REGS, SR_REQ_WR_REG, -+ value, reg, NULL, 0); -+} -+ -+static int wait_phy_eeprom_ready(struct usbnet *dev, int phy) -+{ -+ int i; -+ -+ for (i = 0; i < SR_SHARE_TIMEOUT; i++) { -+ u8 tmp = 0; -+ int ret; -+ -+ udelay(1); -+ ret = sr_read_reg(dev, EPCR, &tmp); -+ if (ret < 0) -+ return ret; -+ -+ /* ready */ -+ if (!(tmp & EPCR_ERRE)) -+ return 0; -+ } -+ -+ netdev_err(dev->net, "%s write timed out!\n", phy ? "phy" : "eeprom"); -+ -+ return -EIO; -+} -+ -+static int sr_share_read_word(struct usbnet *dev, int phy, u8 reg, -+ __le16 *value) -+{ -+ int ret; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ sr_write_reg(dev, EPAR, phy ? (reg | EPAR_PHY_ADR) : reg); -+ sr_write_reg(dev, EPCR, phy ? (EPCR_EPOS | EPCR_ERPRR) : EPCR_ERPRR); -+ -+ ret = wait_phy_eeprom_ready(dev, phy); -+ if (ret < 0) -+ goto out_unlock; -+ -+ sr_write_reg(dev, EPCR, 0x0); -+ ret = sr_read(dev, EPDR, 2, value); -+ -+ netdev_dbg(dev->net, "read shared %d 0x%02x returned 0x%04x, %d\n", -+ phy, reg, *value, ret); -+ -+out_unlock: -+ mutex_unlock(&dev->phy_mutex); -+ return ret; -+} -+ -+static int sr_share_write_word(struct usbnet *dev, int phy, u8 reg, -+ __le16 value) -+{ -+ int ret; -+ -+ mutex_lock(&dev->phy_mutex); -+ -+ ret = sr_write(dev, EPDR, 2, &value); -+ if (ret < 0) -+ goto out_unlock; -+ -+ sr_write_reg(dev, EPAR, phy ? (reg | EPAR_PHY_ADR) : reg); -+ sr_write_reg(dev, EPCR, phy ? (EPCR_WEP | EPCR_EPOS | EPCR_ERPRW) : -+ (EPCR_WEP | EPCR_ERPRW)); -+ -+ ret = wait_phy_eeprom_ready(dev, phy); -+ if (ret < 0) -+ goto out_unlock; -+ -+ sr_write_reg(dev, EPCR, 0x0); -+ -+out_unlock: -+ mutex_unlock(&dev->phy_mutex); -+ return ret; -+} -+ -+static int sr_read_eeprom_word(struct usbnet *dev, u8 offset, void *value) -+{ -+ return sr_share_read_word(dev, 0, offset, value); -+} -+ -+static int sr9700_get_eeprom_len(struct net_device *netdev) -+{ -+ return SR_EEPROM_LEN; -+} -+ -+static int sr9700_get_eeprom(struct net_device *netdev, -+ struct ethtool_eeprom *eeprom, u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ __le16 *buf = (__le16 *)data; -+ int ret = 0; -+ int i; -+ -+ /* access is 16bit */ -+ if ((eeprom->offset & 0x01) || (eeprom->len & 0x01)) -+ return -EINVAL; -+ -+ for (i = 0; i < eeprom->len / 2; i++) { -+ ret = sr_read_eeprom_word(dev, eeprom->offset / 2 + i, buf + i); -+ if (ret < 0) -+ break; -+ } -+ -+ return ret; -+} -+ -+static int sr_mdio_read(struct net_device *netdev, int phy_id, int loc) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ __le16 res; -+ int rc = 0; -+ -+ if (phy_id) { -+ netdev_dbg(netdev, "Only internal phy supported\n"); -+ return 0; -+ } -+ -+ /* Access NSR_LINKST bit for link status instead of MII_BMSR */ -+ if (loc == MII_BMSR) { -+ u8 value; -+ -+ sr_read_reg(dev, NSR, &value); -+ if (value & NSR_LINKST) -+ rc = 1; -+ } -+ sr_share_read_word(dev, 1, loc, &res); -+ if (rc == 1) -+ res = le16_to_cpu(res) | BMSR_LSTATUS; -+ else -+ res = le16_to_cpu(res) & ~BMSR_LSTATUS; -+ -+ netdev_dbg(netdev, "sr_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", -+ phy_id, loc, res); -+ -+ return res; -+} -+ -+static void sr_mdio_write(struct net_device *netdev, int phy_id, int loc, -+ int val) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ __le16 res = cpu_to_le16(val); -+ -+ if (phy_id) { -+ netdev_dbg(netdev, "Only internal phy supported\n"); -+ return; -+ } -+ -+ netdev_dbg(netdev, "sr_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", -+ phy_id, loc, val); -+ -+ sr_share_write_word(dev, 1, loc, res); -+} -+ -+static u32 sr9700_get_link(struct net_device *netdev) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ u8 value = 0; -+ int rc = 0; -+ -+ /* Get the Link Status directly */ -+ sr_read_reg(dev, NSR, &value); -+ if (value & NSR_LINKST) -+ rc = 1; -+ -+ return rc; -+} -+ -+static int sr9700_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ -+ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -+} -+ -+static const struct ethtool_ops sr9700_ethtool_ops = { -+ .get_drvinfo = usbnet_get_drvinfo, -+ .get_link = sr9700_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_eeprom_len = sr9700_get_eeprom_len, -+ .get_eeprom = sr9700_get_eeprom, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .nway_reset = usbnet_nway_reset, -+}; -+ -+static void sr9700_set_multicast(struct net_device *netdev) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ /* We use the 20 byte dev->data for our 8 byte filter buffer -+ * to avoid allocating memory that is tricky to free later -+ */ -+ u8 *hashes = (u8 *)&dev->data; -+ /* rx_ctl setting : enable, disable_long, disable_crc */ -+ u8 rx_ctl = RCR_RXEN | RCR_DIS_CRC | RCR_DIS_LONG; -+ -+ memset(hashes, 0x00, SR_MCAST_SIZE); -+ /* broadcast address */ -+ hashes[SR_MCAST_SIZE - 1] |= SR_MCAST_ADDR_FLAG; -+ if (netdev->flags & IFF_PROMISC) { -+ rx_ctl |= RCR_PRMSC; -+ } else if (netdev->flags & IFF_ALLMULTI || -+ netdev_mc_count(netdev) > SR_MCAST_MAX) { -+ rx_ctl |= RCR_RUNT; -+ } else if (!netdev_mc_empty(netdev)) { -+ struct netdev_hw_addr *ha; -+ -+ netdev_for_each_mc_addr(ha, netdev) { -+ u32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26; -+ hashes[crc >> 3] |= 1 << (crc & 0x7); -+ } -+ } -+ -+ sr_write_async(dev, MAR, SR_MCAST_SIZE, hashes); -+ sr_write_reg_async(dev, RCR, rx_ctl); -+} -+ -+static int sr9700_set_mac_address(struct net_device *netdev, void *p) -+{ -+ struct usbnet *dev = netdev_priv(netdev); -+ struct sockaddr *addr = p; -+ -+ if (!is_valid_ether_addr(addr->sa_data)) { -+ netdev_err(netdev, "not setting invalid mac address %pM\n", -+ addr->sa_data); -+ return -EINVAL; -+ } -+ -+ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); -+ sr_write_async(dev, PAR, 6, netdev->dev_addr); -+ -+ return 0; -+} -+ -+static const struct net_device_ops sr9700_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = sr9700_ioctl, -+ .ndo_set_rx_mode = sr9700_set_multicast, -+ .ndo_set_mac_address = sr9700_set_mac_address, -+}; -+ -+static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ struct net_device *netdev; -+ struct mii_if_info *mii; -+ int ret; -+ -+ ret = usbnet_get_endpoints(dev, intf); -+ if (ret) -+ goto out; -+ -+ netdev = dev->net; -+ -+ netdev->netdev_ops = &sr9700_netdev_ops; -+ netdev->ethtool_ops = &sr9700_ethtool_ops; -+ netdev->hard_header_len += SR_TX_OVERHEAD; -+ dev->hard_mtu = netdev->mtu + netdev->hard_header_len; -+ /* bulkin buffer is preferably not less than 3K */ -+ dev->rx_urb_size = 3072; -+ -+ mii = &dev->mii; -+ mii->dev = netdev; -+ mii->mdio_read = sr_mdio_read; -+ mii->mdio_write = sr_mdio_write; -+ mii->phy_id_mask = 0x1f; -+ mii->reg_num_mask = 0x1f; -+ -+ sr_write_reg(dev, NCR, NCR_RST); -+ udelay(20); -+ -+ /* read MAC -+ * After Chip Power on, the Chip will reload the MAC from -+ * EEPROM automatically to PAR. In case there is no EEPROM externally, -+ * a default MAC address is stored in PAR for making chip work properly. -+ */ -+ if (sr_read(dev, PAR, ETH_ALEN, netdev->dev_addr) < 0) { -+ netdev_err(netdev, "Error reading MAC address\n"); -+ ret = -ENODEV; -+ goto out; -+ } -+ -+ /* power up and reset phy */ -+ sr_write_reg(dev, PRR, PRR_PHY_RST); -+ /* at least 10ms, here 20ms for safe */ -+ mdelay(20); -+ sr_write_reg(dev, PRR, 0); -+ /* at least 1ms, here 2ms for reading right register */ -+ udelay(2 * 1000); -+ -+ /* receive broadcast packets */ -+ sr9700_set_multicast(netdev); -+ -+ sr_mdio_write(netdev, mii->phy_id, MII_BMCR, BMCR_RESET); -+ sr_mdio_write(netdev, mii->phy_id, MII_ADVERTISE, ADVERTISE_ALL | -+ ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); -+ mii_nway_restart(mii); -+ -+out: -+ return ret; -+} -+ -+static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ struct sk_buff *sr_skb; -+ int len; -+ -+ /* skb content (packets) format : -+ * p0 p1 p2 ...... pm -+ * / \ -+ * / \ -+ * / \ -+ * / \ -+ * p0b0 p0b1 p0b2 p0b3 ...... p0b(n-4) p0b(n-3)...p0bn -+ * -+ * p0 : packet 0 -+ * p0b0 : packet 0 byte 0 -+ * -+ * b0: rx status -+ * b1: packet length (incl crc) low -+ * b2: packet length (incl crc) high -+ * b3..n-4: packet data -+ * bn-3..bn: ethernet packet crc -+ */ -+ if (unlikely(skb->len < SR_RX_OVERHEAD)) { -+ netdev_err(dev->net, "unexpected tiny rx frame\n"); -+ return 0; -+ } -+ -+ /* one skb may contains multiple packets */ -+ while (skb->len > SR_RX_OVERHEAD) { -+ if (skb->data[0] != 0x40) -+ return 0; -+ -+ /* ignore the CRC length */ -+ len = (skb->data[1] | (skb->data[2] << 8)) - 4; -+ -+ if (len > ETH_FRAME_LEN) -+ return 0; -+ -+ /* the last packet of current skb */ -+ if (skb->len == (len + SR_RX_OVERHEAD)) { -+ skb_pull(skb, 3); -+ skb->len = len; -+ skb_set_tail_pointer(skb, len); -+ skb->truesize = len + sizeof(struct sk_buff); -+ return 2; -+ } -+ -+ /* skb_clone is used for address align */ -+ sr_skb = skb_clone(skb, GFP_ATOMIC); -+ if (!sr_skb) -+ return 0; -+ -+ sr_skb->len = len; -+ sr_skb->data = skb->data + 3; -+ skb_set_tail_pointer(sr_skb, len); -+ sr_skb->truesize = len + sizeof(struct sk_buff); -+ usbnet_skb_return(dev, sr_skb); -+ -+ skb_pull(skb, len + SR_RX_OVERHEAD); -+ }; -+ -+ return 0; -+} -+ -+static struct sk_buff *sr9700_tx_fixup(struct usbnet *dev, struct sk_buff *skb, -+ gfp_t flags) -+{ -+ int len; -+ -+ /* SR9700 can only send out one ethernet packet at once. -+ * -+ * b0 b1 b2 b3 ...... b(n-4) b(n-3)...bn -+ * -+ * b0: rx status -+ * b1: packet length (incl crc) low -+ * b2: packet length (incl crc) high -+ * b3..n-4: packet data -+ * bn-3..bn: ethernet packet crc -+ */ -+ -+ len = skb->len; -+ -+ if (skb_headroom(skb) < SR_TX_OVERHEAD) { -+ struct sk_buff *skb2; -+ -+ skb2 = skb_copy_expand(skb, SR_TX_OVERHEAD, 0, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (!skb) -+ return NULL; -+ } -+ -+ __skb_push(skb, SR_TX_OVERHEAD); -+ -+ /* usbnet adds padding if length is a multiple of packet size -+ * if so, adjust length value in header -+ */ -+ if ((skb->len % dev->maxpacket) == 0) -+ len++; -+ -+ skb->data[0] = len; -+ skb->data[1] = len >> 8; -+ -+ return skb; -+} -+ -+static void sr9700_status(struct usbnet *dev, struct urb *urb) -+{ -+ int link; -+ u8 *buf; -+ -+ /* format: -+ b0: net status -+ b1: tx status 1 -+ b2: tx status 2 -+ b3: rx status -+ b4: rx overflow -+ b5: rx count -+ b6: tx count -+ b7: gpr -+ */ -+ -+ if (urb->actual_length < 8) -+ return; -+ -+ buf = urb->transfer_buffer; -+ -+ link = !!(buf[0] & 0x40); -+ if (netif_carrier_ok(dev->net) != link) { -+ usbnet_link_change(dev, link, 1); -+ netdev_dbg(dev->net, "Link Status is: %d\n", link); -+ } -+} -+ -+static int sr9700_link_reset(struct usbnet *dev) -+{ -+ struct ethtool_cmd ecmd; -+ -+ mii_check_media(&dev->mii, 1, 1); -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ -+ netdev_dbg(dev->net, "link_reset() speed: %d duplex: %d\n", -+ ecmd.speed, ecmd.duplex); -+ -+ return 0; -+} -+ -+static const struct driver_info sr9700_driver_info = { -+ .description = "CoreChip SR9700 USB Ethernet", -+ .flags = FLAG_ETHER, -+ .bind = sr9700_bind, -+ .rx_fixup = sr9700_rx_fixup, -+ .tx_fixup = sr9700_tx_fixup, -+ .status = sr9700_status, -+ .link_reset = sr9700_link_reset, -+ .reset = sr9700_link_reset, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ USB_DEVICE(0x0fe6, 0x9700), /* SR9700 device */ -+ .driver_info = (unsigned long)&sr9700_driver_info, -+ }, -+ {}, /* END */ -+}; -+ -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver sr9700_usb_driver = { -+ .name = "sr9700", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(sr9700_usb_driver); -+ -+MODULE_AUTHOR("liujl liujunliang_ljl@163.com"); -+MODULE_DESCRIPTION("SR9700 one chip USB 1.1 USB to Ethernet device from http://www.corechip-sz.com/"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/sr9700.h backports-3.18.1-1/drivers/net/usb/sr9700.h ---- backports-3.18.1-1.org/drivers/net/usb/sr9700.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/sr9700.h 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,173 @@ -+/* -+ * CoreChip-sz SR9700 one chip USB 1.1 Ethernet Devices -+ * -+ * Author : Liu Junliang liujunliang_ljl@163.com -+ * -+ * This program is free software; you can redistribute it and/or -+ * modify it under the terms of the GNU General Public License -+ * version 2 as published by the Free Software Foundation. -+ */ -+ -+#ifndef _SR9700_H -+#define _SR9700_H -+ -+/* sr9700 spec. register table on Linux platform */ -+ -+/* Network Control Reg */ -+#define NCR 0x00 -+#define NCR_RST (1 << 0) -+#define NCR_LBK (3 << 1) -+#define NCR_FDX (1 << 3) -+#define NCR_WAKEEN (1 << 6) -+/* Network Status Reg */ -+#define NSR 0x01 -+#define NSR_RXRDY (1 << 0) -+#define NSR_RXOV (1 << 1) -+#define NSR_TX1END (1 << 2) -+#define NSR_TX2END (1 << 3) -+#define NSR_TXFULL (1 << 4) -+#define NSR_WAKEST (1 << 5) -+#define NSR_LINKST (1 << 6) -+#define NSR_SPEED (1 << 7) -+/* Tx Control Reg */ -+#define TCR 0x02 -+#define TCR_CRC_DIS (1 << 1) -+#define TCR_PAD_DIS (1 << 2) -+#define TCR_LC_CARE (1 << 3) -+#define TCR_CRS_CARE (1 << 4) -+#define TCR_EXCECM (1 << 5) -+#define TCR_LF_EN (1 << 6) -+/* Tx Status Reg for Packet Index 1 */ -+#define TSR1 0x03 -+#define TSR1_EC (1 << 2) -+#define TSR1_COL (1 << 3) -+#define TSR1_LC (1 << 4) -+#define TSR1_NC (1 << 5) -+#define TSR1_LOC (1 << 6) -+#define TSR1_TLF (1 << 7) -+/* Tx Status Reg for Packet Index 2 */ -+#define TSR2 0x04 -+#define TSR2_EC (1 << 2) -+#define TSR2_COL (1 << 3) -+#define TSR2_LC (1 << 4) -+#define TSR2_NC (1 << 5) -+#define TSR2_LOC (1 << 6) -+#define TSR2_TLF (1 << 7) -+/* Rx Control Reg*/ -+#define RCR 0x05 -+#define RCR_RXEN (1 << 0) -+#define RCR_PRMSC (1 << 1) -+#define RCR_RUNT (1 << 2) -+#define RCR_ALL (1 << 3) -+#define RCR_DIS_CRC (1 << 4) -+#define RCR_DIS_LONG (1 << 5) -+/* Rx Status Reg */ -+#define RSR 0x06 -+#define RSR_AE (1 << 2) -+#define RSR_MF (1 << 6) -+#define RSR_RF (1 << 7) -+/* Rx Overflow Counter Reg */ -+#define ROCR 0x07 -+#define ROCR_ROC (0x7F << 0) -+#define ROCR_RXFU (1 << 7) -+/* Back Pressure Threshold Reg */ -+#define BPTR 0x08 -+#define BPTR_JPT (0x0F << 0) -+#define BPTR_BPHW (0x0F << 4) -+/* Flow Control Threshold Reg */ -+#define FCTR 0x09 -+#define FCTR_LWOT (0x0F << 0) -+#define FCTR_HWOT (0x0F << 4) -+/* rx/tx Flow Control Reg */ -+#define FCR 0x0A -+#define FCR_FLCE (1 << 0) -+#define FCR_BKPA (1 << 4) -+#define FCR_TXPEN (1 << 5) -+#define FCR_TXPF (1 << 6) -+#define FCR_TXP0 (1 << 7) -+/* Eeprom & Phy Control Reg */ -+#define EPCR 0x0B -+#define EPCR_ERRE (1 << 0) -+#define EPCR_ERPRW (1 << 1) -+#define EPCR_ERPRR (1 << 2) -+#define EPCR_EPOS (1 << 3) -+#define EPCR_WEP (1 << 4) -+/* Eeprom & Phy Address Reg */ -+#define EPAR 0x0C -+#define EPAR_EROA (0x3F << 0) -+#define EPAR_PHY_ADR_MASK (0x03 << 6) -+#define EPAR_PHY_ADR (0x01 << 6) -+/* Eeprom & Phy Data Reg */ -+#define EPDR 0x0D /* 0x0D ~ 0x0E for Data Reg Low & High */ -+/* Wakeup Control Reg */ -+#define WCR 0x0F -+#define WCR_MAGICST (1 << 0) -+#define WCR_LINKST (1 << 2) -+#define WCR_MAGICEN (1 << 3) -+#define WCR_LINKEN (1 << 5) -+/* Physical Address Reg */ -+#define PAR 0x10 /* 0x10 ~ 0x15 6 bytes for PAR */ -+/* Multicast Address Reg */ -+#define MAR 0x16 /* 0x16 ~ 0x1D 8 bytes for MAR */ -+/* 0x1e unused */ -+/* Phy Reset Reg */ -+#define PRR 0x1F -+#define PRR_PHY_RST (1 << 0) -+/* Tx sdram Write Pointer Address Low */ -+#define TWPAL 0x20 -+/* Tx sdram Write Pointer Address High */ -+#define TWPAH 0x21 -+/* Tx sdram Read Pointer Address Low */ -+#define TRPAL 0x22 -+/* Tx sdram Read Pointer Address High */ -+#define TRPAH 0x23 -+/* Rx sdram Write Pointer Address Low */ -+#define RWPAL 0x24 -+/* Rx sdram Write Pointer Address High */ -+#define RWPAH 0x25 -+/* Rx sdram Read Pointer Address Low */ -+#define RRPAL 0x26 -+/* Rx sdram Read Pointer Address High */ -+#define RRPAH 0x27 -+/* Vendor ID register */ -+#define VID 0x28 /* 0x28 ~ 0x29 2 bytes for VID */ -+/* Product ID register */ -+#define PID 0x2A /* 0x2A ~ 0x2B 2 bytes for PID */ -+/* CHIP Revision register */ -+#define CHIPR 0x2C -+/* 0x2D --> 0xEF unused */ -+/* USB Device Address */ -+#define USBDA 0xF0 -+#define USBDA_USBFA (0x7F << 0) -+/* RX packet Counter Reg */ -+#define RXC 0xF1 -+/* Tx packet Counter & USB Status Reg */ -+#define TXC_USBS 0xF2 -+#define TXC_USBS_TXC0 (1 << 0) -+#define TXC_USBS_TXC1 (1 << 1) -+#define TXC_USBS_TXC2 (1 << 2) -+#define TXC_USBS_EP1RDY (1 << 5) -+#define TXC_USBS_SUSFLAG (1 << 6) -+#define TXC_USBS_RXFAULT (1 << 7) -+/* USB Control register */ -+#define USBC 0xF4 -+#define USBC_EP3NAK (1 << 4) -+#define USBC_EP3ACK (1 << 5) -+ -+/* Register access commands and flags */ -+#define SR_RD_REGS 0x00 -+#define SR_WR_REGS 0x01 -+#define SR_WR_REG 0x03 -+#define SR_REQ_RD_REG (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE) -+#define SR_REQ_WR_REG (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) -+ -+/* parameters */ -+#define SR_SHARE_TIMEOUT 1000 -+#define SR_EEPROM_LEN 256 -+#define SR_MCAST_SIZE 8 -+#define SR_MCAST_ADDR_FLAG 0x80 -+#define SR_MCAST_MAX 64 -+#define SR_TX_OVERHEAD 2 /* 2bytes header */ -+#define SR_RX_OVERHEAD 7 /* 3bytes header + 4crc tail */ -+ -+#endif /* _SR9700_H */ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/sr9800.c backports-3.18.1-1/drivers/net/usb/sr9800.c ---- backports-3.18.1-1.org/drivers/net/usb/sr9800.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/sr9800.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,874 @@ -+/* CoreChip-sz SR9800 one chip USB 2.0 Ethernet Devices -+ * -+ * Author : Liu Junliang liujunliang_ljl@163.com -+ * -+ * Based on asix_common.c, asix_devices.c -+ * -+ * This file is licensed under the terms of the GNU General Public License -+ * version 2. This program is licensed "as is" without any warranty of any -+ * kind, whether express or implied.* -+ */ -+ -+#include <linux/module.h> -+#include <linux/kmod.h> -+#include <linux/init.h> -+#include <linux/netdevice.h> -+#include <linux/etherdevice.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/usb.h> -+#include <linux/crc32.h> -+#include <linux/usb/usbnet.h> -+#include <linux/slab.h> -+#include <linux/if_vlan.h> -+ -+#include "sr9800.h" -+ -+static int sr_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data) -+{ -+ int err; -+ -+ err = usbnet_read_cmd(dev, cmd, SR_REQ_RD_REG, value, index, -+ data, size); -+ if ((err != size) && (err >= 0)) -+ err = -EINVAL; -+ -+ return err; -+} -+ -+static int sr_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data) -+{ -+ int err; -+ -+ err = usbnet_write_cmd(dev, cmd, SR_REQ_WR_REG, value, index, -+ data, size); -+ if ((err != size) && (err >= 0)) -+ err = -EINVAL; -+ -+ return err; -+} -+ -+static void -+sr_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, -+ u16 size, void *data) -+{ -+ usbnet_write_cmd_async(dev, cmd, SR_REQ_WR_REG, value, index, data, -+ size); -+} -+ -+static int sr_rx_fixup(struct usbnet *dev, struct sk_buff *skb) -+{ -+ int offset = 0; -+ -+ /* This check is no longer done by usbnet */ -+ if (skb->len < dev->net->hard_header_len) -+ return 0; -+ -+ while (offset + sizeof(u32) < skb->len) { -+ struct sk_buff *sr_skb; -+ u16 size; -+ u32 header = get_unaligned_le32(skb->data + offset); -+ -+ offset += sizeof(u32); -+ /* get the packet length */ -+ size = (u16) (header & 0x7ff); -+ if (size != ((~header >> 16) & 0x07ff)) { -+ netdev_err(dev->net, "%s : Bad Header Length\n", -+ __func__); -+ return 0; -+ } -+ -+ if ((size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) || -+ (size + offset > skb->len)) { -+ netdev_err(dev->net, "%s : Bad RX Length %d\n", -+ __func__, size); -+ return 0; -+ } -+ sr_skb = netdev_alloc_skb_ip_align(dev->net, size); -+ if (!sr_skb) -+ return 0; -+ -+ skb_put(sr_skb, size); -+ memcpy(sr_skb->data, skb->data + offset, size); -+ usbnet_skb_return(dev, sr_skb); -+ -+ offset += (size + 1) & 0xfffe; -+ } -+ -+ if (skb->len != offset) { -+ netdev_err(dev->net, "%s : Bad SKB Length %d\n", __func__, -+ skb->len); -+ return 0; -+ } -+ -+ return 1; -+} -+ -+static struct sk_buff *sr_tx_fixup(struct usbnet *dev, struct sk_buff *skb, -+ gfp_t flags) -+{ -+ int headroom = skb_headroom(skb); -+ int tailroom = skb_tailroom(skb); -+ u32 padbytes = 0xffff0000; -+ u32 packet_len; -+ int padlen; -+ -+ padlen = ((skb->len + 4) % (dev->maxpacket - 1)) ? 0 : 4; -+ -+ if ((!skb_cloned(skb)) && ((headroom + tailroom) >= (4 + padlen))) { -+ if ((headroom < 4) || (tailroom < padlen)) { -+ skb->data = memmove(skb->head + 4, skb->data, -+ skb->len); -+ skb_set_tail_pointer(skb, skb->len); -+ } -+ } else { -+ struct sk_buff *skb2; -+ skb2 = skb_copy_expand(skb, 4, padlen, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (!skb) -+ return NULL; -+ } -+ -+ skb_push(skb, 4); -+ packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4); -+ cpu_to_le32s(&packet_len); -+ skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len)); -+ -+ if (padlen) { -+ cpu_to_le32s(&padbytes); -+ memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes)); -+ skb_put(skb, sizeof(padbytes)); -+ } -+ -+ return skb; -+} -+ -+static void sr_status(struct usbnet *dev, struct urb *urb) -+{ -+ struct sr9800_int_data *event; -+ int link; -+ -+ if (urb->actual_length < 8) -+ return; -+ -+ event = urb->transfer_buffer; -+ link = event->link & 0x01; -+ if (netif_carrier_ok(dev->net) != link) { -+ usbnet_link_change(dev, link, 1); -+ netdev_dbg(dev->net, "Link Status is: %d\n", link); -+ } -+ -+ return; -+} -+ -+static inline int sr_set_sw_mii(struct usbnet *dev) -+{ -+ int ret; -+ -+ ret = sr_write_cmd(dev, SR_CMD_SET_SW_MII, 0x0000, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to enable software MII access\n"); -+ return ret; -+} -+ -+static inline int sr_set_hw_mii(struct usbnet *dev) -+{ -+ int ret; -+ -+ ret = sr_write_cmd(dev, SR_CMD_SET_HW_MII, 0x0000, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to enable hardware MII access\n"); -+ return ret; -+} -+ -+static inline int sr_get_phy_addr(struct usbnet *dev) -+{ -+ u8 buf[2]; -+ int ret; -+ -+ ret = sr_read_cmd(dev, SR_CMD_READ_PHY_ID, 0, 0, 2, buf); -+ if (ret < 0) { -+ netdev_err(dev->net, "%s : Error reading PHYID register:%02x\n", -+ __func__, ret); -+ goto out; -+ } -+ netdev_dbg(dev->net, "%s : returning 0x%04x\n", __func__, -+ *((__le16 *)buf)); -+ -+ ret = buf[1]; -+ -+out: -+ return ret; -+} -+ -+static int sr_sw_reset(struct usbnet *dev, u8 flags) -+{ -+ int ret; -+ -+ ret = sr_write_cmd(dev, SR_CMD_SW_RESET, flags, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to send software reset:%02x\n", -+ ret); -+ -+ return ret; -+} -+ -+static u16 sr_read_rx_ctl(struct usbnet *dev) -+{ -+ __le16 v; -+ int ret; -+ -+ ret = sr_read_cmd(dev, SR_CMD_READ_RX_CTL, 0, 0, 2, &v); -+ if (ret < 0) { -+ netdev_err(dev->net, "Error reading RX_CTL register:%02x\n", -+ ret); -+ goto out; -+ } -+ -+ ret = le16_to_cpu(v); -+out: -+ return ret; -+} -+ -+static int sr_write_rx_ctl(struct usbnet *dev, u16 mode) -+{ -+ int ret; -+ -+ netdev_dbg(dev->net, "%s : mode = 0x%04x\n", __func__, mode); -+ ret = sr_write_cmd(dev, SR_CMD_WRITE_RX_CTL, mode, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, -+ "Failed to write RX_CTL mode to 0x%04x:%02x\n", -+ mode, ret); -+ -+ return ret; -+} -+ -+static u16 sr_read_medium_status(struct usbnet *dev) -+{ -+ __le16 v; -+ int ret; -+ -+ ret = sr_read_cmd(dev, SR_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v); -+ if (ret < 0) { -+ netdev_err(dev->net, -+ "Error reading Medium Status register:%02x\n", ret); -+ return ret; /* TODO: callers not checking for error ret */ -+ } -+ -+ return le16_to_cpu(v); -+} -+ -+static int sr_write_medium_mode(struct usbnet *dev, u16 mode) -+{ -+ int ret; -+ -+ netdev_dbg(dev->net, "%s : mode = 0x%04x\n", __func__, mode); -+ ret = sr_write_cmd(dev, SR_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, -+ "Failed to write Medium Mode mode to 0x%04x:%02x\n", -+ mode, ret); -+ return ret; -+} -+ -+static int sr_write_gpio(struct usbnet *dev, u16 value, int sleep) -+{ -+ int ret; -+ -+ netdev_dbg(dev->net, "%s : value = 0x%04x\n", __func__, value); -+ ret = sr_write_cmd(dev, SR_CMD_WRITE_GPIOS, value, 0, 0, NULL); -+ if (ret < 0) -+ netdev_err(dev->net, "Failed to write GPIO value 0x%04x:%02x\n", -+ value, ret); -+ if (sleep) -+ msleep(sleep); -+ -+ return ret; -+} -+ -+/* SR9800 have a 16-bit RX_CTL value */ -+static void sr_set_multicast(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct sr_data *data = (struct sr_data *)&dev->data; -+ u16 rx_ctl = SR_DEFAULT_RX_CTL; -+ -+ if (net->flags & IFF_PROMISC) { -+ rx_ctl |= SR_RX_CTL_PRO; -+ } else if (net->flags & IFF_ALLMULTI || -+ netdev_mc_count(net) > SR_MAX_MCAST) { -+ rx_ctl |= SR_RX_CTL_AMALL; -+ } else if (netdev_mc_empty(net)) { -+ /* just broadcast and directed */ -+ } else { -+ /* We use the 20 byte dev->data -+ * for our 8 byte filter buffer -+ * to avoid allocating memory that -+ * is tricky to free later -+ */ -+ struct netdev_hw_addr *ha; -+ u32 crc_bits; -+ -+ memset(data->multi_filter, 0, SR_MCAST_FILTER_SIZE); -+ -+ /* Build the multicast hash filter. */ -+ netdev_for_each_mc_addr(ha, net) { -+ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; -+ data->multi_filter[crc_bits >> 3] |= -+ 1 << (crc_bits & 7); -+ } -+ -+ sr_write_cmd_async(dev, SR_CMD_WRITE_MULTI_FILTER, 0, 0, -+ SR_MCAST_FILTER_SIZE, data->multi_filter); -+ -+ rx_ctl |= SR_RX_CTL_AM; -+ } -+ -+ sr_write_cmd_async(dev, SR_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); -+} -+ -+static int sr_mdio_read(struct net_device *net, int phy_id, int loc) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ __le16 res; -+ -+ mutex_lock(&dev->phy_mutex); -+ sr_set_sw_mii(dev); -+ sr_read_cmd(dev, SR_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res); -+ sr_set_hw_mii(dev); -+ mutex_unlock(&dev->phy_mutex); -+ -+ netdev_dbg(dev->net, -+ "%s : phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", __func__, -+ phy_id, loc, le16_to_cpu(res)); -+ -+ return le16_to_cpu(res); -+} -+ -+static void -+sr_mdio_write(struct net_device *net, int phy_id, int loc, int val) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ __le16 res = cpu_to_le16(val); -+ -+ netdev_dbg(dev->net, -+ "%s : phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", __func__, -+ phy_id, loc, val); -+ mutex_lock(&dev->phy_mutex); -+ sr_set_sw_mii(dev); -+ sr_write_cmd(dev, SR_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); -+ sr_set_hw_mii(dev); -+ mutex_unlock(&dev->phy_mutex); -+} -+ -+/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ -+static u32 sr_get_phyid(struct usbnet *dev) -+{ -+ int phy_reg; -+ u32 phy_id; -+ int i; -+ -+ /* Poll for the rare case the FW or phy isn't ready yet. */ -+ for (i = 0; i < 100; i++) { -+ phy_reg = sr_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1); -+ if (phy_reg != 0 && phy_reg != 0xFFFF) -+ break; -+ mdelay(1); -+ } -+ -+ if (phy_reg <= 0 || phy_reg == 0xFFFF) -+ return 0; -+ -+ phy_id = (phy_reg & 0xffff) << 16; -+ -+ phy_reg = sr_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2); -+ if (phy_reg < 0) -+ return 0; -+ -+ phy_id |= (phy_reg & 0xffff); -+ -+ return phy_id; -+} -+ -+static void -+sr_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u8 opt; -+ -+ if (sr_read_cmd(dev, SR_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) { -+ wolinfo->supported = 0; -+ wolinfo->wolopts = 0; -+ return; -+ } -+ wolinfo->supported = WAKE_PHY | WAKE_MAGIC; -+ wolinfo->wolopts = 0; -+ if (opt & SR_MONITOR_LINK) -+ wolinfo->wolopts |= WAKE_PHY; -+ if (opt & SR_MONITOR_MAGIC) -+ wolinfo->wolopts |= WAKE_MAGIC; -+} -+ -+static int -+sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ u8 opt = 0; -+ -+ if (wolinfo->wolopts & WAKE_PHY) -+ opt |= SR_MONITOR_LINK; -+ if (wolinfo->wolopts & WAKE_MAGIC) -+ opt |= SR_MONITOR_MAGIC; -+ -+ if (sr_write_cmd(dev, SR_CMD_WRITE_MONITOR_MODE, -+ opt, 0, 0, NULL) < 0) -+ return -EINVAL; -+ -+ return 0; -+} -+ -+static int sr_get_eeprom_len(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct sr_data *data = (struct sr_data *)&dev->data; -+ -+ return data->eeprom_len; -+} -+ -+static int sr_get_eeprom(struct net_device *net, -+ struct ethtool_eeprom *eeprom, u8 *data) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ __le16 *ebuf = (__le16 *)data; -+ int ret; -+ int i; -+ -+ /* Crude hack to ensure that we don't overwrite memory -+ * if an odd length is supplied -+ */ -+ if (eeprom->len % 2) -+ return -EINVAL; -+ -+ eeprom->magic = SR_EEPROM_MAGIC; -+ -+ /* sr9800 returns 2 bytes from eeprom on read */ -+ for (i = 0; i < eeprom->len / 2; i++) { -+ ret = sr_read_cmd(dev, SR_CMD_READ_EEPROM, eeprom->offset + i, -+ 0, 2, &ebuf[i]); -+ if (ret < 0) -+ return -EINVAL; -+ } -+ return 0; -+} -+ -+static void sr_get_drvinfo(struct net_device *net, -+ struct ethtool_drvinfo *info) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct sr_data *data = (struct sr_data *)&dev->data; -+ -+ /* Inherit standard device info */ -+ usbnet_get_drvinfo(net, info); -+ strncpy(info->driver, DRIVER_NAME, sizeof(info->driver)); -+ strncpy(info->version, DRIVER_VERSION, sizeof(info->version)); -+ info->eedump_len = data->eeprom_len; -+} -+ -+static u32 sr_get_link(struct net_device *net) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ return mii_link_ok(&dev->mii); -+} -+ -+static int sr_ioctl(struct net_device *net, struct ifreq *rq, int cmd) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ -+ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); -+} -+ -+static int sr_set_mac_address(struct net_device *net, void *p) -+{ -+ struct usbnet *dev = netdev_priv(net); -+ struct sr_data *data = (struct sr_data *)&dev->data; -+ struct sockaddr *addr = p; -+ -+ if (netif_running(net)) -+ return -EBUSY; -+ if (!is_valid_ether_addr(addr->sa_data)) -+ return -EADDRNOTAVAIL; -+ -+ memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); -+ -+ /* We use the 20 byte dev->data -+ * for our 6 byte mac buffer -+ * to avoid allocating memory that -+ * is tricky to free later -+ */ -+ memcpy(data->mac_addr, addr->sa_data, ETH_ALEN); -+ sr_write_cmd_async(dev, SR_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, -+ data->mac_addr); -+ -+ return 0; -+} -+ -+static const struct ethtool_ops sr9800_ethtool_ops = { -+ .get_drvinfo = sr_get_drvinfo, -+ .get_link = sr_get_link, -+ .get_msglevel = usbnet_get_msglevel, -+ .set_msglevel = usbnet_set_msglevel, -+ .get_wol = sr_get_wol, -+ .set_wol = sr_set_wol, -+ .get_eeprom_len = sr_get_eeprom_len, -+ .get_eeprom = sr_get_eeprom, -+ .get_settings = usbnet_get_settings, -+ .set_settings = usbnet_set_settings, -+ .nway_reset = usbnet_nway_reset, -+}; -+ -+static int sr9800_link_reset(struct usbnet *dev) -+{ -+ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; -+ u16 mode; -+ -+ mii_check_media(&dev->mii, 1, 1); -+ mii_ethtool_gset(&dev->mii, &ecmd); -+ mode = SR9800_MEDIUM_DEFAULT; -+ -+ if (ethtool_cmd_speed(&ecmd) != SPEED_100) -+ mode &= ~SR_MEDIUM_PS; -+ -+ if (ecmd.duplex != DUPLEX_FULL) -+ mode &= ~SR_MEDIUM_FD; -+ -+ netdev_dbg(dev->net, "%s : speed: %u duplex: %d mode: 0x%04x\n", -+ __func__, ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); -+ -+ sr_write_medium_mode(dev, mode); -+ -+ return 0; -+} -+ -+ -+static int sr9800_set_default_mode(struct usbnet *dev) -+{ -+ u16 rx_ctl; -+ int ret; -+ -+ sr_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); -+ sr_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, -+ ADVERTISE_ALL | ADVERTISE_CSMA); -+ mii_nway_restart(&dev->mii); -+ -+ ret = sr_write_medium_mode(dev, SR9800_MEDIUM_DEFAULT); -+ if (ret < 0) -+ goto out; -+ -+ ret = sr_write_cmd(dev, SR_CMD_WRITE_IPG012, -+ SR9800_IPG0_DEFAULT | SR9800_IPG1_DEFAULT, -+ SR9800_IPG2_DEFAULT, 0, NULL); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); -+ goto out; -+ } -+ -+ /* Set RX_CTL to default values with 2k buffer, and enable cactus */ -+ ret = sr_write_rx_ctl(dev, SR_DEFAULT_RX_CTL); -+ if (ret < 0) -+ goto out; -+ -+ rx_ctl = sr_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", -+ rx_ctl); -+ -+ rx_ctl = sr_read_medium_status(dev); -+ netdev_dbg(dev->net, "Medium Status:0x%04x after all initializations\n", -+ rx_ctl); -+ -+ return 0; -+out: -+ return ret; -+} -+ -+static int sr9800_reset(struct usbnet *dev) -+{ -+ struct sr_data *data = (struct sr_data *)&dev->data; -+ int ret, embd_phy; -+ u16 rx_ctl; -+ -+ ret = sr_write_gpio(dev, -+ SR_GPIO_RSE | SR_GPIO_GPO_2 | SR_GPIO_GPO2EN, 5); -+ if (ret < 0) -+ goto out; -+ -+ embd_phy = ((sr_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0); -+ -+ ret = sr_write_cmd(dev, SR_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); -+ goto out; -+ } -+ -+ ret = sr_sw_reset(dev, SR_SWRESET_IPPD | SR_SWRESET_PRL); -+ if (ret < 0) -+ goto out; -+ -+ msleep(150); -+ -+ ret = sr_sw_reset(dev, SR_SWRESET_CLEAR); -+ if (ret < 0) -+ goto out; -+ -+ msleep(150); -+ -+ if (embd_phy) { -+ ret = sr_sw_reset(dev, SR_SWRESET_IPRL); -+ if (ret < 0) -+ goto out; -+ } else { -+ ret = sr_sw_reset(dev, SR_SWRESET_PRTE); -+ if (ret < 0) -+ goto out; -+ } -+ -+ msleep(150); -+ rx_ctl = sr_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); -+ ret = sr_write_rx_ctl(dev, 0x0000); -+ if (ret < 0) -+ goto out; -+ -+ rx_ctl = sr_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); -+ -+ ret = sr_sw_reset(dev, SR_SWRESET_PRL); -+ if (ret < 0) -+ goto out; -+ -+ msleep(150); -+ -+ ret = sr_sw_reset(dev, SR_SWRESET_IPRL | SR_SWRESET_PRL); -+ if (ret < 0) -+ goto out; -+ -+ msleep(150); -+ -+ ret = sr9800_set_default_mode(dev); -+ if (ret < 0) -+ goto out; -+ -+ /* Rewrite MAC address */ -+ memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); -+ ret = sr_write_cmd(dev, SR_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, -+ data->mac_addr); -+ if (ret < 0) -+ goto out; -+ -+ return 0; -+ -+out: -+ return ret; -+} -+ -+static const struct net_device_ops sr9800_netdev_ops = { -+ .ndo_open = usbnet_open, -+ .ndo_stop = usbnet_stop, -+ .ndo_start_xmit = usbnet_start_xmit, -+ .ndo_tx_timeout = usbnet_tx_timeout, -+ .ndo_change_mtu = usbnet_change_mtu, -+ .ndo_set_mac_address = sr_set_mac_address, -+ .ndo_validate_addr = eth_validate_addr, -+ .ndo_do_ioctl = sr_ioctl, -+ .ndo_set_rx_mode = sr_set_multicast, -+}; -+ -+static int sr9800_phy_powerup(struct usbnet *dev) -+{ -+ int ret; -+ -+ /* set the embedded Ethernet PHY in power-down state */ -+ ret = sr_sw_reset(dev, SR_SWRESET_IPPD | SR_SWRESET_IPRL); -+ if (ret < 0) { -+ netdev_err(dev->net, "Failed to power down PHY : %d\n", ret); -+ return ret; -+ } -+ msleep(20); -+ -+ /* set the embedded Ethernet PHY in power-up state */ -+ ret = sr_sw_reset(dev, SR_SWRESET_IPRL); -+ if (ret < 0) { -+ netdev_err(dev->net, "Failed to reset PHY: %d\n", ret); -+ return ret; -+ } -+ msleep(600); -+ -+ /* set the embedded Ethernet PHY in reset state */ -+ ret = sr_sw_reset(dev, SR_SWRESET_CLEAR); -+ if (ret < 0) { -+ netdev_err(dev->net, "Failed to power up PHY: %d\n", ret); -+ return ret; -+ } -+ msleep(20); -+ -+ /* set the embedded Ethernet PHY in power-up state */ -+ ret = sr_sw_reset(dev, SR_SWRESET_IPRL); -+ if (ret < 0) { -+ netdev_err(dev->net, "Failed to reset PHY: %d\n", ret); -+ return ret; -+ } -+ -+ return 0; -+} -+ -+static int sr9800_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ struct sr_data *data = (struct sr_data *)&dev->data; -+ u16 led01_mux, led23_mux; -+ int ret, embd_phy; -+ u32 phyid; -+ u16 rx_ctl; -+ -+ data->eeprom_len = SR9800_EEPROM_LEN; -+ -+ usbnet_get_endpoints(dev, intf); -+ -+ /* LED Setting Rule : -+ * AABB:CCDD -+ * AA : MFA0(LED0) -+ * BB : MFA1(LED1) -+ * CC : MFA2(LED2), Reserved for SR9800 -+ * DD : MFA3(LED3), Reserved for SR9800 -+ */ -+ led01_mux = (SR_LED_MUX_LINK_ACTIVE << 8) | SR_LED_MUX_LINK; -+ led23_mux = (SR_LED_MUX_LINK_ACTIVE << 8) | SR_LED_MUX_TX_ACTIVE; -+ ret = sr_write_cmd(dev, SR_CMD_LED_MUX, led01_mux, led23_mux, 0, NULL); -+ if (ret < 0) { -+ netdev_err(dev->net, "set LINK LED failed : %d\n", ret); -+ goto out; -+ } -+ -+ /* Get the MAC address */ -+ ret = sr_read_cmd(dev, SR_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, -+ dev->net->dev_addr); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); -+ return ret; -+ } -+ netdev_dbg(dev->net, "mac addr : %pM\n", dev->net->dev_addr); -+ -+ /* Initialize MII structure */ -+ dev->mii.dev = dev->net; -+ dev->mii.mdio_read = sr_mdio_read; -+ dev->mii.mdio_write = sr_mdio_write; -+ dev->mii.phy_id_mask = 0x1f; -+ dev->mii.reg_num_mask = 0x1f; -+ dev->mii.phy_id = sr_get_phy_addr(dev); -+ -+ dev->net->netdev_ops = &sr9800_netdev_ops; -+ dev->net->ethtool_ops = &sr9800_ethtool_ops; -+ -+ embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0); -+ /* Reset the PHY to normal operation mode */ -+ ret = sr_write_cmd(dev, SR_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); -+ if (ret < 0) { -+ netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); -+ return ret; -+ } -+ -+ /* Init PHY routine */ -+ ret = sr9800_phy_powerup(dev); -+ if (ret < 0) -+ goto out; -+ -+ rx_ctl = sr_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); -+ ret = sr_write_rx_ctl(dev, 0x0000); -+ if (ret < 0) -+ goto out; -+ -+ rx_ctl = sr_read_rx_ctl(dev); -+ netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); -+ -+ /* Read PHYID register *AFTER* the PHY was reset properly */ -+ phyid = sr_get_phyid(dev); -+ netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid); -+ -+ /* medium mode setting */ -+ ret = sr9800_set_default_mode(dev); -+ if (ret < 0) -+ goto out; -+ -+ if (dev->udev->speed == USB_SPEED_HIGH) { -+ ret = sr_write_cmd(dev, SR_CMD_BULKIN_SIZE, -+ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].byte_cnt, -+ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].threshold, -+ 0, NULL); -+ if (ret < 0) { -+ netdev_err(dev->net, "Reset RX_CTL failed: %d\n", ret); -+ goto out; -+ } -+ dev->rx_urb_size = -+ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].size; -+ } else { -+ ret = sr_write_cmd(dev, SR_CMD_BULKIN_SIZE, -+ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].byte_cnt, -+ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].threshold, -+ 0, NULL); -+ if (ret < 0) { -+ netdev_err(dev->net, "Reset RX_CTL failed: %d\n", ret); -+ goto out; -+ } -+ dev->rx_urb_size = -+ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].size; -+ } -+ netdev_dbg(dev->net, "%s : setting rx_urb_size with : %zu\n", __func__, -+ dev->rx_urb_size); -+ return 0; -+ -+out: -+ return ret; -+} -+ -+static const struct driver_info sr9800_driver_info = { -+ .description = "CoreChip SR9800 USB 2.0 Ethernet", -+ .bind = sr9800_bind, -+ .status = sr_status, -+ .link_reset = sr9800_link_reset, -+ .reset = sr9800_reset, -+ .flags = DRIVER_FLAG, -+ .rx_fixup = sr_rx_fixup, -+ .tx_fixup = sr_tx_fixup, -+}; -+ -+static const struct usb_device_id products[] = { -+ { -+ USB_DEVICE(0x0fe6, 0x9800), /* SR9800 Device */ -+ .driver_info = (unsigned long) &sr9800_driver_info, -+ }, -+ {}, /* END */ -+}; -+ -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver sr_driver = { -+ .name = DRIVER_NAME, -+ .id_table = products, -+ .probe = usbnet_probe, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disconnect = usbnet_disconnect, -+ .supports_autosuspend = 1, -+}; -+ -+module_usb_driver(sr_driver); -+ -+MODULE_AUTHOR("Liu Junliang <liujunliang_ljl@163.com"); -+MODULE_VERSION(DRIVER_VERSION); -+MODULE_DESCRIPTION("SR9800 USB 2.0 USB2NET Dev : http://www.corechip-sz.com"); -+MODULE_LICENSE("GPL"); -diff -Naur backports-3.18.1-1.org/drivers/net/usb/sr9800.h backports-3.18.1-1/drivers/net/usb/sr9800.h ---- backports-3.18.1-1.org/drivers/net/usb/sr9800.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/sr9800.h 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,202 @@ -+/* CoreChip-sz SR9800 one chip USB 2.0 Ethernet Devices -+ * -+ * Author : Liu Junliang liujunliang_ljl@163.com -+ * -+ * This file is licensed under the terms of the GNU General Public License -+ * version 2. This program is licensed "as is" without any warranty of any -+ * kind, whether express or implied. -+ */ -+ -+#ifndef _SR9800_H -+#define _SR9800_H -+ -+/* SR9800 spec. command table on Linux Platform */ -+ -+/* command : Software Station Management Control Reg */ -+#define SR_CMD_SET_SW_MII 0x06 -+/* command : PHY Read Reg */ -+#define SR_CMD_READ_MII_REG 0x07 -+/* command : PHY Write Reg */ -+#define SR_CMD_WRITE_MII_REG 0x08 -+/* command : Hardware Station Management Control Reg */ -+#define SR_CMD_SET_HW_MII 0x0a -+/* command : SROM Read Reg */ -+#define SR_CMD_READ_EEPROM 0x0b -+/* command : SROM Write Reg */ -+#define SR_CMD_WRITE_EEPROM 0x0c -+/* command : SROM Write Enable Reg */ -+#define SR_CMD_WRITE_ENABLE 0x0d -+/* command : SROM Write Disable Reg */ -+#define SR_CMD_WRITE_DISABLE 0x0e -+/* command : RX Control Read Reg */ -+#define SR_CMD_READ_RX_CTL 0x0f -+#define SR_RX_CTL_PRO (1 << 0) -+#define SR_RX_CTL_AMALL (1 << 1) -+#define SR_RX_CTL_SEP (1 << 2) -+#define SR_RX_CTL_AB (1 << 3) -+#define SR_RX_CTL_AM (1 << 4) -+#define SR_RX_CTL_AP (1 << 5) -+#define SR_RX_CTL_ARP (1 << 6) -+#define SR_RX_CTL_SO (1 << 7) -+#define SR_RX_CTL_RH1M (1 << 8) -+#define SR_RX_CTL_RH2M (1 << 9) -+#define SR_RX_CTL_RH3M (1 << 10) -+/* command : RX Control Write Reg */ -+#define SR_CMD_WRITE_RX_CTL 0x10 -+/* command : IPG0/IPG1/IPG2 Control Read Reg */ -+#define SR_CMD_READ_IPG012 0x11 -+/* command : IPG0/IPG1/IPG2 Control Write Reg */ -+#define SR_CMD_WRITE_IPG012 0x12 -+/* command : Node ID Read Reg */ -+#define SR_CMD_READ_NODE_ID 0x13 -+/* command : Node ID Write Reg */ -+#define SR_CMD_WRITE_NODE_ID 0x14 -+/* command : Multicast Filter Array Read Reg */ -+#define SR_CMD_READ_MULTI_FILTER 0x15 -+/* command : Multicast Filter Array Write Reg */ -+#define SR_CMD_WRITE_MULTI_FILTER 0x16 -+/* command : Eth/HomePNA PHY Address Reg */ -+#define SR_CMD_READ_PHY_ID 0x19 -+/* command : Medium Status Read Reg */ -+#define SR_CMD_READ_MEDIUM_STATUS 0x1a -+#define SR_MONITOR_LINK (1 << 1) -+#define SR_MONITOR_MAGIC (1 << 2) -+#define SR_MONITOR_HSFS (1 << 4) -+/* command : Medium Status Write Reg */ -+#define SR_CMD_WRITE_MEDIUM_MODE 0x1b -+#define SR_MEDIUM_GM (1 << 0) -+#define SR_MEDIUM_FD (1 << 1) -+#define SR_MEDIUM_AC (1 << 2) -+#define SR_MEDIUM_ENCK (1 << 3) -+#define SR_MEDIUM_RFC (1 << 4) -+#define SR_MEDIUM_TFC (1 << 5) -+#define SR_MEDIUM_JFE (1 << 6) -+#define SR_MEDIUM_PF (1 << 7) -+#define SR_MEDIUM_RE (1 << 8) -+#define SR_MEDIUM_PS (1 << 9) -+#define SR_MEDIUM_RSV (1 << 10) -+#define SR_MEDIUM_SBP (1 << 11) -+#define SR_MEDIUM_SM (1 << 12) -+/* command : Monitor Mode Status Read Reg */ -+#define SR_CMD_READ_MONITOR_MODE 0x1c -+/* command : Monitor Mode Status Write Reg */ -+#define SR_CMD_WRITE_MONITOR_MODE 0x1d -+/* command : GPIO Status Read Reg */ -+#define SR_CMD_READ_GPIOS 0x1e -+#define SR_GPIO_GPO0EN (1 << 0) /* GPIO0 Output enable */ -+#define SR_GPIO_GPO_0 (1 << 1) /* GPIO0 Output value */ -+#define SR_GPIO_GPO1EN (1 << 2) /* GPIO1 Output enable */ -+#define SR_GPIO_GPO_1 (1 << 3) /* GPIO1 Output value */ -+#define SR_GPIO_GPO2EN (1 << 4) /* GPIO2 Output enable */ -+#define SR_GPIO_GPO_2 (1 << 5) /* GPIO2 Output value */ -+#define SR_GPIO_RESERVED (1 << 6) /* Reserved */ -+#define SR_GPIO_RSE (1 << 7) /* Reload serial EEPROM */ -+/* command : GPIO Status Write Reg */ -+#define SR_CMD_WRITE_GPIOS 0x1f -+/* command : Eth PHY Power and Reset Control Reg */ -+#define SR_CMD_SW_RESET 0x20 -+#define SR_SWRESET_CLEAR 0x00 -+#define SR_SWRESET_RR (1 << 0) -+#define SR_SWRESET_RT (1 << 1) -+#define SR_SWRESET_PRTE (1 << 2) -+#define SR_SWRESET_PRL (1 << 3) -+#define SR_SWRESET_BZ (1 << 4) -+#define SR_SWRESET_IPRL (1 << 5) -+#define SR_SWRESET_IPPD (1 << 6) -+/* command : Software Interface Selection Status Read Reg */ -+#define SR_CMD_SW_PHY_STATUS 0x21 -+/* command : Software Interface Selection Status Write Reg */ -+#define SR_CMD_SW_PHY_SELECT 0x22 -+/* command : BULK in Buffer Size Reg */ -+#define SR_CMD_BULKIN_SIZE 0x2A -+/* command : LED_MUX Control Reg */ -+#define SR_CMD_LED_MUX 0x70 -+#define SR_LED_MUX_TX_ACTIVE (1 << 0) -+#define SR_LED_MUX_RX_ACTIVE (1 << 1) -+#define SR_LED_MUX_COLLISION (1 << 2) -+#define SR_LED_MUX_DUP_COL (1 << 3) -+#define SR_LED_MUX_DUP (1 << 4) -+#define SR_LED_MUX_SPEED (1 << 5) -+#define SR_LED_MUX_LINK_ACTIVE (1 << 6) -+#define SR_LED_MUX_LINK (1 << 7) -+ -+/* Register Access Flags */ -+#define SR_REQ_RD_REG (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE) -+#define SR_REQ_WR_REG (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) -+ -+/* Multicast Filter Array size & Max Number */ -+#define SR_MCAST_FILTER_SIZE 8 -+#define SR_MAX_MCAST 64 -+ -+/* IPG0/1/2 Default Value */ -+#define SR9800_IPG0_DEFAULT 0x15 -+#define SR9800_IPG1_DEFAULT 0x0c -+#define SR9800_IPG2_DEFAULT 0x12 -+ -+/* Medium Status Default Mode */ -+#define SR9800_MEDIUM_DEFAULT \ -+ (SR_MEDIUM_FD | SR_MEDIUM_RFC | \ -+ SR_MEDIUM_TFC | SR_MEDIUM_PS | \ -+ SR_MEDIUM_AC | SR_MEDIUM_RE) -+ -+/* RX Control Default Setting */ -+#define SR_DEFAULT_RX_CTL \ -+ (SR_RX_CTL_SO | SR_RX_CTL_AB | SR_RX_CTL_RH1M) -+ -+/* EEPROM Magic Number & EEPROM Size */ -+#define SR_EEPROM_MAGIC 0xdeadbeef -+#define SR9800_EEPROM_LEN 0xff -+ -+/* SR9800 Driver Version and Driver Name */ -+#define DRIVER_VERSION "11-Nov-2013" -+#define DRIVER_NAME "CoreChips" -+#define DRIVER_FLAG \ -+ (FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET) -+ -+/* SR9800 BULKIN Buffer Size */ -+#define SR9800_MAX_BULKIN_2K 0 -+#define SR9800_MAX_BULKIN_4K 1 -+#define SR9800_MAX_BULKIN_6K 2 -+#define SR9800_MAX_BULKIN_8K 3 -+#define SR9800_MAX_BULKIN_16K 4 -+#define SR9800_MAX_BULKIN_20K 5 -+#define SR9800_MAX_BULKIN_24K 6 -+#define SR9800_MAX_BULKIN_32K 7 -+ -+struct {unsigned short size, byte_cnt, threshold; } SR9800_BULKIN_SIZE[] = { -+ /* 2k */ -+ {2048, 0x8000, 0x8001}, -+ /* 4k */ -+ {4096, 0x8100, 0x8147}, -+ /* 6k */ -+ {6144, 0x8200, 0x81EB}, -+ /* 8k */ -+ {8192, 0x8300, 0x83D7}, -+ /* 16 */ -+ {16384, 0x8400, 0x851E}, -+ /* 20k */ -+ {20480, 0x8500, 0x8666}, -+ /* 24k */ -+ {24576, 0x8600, 0x87AE}, -+ /* 32k */ -+ {32768, 0x8700, 0x8A3D}, -+}; -+ -+/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ -+struct sr_data { -+ u8 multi_filter[SR_MCAST_FILTER_SIZE]; -+ u8 mac_addr[ETH_ALEN]; -+ u8 phymode; -+ u8 ledmode; -+ u8 eeprom_len; -+}; -+ -+struct sr9800_int_data { -+ __le16 res1; -+ u8 link; -+ __le16 res2; -+ u8 status; -+ __le16 res3; -+} __packed; -+ -+#endif /* _SR9800_H */ -diff -Naur backports-3.18.1-1.org/drivers/net/usb/zaurus.c backports-3.18.1-1/drivers/net/usb/zaurus.c ---- backports-3.18.1-1.org/drivers/net/usb/zaurus.c 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/zaurus.c 2014-12-16 18:39:45.000000000 +0100 -@@ -0,0 +1,385 @@ -+/* -+ * Copyright (C) 2002 Pavel Machek pavel@ucw.cz -+ * Copyright (C) 2002-2005 by David Brownell -+ * -+ * This program is free software; you can redistribute it and/or modify -+ * it under the terms of the GNU General Public License as published by -+ * the Free Software Foundation; either version 2 of the License, or -+ * (at your option) any later version. -+ * -+ * 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. -+ * -+ * You should have received a copy of the GNU General Public License -+ * along with this program; if not, see http://www.gnu.org/licenses/. -+ */ -+ -+// #define DEBUG // error path messages, extra info -+// #define VERBOSE // more; success messages -+ -+#include <linux/module.h> -+#include <linux/netdevice.h> -+#include <linux/ethtool.h> -+#include <linux/workqueue.h> -+#include <linux/mii.h> -+#include <linux/crc32.h> -+#include <linux/usb.h> -+#include <linux/usb/cdc.h> -+#include <linux/usb/usbnet.h> -+ -+ -+/* -+ * All known Zaurii lie about their standards conformance. At least -+ * the earliest SA-1100 models lie by saying they support CDC Ethernet. -+ * Some later models (especially PXA-25x and PXA-27x based ones) lie -+ * and say they support CDC MDLM (for access to cell phone modems). -+ * -+ * There are non-Zaurus products that use these same protocols too. -+ * -+ * The annoying thing is that at the same time Sharp was developing -+ * that annoying standards-breaking software, the Linux community had -+ * a simple "CDC Subset" working reliably on the same SA-1100 hardware. -+ * That is, the same functionality but not violating standards. -+ * -+ * The CDC Ethernet nonconformance points are troublesome to hosts -+ * with a true CDC Ethernet implementation: -+ * - Framing appends a CRC, which the spec says drivers "must not" do; -+ * - Transfers data in altsetting zero, instead of altsetting 1; -+ * - All these peripherals use the same ethernet address. -+ * -+ * The CDC MDLM nonconformance is less immediately troublesome, since all -+ * MDLM implementations are quasi-proprietary anyway. -+ */ -+ -+static struct sk_buff * -+zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) -+{ -+ int padlen; -+ struct sk_buff *skb2; -+ -+ padlen = 2; -+ if (!skb_cloned(skb)) { -+ int tailroom = skb_tailroom(skb); -+ if ((padlen + 4) <= tailroom) -+ goto done; -+ } -+ skb2 = skb_copy_expand(skb, 0, 4 + padlen, flags); -+ dev_kfree_skb_any(skb); -+ skb = skb2; -+ if (skb) { -+ u32 fcs; -+done: -+ fcs = crc32_le(~0, skb->data, skb->len); -+ fcs = ~fcs; -+ -+ *skb_put (skb, 1) = fcs & 0xff; -+ *skb_put (skb, 1) = (fcs>> 8) & 0xff; -+ *skb_put (skb, 1) = (fcs>>16) & 0xff; -+ *skb_put (skb, 1) = (fcs>>24) & 0xff; -+ } -+ return skb; -+} -+ -+static int zaurus_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ /* Belcarra's funky framing has other options; mostly -+ * TRAILERS (!) with 4 bytes CRC, and maybe 2 pad bytes. -+ */ -+ dev->net->hard_header_len += 6; -+ dev->rx_urb_size = dev->net->hard_header_len + dev->net->mtu; -+ return usbnet_generic_cdc_bind(dev, intf); -+} -+ -+/* PDA style devices are always connected if present */ -+static int always_connected (struct usbnet *dev) -+{ -+ return 0; -+} -+ -+static const struct driver_info zaurus_sl5x00_info = { -+ .description = "Sharp Zaurus SL-5x00", -+ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, -+ .check_connect = always_connected, -+ .bind = zaurus_bind, -+ .unbind = usbnet_cdc_unbind, -+ .tx_fixup = zaurus_tx_fixup, -+}; -+#define ZAURUS_STRONGARM_INFO ((unsigned long)&zaurus_sl5x00_info) -+ -+static const struct driver_info zaurus_pxa_info = { -+ .description = "Sharp Zaurus, PXA-2xx based", -+ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, -+ .check_connect = always_connected, -+ .bind = zaurus_bind, -+ .unbind = usbnet_cdc_unbind, -+ .tx_fixup = zaurus_tx_fixup, -+}; -+#define ZAURUS_PXA_INFO ((unsigned long)&zaurus_pxa_info) -+ -+static const struct driver_info olympus_mxl_info = { -+ .description = "Olympus R1000", -+ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, -+ .check_connect = always_connected, -+ .bind = zaurus_bind, -+ .unbind = usbnet_cdc_unbind, -+ .tx_fixup = zaurus_tx_fixup, -+}; -+#define OLYMPUS_MXL_INFO ((unsigned long)&olympus_mxl_info) -+ -+ -+/* Some more recent products using Lineo/Belcarra code will wrongly claim -+ * CDC MDLM conformance. They aren't conformant: data endpoints live -+ * in the control interface, there's no data interface, and it's not used -+ * to talk to a cell phone radio. But at least we can detect these two -+ * pseudo-classes, rather than growing this product list with entries for -+ * each new nonconformant product (sigh). -+ */ -+static const u8 safe_guid[16] = { -+ 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6, -+ 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f, -+}; -+static const u8 blan_guid[16] = { -+ 0x74, 0xf0, 0x3d, 0xbd, 0x1e, 0xc1, 0x44, 0x70, -+ 0xa3, 0x67, 0x71, 0x34, 0xc9, 0xf5, 0x54, 0x37, -+}; -+ -+static int blan_mdlm_bind(struct usbnet *dev, struct usb_interface *intf) -+{ -+ u8 *buf = intf->cur_altsetting->extra; -+ int len = intf->cur_altsetting->extralen; -+ struct usb_cdc_mdlm_desc *desc = NULL; -+ struct usb_cdc_mdlm_detail_desc *detail = NULL; -+ -+ while (len > 3) { -+ if (buf [1] != USB_DT_CS_INTERFACE) -+ goto next_desc; -+ -+ /* use bDescriptorSubType, and just verify that we get a -+ * "BLAN" (or "SAFE") descriptor. -+ */ -+ switch (buf [2]) { -+ case USB_CDC_MDLM_TYPE: -+ if (desc) { -+ dev_dbg(&intf->dev, "extra MDLM\n"); -+ goto bad_desc; -+ } -+ desc = (void *) buf; -+ if (desc->bLength != sizeof *desc) { -+ dev_dbg(&intf->dev, "MDLM len %u\n", -+ desc->bLength); -+ goto bad_desc; -+ } -+ /* expect bcdVersion 1.0, ignore */ -+ if (memcmp(&desc->bGUID, blan_guid, 16) && -+ memcmp(&desc->bGUID, safe_guid, 16)) { -+ /* hey, this one might _really_ be MDLM! */ -+ dev_dbg(&intf->dev, "MDLM guid\n"); -+ goto bad_desc; -+ } -+ break; -+ case USB_CDC_MDLM_DETAIL_TYPE: -+ if (detail) { -+ dev_dbg(&intf->dev, "extra MDLM detail\n"); -+ goto bad_desc; -+ } -+ detail = (void *) buf; -+ switch (detail->bGuidDescriptorType) { -+ case 0: /* "SAFE" */ -+ if (detail->bLength != (sizeof *detail + 2)) -+ goto bad_detail; -+ break; -+ case 1: /* "BLAN" */ -+ if (detail->bLength != (sizeof *detail + 3)) -+ goto bad_detail; -+ break; -+ default: -+ goto bad_detail; -+ } -+ -+ /* assuming we either noticed BLAN already, or will -+ * find it soon, there are some data bytes here: -+ * - bmNetworkCapabilities (unused) -+ * - bmDataCapabilities (bits, see below) -+ * - bPad (ignored, for PADAFTER -- BLAN-only) -+ * bits are: -+ * - 0x01 -- Zaurus framing (add CRC) -+ * - 0x02 -- PADBEFORE (CRC includes some padding) -+ * - 0x04 -- PADAFTER (some padding after CRC) -+ * - 0x08 -- "fermat" packet mangling (for hw bugs) -+ * the PADBEFORE appears not to matter; we interop -+ * with devices that use it and those that don't. -+ */ -+ if ((detail->bDetailData[1] & ~0x02) != 0x01) { -+ /* bmDataCapabilities == 0 would be fine too, -+ * but framing is minidriver-coupled for now. -+ */ -+bad_detail: -+ dev_dbg(&intf->dev, -+ "bad MDLM detail, %d %d %d\n", -+ detail->bLength, -+ detail->bDetailData[0], -+ detail->bDetailData[2]); -+ goto bad_desc; -+ } -+ -+ /* same extra framing as for non-BLAN mode */ -+ dev->net->hard_header_len += 6; -+ dev->rx_urb_size = dev->net->hard_header_len -+ + dev->net->mtu; -+ break; -+ } -+next_desc: -+ len -= buf [0]; /* bLength */ -+ buf += buf [0]; -+ } -+ -+ if (!desc || !detail) { -+ dev_dbg(&intf->dev, "missing cdc mdlm %s%sdescriptor\n", -+ desc ? "" : "func ", -+ detail ? "" : "detail "); -+ goto bad_desc; -+ } -+ -+ /* There's probably a CDC Ethernet descriptor there, but we can't -+ * rely on the Ethernet address it provides since not all vendors -+ * bother to make it unique. Likewise there's no point in tracking -+ * of the CDC event notifications. -+ */ -+ return usbnet_get_endpoints(dev, intf); -+ -+bad_desc: -+ dev_info(&dev->udev->dev, "unsupported MDLM descriptors\n"); -+ return -ENODEV; -+} -+ -+static const struct driver_info bogus_mdlm_info = { -+ .description = "pseudo-MDLM (BLAN) device", -+ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, -+ .check_connect = always_connected, -+ .tx_fixup = zaurus_tx_fixup, -+ .bind = blan_mdlm_bind, -+}; -+ -+static const struct usb_device_id products [] = { -+#define ZAURUS_MASTER_INTERFACE \ -+ .bInterfaceClass = USB_CLASS_COMM, \ -+ .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \ -+ .bInterfaceProtocol = USB_CDC_PROTO_NONE -+ -+/* SA-1100 based Sharp Zaurus ("collie"), or compatible. */ -+{ -+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO -+ | USB_DEVICE_ID_MATCH_DEVICE, -+ .idVendor = 0x04DD, -+ .idProduct = 0x8004, -+ ZAURUS_MASTER_INTERFACE, -+ .driver_info = ZAURUS_STRONGARM_INFO, -+}, -+ -+/* PXA-2xx based models are also lying-about-cdc. If you add any -+ * more devices that claim to be CDC Ethernet, make sure they get -+ * added to the blacklist in cdc_ether too. -+ * -+ * NOTE: OpenZaurus versions with 2.6 kernels won't use these entries, -+ * unlike the older ones with 2.4 "embedix" kernels. -+ */ -+{ -+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO -+ | USB_DEVICE_ID_MATCH_DEVICE, -+ .idVendor = 0x04DD, -+ .idProduct = 0x8005, /* A-300 */ -+ ZAURUS_MASTER_INTERFACE, -+ .driver_info = ZAURUS_PXA_INFO, -+}, { -+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO -+ | USB_DEVICE_ID_MATCH_DEVICE, -+ .idVendor = 0x04DD, -+ .idProduct = 0x8006, /* B-500/SL-5600 */ -+ ZAURUS_MASTER_INTERFACE, -+ .driver_info = ZAURUS_PXA_INFO, -+}, { -+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO -+ | USB_DEVICE_ID_MATCH_DEVICE, -+ .idVendor = 0x04DD, -+ .idProduct = 0x8007, /* C-700 */ -+ ZAURUS_MASTER_INTERFACE, -+ .driver_info = ZAURUS_PXA_INFO, -+}, { -+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO -+ | USB_DEVICE_ID_MATCH_DEVICE, -+ .idVendor = 0x04DD, -+ .idProduct = 0x9031, /* C-750 C-760 */ -+ ZAURUS_MASTER_INTERFACE, -+ .driver_info = ZAURUS_PXA_INFO, -+}, { -+ /* C-750/C-760/C-860/SL-C3000 PDA in MDLM mode */ -+ USB_DEVICE_AND_INTERFACE_INFO(0x04DD, 0x9031, USB_CLASS_COMM, -+ USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), -+ .driver_info = (unsigned long) &bogus_mdlm_info, -+}, { -+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO -+ | USB_DEVICE_ID_MATCH_DEVICE, -+ .idVendor = 0x04DD, -+ .idProduct = 0x9032, /* SL-6000 */ -+ ZAURUS_MASTER_INTERFACE, -+ .driver_info = ZAURUS_PXA_INFO, -+}, { -+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO -+ | USB_DEVICE_ID_MATCH_DEVICE, -+ .idVendor = 0x04DD, -+ /* reported with some C860 units */ -+ .idProduct = 0x9050, /* C-860 */ -+ ZAURUS_MASTER_INTERFACE, -+ .driver_info = ZAURUS_PXA_INFO, -+}, -+{ -+ /* Motorola Rokr E6 */ -+ USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x6027, USB_CLASS_COMM, -+ USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), -+ .driver_info = (unsigned long) &bogus_mdlm_info, -+}, { -+ /* Motorola MOTOMAGX phones */ -+ USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x6425, USB_CLASS_COMM, -+ USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), -+ .driver_info = (unsigned long) &bogus_mdlm_info, -+}, -+ -+/* Olympus has some models with a Zaurus-compatible option. -+ * R-1000 uses a FreeScale i.MXL cpu (ARMv4T) -+ */ -+{ -+ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO -+ | USB_DEVICE_ID_MATCH_DEVICE, -+ .idVendor = 0x07B4, -+ .idProduct = 0x0F02, /* R-1000 */ -+ ZAURUS_MASTER_INTERFACE, -+ .driver_info = OLYMPUS_MXL_INFO, -+}, -+ -+/* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */ -+{ -+ USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM, -+ USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), -+ .driver_info = (unsigned long) &bogus_mdlm_info, -+}, -+ { }, // END -+}; -+MODULE_DEVICE_TABLE(usb, products); -+ -+static struct usb_driver zaurus_driver = { -+ .name = "zaurus", -+ .id_table = products, -+ .probe = usbnet_probe, -+ .disconnect = usbnet_disconnect, -+ .suspend = usbnet_suspend, -+ .resume = usbnet_resume, -+ .disable_hub_initiated_lpm = 1, -+}; -+ -+module_usb_driver(zaurus_driver); -+ -+MODULE_AUTHOR("Pavel Machek, David Brownell"); -+MODULE_DESCRIPTION("Sharp Zaurus PDA, and compatible products"); -+MODULE_LICENSE("GPL"); diff --git a/src/patches/backports-3.18.1-1-grsecurity.patch b/src/patches/backports-3.18.1-1-grsecurity.patch deleted file mode 100644 index 711f2e3..0000000 --- a/src/patches/backports-3.18.1-1-grsecurity.patch +++ /dev/null @@ -1,3806 +0,0 @@ -diff -Naur backports-3.18.1-1.org/drivers/bluetooth/btwilink.c backports-3.18.1-1/drivers/bluetooth/btwilink.c ---- backports-3.18.1-1.org/drivers/bluetooth/btwilink.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/drivers/bluetooth/btwilink.c 2014-12-28 14:10:09.480888533 +0100 -@@ -288,7 +288,7 @@ - - static int bt_ti_probe(struct platform_device *pdev) - { -- static struct ti_st *hst; -+ struct ti_st *hst; - struct hci_dev *hdev; - int err; - -diff -Naur backports-3.18.1-1.org/drivers/media/dvb-core/dvbdev.c backports-3.18.1-1/drivers/media/dvb-core/dvbdev.c ---- backports-3.18.1-1.org/drivers/media/dvb-core/dvbdev.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/dvb-core/dvbdev.c 2014-12-28 14:10:09.528888772 +0100 -@@ -185,7 +185,7 @@ - const struct dvb_device *template, void *priv, int type) - { - struct dvb_device *dvbdev; -- struct file_operations *dvbdevfops; -+ file_operations_no_const *dvbdevfops; - struct device *clsdev; - int minor; - int id; -diff -Naur backports-3.18.1-1.org/drivers/media/dvb-frontends/af9033.h backports-3.18.1-1/drivers/media/dvb-frontends/af9033.h ---- backports-3.18.1-1.org/drivers/media/dvb-frontends/af9033.h 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/dvb-frontends/af9033.h 2014-12-28 14:10:09.528888772 +0100 -@@ -96,6 +96,6 @@ - int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff); - int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid, - int onoff); --}; -+} __no_const; - - #endif /* AF9033_H */ -diff -Naur backports-3.18.1-1.org/drivers/media/dvb-frontends/dib3000.h backports-3.18.1-1/drivers/media/dvb-frontends/dib3000.h ---- backports-3.18.1-1.org/drivers/media/dvb-frontends/dib3000.h 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/dvb-frontends/dib3000.h 2014-12-28 14:10:09.528888772 +0100 -@@ -39,7 +39,7 @@ - int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff); - int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff); - int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl); --}; -+} __no_const; - - #if IS_ENABLED(CPTCFG_DVB_DIB3000MB) - extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, -diff -Naur backports-3.18.1-1.org/drivers/media/dvb-frontends/dib7000p.h backports-3.18.1-1/drivers/media/dvb-frontends/dib7000p.h ---- backports-3.18.1-1.org/drivers/media/dvb-frontends/dib7000p.h 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/dvb-frontends/dib7000p.h 2014-12-28 14:10:09.528888772 +0100 -@@ -64,7 +64,7 @@ - int (*get_adc_power)(struct dvb_frontend *fe); - int (*slave_reset)(struct dvb_frontend *fe); - struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg); --}; -+} __no_const; - - #if IS_ENABLED(CPTCFG_DVB_DIB7000P) - void *dib7000p_attach(struct dib7000p_ops *ops); -diff -Naur backports-3.18.1-1.org/drivers/media/dvb-frontends/dib8000.h backports-3.18.1-1/drivers/media/dvb-frontends/dib8000.h ---- backports-3.18.1-1.org/drivers/media/dvb-frontends/dib8000.h 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/dvb-frontends/dib8000.h 2014-12-28 14:10:09.528888772 +0100 -@@ -61,7 +61,7 @@ - int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff); - int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff); - struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg); --}; -+} __no_const; - - #if IS_ENABLED(CPTCFG_DVB_DIB8000) - void *dib8000_attach(struct dib8000_ops *ops); -diff -Naur backports-3.18.1-1.org/drivers/media/pci/cx88/cx88-video.c backports-3.18.1-1/drivers/media/pci/cx88/cx88-video.c ---- backports-3.18.1-1.org/drivers/media/pci/cx88/cx88-video.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/pci/cx88/cx88-video.c 2014-12-28 14:10:09.528888772 +0100 -@@ -50,9 +50,9 @@ - - /* ------------------------------------------------------------------ */ - --static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; --static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; --static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; -+static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; -+static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; -+static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; - - module_param_array(video_nr, int, NULL, 0444); - module_param_array(vbi_nr, int, NULL, 0444); -diff -Naur backports-3.18.1-1.org/drivers/media/pci/ivtv/ivtv-driver.c backports-3.18.1-1/drivers/media/pci/ivtv/ivtv-driver.c ---- backports-3.18.1-1.org/drivers/media/pci/ivtv/ivtv-driver.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/pci/ivtv/ivtv-driver.c 2014-12-28 14:10:09.528888772 +0100 -@@ -83,7 +83,7 @@ - MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl); - - /* ivtv instance counter */ --static atomic_t ivtv_instance = ATOMIC_INIT(0); -+static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0); - - /* Parameter declarations */ - static int cardtype[IVTV_MAX_CARDS]; -diff -Naur backports-3.18.1-1.org/drivers/media/pci/solo6x10/solo6x10-core.c backports-3.18.1-1/drivers/media/pci/solo6x10/solo6x10-core.c ---- backports-3.18.1-1.org/drivers/media/pci/solo6x10/solo6x10-core.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/pci/solo6x10/solo6x10-core.c 2014-12-28 14:10:09.528888772 +0100 -@@ -424,7 +424,7 @@ - - static int solo_sysfs_init(struct solo_dev *solo_dev) - { -- struct bin_attribute *sdram_attr = &solo_dev->sdram_attr; -+ bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr; - struct device *dev = &solo_dev->dev; - const char *driver; - int i; -diff -Naur backports-3.18.1-1.org/drivers/media/pci/solo6x10/solo6x10-g723.c backports-3.18.1-1/drivers/media/pci/solo6x10/solo6x10-g723.c ---- backports-3.18.1-1.org/drivers/media/pci/solo6x10/solo6x10-g723.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/pci/solo6x10/solo6x10-g723.c 2014-12-28 14:10:09.528888772 +0100 -@@ -351,7 +351,7 @@ - - int solo_g723_init(struct solo_dev *solo_dev) - { -- static struct snd_device_ops ops = { NULL }; -+ static struct snd_device_ops ops = { }; - struct snd_card *card; - struct snd_kcontrol_new kctl; - char name[32]; -diff -Naur backports-3.18.1-1.org/drivers/media/pci/solo6x10/solo6x10.h backports-3.18.1-1/drivers/media/pci/solo6x10/solo6x10.h ---- backports-3.18.1-1.org/drivers/media/pci/solo6x10/solo6x10.h 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/pci/solo6x10/solo6x10.h 2014-12-28 14:10:09.532888798 +0100 -@@ -219,7 +219,7 @@ - - /* P2M DMA Engine */ - struct solo_p2m_dev p2m_dev[SOLO_NR_P2M]; -- atomic_t p2m_count; -+ atomic_unchecked_t p2m_count; - int p2m_jiffies; - unsigned int p2m_timeouts; - -diff -Naur backports-3.18.1-1.org/drivers/media/pci/solo6x10/solo6x10-p2m.c backports-3.18.1-1/drivers/media/pci/solo6x10/solo6x10-p2m.c ---- backports-3.18.1-1.org/drivers/media/pci/solo6x10/solo6x10-p2m.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/pci/solo6x10/solo6x10-p2m.c 2014-12-28 14:10:09.532888798 +0100 -@@ -73,7 +73,7 @@ - - /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */ - if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) { -- p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M; -+ p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M; - if (p2m_id < 0) - p2m_id = -p2m_id; - } -diff -Naur backports-3.18.1-1.org/drivers/media/platform/omap/omap_vout.c backports-3.18.1-1/drivers/media/platform/omap/omap_vout.c ---- backports-3.18.1-1.org/drivers/media/platform/omap/omap_vout.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/platform/omap/omap_vout.c 2014-12-28 14:10:09.532888798 +0100 -@@ -63,7 +63,6 @@ - OMAP_VIDEO2, - }; - --static struct videobuf_queue_ops video_vbq_ops; - /* Variables configurable through module params*/ - static u32 video1_numbuffers = 3; - static u32 video2_numbuffers = 3; -@@ -1012,6 +1011,12 @@ - { - struct videobuf_queue *q; - struct omap_vout_device *vout = NULL; -+ static struct videobuf_queue_ops video_vbq_ops = { -+ .buf_setup = omap_vout_buffer_setup, -+ .buf_prepare = omap_vout_buffer_prepare, -+ .buf_release = omap_vout_buffer_release, -+ .buf_queue = omap_vout_buffer_queue, -+ }; - - vout = video_drvdata(file); - v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__); -@@ -1029,10 +1034,6 @@ - vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; - - q = &vout->vbq; -- video_vbq_ops.buf_setup = omap_vout_buffer_setup; -- video_vbq_ops.buf_prepare = omap_vout_buffer_prepare; -- video_vbq_ops.buf_release = omap_vout_buffer_release; -- video_vbq_ops.buf_queue = omap_vout_buffer_queue; - spin_lock_init(&vout->vbq_lock); - - videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev, -diff -Naur backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer_grp_layer.c backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer_grp_layer.c ---- backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer_grp_layer.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer_grp_layer.c 2014-12-28 14:10:09.532888798 +0100 -@@ -235,7 +235,7 @@ - { - struct mxr_layer *layer; - int ret; -- struct mxr_layer_ops ops = { -+ static struct mxr_layer_ops ops = { - .release = mxr_graph_layer_release, - .buffer_set = mxr_graph_buffer_set, - .stream_set = mxr_graph_stream_set, -diff -Naur backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer.h backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer.h ---- backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer.h 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer.h 2014-12-28 14:10:09.532888798 +0100 -@@ -156,7 +156,7 @@ - /** layer index (unique identifier) */ - int idx; - /** callbacks for layer methods */ -- struct mxr_layer_ops ops; -+ struct mxr_layer_ops *ops; - /** format array */ - const struct mxr_format **fmt_array; - /** size of format array */ -diff -Naur backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer_reg.c backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer_reg.c ---- backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer_reg.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer_reg.c 2014-12-28 14:10:09.532888798 +0100 -@@ -276,7 +276,7 @@ - layer->update_buf = next; - } - -- layer->ops.buffer_set(layer, layer->update_buf); -+ layer->ops->buffer_set(layer, layer->update_buf); - - if (done && done != layer->shadow_buf) - vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE); -diff -Naur backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer_video.c backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer_video.c ---- backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer_video.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer_video.c 2014-12-28 14:10:09.532888798 +0100 -@@ -210,7 +210,7 @@ - layer->geo.src.height = layer->geo.src.full_height; - - mxr_geometry_dump(mdev, &layer->geo); -- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0); -+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0); - mxr_geometry_dump(mdev, &layer->geo); - } - -@@ -228,7 +228,7 @@ - layer->geo.dst.full_width = mbus_fmt.width; - layer->geo.dst.full_height = mbus_fmt.height; - layer->geo.dst.field = mbus_fmt.field; -- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0); -+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0); - - mxr_geometry_dump(mdev, &layer->geo); - } -@@ -334,7 +334,7 @@ - /* set source size to highest accepted value */ - geo->src.full_width = max(geo->dst.full_width, pix->width); - geo->src.full_height = max(geo->dst.full_height, pix->height); -- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0); -+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0); - mxr_geometry_dump(mdev, &layer->geo); - /* set cropping to total visible screen */ - geo->src.width = pix->width; -@@ -342,12 +342,12 @@ - geo->src.x_offset = 0; - geo->src.y_offset = 0; - /* assure consistency of geometry */ -- layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET); -+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET); - mxr_geometry_dump(mdev, &layer->geo); - /* set full size to lowest possible value */ - geo->src.full_width = 0; - geo->src.full_height = 0; -- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0); -+ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0); - mxr_geometry_dump(mdev, &layer->geo); - - /* returning results */ -@@ -474,7 +474,7 @@ - target->width = s->r.width; - target->height = s->r.height; - -- layer->ops.fix_geometry(layer, stage, s->flags); -+ layer->ops->fix_geometry(layer, stage, s->flags); - - /* retrieve update selection rectangle */ - res.left = target->x_offset; -@@ -954,13 +954,13 @@ - mxr_output_get(mdev); - - mxr_layer_update_output(layer); -- layer->ops.format_set(layer); -+ layer->ops->format_set(layer); - /* enabling layer in hardware */ - spin_lock_irqsave(&layer->enq_slock, flags); - layer->state = MXR_LAYER_STREAMING; - spin_unlock_irqrestore(&layer->enq_slock, flags); - -- layer->ops.stream_set(layer, MXR_ENABLE); -+ layer->ops->stream_set(layer, MXR_ENABLE); - mxr_streamer_get(mdev); - - return 0; -@@ -1030,7 +1030,7 @@ - spin_unlock_irqrestore(&layer->enq_slock, flags); - - /* disabling layer in hardware */ -- layer->ops.stream_set(layer, MXR_DISABLE); -+ layer->ops->stream_set(layer, MXR_DISABLE); - /* remove one streamer */ - mxr_streamer_put(mdev); - /* allow changes in output configuration */ -@@ -1068,8 +1068,8 @@ - - void mxr_layer_release(struct mxr_layer *layer) - { -- if (layer->ops.release) -- layer->ops.release(layer); -+ if (layer->ops->release) -+ layer->ops->release(layer); - } - - void mxr_base_layer_release(struct mxr_layer *layer) -@@ -1095,7 +1095,7 @@ - - layer->mdev = mdev; - layer->idx = idx; -- layer->ops = *ops; -+ layer->ops = ops; - - spin_lock_init(&layer->enq_slock); - INIT_LIST_HEAD(&layer->enq_list); -diff -Naur backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer_vp_layer.c backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer_vp_layer.c ---- backports-3.18.1-1.org/drivers/media/platform/s5p-tv/mixer_vp_layer.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/platform/s5p-tv/mixer_vp_layer.c 2014-12-28 14:10:09.532888798 +0100 -@@ -206,7 +206,7 @@ - { - struct mxr_layer *layer; - int ret; -- struct mxr_layer_ops ops = { -+ static struct mxr_layer_ops ops = { - .release = mxr_vp_layer_release, - .buffer_set = mxr_vp_buffer_set, - .stream_set = mxr_vp_stream_set, -diff -Naur backports-3.18.1-1.org/drivers/media/radio/radio-cadet.c backports-3.18.1-1/drivers/media/radio/radio-cadet.c ---- backports-3.18.1-1.org/drivers/media/radio/radio-cadet.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/radio/radio-cadet.c 2014-12-28 14:10:09.532888798 +0100 -@@ -333,6 +333,8 @@ - unsigned char readbuf[RDS_BUFFER]; - int i = 0; - -+ if (count > RDS_BUFFER) -+ return -EFAULT; - mutex_lock(&dev->lock); - if (dev->rdsstat == 0) - cadet_start_rds(dev); -@@ -349,8 +351,9 @@ - readbuf[i++] = dev->rdsbuf[dev->rdsout++]; - mutex_unlock(&dev->lock); - -- if (i && copy_to_user(data, readbuf, i)) -- return -EFAULT; -+ if (i > sizeof(readbuf) || (i && copy_to_user(data, readbuf, i))) -+ i = -EFAULT; -+ - return i; - } - -diff -Naur backports-3.18.1-1.org/drivers/media/radio/radio-maxiradio.c backports-3.18.1-1/drivers/media/radio/radio-maxiradio.c ---- backports-3.18.1-1.org/drivers/media/radio/radio-maxiradio.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/radio/radio-maxiradio.c 2014-12-28 14:10:09.532888798 +0100 -@@ -61,7 +61,7 @@ - /* TEA5757 pin mappings */ - static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16; - --static atomic_t maxiradio_instance = ATOMIC_INIT(0); -+static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0); - - #define PCI_VENDOR_ID_GUILLEMOT 0x5046 - #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001 -diff -Naur backports-3.18.1-1.org/drivers/media/radio/radio-shark2.c backports-3.18.1-1/drivers/media/radio/radio-shark2.c ---- backports-3.18.1-1.org/drivers/media/radio/radio-shark2.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/radio/radio-shark2.c 2014-12-28 14:10:09.532888798 +0100 -@@ -74,7 +74,7 @@ - u8 *transfer_buffer; - }; - --static atomic_t shark_instance = ATOMIC_INIT(0); -+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0); - - static int shark_write_reg(struct radio_tea5777 *tea, u64 reg) - { -diff -Naur backports-3.18.1-1.org/drivers/media/radio/radio-shark.c backports-3.18.1-1/drivers/media/radio/radio-shark.c ---- backports-3.18.1-1.org/drivers/media/radio/radio-shark.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/radio/radio-shark.c 2014-12-28 14:10:09.532888798 +0100 -@@ -79,7 +79,7 @@ - u32 last_val; - }; - --static atomic_t shark_instance = ATOMIC_INIT(0); -+static atomic_unchecked_t shark_instance = ATOMIC_INIT(0); - - static void shark_write_val(struct snd_tea575x *tea, u32 val) - { -diff -Naur backports-3.18.1-1.org/drivers/media/radio/radio-si476x.c backports-3.18.1-1/drivers/media/radio/radio-si476x.c ---- backports-3.18.1-1.org/drivers/media/radio/radio-si476x.c 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/radio/radio-si476x.c 2014-12-28 14:10:09.532888798 +0100 -@@ -1445,7 +1445,7 @@ - struct si476x_radio *radio; - struct v4l2_ctrl *ctrl; - -- static atomic_t instance = ATOMIC_INIT(0); -+ static atomic_unchecked_t instance = ATOMIC_INIT(0); - - radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL); - if (!radio) -diff -Naur backports-3.18.1-1.org/drivers/media/usb/dvb-usb/cinergyT2-core.c backports-3.18.1-1/drivers/media/usb/dvb-usb/cinergyT2-core.c ---- backports-3.18.1-1.org/drivers/media/usb/dvb-usb/cinergyT2-core.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/usb/dvb-usb/cinergyT2-core.c 2014-12-28 14:10:09.532888798 +0100 -@@ -50,29 +50,73 @@ - - static int cinergyt2_streaming_ctrl(struct dvb_usb_adapter *adap, int enable) - { -- char buf[] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 }; -- char result[64]; -- return dvb_usb_generic_rw(adap->dev, buf, sizeof(buf), result, -- sizeof(result), 0); -+ char *buf; -+ char *result; -+ int retval; -+ -+ buf = kmalloc(2, GFP_KERNEL); -+ if (buf == NULL) -+ return -ENOMEM; -+ result = kmalloc(64, GFP_KERNEL); -+ if (result == NULL) { -+ kfree(buf); -+ return -ENOMEM; -+ } -+ -+ buf[0] = CINERGYT2_EP1_CONTROL_STREAM_TRANSFER; -+ buf[1] = enable ? 1 : 0; -+ -+ retval = dvb_usb_generic_rw(adap->dev, buf, 2, result, 64, 0); -+ -+ kfree(buf); -+ kfree(result); -+ return retval; - } - - static int cinergyt2_power_ctrl(struct dvb_usb_device *d, int enable) - { -- char buf[] = { CINERGYT2_EP1_SLEEP_MODE, enable ? 0 : 1 }; -- char state[3]; -- return dvb_usb_generic_rw(d, buf, sizeof(buf), state, sizeof(state), 0); -+ char *buf; -+ char *state; -+ int retval; -+ -+ buf = kmalloc(2, GFP_KERNEL); -+ if (buf == NULL) -+ return -ENOMEM; -+ state = kmalloc(3, GFP_KERNEL); -+ if (state == NULL) { -+ kfree(buf); -+ return -ENOMEM; -+ } -+ -+ buf[0] = CINERGYT2_EP1_SLEEP_MODE; -+ buf[1] = enable ? 1 : 0; -+ -+ retval = dvb_usb_generic_rw(d, buf, 2, state, 3, 0); -+ -+ kfree(buf); -+ kfree(state); -+ return retval; - } - - static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap) - { -- char query[] = { CINERGYT2_EP1_GET_FIRMWARE_VERSION }; -- char state[3]; -+ char *query; -+ char *state; - int ret; -+ query = kmalloc(1, GFP_KERNEL); -+ if (query == NULL) -+ return -ENOMEM; -+ state = kmalloc(3, GFP_KERNEL); -+ if (state == NULL) { -+ kfree(query); -+ return -ENOMEM; -+ } -+ -+ query[0] = CINERGYT2_EP1_GET_FIRMWARE_VERSION; - - adap->fe_adap[0].fe = cinergyt2_fe_attach(adap->dev); - -- ret = dvb_usb_generic_rw(adap->dev, query, sizeof(query), state, -- sizeof(state), 0); -+ ret = dvb_usb_generic_rw(adap->dev, query, 1, state, 3, 0); - if (ret < 0) { - deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep " - "state info\n"); -@@ -80,7 +124,8 @@ - - /* Copy this pointer as we are gonna need it in the release phase */ - cinergyt2_usb_device = adap->dev; -- -+ kfree(query); -+ kfree(state); - return 0; - } - -@@ -141,12 +186,23 @@ - static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state) - { - struct cinergyt2_state *st = d->priv; -- u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS; -+ u8 *key, *cmd; - int i; - -+ cmd = kmalloc(1, GFP_KERNEL); -+ if (cmd == NULL) -+ return -EINVAL; -+ key = kzalloc(5, GFP_KERNEL); -+ if (key == NULL) { -+ kfree(cmd); -+ return -EINVAL; -+ } -+ -+ cmd[0] = CINERGYT2_EP1_GET_RC_EVENTS; -+ - *state = REMOTE_NO_KEY_PRESSED; - -- dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0); -+ dvb_usb_generic_rw(d, cmd, 1, key, 5, 0); - if (key[4] == 0xff) { - /* key repeat */ - st->rc_counter++; -@@ -157,12 +213,12 @@ - *event = d->last_event; - deb_rc("repeat key, event %x\n", - *event); -- return 0; -+ goto out; - } - } - deb_rc("repeated key (non repeatable)\n"); - } -- return 0; -+ goto out; - } - - /* hack to pass checksum on the custom field */ -@@ -174,6 +230,9 @@ - - deb_rc("key: %*ph\n", 5, key); - } -+out: -+ kfree(cmd); -+ kfree(key); - return 0; - } - -diff -Naur backports-3.18.1-1.org/drivers/media/usb/dvb-usb/cinergyT2-fe.c backports-3.18.1-1/drivers/media/usb/dvb-usb/cinergyT2-fe.c ---- backports-3.18.1-1.org/drivers/media/usb/dvb-usb/cinergyT2-fe.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/usb/dvb-usb/cinergyT2-fe.c 2014-12-28 14:10:09.532888798 +0100 -@@ -145,103 +145,176 @@ - fe_status_t *status) - { - struct cinergyt2_fe_state *state = fe->demodulator_priv; -- struct dvbt_get_status_msg result; -- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; -+ struct dvbt_get_status_msg *result; -+ u8 *cmd; - int ret; - -- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&result, -- sizeof(result), 0); -+ cmd = kmalloc(1, GFP_KERNEL); -+ if (cmd == NULL) -+ return -ENOMEM; -+ result = kmalloc(sizeof(*result), GFP_KERNEL); -+ if (result == NULL) { -+ kfree(cmd); -+ return -ENOMEM; -+ } -+ -+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; -+ -+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)result, -+ sizeof(*result), 0); - if (ret < 0) -- return ret; -+ goto out; - - *status = 0; - -- if (0xffff - le16_to_cpu(result.gain) > 30) -+ if (0xffff - le16_to_cpu(result->gain) > 30) - *status |= FE_HAS_SIGNAL; -- if (result.lock_bits & (1 << 6)) -+ if (result->lock_bits & (1 << 6)) - *status |= FE_HAS_LOCK; -- if (result.lock_bits & (1 << 5)) -+ if (result->lock_bits & (1 << 5)) - *status |= FE_HAS_SYNC; -- if (result.lock_bits & (1 << 4)) -+ if (result->lock_bits & (1 << 4)) - *status |= FE_HAS_CARRIER; -- if (result.lock_bits & (1 << 1)) -+ if (result->lock_bits & (1 << 1)) - *status |= FE_HAS_VITERBI; - - if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) != - (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) - *status &= ~FE_HAS_LOCK; - -- return 0; -+out: -+ kfree(cmd); -+ kfree(result); -+ return ret; - } - - static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber) - { - struct cinergyt2_fe_state *state = fe->demodulator_priv; -- struct dvbt_get_status_msg status; -- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; -+ struct dvbt_get_status_msg *status; -+ char *cmd; - int ret; - -- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status, -- sizeof(status), 0); -+ cmd = kmalloc(1, GFP_KERNEL); -+ if (cmd == NULL) -+ return -ENOMEM; -+ status = kmalloc(sizeof(*status), GFP_KERNEL); -+ if (status == NULL) { -+ kfree(cmd); -+ return -ENOMEM; -+ } -+ -+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; -+ -+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status, -+ sizeof(*status), 0); - if (ret < 0) -- return ret; -+ goto out; - -- *ber = le32_to_cpu(status.viterbi_error_rate); -+ *ber = le32_to_cpu(status->viterbi_error_rate); -+out: -+ kfree(cmd); -+ kfree(status); - return 0; - } - - static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc) - { - struct cinergyt2_fe_state *state = fe->demodulator_priv; -- struct dvbt_get_status_msg status; -- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; -+ struct dvbt_get_status_msg *status; -+ u8 *cmd; - int ret; - -- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&status, -- sizeof(status), 0); -+ cmd = kmalloc(1, GFP_KERNEL); -+ if (cmd == NULL) -+ return -ENOMEM; -+ status = kmalloc(sizeof(*status), GFP_KERNEL); -+ if (status == NULL) { -+ kfree(cmd); -+ return -ENOMEM; -+ } -+ -+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; -+ -+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)status, -+ sizeof(*status), 0); - if (ret < 0) { - err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n", - ret); -- return ret; -+ goto out; - } -- *unc = le32_to_cpu(status.uncorrected_block_count); -- return 0; -+ *unc = le32_to_cpu(status->uncorrected_block_count); -+ -+out: -+ kfree(cmd); -+ kfree(status); -+ return ret; - } - - static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe, - u16 *strength) - { - struct cinergyt2_fe_state *state = fe->demodulator_priv; -- struct dvbt_get_status_msg status; -- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; -+ struct dvbt_get_status_msg *status; -+ char *cmd; - int ret; - -- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status, -- sizeof(status), 0); -+ cmd = kmalloc(1, GFP_KERNEL); -+ if (cmd == NULL) -+ return -ENOMEM; -+ status = kmalloc(sizeof(*status), GFP_KERNEL); -+ if (status == NULL) { -+ kfree(cmd); -+ return -ENOMEM; -+ } -+ -+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; -+ -+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status, -+ sizeof(*status), 0); - if (ret < 0) { - err("cinergyt2_fe_read_signal_strength() Failed!" - " (Error=%d)\n", ret); -- return ret; -+ goto out; - } -- *strength = (0xffff - le16_to_cpu(status.gain)); -+ *strength = (0xffff - le16_to_cpu(status->gain)); -+ -+out: -+ kfree(cmd); -+ kfree(status); - return 0; - } - - static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr) - { - struct cinergyt2_fe_state *state = fe->demodulator_priv; -- struct dvbt_get_status_msg status; -- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; -+ struct dvbt_get_status_msg *status; -+ char *cmd; - int ret; - -- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status, -- sizeof(status), 0); -+ cmd = kmalloc(1, GFP_KERNEL); -+ if (cmd == NULL) -+ return -ENOMEM; -+ status = kmalloc(sizeof(*status), GFP_KERNEL); -+ if (status == NULL) { -+ kfree(cmd); -+ return -ENOMEM; -+ } -+ -+ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; -+ -+ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status, -+ sizeof(*status), 0); - if (ret < 0) { - err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret); -- return ret; -+ goto out; - } -- *snr = (status.snr << 8) | status.snr; -- return 0; -+ *snr = (status->snr << 8) | status->snr; -+ -+out: -+ kfree(cmd); -+ kfree(status); -+ return ret; - } - - static int cinergyt2_fe_init(struct dvb_frontend *fe) -@@ -266,35 +339,46 @@ - { - struct dtv_frontend_properties *fep = &fe->dtv_property_cache; - struct cinergyt2_fe_state *state = fe->demodulator_priv; -- struct dvbt_set_parameters_msg param; -- char result[2]; -+ struct dvbt_set_parameters_msg *param; -+ char *result; - int err; - -- param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; -- param.tps = cpu_to_le16(compute_tps(fep)); -- param.freq = cpu_to_le32(fep->frequency / 1000); -- param.flags = 0; -+ result = kmalloc(2, GFP_KERNEL); -+ if (result == NULL) -+ return -ENOMEM; -+ param = kmalloc(sizeof(*param), GFP_KERNEL); -+ if (param == NULL) { -+ kfree(result); -+ return -ENOMEM; -+ } -+ -+ param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; -+ param->tps = cpu_to_le16(compute_tps(fep)); -+ param->freq = cpu_to_le32(fep->frequency / 1000); -+ param->flags = 0; - - switch (fep->bandwidth_hz) { - default: - case 8000000: -- param.bandwidth = 8; -+ param->bandwidth = 8; - break; - case 7000000: -- param.bandwidth = 7; -+ param->bandwidth = 7; - break; - case 6000000: -- param.bandwidth = 6; -+ param->bandwidth = 6; - break; - } - - err = dvb_usb_generic_rw(state->d, -- (char *)¶m, sizeof(param), -- result, sizeof(result), 0); -+ (char *)param, sizeof(*param), -+ result, 2, 0); - if (err < 0) - err("cinergyt2_fe_set_frontend() Failed! err=%d\n", err); - -- return (err < 0) ? err : 0; -+ kfree(result); -+ kfree(param); -+ return err; - } - - static void cinergyt2_fe_release(struct dvb_frontend *fe) -diff -Naur backports-3.18.1-1.org/drivers/media/usb/dvb-usb/dvb-usb-firmware.c backports-3.18.1-1/drivers/media/usb/dvb-usb/dvb-usb-firmware.c ---- backports-3.18.1-1.org/drivers/media/usb/dvb-usb/dvb-usb-firmware.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/usb/dvb-usb/dvb-usb-firmware.c 2014-12-28 14:10:09.532888798 +0100 -@@ -35,42 +35,57 @@ - - int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) - { -- struct hexline hx; -- u8 reset; -+ struct hexline *hx; -+ u8 *reset; - int ret,pos=0; - -+ reset = kmalloc(1, GFP_KERNEL); -+ if (reset == NULL) -+ return -ENOMEM; -+ -+ hx = kmalloc(sizeof(struct hexline), GFP_KERNEL); -+ if (hx == NULL) { -+ kfree(reset); -+ return -ENOMEM; -+ } -+ - /* stop the CPU */ -- reset = 1; -- if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) -+ reset[0] = 1; -+ if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1)) != 1) - err("could not stop the USB controller CPU."); - -- while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) { -- deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk); -- ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len); -+ while ((ret = dvb_usb_get_hexline(fw,hx,&pos)) > 0) { -+ deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx->addr,hx->len,hx->chk); -+ ret = usb_cypress_writemem(udev,hx->addr,hx->data,hx->len); - -- if (ret != hx.len) { -+ if (ret != hx->len) { - err("error while transferring firmware " - "(transferred size: %d, block size: %d)", -- ret,hx.len); -+ ret,hx->len); - ret = -EINVAL; - break; - } - } - if (ret < 0) { - err("firmware download failed at %d with %d",pos,ret); -+ kfree(reset); -+ kfree(hx); - return ret; - } - - if (ret == 0) { - /* restart the CPU */ -- reset = 0; -- if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) { -+ reset[0] = 0; -+ if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1) != 1) { - err("could not restart the USB controller CPU."); - ret = -EINVAL; - } - } else - ret = -EIO; - -+ kfree(reset); -+ kfree(hx); -+ - return ret; - } - EXPORT_SYMBOL(usb_cypress_load_firmware); -diff -Naur backports-3.18.1-1.org/drivers/media/usb/dvb-usb/dw2102.c backports-3.18.1-1/drivers/media/usb/dvb-usb/dw2102.c ---- backports-3.18.1-1.org/drivers/media/usb/dvb-usb/dw2102.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/usb/dvb-usb/dw2102.c 2014-12-28 14:10:09.536888811 +0100 -@@ -118,7 +118,7 @@ - - struct s6x0_state { - int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v); --}; -+} __no_const; - - /* debug */ - static int dvb_usb_dw2102_debug; -diff -Naur backports-3.18.1-1.org/drivers/media/usb/dvb-usb/technisat-usb2.c backports-3.18.1-1/drivers/media/usb/dvb-usb/technisat-usb2.c ---- backports-3.18.1-1.org/drivers/media/usb/dvb-usb/technisat-usb2.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/usb/dvb-usb/technisat-usb2.c 2014-12-28 14:10:09.536888811 +0100 -@@ -87,8 +87,11 @@ - static int technisat_usb2_i2c_access(struct usb_device *udev, - u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen) - { -- u8 b[64]; -- int ret, actual_length; -+ u8 *b = kmalloc(64, GFP_KERNEL); -+ int ret, actual_length, error = 0; -+ -+ if (b == NULL) -+ return -ENOMEM; - - deb_i2c("i2c-access: %02x, tx: ", device_addr); - debug_dump(tx, txlen, deb_i2c); -@@ -121,7 +124,8 @@ - - if (ret < 0) { - err("i2c-error: out failed %02x = %d", device_addr, ret); -- return -ENODEV; -+ error = -ENODEV; -+ goto out; - } - - ret = usb_bulk_msg(udev, -@@ -129,7 +133,8 @@ - b, 64, &actual_length, 1000); - if (ret < 0) { - err("i2c-error: in failed %02x = %d", device_addr, ret); -- return -ENODEV; -+ error = -ENODEV; -+ goto out; - } - - if (b[0] != I2C_STATUS_OK) { -@@ -137,8 +142,10 @@ - /* handle tuner-i2c-nak */ - if (!(b[0] == I2C_STATUS_NAK && - device_addr == 0x60 -- /* && device_is_technisat_usb2 */)) -- return -ENODEV; -+ /* && device_is_technisat_usb2 */)) { -+ error = -ENODEV; -+ goto out; -+ } - } - - deb_i2c("status: %d, ", b[0]); -@@ -152,7 +159,9 @@ - - deb_i2c("\n"); - -- return 0; -+out: -+ kfree(b); -+ return error; - } - - static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, -@@ -224,14 +233,16 @@ - { - int ret; - -- u8 led[8] = { -- red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST, -- 0 -- }; -+ u8 *led = kzalloc(8, GFP_KERNEL); -+ -+ if (led == NULL) -+ return -ENOMEM; - - if (disable_led_control && state != TECH_LED_OFF) - return 0; - -+ led[0] = red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST; -+ - switch (state) { - case TECH_LED_ON: - led[1] = 0x82; -@@ -263,16 +274,22 @@ - red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST, - USB_TYPE_VENDOR | USB_DIR_OUT, - 0, 0, -- led, sizeof(led), 500); -+ led, 8, 500); - - mutex_unlock(&d->i2c_mutex); -+ -+ kfree(led); -+ - return ret; - } - - static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 green) - { - int ret; -- u8 b = 0; -+ u8 *b = kzalloc(1, GFP_KERNEL); -+ -+ if (b == NULL) -+ return -ENOMEM; - - if (mutex_lock_interruptible(&d->i2c_mutex) < 0) - return -EAGAIN; -@@ -281,10 +298,12 @@ - SET_LED_TIMER_DIVIDER_VENDOR_REQUEST, - USB_TYPE_VENDOR | USB_DIR_OUT, - (red << 8) | green, 0, -- &b, 1, 500); -+ b, 1, 500); - - mutex_unlock(&d->i2c_mutex); - -+ kfree(b); -+ - return ret; - } - -@@ -328,7 +347,7 @@ - struct dvb_usb_device_description **desc, int *cold) - { - int ret; -- u8 version[3]; -+ u8 *version = kmalloc(3, GFP_KERNEL); - - /* first select the interface */ - if (usb_set_interface(udev, 0, 1) != 0) -@@ -338,11 +357,14 @@ - - *cold = 0; /* by default do not download a firmware - just in case something is wrong */ - -+ if (version == NULL) -+ return 0; -+ - ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), - GET_VERSION_INFO_VENDOR_REQUEST, - USB_TYPE_VENDOR | USB_DIR_IN, - 0, 0, -- version, sizeof(version), 500); -+ version, 3, 500); - - if (ret < 0) - *cold = 1; -@@ -351,6 +373,8 @@ - *cold = 0; - } - -+ kfree(version); -+ - return 0; - } - -@@ -591,10 +615,15 @@ - - static int technisat_usb2_get_ir(struct dvb_usb_device *d) - { -- u8 buf[62], *b; -+ u8 *buf, *b; - int ret; - struct ir_raw_event ev; - -+ buf = kmalloc(62, GFP_KERNEL); -+ -+ if (buf == NULL) -+ return -ENOMEM; -+ - buf[0] = GET_IR_DATA_VENDOR_REQUEST; - buf[1] = 0x08; - buf[2] = 0x8f; -@@ -617,16 +646,20 @@ - GET_IR_DATA_VENDOR_REQUEST, - USB_TYPE_VENDOR | USB_DIR_IN, - 0x8080, 0, -- buf, sizeof(buf), 500); -+ buf, 62, 500); - - unlock: - mutex_unlock(&d->i2c_mutex); - -- if (ret < 0) -+ if (ret < 0) { -+ kfree(buf); - return ret; -+ } - -- if (ret == 1) -+ if (ret == 1) { -+ kfree(buf); - return 0; /* no key pressed */ -+ } - - /* decoding */ - b = buf+1; -@@ -653,6 +686,8 @@ - - ir_raw_event_handle(d->rc_dev); - -+ kfree(buf); -+ - return 1; - } - -diff -Naur backports-3.18.1-1.org/drivers/media/v4l2-core/v4l2-device.c backports-3.18.1-1/drivers/media/v4l2-core/v4l2-device.c ---- backports-3.18.1-1.org/drivers/media/v4l2-core/v4l2-device.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/v4l2-core/v4l2-device.c 2014-12-28 14:10:09.536888811 +0100 -@@ -75,9 +75,9 @@ - EXPORT_SYMBOL_GPL(v4l2_device_put); - - int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename, -- atomic_t *instance) -+ atomic_unchecked_t *instance) - { -- int num = atomic_inc_return(instance) - 1; -+ int num = atomic_inc_return_unchecked(instance) - 1; - int len = strlen(basename); - - if (basename[len - 1] >= '0' && basename[len - 1] <= '9') -diff -Naur backports-3.18.1-1.org/drivers/media/v4l2-core/v4l2-ioctl.c backports-3.18.1-1/drivers/media/v4l2-core/v4l2-ioctl.c ---- backports-3.18.1-1.org/drivers/media/v4l2-core/v4l2-ioctl.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/media/v4l2-core/v4l2-ioctl.c 2014-12-28 14:10:09.536888811 +0100 -@@ -2142,7 +2142,8 @@ - struct file *file, void *fh, void *p); - } u; - void (*debug)(const void *arg, bool write_only); --}; -+} __do_const; -+typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const; - - /* This control needs a priority check */ - #define INFO_FL_PRIO (1 << 0) -@@ -2326,7 +2327,7 @@ - struct video_device *vfd = video_devdata(file); - const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; - bool write_only = false; -- struct v4l2_ioctl_info default_info; -+ v4l2_ioctl_info_no_const default_info; - const struct v4l2_ioctl_info *info; - void *fh = file->private_data; - struct v4l2_fh *vfh = NULL; -@@ -2413,7 +2414,7 @@ - ret = -EINVAL; - break; - } -- *user_ptr = (void __user *)buf->m.planes; -+ *user_ptr = (void __force_user *)buf->m.planes; - *kernel_ptr = (void **)&buf->m.planes; - *array_size = sizeof(struct v4l2_plane) * buf->length; - ret = 1; -@@ -2430,7 +2431,7 @@ - ret = -EINVAL; - break; - } -- *user_ptr = (void __user *)edid->edid; -+ *user_ptr = (void __force_user *)edid->edid; - *kernel_ptr = (void **)&edid->edid; - *array_size = edid->blocks * 128; - ret = 1; -@@ -2448,7 +2449,7 @@ - ret = -EINVAL; - break; - } -- *user_ptr = (void __user *)ctrls->controls; -+ *user_ptr = (void __force_user *)ctrls->controls; - *kernel_ptr = (void **)&ctrls->controls; - *array_size = sizeof(struct v4l2_ext_control) - * ctrls->count; -@@ -2549,7 +2550,7 @@ - } - - if (has_array_args) { -- *kernel_ptr = (void __force *)user_ptr; -+ *kernel_ptr = (void __force_kernel *)user_ptr; - if (copy_to_user(user_ptr, mbuf, array_size)) - err = -EFAULT; - goto out_array_args; -diff -Naur backports-3.18.1-1.org/drivers/net/ieee802154/fakehard.c backports-3.18.1-1/drivers/net/ieee802154/fakehard.c ---- backports-3.18.1-1.org/drivers/net/ieee802154/fakehard.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/ieee802154/fakehard.c 2014-12-28 14:10:09.556888909 +0100 -@@ -365,7 +365,7 @@ - phy->transmit_power = 0xbf; - - dev->netdev_ops = &fake_ops; -- dev->ml_priv = &fake_mlme; -+ dev->ml_priv = (void *)&fake_mlme; - - priv = netdev_priv(dev); - priv->phy = phy; -diff -Naur backports-3.18.1-1.org/drivers/net/usb/sierra_net.c backports-3.18.1-1/drivers/net/usb/sierra_net.c ---- backports-3.18.1-1.org/drivers/net/usb/sierra_net.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/usb/sierra_net.c 2014-12-28 14:10:09.560888936 +0100 -@@ -51,7 +51,7 @@ - /* atomic counter partially included in MAC address to make sure 2 devices - * do not end up with the same MAC - concept breaks in case of > 255 ifaces - */ --static atomic_t iface_counter = ATOMIC_INIT(0); -+static atomic_unchecked_t iface_counter = ATOMIC_INIT(0); - - /* - * SYNC Timer Delay definition used to set the expiry time -@@ -697,7 +697,7 @@ - dev->net->netdev_ops = &sierra_net_device_ops; - - /* change MAC addr to include, ifacenum, and to be unique */ -- dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter); -+ dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter); - dev->net->dev_addr[ETH_ALEN-1] = ifacenum; - - /* we will have to manufacture ethernet headers, prepare template */ -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/at76c50x-usb.c backports-3.18.1-1/drivers/net/wireless/at76c50x-usb.c ---- backports-3.18.1-1.org/drivers/net/wireless/at76c50x-usb.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/at76c50x-usb.c 2014-12-28 14:10:09.560888936 +0100 -@@ -353,7 +353,7 @@ - } - - /* Convert timeout from the DFU status to jiffies */ --static inline unsigned long at76_get_timeout(struct dfu_status *s) -+static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s) - { - return msecs_to_jiffies((s->poll_timeout[2] << 16) - | (s->poll_timeout[1] << 8) -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ath/ath10k/htc.c backports-3.18.1-1/drivers/net/wireless/ath/ath10k/htc.c ---- backports-3.18.1-1.org/drivers/net/wireless/ath/ath10k/htc.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ath/ath10k/htc.c 2014-12-28 14:10:09.560888936 +0100 -@@ -848,7 +848,10 @@ - /* registered target arrival callback from the HIF layer */ - int ath10k_htc_init(struct ath10k *ar) - { -- struct ath10k_hif_cb htc_callbacks; -+ static struct ath10k_hif_cb htc_callbacks = { -+ .rx_completion = ath10k_htc_rx_completion_handler, -+ .tx_completion = ath10k_htc_tx_completion_handler, -+ }; - struct ath10k_htc_ep *ep = NULL; - struct ath10k_htc *htc = &ar->htc; - -@@ -857,8 +860,6 @@ - ath10k_htc_reset_endpoint_states(htc); - - /* setup HIF layer callbacks */ -- htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler; -- htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler; - htc->ar = ar; - - /* Get HIF default pipe for HTC message exchange */ -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ath/ath10k/htc.h backports-3.18.1-1/drivers/net/wireless/ath/ath10k/htc.h ---- backports-3.18.1-1.org/drivers/net/wireless/ath/ath10k/htc.h 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ath/ath10k/htc.h 2014-12-28 14:10:09.560888936 +0100 -@@ -270,13 +270,13 @@ - - struct ath10k_htc_ops { - void (*target_send_suspend_complete)(struct ath10k *ar); --}; -+} __no_const; - - struct ath10k_htc_ep_ops { - void (*ep_tx_complete)(struct ath10k *, struct sk_buff *); - void (*ep_rx_complete)(struct ath10k *, struct sk_buff *); - void (*ep_tx_credits)(struct ath10k *); --}; -+} __no_const; - - /* service connection information */ - struct ath10k_htc_svc_conn_req { -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ath/ath9k/ar9002_mac.c backports-3.18.1-1/drivers/net/wireless/ath/ath9k/ar9002_mac.c ---- backports-3.18.1-1.org/drivers/net/wireless/ath/ath9k/ar9002_mac.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ath/ath9k/ar9002_mac.c 2014-12-28 14:10:09.560888936 +0100 -@@ -220,8 +220,8 @@ - ads->ds_txstatus6 = ads->ds_txstatus7 = 0; - ads->ds_txstatus8 = ads->ds_txstatus9 = 0; - -- ACCESS_ONCE(ads->ds_link) = i->link; -- ACCESS_ONCE(ads->ds_data) = i->buf_addr[0]; -+ ACCESS_ONCE_RW(ads->ds_link) = i->link; -+ ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0]; - - ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore); - ctl6 = SM(i->keytype, AR_EncrType); -@@ -235,26 +235,26 @@ - - if ((i->is_first || i->is_last) && - i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) { -- ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0) -+ ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0) - | set11nTries(i->rates, 1) - | set11nTries(i->rates, 2) - | set11nTries(i->rates, 3) - | (i->dur_update ? AR_DurUpdateEna : 0) - | SM(0, AR_BurstDur); - -- ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0) -+ ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0) - | set11nRate(i->rates, 1) - | set11nRate(i->rates, 2) - | set11nRate(i->rates, 3); - } else { -- ACCESS_ONCE(ads->ds_ctl2) = 0; -- ACCESS_ONCE(ads->ds_ctl3) = 0; -+ ACCESS_ONCE_RW(ads->ds_ctl2) = 0; -+ ACCESS_ONCE_RW(ads->ds_ctl3) = 0; - } - - if (!i->is_first) { -- ACCESS_ONCE(ads->ds_ctl0) = 0; -- ACCESS_ONCE(ads->ds_ctl1) = ctl1; -- ACCESS_ONCE(ads->ds_ctl6) = ctl6; -+ ACCESS_ONCE_RW(ads->ds_ctl0) = 0; -+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1; -+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6; - return; - } - -@@ -279,7 +279,7 @@ - break; - } - -- ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen) -+ ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen) - | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0) - | SM(i->txpower, AR_XmitPower0) - | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0) -@@ -289,27 +289,27 @@ - | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable : - (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0)); - -- ACCESS_ONCE(ads->ds_ctl1) = ctl1; -- ACCESS_ONCE(ads->ds_ctl6) = ctl6; -+ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1; -+ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6; - - if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST) - return; - -- ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0) -+ ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0) - | set11nPktDurRTSCTS(i->rates, 1); - -- ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2) -+ ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2) - | set11nPktDurRTSCTS(i->rates, 3); - -- ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0) -+ ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0) - | set11nRateFlags(i->rates, 1) - | set11nRateFlags(i->rates, 2) - | set11nRateFlags(i->rates, 3) - | SM(i->rtscts_rate, AR_RTSCTSRate); - -- ACCESS_ONCE(ads->ds_ctl9) = SM(i->txpower, AR_XmitPower1); -- ACCESS_ONCE(ads->ds_ctl10) = SM(i->txpower, AR_XmitPower2); -- ACCESS_ONCE(ads->ds_ctl11) = SM(i->txpower, AR_XmitPower3); -+ ACCESS_ONCE_RW(ads->ds_ctl9) = SM(i->txpower, AR_XmitPower1); -+ ACCESS_ONCE_RW(ads->ds_ctl10) = SM(i->txpower, AR_XmitPower2); -+ ACCESS_ONCE_RW(ads->ds_ctl11) = SM(i->txpower, AR_XmitPower3); - } - - static int ar9002_hw_proc_txdesc(struct ath_hw *ah, void *ds, -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ath/ath9k/ar9003_mac.c backports-3.18.1-1/drivers/net/wireless/ath/ath9k/ar9003_mac.c ---- backports-3.18.1-1.org/drivers/net/wireless/ath/ath9k/ar9003_mac.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ath/ath9k/ar9003_mac.c 2014-12-28 14:10:09.560888936 +0100 -@@ -39,47 +39,47 @@ - (i->qcu << AR_TxQcuNum_S) | desc_len; - - checksum += val; -- ACCESS_ONCE(ads->info) = val; -+ ACCESS_ONCE_RW(ads->info) = val; - - checksum += i->link; -- ACCESS_ONCE(ads->link) = i->link; -+ ACCESS_ONCE_RW(ads->link) = i->link; - - checksum += i->buf_addr[0]; -- ACCESS_ONCE(ads->data0) = i->buf_addr[0]; -+ ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0]; - checksum += i->buf_addr[1]; -- ACCESS_ONCE(ads->data1) = i->buf_addr[1]; -+ ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1]; - checksum += i->buf_addr[2]; -- ACCESS_ONCE(ads->data2) = i->buf_addr[2]; -+ ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2]; - checksum += i->buf_addr[3]; -- ACCESS_ONCE(ads->data3) = i->buf_addr[3]; -+ ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3]; - - checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen); -- ACCESS_ONCE(ads->ctl3) = val; -+ ACCESS_ONCE_RW(ads->ctl3) = val; - checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen); -- ACCESS_ONCE(ads->ctl5) = val; -+ ACCESS_ONCE_RW(ads->ctl5) = val; - checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen); -- ACCESS_ONCE(ads->ctl7) = val; -+ ACCESS_ONCE_RW(ads->ctl7) = val; - checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen); -- ACCESS_ONCE(ads->ctl9) = val; -+ ACCESS_ONCE_RW(ads->ctl9) = val; - - checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff); -- ACCESS_ONCE(ads->ctl10) = checksum; -+ ACCESS_ONCE_RW(ads->ctl10) = checksum; - - if (i->is_first || i->is_last) { -- ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0) -+ ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0) - | set11nTries(i->rates, 1) - | set11nTries(i->rates, 2) - | set11nTries(i->rates, 3) - | (i->dur_update ? AR_DurUpdateEna : 0) - | SM(0, AR_BurstDur); - -- ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0) -+ ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0) - | set11nRate(i->rates, 1) - | set11nRate(i->rates, 2) - | set11nRate(i->rates, 3); - } else { -- ACCESS_ONCE(ads->ctl13) = 0; -- ACCESS_ONCE(ads->ctl14) = 0; -+ ACCESS_ONCE_RW(ads->ctl13) = 0; -+ ACCESS_ONCE_RW(ads->ctl14) = 0; - } - - ads->ctl20 = 0; -@@ -89,17 +89,17 @@ - - ctl17 = SM(i->keytype, AR_EncrType); - if (!i->is_first) { -- ACCESS_ONCE(ads->ctl11) = 0; -- ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore; -- ACCESS_ONCE(ads->ctl15) = 0; -- ACCESS_ONCE(ads->ctl16) = 0; -- ACCESS_ONCE(ads->ctl17) = ctl17; -- ACCESS_ONCE(ads->ctl18) = 0; -- ACCESS_ONCE(ads->ctl19) = 0; -+ ACCESS_ONCE_RW(ads->ctl11) = 0; -+ ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore; -+ ACCESS_ONCE_RW(ads->ctl15) = 0; -+ ACCESS_ONCE_RW(ads->ctl16) = 0; -+ ACCESS_ONCE_RW(ads->ctl17) = ctl17; -+ ACCESS_ONCE_RW(ads->ctl18) = 0; -+ ACCESS_ONCE_RW(ads->ctl19) = 0; - return; - } - -- ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen) -+ ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen) - | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0) - | SM(i->txpower, AR_XmitPower0) - | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0) -@@ -135,26 +135,26 @@ - val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S; - ctl12 |= SM(val, AR_PAPRDChainMask); - -- ACCESS_ONCE(ads->ctl12) = ctl12; -- ACCESS_ONCE(ads->ctl17) = ctl17; -+ ACCESS_ONCE_RW(ads->ctl12) = ctl12; -+ ACCESS_ONCE_RW(ads->ctl17) = ctl17; - -- ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0) -+ ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0) - | set11nPktDurRTSCTS(i->rates, 1); - -- ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2) -+ ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2) - | set11nPktDurRTSCTS(i->rates, 3); - -- ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0) -+ ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0) - | set11nRateFlags(i->rates, 1) - | set11nRateFlags(i->rates, 2) - | set11nRateFlags(i->rates, 3) - | SM(i->rtscts_rate, AR_RTSCTSRate); - -- ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding; -+ ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding; - -- ACCESS_ONCE(ads->ctl20) = SM(i->txpower, AR_XmitPower1); -- ACCESS_ONCE(ads->ctl21) = SM(i->txpower, AR_XmitPower2); -- ACCESS_ONCE(ads->ctl22) = SM(i->txpower, AR_XmitPower3); -+ ACCESS_ONCE_RW(ads->ctl20) = SM(i->txpower, AR_XmitPower1); -+ ACCESS_ONCE_RW(ads->ctl21) = SM(i->txpower, AR_XmitPower2); -+ ACCESS_ONCE_RW(ads->ctl22) = SM(i->txpower, AR_XmitPower3); - } - - static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads) -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ath/ath9k/hw.h backports-3.18.1-1/drivers/net/wireless/ath/ath9k/hw.h ---- backports-3.18.1-1.org/drivers/net/wireless/ath/ath9k/hw.h 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ath/ath9k/hw.h 2014-12-28 14:10:09.564888946 +0100 -@@ -630,7 +630,7 @@ - - /* ANI */ - void (*ani_cache_ini_regs)(struct ath_hw *ah); --}; -+} __no_const; - - /** - * struct ath_spec_scan - parameters for Atheros spectral scan -@@ -708,7 +708,7 @@ - #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT - void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable); - #endif --}; -+} __no_const; - - struct ath_nf_limits { - s16 max; -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ath/ath9k/main.c backports-3.18.1-1/drivers/net/wireless/ath/ath9k/main.c ---- backports-3.18.1-1.org/drivers/net/wireless/ath/ath9k/main.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ath/ath9k/main.c 2014-12-28 14:24:49.169250593 +0100 -@@ -2454,16 +2454,18 @@ - if (!ath9k_is_chanctx_enabled()) - return; - -- ath9k_ops.hw_scan = ath9k_hw_scan; -- ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan; -- ath9k_ops.remain_on_channel = ath9k_remain_on_channel; -- ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel; -- ath9k_ops.add_chanctx = ath9k_add_chanctx; -- ath9k_ops.remove_chanctx = ath9k_remove_chanctx; -- ath9k_ops.change_chanctx = ath9k_change_chanctx; -- ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx; -- ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx; -- ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx; -+ pax_open_kernel(); -+ *(void **)&ath9k_ops.hw_scan = ath9k_hw_scan; -+ *(void **)&ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan; -+ *(void **)&ath9k_ops.remain_on_channel = ath9k_remain_on_channel; -+ *(void **)&ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel; -+ *(void **)&ath9k_ops.add_chanctx = ath9k_add_chanctx; -+ *(void **)&ath9k_ops.remove_chanctx = ath9k_remove_chanctx; -+ *(void **)&ath9k_ops.change_chanctx = ath9k_change_chanctx; -+ *(void **)&ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx; -+ *(void **)&ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx; -+ *(void **)&ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx; -+ pax_close_kernel(); - } - - #endif -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/b43/phy_lp.c backports-3.18.1-1/drivers/net/wireless/b43/phy_lp.c ---- backports-3.18.1-1.org/drivers/net/wireless/b43/phy_lp.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/b43/phy_lp.c 2014-12-28 14:10:09.564888946 +0100 -@@ -2502,7 +2502,7 @@ - { - struct ssb_bus *bus = dev->dev->sdev->bus; - -- static const struct b206x_channel *chandata = NULL; -+ const struct b206x_channel *chandata = NULL; - u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000; - u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count; - u16 old_comm15, scale; -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/iwlegacy/3945-mac.c backports-3.18.1-1/drivers/net/wireless/iwlegacy/3945-mac.c ---- backports-3.18.1-1.org/drivers/net/wireless/iwlegacy/3945-mac.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/iwlegacy/3945-mac.c 2014-12-28 14:10:09.564888946 +0100 -@@ -3633,7 +3633,9 @@ - */ - if (il3945_mod_params.disable_hw_scan) { - D_INFO("Disabling hw_scan\n"); -- il3945_mac_ops.hw_scan = NULL; -+ pax_open_kernel(); -+ *(void **)&il3945_mac_ops.hw_scan = NULL; -+ pax_close_kernel(); - } - - D_INFO("*** LOAD DRIVER ***\n"); -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/iwlwifi/dvm/debugfs.c backports-3.18.1-1/drivers/net/wireless/iwlwifi/dvm/debugfs.c ---- backports-3.18.1-1.org/drivers/net/wireless/iwlwifi/dvm/debugfs.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/iwlwifi/dvm/debugfs.c 2014-12-28 14:10:09.564888946 +0100 -@@ -188,7 +188,7 @@ - { - struct iwl_priv *priv = file->private_data; - char buf[64]; -- int buf_size; -+ size_t buf_size; - u32 offset, len; - - memset(buf, 0, sizeof(buf)); -@@ -458,7 +458,7 @@ - struct iwl_priv *priv = file->private_data; - - char buf[8]; -- int buf_size; -+ size_t buf_size; - u32 reset_flag; - - memset(buf, 0, sizeof(buf)); -@@ -539,7 +539,7 @@ - { - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int ht40; - - memset(buf, 0, sizeof(buf)); -@@ -591,7 +591,7 @@ - { - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int value; - - memset(buf, 0, sizeof(buf)); -@@ -683,10 +683,10 @@ - DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); - DEBUGFS_READ_FILE_OPS(current_sleep_command); - --static const char *fmt_value = " %-30s %10u\n"; --static const char *fmt_hex = " %-30s 0x%02X\n"; --static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; --static const char *fmt_header = -+static const char fmt_value[] = " %-30s %10u\n"; -+static const char fmt_hex[] = " %-30s 0x%02X\n"; -+static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n"; -+static const char fmt_header[] = - "%-32s current cumulative delta max\n"; - - static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) -@@ -1856,7 +1856,7 @@ - { - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int clear; - - memset(buf, 0, sizeof(buf)); -@@ -1901,7 +1901,7 @@ - { - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int trace; - - memset(buf, 0, sizeof(buf)); -@@ -1972,7 +1972,7 @@ - { - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int missed; - - memset(buf, 0, sizeof(buf)); -@@ -2013,7 +2013,7 @@ - - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int plcp; - - memset(buf, 0, sizeof(buf)); -@@ -2073,7 +2073,7 @@ - - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int flush; - - memset(buf, 0, sizeof(buf)); -@@ -2163,7 +2163,7 @@ - - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int rts; - - if (!priv->cfg->ht_params) -@@ -2204,7 +2204,7 @@ - { - struct iwl_priv *priv = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); -@@ -2238,7 +2238,7 @@ - struct iwl_priv *priv = file->private_data; - u32 event_log_flag; - char buf[8]; -- int buf_size; -+ size_t buf_size; - - /* check that the interface is up */ - if (!iwl_is_ready(priv)) -@@ -2292,7 +2292,7 @@ - struct iwl_priv *priv = file->private_data; - char buf[8]; - u32 calib_disabled; -- int buf_size; -+ size_t buf_size; - - memset(buf, 0, sizeof(buf)); - buf_size = min(count, sizeof(buf) - 1); -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/iwlwifi/pcie/trans.c backports-3.18.1-1/drivers/net/wireless/iwlwifi/pcie/trans.c ---- backports-3.18.1-1.org/drivers/net/wireless/iwlwifi/pcie/trans.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/iwlwifi/pcie/trans.c 2014-12-28 14:10:09.564888946 +0100 -@@ -1689,7 +1689,7 @@ - struct isr_statistics *isr_stats = &trans_pcie->isr_stats; - - char buf[8]; -- int buf_size; -+ size_t buf_size; - u32 reset_flag; - - memset(buf, 0, sizeof(buf)); -@@ -1710,7 +1710,7 @@ - { - struct iwl_trans *trans = file->private_data; - char buf[8]; -- int buf_size; -+ size_t buf_size; - int csr; - - memset(buf, 0, sizeof(buf)); -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/mac80211_hwsim.c backports-3.18.1-1/drivers/net/wireless/mac80211_hwsim.c ---- backports-3.18.1-1.org/drivers/net/wireless/mac80211_hwsim.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/mac80211_hwsim.c 2014-12-28 14:10:09.568888967 +0100 -@@ -2578,20 +2578,20 @@ - if (channels < 1) - return -EINVAL; - -- mac80211_hwsim_mchan_ops = mac80211_hwsim_ops; -- mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan; -- mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan; -- mac80211_hwsim_mchan_ops.sw_scan_start = NULL; -- mac80211_hwsim_mchan_ops.sw_scan_complete = NULL; -- mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc; -- mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc; -- mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx; -- mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx; -- mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx; -- mac80211_hwsim_mchan_ops.assign_vif_chanctx = -- mac80211_hwsim_assign_vif_chanctx; -- mac80211_hwsim_mchan_ops.unassign_vif_chanctx = -- mac80211_hwsim_unassign_vif_chanctx; -+ pax_open_kernel(); -+ memcpy((void *)&mac80211_hwsim_mchan_ops, &mac80211_hwsim_ops, sizeof mac80211_hwsim_mchan_ops); -+ *(void **)&mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan; -+ *(void **)&mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan; -+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_start = NULL; -+ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_complete = NULL; -+ *(void **)&mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc; -+ *(void **)&mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc; -+ *(void **)&mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx; -+ *(void **)&mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx; -+ *(void **)&mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx; -+ *(void **)&mac80211_hwsim_mchan_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx; -+ *(void **)&mac80211_hwsim_mchan_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx; -+ pax_close_kernel(); - - spin_lock_init(&hwsim_radio_lock); - INIT_LIST_HEAD(&hwsim_radios); -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/rndis_wlan.c backports-3.18.1-1/drivers/net/wireless/rndis_wlan.c ---- backports-3.18.1-1.org/drivers/net/wireless/rndis_wlan.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/rndis_wlan.c 2014-12-28 14:10:09.568888967 +0100 -@@ -1236,7 +1236,7 @@ - - netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold); - -- if (rts_threshold < 0 || rts_threshold > 2347) -+ if (rts_threshold > 2347) - rts_threshold = 2347; - - tmp = cpu_to_le32(rts_threshold); -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/rt2x00/rt2x00.h backports-3.18.1-1/drivers/net/wireless/rt2x00/rt2x00.h ---- backports-3.18.1-1.org/drivers/net/wireless/rt2x00/rt2x00.h 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/rt2x00/rt2x00.h 2014-12-28 14:10:09.568888967 +0100 -@@ -375,7 +375,7 @@ - * for hardware which doesn't support hardware - * sequence counting. - */ -- atomic_t seqno; -+ atomic_unchecked_t seqno; - }; - - static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif) -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/rt2x00/rt2x00queue.c backports-3.18.1-1/drivers/net/wireless/rt2x00/rt2x00queue.c ---- backports-3.18.1-1.org/drivers/net/wireless/rt2x00/rt2x00queue.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/rt2x00/rt2x00queue.c 2014-12-28 14:10:09.568888967 +0100 -@@ -224,9 +224,9 @@ - * sequence counter given by mac80211. - */ - if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)) -- seqno = atomic_add_return(0x10, &intf->seqno); -+ seqno = atomic_add_return_unchecked(0x10, &intf->seqno); - else -- seqno = atomic_read(&intf->seqno); -+ seqno = atomic_read_unchecked(&intf->seqno); - - hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); - hdr->seq_ctrl |= cpu_to_le16(seqno); -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ti/wl1251/sdio.c backports-3.18.1-1/drivers/net/wireless/ti/wl1251/sdio.c ---- backports-3.18.1-1.org/drivers/net/wireless/ti/wl1251/sdio.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ti/wl1251/sdio.c 2014-12-28 14:10:09.568888967 +0100 -@@ -282,13 +282,17 @@ - - irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); - -- wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq; -- wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq; -+ pax_open_kernel(); -+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq; -+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq; -+ pax_close_kernel(); - - wl1251_info("using dedicated interrupt line"); - } else { -- wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq; -- wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq; -+ pax_open_kernel(); -+ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq; -+ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq; -+ pax_close_kernel(); - - wl1251_info("using SDIO interrupt"); - } -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ti/wl12xx/main.c backports-3.18.1-1/drivers/net/wireless/ti/wl12xx/main.c ---- backports-3.18.1-1.org/drivers/net/wireless/ti/wl12xx/main.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ti/wl12xx/main.c 2014-12-28 14:10:09.568888967 +0100 -@@ -656,7 +656,9 @@ - sizeof(wl->conf.mem)); - - /* read data preparation is only needed by wl127x */ -- wl->ops->prepare_read = wl127x_prepare_read; -+ pax_open_kernel(); -+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read; -+ pax_close_kernel(); - - wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, - WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER, -@@ -681,7 +683,9 @@ - sizeof(wl->conf.mem)); - - /* read data preparation is only needed by wl127x */ -- wl->ops->prepare_read = wl127x_prepare_read; -+ pax_open_kernel(); -+ *(void **)&wl->ops->prepare_read = wl127x_prepare_read; -+ pax_close_kernel(); - - wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, - WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER, -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/ti/wl18xx/main.c backports-3.18.1-1/drivers/net/wireless/ti/wl18xx/main.c ---- backports-3.18.1-1.org/drivers/net/wireless/ti/wl18xx/main.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/ti/wl18xx/main.c 2014-12-28 14:10:09.568888967 +0100 -@@ -1916,8 +1916,10 @@ - } - - if (!checksum_param) { -- wl18xx_ops.set_rx_csum = NULL; -- wl18xx_ops.init_vif = NULL; -+ pax_open_kernel(); -+ *(void **)&wl18xx_ops.set_rx_csum = NULL; -+ *(void **)&wl18xx_ops.init_vif = NULL; -+ pax_close_kernel(); - } - - /* Enable 11a Band only if we have 5G antennas */ -diff -Naur backports-3.18.1-1.org/drivers/net/wireless/zd1211rw/zd_usb.c backports-3.18.1-1/drivers/net/wireless/zd1211rw/zd_usb.c ---- backports-3.18.1-1.org/drivers/net/wireless/zd1211rw/zd_usb.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/net/wireless/zd1211rw/zd_usb.c 2014-12-28 14:10:09.568888967 +0100 -@@ -385,7 +385,7 @@ - { - struct zd_usb *usb = urb->context; - struct zd_usb_interrupt *intr = &usb->intr; -- int len; -+ unsigned int len; - u16 int_num; - - ZD_ASSERT(in_interrupt()); -diff -Naur backports-3.18.1-1.org/drivers/nfc/nfcwilink.c backports-3.18.1-1/drivers/nfc/nfcwilink.c ---- backports-3.18.1-1.org/drivers/nfc/nfcwilink.c 2014-12-21 22:37:14.000000000 +0100 -+++ backports-3.18.1-1/drivers/nfc/nfcwilink.c 2014-12-28 14:10:09.568888967 +0100 -@@ -497,7 +497,7 @@ - - static int nfcwilink_probe(struct platform_device *pdev) - { -- static struct nfcwilink *drv; -+ struct nfcwilink *drv; - int rc; - __u32 protocols; - -diff -Naur backports-3.18.1-1.org/include/linux/gracl_compat.h backports-3.18.1-1/include/linux/gracl_compat.h ---- backports-3.18.1-1.org/include/linux/gracl_compat.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/linux/gracl_compat.h 2014-12-28 14:10:09.684889542 +0100 -@@ -0,0 +1,156 @@ -+#ifndef GR_ACL_COMPAT_H -+#define GR_ACL_COMPAT_H -+ -+#include <linux/resource.h> -+#include <asm/resource.h> -+ -+struct sprole_pw_compat { -+ compat_uptr_t rolename; -+ unsigned char salt[GR_SALT_LEN]; -+ unsigned char sum[GR_SHA_LEN]; -+}; -+ -+struct gr_hash_struct_compat { -+ compat_uptr_t table; -+ compat_uptr_t nametable; -+ compat_uptr_t first; -+ __u32 table_size; -+ __u32 used_size; -+ int type; -+}; -+ -+struct acl_subject_label_compat { -+ compat_uptr_t filename; -+ compat_ino_t inode; -+ __u32 device; -+ __u32 mode; -+ kernel_cap_t cap_mask; -+ kernel_cap_t cap_lower; -+ kernel_cap_t cap_invert_audit; -+ -+ struct compat_rlimit res[GR_NLIMITS]; -+ __u32 resmask; -+ -+ __u8 user_trans_type; -+ __u8 group_trans_type; -+ compat_uptr_t user_transitions; -+ compat_uptr_t group_transitions; -+ __u16 user_trans_num; -+ __u16 group_trans_num; -+ -+ __u32 sock_families[2]; -+ __u32 ip_proto[8]; -+ __u32 ip_type; -+ compat_uptr_t ips; -+ __u32 ip_num; -+ __u32 inaddr_any_override; -+ -+ __u32 crashes; -+ compat_ulong_t expires; -+ -+ compat_uptr_t parent_subject; -+ compat_uptr_t hash; -+ compat_uptr_t prev; -+ compat_uptr_t next; -+ -+ compat_uptr_t obj_hash; -+ __u32 obj_hash_size; -+ __u16 pax_flags; -+}; -+ -+struct role_allowed_ip_compat { -+ __u32 addr; -+ __u32 netmask; -+ -+ compat_uptr_t prev; -+ compat_uptr_t next; -+}; -+ -+struct role_transition_compat { -+ compat_uptr_t rolename; -+ -+ compat_uptr_t prev; -+ compat_uptr_t next; -+}; -+ -+struct acl_role_label_compat { -+ compat_uptr_t rolename; -+ uid_t uidgid; -+ __u16 roletype; -+ -+ __u16 auth_attempts; -+ compat_ulong_t expires; -+ -+ compat_uptr_t root_label; -+ compat_uptr_t hash; -+ -+ compat_uptr_t prev; -+ compat_uptr_t next; -+ -+ compat_uptr_t transitions; -+ compat_uptr_t allowed_ips; -+ compat_uptr_t domain_children; -+ __u16 domain_child_num; -+ -+ umode_t umask; -+ -+ compat_uptr_t subj_hash; -+ __u32 subj_hash_size; -+}; -+ -+struct user_acl_role_db_compat { -+ compat_uptr_t r_table; -+ __u32 num_pointers; -+ __u32 num_roles; -+ __u32 num_domain_children; -+ __u32 num_subjects; -+ __u32 num_objects; -+}; -+ -+struct acl_object_label_compat { -+ compat_uptr_t filename; -+ compat_ino_t inode; -+ __u32 device; -+ __u32 mode; -+ -+ compat_uptr_t nested; -+ compat_uptr_t globbed; -+ -+ compat_uptr_t prev; -+ compat_uptr_t next; -+}; -+ -+struct acl_ip_label_compat { -+ compat_uptr_t iface; -+ __u32 addr; -+ __u32 netmask; -+ __u16 low, high; -+ __u8 mode; -+ __u32 type; -+ __u32 proto[8]; -+ -+ compat_uptr_t prev; -+ compat_uptr_t next; -+}; -+ -+struct gr_arg_compat { -+ struct user_acl_role_db_compat role_db; -+ unsigned char pw[GR_PW_LEN]; -+ unsigned char salt[GR_SALT_LEN]; -+ unsigned char sum[GR_SHA_LEN]; -+ unsigned char sp_role[GR_SPROLE_LEN]; -+ compat_uptr_t sprole_pws; -+ __u32 segv_device; -+ compat_ino_t segv_inode; -+ uid_t segv_uid; -+ __u16 num_sprole_pws; -+ __u16 mode; -+}; -+ -+struct gr_arg_wrapper_compat { -+ compat_uptr_t arg; -+ __u32 version; -+ __u32 size; -+}; -+ -+#endif -diff -Naur backports-3.18.1-1.org/include/linux/gracl.h backports-3.18.1-1/include/linux/gracl.h ---- backports-3.18.1-1.org/include/linux/gracl.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/linux/gracl.h 2014-12-28 14:10:09.684889542 +0100 -@@ -0,0 +1,340 @@ -+#ifndef GR_ACL_H -+#define GR_ACL_H -+ -+#include <linux/grdefs.h> -+#include <linux/resource.h> -+#include <linux/capability.h> -+#include <linux/dcache.h> -+#include <asm/resource.h> -+ -+/* Major status information */ -+ -+#define GR_VERSION "grsecurity 3.0" -+#define GRSECURITY_VERSION 0x3000 -+ -+enum { -+ GR_SHUTDOWN = 0, -+ GR_ENABLE = 1, -+ GR_SPROLE = 2, -+ GR_OLDRELOAD = 3, -+ GR_SEGVMOD = 4, -+ GR_STATUS = 5, -+ GR_UNSPROLE = 6, -+ GR_PASSSET = 7, -+ GR_SPROLEPAM = 8, -+ GR_RELOAD = 9, -+}; -+ -+/* Password setup definitions -+ * kernel/grhash.c */ -+enum { -+ GR_PW_LEN = 128, -+ GR_SALT_LEN = 16, -+ GR_SHA_LEN = 32, -+}; -+ -+enum { -+ GR_SPROLE_LEN = 64, -+}; -+ -+enum { -+ GR_NO_GLOB = 0, -+ GR_REG_GLOB, -+ GR_CREATE_GLOB -+}; -+ -+#define GR_NLIMITS 32 -+ -+/* Begin Data Structures */ -+ -+struct sprole_pw { -+ unsigned char *rolename; -+ unsigned char salt[GR_SALT_LEN]; -+ unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */ -+}; -+ -+struct name_entry { -+ __u32 key; -+ ino_t inode; -+ dev_t device; -+ char *name; -+ __u16 len; -+ __u8 deleted; -+ struct name_entry *prev; -+ struct name_entry *next; -+}; -+ -+struct inodev_entry { -+ struct name_entry *nentry; -+ struct inodev_entry *prev; -+ struct inodev_entry *next; -+}; -+ -+struct acl_role_db { -+ struct acl_role_label **r_hash; -+ __u32 r_size; -+}; -+ -+struct inodev_db { -+ struct inodev_entry **i_hash; -+ __u32 i_size; -+}; -+ -+struct name_db { -+ struct name_entry **n_hash; -+ __u32 n_size; -+}; -+ -+struct crash_uid { -+ uid_t uid; -+ unsigned long expires; -+}; -+ -+struct gr_hash_struct { -+ void **table; -+ void **nametable; -+ void *first; -+ __u32 table_size; -+ __u32 used_size; -+ int type; -+}; -+ -+/* Userspace Grsecurity ACL data structures */ -+ -+struct acl_subject_label { -+ char *filename; -+ ino_t inode; -+ dev_t device; -+ __u32 mode; -+ kernel_cap_t cap_mask; -+ kernel_cap_t cap_lower; -+ kernel_cap_t cap_invert_audit; -+ -+ struct rlimit res[GR_NLIMITS]; -+ __u32 resmask; -+ -+ __u8 user_trans_type; -+ __u8 group_trans_type; -+ uid_t *user_transitions; -+ gid_t *group_transitions; -+ __u16 user_trans_num; -+ __u16 group_trans_num; -+ -+ __u32 sock_families[2]; -+ __u32 ip_proto[8]; -+ __u32 ip_type; -+ struct acl_ip_label **ips; -+ __u32 ip_num; -+ __u32 inaddr_any_override; -+ -+ __u32 crashes; -+ unsigned long expires; -+ -+ struct acl_subject_label *parent_subject; -+ struct gr_hash_struct *hash; -+ struct acl_subject_label *prev; -+ struct acl_subject_label *next; -+ -+ struct acl_object_label **obj_hash; -+ __u32 obj_hash_size; -+ __u16 pax_flags; -+}; -+ -+struct role_allowed_ip { -+ __u32 addr; -+ __u32 netmask; -+ -+ struct role_allowed_ip *prev; -+ struct role_allowed_ip *next; -+}; -+ -+struct role_transition { -+ char *rolename; -+ -+ struct role_transition *prev; -+ struct role_transition *next; -+}; -+ -+struct acl_role_label { -+ char *rolename; -+ uid_t uidgid; -+ __u16 roletype; -+ -+ __u16 auth_attempts; -+ unsigned long expires; -+ -+ struct acl_subject_label *root_label; -+ struct gr_hash_struct *hash; -+ -+ struct acl_role_label *prev; -+ struct acl_role_label *next; -+ -+ struct role_transition *transitions; -+ struct role_allowed_ip *allowed_ips; -+ uid_t *domain_children; -+ __u16 domain_child_num; -+ -+ umode_t umask; -+ -+ struct acl_subject_label **subj_hash; -+ __u32 subj_hash_size; -+}; -+ -+struct user_acl_role_db { -+ struct acl_role_label **r_table; -+ __u32 num_pointers; /* Number of allocations to track */ -+ __u32 num_roles; /* Number of roles */ -+ __u32 num_domain_children; /* Number of domain children */ -+ __u32 num_subjects; /* Number of subjects */ -+ __u32 num_objects; /* Number of objects */ -+}; -+ -+struct acl_object_label { -+ char *filename; -+ ino_t inode; -+ dev_t device; -+ __u32 mode; -+ -+ struct acl_subject_label *nested; -+ struct acl_object_label *globbed; -+ -+ /* next two structures not used */ -+ -+ struct acl_object_label *prev; -+ struct acl_object_label *next; -+}; -+ -+struct acl_ip_label { -+ char *iface; -+ __u32 addr; -+ __u32 netmask; -+ __u16 low, high; -+ __u8 mode; -+ __u32 type; -+ __u32 proto[8]; -+ -+ /* next two structures not used */ -+ -+ struct acl_ip_label *prev; -+ struct acl_ip_label *next; -+}; -+ -+struct gr_arg { -+ struct user_acl_role_db role_db; -+ unsigned char pw[GR_PW_LEN]; -+ unsigned char salt[GR_SALT_LEN]; -+ unsigned char sum[GR_SHA_LEN]; -+ unsigned char sp_role[GR_SPROLE_LEN]; -+ struct sprole_pw *sprole_pws; -+ dev_t segv_device; -+ ino_t segv_inode; -+ uid_t segv_uid; -+ __u16 num_sprole_pws; -+ __u16 mode; -+}; -+ -+struct gr_arg_wrapper { -+ struct gr_arg *arg; -+ __u32 version; -+ __u32 size; -+}; -+ -+struct subject_map { -+ struct acl_subject_label *user; -+ struct acl_subject_label *kernel; -+ struct subject_map *prev; -+ struct subject_map *next; -+}; -+ -+struct acl_subj_map_db { -+ struct subject_map **s_hash; -+ __u32 s_size; -+}; -+ -+struct gr_policy_state { -+ struct sprole_pw **acl_special_roles; -+ __u16 num_sprole_pws; -+ struct acl_role_label *kernel_role; -+ struct acl_role_label *role_list; -+ struct acl_role_label *default_role; -+ struct acl_role_db acl_role_set; -+ struct acl_subj_map_db subj_map_set; -+ struct name_db name_set; -+ struct inodev_db inodev_set; -+}; -+ -+struct gr_alloc_state { -+ unsigned long alloc_stack_next; -+ unsigned long alloc_stack_size; -+ void **alloc_stack; -+}; -+ -+struct gr_reload_state { -+ struct gr_policy_state oldpolicy; -+ struct gr_alloc_state oldalloc; -+ struct gr_policy_state newpolicy; -+ struct gr_alloc_state newalloc; -+ struct gr_policy_state *oldpolicy_ptr; -+ struct gr_alloc_state *oldalloc_ptr; -+ unsigned char oldmode; -+}; -+ -+/* End Data Structures Section */ -+ -+/* Hash functions generated by empirical testing by Brad Spengler -+ Makes good use of the low bits of the inode. Generally 0-1 times -+ in loop for successful match. 0-3 for unsuccessful match. -+ Shift/add algorithm with modulus of table size and an XOR*/ -+ -+static __inline__ unsigned int -+gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz) -+{ -+ return ((((uid + type) << (16 + type)) ^ uid) % sz); -+} -+ -+ static __inline__ unsigned int -+gr_shash(const struct acl_subject_label *userp, const unsigned int sz) -+{ -+ return ((const unsigned long)userp % sz); -+} -+ -+static __inline__ unsigned int -+gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz) -+{ -+ return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz); -+} -+ -+static __inline__ unsigned int -+gr_nhash(const char *name, const __u16 len, const unsigned int sz) -+{ -+ return full_name_hash((const unsigned char *)name, len) % sz; -+} -+ -+#define FOR_EACH_SUBJECT_START(role,subj,iter) \ -+ subj = NULL; \ -+ iter = 0; \ -+ while (iter < role->subj_hash_size) { \ -+ if (subj == NULL) \ -+ subj = role->subj_hash[iter]; \ -+ if (subj == NULL) { \ -+ iter++; \ -+ continue; \ -+ } -+ -+#define FOR_EACH_SUBJECT_END(subj,iter) \ -+ subj = subj->next; \ -+ if (subj == NULL) \ -+ iter++; \ -+ } -+ -+ -+#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \ -+ subj = role->hash->first; \ -+ while (subj != NULL) { -+ -+#define FOR_EACH_NESTED_SUBJECT_END(subj) \ -+ subj = subj->next; \ -+ } -+ -+#endif -+ -diff -Naur backports-3.18.1-1.org/include/linux/gralloc.h backports-3.18.1-1/include/linux/gralloc.h ---- backports-3.18.1-1.org/include/linux/gralloc.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/linux/gralloc.h 2014-12-28 14:10:09.684889542 +0100 -@@ -0,0 +1,9 @@ -+#ifndef __GRALLOC_H -+#define __GRALLOC_H -+ -+void acl_free_all(void); -+int acl_alloc_stack_init(unsigned long size); -+void *acl_alloc(unsigned long len); -+void *acl_alloc_num(unsigned long num, unsigned long len); -+ -+#endif -diff -Naur backports-3.18.1-1.org/include/linux/grdefs.h backports-3.18.1-1/include/linux/grdefs.h ---- backports-3.18.1-1.org/include/linux/grdefs.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/linux/grdefs.h 2014-12-28 14:10:09.688889562 +0100 -@@ -0,0 +1,140 @@ -+#ifndef GRDEFS_H -+#define GRDEFS_H -+ -+/* Begin grsecurity status declarations */ -+ -+enum { -+ GR_READY = 0x01, -+ GR_STATUS_INIT = 0x00 // disabled state -+}; -+ -+/* Begin ACL declarations */ -+ -+/* Role flags */ -+ -+enum { -+ GR_ROLE_USER = 0x0001, -+ GR_ROLE_GROUP = 0x0002, -+ GR_ROLE_DEFAULT = 0x0004, -+ GR_ROLE_SPECIAL = 0x0008, -+ GR_ROLE_AUTH = 0x0010, -+ GR_ROLE_NOPW = 0x0020, -+ GR_ROLE_GOD = 0x0040, -+ GR_ROLE_LEARN = 0x0080, -+ GR_ROLE_TPE = 0x0100, -+ GR_ROLE_DOMAIN = 0x0200, -+ GR_ROLE_PAM = 0x0400, -+ GR_ROLE_PERSIST = 0x0800 -+}; -+ -+/* ACL Subject and Object mode flags */ -+enum { -+ GR_DELETED = 0x80000000 -+}; -+ -+/* ACL Object-only mode flags */ -+enum { -+ GR_READ = 0x00000001, -+ GR_APPEND = 0x00000002, -+ GR_WRITE = 0x00000004, -+ GR_EXEC = 0x00000008, -+ GR_FIND = 0x00000010, -+ GR_INHERIT = 0x00000020, -+ GR_SETID = 0x00000040, -+ GR_CREATE = 0x00000080, -+ GR_DELETE = 0x00000100, -+ GR_LINK = 0x00000200, -+ GR_AUDIT_READ = 0x00000400, -+ GR_AUDIT_APPEND = 0x00000800, -+ GR_AUDIT_WRITE = 0x00001000, -+ GR_AUDIT_EXEC = 0x00002000, -+ GR_AUDIT_FIND = 0x00004000, -+ GR_AUDIT_INHERIT= 0x00008000, -+ GR_AUDIT_SETID = 0x00010000, -+ GR_AUDIT_CREATE = 0x00020000, -+ GR_AUDIT_DELETE = 0x00040000, -+ GR_AUDIT_LINK = 0x00080000, -+ GR_PTRACERD = 0x00100000, -+ GR_NOPTRACE = 0x00200000, -+ GR_SUPPRESS = 0x00400000, -+ GR_NOLEARN = 0x00800000, -+ GR_INIT_TRANSFER= 0x01000000 -+}; -+ -+#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \ -+ GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \ -+ GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK) -+ -+/* ACL subject-only mode flags */ -+enum { -+ GR_KILL = 0x00000001, -+ GR_VIEW = 0x00000002, -+ GR_PROTECTED = 0x00000004, -+ GR_LEARN = 0x00000008, -+ GR_OVERRIDE = 0x00000010, -+ /* just a placeholder, this mode is only used in userspace */ -+ GR_DUMMY = 0x00000020, -+ GR_PROTSHM = 0x00000040, -+ GR_KILLPROC = 0x00000080, -+ GR_KILLIPPROC = 0x00000100, -+ /* just a placeholder, this mode is only used in userspace */ -+ GR_NOTROJAN = 0x00000200, -+ GR_PROTPROCFD = 0x00000400, -+ GR_PROCACCT = 0x00000800, -+ GR_RELAXPTRACE = 0x00001000, -+ //GR_NESTED = 0x00002000, -+ GR_INHERITLEARN = 0x00004000, -+ GR_PROCFIND = 0x00008000, -+ GR_POVERRIDE = 0x00010000, -+ GR_KERNELAUTH = 0x00020000, -+ GR_ATSECURE = 0x00040000, -+ GR_SHMEXEC = 0x00080000 -+}; -+ -+enum { -+ GR_PAX_ENABLE_SEGMEXEC = 0x0001, -+ GR_PAX_ENABLE_PAGEEXEC = 0x0002, -+ GR_PAX_ENABLE_MPROTECT = 0x0004, -+ GR_PAX_ENABLE_RANDMMAP = 0x0008, -+ GR_PAX_ENABLE_EMUTRAMP = 0x0010, -+ GR_PAX_DISABLE_SEGMEXEC = 0x0100, -+ GR_PAX_DISABLE_PAGEEXEC = 0x0200, -+ GR_PAX_DISABLE_MPROTECT = 0x0400, -+ GR_PAX_DISABLE_RANDMMAP = 0x0800, -+ GR_PAX_DISABLE_EMUTRAMP = 0x1000, -+}; -+ -+enum { -+ GR_ID_USER = 0x01, -+ GR_ID_GROUP = 0x02, -+}; -+ -+enum { -+ GR_ID_ALLOW = 0x01, -+ GR_ID_DENY = 0x02, -+}; -+ -+#define GR_CRASH_RES 31 -+#define GR_UIDTABLE_MAX 500 -+ -+/* begin resource learning section */ -+enum { -+ GR_RLIM_CPU_BUMP = 60, -+ GR_RLIM_FSIZE_BUMP = 50000, -+ GR_RLIM_DATA_BUMP = 10000, -+ GR_RLIM_STACK_BUMP = 1000, -+ GR_RLIM_CORE_BUMP = 10000, -+ GR_RLIM_RSS_BUMP = 500000, -+ GR_RLIM_NPROC_BUMP = 1, -+ GR_RLIM_NOFILE_BUMP = 5, -+ GR_RLIM_MEMLOCK_BUMP = 50000, -+ GR_RLIM_AS_BUMP = 500000, -+ GR_RLIM_LOCKS_BUMP = 2, -+ GR_RLIM_SIGPENDING_BUMP = 5, -+ GR_RLIM_MSGQUEUE_BUMP = 10000, -+ GR_RLIM_NICE_BUMP = 1, -+ GR_RLIM_RTPRIO_BUMP = 1, -+ GR_RLIM_RTTIME_BUMP = 1000000 -+}; -+ -+#endif -diff -Naur backports-3.18.1-1.org/include/linux/grinternal.h backports-3.18.1-1/include/linux/grinternal.h ---- backports-3.18.1-1.org/include/linux/grinternal.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/linux/grinternal.h 2014-12-28 14:10:09.688889562 +0100 -@@ -0,0 +1,229 @@ -+#ifndef __GRINTERNAL_H -+#define __GRINTERNAL_H -+ -+#ifdef CONFIG_GRKERNSEC -+ -+#include <linux/fs.h> -+#include <linux/mnt_namespace.h> -+#include <linux/nsproxy.h> -+#include <linux/gracl.h> -+#include <linux/grdefs.h> -+#include <linux/grmsg.h> -+ -+void gr_add_learn_entry(const char *fmt, ...) -+ __attribute__ ((format (printf, 1, 2))); -+__u32 gr_search_file(const struct dentry *dentry, const __u32 mode, -+ const struct vfsmount *mnt); -+__u32 gr_check_create(const struct dentry *new_dentry, -+ const struct dentry *parent, -+ const struct vfsmount *mnt, const __u32 mode); -+int gr_check_protected_task(const struct task_struct *task); -+__u32 to_gr_audit(const __u32 reqmode); -+int gr_set_acls(const int type); -+int gr_acl_is_enabled(void); -+char gr_roletype_to_char(void); -+ -+void gr_handle_alertkill(struct task_struct *task); -+char *gr_to_filename(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+char *gr_to_filename1(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+char *gr_to_filename2(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+char *gr_to_filename3(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+ -+extern int grsec_enable_ptrace_readexec; -+extern int grsec_enable_harden_ptrace; -+extern int grsec_enable_link; -+extern int grsec_enable_fifo; -+extern int grsec_enable_execve; -+extern int grsec_enable_shm; -+extern int grsec_enable_execlog; -+extern int grsec_enable_signal; -+extern int grsec_enable_audit_ptrace; -+extern int grsec_enable_forkfail; -+extern int grsec_enable_time; -+extern int grsec_enable_rofs; -+extern int grsec_deny_new_usb; -+extern int grsec_enable_chroot_shmat; -+extern int grsec_enable_chroot_mount; -+extern int grsec_enable_chroot_double; -+extern int grsec_enable_chroot_pivot; -+extern int grsec_enable_chroot_chdir; -+extern int grsec_enable_chroot_chmod; -+extern int grsec_enable_chroot_mknod; -+extern int grsec_enable_chroot_fchdir; -+extern int grsec_enable_chroot_nice; -+extern int grsec_enable_chroot_execlog; -+extern int grsec_enable_chroot_caps; -+extern int grsec_enable_chroot_sysctl; -+extern int grsec_enable_chroot_unix; -+extern int grsec_enable_symlinkown; -+extern kgid_t grsec_symlinkown_gid; -+extern int grsec_enable_tpe; -+extern kgid_t grsec_tpe_gid; -+extern int grsec_enable_tpe_all; -+extern int grsec_enable_tpe_invert; -+extern int grsec_enable_socket_all; -+extern kgid_t grsec_socket_all_gid; -+extern int grsec_enable_socket_client; -+extern kgid_t grsec_socket_client_gid; -+extern int grsec_enable_socket_server; -+extern kgid_t grsec_socket_server_gid; -+extern kgid_t grsec_audit_gid; -+extern int grsec_enable_group; -+extern int grsec_enable_log_rwxmaps; -+extern int grsec_enable_mount; -+extern int grsec_enable_chdir; -+extern int grsec_resource_logging; -+extern int grsec_enable_blackhole; -+extern int grsec_lastack_retries; -+extern int grsec_enable_brute; -+extern int grsec_enable_harden_ipc; -+extern int grsec_lock; -+ -+extern spinlock_t grsec_alert_lock; -+extern unsigned long grsec_alert_wtime; -+extern unsigned long grsec_alert_fyet; -+ -+extern spinlock_t grsec_audit_lock; -+ -+extern rwlock_t grsec_exec_file_lock; -+ -+#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \ -+ gr_to_filename2((tsk)->exec_file->f_path.dentry, \ -+ (tsk)->exec_file->f_path.mnt) : "/") -+ -+#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \ -+ gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \ -+ (tsk)->real_parent->exec_file->f_path.mnt) : "/") -+ -+#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \ -+ gr_to_filename((tsk)->exec_file->f_path.dentry, \ -+ (tsk)->exec_file->f_path.mnt) : "/") -+ -+#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \ -+ gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \ -+ (tsk)->real_parent->exec_file->f_path.mnt) : "/") -+ -+#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted) -+ -+#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry) -+ -+static inline bool gr_is_same_file(const struct file *file1, const struct file *file2) -+{ -+ if (file1 && file2) { -+ const struct inode *inode1 = file1->f_path.dentry->d_inode; -+ const struct inode *inode2 = file2->f_path.dentry->d_inode; -+ if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev) -+ return true; -+ } -+ -+ return false; -+} -+ -+#define GR_CHROOT_CAPS {{ \ -+ CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \ -+ CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \ -+ CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \ -+ CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \ -+ CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \ -+ CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \ -+ CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }} -+ -+#define security_learn(normal_msg,args...) \ -+({ \ -+ read_lock(&grsec_exec_file_lock); \ -+ gr_add_learn_entry(normal_msg "\n", ## args); \ -+ read_unlock(&grsec_exec_file_lock); \ -+}) -+ -+enum { -+ GR_DO_AUDIT, -+ GR_DONT_AUDIT, -+ /* used for non-audit messages that we shouldn't kill the task on */ -+ GR_DONT_AUDIT_GOOD -+}; -+ -+enum { -+ GR_TTYSNIFF, -+ GR_RBAC, -+ GR_RBAC_STR, -+ GR_STR_RBAC, -+ GR_RBAC_MODE2, -+ GR_RBAC_MODE3, -+ GR_FILENAME, -+ GR_SYSCTL_HIDDEN, -+ GR_NOARGS, -+ GR_ONE_INT, -+ GR_ONE_INT_TWO_STR, -+ GR_ONE_STR, -+ GR_STR_INT, -+ GR_TWO_STR_INT, -+ GR_TWO_INT, -+ GR_TWO_U64, -+ GR_THREE_INT, -+ GR_FIVE_INT_TWO_STR, -+ GR_TWO_STR, -+ GR_THREE_STR, -+ GR_FOUR_STR, -+ GR_STR_FILENAME, -+ GR_FILENAME_STR, -+ GR_FILENAME_TWO_INT, -+ GR_FILENAME_TWO_INT_STR, -+ GR_TEXTREL, -+ GR_PTRACE, -+ GR_RESOURCE, -+ GR_CAP, -+ GR_SIG, -+ GR_SIG2, -+ GR_CRASH1, -+ GR_CRASH2, -+ GR_PSACCT, -+ GR_RWXMAP, -+ GR_RWXMAPVMA -+}; -+ -+#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str) -+#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task) -+#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt) -+#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str) -+#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt) -+#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2) -+#define gr_log_fs_rbac_mode3(audit, msg, dentry, mnt, str1, str2, str3) gr_log_varargs(audit, msg, GR_RBAC_MODE3, dentry, mnt, str1, str2, str3) -+#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt) -+#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS) -+#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num) -+#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2) -+#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str) -+#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num) -+#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2) -+#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2) -+#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3) -+#define gr_log_int5_str2(audit, msg, num1, num2, str1, str2) gr_log_varargs(audit, msg, GR_FIVE_INT_TWO_STR, num1, num2, str1, str2) -+#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2) -+#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num) -+#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3) -+#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4) -+#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt) -+#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str) -+#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2) -+#define gr_log_fs_int2_str(audit, msg, dentry, mnt, num1, num2, str) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT_STR, dentry, mnt, num1, num2, str) -+#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2) -+#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task) -+#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2) -+#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str) -+#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr) -+#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num) -+#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong) -+#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1) -+#define gr_log_procacct(audit, msg, task, num1, num2, num3, num4, num5, num6, num7, num8, num9) gr_log_varargs(audit, msg, GR_PSACCT, task, num1, num2, num3, num4, num5, num6, num7, num8, num9) -+#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str) -+#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str) -+ -+void gr_log_varargs(int audit, const char *msg, int argtypes, ...); -+ -+#endif -+ -+#endif -diff -Naur backports-3.18.1-1.org/include/linux/grmsg.h backports-3.18.1-1/include/linux/grmsg.h ---- backports-3.18.1-1.org/include/linux/grmsg.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/linux/grmsg.h 2014-12-28 14:10:09.688889562 +0100 -@@ -0,0 +1,117 @@ -+#define DEFAULTSECMSG "%.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u, parent %.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u" -+#define GR_ACL_PROCACCT_MSG "%.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u run time:[%ud %uh %um %us] cpu time:[%ud %uh %um %us] %s with exit code %ld, parent %.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u" -+#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by " -+#define GR_STOPMOD_MSG "denied modification of module state by " -+#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by " -+#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by " -+#define GR_IOPERM_MSG "denied use of ioperm() by " -+#define GR_IOPL_MSG "denied use of iopl() by " -+#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by " -+#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by " -+#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by " -+#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by " -+#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by " -+#define GR_LEARN_AUDIT_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%lu\t%lu\t%.4095s\t%lu\t%pI4" -+#define GR_ID_LEARN_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%c\t%d\t%d\t%d\t%pI4" -+#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by " -+#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by " -+#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by " -+#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by " -+#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by " -+#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by " -+#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by " -+#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against " -+#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by " -+#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by " -+#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by " -+#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by " -+#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for " -+#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by " -+#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by " -+#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by " -+#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by " -+#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by " -+#define GR_EXEC_ACL_MSG "%s execution of %.950s by " -+#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by " -+#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds" -+#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds" -+#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by " -+#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by " -+#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by " -+#define GR_ATIME_ACL_MSG "%s access time change of %.950s by " -+#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by " -+#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by " -+#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by " -+#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by " -+#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by " -+#define GR_CHROOT_FHANDLE_MSG "denied use of file handles inside chroot by " -+#define GR_CHOWN_ACL_MSG "%s chown of %.950s by " -+#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by " -+#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by " -+#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by " -+#define GR_INITF_ACL_MSG "init_variables() failed %s by " -+#define GR_DISABLED_ACL_MSG "Error loading %s, trying to run kernel with acls disabled. To disable acls at startup use <kernel image name> gracl=off from your boot loader" -+#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by " -+#define GR_SHUTS_ACL_MSG "shutdown auth success for " -+#define GR_SHUTF_ACL_MSG "shutdown auth failure for " -+#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for " -+#define GR_SEGVMODS_ACL_MSG "segvmod auth success for " -+#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for " -+#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for " -+#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by " -+#define GR_ENABLEF_ACL_MSG "unable to load %s for " -+#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system" -+#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by " -+#define GR_RELOADF_ACL_MSG "failed reload of %s for " -+#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for " -+#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by " -+#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by " -+#define GR_SPROLEF_ACL_MSG "special role %s failure for " -+#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for " -+#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by " -+#define GR_INVMODE_ACL_MSG "invalid mode %d by " -+#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by " -+#define GR_FAILFORK_MSG "failed fork with errno %s by " -+#define GR_NICE_CHROOT_MSG "denied priority change by " -+#define GR_UNISIGLOG_MSG "%.32s occurred at %p in " -+#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by " -+#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by " -+#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by " -+#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by " -+#define GR_TIME_MSG "time set by " -+#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by " -+#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by " -+#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by " -+#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by " -+#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by " -+#define GR_BIND_MSG "denied bind() by " -+#define GR_CONNECT_MSG "denied connect() by " -+#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by " -+#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by " -+#define GR_IP_LEARN_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%pI4\t%u\t%u\t%u\t%u\t%pI4" -+#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process " -+#define GR_CAP_ACL_MSG "use of %s denied for " -+#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for " -+#define GR_CAP_ACL_MSG2 "use of %s permitted for " -+#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for " -+#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for " -+#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by " -+#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by " -+#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by " -+#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by " -+#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by " -+#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for " -+#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by " -+#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by " -+#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by " -+#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by " -+#define GR_VM86_MSG "denied use of vm86 by " -+#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by " -+#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by " -+#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by " -+#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by " -+#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by " -+#define GR_BRUTE_DAEMON_MSG "bruteforce prevention initiated for the next 30 minutes or until service restarted, stalling each fork 30 seconds. Please investigate the crash report for " -+#define GR_BRUTE_SUID_MSG "bruteforce prevention initiated due to crash of %.950s against uid %u, banning suid/sgid execs for %u minutes. Please investigate the crash report for " -+#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by " -+#define GR_MSRWRITE_MSG "denied write to CPU MSR by " -diff -Naur backports-3.18.1-1.org/include/linux/grsecurity.h backports-3.18.1-1/include/linux/grsecurity.h ---- backports-3.18.1-1.org/include/linux/grsecurity.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/linux/grsecurity.h 2014-12-28 14:10:09.688889562 +0100 -@@ -0,0 +1,254 @@ -+#ifndef GR_SECURITY_H -+#define GR_SECURITY_H -+#include <linux/fs.h> -+#include <linux/fs_struct.h> -+#include <linux/binfmts.h> -+#include <linux/gracl.h> -+ -+/* notify of brain-dead configs */ -+#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP) -+#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled." -+#endif -+#if defined(CONFIG_GRKERNSEC_PROC) && !defined(CONFIG_GRKERNSEC_PROC_USER) && !defined(CONFIG_GRKERNSEC_PROC_USERGROUP) -+#error "CONFIG_GRKERNSEC_PROC enabled, but neither CONFIG_GRKERNSEC_PROC_USER nor CONFIG_GRKERNSEC_PROC_USERGROUP enabled" -+#endif -+#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC) -+#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled." -+#endif -+#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP) -+#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled." -+#endif -+#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR) -+#error "CONFIG_PAX enabled, but no PaX options are enabled." -+#endif -+ -+int gr_handle_new_usb(void); -+ -+void gr_handle_brute_attach(int dumpable); -+void gr_handle_brute_check(void); -+void gr_handle_kernel_exploit(void); -+ -+char gr_roletype_to_char(void); -+ -+int gr_proc_is_restricted(void); -+ -+int gr_acl_enable_at_secure(void); -+ -+int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs); -+int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs); -+ -+int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap); -+ -+void gr_del_task_from_ip_table(struct task_struct *p); -+ -+int gr_pid_is_chrooted(struct task_struct *p); -+int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type); -+int gr_handle_chroot_nice(void); -+int gr_handle_chroot_sysctl(const int op); -+int gr_handle_chroot_setpriority(struct task_struct *p, -+ const int niceval); -+int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt); -+int gr_chroot_fhandle(void); -+int gr_handle_chroot_chroot(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+void gr_handle_chroot_chdir(const struct path *path); -+int gr_handle_chroot_chmod(const struct dentry *dentry, -+ const struct vfsmount *mnt, const int mode); -+int gr_handle_chroot_mknod(const struct dentry *dentry, -+ const struct vfsmount *mnt, const int mode); -+int gr_handle_chroot_mount(const struct dentry *dentry, -+ const struct vfsmount *mnt, -+ const char *dev_name); -+int gr_handle_chroot_pivot(void); -+int gr_handle_chroot_unix(const pid_t pid); -+ -+int gr_handle_rawio(const struct inode *inode); -+ -+void gr_handle_ioperm(void); -+void gr_handle_iopl(void); -+void gr_handle_msr_write(void); -+ -+umode_t gr_acl_umask(void); -+ -+int gr_tpe_allow(const struct file *file); -+ -+void gr_set_chroot_entries(struct task_struct *task, const struct path *path); -+void gr_clear_chroot_entries(struct task_struct *task); -+ -+void gr_log_forkfail(const int retval); -+void gr_log_timechange(void); -+void gr_log_signal(const int sig, const void *addr, const struct task_struct *t); -+void gr_log_chdir(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+void gr_log_chroot_exec(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+void gr_log_remount(const char *devname, const int retval); -+void gr_log_unmount(const char *devname, const int retval); -+void gr_log_mount(const char *from, const char *to, const int retval); -+void gr_log_textrel(struct vm_area_struct *vma); -+void gr_log_ptgnustack(struct file *file); -+void gr_log_rwxmmap(struct file *file); -+void gr_log_rwxmprotect(struct vm_area_struct *vma); -+ -+int gr_handle_follow_link(const struct inode *parent, -+ const struct inode *inode, -+ const struct dentry *dentry, -+ const struct vfsmount *mnt); -+int gr_handle_fifo(const struct dentry *dentry, -+ const struct vfsmount *mnt, -+ const struct dentry *dir, const int flag, -+ const int acc_mode); -+int gr_handle_hardlink(const struct dentry *dentry, -+ const struct vfsmount *mnt, -+ struct inode *inode, -+ const int mode, const struct filename *to); -+ -+int gr_is_capable(const int cap); -+int gr_is_capable_nolog(const int cap); -+int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap); -+int gr_task_is_capable_nolog(const struct task_struct *task, const int cap); -+ -+void gr_copy_label(struct task_struct *tsk); -+void gr_handle_crash(struct task_struct *task, const int sig); -+int gr_handle_signal(const struct task_struct *p, const int sig); -+int gr_check_crash_uid(const kuid_t uid); -+int gr_check_protected_task(const struct task_struct *task); -+int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type); -+int gr_acl_handle_mmap(const struct file *file, -+ const unsigned long prot); -+int gr_acl_handle_mprotect(const struct file *file, -+ const unsigned long prot); -+int gr_check_hidden_task(const struct task_struct *tsk); -+__u32 gr_acl_handle_truncate(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+__u32 gr_acl_handle_utime(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+__u32 gr_acl_handle_access(const struct dentry *dentry, -+ const struct vfsmount *mnt, const int fmode); -+__u32 gr_acl_handle_chmod(const struct dentry *dentry, -+ const struct vfsmount *mnt, umode_t *mode); -+__u32 gr_acl_handle_chown(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+__u32 gr_acl_handle_setxattr(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+__u32 gr_acl_handle_removexattr(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+int gr_handle_ptrace(struct task_struct *task, const long request); -+int gr_handle_proc_ptrace(struct task_struct *task); -+__u32 gr_acl_handle_execve(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+int gr_check_crash_exec(const struct file *filp); -+int gr_acl_is_enabled(void); -+void gr_set_role_label(struct task_struct *task, const kuid_t uid, -+ const kgid_t gid); -+int gr_set_proc_label(const struct dentry *dentry, -+ const struct vfsmount *mnt, -+ const int unsafe_flags); -+__u32 gr_acl_handle_hidden_file(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+__u32 gr_acl_handle_open(const struct dentry *dentry, -+ const struct vfsmount *mnt, int acc_mode); -+__u32 gr_acl_handle_creat(const struct dentry *dentry, -+ const struct dentry *p_dentry, -+ const struct vfsmount *p_mnt, -+ int open_flags, int acc_mode, const int imode); -+void gr_handle_create(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+void gr_handle_proc_create(const struct dentry *dentry, -+ const struct inode *inode); -+__u32 gr_acl_handle_mknod(const struct dentry *new_dentry, -+ const struct dentry *parent_dentry, -+ const struct vfsmount *parent_mnt, -+ const int mode); -+__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry, -+ const struct dentry *parent_dentry, -+ const struct vfsmount *parent_mnt); -+__u32 gr_acl_handle_rmdir(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+void gr_handle_delete(const ino_t ino, const dev_t dev); -+__u32 gr_acl_handle_unlink(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+__u32 gr_acl_handle_symlink(const struct dentry *new_dentry, -+ const struct dentry *parent_dentry, -+ const struct vfsmount *parent_mnt, -+ const struct filename *from); -+__u32 gr_acl_handle_link(const struct dentry *new_dentry, -+ const struct dentry *parent_dentry, -+ const struct vfsmount *parent_mnt, -+ const struct dentry *old_dentry, -+ const struct vfsmount *old_mnt, const struct filename *to); -+int gr_handle_symlink_owner(const struct path *link, const struct inode *target); -+int gr_acl_handle_rename(struct dentry *new_dentry, -+ struct dentry *parent_dentry, -+ const struct vfsmount *parent_mnt, -+ struct dentry *old_dentry, -+ struct inode *old_parent_inode, -+ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags); -+void gr_handle_rename(struct inode *old_dir, struct inode *new_dir, -+ struct dentry *old_dentry, -+ struct dentry *new_dentry, -+ struct vfsmount *mnt, const __u8 replace, unsigned int flags); -+__u32 gr_check_link(const struct dentry *new_dentry, -+ const struct dentry *parent_dentry, -+ const struct vfsmount *parent_mnt, -+ const struct dentry *old_dentry, -+ const struct vfsmount *old_mnt); -+int gr_acl_handle_filldir(const struct file *file, const char *name, -+ const unsigned int namelen, const ino_t ino); -+ -+__u32 gr_acl_handle_unix(const struct dentry *dentry, -+ const struct vfsmount *mnt); -+void gr_acl_handle_exit(void); -+void gr_acl_handle_psacct(struct task_struct *task, const long code); -+int gr_acl_handle_procpidmem(const struct task_struct *task); -+int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags); -+int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode); -+void gr_audit_ptrace(struct task_struct *task); -+dev_t gr_get_dev_from_dentry(struct dentry *dentry); -+void gr_put_exec_file(struct task_struct *task); -+ -+int gr_ptrace_readexec(struct file *file, int unsafe_flags); -+ -+#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)) -+extern void gr_learn_resource(const struct task_struct *task, const int res, -+ const unsigned long wanted, const int gt); -+#else -+static inline void gr_learn_resource(const struct task_struct *task, const int res, -+ const unsigned long wanted, const int gt) -+{ -+} -+#endif -+ -+#ifdef CONFIG_GRKERNSEC_RESLOG -+extern void gr_log_resource(const struct task_struct *task, const int res, -+ const unsigned long wanted, const int gt); -+#else -+static inline void gr_log_resource(const struct task_struct *task, const int res, -+ const unsigned long wanted, const int gt) -+{ -+} -+#endif -+ -+#ifdef CONFIG_GRKERNSEC -+void task_grsec_rbac(struct seq_file *m, struct task_struct *p); -+void gr_handle_vm86(void); -+void gr_handle_mem_readwrite(u64 from, u64 to); -+ -+void gr_log_badprocpid(const char *entry); -+ -+extern int grsec_enable_dmesg; -+extern int grsec_disable_privio; -+ -+#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP -+extern kgid_t grsec_proc_gid; -+#endif -+ -+#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK -+extern int grsec_enable_chroot_findtask; -+#endif -+#ifdef CONFIG_GRKERNSEC_SETXID -+extern int grsec_enable_setxid; -+#endif -+#endif -+ -+#endif -diff -Naur backports-3.18.1-1.org/include/linux/grsock.h backports-3.18.1-1/include/linux/grsock.h ---- backports-3.18.1-1.org/include/linux/grsock.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/linux/grsock.h 2014-12-28 14:10:09.688889562 +0100 -@@ -0,0 +1,19 @@ -+#ifndef __GRSOCK_H -+#define __GRSOCK_H -+ -+extern void gr_attach_curr_ip(const struct sock *sk); -+extern int gr_handle_sock_all(const int family, const int type, -+ const int protocol); -+extern int gr_handle_sock_server(const struct sockaddr *sck); -+extern int gr_handle_sock_server_other(const struct sock *sck); -+extern int gr_handle_sock_client(const struct sockaddr *sck); -+extern int gr_search_connect(struct socket * sock, -+ struct sockaddr_in * addr); -+extern int gr_search_bind(struct socket * sock, -+ struct sockaddr_in * addr); -+extern int gr_search_listen(struct socket * sock); -+extern int gr_search_accept(struct socket * sock); -+extern int gr_search_socket(const int domain, const int type, -+ const int protocol); -+ -+#endif -diff -Naur backports-3.18.1-1.org/include/linux/unaligned/access_ok.h backports-3.18.1-1/include/linux/unaligned/access_ok.h ---- backports-3.18.1-1.org/include/linux/unaligned/access_ok.h 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/include/linux/unaligned/access_ok.h 2014-12-28 14:10:09.712889681 +0100 -@@ -4,34 +4,34 @@ - #include <linux/kernel.h> - #include <asm/byteorder.h> - --static inline u16 get_unaligned_le16(const void *p) -+static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p) - { -- return le16_to_cpup((__le16 *)p); -+ return le16_to_cpup((const __le16 *)p); - } - --static inline u32 get_unaligned_le32(const void *p) -+static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p) - { -- return le32_to_cpup((__le32 *)p); -+ return le32_to_cpup((const __le32 *)p); - } - --static inline u64 get_unaligned_le64(const void *p) -+static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p) - { -- return le64_to_cpup((__le64 *)p); -+ return le64_to_cpup((const __le64 *)p); - } - --static inline u16 get_unaligned_be16(const void *p) -+static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p) - { -- return be16_to_cpup((__be16 *)p); -+ return be16_to_cpup((const __be16 *)p); - } - --static inline u32 get_unaligned_be32(const void *p) -+static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p) - { -- return be32_to_cpup((__be32 *)p); -+ return be32_to_cpup((const __be32 *)p); - } - --static inline u64 get_unaligned_be64(const void *p) -+static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p) - { -- return be64_to_cpup((__be64 *)p); -+ return be64_to_cpup((const __be64 *)p); - } - - static inline void put_unaligned_le16(u16 val, void *p) -diff -Naur backports-3.18.1-1.org/include/media/v4l2-dev.h backports-3.18.1-1/include/media/v4l2-dev.h ---- backports-3.18.1-1.org/include/media/v4l2-dev.h 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/include/media/v4l2-dev.h 2014-12-28 14:10:09.716889709 +0100 -@@ -75,7 +75,7 @@ - int (*mmap) (struct file *, struct vm_area_struct *); - int (*open) (struct file *); - int (*release) (struct file *); --}; -+} __do_const; - - /* - * Newer version of video_device, handled by videodev2.c -diff -Naur backports-3.18.1-1.org/include/media/v4l2-device.h backports-3.18.1-1/include/media/v4l2-device.h ---- backports-3.18.1-1.org/include/media/v4l2-device.h 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/include/media/v4l2-device.h 2014-12-28 14:10:09.716889709 +0100 -@@ -95,7 +95,7 @@ - this function returns 0. If the name ends with a digit (e.g. cx18), - then the name will be set to cx18-0 since cx180 looks really odd. */ - int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename, -- atomic_t *instance); -+ atomic_unchecked_t *instance); - - /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects. - Since the parent disappears this ensures that v4l2_dev doesn't have an -diff -Naur backports-3.18.1-1.org/include/net/bluetooth/l2cap.h backports-3.18.1-1/include/net/bluetooth/l2cap.h ---- backports-3.18.1-1.org/include/net/bluetooth/l2cap.h 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/include/net/bluetooth/l2cap.h 2014-12-28 14:10:09.716889709 +0100 -@@ -608,7 +608,7 @@ - unsigned char *kdata, - struct iovec *iov, - int len); --}; -+} __do_const; - - struct l2cap_conn { - struct hci_conn *hcon; -diff -Naur backports-3.18.1-1.org/include/net/mac80211.h backports-3.18.1-1/include/net/mac80211.h ---- backports-3.18.1-1.org/include/net/mac80211.h 2014-12-21 22:37:13.000000000 +0100 -+++ backports-3.18.1-1/include/net/mac80211.h 2014-12-28 14:10:09.724889743 +0100 -@@ -4648,7 +4648,7 @@ - void (*remove_sta_debugfs)(void *priv, void *priv_sta); - - u32 (*get_expected_throughput)(void *priv_sta); --}; -+} __do_const; - - static inline int rate_supported(struct ieee80211_sta *sta, - enum ieee80211_band band, -diff -Naur backports-3.18.1-1.org/include/trace/events/fs.h backports-3.18.1-1/include/trace/events/fs.h ---- backports-3.18.1-1.org/include/trace/events/fs.h 1970-01-01 01:00:00.000000000 +0100 -+++ backports-3.18.1-1/include/trace/events/fs.h 2014-12-28 14:10:09.728889769 +0100 -@@ -0,0 +1,53 @@ -+#undef TRACE_SYSTEM -+#define TRACE_SYSTEM fs -+ -+#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ) -+#define _TRACE_FS_H -+ -+#include <linux/fs.h> -+#include <linux/tracepoint.h> -+ -+TRACE_EVENT(do_sys_open, -+ -+ TP_PROTO(const char *filename, int flags, int mode), -+ -+ TP_ARGS(filename, flags, mode), -+ -+ TP_STRUCT__entry( -+ __string( filename, filename ) -+ __field( int, flags ) -+ __field( int, mode ) -+ ), -+ -+ TP_fast_assign( -+ __assign_str(filename, filename); -+ __entry->flags = flags; -+ __entry->mode = mode; -+ ), -+ -+ TP_printk(""%s" %x %o", -+ __get_str(filename), __entry->flags, __entry->mode) -+); -+ -+TRACE_EVENT(open_exec, -+ -+ TP_PROTO(const char *filename), -+ -+ TP_ARGS(filename), -+ -+ TP_STRUCT__entry( -+ __string( filename, filename ) -+ ), -+ -+ TP_fast_assign( -+ __assign_str(filename, filename); -+ ), -+ -+ TP_printk(""%s"", -+ __get_str(filename)) -+); -+ -+#endif /* _TRACE_FS_H */ -+ -+/* This part must be outside protection */ -+#include <trace/define_trace.h> -diff -Naur backports-3.18.1-1.org/net/bluetooth/6lowpan.c backports-3.18.1-1/net/bluetooth/6lowpan.c ---- backports-3.18.1-1.org/net/bluetooth/6lowpan.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/6lowpan.c 2014-12-28 14:10:09.784890034 +0100 -@@ -367,7 +367,6 @@ - - drop: - dev->stats.rx_dropped++; -- kfree_skb(skb); - return NET_RX_DROP; - } - -diff -Naur backports-3.18.1-1.org/net/bluetooth/bnep/core.c backports-3.18.1-1/net/bluetooth/bnep/core.c ---- backports-3.18.1-1.org/net/bluetooth/bnep/core.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/bnep/core.c 2014-12-28 14:10:09.784890034 +0100 -@@ -533,6 +533,9 @@ - - BT_DBG(""); - -+ if (!l2cap_is_socket(sock)) -+ return -EBADFD; -+ - baswap((void *) dst, &l2cap_pi(sock->sk)->chan->dst); - baswap((void *) src, &l2cap_pi(sock->sk)->chan->src); - -diff -Naur backports-3.18.1-1.org/net/bluetooth/cmtp/core.c backports-3.18.1-1/net/bluetooth/cmtp/core.c ---- backports-3.18.1-1.org/net/bluetooth/cmtp/core.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/cmtp/core.c 2014-12-28 14:10:09.784890034 +0100 -@@ -334,6 +334,9 @@ - - BT_DBG(""); - -+ if (!l2cap_is_socket(sock)) -+ return -EBADFD; -+ - session = kzalloc(sizeof(struct cmtp_session), GFP_KERNEL); - if (!session) - return -ENOMEM; -diff -Naur backports-3.18.1-1.org/net/bluetooth/hci_sock.c backports-3.18.1-1/net/bluetooth/hci_sock.c ---- backports-3.18.1-1.org/net/bluetooth/hci_sock.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/hci_sock.c 2014-12-28 14:10:09.784890034 +0100 -@@ -1067,7 +1067,7 @@ - uf.event_mask[1] = *((u32 *) f->event_mask + 1); - } - -- len = min_t(unsigned int, len, sizeof(uf)); -+ len = min((size_t)len, sizeof(uf)); - if (copy_from_user(&uf, optval, len)) { - err = -EFAULT; - break; -diff -Naur backports-3.18.1-1.org/net/bluetooth/hidp/core.c backports-3.18.1-1/net/bluetooth/hidp/core.c ---- backports-3.18.1-1.org/net/bluetooth/hidp/core.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/hidp/core.c 2014-12-28 14:10:09.784890034 +0100 -@@ -1322,13 +1322,14 @@ - { - struct hidp_session *session; - struct l2cap_conn *conn; -- struct l2cap_chan *chan = l2cap_pi(ctrl_sock->sk)->chan; -+ struct l2cap_chan *chan; - int ret; - - ret = hidp_verify_sockets(ctrl_sock, intr_sock); - if (ret) - return ret; - -+ chan = l2cap_pi(ctrl_sock->sk)->chan; - conn = NULL; - l2cap_chan_lock(chan); - if (chan->conn) -diff -Naur backports-3.18.1-1.org/net/bluetooth/l2cap_core.c backports-3.18.1-1/net/bluetooth/l2cap_core.c ---- backports-3.18.1-1.org/net/bluetooth/l2cap_core.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/l2cap_core.c 2014-12-28 14:10:09.784890034 +0100 -@@ -3512,8 +3512,10 @@ - break; - - case L2CAP_CONF_RFC: -- if (olen == sizeof(rfc)) -- memcpy(&rfc, (void *)val, olen); -+ if (olen != sizeof(rfc)) -+ break; -+ -+ memcpy(&rfc, (void *)val, olen); - - if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && - rfc.mode != chan->mode) -diff -Naur backports-3.18.1-1.org/net/bluetooth/l2cap_sock.c backports-3.18.1-1/net/bluetooth/l2cap_sock.c ---- backports-3.18.1-1.org/net/bluetooth/l2cap_sock.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/l2cap_sock.c 2014-12-28 14:10:09.788890064 +0100 -@@ -628,7 +628,8 @@ - struct sock *sk = sock->sk; - struct l2cap_chan *chan = l2cap_pi(sk)->chan; - struct l2cap_options opts; -- int len, err = 0; -+ int err = 0; -+ size_t len = optlen; - u32 opt; - - BT_DBG("sk %p", sk); -@@ -655,7 +656,7 @@ - opts.max_tx = chan->max_tx; - opts.txwin_size = chan->tx_win; - -- len = min_t(unsigned int, sizeof(opts), optlen); -+ len = min(sizeof(opts), len); - if (copy_from_user((char *) &opts, optval, len)) { - err = -EFAULT; - break; -@@ -742,7 +743,8 @@ - struct bt_security sec; - struct bt_power pwr; - struct l2cap_conn *conn; -- int len, err = 0; -+ int err = 0; -+ size_t len = optlen; - u32 opt; - - BT_DBG("sk %p", sk); -@@ -766,7 +768,7 @@ - - sec.level = BT_SECURITY_LOW; - -- len = min_t(unsigned int, sizeof(sec), optlen); -+ len = min(sizeof(sec), len); - if (copy_from_user((char *) &sec, optval, len)) { - err = -EFAULT; - break; -@@ -862,7 +864,7 @@ - - pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; - -- len = min_t(unsigned int, sizeof(pwr), optlen); -+ len = min(sizeof(pwr), len); - if (copy_from_user((char *) &pwr, optval, len)) { - err = -EFAULT; - break; -diff -Naur backports-3.18.1-1.org/net/bluetooth/rfcomm/sock.c backports-3.18.1-1/net/bluetooth/rfcomm/sock.c ---- backports-3.18.1-1.org/net/bluetooth/rfcomm/sock.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/rfcomm/sock.c 2014-12-28 14:10:09.788890064 +0100 -@@ -695,7 +695,7 @@ - struct sock *sk = sock->sk; - struct bt_security sec; - int err = 0; -- size_t len; -+ size_t len = optlen; - u32 opt; - - BT_DBG("sk %p", sk); -@@ -717,7 +717,7 @@ - - sec.level = BT_SECURITY_LOW; - -- len = min_t(unsigned int, sizeof(sec), optlen); -+ len = min(sizeof(sec), len); - if (copy_from_user((char *) &sec, optval, len)) { - err = -EFAULT; - break; -diff -Naur backports-3.18.1-1.org/net/bluetooth/rfcomm/tty.c backports-3.18.1-1/net/bluetooth/rfcomm/tty.c ---- backports-3.18.1-1.org/net/bluetooth/rfcomm/tty.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/bluetooth/rfcomm/tty.c 2014-12-28 14:10:09.788890064 +0100 -@@ -752,7 +752,7 @@ - BT_DBG("tty %p id %d", tty, tty->index); - - BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst, -- dev->channel, dev->port.count); -+ dev->channel, atomic_read(&dev->port.count)); - - err = tty_port_open(&dev->port, tty, filp); - if (err) -@@ -775,7 +775,7 @@ - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; - - BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, -- dev->port.count); -+ atomic_read(&dev->port.count)); - - tty_port_close(&dev->port, tty, filp); - } -diff -Naur backports-3.18.1-1.org/net/ieee802154/6lowpan_rtnl.c backports-3.18.1-1/net/ieee802154/6lowpan_rtnl.c ---- backports-3.18.1-1.org/net/ieee802154/6lowpan_rtnl.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/ieee802154/6lowpan_rtnl.c 2014-12-28 14:10:09.796890100 +0100 -@@ -639,7 +639,7 @@ - dev_put(real_dev); - } - --static struct rtnl_link_ops lowpan_link_ops __read_mostly = { -+static struct rtnl_link_ops lowpan_link_ops = { - .kind = "lowpan", - .priv_size = sizeof(struct lowpan_dev_info), - .setup = lowpan_setup, -diff -Naur backports-3.18.1-1.org/net/ieee802154/reassembly.c backports-3.18.1-1/net/ieee802154/reassembly.c ---- backports-3.18.1-1.org/net/ieee802154/reassembly.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/ieee802154/reassembly.c 2014-12-28 14:10:09.796890100 +0100 -@@ -460,14 +460,13 @@ - - static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) - { -- struct ctl_table *table; -+ ctl_table_no_const *table = NULL; - struct ctl_table_header *hdr; - struct netns_ieee802154_lowpan *ieee802154_lowpan = - net_ieee802154_lowpan(net); - -- table = lowpan_frags_ns_ctl_table; - if (!net_eq(net, &init_net)) { -- table = kmemdup(table, sizeof(lowpan_frags_ns_ctl_table), -+ table = kmemdup(lowpan_frags_ns_ctl_table, sizeof(lowpan_frags_ns_ctl_table), - GFP_KERNEL); - if (table == NULL) - goto err_alloc; -@@ -494,8 +493,7 @@ - return 0; - - err_reg: -- if (!net_eq(net, &init_net)) -- kfree(table); -+ kfree(table); - err_alloc: - return -ENOMEM; - } -diff -Naur backports-3.18.1-1.org/net/mac80211/cfg.c backports-3.18.1-1/net/mac80211/cfg.c ---- backports-3.18.1-1.org/net/mac80211/cfg.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/mac80211/cfg.c 2014-12-28 14:10:09.812890175 +0100 -@@ -541,7 +541,7 @@ - ret = ieee80211_vif_use_channel(sdata, chandef, - IEEE80211_CHANCTX_EXCLUSIVE); - } -- } else if (local->open_count == local->monitors) { -+ } else if (local_read(&local->open_count) == local->monitors) { - local->_oper_chandef = *chandef; - ieee80211_hw_config(local, 0); - } -@@ -3326,7 +3326,7 @@ - else - local->probe_req_reg--; - -- if (!local->open_count) -+ if (!local_read(&local->open_count)) - break; - - ieee80211_queue_work(&local->hw, &local->reconfig_filter); -@@ -3460,8 +3460,8 @@ - if (chanctx_conf) { - *chandef = sdata->vif.bss_conf.chandef; - ret = 0; -- } else if (local->open_count > 0 && -- local->open_count == local->monitors && -+ } else if (local_read(&local->open_count) > 0 && -+ local_read(&local->open_count) == local->monitors && - sdata->vif.type == NL80211_IFTYPE_MONITOR) { - if (local->use_chanctx) - *chandef = local->monitor_chandef; -diff -Naur backports-3.18.1-1.org/net/mac80211/ieee80211_i.h backports-3.18.1-1/net/mac80211/ieee80211_i.h ---- backports-3.18.1-1.org/net/mac80211/ieee80211_i.h 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/mac80211/ieee80211_i.h 2014-12-28 14:10:09.812890175 +0100 -@@ -29,6 +29,7 @@ - #include <net/ieee80211_radiotap.h> - #include <net/cfg80211.h> - #include <net/mac80211.h> -+#include <asm/local.h> - #include "key.h" - #include "sta_info.h" - #include "debug.h" -@@ -1057,7 +1058,7 @@ - /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ - spinlock_t queue_stop_reason_lock; - -- int open_count; -+ local_t open_count; - int monitors, cooked_mntrs; - /* number of interfaces with corresponding FIF_ flags */ - int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll, -diff -Naur backports-3.18.1-1.org/net/mac80211/iface.c backports-3.18.1-1/net/mac80211/iface.c ---- backports-3.18.1-1.org/net/mac80211/iface.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/mac80211/iface.c 2014-12-28 14:10:09.812890175 +0100 -@@ -532,7 +532,7 @@ - break; - } - -- if (local->open_count == 0) { -+ if (local_read(&local->open_count) == 0) { - res = drv_start(local); - if (res) - goto err_del_bss; -@@ -579,7 +579,7 @@ - res = drv_add_interface(local, sdata); - if (res) - goto err_stop; -- } else if (local->monitors == 0 && local->open_count == 0) { -+ } else if (local->monitors == 0 && local_read(&local->open_count) == 0) { - res = ieee80211_add_virtual_monitor(local); - if (res) - goto err_stop; -@@ -688,7 +688,7 @@ - atomic_inc(&local->iff_promiscs); - - if (coming_up) -- local->open_count++; -+ local_inc(&local->open_count); - - if (hw_reconf_flags) - ieee80211_hw_config(local, hw_reconf_flags); -@@ -726,7 +726,7 @@ - err_del_interface: - drv_remove_interface(local, sdata); - err_stop: -- if (!local->open_count) -+ if (!local_read(&local->open_count)) - drv_stop(local); - err_del_bss: - sdata->bss = NULL; -@@ -892,7 +892,7 @@ - } - - if (going_down) -- local->open_count--; -+ local_dec(&local->open_count); - - switch (sdata->vif.type) { - case NL80211_IFTYPE_AP_VLAN: -@@ -954,7 +954,7 @@ - } - spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); - -- if (local->open_count == 0) -+ if (local_read(&local->open_count) == 0) - ieee80211_clear_tx_pending(local); - - /* -@@ -997,7 +997,7 @@ - if (cancel_scan) - flush_delayed_work(&local->scan_work); - -- if (local->open_count == 0) { -+ if (local_read(&local->open_count) == 0) { - ieee80211_stop_device(local); - - /* no reconfiguring after stop! */ -@@ -1008,7 +1008,7 @@ - ieee80211_configure_filter(local); - ieee80211_hw_config(local, hw_reconf_flags); - -- if (local->monitors == local->open_count) -+ if (local->monitors == local_read(&local->open_count)) - ieee80211_add_virtual_monitor(local); - } - -diff -Naur backports-3.18.1-1.org/net/mac80211/main.c backports-3.18.1-1/net/mac80211/main.c ---- backports-3.18.1-1.org/net/mac80211/main.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/mac80211/main.c 2014-12-28 14:10:09.812890175 +0100 -@@ -175,7 +175,7 @@ - changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL | - IEEE80211_CONF_CHANGE_POWER); - -- if (changed && local->open_count) { -+ if (changed && local_read(&local->open_count)) { - ret = drv_config(local, changed); - /* - * Goal: -diff -Naur backports-3.18.1-1.org/net/mac80211/pm.c backports-3.18.1-1/net/mac80211/pm.c ---- backports-3.18.1-1.org/net/mac80211/pm.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/mac80211/pm.c 2014-12-28 14:10:09.812890175 +0100 -@@ -12,7 +12,7 @@ - struct ieee80211_sub_if_data *sdata; - struct sta_info *sta; - -- if (!local->open_count) -+ if (!local_read(&local->open_count)) - goto suspend; - - ieee80211_scan_cancel(local); -@@ -59,7 +59,7 @@ - cancel_work_sync(&local->dynamic_ps_enable_work); - del_timer_sync(&local->dynamic_ps_timer); - -- local->wowlan = wowlan && local->open_count; -+ local->wowlan = wowlan && local_read(&local->open_count); - if (local->wowlan) { - int err = drv_suspend(local, wowlan); - if (err < 0) { -@@ -125,7 +125,7 @@ - WARN_ON(!list_empty(&local->chanctx_list)); - - /* stop hardware - this must stop RX */ -- if (local->open_count) -+ if (local_read(&local->open_count)) - ieee80211_stop_device(local); - - suspend: -diff -Naur backports-3.18.1-1.org/net/mac80211/rate.c backports-3.18.1-1/net/mac80211/rate.c ---- backports-3.18.1-1.org/net/mac80211/rate.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/mac80211/rate.c 2014-12-28 14:10:09.812890175 +0100 -@@ -720,7 +720,7 @@ - - ASSERT_RTNL(); - -- if (local->open_count) -+ if (local_read(&local->open_count)) - return -EBUSY; - - if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) { -diff -Naur backports-3.18.1-1.org/net/mac80211/util.c backports-3.18.1-1/net/mac80211/util.c ---- backports-3.18.1-1.org/net/mac80211/util.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/mac80211/util.c 2014-12-28 14:10:09.816890209 +0100 -@@ -1669,7 +1669,7 @@ - } - #endif - /* everything else happens only if HW was up & running */ -- if (!local->open_count) -+ if (!local_read(&local->open_count)) - goto wake_up; - - /* -@@ -1895,7 +1895,7 @@ - local->in_reconfig = false; - barrier(); - -- if (local->monitors == local->open_count && local->monitors > 0) -+ if (local->monitors == local_read(&local->open_count) && local->monitors > 0) - ieee80211_add_virtual_monitor(local); - - /* -diff -Naur backports-3.18.1-1.org/net/wireless/wext-core.c backports-3.18.1-1/net/wireless/wext-core.c ---- backports-3.18.1-1.org/net/wireless/wext-core.c 2014-12-21 22:37:15.000000000 +0100 -+++ backports-3.18.1-1/net/wireless/wext-core.c 2014-12-28 14:10:09.832890290 +0100 -@@ -748,8 +748,7 @@ - */ - - /* Support for very large requests */ -- if ((descr->flags & IW_DESCR_FLAG_NOMAX) && -- (user_length > descr->max_tokens)) { -+ if (user_length > descr->max_tokens) { - /* Allow userspace to GET more than max so - * we can support any size GET requests. - * There is still a limit : -ENOMEM. -@@ -788,22 +787,6 @@ - } - } - -- if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) { -- /* -- * If this is a GET, but not NOMAX, it means that the extra -- * data is not bounded by userspace, but by max_tokens. Thus -- * set the length to max_tokens. This matches the extra data -- * allocation. -- * The driver should fill it with the number of tokens it -- * provided, and it may check iwp->length rather than having -- * knowledge of max_tokens. If the driver doesn't change the -- * iwp->length, this ioctl just copies back max_token tokens -- * filled with zeroes. Hopefully the driver isn't claiming -- * them to be valid data. -- */ -- iwp->length = descr->max_tokens; -- } -- - err = handler(dev, info, (union iwreq_data *) iwp, extra); - - iwp->length += essid_compat; diff --git a/src/patches/backports-4.2.6-1-add_usbnet_modules.patch b/src/patches/backports-4.2.6-1-add_usbnet_modules.patch new file mode 100644 index 0000000..660ef8c --- /dev/null +++ b/src/patches/backports-4.2.6-1-add_usbnet_modules.patch @@ -0,0 +1,28998 @@ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/asix_common.c backports-4.2.6-1/drivers/net/usb/asix_common.c +--- backports-4.2.6-1.org/drivers/net/usb/asix_common.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/asix_common.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,584 @@ ++/* ++ * ASIX AX8817X based USB 2.0 Ethernet Devices ++ * Copyright (C) 2003-2006 David Hollis dhollis@davehollis.com ++ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net ++ * Copyright (C) 2006 James Painter jamie.painter@iname.com ++ * Copyright (c) 2002-2003 TiVo Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include "asix.h" ++ ++int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data) ++{ ++ int ret; ++ ret = usbnet_read_cmd(dev, cmd, ++ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ value, index, data, size); ++ ++ if (ret != size && ret >= 0) ++ return -EINVAL; ++ return ret; ++} ++ ++int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data) ++{ ++ return usbnet_write_cmd(dev, cmd, ++ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ value, index, data, size); ++} ++ ++void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data) ++{ ++ usbnet_write_cmd_async(dev, cmd, ++ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ value, index, data, size); ++} ++ ++int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb, ++ struct asix_rx_fixup_info *rx) ++{ ++ int offset = 0; ++ ++ while (offset + sizeof(u16) <= skb->len) { ++ u16 remaining = 0; ++ unsigned char *data; ++ ++ if (!rx->size) { ++ if ((skb->len - offset == sizeof(u16)) || ++ rx->split_head) { ++ if(!rx->split_head) { ++ rx->header = get_unaligned_le16( ++ skb->data + offset); ++ rx->split_head = true; ++ offset += sizeof(u16); ++ break; ++ } else { ++ rx->header |= (get_unaligned_le16( ++ skb->data + offset) ++ << 16); ++ rx->split_head = false; ++ offset += sizeof(u16); ++ } ++ } else { ++ rx->header = get_unaligned_le32(skb->data + ++ offset); ++ offset += sizeof(u32); ++ } ++ ++ /* get the packet length */ ++ rx->size = (u16) (rx->header & 0x7ff); ++ if (rx->size != ((~rx->header >> 16) & 0x7ff)) { ++ netdev_err(dev->net, "asix_rx_fixup() Bad Header Length 0x%x, offset %d\n", ++ rx->header, offset); ++ rx->size = 0; ++ return 0; ++ } ++ rx->ax_skb = netdev_alloc_skb_ip_align(dev->net, ++ rx->size); ++ if (!rx->ax_skb) ++ return 0; ++ } ++ ++ if (rx->size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) { ++ netdev_err(dev->net, "asix_rx_fixup() Bad RX Length %d\n", ++ rx->size); ++ kfree_skb(rx->ax_skb); ++ rx->ax_skb = NULL; ++ rx->size = 0U; ++ ++ return 0; ++ } ++ ++ if (rx->size > skb->len - offset) { ++ remaining = rx->size - (skb->len - offset); ++ rx->size = skb->len - offset; ++ } ++ ++ data = skb_put(rx->ax_skb, rx->size); ++ memcpy(data, skb->data + offset, rx->size); ++ if (!remaining) ++ usbnet_skb_return(dev, rx->ax_skb); ++ ++ offset += (rx->size + 1) & 0xfffe; ++ rx->size = remaining; ++ } ++ ++ if (skb->len != offset) { ++ netdev_err(dev->net, "asix_rx_fixup() Bad SKB Length %d, %d\n", ++ skb->len, offset); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb) ++{ ++ struct asix_common_private *dp = dev->driver_priv; ++ struct asix_rx_fixup_info *rx = &dp->rx_fixup_info; ++ ++ return asix_rx_fixup_internal(dev, skb, rx); ++} ++ ++struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ++ gfp_t flags) ++{ ++ int padlen; ++ int headroom = skb_headroom(skb); ++ int tailroom = skb_tailroom(skb); ++ u32 packet_len; ++ u32 padbytes = 0xffff0000; ++ ++ padlen = ((skb->len + 4) & (dev->maxpacket - 1)) ? 0 : 4; ++ ++ /* We need to push 4 bytes in front of frame (packet_len) ++ * and maybe add 4 bytes after the end (if padlen is 4) ++ * ++ * Avoid skb_copy_expand() expensive call, using following rules : ++ * - We are allowed to push 4 bytes in headroom if skb_header_cloned() ++ * is false (and if we have 4 bytes of headroom) ++ * - We are allowed to put 4 bytes at tail if skb_cloned() ++ * is false (and if we have 4 bytes of tailroom) ++ * ++ * TCP packets for example are cloned, but skb_header_release() ++ * was called in tcp stack, allowing us to use headroom for our needs. ++ */ ++ if (!skb_header_cloned(skb) && ++ !(padlen && skb_cloned(skb)) && ++ headroom + tailroom >= 4 + padlen) { ++ /* following should not happen, but better be safe */ ++ if (headroom < 4 || ++ tailroom < padlen) { ++ skb->data = memmove(skb->head + 4, skb->data, skb->len); ++ skb_set_tail_pointer(skb, skb->len); ++ } ++ } else { ++ struct sk_buff *skb2; ++ ++ skb2 = skb_copy_expand(skb, 4, padlen, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (!skb) ++ return NULL; ++ } ++ ++ packet_len = ((skb->len ^ 0x0000ffff) << 16) + skb->len; ++ skb_push(skb, 4); ++ cpu_to_le32s(&packet_len); ++ skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len)); ++ ++ if (padlen) { ++ cpu_to_le32s(&padbytes); ++ memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes)); ++ skb_put(skb, sizeof(padbytes)); ++ } ++ ++ usbnet_set_skb_tx_stats(skb, 1, 0); ++ return skb; ++} ++ ++int asix_set_sw_mii(struct usbnet *dev) ++{ ++ int ret; ++ ret = asix_write_cmd(dev, AX_CMD_SET_SW_MII, 0x0000, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to enable software MII access\n"); ++ return ret; ++} ++ ++int asix_set_hw_mii(struct usbnet *dev) ++{ ++ int ret; ++ ret = asix_write_cmd(dev, AX_CMD_SET_HW_MII, 0x0000, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to enable hardware MII access\n"); ++ return ret; ++} ++ ++int asix_read_phy_addr(struct usbnet *dev, int internal) ++{ ++ int offset = (internal ? 1 : 0); ++ u8 buf[2]; ++ int ret = asix_read_cmd(dev, AX_CMD_READ_PHY_ID, 0, 0, 2, buf); ++ ++ netdev_dbg(dev->net, "asix_get_phy_addr()\n"); ++ ++ if (ret < 0) { ++ netdev_err(dev->net, "Error reading PHYID register: %02x\n", ret); ++ goto out; ++ } ++ netdev_dbg(dev->net, "asix_get_phy_addr() returning 0x%04x\n", ++ *((__le16 *)buf)); ++ ret = buf[offset]; ++ ++out: ++ return ret; ++} ++ ++int asix_get_phy_addr(struct usbnet *dev) ++{ ++ /* return the address of the internal phy */ ++ return asix_read_phy_addr(dev, 1); ++} ++ ++ ++int asix_sw_reset(struct usbnet *dev, u8 flags) ++{ ++ int ret; ++ ++ ret = asix_write_cmd(dev, AX_CMD_SW_RESET, flags, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to send software reset: %02x\n", ret); ++ ++ return ret; ++} ++ ++u16 asix_read_rx_ctl(struct usbnet *dev) ++{ ++ __le16 v; ++ int ret = asix_read_cmd(dev, AX_CMD_READ_RX_CTL, 0, 0, 2, &v); ++ ++ if (ret < 0) { ++ netdev_err(dev->net, "Error reading RX_CTL register: %02x\n", ret); ++ goto out; ++ } ++ ret = le16_to_cpu(v); ++out: ++ return ret; ++} ++ ++int asix_write_rx_ctl(struct usbnet *dev, u16 mode) ++{ ++ int ret; ++ ++ netdev_dbg(dev->net, "asix_write_rx_ctl() - mode = 0x%04x\n", mode); ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_RX_CTL, mode, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to write RX_CTL mode to 0x%04x: %02x\n", ++ mode, ret); ++ ++ return ret; ++} ++ ++u16 asix_read_medium_status(struct usbnet *dev) ++{ ++ __le16 v; ++ int ret = asix_read_cmd(dev, AX_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v); ++ ++ if (ret < 0) { ++ netdev_err(dev->net, "Error reading Medium Status register: %02x\n", ++ ret); ++ return ret; /* TODO: callers not checking for error ret */ ++ } ++ ++ return le16_to_cpu(v); ++ ++} ++ ++int asix_write_medium_mode(struct usbnet *dev, u16 mode) ++{ ++ int ret; ++ ++ netdev_dbg(dev->net, "asix_write_medium_mode() - mode = 0x%04x\n", mode); ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to write Medium Mode mode to 0x%04x: %02x\n", ++ mode, ret); ++ ++ return ret; ++} ++ ++int asix_write_gpio(struct usbnet *dev, u16 value, int sleep) ++{ ++ int ret; ++ ++ netdev_dbg(dev->net, "asix_write_gpio() - value = 0x%04x\n", value); ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, value, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to write GPIO value 0x%04x: %02x\n", ++ value, ret); ++ ++ if (sleep) ++ msleep(sleep); ++ ++ return ret; ++} ++ ++/* ++ * AX88772 & AX88178 have a 16-bit RX_CTL value ++ */ ++void asix_set_multicast(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ u16 rx_ctl = AX_DEFAULT_RX_CTL; ++ ++ if (net->flags & IFF_PROMISC) { ++ rx_ctl |= AX_RX_CTL_PRO; ++ } else if (net->flags & IFF_ALLMULTI || ++ netdev_mc_count(net) > AX_MAX_MCAST) { ++ rx_ctl |= AX_RX_CTL_AMALL; ++ } else if (netdev_mc_empty(net)) { ++ /* just broadcast and directed */ ++ } else { ++ /* We use the 20 byte dev->data ++ * for our 8 byte filter buffer ++ * to avoid allocating memory that ++ * is tricky to free later */ ++ struct netdev_hw_addr *ha; ++ u32 crc_bits; ++ ++ memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); ++ ++ /* Build the multicast hash filter. */ ++ netdev_for_each_mc_addr(ha, net) { ++ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; ++ data->multi_filter[crc_bits >> 3] |= ++ 1 << (crc_bits & 7); ++ } ++ ++ asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, ++ AX_MCAST_FILTER_SIZE, data->multi_filter); ++ ++ rx_ctl |= AX_RX_CTL_AM; ++ } ++ ++ asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); ++} ++ ++int asix_mdio_read(struct net_device *netdev, int phy_id, int loc) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ __le16 res; ++ ++ mutex_lock(&dev->phy_mutex); ++ asix_set_sw_mii(dev); ++ asix_read_cmd(dev, AX_CMD_READ_MII_REG, phy_id, ++ (__u16)loc, 2, &res); ++ asix_set_hw_mii(dev); ++ mutex_unlock(&dev->phy_mutex); ++ ++ netdev_dbg(dev->net, "asix_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", ++ phy_id, loc, le16_to_cpu(res)); ++ ++ return le16_to_cpu(res); ++} ++ ++void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ __le16 res = cpu_to_le16(val); ++ ++ netdev_dbg(dev->net, "asix_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", ++ phy_id, loc, val); ++ mutex_lock(&dev->phy_mutex); ++ asix_set_sw_mii(dev); ++ asix_write_cmd(dev, AX_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); ++ asix_set_hw_mii(dev); ++ mutex_unlock(&dev->phy_mutex); ++} ++ ++void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u8 opt; ++ ++ if (asix_read_cmd(dev, AX_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) { ++ wolinfo->supported = 0; ++ wolinfo->wolopts = 0; ++ return; ++ } ++ wolinfo->supported = WAKE_PHY | WAKE_MAGIC; ++ wolinfo->wolopts = 0; ++ if (opt & AX_MONITOR_LINK) ++ wolinfo->wolopts |= WAKE_PHY; ++ if (opt & AX_MONITOR_MAGIC) ++ wolinfo->wolopts |= WAKE_MAGIC; ++} ++ ++int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u8 opt = 0; ++ ++ if (wolinfo->wolopts & WAKE_PHY) ++ opt |= AX_MONITOR_LINK; ++ if (wolinfo->wolopts & WAKE_MAGIC) ++ opt |= AX_MONITOR_MAGIC; ++ ++ if (asix_write_cmd(dev, AX_CMD_WRITE_MONITOR_MODE, ++ opt, 0, 0, NULL) < 0) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++int asix_get_eeprom_len(struct net_device *net) ++{ ++ return AX_EEPROM_LEN; ++} ++ ++int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, ++ u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u16 *eeprom_buff; ++ int first_word, last_word; ++ int i; ++ ++ if (eeprom->len == 0) ++ return -EINVAL; ++ ++ eeprom->magic = AX_EEPROM_MAGIC; ++ ++ first_word = eeprom->offset >> 1; ++ last_word = (eeprom->offset + eeprom->len - 1) >> 1; ++ ++ eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), ++ GFP_KERNEL); ++ if (!eeprom_buff) ++ return -ENOMEM; ++ ++ /* ax8817x returns 2 bytes from eeprom on read */ ++ for (i = first_word; i <= last_word; i++) { ++ if (asix_read_cmd(dev, AX_CMD_READ_EEPROM, i, 0, 2, ++ &(eeprom_buff[i - first_word])) < 0) { ++ kfree(eeprom_buff); ++ return -EIO; ++ } ++ } ++ ++ memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); ++ kfree(eeprom_buff); ++ return 0; ++} ++ ++int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, ++ u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u16 *eeprom_buff; ++ int first_word, last_word; ++ int i; ++ int ret; ++ ++ netdev_dbg(net, "write EEPROM len %d, offset %d, magic 0x%x\n", ++ eeprom->len, eeprom->offset, eeprom->magic); ++ ++ if (eeprom->len == 0) ++ return -EINVAL; ++ ++ if (eeprom->magic != AX_EEPROM_MAGIC) ++ return -EINVAL; ++ ++ first_word = eeprom->offset >> 1; ++ last_word = (eeprom->offset + eeprom->len - 1) >> 1; ++ ++ eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), ++ GFP_KERNEL); ++ if (!eeprom_buff) ++ return -ENOMEM; ++ ++ /* align data to 16 bit boundaries, read the missing data from ++ the EEPROM */ ++ if (eeprom->offset & 1) { ++ ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, first_word, 0, 2, ++ &(eeprom_buff[0])); ++ if (ret < 0) { ++ netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", first_word); ++ goto free; ++ } ++ } ++ ++ if ((eeprom->offset + eeprom->len) & 1) { ++ ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, last_word, 0, 2, ++ &(eeprom_buff[last_word - first_word])); ++ if (ret < 0) { ++ netdev_err(net, "Failed to read EEPROM at offset 0x%02x.\n", last_word); ++ goto free; ++ } ++ } ++ ++ memcpy((u8 *)eeprom_buff + (eeprom->offset & 1), data, eeprom->len); ++ ++ /* write data to EEPROM */ ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0x0000, 0, 0, NULL); ++ if (ret < 0) { ++ netdev_err(net, "Failed to enable EEPROM write\n"); ++ goto free; ++ } ++ msleep(20); ++ ++ for (i = first_word; i <= last_word; i++) { ++ netdev_dbg(net, "write to EEPROM at offset 0x%02x, data 0x%04x\n", ++ i, eeprom_buff[i - first_word]); ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_EEPROM, i, ++ eeprom_buff[i - first_word], 0, NULL); ++ if (ret < 0) { ++ netdev_err(net, "Failed to write EEPROM at offset 0x%02x.\n", ++ i); ++ goto free; ++ } ++ msleep(20); ++ } ++ ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0x0000, 0, 0, NULL); ++ if (ret < 0) { ++ netdev_err(net, "Failed to disable EEPROM write\n"); ++ goto free; ++ } ++ ++ ret = 0; ++free: ++ kfree(eeprom_buff); ++ return ret; ++} ++ ++void asix_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info) ++{ ++ /* Inherit standard device info */ ++ usbnet_get_drvinfo(net, info); ++ strlcpy(info->driver, DRIVER_NAME, sizeof(info->driver)); ++ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); ++ info->eedump_len = AX_EEPROM_LEN; ++} ++ ++int asix_set_mac_address(struct net_device *net, void *p) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ struct sockaddr *addr = p; ++ ++ if (netif_running(net)) ++ return -EBUSY; ++ if (!is_valid_ether_addr(addr->sa_data)) ++ return -EADDRNOTAVAIL; ++ ++ memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); ++ ++ /* We use the 20 byte dev->data ++ * for our 6 byte mac buffer ++ * to avoid allocating memory that ++ * is tricky to free later */ ++ memcpy(data->mac_addr, addr->sa_data, ETH_ALEN); ++ asix_write_cmd_async(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, ++ data->mac_addr); ++ ++ return 0; ++} +diff -Naur backports-4.2.6-1.org/drivers/net/usb/asix_devices.c backports-4.2.6-1/drivers/net/usb/asix_devices.c +--- backports-4.2.6-1.org/drivers/net/usb/asix_devices.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/asix_devices.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,1107 @@ ++/* ++ * ASIX AX8817X based USB 2.0 Ethernet Devices ++ * Copyright (C) 2003-2006 David Hollis dhollis@davehollis.com ++ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net ++ * Copyright (C) 2006 James Painter jamie.painter@iname.com ++ * Copyright (c) 2002-2003 TiVo Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include "asix.h" ++ ++#define PHY_MODE_MARVELL 0x0000 ++#define MII_MARVELL_LED_CTRL 0x0018 ++#define MII_MARVELL_STATUS 0x001b ++#define MII_MARVELL_CTRL 0x0014 ++ ++#define MARVELL_LED_MANUAL 0x0019 ++ ++#define MARVELL_STATUS_HWCFG 0x0004 ++ ++#define MARVELL_CTRL_TXDELAY 0x0002 ++#define MARVELL_CTRL_RXDELAY 0x0080 ++ ++#define PHY_MODE_RTL8211CL 0x000C ++ ++struct ax88172_int_data { ++ __le16 res1; ++ u8 link; ++ __le16 res2; ++ u8 status; ++ __le16 res3; ++} __packed; ++ ++static void asix_status(struct usbnet *dev, struct urb *urb) ++{ ++ struct ax88172_int_data *event; ++ int link; ++ ++ if (urb->actual_length < 8) ++ return; ++ ++ event = urb->transfer_buffer; ++ link = event->link & 0x01; ++ if (netif_carrier_ok(dev->net) != link) { ++ usbnet_link_change(dev, link, 1); ++ netdev_dbg(dev->net, "Link Status is: %d\n", link); ++ } ++} ++ ++static void asix_set_netdev_dev_addr(struct usbnet *dev, u8 *addr) ++{ ++ if (is_valid_ether_addr(addr)) { ++ memcpy(dev->net->dev_addr, addr, ETH_ALEN); ++ } else { ++ netdev_info(dev->net, "invalid hw address, using random\n"); ++ eth_hw_addr_random(dev->net); ++ } ++} ++ ++/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ ++static u32 asix_get_phyid(struct usbnet *dev) ++{ ++ int phy_reg; ++ u32 phy_id; ++ int i; ++ ++ /* Poll for the rare case the FW or phy isn't ready yet. */ ++ for (i = 0; i < 100; i++) { ++ phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1); ++ if (phy_reg != 0 && phy_reg != 0xFFFF) ++ break; ++ mdelay(1); ++ } ++ ++ if (phy_reg <= 0 || phy_reg == 0xFFFF) ++ return 0; ++ ++ phy_id = (phy_reg & 0xffff) << 16; ++ ++ phy_reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2); ++ if (phy_reg < 0) ++ return 0; ++ ++ phy_id |= (phy_reg & 0xffff); ++ ++ return phy_id; ++} ++ ++static u32 asix_get_link(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ return mii_link_ok(&dev->mii); ++} ++ ++static int asix_ioctl (struct net_device *net, struct ifreq *rq, int cmd) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); ++} ++ ++/* We need to override some ethtool_ops so we require our ++ own structure so we don't interfere with other usbnet ++ devices that may be connected at the same time. */ ++static const struct ethtool_ops ax88172_ethtool_ops = { ++ .get_drvinfo = asix_get_drvinfo, ++ .get_link = asix_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_wol = asix_get_wol, ++ .set_wol = asix_set_wol, ++ .get_eeprom_len = asix_get_eeprom_len, ++ .get_eeprom = asix_get_eeprom, ++ .set_eeprom = asix_set_eeprom, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .nway_reset = usbnet_nway_reset, ++}; ++ ++static void ax88172_set_multicast(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ u8 rx_ctl = 0x8c; ++ ++ if (net->flags & IFF_PROMISC) { ++ rx_ctl |= 0x01; ++ } else if (net->flags & IFF_ALLMULTI || ++ netdev_mc_count(net) > AX_MAX_MCAST) { ++ rx_ctl |= 0x02; ++ } else if (netdev_mc_empty(net)) { ++ /* just broadcast and directed */ ++ } else { ++ /* We use the 20 byte dev->data ++ * for our 8 byte filter buffer ++ * to avoid allocating memory that ++ * is tricky to free later */ ++ struct netdev_hw_addr *ha; ++ u32 crc_bits; ++ ++ memset(data->multi_filter, 0, AX_MCAST_FILTER_SIZE); ++ ++ /* Build the multicast hash filter. */ ++ netdev_for_each_mc_addr(ha, net) { ++ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; ++ data->multi_filter[crc_bits >> 3] |= ++ 1 << (crc_bits & 7); ++ } ++ ++ asix_write_cmd_async(dev, AX_CMD_WRITE_MULTI_FILTER, 0, 0, ++ AX_MCAST_FILTER_SIZE, data->multi_filter); ++ ++ rx_ctl |= 0x10; ++ } ++ ++ asix_write_cmd_async(dev, AX_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); ++} ++ ++static int ax88172_link_reset(struct usbnet *dev) ++{ ++ u8 mode; ++ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; ++ ++ mii_check_media(&dev->mii, 1, 1); ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ mode = AX88172_MEDIUM_DEFAULT; ++ ++ if (ecmd.duplex != DUPLEX_FULL) ++ mode |= ~AX88172_MEDIUM_FD; ++ ++ netdev_dbg(dev->net, "ax88172_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", ++ ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); ++ ++ asix_write_medium_mode(dev, mode); ++ ++ return 0; ++} ++ ++static const struct net_device_ops ax88172_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_set_mac_address = eth_mac_addr, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = asix_ioctl, ++ .ndo_set_rx_mode = ax88172_set_multicast, ++}; ++ ++static int ax88172_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int ret = 0; ++ u8 buf[ETH_ALEN]; ++ int i; ++ unsigned long gpio_bits = dev->driver_info->data; ++ ++ usbnet_get_endpoints(dev,intf); ++ ++ /* Toggle the GPIOs in a manufacturer/model specific way */ ++ for (i = 2; i >= 0; i--) { ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_GPIOS, ++ (gpio_bits >> (i * 8)) & 0xff, 0, 0, NULL); ++ if (ret < 0) ++ goto out; ++ msleep(5); ++ } ++ ++ ret = asix_write_rx_ctl(dev, 0x80); ++ if (ret < 0) ++ goto out; ++ ++ /* Get the MAC address */ ++ ret = asix_read_cmd(dev, AX88172_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "read AX_CMD_READ_NODE_ID failed: %d\n", ++ ret); ++ goto out; ++ } ++ ++ asix_set_netdev_dev_addr(dev, buf); ++ ++ /* Initialize MII structure */ ++ dev->mii.dev = dev->net; ++ dev->mii.mdio_read = asix_mdio_read; ++ dev->mii.mdio_write = asix_mdio_write; ++ dev->mii.phy_id_mask = 0x3f; ++ dev->mii.reg_num_mask = 0x1f; ++ dev->mii.phy_id = asix_get_phy_addr(dev); ++ ++ dev->net->netdev_ops = &ax88172_netdev_ops; ++ dev->net->ethtool_ops = &ax88172_ethtool_ops; ++ dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */ ++ dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */ ++ ++ asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); ++ asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, ++ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); ++ mii_nway_restart(&dev->mii); ++ ++ return 0; ++ ++out: ++ return ret; ++} ++ ++static const struct ethtool_ops ax88772_ethtool_ops = { ++ .get_drvinfo = asix_get_drvinfo, ++ .get_link = asix_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_wol = asix_get_wol, ++ .set_wol = asix_set_wol, ++ .get_eeprom_len = asix_get_eeprom_len, ++ .get_eeprom = asix_get_eeprom, ++ .set_eeprom = asix_set_eeprom, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .nway_reset = usbnet_nway_reset, ++}; ++ ++static int ax88772_link_reset(struct usbnet *dev) ++{ ++ u16 mode; ++ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; ++ ++ mii_check_media(&dev->mii, 1, 1); ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ mode = AX88772_MEDIUM_DEFAULT; ++ ++ if (ethtool_cmd_speed(&ecmd) != SPEED_100) ++ mode &= ~AX_MEDIUM_PS; ++ ++ if (ecmd.duplex != DUPLEX_FULL) ++ mode &= ~AX_MEDIUM_FD; ++ ++ netdev_dbg(dev->net, "ax88772_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", ++ ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); ++ ++ asix_write_medium_mode(dev, mode); ++ ++ return 0; ++} ++ ++static int ax88772_reset(struct usbnet *dev) ++{ ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ int ret, embd_phy; ++ u16 rx_ctl; ++ ++ ret = asix_write_gpio(dev, ++ AX_GPIO_RSE | AX_GPIO_GPO_2 | AX_GPIO_GPO2EN, 5); ++ if (ret < 0) ++ goto out; ++ ++ embd_phy = ((asix_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0); ++ ++ ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); ++ goto out; ++ } ++ ++ ret = asix_sw_reset(dev, AX_SWRESET_IPPD | AX_SWRESET_PRL); ++ if (ret < 0) ++ goto out; ++ ++ msleep(150); ++ ++ ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); ++ if (ret < 0) ++ goto out; ++ ++ msleep(150); ++ ++ if (embd_phy) { ++ ret = asix_sw_reset(dev, AX_SWRESET_IPRL); ++ if (ret < 0) ++ goto out; ++ } else { ++ ret = asix_sw_reset(dev, AX_SWRESET_PRTE); ++ if (ret < 0) ++ goto out; ++ } ++ ++ msleep(150); ++ rx_ctl = asix_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); ++ ret = asix_write_rx_ctl(dev, 0x0000); ++ if (ret < 0) ++ goto out; ++ ++ rx_ctl = asix_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); ++ ++ ret = asix_sw_reset(dev, AX_SWRESET_PRL); ++ if (ret < 0) ++ goto out; ++ ++ msleep(150); ++ ++ ret = asix_sw_reset(dev, AX_SWRESET_IPRL | AX_SWRESET_PRL); ++ if (ret < 0) ++ goto out; ++ ++ msleep(150); ++ ++ asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); ++ asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, ++ ADVERTISE_ALL | ADVERTISE_CSMA); ++ mii_nway_restart(&dev->mii); ++ ++ ret = asix_write_medium_mode(dev, AX88772_MEDIUM_DEFAULT); ++ if (ret < 0) ++ goto out; ++ ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, ++ AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, ++ AX88772_IPG2_DEFAULT, 0, NULL); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); ++ goto out; ++ } ++ ++ /* Rewrite MAC address */ ++ memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, ++ data->mac_addr); ++ if (ret < 0) ++ goto out; ++ ++ /* Set RX_CTL to default values with 2k buffer, and enable cactus */ ++ ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); ++ if (ret < 0) ++ goto out; ++ ++ rx_ctl = asix_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", ++ rx_ctl); ++ ++ rx_ctl = asix_read_medium_status(dev); ++ netdev_dbg(dev->net, ++ "Medium Status is 0x%04x after all initializations\n", ++ rx_ctl); ++ ++ return 0; ++ ++out: ++ return ret; ++ ++} ++ ++static const struct net_device_ops ax88772_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_set_mac_address = asix_set_mac_address, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = asix_ioctl, ++ .ndo_set_rx_mode = asix_set_multicast, ++}; ++ ++static int ax88772_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int ret, embd_phy, i; ++ u8 buf[ETH_ALEN]; ++ u32 phyid; ++ ++ usbnet_get_endpoints(dev,intf); ++ ++ /* Get the MAC address */ ++ if (dev->driver_info->data & FLAG_EEPROM_MAC) { ++ for (i = 0; i < (ETH_ALEN >> 1); i++) { ++ ret = asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x04 + i, ++ 0, 2, buf + i * 2); ++ if (ret < 0) ++ break; ++ } ++ } else { ++ ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, ++ 0, 0, ETH_ALEN, buf); ++ } ++ ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); ++ return ret; ++ } ++ ++ asix_set_netdev_dev_addr(dev, buf); ++ ++ /* Initialize MII structure */ ++ dev->mii.dev = dev->net; ++ dev->mii.mdio_read = asix_mdio_read; ++ dev->mii.mdio_write = asix_mdio_write; ++ dev->mii.phy_id_mask = 0x1f; ++ dev->mii.reg_num_mask = 0x1f; ++ dev->mii.phy_id = asix_get_phy_addr(dev); ++ ++ dev->net->netdev_ops = &ax88772_netdev_ops; ++ dev->net->ethtool_ops = &ax88772_ethtool_ops; ++ dev->net->needed_headroom = 4; /* cf asix_tx_fixup() */ ++ dev->net->needed_tailroom = 4; /* cf asix_tx_fixup() */ ++ ++ embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0); ++ ++ /* Reset the PHY to normal operation mode */ ++ ret = asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); ++ return ret; ++ } ++ ++ ax88772_reset(dev); ++ ++ /* Read PHYID register *AFTER* the PHY was reset properly */ ++ phyid = asix_get_phyid(dev); ++ netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid); ++ ++ /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ ++ if (dev->driver_info->flags & FLAG_FRAMING_AX) { ++ /* hard_mtu is still the default - the device does not support ++ jumbo eth frames */ ++ dev->rx_urb_size = 2048; ++ } ++ ++ dev->driver_priv = kzalloc(sizeof(struct asix_common_private), GFP_KERNEL); ++ if (!dev->driver_priv) ++ return -ENOMEM; ++ ++ return 0; ++} ++ ++static void ax88772_unbind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ kfree(dev->driver_priv); ++} ++ ++static const struct ethtool_ops ax88178_ethtool_ops = { ++ .get_drvinfo = asix_get_drvinfo, ++ .get_link = asix_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_wol = asix_get_wol, ++ .set_wol = asix_set_wol, ++ .get_eeprom_len = asix_get_eeprom_len, ++ .get_eeprom = asix_get_eeprom, ++ .set_eeprom = asix_set_eeprom, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .nway_reset = usbnet_nway_reset, ++}; ++ ++static int marvell_phy_init(struct usbnet *dev) ++{ ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ u16 reg; ++ ++ netdev_dbg(dev->net, "marvell_phy_init()\n"); ++ ++ reg = asix_mdio_read(dev->net, dev->mii.phy_id, MII_MARVELL_STATUS); ++ netdev_dbg(dev->net, "MII_MARVELL_STATUS = 0x%04x\n", reg); ++ ++ asix_mdio_write(dev->net, dev->mii.phy_id, MII_MARVELL_CTRL, ++ MARVELL_CTRL_RXDELAY | MARVELL_CTRL_TXDELAY); ++ ++ if (data->ledmode) { ++ reg = asix_mdio_read(dev->net, dev->mii.phy_id, ++ MII_MARVELL_LED_CTRL); ++ netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (1) = 0x%04x\n", reg); ++ ++ reg &= 0xf8ff; ++ reg |= (1 + 0x0100); ++ asix_mdio_write(dev->net, dev->mii.phy_id, ++ MII_MARVELL_LED_CTRL, reg); ++ ++ reg = asix_mdio_read(dev->net, dev->mii.phy_id, ++ MII_MARVELL_LED_CTRL); ++ netdev_dbg(dev->net, "MII_MARVELL_LED_CTRL (2) = 0x%04x\n", reg); ++ reg &= 0xfc0f; ++ } ++ ++ return 0; ++} ++ ++static int rtl8211cl_phy_init(struct usbnet *dev) ++{ ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ ++ netdev_dbg(dev->net, "rtl8211cl_phy_init()\n"); ++ ++ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0005); ++ asix_mdio_write (dev->net, dev->mii.phy_id, 0x0c, 0); ++ asix_mdio_write (dev->net, dev->mii.phy_id, 0x01, ++ asix_mdio_read (dev->net, dev->mii.phy_id, 0x01) | 0x0080); ++ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0); ++ ++ if (data->ledmode == 12) { ++ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0x0002); ++ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1a, 0x00cb); ++ asix_mdio_write (dev->net, dev->mii.phy_id, 0x1f, 0); ++ } ++ ++ return 0; ++} ++ ++static int marvell_led_status(struct usbnet *dev, u16 speed) ++{ ++ u16 reg = asix_mdio_read(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL); ++ ++ netdev_dbg(dev->net, "marvell_led_status() read 0x%04x\n", reg); ++ ++ /* Clear out the center LED bits - 0x03F0 */ ++ reg &= 0xfc0f; ++ ++ switch (speed) { ++ case SPEED_1000: ++ reg |= 0x03e0; ++ break; ++ case SPEED_100: ++ reg |= 0x03b0; ++ break; ++ default: ++ reg |= 0x02f0; ++ } ++ ++ netdev_dbg(dev->net, "marvell_led_status() writing 0x%04x\n", reg); ++ asix_mdio_write(dev->net, dev->mii.phy_id, MARVELL_LED_MANUAL, reg); ++ ++ return 0; ++} ++ ++static int ax88178_reset(struct usbnet *dev) ++{ ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ int ret; ++ __le16 eeprom; ++ u8 status; ++ int gpio0 = 0; ++ u32 phyid; ++ ++ asix_read_cmd(dev, AX_CMD_READ_GPIOS, 0, 0, 1, &status); ++ netdev_dbg(dev->net, "GPIO Status: 0x%04x\n", status); ++ ++ asix_write_cmd(dev, AX_CMD_WRITE_ENABLE, 0, 0, 0, NULL); ++ asix_read_cmd(dev, AX_CMD_READ_EEPROM, 0x0017, 0, 2, &eeprom); ++ asix_write_cmd(dev, AX_CMD_WRITE_DISABLE, 0, 0, 0, NULL); ++ ++ netdev_dbg(dev->net, "EEPROM index 0x17 is 0x%04x\n", eeprom); ++ ++ if (eeprom == cpu_to_le16(0xffff)) { ++ data->phymode = PHY_MODE_MARVELL; ++ data->ledmode = 0; ++ gpio0 = 1; ++ } else { ++ data->phymode = le16_to_cpu(eeprom) & 0x7F; ++ data->ledmode = le16_to_cpu(eeprom) >> 8; ++ gpio0 = (le16_to_cpu(eeprom) & 0x80) ? 0 : 1; ++ } ++ netdev_dbg(dev->net, "GPIO0: %d, PhyMode: %d\n", gpio0, data->phymode); ++ ++ /* Power up external GigaPHY through AX88178 GPIO pin */ ++ asix_write_gpio(dev, AX_GPIO_RSE | AX_GPIO_GPO_1 | AX_GPIO_GPO1EN, 40); ++ if ((le16_to_cpu(eeprom) >> 8) != 1) { ++ asix_write_gpio(dev, 0x003c, 30); ++ asix_write_gpio(dev, 0x001c, 300); ++ asix_write_gpio(dev, 0x003c, 30); ++ } else { ++ netdev_dbg(dev->net, "gpio phymode == 1 path\n"); ++ asix_write_gpio(dev, AX_GPIO_GPO1EN, 30); ++ asix_write_gpio(dev, AX_GPIO_GPO1EN | AX_GPIO_GPO_1, 30); ++ } ++ ++ /* Read PHYID register *AFTER* powering up PHY */ ++ phyid = asix_get_phyid(dev); ++ netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid); ++ ++ /* Set AX88178 to enable MII/GMII/RGMII interface for external PHY */ ++ asix_write_cmd(dev, AX_CMD_SW_PHY_SELECT, 0, 0, 0, NULL); ++ ++ asix_sw_reset(dev, 0); ++ msleep(150); ++ ++ asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD); ++ msleep(150); ++ ++ asix_write_rx_ctl(dev, 0); ++ ++ if (data->phymode == PHY_MODE_MARVELL) { ++ marvell_phy_init(dev); ++ msleep(60); ++ } else if (data->phymode == PHY_MODE_RTL8211CL) ++ rtl8211cl_phy_init(dev); ++ ++ asix_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, ++ BMCR_RESET | BMCR_ANENABLE); ++ asix_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, ++ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); ++ asix_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000, ++ ADVERTISE_1000FULL); ++ ++ mii_nway_restart(&dev->mii); ++ ++ ret = asix_write_medium_mode(dev, AX88178_MEDIUM_DEFAULT); ++ if (ret < 0) ++ return ret; ++ ++ /* Rewrite MAC address */ ++ memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, ++ data->mac_addr); ++ if (ret < 0) ++ return ret; ++ ++ ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); ++ if (ret < 0) ++ return ret; ++ ++ return 0; ++} ++ ++static int ax88178_link_reset(struct usbnet *dev) ++{ ++ u16 mode; ++ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ u32 speed; ++ ++ netdev_dbg(dev->net, "ax88178_link_reset()\n"); ++ ++ mii_check_media(&dev->mii, 1, 1); ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ mode = AX88178_MEDIUM_DEFAULT; ++ speed = ethtool_cmd_speed(&ecmd); ++ ++ if (speed == SPEED_1000) ++ mode |= AX_MEDIUM_GM; ++ else if (speed == SPEED_100) ++ mode |= AX_MEDIUM_PS; ++ else ++ mode &= ~(AX_MEDIUM_PS | AX_MEDIUM_GM); ++ ++ mode |= AX_MEDIUM_ENCK; ++ ++ if (ecmd.duplex == DUPLEX_FULL) ++ mode |= AX_MEDIUM_FD; ++ else ++ mode &= ~AX_MEDIUM_FD; ++ ++ netdev_dbg(dev->net, "ax88178_link_reset() speed: %u duplex: %d setting mode to 0x%04x\n", ++ speed, ecmd.duplex, mode); ++ ++ asix_write_medium_mode(dev, mode); ++ ++ if (data->phymode == PHY_MODE_MARVELL && data->ledmode) ++ marvell_led_status(dev, speed); ++ ++ return 0; ++} ++ ++static void ax88178_set_mfb(struct usbnet *dev) ++{ ++ u16 mfb = AX_RX_CTL_MFB_16384; ++ u16 rxctl; ++ u16 medium; ++ int old_rx_urb_size = dev->rx_urb_size; ++ ++ if (dev->hard_mtu < 2048) { ++ dev->rx_urb_size = 2048; ++ mfb = AX_RX_CTL_MFB_2048; ++ } else if (dev->hard_mtu < 4096) { ++ dev->rx_urb_size = 4096; ++ mfb = AX_RX_CTL_MFB_4096; ++ } else if (dev->hard_mtu < 8192) { ++ dev->rx_urb_size = 8192; ++ mfb = AX_RX_CTL_MFB_8192; ++ } else if (dev->hard_mtu < 16384) { ++ dev->rx_urb_size = 16384; ++ mfb = AX_RX_CTL_MFB_16384; ++ } ++ ++ rxctl = asix_read_rx_ctl(dev); ++ asix_write_rx_ctl(dev, (rxctl & ~AX_RX_CTL_MFB_16384) | mfb); ++ ++ medium = asix_read_medium_status(dev); ++ if (dev->net->mtu > 1500) ++ medium |= AX_MEDIUM_JFE; ++ else ++ medium &= ~AX_MEDIUM_JFE; ++ asix_write_medium_mode(dev, medium); ++ ++ if (dev->rx_urb_size > old_rx_urb_size) ++ usbnet_unlink_rx_urbs(dev); ++} ++ ++static int ax88178_change_mtu(struct net_device *net, int new_mtu) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ int ll_mtu = new_mtu + net->hard_header_len + 4; ++ ++ netdev_dbg(dev->net, "ax88178_change_mtu() new_mtu=%d\n", new_mtu); ++ ++ if (new_mtu <= 0 || ll_mtu > 16384) ++ return -EINVAL; ++ ++ if ((ll_mtu % dev->maxpacket) == 0) ++ return -EDOM; ++ ++ net->mtu = new_mtu; ++ dev->hard_mtu = net->mtu + net->hard_header_len; ++ ax88178_set_mfb(dev); ++ ++ /* max qlen depend on hard_mtu and rx_urb_size */ ++ usbnet_update_max_qlen(dev); ++ ++ return 0; ++} ++ ++static const struct net_device_ops ax88178_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_set_mac_address = asix_set_mac_address, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_set_rx_mode = asix_set_multicast, ++ .ndo_do_ioctl = asix_ioctl, ++ .ndo_change_mtu = ax88178_change_mtu, ++}; ++ ++static int ax88178_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int ret; ++ u8 buf[ETH_ALEN]; ++ ++ usbnet_get_endpoints(dev,intf); ++ ++ /* Get the MAC address */ ++ ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); ++ return ret; ++ } ++ ++ asix_set_netdev_dev_addr(dev, buf); ++ ++ /* Initialize MII structure */ ++ dev->mii.dev = dev->net; ++ dev->mii.mdio_read = asix_mdio_read; ++ dev->mii.mdio_write = asix_mdio_write; ++ dev->mii.phy_id_mask = 0x1f; ++ dev->mii.reg_num_mask = 0xff; ++ dev->mii.supports_gmii = 1; ++ dev->mii.phy_id = asix_get_phy_addr(dev); ++ ++ dev->net->netdev_ops = &ax88178_netdev_ops; ++ dev->net->ethtool_ops = &ax88178_ethtool_ops; ++ ++ /* Blink LEDS so users know driver saw dongle */ ++ asix_sw_reset(dev, 0); ++ msleep(150); ++ ++ asix_sw_reset(dev, AX_SWRESET_PRL | AX_SWRESET_IPPD); ++ msleep(150); ++ ++ /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ ++ if (dev->driver_info->flags & FLAG_FRAMING_AX) { ++ /* hard_mtu is still the default - the device does not support ++ jumbo eth frames */ ++ dev->rx_urb_size = 2048; ++ } ++ ++ dev->driver_priv = kzalloc(sizeof(struct asix_common_private), GFP_KERNEL); ++ if (!dev->driver_priv) ++ return -ENOMEM; ++ ++ return 0; ++} ++ ++static const struct driver_info ax8817x_info = { ++ .description = "ASIX AX8817x USB 2.0 Ethernet", ++ .bind = ax88172_bind, ++ .status = asix_status, ++ .link_reset = ax88172_link_reset, ++ .reset = ax88172_link_reset, ++ .flags = FLAG_ETHER | FLAG_LINK_INTR, ++ .data = 0x00130103, ++}; ++ ++static const struct driver_info dlink_dub_e100_info = { ++ .description = "DLink DUB-E100 USB Ethernet", ++ .bind = ax88172_bind, ++ .status = asix_status, ++ .link_reset = ax88172_link_reset, ++ .reset = ax88172_link_reset, ++ .flags = FLAG_ETHER | FLAG_LINK_INTR, ++ .data = 0x009f9d9f, ++}; ++ ++static const struct driver_info netgear_fa120_info = { ++ .description = "Netgear FA-120 USB Ethernet", ++ .bind = ax88172_bind, ++ .status = asix_status, ++ .link_reset = ax88172_link_reset, ++ .reset = ax88172_link_reset, ++ .flags = FLAG_ETHER | FLAG_LINK_INTR, ++ .data = 0x00130103, ++}; ++ ++static const struct driver_info hawking_uf200_info = { ++ .description = "Hawking UF200 USB Ethernet", ++ .bind = ax88172_bind, ++ .status = asix_status, ++ .link_reset = ax88172_link_reset, ++ .reset = ax88172_link_reset, ++ .flags = FLAG_ETHER | FLAG_LINK_INTR, ++ .data = 0x001f1d1f, ++}; ++ ++static const struct driver_info ax88772_info = { ++ .description = "ASIX AX88772 USB 2.0 Ethernet", ++ .bind = ax88772_bind, ++ .unbind = ax88772_unbind, ++ .status = asix_status, ++ .link_reset = ax88772_link_reset, ++ .reset = ax88772_link_reset, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET, ++ .rx_fixup = asix_rx_fixup_common, ++ .tx_fixup = asix_tx_fixup, ++}; ++ ++static const struct driver_info ax88772b_info = { ++ .description = "ASIX AX88772B USB 2.0 Ethernet", ++ .bind = ax88772_bind, ++ .unbind = ax88772_unbind, ++ .status = asix_status, ++ .link_reset = ax88772_link_reset, ++ .reset = ax88772_reset, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | ++ FLAG_MULTI_PACKET, ++ .rx_fixup = asix_rx_fixup_common, ++ .tx_fixup = asix_tx_fixup, ++ .data = FLAG_EEPROM_MAC, ++}; ++ ++static const struct driver_info ax88178_info = { ++ .description = "ASIX AX88178 USB 2.0 Ethernet", ++ .bind = ax88178_bind, ++ .unbind = ax88772_unbind, ++ .status = asix_status, ++ .link_reset = ax88178_link_reset, ++ .reset = ax88178_reset, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | ++ FLAG_MULTI_PACKET, ++ .rx_fixup = asix_rx_fixup_common, ++ .tx_fixup = asix_tx_fixup, ++}; ++ ++/* ++ * USBLINK 20F9 "USB 2.0 LAN" USB ethernet adapter, typically found in ++ * no-name packaging. ++ * USB device strings are: ++ * 1: Manufacturer: USBLINK ++ * 2: Product: HG20F9 USB2.0 ++ * 3: Serial: 000003 ++ * Appears to be compatible with Asix 88772B. ++ */ ++static const struct driver_info hg20f9_info = { ++ .description = "HG20F9 USB 2.0 Ethernet", ++ .bind = ax88772_bind, ++ .unbind = ax88772_unbind, ++ .status = asix_status, ++ .link_reset = ax88772_link_reset, ++ .reset = ax88772_reset, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | ++ FLAG_MULTI_PACKET, ++ .rx_fixup = asix_rx_fixup_common, ++ .tx_fixup = asix_tx_fixup, ++ .data = FLAG_EEPROM_MAC, ++}; ++ ++static const struct usb_device_id products [] = { ++{ ++ // Linksys USB200M ++ USB_DEVICE (0x077b, 0x2226), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // Netgear FA120 ++ USB_DEVICE (0x0846, 0x1040), ++ .driver_info = (unsigned long) &netgear_fa120_info, ++}, { ++ // DLink DUB-E100 ++ USB_DEVICE (0x2001, 0x1a00), ++ .driver_info = (unsigned long) &dlink_dub_e100_info, ++}, { ++ // Intellinet, ST Lab USB Ethernet ++ USB_DEVICE (0x0b95, 0x1720), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // Hawking UF200, TrendNet TU2-ET100 ++ USB_DEVICE (0x07b8, 0x420a), ++ .driver_info = (unsigned long) &hawking_uf200_info, ++}, { ++ // Billionton Systems, USB2AR ++ USB_DEVICE (0x08dd, 0x90ff), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // ATEN UC210T ++ USB_DEVICE (0x0557, 0x2009), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // Buffalo LUA-U2-KTX ++ USB_DEVICE (0x0411, 0x003d), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // Buffalo LUA-U2-GT 10/100/1000 ++ USB_DEVICE (0x0411, 0x006e), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // Sitecom LN-029 "USB 2.0 10/100 Ethernet adapter" ++ USB_DEVICE (0x6189, 0x182d), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // Sitecom LN-031 "USB 2.0 10/100/1000 Ethernet adapter" ++ USB_DEVICE (0x0df6, 0x0056), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // Sitecom LN-028 "USB 2.0 10/100/1000 Ethernet adapter" ++ USB_DEVICE (0x0df6, 0x061c), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // corega FEther USB2-TX ++ USB_DEVICE (0x07aa, 0x0017), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // Surecom EP-1427X-2 ++ USB_DEVICE (0x1189, 0x0893), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // goodway corp usb gwusb2e ++ USB_DEVICE (0x1631, 0x6200), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // JVC MP-PRX1 Port Replicator ++ USB_DEVICE (0x04f1, 0x3008), ++ .driver_info = (unsigned long) &ax8817x_info, ++}, { ++ // Lenovo U2L100P 10/100 ++ USB_DEVICE (0x17ef, 0x7203), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // ASIX AX88772B 10/100 ++ USB_DEVICE (0x0b95, 0x772b), ++ .driver_info = (unsigned long) &ax88772b_info, ++}, { ++ // ASIX AX88772 10/100 ++ USB_DEVICE (0x0b95, 0x7720), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // ASIX AX88178 10/100/1000 ++ USB_DEVICE (0x0b95, 0x1780), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // Logitec LAN-GTJ/U2A ++ USB_DEVICE (0x0789, 0x0160), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // Linksys USB200M Rev 2 ++ USB_DEVICE (0x13b1, 0x0018), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // 0Q0 cable ethernet ++ USB_DEVICE (0x1557, 0x7720), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // DLink DUB-E100 H/W Ver B1 ++ USB_DEVICE (0x07d1, 0x3c05), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // DLink DUB-E100 H/W Ver B1 Alternate ++ USB_DEVICE (0x2001, 0x3c05), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // DLink DUB-E100 H/W Ver C1 ++ USB_DEVICE (0x2001, 0x1a02), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // Linksys USB1000 ++ USB_DEVICE (0x1737, 0x0039), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // IO-DATA ETG-US2 ++ USB_DEVICE (0x04bb, 0x0930), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // Belkin F5D5055 ++ USB_DEVICE(0x050d, 0x5055), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // Apple USB Ethernet Adapter ++ USB_DEVICE(0x05ac, 0x1402), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // Cables-to-Go USB Ethernet Adapter ++ USB_DEVICE(0x0b95, 0x772a), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // ABOCOM for pci ++ USB_DEVICE(0x14ea, 0xab11), ++ .driver_info = (unsigned long) &ax88178_info, ++}, { ++ // ASIX 88772a ++ USB_DEVICE(0x0db0, 0xa877), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ // Asus USB Ethernet Adapter ++ USB_DEVICE (0x0b95, 0x7e2b), ++ .driver_info = (unsigned long) &ax88772_info, ++}, { ++ /* ASIX 88172a demo board */ ++ USB_DEVICE(0x0b95, 0x172a), ++ .driver_info = (unsigned long) &ax88172a_info, ++}, { ++ /* ++ * USBLINK HG20F9 "USB 2.0 LAN" ++ * Appears to have gazumped Linksys's manufacturer ID but ++ * doesn't (yet) conflict with any known Linksys product. ++ */ ++ USB_DEVICE(0x066b, 0x20f9), ++ .driver_info = (unsigned long) &hg20f9_info, ++}, ++ { }, // END ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver asix_driver = { ++ .name = DRIVER_NAME, ++ .id_table = products, ++ .probe = usbnet_probe, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disconnect = usbnet_disconnect, ++ .supports_autosuspend = 1, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(asix_driver); ++ ++MODULE_AUTHOR("David Hollis"); ++MODULE_VERSION(DRIVER_VERSION); ++MODULE_DESCRIPTION("ASIX AX8817X based USB 2.0 Ethernet Devices"); ++MODULE_LICENSE("GPL"); ++ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/asix.h backports-4.2.6-1/drivers/net/usb/asix.h +--- backports-4.2.6-1.org/drivers/net/usb/asix.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/asix.h 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,234 @@ ++/* ++ * ASIX AX8817X based USB 2.0 Ethernet Devices ++ * Copyright (C) 2003-2006 David Hollis dhollis@davehollis.com ++ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net ++ * Copyright (C) 2006 James Painter jamie.painter@iname.com ++ * Copyright (c) 2002-2003 TiVo Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#ifndef _ASIX_H ++#define _ASIX_H ++ ++// #define DEBUG // error path messages, extra info ++// #define VERBOSE // more; success messages ++ ++#include <linux/module.h> ++#include <linux/kmod.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/crc32.h> ++#include <linux/usb/usbnet.h> ++#include <linux/slab.h> ++#include <linux/if_vlan.h> ++ ++#define DRIVER_VERSION "22-Dec-2011" ++#define DRIVER_NAME "asix" ++ ++/* ASIX AX8817X based USB 2.0 Ethernet Devices */ ++ ++#define AX_CMD_SET_SW_MII 0x06 ++#define AX_CMD_READ_MII_REG 0x07 ++#define AX_CMD_WRITE_MII_REG 0x08 ++#define AX_CMD_SET_HW_MII 0x0a ++#define AX_CMD_READ_EEPROM 0x0b ++#define AX_CMD_WRITE_EEPROM 0x0c ++#define AX_CMD_WRITE_ENABLE 0x0d ++#define AX_CMD_WRITE_DISABLE 0x0e ++#define AX_CMD_READ_RX_CTL 0x0f ++#define AX_CMD_WRITE_RX_CTL 0x10 ++#define AX_CMD_READ_IPG012 0x11 ++#define AX_CMD_WRITE_IPG0 0x12 ++#define AX_CMD_WRITE_IPG1 0x13 ++#define AX_CMD_READ_NODE_ID 0x13 ++#define AX_CMD_WRITE_NODE_ID 0x14 ++#define AX_CMD_WRITE_IPG2 0x14 ++#define AX_CMD_WRITE_MULTI_FILTER 0x16 ++#define AX88172_CMD_READ_NODE_ID 0x17 ++#define AX_CMD_READ_PHY_ID 0x19 ++#define AX_CMD_READ_MEDIUM_STATUS 0x1a ++#define AX_CMD_WRITE_MEDIUM_MODE 0x1b ++#define AX_CMD_READ_MONITOR_MODE 0x1c ++#define AX_CMD_WRITE_MONITOR_MODE 0x1d ++#define AX_CMD_READ_GPIOS 0x1e ++#define AX_CMD_WRITE_GPIOS 0x1f ++#define AX_CMD_SW_RESET 0x20 ++#define AX_CMD_SW_PHY_STATUS 0x21 ++#define AX_CMD_SW_PHY_SELECT 0x22 ++ ++#define AX_PHY_SELECT_MASK (BIT(3) | BIT(2)) ++#define AX_PHY_SELECT_INTERNAL 0 ++#define AX_PHY_SELECT_EXTERNAL BIT(2) ++ ++#define AX_MONITOR_MODE 0x01 ++#define AX_MONITOR_LINK 0x02 ++#define AX_MONITOR_MAGIC 0x04 ++#define AX_MONITOR_HSFS 0x10 ++ ++/* AX88172 Medium Status Register values */ ++#define AX88172_MEDIUM_FD 0x02 ++#define AX88172_MEDIUM_TX 0x04 ++#define AX88172_MEDIUM_FC 0x10 ++#define AX88172_MEDIUM_DEFAULT \ ++ ( AX88172_MEDIUM_FD | AX88172_MEDIUM_TX | AX88172_MEDIUM_FC ) ++ ++#define AX_MCAST_FILTER_SIZE 8 ++#define AX_MAX_MCAST 64 ++ ++#define AX_SWRESET_CLEAR 0x00 ++#define AX_SWRESET_RR 0x01 ++#define AX_SWRESET_RT 0x02 ++#define AX_SWRESET_PRTE 0x04 ++#define AX_SWRESET_PRL 0x08 ++#define AX_SWRESET_BZ 0x10 ++#define AX_SWRESET_IPRL 0x20 ++#define AX_SWRESET_IPPD 0x40 ++ ++#define AX88772_IPG0_DEFAULT 0x15 ++#define AX88772_IPG1_DEFAULT 0x0c ++#define AX88772_IPG2_DEFAULT 0x12 ++ ++/* AX88772 & AX88178 Medium Mode Register */ ++#define AX_MEDIUM_PF 0x0080 ++#define AX_MEDIUM_JFE 0x0040 ++#define AX_MEDIUM_TFC 0x0020 ++#define AX_MEDIUM_RFC 0x0010 ++#define AX_MEDIUM_ENCK 0x0008 ++#define AX_MEDIUM_AC 0x0004 ++#define AX_MEDIUM_FD 0x0002 ++#define AX_MEDIUM_GM 0x0001 ++#define AX_MEDIUM_SM 0x1000 ++#define AX_MEDIUM_SBP 0x0800 ++#define AX_MEDIUM_PS 0x0200 ++#define AX_MEDIUM_RE 0x0100 ++ ++#define AX88178_MEDIUM_DEFAULT \ ++ (AX_MEDIUM_PS | AX_MEDIUM_FD | AX_MEDIUM_AC | \ ++ AX_MEDIUM_RFC | AX_MEDIUM_TFC | AX_MEDIUM_JFE | \ ++ AX_MEDIUM_RE) ++ ++#define AX88772_MEDIUM_DEFAULT \ ++ (AX_MEDIUM_FD | AX_MEDIUM_RFC | \ ++ AX_MEDIUM_TFC | AX_MEDIUM_PS | \ ++ AX_MEDIUM_AC | AX_MEDIUM_RE) ++ ++/* AX88772 & AX88178 RX_CTL values */ ++#define AX_RX_CTL_SO 0x0080 ++#define AX_RX_CTL_AP 0x0020 ++#define AX_RX_CTL_AM 0x0010 ++#define AX_RX_CTL_AB 0x0008 ++#define AX_RX_CTL_SEP 0x0004 ++#define AX_RX_CTL_AMALL 0x0002 ++#define AX_RX_CTL_PRO 0x0001 ++#define AX_RX_CTL_MFB_2048 0x0000 ++#define AX_RX_CTL_MFB_4096 0x0100 ++#define AX_RX_CTL_MFB_8192 0x0200 ++#define AX_RX_CTL_MFB_16384 0x0300 ++ ++#define AX_DEFAULT_RX_CTL (AX_RX_CTL_SO | AX_RX_CTL_AB) ++ ++/* GPIO 0 .. 2 toggles */ ++#define AX_GPIO_GPO0EN 0x01 /* GPIO0 Output enable */ ++#define AX_GPIO_GPO_0 0x02 /* GPIO0 Output value */ ++#define AX_GPIO_GPO1EN 0x04 /* GPIO1 Output enable */ ++#define AX_GPIO_GPO_1 0x08 /* GPIO1 Output value */ ++#define AX_GPIO_GPO2EN 0x10 /* GPIO2 Output enable */ ++#define AX_GPIO_GPO_2 0x20 /* GPIO2 Output value */ ++#define AX_GPIO_RESERVED 0x40 /* Reserved */ ++#define AX_GPIO_RSE 0x80 /* Reload serial EEPROM */ ++ ++#define AX_EEPROM_MAGIC 0xdeadbeef ++#define AX_EEPROM_LEN 0x200 ++ ++/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ ++struct asix_data { ++ u8 multi_filter[AX_MCAST_FILTER_SIZE]; ++ u8 mac_addr[ETH_ALEN]; ++ u8 phymode; ++ u8 ledmode; ++ u8 res; ++}; ++ ++struct asix_rx_fixup_info { ++ struct sk_buff *ax_skb; ++ u32 header; ++ u16 size; ++ bool split_head; ++}; ++ ++struct asix_common_private { ++ struct asix_rx_fixup_info rx_fixup_info; ++}; ++ ++extern const struct driver_info ax88172a_info; ++ ++/* ASIX specific flags */ ++#define FLAG_EEPROM_MAC (1UL << 0) /* init device MAC from eeprom */ ++ ++int asix_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data); ++ ++int asix_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data); ++ ++void asix_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, ++ u16 index, u16 size, void *data); ++ ++int asix_rx_fixup_internal(struct usbnet *dev, struct sk_buff *skb, ++ struct asix_rx_fixup_info *rx); ++int asix_rx_fixup_common(struct usbnet *dev, struct sk_buff *skb); ++ ++struct sk_buff *asix_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ++ gfp_t flags); ++ ++int asix_set_sw_mii(struct usbnet *dev); ++int asix_set_hw_mii(struct usbnet *dev); ++ ++int asix_read_phy_addr(struct usbnet *dev, int internal); ++int asix_get_phy_addr(struct usbnet *dev); ++ ++int asix_sw_reset(struct usbnet *dev, u8 flags); ++ ++u16 asix_read_rx_ctl(struct usbnet *dev); ++int asix_write_rx_ctl(struct usbnet *dev, u16 mode); ++ ++u16 asix_read_medium_status(struct usbnet *dev); ++int asix_write_medium_mode(struct usbnet *dev, u16 mode); ++ ++int asix_write_gpio(struct usbnet *dev, u16 value, int sleep); ++ ++void asix_set_multicast(struct net_device *net); ++ ++int asix_mdio_read(struct net_device *netdev, int phy_id, int loc); ++void asix_mdio_write(struct net_device *netdev, int phy_id, int loc, int val); ++ ++void asix_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo); ++int asix_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo); ++ ++int asix_get_eeprom_len(struct net_device *net); ++int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, ++ u8 *data); ++int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, ++ u8 *data); ++ ++void asix_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *info); ++ ++int asix_set_mac_address(struct net_device *net, void *p); ++ ++#endif /* _ASIX_H */ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/ax88172a.c backports-4.2.6-1/drivers/net/usb/ax88172a.c +--- backports-4.2.6-1.org/drivers/net/usb/ax88172a.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/ax88172a.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,422 @@ ++/* ++ * ASIX AX88172A based USB 2.0 Ethernet Devices ++ * Copyright (C) 2012 OMICRON electronics GmbH ++ * ++ * Supports external PHYs via phylib. Based on the driver for the ++ * AX88772. Original copyrights follow: ++ * ++ * Copyright (C) 2003-2006 David Hollis dhollis@davehollis.com ++ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net ++ * Copyright (C) 2006 James Painter jamie.painter@iname.com ++ * Copyright (c) 2002-2003 TiVo Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include "asix.h" ++#include <linux/phy.h> ++ ++struct ax88172a_private { ++ struct mii_bus *mdio; ++ struct phy_device *phydev; ++ char phy_name[20]; ++ u16 phy_addr; ++ u16 oldmode; ++ int use_embdphy; ++ struct asix_rx_fixup_info rx_fixup_info; ++}; ++ ++/* MDIO read and write wrappers for phylib */ ++static int asix_mdio_bus_read(struct mii_bus *bus, int phy_id, int regnum) ++{ ++ return asix_mdio_read(((struct usbnet *)bus->priv)->net, phy_id, ++ regnum); ++} ++ ++static int asix_mdio_bus_write(struct mii_bus *bus, int phy_id, int regnum, ++ u16 val) ++{ ++ asix_mdio_write(((struct usbnet *)bus->priv)->net, phy_id, regnum, val); ++ return 0; ++} ++ ++static int ax88172a_ioctl(struct net_device *net, struct ifreq *rq, int cmd) ++{ ++ if (!netif_running(net)) ++ return -EINVAL; ++ ++ if (!net->phydev) ++ return -ENODEV; ++ ++ return phy_mii_ioctl(net->phydev, rq, cmd); ++} ++ ++/* set MAC link settings according to information from phylib */ ++static void ax88172a_adjust_link(struct net_device *netdev) ++{ ++ struct phy_device *phydev = netdev->phydev; ++ struct usbnet *dev = netdev_priv(netdev); ++ struct ax88172a_private *priv = dev->driver_priv; ++ u16 mode = 0; ++ ++ if (phydev->link) { ++ mode = AX88772_MEDIUM_DEFAULT; ++ ++ if (phydev->duplex == DUPLEX_HALF) ++ mode &= ~AX_MEDIUM_FD; ++ ++ if (phydev->speed != SPEED_100) ++ mode &= ~AX_MEDIUM_PS; ++ } ++ ++ if (mode != priv->oldmode) { ++ asix_write_medium_mode(dev, mode); ++ priv->oldmode = mode; ++ netdev_dbg(netdev, "speed %u duplex %d, setting mode to 0x%04x\n", ++ phydev->speed, phydev->duplex, mode); ++ phy_print_status(phydev); ++ } ++} ++ ++static void ax88172a_status(struct usbnet *dev, struct urb *urb) ++{ ++ /* link changes are detected by polling the phy */ ++} ++ ++/* use phylib infrastructure */ ++static int ax88172a_init_mdio(struct usbnet *dev) ++{ ++ struct ax88172a_private *priv = dev->driver_priv; ++ int ret, i; ++ ++ priv->mdio = mdiobus_alloc(); ++ if (!priv->mdio) { ++ netdev_err(dev->net, "Could not allocate MDIO bus\n"); ++ return -ENOMEM; ++ } ++ ++ priv->mdio->priv = (void *)dev; ++ priv->mdio->read = &asix_mdio_bus_read; ++ priv->mdio->write = &asix_mdio_bus_write; ++ priv->mdio->name = "Asix MDIO Bus"; ++ /* mii bus name is usb-<usb bus number>-<usb device number> */ ++ snprintf(priv->mdio->id, MII_BUS_ID_SIZE, "usb-%03d:%03d", ++ dev->udev->bus->busnum, dev->udev->devnum); ++ ++ priv->mdio->irq = kzalloc(sizeof(int) * PHY_MAX_ADDR, GFP_KERNEL); ++ if (!priv->mdio->irq) { ++ ret = -ENOMEM; ++ goto mfree; ++ } ++ for (i = 0; i < PHY_MAX_ADDR; i++) ++ priv->mdio->irq[i] = PHY_POLL; ++ ++ ret = mdiobus_register(priv->mdio); ++ if (ret) { ++ netdev_err(dev->net, "Could not register MDIO bus\n"); ++ goto ifree; ++ } ++ ++ netdev_info(dev->net, "registered mdio bus %s\n", priv->mdio->id); ++ return 0; ++ ++ifree: ++ kfree(priv->mdio->irq); ++mfree: ++ mdiobus_free(priv->mdio); ++ return ret; ++} ++ ++static void ax88172a_remove_mdio(struct usbnet *dev) ++{ ++ struct ax88172a_private *priv = dev->driver_priv; ++ ++ netdev_info(dev->net, "deregistering mdio bus %s\n", priv->mdio->id); ++ mdiobus_unregister(priv->mdio); ++ kfree(priv->mdio->irq); ++ mdiobus_free(priv->mdio); ++} ++ ++static const struct net_device_ops ax88172a_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_set_mac_address = asix_set_mac_address, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = ax88172a_ioctl, ++ .ndo_set_rx_mode = asix_set_multicast, ++}; ++ ++static int ax88172a_get_settings(struct net_device *net, ++ struct ethtool_cmd *cmd) ++{ ++ if (!net->phydev) ++ return -ENODEV; ++ ++ return phy_ethtool_gset(net->phydev, cmd); ++} ++ ++static int ax88172a_set_settings(struct net_device *net, ++ struct ethtool_cmd *cmd) ++{ ++ if (!net->phydev) ++ return -ENODEV; ++ ++ return phy_ethtool_sset(net->phydev, cmd); ++} ++ ++static int ax88172a_nway_reset(struct net_device *net) ++{ ++ if (!net->phydev) ++ return -ENODEV; ++ ++ return phy_start_aneg(net->phydev); ++} ++ ++static const struct ethtool_ops ax88172a_ethtool_ops = { ++ .get_drvinfo = asix_get_drvinfo, ++ .get_link = usbnet_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_wol = asix_get_wol, ++ .set_wol = asix_set_wol, ++ .get_eeprom_len = asix_get_eeprom_len, ++ .get_eeprom = asix_get_eeprom, ++ .set_eeprom = asix_set_eeprom, ++ .get_settings = ax88172a_get_settings, ++ .set_settings = ax88172a_set_settings, ++ .nway_reset = ax88172a_nway_reset, ++}; ++ ++static int ax88172a_reset_phy(struct usbnet *dev, int embd_phy) ++{ ++ int ret; ++ ++ ret = asix_sw_reset(dev, AX_SWRESET_IPPD); ++ if (ret < 0) ++ goto err; ++ ++ msleep(150); ++ ret = asix_sw_reset(dev, AX_SWRESET_CLEAR); ++ if (ret < 0) ++ goto err; ++ ++ msleep(150); ++ ++ ret = asix_sw_reset(dev, embd_phy ? AX_SWRESET_IPRL : AX_SWRESET_IPPD); ++ if (ret < 0) ++ goto err; ++ ++ return 0; ++ ++err: ++ return ret; ++} ++ ++ ++static int ax88172a_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int ret; ++ u8 buf[ETH_ALEN]; ++ struct ax88172a_private *priv; ++ ++ usbnet_get_endpoints(dev, intf); ++ ++ priv = kzalloc(sizeof(*priv), GFP_KERNEL); ++ if (!priv) ++ return -ENOMEM; ++ ++ dev->driver_priv = priv; ++ ++ /* Get the MAC address */ ++ ret = asix_read_cmd(dev, AX_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, buf); ++ if (ret < 0) { ++ netdev_err(dev->net, "Failed to read MAC address: %d\n", ret); ++ goto free; ++ } ++ memcpy(dev->net->dev_addr, buf, ETH_ALEN); ++ ++ dev->net->netdev_ops = &ax88172a_netdev_ops; ++ dev->net->ethtool_ops = &ax88172a_ethtool_ops; ++ ++ /* are we using the internal or the external phy? */ ++ ret = asix_read_cmd(dev, AX_CMD_SW_PHY_STATUS, 0, 0, 1, buf); ++ if (ret < 0) { ++ netdev_err(dev->net, "Failed to read software interface selection register: %d\n", ++ ret); ++ goto free; ++ } ++ ++ netdev_dbg(dev->net, "AX_CMD_SW_PHY_STATUS = 0x%02x\n", buf[0]); ++ switch (buf[0] & AX_PHY_SELECT_MASK) { ++ case AX_PHY_SELECT_INTERNAL: ++ netdev_dbg(dev->net, "use internal phy\n"); ++ priv->use_embdphy = 1; ++ break; ++ case AX_PHY_SELECT_EXTERNAL: ++ netdev_dbg(dev->net, "use external phy\n"); ++ priv->use_embdphy = 0; ++ break; ++ default: ++ netdev_err(dev->net, "Interface mode not supported by driver\n"); ++ ret = -ENOTSUPP; ++ goto free; ++ } ++ ++ priv->phy_addr = asix_read_phy_addr(dev, priv->use_embdphy); ++ ax88172a_reset_phy(dev, priv->use_embdphy); ++ ++ /* Asix framing packs multiple eth frames into a 2K usb bulk transfer */ ++ if (dev->driver_info->flags & FLAG_FRAMING_AX) { ++ /* hard_mtu is still the default - the device does not support ++ jumbo eth frames */ ++ dev->rx_urb_size = 2048; ++ } ++ ++ /* init MDIO bus */ ++ ret = ax88172a_init_mdio(dev); ++ if (ret) ++ goto free; ++ ++ return 0; ++ ++free: ++ kfree(priv); ++ return ret; ++} ++ ++static int ax88172a_stop(struct usbnet *dev) ++{ ++ struct ax88172a_private *priv = dev->driver_priv; ++ ++ netdev_dbg(dev->net, "Stopping interface\n"); ++ ++ if (priv->phydev) { ++ netdev_info(dev->net, "Disconnecting from phy %s\n", ++ priv->phy_name); ++ phy_stop(priv->phydev); ++ phy_disconnect(priv->phydev); ++ } ++ ++ return 0; ++} ++ ++static void ax88172a_unbind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ struct ax88172a_private *priv = dev->driver_priv; ++ ++ ax88172a_remove_mdio(dev); ++ kfree(priv); ++} ++ ++static int ax88172a_reset(struct usbnet *dev) ++{ ++ struct asix_data *data = (struct asix_data *)&dev->data; ++ struct ax88172a_private *priv = dev->driver_priv; ++ int ret; ++ u16 rx_ctl; ++ ++ ax88172a_reset_phy(dev, priv->use_embdphy); ++ ++ msleep(150); ++ rx_ctl = asix_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); ++ ret = asix_write_rx_ctl(dev, 0x0000); ++ if (ret < 0) ++ goto out; ++ ++ rx_ctl = asix_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); ++ ++ msleep(150); ++ ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_IPG0, ++ AX88772_IPG0_DEFAULT | AX88772_IPG1_DEFAULT, ++ AX88772_IPG2_DEFAULT, 0, NULL); ++ if (ret < 0) { ++ netdev_err(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); ++ goto out; ++ } ++ ++ /* Rewrite MAC address */ ++ memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); ++ ret = asix_write_cmd(dev, AX_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, ++ data->mac_addr); ++ if (ret < 0) ++ goto out; ++ ++ /* Set RX_CTL to default values with 2k buffer, and enable cactus */ ++ ret = asix_write_rx_ctl(dev, AX_DEFAULT_RX_CTL); ++ if (ret < 0) ++ goto out; ++ ++ rx_ctl = asix_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", ++ rx_ctl); ++ ++ rx_ctl = asix_read_medium_status(dev); ++ netdev_dbg(dev->net, "Medium Status is 0x%04x after all initializations\n", ++ rx_ctl); ++ ++ /* Connect to PHY */ ++ snprintf(priv->phy_name, 20, PHY_ID_FMT, ++ priv->mdio->id, priv->phy_addr); ++ ++ priv->phydev = phy_connect(dev->net, priv->phy_name, ++ &ax88172a_adjust_link, ++ PHY_INTERFACE_MODE_MII); ++ if (IS_ERR(priv->phydev)) { ++ netdev_err(dev->net, "Could not connect to PHY device %s\n", ++ priv->phy_name); ++ ret = PTR_ERR(priv->phydev); ++ goto out; ++ } ++ ++ netdev_info(dev->net, "Connected to phy %s\n", priv->phy_name); ++ ++ /* During power-up, the AX88172A set the power down (BMCR_PDOWN) ++ * bit of the PHY. Bring the PHY up again. ++ */ ++ genphy_resume(priv->phydev); ++ phy_start(priv->phydev); ++ ++ return 0; ++ ++out: ++ return ret; ++ ++} ++ ++static int ax88172a_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ struct ax88172a_private *dp = dev->driver_priv; ++ struct asix_rx_fixup_info *rx = &dp->rx_fixup_info; ++ ++ return asix_rx_fixup_internal(dev, skb, rx); ++} ++ ++const struct driver_info ax88172a_info = { ++ .description = "ASIX AX88172A USB 2.0 Ethernet", ++ .bind = ax88172a_bind, ++ .reset = ax88172a_reset, ++ .stop = ax88172a_stop, ++ .unbind = ax88172a_unbind, ++ .status = ax88172a_status, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | ++ FLAG_MULTI_PACKET, ++ .rx_fixup = ax88172a_rx_fixup, ++ .tx_fixup = asix_tx_fixup, ++}; +diff -Naur backports-4.2.6-1.org/drivers/net/usb/ax88179_178a.c backports-4.2.6-1/drivers/net/usb/ax88179_178a.c +--- backports-4.2.6-1.org/drivers/net/usb/ax88179_178a.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/ax88179_178a.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,1756 @@ ++/* ++ * ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet Devices ++ * ++ * Copyright (C) 2011-2013 ASIX ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include <linux/module.h> ++#include <linux/etherdevice.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/crc32.h> ++#include <linux/usb/usbnet.h> ++#include <uapi/linux/mdio.h> ++#include <linux/mdio.h> ++ ++#define AX88179_PHY_ID 0x03 ++#define AX_EEPROM_LEN 0x100 ++#define AX88179_EEPROM_MAGIC 0x17900b95 ++#define AX_MCAST_FLTSIZE 8 ++#define AX_MAX_MCAST 64 ++#define AX_INT_PPLS_LINK ((u32)BIT(16)) ++#define AX_RXHDR_L4_TYPE_MASK 0x1c ++#define AX_RXHDR_L4_TYPE_UDP 4 ++#define AX_RXHDR_L4_TYPE_TCP 16 ++#define AX_RXHDR_L3CSUM_ERR 2 ++#define AX_RXHDR_L4CSUM_ERR 1 ++#define AX_RXHDR_CRC_ERR ((u32)BIT(29)) ++#define AX_RXHDR_DROP_ERR ((u32)BIT(31)) ++#define AX_ACCESS_MAC 0x01 ++#define AX_ACCESS_PHY 0x02 ++#define AX_ACCESS_EEPROM 0x04 ++#define AX_ACCESS_EFUS 0x05 ++#define AX_PAUSE_WATERLVL_HIGH 0x54 ++#define AX_PAUSE_WATERLVL_LOW 0x55 ++ ++#define PHYSICAL_LINK_STATUS 0x02 ++ #define AX_USB_SS 0x04 ++ #define AX_USB_HS 0x02 ++ ++#define GENERAL_STATUS 0x03 ++/* Check AX88179 version. UA1:Bit2 = 0, UA2:Bit2 = 1 */ ++ #define AX_SECLD 0x04 ++ ++#define AX_SROM_ADDR 0x07 ++#define AX_SROM_CMD 0x0a ++ #define EEP_RD 0x04 ++ #define EEP_BUSY 0x10 ++ ++#define AX_SROM_DATA_LOW 0x08 ++#define AX_SROM_DATA_HIGH 0x09 ++ ++#define AX_RX_CTL 0x0b ++ #define AX_RX_CTL_DROPCRCERR 0x0100 ++ #define AX_RX_CTL_IPE 0x0200 ++ #define AX_RX_CTL_START 0x0080 ++ #define AX_RX_CTL_AP 0x0020 ++ #define AX_RX_CTL_AM 0x0010 ++ #define AX_RX_CTL_AB 0x0008 ++ #define AX_RX_CTL_AMALL 0x0002 ++ #define AX_RX_CTL_PRO 0x0001 ++ #define AX_RX_CTL_STOP 0x0000 ++ ++#define AX_NODE_ID 0x10 ++#define AX_MULFLTARY 0x16 ++ ++#define AX_MEDIUM_STATUS_MODE 0x22 ++ #define AX_MEDIUM_GIGAMODE 0x01 ++ #define AX_MEDIUM_FULL_DUPLEX 0x02 ++ #define AX_MEDIUM_EN_125MHZ 0x08 ++ #define AX_MEDIUM_RXFLOW_CTRLEN 0x10 ++ #define AX_MEDIUM_TXFLOW_CTRLEN 0x20 ++ #define AX_MEDIUM_RECEIVE_EN 0x100 ++ #define AX_MEDIUM_PS 0x200 ++ #define AX_MEDIUM_JUMBO_EN 0x8040 ++ ++#define AX_MONITOR_MOD 0x24 ++ #define AX_MONITOR_MODE_RWLC 0x02 ++ #define AX_MONITOR_MODE_RWMP 0x04 ++ #define AX_MONITOR_MODE_PMEPOL 0x20 ++ #define AX_MONITOR_MODE_PMETYPE 0x40 ++ ++#define AX_GPIO_CTRL 0x25 ++ #define AX_GPIO_CTRL_GPIO3EN 0x80 ++ #define AX_GPIO_CTRL_GPIO2EN 0x40 ++ #define AX_GPIO_CTRL_GPIO1EN 0x20 ++ ++#define AX_PHYPWR_RSTCTL 0x26 ++ #define AX_PHYPWR_RSTCTL_BZ 0x0010 ++ #define AX_PHYPWR_RSTCTL_IPRL 0x0020 ++ #define AX_PHYPWR_RSTCTL_AT 0x1000 ++ ++#define AX_RX_BULKIN_QCTRL 0x2e ++#define AX_CLK_SELECT 0x33 ++ #define AX_CLK_SELECT_BCS 0x01 ++ #define AX_CLK_SELECT_ACS 0x02 ++ #define AX_CLK_SELECT_ULR 0x08 ++ ++#define AX_RXCOE_CTL 0x34 ++ #define AX_RXCOE_IP 0x01 ++ #define AX_RXCOE_TCP 0x02 ++ #define AX_RXCOE_UDP 0x04 ++ #define AX_RXCOE_TCPV6 0x20 ++ #define AX_RXCOE_UDPV6 0x40 ++ ++#define AX_TXCOE_CTL 0x35 ++ #define AX_TXCOE_IP 0x01 ++ #define AX_TXCOE_TCP 0x02 ++ #define AX_TXCOE_UDP 0x04 ++ #define AX_TXCOE_TCPV6 0x20 ++ #define AX_TXCOE_UDPV6 0x40 ++ ++#define AX_LEDCTRL 0x73 ++ ++#define GMII_PHY_PHYSR 0x11 ++ #define GMII_PHY_PHYSR_SMASK 0xc000 ++ #define GMII_PHY_PHYSR_GIGA 0x8000 ++ #define GMII_PHY_PHYSR_100 0x4000 ++ #define GMII_PHY_PHYSR_FULL 0x2000 ++ #define GMII_PHY_PHYSR_LINK 0x400 ++ ++#define GMII_LED_ACT 0x1a ++ #define GMII_LED_ACTIVE_MASK 0xff8f ++ #define GMII_LED0_ACTIVE BIT(4) ++ #define GMII_LED1_ACTIVE BIT(5) ++ #define GMII_LED2_ACTIVE BIT(6) ++ ++#define GMII_LED_LINK 0x1c ++ #define GMII_LED_LINK_MASK 0xf888 ++ #define GMII_LED0_LINK_10 BIT(0) ++ #define GMII_LED0_LINK_100 BIT(1) ++ #define GMII_LED0_LINK_1000 BIT(2) ++ #define GMII_LED1_LINK_10 BIT(4) ++ #define GMII_LED1_LINK_100 BIT(5) ++ #define GMII_LED1_LINK_1000 BIT(6) ++ #define GMII_LED2_LINK_10 BIT(8) ++ #define GMII_LED2_LINK_100 BIT(9) ++ #define GMII_LED2_LINK_1000 BIT(10) ++ #define LED0_ACTIVE BIT(0) ++ #define LED0_LINK_10 BIT(1) ++ #define LED0_LINK_100 BIT(2) ++ #define LED0_LINK_1000 BIT(3) ++ #define LED0_FD BIT(4) ++ #define LED0_USB3_MASK 0x001f ++ #define LED1_ACTIVE BIT(5) ++ #define LED1_LINK_10 BIT(6) ++ #define LED1_LINK_100 BIT(7) ++ #define LED1_LINK_1000 BIT(8) ++ #define LED1_FD BIT(9) ++ #define LED1_USB3_MASK 0x03e0 ++ #define LED2_ACTIVE BIT(10) ++ #define LED2_LINK_1000 BIT(13) ++ #define LED2_LINK_100 BIT(12) ++ #define LED2_LINK_10 BIT(11) ++ #define LED2_FD BIT(14) ++ #define LED_VALID BIT(15) ++ #define LED2_USB3_MASK 0x7c00 ++ ++#define GMII_PHYPAGE 0x1e ++#define GMII_PHY_PAGE_SELECT 0x1f ++ #define GMII_PHY_PGSEL_EXT 0x0007 ++ #define GMII_PHY_PGSEL_PAGE0 0x0000 ++ #define GMII_PHY_PGSEL_PAGE3 0x0003 ++ #define GMII_PHY_PGSEL_PAGE5 0x0005 ++ ++struct ax88179_data { ++ u8 eee_enabled; ++ u8 eee_active; ++ u16 rxctl; ++ u16 reserved; ++}; ++ ++struct ax88179_int_data { ++ __le32 intdata1; ++ __le32 intdata2; ++}; ++ ++static const struct { ++ unsigned char ctrl, timer_l, timer_h, size, ifg; ++} AX88179_BULKIN_SIZE[] = { ++ {7, 0x4f, 0, 0x12, 0xff}, ++ {7, 0x20, 3, 0x16, 0xff}, ++ {7, 0xae, 7, 0x18, 0xff}, ++ {7, 0xcc, 0x4c, 0x18, 8}, ++}; ++ ++static int __ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data, int in_pm) ++{ ++ int ret; ++ int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); ++ ++ BUG_ON(!dev); ++ ++ if (!in_pm) ++ fn = usbnet_read_cmd; ++ else ++ fn = usbnet_read_cmd_nopm; ++ ++ ret = fn(dev, cmd, USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ value, index, data, size); ++ ++ if (unlikely(ret < 0)) ++ netdev_warn(dev->net, "Failed to read reg index 0x%04x: %d\n", ++ index, ret); ++ ++ return ret; ++} ++ ++static int __ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data, int in_pm) ++{ ++ int ret; ++ int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); ++ ++ BUG_ON(!dev); ++ ++ if (!in_pm) ++ fn = usbnet_write_cmd; ++ else ++ fn = usbnet_write_cmd_nopm; ++ ++ ret = fn(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ value, index, data, size); ++ ++ if (unlikely(ret < 0)) ++ netdev_warn(dev->net, "Failed to write reg index 0x%04x: %d\n", ++ index, ret); ++ ++ return ret; ++} ++ ++static void ax88179_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, ++ u16 index, u16 size, void *data) ++{ ++ u16 buf; ++ ++ if (2 == size) { ++ buf = *((u16 *)data); ++ cpu_to_le16s(&buf); ++ usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | ++ USB_RECIP_DEVICE, value, index, &buf, ++ size); ++ } else { ++ usbnet_write_cmd_async(dev, cmd, USB_DIR_OUT | USB_TYPE_VENDOR | ++ USB_RECIP_DEVICE, value, index, data, ++ size); ++ } ++} ++ ++static int ax88179_read_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, ++ u16 index, u16 size, void *data) ++{ ++ int ret; ++ ++ if (2 == size) { ++ u16 buf; ++ ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 1); ++ le16_to_cpus(&buf); ++ *((u16 *)data) = buf; ++ } else if (4 == size) { ++ u32 buf; ++ ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 1); ++ le32_to_cpus(&buf); ++ *((u32 *)data) = buf; ++ } else { ++ ret = __ax88179_read_cmd(dev, cmd, value, index, size, data, 1); ++ } ++ ++ return ret; ++} ++ ++static int ax88179_write_cmd_nopm(struct usbnet *dev, u8 cmd, u16 value, ++ u16 index, u16 size, void *data) ++{ ++ int ret; ++ ++ if (2 == size) { ++ u16 buf; ++ buf = *((u16 *)data); ++ cpu_to_le16s(&buf); ++ ret = __ax88179_write_cmd(dev, cmd, value, index, ++ size, &buf, 1); ++ } else { ++ ret = __ax88179_write_cmd(dev, cmd, value, index, ++ size, data, 1); ++ } ++ ++ return ret; ++} ++ ++static int ax88179_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data) ++{ ++ int ret; ++ ++ if (2 == size) { ++ u16 buf; ++ ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0); ++ le16_to_cpus(&buf); ++ *((u16 *)data) = buf; ++ } else if (4 == size) { ++ u32 buf; ++ ret = __ax88179_read_cmd(dev, cmd, value, index, size, &buf, 0); ++ le32_to_cpus(&buf); ++ *((u32 *)data) = buf; ++ } else { ++ ret = __ax88179_read_cmd(dev, cmd, value, index, size, data, 0); ++ } ++ ++ return ret; ++} ++ ++static int ax88179_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data) ++{ ++ int ret; ++ ++ if (2 == size) { ++ u16 buf; ++ buf = *((u16 *)data); ++ cpu_to_le16s(&buf); ++ ret = __ax88179_write_cmd(dev, cmd, value, index, ++ size, &buf, 0); ++ } else { ++ ret = __ax88179_write_cmd(dev, cmd, value, index, ++ size, data, 0); ++ } ++ ++ return ret; ++} ++ ++static void ax88179_status(struct usbnet *dev, struct urb *urb) ++{ ++ struct ax88179_int_data *event; ++ u32 link; ++ ++ if (urb->actual_length < 8) ++ return; ++ ++ event = urb->transfer_buffer; ++ le32_to_cpus((void *)&event->intdata1); ++ ++ link = (((__force u32)event->intdata1) & AX_INT_PPLS_LINK) >> 16; ++ ++ if (netif_carrier_ok(dev->net) != link) { ++ usbnet_link_change(dev, link, 1); ++ netdev_info(dev->net, "ax88179 - Link status is: %d\n", link); ++ } ++} ++ ++static int ax88179_mdio_read(struct net_device *netdev, int phy_id, int loc) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u16 res; ++ ++ ax88179_read_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); ++ return res; ++} ++ ++static void ax88179_mdio_write(struct net_device *netdev, int phy_id, int loc, ++ int val) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u16 res = (u16) val; ++ ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, phy_id, (__u16)loc, 2, &res); ++} ++ ++static inline int ax88179_phy_mmd_indirect(struct usbnet *dev, u16 prtad, ++ u16 devad) ++{ ++ u16 tmp16; ++ int ret; ++ ++ tmp16 = devad; ++ ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ MII_MMD_CTRL, 2, &tmp16); ++ ++ tmp16 = prtad; ++ ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ MII_MMD_DATA, 2, &tmp16); ++ ++ tmp16 = devad | MII_MMD_CTRL_NOINCR; ++ ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ MII_MMD_CTRL, 2, &tmp16); ++ ++ return ret; ++} ++ ++static int ++ax88179_phy_read_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad) ++{ ++ int ret; ++ u16 tmp16; ++ ++ ax88179_phy_mmd_indirect(dev, prtad, devad); ++ ++ ret = ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ MII_MMD_DATA, 2, &tmp16); ++ if (ret < 0) ++ return ret; ++ ++ return tmp16; ++} ++ ++static int ++ax88179_phy_write_mmd_indirect(struct usbnet *dev, u16 prtad, u16 devad, ++ u16 data) ++{ ++ int ret; ++ ++ ax88179_phy_mmd_indirect(dev, prtad, devad); ++ ++ ret = ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ MII_MMD_DATA, 2, &data); ++ ++ if (ret < 0) ++ return ret; ++ ++ return 0; ++} ++ ++static int ax88179_suspend(struct usb_interface *intf, pm_message_t message) ++{ ++ struct usbnet *dev = usb_get_intfdata(intf); ++ u16 tmp16; ++ u8 tmp8; ++ ++ usbnet_suspend(intf, message); ++ ++ /* Disable RX path */ ++ ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &tmp16); ++ tmp16 &= ~AX_MEDIUM_RECEIVE_EN; ++ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &tmp16); ++ ++ /* Force bulk-in zero length */ ++ ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, ++ 2, 2, &tmp16); ++ ++ tmp16 |= AX_PHYPWR_RSTCTL_BZ | AX_PHYPWR_RSTCTL_IPRL; ++ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, ++ 2, 2, &tmp16); ++ ++ /* change clock */ ++ tmp8 = 0; ++ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); ++ ++ /* Configure RX control register => stop operation */ ++ tmp16 = AX_RX_CTL_STOP; ++ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); ++ ++ return 0; ++} ++ ++/* This function is used to enable the autodetach function. */ ++/* This function is determined by offset 0x43 of EEPROM */ ++static int ax88179_auto_detach(struct usbnet *dev, int in_pm) ++{ ++ u16 tmp16; ++ u8 tmp8; ++ int (*fnr)(struct usbnet *, u8, u16, u16, u16, void *); ++ int (*fnw)(struct usbnet *, u8, u16, u16, u16, void *); ++ ++ if (!in_pm) { ++ fnr = ax88179_read_cmd; ++ fnw = ax88179_write_cmd; ++ } else { ++ fnr = ax88179_read_cmd_nopm; ++ fnw = ax88179_write_cmd_nopm; ++ } ++ ++ if (fnr(dev, AX_ACCESS_EEPROM, 0x43, 1, 2, &tmp16) < 0) ++ return 0; ++ ++ if ((tmp16 == 0xFFFF) || (!(tmp16 & 0x0100))) ++ return 0; ++ ++ /* Enable Auto Detach bit */ ++ tmp8 = 0; ++ fnr(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); ++ tmp8 |= AX_CLK_SELECT_ULR; ++ fnw(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); ++ ++ fnr(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); ++ tmp16 |= AX_PHYPWR_RSTCTL_AT; ++ fnw(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); ++ ++ return 0; ++} ++ ++static int ax88179_resume(struct usb_interface *intf) ++{ ++ struct usbnet *dev = usb_get_intfdata(intf); ++ u16 tmp16; ++ u8 tmp8; ++ ++ usbnet_link_change(dev, 0, 0); ++ ++ /* Power up ethernet PHY */ ++ tmp16 = 0; ++ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, ++ 2, 2, &tmp16); ++ udelay(1000); ++ ++ tmp16 = AX_PHYPWR_RSTCTL_IPRL; ++ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, ++ 2, 2, &tmp16); ++ msleep(200); ++ ++ /* Ethernet PHY Auto Detach*/ ++ ax88179_auto_detach(dev, 1); ++ ++ /* Enable clock */ ++ ax88179_read_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); ++ tmp8 |= AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; ++ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp8); ++ msleep(100); ++ ++ /* Configure RX control register => start operation */ ++ tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | ++ AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; ++ ax88179_write_cmd_nopm(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); ++ ++ return usbnet_resume(intf); ++} ++ ++static void ++ax88179_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u8 opt; ++ ++ if (ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, ++ 1, 1, &opt) < 0) { ++ wolinfo->supported = 0; ++ wolinfo->wolopts = 0; ++ return; ++ } ++ ++ wolinfo->supported = WAKE_PHY | WAKE_MAGIC; ++ wolinfo->wolopts = 0; ++ if (opt & AX_MONITOR_MODE_RWLC) ++ wolinfo->wolopts |= WAKE_PHY; ++ if (opt & AX_MONITOR_MODE_RWMP) ++ wolinfo->wolopts |= WAKE_MAGIC; ++} ++ ++static int ++ax88179_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u8 opt = 0; ++ ++ if (wolinfo->wolopts & WAKE_PHY) ++ opt |= AX_MONITOR_MODE_RWLC; ++ if (wolinfo->wolopts & WAKE_MAGIC) ++ opt |= AX_MONITOR_MODE_RWMP; ++ ++ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, ++ 1, 1, &opt) < 0) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int ax88179_get_eeprom_len(struct net_device *net) ++{ ++ return AX_EEPROM_LEN; ++} ++ ++static int ++ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, ++ u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u16 *eeprom_buff; ++ int first_word, last_word; ++ int i, ret; ++ ++ if (eeprom->len == 0) ++ return -EINVAL; ++ ++ eeprom->magic = AX88179_EEPROM_MAGIC; ++ ++ first_word = eeprom->offset >> 1; ++ last_word = (eeprom->offset + eeprom->len - 1) >> 1; ++ eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), ++ GFP_KERNEL); ++ if (!eeprom_buff) ++ return -ENOMEM; ++ ++ /* ax88179/178A returns 2 bytes from eeprom on read */ ++ for (i = first_word; i <= last_word; i++) { ++ ret = __ax88179_read_cmd(dev, AX_ACCESS_EEPROM, i, 1, 2, ++ &eeprom_buff[i - first_word], ++ 0); ++ if (ret < 0) { ++ kfree(eeprom_buff); ++ return -EIO; ++ } ++ } ++ ++ memcpy(data, (u8 *)eeprom_buff + (eeprom->offset & 1), eeprom->len); ++ kfree(eeprom_buff); ++ return 0; ++} ++ ++static int ax88179_get_settings(struct net_device *net, struct ethtool_cmd *cmd) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ return mii_ethtool_gset(&dev->mii, cmd); ++} ++ ++static int ax88179_set_settings(struct net_device *net, struct ethtool_cmd *cmd) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ return mii_ethtool_sset(&dev->mii, cmd); ++} ++ ++static int ++ax88179_ethtool_get_eee(struct usbnet *dev, struct ethtool_eee *data) ++{ ++ int val; ++ ++ /* Get Supported EEE */ ++ val = ax88179_phy_read_mmd_indirect(dev, MDIO_PCS_EEE_ABLE, ++ MDIO_MMD_PCS); ++ if (val < 0) ++ return val; ++ data->supported = mmd_eee_cap_to_ethtool_sup_t(val); ++ ++ /* Get advertisement EEE */ ++ val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_ADV, ++ MDIO_MMD_AN); ++ if (val < 0) ++ return val; ++ data->advertised = mmd_eee_adv_to_ethtool_adv_t(val); ++ ++ /* Get LP advertisement EEE */ ++ val = ax88179_phy_read_mmd_indirect(dev, MDIO_AN_EEE_LPABLE, ++ MDIO_MMD_AN); ++ if (val < 0) ++ return val; ++ data->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(val); ++ ++ return 0; ++} ++ ++static int ++ax88179_ethtool_set_eee(struct usbnet *dev, struct ethtool_eee *data) ++{ ++ u16 tmp16 = ethtool_adv_to_mmd_eee_adv_t(data->advertised); ++ ++ return ax88179_phy_write_mmd_indirect(dev, MDIO_AN_EEE_ADV, ++ MDIO_MMD_AN, tmp16); ++} ++ ++static int ax88179_chk_eee(struct usbnet *dev) ++{ ++ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; ++ struct ax88179_data *priv = (struct ax88179_data *)dev->data; ++ ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ ++ if (ecmd.duplex & DUPLEX_FULL) { ++ int eee_lp, eee_cap, eee_adv; ++ u32 lp, cap, adv, supported = 0; ++ ++ eee_cap = ax88179_phy_read_mmd_indirect(dev, ++ MDIO_PCS_EEE_ABLE, ++ MDIO_MMD_PCS); ++ if (eee_cap < 0) { ++ priv->eee_active = 0; ++ return false; ++ } ++ ++ cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap); ++ if (!cap) { ++ priv->eee_active = 0; ++ return false; ++ } ++ ++ eee_lp = ax88179_phy_read_mmd_indirect(dev, ++ MDIO_AN_EEE_LPABLE, ++ MDIO_MMD_AN); ++ if (eee_lp < 0) { ++ priv->eee_active = 0; ++ return false; ++ } ++ ++ eee_adv = ax88179_phy_read_mmd_indirect(dev, ++ MDIO_AN_EEE_ADV, ++ MDIO_MMD_AN); ++ ++ if (eee_adv < 0) { ++ priv->eee_active = 0; ++ return false; ++ } ++ ++ adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv); ++ lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp); ++ supported = (ecmd.speed == SPEED_1000) ? ++ SUPPORTED_1000baseT_Full : ++ SUPPORTED_100baseT_Full; ++ ++ if (!(lp & adv & supported)) { ++ priv->eee_active = 0; ++ return false; ++ } ++ ++ priv->eee_active = 1; ++ return true; ++ } ++ ++ priv->eee_active = 0; ++ return false; ++} ++ ++static void ax88179_disable_eee(struct usbnet *dev) ++{ ++ u16 tmp16; ++ ++ tmp16 = GMII_PHY_PGSEL_PAGE3; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHY_PAGE_SELECT, 2, &tmp16); ++ ++ tmp16 = 0x3246; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ MII_PHYADDR, 2, &tmp16); ++ ++ tmp16 = GMII_PHY_PGSEL_PAGE0; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHY_PAGE_SELECT, 2, &tmp16); ++} ++ ++static void ax88179_enable_eee(struct usbnet *dev) ++{ ++ u16 tmp16; ++ ++ tmp16 = GMII_PHY_PGSEL_PAGE3; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHY_PAGE_SELECT, 2, &tmp16); ++ ++ tmp16 = 0x3247; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ MII_PHYADDR, 2, &tmp16); ++ ++ tmp16 = GMII_PHY_PGSEL_PAGE5; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHY_PAGE_SELECT, 2, &tmp16); ++ ++ tmp16 = 0x0680; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ MII_BMSR, 2, &tmp16); ++ ++ tmp16 = GMII_PHY_PGSEL_PAGE0; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHY_PAGE_SELECT, 2, &tmp16); ++} ++ ++static int ax88179_get_eee(struct net_device *net, struct ethtool_eee *edata) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct ax88179_data *priv = (struct ax88179_data *)dev->data; ++ ++ edata->eee_enabled = priv->eee_enabled; ++ edata->eee_active = priv->eee_active; ++ ++ return ax88179_ethtool_get_eee(dev, edata); ++} ++ ++static int ax88179_set_eee(struct net_device *net, struct ethtool_eee *edata) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct ax88179_data *priv = (struct ax88179_data *)dev->data; ++ int ret = -EOPNOTSUPP; ++ ++ priv->eee_enabled = edata->eee_enabled; ++ if (!priv->eee_enabled) { ++ ax88179_disable_eee(dev); ++ } else { ++ priv->eee_enabled = ax88179_chk_eee(dev); ++ if (!priv->eee_enabled) ++ return -EOPNOTSUPP; ++ ++ ax88179_enable_eee(dev); ++ } ++ ++ ret = ax88179_ethtool_set_eee(dev, edata); ++ if (ret) ++ return ret; ++ ++ mii_nway_restart(&dev->mii); ++ ++ usbnet_link_change(dev, 0, 0); ++ ++ return ret; ++} ++ ++static int ax88179_ioctl(struct net_device *net, struct ifreq *rq, int cmd) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); ++} ++ ++static const struct ethtool_ops ax88179_ethtool_ops = { ++ .get_link = ethtool_op_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_wol = ax88179_get_wol, ++ .set_wol = ax88179_set_wol, ++ .get_eeprom_len = ax88179_get_eeprom_len, ++ .get_eeprom = ax88179_get_eeprom, ++ .get_settings = ax88179_get_settings, ++ .set_settings = ax88179_set_settings, ++ .get_eee = ax88179_get_eee, ++ .set_eee = ax88179_set_eee, ++ .nway_reset = usbnet_nway_reset, ++}; ++ ++static void ax88179_set_multicast(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct ax88179_data *data = (struct ax88179_data *)dev->data; ++ u8 *m_filter = ((u8 *)dev->data) + 12; ++ ++ data->rxctl = (AX_RX_CTL_START | AX_RX_CTL_AB | AX_RX_CTL_IPE); ++ ++ if (net->flags & IFF_PROMISC) { ++ data->rxctl |= AX_RX_CTL_PRO; ++ } else if (net->flags & IFF_ALLMULTI || ++ netdev_mc_count(net) > AX_MAX_MCAST) { ++ data->rxctl |= AX_RX_CTL_AMALL; ++ } else if (netdev_mc_empty(net)) { ++ /* just broadcast and directed */ ++ } else { ++ /* We use the 20 byte dev->data for our 8 byte filter buffer ++ * to avoid allocating memory that is tricky to free later ++ */ ++ u32 crc_bits; ++ struct netdev_hw_addr *ha; ++ ++ memset(m_filter, 0, AX_MCAST_FLTSIZE); ++ ++ netdev_for_each_mc_addr(ha, net) { ++ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; ++ *(m_filter + (crc_bits >> 3)) |= (1 << (crc_bits & 7)); ++ } ++ ++ ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_MULFLTARY, ++ AX_MCAST_FLTSIZE, AX_MCAST_FLTSIZE, ++ m_filter); ++ ++ data->rxctl |= AX_RX_CTL_AM; ++ } ++ ++ ax88179_write_cmd_async(dev, AX_ACCESS_MAC, AX_RX_CTL, ++ 2, 2, &data->rxctl); ++} ++ ++static int ++ax88179_set_features(struct net_device *net, netdev_features_t features) ++{ ++ u8 tmp; ++ struct usbnet *dev = netdev_priv(net); ++ netdev_features_t changed = net->features ^ features; ++ ++ if (changed & NETIF_F_IP_CSUM) { ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); ++ tmp ^= AX_TXCOE_TCP | AX_TXCOE_UDP; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); ++ } ++ ++ if (changed & NETIF_F_IPV6_CSUM) { ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); ++ tmp ^= AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, &tmp); ++ } ++ ++ if (changed & NETIF_F_RXCSUM) { ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); ++ tmp ^= AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | ++ AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, &tmp); ++ } ++ ++ return 0; ++} ++ ++static int ax88179_change_mtu(struct net_device *net, int new_mtu) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u16 tmp16; ++ ++ if (new_mtu <= 0 || new_mtu > 4088) ++ return -EINVAL; ++ ++ net->mtu = new_mtu; ++ dev->hard_mtu = net->mtu + net->hard_header_len; ++ ++ if (net->mtu > 1500) { ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &tmp16); ++ tmp16 |= AX_MEDIUM_JUMBO_EN; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &tmp16); ++ } else { ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &tmp16); ++ tmp16 &= ~AX_MEDIUM_JUMBO_EN; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &tmp16); ++ } ++ ++ /* max qlen depend on hard_mtu and rx_urb_size */ ++ usbnet_update_max_qlen(dev); ++ ++ return 0; ++} ++ ++static int ax88179_set_mac_addr(struct net_device *net, void *p) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct sockaddr *addr = p; ++ int ret; ++ ++ if (netif_running(net)) ++ return -EBUSY; ++ if (!is_valid_ether_addr(addr->sa_data)) ++ return -EADDRNOTAVAIL; ++ ++ memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); ++ ++ /* Set the MAC address */ ++ ret = ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ++ ETH_ALEN, net->dev_addr); ++ if (ret < 0) ++ return ret; ++ ++ return 0; ++} ++ ++static const struct net_device_ops ax88179_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = ax88179_change_mtu, ++ .ndo_set_mac_address = ax88179_set_mac_addr, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = ax88179_ioctl, ++ .ndo_set_rx_mode = ax88179_set_multicast, ++ .ndo_set_features = ax88179_set_features, ++}; ++ ++static int ax88179_check_eeprom(struct usbnet *dev) ++{ ++ u8 i, buf, eeprom[20]; ++ u16 csum, delay = HZ / 10; ++ unsigned long jtimeout; ++ ++ /* Read EEPROM content */ ++ for (i = 0; i < 6; i++) { ++ buf = i; ++ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, ++ 1, 1, &buf) < 0) ++ return -EINVAL; ++ ++ buf = EEP_RD; ++ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, ++ 1, 1, &buf) < 0) ++ return -EINVAL; ++ ++ jtimeout = jiffies + delay; ++ do { ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, ++ 1, 1, &buf); ++ ++ if (time_after(jiffies, jtimeout)) ++ return -EINVAL; ++ ++ } while (buf & EEP_BUSY); ++ ++ __ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, ++ 2, 2, &eeprom[i * 2], 0); ++ ++ if ((i == 0) && (eeprom[0] == 0xFF)) ++ return -EINVAL; ++ } ++ ++ csum = eeprom[6] + eeprom[7] + eeprom[8] + eeprom[9]; ++ csum = (csum >> 8) + (csum & 0xff); ++ if ((csum + eeprom[10]) != 0xff) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int ax88179_check_efuse(struct usbnet *dev, u16 *ledmode) ++{ ++ u8 i; ++ u8 efuse[64]; ++ u16 csum = 0; ++ ++ if (ax88179_read_cmd(dev, AX_ACCESS_EFUS, 0, 64, 64, efuse) < 0) ++ return -EINVAL; ++ ++ if (*efuse == 0xFF) ++ return -EINVAL; ++ ++ for (i = 0; i < 64; i++) ++ csum = csum + efuse[i]; ++ ++ while (csum > 255) ++ csum = (csum & 0x00FF) + ((csum >> 8) & 0x00FF); ++ ++ if (csum != 0xFF) ++ return -EINVAL; ++ ++ *ledmode = (efuse[51] << 8) | efuse[52]; ++ ++ return 0; ++} ++ ++static int ax88179_convert_old_led(struct usbnet *dev, u16 *ledvalue) ++{ ++ u16 led; ++ ++ /* Loaded the old eFuse LED Mode */ ++ if (ax88179_read_cmd(dev, AX_ACCESS_EEPROM, 0x3C, 1, 2, &led) < 0) ++ return -EINVAL; ++ ++ led >>= 8; ++ switch (led) { ++ case 0xFF: ++ led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | ++ LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | ++ LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; ++ break; ++ case 0xFE: ++ led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | LED_VALID; ++ break; ++ case 0xFD: ++ led = LED0_ACTIVE | LED1_LINK_1000 | LED2_LINK_100 | ++ LED2_LINK_10 | LED_VALID; ++ break; ++ case 0xFC: ++ led = LED0_ACTIVE | LED1_ACTIVE | LED1_LINK_1000 | LED2_ACTIVE | ++ LED2_LINK_100 | LED2_LINK_10 | LED_VALID; ++ break; ++ default: ++ led = LED0_ACTIVE | LED1_LINK_10 | LED1_LINK_100 | ++ LED1_LINK_1000 | LED2_ACTIVE | LED2_LINK_10 | ++ LED2_LINK_100 | LED2_LINK_1000 | LED_VALID; ++ break; ++ } ++ ++ *ledvalue = led; ++ ++ return 0; ++} ++ ++static int ax88179_led_setting(struct usbnet *dev) ++{ ++ u8 ledfd, value = 0; ++ u16 tmp, ledact, ledlink, ledvalue = 0, delay = HZ / 10; ++ unsigned long jtimeout; ++ ++ /* Check AX88179 version. UA1 or UA2*/ ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, GENERAL_STATUS, 1, 1, &value); ++ ++ if (!(value & AX_SECLD)) { /* UA1 */ ++ value = AX_GPIO_CTRL_GPIO3EN | AX_GPIO_CTRL_GPIO2EN | ++ AX_GPIO_CTRL_GPIO1EN; ++ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_GPIO_CTRL, ++ 1, 1, &value) < 0) ++ return -EINVAL; ++ } ++ ++ /* Check EEPROM */ ++ if (!ax88179_check_eeprom(dev)) { ++ value = 0x42; ++ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_ADDR, ++ 1, 1, &value) < 0) ++ return -EINVAL; ++ ++ value = EEP_RD; ++ if (ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, ++ 1, 1, &value) < 0) ++ return -EINVAL; ++ ++ jtimeout = jiffies + delay; ++ do { ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_CMD, ++ 1, 1, &value); ++ ++ if (time_after(jiffies, jtimeout)) ++ return -EINVAL; ++ ++ } while (value & EEP_BUSY); ++ ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_HIGH, ++ 1, 1, &value); ++ ledvalue = (value << 8); ++ ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_SROM_DATA_LOW, ++ 1, 1, &value); ++ ledvalue |= value; ++ ++ /* load internal ROM for defaule setting */ ++ if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) ++ ax88179_convert_old_led(dev, &ledvalue); ++ ++ } else if (!ax88179_check_efuse(dev, &ledvalue)) { ++ if ((ledvalue == 0xFFFF) || ((ledvalue & LED_VALID) == 0)) ++ ax88179_convert_old_led(dev, &ledvalue); ++ } else { ++ ax88179_convert_old_led(dev, &ledvalue); ++ } ++ ++ tmp = GMII_PHY_PGSEL_EXT; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHY_PAGE_SELECT, 2, &tmp); ++ ++ tmp = 0x2c; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHYPAGE, 2, &tmp); ++ ++ ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_LED_ACT, 2, &ledact); ++ ++ ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_LED_LINK, 2, &ledlink); ++ ++ ledact &= GMII_LED_ACTIVE_MASK; ++ ledlink &= GMII_LED_LINK_MASK; ++ ++ if (ledvalue & LED0_ACTIVE) ++ ledact |= GMII_LED0_ACTIVE; ++ ++ if (ledvalue & LED1_ACTIVE) ++ ledact |= GMII_LED1_ACTIVE; ++ ++ if (ledvalue & LED2_ACTIVE) ++ ledact |= GMII_LED2_ACTIVE; ++ ++ if (ledvalue & LED0_LINK_10) ++ ledlink |= GMII_LED0_LINK_10; ++ ++ if (ledvalue & LED1_LINK_10) ++ ledlink |= GMII_LED1_LINK_10; ++ ++ if (ledvalue & LED2_LINK_10) ++ ledlink |= GMII_LED2_LINK_10; ++ ++ if (ledvalue & LED0_LINK_100) ++ ledlink |= GMII_LED0_LINK_100; ++ ++ if (ledvalue & LED1_LINK_100) ++ ledlink |= GMII_LED1_LINK_100; ++ ++ if (ledvalue & LED2_LINK_100) ++ ledlink |= GMII_LED2_LINK_100; ++ ++ if (ledvalue & LED0_LINK_1000) ++ ledlink |= GMII_LED0_LINK_1000; ++ ++ if (ledvalue & LED1_LINK_1000) ++ ledlink |= GMII_LED1_LINK_1000; ++ ++ if (ledvalue & LED2_LINK_1000) ++ ledlink |= GMII_LED2_LINK_1000; ++ ++ tmp = ledact; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_LED_ACT, 2, &tmp); ++ ++ tmp = ledlink; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_LED_LINK, 2, &tmp); ++ ++ tmp = GMII_PHY_PGSEL_PAGE0; ++ ax88179_write_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHY_PAGE_SELECT, 2, &tmp); ++ ++ /* LED full duplex setting */ ++ ledfd = 0; ++ if (ledvalue & LED0_FD) ++ ledfd |= 0x01; ++ else if ((ledvalue & LED0_USB3_MASK) == 0) ++ ledfd |= 0x02; ++ ++ if (ledvalue & LED1_FD) ++ ledfd |= 0x04; ++ else if ((ledvalue & LED1_USB3_MASK) == 0) ++ ledfd |= 0x08; ++ ++ if (ledvalue & LED2_FD) ++ ledfd |= 0x10; ++ else if ((ledvalue & LED2_USB3_MASK) == 0) ++ ledfd |= 0x20; ++ ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_LEDCTRL, 1, 1, &ledfd); ++ ++ return 0; ++} ++ ++static int ax88179_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ u8 buf[5]; ++ u16 *tmp16; ++ u8 *tmp; ++ struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; ++ struct ethtool_eee eee_data; ++ ++ usbnet_get_endpoints(dev, intf); ++ ++ tmp16 = (u16 *)buf; ++ tmp = (u8 *)buf; ++ ++ memset(ax179_data, 0, sizeof(*ax179_data)); ++ ++ /* Power up ethernet PHY */ ++ *tmp16 = 0; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); ++ *tmp16 = AX_PHYPWR_RSTCTL_IPRL; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); ++ msleep(200); ++ ++ *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp); ++ msleep(100); ++ ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ++ ETH_ALEN, dev->net->dev_addr); ++ memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN); ++ ++ /* RX bulk configuration */ ++ memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); ++ ++ dev->rx_urb_size = 1024 * 20; ++ ++ *tmp = 0x34; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp); ++ ++ *tmp = 0x52; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, ++ 1, 1, tmp); ++ ++ dev->net->netdev_ops = &ax88179_netdev_ops; ++ dev->net->ethtool_ops = &ax88179_ethtool_ops; ++ dev->net->needed_headroom = 8; ++ ++ /* Initialize MII structure */ ++ dev->mii.dev = dev->net; ++ dev->mii.mdio_read = ax88179_mdio_read; ++ dev->mii.mdio_write = ax88179_mdio_write; ++ dev->mii.phy_id_mask = 0xff; ++ dev->mii.reg_num_mask = 0xff; ++ dev->mii.phy_id = 0x03; ++ dev->mii.supports_gmii = 1; ++ ++ dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | ++ NETIF_F_RXCSUM; ++ ++ dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | ++ NETIF_F_RXCSUM; ++ ++ /* Enable checksum offload */ ++ *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | ++ AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp); ++ ++ *tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP | ++ AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp); ++ ++ /* Configure RX control register => start operation */ ++ *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | ++ AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); ++ ++ *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | ++ AX_MONITOR_MODE_RWMP; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp); ++ ++ /* Configure default medium type => giga */ ++ *tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | ++ AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX | ++ AX_MEDIUM_GIGAMODE; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, tmp16); ++ ++ ax88179_led_setting(dev); ++ ++ ax179_data->eee_enabled = 0; ++ ax179_data->eee_active = 0; ++ ++ ax88179_disable_eee(dev); ++ ++ ax88179_ethtool_get_eee(dev, &eee_data); ++ eee_data.advertised = 0; ++ ax88179_ethtool_set_eee(dev, &eee_data); ++ ++ /* Restart autoneg */ ++ mii_nway_restart(&dev->mii); ++ ++ usbnet_link_change(dev, 0, 0); ++ ++ return 0; ++} ++ ++static void ax88179_unbind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ u16 tmp16; ++ ++ /* Configure RX control register => stop operation */ ++ tmp16 = AX_RX_CTL_STOP; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &tmp16); ++ ++ tmp16 = 0; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, &tmp16); ++ ++ /* Power down ethernet PHY */ ++ tmp16 = 0; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, &tmp16); ++} ++ ++static void ++ax88179_rx_checksum(struct sk_buff *skb, u32 *pkt_hdr) ++{ ++ skb->ip_summed = CHECKSUM_NONE; ++ ++ /* checksum error bit is set */ ++ if ((*pkt_hdr & AX_RXHDR_L3CSUM_ERR) || ++ (*pkt_hdr & AX_RXHDR_L4CSUM_ERR)) ++ return; ++ ++ /* It must be a TCP or UDP packet with a valid checksum */ ++ if (((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_TCP) || ++ ((*pkt_hdr & AX_RXHDR_L4_TYPE_MASK) == AX_RXHDR_L4_TYPE_UDP)) ++ skb->ip_summed = CHECKSUM_UNNECESSARY; ++} ++ ++static int ax88179_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ struct sk_buff *ax_skb; ++ int pkt_cnt; ++ u32 rx_hdr; ++ u16 hdr_off; ++ u32 *pkt_hdr; ++ ++ /* This check is no longer done by usbnet */ ++ if (skb->len < dev->net->hard_header_len) ++ return 0; ++ ++ skb_trim(skb, skb->len - 4); ++ memcpy(&rx_hdr, skb_tail_pointer(skb), 4); ++ le32_to_cpus(&rx_hdr); ++ ++ pkt_cnt = (u16)rx_hdr; ++ hdr_off = (u16)(rx_hdr >> 16); ++ pkt_hdr = (u32 *)(skb->data + hdr_off); ++ ++ while (pkt_cnt--) { ++ u16 pkt_len; ++ ++ le32_to_cpus(pkt_hdr); ++ pkt_len = (*pkt_hdr >> 16) & 0x1fff; ++ ++ /* Check CRC or runt packet */ ++ if ((*pkt_hdr & AX_RXHDR_CRC_ERR) || ++ (*pkt_hdr & AX_RXHDR_DROP_ERR)) { ++ skb_pull(skb, (pkt_len + 7) & 0xFFF8); ++ pkt_hdr++; ++ continue; ++ } ++ ++ if (pkt_cnt == 0) { ++ /* Skip IP alignment psudo header */ ++ skb_pull(skb, 2); ++ skb->len = pkt_len; ++ skb_set_tail_pointer(skb, pkt_len); ++ skb->truesize = pkt_len + sizeof(struct sk_buff); ++ ax88179_rx_checksum(skb, pkt_hdr); ++ return 1; ++ } ++ ++ ax_skb = skb_clone(skb, GFP_ATOMIC); ++ if (ax_skb) { ++ ax_skb->len = pkt_len; ++ ax_skb->data = skb->data + 2; ++ skb_set_tail_pointer(ax_skb, pkt_len); ++ ax_skb->truesize = pkt_len + sizeof(struct sk_buff); ++ ax88179_rx_checksum(ax_skb, pkt_hdr); ++ usbnet_skb_return(dev, ax_skb); ++ } else { ++ return 0; ++ } ++ ++ skb_pull(skb, (pkt_len + 7) & 0xFFF8); ++ pkt_hdr++; ++ } ++ return 1; ++} ++ ++static struct sk_buff * ++ax88179_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) ++{ ++ u32 tx_hdr1, tx_hdr2; ++ int frame_size = dev->maxpacket; ++ int mss = skb_shinfo(skb)->gso_size; ++ int headroom; ++ ++ tx_hdr1 = skb->len; ++ tx_hdr2 = mss; ++ if (((skb->len + 8) % frame_size) == 0) ++ tx_hdr2 |= 0x80008000; /* Enable padding */ ++ ++ headroom = skb_headroom(skb) - 8; ++ ++ if ((skb_header_cloned(skb) || headroom < 0) && ++ pskb_expand_head(skb, headroom < 0 ? 8 : 0, 0, GFP_ATOMIC)) { ++ dev_kfree_skb_any(skb); ++ return NULL; ++ } ++ ++ skb_push(skb, 4); ++ cpu_to_le32s(&tx_hdr2); ++ skb_copy_to_linear_data(skb, &tx_hdr2, 4); ++ ++ skb_push(skb, 4); ++ cpu_to_le32s(&tx_hdr1); ++ skb_copy_to_linear_data(skb, &tx_hdr1, 4); ++ ++ return skb; ++} ++ ++static int ax88179_link_reset(struct usbnet *dev) ++{ ++ struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; ++ u8 tmp[5], link_sts; ++ u16 mode, tmp16, delay = HZ / 10; ++ u32 tmp32 = 0x40000000; ++ unsigned long jtimeout; ++ ++ jtimeout = jiffies + delay; ++ while (tmp32 & 0x40000000) { ++ mode = 0; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, &mode); ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, ++ &ax179_data->rxctl); ++ ++ /*link up, check the usb device control TX FIFO full or empty*/ ++ ax88179_read_cmd(dev, 0x81, 0x8c, 0, 4, &tmp32); ++ ++ if (time_after(jiffies, jtimeout)) ++ return 0; ++ } ++ ++ mode = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | ++ AX_MEDIUM_RXFLOW_CTRLEN; ++ ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, PHYSICAL_LINK_STATUS, ++ 1, 1, &link_sts); ++ ++ ax88179_read_cmd(dev, AX_ACCESS_PHY, AX88179_PHY_ID, ++ GMII_PHY_PHYSR, 2, &tmp16); ++ ++ if (!(tmp16 & GMII_PHY_PHYSR_LINK)) { ++ return 0; ++ } else if (GMII_PHY_PHYSR_GIGA == (tmp16 & GMII_PHY_PHYSR_SMASK)) { ++ mode |= AX_MEDIUM_GIGAMODE | AX_MEDIUM_EN_125MHZ; ++ if (dev->net->mtu > 1500) ++ mode |= AX_MEDIUM_JUMBO_EN; ++ ++ if (link_sts & AX_USB_SS) ++ memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); ++ else if (link_sts & AX_USB_HS) ++ memcpy(tmp, &AX88179_BULKIN_SIZE[1], 5); ++ else ++ memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); ++ } else if (GMII_PHY_PHYSR_100 == (tmp16 & GMII_PHY_PHYSR_SMASK)) { ++ mode |= AX_MEDIUM_PS; ++ ++ if (link_sts & (AX_USB_SS | AX_USB_HS)) ++ memcpy(tmp, &AX88179_BULKIN_SIZE[2], 5); ++ else ++ memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); ++ } else { ++ memcpy(tmp, &AX88179_BULKIN_SIZE[3], 5); ++ } ++ ++ /* RX bulk configuration */ ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); ++ ++ dev->rx_urb_size = (1024 * (tmp[3] + 2)); ++ ++ if (tmp16 & GMII_PHY_PHYSR_FULL) ++ mode |= AX_MEDIUM_FULL_DUPLEX; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &mode); ++ ++ ax179_data->eee_enabled = ax88179_chk_eee(dev); ++ ++ netif_carrier_on(dev->net); ++ ++ return 0; ++} ++ ++static int ax88179_reset(struct usbnet *dev) ++{ ++ u8 buf[5]; ++ u16 *tmp16; ++ u8 *tmp; ++ struct ax88179_data *ax179_data = (struct ax88179_data *)dev->data; ++ struct ethtool_eee eee_data; ++ ++ tmp16 = (u16 *)buf; ++ tmp = (u8 *)buf; ++ ++ /* Power up ethernet PHY */ ++ *tmp16 = 0; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); ++ ++ *tmp16 = AX_PHYPWR_RSTCTL_IPRL; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PHYPWR_RSTCTL, 2, 2, tmp16); ++ msleep(200); ++ ++ *tmp = AX_CLK_SELECT_ACS | AX_CLK_SELECT_BCS; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_CLK_SELECT, 1, 1, tmp); ++ msleep(100); ++ ++ /* Ethernet PHY Auto Detach*/ ++ ax88179_auto_detach(dev, 0); ++ ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_NODE_ID, ETH_ALEN, ETH_ALEN, ++ dev->net->dev_addr); ++ memcpy(dev->net->perm_addr, dev->net->dev_addr, ETH_ALEN); ++ ++ /* RX bulk configuration */ ++ memcpy(tmp, &AX88179_BULKIN_SIZE[0], 5); ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_BULKIN_QCTRL, 5, 5, tmp); ++ ++ dev->rx_urb_size = 1024 * 20; ++ ++ *tmp = 0x34; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_LOW, 1, 1, tmp); ++ ++ *tmp = 0x52; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_PAUSE_WATERLVL_HIGH, ++ 1, 1, tmp); ++ ++ dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | ++ NETIF_F_RXCSUM; ++ ++ dev->net->hw_features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | ++ NETIF_F_RXCSUM; ++ ++ /* Enable checksum offload */ ++ *tmp = AX_RXCOE_IP | AX_RXCOE_TCP | AX_RXCOE_UDP | ++ AX_RXCOE_TCPV6 | AX_RXCOE_UDPV6; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RXCOE_CTL, 1, 1, tmp); ++ ++ *tmp = AX_TXCOE_IP | AX_TXCOE_TCP | AX_TXCOE_UDP | ++ AX_TXCOE_TCPV6 | AX_TXCOE_UDPV6; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_TXCOE_CTL, 1, 1, tmp); ++ ++ /* Configure RX control register => start operation */ ++ *tmp16 = AX_RX_CTL_DROPCRCERR | AX_RX_CTL_IPE | AX_RX_CTL_START | ++ AX_RX_CTL_AP | AX_RX_CTL_AMALL | AX_RX_CTL_AB; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_RX_CTL, 2, 2, tmp16); ++ ++ *tmp = AX_MONITOR_MODE_PMETYPE | AX_MONITOR_MODE_PMEPOL | ++ AX_MONITOR_MODE_RWMP; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MONITOR_MOD, 1, 1, tmp); ++ ++ /* Configure default medium type => giga */ ++ *tmp16 = AX_MEDIUM_RECEIVE_EN | AX_MEDIUM_TXFLOW_CTRLEN | ++ AX_MEDIUM_RXFLOW_CTRLEN | AX_MEDIUM_FULL_DUPLEX | ++ AX_MEDIUM_GIGAMODE; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, tmp16); ++ ++ ax88179_led_setting(dev); ++ ++ ax179_data->eee_enabled = 0; ++ ax179_data->eee_active = 0; ++ ++ ax88179_disable_eee(dev); ++ ++ ax88179_ethtool_get_eee(dev, &eee_data); ++ eee_data.advertised = 0; ++ ax88179_ethtool_set_eee(dev, &eee_data); ++ ++ /* Restart autoneg */ ++ mii_nway_restart(&dev->mii); ++ ++ usbnet_link_change(dev, 0, 0); ++ ++ return 0; ++} ++ ++static int ax88179_stop(struct usbnet *dev) ++{ ++ u16 tmp16; ++ ++ ax88179_read_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &tmp16); ++ tmp16 &= ~AX_MEDIUM_RECEIVE_EN; ++ ax88179_write_cmd(dev, AX_ACCESS_MAC, AX_MEDIUM_STATUS_MODE, ++ 2, 2, &tmp16); ++ ++ return 0; ++} ++ ++static const struct driver_info ax88179_info = { ++ .description = "ASIX AX88179 USB 3.0 Gigabit Ethernet", ++ .bind = ax88179_bind, ++ .unbind = ax88179_unbind, ++ .status = ax88179_status, ++ .link_reset = ax88179_link_reset, ++ .reset = ax88179_reset, ++ .stop = ax88179_stop, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX, ++ .rx_fixup = ax88179_rx_fixup, ++ .tx_fixup = ax88179_tx_fixup, ++}; ++ ++static const struct driver_info ax88178a_info = { ++ .description = "ASIX AX88178A USB 2.0 Gigabit Ethernet", ++ .bind = ax88179_bind, ++ .unbind = ax88179_unbind, ++ .status = ax88179_status, ++ .link_reset = ax88179_link_reset, ++ .reset = ax88179_reset, ++ .stop = ax88179_stop, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX, ++ .rx_fixup = ax88179_rx_fixup, ++ .tx_fixup = ax88179_tx_fixup, ++}; ++ ++static const struct driver_info dlink_dub1312_info = { ++ .description = "D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter", ++ .bind = ax88179_bind, ++ .unbind = ax88179_unbind, ++ .status = ax88179_status, ++ .link_reset = ax88179_link_reset, ++ .reset = ax88179_reset, ++ .stop = ax88179_stop, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX, ++ .rx_fixup = ax88179_rx_fixup, ++ .tx_fixup = ax88179_tx_fixup, ++}; ++ ++static const struct driver_info sitecom_info = { ++ .description = "Sitecom USB 3.0 to Gigabit Adapter", ++ .bind = ax88179_bind, ++ .unbind = ax88179_unbind, ++ .status = ax88179_status, ++ .link_reset = ax88179_link_reset, ++ .reset = ax88179_reset, ++ .stop = ax88179_stop, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX, ++ .rx_fixup = ax88179_rx_fixup, ++ .tx_fixup = ax88179_tx_fixup, ++}; ++ ++static const struct driver_info samsung_info = { ++ .description = "Samsung USB Ethernet Adapter", ++ .bind = ax88179_bind, ++ .unbind = ax88179_unbind, ++ .status = ax88179_status, ++ .link_reset = ax88179_link_reset, ++ .reset = ax88179_reset, ++ .stop = ax88179_stop, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX, ++ .rx_fixup = ax88179_rx_fixup, ++ .tx_fixup = ax88179_tx_fixup, ++}; ++ ++static const struct driver_info lenovo_info = { ++ .description = "Lenovo OneLinkDock Gigabit LAN", ++ .bind = ax88179_bind, ++ .unbind = ax88179_unbind, ++ .status = ax88179_status, ++ .link_reset = ax88179_link_reset, ++ .reset = ax88179_reset, ++ .stop = ax88179_stop, ++ .flags = FLAG_ETHER | FLAG_FRAMING_AX, ++ .rx_fixup = ax88179_rx_fixup, ++ .tx_fixup = ax88179_tx_fixup, ++}; ++ ++static const struct usb_device_id products[] = { ++{ ++ /* ASIX AX88179 10/100/1000 */ ++ USB_DEVICE(0x0b95, 0x1790), ++ .driver_info = (unsigned long)&ax88179_info, ++}, { ++ /* ASIX AX88178A 10/100/1000 */ ++ USB_DEVICE(0x0b95, 0x178a), ++ .driver_info = (unsigned long)&ax88178a_info, ++}, { ++ /* D-Link DUB-1312 USB 3.0 to Gigabit Ethernet Adapter */ ++ USB_DEVICE(0x2001, 0x4a00), ++ .driver_info = (unsigned long)&dlink_dub1312_info, ++}, { ++ /* Sitecom USB 3.0 to Gigabit Adapter */ ++ USB_DEVICE(0x0df6, 0x0072), ++ .driver_info = (unsigned long)&sitecom_info, ++}, { ++ /* Samsung USB Ethernet Adapter */ ++ USB_DEVICE(0x04e8, 0xa100), ++ .driver_info = (unsigned long)&samsung_info, ++}, { ++ /* Lenovo OneLinkDock Gigabit LAN */ ++ USB_DEVICE(0x17ef, 0x304b), ++ .driver_info = (unsigned long)&lenovo_info, ++}, ++ { }, ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver ax88179_178a_driver = { ++ .name = "ax88179_178a", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .suspend = ax88179_suspend, ++ .resume = ax88179_resume, ++ .reset_resume = ax88179_resume, ++ .disconnect = usbnet_disconnect, ++ .supports_autosuspend = 1, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(ax88179_178a_driver); ++ ++MODULE_DESCRIPTION("ASIX AX88179/178A based USB 3.0/2.0 Gigabit Ethernet Devices"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/catc.c backports-4.2.6-1/drivers/net/usb/catc.c +--- backports-4.2.6-1.org/drivers/net/usb/catc.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/catc.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,965 @@ ++/* ++ * Copyright (c) 2001 Vojtech Pavlik ++ * ++ * CATC EL1210A NetMate USB Ethernet driver ++ * ++ * Sponsored by SuSE ++ * ++ * Based on the work of ++ * Donald Becker ++ * ++ * Old chipset support added by Simon Evans spse@secret.org.uk 2002 ++ * - adds support for Belkin F5U011 ++ */ ++ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ * ++ * Should you need to contact me, the author, you can do so either by ++ * e-mail - mail your message to vojtech@suse.cz, or by paper mail: ++ * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic ++ */ ++ ++#include <linux/module.h> ++#include <linux/kernel.h> ++#include <linux/string.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/skbuff.h> ++#include <linux/spinlock.h> ++#include <linux/ethtool.h> ++#include <linux/crc32.h> ++#include <linux/bitops.h> ++#include <linux/gfp.h> ++#include <asm/uaccess.h> ++ ++#undef DEBUG ++ ++#include <linux/usb.h> ++ ++/* ++ * Version information. ++ */ ++ ++#define DRIVER_VERSION "v2.8" ++#define DRIVER_AUTHOR "Vojtech Pavlik vojtech@suse.cz" ++#define DRIVER_DESC "CATC EL1210A NetMate USB Ethernet driver" ++#define SHORT_DRIVER_DESC "EL1210A NetMate USB Ethernet" ++ ++MODULE_AUTHOR(DRIVER_AUTHOR); ++MODULE_DESCRIPTION(DRIVER_DESC); ++MODULE_LICENSE("GPL"); ++ ++static const char driver_name[] = "catc"; ++ ++/* ++ * Some defines. ++ */ ++ ++#define STATS_UPDATE (HZ) /* Time between stats updates */ ++#define TX_TIMEOUT (5*HZ) /* Max time the queue can be stopped */ ++#define PKT_SZ 1536 /* Max Ethernet packet size */ ++#define RX_MAX_BURST 15 /* Max packets per rx buffer (> 0, < 16) */ ++#define TX_MAX_BURST 15 /* Max full sized packets per tx buffer (> 0) */ ++#define CTRL_QUEUE 16 /* Max control requests in flight (power of two) */ ++#define RX_PKT_SZ 1600 /* Max size of receive packet for F5U011 */ ++ ++/* ++ * Control requests. ++ */ ++ ++enum control_requests { ++ ReadMem = 0xf1, ++ GetMac = 0xf2, ++ Reset = 0xf4, ++ SetMac = 0xf5, ++ SetRxMode = 0xf5, /* F5U011 only */ ++ WriteROM = 0xf8, ++ SetReg = 0xfa, ++ GetReg = 0xfb, ++ WriteMem = 0xfc, ++ ReadROM = 0xfd, ++}; ++ ++/* ++ * Registers. ++ */ ++ ++enum register_offsets { ++ TxBufCount = 0x20, ++ RxBufCount = 0x21, ++ OpModes = 0x22, ++ TxQed = 0x23, ++ RxQed = 0x24, ++ MaxBurst = 0x25, ++ RxUnit = 0x60, ++ EthStatus = 0x61, ++ StationAddr0 = 0x67, ++ EthStats = 0x69, ++ LEDCtrl = 0x81, ++}; ++ ++enum eth_stats { ++ TxSingleColl = 0x00, ++ TxMultiColl = 0x02, ++ TxExcessColl = 0x04, ++ RxFramErr = 0x06, ++}; ++ ++enum op_mode_bits { ++ Op3MemWaits = 0x03, ++ OpLenInclude = 0x08, ++ OpRxMerge = 0x10, ++ OpTxMerge = 0x20, ++ OpWin95bugfix = 0x40, ++ OpLoopback = 0x80, ++}; ++ ++enum rx_filter_bits { ++ RxEnable = 0x01, ++ RxPolarity = 0x02, ++ RxForceOK = 0x04, ++ RxMultiCast = 0x08, ++ RxPromisc = 0x10, ++ AltRxPromisc = 0x20, /* F5U011 uses different bit */ ++}; ++ ++enum led_values { ++ LEDFast = 0x01, ++ LEDSlow = 0x02, ++ LEDFlash = 0x03, ++ LEDPulse = 0x04, ++ LEDLink = 0x08, ++}; ++ ++enum link_status { ++ LinkNoChange = 0, ++ LinkGood = 1, ++ LinkBad = 2 ++}; ++ ++/* ++ * The catc struct. ++ */ ++ ++#define CTRL_RUNNING 0 ++#define RX_RUNNING 1 ++#define TX_RUNNING 2 ++ ++struct catc { ++ struct net_device *netdev; ++ struct usb_device *usbdev; ++ ++ unsigned long flags; ++ ++ unsigned int tx_ptr, tx_idx; ++ unsigned int ctrl_head, ctrl_tail; ++ spinlock_t tx_lock, ctrl_lock; ++ ++ u8 tx_buf[2][TX_MAX_BURST * (PKT_SZ + 2)]; ++ u8 rx_buf[RX_MAX_BURST * (PKT_SZ + 2)]; ++ u8 irq_buf[2]; ++ u8 ctrl_buf[64]; ++ struct usb_ctrlrequest ctrl_dr; ++ ++ struct timer_list timer; ++ u8 stats_buf[8]; ++ u16 stats_vals[4]; ++ unsigned long last_stats; ++ ++ u8 multicast[64]; ++ ++ struct ctrl_queue { ++ u8 dir; ++ u8 request; ++ u16 value; ++ u16 index; ++ void *buf; ++ int len; ++ void (*callback)(struct catc *catc, struct ctrl_queue *q); ++ } ctrl_queue[CTRL_QUEUE]; ++ ++ struct urb *tx_urb, *rx_urb, *irq_urb, *ctrl_urb; ++ ++ u8 is_f5u011; /* Set if device is an F5U011 */ ++ u8 rxmode[2]; /* Used for F5U011 */ ++ atomic_t recq_sz; /* Used for F5U011 - counter of waiting rx packets */ ++}; ++ ++/* ++ * Useful macros. ++ */ ++ ++#define catc_get_mac(catc, mac) catc_ctrl_msg(catc, USB_DIR_IN, GetMac, 0, 0, mac, 6) ++#define catc_reset(catc) catc_ctrl_msg(catc, USB_DIR_OUT, Reset, 0, 0, NULL, 0) ++#define catc_set_reg(catc, reg, val) catc_ctrl_msg(catc, USB_DIR_OUT, SetReg, val, reg, NULL, 0) ++#define catc_get_reg(catc, reg, buf) catc_ctrl_msg(catc, USB_DIR_IN, GetReg, 0, reg, buf, 1) ++#define catc_write_mem(catc, addr, buf, size) catc_ctrl_msg(catc, USB_DIR_OUT, WriteMem, 0, addr, buf, size) ++#define catc_read_mem(catc, addr, buf, size) catc_ctrl_msg(catc, USB_DIR_IN, ReadMem, 0, addr, buf, size) ++ ++#define f5u011_rxmode(catc, rxmode) catc_ctrl_msg(catc, USB_DIR_OUT, SetRxMode, 0, 1, rxmode, 2) ++#define f5u011_rxmode_async(catc, rxmode) catc_ctrl_async(catc, USB_DIR_OUT, SetRxMode, 0, 1, &rxmode, 2, NULL) ++#define f5u011_mchash_async(catc, hash) catc_ctrl_async(catc, USB_DIR_OUT, SetRxMode, 0, 2, &hash, 8, NULL) ++ ++#define catc_set_reg_async(catc, reg, val) catc_ctrl_async(catc, USB_DIR_OUT, SetReg, val, reg, NULL, 0, NULL) ++#define catc_get_reg_async(catc, reg, cb) catc_ctrl_async(catc, USB_DIR_IN, GetReg, 0, reg, NULL, 1, cb) ++#define catc_write_mem_async(catc, addr, buf, size) catc_ctrl_async(catc, USB_DIR_OUT, WriteMem, 0, addr, buf, size, NULL) ++ ++/* ++ * Receive routines. ++ */ ++ ++static void catc_rx_done(struct urb *urb) ++{ ++ struct catc *catc = urb->context; ++ u8 *pkt_start = urb->transfer_buffer; ++ struct sk_buff *skb; ++ int pkt_len, pkt_offset = 0; ++ int status = urb->status; ++ ++ if (!catc->is_f5u011) { ++ clear_bit(RX_RUNNING, &catc->flags); ++ pkt_offset = 2; ++ } ++ ++ if (status) { ++ dev_dbg(&urb->dev->dev, "rx_done, status %d, length %d\n", ++ status, urb->actual_length); ++ return; ++ } ++ ++ do { ++ if(!catc->is_f5u011) { ++ pkt_len = le16_to_cpup((__le16*)pkt_start); ++ if (pkt_len > urb->actual_length) { ++ catc->netdev->stats.rx_length_errors++; ++ catc->netdev->stats.rx_errors++; ++ break; ++ } ++ } else { ++ pkt_len = urb->actual_length; ++ } ++ ++ if (!(skb = dev_alloc_skb(pkt_len))) ++ return; ++ ++ skb_copy_to_linear_data(skb, pkt_start + pkt_offset, pkt_len); ++ skb_put(skb, pkt_len); ++ ++ skb->protocol = eth_type_trans(skb, catc->netdev); ++ netif_rx(skb); ++ ++ catc->netdev->stats.rx_packets++; ++ catc->netdev->stats.rx_bytes += pkt_len; ++ ++ /* F5U011 only does one packet per RX */ ++ if (catc->is_f5u011) ++ break; ++ pkt_start += (((pkt_len + 1) >> 6) + 1) << 6; ++ ++ } while (pkt_start - (u8 *) urb->transfer_buffer < urb->actual_length); ++ ++ if (catc->is_f5u011) { ++ if (atomic_read(&catc->recq_sz)) { ++ int state; ++ atomic_dec(&catc->recq_sz); ++ netdev_dbg(catc->netdev, "getting extra packet\n"); ++ urb->dev = catc->usbdev; ++ if ((state = usb_submit_urb(urb, GFP_ATOMIC)) < 0) { ++ netdev_dbg(catc->netdev, ++ "submit(rx_urb) status %d\n", state); ++ } ++ } else { ++ clear_bit(RX_RUNNING, &catc->flags); ++ } ++ } ++} ++ ++static void catc_irq_done(struct urb *urb) ++{ ++ struct catc *catc = urb->context; ++ u8 *data = urb->transfer_buffer; ++ int status = urb->status; ++ unsigned int hasdata = 0, linksts = LinkNoChange; ++ int res; ++ ++ if (!catc->is_f5u011) { ++ hasdata = data[1] & 0x80; ++ if (data[1] & 0x40) ++ linksts = LinkGood; ++ else if (data[1] & 0x20) ++ linksts = LinkBad; ++ } else { ++ hasdata = (unsigned int)(be16_to_cpup((__be16*)data) & 0x0fff); ++ if (data[0] == 0x90) ++ linksts = LinkGood; ++ else if (data[0] == 0xA0) ++ linksts = LinkBad; ++ } ++ ++ switch (status) { ++ case 0: /* success */ ++ break; ++ case -ECONNRESET: /* unlink */ ++ case -ENOENT: ++ case -ESHUTDOWN: ++ return; ++ /* -EPIPE: should clear the halt */ ++ default: /* error */ ++ dev_dbg(&urb->dev->dev, ++ "irq_done, status %d, data %02x %02x.\n", ++ status, data[0], data[1]); ++ goto resubmit; ++ } ++ ++ if (linksts == LinkGood) { ++ netif_carrier_on(catc->netdev); ++ netdev_dbg(catc->netdev, "link ok\n"); ++ } ++ ++ if (linksts == LinkBad) { ++ netif_carrier_off(catc->netdev); ++ netdev_dbg(catc->netdev, "link bad\n"); ++ } ++ ++ if (hasdata) { ++ if (test_and_set_bit(RX_RUNNING, &catc->flags)) { ++ if (catc->is_f5u011) ++ atomic_inc(&catc->recq_sz); ++ } else { ++ catc->rx_urb->dev = catc->usbdev; ++ if ((res = usb_submit_urb(catc->rx_urb, GFP_ATOMIC)) < 0) { ++ dev_err(&catc->usbdev->dev, ++ "submit(rx_urb) status %d\n", res); ++ } ++ } ++ } ++resubmit: ++ res = usb_submit_urb (urb, GFP_ATOMIC); ++ if (res) ++ dev_err(&catc->usbdev->dev, ++ "can't resubmit intr, %s-%s, status %d\n", ++ catc->usbdev->bus->bus_name, ++ catc->usbdev->devpath, res); ++} ++ ++/* ++ * Transmit routines. ++ */ ++ ++static int catc_tx_run(struct catc *catc) ++{ ++ int status; ++ ++ if (catc->is_f5u011) ++ catc->tx_ptr = (catc->tx_ptr + 63) & ~63; ++ ++ catc->tx_urb->transfer_buffer_length = catc->tx_ptr; ++ catc->tx_urb->transfer_buffer = catc->tx_buf[catc->tx_idx]; ++ catc->tx_urb->dev = catc->usbdev; ++ ++ if ((status = usb_submit_urb(catc->tx_urb, GFP_ATOMIC)) < 0) ++ dev_err(&catc->usbdev->dev, "submit(tx_urb), status %d\n", ++ status); ++ ++ catc->tx_idx = !catc->tx_idx; ++ catc->tx_ptr = 0; ++ ++ catc->netdev->trans_start = jiffies; ++ return status; ++} ++ ++static void catc_tx_done(struct urb *urb) ++{ ++ struct catc *catc = urb->context; ++ unsigned long flags; ++ int r, status = urb->status; ++ ++ if (status == -ECONNRESET) { ++ dev_dbg(&urb->dev->dev, "Tx Reset.\n"); ++ urb->status = 0; ++ catc->netdev->trans_start = jiffies; ++ catc->netdev->stats.tx_errors++; ++ clear_bit(TX_RUNNING, &catc->flags); ++ netif_wake_queue(catc->netdev); ++ return; ++ } ++ ++ if (status) { ++ dev_dbg(&urb->dev->dev, "tx_done, status %d, length %d\n", ++ status, urb->actual_length); ++ return; ++ } ++ ++ spin_lock_irqsave(&catc->tx_lock, flags); ++ ++ if (catc->tx_ptr) { ++ r = catc_tx_run(catc); ++ if (unlikely(r < 0)) ++ clear_bit(TX_RUNNING, &catc->flags); ++ } else { ++ clear_bit(TX_RUNNING, &catc->flags); ++ } ++ ++ netif_wake_queue(catc->netdev); ++ ++ spin_unlock_irqrestore(&catc->tx_lock, flags); ++} ++ ++static netdev_tx_t catc_start_xmit(struct sk_buff *skb, ++ struct net_device *netdev) ++{ ++ struct catc *catc = netdev_priv(netdev); ++ unsigned long flags; ++ int r = 0; ++ char *tx_buf; ++ ++ spin_lock_irqsave(&catc->tx_lock, flags); ++ ++ catc->tx_ptr = (((catc->tx_ptr - 1) >> 6) + 1) << 6; ++ tx_buf = catc->tx_buf[catc->tx_idx] + catc->tx_ptr; ++ if (catc->is_f5u011) ++ *(__be16 *)tx_buf = cpu_to_be16(skb->len); ++ else ++ *(__le16 *)tx_buf = cpu_to_le16(skb->len); ++ skb_copy_from_linear_data(skb, tx_buf + 2, skb->len); ++ catc->tx_ptr += skb->len + 2; ++ ++ if (!test_and_set_bit(TX_RUNNING, &catc->flags)) { ++ r = catc_tx_run(catc); ++ if (r < 0) ++ clear_bit(TX_RUNNING, &catc->flags); ++ } ++ ++ if ((catc->is_f5u011 && catc->tx_ptr) || ++ (catc->tx_ptr >= ((TX_MAX_BURST - 1) * (PKT_SZ + 2)))) ++ netif_stop_queue(netdev); ++ ++ spin_unlock_irqrestore(&catc->tx_lock, flags); ++ ++ if (r >= 0) { ++ catc->netdev->stats.tx_bytes += skb->len; ++ catc->netdev->stats.tx_packets++; ++ } ++ ++ dev_kfree_skb(skb); ++ ++ return NETDEV_TX_OK; ++} ++ ++static void catc_tx_timeout(struct net_device *netdev) ++{ ++ struct catc *catc = netdev_priv(netdev); ++ ++ dev_warn(&netdev->dev, "Transmit timed out.\n"); ++ usb_unlink_urb(catc->tx_urb); ++} ++ ++/* ++ * Control messages. ++ */ ++ ++static int catc_ctrl_msg(struct catc *catc, u8 dir, u8 request, u16 value, u16 index, void *buf, int len) ++{ ++ int retval = usb_control_msg(catc->usbdev, ++ dir ? usb_rcvctrlpipe(catc->usbdev, 0) : usb_sndctrlpipe(catc->usbdev, 0), ++ request, 0x40 | dir, value, index, buf, len, 1000); ++ return retval < 0 ? retval : 0; ++} ++ ++static void catc_ctrl_run(struct catc *catc) ++{ ++ struct ctrl_queue *q = catc->ctrl_queue + catc->ctrl_tail; ++ struct usb_device *usbdev = catc->usbdev; ++ struct urb *urb = catc->ctrl_urb; ++ struct usb_ctrlrequest *dr = &catc->ctrl_dr; ++ int status; ++ ++ dr->bRequest = q->request; ++ dr->bRequestType = 0x40 | q->dir; ++ dr->wValue = cpu_to_le16(q->value); ++ dr->wIndex = cpu_to_le16(q->index); ++ dr->wLength = cpu_to_le16(q->len); ++ ++ urb->pipe = q->dir ? usb_rcvctrlpipe(usbdev, 0) : usb_sndctrlpipe(usbdev, 0); ++ urb->transfer_buffer_length = q->len; ++ urb->transfer_buffer = catc->ctrl_buf; ++ urb->setup_packet = (void *) dr; ++ urb->dev = usbdev; ++ ++ if (!q->dir && q->buf && q->len) ++ memcpy(catc->ctrl_buf, q->buf, q->len); ++ ++ if ((status = usb_submit_urb(catc->ctrl_urb, GFP_ATOMIC))) ++ dev_err(&catc->usbdev->dev, "submit(ctrl_urb) status %d\n", ++ status); ++} ++ ++static void catc_ctrl_done(struct urb *urb) ++{ ++ struct catc *catc = urb->context; ++ struct ctrl_queue *q; ++ unsigned long flags; ++ int status = urb->status; ++ ++ if (status) ++ dev_dbg(&urb->dev->dev, "ctrl_done, status %d, len %d.\n", ++ status, urb->actual_length); ++ ++ spin_lock_irqsave(&catc->ctrl_lock, flags); ++ ++ q = catc->ctrl_queue + catc->ctrl_tail; ++ ++ if (q->dir) { ++ if (q->buf && q->len) ++ memcpy(q->buf, catc->ctrl_buf, q->len); ++ else ++ q->buf = catc->ctrl_buf; ++ } ++ ++ if (q->callback) ++ q->callback(catc, q); ++ ++ catc->ctrl_tail = (catc->ctrl_tail + 1) & (CTRL_QUEUE - 1); ++ ++ if (catc->ctrl_head != catc->ctrl_tail) ++ catc_ctrl_run(catc); ++ else ++ clear_bit(CTRL_RUNNING, &catc->flags); ++ ++ spin_unlock_irqrestore(&catc->ctrl_lock, flags); ++} ++ ++static int catc_ctrl_async(struct catc *catc, u8 dir, u8 request, u16 value, ++ u16 index, void *buf, int len, void (*callback)(struct catc *catc, struct ctrl_queue *q)) ++{ ++ struct ctrl_queue *q; ++ int retval = 0; ++ unsigned long flags; ++ ++ spin_lock_irqsave(&catc->ctrl_lock, flags); ++ ++ q = catc->ctrl_queue + catc->ctrl_head; ++ ++ q->dir = dir; ++ q->request = request; ++ q->value = value; ++ q->index = index; ++ q->buf = buf; ++ q->len = len; ++ q->callback = callback; ++ ++ catc->ctrl_head = (catc->ctrl_head + 1) & (CTRL_QUEUE - 1); ++ ++ if (catc->ctrl_head == catc->ctrl_tail) { ++ dev_err(&catc->usbdev->dev, "ctrl queue full\n"); ++ catc->ctrl_tail = (catc->ctrl_tail + 1) & (CTRL_QUEUE - 1); ++ retval = -1; ++ } ++ ++ if (!test_and_set_bit(CTRL_RUNNING, &catc->flags)) ++ catc_ctrl_run(catc); ++ ++ spin_unlock_irqrestore(&catc->ctrl_lock, flags); ++ ++ return retval; ++} ++ ++/* ++ * Statistics. ++ */ ++ ++static void catc_stats_done(struct catc *catc, struct ctrl_queue *q) ++{ ++ int index = q->index - EthStats; ++ u16 data, last; ++ ++ catc->stats_buf[index] = *((char *)q->buf); ++ ++ if (index & 1) ++ return; ++ ++ data = ((u16)catc->stats_buf[index] << 8) | catc->stats_buf[index + 1]; ++ last = catc->stats_vals[index >> 1]; ++ ++ switch (index) { ++ case TxSingleColl: ++ case TxMultiColl: ++ catc->netdev->stats.collisions += data - last; ++ break; ++ case TxExcessColl: ++ catc->netdev->stats.tx_aborted_errors += data - last; ++ catc->netdev->stats.tx_errors += data - last; ++ break; ++ case RxFramErr: ++ catc->netdev->stats.rx_frame_errors += data - last; ++ catc->netdev->stats.rx_errors += data - last; ++ break; ++ } ++ ++ catc->stats_vals[index >> 1] = data; ++} ++ ++static void catc_stats_timer(unsigned long data) ++{ ++ struct catc *catc = (void *) data; ++ int i; ++ ++ for (i = 0; i < 8; i++) ++ catc_get_reg_async(catc, EthStats + 7 - i, catc_stats_done); ++ ++ mod_timer(&catc->timer, jiffies + STATS_UPDATE); ++} ++ ++/* ++ * Receive modes. Broadcast, Multicast, Promisc. ++ */ ++ ++static void catc_multicast(unsigned char *addr, u8 *multicast) ++{ ++ u32 crc; ++ ++ crc = ether_crc_le(6, addr); ++ multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7); ++} ++ ++static void catc_set_multicast_list(struct net_device *netdev) ++{ ++ struct catc *catc = netdev_priv(netdev); ++ struct netdev_hw_addr *ha; ++ u8 broadcast[ETH_ALEN]; ++ u8 rx = RxEnable | RxPolarity | RxMultiCast; ++ ++ eth_broadcast_addr(broadcast); ++ memset(catc->multicast, 0, 64); ++ ++ catc_multicast(broadcast, catc->multicast); ++ catc_multicast(netdev->dev_addr, catc->multicast); ++ ++ if (netdev->flags & IFF_PROMISC) { ++ memset(catc->multicast, 0xff, 64); ++ rx |= (!catc->is_f5u011) ? RxPromisc : AltRxPromisc; ++ } ++ ++ if (netdev->flags & IFF_ALLMULTI) { ++ memset(catc->multicast, 0xff, 64); ++ } else { ++ netdev_for_each_mc_addr(ha, netdev) { ++ u32 crc = ether_crc_le(6, ha->addr); ++ if (!catc->is_f5u011) { ++ catc->multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7); ++ } else { ++ catc->multicast[7-(crc >> 29)] |= 1 << ((crc >> 26) & 7); ++ } ++ } ++ } ++ if (!catc->is_f5u011) { ++ catc_set_reg_async(catc, RxUnit, rx); ++ catc_write_mem_async(catc, 0xfa80, catc->multicast, 64); ++ } else { ++ f5u011_mchash_async(catc, catc->multicast); ++ if (catc->rxmode[0] != rx) { ++ catc->rxmode[0] = rx; ++ netdev_dbg(catc->netdev, ++ "Setting RX mode to %2.2X %2.2X\n", ++ catc->rxmode[0], catc->rxmode[1]); ++ f5u011_rxmode_async(catc, catc->rxmode); ++ } ++ } ++} ++ ++static void catc_get_drvinfo(struct net_device *dev, ++ struct ethtool_drvinfo *info) ++{ ++ struct catc *catc = netdev_priv(dev); ++ strlcpy(info->driver, driver_name, sizeof(info->driver)); ++ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); ++ usb_make_path(catc->usbdev, info->bus_info, sizeof(info->bus_info)); ++} ++ ++static int catc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) ++{ ++ struct catc *catc = netdev_priv(dev); ++ if (!catc->is_f5u011) ++ return -EOPNOTSUPP; ++ ++ cmd->supported = SUPPORTED_10baseT_Half | SUPPORTED_TP; ++ cmd->advertising = ADVERTISED_10baseT_Half | ADVERTISED_TP; ++ ethtool_cmd_speed_set(cmd, SPEED_10); ++ cmd->duplex = DUPLEX_HALF; ++ cmd->port = PORT_TP; ++ cmd->phy_address = 0; ++ cmd->transceiver = XCVR_INTERNAL; ++ cmd->autoneg = AUTONEG_DISABLE; ++ cmd->maxtxpkt = 1; ++ cmd->maxrxpkt = 1; ++ return 0; ++} ++ ++static const struct ethtool_ops ops = { ++ .get_drvinfo = catc_get_drvinfo, ++ .get_settings = catc_get_settings, ++ .get_link = ethtool_op_get_link ++}; ++ ++/* ++ * Open, close. ++ */ ++ ++static int catc_open(struct net_device *netdev) ++{ ++ struct catc *catc = netdev_priv(netdev); ++ int status; ++ ++ catc->irq_urb->dev = catc->usbdev; ++ if ((status = usb_submit_urb(catc->irq_urb, GFP_KERNEL)) < 0) { ++ dev_err(&catc->usbdev->dev, "submit(irq_urb) status %d\n", ++ status); ++ return -1; ++ } ++ ++ netif_start_queue(netdev); ++ ++ if (!catc->is_f5u011) ++ mod_timer(&catc->timer, jiffies + STATS_UPDATE); ++ ++ return 0; ++} ++ ++static int catc_stop(struct net_device *netdev) ++{ ++ struct catc *catc = netdev_priv(netdev); ++ ++ netif_stop_queue(netdev); ++ ++ if (!catc->is_f5u011) ++ del_timer_sync(&catc->timer); ++ ++ usb_kill_urb(catc->rx_urb); ++ usb_kill_urb(catc->tx_urb); ++ usb_kill_urb(catc->irq_urb); ++ usb_kill_urb(catc->ctrl_urb); ++ ++ return 0; ++} ++ ++static const struct net_device_ops catc_netdev_ops = { ++ .ndo_open = catc_open, ++ .ndo_stop = catc_stop, ++ .ndo_start_xmit = catc_start_xmit, ++ ++ .ndo_tx_timeout = catc_tx_timeout, ++ .ndo_set_rx_mode = catc_set_multicast_list, ++ .ndo_change_mtu = eth_change_mtu, ++ .ndo_set_mac_address = eth_mac_addr, ++ .ndo_validate_addr = eth_validate_addr, ++}; ++ ++/* ++ * USB probe, disconnect. ++ */ ++ ++static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id) ++{ ++ struct device *dev = &intf->dev; ++ struct usb_device *usbdev = interface_to_usbdev(intf); ++ struct net_device *netdev; ++ struct catc *catc; ++ u8 broadcast[ETH_ALEN]; ++ int i, pktsz; ++ ++ if (usb_set_interface(usbdev, ++ intf->altsetting->desc.bInterfaceNumber, 1)) { ++ dev_err(dev, "Can't set altsetting 1.\n"); ++ return -EIO; ++ } ++ ++ netdev = alloc_etherdev(sizeof(struct catc)); ++ if (!netdev) ++ return -ENOMEM; ++ ++ catc = netdev_priv(netdev); ++ ++ netdev->netdev_ops = &catc_netdev_ops; ++ netdev->watchdog_timeo = TX_TIMEOUT; ++ netdev->ethtool_ops = &ops; ++ ++ catc->usbdev = usbdev; ++ catc->netdev = netdev; ++ ++ spin_lock_init(&catc->tx_lock); ++ spin_lock_init(&catc->ctrl_lock); ++ ++ init_timer(&catc->timer); ++ catc->timer.data = (long) catc; ++ catc->timer.function = catc_stats_timer; ++ ++ catc->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL); ++ catc->tx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ catc->rx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ catc->irq_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if ((!catc->ctrl_urb) || (!catc->tx_urb) || ++ (!catc->rx_urb) || (!catc->irq_urb)) { ++ dev_err(&intf->dev, "No free urbs available.\n"); ++ usb_free_urb(catc->ctrl_urb); ++ usb_free_urb(catc->tx_urb); ++ usb_free_urb(catc->rx_urb); ++ usb_free_urb(catc->irq_urb); ++ free_netdev(netdev); ++ return -ENOMEM; ++ } ++ ++ /* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */ ++ if (le16_to_cpu(usbdev->descriptor.idVendor) == 0x0423 && ++ le16_to_cpu(usbdev->descriptor.idProduct) == 0xa && ++ le16_to_cpu(catc->usbdev->descriptor.bcdDevice) == 0x0130) { ++ dev_dbg(dev, "Testing for f5u011\n"); ++ catc->is_f5u011 = 1; ++ atomic_set(&catc->recq_sz, 0); ++ pktsz = RX_PKT_SZ; ++ } else { ++ pktsz = RX_MAX_BURST * (PKT_SZ + 2); ++ } ++ ++ usb_fill_control_urb(catc->ctrl_urb, usbdev, usb_sndctrlpipe(usbdev, 0), ++ NULL, NULL, 0, catc_ctrl_done, catc); ++ ++ usb_fill_bulk_urb(catc->tx_urb, usbdev, usb_sndbulkpipe(usbdev, 1), ++ NULL, 0, catc_tx_done, catc); ++ ++ usb_fill_bulk_urb(catc->rx_urb, usbdev, usb_rcvbulkpipe(usbdev, 1), ++ catc->rx_buf, pktsz, catc_rx_done, catc); ++ ++ usb_fill_int_urb(catc->irq_urb, usbdev, usb_rcvintpipe(usbdev, 2), ++ catc->irq_buf, 2, catc_irq_done, catc, 1); ++ ++ if (!catc->is_f5u011) { ++ dev_dbg(dev, "Checking memory size\n"); ++ ++ i = 0x12345678; ++ catc_write_mem(catc, 0x7a80, &i, 4); ++ i = 0x87654321; ++ catc_write_mem(catc, 0xfa80, &i, 4); ++ catc_read_mem(catc, 0x7a80, &i, 4); ++ ++ switch (i) { ++ case 0x12345678: ++ catc_set_reg(catc, TxBufCount, 8); ++ catc_set_reg(catc, RxBufCount, 32); ++ dev_dbg(dev, "64k Memory\n"); ++ break; ++ default: ++ dev_warn(&intf->dev, ++ "Couldn't detect memory size, assuming 32k\n"); ++ case 0x87654321: ++ catc_set_reg(catc, TxBufCount, 4); ++ catc_set_reg(catc, RxBufCount, 16); ++ dev_dbg(dev, "32k Memory\n"); ++ break; ++ } ++ ++ dev_dbg(dev, "Getting MAC from SEEROM.\n"); ++ ++ catc_get_mac(catc, netdev->dev_addr); ++ ++ dev_dbg(dev, "Setting MAC into registers.\n"); ++ ++ for (i = 0; i < 6; i++) ++ catc_set_reg(catc, StationAddr0 - i, netdev->dev_addr[i]); ++ ++ dev_dbg(dev, "Filling the multicast list.\n"); ++ ++ eth_broadcast_addr(broadcast); ++ catc_multicast(broadcast, catc->multicast); ++ catc_multicast(netdev->dev_addr, catc->multicast); ++ catc_write_mem(catc, 0xfa80, catc->multicast, 64); ++ ++ dev_dbg(dev, "Clearing error counters.\n"); ++ ++ for (i = 0; i < 8; i++) ++ catc_set_reg(catc, EthStats + i, 0); ++ catc->last_stats = jiffies; ++ ++ dev_dbg(dev, "Enabling.\n"); ++ ++ catc_set_reg(catc, MaxBurst, RX_MAX_BURST); ++ catc_set_reg(catc, OpModes, OpTxMerge | OpRxMerge | OpLenInclude | Op3MemWaits); ++ catc_set_reg(catc, LEDCtrl, LEDLink); ++ catc_set_reg(catc, RxUnit, RxEnable | RxPolarity | RxMultiCast); ++ } else { ++ dev_dbg(dev, "Performing reset\n"); ++ catc_reset(catc); ++ catc_get_mac(catc, netdev->dev_addr); ++ ++ dev_dbg(dev, "Setting RX Mode\n"); ++ catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast; ++ catc->rxmode[1] = 0; ++ f5u011_rxmode(catc, catc->rxmode); ++ } ++ dev_dbg(dev, "Init done.\n"); ++ printk(KERN_INFO "%s: %s USB Ethernet at usb-%s-%s, %pM.\n", ++ netdev->name, (catc->is_f5u011) ? "Belkin F5U011" : "CATC EL1210A NetMate", ++ usbdev->bus->bus_name, usbdev->devpath, netdev->dev_addr); ++ usb_set_intfdata(intf, catc); ++ ++ SET_NETDEV_DEV(netdev, &intf->dev); ++ if (register_netdev(netdev) != 0) { ++ usb_set_intfdata(intf, NULL); ++ usb_free_urb(catc->ctrl_urb); ++ usb_free_urb(catc->tx_urb); ++ usb_free_urb(catc->rx_urb); ++ usb_free_urb(catc->irq_urb); ++ free_netdev(netdev); ++ return -EIO; ++ } ++ return 0; ++} ++ ++static void catc_disconnect(struct usb_interface *intf) ++{ ++ struct catc *catc = usb_get_intfdata(intf); ++ ++ usb_set_intfdata(intf, NULL); ++ if (catc) { ++ unregister_netdev(catc->netdev); ++ usb_free_urb(catc->ctrl_urb); ++ usb_free_urb(catc->tx_urb); ++ usb_free_urb(catc->rx_urb); ++ usb_free_urb(catc->irq_urb); ++ free_netdev(catc->netdev); ++ } ++} ++ ++/* ++ * Module functions and tables. ++ */ ++ ++static struct usb_device_id catc_id_table [] = { ++ { USB_DEVICE(0x0423, 0xa) }, /* CATC Netmate, Belkin F5U011 */ ++ { USB_DEVICE(0x0423, 0xc) }, /* CATC Netmate II, Belkin F5U111 */ ++ { USB_DEVICE(0x08d1, 0x1) }, /* smartBridges smartNIC */ ++ { } ++}; ++ ++MODULE_DEVICE_TABLE(usb, catc_id_table); ++ ++static struct usb_driver catc_driver = { ++ .name = driver_name, ++ .probe = catc_probe, ++ .disconnect = catc_disconnect, ++ .id_table = catc_id_table, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(catc_driver); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/cdc_eem.c backports-4.2.6-1/drivers/net/usb/cdc_eem.c +--- backports-4.2.6-1.org/drivers/net/usb/cdc_eem.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/cdc_eem.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,381 @@ ++/* ++ * USB CDC EEM network interface driver ++ * Copyright (C) 2009 Oberthur Technologies ++ * by Omar Laazimani, Olivier Condemine ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ctype.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/crc32.h> ++#include <linux/usb/cdc.h> ++#include <linux/usb/usbnet.h> ++#include <linux/gfp.h> ++#include <linux/if_vlan.h> ++ ++ ++/* ++ * This driver is an implementation of the CDC "Ethernet Emulation ++ * Model" (EEM) specification, which encapsulates Ethernet frames ++ * for transport over USB using a simpler USB device model than the ++ * previous CDC "Ethernet Control Model" (ECM, or "CDC Ethernet"). ++ * ++ * For details, see www.usb.org/developers/devclass_docs/CDC_EEM10.pdf ++ * ++ * This version has been tested with GIGAntIC WuaoW SIM Smart Card on 2.6.24, ++ * 2.6.27 and 2.6.30rc2 kernel. ++ * It has also been validated on Openmoko Om 2008.12 (based on 2.6.24 kernel). ++ * build on 23-April-2009 ++ */ ++ ++#define EEM_HEAD 2 /* 2 byte header */ ++ ++/*-------------------------------------------------------------------------*/ ++ ++static void eem_linkcmd_complete(struct urb *urb) ++{ ++ dev_kfree_skb(urb->context); ++ usb_free_urb(urb); ++} ++ ++static void eem_linkcmd(struct usbnet *dev, struct sk_buff *skb) ++{ ++ struct urb *urb; ++ int status; ++ ++ urb = usb_alloc_urb(0, GFP_ATOMIC); ++ if (!urb) ++ goto fail; ++ ++ usb_fill_bulk_urb(urb, dev->udev, dev->out, ++ skb->data, skb->len, eem_linkcmd_complete, skb); ++ ++ status = usb_submit_urb(urb, GFP_ATOMIC); ++ if (status) { ++ usb_free_urb(urb); ++fail: ++ dev_kfree_skb(skb); ++ netdev_warn(dev->net, "link cmd failure\n"); ++ return; ++ } ++} ++ ++static int eem_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int status = 0; ++ ++ status = usbnet_get_endpoints(dev, intf); ++ if (status < 0) { ++ usb_set_intfdata(intf, NULL); ++ usb_driver_release_interface(driver_of(intf), intf); ++ return status; ++ } ++ ++ /* no jumbogram (16K) support for now */ ++ ++ dev->net->hard_header_len += EEM_HEAD + ETH_FCS_LEN + VLAN_HLEN; ++ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; ++ ++ return 0; ++} ++ ++/* ++ * EEM permits packing multiple Ethernet frames into USB transfers ++ * (a "bundle"), but for TX we don't try to do that. ++ */ ++static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ++ gfp_t flags) ++{ ++ struct sk_buff *skb2 = NULL; ++ u16 len = skb->len; ++ u32 crc = 0; ++ int padlen = 0; ++ ++ /* When ((len + EEM_HEAD + ETH_FCS_LEN) % dev->maxpacket) is ++ * zero, stick two bytes of zero length EEM packet on the end. ++ * Else the framework would add invalid single byte padding, ++ * since it can't know whether ZLPs will be handled right by ++ * all the relevant hardware and software. ++ */ ++ if (!((len + EEM_HEAD + ETH_FCS_LEN) % dev->maxpacket)) ++ padlen += 2; ++ ++ if (!skb_cloned(skb)) { ++ int headroom = skb_headroom(skb); ++ int tailroom = skb_tailroom(skb); ++ ++ if ((tailroom >= ETH_FCS_LEN + padlen) && ++ (headroom >= EEM_HEAD)) ++ goto done; ++ ++ if ((headroom + tailroom) ++ > (EEM_HEAD + ETH_FCS_LEN + padlen)) { ++ skb->data = memmove(skb->head + ++ EEM_HEAD, ++ skb->data, ++ skb->len); ++ skb_set_tail_pointer(skb, len); ++ goto done; ++ } ++ } ++ ++ skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags); ++ if (!skb2) ++ return NULL; ++ ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ ++done: ++ /* we don't use the "no Ethernet CRC" option */ ++ crc = crc32_le(~0, skb->data, skb->len); ++ crc = ~crc; ++ ++ put_unaligned_le32(crc, skb_put(skb, 4)); ++ ++ /* EEM packet header format: ++ * b0..13: length of ethernet frame ++ * b14: bmCRC (1 == valid Ethernet CRC) ++ * b15: bmType (0 == data) ++ */ ++ len = skb->len; ++ put_unaligned_le16(BIT(14) | len, skb_push(skb, 2)); ++ ++ /* Bundle a zero length EEM packet if needed */ ++ if (padlen) ++ put_unaligned_le16(0, skb_put(skb, 2)); ++ ++ return skb; ++} ++ ++static int eem_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ /* ++ * Our task here is to strip off framing, leaving skb with one ++ * data frame for the usbnet framework code to process. But we ++ * may have received multiple EEM payloads, or command payloads. ++ * So we must process _everything_ as if it's a header, except ++ * maybe the last data payload ++ * ++ * REVISIT the framework needs updating so that when we consume ++ * all payloads (the last or only message was a command, or a ++ * zero length EEM packet) that is not accounted as an rx_error. ++ */ ++ do { ++ struct sk_buff *skb2 = NULL; ++ u16 header; ++ u16 len = 0; ++ ++ /* incomplete EEM header? */ ++ if (skb->len < EEM_HEAD) ++ return 0; ++ ++ /* ++ * EEM packet header format: ++ * b0..14: EEM type dependent (Data or Command) ++ * b15: bmType ++ */ ++ header = get_unaligned_le16(skb->data); ++ skb_pull(skb, EEM_HEAD); ++ ++ /* ++ * The bmType bit helps to denote when EEM ++ * packet is data or command : ++ * bmType = 0 : EEM data payload ++ * bmType = 1 : EEM (link) command ++ */ ++ if (header & BIT(15)) { ++ u16 bmEEMCmd; ++ ++ /* ++ * EEM (link) command packet: ++ * b0..10: bmEEMCmdParam ++ * b11..13: bmEEMCmd ++ * b14: bmReserved (must be 0) ++ * b15: 1 (EEM command) ++ */ ++ if (header & BIT(14)) { ++ netdev_dbg(dev->net, "reserved command %04x\n", ++ header); ++ continue; ++ } ++ ++ bmEEMCmd = (header >> 11) & 0x7; ++ switch (bmEEMCmd) { ++ ++ /* Responding to echo requests is mandatory. */ ++ case 0: /* Echo command */ ++ len = header & 0x7FF; ++ ++ /* bogus command? */ ++ if (skb->len < len) ++ return 0; ++ ++ skb2 = skb_clone(skb, GFP_ATOMIC); ++ if (unlikely(!skb2)) ++ goto next; ++ skb_trim(skb2, len); ++ put_unaligned_le16(BIT(15) | (1 << 11) | len, ++ skb_push(skb2, 2)); ++ eem_linkcmd(dev, skb2); ++ break; ++ ++ /* ++ * Host may choose to ignore hints. ++ * - suspend: peripheral ready to suspend ++ * - response: suggest N millisec polling ++ * - response complete: suggest N sec polling ++ * ++ * Suspend is reported and maybe heeded. ++ */ ++ case 2: /* Suspend hint */ ++ usbnet_device_suggests_idle(dev); ++ continue; ++ case 3: /* Response hint */ ++ case 4: /* Response complete hint */ ++ continue; ++ ++ /* ++ * Hosts should never receive host-to-peripheral ++ * or reserved command codes; or responses to an ++ * echo command we didn't send. ++ */ ++ case 1: /* Echo response */ ++ case 5: /* Tickle */ ++ default: /* reserved */ ++ netdev_warn(dev->net, ++ "unexpected link command %d\n", ++ bmEEMCmd); ++ continue; ++ } ++ ++ } else { ++ u32 crc, crc2; ++ int is_last; ++ ++ /* zero length EEM packet? */ ++ if (header == 0) ++ continue; ++ ++ /* ++ * EEM data packet header : ++ * b0..13: length of ethernet frame ++ * b14: bmCRC ++ * b15: 0 (EEM data) ++ */ ++ len = header & 0x3FFF; ++ ++ /* bogus EEM payload? */ ++ if (skb->len < len) ++ return 0; ++ ++ /* bogus ethernet frame? */ ++ if (len < (ETH_HLEN + ETH_FCS_LEN)) ++ goto next; ++ ++ /* ++ * Treat the last payload differently: framework ++ * code expects our "fixup" to have stripped off ++ * headers, so "skb" is a data packet (or error). ++ * Else if it's not the last payload, keep "skb" ++ * for further processing. ++ */ ++ is_last = (len == skb->len); ++ if (is_last) ++ skb2 = skb; ++ else { ++ skb2 = skb_clone(skb, GFP_ATOMIC); ++ if (unlikely(!skb2)) ++ return 0; ++ } ++ ++ /* ++ * The bmCRC helps to denote when the CRC field in ++ * the Ethernet frame contains a calculated CRC: ++ * bmCRC = 1 : CRC is calculated ++ * bmCRC = 0 : CRC = 0xDEADBEEF ++ */ ++ if (header & BIT(14)) { ++ crc = get_unaligned_le32(skb2->data ++ + len - ETH_FCS_LEN); ++ crc2 = ~crc32_le(~0, skb2->data, skb2->len ++ - ETH_FCS_LEN); ++ } else { ++ crc = get_unaligned_be32(skb2->data ++ + len - ETH_FCS_LEN); ++ crc2 = 0xdeadbeef; ++ } ++ skb_trim(skb2, len - ETH_FCS_LEN); ++ ++ if (is_last) ++ return crc == crc2; ++ ++ if (unlikely(crc != crc2)) { ++ dev->net->stats.rx_errors++; ++ dev_kfree_skb_any(skb2); ++ } else ++ usbnet_skb_return(dev, skb2); ++ } ++ ++next: ++ skb_pull(skb, len); ++ } while (skb->len); ++ ++ return 1; ++} ++ ++static const struct driver_info eem_info = { ++ .description = "CDC EEM Device", ++ .flags = FLAG_ETHER | FLAG_POINTTOPOINT, ++ .bind = eem_bind, ++ .rx_fixup = eem_rx_fixup, ++ .tx_fixup = eem_tx_fixup, ++}; ++ ++/*-------------------------------------------------------------------------*/ ++ ++static const struct usb_device_id products[] = { ++{ ++ USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_EEM, ++ USB_CDC_PROTO_EEM), ++ .driver_info = (unsigned long) &eem_info, ++}, ++{ ++ /* EMPTY == end of list */ ++}, ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver eem_driver = { ++ .name = "cdc_eem", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(eem_driver); ++ ++MODULE_AUTHOR("Omar Laazimani omar.oberthur@gmail.com"); ++MODULE_DESCRIPTION("USB CDC EEM"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/cdc-phonet.c backports-4.2.6-1/drivers/net/usb/cdc-phonet.c +--- backports-4.2.6-1.org/drivers/net/usb/cdc-phonet.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/cdc-phonet.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,466 @@ ++/* ++ * phonet.c -- USB CDC Phonet host driver ++ * ++ * Copyright (C) 2008-2009 Nokia Corporation. All rights reserved. ++ * ++ * Author: Rémi Denis-Courmont ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ++ * 02110-1301 USA ++ */ ++ ++#include <linux/kernel.h> ++#include <linux/mm.h> ++#include <linux/module.h> ++#include <linux/gfp.h> ++#include <linux/usb.h> ++#include <linux/usb/cdc.h> ++#include <linux/netdevice.h> ++#include <linux/if_arp.h> ++#include <linux/if_phonet.h> ++#include <linux/phonet.h> ++ ++#define PN_MEDIA_USB 0x1B ++ ++static const unsigned rxq_size = 17; ++ ++struct usbpn_dev { ++ struct net_device *dev; ++ ++ struct usb_interface *intf, *data_intf; ++ struct usb_device *usb; ++ unsigned int tx_pipe, rx_pipe; ++ u8 active_setting; ++ u8 disconnected; ++ ++ unsigned tx_queue; ++ spinlock_t tx_lock; ++ ++ spinlock_t rx_lock; ++ struct sk_buff *rx_skb; ++ struct urb *urbs[0]; ++}; ++ ++static void tx_complete(struct urb *req); ++static void rx_complete(struct urb *req); ++ ++/* ++ * Network device callbacks ++ */ ++static netdev_tx_t usbpn_xmit(struct sk_buff *skb, struct net_device *dev) ++{ ++ struct usbpn_dev *pnd = netdev_priv(dev); ++ struct urb *req = NULL; ++ unsigned long flags; ++ int err; ++ ++ if (skb->protocol != htons(ETH_P_PHONET)) ++ goto drop; ++ ++ req = usb_alloc_urb(0, GFP_ATOMIC); ++ if (!req) ++ goto drop; ++ usb_fill_bulk_urb(req, pnd->usb, pnd->tx_pipe, skb->data, skb->len, ++ tx_complete, skb); ++ req->transfer_flags = URB_ZERO_PACKET; ++ err = usb_submit_urb(req, GFP_ATOMIC); ++ if (err) { ++ usb_free_urb(req); ++ goto drop; ++ } ++ ++ spin_lock_irqsave(&pnd->tx_lock, flags); ++ pnd->tx_queue++; ++ if (pnd->tx_queue >= dev->tx_queue_len) ++ netif_stop_queue(dev); ++ spin_unlock_irqrestore(&pnd->tx_lock, flags); ++ return NETDEV_TX_OK; ++ ++drop: ++ dev_kfree_skb(skb); ++ dev->stats.tx_dropped++; ++ return NETDEV_TX_OK; ++} ++ ++static void tx_complete(struct urb *req) ++{ ++ struct sk_buff *skb = req->context; ++ struct net_device *dev = skb->dev; ++ struct usbpn_dev *pnd = netdev_priv(dev); ++ int status = req->status; ++ ++ switch (status) { ++ case 0: ++ dev->stats.tx_bytes += skb->len; ++ break; ++ ++ case -ENOENT: ++ case -ECONNRESET: ++ case -ESHUTDOWN: ++ dev->stats.tx_aborted_errors++; ++ default: ++ dev->stats.tx_errors++; ++ dev_dbg(&dev->dev, "TX error (%d)\n", status); ++ } ++ dev->stats.tx_packets++; ++ ++ spin_lock(&pnd->tx_lock); ++ pnd->tx_queue--; ++ netif_wake_queue(dev); ++ spin_unlock(&pnd->tx_lock); ++ ++ dev_kfree_skb_any(skb); ++ usb_free_urb(req); ++} ++ ++static int rx_submit(struct usbpn_dev *pnd, struct urb *req, gfp_t gfp_flags) ++{ ++ struct net_device *dev = pnd->dev; ++ struct page *page; ++ int err; ++ ++ page = __dev_alloc_page(gfp_flags | __GFP_NOMEMALLOC); ++ if (!page) ++ return -ENOMEM; ++ ++ usb_fill_bulk_urb(req, pnd->usb, pnd->rx_pipe, page_address(page), ++ PAGE_SIZE, rx_complete, dev); ++ req->transfer_flags = 0; ++ err = usb_submit_urb(req, gfp_flags); ++ if (unlikely(err)) { ++ dev_dbg(&dev->dev, "RX submit error (%d)\n", err); ++ put_page(page); ++ } ++ return err; ++} ++ ++static void rx_complete(struct urb *req) ++{ ++ struct net_device *dev = req->context; ++ struct usbpn_dev *pnd = netdev_priv(dev); ++ struct page *page = virt_to_page(req->transfer_buffer); ++ struct sk_buff *skb; ++ unsigned long flags; ++ int status = req->status; ++ ++ switch (status) { ++ case 0: ++ spin_lock_irqsave(&pnd->rx_lock, flags); ++ skb = pnd->rx_skb; ++ if (!skb) { ++ skb = pnd->rx_skb = netdev_alloc_skb(dev, 12); ++ if (likely(skb)) { ++ /* Can't use pskb_pull() on page in IRQ */ ++ memcpy(skb_put(skb, 1), page_address(page), 1); ++ skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, ++ page, 1, req->actual_length, ++ PAGE_SIZE); ++ page = NULL; ++ } ++ } else { ++ skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, ++ page, 0, req->actual_length, ++ PAGE_SIZE); ++ page = NULL; ++ } ++ if (req->actual_length < PAGE_SIZE) ++ pnd->rx_skb = NULL; /* Last fragment */ ++ else ++ skb = NULL; ++ spin_unlock_irqrestore(&pnd->rx_lock, flags); ++ if (skb) { ++ skb->protocol = htons(ETH_P_PHONET); ++ skb_reset_mac_header(skb); ++ __skb_pull(skb, 1); ++ skb->dev = dev; ++ dev->stats.rx_packets++; ++ dev->stats.rx_bytes += skb->len; ++ ++ netif_rx(skb); ++ } ++ goto resubmit; ++ ++ case -ENOENT: ++ case -ECONNRESET: ++ case -ESHUTDOWN: ++ req = NULL; ++ break; ++ ++ case -EOVERFLOW: ++ dev->stats.rx_over_errors++; ++ dev_dbg(&dev->dev, "RX overflow\n"); ++ break; ++ ++ case -EILSEQ: ++ dev->stats.rx_crc_errors++; ++ break; ++ } ++ ++ dev->stats.rx_errors++; ++resubmit: ++ if (page) ++ put_page(page); ++ if (req) ++ rx_submit(pnd, req, GFP_ATOMIC); ++} ++ ++static int usbpn_close(struct net_device *dev); ++ ++static int usbpn_open(struct net_device *dev) ++{ ++ struct usbpn_dev *pnd = netdev_priv(dev); ++ int err; ++ unsigned i; ++ unsigned num = pnd->data_intf->cur_altsetting->desc.bInterfaceNumber; ++ ++ err = usb_set_interface(pnd->usb, num, pnd->active_setting); ++ if (err) ++ return err; ++ ++ for (i = 0; i < rxq_size; i++) { ++ struct urb *req = usb_alloc_urb(0, GFP_KERNEL); ++ ++ if (!req || rx_submit(pnd, req, GFP_KERNEL)) { ++ usb_free_urb(req); ++ usbpn_close(dev); ++ return -ENOMEM; ++ } ++ pnd->urbs[i] = req; ++ } ++ ++ netif_wake_queue(dev); ++ return 0; ++} ++ ++static int usbpn_close(struct net_device *dev) ++{ ++ struct usbpn_dev *pnd = netdev_priv(dev); ++ unsigned i; ++ unsigned num = pnd->data_intf->cur_altsetting->desc.bInterfaceNumber; ++ ++ netif_stop_queue(dev); ++ ++ for (i = 0; i < rxq_size; i++) { ++ struct urb *req = pnd->urbs[i]; ++ ++ if (!req) ++ continue; ++ usb_kill_urb(req); ++ usb_free_urb(req); ++ pnd->urbs[i] = NULL; ++ } ++ ++ return usb_set_interface(pnd->usb, num, !pnd->active_setting); ++} ++ ++static int usbpn_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ++{ ++ struct if_phonet_req *req = (struct if_phonet_req *)ifr; ++ ++ switch (cmd) { ++ case SIOCPNGAUTOCONF: ++ req->ifr_phonet_autoconf.device = PN_DEV_PC; ++ return 0; ++ } ++ return -ENOIOCTLCMD; ++} ++ ++static int usbpn_set_mtu(struct net_device *dev, int new_mtu) ++{ ++ if ((new_mtu < PHONET_MIN_MTU) || (new_mtu > PHONET_MAX_MTU)) ++ return -EINVAL; ++ ++ dev->mtu = new_mtu; ++ return 0; ++} ++ ++static const struct net_device_ops usbpn_ops = { ++ .ndo_open = usbpn_open, ++ .ndo_stop = usbpn_close, ++ .ndo_start_xmit = usbpn_xmit, ++ .ndo_do_ioctl = usbpn_ioctl, ++ .ndo_change_mtu = usbpn_set_mtu, ++}; ++ ++static void usbpn_setup(struct net_device *dev) ++{ ++ dev->features = 0; ++ dev->netdev_ops = &usbpn_ops, ++ dev->header_ops = &phonet_header_ops; ++ dev->type = ARPHRD_PHONET; ++ dev->flags = IFF_POINTOPOINT | IFF_NOARP; ++ dev->mtu = PHONET_MAX_MTU; ++ dev->hard_header_len = 1; ++ dev->dev_addr[0] = PN_MEDIA_USB; ++ dev->addr_len = 1; ++ dev->tx_queue_len = 3; ++ ++ dev->destructor = free_netdev; ++} ++ ++/* ++ * USB driver callbacks ++ */ ++static struct usb_device_id usbpn_ids[] = { ++ { ++ .match_flags = USB_DEVICE_ID_MATCH_VENDOR ++ | USB_DEVICE_ID_MATCH_INT_CLASS ++ | USB_DEVICE_ID_MATCH_INT_SUBCLASS, ++ .idVendor = 0x0421, /* Nokia */ ++ .bInterfaceClass = USB_CLASS_COMM, ++ .bInterfaceSubClass = 0xFE, ++ }, ++ { }, ++}; ++ ++MODULE_DEVICE_TABLE(usb, usbpn_ids); ++ ++static struct usb_driver usbpn_driver; ++ ++static int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *id) ++{ ++ static const char ifname[] = "usbpn%d"; ++ const struct usb_cdc_union_desc *union_header = NULL; ++ const struct usb_host_interface *data_desc; ++ struct usb_interface *data_intf; ++ struct usb_device *usbdev = interface_to_usbdev(intf); ++ struct net_device *dev; ++ struct usbpn_dev *pnd; ++ u8 *data; ++ int phonet = 0; ++ int len, err; ++ ++ data = intf->altsetting->extra; ++ len = intf->altsetting->extralen; ++ while (len >= 3) { ++ u8 dlen = data[0]; ++ if (dlen < 3) ++ return -EINVAL; ++ ++ /* bDescriptorType */ ++ if (data[1] == USB_DT_CS_INTERFACE) { ++ /* bDescriptorSubType */ ++ switch (data[2]) { ++ case USB_CDC_UNION_TYPE: ++ if (union_header || dlen < 5) ++ break; ++ union_header = ++ (struct usb_cdc_union_desc *)data; ++ break; ++ case 0xAB: ++ phonet = 1; ++ break; ++ } ++ } ++ data += dlen; ++ len -= dlen; ++ } ++ ++ if (!union_header || !phonet) ++ return -EINVAL; ++ ++ data_intf = usb_ifnum_to_if(usbdev, union_header->bSlaveInterface0); ++ if (data_intf == NULL) ++ return -ENODEV; ++ /* Data interface has one inactive and one active setting */ ++ if (data_intf->num_altsetting != 2) ++ return -EINVAL; ++ if (data_intf->altsetting[0].desc.bNumEndpoints == 0 && ++ data_intf->altsetting[1].desc.bNumEndpoints == 2) ++ data_desc = data_intf->altsetting + 1; ++ else ++ if (data_intf->altsetting[0].desc.bNumEndpoints == 2 && ++ data_intf->altsetting[1].desc.bNumEndpoints == 0) ++ data_desc = data_intf->altsetting; ++ else ++ return -EINVAL; ++ ++ dev = alloc_netdev(sizeof(*pnd) + sizeof(pnd->urbs[0]) * rxq_size, ++ ifname, NET_NAME_UNKNOWN, usbpn_setup); ++ if (!dev) ++ return -ENOMEM; ++ ++ pnd = netdev_priv(dev); ++ SET_NETDEV_DEV(dev, &intf->dev); ++ ++ pnd->dev = dev; ++ pnd->usb = usbdev; ++ pnd->intf = intf; ++ pnd->data_intf = data_intf; ++ spin_lock_init(&pnd->tx_lock); ++ spin_lock_init(&pnd->rx_lock); ++ /* Endpoints */ ++ if (usb_pipein(data_desc->endpoint[0].desc.bEndpointAddress)) { ++ pnd->rx_pipe = usb_rcvbulkpipe(usbdev, ++ data_desc->endpoint[0].desc.bEndpointAddress); ++ pnd->tx_pipe = usb_sndbulkpipe(usbdev, ++ data_desc->endpoint[1].desc.bEndpointAddress); ++ } else { ++ pnd->rx_pipe = usb_rcvbulkpipe(usbdev, ++ data_desc->endpoint[1].desc.bEndpointAddress); ++ pnd->tx_pipe = usb_sndbulkpipe(usbdev, ++ data_desc->endpoint[0].desc.bEndpointAddress); ++ } ++ pnd->active_setting = data_desc - data_intf->altsetting; ++ ++ err = usb_driver_claim_interface(&usbpn_driver, data_intf, pnd); ++ if (err) ++ goto out; ++ ++ /* Force inactive mode until the network device is brought UP */ ++ usb_set_interface(usbdev, union_header->bSlaveInterface0, ++ !pnd->active_setting); ++ usb_set_intfdata(intf, pnd); ++ ++ err = register_netdev(dev); ++ if (err) { ++ usb_driver_release_interface(&usbpn_driver, data_intf); ++ goto out; ++ } ++ ++ dev_dbg(&dev->dev, "USB CDC Phonet device found\n"); ++ return 0; ++ ++out: ++ usb_set_intfdata(intf, NULL); ++ free_netdev(dev); ++ return err; ++} ++ ++static void usbpn_disconnect(struct usb_interface *intf) ++{ ++ struct usbpn_dev *pnd = usb_get_intfdata(intf); ++ ++ if (pnd->disconnected) ++ return; ++ ++ pnd->disconnected = 1; ++ usb_driver_release_interface(&usbpn_driver, ++ (pnd->intf == intf) ? pnd->data_intf : pnd->intf); ++ unregister_netdev(pnd->dev); ++} ++ ++static struct usb_driver usbpn_driver = { ++ .name = "cdc_phonet", ++ .probe = usbpn_probe, ++ .disconnect = usbpn_disconnect, ++ .id_table = usbpn_ids, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(usbpn_driver); ++ ++MODULE_AUTHOR("Remi Denis-Courmont"); ++MODULE_DESCRIPTION("USB CDC Phonet host interface"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/cdc_subset.c backports-4.2.6-1/drivers/net/usb/cdc_subset.c +--- backports-4.2.6-1.org/drivers/net/usb/cdc_subset.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/cdc_subset.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,369 @@ ++/* ++ * Simple "CDC Subset" USB Networking Links ++ * Copyright (C) 2000-2005 by David Brownell ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include <linux/module.h> ++#include <linux/kmod.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/usb/usbnet.h> ++ ++ ++/* ++ * This supports simple USB network links that don't require any special ++ * framing or hardware control operations. The protocol used here is a ++ * strict subset of CDC Ethernet, with three basic differences reflecting ++ * the goal that almost any hardware should run it: ++ * ++ * - Minimal runtime control: one interface, no altsettings, and ++ * no vendor or class specific control requests. If a device is ++ * configured, it is allowed to exchange packets with the host. ++ * Fancier models would mean not working on some hardware. ++ * ++ * - Minimal manufacturing control: no IEEE "Organizationally ++ * Unique ID" required, or an EEPROMs to store one. Each host uses ++ * one random "locally assigned" Ethernet address instead, which can ++ * of course be overridden using standard tools like "ifconfig". ++ * (With 2^46 such addresses, same-net collisions are quite rare.) ++ * ++ * - There is no additional framing data for USB. Packets are written ++ * exactly as in CDC Ethernet, starting with an Ethernet header and ++ * terminated by a short packet. However, the host will never send a ++ * zero length packet; some systems can't handle those robustly. ++ * ++ * Anything that can transmit and receive USB bulk packets can implement ++ * this protocol. That includes both smart peripherals and quite a lot ++ * of "host-to-host" USB cables (which embed two devices back-to-back). ++ * ++ * Note that although Linux may use many of those host-to-host links ++ * with this "cdc_subset" framing, that doesn't mean there may not be a ++ * better approach. Handling the "other end unplugs/replugs" scenario ++ * well tends to require chip-specific vendor requests. Also, Windows ++ * peers at the other end of host-to-host cables may expect their own ++ * framing to be used rather than this "cdc_subset" model. ++ */ ++ ++#if defined(CONFIG_USB_EPSON2888) || defined(CONFIG_USB_ARMLINUX) ++/* PDA style devices are always connected if present */ ++static int always_connected (struct usbnet *dev) ++{ ++ return 0; ++} ++#endif ++ ++#ifdef CONFIG_USB_ALI_M5632 ++#define HAVE_HARDWARE ++ ++/*------------------------------------------------------------------------- ++ * ++ * ALi M5632 driver ... does high speed ++ * ++ * NOTE that the MS-Windows drivers for this chip use some funky and ++ * (naturally) undocumented 7-byte prefix to each packet, so this is a ++ * case where we don't currently interoperate. Also, once you unplug ++ * one end of the cable, you need to replug the other end too ... since ++ * chip docs are unavailable, there's no way to reset the relevant state ++ * short of a power cycle. ++ * ++ *-------------------------------------------------------------------------*/ ++ ++static void m5632_recover(struct usbnet *dev) ++{ ++ struct usb_device *udev = dev->udev; ++ struct usb_interface *intf = dev->intf; ++ int r; ++ ++ r = usb_lock_device_for_reset(udev, intf); ++ if (r < 0) ++ return; ++ ++ usb_reset_device(udev); ++ usb_unlock_device(udev); ++} ++ ++static const struct driver_info ali_m5632_info = { ++ .description = "ALi M5632", ++ .flags = FLAG_POINTTOPOINT, ++ .recover = m5632_recover, ++}; ++ ++#endif ++ ++#ifdef CONFIG_USB_AN2720 ++#define HAVE_HARDWARE ++ ++/*------------------------------------------------------------------------- ++ * ++ * AnchorChips 2720 driver ... http://www.cypress.com ++ * ++ * This doesn't seem to have a way to detect whether the peer is ++ * connected, or need any reset handshaking. It's got pretty big ++ * internal buffers (handles most of a frame's worth of data). ++ * Chip data sheets don't describe any vendor control messages. ++ * ++ *-------------------------------------------------------------------------*/ ++ ++static const struct driver_info an2720_info = { ++ .description = "AnchorChips/Cypress 2720", ++ .flags = FLAG_POINTTOPOINT, ++ // no reset available! ++ // no check_connect available! ++ ++ .in = 2, .out = 2, // direction distinguishes these ++}; ++ ++#endif /* CONFIG_USB_AN2720 */ ++ ++ ++#ifdef CONFIG_USB_BELKIN ++#define HAVE_HARDWARE ++ ++/*------------------------------------------------------------------------- ++ * ++ * Belkin F5U104 ... two NetChip 2280 devices + Atmel AVR microcontroller ++ * ++ * ... also two eTEK designs, including one sold as "Advance USBNET" ++ * ++ *-------------------------------------------------------------------------*/ ++ ++static const struct driver_info belkin_info = { ++ .description = "Belkin, eTEK, or compatible", ++ .flags = FLAG_POINTTOPOINT, ++}; ++ ++#endif /* CONFIG_USB_BELKIN */ ++ ++ ++ ++#ifdef CONFIG_USB_EPSON2888 ++#define HAVE_HARDWARE ++ ++/*------------------------------------------------------------------------- ++ * ++ * EPSON USB clients ++ * ++ * This is the same idea as Linux PDAs (below) except the firmware in the ++ * device might not be Tux-powered. Epson provides reference firmware that ++ * implements this interface. Product developers can reuse or modify that ++ * code, such as by using their own product and vendor codes. ++ * ++ * Support was from Juro Bystricky bystricky.juro@erd.epson.com ++ * ++ *-------------------------------------------------------------------------*/ ++ ++static const struct driver_info epson2888_info = { ++ .description = "Epson USB Device", ++ .check_connect = always_connected, ++ .flags = FLAG_POINTTOPOINT, ++ ++ .in = 4, .out = 3, ++}; ++ ++#endif /* CONFIG_USB_EPSON2888 */ ++ ++ ++/*------------------------------------------------------------------------- ++ * ++ * info from Jonathan McDowell noodles@earth.li ++ * ++ *-------------------------------------------------------------------------*/ ++#ifdef CONFIG_USB_KC2190 ++#define HAVE_HARDWARE ++static const struct driver_info kc2190_info = { ++ .description = "KC Technology KC-190", ++ .flags = FLAG_POINTTOPOINT, ++}; ++#endif /* CONFIG_USB_KC2190 */ ++ ++ ++#ifdef CONFIG_USB_ARMLINUX ++#define HAVE_HARDWARE ++ ++/*------------------------------------------------------------------------- ++ * ++ * Intel's SA-1100 chip integrates basic USB support, and is used ++ * in PDAs like some iPaqs, the Yopy, some Zaurus models, and more. ++ * When they run Linux, arch/arm/mach-sa1100/usb-eth.c may be used to ++ * network using minimal USB framing data. ++ * ++ * This describes the driver currently in standard ARM Linux kernels. ++ * The Zaurus uses a different driver (see later). ++ * ++ * PXA25x and PXA210 use XScale cores (ARM v5TE) with better USB support ++ * and different USB endpoint numbering than the SA1100 devices. The ++ * mach-pxa/usb-eth.c driver re-uses the device ids from mach-sa1100 ++ * so we rely on the endpoint descriptors. ++ * ++ *-------------------------------------------------------------------------*/ ++ ++static const struct driver_info linuxdev_info = { ++ .description = "Linux Device", ++ .check_connect = always_connected, ++ .flags = FLAG_POINTTOPOINT, ++}; ++ ++static const struct driver_info yopy_info = { ++ .description = "Yopy", ++ .check_connect = always_connected, ++ .flags = FLAG_POINTTOPOINT, ++}; ++ ++static const struct driver_info blob_info = { ++ .description = "Boot Loader OBject", ++ .check_connect = always_connected, ++ .flags = FLAG_POINTTOPOINT, ++}; ++ ++#endif /* CONFIG_USB_ARMLINUX */ ++ ++ ++/*-------------------------------------------------------------------------*/ ++ ++#ifndef HAVE_HARDWARE ++#warning You need to configure some hardware for this driver ++#endif ++ ++/* ++ * chip vendor names won't normally be on the cables, and ++ * may not be on the device. ++ */ ++ ++static const struct usb_device_id products [] = { ++ ++#ifdef CONFIG_USB_ALI_M5632 ++{ ++ USB_DEVICE (0x0402, 0x5632), // ALi defaults ++ .driver_info = (unsigned long) &ali_m5632_info, ++}, ++{ ++ USB_DEVICE (0x182d,0x207c), // SiteCom CN-124 ++ .driver_info = (unsigned long) &ali_m5632_info, ++}, ++#endif ++ ++#ifdef CONFIG_USB_AN2720 ++{ ++ USB_DEVICE (0x0547, 0x2720), // AnchorChips defaults ++ .driver_info = (unsigned long) &an2720_info, ++}, { ++ USB_DEVICE (0x0547, 0x2727), // Xircom PGUNET ++ .driver_info = (unsigned long) &an2720_info, ++}, ++#endif ++ ++#ifdef CONFIG_USB_BELKIN ++{ ++ USB_DEVICE (0x050d, 0x0004), // Belkin ++ .driver_info = (unsigned long) &belkin_info, ++}, { ++ USB_DEVICE (0x056c, 0x8100), // eTEK ++ .driver_info = (unsigned long) &belkin_info, ++}, { ++ USB_DEVICE (0x0525, 0x9901), // Advance USBNET (eTEK) ++ .driver_info = (unsigned long) &belkin_info, ++}, ++#endif ++ ++#ifdef CONFIG_USB_EPSON2888 ++{ ++ USB_DEVICE (0x0525, 0x2888), // EPSON USB client ++ .driver_info = (unsigned long) &epson2888_info, ++}, ++#endif ++ ++#ifdef CONFIG_USB_KC2190 ++{ ++ USB_DEVICE (0x050f, 0x0190), // KC-190 ++ .driver_info = (unsigned long) &kc2190_info, ++}, ++#endif ++ ++#ifdef CONFIG_USB_ARMLINUX ++/* ++ * SA-1100 using standard ARM Linux kernels, or compatible. ++ * Often used when talking to Linux PDAs (iPaq, Yopy, etc). ++ * The sa-1100 "usb-eth" driver handles the basic framing. ++ * ++ * PXA25x or PXA210 ... these use a "usb-eth" driver much like ++ * the sa1100 one, but hardware uses different endpoint numbers. ++ * ++ * Or the Linux "Ethernet" gadget on hardware that can't talk ++ * CDC Ethernet (e.g., no altsettings), in either of two modes: ++ * - acting just like the old "usb-eth" firmware, though ++ * the implementation is different ++ * - supporting RNDIS as the first/default configuration for ++ * MS-Windows interop; Linux needs to use the other config ++ */ ++{ ++ // 1183 = 0x049F, both used as hex values? ++ // Compaq "Itsy" vendor/product id ++ USB_DEVICE (0x049F, 0x505A), // usb-eth, or compatible ++ .driver_info = (unsigned long) &linuxdev_info, ++}, { ++ USB_DEVICE (0x0E7E, 0x1001), // G.Mate "Yopy" ++ .driver_info = (unsigned long) &yopy_info, ++}, { ++ USB_DEVICE (0x8086, 0x07d3), // "blob" bootloader ++ .driver_info = (unsigned long) &blob_info, ++}, { ++ USB_DEVICE (0x1286, 0x8001), // "blob" bootloader ++ .driver_info = (unsigned long) &blob_info, ++}, { ++ // Linux Ethernet/RNDIS gadget, mostly on PXA, second config ++ // e.g. Gumstix, current OpenZaurus, ... or anything else ++ // that just enables this gadget option. ++ USB_DEVICE (0x0525, 0xa4a2), ++ .driver_info = (unsigned long) &linuxdev_info, ++}, ++#endif ++ ++ { }, // END ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++/*-------------------------------------------------------------------------*/ ++static int dummy_prereset(struct usb_interface *intf) ++{ ++ return 0; ++} ++ ++static int dummy_postreset(struct usb_interface *intf) ++{ ++ return 0; ++} ++ ++static struct usb_driver cdc_subset_driver = { ++ .name = "cdc_subset", ++ .probe = usbnet_probe, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .pre_reset = dummy_prereset, ++ .post_reset = dummy_postreset, ++ .disconnect = usbnet_disconnect, ++ .id_table = products, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(cdc_subset_driver); ++ ++MODULE_AUTHOR("David Brownell"); ++MODULE_DESCRIPTION("Simple 'CDC Subset' USB networking links"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/cx82310_eth.c backports-4.2.6-1/drivers/net/usb/cx82310_eth.c +--- backports-4.2.6-1.org/drivers/net/usb/cx82310_eth.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/cx82310_eth.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,353 @@ ++/* ++ * Driver for USB ethernet port of Conexant CX82310-based ADSL routers ++ * Copyright (C) 2010 by Ondrej Zary ++ * some parts inspired by the cxacru driver ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/usb/usbnet.h> ++ ++enum cx82310_cmd { ++ CMD_START = 0x84, /* no effect? */ ++ CMD_STOP = 0x85, /* no effect? */ ++ CMD_GET_STATUS = 0x90, /* returns nothing? */ ++ CMD_GET_MAC_ADDR = 0x91, /* read MAC address */ ++ CMD_GET_LINK_STATUS = 0x92, /* not useful, link is always up */ ++ CMD_ETHERNET_MODE = 0x99, /* unknown, needed during init */ ++}; ++ ++enum cx82310_status { ++ STATUS_UNDEFINED, ++ STATUS_SUCCESS, ++ STATUS_ERROR, ++ STATUS_UNSUPPORTED, ++ STATUS_UNIMPLEMENTED, ++ STATUS_PARAMETER_ERROR, ++ STATUS_DBG_LOOPBACK, ++}; ++ ++#define CMD_PACKET_SIZE 64 ++#define CMD_TIMEOUT 100 ++#define CMD_REPLY_RETRY 5 ++ ++#define CX82310_MTU 1514 ++#define CMD_EP 0x01 ++ ++/* ++ * execute control command ++ * - optionally send some data (command parameters) ++ * - optionally wait for the reply ++ * - optionally read some data from the reply ++ */ ++static int cx82310_cmd(struct usbnet *dev, enum cx82310_cmd cmd, bool reply, ++ u8 *wdata, int wlen, u8 *rdata, int rlen) ++{ ++ int actual_len, retries, ret; ++ struct usb_device *udev = dev->udev; ++ u8 *buf = kzalloc(CMD_PACKET_SIZE, GFP_KERNEL); ++ ++ if (!buf) ++ return -ENOMEM; ++ ++ /* create command packet */ ++ buf[0] = cmd; ++ if (wdata) ++ memcpy(buf + 4, wdata, min_t(int, wlen, CMD_PACKET_SIZE - 4)); ++ ++ /* send command packet */ ++ ret = usb_bulk_msg(udev, usb_sndbulkpipe(udev, CMD_EP), buf, ++ CMD_PACKET_SIZE, &actual_len, CMD_TIMEOUT); ++ if (ret < 0) { ++ if (cmd != CMD_GET_LINK_STATUS) ++ dev_err(&dev->udev->dev, "send command %#x: error %d\n", ++ cmd, ret); ++ goto end; ++ } ++ ++ if (reply) { ++ /* wait for reply, retry if it's empty */ ++ for (retries = 0; retries < CMD_REPLY_RETRY; retries++) { ++ ret = usb_bulk_msg(udev, usb_rcvbulkpipe(udev, CMD_EP), ++ buf, CMD_PACKET_SIZE, &actual_len, ++ CMD_TIMEOUT); ++ if (ret < 0) { ++ if (cmd != CMD_GET_LINK_STATUS) ++ dev_err(&dev->udev->dev, ++ "reply receive error %d\n", ++ ret); ++ goto end; ++ } ++ if (actual_len > 0) ++ break; ++ } ++ if (actual_len == 0) { ++ dev_err(&dev->udev->dev, "no reply to command %#x\n", ++ cmd); ++ ret = -EIO; ++ goto end; ++ } ++ if (buf[0] != cmd) { ++ dev_err(&dev->udev->dev, ++ "got reply to command %#x, expected: %#x\n", ++ buf[0], cmd); ++ ret = -EIO; ++ goto end; ++ } ++ if (buf[1] != STATUS_SUCCESS) { ++ dev_err(&dev->udev->dev, "command %#x failed: %#x\n", ++ cmd, buf[1]); ++ ret = -EIO; ++ goto end; ++ } ++ if (rdata) ++ memcpy(rdata, buf + 4, ++ min_t(int, rlen, CMD_PACKET_SIZE - 4)); ++ } ++end: ++ kfree(buf); ++ return ret; ++} ++ ++#define partial_len data[0] /* length of partial packet data */ ++#define partial_rem data[1] /* remaining (missing) data length */ ++#define partial_data data[2] /* partial packet data */ ++ ++static int cx82310_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int ret; ++ char buf[15]; ++ struct usb_device *udev = dev->udev; ++ u8 link[3]; ++ int timeout = 50; ++ ++ /* avoid ADSL modems - continue only if iProduct is "USB NET CARD" */ ++ if (usb_string(udev, udev->descriptor.iProduct, buf, sizeof(buf)) > 0 ++ && strcmp(buf, "USB NET CARD")) { ++ dev_info(&udev->dev, "ignoring: probably an ADSL modem\n"); ++ return -ENODEV; ++ } ++ ++ ret = usbnet_get_endpoints(dev, intf); ++ if (ret) ++ return ret; ++ ++ /* ++ * this must not include ethernet header as the device can send partial ++ * packets with no header (and sometimes even empty URBs) ++ */ ++ dev->net->hard_header_len = 0; ++ /* we can send at most 1514 bytes of data (+ 2-byte header) per URB */ ++ dev->hard_mtu = CX82310_MTU + 2; ++ /* we can receive URBs up to 4KB from the device */ ++ dev->rx_urb_size = 4096; ++ ++ dev->partial_data = (unsigned long) kmalloc(dev->hard_mtu, GFP_KERNEL); ++ if (!dev->partial_data) ++ return -ENOMEM; ++ ++ /* wait for firmware to become ready (indicated by the link being up) */ ++ while (--timeout) { ++ ret = cx82310_cmd(dev, CMD_GET_LINK_STATUS, true, NULL, 0, ++ link, sizeof(link)); ++ /* the command can time out during boot - it's not an error */ ++ if (!ret && link[0] == 1 && link[2] == 1) ++ break; ++ msleep(500); ++ } ++ if (!timeout) { ++ dev_err(&udev->dev, "firmware not ready in time\n"); ++ return -ETIMEDOUT; ++ } ++ ++ /* enable ethernet mode (?) */ ++ ret = cx82310_cmd(dev, CMD_ETHERNET_MODE, true, "\x01", 1, NULL, 0); ++ if (ret) { ++ dev_err(&udev->dev, "unable to enable ethernet mode: %d\n", ++ ret); ++ goto err; ++ } ++ ++ /* get the MAC address */ ++ ret = cx82310_cmd(dev, CMD_GET_MAC_ADDR, true, NULL, 0, ++ dev->net->dev_addr, ETH_ALEN); ++ if (ret) { ++ dev_err(&udev->dev, "unable to read MAC address: %d\n", ret); ++ goto err; ++ } ++ ++ /* start (does not seem to have any effect?) */ ++ ret = cx82310_cmd(dev, CMD_START, false, NULL, 0, NULL, 0); ++ if (ret) ++ goto err; ++ ++ return 0; ++err: ++ kfree((void *)dev->partial_data); ++ return ret; ++} ++ ++static void cx82310_unbind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ kfree((void *)dev->partial_data); ++} ++ ++/* ++ * RX is NOT easy - we can receive multiple packets per skb, each having 2-byte ++ * packet length at the beginning. ++ * The last packet might be incomplete (when it crosses the 4KB URB size), ++ * continuing in the next skb (without any headers). ++ * If a packet has odd length, there is one extra byte at the end (before next ++ * packet or at the end of the URB). ++ */ ++static int cx82310_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ int len; ++ struct sk_buff *skb2; ++ ++ /* ++ * If the last skb ended with an incomplete packet, this skb contains ++ * end of that packet at the beginning. ++ */ ++ if (dev->partial_rem) { ++ len = dev->partial_len + dev->partial_rem; ++ skb2 = alloc_skb(len, GFP_ATOMIC); ++ if (!skb2) ++ return 0; ++ skb_put(skb2, len); ++ memcpy(skb2->data, (void *)dev->partial_data, ++ dev->partial_len); ++ memcpy(skb2->data + dev->partial_len, skb->data, ++ dev->partial_rem); ++ usbnet_skb_return(dev, skb2); ++ skb_pull(skb, (dev->partial_rem + 1) & ~1); ++ dev->partial_rem = 0; ++ if (skb->len < 2) ++ return 1; ++ } ++ ++ /* a skb can contain multiple packets */ ++ while (skb->len > 1) { ++ /* first two bytes are packet length */ ++ len = skb->data[0] | (skb->data[1] << 8); ++ skb_pull(skb, 2); ++ ++ /* if last packet in the skb, let usbnet to process it */ ++ if (len == skb->len || len + 1 == skb->len) { ++ skb_trim(skb, len); ++ break; ++ } ++ ++ if (len > CX82310_MTU) { ++ dev_err(&dev->udev->dev, "RX packet too long: %d B\n", ++ len); ++ return 0; ++ } ++ ++ /* incomplete packet, save it for the next skb */ ++ if (len > skb->len) { ++ dev->partial_len = skb->len; ++ dev->partial_rem = len - skb->len; ++ memcpy((void *)dev->partial_data, skb->data, ++ dev->partial_len); ++ skb_pull(skb, skb->len); ++ break; ++ } ++ ++ skb2 = alloc_skb(len, GFP_ATOMIC); ++ if (!skb2) ++ return 0; ++ skb_put(skb2, len); ++ memcpy(skb2->data, skb->data, len); ++ /* process the packet */ ++ usbnet_skb_return(dev, skb2); ++ ++ skb_pull(skb, (len + 1) & ~1); ++ } ++ ++ /* let usbnet process the last packet */ ++ return 1; ++} ++ ++/* TX is easy, just add 2 bytes of length at the beginning */ ++static struct sk_buff *cx82310_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ++ gfp_t flags) ++{ ++ int len = skb->len; ++ ++ if (skb_headroom(skb) < 2) { ++ struct sk_buff *skb2 = skb_copy_expand(skb, 2, 0, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (!skb) ++ return NULL; ++ } ++ skb_push(skb, 2); ++ ++ skb->data[0] = len; ++ skb->data[1] = len >> 8; ++ ++ return skb; ++} ++ ++ ++static const struct driver_info cx82310_info = { ++ .description = "Conexant CX82310 USB ethernet", ++ .flags = FLAG_ETHER, ++ .bind = cx82310_bind, ++ .unbind = cx82310_unbind, ++ .rx_fixup = cx82310_rx_fixup, ++ .tx_fixup = cx82310_tx_fixup, ++}; ++ ++#define USB_DEVICE_CLASS(vend, prod, cl, sc, pr) \ ++ .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ ++ USB_DEVICE_ID_MATCH_DEV_INFO, \ ++ .idVendor = (vend), \ ++ .idProduct = (prod), \ ++ .bDeviceClass = (cl), \ ++ .bDeviceSubClass = (sc), \ ++ .bDeviceProtocol = (pr) ++ ++static const struct usb_device_id products[] = { ++ { ++ USB_DEVICE_CLASS(0x0572, 0xcb01, 0xff, 0, 0), ++ .driver_info = (unsigned long) &cx82310_info ++ }, ++ { }, ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver cx82310_driver = { ++ .name = "cx82310_eth", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(cx82310_driver); ++ ++MODULE_AUTHOR("Ondrej Zary"); ++MODULE_DESCRIPTION("Conexant CX82310-based ADSL router USB ethernet driver"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/dm9601.c backports-4.2.6-1/drivers/net/usb/dm9601.c +--- backports-4.2.6-1.org/drivers/net/usb/dm9601.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/dm9601.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,647 @@ ++/* ++ * Davicom DM96xx USB 10/100Mbps ethernet devices ++ * ++ * Peter Korsgaard jacmet@sunsite.dk ++ * ++ * This file is licensed under the terms of the GNU General Public License ++ * version 2. This program is licensed "as is" without any warranty of any ++ * kind, whether express or implied. ++ */ ++ ++//#define DEBUG ++ ++#include <linux/module.h> ++#include <linux/sched.h> ++#include <linux/stddef.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/crc32.h> ++#include <linux/usb/usbnet.h> ++#include <linux/slab.h> ++ ++/* datasheet: ++ http://ptm2.cc.utu.fi/ftp/network/cards/DM9601/From_NET/DM9601-DS-P01-930914... ++*/ ++ ++/* control requests */ ++#define DM_READ_REGS 0x00 ++#define DM_WRITE_REGS 0x01 ++#define DM_READ_MEMS 0x02 ++#define DM_WRITE_REG 0x03 ++#define DM_WRITE_MEMS 0x05 ++#define DM_WRITE_MEM 0x07 ++ ++/* registers */ ++#define DM_NET_CTRL 0x00 ++#define DM_RX_CTRL 0x05 ++#define DM_SHARED_CTRL 0x0b ++#define DM_SHARED_ADDR 0x0c ++#define DM_SHARED_DATA 0x0d /* low + high */ ++#define DM_PHY_ADDR 0x10 /* 6 bytes */ ++#define DM_MCAST_ADDR 0x16 /* 8 bytes */ ++#define DM_GPR_CTRL 0x1e ++#define DM_GPR_DATA 0x1f ++#define DM_CHIP_ID 0x2c ++#define DM_MODE_CTRL 0x91 /* only on dm9620 */ ++ ++/* chip id values */ ++#define ID_DM9601 0 ++#define ID_DM9620 1 ++ ++#define DM_MAX_MCAST 64 ++#define DM_MCAST_SIZE 8 ++#define DM_EEPROM_LEN 256 ++#define DM_TX_OVERHEAD 2 /* 2 byte header */ ++#define DM_RX_OVERHEAD 7 /* 3 byte header + 4 byte crc tail */ ++#define DM_TIMEOUT 1000 ++ ++static int dm_read(struct usbnet *dev, u8 reg, u16 length, void *data) ++{ ++ int err; ++ err = usbnet_read_cmd(dev, DM_READ_REGS, ++ USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ 0, reg, data, length); ++ if(err != length && err >= 0) ++ err = -EINVAL; ++ return err; ++} ++ ++static int dm_read_reg(struct usbnet *dev, u8 reg, u8 *value) ++{ ++ return dm_read(dev, reg, 1, value); ++} ++ ++static int dm_write(struct usbnet *dev, u8 reg, u16 length, void *data) ++{ ++ int err; ++ err = usbnet_write_cmd(dev, DM_WRITE_REGS, ++ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ 0, reg, data, length); ++ ++ if (err >= 0 && err < length) ++ err = -EINVAL; ++ return err; ++} ++ ++static int dm_write_reg(struct usbnet *dev, u8 reg, u8 value) ++{ ++ return usbnet_write_cmd(dev, DM_WRITE_REG, ++ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ value, reg, NULL, 0); ++} ++ ++static void dm_write_async(struct usbnet *dev, u8 reg, u16 length, void *data) ++{ ++ usbnet_write_cmd_async(dev, DM_WRITE_REGS, ++ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ 0, reg, data, length); ++} ++ ++static void dm_write_reg_async(struct usbnet *dev, u8 reg, u8 value) ++{ ++ usbnet_write_cmd_async(dev, DM_WRITE_REG, ++ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ value, reg, NULL, 0); ++} ++ ++static int dm_read_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 *value) ++{ ++ int ret, i; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); ++ dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0xc : 0x4); ++ ++ for (i = 0; i < DM_TIMEOUT; i++) { ++ u8 tmp = 0; ++ ++ udelay(1); ++ ret = dm_read_reg(dev, DM_SHARED_CTRL, &tmp); ++ if (ret < 0) ++ goto out; ++ ++ /* ready */ ++ if ((tmp & 1) == 0) ++ break; ++ } ++ ++ if (i == DM_TIMEOUT) { ++ netdev_err(dev->net, "%s read timed out!\n", phy ? "phy" : "eeprom"); ++ ret = -EIO; ++ goto out; ++ } ++ ++ dm_write_reg(dev, DM_SHARED_CTRL, 0x0); ++ ret = dm_read(dev, DM_SHARED_DATA, 2, value); ++ ++ netdev_dbg(dev->net, "read shared %d 0x%02x returned 0x%04x, %d\n", ++ phy, reg, *value, ret); ++ ++ out: ++ mutex_unlock(&dev->phy_mutex); ++ return ret; ++} ++ ++static int dm_write_shared_word(struct usbnet *dev, int phy, u8 reg, __le16 value) ++{ ++ int ret, i; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ ret = dm_write(dev, DM_SHARED_DATA, 2, &value); ++ if (ret < 0) ++ goto out; ++ ++ dm_write_reg(dev, DM_SHARED_ADDR, phy ? (reg | 0x40) : reg); ++ dm_write_reg(dev, DM_SHARED_CTRL, phy ? 0x1a : 0x12); ++ ++ for (i = 0; i < DM_TIMEOUT; i++) { ++ u8 tmp = 0; ++ ++ udelay(1); ++ ret = dm_read_reg(dev, DM_SHARED_CTRL, &tmp); ++ if (ret < 0) ++ goto out; ++ ++ /* ready */ ++ if ((tmp & 1) == 0) ++ break; ++ } ++ ++ if (i == DM_TIMEOUT) { ++ netdev_err(dev->net, "%s write timed out!\n", phy ? "phy" : "eeprom"); ++ ret = -EIO; ++ goto out; ++ } ++ ++ dm_write_reg(dev, DM_SHARED_CTRL, 0x0); ++ ++out: ++ mutex_unlock(&dev->phy_mutex); ++ return ret; ++} ++ ++static int dm_read_eeprom_word(struct usbnet *dev, u8 offset, void *value) ++{ ++ return dm_read_shared_word(dev, 0, offset, value); ++} ++ ++ ++ ++static int dm9601_get_eeprom_len(struct net_device *dev) ++{ ++ return DM_EEPROM_LEN; ++} ++ ++static int dm9601_get_eeprom(struct net_device *net, ++ struct ethtool_eeprom *eeprom, u8 * data) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ __le16 *ebuf = (__le16 *) data; ++ int i; ++ ++ /* access is 16bit */ ++ if ((eeprom->offset % 2) || (eeprom->len % 2)) ++ return -EINVAL; ++ ++ for (i = 0; i < eeprom->len / 2; i++) { ++ if (dm_read_eeprom_word(dev, eeprom->offset / 2 + i, ++ &ebuf[i]) < 0) ++ return -EINVAL; ++ } ++ return 0; ++} ++ ++static int dm9601_mdio_read(struct net_device *netdev, int phy_id, int loc) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ ++ __le16 res; ++ ++ if (phy_id) { ++ netdev_dbg(dev->net, "Only internal phy supported\n"); ++ return 0; ++ } ++ ++ dm_read_shared_word(dev, 1, loc, &res); ++ ++ netdev_dbg(dev->net, ++ "dm9601_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", ++ phy_id, loc, le16_to_cpu(res)); ++ ++ return le16_to_cpu(res); ++} ++ ++static void dm9601_mdio_write(struct net_device *netdev, int phy_id, int loc, ++ int val) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ __le16 res = cpu_to_le16(val); ++ ++ if (phy_id) { ++ netdev_dbg(dev->net, "Only internal phy supported\n"); ++ return; ++ } ++ ++ netdev_dbg(dev->net, "dm9601_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", ++ phy_id, loc, val); ++ ++ dm_write_shared_word(dev, 1, loc, res); ++} ++ ++static void dm9601_get_drvinfo(struct net_device *net, ++ struct ethtool_drvinfo *info) ++{ ++ /* Inherit standard device info */ ++ usbnet_get_drvinfo(net, info); ++ info->eedump_len = DM_EEPROM_LEN; ++} ++ ++static u32 dm9601_get_link(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ return mii_link_ok(&dev->mii); ++} ++ ++static int dm9601_ioctl(struct net_device *net, struct ifreq *rq, int cmd) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); ++} ++ ++static const struct ethtool_ops dm9601_ethtool_ops = { ++ .get_drvinfo = dm9601_get_drvinfo, ++ .get_link = dm9601_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_eeprom_len = dm9601_get_eeprom_len, ++ .get_eeprom = dm9601_get_eeprom, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .nway_reset = usbnet_nway_reset, ++}; ++ ++static void dm9601_set_multicast(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ /* We use the 20 byte dev->data for our 8 byte filter buffer ++ * to avoid allocating memory that is tricky to free later */ ++ u8 *hashes = (u8 *) & dev->data; ++ u8 rx_ctl = 0x31; ++ ++ memset(hashes, 0x00, DM_MCAST_SIZE); ++ hashes[DM_MCAST_SIZE - 1] |= 0x80; /* broadcast address */ ++ ++ if (net->flags & IFF_PROMISC) { ++ rx_ctl |= 0x02; ++ } else if (net->flags & IFF_ALLMULTI || ++ netdev_mc_count(net) > DM_MAX_MCAST) { ++ rx_ctl |= 0x08; ++ } else if (!netdev_mc_empty(net)) { ++ struct netdev_hw_addr *ha; ++ ++ netdev_for_each_mc_addr(ha, net) { ++ u32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26; ++ hashes[crc >> 3] |= 1 << (crc & 0x7); ++ } ++ } ++ ++ dm_write_async(dev, DM_MCAST_ADDR, DM_MCAST_SIZE, hashes); ++ dm_write_reg_async(dev, DM_RX_CTRL, rx_ctl); ++} ++ ++static void __dm9601_set_mac_address(struct usbnet *dev) ++{ ++ dm_write_async(dev, DM_PHY_ADDR, ETH_ALEN, dev->net->dev_addr); ++} ++ ++static int dm9601_set_mac_address(struct net_device *net, void *p) ++{ ++ struct sockaddr *addr = p; ++ struct usbnet *dev = netdev_priv(net); ++ ++ if (!is_valid_ether_addr(addr->sa_data)) { ++ dev_err(&net->dev, "not setting invalid mac address %pM\n", ++ addr->sa_data); ++ return -EINVAL; ++ } ++ ++ memcpy(net->dev_addr, addr->sa_data, net->addr_len); ++ __dm9601_set_mac_address(dev); ++ ++ return 0; ++} ++ ++static const struct net_device_ops dm9601_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = dm9601_ioctl, ++ .ndo_set_rx_mode = dm9601_set_multicast, ++ .ndo_set_mac_address = dm9601_set_mac_address, ++}; ++ ++static int dm9601_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int ret; ++ u8 mac[ETH_ALEN], id; ++ ++ ret = usbnet_get_endpoints(dev, intf); ++ if (ret) ++ goto out; ++ ++ dev->net->netdev_ops = &dm9601_netdev_ops; ++ dev->net->ethtool_ops = &dm9601_ethtool_ops; ++ dev->net->hard_header_len += DM_TX_OVERHEAD; ++ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; ++ ++ /* dm9620/21a require room for 4 byte padding, even in dm9601 ++ * mode, so we need +1 to be able to receive full size ++ * ethernet frames. ++ */ ++ dev->rx_urb_size = dev->net->mtu + ETH_HLEN + DM_RX_OVERHEAD + 1; ++ ++ dev->mii.dev = dev->net; ++ dev->mii.mdio_read = dm9601_mdio_read; ++ dev->mii.mdio_write = dm9601_mdio_write; ++ dev->mii.phy_id_mask = 0x1f; ++ dev->mii.reg_num_mask = 0x1f; ++ ++ /* reset */ ++ dm_write_reg(dev, DM_NET_CTRL, 1); ++ udelay(20); ++ ++ /* read MAC */ ++ if (dm_read(dev, DM_PHY_ADDR, ETH_ALEN, mac) < 0) { ++ printk(KERN_ERR "Error reading MAC address\n"); ++ ret = -ENODEV; ++ goto out; ++ } ++ ++ /* ++ * Overwrite the auto-generated address only with good ones. ++ */ ++ if (is_valid_ether_addr(mac)) ++ memcpy(dev->net->dev_addr, mac, ETH_ALEN); ++ else { ++ printk(KERN_WARNING ++ "dm9601: No valid MAC address in EEPROM, using %pM\n", ++ dev->net->dev_addr); ++ __dm9601_set_mac_address(dev); ++ } ++ ++ if (dm_read_reg(dev, DM_CHIP_ID, &id) < 0) { ++ netdev_err(dev->net, "Error reading chip ID\n"); ++ ret = -ENODEV; ++ goto out; ++ } ++ ++ /* put dm9620 devices in dm9601 mode */ ++ if (id == ID_DM9620) { ++ u8 mode; ++ ++ if (dm_read_reg(dev, DM_MODE_CTRL, &mode) < 0) { ++ netdev_err(dev->net, "Error reading MODE_CTRL\n"); ++ ret = -ENODEV; ++ goto out; ++ } ++ dm_write_reg(dev, DM_MODE_CTRL, mode & 0x7f); ++ } ++ ++ /* power up phy */ ++ dm_write_reg(dev, DM_GPR_CTRL, 1); ++ dm_write_reg(dev, DM_GPR_DATA, 0); ++ ++ /* receive broadcast packets */ ++ dm9601_set_multicast(dev->net); ++ ++ dm9601_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); ++ dm9601_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, ++ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); ++ mii_nway_restart(&dev->mii); ++ ++out: ++ return ret; ++} ++ ++static int dm9601_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ u8 status; ++ int len; ++ ++ /* format: ++ b1: rx status ++ b2: packet length (incl crc) low ++ b3: packet length (incl crc) high ++ b4..n-4: packet data ++ bn-3..bn: ethernet crc ++ */ ++ ++ if (unlikely(skb->len < DM_RX_OVERHEAD)) { ++ dev_err(&dev->udev->dev, "unexpected tiny rx frame\n"); ++ return 0; ++ } ++ ++ status = skb->data[0]; ++ len = (skb->data[1] | (skb->data[2] << 8)) - 4; ++ ++ if (unlikely(status & 0xbf)) { ++ if (status & 0x01) dev->net->stats.rx_fifo_errors++; ++ if (status & 0x02) dev->net->stats.rx_crc_errors++; ++ if (status & 0x04) dev->net->stats.rx_frame_errors++; ++ if (status & 0x20) dev->net->stats.rx_missed_errors++; ++ if (status & 0x90) dev->net->stats.rx_length_errors++; ++ return 0; ++ } ++ ++ skb_pull(skb, 3); ++ skb_trim(skb, len); ++ ++ return 1; ++} ++ ++static struct sk_buff *dm9601_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ++ gfp_t flags) ++{ ++ int len, pad; ++ ++ /* format: ++ b1: packet length low ++ b2: packet length high ++ b3..n: packet data ++ */ ++ ++ len = skb->len + DM_TX_OVERHEAD; ++ ++ /* workaround for dm962x errata with tx fifo getting out of ++ * sync if a USB bulk transfer retry happens right after a ++ * packet with odd / maxpacket length by adding up to 3 bytes ++ * padding. ++ */ ++ while ((len & 1) || !(len % dev->maxpacket)) ++ len++; ++ ++ len -= DM_TX_OVERHEAD; /* hw header doesn't count as part of length */ ++ pad = len - skb->len; ++ ++ if (skb_headroom(skb) < DM_TX_OVERHEAD || skb_tailroom(skb) < pad) { ++ struct sk_buff *skb2; ++ ++ skb2 = skb_copy_expand(skb, DM_TX_OVERHEAD, pad, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (!skb) ++ return NULL; ++ } ++ ++ __skb_push(skb, DM_TX_OVERHEAD); ++ ++ if (pad) { ++ memset(skb->data + skb->len, 0, pad); ++ __skb_put(skb, pad); ++ } ++ ++ skb->data[0] = len; ++ skb->data[1] = len >> 8; ++ ++ return skb; ++} ++ ++static void dm9601_status(struct usbnet *dev, struct urb *urb) ++{ ++ int link; ++ u8 *buf; ++ ++ /* format: ++ b0: net status ++ b1: tx status 1 ++ b2: tx status 2 ++ b3: rx status ++ b4: rx overflow ++ b5: rx count ++ b6: tx count ++ b7: gpr ++ */ ++ ++ if (urb->actual_length < 8) ++ return; ++ ++ buf = urb->transfer_buffer; ++ ++ link = !!(buf[0] & 0x40); ++ if (netif_carrier_ok(dev->net) != link) { ++ usbnet_link_change(dev, link, 1); ++ netdev_dbg(dev->net, "Link Status is: %d\n", link); ++ } ++} ++ ++static int dm9601_link_reset(struct usbnet *dev) ++{ ++ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; ++ ++ mii_check_media(&dev->mii, 1, 1); ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ ++ netdev_dbg(dev->net, "link_reset() speed: %u duplex: %d\n", ++ ethtool_cmd_speed(&ecmd), ecmd.duplex); ++ ++ return 0; ++} ++ ++static const struct driver_info dm9601_info = { ++ .description = "Davicom DM96xx USB 10/100 Ethernet", ++ .flags = FLAG_ETHER | FLAG_LINK_INTR, ++ .bind = dm9601_bind, ++ .rx_fixup = dm9601_rx_fixup, ++ .tx_fixup = dm9601_tx_fixup, ++ .status = dm9601_status, ++ .link_reset = dm9601_link_reset, ++ .reset = dm9601_link_reset, ++}; ++ ++static const struct usb_device_id products[] = { ++ { ++ USB_DEVICE(0x07aa, 0x9601), /* Corega FEther USB-TXC */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x9601), /* Davicom USB-100 */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x6688), /* ZT6688 USB NIC */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x0268), /* ShanTou ST268 USB NIC */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x8515), /* ADMtek ADM8515 USB NIC */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a47, 0x9601), /* Hirose USB-100 */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0fe6, 0x8101), /* DM9601 USB to Fast Ethernet Adapter */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0fe6, 0x9700), /* DM9601 USB to Fast Ethernet Adapter */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x9000), /* DM9000E */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x9620), /* DM9620 USB to Fast Ethernet Adapter */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x9621), /* DM9621A USB to Fast Ethernet Adapter */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x9622), /* DM9622 USB to Fast Ethernet Adapter */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x0269), /* DM962OA USB to Fast Ethernet Adapter */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ { ++ USB_DEVICE(0x0a46, 0x1269), /* DM9621A USB to Fast Ethernet Adapter */ ++ .driver_info = (unsigned long)&dm9601_info, ++ }, ++ {}, // END ++}; ++ ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver dm9601_driver = { ++ .name = "dm9601", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(dm9601_driver); ++ ++MODULE_AUTHOR("Peter Korsgaard jacmet@sunsite.dk"); ++MODULE_DESCRIPTION("Davicom DM96xx USB 10/100 ethernet devices"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/gl620a.c backports-4.2.6-1/drivers/net/usb/gl620a.c +--- backports-4.2.6-1.org/drivers/net/usb/gl620a.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/gl620a.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,242 @@ ++/* ++ * GeneSys GL620USB-A based links ++ * Copyright (C) 2001 by Jiun-Jie Huang huangjj@genesyslogic.com.tw ++ * Copyright (C) 2001 by Stanislav Brabec utx@penguin.cz ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++// #define DEBUG // error path messages, extra info ++// #define VERBOSE // more; success messages ++ ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/usb/usbnet.h> ++#include <linux/gfp.h> ++ ++ ++/* ++ * GeneSys GL620USB-A (www.genesyslogic.com.tw) ++ * ++ * ... should partially interop with the Win32 driver for this hardware. ++ * The GeneSys docs imply there's some NDIS issue motivating this framing. ++ * ++ * Some info from GeneSys: ++ * - GL620USB-A is full duplex; GL620USB is only half duplex for bulk. ++ * (Some cables, like the BAFO-100c, use the half duplex version.) ++ * - For the full duplex model, the low bit of the version code says ++ * which side is which ("left/right"). ++ * - For the half duplex type, a control/interrupt handshake settles ++ * the transfer direction. (That's disabled here, partially coded.) ++ * A control URB would block until other side writes an interrupt. ++ * ++ * Original code from Jiun-Jie Huang huangjj@genesyslogic.com.tw ++ * and merged into "usbnet" by Stanislav Brabec utx@penguin.cz. ++ */ ++ ++// control msg write command ++#define GENELINK_CONNECT_WRITE 0xF0 ++// interrupt pipe index ++#define GENELINK_INTERRUPT_PIPE 0x03 ++// interrupt read buffer size ++#define INTERRUPT_BUFSIZE 0x08 ++// interrupt pipe interval value ++#define GENELINK_INTERRUPT_INTERVAL 0x10 ++// max transmit packet number per transmit ++#define GL_MAX_TRANSMIT_PACKETS 32 ++// max packet length ++#define GL_MAX_PACKET_LEN 1514 ++// max receive buffer size ++#define GL_RCV_BUF_SIZE \ ++ (((GL_MAX_PACKET_LEN + 4) * GL_MAX_TRANSMIT_PACKETS) + 4) ++ ++struct gl_packet { ++ __le32 packet_length; ++ char packet_data [1]; ++}; ++ ++struct gl_header { ++ __le32 packet_count; ++ struct gl_packet packets; ++}; ++ ++static int genelink_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ struct gl_header *header; ++ struct gl_packet *packet; ++ struct sk_buff *gl_skb; ++ u32 size; ++ u32 count; ++ ++ /* This check is no longer done by usbnet */ ++ if (skb->len < dev->net->hard_header_len) ++ return 0; ++ ++ header = (struct gl_header *) skb->data; ++ ++ // get the packet count of the received skb ++ count = le32_to_cpu(header->packet_count); ++ if (count > GL_MAX_TRANSMIT_PACKETS) { ++ netdev_dbg(dev->net, ++ "genelink: invalid received packet count %u\n", ++ count); ++ return 0; ++ } ++ ++ // set the current packet pointer to the first packet ++ packet = &header->packets; ++ ++ // decrement the length for the packet count size 4 bytes ++ skb_pull(skb, 4); ++ ++ while (count > 1) { ++ // get the packet length ++ size = le32_to_cpu(packet->packet_length); ++ ++ // this may be a broken packet ++ if (size > GL_MAX_PACKET_LEN) { ++ netdev_dbg(dev->net, "genelink: invalid rx length %d\n", ++ size); ++ return 0; ++ } ++ ++ // allocate the skb for the individual packet ++ gl_skb = alloc_skb(size, GFP_ATOMIC); ++ if (gl_skb) { ++ ++ // copy the packet data to the new skb ++ memcpy(skb_put(gl_skb, size), ++ packet->packet_data, size); ++ usbnet_skb_return(dev, gl_skb); ++ } ++ ++ // advance to the next packet ++ packet = (struct gl_packet *)&packet->packet_data[size]; ++ count--; ++ ++ // shift the data pointer to the next gl_packet ++ skb_pull(skb, size + 4); ++ } ++ ++ // skip the packet length field 4 bytes ++ skb_pull(skb, 4); ++ ++ if (skb->len > GL_MAX_PACKET_LEN) { ++ netdev_dbg(dev->net, "genelink: invalid rx length %d\n", ++ skb->len); ++ return 0; ++ } ++ return 1; ++} ++ ++static struct sk_buff * ++genelink_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) ++{ ++ int padlen; ++ int length = skb->len; ++ int headroom = skb_headroom(skb); ++ int tailroom = skb_tailroom(skb); ++ __le32 *packet_count; ++ __le32 *packet_len; ++ ++ // FIXME: magic numbers, bleech ++ padlen = ((skb->len + (4 + 4*1)) % 64) ? 0 : 1; ++ ++ if ((!skb_cloned(skb)) ++ && ((headroom + tailroom) >= (padlen + (4 + 4*1)))) { ++ if ((headroom < (4 + 4*1)) || (tailroom < padlen)) { ++ skb->data = memmove(skb->head + (4 + 4*1), ++ skb->data, skb->len); ++ skb_set_tail_pointer(skb, skb->len); ++ } ++ } else { ++ struct sk_buff *skb2; ++ skb2 = skb_copy_expand(skb, (4 + 4*1) , padlen, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (!skb) ++ return NULL; ++ } ++ ++ // attach the packet count to the header ++ packet_count = (__le32 *) skb_push(skb, (4 + 4*1)); ++ packet_len = packet_count + 1; ++ ++ *packet_count = cpu_to_le32(1); ++ *packet_len = cpu_to_le32(length); ++ ++ // add padding byte ++ if ((skb->len % dev->maxpacket) == 0) ++ skb_put(skb, 1); ++ ++ return skb; ++} ++ ++static int genelink_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ dev->hard_mtu = GL_RCV_BUF_SIZE; ++ dev->net->hard_header_len += 4; ++ dev->in = usb_rcvbulkpipe(dev->udev, dev->driver_info->in); ++ dev->out = usb_sndbulkpipe(dev->udev, dev->driver_info->out); ++ return 0; ++} ++ ++static const struct driver_info genelink_info = { ++ .description = "Genesys GeneLink", ++ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_GL | FLAG_NO_SETINT, ++ .bind = genelink_bind, ++ .rx_fixup = genelink_rx_fixup, ++ .tx_fixup = genelink_tx_fixup, ++ ++ .in = 1, .out = 2, ++ ++#ifdef GENELINK_ACK ++ .check_connect =genelink_check_connect, ++#endif ++}; ++ ++static const struct usb_device_id products [] = { ++ ++{ ++ USB_DEVICE(0x05e3, 0x0502), // GL620USB-A ++ .driver_info = (unsigned long) &genelink_info, ++}, ++ /* NOT: USB_DEVICE(0x05e3, 0x0501), // GL620USB ++ * that's half duplex, not currently supported ++ */ ++ { }, // END ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver gl620a_driver = { ++ .name = "gl620a", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(gl620a_driver); ++ ++MODULE_AUTHOR("Jiun-Jie Huang"); ++MODULE_DESCRIPTION("GL620-USB-A Host-to-Host Link cables"); ++MODULE_LICENSE("GPL"); ++ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/hso.c backports-4.2.6-1/drivers/net/usb/hso.c +--- backports-4.2.6-1.org/drivers/net/usb/hso.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/hso.c 2016-01-27 15:03:25.000000000 +0100 +@@ -0,0 +1,3322 @@ ++/****************************************************************************** ++ * ++ * Driver for Option High Speed Mobile Devices. ++ * ++ * Copyright (C) 2008 Option International ++ * Filip Aben f.aben@option.com ++ * Denis Joseph Barrow d.barow@option.com ++ * Jan Dumon j.dumon@option.com ++ * Copyright (C) 2007 Andrew Bird (Sphere Systems Ltd) ++ * ajb@spheresystems.co.uk ++ * Copyright (C) 2008 Greg Kroah-Hartman gregkh@suse.de ++ * Copyright (C) 2008 Novell, Inc. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, ++ * USA ++ * ++ * ++ *****************************************************************************/ ++ ++/****************************************************************************** ++ * ++ * Description of the device: ++ * ++ * Interface 0: Contains the IP network interface on the bulk end points. ++ * The multiplexed serial ports are using the interrupt and ++ * control endpoints. ++ * Interrupt contains a bitmap telling which multiplexed ++ * serialport needs servicing. ++ * ++ * Interface 1: Diagnostics port, uses bulk only, do not submit urbs until the ++ * port is opened, as this have a huge impact on the network port ++ * throughput. ++ * ++ * Interface 2: Standard modem interface - circuit switched interface, this ++ * can be used to make a standard ppp connection however it ++ * should not be used in conjunction with the IP network interface ++ * enabled for USB performance reasons i.e. if using this set ++ * ideally disable_net=1. ++ * ++ *****************************************************************************/ ++ ++#include <linux/sched.h> ++#include <linux/slab.h> ++#include <linux/init.h> ++#include <linux/delay.h> ++#include <linux/netdevice.h> ++#include <linux/module.h> ++#include <linux/ethtool.h> ++#include <linux/usb.h> ++#include <linux/tty.h> ++#include <linux/tty_driver.h> ++#include <linux/tty_flip.h> ++#include <linux/kmod.h> ++#include <linux/rfkill.h> ++#include <linux/ip.h> ++#include <linux/uaccess.h> ++#include <linux/usb/cdc.h> ++#include <net/arp.h> ++#include <asm/byteorder.h> ++#include <linux/serial_core.h> ++#include <linux/serial.h> ++#include <asm/local.h> ++ ++#define MOD_AUTHOR "Option Wireless" ++#define MOD_DESCRIPTION "USB High Speed Option driver" ++#define MOD_LICENSE "GPL" ++ ++#define HSO_MAX_NET_DEVICES 10 ++#define HSO__MAX_MTU 2048 ++#define DEFAULT_MTU 1500 ++#define DEFAULT_MRU 1500 ++ ++#define CTRL_URB_RX_SIZE 1024 ++#define CTRL_URB_TX_SIZE 64 ++ ++#define BULK_URB_RX_SIZE 4096 ++#define BULK_URB_TX_SIZE 8192 ++ ++#define MUX_BULK_RX_BUF_SIZE HSO__MAX_MTU ++#define MUX_BULK_TX_BUF_SIZE HSO__MAX_MTU ++#define MUX_BULK_RX_BUF_COUNT 4 ++#define USB_TYPE_OPTION_VENDOR 0x20 ++ ++/* These definitions are used with the struct hso_net flags element */ ++/* - use *_bit operations on it. (bit indices not values.) */ ++#define HSO_NET_RUNNING 0 ++ ++#define HSO_NET_TX_TIMEOUT (HZ*10) ++ ++#define HSO_SERIAL_MAGIC 0x48534f31 ++ ++/* Number of ttys to handle */ ++#define HSO_SERIAL_TTY_MINORS 256 ++ ++#define MAX_RX_URBS 2 ++ ++/*****************************************************************************/ ++/* Debugging functions */ ++/*****************************************************************************/ ++#define D__(lvl_, fmt, arg...) \ ++ do { \ ++ printk(lvl_ "[%d:%s]: " fmt "\n", \ ++ __LINE__, __func__, ## arg); \ ++ } while (0) ++ ++#define D_(lvl, args...) \ ++ do { \ ++ if (lvl & debug) \ ++ D__(KERN_INFO, args); \ ++ } while (0) ++ ++#define D1(args...) D_(0x01, ##args) ++#define D2(args...) D_(0x02, ##args) ++#define D3(args...) D_(0x04, ##args) ++#define D4(args...) D_(0x08, ##args) ++#define D5(args...) D_(0x10, ##args) ++ ++/*****************************************************************************/ ++/* Enumerators */ ++/*****************************************************************************/ ++enum pkt_parse_state { ++ WAIT_IP, ++ WAIT_DATA, ++ WAIT_SYNC ++}; ++ ++/*****************************************************************************/ ++/* Structs */ ++/*****************************************************************************/ ++ ++struct hso_shared_int { ++ struct usb_endpoint_descriptor *intr_endp; ++ void *shared_intr_buf; ++ struct urb *shared_intr_urb; ++ struct usb_device *usb; ++ int use_count; ++ int ref_count; ++ struct mutex shared_int_lock; ++}; ++ ++struct hso_net { ++ struct hso_device *parent; ++ struct net_device *net; ++ struct rfkill *rfkill; ++ char name[24]; ++ ++ struct usb_endpoint_descriptor *in_endp; ++ struct usb_endpoint_descriptor *out_endp; ++ ++ struct urb *mux_bulk_rx_urb_pool[MUX_BULK_RX_BUF_COUNT]; ++ struct urb *mux_bulk_tx_urb; ++ void *mux_bulk_rx_buf_pool[MUX_BULK_RX_BUF_COUNT]; ++ void *mux_bulk_tx_buf; ++ ++ struct sk_buff *skb_rx_buf; ++ struct sk_buff *skb_tx_buf; ++ ++ enum pkt_parse_state rx_parse_state; ++ spinlock_t net_lock; ++ ++ unsigned short rx_buf_size; ++ unsigned short rx_buf_missing; ++ struct iphdr rx_ip_hdr; ++ ++ unsigned long flags; ++}; ++ ++enum rx_ctrl_state{ ++ RX_IDLE, ++ RX_SENT, ++ RX_PENDING ++}; ++ ++#define BM_REQUEST_TYPE (0xa1) ++#define B_NOTIFICATION (0x20) ++#define W_VALUE (0x0) ++#define W_LENGTH (0x2) ++ ++#define B_OVERRUN (0x1<<6) ++#define B_PARITY (0x1<<5) ++#define B_FRAMING (0x1<<4) ++#define B_RING_SIGNAL (0x1<<3) ++#define B_BREAK (0x1<<2) ++#define B_TX_CARRIER (0x1<<1) ++#define B_RX_CARRIER (0x1<<0) ++ ++struct hso_serial_state_notification { ++ u8 bmRequestType; ++ u8 bNotification; ++ u16 wValue; ++ u16 wIndex; ++ u16 wLength; ++ u16 UART_state_bitmap; ++} __packed; ++ ++struct hso_tiocmget { ++ struct mutex mutex; ++ wait_queue_head_t waitq; ++ int intr_completed; ++ struct usb_endpoint_descriptor *endp; ++ struct urb *urb; ++ struct hso_serial_state_notification serial_state_notification; ++ u16 prev_UART_state_bitmap; ++ struct uart_icount icount; ++}; ++ ++ ++struct hso_serial { ++ struct hso_device *parent; ++ int magic; ++ u8 minor; ++ ++ struct hso_shared_int *shared_int; ++ ++ /* rx/tx urb could be either a bulk urb or a control urb depending ++ on which serial port it is used on. */ ++ struct urb *rx_urb[MAX_RX_URBS]; ++ u8 num_rx_urbs; ++ u8 *rx_data[MAX_RX_URBS]; ++ u16 rx_data_length; /* should contain allocated length */ ++ ++ struct urb *tx_urb; ++ u8 *tx_data; ++ u8 *tx_buffer; ++ u16 tx_data_length; /* should contain allocated length */ ++ u16 tx_data_count; ++ u16 tx_buffer_count; ++ struct usb_ctrlrequest ctrl_req_tx; ++ struct usb_ctrlrequest ctrl_req_rx; ++ ++ struct usb_endpoint_descriptor *in_endp; ++ struct usb_endpoint_descriptor *out_endp; ++ ++ enum rx_ctrl_state rx_state; ++ u8 rts_state; ++ u8 dtr_state; ++ unsigned tx_urb_used:1; ++ ++ struct tty_port port; ++ /* from usb_serial_port */ ++ spinlock_t serial_lock; ++ ++ int (*write_data) (struct hso_serial *serial); ++ struct hso_tiocmget *tiocmget; ++ /* Hacks required to get flow control ++ * working on the serial receive buffers ++ * so as not to drop characters on the floor. ++ */ ++ int curr_rx_urb_idx; ++ u8 rx_urb_filled[MAX_RX_URBS]; ++ struct tasklet_struct unthrottle_tasklet; ++}; ++ ++struct hso_device { ++ union { ++ struct hso_serial *dev_serial; ++ struct hso_net *dev_net; ++ } port_data; ++ ++ u32 port_spec; ++ ++ u8 is_active; ++ u8 usb_gone; ++ struct work_struct async_get_intf; ++ struct work_struct async_put_intf; ++ ++ struct usb_device *usb; ++ struct usb_interface *interface; ++ ++ struct device *dev; ++ struct kref ref; ++ struct mutex mutex; ++}; ++ ++/* Type of interface */ ++#define HSO_INTF_MASK 0xFF00 ++#define HSO_INTF_MUX 0x0100 ++#define HSO_INTF_BULK 0x0200 ++ ++/* Type of port */ ++#define HSO_PORT_MASK 0xFF ++#define HSO_PORT_NO_PORT 0x0 ++#define HSO_PORT_CONTROL 0x1 ++#define HSO_PORT_APP 0x2 ++#define HSO_PORT_GPS 0x3 ++#define HSO_PORT_PCSC 0x4 ++#define HSO_PORT_APP2 0x5 ++#define HSO_PORT_GPS_CONTROL 0x6 ++#define HSO_PORT_MSD 0x7 ++#define HSO_PORT_VOICE 0x8 ++#define HSO_PORT_DIAG2 0x9 ++#define HSO_PORT_DIAG 0x10 ++#define HSO_PORT_MODEM 0x11 ++#define HSO_PORT_NETWORK 0x12 ++ ++/* Additional device info */ ++#define HSO_INFO_MASK 0xFF000000 ++#define HSO_INFO_CRC_BUG 0x01000000 ++ ++/*****************************************************************************/ ++/* Prototypes */ ++/*****************************************************************************/ ++/* Serial driver functions */ ++static int hso_serial_tiocmset(struct tty_struct *tty, ++ unsigned int set, unsigned int clear); ++static void ctrl_callback(struct urb *urb); ++static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial); ++static void hso_kick_transmit(struct hso_serial *serial); ++/* Helper functions */ ++static int hso_mux_submit_intr_urb(struct hso_shared_int *mux_int, ++ struct usb_device *usb, gfp_t gfp); ++static void handle_usb_error(int status, const char *function, ++ struct hso_device *hso_dev); ++static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *intf, ++ int type, int dir); ++static int hso_get_mux_ports(struct usb_interface *intf, unsigned char *ports); ++static void hso_free_interface(struct usb_interface *intf); ++static int hso_start_serial_device(struct hso_device *hso_dev, gfp_t flags); ++static int hso_stop_serial_device(struct hso_device *hso_dev); ++static int hso_start_net_device(struct hso_device *hso_dev); ++static void hso_free_shared_int(struct hso_shared_int *shared_int); ++static int hso_stop_net_device(struct hso_device *hso_dev); ++static void hso_serial_ref_free(struct kref *ref); ++static void hso_std_serial_read_bulk_callback(struct urb *urb); ++static int hso_mux_serial_read(struct hso_serial *serial); ++static void async_get_intf(struct work_struct *data); ++static void async_put_intf(struct work_struct *data); ++static int hso_put_activity(struct hso_device *hso_dev); ++static int hso_get_activity(struct hso_device *hso_dev); ++static void tiocmget_intr_callback(struct urb *urb); ++/*****************************************************************************/ ++/* Helping functions */ ++/*****************************************************************************/ ++ ++/* #define DEBUG */ ++ ++static inline struct hso_net *dev2net(struct hso_device *hso_dev) ++{ ++ return hso_dev->port_data.dev_net; ++} ++ ++static inline struct hso_serial *dev2ser(struct hso_device *hso_dev) ++{ ++ return hso_dev->port_data.dev_serial; ++} ++ ++/* Debugging functions */ ++#ifdef DEBUG ++static void dbg_dump(int line_count, const char *func_name, unsigned char *buf, ++ unsigned int len) ++{ ++ static char name[255]; ++ ++ sprintf(name, "hso[%d:%s]", line_count, func_name); ++ print_hex_dump_bytes(name, DUMP_PREFIX_NONE, buf, len); ++} ++ ++#define DUMP(buf_, len_) \ ++ dbg_dump(__LINE__, __func__, (unsigned char *)buf_, len_) ++ ++#define DUMP1(buf_, len_) \ ++ do { \ ++ if (0x01 & debug) \ ++ DUMP(buf_, len_); \ ++ } while (0) ++#else ++#define DUMP(buf_, len_) ++#define DUMP1(buf_, len_) ++#endif ++ ++/* module parameters */ ++static int debug; ++static int tty_major; ++static int disable_net; ++ ++/* driver info */ ++static const char driver_name[] = "hso"; ++static const char tty_filename[] = "ttyHS"; ++static const char *version = __FILE__ ": " MOD_AUTHOR; ++/* the usb driver itself (registered in hso_init) */ ++static struct usb_driver hso_driver; ++/* serial structures */ ++static struct tty_driver *tty_drv; ++static struct hso_device *serial_table[HSO_SERIAL_TTY_MINORS]; ++static struct hso_device *network_table[HSO_MAX_NET_DEVICES]; ++static spinlock_t serial_table_lock; ++ ++static const s32 default_port_spec[] = { ++ HSO_INTF_MUX | HSO_PORT_NETWORK, ++ HSO_INTF_BULK | HSO_PORT_DIAG, ++ HSO_INTF_BULK | HSO_PORT_MODEM, ++ 0 ++}; ++ ++static const s32 icon321_port_spec[] = { ++ HSO_INTF_MUX | HSO_PORT_NETWORK, ++ HSO_INTF_BULK | HSO_PORT_DIAG2, ++ HSO_INTF_BULK | HSO_PORT_MODEM, ++ HSO_INTF_BULK | HSO_PORT_DIAG, ++ 0 ++}; ++ ++#define default_port_device(vendor, product) \ ++ USB_DEVICE(vendor, product), \ ++ .driver_info = (kernel_ulong_t)default_port_spec ++ ++#define icon321_port_device(vendor, product) \ ++ USB_DEVICE(vendor, product), \ ++ .driver_info = (kernel_ulong_t)icon321_port_spec ++ ++/* list of devices we support */ ++static const struct usb_device_id hso_ids[] = { ++ {default_port_device(0x0af0, 0x6711)}, ++ {default_port_device(0x0af0, 0x6731)}, ++ {default_port_device(0x0af0, 0x6751)}, ++ {default_port_device(0x0af0, 0x6771)}, ++ {default_port_device(0x0af0, 0x6791)}, ++ {default_port_device(0x0af0, 0x6811)}, ++ {default_port_device(0x0af0, 0x6911)}, ++ {default_port_device(0x0af0, 0x6951)}, ++ {default_port_device(0x0af0, 0x6971)}, ++ {default_port_device(0x0af0, 0x7011)}, ++ {default_port_device(0x0af0, 0x7031)}, ++ {default_port_device(0x0af0, 0x7051)}, ++ {default_port_device(0x0af0, 0x7071)}, ++ {default_port_device(0x0af0, 0x7111)}, ++ {default_port_device(0x0af0, 0x7211)}, ++ {default_port_device(0x0af0, 0x7251)}, ++ {default_port_device(0x0af0, 0x7271)}, ++ {default_port_device(0x0af0, 0x7311)}, ++ {default_port_device(0x0af0, 0xc031)}, /* Icon-Edge */ ++ {icon321_port_device(0x0af0, 0xd013)}, /* Module HSxPA */ ++ {icon321_port_device(0x0af0, 0xd031)}, /* Icon-321 */ ++ {icon321_port_device(0x0af0, 0xd033)}, /* Icon-322 */ ++ {USB_DEVICE(0x0af0, 0x7301)}, /* GE40x */ ++ {USB_DEVICE(0x0af0, 0x7361)}, /* GE40x */ ++ {USB_DEVICE(0x0af0, 0x7381)}, /* GE40x */ ++ {USB_DEVICE(0x0af0, 0x7401)}, /* GI 0401 */ ++ {USB_DEVICE(0x0af0, 0x7501)}, /* GTM 382 */ ++ {USB_DEVICE(0x0af0, 0x7601)}, /* GE40x */ ++ {USB_DEVICE(0x0af0, 0x7701)}, ++ {USB_DEVICE(0x0af0, 0x7706)}, ++ {USB_DEVICE(0x0af0, 0x7801)}, ++ {USB_DEVICE(0x0af0, 0x7901)}, ++ {USB_DEVICE(0x0af0, 0x7A01)}, ++ {USB_DEVICE(0x0af0, 0x7A05)}, ++ {USB_DEVICE(0x0af0, 0x8200)}, ++ {USB_DEVICE(0x0af0, 0x8201)}, ++ {USB_DEVICE(0x0af0, 0x8300)}, ++ {USB_DEVICE(0x0af0, 0x8302)}, ++ {USB_DEVICE(0x0af0, 0x8304)}, ++ {USB_DEVICE(0x0af0, 0x8400)}, ++ {USB_DEVICE(0x0af0, 0x8600)}, ++ {USB_DEVICE(0x0af0, 0x8800)}, ++ {USB_DEVICE(0x0af0, 0x8900)}, ++ {USB_DEVICE(0x0af0, 0x9000)}, ++ {USB_DEVICE(0x0af0, 0x9200)}, /* Option GTM671WFS */ ++ {USB_DEVICE(0x0af0, 0xd035)}, ++ {USB_DEVICE(0x0af0, 0xd055)}, ++ {USB_DEVICE(0x0af0, 0xd155)}, ++ {USB_DEVICE(0x0af0, 0xd255)}, ++ {USB_DEVICE(0x0af0, 0xd057)}, ++ {USB_DEVICE(0x0af0, 0xd157)}, ++ {USB_DEVICE(0x0af0, 0xd257)}, ++ {USB_DEVICE(0x0af0, 0xd357)}, ++ {USB_DEVICE(0x0af0, 0xd058)}, ++ {USB_DEVICE(0x0af0, 0xc100)}, ++ {} ++}; ++MODULE_DEVICE_TABLE(usb, hso_ids); ++ ++/* Sysfs attribute */ ++static ssize_t hso_sysfs_show_porttype(struct device *dev, ++ struct device_attribute *attr, ++ char *buf) ++{ ++ struct hso_device *hso_dev = dev_get_drvdata(dev); ++ char *port_name; ++ ++ if (!hso_dev) ++ return 0; ++ ++ switch (hso_dev->port_spec & HSO_PORT_MASK) { ++ case HSO_PORT_CONTROL: ++ port_name = "Control"; ++ break; ++ case HSO_PORT_APP: ++ port_name = "Application"; ++ break; ++ case HSO_PORT_APP2: ++ port_name = "Application2"; ++ break; ++ case HSO_PORT_GPS: ++ port_name = "GPS"; ++ break; ++ case HSO_PORT_GPS_CONTROL: ++ port_name = "GPS Control"; ++ break; ++ case HSO_PORT_PCSC: ++ port_name = "PCSC"; ++ break; ++ case HSO_PORT_DIAG: ++ port_name = "Diagnostic"; ++ break; ++ case HSO_PORT_DIAG2: ++ port_name = "Diagnostic2"; ++ break; ++ case HSO_PORT_MODEM: ++ port_name = "Modem"; ++ break; ++ case HSO_PORT_NETWORK: ++ port_name = "Network"; ++ break; ++ default: ++ port_name = "Unknown"; ++ break; ++ } ++ ++ return sprintf(buf, "%s\n", port_name); ++} ++static DEVICE_ATTR(hsotype, S_IRUGO, hso_sysfs_show_porttype, NULL); ++ ++static struct attribute *hso_serial_dev_attrs[] = { ++ &dev_attr_hsotype.attr, ++ NULL ++}; ++ ++ATTRIBUTE_GROUPS(hso_serial_dev); ++ ++static int hso_urb_to_index(struct hso_serial *serial, struct urb *urb) ++{ ++ int idx; ++ ++ for (idx = 0; idx < serial->num_rx_urbs; idx++) ++ if (serial->rx_urb[idx] == urb) ++ return idx; ++ dev_err(serial->parent->dev, "hso_urb_to_index failed\n"); ++ return -1; ++} ++ ++/* converts mux value to a port spec value */ ++static u32 hso_mux_to_port(int mux) ++{ ++ u32 result; ++ ++ switch (mux) { ++ case 0x1: ++ result = HSO_PORT_CONTROL; ++ break; ++ case 0x2: ++ result = HSO_PORT_APP; ++ break; ++ case 0x4: ++ result = HSO_PORT_PCSC; ++ break; ++ case 0x8: ++ result = HSO_PORT_GPS; ++ break; ++ case 0x10: ++ result = HSO_PORT_APP2; ++ break; ++ default: ++ result = HSO_PORT_NO_PORT; ++ } ++ return result; ++} ++ ++/* converts port spec value to a mux value */ ++static u32 hso_port_to_mux(int port) ++{ ++ u32 result; ++ ++ switch (port & HSO_PORT_MASK) { ++ case HSO_PORT_CONTROL: ++ result = 0x0; ++ break; ++ case HSO_PORT_APP: ++ result = 0x1; ++ break; ++ case HSO_PORT_PCSC: ++ result = 0x2; ++ break; ++ case HSO_PORT_GPS: ++ result = 0x3; ++ break; ++ case HSO_PORT_APP2: ++ result = 0x4; ++ break; ++ default: ++ result = 0x0; ++ } ++ return result; ++} ++ ++static struct hso_serial *get_serial_by_shared_int_and_type( ++ struct hso_shared_int *shared_int, ++ int mux) ++{ ++ int i, port; ++ ++ port = hso_mux_to_port(mux); ++ ++ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { ++ if (serial_table[i] && ++ (dev2ser(serial_table[i])->shared_int == shared_int) && ++ ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) { ++ return dev2ser(serial_table[i]); ++ } ++ } ++ ++ return NULL; ++} ++ ++static struct hso_serial *get_serial_by_index(unsigned index) ++{ ++ struct hso_serial *serial = NULL; ++ unsigned long flags; ++ ++ spin_lock_irqsave(&serial_table_lock, flags); ++ if (serial_table[index]) ++ serial = dev2ser(serial_table[index]); ++ spin_unlock_irqrestore(&serial_table_lock, flags); ++ ++ return serial; ++} ++ ++static int get_free_serial_index(void) ++{ ++ int index; ++ unsigned long flags; ++ ++ spin_lock_irqsave(&serial_table_lock, flags); ++ for (index = 0; index < HSO_SERIAL_TTY_MINORS; index++) { ++ if (serial_table[index] == NULL) { ++ spin_unlock_irqrestore(&serial_table_lock, flags); ++ return index; ++ } ++ } ++ spin_unlock_irqrestore(&serial_table_lock, flags); ++ ++ printk(KERN_ERR "%s: no free serial devices in table\n", __func__); ++ return -1; ++} ++ ++static void set_serial_by_index(unsigned index, struct hso_serial *serial) ++{ ++ unsigned long flags; ++ ++ spin_lock_irqsave(&serial_table_lock, flags); ++ if (serial) ++ serial_table[index] = serial->parent; ++ else ++ serial_table[index] = NULL; ++ spin_unlock_irqrestore(&serial_table_lock, flags); ++} ++ ++static void handle_usb_error(int status, const char *function, ++ struct hso_device *hso_dev) ++{ ++ char *explanation; ++ ++ switch (status) { ++ case -ENODEV: ++ explanation = "no device"; ++ break; ++ case -ENOENT: ++ explanation = "endpoint not enabled"; ++ break; ++ case -EPIPE: ++ explanation = "endpoint stalled"; ++ break; ++ case -ENOSPC: ++ explanation = "not enough bandwidth"; ++ break; ++ case -ESHUTDOWN: ++ explanation = "device disabled"; ++ break; ++ case -EHOSTUNREACH: ++ explanation = "device suspended"; ++ break; ++ case -EINVAL: ++ case -EAGAIN: ++ case -EFBIG: ++ case -EMSGSIZE: ++ explanation = "internal error"; ++ break; ++ case -EILSEQ: ++ case -EPROTO: ++ case -ETIME: ++ case -ETIMEDOUT: ++ explanation = "protocol error"; ++ if (hso_dev) ++ usb_queue_reset_device(hso_dev->interface); ++ break; ++ default: ++ explanation = "unknown status"; ++ break; ++ } ++ ++ /* log a meaningful explanation of an USB status */ ++ D1("%s: received USB status - %s (%d)", function, explanation, status); ++} ++ ++/* Network interface functions */ ++ ++/* called when net interface is brought up by ifconfig */ ++static int hso_net_open(struct net_device *net) ++{ ++ struct hso_net *odev = netdev_priv(net); ++ unsigned long flags = 0; ++ ++ if (!odev) { ++ dev_err(&net->dev, "No net device !\n"); ++ return -ENODEV; ++ } ++ ++ odev->skb_tx_buf = NULL; ++ ++ /* setup environment */ ++ spin_lock_irqsave(&odev->net_lock, flags); ++ odev->rx_parse_state = WAIT_IP; ++ odev->rx_buf_size = 0; ++ odev->rx_buf_missing = sizeof(struct iphdr); ++ spin_unlock_irqrestore(&odev->net_lock, flags); ++ ++ /* We are up and running. */ ++ set_bit(HSO_NET_RUNNING, &odev->flags); ++ hso_start_net_device(odev->parent); ++ ++ /* Tell the kernel we are ready to start receiving from it */ ++ netif_start_queue(net); ++ ++ return 0; ++} ++ ++/* called when interface is brought down by ifconfig */ ++static int hso_net_close(struct net_device *net) ++{ ++ struct hso_net *odev = netdev_priv(net); ++ ++ /* we don't need the queue anymore */ ++ netif_stop_queue(net); ++ /* no longer running */ ++ clear_bit(HSO_NET_RUNNING, &odev->flags); ++ ++ hso_stop_net_device(odev->parent); ++ ++ /* done */ ++ return 0; ++} ++ ++/* USB tells is xmit done, we should start the netqueue again */ ++static void write_bulk_callback(struct urb *urb) ++{ ++ struct hso_net *odev = urb->context; ++ int status = urb->status; ++ ++ /* Sanity check */ ++ if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { ++ dev_err(&urb->dev->dev, "%s: device not running\n", __func__); ++ return; ++ } ++ ++ /* Do we still have a valid kernel network device? */ ++ if (!netif_device_present(odev->net)) { ++ dev_err(&urb->dev->dev, "%s: net device not present\n", ++ __func__); ++ return; ++ } ++ ++ /* log status, but don't act on it, we don't need to resubmit anything ++ * anyhow */ ++ if (status) ++ handle_usb_error(status, __func__, odev->parent); ++ ++ hso_put_activity(odev->parent); ++ ++ /* Tell the network interface we are ready for another frame */ ++ netif_wake_queue(odev->net); ++} ++ ++/* called by kernel when we need to transmit a packet */ ++static netdev_tx_t hso_net_start_xmit(struct sk_buff *skb, ++ struct net_device *net) ++{ ++ struct hso_net *odev = netdev_priv(net); ++ int result; ++ ++ /* Tell the kernel, "No more frames 'til we are done with this one." */ ++ netif_stop_queue(net); ++ if (hso_get_activity(odev->parent) == -EAGAIN) { ++ odev->skb_tx_buf = skb; ++ return NETDEV_TX_OK; ++ } ++ ++ /* log if asked */ ++ DUMP1(skb->data, skb->len); ++ /* Copy it from kernel memory to OUR memory */ ++ memcpy(odev->mux_bulk_tx_buf, skb->data, skb->len); ++ D1("len: %d/%d", skb->len, MUX_BULK_TX_BUF_SIZE); ++ ++ /* Fill in the URB for shipping it out. */ ++ usb_fill_bulk_urb(odev->mux_bulk_tx_urb, ++ odev->parent->usb, ++ usb_sndbulkpipe(odev->parent->usb, ++ odev->out_endp-> ++ bEndpointAddress & 0x7F), ++ odev->mux_bulk_tx_buf, skb->len, write_bulk_callback, ++ odev); ++ ++ /* Deal with the Zero Length packet problem, I hope */ ++ odev->mux_bulk_tx_urb->transfer_flags |= URB_ZERO_PACKET; ++ ++ /* Send the URB on its merry way. */ ++ result = usb_submit_urb(odev->mux_bulk_tx_urb, GFP_ATOMIC); ++ if (result) { ++ dev_warn(&odev->parent->interface->dev, ++ "failed mux_bulk_tx_urb %d\n", result); ++ net->stats.tx_errors++; ++ netif_start_queue(net); ++ } else { ++ net->stats.tx_packets++; ++ net->stats.tx_bytes += skb->len; ++ } ++ dev_kfree_skb(skb); ++ /* we're done */ ++ return NETDEV_TX_OK; ++} ++ ++static const struct ethtool_ops ops = { ++ .get_link = ethtool_op_get_link ++}; ++ ++/* called when a packet did not ack after watchdogtimeout */ ++static void hso_net_tx_timeout(struct net_device *net) ++{ ++ struct hso_net *odev = netdev_priv(net); ++ ++ if (!odev) ++ return; ++ ++ /* Tell syslog we are hosed. */ ++ dev_warn(&net->dev, "Tx timed out.\n"); ++ ++ /* Tear the waiting frame off the list */ ++ if (odev->mux_bulk_tx_urb && ++ (odev->mux_bulk_tx_urb->status == -EINPROGRESS)) ++ usb_unlink_urb(odev->mux_bulk_tx_urb); ++ ++ /* Update statistics */ ++ net->stats.tx_errors++; ++} ++ ++/* make a real packet from the received USB buffer */ ++static void packetizeRx(struct hso_net *odev, unsigned char *ip_pkt, ++ unsigned int count, unsigned char is_eop) ++{ ++ unsigned short temp_bytes; ++ unsigned short buffer_offset = 0; ++ unsigned short frame_len; ++ unsigned char *tmp_rx_buf; ++ ++ /* log if needed */ ++ D1("Rx %d bytes", count); ++ DUMP(ip_pkt, min(128, (int)count)); ++ ++ while (count) { ++ switch (odev->rx_parse_state) { ++ case WAIT_IP: ++ /* waiting for IP header. */ ++ /* wanted bytes - size of ip header */ ++ temp_bytes = ++ (count < ++ odev->rx_buf_missing) ? count : odev-> ++ rx_buf_missing; ++ ++ memcpy(((unsigned char *)(&odev->rx_ip_hdr)) + ++ odev->rx_buf_size, ip_pkt + buffer_offset, ++ temp_bytes); ++ ++ odev->rx_buf_size += temp_bytes; ++ buffer_offset += temp_bytes; ++ odev->rx_buf_missing -= temp_bytes; ++ count -= temp_bytes; ++ ++ if (!odev->rx_buf_missing) { ++ /* header is complete allocate an sk_buffer and ++ * continue to WAIT_DATA */ ++ frame_len = ntohs(odev->rx_ip_hdr.tot_len); ++ ++ if ((frame_len > DEFAULT_MRU) || ++ (frame_len < sizeof(struct iphdr))) { ++ dev_err(&odev->net->dev, ++ "Invalid frame (%d) length\n", ++ frame_len); ++ odev->rx_parse_state = WAIT_SYNC; ++ continue; ++ } ++ /* Allocate an sk_buff */ ++ odev->skb_rx_buf = netdev_alloc_skb(odev->net, ++ frame_len); ++ if (!odev->skb_rx_buf) { ++ /* We got no receive buffer. */ ++ D1("could not allocate memory"); ++ odev->rx_parse_state = WAIT_SYNC; ++ continue; ++ } ++ ++ /* Copy what we got so far. make room for iphdr ++ * after tail. */ ++ tmp_rx_buf = ++ skb_put(odev->skb_rx_buf, ++ sizeof(struct iphdr)); ++ memcpy(tmp_rx_buf, (char *)&(odev->rx_ip_hdr), ++ sizeof(struct iphdr)); ++ ++ /* ETH_HLEN */ ++ odev->rx_buf_size = sizeof(struct iphdr); ++ ++ /* Filip actually use .tot_len */ ++ odev->rx_buf_missing = ++ frame_len - sizeof(struct iphdr); ++ odev->rx_parse_state = WAIT_DATA; ++ } ++ break; ++ ++ case WAIT_DATA: ++ temp_bytes = (count < odev->rx_buf_missing) ++ ? count : odev->rx_buf_missing; ++ ++ /* Copy the rest of the bytes that are left in the ++ * buffer into the waiting sk_buf. */ ++ /* Make room for temp_bytes after tail. */ ++ tmp_rx_buf = skb_put(odev->skb_rx_buf, temp_bytes); ++ memcpy(tmp_rx_buf, ip_pkt + buffer_offset, temp_bytes); ++ ++ odev->rx_buf_missing -= temp_bytes; ++ count -= temp_bytes; ++ buffer_offset += temp_bytes; ++ odev->rx_buf_size += temp_bytes; ++ if (!odev->rx_buf_missing) { ++ /* Packet is complete. Inject into stack. */ ++ /* We have IP packet here */ ++ odev->skb_rx_buf->protocol = cpu_to_be16(ETH_P_IP); ++ skb_reset_mac_header(odev->skb_rx_buf); ++ ++ /* Ship it off to the kernel */ ++ netif_rx(odev->skb_rx_buf); ++ /* No longer our buffer. */ ++ odev->skb_rx_buf = NULL; ++ ++ /* update out statistics */ ++ odev->net->stats.rx_packets++; ++ ++ odev->net->stats.rx_bytes += odev->rx_buf_size; ++ ++ odev->rx_buf_size = 0; ++ odev->rx_buf_missing = sizeof(struct iphdr); ++ odev->rx_parse_state = WAIT_IP; ++ } ++ break; ++ ++ case WAIT_SYNC: ++ D1(" W_S"); ++ count = 0; ++ break; ++ default: ++ D1(" "); ++ count--; ++ break; ++ } ++ } ++ ++ /* Recovery mechanism for WAIT_SYNC state. */ ++ if (is_eop) { ++ if (odev->rx_parse_state == WAIT_SYNC) { ++ odev->rx_parse_state = WAIT_IP; ++ odev->rx_buf_size = 0; ++ odev->rx_buf_missing = sizeof(struct iphdr); ++ } ++ } ++} ++ ++static void fix_crc_bug(struct urb *urb, __le16 max_packet_size) ++{ ++ static const u8 crc_check[4] = { 0xDE, 0xAD, 0xBE, 0xEF }; ++ u32 rest = urb->actual_length % le16_to_cpu(max_packet_size); ++ ++ if (((rest == 5) || (rest == 6)) && ++ !memcmp(((u8 *)urb->transfer_buffer) + urb->actual_length - 4, ++ crc_check, 4)) { ++ urb->actual_length -= 4; ++ } ++} ++ ++/* Moving data from usb to kernel (in interrupt state) */ ++static void read_bulk_callback(struct urb *urb) ++{ ++ struct hso_net *odev = urb->context; ++ struct net_device *net; ++ int result; ++ int status = urb->status; ++ ++ /* is al ok? (Filip: Who's Al ?) */ ++ if (status) { ++ handle_usb_error(status, __func__, odev->parent); ++ return; ++ } ++ ++ /* Sanity check */ ++ if (!odev || !test_bit(HSO_NET_RUNNING, &odev->flags)) { ++ D1("BULK IN callback but driver is not active!"); ++ return; ++ } ++ usb_mark_last_busy(urb->dev); ++ ++ net = odev->net; ++ ++ if (!netif_device_present(net)) { ++ /* Somebody killed our network interface... */ ++ return; ++ } ++ ++ if (odev->parent->port_spec & HSO_INFO_CRC_BUG) ++ fix_crc_bug(urb, odev->in_endp->wMaxPacketSize); ++ ++ /* do we even have a packet? */ ++ if (urb->actual_length) { ++ /* Handle the IP stream, add header and push it onto network ++ * stack if the packet is complete. */ ++ spin_lock(&odev->net_lock); ++ packetizeRx(odev, urb->transfer_buffer, urb->actual_length, ++ (urb->transfer_buffer_length > ++ urb->actual_length) ? 1 : 0); ++ spin_unlock(&odev->net_lock); ++ } ++ ++ /* We are done with this URB, resubmit it. Prep the USB to wait for ++ * another frame. Reuse same as received. */ ++ usb_fill_bulk_urb(urb, ++ odev->parent->usb, ++ usb_rcvbulkpipe(odev->parent->usb, ++ odev->in_endp-> ++ bEndpointAddress & 0x7F), ++ urb->transfer_buffer, MUX_BULK_RX_BUF_SIZE, ++ read_bulk_callback, odev); ++ ++ /* Give this to the USB subsystem so it can tell us when more data ++ * arrives. */ ++ result = usb_submit_urb(urb, GFP_ATOMIC); ++ if (result) ++ dev_warn(&odev->parent->interface->dev, ++ "%s failed submit mux_bulk_rx_urb %d\n", __func__, ++ result); ++} ++ ++/* Serial driver functions */ ++ ++static void hso_init_termios(struct ktermios *termios) ++{ ++ /* ++ * The default requirements for this device are: ++ */ ++ termios->c_iflag &= ++ ~(IGNBRK /* disable ignore break */ ++ | BRKINT /* disable break causes interrupt */ ++ | PARMRK /* disable mark parity errors */ ++ | ISTRIP /* disable clear high bit of input characters */ ++ | INLCR /* disable translate NL to CR */ ++ | IGNCR /* disable ignore CR */ ++ | ICRNL /* disable translate CR to NL */ ++ | IXON); /* disable enable XON/XOFF flow control */ ++ ++ /* disable postprocess output characters */ ++ termios->c_oflag &= ~OPOST; ++ ++ termios->c_lflag &= ++ ~(ECHO /* disable echo input characters */ ++ | ECHONL /* disable echo new line */ ++ | ICANON /* disable erase, kill, werase, and rprnt ++ special characters */ ++ | ISIG /* disable interrupt, quit, and suspend special ++ characters */ ++ | IEXTEN); /* disable non-POSIX special characters */ ++ ++ termios->c_cflag &= ++ ~(CSIZE /* no size */ ++ | PARENB /* disable parity bit */ ++ | CBAUD /* clear current baud rate */ ++ | CBAUDEX); /* clear current buad rate */ ++ ++ termios->c_cflag |= CS8; /* character size 8 bits */ ++ ++ /* baud rate 115200 */ ++ tty_termios_encode_baud_rate(termios, 115200, 115200); ++} ++ ++static void _hso_serial_set_termios(struct tty_struct *tty, ++ struct ktermios *old) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ ++ if (!serial) { ++ printk(KERN_ERR "%s: no tty structures", __func__); ++ return; ++ } ++ ++ D4("port %d", serial->minor); ++ ++ /* ++ * Fix up unsupported bits ++ */ ++ tty->termios.c_iflag &= ~IXON; /* disable enable XON/XOFF flow control */ ++ ++ tty->termios.c_cflag &= ++ ~(CSIZE /* no size */ ++ | PARENB /* disable parity bit */ ++ | CBAUD /* clear current baud rate */ ++ | CBAUDEX); /* clear current buad rate */ ++ ++ tty->termios.c_cflag |= CS8; /* character size 8 bits */ ++ ++ /* baud rate 115200 */ ++ tty_encode_baud_rate(tty, 115200, 115200); ++} ++ ++static void hso_resubmit_rx_bulk_urb(struct hso_serial *serial, struct urb *urb) ++{ ++ int result; ++ /* We are done with this URB, resubmit it. Prep the USB to wait for ++ * another frame */ ++ usb_fill_bulk_urb(urb, serial->parent->usb, ++ usb_rcvbulkpipe(serial->parent->usb, ++ serial->in_endp-> ++ bEndpointAddress & 0x7F), ++ urb->transfer_buffer, serial->rx_data_length, ++ hso_std_serial_read_bulk_callback, serial); ++ /* Give this to the USB subsystem so it can tell us when more data ++ * arrives. */ ++ result = usb_submit_urb(urb, GFP_ATOMIC); ++ if (result) { ++ dev_err(&urb->dev->dev, "%s failed submit serial rx_urb %d\n", ++ __func__, result); ++ } ++} ++ ++ ++ ++ ++static void put_rxbuf_data_and_resubmit_bulk_urb(struct hso_serial *serial) ++{ ++ int count; ++ struct urb *curr_urb; ++ ++ while (serial->rx_urb_filled[serial->curr_rx_urb_idx]) { ++ curr_urb = serial->rx_urb[serial->curr_rx_urb_idx]; ++ count = put_rxbuf_data(curr_urb, serial); ++ if (count == -1) ++ return; ++ if (count == 0) { ++ serial->curr_rx_urb_idx++; ++ if (serial->curr_rx_urb_idx >= serial->num_rx_urbs) ++ serial->curr_rx_urb_idx = 0; ++ hso_resubmit_rx_bulk_urb(serial, curr_urb); ++ } ++ } ++} ++ ++static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial) ++{ ++ int count = 0; ++ struct urb *urb; ++ ++ urb = serial->rx_urb[0]; ++ if (atomic_read(&serial->port.count) > 0) { ++ count = put_rxbuf_data(urb, serial); ++ if (count == -1) ++ return; ++ } ++ /* Re issue a read as long as we receive data. */ ++ ++ if (count == 0 && ((urb->actual_length != 0) || ++ (serial->rx_state == RX_PENDING))) { ++ serial->rx_state = RX_SENT; ++ hso_mux_serial_read(serial); ++ } else ++ serial->rx_state = RX_IDLE; ++} ++ ++ ++/* read callback for Diag and CS port */ ++static void hso_std_serial_read_bulk_callback(struct urb *urb) ++{ ++ struct hso_serial *serial = urb->context; ++ int status = urb->status; ++ ++ D4("\n--- Got serial_read_bulk callback %02x ---", status); ++ ++ /* sanity check */ ++ if (!serial) { ++ D1("serial == NULL"); ++ return; ++ } ++ if (status) { ++ handle_usb_error(status, __func__, serial->parent); ++ return; ++ } ++ ++ D1("Actual length = %d\n", urb->actual_length); ++ DUMP1(urb->transfer_buffer, urb->actual_length); ++ ++ /* Anyone listening? */ ++ if (atomic_read(&serial->port.count) == 0) ++ return; ++ ++ if (serial->parent->port_spec & HSO_INFO_CRC_BUG) ++ fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); ++ /* Valid data, handle RX data */ ++ spin_lock(&serial->serial_lock); ++ serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; ++ put_rxbuf_data_and_resubmit_bulk_urb(serial); ++ spin_unlock(&serial->serial_lock); ++} ++ ++/* ++ * This needs to be a tasklet otherwise we will ++ * end up recursively calling this function. ++ */ ++static void hso_unthrottle_tasklet(struct hso_serial *serial) ++{ ++ unsigned long flags; ++ ++ spin_lock_irqsave(&serial->serial_lock, flags); ++ if ((serial->parent->port_spec & HSO_INTF_MUX)) ++ put_rxbuf_data_and_resubmit_ctrl_urb(serial); ++ else ++ put_rxbuf_data_and_resubmit_bulk_urb(serial); ++ spin_unlock_irqrestore(&serial->serial_lock, flags); ++} ++ ++static void hso_unthrottle(struct tty_struct *tty) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ ++ tasklet_hi_schedule(&serial->unthrottle_tasklet); ++} ++ ++/* open the requested serial port */ ++static int hso_serial_open(struct tty_struct *tty, struct file *filp) ++{ ++ struct hso_serial *serial = get_serial_by_index(tty->index); ++ int result; ++ ++ /* sanity check */ ++ if (serial == NULL || serial->magic != HSO_SERIAL_MAGIC) { ++ WARN_ON(1); ++ tty->driver_data = NULL; ++ D1("Failed to open port"); ++ return -ENODEV; ++ } ++ ++ mutex_lock(&serial->parent->mutex); ++ result = usb_autopm_get_interface(serial->parent->interface); ++ if (result < 0) ++ goto err_out; ++ ++ D1("Opening %d", serial->minor); ++ ++ /* setup */ ++ tty->driver_data = serial; ++ tty_port_tty_set(&serial->port, tty); ++ ++ /* check for port already opened, if not set the termios */ ++ if (atomic_inc_return(&serial->port.count) == 1) { ++ serial->rx_state = RX_IDLE; ++ /* Force default termio settings */ ++ _hso_serial_set_termios(tty, NULL); ++ tasklet_init(&serial->unthrottle_tasklet, ++ (void (*)(unsigned long))hso_unthrottle_tasklet, ++ (unsigned long)serial); ++ result = hso_start_serial_device(serial->parent, GFP_KERNEL); ++ if (result) { ++ hso_stop_serial_device(serial->parent); ++ atomic_dec(&serial->port.count); ++ } else { ++ kref_get(&serial->parent->ref); ++ } ++ } else { ++ D1("Port was already open"); ++ } ++ ++ usb_autopm_put_interface(serial->parent->interface); ++ ++ /* done */ ++ if (result) ++ hso_serial_tiocmset(tty, TIOCM_RTS | TIOCM_DTR, 0); ++err_out: ++ mutex_unlock(&serial->parent->mutex); ++ return result; ++} ++ ++/* close the requested serial port */ ++static void hso_serial_close(struct tty_struct *tty, struct file *filp) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ u8 usb_gone; ++ ++ D1("Closing serial port"); ++ ++ /* Open failed, no close cleanup required */ ++ if (serial == NULL) ++ return; ++ ++ mutex_lock(&serial->parent->mutex); ++ usb_gone = serial->parent->usb_gone; ++ ++ if (!usb_gone) ++ usb_autopm_get_interface(serial->parent->interface); ++ ++ /* reset the rts and dtr */ ++ /* do the actual close */ ++ atomic_dec(&serial->port.count); ++ ++ if (atomic_read(&serial->port.count) <= 0) { ++ atomic_set(&serial->port.count, 0); ++ tty_port_tty_set(&serial->port, NULL); ++ if (!usb_gone) ++ hso_stop_serial_device(serial->parent); ++ tasklet_kill(&serial->unthrottle_tasklet); ++ } ++ ++ if (!usb_gone) ++ usb_autopm_put_interface(serial->parent->interface); ++ ++ mutex_unlock(&serial->parent->mutex); ++} ++ ++/* close the requested serial port */ ++static int hso_serial_write(struct tty_struct *tty, const unsigned char *buf, ++ int count) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ int space, tx_bytes; ++ unsigned long flags; ++ ++ /* sanity check */ ++ if (serial == NULL) { ++ printk(KERN_ERR "%s: serial is NULL\n", __func__); ++ return -ENODEV; ++ } ++ ++ spin_lock_irqsave(&serial->serial_lock, flags); ++ ++ space = serial->tx_data_length - serial->tx_buffer_count; ++ tx_bytes = (count < space) ? count : space; ++ ++ if (!tx_bytes) ++ goto out; ++ ++ memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); ++ serial->tx_buffer_count += tx_bytes; ++ ++out: ++ spin_unlock_irqrestore(&serial->serial_lock, flags); ++ ++ hso_kick_transmit(serial); ++ /* done */ ++ return tx_bytes; ++} ++ ++/* how much room is there for writing */ ++static int hso_serial_write_room(struct tty_struct *tty) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ int room; ++ unsigned long flags; ++ ++ spin_lock_irqsave(&serial->serial_lock, flags); ++ room = serial->tx_data_length - serial->tx_buffer_count; ++ spin_unlock_irqrestore(&serial->serial_lock, flags); ++ ++ /* return free room */ ++ return room; ++} ++ ++static void hso_serial_cleanup(struct tty_struct *tty) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ ++ if (!serial) ++ return; ++ ++ kref_put(&serial->parent->ref, hso_serial_ref_free); ++} ++ ++/* setup the term */ ++static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ unsigned long flags; ++ ++ if (old) ++ D5("Termios called with: cflags new[%d] - old[%d]", ++ tty->termios.c_cflag, old->c_cflag); ++ ++ /* the actual setup */ ++ spin_lock_irqsave(&serial->serial_lock, flags); ++ if (atomic_read(&serial->port.count)) ++ _hso_serial_set_termios(tty, old); ++ else ++ tty->termios = *old; ++ spin_unlock_irqrestore(&serial->serial_lock, flags); ++ ++ /* done */ ++} ++ ++/* how many characters in the buffer */ ++static int hso_serial_chars_in_buffer(struct tty_struct *tty) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ int chars; ++ unsigned long flags; ++ ++ /* sanity check */ ++ if (serial == NULL) ++ return 0; ++ ++ spin_lock_irqsave(&serial->serial_lock, flags); ++ chars = serial->tx_buffer_count; ++ spin_unlock_irqrestore(&serial->serial_lock, flags); ++ ++ return chars; ++} ++static int tiocmget_submit_urb(struct hso_serial *serial, ++ struct hso_tiocmget *tiocmget, ++ struct usb_device *usb) ++{ ++ int result; ++ ++ if (serial->parent->usb_gone) ++ return -ENODEV; ++ usb_fill_int_urb(tiocmget->urb, usb, ++ usb_rcvintpipe(usb, ++ tiocmget->endp-> ++ bEndpointAddress & 0x7F), ++ &tiocmget->serial_state_notification, ++ sizeof(struct hso_serial_state_notification), ++ tiocmget_intr_callback, serial, ++ tiocmget->endp->bInterval); ++ result = usb_submit_urb(tiocmget->urb, GFP_ATOMIC); ++ if (result) { ++ dev_warn(&usb->dev, "%s usb_submit_urb failed %d\n", __func__, ++ result); ++ } ++ return result; ++ ++} ++ ++static void tiocmget_intr_callback(struct urb *urb) ++{ ++ struct hso_serial *serial = urb->context; ++ struct hso_tiocmget *tiocmget; ++ int status = urb->status; ++ u16 UART_state_bitmap, prev_UART_state_bitmap; ++ struct uart_icount *icount; ++ struct hso_serial_state_notification *serial_state_notification; ++ struct usb_device *usb; ++ struct usb_interface *interface; ++ int if_num; ++ ++ /* Sanity checks */ ++ if (!serial) ++ return; ++ if (status) { ++ handle_usb_error(status, __func__, serial->parent); ++ return; ++ } ++ ++ /* tiocmget is only supported on HSO_PORT_MODEM */ ++ tiocmget = serial->tiocmget; ++ if (!tiocmget) ++ return; ++ BUG_ON((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM); ++ ++ usb = serial->parent->usb; ++ interface = serial->parent->interface; ++ ++ if_num = interface->cur_altsetting->desc.bInterfaceNumber; ++ ++ /* wIndex should be the USB interface number of the port to which the ++ * notification applies, which should always be the Modem port. ++ */ ++ serial_state_notification = &tiocmget->serial_state_notification; ++ if (serial_state_notification->bmRequestType != BM_REQUEST_TYPE || ++ serial_state_notification->bNotification != B_NOTIFICATION || ++ le16_to_cpu(serial_state_notification->wValue) != W_VALUE || ++ le16_to_cpu(serial_state_notification->wIndex) != if_num || ++ le16_to_cpu(serial_state_notification->wLength) != W_LENGTH) { ++ dev_warn(&usb->dev, ++ "hso received invalid serial state notification\n"); ++ DUMP(serial_state_notification, ++ sizeof(struct hso_serial_state_notification)); ++ } else { ++ ++ UART_state_bitmap = le16_to_cpu(serial_state_notification-> ++ UART_state_bitmap); ++ prev_UART_state_bitmap = tiocmget->prev_UART_state_bitmap; ++ icount = &tiocmget->icount; ++ spin_lock(&serial->serial_lock); ++ if ((UART_state_bitmap & B_OVERRUN) != ++ (prev_UART_state_bitmap & B_OVERRUN)) ++ icount->parity++; ++ if ((UART_state_bitmap & B_PARITY) != ++ (prev_UART_state_bitmap & B_PARITY)) ++ icount->parity++; ++ if ((UART_state_bitmap & B_FRAMING) != ++ (prev_UART_state_bitmap & B_FRAMING)) ++ icount->frame++; ++ if ((UART_state_bitmap & B_RING_SIGNAL) && ++ !(prev_UART_state_bitmap & B_RING_SIGNAL)) ++ icount->rng++; ++ if ((UART_state_bitmap & B_BREAK) != ++ (prev_UART_state_bitmap & B_BREAK)) ++ icount->brk++; ++ if ((UART_state_bitmap & B_TX_CARRIER) != ++ (prev_UART_state_bitmap & B_TX_CARRIER)) ++ icount->dsr++; ++ if ((UART_state_bitmap & B_RX_CARRIER) != ++ (prev_UART_state_bitmap & B_RX_CARRIER)) ++ icount->dcd++; ++ tiocmget->prev_UART_state_bitmap = UART_state_bitmap; ++ spin_unlock(&serial->serial_lock); ++ tiocmget->intr_completed = 1; ++ wake_up_interruptible(&tiocmget->waitq); ++ } ++ memset(serial_state_notification, 0, ++ sizeof(struct hso_serial_state_notification)); ++ tiocmget_submit_urb(serial, ++ tiocmget, ++ serial->parent->usb); ++} ++ ++/* ++ * next few functions largely stolen from drivers/serial/serial_core.c ++ */ ++/* Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change ++ * - mask passed in arg for lines of interest ++ * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) ++ * Caller should use TIOCGICOUNT to see which one it was ++ */ ++static int ++hso_wait_modem_status(struct hso_serial *serial, unsigned long arg) ++{ ++ DECLARE_WAITQUEUE(wait, current); ++ struct uart_icount cprev, cnow; ++ struct hso_tiocmget *tiocmget; ++ int ret; ++ ++ tiocmget = serial->tiocmget; ++ if (!tiocmget) ++ return -ENOENT; ++ /* ++ * note the counters on entry ++ */ ++ spin_lock_irq(&serial->serial_lock); ++ memcpy(&cprev, &tiocmget->icount, sizeof(struct uart_icount)); ++ spin_unlock_irq(&serial->serial_lock); ++ add_wait_queue(&tiocmget->waitq, &wait); ++ for (;;) { ++ spin_lock_irq(&serial->serial_lock); ++ memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); ++ spin_unlock_irq(&serial->serial_lock); ++ set_current_state(TASK_INTERRUPTIBLE); ++ if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || ++ ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || ++ ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd))) { ++ ret = 0; ++ break; ++ } ++ schedule(); ++ /* see if a signal did it */ ++ if (signal_pending(current)) { ++ ret = -ERESTARTSYS; ++ break; ++ } ++ cprev = cnow; ++ } ++ __set_current_state(TASK_RUNNING); ++ remove_wait_queue(&tiocmget->waitq, &wait); ++ ++ return ret; ++} ++ ++/* ++ * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) ++ * Return: write counters to the user passed counter struct ++ * NB: both 1->0 and 0->1 transitions are counted except for ++ * RI where only 0->1 is counted. ++ */ ++static int hso_get_count(struct tty_struct *tty, ++ struct serial_icounter_struct *icount) ++{ ++ struct uart_icount cnow; ++ struct hso_serial *serial = tty->driver_data; ++ struct hso_tiocmget *tiocmget = serial->tiocmget; ++ ++ memset(icount, 0, sizeof(struct serial_icounter_struct)); ++ ++ if (!tiocmget) ++ return -ENOENT; ++ spin_lock_irq(&serial->serial_lock); ++ memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); ++ spin_unlock_irq(&serial->serial_lock); ++ ++ icount->cts = cnow.cts; ++ icount->dsr = cnow.dsr; ++ icount->rng = cnow.rng; ++ icount->dcd = cnow.dcd; ++ icount->rx = cnow.rx; ++ icount->tx = cnow.tx; ++ icount->frame = cnow.frame; ++ icount->overrun = cnow.overrun; ++ icount->parity = cnow.parity; ++ icount->brk = cnow.brk; ++ icount->buf_overrun = cnow.buf_overrun; ++ ++ return 0; ++} ++ ++ ++static int hso_serial_tiocmget(struct tty_struct *tty) ++{ ++ int retval; ++ struct hso_serial *serial = tty->driver_data; ++ struct hso_tiocmget *tiocmget; ++ u16 UART_state_bitmap; ++ ++ /* sanity check */ ++ if (!serial) { ++ D1("no tty structures"); ++ return -EINVAL; ++ } ++ spin_lock_irq(&serial->serial_lock); ++ retval = ((serial->rts_state) ? TIOCM_RTS : 0) | ++ ((serial->dtr_state) ? TIOCM_DTR : 0); ++ tiocmget = serial->tiocmget; ++ if (tiocmget) { ++ ++ UART_state_bitmap = le16_to_cpu( ++ tiocmget->prev_UART_state_bitmap); ++ if (UART_state_bitmap & B_RING_SIGNAL) ++ retval |= TIOCM_RNG; ++ if (UART_state_bitmap & B_RX_CARRIER) ++ retval |= TIOCM_CD; ++ if (UART_state_bitmap & B_TX_CARRIER) ++ retval |= TIOCM_DSR; ++ } ++ spin_unlock_irq(&serial->serial_lock); ++ return retval; ++} ++ ++static int hso_serial_tiocmset(struct tty_struct *tty, ++ unsigned int set, unsigned int clear) ++{ ++ int val = 0; ++ unsigned long flags; ++ int if_num; ++ struct hso_serial *serial = tty->driver_data; ++ struct usb_interface *interface; ++ ++ /* sanity check */ ++ if (!serial) { ++ D1("no tty structures"); ++ return -EINVAL; ++ } ++ ++ if ((serial->parent->port_spec & HSO_PORT_MASK) != HSO_PORT_MODEM) ++ return -EINVAL; ++ ++ interface = serial->parent->interface; ++ if_num = interface->cur_altsetting->desc.bInterfaceNumber; ++ ++ spin_lock_irqsave(&serial->serial_lock, flags); ++ if (set & TIOCM_RTS) ++ serial->rts_state = 1; ++ if (set & TIOCM_DTR) ++ serial->dtr_state = 1; ++ ++ if (clear & TIOCM_RTS) ++ serial->rts_state = 0; ++ if (clear & TIOCM_DTR) ++ serial->dtr_state = 0; ++ ++ if (serial->dtr_state) ++ val |= 0x01; ++ if (serial->rts_state) ++ val |= 0x02; ++ ++ spin_unlock_irqrestore(&serial->serial_lock, flags); ++ ++ return usb_control_msg(serial->parent->usb, ++ usb_rcvctrlpipe(serial->parent->usb, 0), 0x22, ++ 0x21, val, if_num, NULL, 0, ++ USB_CTRL_SET_TIMEOUT); ++} ++ ++static int hso_serial_ioctl(struct tty_struct *tty, ++ unsigned int cmd, unsigned long arg) ++{ ++ struct hso_serial *serial = tty->driver_data; ++ int ret = 0; ++ D4("IOCTL cmd: %d, arg: %ld", cmd, arg); ++ ++ if (!serial) ++ return -ENODEV; ++ switch (cmd) { ++ case TIOCMIWAIT: ++ ret = hso_wait_modem_status(serial, arg); ++ break; ++ default: ++ ret = -ENOIOCTLCMD; ++ break; ++ } ++ return ret; ++} ++ ++ ++/* starts a transmit */ ++static void hso_kick_transmit(struct hso_serial *serial) ++{ ++ u8 *temp; ++ unsigned long flags; ++ int res; ++ ++ spin_lock_irqsave(&serial->serial_lock, flags); ++ if (!serial->tx_buffer_count) ++ goto out; ++ ++ if (serial->tx_urb_used) ++ goto out; ++ ++ /* Wakeup USB interface if necessary */ ++ if (hso_get_activity(serial->parent) == -EAGAIN) ++ goto out; ++ ++ /* Switch pointers around to avoid memcpy */ ++ temp = serial->tx_buffer; ++ serial->tx_buffer = serial->tx_data; ++ serial->tx_data = temp; ++ serial->tx_data_count = serial->tx_buffer_count; ++ serial->tx_buffer_count = 0; ++ ++ /* If temp is set, it means we switched buffers */ ++ if (temp && serial->write_data) { ++ res = serial->write_data(serial); ++ if (res >= 0) ++ serial->tx_urb_used = 1; ++ } ++out: ++ spin_unlock_irqrestore(&serial->serial_lock, flags); ++} ++ ++/* make a request (for reading and writing data to muxed serial port) */ ++static int mux_device_request(struct hso_serial *serial, u8 type, u16 port, ++ struct urb *ctrl_urb, ++ struct usb_ctrlrequest *ctrl_req, ++ u8 *ctrl_urb_data, u32 size) ++{ ++ int result; ++ int pipe; ++ ++ /* Sanity check */ ++ if (!serial || !ctrl_urb || !ctrl_req) { ++ printk(KERN_ERR "%s: Wrong arguments\n", __func__); ++ return -EINVAL; ++ } ++ ++ /* initialize */ ++ ctrl_req->wValue = 0; ++ ctrl_req->wIndex = cpu_to_le16(hso_port_to_mux(port)); ++ ctrl_req->wLength = cpu_to_le16(size); ++ ++ if (type == USB_CDC_GET_ENCAPSULATED_RESPONSE) { ++ /* Reading command */ ++ ctrl_req->bRequestType = USB_DIR_IN | ++ USB_TYPE_OPTION_VENDOR | ++ USB_RECIP_INTERFACE; ++ ctrl_req->bRequest = USB_CDC_GET_ENCAPSULATED_RESPONSE; ++ pipe = usb_rcvctrlpipe(serial->parent->usb, 0); ++ } else { ++ /* Writing command */ ++ ctrl_req->bRequestType = USB_DIR_OUT | ++ USB_TYPE_OPTION_VENDOR | ++ USB_RECIP_INTERFACE; ++ ctrl_req->bRequest = USB_CDC_SEND_ENCAPSULATED_COMMAND; ++ pipe = usb_sndctrlpipe(serial->parent->usb, 0); ++ } ++ /* syslog */ ++ D2("%s command (%02x) len: %d, port: %d", ++ type == USB_CDC_GET_ENCAPSULATED_RESPONSE ? "Read" : "Write", ++ ctrl_req->bRequestType, ctrl_req->wLength, port); ++ ++ /* Load ctrl urb */ ++ ctrl_urb->transfer_flags = 0; ++ usb_fill_control_urb(ctrl_urb, ++ serial->parent->usb, ++ pipe, ++ (u8 *) ctrl_req, ++ ctrl_urb_data, size, ctrl_callback, serial); ++ /* Send it on merry way */ ++ result = usb_submit_urb(ctrl_urb, GFP_ATOMIC); ++ if (result) { ++ dev_err(&ctrl_urb->dev->dev, ++ "%s failed submit ctrl_urb %d type %d\n", __func__, ++ result, type); ++ return result; ++ } ++ ++ /* done */ ++ return size; ++} ++ ++/* called by intr_callback when read occurs */ ++static int hso_mux_serial_read(struct hso_serial *serial) ++{ ++ if (!serial) ++ return -EINVAL; ++ ++ /* clean data */ ++ memset(serial->rx_data[0], 0, CTRL_URB_RX_SIZE); ++ /* make the request */ ++ ++ if (serial->num_rx_urbs != 1) { ++ dev_err(&serial->parent->interface->dev, ++ "ERROR: mux'd reads with multiple buffers " ++ "not possible\n"); ++ return 0; ++ } ++ return mux_device_request(serial, ++ USB_CDC_GET_ENCAPSULATED_RESPONSE, ++ serial->parent->port_spec & HSO_PORT_MASK, ++ serial->rx_urb[0], ++ &serial->ctrl_req_rx, ++ serial->rx_data[0], serial->rx_data_length); ++} ++ ++/* used for muxed serial port callback (muxed serial read) */ ++static void intr_callback(struct urb *urb) ++{ ++ struct hso_shared_int *shared_int = urb->context; ++ struct hso_serial *serial; ++ unsigned char *port_req; ++ int status = urb->status; ++ int i; ++ ++ usb_mark_last_busy(urb->dev); ++ ++ /* sanity check */ ++ if (!shared_int) ++ return; ++ ++ /* status check */ ++ if (status) { ++ handle_usb_error(status, __func__, NULL); ++ return; ++ } ++ D4("\n--- Got intr callback 0x%02X ---", status); ++ ++ /* what request? */ ++ port_req = urb->transfer_buffer; ++ D4(" port_req = 0x%.2X\n", *port_req); ++ /* loop over all muxed ports to find the one sending this */ ++ for (i = 0; i < 8; i++) { ++ /* max 8 channels on MUX */ ++ if (*port_req & (1 << i)) { ++ serial = get_serial_by_shared_int_and_type(shared_int, ++ (1 << i)); ++ if (serial != NULL) { ++ D1("Pending read interrupt on port %d\n", i); ++ spin_lock(&serial->serial_lock); ++ if (serial->rx_state == RX_IDLE && ++ atomic_read(&serial->port.count) > 0) { ++ /* Setup and send a ctrl req read on ++ * port i */ ++ if (!serial->rx_urb_filled[0]) { ++ serial->rx_state = RX_SENT; ++ hso_mux_serial_read(serial); ++ } else ++ serial->rx_state = RX_PENDING; ++ } else { ++ D1("Already a read pending on " ++ "port %d or port not open\n", i); ++ } ++ spin_unlock(&serial->serial_lock); ++ } ++ } ++ } ++ /* Resubmit interrupt urb */ ++ hso_mux_submit_intr_urb(shared_int, urb->dev, GFP_ATOMIC); ++} ++ ++/* called for writing to muxed serial port */ ++static int hso_mux_serial_write_data(struct hso_serial *serial) ++{ ++ if (NULL == serial) ++ return -EINVAL; ++ ++ return mux_device_request(serial, ++ USB_CDC_SEND_ENCAPSULATED_COMMAND, ++ serial->parent->port_spec & HSO_PORT_MASK, ++ serial->tx_urb, ++ &serial->ctrl_req_tx, ++ serial->tx_data, serial->tx_data_count); ++} ++ ++/* write callback for Diag and CS port */ ++static void hso_std_serial_write_bulk_callback(struct urb *urb) ++{ ++ struct hso_serial *serial = urb->context; ++ int status = urb->status; ++ ++ /* sanity check */ ++ if (!serial) { ++ D1("serial == NULL"); ++ return; ++ } ++ ++ spin_lock(&serial->serial_lock); ++ serial->tx_urb_used = 0; ++ spin_unlock(&serial->serial_lock); ++ if (status) { ++ handle_usb_error(status, __func__, serial->parent); ++ return; ++ } ++ hso_put_activity(serial->parent); ++ tty_port_tty_wakeup(&serial->port); ++ hso_kick_transmit(serial); ++ ++ D1(" "); ++} ++ ++/* called for writing diag or CS serial port */ ++static int hso_std_serial_write_data(struct hso_serial *serial) ++{ ++ int count = serial->tx_data_count; ++ int result; ++ ++ usb_fill_bulk_urb(serial->tx_urb, ++ serial->parent->usb, ++ usb_sndbulkpipe(serial->parent->usb, ++ serial->out_endp-> ++ bEndpointAddress & 0x7F), ++ serial->tx_data, serial->tx_data_count, ++ hso_std_serial_write_bulk_callback, serial); ++ ++ result = usb_submit_urb(serial->tx_urb, GFP_ATOMIC); ++ if (result) { ++ dev_warn(&serial->parent->usb->dev, ++ "Failed to submit urb - res %d\n", result); ++ return result; ++ } ++ ++ return count; ++} ++ ++/* callback after read or write on muxed serial port */ ++static void ctrl_callback(struct urb *urb) ++{ ++ struct hso_serial *serial = urb->context; ++ struct usb_ctrlrequest *req; ++ int status = urb->status; ++ ++ /* sanity check */ ++ if (!serial) ++ return; ++ ++ spin_lock(&serial->serial_lock); ++ serial->tx_urb_used = 0; ++ spin_unlock(&serial->serial_lock); ++ if (status) { ++ handle_usb_error(status, __func__, serial->parent); ++ return; ++ } ++ ++ /* what request? */ ++ req = (struct usb_ctrlrequest *)(urb->setup_packet); ++ D4("\n--- Got muxed ctrl callback 0x%02X ---", status); ++ D4("Actual length of urb = %d\n", urb->actual_length); ++ DUMP1(urb->transfer_buffer, urb->actual_length); ++ ++ if (req->bRequestType == ++ (USB_DIR_IN | USB_TYPE_OPTION_VENDOR | USB_RECIP_INTERFACE)) { ++ /* response to a read command */ ++ serial->rx_urb_filled[0] = 1; ++ spin_lock(&serial->serial_lock); ++ put_rxbuf_data_and_resubmit_ctrl_urb(serial); ++ spin_unlock(&serial->serial_lock); ++ } else { ++ hso_put_activity(serial->parent); ++ tty_port_tty_wakeup(&serial->port); ++ /* response to a write command */ ++ hso_kick_transmit(serial); ++ } ++} ++ ++/* handle RX data for serial port */ ++static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) ++{ ++ struct tty_struct *tty; ++ int count; ++ ++ /* Sanity check */ ++ if (urb == NULL || serial == NULL) { ++ D1("serial = NULL"); ++ return -2; ++ } ++ ++ tty = tty_port_tty_get(&serial->port); ++ ++ if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { ++ tty_kref_put(tty); ++ return -1; ++ } ++ ++ /* Push data to tty */ ++ D1("data to push to tty"); ++ count = tty_buffer_request_room(&serial->port, urb->actual_length); ++ if (count >= urb->actual_length) { ++ tty_insert_flip_string(&serial->port, urb->transfer_buffer, ++ urb->actual_length); ++ tty_flip_buffer_push(&serial->port); ++ } else { ++ dev_warn(&serial->parent->usb->dev, ++ "dropping data, %d bytes lost\n", urb->actual_length); ++ } ++ ++ tty_kref_put(tty); ++ ++ serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; ++ ++ return 0; ++} ++ ++ ++/* Base driver functions */ ++ ++static void hso_log_port(struct hso_device *hso_dev) ++{ ++ char *port_type; ++ char port_dev[20]; ++ ++ switch (hso_dev->port_spec & HSO_PORT_MASK) { ++ case HSO_PORT_CONTROL: ++ port_type = "Control"; ++ break; ++ case HSO_PORT_APP: ++ port_type = "Application"; ++ break; ++ case HSO_PORT_GPS: ++ port_type = "GPS"; ++ break; ++ case HSO_PORT_GPS_CONTROL: ++ port_type = "GPS control"; ++ break; ++ case HSO_PORT_APP2: ++ port_type = "Application2"; ++ break; ++ case HSO_PORT_PCSC: ++ port_type = "PCSC"; ++ break; ++ case HSO_PORT_DIAG: ++ port_type = "Diagnostic"; ++ break; ++ case HSO_PORT_DIAG2: ++ port_type = "Diagnostic2"; ++ break; ++ case HSO_PORT_MODEM: ++ port_type = "Modem"; ++ break; ++ case HSO_PORT_NETWORK: ++ port_type = "Network"; ++ break; ++ default: ++ port_type = "Unknown"; ++ break; ++ } ++ if ((hso_dev->port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { ++ sprintf(port_dev, "%s", dev2net(hso_dev)->net->name); ++ } else ++ sprintf(port_dev, "/dev/%s%d", tty_filename, ++ dev2ser(hso_dev)->minor); ++ ++ dev_dbg(&hso_dev->interface->dev, "HSO: Found %s port %s\n", ++ port_type, port_dev); ++} ++ ++static int hso_start_net_device(struct hso_device *hso_dev) ++{ ++ int i, result = 0; ++ struct hso_net *hso_net = dev2net(hso_dev); ++ ++ if (!hso_net) ++ return -ENODEV; ++ ++ /* send URBs for all read buffers */ ++ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { ++ ++ /* Prep a receive URB */ ++ usb_fill_bulk_urb(hso_net->mux_bulk_rx_urb_pool[i], ++ hso_dev->usb, ++ usb_rcvbulkpipe(hso_dev->usb, ++ hso_net->in_endp-> ++ bEndpointAddress & 0x7F), ++ hso_net->mux_bulk_rx_buf_pool[i], ++ MUX_BULK_RX_BUF_SIZE, read_bulk_callback, ++ hso_net); ++ ++ /* Put it out there so the device can send us stuff */ ++ result = usb_submit_urb(hso_net->mux_bulk_rx_urb_pool[i], ++ GFP_NOIO); ++ if (result) ++ dev_warn(&hso_dev->usb->dev, ++ "%s failed mux_bulk_rx_urb[%d] %d\n", __func__, ++ i, result); ++ } ++ ++ return result; ++} ++ ++static int hso_stop_net_device(struct hso_device *hso_dev) ++{ ++ int i; ++ struct hso_net *hso_net = dev2net(hso_dev); ++ ++ if (!hso_net) ++ return -ENODEV; ++ ++ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { ++ if (hso_net->mux_bulk_rx_urb_pool[i]) ++ usb_kill_urb(hso_net->mux_bulk_rx_urb_pool[i]); ++ ++ } ++ if (hso_net->mux_bulk_tx_urb) ++ usb_kill_urb(hso_net->mux_bulk_tx_urb); ++ ++ return 0; ++} ++ ++static int hso_start_serial_device(struct hso_device *hso_dev, gfp_t flags) ++{ ++ int i, result = 0; ++ struct hso_serial *serial = dev2ser(hso_dev); ++ ++ if (!serial) ++ return -ENODEV; ++ ++ /* If it is not the MUX port fill in and submit a bulk urb (already ++ * allocated in hso_serial_start) */ ++ if (!(serial->parent->port_spec & HSO_INTF_MUX)) { ++ for (i = 0; i < serial->num_rx_urbs; i++) { ++ usb_fill_bulk_urb(serial->rx_urb[i], ++ serial->parent->usb, ++ usb_rcvbulkpipe(serial->parent->usb, ++ serial->in_endp-> ++ bEndpointAddress & ++ 0x7F), ++ serial->rx_data[i], ++ serial->rx_data_length, ++ hso_std_serial_read_bulk_callback, ++ serial); ++ result = usb_submit_urb(serial->rx_urb[i], flags); ++ if (result) { ++ dev_warn(&serial->parent->usb->dev, ++ "Failed to submit urb - res %d\n", ++ result); ++ break; ++ } ++ } ++ } else { ++ mutex_lock(&serial->shared_int->shared_int_lock); ++ if (!serial->shared_int->use_count) { ++ result = ++ hso_mux_submit_intr_urb(serial->shared_int, ++ hso_dev->usb, flags); ++ } ++ serial->shared_int->use_count++; ++ mutex_unlock(&serial->shared_int->shared_int_lock); ++ } ++ if (serial->tiocmget) ++ tiocmget_submit_urb(serial, ++ serial->tiocmget, ++ serial->parent->usb); ++ return result; ++} ++ ++static int hso_stop_serial_device(struct hso_device *hso_dev) ++{ ++ int i; ++ struct hso_serial *serial = dev2ser(hso_dev); ++ struct hso_tiocmget *tiocmget; ++ ++ if (!serial) ++ return -ENODEV; ++ ++ for (i = 0; i < serial->num_rx_urbs; i++) { ++ if (serial->rx_urb[i]) { ++ usb_kill_urb(serial->rx_urb[i]); ++ serial->rx_urb_filled[i] = 0; ++ } ++ } ++ serial->curr_rx_urb_idx = 0; ++ ++ if (serial->tx_urb) ++ usb_kill_urb(serial->tx_urb); ++ ++ if (serial->shared_int) { ++ mutex_lock(&serial->shared_int->shared_int_lock); ++ if (serial->shared_int->use_count && ++ (--serial->shared_int->use_count == 0)) { ++ struct urb *urb; ++ ++ urb = serial->shared_int->shared_intr_urb; ++ if (urb) ++ usb_kill_urb(urb); ++ } ++ mutex_unlock(&serial->shared_int->shared_int_lock); ++ } ++ tiocmget = serial->tiocmget; ++ if (tiocmget) { ++ wake_up_interruptible(&tiocmget->waitq); ++ usb_kill_urb(tiocmget->urb); ++ } ++ ++ return 0; ++} ++ ++static void hso_serial_tty_unregister(struct hso_serial *serial) ++{ ++ tty_unregister_device(tty_drv, serial->minor); ++} ++ ++static void hso_serial_common_free(struct hso_serial *serial) ++{ ++ int i; ++ ++ for (i = 0; i < serial->num_rx_urbs; i++) { ++ /* unlink and free RX URB */ ++ usb_free_urb(serial->rx_urb[i]); ++ /* free the RX buffer */ ++ kfree(serial->rx_data[i]); ++ } ++ ++ /* unlink and free TX URB */ ++ usb_free_urb(serial->tx_urb); ++ kfree(serial->tx_buffer); ++ kfree(serial->tx_data); ++ tty_port_destroy(&serial->port); ++} ++ ++static int hso_serial_common_create(struct hso_serial *serial, int num_urbs, ++ int rx_size, int tx_size) ++{ ++ struct device *dev; ++ int minor; ++ int i; ++ ++ tty_port_init(&serial->port); ++ ++ minor = get_free_serial_index(); ++ if (minor < 0) ++ goto exit; ++ ++ /* register our minor number */ ++ serial->parent->dev = tty_port_register_device_attr(&serial->port, ++ tty_drv, minor, &serial->parent->interface->dev, ++ serial->parent, hso_serial_dev_groups); ++ dev = serial->parent->dev; ++ ++ /* fill in specific data for later use */ ++ serial->minor = minor; ++ serial->magic = HSO_SERIAL_MAGIC; ++ spin_lock_init(&serial->serial_lock); ++ serial->num_rx_urbs = num_urbs; ++ ++ /* RX, allocate urb and initialize */ ++ ++ /* prepare our RX buffer */ ++ serial->rx_data_length = rx_size; ++ for (i = 0; i < serial->num_rx_urbs; i++) { ++ serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); ++ if (!serial->rx_urb[i]) { ++ dev_err(dev, "Could not allocate urb?\n"); ++ goto exit; ++ } ++ serial->rx_urb[i]->transfer_buffer = NULL; ++ serial->rx_urb[i]->transfer_buffer_length = 0; ++ serial->rx_data[i] = kzalloc(serial->rx_data_length, ++ GFP_KERNEL); ++ if (!serial->rx_data[i]) ++ goto exit; ++ } ++ ++ /* TX, allocate urb and initialize */ ++ serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!serial->tx_urb) { ++ dev_err(dev, "Could not allocate urb?\n"); ++ goto exit; ++ } ++ serial->tx_urb->transfer_buffer = NULL; ++ serial->tx_urb->transfer_buffer_length = 0; ++ /* prepare our TX buffer */ ++ serial->tx_data_count = 0; ++ serial->tx_buffer_count = 0; ++ serial->tx_data_length = tx_size; ++ serial->tx_data = kzalloc(serial->tx_data_length, GFP_KERNEL); ++ if (!serial->tx_data) ++ goto exit; ++ ++ serial->tx_buffer = kzalloc(serial->tx_data_length, GFP_KERNEL); ++ if (!serial->tx_buffer) ++ goto exit; ++ ++ return 0; ++exit: ++ hso_serial_tty_unregister(serial); ++ hso_serial_common_free(serial); ++ return -1; ++} ++ ++/* Creates a general hso device */ ++static struct hso_device *hso_create_device(struct usb_interface *intf, ++ int port_spec) ++{ ++ struct hso_device *hso_dev; ++ ++ hso_dev = kzalloc(sizeof(*hso_dev), GFP_ATOMIC); ++ if (!hso_dev) ++ return NULL; ++ ++ hso_dev->port_spec = port_spec; ++ hso_dev->usb = interface_to_usbdev(intf); ++ hso_dev->interface = intf; ++ kref_init(&hso_dev->ref); ++ mutex_init(&hso_dev->mutex); ++ ++ INIT_WORK(&hso_dev->async_get_intf, async_get_intf); ++ INIT_WORK(&hso_dev->async_put_intf, async_put_intf); ++ ++ return hso_dev; ++} ++ ++/* Removes a network device in the network device table */ ++static int remove_net_device(struct hso_device *hso_dev) ++{ ++ int i; ++ ++ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { ++ if (network_table[i] == hso_dev) { ++ network_table[i] = NULL; ++ break; ++ } ++ } ++ if (i == HSO_MAX_NET_DEVICES) ++ return -1; ++ return 0; ++} ++ ++/* Frees our network device */ ++static void hso_free_net_device(struct hso_device *hso_dev) ++{ ++ int i; ++ struct hso_net *hso_net = dev2net(hso_dev); ++ ++ if (!hso_net) ++ return; ++ ++ remove_net_device(hso_net->parent); ++ ++ if (hso_net->net) ++ unregister_netdev(hso_net->net); ++ ++ /* start freeing */ ++ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { ++ usb_free_urb(hso_net->mux_bulk_rx_urb_pool[i]); ++ kfree(hso_net->mux_bulk_rx_buf_pool[i]); ++ hso_net->mux_bulk_rx_buf_pool[i] = NULL; ++ } ++ usb_free_urb(hso_net->mux_bulk_tx_urb); ++ kfree(hso_net->mux_bulk_tx_buf); ++ hso_net->mux_bulk_tx_buf = NULL; ++ ++ if (hso_net->net) ++ free_netdev(hso_net->net); ++ ++ kfree(hso_dev); ++} ++ ++static const struct net_device_ops hso_netdev_ops = { ++ .ndo_open = hso_net_open, ++ .ndo_stop = hso_net_close, ++ .ndo_start_xmit = hso_net_start_xmit, ++ .ndo_tx_timeout = hso_net_tx_timeout, ++}; ++ ++/* initialize the network interface */ ++static void hso_net_init(struct net_device *net) ++{ ++ struct hso_net *hso_net = netdev_priv(net); ++ ++ D1("sizeof hso_net is %d", (int)sizeof(*hso_net)); ++ ++ /* fill in the other fields */ ++ net->netdev_ops = &hso_netdev_ops; ++ net->watchdog_timeo = HSO_NET_TX_TIMEOUT; ++ net->flags = IFF_POINTOPOINT | IFF_NOARP | IFF_MULTICAST; ++ net->type = ARPHRD_NONE; ++ net->mtu = DEFAULT_MTU - 14; ++ net->tx_queue_len = 10; ++ net->ethtool_ops = &ops; ++ ++ /* and initialize the semaphore */ ++ spin_lock_init(&hso_net->net_lock); ++} ++ ++/* Adds a network device in the network device table */ ++static int add_net_device(struct hso_device *hso_dev) ++{ ++ int i; ++ ++ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { ++ if (network_table[i] == NULL) { ++ network_table[i] = hso_dev; ++ break; ++ } ++ } ++ if (i == HSO_MAX_NET_DEVICES) ++ return -1; ++ return 0; ++} ++ ++static int hso_rfkill_set_block(void *data, bool blocked) ++{ ++ struct hso_device *hso_dev = data; ++ int enabled = !blocked; ++ int rv; ++ ++ mutex_lock(&hso_dev->mutex); ++ if (hso_dev->usb_gone) ++ rv = 0; ++ else ++ rv = usb_control_msg(hso_dev->usb, usb_rcvctrlpipe(hso_dev->usb, 0), ++ enabled ? 0x82 : 0x81, 0x40, 0, 0, NULL, 0, ++ USB_CTRL_SET_TIMEOUT); ++ mutex_unlock(&hso_dev->mutex); ++ return rv; ++} ++ ++static const struct rfkill_ops hso_rfkill_ops = { ++ .set_block = hso_rfkill_set_block, ++}; ++ ++/* Creates and sets up everything for rfkill */ ++static void hso_create_rfkill(struct hso_device *hso_dev, ++ struct usb_interface *interface) ++{ ++ struct hso_net *hso_net = dev2net(hso_dev); ++ struct device *dev = &hso_net->net->dev; ++ static u32 rfkill_counter; ++ ++ snprintf(hso_net->name, sizeof(hso_net->name), "hso-%d", ++ rfkill_counter++); ++ ++ hso_net->rfkill = rfkill_alloc(hso_net->name, ++ &interface_to_usbdev(interface)->dev, ++ RFKILL_TYPE_WWAN, ++ &hso_rfkill_ops, hso_dev); ++ if (!hso_net->rfkill) { ++ dev_err(dev, "%s - Out of memory\n", __func__); ++ return; ++ } ++ if (rfkill_register(hso_net->rfkill) < 0) { ++ rfkill_destroy(hso_net->rfkill); ++ hso_net->rfkill = NULL; ++ dev_err(dev, "%s - Failed to register rfkill\n", __func__); ++ return; ++ } ++} ++ ++static struct device_type hso_type = { ++ .name = "wwan", ++}; ++ ++/* Creates our network device */ ++static struct hso_device *hso_create_net_device(struct usb_interface *interface, ++ int port_spec) ++{ ++ int result, i; ++ struct net_device *net; ++ struct hso_net *hso_net; ++ struct hso_device *hso_dev; ++ ++ hso_dev = hso_create_device(interface, port_spec); ++ if (!hso_dev) ++ return NULL; ++ ++ /* allocate our network device, then we can put in our private data */ ++ /* call hso_net_init to do the basic initialization */ ++ net = alloc_netdev(sizeof(struct hso_net), "hso%d", NET_NAME_UNKNOWN, ++ hso_net_init); ++ if (!net) { ++ dev_err(&interface->dev, "Unable to create ethernet device\n"); ++ goto exit; ++ } ++ ++ hso_net = netdev_priv(net); ++ ++ hso_dev->port_data.dev_net = hso_net; ++ hso_net->net = net; ++ hso_net->parent = hso_dev; ++ ++ hso_net->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, ++ USB_DIR_IN); ++ if (!hso_net->in_endp) { ++ dev_err(&interface->dev, "Can't find BULK IN endpoint\n"); ++ goto exit; ++ } ++ hso_net->out_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, ++ USB_DIR_OUT); ++ if (!hso_net->out_endp) { ++ dev_err(&interface->dev, "Can't find BULK OUT endpoint\n"); ++ goto exit; ++ } ++ SET_NETDEV_DEV(net, &interface->dev); ++ SET_NETDEV_DEVTYPE(net, &hso_type); ++ ++ /* registering our net device */ ++ result = register_netdev(net); ++ if (result) { ++ dev_err(&interface->dev, "Failed to register device\n"); ++ goto exit; ++ } ++ ++ /* start allocating */ ++ for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) { ++ hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL); ++ if (!hso_net->mux_bulk_rx_urb_pool[i]) { ++ dev_err(&interface->dev, "Could not allocate rx urb\n"); ++ goto exit; ++ } ++ hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE, ++ GFP_KERNEL); ++ if (!hso_net->mux_bulk_rx_buf_pool[i]) ++ goto exit; ++ } ++ hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!hso_net->mux_bulk_tx_urb) { ++ dev_err(&interface->dev, "Could not allocate tx urb\n"); ++ goto exit; ++ } ++ hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL); ++ if (!hso_net->mux_bulk_tx_buf) ++ goto exit; ++ ++ add_net_device(hso_dev); ++ ++ hso_log_port(hso_dev); ++ ++ hso_create_rfkill(hso_dev, interface); ++ ++ return hso_dev; ++exit: ++ hso_free_net_device(hso_dev); ++ return NULL; ++} ++ ++static void hso_free_tiomget(struct hso_serial *serial) ++{ ++ struct hso_tiocmget *tiocmget; ++ if (!serial) ++ return; ++ tiocmget = serial->tiocmget; ++ if (tiocmget) { ++ usb_free_urb(tiocmget->urb); ++ tiocmget->urb = NULL; ++ serial->tiocmget = NULL; ++ kfree(tiocmget); ++ } ++} ++ ++/* Frees an AT channel ( goes for both mux and non-mux ) */ ++static void hso_free_serial_device(struct hso_device *hso_dev) ++{ ++ struct hso_serial *serial = dev2ser(hso_dev); ++ ++ if (!serial) ++ return; ++ ++ hso_serial_common_free(serial); ++ ++ if (serial->shared_int) { ++ mutex_lock(&serial->shared_int->shared_int_lock); ++ if (--serial->shared_int->ref_count == 0) ++ hso_free_shared_int(serial->shared_int); ++ else ++ mutex_unlock(&serial->shared_int->shared_int_lock); ++ } ++ hso_free_tiomget(serial); ++ kfree(serial); ++ kfree(hso_dev); ++} ++ ++/* Creates a bulk AT channel */ ++static struct hso_device *hso_create_bulk_serial_device( ++ struct usb_interface *interface, int port) ++{ ++ struct hso_device *hso_dev; ++ struct hso_serial *serial; ++ int num_urbs; ++ struct hso_tiocmget *tiocmget; ++ ++ hso_dev = hso_create_device(interface, port); ++ if (!hso_dev) ++ return NULL; ++ ++ serial = kzalloc(sizeof(*serial), GFP_KERNEL); ++ if (!serial) ++ goto exit; ++ ++ serial->parent = hso_dev; ++ hso_dev->port_data.dev_serial = serial; ++ ++ if ((port & HSO_PORT_MASK) == HSO_PORT_MODEM) { ++ num_urbs = 2; ++ serial->tiocmget = kzalloc(sizeof(struct hso_tiocmget), ++ GFP_KERNEL); ++ /* it isn't going to break our heart if serial->tiocmget ++ * allocation fails don't bother checking this. ++ */ ++ if (serial->tiocmget) { ++ tiocmget = serial->tiocmget; ++ tiocmget->urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (tiocmget->urb) { ++ mutex_init(&tiocmget->mutex); ++ init_waitqueue_head(&tiocmget->waitq); ++ tiocmget->endp = hso_get_ep( ++ interface, ++ USB_ENDPOINT_XFER_INT, ++ USB_DIR_IN); ++ } else ++ hso_free_tiomget(serial); ++ } ++ } ++ else ++ num_urbs = 1; ++ ++ if (hso_serial_common_create(serial, num_urbs, BULK_URB_RX_SIZE, ++ BULK_URB_TX_SIZE)) ++ goto exit; ++ ++ serial->in_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, ++ USB_DIR_IN); ++ if (!serial->in_endp) { ++ dev_err(&interface->dev, "Failed to find BULK IN ep\n"); ++ goto exit2; ++ } ++ ++ if (! ++ (serial->out_endp = ++ hso_get_ep(interface, USB_ENDPOINT_XFER_BULK, USB_DIR_OUT))) { ++ dev_err(&interface->dev, "Failed to find BULK IN ep\n"); ++ goto exit2; ++ } ++ ++ serial->write_data = hso_std_serial_write_data; ++ ++ /* and record this serial */ ++ set_serial_by_index(serial->minor, serial); ++ ++ /* setup the proc dirs and files if needed */ ++ hso_log_port(hso_dev); ++ ++ /* done, return it */ ++ return hso_dev; ++ ++exit2: ++ hso_serial_tty_unregister(serial); ++ hso_serial_common_free(serial); ++exit: ++ hso_free_tiomget(serial); ++ kfree(serial); ++ kfree(hso_dev); ++ return NULL; ++} ++ ++/* Creates a multiplexed AT channel */ ++static ++struct hso_device *hso_create_mux_serial_device(struct usb_interface *interface, ++ int port, ++ struct hso_shared_int *mux) ++{ ++ struct hso_device *hso_dev; ++ struct hso_serial *serial; ++ int port_spec; ++ ++ port_spec = HSO_INTF_MUX; ++ port_spec &= ~HSO_PORT_MASK; ++ ++ port_spec |= hso_mux_to_port(port); ++ if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NO_PORT) ++ return NULL; ++ ++ hso_dev = hso_create_device(interface, port_spec); ++ if (!hso_dev) ++ return NULL; ++ ++ serial = kzalloc(sizeof(*serial), GFP_KERNEL); ++ if (!serial) ++ goto exit; ++ ++ hso_dev->port_data.dev_serial = serial; ++ serial->parent = hso_dev; ++ ++ if (hso_serial_common_create ++ (serial, 1, CTRL_URB_RX_SIZE, CTRL_URB_TX_SIZE)) ++ goto exit; ++ ++ serial->tx_data_length--; ++ serial->write_data = hso_mux_serial_write_data; ++ ++ serial->shared_int = mux; ++ mutex_lock(&serial->shared_int->shared_int_lock); ++ serial->shared_int->ref_count++; ++ mutex_unlock(&serial->shared_int->shared_int_lock); ++ ++ /* and record this serial */ ++ set_serial_by_index(serial->minor, serial); ++ ++ /* setup the proc dirs and files if needed */ ++ hso_log_port(hso_dev); ++ ++ /* done, return it */ ++ return hso_dev; ++ ++exit: ++ if (serial) { ++ tty_unregister_device(tty_drv, serial->minor); ++ kfree(serial); ++ } ++ kfree(hso_dev); ++ return NULL; ++ ++} ++ ++static void hso_free_shared_int(struct hso_shared_int *mux) ++{ ++ usb_free_urb(mux->shared_intr_urb); ++ kfree(mux->shared_intr_buf); ++ mutex_unlock(&mux->shared_int_lock); ++ kfree(mux); ++} ++ ++static ++struct hso_shared_int *hso_create_shared_int(struct usb_interface *interface) ++{ ++ struct hso_shared_int *mux = kzalloc(sizeof(*mux), GFP_KERNEL); ++ ++ if (!mux) ++ return NULL; ++ ++ mux->intr_endp = hso_get_ep(interface, USB_ENDPOINT_XFER_INT, ++ USB_DIR_IN); ++ if (!mux->intr_endp) { ++ dev_err(&interface->dev, "Can't find INT IN endpoint\n"); ++ goto exit; ++ } ++ ++ mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!mux->shared_intr_urb) { ++ dev_err(&interface->dev, "Could not allocate intr urb?\n"); ++ goto exit; ++ } ++ mux->shared_intr_buf = ++ kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize), ++ GFP_KERNEL); ++ if (!mux->shared_intr_buf) ++ goto exit; ++ ++ mutex_init(&mux->shared_int_lock); ++ ++ return mux; ++ ++exit: ++ kfree(mux->shared_intr_buf); ++ usb_free_urb(mux->shared_intr_urb); ++ kfree(mux); ++ return NULL; ++} ++ ++/* Gets the port spec for a certain interface */ ++static int hso_get_config_data(struct usb_interface *interface) ++{ ++ struct usb_device *usbdev = interface_to_usbdev(interface); ++ u8 *config_data = kmalloc(17, GFP_KERNEL); ++ u32 if_num = interface->cur_altsetting->desc.bInterfaceNumber; ++ s32 result; ++ ++ if (!config_data) ++ return -ENOMEM; ++ if (usb_control_msg(usbdev, usb_rcvctrlpipe(usbdev, 0), ++ 0x86, 0xC0, 0, 0, config_data, 17, ++ USB_CTRL_SET_TIMEOUT) != 0x11) { ++ kfree(config_data); ++ return -EIO; ++ } ++ ++ switch (config_data[if_num]) { ++ case 0x0: ++ result = 0; ++ break; ++ case 0x1: ++ result = HSO_PORT_DIAG; ++ break; ++ case 0x2: ++ result = HSO_PORT_GPS; ++ break; ++ case 0x3: ++ result = HSO_PORT_GPS_CONTROL; ++ break; ++ case 0x4: ++ result = HSO_PORT_APP; ++ break; ++ case 0x5: ++ result = HSO_PORT_APP2; ++ break; ++ case 0x6: ++ result = HSO_PORT_CONTROL; ++ break; ++ case 0x7: ++ result = HSO_PORT_NETWORK; ++ break; ++ case 0x8: ++ result = HSO_PORT_MODEM; ++ break; ++ case 0x9: ++ result = HSO_PORT_MSD; ++ break; ++ case 0xa: ++ result = HSO_PORT_PCSC; ++ break; ++ case 0xb: ++ result = HSO_PORT_VOICE; ++ break; ++ default: ++ result = 0; ++ } ++ ++ if (result) ++ result |= HSO_INTF_BULK; ++ ++ if (config_data[16] & 0x1) ++ result |= HSO_INFO_CRC_BUG; ++ ++ kfree(config_data); ++ return result; ++} ++ ++/* called once for each interface upon device insertion */ ++static int hso_probe(struct usb_interface *interface, ++ const struct usb_device_id *id) ++{ ++ int mux, i, if_num, port_spec; ++ unsigned char port_mask; ++ struct hso_device *hso_dev = NULL; ++ struct hso_shared_int *shared_int; ++ struct hso_device *tmp_dev = NULL; ++ ++ if (interface->cur_altsetting->desc.bInterfaceClass != 0xFF) { ++ dev_err(&interface->dev, "Not our interface\n"); ++ return -ENODEV; ++ } ++ ++ if_num = interface->cur_altsetting->desc.bInterfaceNumber; ++ ++ /* Get the interface/port specification from either driver_info or from ++ * the device itself */ ++ if (id->driver_info) ++ port_spec = ((u32 *)(id->driver_info))[if_num]; ++ else ++ port_spec = hso_get_config_data(interface); ++ ++ /* Check if we need to switch to alt interfaces prior to port ++ * configuration */ ++ if (interface->num_altsetting > 1) ++ usb_set_interface(interface_to_usbdev(interface), if_num, 1); ++ interface->needs_remote_wakeup = 1; ++ ++ /* Allocate new hso device(s) */ ++ switch (port_spec & HSO_INTF_MASK) { ++ case HSO_INTF_MUX: ++ if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { ++ /* Create the network device */ ++ if (!disable_net) { ++ hso_dev = hso_create_net_device(interface, ++ port_spec); ++ if (!hso_dev) ++ goto exit; ++ tmp_dev = hso_dev; ++ } ++ } ++ ++ if (hso_get_mux_ports(interface, &port_mask)) ++ /* TODO: de-allocate everything */ ++ goto exit; ++ ++ shared_int = hso_create_shared_int(interface); ++ if (!shared_int) ++ goto exit; ++ ++ for (i = 1, mux = 0; i < 0x100; i = i << 1, mux++) { ++ if (port_mask & i) { ++ hso_dev = hso_create_mux_serial_device( ++ interface, i, shared_int); ++ if (!hso_dev) ++ goto exit; ++ } ++ } ++ ++ if (tmp_dev) ++ hso_dev = tmp_dev; ++ break; ++ ++ case HSO_INTF_BULK: ++ /* It's a regular bulk interface */ ++ if ((port_spec & HSO_PORT_MASK) == HSO_PORT_NETWORK) { ++ if (!disable_net) ++ hso_dev = ++ hso_create_net_device(interface, port_spec); ++ } else { ++ hso_dev = ++ hso_create_bulk_serial_device(interface, port_spec); ++ } ++ if (!hso_dev) ++ goto exit; ++ break; ++ default: ++ goto exit; ++ } ++ ++ /* save our data pointer in this device */ ++ usb_set_intfdata(interface, hso_dev); ++ ++ /* done */ ++ return 0; ++exit: ++ hso_free_interface(interface); ++ return -ENODEV; ++} ++ ++/* device removed, cleaning up */ ++static void hso_disconnect(struct usb_interface *interface) ++{ ++ hso_free_interface(interface); ++ ++ /* remove reference of our private data */ ++ usb_set_intfdata(interface, NULL); ++} ++ ++static void async_get_intf(struct work_struct *data) ++{ ++ struct hso_device *hso_dev = ++ container_of(data, struct hso_device, async_get_intf); ++ usb_autopm_get_interface(hso_dev->interface); ++} ++ ++static void async_put_intf(struct work_struct *data) ++{ ++ struct hso_device *hso_dev = ++ container_of(data, struct hso_device, async_put_intf); ++ usb_autopm_put_interface(hso_dev->interface); ++} ++ ++static int hso_get_activity(struct hso_device *hso_dev) ++{ ++ if (hso_dev->usb->state == USB_STATE_SUSPENDED) { ++ if (!hso_dev->is_active) { ++ hso_dev->is_active = 1; ++ schedule_work(&hso_dev->async_get_intf); ++ } ++ } ++ ++ if (hso_dev->usb->state != USB_STATE_CONFIGURED) ++ return -EAGAIN; ++ ++ usb_mark_last_busy(hso_dev->usb); ++ ++ return 0; ++} ++ ++static int hso_put_activity(struct hso_device *hso_dev) ++{ ++ if (hso_dev->usb->state != USB_STATE_SUSPENDED) { ++ if (hso_dev->is_active) { ++ hso_dev->is_active = 0; ++ schedule_work(&hso_dev->async_put_intf); ++ return -EAGAIN; ++ } ++ } ++ hso_dev->is_active = 0; ++ return 0; ++} ++ ++/* called by kernel when we need to suspend device */ ++static int hso_suspend(struct usb_interface *iface, pm_message_t message) ++{ ++ int i, result; ++ ++ /* Stop all serial ports */ ++ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { ++ if (serial_table[i] && (serial_table[i]->interface == iface)) { ++ result = hso_stop_serial_device(serial_table[i]); ++ if (result) ++ goto out; ++ } ++ } ++ ++ /* Stop all network ports */ ++ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { ++ if (network_table[i] && ++ (network_table[i]->interface == iface)) { ++ result = hso_stop_net_device(network_table[i]); ++ if (result) ++ goto out; ++ } ++ } ++ ++out: ++ return 0; ++} ++ ++/* called by kernel when we need to resume device */ ++static int hso_resume(struct usb_interface *iface) ++{ ++ int i, result = 0; ++ struct hso_net *hso_net; ++ ++ /* Start all serial ports */ ++ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { ++ if (serial_table[i] && (serial_table[i]->interface == iface)) { ++ if (atomic_read(&dev2ser(serial_table[i])->port.count)) { ++ result = ++ hso_start_serial_device(serial_table[i], GFP_NOIO); ++ hso_kick_transmit(dev2ser(serial_table[i])); ++ if (result) ++ goto out; ++ } ++ } ++ } ++ ++ /* Start all network ports */ ++ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { ++ if (network_table[i] && ++ (network_table[i]->interface == iface)) { ++ hso_net = dev2net(network_table[i]); ++ if (hso_net->flags & IFF_UP) { ++ /* First transmit any lingering data, ++ then restart the device. */ ++ if (hso_net->skb_tx_buf) { ++ dev_dbg(&iface->dev, ++ "Transmitting" ++ " lingering data\n"); ++ hso_net_start_xmit(hso_net->skb_tx_buf, ++ hso_net->net); ++ hso_net->skb_tx_buf = NULL; ++ } ++ result = hso_start_net_device(network_table[i]); ++ if (result) ++ goto out; ++ } ++ } ++ } ++ ++out: ++ return result; ++} ++ ++static void hso_serial_ref_free(struct kref *ref) ++{ ++ struct hso_device *hso_dev = container_of(ref, struct hso_device, ref); ++ ++ hso_free_serial_device(hso_dev); ++} ++ ++static void hso_free_interface(struct usb_interface *interface) ++{ ++ struct hso_serial *serial; ++ int i; ++ ++ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) { ++ if (serial_table[i] && ++ (serial_table[i]->interface == interface)) { ++ serial = dev2ser(serial_table[i]); ++ tty_port_tty_hangup(&serial->port, false); ++ mutex_lock(&serial->parent->mutex); ++ serial->parent->usb_gone = 1; ++ mutex_unlock(&serial->parent->mutex); ++ cancel_work_sync(&serial_table[i]->async_put_intf); ++ cancel_work_sync(&serial_table[i]->async_get_intf); ++ hso_serial_tty_unregister(serial); ++ kref_put(&serial_table[i]->ref, hso_serial_ref_free); ++ set_serial_by_index(i, NULL); ++ } ++ } ++ ++ for (i = 0; i < HSO_MAX_NET_DEVICES; i++) { ++ if (network_table[i] && ++ (network_table[i]->interface == interface)) { ++ struct rfkill *rfk = dev2net(network_table[i])->rfkill; ++ /* hso_stop_net_device doesn't stop the net queue since ++ * traffic needs to start it again when suspended */ ++ netif_stop_queue(dev2net(network_table[i])->net); ++ hso_stop_net_device(network_table[i]); ++ cancel_work_sync(&network_table[i]->async_put_intf); ++ cancel_work_sync(&network_table[i]->async_get_intf); ++ if (rfk) { ++ rfkill_unregister(rfk); ++ rfkill_destroy(rfk); ++ } ++ hso_free_net_device(network_table[i]); ++ } ++ } ++} ++ ++/* Helper functions */ ++ ++/* Get the endpoint ! */ ++static struct usb_endpoint_descriptor *hso_get_ep(struct usb_interface *intf, ++ int type, int dir) ++{ ++ int i; ++ struct usb_host_interface *iface = intf->cur_altsetting; ++ struct usb_endpoint_descriptor *endp; ++ ++ for (i = 0; i < iface->desc.bNumEndpoints; i++) { ++ endp = &iface->endpoint[i].desc; ++ if (((endp->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == dir) && ++ (usb_endpoint_type(endp) == type)) ++ return endp; ++ } ++ ++ return NULL; ++} ++ ++/* Get the byte that describes which ports are enabled */ ++static int hso_get_mux_ports(struct usb_interface *intf, unsigned char *ports) ++{ ++ int i; ++ struct usb_host_interface *iface = intf->cur_altsetting; ++ ++ if (iface->extralen == 3) { ++ *ports = iface->extra[2]; ++ return 0; ++ } ++ ++ for (i = 0; i < iface->desc.bNumEndpoints; i++) { ++ if (iface->endpoint[i].extralen == 3) { ++ *ports = iface->endpoint[i].extra[2]; ++ return 0; ++ } ++ } ++ ++ return -1; ++} ++ ++/* interrupt urb needs to be submitted, used for serial read of muxed port */ ++static int hso_mux_submit_intr_urb(struct hso_shared_int *shared_int, ++ struct usb_device *usb, gfp_t gfp) ++{ ++ int result; ++ ++ usb_fill_int_urb(shared_int->shared_intr_urb, usb, ++ usb_rcvintpipe(usb, ++ shared_int->intr_endp->bEndpointAddress & 0x7F), ++ shared_int->shared_intr_buf, ++ 1, ++ intr_callback, shared_int, ++ shared_int->intr_endp->bInterval); ++ ++ result = usb_submit_urb(shared_int->shared_intr_urb, gfp); ++ if (result) ++ dev_warn(&usb->dev, "%s failed mux_intr_urb %d\n", __func__, ++ result); ++ ++ return result; ++} ++ ++/* operations setup of the serial interface */ ++static const struct tty_operations hso_serial_ops = { ++ .open = hso_serial_open, ++ .close = hso_serial_close, ++ .write = hso_serial_write, ++ .write_room = hso_serial_write_room, ++ .cleanup = hso_serial_cleanup, ++ .ioctl = hso_serial_ioctl, ++ .set_termios = hso_serial_set_termios, ++ .chars_in_buffer = hso_serial_chars_in_buffer, ++ .tiocmget = hso_serial_tiocmget, ++ .tiocmset = hso_serial_tiocmset, ++ .get_icount = hso_get_count, ++ .unthrottle = hso_unthrottle ++}; ++ ++static struct usb_driver hso_driver = { ++ .name = driver_name, ++ .probe = hso_probe, ++ .disconnect = hso_disconnect, ++ .id_table = hso_ids, ++ .suspend = hso_suspend, ++ .resume = hso_resume, ++ .reset_resume = hso_resume, ++ .supports_autosuspend = 1, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++static int __init hso_init(void) ++{ ++ int i; ++ int result; ++ ++ /* put it in the log */ ++ printk(KERN_INFO "hso: %s\n", version); ++ ++ /* Initialise the serial table semaphore and table */ ++ spin_lock_init(&serial_table_lock); ++ for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) ++ serial_table[i] = NULL; ++ ++ /* allocate our driver using the proper amount of supported minors */ ++ tty_drv = alloc_tty_driver(HSO_SERIAL_TTY_MINORS); ++ if (!tty_drv) ++ return -ENOMEM; ++ ++ /* fill in all needed values */ ++ tty_drv->driver_name = driver_name; ++ tty_drv->name = tty_filename; ++ ++ /* if major number is provided as parameter, use that one */ ++ if (tty_major) ++ tty_drv->major = tty_major; ++ ++ tty_drv->minor_start = 0; ++ tty_drv->type = TTY_DRIVER_TYPE_SERIAL; ++ tty_drv->subtype = SERIAL_TYPE_NORMAL; ++ tty_drv->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; ++ tty_drv->init_termios = tty_std_termios; ++ hso_init_termios(&tty_drv->init_termios); ++ tty_set_operations(tty_drv, &hso_serial_ops); ++ ++ /* register the tty driver */ ++ result = tty_register_driver(tty_drv); ++ if (result) { ++ printk(KERN_ERR "%s - tty_register_driver failed(%d)\n", ++ __func__, result); ++ goto err_free_tty; ++ } ++ ++ /* register this module as an usb driver */ ++ result = usb_register(&hso_driver); ++ if (result) { ++ printk(KERN_ERR "Could not register hso driver? error: %d\n", ++ result); ++ goto err_unreg_tty; ++ } ++ ++ /* done */ ++ return 0; ++err_unreg_tty: ++ tty_unregister_driver(tty_drv); ++err_free_tty: ++ put_tty_driver(tty_drv); ++ return result; ++} ++ ++static void __exit hso_exit(void) ++{ ++ printk(KERN_INFO "hso: unloaded\n"); ++ ++ tty_unregister_driver(tty_drv); ++ put_tty_driver(tty_drv); ++ /* deregister the usb driver */ ++ usb_deregister(&hso_driver); ++} ++ ++/* Module definitions */ ++module_init(hso_init); ++module_exit(hso_exit); ++ ++MODULE_AUTHOR(MOD_AUTHOR); ++MODULE_DESCRIPTION(MOD_DESCRIPTION); ++MODULE_LICENSE(MOD_LICENSE); ++ ++/* change the debug level (eg: insmod hso.ko debug=0x04) */ ++MODULE_PARM_DESC(debug, "Level of debug [0x01 | 0x02 | 0x04 | 0x08 | 0x10]"); ++module_param(debug, int, S_IRUGO | S_IWUSR); ++ ++/* set the major tty number (eg: insmod hso.ko tty_major=245) */ ++MODULE_PARM_DESC(tty_major, "Set the major tty number"); ++module_param(tty_major, int, S_IRUGO | S_IWUSR); ++ ++/* disable network interface (eg: insmod hso.ko disable_net=1) */ ++MODULE_PARM_DESC(disable_net, "Disable the network interface"); ++module_param(disable_net, int, S_IRUGO | S_IWUSR); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/huawei_cdc_ncm.c backports-4.2.6-1/drivers/net/usb/huawei_cdc_ncm.c +--- backports-4.2.6-1.org/drivers/net/usb/huawei_cdc_ncm.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/huawei_cdc_ncm.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,224 @@ ++/* huawei_cdc_ncm.c - handles Huawei devices using the CDC NCM protocol as ++ * transport layer. ++ * Copyright (C) 2013 Enrico Mioso mrkiko.rs@gmail.com ++ * ++ * ++ * ABSTRACT: ++ * This driver handles devices resembling the CDC NCM standard, but ++ * encapsulating another protocol inside it. An example are some Huawei 3G ++ * devices, exposing an embedded AT channel where you can set up the NCM ++ * connection. ++ * This code has been heavily inspired by the cdc_mbim.c driver, which is ++ * Copyright (c) 2012 Smith Micro Software, Inc. ++ * Copyright (c) 2012 Bjørn Mork bjorn@mork.no ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation. ++ */ ++ ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/ethtool.h> ++#include <linux/if_vlan.h> ++#include <linux/ip.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/usb/cdc.h> ++#include <linux/usb/usbnet.h> ++#include <linux/usb/cdc-wdm.h> ++#include <linux/usb/cdc_ncm.h> ++ ++/* Driver data */ ++struct huawei_cdc_ncm_state { ++ struct cdc_ncm_ctx *ctx; ++ atomic_t pmcount; ++ struct usb_driver *subdriver; ++ struct usb_interface *control; ++ struct usb_interface *data; ++}; ++ ++static int huawei_cdc_ncm_manage_power(struct usbnet *usbnet_dev, int on) ++{ ++ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; ++ int rv; ++ ++ if ((on && atomic_add_return(1, &drvstate->pmcount) == 1) || ++ (!on && atomic_dec_and_test(&drvstate->pmcount))) { ++ rv = usb_autopm_get_interface(usbnet_dev->intf); ++ usbnet_dev->intf->needs_remote_wakeup = on; ++ if (!rv) ++ usb_autopm_put_interface(usbnet_dev->intf); ++ } ++ return 0; ++} ++ ++static int huawei_cdc_ncm_wdm_manage_power(struct usb_interface *intf, ++ int status) ++{ ++ struct usbnet *usbnet_dev = usb_get_intfdata(intf); ++ ++ /* can be called while disconnecting */ ++ if (!usbnet_dev) ++ return 0; ++ ++ return huawei_cdc_ncm_manage_power(usbnet_dev, status); ++} ++ ++ ++static int huawei_cdc_ncm_bind(struct usbnet *usbnet_dev, ++ struct usb_interface *intf) ++{ ++ struct cdc_ncm_ctx *ctx; ++ struct usb_driver *subdriver = ERR_PTR(-ENODEV); ++ int ret = -ENODEV; ++ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; ++ int drvflags = 0; ++ ++ /* altsetting should always be 1 for NCM devices - so we hard-coded ++ * it here. Some huawei devices will need the NDP part of the NCM package to ++ * be at the end of the frame. ++ */ ++ drvflags |= CDC_NCM_FLAG_NDP_TO_END; ++ ret = cdc_ncm_bind_common(usbnet_dev, intf, 1, drvflags); ++ if (ret) ++ goto err; ++ ++ ctx = drvstate->ctx; ++ ++ if (usbnet_dev->status) ++ /* The wMaxCommand buffer must be big enough to hold ++ * any message from the modem. Experience has shown ++ * that some replies are more than 256 bytes long ++ */ ++ subdriver = usb_cdc_wdm_register(ctx->control, ++ &usbnet_dev->status->desc, ++ 1024, /* wMaxCommand */ ++ huawei_cdc_ncm_wdm_manage_power); ++ if (IS_ERR(subdriver)) { ++ ret = PTR_ERR(subdriver); ++ cdc_ncm_unbind(usbnet_dev, intf); ++ goto err; ++ } ++ ++ /* Prevent usbnet from using the status descriptor */ ++ usbnet_dev->status = NULL; ++ ++ drvstate->subdriver = subdriver; ++ ++err: ++ return ret; ++} ++ ++static void huawei_cdc_ncm_unbind(struct usbnet *usbnet_dev, ++ struct usb_interface *intf) ++{ ++ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; ++ struct cdc_ncm_ctx *ctx = drvstate->ctx; ++ ++ if (drvstate->subdriver && drvstate->subdriver->disconnect) ++ drvstate->subdriver->disconnect(ctx->control); ++ drvstate->subdriver = NULL; ++ ++ cdc_ncm_unbind(usbnet_dev, intf); ++} ++ ++static int huawei_cdc_ncm_suspend(struct usb_interface *intf, ++ pm_message_t message) ++{ ++ int ret = 0; ++ struct usbnet *usbnet_dev = usb_get_intfdata(intf); ++ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; ++ struct cdc_ncm_ctx *ctx = drvstate->ctx; ++ ++ if (ctx == NULL) { ++ ret = -ENODEV; ++ goto error; ++ } ++ ++ ret = usbnet_suspend(intf, message); ++ if (ret < 0) ++ goto error; ++ ++ if (intf == ctx->control && ++ drvstate->subdriver && ++ drvstate->subdriver->suspend) ++ ret = drvstate->subdriver->suspend(intf, message); ++ if (ret < 0) ++ usbnet_resume(intf); ++ ++error: ++ return ret; ++} ++ ++static int huawei_cdc_ncm_resume(struct usb_interface *intf) ++{ ++ int ret = 0; ++ struct usbnet *usbnet_dev = usb_get_intfdata(intf); ++ struct huawei_cdc_ncm_state *drvstate = (void *)&usbnet_dev->data; ++ bool callsub; ++ struct cdc_ncm_ctx *ctx = drvstate->ctx; ++ ++ /* should we call subdriver's resume function? */ ++ callsub = ++ (intf == ctx->control && ++ drvstate->subdriver && ++ drvstate->subdriver->resume); ++ ++ if (callsub) ++ ret = drvstate->subdriver->resume(intf); ++ if (ret < 0) ++ goto err; ++ ret = usbnet_resume(intf); ++ if (ret < 0 && callsub) ++ drvstate->subdriver->suspend(intf, PMSG_SUSPEND); ++err: ++ return ret; ++} ++ ++static const struct driver_info huawei_cdc_ncm_info = { ++ .description = "Huawei CDC NCM device", ++ .flags = FLAG_NO_SETINT | FLAG_MULTI_PACKET | FLAG_WWAN, ++ .bind = huawei_cdc_ncm_bind, ++ .unbind = huawei_cdc_ncm_unbind, ++ .manage_power = huawei_cdc_ncm_manage_power, ++ .rx_fixup = cdc_ncm_rx_fixup, ++ .tx_fixup = cdc_ncm_tx_fixup, ++}; ++ ++static const struct usb_device_id huawei_cdc_ncm_devs[] = { ++ /* Huawei NCM devices disguised as vendor specific */ ++ { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x16), ++ .driver_info = (unsigned long)&huawei_cdc_ncm_info, ++ }, ++ { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x46), ++ .driver_info = (unsigned long)&huawei_cdc_ncm_info, ++ }, ++ { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x76), ++ .driver_info = (unsigned long)&huawei_cdc_ncm_info, ++ }, ++ { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x03, 0x16), ++ .driver_info = (unsigned long)&huawei_cdc_ncm_info, ++ }, ++ ++ /* Terminating entry */ ++ { ++ }, ++}; ++MODULE_DEVICE_TABLE(usb, huawei_cdc_ncm_devs); ++ ++static struct usb_driver huawei_cdc_ncm_driver = { ++ .name = "huawei_cdc_ncm", ++ .id_table = huawei_cdc_ncm_devs, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = huawei_cdc_ncm_suspend, ++ .resume = huawei_cdc_ncm_resume, ++ .reset_resume = huawei_cdc_ncm_resume, ++ .supports_autosuspend = 1, ++ .disable_hub_initiated_lpm = 1, ++}; ++module_usb_driver(huawei_cdc_ncm_driver); ++MODULE_AUTHOR("Enrico Mioso mrkiko.rs@gmail.com"); ++MODULE_DESCRIPTION("USB CDC NCM host driver with encapsulated protocol support"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/int51x1.c backports-4.2.6-1/drivers/net/usb/int51x1.c +--- backports-4.2.6-1.org/drivers/net/usb/int51x1.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/int51x1.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,199 @@ ++/* ++ * Copyright (c) 2009 Peter Holik ++ * ++ * Intellon usb PLC (Powerline Communications) usb net driver ++ * ++ * http://www.tandel.be/downloads/INT51X1_Datasheet.pdf ++ * ++ * Based on the work of Jan 'RedBully' Seiffert ++ */ ++ ++/* ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or. ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include <linux/module.h> ++#include <linux/ctype.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/slab.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/usb/usbnet.h> ++ ++#define INT51X1_VENDOR_ID 0x09e1 ++#define INT51X1_PRODUCT_ID 0x5121 ++ ++#define INT51X1_HEADER_SIZE 2 /* 2 byte header */ ++ ++#define PACKET_TYPE_PROMISCUOUS (1 << 0) ++#define PACKET_TYPE_ALL_MULTICAST (1 << 1) /* no filter */ ++#define PACKET_TYPE_DIRECTED (1 << 2) ++#define PACKET_TYPE_BROADCAST (1 << 3) ++#define PACKET_TYPE_MULTICAST (1 << 4) /* filtered */ ++ ++#define SET_ETHERNET_PACKET_FILTER 0x43 ++ ++static int int51x1_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ int len; ++ ++ if (!(pskb_may_pull(skb, INT51X1_HEADER_SIZE))) { ++ netdev_err(dev->net, "unexpected tiny rx frame\n"); ++ return 0; ++ } ++ ++ len = le16_to_cpu(*(__le16 *)&skb->data[skb->len - 2]); ++ ++ skb_trim(skb, len); ++ ++ return 1; ++} ++ ++static struct sk_buff *int51x1_tx_fixup(struct usbnet *dev, ++ struct sk_buff *skb, gfp_t flags) ++{ ++ int pack_len = skb->len; ++ int pack_with_header_len = pack_len + INT51X1_HEADER_SIZE; ++ int headroom = skb_headroom(skb); ++ int tailroom = skb_tailroom(skb); ++ int need_tail = 0; ++ __le16 *len; ++ ++ /* if packet and our header is smaler than 64 pad to 64 (+ ZLP) */ ++ if ((pack_with_header_len) < dev->maxpacket) ++ need_tail = dev->maxpacket - pack_with_header_len + 1; ++ /* ++ * usbnet would send a ZLP if packetlength mod urbsize == 0 for us, ++ * but we need to know ourself, because this would add to the length ++ * we send down to the device... ++ */ ++ else if (!(pack_with_header_len % dev->maxpacket)) ++ need_tail = 1; ++ ++ if (!skb_cloned(skb) && ++ (headroom + tailroom >= need_tail + INT51X1_HEADER_SIZE)) { ++ if (headroom < INT51X1_HEADER_SIZE || tailroom < need_tail) { ++ skb->data = memmove(skb->head + INT51X1_HEADER_SIZE, ++ skb->data, skb->len); ++ skb_set_tail_pointer(skb, skb->len); ++ } ++ } else { ++ struct sk_buff *skb2; ++ ++ skb2 = skb_copy_expand(skb, ++ INT51X1_HEADER_SIZE, ++ need_tail, ++ flags); ++ dev_kfree_skb_any(skb); ++ if (!skb2) ++ return NULL; ++ skb = skb2; ++ } ++ ++ pack_len += need_tail; ++ pack_len &= 0x07ff; ++ ++ len = (__le16 *) __skb_push(skb, INT51X1_HEADER_SIZE); ++ *len = cpu_to_le16(pack_len); ++ ++ if(need_tail) ++ memset(__skb_put(skb, need_tail), 0, need_tail); ++ ++ return skb; ++} ++ ++static void int51x1_set_multicast(struct net_device *netdev) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u16 filter = PACKET_TYPE_DIRECTED | PACKET_TYPE_BROADCAST; ++ ++ if (netdev->flags & IFF_PROMISC) { ++ /* do not expect to see traffic of other PLCs */ ++ filter |= PACKET_TYPE_PROMISCUOUS; ++ netdev_info(dev->net, "promiscuous mode enabled\n"); ++ } else if (!netdev_mc_empty(netdev) || ++ (netdev->flags & IFF_ALLMULTI)) { ++ filter |= PACKET_TYPE_ALL_MULTICAST; ++ netdev_dbg(dev->net, "receive all multicast enabled\n"); ++ } else { ++ /* ~PROMISCUOUS, ~MULTICAST */ ++ netdev_dbg(dev->net, "receive own packets only\n"); ++ } ++ ++ usbnet_write_cmd_async(dev, SET_ETHERNET_PACKET_FILTER, ++ USB_DIR_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE, ++ filter, 0, NULL, 0); ++} ++ ++static const struct net_device_ops int51x1_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_set_mac_address = eth_mac_addr, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_set_rx_mode = int51x1_set_multicast, ++}; ++ ++static int int51x1_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int status = usbnet_get_ethernet_addr(dev, 3); ++ ++ if (status) ++ return status; ++ ++ dev->net->hard_header_len += INT51X1_HEADER_SIZE; ++ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; ++ dev->net->netdev_ops = &int51x1_netdev_ops; ++ ++ return usbnet_get_endpoints(dev, intf); ++} ++ ++static const struct driver_info int51x1_info = { ++ .description = "Intellon usb powerline adapter", ++ .bind = int51x1_bind, ++ .rx_fixup = int51x1_rx_fixup, ++ .tx_fixup = int51x1_tx_fixup, ++ .in = 1, ++ .out = 2, ++ .flags = FLAG_ETHER, ++}; ++ ++static const struct usb_device_id products[] = { ++ { ++ USB_DEVICE(INT51X1_VENDOR_ID, INT51X1_PRODUCT_ID), ++ .driver_info = (unsigned long) &int51x1_info, ++ }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver int51x1_driver = { ++ .name = "int51x1", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(int51x1_driver); ++ ++MODULE_AUTHOR("Peter Holik"); ++MODULE_DESCRIPTION("Intellon usb powerline adapter"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/ipheth.c backports-4.2.6-1/drivers/net/usb/ipheth.c +--- backports-4.2.6-1.org/drivers/net/usb/ipheth.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/ipheth.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,588 @@ ++/* ++ * ipheth.c - Apple iPhone USB Ethernet driver ++ * ++ * Copyright (c) 2009 Diego Giagio diego@giagio.com ++ * All rights reserved. ++ * ++ * Redistribution and use in source and binary forms, with or without ++ * modification, are permitted provided that the following conditions ++ * are met: ++ * 1. Redistributions of source code must retain the above copyright ++ * notice, this list of conditions and the following disclaimer. ++ * 2. Redistributions in binary form must reproduce the above copyright ++ * notice, this list of conditions and the following disclaimer in the ++ * documentation and/or other materials provided with the distribution. ++ * 3. Neither the name of GIAGIO.COM nor the names of its contributors ++ * may be used to endorse or promote products derived from this software ++ * without specific prior written permission. ++ * ++ * Alternatively, provided that this notice is retained in full, this ++ * software may be distributed under the terms of the GNU General ++ * Public License ("GPL") version 2, in which case the provisions of the ++ * GPL apply INSTEAD OF those given above. ++ * ++ * The provided data structures and external interfaces from this code ++ * are not restricted to be used by modules with a GPL compatible license. ++ * ++ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ++ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ++ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ++ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ++ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ++ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ++ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ++ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH ++ * DAMAGE. ++ * ++ * ++ * Attention: iPhone device must be paired, otherwise it won't respond to our ++ * driver. For more info: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver ++ * ++ */ ++ ++#include <linux/kernel.h> ++#include <linux/errno.h> ++#include <linux/slab.h> ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/usb.h> ++#include <linux/workqueue.h> ++ ++#define USB_VENDOR_APPLE 0x05ac ++#define USB_PRODUCT_IPHONE 0x1290 ++#define USB_PRODUCT_IPHONE_3G 0x1292 ++#define USB_PRODUCT_IPHONE_3GS 0x1294 ++#define USB_PRODUCT_IPHONE_4 0x1297 ++#define USB_PRODUCT_IPAD 0x129a ++#define USB_PRODUCT_IPAD_2 0x12a2 ++#define USB_PRODUCT_IPAD_3 0x12a6 ++#define USB_PRODUCT_IPAD_MINI 0x12ab ++#define USB_PRODUCT_IPHONE_4_VZW 0x129c ++#define USB_PRODUCT_IPHONE_4S 0x12a0 ++#define USB_PRODUCT_IPHONE_5 0x12a8 ++ ++#define IPHETH_USBINTF_CLASS 255 ++#define IPHETH_USBINTF_SUBCLASS 253 ++#define IPHETH_USBINTF_PROTO 1 ++ ++#define IPHETH_BUF_SIZE 1516 ++#define IPHETH_IP_ALIGN 2 /* padding at front of URB */ ++#define IPHETH_TX_TIMEOUT (5 * HZ) ++ ++#define IPHETH_INTFNUM 2 ++#define IPHETH_ALT_INTFNUM 1 ++ ++#define IPHETH_CTRL_ENDP 0x00 ++#define IPHETH_CTRL_BUF_SIZE 0x40 ++#define IPHETH_CTRL_TIMEOUT (5 * HZ) ++ ++#define IPHETH_CMD_GET_MACADDR 0x00 ++#define IPHETH_CMD_CARRIER_CHECK 0x45 ++ ++#define IPHETH_CARRIER_CHECK_TIMEOUT round_jiffies_relative(1 * HZ) ++#define IPHETH_CARRIER_ON 0x04 ++ ++static struct usb_device_id ipheth_table[] = { ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3G, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_3GS, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPAD, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_2, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_3, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPAD_MINI, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4_VZW, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_4S, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { USB_DEVICE_AND_INTERFACE_INFO( ++ USB_VENDOR_APPLE, USB_PRODUCT_IPHONE_5, ++ IPHETH_USBINTF_CLASS, IPHETH_USBINTF_SUBCLASS, ++ IPHETH_USBINTF_PROTO) }, ++ { } ++}; ++MODULE_DEVICE_TABLE(usb, ipheth_table); ++ ++struct ipheth_device { ++ struct usb_device *udev; ++ struct usb_interface *intf; ++ struct net_device *net; ++ struct sk_buff *tx_skb; ++ struct urb *tx_urb; ++ struct urb *rx_urb; ++ unsigned char *tx_buf; ++ unsigned char *rx_buf; ++ unsigned char *ctrl_buf; ++ u8 bulk_in; ++ u8 bulk_out; ++ struct delayed_work carrier_work; ++}; ++ ++static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags); ++ ++static int ipheth_alloc_urbs(struct ipheth_device *iphone) ++{ ++ struct urb *tx_urb = NULL; ++ struct urb *rx_urb = NULL; ++ u8 *tx_buf = NULL; ++ u8 *rx_buf = NULL; ++ ++ tx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (tx_urb == NULL) ++ goto error_nomem; ++ ++ rx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (rx_urb == NULL) ++ goto free_tx_urb; ++ ++ tx_buf = usb_alloc_coherent(iphone->udev, IPHETH_BUF_SIZE, ++ GFP_KERNEL, &tx_urb->transfer_dma); ++ if (tx_buf == NULL) ++ goto free_rx_urb; ++ ++ rx_buf = usb_alloc_coherent(iphone->udev, IPHETH_BUF_SIZE, ++ GFP_KERNEL, &rx_urb->transfer_dma); ++ if (rx_buf == NULL) ++ goto free_tx_buf; ++ ++ ++ iphone->tx_urb = tx_urb; ++ iphone->rx_urb = rx_urb; ++ iphone->tx_buf = tx_buf; ++ iphone->rx_buf = rx_buf; ++ return 0; ++ ++free_tx_buf: ++ usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, tx_buf, ++ tx_urb->transfer_dma); ++free_rx_urb: ++ usb_free_urb(rx_urb); ++free_tx_urb: ++ usb_free_urb(tx_urb); ++error_nomem: ++ return -ENOMEM; ++} ++ ++static void ipheth_free_urbs(struct ipheth_device *iphone) ++{ ++ usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, iphone->rx_buf, ++ iphone->rx_urb->transfer_dma); ++ usb_free_coherent(iphone->udev, IPHETH_BUF_SIZE, iphone->tx_buf, ++ iphone->tx_urb->transfer_dma); ++ usb_free_urb(iphone->rx_urb); ++ usb_free_urb(iphone->tx_urb); ++} ++ ++static void ipheth_kill_urbs(struct ipheth_device *dev) ++{ ++ usb_kill_urb(dev->tx_urb); ++ usb_kill_urb(dev->rx_urb); ++} ++ ++static void ipheth_rcvbulk_callback(struct urb *urb) ++{ ++ struct ipheth_device *dev; ++ struct sk_buff *skb; ++ int status; ++ char *buf; ++ int len; ++ ++ dev = urb->context; ++ if (dev == NULL) ++ return; ++ ++ status = urb->status; ++ switch (status) { ++ case -ENOENT: ++ case -ECONNRESET: ++ case -ESHUTDOWN: ++ return; ++ case 0: ++ break; ++ default: ++ dev_err(&dev->intf->dev, "%s: urb status: %d\n", ++ __func__, status); ++ return; ++ } ++ ++ if (urb->actual_length <= IPHETH_IP_ALIGN) { ++ dev->net->stats.rx_length_errors++; ++ return; ++ } ++ len = urb->actual_length - IPHETH_IP_ALIGN; ++ buf = urb->transfer_buffer + IPHETH_IP_ALIGN; ++ ++ skb = dev_alloc_skb(len); ++ if (!skb) { ++ dev_err(&dev->intf->dev, "%s: dev_alloc_skb: -ENOMEM\n", ++ __func__); ++ dev->net->stats.rx_dropped++; ++ return; ++ } ++ ++ memcpy(skb_put(skb, len), buf, len); ++ skb->dev = dev->net; ++ skb->protocol = eth_type_trans(skb, dev->net); ++ ++ dev->net->stats.rx_packets++; ++ dev->net->stats.rx_bytes += len; ++ ++ netif_rx(skb); ++ ipheth_rx_submit(dev, GFP_ATOMIC); ++} ++ ++static void ipheth_sndbulk_callback(struct urb *urb) ++{ ++ struct ipheth_device *dev; ++ int status = urb->status; ++ ++ dev = urb->context; ++ if (dev == NULL) ++ return; ++ ++ if (status != 0 && ++ status != -ENOENT && ++ status != -ECONNRESET && ++ status != -ESHUTDOWN) ++ dev_err(&dev->intf->dev, "%s: urb status: %d\n", ++ __func__, status); ++ ++ dev_kfree_skb_irq(dev->tx_skb); ++ netif_wake_queue(dev->net); ++} ++ ++static int ipheth_carrier_set(struct ipheth_device *dev) ++{ ++ struct usb_device *udev = dev->udev; ++ int retval; ++ ++ retval = usb_control_msg(udev, ++ usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), ++ IPHETH_CMD_CARRIER_CHECK, /* request */ ++ 0xc0, /* request type */ ++ 0x00, /* value */ ++ 0x02, /* index */ ++ dev->ctrl_buf, IPHETH_CTRL_BUF_SIZE, ++ IPHETH_CTRL_TIMEOUT); ++ if (retval < 0) { ++ dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n", ++ __func__, retval); ++ return retval; ++ } ++ ++ if (dev->ctrl_buf[0] == IPHETH_CARRIER_ON) ++ netif_carrier_on(dev->net); ++ else ++ netif_carrier_off(dev->net); ++ ++ return 0; ++} ++ ++static void ipheth_carrier_check_work(struct work_struct *work) ++{ ++ struct ipheth_device *dev = container_of(work, struct ipheth_device, ++ carrier_work.work); ++ ++ ipheth_carrier_set(dev); ++ schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); ++} ++ ++static int ipheth_get_macaddr(struct ipheth_device *dev) ++{ ++ struct usb_device *udev = dev->udev; ++ struct net_device *net = dev->net; ++ int retval; ++ ++ retval = usb_control_msg(udev, ++ usb_rcvctrlpipe(udev, IPHETH_CTRL_ENDP), ++ IPHETH_CMD_GET_MACADDR, /* request */ ++ 0xc0, /* request type */ ++ 0x00, /* value */ ++ 0x02, /* index */ ++ dev->ctrl_buf, ++ IPHETH_CTRL_BUF_SIZE, ++ IPHETH_CTRL_TIMEOUT); ++ if (retval < 0) { ++ dev_err(&dev->intf->dev, "%s: usb_control_msg: %d\n", ++ __func__, retval); ++ } else if (retval < ETH_ALEN) { ++ dev_err(&dev->intf->dev, ++ "%s: usb_control_msg: short packet: %d bytes\n", ++ __func__, retval); ++ retval = -EINVAL; ++ } else { ++ memcpy(net->dev_addr, dev->ctrl_buf, ETH_ALEN); ++ retval = 0; ++ } ++ ++ return retval; ++} ++ ++static int ipheth_rx_submit(struct ipheth_device *dev, gfp_t mem_flags) ++{ ++ struct usb_device *udev = dev->udev; ++ int retval; ++ ++ usb_fill_bulk_urb(dev->rx_urb, udev, ++ usb_rcvbulkpipe(udev, dev->bulk_in), ++ dev->rx_buf, IPHETH_BUF_SIZE, ++ ipheth_rcvbulk_callback, ++ dev); ++ dev->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ++ ++ retval = usb_submit_urb(dev->rx_urb, mem_flags); ++ if (retval) ++ dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n", ++ __func__, retval); ++ return retval; ++} ++ ++static int ipheth_open(struct net_device *net) ++{ ++ struct ipheth_device *dev = netdev_priv(net); ++ struct usb_device *udev = dev->udev; ++ int retval = 0; ++ ++ usb_set_interface(udev, IPHETH_INTFNUM, IPHETH_ALT_INTFNUM); ++ ++ retval = ipheth_carrier_set(dev); ++ if (retval) ++ return retval; ++ ++ retval = ipheth_rx_submit(dev, GFP_KERNEL); ++ if (retval) ++ return retval; ++ ++ schedule_delayed_work(&dev->carrier_work, IPHETH_CARRIER_CHECK_TIMEOUT); ++ netif_start_queue(net); ++ return retval; ++} ++ ++static int ipheth_close(struct net_device *net) ++{ ++ struct ipheth_device *dev = netdev_priv(net); ++ ++ cancel_delayed_work_sync(&dev->carrier_work); ++ netif_stop_queue(net); ++ return 0; ++} ++ ++static int ipheth_tx(struct sk_buff *skb, struct net_device *net) ++{ ++ struct ipheth_device *dev = netdev_priv(net); ++ struct usb_device *udev = dev->udev; ++ int retval; ++ ++ /* Paranoid */ ++ if (skb->len > IPHETH_BUF_SIZE) { ++ WARN(1, "%s: skb too large: %d bytes\n", __func__, skb->len); ++ dev->net->stats.tx_dropped++; ++ dev_kfree_skb_irq(skb); ++ return NETDEV_TX_OK; ++ } ++ ++ memcpy(dev->tx_buf, skb->data, skb->len); ++ if (skb->len < IPHETH_BUF_SIZE) ++ memset(dev->tx_buf + skb->len, 0, IPHETH_BUF_SIZE - skb->len); ++ ++ usb_fill_bulk_urb(dev->tx_urb, udev, ++ usb_sndbulkpipe(udev, dev->bulk_out), ++ dev->tx_buf, IPHETH_BUF_SIZE, ++ ipheth_sndbulk_callback, ++ dev); ++ dev->tx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ++ ++ retval = usb_submit_urb(dev->tx_urb, GFP_ATOMIC); ++ if (retval) { ++ dev_err(&dev->intf->dev, "%s: usb_submit_urb: %d\n", ++ __func__, retval); ++ dev->net->stats.tx_errors++; ++ dev_kfree_skb_irq(skb); ++ } else { ++ dev->tx_skb = skb; ++ ++ dev->net->stats.tx_packets++; ++ dev->net->stats.tx_bytes += skb->len; ++ netif_stop_queue(net); ++ } ++ ++ return NETDEV_TX_OK; ++} ++ ++static void ipheth_tx_timeout(struct net_device *net) ++{ ++ struct ipheth_device *dev = netdev_priv(net); ++ ++ dev_err(&dev->intf->dev, "%s: TX timeout\n", __func__); ++ dev->net->stats.tx_errors++; ++ usb_unlink_urb(dev->tx_urb); ++} ++ ++static u32 ipheth_ethtool_op_get_link(struct net_device *net) ++{ ++ struct ipheth_device *dev = netdev_priv(net); ++ return netif_carrier_ok(dev->net); ++} ++ ++static const struct ethtool_ops ops = { ++ .get_link = ipheth_ethtool_op_get_link ++}; ++ ++static const struct net_device_ops ipheth_netdev_ops = { ++ .ndo_open = ipheth_open, ++ .ndo_stop = ipheth_close, ++ .ndo_start_xmit = ipheth_tx, ++ .ndo_tx_timeout = ipheth_tx_timeout, ++}; ++ ++static int ipheth_probe(struct usb_interface *intf, ++ const struct usb_device_id *id) ++{ ++ struct usb_device *udev = interface_to_usbdev(intf); ++ struct usb_host_interface *hintf; ++ struct usb_endpoint_descriptor *endp; ++ struct ipheth_device *dev; ++ struct net_device *netdev; ++ int i; ++ int retval; ++ ++ netdev = alloc_etherdev(sizeof(struct ipheth_device)); ++ if (!netdev) ++ return -ENOMEM; ++ ++ netdev->netdev_ops = &ipheth_netdev_ops; ++ netdev->watchdog_timeo = IPHETH_TX_TIMEOUT; ++ strcpy(netdev->name, "eth%d"); ++ ++ dev = netdev_priv(netdev); ++ dev->udev = udev; ++ dev->net = netdev; ++ dev->intf = intf; ++ ++ /* Set up endpoints */ ++ hintf = usb_altnum_to_altsetting(intf, IPHETH_ALT_INTFNUM); ++ if (hintf == NULL) { ++ retval = -ENODEV; ++ dev_err(&intf->dev, "Unable to find alternate settings interface\n"); ++ goto err_endpoints; ++ } ++ ++ for (i = 0; i < hintf->desc.bNumEndpoints; i++) { ++ endp = &hintf->endpoint[i].desc; ++ if (usb_endpoint_is_bulk_in(endp)) ++ dev->bulk_in = endp->bEndpointAddress; ++ else if (usb_endpoint_is_bulk_out(endp)) ++ dev->bulk_out = endp->bEndpointAddress; ++ } ++ if (!(dev->bulk_in && dev->bulk_out)) { ++ retval = -ENODEV; ++ dev_err(&intf->dev, "Unable to find endpoints\n"); ++ goto err_endpoints; ++ } ++ ++ dev->ctrl_buf = kmalloc(IPHETH_CTRL_BUF_SIZE, GFP_KERNEL); ++ if (dev->ctrl_buf == NULL) { ++ retval = -ENOMEM; ++ goto err_alloc_ctrl_buf; ++ } ++ ++ retval = ipheth_get_macaddr(dev); ++ if (retval) ++ goto err_get_macaddr; ++ ++ INIT_DELAYED_WORK(&dev->carrier_work, ipheth_carrier_check_work); ++ ++ retval = ipheth_alloc_urbs(dev); ++ if (retval) { ++ dev_err(&intf->dev, "error allocating urbs: %d\n", retval); ++ goto err_alloc_urbs; ++ } ++ ++ usb_set_intfdata(intf, dev); ++ ++ SET_NETDEV_DEV(netdev, &intf->dev); ++ netdev->ethtool_ops = &ops; ++ ++ retval = register_netdev(netdev); ++ if (retval) { ++ dev_err(&intf->dev, "error registering netdev: %d\n", retval); ++ retval = -EIO; ++ goto err_register_netdev; ++ } ++ ++ dev_info(&intf->dev, "Apple iPhone USB Ethernet device attached\n"); ++ return 0; ++ ++err_register_netdev: ++ ipheth_free_urbs(dev); ++err_alloc_urbs: ++err_get_macaddr: ++err_alloc_ctrl_buf: ++ kfree(dev->ctrl_buf); ++err_endpoints: ++ free_netdev(netdev); ++ return retval; ++} ++ ++static void ipheth_disconnect(struct usb_interface *intf) ++{ ++ struct ipheth_device *dev; ++ ++ dev = usb_get_intfdata(intf); ++ if (dev != NULL) { ++ unregister_netdev(dev->net); ++ ipheth_kill_urbs(dev); ++ ipheth_free_urbs(dev); ++ kfree(dev->ctrl_buf); ++ free_netdev(dev->net); ++ } ++ usb_set_intfdata(intf, NULL); ++ dev_info(&intf->dev, "Apple iPhone USB Ethernet now disconnected\n"); ++} ++ ++static struct usb_driver ipheth_driver = { ++ .name = "ipheth", ++ .probe = ipheth_probe, ++ .disconnect = ipheth_disconnect, ++ .id_table = ipheth_table, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(ipheth_driver); ++ ++MODULE_AUTHOR("Diego Giagio diego@giagio.com"); ++MODULE_DESCRIPTION("Apple iPhone USB Ethernet driver"); ++MODULE_LICENSE("Dual BSD/GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/kalmia.c backports-4.2.6-1/drivers/net/usb/kalmia.c +--- backports-4.2.6-1.org/drivers/net/usb/kalmia.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/kalmia.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,366 @@ ++/* ++ * USB network interface driver for Samsung Kalmia based LTE USB modem like the ++ * Samsung GT-B3730 and GT-B3710. ++ * ++ * Copyright (C) 2011 Marius Bjoernstad Kotsbak marius@kotsbak.com ++ * ++ * Sponsored by Quicklink Video Distribution Services Ltd. ++ * ++ * Based on the cdc_eem module. ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ */ ++ ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ctype.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/crc32.h> ++#include <linux/usb/cdc.h> ++#include <linux/usb/usbnet.h> ++#include <linux/gfp.h> ++ ++/* ++ * The Samsung Kalmia based LTE USB modems have a CDC ACM port for modem control ++ * handled by the "option" module and an ethernet data port handled by this ++ * module. ++ * ++ * The stick must first be switched into modem mode by usb_modeswitch ++ * or similar tool. Then the modem gets sent two initialization packets by ++ * this module, which gives the MAC address of the device. User space can then ++ * connect the modem using AT commands through the ACM port and then use ++ * DHCP on the network interface exposed by this module. Network packets are ++ * sent to and from the modem in a proprietary format discovered after watching ++ * the behavior of the windows driver for the modem. ++ * ++ * More information about the use of the modem is available in usb_modeswitch ++ * forum and the project page: ++ * ++ * http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?t=465 ++ * https://github.com/mkotsbak/Samsung-GT-B3730-linux-driver ++ */ ++ ++/* #define DEBUG */ ++/* #define VERBOSE */ ++ ++#define KALMIA_HEADER_LENGTH 6 ++#define KALMIA_ALIGN_SIZE 4 ++#define KALMIA_USB_TIMEOUT 10000 ++ ++/*-------------------------------------------------------------------------*/ ++ ++static int ++kalmia_send_init_packet(struct usbnet *dev, u8 *init_msg, u8 init_msg_len, ++ u8 *buffer, u8 expected_len) ++{ ++ int act_len; ++ int status; ++ ++ netdev_dbg(dev->net, "Sending init packet"); ++ ++ status = usb_bulk_msg(dev->udev, usb_sndbulkpipe(dev->udev, 0x02), ++ init_msg, init_msg_len, &act_len, KALMIA_USB_TIMEOUT); ++ if (status != 0) { ++ netdev_err(dev->net, ++ "Error sending init packet. Status %i, length %i\n", ++ status, act_len); ++ return status; ++ } ++ else if (act_len != init_msg_len) { ++ netdev_err(dev->net, ++ "Did not send all of init packet. Bytes sent: %i", ++ act_len); ++ } ++ else { ++ netdev_dbg(dev->net, "Successfully sent init packet."); ++ } ++ ++ status = usb_bulk_msg(dev->udev, usb_rcvbulkpipe(dev->udev, 0x81), ++ buffer, expected_len, &act_len, KALMIA_USB_TIMEOUT); ++ ++ if (status != 0) ++ netdev_err(dev->net, ++ "Error receiving init result. Status %i, length %i\n", ++ status, act_len); ++ else if (act_len != expected_len) ++ netdev_err(dev->net, "Unexpected init result length: %i\n", ++ act_len); ++ ++ return status; ++} ++ ++static int ++kalmia_init_and_get_ethernet_addr(struct usbnet *dev, u8 *ethernet_addr) ++{ ++ static const char init_msg_1[] = ++ { 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, ++ 0x00, 0x00 }; ++ static const char init_msg_2[] = ++ { 0x57, 0x50, 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0xf4, ++ 0x00, 0x00 }; ++ static const int buflen = 28; ++ char *usb_buf; ++ int status; ++ ++ usb_buf = kmalloc(buflen, GFP_DMA | GFP_KERNEL); ++ if (!usb_buf) ++ return -ENOMEM; ++ ++ memcpy(usb_buf, init_msg_1, 12); ++ status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_1) ++ / sizeof(init_msg_1[0]), usb_buf, 24); ++ if (status != 0) ++ return status; ++ ++ memcpy(usb_buf, init_msg_2, 12); ++ status = kalmia_send_init_packet(dev, usb_buf, sizeof(init_msg_2) ++ / sizeof(init_msg_2[0]), usb_buf, 28); ++ if (status != 0) ++ return status; ++ ++ memcpy(ethernet_addr, usb_buf + 10, ETH_ALEN); ++ ++ kfree(usb_buf); ++ return status; ++} ++ ++static int ++kalmia_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int status; ++ u8 ethernet_addr[ETH_ALEN]; ++ ++ /* Don't bind to AT command interface */ ++ if (intf->cur_altsetting->desc.bInterfaceClass != USB_CLASS_VENDOR_SPEC) ++ return -EINVAL; ++ ++ dev->in = usb_rcvbulkpipe(dev->udev, 0x81 & USB_ENDPOINT_NUMBER_MASK); ++ dev->out = usb_sndbulkpipe(dev->udev, 0x02 & USB_ENDPOINT_NUMBER_MASK); ++ dev->status = NULL; ++ ++ dev->net->hard_header_len += KALMIA_HEADER_LENGTH; ++ dev->hard_mtu = 1400; ++ dev->rx_urb_size = dev->hard_mtu * 10; // Found as optimal after testing ++ ++ status = kalmia_init_and_get_ethernet_addr(dev, ethernet_addr); ++ ++ if (status < 0) { ++ usb_set_intfdata(intf, NULL); ++ usb_driver_release_interface(driver_of(intf), intf); ++ return status; ++ } ++ ++ memcpy(dev->net->dev_addr, ethernet_addr, ETH_ALEN); ++ ++ return status; ++} ++ ++static struct sk_buff * ++kalmia_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) ++{ ++ struct sk_buff *skb2 = NULL; ++ u16 content_len; ++ unsigned char *header_start; ++ unsigned char ether_type_1, ether_type_2; ++ u8 remainder, padlen = 0; ++ ++ if (!skb_cloned(skb)) { ++ int headroom = skb_headroom(skb); ++ int tailroom = skb_tailroom(skb); ++ ++ if ((tailroom >= KALMIA_ALIGN_SIZE) && (headroom ++ >= KALMIA_HEADER_LENGTH)) ++ goto done; ++ ++ if ((headroom + tailroom) > (KALMIA_HEADER_LENGTH ++ + KALMIA_ALIGN_SIZE)) { ++ skb->data = memmove(skb->head + KALMIA_HEADER_LENGTH, ++ skb->data, skb->len); ++ skb_set_tail_pointer(skb, skb->len); ++ goto done; ++ } ++ } ++ ++ skb2 = skb_copy_expand(skb, KALMIA_HEADER_LENGTH, ++ KALMIA_ALIGN_SIZE, flags); ++ if (!skb2) ++ return NULL; ++ ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ ++done: ++ header_start = skb_push(skb, KALMIA_HEADER_LENGTH); ++ ether_type_1 = header_start[KALMIA_HEADER_LENGTH + 12]; ++ ether_type_2 = header_start[KALMIA_HEADER_LENGTH + 13]; ++ ++ netdev_dbg(dev->net, "Sending etherType: %02x%02x", ether_type_1, ++ ether_type_2); ++ ++ /* According to empiric data for data packages */ ++ header_start[0] = 0x57; ++ header_start[1] = 0x44; ++ content_len = skb->len - KALMIA_HEADER_LENGTH; ++ ++ put_unaligned_le16(content_len, &header_start[2]); ++ header_start[4] = ether_type_1; ++ header_start[5] = ether_type_2; ++ ++ /* Align to 4 bytes by padding with zeros */ ++ remainder = skb->len % KALMIA_ALIGN_SIZE; ++ if (remainder > 0) { ++ padlen = KALMIA_ALIGN_SIZE - remainder; ++ memset(skb_put(skb, padlen), 0, padlen); ++ } ++ ++ netdev_dbg(dev->net, ++ "Sending package with length %i and padding %i. Header: %6phC.", ++ content_len, padlen, header_start); ++ ++ return skb; ++} ++ ++static int ++kalmia_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ /* ++ * Our task here is to strip off framing, leaving skb with one ++ * data frame for the usbnet framework code to process. ++ */ ++ static const u8 HEADER_END_OF_USB_PACKET[] = ++ { 0x57, 0x5a, 0x00, 0x00, 0x08, 0x00 }; ++ static const u8 EXPECTED_UNKNOWN_HEADER_1[] = ++ { 0x57, 0x43, 0x1e, 0x00, 0x15, 0x02 }; ++ static const u8 EXPECTED_UNKNOWN_HEADER_2[] = ++ { 0x57, 0x50, 0x0e, 0x00, 0x00, 0x00 }; ++ int i = 0; ++ ++ /* incomplete header? */ ++ if (skb->len < KALMIA_HEADER_LENGTH) ++ return 0; ++ ++ do { ++ struct sk_buff *skb2 = NULL; ++ u8 *header_start; ++ u16 usb_packet_length, ether_packet_length; ++ int is_last; ++ ++ header_start = skb->data; ++ ++ if (unlikely(header_start[0] != 0x57 || header_start[1] != 0x44)) { ++ if (!memcmp(header_start, EXPECTED_UNKNOWN_HEADER_1, ++ sizeof(EXPECTED_UNKNOWN_HEADER_1)) || !memcmp( ++ header_start, EXPECTED_UNKNOWN_HEADER_2, ++ sizeof(EXPECTED_UNKNOWN_HEADER_2))) { ++ netdev_dbg(dev->net, ++ "Received expected unknown frame header: %6phC. Package length: %i\n", ++ header_start, ++ skb->len - KALMIA_HEADER_LENGTH); ++ } ++ else { ++ netdev_err(dev->net, ++ "Received unknown frame header: %6phC. Package length: %i\n", ++ header_start, ++ skb->len - KALMIA_HEADER_LENGTH); ++ return 0; ++ } ++ } ++ else ++ netdev_dbg(dev->net, ++ "Received header: %6phC. Package length: %i\n", ++ header_start, skb->len - KALMIA_HEADER_LENGTH); ++ ++ /* subtract start header and end header */ ++ usb_packet_length = skb->len - (2 * KALMIA_HEADER_LENGTH); ++ ether_packet_length = get_unaligned_le16(&header_start[2]); ++ skb_pull(skb, KALMIA_HEADER_LENGTH); ++ ++ /* Some small packets misses end marker */ ++ if (usb_packet_length < ether_packet_length) { ++ ether_packet_length = usb_packet_length ++ + KALMIA_HEADER_LENGTH; ++ is_last = true; ++ } ++ else { ++ netdev_dbg(dev->net, "Correct package length #%i", i ++ + 1); ++ ++ is_last = (memcmp(skb->data + ether_packet_length, ++ HEADER_END_OF_USB_PACKET, ++ sizeof(HEADER_END_OF_USB_PACKET)) == 0); ++ if (!is_last) { ++ header_start = skb->data + ether_packet_length; ++ netdev_dbg(dev->net, ++ "End header: %6phC. Package length: %i\n", ++ header_start, ++ skb->len - KALMIA_HEADER_LENGTH); ++ } ++ } ++ ++ if (is_last) { ++ skb2 = skb; ++ } ++ else { ++ skb2 = skb_clone(skb, GFP_ATOMIC); ++ if (unlikely(!skb2)) ++ return 0; ++ } ++ ++ skb_trim(skb2, ether_packet_length); ++ ++ if (is_last) { ++ return 1; ++ } ++ else { ++ usbnet_skb_return(dev, skb2); ++ skb_pull(skb, ether_packet_length); ++ } ++ ++ i++; ++ } ++ while (skb->len); ++ ++ return 1; ++} ++ ++static const struct driver_info kalmia_info = { ++ .description = "Samsung Kalmia LTE USB dongle", ++ .flags = FLAG_WWAN, ++ .bind = kalmia_bind, ++ .rx_fixup = kalmia_rx_fixup, ++ .tx_fixup = kalmia_tx_fixup ++}; ++ ++/*-------------------------------------------------------------------------*/ ++ ++static const struct usb_device_id products[] = { ++ /* The unswitched USB ID, to get the module auto loaded: */ ++ { USB_DEVICE(0x04e8, 0x689a) }, ++ /* The stick swithed into modem (by e.g. usb_modeswitch): */ ++ { USB_DEVICE(0x04e8, 0x6889), ++ .driver_info = (unsigned long) &kalmia_info, }, ++ { /* EMPTY == end of list */} }; ++MODULE_DEVICE_TABLE( usb, products); ++ ++static struct usb_driver kalmia_driver = { ++ .name = "kalmia", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(kalmia_driver); ++ ++MODULE_AUTHOR("Marius Bjoernstad Kotsbak marius@kotsbak.com"); ++MODULE_DESCRIPTION("Samsung Kalmia USB network driver"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/kaweth.c backports-4.2.6-1/drivers/net/usb/kaweth.c +--- backports-4.2.6-1.org/drivers/net/usb/kaweth.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/kaweth.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,1331 @@ ++/**************************************************************** ++ * ++ * kaweth.c - driver for KL5KUSB101 based USB->Ethernet ++ * ++ * (c) 2000 Interlan Communications ++ * (c) 2000 Stephane Alnet ++ * (C) 2001 Brad Hards ++ * (C) 2002 Oliver Neukum ++ * ++ * Original author: The Zapman zapman@interlan.net ++ * Inspired by, and much credit goes to Michael Rothwell ++ * rothwell@interlan.net for the test equipment, help, and patience ++ * Based off of (and with thanks to) Petko Manolov's pegaus.c driver. ++ * Also many thanks to Joel Silverman and Ed Surprenant at Kawasaki ++ * for providing the firmware and driver resources. ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License as ++ * published by the Free Software Foundation; either version 2, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ * ++ ****************************************************************/ ++ ++/* TODO: ++ * Develop test procedures for USB net interfaces ++ * Run test procedures ++ * Fix bugs from previous two steps ++ * Snoop other OSs for any tricks we're not doing ++ * Reduce arbitrary timeouts ++ * Smart multicast support ++ * Temporary MAC change support ++ * Tunable SOFs parameter - ioctl()? ++ * Ethernet stats collection ++ * Code formatting improvements ++ */ ++ ++#include <linux/module.h> ++#include <linux/slab.h> ++#include <linux/string.h> ++#include <linux/delay.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/usb.h> ++#include <linux/types.h> ++#include <linux/ethtool.h> ++#include <linux/dma-mapping.h> ++#include <linux/wait.h> ++#include <linux/firmware.h> ++#include <asm/uaccess.h> ++#include <asm/byteorder.h> ++ ++#undef DEBUG ++ ++#define KAWETH_MTU 1514 ++#define KAWETH_BUF_SIZE 1664 ++#define KAWETH_TX_TIMEOUT (5 * HZ) ++#define KAWETH_SCRATCH_SIZE 32 ++#define KAWETH_FIRMWARE_BUF_SIZE 4096 ++#define KAWETH_CONTROL_TIMEOUT (30000) ++ ++#define KAWETH_STATUS_BROKEN 0x0000001 ++#define KAWETH_STATUS_CLOSING 0x0000002 ++#define KAWETH_STATUS_SUSPENDING 0x0000004 ++ ++#define KAWETH_STATUS_BLOCKED (KAWETH_STATUS_CLOSING | KAWETH_STATUS_SUSPENDING) ++ ++#define KAWETH_PACKET_FILTER_PROMISCUOUS 0x01 ++#define KAWETH_PACKET_FILTER_ALL_MULTICAST 0x02 ++#define KAWETH_PACKET_FILTER_DIRECTED 0x04 ++#define KAWETH_PACKET_FILTER_BROADCAST 0x08 ++#define KAWETH_PACKET_FILTER_MULTICAST 0x10 ++ ++/* Table 7 */ ++#define KAWETH_COMMAND_GET_ETHERNET_DESC 0x00 ++#define KAWETH_COMMAND_MULTICAST_FILTERS 0x01 ++#define KAWETH_COMMAND_SET_PACKET_FILTER 0x02 ++#define KAWETH_COMMAND_STATISTICS 0x03 ++#define KAWETH_COMMAND_SET_TEMP_MAC 0x06 ++#define KAWETH_COMMAND_GET_TEMP_MAC 0x07 ++#define KAWETH_COMMAND_SET_URB_SIZE 0x08 ++#define KAWETH_COMMAND_SET_SOFS_WAIT 0x09 ++#define KAWETH_COMMAND_SCAN 0xFF ++ ++#define KAWETH_SOFS_TO_WAIT 0x05 ++ ++#define INTBUFFERSIZE 4 ++ ++#define STATE_OFFSET 0 ++#define STATE_MASK 0x40 ++#define STATE_SHIFT 5 ++ ++#define IS_BLOCKED(s) (s & KAWETH_STATUS_BLOCKED) ++ ++ ++MODULE_AUTHOR("Michael Zappe zapman@interlan.net, Stephane Alnet stephane@u-picardie.fr, Brad Hards bhards@bigpond.net.au and Oliver Neukum oliver@neukum.org"); ++MODULE_DESCRIPTION("KL5USB101 USB Ethernet driver"); ++MODULE_LICENSE("GPL"); ++MODULE_FIRMWARE("kaweth/new_code.bin"); ++MODULE_FIRMWARE("kaweth/new_code_fix.bin"); ++MODULE_FIRMWARE("kaweth/trigger_code.bin"); ++MODULE_FIRMWARE("kaweth/trigger_code_fix.bin"); ++ ++static const char driver_name[] = "kaweth"; ++ ++static int kaweth_probe( ++ struct usb_interface *intf, ++ const struct usb_device_id *id /* from id_table */ ++ ); ++static void kaweth_disconnect(struct usb_interface *intf); ++static int kaweth_internal_control_msg(struct usb_device *usb_dev, ++ unsigned int pipe, ++ struct usb_ctrlrequest *cmd, void *data, ++ int len, int timeout); ++static int kaweth_suspend(struct usb_interface *intf, pm_message_t message); ++static int kaweth_resume(struct usb_interface *intf); ++ ++/**************************************************************** ++ * usb_device_id ++ ****************************************************************/ ++static struct usb_device_id usb_klsi_table[] = { ++ { USB_DEVICE(0x03e8, 0x0008) }, /* AOX Endpoints USB Ethernet */ ++ { USB_DEVICE(0x04bb, 0x0901) }, /* I-O DATA USB-ET/T */ ++ { USB_DEVICE(0x0506, 0x03e8) }, /* 3Com 3C19250 */ ++ { USB_DEVICE(0x0506, 0x11f8) }, /* 3Com 3C460 */ ++ { USB_DEVICE(0x0557, 0x2002) }, /* ATEN USB Ethernet */ ++ { USB_DEVICE(0x0557, 0x4000) }, /* D-Link DSB-650C */ ++ { USB_DEVICE(0x0565, 0x0002) }, /* Peracom Enet */ ++ { USB_DEVICE(0x0565, 0x0003) }, /* Optus@Home UEP1045A */ ++ { USB_DEVICE(0x0565, 0x0005) }, /* Peracom Enet2 */ ++ { USB_DEVICE(0x05e9, 0x0008) }, /* KLSI KL5KUSB101B */ ++ { USB_DEVICE(0x05e9, 0x0009) }, /* KLSI KL5KUSB101B (Board change) */ ++ { USB_DEVICE(0x066b, 0x2202) }, /* Linksys USB10T */ ++ { USB_DEVICE(0x06e1, 0x0008) }, /* ADS USB-10BT */ ++ { USB_DEVICE(0x06e1, 0x0009) }, /* ADS USB-10BT */ ++ { USB_DEVICE(0x0707, 0x0100) }, /* SMC 2202USB */ ++ { USB_DEVICE(0x07aa, 0x0001) }, /* Correga K.K. */ ++ { USB_DEVICE(0x07b8, 0x4000) }, /* D-Link DU-E10 */ ++ { USB_DEVICE(0x07c9, 0xb010) }, /* Allied Telesyn AT-USB10 USB Ethernet Adapter */ ++ { USB_DEVICE(0x0846, 0x1001) }, /* NetGear EA-101 */ ++ { USB_DEVICE(0x0846, 0x1002) }, /* NetGear EA-101 */ ++ { USB_DEVICE(0x085a, 0x0008) }, /* PortGear Ethernet Adapter */ ++ { USB_DEVICE(0x085a, 0x0009) }, /* PortGear Ethernet Adapter */ ++ { USB_DEVICE(0x087d, 0x5704) }, /* Jaton USB Ethernet Device Adapter */ ++ { USB_DEVICE(0x0951, 0x0008) }, /* Kingston Technology USB Ethernet Adapter */ ++ { USB_DEVICE(0x095a, 0x3003) }, /* Portsmith Express Ethernet Adapter */ ++ { USB_DEVICE(0x10bd, 0x1427) }, /* ASANTE USB To Ethernet Adapter */ ++ { USB_DEVICE(0x1342, 0x0204) }, /* Mobility USB-Ethernet Adapter */ ++ { USB_DEVICE(0x13d2, 0x0400) }, /* Shark Pocket Adapter */ ++ { USB_DEVICE(0x1485, 0x0001) }, /* Silicom U2E */ ++ { USB_DEVICE(0x1485, 0x0002) }, /* Psion Dacom Gold Port Ethernet */ ++ { USB_DEVICE(0x1645, 0x0005) }, /* Entrega E45 */ ++ { USB_DEVICE(0x1645, 0x0008) }, /* Entrega USB Ethernet Adapter */ ++ { USB_DEVICE(0x1645, 0x8005) }, /* PortGear Ethernet Adapter */ ++ { USB_DEVICE(0x1668, 0x0323) }, /* Actiontec USB Ethernet */ ++ { USB_DEVICE(0x2001, 0x4000) }, /* D-link DSB-650C */ ++ {} /* Null terminator */ ++}; ++ ++MODULE_DEVICE_TABLE (usb, usb_klsi_table); ++ ++/**************************************************************** ++ * kaweth_driver ++ ****************************************************************/ ++static struct usb_driver kaweth_driver = { ++ .name = driver_name, ++ .probe = kaweth_probe, ++ .disconnect = kaweth_disconnect, ++ .suspend = kaweth_suspend, ++ .resume = kaweth_resume, ++ .id_table = usb_klsi_table, ++ .supports_autosuspend = 1, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++typedef __u8 eth_addr_t[6]; ++ ++/**************************************************************** ++ * usb_eth_dev ++ ****************************************************************/ ++struct usb_eth_dev { ++ char *name; ++ __u16 vendor; ++ __u16 device; ++ void *pdata; ++}; ++ ++/**************************************************************** ++ * kaweth_ethernet_configuration ++ * Refer Table 8 ++ ****************************************************************/ ++struct kaweth_ethernet_configuration ++{ ++ __u8 size; ++ __u8 reserved1; ++ __u8 reserved2; ++ eth_addr_t hw_addr; ++ __u32 statistics_mask; ++ __le16 segment_size; ++ __u16 max_multicast_filters; ++ __u8 reserved3; ++} __packed; ++ ++/**************************************************************** ++ * kaweth_device ++ ****************************************************************/ ++struct kaweth_device ++{ ++ spinlock_t device_lock; ++ ++ __u32 status; ++ int end; ++ int suspend_lowmem_rx; ++ int suspend_lowmem_ctrl; ++ int linkstate; ++ int opened; ++ struct delayed_work lowmem_work; ++ ++ struct usb_device *dev; ++ struct usb_interface *intf; ++ struct net_device *net; ++ wait_queue_head_t term_wait; ++ ++ struct urb *rx_urb; ++ struct urb *tx_urb; ++ struct urb *irq_urb; ++ ++ dma_addr_t intbufferhandle; ++ __u8 *intbuffer; ++ dma_addr_t rxbufferhandle; ++ __u8 *rx_buf; ++ ++ ++ struct sk_buff *tx_skb; ++ ++ __u8 *firmware_buf; ++ __u8 scratch[KAWETH_SCRATCH_SIZE]; ++ __u16 packet_filter_bitmap; ++ ++ struct kaweth_ethernet_configuration configuration; ++ ++ struct net_device_stats stats; ++}; ++ ++/**************************************************************** ++ * kaweth_control ++ ****************************************************************/ ++static int kaweth_control(struct kaweth_device *kaweth, ++ unsigned int pipe, ++ __u8 request, ++ __u8 requesttype, ++ __u16 value, ++ __u16 index, ++ void *data, ++ __u16 size, ++ int timeout) ++{ ++ struct usb_ctrlrequest *dr; ++ int retval; ++ ++ netdev_dbg(kaweth->net, "kaweth_control()\n"); ++ ++ if(in_interrupt()) { ++ netdev_dbg(kaweth->net, "in_interrupt()\n"); ++ return -EBUSY; ++ } ++ ++ dr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); ++ if (!dr) ++ return -ENOMEM; ++ ++ dr->bRequestType = requesttype; ++ dr->bRequest = request; ++ dr->wValue = cpu_to_le16(value); ++ dr->wIndex = cpu_to_le16(index); ++ dr->wLength = cpu_to_le16(size); ++ ++ retval = kaweth_internal_control_msg(kaweth->dev, ++ pipe, ++ dr, ++ data, ++ size, ++ timeout); ++ ++ kfree(dr); ++ return retval; ++} ++ ++/**************************************************************** ++ * kaweth_read_configuration ++ ****************************************************************/ ++static int kaweth_read_configuration(struct kaweth_device *kaweth) ++{ ++ int retval; ++ ++ netdev_dbg(kaweth->net, "Reading kaweth configuration\n"); ++ ++ retval = kaweth_control(kaweth, ++ usb_rcvctrlpipe(kaweth->dev, 0), ++ KAWETH_COMMAND_GET_ETHERNET_DESC, ++ USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_DEVICE, ++ 0, ++ 0, ++ (void *)&kaweth->configuration, ++ sizeof(kaweth->configuration), ++ KAWETH_CONTROL_TIMEOUT); ++ ++ return retval; ++} ++ ++/**************************************************************** ++ * kaweth_set_urb_size ++ ****************************************************************/ ++static int kaweth_set_urb_size(struct kaweth_device *kaweth, __u16 urb_size) ++{ ++ int retval; ++ ++ netdev_dbg(kaweth->net, "Setting URB size to %d\n", (unsigned)urb_size); ++ ++ retval = kaweth_control(kaweth, ++ usb_sndctrlpipe(kaweth->dev, 0), ++ KAWETH_COMMAND_SET_URB_SIZE, ++ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, ++ urb_size, ++ 0, ++ (void *)&kaweth->scratch, ++ 0, ++ KAWETH_CONTROL_TIMEOUT); ++ ++ return retval; ++} ++ ++/**************************************************************** ++ * kaweth_set_sofs_wait ++ ****************************************************************/ ++static int kaweth_set_sofs_wait(struct kaweth_device *kaweth, __u16 sofs_wait) ++{ ++ int retval; ++ ++ netdev_dbg(kaweth->net, "Set SOFS wait to %d\n", (unsigned)sofs_wait); ++ ++ retval = kaweth_control(kaweth, ++ usb_sndctrlpipe(kaweth->dev, 0), ++ KAWETH_COMMAND_SET_SOFS_WAIT, ++ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, ++ sofs_wait, ++ 0, ++ (void *)&kaweth->scratch, ++ 0, ++ KAWETH_CONTROL_TIMEOUT); ++ ++ return retval; ++} ++ ++/**************************************************************** ++ * kaweth_set_receive_filter ++ ****************************************************************/ ++static int kaweth_set_receive_filter(struct kaweth_device *kaweth, ++ __u16 receive_filter) ++{ ++ int retval; ++ ++ netdev_dbg(kaweth->net, "Set receive filter to %d\n", ++ (unsigned)receive_filter); ++ ++ retval = kaweth_control(kaweth, ++ usb_sndctrlpipe(kaweth->dev, 0), ++ KAWETH_COMMAND_SET_PACKET_FILTER, ++ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, ++ receive_filter, ++ 0, ++ (void *)&kaweth->scratch, ++ 0, ++ KAWETH_CONTROL_TIMEOUT); ++ ++ return retval; ++} ++ ++/**************************************************************** ++ * kaweth_download_firmware ++ ****************************************************************/ ++static int kaweth_download_firmware(struct kaweth_device *kaweth, ++ const char *fwname, ++ __u8 interrupt, ++ __u8 type) ++{ ++ const struct firmware *fw; ++ int data_len; ++ int ret; ++ ++ ret = request_firmware(&fw, fwname, &kaweth->dev->dev); ++ if (ret) { ++ dev_err(&kaweth->intf->dev, "Firmware request failed\n"); ++ return ret; ++ } ++ ++ if (fw->size > KAWETH_FIRMWARE_BUF_SIZE) { ++ dev_err(&kaweth->intf->dev, "Firmware too big: %zu\n", ++ fw->size); ++ release_firmware(fw); ++ return -ENOSPC; ++ } ++ data_len = fw->size; ++ memcpy(kaweth->firmware_buf, fw->data, fw->size); ++ ++ release_firmware(fw); ++ ++ kaweth->firmware_buf[2] = (data_len & 0xFF) - 7; ++ kaweth->firmware_buf[3] = data_len >> 8; ++ kaweth->firmware_buf[4] = type; ++ kaweth->firmware_buf[5] = interrupt; ++ ++ netdev_dbg(kaweth->net, "High: %i, Low:%i\n", kaweth->firmware_buf[3], ++ kaweth->firmware_buf[2]); ++ ++ netdev_dbg(kaweth->net, ++ "Downloading firmware at %p to kaweth device at %p\n", ++ kaweth->firmware_buf, kaweth); ++ netdev_dbg(kaweth->net, "Firmware length: %d\n", data_len); ++ ++ return kaweth_control(kaweth, ++ usb_sndctrlpipe(kaweth->dev, 0), ++ KAWETH_COMMAND_SCAN, ++ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, ++ 0, ++ 0, ++ (void *)kaweth->firmware_buf, ++ data_len, ++ KAWETH_CONTROL_TIMEOUT); ++} ++ ++/**************************************************************** ++ * kaweth_trigger_firmware ++ ****************************************************************/ ++static int kaweth_trigger_firmware(struct kaweth_device *kaweth, ++ __u8 interrupt) ++{ ++ kaweth->firmware_buf[0] = 0xB6; ++ kaweth->firmware_buf[1] = 0xC3; ++ kaweth->firmware_buf[2] = 0x01; ++ kaweth->firmware_buf[3] = 0x00; ++ kaweth->firmware_buf[4] = 0x06; ++ kaweth->firmware_buf[5] = interrupt; ++ kaweth->firmware_buf[6] = 0x00; ++ kaweth->firmware_buf[7] = 0x00; ++ ++ netdev_dbg(kaweth->net, "Triggering firmware\n"); ++ ++ return kaweth_control(kaweth, ++ usb_sndctrlpipe(kaweth->dev, 0), ++ KAWETH_COMMAND_SCAN, ++ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, ++ 0, ++ 0, ++ (void *)kaweth->firmware_buf, ++ 8, ++ KAWETH_CONTROL_TIMEOUT); ++} ++ ++/**************************************************************** ++ * kaweth_reset ++ ****************************************************************/ ++static int kaweth_reset(struct kaweth_device *kaweth) ++{ ++ int result; ++ ++ netdev_dbg(kaweth->net, "kaweth_reset(%p)\n", kaweth); ++ result = usb_reset_configuration(kaweth->dev); ++ mdelay(10); ++ ++ netdev_dbg(kaweth->net, "kaweth_reset() returns %d.\n", result); ++ ++ return result; ++} ++ ++static void kaweth_usb_receive(struct urb *); ++static int kaweth_resubmit_rx_urb(struct kaweth_device *, gfp_t); ++ ++/**************************************************************** ++ int_callback ++*****************************************************************/ ++ ++static void kaweth_resubmit_int_urb(struct kaweth_device *kaweth, gfp_t mf) ++{ ++ int status; ++ ++ status = usb_submit_urb (kaweth->irq_urb, mf); ++ if (unlikely(status == -ENOMEM)) { ++ kaweth->suspend_lowmem_ctrl = 1; ++ schedule_delayed_work(&kaweth->lowmem_work, HZ/4); ++ } else { ++ kaweth->suspend_lowmem_ctrl = 0; ++ } ++ ++ if (status) ++ dev_err(&kaweth->intf->dev, ++ "can't resubmit intr, %s-%s, status %d\n", ++ kaweth->dev->bus->bus_name, ++ kaweth->dev->devpath, status); ++} ++ ++static void int_callback(struct urb *u) ++{ ++ struct kaweth_device *kaweth = u->context; ++ int act_state; ++ int status = u->status; ++ ++ switch (status) { ++ case 0: /* success */ ++ break; ++ case -ECONNRESET: /* unlink */ ++ case -ENOENT: ++ case -ESHUTDOWN: ++ return; ++ /* -EPIPE: should clear the halt */ ++ default: /* error */ ++ goto resubmit; ++ } ++ ++ /* we check the link state to report changes */ ++ if (kaweth->linkstate != (act_state = ( kaweth->intbuffer[STATE_OFFSET] | STATE_MASK) >> STATE_SHIFT)) { ++ if (act_state) ++ netif_carrier_on(kaweth->net); ++ else ++ netif_carrier_off(kaweth->net); ++ ++ kaweth->linkstate = act_state; ++ } ++resubmit: ++ kaweth_resubmit_int_urb(kaweth, GFP_ATOMIC); ++} ++ ++static void kaweth_resubmit_tl(struct work_struct *work) ++{ ++ struct kaweth_device *kaweth = ++ container_of(work, struct kaweth_device, lowmem_work.work); ++ ++ if (IS_BLOCKED(kaweth->status)) ++ return; ++ ++ if (kaweth->suspend_lowmem_rx) ++ kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); ++ ++ if (kaweth->suspend_lowmem_ctrl) ++ kaweth_resubmit_int_urb(kaweth, GFP_NOIO); ++} ++ ++ ++/**************************************************************** ++ * kaweth_resubmit_rx_urb ++ ****************************************************************/ ++static int kaweth_resubmit_rx_urb(struct kaweth_device *kaweth, ++ gfp_t mem_flags) ++{ ++ int result; ++ ++ usb_fill_bulk_urb(kaweth->rx_urb, ++ kaweth->dev, ++ usb_rcvbulkpipe(kaweth->dev, 1), ++ kaweth->rx_buf, ++ KAWETH_BUF_SIZE, ++ kaweth_usb_receive, ++ kaweth); ++ kaweth->rx_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ++ kaweth->rx_urb->transfer_dma = kaweth->rxbufferhandle; ++ ++ if((result = usb_submit_urb(kaweth->rx_urb, mem_flags))) { ++ if (result == -ENOMEM) { ++ kaweth->suspend_lowmem_rx = 1; ++ schedule_delayed_work(&kaweth->lowmem_work, HZ/4); ++ } ++ dev_err(&kaweth->intf->dev, "resubmitting rx_urb %d failed\n", ++ result); ++ } else { ++ kaweth->suspend_lowmem_rx = 0; ++ } ++ ++ return result; ++} ++ ++static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth); ++ ++/**************************************************************** ++ * kaweth_usb_receive ++ ****************************************************************/ ++static void kaweth_usb_receive(struct urb *urb) ++{ ++ struct device *dev = &urb->dev->dev; ++ struct kaweth_device *kaweth = urb->context; ++ struct net_device *net = kaweth->net; ++ int status = urb->status; ++ ++ int count = urb->actual_length; ++ int count2 = urb->transfer_buffer_length; ++ ++ __u16 pkt_len = le16_to_cpup((__le16 *)kaweth->rx_buf); ++ ++ struct sk_buff *skb; ++ ++ if (unlikely(status == -EPIPE)) { ++ kaweth->stats.rx_errors++; ++ kaweth->end = 1; ++ wake_up(&kaweth->term_wait); ++ dev_dbg(dev, "Status was -EPIPE.\n"); ++ return; ++ } ++ if (unlikely(status == -ECONNRESET || status == -ESHUTDOWN)) { ++ /* we are killed - set a flag and wake the disconnect handler */ ++ kaweth->end = 1; ++ wake_up(&kaweth->term_wait); ++ dev_dbg(dev, "Status was -ECONNRESET or -ESHUTDOWN.\n"); ++ return; ++ } ++ if (unlikely(status == -EPROTO || status == -ETIME || ++ status == -EILSEQ)) { ++ kaweth->stats.rx_errors++; ++ dev_dbg(dev, "Status was -EPROTO, -ETIME, or -EILSEQ.\n"); ++ return; ++ } ++ if (unlikely(status == -EOVERFLOW)) { ++ kaweth->stats.rx_errors++; ++ dev_dbg(dev, "Status was -EOVERFLOW.\n"); ++ } ++ spin_lock(&kaweth->device_lock); ++ if (IS_BLOCKED(kaweth->status)) { ++ spin_unlock(&kaweth->device_lock); ++ return; ++ } ++ spin_unlock(&kaweth->device_lock); ++ ++ if(status && status != -EREMOTEIO && count != 1) { ++ dev_err(&kaweth->intf->dev, ++ "%s RX status: %d count: %d packet_len: %d\n", ++ net->name, status, count, (int)pkt_len); ++ kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); ++ return; ++ } ++ ++ if(kaweth->net && (count > 2)) { ++ if(pkt_len > (count - 2)) { ++ dev_err(&kaweth->intf->dev, ++ "Packet length too long for USB frame (pkt_len: %x, count: %x)\n", ++ pkt_len, count); ++ dev_err(&kaweth->intf->dev, "Packet len & 2047: %x\n", ++ pkt_len & 2047); ++ dev_err(&kaweth->intf->dev, "Count 2: %x\n", count2); ++ kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); ++ return; ++ } ++ ++ if(!(skb = dev_alloc_skb(pkt_len+2))) { ++ kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); ++ return; ++ } ++ ++ skb_reserve(skb, 2); /* Align IP on 16 byte boundaries */ ++ ++ skb_copy_to_linear_data(skb, kaweth->rx_buf + 2, pkt_len); ++ ++ skb_put(skb, pkt_len); ++ ++ skb->protocol = eth_type_trans(skb, net); ++ ++ netif_rx(skb); ++ ++ kaweth->stats.rx_packets++; ++ kaweth->stats.rx_bytes += pkt_len; ++ } ++ ++ kaweth_resubmit_rx_urb(kaweth, GFP_ATOMIC); ++} ++ ++/**************************************************************** ++ * kaweth_open ++ ****************************************************************/ ++static int kaweth_open(struct net_device *net) ++{ ++ struct kaweth_device *kaweth = netdev_priv(net); ++ int res; ++ ++ netdev_dbg(kaweth->net, "Opening network device.\n"); ++ ++ res = usb_autopm_get_interface(kaweth->intf); ++ if (res) { ++ dev_err(&kaweth->intf->dev, "Interface cannot be resumed.\n"); ++ return -EIO; ++ } ++ res = kaweth_resubmit_rx_urb(kaweth, GFP_KERNEL); ++ if (res) ++ goto err_out; ++ ++ usb_fill_int_urb( ++ kaweth->irq_urb, ++ kaweth->dev, ++ usb_rcvintpipe(kaweth->dev, 3), ++ kaweth->intbuffer, ++ INTBUFFERSIZE, ++ int_callback, ++ kaweth, ++ 250); /* overriding the descriptor */ ++ kaweth->irq_urb->transfer_dma = kaweth->intbufferhandle; ++ kaweth->irq_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; ++ ++ res = usb_submit_urb(kaweth->irq_urb, GFP_KERNEL); ++ if (res) { ++ usb_kill_urb(kaweth->rx_urb); ++ goto err_out; ++ } ++ kaweth->opened = 1; ++ ++ netif_start_queue(net); ++ ++ kaweth_async_set_rx_mode(kaweth); ++ return 0; ++ ++err_out: ++ usb_autopm_put_interface(kaweth->intf); ++ return -EIO; ++} ++ ++/**************************************************************** ++ * kaweth_kill_urbs ++ ****************************************************************/ ++static void kaweth_kill_urbs(struct kaweth_device *kaweth) ++{ ++ usb_kill_urb(kaweth->irq_urb); ++ usb_kill_urb(kaweth->rx_urb); ++ usb_kill_urb(kaweth->tx_urb); ++ ++ cancel_delayed_work_sync(&kaweth->lowmem_work); ++ ++ /* a scheduled work may have resubmitted, ++ we hit them again */ ++ usb_kill_urb(kaweth->irq_urb); ++ usb_kill_urb(kaweth->rx_urb); ++} ++ ++/**************************************************************** ++ * kaweth_close ++ ****************************************************************/ ++static int kaweth_close(struct net_device *net) ++{ ++ struct kaweth_device *kaweth = netdev_priv(net); ++ ++ netif_stop_queue(net); ++ kaweth->opened = 0; ++ ++ kaweth->status |= KAWETH_STATUS_CLOSING; ++ ++ kaweth_kill_urbs(kaweth); ++ ++ kaweth->status &= ~KAWETH_STATUS_CLOSING; ++ ++ usb_autopm_put_interface(kaweth->intf); ++ ++ return 0; ++} ++ ++static u32 kaweth_get_link(struct net_device *dev) ++{ ++ struct kaweth_device *kaweth = netdev_priv(dev); ++ ++ return kaweth->linkstate; ++} ++ ++static const struct ethtool_ops ops = { ++ .get_link = kaweth_get_link ++}; ++ ++/**************************************************************** ++ * kaweth_usb_transmit_complete ++ ****************************************************************/ ++static void kaweth_usb_transmit_complete(struct urb *urb) ++{ ++ struct kaweth_device *kaweth = urb->context; ++ struct sk_buff *skb = kaweth->tx_skb; ++ int status = urb->status; ++ ++ if (unlikely(status != 0)) ++ if (status != -ENOENT) ++ dev_dbg(&urb->dev->dev, "%s: TX status %d.\n", ++ kaweth->net->name, status); ++ ++ netif_wake_queue(kaweth->net); ++ dev_kfree_skb_irq(skb); ++} ++ ++/**************************************************************** ++ * kaweth_start_xmit ++ ****************************************************************/ ++static netdev_tx_t kaweth_start_xmit(struct sk_buff *skb, ++ struct net_device *net) ++{ ++ struct kaweth_device *kaweth = netdev_priv(net); ++ __le16 *private_header; ++ ++ int res; ++ ++ spin_lock_irq(&kaweth->device_lock); ++ ++ kaweth_async_set_rx_mode(kaweth); ++ netif_stop_queue(net); ++ if (IS_BLOCKED(kaweth->status)) { ++ goto skip; ++ } ++ ++ /* We now decide whether we can put our special header into the sk_buff */ ++ if (skb_cloned(skb) || skb_headroom(skb) < 2) { ++ /* no such luck - we make our own */ ++ struct sk_buff *copied_skb; ++ copied_skb = skb_copy_expand(skb, 2, 0, GFP_ATOMIC); ++ dev_kfree_skb_irq(skb); ++ skb = copied_skb; ++ if (!copied_skb) { ++ kaweth->stats.tx_errors++; ++ netif_start_queue(net); ++ spin_unlock_irq(&kaweth->device_lock); ++ return NETDEV_TX_OK; ++ } ++ } ++ ++ private_header = (__le16 *)__skb_push(skb, 2); ++ *private_header = cpu_to_le16(skb->len-2); ++ kaweth->tx_skb = skb; ++ ++ usb_fill_bulk_urb(kaweth->tx_urb, ++ kaweth->dev, ++ usb_sndbulkpipe(kaweth->dev, 2), ++ private_header, ++ skb->len, ++ kaweth_usb_transmit_complete, ++ kaweth); ++ kaweth->end = 0; ++ ++ if((res = usb_submit_urb(kaweth->tx_urb, GFP_ATOMIC))) ++ { ++ dev_warn(&net->dev, "kaweth failed tx_urb %d\n", res); ++skip: ++ kaweth->stats.tx_errors++; ++ ++ netif_start_queue(net); ++ dev_kfree_skb_irq(skb); ++ } ++ else ++ { ++ kaweth->stats.tx_packets++; ++ kaweth->stats.tx_bytes += skb->len; ++ } ++ ++ spin_unlock_irq(&kaweth->device_lock); ++ ++ return NETDEV_TX_OK; ++} ++ ++/**************************************************************** ++ * kaweth_set_rx_mode ++ ****************************************************************/ ++static void kaweth_set_rx_mode(struct net_device *net) ++{ ++ struct kaweth_device *kaweth = netdev_priv(net); ++ ++ __u16 packet_filter_bitmap = KAWETH_PACKET_FILTER_DIRECTED | ++ KAWETH_PACKET_FILTER_BROADCAST | ++ KAWETH_PACKET_FILTER_MULTICAST; ++ ++ netdev_dbg(net, "Setting Rx mode to %d\n", packet_filter_bitmap); ++ ++ netif_stop_queue(net); ++ ++ if (net->flags & IFF_PROMISC) { ++ packet_filter_bitmap |= KAWETH_PACKET_FILTER_PROMISCUOUS; ++ } ++ else if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI)) { ++ packet_filter_bitmap |= KAWETH_PACKET_FILTER_ALL_MULTICAST; ++ } ++ ++ kaweth->packet_filter_bitmap = packet_filter_bitmap; ++ netif_wake_queue(net); ++} ++ ++/**************************************************************** ++ * kaweth_async_set_rx_mode ++ ****************************************************************/ ++static void kaweth_async_set_rx_mode(struct kaweth_device *kaweth) ++{ ++ int result; ++ __u16 packet_filter_bitmap = kaweth->packet_filter_bitmap; ++ ++ kaweth->packet_filter_bitmap = 0; ++ if (packet_filter_bitmap == 0) ++ return; ++ ++ if (in_interrupt()) ++ return; ++ ++ result = kaweth_control(kaweth, ++ usb_sndctrlpipe(kaweth->dev, 0), ++ KAWETH_COMMAND_SET_PACKET_FILTER, ++ USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, ++ packet_filter_bitmap, ++ 0, ++ (void *)&kaweth->scratch, ++ 0, ++ KAWETH_CONTROL_TIMEOUT); ++ ++ if(result < 0) { ++ dev_err(&kaweth->intf->dev, "Failed to set Rx mode: %d\n", ++ result); ++ } ++ else { ++ netdev_dbg(kaweth->net, "Set Rx mode to %d\n", ++ packet_filter_bitmap); ++ } ++} ++ ++/**************************************************************** ++ * kaweth_netdev_stats ++ ****************************************************************/ ++static struct net_device_stats *kaweth_netdev_stats(struct net_device *dev) ++{ ++ struct kaweth_device *kaweth = netdev_priv(dev); ++ return &kaweth->stats; ++} ++ ++/**************************************************************** ++ * kaweth_tx_timeout ++ ****************************************************************/ ++static void kaweth_tx_timeout(struct net_device *net) ++{ ++ struct kaweth_device *kaweth = netdev_priv(net); ++ ++ dev_warn(&net->dev, "%s: Tx timed out. Resetting.\n", net->name); ++ kaweth->stats.tx_errors++; ++ net->trans_start = jiffies; ++ ++ usb_unlink_urb(kaweth->tx_urb); ++} ++ ++/**************************************************************** ++ * kaweth_suspend ++ ****************************************************************/ ++static int kaweth_suspend(struct usb_interface *intf, pm_message_t message) ++{ ++ struct kaweth_device *kaweth = usb_get_intfdata(intf); ++ unsigned long flags; ++ ++ dev_dbg(&intf->dev, "Suspending device\n"); ++ spin_lock_irqsave(&kaweth->device_lock, flags); ++ kaweth->status |= KAWETH_STATUS_SUSPENDING; ++ spin_unlock_irqrestore(&kaweth->device_lock, flags); ++ ++ kaweth_kill_urbs(kaweth); ++ return 0; ++} ++ ++/**************************************************************** ++ * kaweth_resume ++ ****************************************************************/ ++static int kaweth_resume(struct usb_interface *intf) ++{ ++ struct kaweth_device *kaweth = usb_get_intfdata(intf); ++ unsigned long flags; ++ ++ dev_dbg(&intf->dev, "Resuming device\n"); ++ spin_lock_irqsave(&kaweth->device_lock, flags); ++ kaweth->status &= ~KAWETH_STATUS_SUSPENDING; ++ spin_unlock_irqrestore(&kaweth->device_lock, flags); ++ ++ if (!kaweth->opened) ++ return 0; ++ kaweth_resubmit_rx_urb(kaweth, GFP_NOIO); ++ kaweth_resubmit_int_urb(kaweth, GFP_NOIO); ++ ++ return 0; ++} ++ ++/**************************************************************** ++ * kaweth_probe ++ ****************************************************************/ ++ ++ ++static const struct net_device_ops kaweth_netdev_ops = { ++ .ndo_open = kaweth_open, ++ .ndo_stop = kaweth_close, ++ .ndo_start_xmit = kaweth_start_xmit, ++ .ndo_tx_timeout = kaweth_tx_timeout, ++ .ndo_set_rx_mode = kaweth_set_rx_mode, ++ .ndo_get_stats = kaweth_netdev_stats, ++ .ndo_change_mtu = eth_change_mtu, ++ .ndo_set_mac_address = eth_mac_addr, ++ .ndo_validate_addr = eth_validate_addr, ++}; ++ ++static int kaweth_probe( ++ struct usb_interface *intf, ++ const struct usb_device_id *id /* from id_table */ ++ ) ++{ ++ struct device *dev = &intf->dev; ++ struct usb_device *udev = interface_to_usbdev(intf); ++ struct kaweth_device *kaweth; ++ struct net_device *netdev; ++ const eth_addr_t bcast_addr = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF }; ++ int result = 0; ++ ++ dev_dbg(dev, ++ "Kawasaki Device Probe (Device number:%d): 0x%4.4x:0x%4.4x:0x%4.4x\n", ++ udev->devnum, le16_to_cpu(udev->descriptor.idVendor), ++ le16_to_cpu(udev->descriptor.idProduct), ++ le16_to_cpu(udev->descriptor.bcdDevice)); ++ ++ dev_dbg(dev, "Device at %p\n", udev); ++ ++ dev_dbg(dev, "Descriptor length: %x type: %x\n", ++ (int)udev->descriptor.bLength, ++ (int)udev->descriptor.bDescriptorType); ++ ++ netdev = alloc_etherdev(sizeof(*kaweth)); ++ if (!netdev) ++ return -ENOMEM; ++ ++ kaweth = netdev_priv(netdev); ++ kaweth->dev = udev; ++ kaweth->net = netdev; ++ ++ spin_lock_init(&kaweth->device_lock); ++ init_waitqueue_head(&kaweth->term_wait); ++ ++ dev_dbg(dev, "Resetting.\n"); ++ ++ kaweth_reset(kaweth); ++ ++ /* ++ * If high byte of bcdDevice is nonzero, firmware is already ++ * downloaded. Don't try to do it again, or we'll hang the device. ++ */ ++ ++ if (le16_to_cpu(udev->descriptor.bcdDevice) >> 8) { ++ dev_info(dev, "Firmware present in device.\n"); ++ } else { ++ /* Download the firmware */ ++ dev_info(dev, "Downloading firmware...\n"); ++ kaweth->firmware_buf = (__u8 *)__get_free_page(GFP_KERNEL); ++ if ((result = kaweth_download_firmware(kaweth, ++ "kaweth/new_code.bin", ++ 100, ++ 2)) < 0) { ++ dev_err(dev, "Error downloading firmware (%d)\n", ++ result); ++ goto err_fw; ++ } ++ ++ if ((result = kaweth_download_firmware(kaweth, ++ "kaweth/new_code_fix.bin", ++ 100, ++ 3)) < 0) { ++ dev_err(dev, "Error downloading firmware fix (%d)\n", ++ result); ++ goto err_fw; ++ } ++ ++ if ((result = kaweth_download_firmware(kaweth, ++ "kaweth/trigger_code.bin", ++ 126, ++ 2)) < 0) { ++ dev_err(dev, "Error downloading trigger code (%d)\n", ++ result); ++ goto err_fw; ++ ++ } ++ ++ if ((result = kaweth_download_firmware(kaweth, ++ "kaweth/trigger_code_fix.bin", ++ 126, ++ 3)) < 0) { ++ dev_err(dev, "Error downloading trigger code fix (%d)\n", result); ++ goto err_fw; ++ } ++ ++ ++ if ((result = kaweth_trigger_firmware(kaweth, 126)) < 0) { ++ dev_err(dev, "Error triggering firmware (%d)\n", result); ++ goto err_fw; ++ } ++ ++ /* Device will now disappear for a moment... */ ++ dev_info(dev, "Firmware loaded. I'll be back...\n"); ++err_fw: ++ free_page((unsigned long)kaweth->firmware_buf); ++ free_netdev(netdev); ++ return -EIO; ++ } ++ ++ result = kaweth_read_configuration(kaweth); ++ ++ if(result < 0) { ++ dev_err(dev, "Error reading configuration (%d), no net device created\n", result); ++ goto err_free_netdev; ++ } ++ ++ dev_info(dev, "Statistics collection: %x\n", kaweth->configuration.statistics_mask); ++ dev_info(dev, "Multicast filter limit: %x\n", kaweth->configuration.max_multicast_filters & ((1 << 15) - 1)); ++ dev_info(dev, "MTU: %d\n", le16_to_cpu(kaweth->configuration.segment_size)); ++ dev_info(dev, "Read MAC address %pM\n", kaweth->configuration.hw_addr); ++ ++ if(!memcmp(&kaweth->configuration.hw_addr, ++ &bcast_addr, ++ sizeof(bcast_addr))) { ++ dev_err(dev, "Firmware not functioning properly, no net device created\n"); ++ goto err_free_netdev; ++ } ++ ++ if(kaweth_set_urb_size(kaweth, KAWETH_BUF_SIZE) < 0) { ++ dev_dbg(dev, "Error setting URB size\n"); ++ goto err_free_netdev; ++ } ++ ++ if(kaweth_set_sofs_wait(kaweth, KAWETH_SOFS_TO_WAIT) < 0) { ++ dev_err(dev, "Error setting SOFS wait\n"); ++ goto err_free_netdev; ++ } ++ ++ result = kaweth_set_receive_filter(kaweth, ++ KAWETH_PACKET_FILTER_DIRECTED | ++ KAWETH_PACKET_FILTER_BROADCAST | ++ KAWETH_PACKET_FILTER_MULTICAST); ++ ++ if(result < 0) { ++ dev_err(dev, "Error setting receive filter\n"); ++ goto err_free_netdev; ++ } ++ ++ dev_dbg(dev, "Initializing net device.\n"); ++ ++ kaweth->intf = intf; ++ ++ kaweth->tx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!kaweth->tx_urb) ++ goto err_free_netdev; ++ kaweth->rx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!kaweth->rx_urb) ++ goto err_only_tx; ++ kaweth->irq_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!kaweth->irq_urb) ++ goto err_tx_and_rx; ++ ++ kaweth->intbuffer = usb_alloc_coherent( kaweth->dev, ++ INTBUFFERSIZE, ++ GFP_KERNEL, ++ &kaweth->intbufferhandle); ++ if (!kaweth->intbuffer) ++ goto err_tx_and_rx_and_irq; ++ kaweth->rx_buf = usb_alloc_coherent( kaweth->dev, ++ KAWETH_BUF_SIZE, ++ GFP_KERNEL, ++ &kaweth->rxbufferhandle); ++ if (!kaweth->rx_buf) ++ goto err_all_but_rxbuf; ++ ++ memcpy(netdev->broadcast, &bcast_addr, sizeof(bcast_addr)); ++ memcpy(netdev->dev_addr, &kaweth->configuration.hw_addr, ++ sizeof(kaweth->configuration.hw_addr)); ++ ++ netdev->netdev_ops = &kaweth_netdev_ops; ++ netdev->watchdog_timeo = KAWETH_TX_TIMEOUT; ++ netdev->mtu = le16_to_cpu(kaweth->configuration.segment_size); ++ netdev->ethtool_ops = &ops; ++ ++ /* kaweth is zeroed as part of alloc_netdev */ ++ INIT_DELAYED_WORK(&kaweth->lowmem_work, kaweth_resubmit_tl); ++ usb_set_intfdata(intf, kaweth); ++ ++#if 0 ++// dma_supported() is deeply broken on almost all architectures ++ if (dma_supported (dev, 0xffffffffffffffffULL)) ++ kaweth->net->features |= NETIF_F_HIGHDMA; ++#endif ++ ++ SET_NETDEV_DEV(netdev, dev); ++ if (register_netdev(netdev) != 0) { ++ dev_err(dev, "Error registering netdev.\n"); ++ goto err_intfdata; ++ } ++ ++ dev_info(dev, "kaweth interface created at %s\n", ++ kaweth->net->name); ++ ++ dev_dbg(dev, "Kaweth probe returning.\n"); ++ ++ return 0; ++ ++err_intfdata: ++ usb_set_intfdata(intf, NULL); ++ usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); ++err_all_but_rxbuf: ++ usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); ++err_tx_and_rx_and_irq: ++ usb_free_urb(kaweth->irq_urb); ++err_tx_and_rx: ++ usb_free_urb(kaweth->rx_urb); ++err_only_tx: ++ usb_free_urb(kaweth->tx_urb); ++err_free_netdev: ++ free_netdev(netdev); ++ ++ return -EIO; ++} ++ ++/**************************************************************** ++ * kaweth_disconnect ++ ****************************************************************/ ++static void kaweth_disconnect(struct usb_interface *intf) ++{ ++ struct kaweth_device *kaweth = usb_get_intfdata(intf); ++ struct net_device *netdev; ++ ++ dev_info(&intf->dev, "Unregistering\n"); ++ ++ usb_set_intfdata(intf, NULL); ++ if (!kaweth) { ++ dev_warn(&intf->dev, "unregistering non-existent device\n"); ++ return; ++ } ++ netdev = kaweth->net; ++ ++ netdev_dbg(kaweth->net, "Unregistering net device\n"); ++ unregister_netdev(netdev); ++ ++ usb_free_urb(kaweth->rx_urb); ++ usb_free_urb(kaweth->tx_urb); ++ usb_free_urb(kaweth->irq_urb); ++ ++ usb_free_coherent(kaweth->dev, KAWETH_BUF_SIZE, (void *)kaweth->rx_buf, kaweth->rxbufferhandle); ++ usb_free_coherent(kaweth->dev, INTBUFFERSIZE, (void *)kaweth->intbuffer, kaweth->intbufferhandle); ++ ++ free_netdev(netdev); ++} ++ ++ ++// FIXME this completion stuff is a modified clone of ++// an OLD version of some stuff in usb.c ... ++struct usb_api_data { ++ wait_queue_head_t wqh; ++ int done; ++}; ++ ++/*-------------------------------------------------------------------* ++ * completion handler for compatibility wrappers (sync control/bulk) * ++ *-------------------------------------------------------------------*/ ++static void usb_api_blocking_completion(struct urb *urb) ++{ ++ struct usb_api_data *awd = (struct usb_api_data *)urb->context; ++ ++ awd->done=1; ++ wake_up(&awd->wqh); ++} ++ ++/*-------------------------------------------------------------------* ++ * COMPATIBILITY STUFF * ++ *-------------------------------------------------------------------*/ ++ ++// Starts urb and waits for completion or timeout ++static int usb_start_wait_urb(struct urb *urb, int timeout, int* actual_length) ++{ ++ struct usb_api_data awd; ++ int status; ++ ++ init_waitqueue_head(&awd.wqh); ++ awd.done = 0; ++ ++ urb->context = &awd; ++ status = usb_submit_urb(urb, GFP_ATOMIC); ++ if (status) { ++ // something went wrong ++ usb_free_urb(urb); ++ return status; ++ } ++ ++ if (!wait_event_timeout(awd.wqh, awd.done, timeout)) { ++ // timeout ++ dev_warn(&urb->dev->dev, "usb_control/bulk_msg: timeout\n"); ++ usb_kill_urb(urb); // remove urb safely ++ status = -ETIMEDOUT; ++ } ++ else { ++ status = urb->status; ++ } ++ ++ if (actual_length) { ++ *actual_length = urb->actual_length; ++ } ++ ++ usb_free_urb(urb); ++ return status; ++} ++ ++/*-------------------------------------------------------------------*/ ++// returns status (negative) or length (positive) ++static int kaweth_internal_control_msg(struct usb_device *usb_dev, ++ unsigned int pipe, ++ struct usb_ctrlrequest *cmd, void *data, ++ int len, int timeout) ++{ ++ struct urb *urb; ++ int retv; ++ int length = 0; /* shut up GCC */ ++ ++ urb = usb_alloc_urb(0, GFP_ATOMIC); ++ if (!urb) ++ return -ENOMEM; ++ ++ usb_fill_control_urb(urb, usb_dev, pipe, (unsigned char*)cmd, data, ++ len, usb_api_blocking_completion, NULL); ++ ++ retv = usb_start_wait_urb(urb, timeout, &length); ++ if (retv < 0) { ++ return retv; ++ } ++ else { ++ return length; ++ } ++} ++ ++module_usb_driver(kaweth_driver); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/Kconfig backports-4.2.6-1/drivers/net/usb/Kconfig +--- backports-4.2.6-1.org/drivers/net/usb/Kconfig 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/Kconfig 2016-01-27 15:58:23.159192032 +0100 +@@ -13,7 +13,6 @@ + if USB_NET_DRIVERS + + config USB_CATC +- depends on n + tristate "USB CATC NetMate-based Ethernet device support" + depends on m + depends on CRC32 +@@ -34,7 +33,6 @@ + module will be called catc. + + config USB_KAWETH +- depends on n + tristate "USB KLSI KL5USB101-based ethernet device support" + depends on m + ---help--- +@@ -75,7 +73,6 @@ + module will be called kaweth. + + config USB_PEGASUS +- depends on n + tristate "USB Pegasus/Pegasus-II based ethernet device support" + depends on m + select BPAUTO_MII +@@ -92,7 +89,6 @@ + module will be called pegasus. + + config USB_RTL8150 +- depends on n + tristate "USB RTL8150 based ethernet device support" + depends on m + select BPAUTO_MII +@@ -105,7 +101,6 @@ + module will be called rtl8150. + + config USB_RTL8152 +- depends on n + tristate "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters" + depends on m + select BPAUTO_MII +@@ -153,7 +148,6 @@ + module will be called usbnet. + + config USB_NET_AX8817X +- depends on n + tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" + depends on m + depends on USB_USBNET +@@ -184,7 +178,6 @@ + what other networking devices you have in use. + + config USB_NET_AX88179_178A +- depends on n + tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet" + depends on m + depends on USB_USBNET +@@ -233,7 +226,6 @@ + name is used instead. + + config USB_NET_CDC_EEM +- depends on n + tristate "CDC EEM support" + depends on m + depends on USB_USBNET +@@ -269,7 +261,6 @@ + * Ericsson F5521gw Mobile Broadband Module + + config USB_NET_HUAWEI_CDC_NCM +- depends on n + tristate "Huawei NCM embedded AT channel support" + depends on m + depends on USB_USBNET +@@ -305,7 +296,6 @@ + module will be called cdc_mbim. + + config USB_NET_DM9601 +- depends on n + tristate "Davicom DM96xx based USB 10/100 ethernet devices" + depends on m + depends on USB_USBNET +@@ -315,7 +305,6 @@ + based USB 10/100 Ethernet adapters. + + config USB_NET_SR9700 +- depends on n + tristate "CoreChip-sz SR9700 based USB 1.1 10/100 ethernet devices" + depends on m + depends on USB_USBNET +@@ -325,7 +314,6 @@ + 10/100 Ethernet adapters. + + config USB_NET_SR9800 +- depends on n + tristate "CoreChip-sz SR9800 based USB 2.0 10/100 ethernet devices" + depends on m + depends on USB_USBNET +@@ -342,7 +330,6 @@ + module will be called sr9800. + + config USB_NET_SMSC75XX +- depends on n + tristate "SMSC LAN75XX based USB 2.0 gigabit ethernet devices" + depends on m + depends on USB_USBNET +@@ -354,7 +341,6 @@ + Gigabit Ethernet adapters. + + config USB_NET_SMSC95XX +- depends on n + tristate "SMSC LAN95XX based USB 2.0 10/100 ethernet devices" + depends on m + depends on USB_USBNET +@@ -366,7 +352,6 @@ + 10/100 Ethernet adapters. + + config USB_NET_GL620A +- depends on n + tristate "GeneSys GL620USB-A based cables" + depends on m + depends on USB_USBNET +@@ -377,7 +362,6 @@ + Note that the half-duplex "GL620USB" is not supported. + + config USB_NET_NET1080 +- depends on n + tristate "NetChip 1080 based cables (Laplink, ...)" + depends on m + default y +@@ -388,7 +372,6 @@ + optionally with LEDs that indicate traffic + + config USB_NET_PLUSB +- depends on n + tristate "Prolific PL-2301/2302/25A1 based cables" + depends on m + # if the handshake/init/reset problems, from original 'plusb', +@@ -399,7 +382,6 @@ + with one of these chips. + + config USB_NET_MCS7830 +- depends on n + tristate "MosChip MCS7830 based Ethernet adapters" + depends on m + depends on USB_USBNET +@@ -425,7 +407,6 @@ + (and for) Microsoft; it isn't an "Open" ecosystem or market. + + config USB_NET_CDC_SUBSET +- depends on n + tristate "Simple USB Network Links (CDC Ethernet subset)" + depends on m + depends on USB_USBNET +@@ -497,7 +478,6 @@ + with one of these chips. + + config USB_NET_ZAURUS +- depends on n + tristate "Sharp Zaurus (stock ROMs) and compatible" + depends on m + depends on USB_USBNET +@@ -517,7 +497,6 @@ + some cases CDC MDLM) protocol, not "g_ether". + + config USB_NET_CX82310_ETH +- depends on n + tristate "Conexant CX82310 USB ethernet port" + depends on m + depends on USB_USBNET +@@ -527,7 +506,6 @@ + it will not work with ADSL modems (use cxacru driver instead). + + config USB_NET_KALMIA +- depends on n + tristate "Samsung Kalmia based LTE USB modem" + depends on m + depends on USB_USBNET +@@ -562,7 +540,6 @@ + module will be called qmi_wwan. + + config USB_HSO +- depends on n + tristate "Option USB High Speed Mobile Devices" + depends on m + depends on USB && RFKILL && TTY +@@ -575,7 +552,6 @@ + module will be called hso. + + config USB_NET_INT51X1 +- depends on n + tristate "Intellon PLC based usb adapter" + depends on m + depends on USB_USBNET +@@ -585,7 +561,6 @@ + INT51x1/INT5200 chip, like the "devolo dLan duo". + + config USB_CDC_PHONET +- depends on n + tristate "CDC Phonet support" + depends on m + depends on PHONET +@@ -595,7 +570,6 @@ + "PC suite" USB profile. + + config USB_IPHETH +- depends on n + tristate "Apple iPhone USB Ethernet driver" + depends on m + default n +@@ -619,11 +593,10 @@ + module will be called sierra_net. + + config USB_VL600 +- depends on n + tristate "LG VL600 modem dongle" + depends on m + depends on USB_NET_CDCETHER && TTY +- select USB_ACM ++# depends on USB_ACM + help + Select this if you want to use an LG Electronics 4G/LTE usb modem + called VL600. This driver only handles the ethernet +diff -Naur backports-4.2.6-1.org/drivers/net/usb/Kconfig.orig backports-4.2.6-1/drivers/net/usb/Kconfig.orig +--- backports-4.2.6-1.org/drivers/net/usb/Kconfig.orig 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/Kconfig.orig 2015-11-15 22:19:40.000000000 +0100 +@@ -0,0 +1,638 @@ ++# ++# USB Network devices configuration ++# ++comment "Host-side USB support is needed for USB Network Adapter support" ++ depends on !USB && NET ++ ++menuconfig USB_NET_DRIVERS ++ tristate "USB Network Adapters" ++ depends on m ++ default USB if USB ++ depends on USB && NET ++ ++if USB_NET_DRIVERS ++ ++config USB_CATC ++ depends on n ++ tristate "USB CATC NetMate-based Ethernet device support" ++ depends on m ++ depends on CRC32 ++ ---help--- ++ Say Y if you want to use one of the following 10Mbps USB Ethernet ++ device based on the EL1210A chip. Supported devices are: ++ Belkin F5U011 ++ Belkin F5U111 ++ CATC NetMate ++ CATC NetMate II ++ smartBridges smartNIC ++ ++ This driver makes the adapter appear as a normal Ethernet interface, ++ typically on eth0, if it is the only ethernet device, or perhaps on ++ eth1, if you have a PCI or ISA ethernet card installed. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called catc. ++ ++config USB_KAWETH ++ depends on n ++ tristate "USB KLSI KL5USB101-based ethernet device support" ++ depends on m ++ ---help--- ++ Say Y here if you want to use one of the following 10Mbps only ++ USB Ethernet adapters based on the KLSI KL5KUSB101B chipset: ++ 3Com 3C19250 ++ ADS USB-10BT ++ ATEN USB Ethernet ++ ASANTE USB To Ethernet Adapter ++ AOX Endpoints USB Ethernet ++ Correga K.K. ++ D-Link DSB-650C and DU-E10 ++ Entrega / Portgear E45 ++ I-O DATA USB-ET/T ++ Jaton USB Ethernet Device Adapter ++ Kingston Technology USB Ethernet Adapter ++ Linksys USB10T ++ Mobility USB-Ethernet Adapter ++ NetGear EA-101 ++ Peracom Enet and Enet2 ++ Portsmith Express Ethernet Adapter ++ Shark Pocket Adapter ++ SMC 2202USB ++ Sony Vaio port extender ++ ++ This driver is likely to work with most 10Mbps only USB Ethernet ++ adapters, including some "no brand" devices. It does NOT work on ++ SmartBridges smartNIC or on Belkin F5U111 devices - you should use ++ the CATC NetMate driver for those. If you are not sure which one ++ you need, select both, and the correct one should be selected for ++ you. ++ ++ This driver makes the adapter appear as a normal Ethernet interface, ++ typically on eth0, if it is the only ethernet device, or perhaps on ++ eth1, if you have a PCI or ISA ethernet card installed. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called kaweth. ++ ++config USB_PEGASUS ++ depends on n ++ tristate "USB Pegasus/Pegasus-II based ethernet device support" ++ depends on m ++ select BPAUTO_MII ++ ---help--- ++ Say Y here if you know you have Pegasus or Pegasus-II based adapter. ++ If in doubt then look at file:drivers/net/usb/pegasus.h for the ++ complete list of supported devices. ++ ++ If your particular adapter is not in the list and you are _sure_ it ++ is Pegasus or Pegasus II based then send me ++ petkan@users.sourceforge.net vendor and device IDs. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called pegasus. ++ ++config USB_RTL8150 ++ depends on n ++ tristate "USB RTL8150 based ethernet device support" ++ depends on m ++ select BPAUTO_MII ++ help ++ Say Y here if you have RTL8150 based usb-ethernet adapter. ++ Send me petkan@users.sourceforge.net any comments you may have. ++ You can also check for updates at http://pegasus2.sourceforge.net/. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called rtl8150. ++ ++config USB_RTL8152 ++ depends on n ++ tristate "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters" ++ depends on m ++ select BPAUTO_MII ++ help ++ This option adds support for Realtek RTL8152 based USB 2.0 ++ 10/100 Ethernet adapters and RTL8153 based USB 3.0 10/100/1000 ++ Ethernet adapters. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called r8152. ++ ++config USB_USBNET ++ tristate "Multi-purpose USB Networking Framework" ++ depends on m ++ select BPAUTO_MII ++ ---help--- ++ This driver supports several kinds of network links over USB, ++ with "minidrivers" built around a common network driver core ++ that supports deep queues for efficient transfers. (This gives ++ better performance with small packets and at high speeds). ++ ++ The USB host runs "usbnet", and the other end of the link might be: ++ ++ - Another USB host, when using USB "network" or "data transfer" ++ cables. These are often used to network laptops to PCs, like ++ "Laplink" parallel cables or some motherboards. These rely ++ on specialized chips from many suppliers. ++ ++ - An intelligent USB gadget, perhaps embedding a Linux system. ++ These include PDAs running Linux (iPaq, Yopy, Zaurus, and ++ others), and devices that interoperate using the standard ++ CDC-Ethernet specification (including many cable modems). ++ ++ - Network adapter hardware (like those for 10/100 Ethernet) which ++ uses this driver framework. ++ ++ The link will appear with a name like "usb0", when the link is ++ a two-node link, or "eth0" for most CDC-Ethernet devices. Those ++ two-node links are most easily managed with Ethernet Bridging ++ (CONFIG_BRIDGE) instead of routing. ++ ++ For more information see http://www.linux-usb.org/usbnet/. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called usbnet. ++ ++config USB_NET_AX8817X ++ depends on n ++ tristate "ASIX AX88xxx Based USB 2.0 Ethernet Adapters" ++ depends on m ++ depends on USB_USBNET ++ depends on CRC32 ++ depends on PHYLIB ++ default y ++ help ++ This option adds support for ASIX AX88xxx based USB 2.0 ++ 10/100 Ethernet adapters. ++ ++ This driver should work with at least the following devices: ++ * Aten UC210T ++ * ASIX AX88172 ++ * Billionton Systems, USB2AR ++ * Buffalo LUA-U2-KTX ++ * Corega FEther USB2-TX ++ * D-Link DUB-E100 ++ * Hawking UF200 ++ * Linksys USB200M ++ * Netgear FA120 ++ * Sitecom LN-029 ++ * Sitecom LN-028 ++ * Intellinet USB 2.0 Ethernet ++ * ST Lab USB 2.0 Ethernet ++ * TrendNet TU2-ET100 ++ ++ This driver creates an interface named "ethX", where X depends on ++ what other networking devices you have in use. ++ ++config USB_NET_AX88179_178A ++ depends on n ++ tristate "ASIX AX88179/178A USB 3.0/2.0 to Gigabit Ethernet" ++ depends on m ++ depends on USB_USBNET ++ depends on CRC32 ++ depends on PHYLIB ++ default y ++ help ++ This option adds support for ASIX AX88179 based USB 3.0/2.0 ++ to Gigabit Ethernet adapters. ++ ++ This driver should work with at least the following devices: ++ * ASIX AX88179 ++ * ASIX AX88178A ++ * Sitcomm LN-032 ++ ++ This driver creates an interface named "ethX", where X depends on ++ what other networking devices you have in use. ++ ++config USB_NET_CDCETHER ++ tristate "CDC Ethernet support (smart devices such as cable modems)" ++ depends on m ++ depends on USB_USBNET ++ default y ++ help ++ This option supports devices conforming to the Communication Device ++ Class (CDC) Ethernet Control Model, a specification that's easy to ++ implement in device firmware. The CDC specifications are available ++ from http://www.usb.org/. ++ ++ CDC Ethernet is an implementation option for DOCSIS cable modems ++ that support USB connectivity, used for non-Microsoft USB hosts. ++ The Linux-USB CDC Ethernet Gadget driver is an open implementation. ++ This driver should work with at least the following devices: ++ ++ * Dell Wireless 5530 HSPA ++ * Ericsson PipeRider (all variants) ++ * Ericsson Mobile Broadband Module (all variants) ++ * Motorola (DM100 and SB4100) ++ * Broadcom Cable Modem (reference design) ++ * Toshiba (PCX1100U and F3507g/F3607gw) ++ * ... ++ ++ This driver creates an interface named "ethX", where X depends on ++ what other networking devices you have in use. However, if the ++ IEEE 802 "local assignment" bit is set in the address, a "usbX" ++ name is used instead. ++ ++config USB_NET_CDC_EEM ++ depends on n ++ tristate "CDC EEM support" ++ depends on m ++ depends on USB_USBNET ++ help ++ This option supports devices conforming to the Communication Device ++ Class (CDC) Ethernet Emulation Model, a specification that's easy to ++ implement in device firmware. The CDC EEM specifications are available ++ from http://www.usb.org/. ++ ++ This driver creates an interface named "ethX", where X depends on ++ what other networking devices you have in use. However, if the ++ IEEE 802 "local assignment" bit is set in the address, a "usbX" ++ name is used instead. ++ ++config USB_NET_CDC_NCM ++ tristate "CDC NCM support" ++ depends on m ++ depends on USB_USBNET ++ default y ++ help ++ This driver provides support for CDC NCM (Network Control Model ++ Device USB Class Specification). The CDC NCM specification is ++ available from http://www.usb.org/. ++ ++ Say "y" to link the driver statically, or "m" to build a ++ dynamically linked module. ++ ++ This driver should work with at least the following devices: ++ * ST-Ericsson M700 LTE FDD/TDD Mobile Broadband Modem (ref. design) ++ * ST-Ericsson M5730 HSPA+ Mobile Broadband Modem (reference design) ++ * ST-Ericsson M570 HSPA+ Mobile Broadband Modem (reference design) ++ * ST-Ericsson M343 HSPA Mobile Broadband Modem (reference design) ++ * Ericsson F5521gw Mobile Broadband Module ++ ++config USB_NET_HUAWEI_CDC_NCM ++ depends on n ++ tristate "Huawei NCM embedded AT channel support" ++ depends on m ++ depends on USB_USBNET ++ select USB_WDM ++ select USB_NET_CDC_NCM ++ help ++ This driver supports huawei-style NCM devices, that use NCM as a ++ transport for other protocols, usually an embedded AT channel. ++ Good examples are: ++ * Huawei E3131 ++ * Huawei E3251 ++ ++ To compile this driver as a module, choose M here: the module will be ++ called huawei_cdc_ncm.ko. ++ ++config USB_NET_CDC_MBIM ++ tristate "CDC MBIM support" ++ depends on m ++ depends on USB_USBNET ++ select USB_WDM ++ select USB_NET_CDC_NCM ++ help ++ This driver provides support for CDC MBIM (Mobile Broadband ++ Interface Model) devices. The CDC MBIM specification is ++ available from http://www.usb.org/. ++ ++ MBIM devices require configuration using the management ++ protocol defined by the MBIM specification. This driver ++ provides unfiltered access to the MBIM control channel ++ through the associated /dev/cdc-wdmx character device. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called cdc_mbim. ++ ++config USB_NET_DM9601 ++ depends on n ++ tristate "Davicom DM96xx based USB 10/100 ethernet devices" ++ depends on m ++ depends on USB_USBNET ++ depends on CRC32 ++ help ++ This option adds support for Davicom DM9601/DM9620/DM9621A ++ based USB 10/100 Ethernet adapters. ++ ++config USB_NET_SR9700 ++ depends on n ++ tristate "CoreChip-sz SR9700 based USB 1.1 10/100 ethernet devices" ++ depends on m ++ depends on USB_USBNET ++ depends on CRC32 ++ help ++ This option adds support for CoreChip-sz SR9700 based USB 1.1 ++ 10/100 Ethernet adapters. ++ ++config USB_NET_SR9800 ++ depends on n ++ tristate "CoreChip-sz SR9800 based USB 2.0 10/100 ethernet devices" ++ depends on m ++ depends on USB_USBNET ++ depends on CRC32 ++ ---help--- ++ Say Y if you want to use one of the following 100Mbps USB Ethernet ++ device based on the CoreChip-sz SR9800 chip. ++ ++ This driver makes the adapter appear as a normal Ethernet interface, ++ typically on eth0, if it is the only ethernet device, or perhaps on ++ eth1, if you have a PCI or ISA ethernet card installed. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called sr9800. ++ ++config USB_NET_SMSC75XX ++ depends on n ++ tristate "SMSC LAN75XX based USB 2.0 gigabit ethernet devices" ++ depends on m ++ depends on USB_USBNET ++ depends on BITREVERSE ++ depends on CRC16 ++ depends on CRC32 ++ help ++ This option adds support for SMSC LAN75XX based USB 2.0 ++ Gigabit Ethernet adapters. ++ ++config USB_NET_SMSC95XX ++ depends on n ++ tristate "SMSC LAN95XX based USB 2.0 10/100 ethernet devices" ++ depends on m ++ depends on USB_USBNET ++ depends on BITREVERSE ++ depends on CRC16 ++ depends on CRC32 ++ help ++ This option adds support for SMSC LAN95XX based USB 2.0 ++ 10/100 Ethernet adapters. ++ ++config USB_NET_GL620A ++ depends on n ++ tristate "GeneSys GL620USB-A based cables" ++ depends on m ++ depends on USB_USBNET ++ help ++ Choose this option if you're using a host-to-host cable, ++ or PC2PC motherboard, with this chip. ++ ++ Note that the half-duplex "GL620USB" is not supported. ++ ++config USB_NET_NET1080 ++ depends on n ++ tristate "NetChip 1080 based cables (Laplink, ...)" ++ depends on m ++ default y ++ depends on USB_USBNET ++ help ++ Choose this option if you're using a host-to-host cable based ++ on this design: one NetChip 1080 chip and supporting logic, ++ optionally with LEDs that indicate traffic ++ ++config USB_NET_PLUSB ++ depends on n ++ tristate "Prolific PL-2301/2302/25A1 based cables" ++ depends on m ++ # if the handshake/init/reset problems, from original 'plusb', ++ # are ever resolved ... then remove "experimental" ++ depends on USB_USBNET ++ help ++ Choose this option if you're using a host-to-host cable ++ with one of these chips. ++ ++config USB_NET_MCS7830 ++ depends on n ++ tristate "MosChip MCS7830 based Ethernet adapters" ++ depends on m ++ depends on USB_USBNET ++ help ++ Choose this option if you're using a 10/100 Ethernet USB2 ++ adapter based on the MosChip 7830 controller. This includes ++ adapters marketed under the DeLOCK brand. ++ ++config USB_NET_RNDIS_HOST ++ tristate "Host for RNDIS and ActiveSync devices" ++ depends on m ++ depends on USB_USBNET ++ select USB_NET_CDCETHER ++ help ++ This option enables hosting "Remote NDIS" USB networking links, ++ as encouraged by Microsoft (instead of CDC Ethernet!) for use in ++ various devices that may only support this protocol. A variant ++ of this protocol (with even less public documentation) seems to ++ be at the root of Microsoft's "ActiveSync" too. ++ ++ Avoid using this protocol unless you have no better options. ++ The protocol specification is incomplete, and is controlled by ++ (and for) Microsoft; it isn't an "Open" ecosystem or market. ++ ++config USB_NET_CDC_SUBSET ++ depends on n ++ tristate "Simple USB Network Links (CDC Ethernet subset)" ++ depends on m ++ depends on USB_USBNET ++ default y ++ help ++ This driver module supports USB network devices that can work ++ without any device-specific information. Select it if you have ++ one of these drivers. ++ ++ Note that while many USB host-to-host cables can work in this mode, ++ that may mean not being able to talk to Win32 systems or more ++ commonly not being able to handle certain events (like replugging ++ the host on the other end) very well. Also, these devices will ++ not generally have permanently assigned Ethernet addresses. ++ ++config USB_ALI_M5632 ++ bool "ALi M5632 based 'USB 2.0 Data Link' cables" ++ depends on USB_NET_CDC_SUBSET ++ help ++ Choose this option if you're using a host-to-host cable ++ based on this design, which supports USB 2.0 high speed. ++ ++config USB_AN2720 ++ bool "AnchorChips 2720 based cables (Xircom PGUNET, ...)" ++ depends on USB_NET_CDC_SUBSET ++ help ++ Choose this option if you're using a host-to-host cable ++ based on this design. Note that AnchorChips is now a ++ Cypress brand. ++ ++config USB_BELKIN ++ bool "eTEK based host-to-host cables (Advance, Belkin, ...)" ++ depends on USB_NET_CDC_SUBSET ++ default y ++ help ++ Choose this option if you're using a host-to-host cable ++ based on this design: two NetChip 2890 chips and an Atmel ++ microcontroller, with LEDs that indicate traffic. ++ ++config USB_ARMLINUX ++ bool "Embedded ARM Linux links (iPaq, ...)" ++ depends on USB_NET_CDC_SUBSET ++ default y ++ help ++ Choose this option to support the "usb-eth" networking driver ++ used by most of the ARM Linux community with device controllers ++ such as the SA-11x0 and PXA-25x UDCs, or the tftp capabilities ++ in some PXA versions of the "blob" boot loader. ++ ++ Linux-based "Gumstix" PXA-25x based systems use this protocol ++ to talk with other Linux systems. ++ ++ Although the ROMs shipped with Sharp Zaurus products use a ++ different link level framing protocol, you can have them use ++ this simpler protocol by installing a different kernel. ++ ++config USB_EPSON2888 ++ bool "Epson 2888 based firmware (DEVELOPMENT)" ++ depends on USB_NET_CDC_SUBSET ++ help ++ Choose this option to support the usb networking links used ++ by some sample firmware from Epson. ++ ++config USB_KC2190 ++ bool "KT Technology KC2190 based cables (InstaNet)" ++ depends on USB_NET_CDC_SUBSET ++ help ++ Choose this option if you're using a host-to-host cable ++ with one of these chips. ++ ++config USB_NET_ZAURUS ++ depends on n ++ tristate "Sharp Zaurus (stock ROMs) and compatible" ++ depends on m ++ depends on USB_USBNET ++ select USB_NET_CDCETHER ++ depends on CRC32 ++ default y ++ help ++ Choose this option to support the usb networking links used by ++ Zaurus models like the SL-5000D, SL-5500, SL-5600, A-300, B-500. ++ This also supports some related device firmware, as used in some ++ PDAs from Olympus and some cell phones from Motorola. ++ ++ If you install an alternate image, such as the Linux 2.6 based ++ versions of OpenZaurus, you should no longer need to support this ++ protocol. Only the "eth-fd" or "net_fd" drivers in these devices ++ really need this non-conformant variant of CDC Ethernet (or in ++ some cases CDC MDLM) protocol, not "g_ether". ++ ++config USB_NET_CX82310_ETH ++ depends on n ++ tristate "Conexant CX82310 USB ethernet port" ++ depends on m ++ depends on USB_USBNET ++ help ++ Choose this option if you're using a Conexant CX82310-based ADSL ++ router with USB ethernet port. This driver is for routers only, ++ it will not work with ADSL modems (use cxacru driver instead). ++ ++config USB_NET_KALMIA ++ depends on n ++ tristate "Samsung Kalmia based LTE USB modem" ++ depends on m ++ depends on USB_USBNET ++ help ++ Choose this option if you have a Samsung Kalmia based USB modem ++ as Samsung GT-B3730. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called kalmia. ++ ++config USB_NET_QMI_WWAN ++ tristate "QMI WWAN driver for Qualcomm MSM based 3G and LTE modems" ++ depends on m ++ depends on USB_USBNET ++ select USB_WDM ++ help ++ Support WWAN LTE/3G devices based on Qualcomm Mobile Data Modem ++ (MDM) chipsets. Examples of such devices are ++ * Huawei E392/E398 ++ ++ This driver will only drive the ethernet part of the chips. ++ The devices require additional configuration to be usable. ++ Multiple management interfaces with linux drivers are ++ available: ++ ++ * option: AT commands on /dev/ttyUSBx ++ * cdc-wdm: Qualcomm MSM Interface (QMI) protocol on /dev/cdc-wdmx ++ ++ A modem manager with support for QMI is recommended. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called qmi_wwan. ++ ++config USB_HSO ++ depends on n ++ tristate "Option USB High Speed Mobile Devices" ++ depends on m ++ depends on USB && RFKILL && TTY ++ default n ++ help ++ Choose this option if you have an Option HSDPA/HSUPA card. ++ These cards support downlink speeds of 7.2Mbps or greater. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called hso. ++ ++config USB_NET_INT51X1 ++ depends on n ++ tristate "Intellon PLC based usb adapter" ++ depends on m ++ depends on USB_USBNET ++ help ++ Choose this option if you're using a 14Mb USB-based PLC ++ (Powerline Communications) solution with an Intellon ++ INT51x1/INT5200 chip, like the "devolo dLan duo". ++ ++config USB_CDC_PHONET ++ depends on n ++ tristate "CDC Phonet support" ++ depends on m ++ depends on PHONET ++ help ++ Choose this option to support the Phonet interface to a Nokia ++ cellular modem, as found on most Nokia handsets with the ++ "PC suite" USB profile. ++ ++config USB_IPHETH ++ depends on n ++ tristate "Apple iPhone USB Ethernet driver" ++ depends on m ++ default n ++ ---help--- ++ Module used to share Internet connection (tethering) from your ++ iPhone (Original, 3G and 3GS) to your system. ++ Note that you need userspace libraries and programs that are needed ++ to pair your device with your system and that understand the iPhone ++ protocol. ++ ++ For more information: http://giagio.com/wiki/moin.cgi/iPhoneEthernetDriver ++ ++config USB_SIERRA_NET ++ tristate "USB-to-WWAN Driver for Sierra Wireless modems" ++ depends on m ++ depends on USB_USBNET ++ help ++ Choose this option if you have a Sierra Wireless USB-to-WWAN device. ++ ++ To compile this driver as a module, choose M here: the ++ module will be called sierra_net. ++ ++config USB_VL600 ++ depends on n ++ tristate "LG VL600 modem dongle" ++ depends on m ++ depends on USB_NET_CDCETHER && TTY ++ select USB_ACM ++ help ++ Select this if you want to use an LG Electronics 4G/LTE usb modem ++ called VL600. This driver only handles the ethernet ++ interface exposed by the modem firmware. To establish a connection ++ you will first need a userspace program that sends the right ++ command to the modem through its CDC ACM port, and most ++ likely also a DHCP client. See this thread about using the ++ 4G modem from Verizon: ++ ++ http://ubuntuforums.org/showpost.php?p=10589647&postcount=17 ++ ++endif # USB_NET_DRIVERS +diff -Naur backports-4.2.6-1.org/drivers/net/usb/lg-vl600.c backports-4.2.6-1/drivers/net/usb/lg-vl600.c +--- backports-4.2.6-1.org/drivers/net/usb/lg-vl600.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/lg-vl600.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,353 @@ ++/* ++ * Ethernet interface part of the LG VL600 LTE modem (4G dongle) ++ * ++ * Copyright (C) 2011 Intel Corporation ++ * Author: Andrzej Zaborowski balrogg@gmail.com ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/usb/cdc.h> ++#include <linux/usb/usbnet.h> ++#include <linux/if_ether.h> ++#include <linux/if_arp.h> ++#include <linux/inetdevice.h> ++#include <linux/module.h> ++ ++/* ++ * The device has a CDC ACM port for modem control (it claims to be ++ * CDC ACM anyway) and a CDC Ethernet port for actual network data. ++ * It will however ignore data on both ports that is not encapsulated ++ * in a specific way, any data returned is also encapsulated the same ++ * way. The headers don't seem to follow any popular standard. ++ * ++ * This driver adds and strips these headers from the ethernet frames ++ * sent/received from the CDC Ethernet port. The proprietary header ++ * replaces the standard ethernet header in a packet so only actual ++ * ethernet frames are allowed. The headers allow some form of ++ * multiplexing by using non standard values of the .h_proto field. ++ * Windows/Mac drivers do send a couple of such frames to the device ++ * during initialisation, with protocol set to 0x0906 or 0x0b06 and (what ++ * seems to be) a flag in the .dummy_flags. This doesn't seem necessary ++ * for modem operation but can possibly be used for GPS or other funcitons. ++ */ ++ ++struct vl600_frame_hdr { ++ __le32 len; ++ __le32 serial; ++ __le32 pkt_cnt; ++ __le32 dummy_flags; ++ __le32 dummy; ++ __le32 magic; ++} __attribute__((packed)); ++ ++struct vl600_pkt_hdr { ++ __le32 dummy[2]; ++ __le32 len; ++ __be16 h_proto; ++} __attribute__((packed)); ++ ++struct vl600_state { ++ struct sk_buff *current_rx_buf; ++}; ++ ++static int vl600_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ int ret; ++ struct vl600_state *s = kzalloc(sizeof(struct vl600_state), GFP_KERNEL); ++ ++ if (!s) ++ return -ENOMEM; ++ ++ ret = usbnet_cdc_bind(dev, intf); ++ if (ret) { ++ kfree(s); ++ return ret; ++ } ++ ++ dev->driver_priv = s; ++ ++ /* ARP packets don't go through, but they're also of no use. The ++ * subnet has only two hosts anyway: us and the gateway / DHCP ++ * server (probably simulated by modem firmware or network operator) ++ * whose address changes everytime we connect to the intarwebz and ++ * who doesn't bother answering ARP requests either. So hardware ++ * addresses have no meaning, the destination and the source of every ++ * packet depend only on whether it is on the IN or OUT endpoint. */ ++ dev->net->flags |= IFF_NOARP; ++ /* IPv6 NDP relies on multicast. Enable it by default. */ ++ dev->net->flags |= IFF_MULTICAST; ++ ++ return ret; ++} ++ ++static void vl600_unbind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ struct vl600_state *s = dev->driver_priv; ++ ++ if (s->current_rx_buf) ++ dev_kfree_skb(s->current_rx_buf); ++ ++ kfree(s); ++ ++ return usbnet_cdc_unbind(dev, intf); ++} ++ ++static int vl600_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ struct vl600_frame_hdr *frame; ++ struct vl600_pkt_hdr *packet; ++ struct ethhdr *ethhdr; ++ int packet_len, count; ++ struct sk_buff *buf = skb; ++ struct sk_buff *clone; ++ struct vl600_state *s = dev->driver_priv; ++ ++ /* Frame lengths are generally 4B multiplies but every couple of ++ * hours there's an odd number of bytes sized yet correct frame, ++ * so don't require this. */ ++ ++ /* Allow a packet (or multiple packets batched together) to be ++ * split across many frames. We don't allow a new batch to ++ * begin in the same frame another one is ending however, and no ++ * leading or trailing pad bytes. */ ++ if (s->current_rx_buf) { ++ frame = (struct vl600_frame_hdr *) s->current_rx_buf->data; ++ if (skb->len + s->current_rx_buf->len > ++ le32_to_cpup(&frame->len)) { ++ netif_err(dev, ifup, dev->net, "Fragment too long\n"); ++ dev->net->stats.rx_length_errors++; ++ goto error; ++ } ++ ++ buf = s->current_rx_buf; ++ memcpy(skb_put(buf, skb->len), skb->data, skb->len); ++ } else if (skb->len < 4) { ++ netif_err(dev, ifup, dev->net, "Frame too short\n"); ++ dev->net->stats.rx_length_errors++; ++ goto error; ++ } ++ ++ frame = (struct vl600_frame_hdr *) buf->data; ++ /* Yes, check that frame->magic == 0x53544448 (or 0x44544d48), ++ * otherwise we may run out of memory w/a bad packet */ ++ if (ntohl(frame->magic) != 0x53544448 && ++ ntohl(frame->magic) != 0x44544d48) ++ goto error; ++ ++ if (buf->len < sizeof(*frame) || ++ buf->len != le32_to_cpup(&frame->len)) { ++ /* Save this fragment for later assembly */ ++ if (s->current_rx_buf) ++ return 0; ++ ++ s->current_rx_buf = skb_copy_expand(skb, 0, ++ le32_to_cpup(&frame->len), GFP_ATOMIC); ++ if (!s->current_rx_buf) { ++ netif_err(dev, ifup, dev->net, "Reserving %i bytes " ++ "for packet assembly failed.\n", ++ le32_to_cpup(&frame->len)); ++ dev->net->stats.rx_errors++; ++ } ++ ++ return 0; ++ } ++ ++ count = le32_to_cpup(&frame->pkt_cnt); ++ ++ skb_pull(buf, sizeof(*frame)); ++ ++ while (count--) { ++ if (buf->len < sizeof(*packet)) { ++ netif_err(dev, ifup, dev->net, "Packet too short\n"); ++ goto error; ++ } ++ ++ packet = (struct vl600_pkt_hdr *) buf->data; ++ packet_len = sizeof(*packet) + le32_to_cpup(&packet->len); ++ if (packet_len > buf->len) { ++ netif_err(dev, ifup, dev->net, ++ "Bad packet length stored in header\n"); ++ goto error; ++ } ++ ++ /* Packet header is same size as the ethernet header ++ * (sizeof(*packet) == sizeof(*ethhdr)), additionally ++ * the h_proto field is in the same place so we just leave it ++ * alone and fill in the remaining fields. ++ */ ++ ethhdr = (struct ethhdr *) skb->data; ++ if (be16_to_cpup(ðhdr->h_proto) == ETH_P_ARP && ++ buf->len > 0x26) { ++ /* Copy the addresses from packet contents */ ++ memcpy(ethhdr->h_source, ++ &buf->data[sizeof(*ethhdr) + 0x8], ++ ETH_ALEN); ++ memcpy(ethhdr->h_dest, ++ &buf->data[sizeof(*ethhdr) + 0x12], ++ ETH_ALEN); ++ } else { ++ eth_zero_addr(ethhdr->h_source); ++ memcpy(ethhdr->h_dest, dev->net->dev_addr, ETH_ALEN); ++ ++ /* Inbound IPv6 packets have an IPv4 ethertype (0x800) ++ * for some reason. Peek at the L3 header to check ++ * for IPv6 packets, and set the ethertype to IPv6 ++ * (0x86dd) so Linux can understand it. ++ */ ++ if ((buf->data[sizeof(*ethhdr)] & 0xf0) == 0x60) ++ ethhdr->h_proto = htons(ETH_P_IPV6); ++ } ++ ++ if (count) { ++ /* Not the last packet in this batch */ ++ clone = skb_clone(buf, GFP_ATOMIC); ++ if (!clone) ++ goto error; ++ ++ skb_trim(clone, packet_len); ++ usbnet_skb_return(dev, clone); ++ ++ skb_pull(buf, (packet_len + 3) & ~3); ++ } else { ++ skb_trim(buf, packet_len); ++ ++ if (s->current_rx_buf) { ++ usbnet_skb_return(dev, buf); ++ s->current_rx_buf = NULL; ++ return 0; ++ } ++ ++ return 1; ++ } ++ } ++ ++error: ++ if (s->current_rx_buf) { ++ dev_kfree_skb_any(s->current_rx_buf); ++ s->current_rx_buf = NULL; ++ } ++ dev->net->stats.rx_errors++; ++ return 0; ++} ++ ++static struct sk_buff *vl600_tx_fixup(struct usbnet *dev, ++ struct sk_buff *skb, gfp_t flags) ++{ ++ struct sk_buff *ret; ++ struct vl600_frame_hdr *frame; ++ struct vl600_pkt_hdr *packet; ++ static uint32_t serial = 1; ++ int orig_len = skb->len - sizeof(struct ethhdr); ++ int full_len = (skb->len + sizeof(struct vl600_frame_hdr) + 3) & ~3; ++ ++ frame = (struct vl600_frame_hdr *) skb->data; ++ if (skb->len > sizeof(*frame) && skb->len == le32_to_cpup(&frame->len)) ++ return skb; /* Already encapsulated? */ ++ ++ if (skb->len < sizeof(struct ethhdr)) ++ /* Drop, device can only deal with ethernet packets */ ++ return NULL; ++ ++ if (!skb_cloned(skb)) { ++ int headroom = skb_headroom(skb); ++ int tailroom = skb_tailroom(skb); ++ ++ if (tailroom >= full_len - skb->len - sizeof(*frame) && ++ headroom >= sizeof(*frame)) ++ /* There's enough head and tail room */ ++ goto encapsulate; ++ ++ if (headroom + tailroom + skb->len >= full_len) { ++ /* There's enough total room, just readjust */ ++ skb->data = memmove(skb->head + sizeof(*frame), ++ skb->data, skb->len); ++ skb_set_tail_pointer(skb, skb->len); ++ goto encapsulate; ++ } ++ } ++ ++ /* Alloc a new skb with the required size */ ++ ret = skb_copy_expand(skb, sizeof(struct vl600_frame_hdr), full_len - ++ skb->len - sizeof(struct vl600_frame_hdr), flags); ++ dev_kfree_skb_any(skb); ++ if (!ret) ++ return ret; ++ skb = ret; ++ ++encapsulate: ++ /* Packet header is same size as ethernet packet header ++ * (sizeof(*packet) == sizeof(struct ethhdr)), additionally the ++ * h_proto field is in the same place so we just leave it alone and ++ * overwrite the remaining fields. ++ */ ++ packet = (struct vl600_pkt_hdr *) skb->data; ++ /* The VL600 wants IPv6 packets to have an IPv4 ethertype ++ * Since this modem only supports IPv4 and IPv6, just set all ++ * frames to 0x0800 (ETH_P_IP) ++ */ ++ packet->h_proto = htons(ETH_P_IP); ++ memset(&packet->dummy, 0, sizeof(packet->dummy)); ++ packet->len = cpu_to_le32(orig_len); ++ ++ frame = (struct vl600_frame_hdr *) skb_push(skb, sizeof(*frame)); ++ memset(frame, 0, sizeof(*frame)); ++ frame->len = cpu_to_le32(full_len); ++ frame->serial = cpu_to_le32(serial++); ++ frame->pkt_cnt = cpu_to_le32(1); ++ ++ if (skb->len < full_len) /* Pad */ ++ skb_put(skb, full_len - skb->len); ++ ++ return skb; ++} ++ ++static const struct driver_info vl600_info = { ++ .description = "LG VL600 modem", ++ .flags = FLAG_RX_ASSEMBLE | FLAG_WWAN, ++ .bind = vl600_bind, ++ .unbind = vl600_unbind, ++ .status = usbnet_cdc_status, ++ .rx_fixup = vl600_rx_fixup, ++ .tx_fixup = vl600_tx_fixup, ++}; ++ ++static const struct usb_device_id products[] = { ++ { ++ USB_DEVICE_AND_INTERFACE_INFO(0x1004, 0x61aa, USB_CLASS_COMM, ++ USB_CDC_SUBCLASS_ETHERNET, USB_CDC_PROTO_NONE), ++ .driver_info = (unsigned long) &vl600_info, ++ }, ++ {}, /* End */ ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver lg_vl600_driver = { ++ .name = "lg-vl600", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(lg_vl600_driver); ++ ++MODULE_AUTHOR("Anrzej Zaborowski"); ++MODULE_DESCRIPTION("LG-VL600 modem's ethernet link"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/Makefile backports-4.2.6-1/drivers/net/usb/Makefile +--- backports-4.2.6-1.org/drivers/net/usb/Makefile 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/Makefile 2016-01-27 15:53:50.000000000 +0100 +@@ -1,39 +1,40 @@ + # + # Makefile for USB Network drivers + # +-# +-#obj-$(CPTCFG_USB_CATC) += catc.o +-#obj-$(CPTCFG_USB_KAWETH) += kaweth.o +-#obj-$(CPTCFG_USB_PEGASUS) += pegasus.o +-#obj-$(CPTCFG_USB_RTL8150) += rtl8150.o +-#obj-$(CPTCFG_USB_RTL8152) += r8152.o +-#obj-$(CPTCFG_USB_HSO) += hso.o +-#obj-$(CPTCFG_USB_NET_AX8817X) += asix.o +-#obj-$(CPTCFG_USB_NET_AX88179_178A) += ax88179_178a.o ++ ++obj-$(CPTCFG_USB_CATC) += catc.o ++obj-$(CPTCFG_USB_KAWETH) += kaweth.o ++obj-$(CPTCFG_USB_PEGASUS) += pegasus.o ++obj-$(CPTCFG_USB_RTL8150) += rtl8150.o ++obj-$(CPTCFG_USB_RTL8152) += r8152.o ++obj-$(CPTCFG_USB_HSO) += hso.o ++obj-$(CPTCFG_USB_NET_AX8817X) += asix.o ++asix-y := asix_devices.o asix_common.o ax88172a.o ++obj-$(CPTCFG_USB_NET_AX88179_178A) += ax88179_178a.o + obj-$(CPTCFG_USB_NET_CDCETHER) += cdc_ether.o +-#obj-$(CPTCFG_USB_NET_CDC_EEM) += cdc_eem.o +-#obj-$(CPTCFG_USB_NET_DM9601) += dm9601.o +-#obj-$(CPTCFG_USB_NET_SR9700) += sr9700.o +-#obj-$(CPTCFG_USB_NET_SR9800) += sr9800.o +-#obj-$(CPTCFG_USB_NET_SMSC75XX) += smsc75xx.o +-#obj-$(CPTCFG_USB_NET_SMSC95XX) += smsc95xx.o +-#obj-$(CPTCFG_USB_NET_GL620A) += gl620a.o +-#obj-$(CPTCFG_USB_NET_NET1080) += net1080.o +-#obj-$(CPTCFG_USB_NET_PLUSB) += plusb.o ++obj-$(CPTCFG_USB_NET_CDC_EEM) += cdc_eem.o ++obj-$(CPTCFG_USB_NET_DM9601) += dm9601.o ++obj-$(CPTCFG_USB_NET_SR9700) += sr9700.o ++obj-$(CPTCFG_USB_NET_SR9800) += sr9800.o ++obj-$(CPTCFG_USB_NET_SMSC75XX) += smsc75xx.o ++obj-$(CPTCFG_USB_NET_SMSC95XX) += smsc95xx.o ++obj-$(CPTCFG_USB_NET_GL620A) += gl620a.o ++obj-$(CPTCFG_USB_NET_NET1080) += net1080.o ++obj-$(CPTCFG_USB_NET_PLUSB) += plusb.o + obj-$(CPTCFG_USB_NET_RNDIS_HOST) += rndis_host.o +-#obj-$(CPTCFG_USB_NET_CDC_SUBSET) += cdc_subset.o +-#obj-$(CPTCFG_USB_NET_ZAURUS) += zaurus.o +-#obj-$(CPTCFG_USB_NET_MCS7830) += mcs7830.o ++obj-$(CPTCFG_USB_NET_CDC_SUBSET) += cdc_subset.o ++obj-$(CPTCFG_USB_NET_ZAURUS) += zaurus.o ++obj-$(CPTCFG_USB_NET_MCS7830) += mcs7830.o + obj-$(CPTCFG_USB_USBNET) += usbnet.o +-#obj-$(CPTCFG_USB_NET_INT51X1) += int51x1.o +-#obj-$(CPTCFG_USB_CDC_PHONET) += cdc-phonet.o +-#obj-$(CPTCFG_USB_NET_KALMIA) += kalmia.o +-#obj-$(CPTCFG_USB_IPHETH) += ipheth.o ++obj-$(CPTCFG_USB_NET_INT51X1) += int51x1.o ++obj-$(CPTCFG_USB_CDC_PHONET) += cdc-phonet.o ++obj-$(CPTCFG_USB_NET_KALMIA) += kalmia.o ++obj-$(CPTCFG_USB_IPHETH) += ipheth.o + obj-$(CPTCFG_USB_SIERRA_NET) += sierra_net.o +-#obj-$(CPTCFG_USB_NET_CX82310_ETH) += cx82310_eth.o ++obj-$(CPTCFG_USB_NET_CX82310_ETH) += cx82310_eth.o + obj-$(CPTCFG_USB_NET_CDC_NCM) += cdc_ncm.o +-#obj-$(CPTCFG_USB_NET_HUAWEI_CDC_NCM) += huawei_cdc_ncm.o +-#obj-$(CPTCFG_USB_VL600) += lg-vl600.o ++obj-$(CPTCFG_USB_NET_HUAWEI_CDC_NCM) += huawei_cdc_ncm.o ++obj-$(CPTCFG_USB_VL600) += lg-vl600.o + obj-$(CPTCFG_USB_NET_QMI_WWAN) += qmi_wwan.o + obj-$(CPTCFG_USB_NET_CDC_MBIM) += cdc_mbim.o + +diff -Naur backports-4.2.6-1.org/drivers/net/usb/mcs7830.c backports-4.2.6-1/drivers/net/usb/mcs7830.c +--- backports-4.2.6-1.org/drivers/net/usb/mcs7830.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/mcs7830.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,643 @@ ++/* ++ * MOSCHIP MCS7830 based (7730/7830/7832) USB 2.0 Ethernet Devices ++ * ++ * based on usbnet.c, asix.c and the vendor provided mcs7830 driver ++ * ++ * Copyright (C) 2010 Andreas Mohr andi@lisas.de ++ * Copyright (C) 2006 Arnd Bergmann arnd@arndb.de ++ * Copyright (C) 2003-2005 David Hollis dhollis@davehollis.com ++ * Copyright (C) 2005 Phil Chang pchang23@sbcglobal.net ++ * Copyright (c) 2002-2003 TiVo Inc. ++ * ++ * Definitions gathered from MOSCHIP, Data Sheet_7830DA.pdf (thanks!). ++ * ++ * 2010-12-19: add 7832 USB PID ("functionality same as MCS7830"), ++ * per active notification by manufacturer ++ * ++ * TODO: ++ * - support HIF_REG_CONFIG_SLEEPMODE/HIF_REG_CONFIG_TXENABLE (via autopm?) ++ * - implement ethtool_ops get_pauseparam/set_pauseparam ++ * via HIF_REG_PAUSE_THRESHOLD (>= revision C only!) ++ * - implement get_eeprom/[set_eeprom] ++ * - switch PHY on/off on ifup/ifdown (perhaps in usbnet.c, via MII) ++ * - mcs7830_get_regs() handling is weird: for rev 2 we return 32 regs, ++ * can access only ~ 24, remaining user buffer is uninitialized garbage ++ * - anything else? ++ * ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++#include <linux/crc32.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/mii.h> ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/slab.h> ++#include <linux/usb.h> ++#include <linux/usb/usbnet.h> ++ ++/* requests */ ++#define MCS7830_RD_BMREQ (USB_DIR_IN | USB_TYPE_VENDOR | \ ++ USB_RECIP_DEVICE) ++#define MCS7830_WR_BMREQ (USB_DIR_OUT | USB_TYPE_VENDOR | \ ++ USB_RECIP_DEVICE) ++#define MCS7830_RD_BREQ 0x0E ++#define MCS7830_WR_BREQ 0x0D ++ ++#define MCS7830_CTRL_TIMEOUT 1000 ++#define MCS7830_MAX_MCAST 64 ++ ++#define MCS7830_VENDOR_ID 0x9710 ++#define MCS7832_PRODUCT_ID 0x7832 ++#define MCS7830_PRODUCT_ID 0x7830 ++#define MCS7730_PRODUCT_ID 0x7730 ++ ++#define SITECOM_VENDOR_ID 0x0DF6 ++#define LN_030_PRODUCT_ID 0x0021 ++ ++#define MCS7830_MII_ADVERTISE (ADVERTISE_PAUSE_CAP | ADVERTISE_100FULL | \ ++ ADVERTISE_100HALF | ADVERTISE_10FULL | \ ++ ADVERTISE_10HALF | ADVERTISE_CSMA) ++ ++/* HIF_REG_XX corresponding index value */ ++enum { ++ HIF_REG_MULTICAST_HASH = 0x00, ++ HIF_REG_PACKET_GAP1 = 0x08, ++ HIF_REG_PACKET_GAP2 = 0x09, ++ HIF_REG_PHY_DATA = 0x0a, ++ HIF_REG_PHY_CMD1 = 0x0c, ++ HIF_REG_PHY_CMD1_READ = 0x40, ++ HIF_REG_PHY_CMD1_WRITE = 0x20, ++ HIF_REG_PHY_CMD1_PHYADDR = 0x01, ++ HIF_REG_PHY_CMD2 = 0x0d, ++ HIF_REG_PHY_CMD2_PEND_FLAG_BIT = 0x80, ++ HIF_REG_PHY_CMD2_READY_FLAG_BIT = 0x40, ++ HIF_REG_CONFIG = 0x0e, ++ /* hmm, spec sez: "R/W", "Except bit 3" (likely TXENABLE). */ ++ HIF_REG_CONFIG_CFG = 0x80, ++ HIF_REG_CONFIG_SPEED100 = 0x40, ++ HIF_REG_CONFIG_FULLDUPLEX_ENABLE = 0x20, ++ HIF_REG_CONFIG_RXENABLE = 0x10, ++ HIF_REG_CONFIG_TXENABLE = 0x08, ++ HIF_REG_CONFIG_SLEEPMODE = 0x04, ++ HIF_REG_CONFIG_ALLMULTICAST = 0x02, ++ HIF_REG_CONFIG_PROMISCUOUS = 0x01, ++ HIF_REG_ETHERNET_ADDR = 0x0f, ++ HIF_REG_FRAME_DROP_COUNTER = 0x15, /* 0..ff; reset: 0 */ ++ HIF_REG_PAUSE_THRESHOLD = 0x16, ++ HIF_REG_PAUSE_THRESHOLD_DEFAULT = 0, ++}; ++ ++/* Trailing status byte in Ethernet Rx frame */ ++enum { ++ MCS7830_RX_SHORT_FRAME = 0x01, /* < 64 bytes */ ++ MCS7830_RX_LENGTH_ERROR = 0x02, /* framelen != Ethernet length field */ ++ MCS7830_RX_ALIGNMENT_ERROR = 0x04, /* non-even number of nibbles */ ++ MCS7830_RX_CRC_ERROR = 0x08, ++ MCS7830_RX_LARGE_FRAME = 0x10, /* > 1518 bytes */ ++ MCS7830_RX_FRAME_CORRECT = 0x20, /* frame is correct */ ++ /* [7:6] reserved */ ++}; ++ ++struct mcs7830_data { ++ u8 multi_filter[8]; ++ u8 config; ++}; ++ ++static const char driver_name[] = "MOSCHIP usb-ethernet driver"; ++ ++static int mcs7830_get_reg(struct usbnet *dev, u16 index, u16 size, void *data) ++{ ++ return usbnet_read_cmd(dev, MCS7830_RD_BREQ, MCS7830_RD_BMREQ, ++ 0x0000, index, data, size); ++} ++ ++static int mcs7830_set_reg(struct usbnet *dev, u16 index, u16 size, const void *data) ++{ ++ return usbnet_write_cmd(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ, ++ 0x0000, index, data, size); ++} ++ ++static void mcs7830_set_reg_async(struct usbnet *dev, u16 index, u16 size, void *data) ++{ ++ usbnet_write_cmd_async(dev, MCS7830_WR_BREQ, MCS7830_WR_BMREQ, ++ 0x0000, index, data, size); ++} ++ ++static int mcs7830_hif_get_mac_address(struct usbnet *dev, unsigned char *addr) ++{ ++ int ret = mcs7830_get_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr); ++ if (ret < 0) ++ return ret; ++ return 0; ++} ++ ++static int mcs7830_hif_set_mac_address(struct usbnet *dev, unsigned char *addr) ++{ ++ int ret = mcs7830_set_reg(dev, HIF_REG_ETHERNET_ADDR, ETH_ALEN, addr); ++ ++ if (ret < 0) ++ return ret; ++ return 0; ++} ++ ++static int mcs7830_set_mac_address(struct net_device *netdev, void *p) ++{ ++ int ret; ++ struct usbnet *dev = netdev_priv(netdev); ++ struct sockaddr *addr = p; ++ ++ if (netif_running(netdev)) ++ return -EBUSY; ++ ++ if (!is_valid_ether_addr(addr->sa_data)) ++ return -EADDRNOTAVAIL; ++ ++ ret = mcs7830_hif_set_mac_address(dev, addr->sa_data); ++ ++ if (ret < 0) ++ return ret; ++ ++ /* it worked --> adopt it on netdev side */ ++ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); ++ ++ return 0; ++} ++ ++static int mcs7830_read_phy(struct usbnet *dev, u8 index) ++{ ++ int ret; ++ int i; ++ __le16 val; ++ ++ u8 cmd[2] = { ++ HIF_REG_PHY_CMD1_READ | HIF_REG_PHY_CMD1_PHYADDR, ++ HIF_REG_PHY_CMD2_PEND_FLAG_BIT | index, ++ }; ++ ++ mutex_lock(&dev->phy_mutex); ++ /* write the MII command */ ++ ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); ++ if (ret < 0) ++ goto out; ++ ++ /* wait for the data to become valid, should be within < 1ms */ ++ for (i = 0; i < 10; i++) { ++ ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); ++ if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT)) ++ break; ++ ret = -EIO; ++ msleep(1); ++ } ++ if (ret < 0) ++ goto out; ++ ++ /* read actual register contents */ ++ ret = mcs7830_get_reg(dev, HIF_REG_PHY_DATA, 2, &val); ++ if (ret < 0) ++ goto out; ++ ret = le16_to_cpu(val); ++ dev_dbg(&dev->udev->dev, "read PHY reg %02x: %04x (%d tries)\n", ++ index, val, i); ++out: ++ mutex_unlock(&dev->phy_mutex); ++ return ret; ++} ++ ++static int mcs7830_write_phy(struct usbnet *dev, u8 index, u16 val) ++{ ++ int ret; ++ int i; ++ __le16 le_val; ++ ++ u8 cmd[2] = { ++ HIF_REG_PHY_CMD1_WRITE | HIF_REG_PHY_CMD1_PHYADDR, ++ HIF_REG_PHY_CMD2_PEND_FLAG_BIT | (index & 0x1F), ++ }; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ /* write the new register contents */ ++ le_val = cpu_to_le16(val); ++ ret = mcs7830_set_reg(dev, HIF_REG_PHY_DATA, 2, &le_val); ++ if (ret < 0) ++ goto out; ++ ++ /* write the MII command */ ++ ret = mcs7830_set_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); ++ if (ret < 0) ++ goto out; ++ ++ /* wait for the command to be accepted by the PHY */ ++ for (i = 0; i < 10; i++) { ++ ret = mcs7830_get_reg(dev, HIF_REG_PHY_CMD1, 2, cmd); ++ if ((ret < 0) || (cmd[1] & HIF_REG_PHY_CMD2_READY_FLAG_BIT)) ++ break; ++ ret = -EIO; ++ msleep(1); ++ } ++ if (ret < 0) ++ goto out; ++ ++ ret = 0; ++ dev_dbg(&dev->udev->dev, "write PHY reg %02x: %04x (%d tries)\n", ++ index, val, i); ++out: ++ mutex_unlock(&dev->phy_mutex); ++ return ret; ++} ++ ++/* ++ * This algorithm comes from the original mcs7830 version 1.4 driver, ++ * not sure if it is needed. ++ */ ++static int mcs7830_set_autoneg(struct usbnet *dev, int ptrUserPhyMode) ++{ ++ int ret; ++ /* Enable all media types */ ++ ret = mcs7830_write_phy(dev, MII_ADVERTISE, MCS7830_MII_ADVERTISE); ++ ++ /* First reset BMCR */ ++ if (!ret) ++ ret = mcs7830_write_phy(dev, MII_BMCR, 0x0000); ++ /* Enable Auto Neg */ ++ if (!ret) ++ ret = mcs7830_write_phy(dev, MII_BMCR, BMCR_ANENABLE); ++ /* Restart Auto Neg (Keep the Enable Auto Neg Bit Set) */ ++ if (!ret) ++ ret = mcs7830_write_phy(dev, MII_BMCR, ++ BMCR_ANENABLE | BMCR_ANRESTART ); ++ return ret; ++} ++ ++ ++/* ++ * if we can read register 22, the chip revision is C or higher ++ */ ++static int mcs7830_get_rev(struct usbnet *dev) ++{ ++ u8 dummy[2]; ++ int ret; ++ ret = mcs7830_get_reg(dev, HIF_REG_FRAME_DROP_COUNTER, 2, dummy); ++ if (ret > 0) ++ return 2; /* Rev C or later */ ++ return 1; /* earlier revision */ ++} ++ ++/* ++ * On rev. C we need to set the pause threshold ++ */ ++static void mcs7830_rev_C_fixup(struct usbnet *dev) ++{ ++ u8 pause_threshold = HIF_REG_PAUSE_THRESHOLD_DEFAULT; ++ int retry; ++ ++ for (retry = 0; retry < 2; retry++) { ++ if (mcs7830_get_rev(dev) == 2) { ++ dev_info(&dev->udev->dev, "applying rev.C fixup\n"); ++ mcs7830_set_reg(dev, HIF_REG_PAUSE_THRESHOLD, ++ 1, &pause_threshold); ++ } ++ msleep(1); ++ } ++} ++ ++static int mcs7830_mdio_read(struct net_device *netdev, int phy_id, ++ int location) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ return mcs7830_read_phy(dev, location); ++} ++ ++static void mcs7830_mdio_write(struct net_device *netdev, int phy_id, ++ int location, int val) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ mcs7830_write_phy(dev, location, val); ++} ++ ++static int mcs7830_ioctl(struct net_device *net, struct ifreq *rq, int cmd) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); ++} ++ ++static inline struct mcs7830_data *mcs7830_get_data(struct usbnet *dev) ++{ ++ return (struct mcs7830_data *)&dev->data; ++} ++ ++static void mcs7830_hif_update_multicast_hash(struct usbnet *dev) ++{ ++ struct mcs7830_data *data = mcs7830_get_data(dev); ++ mcs7830_set_reg_async(dev, HIF_REG_MULTICAST_HASH, ++ sizeof data->multi_filter, ++ data->multi_filter); ++} ++ ++static void mcs7830_hif_update_config(struct usbnet *dev) ++{ ++ /* implementation specific to data->config ++ (argument needs to be heap-based anyway - USB DMA!) */ ++ struct mcs7830_data *data = mcs7830_get_data(dev); ++ mcs7830_set_reg_async(dev, HIF_REG_CONFIG, 1, &data->config); ++} ++ ++static void mcs7830_data_set_multicast(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct mcs7830_data *data = mcs7830_get_data(dev); ++ ++ memset(data->multi_filter, 0, sizeof data->multi_filter); ++ ++ data->config = HIF_REG_CONFIG_TXENABLE; ++ ++ /* this should not be needed, but it doesn't work otherwise */ ++ data->config |= HIF_REG_CONFIG_ALLMULTICAST; ++ ++ if (net->flags & IFF_PROMISC) { ++ data->config |= HIF_REG_CONFIG_PROMISCUOUS; ++ } else if (net->flags & IFF_ALLMULTI || ++ netdev_mc_count(net) > MCS7830_MAX_MCAST) { ++ data->config |= HIF_REG_CONFIG_ALLMULTICAST; ++ } else if (netdev_mc_empty(net)) { ++ /* just broadcast and directed */ ++ } else { ++ /* We use the 20 byte dev->data ++ * for our 8 byte filter buffer ++ * to avoid allocating memory that ++ * is tricky to free later */ ++ struct netdev_hw_addr *ha; ++ u32 crc_bits; ++ ++ /* Build the multicast hash filter. */ ++ netdev_for_each_mc_addr(ha, net) { ++ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; ++ data->multi_filter[crc_bits >> 3] |= 1 << (crc_bits & 7); ++ } ++ } ++} ++ ++static int mcs7830_apply_base_config(struct usbnet *dev) ++{ ++ int ret; ++ ++ /* re-configure known MAC (suspend case etc.) */ ++ ret = mcs7830_hif_set_mac_address(dev, dev->net->dev_addr); ++ if (ret) { ++ dev_info(&dev->udev->dev, "Cannot set MAC address\n"); ++ goto out; ++ } ++ ++ /* Set up PHY */ ++ ret = mcs7830_set_autoneg(dev, 0); ++ if (ret) { ++ dev_info(&dev->udev->dev, "Cannot set autoneg\n"); ++ goto out; ++ } ++ ++ mcs7830_hif_update_multicast_hash(dev); ++ mcs7830_hif_update_config(dev); ++ ++ mcs7830_rev_C_fixup(dev); ++ ret = 0; ++out: ++ return ret; ++} ++ ++/* credits go to asix_set_multicast */ ++static void mcs7830_set_multicast(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ mcs7830_data_set_multicast(net); ++ ++ mcs7830_hif_update_multicast_hash(dev); ++ mcs7830_hif_update_config(dev); ++} ++ ++static int mcs7830_get_regs_len(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ switch (mcs7830_get_rev(dev)) { ++ case 1: ++ return 21; ++ case 2: ++ return 32; ++ } ++ return 0; ++} ++ ++static void mcs7830_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *drvinfo) ++{ ++ usbnet_get_drvinfo(net, drvinfo); ++ drvinfo->regdump_len = mcs7830_get_regs_len(net); ++} ++ ++static void mcs7830_get_regs(struct net_device *net, struct ethtool_regs *regs, void *data) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ regs->version = mcs7830_get_rev(dev); ++ mcs7830_get_reg(dev, 0, regs->len, data); ++} ++ ++static const struct ethtool_ops mcs7830_ethtool_ops = { ++ .get_drvinfo = mcs7830_get_drvinfo, ++ .get_regs_len = mcs7830_get_regs_len, ++ .get_regs = mcs7830_get_regs, ++ ++ /* common usbnet calls */ ++ .get_link = usbnet_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .nway_reset = usbnet_nway_reset, ++}; ++ ++static const struct net_device_ops mcs7830_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = mcs7830_ioctl, ++ .ndo_set_rx_mode = mcs7830_set_multicast, ++ .ndo_set_mac_address = mcs7830_set_mac_address, ++}; ++ ++static int mcs7830_bind(struct usbnet *dev, struct usb_interface *udev) ++{ ++ struct net_device *net = dev->net; ++ int ret; ++ int retry; ++ ++ /* Initial startup: Gather MAC address setting from EEPROM */ ++ ret = -EINVAL; ++ for (retry = 0; retry < 5 && ret; retry++) ++ ret = mcs7830_hif_get_mac_address(dev, net->dev_addr); ++ if (ret) { ++ dev_warn(&dev->udev->dev, "Cannot read MAC address\n"); ++ goto out; ++ } ++ ++ mcs7830_data_set_multicast(net); ++ ++ ret = mcs7830_apply_base_config(dev); ++ if (ret) ++ goto out; ++ ++ net->ethtool_ops = &mcs7830_ethtool_ops; ++ net->netdev_ops = &mcs7830_netdev_ops; ++ ++ /* reserve space for the status byte on rx */ ++ dev->rx_urb_size = ETH_FRAME_LEN + 1; ++ ++ dev->mii.mdio_read = mcs7830_mdio_read; ++ dev->mii.mdio_write = mcs7830_mdio_write; ++ dev->mii.dev = net; ++ dev->mii.phy_id_mask = 0x3f; ++ dev->mii.reg_num_mask = 0x1f; ++ dev->mii.phy_id = *((u8 *) net->dev_addr + 1); ++ ++ ret = usbnet_get_endpoints(dev, udev); ++out: ++ return ret; ++} ++ ++/* The chip always appends a status byte that we need to strip */ ++static int mcs7830_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ u8 status; ++ ++ /* This check is no longer done by usbnet */ ++ if (skb->len < dev->net->hard_header_len) { ++ dev_err(&dev->udev->dev, "unexpected tiny rx frame\n"); ++ return 0; ++ } ++ ++ skb_trim(skb, skb->len - 1); ++ status = skb->data[skb->len]; ++ ++ if (status != MCS7830_RX_FRAME_CORRECT) { ++ dev_dbg(&dev->udev->dev, "rx fixup status %x\n", status); ++ ++ /* hmm, perhaps usbnet.c already sees a globally visible ++ frame error and increments rx_errors on its own already? */ ++ dev->net->stats.rx_errors++; ++ ++ if (status & (MCS7830_RX_SHORT_FRAME ++ |MCS7830_RX_LENGTH_ERROR ++ |MCS7830_RX_LARGE_FRAME)) ++ dev->net->stats.rx_length_errors++; ++ if (status & MCS7830_RX_ALIGNMENT_ERROR) ++ dev->net->stats.rx_frame_errors++; ++ if (status & MCS7830_RX_CRC_ERROR) ++ dev->net->stats.rx_crc_errors++; ++ } ++ ++ return skb->len > 0; ++} ++ ++static void mcs7830_status(struct usbnet *dev, struct urb *urb) ++{ ++ u8 *buf = urb->transfer_buffer; ++ bool link, link_changed; ++ ++ if (urb->actual_length < 16) ++ return; ++ ++ link = !(buf[1] == 0x20); ++ link_changed = netif_carrier_ok(dev->net) != link; ++ if (link_changed) { ++ usbnet_link_change(dev, link, 0); ++ netdev_dbg(dev->net, "Link Status is: %d\n", link); ++ } ++} ++ ++static const struct driver_info moschip_info = { ++ .description = "MOSCHIP 7830/7832/7730 usb-NET adapter", ++ .bind = mcs7830_bind, ++ .rx_fixup = mcs7830_rx_fixup, ++ .flags = FLAG_ETHER | FLAG_LINK_INTR, ++ .status = mcs7830_status, ++ .in = 1, ++ .out = 2, ++}; ++ ++static const struct driver_info sitecom_info = { ++ .description = "Sitecom LN-30 usb-NET adapter", ++ .bind = mcs7830_bind, ++ .rx_fixup = mcs7830_rx_fixup, ++ .flags = FLAG_ETHER | FLAG_LINK_INTR, ++ .status = mcs7830_status, ++ .in = 1, ++ .out = 2, ++}; ++ ++static const struct usb_device_id products[] = { ++ { ++ USB_DEVICE(MCS7830_VENDOR_ID, MCS7832_PRODUCT_ID), ++ .driver_info = (unsigned long) &moschip_info, ++ }, ++ { ++ USB_DEVICE(MCS7830_VENDOR_ID, MCS7830_PRODUCT_ID), ++ .driver_info = (unsigned long) &moschip_info, ++ }, ++ { ++ USB_DEVICE(MCS7830_VENDOR_ID, MCS7730_PRODUCT_ID), ++ .driver_info = (unsigned long) &moschip_info, ++ }, ++ { ++ USB_DEVICE(SITECOM_VENDOR_ID, LN_030_PRODUCT_ID), ++ .driver_info = (unsigned long) &sitecom_info, ++ }, ++ {}, ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static int mcs7830_reset_resume (struct usb_interface *intf) ++{ ++ /* YES, this function is successful enough that ethtool -d ++ does show same output pre-/post-suspend */ ++ ++ struct usbnet *dev = usb_get_intfdata(intf); ++ ++ mcs7830_apply_base_config(dev); ++ ++ usbnet_resume(intf); ++ ++ return 0; ++} ++ ++static struct usb_driver mcs7830_driver = { ++ .name = driver_name, ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .reset_resume = mcs7830_reset_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(mcs7830_driver); ++ ++MODULE_DESCRIPTION("USB to network adapter MCS7830)"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/net1080.c backports-4.2.6-1/drivers/net/usb/net1080.c +--- backports-4.2.6-1.org/drivers/net/usb/net1080.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/net1080.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,544 @@ ++/* ++ * Net1080 based USB host-to-host cables ++ * Copyright (C) 2000-2005 by David Brownell ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++// #define DEBUG // error path messages, extra info ++// #define VERBOSE // more; success messages ++ ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/usb/usbnet.h> ++#include <linux/slab.h> ++ ++#include <asm/unaligned.h> ++ ++ ++/* ++ * Netchip 1080 driver ... http://www.netchip.com ++ * (Sept 2004: End-of-life announcement has been sent.) ++ * Used in (some) LapLink cables ++ */ ++ ++#define frame_errors data[1] ++ ++/* ++ * NetChip framing of ethernet packets, supporting additional error ++ * checks for links that may drop bulk packets from inside messages. ++ * Odd USB length == always short read for last usb packet. ++ * - nc_header ++ * - Ethernet header (14 bytes) ++ * - payload ++ * - (optional padding byte, if needed so length becomes odd) ++ * - nc_trailer ++ * ++ * This framing is to be avoided for non-NetChip devices. ++ */ ++ ++struct nc_header { // packed: ++ __le16 hdr_len; // sizeof nc_header (LE, all) ++ __le16 packet_len; // payload size (including ethhdr) ++ __le16 packet_id; // detects dropped packets ++#define MIN_HEADER 6 ++ ++ // all else is optional, and must start with: ++ // __le16 vendorId; // from usb-if ++ // __le16 productId; ++} __packed; ++ ++#define PAD_BYTE ((unsigned char)0xAC) ++ ++struct nc_trailer { ++ __le16 packet_id; ++} __packed; ++ ++// packets may use FLAG_FRAMING_NC and optional pad ++#define FRAMED_SIZE(mtu) (sizeof (struct nc_header) \ ++ + sizeof (struct ethhdr) \ ++ + (mtu) \ ++ + 1 \ ++ + sizeof (struct nc_trailer)) ++ ++#define MIN_FRAMED FRAMED_SIZE(0) ++ ++/* packets _could_ be up to 64KB... */ ++#define NC_MAX_PACKET 32767 ++ ++ ++/* ++ * Zero means no timeout; else, how long a 64 byte bulk packet may be queued ++ * before the hardware drops it. If that's done, the driver will need to ++ * frame network packets to guard against the dropped USB packets. The win32 ++ * driver sets this for both sides of the link. ++ */ ++#define NC_READ_TTL_MS ((u8)255) // ms ++ ++/* ++ * We ignore most registers and EEPROM contents. ++ */ ++#define REG_USBCTL ((u8)0x04) ++#define REG_TTL ((u8)0x10) ++#define REG_STATUS ((u8)0x11) ++ ++/* ++ * Vendor specific requests to read/write data ++ */ ++#define REQUEST_REGISTER ((u8)0x10) ++#define REQUEST_EEPROM ((u8)0x11) ++ ++static int ++nc_vendor_read(struct usbnet *dev, u8 req, u8 regnum, u16 *retval_ptr) ++{ ++ int status = usbnet_read_cmd(dev, req, ++ USB_DIR_IN | USB_TYPE_VENDOR | ++ USB_RECIP_DEVICE, ++ 0, regnum, retval_ptr, ++ sizeof *retval_ptr); ++ if (status > 0) ++ status = 0; ++ if (!status) ++ le16_to_cpus(retval_ptr); ++ return status; ++} ++ ++static inline int ++nc_register_read(struct usbnet *dev, u8 regnum, u16 *retval_ptr) ++{ ++ return nc_vendor_read(dev, REQUEST_REGISTER, regnum, retval_ptr); ++} ++ ++// no retval ... can become async, usable in_interrupt() ++static void ++nc_vendor_write(struct usbnet *dev, u8 req, u8 regnum, u16 value) ++{ ++ usbnet_write_cmd(dev, req, ++ USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ value, regnum, NULL, 0); ++} ++ ++static inline void ++nc_register_write(struct usbnet *dev, u8 regnum, u16 value) ++{ ++ nc_vendor_write(dev, REQUEST_REGISTER, regnum, value); ++} ++ ++ ++#if 0 ++static void nc_dump_registers(struct usbnet *dev) ++{ ++ u8 reg; ++ u16 *vp = kmalloc(sizeof (u16)); ++ ++ if (!vp) ++ return; ++ ++ netdev_dbg(dev->net, "registers:\n"); ++ for (reg = 0; reg < 0x20; reg++) { ++ int retval; ++ ++ // reading some registers is trouble ++ if (reg >= 0x08 && reg <= 0xf) ++ continue; ++ if (reg >= 0x12 && reg <= 0x1e) ++ continue; ++ ++ retval = nc_register_read(dev, reg, vp); ++ if (retval < 0) ++ netdev_dbg(dev->net, "reg [0x%x] ==> error %d\n", ++ reg, retval); ++ else ++ netdev_dbg(dev->net, "reg [0x%x] = 0x%x\n", reg, *vp); ++ } ++ kfree(vp); ++} ++#endif ++ ++ ++/*-------------------------------------------------------------------------*/ ++ ++/* ++ * Control register ++ */ ++ ++#define USBCTL_WRITABLE_MASK 0x1f0f ++// bits 15-13 reserved, r/o ++#define USBCTL_ENABLE_LANG (1 << 12) ++#define USBCTL_ENABLE_MFGR (1 << 11) ++#define USBCTL_ENABLE_PROD (1 << 10) ++#define USBCTL_ENABLE_SERIAL (1 << 9) ++#define USBCTL_ENABLE_DEFAULTS (1 << 8) ++// bits 7-4 reserved, r/o ++#define USBCTL_FLUSH_OTHER (1 << 3) ++#define USBCTL_FLUSH_THIS (1 << 2) ++#define USBCTL_DISCONN_OTHER (1 << 1) ++#define USBCTL_DISCONN_THIS (1 << 0) ++ ++static inline void nc_dump_usbctl(struct usbnet *dev, u16 usbctl) ++{ ++ netif_dbg(dev, link, dev->net, ++ "net1080 %s-%s usbctl 0x%x:%s%s%s%s%s; this%s%s; other%s%s; r/o 0x%x\n", ++ dev->udev->bus->bus_name, dev->udev->devpath, ++ usbctl, ++ (usbctl & USBCTL_ENABLE_LANG) ? " lang" : "", ++ (usbctl & USBCTL_ENABLE_MFGR) ? " mfgr" : "", ++ (usbctl & USBCTL_ENABLE_PROD) ? " prod" : "", ++ (usbctl & USBCTL_ENABLE_SERIAL) ? " serial" : "", ++ (usbctl & USBCTL_ENABLE_DEFAULTS) ? " defaults" : "", ++ ++ (usbctl & USBCTL_FLUSH_THIS) ? " FLUSH" : "", ++ (usbctl & USBCTL_DISCONN_THIS) ? " DIS" : "", ++ ++ (usbctl & USBCTL_FLUSH_OTHER) ? " FLUSH" : "", ++ (usbctl & USBCTL_DISCONN_OTHER) ? " DIS" : "", ++ ++ usbctl & ~USBCTL_WRITABLE_MASK); ++} ++ ++/*-------------------------------------------------------------------------*/ ++ ++/* ++ * Status register ++ */ ++ ++#define STATUS_PORT_A (1 << 15) ++ ++#define STATUS_CONN_OTHER (1 << 14) ++#define STATUS_SUSPEND_OTHER (1 << 13) ++#define STATUS_MAILBOX_OTHER (1 << 12) ++#define STATUS_PACKETS_OTHER(n) (((n) >> 8) & 0x03) ++ ++#define STATUS_CONN_THIS (1 << 6) ++#define STATUS_SUSPEND_THIS (1 << 5) ++#define STATUS_MAILBOX_THIS (1 << 4) ++#define STATUS_PACKETS_THIS(n) (((n) >> 0) & 0x03) ++ ++#define STATUS_UNSPEC_MASK 0x0c8c ++#define STATUS_NOISE_MASK ((u16)~(0x0303|STATUS_UNSPEC_MASK)) ++ ++ ++static inline void nc_dump_status(struct usbnet *dev, u16 status) ++{ ++ netif_dbg(dev, link, dev->net, ++ "net1080 %s-%s status 0x%x: this (%c) PKT=%d%s%s%s; other PKT=%d%s%s%s; unspec 0x%x\n", ++ dev->udev->bus->bus_name, dev->udev->devpath, ++ status, ++ ++ // XXX the packet counts don't seem right ++ // (1 at reset, not 0); maybe UNSPEC too ++ ++ (status & STATUS_PORT_A) ? 'A' : 'B', ++ STATUS_PACKETS_THIS(status), ++ (status & STATUS_CONN_THIS) ? " CON" : "", ++ (status & STATUS_SUSPEND_THIS) ? " SUS" : "", ++ (status & STATUS_MAILBOX_THIS) ? " MBOX" : "", ++ ++ STATUS_PACKETS_OTHER(status), ++ (status & STATUS_CONN_OTHER) ? " CON" : "", ++ (status & STATUS_SUSPEND_OTHER) ? " SUS" : "", ++ (status & STATUS_MAILBOX_OTHER) ? " MBOX" : "", ++ ++ status & STATUS_UNSPEC_MASK); ++} ++ ++/*-------------------------------------------------------------------------*/ ++ ++/* ++ * TTL register ++ */ ++ ++#define TTL_THIS(ttl) (0x00ff & ttl) ++#define TTL_OTHER(ttl) (0x00ff & (ttl >> 8)) ++#define MK_TTL(this,other) ((u16)(((other)<<8)|(0x00ff&(this)))) ++ ++static inline void nc_dump_ttl(struct usbnet *dev, u16 ttl) ++{ ++ netif_dbg(dev, link, dev->net, "net1080 %s-%s ttl 0x%x this = %d, other = %d\n", ++ dev->udev->bus->bus_name, dev->udev->devpath, ++ ttl, TTL_THIS(ttl), TTL_OTHER(ttl)); ++} ++ ++/*-------------------------------------------------------------------------*/ ++ ++static int net1080_reset(struct usbnet *dev) ++{ ++ u16 usbctl, status, ttl; ++ u16 vp; ++ int retval; ++ ++ // nc_dump_registers(dev); ++ ++ if ((retval = nc_register_read(dev, REG_STATUS, &vp)) < 0) { ++ netdev_dbg(dev->net, "can't read %s-%s status: %d\n", ++ dev->udev->bus->bus_name, dev->udev->devpath, retval); ++ goto done; ++ } ++ status = vp; ++ nc_dump_status(dev, status); ++ ++ if ((retval = nc_register_read(dev, REG_USBCTL, &vp)) < 0) { ++ netdev_dbg(dev->net, "can't read USBCTL, %d\n", retval); ++ goto done; ++ } ++ usbctl = vp; ++ nc_dump_usbctl(dev, usbctl); ++ ++ nc_register_write(dev, REG_USBCTL, ++ USBCTL_FLUSH_THIS | USBCTL_FLUSH_OTHER); ++ ++ if ((retval = nc_register_read(dev, REG_TTL, &vp)) < 0) { ++ netdev_dbg(dev->net, "can't read TTL, %d\n", retval); ++ goto done; ++ } ++ ttl = vp; ++ // nc_dump_ttl(dev, ttl); ++ ++ nc_register_write(dev, REG_TTL, ++ MK_TTL(NC_READ_TTL_MS, TTL_OTHER(ttl)) ); ++ netdev_dbg(dev->net, "assigned TTL, %d ms\n", NC_READ_TTL_MS); ++ ++ netif_info(dev, link, dev->net, "port %c, peer %sconnected\n", ++ (status & STATUS_PORT_A) ? 'A' : 'B', ++ (status & STATUS_CONN_OTHER) ? "" : "dis"); ++ retval = 0; ++ ++done: ++ return retval; ++} ++ ++static int net1080_check_connect(struct usbnet *dev) ++{ ++ int retval; ++ u16 status; ++ u16 vp; ++ ++ retval = nc_register_read(dev, REG_STATUS, &vp); ++ status = vp; ++ if (retval != 0) { ++ netdev_dbg(dev->net, "net1080_check_conn read - %d\n", retval); ++ return retval; ++ } ++ if ((status & STATUS_CONN_OTHER) != STATUS_CONN_OTHER) ++ return -ENOLINK; ++ return 0; ++} ++ ++static void nc_ensure_sync(struct usbnet *dev) ++{ ++ if (++dev->frame_errors <= 5) ++ return; ++ ++ if (usbnet_write_cmd_async(dev, REQUEST_REGISTER, ++ USB_DIR_OUT | USB_TYPE_VENDOR | ++ USB_RECIP_DEVICE, ++ USBCTL_FLUSH_THIS | ++ USBCTL_FLUSH_OTHER, ++ REG_USBCTL, NULL, 0)) ++ return; ++ ++ netif_dbg(dev, rx_err, dev->net, ++ "flush net1080; too many framing errors\n"); ++ dev->frame_errors = 0; ++} ++ ++static int net1080_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ struct nc_header *header; ++ struct nc_trailer *trailer; ++ u16 hdr_len, packet_len; ++ ++ /* This check is no longer done by usbnet */ ++ if (skb->len < dev->net->hard_header_len) ++ return 0; ++ ++ if (!(skb->len & 0x01)) { ++ netdev_dbg(dev->net, "rx framesize %d range %d..%d mtu %d\n", ++ skb->len, dev->net->hard_header_len, dev->hard_mtu, ++ dev->net->mtu); ++ dev->net->stats.rx_frame_errors++; ++ nc_ensure_sync(dev); ++ return 0; ++ } ++ ++ header = (struct nc_header *) skb->data; ++ hdr_len = le16_to_cpup(&header->hdr_len); ++ packet_len = le16_to_cpup(&header->packet_len); ++ if (FRAMED_SIZE(packet_len) > NC_MAX_PACKET) { ++ dev->net->stats.rx_frame_errors++; ++ netdev_dbg(dev->net, "packet too big, %d\n", packet_len); ++ nc_ensure_sync(dev); ++ return 0; ++ } else if (hdr_len < MIN_HEADER) { ++ dev->net->stats.rx_frame_errors++; ++ netdev_dbg(dev->net, "header too short, %d\n", hdr_len); ++ nc_ensure_sync(dev); ++ return 0; ++ } else if (hdr_len > MIN_HEADER) { ++ // out of band data for us? ++ netdev_dbg(dev->net, "header OOB, %d bytes\n", hdr_len - MIN_HEADER); ++ nc_ensure_sync(dev); ++ // switch (vendor/product ids) { ... } ++ } ++ skb_pull(skb, hdr_len); ++ ++ trailer = (struct nc_trailer *) ++ (skb->data + skb->len - sizeof *trailer); ++ skb_trim(skb, skb->len - sizeof *trailer); ++ ++ if ((packet_len & 0x01) == 0) { ++ if (skb->data [packet_len] != PAD_BYTE) { ++ dev->net->stats.rx_frame_errors++; ++ netdev_dbg(dev->net, "bad pad\n"); ++ return 0; ++ } ++ skb_trim(skb, skb->len - 1); ++ } ++ if (skb->len != packet_len) { ++ dev->net->stats.rx_frame_errors++; ++ netdev_dbg(dev->net, "bad packet len %d (expected %d)\n", ++ skb->len, packet_len); ++ nc_ensure_sync(dev); ++ return 0; ++ } ++ if (header->packet_id != get_unaligned(&trailer->packet_id)) { ++ dev->net->stats.rx_fifo_errors++; ++ netdev_dbg(dev->net, "(2+ dropped) rx packet_id mismatch 0x%x 0x%x\n", ++ le16_to_cpu(header->packet_id), ++ le16_to_cpu(trailer->packet_id)); ++ return 0; ++ } ++#if 0 ++ netdev_dbg(dev->net, "frame <rx h %d p %d id %d\n", header->hdr_len, ++ header->packet_len, header->packet_id); ++#endif ++ dev->frame_errors = 0; ++ return 1; ++} ++ ++static struct sk_buff * ++net1080_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) ++{ ++ struct sk_buff *skb2; ++ struct nc_header *header = NULL; ++ struct nc_trailer *trailer = NULL; ++ int padlen = sizeof (struct nc_trailer); ++ int len = skb->len; ++ ++ if (!((len + padlen + sizeof (struct nc_header)) & 0x01)) ++ padlen++; ++ if (!skb_cloned(skb)) { ++ int headroom = skb_headroom(skb); ++ int tailroom = skb_tailroom(skb); ++ ++ if (padlen <= tailroom && ++ sizeof(struct nc_header) <= headroom) ++ /* There's enough head and tail room */ ++ goto encapsulate; ++ ++ if ((sizeof (struct nc_header) + padlen) < ++ (headroom + tailroom)) { ++ /* There's enough total room, so just readjust */ ++ skb->data = memmove(skb->head ++ + sizeof (struct nc_header), ++ skb->data, skb->len); ++ skb_set_tail_pointer(skb, len); ++ goto encapsulate; ++ } ++ } ++ ++ /* Create a new skb to use with the correct size */ ++ skb2 = skb_copy_expand(skb, ++ sizeof (struct nc_header), ++ padlen, ++ flags); ++ dev_kfree_skb_any(skb); ++ if (!skb2) ++ return skb2; ++ skb = skb2; ++ ++encapsulate: ++ /* header first */ ++ header = (struct nc_header *) skb_push(skb, sizeof *header); ++ header->hdr_len = cpu_to_le16(sizeof (*header)); ++ header->packet_len = cpu_to_le16(len); ++ header->packet_id = cpu_to_le16((u16)dev->xid++); ++ ++ /* maybe pad; then trailer */ ++ if (!((skb->len + sizeof *trailer) & 0x01)) ++ *skb_put(skb, 1) = PAD_BYTE; ++ trailer = (struct nc_trailer *) skb_put(skb, sizeof *trailer); ++ put_unaligned(header->packet_id, &trailer->packet_id); ++#if 0 ++ netdev_dbg(dev->net, "frame >tx h %d p %d id %d\n", ++ header->hdr_len, header->packet_len, ++ header->packet_id); ++#endif ++ return skb; ++} ++ ++static int net1080_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ unsigned extra = sizeof (struct nc_header) ++ + 1 ++ + sizeof (struct nc_trailer); ++ ++ dev->net->hard_header_len += extra; ++ dev->rx_urb_size = dev->net->hard_header_len + dev->net->mtu; ++ dev->hard_mtu = NC_MAX_PACKET; ++ return usbnet_get_endpoints (dev, intf); ++} ++ ++static const struct driver_info net1080_info = { ++ .description = "NetChip TurboCONNECT", ++ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_NC, ++ .bind = net1080_bind, ++ .reset = net1080_reset, ++ .check_connect = net1080_check_connect, ++ .rx_fixup = net1080_rx_fixup, ++ .tx_fixup = net1080_tx_fixup, ++}; ++ ++static const struct usb_device_id products [] = { ++{ ++ USB_DEVICE(0x0525, 0x1080), // NetChip ref design ++ .driver_info = (unsigned long) &net1080_info, ++}, { ++ USB_DEVICE(0x06D0, 0x0622), // Laplink Gold ++ .driver_info = (unsigned long) &net1080_info, ++}, ++ { }, // END ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver net1080_driver = { ++ .name = "net1080", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(net1080_driver); ++ ++MODULE_AUTHOR("David Brownell"); ++MODULE_DESCRIPTION("NetChip 1080 based USB Host-to-Host Links"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/pegasus.c backports-4.2.6-1/drivers/net/usb/pegasus.c +--- backports-4.2.6-1.org/drivers/net/usb/pegasus.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/pegasus.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,1335 @@ ++/* ++ * Copyright (c) 1999-2013 Petko Manolov (petkan@nucleusys.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as ++ * published by the Free Software Foundation. ++ * ++ * ChangeLog: ++ * .... Most of the time spent on reading sources & docs. ++ * v0.2.x First official release for the Linux kernel. ++ * v0.3.0 Beutified and structured, some bugs fixed. ++ * v0.3.x URBifying bulk requests and bugfixing. First relatively ++ * stable release. Still can touch device's registers only ++ * from top-halves. ++ * v0.4.0 Control messages remained unurbified are now URBs. ++ * Now we can touch the HW at any time. ++ * v0.4.9 Control urbs again use process context to wait. Argh... ++ * Some long standing bugs (enable_net_traffic) fixed. ++ * Also nasty trick about resubmiting control urb from ++ * interrupt context used. Please let me know how it ++ * behaves. Pegasus II support added since this version. ++ * TODO: suppressing HCD warnings spewage on disconnect. ++ * v0.4.13 Ethernet address is now set at probe(), not at open() ++ * time as this seems to break dhcpd. ++ * v0.5.0 branch to 2.5.x kernels ++ * v0.5.1 ethtool support added ++ * v0.5.5 rx socket buffers are in a pool and the their allocation ++ * is out of the interrupt routine. ++ * ... ++ * v0.9.3 simplified [get|set]_register(s), async update registers ++ * logic revisited, receive skb_pool removed. ++ */ ++ ++#include <linux/sched.h> ++#include <linux/slab.h> ++#include <linux/init.h> ++#include <linux/delay.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/module.h> ++#include <asm/byteorder.h> ++#include <asm/uaccess.h> ++#include "pegasus.h" ++ ++/* ++ * Version Information ++ */ ++#define DRIVER_VERSION "v0.9.3 (2013/04/25)" ++#define DRIVER_AUTHOR "Petko Manolov petkan@nucleusys.com" ++#define DRIVER_DESC "Pegasus/Pegasus II USB Ethernet driver" ++ ++static const char driver_name[] = "pegasus"; ++ ++#undef PEGASUS_WRITE_EEPROM ++#define BMSR_MEDIA (BMSR_10HALF | BMSR_10FULL | BMSR_100HALF | \ ++ BMSR_100FULL | BMSR_ANEGCAPABLE) ++ ++static bool loopback; ++static bool mii_mode; ++static char *devid; ++ ++static struct usb_eth_dev usb_dev_id[] = { ++#define PEGASUS_DEV(pn, vid, pid, flags) \ ++ {.name = pn, .vendor = vid, .device = pid, .private = flags}, ++#define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \ ++ PEGASUS_DEV(pn, vid, pid, flags) ++#include "pegasus.h" ++#undef PEGASUS_DEV ++#undef PEGASUS_DEV_CLASS ++ {NULL, 0, 0, 0}, ++ {NULL, 0, 0, 0} ++}; ++ ++static struct usb_device_id pegasus_ids[] = { ++#define PEGASUS_DEV(pn, vid, pid, flags) \ ++ {.match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = vid, .idProduct = pid}, ++/* ++ * The Belkin F8T012xx1 bluetooth adaptor has the same vendor and product ++ * IDs as the Belkin F5D5050, so we need to teach the pegasus driver to ++ * ignore adaptors belonging to the "Wireless" class 0xE0. For this one ++ * case anyway, seeing as the pegasus is for "Wired" adaptors. ++ */ ++#define PEGASUS_DEV_CLASS(pn, vid, pid, dclass, flags) \ ++ {.match_flags = (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_CLASS), \ ++ .idVendor = vid, .idProduct = pid, .bDeviceClass = dclass}, ++#include "pegasus.h" ++#undef PEGASUS_DEV ++#undef PEGASUS_DEV_CLASS ++ {}, ++ {} ++}; ++ ++MODULE_AUTHOR(DRIVER_AUTHOR); ++MODULE_DESCRIPTION(DRIVER_DESC); ++MODULE_LICENSE("GPL"); ++module_param(loopback, bool, 0); ++module_param(mii_mode, bool, 0); ++module_param(devid, charp, 0); ++MODULE_PARM_DESC(loopback, "Enable MAC loopback mode (bit 0)"); ++MODULE_PARM_DESC(mii_mode, "Enable HomePNA mode (bit 0),default=MII mode = 0"); ++MODULE_PARM_DESC(devid, "The format is: 'DEV_name:VendorID:DeviceID:Flags'"); ++ ++/* use ethtool to change the level for any given device */ ++static int msg_level = -1; ++module_param(msg_level, int, 0); ++MODULE_PARM_DESC(msg_level, "Override default message level"); ++ ++MODULE_DEVICE_TABLE(usb, pegasus_ids); ++static const struct net_device_ops pegasus_netdev_ops; ++ ++/*****/ ++ ++static void async_ctrl_callback(struct urb *urb) ++{ ++ struct usb_ctrlrequest *req = (struct usb_ctrlrequest *)urb->context; ++ int status = urb->status; ++ ++ if (status < 0) ++ dev_dbg(&urb->dev->dev, "%s failed with %d", __func__, status); ++ kfree(req); ++ usb_free_urb(urb); ++} ++ ++static int get_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) ++{ ++ int ret; ++ ++ ret = usb_control_msg(pegasus->usb, usb_rcvctrlpipe(pegasus->usb, 0), ++ PEGASUS_REQ_GET_REGS, PEGASUS_REQT_READ, 0, ++ indx, data, size, 1000); ++ if (ret < 0) ++ netif_dbg(pegasus, drv, pegasus->net, ++ "%s returned %d\n", __func__, ret); ++ return ret; ++} ++ ++static int set_registers(pegasus_t *pegasus, __u16 indx, __u16 size, void *data) ++{ ++ int ret; ++ ++ ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), ++ PEGASUS_REQ_SET_REGS, PEGASUS_REQT_WRITE, 0, ++ indx, data, size, 100); ++ if (ret < 0) ++ netif_dbg(pegasus, drv, pegasus->net, ++ "%s returned %d\n", __func__, ret); ++ return ret; ++} ++ ++static int set_register(pegasus_t *pegasus, __u16 indx, __u8 data) ++{ ++ int ret; ++ ++ ret = usb_control_msg(pegasus->usb, usb_sndctrlpipe(pegasus->usb, 0), ++ PEGASUS_REQ_SET_REG, PEGASUS_REQT_WRITE, data, ++ indx, &data, 1, 1000); ++ if (ret < 0) ++ netif_dbg(pegasus, drv, pegasus->net, ++ "%s returned %d\n", __func__, ret); ++ return ret; ++} ++ ++static int update_eth_regs_async(pegasus_t *pegasus) ++{ ++ int ret = -ENOMEM; ++ struct urb *async_urb; ++ struct usb_ctrlrequest *req; ++ ++ req = kmalloc(sizeof(struct usb_ctrlrequest), GFP_ATOMIC); ++ if (req == NULL) ++ return ret; ++ ++ async_urb = usb_alloc_urb(0, GFP_ATOMIC); ++ if (async_urb == NULL) { ++ kfree(req); ++ return ret; ++ } ++ req->bRequestType = PEGASUS_REQT_WRITE; ++ req->bRequest = PEGASUS_REQ_SET_REGS; ++ req->wValue = cpu_to_le16(0); ++ req->wIndex = cpu_to_le16(EthCtrl0); ++ req->wLength = cpu_to_le16(3); ++ ++ usb_fill_control_urb(async_urb, pegasus->usb, ++ usb_sndctrlpipe(pegasus->usb, 0), (void *)req, ++ pegasus->eth_regs, 3, async_ctrl_callback, req); ++ ++ ret = usb_submit_urb(async_urb, GFP_ATOMIC); ++ if (ret) { ++ if (ret == -ENODEV) ++ netif_device_detach(pegasus->net); ++ netif_err(pegasus, drv, pegasus->net, ++ "%s returned %d\n", __func__, ret); ++ } ++ return ret; ++} ++ ++static int __mii_op(pegasus_t *p, __u8 phy, __u8 indx, __u16 *regd, __u8 cmd) ++{ ++ int i; ++ __u8 data[4] = { phy, 0, 0, indx }; ++ __le16 regdi; ++ int ret = -ETIMEDOUT; ++ ++ if (cmd & PHY_WRITE) { ++ __le16 *t = (__le16 *) & data[1]; ++ *t = cpu_to_le16(*regd); ++ } ++ set_register(p, PhyCtrl, 0); ++ set_registers(p, PhyAddr, sizeof(data), data); ++ set_register(p, PhyCtrl, (indx | cmd)); ++ for (i = 0; i < REG_TIMEOUT; i++) { ++ ret = get_registers(p, PhyCtrl, 1, data); ++ if (ret < 0) ++ goto fail; ++ if (data[0] & PHY_DONE) ++ break; ++ } ++ if (i >= REG_TIMEOUT) ++ goto fail; ++ if (cmd & PHY_READ) { ++ ret = get_registers(p, PhyData, 2, ®di); ++ *regd = le16_to_cpu(regdi); ++ return ret; ++ } ++ return 0; ++fail: ++ netif_dbg(p, drv, p->net, "%s failed\n", __func__); ++ return ret; ++} ++ ++/* Returns non-negative int on success, error on failure */ ++static int read_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd) ++{ ++ return __mii_op(pegasus, phy, indx, regd, PHY_READ); ++} ++ ++/* Returns zero on success, error on failure */ ++static int write_mii_word(pegasus_t *pegasus, __u8 phy, __u8 indx, __u16 *regd) ++{ ++ return __mii_op(pegasus, phy, indx, regd, PHY_WRITE); ++} ++ ++static int mdio_read(struct net_device *dev, int phy_id, int loc) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ u16 res; ++ ++ read_mii_word(pegasus, phy_id, loc, &res); ++ return (int)res; ++} ++ ++static void mdio_write(struct net_device *dev, int phy_id, int loc, int val) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ u16 data = val; ++ ++ write_mii_word(pegasus, phy_id, loc, &data); ++} ++ ++static int read_eprom_word(pegasus_t *pegasus, __u8 index, __u16 *retdata) ++{ ++ int i; ++ __u8 tmp; ++ __le16 retdatai; ++ int ret; ++ ++ set_register(pegasus, EpromCtrl, 0); ++ set_register(pegasus, EpromOffset, index); ++ set_register(pegasus, EpromCtrl, EPROM_READ); ++ ++ for (i = 0; i < REG_TIMEOUT; i++) { ++ ret = get_registers(pegasus, EpromCtrl, 1, &tmp); ++ if (tmp & EPROM_DONE) ++ break; ++ if (ret == -ESHUTDOWN) ++ goto fail; ++ } ++ if (i >= REG_TIMEOUT) ++ goto fail; ++ ++ ret = get_registers(pegasus, EpromData, 2, &retdatai); ++ *retdata = le16_to_cpu(retdatai); ++ return ret; ++ ++fail: ++ netif_warn(pegasus, drv, pegasus->net, "%s failed\n", __func__); ++ return -ETIMEDOUT; ++} ++ ++#ifdef PEGASUS_WRITE_EEPROM ++static inline void enable_eprom_write(pegasus_t *pegasus) ++{ ++ __u8 tmp; ++ ++ get_registers(pegasus, EthCtrl2, 1, &tmp); ++ set_register(pegasus, EthCtrl2, tmp | EPROM_WR_ENABLE); ++} ++ ++static inline void disable_eprom_write(pegasus_t *pegasus) ++{ ++ __u8 tmp; ++ ++ get_registers(pegasus, EthCtrl2, 1, &tmp); ++ set_register(pegasus, EpromCtrl, 0); ++ set_register(pegasus, EthCtrl2, tmp & ~EPROM_WR_ENABLE); ++} ++ ++static int write_eprom_word(pegasus_t *pegasus, __u8 index, __u16 data) ++{ ++ int i; ++ __u8 tmp, d[4] = { 0x3f, 0, 0, EPROM_WRITE }; ++ int ret; ++ __le16 le_data = cpu_to_le16(data); ++ ++ set_registers(pegasus, EpromOffset, 4, d); ++ enable_eprom_write(pegasus); ++ set_register(pegasus, EpromOffset, index); ++ set_registers(pegasus, EpromData, 2, &le_data); ++ set_register(pegasus, EpromCtrl, EPROM_WRITE); ++ ++ for (i = 0; i < REG_TIMEOUT; i++) { ++ ret = get_registers(pegasus, EpromCtrl, 1, &tmp); ++ if (ret == -ESHUTDOWN) ++ goto fail; ++ if (tmp & EPROM_DONE) ++ break; ++ } ++ disable_eprom_write(pegasus); ++ if (i >= REG_TIMEOUT) ++ goto fail; ++ ++ return ret; ++ ++fail: ++ netif_warn(pegasus, drv, pegasus->net, "%s failed\n", __func__); ++ return -ETIMEDOUT; ++} ++#endif /* PEGASUS_WRITE_EEPROM */ ++ ++static inline void get_node_id(pegasus_t *pegasus, __u8 *id) ++{ ++ int i; ++ __u16 w16; ++ ++ for (i = 0; i < 3; i++) { ++ read_eprom_word(pegasus, i, &w16); ++ ((__le16 *) id)[i] = cpu_to_le16(w16); ++ } ++} ++ ++static void set_ethernet_addr(pegasus_t *pegasus) ++{ ++ __u8 node_id[6]; ++ ++ if (pegasus->features & PEGASUS_II) { ++ get_registers(pegasus, 0x10, sizeof(node_id), node_id); ++ } else { ++ get_node_id(pegasus, node_id); ++ set_registers(pegasus, EthID, sizeof(node_id), node_id); ++ } ++ memcpy(pegasus->net->dev_addr, node_id, sizeof(node_id)); ++} ++ ++static inline int reset_mac(pegasus_t *pegasus) ++{ ++ __u8 data = 0x8; ++ int i; ++ ++ set_register(pegasus, EthCtrl1, data); ++ for (i = 0; i < REG_TIMEOUT; i++) { ++ get_registers(pegasus, EthCtrl1, 1, &data); ++ if (~data & 0x08) { ++ if (loopback) ++ break; ++ if (mii_mode && (pegasus->features & HAS_HOME_PNA)) ++ set_register(pegasus, Gpio1, 0x34); ++ else ++ set_register(pegasus, Gpio1, 0x26); ++ set_register(pegasus, Gpio0, pegasus->features); ++ set_register(pegasus, Gpio0, DEFAULT_GPIO_SET); ++ break; ++ } ++ } ++ if (i == REG_TIMEOUT) ++ return -ETIMEDOUT; ++ ++ if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS || ++ usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) { ++ set_register(pegasus, Gpio0, 0x24); ++ set_register(pegasus, Gpio0, 0x26); ++ } ++ if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_ELCON) { ++ __u16 auxmode; ++ read_mii_word(pegasus, 3, 0x1b, &auxmode); ++ auxmode |= 4; ++ write_mii_word(pegasus, 3, 0x1b, &auxmode); ++ } ++ ++ return 0; ++} ++ ++static int enable_net_traffic(struct net_device *dev, struct usb_device *usb) ++{ ++ __u16 linkpart; ++ __u8 data[4]; ++ pegasus_t *pegasus = netdev_priv(dev); ++ int ret; ++ ++ read_mii_word(pegasus, pegasus->phy, MII_LPA, &linkpart); ++ data[0] = 0xc9; ++ data[1] = 0; ++ if (linkpart & (ADVERTISE_100FULL | ADVERTISE_10FULL)) ++ data[1] |= 0x20; /* set full duplex */ ++ if (linkpart & (ADVERTISE_100FULL | ADVERTISE_100HALF)) ++ data[1] |= 0x10; /* set 100 Mbps */ ++ if (mii_mode) ++ data[1] = 0; ++ data[2] = loopback ? 0x09 : 0x01; ++ ++ memcpy(pegasus->eth_regs, data, sizeof(data)); ++ ret = set_registers(pegasus, EthCtrl0, 3, data); ++ ++ if (usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS || ++ usb_dev_id[pegasus->dev_index].vendor == VENDOR_LINKSYS2 || ++ usb_dev_id[pegasus->dev_index].vendor == VENDOR_DLINK) { ++ u16 auxmode; ++ read_mii_word(pegasus, 0, 0x1b, &auxmode); ++ auxmode |= 4; ++ write_mii_word(pegasus, 0, 0x1b, &auxmode); ++ } ++ ++ return ret; ++} ++ ++static void read_bulk_callback(struct urb *urb) ++{ ++ pegasus_t *pegasus = urb->context; ++ struct net_device *net; ++ int rx_status, count = urb->actual_length; ++ int status = urb->status; ++ u8 *buf = urb->transfer_buffer; ++ __u16 pkt_len; ++ ++ if (!pegasus) ++ return; ++ ++ net = pegasus->net; ++ if (!netif_device_present(net) || !netif_running(net)) ++ return; ++ ++ switch (status) { ++ case 0: ++ break; ++ case -ETIME: ++ netif_dbg(pegasus, rx_err, net, "reset MAC\n"); ++ pegasus->flags &= ~PEGASUS_RX_BUSY; ++ break; ++ case -EPIPE: /* stall, or disconnect from TT */ ++ /* FIXME schedule work to clear the halt */ ++ netif_warn(pegasus, rx_err, net, "no rx stall recovery\n"); ++ return; ++ case -ENOENT: ++ case -ECONNRESET: ++ case -ESHUTDOWN: ++ netif_dbg(pegasus, ifdown, net, "rx unlink, %d\n", status); ++ return; ++ default: ++ netif_dbg(pegasus, rx_err, net, "RX status %d\n", status); ++ goto goon; ++ } ++ ++ if (!count || count < 4) ++ goto goon; ++ ++ rx_status = buf[count - 2]; ++ if (rx_status & 0x1e) { ++ netif_dbg(pegasus, rx_err, net, ++ "RX packet error %x\n", rx_status); ++ pegasus->stats.rx_errors++; ++ if (rx_status & 0x06) /* long or runt */ ++ pegasus->stats.rx_length_errors++; ++ if (rx_status & 0x08) ++ pegasus->stats.rx_crc_errors++; ++ if (rx_status & 0x10) /* extra bits */ ++ pegasus->stats.rx_frame_errors++; ++ goto goon; ++ } ++ if (pegasus->chip == 0x8513) { ++ pkt_len = le32_to_cpu(*(__le32 *)urb->transfer_buffer); ++ pkt_len &= 0x0fff; ++ pegasus->rx_skb->data += 2; ++ } else { ++ pkt_len = buf[count - 3] << 8; ++ pkt_len += buf[count - 4]; ++ pkt_len &= 0xfff; ++ pkt_len -= 8; ++ } ++ ++ /* ++ * If the packet is unreasonably long, quietly drop it rather than ++ * kernel panicing by calling skb_put. ++ */ ++ if (pkt_len > PEGASUS_MTU) ++ goto goon; ++ ++ /* ++ * at this point we are sure pegasus->rx_skb != NULL ++ * so we go ahead and pass up the packet. ++ */ ++ skb_put(pegasus->rx_skb, pkt_len); ++ pegasus->rx_skb->protocol = eth_type_trans(pegasus->rx_skb, net); ++ netif_rx(pegasus->rx_skb); ++ pegasus->stats.rx_packets++; ++ pegasus->stats.rx_bytes += pkt_len; ++ ++ if (pegasus->flags & PEGASUS_UNPLUG) ++ return; ++ ++ pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net, PEGASUS_MTU, ++ GFP_ATOMIC); ++ ++ if (pegasus->rx_skb == NULL) ++ goto tl_sched; ++goon: ++ usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, ++ usb_rcvbulkpipe(pegasus->usb, 1), ++ pegasus->rx_skb->data, PEGASUS_MTU + 8, ++ read_bulk_callback, pegasus); ++ rx_status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC); ++ if (rx_status == -ENODEV) ++ netif_device_detach(pegasus->net); ++ else if (rx_status) { ++ pegasus->flags |= PEGASUS_RX_URB_FAIL; ++ goto tl_sched; ++ } else { ++ pegasus->flags &= ~PEGASUS_RX_URB_FAIL; ++ } ++ ++ return; ++ ++tl_sched: ++ tasklet_schedule(&pegasus->rx_tl); ++} ++ ++static void rx_fixup(unsigned long data) ++{ ++ pegasus_t *pegasus; ++ int status; ++ ++ pegasus = (pegasus_t *) data; ++ if (pegasus->flags & PEGASUS_UNPLUG) ++ return; ++ ++ if (pegasus->flags & PEGASUS_RX_URB_FAIL) ++ if (pegasus->rx_skb) ++ goto try_again; ++ if (pegasus->rx_skb == NULL) ++ pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net, ++ PEGASUS_MTU, ++ GFP_ATOMIC); ++ if (pegasus->rx_skb == NULL) { ++ netif_warn(pegasus, rx_err, pegasus->net, "low on memory\n"); ++ tasklet_schedule(&pegasus->rx_tl); ++ return; ++ } ++ usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, ++ usb_rcvbulkpipe(pegasus->usb, 1), ++ pegasus->rx_skb->data, PEGASUS_MTU + 8, ++ read_bulk_callback, pegasus); ++try_again: ++ status = usb_submit_urb(pegasus->rx_urb, GFP_ATOMIC); ++ if (status == -ENODEV) ++ netif_device_detach(pegasus->net); ++ else if (status) { ++ pegasus->flags |= PEGASUS_RX_URB_FAIL; ++ tasklet_schedule(&pegasus->rx_tl); ++ } else { ++ pegasus->flags &= ~PEGASUS_RX_URB_FAIL; ++ } ++} ++ ++static void write_bulk_callback(struct urb *urb) ++{ ++ pegasus_t *pegasus = urb->context; ++ struct net_device *net; ++ int status = urb->status; ++ ++ if (!pegasus) ++ return; ++ ++ net = pegasus->net; ++ ++ if (!netif_device_present(net) || !netif_running(net)) ++ return; ++ ++ switch (status) { ++ case -EPIPE: ++ /* FIXME schedule_work() to clear the tx halt */ ++ netif_stop_queue(net); ++ netif_warn(pegasus, tx_err, net, "no tx stall recovery\n"); ++ return; ++ case -ENOENT: ++ case -ECONNRESET: ++ case -ESHUTDOWN: ++ netif_dbg(pegasus, ifdown, net, "tx unlink, %d\n", status); ++ return; ++ default: ++ netif_info(pegasus, tx_err, net, "TX status %d\n", status); ++ /* FALL THROUGH */ ++ case 0: ++ break; ++ } ++ ++ net->trans_start = jiffies; /* prevent tx timeout */ ++ netif_wake_queue(net); ++} ++ ++static void intr_callback(struct urb *urb) ++{ ++ pegasus_t *pegasus = urb->context; ++ struct net_device *net; ++ int res, status = urb->status; ++ ++ if (!pegasus) ++ return; ++ net = pegasus->net; ++ ++ switch (status) { ++ case 0: ++ break; ++ case -ECONNRESET: /* unlink */ ++ case -ENOENT: ++ case -ESHUTDOWN: ++ return; ++ default: ++ /* some Pegasus-I products report LOTS of data ++ * toggle errors... avoid log spamming ++ */ ++ netif_dbg(pegasus, timer, net, "intr status %d\n", status); ++ } ++ ++ if (urb->actual_length >= 6) { ++ u8 *d = urb->transfer_buffer; ++ ++ /* byte 0 == tx_status1, reg 2B */ ++ if (d[0] & (TX_UNDERRUN|EXCESSIVE_COL ++ |LATE_COL|JABBER_TIMEOUT)) { ++ pegasus->stats.tx_errors++; ++ if (d[0] & TX_UNDERRUN) ++ pegasus->stats.tx_fifo_errors++; ++ if (d[0] & (EXCESSIVE_COL | JABBER_TIMEOUT)) ++ pegasus->stats.tx_aborted_errors++; ++ if (d[0] & LATE_COL) ++ pegasus->stats.tx_window_errors++; ++ } ++ ++ /* d[5].LINK_STATUS lies on some adapters. ++ * d[0].NO_CARRIER kicks in only with failed TX. ++ * ... so monitoring with MII may be safest. ++ */ ++ ++ /* bytes 3-4 == rx_lostpkt, reg 2E/2F */ ++ pegasus->stats.rx_missed_errors += ((d[3] & 0x7f) << 8) | d[4]; ++ } ++ ++ res = usb_submit_urb(urb, GFP_ATOMIC); ++ if (res == -ENODEV) ++ netif_device_detach(pegasus->net); ++ if (res) ++ netif_err(pegasus, timer, net, ++ "can't resubmit interrupt urb, %d\n", res); ++} ++ ++static void pegasus_tx_timeout(struct net_device *net) ++{ ++ pegasus_t *pegasus = netdev_priv(net); ++ netif_warn(pegasus, timer, net, "tx timeout\n"); ++ usb_unlink_urb(pegasus->tx_urb); ++ pegasus->stats.tx_errors++; ++} ++ ++static netdev_tx_t pegasus_start_xmit(struct sk_buff *skb, ++ struct net_device *net) ++{ ++ pegasus_t *pegasus = netdev_priv(net); ++ int count = ((skb->len + 2) & 0x3f) ? skb->len + 2 : skb->len + 3; ++ int res; ++ __u16 l16 = skb->len; ++ ++ netif_stop_queue(net); ++ ++ ((__le16 *) pegasus->tx_buff)[0] = cpu_to_le16(l16); ++ skb_copy_from_linear_data(skb, pegasus->tx_buff + 2, skb->len); ++ usb_fill_bulk_urb(pegasus->tx_urb, pegasus->usb, ++ usb_sndbulkpipe(pegasus->usb, 2), ++ pegasus->tx_buff, count, ++ write_bulk_callback, pegasus); ++ if ((res = usb_submit_urb(pegasus->tx_urb, GFP_ATOMIC))) { ++ netif_warn(pegasus, tx_err, net, "fail tx, %d\n", res); ++ switch (res) { ++ case -EPIPE: /* stall, or disconnect from TT */ ++ /* cleanup should already have been scheduled */ ++ break; ++ case -ENODEV: /* disconnect() upcoming */ ++ case -EPERM: ++ netif_device_detach(pegasus->net); ++ break; ++ default: ++ pegasus->stats.tx_errors++; ++ netif_start_queue(net); ++ } ++ } else { ++ pegasus->stats.tx_packets++; ++ pegasus->stats.tx_bytes += skb->len; ++ } ++ dev_kfree_skb(skb); ++ ++ return NETDEV_TX_OK; ++} ++ ++static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev) ++{ ++ return &((pegasus_t *) netdev_priv(dev))->stats; ++} ++ ++static inline void disable_net_traffic(pegasus_t *pegasus) ++{ ++ __le16 tmp = cpu_to_le16(0); ++ ++ set_registers(pegasus, EthCtrl0, sizeof(tmp), &tmp); ++} ++ ++static inline void get_interrupt_interval(pegasus_t *pegasus) ++{ ++ u16 data; ++ u8 interval; ++ ++ read_eprom_word(pegasus, 4, &data); ++ interval = data >> 8; ++ if (pegasus->usb->speed != USB_SPEED_HIGH) { ++ if (interval < 0x80) { ++ netif_info(pegasus, timer, pegasus->net, ++ "intr interval changed from %ums to %ums\n", ++ interval, 0x80); ++ interval = 0x80; ++ data = (data & 0x00FF) | ((u16)interval << 8); ++#ifdef PEGASUS_WRITE_EEPROM ++ write_eprom_word(pegasus, 4, data); ++#endif ++ } ++ } ++ pegasus->intr_interval = interval; ++} ++ ++static void set_carrier(struct net_device *net) ++{ ++ pegasus_t *pegasus = netdev_priv(net); ++ u16 tmp; ++ ++ if (read_mii_word(pegasus, pegasus->phy, MII_BMSR, &tmp)) ++ return; ++ ++ if (tmp & BMSR_LSTATUS) ++ netif_carrier_on(net); ++ else ++ netif_carrier_off(net); ++} ++ ++static void free_all_urbs(pegasus_t *pegasus) ++{ ++ usb_free_urb(pegasus->intr_urb); ++ usb_free_urb(pegasus->tx_urb); ++ usb_free_urb(pegasus->rx_urb); ++} ++ ++static void unlink_all_urbs(pegasus_t *pegasus) ++{ ++ usb_kill_urb(pegasus->intr_urb); ++ usb_kill_urb(pegasus->tx_urb); ++ usb_kill_urb(pegasus->rx_urb); ++} ++ ++static int alloc_urbs(pegasus_t *pegasus) ++{ ++ int res = -ENOMEM; ++ ++ pegasus->rx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!pegasus->rx_urb) { ++ return res; ++ } ++ pegasus->tx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!pegasus->tx_urb) { ++ usb_free_urb(pegasus->rx_urb); ++ return res; ++ } ++ pegasus->intr_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!pegasus->intr_urb) { ++ usb_free_urb(pegasus->tx_urb); ++ usb_free_urb(pegasus->rx_urb); ++ return res; ++ } ++ ++ return 0; ++} ++ ++static int pegasus_open(struct net_device *net) ++{ ++ pegasus_t *pegasus = netdev_priv(net); ++ int res=-ENOMEM; ++ ++ if (pegasus->rx_skb == NULL) ++ pegasus->rx_skb = __netdev_alloc_skb_ip_align(pegasus->net, ++ PEGASUS_MTU, ++ GFP_KERNEL); ++ if (!pegasus->rx_skb) ++ goto exit; ++ ++ res = set_registers(pegasus, EthID, 6, net->dev_addr); ++ ++ usb_fill_bulk_urb(pegasus->rx_urb, pegasus->usb, ++ usb_rcvbulkpipe(pegasus->usb, 1), ++ pegasus->rx_skb->data, PEGASUS_MTU + 8, ++ read_bulk_callback, pegasus); ++ if ((res = usb_submit_urb(pegasus->rx_urb, GFP_KERNEL))) { ++ if (res == -ENODEV) ++ netif_device_detach(pegasus->net); ++ netif_dbg(pegasus, ifup, net, "failed rx_urb, %d\n", res); ++ goto exit; ++ } ++ ++ usb_fill_int_urb(pegasus->intr_urb, pegasus->usb, ++ usb_rcvintpipe(pegasus->usb, 3), ++ pegasus->intr_buff, sizeof(pegasus->intr_buff), ++ intr_callback, pegasus, pegasus->intr_interval); ++ if ((res = usb_submit_urb(pegasus->intr_urb, GFP_KERNEL))) { ++ if (res == -ENODEV) ++ netif_device_detach(pegasus->net); ++ netif_dbg(pegasus, ifup, net, "failed intr_urb, %d\n", res); ++ usb_kill_urb(pegasus->rx_urb); ++ goto exit; ++ } ++ res = enable_net_traffic(net, pegasus->usb); ++ if (res < 0) { ++ netif_dbg(pegasus, ifup, net, ++ "can't enable_net_traffic() - %d\n", res); ++ res = -EIO; ++ usb_kill_urb(pegasus->rx_urb); ++ usb_kill_urb(pegasus->intr_urb); ++ goto exit; ++ } ++ set_carrier(net); ++ netif_start_queue(net); ++ netif_dbg(pegasus, ifup, net, "open\n"); ++ res = 0; ++exit: ++ return res; ++} ++ ++static int pegasus_close(struct net_device *net) ++{ ++ pegasus_t *pegasus = netdev_priv(net); ++ ++ netif_stop_queue(net); ++ if (!(pegasus->flags & PEGASUS_UNPLUG)) ++ disable_net_traffic(pegasus); ++ tasklet_kill(&pegasus->rx_tl); ++ unlink_all_urbs(pegasus); ++ ++ return 0; ++} ++ ++static void pegasus_get_drvinfo(struct net_device *dev, ++ struct ethtool_drvinfo *info) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ ++ strlcpy(info->driver, driver_name, sizeof(info->driver)); ++ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); ++ usb_make_path(pegasus->usb, info->bus_info, sizeof(info->bus_info)); ++} ++ ++/* also handles three patterns of some kind in hardware */ ++#define WOL_SUPPORTED (WAKE_MAGIC|WAKE_PHY) ++ ++static void ++pegasus_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ ++ wol->supported = WAKE_MAGIC | WAKE_PHY; ++ wol->wolopts = pegasus->wolopts; ++} ++ ++static int ++pegasus_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ u8 reg78 = 0x04; ++ int ret; ++ ++ if (wol->wolopts & ~WOL_SUPPORTED) ++ return -EINVAL; ++ ++ if (wol->wolopts & WAKE_MAGIC) ++ reg78 |= 0x80; ++ if (wol->wolopts & WAKE_PHY) ++ reg78 |= 0x40; ++ /* FIXME this 0x10 bit still needs to get set in the chip... */ ++ if (wol->wolopts) ++ pegasus->eth_regs[0] |= 0x10; ++ else ++ pegasus->eth_regs[0] &= ~0x10; ++ pegasus->wolopts = wol->wolopts; ++ ++ ret = set_register(pegasus, WakeupControl, reg78); ++ if (!ret) ++ ret = device_set_wakeup_enable(&pegasus->usb->dev, ++ wol->wolopts); ++ return ret; ++} ++ ++static inline void pegasus_reset_wol(struct net_device *dev) ++{ ++ struct ethtool_wolinfo wol; ++ ++ memset(&wol, 0, sizeof wol); ++ (void) pegasus_set_wol(dev, &wol); ++} ++ ++static int ++pegasus_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) ++{ ++ pegasus_t *pegasus; ++ ++ pegasus = netdev_priv(dev); ++ mii_ethtool_gset(&pegasus->mii, ecmd); ++ return 0; ++} ++ ++static int ++pegasus_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ return mii_ethtool_sset(&pegasus->mii, ecmd); ++} ++ ++static int pegasus_nway_reset(struct net_device *dev) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ return mii_nway_restart(&pegasus->mii); ++} ++ ++static u32 pegasus_get_link(struct net_device *dev) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ return mii_link_ok(&pegasus->mii); ++} ++ ++static u32 pegasus_get_msglevel(struct net_device *dev) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ return pegasus->msg_enable; ++} ++ ++static void pegasus_set_msglevel(struct net_device *dev, u32 v) ++{ ++ pegasus_t *pegasus = netdev_priv(dev); ++ pegasus->msg_enable = v; ++} ++ ++static const struct ethtool_ops ops = { ++ .get_drvinfo = pegasus_get_drvinfo, ++ .get_settings = pegasus_get_settings, ++ .set_settings = pegasus_set_settings, ++ .nway_reset = pegasus_nway_reset, ++ .get_link = pegasus_get_link, ++ .get_msglevel = pegasus_get_msglevel, ++ .set_msglevel = pegasus_set_msglevel, ++ .get_wol = pegasus_get_wol, ++ .set_wol = pegasus_set_wol, ++}; ++ ++static int pegasus_ioctl(struct net_device *net, struct ifreq *rq, int cmd) ++{ ++ __u16 *data = (__u16 *) &rq->ifr_ifru; ++ pegasus_t *pegasus = netdev_priv(net); ++ int res; ++ ++ switch (cmd) { ++ case SIOCDEVPRIVATE: ++ data[0] = pegasus->phy; ++ case SIOCDEVPRIVATE + 1: ++ read_mii_word(pegasus, data[0], data[1] & 0x1f, &data[3]); ++ res = 0; ++ break; ++ case SIOCDEVPRIVATE + 2: ++ if (!capable(CAP_NET_ADMIN)) ++ return -EPERM; ++ write_mii_word(pegasus, pegasus->phy, data[1] & 0x1f, &data[2]); ++ res = 0; ++ break; ++ default: ++ res = -EOPNOTSUPP; ++ } ++ return res; ++} ++ ++static void pegasus_set_multicast(struct net_device *net) ++{ ++ pegasus_t *pegasus = netdev_priv(net); ++ ++ if (net->flags & IFF_PROMISC) { ++ pegasus->eth_regs[EthCtrl2] |= RX_PROMISCUOUS; ++ netif_info(pegasus, link, net, "Promiscuous mode enabled\n"); ++ } else if (!netdev_mc_empty(net) || (net->flags & IFF_ALLMULTI)) { ++ pegasus->eth_regs[EthCtrl0] |= RX_MULTICAST; ++ pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; ++ netif_dbg(pegasus, link, net, "set allmulti\n"); ++ } else { ++ pegasus->eth_regs[EthCtrl0] &= ~RX_MULTICAST; ++ pegasus->eth_regs[EthCtrl2] &= ~RX_PROMISCUOUS; ++ } ++ update_eth_regs_async(pegasus); ++} ++ ++static __u8 mii_phy_probe(pegasus_t *pegasus) ++{ ++ int i; ++ __u16 tmp; ++ ++ for (i = 0; i < 32; i++) { ++ read_mii_word(pegasus, i, MII_BMSR, &tmp); ++ if (tmp == 0 || tmp == 0xffff || (tmp & BMSR_MEDIA) == 0) ++ continue; ++ else ++ return i; ++ } ++ ++ return 0xff; ++} ++ ++static inline void setup_pegasus_II(pegasus_t *pegasus) ++{ ++ __u8 data = 0xa5; ++ ++ set_register(pegasus, Reg1d, 0); ++ set_register(pegasus, Reg7b, 1); ++ mdelay(100); ++ if ((pegasus->features & HAS_HOME_PNA) && mii_mode) ++ set_register(pegasus, Reg7b, 0); ++ else ++ set_register(pegasus, Reg7b, 2); ++ ++ set_register(pegasus, 0x83, data); ++ get_registers(pegasus, 0x83, 1, &data); ++ ++ if (data == 0xa5) ++ pegasus->chip = 0x8513; ++ else ++ pegasus->chip = 0; ++ ++ set_register(pegasus, 0x80, 0xc0); ++ set_register(pegasus, 0x83, 0xff); ++ set_register(pegasus, 0x84, 0x01); ++ ++ if (pegasus->features & HAS_HOME_PNA && mii_mode) ++ set_register(pegasus, Reg81, 6); ++ else ++ set_register(pegasus, Reg81, 2); ++} ++ ++ ++static int pegasus_count; ++static struct workqueue_struct *pegasus_workqueue; ++#define CARRIER_CHECK_DELAY (2 * HZ) ++ ++static void check_carrier(struct work_struct *work) ++{ ++ pegasus_t *pegasus = container_of(work, pegasus_t, carrier_check.work); ++ set_carrier(pegasus->net); ++ if (!(pegasus->flags & PEGASUS_UNPLUG)) { ++ queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, ++ CARRIER_CHECK_DELAY); ++ } ++} ++ ++static int pegasus_blacklisted(struct usb_device *udev) ++{ ++ struct usb_device_descriptor *udd = &udev->descriptor; ++ ++ /* Special quirk to keep the driver from handling the Belkin Bluetooth ++ * dongle which happens to have the same ID. ++ */ ++ if ((udd->idVendor == cpu_to_le16(VENDOR_BELKIN)) && ++ (udd->idProduct == cpu_to_le16(0x0121)) && ++ (udd->bDeviceClass == USB_CLASS_WIRELESS_CONTROLLER) && ++ (udd->bDeviceProtocol == 1)) ++ return 1; ++ ++ return 0; ++} ++ ++/* we rely on probe() and remove() being serialized so we ++ * don't need extra locking on pegasus_count. ++ */ ++static void pegasus_dec_workqueue(void) ++{ ++ pegasus_count--; ++ if (pegasus_count == 0) { ++ destroy_workqueue(pegasus_workqueue); ++ pegasus_workqueue = NULL; ++ } ++} ++ ++static int pegasus_probe(struct usb_interface *intf, ++ const struct usb_device_id *id) ++{ ++ struct usb_device *dev = interface_to_usbdev(intf); ++ struct net_device *net; ++ pegasus_t *pegasus; ++ int dev_index = id - pegasus_ids; ++ int res = -ENOMEM; ++ ++ if (pegasus_blacklisted(dev)) ++ return -ENODEV; ++ ++ if (pegasus_count == 0) { ++ pegasus_workqueue = create_singlethread_workqueue("pegasus"); ++ if (!pegasus_workqueue) ++ return -ENOMEM; ++ } ++ pegasus_count++; ++ ++ net = alloc_etherdev(sizeof(struct pegasus)); ++ if (!net) ++ goto out; ++ ++ pegasus = netdev_priv(net); ++ pegasus->dev_index = dev_index; ++ ++ res = alloc_urbs(pegasus); ++ if (res < 0) { ++ dev_err(&intf->dev, "can't allocate %s\n", "urbs"); ++ goto out1; ++ } ++ ++ tasklet_init(&pegasus->rx_tl, rx_fixup, (unsigned long) pegasus); ++ ++ INIT_DELAYED_WORK(&pegasus->carrier_check, check_carrier); ++ ++ pegasus->intf = intf; ++ pegasus->usb = dev; ++ pegasus->net = net; ++ ++ ++ net->watchdog_timeo = PEGASUS_TX_TIMEOUT; ++ net->netdev_ops = &pegasus_netdev_ops; ++ net->ethtool_ops = &ops; ++ pegasus->mii.dev = net; ++ pegasus->mii.mdio_read = mdio_read; ++ pegasus->mii.mdio_write = mdio_write; ++ pegasus->mii.phy_id_mask = 0x1f; ++ pegasus->mii.reg_num_mask = 0x1f; ++ pegasus->msg_enable = netif_msg_init(msg_level, NETIF_MSG_DRV ++ | NETIF_MSG_PROBE | NETIF_MSG_LINK); ++ ++ pegasus->features = usb_dev_id[dev_index].private; ++ get_interrupt_interval(pegasus); ++ if (reset_mac(pegasus)) { ++ dev_err(&intf->dev, "can't reset MAC\n"); ++ res = -EIO; ++ goto out2; ++ } ++ set_ethernet_addr(pegasus); ++ if (pegasus->features & PEGASUS_II) { ++ dev_info(&intf->dev, "setup Pegasus II specific registers\n"); ++ setup_pegasus_II(pegasus); ++ } ++ pegasus->phy = mii_phy_probe(pegasus); ++ if (pegasus->phy == 0xff) { ++ dev_warn(&intf->dev, "can't locate MII phy, using default\n"); ++ pegasus->phy = 1; ++ } ++ pegasus->mii.phy_id = pegasus->phy; ++ usb_set_intfdata(intf, pegasus); ++ SET_NETDEV_DEV(net, &intf->dev); ++ pegasus_reset_wol(net); ++ res = register_netdev(net); ++ if (res) ++ goto out3; ++ queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, ++ CARRIER_CHECK_DELAY); ++ dev_info(&intf->dev, "%s, %s, %pM\n", net->name, ++ usb_dev_id[dev_index].name, net->dev_addr); ++ return 0; ++ ++out3: ++ usb_set_intfdata(intf, NULL); ++out2: ++ free_all_urbs(pegasus); ++out1: ++ free_netdev(net); ++out: ++ pegasus_dec_workqueue(); ++ return res; ++} ++ ++static void pegasus_disconnect(struct usb_interface *intf) ++{ ++ struct pegasus *pegasus = usb_get_intfdata(intf); ++ ++ usb_set_intfdata(intf, NULL); ++ if (!pegasus) { ++ dev_dbg(&intf->dev, "unregistering non-bound device?\n"); ++ return; ++ } ++ ++ pegasus->flags |= PEGASUS_UNPLUG; ++ cancel_delayed_work(&pegasus->carrier_check); ++ unregister_netdev(pegasus->net); ++ unlink_all_urbs(pegasus); ++ free_all_urbs(pegasus); ++ if (pegasus->rx_skb != NULL) { ++ dev_kfree_skb(pegasus->rx_skb); ++ pegasus->rx_skb = NULL; ++ } ++ free_netdev(pegasus->net); ++ pegasus_dec_workqueue(); ++} ++ ++static int pegasus_suspend(struct usb_interface *intf, pm_message_t message) ++{ ++ struct pegasus *pegasus = usb_get_intfdata(intf); ++ ++ netif_device_detach(pegasus->net); ++ cancel_delayed_work(&pegasus->carrier_check); ++ if (netif_running(pegasus->net)) { ++ usb_kill_urb(pegasus->rx_urb); ++ usb_kill_urb(pegasus->intr_urb); ++ } ++ return 0; ++} ++ ++static int pegasus_resume(struct usb_interface *intf) ++{ ++ struct pegasus *pegasus = usb_get_intfdata(intf); ++ ++ netif_device_attach(pegasus->net); ++ if (netif_running(pegasus->net)) { ++ pegasus->rx_urb->status = 0; ++ pegasus->rx_urb->actual_length = 0; ++ read_bulk_callback(pegasus->rx_urb); ++ ++ pegasus->intr_urb->status = 0; ++ pegasus->intr_urb->actual_length = 0; ++ intr_callback(pegasus->intr_urb); ++ } ++ queue_delayed_work(pegasus_workqueue, &pegasus->carrier_check, ++ CARRIER_CHECK_DELAY); ++ return 0; ++} ++ ++static const struct net_device_ops pegasus_netdev_ops = { ++ .ndo_open = pegasus_open, ++ .ndo_stop = pegasus_close, ++ .ndo_do_ioctl = pegasus_ioctl, ++ .ndo_start_xmit = pegasus_start_xmit, ++ .ndo_set_rx_mode = pegasus_set_multicast, ++ .ndo_get_stats = pegasus_netdev_stats, ++ .ndo_tx_timeout = pegasus_tx_timeout, ++ .ndo_change_mtu = eth_change_mtu, ++ .ndo_set_mac_address = eth_mac_addr, ++ .ndo_validate_addr = eth_validate_addr, ++}; ++ ++static struct usb_driver pegasus_driver = { ++ .name = driver_name, ++ .probe = pegasus_probe, ++ .disconnect = pegasus_disconnect, ++ .id_table = pegasus_ids, ++ .suspend = pegasus_suspend, ++ .resume = pegasus_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++static void __init parse_id(char *id) ++{ ++ unsigned int vendor_id = 0, device_id = 0, flags = 0, i = 0; ++ char *token, *name = NULL; ++ ++ if ((token = strsep(&id, ":")) != NULL) ++ name = token; ++ /* name now points to a null terminated string*/ ++ if ((token = strsep(&id, ":")) != NULL) ++ vendor_id = simple_strtoul(token, NULL, 16); ++ if ((token = strsep(&id, ":")) != NULL) ++ device_id = simple_strtoul(token, NULL, 16); ++ flags = simple_strtoul(id, NULL, 16); ++ pr_info("%s: new device %s, vendor ID 0x%04x, device ID 0x%04x, flags: 0x%x\n", ++ driver_name, name, vendor_id, device_id, flags); ++ ++ if (vendor_id > 0x10000 || vendor_id == 0) ++ return; ++ if (device_id > 0x10000 || device_id == 0) ++ return; ++ ++ for (i = 0; usb_dev_id[i].name; i++); ++ usb_dev_id[i].name = name; ++ usb_dev_id[i].vendor = vendor_id; ++ usb_dev_id[i].device = device_id; ++ usb_dev_id[i].private = flags; ++ pegasus_ids[i].match_flags = USB_DEVICE_ID_MATCH_DEVICE; ++ pegasus_ids[i].idVendor = vendor_id; ++ pegasus_ids[i].idProduct = device_id; ++} ++ ++static int __init pegasus_init(void) ++{ ++ pr_info("%s: %s, " DRIVER_DESC "\n", driver_name, DRIVER_VERSION); ++ if (devid) ++ parse_id(devid); ++ return usb_register(&pegasus_driver); ++} ++ ++static void __exit pegasus_exit(void) ++{ ++ usb_deregister(&pegasus_driver); ++} ++ ++module_init(pegasus_init); ++module_exit(pegasus_exit); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/pegasus.h backports-4.2.6-1/drivers/net/usb/pegasus.h +--- backports-4.2.6-1.org/drivers/net/usb/pegasus.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/pegasus.h 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,308 @@ ++/* ++ * Copyright (c) 1999-2013 Petko Manolov (petkan@nucleusys.com) ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License version 2 as published ++ * by the Free Software Foundation. ++ */ ++ ++ ++#ifndef PEGASUS_DEV ++ ++#define PEGASUS_II 0x80000000 ++#define HAS_HOME_PNA 0x40000000 ++ ++#define PEGASUS_MTU 1536 ++ ++#define EPROM_WRITE 0x01 ++#define EPROM_READ 0x02 ++#define EPROM_DONE 0x04 ++#define EPROM_WR_ENABLE 0x10 ++#define EPROM_LOAD 0x20 ++ ++#define PHY_DONE 0x80 ++#define PHY_READ 0x40 ++#define PHY_WRITE 0x20 ++#define DEFAULT_GPIO_RESET 0x24 ++#define DEFAULT_GPIO_SET 0x26 ++ ++#define PEGASUS_PRESENT 0x00000001 ++#define PEGASUS_TX_BUSY 0x00000004 ++#define PEGASUS_RX_BUSY 0x00000008 ++#define CTRL_URB_RUNNING 0x00000010 ++#define CTRL_URB_SLEEP 0x00000020 ++#define PEGASUS_UNPLUG 0x00000040 ++#define PEGASUS_RX_URB_FAIL 0x00000080 ++ ++#define RX_MULTICAST 2 ++#define RX_PROMISCUOUS 4 ++ ++#define REG_TIMEOUT (HZ) ++#define PEGASUS_TX_TIMEOUT (HZ*10) ++ ++#define TX_UNDERRUN 0x80 ++#define EXCESSIVE_COL 0x40 ++#define LATE_COL 0x20 ++#define NO_CARRIER 0x10 ++#define LOSS_CARRIER 0x08 ++#define JABBER_TIMEOUT 0x04 ++ ++#define LINK_STATUS 0x01 ++ ++#define PEGASUS_REQT_READ 0xc0 ++#define PEGASUS_REQT_WRITE 0x40 ++#define PEGASUS_REQ_GET_REGS 0xf0 ++#define PEGASUS_REQ_SET_REGS 0xf1 ++#define PEGASUS_REQ_SET_REG PEGASUS_REQ_SET_REGS ++ ++enum pegasus_registers { ++ EthCtrl0 = 0, ++ EthCtrl1 = 1, ++ EthCtrl2 = 2, ++ EthID = 0x10, ++ Reg1d = 0x1d, ++ EpromOffset = 0x20, ++ EpromData = 0x21, /* 0x21 low, 0x22 high byte */ ++ EpromCtrl = 0x23, ++ PhyAddr = 0x25, ++ PhyData = 0x26, /* 0x26 low, 0x27 high byte */ ++ PhyCtrl = 0x28, ++ UsbStst = 0x2a, ++ EthTxStat0 = 0x2b, ++ EthTxStat1 = 0x2c, ++ EthRxStat = 0x2d, ++ WakeupControl = 0x78, ++ Reg7b = 0x7b, ++ Gpio0 = 0x7e, ++ Gpio1 = 0x7f, ++ Reg81 = 0x81, ++}; ++ ++ ++typedef struct pegasus { ++ struct usb_device *usb; ++ struct usb_interface *intf; ++ struct net_device *net; ++ struct net_device_stats stats; ++ struct mii_if_info mii; ++ unsigned flags; ++ unsigned features; ++ u32 msg_enable; ++ u32 wolopts; ++ int dev_index; ++ int intr_interval; ++ struct tasklet_struct rx_tl; ++ struct delayed_work carrier_check; ++ struct urb *rx_urb, *tx_urb, *intr_urb; ++ struct sk_buff *rx_skb; ++ int chip; ++ unsigned char intr_buff[8]; ++ __u8 tx_buff[PEGASUS_MTU]; ++ __u8 eth_regs[4]; ++ __u8 phy; ++ __u8 gpio_res; ++} pegasus_t; ++ ++ ++struct usb_eth_dev { ++ char *name; ++ __u16 vendor; ++ __u16 device; ++ __u32 private; /* LSB is gpio reset value */ ++}; ++ ++#define VENDOR_3COM 0x0506 ++#define VENDOR_ABOCOM 0x07b8 ++#define VENDOR_ACCTON 0x083a ++#define VENDOR_ADMTEK 0x07a6 ++#define VENDOR_AEILAB 0x3334 ++#define VENDOR_ALLIEDTEL 0x07c9 ++#define VENDOR_ATEN 0x0557 ++#define VENDOR_BELKIN 0x050d ++#define VENDOR_BILLIONTON 0x08dd ++#define VENDOR_COMPAQ 0x049f ++#define VENDOR_COREGA 0x07aa ++#define VENDOR_DLINK 0x2001 ++#define VENDOR_ELCON 0x0db7 ++#define VENDOR_ELECOM 0x056e ++#define VENDOR_ELSA 0x05cc ++#define VENDOR_GIGABYTE 0x1044 ++#define VENDOR_HAWKING 0x0e66 ++#define VENDOR_HP 0x03f0 ++#define VENDOR_IODATA 0x04bb ++#define VENDOR_KINGSTON 0x0951 ++#define VENDOR_LANEED 0x056e ++#define VENDOR_LINKSYS 0x066b ++#define VENDOR_LINKSYS2 0x077b ++#define VENDOR_MELCO 0x0411 ++#define VENDOR_MICROSOFT 0x045e ++#define VENDOR_MOBILITY 0x1342 ++#define VENDOR_NETGEAR 0x0846 ++#define VENDOR_OCT 0x0b39 ++#define VENDOR_SMARTBRIDGES 0x08d1 ++#define VENDOR_SMC 0x0707 ++#define VENDOR_SOHOWARE 0x15e8 ++#define VENDOR_SIEMENS 0x067c ++ ++ ++#else /* PEGASUS_DEV */ ++ ++PEGASUS_DEV("3Com USB Ethernet 3C460B", VENDOR_3COM, 0x4601, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("ATEN USB Ethernet UC-110T", VENDOR_ATEN, 0x2007, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("USB HPNA/Ethernet", VENDOR_ABOCOM, 0x110c, ++ DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA) ++PEGASUS_DEV("USB HPNA/Ethernet", VENDOR_ABOCOM, 0x4104, ++ DEFAULT_GPIO_RESET | HAS_HOME_PNA) ++PEGASUS_DEV("USB HPNA/Ethernet", VENDOR_ABOCOM, 0x4004, ++ DEFAULT_GPIO_RESET | HAS_HOME_PNA) ++PEGASUS_DEV("USB HPNA/Ethernet", VENDOR_ABOCOM, 0x4007, ++ DEFAULT_GPIO_RESET | HAS_HOME_PNA) ++PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x4102, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x4002, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x400b, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x400c, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0xabc1, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("USB 10/100 Fast Ethernet", VENDOR_ABOCOM, 0x200c, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Accton USB 10/100 Ethernet Adapter", VENDOR_ACCTON, 0x1046, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("SpeedStream USB 10/100 Ethernet", VENDOR_ACCTON, 0x5046, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Philips USB 10/100 Ethernet", VENDOR_ACCTON, 0xb004, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("ADMtek ADM8511 "Pegasus II" USB Ethernet", ++ VENDOR_ADMTEK, 0x8511, ++ DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA) ++PEGASUS_DEV("ADMtek ADM8513 "Pegasus II" USB Ethernet", ++ VENDOR_ADMTEK, 0x8513, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("ADMtek ADM8515 "Pegasus II" USB-2.0 Ethernet", ++ VENDOR_ADMTEK, 0x8515, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("ADMtek AN986 "Pegasus" USB Ethernet (evaluation board)", ++ VENDOR_ADMTEK, 0x0986, ++ DEFAULT_GPIO_RESET | HAS_HOME_PNA) ++PEGASUS_DEV("AN986A USB MAC", VENDOR_ADMTEK, 1986, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("AEI USB Fast Ethernet Adapter", VENDOR_AEILAB, 0x1701, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Allied Telesyn Int. AT-USB100", VENDOR_ALLIEDTEL, 0xb100, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++/* ++ * Distinguish between this Belkin adaptor and the Belkin bluetooth adaptors ++ * with the same product IDs by checking the device class too. ++ */ ++PEGASUS_DEV_CLASS("Belkin F5D5050 USB Ethernet", VENDOR_BELKIN, 0x0121, 0x00, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Belkin F5U122 10/100 USB Ethernet", VENDOR_BELKIN, 0x0122, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Billionton USB-100", VENDOR_BILLIONTON, 0x0986, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("Billionton USBLP-100", VENDOR_BILLIONTON, 0x0987, ++ DEFAULT_GPIO_RESET | HAS_HOME_PNA) ++PEGASUS_DEV("iPAQ Networking 10/100 USB", VENDOR_COMPAQ, 0x8511, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Billionton USBEL-100", VENDOR_BILLIONTON, 0x0988, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("Billionton USBE-100", VENDOR_BILLIONTON, 0x8511, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Corega FEther USB-TX", VENDOR_COREGA, 0x0004, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("Corega FEther USB-TXS", VENDOR_COREGA, 0x000d, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x4001, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x4002, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x4102, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x400b, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("D-Link DSB-650TX", VENDOR_DLINK, 0x200c, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("D-Link DSB-650TX(PNA)", VENDOR_DLINK, 0x4003, ++ DEFAULT_GPIO_RESET | HAS_HOME_PNA) ++PEGASUS_DEV("D-Link DSB-650", VENDOR_DLINK, 0xabc1, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("GOLDPFEIL USB Adapter", VENDOR_ELCON, 0x0002, ++ DEFAULT_GPIO_RESET | PEGASUS_II | HAS_HOME_PNA) ++PEGASUS_DEV("ELECOM USB Ethernet LD-USB20", VENDOR_ELECOM, 0x4010, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("EasiDock Ethernet", VENDOR_MOBILITY, 0x0304, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("Elsa Micolink USB2Ethernet", VENDOR_ELSA, 0x3000, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("GIGABYTE GN-BR402W Wireless Router", VENDOR_GIGABYTE, 0x8002, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("Hawking UF100 10/100 Ethernet", VENDOR_HAWKING, 0x400c, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("HP hn210c Ethernet USB", VENDOR_HP, 0x811c, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("IO DATA USB ET/TX", VENDOR_IODATA, 0x0904, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("IO DATA USB ET/TX-S", VENDOR_IODATA, 0x0913, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("IO DATA USB ETX-US2", VENDOR_IODATA, 0x093a, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Kingston KNU101TX Ethernet", VENDOR_KINGSTON, 0x000a, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x4002, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("LANEED USB Ethernet LD-USBL/TX", VENDOR_LANEED, 0x4005, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x400b, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("LANEED USB Ethernet LD-USB/T", VENDOR_LANEED, 0xabc1, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("LANEED USB Ethernet LD-USB/TX", VENDOR_LANEED, 0x200c, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Linksys USB10TX", VENDOR_LINKSYS, 0x2202, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("Linksys USB100TX", VENDOR_LINKSYS, 0x2203, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("Linksys USB100TX", VENDOR_LINKSYS, 0x2204, ++ DEFAULT_GPIO_RESET | HAS_HOME_PNA) ++PEGASUS_DEV("Linksys USB10T Ethernet Adapter", VENDOR_LINKSYS, 0x2206, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Linksys USBVPN1", VENDOR_LINKSYS2, 0x08b4, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("Linksys USB USB100TX", VENDOR_LINKSYS, 0x400b, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Linksys USB10TX", VENDOR_LINKSYS, 0x200c, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("MELCO/BUFFALO LUA-TX", VENDOR_MELCO, 0x0001, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("MELCO/BUFFALO LUA-TX", VENDOR_MELCO, 0x0005, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("MELCO/BUFFALO LUA2-TX", VENDOR_MELCO, 0x0009, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("Microsoft MN-110", VENDOR_MICROSOFT, 0x007a, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("NETGEAR FA101", VENDOR_NETGEAR, 0x1020, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("OCT Inc.", VENDOR_OCT, 0x0109, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("OCT USB TO Ethernet", VENDOR_OCT, 0x0901, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("smartNIC 2 PnP Adapter", VENDOR_SMARTBRIDGES, 0x0003, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("SMC 202 USB Ethernet", VENDOR_SMC, 0x0200, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("SMC 2206 USB Ethernet", VENDOR_SMC, 0x0201, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("SOHOware NUB100 Ethernet", VENDOR_SOHOWARE, 0x9100, ++ DEFAULT_GPIO_RESET) ++PEGASUS_DEV("SOHOware NUB110 Ethernet", VENDOR_SOHOWARE, 0x9110, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++PEGASUS_DEV("SpeedStream USB 10/100 Ethernet", VENDOR_SIEMENS, 0x1001, ++ DEFAULT_GPIO_RESET | PEGASUS_II) ++ ++ ++#endif /* PEGASUS_DEV */ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/plusb.c backports-4.2.6-1/drivers/net/usb/plusb.c +--- backports-4.2.6-1.org/drivers/net/usb/plusb.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/plusb.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,162 @@ ++/* ++ * PL-2301/2302 USB host-to-host link cables ++ * Copyright (C) 2000-2005 by David Brownell ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++// #define DEBUG // error path messages, extra info ++// #define VERBOSE // more; success messages ++ ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/usb/usbnet.h> ++ ++ ++/* ++ * Prolific PL-2301/PL-2302 driver ... http://www.prolific.com.tw/ ++ * ++ * The protocol and handshaking used here should be bug-compatible ++ * with the Linux 2.2 "plusb" driver, by Deti Fliegl. ++ * ++ * HEADS UP: this handshaking isn't all that robust. This driver ++ * gets confused easily if you unplug one end of the cable then ++ * try to connect it again; you'll need to restart both ends. The ++ * "naplink" software (used by some PlayStation/2 deveopers) does ++ * the handshaking much better! Also, sometimes this hardware ++ * seems to get wedged under load. Prolific docs are weak, and ++ * don't identify differences between PL2301 and PL2302, much less ++ * anything to explain the different PL2302 versions observed. ++ * ++ * NOTE: pl2501 has several modes, including pl2301 and pl2302 ++ * compatibility. Some docs suggest the difference between 2301 ++ * and 2302 is only to make MS-Windows use a different driver... ++ * ++ * pl25a1 glue based on patch from Tony Gibbs. Prolific "docs" on ++ * this chip are as usual incomplete about what control messages ++ * are supported. ++ */ ++ ++/* ++ * Bits 0-4 can be used for software handshaking; they're set from ++ * one end, cleared from the other, "read" with the interrupt byte. ++ */ ++#define PL_S_EN (1<<7) /* (feature only) suspend enable */ ++/* reserved bit -- rx ready (6) ? */ ++#define PL_TX_READY (1<<5) /* (interrupt only) transmit ready */ ++#define PL_RESET_OUT (1<<4) /* reset output pipe */ ++#define PL_RESET_IN (1<<3) /* reset input pipe */ ++#define PL_TX_C (1<<2) /* transmission complete */ ++#define PL_TX_REQ (1<<1) /* transmission received */ ++#define PL_PEER_E (1<<0) /* peer exists */ ++ ++static inline int ++pl_vendor_req(struct usbnet *dev, u8 req, u8 val, u8 index) ++{ ++ return usbnet_read_cmd(dev, req, ++ USB_DIR_IN | USB_TYPE_VENDOR | ++ USB_RECIP_DEVICE, ++ val, index, NULL, 0); ++} ++ ++static inline int ++pl_clear_QuickLink_features(struct usbnet *dev, int val) ++{ ++ return pl_vendor_req(dev, 1, (u8) val, 0); ++} ++ ++static inline int ++pl_set_QuickLink_features(struct usbnet *dev, int val) ++{ ++ return pl_vendor_req(dev, 3, (u8) val, 0); ++} ++ ++static int pl_reset(struct usbnet *dev) ++{ ++ int status; ++ ++ /* some units seem to need this reset, others reject it utterly. ++ * FIXME be more like "naplink" or windows drivers. ++ */ ++ status = pl_set_QuickLink_features(dev, ++ PL_S_EN|PL_RESET_OUT|PL_RESET_IN|PL_PEER_E); ++ if (status != 0 && netif_msg_probe(dev)) ++ netif_dbg(dev, link, dev->net, "pl_reset --> %d\n", status); ++ return 0; ++} ++ ++static const struct driver_info prolific_info = { ++ .description = "Prolific PL-2301/PL-2302/PL-25A1", ++ .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT, ++ /* some PL-2302 versions seem to fail usb_set_interface() */ ++ .reset = pl_reset, ++}; ++ ++ ++/*-------------------------------------------------------------------------*/ ++ ++/* ++ * Proilific's name won't normally be on the cables, and ++ * may not be on the device. ++ */ ++ ++static const struct usb_device_id products [] = { ++ ++/* full speed cables */ ++{ ++ USB_DEVICE(0x067b, 0x0000), // PL-2301 ++ .driver_info = (unsigned long) &prolific_info, ++}, { ++ USB_DEVICE(0x067b, 0x0001), // PL-2302 ++ .driver_info = (unsigned long) &prolific_info, ++}, ++ ++/* high speed cables */ ++{ ++ USB_DEVICE(0x067b, 0x25a1), /* PL-25A1, no eeprom */ ++ .driver_info = (unsigned long) &prolific_info, ++}, { ++ USB_DEVICE(0x050d, 0x258a), /* Belkin F5U258/F5U279 (PL-25A1) */ ++ .driver_info = (unsigned long) &prolific_info, ++}, { ++ USB_DEVICE(0x3923, 0x7825), /* National Instruments USB ++ * Host-to-Host Cable ++ */ ++ .driver_info = (unsigned long) &prolific_info, ++}, ++ ++ { }, // END ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver plusb_driver = { ++ .name = "plusb", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(plusb_driver); ++ ++MODULE_AUTHOR("David Brownell"); ++MODULE_DESCRIPTION("Prolific PL-2301/2302/25A1 USB Host to Host Link Driver"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/r8152.c backports-4.2.6-1/drivers/net/usb/r8152.c +--- backports-4.2.6-1.org/drivers/net/usb/r8152.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/r8152.c 2016-01-27 12:43:25.000000000 +0100 +@@ -0,0 +1,2847 @@ ++/* ++ * Copyright (c) 2014 Realtek Semiconductor Corp. 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 as published by the Free Software Foundation. ++ * ++ */ ++ ++#include <linux/signal.h> ++#include <linux/slab.h> ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/mii.h> ++#include <linux/ethtool.h> ++#include <linux/usb.h> ++#include <linux/crc32.h> ++#include <linux/if_vlan.h> ++#include <linux/uaccess.h> ++#include <linux/list.h> ++#include <linux/ip.h> ++#include <linux/ipv6.h> ++ ++/* Version Information */ ++#define DRIVER_VERSION "v1.04.0 (2014/01/15)" ++#define DRIVER_AUTHOR "Realtek linux nic maintainers nic_swsd@realtek.com" ++#define DRIVER_DESC "Realtek RTL8152/RTL8153 Based USB Ethernet Adapters" ++#define MODULENAME "r8152" ++ ++#define R8152_PHY_ID 32 ++ ++#define PLA_IDR 0xc000 ++#define PLA_RCR 0xc010 ++#define PLA_RMS 0xc016 ++#define PLA_RXFIFO_CTRL0 0xc0a0 ++#define PLA_RXFIFO_CTRL1 0xc0a4 ++#define PLA_RXFIFO_CTRL2 0xc0a8 ++#define PLA_FMC 0xc0b4 ++#define PLA_CFG_WOL 0xc0b6 ++#define PLA_TEREDO_CFG 0xc0bc ++#define PLA_MAR 0xcd00 ++#define PLA_BACKUP 0xd000 ++#define PAL_BDC_CR 0xd1a0 ++#define PLA_TEREDO_TIMER 0xd2cc ++#define PLA_REALWOW_TIMER 0xd2e8 ++#define PLA_LEDSEL 0xdd90 ++#define PLA_LED_FEATURE 0xdd92 ++#define PLA_PHYAR 0xde00 ++#define PLA_BOOT_CTRL 0xe004 ++#define PLA_GPHY_INTR_IMR 0xe022 ++#define PLA_EEE_CR 0xe040 ++#define PLA_EEEP_CR 0xe080 ++#define PLA_MAC_PWR_CTRL 0xe0c0 ++#define PLA_MAC_PWR_CTRL2 0xe0ca ++#define PLA_MAC_PWR_CTRL3 0xe0cc ++#define PLA_MAC_PWR_CTRL4 0xe0ce ++#define PLA_WDT6_CTRL 0xe428 ++#define PLA_TCR0 0xe610 ++#define PLA_TCR1 0xe612 ++#define PLA_TXFIFO_CTRL 0xe618 ++#define PLA_RSTTELLY 0xe800 ++#define PLA_CR 0xe813 ++#define PLA_CRWECR 0xe81c ++#define PLA_CONFIG5 0xe822 ++#define PLA_PHY_PWR 0xe84c ++#define PLA_OOB_CTRL 0xe84f ++#define PLA_CPCR 0xe854 ++#define PLA_MISC_0 0xe858 ++#define PLA_MISC_1 0xe85a ++#define PLA_OCP_GPHY_BASE 0xe86c ++#define PLA_TELLYCNT 0xe890 ++#define PLA_SFF_STS_7 0xe8de ++#define PLA_PHYSTATUS 0xe908 ++#define PLA_BP_BA 0xfc26 ++#define PLA_BP_0 0xfc28 ++#define PLA_BP_1 0xfc2a ++#define PLA_BP_2 0xfc2c ++#define PLA_BP_3 0xfc2e ++#define PLA_BP_4 0xfc30 ++#define PLA_BP_5 0xfc32 ++#define PLA_BP_6 0xfc34 ++#define PLA_BP_7 0xfc36 ++#define PLA_BP_EN 0xfc38 ++ ++#define USB_U2P3_CTRL 0xb460 ++#define USB_DEV_STAT 0xb808 ++#define USB_USB_CTRL 0xd406 ++#define USB_PHY_CTRL 0xd408 ++#define USB_TX_AGG 0xd40a ++#define USB_RX_BUF_TH 0xd40c ++#define USB_USB_TIMER 0xd428 ++#define USB_RX_EARLY_AGG 0xd42c ++#define USB_PM_CTRL_STATUS 0xd432 ++#define USB_TX_DMA 0xd434 ++#define USB_TOLERANCE 0xd490 ++#define USB_LPM_CTRL 0xd41a ++#define USB_UPS_CTRL 0xd800 ++#define USB_MISC_0 0xd81a ++#define USB_POWER_CUT 0xd80a ++#define USB_AFE_CTRL2 0xd824 ++#define USB_WDT11_CTRL 0xe43c ++#define USB_BP_BA 0xfc26 ++#define USB_BP_0 0xfc28 ++#define USB_BP_1 0xfc2a ++#define USB_BP_2 0xfc2c ++#define USB_BP_3 0xfc2e ++#define USB_BP_4 0xfc30 ++#define USB_BP_5 0xfc32 ++#define USB_BP_6 0xfc34 ++#define USB_BP_7 0xfc36 ++#define USB_BP_EN 0xfc38 ++ ++/* OCP Registers */ ++#define OCP_ALDPS_CONFIG 0x2010 ++#define OCP_EEE_CONFIG1 0x2080 ++#define OCP_EEE_CONFIG2 0x2092 ++#define OCP_EEE_CONFIG3 0x2094 ++#define OCP_BASE_MII 0xa400 ++#define OCP_EEE_AR 0xa41a ++#define OCP_EEE_DATA 0xa41c ++#define OCP_PHY_STATUS 0xa420 ++#define OCP_POWER_CFG 0xa430 ++#define OCP_EEE_CFG 0xa432 ++#define OCP_SRAM_ADDR 0xa436 ++#define OCP_SRAM_DATA 0xa438 ++#define OCP_DOWN_SPEED 0xa442 ++#define OCP_EEE_CFG2 0xa5d0 ++#define OCP_ADC_CFG 0xbc06 ++ ++/* SRAM Register */ ++#define SRAM_LPF_CFG 0x8012 ++#define SRAM_10M_AMP1 0x8080 ++#define SRAM_10M_AMP2 0x8082 ++#define SRAM_IMPEDANCE 0x8084 ++ ++/* PLA_RCR */ ++#define RCR_AAP 0x00000001 ++#define RCR_APM 0x00000002 ++#define RCR_AM 0x00000004 ++#define RCR_AB 0x00000008 ++#define RCR_ACPT_ALL (RCR_AAP | RCR_APM | RCR_AM | RCR_AB) ++ ++/* PLA_RXFIFO_CTRL0 */ ++#define RXFIFO_THR1_NORMAL 0x00080002 ++#define RXFIFO_THR1_OOB 0x01800003 ++ ++/* PLA_RXFIFO_CTRL1 */ ++#define RXFIFO_THR2_FULL 0x00000060 ++#define RXFIFO_THR2_HIGH 0x00000038 ++#define RXFIFO_THR2_OOB 0x0000004a ++#define RXFIFO_THR2_NORMAL 0x00a0 ++ ++/* PLA_RXFIFO_CTRL2 */ ++#define RXFIFO_THR3_FULL 0x00000078 ++#define RXFIFO_THR3_HIGH 0x00000048 ++#define RXFIFO_THR3_OOB 0x0000005a ++#define RXFIFO_THR3_NORMAL 0x0110 ++ ++/* PLA_TXFIFO_CTRL */ ++#define TXFIFO_THR_NORMAL 0x00400008 ++#define TXFIFO_THR_NORMAL2 0x01000008 ++ ++/* PLA_FMC */ ++#define FMC_FCR_MCU_EN 0x0001 ++ ++/* PLA_EEEP_CR */ ++#define EEEP_CR_EEEP_TX 0x0002 ++ ++/* PLA_WDT6_CTRL */ ++#define WDT6_SET_MODE 0x0010 ++ ++/* PLA_TCR0 */ ++#define TCR0_TX_EMPTY 0x0800 ++#define TCR0_AUTO_FIFO 0x0080 ++ ++/* PLA_TCR1 */ ++#define VERSION_MASK 0x7cf0 ++ ++/* PLA_CR */ ++#define CR_RST 0x10 ++#define CR_RE 0x08 ++#define CR_TE 0x04 ++ ++/* PLA_CRWECR */ ++#define CRWECR_NORAML 0x00 ++#define CRWECR_CONFIG 0xc0 ++ ++/* PLA_OOB_CTRL */ ++#define NOW_IS_OOB 0x80 ++#define TXFIFO_EMPTY 0x20 ++#define RXFIFO_EMPTY 0x10 ++#define LINK_LIST_READY 0x02 ++#define DIS_MCU_CLROOB 0x01 ++#define FIFO_EMPTY (TXFIFO_EMPTY | RXFIFO_EMPTY) ++ ++/* PLA_MISC_1 */ ++#define RXDY_GATED_EN 0x0008 ++ ++/* PLA_SFF_STS_7 */ ++#define RE_INIT_LL 0x8000 ++#define MCU_BORW_EN 0x4000 ++ ++/* PLA_CPCR */ ++#define CPCR_RX_VLAN 0x0040 ++ ++/* PLA_CFG_WOL */ ++#define MAGIC_EN 0x0001 ++ ++/* PLA_TEREDO_CFG */ ++#define TEREDO_SEL 0x8000 ++#define TEREDO_WAKE_MASK 0x7f00 ++#define TEREDO_RS_EVENT_MASK 0x00fe ++#define OOB_TEREDO_EN 0x0001 ++ ++/* PAL_BDC_CR */ ++#define ALDPS_PROXY_MODE 0x0001 ++ ++/* PLA_CONFIG5 */ ++#define LAN_WAKE_EN 0x0002 ++ ++/* PLA_LED_FEATURE */ ++#define LED_MODE_MASK 0x0700 ++ ++/* PLA_PHY_PWR */ ++#define TX_10M_IDLE_EN 0x0080 ++#define PFM_PWM_SWITCH 0x0040 ++ ++/* PLA_MAC_PWR_CTRL */ ++#define D3_CLK_GATED_EN 0x00004000 ++#define MCU_CLK_RATIO 0x07010f07 ++#define MCU_CLK_RATIO_MASK 0x0f0f0f0f ++#define ALDPS_SPDWN_RATIO 0x0f87 ++ ++/* PLA_MAC_PWR_CTRL2 */ ++#define EEE_SPDWN_RATIO 0x8007 ++ ++/* PLA_MAC_PWR_CTRL3 */ ++#define PKT_AVAIL_SPDWN_EN 0x0100 ++#define SUSPEND_SPDWN_EN 0x0004 ++#define U1U2_SPDWN_EN 0x0002 ++#define L1_SPDWN_EN 0x0001 ++ ++/* PLA_MAC_PWR_CTRL4 */ ++#define PWRSAVE_SPDWN_EN 0x1000 ++#define RXDV_SPDWN_EN 0x0800 ++#define TX10MIDLE_EN 0x0100 ++#define TP100_SPDWN_EN 0x0020 ++#define TP500_SPDWN_EN 0x0010 ++#define TP1000_SPDWN_EN 0x0008 ++#define EEE_SPDWN_EN 0x0001 ++ ++/* PLA_GPHY_INTR_IMR */ ++#define GPHY_STS_MSK 0x0001 ++#define SPEED_DOWN_MSK 0x0002 ++#define SPDWN_RXDV_MSK 0x0004 ++#define SPDWN_LINKCHG_MSK 0x0008 ++ ++/* PLA_PHYAR */ ++#define PHYAR_FLAG 0x80000000 ++ ++/* PLA_EEE_CR */ ++#define EEE_RX_EN 0x0001 ++#define EEE_TX_EN 0x0002 ++ ++/* PLA_BOOT_CTRL */ ++#define AUTOLOAD_DONE 0x0002 ++ ++/* USB_DEV_STAT */ ++#define STAT_SPEED_MASK 0x0006 ++#define STAT_SPEED_HIGH 0x0000 ++#define STAT_SPEED_FULL 0x0001 ++ ++/* USB_TX_AGG */ ++#define TX_AGG_MAX_THRESHOLD 0x03 ++ ++/* USB_RX_BUF_TH */ ++#define RX_THR_SUPPER 0x0c350180 ++#define RX_THR_HIGH 0x7a120180 ++#define RX_THR_SLOW 0xffff0180 ++ ++/* USB_TX_DMA */ ++#define TEST_MODE_DISABLE 0x00000001 ++#define TX_SIZE_ADJUST1 0x00000100 ++ ++/* USB_UPS_CTRL */ ++#define POWER_CUT 0x0100 ++ ++/* USB_PM_CTRL_STATUS */ ++#define RESUME_INDICATE 0x0001 ++ ++/* USB_USB_CTRL */ ++#define RX_AGG_DISABLE 0x0010 ++ ++/* USB_U2P3_CTRL */ ++#define U2P3_ENABLE 0x0001 ++ ++/* USB_POWER_CUT */ ++#define PWR_EN 0x0001 ++#define PHASE2_EN 0x0008 ++ ++/* USB_MISC_0 */ ++#define PCUT_STATUS 0x0001 ++ ++/* USB_RX_EARLY_AGG */ ++#define EARLY_AGG_SUPPER 0x0e832981 ++#define EARLY_AGG_HIGH 0x0e837a12 ++#define EARLY_AGG_SLOW 0x0e83ffff ++ ++/* USB_WDT11_CTRL */ ++#define TIMER11_EN 0x0001 ++ ++/* USB_LPM_CTRL */ ++#define LPM_TIMER_MASK 0x0c ++#define LPM_TIMER_500MS 0x04 /* 500 ms */ ++#define LPM_TIMER_500US 0x0c /* 500 us */ ++ ++/* USB_AFE_CTRL2 */ ++#define SEN_VAL_MASK 0xf800 ++#define SEN_VAL_NORMAL 0xa000 ++#define SEL_RXIDLE 0x0100 ++ ++/* OCP_ALDPS_CONFIG */ ++#define ENPWRSAVE 0x8000 ++#define ENPDNPS 0x0200 ++#define LINKENA 0x0100 ++#define DIS_SDSAVE 0x0010 ++ ++/* OCP_PHY_STATUS */ ++#define PHY_STAT_MASK 0x0007 ++#define PHY_STAT_LAN_ON 3 ++#define PHY_STAT_PWRDN 5 ++ ++/* OCP_POWER_CFG */ ++#define EEE_CLKDIV_EN 0x8000 ++#define EN_ALDPS 0x0004 ++#define EN_10M_PLLOFF 0x0001 ++ ++/* OCP_EEE_CONFIG1 */ ++#define RG_TXLPI_MSK_HFDUP 0x8000 ++#define RG_MATCLR_EN 0x4000 ++#define EEE_10_CAP 0x2000 ++#define EEE_NWAY_EN 0x1000 ++#define TX_QUIET_EN 0x0200 ++#define RX_QUIET_EN 0x0100 ++#define SDRISETIME 0x0010 /* bit 4 ~ 6 */ ++#define RG_RXLPI_MSK_HFDUP 0x0008 ++#define SDFALLTIME 0x0007 /* bit 0 ~ 2 */ ++ ++/* OCP_EEE_CONFIG2 */ ++#define RG_LPIHYS_NUM 0x7000 /* bit 12 ~ 15 */ ++#define RG_DACQUIET_EN 0x0400 ++#define RG_LDVQUIET_EN 0x0200 ++#define RG_CKRSEL 0x0020 ++#define RG_EEEPRG_EN 0x0010 ++ ++/* OCP_EEE_CONFIG3 */ ++#define FST_SNR_EYE_R 0x1500 /* bit 7 ~ 15 */ ++#define RG_LFS_SEL 0x0060 /* bit 6 ~ 5 */ ++#define MSK_PH 0x0006 /* bit 0 ~ 3 */ ++ ++/* OCP_EEE_AR */ ++/* bit[15:14] function */ ++#define FUN_ADDR 0x0000 ++#define FUN_DATA 0x4000 ++/* bit[4:0] device addr */ ++#define DEVICE_ADDR 0x0007 ++ ++/* OCP_EEE_DATA */ ++#define EEE_ADDR 0x003C ++#define EEE_DATA 0x0002 ++ ++/* OCP_EEE_CFG */ ++#define CTAP_SHORT_EN 0x0040 ++#define EEE10_EN 0x0010 ++ ++/* OCP_DOWN_SPEED */ ++#define EN_10M_BGOFF 0x0080 ++ ++/* OCP_EEE_CFG2 */ ++#define MY1000_EEE 0x0004 ++#define MY100_EEE 0x0002 ++ ++/* OCP_ADC_CFG */ ++#define CKADSEL_L 0x0100 ++#define ADC_EN 0x0080 ++#define EN_EMI_L 0x0040 ++ ++/* SRAM_LPF_CFG */ ++#define LPF_AUTO_TUNE 0x8000 ++ ++/* SRAM_10M_AMP1 */ ++#define GDAC_IB_UPALL 0x0008 ++ ++/* SRAM_10M_AMP2 */ ++#define AMP_DN 0x0200 ++ ++/* SRAM_IMPEDANCE */ ++#define RX_DRIVING_MASK 0x6000 ++ ++enum rtl_register_content { ++ _1000bps = 0x10, ++ _100bps = 0x08, ++ _10bps = 0x04, ++ LINK_STATUS = 0x02, ++ FULL_DUP = 0x01, ++}; ++ ++#define RTL8152_MAX_TX 10 ++#define RTL8152_MAX_RX 10 ++#define INTBUFSIZE 2 ++#define CRC_SIZE 4 ++#define TX_ALIGN 4 ++#define RX_ALIGN 8 ++ ++#define INTR_LINK 0x0004 ++ ++#define RTL8152_REQT_READ 0xc0 ++#define RTL8152_REQT_WRITE 0x40 ++#define RTL8152_REQ_GET_REGS 0x05 ++#define RTL8152_REQ_SET_REGS 0x05 ++ ++#define BYTE_EN_DWORD 0xff ++#define BYTE_EN_WORD 0x33 ++#define BYTE_EN_BYTE 0x11 ++#define BYTE_EN_SIX_BYTES 0x3f ++#define BYTE_EN_START_MASK 0x0f ++#define BYTE_EN_END_MASK 0xf0 ++ ++#define RTL8152_RMS (VLAN_ETH_FRAME_LEN + VLAN_HLEN) ++#define RTL8152_TX_TIMEOUT (HZ) ++ ++/* rtl8152 flags */ ++enum rtl8152_flags { ++ RTL8152_UNPLUG = 0, ++ RTL8152_SET_RX_MODE, ++ WORK_ENABLE, ++ RTL8152_LINK_CHG, ++}; ++ ++/* Define these values to match your device */ ++#define VENDOR_ID_REALTEK 0x0bda ++#define PRODUCT_ID_RTL8152 0x8152 ++#define PRODUCT_ID_RTL8153 0x8153 ++ ++#define VENDOR_ID_SAMSUNG 0x04e8 ++#define PRODUCT_ID_SAMSUNG 0xa101 ++ ++#define MCU_TYPE_PLA 0x0100 ++#define MCU_TYPE_USB 0x0000 ++ ++struct rx_desc { ++ __le32 opts1; ++#define RX_LEN_MASK 0x7fff ++ __le32 opts2; ++ __le32 opts3; ++ __le32 opts4; ++ __le32 opts5; ++ __le32 opts6; ++}; ++ ++struct tx_desc { ++ __le32 opts1; ++#define TX_FS (1 << 31) /* First segment of a packet */ ++#define TX_LS (1 << 30) /* Final segment of a packet */ ++#define TX_LEN_MASK 0x3ffff ++ ++ __le32 opts2; ++#define UDP_CS (1 << 31) /* Calculate UDP/IP checksum */ ++#define TCP_CS (1 << 30) /* Calculate TCP/IP checksum */ ++#define IPV4_CS (1 << 29) /* Calculate IPv4 checksum */ ++#define IPV6_CS (1 << 28) /* Calculate IPv6 checksum */ ++}; ++ ++struct r8152; ++ ++struct rx_agg { ++ struct list_head list; ++ struct urb *urb; ++ struct r8152 *context; ++ void *buffer; ++ void *head; ++}; ++ ++struct tx_agg { ++ struct list_head list; ++ struct urb *urb; ++ struct r8152 *context; ++ void *buffer; ++ void *head; ++ u32 skb_num; ++ u32 skb_len; ++}; ++ ++struct r8152 { ++ unsigned long flags; ++ struct usb_device *udev; ++ struct tasklet_struct tl; ++ struct usb_interface *intf; ++ struct net_device *netdev; ++ struct urb *intr_urb; ++ struct tx_agg tx_info[RTL8152_MAX_TX]; ++ struct rx_agg rx_info[RTL8152_MAX_RX]; ++ struct list_head rx_done, tx_free; ++ struct sk_buff_head tx_queue; ++ spinlock_t rx_lock, tx_lock; ++ struct delayed_work schedule; ++ struct mii_if_info mii; ++ ++ struct rtl_ops { ++ void (*init)(struct r8152 *); ++ int (*enable)(struct r8152 *); ++ void (*disable)(struct r8152 *); ++ void (*down)(struct r8152 *); ++ void (*unload)(struct r8152 *); ++ } __no_const rtl_ops; ++ ++ int intr_interval; ++ u32 msg_enable; ++ u32 tx_qlen; ++ u16 ocp_base; ++ u8 *intr_buff; ++ u8 version; ++ u8 speed; ++}; ++ ++enum rtl_version { ++ RTL_VER_UNKNOWN = 0, ++ RTL_VER_01, ++ RTL_VER_02, ++ RTL_VER_03, ++ RTL_VER_04, ++ RTL_VER_05, ++ RTL_VER_MAX ++}; ++ ++/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). ++ * The RTL chips use a 64 element hash table based on the Ethernet CRC. ++ */ ++static const int multicast_filter_limit = 32; ++static unsigned int rx_buf_sz = 16384; ++ ++static ++int get_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) ++{ ++ int ret; ++ void *tmp; ++ ++ tmp = kmalloc(size, GFP_KERNEL); ++ if (!tmp) ++ return -ENOMEM; ++ ++ ret = usb_control_msg(tp->udev, usb_rcvctrlpipe(tp->udev, 0), ++ RTL8152_REQ_GET_REGS, RTL8152_REQT_READ, ++ value, index, tmp, size, 500); ++ ++ memcpy(data, tmp, size); ++ kfree(tmp); ++ ++ return ret; ++} ++ ++static ++int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data) ++{ ++ int ret; ++ void *tmp; ++ ++ tmp = kmalloc(size, GFP_KERNEL); ++ if (!tmp) ++ return -ENOMEM; ++ ++ memcpy(tmp, data, size); ++ ++ ret = usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0), ++ RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE, ++ value, index, tmp, size, 500); ++ ++ kfree(tmp); ++ return ret; ++} ++ ++static int generic_ocp_read(struct r8152 *tp, u16 index, u16 size, ++ void *data, u16 type) ++{ ++ u16 limit = 64; ++ int ret = 0; ++ ++ if (test_bit(RTL8152_UNPLUG, &tp->flags)) ++ return -ENODEV; ++ ++ /* both size and indix must be 4 bytes align */ ++ if ((size & 3) || !size || (index & 3) || !data) ++ return -EPERM; ++ ++ if ((u32)index + (u32)size > 0xffff) ++ return -EPERM; ++ ++ while (size) { ++ if (size > limit) { ++ ret = get_registers(tp, index, type, limit, data); ++ if (ret < 0) ++ break; ++ ++ index += limit; ++ data += limit; ++ size -= limit; ++ } else { ++ ret = get_registers(tp, index, type, size, data); ++ if (ret < 0) ++ break; ++ ++ index += size; ++ data += size; ++ size = 0; ++ break; ++ } ++ } ++ ++ return ret; ++} ++ ++static int generic_ocp_write(struct r8152 *tp, u16 index, u16 byteen, ++ u16 size, void *data, u16 type) ++{ ++ int ret; ++ u16 byteen_start, byteen_end, byen; ++ u16 limit = 512; ++ ++ if (test_bit(RTL8152_UNPLUG, &tp->flags)) ++ return -ENODEV; ++ ++ /* both size and indix must be 4 bytes align */ ++ if ((size & 3) || !size || (index & 3) || !data) ++ return -EPERM; ++ ++ if ((u32)index + (u32)size > 0xffff) ++ return -EPERM; ++ ++ byteen_start = byteen & BYTE_EN_START_MASK; ++ byteen_end = byteen & BYTE_EN_END_MASK; ++ ++ byen = byteen_start | (byteen_start << 4); ++ ret = set_registers(tp, index, type | byen, 4, data); ++ if (ret < 0) ++ goto error1; ++ ++ index += 4; ++ data += 4; ++ size -= 4; ++ ++ if (size) { ++ size -= 4; ++ ++ while (size) { ++ if (size > limit) { ++ ret = set_registers(tp, index, ++ type | BYTE_EN_DWORD, ++ limit, data); ++ if (ret < 0) ++ goto error1; ++ ++ index += limit; ++ data += limit; ++ size -= limit; ++ } else { ++ ret = set_registers(tp, index, ++ type | BYTE_EN_DWORD, ++ size, data); ++ if (ret < 0) ++ goto error1; ++ ++ index += size; ++ data += size; ++ size = 0; ++ break; ++ } ++ } ++ ++ byen = byteen_end | (byteen_end >> 4); ++ ret = set_registers(tp, index, type | byen, 4, data); ++ if (ret < 0) ++ goto error1; ++ } ++ ++error1: ++ return ret; ++} ++ ++static inline ++int pla_ocp_read(struct r8152 *tp, u16 index, u16 size, void *data) ++{ ++ return generic_ocp_read(tp, index, size, data, MCU_TYPE_PLA); ++} ++ ++static inline ++int pla_ocp_write(struct r8152 *tp, u16 index, u16 byteen, u16 size, void *data) ++{ ++ return generic_ocp_write(tp, index, byteen, size, data, MCU_TYPE_PLA); ++} ++ ++static inline ++int usb_ocp_read(struct r8152 *tp, u16 index, u16 size, void *data) ++{ ++ return generic_ocp_read(tp, index, size, data, MCU_TYPE_USB); ++} ++ ++static inline ++int usb_ocp_write(struct r8152 *tp, u16 index, u16 byteen, u16 size, void *data) ++{ ++ return generic_ocp_write(tp, index, byteen, size, data, MCU_TYPE_USB); ++} ++ ++static u32 ocp_read_dword(struct r8152 *tp, u16 type, u16 index) ++{ ++ __le32 data; ++ ++ generic_ocp_read(tp, index, sizeof(data), &data, type); ++ ++ return __le32_to_cpu(data); ++} ++ ++static void ocp_write_dword(struct r8152 *tp, u16 type, u16 index, u32 data) ++{ ++ __le32 tmp = __cpu_to_le32(data); ++ ++ generic_ocp_write(tp, index, BYTE_EN_DWORD, sizeof(tmp), &tmp, type); ++} ++ ++static u16 ocp_read_word(struct r8152 *tp, u16 type, u16 index) ++{ ++ u32 data; ++ __le32 tmp; ++ u8 shift = index & 2; ++ ++ index &= ~3; ++ ++ generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); ++ ++ data = __le32_to_cpu(tmp); ++ data >>= (shift * 8); ++ data &= 0xffff; ++ ++ return (u16)data; ++} ++ ++static void ocp_write_word(struct r8152 *tp, u16 type, u16 index, u32 data) ++{ ++ u32 mask = 0xffff; ++ __le32 tmp; ++ u16 byen = BYTE_EN_WORD; ++ u8 shift = index & 2; ++ ++ data &= mask; ++ ++ if (index & 2) { ++ byen <<= shift; ++ mask <<= (shift * 8); ++ data <<= (shift * 8); ++ index &= ~3; ++ } ++ ++ generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); ++ ++ data |= __le32_to_cpu(tmp) & ~mask; ++ tmp = __cpu_to_le32(data); ++ ++ generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); ++} ++ ++static u8 ocp_read_byte(struct r8152 *tp, u16 type, u16 index) ++{ ++ u32 data; ++ __le32 tmp; ++ u8 shift = index & 3; ++ ++ index &= ~3; ++ ++ generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); ++ ++ data = __le32_to_cpu(tmp); ++ data >>= (shift * 8); ++ data &= 0xff; ++ ++ return (u8)data; ++} ++ ++static void ocp_write_byte(struct r8152 *tp, u16 type, u16 index, u32 data) ++{ ++ u32 mask = 0xff; ++ __le32 tmp; ++ u16 byen = BYTE_EN_BYTE; ++ u8 shift = index & 3; ++ ++ data &= mask; ++ ++ if (index & 3) { ++ byen <<= shift; ++ mask <<= (shift * 8); ++ data <<= (shift * 8); ++ index &= ~3; ++ } ++ ++ generic_ocp_read(tp, index, sizeof(tmp), &tmp, type); ++ ++ data |= __le32_to_cpu(tmp) & ~mask; ++ tmp = __cpu_to_le32(data); ++ ++ generic_ocp_write(tp, index, byen, sizeof(tmp), &tmp, type); ++} ++ ++static u16 ocp_reg_read(struct r8152 *tp, u16 addr) ++{ ++ u16 ocp_base, ocp_index; ++ ++ ocp_base = addr & 0xf000; ++ if (ocp_base != tp->ocp_base) { ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, ocp_base); ++ tp->ocp_base = ocp_base; ++ } ++ ++ ocp_index = (addr & 0x0fff) | 0xb000; ++ return ocp_read_word(tp, MCU_TYPE_PLA, ocp_index); ++} ++ ++static void ocp_reg_write(struct r8152 *tp, u16 addr, u16 data) ++{ ++ u16 ocp_base, ocp_index; ++ ++ ocp_base = addr & 0xf000; ++ if (ocp_base != tp->ocp_base) { ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_OCP_GPHY_BASE, ocp_base); ++ tp->ocp_base = ocp_base; ++ } ++ ++ ocp_index = (addr & 0x0fff) | 0xb000; ++ ocp_write_word(tp, MCU_TYPE_PLA, ocp_index, data); ++} ++ ++static inline void r8152_mdio_write(struct r8152 *tp, u32 reg_addr, u32 value) ++{ ++ ocp_reg_write(tp, OCP_BASE_MII + reg_addr * 2, value); ++} ++ ++static inline int r8152_mdio_read(struct r8152 *tp, u32 reg_addr) ++{ ++ return ocp_reg_read(tp, OCP_BASE_MII + reg_addr * 2); ++} ++ ++static void sram_write(struct r8152 *tp, u16 addr, u16 data) ++{ ++ ocp_reg_write(tp, OCP_SRAM_ADDR, addr); ++ ocp_reg_write(tp, OCP_SRAM_DATA, data); ++} ++ ++static u16 sram_read(struct r8152 *tp, u16 addr) ++{ ++ ocp_reg_write(tp, OCP_SRAM_ADDR, addr); ++ return ocp_reg_read(tp, OCP_SRAM_DATA); ++} ++ ++static int read_mii_word(struct net_device *netdev, int phy_id, int reg) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ ++ if (phy_id != R8152_PHY_ID) ++ return -EINVAL; ++ ++ return r8152_mdio_read(tp, reg); ++} ++ ++static ++void write_mii_word(struct net_device *netdev, int phy_id, int reg, int val) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ ++ if (phy_id != R8152_PHY_ID) ++ return; ++ ++ r8152_mdio_write(tp, reg, val); ++} ++ ++static ++int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags); ++ ++static inline void set_ethernet_addr(struct r8152 *tp) ++{ ++ struct net_device *dev = tp->netdev; ++ u8 node_id[8] = {0}; ++ ++ if (pla_ocp_read(tp, PLA_IDR, sizeof(node_id), node_id) < 0) ++ netif_notice(tp, probe, dev, "inet addr fail\n"); ++ else { ++ memcpy(dev->dev_addr, node_id, dev->addr_len); ++ memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len); ++ } ++} ++ ++static int rtl8152_set_mac_address(struct net_device *netdev, void *p) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ struct sockaddr *addr = p; ++ ++ if (!is_valid_ether_addr(addr->sa_data)) ++ return -EADDRNOTAVAIL; ++ ++ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); ++ ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_CONFIG); ++ pla_ocp_write(tp, PLA_IDR, BYTE_EN_SIX_BYTES, 8, addr->sa_data); ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); ++ ++ return 0; ++} ++ ++static struct net_device_stats *rtl8152_get_stats(struct net_device *dev) ++{ ++ return &dev->stats; ++} ++ ++static void read_bulk_callback(struct urb *urb) ++{ ++ struct net_device *netdev; ++ unsigned long flags; ++ int status = urb->status; ++ struct rx_agg *agg; ++ struct r8152 *tp; ++ int result; ++ ++ agg = urb->context; ++ if (!agg) ++ return; ++ ++ tp = agg->context; ++ if (!tp) ++ return; ++ ++ if (test_bit(RTL8152_UNPLUG, &tp->flags)) ++ return; ++ ++ if (!test_bit(WORK_ENABLE, &tp->flags)) ++ return; ++ ++ netdev = tp->netdev; ++ ++ /* When link down, the driver would cancel all bulks. */ ++ /* This avoid the re-submitting bulk */ ++ if (!netif_carrier_ok(netdev)) ++ return; ++ ++ switch (status) { ++ case 0: ++ if (urb->actual_length < ETH_ZLEN) ++ break; ++ ++ spin_lock_irqsave(&tp->rx_lock, flags); ++ list_add_tail(&agg->list, &tp->rx_done); ++ spin_unlock_irqrestore(&tp->rx_lock, flags); ++ tasklet_schedule(&tp->tl); ++ return; ++ case -ESHUTDOWN: ++ set_bit(RTL8152_UNPLUG, &tp->flags); ++ netif_device_detach(tp->netdev); ++ return; ++ case -ENOENT: ++ return; /* the urb is in unlink state */ ++ case -ETIME: ++ if (net_ratelimit()) ++ netdev_warn(netdev, "maybe reset is needed?\n"); ++ break; ++ default: ++ if (net_ratelimit()) ++ netdev_warn(netdev, "Rx status %d\n", status); ++ break; ++ } ++ ++ result = r8152_submit_rx(tp, agg, GFP_ATOMIC); ++ if (result == -ENODEV) { ++ netif_device_detach(tp->netdev); ++ } else if (result) { ++ spin_lock_irqsave(&tp->rx_lock, flags); ++ list_add_tail(&agg->list, &tp->rx_done); ++ spin_unlock_irqrestore(&tp->rx_lock, flags); ++ tasklet_schedule(&tp->tl); ++ } ++} ++ ++static void write_bulk_callback(struct urb *urb) ++{ ++ struct net_device_stats *stats; ++ unsigned long flags; ++ struct tx_agg *agg; ++ struct r8152 *tp; ++ int status = urb->status; ++ ++ agg = urb->context; ++ if (!agg) ++ return; ++ ++ tp = agg->context; ++ if (!tp) ++ return; ++ ++ stats = rtl8152_get_stats(tp->netdev); ++ if (status) { ++ if (net_ratelimit()) ++ netdev_warn(tp->netdev, "Tx status %d\n", status); ++ stats->tx_errors += agg->skb_num; ++ } else { ++ stats->tx_packets += agg->skb_num; ++ stats->tx_bytes += agg->skb_len; ++ } ++ ++ spin_lock_irqsave(&tp->tx_lock, flags); ++ list_add_tail(&agg->list, &tp->tx_free); ++ spin_unlock_irqrestore(&tp->tx_lock, flags); ++ ++ if (!netif_carrier_ok(tp->netdev)) ++ return; ++ ++ if (!test_bit(WORK_ENABLE, &tp->flags)) ++ return; ++ ++ if (test_bit(RTL8152_UNPLUG, &tp->flags)) ++ return; ++ ++ if (!skb_queue_empty(&tp->tx_queue)) ++ tasklet_schedule(&tp->tl); ++} ++ ++static void intr_callback(struct urb *urb) ++{ ++ struct r8152 *tp; ++ __le16 *d; ++ int status = urb->status; ++ int res; ++ ++ tp = urb->context; ++ if (!tp) ++ return; ++ ++ if (!test_bit(WORK_ENABLE, &tp->flags)) ++ return; ++ ++ if (test_bit(RTL8152_UNPLUG, &tp->flags)) ++ return; ++ ++ switch (status) { ++ case 0: /* success */ ++ break; ++ case -ECONNRESET: /* unlink */ ++ case -ESHUTDOWN: ++ netif_device_detach(tp->netdev); ++ case -ENOENT: ++ return; ++ case -EOVERFLOW: ++ netif_info(tp, intr, tp->netdev, "intr status -EOVERFLOW\n"); ++ goto resubmit; ++ /* -EPIPE: should clear the halt */ ++ default: ++ netif_info(tp, intr, tp->netdev, "intr status %d\n", status); ++ goto resubmit; ++ } ++ ++ d = urb->transfer_buffer; ++ if (INTR_LINK & __le16_to_cpu(d[0])) { ++ if (!(tp->speed & LINK_STATUS)) { ++ set_bit(RTL8152_LINK_CHG, &tp->flags); ++ schedule_delayed_work(&tp->schedule, 0); ++ } ++ } else { ++ if (tp->speed & LINK_STATUS) { ++ set_bit(RTL8152_LINK_CHG, &tp->flags); ++ schedule_delayed_work(&tp->schedule, 0); ++ } ++ } ++ ++resubmit: ++ res = usb_submit_urb(urb, GFP_ATOMIC); ++ if (res == -ENODEV) ++ netif_device_detach(tp->netdev); ++ else if (res) ++ netif_err(tp, intr, tp->netdev, ++ "can't resubmit intr, status %d\n", res); ++} ++ ++static inline void *rx_agg_align(void *data) ++{ ++ return (void *)ALIGN((uintptr_t)data, RX_ALIGN); ++} ++ ++static inline void *tx_agg_align(void *data) ++{ ++ return (void *)ALIGN((uintptr_t)data, TX_ALIGN); ++} ++ ++static void free_all_mem(struct r8152 *tp) ++{ ++ int i; ++ ++ for (i = 0; i < RTL8152_MAX_RX; i++) { ++ usb_free_urb(tp->rx_info[i].urb); ++ tp->rx_info[i].urb = NULL; ++ ++ kfree(tp->rx_info[i].buffer); ++ tp->rx_info[i].buffer = NULL; ++ tp->rx_info[i].head = NULL; ++ } ++ ++ for (i = 0; i < RTL8152_MAX_TX; i++) { ++ usb_free_urb(tp->tx_info[i].urb); ++ tp->tx_info[i].urb = NULL; ++ ++ kfree(tp->tx_info[i].buffer); ++ tp->tx_info[i].buffer = NULL; ++ tp->tx_info[i].head = NULL; ++ } ++ ++ usb_free_urb(tp->intr_urb); ++ tp->intr_urb = NULL; ++ ++ kfree(tp->intr_buff); ++ tp->intr_buff = NULL; ++} ++ ++static int alloc_all_mem(struct r8152 *tp) ++{ ++ struct net_device *netdev = tp->netdev; ++ struct usb_interface *intf = tp->intf; ++ struct usb_host_interface *alt = intf->cur_altsetting; ++ struct usb_host_endpoint *ep_intr = alt->endpoint + 2; ++ struct urb *urb; ++ int node, i; ++ u8 *buf; ++ ++ node = netdev->dev.parent ? dev_to_node(netdev->dev.parent) : -1; ++ ++ spin_lock_init(&tp->rx_lock); ++ spin_lock_init(&tp->tx_lock); ++ INIT_LIST_HEAD(&tp->rx_done); ++ INIT_LIST_HEAD(&tp->tx_free); ++ skb_queue_head_init(&tp->tx_queue); ++ ++ for (i = 0; i < RTL8152_MAX_RX; i++) { ++ buf = kmalloc_node(rx_buf_sz, GFP_KERNEL, node); ++ if (!buf) ++ goto err1; ++ ++ if (buf != rx_agg_align(buf)) { ++ kfree(buf); ++ buf = kmalloc_node(rx_buf_sz + RX_ALIGN, GFP_KERNEL, ++ node); ++ if (!buf) ++ goto err1; ++ } ++ ++ urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!urb) { ++ kfree(buf); ++ goto err1; ++ } ++ ++ INIT_LIST_HEAD(&tp->rx_info[i].list); ++ tp->rx_info[i].context = tp; ++ tp->rx_info[i].urb = urb; ++ tp->rx_info[i].buffer = buf; ++ tp->rx_info[i].head = rx_agg_align(buf); ++ } ++ ++ for (i = 0; i < RTL8152_MAX_TX; i++) { ++ buf = kmalloc_node(rx_buf_sz, GFP_KERNEL, node); ++ if (!buf) ++ goto err1; ++ ++ if (buf != tx_agg_align(buf)) { ++ kfree(buf); ++ buf = kmalloc_node(rx_buf_sz + TX_ALIGN, GFP_KERNEL, ++ node); ++ if (!buf) ++ goto err1; ++ } ++ ++ urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!urb) { ++ kfree(buf); ++ goto err1; ++ } ++ ++ INIT_LIST_HEAD(&tp->tx_info[i].list); ++ tp->tx_info[i].context = tp; ++ tp->tx_info[i].urb = urb; ++ tp->tx_info[i].buffer = buf; ++ tp->tx_info[i].head = tx_agg_align(buf); ++ ++ list_add_tail(&tp->tx_info[i].list, &tp->tx_free); ++ } ++ ++ tp->intr_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!tp->intr_urb) ++ goto err1; ++ ++ tp->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL); ++ if (!tp->intr_buff) ++ goto err1; ++ ++ tp->intr_interval = (int)ep_intr->desc.bInterval; ++ usb_fill_int_urb(tp->intr_urb, tp->udev, usb_rcvintpipe(tp->udev, 3), ++ tp->intr_buff, INTBUFSIZE, intr_callback, ++ tp, tp->intr_interval); ++ ++ return 0; ++ ++err1: ++ free_all_mem(tp); ++ return -ENOMEM; ++} ++ ++static struct tx_agg *r8152_get_tx_agg(struct r8152 *tp) ++{ ++ struct tx_agg *agg = NULL; ++ unsigned long flags; ++ ++ spin_lock_irqsave(&tp->tx_lock, flags); ++ if (!list_empty(&tp->tx_free)) { ++ struct list_head *cursor; ++ ++ cursor = tp->tx_free.next; ++ list_del_init(cursor); ++ agg = list_entry(cursor, struct tx_agg, list); ++ } ++ spin_unlock_irqrestore(&tp->tx_lock, flags); ++ ++ return agg; ++} ++ ++static void ++r8152_tx_csum(struct r8152 *tp, struct tx_desc *desc, struct sk_buff *skb) ++{ ++ memset(desc, 0, sizeof(*desc)); ++ ++ desc->opts1 = cpu_to_le32((skb->len & TX_LEN_MASK) | TX_FS | TX_LS); ++ ++ if (skb->ip_summed == CHECKSUM_PARTIAL) { ++ __be16 protocol; ++ u8 ip_protocol; ++ u32 opts2 = 0; ++ ++ if (skb->protocol == htons(ETH_P_8021Q)) ++ protocol = vlan_eth_hdr(skb)->h_vlan_encapsulated_proto; ++ else ++ protocol = skb->protocol; ++ ++ switch (protocol) { ++ case htons(ETH_P_IP): ++ opts2 |= IPV4_CS; ++ ip_protocol = ip_hdr(skb)->protocol; ++ break; ++ ++ case htons(ETH_P_IPV6): ++ opts2 |= IPV6_CS; ++ ip_protocol = ipv6_hdr(skb)->nexthdr; ++ break; ++ ++ default: ++ ip_protocol = IPPROTO_RAW; ++ break; ++ } ++ ++ if (ip_protocol == IPPROTO_TCP) { ++ opts2 |= TCP_CS; ++ opts2 |= (skb_transport_offset(skb) & 0x7fff) << 17; ++ } else if (ip_protocol == IPPROTO_UDP) { ++ opts2 |= UDP_CS; ++ } else { ++ WARN_ON_ONCE(1); ++ } ++ ++ desc->opts2 = cpu_to_le32(opts2); ++ } ++} ++ ++static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg) ++{ ++ int remain; ++ u8 *tx_data; ++ ++ tx_data = agg->head; ++ agg->skb_num = agg->skb_len = 0; ++ remain = rx_buf_sz; ++ ++ while (remain >= ETH_ZLEN + sizeof(struct tx_desc)) { ++ struct tx_desc *tx_desc; ++ struct sk_buff *skb; ++ unsigned int len; ++ ++ skb = skb_dequeue(&tp->tx_queue); ++ if (!skb) ++ break; ++ ++ remain -= sizeof(*tx_desc); ++ len = skb->len; ++ if (remain < len) { ++ skb_queue_head(&tp->tx_queue, skb); ++ break; ++ } ++ ++ tx_data = tx_agg_align(tx_data); ++ tx_desc = (struct tx_desc *)tx_data; ++ tx_data += sizeof(*tx_desc); ++ ++ r8152_tx_csum(tp, tx_desc, skb); ++ memcpy(tx_data, skb->data, len); ++ agg->skb_num++; ++ agg->skb_len += len; ++ dev_kfree_skb_any(skb); ++ ++ tx_data += len; ++ remain = rx_buf_sz - (int)(tx_agg_align(tx_data) - agg->head); ++ } ++ ++ netif_tx_lock(tp->netdev); ++ ++ if (netif_queue_stopped(tp->netdev) && ++ skb_queue_len(&tp->tx_queue) < tp->tx_qlen) ++ netif_wake_queue(tp->netdev); ++ ++ netif_tx_unlock(tp->netdev); ++ ++ usb_fill_bulk_urb(agg->urb, tp->udev, usb_sndbulkpipe(tp->udev, 2), ++ agg->head, (int)(tx_data - (u8 *)agg->head), ++ (usb_complete_t)write_bulk_callback, agg); ++ ++ return usb_submit_urb(agg->urb, GFP_ATOMIC); ++} ++ ++static void rx_bottom(struct r8152 *tp) ++{ ++ unsigned long flags; ++ struct list_head *cursor, *next; ++ ++ spin_lock_irqsave(&tp->rx_lock, flags); ++ list_for_each_safe(cursor, next, &tp->rx_done) { ++ struct rx_desc *rx_desc; ++ struct rx_agg *agg; ++ int len_used = 0; ++ struct urb *urb; ++ u8 *rx_data; ++ int ret; ++ ++ list_del_init(cursor); ++ spin_unlock_irqrestore(&tp->rx_lock, flags); ++ ++ agg = list_entry(cursor, struct rx_agg, list); ++ urb = agg->urb; ++ if (urb->actual_length < ETH_ZLEN) ++ goto submit; ++ ++ rx_desc = agg->head; ++ rx_data = agg->head; ++ len_used += sizeof(struct rx_desc); ++ ++ while (urb->actual_length > len_used) { ++ struct net_device *netdev = tp->netdev; ++ struct net_device_stats *stats; ++ unsigned int pkt_len; ++ struct sk_buff *skb; ++ ++ pkt_len = le32_to_cpu(rx_desc->opts1) & RX_LEN_MASK; ++ if (pkt_len < ETH_ZLEN) ++ break; ++ ++ len_used += pkt_len; ++ if (urb->actual_length < len_used) ++ break; ++ ++ stats = rtl8152_get_stats(netdev); ++ ++ pkt_len -= CRC_SIZE; ++ rx_data += sizeof(struct rx_desc); ++ ++ skb = netdev_alloc_skb_ip_align(netdev, pkt_len); ++ if (!skb) { ++ stats->rx_dropped++; ++ break; ++ } ++ memcpy(skb->data, rx_data, pkt_len); ++ skb_put(skb, pkt_len); ++ skb->protocol = eth_type_trans(skb, netdev); ++ netif_rx(skb); ++ stats->rx_packets++; ++ stats->rx_bytes += pkt_len; ++ ++ rx_data = rx_agg_align(rx_data + pkt_len + CRC_SIZE); ++ rx_desc = (struct rx_desc *)rx_data; ++ len_used = (int)(rx_data - (u8 *)agg->head); ++ len_used += sizeof(struct rx_desc); ++ } ++ ++submit: ++ ret = r8152_submit_rx(tp, agg, GFP_ATOMIC); ++ spin_lock_irqsave(&tp->rx_lock, flags); ++ if (ret && ret != -ENODEV) { ++ list_add_tail(&agg->list, next); ++ tasklet_schedule(&tp->tl); ++ } ++ } ++ spin_unlock_irqrestore(&tp->rx_lock, flags); ++} ++ ++static void tx_bottom(struct r8152 *tp) ++{ ++ int res; ++ ++ do { ++ struct tx_agg *agg; ++ ++ if (skb_queue_empty(&tp->tx_queue)) ++ break; ++ ++ agg = r8152_get_tx_agg(tp); ++ if (!agg) ++ break; ++ ++ res = r8152_tx_agg_fill(tp, agg); ++ if (res) { ++ struct net_device_stats *stats; ++ struct net_device *netdev; ++ unsigned long flags; ++ ++ netdev = tp->netdev; ++ stats = rtl8152_get_stats(netdev); ++ ++ if (res == -ENODEV) { ++ netif_device_detach(netdev); ++ } else { ++ netif_warn(tp, tx_err, netdev, ++ "failed tx_urb %d\n", res); ++ stats->tx_dropped += agg->skb_num; ++ spin_lock_irqsave(&tp->tx_lock, flags); ++ list_add_tail(&agg->list, &tp->tx_free); ++ spin_unlock_irqrestore(&tp->tx_lock, flags); ++ } ++ } ++ } while (res == 0); ++} ++ ++static void bottom_half(unsigned long data) ++{ ++ struct r8152 *tp; ++ ++ tp = (struct r8152 *)data; ++ ++ if (test_bit(RTL8152_UNPLUG, &tp->flags)) ++ return; ++ ++ if (!test_bit(WORK_ENABLE, &tp->flags)) ++ return; ++ ++ /* When link down, the driver would cancel all bulks. */ ++ /* This avoid the re-submitting bulk */ ++ if (!netif_carrier_ok(tp->netdev)) ++ return; ++ ++ rx_bottom(tp); ++ tx_bottom(tp); ++} ++ ++static ++int r8152_submit_rx(struct r8152 *tp, struct rx_agg *agg, gfp_t mem_flags) ++{ ++ usb_fill_bulk_urb(agg->urb, tp->udev, usb_rcvbulkpipe(tp->udev, 1), ++ agg->head, rx_buf_sz, ++ (usb_complete_t)read_bulk_callback, agg); ++ ++ return usb_submit_urb(agg->urb, mem_flags); ++} ++ ++static void rtl8152_tx_timeout(struct net_device *netdev) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ int i; ++ ++ netif_warn(tp, tx_err, netdev, "Tx timeout\n"); ++ for (i = 0; i < RTL8152_MAX_TX; i++) ++ usb_unlink_urb(tp->tx_info[i].urb); ++} ++ ++static void rtl8152_set_rx_mode(struct net_device *netdev) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ ++ if (tp->speed & LINK_STATUS) { ++ set_bit(RTL8152_SET_RX_MODE, &tp->flags); ++ schedule_delayed_work(&tp->schedule, 0); ++ } ++} ++ ++static void _rtl8152_set_rx_mode(struct net_device *netdev) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ u32 mc_filter[2]; /* Multicast hash filter */ ++ __le32 tmp[2]; ++ u32 ocp_data; ++ ++ clear_bit(RTL8152_SET_RX_MODE, &tp->flags); ++ netif_stop_queue(netdev); ++ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ++ ocp_data &= ~RCR_ACPT_ALL; ++ ocp_data |= RCR_AB | RCR_APM; ++ ++ if (netdev->flags & IFF_PROMISC) { ++ /* Unconditionally log net taps. */ ++ netif_notice(tp, link, netdev, "Promiscuous mode enabled\n"); ++ ocp_data |= RCR_AM | RCR_AAP; ++ mc_filter[1] = mc_filter[0] = 0xffffffff; ++ } else if ((netdev_mc_count(netdev) > multicast_filter_limit) || ++ (netdev->flags & IFF_ALLMULTI)) { ++ /* Too many to filter perfectly -- accept all multicasts. */ ++ ocp_data |= RCR_AM; ++ mc_filter[1] = mc_filter[0] = 0xffffffff; ++ } else { ++ struct netdev_hw_addr *ha; ++ ++ mc_filter[1] = mc_filter[0] = 0; ++ netdev_for_each_mc_addr(ha, netdev) { ++ int bit_nr = ether_crc(ETH_ALEN, ha->addr) >> 26; ++ mc_filter[bit_nr >> 5] |= 1 << (bit_nr & 31); ++ ocp_data |= RCR_AM; ++ } ++ } ++ ++ tmp[0] = __cpu_to_le32(swab32(mc_filter[1])); ++ tmp[1] = __cpu_to_le32(swab32(mc_filter[0])); ++ ++ pla_ocp_write(tp, PLA_MAR, BYTE_EN_DWORD, sizeof(tmp), tmp); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); ++ netif_wake_queue(netdev); ++} ++ ++static netdev_tx_t rtl8152_start_xmit(struct sk_buff *skb, ++ struct net_device *netdev) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ ++ skb_tx_timestamp(skb); ++ ++ skb_queue_tail(&tp->tx_queue, skb); ++ ++ if (list_empty(&tp->tx_free) && ++ skb_queue_len(&tp->tx_queue) > tp->tx_qlen) ++ netif_stop_queue(netdev); ++ ++ if (!list_empty(&tp->tx_free)) ++ tasklet_schedule(&tp->tl); ++ ++ return NETDEV_TX_OK; ++} ++ ++static void r8152b_reset_packet_filter(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_FMC); ++ ocp_data &= ~FMC_FCR_MCU_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_FMC, ocp_data); ++ ocp_data |= FMC_FCR_MCU_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_FMC, ocp_data); ++} ++ ++static void rtl8152_nic_reset(struct r8152 *tp) ++{ ++ int i; ++ ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, CR_RST); ++ ++ for (i = 0; i < 1000; i++) { ++ if (!(ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CR) & CR_RST)) ++ break; ++ udelay(100); ++ } ++} ++ ++static void set_tx_qlen(struct r8152 *tp) ++{ ++ struct net_device *netdev = tp->netdev; ++ ++ tp->tx_qlen = rx_buf_sz / (netdev->mtu + VLAN_ETH_HLEN + VLAN_HLEN + ++ sizeof(struct tx_desc)); ++} ++ ++static inline u8 rtl8152_get_speed(struct r8152 *tp) ++{ ++ return ocp_read_byte(tp, MCU_TYPE_PLA, PLA_PHYSTATUS); ++} ++ ++static void rtl_set_eee_plus(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ u8 speed; ++ ++ speed = rtl8152_get_speed(tp); ++ if (speed & _10bps) { ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR); ++ ocp_data |= EEEP_CR_EEEP_TX; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data); ++ } else { ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR); ++ ocp_data &= ~EEEP_CR_EEEP_TX; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEEP_CR, ocp_data); ++ } ++} ++ ++static int rtl_enable(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ int i, ret; ++ ++ r8152b_reset_packet_filter(tp); ++ ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CR); ++ ocp_data |= CR_RE | CR_TE; ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MISC_1); ++ ocp_data &= ~RXDY_GATED_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MISC_1, ocp_data); ++ ++ INIT_LIST_HEAD(&tp->rx_done); ++ ret = 0; ++ for (i = 0; i < RTL8152_MAX_RX; i++) { ++ INIT_LIST_HEAD(&tp->rx_info[i].list); ++ ret |= r8152_submit_rx(tp, &tp->rx_info[i], GFP_KERNEL); ++ } ++ ++ return ret; ++} ++ ++static int rtl8152_enable(struct r8152 *tp) ++{ ++ set_tx_qlen(tp); ++ rtl_set_eee_plus(tp); ++ ++ return rtl_enable(tp); ++} ++ ++static void r8153_set_rx_agg(struct r8152 *tp) ++{ ++ u8 speed; ++ ++ speed = rtl8152_get_speed(tp); ++ if (speed & _1000bps) { ++ if (tp->udev->speed == USB_SPEED_SUPER) { ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, ++ RX_THR_SUPPER); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_EARLY_AGG, ++ EARLY_AGG_SUPPER); ++ } else { ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, ++ RX_THR_HIGH); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_EARLY_AGG, ++ EARLY_AGG_HIGH); ++ } ++ } else { ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, RX_THR_SLOW); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_EARLY_AGG, ++ EARLY_AGG_SLOW); ++ } ++} ++ ++static int rtl8153_enable(struct r8152 *tp) ++{ ++ set_tx_qlen(tp); ++ rtl_set_eee_plus(tp); ++ r8153_set_rx_agg(tp); ++ ++ return rtl_enable(tp); ++} ++ ++static void rtl8152_disable(struct r8152 *tp) ++{ ++ struct net_device_stats *stats = rtl8152_get_stats(tp->netdev); ++ struct sk_buff *skb; ++ u32 ocp_data; ++ int i; ++ ++ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ++ ocp_data &= ~RCR_ACPT_ALL; ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); ++ ++ while ((skb = skb_dequeue(&tp->tx_queue))) { ++ dev_kfree_skb(skb); ++ stats->tx_dropped++; ++ } ++ ++ for (i = 0; i < RTL8152_MAX_TX; i++) ++ usb_kill_urb(tp->tx_info[i].urb); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MISC_1); ++ ocp_data |= RXDY_GATED_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MISC_1, ocp_data); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if ((ocp_data & FIFO_EMPTY) == FIFO_EMPTY) ++ break; ++ mdelay(1); ++ } ++ ++ for (i = 0; i < 1000; i++) { ++ if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0) & TCR0_TX_EMPTY) ++ break; ++ mdelay(1); ++ } ++ ++ for (i = 0; i < RTL8152_MAX_RX; i++) ++ usb_kill_urb(tp->rx_info[i].urb); ++ ++ rtl8152_nic_reset(tp); ++} ++ ++static void r8152b_exit_oob(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ int i; ++ ++ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ++ ocp_data &= ~RCR_ACPT_ALL; ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MISC_1); ++ ocp_data |= RXDY_GATED_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MISC_1, ocp_data); ++ ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CRWECR, CRWECR_NORAML); ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CR, 0x00); ++ ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ ocp_data &= ~NOW_IS_OOB; ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); ++ ocp_data &= ~MCU_BORW_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if (ocp_data & LINK_LIST_READY) ++ break; ++ mdelay(1); ++ } ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); ++ ocp_data |= RE_INIT_LL; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if (ocp_data & LINK_LIST_READY) ++ break; ++ mdelay(1); ++ } ++ ++ rtl8152_nic_reset(tp); ++ ++ /* rx share fifo credit full threshold */ ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_NORMAL); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_DEV_STAT); ++ ocp_data &= STAT_SPEED_MASK; ++ if (ocp_data == STAT_SPEED_FULL) { ++ /* rx share fifo credit near full threshold */ ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, ++ RXFIFO_THR2_FULL); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, ++ RXFIFO_THR3_FULL); ++ } else { ++ /* rx share fifo credit near full threshold */ ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, ++ RXFIFO_THR2_HIGH); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, ++ RXFIFO_THR3_HIGH); ++ } ++ ++ /* TX share fifo free credit full threshold */ ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TXFIFO_CTRL, TXFIFO_THR_NORMAL); ++ ++ ocp_write_byte(tp, MCU_TYPE_USB, USB_TX_AGG, TX_AGG_MAX_THRESHOLD); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_RX_BUF_TH, RX_THR_HIGH); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_TX_DMA, ++ TEST_MODE_DISABLE | TX_SIZE_ADJUST1); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CPCR); ++ ocp_data &= ~CPCR_RX_VLAN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CPCR, ocp_data); ++ ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8152_RMS); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0); ++ ocp_data |= TCR0_AUTO_FIFO; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_TCR0, ocp_data); ++} ++ ++static void r8152b_enter_oob(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ int i; ++ ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ ocp_data &= ~NOW_IS_OOB; ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); ++ ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_OOB); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_OOB); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_OOB); ++ ++ rtl8152_disable(tp); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if (ocp_data & LINK_LIST_READY) ++ break; ++ mdelay(1); ++ } ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); ++ ocp_data |= RE_INIT_LL; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if (ocp_data & LINK_LIST_READY) ++ break; ++ mdelay(1); ++ } ++ ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8152_RMS); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CFG_WOL); ++ ocp_data |= MAGIC_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CFG_WOL, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CPCR); ++ ocp_data |= CPCR_RX_VLAN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CPCR, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PAL_BDC_CR); ++ ocp_data |= ALDPS_PROXY_MODE; ++ ocp_write_word(tp, MCU_TYPE_PLA, PAL_BDC_CR, ocp_data); ++ ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB; ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); ++ ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CONFIG5, LAN_WAKE_EN); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MISC_1); ++ ocp_data &= ~RXDY_GATED_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MISC_1, ocp_data); ++ ++ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ++ ocp_data |= RCR_APM | RCR_AM | RCR_AB; ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); ++} ++ ++static void r8152b_disable_aldps(struct r8152 *tp) ++{ ++ ocp_reg_write(tp, OCP_ALDPS_CONFIG, ENPDNPS | LINKENA | DIS_SDSAVE); ++ msleep(20); ++} ++ ++static inline void r8152b_enable_aldps(struct r8152 *tp) ++{ ++ ocp_reg_write(tp, OCP_ALDPS_CONFIG, ENPWRSAVE | ENPDNPS | ++ LINKENA | DIS_SDSAVE); ++} ++ ++static void r8153_hw_phy_cfg(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ u16 data; ++ ++ ocp_reg_write(tp, OCP_ADC_CFG, CKADSEL_L | ADC_EN | EN_EMI_L); ++ r8152_mdio_write(tp, MII_BMCR, BMCR_ANENABLE); ++ ++ if (tp->version == RTL_VER_03) { ++ data = ocp_reg_read(tp, OCP_EEE_CFG); ++ data &= ~CTAP_SHORT_EN; ++ ocp_reg_write(tp, OCP_EEE_CFG, data); ++ } ++ ++ data = ocp_reg_read(tp, OCP_POWER_CFG); ++ data |= EEE_CLKDIV_EN; ++ ocp_reg_write(tp, OCP_POWER_CFG, data); ++ ++ data = ocp_reg_read(tp, OCP_DOWN_SPEED); ++ data |= EN_10M_BGOFF; ++ ocp_reg_write(tp, OCP_DOWN_SPEED, data); ++ data = ocp_reg_read(tp, OCP_POWER_CFG); ++ data |= EN_10M_PLLOFF; ++ ocp_reg_write(tp, OCP_POWER_CFG, data); ++ data = sram_read(tp, SRAM_IMPEDANCE); ++ data &= ~RX_DRIVING_MASK; ++ sram_write(tp, SRAM_IMPEDANCE, data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR); ++ ocp_data |= PFM_PWM_SWITCH; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR, ocp_data); ++ ++ data = sram_read(tp, SRAM_LPF_CFG); ++ data |= LPF_AUTO_TUNE; ++ sram_write(tp, SRAM_LPF_CFG, data); ++ ++ data = sram_read(tp, SRAM_10M_AMP1); ++ data |= GDAC_IB_UPALL; ++ sram_write(tp, SRAM_10M_AMP1, data); ++ data = sram_read(tp, SRAM_10M_AMP2); ++ data |= AMP_DN; ++ sram_write(tp, SRAM_10M_AMP2, data); ++} ++ ++static void r8153_u1u2en(struct r8152 *tp, int enable) ++{ ++ u8 u1u2[8]; ++ ++ if (enable) ++ memset(u1u2, 0xff, sizeof(u1u2)); ++ else ++ memset(u1u2, 0x00, sizeof(u1u2)); ++ ++ usb_ocp_write(tp, USB_TOLERANCE, BYTE_EN_SIX_BYTES, sizeof(u1u2), u1u2); ++} ++ ++static void r8153_u2p3en(struct r8152 *tp, int enable) ++{ ++ u32 ocp_data; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL); ++ if (enable) ++ ocp_data |= U2P3_ENABLE; ++ else ++ ocp_data &= ~U2P3_ENABLE; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_U2P3_CTRL, ocp_data); ++} ++ ++static void r8153_power_cut_en(struct r8152 *tp, int enable) ++{ ++ u32 ocp_data; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_POWER_CUT); ++ if (enable) ++ ocp_data |= PWR_EN | PHASE2_EN; ++ else ++ ocp_data &= ~(PWR_EN | PHASE2_EN); ++ ocp_write_word(tp, MCU_TYPE_USB, USB_POWER_CUT, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_MISC_0); ++ ocp_data &= ~PCUT_STATUS; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_MISC_0, ocp_data); ++} ++ ++static void r8153_teredo_off(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG); ++ ocp_data &= ~(TEREDO_SEL | TEREDO_RS_EVENT_MASK | OOB_TEREDO_EN); ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG, ocp_data); ++ ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_WDT6_CTRL, WDT6_SET_MODE); ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_REALWOW_TIMER, 0); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TEREDO_TIMER, 0); ++} ++ ++static void r8153_first_init(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ int i; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MISC_1); ++ ocp_data |= RXDY_GATED_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MISC_1, ocp_data); ++ ++ r8153_teredo_off(tp); ++ ++ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ++ ocp_data &= ~RCR_ACPT_ALL; ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); ++ ++ r8153_hw_phy_cfg(tp); ++ ++ rtl8152_nic_reset(tp); ++ ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ ocp_data &= ~NOW_IS_OOB; ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); ++ ocp_data &= ~MCU_BORW_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if (ocp_data & LINK_LIST_READY) ++ break; ++ mdelay(1); ++ } ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); ++ ocp_data |= RE_INIT_LL; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if (ocp_data & LINK_LIST_READY) ++ break; ++ mdelay(1); ++ } ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CPCR); ++ ocp_data &= ~CPCR_RX_VLAN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CPCR, ocp_data); ++ ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8152_RMS); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR0); ++ ocp_data |= TCR0_AUTO_FIFO; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_TCR0, ocp_data); ++ ++ rtl8152_nic_reset(tp); ++ ++ /* rx share fifo credit full threshold */ ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_NORMAL); ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, RXFIFO_THR2_NORMAL); ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL2, RXFIFO_THR3_NORMAL); ++ /* TX share fifo free credit full threshold */ ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_TXFIFO_CTRL, TXFIFO_THR_NORMAL2); ++ ++ /* rx aggregation */ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL); ++ ocp_data &= ~RX_AGG_DISABLE; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data); ++} ++ ++static void r8153_enter_oob(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ int i; ++ ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ ocp_data &= ~NOW_IS_OOB; ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); ++ ++ rtl8152_disable(tp); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if (ocp_data & LINK_LIST_READY) ++ break; ++ mdelay(1); ++ } ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7); ++ ocp_data |= RE_INIT_LL; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_SFF_STS_7, ocp_data); ++ ++ for (i = 0; i < 1000; i++) { ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ if (ocp_data & LINK_LIST_READY) ++ break; ++ mdelay(1); ++ } ++ ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_RMS, RTL8152_RMS); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CFG_WOL); ++ ocp_data |= MAGIC_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CFG_WOL, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG); ++ ocp_data &= ~TEREDO_WAKE_MASK; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_TEREDO_CFG, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_CPCR); ++ ocp_data |= CPCR_RX_VLAN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_CPCR, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PAL_BDC_CR); ++ ocp_data |= ALDPS_PROXY_MODE; ++ ocp_write_word(tp, MCU_TYPE_PLA, PAL_BDC_CR, ocp_data); ++ ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); ++ ocp_data |= NOW_IS_OOB | DIS_MCU_CLROOB; ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); ++ ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_CONFIG5, LAN_WAKE_EN); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_MISC_1); ++ ocp_data &= ~RXDY_GATED_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MISC_1, ocp_data); ++ ++ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_RCR); ++ ocp_data |= RCR_APM | RCR_AM | RCR_AB; ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RCR, ocp_data); ++} ++ ++static void r8153_disable_aldps(struct r8152 *tp) ++{ ++ u16 data; ++ ++ data = ocp_reg_read(tp, OCP_POWER_CFG); ++ data &= ~EN_ALDPS; ++ ocp_reg_write(tp, OCP_POWER_CFG, data); ++ msleep(20); ++} ++ ++static void r8153_enable_aldps(struct r8152 *tp) ++{ ++ u16 data; ++ ++ data = ocp_reg_read(tp, OCP_POWER_CFG); ++ data |= EN_ALDPS; ++ ocp_reg_write(tp, OCP_POWER_CFG, data); ++} ++ ++static int rtl8152_set_speed(struct r8152 *tp, u8 autoneg, u16 speed, u8 duplex) ++{ ++ u16 bmcr, anar, gbcr; ++ int ret = 0; ++ ++ cancel_delayed_work_sync(&tp->schedule); ++ anar = r8152_mdio_read(tp, MII_ADVERTISE); ++ anar &= ~(ADVERTISE_10HALF | ADVERTISE_10FULL | ++ ADVERTISE_100HALF | ADVERTISE_100FULL); ++ if (tp->mii.supports_gmii) { ++ gbcr = r8152_mdio_read(tp, MII_CTRL1000); ++ gbcr &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF); ++ } else { ++ gbcr = 0; ++ } ++ ++ if (autoneg == AUTONEG_DISABLE) { ++ if (speed == SPEED_10) { ++ bmcr = 0; ++ anar |= ADVERTISE_10HALF | ADVERTISE_10FULL; ++ } else if (speed == SPEED_100) { ++ bmcr = BMCR_SPEED100; ++ anar |= ADVERTISE_100HALF | ADVERTISE_100FULL; ++ } else if (speed == SPEED_1000 && tp->mii.supports_gmii) { ++ bmcr = BMCR_SPEED1000; ++ gbcr |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; ++ } else { ++ ret = -EINVAL; ++ goto out; ++ } ++ ++ if (duplex == DUPLEX_FULL) ++ bmcr |= BMCR_FULLDPLX; ++ } else { ++ if (speed == SPEED_10) { ++ if (duplex == DUPLEX_FULL) ++ anar |= ADVERTISE_10HALF | ADVERTISE_10FULL; ++ else ++ anar |= ADVERTISE_10HALF; ++ } else if (speed == SPEED_100) { ++ if (duplex == DUPLEX_FULL) { ++ anar |= ADVERTISE_10HALF | ADVERTISE_10FULL; ++ anar |= ADVERTISE_100HALF | ADVERTISE_100FULL; ++ } else { ++ anar |= ADVERTISE_10HALF; ++ anar |= ADVERTISE_100HALF; ++ } ++ } else if (speed == SPEED_1000 && tp->mii.supports_gmii) { ++ if (duplex == DUPLEX_FULL) { ++ anar |= ADVERTISE_10HALF | ADVERTISE_10FULL; ++ anar |= ADVERTISE_100HALF | ADVERTISE_100FULL; ++ gbcr |= ADVERTISE_1000FULL | ADVERTISE_1000HALF; ++ } else { ++ anar |= ADVERTISE_10HALF; ++ anar |= ADVERTISE_100HALF; ++ gbcr |= ADVERTISE_1000HALF; ++ } ++ } else { ++ ret = -EINVAL; ++ goto out; ++ } ++ ++ bmcr = BMCR_ANENABLE | BMCR_ANRESTART; ++ } ++ ++ if (tp->mii.supports_gmii) ++ r8152_mdio_write(tp, MII_CTRL1000, gbcr); ++ ++ r8152_mdio_write(tp, MII_ADVERTISE, anar); ++ r8152_mdio_write(tp, MII_BMCR, bmcr); ++ ++out: ++ ++ return ret; ++} ++ ++static void rtl8152_down(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_UPS_CTRL); ++ ocp_data &= ~POWER_CUT; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_UPS_CTRL, ocp_data); ++ ++ r8152b_disable_aldps(tp); ++ r8152b_enter_oob(tp); ++ r8152b_enable_aldps(tp); ++} ++ ++static void rtl8153_down(struct r8152 *tp) ++{ ++ r8153_u1u2en(tp, 0); ++ r8153_power_cut_en(tp, 0); ++ r8153_disable_aldps(tp); ++ r8153_enter_oob(tp); ++ r8153_enable_aldps(tp); ++} ++ ++static void set_carrier(struct r8152 *tp) ++{ ++ struct net_device *netdev = tp->netdev; ++ u8 speed; ++ ++ clear_bit(RTL8152_LINK_CHG, &tp->flags); ++ speed = rtl8152_get_speed(tp); ++ ++ if (speed & LINK_STATUS) { ++ if (!(tp->speed & LINK_STATUS)) { ++ tp->rtl_ops.enable(tp); ++ set_bit(RTL8152_SET_RX_MODE, &tp->flags); ++ netif_carrier_on(netdev); ++ } ++ } else { ++ if (tp->speed & LINK_STATUS) { ++ netif_carrier_off(netdev); ++ tasklet_disable(&tp->tl); ++ tp->rtl_ops.disable(tp); ++ tasklet_enable(&tp->tl); ++ } ++ } ++ tp->speed = speed; ++} ++ ++static void rtl_work_func_t(struct work_struct *work) ++{ ++ struct r8152 *tp = container_of(work, struct r8152, schedule.work); ++ ++ if (!test_bit(WORK_ENABLE, &tp->flags)) ++ goto out1; ++ ++ if (test_bit(RTL8152_UNPLUG, &tp->flags)) ++ goto out1; ++ ++ if (test_bit(RTL8152_LINK_CHG, &tp->flags)) ++ set_carrier(tp); ++ ++ if (test_bit(RTL8152_SET_RX_MODE, &tp->flags)) ++ _rtl8152_set_rx_mode(tp->netdev); ++ ++out1: ++ return; ++} ++ ++static int rtl8152_open(struct net_device *netdev) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ int res = 0; ++ ++ rtl8152_set_speed(tp, AUTONEG_ENABLE, ++ tp->mii.supports_gmii ? SPEED_1000 : SPEED_100, ++ DUPLEX_FULL); ++ tp->speed = 0; ++ netif_carrier_off(netdev); ++ netif_start_queue(netdev); ++ set_bit(WORK_ENABLE, &tp->flags); ++ res = usb_submit_urb(tp->intr_urb, GFP_KERNEL); ++ if (res) { ++ if (res == -ENODEV) ++ netif_device_detach(tp->netdev); ++ netif_warn(tp, ifup, netdev, "intr_urb submit failed: %d\n", ++ res); ++ } ++ ++ ++ return res; ++} ++ ++static int rtl8152_close(struct net_device *netdev) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ int res = 0; ++ ++ clear_bit(WORK_ENABLE, &tp->flags); ++ usb_kill_urb(tp->intr_urb); ++ cancel_delayed_work_sync(&tp->schedule); ++ netif_stop_queue(netdev); ++ tasklet_disable(&tp->tl); ++ tp->rtl_ops.disable(tp); ++ tasklet_enable(&tp->tl); ++ ++ return res; ++} ++ ++static void rtl_clear_bp(struct r8152 *tp) ++{ ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_0, 0); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_2, 0); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_4, 0); ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_BP_6, 0); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_0, 0); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_2, 0); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_4, 0); ++ ocp_write_dword(tp, MCU_TYPE_USB, USB_BP_6, 0); ++ mdelay(3); ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_BP_BA, 0); ++ ocp_write_word(tp, MCU_TYPE_USB, USB_BP_BA, 0); ++} ++ ++static void r8153_clear_bp(struct r8152 *tp) ++{ ++ ocp_write_byte(tp, MCU_TYPE_PLA, PLA_BP_EN, 0); ++ ocp_write_byte(tp, MCU_TYPE_USB, USB_BP_EN, 0); ++ rtl_clear_bp(tp); ++} ++ ++static void r8152b_enable_eee(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEE_CR); ++ ocp_data |= EEE_RX_EN | EEE_TX_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEE_CR, ocp_data); ++ ocp_reg_write(tp, OCP_EEE_CONFIG1, RG_TXLPI_MSK_HFDUP | RG_MATCLR_EN | ++ EEE_10_CAP | EEE_NWAY_EN | ++ TX_QUIET_EN | RX_QUIET_EN | ++ SDRISETIME | RG_RXLPI_MSK_HFDUP | ++ SDFALLTIME); ++ ocp_reg_write(tp, OCP_EEE_CONFIG2, RG_LPIHYS_NUM | RG_DACQUIET_EN | ++ RG_LDVQUIET_EN | RG_CKRSEL | ++ RG_EEEPRG_EN); ++ ocp_reg_write(tp, OCP_EEE_CONFIG3, FST_SNR_EYE_R | RG_LFS_SEL | MSK_PH); ++ ocp_reg_write(tp, OCP_EEE_AR, FUN_ADDR | DEVICE_ADDR); ++ ocp_reg_write(tp, OCP_EEE_DATA, EEE_ADDR); ++ ocp_reg_write(tp, OCP_EEE_AR, FUN_DATA | DEVICE_ADDR); ++ ocp_reg_write(tp, OCP_EEE_DATA, EEE_DATA); ++ ocp_reg_write(tp, OCP_EEE_AR, 0x0000); ++} ++ ++static void r8153_enable_eee(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ u16 data; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_EEE_CR); ++ ocp_data |= EEE_RX_EN | EEE_TX_EN; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_EEE_CR, ocp_data); ++ data = ocp_reg_read(tp, OCP_EEE_CFG); ++ data |= EEE10_EN; ++ ocp_reg_write(tp, OCP_EEE_CFG, data); ++ data = ocp_reg_read(tp, OCP_EEE_CFG2); ++ data |= MY1000_EEE | MY100_EEE; ++ ocp_reg_write(tp, OCP_EEE_CFG2, data); ++} ++ ++static void r8152b_enable_fc(struct r8152 *tp) ++{ ++ u16 anar; ++ ++ anar = r8152_mdio_read(tp, MII_ADVERTISE); ++ anar |= ADVERTISE_PAUSE_CAP | ADVERTISE_PAUSE_ASYM; ++ r8152_mdio_write(tp, MII_ADVERTISE, anar); ++} ++ ++static void r8152b_hw_phy_cfg(struct r8152 *tp) ++{ ++ r8152_mdio_write(tp, MII_BMCR, BMCR_ANENABLE); ++ r8152b_disable_aldps(tp); ++} ++ ++static void r8152b_init(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ int i; ++ ++ rtl_clear_bp(tp); ++ ++ if (tp->version == RTL_VER_01) { ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); ++ ocp_data &= ~LED_MODE_MASK; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE, ocp_data); ++ } ++ ++ r8152b_hw_phy_cfg(tp); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_UPS_CTRL); ++ ocp_data &= ~POWER_CUT; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_UPS_CTRL, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS); ++ ocp_data &= ~RESUME_INDICATE; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS, ocp_data); ++ ++ r8152b_exit_oob(tp); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR); ++ ocp_data |= TX_10M_IDLE_EN | PFM_PWM_SWITCH; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_PHY_PWR, ocp_data); ++ ocp_data = ocp_read_dword(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL); ++ ocp_data &= ~MCU_CLK_RATIO_MASK; ++ ocp_data |= MCU_CLK_RATIO | D3_CLK_GATED_EN; ++ ocp_write_dword(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, ocp_data); ++ ocp_data = GPHY_STS_MSK | SPEED_DOWN_MSK | ++ SPDWN_RXDV_MSK | SPDWN_LINKCHG_MSK; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_GPHY_INTR_IMR, ocp_data); ++ ++ r8152b_enable_eee(tp); ++ r8152b_enable_aldps(tp); ++ r8152b_enable_fc(tp); ++ ++ r8152_mdio_write(tp, MII_BMCR, BMCR_RESET | BMCR_ANENABLE | ++ BMCR_ANRESTART); ++ for (i = 0; i < 100; i++) { ++ udelay(100); ++ if (!(r8152_mdio_read(tp, MII_BMCR) & BMCR_RESET)) ++ break; ++ } ++ ++ /* enable rx aggregation */ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_USB_CTRL); ++ ocp_data &= ~RX_AGG_DISABLE; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_USB_CTRL, ocp_data); ++} ++ ++static void r8153_init(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ int i; ++ ++ r8153_u1u2en(tp, 0); ++ ++ for (i = 0; i < 500; i++) { ++ if (ocp_read_word(tp, MCU_TYPE_PLA, PLA_BOOT_CTRL) & ++ AUTOLOAD_DONE) ++ break; ++ msleep(20); ++ } ++ ++ for (i = 0; i < 500; i++) { ++ ocp_data = ocp_reg_read(tp, OCP_PHY_STATUS) & PHY_STAT_MASK; ++ if (ocp_data == PHY_STAT_LAN_ON || ocp_data == PHY_STAT_PWRDN) ++ break; ++ msleep(20); ++ } ++ ++ r8153_u2p3en(tp, 0); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_WDT11_CTRL); ++ ocp_data &= ~TIMER11_EN; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_WDT11_CTRL, ocp_data); ++ ++ r8153_clear_bp(tp); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE); ++ ocp_data &= ~LED_MODE_MASK; ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_LED_FEATURE, ocp_data); ++ ++ ocp_data = ocp_read_byte(tp, MCU_TYPE_USB, USB_LPM_CTRL); ++ ocp_data &= ~LPM_TIMER_MASK; ++ if (tp->udev->speed == USB_SPEED_SUPER) ++ ocp_data |= LPM_TIMER_500US; ++ else ++ ocp_data |= LPM_TIMER_500MS; ++ ocp_write_byte(tp, MCU_TYPE_USB, USB_LPM_CTRL, ocp_data); ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_AFE_CTRL2); ++ ocp_data &= ~SEN_VAL_MASK; ++ ocp_data |= SEN_VAL_NORMAL | SEL_RXIDLE; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_AFE_CTRL2, ocp_data); ++ ++ r8153_power_cut_en(tp, 0); ++ r8153_u1u2en(tp, 1); ++ ++ r8153_first_init(tp); ++ ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, ALDPS_SPDWN_RATIO); ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, EEE_SPDWN_RATIO); ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, ++ PKT_AVAIL_SPDWN_EN | SUSPEND_SPDWN_EN | ++ U1U2_SPDWN_EN | L1_SPDWN_EN); ++ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, ++ PWRSAVE_SPDWN_EN | RXDV_SPDWN_EN | TX10MIDLE_EN | ++ TP100_SPDWN_EN | TP500_SPDWN_EN | TP1000_SPDWN_EN | ++ EEE_SPDWN_EN); ++ ++ r8153_enable_eee(tp); ++ r8153_enable_aldps(tp); ++ r8152b_enable_fc(tp); ++ ++ r8152_mdio_write(tp, MII_BMCR, BMCR_RESET | BMCR_ANENABLE | ++ BMCR_ANRESTART); ++} ++ ++static int rtl8152_suspend(struct usb_interface *intf, pm_message_t message) ++{ ++ struct r8152 *tp = usb_get_intfdata(intf); ++ ++ netif_device_detach(tp->netdev); ++ ++ if (netif_running(tp->netdev)) { ++ clear_bit(WORK_ENABLE, &tp->flags); ++ usb_kill_urb(tp->intr_urb); ++ cancel_delayed_work_sync(&tp->schedule); ++ tasklet_disable(&tp->tl); ++ } ++ ++ tp->rtl_ops.down(tp); ++ ++ return 0; ++} ++ ++static int rtl8152_resume(struct usb_interface *intf) ++{ ++ struct r8152 *tp = usb_get_intfdata(intf); ++ ++ tp->rtl_ops.init(tp); ++ netif_device_attach(tp->netdev); ++ if (netif_running(tp->netdev)) { ++ rtl8152_set_speed(tp, AUTONEG_ENABLE, ++ tp->mii.supports_gmii ? SPEED_1000 : SPEED_100, ++ DUPLEX_FULL); ++ tp->speed = 0; ++ netif_carrier_off(tp->netdev); ++ set_bit(WORK_ENABLE, &tp->flags); ++ usb_submit_urb(tp->intr_urb, GFP_KERNEL); ++ tasklet_enable(&tp->tl); ++ } ++ ++ return 0; ++} ++ ++static void rtl8152_get_drvinfo(struct net_device *netdev, ++ struct ethtool_drvinfo *info) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ ++ strncpy(info->driver, MODULENAME, ETHTOOL_BUSINFO_LEN); ++ strncpy(info->version, DRIVER_VERSION, ETHTOOL_BUSINFO_LEN); ++ usb_make_path(tp->udev, info->bus_info, sizeof(info->bus_info)); ++} ++ ++static ++int rtl8152_get_settings(struct net_device *netdev, struct ethtool_cmd *cmd) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ ++ if (!tp->mii.mdio_read) ++ return -EOPNOTSUPP; ++ ++ return mii_ethtool_gset(&tp->mii, cmd); ++} ++ ++static int rtl8152_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) ++{ ++ struct r8152 *tp = netdev_priv(dev); ++ ++ return rtl8152_set_speed(tp, cmd->autoneg, cmd->speed, cmd->duplex); ++} ++ ++static struct ethtool_ops ops = { ++ .get_drvinfo = rtl8152_get_drvinfo, ++ .get_settings = rtl8152_get_settings, ++ .set_settings = rtl8152_set_settings, ++ .get_link = ethtool_op_get_link, ++}; ++ ++static int rtl8152_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) ++{ ++ struct r8152 *tp = netdev_priv(netdev); ++ struct mii_ioctl_data *data = if_mii(rq); ++ int res = 0; ++ ++ switch (cmd) { ++ case SIOCGMIIPHY: ++ data->phy_id = R8152_PHY_ID; /* Internal PHY */ ++ break; ++ ++ case SIOCGMIIREG: ++ data->val_out = r8152_mdio_read(tp, data->reg_num); ++ break; ++ ++ case SIOCSMIIREG: ++ if (!capable(CAP_NET_ADMIN)) { ++ res = -EPERM; ++ break; ++ } ++ r8152_mdio_write(tp, data->reg_num, data->val_in); ++ break; ++ ++ default: ++ res = -EOPNOTSUPP; ++ } ++ ++ return res; ++} ++ ++static const struct net_device_ops rtl8152_netdev_ops = { ++ .ndo_open = rtl8152_open, ++ .ndo_stop = rtl8152_close, ++ .ndo_do_ioctl = rtl8152_ioctl, ++ .ndo_start_xmit = rtl8152_start_xmit, ++ .ndo_tx_timeout = rtl8152_tx_timeout, ++ .ndo_set_rx_mode = rtl8152_set_rx_mode, ++ .ndo_set_mac_address = rtl8152_set_mac_address, ++ ++ .ndo_change_mtu = eth_change_mtu, ++ .ndo_validate_addr = eth_validate_addr, ++}; ++ ++static void r8152b_get_version(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ u16 version; ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_PLA, PLA_TCR1); ++ version = (u16)(ocp_data & VERSION_MASK); ++ ++ switch (version) { ++ case 0x4c00: ++ tp->version = RTL_VER_01; ++ break; ++ case 0x4c10: ++ tp->version = RTL_VER_02; ++ break; ++ case 0x5c00: ++ tp->version = RTL_VER_03; ++ tp->mii.supports_gmii = 1; ++ break; ++ case 0x5c10: ++ tp->version = RTL_VER_04; ++ tp->mii.supports_gmii = 1; ++ break; ++ case 0x5c20: ++ tp->version = RTL_VER_05; ++ tp->mii.supports_gmii = 1; ++ break; ++ default: ++ netif_info(tp, probe, tp->netdev, ++ "Unknown version 0x%04x\n", version); ++ break; ++ } ++} ++ ++static void rtl8152_unload(struct r8152 *tp) ++{ ++ u32 ocp_data; ++ ++ if (tp->version != RTL_VER_01) { ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_UPS_CTRL); ++ ocp_data |= POWER_CUT; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_UPS_CTRL, ocp_data); ++ } ++ ++ ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS); ++ ocp_data &= ~RESUME_INDICATE; ++ ocp_write_word(tp, MCU_TYPE_USB, USB_PM_CTRL_STATUS, ocp_data); ++} ++ ++static void rtl8153_unload(struct r8152 *tp) ++{ ++ r8153_power_cut_en(tp, 1); ++} ++ ++static int rtl_ops_init(struct r8152 *tp, const struct usb_device_id *id) ++{ ++ struct rtl_ops *ops = &tp->rtl_ops; ++ int ret = -ENODEV; ++ ++ switch (id->idVendor) { ++ case VENDOR_ID_REALTEK: ++ switch (id->idProduct) { ++ case PRODUCT_ID_RTL8152: ++ ops->init = r8152b_init; ++ ops->enable = rtl8152_enable; ++ ops->disable = rtl8152_disable; ++ ops->down = rtl8152_down; ++ ops->unload = rtl8152_unload; ++ ret = 0; ++ break; ++ case PRODUCT_ID_RTL8153: ++ ops->init = r8153_init; ++ ops->enable = rtl8153_enable; ++ ops->disable = rtl8152_disable; ++ ops->down = rtl8153_down; ++ ops->unload = rtl8153_unload; ++ ret = 0; ++ break; ++ default: ++ break; ++ } ++ break; ++ ++ case VENDOR_ID_SAMSUNG: ++ switch (id->idProduct) { ++ case PRODUCT_ID_SAMSUNG: ++ ops->init = r8153_init; ++ ops->enable = rtl8153_enable; ++ ops->disable = rtl8152_disable; ++ ops->down = rtl8153_down; ++ ops->unload = rtl8153_unload; ++ ret = 0; ++ break; ++ default: ++ break; ++ } ++ break; ++ ++ default: ++ break; ++ } ++ ++ if (ret) ++ netif_err(tp, probe, tp->netdev, "Unknown Device\n"); ++ ++ return ret; ++} ++ ++static int rtl8152_probe(struct usb_interface *intf, ++ const struct usb_device_id *id) ++{ ++ struct usb_device *udev = interface_to_usbdev(intf); ++ struct r8152 *tp; ++ struct net_device *netdev; ++ int ret; ++ ++ if (udev->actconfig->desc.bConfigurationValue != 1) { ++ usb_driver_set_configuration(udev, 1); ++ return -ENODEV; ++ } ++ ++ usb_reset_device(udev); ++ netdev = alloc_etherdev(sizeof(struct r8152)); ++ if (!netdev) { ++ dev_err(&intf->dev, "Out of memory\n"); ++ return -ENOMEM; ++ } ++ ++ SET_NETDEV_DEV(netdev, &intf->dev); ++ tp = netdev_priv(netdev); ++ tp->msg_enable = 0x7FFF; ++ ++ tp->udev = udev; ++ tp->netdev = netdev; ++ tp->intf = intf; ++ ++ ret = rtl_ops_init(tp, id); ++ if (ret) ++ goto out; ++ ++ tasklet_init(&tp->tl, bottom_half, (unsigned long)tp); ++ INIT_DELAYED_WORK(&tp->schedule, rtl_work_func_t); ++ ++ netdev->netdev_ops = &rtl8152_netdev_ops; ++ netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; ++ ++ netdev->features |= NETIF_F_IP_CSUM; ++ netdev->hw_features = NETIF_F_IP_CSUM; ++ SET_ETHTOOL_OPS(netdev, &ops); ++ ++ tp->mii.dev = netdev; ++ tp->mii.mdio_read = read_mii_word; ++ tp->mii.mdio_write = write_mii_word; ++ tp->mii.phy_id_mask = 0x3f; ++ tp->mii.reg_num_mask = 0x1f; ++ tp->mii.phy_id = R8152_PHY_ID; ++ tp->mii.supports_gmii = 0; ++ ++ r8152b_get_version(tp); ++ tp->rtl_ops.init(tp); ++ set_ethernet_addr(tp); ++ ++ ret = alloc_all_mem(tp); ++ if (ret) ++ goto out; ++ ++ usb_set_intfdata(intf, tp); ++ ++ ret = register_netdev(netdev); ++ if (ret != 0) { ++ netif_err(tp, probe, netdev, "couldn't register the device\n"); ++ goto out1; ++ } ++ ++ netif_info(tp, probe, netdev, "%s\n", DRIVER_VERSION); ++ ++ return 0; ++ ++out1: ++ usb_set_intfdata(intf, NULL); ++out: ++ free_netdev(netdev); ++ return ret; ++} ++ ++static void rtl8152_disconnect(struct usb_interface *intf) ++{ ++ struct r8152 *tp = usb_get_intfdata(intf); ++ ++ usb_set_intfdata(intf, NULL); ++ if (tp) { ++ set_bit(RTL8152_UNPLUG, &tp->flags); ++ tasklet_kill(&tp->tl); ++ unregister_netdev(tp->netdev); ++ tp->rtl_ops.unload(tp); ++ free_all_mem(tp); ++ free_netdev(tp->netdev); ++ } ++} ++ ++/* table of devices that work with this driver */ ++static struct usb_device_id rtl8152_table[] = { ++ {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8152)}, ++ {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8153)}, ++ {USB_DEVICE(VENDOR_ID_SAMSUNG, PRODUCT_ID_SAMSUNG)}, ++ {} ++}; ++ ++MODULE_DEVICE_TABLE(usb, rtl8152_table); ++ ++static struct usb_driver rtl8152_driver = { ++ .name = MODULENAME, ++ .id_table = rtl8152_table, ++ .probe = rtl8152_probe, ++ .disconnect = rtl8152_disconnect, ++ .suspend = rtl8152_suspend, ++ .resume = rtl8152_resume, ++ .reset_resume = rtl8152_resume, ++}; ++ ++module_usb_driver(rtl8152_driver); ++ ++MODULE_AUTHOR(DRIVER_AUTHOR); ++MODULE_DESCRIPTION(DRIVER_DESC); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/rtl8150.c backports-4.2.6-1/drivers/net/usb/rtl8150.c +--- backports-4.2.6-1.org/drivers/net/usb/rtl8150.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/rtl8150.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,949 @@ ++/* ++ * Copyright (c) 2002 Petko Manolov (petkan@users.sourceforge.net) ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation. ++ */ ++ ++#include <linux/signal.h> ++#include <linux/slab.h> ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/mii.h> ++#include <linux/ethtool.h> ++#include <linux/usb.h> ++#include <asm/uaccess.h> ++ ++/* Version Information */ ++#define DRIVER_VERSION "v0.6.2 (2004/08/27)" ++#define DRIVER_AUTHOR "Petko Manolov petkan@users.sourceforge.net" ++#define DRIVER_DESC "rtl8150 based usb-ethernet driver" ++ ++#define IDR 0x0120 ++#define MAR 0x0126 ++#define CR 0x012e ++#define TCR 0x012f ++#define RCR 0x0130 ++#define TSR 0x0132 ++#define RSR 0x0133 ++#define CON0 0x0135 ++#define CON1 0x0136 ++#define MSR 0x0137 ++#define PHYADD 0x0138 ++#define PHYDAT 0x0139 ++#define PHYCNT 0x013b ++#define GPPC 0x013d ++#define BMCR 0x0140 ++#define BMSR 0x0142 ++#define ANAR 0x0144 ++#define ANLP 0x0146 ++#define AER 0x0148 ++#define CSCR 0x014C /* This one has the link status */ ++#define CSCR_LINK_STATUS (1 << 3) ++ ++#define IDR_EEPROM 0x1202 ++ ++#define PHY_READ 0 ++#define PHY_WRITE 0x20 ++#define PHY_GO 0x40 ++ ++#define MII_TIMEOUT 10 ++#define INTBUFSIZE 8 ++ ++#define RTL8150_REQT_READ 0xc0 ++#define RTL8150_REQT_WRITE 0x40 ++#define RTL8150_REQ_GET_REGS 0x05 ++#define RTL8150_REQ_SET_REGS 0x05 ++ ++ ++/* Transmit status register errors */ ++#define TSR_ECOL (1<<5) ++#define TSR_LCOL (1<<4) ++#define TSR_LOSS_CRS (1<<3) ++#define TSR_JBR (1<<2) ++#define TSR_ERRORS (TSR_ECOL | TSR_LCOL | TSR_LOSS_CRS | TSR_JBR) ++/* Receive status register errors */ ++#define RSR_CRC (1<<2) ++#define RSR_FAE (1<<1) ++#define RSR_ERRORS (RSR_CRC | RSR_FAE) ++ ++/* Media status register definitions */ ++#define MSR_DUPLEX (1<<4) ++#define MSR_SPEED (1<<3) ++#define MSR_LINK (1<<2) ++ ++/* Interrupt pipe data */ ++#define INT_TSR 0x00 ++#define INT_RSR 0x01 ++#define INT_MSR 0x02 ++#define INT_WAKSR 0x03 ++#define INT_TXOK_CNT 0x04 ++#define INT_RXLOST_CNT 0x05 ++#define INT_CRERR_CNT 0x06 ++#define INT_COL_CNT 0x07 ++ ++ ++#define RTL8150_MTU 1540 ++#define RTL8150_TX_TIMEOUT (HZ) ++#define RX_SKB_POOL_SIZE 4 ++ ++/* rtl8150 flags */ ++#define RTL8150_HW_CRC 0 ++#define RX_REG_SET 1 ++#define RTL8150_UNPLUG 2 ++#define RX_URB_FAIL 3 ++ ++/* Define these values to match your device */ ++#define VENDOR_ID_REALTEK 0x0bda ++#define VENDOR_ID_MELCO 0x0411 ++#define VENDOR_ID_MICRONET 0x3980 ++#define VENDOR_ID_LONGSHINE 0x07b8 ++#define VENDOR_ID_OQO 0x1557 ++#define VENDOR_ID_ZYXEL 0x0586 ++ ++#define PRODUCT_ID_RTL8150 0x8150 ++#define PRODUCT_ID_LUAKTX 0x0012 ++#define PRODUCT_ID_LCS8138TX 0x401a ++#define PRODUCT_ID_SP128AR 0x0003 ++#define PRODUCT_ID_PRESTIGE 0x401a ++ ++#undef EEPROM_WRITE ++ ++/* table of devices that work with this driver */ ++static struct usb_device_id rtl8150_table[] = { ++ {USB_DEVICE(VENDOR_ID_REALTEK, PRODUCT_ID_RTL8150)}, ++ {USB_DEVICE(VENDOR_ID_MELCO, PRODUCT_ID_LUAKTX)}, ++ {USB_DEVICE(VENDOR_ID_MICRONET, PRODUCT_ID_SP128AR)}, ++ {USB_DEVICE(VENDOR_ID_LONGSHINE, PRODUCT_ID_LCS8138TX)}, ++ {USB_DEVICE(VENDOR_ID_OQO, PRODUCT_ID_RTL8150)}, ++ {USB_DEVICE(VENDOR_ID_ZYXEL, PRODUCT_ID_PRESTIGE)}, ++ {} ++}; ++ ++MODULE_DEVICE_TABLE(usb, rtl8150_table); ++ ++struct rtl8150 { ++ unsigned long flags; ++ struct usb_device *udev; ++ struct tasklet_struct tl; ++ struct net_device *netdev; ++ struct urb *rx_urb, *tx_urb, *intr_urb; ++ struct sk_buff *tx_skb, *rx_skb; ++ struct sk_buff *rx_skb_pool[RX_SKB_POOL_SIZE]; ++ spinlock_t rx_pool_lock; ++ struct usb_ctrlrequest dr; ++ int intr_interval; ++ u8 *intr_buff; ++ u8 phy; ++}; ++ ++typedef struct rtl8150 rtl8150_t; ++ ++struct async_req { ++ struct usb_ctrlrequest dr; ++ u16 rx_creg; ++}; ++ ++static const char driver_name [] = "rtl8150"; ++ ++/* ++** ++** device related part of the code ++** ++*/ ++static int get_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) ++{ ++ return usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), ++ RTL8150_REQ_GET_REGS, RTL8150_REQT_READ, ++ indx, 0, data, size, 500); ++} ++ ++static int set_registers(rtl8150_t * dev, u16 indx, u16 size, void *data) ++{ ++ return usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), ++ RTL8150_REQ_SET_REGS, RTL8150_REQT_WRITE, ++ indx, 0, data, size, 500); ++} ++ ++static void async_set_reg_cb(struct urb *urb) ++{ ++ struct async_req *req = (struct async_req *)urb->context; ++ int status = urb->status; ++ ++ if (status < 0) ++ dev_dbg(&urb->dev->dev, "%s failed with %d", __func__, status); ++ kfree(req); ++ usb_free_urb(urb); ++} ++ ++static int async_set_registers(rtl8150_t *dev, u16 indx, u16 size, u16 reg) ++{ ++ int res = -ENOMEM; ++ struct urb *async_urb; ++ struct async_req *req; ++ ++ req = kmalloc(sizeof(struct async_req), GFP_ATOMIC); ++ if (req == NULL) ++ return res; ++ async_urb = usb_alloc_urb(0, GFP_ATOMIC); ++ if (async_urb == NULL) { ++ kfree(req); ++ return res; ++ } ++ req->rx_creg = cpu_to_le16(reg); ++ req->dr.bRequestType = RTL8150_REQT_WRITE; ++ req->dr.bRequest = RTL8150_REQ_SET_REGS; ++ req->dr.wIndex = 0; ++ req->dr.wValue = cpu_to_le16(indx); ++ req->dr.wLength = cpu_to_le16(size); ++ usb_fill_control_urb(async_urb, dev->udev, ++ usb_sndctrlpipe(dev->udev, 0), (void *)&req->dr, ++ &req->rx_creg, size, async_set_reg_cb, req); ++ res = usb_submit_urb(async_urb, GFP_ATOMIC); ++ if (res) { ++ if (res == -ENODEV) ++ netif_device_detach(dev->netdev); ++ dev_err(&dev->udev->dev, "%s failed with %d\n", __func__, res); ++ } ++ return res; ++} ++ ++static int read_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 * reg) ++{ ++ int i; ++ u8 data[3], tmp; ++ ++ data[0] = phy; ++ data[1] = data[2] = 0; ++ tmp = indx | PHY_READ | PHY_GO; ++ i = 0; ++ ++ set_registers(dev, PHYADD, sizeof(data), data); ++ set_registers(dev, PHYCNT, 1, &tmp); ++ do { ++ get_registers(dev, PHYCNT, 1, data); ++ } while ((data[0] & PHY_GO) && (i++ < MII_TIMEOUT)); ++ ++ if (i <= MII_TIMEOUT) { ++ get_registers(dev, PHYDAT, 2, data); ++ *reg = data[0] | (data[1] << 8); ++ return 0; ++ } else ++ return 1; ++} ++ ++static int write_mii_word(rtl8150_t * dev, u8 phy, __u8 indx, u16 reg) ++{ ++ int i; ++ u8 data[3], tmp; ++ ++ data[0] = phy; ++ data[1] = reg & 0xff; ++ data[2] = (reg >> 8) & 0xff; ++ tmp = indx | PHY_WRITE | PHY_GO; ++ i = 0; ++ ++ set_registers(dev, PHYADD, sizeof(data), data); ++ set_registers(dev, PHYCNT, 1, &tmp); ++ do { ++ get_registers(dev, PHYCNT, 1, data); ++ } while ((data[0] & PHY_GO) && (i++ < MII_TIMEOUT)); ++ ++ if (i <= MII_TIMEOUT) ++ return 0; ++ else ++ return 1; ++} ++ ++static inline void set_ethernet_addr(rtl8150_t * dev) ++{ ++ u8 node_id[6]; ++ ++ get_registers(dev, IDR, sizeof(node_id), node_id); ++ memcpy(dev->netdev->dev_addr, node_id, sizeof(node_id)); ++} ++ ++static int rtl8150_set_mac_address(struct net_device *netdev, void *p) ++{ ++ struct sockaddr *addr = p; ++ rtl8150_t *dev = netdev_priv(netdev); ++ ++ if (netif_running(netdev)) ++ return -EBUSY; ++ ++ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); ++ netdev_dbg(netdev, "Setting MAC address to %pM\n", netdev->dev_addr); ++ /* Set the IDR registers. */ ++ set_registers(dev, IDR, netdev->addr_len, netdev->dev_addr); ++#ifdef EEPROM_WRITE ++ { ++ int i; ++ u8 cr; ++ /* Get the CR contents. */ ++ get_registers(dev, CR, 1, &cr); ++ /* Set the WEPROM bit (eeprom write enable). */ ++ cr |= 0x20; ++ set_registers(dev, CR, 1, &cr); ++ /* Write the MAC address into eeprom. Eeprom writes must be word-sized, ++ so we need to split them up. */ ++ for (i = 0; i * 2 < netdev->addr_len; i++) { ++ set_registers(dev, IDR_EEPROM + (i * 2), 2, ++ netdev->dev_addr + (i * 2)); ++ } ++ /* Clear the WEPROM bit (preventing accidental eeprom writes). */ ++ cr &= 0xdf; ++ set_registers(dev, CR, 1, &cr); ++ } ++#endif ++ return 0; ++} ++ ++static int rtl8150_reset(rtl8150_t * dev) ++{ ++ u8 data = 0x10; ++ int i = HZ; ++ ++ set_registers(dev, CR, 1, &data); ++ do { ++ get_registers(dev, CR, 1, &data); ++ } while ((data & 0x10) && --i); ++ ++ return (i > 0) ? 1 : 0; ++} ++ ++static int alloc_all_urbs(rtl8150_t * dev) ++{ ++ dev->rx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!dev->rx_urb) ++ return 0; ++ dev->tx_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!dev->tx_urb) { ++ usb_free_urb(dev->rx_urb); ++ return 0; ++ } ++ dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL); ++ if (!dev->intr_urb) { ++ usb_free_urb(dev->rx_urb); ++ usb_free_urb(dev->tx_urb); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static void free_all_urbs(rtl8150_t * dev) ++{ ++ usb_free_urb(dev->rx_urb); ++ usb_free_urb(dev->tx_urb); ++ usb_free_urb(dev->intr_urb); ++} ++ ++static void unlink_all_urbs(rtl8150_t * dev) ++{ ++ usb_kill_urb(dev->rx_urb); ++ usb_kill_urb(dev->tx_urb); ++ usb_kill_urb(dev->intr_urb); ++} ++ ++static inline struct sk_buff *pull_skb(rtl8150_t *dev) ++{ ++ struct sk_buff *skb; ++ int i; ++ ++ for (i = 0; i < RX_SKB_POOL_SIZE; i++) { ++ if (dev->rx_skb_pool[i]) { ++ skb = dev->rx_skb_pool[i]; ++ dev->rx_skb_pool[i] = NULL; ++ return skb; ++ } ++ } ++ return NULL; ++} ++ ++static void read_bulk_callback(struct urb *urb) ++{ ++ rtl8150_t *dev; ++ unsigned pkt_len, res; ++ struct sk_buff *skb; ++ struct net_device *netdev; ++ u16 rx_stat; ++ int status = urb->status; ++ int result; ++ ++ dev = urb->context; ++ if (!dev) ++ return; ++ if (test_bit(RTL8150_UNPLUG, &dev->flags)) ++ return; ++ netdev = dev->netdev; ++ if (!netif_device_present(netdev)) ++ return; ++ ++ switch (status) { ++ case 0: ++ break; ++ case -ENOENT: ++ return; /* the urb is in unlink state */ ++ case -ETIME: ++ if (printk_ratelimit()) ++ dev_warn(&urb->dev->dev, "may be reset is needed?..\n"); ++ goto goon; ++ default: ++ if (printk_ratelimit()) ++ dev_warn(&urb->dev->dev, "Rx status %d\n", status); ++ goto goon; ++ } ++ ++ if (!dev->rx_skb) ++ goto resched; ++ /* protect against short packets (tell me why we got some?!?) */ ++ if (urb->actual_length < 4) ++ goto goon; ++ ++ res = urb->actual_length; ++ rx_stat = le16_to_cpu(*(__le16 *)(urb->transfer_buffer + res - 4)); ++ pkt_len = res - 4; ++ ++ skb_put(dev->rx_skb, pkt_len); ++ dev->rx_skb->protocol = eth_type_trans(dev->rx_skb, netdev); ++ netif_rx(dev->rx_skb); ++ netdev->stats.rx_packets++; ++ netdev->stats.rx_bytes += pkt_len; ++ ++ spin_lock(&dev->rx_pool_lock); ++ skb = pull_skb(dev); ++ spin_unlock(&dev->rx_pool_lock); ++ if (!skb) ++ goto resched; ++ ++ dev->rx_skb = skb; ++goon: ++ usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), ++ dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); ++ result = usb_submit_urb(dev->rx_urb, GFP_ATOMIC); ++ if (result == -ENODEV) ++ netif_device_detach(dev->netdev); ++ else if (result) { ++ set_bit(RX_URB_FAIL, &dev->flags); ++ goto resched; ++ } else { ++ clear_bit(RX_URB_FAIL, &dev->flags); ++ } ++ ++ return; ++resched: ++ tasklet_schedule(&dev->tl); ++} ++ ++static void write_bulk_callback(struct urb *urb) ++{ ++ rtl8150_t *dev; ++ int status = urb->status; ++ ++ dev = urb->context; ++ if (!dev) ++ return; ++ dev_kfree_skb_irq(dev->tx_skb); ++ if (!netif_device_present(dev->netdev)) ++ return; ++ if (status) ++ dev_info(&urb->dev->dev, "%s: Tx status %d\n", ++ dev->netdev->name, status); ++ dev->netdev->trans_start = jiffies; ++ netif_wake_queue(dev->netdev); ++} ++ ++static void intr_callback(struct urb *urb) ++{ ++ rtl8150_t *dev; ++ __u8 *d; ++ int status = urb->status; ++ int res; ++ ++ dev = urb->context; ++ if (!dev) ++ return; ++ switch (status) { ++ case 0: /* success */ ++ break; ++ case -ECONNRESET: /* unlink */ ++ case -ENOENT: ++ case -ESHUTDOWN: ++ return; ++ /* -EPIPE: should clear the halt */ ++ default: ++ dev_info(&urb->dev->dev, "%s: intr status %d\n", ++ dev->netdev->name, status); ++ goto resubmit; ++ } ++ ++ d = urb->transfer_buffer; ++ if (d[0] & TSR_ERRORS) { ++ dev->netdev->stats.tx_errors++; ++ if (d[INT_TSR] & (TSR_ECOL | TSR_JBR)) ++ dev->netdev->stats.tx_aborted_errors++; ++ if (d[INT_TSR] & TSR_LCOL) ++ dev->netdev->stats.tx_window_errors++; ++ if (d[INT_TSR] & TSR_LOSS_CRS) ++ dev->netdev->stats.tx_carrier_errors++; ++ } ++ /* Report link status changes to the network stack */ ++ if ((d[INT_MSR] & MSR_LINK) == 0) { ++ if (netif_carrier_ok(dev->netdev)) { ++ netif_carrier_off(dev->netdev); ++ netdev_dbg(dev->netdev, "%s: LINK LOST\n", __func__); ++ } ++ } else { ++ if (!netif_carrier_ok(dev->netdev)) { ++ netif_carrier_on(dev->netdev); ++ netdev_dbg(dev->netdev, "%s: LINK CAME BACK\n", __func__); ++ } ++ } ++ ++resubmit: ++ res = usb_submit_urb (urb, GFP_ATOMIC); ++ if (res == -ENODEV) ++ netif_device_detach(dev->netdev); ++ else if (res) ++ dev_err(&dev->udev->dev, ++ "can't resubmit intr, %s-%s/input0, status %d\n", ++ dev->udev->bus->bus_name, dev->udev->devpath, res); ++} ++ ++static int rtl8150_suspend(struct usb_interface *intf, pm_message_t message) ++{ ++ rtl8150_t *dev = usb_get_intfdata(intf); ++ ++ netif_device_detach(dev->netdev); ++ ++ if (netif_running(dev->netdev)) { ++ usb_kill_urb(dev->rx_urb); ++ usb_kill_urb(dev->intr_urb); ++ } ++ return 0; ++} ++ ++static int rtl8150_resume(struct usb_interface *intf) ++{ ++ rtl8150_t *dev = usb_get_intfdata(intf); ++ ++ netif_device_attach(dev->netdev); ++ if (netif_running(dev->netdev)) { ++ dev->rx_urb->status = 0; ++ dev->rx_urb->actual_length = 0; ++ read_bulk_callback(dev->rx_urb); ++ ++ dev->intr_urb->status = 0; ++ dev->intr_urb->actual_length = 0; ++ intr_callback(dev->intr_urb); ++ } ++ return 0; ++} ++ ++/* ++** ++** network related part of the code ++** ++*/ ++ ++static void fill_skb_pool(rtl8150_t *dev) ++{ ++ struct sk_buff *skb; ++ int i; ++ ++ for (i = 0; i < RX_SKB_POOL_SIZE; i++) { ++ if (dev->rx_skb_pool[i]) ++ continue; ++ skb = dev_alloc_skb(RTL8150_MTU + 2); ++ if (!skb) { ++ return; ++ } ++ skb_reserve(skb, 2); ++ dev->rx_skb_pool[i] = skb; ++ } ++} ++ ++static void free_skb_pool(rtl8150_t *dev) ++{ ++ int i; ++ ++ for (i = 0; i < RX_SKB_POOL_SIZE; i++) ++ if (dev->rx_skb_pool[i]) ++ dev_kfree_skb(dev->rx_skb_pool[i]); ++} ++ ++static void rx_fixup(unsigned long data) ++{ ++ struct rtl8150 *dev = (struct rtl8150 *)data; ++ struct sk_buff *skb; ++ int status; ++ ++ spin_lock_irq(&dev->rx_pool_lock); ++ fill_skb_pool(dev); ++ spin_unlock_irq(&dev->rx_pool_lock); ++ if (test_bit(RX_URB_FAIL, &dev->flags)) ++ if (dev->rx_skb) ++ goto try_again; ++ spin_lock_irq(&dev->rx_pool_lock); ++ skb = pull_skb(dev); ++ spin_unlock_irq(&dev->rx_pool_lock); ++ if (skb == NULL) ++ goto tlsched; ++ dev->rx_skb = skb; ++ usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), ++ dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); ++try_again: ++ status = usb_submit_urb(dev->rx_urb, GFP_ATOMIC); ++ if (status == -ENODEV) { ++ netif_device_detach(dev->netdev); ++ } else if (status) { ++ set_bit(RX_URB_FAIL, &dev->flags); ++ goto tlsched; ++ } else { ++ clear_bit(RX_URB_FAIL, &dev->flags); ++ } ++ ++ return; ++tlsched: ++ tasklet_schedule(&dev->tl); ++} ++ ++static int enable_net_traffic(rtl8150_t * dev) ++{ ++ u8 cr, tcr, rcr, msr; ++ ++ if (!rtl8150_reset(dev)) { ++ dev_warn(&dev->udev->dev, "device reset failed\n"); ++ } ++ /* RCR bit7=1 attach Rx info at the end; =0 HW CRC (which is broken) */ ++ rcr = 0x9e; ++ tcr = 0xd8; ++ cr = 0x0c; ++ if (!(rcr & 0x80)) ++ set_bit(RTL8150_HW_CRC, &dev->flags); ++ set_registers(dev, RCR, 1, &rcr); ++ set_registers(dev, TCR, 1, &tcr); ++ set_registers(dev, CR, 1, &cr); ++ get_registers(dev, MSR, 1, &msr); ++ ++ return 0; ++} ++ ++static void disable_net_traffic(rtl8150_t * dev) ++{ ++ u8 cr; ++ ++ get_registers(dev, CR, 1, &cr); ++ cr &= 0xf3; ++ set_registers(dev, CR, 1, &cr); ++} ++ ++static void rtl8150_tx_timeout(struct net_device *netdev) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ dev_warn(&netdev->dev, "Tx timeout.\n"); ++ usb_unlink_urb(dev->tx_urb); ++ netdev->stats.tx_errors++; ++} ++ ++static void rtl8150_set_multicast(struct net_device *netdev) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ u16 rx_creg = 0x9e; ++ ++ netif_stop_queue(netdev); ++ if (netdev->flags & IFF_PROMISC) { ++ rx_creg |= 0x0001; ++ dev_info(&netdev->dev, "%s: promiscuous mode\n", netdev->name); ++ } else if (!netdev_mc_empty(netdev) || ++ (netdev->flags & IFF_ALLMULTI)) { ++ rx_creg &= 0xfffe; ++ rx_creg |= 0x0002; ++ dev_info(&netdev->dev, "%s: allmulti set\n", netdev->name); ++ } else { ++ /* ~RX_MULTICAST, ~RX_PROMISCUOUS */ ++ rx_creg &= 0x00fc; ++ } ++ async_set_registers(dev, RCR, sizeof(rx_creg), rx_creg); ++ netif_wake_queue(netdev); ++} ++ ++static netdev_tx_t rtl8150_start_xmit(struct sk_buff *skb, ++ struct net_device *netdev) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ int count, res; ++ ++ netif_stop_queue(netdev); ++ count = (skb->len < 60) ? 60 : skb->len; ++ count = (count & 0x3f) ? count : count + 1; ++ dev->tx_skb = skb; ++ usb_fill_bulk_urb(dev->tx_urb, dev->udev, usb_sndbulkpipe(dev->udev, 2), ++ skb->data, count, write_bulk_callback, dev); ++ if ((res = usb_submit_urb(dev->tx_urb, GFP_ATOMIC))) { ++ /* Can we get/handle EPIPE here? */ ++ if (res == -ENODEV) ++ netif_device_detach(dev->netdev); ++ else { ++ dev_warn(&netdev->dev, "failed tx_urb %d\n", res); ++ netdev->stats.tx_errors++; ++ netif_start_queue(netdev); ++ } ++ } else { ++ netdev->stats.tx_packets++; ++ netdev->stats.tx_bytes += skb->len; ++ netdev->trans_start = jiffies; ++ } ++ ++ return NETDEV_TX_OK; ++} ++ ++ ++static void set_carrier(struct net_device *netdev) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ short tmp; ++ ++ get_registers(dev, CSCR, 2, &tmp); ++ if (tmp & CSCR_LINK_STATUS) ++ netif_carrier_on(netdev); ++ else ++ netif_carrier_off(netdev); ++} ++ ++static int rtl8150_open(struct net_device *netdev) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ int res; ++ ++ if (dev->rx_skb == NULL) ++ dev->rx_skb = pull_skb(dev); ++ if (!dev->rx_skb) ++ return -ENOMEM; ++ ++ set_registers(dev, IDR, 6, netdev->dev_addr); ++ ++ usb_fill_bulk_urb(dev->rx_urb, dev->udev, usb_rcvbulkpipe(dev->udev, 1), ++ dev->rx_skb->data, RTL8150_MTU, read_bulk_callback, dev); ++ if ((res = usb_submit_urb(dev->rx_urb, GFP_KERNEL))) { ++ if (res == -ENODEV) ++ netif_device_detach(dev->netdev); ++ dev_warn(&netdev->dev, "rx_urb submit failed: %d\n", res); ++ return res; ++ } ++ usb_fill_int_urb(dev->intr_urb, dev->udev, usb_rcvintpipe(dev->udev, 3), ++ dev->intr_buff, INTBUFSIZE, intr_callback, ++ dev, dev->intr_interval); ++ if ((res = usb_submit_urb(dev->intr_urb, GFP_KERNEL))) { ++ if (res == -ENODEV) ++ netif_device_detach(dev->netdev); ++ dev_warn(&netdev->dev, "intr_urb submit failed: %d\n", res); ++ usb_kill_urb(dev->rx_urb); ++ return res; ++ } ++ enable_net_traffic(dev); ++ set_carrier(netdev); ++ netif_start_queue(netdev); ++ ++ return res; ++} ++ ++static int rtl8150_close(struct net_device *netdev) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ ++ netif_stop_queue(netdev); ++ if (!test_bit(RTL8150_UNPLUG, &dev->flags)) ++ disable_net_traffic(dev); ++ unlink_all_urbs(dev); ++ ++ return 0; ++} ++ ++static void rtl8150_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ ++ strlcpy(info->driver, driver_name, sizeof(info->driver)); ++ strlcpy(info->version, DRIVER_VERSION, sizeof(info->version)); ++ usb_make_path(dev->udev, info->bus_info, sizeof(info->bus_info)); ++} ++ ++static int rtl8150_get_settings(struct net_device *netdev, struct ethtool_cmd *ecmd) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ short lpa, bmcr; ++ ++ ecmd->supported = (SUPPORTED_10baseT_Half | ++ SUPPORTED_10baseT_Full | ++ SUPPORTED_100baseT_Half | ++ SUPPORTED_100baseT_Full | ++ SUPPORTED_Autoneg | ++ SUPPORTED_TP | SUPPORTED_MII); ++ ecmd->port = PORT_TP; ++ ecmd->transceiver = XCVR_INTERNAL; ++ ecmd->phy_address = dev->phy; ++ get_registers(dev, BMCR, 2, &bmcr); ++ get_registers(dev, ANLP, 2, &lpa); ++ if (bmcr & BMCR_ANENABLE) { ++ u32 speed = ((lpa & (LPA_100HALF | LPA_100FULL)) ? ++ SPEED_100 : SPEED_10); ++ ethtool_cmd_speed_set(ecmd, speed); ++ ecmd->autoneg = AUTONEG_ENABLE; ++ if (speed == SPEED_100) ++ ecmd->duplex = (lpa & LPA_100FULL) ? ++ DUPLEX_FULL : DUPLEX_HALF; ++ else ++ ecmd->duplex = (lpa & LPA_10FULL) ? ++ DUPLEX_FULL : DUPLEX_HALF; ++ } else { ++ ecmd->autoneg = AUTONEG_DISABLE; ++ ethtool_cmd_speed_set(ecmd, ((bmcr & BMCR_SPEED100) ? ++ SPEED_100 : SPEED_10)); ++ ecmd->duplex = (bmcr & BMCR_FULLDPLX) ? ++ DUPLEX_FULL : DUPLEX_HALF; ++ } ++ return 0; ++} ++ ++static const struct ethtool_ops ops = { ++ .get_drvinfo = rtl8150_get_drvinfo, ++ .get_settings = rtl8150_get_settings, ++ .get_link = ethtool_op_get_link ++}; ++ ++static int rtl8150_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) ++{ ++ rtl8150_t *dev = netdev_priv(netdev); ++ u16 *data = (u16 *) & rq->ifr_ifru; ++ int res = 0; ++ ++ switch (cmd) { ++ case SIOCDEVPRIVATE: ++ data[0] = dev->phy; ++ case SIOCDEVPRIVATE + 1: ++ read_mii_word(dev, dev->phy, (data[1] & 0x1f), &data[3]); ++ break; ++ case SIOCDEVPRIVATE + 2: ++ if (!capable(CAP_NET_ADMIN)) ++ return -EPERM; ++ write_mii_word(dev, dev->phy, (data[1] & 0x1f), data[2]); ++ break; ++ default: ++ res = -EOPNOTSUPP; ++ } ++ ++ return res; ++} ++ ++static const struct net_device_ops rtl8150_netdev_ops = { ++ .ndo_open = rtl8150_open, ++ .ndo_stop = rtl8150_close, ++ .ndo_do_ioctl = rtl8150_ioctl, ++ .ndo_start_xmit = rtl8150_start_xmit, ++ .ndo_tx_timeout = rtl8150_tx_timeout, ++ .ndo_set_rx_mode = rtl8150_set_multicast, ++ .ndo_set_mac_address = rtl8150_set_mac_address, ++ ++ .ndo_change_mtu = eth_change_mtu, ++ .ndo_validate_addr = eth_validate_addr, ++}; ++ ++static int rtl8150_probe(struct usb_interface *intf, ++ const struct usb_device_id *id) ++{ ++ struct usb_device *udev = interface_to_usbdev(intf); ++ rtl8150_t *dev; ++ struct net_device *netdev; ++ ++ netdev = alloc_etherdev(sizeof(rtl8150_t)); ++ if (!netdev) ++ return -ENOMEM; ++ ++ dev = netdev_priv(netdev); ++ ++ dev->intr_buff = kmalloc(INTBUFSIZE, GFP_KERNEL); ++ if (!dev->intr_buff) { ++ free_netdev(netdev); ++ return -ENOMEM; ++ } ++ ++ tasklet_init(&dev->tl, rx_fixup, (unsigned long)dev); ++ spin_lock_init(&dev->rx_pool_lock); ++ ++ dev->udev = udev; ++ dev->netdev = netdev; ++ netdev->netdev_ops = &rtl8150_netdev_ops; ++ netdev->watchdog_timeo = RTL8150_TX_TIMEOUT; ++ netdev->ethtool_ops = &ops; ++ dev->intr_interval = 100; /* 100ms */ ++ ++ if (!alloc_all_urbs(dev)) { ++ dev_err(&intf->dev, "out of memory\n"); ++ goto out; ++ } ++ if (!rtl8150_reset(dev)) { ++ dev_err(&intf->dev, "couldn't reset the device\n"); ++ goto out1; ++ } ++ fill_skb_pool(dev); ++ set_ethernet_addr(dev); ++ ++ usb_set_intfdata(intf, dev); ++ SET_NETDEV_DEV(netdev, &intf->dev); ++ if (register_netdev(netdev) != 0) { ++ dev_err(&intf->dev, "couldn't register the device\n"); ++ goto out2; ++ } ++ ++ dev_info(&intf->dev, "%s: rtl8150 is detected\n", netdev->name); ++ ++ return 0; ++ ++out2: ++ usb_set_intfdata(intf, NULL); ++ free_skb_pool(dev); ++out1: ++ free_all_urbs(dev); ++out: ++ kfree(dev->intr_buff); ++ free_netdev(netdev); ++ return -EIO; ++} ++ ++static void rtl8150_disconnect(struct usb_interface *intf) ++{ ++ rtl8150_t *dev = usb_get_intfdata(intf); ++ ++ usb_set_intfdata(intf, NULL); ++ if (dev) { ++ set_bit(RTL8150_UNPLUG, &dev->flags); ++ tasklet_kill(&dev->tl); ++ unregister_netdev(dev->netdev); ++ unlink_all_urbs(dev); ++ free_all_urbs(dev); ++ free_skb_pool(dev); ++ if (dev->rx_skb) ++ dev_kfree_skb(dev->rx_skb); ++ kfree(dev->intr_buff); ++ free_netdev(dev->netdev); ++ } ++} ++ ++static struct usb_driver rtl8150_driver = { ++ .name = driver_name, ++ .probe = rtl8150_probe, ++ .disconnect = rtl8150_disconnect, ++ .id_table = rtl8150_table, ++ .suspend = rtl8150_suspend, ++ .resume = rtl8150_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(rtl8150_driver); ++ ++MODULE_AUTHOR(DRIVER_AUTHOR); ++MODULE_DESCRIPTION(DRIVER_DESC); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/smsc75xx.c backports-4.2.6-1/drivers/net/usb/smsc75xx.c +--- backports-4.2.6-1.org/drivers/net/usb/smsc75xx.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/smsc75xx.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,2286 @@ ++ /*************************************************************************** ++ * ++ * Copyright (C) 2007-2010 SMSC ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ * ++ *****************************************************************************/ ++ ++#include <linux/module.h> ++#include <linux/kmod.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/bitrev.h> ++#include <linux/crc16.h> ++#include <linux/crc32.h> ++#include <linux/usb/usbnet.h> ++#include <linux/slab.h> ++#include "smsc75xx.h" ++ ++#define SMSC_CHIPNAME "smsc75xx" ++#define SMSC_DRIVER_VERSION "1.0.0" ++#define HS_USB_PKT_SIZE (512) ++#define FS_USB_PKT_SIZE (64) ++#define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE) ++#define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE) ++#define DEFAULT_BULK_IN_DELAY (0x00002000) ++#define MAX_SINGLE_PACKET_SIZE (9000) ++#define LAN75XX_EEPROM_MAGIC (0x7500) ++#define EEPROM_MAC_OFFSET (0x01) ++#define DEFAULT_TX_CSUM_ENABLE (true) ++#define DEFAULT_RX_CSUM_ENABLE (true) ++#define SMSC75XX_INTERNAL_PHY_ID (1) ++#define SMSC75XX_TX_OVERHEAD (8) ++#define MAX_RX_FIFO_SIZE (20 * 1024) ++#define MAX_TX_FIFO_SIZE (12 * 1024) ++#define USB_VENDOR_ID_SMSC (0x0424) ++#define USB_PRODUCT_ID_LAN7500 (0x7500) ++#define USB_PRODUCT_ID_LAN7505 (0x7505) ++#define RXW_PADDING 2 ++#define SUPPORTED_WAKE (WAKE_PHY | WAKE_UCAST | WAKE_BCAST | \ ++ WAKE_MCAST | WAKE_ARP | WAKE_MAGIC) ++ ++#define SUSPEND_SUSPEND0 (0x01) ++#define SUSPEND_SUSPEND1 (0x02) ++#define SUSPEND_SUSPEND2 (0x04) ++#define SUSPEND_SUSPEND3 (0x08) ++#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \ ++ SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3) ++ ++struct smsc75xx_priv { ++ struct usbnet *dev; ++ u32 rfe_ctl; ++ u32 wolopts; ++ u32 multicast_hash_table[DP_SEL_VHF_HASH_LEN]; ++ struct mutex dataport_mutex; ++ spinlock_t rfe_ctl_lock; ++ struct work_struct set_multicast; ++ u8 suspend_flags; ++}; ++ ++struct usb_context { ++ struct usb_ctrlrequest req; ++ struct usbnet *dev; ++}; ++ ++static bool turbo_mode = true; ++module_param(turbo_mode, bool, 0644); ++MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); ++ ++static int __must_check __smsc75xx_read_reg(struct usbnet *dev, u32 index, ++ u32 *data, int in_pm) ++{ ++ u32 buf; ++ int ret; ++ int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); ++ ++ BUG_ON(!dev); ++ ++ if (!in_pm) ++ fn = usbnet_read_cmd; ++ else ++ fn = usbnet_read_cmd_nopm; ++ ++ ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN ++ | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ 0, index, &buf, 4); ++ if (unlikely(ret < 0)) ++ netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n", ++ index, ret); ++ ++ le32_to_cpus(&buf); ++ *data = buf; ++ ++ return ret; ++} ++ ++static int __must_check __smsc75xx_write_reg(struct usbnet *dev, u32 index, ++ u32 data, int in_pm) ++{ ++ u32 buf; ++ int ret; ++ int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); ++ ++ BUG_ON(!dev); ++ ++ if (!in_pm) ++ fn = usbnet_write_cmd; ++ else ++ fn = usbnet_write_cmd_nopm; ++ ++ buf = data; ++ cpu_to_le32s(&buf); ++ ++ ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, USB_DIR_OUT ++ | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ 0, index, &buf, 4); ++ if (unlikely(ret < 0)) ++ netdev_warn(dev->net, "Failed to write reg index 0x%08x: %d\n", ++ index, ret); ++ ++ return ret; ++} ++ ++static int __must_check smsc75xx_read_reg_nopm(struct usbnet *dev, u32 index, ++ u32 *data) ++{ ++ return __smsc75xx_read_reg(dev, index, data, 1); ++} ++ ++static int __must_check smsc75xx_write_reg_nopm(struct usbnet *dev, u32 index, ++ u32 data) ++{ ++ return __smsc75xx_write_reg(dev, index, data, 1); ++} ++ ++static int __must_check smsc75xx_read_reg(struct usbnet *dev, u32 index, ++ u32 *data) ++{ ++ return __smsc75xx_read_reg(dev, index, data, 0); ++} ++ ++static int __must_check smsc75xx_write_reg(struct usbnet *dev, u32 index, ++ u32 data) ++{ ++ return __smsc75xx_write_reg(dev, index, data, 0); ++} ++ ++/* Loop until the read is completed with timeout ++ * called with phy_mutex held */ ++static __must_check int __smsc75xx_phy_wait_not_busy(struct usbnet *dev, ++ int in_pm) ++{ ++ unsigned long start_time = jiffies; ++ u32 val; ++ int ret; ++ ++ do { ++ ret = __smsc75xx_read_reg(dev, MII_ACCESS, &val, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading MII_ACCESS\n"); ++ return ret; ++ } ++ ++ if (!(val & MII_ACCESS_BUSY)) ++ return 0; ++ } while (!time_after(jiffies, start_time + HZ)); ++ ++ return -EIO; ++} ++ ++static int __smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx, ++ int in_pm) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u32 val, addr; ++ int ret; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ /* confirm MII not busy */ ++ ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "MII is busy in smsc75xx_mdio_read\n"); ++ goto done; ++ } ++ ++ /* set the address, index & direction (read from PHY) */ ++ phy_id &= dev->mii.phy_id_mask; ++ idx &= dev->mii.reg_num_mask; ++ addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR) ++ | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR) ++ | MII_ACCESS_READ | MII_ACCESS_BUSY; ++ ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing MII_ACCESS\n"); ++ goto done; ++ } ++ ++ ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx); ++ goto done; ++ } ++ ++ ret = __smsc75xx_read_reg(dev, MII_DATA, &val, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading MII_DATA\n"); ++ goto done; ++ } ++ ++ ret = (u16)(val & 0xFFFF); ++ ++done: ++ mutex_unlock(&dev->phy_mutex); ++ return ret; ++} ++ ++static void __smsc75xx_mdio_write(struct net_device *netdev, int phy_id, ++ int idx, int regval, int in_pm) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u32 val, addr; ++ int ret; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ /* confirm MII not busy */ ++ ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "MII is busy in smsc75xx_mdio_write\n"); ++ goto done; ++ } ++ ++ val = regval; ++ ret = __smsc75xx_write_reg(dev, MII_DATA, val, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing MII_DATA\n"); ++ goto done; ++ } ++ ++ /* set the address, index & direction (write to PHY) */ ++ phy_id &= dev->mii.phy_id_mask; ++ idx &= dev->mii.reg_num_mask; ++ addr = ((phy_id << MII_ACCESS_PHY_ADDR_SHIFT) & MII_ACCESS_PHY_ADDR) ++ | ((idx << MII_ACCESS_REG_ADDR_SHIFT) & MII_ACCESS_REG_ADDR) ++ | MII_ACCESS_WRITE | MII_ACCESS_BUSY; ++ ret = __smsc75xx_write_reg(dev, MII_ACCESS, addr, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing MII_ACCESS\n"); ++ goto done; ++ } ++ ++ ret = __smsc75xx_phy_wait_not_busy(dev, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx); ++ goto done; ++ } ++ ++done: ++ mutex_unlock(&dev->phy_mutex); ++} ++ ++static int smsc75xx_mdio_read_nopm(struct net_device *netdev, int phy_id, ++ int idx) ++{ ++ return __smsc75xx_mdio_read(netdev, phy_id, idx, 1); ++} ++ ++static void smsc75xx_mdio_write_nopm(struct net_device *netdev, int phy_id, ++ int idx, int regval) ++{ ++ __smsc75xx_mdio_write(netdev, phy_id, idx, regval, 1); ++} ++ ++static int smsc75xx_mdio_read(struct net_device *netdev, int phy_id, int idx) ++{ ++ return __smsc75xx_mdio_read(netdev, phy_id, idx, 0); ++} ++ ++static void smsc75xx_mdio_write(struct net_device *netdev, int phy_id, int idx, ++ int regval) ++{ ++ __smsc75xx_mdio_write(netdev, phy_id, idx, regval, 0); ++} ++ ++static int smsc75xx_wait_eeprom(struct usbnet *dev) ++{ ++ unsigned long start_time = jiffies; ++ u32 val; ++ int ret; ++ ++ do { ++ ret = smsc75xx_read_reg(dev, E2P_CMD, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading E2P_CMD\n"); ++ return ret; ++ } ++ ++ if (!(val & E2P_CMD_BUSY) || (val & E2P_CMD_TIMEOUT)) ++ break; ++ udelay(40); ++ } while (!time_after(jiffies, start_time + HZ)); ++ ++ if (val & (E2P_CMD_TIMEOUT | E2P_CMD_BUSY)) { ++ netdev_warn(dev->net, "EEPROM read operation timeout\n"); ++ return -EIO; ++ } ++ ++ return 0; ++} ++ ++static int smsc75xx_eeprom_confirm_not_busy(struct usbnet *dev) ++{ ++ unsigned long start_time = jiffies; ++ u32 val; ++ int ret; ++ ++ do { ++ ret = smsc75xx_read_reg(dev, E2P_CMD, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading E2P_CMD\n"); ++ return ret; ++ } ++ ++ if (!(val & E2P_CMD_BUSY)) ++ return 0; ++ ++ udelay(40); ++ } while (!time_after(jiffies, start_time + HZ)); ++ ++ netdev_warn(dev->net, "EEPROM is busy\n"); ++ return -EIO; ++} ++ ++static int smsc75xx_read_eeprom(struct usbnet *dev, u32 offset, u32 length, ++ u8 *data) ++{ ++ u32 val; ++ int i, ret; ++ ++ BUG_ON(!dev); ++ BUG_ON(!data); ++ ++ ret = smsc75xx_eeprom_confirm_not_busy(dev); ++ if (ret) ++ return ret; ++ ++ for (i = 0; i < length; i++) { ++ val = E2P_CMD_BUSY | E2P_CMD_READ | (offset & E2P_CMD_ADDR); ++ ret = smsc75xx_write_reg(dev, E2P_CMD, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing E2P_CMD\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_wait_eeprom(dev); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc75xx_read_reg(dev, E2P_DATA, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading E2P_DATA\n"); ++ return ret; ++ } ++ ++ data[i] = val & 0xFF; ++ offset++; ++ } ++ ++ return 0; ++} ++ ++static int smsc75xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length, ++ u8 *data) ++{ ++ u32 val; ++ int i, ret; ++ ++ BUG_ON(!dev); ++ BUG_ON(!data); ++ ++ ret = smsc75xx_eeprom_confirm_not_busy(dev); ++ if (ret) ++ return ret; ++ ++ /* Issue write/erase enable command */ ++ val = E2P_CMD_BUSY | E2P_CMD_EWEN; ++ ret = smsc75xx_write_reg(dev, E2P_CMD, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing E2P_CMD\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_wait_eeprom(dev); ++ if (ret < 0) ++ return ret; ++ ++ for (i = 0; i < length; i++) { ++ ++ /* Fill data register */ ++ val = data[i]; ++ ret = smsc75xx_write_reg(dev, E2P_DATA, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing E2P_DATA\n"); ++ return ret; ++ } ++ ++ /* Send "write" command */ ++ val = E2P_CMD_BUSY | E2P_CMD_WRITE | (offset & E2P_CMD_ADDR); ++ ret = smsc75xx_write_reg(dev, E2P_CMD, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing E2P_CMD\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_wait_eeprom(dev); ++ if (ret < 0) ++ return ret; ++ ++ offset++; ++ } ++ ++ return 0; ++} ++ ++static int smsc75xx_dataport_wait_not_busy(struct usbnet *dev) ++{ ++ int i, ret; ++ ++ for (i = 0; i < 100; i++) { ++ u32 dp_sel; ++ ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading DP_SEL\n"); ++ return ret; ++ } ++ ++ if (dp_sel & DP_SEL_DPRDY) ++ return 0; ++ ++ udelay(40); ++ } ++ ++ netdev_warn(dev->net, "smsc75xx_dataport_wait_not_busy timed out\n"); ++ ++ return -EIO; ++} ++ ++static int smsc75xx_dataport_write(struct usbnet *dev, u32 ram_select, u32 addr, ++ u32 length, u32 *buf) ++{ ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ u32 dp_sel; ++ int i, ret; ++ ++ mutex_lock(&pdata->dataport_mutex); ++ ++ ret = smsc75xx_dataport_wait_not_busy(dev); ++ if (ret < 0) { ++ netdev_warn(dev->net, "smsc75xx_dataport_write busy on entry\n"); ++ goto done; ++ } ++ ++ ret = smsc75xx_read_reg(dev, DP_SEL, &dp_sel); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading DP_SEL\n"); ++ goto done; ++ } ++ ++ dp_sel &= ~DP_SEL_RSEL; ++ dp_sel |= ram_select; ++ ret = smsc75xx_write_reg(dev, DP_SEL, dp_sel); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing DP_SEL\n"); ++ goto done; ++ } ++ ++ for (i = 0; i < length; i++) { ++ ret = smsc75xx_write_reg(dev, DP_ADDR, addr + i); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing DP_ADDR\n"); ++ goto done; ++ } ++ ++ ret = smsc75xx_write_reg(dev, DP_DATA, buf[i]); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing DP_DATA\n"); ++ goto done; ++ } ++ ++ ret = smsc75xx_write_reg(dev, DP_CMD, DP_CMD_WRITE); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing DP_CMD\n"); ++ goto done; ++ } ++ ++ ret = smsc75xx_dataport_wait_not_busy(dev); ++ if (ret < 0) { ++ netdev_warn(dev->net, "smsc75xx_dataport_write timeout\n"); ++ goto done; ++ } ++ } ++ ++done: ++ mutex_unlock(&pdata->dataport_mutex); ++ return ret; ++} ++ ++/* returns hash bit number for given MAC address */ ++static u32 smsc75xx_hash(char addr[ETH_ALEN]) ++{ ++ return (ether_crc(ETH_ALEN, addr) >> 23) & 0x1ff; ++} ++ ++static void smsc75xx_deferred_multicast_write(struct work_struct *param) ++{ ++ struct smsc75xx_priv *pdata = ++ container_of(param, struct smsc75xx_priv, set_multicast); ++ struct usbnet *dev = pdata->dev; ++ int ret; ++ ++ netif_dbg(dev, drv, dev->net, "deferred multicast write 0x%08x\n", ++ pdata->rfe_ctl); ++ ++ smsc75xx_dataport_write(dev, DP_SEL_VHF, DP_SEL_VHF_VLAN_LEN, ++ DP_SEL_VHF_HASH_LEN, pdata->multicast_hash_table); ++ ++ ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); ++ if (ret < 0) ++ netdev_warn(dev->net, "Error writing RFE_CRL\n"); ++} ++ ++static void smsc75xx_set_multicast(struct net_device *netdev) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ unsigned long flags; ++ int i; ++ ++ spin_lock_irqsave(&pdata->rfe_ctl_lock, flags); ++ ++ pdata->rfe_ctl &= ++ ~(RFE_CTL_AU | RFE_CTL_AM | RFE_CTL_DPF | RFE_CTL_MHF); ++ pdata->rfe_ctl |= RFE_CTL_AB; ++ ++ for (i = 0; i < DP_SEL_VHF_HASH_LEN; i++) ++ pdata->multicast_hash_table[i] = 0; ++ ++ if (dev->net->flags & IFF_PROMISC) { ++ netif_dbg(dev, drv, dev->net, "promiscuous mode enabled\n"); ++ pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_AU; ++ } else if (dev->net->flags & IFF_ALLMULTI) { ++ netif_dbg(dev, drv, dev->net, "receive all multicast enabled\n"); ++ pdata->rfe_ctl |= RFE_CTL_AM | RFE_CTL_DPF; ++ } else if (!netdev_mc_empty(dev->net)) { ++ struct netdev_hw_addr *ha; ++ ++ netif_dbg(dev, drv, dev->net, "receive multicast hash filter\n"); ++ ++ pdata->rfe_ctl |= RFE_CTL_MHF | RFE_CTL_DPF; ++ ++ netdev_for_each_mc_addr(ha, netdev) { ++ u32 bitnum = smsc75xx_hash(ha->addr); ++ pdata->multicast_hash_table[bitnum / 32] |= ++ (1 << (bitnum % 32)); ++ } ++ } else { ++ netif_dbg(dev, drv, dev->net, "receive own packets only\n"); ++ pdata->rfe_ctl |= RFE_CTL_DPF; ++ } ++ ++ spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags); ++ ++ /* defer register writes to a sleepable context */ ++ schedule_work(&pdata->set_multicast); ++} ++ ++static int smsc75xx_update_flowcontrol(struct usbnet *dev, u8 duplex, ++ u16 lcladv, u16 rmtadv) ++{ ++ u32 flow = 0, fct_flow = 0; ++ int ret; ++ ++ if (duplex == DUPLEX_FULL) { ++ u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); ++ ++ if (cap & FLOW_CTRL_TX) { ++ flow = (FLOW_TX_FCEN | 0xFFFF); ++ /* set fct_flow thresholds to 20% and 80% */ ++ fct_flow = (8 << 8) | 32; ++ } ++ ++ if (cap & FLOW_CTRL_RX) ++ flow |= FLOW_RX_FCEN; ++ ++ netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s\n", ++ (cap & FLOW_CTRL_RX ? "enabled" : "disabled"), ++ (cap & FLOW_CTRL_TX ? "enabled" : "disabled")); ++ } else { ++ netif_dbg(dev, link, dev->net, "half duplex\n"); ++ } ++ ++ ret = smsc75xx_write_reg(dev, FLOW, flow); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing FLOW\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_write_reg(dev, FCT_FLOW, fct_flow); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing FCT_FLOW\n"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int smsc75xx_link_reset(struct usbnet *dev) ++{ ++ struct mii_if_info *mii = &dev->mii; ++ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; ++ u16 lcladv, rmtadv; ++ int ret; ++ ++ /* write to clear phy interrupt status */ ++ smsc75xx_mdio_write(dev->net, mii->phy_id, PHY_INT_SRC, ++ PHY_INT_SRC_CLEAR_ALL); ++ ++ ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing INT_STS\n"); ++ return ret; ++ } ++ ++ mii_check_media(mii, 1, 1); ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ lcladv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); ++ rmtadv = smsc75xx_mdio_read(dev->net, mii->phy_id, MII_LPA); ++ ++ netif_dbg(dev, link, dev->net, "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n", ++ ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv); ++ ++ return smsc75xx_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); ++} ++ ++static void smsc75xx_status(struct usbnet *dev, struct urb *urb) ++{ ++ u32 intdata; ++ ++ if (urb->actual_length != 4) { ++ netdev_warn(dev->net, "unexpected urb length %d\n", ++ urb->actual_length); ++ return; ++ } ++ ++ memcpy(&intdata, urb->transfer_buffer, 4); ++ le32_to_cpus(&intdata); ++ ++ netif_dbg(dev, link, dev->net, "intdata: 0x%08X\n", intdata); ++ ++ if (intdata & INT_ENP_PHY_INT) ++ usbnet_defer_kevent(dev, EVENT_LINK_RESET); ++ else ++ netdev_warn(dev->net, "unexpected interrupt, intdata=0x%08X\n", ++ intdata); ++} ++ ++static int smsc75xx_ethtool_get_eeprom_len(struct net_device *net) ++{ ++ return MAX_EEPROM_SIZE; ++} ++ ++static int smsc75xx_ethtool_get_eeprom(struct net_device *netdev, ++ struct ethtool_eeprom *ee, u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ ++ ee->magic = LAN75XX_EEPROM_MAGIC; ++ ++ return smsc75xx_read_eeprom(dev, ee->offset, ee->len, data); ++} ++ ++static int smsc75xx_ethtool_set_eeprom(struct net_device *netdev, ++ struct ethtool_eeprom *ee, u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ ++ if (ee->magic != LAN75XX_EEPROM_MAGIC) { ++ netdev_warn(dev->net, "EEPROM: magic value mismatch: 0x%x\n", ++ ee->magic); ++ return -EINVAL; ++ } ++ ++ return smsc75xx_write_eeprom(dev, ee->offset, ee->len, data); ++} ++ ++static void smsc75xx_ethtool_get_wol(struct net_device *net, ++ struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ ++ wolinfo->supported = SUPPORTED_WAKE; ++ wolinfo->wolopts = pdata->wolopts; ++} ++ ++static int smsc75xx_ethtool_set_wol(struct net_device *net, ++ struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ int ret; ++ ++ pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; ++ ++ ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); ++ if (ret < 0) ++ netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret); ++ ++ return ret; ++} ++ ++static const struct ethtool_ops smsc75xx_ethtool_ops = { ++ .get_link = usbnet_get_link, ++ .nway_reset = usbnet_nway_reset, ++ .get_drvinfo = usbnet_get_drvinfo, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .get_eeprom_len = smsc75xx_ethtool_get_eeprom_len, ++ .get_eeprom = smsc75xx_ethtool_get_eeprom, ++ .set_eeprom = smsc75xx_ethtool_set_eeprom, ++ .get_wol = smsc75xx_ethtool_get_wol, ++ .set_wol = smsc75xx_ethtool_set_wol, ++}; ++ ++static int smsc75xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ ++ if (!netif_running(netdev)) ++ return -EINVAL; ++ ++ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); ++} ++ ++static void smsc75xx_init_mac_address(struct usbnet *dev) ++{ ++ /* try reading mac address from EEPROM */ ++ if (smsc75xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, ++ dev->net->dev_addr) == 0) { ++ if (is_valid_ether_addr(dev->net->dev_addr)) { ++ /* eeprom values are valid so use them */ ++ netif_dbg(dev, ifup, dev->net, ++ "MAC address read from EEPROM\n"); ++ return; ++ } ++ } ++ ++ /* no eeprom, or eeprom values are invalid. generate random MAC */ ++ eth_hw_addr_random(dev->net); ++ netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n"); ++} ++ ++static int smsc75xx_set_mac_address(struct usbnet *dev) ++{ ++ u32 addr_lo = dev->net->dev_addr[0] | dev->net->dev_addr[1] << 8 | ++ dev->net->dev_addr[2] << 16 | dev->net->dev_addr[3] << 24; ++ u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8; ++ ++ int ret = smsc75xx_write_reg(dev, RX_ADDRH, addr_hi); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write RX_ADDRH: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_write_reg(dev, RX_ADDRL, addr_lo); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write RX_ADDRL: %d\n", ret); ++ return ret; ++ } ++ ++ addr_hi |= ADDR_FILTX_FB_VALID; ++ ret = smsc75xx_write_reg(dev, ADDR_FILTX, addr_hi); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write ADDR_FILTX: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_write_reg(dev, ADDR_FILTX + 4, addr_lo); ++ if (ret < 0) ++ netdev_warn(dev->net, "Failed to write ADDR_FILTX+4: %d\n", ret); ++ ++ return ret; ++} ++ ++static int smsc75xx_phy_initialize(struct usbnet *dev) ++{ ++ int bmcr, ret, timeout = 0; ++ ++ /* Initialize MII structure */ ++ dev->mii.dev = dev->net; ++ dev->mii.mdio_read = smsc75xx_mdio_read; ++ dev->mii.mdio_write = smsc75xx_mdio_write; ++ dev->mii.phy_id_mask = 0x1f; ++ dev->mii.reg_num_mask = 0x1f; ++ dev->mii.supports_gmii = 1; ++ dev->mii.phy_id = SMSC75XX_INTERNAL_PHY_ID; ++ ++ /* reset phy and wait for reset to complete */ ++ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); ++ ++ do { ++ msleep(10); ++ bmcr = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); ++ if (bmcr < 0) { ++ netdev_warn(dev->net, "Error reading MII_BMCR\n"); ++ return bmcr; ++ } ++ timeout++; ++ } while ((bmcr & BMCR_RESET) && (timeout < 100)); ++ ++ if (timeout >= 100) { ++ netdev_warn(dev->net, "timeout on PHY Reset\n"); ++ return -EIO; ++ } ++ ++ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, ++ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | ++ ADVERTISE_PAUSE_ASYM); ++ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, MII_CTRL1000, ++ ADVERTISE_1000FULL); ++ ++ /* read and write to clear phy interrupt status */ ++ ret = smsc75xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PHY_INT_SRC\n"); ++ return ret; ++ } ++ ++ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_SRC, 0xffff); ++ ++ smsc75xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, ++ PHY_INT_MASK_DEFAULT); ++ mii_nway_restart(&dev->mii); ++ ++ netif_dbg(dev, ifup, dev->net, "phy initialised successfully\n"); ++ return 0; ++} ++ ++static int smsc75xx_set_rx_max_frame_length(struct usbnet *dev, int size) ++{ ++ int ret = 0; ++ u32 buf; ++ bool rxenabled; ++ ++ ret = smsc75xx_read_reg(dev, MAC_RX, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret); ++ return ret; ++ } ++ ++ rxenabled = ((buf & MAC_RX_RXEN) != 0); ++ ++ if (rxenabled) { ++ buf &= ~MAC_RX_RXEN; ++ ret = smsc75xx_write_reg(dev, MAC_RX, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); ++ return ret; ++ } ++ } ++ ++ /* add 4 to size for FCS */ ++ buf &= ~MAC_RX_MAX_SIZE; ++ buf |= (((size + 4) << MAC_RX_MAX_SIZE_SHIFT) & MAC_RX_MAX_SIZE); ++ ++ ret = smsc75xx_write_reg(dev, MAC_RX, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); ++ return ret; ++ } ++ ++ if (rxenabled) { ++ buf |= MAC_RX_RXEN; ++ ret = smsc75xx_write_reg(dev, MAC_RX, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); ++ return ret; ++ } ++ } ++ ++ return 0; ++} ++ ++static int smsc75xx_change_mtu(struct net_device *netdev, int new_mtu) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ int ret; ++ ++ if (new_mtu > MAX_SINGLE_PACKET_SIZE) ++ return -EINVAL; ++ ++ ret = smsc75xx_set_rx_max_frame_length(dev, new_mtu + ETH_HLEN); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to set mac rx frame length\n"); ++ return ret; ++ } ++ ++ return usbnet_change_mtu(netdev, new_mtu); ++} ++ ++/* Enable or disable Rx checksum offload engine */ ++static int smsc75xx_set_features(struct net_device *netdev, ++ netdev_features_t features) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ unsigned long flags; ++ int ret; ++ ++ spin_lock_irqsave(&pdata->rfe_ctl_lock, flags); ++ ++ if (features & NETIF_F_RXCSUM) ++ pdata->rfe_ctl |= RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM; ++ else ++ pdata->rfe_ctl &= ~(RFE_CTL_TCPUDP_CKM | RFE_CTL_IP_CKM); ++ ++ spin_unlock_irqrestore(&pdata->rfe_ctl_lock, flags); ++ /* it's racing here! */ ++ ++ ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); ++ if (ret < 0) ++ netdev_warn(dev->net, "Error writing RFE_CTL\n"); ++ ++ return ret; ++} ++ ++static int smsc75xx_wait_ready(struct usbnet *dev, int in_pm) ++{ ++ int timeout = 0; ++ ++ do { ++ u32 buf; ++ int ret; ++ ++ ret = __smsc75xx_read_reg(dev, PMT_CTL, &buf, in_pm); ++ ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ if (buf & PMT_CTL_DEV_RDY) ++ return 0; ++ ++ msleep(10); ++ timeout++; ++ } while (timeout < 100); ++ ++ netdev_warn(dev->net, "timeout waiting for device ready\n"); ++ return -EIO; ++} ++ ++static int smsc75xx_reset(struct usbnet *dev) ++{ ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ u32 buf; ++ int ret = 0, timeout; ++ ++ netif_dbg(dev, ifup, dev->net, "entering smsc75xx_reset\n"); ++ ++ ret = smsc75xx_wait_ready(dev, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "device not ready in smsc75xx_reset\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ buf |= HW_CFG_LRST; ++ ++ ret = smsc75xx_write_reg(dev, HW_CFG, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ timeout = 0; ++ do { ++ msleep(10); ++ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); ++ return ret; ++ } ++ timeout++; ++ } while ((buf & HW_CFG_LRST) && (timeout < 100)); ++ ++ if (timeout >= 100) { ++ netdev_warn(dev->net, "timeout on completion of Lite Reset\n"); ++ return -EIO; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "Lite reset complete, resetting PHY\n"); ++ ++ ret = smsc75xx_read_reg(dev, PMT_CTL, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ buf |= PMT_CTL_PHY_RST; ++ ++ ret = smsc75xx_write_reg(dev, PMT_CTL, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write PMT_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ timeout = 0; ++ do { ++ msleep(10); ++ ret = smsc75xx_read_reg(dev, PMT_CTL, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read PMT_CTL: %d\n", ret); ++ return ret; ++ } ++ timeout++; ++ } while ((buf & PMT_CTL_PHY_RST) && (timeout < 100)); ++ ++ if (timeout >= 100) { ++ netdev_warn(dev->net, "timeout waiting for PHY Reset\n"); ++ return -EIO; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "PHY reset complete\n"); ++ ++ ret = smsc75xx_set_mac_address(dev); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to set mac address\n"); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "MAC Address: %pM\n", ++ dev->net->dev_addr); ++ ++ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n", ++ buf); ++ ++ buf |= HW_CFG_BIR; ++ ++ ret = smsc75xx_write_reg(dev, HW_CFG, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG after writing HW_CFG_BIR: 0x%08x\n", ++ buf); ++ ++ if (!turbo_mode) { ++ buf = 0; ++ dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE; ++ } else if (dev->udev->speed == USB_SPEED_HIGH) { ++ buf = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE; ++ dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE; ++ } else { ++ buf = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE; ++ dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "rx_urb_size=%ld\n", ++ (ulong)dev->rx_urb_size); ++ ++ ret = smsc75xx_write_reg(dev, BURST_CAP, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write BURST_CAP: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, BURST_CAP, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read BURST_CAP: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, ++ "Read Value from BURST_CAP after writing: 0x%08x\n", buf); ++ ++ ret = smsc75xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write BULK_IN_DLY: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, BULK_IN_DLY, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read BULK_IN_DLY: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, ++ "Read Value from BULK_IN_DLY after writing: 0x%08x\n", buf); ++ ++ if (turbo_mode) { ++ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf); ++ ++ buf |= (HW_CFG_MEF | HW_CFG_BCE); ++ ++ ret = smsc75xx_write_reg(dev, HW_CFG, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write HW_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, HW_CFG, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read HW_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "HW_CFG: 0x%08x\n", buf); ++ } ++ ++ /* set FIFO sizes */ ++ buf = (MAX_RX_FIFO_SIZE - 512) / 512; ++ ret = smsc75xx_write_reg(dev, FCT_RX_FIFO_END, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write FCT_RX_FIFO_END: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "FCT_RX_FIFO_END set to 0x%08x\n", buf); ++ ++ buf = (MAX_TX_FIFO_SIZE - 512) / 512; ++ ret = smsc75xx_write_reg(dev, FCT_TX_FIFO_END, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write FCT_TX_FIFO_END: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "FCT_TX_FIFO_END set to 0x%08x\n", buf); ++ ++ ret = smsc75xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write INT_STS: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, ID_REV, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read ID_REV: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", buf); ++ ++ ret = smsc75xx_read_reg(dev, E2P_CMD, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read E2P_CMD: %d\n", ret); ++ return ret; ++ } ++ ++ /* only set default GPIO/LED settings if no EEPROM is detected */ ++ if (!(buf & E2P_CMD_LOADED)) { ++ ret = smsc75xx_read_reg(dev, LED_GPIO_CFG, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read LED_GPIO_CFG: %d\n", ret); ++ return ret; ++ } ++ ++ buf &= ~(LED_GPIO_CFG_LED2_FUN_SEL | LED_GPIO_CFG_LED10_FUN_SEL); ++ buf |= LED_GPIO_CFG_LEDGPIO_EN | LED_GPIO_CFG_LED2_FUN_SEL; ++ ++ ret = smsc75xx_write_reg(dev, LED_GPIO_CFG, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write LED_GPIO_CFG: %d\n", ret); ++ return ret; ++ } ++ } ++ ++ ret = smsc75xx_write_reg(dev, FLOW, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write FLOW: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_write_reg(dev, FCT_FLOW, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write FCT_FLOW: %d\n", ret); ++ return ret; ++ } ++ ++ /* Don't need rfe_ctl_lock during initialisation */ ++ ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read RFE_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ pdata->rfe_ctl |= RFE_CTL_AB | RFE_CTL_DPF; ++ ++ ret = smsc75xx_write_reg(dev, RFE_CTL, pdata->rfe_ctl); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write RFE_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, RFE_CTL, &pdata->rfe_ctl); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read RFE_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "RFE_CTL set to 0x%08x\n", ++ pdata->rfe_ctl); ++ ++ /* Enable or disable checksum offload engines */ ++ smsc75xx_set_features(dev->net, dev->net->features); ++ ++ smsc75xx_set_multicast(dev->net); ++ ++ ret = smsc75xx_phy_initialize(dev); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to initialize PHY: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, INT_EP_CTL, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read INT_EP_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ /* enable PHY interrupts */ ++ buf |= INT_ENP_PHY_INT; ++ ++ ret = smsc75xx_write_reg(dev, INT_EP_CTL, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write INT_EP_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ /* allow mac to detect speed and duplex from phy */ ++ ret = smsc75xx_read_reg(dev, MAC_CR, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read MAC_CR: %d\n", ret); ++ return ret; ++ } ++ ++ buf |= (MAC_CR_ADD | MAC_CR_ASD); ++ ret = smsc75xx_write_reg(dev, MAC_CR, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write MAC_CR: %d\n", ret); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, MAC_TX, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read MAC_TX: %d\n", ret); ++ return ret; ++ } ++ ++ buf |= MAC_TX_TXEN; ++ ++ ret = smsc75xx_write_reg(dev, MAC_TX, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write MAC_TX: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "MAC_TX set to 0x%08x\n", buf); ++ ++ ret = smsc75xx_read_reg(dev, FCT_TX_CTL, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read FCT_TX_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ buf |= FCT_TX_CTL_EN; ++ ++ ret = smsc75xx_write_reg(dev, FCT_TX_CTL, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write FCT_TX_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "FCT_TX_CTL set to 0x%08x\n", buf); ++ ++ ret = smsc75xx_set_rx_max_frame_length(dev, dev->net->mtu + ETH_HLEN); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to set max rx frame length\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_read_reg(dev, MAC_RX, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret); ++ return ret; ++ } ++ ++ buf |= MAC_RX_RXEN; ++ ++ ret = smsc75xx_write_reg(dev, MAC_RX, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "MAC_RX set to 0x%08x\n", buf); ++ ++ ret = smsc75xx_read_reg(dev, FCT_RX_CTL, &buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read FCT_RX_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ buf |= FCT_RX_CTL_EN; ++ ++ ret = smsc75xx_write_reg(dev, FCT_RX_CTL, buf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write FCT_RX_CTL: %d\n", ret); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "FCT_RX_CTL set to 0x%08x\n", buf); ++ ++ netif_dbg(dev, ifup, dev->net, "smsc75xx_reset, return 0\n"); ++ return 0; ++} ++ ++static const struct net_device_ops smsc75xx_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = smsc75xx_change_mtu, ++ .ndo_set_mac_address = eth_mac_addr, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = smsc75xx_ioctl, ++ .ndo_set_rx_mode = smsc75xx_set_multicast, ++ .ndo_set_features = smsc75xx_set_features, ++}; ++ ++static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ struct smsc75xx_priv *pdata = NULL; ++ int ret; ++ ++ printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); ++ ++ ret = usbnet_get_endpoints(dev, intf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret); ++ return ret; ++ } ++ ++ dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc75xx_priv), ++ GFP_KERNEL); ++ ++ pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ if (!pdata) ++ return -ENOMEM; ++ ++ pdata->dev = dev; ++ ++ spin_lock_init(&pdata->rfe_ctl_lock); ++ mutex_init(&pdata->dataport_mutex); ++ ++ INIT_WORK(&pdata->set_multicast, smsc75xx_deferred_multicast_write); ++ ++ if (DEFAULT_TX_CSUM_ENABLE) ++ dev->net->features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM; ++ ++ if (DEFAULT_RX_CSUM_ENABLE) ++ dev->net->features |= NETIF_F_RXCSUM; ++ ++ dev->net->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | ++ NETIF_F_RXCSUM; ++ ++ ret = smsc75xx_wait_ready(dev, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "device not ready in smsc75xx_bind\n"); ++ return ret; ++ } ++ ++ smsc75xx_init_mac_address(dev); ++ ++ /* Init all registers */ ++ ret = smsc75xx_reset(dev); ++ if (ret < 0) { ++ netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret); ++ return ret; ++ } ++ ++ dev->net->netdev_ops = &smsc75xx_netdev_ops; ++ dev->net->ethtool_ops = &smsc75xx_ethtool_ops; ++ dev->net->flags |= IFF_MULTICAST; ++ dev->net->hard_header_len += SMSC75XX_TX_OVERHEAD; ++ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; ++ return 0; ++} ++ ++static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ if (pdata) { ++ netif_dbg(dev, ifdown, dev->net, "free pdata\n"); ++ kfree(pdata); ++ pdata = NULL; ++ dev->data[0] = 0; ++ } ++} ++ ++static u16 smsc_crc(const u8 *buffer, size_t len) ++{ ++ return bitrev16(crc16(0xFFFF, buffer, len)); ++} ++ ++static int smsc75xx_write_wuff(struct usbnet *dev, int filter, u32 wuf_cfg, ++ u32 wuf_mask1) ++{ ++ int cfg_base = WUF_CFGX + filter * 4; ++ int mask_base = WUF_MASKX + filter * 16; ++ int ret; ++ ++ ret = smsc75xx_write_reg(dev, cfg_base, wuf_cfg); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUF_CFGX\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_write_reg(dev, mask_base, wuf_mask1); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUF_MASKX\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_write_reg(dev, mask_base + 4, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUF_MASKX\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_write_reg(dev, mask_base + 8, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUF_MASKX\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_write_reg(dev, mask_base + 12, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUF_MASKX\n"); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int smsc75xx_enter_suspend0(struct usbnet *dev) ++{ ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ u32 val; ++ int ret; ++ ++ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PMT_CTL\n"); ++ return ret; ++ } ++ ++ val &= (~(PMT_CTL_SUS_MODE | PMT_CTL_PHY_RST)); ++ val |= PMT_CTL_SUS_MODE_0 | PMT_CTL_WOL_EN | PMT_CTL_WUPS; ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ return ret; ++ } ++ ++ pdata->suspend_flags |= SUSPEND_SUSPEND0; ++ ++ return 0; ++} ++ ++static int smsc75xx_enter_suspend1(struct usbnet *dev) ++{ ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ u32 val; ++ int ret; ++ ++ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PMT_CTL\n"); ++ return ret; ++ } ++ ++ val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); ++ val |= PMT_CTL_SUS_MODE_1; ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ return ret; ++ } ++ ++ /* clear wol status, enable energy detection */ ++ val &= ~PMT_CTL_WUPS; ++ val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN); ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ return ret; ++ } ++ ++ pdata->suspend_flags |= SUSPEND_SUSPEND1; ++ ++ return 0; ++} ++ ++static int smsc75xx_enter_suspend2(struct usbnet *dev) ++{ ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ u32 val; ++ int ret; ++ ++ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PMT_CTL\n"); ++ return ret; ++ } ++ ++ val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); ++ val |= PMT_CTL_SUS_MODE_2; ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ return ret; ++ } ++ ++ pdata->suspend_flags |= SUSPEND_SUSPEND2; ++ ++ return 0; ++} ++ ++static int smsc75xx_enter_suspend3(struct usbnet *dev) ++{ ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ u32 val; ++ int ret; ++ ++ ret = smsc75xx_read_reg_nopm(dev, FCT_RX_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading FCT_RX_CTL\n"); ++ return ret; ++ } ++ ++ if (val & FCT_RX_CTL_RXUSED) { ++ netdev_dbg(dev->net, "rx fifo not empty in autosuspend\n"); ++ return -EBUSY; ++ } ++ ++ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PMT_CTL\n"); ++ return ret; ++ } ++ ++ val &= ~(PMT_CTL_SUS_MODE | PMT_CTL_WUPS | PMT_CTL_PHY_RST); ++ val |= PMT_CTL_SUS_MODE_3 | PMT_CTL_RES_CLR_WKP_EN; ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ return ret; ++ } ++ ++ /* clear wol status */ ++ val &= ~PMT_CTL_WUPS; ++ val |= PMT_CTL_WUPS_WOL; ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ return ret; ++ } ++ ++ pdata->suspend_flags |= SUSPEND_SUSPEND3; ++ ++ return 0; ++} ++ ++static int smsc75xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) ++{ ++ struct mii_if_info *mii = &dev->mii; ++ int ret; ++ ++ netdev_dbg(dev->net, "enabling PHY wakeup interrupts\n"); ++ ++ /* read to clear */ ++ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PHY_INT_SRC\n"); ++ return ret; ++ } ++ ++ /* enable interrupt source */ ++ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PHY_INT_MASK\n"); ++ return ret; ++ } ++ ++ ret |= mask; ++ ++ smsc75xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_INT_MASK, ret); ++ ++ return 0; ++} ++ ++static int smsc75xx_link_ok_nopm(struct usbnet *dev) ++{ ++ struct mii_if_info *mii = &dev->mii; ++ int ret; ++ ++ /* first, a dummy read, needed to latch some MII phys */ ++ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading MII_BMSR\n"); ++ return ret; ++ } ++ ++ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading MII_BMSR\n"); ++ return ret; ++ } ++ ++ return !!(ret & BMSR_LSTATUS); ++} ++ ++static int smsc75xx_autosuspend(struct usbnet *dev, u32 link_up) ++{ ++ int ret; ++ ++ if (!netif_running(dev->net)) { ++ /* interface is ifconfig down so fully power down hw */ ++ netdev_dbg(dev->net, "autosuspend entering SUSPEND2\n"); ++ return smsc75xx_enter_suspend2(dev); ++ } ++ ++ if (!link_up) { ++ /* link is down so enter EDPD mode */ ++ netdev_dbg(dev->net, "autosuspend entering SUSPEND1\n"); ++ ++ /* enable PHY wakeup events for if cable is attached */ ++ ret = smsc75xx_enable_phy_wakeup_interrupts(dev, ++ PHY_INT_MASK_ANEG_COMP); ++ if (ret < 0) { ++ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); ++ return ret; ++ } ++ ++ netdev_info(dev->net, "entering SUSPEND1 mode\n"); ++ return smsc75xx_enter_suspend1(dev); ++ } ++ ++ /* enable PHY wakeup events so we remote wakeup if cable is pulled */ ++ ret = smsc75xx_enable_phy_wakeup_interrupts(dev, ++ PHY_INT_MASK_LINK_DOWN); ++ if (ret < 0) { ++ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); ++ return ret; ++ } ++ ++ netdev_dbg(dev->net, "autosuspend entering SUSPEND3\n"); ++ return smsc75xx_enter_suspend3(dev); ++} ++ ++static int smsc75xx_suspend(struct usb_interface *intf, pm_message_t message) ++{ ++ struct usbnet *dev = usb_get_intfdata(intf); ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ u32 val, link_up; ++ int ret; ++ ++ ret = usbnet_suspend(intf, message); ++ if (ret < 0) { ++ netdev_warn(dev->net, "usbnet_suspend error\n"); ++ return ret; ++ } ++ ++ if (pdata->suspend_flags) { ++ netdev_warn(dev->net, "error during last resume\n"); ++ pdata->suspend_flags = 0; ++ } ++ ++ /* determine if link is up using only _nopm functions */ ++ link_up = smsc75xx_link_ok_nopm(dev); ++ ++ if (message.event == PM_EVENT_AUTO_SUSPEND) { ++ ret = smsc75xx_autosuspend(dev, link_up); ++ goto done; ++ } ++ ++ /* if we get this far we're not autosuspending */ ++ /* if no wol options set, or if link is down and we're not waking on ++ * PHY activity, enter lowest power SUSPEND2 mode ++ */ ++ if (!(pdata->wolopts & SUPPORTED_WAKE) || ++ !(link_up || (pdata->wolopts & WAKE_PHY))) { ++ netdev_info(dev->net, "entering SUSPEND2 mode\n"); ++ ++ /* disable energy detect (link up) & wake up events */ ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ goto done; ++ } ++ ++ val &= ~(WUCSR_MPEN | WUCSR_WUEN); ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ goto done; ++ } ++ ++ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PMT_CTL\n"); ++ goto done; ++ } ++ ++ val &= ~(PMT_CTL_ED_EN | PMT_CTL_WOL_EN); ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ goto done; ++ } ++ ++ ret = smsc75xx_enter_suspend2(dev); ++ goto done; ++ } ++ ++ if (pdata->wolopts & WAKE_PHY) { ++ ret = smsc75xx_enable_phy_wakeup_interrupts(dev, ++ (PHY_INT_MASK_ANEG_COMP | PHY_INT_MASK_LINK_DOWN)); ++ if (ret < 0) { ++ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); ++ goto done; ++ } ++ ++ /* if link is down then configure EDPD and enter SUSPEND1, ++ * otherwise enter SUSPEND0 below ++ */ ++ if (!link_up) { ++ struct mii_if_info *mii = &dev->mii; ++ netdev_info(dev->net, "entering SUSPEND1 mode\n"); ++ ++ /* enable energy detect power-down mode */ ++ ret = smsc75xx_mdio_read_nopm(dev->net, mii->phy_id, ++ PHY_MODE_CTRL_STS); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PHY_MODE_CTRL_STS\n"); ++ goto done; ++ } ++ ++ ret |= MODE_CTRL_STS_EDPWRDOWN; ++ ++ smsc75xx_mdio_write_nopm(dev->net, mii->phy_id, ++ PHY_MODE_CTRL_STS, ret); ++ ++ /* enter SUSPEND1 mode */ ++ ret = smsc75xx_enter_suspend1(dev); ++ goto done; ++ } ++ } ++ ++ if (pdata->wolopts & (WAKE_MCAST | WAKE_ARP)) { ++ int i, filter = 0; ++ ++ /* disable all filters */ ++ for (i = 0; i < WUF_NUM; i++) { ++ ret = smsc75xx_write_reg_nopm(dev, WUF_CFGX + i * 4, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUF_CFGX\n"); ++ goto done; ++ } ++ } ++ ++ if (pdata->wolopts & WAKE_MCAST) { ++ const u8 mcast[] = {0x01, 0x00, 0x5E}; ++ netdev_info(dev->net, "enabling multicast detection\n"); ++ ++ val = WUF_CFGX_EN | WUF_CFGX_ATYPE_MULTICAST ++ | smsc_crc(mcast, 3); ++ ret = smsc75xx_write_wuff(dev, filter++, val, 0x0007); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing wakeup filter\n"); ++ goto done; ++ } ++ } ++ ++ if (pdata->wolopts & WAKE_ARP) { ++ const u8 arp[] = {0x08, 0x06}; ++ netdev_info(dev->net, "enabling ARP detection\n"); ++ ++ val = WUF_CFGX_EN | WUF_CFGX_ATYPE_ALL | (0x0C << 16) ++ | smsc_crc(arp, 2); ++ ret = smsc75xx_write_wuff(dev, filter++, val, 0x0003); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing wakeup filter\n"); ++ goto done; ++ } ++ } ++ ++ /* clear any pending pattern match packet status */ ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ goto done; ++ } ++ ++ val |= WUCSR_WUFR; ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ goto done; ++ } ++ ++ netdev_info(dev->net, "enabling packet match detection\n"); ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ goto done; ++ } ++ ++ val |= WUCSR_WUEN; ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ goto done; ++ } ++ } else { ++ netdev_info(dev->net, "disabling packet match detection\n"); ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ goto done; ++ } ++ ++ val &= ~WUCSR_WUEN; ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ goto done; ++ } ++ } ++ ++ /* disable magic, bcast & unicast wakeup sources */ ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ goto done; ++ } ++ ++ val &= ~(WUCSR_MPEN | WUCSR_BCST_EN | WUCSR_PFDA_EN); ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ goto done; ++ } ++ ++ if (pdata->wolopts & WAKE_PHY) { ++ netdev_info(dev->net, "enabling PHY wakeup\n"); ++ ++ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PMT_CTL\n"); ++ goto done; ++ } ++ ++ /* clear wol status, enable energy detection */ ++ val &= ~PMT_CTL_WUPS; ++ val |= (PMT_CTL_WUPS_ED | PMT_CTL_ED_EN); ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ goto done; ++ } ++ } ++ ++ if (pdata->wolopts & WAKE_MAGIC) { ++ netdev_info(dev->net, "enabling magic packet wakeup\n"); ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ goto done; ++ } ++ ++ /* clear any pending magic packet status */ ++ val |= WUCSR_MPR | WUCSR_MPEN; ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ goto done; ++ } ++ } ++ ++ if (pdata->wolopts & WAKE_BCAST) { ++ netdev_info(dev->net, "enabling broadcast detection\n"); ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ goto done; ++ } ++ ++ val |= WUCSR_BCAST_FR | WUCSR_BCST_EN; ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ goto done; ++ } ++ } ++ ++ if (pdata->wolopts & WAKE_UCAST) { ++ netdev_info(dev->net, "enabling unicast detection\n"); ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ goto done; ++ } ++ ++ val |= WUCSR_WUFR | WUCSR_PFDA_EN; ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ goto done; ++ } ++ } ++ ++ /* enable receiver to enable frame reception */ ++ ret = smsc75xx_read_reg_nopm(dev, MAC_RX, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read MAC_RX: %d\n", ret); ++ goto done; ++ } ++ ++ val |= MAC_RX_RXEN; ++ ++ ret = smsc75xx_write_reg_nopm(dev, MAC_RX, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to write MAC_RX: %d\n", ret); ++ goto done; ++ } ++ ++ /* some wol options are enabled, so enter SUSPEND0 */ ++ netdev_info(dev->net, "entering SUSPEND0 mode\n"); ++ ret = smsc75xx_enter_suspend0(dev); ++ ++done: ++ /* ++ * TODO: resume() might need to handle the suspend failure ++ * in system sleep ++ */ ++ if (ret && PMSG_IS_AUTO(message)) ++ usbnet_resume(intf); ++ return ret; ++} ++ ++static int smsc75xx_resume(struct usb_interface *intf) ++{ ++ struct usbnet *dev = usb_get_intfdata(intf); ++ struct smsc75xx_priv *pdata = (struct smsc75xx_priv *)(dev->data[0]); ++ u8 suspend_flags = pdata->suspend_flags; ++ int ret; ++ u32 val; ++ ++ netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags); ++ ++ /* do this first to ensure it's cleared even in error case */ ++ pdata->suspend_flags = 0; ++ ++ if (suspend_flags & SUSPEND_ALLMODES) { ++ /* Disable wakeup sources */ ++ ret = smsc75xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading WUCSR\n"); ++ return ret; ++ } ++ ++ val &= ~(WUCSR_WUEN | WUCSR_MPEN | WUCSR_PFDA_EN ++ | WUCSR_BCST_EN); ++ ++ ret = smsc75xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing WUCSR\n"); ++ return ret; ++ } ++ ++ /* clear wake-up status */ ++ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PMT_CTL\n"); ++ return ret; ++ } ++ ++ val &= ~PMT_CTL_WOL_EN; ++ val |= PMT_CTL_WUPS; ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ return ret; ++ } ++ } ++ ++ if (suspend_flags & SUSPEND_SUSPEND2) { ++ netdev_info(dev->net, "resuming from SUSPEND2\n"); ++ ++ ret = smsc75xx_read_reg_nopm(dev, PMT_CTL, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading PMT_CTL\n"); ++ return ret; ++ } ++ ++ val |= PMT_CTL_PHY_PWRUP; ++ ++ ret = smsc75xx_write_reg_nopm(dev, PMT_CTL, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing PMT_CTL\n"); ++ return ret; ++ } ++ } ++ ++ ret = smsc75xx_wait_ready(dev, 1); ++ if (ret < 0) { ++ netdev_warn(dev->net, "device not ready in smsc75xx_resume\n"); ++ return ret; ++ } ++ ++ return usbnet_resume(intf); ++} ++ ++static void smsc75xx_rx_csum_offload(struct usbnet *dev, struct sk_buff *skb, ++ u32 rx_cmd_a, u32 rx_cmd_b) ++{ ++ if (!(dev->net->features & NETIF_F_RXCSUM) || ++ unlikely(rx_cmd_a & RX_CMD_A_LCSM)) { ++ skb->ip_summed = CHECKSUM_NONE; ++ } else { ++ skb->csum = ntohs((u16)(rx_cmd_b >> RX_CMD_B_CSUM_SHIFT)); ++ skb->ip_summed = CHECKSUM_COMPLETE; ++ } ++} ++ ++static int smsc75xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ /* This check is no longer done by usbnet */ ++ if (skb->len < dev->net->hard_header_len) ++ return 0; ++ ++ while (skb->len > 0) { ++ u32 rx_cmd_a, rx_cmd_b, align_count, size; ++ struct sk_buff *ax_skb; ++ unsigned char *packet; ++ ++ memcpy(&rx_cmd_a, skb->data, sizeof(rx_cmd_a)); ++ le32_to_cpus(&rx_cmd_a); ++ skb_pull(skb, 4); ++ ++ memcpy(&rx_cmd_b, skb->data, sizeof(rx_cmd_b)); ++ le32_to_cpus(&rx_cmd_b); ++ skb_pull(skb, 4 + RXW_PADDING); ++ ++ packet = skb->data; ++ ++ /* get the packet length */ ++ size = (rx_cmd_a & RX_CMD_A_LEN) - RXW_PADDING; ++ align_count = (4 - ((size + RXW_PADDING) % 4)) % 4; ++ ++ if (unlikely(rx_cmd_a & RX_CMD_A_RED)) { ++ netif_dbg(dev, rx_err, dev->net, ++ "Error rx_cmd_a=0x%08x\n", rx_cmd_a); ++ dev->net->stats.rx_errors++; ++ dev->net->stats.rx_dropped++; ++ ++ if (rx_cmd_a & RX_CMD_A_FCS) ++ dev->net->stats.rx_crc_errors++; ++ else if (rx_cmd_a & (RX_CMD_A_LONG | RX_CMD_A_RUNT)) ++ dev->net->stats.rx_frame_errors++; ++ } else { ++ /* MAX_SINGLE_PACKET_SIZE + 4(CRC) + 2(COE) + 4(Vlan) */ ++ if (unlikely(size > (MAX_SINGLE_PACKET_SIZE + ETH_HLEN + 12))) { ++ netif_dbg(dev, rx_err, dev->net, ++ "size err rx_cmd_a=0x%08x\n", ++ rx_cmd_a); ++ return 0; ++ } ++ ++ /* last frame in this batch */ ++ if (skb->len == size) { ++ smsc75xx_rx_csum_offload(dev, skb, rx_cmd_a, ++ rx_cmd_b); ++ ++ skb_trim(skb, skb->len - 4); /* remove fcs */ ++ skb->truesize = size + sizeof(struct sk_buff); ++ ++ return 1; ++ } ++ ++ ax_skb = skb_clone(skb, GFP_ATOMIC); ++ if (unlikely(!ax_skb)) { ++ netdev_warn(dev->net, "Error allocating skb\n"); ++ return 0; ++ } ++ ++ ax_skb->len = size; ++ ax_skb->data = packet; ++ skb_set_tail_pointer(ax_skb, size); ++ ++ smsc75xx_rx_csum_offload(dev, ax_skb, rx_cmd_a, ++ rx_cmd_b); ++ ++ skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */ ++ ax_skb->truesize = size + sizeof(struct sk_buff); ++ ++ usbnet_skb_return(dev, ax_skb); ++ } ++ ++ skb_pull(skb, size); ++ ++ /* padding bytes before the next frame starts */ ++ if (skb->len) ++ skb_pull(skb, align_count); ++ } ++ ++ if (unlikely(skb->len < 0)) { ++ netdev_warn(dev->net, "invalid rx length<0 %d\n", skb->len); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static struct sk_buff *smsc75xx_tx_fixup(struct usbnet *dev, ++ struct sk_buff *skb, gfp_t flags) ++{ ++ u32 tx_cmd_a, tx_cmd_b; ++ ++ if (skb_headroom(skb) < SMSC75XX_TX_OVERHEAD) { ++ struct sk_buff *skb2 = ++ skb_copy_expand(skb, SMSC75XX_TX_OVERHEAD, 0, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (!skb) ++ return NULL; ++ } ++ ++ tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN) | TX_CMD_A_FCS; ++ ++ if (skb->ip_summed == CHECKSUM_PARTIAL) ++ tx_cmd_a |= TX_CMD_A_IPE | TX_CMD_A_TPE; ++ ++ if (skb_is_gso(skb)) { ++ u16 mss = max(skb_shinfo(skb)->gso_size, TX_MSS_MIN); ++ tx_cmd_b = (mss << TX_CMD_B_MSS_SHIFT) & TX_CMD_B_MSS; ++ ++ tx_cmd_a |= TX_CMD_A_LSO; ++ } else { ++ tx_cmd_b = 0; ++ } ++ ++ skb_push(skb, 4); ++ cpu_to_le32s(&tx_cmd_b); ++ memcpy(skb->data, &tx_cmd_b, 4); ++ ++ skb_push(skb, 4); ++ cpu_to_le32s(&tx_cmd_a); ++ memcpy(skb->data, &tx_cmd_a, 4); ++ ++ return skb; ++} ++ ++static int smsc75xx_manage_power(struct usbnet *dev, int on) ++{ ++ dev->intf->needs_remote_wakeup = on; ++ return 0; ++} ++ ++static const struct driver_info smsc75xx_info = { ++ .description = "smsc75xx USB 2.0 Gigabit Ethernet", ++ .bind = smsc75xx_bind, ++ .unbind = smsc75xx_unbind, ++ .link_reset = smsc75xx_link_reset, ++ .reset = smsc75xx_reset, ++ .rx_fixup = smsc75xx_rx_fixup, ++ .tx_fixup = smsc75xx_tx_fixup, ++ .status = smsc75xx_status, ++ .manage_power = smsc75xx_manage_power, ++ .flags = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR, ++}; ++ ++static const struct usb_device_id products[] = { ++ { ++ /* SMSC7500 USB Gigabit Ethernet Device */ ++ USB_DEVICE(USB_VENDOR_ID_SMSC, USB_PRODUCT_ID_LAN7500), ++ .driver_info = (unsigned long) &smsc75xx_info, ++ }, ++ { ++ /* SMSC7500 USB Gigabit Ethernet Device */ ++ USB_DEVICE(USB_VENDOR_ID_SMSC, USB_PRODUCT_ID_LAN7505), ++ .driver_info = (unsigned long) &smsc75xx_info, ++ }, ++ { }, /* END */ ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver smsc75xx_driver = { ++ .name = SMSC_CHIPNAME, ++ .id_table = products, ++ .probe = usbnet_probe, ++ .suspend = smsc75xx_suspend, ++ .resume = smsc75xx_resume, ++ .reset_resume = smsc75xx_resume, ++ .disconnect = usbnet_disconnect, ++ .disable_hub_initiated_lpm = 1, ++ .supports_autosuspend = 1, ++}; ++ ++module_usb_driver(smsc75xx_driver); ++ ++MODULE_AUTHOR("Nancy Lin"); ++MODULE_AUTHOR("Steve Glendinning steve.glendinning@shawell.net"); ++MODULE_DESCRIPTION("SMSC75XX USB 2.0 Gigabit Ethernet Devices"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/smsc75xx.h backports-4.2.6-1/drivers/net/usb/smsc75xx.h +--- backports-4.2.6-1.org/drivers/net/usb/smsc75xx.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/smsc75xx.h 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,421 @@ ++ /*************************************************************************** ++ * ++ * Copyright (C) 2007-2010 SMSC ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ * ++ *****************************************************************************/ ++ ++#ifndef _SMSC75XX_H ++#define _SMSC75XX_H ++ ++/* Tx command words */ ++#define TX_CMD_A_LSO (0x08000000) ++#define TX_CMD_A_IPE (0x04000000) ++#define TX_CMD_A_TPE (0x02000000) ++#define TX_CMD_A_IVTG (0x01000000) ++#define TX_CMD_A_RVTG (0x00800000) ++#define TX_CMD_A_FCS (0x00400000) ++#define TX_CMD_A_LEN (0x000FFFFF) ++ ++#define TX_CMD_B_MSS (0x3FFF0000) ++#define TX_CMD_B_MSS_SHIFT (16) ++#define TX_MSS_MIN ((u16)8) ++#define TX_CMD_B_VTAG (0x0000FFFF) ++ ++/* Rx command words */ ++#define RX_CMD_A_ICE (0x80000000) ++#define RX_CMD_A_TCE (0x40000000) ++#define RX_CMD_A_IPV (0x20000000) ++#define RX_CMD_A_PID (0x18000000) ++#define RX_CMD_A_PID_NIP (0x00000000) ++#define RX_CMD_A_PID_TCP (0x08000000) ++#define RX_CMD_A_PID_UDP (0x10000000) ++#define RX_CMD_A_PID_PP (0x18000000) ++#define RX_CMD_A_PFF (0x04000000) ++#define RX_CMD_A_BAM (0x02000000) ++#define RX_CMD_A_MAM (0x01000000) ++#define RX_CMD_A_FVTG (0x00800000) ++#define RX_CMD_A_RED (0x00400000) ++#define RX_CMD_A_RWT (0x00200000) ++#define RX_CMD_A_RUNT (0x00100000) ++#define RX_CMD_A_LONG (0x00080000) ++#define RX_CMD_A_RXE (0x00040000) ++#define RX_CMD_A_DRB (0x00020000) ++#define RX_CMD_A_FCS (0x00010000) ++#define RX_CMD_A_UAM (0x00008000) ++#define RX_CMD_A_LCSM (0x00004000) ++#define RX_CMD_A_LEN (0x00003FFF) ++ ++#define RX_CMD_B_CSUM (0xFFFF0000) ++#define RX_CMD_B_CSUM_SHIFT (16) ++#define RX_CMD_B_VTAG (0x0000FFFF) ++ ++/* SCSRs */ ++#define ID_REV (0x0000) ++ ++#define FPGA_REV (0x0004) ++ ++#define BOND_CTL (0x0008) ++ ++#define INT_STS (0x000C) ++#define INT_STS_RDFO_INT (0x00400000) ++#define INT_STS_TXE_INT (0x00200000) ++#define INT_STS_MACRTO_INT (0x00100000) ++#define INT_STS_TX_DIS_INT (0x00080000) ++#define INT_STS_RX_DIS_INT (0x00040000) ++#define INT_STS_PHY_INT_ (0x00020000) ++#define INT_STS_MAC_ERR_INT (0x00008000) ++#define INT_STS_TDFU (0x00004000) ++#define INT_STS_TDFO (0x00002000) ++#define INT_STS_GPIOS (0x00000FFF) ++#define INT_STS_CLEAR_ALL (0xFFFFFFFF) ++ ++#define HW_CFG (0x0010) ++#define HW_CFG_SMDET_STS (0x00008000) ++#define HW_CFG_SMDET_EN (0x00004000) ++#define HW_CFG_EEM (0x00002000) ++#define HW_CFG_RST_PROTECT (0x00001000) ++#define HW_CFG_PORT_SWAP (0x00000800) ++#define HW_CFG_PHY_BOOST (0x00000600) ++#define HW_CFG_PHY_BOOST_NORMAL (0x00000000) ++#define HW_CFG_PHY_BOOST_4 (0x00002000) ++#define HW_CFG_PHY_BOOST_8 (0x00004000) ++#define HW_CFG_PHY_BOOST_12 (0x00006000) ++#define HW_CFG_LEDB (0x00000100) ++#define HW_CFG_BIR (0x00000080) ++#define HW_CFG_SBP (0x00000040) ++#define HW_CFG_IME (0x00000020) ++#define HW_CFG_MEF (0x00000010) ++#define HW_CFG_ETC (0x00000008) ++#define HW_CFG_BCE (0x00000004) ++#define HW_CFG_LRST (0x00000002) ++#define HW_CFG_SRST (0x00000001) ++ ++#define PMT_CTL (0x0014) ++#define PMT_CTL_PHY_PWRUP (0x00000400) ++#define PMT_CTL_RES_CLR_WKP_EN (0x00000100) ++#define PMT_CTL_DEV_RDY (0x00000080) ++#define PMT_CTL_SUS_MODE (0x00000060) ++#define PMT_CTL_SUS_MODE_0 (0x00000000) ++#define PMT_CTL_SUS_MODE_1 (0x00000020) ++#define PMT_CTL_SUS_MODE_2 (0x00000040) ++#define PMT_CTL_SUS_MODE_3 (0x00000060) ++#define PMT_CTL_PHY_RST (0x00000010) ++#define PMT_CTL_WOL_EN (0x00000008) ++#define PMT_CTL_ED_EN (0x00000004) ++#define PMT_CTL_WUPS (0x00000003) ++#define PMT_CTL_WUPS_NO (0x00000000) ++#define PMT_CTL_WUPS_ED (0x00000001) ++#define PMT_CTL_WUPS_WOL (0x00000002) ++#define PMT_CTL_WUPS_MULTI (0x00000003) ++ ++#define LED_GPIO_CFG (0x0018) ++#define LED_GPIO_CFG_LED2_FUN_SEL (0x80000000) ++#define LED_GPIO_CFG_LED10_FUN_SEL (0x40000000) ++#define LED_GPIO_CFG_LEDGPIO_EN (0x0000F000) ++#define LED_GPIO_CFG_LEDGPIO_EN_0 (0x00001000) ++#define LED_GPIO_CFG_LEDGPIO_EN_1 (0x00002000) ++#define LED_GPIO_CFG_LEDGPIO_EN_2 (0x00004000) ++#define LED_GPIO_CFG_LEDGPIO_EN_3 (0x00008000) ++#define LED_GPIO_CFG_GPBUF (0x00000F00) ++#define LED_GPIO_CFG_GPBUF_0 (0x00000100) ++#define LED_GPIO_CFG_GPBUF_1 (0x00000200) ++#define LED_GPIO_CFG_GPBUF_2 (0x00000400) ++#define LED_GPIO_CFG_GPBUF_3 (0x00000800) ++#define LED_GPIO_CFG_GPDIR (0x000000F0) ++#define LED_GPIO_CFG_GPDIR_0 (0x00000010) ++#define LED_GPIO_CFG_GPDIR_1 (0x00000020) ++#define LED_GPIO_CFG_GPDIR_2 (0x00000040) ++#define LED_GPIO_CFG_GPDIR_3 (0x00000080) ++#define LED_GPIO_CFG_GPDATA (0x0000000F) ++#define LED_GPIO_CFG_GPDATA_0 (0x00000001) ++#define LED_GPIO_CFG_GPDATA_1 (0x00000002) ++#define LED_GPIO_CFG_GPDATA_2 (0x00000004) ++#define LED_GPIO_CFG_GPDATA_3 (0x00000008) ++ ++#define GPIO_CFG (0x001C) ++#define GPIO_CFG_SHIFT (24) ++#define GPIO_CFG_GPEN (0xFF000000) ++#define GPIO_CFG_GPBUF (0x00FF0000) ++#define GPIO_CFG_GPDIR (0x0000FF00) ++#define GPIO_CFG_GPDATA (0x000000FF) ++ ++#define GPIO_WAKE (0x0020) ++#define GPIO_WAKE_PHY_LINKUP_EN (0x80000000) ++#define GPIO_WAKE_POL (0x0FFF0000) ++#define GPIO_WAKE_POL_SHIFT (16) ++#define GPIO_WAKE_WK (0x00000FFF) ++ ++#define DP_SEL (0x0024) ++#define DP_SEL_DPRDY (0x80000000) ++#define DP_SEL_RSEL (0x0000000F) ++#define DP_SEL_URX (0x00000000) ++#define DP_SEL_VHF (0x00000001) ++#define DP_SEL_VHF_HASH_LEN (16) ++#define DP_SEL_VHF_VLAN_LEN (128) ++#define DP_SEL_LSO_HEAD (0x00000002) ++#define DP_SEL_FCT_RX (0x00000003) ++#define DP_SEL_FCT_TX (0x00000004) ++#define DP_SEL_DESCRIPTOR (0x00000005) ++#define DP_SEL_WOL (0x00000006) ++ ++#define DP_CMD (0x0028) ++#define DP_CMD_WRITE (0x01) ++#define DP_CMD_READ (0x00) ++ ++#define DP_ADDR (0x002C) ++ ++#define DP_DATA (0x0030) ++ ++#define BURST_CAP (0x0034) ++#define BURST_CAP_MASK (0x0000000F) ++ ++#define INT_EP_CTL (0x0038) ++#define INT_EP_CTL_INTEP_ON (0x80000000) ++#define INT_EP_CTL_RDFO_EN (0x00400000) ++#define INT_EP_CTL_TXE_EN (0x00200000) ++#define INT_EP_CTL_MACROTO_EN (0x00100000) ++#define INT_EP_CTL_TX_DIS_EN (0x00080000) ++#define INT_EP_CTL_RX_DIS_EN (0x00040000) ++#define INT_EP_CTL_PHY_EN_ (0x00020000) ++#define INT_EP_CTL_MAC_ERR_EN (0x00008000) ++#define INT_EP_CTL_TDFU_EN (0x00004000) ++#define INT_EP_CTL_TDFO_EN (0x00002000) ++#define INT_EP_CTL_RX_FIFO_EN (0x00001000) ++#define INT_EP_CTL_GPIOX_EN (0x00000FFF) ++ ++#define BULK_IN_DLY (0x003C) ++#define BULK_IN_DLY_MASK (0xFFFF) ++ ++#define E2P_CMD (0x0040) ++#define E2P_CMD_BUSY (0x80000000) ++#define E2P_CMD_MASK (0x70000000) ++#define E2P_CMD_READ (0x00000000) ++#define E2P_CMD_EWDS (0x10000000) ++#define E2P_CMD_EWEN (0x20000000) ++#define E2P_CMD_WRITE (0x30000000) ++#define E2P_CMD_WRAL (0x40000000) ++#define E2P_CMD_ERASE (0x50000000) ++#define E2P_CMD_ERAL (0x60000000) ++#define E2P_CMD_RELOAD (0x70000000) ++#define E2P_CMD_TIMEOUT (0x00000400) ++#define E2P_CMD_LOADED (0x00000200) ++#define E2P_CMD_ADDR (0x000001FF) ++ ++#define MAX_EEPROM_SIZE (512) ++ ++#define E2P_DATA (0x0044) ++#define E2P_DATA_MASK_ (0x000000FF) ++ ++#define RFE_CTL (0x0060) ++#define RFE_CTL_TCPUDP_CKM (0x00001000) ++#define RFE_CTL_IP_CKM (0x00000800) ++#define RFE_CTL_AB (0x00000400) ++#define RFE_CTL_AM (0x00000200) ++#define RFE_CTL_AU (0x00000100) ++#define RFE_CTL_VS (0x00000080) ++#define RFE_CTL_UF (0x00000040) ++#define RFE_CTL_VF (0x00000020) ++#define RFE_CTL_SPF (0x00000010) ++#define RFE_CTL_MHF (0x00000008) ++#define RFE_CTL_DHF (0x00000004) ++#define RFE_CTL_DPF (0x00000002) ++#define RFE_CTL_RST_RF (0x00000001) ++ ++#define VLAN_TYPE (0x0064) ++#define VLAN_TYPE_MASK (0x0000FFFF) ++ ++#define FCT_RX_CTL (0x0090) ++#define FCT_RX_CTL_EN (0x80000000) ++#define FCT_RX_CTL_RST (0x40000000) ++#define FCT_RX_CTL_SBF (0x02000000) ++#define FCT_RX_CTL_OVERFLOW (0x01000000) ++#define FCT_RX_CTL_FRM_DROP (0x00800000) ++#define FCT_RX_CTL_RX_NOT_EMPTY (0x00400000) ++#define FCT_RX_CTL_RX_EMPTY (0x00200000) ++#define FCT_RX_CTL_RX_DISABLED (0x00100000) ++#define FCT_RX_CTL_RXUSED (0x0000FFFF) ++ ++#define FCT_TX_CTL (0x0094) ++#define FCT_TX_CTL_EN (0x80000000) ++#define FCT_TX_CTL_RST (0x40000000) ++#define FCT_TX_CTL_TX_NOT_EMPTY (0x00400000) ++#define FCT_TX_CTL_TX_EMPTY (0x00200000) ++#define FCT_TX_CTL_TX_DISABLED (0x00100000) ++#define FCT_TX_CTL_TXUSED (0x0000FFFF) ++ ++#define FCT_RX_FIFO_END (0x0098) ++#define FCT_RX_FIFO_END_MASK (0x0000007F) ++ ++#define FCT_TX_FIFO_END (0x009C) ++#define FCT_TX_FIFO_END_MASK (0x0000003F) ++ ++#define FCT_FLOW (0x00A0) ++#define FCT_FLOW_THRESHOLD_OFF (0x00007F00) ++#define FCT_FLOW_THRESHOLD_OFF_SHIFT (8) ++#define FCT_FLOW_THRESHOLD_ON (0x0000007F) ++ ++/* MAC CSRs */ ++#define MAC_CR (0x100) ++#define MAC_CR_ADP (0x00002000) ++#define MAC_CR_ADD (0x00001000) ++#define MAC_CR_ASD (0x00000800) ++#define MAC_CR_INT_LOOP (0x00000400) ++#define MAC_CR_BOLMT (0x000000C0) ++#define MAC_CR_FDPX (0x00000008) ++#define MAC_CR_CFG (0x00000006) ++#define MAC_CR_CFG_10 (0x00000000) ++#define MAC_CR_CFG_100 (0x00000002) ++#define MAC_CR_CFG_1000 (0x00000004) ++#define MAC_CR_RST (0x00000001) ++ ++#define MAC_RX (0x104) ++#define MAC_RX_MAX_SIZE (0x3FFF0000) ++#define MAC_RX_MAX_SIZE_SHIFT (16) ++#define MAC_RX_FCS_STRIP (0x00000010) ++#define MAC_RX_FSE (0x00000004) ++#define MAC_RX_RXD (0x00000002) ++#define MAC_RX_RXEN (0x00000001) ++ ++#define MAC_TX (0x108) ++#define MAC_TX_BFCS (0x00000004) ++#define MAC_TX_TXD (0x00000002) ++#define MAC_TX_TXEN (0x00000001) ++ ++#define FLOW (0x10C) ++#define FLOW_FORCE_FC (0x80000000) ++#define FLOW_TX_FCEN (0x40000000) ++#define FLOW_RX_FCEN (0x20000000) ++#define FLOW_FPF (0x10000000) ++#define FLOW_PAUSE_TIME (0x0000FFFF) ++ ++#define RAND_SEED (0x110) ++#define RAND_SEED_MASK (0x0000FFFF) ++ ++#define ERR_STS (0x114) ++#define ERR_STS_FCS_ERR (0x00000100) ++#define ERR_STS_LFRM_ERR (0x00000080) ++#define ERR_STS_RUNT_ERR (0x00000040) ++#define ERR_STS_COLLISION_ERR (0x00000010) ++#define ERR_STS_ALIGN_ERR (0x00000008) ++#define ERR_STS_URUN_ERR (0x00000004) ++ ++#define RX_ADDRH (0x118) ++#define RX_ADDRH_MASK (0x0000FFFF) ++ ++#define RX_ADDRL (0x11C) ++ ++#define MII_ACCESS (0x120) ++#define MII_ACCESS_PHY_ADDR (0x0000F800) ++#define MII_ACCESS_PHY_ADDR_SHIFT (11) ++#define MII_ACCESS_REG_ADDR (0x000007C0) ++#define MII_ACCESS_REG_ADDR_SHIFT (6) ++#define MII_ACCESS_READ (0x00000000) ++#define MII_ACCESS_WRITE (0x00000002) ++#define MII_ACCESS_BUSY (0x00000001) ++ ++#define MII_DATA (0x124) ++#define MII_DATA_MASK (0x0000FFFF) ++ ++#define WUCSR (0x140) ++#define WUCSR_PFDA_FR (0x00000080) ++#define WUCSR_WUFR (0x00000040) ++#define WUCSR_MPR (0x00000020) ++#define WUCSR_BCAST_FR (0x00000010) ++#define WUCSR_PFDA_EN (0x00000008) ++#define WUCSR_WUEN (0x00000004) ++#define WUCSR_MPEN (0x00000002) ++#define WUCSR_BCST_EN (0x00000001) ++ ++#define WUF_CFGX (0x144) ++#define WUF_CFGX_EN (0x80000000) ++#define WUF_CFGX_ATYPE (0x03000000) ++#define WUF_CFGX_ATYPE_UNICAST (0x00000000) ++#define WUF_CFGX_ATYPE_MULTICAST (0x02000000) ++#define WUF_CFGX_ATYPE_ALL (0x03000000) ++#define WUF_CFGX_PATTERN_OFFSET (0x007F0000) ++#define WUF_CFGX_PATTERN_OFFSET_SHIFT (16) ++#define WUF_CFGX_CRC16 (0x0000FFFF) ++#define WUF_NUM (8) ++ ++#define WUF_MASKX (0x170) ++#define WUF_MASKX_AVALID (0x80000000) ++#define WUF_MASKX_ATYPE (0x40000000) ++ ++#define ADDR_FILTX (0x300) ++#define ADDR_FILTX_FB_VALID (0x80000000) ++#define ADDR_FILTX_FB_TYPE (0x40000000) ++#define ADDR_FILTX_FB_ADDRHI (0x0000FFFF) ++#define ADDR_FILTX_SB_ADDRLO (0xFFFFFFFF) ++ ++#define WUCSR2 (0x500) ++#define WUCSR2_NS_RCD (0x00000040) ++#define WUCSR2_ARP_RCD (0x00000020) ++#define WUCSR2_TCPSYN_RCD (0x00000010) ++#define WUCSR2_NS_OFFLOAD (0x00000004) ++#define WUCSR2_ARP_OFFLOAD (0x00000002) ++#define WUCSR2_TCPSYN_OFFLOAD (0x00000001) ++ ++#define WOL_FIFO_STS (0x504) ++ ++#define IPV6_ADDRX (0x510) ++ ++#define IPV4_ADDRX (0x590) ++ ++ ++/* Vendor-specific PHY Definitions */ ++ ++/* Mode Control/Status Register */ ++#define PHY_MODE_CTRL_STS (17) ++#define MODE_CTRL_STS_EDPWRDOWN ((u16)0x2000) ++#define MODE_CTRL_STS_ENERGYON ((u16)0x0002) ++ ++#define PHY_INT_SRC (29) ++#define PHY_INT_SRC_ENERGY_ON ((u16)0x0080) ++#define PHY_INT_SRC_ANEG_COMP ((u16)0x0040) ++#define PHY_INT_SRC_REMOTE_FAULT ((u16)0x0020) ++#define PHY_INT_SRC_LINK_DOWN ((u16)0x0010) ++#define PHY_INT_SRC_CLEAR_ALL ((u16)0xffff) ++ ++#define PHY_INT_MASK (30) ++#define PHY_INT_MASK_ENERGY_ON ((u16)0x0080) ++#define PHY_INT_MASK_ANEG_COMP ((u16)0x0040) ++#define PHY_INT_MASK_REMOTE_FAULT ((u16)0x0020) ++#define PHY_INT_MASK_LINK_DOWN ((u16)0x0010) ++#define PHY_INT_MASK_DEFAULT (PHY_INT_MASK_ANEG_COMP | \ ++ PHY_INT_MASK_LINK_DOWN) ++ ++#define PHY_SPECIAL (31) ++#define PHY_SPECIAL_SPD ((u16)0x001C) ++#define PHY_SPECIAL_SPD_10HALF ((u16)0x0004) ++#define PHY_SPECIAL_SPD_10FULL ((u16)0x0014) ++#define PHY_SPECIAL_SPD_100HALF ((u16)0x0008) ++#define PHY_SPECIAL_SPD_100FULL ((u16)0x0018) ++ ++/* USB Vendor Requests */ ++#define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0 ++#define USB_VENDOR_REQUEST_READ_REGISTER 0xA1 ++#define USB_VENDOR_REQUEST_GET_STATS 0xA2 ++ ++/* Interrupt Endpoint status word bitfields */ ++#define INT_ENP_RDFO_INT ((u32)BIT(22)) ++#define INT_ENP_TXE_INT ((u32)BIT(21)) ++#define INT_ENP_TX_DIS_INT ((u32)BIT(19)) ++#define INT_ENP_RX_DIS_INT ((u32)BIT(18)) ++#define INT_ENP_PHY_INT ((u32)BIT(17)) ++#define INT_ENP_MAC_ERR_INT ((u32)BIT(15)) ++#define INT_ENP_RX_FIFO_DATA_INT ((u32)BIT(12)) ++ ++#endif /* _SMSC75XX_H */ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/smsc95xx.c backports-4.2.6-1/drivers/net/usb/smsc95xx.c +--- backports-4.2.6-1.org/drivers/net/usb/smsc95xx.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/smsc95xx.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,2032 @@ ++ /*************************************************************************** ++ * ++ * Copyright (C) 2007-2008 SMSC ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ * ++ *****************************************************************************/ ++ ++#include <linux/module.h> ++#include <linux/kmod.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/bitrev.h> ++#include <linux/crc16.h> ++#include <linux/crc32.h> ++#include <linux/usb/usbnet.h> ++#include <linux/slab.h> ++#include "smsc95xx.h" ++ ++#define SMSC_CHIPNAME "smsc95xx" ++#define SMSC_DRIVER_VERSION "1.0.4" ++#define HS_USB_PKT_SIZE (512) ++#define FS_USB_PKT_SIZE (64) ++#define DEFAULT_HS_BURST_CAP_SIZE (16 * 1024 + 5 * HS_USB_PKT_SIZE) ++#define DEFAULT_FS_BURST_CAP_SIZE (6 * 1024 + 33 * FS_USB_PKT_SIZE) ++#define DEFAULT_BULK_IN_DELAY (0x00002000) ++#define MAX_SINGLE_PACKET_SIZE (2048) ++#define LAN95XX_EEPROM_MAGIC (0x9500) ++#define EEPROM_MAC_OFFSET (0x01) ++#define DEFAULT_TX_CSUM_ENABLE (true) ++#define DEFAULT_RX_CSUM_ENABLE (true) ++#define SMSC95XX_INTERNAL_PHY_ID (1) ++#define SMSC95XX_TX_OVERHEAD (8) ++#define SMSC95XX_TX_OVERHEAD_CSUM (12) ++#define SUPPORTED_WAKE (WAKE_PHY | WAKE_UCAST | WAKE_BCAST | \ ++ WAKE_MCAST | WAKE_ARP | WAKE_MAGIC) ++ ++#define FEATURE_8_WAKEUP_FILTERS (0x01) ++#define FEATURE_PHY_NLP_CROSSOVER (0x02) ++#define FEATURE_REMOTE_WAKEUP (0x04) ++ ++#define SUSPEND_SUSPEND0 (0x01) ++#define SUSPEND_SUSPEND1 (0x02) ++#define SUSPEND_SUSPEND2 (0x04) ++#define SUSPEND_SUSPEND3 (0x08) ++#define SUSPEND_ALLMODES (SUSPEND_SUSPEND0 | SUSPEND_SUSPEND1 | \ ++ SUSPEND_SUSPEND2 | SUSPEND_SUSPEND3) ++ ++struct smsc95xx_priv { ++ u32 mac_cr; ++ u32 hash_hi; ++ u32 hash_lo; ++ u32 wolopts; ++ spinlock_t mac_cr_lock; ++ u8 features; ++ u8 suspend_flags; ++}; ++ ++static bool turbo_mode = true; ++module_param(turbo_mode, bool, 0644); ++MODULE_PARM_DESC(turbo_mode, "Enable multiple frames per Rx transaction"); ++ ++static int __must_check __smsc95xx_read_reg(struct usbnet *dev, u32 index, ++ u32 *data, int in_pm) ++{ ++ u32 buf; ++ int ret; ++ int (*fn)(struct usbnet *, u8, u8, u16, u16, void *, u16); ++ ++ BUG_ON(!dev); ++ ++ if (!in_pm) ++ fn = usbnet_read_cmd; ++ else ++ fn = usbnet_read_cmd_nopm; ++ ++ ret = fn(dev, USB_VENDOR_REQUEST_READ_REGISTER, USB_DIR_IN ++ | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ 0, index, &buf, 4); ++ if (unlikely(ret < 0)) ++ netdev_warn(dev->net, "Failed to read reg index 0x%08x: %d\n", ++ index, ret); ++ ++ le32_to_cpus(&buf); ++ *data = buf; ++ ++ return ret; ++} ++ ++static int __must_check __smsc95xx_write_reg(struct usbnet *dev, u32 index, ++ u32 data, int in_pm) ++{ ++ u32 buf; ++ int ret; ++ int (*fn)(struct usbnet *, u8, u8, u16, u16, const void *, u16); ++ ++ BUG_ON(!dev); ++ ++ if (!in_pm) ++ fn = usbnet_write_cmd; ++ else ++ fn = usbnet_write_cmd_nopm; ++ ++ buf = data; ++ cpu_to_le32s(&buf); ++ ++ ret = fn(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, USB_DIR_OUT ++ | USB_TYPE_VENDOR | USB_RECIP_DEVICE, ++ 0, index, &buf, 4); ++ if (unlikely(ret < 0)) ++ netdev_warn(dev->net, "Failed to write reg index 0x%08x: %d\n", ++ index, ret); ++ ++ return ret; ++} ++ ++static int __must_check smsc95xx_read_reg_nopm(struct usbnet *dev, u32 index, ++ u32 *data) ++{ ++ return __smsc95xx_read_reg(dev, index, data, 1); ++} ++ ++static int __must_check smsc95xx_write_reg_nopm(struct usbnet *dev, u32 index, ++ u32 data) ++{ ++ return __smsc95xx_write_reg(dev, index, data, 1); ++} ++ ++static int __must_check smsc95xx_read_reg(struct usbnet *dev, u32 index, ++ u32 *data) ++{ ++ return __smsc95xx_read_reg(dev, index, data, 0); ++} ++ ++static int __must_check smsc95xx_write_reg(struct usbnet *dev, u32 index, ++ u32 data) ++{ ++ return __smsc95xx_write_reg(dev, index, data, 0); ++} ++ ++/* Loop until the read is completed with timeout ++ * called with phy_mutex held */ ++static int __must_check __smsc95xx_phy_wait_not_busy(struct usbnet *dev, ++ int in_pm) ++{ ++ unsigned long start_time = jiffies; ++ u32 val; ++ int ret; ++ ++ do { ++ ret = __smsc95xx_read_reg(dev, MII_ADDR, &val, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading MII_ACCESS\n"); ++ return ret; ++ } ++ ++ if (!(val & MII_BUSY_)) ++ return 0; ++ } while (!time_after(jiffies, start_time + HZ)); ++ ++ return -EIO; ++} ++ ++static int __smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx, ++ int in_pm) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u32 val, addr; ++ int ret; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ /* confirm MII not busy */ ++ ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_read\n"); ++ goto done; ++ } ++ ++ /* set the address, index & direction (read from PHY) */ ++ phy_id &= dev->mii.phy_id_mask; ++ idx &= dev->mii.reg_num_mask; ++ addr = (phy_id << 11) | (idx << 6) | MII_READ_ | MII_BUSY_; ++ ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing MII_ADDR\n"); ++ goto done; ++ } ++ ++ ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Timed out reading MII reg %02X\n", idx); ++ goto done; ++ } ++ ++ ret = __smsc95xx_read_reg(dev, MII_DATA, &val, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading MII_DATA\n"); ++ goto done; ++ } ++ ++ ret = (u16)(val & 0xFFFF); ++ ++done: ++ mutex_unlock(&dev->phy_mutex); ++ return ret; ++} ++ ++static void __smsc95xx_mdio_write(struct net_device *netdev, int phy_id, ++ int idx, int regval, int in_pm) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u32 val, addr; ++ int ret; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ /* confirm MII not busy */ ++ ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "MII is busy in smsc95xx_mdio_write\n"); ++ goto done; ++ } ++ ++ val = regval; ++ ret = __smsc95xx_write_reg(dev, MII_DATA, val, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing MII_DATA\n"); ++ goto done; ++ } ++ ++ /* set the address, index & direction (write to PHY) */ ++ phy_id &= dev->mii.phy_id_mask; ++ idx &= dev->mii.reg_num_mask; ++ addr = (phy_id << 11) | (idx << 6) | MII_WRITE_ | MII_BUSY_; ++ ret = __smsc95xx_write_reg(dev, MII_ADDR, addr, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing MII_ADDR\n"); ++ goto done; ++ } ++ ++ ret = __smsc95xx_phy_wait_not_busy(dev, in_pm); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Timed out writing MII reg %02X\n", idx); ++ goto done; ++ } ++ ++done: ++ mutex_unlock(&dev->phy_mutex); ++} ++ ++static int smsc95xx_mdio_read_nopm(struct net_device *netdev, int phy_id, ++ int idx) ++{ ++ return __smsc95xx_mdio_read(netdev, phy_id, idx, 1); ++} ++ ++static void smsc95xx_mdio_write_nopm(struct net_device *netdev, int phy_id, ++ int idx, int regval) ++{ ++ __smsc95xx_mdio_write(netdev, phy_id, idx, regval, 1); ++} ++ ++static int smsc95xx_mdio_read(struct net_device *netdev, int phy_id, int idx) ++{ ++ return __smsc95xx_mdio_read(netdev, phy_id, idx, 0); ++} ++ ++static void smsc95xx_mdio_write(struct net_device *netdev, int phy_id, int idx, ++ int regval) ++{ ++ __smsc95xx_mdio_write(netdev, phy_id, idx, regval, 0); ++} ++ ++static int __must_check smsc95xx_wait_eeprom(struct usbnet *dev) ++{ ++ unsigned long start_time = jiffies; ++ u32 val; ++ int ret; ++ ++ do { ++ ret = smsc95xx_read_reg(dev, E2P_CMD, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading E2P_CMD\n"); ++ return ret; ++ } ++ ++ if (!(val & E2P_CMD_BUSY_) || (val & E2P_CMD_TIMEOUT_)) ++ break; ++ udelay(40); ++ } while (!time_after(jiffies, start_time + HZ)); ++ ++ if (val & (E2P_CMD_TIMEOUT_ | E2P_CMD_BUSY_)) { ++ netdev_warn(dev->net, "EEPROM read operation timeout\n"); ++ return -EIO; ++ } ++ ++ return 0; ++} ++ ++static int __must_check smsc95xx_eeprom_confirm_not_busy(struct usbnet *dev) ++{ ++ unsigned long start_time = jiffies; ++ u32 val; ++ int ret; ++ ++ do { ++ ret = smsc95xx_read_reg(dev, E2P_CMD, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading E2P_CMD\n"); ++ return ret; ++ } ++ ++ if (!(val & E2P_CMD_BUSY_)) ++ return 0; ++ ++ udelay(40); ++ } while (!time_after(jiffies, start_time + HZ)); ++ ++ netdev_warn(dev->net, "EEPROM is busy\n"); ++ return -EIO; ++} ++ ++static int smsc95xx_read_eeprom(struct usbnet *dev, u32 offset, u32 length, ++ u8 *data) ++{ ++ u32 val; ++ int i, ret; ++ ++ BUG_ON(!dev); ++ BUG_ON(!data); ++ ++ ret = smsc95xx_eeprom_confirm_not_busy(dev); ++ if (ret) ++ return ret; ++ ++ for (i = 0; i < length; i++) { ++ val = E2P_CMD_BUSY_ | E2P_CMD_READ_ | (offset & E2P_CMD_ADDR_); ++ ret = smsc95xx_write_reg(dev, E2P_CMD, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing E2P_CMD\n"); ++ return ret; ++ } ++ ++ ret = smsc95xx_wait_eeprom(dev); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_read_reg(dev, E2P_DATA, &val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error reading E2P_DATA\n"); ++ return ret; ++ } ++ ++ data[i] = val & 0xFF; ++ offset++; ++ } ++ ++ return 0; ++} ++ ++static int smsc95xx_write_eeprom(struct usbnet *dev, u32 offset, u32 length, ++ u8 *data) ++{ ++ u32 val; ++ int i, ret; ++ ++ BUG_ON(!dev); ++ BUG_ON(!data); ++ ++ ret = smsc95xx_eeprom_confirm_not_busy(dev); ++ if (ret) ++ return ret; ++ ++ /* Issue write/erase enable command */ ++ val = E2P_CMD_BUSY_ | E2P_CMD_EWEN_; ++ ret = smsc95xx_write_reg(dev, E2P_CMD, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing E2P_DATA\n"); ++ return ret; ++ } ++ ++ ret = smsc95xx_wait_eeprom(dev); ++ if (ret < 0) ++ return ret; ++ ++ for (i = 0; i < length; i++) { ++ ++ /* Fill data register */ ++ val = data[i]; ++ ret = smsc95xx_write_reg(dev, E2P_DATA, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing E2P_DATA\n"); ++ return ret; ++ } ++ ++ /* Send "write" command */ ++ val = E2P_CMD_BUSY_ | E2P_CMD_WRITE_ | (offset & E2P_CMD_ADDR_); ++ ret = smsc95xx_write_reg(dev, E2P_CMD, val); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Error writing E2P_CMD\n"); ++ return ret; ++ } ++ ++ ret = smsc95xx_wait_eeprom(dev); ++ if (ret < 0) ++ return ret; ++ ++ offset++; ++ } ++ ++ return 0; ++} ++ ++static int __must_check smsc95xx_write_reg_async(struct usbnet *dev, u16 index, ++ u32 data) ++{ ++ const u16 size = 4; ++ u32 buf; ++ int ret; ++ ++ buf = data; ++ cpu_to_le32s(&buf); ++ ++ ret = usbnet_write_cmd_async(dev, USB_VENDOR_REQUEST_WRITE_REGISTER, ++ USB_DIR_OUT | USB_TYPE_VENDOR | ++ USB_RECIP_DEVICE, ++ 0, index, &buf, size); ++ if (ret < 0) ++ netdev_warn(dev->net, "Error write async cmd, sts=%d\n", ++ ret); ++ return ret; ++} ++ ++/* returns hash bit number for given MAC address ++ * example: ++ * 01 00 5E 00 00 01 -> returns bit number 31 */ ++static unsigned int smsc95xx_hash(char addr[ETH_ALEN]) ++{ ++ return (ether_crc(ETH_ALEN, addr) >> 26) & 0x3f; ++} ++ ++static void smsc95xx_set_multicast(struct net_device *netdev) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ unsigned long flags; ++ int ret; ++ ++ pdata->hash_hi = 0; ++ pdata->hash_lo = 0; ++ ++ spin_lock_irqsave(&pdata->mac_cr_lock, flags); ++ ++ if (dev->net->flags & IFF_PROMISC) { ++ netif_dbg(dev, drv, dev->net, "promiscuous mode enabled\n"); ++ pdata->mac_cr |= MAC_CR_PRMS_; ++ pdata->mac_cr &= ~(MAC_CR_MCPAS_ | MAC_CR_HPFILT_); ++ } else if (dev->net->flags & IFF_ALLMULTI) { ++ netif_dbg(dev, drv, dev->net, "receive all multicast enabled\n"); ++ pdata->mac_cr |= MAC_CR_MCPAS_; ++ pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_HPFILT_); ++ } else if (!netdev_mc_empty(dev->net)) { ++ struct netdev_hw_addr *ha; ++ ++ pdata->mac_cr |= MAC_CR_HPFILT_; ++ pdata->mac_cr &= ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_); ++ ++ netdev_for_each_mc_addr(ha, netdev) { ++ u32 bitnum = smsc95xx_hash(ha->addr); ++ u32 mask = 0x01 << (bitnum & 0x1F); ++ if (bitnum & 0x20) ++ pdata->hash_hi |= mask; ++ else ++ pdata->hash_lo |= mask; ++ } ++ ++ netif_dbg(dev, drv, dev->net, "HASHH=0x%08X, HASHL=0x%08X\n", ++ pdata->hash_hi, pdata->hash_lo); ++ } else { ++ netif_dbg(dev, drv, dev->net, "receive own packets only\n"); ++ pdata->mac_cr &= ++ ~(MAC_CR_PRMS_ | MAC_CR_MCPAS_ | MAC_CR_HPFILT_); ++ } ++ ++ spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); ++ ++ /* Initiate async writes, as we can't wait for completion here */ ++ ret = smsc95xx_write_reg_async(dev, HASHH, pdata->hash_hi); ++ if (ret < 0) ++ netdev_warn(dev->net, "failed to initiate async write to HASHH\n"); ++ ++ ret = smsc95xx_write_reg_async(dev, HASHL, pdata->hash_lo); ++ if (ret < 0) ++ netdev_warn(dev->net, "failed to initiate async write to HASHL\n"); ++ ++ ret = smsc95xx_write_reg_async(dev, MAC_CR, pdata->mac_cr); ++ if (ret < 0) ++ netdev_warn(dev->net, "failed to initiate async write to MAC_CR\n"); ++} ++ ++static int smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex, ++ u16 lcladv, u16 rmtadv) ++{ ++ u32 flow, afc_cfg = 0; ++ ++ int ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg); ++ if (ret < 0) ++ return ret; ++ ++ if (duplex == DUPLEX_FULL) { ++ u8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv); ++ ++ if (cap & FLOW_CTRL_RX) ++ flow = 0xFFFF0002; ++ else ++ flow = 0; ++ ++ if (cap & FLOW_CTRL_TX) ++ afc_cfg |= 0xF; ++ else ++ afc_cfg &= ~0xF; ++ ++ netif_dbg(dev, link, dev->net, "rx pause %s, tx pause %s\n", ++ cap & FLOW_CTRL_RX ? "enabled" : "disabled", ++ cap & FLOW_CTRL_TX ? "enabled" : "disabled"); ++ } else { ++ netif_dbg(dev, link, dev->net, "half duplex\n"); ++ flow = 0; ++ afc_cfg |= 0xF; ++ } ++ ++ ret = smsc95xx_write_reg(dev, FLOW, flow); ++ if (ret < 0) ++ return ret; ++ ++ return smsc95xx_write_reg(dev, AFC_CFG, afc_cfg); ++} ++ ++static int smsc95xx_link_reset(struct usbnet *dev) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ struct mii_if_info *mii = &dev->mii; ++ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; ++ unsigned long flags; ++ u16 lcladv, rmtadv; ++ int ret; ++ ++ /* clear interrupt status */ ++ ret = smsc95xx_mdio_read(dev->net, mii->phy_id, PHY_INT_SRC); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_); ++ if (ret < 0) ++ return ret; ++ ++ mii_check_media(mii, 1, 1); ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ lcladv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_ADVERTISE); ++ rmtadv = smsc95xx_mdio_read(dev->net, mii->phy_id, MII_LPA); ++ ++ netif_dbg(dev, link, dev->net, ++ "speed: %u duplex: %d lcladv: %04x rmtadv: %04x\n", ++ ethtool_cmd_speed(&ecmd), ecmd.duplex, lcladv, rmtadv); ++ ++ spin_lock_irqsave(&pdata->mac_cr_lock, flags); ++ if (ecmd.duplex != DUPLEX_FULL) { ++ pdata->mac_cr &= ~MAC_CR_FDPX_; ++ pdata->mac_cr |= MAC_CR_RCVOWN_; ++ } else { ++ pdata->mac_cr &= ~MAC_CR_RCVOWN_; ++ pdata->mac_cr |= MAC_CR_FDPX_; ++ } ++ spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); ++ ++ ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_phy_update_flowcontrol(dev, ecmd.duplex, lcladv, rmtadv); ++ if (ret < 0) ++ netdev_warn(dev->net, "Error updating PHY flow control\n"); ++ ++ return ret; ++} ++ ++static void smsc95xx_status(struct usbnet *dev, struct urb *urb) ++{ ++ u32 intdata; ++ ++ if (urb->actual_length != 4) { ++ netdev_warn(dev->net, "unexpected urb length %d\n", ++ urb->actual_length); ++ return; ++ } ++ ++ memcpy(&intdata, urb->transfer_buffer, 4); ++ le32_to_cpus(&intdata); ++ ++ netif_dbg(dev, link, dev->net, "intdata: 0x%08X\n", intdata); ++ ++ if (intdata & INT_ENP_PHY_INT_) ++ usbnet_defer_kevent(dev, EVENT_LINK_RESET); ++ else ++ netdev_warn(dev->net, "unexpected interrupt, intdata=0x%08X\n", ++ intdata); ++} ++ ++/* Enable or disable Tx & Rx checksum offload engines */ ++static int smsc95xx_set_features(struct net_device *netdev, ++ netdev_features_t features) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u32 read_buf; ++ int ret; ++ ++ ret = smsc95xx_read_reg(dev, COE_CR, &read_buf); ++ if (ret < 0) ++ return ret; ++ ++ if (features & NETIF_F_HW_CSUM) ++ read_buf |= Tx_COE_EN_; ++ else ++ read_buf &= ~Tx_COE_EN_; ++ ++ if (features & NETIF_F_RXCSUM) ++ read_buf |= Rx_COE_EN_; ++ else ++ read_buf &= ~Rx_COE_EN_; ++ ++ ret = smsc95xx_write_reg(dev, COE_CR, read_buf); ++ if (ret < 0) ++ return ret; ++ ++ netif_dbg(dev, hw, dev->net, "COE_CR = 0x%08x\n", read_buf); ++ return 0; ++} ++ ++static int smsc95xx_ethtool_get_eeprom_len(struct net_device *net) ++{ ++ return MAX_EEPROM_SIZE; ++} ++ ++static int smsc95xx_ethtool_get_eeprom(struct net_device *netdev, ++ struct ethtool_eeprom *ee, u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ ++ ee->magic = LAN95XX_EEPROM_MAGIC; ++ ++ return smsc95xx_read_eeprom(dev, ee->offset, ee->len, data); ++} ++ ++static int smsc95xx_ethtool_set_eeprom(struct net_device *netdev, ++ struct ethtool_eeprom *ee, u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ ++ if (ee->magic != LAN95XX_EEPROM_MAGIC) { ++ netdev_warn(dev->net, "EEPROM: magic value mismatch, magic = 0x%x\n", ++ ee->magic); ++ return -EINVAL; ++ } ++ ++ return smsc95xx_write_eeprom(dev, ee->offset, ee->len, data); ++} ++ ++static int smsc95xx_ethtool_getregslen(struct net_device *netdev) ++{ ++ /* all smsc95xx registers */ ++ return COE_CR - ID_REV + sizeof(u32); ++} ++ ++static void ++smsc95xx_ethtool_getregs(struct net_device *netdev, struct ethtool_regs *regs, ++ void *buf) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ unsigned int i, j; ++ int retval; ++ u32 *data = buf; ++ ++ retval = smsc95xx_read_reg(dev, ID_REV, ®s->version); ++ if (retval < 0) { ++ netdev_warn(netdev, "REGS: cannot read ID_REV\n"); ++ return; ++ } ++ ++ for (i = ID_REV, j = 0; i <= COE_CR; i += (sizeof(u32)), j++) { ++ retval = smsc95xx_read_reg(dev, i, &data[j]); ++ if (retval < 0) { ++ netdev_warn(netdev, "REGS: cannot read reg[%x]\n", i); ++ return; ++ } ++ } ++} ++ ++static void smsc95xx_ethtool_get_wol(struct net_device *net, ++ struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ ++ wolinfo->supported = SUPPORTED_WAKE; ++ wolinfo->wolopts = pdata->wolopts; ++} ++ ++static int smsc95xx_ethtool_set_wol(struct net_device *net, ++ struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ int ret; ++ ++ pdata->wolopts = wolinfo->wolopts & SUPPORTED_WAKE; ++ ++ ret = device_set_wakeup_enable(&dev->udev->dev, pdata->wolopts); ++ if (ret < 0) ++ netdev_warn(dev->net, "device_set_wakeup_enable error %d\n", ret); ++ ++ return ret; ++} ++ ++static const struct ethtool_ops smsc95xx_ethtool_ops = { ++ .get_link = usbnet_get_link, ++ .nway_reset = usbnet_nway_reset, ++ .get_drvinfo = usbnet_get_drvinfo, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .get_eeprom_len = smsc95xx_ethtool_get_eeprom_len, ++ .get_eeprom = smsc95xx_ethtool_get_eeprom, ++ .set_eeprom = smsc95xx_ethtool_set_eeprom, ++ .get_regs_len = smsc95xx_ethtool_getregslen, ++ .get_regs = smsc95xx_ethtool_getregs, ++ .get_wol = smsc95xx_ethtool_get_wol, ++ .set_wol = smsc95xx_ethtool_set_wol, ++}; ++ ++static int smsc95xx_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ ++ if (!netif_running(netdev)) ++ return -EINVAL; ++ ++ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); ++} ++ ++static void smsc95xx_init_mac_address(struct usbnet *dev) ++{ ++ /* try reading mac address from EEPROM */ ++ if (smsc95xx_read_eeprom(dev, EEPROM_MAC_OFFSET, ETH_ALEN, ++ dev->net->dev_addr) == 0) { ++ if (is_valid_ether_addr(dev->net->dev_addr)) { ++ /* eeprom values are valid so use them */ ++ netif_dbg(dev, ifup, dev->net, "MAC address read from EEPROM\n"); ++ return; ++ } ++ } ++ ++ /* no eeprom, or eeprom values are invalid. generate random MAC */ ++ eth_hw_addr_random(dev->net); ++ netif_dbg(dev, ifup, dev->net, "MAC address set to eth_random_addr\n"); ++} ++ ++static int smsc95xx_set_mac_address(struct usbnet *dev) ++{ ++ u32 addr_lo = dev->net->dev_addr[0] | dev->net->dev_addr[1] << 8 | ++ dev->net->dev_addr[2] << 16 | dev->net->dev_addr[3] << 24; ++ u32 addr_hi = dev->net->dev_addr[4] | dev->net->dev_addr[5] << 8; ++ int ret; ++ ++ ret = smsc95xx_write_reg(dev, ADDRL, addr_lo); ++ if (ret < 0) ++ return ret; ++ ++ return smsc95xx_write_reg(dev, ADDRH, addr_hi); ++} ++ ++/* starts the TX path */ ++static int smsc95xx_start_tx_path(struct usbnet *dev) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ unsigned long flags; ++ int ret; ++ ++ /* Enable Tx at MAC */ ++ spin_lock_irqsave(&pdata->mac_cr_lock, flags); ++ pdata->mac_cr |= MAC_CR_TXEN_; ++ spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); ++ ++ ret = smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr); ++ if (ret < 0) ++ return ret; ++ ++ /* Enable Tx at SCSRs */ ++ return smsc95xx_write_reg(dev, TX_CFG, TX_CFG_ON_); ++} ++ ++/* Starts the Receive path */ ++static int smsc95xx_start_rx_path(struct usbnet *dev, int in_pm) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ unsigned long flags; ++ ++ spin_lock_irqsave(&pdata->mac_cr_lock, flags); ++ pdata->mac_cr |= MAC_CR_RXEN_; ++ spin_unlock_irqrestore(&pdata->mac_cr_lock, flags); ++ ++ return __smsc95xx_write_reg(dev, MAC_CR, pdata->mac_cr, in_pm); ++} ++ ++static int smsc95xx_phy_initialize(struct usbnet *dev) ++{ ++ int bmcr, ret, timeout = 0; ++ ++ /* Initialize MII structure */ ++ dev->mii.dev = dev->net; ++ dev->mii.mdio_read = smsc95xx_mdio_read; ++ dev->mii.mdio_write = smsc95xx_mdio_write; ++ dev->mii.phy_id_mask = 0x1f; ++ dev->mii.reg_num_mask = 0x1f; ++ dev->mii.phy_id = SMSC95XX_INTERNAL_PHY_ID; ++ ++ /* reset phy and wait for reset to complete */ ++ smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); ++ ++ do { ++ msleep(10); ++ bmcr = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, MII_BMCR); ++ timeout++; ++ } while ((bmcr & BMCR_RESET) && (timeout < 100)); ++ ++ if (timeout >= 100) { ++ netdev_warn(dev->net, "timeout on PHY Reset"); ++ return -EIO; ++ } ++ ++ smsc95xx_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, ++ ADVERTISE_ALL | ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP | ++ ADVERTISE_PAUSE_ASYM); ++ ++ /* read to clear */ ++ ret = smsc95xx_mdio_read(dev->net, dev->mii.phy_id, PHY_INT_SRC); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to read PHY_INT_SRC during init\n"); ++ return ret; ++ } ++ ++ smsc95xx_mdio_write(dev->net, dev->mii.phy_id, PHY_INT_MASK, ++ PHY_INT_MASK_DEFAULT_); ++ mii_nway_restart(&dev->mii); ++ ++ netif_dbg(dev, ifup, dev->net, "phy initialised successfully\n"); ++ return 0; ++} ++ ++static int smsc95xx_reset(struct usbnet *dev) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ u32 read_buf, write_buf, burst_cap; ++ int ret = 0, timeout; ++ ++ netif_dbg(dev, ifup, dev->net, "entering smsc95xx_reset\n"); ++ ++ ret = smsc95xx_write_reg(dev, HW_CFG, HW_CFG_LRST_); ++ if (ret < 0) ++ return ret; ++ ++ timeout = 0; ++ do { ++ msleep(10); ++ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ++ if (ret < 0) ++ return ret; ++ timeout++; ++ } while ((read_buf & HW_CFG_LRST_) && (timeout < 100)); ++ ++ if (timeout >= 100) { ++ netdev_warn(dev->net, "timeout waiting for completion of Lite Reset\n"); ++ return ret; ++ } ++ ++ ret = smsc95xx_write_reg(dev, PM_CTRL, PM_CTL_PHY_RST_); ++ if (ret < 0) ++ return ret; ++ ++ timeout = 0; ++ do { ++ msleep(10); ++ ret = smsc95xx_read_reg(dev, PM_CTRL, &read_buf); ++ if (ret < 0) ++ return ret; ++ timeout++; ++ } while ((read_buf & PM_CTL_PHY_RST_) && (timeout < 100)); ++ ++ if (timeout >= 100) { ++ netdev_warn(dev->net, "timeout waiting for PHY Reset\n"); ++ return ret; ++ } ++ ++ ret = smsc95xx_set_mac_address(dev); ++ if (ret < 0) ++ return ret; ++ ++ netif_dbg(dev, ifup, dev->net, "MAC Address: %pM\n", ++ dev->net->dev_addr); ++ ++ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ++ if (ret < 0) ++ return ret; ++ ++ netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG : 0x%08x\n", ++ read_buf); ++ ++ read_buf |= HW_CFG_BIR_; ++ ++ ret = smsc95xx_write_reg(dev, HW_CFG, read_buf); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ++ if (ret < 0) ++ return ret; ++ ++ netif_dbg(dev, ifup, dev->net, ++ "Read Value from HW_CFG after writing HW_CFG_BIR_: 0x%08x\n", ++ read_buf); ++ ++ if (!turbo_mode) { ++ burst_cap = 0; ++ dev->rx_urb_size = MAX_SINGLE_PACKET_SIZE; ++ } else if (dev->udev->speed == USB_SPEED_HIGH) { ++ burst_cap = DEFAULT_HS_BURST_CAP_SIZE / HS_USB_PKT_SIZE; ++ dev->rx_urb_size = DEFAULT_HS_BURST_CAP_SIZE; ++ } else { ++ burst_cap = DEFAULT_FS_BURST_CAP_SIZE / FS_USB_PKT_SIZE; ++ dev->rx_urb_size = DEFAULT_FS_BURST_CAP_SIZE; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "rx_urb_size=%ld\n", ++ (ulong)dev->rx_urb_size); ++ ++ ret = smsc95xx_write_reg(dev, BURST_CAP, burst_cap); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_read_reg(dev, BURST_CAP, &read_buf); ++ if (ret < 0) ++ return ret; ++ ++ netif_dbg(dev, ifup, dev->net, ++ "Read Value from BURST_CAP after writing: 0x%08x\n", ++ read_buf); ++ ++ ret = smsc95xx_write_reg(dev, BULK_IN_DLY, DEFAULT_BULK_IN_DELAY); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_read_reg(dev, BULK_IN_DLY, &read_buf); ++ if (ret < 0) ++ return ret; ++ ++ netif_dbg(dev, ifup, dev->net, ++ "Read Value from BULK_IN_DLY after writing: 0x%08x\n", ++ read_buf); ++ ++ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ++ if (ret < 0) ++ return ret; ++ ++ netif_dbg(dev, ifup, dev->net, "Read Value from HW_CFG: 0x%08x\n", ++ read_buf); ++ ++ if (turbo_mode) ++ read_buf |= (HW_CFG_MEF_ | HW_CFG_BCE_); ++ ++ read_buf &= ~HW_CFG_RXDOFF_; ++ ++ /* set Rx data offset=2, Make IP header aligns on word boundary. */ ++ read_buf |= NET_IP_ALIGN << 9; ++ ++ ret = smsc95xx_write_reg(dev, HW_CFG, read_buf); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_read_reg(dev, HW_CFG, &read_buf); ++ if (ret < 0) ++ return ret; ++ ++ netif_dbg(dev, ifup, dev->net, ++ "Read Value from HW_CFG after writing: 0x%08x\n", read_buf); ++ ++ ret = smsc95xx_write_reg(dev, INT_STS, INT_STS_CLEAR_ALL_); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_read_reg(dev, ID_REV, &read_buf); ++ if (ret < 0) ++ return ret; ++ netif_dbg(dev, ifup, dev->net, "ID_REV = 0x%08x\n", read_buf); ++ ++ /* Configure GPIO pins as LED outputs */ ++ write_buf = LED_GPIO_CFG_SPD_LED | LED_GPIO_CFG_LNK_LED | ++ LED_GPIO_CFG_FDX_LED; ++ ret = smsc95xx_write_reg(dev, LED_GPIO_CFG, write_buf); ++ if (ret < 0) ++ return ret; ++ ++ /* Init Tx */ ++ ret = smsc95xx_write_reg(dev, FLOW, 0); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_write_reg(dev, AFC_CFG, AFC_CFG_DEFAULT); ++ if (ret < 0) ++ return ret; ++ ++ /* Don't need mac_cr_lock during initialisation */ ++ ret = smsc95xx_read_reg(dev, MAC_CR, &pdata->mac_cr); ++ if (ret < 0) ++ return ret; ++ ++ /* Init Rx */ ++ /* Set Vlan */ ++ ret = smsc95xx_write_reg(dev, VLAN1, (u32)ETH_P_8021Q); ++ if (ret < 0) ++ return ret; ++ ++ /* Enable or disable checksum offload engines */ ++ ret = smsc95xx_set_features(dev->net, dev->net->features); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to set checksum offload features\n"); ++ return ret; ++ } ++ ++ smsc95xx_set_multicast(dev->net); ++ ++ ret = smsc95xx_phy_initialize(dev); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to init PHY\n"); ++ return ret; ++ } ++ ++ ret = smsc95xx_read_reg(dev, INT_EP_CTL, &read_buf); ++ if (ret < 0) ++ return ret; ++ ++ /* enable PHY interrupts */ ++ read_buf |= INT_EP_CTL_PHY_INT_; ++ ++ ret = smsc95xx_write_reg(dev, INT_EP_CTL, read_buf); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_start_tx_path(dev); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to start TX path\n"); ++ return ret; ++ } ++ ++ ret = smsc95xx_start_rx_path(dev, 0); ++ if (ret < 0) { ++ netdev_warn(dev->net, "Failed to start RX path\n"); ++ return ret; ++ } ++ ++ netif_dbg(dev, ifup, dev->net, "smsc95xx_reset, return 0\n"); ++ return 0; ++} ++ ++static const struct net_device_ops smsc95xx_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_set_mac_address = eth_mac_addr, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = smsc95xx_ioctl, ++ .ndo_set_rx_mode = smsc95xx_set_multicast, ++ .ndo_set_features = smsc95xx_set_features, ++}; ++ ++static int smsc95xx_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ struct smsc95xx_priv *pdata = NULL; ++ u32 val; ++ int ret; ++ ++ printk(KERN_INFO SMSC_CHIPNAME " v" SMSC_DRIVER_VERSION "\n"); ++ ++ ret = usbnet_get_endpoints(dev, intf); ++ if (ret < 0) { ++ netdev_warn(dev->net, "usbnet_get_endpoints failed: %d\n", ret); ++ return ret; ++ } ++ ++ dev->data[0] = (unsigned long)kzalloc(sizeof(struct smsc95xx_priv), ++ GFP_KERNEL); ++ ++ pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ if (!pdata) ++ return -ENOMEM; ++ ++ spin_lock_init(&pdata->mac_cr_lock); ++ ++ if (DEFAULT_TX_CSUM_ENABLE) ++ dev->net->features |= NETIF_F_HW_CSUM; ++ if (DEFAULT_RX_CSUM_ENABLE) ++ dev->net->features |= NETIF_F_RXCSUM; ++ ++ dev->net->hw_features = NETIF_F_HW_CSUM | NETIF_F_RXCSUM; ++ ++ smsc95xx_init_mac_address(dev); ++ ++ /* Init all registers */ ++ ret = smsc95xx_reset(dev); ++ ++ /* detect device revision as different features may be available */ ++ ret = smsc95xx_read_reg(dev, ID_REV, &val); ++ if (ret < 0) ++ return ret; ++ val >>= 16; ++ ++ if ((val == ID_REV_CHIP_ID_9500A_) || (val == ID_REV_CHIP_ID_9530_) || ++ (val == ID_REV_CHIP_ID_89530_) || (val == ID_REV_CHIP_ID_9730_)) ++ pdata->features = (FEATURE_8_WAKEUP_FILTERS | ++ FEATURE_PHY_NLP_CROSSOVER | ++ FEATURE_REMOTE_WAKEUP); ++ else if (val == ID_REV_CHIP_ID_9512_) ++ pdata->features = FEATURE_8_WAKEUP_FILTERS; ++ ++ dev->net->netdev_ops = &smsc95xx_netdev_ops; ++ dev->net->ethtool_ops = &smsc95xx_ethtool_ops; ++ dev->net->flags |= IFF_MULTICAST; ++ dev->net->hard_header_len += SMSC95XX_TX_OVERHEAD_CSUM; ++ dev->hard_mtu = dev->net->mtu + dev->net->hard_header_len; ++ return 0; ++} ++ ++static void smsc95xx_unbind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ if (pdata) { ++ netif_dbg(dev, ifdown, dev->net, "free pdata\n"); ++ kfree(pdata); ++ pdata = NULL; ++ dev->data[0] = 0; ++ } ++} ++ ++static u32 smsc_crc(const u8 *buffer, size_t len, int filter) ++{ ++ u32 crc = bitrev16(crc16(0xFFFF, buffer, len)); ++ return crc << ((filter % 2) * 16); ++} ++ ++static int smsc95xx_enable_phy_wakeup_interrupts(struct usbnet *dev, u16 mask) ++{ ++ struct mii_if_info *mii = &dev->mii; ++ int ret; ++ ++ netdev_dbg(dev->net, "enabling PHY wakeup interrupts\n"); ++ ++ /* read to clear */ ++ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_SRC); ++ if (ret < 0) ++ return ret; ++ ++ /* enable interrupt source */ ++ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_INT_MASK); ++ if (ret < 0) ++ return ret; ++ ++ ret |= mask; ++ ++ smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_INT_MASK, ret); ++ ++ return 0; ++} ++ ++static int smsc95xx_link_ok_nopm(struct usbnet *dev) ++{ ++ struct mii_if_info *mii = &dev->mii; ++ int ret; ++ ++ /* first, a dummy read, needed to latch some MII phys */ ++ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); ++ if (ret < 0) ++ return ret; ++ ++ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, MII_BMSR); ++ if (ret < 0) ++ return ret; ++ ++ return !!(ret & BMSR_LSTATUS); ++} ++ ++static int smsc95xx_enter_suspend0(struct usbnet *dev) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ u32 val; ++ int ret; ++ ++ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ++ if (ret < 0) ++ return ret; ++ ++ val &= (~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_)); ++ val |= PM_CTL_SUS_MODE_0; ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ return ret; ++ ++ /* clear wol status */ ++ val &= ~PM_CTL_WUPS_; ++ val |= PM_CTL_WUPS_WOL_; ++ ++ /* enable energy detection */ ++ if (pdata->wolopts & WAKE_PHY) ++ val |= PM_CTL_WUPS_ED_; ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ return ret; ++ ++ /* read back PM_CTRL */ ++ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ++ if (ret < 0) ++ return ret; ++ ++ pdata->suspend_flags |= SUSPEND_SUSPEND0; ++ ++ return 0; ++} ++ ++static int smsc95xx_enter_suspend1(struct usbnet *dev) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ struct mii_if_info *mii = &dev->mii; ++ u32 val; ++ int ret; ++ ++ /* reconfigure link pulse detection timing for ++ * compatibility with non-standard link partners ++ */ ++ if (pdata->features & FEATURE_PHY_NLP_CROSSOVER) ++ smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_EDPD_CONFIG, ++ PHY_EDPD_CONFIG_DEFAULT); ++ ++ /* enable energy detect power-down mode */ ++ ret = smsc95xx_mdio_read_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS); ++ if (ret < 0) ++ return ret; ++ ++ ret |= MODE_CTRL_STS_EDPWRDOWN_; ++ ++ smsc95xx_mdio_write_nopm(dev->net, mii->phy_id, PHY_MODE_CTRL_STS, ret); ++ ++ /* enter SUSPEND1 mode */ ++ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ++ if (ret < 0) ++ return ret; ++ ++ val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); ++ val |= PM_CTL_SUS_MODE_1; ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ return ret; ++ ++ /* clear wol status, enable energy detection */ ++ val &= ~PM_CTL_WUPS_; ++ val |= (PM_CTL_WUPS_ED_ | PM_CTL_ED_EN_); ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ return ret; ++ ++ pdata->suspend_flags |= SUSPEND_SUSPEND1; ++ ++ return 0; ++} ++ ++static int smsc95xx_enter_suspend2(struct usbnet *dev) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ u32 val; ++ int ret; ++ ++ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ++ if (ret < 0) ++ return ret; ++ ++ val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); ++ val |= PM_CTL_SUS_MODE_2; ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ return ret; ++ ++ pdata->suspend_flags |= SUSPEND_SUSPEND2; ++ ++ return 0; ++} ++ ++static int smsc95xx_enter_suspend3(struct usbnet *dev) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ u32 val; ++ int ret; ++ ++ ret = smsc95xx_read_reg_nopm(dev, RX_FIFO_INF, &val); ++ if (ret < 0) ++ return ret; ++ ++ if (val & 0xFFFF) { ++ netdev_info(dev->net, "rx fifo not empty in autosuspend\n"); ++ return -EBUSY; ++ } ++ ++ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ++ if (ret < 0) ++ return ret; ++ ++ val &= ~(PM_CTL_SUS_MODE_ | PM_CTL_WUPS_ | PM_CTL_PHY_RST_); ++ val |= PM_CTL_SUS_MODE_3 | PM_CTL_RES_CLR_WKP_STS; ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ return ret; ++ ++ /* clear wol status */ ++ val &= ~PM_CTL_WUPS_; ++ val |= PM_CTL_WUPS_WOL_; ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ return ret; ++ ++ pdata->suspend_flags |= SUSPEND_SUSPEND3; ++ ++ return 0; ++} ++ ++static int smsc95xx_autosuspend(struct usbnet *dev, u32 link_up) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ int ret; ++ ++ if (!netif_running(dev->net)) { ++ /* interface is ifconfig down so fully power down hw */ ++ netdev_dbg(dev->net, "autosuspend entering SUSPEND2\n"); ++ return smsc95xx_enter_suspend2(dev); ++ } ++ ++ if (!link_up) { ++ /* link is down so enter EDPD mode, but only if device can ++ * reliably resume from it. This check should be redundant ++ * as current FEATURE_REMOTE_WAKEUP parts also support ++ * FEATURE_PHY_NLP_CROSSOVER but it's included for clarity */ ++ if (!(pdata->features & FEATURE_PHY_NLP_CROSSOVER)) { ++ netdev_warn(dev->net, "EDPD not supported\n"); ++ return -EBUSY; ++ } ++ ++ netdev_dbg(dev->net, "autosuspend entering SUSPEND1\n"); ++ ++ /* enable PHY wakeup events for if cable is attached */ ++ ret = smsc95xx_enable_phy_wakeup_interrupts(dev, ++ PHY_INT_MASK_ANEG_COMP_); ++ if (ret < 0) { ++ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); ++ return ret; ++ } ++ ++ netdev_info(dev->net, "entering SUSPEND1 mode\n"); ++ return smsc95xx_enter_suspend1(dev); ++ } ++ ++ /* enable PHY wakeup events so we remote wakeup if cable is pulled */ ++ ret = smsc95xx_enable_phy_wakeup_interrupts(dev, ++ PHY_INT_MASK_LINK_DOWN_); ++ if (ret < 0) { ++ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); ++ return ret; ++ } ++ ++ netdev_dbg(dev->net, "autosuspend entering SUSPEND3\n"); ++ return smsc95xx_enter_suspend3(dev); ++} ++ ++static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) ++{ ++ struct usbnet *dev = usb_get_intfdata(intf); ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ u32 val, link_up; ++ int ret; ++ ++ ret = usbnet_suspend(intf, message); ++ if (ret < 0) { ++ netdev_warn(dev->net, "usbnet_suspend error\n"); ++ return ret; ++ } ++ ++ if (pdata->suspend_flags) { ++ netdev_warn(dev->net, "error during last resume\n"); ++ pdata->suspend_flags = 0; ++ } ++ ++ /* determine if link is up using only _nopm functions */ ++ link_up = smsc95xx_link_ok_nopm(dev); ++ ++ if (message.event == PM_EVENT_AUTO_SUSPEND && ++ (pdata->features & FEATURE_REMOTE_WAKEUP)) { ++ ret = smsc95xx_autosuspend(dev, link_up); ++ goto done; ++ } ++ ++ /* if we get this far we're not autosuspending */ ++ /* if no wol options set, or if link is down and we're not waking on ++ * PHY activity, enter lowest power SUSPEND2 mode ++ */ ++ if (!(pdata->wolopts & SUPPORTED_WAKE) || ++ !(link_up || (pdata->wolopts & WAKE_PHY))) { ++ netdev_info(dev->net, "entering SUSPEND2 mode\n"); ++ ++ /* disable energy detect (link up) & wake up events */ ++ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) ++ goto done; ++ ++ val &= ~(WUCSR_MPEN_ | WUCSR_WAKE_EN_); ++ ++ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) ++ goto done; ++ ++ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ++ if (ret < 0) ++ goto done; ++ ++ val &= ~(PM_CTL_ED_EN_ | PM_CTL_WOL_EN_); ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ goto done; ++ ++ ret = smsc95xx_enter_suspend2(dev); ++ goto done; ++ } ++ ++ if (pdata->wolopts & WAKE_PHY) { ++ ret = smsc95xx_enable_phy_wakeup_interrupts(dev, ++ (PHY_INT_MASK_ANEG_COMP_ | PHY_INT_MASK_LINK_DOWN_)); ++ if (ret < 0) { ++ netdev_warn(dev->net, "error enabling PHY wakeup ints\n"); ++ goto done; ++ } ++ ++ /* if link is down then configure EDPD and enter SUSPEND1, ++ * otherwise enter SUSPEND0 below ++ */ ++ if (!link_up) { ++ netdev_info(dev->net, "entering SUSPEND1 mode\n"); ++ ret = smsc95xx_enter_suspend1(dev); ++ goto done; ++ } ++ } ++ ++ if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { ++ u32 *filter_mask = kzalloc(sizeof(u32) * 32, GFP_KERNEL); ++ u32 command[2]; ++ u32 offset[2]; ++ u32 crc[4]; ++ int wuff_filter_count = ++ (pdata->features & FEATURE_8_WAKEUP_FILTERS) ? ++ LAN9500A_WUFF_NUM : LAN9500_WUFF_NUM; ++ int i, filter = 0; ++ ++ if (!filter_mask) { ++ netdev_warn(dev->net, "Unable to allocate filter_mask\n"); ++ ret = -ENOMEM; ++ goto done; ++ } ++ ++ memset(command, 0, sizeof(command)); ++ memset(offset, 0, sizeof(offset)); ++ memset(crc, 0, sizeof(crc)); ++ ++ if (pdata->wolopts & WAKE_BCAST) { ++ const u8 bcast[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; ++ netdev_info(dev->net, "enabling broadcast detection\n"); ++ filter_mask[filter * 4] = 0x003F; ++ filter_mask[filter * 4 + 1] = 0x00; ++ filter_mask[filter * 4 + 2] = 0x00; ++ filter_mask[filter * 4 + 3] = 0x00; ++ command[filter/4] |= 0x05UL << ((filter % 4) * 8); ++ offset[filter/4] |= 0x00 << ((filter % 4) * 8); ++ crc[filter/2] |= smsc_crc(bcast, 6, filter); ++ filter++; ++ } ++ ++ if (pdata->wolopts & WAKE_MCAST) { ++ const u8 mcast[] = {0x01, 0x00, 0x5E}; ++ netdev_info(dev->net, "enabling multicast detection\n"); ++ filter_mask[filter * 4] = 0x0007; ++ filter_mask[filter * 4 + 1] = 0x00; ++ filter_mask[filter * 4 + 2] = 0x00; ++ filter_mask[filter * 4 + 3] = 0x00; ++ command[filter/4] |= 0x09UL << ((filter % 4) * 8); ++ offset[filter/4] |= 0x00 << ((filter % 4) * 8); ++ crc[filter/2] |= smsc_crc(mcast, 3, filter); ++ filter++; ++ } ++ ++ if (pdata->wolopts & WAKE_ARP) { ++ const u8 arp[] = {0x08, 0x06}; ++ netdev_info(dev->net, "enabling ARP detection\n"); ++ filter_mask[filter * 4] = 0x0003; ++ filter_mask[filter * 4 + 1] = 0x00; ++ filter_mask[filter * 4 + 2] = 0x00; ++ filter_mask[filter * 4 + 3] = 0x00; ++ command[filter/4] |= 0x05UL << ((filter % 4) * 8); ++ offset[filter/4] |= 0x0C << ((filter % 4) * 8); ++ crc[filter/2] |= smsc_crc(arp, 2, filter); ++ filter++; ++ } ++ ++ if (pdata->wolopts & WAKE_UCAST) { ++ netdev_info(dev->net, "enabling unicast detection\n"); ++ filter_mask[filter * 4] = 0x003F; ++ filter_mask[filter * 4 + 1] = 0x00; ++ filter_mask[filter * 4 + 2] = 0x00; ++ filter_mask[filter * 4 + 3] = 0x00; ++ command[filter/4] |= 0x01UL << ((filter % 4) * 8); ++ offset[filter/4] |= 0x00 << ((filter % 4) * 8); ++ crc[filter/2] |= smsc_crc(dev->net->dev_addr, ETH_ALEN, filter); ++ filter++; ++ } ++ ++ for (i = 0; i < (wuff_filter_count * 4); i++) { ++ ret = smsc95xx_write_reg_nopm(dev, WUFF, filter_mask[i]); ++ if (ret < 0) { ++ kfree(filter_mask); ++ goto done; ++ } ++ } ++ kfree(filter_mask); ++ ++ for (i = 0; i < (wuff_filter_count / 4); i++) { ++ ret = smsc95xx_write_reg_nopm(dev, WUFF, command[i]); ++ if (ret < 0) ++ goto done; ++ } ++ ++ for (i = 0; i < (wuff_filter_count / 4); i++) { ++ ret = smsc95xx_write_reg_nopm(dev, WUFF, offset[i]); ++ if (ret < 0) ++ goto done; ++ } ++ ++ for (i = 0; i < (wuff_filter_count / 2); i++) { ++ ret = smsc95xx_write_reg_nopm(dev, WUFF, crc[i]); ++ if (ret < 0) ++ goto done; ++ } ++ ++ /* clear any pending pattern match packet status */ ++ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) ++ goto done; ++ ++ val |= WUCSR_WUFR_; ++ ++ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) ++ goto done; ++ } ++ ++ if (pdata->wolopts & WAKE_MAGIC) { ++ /* clear any pending magic packet status */ ++ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) ++ goto done; ++ ++ val |= WUCSR_MPR_; ++ ++ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) ++ goto done; ++ } ++ ++ /* enable/disable wakeup sources */ ++ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) ++ goto done; ++ ++ if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { ++ netdev_info(dev->net, "enabling pattern match wakeup\n"); ++ val |= WUCSR_WAKE_EN_; ++ } else { ++ netdev_info(dev->net, "disabling pattern match wakeup\n"); ++ val &= ~WUCSR_WAKE_EN_; ++ } ++ ++ if (pdata->wolopts & WAKE_MAGIC) { ++ netdev_info(dev->net, "enabling magic packet wakeup\n"); ++ val |= WUCSR_MPEN_; ++ } else { ++ netdev_info(dev->net, "disabling magic packet wakeup\n"); ++ val &= ~WUCSR_MPEN_; ++ } ++ ++ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) ++ goto done; ++ ++ /* enable wol wakeup source */ ++ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ++ if (ret < 0) ++ goto done; ++ ++ val |= PM_CTL_WOL_EN_; ++ ++ /* phy energy detect wakeup source */ ++ if (pdata->wolopts & WAKE_PHY) ++ val |= PM_CTL_ED_EN_; ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ goto done; ++ ++ /* enable receiver to enable frame reception */ ++ smsc95xx_start_rx_path(dev, 1); ++ ++ /* some wol options are enabled, so enter SUSPEND0 */ ++ netdev_info(dev->net, "entering SUSPEND0 mode\n"); ++ ret = smsc95xx_enter_suspend0(dev); ++ ++done: ++ /* ++ * TODO: resume() might need to handle the suspend failure ++ * in system sleep ++ */ ++ if (ret && PMSG_IS_AUTO(message)) ++ usbnet_resume(intf); ++ return ret; ++} ++ ++static int smsc95xx_resume(struct usb_interface *intf) ++{ ++ struct usbnet *dev = usb_get_intfdata(intf); ++ struct smsc95xx_priv *pdata; ++ u8 suspend_flags; ++ int ret; ++ u32 val; ++ ++ BUG_ON(!dev); ++ pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ suspend_flags = pdata->suspend_flags; ++ ++ netdev_dbg(dev->net, "resume suspend_flags=0x%02x\n", suspend_flags); ++ ++ /* do this first to ensure it's cleared even in error case */ ++ pdata->suspend_flags = 0; ++ ++ if (suspend_flags & SUSPEND_ALLMODES) { ++ /* clear wake-up sources */ ++ ret = smsc95xx_read_reg_nopm(dev, WUCSR, &val); ++ if (ret < 0) ++ return ret; ++ ++ val &= ~(WUCSR_WAKE_EN_ | WUCSR_MPEN_); ++ ++ ret = smsc95xx_write_reg_nopm(dev, WUCSR, val); ++ if (ret < 0) ++ return ret; ++ ++ /* clear wake-up status */ ++ ret = smsc95xx_read_reg_nopm(dev, PM_CTRL, &val); ++ if (ret < 0) ++ return ret; ++ ++ val &= ~PM_CTL_WOL_EN_; ++ val |= PM_CTL_WUPS_; ++ ++ ret = smsc95xx_write_reg_nopm(dev, PM_CTRL, val); ++ if (ret < 0) ++ return ret; ++ } ++ ++ ret = usbnet_resume(intf); ++ if (ret < 0) ++ netdev_warn(dev->net, "usbnet_resume error\n"); ++ ++ return ret; ++} ++ ++static int smsc95xx_reset_resume(struct usb_interface *intf) ++{ ++ struct usbnet *dev = usb_get_intfdata(intf); ++ int ret; ++ ++ ret = smsc95xx_reset(dev); ++ if (ret < 0) ++ return ret; ++ ++ return smsc95xx_resume(intf); ++} ++ ++static void smsc95xx_rx_csum_offload(struct sk_buff *skb) ++{ ++ skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2); ++ skb->ip_summed = CHECKSUM_COMPLETE; ++ skb_trim(skb, skb->len - 2); ++} ++ ++static int smsc95xx_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ /* This check is no longer done by usbnet */ ++ if (skb->len < dev->net->hard_header_len) ++ return 0; ++ ++ while (skb->len > 0) { ++ u32 header, align_count; ++ struct sk_buff *ax_skb; ++ unsigned char *packet; ++ u16 size; ++ ++ memcpy(&header, skb->data, sizeof(header)); ++ le32_to_cpus(&header); ++ skb_pull(skb, 4 + NET_IP_ALIGN); ++ packet = skb->data; ++ ++ /* get the packet length */ ++ size = (u16)((header & RX_STS_FL_) >> 16); ++ align_count = (4 - ((size + NET_IP_ALIGN) % 4)) % 4; ++ ++ if (unlikely(header & RX_STS_ES_)) { ++ netif_dbg(dev, rx_err, dev->net, ++ "Error header=0x%08x\n", header); ++ dev->net->stats.rx_errors++; ++ dev->net->stats.rx_dropped++; ++ ++ if (header & RX_STS_CRC_) { ++ dev->net->stats.rx_crc_errors++; ++ } else { ++ if (header & (RX_STS_TL_ | RX_STS_RF_)) ++ dev->net->stats.rx_frame_errors++; ++ ++ if ((header & RX_STS_LE_) && ++ (!(header & RX_STS_FT_))) ++ dev->net->stats.rx_length_errors++; ++ } ++ } else { ++ /* ETH_FRAME_LEN + 4(CRC) + 2(COE) + 4(Vlan) */ ++ if (unlikely(size > (ETH_FRAME_LEN + 12))) { ++ netif_dbg(dev, rx_err, dev->net, ++ "size err header=0x%08x\n", header); ++ return 0; ++ } ++ ++ /* last frame in this batch */ ++ if (skb->len == size) { ++ if (dev->net->features & NETIF_F_RXCSUM) ++ smsc95xx_rx_csum_offload(skb); ++ skb_trim(skb, skb->len - 4); /* remove fcs */ ++ skb->truesize = size + sizeof(struct sk_buff); ++ ++ return 1; ++ } ++ ++ ax_skb = skb_clone(skb, GFP_ATOMIC); ++ if (unlikely(!ax_skb)) { ++ netdev_warn(dev->net, "Error allocating skb\n"); ++ return 0; ++ } ++ ++ ax_skb->len = size; ++ ax_skb->data = packet; ++ skb_set_tail_pointer(ax_skb, size); ++ ++ if (dev->net->features & NETIF_F_RXCSUM) ++ smsc95xx_rx_csum_offload(ax_skb); ++ skb_trim(ax_skb, ax_skb->len - 4); /* remove fcs */ ++ ax_skb->truesize = size + sizeof(struct sk_buff); ++ ++ usbnet_skb_return(dev, ax_skb); ++ } ++ ++ skb_pull(skb, size); ++ ++ /* padding bytes before the next frame starts */ ++ if (skb->len) ++ skb_pull(skb, align_count); ++ } ++ ++ if (unlikely(skb->len < 0)) { ++ netdev_warn(dev->net, "invalid rx length<0 %d\n", skb->len); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static u32 smsc95xx_calc_csum_preamble(struct sk_buff *skb) ++{ ++ u16 low_16 = (u16)skb_checksum_start_offset(skb); ++ u16 high_16 = low_16 + skb->csum_offset; ++ return (high_16 << 16) | low_16; ++} ++ ++static struct sk_buff *smsc95xx_tx_fixup(struct usbnet *dev, ++ struct sk_buff *skb, gfp_t flags) ++{ ++ bool csum = skb->ip_summed == CHECKSUM_PARTIAL; ++ int overhead = csum ? SMSC95XX_TX_OVERHEAD_CSUM : SMSC95XX_TX_OVERHEAD; ++ u32 tx_cmd_a, tx_cmd_b; ++ ++ /* We do not advertise SG, so skbs should be already linearized */ ++ BUG_ON(skb_shinfo(skb)->nr_frags); ++ ++ if (skb_headroom(skb) < overhead) { ++ struct sk_buff *skb2 = skb_copy_expand(skb, ++ overhead, 0, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (!skb) ++ return NULL; ++ } ++ ++ if (csum) { ++ if (skb->len <= 45) { ++ /* workaround - hardware tx checksum does not work ++ * properly with extremely small packets */ ++ long csstart = skb_checksum_start_offset(skb); ++ __wsum calc = csum_partial(skb->data + csstart, ++ skb->len - csstart, 0); ++ *((__sum16 *)(skb->data + csstart ++ + skb->csum_offset)) = csum_fold(calc); ++ ++ csum = false; ++ } else { ++ u32 csum_preamble = smsc95xx_calc_csum_preamble(skb); ++ skb_push(skb, 4); ++ cpu_to_le32s(&csum_preamble); ++ memcpy(skb->data, &csum_preamble, 4); ++ } ++ } ++ ++ skb_push(skb, 4); ++ tx_cmd_b = (u32)(skb->len - 4); ++ if (csum) ++ tx_cmd_b |= TX_CMD_B_CSUM_ENABLE; ++ cpu_to_le32s(&tx_cmd_b); ++ memcpy(skb->data, &tx_cmd_b, 4); ++ ++ skb_push(skb, 4); ++ tx_cmd_a = (u32)(skb->len - 8) | TX_CMD_A_FIRST_SEG_ | ++ TX_CMD_A_LAST_SEG_; ++ cpu_to_le32s(&tx_cmd_a); ++ memcpy(skb->data, &tx_cmd_a, 4); ++ ++ return skb; ++} ++ ++static int smsc95xx_manage_power(struct usbnet *dev, int on) ++{ ++ struct smsc95xx_priv *pdata = (struct smsc95xx_priv *)(dev->data[0]); ++ ++ dev->intf->needs_remote_wakeup = on; ++ ++ if (pdata->features & FEATURE_REMOTE_WAKEUP) ++ return 0; ++ ++ /* this chip revision isn't capable of remote wakeup */ ++ netdev_info(dev->net, "hardware isn't capable of remote wakeup\n"); ++ ++ if (on) ++ usb_autopm_get_interface_no_resume(dev->intf); ++ else ++ usb_autopm_put_interface(dev->intf); ++ ++ return 0; ++} ++ ++static const struct driver_info smsc95xx_info = { ++ .description = "smsc95xx USB 2.0 Ethernet", ++ .bind = smsc95xx_bind, ++ .unbind = smsc95xx_unbind, ++ .link_reset = smsc95xx_link_reset, ++ .reset = smsc95xx_reset, ++ .rx_fixup = smsc95xx_rx_fixup, ++ .tx_fixup = smsc95xx_tx_fixup, ++ .status = smsc95xx_status, ++ .manage_power = smsc95xx_manage_power, ++ .flags = FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR, ++}; ++ ++static const struct usb_device_id products[] = { ++ { ++ /* SMSC9500 USB Ethernet Device */ ++ USB_DEVICE(0x0424, 0x9500), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9505 USB Ethernet Device */ ++ USB_DEVICE(0x0424, 0x9505), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9500A USB Ethernet Device */ ++ USB_DEVICE(0x0424, 0x9E00), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9505A USB Ethernet Device */ ++ USB_DEVICE(0x0424, 0x9E01), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9512/9514 USB Hub & Ethernet Device */ ++ USB_DEVICE(0x0424, 0xec00), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9500 USB Ethernet Device (SAL10) */ ++ USB_DEVICE(0x0424, 0x9900), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9505 USB Ethernet Device (SAL10) */ ++ USB_DEVICE(0x0424, 0x9901), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9500A USB Ethernet Device (SAL10) */ ++ USB_DEVICE(0x0424, 0x9902), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9505A USB Ethernet Device (SAL10) */ ++ USB_DEVICE(0x0424, 0x9903), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9512/9514 USB Hub & Ethernet Device (SAL10) */ ++ USB_DEVICE(0x0424, 0x9904), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9500A USB Ethernet Device (HAL) */ ++ USB_DEVICE(0x0424, 0x9905), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9505A USB Ethernet Device (HAL) */ ++ USB_DEVICE(0x0424, 0x9906), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9500 USB Ethernet Device (Alternate ID) */ ++ USB_DEVICE(0x0424, 0x9907), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9500A USB Ethernet Device (Alternate ID) */ ++ USB_DEVICE(0x0424, 0x9908), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC9512/9514 USB Hub & Ethernet Device (Alternate ID) */ ++ USB_DEVICE(0x0424, 0x9909), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC LAN9530 USB Ethernet Device */ ++ USB_DEVICE(0x0424, 0x9530), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC LAN9730 USB Ethernet Device */ ++ USB_DEVICE(0x0424, 0x9730), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { ++ /* SMSC LAN89530 USB Ethernet Device */ ++ USB_DEVICE(0x0424, 0x9E08), ++ .driver_info = (unsigned long) &smsc95xx_info, ++ }, ++ { }, /* END */ ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver smsc95xx_driver = { ++ .name = "smsc95xx", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .suspend = smsc95xx_suspend, ++ .resume = smsc95xx_resume, ++ .reset_resume = smsc95xx_reset_resume, ++ .disconnect = usbnet_disconnect, ++ .disable_hub_initiated_lpm = 1, ++ .supports_autosuspend = 1, ++}; ++ ++module_usb_driver(smsc95xx_driver); ++ ++MODULE_AUTHOR("Nancy Lin"); ++MODULE_AUTHOR("Steve Glendinning steve.glendinning@shawell.net"); ++MODULE_DESCRIPTION("SMSC95XX USB 2.0 Ethernet Devices"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/smsc95xx.h backports-4.2.6-1/drivers/net/usb/smsc95xx.h +--- backports-4.2.6-1.org/drivers/net/usb/smsc95xx.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/smsc95xx.h 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,290 @@ ++ /*************************************************************************** ++ * ++ * Copyright (C) 2007-2008 SMSC ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2 ++ * of the License, or (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ * ++ *****************************************************************************/ ++ ++#ifndef _SMSC95XX_H ++#define _SMSC95XX_H ++ ++/* Tx command words */ ++#define TX_CMD_A_DATA_OFFSET_ (0x001F0000) ++#define TX_CMD_A_FIRST_SEG_ (0x00002000) ++#define TX_CMD_A_LAST_SEG_ (0x00001000) ++#define TX_CMD_A_BUF_SIZE_ (0x000007FF) ++ ++#define TX_CMD_B_CSUM_ENABLE (0x00004000) ++#define TX_CMD_B_ADD_CRC_DISABLE_ (0x00002000) ++#define TX_CMD_B_DISABLE_PADDING_ (0x00001000) ++#define TX_CMD_B_PKT_BYTE_LENGTH_ (0x000007FF) ++ ++/* Rx status word */ ++#define RX_STS_FF_ (0x40000000) /* Filter Fail */ ++#define RX_STS_FL_ (0x3FFF0000) /* Frame Length */ ++#define RX_STS_ES_ (0x00008000) /* Error Summary */ ++#define RX_STS_BF_ (0x00002000) /* Broadcast Frame */ ++#define RX_STS_LE_ (0x00001000) /* Length Error */ ++#define RX_STS_RF_ (0x00000800) /* Runt Frame */ ++#define RX_STS_MF_ (0x00000400) /* Multicast Frame */ ++#define RX_STS_TL_ (0x00000080) /* Frame too long */ ++#define RX_STS_CS_ (0x00000040) /* Collision Seen */ ++#define RX_STS_FT_ (0x00000020) /* Frame Type */ ++#define RX_STS_RW_ (0x00000010) /* Receive Watchdog */ ++#define RX_STS_ME_ (0x00000008) /* Mii Error */ ++#define RX_STS_DB_ (0x00000004) /* Dribbling */ ++#define RX_STS_CRC_ (0x00000002) /* CRC Error */ ++ ++/* SCSRs */ ++#define ID_REV (0x00) ++#define ID_REV_CHIP_ID_MASK_ (0xFFFF0000) ++#define ID_REV_CHIP_REV_MASK_ (0x0000FFFF) ++#define ID_REV_CHIP_ID_9500_ (0x9500) ++#define ID_REV_CHIP_ID_9500A_ (0x9E00) ++#define ID_REV_CHIP_ID_9512_ (0xEC00) ++#define ID_REV_CHIP_ID_9530_ (0x9530) ++#define ID_REV_CHIP_ID_89530_ (0x9E08) ++#define ID_REV_CHIP_ID_9730_ (0x9730) ++ ++#define INT_STS (0x08) ++#define INT_STS_TX_STOP_ (0x00020000) ++#define INT_STS_RX_STOP_ (0x00010000) ++#define INT_STS_PHY_INT_ (0x00008000) ++#define INT_STS_TXE_ (0x00004000) ++#define INT_STS_TDFU_ (0x00002000) ++#define INT_STS_TDFO_ (0x00001000) ++#define INT_STS_RXDF_ (0x00000800) ++#define INT_STS_GPIOS_ (0x000007FF) ++#define INT_STS_CLEAR_ALL_ (0xFFFFFFFF) ++ ++#define RX_CFG (0x0C) ++#define RX_FIFO_FLUSH_ (0x00000001) ++ ++#define TX_CFG (0x10) ++#define TX_CFG_ON_ (0x00000004) ++#define TX_CFG_STOP_ (0x00000002) ++#define TX_CFG_FIFO_FLUSH_ (0x00000001) ++ ++#define HW_CFG (0x14) ++#define HW_CFG_BIR_ (0x00001000) ++#define HW_CFG_LEDB_ (0x00000800) ++#define HW_CFG_RXDOFF_ (0x00000600) ++#define HW_CFG_DRP_ (0x00000040) ++#define HW_CFG_MEF_ (0x00000020) ++#define HW_CFG_LRST_ (0x00000008) ++#define HW_CFG_PSEL_ (0x00000004) ++#define HW_CFG_BCE_ (0x00000002) ++#define HW_CFG_SRST_ (0x00000001) ++ ++#define RX_FIFO_INF (0x18) ++ ++#define PM_CTRL (0x20) ++#define PM_CTL_RES_CLR_WKP_STS (0x00000200) ++#define PM_CTL_DEV_RDY_ (0x00000080) ++#define PM_CTL_SUS_MODE_ (0x00000060) ++#define PM_CTL_SUS_MODE_0 (0x00000000) ++#define PM_CTL_SUS_MODE_1 (0x00000020) ++#define PM_CTL_SUS_MODE_2 (0x00000040) ++#define PM_CTL_SUS_MODE_3 (0x00000060) ++#define PM_CTL_PHY_RST_ (0x00000010) ++#define PM_CTL_WOL_EN_ (0x00000008) ++#define PM_CTL_ED_EN_ (0x00000004) ++#define PM_CTL_WUPS_ (0x00000003) ++#define PM_CTL_WUPS_NO_ (0x00000000) ++#define PM_CTL_WUPS_ED_ (0x00000001) ++#define PM_CTL_WUPS_WOL_ (0x00000002) ++#define PM_CTL_WUPS_MULTI_ (0x00000003) ++ ++#define LED_GPIO_CFG (0x24) ++#define LED_GPIO_CFG_SPD_LED (0x01000000) ++#define LED_GPIO_CFG_LNK_LED (0x00100000) ++#define LED_GPIO_CFG_FDX_LED (0x00010000) ++ ++#define GPIO_CFG (0x28) ++ ++#define AFC_CFG (0x2C) ++ ++/* Hi watermark = 15.5Kb (~10 mtu pkts) */ ++/* low watermark = 3k (~2 mtu pkts) */ ++/* backpressure duration = ~ 350us */ ++/* Apply FC on any frame. */ ++#define AFC_CFG_DEFAULT (0x00F830A1) ++ ++#define E2P_CMD (0x30) ++#define E2P_CMD_BUSY_ (0x80000000) ++#define E2P_CMD_MASK_ (0x70000000) ++#define E2P_CMD_READ_ (0x00000000) ++#define E2P_CMD_EWDS_ (0x10000000) ++#define E2P_CMD_EWEN_ (0x20000000) ++#define E2P_CMD_WRITE_ (0x30000000) ++#define E2P_CMD_WRAL_ (0x40000000) ++#define E2P_CMD_ERASE_ (0x50000000) ++#define E2P_CMD_ERAL_ (0x60000000) ++#define E2P_CMD_RELOAD_ (0x70000000) ++#define E2P_CMD_TIMEOUT_ (0x00000400) ++#define E2P_CMD_LOADED_ (0x00000200) ++#define E2P_CMD_ADDR_ (0x000001FF) ++ ++#define MAX_EEPROM_SIZE (512) ++ ++#define E2P_DATA (0x34) ++#define E2P_DATA_MASK_ (0x000000FF) ++ ++#define BURST_CAP (0x38) ++ ++#define GPIO_WAKE (0x64) ++ ++#define INT_EP_CTL (0x68) ++#define INT_EP_CTL_INTEP_ (0x80000000) ++#define INT_EP_CTL_MACRTO_ (0x00080000) ++#define INT_EP_CTL_TX_STOP_ (0x00020000) ++#define INT_EP_CTL_RX_STOP_ (0x00010000) ++#define INT_EP_CTL_PHY_INT_ (0x00008000) ++#define INT_EP_CTL_TXE_ (0x00004000) ++#define INT_EP_CTL_TDFU_ (0x00002000) ++#define INT_EP_CTL_TDFO_ (0x00001000) ++#define INT_EP_CTL_RXDF_ (0x00000800) ++#define INT_EP_CTL_GPIOS_ (0x000007FF) ++ ++#define BULK_IN_DLY (0x6C) ++ ++/* MAC CSRs */ ++#define MAC_CR (0x100) ++#define MAC_CR_RXALL_ (0x80000000) ++#define MAC_CR_RCVOWN_ (0x00800000) ++#define MAC_CR_LOOPBK_ (0x00200000) ++#define MAC_CR_FDPX_ (0x00100000) ++#define MAC_CR_MCPAS_ (0x00080000) ++#define MAC_CR_PRMS_ (0x00040000) ++#define MAC_CR_INVFILT_ (0x00020000) ++#define MAC_CR_PASSBAD_ (0x00010000) ++#define MAC_CR_HFILT_ (0x00008000) ++#define MAC_CR_HPFILT_ (0x00002000) ++#define MAC_CR_LCOLL_ (0x00001000) ++#define MAC_CR_BCAST_ (0x00000800) ++#define MAC_CR_DISRTY_ (0x00000400) ++#define MAC_CR_PADSTR_ (0x00000100) ++#define MAC_CR_BOLMT_MASK (0x000000C0) ++#define MAC_CR_DFCHK_ (0x00000020) ++#define MAC_CR_TXEN_ (0x00000008) ++#define MAC_CR_RXEN_ (0x00000004) ++ ++#define ADDRH (0x104) ++ ++#define ADDRL (0x108) ++ ++#define HASHH (0x10C) ++ ++#define HASHL (0x110) ++ ++#define MII_ADDR (0x114) ++#define MII_WRITE_ (0x02) ++#define MII_BUSY_ (0x01) ++#define MII_READ_ (0x00) /* ~of MII Write bit */ ++ ++#define MII_DATA (0x118) ++ ++#define FLOW (0x11C) ++#define FLOW_FCPT_ (0xFFFF0000) ++#define FLOW_FCPASS_ (0x00000004) ++#define FLOW_FCEN_ (0x00000002) ++#define FLOW_FCBSY_ (0x00000001) ++ ++#define VLAN1 (0x120) ++ ++#define VLAN2 (0x124) ++ ++#define WUFF (0x128) ++#define LAN9500_WUFF_NUM (4) ++#define LAN9500A_WUFF_NUM (8) ++ ++#define WUCSR (0x12C) ++#define WUCSR_WFF_PTR_RST_ (0x80000000) ++#define WUCSR_GUE_ (0x00000200) ++#define WUCSR_WUFR_ (0x00000040) ++#define WUCSR_MPR_ (0x00000020) ++#define WUCSR_WAKE_EN_ (0x00000004) ++#define WUCSR_MPEN_ (0x00000002) ++ ++#define COE_CR (0x130) ++#define Tx_COE_EN_ (0x00010000) ++#define Rx_COE_MODE_ (0x00000002) ++#define Rx_COE_EN_ (0x00000001) ++ ++/* Vendor-specific PHY Definitions */ ++ ++/* EDPD NLP / crossover time configuration (LAN9500A only) */ ++#define PHY_EDPD_CONFIG (16) ++#define PHY_EDPD_CONFIG_TX_NLP_EN_ ((u16)0x8000) ++#define PHY_EDPD_CONFIG_TX_NLP_1000_ ((u16)0x0000) ++#define PHY_EDPD_CONFIG_TX_NLP_768_ ((u16)0x2000) ++#define PHY_EDPD_CONFIG_TX_NLP_512_ ((u16)0x4000) ++#define PHY_EDPD_CONFIG_TX_NLP_256_ ((u16)0x6000) ++#define PHY_EDPD_CONFIG_RX_1_NLP_ ((u16)0x1000) ++#define PHY_EDPD_CONFIG_RX_NLP_64_ ((u16)0x0000) ++#define PHY_EDPD_CONFIG_RX_NLP_256_ ((u16)0x0400) ++#define PHY_EDPD_CONFIG_RX_NLP_512_ ((u16)0x0800) ++#define PHY_EDPD_CONFIG_RX_NLP_1000_ ((u16)0x0C00) ++#define PHY_EDPD_CONFIG_EXT_CROSSOVER_ ((u16)0x0001) ++#define PHY_EDPD_CONFIG_DEFAULT (PHY_EDPD_CONFIG_TX_NLP_EN_ | \ ++ PHY_EDPD_CONFIG_TX_NLP_768_ | \ ++ PHY_EDPD_CONFIG_RX_1_NLP_) ++ ++/* Mode Control/Status Register */ ++#define PHY_MODE_CTRL_STS (17) ++#define MODE_CTRL_STS_EDPWRDOWN_ ((u16)0x2000) ++#define MODE_CTRL_STS_ENERGYON_ ((u16)0x0002) ++ ++#define SPECIAL_CTRL_STS (27) ++#define SPECIAL_CTRL_STS_OVRRD_AMDIX_ ((u16)0x8000) ++#define SPECIAL_CTRL_STS_AMDIX_ENABLE_ ((u16)0x4000) ++#define SPECIAL_CTRL_STS_AMDIX_STATE_ ((u16)0x2000) ++ ++#define PHY_INT_SRC (29) ++#define PHY_INT_SRC_ENERGY_ON_ ((u16)0x0080) ++#define PHY_INT_SRC_ANEG_COMP_ ((u16)0x0040) ++#define PHY_INT_SRC_REMOTE_FAULT_ ((u16)0x0020) ++#define PHY_INT_SRC_LINK_DOWN_ ((u16)0x0010) ++ ++#define PHY_INT_MASK (30) ++#define PHY_INT_MASK_ENERGY_ON_ ((u16)0x0080) ++#define PHY_INT_MASK_ANEG_COMP_ ((u16)0x0040) ++#define PHY_INT_MASK_REMOTE_FAULT_ ((u16)0x0020) ++#define PHY_INT_MASK_LINK_DOWN_ ((u16)0x0010) ++#define PHY_INT_MASK_DEFAULT_ (PHY_INT_MASK_ANEG_COMP_ | \ ++ PHY_INT_MASK_LINK_DOWN_) ++ ++#define PHY_SPECIAL (31) ++#define PHY_SPECIAL_SPD_ ((u16)0x001C) ++#define PHY_SPECIAL_SPD_10HALF_ ((u16)0x0004) ++#define PHY_SPECIAL_SPD_10FULL_ ((u16)0x0014) ++#define PHY_SPECIAL_SPD_100HALF_ ((u16)0x0008) ++#define PHY_SPECIAL_SPD_100FULL_ ((u16)0x0018) ++ ++/* USB Vendor Requests */ ++#define USB_VENDOR_REQUEST_WRITE_REGISTER 0xA0 ++#define USB_VENDOR_REQUEST_READ_REGISTER 0xA1 ++#define USB_VENDOR_REQUEST_GET_STATS 0xA2 ++ ++/* Interrupt Endpoint status word bitfields */ ++#define INT_ENP_TX_STOP_ ((u32)BIT(17)) ++#define INT_ENP_RX_STOP_ ((u32)BIT(16)) ++#define INT_ENP_PHY_INT_ ((u32)BIT(15)) ++#define INT_ENP_TXE_ ((u32)BIT(14)) ++#define INT_ENP_TDFU_ ((u32)BIT(13)) ++#define INT_ENP_TDFO_ ((u32)BIT(12)) ++#define INT_ENP_RXDF_ ((u32)BIT(11)) ++ ++#endif /* _SMSC95XX_H */ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/sr9700.c backports-4.2.6-1/drivers/net/usb/sr9700.c +--- backports-4.2.6-1.org/drivers/net/usb/sr9700.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/sr9700.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,559 @@ ++/* ++ * CoreChip-sz SR9700 one chip USB 1.1 Ethernet Devices ++ * ++ * Author : Liu Junliang liujunliang_ljl@163.com ++ * ++ * Based on dm9601.c ++ * ++ * This file is licensed under the terms of the GNU General Public License ++ * version 2. This program is licensed "as is" without any warranty of any ++ * kind, whether express or implied. ++ */ ++ ++#include <linux/module.h> ++#include <linux/sched.h> ++#include <linux/stddef.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/crc32.h> ++#include <linux/usb/usbnet.h> ++ ++#include "sr9700.h" ++ ++static int sr_read(struct usbnet *dev, u8 reg, u16 length, void *data) ++{ ++ int err; ++ ++ err = usbnet_read_cmd(dev, SR_RD_REGS, SR_REQ_RD_REG, 0, reg, data, ++ length); ++ if ((err != length) && (err >= 0)) ++ err = -EINVAL; ++ return err; ++} ++ ++static int sr_write(struct usbnet *dev, u8 reg, u16 length, void *data) ++{ ++ int err; ++ ++ err = usbnet_write_cmd(dev, SR_WR_REGS, SR_REQ_WR_REG, 0, reg, data, ++ length); ++ if ((err >= 0) && (err < length)) ++ err = -EINVAL; ++ return err; ++} ++ ++static int sr_read_reg(struct usbnet *dev, u8 reg, u8 *value) ++{ ++ return sr_read(dev, reg, 1, value); ++} ++ ++static int sr_write_reg(struct usbnet *dev, u8 reg, u8 value) ++{ ++ return usbnet_write_cmd(dev, SR_WR_REGS, SR_REQ_WR_REG, ++ value, reg, NULL, 0); ++} ++ ++static void sr_write_async(struct usbnet *dev, u8 reg, u16 length, void *data) ++{ ++ usbnet_write_cmd_async(dev, SR_WR_REGS, SR_REQ_WR_REG, ++ 0, reg, data, length); ++} ++ ++static void sr_write_reg_async(struct usbnet *dev, u8 reg, u8 value) ++{ ++ usbnet_write_cmd_async(dev, SR_WR_REGS, SR_REQ_WR_REG, ++ value, reg, NULL, 0); ++} ++ ++static int wait_phy_eeprom_ready(struct usbnet *dev, int phy) ++{ ++ int i; ++ ++ for (i = 0; i < SR_SHARE_TIMEOUT; i++) { ++ u8 tmp = 0; ++ int ret; ++ ++ udelay(1); ++ ret = sr_read_reg(dev, SR_EPCR, &tmp); ++ if (ret < 0) ++ return ret; ++ ++ /* ready */ ++ if (!(tmp & EPCR_ERRE)) ++ return 0; ++ } ++ ++ netdev_err(dev->net, "%s write timed out!\n", phy ? "phy" : "eeprom"); ++ ++ return -EIO; ++} ++ ++static int sr_share_read_word(struct usbnet *dev, int phy, u8 reg, ++ __le16 *value) ++{ ++ int ret; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ sr_write_reg(dev, SR_EPAR, phy ? (reg | EPAR_PHY_ADR) : reg); ++ sr_write_reg(dev, SR_EPCR, phy ? (EPCR_EPOS | EPCR_ERPRR) : EPCR_ERPRR); ++ ++ ret = wait_phy_eeprom_ready(dev, phy); ++ if (ret < 0) ++ goto out_unlock; ++ ++ sr_write_reg(dev, SR_EPCR, 0x0); ++ ret = sr_read(dev, SR_EPDR, 2, value); ++ ++ netdev_dbg(dev->net, "read shared %d 0x%02x returned 0x%04x, %d\n", ++ phy, reg, *value, ret); ++ ++out_unlock: ++ mutex_unlock(&dev->phy_mutex); ++ return ret; ++} ++ ++static int sr_share_write_word(struct usbnet *dev, int phy, u8 reg, ++ __le16 value) ++{ ++ int ret; ++ ++ mutex_lock(&dev->phy_mutex); ++ ++ ret = sr_write(dev, SR_EPDR, 2, &value); ++ if (ret < 0) ++ goto out_unlock; ++ ++ sr_write_reg(dev, SR_EPAR, phy ? (reg | EPAR_PHY_ADR) : reg); ++ sr_write_reg(dev, SR_EPCR, phy ? (EPCR_WEP | EPCR_EPOS | EPCR_ERPRW) : ++ (EPCR_WEP | EPCR_ERPRW)); ++ ++ ret = wait_phy_eeprom_ready(dev, phy); ++ if (ret < 0) ++ goto out_unlock; ++ ++ sr_write_reg(dev, SR_EPCR, 0x0); ++ ++out_unlock: ++ mutex_unlock(&dev->phy_mutex); ++ return ret; ++} ++ ++static int sr_read_eeprom_word(struct usbnet *dev, u8 offset, void *value) ++{ ++ return sr_share_read_word(dev, 0, offset, value); ++} ++ ++static int sr9700_get_eeprom_len(struct net_device *netdev) ++{ ++ return SR_EEPROM_LEN; ++} ++ ++static int sr9700_get_eeprom(struct net_device *netdev, ++ struct ethtool_eeprom *eeprom, u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ __le16 *buf = (__le16 *)data; ++ int ret = 0; ++ int i; ++ ++ /* access is 16bit */ ++ if ((eeprom->offset & 0x01) || (eeprom->len & 0x01)) ++ return -EINVAL; ++ ++ for (i = 0; i < eeprom->len / 2; i++) { ++ ret = sr_read_eeprom_word(dev, eeprom->offset / 2 + i, buf + i); ++ if (ret < 0) ++ break; ++ } ++ ++ return ret; ++} ++ ++static int sr_mdio_read(struct net_device *netdev, int phy_id, int loc) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ __le16 res; ++ int rc = 0; ++ ++ if (phy_id) { ++ netdev_dbg(netdev, "Only internal phy supported\n"); ++ return 0; ++ } ++ ++ /* Access NSR_LINKST bit for link status instead of MII_BMSR */ ++ if (loc == MII_BMSR) { ++ u8 value; ++ ++ sr_read_reg(dev, SR_NSR, &value); ++ if (value & NSR_LINKST) ++ rc = 1; ++ } ++ sr_share_read_word(dev, 1, loc, &res); ++ if (rc == 1) ++ res = le16_to_cpu(res) | BMSR_LSTATUS; ++ else ++ res = le16_to_cpu(res) & ~BMSR_LSTATUS; ++ ++ netdev_dbg(netdev, "sr_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", ++ phy_id, loc, res); ++ ++ return res; ++} ++ ++static void sr_mdio_write(struct net_device *netdev, int phy_id, int loc, ++ int val) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ __le16 res = cpu_to_le16(val); ++ ++ if (phy_id) { ++ netdev_dbg(netdev, "Only internal phy supported\n"); ++ return; ++ } ++ ++ netdev_dbg(netdev, "sr_mdio_write() phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", ++ phy_id, loc, val); ++ ++ sr_share_write_word(dev, 1, loc, res); ++} ++ ++static u32 sr9700_get_link(struct net_device *netdev) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ u8 value = 0; ++ int rc = 0; ++ ++ /* Get the Link Status directly */ ++ sr_read_reg(dev, SR_NSR, &value); ++ if (value & NSR_LINKST) ++ rc = 1; ++ ++ return rc; ++} ++ ++static int sr9700_ioctl(struct net_device *netdev, struct ifreq *rq, int cmd) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ ++ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); ++} ++ ++static const struct ethtool_ops sr9700_ethtool_ops = { ++ .get_drvinfo = usbnet_get_drvinfo, ++ .get_link = sr9700_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_eeprom_len = sr9700_get_eeprom_len, ++ .get_eeprom = sr9700_get_eeprom, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .nway_reset = usbnet_nway_reset, ++}; ++ ++static void sr9700_set_multicast(struct net_device *netdev) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ /* We use the 20 byte dev->data for our 8 byte filter buffer ++ * to avoid allocating memory that is tricky to free later ++ */ ++ u8 *hashes = (u8 *)&dev->data; ++ /* rx_ctl setting : enable, disable_long, disable_crc */ ++ u8 rx_ctl = RCR_RXEN | RCR_DIS_CRC | RCR_DIS_LONG; ++ ++ memset(hashes, 0x00, SR_MCAST_SIZE); ++ /* broadcast address */ ++ hashes[SR_MCAST_SIZE - 1] |= SR_MCAST_ADDR_FLAG; ++ if (netdev->flags & IFF_PROMISC) { ++ rx_ctl |= RCR_PRMSC; ++ } else if (netdev->flags & IFF_ALLMULTI || ++ netdev_mc_count(netdev) > SR_MCAST_MAX) { ++ rx_ctl |= RCR_RUNT; ++ } else if (!netdev_mc_empty(netdev)) { ++ struct netdev_hw_addr *ha; ++ ++ netdev_for_each_mc_addr(ha, netdev) { ++ u32 crc = ether_crc(ETH_ALEN, ha->addr) >> 26; ++ hashes[crc >> 3] |= 1 << (crc & 0x7); ++ } ++ } ++ ++ sr_write_async(dev, SR_MAR, SR_MCAST_SIZE, hashes); ++ sr_write_reg_async(dev, SR_RCR, rx_ctl); ++} ++ ++static int sr9700_set_mac_address(struct net_device *netdev, void *p) ++{ ++ struct usbnet *dev = netdev_priv(netdev); ++ struct sockaddr *addr = p; ++ ++ if (!is_valid_ether_addr(addr->sa_data)) { ++ netdev_err(netdev, "not setting invalid mac address %pM\n", ++ addr->sa_data); ++ return -EINVAL; ++ } ++ ++ memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); ++ sr_write_async(dev, SR_PAR, 6, netdev->dev_addr); ++ ++ return 0; ++} ++ ++static const struct net_device_ops sr9700_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = sr9700_ioctl, ++ .ndo_set_rx_mode = sr9700_set_multicast, ++ .ndo_set_mac_address = sr9700_set_mac_address, ++}; ++ ++static int sr9700_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ struct net_device *netdev; ++ struct mii_if_info *mii; ++ int ret; ++ ++ ret = usbnet_get_endpoints(dev, intf); ++ if (ret) ++ goto out; ++ ++ netdev = dev->net; ++ ++ netdev->netdev_ops = &sr9700_netdev_ops; ++ netdev->ethtool_ops = &sr9700_ethtool_ops; ++ netdev->hard_header_len += SR_TX_OVERHEAD; ++ dev->hard_mtu = netdev->mtu + netdev->hard_header_len; ++ /* bulkin buffer is preferably not less than 3K */ ++ dev->rx_urb_size = 3072; ++ ++ mii = &dev->mii; ++ mii->dev = netdev; ++ mii->mdio_read = sr_mdio_read; ++ mii->mdio_write = sr_mdio_write; ++ mii->phy_id_mask = 0x1f; ++ mii->reg_num_mask = 0x1f; ++ ++ sr_write_reg(dev, SR_NCR, NCR_RST); ++ udelay(20); ++ ++ /* read MAC ++ * After Chip Power on, the Chip will reload the MAC from ++ * EEPROM automatically to PAR. In case there is no EEPROM externally, ++ * a default MAC address is stored in PAR for making chip work properly. ++ */ ++ if (sr_read(dev, SR_PAR, ETH_ALEN, netdev->dev_addr) < 0) { ++ netdev_err(netdev, "Error reading MAC address\n"); ++ ret = -ENODEV; ++ goto out; ++ } ++ ++ /* power up and reset phy */ ++ sr_write_reg(dev, SR_PRR, PRR_PHY_RST); ++ /* at least 10ms, here 20ms for safe */ ++ mdelay(20); ++ sr_write_reg(dev, SR_PRR, 0); ++ /* at least 1ms, here 2ms for reading right register */ ++ udelay(2 * 1000); ++ ++ /* receive broadcast packets */ ++ sr9700_set_multicast(netdev); ++ ++ sr_mdio_write(netdev, mii->phy_id, MII_BMCR, BMCR_RESET); ++ sr_mdio_write(netdev, mii->phy_id, MII_ADVERTISE, ADVERTISE_ALL | ++ ADVERTISE_CSMA | ADVERTISE_PAUSE_CAP); ++ mii_nway_restart(mii); ++ ++out: ++ return ret; ++} ++ ++static int sr9700_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ struct sk_buff *sr_skb; ++ int len; ++ ++ /* skb content (packets) format : ++ * p0 p1 p2 ...... pm ++ * / \ ++ * / \ ++ * / \ ++ * / \ ++ * p0b0 p0b1 p0b2 p0b3 ...... p0b(n-4) p0b(n-3)...p0bn ++ * ++ * p0 : packet 0 ++ * p0b0 : packet 0 byte 0 ++ * ++ * b0: rx status ++ * b1: packet length (incl crc) low ++ * b2: packet length (incl crc) high ++ * b3..n-4: packet data ++ * bn-3..bn: ethernet packet crc ++ */ ++ if (unlikely(skb->len < SR_RX_OVERHEAD)) { ++ netdev_err(dev->net, "unexpected tiny rx frame\n"); ++ return 0; ++ } ++ ++ /* one skb may contains multiple packets */ ++ while (skb->len > SR_RX_OVERHEAD) { ++ if (skb->data[0] != 0x40) ++ return 0; ++ ++ /* ignore the CRC length */ ++ len = (skb->data[1] | (skb->data[2] << 8)) - 4; ++ ++ if (len > ETH_FRAME_LEN) ++ return 0; ++ ++ /* the last packet of current skb */ ++ if (skb->len == (len + SR_RX_OVERHEAD)) { ++ skb_pull(skb, 3); ++ skb->len = len; ++ skb_set_tail_pointer(skb, len); ++ skb->truesize = len + sizeof(struct sk_buff); ++ return 2; ++ } ++ ++ /* skb_clone is used for address align */ ++ sr_skb = skb_clone(skb, GFP_ATOMIC); ++ if (!sr_skb) ++ return 0; ++ ++ sr_skb->len = len; ++ sr_skb->data = skb->data + 3; ++ skb_set_tail_pointer(sr_skb, len); ++ sr_skb->truesize = len + sizeof(struct sk_buff); ++ usbnet_skb_return(dev, sr_skb); ++ ++ skb_pull(skb, len + SR_RX_OVERHEAD); ++ }; ++ ++ return 0; ++} ++ ++static struct sk_buff *sr9700_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ++ gfp_t flags) ++{ ++ int len; ++ ++ /* SR9700 can only send out one ethernet packet at once. ++ * ++ * b0 b1 b2 b3 ...... b(n-4) b(n-3)...bn ++ * ++ * b0: rx status ++ * b1: packet length (incl crc) low ++ * b2: packet length (incl crc) high ++ * b3..n-4: packet data ++ * bn-3..bn: ethernet packet crc ++ */ ++ ++ len = skb->len; ++ ++ if (skb_headroom(skb) < SR_TX_OVERHEAD) { ++ struct sk_buff *skb2; ++ ++ skb2 = skb_copy_expand(skb, SR_TX_OVERHEAD, 0, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (!skb) ++ return NULL; ++ } ++ ++ __skb_push(skb, SR_TX_OVERHEAD); ++ ++ /* usbnet adds padding if length is a multiple of packet size ++ * if so, adjust length value in header ++ */ ++ if ((skb->len % dev->maxpacket) == 0) ++ len++; ++ ++ skb->data[0] = len; ++ skb->data[1] = len >> 8; ++ ++ return skb; ++} ++ ++static void sr9700_status(struct usbnet *dev, struct urb *urb) ++{ ++ int link; ++ u8 *buf; ++ ++ /* format: ++ b0: net status ++ b1: tx status 1 ++ b2: tx status 2 ++ b3: rx status ++ b4: rx overflow ++ b5: rx count ++ b6: tx count ++ b7: gpr ++ */ ++ ++ if (urb->actual_length < 8) ++ return; ++ ++ buf = urb->transfer_buffer; ++ ++ link = !!(buf[0] & 0x40); ++ if (netif_carrier_ok(dev->net) != link) { ++ usbnet_link_change(dev, link, 1); ++ netdev_dbg(dev->net, "Link Status is: %d\n", link); ++ } ++} ++ ++static int sr9700_link_reset(struct usbnet *dev) ++{ ++ struct ethtool_cmd ecmd; ++ ++ mii_check_media(&dev->mii, 1, 1); ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ ++ netdev_dbg(dev->net, "link_reset() speed: %d duplex: %d\n", ++ ecmd.speed, ecmd.duplex); ++ ++ return 0; ++} ++ ++static const struct driver_info sr9700_driver_info = { ++ .description = "CoreChip SR9700 USB Ethernet", ++ .flags = FLAG_ETHER, ++ .bind = sr9700_bind, ++ .rx_fixup = sr9700_rx_fixup, ++ .tx_fixup = sr9700_tx_fixup, ++ .status = sr9700_status, ++ .link_reset = sr9700_link_reset, ++ .reset = sr9700_link_reset, ++}; ++ ++static const struct usb_device_id products[] = { ++ { ++ USB_DEVICE(0x0fe6, 0x9700), /* SR9700 device */ ++ .driver_info = (unsigned long)&sr9700_driver_info, ++ }, ++ {}, /* END */ ++}; ++ ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver sr9700_usb_driver = { ++ .name = "sr9700", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(sr9700_usb_driver); ++ ++MODULE_AUTHOR("liujl liujunliang_ljl@163.com"); ++MODULE_DESCRIPTION("SR9700 one chip USB 1.1 USB to Ethernet device from http://www.corechip-sz.com/"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/sr9700.h backports-4.2.6-1/drivers/net/usb/sr9700.h +--- backports-4.2.6-1.org/drivers/net/usb/sr9700.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/sr9700.h 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,173 @@ ++/* ++ * CoreChip-sz SR9700 one chip USB 1.1 Ethernet Devices ++ * ++ * Author : Liu Junliang liujunliang_ljl@163.com ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * version 2 as published by the Free Software Foundation. ++ */ ++ ++#ifndef _SR9700_H ++#define _SR9700_H ++ ++/* sr9700 spec. register table on Linux platform */ ++ ++/* Network Control Reg */ ++#define SR_NCR 0x00 ++#define NCR_RST (1 << 0) ++#define NCR_LBK (3 << 1) ++#define NCR_FDX (1 << 3) ++#define NCR_WAKEEN (1 << 6) ++/* Network Status Reg */ ++#define SR_NSR 0x01 ++#define NSR_RXRDY (1 << 0) ++#define NSR_RXOV (1 << 1) ++#define NSR_TX1END (1 << 2) ++#define NSR_TX2END (1 << 3) ++#define NSR_TXFULL (1 << 4) ++#define NSR_WAKEST (1 << 5) ++#define NSR_LINKST (1 << 6) ++#define NSR_SPEED (1 << 7) ++/* Tx Control Reg */ ++#define SR_TCR 0x02 ++#define TCR_CRC_DIS (1 << 1) ++#define TCR_PAD_DIS (1 << 2) ++#define TCR_LC_CARE (1 << 3) ++#define TCR_CRS_CARE (1 << 4) ++#define TCR_EXCECM (1 << 5) ++#define TCR_LF_EN (1 << 6) ++/* Tx Status Reg for Packet Index 1 */ ++#define SR_TSR1 0x03 ++#define TSR1_EC (1 << 2) ++#define TSR1_COL (1 << 3) ++#define TSR1_LC (1 << 4) ++#define TSR1_NC (1 << 5) ++#define TSR1_LOC (1 << 6) ++#define TSR1_TLF (1 << 7) ++/* Tx Status Reg for Packet Index 2 */ ++#define SR_TSR2 0x04 ++#define TSR2_EC (1 << 2) ++#define TSR2_COL (1 << 3) ++#define TSR2_LC (1 << 4) ++#define TSR2_NC (1 << 5) ++#define TSR2_LOC (1 << 6) ++#define TSR2_TLF (1 << 7) ++/* Rx Control Reg*/ ++#define SR_RCR 0x05 ++#define RCR_RXEN (1 << 0) ++#define RCR_PRMSC (1 << 1) ++#define RCR_RUNT (1 << 2) ++#define RCR_ALL (1 << 3) ++#define RCR_DIS_CRC (1 << 4) ++#define RCR_DIS_LONG (1 << 5) ++/* Rx Status Reg */ ++#define SR_RSR 0x06 ++#define RSR_AE (1 << 2) ++#define RSR_MF (1 << 6) ++#define RSR_RF (1 << 7) ++/* Rx Overflow Counter Reg */ ++#define SR_ROCR 0x07 ++#define ROCR_ROC (0x7F << 0) ++#define ROCR_RXFU (1 << 7) ++/* Back Pressure Threshold Reg */ ++#define SR_BPTR 0x08 ++#define BPTR_JPT (0x0F << 0) ++#define BPTR_BPHW (0x0F << 4) ++/* Flow Control Threshold Reg */ ++#define SR_FCTR 0x09 ++#define FCTR_LWOT (0x0F << 0) ++#define FCTR_HWOT (0x0F << 4) ++/* rx/tx Flow Control Reg */ ++#define SR_FCR 0x0A ++#define FCR_FLCE (1 << 0) ++#define FCR_BKPA (1 << 4) ++#define FCR_TXPEN (1 << 5) ++#define FCR_TXPF (1 << 6) ++#define FCR_TXP0 (1 << 7) ++/* Eeprom & Phy Control Reg */ ++#define SR_EPCR 0x0B ++#define EPCR_ERRE (1 << 0) ++#define EPCR_ERPRW (1 << 1) ++#define EPCR_ERPRR (1 << 2) ++#define EPCR_EPOS (1 << 3) ++#define EPCR_WEP (1 << 4) ++/* Eeprom & Phy Address Reg */ ++#define SR_EPAR 0x0C ++#define EPAR_EROA (0x3F << 0) ++#define EPAR_PHY_ADR_MASK (0x03 << 6) ++#define EPAR_PHY_ADR (0x01 << 6) ++/* Eeprom & Phy Data Reg */ ++#define SR_EPDR 0x0D /* 0x0D ~ 0x0E for Data Reg Low & High */ ++/* Wakeup Control Reg */ ++#define SR_WCR 0x0F ++#define WCR_MAGICST (1 << 0) ++#define WCR_LINKST (1 << 2) ++#define WCR_MAGICEN (1 << 3) ++#define WCR_LINKEN (1 << 5) ++/* Physical Address Reg */ ++#define SR_PAR 0x10 /* 0x10 ~ 0x15 6 bytes for PAR */ ++/* Multicast Address Reg */ ++#define SR_MAR 0x16 /* 0x16 ~ 0x1D 8 bytes for MAR */ ++/* 0x1e unused */ ++/* Phy Reset Reg */ ++#define SR_PRR 0x1F ++#define PRR_PHY_RST (1 << 0) ++/* Tx sdram Write Pointer Address Low */ ++#define SR_TWPAL 0x20 ++/* Tx sdram Write Pointer Address High */ ++#define SR_TWPAH 0x21 ++/* Tx sdram Read Pointer Address Low */ ++#define SR_TRPAL 0x22 ++/* Tx sdram Read Pointer Address High */ ++#define SR_TRPAH 0x23 ++/* Rx sdram Write Pointer Address Low */ ++#define SR_RWPAL 0x24 ++/* Rx sdram Write Pointer Address High */ ++#define SR_RWPAH 0x25 ++/* Rx sdram Read Pointer Address Low */ ++#define SR_RRPAL 0x26 ++/* Rx sdram Read Pointer Address High */ ++#define SR_RRPAH 0x27 ++/* Vendor ID register */ ++#define SR_VID 0x28 /* 0x28 ~ 0x29 2 bytes for VID */ ++/* Product ID register */ ++#define SR_PID 0x2A /* 0x2A ~ 0x2B 2 bytes for PID */ ++/* CHIP Revision register */ ++#define SR_CHIPR 0x2C ++/* 0x2D --> 0xEF unused */ ++/* USB Device Address */ ++#define SR_USBDA 0xF0 ++#define USBDA_USBFA (0x7F << 0) ++/* RX packet Counter Reg */ ++#define SR_RXC 0xF1 ++/* Tx packet Counter & USB Status Reg */ ++#define SR_TXC_USBS 0xF2 ++#define TXC_USBS_TXC0 (1 << 0) ++#define TXC_USBS_TXC1 (1 << 1) ++#define TXC_USBS_TXC2 (1 << 2) ++#define TXC_USBS_EP1RDY (1 << 5) ++#define TXC_USBS_SUSFLAG (1 << 6) ++#define TXC_USBS_RXFAULT (1 << 7) ++/* USB Control register */ ++#define SR_USBC 0xF4 ++#define USBC_EP3NAK (1 << 4) ++#define USBC_EP3ACK (1 << 5) ++ ++/* Register access commands and flags */ ++#define SR_RD_REGS 0x00 ++#define SR_WR_REGS 0x01 ++#define SR_WR_REG 0x03 ++#define SR_REQ_RD_REG (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE) ++#define SR_REQ_WR_REG (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) ++ ++/* parameters */ ++#define SR_SHARE_TIMEOUT 1000 ++#define SR_EEPROM_LEN 256 ++#define SR_MCAST_SIZE 8 ++#define SR_MCAST_ADDR_FLAG 0x80 ++#define SR_MCAST_MAX 64 ++#define SR_TX_OVERHEAD 2 /* 2bytes header */ ++#define SR_RX_OVERHEAD 7 /* 3bytes header + 4crc tail */ ++ ++#endif /* _SR9700_H */ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/sr9800.c backports-4.2.6-1/drivers/net/usb/sr9800.c +--- backports-4.2.6-1.org/drivers/net/usb/sr9800.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/sr9800.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,875 @@ ++/* CoreChip-sz SR9800 one chip USB 2.0 Ethernet Devices ++ * ++ * Author : Liu Junliang liujunliang_ljl@163.com ++ * ++ * Based on asix_common.c, asix_devices.c ++ * ++ * This file is licensed under the terms of the GNU General Public License ++ * version 2. This program is licensed "as is" without any warranty of any ++ * kind, whether express or implied.* ++ */ ++ ++#include <linux/module.h> ++#include <linux/kmod.h> ++#include <linux/init.h> ++#include <linux/netdevice.h> ++#include <linux/etherdevice.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/usb.h> ++#include <linux/crc32.h> ++#include <linux/usb/usbnet.h> ++#include <linux/slab.h> ++#include <linux/if_vlan.h> ++ ++#include "sr9800.h" ++ ++static int sr_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data) ++{ ++ int err; ++ ++ err = usbnet_read_cmd(dev, cmd, SR_REQ_RD_REG, value, index, ++ data, size); ++ if ((err != size) && (err >= 0)) ++ err = -EINVAL; ++ ++ return err; ++} ++ ++static int sr_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data) ++{ ++ int err; ++ ++ err = usbnet_write_cmd(dev, cmd, SR_REQ_WR_REG, value, index, ++ data, size); ++ if ((err != size) && (err >= 0)) ++ err = -EINVAL; ++ ++ return err; ++} ++ ++static void ++sr_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index, ++ u16 size, void *data) ++{ ++ usbnet_write_cmd_async(dev, cmd, SR_REQ_WR_REG, value, index, data, ++ size); ++} ++ ++static int sr_rx_fixup(struct usbnet *dev, struct sk_buff *skb) ++{ ++ int offset = 0; ++ ++ /* This check is no longer done by usbnet */ ++ if (skb->len < dev->net->hard_header_len) ++ return 0; ++ ++ while (offset + sizeof(u32) < skb->len) { ++ struct sk_buff *sr_skb; ++ u16 size; ++ u32 header = get_unaligned_le32(skb->data + offset); ++ ++ offset += sizeof(u32); ++ /* get the packet length */ ++ size = (u16) (header & 0x7ff); ++ if (size != ((~header >> 16) & 0x07ff)) { ++ netdev_err(dev->net, "%s : Bad Header Length\n", ++ __func__); ++ return 0; ++ } ++ ++ if ((size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) || ++ (size + offset > skb->len)) { ++ netdev_err(dev->net, "%s : Bad RX Length %d\n", ++ __func__, size); ++ return 0; ++ } ++ sr_skb = netdev_alloc_skb_ip_align(dev->net, size); ++ if (!sr_skb) ++ return 0; ++ ++ skb_put(sr_skb, size); ++ memcpy(sr_skb->data, skb->data + offset, size); ++ usbnet_skb_return(dev, sr_skb); ++ ++ offset += (size + 1) & 0xfffe; ++ } ++ ++ if (skb->len != offset) { ++ netdev_err(dev->net, "%s : Bad SKB Length %d\n", __func__, ++ skb->len); ++ return 0; ++ } ++ ++ return 1; ++} ++ ++static struct sk_buff *sr_tx_fixup(struct usbnet *dev, struct sk_buff *skb, ++ gfp_t flags) ++{ ++ int headroom = skb_headroom(skb); ++ int tailroom = skb_tailroom(skb); ++ u32 padbytes = 0xffff0000; ++ u32 packet_len; ++ int padlen; ++ ++ padlen = ((skb->len + 4) % (dev->maxpacket - 1)) ? 0 : 4; ++ ++ if ((!skb_cloned(skb)) && ((headroom + tailroom) >= (4 + padlen))) { ++ if ((headroom < 4) || (tailroom < padlen)) { ++ skb->data = memmove(skb->head + 4, skb->data, ++ skb->len); ++ skb_set_tail_pointer(skb, skb->len); ++ } ++ } else { ++ struct sk_buff *skb2; ++ skb2 = skb_copy_expand(skb, 4, padlen, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (!skb) ++ return NULL; ++ } ++ ++ skb_push(skb, 4); ++ packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4); ++ cpu_to_le32s(&packet_len); ++ skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len)); ++ ++ if (padlen) { ++ cpu_to_le32s(&padbytes); ++ memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes)); ++ skb_put(skb, sizeof(padbytes)); ++ } ++ ++ usbnet_set_skb_tx_stats(skb, 1, 0); ++ return skb; ++} ++ ++static void sr_status(struct usbnet *dev, struct urb *urb) ++{ ++ struct sr9800_int_data *event; ++ int link; ++ ++ if (urb->actual_length < 8) ++ return; ++ ++ event = urb->transfer_buffer; ++ link = event->link & 0x01; ++ if (netif_carrier_ok(dev->net) != link) { ++ usbnet_link_change(dev, link, 1); ++ netdev_dbg(dev->net, "Link Status is: %d\n", link); ++ } ++ ++ return; ++} ++ ++static inline int sr_set_sw_mii(struct usbnet *dev) ++{ ++ int ret; ++ ++ ret = sr_write_cmd(dev, SR_CMD_SET_SW_MII, 0x0000, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to enable software MII access\n"); ++ return ret; ++} ++ ++static inline int sr_set_hw_mii(struct usbnet *dev) ++{ ++ int ret; ++ ++ ret = sr_write_cmd(dev, SR_CMD_SET_HW_MII, 0x0000, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to enable hardware MII access\n"); ++ return ret; ++} ++ ++static inline int sr_get_phy_addr(struct usbnet *dev) ++{ ++ u8 buf[2]; ++ int ret; ++ ++ ret = sr_read_cmd(dev, SR_CMD_READ_PHY_ID, 0, 0, 2, buf); ++ if (ret < 0) { ++ netdev_err(dev->net, "%s : Error reading PHYID register:%02x\n", ++ __func__, ret); ++ goto out; ++ } ++ netdev_dbg(dev->net, "%s : returning 0x%04x\n", __func__, ++ *((__le16 *)buf)); ++ ++ ret = buf[1]; ++ ++out: ++ return ret; ++} ++ ++static int sr_sw_reset(struct usbnet *dev, u8 flags) ++{ ++ int ret; ++ ++ ret = sr_write_cmd(dev, SR_CMD_SW_RESET, flags, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to send software reset:%02x\n", ++ ret); ++ ++ return ret; ++} ++ ++static u16 sr_read_rx_ctl(struct usbnet *dev) ++{ ++ __le16 v; ++ int ret; ++ ++ ret = sr_read_cmd(dev, SR_CMD_READ_RX_CTL, 0, 0, 2, &v); ++ if (ret < 0) { ++ netdev_err(dev->net, "Error reading RX_CTL register:%02x\n", ++ ret); ++ goto out; ++ } ++ ++ ret = le16_to_cpu(v); ++out: ++ return ret; ++} ++ ++static int sr_write_rx_ctl(struct usbnet *dev, u16 mode) ++{ ++ int ret; ++ ++ netdev_dbg(dev->net, "%s : mode = 0x%04x\n", __func__, mode); ++ ret = sr_write_cmd(dev, SR_CMD_WRITE_RX_CTL, mode, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, ++ "Failed to write RX_CTL mode to 0x%04x:%02x\n", ++ mode, ret); ++ ++ return ret; ++} ++ ++static u16 sr_read_medium_status(struct usbnet *dev) ++{ ++ __le16 v; ++ int ret; ++ ++ ret = sr_read_cmd(dev, SR_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v); ++ if (ret < 0) { ++ netdev_err(dev->net, ++ "Error reading Medium Status register:%02x\n", ret); ++ return ret; /* TODO: callers not checking for error ret */ ++ } ++ ++ return le16_to_cpu(v); ++} ++ ++static int sr_write_medium_mode(struct usbnet *dev, u16 mode) ++{ ++ int ret; ++ ++ netdev_dbg(dev->net, "%s : mode = 0x%04x\n", __func__, mode); ++ ret = sr_write_cmd(dev, SR_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, ++ "Failed to write Medium Mode mode to 0x%04x:%02x\n", ++ mode, ret); ++ return ret; ++} ++ ++static int sr_write_gpio(struct usbnet *dev, u16 value, int sleep) ++{ ++ int ret; ++ ++ netdev_dbg(dev->net, "%s : value = 0x%04x\n", __func__, value); ++ ret = sr_write_cmd(dev, SR_CMD_WRITE_GPIOS, value, 0, 0, NULL); ++ if (ret < 0) ++ netdev_err(dev->net, "Failed to write GPIO value 0x%04x:%02x\n", ++ value, ret); ++ if (sleep) ++ msleep(sleep); ++ ++ return ret; ++} ++ ++/* SR9800 have a 16-bit RX_CTL value */ ++static void sr_set_multicast(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct sr_data *data = (struct sr_data *)&dev->data; ++ u16 rx_ctl = SR_DEFAULT_RX_CTL; ++ ++ if (net->flags & IFF_PROMISC) { ++ rx_ctl |= SR_RX_CTL_PRO; ++ } else if (net->flags & IFF_ALLMULTI || ++ netdev_mc_count(net) > SR_MAX_MCAST) { ++ rx_ctl |= SR_RX_CTL_AMALL; ++ } else if (netdev_mc_empty(net)) { ++ /* just broadcast and directed */ ++ } else { ++ /* We use the 20 byte dev->data ++ * for our 8 byte filter buffer ++ * to avoid allocating memory that ++ * is tricky to free later ++ */ ++ struct netdev_hw_addr *ha; ++ u32 crc_bits; ++ ++ memset(data->multi_filter, 0, SR_MCAST_FILTER_SIZE); ++ ++ /* Build the multicast hash filter. */ ++ netdev_for_each_mc_addr(ha, net) { ++ crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26; ++ data->multi_filter[crc_bits >> 3] |= ++ 1 << (crc_bits & 7); ++ } ++ ++ sr_write_cmd_async(dev, SR_CMD_WRITE_MULTI_FILTER, 0, 0, ++ SR_MCAST_FILTER_SIZE, data->multi_filter); ++ ++ rx_ctl |= SR_RX_CTL_AM; ++ } ++ ++ sr_write_cmd_async(dev, SR_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL); ++} ++ ++static int sr_mdio_read(struct net_device *net, int phy_id, int loc) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ __le16 res; ++ ++ mutex_lock(&dev->phy_mutex); ++ sr_set_sw_mii(dev); ++ sr_read_cmd(dev, SR_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res); ++ sr_set_hw_mii(dev); ++ mutex_unlock(&dev->phy_mutex); ++ ++ netdev_dbg(dev->net, ++ "%s : phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", __func__, ++ phy_id, loc, le16_to_cpu(res)); ++ ++ return le16_to_cpu(res); ++} ++ ++static void ++sr_mdio_write(struct net_device *net, int phy_id, int loc, int val) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ __le16 res = cpu_to_le16(val); ++ ++ netdev_dbg(dev->net, ++ "%s : phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", __func__, ++ phy_id, loc, val); ++ mutex_lock(&dev->phy_mutex); ++ sr_set_sw_mii(dev); ++ sr_write_cmd(dev, SR_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res); ++ sr_set_hw_mii(dev); ++ mutex_unlock(&dev->phy_mutex); ++} ++ ++/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */ ++static u32 sr_get_phyid(struct usbnet *dev) ++{ ++ int phy_reg; ++ u32 phy_id; ++ int i; ++ ++ /* Poll for the rare case the FW or phy isn't ready yet. */ ++ for (i = 0; i < 100; i++) { ++ phy_reg = sr_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1); ++ if (phy_reg != 0 && phy_reg != 0xFFFF) ++ break; ++ mdelay(1); ++ } ++ ++ if (phy_reg <= 0 || phy_reg == 0xFFFF) ++ return 0; ++ ++ phy_id = (phy_reg & 0xffff) << 16; ++ ++ phy_reg = sr_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2); ++ if (phy_reg < 0) ++ return 0; ++ ++ phy_id |= (phy_reg & 0xffff); ++ ++ return phy_id; ++} ++ ++static void ++sr_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u8 opt; ++ ++ if (sr_read_cmd(dev, SR_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) { ++ wolinfo->supported = 0; ++ wolinfo->wolopts = 0; ++ return; ++ } ++ wolinfo->supported = WAKE_PHY | WAKE_MAGIC; ++ wolinfo->wolopts = 0; ++ if (opt & SR_MONITOR_LINK) ++ wolinfo->wolopts |= WAKE_PHY; ++ if (opt & SR_MONITOR_MAGIC) ++ wolinfo->wolopts |= WAKE_MAGIC; ++} ++ ++static int ++sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ u8 opt = 0; ++ ++ if (wolinfo->wolopts & WAKE_PHY) ++ opt |= SR_MONITOR_LINK; ++ if (wolinfo->wolopts & WAKE_MAGIC) ++ opt |= SR_MONITOR_MAGIC; ++ ++ if (sr_write_cmd(dev, SR_CMD_WRITE_MONITOR_MODE, ++ opt, 0, 0, NULL) < 0) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int sr_get_eeprom_len(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct sr_data *data = (struct sr_data *)&dev->data; ++ ++ return data->eeprom_len; ++} ++ ++static int sr_get_eeprom(struct net_device *net, ++ struct ethtool_eeprom *eeprom, u8 *data) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ __le16 *ebuf = (__le16 *)data; ++ int ret; ++ int i; ++ ++ /* Crude hack to ensure that we don't overwrite memory ++ * if an odd length is supplied ++ */ ++ if (eeprom->len % 2) ++ return -EINVAL; ++ ++ eeprom->magic = SR_EEPROM_MAGIC; ++ ++ /* sr9800 returns 2 bytes from eeprom on read */ ++ for (i = 0; i < eeprom->len / 2; i++) { ++ ret = sr_read_cmd(dev, SR_CMD_READ_EEPROM, eeprom->offset + i, ++ 0, 2, &ebuf[i]); ++ if (ret < 0) ++ return -EINVAL; ++ } ++ return 0; ++} ++ ++static void sr_get_drvinfo(struct net_device *net, ++ struct ethtool_drvinfo *info) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct sr_data *data = (struct sr_data *)&dev->data; ++ ++ /* Inherit standard device info */ ++ usbnet_get_drvinfo(net, info); ++ strncpy(info->driver, DRIVER_NAME, sizeof(info->driver)); ++ strncpy(info->version, DRIVER_VERSION, sizeof(info->version)); ++ info->eedump_len = data->eeprom_len; ++} ++ ++static u32 sr_get_link(struct net_device *net) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ return mii_link_ok(&dev->mii); ++} ++ ++static int sr_ioctl(struct net_device *net, struct ifreq *rq, int cmd) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ ++ return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL); ++} ++ ++static int sr_set_mac_address(struct net_device *net, void *p) ++{ ++ struct usbnet *dev = netdev_priv(net); ++ struct sr_data *data = (struct sr_data *)&dev->data; ++ struct sockaddr *addr = p; ++ ++ if (netif_running(net)) ++ return -EBUSY; ++ if (!is_valid_ether_addr(addr->sa_data)) ++ return -EADDRNOTAVAIL; ++ ++ memcpy(net->dev_addr, addr->sa_data, ETH_ALEN); ++ ++ /* We use the 20 byte dev->data ++ * for our 6 byte mac buffer ++ * to avoid allocating memory that ++ * is tricky to free later ++ */ ++ memcpy(data->mac_addr, addr->sa_data, ETH_ALEN); ++ sr_write_cmd_async(dev, SR_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, ++ data->mac_addr); ++ ++ return 0; ++} ++ ++static const struct ethtool_ops sr9800_ethtool_ops = { ++ .get_drvinfo = sr_get_drvinfo, ++ .get_link = sr_get_link, ++ .get_msglevel = usbnet_get_msglevel, ++ .set_msglevel = usbnet_set_msglevel, ++ .get_wol = sr_get_wol, ++ .set_wol = sr_set_wol, ++ .get_eeprom_len = sr_get_eeprom_len, ++ .get_eeprom = sr_get_eeprom, ++ .get_settings = usbnet_get_settings, ++ .set_settings = usbnet_set_settings, ++ .nway_reset = usbnet_nway_reset, ++}; ++ ++static int sr9800_link_reset(struct usbnet *dev) ++{ ++ struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET }; ++ u16 mode; ++ ++ mii_check_media(&dev->mii, 1, 1); ++ mii_ethtool_gset(&dev->mii, &ecmd); ++ mode = SR9800_MEDIUM_DEFAULT; ++ ++ if (ethtool_cmd_speed(&ecmd) != SPEED_100) ++ mode &= ~SR_MEDIUM_PS; ++ ++ if (ecmd.duplex != DUPLEX_FULL) ++ mode &= ~SR_MEDIUM_FD; ++ ++ netdev_dbg(dev->net, "%s : speed: %u duplex: %d mode: 0x%04x\n", ++ __func__, ethtool_cmd_speed(&ecmd), ecmd.duplex, mode); ++ ++ sr_write_medium_mode(dev, mode); ++ ++ return 0; ++} ++ ++ ++static int sr9800_set_default_mode(struct usbnet *dev) ++{ ++ u16 rx_ctl; ++ int ret; ++ ++ sr_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET); ++ sr_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE, ++ ADVERTISE_ALL | ADVERTISE_CSMA); ++ mii_nway_restart(&dev->mii); ++ ++ ret = sr_write_medium_mode(dev, SR9800_MEDIUM_DEFAULT); ++ if (ret < 0) ++ goto out; ++ ++ ret = sr_write_cmd(dev, SR_CMD_WRITE_IPG012, ++ SR9800_IPG0_DEFAULT | SR9800_IPG1_DEFAULT, ++ SR9800_IPG2_DEFAULT, 0, NULL); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret); ++ goto out; ++ } ++ ++ /* Set RX_CTL to default values with 2k buffer, and enable cactus */ ++ ret = sr_write_rx_ctl(dev, SR_DEFAULT_RX_CTL); ++ if (ret < 0) ++ goto out; ++ ++ rx_ctl = sr_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n", ++ rx_ctl); ++ ++ rx_ctl = sr_read_medium_status(dev); ++ netdev_dbg(dev->net, "Medium Status:0x%04x after all initializations\n", ++ rx_ctl); ++ ++ return 0; ++out: ++ return ret; ++} ++ ++static int sr9800_reset(struct usbnet *dev) ++{ ++ struct sr_data *data = (struct sr_data *)&dev->data; ++ int ret, embd_phy; ++ u16 rx_ctl; ++ ++ ret = sr_write_gpio(dev, ++ SR_GPIO_RSE | SR_GPIO_GPO_2 | SR_GPIO_GPO2EN, 5); ++ if (ret < 0) ++ goto out; ++ ++ embd_phy = ((sr_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0); ++ ++ ret = sr_write_cmd(dev, SR_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); ++ goto out; ++ } ++ ++ ret = sr_sw_reset(dev, SR_SWRESET_IPPD | SR_SWRESET_PRL); ++ if (ret < 0) ++ goto out; ++ ++ msleep(150); ++ ++ ret = sr_sw_reset(dev, SR_SWRESET_CLEAR); ++ if (ret < 0) ++ goto out; ++ ++ msleep(150); ++ ++ if (embd_phy) { ++ ret = sr_sw_reset(dev, SR_SWRESET_IPRL); ++ if (ret < 0) ++ goto out; ++ } else { ++ ret = sr_sw_reset(dev, SR_SWRESET_PRTE); ++ if (ret < 0) ++ goto out; ++ } ++ ++ msleep(150); ++ rx_ctl = sr_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); ++ ret = sr_write_rx_ctl(dev, 0x0000); ++ if (ret < 0) ++ goto out; ++ ++ rx_ctl = sr_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); ++ ++ ret = sr_sw_reset(dev, SR_SWRESET_PRL); ++ if (ret < 0) ++ goto out; ++ ++ msleep(150); ++ ++ ret = sr_sw_reset(dev, SR_SWRESET_IPRL | SR_SWRESET_PRL); ++ if (ret < 0) ++ goto out; ++ ++ msleep(150); ++ ++ ret = sr9800_set_default_mode(dev); ++ if (ret < 0) ++ goto out; ++ ++ /* Rewrite MAC address */ ++ memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN); ++ ret = sr_write_cmd(dev, SR_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN, ++ data->mac_addr); ++ if (ret < 0) ++ goto out; ++ ++ return 0; ++ ++out: ++ return ret; ++} ++ ++static const struct net_device_ops sr9800_netdev_ops = { ++ .ndo_open = usbnet_open, ++ .ndo_stop = usbnet_stop, ++ .ndo_start_xmit = usbnet_start_xmit, ++ .ndo_tx_timeout = usbnet_tx_timeout, ++ .ndo_change_mtu = usbnet_change_mtu, ++ .ndo_set_mac_address = sr_set_mac_address, ++ .ndo_validate_addr = eth_validate_addr, ++ .ndo_do_ioctl = sr_ioctl, ++ .ndo_set_rx_mode = sr_set_multicast, ++}; ++ ++static int sr9800_phy_powerup(struct usbnet *dev) ++{ ++ int ret; ++ ++ /* set the embedded Ethernet PHY in power-down state */ ++ ret = sr_sw_reset(dev, SR_SWRESET_IPPD | SR_SWRESET_IPRL); ++ if (ret < 0) { ++ netdev_err(dev->net, "Failed to power down PHY : %d\n", ret); ++ return ret; ++ } ++ msleep(20); ++ ++ /* set the embedded Ethernet PHY in power-up state */ ++ ret = sr_sw_reset(dev, SR_SWRESET_IPRL); ++ if (ret < 0) { ++ netdev_err(dev->net, "Failed to reset PHY: %d\n", ret); ++ return ret; ++ } ++ msleep(600); ++ ++ /* set the embedded Ethernet PHY in reset state */ ++ ret = sr_sw_reset(dev, SR_SWRESET_CLEAR); ++ if (ret < 0) { ++ netdev_err(dev->net, "Failed to power up PHY: %d\n", ret); ++ return ret; ++ } ++ msleep(20); ++ ++ /* set the embedded Ethernet PHY in power-up state */ ++ ret = sr_sw_reset(dev, SR_SWRESET_IPRL); ++ if (ret < 0) { ++ netdev_err(dev->net, "Failed to reset PHY: %d\n", ret); ++ return ret; ++ } ++ ++ return 0; ++} ++ ++static int sr9800_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ struct sr_data *data = (struct sr_data *)&dev->data; ++ u16 led01_mux, led23_mux; ++ int ret, embd_phy; ++ u32 phyid; ++ u16 rx_ctl; ++ ++ data->eeprom_len = SR9800_EEPROM_LEN; ++ ++ usbnet_get_endpoints(dev, intf); ++ ++ /* LED Setting Rule : ++ * AABB:CCDD ++ * AA : MFA0(LED0) ++ * BB : MFA1(LED1) ++ * CC : MFA2(LED2), Reserved for SR9800 ++ * DD : MFA3(LED3), Reserved for SR9800 ++ */ ++ led01_mux = (SR_LED_MUX_LINK_ACTIVE << 8) | SR_LED_MUX_LINK; ++ led23_mux = (SR_LED_MUX_LINK_ACTIVE << 8) | SR_LED_MUX_TX_ACTIVE; ++ ret = sr_write_cmd(dev, SR_CMD_LED_MUX, led01_mux, led23_mux, 0, NULL); ++ if (ret < 0) { ++ netdev_err(dev->net, "set LINK LED failed : %d\n", ret); ++ goto out; ++ } ++ ++ /* Get the MAC address */ ++ ret = sr_read_cmd(dev, SR_CMD_READ_NODE_ID, 0, 0, ETH_ALEN, ++ dev->net->dev_addr); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret); ++ return ret; ++ } ++ netdev_dbg(dev->net, "mac addr : %pM\n", dev->net->dev_addr); ++ ++ /* Initialize MII structure */ ++ dev->mii.dev = dev->net; ++ dev->mii.mdio_read = sr_mdio_read; ++ dev->mii.mdio_write = sr_mdio_write; ++ dev->mii.phy_id_mask = 0x1f; ++ dev->mii.reg_num_mask = 0x1f; ++ dev->mii.phy_id = sr_get_phy_addr(dev); ++ ++ dev->net->netdev_ops = &sr9800_netdev_ops; ++ dev->net->ethtool_ops = &sr9800_ethtool_ops; ++ ++ embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0); ++ /* Reset the PHY to normal operation mode */ ++ ret = sr_write_cmd(dev, SR_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL); ++ if (ret < 0) { ++ netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret); ++ return ret; ++ } ++ ++ /* Init PHY routine */ ++ ret = sr9800_phy_powerup(dev); ++ if (ret < 0) ++ goto out; ++ ++ rx_ctl = sr_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl); ++ ret = sr_write_rx_ctl(dev, 0x0000); ++ if (ret < 0) ++ goto out; ++ ++ rx_ctl = sr_read_rx_ctl(dev); ++ netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl); ++ ++ /* Read PHYID register *AFTER* the PHY was reset properly */ ++ phyid = sr_get_phyid(dev); ++ netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid); ++ ++ /* medium mode setting */ ++ ret = sr9800_set_default_mode(dev); ++ if (ret < 0) ++ goto out; ++ ++ if (dev->udev->speed == USB_SPEED_HIGH) { ++ ret = sr_write_cmd(dev, SR_CMD_BULKIN_SIZE, ++ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].byte_cnt, ++ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].threshold, ++ 0, NULL); ++ if (ret < 0) { ++ netdev_err(dev->net, "Reset RX_CTL failed: %d\n", ret); ++ goto out; ++ } ++ dev->rx_urb_size = ++ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].size; ++ } else { ++ ret = sr_write_cmd(dev, SR_CMD_BULKIN_SIZE, ++ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].byte_cnt, ++ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].threshold, ++ 0, NULL); ++ if (ret < 0) { ++ netdev_err(dev->net, "Reset RX_CTL failed: %d\n", ret); ++ goto out; ++ } ++ dev->rx_urb_size = ++ SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].size; ++ } ++ netdev_dbg(dev->net, "%s : setting rx_urb_size with : %zu\n", __func__, ++ dev->rx_urb_size); ++ return 0; ++ ++out: ++ return ret; ++} ++ ++static const struct driver_info sr9800_driver_info = { ++ .description = "CoreChip SR9800 USB 2.0 Ethernet", ++ .bind = sr9800_bind, ++ .status = sr_status, ++ .link_reset = sr9800_link_reset, ++ .reset = sr9800_reset, ++ .flags = DRIVER_FLAG, ++ .rx_fixup = sr_rx_fixup, ++ .tx_fixup = sr_tx_fixup, ++}; ++ ++static const struct usb_device_id products[] = { ++ { ++ USB_DEVICE(0x0fe6, 0x9800), /* SR9800 Device */ ++ .driver_info = (unsigned long) &sr9800_driver_info, ++ }, ++ {}, /* END */ ++}; ++ ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver sr_driver = { ++ .name = DRIVER_NAME, ++ .id_table = products, ++ .probe = usbnet_probe, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disconnect = usbnet_disconnect, ++ .supports_autosuspend = 1, ++}; ++ ++module_usb_driver(sr_driver); ++ ++MODULE_AUTHOR("Liu Junliang <liujunliang_ljl@163.com"); ++MODULE_VERSION(DRIVER_VERSION); ++MODULE_DESCRIPTION("SR9800 USB 2.0 USB2NET Dev : http://www.corechip-sz.com"); ++MODULE_LICENSE("GPL"); +diff -Naur backports-4.2.6-1.org/drivers/net/usb/sr9800.h backports-4.2.6-1/drivers/net/usb/sr9800.h +--- backports-4.2.6-1.org/drivers/net/usb/sr9800.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/sr9800.h 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,202 @@ ++/* CoreChip-sz SR9800 one chip USB 2.0 Ethernet Devices ++ * ++ * Author : Liu Junliang liujunliang_ljl@163.com ++ * ++ * This file is licensed under the terms of the GNU General Public License ++ * version 2. This program is licensed "as is" without any warranty of any ++ * kind, whether express or implied. ++ */ ++ ++#ifndef _SR9800_H ++#define _SR9800_H ++ ++/* SR9800 spec. command table on Linux Platform */ ++ ++/* command : Software Station Management Control Reg */ ++#define SR_CMD_SET_SW_MII 0x06 ++/* command : PHY Read Reg */ ++#define SR_CMD_READ_MII_REG 0x07 ++/* command : PHY Write Reg */ ++#define SR_CMD_WRITE_MII_REG 0x08 ++/* command : Hardware Station Management Control Reg */ ++#define SR_CMD_SET_HW_MII 0x0a ++/* command : SROM Read Reg */ ++#define SR_CMD_READ_EEPROM 0x0b ++/* command : SROM Write Reg */ ++#define SR_CMD_WRITE_EEPROM 0x0c ++/* command : SROM Write Enable Reg */ ++#define SR_CMD_WRITE_ENABLE 0x0d ++/* command : SROM Write Disable Reg */ ++#define SR_CMD_WRITE_DISABLE 0x0e ++/* command : RX Control Read Reg */ ++#define SR_CMD_READ_RX_CTL 0x0f ++#define SR_RX_CTL_PRO (1 << 0) ++#define SR_RX_CTL_AMALL (1 << 1) ++#define SR_RX_CTL_SEP (1 << 2) ++#define SR_RX_CTL_AB (1 << 3) ++#define SR_RX_CTL_AM (1 << 4) ++#define SR_RX_CTL_AP (1 << 5) ++#define SR_RX_CTL_ARP (1 << 6) ++#define SR_RX_CTL_SO (1 << 7) ++#define SR_RX_CTL_RH1M (1 << 8) ++#define SR_RX_CTL_RH2M (1 << 9) ++#define SR_RX_CTL_RH3M (1 << 10) ++/* command : RX Control Write Reg */ ++#define SR_CMD_WRITE_RX_CTL 0x10 ++/* command : IPG0/IPG1/IPG2 Control Read Reg */ ++#define SR_CMD_READ_IPG012 0x11 ++/* command : IPG0/IPG1/IPG2 Control Write Reg */ ++#define SR_CMD_WRITE_IPG012 0x12 ++/* command : Node ID Read Reg */ ++#define SR_CMD_READ_NODE_ID 0x13 ++/* command : Node ID Write Reg */ ++#define SR_CMD_WRITE_NODE_ID 0x14 ++/* command : Multicast Filter Array Read Reg */ ++#define SR_CMD_READ_MULTI_FILTER 0x15 ++/* command : Multicast Filter Array Write Reg */ ++#define SR_CMD_WRITE_MULTI_FILTER 0x16 ++/* command : Eth/HomePNA PHY Address Reg */ ++#define SR_CMD_READ_PHY_ID 0x19 ++/* command : Medium Status Read Reg */ ++#define SR_CMD_READ_MEDIUM_STATUS 0x1a ++#define SR_MONITOR_LINK (1 << 1) ++#define SR_MONITOR_MAGIC (1 << 2) ++#define SR_MONITOR_HSFS (1 << 4) ++/* command : Medium Status Write Reg */ ++#define SR_CMD_WRITE_MEDIUM_MODE 0x1b ++#define SR_MEDIUM_GM (1 << 0) ++#define SR_MEDIUM_FD (1 << 1) ++#define SR_MEDIUM_AC (1 << 2) ++#define SR_MEDIUM_ENCK (1 << 3) ++#define SR_MEDIUM_RFC (1 << 4) ++#define SR_MEDIUM_TFC (1 << 5) ++#define SR_MEDIUM_JFE (1 << 6) ++#define SR_MEDIUM_PF (1 << 7) ++#define SR_MEDIUM_RE (1 << 8) ++#define SR_MEDIUM_PS (1 << 9) ++#define SR_MEDIUM_RSV (1 << 10) ++#define SR_MEDIUM_SBP (1 << 11) ++#define SR_MEDIUM_SM (1 << 12) ++/* command : Monitor Mode Status Read Reg */ ++#define SR_CMD_READ_MONITOR_MODE 0x1c ++/* command : Monitor Mode Status Write Reg */ ++#define SR_CMD_WRITE_MONITOR_MODE 0x1d ++/* command : GPIO Status Read Reg */ ++#define SR_CMD_READ_GPIOS 0x1e ++#define SR_GPIO_GPO0EN (1 << 0) /* GPIO0 Output enable */ ++#define SR_GPIO_GPO_0 (1 << 1) /* GPIO0 Output value */ ++#define SR_GPIO_GPO1EN (1 << 2) /* GPIO1 Output enable */ ++#define SR_GPIO_GPO_1 (1 << 3) /* GPIO1 Output value */ ++#define SR_GPIO_GPO2EN (1 << 4) /* GPIO2 Output enable */ ++#define SR_GPIO_GPO_2 (1 << 5) /* GPIO2 Output value */ ++#define SR_GPIO_RESERVED (1 << 6) /* Reserved */ ++#define SR_GPIO_RSE (1 << 7) /* Reload serial EEPROM */ ++/* command : GPIO Status Write Reg */ ++#define SR_CMD_WRITE_GPIOS 0x1f ++/* command : Eth PHY Power and Reset Control Reg */ ++#define SR_CMD_SW_RESET 0x20 ++#define SR_SWRESET_CLEAR 0x00 ++#define SR_SWRESET_RR (1 << 0) ++#define SR_SWRESET_RT (1 << 1) ++#define SR_SWRESET_PRTE (1 << 2) ++#define SR_SWRESET_PRL (1 << 3) ++#define SR_SWRESET_BZ (1 << 4) ++#define SR_SWRESET_IPRL (1 << 5) ++#define SR_SWRESET_IPPD (1 << 6) ++/* command : Software Interface Selection Status Read Reg */ ++#define SR_CMD_SW_PHY_STATUS 0x21 ++/* command : Software Interface Selection Status Write Reg */ ++#define SR_CMD_SW_PHY_SELECT 0x22 ++/* command : BULK in Buffer Size Reg */ ++#define SR_CMD_BULKIN_SIZE 0x2A ++/* command : LED_MUX Control Reg */ ++#define SR_CMD_LED_MUX 0x70 ++#define SR_LED_MUX_TX_ACTIVE (1 << 0) ++#define SR_LED_MUX_RX_ACTIVE (1 << 1) ++#define SR_LED_MUX_COLLISION (1 << 2) ++#define SR_LED_MUX_DUP_COL (1 << 3) ++#define SR_LED_MUX_DUP (1 << 4) ++#define SR_LED_MUX_SPEED (1 << 5) ++#define SR_LED_MUX_LINK_ACTIVE (1 << 6) ++#define SR_LED_MUX_LINK (1 << 7) ++ ++/* Register Access Flags */ ++#define SR_REQ_RD_REG (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE) ++#define SR_REQ_WR_REG (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) ++ ++/* Multicast Filter Array size & Max Number */ ++#define SR_MCAST_FILTER_SIZE 8 ++#define SR_MAX_MCAST 64 ++ ++/* IPG0/1/2 Default Value */ ++#define SR9800_IPG0_DEFAULT 0x15 ++#define SR9800_IPG1_DEFAULT 0x0c ++#define SR9800_IPG2_DEFAULT 0x12 ++ ++/* Medium Status Default Mode */ ++#define SR9800_MEDIUM_DEFAULT \ ++ (SR_MEDIUM_FD | SR_MEDIUM_RFC | \ ++ SR_MEDIUM_TFC | SR_MEDIUM_PS | \ ++ SR_MEDIUM_AC | SR_MEDIUM_RE) ++ ++/* RX Control Default Setting */ ++#define SR_DEFAULT_RX_CTL \ ++ (SR_RX_CTL_SO | SR_RX_CTL_AB | SR_RX_CTL_RH1M) ++ ++/* EEPROM Magic Number & EEPROM Size */ ++#define SR_EEPROM_MAGIC 0xdeadbeef ++#define SR9800_EEPROM_LEN 0xff ++ ++/* SR9800 Driver Version and Driver Name */ ++#define DRIVER_VERSION "11-Nov-2013" ++#define DRIVER_NAME "CoreChips" ++#define DRIVER_FLAG \ ++ (FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET) ++ ++/* SR9800 BULKIN Buffer Size */ ++#define SR9800_MAX_BULKIN_2K 0 ++#define SR9800_MAX_BULKIN_4K 1 ++#define SR9800_MAX_BULKIN_6K 2 ++#define SR9800_MAX_BULKIN_8K 3 ++#define SR9800_MAX_BULKIN_16K 4 ++#define SR9800_MAX_BULKIN_20K 5 ++#define SR9800_MAX_BULKIN_24K 6 ++#define SR9800_MAX_BULKIN_32K 7 ++ ++struct {unsigned short size, byte_cnt, threshold; } SR9800_BULKIN_SIZE[] = { ++ /* 2k */ ++ {2048, 0x8000, 0x8001}, ++ /* 4k */ ++ {4096, 0x8100, 0x8147}, ++ /* 6k */ ++ {6144, 0x8200, 0x81EB}, ++ /* 8k */ ++ {8192, 0x8300, 0x83D7}, ++ /* 16 */ ++ {16384, 0x8400, 0x851E}, ++ /* 20k */ ++ {20480, 0x8500, 0x8666}, ++ /* 24k */ ++ {24576, 0x8600, 0x87AE}, ++ /* 32k */ ++ {32768, 0x8700, 0x8A3D}, ++}; ++ ++/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */ ++struct sr_data { ++ u8 multi_filter[SR_MCAST_FILTER_SIZE]; ++ u8 mac_addr[ETH_ALEN]; ++ u8 phymode; ++ u8 ledmode; ++ u8 eeprom_len; ++}; ++ ++struct sr9800_int_data { ++ __le16 res1; ++ u8 link; ++ __le16 res2; ++ u8 status; ++ __le16 res3; ++} __packed; ++ ++#endif /* _SR9800_H */ +diff -Naur backports-4.2.6-1.org/drivers/net/usb/zaurus.c backports-4.2.6-1/drivers/net/usb/zaurus.c +--- backports-4.2.6-1.org/drivers/net/usb/zaurus.c 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/zaurus.c 2015-11-09 23:37:56.000000000 +0100 +@@ -0,0 +1,385 @@ ++/* ++ * Copyright (C) 2002 Pavel Machek pavel@ucw.cz ++ * Copyright (C) 2002-2005 by David Brownell ++ * ++ * This program is free software; you can redistribute it and/or modify ++ * it under the terms of the GNU General Public License as published by ++ * the Free Software Foundation; either version 2 of the License, or ++ * (at your option) any later version. ++ * ++ * 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. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, see http://www.gnu.org/licenses/. ++ */ ++ ++// #define DEBUG // error path messages, extra info ++// #define VERBOSE // more; success messages ++ ++#include <linux/module.h> ++#include <linux/netdevice.h> ++#include <linux/ethtool.h> ++#include <linux/workqueue.h> ++#include <linux/mii.h> ++#include <linux/crc32.h> ++#include <linux/usb.h> ++#include <linux/usb/cdc.h> ++#include <linux/usb/usbnet.h> ++ ++ ++/* ++ * All known Zaurii lie about their standards conformance. At least ++ * the earliest SA-1100 models lie by saying they support CDC Ethernet. ++ * Some later models (especially PXA-25x and PXA-27x based ones) lie ++ * and say they support CDC MDLM (for access to cell phone modems). ++ * ++ * There are non-Zaurus products that use these same protocols too. ++ * ++ * The annoying thing is that at the same time Sharp was developing ++ * that annoying standards-breaking software, the Linux community had ++ * a simple "CDC Subset" working reliably on the same SA-1100 hardware. ++ * That is, the same functionality but not violating standards. ++ * ++ * The CDC Ethernet nonconformance points are troublesome to hosts ++ * with a true CDC Ethernet implementation: ++ * - Framing appends a CRC, which the spec says drivers "must not" do; ++ * - Transfers data in altsetting zero, instead of altsetting 1; ++ * - All these peripherals use the same ethernet address. ++ * ++ * The CDC MDLM nonconformance is less immediately troublesome, since all ++ * MDLM implementations are quasi-proprietary anyway. ++ */ ++ ++static struct sk_buff * ++zaurus_tx_fixup(struct usbnet *dev, struct sk_buff *skb, gfp_t flags) ++{ ++ int padlen; ++ struct sk_buff *skb2; ++ ++ padlen = 2; ++ if (!skb_cloned(skb)) { ++ int tailroom = skb_tailroom(skb); ++ if ((padlen + 4) <= tailroom) ++ goto done; ++ } ++ skb2 = skb_copy_expand(skb, 0, 4 + padlen, flags); ++ dev_kfree_skb_any(skb); ++ skb = skb2; ++ if (skb) { ++ u32 fcs; ++done: ++ fcs = crc32_le(~0, skb->data, skb->len); ++ fcs = ~fcs; ++ ++ *skb_put (skb, 1) = fcs & 0xff; ++ *skb_put (skb, 1) = (fcs>> 8) & 0xff; ++ *skb_put (skb, 1) = (fcs>>16) & 0xff; ++ *skb_put (skb, 1) = (fcs>>24) & 0xff; ++ } ++ return skb; ++} ++ ++static int zaurus_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ /* Belcarra's funky framing has other options; mostly ++ * TRAILERS (!) with 4 bytes CRC, and maybe 2 pad bytes. ++ */ ++ dev->net->hard_header_len += 6; ++ dev->rx_urb_size = dev->net->hard_header_len + dev->net->mtu; ++ return usbnet_generic_cdc_bind(dev, intf); ++} ++ ++/* PDA style devices are always connected if present */ ++static int always_connected (struct usbnet *dev) ++{ ++ return 0; ++} ++ ++static const struct driver_info zaurus_sl5x00_info = { ++ .description = "Sharp Zaurus SL-5x00", ++ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, ++ .check_connect = always_connected, ++ .bind = zaurus_bind, ++ .unbind = usbnet_cdc_unbind, ++ .tx_fixup = zaurus_tx_fixup, ++}; ++#define ZAURUS_STRONGARM_INFO ((unsigned long)&zaurus_sl5x00_info) ++ ++static const struct driver_info zaurus_pxa_info = { ++ .description = "Sharp Zaurus, PXA-2xx based", ++ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, ++ .check_connect = always_connected, ++ .bind = zaurus_bind, ++ .unbind = usbnet_cdc_unbind, ++ .tx_fixup = zaurus_tx_fixup, ++}; ++#define ZAURUS_PXA_INFO ((unsigned long)&zaurus_pxa_info) ++ ++static const struct driver_info olympus_mxl_info = { ++ .description = "Olympus R1000", ++ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, ++ .check_connect = always_connected, ++ .bind = zaurus_bind, ++ .unbind = usbnet_cdc_unbind, ++ .tx_fixup = zaurus_tx_fixup, ++}; ++#define OLYMPUS_MXL_INFO ((unsigned long)&olympus_mxl_info) ++ ++ ++/* Some more recent products using Lineo/Belcarra code will wrongly claim ++ * CDC MDLM conformance. They aren't conformant: data endpoints live ++ * in the control interface, there's no data interface, and it's not used ++ * to talk to a cell phone radio. But at least we can detect these two ++ * pseudo-classes, rather than growing this product list with entries for ++ * each new nonconformant product (sigh). ++ */ ++static const u8 safe_guid[16] = { ++ 0x5d, 0x34, 0xcf, 0x66, 0x11, 0x18, 0x11, 0xd6, ++ 0xa2, 0x1a, 0x00, 0x01, 0x02, 0xca, 0x9a, 0x7f, ++}; ++static const u8 blan_guid[16] = { ++ 0x74, 0xf0, 0x3d, 0xbd, 0x1e, 0xc1, 0x44, 0x70, ++ 0xa3, 0x67, 0x71, 0x34, 0xc9, 0xf5, 0x54, 0x37, ++}; ++ ++static int blan_mdlm_bind(struct usbnet *dev, struct usb_interface *intf) ++{ ++ u8 *buf = intf->cur_altsetting->extra; ++ int len = intf->cur_altsetting->extralen; ++ struct usb_cdc_mdlm_desc *desc = NULL; ++ struct usb_cdc_mdlm_detail_desc *detail = NULL; ++ ++ while (len > 3) { ++ if (buf [1] != USB_DT_CS_INTERFACE) ++ goto next_desc; ++ ++ /* use bDescriptorSubType, and just verify that we get a ++ * "BLAN" (or "SAFE") descriptor. ++ */ ++ switch (buf [2]) { ++ case USB_CDC_MDLM_TYPE: ++ if (desc) { ++ dev_dbg(&intf->dev, "extra MDLM\n"); ++ goto bad_desc; ++ } ++ desc = (void *) buf; ++ if (desc->bLength != sizeof *desc) { ++ dev_dbg(&intf->dev, "MDLM len %u\n", ++ desc->bLength); ++ goto bad_desc; ++ } ++ /* expect bcdVersion 1.0, ignore */ ++ if (memcmp(&desc->bGUID, blan_guid, 16) && ++ memcmp(&desc->bGUID, safe_guid, 16)) { ++ /* hey, this one might _really_ be MDLM! */ ++ dev_dbg(&intf->dev, "MDLM guid\n"); ++ goto bad_desc; ++ } ++ break; ++ case USB_CDC_MDLM_DETAIL_TYPE: ++ if (detail) { ++ dev_dbg(&intf->dev, "extra MDLM detail\n"); ++ goto bad_desc; ++ } ++ detail = (void *) buf; ++ switch (detail->bGuidDescriptorType) { ++ case 0: /* "SAFE" */ ++ if (detail->bLength != (sizeof *detail + 2)) ++ goto bad_detail; ++ break; ++ case 1: /* "BLAN" */ ++ if (detail->bLength != (sizeof *detail + 3)) ++ goto bad_detail; ++ break; ++ default: ++ goto bad_detail; ++ } ++ ++ /* assuming we either noticed BLAN already, or will ++ * find it soon, there are some data bytes here: ++ * - bmNetworkCapabilities (unused) ++ * - bmDataCapabilities (bits, see below) ++ * - bPad (ignored, for PADAFTER -- BLAN-only) ++ * bits are: ++ * - 0x01 -- Zaurus framing (add CRC) ++ * - 0x02 -- PADBEFORE (CRC includes some padding) ++ * - 0x04 -- PADAFTER (some padding after CRC) ++ * - 0x08 -- "fermat" packet mangling (for hw bugs) ++ * the PADBEFORE appears not to matter; we interop ++ * with devices that use it and those that don't. ++ */ ++ if ((detail->bDetailData[1] & ~0x02) != 0x01) { ++ /* bmDataCapabilities == 0 would be fine too, ++ * but framing is minidriver-coupled for now. ++ */ ++bad_detail: ++ dev_dbg(&intf->dev, ++ "bad MDLM detail, %d %d %d\n", ++ detail->bLength, ++ detail->bDetailData[0], ++ detail->bDetailData[2]); ++ goto bad_desc; ++ } ++ ++ /* same extra framing as for non-BLAN mode */ ++ dev->net->hard_header_len += 6; ++ dev->rx_urb_size = dev->net->hard_header_len ++ + dev->net->mtu; ++ break; ++ } ++next_desc: ++ len -= buf [0]; /* bLength */ ++ buf += buf [0]; ++ } ++ ++ if (!desc || !detail) { ++ dev_dbg(&intf->dev, "missing cdc mdlm %s%sdescriptor\n", ++ desc ? "" : "func ", ++ detail ? "" : "detail "); ++ goto bad_desc; ++ } ++ ++ /* There's probably a CDC Ethernet descriptor there, but we can't ++ * rely on the Ethernet address it provides since not all vendors ++ * bother to make it unique. Likewise there's no point in tracking ++ * of the CDC event notifications. ++ */ ++ return usbnet_get_endpoints(dev, intf); ++ ++bad_desc: ++ dev_info(&dev->udev->dev, "unsupported MDLM descriptors\n"); ++ return -ENODEV; ++} ++ ++static const struct driver_info bogus_mdlm_info = { ++ .description = "pseudo-MDLM (BLAN) device", ++ .flags = FLAG_POINTTOPOINT | FLAG_FRAMING_Z, ++ .check_connect = always_connected, ++ .tx_fixup = zaurus_tx_fixup, ++ .bind = blan_mdlm_bind, ++}; ++ ++static const struct usb_device_id products [] = { ++#define ZAURUS_MASTER_INTERFACE \ ++ .bInterfaceClass = USB_CLASS_COMM, \ ++ .bInterfaceSubClass = USB_CDC_SUBCLASS_ETHERNET, \ ++ .bInterfaceProtocol = USB_CDC_PROTO_NONE ++ ++/* SA-1100 based Sharp Zaurus ("collie"), or compatible. */ ++{ ++ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO ++ | USB_DEVICE_ID_MATCH_DEVICE, ++ .idVendor = 0x04DD, ++ .idProduct = 0x8004, ++ ZAURUS_MASTER_INTERFACE, ++ .driver_info = ZAURUS_STRONGARM_INFO, ++}, ++ ++/* PXA-2xx based models are also lying-about-cdc. If you add any ++ * more devices that claim to be CDC Ethernet, make sure they get ++ * added to the blacklist in cdc_ether too. ++ * ++ * NOTE: OpenZaurus versions with 2.6 kernels won't use these entries, ++ * unlike the older ones with 2.4 "embedix" kernels. ++ */ ++{ ++ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO ++ | USB_DEVICE_ID_MATCH_DEVICE, ++ .idVendor = 0x04DD, ++ .idProduct = 0x8005, /* A-300 */ ++ ZAURUS_MASTER_INTERFACE, ++ .driver_info = ZAURUS_PXA_INFO, ++}, { ++ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO ++ | USB_DEVICE_ID_MATCH_DEVICE, ++ .idVendor = 0x04DD, ++ .idProduct = 0x8006, /* B-500/SL-5600 */ ++ ZAURUS_MASTER_INTERFACE, ++ .driver_info = ZAURUS_PXA_INFO, ++}, { ++ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO ++ | USB_DEVICE_ID_MATCH_DEVICE, ++ .idVendor = 0x04DD, ++ .idProduct = 0x8007, /* C-700 */ ++ ZAURUS_MASTER_INTERFACE, ++ .driver_info = ZAURUS_PXA_INFO, ++}, { ++ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO ++ | USB_DEVICE_ID_MATCH_DEVICE, ++ .idVendor = 0x04DD, ++ .idProduct = 0x9031, /* C-750 C-760 */ ++ ZAURUS_MASTER_INTERFACE, ++ .driver_info = ZAURUS_PXA_INFO, ++}, { ++ /* C-750/C-760/C-860/SL-C3000 PDA in MDLM mode */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x04DD, 0x9031, USB_CLASS_COMM, ++ USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), ++ .driver_info = (unsigned long) &bogus_mdlm_info, ++}, { ++ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO ++ | USB_DEVICE_ID_MATCH_DEVICE, ++ .idVendor = 0x04DD, ++ .idProduct = 0x9032, /* SL-6000 */ ++ ZAURUS_MASTER_INTERFACE, ++ .driver_info = ZAURUS_PXA_INFO, ++}, { ++ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO ++ | USB_DEVICE_ID_MATCH_DEVICE, ++ .idVendor = 0x04DD, ++ /* reported with some C860 units */ ++ .idProduct = 0x9050, /* C-860 */ ++ ZAURUS_MASTER_INTERFACE, ++ .driver_info = ZAURUS_PXA_INFO, ++}, ++{ ++ /* Motorola Rokr E6 */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x6027, USB_CLASS_COMM, ++ USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), ++ .driver_info = (unsigned long) &bogus_mdlm_info, ++}, { ++ /* Motorola MOTOMAGX phones */ ++ USB_DEVICE_AND_INTERFACE_INFO(0x22b8, 0x6425, USB_CLASS_COMM, ++ USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), ++ .driver_info = (unsigned long) &bogus_mdlm_info, ++}, ++ ++/* Olympus has some models with a Zaurus-compatible option. ++ * R-1000 uses a FreeScale i.MXL cpu (ARMv4T) ++ */ ++{ ++ .match_flags = USB_DEVICE_ID_MATCH_INT_INFO ++ | USB_DEVICE_ID_MATCH_DEVICE, ++ .idVendor = 0x07B4, ++ .idProduct = 0x0F02, /* R-1000 */ ++ ZAURUS_MASTER_INTERFACE, ++ .driver_info = OLYMPUS_MXL_INFO, ++}, ++ ++/* Logitech Harmony 900 - uses the pseudo-MDLM (BLAN) driver */ ++{ ++ USB_DEVICE_AND_INTERFACE_INFO(0x046d, 0xc11f, USB_CLASS_COMM, ++ USB_CDC_SUBCLASS_MDLM, USB_CDC_PROTO_NONE), ++ .driver_info = (unsigned long) &bogus_mdlm_info, ++}, ++ { }, // END ++}; ++MODULE_DEVICE_TABLE(usb, products); ++ ++static struct usb_driver zaurus_driver = { ++ .name = "zaurus", ++ .id_table = products, ++ .probe = usbnet_probe, ++ .disconnect = usbnet_disconnect, ++ .suspend = usbnet_suspend, ++ .resume = usbnet_resume, ++ .disable_hub_initiated_lpm = 1, ++}; ++ ++module_usb_driver(zaurus_driver); ++ ++MODULE_AUTHOR("Pavel Machek, David Brownell"); ++MODULE_DESCRIPTION("Sharp Zaurus PDA, and compatible products"); ++MODULE_LICENSE("GPL"); diff --git a/src/patches/backports-4.2.6-1-grsecurity.patch b/src/patches/backports-4.2.6-1-grsecurity.patch new file mode 100644 index 0000000..1a44409 --- /dev/null +++ b/src/patches/backports-4.2.6-1-grsecurity.patch @@ -0,0 +1,3995 @@ +diff -Naur backports-4.2.6-1.org/drivers/bluetooth/btwilink.c backports-4.2.6-1/drivers/bluetooth/btwilink.c +--- backports-4.2.6-1.org/drivers/bluetooth/btwilink.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/drivers/bluetooth/btwilink.c 2016-01-27 12:26:16.319959957 +0100 +@@ -288,7 +288,7 @@ + + static int bt_ti_probe(struct platform_device *pdev) + { +- static struct ti_st *hst; ++ struct ti_st *hst; + struct hci_dev *hdev; + int err; + +diff -Naur backports-4.2.6-1.org/drivers/media/dvb-core/dvbdev.c backports-4.2.6-1/drivers/media/dvb-core/dvbdev.c +--- backports-4.2.6-1.org/drivers/media/dvb-core/dvbdev.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/dvb-core/dvbdev.c 2016-01-27 12:26:21.266626324 +0100 +@@ -272,7 +272,7 @@ + const struct dvb_device *template, void *priv, int type) + { + struct dvb_device *dvbdev; +- struct file_operations *dvbdevfops; ++ file_operations_no_const *dvbdevfops; + struct device *clsdev; + int minor; + int id; +diff -Naur backports-4.2.6-1.org/drivers/media/dvb-frontends/af9033.h backports-4.2.6-1/drivers/media/dvb-frontends/af9033.h +--- backports-4.2.6-1.org/drivers/media/dvb-frontends/af9033.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/dvb-frontends/af9033.h 2016-01-27 12:26:21.266626324 +0100 +@@ -96,6 +96,6 @@ + int (*pid_filter_ctrl)(struct dvb_frontend *fe, int onoff); + int (*pid_filter)(struct dvb_frontend *fe, int index, u16 pid, + int onoff); +-}; ++} __no_const; + + #endif /* AF9033_H */ +diff -Naur backports-4.2.6-1.org/drivers/media/dvb-frontends/dib3000.h backports-4.2.6-1/drivers/media/dvb-frontends/dib3000.h +--- backports-4.2.6-1.org/drivers/media/dvb-frontends/dib3000.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/dvb-frontends/dib3000.h 2016-01-27 12:26:21.266626324 +0100 +@@ -39,7 +39,7 @@ + int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff); + int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff); + int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl); +-}; ++} __no_const; + + #if IS_REACHABLE(CPTCFG_DVB_DIB3000MB) + extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config, +diff -Naur backports-4.2.6-1.org/drivers/media/dvb-frontends/dib7000p.h backports-4.2.6-1/drivers/media/dvb-frontends/dib7000p.h +--- backports-4.2.6-1.org/drivers/media/dvb-frontends/dib7000p.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/dvb-frontends/dib7000p.h 2016-01-27 12:26:21.266626324 +0100 +@@ -64,7 +64,7 @@ + int (*get_adc_power)(struct dvb_frontend *fe); + int (*slave_reset)(struct dvb_frontend *fe); + struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib7000p_config *cfg); +-}; ++} __no_const; + + #if IS_REACHABLE(CPTCFG_DVB_DIB7000P) + void *dib7000p_attach(struct dib7000p_ops *ops); +diff -Naur backports-4.2.6-1.org/drivers/media/dvb-frontends/dib8000.h backports-4.2.6-1/drivers/media/dvb-frontends/dib8000.h +--- backports-4.2.6-1.org/drivers/media/dvb-frontends/dib8000.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/dvb-frontends/dib8000.h 2016-01-27 12:26:21.266626324 +0100 +@@ -61,7 +61,7 @@ + int (*pid_filter_ctrl)(struct dvb_frontend *fe, u8 onoff); + int (*pid_filter)(struct dvb_frontend *fe, u8 id, u16 pid, u8 onoff); + struct dvb_frontend *(*init)(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg); +-}; ++} __no_const; + + #if IS_REACHABLE(CPTCFG_DVB_DIB8000) + void *dib8000_attach(struct dib8000_ops *ops); +diff -Naur backports-4.2.6-1.org/drivers/media/pci/cx88/cx88-video.c backports-4.2.6-1/drivers/media/pci/cx88/cx88-video.c +--- backports-4.2.6-1.org/drivers/media/pci/cx88/cx88-video.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/pci/cx88/cx88-video.c 2016-01-27 12:26:21.266626324 +0100 +@@ -50,9 +50,9 @@ + + /* ------------------------------------------------------------------ */ + +-static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; +-static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; +-static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; ++static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; ++static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; ++static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET }; + + module_param_array(video_nr, int, NULL, 0444); + module_param_array(vbi_nr, int, NULL, 0444); +diff -Naur backports-4.2.6-1.org/drivers/media/pci/ivtv/ivtv-driver.c backports-4.2.6-1/drivers/media/pci/ivtv/ivtv-driver.c +--- backports-4.2.6-1.org/drivers/media/pci/ivtv/ivtv-driver.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/pci/ivtv/ivtv-driver.c 2016-01-27 12:26:21.266626324 +0100 +@@ -83,7 +83,7 @@ + MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl); + + /* ivtv instance counter */ +-static atomic_t ivtv_instance = ATOMIC_INIT(0); ++static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0); + + /* Parameter declarations */ + static int cardtype[IVTV_MAX_CARDS]; +diff -Naur backports-4.2.6-1.org/drivers/media/pci/solo6x10/solo6x10-core.c backports-4.2.6-1/drivers/media/pci/solo6x10/solo6x10-core.c +--- backports-4.2.6-1.org/drivers/media/pci/solo6x10/solo6x10-core.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/pci/solo6x10/solo6x10-core.c 2016-01-27 12:26:21.266626324 +0100 +@@ -424,7 +424,7 @@ + + static int solo_sysfs_init(struct solo_dev *solo_dev) + { +- struct bin_attribute *sdram_attr = &solo_dev->sdram_attr; ++ bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr; + struct device *dev = &solo_dev->dev; + const char *driver; + int i; +diff -Naur backports-4.2.6-1.org/drivers/media/pci/solo6x10/solo6x10-g723.c backports-4.2.6-1/drivers/media/pci/solo6x10/solo6x10-g723.c +--- backports-4.2.6-1.org/drivers/media/pci/solo6x10/solo6x10-g723.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/pci/solo6x10/solo6x10-g723.c 2016-01-27 12:26:21.266626324 +0100 +@@ -351,7 +351,7 @@ + + int solo_g723_init(struct solo_dev *solo_dev) + { +- static struct snd_device_ops ops = { NULL }; ++ static struct snd_device_ops ops = { }; + struct snd_card *card; + struct snd_kcontrol_new kctl; + char name[32]; +diff -Naur backports-4.2.6-1.org/drivers/media/pci/solo6x10/solo6x10.h backports-4.2.6-1/drivers/media/pci/solo6x10/solo6x10.h +--- backports-4.2.6-1.org/drivers/media/pci/solo6x10/solo6x10.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/pci/solo6x10/solo6x10.h 2016-01-27 12:26:21.266626324 +0100 +@@ -218,7 +218,7 @@ + + /* P2M DMA Engine */ + struct solo_p2m_dev p2m_dev[SOLO_NR_P2M]; +- atomic_t p2m_count; ++ atomic_unchecked_t p2m_count; + int p2m_jiffies; + unsigned int p2m_timeouts; + +diff -Naur backports-4.2.6-1.org/drivers/media/pci/solo6x10/solo6x10-p2m.c backports-4.2.6-1/drivers/media/pci/solo6x10/solo6x10-p2m.c +--- backports-4.2.6-1.org/drivers/media/pci/solo6x10/solo6x10-p2m.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/pci/solo6x10/solo6x10-p2m.c 2016-01-27 12:26:21.266626324 +0100 +@@ -73,7 +73,7 @@ + + /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */ + if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) { +- p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M; ++ p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M; + if (p2m_id < 0) + p2m_id = -p2m_id; + } +diff -Naur backports-4.2.6-1.org/drivers/media/pci/tw68/tw68-core.c backports-4.2.6-1/drivers/media/pci/tw68/tw68-core.c +--- backports-4.2.6-1.org/drivers/media/pci/tw68/tw68-core.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/pci/tw68/tw68-core.c 2016-01-27 12:26:21.266626324 +0100 +@@ -60,7 +60,7 @@ + module_param_array(card, int, NULL, 0444); + MODULE_PARM_DESC(card, "card type"); + +-static atomic_t tw68_instance = ATOMIC_INIT(0); ++static atomic_unchecked_t tw68_instance = ATOMIC_INIT(0); + + /* ------------------------------------------------------------------ */ + +diff -Naur backports-4.2.6-1.org/drivers/media/platform/omap/omap_vout.c backports-4.2.6-1/drivers/media/platform/omap/omap_vout.c +--- backports-4.2.6-1.org/drivers/media/platform/omap/omap_vout.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/platform/omap/omap_vout.c 2016-01-27 12:26:21.266626324 +0100 +@@ -63,7 +63,6 @@ + OMAP_VIDEO2, + }; + +-static struct videobuf_queue_ops video_vbq_ops; + /* Variables configurable through module params*/ + static u32 video1_numbuffers = 3; + static u32 video2_numbuffers = 3; +@@ -1008,6 +1007,12 @@ + { + struct videobuf_queue *q; + struct omap_vout_device *vout = NULL; ++ static struct videobuf_queue_ops video_vbq_ops = { ++ .buf_setup = omap_vout_buffer_setup, ++ .buf_prepare = omap_vout_buffer_prepare, ++ .buf_release = omap_vout_buffer_release, ++ .buf_queue = omap_vout_buffer_queue, ++ }; + + vout = video_drvdata(file); + v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__); +@@ -1025,10 +1030,6 @@ + vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT; + + q = &vout->vbq; +- video_vbq_ops.buf_setup = omap_vout_buffer_setup; +- video_vbq_ops.buf_prepare = omap_vout_buffer_prepare; +- video_vbq_ops.buf_release = omap_vout_buffer_release; +- video_vbq_ops.buf_queue = omap_vout_buffer_queue; + spin_lock_init(&vout->vbq_lock); + + videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev, +diff -Naur backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer_grp_layer.c backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer_grp_layer.c +--- backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer_grp_layer.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer_grp_layer.c 2016-01-27 12:26:21.266626324 +0100 +@@ -235,7 +235,7 @@ + { + struct mxr_layer *layer; + int ret; +- struct mxr_layer_ops ops = { ++ static struct mxr_layer_ops ops = { + .release = mxr_graph_layer_release, + .buffer_set = mxr_graph_buffer_set, + .stream_set = mxr_graph_stream_set, +diff -Naur backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer.h backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer.h +--- backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer.h 2016-01-27 12:26:21.266626324 +0100 +@@ -156,7 +156,7 @@ + /** layer index (unique identifier) */ + int idx; + /** callbacks for layer methods */ +- struct mxr_layer_ops ops; ++ struct mxr_layer_ops *ops; + /** format array */ + const struct mxr_format **fmt_array; + /** size of format array */ +diff -Naur backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer_reg.c backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer_reg.c +--- backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer_reg.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer_reg.c 2016-01-27 12:26:21.266626324 +0100 +@@ -276,7 +276,7 @@ + layer->update_buf = next; + } + +- layer->ops.buffer_set(layer, layer->update_buf); ++ layer->ops->buffer_set(layer, layer->update_buf); + + if (done && done != layer->shadow_buf) + vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE); +diff -Naur backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer_video.c backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer_video.c +--- backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer_video.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer_video.c 2016-01-27 12:26:21.266626324 +0100 +@@ -210,7 +210,7 @@ + layer->geo.src.height = layer->geo.src.full_height; + + mxr_geometry_dump(mdev, &layer->geo); +- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0); ++ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0); + mxr_geometry_dump(mdev, &layer->geo); + } + +@@ -228,7 +228,7 @@ + layer->geo.dst.full_width = mbus_fmt.width; + layer->geo.dst.full_height = mbus_fmt.height; + layer->geo.dst.field = mbus_fmt.field; +- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0); ++ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0); + + mxr_geometry_dump(mdev, &layer->geo); + } +@@ -334,7 +334,7 @@ + /* set source size to highest accepted value */ + geo->src.full_width = max(geo->dst.full_width, pix->width); + geo->src.full_height = max(geo->dst.full_height, pix->height); +- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0); ++ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0); + mxr_geometry_dump(mdev, &layer->geo); + /* set cropping to total visible screen */ + geo->src.width = pix->width; +@@ -342,12 +342,12 @@ + geo->src.x_offset = 0; + geo->src.y_offset = 0; + /* assure consistency of geometry */ +- layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET); ++ layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET); + mxr_geometry_dump(mdev, &layer->geo); + /* set full size to lowest possible value */ + geo->src.full_width = 0; + geo->src.full_height = 0; +- layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0); ++ layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0); + mxr_geometry_dump(mdev, &layer->geo); + + /* returning results */ +@@ -474,7 +474,7 @@ + target->width = s->r.width; + target->height = s->r.height; + +- layer->ops.fix_geometry(layer, stage, s->flags); ++ layer->ops->fix_geometry(layer, stage, s->flags); + + /* retrieve update selection rectangle */ + res.left = target->x_offset; +@@ -938,13 +938,13 @@ + mxr_output_get(mdev); + + mxr_layer_update_output(layer); +- layer->ops.format_set(layer); ++ layer->ops->format_set(layer); + /* enabling layer in hardware */ + spin_lock_irqsave(&layer->enq_slock, flags); + layer->state = MXR_LAYER_STREAMING; + spin_unlock_irqrestore(&layer->enq_slock, flags); + +- layer->ops.stream_set(layer, MXR_ENABLE); ++ layer->ops->stream_set(layer, MXR_ENABLE); + mxr_streamer_get(mdev); + + return 0; +@@ -1014,7 +1014,7 @@ + spin_unlock_irqrestore(&layer->enq_slock, flags); + + /* disabling layer in hardware */ +- layer->ops.stream_set(layer, MXR_DISABLE); ++ layer->ops->stream_set(layer, MXR_DISABLE); + /* remove one streamer */ + mxr_streamer_put(mdev); + /* allow changes in output configuration */ +@@ -1052,8 +1052,8 @@ + + void mxr_layer_release(struct mxr_layer *layer) + { +- if (layer->ops.release) +- layer->ops.release(layer); ++ if (layer->ops->release) ++ layer->ops->release(layer); + } + + void mxr_base_layer_release(struct mxr_layer *layer) +@@ -1079,7 +1079,7 @@ + + layer->mdev = mdev; + layer->idx = idx; +- layer->ops = *ops; ++ layer->ops = ops; + + spin_lock_init(&layer->enq_slock); + INIT_LIST_HEAD(&layer->enq_list); +diff -Naur backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer_vp_layer.c backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer_vp_layer.c +--- backports-4.2.6-1.org/drivers/media/platform/s5p-tv/mixer_vp_layer.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/platform/s5p-tv/mixer_vp_layer.c 2016-01-27 12:26:21.266626324 +0100 +@@ -206,7 +206,7 @@ + { + struct mxr_layer *layer; + int ret; +- struct mxr_layer_ops ops = { ++ static struct mxr_layer_ops ops = { + .release = mxr_vp_layer_release, + .buffer_set = mxr_vp_buffer_set, + .stream_set = mxr_vp_stream_set, +diff -Naur backports-4.2.6-1.org/drivers/media/platform/vivid/vivid-osd.c backports-4.2.6-1/drivers/media/platform/vivid/vivid-osd.c +--- backports-4.2.6-1.org/drivers/media/platform/vivid/vivid-osd.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/platform/vivid/vivid-osd.c 2016-01-27 12:26:21.269959657 +0100 +@@ -85,6 +85,7 @@ + case FBIOGET_VBLANK: { + struct fb_vblank vblank; + ++ memset(&vblank, 0, sizeof(vblank)); + vblank.flags = FB_VBLANK_HAVE_COUNT | FB_VBLANK_HAVE_VCOUNT | + FB_VBLANK_HAVE_VSYNC; + vblank.count = 0; +diff -Naur backports-4.2.6-1.org/drivers/media/radio/radio-cadet.c backports-4.2.6-1/drivers/media/radio/radio-cadet.c +--- backports-4.2.6-1.org/drivers/media/radio/radio-cadet.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/radio/radio-cadet.c 2016-01-27 12:26:21.269959657 +0100 +@@ -333,6 +333,8 @@ + unsigned char readbuf[RDS_BUFFER]; + int i = 0; + ++ if (count > RDS_BUFFER) ++ return -EFAULT; + mutex_lock(&dev->lock); + if (dev->rdsstat == 0) + cadet_start_rds(dev); +@@ -349,8 +351,9 @@ + readbuf[i++] = dev->rdsbuf[dev->rdsout++]; + mutex_unlock(&dev->lock); + +- if (i && copy_to_user(data, readbuf, i)) +- return -EFAULT; ++ if (i > sizeof(readbuf) || (i && copy_to_user(data, readbuf, i))) ++ i = -EFAULT; ++ + return i; + } + +diff -Naur backports-4.2.6-1.org/drivers/media/radio/radio-maxiradio.c backports-4.2.6-1/drivers/media/radio/radio-maxiradio.c +--- backports-4.2.6-1.org/drivers/media/radio/radio-maxiradio.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/radio/radio-maxiradio.c 2016-01-27 12:26:21.269959657 +0100 +@@ -61,7 +61,7 @@ + /* TEA5757 pin mappings */ + static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16; + +-static atomic_t maxiradio_instance = ATOMIC_INIT(0); ++static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0); + + #define PCI_VENDOR_ID_GUILLEMOT 0x5046 + #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001 +diff -Naur backports-4.2.6-1.org/drivers/media/radio/radio-shark2.c backports-4.2.6-1/drivers/media/radio/radio-shark2.c +--- backports-4.2.6-1.org/drivers/media/radio/radio-shark2.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/radio/radio-shark2.c 2016-01-27 12:26:21.269959657 +0100 +@@ -74,7 +74,7 @@ + u8 *transfer_buffer; + }; + +-static atomic_t shark_instance = ATOMIC_INIT(0); ++static atomic_unchecked_t shark_instance = ATOMIC_INIT(0); + + static int shark_write_reg(struct radio_tea5777 *tea, u64 reg) + { +diff -Naur backports-4.2.6-1.org/drivers/media/radio/radio-shark.c backports-4.2.6-1/drivers/media/radio/radio-shark.c +--- backports-4.2.6-1.org/drivers/media/radio/radio-shark.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/radio/radio-shark.c 2016-01-27 12:26:21.269959657 +0100 +@@ -79,7 +79,7 @@ + u32 last_val; + }; + +-static atomic_t shark_instance = ATOMIC_INIT(0); ++static atomic_unchecked_t shark_instance = ATOMIC_INIT(0); + + static void shark_write_val(struct snd_tea575x *tea, u32 val) + { +diff -Naur backports-4.2.6-1.org/drivers/media/radio/radio-si476x.c backports-4.2.6-1/drivers/media/radio/radio-si476x.c +--- backports-4.2.6-1.org/drivers/media/radio/radio-si476x.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/radio/radio-si476x.c 2016-01-27 12:26:21.269959657 +0100 +@@ -1445,7 +1445,7 @@ + struct si476x_radio *radio; + struct v4l2_ctrl *ctrl; + +- static atomic_t instance = ATOMIC_INIT(0); ++ static atomic_unchecked_t instance = ATOMIC_INIT(0); + + radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL); + if (!radio) +diff -Naur backports-4.2.6-1.org/drivers/media/radio/wl128x/fmdrv_common.c backports-4.2.6-1/drivers/media/radio/wl128x/fmdrv_common.c +--- backports-4.2.6-1.org/drivers/media/radio/wl128x/fmdrv_common.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/radio/wl128x/fmdrv_common.c 2016-01-27 12:26:21.269959657 +0100 +@@ -71,7 +71,7 @@ + MODULE_PARM_DESC(rds_buf, "RDS buffer entries"); + + /* Radio Nr */ +-static u32 radio_nr = -1; ++static int radio_nr = -1; + module_param(radio_nr, int, 0444); + MODULE_PARM_DESC(radio_nr, "Radio Nr"); + +diff -Naur backports-4.2.6-1.org/drivers/media/usb/dvb-usb/cinergyT2-core.c backports-4.2.6-1/drivers/media/usb/dvb-usb/cinergyT2-core.c +--- backports-4.2.6-1.org/drivers/media/usb/dvb-usb/cinergyT2-core.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/usb/dvb-usb/cinergyT2-core.c 2016-01-27 12:26:21.269959657 +0100 +@@ -50,29 +50,73 @@ + + static int cinergyt2_streaming_ctrl(struct dvb_usb_adapter *adap, int enable) + { +- char buf[] = { CINERGYT2_EP1_CONTROL_STREAM_TRANSFER, enable ? 1 : 0 }; +- char result[64]; +- return dvb_usb_generic_rw(adap->dev, buf, sizeof(buf), result, +- sizeof(result), 0); ++ char *buf; ++ char *result; ++ int retval; ++ ++ buf = kmalloc(2, GFP_KERNEL); ++ if (buf == NULL) ++ return -ENOMEM; ++ result = kmalloc(64, GFP_KERNEL); ++ if (result == NULL) { ++ kfree(buf); ++ return -ENOMEM; ++ } ++ ++ buf[0] = CINERGYT2_EP1_CONTROL_STREAM_TRANSFER; ++ buf[1] = enable ? 1 : 0; ++ ++ retval = dvb_usb_generic_rw(adap->dev, buf, 2, result, 64, 0); ++ ++ kfree(buf); ++ kfree(result); ++ return retval; + } + + static int cinergyt2_power_ctrl(struct dvb_usb_device *d, int enable) + { +- char buf[] = { CINERGYT2_EP1_SLEEP_MODE, enable ? 0 : 1 }; +- char state[3]; +- return dvb_usb_generic_rw(d, buf, sizeof(buf), state, sizeof(state), 0); ++ char *buf; ++ char *state; ++ int retval; ++ ++ buf = kmalloc(2, GFP_KERNEL); ++ if (buf == NULL) ++ return -ENOMEM; ++ state = kmalloc(3, GFP_KERNEL); ++ if (state == NULL) { ++ kfree(buf); ++ return -ENOMEM; ++ } ++ ++ buf[0] = CINERGYT2_EP1_SLEEP_MODE; ++ buf[1] = enable ? 1 : 0; ++ ++ retval = dvb_usb_generic_rw(d, buf, 2, state, 3, 0); ++ ++ kfree(buf); ++ kfree(state); ++ return retval; + } + + static int cinergyt2_frontend_attach(struct dvb_usb_adapter *adap) + { +- char query[] = { CINERGYT2_EP1_GET_FIRMWARE_VERSION }; +- char state[3]; ++ char *query; ++ char *state; + int ret; ++ query = kmalloc(1, GFP_KERNEL); ++ if (query == NULL) ++ return -ENOMEM; ++ state = kmalloc(3, GFP_KERNEL); ++ if (state == NULL) { ++ kfree(query); ++ return -ENOMEM; ++ } ++ ++ query[0] = CINERGYT2_EP1_GET_FIRMWARE_VERSION; + + adap->fe_adap[0].fe = cinergyt2_fe_attach(adap->dev); + +- ret = dvb_usb_generic_rw(adap->dev, query, sizeof(query), state, +- sizeof(state), 0); ++ ret = dvb_usb_generic_rw(adap->dev, query, 1, state, 3, 0); + if (ret < 0) { + deb_rc("cinergyt2_power_ctrl() Failed to retrieve sleep " + "state info\n"); +@@ -80,7 +124,8 @@ + + /* Copy this pointer as we are gonna need it in the release phase */ + cinergyt2_usb_device = adap->dev; +- ++ kfree(query); ++ kfree(state); + return 0; + } + +@@ -141,12 +186,23 @@ + static int cinergyt2_rc_query(struct dvb_usb_device *d, u32 *event, int *state) + { + struct cinergyt2_state *st = d->priv; +- u8 key[5] = {0, 0, 0, 0, 0}, cmd = CINERGYT2_EP1_GET_RC_EVENTS; ++ u8 *key, *cmd; + int i; + ++ cmd = kmalloc(1, GFP_KERNEL); ++ if (cmd == NULL) ++ return -EINVAL; ++ key = kzalloc(5, GFP_KERNEL); ++ if (key == NULL) { ++ kfree(cmd); ++ return -EINVAL; ++ } ++ ++ cmd[0] = CINERGYT2_EP1_GET_RC_EVENTS; ++ + *state = REMOTE_NO_KEY_PRESSED; + +- dvb_usb_generic_rw(d, &cmd, 1, key, sizeof(key), 0); ++ dvb_usb_generic_rw(d, cmd, 1, key, 5, 0); + if (key[4] == 0xff) { + /* key repeat */ + st->rc_counter++; +@@ -157,12 +213,12 @@ + *event = d->last_event; + deb_rc("repeat key, event %x\n", + *event); +- return 0; ++ goto out; + } + } + deb_rc("repeated key (non repeatable)\n"); + } +- return 0; ++ goto out; + } + + /* hack to pass checksum on the custom field */ +@@ -174,6 +230,9 @@ + + deb_rc("key: %*ph\n", 5, key); + } ++out: ++ kfree(cmd); ++ kfree(key); + return 0; + } + +diff -Naur backports-4.2.6-1.org/drivers/media/usb/dvb-usb/cinergyT2-fe.c backports-4.2.6-1/drivers/media/usb/dvb-usb/cinergyT2-fe.c +--- backports-4.2.6-1.org/drivers/media/usb/dvb-usb/cinergyT2-fe.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/usb/dvb-usb/cinergyT2-fe.c 2016-01-27 12:26:21.269959657 +0100 +@@ -145,103 +145,176 @@ + enum fe_status *status) + { + struct cinergyt2_fe_state *state = fe->demodulator_priv; +- struct dvbt_get_status_msg result; +- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; ++ struct dvbt_get_status_msg *result; ++ u8 *cmd; + int ret; + +- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&result, +- sizeof(result), 0); ++ cmd = kmalloc(1, GFP_KERNEL); ++ if (cmd == NULL) ++ return -ENOMEM; ++ result = kmalloc(sizeof(*result), GFP_KERNEL); ++ if (result == NULL) { ++ kfree(cmd); ++ return -ENOMEM; ++ } ++ ++ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; ++ ++ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)result, ++ sizeof(*result), 0); + if (ret < 0) +- return ret; ++ goto out; + + *status = 0; + +- if (0xffff - le16_to_cpu(result.gain) > 30) ++ if (0xffff - le16_to_cpu(result->gain) > 30) + *status |= FE_HAS_SIGNAL; +- if (result.lock_bits & (1 << 6)) ++ if (result->lock_bits & (1 << 6)) + *status |= FE_HAS_LOCK; +- if (result.lock_bits & (1 << 5)) ++ if (result->lock_bits & (1 << 5)) + *status |= FE_HAS_SYNC; +- if (result.lock_bits & (1 << 4)) ++ if (result->lock_bits & (1 << 4)) + *status |= FE_HAS_CARRIER; +- if (result.lock_bits & (1 << 1)) ++ if (result->lock_bits & (1 << 1)) + *status |= FE_HAS_VITERBI; + + if ((*status & (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) != + (FE_HAS_CARRIER | FE_HAS_VITERBI | FE_HAS_SYNC)) + *status &= ~FE_HAS_LOCK; + +- return 0; ++out: ++ kfree(cmd); ++ kfree(result); ++ return ret; + } + + static int cinergyt2_fe_read_ber(struct dvb_frontend *fe, u32 *ber) + { + struct cinergyt2_fe_state *state = fe->demodulator_priv; +- struct dvbt_get_status_msg status; +- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; ++ struct dvbt_get_status_msg *status; ++ char *cmd; + int ret; + +- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status, +- sizeof(status), 0); ++ cmd = kmalloc(1, GFP_KERNEL); ++ if (cmd == NULL) ++ return -ENOMEM; ++ status = kmalloc(sizeof(*status), GFP_KERNEL); ++ if (status == NULL) { ++ kfree(cmd); ++ return -ENOMEM; ++ } ++ ++ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; ++ ++ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status, ++ sizeof(*status), 0); + if (ret < 0) +- return ret; ++ goto out; + +- *ber = le32_to_cpu(status.viterbi_error_rate); ++ *ber = le32_to_cpu(status->viterbi_error_rate); ++out: ++ kfree(cmd); ++ kfree(status); + return 0; + } + + static int cinergyt2_fe_read_unc_blocks(struct dvb_frontend *fe, u32 *unc) + { + struct cinergyt2_fe_state *state = fe->demodulator_priv; +- struct dvbt_get_status_msg status; +- u8 cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; ++ struct dvbt_get_status_msg *status; ++ u8 *cmd; + int ret; + +- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (u8 *)&status, +- sizeof(status), 0); ++ cmd = kmalloc(1, GFP_KERNEL); ++ if (cmd == NULL) ++ return -ENOMEM; ++ status = kmalloc(sizeof(*status), GFP_KERNEL); ++ if (status == NULL) { ++ kfree(cmd); ++ return -ENOMEM; ++ } ++ ++ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; ++ ++ ret = dvb_usb_generic_rw(state->d, cmd, 1, (u8 *)status, ++ sizeof(*status), 0); + if (ret < 0) { + err("cinergyt2_fe_read_unc_blocks() Failed! (Error=%d)\n", + ret); +- return ret; ++ goto out; + } +- *unc = le32_to_cpu(status.uncorrected_block_count); +- return 0; ++ *unc = le32_to_cpu(status->uncorrected_block_count); ++ ++out: ++ kfree(cmd); ++ kfree(status); ++ return ret; + } + + static int cinergyt2_fe_read_signal_strength(struct dvb_frontend *fe, + u16 *strength) + { + struct cinergyt2_fe_state *state = fe->demodulator_priv; +- struct dvbt_get_status_msg status; +- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; ++ struct dvbt_get_status_msg *status; ++ char *cmd; + int ret; + +- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status, +- sizeof(status), 0); ++ cmd = kmalloc(1, GFP_KERNEL); ++ if (cmd == NULL) ++ return -ENOMEM; ++ status = kmalloc(sizeof(*status), GFP_KERNEL); ++ if (status == NULL) { ++ kfree(cmd); ++ return -ENOMEM; ++ } ++ ++ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; ++ ++ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status, ++ sizeof(*status), 0); + if (ret < 0) { + err("cinergyt2_fe_read_signal_strength() Failed!" + " (Error=%d)\n", ret); +- return ret; ++ goto out; + } +- *strength = (0xffff - le16_to_cpu(status.gain)); ++ *strength = (0xffff - le16_to_cpu(status->gain)); ++ ++out: ++ kfree(cmd); ++ kfree(status); + return 0; + } + + static int cinergyt2_fe_read_snr(struct dvb_frontend *fe, u16 *snr) + { + struct cinergyt2_fe_state *state = fe->demodulator_priv; +- struct dvbt_get_status_msg status; +- char cmd[] = { CINERGYT2_EP1_GET_TUNER_STATUS }; ++ struct dvbt_get_status_msg *status; ++ char *cmd; + int ret; + +- ret = dvb_usb_generic_rw(state->d, cmd, sizeof(cmd), (char *)&status, +- sizeof(status), 0); ++ cmd = kmalloc(1, GFP_KERNEL); ++ if (cmd == NULL) ++ return -ENOMEM; ++ status = kmalloc(sizeof(*status), GFP_KERNEL); ++ if (status == NULL) { ++ kfree(cmd); ++ return -ENOMEM; ++ } ++ ++ cmd[0] = CINERGYT2_EP1_GET_TUNER_STATUS; ++ ++ ret = dvb_usb_generic_rw(state->d, cmd, 1, (char *)status, ++ sizeof(*status), 0); + if (ret < 0) { + err("cinergyt2_fe_read_snr() Failed! (Error=%d)\n", ret); +- return ret; ++ goto out; + } +- *snr = (status.snr << 8) | status.snr; +- return 0; ++ *snr = (status->snr << 8) | status->snr; ++ ++out: ++ kfree(cmd); ++ kfree(status); ++ return ret; + } + + static int cinergyt2_fe_init(struct dvb_frontend *fe) +@@ -266,35 +339,46 @@ + { + struct dtv_frontend_properties *fep = &fe->dtv_property_cache; + struct cinergyt2_fe_state *state = fe->demodulator_priv; +- struct dvbt_set_parameters_msg param; +- char result[2]; ++ struct dvbt_set_parameters_msg *param; ++ char *result; + int err; + +- param.cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; +- param.tps = cpu_to_le16(compute_tps(fep)); +- param.freq = cpu_to_le32(fep->frequency / 1000); +- param.flags = 0; ++ result = kmalloc(2, GFP_KERNEL); ++ if (result == NULL) ++ return -ENOMEM; ++ param = kmalloc(sizeof(*param), GFP_KERNEL); ++ if (param == NULL) { ++ kfree(result); ++ return -ENOMEM; ++ } ++ ++ param->cmd = CINERGYT2_EP1_SET_TUNER_PARAMETERS; ++ param->tps = cpu_to_le16(compute_tps(fep)); ++ param->freq = cpu_to_le32(fep->frequency / 1000); ++ param->flags = 0; + + switch (fep->bandwidth_hz) { + default: + case 8000000: +- param.bandwidth = 8; ++ param->bandwidth = 8; + break; + case 7000000: +- param.bandwidth = 7; ++ param->bandwidth = 7; + break; + case 6000000: +- param.bandwidth = 6; ++ param->bandwidth = 6; + break; + } + + err = dvb_usb_generic_rw(state->d, +- (char *)¶m, sizeof(param), +- result, sizeof(result), 0); ++ (char *)param, sizeof(*param), ++ result, 2, 0); + if (err < 0) + err("cinergyt2_fe_set_frontend() Failed! err=%d\n", err); + +- return (err < 0) ? err : 0; ++ kfree(result); ++ kfree(param); ++ return err; + } + + static void cinergyt2_fe_release(struct dvb_frontend *fe) +diff -Naur backports-4.2.6-1.org/drivers/media/usb/dvb-usb/dvb-usb-firmware.c backports-4.2.6-1/drivers/media/usb/dvb-usb/dvb-usb-firmware.c +--- backports-4.2.6-1.org/drivers/media/usb/dvb-usb/dvb-usb-firmware.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/usb/dvb-usb/dvb-usb-firmware.c 2016-01-27 12:26:21.269959657 +0100 +@@ -35,42 +35,57 @@ + + int usb_cypress_load_firmware(struct usb_device *udev, const struct firmware *fw, int type) + { +- struct hexline hx; +- u8 reset; ++ struct hexline *hx; ++ u8 *reset; + int ret,pos=0; + ++ reset = kmalloc(1, GFP_KERNEL); ++ if (reset == NULL) ++ return -ENOMEM; ++ ++ hx = kmalloc(sizeof(struct hexline), GFP_KERNEL); ++ if (hx == NULL) { ++ kfree(reset); ++ return -ENOMEM; ++ } ++ + /* stop the CPU */ +- reset = 1; +- if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1)) != 1) ++ reset[0] = 1; ++ if ((ret = usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1)) != 1) + err("could not stop the USB controller CPU."); + +- while ((ret = dvb_usb_get_hexline(fw,&hx,&pos)) > 0) { +- deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx.addr,hx.len,hx.chk); +- ret = usb_cypress_writemem(udev,hx.addr,hx.data,hx.len); ++ while ((ret = dvb_usb_get_hexline(fw,hx,&pos)) > 0) { ++ deb_fw("writing to address 0x%04x (buffer: 0x%02x %02x)\n",hx->addr,hx->len,hx->chk); ++ ret = usb_cypress_writemem(udev,hx->addr,hx->data,hx->len); + +- if (ret != hx.len) { ++ if (ret != hx->len) { + err("error while transferring firmware " + "(transferred size: %d, block size: %d)", +- ret,hx.len); ++ ret,hx->len); + ret = -EINVAL; + break; + } + } + if (ret < 0) { + err("firmware download failed at %d with %d",pos,ret); ++ kfree(reset); ++ kfree(hx); + return ret; + } + + if (ret == 0) { + /* restart the CPU */ +- reset = 0; +- if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,&reset,1) != 1) { ++ reset[0] = 0; ++ if (ret || usb_cypress_writemem(udev,cypress[type].cpu_cs_register,reset,1) != 1) { + err("could not restart the USB controller CPU."); + ret = -EINVAL; + } + } else + ret = -EIO; + ++ kfree(reset); ++ kfree(hx); ++ + return ret; + } + EXPORT_SYMBOL(usb_cypress_load_firmware); +diff -Naur backports-4.2.6-1.org/drivers/media/usb/dvb-usb/technisat-usb2.c backports-4.2.6-1/drivers/media/usb/dvb-usb/technisat-usb2.c +--- backports-4.2.6-1.org/drivers/media/usb/dvb-usb/technisat-usb2.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/usb/dvb-usb/technisat-usb2.c 2016-01-27 12:26:21.269959657 +0100 +@@ -87,8 +87,11 @@ + static int technisat_usb2_i2c_access(struct usb_device *udev, + u8 device_addr, u8 *tx, u8 txlen, u8 *rx, u8 rxlen) + { +- u8 b[64]; +- int ret, actual_length; ++ u8 *b = kmalloc(64, GFP_KERNEL); ++ int ret, actual_length, error = 0; ++ ++ if (b == NULL) ++ return -ENOMEM; + + deb_i2c("i2c-access: %02x, tx: ", device_addr); + debug_dump(tx, txlen, deb_i2c); +@@ -121,7 +124,8 @@ + + if (ret < 0) { + err("i2c-error: out failed %02x = %d", device_addr, ret); +- return -ENODEV; ++ error = -ENODEV; ++ goto out; + } + + ret = usb_bulk_msg(udev, +@@ -129,7 +133,8 @@ + b, 64, &actual_length, 1000); + if (ret < 0) { + err("i2c-error: in failed %02x = %d", device_addr, ret); +- return -ENODEV; ++ error = -ENODEV; ++ goto out; + } + + if (b[0] != I2C_STATUS_OK) { +@@ -137,8 +142,10 @@ + /* handle tuner-i2c-nak */ + if (!(b[0] == I2C_STATUS_NAK && + device_addr == 0x60 +- /* && device_is_technisat_usb2 */)) +- return -ENODEV; ++ /* && device_is_technisat_usb2 */)) { ++ error = -ENODEV; ++ goto out; ++ } + } + + deb_i2c("status: %d, ", b[0]); +@@ -152,7 +159,9 @@ + + deb_i2c("\n"); + +- return 0; ++out: ++ kfree(b); ++ return error; + } + + static int technisat_usb2_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, +@@ -224,14 +233,16 @@ + { + int ret; + +- u8 led[8] = { +- red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST, +- 0 +- }; ++ u8 *led = kzalloc(8, GFP_KERNEL); ++ ++ if (led == NULL) ++ return -ENOMEM; + + if (disable_led_control && state != TECH_LED_OFF) + return 0; + ++ led[0] = red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST; ++ + switch (state) { + case TECH_LED_ON: + led[1] = 0x82; +@@ -263,16 +274,22 @@ + red ? SET_RED_LED_VENDOR_REQUEST : SET_GREEN_LED_VENDOR_REQUEST, + USB_TYPE_VENDOR | USB_DIR_OUT, + 0, 0, +- led, sizeof(led), 500); ++ led, 8, 500); + + mutex_unlock(&d->i2c_mutex); ++ ++ kfree(led); ++ + return ret; + } + + static int technisat_usb2_set_led_timer(struct dvb_usb_device *d, u8 red, u8 green) + { + int ret; +- u8 b = 0; ++ u8 *b = kzalloc(1, GFP_KERNEL); ++ ++ if (b == NULL) ++ return -ENOMEM; + + if (mutex_lock_interruptible(&d->i2c_mutex) < 0) + return -EAGAIN; +@@ -281,10 +298,12 @@ + SET_LED_TIMER_DIVIDER_VENDOR_REQUEST, + USB_TYPE_VENDOR | USB_DIR_OUT, + (red << 8) | green, 0, +- &b, 1, 500); ++ b, 1, 500); + + mutex_unlock(&d->i2c_mutex); + ++ kfree(b); ++ + return ret; + } + +@@ -328,7 +347,7 @@ + struct dvb_usb_device_description **desc, int *cold) + { + int ret; +- u8 version[3]; ++ u8 *version = kmalloc(3, GFP_KERNEL); + + /* first select the interface */ + if (usb_set_interface(udev, 0, 1) != 0) +@@ -338,11 +357,14 @@ + + *cold = 0; /* by default do not download a firmware - just in case something is wrong */ + ++ if (version == NULL) ++ return 0; ++ + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), + GET_VERSION_INFO_VENDOR_REQUEST, + USB_TYPE_VENDOR | USB_DIR_IN, + 0, 0, +- version, sizeof(version), 500); ++ version, 3, 500); + + if (ret < 0) + *cold = 1; +@@ -351,6 +373,8 @@ + *cold = 0; + } + ++ kfree(version); ++ + return 0; + } + +@@ -594,10 +618,15 @@ + + static int technisat_usb2_get_ir(struct dvb_usb_device *d) + { +- u8 buf[62], *b; ++ u8 *buf, *b; + int ret; + struct ir_raw_event ev; + ++ buf = kmalloc(62, GFP_KERNEL); ++ ++ if (buf == NULL) ++ return -ENOMEM; ++ + buf[0] = GET_IR_DATA_VENDOR_REQUEST; + buf[1] = 0x08; + buf[2] = 0x8f; +@@ -620,16 +649,20 @@ + GET_IR_DATA_VENDOR_REQUEST, + USB_TYPE_VENDOR | USB_DIR_IN, + 0x8080, 0, +- buf, sizeof(buf), 500); ++ buf, 62, 500); + + unlock: + mutex_unlock(&d->i2c_mutex); + +- if (ret < 0) ++ if (ret < 0) { ++ kfree(buf); + return ret; ++ } + +- if (ret == 1) ++ if (ret == 1) { ++ kfree(buf); + return 0; /* no key pressed */ ++ } + + /* decoding */ + b = buf+1; +@@ -656,6 +689,8 @@ + + ir_raw_event_handle(d->rc_dev); + ++ kfree(buf); ++ + return 1; + } + +diff -Naur backports-4.2.6-1.org/drivers/media/v4l2-core/v4l2-compat-ioctl32.c backports-4.2.6-1/drivers/media/v4l2-core/v4l2-compat-ioctl32.c +--- backports-4.2.6-1.org/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/v4l2-core/v4l2-compat-ioctl32.c 2016-01-27 12:26:21.269959657 +0100 +@@ -429,7 +429,7 @@ + * by passing a very big num_planes value */ + uplane = compat_alloc_user_space(num_planes * + sizeof(struct v4l2_plane)); +- kp->m.planes = (__force struct v4l2_plane *)uplane; ++ kp->m.planes = (__force_kernel struct v4l2_plane *)uplane; + + while (--num_planes >= 0) { + ret = get_v4l2_plane32(uplane, uplane32, kp->memory); +@@ -500,7 +500,7 @@ + if (num_planes == 0) + return 0; + +- uplane = (__force struct v4l2_plane __user *)kp->m.planes; ++ uplane = (struct v4l2_plane __force_user *)kp->m.planes; + if (get_user(p, &up->m.planes)) + return -EFAULT; + uplane32 = compat_ptr(p); +@@ -564,7 +564,7 @@ + get_user(kp->flags, &up->flags) || + copy_from_user(&kp->fmt, &up->fmt, sizeof(up->fmt))) + return -EFAULT; +- kp->base = (__force void *)compat_ptr(tmp); ++ kp->base = (__force_kernel void *)compat_ptr(tmp); + return 0; + } + +@@ -669,7 +669,7 @@ + n * sizeof(struct v4l2_ext_control32))) + return -EFAULT; + kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control)); +- kp->controls = (__force struct v4l2_ext_control *)kcontrols; ++ kp->controls = (__force_kernel struct v4l2_ext_control *)kcontrols; + while (--n >= 0) { + u32 id; + +@@ -696,7 +696,7 @@ + { + struct v4l2_ext_control32 __user *ucontrols; + struct v4l2_ext_control __user *kcontrols = +- (__force struct v4l2_ext_control __user *)kp->controls; ++ (struct v4l2_ext_control __force_user *)kp->controls; + int n = kp->count; + compat_caddr_t p; + +@@ -780,7 +780,7 @@ + get_user(tmp, &up->edid) || + copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved))) + return -EFAULT; +- kp->edid = (__force u8 *)compat_ptr(tmp); ++ kp->edid = (__force_kernel u8 *)compat_ptr(tmp); + return 0; + } + +diff -Naur backports-4.2.6-1.org/drivers/media/v4l2-core/v4l2-device.c backports-4.2.6-1/drivers/media/v4l2-core/v4l2-device.c +--- backports-4.2.6-1.org/drivers/media/v4l2-core/v4l2-device.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/v4l2-core/v4l2-device.c 2016-01-27 12:26:21.269959657 +0100 +@@ -74,9 +74,9 @@ + EXPORT_SYMBOL_GPL(v4l2_device_put); + + int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename, +- atomic_t *instance) ++ atomic_unchecked_t *instance) + { +- int num = atomic_inc_return(instance) - 1; ++ int num = atomic_inc_return_unchecked(instance) - 1; + int len = strlen(basename); + + if (basename[len - 1] >= '0' && basename[len - 1] <= '9') +diff -Naur backports-4.2.6-1.org/drivers/media/v4l2-core/v4l2-ioctl.c backports-4.2.6-1/drivers/media/v4l2-core/v4l2-ioctl.c +--- backports-4.2.6-1.org/drivers/media/v4l2-core/v4l2-ioctl.c 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/drivers/media/v4l2-core/v4l2-ioctl.c 2016-01-27 12:26:21.269959657 +0100 +@@ -2341,7 +2341,8 @@ + struct file *file, void *fh, void *p); + } u; + void (*debug)(const void *arg, bool write_only); +-}; ++} __do_const; ++typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const; + + /* This control needs a priority check */ + #define INFO_FL_PRIO (1 << 0) +@@ -2525,7 +2526,7 @@ + struct video_device *vfd = video_devdata(file); + const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops; + bool write_only = false; +- struct v4l2_ioctl_info default_info; ++ v4l2_ioctl_info_no_const default_info; + const struct v4l2_ioctl_info *info; + void *fh = file->private_data; + struct v4l2_fh *vfh = NULL; +@@ -2616,7 +2617,7 @@ + ret = -EINVAL; + break; + } +- *user_ptr = (void __user *)buf->m.planes; ++ *user_ptr = (void __force_user *)buf->m.planes; + *kernel_ptr = (void **)&buf->m.planes; + *array_size = sizeof(struct v4l2_plane) * buf->length; + ret = 1; +@@ -2633,7 +2634,7 @@ + ret = -EINVAL; + break; + } +- *user_ptr = (void __user *)edid->edid; ++ *user_ptr = (void __force_user *)edid->edid; + *kernel_ptr = (void **)&edid->edid; + *array_size = edid->blocks * 128; + ret = 1; +@@ -2651,7 +2652,7 @@ + ret = -EINVAL; + break; + } +- *user_ptr = (void __user *)ctrls->controls; ++ *user_ptr = (void __force_user *)ctrls->controls; + *kernel_ptr = (void **)&ctrls->controls; + *array_size = sizeof(struct v4l2_ext_control) + * ctrls->count; +@@ -2752,7 +2753,7 @@ + } + + if (has_array_args) { +- *kernel_ptr = (void __force *)user_ptr; ++ *kernel_ptr = (void __force_kernel *)user_ptr; + if (copy_to_user(user_ptr, mbuf, array_size)) + err = -EFAULT; + goto out_array_args; +diff -Naur backports-4.2.6-1.org/drivers/net/usb/sierra_net.c backports-4.2.6-1/drivers/net/usb/sierra_net.c +--- backports-4.2.6-1.org/drivers/net/usb/sierra_net.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/usb/sierra_net.c 2016-01-27 12:26:21.283292990 +0100 +@@ -51,7 +51,7 @@ + /* atomic counter partially included in MAC address to make sure 2 devices + * do not end up with the same MAC - concept breaks in case of > 255 ifaces + */ +-static atomic_t iface_counter = ATOMIC_INIT(0); ++static atomic_unchecked_t iface_counter = ATOMIC_INIT(0); + + /* + * SYNC Timer Delay definition used to set the expiry time +@@ -697,7 +697,7 @@ + dev->net->netdev_ops = &sierra_net_device_ops; + + /* change MAC addr to include, ifacenum, and to be unique */ +- dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter); ++ dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter); + dev->net->dev_addr[ETH_ALEN-1] = ifacenum; + + /* we will have to manufacture ethernet headers, prepare template */ +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/airo.c backports-4.2.6-1/drivers/net/wireless/airo.c +--- backports-4.2.6-1.org/drivers/net/wireless/airo.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/airo.c 2016-01-27 12:26:21.286626323 +0100 +@@ -7846,7 +7846,7 @@ + struct airo_info *ai = dev->ml_priv; + int ridcode; + int enabled; +- static int (* writer)(struct airo_info *, u16 rid, const void *, int, int); ++ int (* writer)(struct airo_info *, u16 rid, const void *, int, int); + unsigned char *iobuf; + + /* Only super-user can write RIDs */ +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/at76c50x-usb.c backports-4.2.6-1/drivers/net/wireless/at76c50x-usb.c +--- backports-4.2.6-1.org/drivers/net/wireless/at76c50x-usb.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/at76c50x-usb.c 2016-01-27 12:26:21.286626323 +0100 +@@ -353,7 +353,7 @@ + } + + /* Convert timeout from the DFU status to jiffies */ +-static inline unsigned long at76_get_timeout(struct dfu_status *s) ++static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s) + { + return msecs_to_jiffies((s->poll_timeout[2] << 16) + | (s->poll_timeout[1] << 8) +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ath/ath10k/ce.c backports-4.2.6-1/drivers/net/wireless/ath/ath10k/ce.c +--- backports-4.2.6-1.org/drivers/net/wireless/ath/ath10k/ce.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ath/ath10k/ce.c 2016-01-27 12:26:21.286626323 +0100 +@@ -896,12 +896,12 @@ + return 0; + } + +-static struct ath10k_ce_ring * ++static struct ath10k_ce_ring * __intentional_overflow(-1) + ath10k_ce_alloc_src_ring(struct ath10k *ar, unsigned int ce_id, + const struct ce_attr *attr) + { + struct ath10k_ce_ring *src_ring; +- u32 nentries = attr->src_nentries; ++ unsigned long nentries = attr->src_nentries; + dma_addr_t base_addr; + + nentries = roundup_pow_of_two(nentries); +@@ -968,7 +968,7 @@ + const struct ce_attr *attr) + { + struct ath10k_ce_ring *dest_ring; +- u32 nentries; ++ unsigned long nentries; + dma_addr_t base_addr; + + nentries = roundup_pow_of_two(attr->dest_nentries); +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ath/ath10k/htc.c backports-4.2.6-1/drivers/net/wireless/ath/ath10k/htc.c +--- backports-4.2.6-1.org/drivers/net/wireless/ath/ath10k/htc.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ath/ath10k/htc.c 2016-01-27 12:26:21.286626323 +0100 +@@ -841,7 +841,10 @@ + /* registered target arrival callback from the HIF layer */ + int ath10k_htc_init(struct ath10k *ar) + { +- struct ath10k_hif_cb htc_callbacks; ++ static struct ath10k_hif_cb htc_callbacks = { ++ .rx_completion = ath10k_htc_rx_completion_handler, ++ .tx_completion = ath10k_htc_tx_completion_handler, ++ }; + struct ath10k_htc_ep *ep = NULL; + struct ath10k_htc *htc = &ar->htc; + +@@ -850,8 +853,6 @@ + ath10k_htc_reset_endpoint_states(htc); + + /* setup HIF layer callbacks */ +- htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler; +- htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler; + htc->ar = ar; + + /* Get HIF default pipe for HTC message exchange */ +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ath/ath10k/htc.h backports-4.2.6-1/drivers/net/wireless/ath/ath10k/htc.h +--- backports-4.2.6-1.org/drivers/net/wireless/ath/ath10k/htc.h 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ath/ath10k/htc.h 2016-01-27 12:26:21.286626323 +0100 +@@ -270,13 +270,13 @@ + + struct ath10k_htc_ops { + void (*target_send_suspend_complete)(struct ath10k *ar); +-}; ++} __no_const; + + struct ath10k_htc_ep_ops { + void (*ep_tx_complete)(struct ath10k *, struct sk_buff *); + void (*ep_rx_complete)(struct ath10k *, struct sk_buff *); + void (*ep_tx_credits)(struct ath10k *); +-}; ++} __no_const; + + /* service connection information */ + struct ath10k_htc_svc_conn_req { +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/ar9002_mac.c backports-4.2.6-1/drivers/net/wireless/ath/ath9k/ar9002_mac.c +--- backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/ar9002_mac.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ath/ath9k/ar9002_mac.c 2016-01-27 12:26:21.286626323 +0100 +@@ -220,8 +220,8 @@ + ads->ds_txstatus6 = ads->ds_txstatus7 = 0; + ads->ds_txstatus8 = ads->ds_txstatus9 = 0; + +- ACCESS_ONCE(ads->ds_link) = i->link; +- ACCESS_ONCE(ads->ds_data) = i->buf_addr[0]; ++ ACCESS_ONCE_RW(ads->ds_link) = i->link; ++ ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0]; + + ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore); + ctl6 = SM(i->keytype, AR_EncrType); +@@ -235,26 +235,26 @@ + + if ((i->is_first || i->is_last) && + i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) { +- ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0) ++ ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0) + | set11nTries(i->rates, 1) + | set11nTries(i->rates, 2) + | set11nTries(i->rates, 3) + | (i->dur_update ? AR_DurUpdateEna : 0) + | SM(0, AR_BurstDur); + +- ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0) ++ ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0) + | set11nRate(i->rates, 1) + | set11nRate(i->rates, 2) + | set11nRate(i->rates, 3); + } else { +- ACCESS_ONCE(ads->ds_ctl2) = 0; +- ACCESS_ONCE(ads->ds_ctl3) = 0; ++ ACCESS_ONCE_RW(ads->ds_ctl2) = 0; ++ ACCESS_ONCE_RW(ads->ds_ctl3) = 0; + } + + if (!i->is_first) { +- ACCESS_ONCE(ads->ds_ctl0) = 0; +- ACCESS_ONCE(ads->ds_ctl1) = ctl1; +- ACCESS_ONCE(ads->ds_ctl6) = ctl6; ++ ACCESS_ONCE_RW(ads->ds_ctl0) = 0; ++ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1; ++ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6; + return; + } + +@@ -279,7 +279,7 @@ + break; + } + +- ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen) ++ ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen) + | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0) + | SM(i->txpower[0], AR_XmitPower0) + | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0) +@@ -289,27 +289,27 @@ + | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable : + (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0)); + +- ACCESS_ONCE(ads->ds_ctl1) = ctl1; +- ACCESS_ONCE(ads->ds_ctl6) = ctl6; ++ ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1; ++ ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6; + + if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST) + return; + +- ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0) ++ ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0) + | set11nPktDurRTSCTS(i->rates, 1); + +- ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2) ++ ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2) + | set11nPktDurRTSCTS(i->rates, 3); + +- ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0) ++ ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0) + | set11nRateFlags(i->rates, 1) + | set11nRateFlags(i->rates, 2) + | set11nRateFlags(i->rates, 3) + | SM(i->rtscts_rate, AR_RTSCTSRate); + +- ACCESS_ONCE(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1); +- ACCESS_ONCE(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2); +- ACCESS_ONCE(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3); ++ ACCESS_ONCE_RW(ads->ds_ctl9) = SM(i->txpower[1], AR_XmitPower1); ++ ACCESS_ONCE_RW(ads->ds_ctl10) = SM(i->txpower[2], AR_XmitPower2); ++ ACCESS_ONCE_RW(ads->ds_ctl11) = SM(i->txpower[3], AR_XmitPower3); + } + + static int ar9002_hw_proc_txdesc(struct ath_hw *ah, void *ds, +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/ar9003_mac.c backports-4.2.6-1/drivers/net/wireless/ath/ath9k/ar9003_mac.c +--- backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/ar9003_mac.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ath/ath9k/ar9003_mac.c 2016-01-27 12:26:21.286626323 +0100 +@@ -39,47 +39,47 @@ + (i->qcu << AR_TxQcuNum_S) | desc_len; + + checksum += val; +- ACCESS_ONCE(ads->info) = val; ++ ACCESS_ONCE_RW(ads->info) = val; + + checksum += i->link; +- ACCESS_ONCE(ads->link) = i->link; ++ ACCESS_ONCE_RW(ads->link) = i->link; + + checksum += i->buf_addr[0]; +- ACCESS_ONCE(ads->data0) = i->buf_addr[0]; ++ ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0]; + checksum += i->buf_addr[1]; +- ACCESS_ONCE(ads->data1) = i->buf_addr[1]; ++ ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1]; + checksum += i->buf_addr[2]; +- ACCESS_ONCE(ads->data2) = i->buf_addr[2]; ++ ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2]; + checksum += i->buf_addr[3]; +- ACCESS_ONCE(ads->data3) = i->buf_addr[3]; ++ ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3]; + + checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen); +- ACCESS_ONCE(ads->ctl3) = val; ++ ACCESS_ONCE_RW(ads->ctl3) = val; + checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen); +- ACCESS_ONCE(ads->ctl5) = val; ++ ACCESS_ONCE_RW(ads->ctl5) = val; + checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen); +- ACCESS_ONCE(ads->ctl7) = val; ++ ACCESS_ONCE_RW(ads->ctl7) = val; + checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen); +- ACCESS_ONCE(ads->ctl9) = val; ++ ACCESS_ONCE_RW(ads->ctl9) = val; + + checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff); +- ACCESS_ONCE(ads->ctl10) = checksum; ++ ACCESS_ONCE_RW(ads->ctl10) = checksum; + + if (i->is_first || i->is_last) { +- ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0) ++ ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0) + | set11nTries(i->rates, 1) + | set11nTries(i->rates, 2) + | set11nTries(i->rates, 3) + | (i->dur_update ? AR_DurUpdateEna : 0) + | SM(0, AR_BurstDur); + +- ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0) ++ ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0) + | set11nRate(i->rates, 1) + | set11nRate(i->rates, 2) + | set11nRate(i->rates, 3); + } else { +- ACCESS_ONCE(ads->ctl13) = 0; +- ACCESS_ONCE(ads->ctl14) = 0; ++ ACCESS_ONCE_RW(ads->ctl13) = 0; ++ ACCESS_ONCE_RW(ads->ctl14) = 0; + } + + ads->ctl20 = 0; +@@ -89,17 +89,17 @@ + + ctl17 = SM(i->keytype, AR_EncrType); + if (!i->is_first) { +- ACCESS_ONCE(ads->ctl11) = 0; +- ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore; +- ACCESS_ONCE(ads->ctl15) = 0; +- ACCESS_ONCE(ads->ctl16) = 0; +- ACCESS_ONCE(ads->ctl17) = ctl17; +- ACCESS_ONCE(ads->ctl18) = 0; +- ACCESS_ONCE(ads->ctl19) = 0; ++ ACCESS_ONCE_RW(ads->ctl11) = 0; ++ ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore; ++ ACCESS_ONCE_RW(ads->ctl15) = 0; ++ ACCESS_ONCE_RW(ads->ctl16) = 0; ++ ACCESS_ONCE_RW(ads->ctl17) = ctl17; ++ ACCESS_ONCE_RW(ads->ctl18) = 0; ++ ACCESS_ONCE_RW(ads->ctl19) = 0; + return; + } + +- ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen) ++ ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen) + | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0) + | SM(i->txpower[0], AR_XmitPower0) + | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0) +@@ -135,26 +135,26 @@ + val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S; + ctl12 |= SM(val, AR_PAPRDChainMask); + +- ACCESS_ONCE(ads->ctl12) = ctl12; +- ACCESS_ONCE(ads->ctl17) = ctl17; ++ ACCESS_ONCE_RW(ads->ctl12) = ctl12; ++ ACCESS_ONCE_RW(ads->ctl17) = ctl17; + +- ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0) ++ ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0) + | set11nPktDurRTSCTS(i->rates, 1); + +- ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2) ++ ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2) + | set11nPktDurRTSCTS(i->rates, 3); + +- ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0) ++ ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0) + | set11nRateFlags(i->rates, 1) + | set11nRateFlags(i->rates, 2) + | set11nRateFlags(i->rates, 3) + | SM(i->rtscts_rate, AR_RTSCTSRate); + +- ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding; ++ ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding; + +- ACCESS_ONCE(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1); +- ACCESS_ONCE(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2); +- ACCESS_ONCE(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3); ++ ACCESS_ONCE_RW(ads->ctl20) = SM(i->txpower[1], AR_XmitPower1); ++ ACCESS_ONCE_RW(ads->ctl21) = SM(i->txpower[2], AR_XmitPower2); ++ ACCESS_ONCE_RW(ads->ctl22) = SM(i->txpower[3], AR_XmitPower3); + } + + static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads) +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/hw.h backports-4.2.6-1/drivers/net/wireless/ath/ath9k/hw.h +--- backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/hw.h 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ath/ath9k/hw.h 2016-01-27 12:33:44.649931973 +0100 +@@ -671,7 +671,7 @@ + #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT + bool (*is_aic_enabled)(struct ath_hw *ah); + #endif /* CPTCFG_ATH9K_BTCOEX_SUPPORT */ +-}; ++} __no_const; + + /** + * struct ath_spec_scan - parameters for Atheros spectral scan +@@ -747,7 +747,7 @@ + #ifdef CPTCFG_ATH9K_BTCOEX_SUPPORT + void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable); + #endif +-}; ++} __no_const; + + struct ath_nf_limits { + s16 max; +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/Kconfig backports-4.2.6-1/drivers/net/wireless/ath/ath9k/Kconfig +--- backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/Kconfig 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ath/ath9k/Kconfig 2016-01-27 12:34:48.923262299 +0100 +@@ -5,7 +5,6 @@ + tristate + depends on m + select ATH_COMMON +- depends on DEBUG_FS + depends on RELAY + config ATH9K_DFS_DEBUGFS + def_bool y +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/main.c backports-4.2.6-1/drivers/net/wireless/ath/ath9k/main.c +--- backports-4.2.6-1.org/drivers/net/wireless/ath/ath9k/main.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ath/ath9k/main.c 2016-01-27 12:26:21.289959656 +0100 +@@ -2574,16 +2574,18 @@ + if (!ath9k_is_chanctx_enabled()) + return; + +- ath9k_ops.hw_scan = ath9k_hw_scan; +- ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan; +- ath9k_ops.remain_on_channel = ath9k_remain_on_channel; +- ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel; +- ath9k_ops.add_chanctx = ath9k_add_chanctx; +- ath9k_ops.remove_chanctx = ath9k_remove_chanctx; +- ath9k_ops.change_chanctx = ath9k_change_chanctx; +- ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx; +- ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx; +- ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx; ++ pax_open_kernel(); ++ *(void **)&ath9k_ops.hw_scan = ath9k_hw_scan; ++ *(void **)&ath9k_ops.cancel_hw_scan = ath9k_cancel_hw_scan; ++ *(void **)&ath9k_ops.remain_on_channel = ath9k_remain_on_channel; ++ *(void **)&ath9k_ops.cancel_remain_on_channel = ath9k_cancel_remain_on_channel; ++ *(void **)&ath9k_ops.add_chanctx = ath9k_add_chanctx; ++ *(void **)&ath9k_ops.remove_chanctx = ath9k_remove_chanctx; ++ *(void **)&ath9k_ops.change_chanctx = ath9k_change_chanctx; ++ *(void **)&ath9k_ops.assign_vif_chanctx = ath9k_assign_vif_chanctx; ++ *(void **)&ath9k_ops.unassign_vif_chanctx = ath9k_unassign_vif_chanctx; ++ *(void **)&ath9k_ops.mgd_prepare_tx = ath9k_mgd_prepare_tx; ++ pax_close_kernel(); + } + + #endif +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/b43/phy_lp.c backports-4.2.6-1/drivers/net/wireless/b43/phy_lp.c +--- backports-4.2.6-1.org/drivers/net/wireless/b43/phy_lp.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/b43/phy_lp.c 2016-01-27 12:26:21.289959656 +0100 +@@ -2502,7 +2502,7 @@ + { + struct ssb_bus *bus = dev->dev->sdev->bus; + +- static const struct b206x_channel *chandata = NULL; ++ const struct b206x_channel *chandata = NULL; + u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000; + u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count; + u16 old_comm15, scale; +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/iwlegacy/3945-mac.c backports-4.2.6-1/drivers/net/wireless/iwlegacy/3945-mac.c +--- backports-4.2.6-1.org/drivers/net/wireless/iwlegacy/3945-mac.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/iwlegacy/3945-mac.c 2016-01-27 12:26:21.289959656 +0100 +@@ -3633,7 +3633,9 @@ + */ + if (il3945_mod_params.disable_hw_scan) { + D_INFO("Disabling hw_scan\n"); +- il3945_mac_ops.hw_scan = NULL; ++ pax_open_kernel(); ++ *(void **)&il3945_mac_ops.hw_scan = NULL; ++ pax_close_kernel(); + } + + D_INFO("*** LOAD DRIVER ***\n"); +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/iwlwifi/dvm/debugfs.c backports-4.2.6-1/drivers/net/wireless/iwlwifi/dvm/debugfs.c +--- backports-4.2.6-1.org/drivers/net/wireless/iwlwifi/dvm/debugfs.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/iwlwifi/dvm/debugfs.c 2016-01-27 12:26:21.289959656 +0100 +@@ -188,7 +188,7 @@ + { + struct iwl_priv *priv = file->private_data; + char buf[64]; +- int buf_size; ++ size_t buf_size; + u32 offset, len; + + memset(buf, 0, sizeof(buf)); +@@ -458,7 +458,7 @@ + struct iwl_priv *priv = file->private_data; + + char buf[8]; +- int buf_size; ++ size_t buf_size; + u32 reset_flag; + + memset(buf, 0, sizeof(buf)); +@@ -539,7 +539,7 @@ + { + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int ht40; + + memset(buf, 0, sizeof(buf)); +@@ -591,7 +591,7 @@ + { + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int value; + + memset(buf, 0, sizeof(buf)); +@@ -683,10 +683,10 @@ + DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override); + DEBUGFS_READ_FILE_OPS(current_sleep_command); + +-static const char *fmt_value = " %-30s %10u\n"; +-static const char *fmt_hex = " %-30s 0x%02X\n"; +-static const char *fmt_table = " %-30s %10u %10u %10u %10u\n"; +-static const char *fmt_header = ++static const char fmt_value[] = " %-30s %10u\n"; ++static const char fmt_hex[] = " %-30s 0x%02X\n"; ++static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n"; ++static const char fmt_header[] = + "%-32s current cumulative delta max\n"; + + static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz) +@@ -1856,7 +1856,7 @@ + { + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int clear; + + memset(buf, 0, sizeof(buf)); +@@ -1901,7 +1901,7 @@ + { + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int trace; + + memset(buf, 0, sizeof(buf)); +@@ -1972,7 +1972,7 @@ + { + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int missed; + + memset(buf, 0, sizeof(buf)); +@@ -2013,7 +2013,7 @@ + + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int plcp; + + memset(buf, 0, sizeof(buf)); +@@ -2073,7 +2073,7 @@ + + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int flush; + + memset(buf, 0, sizeof(buf)); +@@ -2163,7 +2163,7 @@ + + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int rts; + + if (!priv->cfg->ht_params) +@@ -2204,7 +2204,7 @@ + { + struct iwl_priv *priv = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); +@@ -2238,7 +2238,7 @@ + struct iwl_priv *priv = file->private_data; + u32 event_log_flag; + char buf[8]; +- int buf_size; ++ size_t buf_size; + + /* check that the interface is up */ + if (!iwl_is_ready(priv)) +@@ -2292,7 +2292,7 @@ + struct iwl_priv *priv = file->private_data; + char buf[8]; + u32 calib_disabled; +- int buf_size; ++ size_t buf_size; + + memset(buf, 0, sizeof(buf)); + buf_size = min(count, sizeof(buf) - 1); +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/iwlwifi/pcie/trans.c backports-4.2.6-1/drivers/net/wireless/iwlwifi/pcie/trans.c +--- backports-4.2.6-1.org/drivers/net/wireless/iwlwifi/pcie/trans.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/iwlwifi/pcie/trans.c 2016-01-27 12:26:21.289959656 +0100 +@@ -1950,7 +1950,7 @@ + struct isr_statistics *isr_stats = &trans_pcie->isr_stats; + + char buf[8]; +- int buf_size; ++ size_t buf_size; + u32 reset_flag; + + memset(buf, 0, sizeof(buf)); +@@ -1971,7 +1971,7 @@ + { + struct iwl_trans *trans = file->private_data; + char buf[8]; +- int buf_size; ++ size_t buf_size; + int csr; + + memset(buf, 0, sizeof(buf)); +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/mac80211_hwsim.c backports-4.2.6-1/drivers/net/wireless/mac80211_hwsim.c +--- backports-4.2.6-1.org/drivers/net/wireless/mac80211_hwsim.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/mac80211_hwsim.c 2016-01-27 12:26:21.289959656 +0100 +@@ -3150,20 +3150,20 @@ + if (channels < 1) + return -EINVAL; + +- mac80211_hwsim_mchan_ops = mac80211_hwsim_ops; +- mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan; +- mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan; +- mac80211_hwsim_mchan_ops.sw_scan_start = NULL; +- mac80211_hwsim_mchan_ops.sw_scan_complete = NULL; +- mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc; +- mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc; +- mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx; +- mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx; +- mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx; +- mac80211_hwsim_mchan_ops.assign_vif_chanctx = +- mac80211_hwsim_assign_vif_chanctx; +- mac80211_hwsim_mchan_ops.unassign_vif_chanctx = +- mac80211_hwsim_unassign_vif_chanctx; ++ pax_open_kernel(); ++ memcpy((void *)&mac80211_hwsim_mchan_ops, &mac80211_hwsim_ops, sizeof mac80211_hwsim_mchan_ops); ++ *(void **)&mac80211_hwsim_mchan_ops.hw_scan = mac80211_hwsim_hw_scan; ++ *(void **)&mac80211_hwsim_mchan_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan; ++ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_start = NULL; ++ *(void **)&mac80211_hwsim_mchan_ops.sw_scan_complete = NULL; ++ *(void **)&mac80211_hwsim_mchan_ops.remain_on_channel = mac80211_hwsim_roc; ++ *(void **)&mac80211_hwsim_mchan_ops.cancel_remain_on_channel = mac80211_hwsim_croc; ++ *(void **)&mac80211_hwsim_mchan_ops.add_chanctx = mac80211_hwsim_add_chanctx; ++ *(void **)&mac80211_hwsim_mchan_ops.remove_chanctx = mac80211_hwsim_remove_chanctx; ++ *(void **)&mac80211_hwsim_mchan_ops.change_chanctx = mac80211_hwsim_change_chanctx; ++ *(void **)&mac80211_hwsim_mchan_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx; ++ *(void **)&mac80211_hwsim_mchan_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx; ++ pax_close_kernel(); + + spin_lock_init(&hwsim_radio_lock); + INIT_LIST_HEAD(&hwsim_radios); +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/rndis_wlan.c backports-4.2.6-1/drivers/net/wireless/rndis_wlan.c +--- backports-4.2.6-1.org/drivers/net/wireless/rndis_wlan.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/rndis_wlan.c 2016-01-27 12:26:21.293292990 +0100 +@@ -1236,7 +1236,7 @@ + + netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold); + +- if (rts_threshold < 0 || rts_threshold > 2347) ++ if (rts_threshold > 2347) + rts_threshold = 2347; + + tmp = cpu_to_le32(rts_threshold); +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/rt2x00/rt2x00.h backports-4.2.6-1/drivers/net/wireless/rt2x00/rt2x00.h +--- backports-4.2.6-1.org/drivers/net/wireless/rt2x00/rt2x00.h 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/rt2x00/rt2x00.h 2016-01-27 12:26:21.293292990 +0100 +@@ -375,7 +375,7 @@ + * for hardware which doesn't support hardware + * sequence counting. + */ +- atomic_t seqno; ++ atomic_unchecked_t seqno; + }; + + static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif) +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/rt2x00/rt2x00queue.c backports-4.2.6-1/drivers/net/wireless/rt2x00/rt2x00queue.c +--- backports-4.2.6-1.org/drivers/net/wireless/rt2x00/rt2x00queue.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/rt2x00/rt2x00queue.c 2016-01-27 12:26:21.293292990 +0100 +@@ -224,9 +224,9 @@ + * sequence counter given by mac80211. + */ + if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags)) +- seqno = atomic_add_return(0x10, &intf->seqno); ++ seqno = atomic_add_return_unchecked(0x10, &intf->seqno); + else +- seqno = atomic_read(&intf->seqno); ++ seqno = atomic_read_unchecked(&intf->seqno); + + hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG); + hdr->seq_ctrl |= cpu_to_le16(seqno); +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ti/wl1251/sdio.c backports-4.2.6-1/drivers/net/wireless/ti/wl1251/sdio.c +--- backports-4.2.6-1.org/drivers/net/wireless/ti/wl1251/sdio.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ti/wl1251/sdio.c 2016-01-27 12:26:21.293292990 +0100 +@@ -282,13 +282,17 @@ + + irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING); + +- wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq; +- wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq; ++ pax_open_kernel(); ++ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq; ++ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq; ++ pax_close_kernel(); + + wl1251_info("using dedicated interrupt line"); + } else { +- wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq; +- wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq; ++ pax_open_kernel(); ++ *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq; ++ *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq; ++ pax_close_kernel(); + + wl1251_info("using SDIO interrupt"); + } +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ti/wl12xx/main.c backports-4.2.6-1/drivers/net/wireless/ti/wl12xx/main.c +--- backports-4.2.6-1.org/drivers/net/wireless/ti/wl12xx/main.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ti/wl12xx/main.c 2016-01-27 12:26:21.293292990 +0100 +@@ -655,7 +655,9 @@ + sizeof(wl->conf.mem)); + + /* read data preparation is only needed by wl127x */ +- wl->ops->prepare_read = wl127x_prepare_read; ++ pax_open_kernel(); ++ *(void **)&wl->ops->prepare_read = wl127x_prepare_read; ++ pax_close_kernel(); + + wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, + WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER, +@@ -680,7 +682,9 @@ + sizeof(wl->conf.mem)); + + /* read data preparation is only needed by wl127x */ +- wl->ops->prepare_read = wl127x_prepare_read; ++ pax_open_kernel(); ++ *(void **)&wl->ops->prepare_read = wl127x_prepare_read; ++ pax_close_kernel(); + + wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER, + WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER, +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/ti/wl18xx/main.c backports-4.2.6-1/drivers/net/wireless/ti/wl18xx/main.c +--- backports-4.2.6-1.org/drivers/net/wireless/ti/wl18xx/main.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/ti/wl18xx/main.c 2016-01-27 12:26:21.293292990 +0100 +@@ -1952,8 +1952,10 @@ + } + + if (!checksum_param) { +- wl18xx_ops.set_rx_csum = NULL; +- wl18xx_ops.init_vif = NULL; ++ pax_open_kernel(); ++ *(void **)&wl18xx_ops.set_rx_csum = NULL; ++ *(void **)&wl18xx_ops.init_vif = NULL; ++ pax_close_kernel(); + } + + /* Enable 11a Band only if we have 5G antennas */ +diff -Naur backports-4.2.6-1.org/drivers/net/wireless/zd1211rw/zd_usb.c backports-4.2.6-1/drivers/net/wireless/zd1211rw/zd_usb.c +--- backports-4.2.6-1.org/drivers/net/wireless/zd1211rw/zd_usb.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/net/wireless/zd1211rw/zd_usb.c 2016-01-27 12:26:21.293292990 +0100 +@@ -385,7 +385,7 @@ + { + struct zd_usb *usb = urb->context; + struct zd_usb_interrupt *intr = &usb->intr; +- int len; ++ unsigned int len; + u16 int_num; + + ZD_ASSERT(in_interrupt()); +diff -Naur backports-4.2.6-1.org/drivers/nfc/nfcwilink.c backports-4.2.6-1/drivers/nfc/nfcwilink.c +--- backports-4.2.6-1.org/drivers/nfc/nfcwilink.c 2015-11-15 22:19:39.000000000 +0100 ++++ backports-4.2.6-1/drivers/nfc/nfcwilink.c 2016-01-27 12:26:21.293292990 +0100 +@@ -497,7 +497,7 @@ + + static int nfcwilink_probe(struct platform_device *pdev) + { +- static struct nfcwilink *drv; ++ struct nfcwilink *drv; + int rc; + __u32 protocols; + +diff -Naur backports-4.2.6-1.org/include/linux/gracl_compat.h backports-4.2.6-1/include/linux/gracl_compat.h +--- backports-4.2.6-1.org/include/linux/gracl_compat.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/gracl_compat.h 2016-01-27 12:26:26.289959354 +0100 +@@ -0,0 +1,156 @@ ++#ifndef GR_ACL_COMPAT_H ++#define GR_ACL_COMPAT_H ++ ++#include <linux/resource.h> ++#include <asm/resource.h> ++ ++struct sprole_pw_compat { ++ compat_uptr_t rolename; ++ unsigned char salt[GR_SALT_LEN]; ++ unsigned char sum[GR_SHA_LEN]; ++}; ++ ++struct gr_hash_struct_compat { ++ compat_uptr_t table; ++ compat_uptr_t nametable; ++ compat_uptr_t first; ++ __u32 table_size; ++ __u32 used_size; ++ int type; ++}; ++ ++struct acl_subject_label_compat { ++ compat_uptr_t filename; ++ compat_u64 inode; ++ __u32 device; ++ __u32 mode; ++ kernel_cap_t cap_mask; ++ kernel_cap_t cap_lower; ++ kernel_cap_t cap_invert_audit; ++ ++ struct compat_rlimit res[GR_NLIMITS]; ++ __u32 resmask; ++ ++ __u8 user_trans_type; ++ __u8 group_trans_type; ++ compat_uptr_t user_transitions; ++ compat_uptr_t group_transitions; ++ __u16 user_trans_num; ++ __u16 group_trans_num; ++ ++ __u32 sock_families[2]; ++ __u32 ip_proto[8]; ++ __u32 ip_type; ++ compat_uptr_t ips; ++ __u32 ip_num; ++ __u32 inaddr_any_override; ++ ++ __u32 crashes; ++ compat_ulong_t expires; ++ ++ compat_uptr_t parent_subject; ++ compat_uptr_t hash; ++ compat_uptr_t prev; ++ compat_uptr_t next; ++ ++ compat_uptr_t obj_hash; ++ __u32 obj_hash_size; ++ __u16 pax_flags; ++}; ++ ++struct role_allowed_ip_compat { ++ __u32 addr; ++ __u32 netmask; ++ ++ compat_uptr_t prev; ++ compat_uptr_t next; ++}; ++ ++struct role_transition_compat { ++ compat_uptr_t rolename; ++ ++ compat_uptr_t prev; ++ compat_uptr_t next; ++}; ++ ++struct acl_role_label_compat { ++ compat_uptr_t rolename; ++ uid_t uidgid; ++ __u16 roletype; ++ ++ __u16 auth_attempts; ++ compat_ulong_t expires; ++ ++ compat_uptr_t root_label; ++ compat_uptr_t hash; ++ ++ compat_uptr_t prev; ++ compat_uptr_t next; ++ ++ compat_uptr_t transitions; ++ compat_uptr_t allowed_ips; ++ compat_uptr_t domain_children; ++ __u16 domain_child_num; ++ ++ umode_t umask; ++ ++ compat_uptr_t subj_hash; ++ __u32 subj_hash_size; ++}; ++ ++struct user_acl_role_db_compat { ++ compat_uptr_t r_table; ++ __u32 num_pointers; ++ __u32 num_roles; ++ __u32 num_domain_children; ++ __u32 num_subjects; ++ __u32 num_objects; ++}; ++ ++struct acl_object_label_compat { ++ compat_uptr_t filename; ++ compat_u64 inode; ++ __u32 device; ++ __u32 mode; ++ ++ compat_uptr_t nested; ++ compat_uptr_t globbed; ++ ++ compat_uptr_t prev; ++ compat_uptr_t next; ++}; ++ ++struct acl_ip_label_compat { ++ compat_uptr_t iface; ++ __u32 addr; ++ __u32 netmask; ++ __u16 low, high; ++ __u8 mode; ++ __u32 type; ++ __u32 proto[8]; ++ ++ compat_uptr_t prev; ++ compat_uptr_t next; ++}; ++ ++struct gr_arg_compat { ++ struct user_acl_role_db_compat role_db; ++ unsigned char pw[GR_PW_LEN]; ++ unsigned char salt[GR_SALT_LEN]; ++ unsigned char sum[GR_SHA_LEN]; ++ unsigned char sp_role[GR_SPROLE_LEN]; ++ compat_uptr_t sprole_pws; ++ __u32 segv_device; ++ compat_u64 segv_inode; ++ uid_t segv_uid; ++ __u16 num_sprole_pws; ++ __u16 mode; ++}; ++ ++struct gr_arg_wrapper_compat { ++ compat_uptr_t arg; ++ __u32 version; ++ __u32 size; ++}; ++ ++#endif +diff -Naur backports-4.2.6-1.org/include/linux/gracl.h backports-4.2.6-1/include/linux/gracl.h +--- backports-4.2.6-1.org/include/linux/gracl.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/gracl.h 2016-01-27 12:26:26.289959354 +0100 +@@ -0,0 +1,342 @@ ++#ifndef GR_ACL_H ++#define GR_ACL_H ++ ++#include <linux/grdefs.h> ++#include <linux/resource.h> ++#include <linux/capability.h> ++#include <linux/dcache.h> ++#include <asm/resource.h> ++ ++/* Major status information */ ++ ++#define GR_VERSION "grsecurity 3.1" ++#define GRSECURITY_VERSION 0x3100 ++ ++enum { ++ GR_SHUTDOWN = 0, ++ GR_ENABLE = 1, ++ GR_SPROLE = 2, ++ GR_OLDRELOAD = 3, ++ GR_SEGVMOD = 4, ++ GR_STATUS = 5, ++ GR_UNSPROLE = 6, ++ GR_PASSSET = 7, ++ GR_SPROLEPAM = 8, ++ GR_RELOAD = 9, ++}; ++ ++/* Password setup definitions ++ * kernel/grhash.c */ ++enum { ++ GR_PW_LEN = 128, ++ GR_SALT_LEN = 16, ++ GR_SHA_LEN = 32, ++}; ++ ++enum { ++ GR_SPROLE_LEN = 64, ++}; ++ ++enum { ++ GR_NO_GLOB = 0, ++ GR_REG_GLOB, ++ GR_CREATE_GLOB ++}; ++ ++#define GR_NLIMITS 32 ++ ++/* Begin Data Structures */ ++ ++struct sprole_pw { ++ unsigned char *rolename; ++ unsigned char salt[GR_SALT_LEN]; ++ unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */ ++}; ++ ++struct name_entry { ++ __u32 key; ++ u64 inode; ++ dev_t device; ++ char *name; ++ __u16 len; ++ __u8 deleted; ++ struct name_entry *prev; ++ struct name_entry *next; ++}; ++ ++struct inodev_entry { ++ struct name_entry *nentry; ++ struct inodev_entry *prev; ++ struct inodev_entry *next; ++}; ++ ++struct acl_role_db { ++ struct acl_role_label **r_hash; ++ __u32 r_size; ++}; ++ ++struct inodev_db { ++ struct inodev_entry **i_hash; ++ __u32 i_size; ++}; ++ ++struct name_db { ++ struct name_entry **n_hash; ++ __u32 n_size; ++}; ++ ++struct crash_uid { ++ uid_t uid; ++ unsigned long expires; ++}; ++ ++struct gr_hash_struct { ++ void **table; ++ void **nametable; ++ void *first; ++ __u32 table_size; ++ __u32 used_size; ++ int type; ++}; ++ ++/* Userspace Grsecurity ACL data structures */ ++ ++struct acl_subject_label { ++ char *filename; ++ u64 inode; ++ dev_t device; ++ __u32 mode; ++ kernel_cap_t cap_mask; ++ kernel_cap_t cap_lower; ++ kernel_cap_t cap_invert_audit; ++ ++ struct rlimit res[GR_NLIMITS]; ++ __u32 resmask; ++ ++ __u8 user_trans_type; ++ __u8 group_trans_type; ++ uid_t *user_transitions; ++ gid_t *group_transitions; ++ __u16 user_trans_num; ++ __u16 group_trans_num; ++ ++ __u32 sock_families[2]; ++ __u32 ip_proto[8]; ++ __u32 ip_type; ++ struct acl_ip_label **ips; ++ __u32 ip_num; ++ __u32 inaddr_any_override; ++ ++ __u32 crashes; ++ unsigned long expires; ++ ++ struct acl_subject_label *parent_subject; ++ struct gr_hash_struct *hash; ++ struct acl_subject_label *prev; ++ struct acl_subject_label *next; ++ ++ struct acl_object_label **obj_hash; ++ __u32 obj_hash_size; ++ __u16 pax_flags; ++}; ++ ++struct role_allowed_ip { ++ __u32 addr; ++ __u32 netmask; ++ ++ struct role_allowed_ip *prev; ++ struct role_allowed_ip *next; ++}; ++ ++struct role_transition { ++ char *rolename; ++ ++ struct role_transition *prev; ++ struct role_transition *next; ++}; ++ ++struct acl_role_label { ++ char *rolename; ++ uid_t uidgid; ++ __u16 roletype; ++ ++ __u16 auth_attempts; ++ unsigned long expires; ++ ++ struct acl_subject_label *root_label; ++ struct gr_hash_struct *hash; ++ ++ struct acl_role_label *prev; ++ struct acl_role_label *next; ++ ++ struct role_transition *transitions; ++ struct role_allowed_ip *allowed_ips; ++ uid_t *domain_children; ++ __u16 domain_child_num; ++ ++ umode_t umask; ++ ++ struct acl_subject_label **subj_hash; ++ __u32 subj_hash_size; ++}; ++ ++struct user_acl_role_db { ++ struct acl_role_label **r_table; ++ __u32 num_pointers; /* Number of allocations to track */ ++ __u32 num_roles; /* Number of roles */ ++ __u32 num_domain_children; /* Number of domain children */ ++ __u32 num_subjects; /* Number of subjects */ ++ __u32 num_objects; /* Number of objects */ ++}; ++ ++struct acl_object_label { ++ char *filename; ++ u64 inode; ++ dev_t device; ++ __u32 mode; ++ ++ struct acl_subject_label *nested; ++ struct acl_object_label *globbed; ++ ++ /* next two structures not used */ ++ ++ struct acl_object_label *prev; ++ struct acl_object_label *next; ++}; ++ ++struct acl_ip_label { ++ char *iface; ++ __u32 addr; ++ __u32 netmask; ++ __u16 low, high; ++ __u8 mode; ++ __u32 type; ++ __u32 proto[8]; ++ ++ /* next two structures not used */ ++ ++ struct acl_ip_label *prev; ++ struct acl_ip_label *next; ++}; ++ ++struct gr_arg { ++ struct user_acl_role_db role_db; ++ unsigned char pw[GR_PW_LEN]; ++ unsigned char salt[GR_SALT_LEN]; ++ unsigned char sum[GR_SHA_LEN]; ++ unsigned char sp_role[GR_SPROLE_LEN]; ++ struct sprole_pw *sprole_pws; ++ dev_t segv_device; ++ u64 segv_inode; ++ uid_t segv_uid; ++ __u16 num_sprole_pws; ++ __u16 mode; ++}; ++ ++struct gr_arg_wrapper { ++ struct gr_arg *arg; ++ __u32 version; ++ __u32 size; ++}; ++ ++struct subject_map { ++ struct acl_subject_label *user; ++ struct acl_subject_label *kernel; ++ struct subject_map *prev; ++ struct subject_map *next; ++}; ++ ++struct acl_subj_map_db { ++ struct subject_map **s_hash; ++ __u32 s_size; ++}; ++ ++struct gr_policy_state { ++ struct sprole_pw **acl_special_roles; ++ __u16 num_sprole_pws; ++ struct acl_role_label *kernel_role; ++ struct acl_role_label *role_list; ++ struct acl_role_label *default_role; ++ struct acl_role_db acl_role_set; ++ struct acl_subj_map_db subj_map_set; ++ struct name_db name_set; ++ struct inodev_db inodev_set; ++}; ++ ++struct gr_alloc_state { ++ unsigned long alloc_stack_next; ++ unsigned long alloc_stack_size; ++ void **alloc_stack; ++}; ++ ++struct gr_reload_state { ++ struct gr_policy_state oldpolicy; ++ struct gr_alloc_state oldalloc; ++ struct gr_policy_state newpolicy; ++ struct gr_alloc_state newalloc; ++ struct gr_policy_state *oldpolicy_ptr; ++ struct gr_alloc_state *oldalloc_ptr; ++ unsigned char oldmode; ++}; ++ ++/* End Data Structures Section */ ++ ++/* Hash functions generated by empirical testing by Brad Spengler ++ Makes good use of the low bits of the inode. Generally 0-1 times ++ in loop for successful match. 0-3 for unsuccessful match. ++ Shift/add algorithm with modulus of table size and an XOR*/ ++ ++static __inline__ unsigned int ++gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz) ++{ ++ return ((((uid + type) << (16 + type)) ^ uid) % sz); ++} ++ ++ static __inline__ unsigned int ++gr_shash(const struct acl_subject_label *userp, const unsigned int sz) ++{ ++ return ((const unsigned long)userp % sz); ++} ++ ++static __inline__ unsigned int ++gr_fhash(const u64 ino, const dev_t dev, const unsigned int sz) ++{ ++ unsigned int rem; ++ div_u64_rem((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9)), sz, &rem); ++ return rem; ++} ++ ++static __inline__ unsigned int ++gr_nhash(const char *name, const __u16 len, const unsigned int sz) ++{ ++ return full_name_hash((const unsigned char *)name, len) % sz; ++} ++ ++#define FOR_EACH_SUBJECT_START(role,subj,iter) \ ++ subj = NULL; \ ++ iter = 0; \ ++ while (iter < role->subj_hash_size) { \ ++ if (subj == NULL) \ ++ subj = role->subj_hash[iter]; \ ++ if (subj == NULL) { \ ++ iter++; \ ++ continue; \ ++ } ++ ++#define FOR_EACH_SUBJECT_END(subj,iter) \ ++ subj = subj->next; \ ++ if (subj == NULL) \ ++ iter++; \ ++ } ++ ++ ++#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \ ++ subj = role->hash->first; \ ++ while (subj != NULL) { ++ ++#define FOR_EACH_NESTED_SUBJECT_END(subj) \ ++ subj = subj->next; \ ++ } ++ ++#endif ++ +diff -Naur backports-4.2.6-1.org/include/linux/gralloc.h backports-4.2.6-1/include/linux/gralloc.h +--- backports-4.2.6-1.org/include/linux/gralloc.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/gralloc.h 2016-01-27 12:26:26.289959354 +0100 +@@ -0,0 +1,9 @@ ++#ifndef __GRALLOC_H ++#define __GRALLOC_H ++ ++void acl_free_all(void); ++int acl_alloc_stack_init(unsigned long size); ++void *acl_alloc(unsigned long len); ++void *acl_alloc_num(unsigned long num, unsigned long len); ++ ++#endif +diff -Naur backports-4.2.6-1.org/include/linux/grdefs.h backports-4.2.6-1/include/linux/grdefs.h +--- backports-4.2.6-1.org/include/linux/grdefs.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/grdefs.h 2016-01-27 12:26:26.289959354 +0100 +@@ -0,0 +1,140 @@ ++#ifndef GRDEFS_H ++#define GRDEFS_H ++ ++/* Begin grsecurity status declarations */ ++ ++enum { ++ GR_READY = 0x01, ++ GR_STATUS_INIT = 0x00 // disabled state ++}; ++ ++/* Begin ACL declarations */ ++ ++/* Role flags */ ++ ++enum { ++ GR_ROLE_USER = 0x0001, ++ GR_ROLE_GROUP = 0x0002, ++ GR_ROLE_DEFAULT = 0x0004, ++ GR_ROLE_SPECIAL = 0x0008, ++ GR_ROLE_AUTH = 0x0010, ++ GR_ROLE_NOPW = 0x0020, ++ GR_ROLE_GOD = 0x0040, ++ GR_ROLE_LEARN = 0x0080, ++ GR_ROLE_TPE = 0x0100, ++ GR_ROLE_DOMAIN = 0x0200, ++ GR_ROLE_PAM = 0x0400, ++ GR_ROLE_PERSIST = 0x0800 ++}; ++ ++/* ACL Subject and Object mode flags */ ++enum { ++ GR_DELETED = 0x80000000 ++}; ++ ++/* ACL Object-only mode flags */ ++enum { ++ GR_READ = 0x00000001, ++ GR_APPEND = 0x00000002, ++ GR_WRITE = 0x00000004, ++ GR_EXEC = 0x00000008, ++ GR_FIND = 0x00000010, ++ GR_INHERIT = 0x00000020, ++ GR_SETID = 0x00000040, ++ GR_CREATE = 0x00000080, ++ GR_DELETE = 0x00000100, ++ GR_LINK = 0x00000200, ++ GR_AUDIT_READ = 0x00000400, ++ GR_AUDIT_APPEND = 0x00000800, ++ GR_AUDIT_WRITE = 0x00001000, ++ GR_AUDIT_EXEC = 0x00002000, ++ GR_AUDIT_FIND = 0x00004000, ++ GR_AUDIT_INHERIT= 0x00008000, ++ GR_AUDIT_SETID = 0x00010000, ++ GR_AUDIT_CREATE = 0x00020000, ++ GR_AUDIT_DELETE = 0x00040000, ++ GR_AUDIT_LINK = 0x00080000, ++ GR_PTRACERD = 0x00100000, ++ GR_NOPTRACE = 0x00200000, ++ GR_SUPPRESS = 0x00400000, ++ GR_NOLEARN = 0x00800000, ++ GR_INIT_TRANSFER= 0x01000000 ++}; ++ ++#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \ ++ GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \ ++ GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK) ++ ++/* ACL subject-only mode flags */ ++enum { ++ GR_KILL = 0x00000001, ++ GR_VIEW = 0x00000002, ++ GR_PROTECTED = 0x00000004, ++ GR_LEARN = 0x00000008, ++ GR_OVERRIDE = 0x00000010, ++ /* just a placeholder, this mode is only used in userspace */ ++ GR_DUMMY = 0x00000020, ++ GR_PROTSHM = 0x00000040, ++ GR_KILLPROC = 0x00000080, ++ GR_KILLIPPROC = 0x00000100, ++ /* just a placeholder, this mode is only used in userspace */ ++ GR_NOTROJAN = 0x00000200, ++ GR_PROTPROCFD = 0x00000400, ++ GR_PROCACCT = 0x00000800, ++ GR_RELAXPTRACE = 0x00001000, ++ //GR_NESTED = 0x00002000, ++ GR_INHERITLEARN = 0x00004000, ++ GR_PROCFIND = 0x00008000, ++ GR_POVERRIDE = 0x00010000, ++ GR_KERNELAUTH = 0x00020000, ++ GR_ATSECURE = 0x00040000, ++ GR_SHMEXEC = 0x00080000 ++}; ++ ++enum { ++ GR_PAX_ENABLE_SEGMEXEC = 0x0001, ++ GR_PAX_ENABLE_PAGEEXEC = 0x0002, ++ GR_PAX_ENABLE_MPROTECT = 0x0004, ++ GR_PAX_ENABLE_RANDMMAP = 0x0008, ++ GR_PAX_ENABLE_EMUTRAMP = 0x0010, ++ GR_PAX_DISABLE_SEGMEXEC = 0x0100, ++ GR_PAX_DISABLE_PAGEEXEC = 0x0200, ++ GR_PAX_DISABLE_MPROTECT = 0x0400, ++ GR_PAX_DISABLE_RANDMMAP = 0x0800, ++ GR_PAX_DISABLE_EMUTRAMP = 0x1000, ++}; ++ ++enum { ++ GR_ID_USER = 0x01, ++ GR_ID_GROUP = 0x02, ++}; ++ ++enum { ++ GR_ID_ALLOW = 0x01, ++ GR_ID_DENY = 0x02, ++}; ++ ++#define GR_CRASH_RES 31 ++#define GR_UIDTABLE_MAX 500 ++ ++/* begin resource learning section */ ++enum { ++ GR_RLIM_CPU_BUMP = 60, ++ GR_RLIM_FSIZE_BUMP = 50000, ++ GR_RLIM_DATA_BUMP = 10000, ++ GR_RLIM_STACK_BUMP = 1000, ++ GR_RLIM_CORE_BUMP = 10000, ++ GR_RLIM_RSS_BUMP = 500000, ++ GR_RLIM_NPROC_BUMP = 1, ++ GR_RLIM_NOFILE_BUMP = 5, ++ GR_RLIM_MEMLOCK_BUMP = 50000, ++ GR_RLIM_AS_BUMP = 500000, ++ GR_RLIM_LOCKS_BUMP = 2, ++ GR_RLIM_SIGPENDING_BUMP = 5, ++ GR_RLIM_MSGQUEUE_BUMP = 10000, ++ GR_RLIM_NICE_BUMP = 1, ++ GR_RLIM_RTPRIO_BUMP = 1, ++ GR_RLIM_RTTIME_BUMP = 1000000 ++}; ++ ++#endif +diff -Naur backports-4.2.6-1.org/include/linux/grinternal.h backports-4.2.6-1/include/linux/grinternal.h +--- backports-4.2.6-1.org/include/linux/grinternal.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/grinternal.h 2016-01-27 12:26:26.289959354 +0100 +@@ -0,0 +1,230 @@ ++#ifndef __GRINTERNAL_H ++#define __GRINTERNAL_H ++ ++#ifdef CONFIG_GRKERNSEC ++ ++#include <linux/fs.h> ++#include <linux/mnt_namespace.h> ++#include <linux/nsproxy.h> ++#include <linux/gracl.h> ++#include <linux/grdefs.h> ++#include <linux/grmsg.h> ++ ++void gr_add_learn_entry(const char *fmt, ...) ++ __attribute__ ((format (printf, 1, 2))); ++__u32 gr_search_file(const struct dentry *dentry, const __u32 mode, ++ const struct vfsmount *mnt); ++__u32 gr_check_create(const struct dentry *new_dentry, ++ const struct dentry *parent, ++ const struct vfsmount *mnt, const __u32 mode); ++int gr_check_protected_task(const struct task_struct *task); ++__u32 to_gr_audit(const __u32 reqmode); ++int gr_set_acls(const int type); ++int gr_acl_is_enabled(void); ++char gr_roletype_to_char(void); ++ ++void gr_handle_alertkill(struct task_struct *task); ++char *gr_to_filename(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++char *gr_to_filename1(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++char *gr_to_filename2(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++char *gr_to_filename3(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++ ++extern int grsec_enable_ptrace_readexec; ++extern int grsec_enable_harden_ptrace; ++extern int grsec_enable_link; ++extern int grsec_enable_fifo; ++extern int grsec_enable_execve; ++extern int grsec_enable_shm; ++extern int grsec_enable_execlog; ++extern int grsec_enable_signal; ++extern int grsec_enable_audit_ptrace; ++extern int grsec_enable_forkfail; ++extern int grsec_enable_time; ++extern int grsec_enable_rofs; ++extern int grsec_deny_new_usb; ++extern int grsec_enable_chroot_shmat; ++extern int grsec_enable_chroot_mount; ++extern int grsec_enable_chroot_double; ++extern int grsec_enable_chroot_pivot; ++extern int grsec_enable_chroot_chdir; ++extern int grsec_enable_chroot_chmod; ++extern int grsec_enable_chroot_mknod; ++extern int grsec_enable_chroot_fchdir; ++extern int grsec_enable_chroot_nice; ++extern int grsec_enable_chroot_execlog; ++extern int grsec_enable_chroot_caps; ++extern int grsec_enable_chroot_rename; ++extern int grsec_enable_chroot_sysctl; ++extern int grsec_enable_chroot_unix; ++extern int grsec_enable_symlinkown; ++extern kgid_t grsec_symlinkown_gid; ++extern int grsec_enable_tpe; ++extern kgid_t grsec_tpe_gid; ++extern int grsec_enable_tpe_all; ++extern int grsec_enable_tpe_invert; ++extern int grsec_enable_socket_all; ++extern kgid_t grsec_socket_all_gid; ++extern int grsec_enable_socket_client; ++extern kgid_t grsec_socket_client_gid; ++extern int grsec_enable_socket_server; ++extern kgid_t grsec_socket_server_gid; ++extern kgid_t grsec_audit_gid; ++extern int grsec_enable_group; ++extern int grsec_enable_log_rwxmaps; ++extern int grsec_enable_mount; ++extern int grsec_enable_chdir; ++extern int grsec_resource_logging; ++extern int grsec_enable_blackhole; ++extern int grsec_lastack_retries; ++extern int grsec_enable_brute; ++extern int grsec_enable_harden_ipc; ++extern int grsec_lock; ++ ++extern spinlock_t grsec_alert_lock; ++extern unsigned long grsec_alert_wtime; ++extern unsigned long grsec_alert_fyet; ++ ++extern spinlock_t grsec_audit_lock; ++ ++extern rwlock_t grsec_exec_file_lock; ++ ++#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \ ++ gr_to_filename2((tsk)->exec_file->f_path.dentry, \ ++ (tsk)->exec_file->f_path.mnt) : "/") ++ ++#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \ ++ gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \ ++ (tsk)->real_parent->exec_file->f_path.mnt) : "/") ++ ++#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \ ++ gr_to_filename((tsk)->exec_file->f_path.dentry, \ ++ (tsk)->exec_file->f_path.mnt) : "/") ++ ++#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \ ++ gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \ ++ (tsk)->real_parent->exec_file->f_path.mnt) : "/") ++ ++#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted) ++ ++#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry) ++ ++static inline bool gr_is_same_file(const struct file *file1, const struct file *file2) ++{ ++ if (file1 && file2) { ++ const struct inode *inode1 = file1->f_path.dentry->d_inode; ++ const struct inode *inode2 = file2->f_path.dentry->d_inode; ++ if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev) ++ return true; ++ } ++ ++ return false; ++} ++ ++#define GR_CHROOT_CAPS {{ \ ++ CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \ ++ CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \ ++ CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \ ++ CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \ ++ CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \ ++ CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \ ++ CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }} ++ ++#define security_learn(normal_msg,args...) \ ++({ \ ++ read_lock(&grsec_exec_file_lock); \ ++ gr_add_learn_entry(normal_msg "\n", ## args); \ ++ read_unlock(&grsec_exec_file_lock); \ ++}) ++ ++enum { ++ GR_DO_AUDIT, ++ GR_DONT_AUDIT, ++ /* used for non-audit messages that we shouldn't kill the task on */ ++ GR_DONT_AUDIT_GOOD ++}; ++ ++enum { ++ GR_TTYSNIFF, ++ GR_RBAC, ++ GR_RBAC_STR, ++ GR_STR_RBAC, ++ GR_RBAC_MODE2, ++ GR_RBAC_MODE3, ++ GR_FILENAME, ++ GR_SYSCTL_HIDDEN, ++ GR_NOARGS, ++ GR_ONE_INT, ++ GR_ONE_INT_TWO_STR, ++ GR_ONE_STR, ++ GR_STR_INT, ++ GR_TWO_STR_INT, ++ GR_TWO_INT, ++ GR_TWO_U64, ++ GR_THREE_INT, ++ GR_FIVE_INT_TWO_STR, ++ GR_TWO_STR, ++ GR_THREE_STR, ++ GR_FOUR_STR, ++ GR_STR_FILENAME, ++ GR_FILENAME_STR, ++ GR_FILENAME_TWO_INT, ++ GR_FILENAME_TWO_INT_STR, ++ GR_TEXTREL, ++ GR_PTRACE, ++ GR_RESOURCE, ++ GR_CAP, ++ GR_SIG, ++ GR_SIG2, ++ GR_CRASH1, ++ GR_CRASH2, ++ GR_PSACCT, ++ GR_RWXMAP, ++ GR_RWXMAPVMA ++}; ++ ++#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str) ++#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task) ++#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt) ++#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str) ++#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt) ++#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2) ++#define gr_log_fs_rbac_mode3(audit, msg, dentry, mnt, str1, str2, str3) gr_log_varargs(audit, msg, GR_RBAC_MODE3, dentry, mnt, str1, str2, str3) ++#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt) ++#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS) ++#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num) ++#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2) ++#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str) ++#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num) ++#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2) ++#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2) ++#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3) ++#define gr_log_int5_str2(audit, msg, num1, num2, str1, str2) gr_log_varargs(audit, msg, GR_FIVE_INT_TWO_STR, num1, num2, str1, str2) ++#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2) ++#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num) ++#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3) ++#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4) ++#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt) ++#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str) ++#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2) ++#define gr_log_fs_int2_str(audit, msg, dentry, mnt, num1, num2, str) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT_STR, dentry, mnt, num1, num2, str) ++#define gr_log_textrel_ulong_ulong(audit, msg, str, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, str, file, ulong1, ulong2) ++#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task) ++#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2) ++#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str) ++#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr) ++#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num) ++#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong) ++#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1) ++#define gr_log_procacct(audit, msg, task, num1, num2, num3, num4, num5, num6, num7, num8, num9) gr_log_varargs(audit, msg, GR_PSACCT, task, num1, num2, num3, num4, num5, num6, num7, num8, num9) ++#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str) ++#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str) ++ ++void gr_log_varargs(int audit, const char *msg, int argtypes, ...); ++ ++#endif ++ ++#endif +diff -Naur backports-4.2.6-1.org/include/linux/grmsg.h backports-4.2.6-1/include/linux/grmsg.h +--- backports-4.2.6-1.org/include/linux/grmsg.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/grmsg.h 2016-01-27 12:26:26.289959354 +0100 +@@ -0,0 +1,118 @@ ++#define DEFAULTSECMSG "%.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u, parent %.256s[%.16s:%d] uid/euid:%u/%u gid/egid:%u/%u" ++#define GR_ACL_PROCACCT_MSG "%.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u run time:[%ud %uh %um %us] cpu time:[%ud %uh %um %us] %s with exit code %ld, parent %.256s[%.16s:%d] IP:%pI4 TTY:%.64s uid/euid:%u/%u gid/egid:%u/%u" ++#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by " ++#define GR_STOPMOD_MSG "denied modification of module state by " ++#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by " ++#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by " ++#define GR_IOPERM_MSG "denied use of ioperm() by " ++#define GR_IOPL_MSG "denied use of iopl() by " ++#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by " ++#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by " ++#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by " ++#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by " ++#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by " ++#define GR_LEARN_AUDIT_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%lu\t%lu\t%.4095s\t%lu\t%pI4" ++#define GR_ID_LEARN_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%c\t%d\t%d\t%d\t%pI4" ++#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by " ++#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by " ++#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by " ++#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by " ++#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by " ++#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by " ++#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by " ++#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against " ++#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by " ++#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by " ++#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by " ++#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by " ++#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for " ++#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by " ++#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by " ++#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by " ++#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by " ++#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by " ++#define GR_EXEC_ACL_MSG "%s execution of %.950s by " ++#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by " ++#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds" ++#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds" ++#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by " ++#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by " ++#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by " ++#define GR_ATIME_ACL_MSG "%s access time change of %.950s by " ++#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by " ++#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by " ++#define GR_CHROOT_RENAME_MSG "denied bad rename of %.950s out of a chroot by " ++#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by " ++#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by " ++#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by " ++#define GR_CHROOT_FHANDLE_MSG "denied use of file handles inside chroot by " ++#define GR_CHOWN_ACL_MSG "%s chown of %.950s by " ++#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by " ++#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by " ++#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by " ++#define GR_INITF_ACL_MSG "init_variables() failed %s by " ++#define GR_DISABLED_ACL_MSG "Error loading %s, trying to run kernel with acls disabled. To disable acls at startup use <kernel image name> gracl=off from your boot loader" ++#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by " ++#define GR_SHUTS_ACL_MSG "shutdown auth success for " ++#define GR_SHUTF_ACL_MSG "shutdown auth failure for " ++#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for " ++#define GR_SEGVMODS_ACL_MSG "segvmod auth success for " ++#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for " ++#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for " ++#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by " ++#define GR_ENABLEF_ACL_MSG "unable to load %s for " ++#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system" ++#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by " ++#define GR_RELOADF_ACL_MSG "failed reload of %s for " ++#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for " ++#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by " ++#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by " ++#define GR_SPROLEF_ACL_MSG "special role %s failure for " ++#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for " ++#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by " ++#define GR_INVMODE_ACL_MSG "invalid mode %d by " ++#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by " ++#define GR_FAILFORK_MSG "failed fork with errno %s by " ++#define GR_NICE_CHROOT_MSG "denied priority change by " ++#define GR_UNISIGLOG_MSG "%.32s occurred at %p in " ++#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by " ++#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by " ++#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by " ++#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by " ++#define GR_TIME_MSG "time set by " ++#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by " ++#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by " ++#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by " ++#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by " ++#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by " ++#define GR_BIND_MSG "denied bind() by " ++#define GR_CONNECT_MSG "denied connect() by " ++#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by " ++#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by " ++#define GR_IP_LEARN_MSG "%s\t%u\t%u\t%u\t%.4095s\t%.4095s\t%pI4\t%u\t%u\t%u\t%u\t%pI4" ++#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process " ++#define GR_CAP_ACL_MSG "use of %s denied for " ++#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for " ++#define GR_CAP_ACL_MSG2 "use of %s permitted for " ++#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for " ++#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for " ++#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by " ++#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by " ++#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by " ++#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by " ++#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by " ++#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for " ++#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by " ++#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by " ++#define GR_TEXTREL_AUDIT_MSG "allowed %s text relocation transition in %.950s, VMA:0x%08lx 0x%08lx by " ++#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by " ++#define GR_VM86_MSG "denied use of vm86 by " ++#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by " ++#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by " ++#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by " ++#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by " ++#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by " ++#define GR_BRUTE_DAEMON_MSG "bruteforce prevention initiated for the next 30 minutes or until service restarted, stalling each fork 30 seconds. Please investigate the crash report for " ++#define GR_BRUTE_SUID_MSG "bruteforce prevention initiated due to crash of %.950s against uid %u, banning suid/sgid execs for %u minutes. Please investigate the crash report for " ++#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by " ++#define GR_MSRWRITE_MSG "denied write to CPU MSR by " +diff -Naur backports-4.2.6-1.org/include/linux/grsecurity.h backports-4.2.6-1/include/linux/grsecurity.h +--- backports-4.2.6-1.org/include/linux/grsecurity.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/grsecurity.h 2016-01-27 12:26:26.289959354 +0100 +@@ -0,0 +1,255 @@ ++#ifndef GR_SECURITY_H ++#define GR_SECURITY_H ++#include <linux/fs.h> ++#include <linux/fs_struct.h> ++#include <linux/binfmts.h> ++#include <linux/gracl.h> ++ ++/* notify of brain-dead configs */ ++#if defined(CONFIG_DEBUG_FS) && defined(CONFIG_GRKERNSEC_KMEM) ++#error "CONFIG_DEBUG_FS being enabled is a security risk when CONFIG_GRKERNSEC_KMEM is enabled" ++#endif ++#if defined(CONFIG_PROC_PAGE_MONITOR) && defined(CONFIG_GRKERNSEC) ++#error "CONFIG_PROC_PAGE_MONITOR is a security risk" ++#endif ++#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP) ++#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled." ++#endif ++#if defined(CONFIG_GRKERNSEC_PROC) && !defined(CONFIG_GRKERNSEC_PROC_USER) && !defined(CONFIG_GRKERNSEC_PROC_USERGROUP) ++#error "CONFIG_GRKERNSEC_PROC enabled, but neither CONFIG_GRKERNSEC_PROC_USER nor CONFIG_GRKERNSEC_PROC_USERGROUP enabled" ++#endif ++#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC) ++#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled." ++#endif ++#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP) ++#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled." ++#endif ++#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR) ++#error "CONFIG_PAX enabled, but no PaX options are enabled." ++#endif ++ ++int gr_handle_new_usb(void); ++ ++void gr_handle_brute_attach(int dumpable); ++void gr_handle_brute_check(void); ++void gr_handle_kernel_exploit(void); ++ ++char gr_roletype_to_char(void); ++ ++int gr_proc_is_restricted(void); ++ ++int gr_acl_enable_at_secure(void); ++ ++int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs); ++int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs); ++ ++int gr_learn_cap(const struct task_struct *task, const struct cred *cred, const int cap); ++ ++void gr_del_task_from_ip_table(struct task_struct *p); ++ ++int gr_pid_is_chrooted(struct task_struct *p); ++int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type); ++int gr_handle_chroot_nice(void); ++int gr_handle_chroot_sysctl(const int op); ++int gr_handle_chroot_setpriority(struct task_struct *p, ++ const int niceval); ++int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt); ++int gr_chroot_fhandle(void); ++int gr_handle_chroot_chroot(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++void gr_handle_chroot_chdir(const struct path *path); ++int gr_handle_chroot_chmod(const struct dentry *dentry, ++ const struct vfsmount *mnt, const int mode); ++int gr_handle_chroot_mknod(const struct dentry *dentry, ++ const struct vfsmount *mnt, const int mode); ++int gr_handle_chroot_mount(const struct dentry *dentry, ++ const struct vfsmount *mnt, ++ const char *dev_name); ++int gr_handle_chroot_pivot(void); ++int gr_handle_chroot_unix(const pid_t pid); ++ ++int gr_handle_rawio(const struct inode *inode); ++ ++void gr_handle_ioperm(void); ++void gr_handle_iopl(void); ++void gr_handle_msr_write(void); ++ ++umode_t gr_acl_umask(void); ++ ++int gr_tpe_allow(const struct file *file); ++ ++void gr_set_chroot_entries(struct task_struct *task, const struct path *path); ++void gr_clear_chroot_entries(struct task_struct *task); ++ ++void gr_log_forkfail(const int retval); ++void gr_log_timechange(void); ++void gr_log_signal(const int sig, const void *addr, const struct task_struct *t); ++void gr_log_chdir(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++void gr_log_chroot_exec(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++void gr_log_remount(const char *devname, const int retval); ++void gr_log_unmount(const char *devname, const int retval); ++void gr_log_mount(const char *from, struct path *to, const int retval); ++void gr_log_textrel(struct vm_area_struct *vma, bool is_textrel_rw); ++void gr_log_ptgnustack(struct file *file); ++void gr_log_rwxmmap(struct file *file); ++void gr_log_rwxmprotect(struct vm_area_struct *vma); ++ ++int gr_handle_follow_link(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++int gr_handle_fifo(const struct dentry *dentry, ++ const struct vfsmount *mnt, ++ const struct dentry *dir, const int flag, ++ const int acc_mode); ++int gr_handle_hardlink(const struct dentry *dentry, ++ const struct vfsmount *mnt, ++ const struct filename *to); ++ ++int gr_is_capable(const int cap); ++int gr_is_capable_nolog(const int cap); ++int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap); ++int gr_task_is_capable_nolog(const struct task_struct *task, const int cap); ++ ++void gr_copy_label(struct task_struct *tsk); ++void gr_handle_crash(struct task_struct *task, const int sig); ++int gr_handle_signal(const struct task_struct *p, const int sig); ++int gr_check_crash_uid(const kuid_t uid); ++int gr_check_protected_task(const struct task_struct *task); ++int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type); ++int gr_acl_handle_mmap(const struct file *file, ++ const unsigned long prot); ++int gr_acl_handle_mprotect(const struct file *file, ++ const unsigned long prot); ++int gr_check_hidden_task(const struct task_struct *tsk); ++__u32 gr_acl_handle_truncate(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++__u32 gr_acl_handle_utime(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++__u32 gr_acl_handle_access(const struct dentry *dentry, ++ const struct vfsmount *mnt, const int fmode); ++__u32 gr_acl_handle_chmod(const struct dentry *dentry, ++ const struct vfsmount *mnt, umode_t *mode); ++__u32 gr_acl_handle_chown(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++__u32 gr_acl_handle_setxattr(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++__u32 gr_acl_handle_removexattr(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++int gr_handle_ptrace(struct task_struct *task, const long request); ++int gr_handle_proc_ptrace(struct task_struct *task); ++__u32 gr_acl_handle_execve(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++int gr_check_crash_exec(const struct file *filp); ++int gr_acl_is_enabled(void); ++void gr_set_role_label(struct task_struct *task, const kuid_t uid, ++ const kgid_t gid); ++int gr_set_proc_label(const struct dentry *dentry, ++ const struct vfsmount *mnt, ++ const int unsafe_flags); ++__u32 gr_acl_handle_hidden_file(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++__u32 gr_acl_handle_open(const struct dentry *dentry, ++ const struct vfsmount *mnt, int acc_mode); ++__u32 gr_acl_handle_creat(const struct dentry *dentry, ++ const struct dentry *p_dentry, ++ const struct vfsmount *p_mnt, ++ int open_flags, int acc_mode, const int imode); ++void gr_handle_create(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++void gr_handle_proc_create(const struct dentry *dentry, ++ const struct inode *inode); ++__u32 gr_acl_handle_mknod(const struct dentry *new_dentry, ++ const struct dentry *parent_dentry, ++ const struct vfsmount *parent_mnt, ++ const int mode); ++__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry, ++ const struct dentry *parent_dentry, ++ const struct vfsmount *parent_mnt); ++__u32 gr_acl_handle_rmdir(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++void gr_handle_delete(const u64 ino, const dev_t dev); ++__u32 gr_acl_handle_unlink(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++__u32 gr_acl_handle_symlink(const struct dentry *new_dentry, ++ const struct dentry *parent_dentry, ++ const struct vfsmount *parent_mnt, ++ const struct filename *from); ++__u32 gr_acl_handle_link(const struct dentry *new_dentry, ++ const struct dentry *parent_dentry, ++ const struct vfsmount *parent_mnt, ++ const struct dentry *old_dentry, ++ const struct vfsmount *old_mnt, const struct filename *to); ++int gr_handle_symlink_owner(const struct path *link, const struct inode *target); ++int gr_acl_handle_rename(struct dentry *new_dentry, ++ struct dentry *parent_dentry, ++ const struct vfsmount *parent_mnt, ++ struct dentry *old_dentry, ++ struct inode *old_parent_inode, ++ struct vfsmount *old_mnt, const struct filename *newname, unsigned int flags); ++void gr_handle_rename(struct inode *old_dir, struct inode *new_dir, ++ struct dentry *old_dentry, ++ struct dentry *new_dentry, ++ struct vfsmount *mnt, const __u8 replace, unsigned int flags); ++__u32 gr_check_link(const struct dentry *new_dentry, ++ const struct dentry *parent_dentry, ++ const struct vfsmount *parent_mnt, ++ const struct dentry *old_dentry, ++ const struct vfsmount *old_mnt); ++int gr_acl_handle_filldir(const struct file *file, const char *name, ++ const unsigned int namelen, const u64 ino); ++ ++__u32 gr_acl_handle_unix(const struct dentry *dentry, ++ const struct vfsmount *mnt); ++void gr_acl_handle_exit(void); ++void gr_acl_handle_psacct(struct task_struct *task, const long code); ++int gr_acl_handle_procpidmem(const struct task_struct *task); ++int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags); ++int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode); ++void gr_audit_ptrace(struct task_struct *task); ++dev_t gr_get_dev_from_dentry(struct dentry *dentry); ++u64 gr_get_ino_from_dentry(struct dentry *dentry); ++void gr_put_exec_file(struct task_struct *task); ++ ++int gr_get_symlinkown_enabled(void); ++ ++int gr_ptrace_readexec(struct file *file, int unsafe_flags); ++ ++void gr_inc_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt); ++void gr_dec_chroot_refcnts(struct dentry *dentry, struct vfsmount *mnt); ++int gr_bad_chroot_rename(struct dentry *olddentry, struct vfsmount *oldmnt, ++ struct dentry *newdentry, struct vfsmount *newmnt); ++ ++#ifdef CONFIG_GRKERNSEC_RESLOG ++extern void gr_log_resource(const struct task_struct *task, const int res, ++ const unsigned long wanted, const int gt); ++#else ++static inline void gr_log_resource(const struct task_struct *task, const int res, ++ const unsigned long wanted, const int gt) ++{ ++} ++#endif ++ ++#ifdef CONFIG_GRKERNSEC ++void task_grsec_rbac(struct seq_file *m, struct task_struct *p); ++void gr_handle_vm86(void); ++void gr_handle_mem_readwrite(u64 from, u64 to); ++ ++void gr_log_badprocpid(const char *entry); ++ ++extern int grsec_enable_dmesg; ++extern int grsec_disable_privio; ++ ++#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP ++extern kgid_t grsec_proc_gid; ++#endif ++ ++#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK ++extern int grsec_enable_chroot_findtask; ++#endif ++#ifdef CONFIG_GRKERNSEC_SETXID ++extern int grsec_enable_setxid; ++#endif ++#endif ++ ++#endif +diff -Naur backports-4.2.6-1.org/include/linux/grsock.h backports-4.2.6-1/include/linux/grsock.h +--- backports-4.2.6-1.org/include/linux/grsock.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/grsock.h 2016-01-27 12:26:26.289959354 +0100 +@@ -0,0 +1,19 @@ ++#ifndef __GRSOCK_H ++#define __GRSOCK_H ++ ++extern void gr_attach_curr_ip(const struct sock *sk); ++extern int gr_handle_sock_all(const int family, const int type, ++ const int protocol); ++extern int gr_handle_sock_server(const struct sockaddr *sck); ++extern int gr_handle_sock_server_other(const struct sock *sck); ++extern int gr_handle_sock_client(const struct sockaddr *sck); ++extern int gr_search_connect(struct socket * sock, ++ struct sockaddr_in * addr); ++extern int gr_search_bind(struct socket * sock, ++ struct sockaddr_in * addr); ++extern int gr_search_listen(struct socket * sock); ++extern int gr_search_accept(struct socket * sock); ++extern int gr_search_socket(const int domain, const int type, ++ const int protocol); ++ ++#endif +diff -Naur backports-4.2.6-1.org/include/linux/netfilter/xt_gradm.h backports-4.2.6-1/include/linux/netfilter/xt_gradm.h +--- backports-4.2.6-1.org/include/linux/netfilter/xt_gradm.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/linux/netfilter/xt_gradm.h 2016-01-27 12:26:31.209959056 +0100 +@@ -0,0 +1,9 @@ ++#ifndef _LINUX_NETFILTER_XT_GRADM_H ++#define _LINUX_NETFILTER_XT_GRADM_H 1 ++ ++struct xt_gradm_mtinfo { ++ __u16 flags; ++ __u16 invflags; ++}; ++ ++#endif +diff -Naur backports-4.2.6-1.org/include/linux/unaligned/access_ok.h backports-4.2.6-1/include/linux/unaligned/access_ok.h +--- backports-4.2.6-1.org/include/linux/unaligned/access_ok.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/include/linux/unaligned/access_ok.h 2016-01-27 12:26:31.219959057 +0100 +@@ -4,34 +4,34 @@ + #include <linux/kernel.h> + #include <asm/byteorder.h> + +-static inline u16 get_unaligned_le16(const void *p) ++static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p) + { +- return le16_to_cpup((__le16 *)p); ++ return le16_to_cpup((const __le16 *)p); + } + +-static inline u32 get_unaligned_le32(const void *p) ++static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p) + { +- return le32_to_cpup((__le32 *)p); ++ return le32_to_cpup((const __le32 *)p); + } + +-static inline u64 get_unaligned_le64(const void *p) ++static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p) + { +- return le64_to_cpup((__le64 *)p); ++ return le64_to_cpup((const __le64 *)p); + } + +-static inline u16 get_unaligned_be16(const void *p) ++static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p) + { +- return be16_to_cpup((__be16 *)p); ++ return be16_to_cpup((const __be16 *)p); + } + +-static inline u32 get_unaligned_be32(const void *p) ++static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p) + { +- return be32_to_cpup((__be32 *)p); ++ return be32_to_cpup((const __be32 *)p); + } + +-static inline u64 get_unaligned_be64(const void *p) ++static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p) + { +- return be64_to_cpup((__be64 *)p); ++ return be64_to_cpup((const __be64 *)p); + } + + static inline void put_unaligned_le16(u16 val, void *p) +diff -Naur backports-4.2.6-1.org/include/media/v4l2-dev.h backports-4.2.6-1/include/media/v4l2-dev.h +--- backports-4.2.6-1.org/include/media/v4l2-dev.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/include/media/v4l2-dev.h 2016-01-27 12:26:31.219959057 +0100 +@@ -74,7 +74,7 @@ + int (*mmap) (struct file *, struct vm_area_struct *); + int (*open) (struct file *); + int (*release) (struct file *); +-}; ++} __do_const; + + /* + * Newer version of video_device, handled by videodev2.c +diff -Naur backports-4.2.6-1.org/include/media/v4l2-device.h backports-4.2.6-1/include/media/v4l2-device.h +--- backports-4.2.6-1.org/include/media/v4l2-device.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/include/media/v4l2-device.h 2016-01-27 12:26:31.219959057 +0100 +@@ -93,7 +93,7 @@ + this function returns 0. If the name ends with a digit (e.g. cx18), + then the name will be set to cx18-0 since cx180 looks really odd. */ + int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename, +- atomic_t *instance); ++ atomic_unchecked_t *instance); + + /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects. + Since the parent disappears this ensures that v4l2_dev doesn't have an +diff -Naur backports-4.2.6-1.org/include/net/bluetooth/l2cap.h backports-4.2.6-1/include/net/bluetooth/l2cap.h +--- backports-4.2.6-1.org/include/net/bluetooth/l2cap.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/include/net/bluetooth/l2cap.h 2016-01-27 12:31:52.866600109 +0100 +@@ -615,7 +615,7 @@ + struct iovec *iov, + int len); + #endif +-}; ++} __do_const; + + struct l2cap_conn { + struct hci_conn *hcon; +diff -Naur backports-4.2.6-1.org/include/net/mac80211.h backports-4.2.6-1/include/net/mac80211.h +--- backports-4.2.6-1.org/include/net/mac80211.h 2015-11-15 22:19:38.000000000 +0100 ++++ backports-4.2.6-1/include/net/mac80211.h 2016-01-27 12:26:31.223292389 +0100 +@@ -5106,7 +5106,7 @@ + struct sk_buff *skb; + struct ieee80211_tx_rate reported_rate; + bool rts, short_preamble; +- u8 max_rate_idx; ++ s8 max_rate_idx; + u32 rate_idx_mask; + u8 *rate_idx_mcs_mask; + bool bss; +@@ -5143,7 +5143,7 @@ + void (*remove_sta_debugfs)(void *priv, void *priv_sta); + + u32 (*get_expected_throughput)(void *priv_sta); +-}; ++} __do_const; + + static inline int rate_supported(struct ieee80211_sta *sta, + enum ieee80211_band band, +diff -Naur backports-4.2.6-1.org/include/trace/events/fs.h backports-4.2.6-1/include/trace/events/fs.h +--- backports-4.2.6-1.org/include/trace/events/fs.h 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/include/trace/events/fs.h 2016-01-27 12:26:31.226625722 +0100 +@@ -0,0 +1,53 @@ ++#undef TRACE_SYSTEM ++#define TRACE_SYSTEM fs ++ ++#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ) ++#define _TRACE_FS_H ++ ++#include <linux/fs.h> ++#include <linux/tracepoint.h> ++ ++TRACE_EVENT(do_sys_open, ++ ++ TP_PROTO(const char *filename, int flags, int mode), ++ ++ TP_ARGS(filename, flags, mode), ++ ++ TP_STRUCT__entry( ++ __string( filename, filename ) ++ __field( int, flags ) ++ __field( int, mode ) ++ ), ++ ++ TP_fast_assign( ++ __assign_str(filename, filename); ++ __entry->flags = flags; ++ __entry->mode = mode; ++ ), ++ ++ TP_printk(""%s" %x %o", ++ __get_str(filename), __entry->flags, __entry->mode) ++); ++ ++TRACE_EVENT(open_exec, ++ ++ TP_PROTO(const char *filename), ++ ++ TP_ARGS(filename), ++ ++ TP_STRUCT__entry( ++ __string( filename, filename ) ++ ), ++ ++ TP_fast_assign( ++ __assign_str(filename, filename); ++ ), ++ ++ TP_printk(""%s"", ++ __get_str(filename)) ++); ++ ++#endif /* _TRACE_FS_H */ ++ ++/* This part must be outside protection */ ++#include <trace/define_trace.h> +diff -Naur backports-4.2.6-1.org/net/bluetooth/hci_sock.c backports-4.2.6-1/net/bluetooth/hci_sock.c +--- backports-4.2.6-1.org/net/bluetooth/hci_sock.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/bluetooth/hci_sock.c 2016-01-27 12:26:36.269958751 +0100 +@@ -1266,7 +1266,7 @@ + uf.event_mask[1] = *((u32 *) f->event_mask + 1); + } + +- len = min_t(unsigned int, len, sizeof(uf)); ++ len = min((size_t)len, sizeof(uf)); + if (copy_from_user(&uf, optval, len)) { + err = -EFAULT; + break; +diff -Naur backports-4.2.6-1.org/net/bluetooth/l2cap_core.c backports-4.2.6-1/net/bluetooth/l2cap_core.c +--- backports-4.2.6-1.org/net/bluetooth/l2cap_core.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/bluetooth/l2cap_core.c 2016-01-27 12:26:36.269958751 +0100 +@@ -3547,8 +3547,10 @@ + break; + + case L2CAP_CONF_RFC: +- if (olen == sizeof(rfc)) +- memcpy(&rfc, (void *)val, olen); ++ if (olen != sizeof(rfc)) ++ break; ++ ++ memcpy(&rfc, (void *)val, olen); + + if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) && + rfc.mode != chan->mode) +diff -Naur backports-4.2.6-1.org/net/bluetooth/l2cap_sock.c backports-4.2.6-1/net/bluetooth/l2cap_sock.c +--- backports-4.2.6-1.org/net/bluetooth/l2cap_sock.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/bluetooth/l2cap_sock.c 2016-01-27 12:26:36.269958751 +0100 +@@ -633,7 +633,8 @@ + struct sock *sk = sock->sk; + struct l2cap_chan *chan = l2cap_pi(sk)->chan; + struct l2cap_options opts; +- int len, err = 0; ++ int err = 0; ++ size_t len = optlen; + u32 opt; + + BT_DBG("sk %p", sk); +@@ -660,7 +661,7 @@ + opts.max_tx = chan->max_tx; + opts.txwin_size = chan->tx_win; + +- len = min_t(unsigned int, sizeof(opts), optlen); ++ len = min(sizeof(opts), len); + if (copy_from_user((char *) &opts, optval, len)) { + err = -EFAULT; + break; +@@ -747,7 +748,8 @@ + struct bt_security sec; + struct bt_power pwr; + struct l2cap_conn *conn; +- int len, err = 0; ++ int err = 0; ++ size_t len = optlen; + u32 opt; + + BT_DBG("sk %p", sk); +@@ -771,7 +773,7 @@ + + sec.level = BT_SECURITY_LOW; + +- len = min_t(unsigned int, sizeof(sec), optlen); ++ len = min(sizeof(sec), len); + if (copy_from_user((char *) &sec, optval, len)) { + err = -EFAULT; + break; +@@ -867,7 +869,7 @@ + + pwr.force_active = BT_POWER_FORCE_ACTIVE_ON; + +- len = min_t(unsigned int, sizeof(pwr), optlen); ++ len = min(sizeof(pwr), len); + if (copy_from_user((char *) &pwr, optval, len)) { + err = -EFAULT; + break; +diff -Naur backports-4.2.6-1.org/net/bluetooth/rfcomm/sock.c backports-4.2.6-1/net/bluetooth/rfcomm/sock.c +--- backports-4.2.6-1.org/net/bluetooth/rfcomm/sock.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/bluetooth/rfcomm/sock.c 2016-01-27 12:26:36.269958751 +0100 +@@ -713,7 +713,7 @@ + struct sock *sk = sock->sk; + struct bt_security sec; + int err = 0; +- size_t len; ++ size_t len = optlen; + u32 opt; + + BT_DBG("sk %p", sk); +@@ -735,7 +735,7 @@ + + sec.level = BT_SECURITY_LOW; + +- len = min_t(unsigned int, sizeof(sec), optlen); ++ len = min(sizeof(sec), len); + if (copy_from_user((char *) &sec, optval, len)) { + err = -EFAULT; + break; +diff -Naur backports-4.2.6-1.org/net/bluetooth/rfcomm/tty.c backports-4.2.6-1/net/bluetooth/rfcomm/tty.c +--- backports-4.2.6-1.org/net/bluetooth/rfcomm/tty.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/bluetooth/rfcomm/tty.c 2016-01-27 12:26:36.269958751 +0100 +@@ -752,7 +752,7 @@ + BT_DBG("tty %p id %d", tty, tty->index); + + BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst, +- dev->channel, dev->port.count); ++ dev->channel, atomic_read(&dev->port.count)); + + err = tty_port_open(&dev->port, tty, filp); + if (err) +@@ -775,7 +775,7 @@ + struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; + + BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, +- dev->port.count); ++ atomic_read(&dev->port.count)); + + tty_port_close(&dev->port, tty, filp); + } +diff -Naur backports-4.2.6-1.org/net/ieee802154/6lowpan/core.c backports-4.2.6-1/net/ieee802154/6lowpan/core.c +--- backports-4.2.6-1.org/net/ieee802154/6lowpan/core.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/ieee802154/6lowpan/core.c 2016-01-27 12:26:36.273292083 +0100 +@@ -191,7 +191,7 @@ + dev_put(real_dev); + } + +-static struct rtnl_link_ops lowpan_link_ops __read_mostly = { ++static struct rtnl_link_ops lowpan_link_ops = { + .kind = "lowpan", + .priv_size = sizeof(struct lowpan_dev_info), + .setup = lowpan_setup, +diff -Naur backports-4.2.6-1.org/net/ieee802154/6lowpan/reassembly.c backports-4.2.6-1/net/ieee802154/6lowpan/reassembly.c +--- backports-4.2.6-1.org/net/ieee802154/6lowpan/reassembly.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/ieee802154/6lowpan/reassembly.c 2016-01-27 12:26:36.273292083 +0100 +@@ -435,14 +435,13 @@ + + static int __net_init lowpan_frags_ns_sysctl_register(struct net *net) + { +- struct ctl_table *table; ++ ctl_table_no_const *table = NULL; + struct ctl_table_header *hdr; + struct netns_ieee802154_lowpan *ieee802154_lowpan = + net_ieee802154_lowpan(net); + +- table = lowpan_frags_ns_ctl_table; + if (!net_eq(net, &init_net)) { +- table = kmemdup(table, sizeof(lowpan_frags_ns_ctl_table), ++ table = kmemdup(lowpan_frags_ns_ctl_table, sizeof(lowpan_frags_ns_ctl_table), + GFP_KERNEL); + if (table == NULL) + goto err_alloc; +@@ -457,9 +456,9 @@ + /* Don't export sysctls to unprivileged users */ + if (net->user_ns != &init_user_ns) + table[0].procname = NULL; +- } +- +- hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table); ++ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", table); ++ } else ++ hdr = register_net_sysctl(net, "net/ieee802154/6lowpan", lowpan_frags_ns_ctl_table); + if (hdr == NULL) + goto err_reg; + +@@ -467,8 +466,7 @@ + return 0; + + err_reg: +- if (!net_eq(net, &init_net)) +- kfree(table); ++ kfree(table); + err_alloc: + return -ENOMEM; + } +diff -Naur backports-4.2.6-1.org/net/mac80211/cfg.c backports-4.2.6-1/net/mac80211/cfg.c +--- backports-4.2.6-1.org/net/mac80211/cfg.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/mac80211/cfg.c 2016-01-27 12:26:36.286625417 +0100 +@@ -580,7 +580,7 @@ + ret = ieee80211_vif_use_channel(sdata, chandef, + IEEE80211_CHANCTX_EXCLUSIVE); + } +- } else if (local->open_count == local->monitors) { ++ } else if (local_read(&local->open_count) == local->monitors) { + local->_oper_chandef = *chandef; + ieee80211_hw_config(local, 0); + } +@@ -3488,7 +3488,7 @@ + else + local->probe_req_reg--; + +- if (!local->open_count) ++ if (!local_read(&local->open_count)) + break; + + ieee80211_queue_work(&local->hw, &local->reconfig_filter); +@@ -3637,8 +3637,8 @@ + if (chanctx_conf) { + *chandef = sdata->vif.bss_conf.chandef; + ret = 0; +- } else if (local->open_count > 0 && +- local->open_count == local->monitors && ++ } else if (local_read(&local->open_count) > 0 && ++ local_read(&local->open_count) == local->monitors && + sdata->vif.type == NL80211_IFTYPE_MONITOR) { + if (local->use_chanctx) + *chandef = local->monitor_chandef; +diff -Naur backports-4.2.6-1.org/net/mac80211/ieee80211_i.h backports-4.2.6-1/net/mac80211/ieee80211_i.h +--- backports-4.2.6-1.org/net/mac80211/ieee80211_i.h 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/mac80211/ieee80211_i.h 2016-01-27 12:26:36.289958749 +0100 +@@ -30,6 +30,7 @@ + #include <net/ieee80211_radiotap.h> + #include <net/cfg80211.h> + #include <net/mac80211.h> ++#include <asm/local.h> + #include "key.h" + #include "sta_info.h" + #include "debug.h" +@@ -1112,7 +1113,7 @@ + /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ + spinlock_t queue_stop_reason_lock; + +- int open_count; ++ local_t open_count; + int monitors, cooked_mntrs; + /* number of interfaces with corresponding FIF_ flags */ + int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll, +diff -Naur backports-4.2.6-1.org/net/mac80211/iface.c backports-4.2.6-1/net/mac80211/iface.c +--- backports-4.2.6-1.org/net/mac80211/iface.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/mac80211/iface.c 2016-01-27 12:26:36.289958749 +0100 +@@ -550,7 +550,7 @@ + break; + } + +- if (local->open_count == 0) { ++ if (local_read(&local->open_count) == 0) { + res = drv_start(local); + if (res) + goto err_del_bss; +@@ -597,7 +597,7 @@ + res = drv_add_interface(local, sdata); + if (res) + goto err_stop; +- } else if (local->monitors == 0 && local->open_count == 0) { ++ } else if (local->monitors == 0 && local_read(&local->open_count) == 0) { + res = ieee80211_add_virtual_monitor(local); + if (res) + goto err_stop; +@@ -704,7 +704,7 @@ + atomic_inc(&local->iff_allmultis); + + if (coming_up) +- local->open_count++; ++ local_inc(&local->open_count); + + if (hw_reconf_flags) + ieee80211_hw_config(local, hw_reconf_flags); +@@ -742,7 +742,7 @@ + err_del_interface: + drv_remove_interface(local, sdata); + err_stop: +- if (!local->open_count) ++ if (!local_read(&local->open_count)) + drv_stop(local); + err_del_bss: + sdata->bss = NULL; +@@ -909,7 +909,7 @@ + } + + if (going_down) +- local->open_count--; ++ local_dec(&local->open_count); + + switch (sdata->vif.type) { + case NL80211_IFTYPE_AP_VLAN: +@@ -978,7 +978,7 @@ + atomic_set(&sdata->txqs_len[txqi->txq.ac], 0); + } + +- if (local->open_count == 0) ++ if (local_read(&local->open_count) == 0) + ieee80211_clear_tx_pending(local); + + /* +@@ -1021,7 +1021,7 @@ + if (cancel_scan) + flush_delayed_work(&local->scan_work); + +- if (local->open_count == 0) { ++ if (local_read(&local->open_count) == 0) { + ieee80211_stop_device(local); + + /* no reconfiguring after stop! */ +@@ -1032,7 +1032,7 @@ + ieee80211_configure_filter(local); + ieee80211_hw_config(local, hw_reconf_flags); + +- if (local->monitors == local->open_count) ++ if (local->monitors == local_read(&local->open_count)) + ieee80211_add_virtual_monitor(local); + } + +@@ -1905,8 +1905,8 @@ + */ + cfg80211_shutdown_all_interfaces(local->hw.wiphy); + +- WARN(local->open_count, "%s: open count remains %d\n", +- wiphy_name(local->hw.wiphy), local->open_count); ++ WARN(local_read(&local->open_count), "%s: open count remains %ld\n", ++ wiphy_name(local->hw.wiphy), local_read(&local->open_count)); + + mutex_lock(&local->iflist_mtx); + list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) { +diff -Naur backports-4.2.6-1.org/net/mac80211/main.c backports-4.2.6-1/net/mac80211/main.c +--- backports-4.2.6-1.org/net/mac80211/main.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/mac80211/main.c 2016-01-27 12:26:36.289958749 +0100 +@@ -172,7 +172,7 @@ + changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL | + IEEE80211_CONF_CHANGE_POWER); + +- if (changed && local->open_count) { ++ if (changed && local_read(&local->open_count)) { + ret = drv_config(local, changed); + /* + * Goal: +diff -Naur backports-4.2.6-1.org/net/mac80211/pm.c backports-4.2.6-1/net/mac80211/pm.c +--- backports-4.2.6-1.org/net/mac80211/pm.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/mac80211/pm.c 2016-01-27 12:26:36.289958749 +0100 +@@ -12,7 +12,7 @@ + struct ieee80211_sub_if_data *sdata; + struct sta_info *sta; + +- if (!local->open_count) ++ if (!local_read(&local->open_count)) + goto suspend; + + ieee80211_scan_cancel(local); +@@ -166,7 +166,7 @@ + WARN_ON(!list_empty(&local->chanctx_list)); + + /* stop hardware - this must stop RX */ +- if (local->open_count) ++ if (local_read(&local->open_count)) + ieee80211_stop_device(local); + + suspend: +diff -Naur backports-4.2.6-1.org/net/mac80211/rate.c backports-4.2.6-1/net/mac80211/rate.c +--- backports-4.2.6-1.org/net/mac80211/rate.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/mac80211/rate.c 2016-01-27 12:26:36.289958749 +0100 +@@ -730,7 +730,7 @@ + + ASSERT_RTNL(); + +- if (local->open_count) ++ if (local_read(&local->open_count)) + return -EBUSY; + + if (ieee80211_hw_check(&local->hw, HAS_RATE_CONTROL)) { +diff -Naur backports-4.2.6-1.org/net/mac80211/sta_info.c backports-4.2.6-1/net/mac80211/sta_info.c +--- backports-4.2.6-1.org/net/mac80211/sta_info.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/mac80211/sta_info.c 2016-01-27 12:26:36.289958749 +0100 +@@ -341,7 +341,7 @@ + int size = sizeof(struct txq_info) + + ALIGN(hw->txq_data_size, sizeof(void *)); + +- txq_data = kcalloc(ARRAY_SIZE(sta->sta.txq), size, gfp); ++ txq_data = kcalloc(size, ARRAY_SIZE(sta->sta.txq), gfp); + if (!txq_data) + goto free; + +diff -Naur backports-4.2.6-1.org/net/mac80211/util.c backports-4.2.6-1/net/mac80211/util.c +--- backports-4.2.6-1.org/net/mac80211/util.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/mac80211/util.c 2016-01-27 12:26:36.289958749 +0100 +@@ -1761,7 +1761,7 @@ + bool sched_scan_stopped = false; + + /* nothing to do if HW shouldn't run */ +- if (!local->open_count) ++ if (!local_read(&local->open_count)) + goto wake_up; + + #ifdef CONFIG_PM +@@ -2033,7 +2033,7 @@ + local->in_reconfig = false; + barrier(); + +- if (local->monitors == local->open_count && local->monitors > 0) ++ if (local->monitors == local_read(&local->open_count) && local->monitors > 0) + ieee80211_add_virtual_monitor(local); + + /* +@@ -2088,7 +2088,7 @@ + * If this is for hw restart things are still running. + * We may want to change that later, however. + */ +- if (local->open_count && (!local->suspended || reconfig_due_to_wowlan)) ++ if (local_read(&local->open_count) && (!local->suspended || reconfig_due_to_wowlan)) + drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_RESTART); + + if (!local->suspended) +@@ -2112,7 +2112,7 @@ + flush_delayed_work(&local->scan_work); + } + +- if (local->open_count && !reconfig_due_to_wowlan) ++ if (local_read(&local->open_count) && !reconfig_due_to_wowlan) + drv_reconfig_complete(local, IEEE80211_RECONFIG_TYPE_SUSPEND); + + list_for_each_entry(sdata, &local->interfaces, list) { +diff -Naur backports-4.2.6-1.org/net/wireless/wext-core.c backports-4.2.6-1/net/wireless/wext-core.c +--- backports-4.2.6-1.org/net/wireless/wext-core.c 2015-11-15 22:19:40.000000000 +0100 ++++ backports-4.2.6-1/net/wireless/wext-core.c 2016-01-27 12:26:36.303292082 +0100 +@@ -748,8 +748,7 @@ + */ + + /* Support for very large requests */ +- if ((descr->flags & IW_DESCR_FLAG_NOMAX) && +- (user_length > descr->max_tokens)) { ++ if (user_length > descr->max_tokens) { + /* Allow userspace to GET more than max so + * we can support any size GET requests. + * There is still a limit : -ENOMEM. +@@ -788,22 +787,6 @@ + } + } + +- if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) { +- /* +- * If this is a GET, but not NOMAX, it means that the extra +- * data is not bounded by userspace, but by max_tokens. Thus +- * set the length to max_tokens. This matches the extra data +- * allocation. +- * The driver should fill it with the number of tokens it +- * provided, and it may check iwp->length rather than having +- * knowledge of max_tokens. If the driver doesn't change the +- * iwp->length, this ioctl just copies back max_token tokens +- * filled with zeroes. Hopefully the driver isn't claiming +- * them to be valid data. +- */ +- iwp->length = descr->max_tokens; +- } +- + err = handler(dev, info, (union iwreq_data *) iwp, extra); + + iwp->length += essid_compat; +diff -Naur backports-4.2.6-1.org/scripts/gcc-plugin.sh backports-4.2.6-1/scripts/gcc-plugin.sh +--- backports-4.2.6-1.org/scripts/gcc-plugin.sh 1970-01-01 01:00:00.000000000 +0100 ++++ backports-4.2.6-1/scripts/gcc-plugin.sh 2016-01-27 12:26:36.303292082 +0100 +@@ -0,0 +1,51 @@ ++#!/bin/sh ++srctree=$(dirname "$0") ++gccplugins_dir=$($3 -print-file-name=plugin) ++plugincc=$($1 -E -x c++ - -o /dev/null -I"${srctree}"/../tools/gcc -I"${gccplugins_dir}"/include 2>&1 <<EOF ++#include "gcc-common.h" ++#if BUILDING_GCC_VERSION >= 4008 || defined(ENABLE_BUILD_WITH_CXX) ++#warning $2 CXX ++#else ++#warning $1 CC ++#endif ++EOF ++) ++ ++if [ $? -ne 0 ] ++then ++ exit 1 ++fi ++ ++case "$plugincc" in ++ *"$1 CC"*) ++ echo "$1" ++ exit 0 ++ ;; ++ ++ *"$2 CXX"*) ++ # the c++ compiler needs another test, see below ++ ;; ++ ++ *) ++ exit 1 ++ ;; ++esac ++ ++# we need a c++ compiler that supports the designated initializer GNU extension ++plugincc=$($2 -c -x c++ -std=gnu++98 - -fsyntax-only -I"${srctree}"/../tools/gcc -I"${gccplugins_dir}"/include 2>&1 <<EOF ++#include "gcc-common.h" ++class test { ++public: ++ int test; ++} test = { ++ .test = 1 ++}; ++EOF ++) ++ ++if [ $? -eq 0 ] ++then ++ echo "$2" ++ exit 0 ++fi ++exit 1 diff --git a/src/patches/backports-4.2.6-1-mt7601_upstream_fixes.patch b/src/patches/backports-4.2.6-1-mt7601_upstream_fixes.patch new file mode 100644 index 0000000..9918d65 --- /dev/null +++ b/src/patches/backports-4.2.6-1-mt7601_upstream_fixes.patch @@ -0,0 +1,441 @@ +From bed429e1ae8b7ee207e01f3aa60dcc0d06a8ed4d Mon Sep 17 00:00:00 2001 +From: Jakub Kicinski kubakici@wp.pl +Date: Fri, 31 Jul 2015 15:04:46 +0200 +Subject: mt7601u: fix dma from stack address + +DMA to variables located on the stack is a bad idea. +For simplicity and to avoid frequent allocations create +a buffer inside the device structure. Protect this +buffer with vendor_req_mutex. Don't protect vendor +requests which don't use this buffer. + +Signed-off-by: Jakub Kicinski kubakici@wp.pl +Signed-off-by: Kalle Valo kvalo@codeaurora.org +--- + drivers/net/wireless/mediatek/mt7601u/mt7601u.h | 4 +- + drivers/net/wireless/mediatek/mt7601u/usb.c | 63 ++++++++++++------------- + drivers/net/wireless/mediatek/mt7601u/usb.h | 2 + + 3 files changed, 34 insertions(+), 35 deletions(-) + +diff --git a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h +index 9102be6b..6bdfc11 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h ++++ b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h +@@ -146,7 +146,7 @@ enum { + * @rx_lock: protects @rx_q. + * @con_mon_lock: protects @ap_bssid, @bcn_*, @avg_rssi. + * @mutex: ensures exclusive access from mac80211 callbacks. +- * @vendor_req_mutex: ensures atomicity of vendor requests. ++ * @vendor_req_mutex: protects @vend_buf, ensures atomicity of split writes. + * @reg_atomic_mutex: ensures atomicity of indirect register accesses + * (accesses to RF and BBP). + * @hw_atomic_mutex: ensures exclusive access to HW during critical +@@ -184,6 +184,8 @@ struct mt7601u_dev { + struct mt7601u_eeprom_params *ee; + + struct mutex vendor_req_mutex; ++ void *vend_buf; ++ + struct mutex reg_atomic_mutex; + struct mutex hw_atomic_mutex; + +diff --git a/drivers/net/wireless/mediatek/mt7601u/usb.c b/drivers/net/wireless/mediatek/mt7601u/usb.c +index 54dba40..416c604 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/usb.c ++++ b/drivers/net/wireless/mediatek/mt7601u/usb.c +@@ -92,10 +92,9 @@ void mt7601u_complete_urb(struct urb *urb) + complete(cmpl); + } + +-static int +-__mt7601u_vendor_request(struct mt7601u_dev *dev, const u8 req, +- const u8 direction, const u16 val, const u16 offset, +- void *buf, const size_t buflen) ++int mt7601u_vendor_request(struct mt7601u_dev *dev, const u8 req, ++ const u8 direction, const u16 val, const u16 offset, ++ void *buf, const size_t buflen) + { + int i, ret; + struct usb_device *usb_dev = mt7601u_to_usb_dev(dev); +@@ -110,6 +109,8 @@ __mt7601u_vendor_request(struct mt7601u_dev *dev, const u8 req, + trace_mt_vend_req(dev, pipe, req, req_type, val, offset, + buf, buflen, ret); + ++ if (ret == -ENODEV) ++ set_bit(MT7601U_STATE_REMOVED, &dev->state); + if (ret >= 0 || ret == -ENODEV) + return ret; + +@@ -122,25 +123,6 @@ __mt7601u_vendor_request(struct mt7601u_dev *dev, const u8 req, + return ret; + } + +-int +-mt7601u_vendor_request(struct mt7601u_dev *dev, const u8 req, +- const u8 direction, const u16 val, const u16 offset, +- void *buf, const size_t buflen) +-{ +- int ret; +- +- mutex_lock(&dev->vendor_req_mutex); +- +- ret = __mt7601u_vendor_request(dev, req, direction, val, offset, +- buf, buflen); +- if (ret == -ENODEV) +- set_bit(MT7601U_STATE_REMOVED, &dev->state); +- +- mutex_unlock(&dev->vendor_req_mutex); +- +- return ret; +-} +- + void mt7601u_vendor_reset(struct mt7601u_dev *dev) + { + mt7601u_vendor_request(dev, MT_VEND_DEV_MODE, USB_DIR_OUT, +@@ -150,19 +132,21 @@ void mt7601u_vendor_reset(struct mt7601u_dev *dev) + u32 mt7601u_rr(struct mt7601u_dev *dev, u32 offset) + { + int ret; +- __le32 reg; +- u32 val; ++ u32 val = ~0; + + WARN_ONCE(offset > USHRT_MAX, "read high off:%08x", offset); + ++ mutex_lock(&dev->vendor_req_mutex); ++ + ret = mt7601u_vendor_request(dev, MT_VEND_MULTI_READ, USB_DIR_IN, +- 0, offset, ®, sizeof(reg)); +- val = le32_to_cpu(reg); +- if (ret > 0 && ret != sizeof(reg)) { ++ 0, offset, dev->vend_buf, MT_VEND_BUF); ++ if (ret == MT_VEND_BUF) ++ val = get_unaligned_le32(dev->vend_buf); ++ else if (ret > 0) + dev_err(dev->dev, "Error: wrong size read:%d off:%08x\n", + ret, offset); +- val = ~0; +- } ++ ++ mutex_unlock(&dev->vendor_req_mutex); + + trace_reg_read(dev, offset, val); + return val; +@@ -173,12 +157,17 @@ int mt7601u_vendor_single_wr(struct mt7601u_dev *dev, const u8 req, + { + int ret; + ++ mutex_lock(&dev->vendor_req_mutex); ++ + ret = mt7601u_vendor_request(dev, req, USB_DIR_OUT, + val & 0xffff, offset, NULL, 0); +- if (ret) +- return ret; +- return mt7601u_vendor_request(dev, req, USB_DIR_OUT, +- val >> 16, offset + 2, NULL, 0); ++ if (!ret) ++ ret = mt7601u_vendor_request(dev, req, USB_DIR_OUT, ++ val >> 16, offset + 2, NULL, 0); ++ ++ mutex_unlock(&dev->vendor_req_mutex); ++ ++ return ret; + } + + void mt7601u_wr(struct mt7601u_dev *dev, u32 offset, u32 val) +@@ -275,6 +264,12 @@ static int mt7601u_probe(struct usb_interface *usb_intf, + + usb_set_intfdata(usb_intf, dev); + ++ dev->vend_buf = devm_kmalloc(dev->dev, MT_VEND_BUF, GFP_KERNEL); ++ if (!dev->vend_buf) { ++ ret = -ENOMEM; ++ goto err; ++ } ++ + ret = mt7601u_assign_pipes(usb_intf, dev); + if (ret) + goto err; +diff --git a/drivers/net/wireless/mediatek/mt7601u/usb.h b/drivers/net/wireless/mediatek/mt7601u/usb.h +index 49e188f..bc18202 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/usb.h ++++ b/drivers/net/wireless/mediatek/mt7601u/usb.h +@@ -23,6 +23,8 @@ + + #define MT_VEND_DEV_MODE_RESET 1 + ++#define MT_VEND_BUF sizeof(__le32) ++ + enum mt_vendor_req { + MT_VEND_DEV_MODE = 1, + MT_VEND_WRITE = 2, +-- +cgit v0.12 + +From d9517c0a5d7468a7ea63086057604fcb0fff480e Mon Sep 17 00:00:00 2001 +From: Jakub Kicinski kubakici@wp.pl +Date: Fri, 31 Jul 2015 15:04:47 +0200 +Subject: mt7601u: use correct ieee80211_rx variant + +Rx is run inside a tasklet so ieee80211_rx() should be used +instead of ieee80211_rx_ni(). + +Signed-off-by: Jakub Kicinski kubakici@wp.pl +Signed-off-by: Kalle Valo kvalo@codeaurora.org +--- + drivers/net/wireless/mediatek/mt7601u/dma.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c +index 7217da4..fb183e3 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/dma.c ++++ b/drivers/net/wireless/mediatek/mt7601u/dma.c +@@ -112,7 +112,7 @@ static void mt7601u_rx_process_seg(struct mt7601u_dev *dev, u8 *data, + if (!skb) + return; + +- ieee80211_rx_ni(dev->hw, skb); ++ ieee80211_rx(dev->hw, skb); + } + + static u16 mt7601u_rx_next_seg_len(u8 *data, u32 data_len) +-- +cgit v0.12 + +From 4513493d188d5e3052aee68eda85eaaa1a4e41c2 Mon Sep 17 00:00:00 2001 +From: Jakub Kicinski kubakici@wp.pl +Date: Fri, 31 Jul 2015 15:04:48 +0200 +Subject: mt7601u: fix tx status reporting contexts + +mac80211 requires that rx path does not run concurrently with +tx status reporting. Since rx path is run in driver tasklet, +tx status cannot be reported directly from interrupt context +(there would be no way to lock it out). + +Add tasklet for tx and move all possible code from irq handler +there. + +Note: tx tasklet is needed because workqueue is queued very + rarely and that kills TCP performance. + +Signed-off-by: Jakub Kicinski kubakici@wp.pl +Signed-off-by: Kalle Valo kvalo@codeaurora.org +--- + drivers/net/wireless/mediatek/mt7601u/dma.c | 30 +++++++++++++++++++++---- + drivers/net/wireless/mediatek/mt7601u/init.c | 1 + + drivers/net/wireless/mediatek/mt7601u/mac.c | 4 ++++ + drivers/net/wireless/mediatek/mt7601u/mt7601u.h | 2 ++ + 4 files changed, 33 insertions(+), 4 deletions(-) + +diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c +index fb183e3..63c4854 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/dma.c ++++ b/drivers/net/wireless/mediatek/mt7601u/dma.c +@@ -236,23 +236,42 @@ static void mt7601u_complete_tx(struct urb *urb) + skb = q->e[q->start].skb; + trace_mt_tx_dma_done(dev, skb); + +- mt7601u_tx_status(dev, skb); ++ __skb_queue_tail(&dev->tx_skb_done, skb); ++ tasklet_schedule(&dev->tx_tasklet); + + if (q->used == q->entries - q->entries / 8) + ieee80211_wake_queue(dev->hw, skb_get_queue_mapping(skb)); + + q->start = (q->start + 1) % q->entries; + q->used--; ++out: ++ spin_unlock_irqrestore(&dev->tx_lock, flags); ++} + +- if (urb->status) +- goto out; ++static void mt7601u_tx_tasklet(unsigned long data) ++{ ++ struct mt7601u_dev *dev = (struct mt7601u_dev *) data; ++ struct sk_buff_head skbs; ++ unsigned long flags; ++ ++ __skb_queue_head_init(&skbs); ++ ++ spin_lock_irqsave(&dev->tx_lock, flags); + + set_bit(MT7601U_STATE_MORE_STATS, &dev->state); + if (!test_and_set_bit(MT7601U_STATE_READING_STATS, &dev->state)) + queue_delayed_work(dev->stat_wq, &dev->stat_work, + msecs_to_jiffies(10)); +-out: ++ ++ skb_queue_splice_init(&dev->tx_skb_done, &skbs); ++ + spin_unlock_irqrestore(&dev->tx_lock, flags); ++ ++ while (!skb_queue_empty(&skbs)) { ++ struct sk_buff *skb = __skb_dequeue(&skbs); ++ ++ mt7601u_tx_status(dev, skb); ++ } + } + + static int mt7601u_dma_submit_tx(struct mt7601u_dev *dev, +@@ -475,6 +494,7 @@ int mt7601u_dma_init(struct mt7601u_dev *dev) + { + int ret = -ENOMEM; + ++ tasklet_init(&dev->tx_tasklet, mt7601u_tx_tasklet, (unsigned long) dev); + tasklet_init(&dev->rx_tasklet, mt7601u_rx_tasklet, (unsigned long) dev); + + ret = mt7601u_alloc_tx(dev); +@@ -502,4 +522,6 @@ void mt7601u_dma_cleanup(struct mt7601u_dev *dev) + + mt7601u_free_rx(dev); + mt7601u_free_tx(dev); ++ ++ tasklet_kill(&dev->tx_tasklet); + } +diff --git a/drivers/net/wireless/mediatek/mt7601u/init.c b/drivers/net/wireless/mediatek/mt7601u/init.c +index df3dd56..38eb20b 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/init.c ++++ b/drivers/net/wireless/mediatek/mt7601u/init.c +@@ -456,6 +456,7 @@ struct mt7601u_dev *mt7601u_alloc_device(struct device *pdev) + spin_lock_init(&dev->lock); + spin_lock_init(&dev->con_mon_lock); + atomic_set(&dev->avg_ampdu_len, 1); ++ skb_queue_head_init(&dev->tx_skb_done); + + dev->stat_wq = alloc_workqueue("mt7601u", WQ_UNBOUND, 0); + if (!dev->stat_wq) { +diff --git a/drivers/net/wireless/mediatek/mt7601u/mac.c b/drivers/net/wireless/mediatek/mt7601u/mac.c +index 7514bce..e3928cf 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/mac.c ++++ b/drivers/net/wireless/mediatek/mt7601u/mac.c +@@ -181,7 +181,11 @@ void mt76_send_tx_status(struct mt7601u_dev *dev, struct mt76_tx_status *stat) + } + + mt76_mac_fill_tx_status(dev, &info, stat); ++ ++ local_bh_disable(); + ieee80211_tx_status_noskb(dev->hw, sta, &info); ++ local_bh_enable(); ++ + rcu_read_unlock(); + } + +diff --git a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h +index 6bdfc11..bc5e294 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h ++++ b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h +@@ -199,7 +199,9 @@ struct mt7601u_dev { + + /* TX */ + spinlock_t tx_lock; ++ struct tasklet_struct tx_tasklet; + struct mt7601u_tx_queue *tx_q; ++ struct sk_buff_head tx_skb_done; + + atomic_t avg_ampdu_len; + +-- +cgit v0.12 + +From 78623bfb6f4cbdba3183621e8e0e781611217022 Mon Sep 17 00:00:00 2001 +From: Jakub Kicinski kubakici@wp.pl +Date: Fri, 31 Jul 2015 15:04:49 +0200 +Subject: mt7601u: lock out rx path and tx status reporting + +mac80211 requires that rx path does not run concurrently with +tx status reporting. Add a spinlock which will ensure that. + +Signed-off-by: Jakub Kicinski kubakici@wp.pl +Signed-off-by: Kalle Valo kvalo@codeaurora.org +--- + drivers/net/wireless/mediatek/mt7601u/dma.c | 2 ++ + drivers/net/wireless/mediatek/mt7601u/init.c | 1 + + drivers/net/wireless/mediatek/mt7601u/mac.c | 4 ++-- + drivers/net/wireless/mediatek/mt7601u/mt7601u.h | 4 +++- + drivers/net/wireless/mediatek/mt7601u/tx.c | 3 +++ + 5 files changed, 11 insertions(+), 3 deletions(-) + +diff --git a/drivers/net/wireless/mediatek/mt7601u/dma.c b/drivers/net/wireless/mediatek/mt7601u/dma.c +index 63c4854..57a80cf 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/dma.c ++++ b/drivers/net/wireless/mediatek/mt7601u/dma.c +@@ -112,7 +112,9 @@ static void mt7601u_rx_process_seg(struct mt7601u_dev *dev, u8 *data, + if (!skb) + return; + ++ spin_lock(&dev->mac_lock); + ieee80211_rx(dev->hw, skb); ++ spin_unlock(&dev->mac_lock); + } + + static u16 mt7601u_rx_next_seg_len(u8 *data, u32 data_len) +diff --git a/drivers/net/wireless/mediatek/mt7601u/init.c b/drivers/net/wireless/mediatek/mt7601u/init.c +index 38eb20b..26190fd 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/init.c ++++ b/drivers/net/wireless/mediatek/mt7601u/init.c +@@ -454,6 +454,7 @@ struct mt7601u_dev *mt7601u_alloc_device(struct device *pdev) + spin_lock_init(&dev->tx_lock); + spin_lock_init(&dev->rx_lock); + spin_lock_init(&dev->lock); ++ spin_lock_init(&dev->mac_lock); + spin_lock_init(&dev->con_mon_lock); + atomic_set(&dev->avg_ampdu_len, 1); + skb_queue_head_init(&dev->tx_skb_done); +diff --git a/drivers/net/wireless/mediatek/mt7601u/mac.c b/drivers/net/wireless/mediatek/mt7601u/mac.c +index e3928cf..e21c53e 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/mac.c ++++ b/drivers/net/wireless/mediatek/mt7601u/mac.c +@@ -182,9 +182,9 @@ void mt76_send_tx_status(struct mt7601u_dev *dev, struct mt76_tx_status *stat) + + mt76_mac_fill_tx_status(dev, &info, stat); + +- local_bh_disable(); ++ spin_lock_bh(&dev->mac_lock); + ieee80211_tx_status_noskb(dev->hw, sta, &info); +- local_bh_enable(); ++ spin_unlock_bh(&dev->mac_lock); + + rcu_read_unlock(); + } +diff --git a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h +index bc5e294..428bd2f 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/mt7601u.h ++++ b/drivers/net/wireless/mediatek/mt7601u/mt7601u.h +@@ -141,8 +141,9 @@ enum { + /** + * struct mt7601u_dev - adapter structure + * @lock: protects @wcid->tx_rate. ++ * @mac_lock: locks out mac80211's tx status and rx paths. + * @tx_lock: protects @tx_q and changes of MT7601U_STATE_*_STATS +- flags in @state. ++ * flags in @state. + * @rx_lock: protects @rx_q. + * @con_mon_lock: protects @ap_bssid, @bcn_*, @avg_rssi. + * @mutex: ensures exclusive access from mac80211 callbacks. +@@ -177,6 +178,7 @@ struct mt7601u_dev { + struct mt76_wcid __rcu *wcid[N_WCIDS]; + + spinlock_t lock; ++ spinlock_t mac_lock; + + const u16 *beacon_offsets; + +diff --git a/drivers/net/wireless/mediatek/mt7601u/tx.c b/drivers/net/wireless/mediatek/mt7601u/tx.c +index 0be2080..a0a33dc 100644 +--- a/drivers/net/wireless/mediatek/mt7601u/tx.c ++++ b/drivers/net/wireless/mediatek/mt7601u/tx.c +@@ -116,7 +116,10 @@ void mt7601u_tx_status(struct mt7601u_dev *dev, struct sk_buff *skb) + ieee80211_tx_info_clear_status(info); + info->status.rates[0].idx = -1; + info->flags |= IEEE80211_TX_STAT_ACK; ++ ++ spin_lock(&dev->mac_lock); + ieee80211_tx_status(dev->hw, skb); ++ spin_unlock(&dev->mac_lock); + } + + static int mt7601u_skb_rooms(struct mt7601u_dev *dev, struct sk_buff *skb) +-- +cgit v0.12 + diff --git a/src/patches/binutils-2.22-pt-pax-flags-20111121.patch b/src/patches/binutils-2.22-pt-pax-flags-20111121.patch deleted file mode 100644 index 3ba1a87..0000000 --- a/src/patches/binutils-2.22-pt-pax-flags-20111121.patch +++ /dev/null @@ -1,1859 +0,0 @@ ---- binutils-2.22/bfd/elf-bfd.h -+++ binutils-2.22/bfd/elf-bfd.h -@@ -1577,6 +1577,9 @@ struct elf_obj_tdata - /* Segment flags for the PT_GNU_STACK segment. */ - unsigned int stack_flags; - -+ /* Segment flags for the PT_PAX_FLAGS segment. */ -+ unsigned int pax_flags; -+ - /* Symbol version definitions in external objects. */ - Elf_Internal_Verdef *verdef; - ---- binutils-2.22/bfd/elf.c -+++ binutils-2.22/bfd/elf.c -@@ -1158,6 +1158,7 @@ get_segment_type (unsigned int p_type) - case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break; - case PT_GNU_STACK: pt = "STACK"; break; - case PT_GNU_RELRO: pt = "RELRO"; break; -+ case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break; - default: pt = NULL; break; - } - return pt; -@@ -2477,6 +2478,9 @@ bfd_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int hdr_index) - case PT_GNU_RELRO: - return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "relro"); - -+ case PT_PAX_FLAGS: -+ return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "pax_flags"); -+ - default: - /* Check for any processor-specific program segment types. */ - bed = get_elf_backend_data (abfd); -@@ -3551,6 +3555,11 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info) - ++segs; - } - -+ { -+ /* We need a PT_PAX_FLAGS segment. */ -+ ++segs; -+ } -+ - for (s = abfd->sections; s != NULL; s = s->next) - { - if ((s->flags & SEC_LOAD) != 0 -@@ -4153,6 +4162,20 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) - } - } - -+ { -+ amt = sizeof (struct elf_segment_map); -+ m = bfd_zalloc (abfd, amt); -+ if (m == NULL) -+ goto error_return; -+ m->next = NULL; -+ m->p_type = PT_PAX_FLAGS; -+ m->p_flags = elf_tdata (abfd)->pax_flags; -+ m->p_flags_valid = 1; -+ -+ *pm = m; -+ pm = &m->next; -+ } -+ - free (sections); - elf_tdata (abfd)->segment_map = mfirst; - } -@@ -5417,7 +5440,8 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) - 6. PT_TLS segment includes only SHF_TLS sections. - 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments. - 8. PT_DYNAMIC should not contain empty sections at the beginning -- (with the possible exception of .dynamic). */ -+ (with the possible exception of .dynamic). -+ 9. PT_PAX_FLAGS segments do not include any sections. */ - #define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed) \ - ((((segment->p_paddr \ - ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \ -@@ -5425,6 +5449,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) - && (section->flags & SEC_ALLOC) != 0) \ - || IS_NOTE (segment, section)) \ - && segment->p_type != PT_GNU_STACK \ -+ && segment->p_type != PT_PAX_FLAGS \ - && (segment->p_type != PT_TLS \ - || (section->flags & SEC_THREAD_LOCAL)) \ - && (segment->p_type == PT_LOAD \ ---- binutils-2.22/bfd/elflink.c -+++ binutils-2.22/bfd/elflink.c -@@ -5545,16 +5545,30 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, - return TRUE; - - bed = get_elf_backend_data (output_bfd); -+ -+ elf_tdata (output_bfd)->pax_flags = PF_NORANDEXEC; -+ if (info->execheap) -+ elf_tdata (output_bfd)->pax_flags |= PF_NOMPROTECT; -+ else if (info->noexecheap) -+ elf_tdata (output_bfd)->pax_flags |= PF_MPROTECT; -+ - if (info->execstack) -- elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; -+ { -+ elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; -+ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP; -+ } - else if (info->noexecstack) -- elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; -+ { -+ elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; -+ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP; -+ } - else - { - bfd *inputobj; - asection *notesec = NULL; - int exec = 0; - -+ elf_tdata (output_bfd)->pax_flags |= PF_NOEMUTRAMP; - for (inputobj = info->input_bfds; - inputobj; - inputobj = inputobj->link_next) -@@ -5567,7 +5581,11 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, - if (s) - { - if (s->flags & SEC_CODE) -- exec = PF_X; -+ { -+ elf_tdata (output_bfd)->pax_flags &= ~PF_NOEMUTRAMP; -+ elf_tdata (output_bfd)->pax_flags |= PF_EMUTRAMP; -+ exec = PF_X; -+ } - notesec = s; - } - else if (bed->default_execstack) ---- binutils-2.22/binutils/readelf.c -+++ binutils-2.22/binutils/readelf.c -@@ -2740,6 +2740,7 @@ get_segment_type (unsigned long p_type) - return "GNU_EH_FRAME"; - case PT_GNU_STACK: return "GNU_STACK"; - case PT_GNU_RELRO: return "GNU_RELRO"; -+ case PT_PAX_FLAGS: return "PAX_FLAGS"; - - default: - if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC)) ---- binutils-2.22/include/bfdlink.h -+++ binutils-2.22/include/bfdlink.h -@@ -322,6 +322,14 @@ struct bfd_link_info - /* TRUE if PT_GNU_RELRO segment should be created. */ - unsigned int relro: 1; - -+ /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT -+ flags. */ -+ unsigned int execheap: 1; -+ -+ /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT -+ flags. */ -+ unsigned int noexecheap: 1; -+ - /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment - should be created. */ - unsigned int eh_frame_hdr: 1; ---- binutils-2.22/include/elf/common.h -+++ binutils-2.22/include/elf/common.h -@@ -429,6 +429,7 @@ - #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */ - #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */ - #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */ -+#define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */ - - /* Program segment permissions, in program header p_flags field. */ - -@@ -439,6 +440,21 @@ - #define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */ - #define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */ - -+/* Flags to control PaX behavior. */ -+ -+#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */ -+#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */ -+#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */ -+#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */ -+#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */ -+#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */ -+#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */ -+#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */ -+#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */ -+#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */ -+#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */ -+#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */ -+ - /* Values for section header, sh_type field. */ - - #define SHT_NULL 0 /* Section header table entry unused */ ---- binutils-2.22/ld/emultempl/elf32.em -+++ binutils-2.22/ld/emultempl/elf32.em -@@ -2285,6 +2285,16 @@ fragment <<EOF - link_info.noexecstack = TRUE; - link_info.execstack = FALSE; - } -+ else if (strcmp (optarg, "execheap") == 0) -+ { -+ link_info.execheap = TRUE; -+ link_info.noexecheap = FALSE; -+ } -+ else if (strcmp (optarg, "noexecheap") == 0) -+ { -+ link_info.noexecheap = TRUE; -+ link_info.execheap = FALSE; -+ } - EOF - if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then - fragment <<EOF -@@ -2368,6 +2378,8 @@ fragment <<EOF - -z defs Report unresolved symbols in object files.\n")); - fprintf (file, _("\ - -z execstack Mark executable as requiring executable stack\n")); -+ fprintf (file, _("\ -+ -z execheap Mark executable as requiring executable heap\n")); - EOF - - if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then -@@ -2391,6 +2403,8 @@ fragment <<EOF - fragment <<EOF - fprintf (file, _("\ - -z noexecstack Mark executable as not requiring executable stack\n")); -+ fprintf (file, _("\ -+ -z noexecheap Mark executable as not requiring executable heap\n")); - EOF - if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then - fragment <<EOF ---- binutils-2.22/ld/ldgram.y -+++ binutils-2.22/ld/ldgram.y -@@ -1119,6 +1119,8 @@ phdr_type: - $$ = exp_intop (0x6474e550); - else if (strcmp (s, "PT_GNU_STACK") == 0) - $$ = exp_intop (0x6474e551); -+ else if (strcmp (s, "PT_PAX_FLAGS") == 0) -+ $$ = exp_intop (0x65041580); - else - { - einfo (_("\ ---- binutils-2.22/ld/testsuite/ld-alpha/tlsbin.rd -+++ binutils-2.22/ld/testsuite/ld-alpha/tlsbin.rd -@@ -35,13 +35,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ - - Program Headers: - Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align -- PHDR +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+150 R E 0x8 -+ PHDR +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+188 R E 0x8 - INTERP +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1 - .*Requesting program interpreter.* - LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R E 0x10000 - LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x10000 - DYNAMIC +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RW +0x8 - TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 3 entries: ---- binutils-2.22/ld/testsuite/ld-alpha/tlsbinr.rd -+++ binutils-2.22/ld/testsuite/ld-alpha/tlsbinr.rd -@@ -42,6 +42,7 @@ Program Headers: - +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x10000 - +DYNAMIC +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RW +0x8 - +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries: ---- binutils-2.22/ld/testsuite/ld-alpha/tlspic.rd -+++ binutils-2.22/ld/testsuite/ld-alpha/tlspic.rd -@@ -38,6 +38,7 @@ Program Headers: - +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x10000 - +DYNAMIC +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RW +0x8 - +TLS +0x0+10e0 0x0+110e0 0x0+110e0 0x0+60 0x0+80 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 7 entries: ---- binutils-2.22/ld/testsuite/ld-elf/eh1.d -+++ binutils-2.22/ld/testsuite/ld-elf/eh1.d -@@ -22,11 +22,11 @@ Contents of the .eh_frame section: - DW_CFA_nop - DW_CFA_nop - --00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078 -- DW_CFA_advance_loc: 0 to 00400078 -+00000018 0000001c 0000001c FDE cie=00000000 pc=([0-9a-f]+)..\1 -+ DW_CFA_advance_loc: 0 to [0-9a-f]+ - DW_CFA_def_cfa_offset: 16 - DW_CFA_offset: r6 (rbp) at cfa-16 -- DW_CFA_advance_loc: 0 to 00400078 -+ DW_CFA_advance_loc: 0 to [0-9a-f]+ - DW_CFA_def_cfa_register: r6 (rbp) - - 00000038 ZERO terminator ---- binutils-2.22/ld/testsuite/ld-elf/eh2.d -+++ binutils-2.22/ld/testsuite/ld-elf/eh2.d -@@ -22,11 +22,11 @@ Contents of the .eh_frame section: - DW_CFA_nop - DW_CFA_nop - --00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078 -- DW_CFA_advance_loc: 0 to 00400078 -+00000018 0000001c 0000001c FDE cie=00000000 pc=([0-9a-f]+)..\1 -+ DW_CFA_advance_loc: 0 to [0-9a-f]+ - DW_CFA_def_cfa_offset: 16 - DW_CFA_offset: r6 (rbp) at cfa-16 -- DW_CFA_advance_loc: 0 to 00400078 -+ DW_CFA_advance_loc: 0 to [0-9a-f]+ - DW_CFA_def_cfa_register: r6 (rbp) - - 00000038 ZERO terminator ---- binutils-2.22/ld/testsuite/ld-elf/eh3.d -+++ binutils-2.22/ld/testsuite/ld-elf/eh3.d -@@ -22,11 +22,11 @@ Contents of the .eh_frame section: - DW_CFA_nop - DW_CFA_nop - --00000018 0000001c 0000001c FDE cie=00000000 pc=00400078..00400078 -- DW_CFA_advance_loc: 0 to 00400078 -+00000018 0000001c 0000001c FDE cie=00000000 pc=([0-9a-f]+)..\1 -+ DW_CFA_advance_loc: 0 to [0-9a-f]+ - DW_CFA_def_cfa_offset: 16 - DW_CFA_offset: r6 (rbp) at cfa-16 -- DW_CFA_advance_loc: 0 to 00400078 -+ DW_CFA_advance_loc: 0 to [0-9a-f]+ - DW_CFA_def_cfa_register: r6 (rbp) - - 00000038 ZERO terminator ---- binutils-2.22/ld/testsuite/ld-elf/orphan-region.d -+++ binutils-2.22/ld/testsuite/ld-elf/orphan-region.d -@@ -15,7 +15,9 @@ - Program Headers: - Type.* - LOAD[ \t]+0x[0-9a-f]+ 0x0*40000000 0x0*40000000 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x[0-9a-f]+ -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - Segment Sections... - 00 .text .rodata .moredata * -+ 01 + ---- binutils-2.22/ld/testsuite/ld-i386/tlsbin.rd -+++ binutils-2.22/ld/testsuite/ld-i386/tlsbin.rd -@@ -44,6 +44,7 @@ Program Headers: - +LOAD.* - +DYNAMIC.* - +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+60 0x0+a0 R +0x1000 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -53,6 +54,7 @@ Program Headers: - +03 +.tdata .dynamic .got .got.plt * - +04 +.dynamic * - +05 +.tdata .tbss * -+ +06 + - - Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 9 entries: - Offset +Info +Type +Sym.Value +Sym. Name ---- binutils-2.22/ld/testsuite/ld-i386/tlsbindesc.rd -+++ binutils-2.22/ld/testsuite/ld-i386/tlsbindesc.rd -@@ -42,6 +42,7 @@ Program Headers: - +LOAD.* - +DYNAMIC.* - +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+60 0x0+a0 R +0x1000 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -51,6 +52,7 @@ Program Headers: - +03 +.tdata .dynamic .got .got.plt * - +04 +.dynamic * - +05 +.tdata .tbss * -+ +06 + - - Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 9 entries: - Offset +Info +Type +Sym.Value +Sym. Name ---- binutils-2.22/ld/testsuite/ld-i386/tlsdesc.rd -+++ binutils-2.22/ld/testsuite/ld-i386/tlsdesc.rd -@@ -39,6 +39,7 @@ Program Headers: - +LOAD.* - +DYNAMIC.* - +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+60 0x0+80 R +0x1 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -46,6 +47,7 @@ Program Headers: - +01 +.tdata .dynamic .got .got.plt * - +02 +.dynamic * - +03 +.tdata .tbss * -+ +04 + - - Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 20 entries: - Offset +Info +Type +Sym.Value +Sym. Name ---- binutils-2.22/ld/testsuite/ld-i386/tlsdesc.sd -+++ binutils-2.22/ld/testsuite/ld-i386/tlsdesc.sd -@@ -14,7 +14,7 @@ Contents of section .got: - [0-9a-f]+ 6c000000 b4ffffff 4c000000 68000000 .* - [0-9a-f]+ 50000000 70000000 00000000 bcffffff .* - Contents of section .got.plt: -- [0-9a-f]+ b0150000 00000000 00000000 00000000 .* -+ [0-9a-f]+ [a-f]0150000 00000000 00000000 00000000 .* - [0-9a-f]+ 20000000 00000000 60000000 00000000 .* - [0-9a-f]+ 00000000 00000000 00000000 00000000 .* - [0-9a-f]+ 40000000 +.* ---- binutils-2.22/ld/testsuite/ld-i386/tlsgdesc.rd -+++ binutils-2.22/ld/testsuite/ld-i386/tlsgdesc.rd -@@ -36,12 +36,14 @@ Program Headers: - +LOAD.* - +LOAD.* - +DYNAMIC.* -+ +PAX_FLAGS.* - - Section to Segment mapping: - +Segment Sections... - +00 +.hash .dynsym .dynstr .rel.dyn .rel.plt .plt .text * - +01 +.dynamic .got .got.plt * - +02 +.dynamic * -+ +03 + - - Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 8 entries: - Offset +Info +Type +Sym.Value +Sym. Name ---- binutils-2.22/ld/testsuite/ld-i386/tlsnopic.rd -+++ binutils-2.22/ld/testsuite/ld-i386/tlsnopic.rd -@@ -37,6 +37,7 @@ Program Headers: - +LOAD.* - +DYNAMIC.* - +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+ 0x0+24 R +0x1 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -44,6 +45,7 @@ Program Headers: - +01 +.dynamic .got .got.plt * - +02 +.dynamic * - +03 +.tbss * -+ +04 + - - Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 20 entries: - Offset +Info +Type +Sym.Value +Sym. Name ---- binutils-2.22/ld/testsuite/ld-i386/tlspic.rd -+++ binutils-2.22/ld/testsuite/ld-i386/tlspic.rd -@@ -40,6 +40,7 @@ Program Headers: - +LOAD.* - +DYNAMIC.* - +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+60 0x0+80 R +0x1 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -47,6 +48,7 @@ Program Headers: - +01 +.tdata .dynamic .got .got.plt * - +02 +.dynamic * - +03 +.tdata .tbss * -+ +04 + - - Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 26 entries: - Offset +Info +Type +Sym.Value +Sym. Name ---- binutils-2.22/ld/testsuite/ld-ia64/merge1.d -+++ binutils-2.22/ld/testsuite/ld-ia64/merge1.d -@@ -4,7 +4,7 @@ - #objdump: -d - - #... --0+1e0 <.text>: -+[a-f0-9]+ <.text>: - [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; - [ ]*[a-f0-9]+: c0 c0 04 00 48 00 addl r12=24,r1 - [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; ---- binutils-2.22/ld/testsuite/ld-ia64/merge2.d -+++ binutils-2.22/ld/testsuite/ld-ia64/merge2.d -@@ -4,7 +4,7 @@ - #objdump: -d - - #... --0+1e0 <.text>: -+[a-f0-9]+ <.text>: - [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; - [ ]*[a-f0-9]+: c0 c0 04 00 48 00 addl r12=24,r1 - [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; ---- binutils-2.22/ld/testsuite/ld-ia64/merge3.d -+++ binutils-2.22/ld/testsuite/ld-ia64/merge3.d -@@ -4,7 +4,7 @@ - #objdump: -d - - #... --0+210 <.text>: -+[a-f0-9]+ <.text>: - [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; - [ ]*[a-f0-9]+: c0 40 05 00 48 00 addl r12=40,r1 - [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; ---- binutils-2.22/ld/testsuite/ld-ia64/merge4.d -+++ binutils-2.22/ld/testsuite/ld-ia64/merge4.d -@@ -4,7 +4,7 @@ - #objdump: -d - - #... --0+240 <.text>: -+[a-f0-9]+ <.text>: - [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; - [ ]*[a-f0-9]+: c0 40 05 00 48 00 addl r12=40,r1 - [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; ---- binutils-2.22/ld/testsuite/ld-ia64/merge5.d -+++ binutils-2.22/ld/testsuite/ld-ia64/merge5.d -@@ -4,7 +4,7 @@ - #objdump: -d - - #... --0+270 <.text>: -+[a-f0-9]+ <.text>: - [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; - [ ]*[a-f0-9]+: c0 40 05 00 48 00 addl r12=40,r1 - [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; ---- binutils-2.22/ld/testsuite/ld-ia64/tlsbin.rd -+++ binutils-2.22/ld/testsuite/ld-ia64/tlsbin.rd -@@ -36,13 +36,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ - - Program Headers: - +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align -- +PHDR +0x0+40 0x40+40 0x40+40 0x0+188 0x0+188 R E 0x8 -- +INTERP +0x0+1c8 0x40+1c8 0x40+1c8 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1 -+ +PHDR +0x0+40 0x40+40 0x40+40 (0x[0-9a-f]+) \1 R E 0x8 -+ +INTERP +0x0+([0-9a-f]+) (0x40+\1) \2 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1 - .*Requesting program interpreter.* - +LOAD +0x0+ 0x40+ 0x40+ 0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ R E 0x10000 - +LOAD +0x0+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x0+0[0-9a-f]+ 0x0+0[0-9a-f]+ RW +0x10000 - +DYNAMIC +0x0+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x0+150 0x0+150 RW +0x8 - +TLS +0x0+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x0+60 0x0+a0 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - +IA_64_UNWIND .* R +0x8 - #... - ---- binutils-2.22/ld/testsuite/ld-ia64/tlspic.rd -+++ binutils-2.22/ld/testsuite/ld-ia64/tlspic.rd -@@ -40,6 +40,7 @@ Program Headers: - +LOAD +0x0+1[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+0[0-9a-f]+ 0x0+0[0-9a-f]+ RW +0x10000 - +DYNAMIC +0x0+1[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+140 0x0+140 RW +0x8 - +TLS +0x0+1[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+60 0x0+80 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - +IA_64_UNWIND +0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ 0x0+18 0x0+18 R +0x8 - #... - ---- binutils-2.22/ld/testsuite/ld-mips-elf/multi-got-no-shared.d -+++ binutils-2.22/ld/testsuite/ld-mips-elf/multi-got-no-shared.d -@@ -8,9 +8,9 @@ - .*: +file format.* - - Disassembly of section .text: --004000b0 <[^>]*> 3c1c0043 lui gp,0x43 --004000b4 <[^>]*> 279c9ff0 addiu gp,gp,-24592 --004000b8 <[^>]*> afbc0008 sw gp,8(sp) -+004000d0 <[^>]*> 3c1c0043 lui gp,0x43 -+004000d4 <[^>]*> 279c9ff0 addiu gp,gp,-24592 -+004000d8 <[^>]*> afbc0008 sw gp,8(sp) - #... - 00408d60 <[^>]*> 3c1c0043 lui gp,0x43 - 00408d64 <[^>]*> 279c2c98 addiu gp,gp,11416 ---- binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.sd -+++ binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.sd -@@ -1,7 +1,7 @@ - - Elf file type is DYN (Shared object file) - Entry point .* --There are 5 program headers, starting at offset .* -+There are [0-9] program headers, starting at offset .* - - Program Headers: - * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align -@@ -9,6 +9,7 @@ Program Headers: - * LOAD * [^ ]+ * 0x0+00000 * 0x0+00000 [^ ]+ * [^ ]+ * R E * 0x.* - * LOAD * [^ ]+ * 0x0+10000 * 0x0+10000 [^ ]+ * [^ ]+ * RW * 0x.* - * DYNAMIC * [^ ]+ * 0x0+00400 * 0x0+00400 .* -+ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - * NULL * .* - - *Section to Segment mapping: -@@ -18,3 +19,4 @@ Program Headers: - *0*2 * .data .got * - *0*3 * .dynamic * - *0*4 * -+ *0*5 * ---- binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.sd -+++ binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.sd -@@ -1,7 +1,7 @@ - - Elf file type is EXEC (Executable file) - Entry point 0x44000 --There are 8 program headers, starting at offset .* -+There are [0-9] program headers, starting at offset .* - - Program Headers: - * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align -@@ -13,6 +13,7 @@ Program Headers: - * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* - * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* - * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* -+ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - * NULL * .* - - *Section to Segment mapping: -@@ -25,3 +26,4 @@ Program Headers: - *0*5 *.got .data * - *0*6 *.dynamic * - *0*7 * -+ *0*8 * ---- binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.sd -+++ binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.sd -@@ -1,7 +1,7 @@ - - Elf file type is EXEC (Executable file) - Entry point 0x44000 --There are 8 program headers, starting at offset .* -+There are [0-9] program headers, starting at offset .* - - Program Headers: - * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align -@@ -13,6 +13,7 @@ Program Headers: - * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* - * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* - * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* -+ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - * NULL * .* - - *Section to Segment mapping: -@@ -25,3 +26,4 @@ Program Headers: - *0*5 * .got .data .bss * - *0*6 * .dynamic * - *0*7 * -+ *0*8 * ---- binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.sd -+++ binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.sd -@@ -1,7 +1,7 @@ - - Elf file type is EXEC (Executable file) - Entry point 0x44000 --There are 8 program headers, starting at offset .* -+There are [0-9] program headers, starting at offset .* - - Program Headers: - * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align -@@ -13,6 +13,7 @@ Program Headers: - * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* - * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* - * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* -+ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - * NULL * .* - - *Section to Segment mapping: -@@ -25,3 +26,4 @@ Program Headers: - *0*5 * .got .data .bss * - *0*6 * .dynamic * - *0*7 * -+ *0*8 * ---- binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.sd -+++ binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.sd -@@ -1,7 +1,7 @@ - - Elf file type is EXEC (Executable file) - Entry point 0x44000 --There are 8 program headers, starting at offset .* -+There are [0-9] program headers, starting at offset .* - - Program Headers: - * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align -@@ -13,6 +13,7 @@ Program Headers: - * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* - * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* - * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* -+ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - * NULL * .* - - *Section to Segment mapping: -@@ -25,3 +26,4 @@ Program Headers: - *0*5 * .got .data .bss * - *0*6 * .dynamic * - *0*7 * -+ *0*8 * ---- binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.sd -+++ binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.sd -@@ -1,7 +1,7 @@ - - Elf file type is EXEC (Executable file) - Entry point 0x44000 --There are 7 program headers, starting at offset .* -+There are [0-9] program headers, starting at offset .* - - Program Headers: - * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align -@@ -12,6 +12,7 @@ Program Headers: - * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* - * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* - * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* -+ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - * NULL * .* - - *Section to Segment mapping: -@@ -23,3 +24,4 @@ Program Headers: - *0*4 * .got .data .bss * - *0*5 * .dynamic * - *0*6 * -+ *0*7 * ---- binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.sd -+++ binutils-2.22/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.sd -@@ -1,7 +1,7 @@ - - Elf file type is EXEC (Executable file) - Entry point 0x44000 --There are 8 program headers, starting at offset .* -+There are [0-9] program headers, starting at offset .* - - Program Headers: - * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align -@@ -13,6 +13,7 @@ Program Headers: - * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* - * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* - * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* -+ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - * NULL * .* - - *Section to Segment mapping: -@@ -25,3 +26,4 @@ Program Headers: - *0*5 * .got .data .bss * - *0*6 * .dynamic * - *0*7 * -+ *0*8 * ---- binutils-2.22/ld/testsuite/ld-mips-elf/rel32-n32.d -+++ binutils-2.22/ld/testsuite/ld-mips-elf/rel32-n32.d -@@ -10,6 +10,6 @@ Relocation section '.rel.dyn' at offset .* contains 2 entries: - [0-9a-f ]+R_MIPS_REL32 - - Hex dump of section '.text': -- 0x000002e0 00000000 00000000 00000000 00000000 ................ -- 0x000002f0 000002f0 00000000 00000000 00000000 ................ - 0x00000300 00000000 00000000 00000000 00000000 ................ -+ 0x00000310 00000310 00000000 00000000 00000000 ................ -+ 0x00000320 00000000 00000000 00000000 00000000 ................ ---- binutils-2.22/ld/testsuite/ld-mips-elf/rel32-o32.d -+++ binutils-2.22/ld/testsuite/ld-mips-elf/rel32-o32.d -@@ -10,6 +10,6 @@ Relocation section '.rel.dyn' at offset .* contains 2 entries: - [0-9a-f ]+R_MIPS_REL32 - - Hex dump of section '.text': -- 0x000002e0 00000000 00000000 00000000 00000000 ................ -- 0x000002f0 000002f0 00000000 00000000 00000000 ................ - 0x00000300 00000000 00000000 00000000 00000000 ................ -+ 0x00000310 00000310 00000000 00000000 00000000 ................ -+ 0x00000320 00000000 00000000 00000000 00000000 ................ ---- binutils-2.22/ld/testsuite/ld-mips-elf/rel64.d -+++ binutils-2.22/ld/testsuite/ld-mips-elf/rel64.d -@@ -14,6 +14,6 @@ Relocation section '.rel.dyn' at offset .* contains 2 entries: - +Type3: R_MIPS_NONE - - Hex dump of section '.text': -- 0x00000450 00000000 00000000 00000000 00000000 ................ -- 0x00000460 00000000 00000460 00000000 00000000 ................ -- 0x00000470 00000000 00000000 00000000 00000000 ................ -+ 0x00000490 00000000 00000000 00000000 00000000 ................ -+ 0x000004a0 00000000 000004a0 00000000 00000000 ................ -+ 0x000004b0 00000000 00000000 00000000 00000000 ................ ---- binutils-2.22/ld/testsuite/ld-mips-elf/tlsbin-o32.d -+++ binutils-2.22/ld/testsuite/ld-mips-elf/tlsbin-o32.d -@@ -2,42 +2,42 @@ - - Disassembly of section .text: - --004000d0 <__start>: -- 4000d0: 3c1c0fc0 lui gp,0xfc0 -- 4000d4: 279c7f30 addiu gp,gp,32560 -- 4000d8: 0399e021 addu gp,gp,t9 -- 4000dc: 27bdfff0 addiu sp,sp,-16 -- 4000e0: afbe0008 sw s8,8(sp) -- 4000e4: 03a0f021 move s8,sp -- 4000e8: afbc0000 sw gp,0(sp) -- 4000ec: 8f998018 lw t9,-32744(gp) -- 4000f0: 27848028 addiu a0,gp,-32728 -- 4000f4: 0320f809 jalr t9 -- 4000f8: 00000000 nop -- 4000fc: 8fdc0000 lw gp,0(s8) -- 400100: 00000000 nop -- 400104: 8f998018 lw t9,-32744(gp) -- 400108: 27848020 addiu a0,gp,-32736 -- 40010c: 0320f809 jalr t9 -- 400110: 00000000 nop -- 400114: 8fdc0000 lw gp,0(s8) -- 400118: 00401021 move v0,v0 -- 40011c: 3c030000 lui v1,0x0 -- 400120: 24638000 addiu v1,v1,-32768 -- 400124: 00621821 addu v1,v1,v0 -- 400128: 7c02283b rdhwr v0,$5 -- 40012c: 8f83801c lw v1,-32740(gp) -- 400130: 00000000 nop -- 400134: 00621821 addu v1,v1,v0 -- 400138: 7c02283b rdhwr v0,$5 -- 40013c: 3c030000 lui v1,0x0 -- 400140: 24639004 addiu v1,v1,-28668 -- 400144: 00621821 addu v1,v1,v0 -- 400148: 03c0e821 move sp,s8 -- 40014c: 8fbe0008 lw s8,8(sp) -- 400150: 03e00008 jr ra -- 400154: 27bd0010 addiu sp,sp,16 -+00400[0-9a-f]{3} <__start>: -+ 400[0-9a-f]{3}: 3c1c0fc0 lui gp,0xfc0 -+ 400[0-9a-f]{3}: 279c7f30 addiu gp,gp,32560 -+ 400[0-9a-f]{3}: 0399e021 addu gp,gp,t9 -+ 400[0-9a-f]{3}: 27bdfff0 addiu sp,sp,-16 -+ 400[0-9a-f]{3}: afbe0008 sw s8,8(sp) -+ 400[0-9a-f]{3}: 03a0f021 move s8,sp -+ 400[0-9a-f]{3}: afbc0000 sw gp,0(sp) -+ 400[0-9a-f]{3}: 8f998018 lw t9,-32744(gp) -+ 400[0-9a-f]{3}: 27848028 addiu a0,gp,-32728 -+ 400[0-9a-f]{3}: 0320f809 jalr t9 -+ 400[0-9a-f]{3}: 00000000 nop -+ 400[0-9a-f]{3}: 8fdc0000 lw gp,0(s8) -+ 400[0-9a-f]{3}: 00000000 nop -+ 400[0-9a-f]{3}: 8f998018 lw t9,-32744(gp) -+ 400[0-9a-f]{3}: 27848020 addiu a0,gp,-32736 -+ 400[0-9a-f]{3}: 0320f809 jalr t9 -+ 400[0-9a-f]{3}: 00000000 nop -+ 400[0-9a-f]{3}: 8fdc0000 lw gp,0(s8) -+ 400[0-9a-f]{3}: 00401021 move v0,v0 -+ 400[0-9a-f]{3}: 3c030000 lui v1,0x0 -+ 400[0-9a-f]{3}: 24638000 addiu v1,v1,-32768 -+ 400[0-9a-f]{3}: 00621821 addu v1,v1,v0 -+ 400[0-9a-f]{3}: 7c02283b rdhwr v0,$5 -+ 400[0-9a-f]{3}: 8f83801c lw v1,-32740(gp) -+ 400[0-9a-f]{3}: 00000000 nop -+ 400[0-9a-f]{3}: 00621821 addu v1,v1,v0 -+ 400[0-9a-f]{3}: 7c02283b rdhwr v0,$5 -+ 400[0-9a-f]{3}: 3c030000 lui v1,0x0 -+ 400[0-9a-f]{3}: 24639004 addiu v1,v1,-28668 -+ 400[0-9a-f]{3}: 00621821 addu v1,v1,v0 -+ 400[0-9a-f]{3}: 03c0e821 move sp,s8 -+ 400[0-9a-f]{3}: 8fbe0008 lw s8,8(sp) -+ 400[0-9a-f]{3}: 03e00008 jr ra -+ 400[0-9a-f]{3}: 27bd0010 addiu sp,sp,16 - --00400158 <__tls_get_addr>: -- 400158: 03e00008 jr ra -- 40015c: 00000000 nop -+00400[0-9a-f]{3} <__tls_get_addr>: -+ 400[0-9a-f]{3}: 03e00008 jr ra -+ 400[0-9a-f]{3}: 00000000 nop ---- binutils-2.22/ld/testsuite/ld-powerpc/tls.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tls.d -@@ -9,45 +9,45 @@ - - Disassembly of section .text: - --0+100000e8 <_start>: -- 100000e8: 3c 6d 00 00 addis r3,r13,0 -- 100000ec: 60 00 00 00 nop -- 100000f0: 38 63 90 78 addi r3,r3,-28552 -- 100000f4: 3c 6d 00 00 addis r3,r13,0 -- 100000f8: 60 00 00 00 nop -- 100000fc: 38 63 10 00 addi r3,r3,4096 -- 10000100: 3c 6d 00 00 addis r3,r13,0 -- 10000104: 60 00 00 00 nop -- 10000108: 38 63 90 40 addi r3,r3,-28608 -- 1000010c: 3c 6d 00 00 addis r3,r13,0 -- 10000110: 60 00 00 00 nop -- 10000114: 38 63 10 00 addi r3,r3,4096 -- 10000118: 39 23 80 48 addi r9,r3,-32696 -- 1000011c: 3d 23 00 00 addis r9,r3,0 -- 10000120: 81 49 80 50 lwz r10,-32688(r9) -- 10000124: e9 22 80 10 ld r9,-32752(r2) -- 10000128: 7d 49 18 2a ldx r10,r9,r3 -- 1000012c: 3d 2d 00 00 addis r9,r13,0 -- 10000130: a1 49 90 60 lhz r10,-28576(r9) -- 10000134: 89 4d 90 68 lbz r10,-28568(r13) -- 10000138: 3d 2d 00 00 addis r9,r13,0 -- 1000013c: 99 49 90 70 stb r10,-28560(r9) -- 10000140: 3c 6d 00 00 addis r3,r13,0 -- 10000144: 60 00 00 00 nop -- 10000148: 38 63 90 00 addi r3,r3,-28672 -- 1000014c: 3c 6d 00 00 addis r3,r13,0 -- 10000150: 60 00 00 00 nop -- 10000154: 38 63 10 00 addi r3,r3,4096 -- 10000158: f9 43 80 08 std r10,-32760(r3) -- 1000015c: 3d 23 00 00 addis r9,r3,0 -- 10000160: 91 49 80 10 stw r10,-32752(r9) -- 10000164: e9 22 80 08 ld r9,-32760(r2) -- 10000168: 7d 49 19 2a stdx r10,r9,r3 -- 1000016c: 3d 2d 00 00 addis r9,r13,0 -- 10000170: b1 49 90 60 sth r10,-28576(r9) -- 10000174: e9 4d 90 2a lwa r10,-28632(r13) -- 10000178: 3d 2d 00 00 addis r9,r13,0 -- 1000017c: a9 49 90 30 lha r10,-28624(r9) -+0+10000[0-9a-f]{3} <_start>: -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 78 addi r3,r3,-28552 -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 10 00 addi r3,r3,4096 -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 40 addi r3,r3,-28608 -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 10 00 addi r3,r3,4096 -+ 10000[0-9a-f]{3}: 39 23 80 48 addi r9,r3,-32696 -+ 10000[0-9a-f]{3}: 3d 23 00 00 addis r9,r3,0 -+ 10000[0-9a-f]{3}: 81 49 80 50 lwz r10,-32688(r9) -+ 10000[0-9a-f]{3}: e9 22 80 10 ld r9,-32752(r2) -+ 10000[0-9a-f]{3}: 7d 49 18 2a ldx r10,r9,r3 -+ 10000[0-9a-f]{3}: 3d 2d 00 00 addis r9,r13,0 -+ 10000[0-9a-f]{3}: a1 49 90 60 lhz r10,-28576(r9) -+ 10000[0-9a-f]{3}: 89 4d 90 68 lbz r10,-28568(r13) -+ 10000[0-9a-f]{3}: 3d 2d 00 00 addis r9,r13,0 -+ 10000[0-9a-f]{3}: 99 49 90 70 stb r10,-28560(r9) -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 00 addi r3,r3,-28672 -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 10 00 addi r3,r3,4096 -+ 10000[0-9a-f]{3}: f9 43 80 08 std r10,-32760(r3) -+ 10000[0-9a-f]{3}: 3d 23 00 00 addis r9,r3,0 -+ 10000[0-9a-f]{3}: 91 49 80 10 stw r10,-32752(r9) -+ 10000[0-9a-f]{3}: e9 22 80 08 ld r9,-32760(r2) -+ 10000[0-9a-f]{3}: 7d 49 19 2a stdx r10,r9,r3 -+ 10000[0-9a-f]{3}: 3d 2d 00 00 addis r9,r13,0 -+ 10000[0-9a-f]{3}: b1 49 90 60 sth r10,-28576(r9) -+ 10000[0-9a-f]{3}: e9 4d 90 2a lwa r10,-28632(r13) -+ 10000[0-9a-f]{3}: 3d 2d 00 00 addis r9,r13,0 -+ 10000[0-9a-f]{3}: a9 49 90 30 lha r10,-28624(r9) - --0+10000180 <.__tls_get_addr>: -- 10000180: 4e 80 00 20 blr -+0+10000[0-9a-f]{3} <.__tls_get_addr>: -+ 10000[0-9a-f]{3}: 4e 80 00 20 blr ---- binutils-2.22/ld/testsuite/ld-powerpc/tls.g -+++ binutils-2.22/ld/testsuite/ld-powerpc/tls.g -@@ -8,5 +8,5 @@ - .*: +file format elf64-powerpc - - Contents of section .got: -- 100101e0 00000000 100181e0 ffffffff ffff8018 .* -- 100101f0 ffffffff ffff8058 .* -+ 10010([0-9a-f]{3}) 00000000 10018\1 ffffffff ffff8018 .* -+ 10010[0-9a-f]{3} ffffffff ffff8058 .* ---- binutils-2.22/ld/testsuite/ld-powerpc/tls32.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tls32.d -@@ -9,42 +9,42 @@ - - Disassembly of section .text: - --0+1800094 <_start>: -- 1800094: 3c 62 00 00 addis r3,r2,0 -- 1800098: 38 63 90 3c addi r3,r3,-28612 -- 180009c: 3c 62 00 00 addis r3,r2,0 -- 18000a0: 38 63 10 00 addi r3,r3,4096 -- 18000a4: 3c 62 00 00 addis r3,r2,0 -- 18000a8: 38 63 90 20 addi r3,r3,-28640 -- 18000ac: 3c 62 00 00 addis r3,r2,0 -- 18000b0: 38 63 10 00 addi r3,r3,4096 -- 18000b4: 39 23 80 24 addi r9,r3,-32732 -- 18000b8: 3d 23 00 00 addis r9,r3,0 -- 18000bc: 81 49 80 28 lwz r10,-32728(r9) -- 18000c0: 3d 22 00 00 addis r9,r2,0 -- 18000c4: a1 49 90 30 lhz r10,-28624(r9) -- 18000c8: 89 42 90 34 lbz r10,-28620(r2) -- 18000cc: 3d 22 00 00 addis r9,r2,0 -- 18000d0: 99 49 90 38 stb r10,-28616(r9) -- 18000d4: 3c 62 00 00 addis r3,r2,0 -- 18000d8: 38 63 90 00 addi r3,r3,-28672 -- 18000dc: 3c 62 00 00 addis r3,r2,0 -- 18000e0: 38 63 10 00 addi r3,r3,4096 -- 18000e4: 91 43 80 04 stw r10,-32764(r3) -- 18000e8: 3d 23 00 00 addis r9,r3,0 -- 18000ec: 91 49 80 08 stw r10,-32760(r9) -- 18000f0: 3d 22 00 00 addis r9,r2,0 -- 18000f4: b1 49 90 30 sth r10,-28624(r9) -- 18000f8: a1 42 90 14 lhz r10,-28652(r2) -- 18000fc: 3d 22 00 00 addis r9,r2,0 -- 1800100: a9 49 90 18 lha r10,-28648(r9) -+0+1800[0-9a-f]{3} <_start>: -+ 1800[0-9a-f]{3}: 3c 62 00 00 addis r3,r2,0 -+ 1800[0-9a-f]{3}: 38 63 90 3c addi r3,r3,-28612 -+ 1800[0-9a-f]{3}: 3c 62 00 00 addis r3,r2,0 -+ 1800[0-9a-f]{3}: 38 63 10 00 addi r3,r3,4096 -+ 1800[0-9a-f]{3}: 3c 62 00 00 addis r3,r2,0 -+ 1800[0-9a-f]{3}: 38 63 90 20 addi r3,r3,-28640 -+ 1800[0-9a-f]{3}: 3c 62 00 00 addis r3,r2,0 -+ 1800[0-9a-f]{3}: 38 63 10 00 addi r3,r3,4096 -+ 1800[0-9a-f]{3}: 39 23 80 24 addi r9,r3,-32732 -+ 1800[0-9a-f]{3}: 3d 23 00 00 addis r9,r3,0 -+ 1800[0-9a-f]{3}: 81 49 80 28 lwz r10,-32728(r9) -+ 1800[0-9a-f]{3}: 3d 22 00 00 addis r9,r2,0 -+ 1800[0-9a-f]{3}: a1 49 90 30 lhz r10,-28624(r9) -+ 1800[0-9a-f]{3}: 89 42 90 34 lbz r10,-28620(r2) -+ 1800[0-9a-f]{3}: 3d 22 00 00 addis r9,r2,0 -+ 1800[0-9a-f]{3}: 99 49 90 38 stb r10,-28616(r9) -+ 1800[0-9a-f]{3}: 3c 62 00 00 addis r3,r2,0 -+ 1800[0-9a-f]{3}: 38 63 90 00 addi r3,r3,-28672 -+ 1800[0-9a-f]{3}: 3c 62 00 00 addis r3,r2,0 -+ 1800[0-9a-f]{3}: 38 63 10 00 addi r3,r3,4096 -+ 1800[0-9a-f]{3}: 91 43 80 04 stw r10,-32764(r3) -+ 1800[0-9a-f]{3}: 3d 23 00 00 addis r9,r3,0 -+ 1800[0-9a-f]{3}: 91 49 80 08 stw r10,-32760(r9) -+ 1800[0-9a-f]{3}: 3d 22 00 00 addis r9,r2,0 -+ 1800[0-9a-f]{3}: b1 49 90 30 sth r10,-28624(r9) -+ 1800[0-9a-f]{3}: a1 42 90 14 lhz r10,-28652(r2) -+ 1800[0-9a-f]{3}: 3d 22 00 00 addis r9,r2,0 -+ 1800[0-9a-f]{3}: a9 49 90 18 lha r10,-28648(r9) - --0+1800104 <__tls_get_addr>: -- 1800104: 4e 80 00 20 blr -+0+1800[0-9a-f]{3} <__tls_get_addr>: -+ 1800[0-9a-f]{3}: 4e 80 00 20 blr - Disassembly of section .got: - --0+1810128 <_GLOBAL_OFFSET_TABLE_-0x4>: -- 1810128: 4e 80 00 21 blrl -+0+1810[0-9a-f]{3} <_GLOBAL_OFFSET_TABLE_-0x4>: -+ 1810[0-9a-f]{3}: 4e 80 00 21 blrl - --0+181012c <_GLOBAL_OFFSET_TABLE_>: -+0+1810[0-9a-f]{3} <_GLOBAL_OFFSET_TABLE_>: - ... ---- binutils-2.22/ld/testsuite/ld-powerpc/tls32.g -+++ binutils-2.22/ld/testsuite/ld-powerpc/tls32.g -@@ -8,4 +8,4 @@ - .*: +file format elf32-powerpc - - Contents of section .got: -- 1810128 4e800021 00000000 00000000 00000000 .* -+ 18101[0-9a-f]{2} 4e800021 00000000 00000000 00000000 .* ---- binutils-2.22/ld/testsuite/ld-powerpc/tls32.t -+++ binutils-2.22/ld/testsuite/ld-powerpc/tls32.t -@@ -8,5 +8,5 @@ - .*: +file format elf32-powerpc - - Contents of section .tdata: -- 1810108 12345678 23456789 3456789a 456789ab .* -- 1810118 56789abc 6789abcd 789abcde 00c0ffee .* -+ 18101[0-9a-f]{2} 12345678 23456789 3456789a 456789ab .* -+ 18101[0-9a-f]{2} 56789abc 6789abcd 789abcde 00c0ffee .* ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsexe32.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsexe32.d -@@ -44,4 +44,4 @@ Disassembly of section .got: - .*: 4e 80 00 21 blrl - - .* <_GLOBAL_OFFSET_TABLE_>: --.*: 01 81 02 b8 00 00 00 00 00 00 00 00 .* -+.*: 01 81 02 [bd]8 00 00 00 00 00 00 00 00 .* ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsexe32.g -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsexe32.g -@@ -8,4 +8,4 @@ - - Contents of section .got: - .* 00000000 00000000 00000000 4e800021 .* --.* 018102b8 00000000 00000000 .* -+.* 018102[bd]8 00000000 00000000 .* ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsexe32.r -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsexe32.r -@@ -33,13 +33,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ - - Program Headers: - +Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align -- +PHDR +0x000034 0x01800034 0x01800034 0x000c0 0x000c0 R E 0x4 -- +INTERP +0x0000f4 0x018000f4 0x018000f4 0x00011 0x00011 R +0x1 -+ +PHDR +0x000034 0x01800034 0x01800034 (0x000[0-9a-f]{2}) \1 R E 0x4 -+ +INTERP +0x000([0-9a-f]{3}) 0x01800\1 0x01800\1 0x00011 0x00011 R +0x1 - +[Requesting program interpreter: .*] - +LOAD .* R E 0x10000 - +LOAD .* RWE 0x10000 - +DYNAMIC .* RW +0x4 - +TLS .* 0x0001c 0x00038 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -49,6 +50,7 @@ Program Headers: - +03 +.tdata .dynamic .got .plt - +04 +.dynamic - +05 +.tdata .tbss -+ +06 + - - Relocation section '.rela.dyn' at offset .* contains 2 entries: - Offset +Info +Type +Sym. Value +Symbol's Name + Addend ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsmark.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsmark.d -@@ -9,29 +9,29 @@ - - Disassembly of section .text: - --0+100000e8 <_start>: -- 100000e8: 48 00 00 18 b 10000100 <_start+0x18> -- 100000ec: 60 00 00 00 nop -- 100000f0: 38 63 90 00 addi r3,r3,-28672 -- 100000f4: e8 83 00 00 ld r4,0(r3) -- 100000f8: 3c 6d 00 00 addis r3,r13,0 -- 100000fc: 48 00 00 0c b 10000108 <_start+0x20> -- 10000100: 3c 6d 00 00 addis r3,r13,0 -- 10000104: 4b ff ff e8 b 100000ec <_start+0x4> -- 10000108: 60 00 00 00 nop -- 1000010c: 38 63 10 00 addi r3,r3,4096 -- 10000110: e8 83 80 00 ld r4,-32768(r3) -- 10000114: 3c 6d 00 00 addis r3,r13,0 -- 10000118: 48 00 00 0c b 10000124 <_start+0x3c> -- 1000011c: 3c 6d 00 00 addis r3,r13,0 -- 10000120: 48 00 00 14 b 10000134 <_start+0x4c> -- 10000124: 60 00 00 00 nop -- 10000128: 38 63 90 04 addi r3,r3,-28668 -- 1000012c: e8 a3 00 00 ld r5,0(r3) -- 10000130: 4b ff ff ec b 1000011c <_start+0x34> -- 10000134: 60 00 00 00 nop -- 10000138: 38 63 10 00 addi r3,r3,4096 -- 1000013c: e8 a3 80 04 ld r5,-32764(r3) -+0+10000[0-9a-f]{3} <_start>: -+ 10000[0-9a-f]{3}: 48 00 00 18 b 10000[0-9a-f]{3} <_start+0x18> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 00 addi r3,r3,-28672 -+ 10000[0-9a-f]{3}: e8 83 00 00 ld r4,0(r3) -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 48 00 00 0c b 10000[0-9a-f]{3} <_start+0x20> -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 4b ff ff e8 b 10000[0-9a-f]{3} <_start+0x4> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 10 00 addi r3,r3,4096 -+ 10000[0-9a-f]{3}: e8 83 80 00 ld r4,-32768(r3) -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 48 00 00 0c b 10000[0-9a-f]{3} <_start+0x3c> -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 48 00 00 14 b 10000[0-9a-f]{3} <_start+0x4c> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 04 addi r3,r3,-28668 -+ 10000[0-9a-f]{3}: e8 a3 00 00 ld r5,0(r3) -+ 10000[0-9a-f]{3}: 4b ff ff ec b 10000[0-9a-f]{3} <_start+0x34> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 10 00 addi r3,r3,4096 -+ 10000[0-9a-f]{3}: e8 a3 80 04 ld r5,-32764(r3) - --0+10000140 <.__tls_get_addr>: -- 10000140: 4e 80 00 20 blr -+0+10000[0-9a-f]{3} <.__tls_get_addr>: -+ 10000[0-9a-f]{3}: 4e 80 00 20 blr ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsmark32.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsmark32.d -@@ -9,17 +9,17 @@ - - Disassembly of section .text: - --0+1800094 <_start>: -- 1800094: 48 00 00 14 b 18000a8 <_start+0x14> -- 1800098: 38 63 90 00 addi r3,r3,-28672 -- 180009c: 80 83 00 00 lwz r4,0(r3) -- 18000a0: 3c 62 00 00 addis r3,r2,0 -- 18000a4: 48 00 00 0c b 18000b0 <_start+0x1c> -- 18000a8: 3c 62 00 00 addis r3,r2,0 -- 18000ac: 4b ff ff ec b 1800098 <_start+0x4> -- 18000b0: 38 63 10 00 addi r3,r3,4096 -- 18000b4: 80 83 80 00 lwz r4,-32768(r3) -+0+18000[0-9a-f]{2} <_start>: -+ 18000[0-9a-f]{2}: 48 00 00 14 b 18000[0-9a-f]{2} <_start+0x14> -+ 18000[0-9a-f]{2}: 38 63 90 00 addi r3,r3,-28672 -+ 18000[0-9a-f]{2}: 80 83 00 00 lwz r4,0(r3) -+ 18000[0-9a-f]{2}: 3c 62 00 00 addis r3,r2,0 -+ 18000[0-9a-f]{2}: 48 00 00 0c b 18000[0-9a-f]{2} <_start+0x1c> -+ 18000[0-9a-f]{2}: 3c 62 00 00 addis r3,r2,0 -+ 18000[0-9a-f]{2}: 4b ff ff ec b 18000[0-9a-f]{2} <_start+0x4> -+ 18000[0-9a-f]{2}: 38 63 10 00 addi r3,r3,4096 -+ 18000[0-9a-f]{2}: 80 83 80 00 lwz r4,-32768(r3) - --0+18000b8 <__tls_get_addr>: -- 18000b8: 4e 80 00 20 blr --#pass -\ No newline at end of file -+0+18000[0-9a-f]{2} <__tls_get_addr>: -+ 18000[0-9a-f]{2}: 4e 80 00 20 blr -+#pass ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsopt1.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsopt1.d -@@ -9,17 +9,17 @@ - - Disassembly of section .text: - --0+100000e8 <.__tls_get_addr>: -- 100000e8: 4e 80 00 20 blr -+0+10000[0-9a-f]{3} <.__tls_get_addr>: -+ 10000[0-9a-f]{3}: 4e 80 00 20 blr - - Disassembly of section .no_opt1: - --0+100000ec <.no_opt1>: -- 100000ec: 38 62 80 08 addi r3,r2,-32760 -- 100000f0: 2c 24 00 00 cmpdi r4,0 -- 100000f4: 41 82 00 10 beq- .* -- 100000f8: 4b ff ff f1 bl 100000e8 <.__tls_get_addr> -- 100000fc: 60 00 00 00 nop -- 10000100: 48 00 00 0c b .* -- 10000104: 4b ff ff e5 bl 100000e8 <.__tls_get_addr> -- 10000108: 60 00 00 00 nop -+0+10000[0-9a-f]{3} <.no_opt1>: -+ 10000[0-9a-f]{3}: 38 62 80 08 addi r3,r2,-32760 -+ 10000[0-9a-f]{3}: 2c 24 00 00 cmpdi r4,0 -+ 10000[0-9a-f]{3}: 41 82 00 10 beq- .* -+ 10000[0-9a-f]{3}: 4b ff ff f1 bl 10000[0-9a-f]{3} <.__tls_get_addr> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 48 00 00 0c b .* -+ 10000[0-9a-f]{3}: 4b ff ff e5 bl 10000[0-9a-f]{3} <.__tls_get_addr> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsopt1_32.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsopt1_32.d -@@ -9,16 +9,16 @@ - - Disassembly of section .text: - --0+1800094 <__tls_get_addr>: -- 1800094: 4e 80 00 20 blr -+0+18000[0-9a-f]{2} <__tls_get_addr>: -+ 18000[0-9a-f]{2}: 4e 80 00 20 blr - - Disassembly of section .no_opt1: - --0+1800098 <.no_opt1>: -- 1800098: 38 6d ff f4 addi r3,r13,-12 -- 180009c: 2c 04 00 00 cmpwi r4,0 -- 18000a0: 41 82 00 0c beq- .* -- 18000a4: 4b ff ff f1 bl 1800094 <__tls_get_addr> -- 18000a8: 48 00 00 08 b .* -- 18000ac: 4b ff ff e9 bl 1800094 <__tls_get_addr> -+0+18000[0-9a-f]{2} <.no_opt1>: -+ 18000[0-9a-f]{2}: 38 6d ff f4 addi r3,r13,-12 -+ 18000[0-9a-f]{2}: 2c 04 00 00 cmpwi r4,0 -+ 18000[0-9a-f]{2}: 41 82 00 0c beq- .* -+ 18000[0-9a-f]{2}: 4b ff ff f1 bl 18000[0-9a-f]{2} <__tls_get_addr> -+ 18000[0-9a-f]{2}: 48 00 00 08 b .* -+ 18000[0-9a-f]{2}: 4b ff ff e9 bl 18000[0-9a-f]{2} <__tls_get_addr> - #pass ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsopt2.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsopt2.d -@@ -9,15 +9,15 @@ - - Disassembly of section .text: - --0+100000e8 <.__tls_get_addr>: -- 100000e8: 4e 80 00 20 blr -+0+10000[0-9a-f]{3} <.__tls_get_addr>: -+ 10000[0-9a-f]{3}: 4e 80 00 20 blr - - Disassembly of section .no_opt2: - --0+100000ec <.no_opt2>: -- 100000ec: 38 62 80 08 addi r3,r2,-32760 -- 100000f0: 2c 24 00 00 cmpdi r4,0 -- 100000f4: 41 82 00 08 beq- .* -- 100000f8: 38 62 80 08 addi r3,r2,-32760 -- 100000fc: 4b ff ff ed bl 100000e8 <.__tls_get_addr> -- 10000100: 60 00 00 00 nop -+0+10000[0-9a-f]{3} <.no_opt2>: -+ 10000[0-9a-f]{3}: 38 62 80 08 addi r3,r2,-32760 -+ 10000[0-9a-f]{3}: 2c 24 00 00 cmpdi r4,0 -+ 10000[0-9a-f]{3}: 41 82 00 08 beq- .* -+ 10000[0-9a-f]{3}: 38 62 80 08 addi r3,r2,-32760 -+ 10000[0-9a-f]{3}: 4b ff ff ed bl 10000[0-9a-f]{3} <.__tls_get_addr> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsopt2_32.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsopt2_32.d -@@ -9,15 +9,15 @@ - - Disassembly of section .text: - --0+1800094 <__tls_get_addr>: -- 1800094: 4e 80 00 20 blr -+0+18000[0-9a-f]{2} <__tls_get_addr>: -+ 18000[0-9a-f]{2}: 4e 80 00 20 blr - - Disassembly of section .no_opt2: - --0+1800098 <.no_opt2>: -- 1800098: 38 6d ff f4 addi r3,r13,-12 -- 180009c: 2c 04 00 00 cmpwi r4,0 -- 18000a0: 41 82 00 08 beq- .* -- 18000a4: 38 6d ff f4 addi r3,r13,-12 -- 18000a8: 4b ff ff ed bl 1800094 <__tls_get_addr> -+0+18000[0-9a-f]{2} <.no_opt2>: -+ 18000[0-9a-f]{2}: 38 6d ff f4 addi r3,r13,-12 -+ 18000[0-9a-f]{2}: 2c 04 00 00 cmpwi r4,0 -+ 18000[0-9a-f]{2}: 41 82 00 08 beq- .* -+ 18000[0-9a-f]{2}: 38 6d ff f4 addi r3,r13,-12 -+ 18000[0-9a-f]{2}: 4b ff ff ed bl 18000[0-9a-f]{2} <__tls_get_addr> - #pass ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsopt3.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsopt3.d -@@ -9,18 +9,18 @@ - - Disassembly of section .text: - --00000000100000e8 <.__tls_get_addr>: -- 100000e8: 4e 80 00 20 blr -+0000000010000[0-9a-f]{3} <.__tls_get_addr>: -+ 10000[0-9a-f]{3}: 4e 80 00 20 blr - - Disassembly of section .no_opt3: - --00000000100000ec <.no_opt3>: -- 100000ec: 38 62 80 08 addi r3,r2,-32760 -- 100000f0: 48 00 00 0c b .* -- 100000f4: 38 62 80 18 addi r3,r2,-32744 -- 100000f8: 48 00 00 10 b .* -- 100000fc: 4b ff ff ed bl 100000e8 <.__tls_get_addr> -- 10000100: 60 00 00 00 nop -- 10000104: 48 00 00 0c b .* -- 10000108: 4b ff ff e1 bl 100000e8 <.__tls_get_addr> -- 1000010c: 60 00 00 00 nop -+0000000010000[0-9a-f]{3} <.no_opt3>: -+ 10000[0-9a-f]{3}: 38 62 80 08 addi r3,r2,-32760 -+ 10000[0-9a-f]{3}: 48 00 00 0c b .* -+ 10000[0-9a-f]{3}: 38 62 80 18 addi r3,r2,-32744 -+ 10000[0-9a-f]{3}: 48 00 00 10 b .* -+ 10000[0-9a-f]{3}: 4b ff ff ed bl 10000[0-9a-f]{3} <.__tls_get_addr> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 48 00 00 0c b .* -+ 10000[0-9a-f]{3}: 4b ff ff e1 bl 10000[0-9a-f]{3} <.__tls_get_addr> -+ 10000[0-9a-f]{3}: 60 00 00 00 nop ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsopt3_32.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsopt3_32.d -@@ -9,17 +9,17 @@ - - Disassembly of section .text: - --0+1800094 <__tls_get_addr>: -- 1800094: 4e 80 00 20 blr -+0+18000[0-9a-f]{2} <__tls_get_addr>: -+ 18000[0-9a-f]{2}: 4e 80 00 20 blr - - Disassembly of section .no_opt3: - --0+1800098 <.no_opt3>: -- 1800098: 38 6d ff ec addi r3,r13,-20 -- 180009c: 48 00 00 0c b .* -- 18000a0: 38 6d ff f4 addi r3,r13,-12 -- 18000a4: 48 00 00 0c b .* -- 18000a8: 4b ff ff ed bl 1800094 <__tls_get_addr> -- 18000ac: 48 00 00 08 b .* -- 18000b0: 4b ff ff e5 bl 1800094 <__tls_get_addr> -+0+18000[0-9a-f]{2} <.no_opt3>: -+ 18000[0-9a-f]{2}: 38 6d ff ec addi r3,r13,-20 -+ 18000[0-9a-f]{2}: 48 00 00 0c b .* -+ 18000[0-9a-f]{2}: 38 6d ff f4 addi r3,r13,-12 -+ 18000[0-9a-f]{2}: 48 00 00 0c b .* -+ 18000[0-9a-f]{2}: 4b ff ff ed bl 18000[0-9a-f]{2} <__tls_get_addr> -+ 18000[0-9a-f]{2}: 48 00 00 08 b .* -+ 18000[0-9a-f]{2}: 4b ff ff e5 bl 18000[0-9a-f]{2} <__tls_get_addr> - #pass ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsopt4.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsopt4.d -@@ -9,40 +9,40 @@ - - Disassembly of section .text: - --0+100000e8 <.__tls_get_addr>: -- 100000e8: 4e 80 00 20 blr -+0+10000[0-9a-f]{3} <.__tls_get_addr>: -+ 10000[0-9a-f]{3}: 4e 80 00 20 blr - - Disassembly of section .opt1: - --0+100000ec <.opt1>: -- 100000ec: 3c 6d 00 00 addis r3,r13,0 -- 100000f0: 2c 24 00 00 cmpdi r4,0 -- 100000f4: 41 82 00 10 beq- .* -- 100000f8: 60 00 00 00 nop -- 100000fc: 38 63 90 10 addi r3,r3,-28656 -- 10000100: 48 00 00 0c b .* -- 10000104: 60 00 00 00 nop -- 10000108: 38 63 90 10 addi r3,r3,-28656 -+0+10000[0-9a-f]{3} <.opt1>: -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 2c 24 00 00 cmpdi r4,0 -+ 10000[0-9a-f]{3}: 41 82 00 10 beq- .* -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 10 addi r3,r3,-28656 -+ 10000[0-9a-f]{3}: 48 00 00 0c b .* -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 10 addi r3,r3,-28656 - - Disassembly of section .opt2: - --0+1000010c <.opt2>: -- 1000010c: 3c 6d 00 00 addis r3,r13,0 -- 10000110: 2c 24 00 00 cmpdi r4,0 -- 10000114: 41 82 00 08 beq- .* -- 10000118: 3c 6d 00 00 addis r3,r13,0 -- 1000011c: 60 00 00 00 nop -- 10000120: 38 63 90 10 addi r3,r3,-28656 -+0+10000[0-9a-f]{3} <.opt2>: -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 2c 24 00 00 cmpdi r4,0 -+ 10000[0-9a-f]{3}: 41 82 00 08 beq- .* -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 10 addi r3,r3,-28656 - - Disassembly of section .opt3: - --0+10000124 <.opt3>: -- 10000124: 3c 6d 00 00 addis r3,r13,0 -- 10000128: 48 00 00 0c b .* -- 1000012c: 3c 6d 00 00 addis r3,r13,0 -- 10000130: 48 00 00 10 b .* -- 10000134: 60 00 00 00 nop -- 10000138: 38 63 90 10 addi r3,r3,-28656 -- 1000013c: 48 00 00 0c b .* -- 10000140: 60 00 00 00 nop -- 10000144: 38 63 90 08 addi r3,r3,-28664 -+0+10000[0-9a-f]{3} <.opt3>: -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 48 00 00 0c b .* -+ 10000[0-9a-f]{3}: 3c 6d 00 00 addis r3,r13,0 -+ 10000[0-9a-f]{3}: 48 00 00 10 b .* -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 10 addi r3,r3,-28656 -+ 10000[0-9a-f]{3}: 48 00 00 0c b .* -+ 10000[0-9a-f]{3}: 60 00 00 00 nop -+ 10000[0-9a-f]{3}: 38 63 90 08 addi r3,r3,-28664 ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsopt4_32.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsopt4_32.d -@@ -9,36 +9,36 @@ - - Disassembly of section .text: - --0+1800094 <__tls_get_addr>: -- 1800094: 4e 80 00 20 blr -+0+18000[0-9a-f]{2} <__tls_get_addr>: -+ 18000[0-9a-f]{2}: 4e 80 00 20 blr - - Disassembly of section .opt1: - --0+1800098 <.opt1>: -- 1800098: 3c 62 00 00 addis r3,r2,0 -- 180009c: 2c 04 00 00 cmpwi r4,0 -- 18000a0: 41 82 00 0c beq- .* -- 18000a4: 38 63 90 10 addi r3,r3,-28656 -- 18000a8: 48 00 00 08 b .* -- 18000ac: 38 63 90 10 addi r3,r3,-28656 -+0+18000[0-9a-f]{2} <.opt1>: -+ 18000[0-9a-f]{2}: 3c 62 00 00 addis r3,r2,0 -+ 18000[0-9a-f]{2}: 2c 04 00 00 cmpwi r4,0 -+ 18000[0-9a-f]{2}: 41 82 00 0c beq- .* -+ 18000[0-9a-f]{2}: 38 63 90 10 addi r3,r3,-28656 -+ 18000[0-9a-f]{2}: 48 00 00 08 b .* -+ 18000[0-9a-f]{2}: 38 63 90 10 addi r3,r3,-28656 - - Disassembly of section .opt2: - --0+18000b0 <.opt2>: -- 18000b0: 3c 62 00 00 addis r3,r2,0 -- 18000b4: 2c 04 00 00 cmpwi r4,0 -- 18000b8: 41 82 00 08 beq- .* -- 18000bc: 3c 62 00 00 addis r3,r2,0 -- 18000c0: 38 63 90 10 addi r3,r3,-28656 -+0+18000[0-9a-f]{2} <.opt2>: -+ 18000[0-9a-f]{2}: 3c 62 00 00 addis r3,r2,0 -+ 18000[0-9a-f]{2}: 2c 04 00 00 cmpwi r4,0 -+ 18000[0-9a-f]{2}: 41 82 00 08 beq- .* -+ 18000[0-9a-f]{2}: 3c 62 00 00 addis r3,r2,0 -+ 18000[0-9a-f]{2}: 38 63 90 10 addi r3,r3,-28656 - - Disassembly of section .opt3: - --0+18000c4 <.opt3>: -- 18000c4: 3c 62 00 00 addis r3,r2,0 -- 18000c8: 48 00 00 0c b .* -- 18000cc: 3c 62 00 00 addis r3,r2,0 -- 18000d0: 48 00 00 0c b .* -- 18000d4: 38 63 90 10 addi r3,r3,-28656 -- 18000d8: 48 00 00 08 b .* -- 18000dc: 38 63 90 08 addi r3,r3,-28664 -+0+18000[0-9a-f]{2} <.opt3>: -+ 18000[0-9a-f]{2}: 3c 62 00 00 addis r3,r2,0 -+ 18000[0-9a-f]{2}: 48 00 00 0c b .* -+ 18000[0-9a-f]{2}: 3c 62 00 00 addis r3,r2,0 -+ 18000[0-9a-f]{2}: 48 00 00 0c b .* -+ 18000[0-9a-f]{2}: 38 63 90 10 addi r3,r3,-28656 -+ 18000[0-9a-f]{2}: 48 00 00 08 b .* -+ 18000[0-9a-f]{2}: 38 63 90 08 addi r3,r3,-28664 - #pass ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsso32.d -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsso32.d -@@ -42,5 +42,5 @@ Disassembly of section .got: - .* <.got>: - ... - .*: 4e 80 00 21 blrl --.*: 00 01 03 ec .* -+.*: 00 01 [0-9a-f]{2} [0-9a-f]{2} .* - ... ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsso32.g -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsso32.g -@@ -9,5 +9,5 @@ - Contents of section .got: - .* 00000000 00000000 00000000 00000000 .* - .* 00000000 00000000 00000000 00000000 .* --.* 00000000 4e800021 000103ec 00000000 .* -+.* 00000000 4e800021 00010[0-9a-f]{3} 00000000 .* - .* 00000000 .* ---- binutils-2.22/ld/testsuite/ld-powerpc/tlsso32.r -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlsso32.r -@@ -35,6 +35,7 @@ Program Headers: - +LOAD .* RWE 0x10000 - +DYNAMIC .* RW +0x4 - +TLS .* 0x0+1c 0x0+38 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -42,6 +43,7 @@ Program Headers: - +01 +.tdata .dynamic .got .plt - +02 +.dynamic - +03 +.tdata .tbss -+ +04 + - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 18 entries: - Offset +Info +Type +Sym. Value +Symbol's Name + Addend -@@ -52,9 +54,9 @@ Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 18 entries: - [0-9a-f ]+R_PPC_TPREL16 +0+30 +le0 + 0 - [0-9a-f ]+R_PPC_TPREL16_HA +0+34 +le1 + 0 - [0-9a-f ]+R_PPC_TPREL16_LO +0+34 +le1 + 0 --[0-9a-f ]+R_PPC_TPREL16 +0+103d0 +.tdata + 103e4 --[0-9a-f ]+R_PPC_TPREL16_HA +0+103d0 +.tdata + 103e8 --[0-9a-f ]+R_PPC_TPREL16_LO +0+103d0 +.tdata + 103e8 -+[0-9a-f ]+R_PPC_TPREL16 +0+103[df]0 +.tdata + 10[0-9a-f]{3} -+[0-9a-f ]+R_PPC_TPREL16_HA +0+103[df]0 +.tdata + 10[0-9a-f]{3} -+[0-9a-f ]+R_PPC_TPREL16_LO +0+103[df]0 +.tdata + 10[0-9a-f]{3} - [0-9a-f ]+R_PPC_DTPMOD32 +0+ - [0-9a-f ]+R_PPC_DTPREL32 +0+ - [0-9a-f ]+R_PPC_DTPMOD32 +0+ ---- binutils-2.22/ld/testsuite/ld-powerpc/tlstoc.g -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlstoc.g -@@ -8,8 +8,8 @@ - .*: +file format elf64-powerpc - - Contents of section .got: -- 100101a0 00000000 00000001 00000000 00000000 .* -- 100101b0 00000000 00000001 00000000 00000000 .* -- 100101c0 00000000 00000001 00000000 00000000 .* -- 100101d0 00000000 00000001 00000000 00000000 .* -- 100101e0 ffffffff ffff8060 00000000 00000000 .* -+ 10010[0-9a-f]{3} 00000000 00000001 00000000 00000000 .* -+ 10010[0-9a-f]{3} 00000000 00000001 00000000 00000000 .* -+ 10010[0-9a-f]{3} 00000000 00000001 00000000 00000000 .* -+ 10010[0-9a-f]{3} 00000000 00000001 00000000 00000000 .* -+ 10010[0-9a-f]{3} ffffffff ffff8060 00000000 00000000 .* ---- binutils-2.22/ld/testsuite/ld-powerpc/tlstoc.t -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlstoc.t -@@ -8,7 +8,7 @@ - .*: +file format elf64-powerpc - - Contents of section .tdata: -- 10010148 00c0ffee 00000000 12345678 9abcdef0 .* -- 10010158 23456789 abcdef01 3456789a bcdef012 .* -- 10010168 456789ab cdef0123 56789abc def01234 .* -- 10010178 6789abcd ef012345 789abcde f0123456 .* -+ 10010180 00c0ffee 00000000 12345678 9abcdef0 .* -+ 10010190 23456789 abcdef01 3456789a bcdef012 .* -+ 100101a0 456789ab cdef0123 56789abc def01234 .* -+ 100101b0 6789abcd ef012345 789abcde f0123456 .* ---- binutils-2.22/ld/testsuite/ld-powerpc/tlstocso.g -+++ binutils-2.22/ld/testsuite/ld-powerpc/tlstocso.g -@@ -7,7 +7,7 @@ - .*: +file format elf64-powerpc - - Contents of section .got: --.* 00000000 000186c0 00000000 00000000 .* -+.* 00000000 000186f8 00000000 00000000 .* - .* 00000000 00000000 00000000 00000000 .* - .* 00000000 00000000 00000000 00000000 .* - .* 00000000 00000000 00000000 00000000 .* ---- binutils-2.22/ld/testsuite/ld-s390/tlsbin.rd -+++ binutils-2.22/ld/testsuite/ld-s390/tlsbin.rd -@@ -36,13 +36,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ - - Program Headers: - +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align -- +PHDR +0x0+34 0x0+400034 0x0+400034 0x0+c0 0x0+c0 R E 0x4 -- +INTERP +0x0+f4 0x0+4000f4 0x0+4000f4 0x0+11 0x0+11 R +0x1 -+ +PHDR +0x0+34 0x0+400034 0x0+400034 0x0+e0 0x0+e0 R E 0x4 -+ +INTERP +0x0+114 0x0+400114 0x0+400114 0x0+11 0x0+11 R +0x1 - .*Requesting program interpreter.* - +LOAD .* R E 0x1000 - +LOAD .* RW +0x1000 - +DYNAMIC .* RW +0x4 - +TLS .* 0x0+60 0x0+a0 R +0x20 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -52,6 +53,7 @@ Program Headers: - +03 +.tdata .dynamic .got * - +04 +.dynamic * - +05 +.tdata .tbss * -+ +06 + - - Relocation section '.rela.dyn' at offset .* contains 4 entries: - Offset +Info +Type +Sym.Value +Sym. Name + Addend ---- binutils-2.22/ld/testsuite/ld-s390/tlsbin_64.rd -+++ binutils-2.22/ld/testsuite/ld-s390/tlsbin_64.rd -@@ -36,13 +36,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ - - Program Headers: - +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align -- +PHDR +0x0+40 0x0+80000040 0x0+80000040 0x0+150 0x0+150 R E 0x8 -- +INTERP +0x0+190 0x0+80000190 0x0+80000190 0x0+11 0x0+11 R +0x1 -+ +PHDR +0x0+40 0x0+80000040 0x0+80000040 0x0+188 0x0+188 R E 0x8 -+ +INTERP +0x0+1c8 0x0+800001c8 0x0+800001c8 0x0+11 0x0+11 R +0x1 - .*Requesting program interpreter.* - +LOAD .* R E 0x1000 - +LOAD .* RW +0x1000 - +DYNAMIC .* RW +0x8 - +TLS .* 0x0+60 0x0+a0 R +0x20 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -52,6 +53,7 @@ Program Headers: - +03 +.tdata .dynamic .got * - +04 +.dynamic * - +05 +.tdata .tbss * -+ +06 + - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries: - +Offset +Info +Type +Symbol's Value +Symbol's Name + Addend ---- binutils-2.22/ld/testsuite/ld-s390/tlspic.rd -+++ binutils-2.22/ld/testsuite/ld-s390/tlspic.rd -@@ -39,6 +39,7 @@ Program Headers: - +LOAD .* RW +0x1000 - +DYNAMIC .* RW +0x4 - +TLS .* 0x0+60 0x0+80 R +0x20 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -46,6 +47,7 @@ Program Headers: - +01 +.tdata .dynamic .got - +02 +.dynamic - +03 +.tdata .tbss -+ +04 + - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: - Offset +Info +Type +Sym.Value +Sym. Name + Addend ---- binutils-2.22/ld/testsuite/ld-s390/tlspic_64.rd -+++ binutils-2.22/ld/testsuite/ld-s390/tlspic_64.rd -@@ -39,6 +39,7 @@ Program Headers: - +LOAD .* RW +0x1000 - +DYNAMIC .* RW +0x8 - +TLS .* 0x0+60 0x0+80 R +0x20 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -46,6 +47,7 @@ Program Headers: - +01 +.tdata .dynamic .got * - +02 +.dynamic * - +03 +.tdata .tbss * -+ +04 + - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: - +Offset +Info +Type +Symbol's Value +Symbol's Name + Addend ---- binutils-2.22/ld/testsuite/ld-scripts/empty-aligned.d -+++ binutils-2.22/ld/testsuite/ld-scripts/empty-aligned.d -@@ -8,7 +8,9 @@ - Program Headers: - +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg +Align - +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ [RWE ]+ +0x[0-9a-f]+ -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... - +00 +.text -+ +01 + ---- binutils-2.22/ld/testsuite/ld-sh/tlsbin-2.d -+++ binutils-2.22/ld/testsuite/ld-sh/tlsbin-2.d -@@ -44,6 +44,7 @@ Program Headers: - +LOAD.* - +DYNAMIC.* - +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+18 0x0+28 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -53,6 +54,7 @@ Program Headers: - +03 +.tdata .dynamic .got * - +04 +.dynamic * - +05 +.tdata .tbss * -+ +06 + - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries: - Offset +Info +Type +Sym.Value +Sym. Name + Addend ---- binutils-2.22/ld/testsuite/ld-sh/tlspic-2.d -+++ binutils-2.22/ld/testsuite/ld-sh/tlspic-2.d -@@ -32,7 +32,7 @@ Key to Flags: - - Elf file type is DYN (Shared object file) - Entry point 0x[0-9a-f]+ --There are 4 program headers, starting at offset [0-9]+ -+There are [0-9] program headers, starting at offset [0-9]+ - - Program Headers: - +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align -@@ -40,6 +40,7 @@ Program Headers: - +LOAD.* - +DYNAMIC.* - +TLS .* 0x0+18 0x0+20 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -47,6 +48,7 @@ Program Headers: - +01 +.tdata .dynamic .got * - +02 +.dynamic * - +03 +.tdata .tbss * -+ +04 + - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 10 entries: - Offset +Info +Type +Sym.Value +Sym. Name + Addend ---- binutils-2.22/ld/testsuite/ld-sparc/gotop32.rd -+++ binutils-2.22/ld/testsuite/ld-sparc/gotop32.rd -@@ -31,6 +31,7 @@ Program Headers: - +LOAD +0x0+ 0x0+ 0x0+ 0x0+2000 0x0+2000 R E 0x10000 - +LOAD +0x0+2000 0x0+12000 0x0+12000 0x0+2000 0x0+2000 RW +0x10000 - +DYNAMIC +0x0+2000 0x0+12000 0x0+12000 0x0+70 0x0+70 RW +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: ---- binutils-2.22/ld/testsuite/ld-sparc/gotop64.rd -+++ binutils-2.22/ld/testsuite/ld-sparc/gotop64.rd -@@ -31,6 +31,7 @@ Program Headers: - +LOAD +0x0+ 0x0+ 0x0+ 0x0+2000 0x0+2000 R E 0x100000 - +LOAD +0x0+2000 0x0+102000 0x0+102000 0x0+2000 0x0+2000 RW +0x100000 - +DYNAMIC +0x0+2000 0x0+102000 0x0+102000 0x0+e0 0x0+e0 RW +0x8 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: ---- binutils-2.22/ld/testsuite/ld-sparc/tlssunbin32.rd -+++ binutils-2.22/ld/testsuite/ld-sparc/tlssunbin32.rd -@@ -30,13 +30,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ - - Program Headers: - +Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align -- +PHDR +0x0+34 0x0+10034 0x0+10034 0x0+c0 0x0+c0 R E 0x4 -- +INTERP +0x0+f4 0x0+100f4 0x0+100f4 0x0+11 0x0+11 R +0x1 -+ +PHDR +0x0+34 0x0+10034 0x0+10034 (0x[0-9a-f]+) \1 R E 0x4 -+ +INTERP +(0x[0-9a-f]+ ){3}0x0+11 0x0+11 R +0x1 - .*Requesting program interpreter.* - +LOAD .* R E 0x10000 - +LOAD .* RW +0x10000 - +DYNAMIC .* RW +0x4 - +TLS .* 0x0+1060 0x0+10a0 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries: ---- binutils-2.22/ld/testsuite/ld-sparc/tlssunbin64.rd -+++ binutils-2.22/ld/testsuite/ld-sparc/tlssunbin64.rd -@@ -30,13 +30,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ - - Program Headers: - +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align -- +PHDR +0x0+40 0x0+100040 0x0+100040 0x0+150 0x0+150 R E 0x8 -- +INTERP +0x0+190 0x0+100190 0x0+100190 0x0+19 0x0+19 R +0x1 -+ +PHDR +0x0+40 0x0+100040 0x0+100040 (0x[0-9a-f]+) \1 R E 0x8 -+ +INTERP +0x0+([0-9a-f]+) (0x0+10+\1) \2 0x0+19 0x0+19 R +0x1 - .*Requesting program interpreter.* - +LOAD .* R E 0x100000 - +LOAD .* RW +0x100000 - +DYNAMIC .* RW +0x8 - +TLS .* 0x0+60 0x0+a0 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries: ---- binutils-2.22/ld/testsuite/ld-sparc/tlssunnopic32.rd -+++ binutils-2.22/ld/testsuite/ld-sparc/tlssunnopic32.rd -@@ -32,6 +32,7 @@ Program Headers: - +LOAD .* RW +0x10000 - +DYNAMIC .* RW +0x4 - +TLS .* 0x0+ 0x0+24 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 12 entries: ---- binutils-2.22/ld/testsuite/ld-sparc/tlssunnopic64.rd -+++ binutils-2.22/ld/testsuite/ld-sparc/tlssunnopic64.rd -@@ -32,6 +32,7 @@ Program Headers: - +LOAD .* RW +0x100000 - +DYNAMIC .* RW +0x8 - +TLS .* 0x0+ 0x0+24 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: ---- binutils-2.22/ld/testsuite/ld-sparc/tlssunpic32.rd -+++ binutils-2.22/ld/testsuite/ld-sparc/tlssunpic32.rd -@@ -36,6 +36,7 @@ Program Headers: - +LOAD +0x0+2000 0x0+12000 0x0+12000 0x0+184 0x0+184 RWE 0x10000 - +DYNAMIC +0x0+2060 0x0+12060 0x0+12060 0x0+98 0x0+98 RW +0x4 - +TLS +0x0+2000 0x0+12000 0x0+12000 0x0+60 0x0+80 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: ---- binutils-2.22/ld/testsuite/ld-sparc/tlssunpic64.rd -+++ binutils-2.22/ld/testsuite/ld-sparc/tlssunpic64.rd -@@ -36,6 +36,7 @@ Program Headers: - +LOAD +0x0+2000 0x0+102000 0x0+102000 0x0+3a0 0x0+3a0 RWE 0x100000 - +DYNAMIC +0x0+2060 0x0+102060 0x0+102060 0x0+130 0x0+130 RW +0x8 - +TLS +0x0+2000 0x0+102000 0x0+102000 0x0+60 0x0+80 R +0x4 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - #... - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: ---- binutils-2.22/ld/testsuite/ld-x86-64/protected3.d -+++ binutils-2.22/ld/testsuite/ld-x86-64/protected3.d -@@ -8,6 +8,6 @@ - Disassembly of section .text: - - 0+[a-f0-9]+ <bar>: --[ ]*[a-f0-9]+: 8b 05 [a-f0-9][a-f0-9] 00 [a-f0-9][a-f0-9] 00 mov 0x[a-f0-9]+(%rip),%eax # [a-f0-9]+ <foo> -+[ ]*[a-f0-9]+: 8b 05 [a-f0-9][a-f0-9] [a-f0-9][a-f0-9] [a-f0-9][a-f0-9] 00 mov 0x[a-f0-9]+(%rip),%eax # [a-f0-9]+ <foo> - [ ]*[a-f0-9]+: c3 retq - #pass ---- binutils-2.22/ld/testsuite/ld-x86-64/tlsgdesc.rd -+++ binutils-2.22/ld/testsuite/ld-x86-64/tlsgdesc.rd -@@ -36,12 +36,14 @@ Program Headers: - +LOAD.* - +LOAD.* - +DYNAMIC.* -+ +PAX_FLAGS.* - - Section to Segment mapping: - +Segment Sections... - +00 +.hash .dynsym .dynstr .rela.dyn .rela.plt .plt .text * - +01 +.dynamic .got .got.plt * - +02 +.dynamic * -+ +03 + - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 8 entries: - +Offset +Info +Type +Symbol's Value +Symbol's Name + Addend ---- binutils-2.22/ld/testsuite/ld-x86-64/tlspic.rd -+++ binutils-2.22/ld/testsuite/ld-x86-64/tlspic.rd -@@ -40,6 +40,7 @@ Program Headers: - +LOAD +0x0+11ac 0x0+2011ac 0x0+2011ac 0x0+244 0x0+244 RW +0x200000 - +DYNAMIC +0x0+1210 0x0+201210 0x0+201210 0x0+130 0x0+130 RW +0x8 - +TLS +0x0+11ac 0x0+2011ac 0x0+2011ac 0x0+60 0x0+80 R +0x1 -+ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] - - Section to Segment mapping: - +Segment Sections... -@@ -47,6 +48,7 @@ Program Headers: - +01 +.tdata .dynamic .got .got.plt * - +02 +.dynamic * - +03 +.tdata .tbss * -+ +04 + - - Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: - +Offset +Info +Type +Symbol's Value +Symbol's Name + Addend diff --git a/src/patches/binutils-2.24-pt-pax-flags-20131231.patch b/src/patches/binutils-2.24-pt-pax-flags-20131231.patch new file mode 100644 index 0000000..cfb2035 --- /dev/null +++ b/src/patches/binutils-2.24-pt-pax-flags-20131231.patch @@ -0,0 +1,1030 @@ +--- binutils-2.24/bfd/elf-bfd.h ++++ binutils-2.24/bfd/elf-bfd.h +@@ -1577,6 +1577,9 @@ struct elf_obj_tdata + /* Segment flags for the PT_GNU_STACK segment. */ + unsigned int stack_flags; + ++ /* Segment flags for the PT_PAX_FLAGS segment. */ ++ unsigned int pax_flags; ++ + /* This is set to TRUE if the object was created by the backend + linker. */ + bfd_boolean linker; +@@ -1707,6 +1707,7 @@ + #define elf_eh_frame_hdr(bfd) (elf_tdata(bfd) -> o->eh_frame_hdr) + #define elf_linker(bfd) (elf_tdata(bfd) -> o->linker) + #define elf_stack_flags(bfd) (elf_tdata(bfd) -> o->stack_flags) ++#define elf_pax_flags(bfd) (elf_tdata(bfd) -> o->pax_flags) + #define elf_shstrtab(bfd) (elf_tdata(bfd) -> o->strtab_ptr) + #define elf_onesymtab(bfd) (elf_tdata(bfd) -> symtab_section) + #define elf_symtab_shndx(bfd) (elf_tdata(bfd) -> symtab_shndx_section) +--- binutils-2.24/bfd/elf.c ++++ binutils-2.24/bfd/elf.c +@@ -1158,6 +1158,7 @@ get_segment_type (unsigned int p_type) + case PT_GNU_EH_FRAME: pt = "EH_FRAME"; break; + case PT_GNU_STACK: pt = "STACK"; break; + case PT_GNU_RELRO: pt = "RELRO"; break; ++ case PT_PAX_FLAGS: pt = "PAX_FLAGS"; break; + default: pt = NULL; break; + } + return pt; +@@ -2477,6 +2478,9 @@ bfd_section_from_phdr (bfd *abfd, Elf_Internal_Phdr *hdr, int hdr_index) + case PT_GNU_RELRO: + return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "relro"); + ++ case PT_PAX_FLAGS: ++ return _bfd_elf_make_section_from_phdr (abfd, hdr, hdr_index, "pax_flags"); ++ + default: + /* Check for any processor-specific program segment types. */ + bed = get_elf_backend_data (abfd); +@@ -3551,6 +3555,11 @@ get_program_header_size (bfd *abfd, struct bfd_link_info *info) + ++segs; + } + ++ { ++ /* We need a PT_PAX_FLAGS segment. */ ++ ++segs; ++ } ++ + for (s = abfd->sections; s != NULL; s = s->next) + { + if ((s->flags & SEC_LOAD) != 0 +@@ -4153,6 +4162,20 @@ _bfd_elf_map_sections_to_segments (bfd *abfd, struct bfd_link_info *info) + } + } + ++ { ++ amt = sizeof (struct elf_segment_map); ++ m = bfd_zalloc (abfd, amt); ++ if (m == NULL) ++ goto error_return; ++ m->next = NULL; ++ m->p_type = PT_PAX_FLAGS; ++ m->p_flags = elf_pax_flags (abfd); ++ m->p_flags_valid = 1; ++ ++ *pm = m; ++ pm = &m->next; ++ } ++ + free (sections); + elf_tdata (abfd)->segment_map = mfirst; + } +@@ -5417,7 +5440,8 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) + 6. PT_TLS segment includes only SHF_TLS sections. + 7. SHF_TLS sections are only in PT_TLS or PT_LOAD segments. + 8. PT_DYNAMIC should not contain empty sections at the beginning +- (with the possible exception of .dynamic). */ ++ (with the possible exception of .dynamic). ++ 9. PT_PAX_FLAGS segments do not include any sections. */ + #define IS_SECTION_IN_INPUT_SEGMENT(section, segment, bed) \ + ((((segment->p_paddr \ + ? IS_CONTAINED_BY_LMA (section, segment, segment->p_paddr) \ +@@ -5425,6 +5449,7 @@ rewrite_elf_program_header (bfd *ibfd, bfd *obfd) + && (section->flags & SEC_ALLOC) != 0) \ + || IS_NOTE (segment, section)) \ + && segment->p_type != PT_GNU_STACK \ ++ && segment->p_type != PT_PAX_FLAGS \ + && (segment->p_type != PT_TLS \ + || (section->flags & SEC_THREAD_LOCAL)) \ + && (segment->p_type == PT_LOAD \ +--- binutils-2.24/bfd/elflink.c ++++ binutils-2.24/bfd/elflink.c +@@ -5545,17 +5545,30 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, + && ! (*bed->elf_backend_always_size_sections) (output_bfd, info)) + return FALSE; + ++ elf_pax_flags (output_bfd) = PF_NORANDEXEC; ++ if (info->execheap) ++ elf_pax_flags (output_bfd) |= PF_NOMPROTECT; ++ else if (info->noexecheap) ++ elf_pax_flags (output_bfd) |= PF_MPROTECT; ++ + /* Determine any GNU_STACK segment requirements, after the backend + has had a chance to set a default segment size. */ + if (info->execstack) +- elf_stack_flags (output_bfd) = PF_R | PF_W | PF_X; ++ { ++ elf_stack_flags (output_bfd) = PF_R | PF_W | PF_X; ++ elf_pax_flags (output_bfd) |= PF_EMUTRAMP; ++ } + else if (info->noexecstack) +- elf_stack_flags (output_bfd) = PF_R | PF_W; ++ { ++ elf_stack_flags (output_bfd) = PF_R | PF_W; ++ elf_pax_flags (output_bfd) |= PF_NOEMUTRAMP; ++ } + else + { + bfd *inputobj; + asection *notesec = NULL; + int exec = 0; + ++ elf_pax_flags (output_bfd) |= PF_NOEMUTRAMP; + for (inputobj = info->input_bfds; + inputobj; + inputobj = inputobj->link_next) +@@ -5567,7 +5581,11 @@ bfd_elf_size_dynamic_sections (bfd *output_bfd, + if (s) + { + if (s->flags & SEC_CODE) +- exec = PF_X; ++ { ++ elf_pax_flags (output_bfd) &= ~PF_NOEMUTRAMP; ++ elf_pax_flags (output_bfd) |= PF_EMUTRAMP; ++ exec = PF_X; ++ } + notesec = s; + } + else if (bed->default_execstack) +--- binutils-2.24/binutils/readelf.c ++++ binutils-2.24/binutils/readelf.c +@@ -2740,6 +2740,7 @@ get_segment_type (unsigned long p_type) + return "GNU_EH_FRAME"; + case PT_GNU_STACK: return "GNU_STACK"; + case PT_GNU_RELRO: return "GNU_RELRO"; ++ case PT_PAX_FLAGS: return "PAX_FLAGS"; + + default: + if ((p_type >= PT_LOPROC) && (p_type <= PT_HIPROC)) +--- binutils-2.24/include/bfdlink.h ++++ binutils-2.24/include/bfdlink.h +@@ -322,6 +322,14 @@ struct bfd_link_info + /* TRUE if PT_GNU_RELRO segment should be created. */ + unsigned int relro: 1; + ++ /* TRUE if PT_PAX_FLAGS segment should be created with PF_NOMPROTECT ++ flags. */ ++ unsigned int execheap: 1; ++ ++ /* TRUE if PT_PAX_FLAGS segment should be created with PF_MPROTECT ++ flags. */ ++ unsigned int noexecheap: 1; ++ + /* TRUE if .eh_frame_hdr section and PT_GNU_EH_FRAME ELF segment + should be created. */ + unsigned int eh_frame_hdr: 1; +--- binutils-2.24/include/elf/common.h ++++ binutils-2.24/include/elf/common.h +@@ -429,6 +429,7 @@ + #define PT_SUNW_EH_FRAME PT_GNU_EH_FRAME /* Solaris uses the same value */ + #define PT_GNU_STACK (PT_LOOS + 0x474e551) /* Stack flags */ + #define PT_GNU_RELRO (PT_LOOS + 0x474e552) /* Read-only after relocation */ ++#define PT_PAX_FLAGS (PT_LOOS + 0x5041580) /* PaX flags */ + + /* Program segment permissions, in program header p_flags field. */ + +@@ -439,6 +440,21 @@ + #define PF_MASKOS 0x0FF00000 /* New value, Oct 4, 1999 Draft */ + #define PF_MASKPROC 0xF0000000 /* Processor-specific reserved bits */ + ++/* Flags to control PaX behavior. */ ++ ++#define PF_PAGEEXEC (1 << 4) /* Enable PAGEEXEC */ ++#define PF_NOPAGEEXEC (1 << 5) /* Disable PAGEEXEC */ ++#define PF_SEGMEXEC (1 << 6) /* Enable SEGMEXEC */ ++#define PF_NOSEGMEXEC (1 << 7) /* Disable SEGMEXEC */ ++#define PF_MPROTECT (1 << 8) /* Enable MPROTECT */ ++#define PF_NOMPROTECT (1 << 9) /* Disable MPROTECT */ ++#define PF_RANDEXEC (1 << 10) /* Enable RANDEXEC */ ++#define PF_NORANDEXEC (1 << 11) /* Disable RANDEXEC */ ++#define PF_EMUTRAMP (1 << 12) /* Enable EMUTRAMP */ ++#define PF_NOEMUTRAMP (1 << 13) /* Disable EMUTRAMP */ ++#define PF_RANDMMAP (1 << 14) /* Enable RANDMMAP */ ++#define PF_NORANDMMAP (1 << 15) /* Disable RANDMMAP */ ++ + /* Values for section header, sh_type field. */ + + #define SHT_NULL 0 /* Section header table entry unused */ +--- binutils-2.24/ld/emultempl/elf32.em ++++ binutils-2.24/ld/emultempl/elf32.em +@@ -2285,6 +2285,16 @@ fragment <<EOF + link_info.noexecstack = TRUE; + link_info.execstack = FALSE; + } ++ else if (strcmp (optarg, "execheap") == 0) ++ { ++ link_info.execheap = TRUE; ++ link_info.noexecheap = FALSE; ++ } ++ else if (strcmp (optarg, "noexecheap") == 0) ++ { ++ link_info.noexecheap = TRUE; ++ link_info.execheap = FALSE; ++ } + EOF + if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then + fragment <<EOF +@@ -2368,6 +2378,8 @@ fragment <<EOF + -z defs Report unresolved symbols in object files.\n")); + fprintf (file, _("\ + -z execstack Mark executable as requiring executable stack\n")); ++ fprintf (file, _("\ ++ -z execheap Mark executable as requiring executable heap\n")); + EOF + + if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then +@@ -2391,6 +2403,8 @@ fragment <<EOF + fragment <<EOF + fprintf (file, _("\ + -z noexecstack Mark executable as not requiring executable stack\n")); ++ fprintf (file, _("\ ++ -z noexecheap Mark executable as not requiring executable heap\n")); + EOF + if test x"$GENERATE_SHLIB_SCRIPT" = xyes; then + fragment <<EOF +--- binutils-2.24/ld/ldgram.y ++++ binutils-2.24/ld/ldgram.y +@@ -1119,6 +1119,8 @@ phdr_type: + $$ = exp_intop (0x6474e550); + else if (strcmp (s, "PT_GNU_STACK") == 0) + $$ = exp_intop (0x6474e551); ++ else if (strcmp (s, "PT_PAX_FLAGS") == 0) ++ $$ = exp_intop (0x65041580); + else + { + einfo (_("\ +--- binutils-2.24/ld/testsuite/ld-alpha/tlsbin.rd ++++ binutils-2.24/ld/testsuite/ld-alpha/tlsbin.rd +@@ -35,13 +35,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ + + Program Headers: + Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align +- PHDR +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+150 R E 0x8 ++ PHDR +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+188 R E 0x8 + INTERP +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1 + .*Requesting program interpreter.* + LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R E 0x10000 + LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x10000 + DYNAMIC +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RW +0x8 + TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 3 entries: +--- binutils-2.24/ld/testsuite/ld-alpha/tlsbinr.rd ++++ binutils-2.24/ld/testsuite/ld-alpha/tlsbinr.rd +@@ -42,6 +42,7 @@ Program Headers: + +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x10000 + +DYNAMIC +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RW +0x8 + +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 2 entries: +--- binutils-2.24/ld/testsuite/ld-alpha/tlspic.rd ++++ binutils-2.24/ld/testsuite/ld-alpha/tlspic.rd +@@ -38,6 +38,7 @@ Program Headers: + +LOAD +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x10000 + +DYNAMIC +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ RW +0x8 + +TLS +0x0+10e0 0x0+110e0 0x0+110e0 0x0+60 0x0+80 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 7 entries: +--- binutils-2.24/ld/testsuite/ld-elf/eh1.d ++++ binutils-2.24/ld/testsuite/ld-elf/eh1.d +@@ -22,11 +22,11 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078 +- DW_CFA_advance_loc: 0 to 0+400078 ++0+0018 0+001c 0+001c FDE cie=0+0000 pc=([0-9a-f]+)..\1 ++ DW_CFA_advance_loc: 0 to [0-9a-f]+ + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r6 (rbp) at cfa-16 +- DW_CFA_advance_loc: 0 to 0+400078 ++ DW_CFA_advance_loc: 0 to [0-9a-f]+ + DW_CFA_def_cfa_register: r6 (rbp) + + 0+0038 ZERO terminator +--- binutils-2.24/ld/testsuite/ld-elf/eh2.d ++++ binutils-2.24/ld/testsuite/ld-elf/eh2.d +@@ -22,11 +22,11 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078 +- DW_CFA_advance_loc: 0 to 0+400078 ++0+0018 0+001c 0+001c FDE cie=0+0000 pc=([0-9a-f]+)..\1 ++ DW_CFA_advance_loc: 0 to [0-9a-f]+ + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r6 (rbp) at cfa-16 +- DW_CFA_advance_loc: 0 to 0+400078 ++ DW_CFA_advance_loc: 0 to [0-9a-f]+ + DW_CFA_def_cfa_register: r6 (rbp) + + 0+0038 ZERO terminator +--- binutils-2.24/ld/testsuite/ld-elf/eh3.d ++++ binutils-2.24/ld/testsuite/ld-elf/eh3.d +@@ -22,11 +22,11 @@ Contents of the .eh_frame section: + DW_CFA_nop + DW_CFA_nop + +-0+0018 0+001c 0+001c FDE cie=0+0000 pc=0+400078..0+400078 +- DW_CFA_advance_loc: 0 to 0+400078 ++0+0018 0+001c 0+001c FDE cie=0+0000 pc=([0-9a-f]+)..\1 ++ DW_CFA_advance_loc: 0 to [0-9a-f]+ + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r6 (rbp) at cfa-16 +- DW_CFA_advance_loc: 0 to 0+400078 ++ DW_CFA_advance_loc: 0 to [0-9a-f]+ + DW_CFA_def_cfa_register: r6 (rbp) + + 0+0038 ZERO terminator +--- binutils-2.24/ld/testsuite/ld-elf/orphan-region.d ++++ binutils-2.24/ld/testsuite/ld-elf/orphan-region.d +@@ -15,7 +15,9 @@ + Program Headers: + Type.* + LOAD[ \t]+0x[0-9a-f]+ 0x0*40000000 0x0*40000000 0x[0-9a-f]+ 0x[0-9a-f]+ RWE 0x[0-9a-f]+ ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + Segment Sections... + 00 .text .rodata .moredata * ++ 01 + +--- binutils-2.24/ld/testsuite/ld-i386/tlsbin.rd ++++ binutils-2.24/ld/testsuite/ld-i386/tlsbin.rd +@@ -44,6 +44,7 @@ Program Headers: + +LOAD.* + +DYNAMIC.* + +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+60 0x0+a0 R +0x1000 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -53,6 +54,7 @@ Program Headers: + +03 +.tdata .dynamic .got .got.plt * + +04 +.dynamic * + +05 +.tdata .tbss * ++ +06 + + + Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 9 entries: + Offset +Info +Type +Sym.Value +Sym. Name +--- binutils-2.24/ld/testsuite/ld-i386/tlsbindesc.rd ++++ binutils-2.24/ld/testsuite/ld-i386/tlsbindesc.rd +@@ -42,6 +42,7 @@ Program Headers: + +LOAD.* + +DYNAMIC.* + +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+60 0x0+a0 R +0x1000 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -51,6 +52,7 @@ Program Headers: + +03 +.tdata .dynamic .got .got.plt * + +04 +.dynamic * + +05 +.tdata .tbss * ++ +06 + + + Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 9 entries: + Offset +Info +Type +Sym.Value +Sym. Name +--- binutils-2.24/ld/testsuite/ld-i386/tlsdesc.rd ++++ binutils-2.24/ld/testsuite/ld-i386/tlsdesc.rd +@@ -39,6 +39,7 @@ Program Headers: + +LOAD.* + +DYNAMIC.* + +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+60 0x0+80 R +0x1 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -46,6 +47,7 @@ Program Headers: + +01 +.tdata .dynamic .got .got.plt * + +02 +.dynamic * + +03 +.tdata .tbss * ++ +04 + + + Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 20 entries: + Offset +Info +Type +Sym.Value +Sym. Name +--- binutils-2.24/ld/testsuite/ld-i386/tlsgdesc.rd ++++ binutils-2.24/ld/testsuite/ld-i386/tlsgdesc.rd +@@ -36,12 +36,14 @@ Program Headers: + +LOAD.* + +LOAD.* + +DYNAMIC.* ++ +PAX_FLAGS.* + + Section to Segment mapping: + +Segment Sections... + +00 +.hash .dynsym .dynstr .rel.dyn .rel.plt .plt .text * + +01 +.dynamic .got .got.plt * + +02 +.dynamic * ++ +03 + + + Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 8 entries: + Offset +Info +Type +Sym.Value +Sym. Name +--- binutils-2.24/ld/testsuite/ld-i386/tlsnopic.rd ++++ binutils-2.24/ld/testsuite/ld-i386/tlsnopic.rd +@@ -37,6 +37,7 @@ Program Headers: + +LOAD.* + +DYNAMIC.* + +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+ 0x0+24 R +0x1 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -44,6 +45,7 @@ Program Headers: + +01 +.dynamic .got .got.plt * + +02 +.dynamic * + +03 +.tbss * ++ +04 + + + Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 20 entries: + Offset +Info +Type +Sym.Value +Sym. Name +--- binutils-2.24/ld/testsuite/ld-i386/tlspic.rd ++++ binutils-2.24/ld/testsuite/ld-i386/tlspic.rd +@@ -40,6 +40,7 @@ Program Headers: + +LOAD.* + +DYNAMIC.* + +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+60 0x0+80 R +0x1 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -47,6 +48,7 @@ Program Headers: + +01 +.tdata .dynamic .got .got.plt * + +02 +.dynamic * + +03 +.tdata .tbss * ++ +04 + + + Relocation section '.rel.dyn' at offset 0x[0-9a-f]+ contains 26 entries: + Offset +Info +Type +Sym.Value +Sym. Name +--- binutils-2.24/ld/testsuite/ld-ia64/merge1.d ++++ binutils-2.24/ld/testsuite/ld-ia64/merge1.d +@@ -4,7 +4,7 @@ + #objdump: -d + + #... +-0+1e0 <.text>: ++[a-f0-9]+ <.text>: + [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; + [ ]*[a-f0-9]+: c0 c0 04 00 48 00 addl r12=24,r1 + [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; +--- binutils-2.24/ld/testsuite/ld-ia64/merge2.d ++++ binutils-2.24/ld/testsuite/ld-ia64/merge2.d +@@ -4,7 +4,7 @@ + #objdump: -d + + #... +-0+1e0 <.text>: ++[a-f0-9]+ <.text>: + [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; + [ ]*[a-f0-9]+: c0 c0 04 00 48 00 addl r12=24,r1 + [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; +--- binutils-2.24/ld/testsuite/ld-ia64/merge3.d ++++ binutils-2.24/ld/testsuite/ld-ia64/merge3.d +@@ -4,7 +4,7 @@ + #objdump: -d + + #... +-0+210 <.text>: ++[a-f0-9]+ <.text>: + [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; + [ ]*[a-f0-9]+: c0 40 05 00 48 00 addl r12=40,r1 + [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; +--- binutils-2.24/ld/testsuite/ld-ia64/merge4.d ++++ binutils-2.24/ld/testsuite/ld-ia64/merge4.d +@@ -4,7 +4,7 @@ + #objdump: -d + + #... +-0+240 <.text>: ++[a-f0-9]+ <.text>: + [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; + [ ]*[a-f0-9]+: c0 40 05 00 48 00 addl r12=40,r1 + [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; +--- binutils-2.24/ld/testsuite/ld-ia64/merge5.d ++++ binutils-2.24/ld/testsuite/ld-ia64/merge5.d +@@ -4,7 +4,7 @@ + #objdump: -d + + #... +-0+270 <.text>: ++[a-f0-9]+ <.text>: + [ ]*[a-f0-9]+: 0b 60 80 02 00 24 [MMI] addl r12=32,r1;; + [ ]*[a-f0-9]+: c0 40 05 00 48 00 addl r12=40,r1 + [ ]*[a-f0-9]+: 00 00 04 00 nop.i 0x0;; +--- binutils-2.24/ld/testsuite/ld-ia64/tlsbin.rd ++++ binutils-2.24/ld/testsuite/ld-ia64/tlsbin.rd +@@ -36,13 +36,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ + + Program Headers: + +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align +- +PHDR +0x0+40 0x40+40 0x40+40 0x0+188 0x0+188 R E 0x8 +- +INTERP +0x0+1c8 0x40+1c8 0x40+1c8 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1 ++ +PHDR +0x0+40 0x40+40 0x40+40 (0x[0-9a-f]+) \1 R E 0x8 ++ +INTERP +0x0+([0-9a-f]+) (0x40+\1) \2 0x[0-9a-f]+ 0x[0-9a-f]+ R +0x1 + .*Requesting program interpreter.* + +LOAD +0x0+ 0x40+ 0x40+ 0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ R E 0x10000 + +LOAD +0x0+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x0+0[0-9a-f]+ 0x0+0[0-9a-f]+ RW +0x10000 + +DYNAMIC +0x0+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x0+150 0x0+150 RW +0x8 + +TLS +0x0+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x60+1[0-9a-f]+ 0x0+60 0x0+a0 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + +IA_64_UNWIND .* R +0x8 + #... + +--- binutils-2.24/ld/testsuite/ld-ia64/tlspic.rd ++++ binutils-2.24/ld/testsuite/ld-ia64/tlspic.rd +@@ -40,6 +40,7 @@ Program Headers: + +LOAD +0x0+1[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+0[0-9a-f]+ 0x0+0[0-9a-f]+ RW +0x10000 + +DYNAMIC +0x0+1[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+140 0x0+140 RW +0x8 + +TLS +0x0+1[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+11[0-9a-f]+ 0x0+60 0x0+80 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + +IA_64_UNWIND +0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ 0x0+1[0-9a-f]+ 0x0+18 0x0+18 R +0x8 + #... + +--- binutils-2.24/ld/testsuite/ld-mips-elf/multi-got-no-shared.d ++++ binutils-2.24/ld/testsuite/ld-mips-elf/multi-got-no-shared.d +@@ -8,9 +8,9 @@ + .*: +file format.* + + Disassembly of section .text: +-004000b0 <[^>]*> 3c1c0043 lui gp,0x43 +-004000b4 <[^>]*> 279c9ff0 addiu gp,gp,-24592 +-004000b8 <[^>]*> afbc0008 sw gp,8(sp) ++004000d0 <[^>]*> 3c1c0043 lui gp,0x43 ++004000d4 <[^>]*> 279c9ff0 addiu gp,gp,-24592 ++004000d8 <[^>]*> afbc0008 sw gp,8(sp) + #... + 00408d60 <[^>]*> 3c1c0043 lui gp,0x43 + 00408d64 <[^>]*> 279c2c98 addiu gp,gp,11416 +--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.sd ++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-3a.sd +@@ -1,7 +1,7 @@ + + Elf file type is DYN (Shared object file) + Entry point .* +-There are 5 program headers, starting at offset .* ++There are [0-9] program headers, starting at offset .* + + Program Headers: + * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align +@@ -9,6 +9,7 @@ Program Headers: + * LOAD * [^ ]+ * 0x0+00000 * 0x0+00000 [^ ]+ * [^ ]+ * R E * 0x.* + * LOAD * [^ ]+ * 0x0+10000 * 0x0+10000 [^ ]+ * [^ ]+ * RW * 0x.* + * DYNAMIC * [^ ]+ * 0x0+00400 * 0x0+00400 .* ++ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + * NULL * .* + + *Section to Segment mapping: +@@ -18,3 +19,4 @@ Program Headers: + *0*2 * .data .got * + *0*3 * .dynamic * + *0*4 * ++ *0*5 * +--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.sd ++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-3b.sd +@@ -1,7 +1,7 @@ + + Elf file type is EXEC (Executable file) + Entry point 0x44000 +-There are 8 program headers, starting at offset .* ++There are [0-9] program headers, starting at offset .* + + Program Headers: + * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align +@@ -13,6 +13,7 @@ Program Headers: + * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* + * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* + * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* ++ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + * NULL * .* + + *Section to Segment mapping: +@@ -25,3 +26,4 @@ Program Headers: + *0*5 *.got .data * + *0*6 *.dynamic * + *0*7 * ++ *0*8 * +--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.sd ++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-4b.sd +@@ -1,7 +1,7 @@ + + Elf file type is EXEC (Executable file) + Entry point 0x44000 +-There are 8 program headers, starting at offset .* ++There are [0-9] program headers, starting at offset .* + + Program Headers: + * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align +@@ -13,6 +13,7 @@ Program Headers: + * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* + * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* + * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* ++ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + * NULL * .* + + *Section to Segment mapping: +@@ -25,3 +26,4 @@ Program Headers: + *0*5 * .got .data .bss * + *0*6 * .dynamic * + *0*7 * ++ *0*8 * +--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.sd ++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-5b.sd +@@ -1,7 +1,7 @@ + + Elf file type is EXEC (Executable file) + Entry point 0x44000 +-There are 8 program headers, starting at offset .* ++There are [0-9] program headers, starting at offset .* + + Program Headers: + * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align +@@ -13,6 +13,7 @@ Program Headers: + * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* + * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* + * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* ++ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + * NULL * .* + + *Section to Segment mapping: +@@ -25,3 +26,4 @@ Program Headers: + *0*5 * .got .data .bss * + *0*6 * .dynamic * + *0*7 * ++ *0*8 * +--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.sd ++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n32.sd +@@ -1,7 +1,7 @@ + + Elf file type is EXEC (Executable file) + Entry point 0x44000 +-There are 8 program headers, starting at offset .* ++There are [0-9] program headers, starting at offset .* + + Program Headers: + * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align +@@ -13,6 +13,7 @@ Program Headers: + * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* + * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* + * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* ++ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + * NULL * .* + + *Section to Segment mapping: +@@ -25,3 +26,4 @@ Program Headers: + *0*5 * .got .data .bss * + *0*6 * .dynamic * + *0*7 * ++ *0*8 * +--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.sd ++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-n64.sd +@@ -1,7 +1,7 @@ + + Elf file type is EXEC (Executable file) + Entry point 0x44000 +-There are 7 program headers, starting at offset .* ++There are [0-9] program headers, starting at offset .* + + Program Headers: + * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align +@@ -12,6 +12,7 @@ Program Headers: + * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* + * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* + * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* ++ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + * NULL * .* + + *Section to Segment mapping: +@@ -23,3 +24,4 @@ Program Headers: + *0*4 * .got .data .bss * + *0*5 * .dynamic * + *0*6 * ++ *0*7 * +--- binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.sd ++++ binutils-2.24/ld/testsuite/ld-mips-elf/pic-and-nonpic-6-o32.sd +@@ -1,7 +1,7 @@ + + Elf file type is EXEC (Executable file) + Entry point 0x44000 +-There are 8 program headers, starting at offset .* ++There are [0-9] program headers, starting at offset .* + + Program Headers: + * Type * Offset * VirtAddr * PhysAddr * FileSiz * MemSiz * Flg * Align +@@ -13,6 +13,7 @@ Program Headers: + * LOAD * [^ ]+ * 0x0+80000 * 0x0+80000 [^ ]+ * [^ ]+ * RW * 0x.* + * LOAD * [^ ]+ * 0x0+a0000 * 0x0+a0000 [^ ]+ * [^ ]+ * RW * 0x.* + * DYNAMIC * [^ ]+ * 0x0+42000 * 0x0+42000 .* ++ * PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + * NULL * .* + + *Section to Segment mapping: +@@ -25,3 +26,4 @@ Program Headers: + *0*5 * .got .data .bss * + *0*6 * .dynamic * + *0*7 * ++ *0*8 * +--- binutils-2.24/ld/testsuite/ld-powerpc/tlsexe32.r ++++ binutils-2.24/ld/testsuite/ld-powerpc/tlsexe32.r +@@ -33,13 +33,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ + + Program Headers: + +Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align +- +PHDR +0x000034 0x01800034 0x01800034 0x000c0 0x000c0 R E 0x4 +- +INTERP +0x0000f4 0x018000f4 0x018000f4 0x00011 0x00011 R +0x1 ++ +PHDR +0x000034 0x01800034 0x01800034 (0x000[0-9a-f]{2}) \1 R E 0x4 ++ +INTERP +0x000([0-9a-f]{3}) 0x01800\1 0x01800\1 0x00011 0x00011 R +0x1 + +[Requesting program interpreter: .*] + +LOAD .* R E 0x10000 + +LOAD .* RWE 0x10000 + +DYNAMIC .* RW +0x4 + +TLS .* 0x0001c 0x00038 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -49,6 +50,7 @@ Program Headers: + +03 +.tdata .dynamic .got .plt + +04 +.dynamic + +05 +.tdata .tbss ++ +06 + + + Relocation section '.rela.dyn' at offset .* contains 2 entries: + Offset +Info +Type +Sym. Value +Symbol's Name + Addend +--- binutils-2.24/ld/testsuite/ld-powerpc/tlsso32.r ++++ binutils-2.24/ld/testsuite/ld-powerpc/tlsso32.r +@@ -35,6 +35,7 @@ Program Headers: + +LOAD .* RWE 0x10000 + +DYNAMIC .* RW +0x4 + +TLS .* 0x0+1c 0x0+38 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -42,6 +43,7 @@ Program Headers: + +01 +.tdata .dynamic .got .plt + +02 +.dynamic + +03 +.tdata .tbss ++ +04 + + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 18 entries: + Offset +Info +Type +Sym. Value +Symbol's Name + Addend +@@ -52,9 +54,9 @@ Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 18 entries: + [0-9a-f ]+R_PPC_TPREL16 +0+30 +le0 + 0 + [0-9a-f ]+R_PPC_TPREL16_HA +0+34 +le1 + 0 + [0-9a-f ]+R_PPC_TPREL16_LO +0+34 +le1 + 0 +-[0-9a-f ]+R_PPC_TPREL16 +0+103d0 +.tdata + 103e4 +-[0-9a-f ]+R_PPC_TPREL16_HA +0+103d0 +.tdata + 103e8 +-[0-9a-f ]+R_PPC_TPREL16_LO +0+103d0 +.tdata + 103e8 ++[0-9a-f ]+R_PPC_TPREL16 +0+103[df]0 +.tdata + 10[0-9a-f]{3} ++[0-9a-f ]+R_PPC_TPREL16_HA +0+103[df]0 +.tdata + 10[0-9a-f]{3} ++[0-9a-f ]+R_PPC_TPREL16_LO +0+103[df]0 +.tdata + 10[0-9a-f]{3} + [0-9a-f ]+R_PPC_DTPMOD32 +0 + [0-9a-f ]+R_PPC_DTPREL32 +0 + [0-9a-f ]+R_PPC_DTPMOD32 +0 +--- binutils-2.24/ld/testsuite/ld-s390/tlsbin.rd ++++ binutils-2.24/ld/testsuite/ld-s390/tlsbin.rd +@@ -36,6 +36,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+ + +LOAD .* RW +0x1000 + +DYNAMIC .* RW +0x4 + +TLS .* 0x0+60 0x0+a0 R +0x20 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -52,6 +53,7 @@ Program Headers: + +03 +.tdata .dynamic .got * + +04 +.dynamic * + +05 +.tdata .tbss * ++ +06 + + + Relocation section '.rela.dyn' at offset .* contains 4 entries: + Offset +Info +Type +Sym.Value +Sym. Name + Addend +--- binutils-2.24/ld/testsuite/ld-s390/tlsbin_64.rd ++++ binutils-2.24/ld/testsuite/ld-s390/tlsbin_64.rd +@@ -36,6 +36,7 @@ There are [0-9]+ program headers, starting at offset [0-9]+ + +LOAD .* RW +0x1000 + +DYNAMIC .* RW +0x8 + +TLS .* 0x0+60 0x0+a0 R +0x20 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -52,6 +53,7 @@ Program Headers: + +03 +.tdata .dynamic .got * + +04 +.dynamic * + +05 +.tdata .tbss * ++ +06 + + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries: + +Offset +Info +Type +Symbol's Value +Symbol's Name + Addend +--- binutils-2.24/ld/testsuite/ld-s390/tlspic.rd ++++ binutils-2.24/ld/testsuite/ld-s390/tlspic.rd +@@ -39,6 +39,7 @@ Program Headers: + +LOAD .* RW +0x1000 + +DYNAMIC .* RW +0x4 + +TLS .* 0x0+60 0x0+80 R +0x20 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -46,6 +47,7 @@ Program Headers: + +01 +.tdata .dynamic .got + +02 +.dynamic + +03 +.tdata .tbss ++ +04 + + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: + Offset +Info +Type +Sym.Value +Sym. Name + Addend +--- binutils-2.24/ld/testsuite/ld-s390/tlspic_64.rd ++++ binutils-2.24/ld/testsuite/ld-s390/tlspic_64.rd +@@ -39,6 +39,7 @@ Program Headers: + +LOAD .* RW +0x1000 + +DYNAMIC .* RW +0x8 + +TLS .* 0x0+60 0x0+80 R +0x20 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -46,6 +47,7 @@ Program Headers: + +01 +.tdata .dynamic .got * + +02 +.dynamic * + +03 +.tdata .tbss * ++ +04 + + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: + +Offset +Info +Type +Symbol's Value +Symbol's Name + Addend +--- binutils-2.24/ld/testsuite/ld-sh/tlsbin-2.d ++++ binutils-2.24/ld/testsuite/ld-sh/tlsbin-2.d +@@ -44,6 +44,7 @@ Program Headers: + +LOAD.* + +DYNAMIC.* + +TLS +0x[0-9a-f]+ 0x[0-9a-f]+ 0x[0-9a-f]+ 0x0+18 0x0+28 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -53,6 +54,7 @@ Program Headers: + +03 +.tdata .dynamic .got * + +04 +.dynamic * + +05 +.tdata .tbss * ++ +06 + + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries: + Offset +Info +Type +Sym.Value +Sym. Name + Addend +--- binutils-2.24/ld/testsuite/ld-sh/tlspic-2.d ++++ binutils-2.24/ld/testsuite/ld-sh/tlspic-2.d +@@ -32,7 +32,7 @@ Key to Flags: + + Elf file type is DYN (Shared object file) + Entry point 0x[0-9a-f]+ +-There are 4 program headers, starting at offset [0-9]+ ++There are [0-9] program headers, starting at offset [0-9]+ + + Program Headers: + +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align +@@ -40,6 +40,7 @@ Program Headers: + +LOAD.* + +DYNAMIC.* + +TLS .* 0x0+18 0x0+20 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -47,6 +48,7 @@ Program Headers: + +01 +.tdata .dynamic .got * + +02 +.dynamic * + +03 +.tdata .tbss * ++ +04 + + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 10 entries: + Offset +Info +Type +Sym.Value +Sym. Name + Addend +--- binutils-2.24/ld/testsuite/ld-sparc/gotop32.rd ++++ binutils-2.24/ld/testsuite/ld-sparc/gotop32.rd +@@ -31,6 +31,7 @@ Program Headers: + +LOAD +0x0+ 0x0+ 0x0+ 0x0+2000 0x0+2000 R E 0x10000 + +LOAD +0x0+2000 0x0+12000 0x0+12000 0x0+2000 0x0+2000 RW +0x10000 + +DYNAMIC +0x0+2000 0x0+12000 0x0+12000 0x0+70 0x0+70 RW +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: +--- binutils-2.24/ld/testsuite/ld-sparc/gotop64.rd ++++ binutils-2.24/ld/testsuite/ld-sparc/gotop64.rd +@@ -31,6 +31,7 @@ Program Headers: + +LOAD +0x0+ 0x0+ 0x0+ 0x0+2000 0x0+2000 R E 0x100000 + +LOAD +0x0+2000 0x0+102000 0x0+102000 0x0+2000 0x0+2000 RW +0x100000 + +DYNAMIC +0x0+2000 0x0+102000 0x0+102000 0x0+e0 0x0+e0 RW +0x8 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 1 entries: +--- binutils-2.24/ld/testsuite/ld-sparc/tlssunbin32.rd ++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunbin32.rd +@@ -30,13 +30,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ + + Program Headers: + +Type +Offset +VirtAddr +PhysAddr +FileSiz MemSiz +Flg Align +- +PHDR +0x0+34 0x0+10034 0x0+10034 0x0+c0 0x0+c0 R E 0x4 +- +INTERP +0x0+f4 0x0+100f4 0x0+100f4 0x0+11 0x0+11 R +0x1 ++ +PHDR +0x0+34 0x0+10034 0x0+10034 (0x[0-9a-f]+) \1 R E 0x4 ++ +INTERP +(0x[0-9a-f]+ ){3}0x0+11 0x0+11 R +0x1 + .*Requesting program interpreter.* + +LOAD .* R E 0x10000 + +LOAD .* RW +0x10000 + +DYNAMIC .* RW +0x4 + +TLS .* 0x0+1060 0x0+10a0 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries: +--- binutils-2.24/ld/testsuite/ld-sparc/tlssunbin64.rd ++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunbin64.rd +@@ -30,13 +30,14 @@ There are [0-9]+ program headers, starting at offset [0-9]+ + + Program Headers: + +Type +Offset +VirtAddr +PhysAddr +FileSiz +MemSiz +Flg Align +- +PHDR +0x0+40 0x0+100040 0x0+100040 0x0+150 0x0+150 R E 0x8 +- +INTERP +0x0+190 0x0+100190 0x0+100190 0x0+19 0x0+19 R +0x1 ++ +PHDR +0x0+40 0x0+100040 0x0+100040 (0x[0-9a-f]+) \1 R E 0x8 ++ +INTERP +0x0+([0-9a-f]+) (0x0+10+\1) \2 0x0+19 0x0+19 R +0x1 + .*Requesting program interpreter.* + +LOAD .* R E 0x100000 + +LOAD .* RW +0x100000 + +DYNAMIC .* RW +0x8 + +TLS .* 0x0+60 0x0+a0 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries: +--- binutils-2.24/ld/testsuite/ld-sparc/tlssunnopic32.rd ++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunnopic32.rd +@@ -32,6 +32,7 @@ Program Headers: + +LOAD .* RW +0x10000 + +DYNAMIC .* RW +0x4 + +TLS .* 0x0+ 0x0+24 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 12 entries: +--- binutils-2.24/ld/testsuite/ld-sparc/tlssunnopic64.rd ++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunnopic64.rd +@@ -32,6 +32,7 @@ Program Headers: + +LOAD .* RW +0x100000 + +DYNAMIC .* RW +0x8 + +TLS .* 0x0+ 0x0+24 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: +--- binutils-2.24/ld/testsuite/ld-sparc/tlssunpic32.rd ++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunpic32.rd +@@ -36,6 +36,7 @@ Program Headers: + +LOAD +0x0+2000 0x0+12000 0x0+12000 0x0+184 0x0+184 RWE 0x10000 + +DYNAMIC +0x0+2060 0x0+12060 0x0+12060 0x0+98 0x0+98 RW +0x4 + +TLS +0x0+2000 0x0+12000 0x0+12000 0x0+60 0x0+80 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: +--- binutils-2.24/ld/testsuite/ld-sparc/tlssunpic64.rd ++++ binutils-2.24/ld/testsuite/ld-sparc/tlssunpic64.rd +@@ -36,6 +36,7 @@ Program Headers: + +LOAD +0x0+2000 0x0+102000 0x0+102000 0x0+3a0 0x0+3a0 RWE 0x100000 + +DYNAMIC +0x0+2060 0x0+102060 0x0+102060 0x0+130 0x0+130 RW +0x8 + +TLS +0x0+2000 0x0+102000 0x0+102000 0x0+60 0x0+80 R +0x4 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + #... + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: +--- binutils-2.24/ld/testsuite/ld-x86-64/tlsgdesc.rd ++++ binutils-2.24/ld/testsuite/ld-x86-64/tlsgdesc.rd +@@ -36,12 +36,14 @@ Program Headers: + +LOAD.* + +LOAD.* + +DYNAMIC.* ++ +PAX_FLAGS.* + + Section to Segment mapping: + +Segment Sections... + +00 +.hash .dynsym .dynstr .rela.dyn .rela.plt .plt .text * + +01 +.dynamic .got .got.plt * + +02 +.dynamic * ++ +03 + + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 8 entries: + +Offset +Info +Type +Symbol's Value +Symbol's Name + Addend +--- binutils-2.24/ld/testsuite/ld-x86-64/tlspic.rd ++++ binutils-2.24/ld/testsuite/ld-x86-64/tlspic.rd +@@ -40,6 +40,7 @@ Program Headers: + +LOAD +0x0+131a 0x0+20131a 0x0+20131a 0x0+246 0x0+246 RW +0x200000 + +DYNAMIC +0x0+1380 0x0+201380 0x0+201380 0x0+130 0x0+130 RW +0x8 + +TLS +0x0+131a 0x0+20131a 0x0+20131a 0x0+60 0x0+80 R +0x1 ++ +PAX_FLAGS +0x0+ 0x0+ 0x0+ 0x0+ 0x0+ +0x[48] + + Section to Segment mapping: + +Segment Sections... +@@ -47,6 +48,7 @@ Program Headers: + +01 +.tdata .dynamic .got .got.plt * + +02 +.dynamic * + +03 +.tdata .tbss * ++ +04 + + + Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 14 entries: + +Offset +Info +Type +Symbol's Value +Symbol's Name + Addend diff --git a/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch b/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch index f55ebe8..703e94f 100644 --- a/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch +++ b/src/patches/dnsmasq-Add-support-to-read-ISC-DHCP-lease-file.patch @@ -19,7 +19,7 @@ #ifdef HAVE_DNSSEC cache_blockdata_free(crecp); #endif -@@ -1131,7 +1134,7 @@ +@@ -1138,7 +1141,7 @@
}
@@ -28,7 +28,7 @@ struct in_addr a_record_from_hosts(char *name, time_t now) { struct crec *crecp = NULL; -@@ -1274,7 +1277,11 @@ +@@ -1281,7 +1284,11 @@ else crec->ttd = ttd; crec->addr.addr = *host_address; @@ -42,7 +42,7 @@
--- a/src/dnsmasq.c Thu Jul 30 20:59:06 2015 +++ b/src/dnsmasq.c Wed Dec 16 19:38:32 2015 -@@ -982,6 +982,11 @@ +@@ -1013,6 +1013,11 @@
poll_resolv(0, daemon->last_resolv != 0, now); daemon->last_resolv = now; @@ -56,7 +56,7 @@
--- a/src/dnsmasq.h Wed Dec 16 19:24:12 2015 +++ b/src/dnsmasq.h Wed Dec 16 19:40:11 2015 -@@ -1513,8 +1513,12 @@ +@@ -1514,6 +1514,11 @@ void poll_listen(int fd, short event); int do_poll(int timeout);
@@ -326,7 +326,7 @@ +#endif --- a/src/option.c Wed Dec 16 19:24:12 2015 +++ b/src/option.c Wed Dec 16 19:42:48 2015 -@@ -1754,7 +1754,7 @@ +@@ -1769,7 +1769,7 @@ ret_err(_("bad MX target")); break;
@@ -341,8 +341,8 @@ helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \ dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \ domain.o dnssec.o blockdata.o tables.o loop.o inotify.o \ -- poll.o rrfilter.o -+ poll.o rrfilter.o isc.o +- poll.o rrfilter.o edns0.o arp.o ++ poll.o rrfilter.o edns0.o arp.o isc.o
hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \ dns-protocol.h radv-protocol.h ip6addr.h diff --git a/src/patches/dnsmasq/001-Add_TTL_parameter_to_--host-record_and_--cname.patch b/src/patches/dnsmasq/001-Add_TTL_parameter_to_--host-record_and_--cname.patch new file mode 100644 index 0000000..86fbc9c --- /dev/null +++ b/src/patches/dnsmasq/001-Add_TTL_parameter_to_--host-record_and_--cname.patch @@ -0,0 +1,265 @@ +From df3d54f776a3c9b60735b45c0b7fd88b66a2d5c4 Mon Sep 17 00:00:00 2001 +From: Simon Kelley simon@thekelleys.org.uk +Date: Wed, 24 Feb 2016 21:03:38 +0000 +Subject: [PATCH] Add TTL parameter to --host-record and --cname. + +--- + man/dnsmasq.8 | 12 ++++++++++-- + src/cache.c | 7 +++++++ + src/dnsmasq.h | 2 ++ + src/option.c | 46 ++++++++++++++++++++++++++++++++++++++-------- + src/rfc1035.c | 6 +++++- + 5 files changed, 62 insertions(+), 11 deletions(-) + +diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 +index b782eaf..7bc1394 100644 +--- a/man/dnsmasq.8 ++++ b/man/dnsmasq.8 +@@ -529,7 +529,7 @@ zone files: the port, weight and priority numbers are in a different + order. More than one SRV record for a given service/domain is allowed, + all that match are returned. + .TP +-.B --host-record=<name>[,<name>....],[<IPv4-address>],[<IPv6-address>] ++.B --host-record=<name>[,<name>....],[<IPv4-address>],[<IPv6-address>][,<TTL>] + Add A, AAAA and PTR records to the DNS. This adds one or more names to + the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may + appear in more than one +@@ -546,6 +546,10 @@ is in effect. Short and long names may appear in the same + .B host-record, + eg. + .B --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100 ++ ++If the time-to-live is given, it overrides the default, which is zero ++or the value of --local-ttl. The value is a positive integer and gives ++the time-to-live in seconds. + .TP + .B -Y, --txt-record=<name>[[,<text>],<text>] + Return a TXT DNS record. The value of TXT record is a set of strings, +@@ -559,7 +563,7 @@ Return a PTR DNS record. + .B --naptr-record=<name>,<order>,<preference>,<flags>,<service>,<regexp>[,<replacement>] + Return an NAPTR DNS record, as specified in RFC3403. + .TP +-.B --cname=<cname>,<target> ++.B --cname=<cname>,<target>[,<TTL>] + Return a CNAME record which indicates that <cname> is really + <target>. There are significant limitations on the target; it must be a + DNS name which is known to dnsmasq from /etc/hosts (or additional +@@ -568,6 +572,10 @@ hosts files), from DHCP, from --interface-name or from another + If the target does not satisfy this + criteria, the whole cname is ignored. The cname must be unique, but it + is permissable to have more than one cname pointing to the same target. ++ ++If the time-to-live is given, it overrides the default, which is zero ++or the value of -local-ttl. The value is a positive integer and gives ++the time-to-live in seconds. + .TP + .B --dns-rr=<name>,<RR-number>,[<hex data>] + Return an arbitrary DNS Resource Record. The number is the type of the +diff --git a/src/cache.c b/src/cache.c +index a9eaa65..4ecd535 100644 +--- a/src/cache.c ++++ b/src/cache.c +@@ -778,6 +778,7 @@ static void add_hosts_cname(struct crec *target) + (crec = whine_malloc(sizeof(struct crec)))) + { + crec->flags = F_FORWARD | F_IMMORTAL | F_NAMEP | F_CONFIG | F_CNAME; ++ crec->ttd = a->ttl; + crec->name.namep = a->alias; + crec->addr.cname.target.cache = target; + crec->addr.cname.uid = target->uid; +@@ -981,6 +982,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr + strcat(cache->name.sname, "."); + strcat(cache->name.sname, domain_suffix); + cache->flags = flags; ++ cache->ttd = daemon->local_ttl; + add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz); + name_count++; + } +@@ -988,6 +990,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr + { + strcpy(cache->name.sname, canon); + cache->flags = flags; ++ cache->ttd = daemon->local_ttl; + add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz); + name_count++; + } +@@ -1057,6 +1060,7 @@ void cache_reload(void) + ((cache = whine_malloc(sizeof(struct crec))))) + { + cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG; ++ cache->ttd = a->ttl; + cache->name.namep = a->alias; + cache->addr.cname.target.int_name = intr; + cache->addr.cname.uid = SRC_INTERFACE; +@@ -1071,6 +1075,7 @@ void cache_reload(void) + (cache->addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen))) + { + cache->flags = F_FORWARD | F_IMMORTAL | F_DS | F_CONFIG | F_NAMEP; ++ cache->ttd = daemon->local_ttl; + cache->name.namep = ds->name; + cache->addr.ds.keylen = ds->digestlen; + cache->addr.ds.algo = ds->algo; +@@ -1095,6 +1100,7 @@ void cache_reload(void) + (cache = whine_malloc(sizeof(struct crec)))) + { + cache->name.namep = nl->name; ++ cache->ttd = hr->ttl; + cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4 | F_NAMEP | F_CONFIG; + add_hosts_entry(cache, (struct all_addr *)&hr->addr, INADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz); + } +@@ -1103,6 +1109,7 @@ void cache_reload(void) + (cache = whine_malloc(sizeof(struct crec)))) + { + cache->name.namep = nl->name; ++ cache->ttd = hr->ttl; + cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6 | F_NAMEP | F_CONFIG; + add_hosts_entry(cache, (struct all_addr *)&hr->addr6, IN6ADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz); + } +diff --git a/src/dnsmasq.h b/src/dnsmasq.h +index 6d1c5ae..6344df5 100644 +--- a/src/dnsmasq.h ++++ b/src/dnsmasq.h +@@ -308,6 +308,7 @@ struct ptr_record { + }; + + struct cname { ++ int ttl; + char *alias, *target; + struct cname *next; + }; +@@ -344,6 +345,7 @@ struct auth_zone { + + + struct host_record { ++ int ttl; + struct name_list { + char *name; + struct name_list *next; +diff --git a/src/option.c b/src/option.c +index c98bdc9..7c5e6bc 100644 +--- a/src/option.c ++++ b/src/option.c +@@ -448,20 +448,20 @@ static struct { + { LOPT_GEN_NAMES, ARG_DUP, "[=tag:<tag>]", gettext_noop("Generate hostnames based on MAC address for nameless clients."), NULL}, + { LOPT_PROXY, ARG_DUP, "[=<ipaddr>]...", gettext_noop("Use these DHCP relays as full proxies."), NULL }, + { LOPT_RELAY, ARG_DUP, "<local-addr>,<server>[,<interface>]", gettext_noop("Relay DHCP requests to a remote server"), NULL}, +- { LOPT_CNAME, ARG_DUP, "<alias>,<target>", gettext_noop("Specify alias name for LOCAL DNS name."), NULL }, ++ { LOPT_CNAME, ARG_DUP, "<alias>,<target>[,<ttl>]", gettext_noop("Specify alias name for LOCAL DNS name."), NULL }, + { LOPT_PXE_PROMT, ARG_DUP, "<prompt>,[<timeout>]", gettext_noop("Prompt to send to PXE clients."), NULL }, + { LOPT_PXE_SERV, ARG_DUP, "<service>", gettext_noop("Boot service for PXE menu."), NULL }, + { LOPT_TEST, 0, NULL, gettext_noop("Check configuration syntax."), NULL }, + { LOPT_ADD_MAC, ARG_DUP, "[=base64|text]", gettext_noop("Add requestor's MAC address to forwarded DNS queries."), NULL }, + { LOPT_ADD_SBNET, ARG_ONE, "<v4 pref>[,<v6 pref>]", gettext_noop("Add specified IP subnet to forwarded DNS queries."), NULL }, +- { LOPT_CPE_ID, ARG_ONE, "<text>", gettext_noop("Add client identification to forwarded DNS queries."), NULL }, ++ { LOPT_CPE_ID, ARG_ONE, "<text>", gettext_noop("Add client identification to forwarded DNS queries."), NULL }, + { LOPT_DNSSEC, OPT_DNSSEC_PROXY, NULL, gettext_noop("Proxy DNSSEC validation results from upstream nameservers."), NULL }, + { LOPT_INCR_ADDR, OPT_CONSEC_ADDR, NULL, gettext_noop("Attempt to allocate sequential IP addresses to DHCP clients."), NULL }, + { LOPT_CONNTRACK, OPT_CONNTRACK, NULL, gettext_noop("Copy connection-track mark from queries to upstream connections."), NULL }, + { LOPT_FQDN, OPT_FQDN_UPDATE, NULL, gettext_noop("Allow DHCP clients to do their own DDNS updates."), NULL }, + { LOPT_RA, OPT_RA, NULL, gettext_noop("Send router-advertisements for interfaces doing DHCPv6"), NULL }, + { LOPT_DUID, ARG_ONE, "<enterprise>,<duid>", gettext_noop("Specify DUID_EN-type DHCPv6 server DUID"), NULL }, +- { LOPT_HOST_REC, ARG_DUP, "<name>,<address>", gettext_noop("Specify host (A/AAAA and PTR) records"), NULL }, ++ { LOPT_HOST_REC, ARG_DUP, "<name>,<address>[,<ttl>]", gettext_noop("Specify host (A/AAAA and PTR) records"), NULL }, + { LOPT_RR, ARG_DUP, "<name>,<RR-number>,[<data>]", gettext_noop("Specify arbitrary DNS resource record"), NULL }, + { LOPT_CLVERBIND, OPT_CLEVERBIND, NULL, gettext_noop("Bind to interfaces in use - check for new interfaces"), NULL }, + { LOPT_AUTHSERV, ARG_ONE, "<NS>,<interface>", gettext_noop("Export local names to global DNS"), NULL }, +@@ -3692,12 +3692,15 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma + case LOPT_CNAME: /* --cname */ + { + struct cname *new; +- char *alias; +- char *target; ++ char *alias, *target, *ttls; ++ int ttl = -1; + + if (!(comma = split(arg))) + ret_err(gen_err); + ++ if ((ttls = split(comma)) && !atoi_check(ttls, &ttl)) ++ ret_err(_("bad TTL")); ++ + alias = canonicalise_opt(arg); + target = canonicalise_opt(comma); + +@@ -3713,6 +3716,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma + daemon->cnames = new; + new->alias = alias; + new->target = target; ++ new->ttl = ttl; + } + + break; +@@ -3913,14 +3917,22 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma + { + struct host_record *new = opt_malloc(sizeof(struct host_record)); + memset(new, 0, sizeof(struct host_record)); +- ++ new->ttl = -1; ++ + if (!arg || !(comma = split(arg))) + ret_err(_("Bad host-record")); + + while (arg) + { + struct all_addr addr; +- if (inet_pton(AF_INET, arg, &addr)) ++ char *dig; ++ ++ for (dig = arg; *dig != 0; dig++) ++ if (*dig < '0' || *dig > '9') ++ break; ++ if (*dig == 0) ++ new->ttl = atoi(arg); ++ else if (inet_pton(AF_INET, arg, &addr)) + new->addr = addr.addr.addr4; + #ifdef HAVE_IPV6 + else if (inet_pton(AF_INET6, arg, &addr)) +@@ -4601,7 +4613,25 @@ void read_opts(int argc, char **argv, char *compile_opts) + } + } + } +- ++ ++ if (daemon->host_records) ++ { ++ struct host_record *hr; ++ ++ for (hr = daemon->host_records; hr; hr = hr->next) ++ if (hr->ttl == -1) ++ hr->ttl = daemon->local_ttl; ++ } ++ ++ if (daemon->cnames) ++ { ++ struct cname *cn; ++ ++ for (cn = daemon->cnames; cn; cn = cn->next) ++ if (cn->ttl == -1) ++ cn->ttl = daemon->local_ttl; ++ } ++ + if (daemon->if_addrs) + { + struct iname *tmp; +diff --git a/src/rfc1035.c b/src/rfc1035.c +index 9c0ddb5..3535a71 100644 +--- a/src/rfc1035.c ++++ b/src/rfc1035.c +@@ -1169,9 +1169,13 @@ static unsigned long crec_ttl(struct crec *crecp, time_t now) + /* Return 0 ttl for DHCP entries, which might change + before the lease expires. */ + +- if (crecp->flags & (F_IMMORTAL | F_DHCP)) ++ if (crecp->flags & F_DHCP) + return daemon->local_ttl; + ++ /* Immortal entries other than DHCP are local, and hold TTL in TTD field. */ ++ if (crecp->flags & F_IMMORTAL) ++ return crecp->ttd; ++ + /* Return the Max TTL value if it is lower then the actual TTL */ + if (daemon->max_ttl == 0 || ((unsigned)(crecp->ttd - now) < daemon->max_ttl)) + return crecp->ttd - now; +-- +1.7.10.4 + diff --git a/src/patches/dnsmasq/001-include_0_0_0_0_8_in_DNS_rebind_checks.patch b/src/patches/dnsmasq/001-include_0_0_0_0_8_in_DNS_rebind_checks.patch deleted file mode 100644 index 8a2557a..0000000 --- a/src/patches/dnsmasq/001-include_0_0_0_0_8_in_DNS_rebind_checks.patch +++ /dev/null @@ -1,41 +0,0 @@ -From d2aa7dfbb6d1088dcbea9fecc61b9293b320eb95 Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Mon, 3 Aug 2015 21:52:12 +0100 -Subject: [PATCH] Include 0.0.0.0/8 in DNS rebind checks. - ---- - CHANGELOG | 7 +++++++ - src/rfc1035.c | 3 ++- - 2 files changed, 9 insertions(+), 1 deletion(-) - -diff --git a/CHANGELOG b/CHANGELOG -index 901da47..3f4026d 100644 ---- a/CHANGELOG -+++ b/CHANGELOG -@@ -1,3 +1,10 @@ -+version 2.76 -+ Include 0.0.0.0/8 in DNS rebind checks. This range -+ translates to hosts on the local network, or, at -+ least, 0.0.0.0 accesses the local host, so could -+ be targets for DNS rebinding. See RFC 5735 section 3 -+ for details. Thanks to Stephen Röttger for the bug report. -+ - version 2.75 - Fix reversion on 2.74 which caused 100% CPU use when a - dhcp-script is configured. Thanks to Adrian Davey for -diff --git a/src/rfc1035.c b/src/rfc1035.c -index 56647b0..29e9e65 100644 ---- a/src/rfc1035.c -+++ b/src/rfc1035.c -@@ -728,7 +728,8 @@ int private_net(struct in_addr addr, int ban_localhost) - in_addr_t ip_addr = ntohl(addr.s_addr); - - return -- (((ip_addr & 0xFF000000) == 0x7F000000) && ban_localhost) /* 127.0.0.0/8 (loopback) */ || -+ (((ip_addr & 0xFF000000) == 0x7F000000) && ban_localhost) /* 127.0.0.0/8 (loopback) */ || -+ ((ip_addr & 0xFF000000) == 0x00000000) /* RFC 5735 section 3. "here" network */ || - ((ip_addr & 0xFFFF0000) == 0xC0A80000) /* 192.168.0.0/16 (private) */ || - ((ip_addr & 0xFF000000) == 0x0A000000) /* 10.0.0.0/8 (private) */ || - ((ip_addr & 0xFFF00000) == 0xAC100000) /* 172.16.0.0/12 (private) */ || --- -1.7.10.4 diff --git a/src/patches/dnsmasq/002-Add_--dhcp-ttl_option.patch b/src/patches/dnsmasq/002-Add_--dhcp-ttl_option.patch new file mode 100644 index 0000000..45e3b9b --- /dev/null +++ b/src/patches/dnsmasq/002-Add_--dhcp-ttl_option.patch @@ -0,0 +1,117 @@ +From 832e47beab95c2918b5264f0504f2fe6fe523e4c Mon Sep 17 00:00:00 2001 +From: Simon Kelley simon@thekelleys.org.uk +Date: Wed, 24 Feb 2016 21:24:45 +0000 +Subject: [PATCH] Add --dhcp-ttl option. + +--- + man/dnsmasq.8 | 5 ++++- + src/dnsmasq.h | 2 +- + src/option.c | 13 +++++++++++-- + src/rfc1035.c | 2 +- + 4 files changed, 17 insertions(+), 5 deletions(-) + +diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 +index 7bc1394..2bcce20 100644 +--- a/man/dnsmasq.8 ++++ b/man/dnsmasq.8 +@@ -60,7 +60,7 @@ in the same way as for DHCP-derived names. Note that this does not + apply to domain names in cnames, PTR records, TXT records etc. + .TP + .B -T, --local-ttl=<time> +-When replying with information from /etc/hosts or the DHCP leases ++When replying with information from /etc/hosts or configuration or the DHCP leases + file dnsmasq by default sets the time-to-live field to zero, meaning + that the requester should not itself cache the information. This is + the correct thing to do in almost all situations. This option allows a +@@ -68,6 +68,9 @@ time-to-live (in seconds) to be given for these replies. This will + reduce the load on the server at the expense of clients using stale + data under some circumstances. + .TP ++.B --dhcp-ttl=<time> ++As for --local-ttl, but affects only replies with information from DHCP leases. If both are given, --dhcp-ttl applies for DHCP information, and --local-ttl for others. Setting this to zero eliminates the effect of --local-ttl for DHCP. ++.TP + .B --neg-ttl=<time> + Negative replies from upstream servers normally contain time-to-live + information in SOA records which dnsmasq uses for caching. If the +diff --git a/src/dnsmasq.h b/src/dnsmasq.h +index 6344df5..9f73c3b 100644 +--- a/src/dnsmasq.h ++++ b/src/dnsmasq.h +@@ -955,7 +955,7 @@ extern struct daemon { + int max_logs; /* queue limit */ + int cachesize, ftabsize; + int port, query_port, min_port, max_port; +- unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl; ++ unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl; + char *dns_client_id; + struct hostsfile *addn_hosts; + struct dhcp_context *dhcp, *dhcp6; +diff --git a/src/option.c b/src/option.c +index 7c5e6bc..3f6d162 100644 +--- a/src/option.c ++++ b/src/option.c +@@ -157,6 +157,7 @@ struct myoption { + #define LOPT_MAXPORT 345 + #define LOPT_CPE_ID 346 + #define LOPT_SCRIPT_ARP 347 ++#define LOPT_DHCPTTL 348 + + #ifdef HAVE_GETOPT_LONG + static const struct option opts[] = +@@ -319,6 +320,7 @@ static const struct myoption opts[] = + { "quiet-ra", 0, 0, LOPT_QUIET_RA }, + { "dns-loop-detect", 0, 0, LOPT_LOOP_DETECT }, + { "script-arp", 0, 0, LOPT_SCRIPT_ARP }, ++ { "dhcp-ttl", 1, 0 , LOPT_DHCPTTL }, + { NULL, 0, 0, 0 } + }; + +@@ -485,9 +487,10 @@ static struct { + { LOPT_QUIET_DHCP, OPT_QUIET_DHCP, NULL, gettext_noop("Do not log routine DHCP."), NULL }, + { LOPT_QUIET_DHCP6, OPT_QUIET_DHCP6, NULL, gettext_noop("Do not log routine DHCPv6."), NULL }, + { LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL }, +- { LOPT_LOCAL_SERVICE, OPT_LOCAL_SERVICE, NULL, gettext_noop("Accept queries only from directly-connected networks"), NULL }, +- { LOPT_LOOP_DETECT, OPT_LOOP_DETECT, NULL, gettext_noop("Detect and remove DNS forwarding loops"), NULL }, ++ { LOPT_LOCAL_SERVICE, OPT_LOCAL_SERVICE, NULL, gettext_noop("Accept queries only from directly-connected networks."), NULL }, ++ { LOPT_LOOP_DETECT, OPT_LOOP_DETECT, NULL, gettext_noop("Detect and remove DNS forwarding loops."), NULL }, + { LOPT_IGNORE_ADDR, ARG_DUP, "<ipaddr>", gettext_noop("Ignore DNS responses containing ipaddr."), NULL }, ++ { LOPT_DHCPTTL, ARG_ONE, "<ttl>", gettext_noop("Set TTL in DNS responses with DHCP-derived addresses."), NULL }, + { 0, 0, NULL, NULL, NULL } + }; + +@@ -2580,6 +2583,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma + case LOPT_MINCTTL: /* --min-cache-ttl */ + case LOPT_MAXCTTL: /* --max-cache-ttl */ + case LOPT_AUTHTTL: /* --auth-ttl */ ++ case LOPT_DHCPTTL: /* --dhcp-ttl */ + { + int ttl; + if (!atoi_check(arg, &ttl)) +@@ -2598,6 +2602,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma + daemon->max_cache_ttl = (unsigned long)ttl; + else if (option == LOPT_AUTHTTL) + daemon->auth_ttl = (unsigned long)ttl; ++ else if (option == LOPT_DHCPTTL) ++ { ++ daemon->dhcp_ttl = (unsigned long)ttl; ++ daemon->use_dhcp_ttl = 1; ++ } + else + daemon->local_ttl = (unsigned long)ttl; + break; +diff --git a/src/rfc1035.c b/src/rfc1035.c +index 3535a71..8f1e3b4 100644 +--- a/src/rfc1035.c ++++ b/src/rfc1035.c +@@ -1170,7 +1170,7 @@ static unsigned long crec_ttl(struct crec *crecp, time_t now) + before the lease expires. */ + + if (crecp->flags & F_DHCP) +- return daemon->local_ttl; ++ return daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl; + + /* Immortal entries other than DHCP are local, and hold TTL in TTD field. */ + if (crecp->flags & F_IMMORTAL) +-- +1.7.10.4 + diff --git a/src/patches/dnsmasq/002-enhance_add_subnet_to_allow_arbitary_subnet_addresses.patch b/src/patches/dnsmasq/002-enhance_add_subnet_to_allow_arbitary_subnet_addresses.patch deleted file mode 100644 index 2d3d6e4..0000000 --- a/src/patches/dnsmasq/002-enhance_add_subnet_to_allow_arbitary_subnet_addresses.patch +++ /dev/null @@ -1,271 +0,0 @@ -From a7369bef8abd241c3d85633fa9c870943f091e76 Mon Sep 17 00:00:00 2001 -From: Ed Bardsley ebardsley@google.com -Date: Wed, 5 Aug 2015 21:17:18 +0100 -Subject: [PATCH] Enhance --add-subnet to allow arbitary subnet addresses. - ---- - CHANGELOG | 4 ++++ - man/dnsmasq.8 | 32 ++++++++++++++++++++----------- - src/dnsmasq.h | 13 ++++++++++--- - src/option.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++----- - src/rfc1035.c | 39 +++++++++++++++++++++++++++++++------- - 5 files changed, 121 insertions(+), 26 deletions(-) - -diff --git a/CHANGELOG b/CHANGELOG -index 3f4026d..bbc2834 100644 ---- a/CHANGELOG -+++ b/CHANGELOG -@@ -4,6 +4,10 @@ version 2.76 - least, 0.0.0.0 accesses the local host, so could - be targets for DNS rebinding. See RFC 5735 section 3 - for details. Thanks to Stephen Röttger for the bug report. -+ -+ Enhance --add-subnet to allow arbitrary subnet addresses. -+ Thanks to Ed Barsley for the patch. -+ - - version 2.75 - Fix reversion on 2.74 which caused 100% CPU use when a -diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 -index c8913b5..a23c898 100644 ---- a/man/dnsmasq.8 -+++ b/man/dnsmasq.8 -@@ -604,17 +604,27 @@ experimental. Also note that exposing MAC addresses in this way may - have security and privacy implications. The warning about caching - given for --add-subnet applies to --add-mac too. - .TP --.B --add-subnet[[=<IPv4 prefix length>],<IPv6 prefix length>] --Add the subnet address of the requestor to the DNS queries which are --forwarded upstream. The amount of the address forwarded depends on the --prefix length parameter: 32 (128 for IPv6) forwards the whole address, --zero forwards none of it but still marks the request so that no --upstream nameserver will add client address information either. The --default is zero for both IPv4 and IPv6. Note that upstream nameservers --may be configured to return different results based on this --information, but the dnsmasq cache does not take account. If a dnsmasq --instance is configured such that different results may be encountered, --caching should be disabled. -+.B --add-subnet[[=[<IPv4 address>/]<IPv4 prefix length>][,[<IPv6 address>/]<IPv6 prefix length>]] -+Add a subnet address to the DNS queries which are forwarded -+upstream. If an address is specified in the flag, it will be used, -+otherwise, the address of the requestor will be used. The amount of -+the address forwarded depends on the prefix length parameter: 32 (128 -+for IPv6) forwards the whole address, zero forwards none of it but -+still marks the request so that no upstream nameserver will add client -+address information either. The default is zero for both IPv4 and -+IPv6. Note that upstream nameservers may be configured to return -+different results based on this information, but the dnsmasq cache -+does not take account. If a dnsmasq instance is configured such that -+different results may be encountered, caching should be disabled. -+ -+For example, -+.B --add-subnet=24,96 -+will add the /24 and /96 subnets of the requestor for IPv4 and IPv6 requestors, respectively. -+.B --add-subnet=1.2.3.4/24 -+will add 1.2.3.0/24 for IPv4 requestors and ::/0 for IPv6 requestors. -+.B --add-subnet=1.2.3.4/24,1.2.3.4/24 -+will add 1.2.3.0/24 for both IPv4 and IPv6 requestors. -+ - .TP - .B -c, --cache-size=<cachesize> - Set the size of dnsmasq's cache. The default is 150 names. Setting the cache size to zero disables caching. -diff --git a/src/dnsmasq.h b/src/dnsmasq.h -index cf1a782..f42acdb 100644 ---- a/src/dnsmasq.h -+++ b/src/dnsmasq.h -@@ -541,6 +541,13 @@ struct iname { - struct iname *next; - }; - -+/* subnet parameters from command line */ -+struct mysubnet { -+ union mysockaddr addr; -+ int addr_used; -+ int mask; -+}; -+ - /* resolv-file parms from command-line */ - struct resolvc { - struct resolvc *next; -@@ -935,9 +942,9 @@ extern struct daemon { - struct auth_zone *auth_zones; - struct interface_name *int_names; - char *mxtarget; -- int addr4_netmask; -- int addr6_netmask; -- char *lease_file; -+ struct mysubnet *add_subnet4; -+ struct mysubnet *add_subnet6; -+ char *lease_file; - char *username, *groupname, *scriptuser; - char *luascript; - char *authserver, *hostmaster; -diff --git a/src/option.c b/src/option.c -index ecc2619..746cd11 100644 ---- a/src/option.c -+++ b/src/option.c -@@ -445,7 +445,7 @@ static struct { - { LOPT_PXE_SERV, ARG_DUP, "<service>", gettext_noop("Boot service for PXE menu."), NULL }, - { LOPT_TEST, 0, NULL, gettext_noop("Check configuration syntax."), NULL }, - { LOPT_ADD_MAC, OPT_ADD_MAC, NULL, gettext_noop("Add requestor's MAC address to forwarded DNS queries."), NULL }, -- { LOPT_ADD_SBNET, ARG_ONE, "<v4 pref>[,<v6 pref>]", gettext_noop("Add requestor's IP subnet to forwarded DNS queries."), NULL }, -+ { LOPT_ADD_SBNET, ARG_ONE, "<v4 pref>[,<v6 pref>]", gettext_noop("Add specified IP subnet to forwarded DNS queries."), NULL }, - { LOPT_DNSSEC, OPT_DNSSEC_PROXY, NULL, gettext_noop("Proxy DNSSEC validation results from upstream nameservers."), NULL }, - { LOPT_INCR_ADDR, OPT_CONSEC_ADDR, NULL, gettext_noop("Attempt to allocate sequential IP addresses to DHCP clients."), NULL }, - { LOPT_CONNTRACK, OPT_CONNTRACK, NULL, gettext_noop("Copy connection-track mark from queries to upstream connections."), NULL }, -@@ -722,6 +722,20 @@ static void do_usage(void) - - #define ret_err(x) do { strcpy(errstr, (x)); return 0; } while (0) - -+static char *parse_mysockaddr(char *arg, union mysockaddr *addr) -+{ -+ if (inet_pton(AF_INET, arg, &addr->in.sin_addr) > 0) -+ addr->sa.sa_family = AF_INET; -+#ifdef HAVE_IPV6 -+ else if (inet_pton(AF_INET6, arg, &addr->in6.sin6_addr) > 0) -+ addr->sa.sa_family = AF_INET6; -+#endif -+ else -+ return _("bad address"); -+ -+ return NULL; -+} -+ - char *parse_server(char *arg, union mysockaddr *addr, union mysockaddr *source_addr, char *interface, int *flags) - { - int source_port = 0, serv_port = NAMESERVER_PORT; -@@ -1585,7 +1599,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma - li = match_suffix->next; - free(match_suffix->suffix); - free(match_suffix); -- } -+ } - break; - } - -@@ -1593,10 +1607,45 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma - set_option_bool(OPT_CLIENT_SUBNET); - if (arg) - { -+ char *err, *end; - comma = split(arg); -- if (!atoi_check(arg, &daemon->addr4_netmask) || -- (comma && !atoi_check(comma, &daemon->addr6_netmask))) -- ret_err(gen_err); -+ -+ struct mysubnet* new = opt_malloc(sizeof(struct mysubnet)); -+ if ((end = split_chr(arg, '/'))) -+ { -+ /* has subnet+len */ -+ err = parse_mysockaddr(arg, &new->addr); -+ if (err) -+ ret_err(err); -+ if (!atoi_check(end, &new->mask)) -+ ret_err(gen_err); -+ new->addr_used = 1; -+ } -+ else if (!atoi_check(arg, &new->mask)) -+ ret_err(gen_err); -+ -+ daemon->add_subnet4 = new; -+ -+ new = opt_malloc(sizeof(struct mysubnet)); -+ if (comma) -+ { -+ if ((end = split_chr(comma, '/'))) -+ { -+ /* has subnet+len */ -+ err = parse_mysockaddr(comma, &new->addr); -+ if (err) -+ ret_err(err); -+ if (!atoi_check(end, &new->mask)) -+ ret_err(gen_err); -+ new->addr_used = 1; -+ } -+ else -+ { -+ if (!atoi_check(comma, &new->mask)) -+ ret_err(gen_err); -+ } -+ } -+ daemon->add_subnet6 = new; - } - break; - -diff --git a/src/rfc1035.c b/src/rfc1035.c -index 29e9e65..6a51b30 100644 ---- a/src/rfc1035.c -+++ b/src/rfc1035.c -@@ -629,26 +629,47 @@ struct subnet_opt { - #endif - }; - -+static void *get_addrp(union mysockaddr *addr, const short family) -+{ -+#ifdef HAVE_IPV6 -+ if (family == AF_INET6) -+ return &addr->in6.sin6_addr; -+#endif -+ -+ return &addr->in.sin_addr; -+} -+ - static size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source) - { - /* http://tools.ietf.org/html/draft-vandergaast-edns-client-subnet-02 */ - - int len; - void *addrp; -+ int sa_family = source->sa.sa_family; - - #ifdef HAVE_IPV6 - if (source->sa.sa_family == AF_INET6) - { -- opt->family = htons(2); -- opt->source_netmask = daemon->addr6_netmask; -- addrp = &source->in6.sin6_addr; -+ opt->source_netmask = daemon->add_subnet6->mask; -+ if (daemon->add_subnet6->addr_used) -+ { -+ sa_family = daemon->add_subnet6->addr.sa.sa_family; -+ addrp = get_addrp(&daemon->add_subnet6->addr, sa_family); -+ } -+ else -+ addrp = &source->in6.sin6_addr; - } - else - #endif - { -- opt->family = htons(1); -- opt->source_netmask = daemon->addr4_netmask; -- addrp = &source->in.sin_addr; -+ opt->source_netmask = daemon->add_subnet4->mask; -+ if (daemon->add_subnet4->addr_used) -+ { -+ sa_family = daemon->add_subnet4->addr.sa.sa_family; -+ addrp = get_addrp(&daemon->add_subnet4->addr, sa_family); -+ } -+ else -+ addrp = &source->in.sin_addr; - } - - opt->scope_netmask = 0; -@@ -656,6 +677,11 @@ static size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source) - - if (opt->source_netmask != 0) - { -+#ifdef HAVE_IPV6 -+ opt->family = htons(sa_family == AF_INET6 ? 2 : 1); -+#else -+ opt->family = htons(1); -+#endif - len = ((opt->source_netmask - 1) >> 3) + 1; - memcpy(opt->addr, addrp, len); - if (opt->source_netmask & 7) -@@ -2335,4 +2361,3 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen, - - return len; - } -- --- -1.7.10.4 diff --git a/src/patches/dnsmasq/003-Update_CHANGELOG.patch b/src/patches/dnsmasq/003-Update_CHANGELOG.patch new file mode 100644 index 0000000..f04f943 --- /dev/null +++ b/src/patches/dnsmasq/003-Update_CHANGELOG.patch @@ -0,0 +1,17 @@ +X-Git-Url: http://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=blobdiff_plain;f=CHANGELOG;... + +diff --git a/CHANGELOG b/CHANGELOG +index 14354f2..6d9ba49 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -48,6 +48,10 @@ version 2.76 + (ie xx::0 to xx::ffff:ffff:ffff:ffff) + Thanks to Laurent Bendel for spotting this problem. + ++ Add support for a TTL parameter in --host-record and ++ --cname. ++ ++ Add --dhcp-ttl option. + + version 2.75 + Fix reversion on 2.74 which caused 100% CPU use when a diff --git a/src/patches/dnsmasq/003-dont_answer_non_auth_queries_for_auth_zones_locally_when_localise_queries_set.patch b/src/patches/dnsmasq/003-dont_answer_non_auth_queries_for_auth_zones_locally_when_localise_queries_set.patch deleted file mode 100644 index cfbcdfb..0000000 --- a/src/patches/dnsmasq/003-dont_answer_non_auth_queries_for_auth_zones_locally_when_localise_queries_set.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 3a3965ac21b1b759eab8799b6edb09195b671306 Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Sun, 9 Aug 2015 17:45:06 +0100 -Subject: [PATCH] Don't answer non-auth queries for auth zones locally when - --localise-queries set. - ---- - src/forward.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/forward.c b/src/forward.c -index 2731b90..b76a974 100644 ---- a/src/forward.c -+++ b/src/forward.c -@@ -1365,7 +1365,7 @@ void receive_query(struct listener *listen, time_t now) - - #ifdef HAVE_AUTH - /* find queries for zones we're authoritative for, and answer them directly */ -- if (!auth_dns) -+ if (!auth_dns && !option_bool(OPT_LOCALISE)) - for (zone = daemon->auth_zones; zone; zone = zone->next) - if (in_zone(zone, daemon->namebuff, NULL)) - { -@@ -1904,7 +1904,7 @@ unsigned char *tcp_request(int confd, time_t now, - - #ifdef HAVE_AUTH - /* find queries for zones we're authoritative for, and answer them directly */ -- if (!auth_dns) -+ if (!auth_dns && !option_bool(OPT_LOCALISE)) - for (zone = daemon->auth_zones; zone; zone = zone->next) - if (in_zone(zone, daemon->namebuff, NULL)) - { --- -1.7.10.4 diff --git a/src/patches/dnsmasq/004-Add_--tftp-mtu_option.patch b/src/patches/dnsmasq/004-Add_--tftp-mtu_option.patch new file mode 100644 index 0000000..c06705a --- /dev/null +++ b/src/patches/dnsmasq/004-Add_--tftp-mtu_option.patch @@ -0,0 +1,136 @@ +From bec366b4041df72b559e713f1c924177676e6eb0 Mon Sep 17 00:00:00 2001 +From: Simon Kelley simon@thekelleys.org.uk +Date: Wed, 24 Feb 2016 22:03:26 +0000 +Subject: [PATCH] Add --tftp-mtu option. + +--- + CHANGELOG | 4 ++++ + man/dnsmasq.8 | 4 ++++ + src/dnsmasq.h | 2 +- + src/option.c | 10 +++++++++- + src/tftp.c | 14 ++++++++++++-- + 5 files changed, 30 insertions(+), 4 deletions(-) + +diff --git a/CHANGELOG b/CHANGELOG +index 6d9ba49..9218b8c 100644 +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -53,6 +53,10 @@ version 2.76 + + Add --dhcp-ttl option. + ++ Add --tftp-mtu option. Thanks to Patrick McLean for the ++ initial patch. ++ ++ + version 2.75 + Fix reversion on 2.74 which caused 100% CPU use when a + dhcp-script is configured. Thanks to Adrian Davey for +diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 +index 2bcce20..3cf48cd 100644 +--- a/man/dnsmasq.8 ++++ b/man/dnsmasq.8 +@@ -1810,6 +1810,10 @@ require about (2*n) + 10 descriptors. If + .B --tftp-port-range + is given, that can affect the number of concurrent connections. + .TP ++.B --tftp-mtu=<mtu size> ++Use size as the ceiling of the MTU supported by the intervening network when ++negotiating TFTP blocksize, overriding the MTU setting of the local interface if it is larger. ++.TP + .B --tftp-no-blocksize + Stop the TFTP server from negotiating the "blocksize" option with a + client. Some buggy clients request this option but then behave badly +diff --git a/src/dnsmasq.h b/src/dnsmasq.h +index 9f73c3b..280ad9d 100644 +--- a/src/dnsmasq.h ++++ b/src/dnsmasq.h +@@ -975,7 +975,7 @@ extern struct daemon { + struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *dhcp_gen_names; + struct dhcp_netid_list *force_broadcast, *bootp_dynamic; + struct hostsfile *dhcp_hosts_file, *dhcp_opts_file, *dynamic_dirs; +- int dhcp_max, tftp_max; ++ int dhcp_max, tftp_max, tftp_mtu; + int dhcp_server_port, dhcp_client_port; + int start_tftp_port, end_tftp_port; + unsigned int min_leasetime; +diff --git a/src/option.c b/src/option.c +index 3f6d162..765965f 100644 +--- a/src/option.c ++++ b/src/option.c +@@ -158,7 +158,8 @@ struct myoption { + #define LOPT_CPE_ID 346 + #define LOPT_SCRIPT_ARP 347 + #define LOPT_DHCPTTL 348 +- ++#define LOPT_TFTP_MTU 349 ++ + #ifdef HAVE_GETOPT_LONG + static const struct option opts[] = + #else +@@ -244,6 +245,7 @@ static const struct myoption opts[] = + { "tftp-unique-root", 0, 0, LOPT_APREF }, + { "tftp-root", 1, 0, LOPT_PREFIX }, + { "tftp-max", 1, 0, LOPT_TFTP_MAX }, ++ { "tftp-mtu", 1, 0, LOPT_TFTP_MTU }, + { "tftp-lowercase", 0, 0, LOPT_TFTP_LC }, + { "ptr-record", 1, 0, LOPT_PTR }, + { "naptr-record", 1, 0, LOPT_NAPTR }, +@@ -432,6 +434,7 @@ static struct { + { LOPT_SECURE, OPT_TFTP_SECURE, NULL, gettext_noop("Allow access only to files owned by the user running dnsmasq."), NULL }, + { LOPT_TFTP_NO_FAIL, OPT_TFTP_NO_FAIL, NULL, gettext_noop("Do not terminate the service if TFTP directories are inaccessible."), NULL }, + { LOPT_TFTP_MAX, ARG_ONE, "<integer>", gettext_noop("Maximum number of conncurrent TFTP transfers (defaults to %s)."), "#" }, ++ { LOPT_TFTP_MTU, ARG_ONE, "<integer>", gettext_noop("Maximum MTU to use for TFTP transfers."), NULL }, + { LOPT_NOBLOCK, OPT_TFTP_NOBLOCK, NULL, gettext_noop("Disable the TFTP blocksize extension."), NULL }, + { LOPT_TFTP_LC, OPT_TFTP_LC, NULL, gettext_noop("Convert TFTP filenames to lowercase"), NULL }, + { LOPT_TFTPPORTS, ARG_ONE, "<start>,<end>", gettext_noop("Ephemeral port range for use by TFTP transfers."), NULL }, +@@ -2625,6 +2628,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma + ret_err(gen_err); + break; + ++ case LOPT_TFTP_MTU: /* --tftp-mtu */ ++ if (!atoi_check(arg, &daemon->tftp_mtu)) ++ ret_err(gen_err); ++ break; ++ + case LOPT_PREFIX: /* --tftp-prefix */ + comma = split(arg); + if (comma) +diff --git a/src/tftp.c b/src/tftp.c +index 00ed2fc..dc4aa85 100644 +--- a/src/tftp.c ++++ b/src/tftp.c +@@ -103,8 +103,10 @@ void tftp_request(struct listener *listen, time_t now) + if (listen->iface) + { + addr = listen->iface->addr; +- mtu = listen->iface->mtu; + name = listen->iface->name; ++ mtu = listen->iface->mtu; ++ if (daemon->tftp_mtu != 0 && daemon->tftp_mtu < mtu) ++ mtu = daemon->tftp_mtu; + } + else + { +@@ -234,9 +236,17 @@ void tftp_request(struct listener *listen, time_t now) + + strncpy(ifr.ifr_name, name, IF_NAMESIZE); + if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1) +- mtu = ifr.ifr_mtu; ++ { ++ mtu = ifr.ifr_mtu; ++ if (daemon->tftp_mtu != 0 && daemon->tftp_mtu < mtu) ++ mtu = daemon->tftp_mtu; ++ } + } + ++ /* Failed to get interface mtu - can use configured value. */ ++ if (mtu == 0) ++ mtu = daemon->tftp_mtu; ++ + if (name) + { + /* check for per-interface prefix */ +-- +1.7.10.4 + diff --git a/src/patches/dnsmasq/004-fix_behaviour_of_empty_dhcp-option.patch b/src/patches/dnsmasq/004-fix_behaviour_of_empty_dhcp-option.patch deleted file mode 100644 index 492ada9..0000000 --- a/src/patches/dnsmasq/004-fix_behaviour_of_empty_dhcp-option.patch +++ /dev/null @@ -1,38 +0,0 @@ -From 5e3e464ac4022ee0b3794513abe510817e2cf3ca Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Tue, 25 Aug 2015 23:08:39 +0100 -Subject: [PATCH] Fix behaviour of empty dhcp-option=option6:dns-server, which - should inhibit sending option. - ---- - src/rfc3315.c | 9 +++++---- - 1 file changed, 5 insertions(+), 4 deletions(-) - -diff --git a/src/rfc3315.c b/src/rfc3315.c -index 2665d0d..3f1f9ee 100644 ---- a/src/rfc3315.c -+++ b/src/rfc3315.c -@@ -1320,15 +1320,16 @@ static struct dhcp_netid *add_options(struct state *state, int do_refresh) - - if (opt_cfg->opt == OPTION6_REFRESH_TIME) - done_refresh = 1; -+ -+ if (opt_cfg->opt == OPTION6_DNS_SERVER) -+ done_dns = 1; - -- if (opt_cfg->flags & DHOPT_ADDR6) -+ /* Empty DNS_SERVER option will not set DHOPT_ADDR6 */ -+ if ((opt_cfg->flags & DHOPT_ADDR6) || opt_cfg->opt == OPTION6_DNS_SERVER) - { - int len, j; - struct in6_addr *a; - -- if (opt_cfg->opt == OPTION6_DNS_SERVER) -- done_dns = 1; -- - for (a = (struct in6_addr *)opt_cfg->val, len = opt_cfg->len, j = 0; - j < opt_cfg->len; j += IN6ADDRSZ, a++) - if ((IN6_IS_ADDR_ULA_ZERO(a) && IN6_IS_ADDR_UNSPECIFIED(state->ula_addr)) || --- -1.7.10.4 - diff --git a/src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch b/src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch new file mode 100644 index 0000000..2875d2c --- /dev/null +++ b/src/patches/dnsmasq/005-Apply_ceiling_of_lease_length_to_TTL_when_--dhcp-ttl_in_use.patch @@ -0,0 +1,37 @@ +From 7480aeffc8ad195e9fd8bcf424bae0fab3839d55 Mon Sep 17 00:00:00 2001 +From: Simon Kelley simon@thekelleys.org.uk +Date: Fri, 26 Feb 2016 21:58:20 +0000 +Subject: [PATCH] Apply ceiling of lease length to TTL when --dhcp-ttl in use. + +--- + src/rfc1035.c | 12 ++++++++++-- + 1 file changed, 10 insertions(+), 2 deletions(-) + +diff --git a/src/rfc1035.c b/src/rfc1035.c +index 8f1e3b4..bed5312 100644 +--- a/src/rfc1035.c ++++ b/src/rfc1035.c +@@ -1167,10 +1167,18 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int + static unsigned long crec_ttl(struct crec *crecp, time_t now) + { + /* Return 0 ttl for DHCP entries, which might change +- before the lease expires. */ ++ before the lease expires, unless configured otherwise. */ + + if (crecp->flags & F_DHCP) +- return daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl; ++ { ++ int conf_ttl = daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl; ++ ++ /* Apply ceiling of actual lease length to configured TTL. */ ++ if (!(crecp->flags & F_IMMORTAL) && (crecp->ttd - now) < conf_ttl) ++ return crecp->ttd - now; ++ ++ return conf_ttl; ++ } + + /* Immortal entries other than DHCP are local, and hold TTL in TTD field. */ + if (crecp->flags & F_IMMORTAL) +-- +1.7.10.4 + diff --git a/src/patches/dnsmasq/005-suggest_solution_to_ENOMEM_error_with_IPv6_multicast.patch b/src/patches/dnsmasq/005-suggest_solution_to_ENOMEM_error_with_IPv6_multicast.patch deleted file mode 100644 index c7cee60..0000000 --- a/src/patches/dnsmasq/005-suggest_solution_to_ENOMEM_error_with_IPv6_multicast.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 9cdcfe9f19ffd45bac4e5b459879bf7c50a287ed Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Wed, 26 Aug 2015 22:38:08 +0100 -Subject: [PATCH] Suggest solution to ENOMEM error with IPv6 multicast. - ---- - src/network.c | 13 ++++++++++--- - 1 file changed, 10 insertions(+), 3 deletions(-) - -diff --git a/src/network.c b/src/network.c -index a1d90c8..819302f 100644 ---- a/src/network.c -+++ b/src/network.c -@@ -1076,23 +1076,30 @@ void join_multicast(int dienow) - - if ((daemon->doing_dhcp6 || daemon->relay6) && - setsockopt(daemon->dhcp6fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq)) == -1) -- err = 1; -+ err = errno; - - inet_pton(AF_INET6, ALL_SERVERS, &mreq.ipv6mr_multiaddr); - - if (daemon->doing_dhcp6 && - setsockopt(daemon->dhcp6fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq)) == -1) -- err = 1; -+ err = errno; - - inet_pton(AF_INET6, ALL_ROUTERS, &mreq.ipv6mr_multiaddr); - - if (daemon->doing_ra && - setsockopt(daemon->icmp6fd, IPPROTO_IPV6, IPV6_JOIN_GROUP, &mreq, sizeof(mreq)) == -1) -- err = 1; -+ err = errno; - - if (err) - { - char *s = _("interface %s failed to join DHCPv6 multicast group: %s"); -+ errno = err; -+ -+#ifdef HAVE_LINUX_NETWORK -+ if (errno == ENOMEM) -+ my_syslog(LOG_ERR, _("try increasing /proc/sys/net/core/optmem_max")); -+#endif -+ - if (dienow) - die(s, iface->name, EC_BADNET); - else --- -1.7.10.4 - diff --git a/src/patches/dnsmasq/006-clarify_man_page_on_RDNSS_set_in_router_advertisement.patch b/src/patches/dnsmasq/006-clarify_man_page_on_RDNSS_set_in_router_advertisement.patch deleted file mode 100644 index 19c76e6..0000000 --- a/src/patches/dnsmasq/006-clarify_man_page_on_RDNSS_set_in_router_advertisement.patch +++ /dev/null @@ -1,35 +0,0 @@ -From 20fd11e11a9d09edcea94de135396ae1541fbbab Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Wed, 26 Aug 2015 22:48:13 +0100 -Subject: [PATCH] Clarify man page on RDNSS set in router advertisement. - ---- - man/dnsmasq.8 | 6 +++--- - 1 file changed, 3 insertions(+), 3 deletions(-) - -diff --git a/man/dnsmasq.8 b/man/dnsmasq.8 -index a23c898..d51b10f 100644 ---- a/man/dnsmasq.8 -+++ b/man/dnsmasq.8 -@@ -1687,15 +1687,15 @@ creation are handled by a different protocol. When DHCP is in use, - only a subset of this is needed, and dnsmasq can handle it, using - existing DHCP configuration to provide most data. When RA is enabled, - dnsmasq will advertise a prefix for each dhcp-range, with default --router and recursive DNS server as the relevant link-local address on --the machine running dnsmasq. By default, he "managed address" bits are set, and -+router as the relevant link-local address on -+the machine running dnsmasq. By default, the "managed address" bits are set, and - the "use SLAAC" bit is reset. This can be changed for individual - subnets with the mode keywords described in - .B --dhcp-range. - RFC6106 DNS parameters are included in the advertisements. By default, - the relevant link-local address of the machine running dnsmasq is sent - as recursive DNS server. If provided, the DHCPv6 options dns-server and --domain-search are used for RDNSS and DNSSL. -+domain-search are used for the DNS server (RDNSS) and the domain serach list (DNSSL). - .TP - .B --ra-param=<interface>,[high|low],[[<ra-interval>],<router lifetime>] - Set non-default values for router advertisements sent via an --- -1.7.10.4 - diff --git a/src/patches/dnsmasq/007-handle_signed_dangling_CNAME_replies_to_DS_queries.patch b/src/patches/dnsmasq/007-handle_signed_dangling_CNAME_replies_to_DS_queries.patch deleted file mode 100644 index 832a22e..0000000 --- a/src/patches/dnsmasq/007-handle_signed_dangling_CNAME_replies_to_DS_queries.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 6de81f1250fd323c9155de065d5a9dc200a6f20b Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Wed, 9 Sep 2015 22:51:13 +0100 -Subject: [PATCH] Handle signed dangling CNAME replies to DS queries. - ---- - src/dnssec.c | 7 ++----- - 1 file changed, 2 insertions(+), 5 deletions(-) - -diff --git a/src/dnssec.c b/src/dnssec.c -index 4deda24..67ce486 100644 ---- a/src/dnssec.c -+++ b/src/dnssec.c -@@ -1232,11 +1232,8 @@ int dnssec_validate_ds(time_t now, struct dns_header *header, size_t plen, char - - /* If we return STAT_NO_SIG, name contains the name of the DS query */ - if (val == STAT_NO_SIG) -- { -- *keyname = 0; -- return val; -- } -- -+ return val; -+ - /* If the key needed to validate the DS is on the same domain as the DS, we'll - loop getting nowhere. Stop that now. This can happen of the DS answer comes - from the DS's zone, and not the parent zone. */ --- -1.7.10.4 - diff --git a/src/patches/dnsmasq/008-DHCPv6_option_56_does_not_hold_an_address_list.patch b/src/patches/dnsmasq/008-DHCPv6_option_56_does_not_hold_an_address_list.patch deleted file mode 100644 index fdccd0e..0000000 --- a/src/patches/dnsmasq/008-DHCPv6_option_56_does_not_hold_an_address_list.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 102208df695e886a3086754d32bf7f8c541fbe46 Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Thu, 10 Sep 2015 21:50:00 +0100 -Subject: [PATCH] DHCPv6 option 56 does not hold an address list. (RFC 5908). - ---- - src/dhcp-common.c | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/src/dhcp-common.c b/src/dhcp-common.c -index bc48f41..8fc171a 100644 ---- a/src/dhcp-common.c -+++ b/src/dhcp-common.c -@@ -599,7 +599,7 @@ static const struct opttab_t opttab6[] = { - { "sntp-server", 31, OT_ADDR_LIST }, - { "information-refresh-time", 32, OT_TIME }, - { "FQDN", 39, OT_INTERNAL | OT_RFC1035_NAME }, -- { "ntp-server", 56, OT_ADDR_LIST }, -+ { "ntp-server", 56, 0 }, - { "bootfile-url", 59, OT_NAME }, - { "bootfile-param", 60, OT_CSTRING }, - { NULL, 0, 0 } --- -1.7.10.4 - diff --git a/src/patches/dnsmasq/009-Respect_the_--no_resolv_flag_in_inotify_code.patch b/src/patches/dnsmasq/009-Respect_the_--no_resolv_flag_in_inotify_code.patch deleted file mode 100644 index 2014fdb..0000000 --- a/src/patches/dnsmasq/009-Respect_the_--no_resolv_flag_in_inotify_code.patch +++ /dev/null @@ -1,47 +0,0 @@ -From 77607cbea0ad0f876dfb79c8b2c121ee400d57d0 Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Thu, 10 Sep 2015 23:08:43 +0100 -Subject: [PATCH] Respect the --no-resolv flag in inotify code. - ---- - CHANGELOG | 7 ++++++- - debian/changelog | 6 ++++++ - src/inotify.c | 3 +++ - 3 files changed, 15 insertions(+), 1 deletion(-) - -diff --git a/CHANGELOG b/CHANGELOG -index bbc2834..d6e309f 100644 ---- a/CHANGELOG -+++ b/CHANGELOG -@@ -7,8 +7,13 @@ version 2.76 - - Enhance --add-subnet to allow arbitrary subnet addresses. - Thanks to Ed Barsley for the patch. -+ -+ Respect the --no-resolv flag in inotify code. Fixes bug -+ which caused dnsmasq to fail to start if a resolv-file -+ was a dangling symbolic link, even of --no-resolv set. -+ Thanks to Alexander Kurtz for spotting the problem. -+ - -- - version 2.75 - Fix reversion on 2.74 which caused 100% CPU use when a - dhcp-script is configured. Thanks to Adrian Davey for -diff --git a/src/inotify.c b/src/inotify.c -index 52d412f..ef05c58 100644 ---- a/src/inotify.c -+++ b/src/inotify.c -@@ -90,6 +90,9 @@ void inotify_dnsmasq_init() - - if (daemon->inotifyfd == -1) - die(_("failed to create inotify: %s"), NULL, EC_MISC); -+ -+ if (option_bool(OPT_NO_RESOLV)) -+ return; - - for (res = daemon->resolv_files; res; res = res->next) - { --- -1.7.10.4 - diff --git a/src/patches/dnsmasq/010-Rationalise_5e3e464ac4022ee0b3794513abe510817e2cf3ca.patch b/src/patches/dnsmasq/010-Rationalise_5e3e464ac4022ee0b3794513abe510817e2cf3ca.patch deleted file mode 100644 index 281697f..0000000 --- a/src/patches/dnsmasq/010-Rationalise_5e3e464ac4022ee0b3794513abe510817e2cf3ca.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 27b78d990b7cd901866ad6f1a17b9d633a95fdce Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Sat, 26 Sep 2015 21:40:45 +0100 -Subject: [PATCH] Rationalise 5e3e464ac4022ee0b3794513abe510817e2cf3ca - ---- - src/rfc3315.c | 3 +-- - 1 file changed, 1 insertion(+), 2 deletions(-) - -diff --git a/src/rfc3315.c b/src/rfc3315.c -index 3f1f9ee..3ed8623 100644 ---- a/src/rfc3315.c -+++ b/src/rfc3315.c -@@ -1324,8 +1324,7 @@ static struct dhcp_netid *add_options(struct state *state, int do_refresh) - if (opt_cfg->opt == OPTION6_DNS_SERVER) - done_dns = 1; - -- /* Empty DNS_SERVER option will not set DHOPT_ADDR6 */ -- if ((opt_cfg->flags & DHOPT_ADDR6) || opt_cfg->opt == OPTION6_DNS_SERVER) -+ if (opt_cfg->flags & DHOPT_ADDR6) - { - int len, j; - struct in6_addr *a; --- -1.7.10.4 - diff --git a/src/patches/dnsmasq/011-Catch_errors_from_sendmsg_in_DHCP_code.patch b/src/patches/dnsmasq/011-Catch_errors_from_sendmsg_in_DHCP_code.patch deleted file mode 100644 index 631495f..0000000 --- a/src/patches/dnsmasq/011-Catch_errors_from_sendmsg_in_DHCP_code.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 98079ea89851da1df4966dfdfa1852a98da02912 Mon Sep 17 00:00:00 2001 -From: Simon Kelley simon@thekelleys.org.uk -Date: Tue, 13 Oct 2015 20:30:32 +0100 -Subject: [PATCH] Catch errors from sendmsg in DHCP code. Logs, eg, iptables - DROPS of dest 255.255.255.255 - ---- - src/dhcp.c | 7 ++++++- - 1 file changed, 6 insertions(+), 1 deletion(-) - -diff --git a/src/dhcp.c b/src/dhcp.c -index e6fceb1..1c85e42 100644 ---- a/src/dhcp.c -+++ b/src/dhcp.c -@@ -452,8 +452,13 @@ void dhcp_packet(time_t now, int pxe_fd) - #endif - - while(retry_send(sendmsg(fd, &msg, 0))); -+ -+ /* This can fail when, eg, iptables DROPS destination 255.255.255.255 */ -+ if (errno != 0) -+ my_syslog(MS_DHCP | LOG_WARNING, _("Error sending DHCP packet to %s: %s"), -+ inet_ntoa(dest.sin_addr), strerror(errno)); - }