aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Ellerman <mpe@ellerman.id.au>2015-06-05 20:46:23 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2015-06-05 20:46:26 +1000
commit8022c0bd3f0fd83d35ff1b7c4c5ca2fa19a63c3b (patch)
tree522521f7b82758e7443f4444ee627b61147d52f8
parent5cdc7fc4d89b0e1640eaf00321744fd74c444fc6 (diff)
parent084861124d00b046cb4159b0158e1b74626b8257 (diff)
downloadlinux-next-8022c0bd3f0fd83d35ff1b7c4c5ca2fa19a63c3b.tar.gz
Merge remote-tracking branch 'staging/staging-next'
Conflicts: drivers/staging/media/dt3155v4l/dt3155v4l.c
-rw-r--r--Documentation/ABI/testing/sysfs-bus-iio99
-rw-r--r--Documentation/devicetree/bindings/iio/adc/berlin2_adc.txt19
-rw-r--r--Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt4
-rw-r--r--Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt17
-rw-r--r--Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt22
-rw-r--r--Documentation/devicetree/bindings/iio/st-sensors.txt1
-rw-r--r--Documentation/devicetree/bindings/iio/temperature/mlx90614.txt24
-rw-r--r--Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt24
-rw-r--r--Documentation/devicetree/bindings/vendor-prefixes.txt1
-rw-r--r--MAINTAINERS9
-rw-r--r--drivers/Makefile1
-rw-r--r--drivers/iio/accel/Kconfig21
-rw-r--r--drivers/iio/accel/Makefile3
-rw-r--r--drivers/iio/accel/bmc150-accel.c55
-rw-r--r--drivers/iio/accel/hid-sensor-accel-3d.c15
-rw-r--r--drivers/iio/accel/kxcjk-1013.c42
-rw-r--r--drivers/iio/accel/mma8452.c62
-rw-r--r--drivers/iio/accel/mma9551_core.c8
-rw-r--r--drivers/iio/accel/mma9551_core.h2
-rw-r--r--drivers/iio/accel/mma9553.c148
-rw-r--r--drivers/iio/accel/stk8312.c390
-rw-r--r--drivers/iio/accel/stk8ba50.c302
-rw-r--r--drivers/iio/adc/Kconfig11
-rw-r--r--drivers/iio/adc/Makefile1
-rw-r--r--drivers/iio/adc/axp288_adc.c2
-rw-r--r--drivers/iio/adc/berlin2-adc.c378
-rw-r--r--drivers/iio/adc/ti-adc128s052.c30
-rw-r--r--drivers/iio/adc/ti_am335x_adc.c83
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_core.c23
-rw-r--r--drivers/iio/common/st_sensors/st_sensors_trigger.c4
-rw-r--r--drivers/iio/dac/Kconfig10
-rw-r--r--drivers/iio/dac/Makefile1
-rw-r--r--drivers/iio/dac/m62332.c269
-rw-r--r--drivers/iio/gyro/bmg160.c67
-rw-r--r--drivers/iio/gyro/hid-sensor-gyro-3d.c15
-rw-r--r--drivers/iio/humidity/Kconfig2
-rw-r--r--drivers/iio/industrialio-buffer.c328
-rw-r--r--drivers/iio/industrialio-core.c6
-rw-r--r--drivers/iio/industrialio-event.c2
-rw-r--r--drivers/iio/light/Kconfig37
-rw-r--r--drivers/iio/light/Makefile3
-rw-r--r--drivers/iio/light/acpi-als.c231
-rw-r--r--drivers/iio/light/bh1750.c334
-rw-r--r--drivers/iio/light/hid-sensor-als.c14
-rw-r--r--drivers/iio/light/hid-sensor-prox.c2
-rw-r--r--drivers/iio/light/ltr501.c1284
-rw-r--r--drivers/iio/light/stk3310.c722
-rw-r--r--drivers/iio/light/tsl2563.c36
-rw-r--r--drivers/iio/light/tsl4531.c10
-rw-r--r--drivers/iio/magnetometer/Kconfig29
-rw-r--r--drivers/iio/magnetometer/Makefile3
-rw-r--r--drivers/iio/magnetometer/bmc150_magn.c1109
-rw-r--r--drivers/iio/magnetometer/hid-sensor-magn-3d.c2
-rw-r--r--drivers/iio/magnetometer/mmc35240.c512
-rw-r--r--drivers/iio/magnetometer/st_magn.h1
-rw-r--r--drivers/iio/magnetometer/st_magn_core.c116
-rw-r--r--drivers/iio/magnetometer/st_magn_i2c.c5
-rw-r--r--drivers/iio/orientation/hid-sensor-incl-3d.c16
-rw-r--r--drivers/iio/orientation/hid-sensor-rotation.c17
-rw-r--r--drivers/iio/pressure/hid-sensor-press.c14
-rw-r--r--drivers/iio/proximity/sx9500.c457
-rw-r--r--drivers/iio/temperature/mlx90614.c353
-rw-r--r--drivers/iio/temperature/tmp006.c6
-rw-r--r--drivers/platform/goldfish/goldfish_pipe.c18
-rw-r--r--drivers/staging/Kconfig4
-rw-r--r--drivers/staging/Makefile4
-rw-r--r--drivers/staging/android/Kconfig11
-rw-r--r--drivers/staging/android/ion/ion.c1
-rw-r--r--drivers/staging/android/ion/ion_chunk_heap.c2
-rw-r--r--drivers/staging/android/ion/ion_priv.h6
-rw-r--r--drivers/staging/android/ion/ion_test.c20
-rw-r--r--drivers/staging/android/ion/tegra/tegra_ion.c1
-rw-r--r--drivers/staging/android/lowmemorykiller.c17
-rw-r--r--drivers/staging/android/uapi/ion.h2
-rw-r--r--drivers/staging/comedi/Kconfig18
-rw-r--r--drivers/staging/comedi/comedi.h2
-rw-r--r--drivers/staging/comedi/comedi_fops.c43
-rw-r--r--drivers/staging/comedi/comedi_internal.h1
-rw-r--r--drivers/staging/comedi/comedidev.h18
-rw-r--r--drivers/staging/comedi/drivers.c2
-rw-r--r--drivers/staging/comedi/drivers/8255.c232
-rw-r--r--drivers/staging/comedi/drivers/8255.h19
-rw-r--r--drivers/staging/comedi/drivers/Makefile3
-rw-r--r--drivers/staging/comedi/drivers/addi_watchdog.h2
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.c37
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200.h44
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200_common.c61
-rw-r--r--drivers/staging/comedi/drivers/amplc_dio200_pci.c35
-rw-r--r--drivers/staging/comedi/drivers/cb_pcidas64.c154
-rw-r--r--drivers/staging/comedi/drivers/cb_pcimdda.c6
-rw-r--r--drivers/staging/comedi/drivers/comedi_8254.h6
-rw-r--r--drivers/staging/comedi/drivers/comedi_8255.c285
-rw-r--r--drivers/staging/comedi/drivers/comedi_bond.c3
-rw-r--r--drivers/staging/comedi/drivers/comedi_isadma.h4
-rw-r--r--drivers/staging/comedi/drivers/daqboard2000.c196
-rw-r--r--drivers/staging/comedi/drivers/das16m1.c4
-rw-r--r--drivers/staging/comedi/drivers/gsc_hpdi.c191
-rw-r--r--drivers/staging/comedi/drivers/me_daq.c3
-rw-r--r--drivers/staging/comedi/drivers/mite.c110
-rw-r--r--drivers/staging/comedi/drivers/mite.h88
-rw-r--r--drivers/staging/comedi/drivers/ni_mio_common.c2408
-rw-r--r--drivers/staging/comedi/drivers/ni_pcimio.c17
-rw-r--r--drivers/staging/comedi/drivers/ni_stc.h2237
-rw-r--r--drivers/staging/comedi/drivers/pcl812.c10
-rw-r--r--drivers/staging/comedi/drivers/pcl816.c2
-rw-r--r--drivers/staging/comedi/drivers/serial2002.c2
-rw-r--r--drivers/staging/dgap/dgap.c133
-rw-r--r--drivers/staging/dgap/dgap.h2
-rw-r--r--drivers/staging/dgnc/TODO6
-rw-r--r--drivers/staging/dgnc/dgnc_cls.c4
-rw-r--r--drivers/staging/dgnc/dgnc_driver.c9
-rw-r--r--drivers/staging/dgnc/dgnc_driver.h3
-rw-r--r--drivers/staging/dgnc/dgnc_neo.c4
-rw-r--r--drivers/staging/dgnc/dgnc_sysfs.c110
-rw-r--r--drivers/staging/dgnc/dgnc_tty.c106
-rw-r--r--drivers/staging/dgnc/digi.h14
-rw-r--r--drivers/staging/emxx_udc/emxx_udc.c39
-rw-r--r--drivers/staging/fbtft/Kconfig8
-rw-r--r--drivers/staging/fbtft/Makefile1
-rw-r--r--drivers/staging/fbtft/fb_hx8357d.c222
-rw-r--r--drivers/staging/fbtft/fb_hx8357d.h102
-rw-r--r--drivers/staging/fbtft/fb_st7735r.c8
-rw-r--r--drivers/staging/fbtft/fb_tls8204.c1
-rw-r--r--drivers/staging/fbtft/fbtft-bus.c8
-rw-r--r--drivers/staging/fbtft/fbtft-core.c7
-rw-r--r--drivers/staging/fbtft/internal.h2
-rw-r--r--drivers/staging/fsl-mc/bus/mc-bus.c1
-rw-r--r--drivers/staging/ft1000/ft1000-usb/ft1000_debug.c3
-rw-r--r--drivers/staging/fwserial/dma_fifo.c2
-rw-r--r--drivers/staging/fwserial/fwserial.c5
-rw-r--r--drivers/staging/fwserial/fwserial.h2
-rw-r--r--drivers/staging/gdm724x/gdm_endian.c46
-rw-r--r--drivers/staging/gdm724x/gdm_endian.h11
-rw-r--r--drivers/staging/gdm72xx/gdm_wimax.c2
-rw-r--r--drivers/staging/gdm72xx/netlink_k.c2
-rw-r--r--drivers/staging/goldfish/goldfish_audio.c2
-rw-r--r--drivers/staging/goldfish/goldfish_nand.c2
-rw-r--r--drivers/staging/i2o/Kconfig120
-rw-r--r--drivers/staging/i2o/Makefile16
-rw-r--r--drivers/staging/i2o/README98
-rw-r--r--drivers/staging/i2o/README.ioctl394
-rw-r--r--drivers/staging/i2o/bus-osm.c177
-rw-r--r--drivers/staging/i2o/config-osm.c90
-rw-r--r--drivers/staging/i2o/core.h69
-rw-r--r--drivers/staging/i2o/debug.c473
-rw-r--r--drivers/staging/i2o/device.c592
-rw-r--r--drivers/staging/i2o/driver.c381
-rw-r--r--drivers/staging/i2o/exec-osm.c612
-rw-r--r--drivers/staging/i2o/i2o.h988
-rw-r--r--drivers/staging/i2o/i2o_block.c1228
-rw-r--r--drivers/staging/i2o/i2o_block.h103
-rw-r--r--drivers/staging/i2o/i2o_config.c1162
-rw-r--r--drivers/staging/i2o/i2o_proc.c2049
-rw-r--r--drivers/staging/i2o/i2o_scsi.c814
-rw-r--r--drivers/staging/i2o/iop.c1255
-rw-r--r--drivers/staging/i2o/memory.c312
-rw-r--r--drivers/staging/i2o/pci.c500
-rw-r--r--drivers/staging/iio/Documentation/device.txt2
-rw-r--r--drivers/staging/iio/accel/Kconfig2
-rw-r--r--drivers/staging/iio/adc/Kconfig6
-rw-r--r--drivers/staging/iio/adc/ad7606_par.c2
-rw-r--r--drivers/staging/iio/addac/Kconfig2
-rw-r--r--drivers/staging/iio/iio_simple_dummy.h2
-rw-r--r--drivers/staging/iio/iio_simple_dummy_events.c2
-rw-r--r--drivers/staging/iio/light/isl29018.c297
-rw-r--r--drivers/staging/iio/resolver/Kconfig4
-rw-r--r--drivers/staging/lustre/TODO2
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs.h27
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/libcfs_private.h13
-rw-r--r--drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h1
-rw-r--r--drivers/staging/lustre/include/linux/lnet/api.h1
-rw-r--r--drivers/staging/lustre/include/linux/lnet/lib-lnet.h2
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c458
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h680
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c484
-rw-r--r--drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c48
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c468
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h560
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c396
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c150
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c33
-rw-r--r--drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c128
-rw-r--r--drivers/staging/lustre/lnet/lnet/acceptor.c32
-rw-r--r--drivers/staging/lustre/lnet/lnet/api-ni.c232
-rw-r--r--drivers/staging/lustre/lnet/lnet/config.c238
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-eq.c44
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-md.c26
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-me.c20
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-move.c264
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-msg.c50
-rw-r--r--drivers/staging/lustre/lnet/lnet/lib-ptl.c116
-rw-r--r--drivers/staging/lustre/lnet/lnet/lo.c2
-rw-r--r--drivers/staging/lustre/lnet/lnet/module.c22
-rw-r--r--drivers/staging/lustre/lnet/lnet/peer.c50
-rw-r--r--drivers/staging/lustre/lnet/lnet/router.c224
-rw-r--r--drivers/staging/lustre/lnet/lnet/router_proc.c210
-rw-r--r--drivers/staging/lustre/lnet/selftest/brw_test.c60
-rw-r--r--drivers/staging/lustre/lnet/selftest/conctl.c54
-rw-r--r--drivers/staging/lustre/lnet/selftest/conrpc.c124
-rw-r--r--drivers/staging/lustre/lnet/selftest/conrpc.h34
-rw-r--r--drivers/staging/lustre/lnet/selftest/console.c246
-rw-r--r--drivers/staging/lustre/lnet/selftest/console.h186
-rw-r--r--drivers/staging/lustre/lnet/selftest/framework.c160
-rw-r--r--drivers/staging/lustre/lnet/selftest/module.c10
-rw-r--r--drivers/staging/lustre/lnet/selftest/ping_test.c24
-rw-r--r--drivers/staging/lustre/lnet/selftest/rpc.c150
-rw-r--r--drivers/staging/lustre/lnet/selftest/rpc.h141
-rw-r--r--drivers/staging/lustre/lnet/selftest/selftest.h311
-rw-r--r--drivers/staging/lustre/lnet/selftest/timer.c20
-rw-r--r--drivers/staging/lustre/lnet/selftest/timer.h16
-rw-r--r--drivers/staging/lustre/lustre/fid/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/fid/fid_internal.h6
-rw-r--r--drivers/staging/lustre/lustre/fid/fid_request.c73
-rw-r--r--drivers/staging/lustre/lustre/fid/lproc_fid.c49
-rw-r--r--drivers/staging/lustre/lustre/fld/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_cache.c16
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_internal.h5
-rw-r--r--drivers/staging/lustre/lustre/fld/fld_request.c74
-rw-r--r--drivers/staging/lustre/lustre/fld/lproc_fld.c42
-rw-r--r--drivers/staging/lustre/lustre/include/dt_object.h3
-rw-r--r--drivers/staging/lustre/lustre/include/linux/lustre_lite.h1
-rw-r--r--drivers/staging/lustre/lustre/include/linux/obd.h10
-rw-r--r--drivers/staging/lustre/lustre/include/lprocfs_status.h313
-rw-r--r--drivers/staging/lustre/lustre/include/lu_object.h2
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_dlm.h69
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_dlm_flags.h17
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_export.h29
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_fid.h5
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_fld.h16
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_lib.h15
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_net.h17
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_quota.h241
-rw-r--r--drivers/staging/lustre/lustre/include/lustre_sec.h8
-rw-r--r--drivers/staging/lustre/lustre/include/obd.h22
-rw-r--r--drivers/staging/lustre/lustre/include/obd_class.h36
-rw-r--r--drivers/staging/lustre/lustre/include/obd_support.h66
-rw-r--r--drivers/staging/lustre/lustre/lclient/lcommon_cl.c45
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_internal.h76
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lib.c7
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lock.c11
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c90
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_pool.c175
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_request.c4
-rw-r--r--drivers/staging/lustre/lustre/ldlm/ldlm_resource.c358
-rw-r--r--drivers/staging/lustre/lustre/libcfs/Makefile1
-rw-r--r--drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c59
-rw-r--r--drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c9
-rw-r--r--drivers/staging/lustre/lustre/libcfs/module.c1
-rw-r--r--drivers/staging/lustre/lustre/llite/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/llite/dcache.c6
-rw-r--r--drivers/staging/lustre/lustre/llite/dir.c42
-rw-r--r--drivers/staging/lustre/lustre/llite/file.c55
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_close.c6
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_internal.h39
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_lib.c74
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_nfs.c2
-rw-r--r--drivers/staging/lustre/lustre/llite/llite_rmtacl.c4
-rw-r--r--drivers/staging/lustre/lustre/llite/lloop.c8
-rw-r--r--drivers/staging/lustre/lustre/llite/lproc_llite.c713
-rw-r--r--drivers/staging/lustre/lustre/llite/namei.c2
-rw-r--r--drivers/staging/lustre/lustre/llite/rw26.c20
-rw-r--r--drivers/staging/lustre/lustre/llite/statahead.c21
-rw-r--r--drivers/staging/lustre/lustre/llite/super25.c27
-rw-r--r--drivers/staging/lustre/lustre/llite/vvp_dev.c21
-rw-r--r--drivers/staging/lustre/lustre/llite/xattr.c10
-rw-r--r--drivers/staging/lustre/lustre/llite/xattr_cache.c6
-rw-r--r--drivers/staging/lustre/lustre/lmv/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_intent.c4
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_internal.h8
-rw-r--r--drivers/staging/lustre/lustre/lmv/lmv_obd.c112
-rw-r--r--drivers/staging/lustre/lustre/lmv/lproc_lmv.c105
-rw-r--r--drivers/staging/lustre/lustre/lov/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_dev.c19
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_internal.h7
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_io.c5
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_obd.c89
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_pack.c3
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_pool.c51
-rw-r--r--drivers/staging/lustre/lustre/lov/lov_request.c35
-rw-r--r--drivers/staging/lustre/lustre/lov/lovsub_dev.c4
-rw-r--r--drivers/staging/lustre/lustre/lov/lproc_lov.c58
-rw-r--r--drivers/staging/lustre/lustre/mdc/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/mdc/lproc_mdc.c92
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_internal.h7
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_locks.c2
-rw-r--r--drivers/staging/lustre/lustre/mdc/mdc_request.c38
-rw-r--r--drivers/staging/lustre/lustre/mgc/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/mgc/lproc_mgc.c9
-rw-r--r--drivers/staging/lustre/lustre/mgc/mgc_internal.h11
-rw-r--r--drivers/staging/lustre/lustre/mgc/mgc_request.c28
-rw-r--r--drivers/staging/lustre/lustre/obdclass/Makefile4
-rw-r--r--drivers/staging/lustre/lustre/obdclass/acl.c30
-rw-r--r--drivers/staging/lustre/lustre/obdclass/capa.c4
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_io.c13
-rw-r--r--drivers/staging/lustre/lustre/obdclass/cl_page.c20
-rw-r--r--drivers/staging/lustre/lustre/obdclass/class_obd.c41
-rw-r--r--drivers/staging/lustre/lustre/obdclass/dt_object.c6
-rw-r--r--drivers/staging/lustre/lustre/obdclass/genops.c75
-rw-r--r--drivers/staging/lustre/lustre/obdclass/linux/linux-module.c153
-rw-r--r--drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c25
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog.c25
-rw-r--r--drivers/staging/lustre/lustre/obdclass/llog_obd.c4
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lprocfs_status.c625
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lu_object.c10
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lustre_handles.c2
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lustre_peer.c6
-rw-r--r--drivers/staging/lustre/lustre/obdclass/obd_config.c147
-rw-r--r--drivers/staging/lustre/lustre/obdclass/obd_mount.c107
-rw-r--r--drivers/staging/lustre/lustre/obdecho/Makefile2
-rw-r--r--drivers/staging/lustre/lustre/obdecho/echo_client.c53
-rw-r--r--drivers/staging/lustre/lustre/obdecho/lproc_echo.c57
-rw-r--r--drivers/staging/lustre/lustre/osc/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/osc/lproc_osc.c400
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_dev.c4
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_internal.h8
-rw-r--r--drivers/staging/lustre/lustre/osc/osc_request.c38
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/Makefile3
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/client.c20
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/connection.c6
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c267
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/nrs.c32
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c6
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/pinger.c18
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h21
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c14
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec.c2
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c17
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_config.c16
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c35
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/sec_plain.c13
-rw-r--r--drivers/staging/lustre/lustre/ptlrpc/service.c110
-rw-r--r--drivers/staging/lustre/sysfs-fs-lustre543
-rw-r--r--drivers/staging/media/bcm2048/radio-bcm2048.c4
-rw-r--r--drivers/staging/nvec/nvec.c2
-rw-r--r--drivers/staging/octeon-usb/octeon-hcd.c16
-rw-r--r--drivers/staging/octeon-usb/octeon-hcd.h2
-rw-r--r--drivers/staging/octeon/ethernet-defines.h62
-rw-r--r--drivers/staging/octeon/ethernet-mdio.c48
-rw-r--r--drivers/staging/octeon/ethernet-mdio.h24
-rw-r--r--drivers/staging/octeon/ethernet-mem.c30
-rw-r--r--drivers/staging/octeon/ethernet-mem.h23
-rw-r--r--drivers/staging/octeon/ethernet-rgmii.c306
-rw-r--r--drivers/staging/octeon/ethernet-rx.c38
-rw-r--r--drivers/staging/octeon/ethernet-rx.h24
-rw-r--r--drivers/staging/octeon/ethernet-sgmii.c112
-rw-r--r--drivers/staging/octeon/ethernet-spi.c237
-rw-r--r--drivers/staging/octeon/ethernet-tx.c28
-rw-r--r--drivers/staging/octeon/ethernet-tx.h23
-rw-r--r--drivers/staging/octeon/ethernet-util.h23
-rw-r--r--drivers/staging/octeon/ethernet-xaui.c114
-rw-r--r--drivers/staging/octeon/ethernet.c115
-rw-r--r--drivers/staging/octeon/octeon-ethernet.h35
-rw-r--r--drivers/staging/panel/panel.c60
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_ap.c54
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_mlme_ext.c24
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_recv.c2
-rw-r--r--drivers/staging/rtl8188eu/core/rtw_sta_mgt.c2
-rw-r--r--drivers/staging/rtl8188eu/hal/hal_intf.c2
-rw-r--r--drivers/staging/rtl8188eu/include/drv_types.h1
-rw-r--r--drivers/staging/rtl8188eu/include/ieee80211.h29
-rw-r--r--drivers/staging/rtl8188eu/include/osdep_intf.h2
-rw-r--r--drivers/staging/rtl8188eu/include/osdep_service.h2
-rw-r--r--drivers/staging/rtl8188eu/include/recv_osdep.h3
-rw-r--r--drivers/staging/rtl8188eu/include/rtl8188e_hal.h4
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_ap.h2
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_ioctl.h2
-rw-r--r--drivers/staging/rtl8188eu/include/rtw_mlme.h2
-rw-r--r--drivers/staging/rtl8188eu/include/wifi.h77
-rw-r--r--drivers/staging/rtl8188eu/os_dep/ioctl_linux.c8
-rw-r--r--drivers/staging/rtl8188eu/os_dep/mlme_linux.c4
-rw-r--r--drivers/staging/rtl8188eu/os_dep/os_intfs.c110
-rw-r--r--drivers/staging/rtl8188eu/os_dep/usb_intf.c12
-rw-r--r--drivers/staging/rtl8192e/dot11d.h4
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c25
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c63
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c43
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c118
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h1496
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h908
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_cam.c22
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_cam.h4
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.c91
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_core.h21
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h382
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_dm.c1099
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_dm.h9
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_pci.c2
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_pm.c6
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_ps.c13
-rw-r--r--drivers/staging/rtl8192e/rtl8192e/rtl_wx.c107
-rw-r--r--drivers/staging/rtl8192e/rtl819x_BAProc.c149
-rw-r--r--drivers/staging/rtl8192e/rtl819x_HTProc.c54
-rw-r--r--drivers/staging/rtl8192e/rtl819x_Qos.h4
-rw-r--r--drivers/staging/rtl8192e/rtl819x_TS.h2
-rw-r--r--drivers/staging/rtl8192e/rtl819x_TSProc.c75
-rw-r--r--drivers/staging/rtl8192e/rtllib.h125
-rw-r--r--drivers/staging/rtl8192e/rtllib_crypt.c254
-rw-r--r--drivers/staging/rtl8192e/rtllib_crypt.h34
-rw-r--r--drivers/staging/rtl8192e/rtllib_crypt_ccmp.c2
-rw-r--r--drivers/staging/rtl8192e/rtllib_crypt_tkip.c89
-rw-r--r--drivers/staging/rtl8192e/rtllib_debug.h11
-rw-r--r--drivers/staging/rtl8192e/rtllib_module.c63
-rw-r--r--drivers/staging/rtl8192e/rtllib_rx.c1018
-rw-r--r--drivers/staging/rtl8192e/rtllib_softmac.c170
-rw-r--r--drivers/staging/rtl8192e/rtllib_softmac_wx.c18
-rw-r--r--drivers/staging/rtl8192e/rtllib_tx.c78
-rw-r--r--drivers/staging/rtl8192e/rtllib_wx.c51
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211.h188
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c10
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c26
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c9
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c76
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c32
-rw-r--r--drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c14
-rw-r--r--drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c48
-rw-r--r--drivers/staging/rtl8192u/r8192U_core.c26
-rw-r--r--drivers/staging/rtl8192u/r8192U_dm.c2
-rw-r--r--drivers/staging/rtl8712/ieee80211.h29
-rw-r--r--drivers/staging/rtl8712/os_intfs.c8
-rw-r--r--drivers/staging/rtl8712/rtl8712_recv.c3
-rw-r--r--drivers/staging/rtl8712/rtl8712_xmit.c2
-rw-r--r--drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h2
-rw-r--r--drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c2
-rw-r--r--drivers/staging/rtl8723au/hal/odm.c4
-rw-r--r--drivers/staging/rtl8723au/hal/rtl8723a_cmd.c2
-rw-r--r--drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c4
-rw-r--r--drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c2
-rw-r--r--drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c4
-rw-r--r--drivers/staging/rtl8723au/hal/rtl8723au_xmit.c2
-rw-r--r--drivers/staging/rtl8723au/hal/usb_halinit.c2
-rw-r--r--drivers/staging/rtl8723au/include/odm_debug.h2
-rw-r--r--drivers/staging/rtl8723au/include/rtl8723a_hal.h2
-rw-r--r--drivers/staging/rtl8723au/include/rtw_cmd.h2
-rw-r--r--drivers/staging/rtl8723au/include/rtw_mlme.h10
-rw-r--r--drivers/staging/rtl8723au/include/rtw_mlme_ext.h2
-rw-r--r--drivers/staging/rtl8723au/include/sta_info.h2
-rw-r--r--drivers/staging/rtl8723au/os_dep/os_intfs.c4
-rw-r--r--drivers/staging/rts5208/rtsx.c2
-rw-r--r--drivers/staging/rts5208/rtsx.h25
-rw-r--r--drivers/staging/rts5208/rtsx_scsi.c8
-rw-r--r--drivers/staging/skein/skein_api.h6
-rw-r--r--drivers/staging/slicoss/TODO1
-rw-r--r--drivers/staging/slicoss/slic.h20
-rw-r--r--drivers/staging/slicoss/slicoss.c130
-rw-r--r--drivers/staging/sm750fb/TODO3
-rw-r--r--drivers/staging/sm750fb/ddk750_chip.c6
-rw-r--r--drivers/staging/sm750fb/ddk750_chip.h69
-rw-r--r--drivers/staging/sm750fb/ddk750_help.h2
-rw-r--r--drivers/staging/sm750fb/ddk750_mode.c2
-rw-r--r--drivers/staging/sm750fb/ddk750_reg.h4
-rw-r--r--drivers/staging/sm750fb/ddk750_sii164.c4
-rw-r--r--drivers/staging/sm750fb/readme8
-rw-r--r--drivers/staging/sm750fb/sm750.c54
-rw-r--r--drivers/staging/sm750fb/sm750.h3
-rw-r--r--drivers/staging/sm750fb/sm750_accel.c4
-rw-r--r--drivers/staging/sm750fb/sm750_hw.c3
-rw-r--r--drivers/staging/sm750fb/sm750_hw.h2
-rw-r--r--drivers/staging/sm7xxfb/sm7xxfb.c228
-rw-r--r--drivers/staging/unisys/Kconfig9
-rw-r--r--drivers/staging/unisys/Makefile7
-rw-r--r--drivers/staging/unisys/common-spar/include/channels/controlframework.h62
-rw-r--r--drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h310
-rw-r--r--drivers/staging/unisys/include/channel.h (renamed from drivers/staging/unisys/common-spar/include/channels/channel.h)35
-rw-r--r--drivers/staging/unisys/include/channel_guid.h (renamed from drivers/staging/unisys/common-spar/include/channels/channel_guid.h)0
-rw-r--r--drivers/staging/unisys/include/diagchannel.h (renamed from drivers/staging/unisys/common-spar/include/channels/diagchannel.h)0
-rw-r--r--drivers/staging/unisys/include/guestlinuxdebug.h3
-rw-r--r--drivers/staging/unisys/include/iochannel.h (renamed from drivers/staging/unisys/common-spar/include/channels/iochannel.h)381
-rw-r--r--drivers/staging/unisys/include/periodic_work.h10
-rw-r--r--drivers/staging/unisys/include/procobjecttree.h47
-rw-r--r--drivers/staging/unisys/include/sparstop.h30
-rw-r--r--drivers/staging/unisys/include/timskmod.h153
-rw-r--r--drivers/staging/unisys/include/uisqueue.h396
-rw-r--r--drivers/staging/unisys/include/uisthread.h42
-rw-r--r--drivers/staging/unisys/include/uisutils.h299
-rw-r--r--drivers/staging/unisys/include/vbushelper.h2
-rw-r--r--drivers/staging/unisys/include/version.h (renamed from drivers/staging/unisys/common-spar/include/version.h)0
-rw-r--r--drivers/staging/unisys/include/visorbus.h223
-rw-r--r--drivers/staging/unisys/uislib/Kconfig10
-rw-r--r--drivers/staging/unisys/uislib/Makefile12
-rw-r--r--drivers/staging/unisys/uislib/uislib.c1372
-rw-r--r--drivers/staging/unisys/uislib/uisqueue.c322
-rw-r--r--drivers/staging/unisys/uislib/uisthread.c69
-rw-r--r--drivers/staging/unisys/uislib/uisutils.c137
-rw-r--r--drivers/staging/unisys/virthba/Kconfig13
-rw-r--r--drivers/staging/unisys/virthba/Makefile12
-rw-r--r--drivers/staging/unisys/virthba/virthba.c1572
-rw-r--r--drivers/staging/unisys/virthba/virthba.h27
-rw-r--r--drivers/staging/unisys/virtpci/Kconfig10
-rw-r--r--drivers/staging/unisys/virtpci/Makefile10
-rw-r--r--drivers/staging/unisys/virtpci/virtpci.c1394
-rw-r--r--drivers/staging/unisys/virtpci/virtpci.h103
-rw-r--r--drivers/staging/unisys/visorbus/Kconfig9
-rw-r--r--drivers/staging/unisys/visorbus/Makefile13
-rw-r--r--drivers/staging/unisys/visorbus/controlvmchannel.h (renamed from drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h)304
-rw-r--r--drivers/staging/unisys/visorbus/controlvmcompletionstatus.h (renamed from drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h)0
-rw-r--r--drivers/staging/unisys/visorbus/iovmcall_gnuc.h (renamed from drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h)0
-rw-r--r--drivers/staging/unisys/visorbus/periodic_work.c (renamed from drivers/staging/unisys/visorutil/periodic_work.c)56
-rw-r--r--drivers/staging/unisys/visorbus/vbuschannel.h (renamed from drivers/staging/unisys/common-spar/include/channels/vbuschannel.h)2
-rw-r--r--drivers/staging/unisys/visorbus/vbusdeviceinfo.h (renamed from drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h)0
-rw-r--r--drivers/staging/unisys/visorbus/visorbus_main.c1791
-rw-r--r--drivers/staging/unisys/visorbus/visorbus_private.h142
-rw-r--r--drivers/staging/unisys/visorbus/visorchannel.c (renamed from drivers/staging/unisys/visorchannel/visorchannel_funcs.c)444
-rw-r--r--drivers/staging/unisys/visorbus/visorchipset.c (renamed from drivers/staging/unisys/visorchipset/visorchipset_main.c)1504
-rw-r--r--drivers/staging/unisys/visorbus/vmcallinterface.h (renamed from drivers/staging/unisys/common-spar/include/vmcallinterface.h)4
-rw-r--r--drivers/staging/unisys/visorchannel/Kconfig1
-rw-r--r--drivers/staging/unisys/visorchannel/Makefile2
-rw-r--r--drivers/staging/unisys/visorchannel/globals.h2
-rw-r--r--drivers/staging/unisys/visorchannel/visorchannel.h76
-rw-r--r--drivers/staging/unisys/visorchipset/Kconfig11
-rw-r--r--drivers/staging/unisys/visorchipset/Makefile15
-rw-r--r--drivers/staging/unisys/visorchipset/file.c160
-rw-r--r--drivers/staging/unisys/visorchipset/file.h27
-rw-r--r--drivers/staging/unisys/visorchipset/globals.h42
-rw-r--r--drivers/staging/unisys/visorchipset/parser.c430
-rw-r--r--drivers/staging/unisys/visorchipset/parser.h46
-rw-r--r--drivers/staging/unisys/visorchipset/visorchipset.h236
-rw-r--r--drivers/staging/unisys/visorchipset/visorchipset_umode.h35
-rw-r--r--drivers/staging/unisys/visorutil/Kconfig9
-rw-r--r--drivers/staging/unisys/visorutil/Makefile9
-rw-r--r--drivers/staging/unisys/visorutil/charqueue.c127
-rw-r--r--drivers/staging/unisys/visorutil/charqueue.h37
-rw-r--r--drivers/staging/unisys/visorutil/memregion.h43
-rw-r--r--drivers/staging/unisys/visorutil/memregion_direct.c207
-rw-r--r--drivers/staging/unisys/visorutil/visorkmodutils.c71
-rw-r--r--drivers/staging/vt6655/Makefile1
-rw-r--r--drivers/staging/vt6655/device.h11
-rw-r--r--drivers/staging/vt6655/device_main.c177
-rw-r--r--drivers/staging/vt6655/mac.c49
-rw-r--r--drivers/staging/vt6655/mib.c139
-rw-r--r--drivers/staging/vt6655/mib.h82
-rw-r--r--drivers/staging/vt6655/rxtx.c2
-rw-r--r--drivers/staging/vt6656/device.h2
-rw-r--r--drivers/staging/wilc1000/Kconfig59
-rw-r--r--drivers/staging/wilc1000/Makefile34
-rw-r--r--drivers/staging/wilc1000/TODO14
-rw-r--r--drivers/staging/wilc1000/coreconfigsimulator.h20
-rw-r--r--drivers/staging/wilc1000/coreconfigurator.c2186
-rw-r--r--drivers/staging/wilc1000/coreconfigurator.h498
-rw-r--r--drivers/staging/wilc1000/fifo_buffer.c134
-rw-r--r--drivers/staging/wilc1000/fifo_buffer.h23
-rw-r--r--drivers/staging/wilc1000/host_interface.c8043
-rw-r--r--drivers/staging/wilc1000/host_interface.h1344
-rw-r--r--drivers/staging/wilc1000/itypes.h60
-rw-r--r--drivers/staging/wilc1000/linux_mon.c643
-rw-r--r--drivers/staging/wilc1000/linux_wlan.c2871
-rw-r--r--drivers/staging/wilc1000/linux_wlan_common.h170
-rw-r--r--drivers/staging/wilc1000/linux_wlan_sdio.c249
-rw-r--r--drivers/staging/wilc1000/linux_wlan_sdio.h14
-rw-r--r--drivers/staging/wilc1000/linux_wlan_spi.c507
-rw-r--r--drivers/staging/wilc1000/linux_wlan_spi.h14
-rw-r--r--drivers/staging/wilc1000/wilc_debugfs.c185
-rw-r--r--drivers/staging/wilc1000/wilc_errorsupport.h67
-rw-r--r--drivers/staging/wilc1000/wilc_exported_buf.c76
-rw-r--r--drivers/staging/wilc1000/wilc_log.h47
-rw-r--r--drivers/staging/wilc1000/wilc_memory.c58
-rw-r--r--drivers/staging/wilc1000/wilc_memory.h237
-rw-r--r--drivers/staging/wilc1000/wilc_msgqueue.c190
-rw-r--r--drivers/staging/wilc1000/wilc_msgqueue.h103
-rw-r--r--drivers/staging/wilc1000/wilc_osconfig.h9
-rw-r--r--drivers/staging/wilc1000/wilc_oswrapper.h59
-rw-r--r--drivers/staging/wilc1000/wilc_platform.h52
-rw-r--r--drivers/staging/wilc1000/wilc_sdio.c1298
-rw-r--r--drivers/staging/wilc1000/wilc_sleep.c18
-rw-r--r--drivers/staging/wilc1000/wilc_sleep.h17
-rw-r--r--drivers/staging/wilc1000/wilc_spi.c1475
-rw-r--r--drivers/staging/wilc1000/wilc_strutils.c80
-rw-r--r--drivers/staging/wilc1000/wilc_strutils.h130
-rw-r--r--drivers/staging/wilc1000/wilc_timer.c45
-rw-r--r--drivers/staging/wilc1000/wilc_timer.h126
-rw-r--r--drivers/staging/wilc1000/wilc_type.h34
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_cfgoperations.c4097
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_cfgoperations.h129
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_netdevice.c960
-rw-r--r--drivers/staging/wilc1000/wilc_wfi_netdevice.h269
-rw-r--r--drivers/staging/wilc1000/wilc_wlan.c2432
-rw-r--r--drivers/staging/wilc1000/wilc_wlan.h321
-rw-r--r--drivers/staging/wilc1000/wilc_wlan_cfg.c643
-rw-r--r--drivers/staging/wilc1000/wilc_wlan_cfg.h33
-rw-r--r--drivers/staging/wilc1000/wilc_wlan_if.h991
-rw-r--r--drivers/staging/wlan-ng/p80211conv.c2
-rw-r--r--drivers/staging/wlan-ng/prism2sta.c23
-rw-r--r--drivers/staging/xgifb/XGI_main_26.c27
-rw-r--r--drivers/staging/xgifb/vb_setmode.c21
-rw-r--r--drivers/tty/goldfish.c4
-rw-r--r--include/linux/goldfish.h19
-rw-r--r--include/linux/iio/iio.h3
-rw-r--r--include/linux/iio/types.h2
-rw-r--r--include/uapi/linux/iio/types.h2
-rw-r--r--tools/Makefile7
-rw-r--r--tools/iio/Makefile4
590 files changed, 55270 insertions, 38680 deletions
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 3befcb19f41415..bbed111c31b4ed 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -71,6 +71,8 @@ Description:
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_raw
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_raw
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_raw
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_q_raw
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
@@ -81,6 +83,11 @@ Description:
unique to allow association with event codes. Units after
application of scale and offset are millivolts.
+ Channels with 'i' and 'q' modifiers always exist in pairs and both
+ channels refer to the same signal. The 'i' channel contains the in-phase
+ component of the signal while the 'q' channel contains the quadrature
+ component.
+
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_raw
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
@@ -246,8 +253,16 @@ What: /sys/bus/iio/devices/iio:deviceX/in_accel_y_offset
What: /sys/bus/iio/devices/iio:deviceX/in_accel_z_offset
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_offset
What: /sys/bus/iio/devices/iio:deviceX/in_voltage_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_q_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_voltage_q_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_voltage_i_offset
What: /sys/bus/iio/devices/iio:deviceX/in_currentY_offset
What: /sys/bus/iio/devices/iio:deviceX/in_current_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_currentY_i_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_currentY_q_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_current_q_offset
+What: /sys/bus/iio/devices/iio:deviceX/in_current_i_offset
What: /sys/bus/iio/devices/iio:deviceX/in_tempY_offset
What: /sys/bus/iio/devices/iio:deviceX/in_temp_offset
What: /sys/bus/iio/devices/iio:deviceX/in_pressureY_offset
@@ -273,14 +288,22 @@ Description:
to the _raw output.
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_q_scale
What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_scale
What: /sys/bus/iio/devices/iio:deviceX/in_voltage_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_voltage_i_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_voltage_q_scale
What: /sys/bus/iio/devices/iio:deviceX/in_voltage-voltage_scale
What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale
What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_scale
What: /sys/bus/iio/devices/iio:deviceX/in_currentY_scale
What: /sys/bus/iio/devices/iio:deviceX/in_currentY_supply_scale
What: /sys/bus/iio/devices/iio:deviceX/in_current_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_currentY_i_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_currentY_q_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_current_i_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_current_q_scale
What: /sys/bus/iio/devices/iio:deviceX/in_accel_scale
What: /sys/bus/iio/devices/iio:deviceX/in_accel_peak_scale
What: /sys/bus/iio/devices/iio:deviceX/in_anglvel_scale
@@ -328,6 +351,10 @@ Description:
What /sys/bus/iio/devices/iio:deviceX/in_voltageY_calibscale
What /sys/bus/iio/devices/iio:deviceX/in_voltageY_supply_calibscale
+What /sys/bus/iio/devices/iio:deviceX/in_voltageY_i_calibscale
+What /sys/bus/iio/devices/iio:deviceX/in_voltageY_q_calibscale
+What /sys/bus/iio/devices/iio:deviceX/in_voltage_i_calibscale
+What /sys/bus/iio/devices/iio:deviceX/in_voltage_q_calibscale
What /sys/bus/iio/devices/iio:deviceX/in_voltage_calibscale
What /sys/bus/iio/devices/iio:deviceX/in_accel_x_calibscale
What /sys/bus/iio/devices/iio:deviceX/in_accel_y_calibscale
@@ -420,6 +447,16 @@ Description:
to the underlying data channel, then this parameter
gives the 3dB frequency of the filter in Hz.
+What: /sys/.../in_accel_filter_high_pass_3db_frequency
+What: /sys/.../in_anglvel_filter_high_pass_3db_frequency
+What: /sys/.../in_magn_filter_high_pass_3db_frequency
+KernelVersion: 4.2
+Contact: linux-iio@vger.kernel.org
+Description:
+ If a known or controllable high pass filter is applied
+ to the underlying data channel, then this parameter
+ gives the 3dB frequency of the filter in Hz.
+
What: /sys/bus/iio/devices/iio:deviceX/out_voltageY_raw
What: /sys/bus/iio/devices/iio:deviceX/out_altvoltageY_raw
KernelVersion: 2.6.37
@@ -880,6 +917,26 @@ Description:
met before an event is generated. If direction is not
specified then this period applies to both directions.
+What: /sys/.../events/in_accel_thresh_rising_low_pass_filter_3db
+What: /sys/.../events/in_anglvel_thresh_rising_low_pass_filter_3db
+What: /sys/.../events/in_magn_thresh_rising_low_pass_filter_3db
+KernelVersion: 4.2
+Contact: linux-iio@vger.kernel.org
+Description:
+ If a low pass filter can be applied to the event generation
+ this property gives its 3db frequency in Hz.
+ A value of zero disables the filter.
+
+What: /sys/.../events/in_accel_thresh_rising_high_pass_filter_3db
+What: /sys/.../events/in_anglvel_thresh_rising_high_pass_filter_3db
+What: /sys/.../events/in_magn_thresh_rising_high_pass_filter_3db
+KernelVersion: 4.2
+Contact: linux-iio@vger.kernel.org
+Description:
+ If a high pass filter can be applied to the event generation
+ this property gives its 3db frequency in Hz.
+ A value of zero disables the filter.
+
What: /sys/.../events/in_activity_still_thresh_rising_en
What: /sys/.../events/in_activity_still_thresh_falling_en
What: /sys/.../events/in_activity_walking_thresh_rising_en
@@ -1016,6 +1073,10 @@ What: /sys/.../iio:deviceX/scan_elements/in_timestamp_en
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_en
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_en
What: /sys/.../iio:deviceX/scan_elements/in_voltageY-voltageZ_en
+What: /sys/.../iio:deviceX/scan_elements/in_voltageY_i_en
+What: /sys/.../iio:deviceX/scan_elements/in_voltageY_q_en
+What: /sys/.../iio:deviceX/scan_elements/in_voltage_i_en
+What: /sys/.../iio:deviceX/scan_elements/in_voltage_q_en
What: /sys/.../iio:deviceX/scan_elements/in_incli_x_en
What: /sys/.../iio:deviceX/scan_elements/in_incli_y_en
What: /sys/.../iio:deviceX/scan_elements/in_pressureY_en
@@ -1034,6 +1095,10 @@ What: /sys/.../iio:deviceX/scan_elements/in_incli_type
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_type
What: /sys/.../iio:deviceX/scan_elements/in_voltage_type
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_type
+What: /sys/.../iio:deviceX/scan_elements/in_voltageY_i_type
+What: /sys/.../iio:deviceX/scan_elements/in_voltageY_q_type
+What: /sys/.../iio:deviceX/scan_elements/in_voltage_i_type
+What: /sys/.../iio:deviceX/scan_elements/in_voltage_q_type
What: /sys/.../iio:deviceX/scan_elements/in_timestamp_type
What: /sys/.../iio:deviceX/scan_elements/in_pressureY_type
What: /sys/.../iio:deviceX/scan_elements/in_pressure_type
@@ -1071,6 +1136,10 @@ Description:
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_index
What: /sys/.../iio:deviceX/scan_elements/in_voltageY_supply_index
+What: /sys/.../iio:deviceX/scan_elements/in_voltageY_i_index
+What: /sys/.../iio:deviceX/scan_elements/in_voltageY_q_index
+What: /sys/.../iio:deviceX/scan_elements/in_voltage_i_index
+What: /sys/.../iio:deviceX/scan_elements/in_voltage_q_index
What: /sys/.../iio:deviceX/scan_elements/in_accel_x_index
What: /sys/.../iio:deviceX/scan_elements/in_accel_y_index
What: /sys/.../iio:deviceX/scan_elements/in_accel_z_index
@@ -1230,6 +1299,8 @@ Description:
or without compensation from tilt sensors.
What: /sys/bus/iio/devices/iio:deviceX/in_currentX_raw
+What: /sys/bus/iio/devices/iio:deviceX/in_currentX_i_raw
+What: /sys/bus/iio/devices/iio:deviceX/in_currentX_q_raw
KernelVersion: 3.18
Contact: linux-iio@vger.kernel.org
Description:
@@ -1238,6 +1309,11 @@ Description:
present, output should be considered as processed with the
unit in milliamps.
+ Channels with 'i' and 'q' modifiers always exist in pairs and both
+ channels refer to the same signal. The 'i' channel contains the in-phase
+ component of the signal while the 'q' channel contains the quadrature
+ component.
+
What: /sys/.../iio:deviceX/in_energy_en
What: /sys/.../iio:deviceX/in_distance_en
What: /sys/.../iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_en
@@ -1364,3 +1440,26 @@ Description:
hwfifo_watermak_min but not equal to any of the values in this
list, the driver will chose an appropriate value for the
hardware fifo watermark level.
+
+What: /sys/bus/iio/devices/iio:deviceX/in_temp_calibemissivity
+What: /sys/bus/iio/devices/iio:deviceX/in_tempX_calibemissivity
+What: /sys/bus/iio/devices/iio:deviceX/in_temp_object_calibemissivity
+What: /sys/bus/iio/devices/iio:deviceX/in_tempX_object_calibemissivity
+KernelVersion: 4.1
+Contact: linux-iio@vger.kernel.org
+Description:
+ The emissivity ratio of the surface in the field of view of the
+ contactless temperature sensor. Emissivity varies from 0 to 1,
+ with 1 being the emissivity of a black body.
+
+What: /sys/bus/iio/devices/iio:deviceX/in_magn_x_oversampling_ratio
+What: /sys/bus/iio/devices/iio:deviceX/in_magn_y_oversampling_ratio
+What: /sys/bus/iio/devices/iio:deviceX/in_magn_z_oversampling_ratio
+KernelVersion: 4.2
+Contact: linux-iio@vger.kernel.org
+Description:
+ Hardware applied number of measurements for acquiring one
+ data point. The HW will do <type>[_name]_oversampling_ratio
+ measurements and return the average value as output data. Each
+ value resulted from <type>[_name]_oversampling_ratio measurements
+ is considered as one sample for <type>[_name]_sampling_frequency.
diff --git a/Documentation/devicetree/bindings/iio/adc/berlin2_adc.txt b/Documentation/devicetree/bindings/iio/adc/berlin2_adc.txt
new file mode 100644
index 00000000000000..908334c6b07f53
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/adc/berlin2_adc.txt
@@ -0,0 +1,19 @@
+* Berlin Analog to Digital Converter (ADC)
+
+The Berlin ADC has 8 channels, with one connected to a temperature sensor.
+It is part of the system controller register set. The ADC node should be a
+sub-node of the system controller node.
+
+Required properties:
+- compatible: must be "marvell,berlin2-adc"
+- interrupts: the interrupts for the ADC and the temperature sensor
+- interrupt-names: should be "adc" and "tsen"
+
+Example:
+
+adc: adc {
+ compatible = "marvell,berlin2-adc";
+ interrupt-parent = <&sic>;
+ interrupts = <12>, <14>;
+ interrupt-names = "adc", "tsen";
+};
diff --git a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
index 42ca7deec97d72..15ca6b47958e97 100644
--- a/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
+++ b/Documentation/devicetree/bindings/iio/adc/ti-adc128s052.txt
@@ -1,7 +1,7 @@
-* Texas Instruments' ADC128S052 ADC chip
+* Texas Instruments' ADC128S052 and ADC122S021 ADC chip
Required properties:
- - compatible: Should be "ti,adc128s052"
+ - compatible: Should be "ti,adc128s052" or "ti,adc122s021"
- reg: spi chip select number for the device
- vref-supply: The regulator supply for ADC reference voltage
diff --git a/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt
new file mode 100644
index 00000000000000..e4d8f1c52f4a44
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/imu/inv_mpu6050.txt
@@ -0,0 +1,17 @@
+InvenSense MPU-6050 Six-Axis (Gyro + Accelerometer) MEMS MotionTracking Device
+
+http://www.invensense.com/mems/gyro/mpu6050.html
+
+Required properties:
+ - compatible : should be "invensense,mpu6050"
+ - reg : the I2C address of the sensor
+ - interrupt-parent : should be the phandle for the interrupt controller
+ - interrupts : interrupt mapping for GPIO IRQ
+
+Example:
+ mpu6050@68 {
+ compatible = "invensense,mpu6050";
+ reg = <0x68>;
+ interrupt-parent = <&gpio1>;
+ interrupts = <18 1>;
+ };
diff --git a/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt b/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt
new file mode 100644
index 00000000000000..9f263b7df16280
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/magnetometer/bmc150_magn.txt
@@ -0,0 +1,22 @@
+* Bosch BMC150 magnetometer sensor
+
+http://ae-bst.resource.bosch.com/media/products/dokumente/bmc150/BST-BMC150-DS000-04.pdf
+
+Required properties:
+
+ - compatible : should be "bosch,bmc150_magn"
+ - reg : the I2C address of the magnetometer
+
+Optional properties:
+
+ - interrupt-parent : phandle to the parent interrupt controller
+ - interrupts : interrupt mapping for GPIO IRQ
+
+Example:
+
+bmc150_magn@12 {
+ compatible = "bosch,bmc150_magn";
+ reg = <0x12>;
+ interrupt-parent = <&gpio1>;
+ interrupts = <0 1>;
+};
diff --git a/Documentation/devicetree/bindings/iio/st-sensors.txt b/Documentation/devicetree/bindings/iio/st-sensors.txt
index d2aaca97453196..fb5e0c2d18b5d4 100644
--- a/Documentation/devicetree/bindings/iio/st-sensors.txt
+++ b/Documentation/devicetree/bindings/iio/st-sensors.txt
@@ -45,6 +45,7 @@ Gyroscopes:
- st,lsm330-gyro
Magnetometers:
+- st,lsm303dlh-magn
- st,lsm303dlhc-magn
- st,lsm303dlm-magn
- st,lis3mdl-magn
diff --git a/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt b/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt
new file mode 100644
index 00000000000000..9be57b036092cb
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/temperature/mlx90614.txt
@@ -0,0 +1,24 @@
+* Melexis MLX90614 contactless IR temperature sensor
+
+http://melexis.com/Infrared-Thermometer-Sensors/Infrared-Thermometer-Sensors/MLX90614-615.aspx
+
+Required properties:
+
+ - compatible: should be "melexis,mlx90614"
+ - reg: the I2C address of the sensor
+
+Optional properties:
+
+ - wakeup-gpios: device tree identifier of the GPIO connected to the SDA line
+ to hold low in order to wake up the device. In normal operation, the
+ GPIO is set as input and will not interfere in I2C communication. There
+ is no need for a GPIO driving the SCL line. If no GPIO is given, power
+ management is disabled.
+
+Example:
+
+mlx90614@5a {
+ compatible = "melexis,mlx90614";
+ reg = <0x5a>;
+ wakeup-gpios = <&gpio0 2 GPIO_ACTIVE_HIGH>;
+};
diff --git a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
index 6c4fb34823d3e6..b1163bf9714683 100644
--- a/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
+++ b/Documentation/devicetree/bindings/input/touchscreen/ti-tsc-adc.txt
@@ -42,6 +42,27 @@ Optional properties:
hardware knob for adjusting the amount of "settling
time".
+- child "adc"
+ ti,chan-step-opendelay: List of open delays for each channel of
+ ADC in the order of ti,adc-channels. The
+ value corresponds to the number of ADC
+ clock cycles to wait after applying the
+ step configuration registers and before
+ sending the start of ADC conversion.
+ Maximum value is 0x3FFFF.
+ ti,chan-step-sampledelay: List of sample delays for each channel
+ of ADC in the order of ti,adc-channels.
+ The value corresponds to the number of
+ ADC clock cycles to sample (to hold
+ start of conversion high).
+ Maximum value is 0xFF.
+ ti,chan-step-avg: Number of averages to be performed for each
+ channel of ADC. If average is 16 then input
+ is sampled 16 times and averaged to get more
+ accurate value. This increases the time taken
+ by ADC to generate a sample. Valid range is 0
+ average to 16 averages. Maximum value is 16.
+
Example:
tscadc: tscadc@44e0d000 {
compatible = "ti,am3359-tscadc";
@@ -55,5 +76,8 @@ Example:
adc {
ti,adc-channels = <4 5 6 7>;
+ ti,chan-step-opendelay = <0x098 0x3ffff 0x098 0x0>;
+ ti,chan-step-sampledelay = <0xff 0x0 0xf 0x0>;
+ ti,chan-step-avg = <16 2 4 8>;
};
}
diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt
index db65100d02a2b8..ee2ce7ba088cb8 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -125,6 +125,7 @@ lltc Linear Technology Corporation
marvell Marvell Technology Group Ltd.
maxim Maxim Integrated Products
mediatek MediaTek Inc.
+melexis Melexis N.V.
merrii Merrii Technology Co., Ltd.
micrel Micrel Inc.
microchip Microchip Technology Inc.
diff --git a/MAINTAINERS b/MAINTAINERS
index 31105c2302cf67..f13a2d9266e500 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9636,6 +9636,15 @@ M: Forest Bond <forest@alittletooquiet.net>
S: Odd Fixes
F: drivers/staging/vt665?/
+STAGING - WILC1000 WIFI DRIVER
+M: Johnny Kim <johnny.kim@atmel.com>
+M: Rachel Kim <rachel.kim@atmel.com>
+M: Dean Lee <dean.lee@atmel.com>
+M: Chris Park <chris.park@atmel.com>
+L: linux-wireless@vger.kernel.org
+S: Supported
+F: drivers/staging/wilc1000/
+
STAGING - XGI Z7,Z9,Z11 PCI DISPLAY DRIVER
M: Arnaud Patard <arnaud.patard@rtp-net.org>
S: Odd Fixes
diff --git a/drivers/Makefile b/drivers/Makefile
index 46d2554be40459..9a02fb7c5106a6 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -98,7 +98,6 @@ obj-$(CONFIG_USB_GADGET) += usb/
obj-$(CONFIG_SERIO) += input/serio/
obj-$(CONFIG_GAMEPORT) += input/gameport/
obj-$(CONFIG_INPUT) += input/
-obj-$(CONFIG_I2O) += message/
obj-$(CONFIG_RTC_LIB) += rtc/
obj-y += i2c/ media/
obj-$(CONFIG_PPS) += pps/
diff --git a/drivers/iio/accel/Kconfig b/drivers/iio/accel/Kconfig
index 7c9a9a94a8ce9b..00e7bcbdbe2474 100644
--- a/drivers/iio/accel/Kconfig
+++ b/drivers/iio/accel/Kconfig
@@ -136,4 +136,25 @@ config MMA9553
To compile this driver as a module, choose M here: the module
will be called mma9553.
+
+config STK8312
+ tristate "Sensortek STK8312 3-Axis Accelerometer Driver"
+ depends on I2C
+ help
+ Say yes here to get support for the Sensortek STK8312 3-axis
+ accelerometer.
+
+ Choosing M will build the driver as a module. If so, the module
+ will be called stk8312.
+
+config STK8BA50
+ tristate "Sensortek STK8BA50 3-Axis Accelerometer Driver"
+ depends on I2C
+ help
+ Say yes here to get support for the Sensortek STK8BA50 3-axis
+ accelerometer.
+
+ Choosing M will build the driver as a module. If so, the module
+ will be called stk8ba50.
+
endmenu
diff --git a/drivers/iio/accel/Makefile b/drivers/iio/accel/Makefile
index 99d89e46cad132..ebd2675b2a0230 100644
--- a/drivers/iio/accel/Makefile
+++ b/drivers/iio/accel/Makefile
@@ -14,6 +14,9 @@ obj-$(CONFIG_MMA9551_CORE) += mma9551_core.o
obj-$(CONFIG_MMA9551) += mma9551.o
obj-$(CONFIG_MMA9553) += mma9553.o
+obj-$(CONFIG_STK8312) += stk8312.o
+obj-$(CONFIG_STK8BA50) += stk8ba50.o
+
obj-$(CONFIG_IIO_SSP_SENSORS_COMMONS) += ssp_accel_sensor.o
obj-$(CONFIG_IIO_ST_ACCEL_3AXIS) += st_accel.o
diff --git a/drivers/iio/accel/bmc150-accel.c b/drivers/iio/accel/bmc150-accel.c
index 73e87739d21918..4e70f51c237089 100644
--- a/drivers/iio/accel/bmc150-accel.c
+++ b/drivers/iio/accel/bmc150-accel.c
@@ -196,7 +196,7 @@ struct bmc150_accel_data {
u32 slope_thres;
u32 range;
int ev_enable_state;
- int64_t timestamp, old_timestamp;
+ int64_t timestamp, old_timestamp; /* Only used in hw fifo mode. */
const struct bmc150_accel_chip_info *chip_info;
};
@@ -1183,7 +1183,6 @@ static const struct iio_info bmc150_accel_info = {
.write_event_value = bmc150_accel_write_event,
.write_event_config = bmc150_accel_write_event_config,
.read_event_config = bmc150_accel_read_event_config,
- .validate_trigger = bmc150_accel_validate_trigger,
.driver_module = THIS_MODULE,
};
@@ -1222,7 +1221,7 @@ static irqreturn_t bmc150_accel_trigger_handler(int irq, void *p)
mutex_unlock(&data->mutex);
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
- data->timestamp);
+ pf->timestamp);
err_read:
iio_trigger_notify_done(indio_dev->trig);
@@ -1535,6 +1534,13 @@ static int bmc150_accel_fifo_set_mode(struct bmc150_accel_data *data)
return ret;
}
+static int bmc150_accel_buffer_preenable(struct iio_dev *indio_dev)
+{
+ struct bmc150_accel_data *data = iio_priv(indio_dev);
+
+ return bmc150_accel_set_power_state(data, true);
+}
+
static int bmc150_accel_buffer_postenable(struct iio_dev *indio_dev)
{
struct bmc150_accel_data *data = iio_priv(indio_dev);
@@ -1591,9 +1597,18 @@ out:
return 0;
}
+static int bmc150_accel_buffer_postdisable(struct iio_dev *indio_dev)
+{
+ struct bmc150_accel_data *data = iio_priv(indio_dev);
+
+ return bmc150_accel_set_power_state(data, false);
+}
+
static const struct iio_buffer_setup_ops bmc150_accel_buffer_ops = {
+ .preenable = bmc150_accel_buffer_preenable,
.postenable = bmc150_accel_buffer_postenable,
.predisable = bmc150_accel_buffer_predisable,
+ .postdisable = bmc150_accel_buffer_postdisable,
};
static int bmc150_accel_probe(struct i2c_client *client,
@@ -1636,6 +1651,15 @@ static int bmc150_accel_probe(struct i2c_client *client,
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &bmc150_accel_info;
+ ret = iio_triggered_buffer_setup(indio_dev,
+ &iio_pollfunc_store_time,
+ bmc150_accel_trigger_handler,
+ &bmc150_accel_buffer_ops);
+ if (ret < 0) {
+ dev_err(&client->dev, "Failed: iio triggered buffer setup\n");
+ return ret;
+ }
+
if (client->irq < 0)
client->irq = bmc150_accel_gpio_probe(client, data);
@@ -1648,7 +1672,7 @@ static int bmc150_accel_probe(struct i2c_client *client,
BMC150_ACCEL_IRQ_NAME,
indio_dev);
if (ret)
- return ret;
+ goto err_buffer_cleanup;
/*
* Set latched mode interrupt. While certain interrupts are
@@ -1661,24 +1685,14 @@ static int bmc150_accel_probe(struct i2c_client *client,
BMC150_ACCEL_INT_MODE_LATCH_RESET);
if (ret < 0) {
dev_err(&data->client->dev, "Error writing reg_int_rst_latch\n");
- return ret;
+ goto err_buffer_cleanup;
}
bmc150_accel_interrupts_setup(indio_dev, data);
ret = bmc150_accel_triggers_setup(indio_dev, data);
if (ret)
- return ret;
-
- ret = iio_triggered_buffer_setup(indio_dev,
- &iio_pollfunc_store_time,
- bmc150_accel_trigger_handler,
- &bmc150_accel_buffer_ops);
- if (ret < 0) {
- dev_err(&client->dev,
- "Failed: iio triggered buffer setup\n");
- goto err_trigger_unregister;
- }
+ goto err_buffer_cleanup;
if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) ||
i2c_check_functionality(client->adapter,
@@ -1692,7 +1706,7 @@ static int bmc150_accel_probe(struct i2c_client *client,
ret = iio_device_register(indio_dev);
if (ret < 0) {
dev_err(&client->dev, "Unable to register iio device\n");
- goto err_buffer_cleanup;
+ goto err_trigger_unregister;
}
ret = pm_runtime_set_active(&client->dev);
@@ -1708,11 +1722,10 @@ static int bmc150_accel_probe(struct i2c_client *client,
err_iio_unregister:
iio_device_unregister(indio_dev);
-err_buffer_cleanup:
- if (indio_dev->pollfunc)
- iio_triggered_buffer_cleanup(indio_dev);
err_trigger_unregister:
bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1);
+err_buffer_cleanup:
+ iio_triggered_buffer_cleanup(indio_dev);
return ret;
}
@@ -1730,6 +1743,8 @@ static int bmc150_accel_remove(struct i2c_client *client)
bmc150_accel_unregister_triggers(data, BMC150_ACCEL_TRIGGERS - 1);
+ iio_triggered_buffer_cleanup(indio_dev);
+
mutex_lock(&data->mutex);
bmc150_accel_set_mode(data, BMC150_ACCEL_SLEEP_MODE_DEEP_SUSPEND, 0);
mutex_unlock(&data->mutex);
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c
index 2b4fad6998c150..ab1e238d5c7520 100644
--- a/drivers/iio/accel/hid-sensor-accel-3d.c
+++ b/drivers/iio/accel/hid-sensor-accel-3d.c
@@ -299,7 +299,6 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct accel_3d_state *accel_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct accel_3d_state));
@@ -320,21 +319,21 @@ static int hid_accel_3d_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(accel_3d_channels, sizeof(accel_3d_channels),
- GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(accel_3d_channels,
+ sizeof(accel_3d_channels), GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = accel_3d_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_ACCEL_3D, accel_state);
+ ret = accel_3d_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_ACCEL_3D, accel_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels = ARRAY_SIZE(accel_3d_channels);
indio_dev->dev.parent = &pdev->dev;
indio_dev->info = &accel_3d_info;
@@ -400,7 +399,7 @@ static int hid_accel_3d_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id hid_accel_3d_ids[] = {
+static const struct platform_device_id hid_accel_3d_ids[] = {
{
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200073",
diff --git a/drivers/iio/accel/kxcjk-1013.c b/drivers/iio/accel/kxcjk-1013.c
index 51da3692d56137..0d9bd35ff2586b 100644
--- a/drivers/iio/accel/kxcjk-1013.c
+++ b/drivers/iio/accel/kxcjk-1013.c
@@ -875,15 +875,18 @@ static int kxcjk1013_write_event_config(struct iio_dev *indio_dev,
return 0;
}
-static int kxcjk1013_validate_trigger(struct iio_dev *indio_dev,
- struct iio_trigger *trig)
+static int kxcjk1013_buffer_preenable(struct iio_dev *indio_dev)
{
struct kxcjk1013_data *data = iio_priv(indio_dev);
- if (data->dready_trig != trig && data->motion_trig != trig)
- return -EINVAL;
+ return kxcjk1013_set_power_state(data, true);
+}
- return 0;
+static int kxcjk1013_buffer_postdisable(struct iio_dev *indio_dev)
+{
+ struct kxcjk1013_data *data = iio_priv(indio_dev);
+
+ return kxcjk1013_set_power_state(data, false);
}
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL(
@@ -935,6 +938,13 @@ static const struct iio_chan_spec kxcjk1013_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(3),
};
+static const struct iio_buffer_setup_ops kxcjk1013_buffer_setup_ops = {
+ .preenable = kxcjk1013_buffer_preenable,
+ .postenable = iio_triggered_buffer_postenable,
+ .postdisable = kxcjk1013_buffer_postdisable,
+ .predisable = iio_triggered_buffer_predisable,
+};
+
static const struct iio_info kxcjk1013_info = {
.attrs = &kxcjk1013_attrs_group,
.read_raw = kxcjk1013_read_raw,
@@ -943,7 +953,6 @@ static const struct iio_info kxcjk1013_info = {
.write_event_value = kxcjk1013_write_event,
.write_event_config = kxcjk1013_write_event_config,
.read_event_config = kxcjk1013_read_event_config,
- .validate_trigger = kxcjk1013_validate_trigger,
.driver_module = THIS_MODULE,
};
@@ -1147,8 +1156,10 @@ static const char *kxcjk1013_match_acpi_device(struct device *dev,
id = acpi_match_device(dev->driver->acpi_match_table, dev);
if (!id)
return NULL;
+
if (strcmp(id->id, "SMO8500") == 0)
*is_smo8500_device = true;
+
*chipset = (enum kx_chipset)id->driver_data;
return dev_name(dev);
@@ -1163,6 +1174,7 @@ static int kxcjk1013_gpio_probe(struct i2c_client *client,
if (!client)
return -EINVAL;
+
if (data->is_smo8500_device)
return -ENOTSUPP;
@@ -1276,16 +1288,15 @@ static int kxcjk1013_probe(struct i2c_client *client,
data->motion_trig = NULL;
goto err_trigger_unregister;
}
+ }
- ret = iio_triggered_buffer_setup(indio_dev,
- &iio_pollfunc_store_time,
- kxcjk1013_trigger_handler,
- NULL);
- if (ret < 0) {
- dev_err(&client->dev,
- "iio triggered buffer setup failed\n");
- goto err_trigger_unregister;
- }
+ ret = iio_triggered_buffer_setup(indio_dev,
+ &iio_pollfunc_store_time,
+ kxcjk1013_trigger_handler,
+ &kxcjk1013_buffer_setup_ops);
+ if (ret < 0) {
+ dev_err(&client->dev, "iio triggered buffer setup failed\n");
+ goto err_trigger_unregister;
}
ret = iio_device_register(indio_dev);
@@ -1418,6 +1429,7 @@ static const struct dev_pm_ops kxcjk1013_pm_ops = {
static const struct acpi_device_id kx_acpi_match[] = {
{"KXCJ1013", KXCJK1013},
{"KXCJ1008", KXCJ91008},
+ {"KXCJ9000", KXCJ91008},
{"KXTJ1009", KXTJ21009},
{"SMO8500", KXCJ91008},
{ },
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c
index 5b80657883bb8f..877ce2954196b0 100644
--- a/drivers/iio/accel/mma8452.c
+++ b/drivers/iio/accel/mma8452.c
@@ -32,6 +32,9 @@
#define MMA8452_OFF_Z 0x31
#define MMA8452_CTRL_REG1 0x2a
#define MMA8452_CTRL_REG2 0x2b
+#define MMA8452_CTRL_REG2_RST BIT(6)
+
+#define MMA8452_MAX_REG 0x31
#define MMA8452_STATUS_DRDY (BIT(2) | BIT(1) | BIT(0))
@@ -291,6 +294,28 @@ done:
return IRQ_HANDLED;
}
+static int mma8452_reg_access_dbg(struct iio_dev *indio_dev,
+ unsigned reg, unsigned writeval,
+ unsigned *readval)
+{
+ int ret;
+ struct mma8452_data *data = iio_priv(indio_dev);
+
+ if (reg > MMA8452_MAX_REG)
+ return -EINVAL;
+
+ if (!readval)
+ return mma8452_change_config(data, reg, writeval);
+
+ ret = i2c_smbus_read_byte_data(data->client, reg);
+ if (ret < 0)
+ return ret;
+
+ *readval = ret;
+
+ return 0;
+}
+
#define MMA8452_CHANNEL(axis, idx) { \
.type = IIO_ACCEL, \
.modified = 1, \
@@ -330,11 +355,36 @@ static const struct iio_info mma8452_info = {
.attrs = &mma8452_group,
.read_raw = &mma8452_read_raw,
.write_raw = &mma8452_write_raw,
+ .debugfs_reg_access = &mma8452_reg_access_dbg,
.driver_module = THIS_MODULE,
};
static const unsigned long mma8452_scan_masks[] = {0x7, 0};
+static int mma8452_reset(struct i2c_client *client)
+{
+ int i;
+ int ret;
+
+ ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG2,
+ MMA8452_CTRL_REG2_RST);
+ if (ret < 0)
+ return ret;
+
+ for (i = 0; i < 10; i++) {
+ usleep_range(100, 200);
+ ret = i2c_smbus_read_byte_data(client, MMA8452_CTRL_REG2);
+ if (ret == -EIO)
+ continue; /* I2C comm reset */
+ if (ret < 0)
+ return ret;
+ if (!(ret & MMA8452_CTRL_REG2_RST))
+ return 0;
+ }
+
+ return -ETIMEDOUT;
+}
+
static int mma8452_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -365,10 +415,7 @@ static int mma8452_probe(struct i2c_client *client,
indio_dev->num_channels = ARRAY_SIZE(mma8452_channels);
indio_dev->available_scan_masks = mma8452_scan_masks;
- data->ctrl_reg1 = MMA8452_CTRL_ACTIVE |
- (MMA8452_CTRL_DR_DEFAULT << MMA8452_CTRL_DR_SHIFT);
- ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG1,
- data->ctrl_reg1);
+ ret = mma8452_reset(client);
if (ret < 0)
return ret;
@@ -378,6 +425,13 @@ static int mma8452_probe(struct i2c_client *client,
if (ret < 0)
return ret;
+ data->ctrl_reg1 = MMA8452_CTRL_ACTIVE |
+ (MMA8452_CTRL_DR_DEFAULT << MMA8452_CTRL_DR_SHIFT);
+ ret = i2c_smbus_write_byte_data(client, MMA8452_CTRL_REG1,
+ data->ctrl_reg1);
+ if (ret < 0)
+ return ret;
+
ret = iio_triggered_buffer_setup(indio_dev, NULL,
mma8452_trigger_handler, NULL);
if (ret < 0)
diff --git a/drivers/iio/accel/mma9551_core.c b/drivers/iio/accel/mma9551_core.c
index c6d5a3a40b609c..2fd2a995686b27 100644
--- a/drivers/iio/accel/mma9551_core.c
+++ b/drivers/iio/accel/mma9551_core.c
@@ -374,7 +374,7 @@ EXPORT_SYMBOL(mma9551_read_status_word);
* @app_id: Application ID
* @reg: Application register
* @len: Length of array to read in bytes
- * @val: Array of words to read
+ * @buf: Array of words to read
*
* Read multiple configuration registers (word-sized registers).
*
@@ -414,7 +414,7 @@ EXPORT_SYMBOL(mma9551_read_config_words);
* @app_id: Application ID
* @reg: Application register
* @len: Length of array to read in bytes
- * @val: Array of words to read
+ * @buf: Array of words to read
*
* Read multiple status registers (word-sized registers).
*
@@ -454,7 +454,7 @@ EXPORT_SYMBOL(mma9551_read_status_words);
* @app_id: Application ID
* @reg: Application register
* @len: Length of array to write in bytes
- * @val: Array of words to write
+ * @buf: Array of words to write
*
* Write multiple configuration registers (word-sized registers).
*
@@ -800,7 +800,7 @@ EXPORT_SYMBOL(mma9551_read_accel_scale);
*/
int mma9551_app_reset(struct i2c_client *client, u32 app_mask)
{
- return mma9551_write_config_byte(client, MMA9551_APPID_RCS,
+ return mma9551_write_config_byte(client, MMA9551_APPID_RSC,
MMA9551_RSC_RESET +
MMA9551_RSC_OFFSET(app_mask),
MMA9551_RSC_VAL(app_mask));
diff --git a/drivers/iio/accel/mma9551_core.h b/drivers/iio/accel/mma9551_core.h
index edaa56b1078e10..79939e40805a00 100644
--- a/drivers/iio/accel/mma9551_core.h
+++ b/drivers/iio/accel/mma9551_core.h
@@ -22,7 +22,7 @@
#define MMA9551_APPID_TILT 0x0B
#define MMA9551_APPID_SLEEP_WAKE 0x12
#define MMA9551_APPID_PEDOMETER 0x15
-#define MMA9551_APPID_RCS 0x17
+#define MMA9551_APPID_RSC 0x17
#define MMA9551_APPID_NONE 0xff
/* Reset/Suspend/Clear application app masks */
diff --git a/drivers/iio/accel/mma9553.c b/drivers/iio/accel/mma9553.c
index 365a109aaaefe8..8bfc61824fb237 100644
--- a/drivers/iio/accel/mma9553.c
+++ b/drivers/iio/accel/mma9553.c
@@ -63,8 +63,8 @@
#define MMA9553_MASK_STATUS_STEPCHG BIT(13)
#define MMA9553_MASK_STATUS_ACTCHG BIT(12)
#define MMA9553_MASK_STATUS_SUSP BIT(11)
-#define MMA9553_MASK_STATUS_ACTIVITY (BIT(10) | BIT(9) | BIT(8))
-#define MMA9553_MASK_STATUS_VERSION 0x00FF
+#define MMA9553_MASK_STATUS_ACTIVITY GENMASK(10, 8)
+#define MMA9553_MASK_STATUS_VERSION GENMASK(7, 0)
#define MMA9553_REG_STEPCNT 0x02
#define MMA9553_REG_DISTANCE 0x04
@@ -76,14 +76,15 @@
#define MMA9553_DEFAULT_GPIO_PIN mma9551_gpio6
#define MMA9553_DEFAULT_GPIO_POLARITY 0
-/* Bitnum used for gpio configuration = bit number in high status byte */
-#define STATUS_TO_BITNUM(bit) (ffs(bit) - 9)
+/* Bitnum used for GPIO configuration = bit number in high status byte */
+#define MMA9553_STATUS_TO_BITNUM(bit) (ffs(bit) - 9)
+#define MMA9553_MAX_BITNUM MMA9553_STATUS_TO_BITNUM(BIT(16))
#define MMA9553_DEFAULT_SAMPLE_RATE 30 /* Hz */
/*
* The internal activity level must be stable for ACTTHD samples before
- * ACTIVITY is updated.The ACTIVITY variable contains the current activity
+ * ACTIVITY is updated. The ACTIVITY variable contains the current activity
* level and is updated every time a step is detected or once a second
* if there are no steps.
*/
@@ -351,11 +352,11 @@ static int mma9553_conf_gpio(struct mma9553_data *data)
* This bit is the logical OR of the SUSPCHG, STEPCHG, and ACTCHG flags.
*/
if (activity_enabled && ev_step_detect->enabled)
- bitnum = STATUS_TO_BITNUM(MMA9553_MASK_STATUS_MRGFL);
+ bitnum = MMA9553_STATUS_TO_BITNUM(MMA9553_MASK_STATUS_MRGFL);
else if (ev_step_detect->enabled)
- bitnum = STATUS_TO_BITNUM(MMA9553_MASK_STATUS_STEPCHG);
+ bitnum = MMA9553_STATUS_TO_BITNUM(MMA9553_MASK_STATUS_STEPCHG);
else if (activity_enabled)
- bitnum = STATUS_TO_BITNUM(MMA9553_MASK_STATUS_ACTCHG);
+ bitnum = MMA9553_STATUS_TO_BITNUM(MMA9553_MASK_STATUS_ACTCHG);
else /* Reset */
appid = MMA9551_APPID_NONE;
@@ -363,9 +364,12 @@ static int mma9553_conf_gpio(struct mma9553_data *data)
return 0;
/* Save initial values for activity and stepcnt */
- if (activity_enabled || ev_step_detect->enabled)
- mma9553_read_activity_stepcnt(data, &data->activity,
- &data->stepcnt);
+ if (activity_enabled || ev_step_detect->enabled) {
+ ret = mma9553_read_activity_stepcnt(data, &data->activity,
+ &data->stepcnt);
+ if (ret < 0)
+ return ret;
+ }
ret = mma9551_gpio_config(data->client,
MMA9553_DEFAULT_GPIO_PIN,
@@ -396,13 +400,13 @@ static int mma9553_init(struct mma9553_data *data)
sizeof(data->conf), (u16 *) &data->conf);
if (ret < 0) {
dev_err(&data->client->dev,
- "device is not MMA9553L: failed to read cfg regs\n");
+ "failed to read configuration registers\n");
return ret;
}
- /* Reset gpio */
- data->gpio_bitnum = -1;
+ /* Reset GPIO */
+ data->gpio_bitnum = MMA9553_MAX_BITNUM;
ret = mma9553_conf_gpio(data);
if (ret < 0)
return ret;
@@ -436,6 +440,32 @@ static int mma9553_init(struct mma9553_data *data)
return mma9551_set_device_state(data->client, true);
}
+static int mma9553_read_status_word(struct mma9553_data *data, u16 reg,
+ u16 *tmp)
+{
+ bool powered_on;
+ int ret;
+
+ /*
+ * The HW only counts steps and other dependent
+ * parameters (speed, distance, calories, activity)
+ * if power is on (from enabling an event or the
+ * step counter).
+ */
+ powered_on = mma9553_is_any_event_enabled(data, false, 0) ||
+ data->stepcnt_enabled;
+ if (!powered_on) {
+ dev_err(&data->client->dev, "No channels enabled\n");
+ return -EINVAL;
+ }
+
+ mutex_lock(&data->mutex);
+ ret = mma9551_read_status_word(data->client, MMA9551_APPID_PEDOMETER,
+ reg, tmp);
+ mutex_unlock(&data->mutex);
+ return ret;
+}
+
static int mma9553_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int *val, int *val2, long mask)
@@ -444,69 +474,30 @@ static int mma9553_read_raw(struct iio_dev *indio_dev,
int ret;
u16 tmp;
u8 activity;
- bool powered_on;
switch (mask) {
case IIO_CHAN_INFO_PROCESSED:
switch (chan->type) {
case IIO_STEPS:
- /*
- * The HW only counts steps and other dependent
- * parameters (speed, distance, calories, activity)
- * if power is on (from enabling an event or the
- * step counter */
- powered_on =
- mma9553_is_any_event_enabled(data, false, 0) ||
- data->stepcnt_enabled;
- if (!powered_on) {
- dev_err(&data->client->dev,
- "No channels enabled\n");
- return -EINVAL;
- }
- mutex_lock(&data->mutex);
- ret = mma9551_read_status_word(data->client,
- MMA9551_APPID_PEDOMETER,
+ ret = mma9553_read_status_word(data,
MMA9553_REG_STEPCNT,
&tmp);
- mutex_unlock(&data->mutex);
if (ret < 0)
return ret;
*val = tmp;
return IIO_VAL_INT;
case IIO_DISTANCE:
- powered_on =
- mma9553_is_any_event_enabled(data, false, 0) ||
- data->stepcnt_enabled;
- if (!powered_on) {
- dev_err(&data->client->dev,
- "No channels enabled\n");
- return -EINVAL;
- }
- mutex_lock(&data->mutex);
- ret = mma9551_read_status_word(data->client,
- MMA9551_APPID_PEDOMETER,
+ ret = mma9553_read_status_word(data,
MMA9553_REG_DISTANCE,
&tmp);
- mutex_unlock(&data->mutex);
if (ret < 0)
return ret;
*val = tmp;
return IIO_VAL_INT;
case IIO_ACTIVITY:
- powered_on =
- mma9553_is_any_event_enabled(data, false, 0) ||
- data->stepcnt_enabled;
- if (!powered_on) {
- dev_err(&data->client->dev,
- "No channels enabled\n");
- return -EINVAL;
- }
- mutex_lock(&data->mutex);
- ret = mma9551_read_status_word(data->client,
- MMA9551_APPID_PEDOMETER,
+ ret = mma9553_read_status_word(data,
MMA9553_REG_STATUS,
&tmp);
- mutex_unlock(&data->mutex);
if (ret < 0)
return ret;
@@ -531,38 +522,17 @@ static int mma9553_read_raw(struct iio_dev *indio_dev,
case IIO_VELOCITY: /* m/h */
if (chan->channel2 != IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z)
return -EINVAL;
- powered_on =
- mma9553_is_any_event_enabled(data, false, 0) ||
- data->stepcnt_enabled;
- if (!powered_on) {
- dev_err(&data->client->dev,
- "No channels enabled\n");
- return -EINVAL;
- }
- mutex_lock(&data->mutex);
- ret = mma9551_read_status_word(data->client,
- MMA9551_APPID_PEDOMETER,
- MMA9553_REG_SPEED, &tmp);
- mutex_unlock(&data->mutex);
+ ret = mma9553_read_status_word(data,
+ MMA9553_REG_SPEED,
+ &tmp);
if (ret < 0)
return ret;
*val = tmp;
return IIO_VAL_INT;
case IIO_ENERGY: /* Cal or kcal */
- powered_on =
- mma9553_is_any_event_enabled(data, false, 0) ||
- data->stepcnt_enabled;
- if (!powered_on) {
- dev_err(&data->client->dev,
- "No channels enabled\n");
- return -EINVAL;
- }
- mutex_lock(&data->mutex);
- ret = mma9551_read_status_word(data->client,
- MMA9551_APPID_PEDOMETER,
+ ret = mma9553_read_status_word(data,
MMA9553_REG_CALORIES,
&tmp);
- mutex_unlock(&data->mutex);
if (ret < 0)
return ret;
*val = tmp;
@@ -789,7 +759,7 @@ static int mma9553_write_event_config(struct iio_dev *indio_dev,
mutex_unlock(&data->mutex);
- return ret;
+ return 0;
err_conf_gpio:
if (state) {
@@ -897,7 +867,7 @@ static int mma9553_get_calibgender_mode(struct iio_dev *indio_dev,
gender = mma9553_get_bits(data->conf.filter, MMA9553_MASK_CONF_MALE);
/*
* HW expects 0 for female and 1 for male,
- * while iio index is 0 for male and 1 for female
+ * while iio index is 0 for male and 1 for female.
*/
return !gender;
}
@@ -944,11 +914,11 @@ static const struct iio_event_spec mma9553_activity_events[] = {
},
};
-static const char * const calibgender_modes[] = { "male", "female" };
+static const char * const mma9553_calibgender_modes[] = { "male", "female" };
static const struct iio_enum mma9553_calibgender_enum = {
- .items = calibgender_modes,
- .num_items = ARRAY_SIZE(calibgender_modes),
+ .items = mma9553_calibgender_modes,
+ .num_items = ARRAY_SIZE(mma9553_calibgender_modes),
.get = mma9553_get_calibgender_mode,
.set = mma9553_set_calibgender_mode,
};
@@ -1110,16 +1080,16 @@ static int mma9553_gpio_probe(struct i2c_client *client)
dev = &client->dev;
- /* data ready gpio interrupt pin */
+ /* data ready GPIO interrupt pin */
gpio = devm_gpiod_get_index(dev, MMA9553_GPIO_NAME, 0, GPIOD_IN);
if (IS_ERR(gpio)) {
- dev_err(dev, "acpi gpio get index failed\n");
+ dev_err(dev, "ACPI GPIO get index failed\n");
return PTR_ERR(gpio);
}
ret = gpiod_to_irq(gpio);
- dev_dbg(dev, "gpio resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
+ dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
return ret;
}
diff --git a/drivers/iio/accel/stk8312.c b/drivers/iio/accel/stk8312.c
new file mode 100644
index 00000000000000..d211d9f3975b82
--- /dev/null
+++ b/drivers/iio/accel/stk8312.c
@@ -0,0 +1,390 @@
+/**
+ * Sensortek STK8312 3-Axis Accelerometer
+ *
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General Public License. See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * IIO driver for STK8312; 7-bit I2C address: 0x3D.
+ */
+
+#include <linux/acpi.h>
+#include <linux/i2c.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#define STK8312_REG_XOUT 0x00
+#define STK8312_REG_YOUT 0x01
+#define STK8312_REG_ZOUT 0x02
+#define STK8312_REG_MODE 0x07
+#define STK8312_REG_STH 0x13
+#define STK8312_REG_RESET 0x20
+#define STK8312_REG_AFECTRL 0x24
+#define STK8312_REG_OTPADDR 0x3D
+#define STK8312_REG_OTPDATA 0x3E
+#define STK8312_REG_OTPCTRL 0x3F
+
+#define STK8312_MODE_ACTIVE 1
+#define STK8312_MODE_STANDBY 0
+#define STK8312_MODE_MASK 0x01
+#define STK8312_RNG_MASK 0xC0
+#define STK8312_RNG_SHIFT 6
+#define STK8312_READ_RETRIES 16
+
+#define STK8312_DRIVER_NAME "stk8312"
+
+/*
+ * The accelerometer has two measurement ranges:
+ *
+ * -6g - +6g (8-bit, signed)
+ * -16g - +16g (8-bit, signed)
+ *
+ * scale1 = (6 + 6) * 9.81 / (2^8 - 1) = 0.4616
+ * scale2 = (16 + 16) * 9.81 / (2^8 - 1) = 1.2311
+ */
+#define STK8312_SCALE_AVAIL "0.4616 1.2311"
+
+static const int stk8312_scale_table[][2] = {
+ {0, 461600}, {1, 231100}
+};
+
+#define STK8312_ACCEL_CHANNEL(reg, axis) { \
+ .type = IIO_ACCEL, \
+ .address = reg, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_##axis, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
+}
+
+static const struct iio_chan_spec stk8312_channels[] = {
+ STK8312_ACCEL_CHANNEL(STK8312_REG_XOUT, X),
+ STK8312_ACCEL_CHANNEL(STK8312_REG_YOUT, Y),
+ STK8312_ACCEL_CHANNEL(STK8312_REG_ZOUT, Z),
+};
+
+struct stk8312_data {
+ struct i2c_client *client;
+ struct mutex lock;
+ int range;
+ u8 mode;
+};
+
+static IIO_CONST_ATTR(in_accel_scale_available, STK8312_SCALE_AVAIL);
+
+static struct attribute *stk8312_attributes[] = {
+ &iio_const_attr_in_accel_scale_available.dev_attr.attr,
+ NULL,
+};
+
+static const struct attribute_group stk8312_attribute_group = {
+ .attrs = stk8312_attributes
+};
+
+static int stk8312_otp_init(struct stk8312_data *data)
+{
+ int ret;
+ int count = 10;
+ struct i2c_client *client = data->client;
+
+ ret = i2c_smbus_write_byte_data(client, STK8312_REG_OTPADDR, 0x70);
+ if (ret < 0)
+ goto exit_err;
+ ret = i2c_smbus_write_byte_data(client, STK8312_REG_OTPCTRL, 0x02);
+ if (ret < 0)
+ goto exit_err;
+
+ do {
+ usleep_range(1000, 5000);
+ ret = i2c_smbus_read_byte_data(client, STK8312_REG_OTPCTRL);
+ if (ret < 0)
+ goto exit_err;
+ count--;
+ } while (!(ret & 0x80) && count > 0);
+
+ if (count == 0)
+ goto exit_err;
+
+ ret = i2c_smbus_read_byte_data(client, STK8312_REG_OTPDATA);
+ if (ret < 0)
+ goto exit_err;
+
+ ret = i2c_smbus_write_byte_data(data->client,
+ STK8312_REG_AFECTRL, ret);
+ if (ret < 0)
+ goto exit_err;
+ msleep(150);
+
+ return ret;
+
+exit_err:
+ dev_err(&client->dev, "failed to initialize sensor\n");
+ return ret;
+}
+
+static int stk8312_set_mode(struct stk8312_data *data, u8 mode)
+{
+ int ret;
+ u8 masked_reg;
+ struct i2c_client *client = data->client;
+
+ if (mode > 1)
+ return -EINVAL;
+ else if (mode == data->mode)
+ return 0;
+
+ ret = i2c_smbus_read_byte_data(client, STK8312_REG_MODE);
+ if (ret < 0) {
+ dev_err(&client->dev, "failed to change sensor mode\n");
+ return ret;
+ }
+ masked_reg = ret & (~STK8312_MODE_MASK);
+ masked_reg |= mode;
+
+ ret = i2c_smbus_write_byte_data(client,
+ STK8312_REG_MODE, masked_reg);
+ if (ret < 0) {
+ dev_err(&client->dev, "failed to change sensor mode\n");
+ return ret;
+ }
+
+ data->mode = mode;
+ if (mode == STK8312_MODE_ACTIVE) {
+ /* Need to run OTP sequence before entering active mode */
+ usleep_range(1000, 5000);
+ ret = stk8312_otp_init(data);
+ }
+
+ return ret;
+}
+
+static int stk8312_set_range(struct stk8312_data *data, u8 range)
+{
+ int ret;
+ u8 masked_reg;
+ u8 mode;
+ struct i2c_client *client = data->client;
+
+ if (range != 1 && range != 2)
+ return -EINVAL;
+ else if (range == data->range)
+ return 0;
+
+ mode = data->mode;
+ /* We need to go in standby mode to modify registers */
+ ret = stk8312_set_mode(data, STK8312_MODE_STANDBY);
+ if (ret < 0)
+ return ret;
+
+ ret = i2c_smbus_read_byte_data(client, STK8312_REG_STH);
+ if (ret < 0) {
+ dev_err(&client->dev, "failed to change sensor range\n");
+ return ret;
+ }
+
+ masked_reg = ret & (~STK8312_RNG_MASK);
+ masked_reg |= range << STK8312_RNG_SHIFT;
+
+ ret = i2c_smbus_write_byte_data(client, STK8312_REG_STH, masked_reg);
+ if (ret < 0)
+ dev_err(&client->dev, "failed to change sensor range\n");
+ else
+ data->range = range;
+
+ return stk8312_set_mode(data, mode);
+}
+
+static int stk8312_read_accel(struct stk8312_data *data, u8 address)
+{
+ int ret;
+ struct i2c_client *client = data->client;
+
+ if (address > 2)
+ return -EINVAL;
+
+ ret = i2c_smbus_read_byte_data(client, address);
+ if (ret < 0) {
+ dev_err(&client->dev, "register read failed\n");
+ return ret;
+ }
+
+ return sign_extend32(ret, 7);
+}
+
+static int stk8312_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ struct stk8312_data *data = iio_priv(indio_dev);
+
+ if (chan->type != IIO_ACCEL)
+ return -EINVAL;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ mutex_lock(&data->lock);
+ *val = stk8312_read_accel(data, chan->address);
+ mutex_unlock(&data->lock);
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SCALE:
+ *val = stk8312_scale_table[data->range - 1][0];
+ *val2 = stk8312_scale_table[data->range - 1][1];
+ return IIO_VAL_INT_PLUS_MICRO;
+ }
+
+ return -EINVAL;
+}
+
+static int stk8312_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ int i;
+ int index = -1;
+ int ret;
+ struct stk8312_data *data = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ for (i = 0; i < ARRAY_SIZE(stk8312_scale_table); i++)
+ if (val == stk8312_scale_table[i][0] &&
+ val2 == stk8312_scale_table[i][1]) {
+ index = i + 1;
+ break;
+ }
+ if (index < 0)
+ return -EINVAL;
+
+ mutex_lock(&data->lock);
+ ret = stk8312_set_range(data, index);
+ mutex_unlock(&data->lock);
+
+ return ret;
+ }
+
+ return -EINVAL;
+}
+
+static const struct iio_info stk8312_info = {
+ .driver_module = THIS_MODULE,
+ .read_raw = stk8312_read_raw,
+ .write_raw = stk8312_write_raw,
+ .attrs = &stk8312_attribute_group,
+};
+
+static int stk8312_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ int ret;
+ struct iio_dev *indio_dev;
+ struct stk8312_data *data;
+
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ if (!indio_dev) {
+ dev_err(&client->dev, "iio allocation failed!\n");
+ return -ENOMEM;
+ }
+
+ data = iio_priv(indio_dev);
+ data->client = client;
+ i2c_set_clientdata(client, indio_dev);
+ mutex_init(&data->lock);
+
+ indio_dev->dev.parent = &client->dev;
+ indio_dev->info = &stk8312_info;
+ indio_dev->name = STK8312_DRIVER_NAME;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = stk8312_channels;
+ indio_dev->num_channels = ARRAY_SIZE(stk8312_channels);
+
+ /* A software reset is recommended at power-on */
+ ret = i2c_smbus_write_byte_data(data->client, STK8312_REG_RESET, 0x00);
+ if (ret < 0) {
+ dev_err(&client->dev, "failed to reset sensor\n");
+ return ret;
+ }
+ ret = stk8312_set_range(data, 1);
+ if (ret < 0)
+ return ret;
+
+ ret = stk8312_set_mode(data, STK8312_MODE_ACTIVE);
+ if (ret < 0)
+ return ret;
+
+ ret = iio_device_register(indio_dev);
+ if (ret < 0) {
+ dev_err(&client->dev, "device_register failed\n");
+ stk8312_set_mode(data, STK8312_MODE_STANDBY);
+ }
+
+ return ret;
+}
+
+static int stk8312_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+ iio_device_unregister(indio_dev);
+
+ return stk8312_set_mode(iio_priv(indio_dev), STK8312_MODE_STANDBY);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int stk8312_suspend(struct device *dev)
+{
+ struct stk8312_data *data;
+
+ data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
+
+ return stk8312_set_mode(data, STK8312_MODE_STANDBY);
+}
+
+static int stk8312_resume(struct device *dev)
+{
+ struct stk8312_data *data;
+
+ data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
+
+ return stk8312_set_mode(data, STK8312_MODE_ACTIVE);
+}
+
+static SIMPLE_DEV_PM_OPS(stk8312_pm_ops, stk8312_suspend, stk8312_resume);
+
+#define STK8312_PM_OPS (&stk8312_pm_ops)
+#else
+#define STK8312_PM_OPS NULL
+#endif
+
+static const struct i2c_device_id stk8312_i2c_id[] = {
+ {"STK8312", 0},
+ {}
+};
+
+static const struct acpi_device_id stk8312_acpi_id[] = {
+ {"STK8312", 0},
+ {}
+};
+
+MODULE_DEVICE_TABLE(acpi, stk8312_acpi_id);
+
+static struct i2c_driver stk8312_driver = {
+ .driver = {
+ .name = "stk8312",
+ .pm = STK8312_PM_OPS,
+ .acpi_match_table = ACPI_PTR(stk8312_acpi_id),
+ },
+ .probe = stk8312_probe,
+ .remove = stk8312_remove,
+ .id_table = stk8312_i2c_id,
+};
+
+module_i2c_driver(stk8312_driver);
+
+MODULE_AUTHOR("Tiberiu Breana <tiberiu.a.breana@intel.com>");
+MODULE_DESCRIPTION("STK8312 3-Axis Accelerometer driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/accel/stk8ba50.c b/drivers/iio/accel/stk8ba50.c
new file mode 100644
index 00000000000000..30950c6b36de1f
--- /dev/null
+++ b/drivers/iio/accel/stk8ba50.c
@@ -0,0 +1,302 @@
+/**
+ * Sensortek STK8BA50 3-Axis Accelerometer
+ *
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General Public License. See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * STK8BA50 7-bit I2C address: 0x18.
+ */
+
+#include <linux/acpi.h>
+#include <linux/i2c.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#define STK8BA50_REG_XOUT 0x02
+#define STK8BA50_REG_YOUT 0x04
+#define STK8BA50_REG_ZOUT 0x06
+#define STK8BA50_REG_RANGE 0x0F
+#define STK8BA50_REG_POWMODE 0x11
+#define STK8BA50_REG_SWRST 0x14
+
+#define STK8BA50_MODE_NORMAL 0
+#define STK8BA50_MODE_SUSPEND 1
+#define STK8BA50_MODE_POWERBIT BIT(7)
+#define STK8BA50_DATA_SHIFT 6
+#define STK8BA50_RESET_CMD 0xB6
+
+#define STK8BA50_DRIVER_NAME "stk8ba50"
+
+#define STK8BA50_SCALE_AVAIL "0.0384 0.0767 0.1534 0.3069"
+
+/*
+ * The accelerometer has four measurement ranges:
+ * +/-2g; +/-4g; +/-8g; +/-16g
+ *
+ * Acceleration values are 10-bit, 2's complement.
+ * Scales are calculated as following:
+ *
+ * scale1 = (2 + 2) * 9.81 / (2^10 - 1) = 0.0384
+ * scale2 = (4 + 4) * 9.81 / (2^10 - 1) = 0.0767
+ * etc.
+ *
+ * Scales are stored in this format:
+ * { <register value>, <scale value> }
+ *
+ * Locally, the range is stored as a table index.
+ */
+static const int stk8ba50_scale_table[][2] = {
+ {3, 38400}, {5, 76700}, {8, 153400}, {12, 306900}
+};
+
+struct stk8ba50_data {
+ struct i2c_client *client;
+ struct mutex lock;
+ int range;
+};
+
+#define STK8BA50_ACCEL_CHANNEL(reg, axis) { \
+ .type = IIO_ACCEL, \
+ .address = reg, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_##axis, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE), \
+}
+
+static const struct iio_chan_spec stk8ba50_channels[] = {
+ STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_XOUT, X),
+ STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_YOUT, Y),
+ STK8BA50_ACCEL_CHANNEL(STK8BA50_REG_ZOUT, Z),
+};
+
+static IIO_CONST_ATTR(in_accel_scale_available, STK8BA50_SCALE_AVAIL);
+
+static struct attribute *stk8ba50_attributes[] = {
+ &iio_const_attr_in_accel_scale_available.dev_attr.attr,
+ NULL,
+};
+
+static const struct attribute_group stk8ba50_attribute_group = {
+ .attrs = stk8ba50_attributes
+};
+
+static int stk8ba50_read_accel(struct stk8ba50_data *data, u8 reg)
+{
+ int ret;
+ struct i2c_client *client = data->client;
+
+ ret = i2c_smbus_read_word_data(client, reg);
+ if (ret < 0) {
+ dev_err(&client->dev, "register read failed\n");
+ return ret;
+ }
+
+ return sign_extend32(ret >> STK8BA50_DATA_SHIFT, 9);
+}
+
+static int stk8ba50_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ struct stk8ba50_data *data = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ mutex_lock(&data->lock);
+ *val = stk8ba50_read_accel(data, chan->address);
+ mutex_unlock(&data->lock);
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SCALE:
+ *val = 0;
+ *val2 = stk8ba50_scale_table[data->range][1];
+ return IIO_VAL_INT_PLUS_MICRO;
+ }
+
+ return -EINVAL;
+}
+
+static int stk8ba50_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ int ret;
+ int i;
+ int index = -1;
+ struct stk8ba50_data *data = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ if (val != 0)
+ return -EINVAL;
+
+ for (i = 0; i < ARRAY_SIZE(stk8ba50_scale_table); i++)
+ if (val2 == stk8ba50_scale_table[i][1]) {
+ index = i;
+ break;
+ }
+ if (index < 0)
+ return -EINVAL;
+
+ ret = i2c_smbus_write_byte_data(data->client,
+ STK8BA50_REG_RANGE,
+ stk8ba50_scale_table[index][0]);
+ if (ret < 0)
+ dev_err(&data->client->dev,
+ "failed to set measurement range\n");
+ else
+ data->range = index;
+
+ return ret;
+ }
+
+ return -EINVAL;
+}
+
+static const struct iio_info stk8ba50_info = {
+ .driver_module = THIS_MODULE,
+ .read_raw = stk8ba50_read_raw,
+ .write_raw = stk8ba50_write_raw,
+ .attrs = &stk8ba50_attribute_group,
+};
+
+static int stk8ba50_set_power(struct stk8ba50_data *data, bool mode)
+{
+ int ret;
+ u8 masked_reg;
+ struct i2c_client *client = data->client;
+
+ ret = i2c_smbus_read_byte_data(client, STK8BA50_REG_POWMODE);
+ if (ret < 0)
+ goto exit_err;
+
+ if (mode)
+ masked_reg = ret | STK8BA50_MODE_POWERBIT;
+ else
+ masked_reg = ret & (~STK8BA50_MODE_POWERBIT);
+
+ ret = i2c_smbus_write_byte_data(client, STK8BA50_REG_POWMODE,
+ masked_reg);
+ if (ret < 0)
+ goto exit_err;
+
+ return ret;
+
+exit_err:
+ dev_err(&client->dev, "failed to change sensor mode\n");
+ return ret;
+}
+
+static int stk8ba50_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ int ret;
+ struct iio_dev *indio_dev;
+ struct stk8ba50_data *data;
+
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ if (!indio_dev) {
+ dev_err(&client->dev, "iio allocation failed!\n");
+ return -ENOMEM;
+ }
+
+ data = iio_priv(indio_dev);
+ data->client = client;
+ i2c_set_clientdata(client, indio_dev);
+ mutex_init(&data->lock);
+
+ indio_dev->dev.parent = &client->dev;
+ indio_dev->info = &stk8ba50_info;
+ indio_dev->name = STK8BA50_DRIVER_NAME;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = stk8ba50_channels;
+ indio_dev->num_channels = ARRAY_SIZE(stk8ba50_channels);
+
+ /* Reset all registers on startup */
+ ret = i2c_smbus_write_byte_data(client,
+ STK8BA50_REG_SWRST, STK8BA50_RESET_CMD);
+ if (ret < 0) {
+ dev_err(&client->dev, "failed to reset sensor\n");
+ return ret;
+ }
+
+ /* The default range is +/-2g */
+ data->range = 0;
+
+ ret = iio_device_register(indio_dev);
+ if (ret < 0) {
+ dev_err(&client->dev, "device_register failed\n");
+ stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
+ }
+
+ return ret;
+}
+
+static int stk8ba50_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+ iio_device_unregister(indio_dev);
+
+ return stk8ba50_set_power(iio_priv(indio_dev), STK8BA50_MODE_SUSPEND);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int stk8ba50_suspend(struct device *dev)
+{
+ struct stk8ba50_data *data;
+
+ data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
+
+ return stk8ba50_set_power(data, STK8BA50_MODE_SUSPEND);
+}
+
+static int stk8ba50_resume(struct device *dev)
+{
+ struct stk8ba50_data *data;
+
+ data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
+
+ return stk8ba50_set_power(data, STK8BA50_MODE_NORMAL);
+}
+
+static SIMPLE_DEV_PM_OPS(stk8ba50_pm_ops, stk8ba50_suspend, stk8ba50_resume);
+
+#define STK8BA50_PM_OPS (&stk8ba50_pm_ops)
+#else
+#define STK8BA50_PM_OPS NULL
+#endif
+
+static const struct i2c_device_id stk8ba50_i2c_id[] = {
+ {"stk8ba50", 0},
+ {}
+};
+
+static const struct acpi_device_id stk8ba50_acpi_id[] = {
+ {"STK8BA50", 0},
+ {}
+};
+
+MODULE_DEVICE_TABLE(acpi, stk8ba50_acpi_id);
+
+static struct i2c_driver stk8ba50_driver = {
+ .driver = {
+ .name = "stk8ba50",
+ .pm = STK8BA50_PM_OPS,
+ .acpi_match_table = ACPI_PTR(stk8ba50_acpi_id),
+ },
+ .probe = stk8ba50_probe,
+ .remove = stk8ba50_remove,
+ .id_table = stk8ba50_i2c_id,
+};
+
+module_i2c_driver(stk8ba50_driver);
+
+MODULE_AUTHOR("Tiberiu Breana <tiberiu.a.breana@intel.com>");
+MODULE_DESCRIPTION("STK8BA50 3-Axis Accelerometer driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig
index e36a73e7c3a857..7c5565891cb830 100644
--- a/drivers/iio/adc/Kconfig
+++ b/drivers/iio/adc/Kconfig
@@ -135,6 +135,13 @@ config AXP288_ADC
device. Depending on platform configuration, this general purpose ADC can
be used for sampling sensors such as thermal resistors.
+config BERLIN2_ADC
+ tristate "Marvell Berlin2 ADC driver"
+ depends on ARCH_BERLIN
+ help
+ Marvell Berlin2 ADC driver. This ADC has 8 channels, with one used for
+ temperature measurement.
+
config DA9150_GPADC
tristate "Dialog DA9150 GPADC driver support"
depends on MFD_DA9150
@@ -285,11 +292,11 @@ config TI_ADC081C
called ti-adc081c.
config TI_ADC128S052
- tristate "Texas Instruments ADC128S052"
+ tristate "Texas Instruments ADC128S052/ADC122S021"
depends on SPI
help
If you say yes here you get support for Texas Instruments ADC128S052
- chip.
+ and ADC122S021 chips.
This driver can also be built as a module. If so, the module will be
called ti-adc128s052.
diff --git a/drivers/iio/adc/Makefile b/drivers/iio/adc/Makefile
index 3930e63e84bccb..a0962103e8666c 100644
--- a/drivers/iio/adc/Makefile
+++ b/drivers/iio/adc/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_AD7887) += ad7887.o
obj-$(CONFIG_AD799X) += ad799x.o
obj-$(CONFIG_AT91_ADC) += at91_adc.o
obj-$(CONFIG_AXP288_ADC) += axp288_adc.o
+obj-$(CONFIG_BERLIN2_ADC) += berlin2-adc.o
obj-$(CONFIG_DA9150_GPADC) += da9150-gpadc.o
obj-$(CONFIG_CC10001_ADC) += cc10001_adc.o
obj-$(CONFIG_EXYNOS_ADC) += exynos_adc.o
diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c
index 56008a86b78f85..0c904edd6c004c 100644
--- a/drivers/iio/adc/axp288_adc.c
+++ b/drivers/iio/adc/axp288_adc.c
@@ -238,7 +238,7 @@ static int axp288_adc_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id axp288_adc_id_table[] = {
+static const struct platform_device_id axp288_adc_id_table[] = {
{ .name = "axp288_adc" },
{},
};
diff --git a/drivers/iio/adc/berlin2-adc.c b/drivers/iio/adc/berlin2-adc.c
new file mode 100644
index 00000000000000..aecc9ad995ada4
--- /dev/null
+++ b/drivers/iio/adc/berlin2-adc.c
@@ -0,0 +1,378 @@
+/*
+ * Marvell Berlin2 ADC driver
+ *
+ * Copyright (C) 2015 Marvell Technology Group Ltd.
+ *
+ * Antoine Tenart <antoine.tenart@free-electrons.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.
+ */
+
+#include <linux/iio/iio.h>
+#include <linux/iio/driver.h>
+#include <linux/iio/machine.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/mfd/syscon.h>
+#include <linux/regmap.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
+
+#define BERLIN2_SM_CTRL 0x14
+#define BERLIN2_SM_CTRL_SM_SOC_INT BIT(1)
+#define BERLIN2_SM_CTRL_SOC_SM_INT BIT(2)
+#define BERLIN2_SM_CTRL_ADC_SEL(x) (BIT(x) << 5) /* 0-15 */
+#define BERLIN2_SM_CTRL_ADC_SEL_MASK (0xf << 5)
+#define BERLIN2_SM_CTRL_ADC_POWER BIT(9)
+#define BERLIN2_SM_CTRL_ADC_CLKSEL_DIV2 (0x0 << 10)
+#define BERLIN2_SM_CTRL_ADC_CLKSEL_DIV3 (0x1 << 10)
+#define BERLIN2_SM_CTRL_ADC_CLKSEL_DIV4 (0x2 << 10)
+#define BERLIN2_SM_CTRL_ADC_CLKSEL_DIV8 (0x3 << 10)
+#define BERLIN2_SM_CTRL_ADC_CLKSEL_MASK (0x3 << 10)
+#define BERLIN2_SM_CTRL_ADC_START BIT(12)
+#define BERLIN2_SM_CTRL_ADC_RESET BIT(13)
+#define BERLIN2_SM_CTRL_ADC_BANDGAP_RDY BIT(14)
+#define BERLIN2_SM_CTRL_ADC_CONT_SINGLE (0x0 << 15)
+#define BERLIN2_SM_CTRL_ADC_CONT_CONTINUOUS (0x1 << 15)
+#define BERLIN2_SM_CTRL_ADC_BUFFER_EN BIT(16)
+#define BERLIN2_SM_CTRL_ADC_VREF_EXT (0x0 << 17)
+#define BERLIN2_SM_CTRL_ADC_VREF_INT (0x1 << 17)
+#define BERLIN2_SM_CTRL_ADC_ROTATE BIT(19)
+#define BERLIN2_SM_CTRL_TSEN_EN BIT(20)
+#define BERLIN2_SM_CTRL_TSEN_CLK_SEL_125 (0x0 << 21) /* 1.25 MHz */
+#define BERLIN2_SM_CTRL_TSEN_CLK_SEL_250 (0x1 << 21) /* 2.5 MHz */
+#define BERLIN2_SM_CTRL_TSEN_MODE_0_125 (0x0 << 22) /* 0-125 C */
+#define BERLIN2_SM_CTRL_TSEN_MODE_10_50 (0x1 << 22) /* 10-50 C */
+#define BERLIN2_SM_CTRL_TSEN_RESET BIT(29)
+#define BERLIN2_SM_ADC_DATA 0x20
+#define BERLIN2_SM_ADC_MASK 0x3ff
+#define BERLIN2_SM_ADC_STATUS 0x1c
+#define BERLIN2_SM_ADC_STATUS_DATA_RDY(x) BIT(x) /* 0-15 */
+#define BERLIN2_SM_ADC_STATUS_DATA_RDY_MASK 0xf
+#define BERLIN2_SM_ADC_STATUS_INT_EN(x) (BIT(x) << 16) /* 0-15 */
+#define BERLIN2_SM_ADC_STATUS_INT_EN_MASK (0xf << 16)
+#define BERLIN2_SM_TSEN_STATUS 0x24
+#define BERLIN2_SM_TSEN_STATUS_DATA_RDY BIT(0)
+#define BERLIN2_SM_TSEN_STATUS_INT_EN BIT(1)
+#define BERLIN2_SM_TSEN_DATA 0x28
+#define BERLIN2_SM_TSEN_MASK 0xfff
+#define BERLIN2_SM_TSEN_CTRL 0x74
+#define BERLIN2_SM_TSEN_CTRL_START BIT(8)
+#define BERLIN2_SM_TSEN_CTRL_SETTLING_4 (0x0 << 21) /* 4 us */
+#define BERLIN2_SM_TSEN_CTRL_SETTLING_12 (0x1 << 21) /* 12 us */
+#define BERLIN2_SM_TSEN_CTRL_SETTLING_MASK (0x1 << 21)
+#define BERLIN2_SM_TSEN_CTRL_TRIM(x) ((x) << 22)
+#define BERLIN2_SM_TSEN_CTRL_TRIM_MASK (0xf << 22)
+
+struct berlin2_adc_priv {
+ struct regmap *regmap;
+ struct mutex lock;
+ wait_queue_head_t wq;
+ bool data_available;
+ int data;
+};
+
+#define BERLIN2_ADC_CHANNEL(n, t) \
+ { \
+ .channel = n, \
+ .datasheet_name = "channel"#n, \
+ .type = t, \
+ .indexed = 1, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), \
+ }
+
+static struct iio_chan_spec berlin2_adc_channels[] = {
+ BERLIN2_ADC_CHANNEL(0, IIO_VOLTAGE), /* external input */
+ BERLIN2_ADC_CHANNEL(1, IIO_VOLTAGE), /* external input */
+ BERLIN2_ADC_CHANNEL(2, IIO_VOLTAGE), /* external input */
+ BERLIN2_ADC_CHANNEL(3, IIO_VOLTAGE), /* external input */
+ BERLIN2_ADC_CHANNEL(4, IIO_VOLTAGE), /* reserved */
+ BERLIN2_ADC_CHANNEL(5, IIO_VOLTAGE), /* reserved */
+ { /* temperature sensor */
+ .channel = 6,
+ .datasheet_name = "channel6",
+ .type = IIO_TEMP,
+ .indexed = 0,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+ },
+ BERLIN2_ADC_CHANNEL(7, IIO_VOLTAGE), /* reserved */
+ IIO_CHAN_SOFT_TIMESTAMP(8), /* timestamp */
+};
+#define BERLIN2_N_CHANNELS ARRAY_SIZE(berlin2_adc_channels)
+
+static int berlin2_adc_read(struct iio_dev *indio_dev, int channel)
+{
+ struct berlin2_adc_priv *priv = iio_priv(indio_dev);
+ int data, ret;
+
+ mutex_lock(&priv->lock);
+
+ /* Configure the ADC */
+ regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
+ BERLIN2_SM_CTRL_ADC_RESET | BERLIN2_SM_CTRL_ADC_SEL_MASK
+ | BERLIN2_SM_CTRL_ADC_START,
+ BERLIN2_SM_CTRL_ADC_SEL(channel) | BERLIN2_SM_CTRL_ADC_START);
+
+ ret = wait_event_interruptible_timeout(priv->wq, priv->data_available,
+ msecs_to_jiffies(1000));
+
+ /* Disable the interrupts */
+ regmap_update_bits(priv->regmap, BERLIN2_SM_ADC_STATUS,
+ BERLIN2_SM_ADC_STATUS_INT_EN(channel), 0);
+
+ if (ret == 0)
+ ret = -ETIMEDOUT;
+ if (ret < 0) {
+ mutex_unlock(&priv->lock);
+ return ret;
+ }
+
+ regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
+ BERLIN2_SM_CTRL_ADC_START, 0);
+
+ data = priv->data;
+ priv->data_available = false;
+
+ mutex_unlock(&priv->lock);
+
+ return data;
+}
+
+static int berlin2_adc_tsen_read(struct iio_dev *indio_dev)
+{
+ struct berlin2_adc_priv *priv = iio_priv(indio_dev);
+ int data, ret;
+
+ mutex_lock(&priv->lock);
+
+ /* Configure the ADC */
+ regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
+ BERLIN2_SM_CTRL_TSEN_RESET | BERLIN2_SM_CTRL_ADC_ROTATE,
+ BERLIN2_SM_CTRL_ADC_ROTATE);
+
+ /* Configure the temperature sensor */
+ regmap_update_bits(priv->regmap, BERLIN2_SM_TSEN_CTRL,
+ BERLIN2_SM_TSEN_CTRL_TRIM_MASK | BERLIN2_SM_TSEN_CTRL_SETTLING_MASK
+ | BERLIN2_SM_TSEN_CTRL_START,
+ BERLIN2_SM_TSEN_CTRL_TRIM(3) | BERLIN2_SM_TSEN_CTRL_SETTLING_12
+ | BERLIN2_SM_TSEN_CTRL_START);
+
+ ret = wait_event_interruptible_timeout(priv->wq, priv->data_available,
+ msecs_to_jiffies(1000));
+
+ /* Disable interrupts */
+ regmap_update_bits(priv->regmap, BERLIN2_SM_TSEN_STATUS,
+ BERLIN2_SM_TSEN_STATUS_INT_EN, 0);
+
+ if (ret == 0)
+ ret = -ETIMEDOUT;
+ if (ret < 0) {
+ mutex_unlock(&priv->lock);
+ return ret;
+ }
+
+ regmap_update_bits(priv->regmap, BERLIN2_SM_TSEN_CTRL,
+ BERLIN2_SM_TSEN_CTRL_START, 0);
+
+ data = priv->data;
+ priv->data_available = false;
+
+ mutex_unlock(&priv->lock);
+
+ return data;
+}
+
+static int berlin2_adc_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int *val, int *val2,
+ long mask)
+{
+ struct berlin2_adc_priv *priv = iio_priv(indio_dev);
+ int temp;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ if (chan->type != IIO_VOLTAGE)
+ return -EINVAL;
+
+ /* Enable the interrupts */
+ regmap_write(priv->regmap, BERLIN2_SM_ADC_STATUS,
+ BERLIN2_SM_ADC_STATUS_INT_EN(chan->channel));
+
+ *val = berlin2_adc_read(indio_dev, chan->channel);
+ if (*val < 0)
+ return *val;
+
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_PROCESSED:
+ if (chan->type != IIO_TEMP)
+ return -EINVAL;
+
+ /* Enable interrupts */
+ regmap_write(priv->regmap, BERLIN2_SM_TSEN_STATUS,
+ BERLIN2_SM_TSEN_STATUS_INT_EN);
+
+ temp = berlin2_adc_tsen_read(indio_dev);
+ if (temp < 0)
+ return temp;
+
+ if (temp > 2047)
+ temp = -(4096 - temp);
+
+ /* Convert to milli Celsius */
+ *val = ((temp * 100000) / 264 - 270000);
+ return IIO_VAL_INT;
+ default:
+ break;
+ }
+
+ return -EINVAL;
+}
+
+static irqreturn_t berlin2_adc_irq(int irq, void *private)
+{
+ struct berlin2_adc_priv *priv = iio_priv(private);
+ unsigned val;
+
+ regmap_read(priv->regmap, BERLIN2_SM_ADC_STATUS, &val);
+ if (val & BERLIN2_SM_ADC_STATUS_DATA_RDY_MASK) {
+ regmap_read(priv->regmap, BERLIN2_SM_ADC_DATA, &priv->data);
+ priv->data &= BERLIN2_SM_ADC_MASK;
+
+ val &= ~BERLIN2_SM_ADC_STATUS_DATA_RDY_MASK;
+ regmap_write(priv->regmap, BERLIN2_SM_ADC_STATUS, val);
+
+ priv->data_available = true;
+ wake_up_interruptible(&priv->wq);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static irqreturn_t berlin2_adc_tsen_irq(int irq, void *private)
+{
+ struct berlin2_adc_priv *priv = iio_priv(private);
+ unsigned val;
+
+ regmap_read(priv->regmap, BERLIN2_SM_TSEN_STATUS, &val);
+ if (val & BERLIN2_SM_TSEN_STATUS_DATA_RDY) {
+ regmap_read(priv->regmap, BERLIN2_SM_TSEN_DATA, &priv->data);
+ priv->data &= BERLIN2_SM_TSEN_MASK;
+
+ val &= ~BERLIN2_SM_TSEN_STATUS_DATA_RDY;
+ regmap_write(priv->regmap, BERLIN2_SM_TSEN_STATUS, val);
+
+ priv->data_available = true;
+ wake_up_interruptible(&priv->wq);
+ }
+
+ return IRQ_HANDLED;
+}
+
+static const struct iio_info berlin2_adc_info = {
+ .driver_module = THIS_MODULE,
+ .read_raw = berlin2_adc_read_raw,
+};
+
+static int berlin2_adc_probe(struct platform_device *pdev)
+{
+ struct iio_dev *indio_dev;
+ struct berlin2_adc_priv *priv;
+ struct device_node *parent_np = of_get_parent(pdev->dev.of_node);
+ int irq, tsen_irq;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&pdev->dev,
+ sizeof(struct berlin2_adc_priv));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ priv = iio_priv(indio_dev);
+ platform_set_drvdata(pdev, indio_dev);
+
+ priv->regmap = syscon_node_to_regmap(parent_np);
+ of_node_put(parent_np);
+ if (IS_ERR(priv->regmap))
+ return PTR_ERR(priv->regmap);
+
+ irq = platform_get_irq_byname(pdev, "adc");
+ if (irq < 0)
+ return -ENODEV;
+
+ tsen_irq = platform_get_irq_byname(pdev, "tsen");
+ if (tsen_irq < 0)
+ return -ENODEV;
+
+ ret = devm_request_irq(&pdev->dev, irq, berlin2_adc_irq, 0,
+ pdev->dev.driver->name, indio_dev);
+ if (ret)
+ return ret;
+
+ ret = devm_request_irq(&pdev->dev, tsen_irq, berlin2_adc_tsen_irq,
+ 0, pdev->dev.driver->name, indio_dev);
+ if (ret)
+ return ret;
+
+ init_waitqueue_head(&priv->wq);
+ mutex_init(&priv->lock);
+
+ indio_dev->dev.parent = &pdev->dev;
+ indio_dev->name = dev_name(&pdev->dev);
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->info = &berlin2_adc_info;
+
+ indio_dev->num_channels = BERLIN2_N_CHANNELS;
+ indio_dev->channels = berlin2_adc_channels;
+
+ /* Power up the ADC */
+ regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
+ BERLIN2_SM_CTRL_ADC_POWER, BERLIN2_SM_CTRL_ADC_POWER);
+
+ ret = iio_device_register(indio_dev);
+ if (ret) {
+ /* Power down the ADC */
+ regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
+ BERLIN2_SM_CTRL_ADC_POWER, 0);
+ return ret;
+ }
+
+ return 0;
+}
+
+static int berlin2_adc_remove(struct platform_device *pdev)
+{
+ struct iio_dev *indio_dev = platform_get_drvdata(pdev);
+ struct berlin2_adc_priv *priv = iio_priv(indio_dev);
+
+ iio_device_unregister(indio_dev);
+
+ /* Power down the ADC */
+ regmap_update_bits(priv->regmap, BERLIN2_SM_CTRL,
+ BERLIN2_SM_CTRL_ADC_POWER, 0);
+
+ return 0;
+}
+
+static const struct of_device_id berlin2_adc_match[] = {
+ { .compatible = "marvell,berlin2-adc", },
+ { },
+};
+MODULE_DEVICE_TABLE(of, berlin2_adc_match);
+
+static struct platform_driver berlin2_adc_driver = {
+ .driver = {
+ .name = "berlin2-adc",
+ .of_match_table = berlin2_adc_match,
+ },
+ .probe = berlin2_adc_probe,
+ .remove = berlin2_adc_remove,
+};
+module_platform_driver(berlin2_adc_driver);
+
+MODULE_AUTHOR("Antoine Tenart <antoine.tenart@free-electrons.com>");
+MODULE_DESCRIPTION("Marvell Berlin2 ADC driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
index 655cb564ec54af..915be6b60097b2 100644
--- a/drivers/iio/adc/ti-adc128s052.c
+++ b/drivers/iio/adc/ti-adc128s052.c
@@ -1,9 +1,10 @@
/*
* Copyright (C) 2014 Angelo Compagnucci <angelo.compagnucci@gmail.com>
*
- * Driver for Texas Instruments' ADC128S052 ADC chip.
- * Datasheet can be found here:
+ * Driver for Texas Instruments' ADC128S052 and ADC122S021 ADC chip.
+ * Datasheets can be found here:
* http://www.ti.com/lit/ds/symlink/adc128s052.pdf
+ * http://www.ti.com/lit/ds/symlink/adc122s021.pdf
*
* 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
@@ -16,6 +17,11 @@
#include <linux/iio/iio.h>
#include <linux/regulator/consumer.h>
+struct adc128_configuration {
+ const struct iio_chan_spec *channels;
+ u8 num_channels;
+};
+
struct adc128 {
struct spi_device *spi;
@@ -92,7 +98,7 @@ static int adc128_read_raw(struct iio_dev *indio_dev,
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SCALE) \
}
-static const struct iio_chan_spec adc128_channels[] = {
+static const struct iio_chan_spec adc128s052_channels[] = {
ADC128_VOLTAGE_CHANNEL(0),
ADC128_VOLTAGE_CHANNEL(1),
ADC128_VOLTAGE_CHANNEL(2),
@@ -103,6 +109,16 @@ static const struct iio_chan_spec adc128_channels[] = {
ADC128_VOLTAGE_CHANNEL(7),
};
+static const struct iio_chan_spec adc122s021_channels[] = {
+ ADC128_VOLTAGE_CHANNEL(0),
+ ADC128_VOLTAGE_CHANNEL(1),
+};
+
+static const struct adc128_configuration adc128_config[] = {
+ { adc128s052_channels, ARRAY_SIZE(adc128s052_channels) },
+ { adc122s021_channels, ARRAY_SIZE(adc122s021_channels) },
+};
+
static const struct iio_info adc128_info = {
.read_raw = adc128_read_raw,
.driver_module = THIS_MODULE,
@@ -112,6 +128,7 @@ static int adc128_probe(struct spi_device *spi)
{
struct iio_dev *indio_dev;
struct adc128 *adc;
+ int config = spi_get_device_id(spi)->driver_data;
int ret;
indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adc));
@@ -128,8 +145,8 @@ static int adc128_probe(struct spi_device *spi)
indio_dev->modes = INDIO_DIRECT_MODE;
indio_dev->info = &adc128_info;
- indio_dev->channels = adc128_channels;
- indio_dev->num_channels = ARRAY_SIZE(adc128_channels);
+ indio_dev->channels = adc128_config[config].channels;
+ indio_dev->num_channels = adc128_config[config].num_channels;
adc->reg = devm_regulator_get(&spi->dev, "vref");
if (IS_ERR(adc->reg))
@@ -158,7 +175,8 @@ static int adc128_remove(struct spi_device *spi)
}
static const struct spi_device_id adc128_id[] = {
- { "adc128s052", 0},
+ { "adc128s052", 0}, /* index into adc128_config */
+ { "adc122s021", 1},
{ }
};
MODULE_DEVICE_TABLE(spi, adc128_id);
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c
index a0e7161f040c91..942320e32753c3 100644
--- a/drivers/iio/adc/ti_am335x_adc.c
+++ b/drivers/iio/adc/ti_am335x_adc.c
@@ -37,6 +37,7 @@ struct tiadc_device {
u8 channel_step[8];
int buffer_en_ch_steps;
u16 data[8];
+ u32 open_delay[8], sample_delay[8], step_avg[8];
};
static unsigned int tiadc_readl(struct tiadc_device *adc, unsigned int reg)
@@ -85,6 +86,7 @@ static u32 get_adc_step_bit(struct tiadc_device *adc_dev, int chan)
static void tiadc_step_config(struct iio_dev *indio_dev)
{
struct tiadc_device *adc_dev = iio_priv(indio_dev);
+ struct device *dev = adc_dev->mfd_tscadc->dev;
unsigned int stepconfig;
int i, steps = 0;
@@ -98,20 +100,47 @@ static void tiadc_step_config(struct iio_dev *indio_dev)
* needs to be given to ADC to digitalize data.
*/
- if (iio_buffer_enabled(indio_dev))
- stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1
- | STEPCONFIG_MODE_SWCNT;
- else
- stepconfig = STEPCONFIG_AVG_16 | STEPCONFIG_FIFO1;
for (i = 0; i < adc_dev->channels; i++) {
int chan;
chan = adc_dev->channel_line[i];
+
+ if (adc_dev->step_avg[i] > STEPCONFIG_AVG_16) {
+ dev_warn(dev, "chan %d step_avg truncating to %d\n",
+ chan, STEPCONFIG_AVG_16);
+ adc_dev->step_avg[i] = STEPCONFIG_AVG_16;
+ }
+
+ if (adc_dev->step_avg[i])
+ stepconfig =
+ STEPCONFIG_AVG(ffs(adc_dev->step_avg[i]) - 1) |
+ STEPCONFIG_FIFO1;
+ else
+ stepconfig = STEPCONFIG_FIFO1;
+
+ if (iio_buffer_enabled(indio_dev))
+ stepconfig |= STEPCONFIG_MODE_SWCNT;
+
tiadc_writel(adc_dev, REG_STEPCONFIG(steps),
stepconfig | STEPCONFIG_INP(chan));
+
+ if (adc_dev->open_delay[i] > STEPDELAY_OPEN_MASK) {
+ dev_warn(dev, "chan %d open delay truncating to 0x3FFFF\n",
+ chan);
+ adc_dev->open_delay[i] = STEPDELAY_OPEN_MASK;
+ }
+
+ if (adc_dev->sample_delay[i] > 0xFF) {
+ dev_warn(dev, "chan %d sample delay truncating to 0xFF\n",
+ chan);
+ adc_dev->sample_delay[i] = 0xFF;
+ }
+
tiadc_writel(adc_dev, REG_STEPDELAY(steps),
- STEPCONFIG_OPENDLY);
+ STEPDELAY_OPEN(adc_dev->open_delay[i]) |
+ STEPDELAY_SAMPLE(adc_dev->sample_delay[i]));
+
adc_dev->channel_step[i] = steps;
steps++;
}
@@ -395,16 +424,43 @@ static const struct iio_info tiadc_info = {
.driver_module = THIS_MODULE,
};
+static int tiadc_parse_dt(struct platform_device *pdev,
+ struct tiadc_device *adc_dev)
+{
+ struct device_node *node = pdev->dev.of_node;
+ struct property *prop;
+ const __be32 *cur;
+ int channels = 0;
+ u32 val;
+
+ of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
+ adc_dev->channel_line[channels] = val;
+
+ /* Set Default values for optional DT parameters */
+ adc_dev->open_delay[channels] = STEPCONFIG_OPENDLY;
+ adc_dev->sample_delay[channels] = STEPCONFIG_SAMPLEDLY;
+ adc_dev->step_avg[channels] = 16;
+
+ channels++;
+ }
+
+ of_property_read_u32_array(node, "ti,chan-step-avg",
+ adc_dev->step_avg, channels);
+ of_property_read_u32_array(node, "ti,chan-step-opendelay",
+ adc_dev->open_delay, channels);
+ of_property_read_u32_array(node, "ti,chan-step-sampledelay",
+ adc_dev->sample_delay, channels);
+
+ adc_dev->channels = channels;
+ return 0;
+}
+
static int tiadc_probe(struct platform_device *pdev)
{
struct iio_dev *indio_dev;
struct tiadc_device *adc_dev;
struct device_node *node = pdev->dev.of_node;
- struct property *prop;
- const __be32 *cur;
int err;
- u32 val;
- int channels = 0;
if (!node) {
dev_err(&pdev->dev, "Could not find valid DT data.\n");
@@ -420,12 +476,7 @@ static int tiadc_probe(struct platform_device *pdev)
adc_dev = iio_priv(indio_dev);
adc_dev->mfd_tscadc = ti_tscadc_dev_get(pdev);
-
- of_property_for_each_u32(node, "ti,adc-channels", prop, cur, val) {
- adc_dev->channel_line[channels] = val;
- channels++;
- }
- adc_dev->channels = channels;
+ tiadc_parse_dt(pdev, adc_dev);
indio_dev->dev.parent = &pdev->dev;
indio_dev->name = dev_name(&pdev->dev);
diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c
index 8dd0477e201c19..e1634d2b6ae858 100644
--- a/drivers/iio/common/st_sensors/st_sensors_core.c
+++ b/drivers/iio/common/st_sensors/st_sensors_core.c
@@ -245,6 +245,16 @@ static int st_sensors_set_drdy_int_pin(struct iio_dev *indio_dev,
{
struct st_sensor_data *sdata = iio_priv(indio_dev);
+ /* Sensor does not support interrupts */
+ if (sdata->sensor_settings->drdy_irq.addr == 0) {
+ if (pdata->drdy_int_pin)
+ dev_info(&indio_dev->dev,
+ "DRDY on pin INT%d specified, but sensor "
+ "does not support interrupts\n",
+ pdata->drdy_int_pin);
+ return 0;
+ }
+
switch (pdata->drdy_int_pin) {
case 1:
if (sdata->sensor_settings->drdy_irq.mask_int1 == 0) {
@@ -285,7 +295,7 @@ static struct st_sensors_platform_data *st_sensors_of_probe(struct device *dev,
if (!of_property_read_u32(np, "st,drdy-int-pin", &val) && (val <= 2))
pdata->drdy_int_pin = (u8) val;
else
- pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 1;
+ pdata->drdy_int_pin = defdata ? defdata->drdy_int_pin : 0;
return pdata;
}
@@ -332,11 +342,13 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev,
return err;
/* set BDU */
- err = st_sensors_write_data_with_mask(indio_dev,
+ if (sdata->sensor_settings->bdu.addr) {
+ err = st_sensors_write_data_with_mask(indio_dev,
sdata->sensor_settings->bdu.addr,
sdata->sensor_settings->bdu.mask, true);
- if (err < 0)
- return err;
+ if (err < 0)
+ return err;
+ }
err = st_sensors_set_axis_enable(indio_dev, ST_SENSORS_ENABLE_ALL_AXIS);
@@ -489,7 +501,8 @@ int st_sensors_check_device_support(struct iio_dev *indio_dev,
break;
}
if (n == ARRAY_SIZE(sensor_settings[i].sensors_supported)) {
- dev_err(&indio_dev->dev, "device name and WhoAmI mismatch.\n");
+ dev_err(&indio_dev->dev, "device name \"%s\" and WhoAmI (0x%02x) mismatch",
+ indio_dev->name, wai);
goto sensor_name_mismatch;
}
diff --git a/drivers/iio/common/st_sensors/st_sensors_trigger.c b/drivers/iio/common/st_sensors/st_sensors_trigger.c
index 8d8ca6f1e16a5d..3e907040c2c7a7 100644
--- a/drivers/iio/common/st_sensors/st_sensors_trigger.c
+++ b/drivers/iio/common/st_sensors/st_sensors_trigger.c
@@ -37,8 +37,10 @@ int st_sensors_allocate_trigger(struct iio_dev *indio_dev,
IRQF_TRIGGER_RISING,
sdata->trig->name,
sdata->trig);
- if (err)
+ if (err) {
+ dev_err(&indio_dev->dev, "failed to request trigger IRQ.\n");
goto request_irq_error;
+ }
iio_trigger_set_drvdata(sdata->trig, indio_dev);
sdata->trig->ops = trigger_ops;
diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index 13471a76e5bf0b..e701e28fb1cd60 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -142,6 +142,16 @@ config AD7303
To compile this driver as module choose M here: the module will be called
ad7303.
+config M62332
+ tristate "Mitsubishi M62332 DAC driver"
+ depends on I2C
+ help
+ If you say yes here you get support for the Mitsubishi M62332
+ (I2C 8-Bit DACs with rail-to-rail outputs).
+
+ This driver can also be built as a module. If so, the module
+ will be called m62332.
+
config MAX517
tristate "Maxim MAX517/518/519/520/521 DAC driver"
depends on I2C
diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile
index 52be7e1acf16d1..63ae05633e0c95 100644
--- a/drivers/iio/dac/Makefile
+++ b/drivers/iio/dac/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_AD5764) += ad5764.o
obj-$(CONFIG_AD5791) += ad5791.o
obj-$(CONFIG_AD5686) += ad5686.o
obj-$(CONFIG_AD7303) += ad7303.o
+obj-$(CONFIG_M62332) += m62332.o
obj-$(CONFIG_MAX517) += max517.o
obj-$(CONFIG_MAX5821) += max5821.o
obj-$(CONFIG_MCP4725) += mcp4725.o
diff --git a/drivers/iio/dac/m62332.c b/drivers/iio/dac/m62332.c
new file mode 100644
index 00000000000000..c23d7fa889ee3f
--- /dev/null
+++ b/drivers/iio/dac/m62332.c
@@ -0,0 +1,269 @@
+/*
+ * m62332.c - Support for Mitsubishi m62332 DAC
+ *
+ * Copyright (c) 2014 Dmitry Eremin-Solenikov
+ *
+ * Based on max517 driver:
+ * Copyright (C) 2010, 2011 Roland Stigge <stigge@antcom.de>
+ *
+ * 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.
+ */
+
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/i2c.h>
+#include <linux/err.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/driver.h>
+
+#include <linux/regulator/consumer.h>
+
+#define M62332_CHANNELS 2
+
+struct m62332_data {
+ struct i2c_client *client;
+ u16 vref_mv;
+ struct regulator *vcc;
+ struct mutex mutex;
+ u8 raw[M62332_CHANNELS];
+#ifdef CONFIG_PM_SLEEP
+ u8 save[M62332_CHANNELS];
+#endif
+};
+
+static int m62332_set_value(struct iio_dev *indio_dev,
+ u8 val, int channel)
+{
+ struct m62332_data *data = iio_priv(indio_dev);
+ struct i2c_client *client = data->client;
+ u8 outbuf[2];
+ int res;
+
+ if (val == data->raw[channel])
+ return 0;
+
+ outbuf[0] = channel;
+ outbuf[1] = val;
+
+ mutex_lock(&data->mutex);
+
+ if (val) {
+ res = regulator_enable(data->vcc);
+ if (res)
+ goto out;
+ }
+
+ res = i2c_master_send(client, outbuf, 2);
+ if (res >= 0 && res != 2)
+ res = -EIO;
+ if (res < 0)
+ goto out;
+
+ data->raw[channel] = val;
+
+ if (!val)
+ regulator_disable(data->vcc);
+
+ mutex_unlock(&data->mutex);
+
+ return 0;
+
+out:
+ mutex_unlock(&data->mutex);
+
+ return res;
+}
+
+static int m62332_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val,
+ int *val2,
+ long m)
+{
+ struct m62332_data *data = iio_priv(indio_dev);
+
+ switch (m) {
+ case IIO_CHAN_INFO_SCALE:
+ /* Corresponds to Vref / 2^(bits) */
+ *val = data->vref_mv;
+ *val2 = 8;
+ return IIO_VAL_FRACTIONAL_LOG2;
+ case IIO_CHAN_INFO_RAW:
+ *val = data->raw[chan->channel];
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_OFFSET:
+ *val = 1;
+ return IIO_VAL_INT;
+ default:
+ break;
+ }
+ return -EINVAL;
+}
+
+static int m62332_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int val, int val2, long mask)
+{
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ if (val < 0 || val > 255)
+ return -EINVAL;
+
+ ret = m62332_set_value(indio_dev, val, chan->channel);
+ break;
+ default:
+ ret = -EINVAL;
+ break;
+ }
+
+ return ret;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int m62332_suspend(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct m62332_data *data = iio_priv(indio_dev);
+ int ret;
+
+ data->save[0] = data->raw[0];
+ data->save[1] = data->raw[1];
+
+ ret = m62332_set_value(indio_dev, 0, 0);
+ if (ret < 0)
+ return ret;
+
+ return m62332_set_value(indio_dev, 0, 1);
+}
+
+static int m62332_resume(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct m62332_data *data = iio_priv(indio_dev);
+ int ret;
+
+ ret = m62332_set_value(indio_dev, data->save[0], 0);
+ if (ret < 0)
+ return ret;
+
+ return m62332_set_value(indio_dev, data->save[1], 1);
+}
+
+static SIMPLE_DEV_PM_OPS(m62332_pm_ops, m62332_suspend, m62332_resume);
+#define M62332_PM_OPS (&m62332_pm_ops)
+#else
+#define M62332_PM_OPS NULL
+#endif
+
+static const struct iio_info m62332_info = {
+ .read_raw = m62332_read_raw,
+ .write_raw = m62332_write_raw,
+ .driver_module = THIS_MODULE,
+};
+
+#define M62332_CHANNEL(chan) { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .output = 1, \
+ .channel = (chan), \
+ .datasheet_name = "CH" #chan, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
+ BIT(IIO_CHAN_INFO_SCALE) | \
+ BIT(IIO_CHAN_INFO_OFFSET), \
+}
+
+static const struct iio_chan_spec m62332_channels[M62332_CHANNELS] = {
+ M62332_CHANNEL(0),
+ M62332_CHANNEL(1)
+};
+
+static int m62332_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct m62332_data *data;
+ struct iio_dev *indio_dev;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ if (!indio_dev)
+ return -ENOMEM;
+ data = iio_priv(indio_dev);
+ i2c_set_clientdata(client, indio_dev);
+ data->client = client;
+
+ mutex_init(&data->mutex);
+
+ data->vcc = devm_regulator_get(&client->dev, "VCC");
+ if (IS_ERR(data->vcc))
+ return PTR_ERR(data->vcc);
+
+ /* establish that the iio_dev is a child of the i2c device */
+ indio_dev->dev.parent = &client->dev;
+
+ indio_dev->num_channels = M62332_CHANNELS;
+ indio_dev->channels = m62332_channels;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->info = &m62332_info;
+
+ ret = regulator_get_voltage(data->vcc);
+ if (ret < 0)
+ return ret;
+ data->vref_mv = ret / 1000; /* mV */
+
+ ret = iio_map_array_register(indio_dev, client->dev.platform_data);
+ if (ret < 0)
+ return ret;
+
+ ret = iio_device_register(indio_dev);
+ if (ret < 0)
+ goto err;
+
+ return 0;
+
+err:
+ iio_map_array_unregister(indio_dev);
+ return ret;
+}
+
+static int m62332_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+ iio_device_unregister(indio_dev);
+ iio_map_array_unregister(indio_dev);
+
+ return 0;
+}
+
+static const struct i2c_device_id m62332_id[] = {
+ { "m62332", },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, m62332_id);
+
+static struct i2c_driver m62332_driver = {
+ .driver = {
+ .name = "m62332",
+ .pm = M62332_PM_OPS,
+ },
+ .probe = m62332_probe,
+ .remove = m62332_remove,
+ .id_table = m62332_id,
+};
+module_i2c_driver(m62332_driver);
+
+MODULE_AUTHOR("Dmitry Eremin-Solenikov");
+MODULE_DESCRIPTION("M62332 8-bit DAC");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/gyro/bmg160.c b/drivers/iio/gyro/bmg160.c
index 4415f55d26b6b0..460bf715d5417d 100644
--- a/drivers/iio/gyro/bmg160.c
+++ b/drivers/iio/gyro/bmg160.c
@@ -108,7 +108,6 @@ struct bmg160_data {
int slope_thres;
bool dready_trigger_on;
bool motion_trigger_on;
- int64_t timestamp;
};
enum bmg160_axis {
@@ -738,17 +737,6 @@ static int bmg160_write_event_config(struct iio_dev *indio_dev,
return 0;
}
-static int bmg160_validate_trigger(struct iio_dev *indio_dev,
- struct iio_trigger *trig)
-{
- struct bmg160_data *data = iio_priv(indio_dev);
-
- if (data->dready_trig != trig && data->motion_trig != trig)
- return -EINVAL;
-
- return 0;
-}
-
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100 200 400 1000 2000");
static IIO_CONST_ATTR(in_anglvel_scale_available,
@@ -810,7 +798,6 @@ static const struct iio_info bmg160_info = {
.write_event_value = bmg160_write_event,
.write_event_config = bmg160_write_event_config,
.read_event_config = bmg160_read_event_config,
- .validate_trigger = bmg160_validate_trigger,
.driver_module = THIS_MODULE,
};
@@ -835,7 +822,7 @@ static irqreturn_t bmg160_trigger_handler(int irq, void *p)
mutex_unlock(&data->mutex);
iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
- data->timestamp);
+ pf->timestamp);
err:
iio_trigger_notify_done(indio_dev->trig);
@@ -938,21 +925,21 @@ static irqreturn_t bmg160_event_handler(int irq, void *private)
IIO_MOD_X,
IIO_EV_TYPE_ROC,
dir),
- data->timestamp);
+ iio_get_time_ns());
if (ret & BMG160_ANY_MOTION_BIT_Y)
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
0,
IIO_MOD_Y,
IIO_EV_TYPE_ROC,
dir),
- data->timestamp);
+ iio_get_time_ns());
if (ret & BMG160_ANY_MOTION_BIT_Z)
iio_push_event(indio_dev, IIO_MOD_EVENT_CODE(IIO_ANGL_VEL,
0,
IIO_MOD_Z,
IIO_EV_TYPE_ROC,
dir),
- data->timestamp);
+ iio_get_time_ns());
ack_intr_status:
if (!data->dready_trigger_on) {
@@ -973,8 +960,6 @@ static irqreturn_t bmg160_data_rdy_trig_poll(int irq, void *private)
struct iio_dev *indio_dev = private;
struct bmg160_data *data = iio_priv(indio_dev);
- data->timestamp = iio_get_time_ns();
-
if (data->dready_trigger_on)
iio_trigger_poll(data->dready_trig);
else if (data->motion_trigger_on)
@@ -987,6 +972,27 @@ static irqreturn_t bmg160_data_rdy_trig_poll(int irq, void *private)
}
+static int bmg160_buffer_preenable(struct iio_dev *indio_dev)
+{
+ struct bmg160_data *data = iio_priv(indio_dev);
+
+ return bmg160_set_power_state(data, true);
+}
+
+static int bmg160_buffer_postdisable(struct iio_dev *indio_dev)
+{
+ struct bmg160_data *data = iio_priv(indio_dev);
+
+ return bmg160_set_power_state(data, false);
+}
+
+static const struct iio_buffer_setup_ops bmg160_buffer_setup_ops = {
+ .preenable = bmg160_buffer_preenable,
+ .postenable = iio_triggered_buffer_postenable,
+ .predisable = iio_triggered_buffer_predisable,
+ .postdisable = bmg160_buffer_postdisable,
+};
+
static int bmg160_gpio_probe(struct i2c_client *client,
struct bmg160_data *data)
@@ -1103,16 +1109,16 @@ static int bmg160_probe(struct i2c_client *client,
data->motion_trig = NULL;
goto err_trigger_unregister;
}
+ }
- ret = iio_triggered_buffer_setup(indio_dev,
- NULL,
- bmg160_trigger_handler,
- NULL);
- if (ret < 0) {
- dev_err(&client->dev,
- "iio triggered buffer setup failed\n");
- goto err_trigger_unregister;
- }
+ ret = iio_triggered_buffer_setup(indio_dev,
+ iio_pollfunc_store_time,
+ bmg160_trigger_handler,
+ &bmg160_buffer_setup_ops);
+ if (ret < 0) {
+ dev_err(&client->dev,
+ "iio triggered buffer setup failed\n");
+ goto err_trigger_unregister;
}
ret = iio_device_register(indio_dev);
@@ -1135,8 +1141,7 @@ static int bmg160_probe(struct i2c_client *client,
err_iio_unregister:
iio_device_unregister(indio_dev);
err_buffer_cleanup:
- if (data->dready_trig)
- iio_triggered_buffer_cleanup(indio_dev);
+ iio_triggered_buffer_cleanup(indio_dev);
err_trigger_unregister:
if (data->dready_trig)
iio_trigger_unregister(data->dready_trig);
@@ -1156,9 +1161,9 @@ static int bmg160_remove(struct i2c_client *client)
pm_runtime_put_noidle(&client->dev);
iio_device_unregister(indio_dev);
+ iio_triggered_buffer_cleanup(indio_dev);
if (data->dready_trig) {
- iio_triggered_buffer_cleanup(indio_dev);
iio_trigger_unregister(data->dready_trig);
iio_trigger_unregister(data->motion_trig);
}
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c
index b5883b6f4e5044..c67ce2ac471539 100644
--- a/drivers/iio/gyro/hid-sensor-gyro-3d.c
+++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c
@@ -298,7 +298,6 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct gyro_3d_state *gyro_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gyro_state));
if (!indio_dev)
@@ -317,21 +316,21 @@ static int hid_gyro_3d_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(gyro_3d_channels, sizeof(gyro_3d_channels),
- GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(gyro_3d_channels,
+ sizeof(gyro_3d_channels), GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = gyro_3d_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_GYRO_3D, gyro_state);
+ ret = gyro_3d_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_GYRO_3D, gyro_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels = ARRAY_SIZE(gyro_3d_channels);
indio_dev->dev.parent = &pdev->dev;
indio_dev->info = &gyro_3d_info;
@@ -397,7 +396,7 @@ static int hid_gyro_3d_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id hid_gyro_3d_ids[] = {
+static const struct platform_device_id hid_gyro_3d_ids[] = {
{
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200076",
diff --git a/drivers/iio/humidity/Kconfig b/drivers/iio/humidity/Kconfig
index 4813b793b9f7f9..688c0d1cb47dea 100644
--- a/drivers/iio/humidity/Kconfig
+++ b/drivers/iio/humidity/Kconfig
@@ -5,7 +5,7 @@ menu "Humidity sensors"
config DHT11
tristate "DHT11 (and compatible sensors) driver"
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
help
This driver supports reading data via a single interrupt
generating GPIO line. Currently tested are DHT11 and DHT22.
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c
index df919f44d513f4..11291259b7b92b 100644
--- a/drivers/iio/industrialio-buffer.c
+++ b/drivers/iio/industrialio-buffer.c
@@ -539,26 +539,13 @@ static void iio_buffer_deactivate(struct iio_buffer *buffer)
iio_buffer_put(buffer);
}
-void iio_disable_all_buffers(struct iio_dev *indio_dev)
+static void iio_buffer_deactivate_all(struct iio_dev *indio_dev)
{
struct iio_buffer *buffer, *_buffer;
- if (list_empty(&indio_dev->buffer_list))
- return;
-
- if (indio_dev->setup_ops->predisable)
- indio_dev->setup_ops->predisable(indio_dev);
-
list_for_each_entry_safe(buffer, _buffer,
&indio_dev->buffer_list, buffer_list)
iio_buffer_deactivate(buffer);
-
- indio_dev->currentmode = INDIO_DIRECT_MODE;
- if (indio_dev->setup_ops->postdisable)
- indio_dev->setup_ops->postdisable(indio_dev);
-
- if (indio_dev->available_scan_masks == NULL)
- kfree(indio_dev->active_scan_mask);
}
static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev,
@@ -575,167 +562,256 @@ static void iio_buffer_update_bytes_per_datum(struct iio_dev *indio_dev,
buffer->access->set_bytes_per_datum(buffer, bytes);
}
-static int __iio_update_buffers(struct iio_dev *indio_dev,
- struct iio_buffer *insert_buffer,
- struct iio_buffer *remove_buffer)
+static int iio_buffer_request_update(struct iio_dev *indio_dev,
+ struct iio_buffer *buffer)
{
int ret;
- int success = 0;
- struct iio_buffer *buffer;
- unsigned long *compound_mask;
- const unsigned long *old_mask;
- /* Wind down existing buffers - iff there are any */
- if (!list_empty(&indio_dev->buffer_list)) {
- if (indio_dev->setup_ops->predisable) {
- ret = indio_dev->setup_ops->predisable(indio_dev);
- if (ret)
- return ret;
- }
- indio_dev->currentmode = INDIO_DIRECT_MODE;
- if (indio_dev->setup_ops->postdisable) {
- ret = indio_dev->setup_ops->postdisable(indio_dev);
- if (ret)
- return ret;
+ iio_buffer_update_bytes_per_datum(indio_dev, buffer);
+ if (buffer->access->request_update) {
+ ret = buffer->access->request_update(buffer);
+ if (ret) {
+ dev_dbg(&indio_dev->dev,
+ "Buffer not started: buffer parameter update failed (%d)\n",
+ ret);
+ return ret;
}
}
- /* Keep a copy of current setup to allow roll back */
- old_mask = indio_dev->active_scan_mask;
+
+ return 0;
+}
+
+static void iio_free_scan_mask(struct iio_dev *indio_dev,
+ const unsigned long *mask)
+{
+ /* If the mask is dynamically allocated free it, otherwise do nothing */
if (!indio_dev->available_scan_masks)
- indio_dev->active_scan_mask = NULL;
+ kfree(mask);
+}
- if (remove_buffer)
- iio_buffer_deactivate(remove_buffer);
- if (insert_buffer)
- iio_buffer_activate(indio_dev, insert_buffer);
+struct iio_device_config {
+ unsigned int mode;
+ const unsigned long *scan_mask;
+ unsigned int scan_bytes;
+ bool scan_timestamp;
+};
- /* If no buffers in list, we are done */
- if (list_empty(&indio_dev->buffer_list)) {
- indio_dev->currentmode = INDIO_DIRECT_MODE;
- if (indio_dev->available_scan_masks == NULL)
- kfree(old_mask);
- return 0;
+static int iio_verify_update(struct iio_dev *indio_dev,
+ struct iio_buffer *insert_buffer, struct iio_buffer *remove_buffer,
+ struct iio_device_config *config)
+{
+ unsigned long *compound_mask;
+ const unsigned long *scan_mask;
+ struct iio_buffer *buffer;
+ bool scan_timestamp;
+
+ memset(config, 0, sizeof(*config));
+
+ /*
+ * If there is just one buffer and we are removing it there is nothing
+ * to verify.
+ */
+ if (remove_buffer && !insert_buffer &&
+ list_is_singular(&indio_dev->buffer_list))
+ return 0;
+
+ /* Definitely possible for devices to support both of these. */
+ if ((indio_dev->modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) {
+ config->mode = INDIO_BUFFER_TRIGGERED;
+ } else if (indio_dev->modes & INDIO_BUFFER_HARDWARE) {
+ config->mode = INDIO_BUFFER_HARDWARE;
+ } else if (indio_dev->modes & INDIO_BUFFER_SOFTWARE) {
+ config->mode = INDIO_BUFFER_SOFTWARE;
+ } else {
+ /* Can only occur on first buffer */
+ if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
+ dev_dbg(&indio_dev->dev, "Buffer not started: no trigger\n");
+ return -EINVAL;
}
/* What scan mask do we actually have? */
compound_mask = kcalloc(BITS_TO_LONGS(indio_dev->masklength),
sizeof(long), GFP_KERNEL);
- if (compound_mask == NULL) {
- if (indio_dev->available_scan_masks == NULL)
- kfree(old_mask);
+ if (compound_mask == NULL)
return -ENOMEM;
- }
- indio_dev->scan_timestamp = 0;
+
+ scan_timestamp = false;
list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) {
+ if (buffer == remove_buffer)
+ continue;
bitmap_or(compound_mask, compound_mask, buffer->scan_mask,
indio_dev->masklength);
- indio_dev->scan_timestamp |= buffer->scan_timestamp;
+ scan_timestamp |= buffer->scan_timestamp;
+ }
+
+ if (insert_buffer) {
+ bitmap_or(compound_mask, compound_mask,
+ insert_buffer->scan_mask, indio_dev->masklength);
+ scan_timestamp |= insert_buffer->scan_timestamp;
}
+
if (indio_dev->available_scan_masks) {
- indio_dev->active_scan_mask =
- iio_scan_mask_match(indio_dev->available_scan_masks,
- indio_dev->masklength,
- compound_mask);
- if (indio_dev->active_scan_mask == NULL) {
- /*
- * Roll back.
- * Note can only occur when adding a buffer.
- */
- iio_buffer_deactivate(insert_buffer);
- if (old_mask) {
- indio_dev->active_scan_mask = old_mask;
- success = -EINVAL;
- }
- else {
- kfree(compound_mask);
- ret = -EINVAL;
- return ret;
- }
- }
+ scan_mask = iio_scan_mask_match(indio_dev->available_scan_masks,
+ indio_dev->masklength,
+ compound_mask);
+ kfree(compound_mask);
+ if (scan_mask == NULL)
+ return -EINVAL;
} else {
- indio_dev->active_scan_mask = compound_mask;
+ scan_mask = compound_mask;
}
+ config->scan_bytes = iio_compute_scan_bytes(indio_dev,
+ scan_mask, scan_timestamp);
+ config->scan_mask = scan_mask;
+ config->scan_timestamp = scan_timestamp;
+
+ return 0;
+}
+
+static int iio_enable_buffers(struct iio_dev *indio_dev,
+ struct iio_device_config *config)
+{
+ int ret;
+
+ indio_dev->active_scan_mask = config->scan_mask;
+ indio_dev->scan_timestamp = config->scan_timestamp;
+ indio_dev->scan_bytes = config->scan_bytes;
+
iio_update_demux(indio_dev);
/* Wind up again */
if (indio_dev->setup_ops->preenable) {
ret = indio_dev->setup_ops->preenable(indio_dev);
if (ret) {
- printk(KERN_ERR
+ dev_dbg(&indio_dev->dev,
"Buffer not started: buffer preenable failed (%d)\n", ret);
- goto error_remove_inserted;
- }
- }
- indio_dev->scan_bytes =
- iio_compute_scan_bytes(indio_dev,
- indio_dev->active_scan_mask,
- indio_dev->scan_timestamp);
- list_for_each_entry(buffer, &indio_dev->buffer_list, buffer_list) {
- iio_buffer_update_bytes_per_datum(indio_dev, buffer);
- if (buffer->access->request_update) {
- ret = buffer->access->request_update(buffer);
- if (ret) {
- printk(KERN_INFO
- "Buffer not started: buffer parameter update failed (%d)\n", ret);
- goto error_run_postdisable;
- }
+ goto err_undo_config;
}
}
+
if (indio_dev->info->update_scan_mode) {
ret = indio_dev->info
->update_scan_mode(indio_dev,
indio_dev->active_scan_mask);
if (ret < 0) {
- printk(KERN_INFO "Buffer not started: update scan mode failed (%d)\n", ret);
- goto error_run_postdisable;
+ dev_dbg(&indio_dev->dev,
+ "Buffer not started: update scan mode failed (%d)\n",
+ ret);
+ goto err_run_postdisable;
}
}
- /* Definitely possible for devices to support both of these. */
- if ((indio_dev->modes & INDIO_BUFFER_TRIGGERED) && indio_dev->trig) {
- indio_dev->currentmode = INDIO_BUFFER_TRIGGERED;
- } else if (indio_dev->modes & INDIO_BUFFER_HARDWARE) {
- indio_dev->currentmode = INDIO_BUFFER_HARDWARE;
- } else if (indio_dev->modes & INDIO_BUFFER_SOFTWARE) {
- indio_dev->currentmode = INDIO_BUFFER_SOFTWARE;
- } else { /* Should never be reached */
- /* Can only occur on first buffer */
- if (indio_dev->modes & INDIO_BUFFER_TRIGGERED)
- pr_info("Buffer not started: no trigger\n");
- ret = -EINVAL;
- goto error_run_postdisable;
- }
+
+ indio_dev->currentmode = config->mode;
if (indio_dev->setup_ops->postenable) {
ret = indio_dev->setup_ops->postenable(indio_dev);
if (ret) {
- printk(KERN_INFO
+ dev_dbg(&indio_dev->dev,
"Buffer not started: postenable failed (%d)\n", ret);
- indio_dev->currentmode = INDIO_DIRECT_MODE;
- if (indio_dev->setup_ops->postdisable)
- indio_dev->setup_ops->postdisable(indio_dev);
- goto error_disable_all_buffers;
+ goto err_run_postdisable;
}
}
- if (indio_dev->available_scan_masks)
- kfree(compound_mask);
- else
- kfree(old_mask);
-
- return success;
+ return 0;
-error_disable_all_buffers:
+err_run_postdisable:
indio_dev->currentmode = INDIO_DIRECT_MODE;
-error_run_postdisable:
if (indio_dev->setup_ops->postdisable)
indio_dev->setup_ops->postdisable(indio_dev);
-error_remove_inserted:
+err_undo_config:
+ indio_dev->active_scan_mask = NULL;
+
+ return ret;
+}
+
+static int iio_disable_buffers(struct iio_dev *indio_dev)
+{
+ int ret = 0;
+ int ret2;
+
+ /* Wind down existing buffers - iff there are any */
+ if (list_empty(&indio_dev->buffer_list))
+ return 0;
+
+ /*
+ * If things go wrong at some step in disable we still need to continue
+ * to perform the other steps, otherwise we leave the device in a
+ * inconsistent state. We return the error code for the first error we
+ * encountered.
+ */
+
+ if (indio_dev->setup_ops->predisable) {
+ ret2 = indio_dev->setup_ops->predisable(indio_dev);
+ if (ret2 && !ret)
+ ret = ret2;
+ }
+
+ indio_dev->currentmode = INDIO_DIRECT_MODE;
+
+ if (indio_dev->setup_ops->postdisable) {
+ ret2 = indio_dev->setup_ops->postdisable(indio_dev);
+ if (ret2 && !ret)
+ ret = ret2;
+ }
+
+ iio_free_scan_mask(indio_dev, indio_dev->active_scan_mask);
+ indio_dev->active_scan_mask = NULL;
+
+ return ret;
+}
+
+static int __iio_update_buffers(struct iio_dev *indio_dev,
+ struct iio_buffer *insert_buffer,
+ struct iio_buffer *remove_buffer)
+{
+ struct iio_device_config new_config;
+ int ret;
+
+ ret = iio_verify_update(indio_dev, insert_buffer, remove_buffer,
+ &new_config);
+ if (ret)
+ return ret;
+
+ if (insert_buffer) {
+ ret = iio_buffer_request_update(indio_dev, insert_buffer);
+ if (ret)
+ goto err_free_config;
+ }
+
+ ret = iio_disable_buffers(indio_dev);
+ if (ret)
+ goto err_deactivate_all;
+
+ if (remove_buffer)
+ iio_buffer_deactivate(remove_buffer);
if (insert_buffer)
- iio_buffer_deactivate(insert_buffer);
- indio_dev->active_scan_mask = old_mask;
- kfree(compound_mask);
+ iio_buffer_activate(indio_dev, insert_buffer);
+
+ /* If no buffers in list, we are done */
+ if (list_empty(&indio_dev->buffer_list))
+ return 0;
+
+ ret = iio_enable_buffers(indio_dev, &new_config);
+ if (ret)
+ goto err_deactivate_all;
+
+ return 0;
+
+err_deactivate_all:
+ /*
+ * We've already verified that the config is valid earlier. If things go
+ * wrong in either enable or disable the most likely reason is an IO
+ * error from the device. In this case there is no good recovery
+ * strategy. Just make sure to disable everything and leave the device
+ * in a sane state. With a bit of luck the device might come back to
+ * life again later and userspace can try again.
+ */
+ iio_buffer_deactivate_all(indio_dev);
+
+err_free_config:
+ iio_free_scan_mask(indio_dev, new_config.scan_mask);
return ret;
}
@@ -777,6 +853,12 @@ out_unlock:
}
EXPORT_SYMBOL_GPL(iio_update_buffers);
+void iio_disable_all_buffers(struct iio_dev *indio_dev)
+{
+ iio_disable_buffers(indio_dev);
+ iio_buffer_deactivate_all(indio_dev);
+}
+
static ssize_t iio_buffer_store_enable(struct device *dev,
struct device_attribute *attr,
const char *buf,
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 4df97f650e448e..3524b0de872110 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -101,6 +101,8 @@ static const char * const iio_modifier_names[] = {
[IIO_MOD_WALKING] = "walking",
[IIO_MOD_STILL] = "still",
[IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z] = "sqrt(x^2+y^2+z^2)",
+ [IIO_MOD_I] = "i",
+ [IIO_MOD_Q] = "q",
};
/* relies on pairs of these shared then separate */
@@ -117,6 +119,8 @@ static const char * const iio_chan_info_postfix[] = {
[IIO_CHAN_INFO_AVERAGE_RAW] = "mean_raw",
[IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY]
= "filter_low_pass_3db_frequency",
+ [IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY]
+ = "filter_high_pass_3db_frequency",
[IIO_CHAN_INFO_SAMP_FREQ] = "sampling_frequency",
[IIO_CHAN_INFO_FREQUENCY] = "frequency",
[IIO_CHAN_INFO_PHASE] = "phase",
@@ -128,6 +132,8 @@ static const char * const iio_chan_info_postfix[] = {
[IIO_CHAN_INFO_CALIBWEIGHT] = "calibweight",
[IIO_CHAN_INFO_DEBOUNCE_COUNT] = "debounce_count",
[IIO_CHAN_INFO_DEBOUNCE_TIME] = "debounce_time",
+ [IIO_CHAN_INFO_CALIBEMISSIVITY] = "calibemissivity",
+ [IIO_CHAN_INFO_OVERSAMPLING_RATIO] = "oversampling_ratio",
};
/**
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c
index a99692ba91bc75..894d8137c4cfaf 100644
--- a/drivers/iio/industrialio-event.c
+++ b/drivers/iio/industrialio-event.c
@@ -211,6 +211,8 @@ static const char * const iio_ev_info_text[] = {
[IIO_EV_INFO_VALUE] = "value",
[IIO_EV_INFO_HYSTERESIS] = "hysteresis",
[IIO_EV_INFO_PERIOD] = "period",
+ [IIO_EV_INFO_HIGH_PASS_FILTER_3DB] = "high_pass_filter_3db",
+ [IIO_EV_INFO_LOW_PASS_FILTER_3DB] = "low_pass_filter_3db",
};
static enum iio_event_direction iio_ev_attr_dir(struct iio_dev_attr *attr)
diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 01a1a16ab7be8f..e6198b7c9cbfcf 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -5,6 +5,19 @@
menu "Light sensors"
+config ACPI_ALS
+ tristate "ACPI Ambient Light Sensor"
+ depends on ACPI
+ select IIO_BUFFER
+ select IIO_TRIGGERED_BUFFER
+ select IIO_KFIFO_BUF
+ help
+ Say Y here if you want to build a driver for the ACPI0008
+ Ambient Light Sensor.
+
+ To compile this driver as a module, choose M here: the module will
+ be called acpi-als.
+
config ADJD_S311
tristate "ADJD-S311-CR999 digital color sensor"
select IIO_BUFFER
@@ -37,6 +50,16 @@ config APDS9300
To compile this driver as a module, choose M here: the
module will be called apds9300.
+config BH1750
+ tristate "ROHM BH1750 ambient light sensor"
+ depends on I2C
+ help
+ Say Y here to build support for the ROHM BH1710, BH1715, BH1721,
+ BH1750, BH1751 ambient light sensors.
+
+ To compile this driver as a module, choose M here: the module will
+ be called bh1750.
+
config CM32181
depends on I2C
tristate "CM32181 driver"
@@ -169,11 +192,23 @@ config LTR501
select IIO_TRIGGERED_BUFFER
help
If you say yes here you get support for the Lite-On LTR-501ALS-01
- ambient light and proximity sensor.
+ ambient light and proximity sensor. This driver also supports LTR-559
+ ALS/PS or LTR-301 ALS sensors.
This driver can also be built as a module. If so, the module
will be called ltr501.
+config STK3310
+ tristate "STK3310 ALS and proximity sensor"
+ depends on I2C
+ help
+ Say yes here to get support for the Sensortek STK3310 ambient light
+ and proximity sensor. The STK3311 model is also supported by this
+ driver.
+
+ Choosing M will build the driver as a module. If so, the module
+ will be called stk3310.
+
config TCS3414
tristate "TAOS TCS3414 digital color sensor"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index ad7c30fe443b26..e2d50fd59c66fb 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -3,9 +3,11 @@
#
# When adding new entries keep the list in alphabetical order
+obj-$(CONFIG_ACPI_ALS) += acpi-als.o
obj-$(CONFIG_ADJD_S311) += adjd_s311.o
obj-$(CONFIG_AL3320A) += al3320a.o
obj-$(CONFIG_APDS9300) += apds9300.o
+obj-$(CONFIG_BH1750) += bh1750.o
obj-$(CONFIG_CM32181) += cm32181.o
obj-$(CONFIG_CM3232) += cm3232.o
obj-$(CONFIG_CM3323) += cm3323.o
@@ -18,6 +20,7 @@ obj-$(CONFIG_JSA1212) += jsa1212.o
obj-$(CONFIG_SENSORS_LM3533) += lm3533-als.o
obj-$(CONFIG_LTR501) += ltr501.o
obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o
+obj-$(CONFIG_STK3310) += stk3310.o
obj-$(CONFIG_TCS3414) += tcs3414.o
obj-$(CONFIG_TCS3472) += tcs3472.o
obj-$(CONFIG_TSL4531) += tsl4531.o
diff --git a/drivers/iio/light/acpi-als.c b/drivers/iio/light/acpi-als.c
new file mode 100644
index 00000000000000..1dafa0756bfabc
--- /dev/null
+++ b/drivers/iio/light/acpi-als.c
@@ -0,0 +1,231 @@
+/*
+ * ACPI Ambient Light Sensor Driver
+ *
+ * Based on ALS driver:
+ * Copyright (C) 2009 Zhang Rui <rui.zhang@intel.com>
+ *
+ * Rework for IIO subsystem:
+ * Copyright (C) 2012-2013 Martin Liska <marxin.liska@gmail.com>
+ *
+ * Final cleanup and debugging:
+ * Copyright (C) 2013-2014 Marek Vasut <marex@denx.de>
+ * Copyright (C) 2015 Gabriele Mazzotta <gabriele.mzt@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, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#include <linux/module.h>
+#include <linux/acpi.h>
+#include <linux/err.h>
+#include <linux/mutex.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/kfifo_buf.h>
+
+#define ACPI_ALS_CLASS "als"
+#define ACPI_ALS_DEVICE_NAME "acpi-als"
+#define ACPI_ALS_NOTIFY_ILLUMINANCE 0x80
+
+ACPI_MODULE_NAME("acpi-als");
+
+/*
+ * So far, there's only one channel in here, but the specification for
+ * ACPI0008 says there can be more to what the block can report. Like
+ * chromaticity and such. We are ready for incoming additions!
+ */
+static const struct iio_chan_spec acpi_als_channels[] = {
+ {
+ .type = IIO_LIGHT,
+ .scan_type = {
+ .sign = 's',
+ .realbits = 32,
+ .storagebits = 32,
+ },
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ },
+};
+
+/*
+ * The event buffer contains timestamp and all the data from
+ * the ACPI0008 block. There are multiple, but so far we only
+ * support _ALI (illuminance). Once someone adds new channels
+ * to acpi_als_channels[], the evt_buffer below will grow
+ * automatically.
+ */
+#define EVT_NR_SOURCES ARRAY_SIZE(acpi_als_channels)
+#define EVT_BUFFER_SIZE \
+ (sizeof(s64) + (EVT_NR_SOURCES * sizeof(s32)))
+
+struct acpi_als {
+ struct acpi_device *device;
+ struct mutex lock;
+
+ s32 evt_buffer[EVT_BUFFER_SIZE];
+};
+
+/*
+ * All types of properties the ACPI0008 block can report. The ALI, ALC, ALT
+ * and ALP can all be handled by als_read_value() below, while the ALR is
+ * special.
+ *
+ * The _ALR property returns tables that can be used to fine-tune the values
+ * reported by the other props based on the particular hardware type and it's
+ * location (it contains tables for "rainy", "bright inhouse lighting" etc.).
+ *
+ * So far, we support only ALI (illuminance).
+ */
+#define ACPI_ALS_ILLUMINANCE "_ALI"
+#define ACPI_ALS_CHROMATICITY "_ALC"
+#define ACPI_ALS_COLOR_TEMP "_ALT"
+#define ACPI_ALS_POLLING "_ALP"
+#define ACPI_ALS_TABLES "_ALR"
+
+static int als_read_value(struct acpi_als *als, char *prop, s32 *val)
+{
+ unsigned long long temp_val;
+ acpi_status status;
+
+ status = acpi_evaluate_integer(als->device->handle, prop, NULL,
+ &temp_val);
+
+ if (ACPI_FAILURE(status)) {
+ ACPI_EXCEPTION((AE_INFO, status, "Error reading ALS %s", prop));
+ return -EIO;
+ }
+
+ *val = temp_val;
+
+ return 0;
+}
+
+static void acpi_als_notify(struct acpi_device *device, u32 event)
+{
+ struct iio_dev *indio_dev = acpi_driver_data(device);
+ struct acpi_als *als = iio_priv(indio_dev);
+ s32 *buffer = als->evt_buffer;
+ s64 time_ns = iio_get_time_ns();
+ s32 val;
+ int ret;
+
+ mutex_lock(&als->lock);
+
+ memset(buffer, 0, EVT_BUFFER_SIZE);
+
+ switch (event) {
+ case ACPI_ALS_NOTIFY_ILLUMINANCE:
+ ret = als_read_value(als, ACPI_ALS_ILLUMINANCE, &val);
+ if (ret < 0)
+ goto out;
+ *buffer++ = val;
+ break;
+ default:
+ /* Unhandled event */
+ dev_dbg(&device->dev, "Unhandled ACPI ALS event (%08x)!\n",
+ event);
+ goto out;
+ }
+
+ iio_push_to_buffers_with_timestamp(indio_dev, als->evt_buffer, time_ns);
+
+out:
+ mutex_unlock(&als->lock);
+}
+
+static int acpi_als_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int *val,
+ int *val2, long mask)
+{
+ struct acpi_als *als = iio_priv(indio_dev);
+ s32 temp_val;
+ int ret;
+
+ if (mask != IIO_CHAN_INFO_RAW)
+ return -EINVAL;
+
+ /* we support only illumination (_ALI) so far. */
+ if (chan->type != IIO_LIGHT)
+ return -EINVAL;
+
+ ret = als_read_value(als, ACPI_ALS_ILLUMINANCE, &temp_val);
+ if (ret < 0)
+ return ret;
+
+ *val = temp_val;
+
+ return IIO_VAL_INT;
+}
+
+static const struct iio_info acpi_als_info = {
+ .driver_module = THIS_MODULE,
+ .read_raw = acpi_als_read_raw,
+};
+
+static int acpi_als_add(struct acpi_device *device)
+{
+ struct acpi_als *als;
+ struct iio_dev *indio_dev;
+ struct iio_buffer *buffer;
+
+ indio_dev = devm_iio_device_alloc(&device->dev, sizeof(*als));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ als = iio_priv(indio_dev);
+
+ device->driver_data = indio_dev;
+ als->device = device;
+ mutex_init(&als->lock);
+
+ indio_dev->name = ACPI_ALS_DEVICE_NAME;
+ indio_dev->dev.parent = &device->dev;
+ indio_dev->info = &acpi_als_info;
+ indio_dev->modes = INDIO_BUFFER_SOFTWARE;
+ indio_dev->channels = acpi_als_channels;
+ indio_dev->num_channels = ARRAY_SIZE(acpi_als_channels);
+
+ buffer = devm_iio_kfifo_allocate(&device->dev);
+ if (!buffer)
+ return -ENOMEM;
+
+ iio_device_attach_buffer(indio_dev, buffer);
+
+ return devm_iio_device_register(&device->dev, indio_dev);
+}
+
+static const struct acpi_device_id acpi_als_device_ids[] = {
+ {"ACPI0008", 0},
+ {},
+};
+
+MODULE_DEVICE_TABLE(acpi, acpi_als_device_ids);
+
+static struct acpi_driver acpi_als_driver = {
+ .name = "acpi_als",
+ .class = ACPI_ALS_CLASS,
+ .ids = acpi_als_device_ids,
+ .ops = {
+ .add = acpi_als_add,
+ .notify = acpi_als_notify,
+ },
+};
+
+module_acpi_driver(acpi_als_driver);
+
+MODULE_AUTHOR("Zhang Rui <rui.zhang@intel.com>");
+MODULE_AUTHOR("Martin Liska <marxin.liska@gmail.com>");
+MODULE_AUTHOR("Marek Vasut <marex@denx.de>");
+MODULE_DESCRIPTION("ACPI Ambient Light Sensor Driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/iio/light/bh1750.c b/drivers/iio/light/bh1750.c
new file mode 100644
index 00000000000000..564c2b3c1a83dd
--- /dev/null
+++ b/drivers/iio/light/bh1750.c
@@ -0,0 +1,334 @@
+/*
+ * ROHM BH1710/BH1715/BH1721/BH1750/BH1751 ambient light sensor driver
+ *
+ * Copyright (c) Tomasz Duszynski <tduszyns@gmail.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.
+ *
+ * Data sheets:
+ * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1710fvc-e.pdf
+ * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1715fvc-e.pdf
+ * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1721fvc-e.pdf
+ * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1750fvi-e.pdf
+ * http://rohmfs.rohm.com/en/products/databook/datasheet/ic/sensor/light/bh1751fvi-e.pdf
+ *
+ * 7-bit I2C slave addresses:
+ * 0x23 (ADDR pin low)
+ * 0x5C (ADDR pin high)
+ *
+ */
+
+#include <linux/delay.h>
+#include <linux/i2c.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/module.h>
+
+#define BH1750_POWER_DOWN 0x00
+#define BH1750_ONE_TIME_H_RES_MODE 0x20 /* auto-mode for BH1721 */
+#define BH1750_CHANGE_INT_TIME_H_BIT 0x40
+#define BH1750_CHANGE_INT_TIME_L_BIT 0x60
+
+enum {
+ BH1710,
+ BH1721,
+ BH1750,
+};
+
+struct bh1750_chip_info;
+struct bh1750_data {
+ struct i2c_client *client;
+ struct mutex lock;
+ const struct bh1750_chip_info *chip_info;
+ u16 mtreg;
+};
+
+struct bh1750_chip_info {
+ u16 mtreg_min;
+ u16 mtreg_max;
+ u16 mtreg_default;
+ int mtreg_to_usec;
+ int mtreg_to_scale;
+
+ /*
+ * For BH1710/BH1721 all possible integration time values won't fit
+ * into one page so displaying is limited to every second one.
+ * Note, that user can still write proper values which were not
+ * listed.
+ */
+ int inc;
+
+ u16 int_time_low_mask;
+ u16 int_time_high_mask;
+}
+
+static const bh1750_chip_info_tbl[] = {
+ [BH1710] = { 140, 1022, 300, 400, 250000000, 2, 0x001F, 0x03E0 },
+ [BH1721] = { 140, 1020, 300, 400, 250000000, 2, 0x0010, 0x03E0 },
+ [BH1750] = { 31, 254, 69, 1740, 57500000, 1, 0x001F, 0x00E0 },
+};
+
+static int bh1750_change_int_time(struct bh1750_data *data, int usec)
+{
+ int ret;
+ u16 val;
+ u8 regval;
+ const struct bh1750_chip_info *chip_info = data->chip_info;
+
+ if ((usec % chip_info->mtreg_to_usec) != 0)
+ return -EINVAL;
+
+ val = usec / chip_info->mtreg_to_usec;
+ if (val < chip_info->mtreg_min || val > chip_info->mtreg_max)
+ return -EINVAL;
+
+ ret = i2c_smbus_write_byte(data->client, BH1750_POWER_DOWN);
+ if (ret < 0)
+ return ret;
+
+ regval = (val & chip_info->int_time_high_mask) >> 5;
+ ret = i2c_smbus_write_byte(data->client,
+ BH1750_CHANGE_INT_TIME_H_BIT | regval);
+ if (ret < 0)
+ return ret;
+
+ regval = val & chip_info->int_time_low_mask;
+ ret = i2c_smbus_write_byte(data->client,
+ BH1750_CHANGE_INT_TIME_L_BIT | regval);
+ if (ret < 0)
+ return ret;
+
+ data->mtreg = val;
+
+ return 0;
+}
+
+static int bh1750_read(struct bh1750_data *data, int *val)
+{
+ int ret;
+ __be16 result;
+ const struct bh1750_chip_info *chip_info = data->chip_info;
+ unsigned long delay = chip_info->mtreg_to_usec * data->mtreg;
+
+ /*
+ * BH1721 will enter continuous mode on receiving this command.
+ * Note, that this eliminates need for bh1750_resume().
+ */
+ ret = i2c_smbus_write_byte(data->client, BH1750_ONE_TIME_H_RES_MODE);
+ if (ret < 0)
+ return ret;
+
+ usleep_range(delay + 15000, delay + 40000);
+
+ ret = i2c_master_recv(data->client, (char *)&result, 2);
+ if (ret < 0)
+ return ret;
+
+ *val = be16_to_cpu(result);
+
+ return 0;
+}
+
+static int bh1750_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ int ret, tmp;
+ struct bh1750_data *data = iio_priv(indio_dev);
+ const struct bh1750_chip_info *chip_info = data->chip_info;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ switch (chan->type) {
+ case IIO_LIGHT:
+ mutex_lock(&data->lock);
+ ret = bh1750_read(data, val);
+ mutex_unlock(&data->lock);
+ if (ret < 0)
+ return ret;
+
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ case IIO_CHAN_INFO_SCALE:
+ tmp = chip_info->mtreg_to_scale / data->mtreg;
+ *val = tmp / 1000000;
+ *val2 = tmp % 1000000;
+ return IIO_VAL_INT_PLUS_MICRO;
+ case IIO_CHAN_INFO_INT_TIME:
+ *val = 0;
+ *val2 = chip_info->mtreg_to_usec * data->mtreg;
+ return IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int bh1750_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ int ret;
+ struct bh1750_data *data = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_INT_TIME:
+ if (val != 0)
+ return -EINVAL;
+
+ mutex_lock(&data->lock);
+ ret = bh1750_change_int_time(data, val2);
+ mutex_unlock(&data->lock);
+ return ret;
+ default:
+ return -EINVAL;
+ }
+}
+
+static ssize_t bh1750_show_int_time_available(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ int i;
+ size_t len = 0;
+ struct bh1750_data *data = iio_priv(dev_to_iio_dev(dev));
+ const struct bh1750_chip_info *chip_info = data->chip_info;
+
+ for (i = chip_info->mtreg_min; i <= chip_info->mtreg_max; i += chip_info->inc)
+ len += scnprintf(buf + len, PAGE_SIZE - len, "0.%06d ",
+ chip_info->mtreg_to_usec * i);
+
+ buf[len - 1] = '\n';
+
+ return len;
+}
+
+static IIO_DEV_ATTR_INT_TIME_AVAIL(bh1750_show_int_time_available);
+
+static struct attribute *bh1750_attributes[] = {
+ &iio_dev_attr_integration_time_available.dev_attr.attr,
+ NULL,
+};
+
+static struct attribute_group bh1750_attribute_group = {
+ .attrs = bh1750_attributes,
+};
+
+static const struct iio_info bh1750_info = {
+ .driver_module = THIS_MODULE,
+ .attrs = &bh1750_attribute_group,
+ .read_raw = bh1750_read_raw,
+ .write_raw = bh1750_write_raw,
+};
+
+static const struct iio_chan_spec bh1750_channels[] = {
+ {
+ .type = IIO_LIGHT,
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_INT_TIME)
+ }
+};
+
+static int bh1750_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ int ret, usec;
+ struct bh1750_data *data;
+ struct iio_dev *indio_dev;
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C |
+ I2C_FUNC_SMBUS_WRITE_BYTE))
+ return -ENODEV;
+
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ data = iio_priv(indio_dev);
+ i2c_set_clientdata(client, indio_dev);
+ data->client = client;
+ data->chip_info = &bh1750_chip_info_tbl[id->driver_data];
+
+ usec = data->chip_info->mtreg_to_usec * data->chip_info->mtreg_default;
+ ret = bh1750_change_int_time(data, usec);
+ if (ret < 0)
+ return ret;
+
+ mutex_init(&data->lock);
+ indio_dev->dev.parent = &client->dev;
+ indio_dev->info = &bh1750_info;
+ indio_dev->name = id->name;
+ indio_dev->channels = bh1750_channels;
+ indio_dev->num_channels = ARRAY_SIZE(bh1750_channels);
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ return iio_device_register(indio_dev);
+}
+
+static int bh1750_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct bh1750_data *data = iio_priv(indio_dev);
+
+ iio_device_unregister(indio_dev);
+
+ mutex_lock(&data->lock);
+ i2c_smbus_write_byte(client, BH1750_POWER_DOWN);
+ mutex_unlock(&data->lock);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int bh1750_suspend(struct device *dev)
+{
+ int ret;
+ struct bh1750_data *data =
+ iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
+
+ /*
+ * This is mainly for BH1721 which doesn't enter power down
+ * mode automatically.
+ */
+ mutex_lock(&data->lock);
+ ret = i2c_smbus_write_byte(data->client, BH1750_POWER_DOWN);
+ mutex_unlock(&data->lock);
+
+ return ret;
+}
+
+static SIMPLE_DEV_PM_OPS(bh1750_pm_ops, bh1750_suspend, NULL);
+#define BH1750_PM_OPS (&bh1750_pm_ops)
+#else
+#define BH1750_PM_OPS NULL
+#endif
+
+static const struct i2c_device_id bh1750_id[] = {
+ { "bh1710", BH1710 },
+ { "bh1715", BH1750 },
+ { "bh1721", BH1721 },
+ { "bh1750", BH1750 },
+ { "bh1751", BH1750 },
+ { }
+};
+MODULE_DEVICE_TABLE(i2c, bh1750_id);
+
+static struct i2c_driver bh1750_driver = {
+ .driver = {
+ .name = "bh1750",
+ .owner = THIS_MODULE,
+ .pm = BH1750_PM_OPS,
+ },
+ .probe = bh1750_probe,
+ .remove = bh1750_remove,
+ .id_table = bh1750_id,
+
+};
+module_i2c_driver(bh1750_driver);
+
+MODULE_AUTHOR("Tomasz Duszynski <tduszyns@gmail.com>");
+MODULE_DESCRIPTION("ROHM BH1710/BH1715/BH1721/BH1750/BH1751 als driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c
index 1609ecdd01b07a..8bb1f90ecd51c0 100644
--- a/drivers/iio/light/hid-sensor-als.c
+++ b/drivers/iio/light/hid-sensor-als.c
@@ -263,7 +263,6 @@ static int hid_als_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct als_state *als_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(struct als_state));
if (!indio_dev)
@@ -281,20 +280,21 @@ static int hid_als_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(als_channels, sizeof(als_channels), GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(als_channels,
+ sizeof(als_channels), GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = als_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_ALS, als_state);
+ ret = als_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_ALS, als_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels =
ARRAY_SIZE(als_channels);
indio_dev->dev.parent = &pdev->dev;
@@ -361,7 +361,7 @@ static int hid_als_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id hid_als_ids[] = {
+static const struct platform_device_id hid_als_ids[] = {
{
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200041",
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c
index ef60bae738e344..0d248476f4c9b6 100644
--- a/drivers/iio/light/hid-sensor-prox.c
+++ b/drivers/iio/light/hid-sensor-prox.c
@@ -350,7 +350,7 @@ static int hid_prox_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id hid_prox_ids[] = {
+static const struct platform_device_id hid_prox_ids[] = {
{
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200011",
diff --git a/drivers/iio/light/ltr501.c b/drivers/iio/light/ltr501.c
index 78b87839c4b958..1ef7d3773ab90b 100644
--- a/drivers/iio/light/ltr501.c
+++ b/drivers/iio/light/ltr501.c
@@ -9,15 +9,18 @@
*
* 7-bit I2C slave address 0x23
*
- * TODO: interrupt, threshold, measurement rate, IR LED characteristics
+ * TODO: IR LED characteristics
*/
#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/err.h>
#include <linux/delay.h>
+#include <linux/regmap.h>
+#include <linux/acpi.h>
#include <linux/iio/iio.h>
+#include <linux/iio/events.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/trigger_consumer.h>
#include <linux/iio/buffer.h>
@@ -27,12 +30,21 @@
#define LTR501_ALS_CONTR 0x80 /* ALS operation mode, SW reset */
#define LTR501_PS_CONTR 0x81 /* PS operation mode */
+#define LTR501_PS_MEAS_RATE 0x84 /* measurement rate*/
+#define LTR501_ALS_MEAS_RATE 0x85 /* ALS integ time, measurement rate*/
#define LTR501_PART_ID 0x86
#define LTR501_MANUFAC_ID 0x87
#define LTR501_ALS_DATA1 0x88 /* 16-bit, little endian */
#define LTR501_ALS_DATA0 0x8a /* 16-bit, little endian */
#define LTR501_ALS_PS_STATUS 0x8c
#define LTR501_PS_DATA 0x8d /* 16-bit, little endian */
+#define LTR501_INTR 0x8f /* output mode, polarity, mode */
+#define LTR501_PS_THRESH_UP 0x90 /* 11 bit, ps upper threshold */
+#define LTR501_PS_THRESH_LOW 0x92 /* 11 bit, ps lower threshold */
+#define LTR501_ALS_THRESH_UP 0x97 /* 16 bit, ALS upper threshold */
+#define LTR501_ALS_THRESH_LOW 0x99 /* 16 bit, ALS lower threshold */
+#define LTR501_INTR_PRST 0x9e /* ps thresh, als thresh */
+#define LTR501_MAX_REG 0x9f
#define LTR501_ALS_CONTR_SW_RESET BIT(2)
#define LTR501_CONTR_PS_GAIN_MASK (BIT(3) | BIT(2))
@@ -40,28 +52,288 @@
#define LTR501_CONTR_ALS_GAIN_MASK BIT(3)
#define LTR501_CONTR_ACTIVE BIT(1)
+#define LTR501_STATUS_ALS_INTR BIT(3)
#define LTR501_STATUS_ALS_RDY BIT(2)
+#define LTR501_STATUS_PS_INTR BIT(1)
#define LTR501_STATUS_PS_RDY BIT(0)
#define LTR501_PS_DATA_MASK 0x7ff
+#define LTR501_PS_THRESH_MASK 0x7ff
+#define LTR501_ALS_THRESH_MASK 0xffff
+
+#define LTR501_ALS_DEF_PERIOD 500000
+#define LTR501_PS_DEF_PERIOD 100000
+
+#define LTR501_REGMAP_NAME "ltr501_regmap"
+
+#define LTR501_LUX_CONV(vis_coeff, vis_data, ir_coeff, ir_data) \
+ ((vis_coeff * vis_data) - (ir_coeff * ir_data))
+
+static const int int_time_mapping[] = {100000, 50000, 200000, 400000};
+
+static const struct reg_field reg_field_it =
+ REG_FIELD(LTR501_ALS_MEAS_RATE, 3, 4);
+static const struct reg_field reg_field_als_intr =
+ REG_FIELD(LTR501_INTR, 0, 0);
+static const struct reg_field reg_field_ps_intr =
+ REG_FIELD(LTR501_INTR, 1, 1);
+static const struct reg_field reg_field_als_rate =
+ REG_FIELD(LTR501_ALS_MEAS_RATE, 0, 2);
+static const struct reg_field reg_field_ps_rate =
+ REG_FIELD(LTR501_PS_MEAS_RATE, 0, 3);
+static const struct reg_field reg_field_als_prst =
+ REG_FIELD(LTR501_INTR_PRST, 0, 3);
+static const struct reg_field reg_field_ps_prst =
+ REG_FIELD(LTR501_INTR_PRST, 4, 7);
+
+struct ltr501_samp_table {
+ int freq_val; /* repetition frequency in micro HZ*/
+ int time_val; /* repetition rate in micro seconds */
+};
+
+#define LTR501_RESERVED_GAIN -1
+
+enum {
+ ltr501 = 0,
+ ltr559,
+ ltr301,
+};
+
+struct ltr501_gain {
+ int scale;
+ int uscale;
+};
+
+static struct ltr501_gain ltr501_als_gain_tbl[] = {
+ {1, 0},
+ {0, 5000},
+};
+
+static struct ltr501_gain ltr559_als_gain_tbl[] = {
+ {1, 0},
+ {0, 500000},
+ {0, 250000},
+ {0, 125000},
+ {LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN},
+ {LTR501_RESERVED_GAIN, LTR501_RESERVED_GAIN},
+ {0, 20000},
+ {0, 10000},
+};
+
+static struct ltr501_gain ltr501_ps_gain_tbl[] = {
+ {1, 0},
+ {0, 250000},
+ {0, 125000},
+ {0, 62500},
+};
+
+static struct ltr501_gain ltr559_ps_gain_tbl[] = {
+ {0, 62500}, /* x16 gain */
+ {0, 31250}, /* x32 gain */
+ {0, 15625}, /* bits X1 are for x64 gain */
+ {0, 15624},
+};
+
+struct ltr501_chip_info {
+ u8 partid;
+ struct ltr501_gain *als_gain;
+ int als_gain_tbl_size;
+ struct ltr501_gain *ps_gain;
+ int ps_gain_tbl_size;
+ u8 als_mode_active;
+ u8 als_gain_mask;
+ u8 als_gain_shift;
+ struct iio_chan_spec const *channels;
+ const int no_channels;
+ const struct iio_info *info;
+ const struct iio_info *info_no_irq;
+};
struct ltr501_data {
struct i2c_client *client;
struct mutex lock_als, lock_ps;
+ struct ltr501_chip_info *chip_info;
u8 als_contr, ps_contr;
+ int als_period, ps_period; /* period in micro seconds */
+ struct regmap *regmap;
+ struct regmap_field *reg_it;
+ struct regmap_field *reg_als_intr;
+ struct regmap_field *reg_ps_intr;
+ struct regmap_field *reg_als_rate;
+ struct regmap_field *reg_ps_rate;
+ struct regmap_field *reg_als_prst;
+ struct regmap_field *reg_ps_prst;
+};
+
+static const struct ltr501_samp_table ltr501_als_samp_table[] = {
+ {20000000, 50000}, {10000000, 100000},
+ {5000000, 200000}, {2000000, 500000},
+ {1000000, 1000000}, {500000, 2000000},
+ {500000, 2000000}, {500000, 2000000}
};
+static const struct ltr501_samp_table ltr501_ps_samp_table[] = {
+ {20000000, 50000}, {14285714, 70000},
+ {10000000, 100000}, {5000000, 200000},
+ {2000000, 500000}, {1000000, 1000000},
+ {500000, 2000000}, {500000, 2000000},
+ {500000, 2000000}
+};
+
+static unsigned int ltr501_match_samp_freq(const struct ltr501_samp_table *tab,
+ int len, int val, int val2)
+{
+ int i, freq;
+
+ freq = val * 1000000 + val2;
+
+ for (i = 0; i < len; i++) {
+ if (tab[i].freq_val == freq)
+ return i;
+ }
+
+ return -EINVAL;
+}
+
+static int ltr501_als_read_samp_freq(struct ltr501_data *data,
+ int *val, int *val2)
+{
+ int ret, i;
+
+ ret = regmap_field_read(data->reg_als_rate, &i);
+ if (ret < 0)
+ return ret;
+
+ if (i < 0 || i >= ARRAY_SIZE(ltr501_als_samp_table))
+ return -EINVAL;
+
+ *val = ltr501_als_samp_table[i].freq_val / 1000000;
+ *val2 = ltr501_als_samp_table[i].freq_val % 1000000;
+
+ return IIO_VAL_INT_PLUS_MICRO;
+}
+
+static int ltr501_ps_read_samp_freq(struct ltr501_data *data,
+ int *val, int *val2)
+{
+ int ret, i;
+
+ ret = regmap_field_read(data->reg_ps_rate, &i);
+ if (ret < 0)
+ return ret;
+
+ if (i < 0 || i >= ARRAY_SIZE(ltr501_ps_samp_table))
+ return -EINVAL;
+
+ *val = ltr501_ps_samp_table[i].freq_val / 1000000;
+ *val2 = ltr501_ps_samp_table[i].freq_val % 1000000;
+
+ return IIO_VAL_INT_PLUS_MICRO;
+}
+
+static int ltr501_als_write_samp_freq(struct ltr501_data *data,
+ int val, int val2)
+{
+ int i, ret;
+
+ i = ltr501_match_samp_freq(ltr501_als_samp_table,
+ ARRAY_SIZE(ltr501_als_samp_table),
+ val, val2);
+
+ if (i < 0)
+ return i;
+
+ mutex_lock(&data->lock_als);
+ ret = regmap_field_write(data->reg_als_rate, i);
+ mutex_unlock(&data->lock_als);
+
+ return ret;
+}
+
+static int ltr501_ps_write_samp_freq(struct ltr501_data *data,
+ int val, int val2)
+{
+ int i, ret;
+
+ i = ltr501_match_samp_freq(ltr501_ps_samp_table,
+ ARRAY_SIZE(ltr501_ps_samp_table),
+ val, val2);
+
+ if (i < 0)
+ return i;
+
+ mutex_lock(&data->lock_ps);
+ ret = regmap_field_write(data->reg_ps_rate, i);
+ mutex_unlock(&data->lock_ps);
+
+ return ret;
+}
+
+static int ltr501_als_read_samp_period(struct ltr501_data *data, int *val)
+{
+ int ret, i;
+
+ ret = regmap_field_read(data->reg_als_rate, &i);
+ if (ret < 0)
+ return ret;
+
+ if (i < 0 || i >= ARRAY_SIZE(ltr501_als_samp_table))
+ return -EINVAL;
+
+ *val = ltr501_als_samp_table[i].time_val;
+
+ return IIO_VAL_INT;
+}
+
+static int ltr501_ps_read_samp_period(struct ltr501_data *data, int *val)
+{
+ int ret, i;
+
+ ret = regmap_field_read(data->reg_ps_rate, &i);
+ if (ret < 0)
+ return ret;
+
+ if (i < 0 || i >= ARRAY_SIZE(ltr501_ps_samp_table))
+ return -EINVAL;
+
+ *val = ltr501_ps_samp_table[i].time_val;
+
+ return IIO_VAL_INT;
+}
+
+/* IR and visible spectrum coeff's are given in data sheet */
+static unsigned long ltr501_calculate_lux(u16 vis_data, u16 ir_data)
+{
+ unsigned long ratio, lux;
+
+ if (vis_data == 0)
+ return 0;
+
+ /* multiply numerator by 100 to avoid handling ratio < 1 */
+ ratio = DIV_ROUND_UP(ir_data * 100, ir_data + vis_data);
+
+ if (ratio < 45)
+ lux = LTR501_LUX_CONV(1774, vis_data, -1105, ir_data);
+ else if (ratio >= 45 && ratio < 64)
+ lux = LTR501_LUX_CONV(3772, vis_data, 1336, ir_data);
+ else if (ratio >= 64 && ratio < 85)
+ lux = LTR501_LUX_CONV(1690, vis_data, 169, ir_data);
+ else
+ lux = 0;
+
+ return lux / 1000;
+}
+
static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask)
{
int tries = 100;
- int ret;
+ int ret, status;
while (tries--) {
- ret = i2c_smbus_read_byte_data(data->client,
- LTR501_ALS_PS_STATUS);
+ ret = regmap_read(data->regmap, LTR501_ALS_PS_STATUS, &status);
if (ret < 0)
return ret;
- if ((ret & drdy_mask) == drdy_mask)
+ if ((status & drdy_mask) == drdy_mask)
return 0;
msleep(25);
}
@@ -70,25 +342,221 @@ static int ltr501_drdy(struct ltr501_data *data, u8 drdy_mask)
return -EIO;
}
+static int ltr501_set_it_time(struct ltr501_data *data, int it)
+{
+ int ret, i, index = -1, status;
+
+ for (i = 0; i < ARRAY_SIZE(int_time_mapping); i++) {
+ if (int_time_mapping[i] == it) {
+ index = i;
+ break;
+ }
+ }
+ /* Make sure integ time index is valid */
+ if (index < 0)
+ return -EINVAL;
+
+ ret = regmap_read(data->regmap, LTR501_ALS_CONTR, &status);
+ if (ret < 0)
+ return ret;
+
+ if (status & LTR501_CONTR_ALS_GAIN_MASK) {
+ /*
+ * 200 ms and 400 ms integ time can only be
+ * used in dynamic range 1
+ */
+ if (index > 1)
+ return -EINVAL;
+ } else
+ /* 50 ms integ time can only be used in dynamic range 2 */
+ if (index == 1)
+ return -EINVAL;
+
+ return regmap_field_write(data->reg_it, index);
+}
+
+/* read int time in micro seconds */
+static int ltr501_read_it_time(struct ltr501_data *data, int *val, int *val2)
+{
+ int ret, index;
+
+ ret = regmap_field_read(data->reg_it, &index);
+ if (ret < 0)
+ return ret;
+
+ /* Make sure integ time index is valid */
+ if (index < 0 || index >= ARRAY_SIZE(int_time_mapping))
+ return -EINVAL;
+
+ *val2 = int_time_mapping[index];
+ *val = 0;
+
+ return IIO_VAL_INT_PLUS_MICRO;
+}
+
static int ltr501_read_als(struct ltr501_data *data, __le16 buf[2])
{
- int ret = ltr501_drdy(data, LTR501_STATUS_ALS_RDY);
+ int ret;
+
+ ret = ltr501_drdy(data, LTR501_STATUS_ALS_RDY);
if (ret < 0)
return ret;
/* always read both ALS channels in given order */
- return i2c_smbus_read_i2c_block_data(data->client,
- LTR501_ALS_DATA1, 2 * sizeof(__le16), (u8 *) buf);
+ return regmap_bulk_read(data->regmap, LTR501_ALS_DATA1,
+ buf, 2 * sizeof(__le16));
}
static int ltr501_read_ps(struct ltr501_data *data)
{
- int ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY);
+ int ret, status;
+
+ ret = ltr501_drdy(data, LTR501_STATUS_PS_RDY);
if (ret < 0)
return ret;
- return i2c_smbus_read_word_data(data->client, LTR501_PS_DATA);
+
+ ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA,
+ &status, 2);
+ if (ret < 0)
+ return ret;
+
+ return status;
+}
+
+static int ltr501_read_intr_prst(struct ltr501_data *data,
+ enum iio_chan_type type,
+ int *val2)
+{
+ int ret, samp_period, prst;
+
+ switch (type) {
+ case IIO_INTENSITY:
+ ret = regmap_field_read(data->reg_als_prst, &prst);
+ if (ret < 0)
+ return ret;
+
+ ret = ltr501_als_read_samp_period(data, &samp_period);
+
+ if (ret < 0)
+ return ret;
+ *val2 = samp_period * prst;
+ return IIO_VAL_INT_PLUS_MICRO;
+ case IIO_PROXIMITY:
+ ret = regmap_field_read(data->reg_ps_prst, &prst);
+ if (ret < 0)
+ return ret;
+
+ ret = ltr501_ps_read_samp_period(data, &samp_period);
+
+ if (ret < 0)
+ return ret;
+
+ *val2 = samp_period * prst;
+ return IIO_VAL_INT_PLUS_MICRO;
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
}
-#define LTR501_INTENSITY_CHANNEL(_idx, _addr, _mod, _shared) { \
+static int ltr501_write_intr_prst(struct ltr501_data *data,
+ enum iio_chan_type type,
+ int val, int val2)
+{
+ int ret, samp_period, new_val;
+ unsigned long period;
+
+ if (val < 0 || val2 < 0)
+ return -EINVAL;
+
+ /* period in microseconds */
+ period = ((val * 1000000) + val2);
+
+ switch (type) {
+ case IIO_INTENSITY:
+ ret = ltr501_als_read_samp_period(data, &samp_period);
+ if (ret < 0)
+ return ret;
+
+ /* period should be atleast equal to sampling period */
+ if (period < samp_period)
+ return -EINVAL;
+
+ new_val = DIV_ROUND_UP(period, samp_period);
+ if (new_val < 0 || new_val > 0x0f)
+ return -EINVAL;
+
+ mutex_lock(&data->lock_als);
+ ret = regmap_field_write(data->reg_als_prst, new_val);
+ mutex_unlock(&data->lock_als);
+ if (ret >= 0)
+ data->als_period = period;
+
+ return ret;
+ case IIO_PROXIMITY:
+ ret = ltr501_ps_read_samp_period(data, &samp_period);
+ if (ret < 0)
+ return ret;
+
+ /* period should be atleast equal to rate */
+ if (period < samp_period)
+ return -EINVAL;
+
+ new_val = DIV_ROUND_UP(period, samp_period);
+ if (new_val < 0 || new_val > 0x0f)
+ return -EINVAL;
+
+ mutex_lock(&data->lock_ps);
+ ret = regmap_field_write(data->reg_ps_prst, new_val);
+ mutex_unlock(&data->lock_ps);
+ if (ret >= 0)
+ data->ps_period = period;
+
+ return ret;
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
+static const struct iio_event_spec ltr501_als_event_spec[] = {
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_RISING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE),
+ }, {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_FALLING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE),
+ }, {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_EITHER,
+ .mask_separate = BIT(IIO_EV_INFO_ENABLE) |
+ BIT(IIO_EV_INFO_PERIOD),
+ },
+
+};
+
+static const struct iio_event_spec ltr501_pxs_event_spec[] = {
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_RISING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE),
+ }, {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_FALLING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE),
+ }, {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_EITHER,
+ .mask_separate = BIT(IIO_EV_INFO_ENABLE) |
+ BIT(IIO_EV_INFO_PERIOD),
+ },
+};
+
+#define LTR501_INTENSITY_CHANNEL(_idx, _addr, _mod, _shared, \
+ _evspec, _evsize) { \
.type = IIO_INTENSITY, \
.modified = 1, \
.address = (_addr), \
@@ -101,13 +569,27 @@ static int ltr501_read_ps(struct ltr501_data *data)
.realbits = 16, \
.storagebits = 16, \
.endianness = IIO_CPU, \
- } \
+ }, \
+ .event_spec = _evspec,\
+ .num_event_specs = _evsize,\
+}
+
+#define LTR501_LIGHT_CHANNEL() { \
+ .type = IIO_LIGHT, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \
+ .scan_index = -1, \
}
static const struct iio_chan_spec ltr501_channels[] = {
- LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0),
+ LTR501_LIGHT_CHANNEL(),
+ LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0,
+ ltr501_als_event_spec,
+ ARRAY_SIZE(ltr501_als_event_spec)),
LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR,
- BIT(IIO_CHAN_INFO_SCALE)),
+ BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_SAMP_FREQ),
+ NULL, 0),
{
.type = IIO_PROXIMITY,
.address = LTR501_PS_DATA,
@@ -120,23 +602,51 @@ static const struct iio_chan_spec ltr501_channels[] = {
.storagebits = 16,
.endianness = IIO_CPU,
},
+ .event_spec = ltr501_pxs_event_spec,
+ .num_event_specs = ARRAY_SIZE(ltr501_pxs_event_spec),
},
IIO_CHAN_SOFT_TIMESTAMP(3),
};
-static const int ltr501_ps_gain[4][2] = {
- {1, 0}, {0, 250000}, {0, 125000}, {0, 62500}
+static const struct iio_chan_spec ltr301_channels[] = {
+ LTR501_LIGHT_CHANNEL(),
+ LTR501_INTENSITY_CHANNEL(0, LTR501_ALS_DATA0, IIO_MOD_LIGHT_BOTH, 0,
+ ltr501_als_event_spec,
+ ARRAY_SIZE(ltr501_als_event_spec)),
+ LTR501_INTENSITY_CHANNEL(1, LTR501_ALS_DATA1, IIO_MOD_LIGHT_IR,
+ BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_INT_TIME) |
+ BIT(IIO_CHAN_INFO_SAMP_FREQ),
+ NULL, 0),
+ IIO_CHAN_SOFT_TIMESTAMP(2),
};
static int ltr501_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val, int *val2, long mask)
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
{
struct ltr501_data *data = iio_priv(indio_dev);
__le16 buf[2];
int ret, i;
switch (mask) {
+ case IIO_CHAN_INFO_PROCESSED:
+ if (iio_buffer_enabled(indio_dev))
+ return -EBUSY;
+
+ switch (chan->type) {
+ case IIO_LIGHT:
+ mutex_lock(&data->lock_als);
+ ret = ltr501_read_als(data, buf);
+ mutex_unlock(&data->lock_als);
+ if (ret < 0)
+ return ret;
+ *val = ltr501_calculate_lux(le16_to_cpu(buf[1]),
+ le16_to_cpu(buf[0]));
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
case IIO_CHAN_INFO_RAW:
if (iio_buffer_enabled(indio_dev))
return -EBUSY;
@@ -149,7 +659,7 @@ static int ltr501_read_raw(struct iio_dev *indio_dev,
if (ret < 0)
return ret;
*val = le16_to_cpu(chan->address == LTR501_ALS_DATA1 ?
- buf[0] : buf[1]);
+ buf[0] : buf[1]);
return IIO_VAL_INT;
case IIO_PROXIMITY:
mutex_lock(&data->lock_ps);
@@ -165,45 +675,59 @@ static int ltr501_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_INTENSITY:
- if (data->als_contr & LTR501_CONTR_ALS_GAIN_MASK) {
- *val = 0;
- *val2 = 5000;
- return IIO_VAL_INT_PLUS_MICRO;
- } else {
- *val = 1;
- *val2 = 0;
- return IIO_VAL_INT;
- }
+ i = (data->als_contr & data->chip_info->als_gain_mask)
+ >> data->chip_info->als_gain_shift;
+ *val = data->chip_info->als_gain[i].scale;
+ *val2 = data->chip_info->als_gain[i].uscale;
+ return IIO_VAL_INT_PLUS_MICRO;
case IIO_PROXIMITY:
i = (data->ps_contr & LTR501_CONTR_PS_GAIN_MASK) >>
LTR501_CONTR_PS_GAIN_SHIFT;
- *val = ltr501_ps_gain[i][0];
- *val2 = ltr501_ps_gain[i][1];
+ *val = data->chip_info->ps_gain[i].scale;
+ *val2 = data->chip_info->ps_gain[i].uscale;
return IIO_VAL_INT_PLUS_MICRO;
default:
return -EINVAL;
}
+ case IIO_CHAN_INFO_INT_TIME:
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ return ltr501_read_it_time(data, val, val2);
+ default:
+ return -EINVAL;
+ }
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ return ltr501_als_read_samp_freq(data, val, val2);
+ case IIO_PROXIMITY:
+ return ltr501_ps_read_samp_freq(data, val, val2);
+ default:
+ return -EINVAL;
+ }
}
return -EINVAL;
}
-static int ltr501_get_ps_gain_index(int val, int val2)
+static int ltr501_get_gain_index(struct ltr501_gain *gain, int size,
+ int val, int val2)
{
int i;
- for (i = 0; i < ARRAY_SIZE(ltr501_ps_gain); i++)
- if (val == ltr501_ps_gain[i][0] && val2 == ltr501_ps_gain[i][1])
+ for (i = 0; i < size; i++)
+ if (val == gain[i].scale && val2 == gain[i].uscale)
return i;
return -1;
}
static int ltr501_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val, int val2, long mask)
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
{
struct ltr501_data *data = iio_priv(indio_dev);
- int i;
+ int i, ret, freq_val, freq_val2;
+ struct ltr501_chip_info *info = data->chip_info;
if (iio_buffer_enabled(indio_dev))
return -EBUSY;
@@ -212,35 +736,382 @@ static int ltr501_write_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_INTENSITY:
- if (val == 0 && val2 == 5000)
- data->als_contr |= LTR501_CONTR_ALS_GAIN_MASK;
- else if (val == 1 && val2 == 0)
- data->als_contr &= ~LTR501_CONTR_ALS_GAIN_MASK;
- else
+ i = ltr501_get_gain_index(info->als_gain,
+ info->als_gain_tbl_size,
+ val, val2);
+ if (i < 0)
return -EINVAL;
- return i2c_smbus_write_byte_data(data->client,
- LTR501_ALS_CONTR, data->als_contr);
+
+ data->als_contr &= ~info->als_gain_mask;
+ data->als_contr |= i << info->als_gain_shift;
+
+ return regmap_write(data->regmap, LTR501_ALS_CONTR,
+ data->als_contr);
case IIO_PROXIMITY:
- i = ltr501_get_ps_gain_index(val, val2);
+ i = ltr501_get_gain_index(info->ps_gain,
+ info->ps_gain_tbl_size,
+ val, val2);
if (i < 0)
return -EINVAL;
data->ps_contr &= ~LTR501_CONTR_PS_GAIN_MASK;
data->ps_contr |= i << LTR501_CONTR_PS_GAIN_SHIFT;
- return i2c_smbus_write_byte_data(data->client,
- LTR501_PS_CONTR, data->ps_contr);
+
+ return regmap_write(data->regmap, LTR501_PS_CONTR,
+ data->ps_contr);
default:
return -EINVAL;
}
+ case IIO_CHAN_INFO_INT_TIME:
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ if (val != 0)
+ return -EINVAL;
+ mutex_lock(&data->lock_als);
+ i = ltr501_set_it_time(data, val2);
+ mutex_unlock(&data->lock_als);
+ return i;
+ default:
+ return -EINVAL;
+ }
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ ret = ltr501_als_read_samp_freq(data, &freq_val,
+ &freq_val2);
+ if (ret < 0)
+ return ret;
+
+ ret = ltr501_als_write_samp_freq(data, val, val2);
+ if (ret < 0)
+ return ret;
+
+ /* update persistence count when changing frequency */
+ ret = ltr501_write_intr_prst(data, chan->type,
+ 0, data->als_period);
+
+ if (ret < 0)
+ return ltr501_als_write_samp_freq(data,
+ freq_val,
+ freq_val2);
+ return ret;
+ case IIO_PROXIMITY:
+ ret = ltr501_ps_read_samp_freq(data, &freq_val,
+ &freq_val2);
+ if (ret < 0)
+ return ret;
+
+ ret = ltr501_ps_write_samp_freq(data, val, val2);
+ if (ret < 0)
+ return ret;
+
+ /* update persistence count when changing frequency */
+ ret = ltr501_write_intr_prst(data, chan->type,
+ 0, data->ps_period);
+
+ if (ret < 0)
+ return ltr501_ps_write_samp_freq(data,
+ freq_val,
+ freq_val2);
+ return ret;
+ default:
+ return -EINVAL;
+ }
+ }
+ return -EINVAL;
+}
+
+static int ltr501_read_thresh(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int *val, int *val2)
+{
+ struct ltr501_data *data = iio_priv(indio_dev);
+ int ret, thresh_data;
+
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ switch (dir) {
+ case IIO_EV_DIR_RISING:
+ ret = regmap_bulk_read(data->regmap,
+ LTR501_ALS_THRESH_UP,
+ &thresh_data, 2);
+ if (ret < 0)
+ return ret;
+ *val = thresh_data & LTR501_ALS_THRESH_MASK;
+ return IIO_VAL_INT;
+ case IIO_EV_DIR_FALLING:
+ ret = regmap_bulk_read(data->regmap,
+ LTR501_ALS_THRESH_LOW,
+ &thresh_data, 2);
+ if (ret < 0)
+ return ret;
+ *val = thresh_data & LTR501_ALS_THRESH_MASK;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ case IIO_PROXIMITY:
+ switch (dir) {
+ case IIO_EV_DIR_RISING:
+ ret = regmap_bulk_read(data->regmap,
+ LTR501_PS_THRESH_UP,
+ &thresh_data, 2);
+ if (ret < 0)
+ return ret;
+ *val = thresh_data & LTR501_PS_THRESH_MASK;
+ return IIO_VAL_INT;
+ case IIO_EV_DIR_FALLING:
+ ret = regmap_bulk_read(data->regmap,
+ LTR501_PS_THRESH_LOW,
+ &thresh_data, 2);
+ if (ret < 0)
+ return ret;
+ *val = thresh_data & LTR501_PS_THRESH_MASK;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ default:
+ return -EINVAL;
}
+
return -EINVAL;
}
-static IIO_CONST_ATTR(in_proximity_scale_available, "1 0.25 0.125 0.0625");
-static IIO_CONST_ATTR(in_intensity_scale_available, "1 0.005");
+static int ltr501_write_thresh(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int val, int val2)
+{
+ struct ltr501_data *data = iio_priv(indio_dev);
+ int ret;
+
+ if (val < 0)
+ return -EINVAL;
+
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ if (val > LTR501_ALS_THRESH_MASK)
+ return -EINVAL;
+ switch (dir) {
+ case IIO_EV_DIR_RISING:
+ mutex_lock(&data->lock_als);
+ ret = regmap_bulk_write(data->regmap,
+ LTR501_ALS_THRESH_UP,
+ &val, 2);
+ mutex_unlock(&data->lock_als);
+ return ret;
+ case IIO_EV_DIR_FALLING:
+ mutex_lock(&data->lock_als);
+ ret = regmap_bulk_write(data->regmap,
+ LTR501_ALS_THRESH_LOW,
+ &val, 2);
+ mutex_unlock(&data->lock_als);
+ return ret;
+ default:
+ return -EINVAL;
+ }
+ case IIO_PROXIMITY:
+ if (val > LTR501_PS_THRESH_MASK)
+ return -EINVAL;
+ switch (dir) {
+ case IIO_EV_DIR_RISING:
+ mutex_lock(&data->lock_ps);
+ ret = regmap_bulk_write(data->regmap,
+ LTR501_PS_THRESH_UP,
+ &val, 2);
+ mutex_unlock(&data->lock_ps);
+ return ret;
+ case IIO_EV_DIR_FALLING:
+ mutex_lock(&data->lock_ps);
+ ret = regmap_bulk_write(data->regmap,
+ LTR501_PS_THRESH_LOW,
+ &val, 2);
+ mutex_unlock(&data->lock_ps);
+ return ret;
+ default:
+ return -EINVAL;
+ }
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
+static int ltr501_read_event(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int *val, int *val2)
+{
+ int ret;
+
+ switch (info) {
+ case IIO_EV_INFO_VALUE:
+ return ltr501_read_thresh(indio_dev, chan, type, dir,
+ info, val, val2);
+ case IIO_EV_INFO_PERIOD:
+ ret = ltr501_read_intr_prst(iio_priv(indio_dev),
+ chan->type, val2);
+ *val = *val2 / 1000000;
+ *val2 = *val2 % 1000000;
+ return ret;
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
+static int ltr501_write_event(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int val, int val2)
+{
+ switch (info) {
+ case IIO_EV_INFO_VALUE:
+ if (val2 != 0)
+ return -EINVAL;
+ return ltr501_write_thresh(indio_dev, chan, type, dir,
+ info, val, val2);
+ case IIO_EV_INFO_PERIOD:
+ return ltr501_write_intr_prst(iio_priv(indio_dev), chan->type,
+ val, val2);
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
+static int ltr501_read_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir)
+{
+ struct ltr501_data *data = iio_priv(indio_dev);
+ int ret, status;
+
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ ret = regmap_field_read(data->reg_als_intr, &status);
+ if (ret < 0)
+ return ret;
+ return status;
+ case IIO_PROXIMITY:
+ ret = regmap_field_read(data->reg_ps_intr, &status);
+ if (ret < 0)
+ return ret;
+ return status;
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
+static int ltr501_write_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir, int state)
+{
+ struct ltr501_data *data = iio_priv(indio_dev);
+ int ret;
+
+ /* only 1 and 0 are valid inputs */
+ if (state != 1 && state != 0)
+ return -EINVAL;
+
+ switch (chan->type) {
+ case IIO_INTENSITY:
+ mutex_lock(&data->lock_als);
+ ret = regmap_field_write(data->reg_als_intr, state);
+ mutex_unlock(&data->lock_als);
+ return ret;
+ case IIO_PROXIMITY:
+ mutex_lock(&data->lock_ps);
+ ret = regmap_field_write(data->reg_ps_intr, state);
+ mutex_unlock(&data->lock_ps);
+ return ret;
+ default:
+ return -EINVAL;
+ }
+
+ return -EINVAL;
+}
+
+static ssize_t ltr501_show_proximity_scale_avail(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct ltr501_data *data = iio_priv(dev_to_iio_dev(dev));
+ struct ltr501_chip_info *info = data->chip_info;
+ ssize_t len = 0;
+ int i;
+
+ for (i = 0; i < info->ps_gain_tbl_size; i++) {
+ if (info->ps_gain[i].scale == LTR501_RESERVED_GAIN)
+ continue;
+ len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%06d ",
+ info->ps_gain[i].scale,
+ info->ps_gain[i].uscale);
+ }
+
+ buf[len - 1] = '\n';
+
+ return len;
+}
+
+static ssize_t ltr501_show_intensity_scale_avail(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct ltr501_data *data = iio_priv(dev_to_iio_dev(dev));
+ struct ltr501_chip_info *info = data->chip_info;
+ ssize_t len = 0;
+ int i;
+
+ for (i = 0; i < info->als_gain_tbl_size; i++) {
+ if (info->als_gain[i].scale == LTR501_RESERVED_GAIN)
+ continue;
+ len += scnprintf(buf + len, PAGE_SIZE - len, "%d.%06d ",
+ info->als_gain[i].scale,
+ info->als_gain[i].uscale);
+ }
+
+ buf[len - 1] = '\n';
+
+ return len;
+}
+
+static IIO_CONST_ATTR_INT_TIME_AVAIL("0.05 0.1 0.2 0.4");
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("20 10 5 2 1 0.5");
+
+static IIO_DEVICE_ATTR(in_proximity_scale_available, S_IRUGO,
+ ltr501_show_proximity_scale_avail, NULL, 0);
+static IIO_DEVICE_ATTR(in_intensity_scale_available, S_IRUGO,
+ ltr501_show_intensity_scale_avail, NULL, 0);
static struct attribute *ltr501_attributes[] = {
- &iio_const_attr_in_proximity_scale_available.dev_attr.attr,
- &iio_const_attr_in_intensity_scale_available.dev_attr.attr,
+ &iio_dev_attr_in_proximity_scale_available.dev_attr.attr,
+ &iio_dev_attr_in_intensity_scale_available.dev_attr.attr,
+ &iio_const_attr_integration_time_available.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
+ NULL
+};
+
+static struct attribute *ltr301_attributes[] = {
+ &iio_dev_attr_in_intensity_scale_available.dev_attr.attr,
+ &iio_const_attr_integration_time_available.dev_attr.attr,
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
NULL
};
@@ -248,20 +1119,98 @@ static const struct attribute_group ltr501_attribute_group = {
.attrs = ltr501_attributes,
};
+static const struct attribute_group ltr301_attribute_group = {
+ .attrs = ltr301_attributes,
+};
+
+static const struct iio_info ltr501_info_no_irq = {
+ .read_raw = ltr501_read_raw,
+ .write_raw = ltr501_write_raw,
+ .attrs = &ltr501_attribute_group,
+ .driver_module = THIS_MODULE,
+};
+
static const struct iio_info ltr501_info = {
.read_raw = ltr501_read_raw,
.write_raw = ltr501_write_raw,
.attrs = &ltr501_attribute_group,
+ .read_event_value = &ltr501_read_event,
+ .write_event_value = &ltr501_write_event,
+ .read_event_config = &ltr501_read_event_config,
+ .write_event_config = &ltr501_write_event_config,
+ .driver_module = THIS_MODULE,
+};
+
+static const struct iio_info ltr301_info_no_irq = {
+ .read_raw = ltr501_read_raw,
+ .write_raw = ltr501_write_raw,
+ .attrs = &ltr301_attribute_group,
.driver_module = THIS_MODULE,
};
-static int ltr501_write_contr(struct i2c_client *client, u8 als_val, u8 ps_val)
+static const struct iio_info ltr301_info = {
+ .read_raw = ltr501_read_raw,
+ .write_raw = ltr501_write_raw,
+ .attrs = &ltr301_attribute_group,
+ .read_event_value = &ltr501_read_event,
+ .write_event_value = &ltr501_write_event,
+ .read_event_config = &ltr501_read_event_config,
+ .write_event_config = &ltr501_write_event_config,
+ .driver_module = THIS_MODULE,
+};
+
+static struct ltr501_chip_info ltr501_chip_info_tbl[] = {
+ [ltr501] = {
+ .partid = 0x08,
+ .als_gain = ltr501_als_gain_tbl,
+ .als_gain_tbl_size = ARRAY_SIZE(ltr501_als_gain_tbl),
+ .ps_gain = ltr501_ps_gain_tbl,
+ .ps_gain_tbl_size = ARRAY_SIZE(ltr501_ps_gain_tbl),
+ .als_mode_active = BIT(0) | BIT(1),
+ .als_gain_mask = BIT(3),
+ .als_gain_shift = 3,
+ .info = &ltr501_info,
+ .info_no_irq = &ltr501_info_no_irq,
+ .channels = ltr501_channels,
+ .no_channels = ARRAY_SIZE(ltr501_channels),
+ },
+ [ltr559] = {
+ .partid = 0x09,
+ .als_gain = ltr559_als_gain_tbl,
+ .als_gain_tbl_size = ARRAY_SIZE(ltr559_als_gain_tbl),
+ .ps_gain = ltr559_ps_gain_tbl,
+ .ps_gain_tbl_size = ARRAY_SIZE(ltr559_ps_gain_tbl),
+ .als_mode_active = BIT(1),
+ .als_gain_mask = BIT(2) | BIT(3) | BIT(4),
+ .als_gain_shift = 2,
+ .info = &ltr501_info,
+ .info_no_irq = &ltr501_info_no_irq,
+ .channels = ltr501_channels,
+ .no_channels = ARRAY_SIZE(ltr501_channels),
+ },
+ [ltr301] = {
+ .partid = 0x08,
+ .als_gain = ltr501_als_gain_tbl,
+ .als_gain_tbl_size = ARRAY_SIZE(ltr501_als_gain_tbl),
+ .als_mode_active = BIT(0) | BIT(1),
+ .als_gain_mask = BIT(3),
+ .als_gain_shift = 3,
+ .info = &ltr301_info,
+ .info_no_irq = &ltr301_info_no_irq,
+ .channels = ltr301_channels,
+ .no_channels = ARRAY_SIZE(ltr301_channels),
+ },
+};
+
+static int ltr501_write_contr(struct ltr501_data *data, u8 als_val, u8 ps_val)
{
- int ret = i2c_smbus_write_byte_data(client, LTR501_ALS_CONTR, als_val);
+ int ret;
+
+ ret = regmap_write(data->regmap, LTR501_ALS_CONTR, als_val);
if (ret < 0)
return ret;
- return i2c_smbus_write_byte_data(client, LTR501_PS_CONTR, ps_val);
+ return regmap_write(data->regmap, LTR501_PS_CONTR, ps_val);
}
static irqreturn_t ltr501_trigger_handler(int irq, void *p)
@@ -273,13 +1222,13 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
__le16 als_buf[2];
u8 mask = 0;
int j = 0;
- int ret;
+ int ret, psdata;
memset(buf, 0, sizeof(buf));
/* figure out which data needs to be ready */
if (test_bit(0, indio_dev->active_scan_mask) ||
- test_bit(1, indio_dev->active_scan_mask))
+ test_bit(1, indio_dev->active_scan_mask))
mask |= LTR501_STATUS_ALS_RDY;
if (test_bit(2, indio_dev->active_scan_mask))
mask |= LTR501_STATUS_PS_RDY;
@@ -289,8 +1238,8 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
goto done;
if (mask & LTR501_STATUS_ALS_RDY) {
- ret = i2c_smbus_read_i2c_block_data(data->client,
- LTR501_ALS_DATA1, sizeof(als_buf), (u8 *) als_buf);
+ ret = regmap_bulk_read(data->regmap, LTR501_ALS_DATA1,
+ (u8 *)als_buf, sizeof(als_buf));
if (ret < 0)
return ret;
if (test_bit(0, indio_dev->active_scan_mask))
@@ -300,14 +1249,14 @@ static irqreturn_t ltr501_trigger_handler(int irq, void *p)
}
if (mask & LTR501_STATUS_PS_RDY) {
- ret = i2c_smbus_read_word_data(data->client, LTR501_PS_DATA);
+ ret = regmap_bulk_read(data->regmap, LTR501_PS_DATA,
+ &psdata, 2);
if (ret < 0)
goto done;
- buf[j++] = ret & LTR501_PS_DATA_MASK;
+ buf[j++] = psdata & LTR501_PS_DATA_MASK;
}
- iio_push_to_buffers_with_timestamp(indio_dev, buf,
- iio_get_time_ns());
+ iio_push_to_buffers_with_timestamp(indio_dev, buf, iio_get_time_ns());
done:
iio_trigger_notify_done(indio_dev->trig);
@@ -315,67 +1264,225 @@ done:
return IRQ_HANDLED;
}
+static irqreturn_t ltr501_interrupt_handler(int irq, void *private)
+{
+ struct iio_dev *indio_dev = private;
+ struct ltr501_data *data = iio_priv(indio_dev);
+ int ret, status;
+
+ ret = regmap_read(data->regmap, LTR501_ALS_PS_STATUS, &status);
+ if (ret < 0) {
+ dev_err(&data->client->dev,
+ "irq read int reg failed\n");
+ return IRQ_HANDLED;
+ }
+
+ if (status & LTR501_STATUS_ALS_INTR)
+ iio_push_event(indio_dev,
+ IIO_UNMOD_EVENT_CODE(IIO_INTENSITY, 0,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_EITHER),
+ iio_get_time_ns());
+
+ if (status & LTR501_STATUS_PS_INTR)
+ iio_push_event(indio_dev,
+ IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 0,
+ IIO_EV_TYPE_THRESH,
+ IIO_EV_DIR_EITHER),
+ iio_get_time_ns());
+
+ return IRQ_HANDLED;
+}
+
static int ltr501_init(struct ltr501_data *data)
{
- int ret;
+ int ret, status;
- ret = i2c_smbus_read_byte_data(data->client, LTR501_ALS_CONTR);
+ ret = regmap_read(data->regmap, LTR501_ALS_CONTR, &status);
if (ret < 0)
return ret;
- data->als_contr = ret | LTR501_CONTR_ACTIVE;
- ret = i2c_smbus_read_byte_data(data->client, LTR501_PS_CONTR);
+ data->als_contr = ret | data->chip_info->als_mode_active;
+
+ ret = regmap_read(data->regmap, LTR501_PS_CONTR, &status);
if (ret < 0)
return ret;
- data->ps_contr = ret | LTR501_CONTR_ACTIVE;
- return ltr501_write_contr(data->client, data->als_contr,
- data->ps_contr);
+ data->ps_contr = status | LTR501_CONTR_ACTIVE;
+
+ ret = ltr501_read_intr_prst(data, IIO_INTENSITY, &data->als_period);
+ if (ret < 0)
+ return ret;
+
+ ret = ltr501_read_intr_prst(data, IIO_PROXIMITY, &data->ps_period);
+ if (ret < 0)
+ return ret;
+
+ return ltr501_write_contr(data, data->als_contr, data->ps_contr);
+}
+
+static bool ltr501_is_volatile_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case LTR501_ALS_DATA1:
+ case LTR501_ALS_DATA0:
+ case LTR501_ALS_PS_STATUS:
+ case LTR501_PS_DATA:
+ return true;
+ default:
+ return false;
+ }
}
+static struct regmap_config ltr501_regmap_config = {
+ .name = LTR501_REGMAP_NAME,
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = LTR501_MAX_REG,
+ .cache_type = REGCACHE_RBTREE,
+ .volatile_reg = ltr501_is_volatile_reg,
+};
+
static int ltr501_powerdown(struct ltr501_data *data)
{
- return ltr501_write_contr(data->client,
- data->als_contr & ~LTR501_CONTR_ACTIVE,
+ return ltr501_write_contr(data, data->als_contr &
+ ~data->chip_info->als_mode_active,
data->ps_contr & ~LTR501_CONTR_ACTIVE);
}
+static const char *ltr501_match_acpi_device(struct device *dev, int *chip_idx)
+{
+ const struct acpi_device_id *id;
+
+ id = acpi_match_device(dev->driver->acpi_match_table, dev);
+ if (!id)
+ return NULL;
+ *chip_idx = id->driver_data;
+ return dev_name(dev);
+}
+
static int ltr501_probe(struct i2c_client *client,
- const struct i2c_device_id *id)
+ const struct i2c_device_id *id)
{
struct ltr501_data *data;
struct iio_dev *indio_dev;
- int ret;
+ struct regmap *regmap;
+ int ret, partid, chip_idx = 0;
+ const char *name = NULL;
indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
if (!indio_dev)
return -ENOMEM;
+ regmap = devm_regmap_init_i2c(client, &ltr501_regmap_config);
+ if (IS_ERR(regmap)) {
+ dev_err(&client->dev, "Regmap initialization failed.\n");
+ return PTR_ERR(regmap);
+ }
+
data = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
data->client = client;
+ data->regmap = regmap;
mutex_init(&data->lock_als);
mutex_init(&data->lock_ps);
- ret = i2c_smbus_read_byte_data(data->client, LTR501_PART_ID);
+ data->reg_it = devm_regmap_field_alloc(&client->dev, regmap,
+ reg_field_it);
+ if (IS_ERR(data->reg_it)) {
+ dev_err(&client->dev, "Integ time reg field init failed.\n");
+ return PTR_ERR(data->reg_it);
+ }
+
+ data->reg_als_intr = devm_regmap_field_alloc(&client->dev, regmap,
+ reg_field_als_intr);
+ if (IS_ERR(data->reg_als_intr)) {
+ dev_err(&client->dev, "ALS intr mode reg field init failed\n");
+ return PTR_ERR(data->reg_als_intr);
+ }
+
+ data->reg_ps_intr = devm_regmap_field_alloc(&client->dev, regmap,
+ reg_field_ps_intr);
+ if (IS_ERR(data->reg_ps_intr)) {
+ dev_err(&client->dev, "PS intr mode reg field init failed.\n");
+ return PTR_ERR(data->reg_ps_intr);
+ }
+
+ data->reg_als_rate = devm_regmap_field_alloc(&client->dev, regmap,
+ reg_field_als_rate);
+ if (IS_ERR(data->reg_als_rate)) {
+ dev_err(&client->dev, "ALS samp rate field init failed.\n");
+ return PTR_ERR(data->reg_als_rate);
+ }
+
+ data->reg_ps_rate = devm_regmap_field_alloc(&client->dev, regmap,
+ reg_field_ps_rate);
+ if (IS_ERR(data->reg_ps_rate)) {
+ dev_err(&client->dev, "PS samp rate field init failed.\n");
+ return PTR_ERR(data->reg_ps_rate);
+ }
+
+ data->reg_als_prst = devm_regmap_field_alloc(&client->dev, regmap,
+ reg_field_als_prst);
+ if (IS_ERR(data->reg_als_prst)) {
+ dev_err(&client->dev, "ALS prst reg field init failed\n");
+ return PTR_ERR(data->reg_als_prst);
+ }
+
+ data->reg_ps_prst = devm_regmap_field_alloc(&client->dev, regmap,
+ reg_field_ps_prst);
+ if (IS_ERR(data->reg_ps_prst)) {
+ dev_err(&client->dev, "PS prst reg field init failed.\n");
+ return PTR_ERR(data->reg_ps_prst);
+ }
+
+ ret = regmap_read(data->regmap, LTR501_PART_ID, &partid);
if (ret < 0)
return ret;
- if ((ret >> 4) != 0x8)
+
+ if (id) {
+ name = id->name;
+ chip_idx = id->driver_data;
+ } else if (ACPI_HANDLE(&client->dev)) {
+ name = ltr501_match_acpi_device(&client->dev, &chip_idx);
+ } else {
+ return -ENODEV;
+ }
+
+ data->chip_info = &ltr501_chip_info_tbl[chip_idx];
+
+ if ((partid >> 4) != data->chip_info->partid)
return -ENODEV;
indio_dev->dev.parent = &client->dev;
- indio_dev->info = &ltr501_info;
- indio_dev->channels = ltr501_channels;
- indio_dev->num_channels = ARRAY_SIZE(ltr501_channels);
- indio_dev->name = LTR501_DRV_NAME;
+ indio_dev->info = data->chip_info->info;
+ indio_dev->channels = data->chip_info->channels;
+ indio_dev->num_channels = data->chip_info->no_channels;
+ indio_dev->name = name;
indio_dev->modes = INDIO_DIRECT_MODE;
ret = ltr501_init(data);
if (ret < 0)
return ret;
+ if (client->irq > 0) {
+ ret = devm_request_threaded_irq(&client->dev, client->irq,
+ NULL, ltr501_interrupt_handler,
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
+ "ltr501_thresh_event",
+ indio_dev);
+ if (ret) {
+ dev_err(&client->dev, "request irq (%d) failed\n",
+ client->irq);
+ return ret;
+ }
+ } else {
+ indio_dev->info = data->chip_info->info_no_irq;
+ }
+
ret = iio_triggered_buffer_setup(indio_dev, NULL,
- ltr501_trigger_handler, NULL);
+ ltr501_trigger_handler, NULL);
if (ret)
goto powerdown_on_error;
@@ -407,24 +1514,34 @@ static int ltr501_remove(struct i2c_client *client)
static int ltr501_suspend(struct device *dev)
{
struct ltr501_data *data = iio_priv(i2c_get_clientdata(
- to_i2c_client(dev)));
+ to_i2c_client(dev)));
return ltr501_powerdown(data);
}
static int ltr501_resume(struct device *dev)
{
struct ltr501_data *data = iio_priv(i2c_get_clientdata(
- to_i2c_client(dev)));
+ to_i2c_client(dev)));
- return ltr501_write_contr(data->client, data->als_contr,
+ return ltr501_write_contr(data, data->als_contr,
data->ps_contr);
}
#endif
static SIMPLE_DEV_PM_OPS(ltr501_pm_ops, ltr501_suspend, ltr501_resume);
+static const struct acpi_device_id ltr_acpi_match[] = {
+ {"LTER0501", ltr501},
+ {"LTER0559", ltr559},
+ {"LTER0301", ltr301},
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, ltr_acpi_match);
+
static const struct i2c_device_id ltr501_id[] = {
- { "ltr501", 0 },
+ { "ltr501", ltr501},
+ { "ltr559", ltr559},
+ { "ltr301", ltr301},
{ }
};
MODULE_DEVICE_TABLE(i2c, ltr501_id);
@@ -433,6 +1550,7 @@ static struct i2c_driver ltr501_driver = {
.driver = {
.name = LTR501_DRV_NAME,
.pm = &ltr501_pm_ops,
+ .acpi_match_table = ACPI_PTR(ltr_acpi_match),
.owner = THIS_MODULE,
},
.probe = ltr501_probe,
diff --git a/drivers/iio/light/stk3310.c b/drivers/iio/light/stk3310.c
new file mode 100644
index 00000000000000..e79b9d89b024ed
--- /dev/null
+++ b/drivers/iio/light/stk3310.c
@@ -0,0 +1,722 @@
+/**
+ * Sensortek STK3310/STK3311 Ambient Light and Proximity Sensor
+ *
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General Public License. See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * IIO driver for STK3310/STK3311. 7-bit I2C address: 0x48.
+ */
+
+#include <linux/acpi.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/gpio/consumer.h>
+#include <linux/iio/events.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#define STK3310_REG_STATE 0x00
+#define STK3310_REG_PSCTRL 0x01
+#define STK3310_REG_ALSCTRL 0x02
+#define STK3310_REG_INT 0x04
+#define STK3310_REG_THDH_PS 0x06
+#define STK3310_REG_THDL_PS 0x08
+#define STK3310_REG_FLAG 0x10
+#define STK3310_REG_PS_DATA_MSB 0x11
+#define STK3310_REG_PS_DATA_LSB 0x12
+#define STK3310_REG_ALS_DATA_MSB 0x13
+#define STK3310_REG_ALS_DATA_LSB 0x14
+#define STK3310_REG_ID 0x3E
+#define STK3310_MAX_REG 0x80
+
+#define STK3310_STATE_EN_PS 0x01
+#define STK3310_STATE_EN_ALS 0x02
+#define STK3310_STATE_STANDBY 0x00
+
+#define STK3310_CHIP_ID_VAL 0x13
+#define STK3311_CHIP_ID_VAL 0x1D
+#define STK3310_PSINT_EN 0x01
+#define STK3310_PS_MAX_VAL 0xFFFF
+#define STK3310_THRESH_MAX 0xFFFF
+
+#define STK3310_DRIVER_NAME "stk3310"
+#define STK3310_REGMAP_NAME "stk3310_regmap"
+#define STK3310_EVENT "stk3310_event"
+#define STK3310_GPIO "stk3310_gpio"
+
+#define STK3310_SCALE_AVAILABLE "6.4 1.6 0.4 0.1"
+
+#define STK3310_IT_AVAILABLE \
+ "0.000185 0.000370 0.000741 0.001480 0.002960 0.005920 0.011840 " \
+ "0.023680 0.047360 0.094720 0.189440 0.378880 0.757760 1.515520 " \
+ "3.031040 6.062080"
+
+#define STK3310_REGFIELD(name) \
+ do { \
+ data->reg_##name = \
+ devm_regmap_field_alloc(&client->dev, regmap, \
+ stk3310_reg_field_##name); \
+ if (IS_ERR(data->reg_##name)) { \
+ dev_err(&client->dev, "reg field alloc failed.\n"); \
+ return PTR_ERR(data->reg_##name); \
+ } \
+ } while (0)
+
+static const struct reg_field stk3310_reg_field_state =
+ REG_FIELD(STK3310_REG_STATE, 0, 2);
+static const struct reg_field stk3310_reg_field_als_gain =
+ REG_FIELD(STK3310_REG_ALSCTRL, 4, 5);
+static const struct reg_field stk3310_reg_field_ps_gain =
+ REG_FIELD(STK3310_REG_PSCTRL, 4, 5);
+static const struct reg_field stk3310_reg_field_als_it =
+ REG_FIELD(STK3310_REG_ALSCTRL, 0, 3);
+static const struct reg_field stk3310_reg_field_ps_it =
+ REG_FIELD(STK3310_REG_PSCTRL, 0, 3);
+static const struct reg_field stk3310_reg_field_int_ps =
+ REG_FIELD(STK3310_REG_INT, 0, 2);
+static const struct reg_field stk3310_reg_field_flag_psint =
+ REG_FIELD(STK3310_REG_FLAG, 4, 4);
+static const struct reg_field stk3310_reg_field_flag_nf =
+ REG_FIELD(STK3310_REG_FLAG, 0, 0);
+/*
+ * Maximum PS values with regard to scale. Used to export the 'inverse'
+ * PS value (high values for far objects, low values for near objects).
+ */
+static const int stk3310_ps_max[4] = {
+ STK3310_PS_MAX_VAL / 64,
+ STK3310_PS_MAX_VAL / 16,
+ STK3310_PS_MAX_VAL / 4,
+ STK3310_PS_MAX_VAL,
+};
+
+static const int stk3310_scale_table[][2] = {
+ {6, 400000}, {1, 600000}, {0, 400000}, {0, 100000}
+};
+
+/* Integration time in seconds, microseconds */
+static const int stk3310_it_table[][2] = {
+ {0, 185}, {0, 370}, {0, 741}, {0, 1480},
+ {0, 2960}, {0, 5920}, {0, 11840}, {0, 23680},
+ {0, 47360}, {0, 94720}, {0, 189440}, {0, 378880},
+ {0, 757760}, {1, 515520}, {3, 31040}, {6, 62080},
+};
+
+struct stk3310_data {
+ struct i2c_client *client;
+ struct mutex lock;
+ bool als_enabled;
+ bool ps_enabled;
+ u64 timestamp;
+ struct regmap *regmap;
+ struct regmap_field *reg_state;
+ struct regmap_field *reg_als_gain;
+ struct regmap_field *reg_ps_gain;
+ struct regmap_field *reg_als_it;
+ struct regmap_field *reg_ps_it;
+ struct regmap_field *reg_int_ps;
+ struct regmap_field *reg_flag_psint;
+ struct regmap_field *reg_flag_nf;
+};
+
+static const struct iio_event_spec stk3310_events[] = {
+ /* Proximity event */
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_FALLING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE) |
+ BIT(IIO_EV_INFO_ENABLE),
+ },
+ /* Out-of-proximity event */
+ {
+ .type = IIO_EV_TYPE_THRESH,
+ .dir = IIO_EV_DIR_RISING,
+ .mask_separate = BIT(IIO_EV_INFO_VALUE) |
+ BIT(IIO_EV_INFO_ENABLE),
+ },
+};
+
+static const struct iio_chan_spec stk3310_channels[] = {
+ {
+ .type = IIO_LIGHT,
+ .info_mask_separate =
+ BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_INT_TIME),
+ },
+ {
+ .type = IIO_PROXIMITY,
+ .info_mask_separate =
+ BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_SCALE) |
+ BIT(IIO_CHAN_INFO_INT_TIME),
+ .event_spec = stk3310_events,
+ .num_event_specs = ARRAY_SIZE(stk3310_events),
+ }
+};
+
+static IIO_CONST_ATTR(in_illuminance_scale_available, STK3310_SCALE_AVAILABLE);
+
+static IIO_CONST_ATTR(in_proximity_scale_available, STK3310_SCALE_AVAILABLE);
+
+static IIO_CONST_ATTR(in_illuminance_integration_time_available,
+ STK3310_IT_AVAILABLE);
+
+static IIO_CONST_ATTR(in_proximity_integration_time_available,
+ STK3310_IT_AVAILABLE);
+
+static struct attribute *stk3310_attributes[] = {
+ &iio_const_attr_in_illuminance_scale_available.dev_attr.attr,
+ &iio_const_attr_in_proximity_scale_available.dev_attr.attr,
+ &iio_const_attr_in_illuminance_integration_time_available.dev_attr.attr,
+ &iio_const_attr_in_proximity_integration_time_available.dev_attr.attr,
+ NULL,
+};
+
+static const struct attribute_group stk3310_attribute_group = {
+ .attrs = stk3310_attributes
+};
+
+static int stk3310_get_index(const int table[][2], int table_size,
+ int val, int val2)
+{
+ int i;
+
+ for (i = 0; i < table_size; i++) {
+ if (val == table[i][0] && val2 == table[i][1])
+ return i;
+ }
+
+ return -EINVAL;
+}
+
+static int stk3310_read_event(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int *val, int *val2)
+{
+ u8 reg;
+ u16 buf;
+ int ret;
+ unsigned int index;
+ struct stk3310_data *data = iio_priv(indio_dev);
+
+ if (info != IIO_EV_INFO_VALUE)
+ return -EINVAL;
+
+ /*
+ * Only proximity interrupts are implemented at the moment.
+ * Since we're inverting proximity values, the sensor's 'high'
+ * threshold will become our 'low' threshold, associated with
+ * 'near' events. Similarly, the sensor's 'low' threshold will
+ * be our 'high' threshold, associated with 'far' events.
+ */
+ if (dir == IIO_EV_DIR_RISING)
+ reg = STK3310_REG_THDL_PS;
+ else if (dir == IIO_EV_DIR_FALLING)
+ reg = STK3310_REG_THDH_PS;
+ else
+ return -EINVAL;
+
+ mutex_lock(&data->lock);
+ ret = regmap_bulk_read(data->regmap, reg, &buf, 2);
+ mutex_unlock(&data->lock);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "register read failed\n");
+ return ret;
+ }
+ regmap_field_read(data->reg_ps_gain, &index);
+ *val = swab16(stk3310_ps_max[index] - buf);
+
+ return IIO_VAL_INT;
+}
+
+static int stk3310_write_event(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ enum iio_event_info info,
+ int val, int val2)
+{
+ u8 reg;
+ u16 buf;
+ int ret;
+ unsigned int index;
+ struct stk3310_data *data = iio_priv(indio_dev);
+ struct i2c_client *client = data->client;
+
+ regmap_field_read(data->reg_ps_gain, &index);
+ if (val > stk3310_ps_max[index])
+ return -EINVAL;
+
+ if (dir == IIO_EV_DIR_RISING)
+ reg = STK3310_REG_THDL_PS;
+ else if (dir == IIO_EV_DIR_FALLING)
+ reg = STK3310_REG_THDH_PS;
+ else
+ return -EINVAL;
+
+ buf = swab16(stk3310_ps_max[index] - val);
+ ret = regmap_bulk_write(data->regmap, reg, &buf, 2);
+ if (ret < 0)
+ dev_err(&client->dev, "failed to set PS threshold!\n");
+
+ return ret;
+}
+
+static int stk3310_read_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir)
+{
+ unsigned int event_val;
+ struct stk3310_data *data = iio_priv(indio_dev);
+
+ regmap_field_read(data->reg_int_ps, &event_val);
+
+ return event_val;
+}
+
+static int stk3310_write_event_config(struct iio_dev *indio_dev,
+ const struct iio_chan_spec *chan,
+ enum iio_event_type type,
+ enum iio_event_direction dir,
+ int state)
+{
+ int ret;
+ struct stk3310_data *data = iio_priv(indio_dev);
+ struct i2c_client *client = data->client;
+
+ if (state < 0 || state > 7)
+ return -EINVAL;
+
+ /* Set INT_PS value */
+ mutex_lock(&data->lock);
+ ret = regmap_field_write(data->reg_int_ps, state);
+ if (ret < 0)
+ dev_err(&client->dev, "failed to set interrupt mode\n");
+ mutex_unlock(&data->lock);
+
+ return ret;
+}
+
+static int stk3310_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ u8 reg;
+ u16 buf;
+ int ret;
+ unsigned int index;
+ struct stk3310_data *data = iio_priv(indio_dev);
+ struct i2c_client *client = data->client;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ if (chan->type == IIO_LIGHT)
+ reg = STK3310_REG_ALS_DATA_MSB;
+ else if (chan->type == IIO_PROXIMITY)
+ reg = STK3310_REG_PS_DATA_MSB;
+ else
+ return -EINVAL;
+ mutex_lock(&data->lock);
+ ret = regmap_bulk_read(data->regmap, reg, &buf, 2);
+ if (ret < 0) {
+ dev_err(&client->dev, "register read failed\n");
+ mutex_unlock(&data->lock);
+ return ret;
+ }
+ *val = swab16(buf);
+ if (chan->type == IIO_PROXIMITY) {
+ /*
+ * Invert the proximity data so we return low values
+ * for close objects and high values for far ones.
+ */
+ regmap_field_read(data->reg_ps_gain, &index);
+ *val = stk3310_ps_max[index] - *val;
+ }
+ mutex_unlock(&data->lock);
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_INT_TIME:
+ if (chan->type == IIO_LIGHT)
+ regmap_field_read(data->reg_als_it, &index);
+ else
+ regmap_field_read(data->reg_ps_it, &index);
+ *val = stk3310_it_table[index][0];
+ *val2 = stk3310_it_table[index][1];
+ return IIO_VAL_INT_PLUS_MICRO;
+ case IIO_CHAN_INFO_SCALE:
+ if (chan->type == IIO_LIGHT)
+ regmap_field_read(data->reg_als_gain, &index);
+ else
+ regmap_field_read(data->reg_ps_gain, &index);
+ *val = stk3310_scale_table[index][0];
+ *val2 = stk3310_scale_table[index][1];
+ return IIO_VAL_INT_PLUS_MICRO;
+ }
+
+ return -EINVAL;
+}
+
+static int stk3310_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ int ret;
+ unsigned int index;
+ struct stk3310_data *data = iio_priv(indio_dev);
+
+ switch (mask) {
+ case IIO_CHAN_INFO_INT_TIME:
+ index = stk3310_get_index(stk3310_it_table,
+ ARRAY_SIZE(stk3310_it_table),
+ val, val2);
+ if (index < 0)
+ return -EINVAL;
+ mutex_lock(&data->lock);
+ if (chan->type == IIO_LIGHT)
+ ret = regmap_field_write(data->reg_als_it, index);
+ else
+ ret = regmap_field_write(data->reg_ps_it, index);
+ if (ret < 0)
+ dev_err(&data->client->dev,
+ "sensor configuration failed\n");
+ mutex_unlock(&data->lock);
+ return ret;
+
+ case IIO_CHAN_INFO_SCALE:
+ index = stk3310_get_index(stk3310_scale_table,
+ ARRAY_SIZE(stk3310_scale_table),
+ val, val2);
+ if (index < 0)
+ return -EINVAL;
+ mutex_lock(&data->lock);
+ if (chan->type == IIO_LIGHT)
+ ret = regmap_field_write(data->reg_als_gain, index);
+ else
+ ret = regmap_field_write(data->reg_ps_gain, index);
+ if (ret < 0)
+ dev_err(&data->client->dev,
+ "sensor configuration failed\n");
+ mutex_unlock(&data->lock);
+ return ret;
+ }
+
+ return -EINVAL;
+}
+
+static const struct iio_info stk3310_info = {
+ .driver_module = THIS_MODULE,
+ .read_raw = stk3310_read_raw,
+ .write_raw = stk3310_write_raw,
+ .attrs = &stk3310_attribute_group,
+ .read_event_value = stk3310_read_event,
+ .write_event_value = stk3310_write_event,
+ .read_event_config = stk3310_read_event_config,
+ .write_event_config = stk3310_write_event_config,
+};
+
+static int stk3310_set_state(struct stk3310_data *data, u8 state)
+{
+ int ret;
+ struct i2c_client *client = data->client;
+
+ /* 3-bit state; 0b100 is not supported. */
+ if (state > 7 || state == 4)
+ return -EINVAL;
+
+ mutex_lock(&data->lock);
+ ret = regmap_field_write(data->reg_state, state);
+ if (ret < 0) {
+ dev_err(&client->dev, "failed to change sensor state\n");
+ } else if (state != STK3310_STATE_STANDBY) {
+ /* Don't reset the 'enabled' flags if we're going in standby */
+ data->ps_enabled = !!(state & 0x01);
+ data->als_enabled = !!(state & 0x02);
+ }
+ mutex_unlock(&data->lock);
+
+ return ret;
+}
+
+static int stk3310_init(struct iio_dev *indio_dev)
+{
+ int ret;
+ int chipid;
+ u8 state;
+ struct stk3310_data *data = iio_priv(indio_dev);
+ struct i2c_client *client = data->client;
+
+ regmap_read(data->regmap, STK3310_REG_ID, &chipid);
+ if (chipid != STK3310_CHIP_ID_VAL &&
+ chipid != STK3311_CHIP_ID_VAL) {
+ dev_err(&client->dev, "invalid chip id: 0x%x\n", chipid);
+ return -ENODEV;
+ }
+
+ state = STK3310_STATE_EN_ALS | STK3310_STATE_EN_PS;
+ ret = stk3310_set_state(data, state);
+ if (ret < 0) {
+ dev_err(&client->dev, "failed to enable sensor");
+ return ret;
+ }
+
+ /* Enable PS interrupts */
+ ret = regmap_field_write(data->reg_int_ps, STK3310_PSINT_EN);
+ if (ret < 0)
+ dev_err(&client->dev, "failed to enable interrupts!\n");
+
+ return ret;
+}
+
+static int stk3310_gpio_probe(struct i2c_client *client)
+{
+ struct device *dev;
+ struct gpio_desc *gpio;
+ int ret;
+
+ if (!client)
+ return -EINVAL;
+
+ dev = &client->dev;
+
+ /* gpio interrupt pin */
+ gpio = devm_gpiod_get_index(dev, STK3310_GPIO, 0);
+ if (IS_ERR(gpio)) {
+ dev_err(dev, "acpi gpio get index failed\n");
+ return PTR_ERR(gpio);
+ }
+
+ ret = gpiod_direction_input(gpio);
+ if (ret)
+ return ret;
+
+ ret = gpiod_to_irq(gpio);
+ dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
+
+ return ret;
+}
+
+static bool stk3310_is_volatile_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case STK3310_REG_ALS_DATA_MSB:
+ case STK3310_REG_ALS_DATA_LSB:
+ case STK3310_REG_PS_DATA_LSB:
+ case STK3310_REG_PS_DATA_MSB:
+ case STK3310_REG_FLAG:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static struct regmap_config stk3310_regmap_config = {
+ .name = STK3310_REGMAP_NAME,
+ .reg_bits = 8,
+ .val_bits = 8,
+ .max_register = STK3310_MAX_REG,
+ .cache_type = REGCACHE_RBTREE,
+ .volatile_reg = stk3310_is_volatile_reg,
+};
+
+static int stk3310_regmap_init(struct stk3310_data *data)
+{
+ struct regmap *regmap;
+ struct i2c_client *client;
+
+ client = data->client;
+ regmap = devm_regmap_init_i2c(client, &stk3310_regmap_config);
+ if (IS_ERR(regmap)) {
+ dev_err(&client->dev, "regmap initialization failed.\n");
+ return PTR_ERR(regmap);
+ }
+ data->regmap = regmap;
+
+ STK3310_REGFIELD(state);
+ STK3310_REGFIELD(als_gain);
+ STK3310_REGFIELD(ps_gain);
+ STK3310_REGFIELD(als_it);
+ STK3310_REGFIELD(ps_it);
+ STK3310_REGFIELD(int_ps);
+ STK3310_REGFIELD(flag_psint);
+ STK3310_REGFIELD(flag_nf);
+
+ return 0;
+}
+
+static irqreturn_t stk3310_irq_handler(int irq, void *private)
+{
+ struct iio_dev *indio_dev = private;
+ struct stk3310_data *data = iio_priv(indio_dev);
+
+ data->timestamp = iio_get_time_ns();
+
+ return IRQ_WAKE_THREAD;
+}
+
+static irqreturn_t stk3310_irq_event_handler(int irq, void *private)
+{
+ int ret;
+ unsigned int dir;
+ u64 event;
+
+ struct iio_dev *indio_dev = private;
+ struct stk3310_data *data = iio_priv(indio_dev);
+
+ /* Read FLAG_NF to figure out what threshold has been met. */
+ mutex_lock(&data->lock);
+ ret = regmap_field_read(data->reg_flag_nf, &dir);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "register read failed\n");
+ mutex_unlock(&data->lock);
+ return ret;
+ }
+ event = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, 1,
+ IIO_EV_TYPE_THRESH,
+ (dir ? IIO_EV_DIR_RISING :
+ IIO_EV_DIR_FALLING));
+ iio_push_event(indio_dev, event, data->timestamp);
+
+ /* Reset the interrupt flag */
+ ret = regmap_field_write(data->reg_flag_psint, 0);
+ if (ret < 0)
+ dev_err(&data->client->dev, "failed to reset interrupts\n");
+ mutex_unlock(&data->lock);
+
+ return IRQ_HANDLED;
+}
+
+static int stk3310_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ int ret;
+ struct iio_dev *indio_dev;
+ struct stk3310_data *data;
+
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ if (!indio_dev) {
+ dev_err(&client->dev, "iio allocation failed!\n");
+ return -ENOMEM;
+ }
+
+ data = iio_priv(indio_dev);
+ data->client = client;
+ i2c_set_clientdata(client, indio_dev);
+ mutex_init(&data->lock);
+
+ ret = stk3310_regmap_init(data);
+ if (ret < 0)
+ return ret;
+
+ indio_dev->dev.parent = &client->dev;
+ indio_dev->info = &stk3310_info;
+ indio_dev->name = STK3310_DRIVER_NAME;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->channels = stk3310_channels;
+ indio_dev->num_channels = ARRAY_SIZE(stk3310_channels);
+
+ ret = stk3310_init(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ ret = iio_device_register(indio_dev);
+ if (ret < 0) {
+ dev_err(&client->dev, "device_register failed\n");
+ stk3310_set_state(data, STK3310_STATE_STANDBY);
+ }
+
+ if (client->irq <= 0)
+ client->irq = stk3310_gpio_probe(client);
+
+ if (client->irq >= 0) {
+ ret = devm_request_threaded_irq(&client->dev, client->irq,
+ stk3310_irq_handler,
+ stk3310_irq_event_handler,
+ IRQF_TRIGGER_FALLING |
+ IRQF_ONESHOT,
+ STK3310_EVENT, indio_dev);
+ if (ret < 0)
+ dev_err(&client->dev, "request irq %d failed\n",
+ client->irq);
+ }
+
+ return ret;
+}
+
+static int stk3310_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+
+ iio_device_unregister(indio_dev);
+ return stk3310_set_state(iio_priv(indio_dev), STK3310_STATE_STANDBY);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int stk3310_suspend(struct device *dev)
+{
+ struct stk3310_data *data;
+
+ data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
+
+ return stk3310_set_state(data, STK3310_STATE_STANDBY);
+}
+
+static int stk3310_resume(struct device *dev)
+{
+ int state = 0;
+ struct stk3310_data *data;
+
+ data = iio_priv(i2c_get_clientdata(to_i2c_client(dev)));
+ if (data->ps_enabled)
+ state |= STK3310_STATE_EN_PS;
+ if (data->als_enabled)
+ state |= STK3310_STATE_EN_ALS;
+
+ return stk3310_set_state(data, state);
+}
+
+static SIMPLE_DEV_PM_OPS(stk3310_pm_ops, stk3310_suspend, stk3310_resume);
+
+#define STK3310_PM_OPS (&stk3310_pm_ops)
+#else
+#define STK3310_PM_OPS NULL
+#endif
+
+static const struct i2c_device_id stk3310_i2c_id[] = {
+ {"STK3310", 0},
+ {"STK3311", 0},
+ {}
+};
+
+static const struct acpi_device_id stk3310_acpi_id[] = {
+ {"STK3310", 0},
+ {"STK3311", 0},
+ {}
+};
+
+MODULE_DEVICE_TABLE(acpi, stk3310_acpi_id);
+
+static struct i2c_driver stk3310_driver = {
+ .driver = {
+ .name = "stk3310",
+ .pm = STK3310_PM_OPS,
+ .acpi_match_table = ACPI_PTR(stk3310_acpi_id),
+ },
+ .probe = stk3310_probe,
+ .remove = stk3310_remove,
+ .id_table = stk3310_i2c_id,
+};
+
+module_i2c_driver(stk3310_driver);
+
+MODULE_AUTHOR("Tiberiu Breana <tiberiu.a.breana@intel.com>");
+MODULE_DESCRIPTION("STK3310 Ambient Light and Proximity Sensor driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/light/tsl2563.c b/drivers/iio/light/tsl2563.c
index 94daa9fc12478b..12731d6b89ecdf 100644
--- a/drivers/iio/light/tsl2563.c
+++ b/drivers/iio/light/tsl2563.c
@@ -240,7 +240,7 @@ static int tsl2563_read_id(struct tsl2563_chip *chip, u8 *id)
* convert between normalized values and HW values obtained using given
* timing and gain settings.
*/
-static int adc_shiftbits(u8 timing)
+static int tsl2563_adc_shiftbits(u8 timing)
{
int shift = 0;
@@ -263,9 +263,9 @@ static int adc_shiftbits(u8 timing)
}
/* Convert a HW ADC value to normalized scale. */
-static u32 normalize_adc(u16 adc, u8 timing)
+static u32 tsl2563_normalize_adc(u16 adc, u8 timing)
{
- return adc << adc_shiftbits(timing);
+ return adc << tsl2563_adc_shiftbits(timing);
}
static void tsl2563_wait_adc(struct tsl2563_chip *chip)
@@ -350,8 +350,8 @@ static int tsl2563_get_adc(struct tsl2563_chip *chip)
retry = tsl2563_adjust_gainlevel(chip, adc0);
}
- chip->data0 = normalize_adc(adc0, chip->gainlevel->gaintime);
- chip->data1 = normalize_adc(adc1, chip->gainlevel->gaintime);
+ chip->data0 = tsl2563_normalize_adc(adc0, chip->gainlevel->gaintime);
+ chip->data1 = tsl2563_normalize_adc(adc1, chip->gainlevel->gaintime);
if (!chip->int_enabled)
schedule_delayed_work(&chip->poweroff_work, 5 * HZ);
@@ -361,13 +361,13 @@ out:
return ret;
}
-static inline int calib_to_sysfs(u32 calib)
+static inline int tsl2563_calib_to_sysfs(u32 calib)
{
return (int) (((calib * CALIB_BASE_SYSFS) +
CALIB_FRAC_HALF) >> CALIB_FRAC_BITS);
}
-static inline u32 calib_from_sysfs(int value)
+static inline u32 tsl2563_calib_from_sysfs(int value)
{
return (((u32) value) << CALIB_FRAC_BITS) / CALIB_BASE_SYSFS;
}
@@ -426,7 +426,7 @@ static const struct tsl2563_lux_coeff lux_table[] = {
};
/* Convert normalized, scaled ADC values to lux. */
-static unsigned int adc_to_lux(u32 adc0, u32 adc1)
+static unsigned int tsl2563_adc_to_lux(u32 adc0, u32 adc1)
{
const struct tsl2563_lux_coeff *lp = lux_table;
unsigned long ratio, lux, ch0 = adc0, ch1 = adc1;
@@ -442,7 +442,7 @@ static unsigned int adc_to_lux(u32 adc0, u32 adc1)
}
/* Apply calibration coefficient to ADC count. */
-static u32 calib_adc(u32 adc, u32 calib)
+static u32 tsl2563_calib_adc(u32 adc, u32 calib)
{
unsigned long scaled = adc;
@@ -463,9 +463,9 @@ static int tsl2563_write_raw(struct iio_dev *indio_dev,
if (mask != IIO_CHAN_INFO_CALIBSCALE)
return -EINVAL;
if (chan->channel2 == IIO_MOD_LIGHT_BOTH)
- chip->calib0 = calib_from_sysfs(val);
+ chip->calib0 = tsl2563_calib_from_sysfs(val);
else if (chan->channel2 == IIO_MOD_LIGHT_IR)
- chip->calib1 = calib_from_sysfs(val);
+ chip->calib1 = tsl2563_calib_from_sysfs(val);
else
return -EINVAL;
@@ -491,11 +491,11 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev,
ret = tsl2563_get_adc(chip);
if (ret)
goto error_ret;
- calib0 = calib_adc(chip->data0, chip->calib0) *
+ calib0 = tsl2563_calib_adc(chip->data0, chip->calib0) *
chip->cover_comp_gain;
- calib1 = calib_adc(chip->data1, chip->calib1) *
+ calib1 = tsl2563_calib_adc(chip->data1, chip->calib1) *
chip->cover_comp_gain;
- *val = adc_to_lux(calib0, calib1);
+ *val = tsl2563_adc_to_lux(calib0, calib1);
ret = IIO_VAL_INT;
break;
case IIO_INTENSITY:
@@ -515,9 +515,9 @@ static int tsl2563_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_CALIBSCALE:
if (chan->channel2 == IIO_MOD_LIGHT_BOTH)
- *val = calib_to_sysfs(chip->calib0);
+ *val = tsl2563_calib_to_sysfs(chip->calib0);
else
- *val = calib_to_sysfs(chip->calib1);
+ *val = tsl2563_calib_to_sysfs(chip->calib1);
ret = IIO_VAL_INT;
break;
default:
@@ -750,8 +750,8 @@ static int tsl2563_probe(struct i2c_client *client,
chip->high_thres = 0xffff;
chip->gainlevel = tsl2563_gainlevel_table;
chip->intr = TSL2563_INT_PERSIST(4);
- chip->calib0 = calib_from_sysfs(CALIB_BASE_SYSFS);
- chip->calib1 = calib_from_sysfs(CALIB_BASE_SYSFS);
+ chip->calib0 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
+ chip->calib1 = tsl2563_calib_from_sysfs(CALIB_BASE_SYSFS);
if (pdata)
chip->cover_comp_gain = pdata->cover_comp_gain;
diff --git a/drivers/iio/light/tsl4531.c b/drivers/iio/light/tsl4531.c
index 0763b863257387..63c26e2d5d9722 100644
--- a/drivers/iio/light/tsl4531.c
+++ b/drivers/iio/light/tsl4531.c
@@ -24,12 +24,12 @@
#define TSL4531_DRV_NAME "tsl4531"
-#define TCS3472_COMMAND BIT(7)
+#define TSL4531_COMMAND BIT(7)
-#define TSL4531_CONTROL (TCS3472_COMMAND | 0x00)
-#define TSL4531_CONFIG (TCS3472_COMMAND | 0x01)
-#define TSL4531_DATA (TCS3472_COMMAND | 0x04)
-#define TSL4531_ID (TCS3472_COMMAND | 0x0a)
+#define TSL4531_CONTROL (TSL4531_COMMAND | 0x00)
+#define TSL4531_CONFIG (TSL4531_COMMAND | 0x01)
+#define TSL4531_DATA (TSL4531_COMMAND | 0x04)
+#define TSL4531_ID (TSL4531_COMMAND | 0x0a)
/* operating modes in control register */
#define TSL4531_MODE_POWERDOWN 0x00
diff --git a/drivers/iio/magnetometer/Kconfig b/drivers/iio/magnetometer/Kconfig
index a5d6de72c523ba..dcadfc4f06619a 100644
--- a/drivers/iio/magnetometer/Kconfig
+++ b/drivers/iio/magnetometer/Kconfig
@@ -8,7 +8,7 @@ menu "Magnetometer sensors"
config AK8975
tristate "Asahi Kasei AK 3-Axis Magnetometer"
depends on I2C
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
help
Say yes here to build support for Asahi Kasei AK8975, AK8963,
AK09911 or AK09912 3-Axis Magnetometer.
@@ -19,7 +19,7 @@ config AK8975
config AK09911
tristate "Asahi Kasei AK09911 3-axis Compass"
depends on I2C
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
select AK8975
help
Deprecated: AK09911 is now supported by AK8975 driver.
@@ -47,6 +47,17 @@ config HID_SENSOR_MAGNETOMETER_3D
Say yes here to build support for the HID SENSOR
Magnetometer 3D.
+config MMC35240
+ tristate "MEMSIC MMC35240 3-axis magnetic sensor"
+ select REGMAP_I2C
+ depends on I2C
+ help
+ Say yes here to build support for the MEMSIC MMC35240 3-axis
+ magnetic sensor.
+
+ To compile this driver as a module, choose M here: the module
+ will be called mmc35240.
+
config IIO_ST_MAGN_3AXIS
tristate "STMicroelectronics magnetometers 3-Axis Driver"
depends on (I2C || SPI_MASTER) && SYSFS
@@ -76,4 +87,18 @@ config IIO_ST_MAGN_SPI_3AXIS
depends on IIO_ST_MAGN_3AXIS
depends on IIO_ST_SENSORS_SPI
+config BMC150_MAGN
+ tristate "Bosch BMC150 Magnetometer Driver"
+ depends on I2C
+ select IIO_BUFFER
+ select IIO_TRIGGERED_BUFFER
+ help
+ Say yes here to build support for the BMC150 magnetometer.
+
+ Currently this only supports the device via an i2c interface.
+
+ This is a combo module with both accelerometer and magnetometer.
+ This driver is only implementing magnetometer part, which has
+ its own address and register map.
+
endmenu
diff --git a/drivers/iio/magnetometer/Makefile b/drivers/iio/magnetometer/Makefile
index 0f5d3c98579924..33b1d4d54ee70a 100644
--- a/drivers/iio/magnetometer/Makefile
+++ b/drivers/iio/magnetometer/Makefile
@@ -6,6 +6,7 @@
obj-$(CONFIG_AK8975) += ak8975.o
obj-$(CONFIG_MAG3110) += mag3110.o
obj-$(CONFIG_HID_SENSOR_MAGNETOMETER_3D) += hid-sensor-magn-3d.o
+obj-$(CONFIG_MMC35240) += mmc35240.o
obj-$(CONFIG_IIO_ST_MAGN_3AXIS) += st_magn.o
st_magn-y := st_magn_core.o
@@ -13,3 +14,5 @@ st_magn-$(CONFIG_IIO_BUFFER) += st_magn_buffer.o
obj-$(CONFIG_IIO_ST_MAGN_I2C_3AXIS) += st_magn_i2c.o
obj-$(CONFIG_IIO_ST_MAGN_SPI_3AXIS) += st_magn_spi.o
+
+obj-$(CONFIG_BMC150_MAGN) += bmc150_magn.o
diff --git a/drivers/iio/magnetometer/bmc150_magn.c b/drivers/iio/magnetometer/bmc150_magn.c
new file mode 100644
index 00000000000000..d4c1788699911e
--- /dev/null
+++ b/drivers/iio/magnetometer/bmc150_magn.c
@@ -0,0 +1,1109 @@
+/*
+ * Bosch BMC150 three-axis magnetic field sensor driver
+ *
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This code is based on bmm050_api.c authored by contact@bosch.sensortec.com:
+ *
+ * (C) Copyright 2011~2014 Bosch Sensortec GmbH All Rights Reserved
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ */
+
+#include <linux/module.h>
+#include <linux/i2c.h>
+#include <linux/interrupt.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/acpi.h>
+#include <linux/gpio/consumer.h>
+#include <linux/pm.h>
+#include <linux/pm_runtime.h>
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+#include <linux/iio/buffer.h>
+#include <linux/iio/events.h>
+#include <linux/iio/trigger.h>
+#include <linux/iio/trigger_consumer.h>
+#include <linux/iio/triggered_buffer.h>
+#include <linux/regmap.h>
+
+#define BMC150_MAGN_DRV_NAME "bmc150_magn"
+#define BMC150_MAGN_IRQ_NAME "bmc150_magn_event"
+#define BMC150_MAGN_GPIO_INT "interrupt"
+
+#define BMC150_MAGN_REG_CHIP_ID 0x40
+#define BMC150_MAGN_CHIP_ID_VAL 0x32
+
+#define BMC150_MAGN_REG_X_L 0x42
+#define BMC150_MAGN_REG_X_M 0x43
+#define BMC150_MAGN_REG_Y_L 0x44
+#define BMC150_MAGN_REG_Y_M 0x45
+#define BMC150_MAGN_SHIFT_XY_L 3
+#define BMC150_MAGN_REG_Z_L 0x46
+#define BMC150_MAGN_REG_Z_M 0x47
+#define BMC150_MAGN_SHIFT_Z_L 1
+#define BMC150_MAGN_REG_RHALL_L 0x48
+#define BMC150_MAGN_REG_RHALL_M 0x49
+#define BMC150_MAGN_SHIFT_RHALL_L 2
+
+#define BMC150_MAGN_REG_INT_STATUS 0x4A
+
+#define BMC150_MAGN_REG_POWER 0x4B
+#define BMC150_MAGN_MASK_POWER_CTL BIT(0)
+
+#define BMC150_MAGN_REG_OPMODE_ODR 0x4C
+#define BMC150_MAGN_MASK_OPMODE GENMASK(2, 1)
+#define BMC150_MAGN_SHIFT_OPMODE 1
+#define BMC150_MAGN_MODE_NORMAL 0x00
+#define BMC150_MAGN_MODE_FORCED 0x01
+#define BMC150_MAGN_MODE_SLEEP 0x03
+#define BMC150_MAGN_MASK_ODR GENMASK(5, 3)
+#define BMC150_MAGN_SHIFT_ODR 3
+
+#define BMC150_MAGN_REG_INT 0x4D
+
+#define BMC150_MAGN_REG_INT_DRDY 0x4E
+#define BMC150_MAGN_MASK_DRDY_EN BIT(7)
+#define BMC150_MAGN_SHIFT_DRDY_EN 7
+#define BMC150_MAGN_MASK_DRDY_INT3 BIT(6)
+#define BMC150_MAGN_MASK_DRDY_Z_EN BIT(5)
+#define BMC150_MAGN_MASK_DRDY_Y_EN BIT(4)
+#define BMC150_MAGN_MASK_DRDY_X_EN BIT(3)
+#define BMC150_MAGN_MASK_DRDY_DR_POLARITY BIT(2)
+#define BMC150_MAGN_MASK_DRDY_LATCHING BIT(1)
+#define BMC150_MAGN_MASK_DRDY_INT3_POLARITY BIT(0)
+
+#define BMC150_MAGN_REG_LOW_THRESH 0x4F
+#define BMC150_MAGN_REG_HIGH_THRESH 0x50
+#define BMC150_MAGN_REG_REP_XY 0x51
+#define BMC150_MAGN_REG_REP_Z 0x52
+
+#define BMC150_MAGN_REG_TRIM_START 0x5D
+#define BMC150_MAGN_REG_TRIM_END 0x71
+
+#define BMC150_MAGN_XY_OVERFLOW_VAL -4096
+#define BMC150_MAGN_Z_OVERFLOW_VAL -16384
+
+/* Time from SUSPEND to SLEEP */
+#define BMC150_MAGN_START_UP_TIME_MS 3
+
+#define BMC150_MAGN_AUTO_SUSPEND_DELAY_MS 2000
+
+#define BMC150_MAGN_REGVAL_TO_REPXY(regval) (((regval) * 2) + 1)
+#define BMC150_MAGN_REGVAL_TO_REPZ(regval) ((regval) + 1)
+#define BMC150_MAGN_REPXY_TO_REGVAL(rep) (((rep) - 1) / 2)
+#define BMC150_MAGN_REPZ_TO_REGVAL(rep) ((rep) - 1)
+
+enum bmc150_magn_axis {
+ AXIS_X,
+ AXIS_Y,
+ AXIS_Z,
+ RHALL,
+ AXIS_XYZ_MAX = RHALL,
+ AXIS_XYZR_MAX,
+};
+
+enum bmc150_magn_power_modes {
+ BMC150_MAGN_POWER_MODE_SUSPEND,
+ BMC150_MAGN_POWER_MODE_SLEEP,
+ BMC150_MAGN_POWER_MODE_NORMAL,
+};
+
+struct bmc150_magn_trim_regs {
+ s8 x1;
+ s8 y1;
+ __le16 reserved1;
+ u8 reserved2;
+ __le16 z4;
+ s8 x2;
+ s8 y2;
+ __le16 reserved3;
+ __le16 z2;
+ __le16 z1;
+ __le16 xyz1;
+ __le16 z3;
+ s8 xy2;
+ u8 xy1;
+} __packed;
+
+struct bmc150_magn_data {
+ struct i2c_client *client;
+ /*
+ * 1. Protect this structure.
+ * 2. Serialize sequences that power on/off the device and access HW.
+ */
+ struct mutex mutex;
+ struct regmap *regmap;
+ /* 4 x 32 bits for x, y z, 4 bytes align, 64 bits timestamp */
+ s32 buffer[6];
+ struct iio_trigger *dready_trig;
+ bool dready_trigger_on;
+ int max_odr;
+};
+
+static const struct {
+ int freq;
+ u8 reg_val;
+} bmc150_magn_samp_freq_table[] = { {2, 0x01},
+ {6, 0x02},
+ {8, 0x03},
+ {10, 0x00},
+ {15, 0x04},
+ {20, 0x05},
+ {25, 0x06},
+ {30, 0x07} };
+
+enum bmc150_magn_presets {
+ LOW_POWER_PRESET,
+ REGULAR_PRESET,
+ ENHANCED_REGULAR_PRESET,
+ HIGH_ACCURACY_PRESET
+};
+
+static const struct bmc150_magn_preset {
+ u8 rep_xy;
+ u8 rep_z;
+ u8 odr;
+} bmc150_magn_presets_table[] = {
+ [LOW_POWER_PRESET] = {3, 3, 10},
+ [REGULAR_PRESET] = {9, 15, 10},
+ [ENHANCED_REGULAR_PRESET] = {15, 27, 10},
+ [HIGH_ACCURACY_PRESET] = {47, 83, 20},
+};
+
+#define BMC150_MAGN_DEFAULT_PRESET REGULAR_PRESET
+
+static bool bmc150_magn_is_writeable_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case BMC150_MAGN_REG_POWER:
+ case BMC150_MAGN_REG_OPMODE_ODR:
+ case BMC150_MAGN_REG_INT:
+ case BMC150_MAGN_REG_INT_DRDY:
+ case BMC150_MAGN_REG_LOW_THRESH:
+ case BMC150_MAGN_REG_HIGH_THRESH:
+ case BMC150_MAGN_REG_REP_XY:
+ case BMC150_MAGN_REG_REP_Z:
+ return true;
+ default:
+ return false;
+ };
+}
+
+static bool bmc150_magn_is_volatile_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case BMC150_MAGN_REG_X_L:
+ case BMC150_MAGN_REG_X_M:
+ case BMC150_MAGN_REG_Y_L:
+ case BMC150_MAGN_REG_Y_M:
+ case BMC150_MAGN_REG_Z_L:
+ case BMC150_MAGN_REG_Z_M:
+ case BMC150_MAGN_REG_RHALL_L:
+ case BMC150_MAGN_REG_RHALL_M:
+ case BMC150_MAGN_REG_INT_STATUS:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static const struct regmap_config bmc150_magn_regmap_config = {
+ .reg_bits = 8,
+ .val_bits = 8,
+
+ .max_register = BMC150_MAGN_REG_TRIM_END,
+ .cache_type = REGCACHE_RBTREE,
+
+ .writeable_reg = bmc150_magn_is_writeable_reg,
+ .volatile_reg = bmc150_magn_is_volatile_reg,
+};
+
+static int bmc150_magn_set_power_mode(struct bmc150_magn_data *data,
+ enum bmc150_magn_power_modes mode,
+ bool state)
+{
+ int ret;
+
+ switch (mode) {
+ case BMC150_MAGN_POWER_MODE_SUSPEND:
+ ret = regmap_update_bits(data->regmap, BMC150_MAGN_REG_POWER,
+ BMC150_MAGN_MASK_POWER_CTL, !state);
+ if (ret < 0)
+ return ret;
+ usleep_range(BMC150_MAGN_START_UP_TIME_MS * 1000, 20000);
+ return 0;
+ case BMC150_MAGN_POWER_MODE_SLEEP:
+ return regmap_update_bits(data->regmap,
+ BMC150_MAGN_REG_OPMODE_ODR,
+ BMC150_MAGN_MASK_OPMODE,
+ BMC150_MAGN_MODE_SLEEP <<
+ BMC150_MAGN_SHIFT_OPMODE);
+ case BMC150_MAGN_POWER_MODE_NORMAL:
+ return regmap_update_bits(data->regmap,
+ BMC150_MAGN_REG_OPMODE_ODR,
+ BMC150_MAGN_MASK_OPMODE,
+ BMC150_MAGN_MODE_NORMAL <<
+ BMC150_MAGN_SHIFT_OPMODE);
+ }
+
+ return -EINVAL;
+}
+
+static int bmc150_magn_set_power_state(struct bmc150_magn_data *data, bool on)
+{
+#ifdef CONFIG_PM
+ int ret;
+
+ if (on) {
+ ret = pm_runtime_get_sync(&data->client->dev);
+ } else {
+ pm_runtime_mark_last_busy(&data->client->dev);
+ ret = pm_runtime_put_autosuspend(&data->client->dev);
+ }
+
+ if (ret < 0) {
+ dev_err(&data->client->dev,
+ "failed to change power state to %d\n", on);
+ if (on)
+ pm_runtime_put_noidle(&data->client->dev);
+
+ return ret;
+ }
+#endif
+
+ return 0;
+}
+
+static int bmc150_magn_get_odr(struct bmc150_magn_data *data, int *val)
+{
+ int ret, reg_val;
+ u8 i, odr_val;
+
+ ret = regmap_read(data->regmap, BMC150_MAGN_REG_OPMODE_ODR, &reg_val);
+ if (ret < 0)
+ return ret;
+ odr_val = (reg_val & BMC150_MAGN_MASK_ODR) >> BMC150_MAGN_SHIFT_ODR;
+
+ for (i = 0; i < ARRAY_SIZE(bmc150_magn_samp_freq_table); i++)
+ if (bmc150_magn_samp_freq_table[i].reg_val == odr_val) {
+ *val = bmc150_magn_samp_freq_table[i].freq;
+ return 0;
+ }
+
+ return -EINVAL;
+}
+
+static int bmc150_magn_set_odr(struct bmc150_magn_data *data, int val)
+{
+ int ret;
+ u8 i;
+
+ for (i = 0; i < ARRAY_SIZE(bmc150_magn_samp_freq_table); i++) {
+ if (bmc150_magn_samp_freq_table[i].freq == val) {
+ ret = regmap_update_bits(data->regmap,
+ BMC150_MAGN_REG_OPMODE_ODR,
+ BMC150_MAGN_MASK_ODR,
+ bmc150_magn_samp_freq_table[i].
+ reg_val <<
+ BMC150_MAGN_SHIFT_ODR);
+ if (ret < 0)
+ return ret;
+ return 0;
+ }
+ }
+
+ return -EINVAL;
+}
+
+static int bmc150_magn_set_max_odr(struct bmc150_magn_data *data, int rep_xy,
+ int rep_z, int odr)
+{
+ int ret, reg_val, max_odr;
+
+ if (rep_xy <= 0) {
+ ret = regmap_read(data->regmap, BMC150_MAGN_REG_REP_XY,
+ &reg_val);
+ if (ret < 0)
+ return ret;
+ rep_xy = BMC150_MAGN_REGVAL_TO_REPXY(reg_val);
+ }
+ if (rep_z <= 0) {
+ ret = regmap_read(data->regmap, BMC150_MAGN_REG_REP_Z,
+ &reg_val);
+ if (ret < 0)
+ return ret;
+ rep_z = BMC150_MAGN_REGVAL_TO_REPZ(reg_val);
+ }
+ if (odr <= 0) {
+ ret = bmc150_magn_get_odr(data, &odr);
+ if (ret < 0)
+ return ret;
+ }
+ /* the maximum selectable read-out frequency from datasheet */
+ max_odr = 1000000 / (145 * rep_xy + 500 * rep_z + 980);
+ if (odr > max_odr) {
+ dev_err(&data->client->dev,
+ "Can't set oversampling with sampling freq %d\n",
+ odr);
+ return -EINVAL;
+ }
+ data->max_odr = max_odr;
+
+ return 0;
+}
+
+static s32 bmc150_magn_compensate_x(struct bmc150_magn_trim_regs *tregs, s16 x,
+ u16 rhall)
+{
+ s16 val;
+ u16 xyz1 = le16_to_cpu(tregs->xyz1);
+
+ if (x == BMC150_MAGN_XY_OVERFLOW_VAL)
+ return S32_MIN;
+
+ if (!rhall)
+ rhall = xyz1;
+
+ val = ((s16)(((u16)((((s32)xyz1) << 14) / rhall)) - ((u16)0x4000)));
+ val = ((s16)((((s32)x) * ((((((((s32)tregs->xy2) * ((((s32)val) *
+ ((s32)val)) >> 7)) + (((s32)val) *
+ ((s32)(((s16)tregs->xy1) << 7)))) >> 9) + ((s32)0x100000)) *
+ ((s32)(((s16)tregs->x2) + ((s16)0xA0)))) >> 12)) >> 13)) +
+ (((s16)tregs->x1) << 3);
+
+ return (s32)val;
+}
+
+static s32 bmc150_magn_compensate_y(struct bmc150_magn_trim_regs *tregs, s16 y,
+ u16 rhall)
+{
+ s16 val;
+ u16 xyz1 = le16_to_cpu(tregs->xyz1);
+
+ if (y == BMC150_MAGN_XY_OVERFLOW_VAL)
+ return S32_MIN;
+
+ if (!rhall)
+ rhall = xyz1;
+
+ val = ((s16)(((u16)((((s32)xyz1) << 14) / rhall)) - ((u16)0x4000)));
+ val = ((s16)((((s32)y) * ((((((((s32)tregs->xy2) * ((((s32)val) *
+ ((s32)val)) >> 7)) + (((s32)val) *
+ ((s32)(((s16)tregs->xy1) << 7)))) >> 9) + ((s32)0x100000)) *
+ ((s32)(((s16)tregs->y2) + ((s16)0xA0)))) >> 12)) >> 13)) +
+ (((s16)tregs->y1) << 3);
+
+ return (s32)val;
+}
+
+static s32 bmc150_magn_compensate_z(struct bmc150_magn_trim_regs *tregs, s16 z,
+ u16 rhall)
+{
+ s32 val;
+ u16 xyz1 = le16_to_cpu(tregs->xyz1);
+ u16 z1 = le16_to_cpu(tregs->z1);
+ s16 z2 = le16_to_cpu(tregs->z2);
+ s16 z3 = le16_to_cpu(tregs->z3);
+ s16 z4 = le16_to_cpu(tregs->z4);
+
+ if (z == BMC150_MAGN_Z_OVERFLOW_VAL)
+ return S32_MIN;
+
+ val = (((((s32)(z - z4)) << 15) - ((((s32)z3) * ((s32)(((s16)rhall) -
+ ((s16)xyz1)))) >> 2)) / (z2 + ((s16)(((((s32)z1) *
+ ((((s16)rhall) << 1))) + (1 << 15)) >> 16))));
+
+ return val;
+}
+
+static int bmc150_magn_read_xyz(struct bmc150_magn_data *data, s32 *buffer)
+{
+ int ret;
+ __le16 values[AXIS_XYZR_MAX];
+ s16 raw_x, raw_y, raw_z;
+ u16 rhall;
+ struct bmc150_magn_trim_regs tregs;
+
+ ret = regmap_bulk_read(data->regmap, BMC150_MAGN_REG_X_L,
+ values, sizeof(values));
+ if (ret < 0)
+ return ret;
+
+ raw_x = (s16)le16_to_cpu(values[AXIS_X]) >> BMC150_MAGN_SHIFT_XY_L;
+ raw_y = (s16)le16_to_cpu(values[AXIS_Y]) >> BMC150_MAGN_SHIFT_XY_L;
+ raw_z = (s16)le16_to_cpu(values[AXIS_Z]) >> BMC150_MAGN_SHIFT_Z_L;
+ rhall = le16_to_cpu(values[RHALL]) >> BMC150_MAGN_SHIFT_RHALL_L;
+
+ ret = regmap_bulk_read(data->regmap, BMC150_MAGN_REG_TRIM_START,
+ &tregs, sizeof(tregs));
+ if (ret < 0)
+ return ret;
+
+ buffer[AXIS_X] = bmc150_magn_compensate_x(&tregs, raw_x, rhall);
+ buffer[AXIS_Y] = bmc150_magn_compensate_y(&tregs, raw_y, rhall);
+ buffer[AXIS_Z] = bmc150_magn_compensate_z(&tregs, raw_z, rhall);
+
+ return 0;
+}
+
+static int bmc150_magn_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int *val, int *val2, long mask)
+{
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ int ret, tmp;
+ s32 values[AXIS_XYZ_MAX];
+
+ switch (mask) {
+ case IIO_CHAN_INFO_RAW:
+ if (iio_buffer_enabled(indio_dev))
+ return -EBUSY;
+ mutex_lock(&data->mutex);
+
+ ret = bmc150_magn_set_power_state(data, true);
+ if (ret < 0) {
+ mutex_unlock(&data->mutex);
+ return ret;
+ }
+
+ ret = bmc150_magn_read_xyz(data, values);
+ if (ret < 0) {
+ bmc150_magn_set_power_state(data, false);
+ mutex_unlock(&data->mutex);
+ return ret;
+ }
+ *val = values[chan->scan_index];
+
+ ret = bmc150_magn_set_power_state(data, false);
+ if (ret < 0) {
+ mutex_unlock(&data->mutex);
+ return ret;
+ }
+
+ mutex_unlock(&data->mutex);
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_SCALE:
+ /*
+ * The API/driver performs an off-chip temperature
+ * compensation and outputs x/y/z magnetic field data in
+ * 16 LSB/uT to the upper application layer.
+ */
+ *val = 0;
+ *val2 = 625;
+ return IIO_VAL_INT_PLUS_MICRO;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ ret = bmc150_magn_get_odr(data, val);
+ if (ret < 0)
+ return ret;
+ return IIO_VAL_INT;
+ case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
+ switch (chan->channel2) {
+ case IIO_MOD_X:
+ case IIO_MOD_Y:
+ ret = regmap_read(data->regmap, BMC150_MAGN_REG_REP_XY,
+ &tmp);
+ if (ret < 0)
+ return ret;
+ *val = BMC150_MAGN_REGVAL_TO_REPXY(tmp);
+ return IIO_VAL_INT;
+ case IIO_MOD_Z:
+ ret = regmap_read(data->regmap, BMC150_MAGN_REG_REP_Z,
+ &tmp);
+ if (ret < 0)
+ return ret;
+ *val = BMC150_MAGN_REGVAL_TO_REPZ(tmp);
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+ default:
+ return -EINVAL;
+ }
+}
+
+static int bmc150_magn_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan,
+ int val, int val2, long mask)
+{
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ int ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ if (val > data->max_odr)
+ return -EINVAL;
+ mutex_lock(&data->mutex);
+ ret = bmc150_magn_set_odr(data, val);
+ mutex_unlock(&data->mutex);
+ return ret;
+ case IIO_CHAN_INFO_OVERSAMPLING_RATIO:
+ switch (chan->channel2) {
+ case IIO_MOD_X:
+ case IIO_MOD_Y:
+ if (val < 1 || val > 511)
+ return -EINVAL;
+ mutex_lock(&data->mutex);
+ ret = bmc150_magn_set_max_odr(data, val, 0, 0);
+ if (ret < 0) {
+ mutex_unlock(&data->mutex);
+ return ret;
+ }
+ ret = regmap_update_bits(data->regmap,
+ BMC150_MAGN_REG_REP_XY,
+ 0xFF,
+ BMC150_MAGN_REPXY_TO_REGVAL
+ (val));
+ mutex_unlock(&data->mutex);
+ return ret;
+ case IIO_MOD_Z:
+ if (val < 1 || val > 256)
+ return -EINVAL;
+ mutex_lock(&data->mutex);
+ ret = bmc150_magn_set_max_odr(data, 0, val, 0);
+ if (ret < 0) {
+ mutex_unlock(&data->mutex);
+ return ret;
+ }
+ ret = regmap_update_bits(data->regmap,
+ BMC150_MAGN_REG_REP_Z,
+ 0xFF,
+ BMC150_MAGN_REPZ_TO_REGVAL
+ (val));
+ mutex_unlock(&data->mutex);
+ return ret;
+ default:
+ return -EINVAL;
+ }
+ default:
+ return -EINVAL;
+ }
+}
+
+static int bmc150_magn_validate_trigger(struct iio_dev *indio_dev,
+ struct iio_trigger *trig)
+{
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+
+ if (data->dready_trig != trig)
+ return -EINVAL;
+
+ return 0;
+}
+
+static ssize_t bmc150_magn_show_samp_freq_avail(struct device *dev,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct iio_dev *indio_dev = dev_to_iio_dev(dev);
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ size_t len = 0;
+ u8 i;
+
+ for (i = 0; i < ARRAY_SIZE(bmc150_magn_samp_freq_table); i++) {
+ if (bmc150_magn_samp_freq_table[i].freq > data->max_odr)
+ break;
+ len += scnprintf(buf + len, PAGE_SIZE - len, "%d ",
+ bmc150_magn_samp_freq_table[i].freq);
+ }
+ /* replace last space with a newline */
+ buf[len - 1] = '\n';
+
+ return len;
+}
+
+static IIO_DEV_ATTR_SAMP_FREQ_AVAIL(bmc150_magn_show_samp_freq_avail);
+
+static struct attribute *bmc150_magn_attributes[] = {
+ &iio_dev_attr_sampling_frequency_available.dev_attr.attr,
+ NULL,
+};
+
+static const struct attribute_group bmc150_magn_attrs_group = {
+ .attrs = bmc150_magn_attributes,
+};
+
+#define BMC150_MAGN_CHANNEL(_axis) { \
+ .type = IIO_MAGN, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_##_axis, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | \
+ BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ) | \
+ BIT(IIO_CHAN_INFO_SCALE), \
+ .scan_index = AXIS_##_axis, \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = 32, \
+ .storagebits = 32, \
+ .endianness = IIO_LE \
+ }, \
+}
+
+static const struct iio_chan_spec bmc150_magn_channels[] = {
+ BMC150_MAGN_CHANNEL(X),
+ BMC150_MAGN_CHANNEL(Y),
+ BMC150_MAGN_CHANNEL(Z),
+ IIO_CHAN_SOFT_TIMESTAMP(3),
+};
+
+static const struct iio_info bmc150_magn_info = {
+ .attrs = &bmc150_magn_attrs_group,
+ .read_raw = bmc150_magn_read_raw,
+ .write_raw = bmc150_magn_write_raw,
+ .validate_trigger = bmc150_magn_validate_trigger,
+ .driver_module = THIS_MODULE,
+};
+
+static const unsigned long bmc150_magn_scan_masks[] = {0x07, 0};
+
+static irqreturn_t bmc150_magn_trigger_handler(int irq, void *p)
+{
+ struct iio_poll_func *pf = p;
+ struct iio_dev *indio_dev = pf->indio_dev;
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ int ret;
+
+ mutex_lock(&data->mutex);
+ ret = bmc150_magn_read_xyz(data, data->buffer);
+ mutex_unlock(&data->mutex);
+ if (ret < 0)
+ goto err;
+
+ iio_push_to_buffers_with_timestamp(indio_dev, data->buffer,
+ pf->timestamp);
+
+err:
+ iio_trigger_notify_done(data->dready_trig);
+
+ return IRQ_HANDLED;
+}
+
+static int bmc150_magn_init(struct bmc150_magn_data *data)
+{
+ int ret, chip_id;
+ struct bmc150_magn_preset preset;
+
+ ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND,
+ false);
+ if (ret < 0) {
+ dev_err(&data->client->dev,
+ "Failed to bring up device from suspend mode\n");
+ return ret;
+ }
+
+ ret = regmap_read(data->regmap, BMC150_MAGN_REG_CHIP_ID, &chip_id);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "Failed reading chip id\n");
+ goto err_poweroff;
+ }
+ if (chip_id != BMC150_MAGN_CHIP_ID_VAL) {
+ dev_err(&data->client->dev, "Invalid chip id 0x%x\n", ret);
+ ret = -ENODEV;
+ goto err_poweroff;
+ }
+ dev_dbg(&data->client->dev, "Chip id %x\n", ret);
+
+ preset = bmc150_magn_presets_table[BMC150_MAGN_DEFAULT_PRESET];
+ ret = bmc150_magn_set_odr(data, preset.odr);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "Failed to set ODR to %d\n",
+ preset.odr);
+ goto err_poweroff;
+ }
+
+ ret = regmap_write(data->regmap, BMC150_MAGN_REG_REP_XY,
+ BMC150_MAGN_REPXY_TO_REGVAL(preset.rep_xy));
+ if (ret < 0) {
+ dev_err(&data->client->dev, "Failed to set REP XY to %d\n",
+ preset.rep_xy);
+ goto err_poweroff;
+ }
+
+ ret = regmap_write(data->regmap, BMC150_MAGN_REG_REP_Z,
+ BMC150_MAGN_REPZ_TO_REGVAL(preset.rep_z));
+ if (ret < 0) {
+ dev_err(&data->client->dev, "Failed to set REP Z to %d\n",
+ preset.rep_z);
+ goto err_poweroff;
+ }
+
+ ret = bmc150_magn_set_max_odr(data, preset.rep_xy, preset.rep_z,
+ preset.odr);
+ if (ret < 0)
+ goto err_poweroff;
+
+ ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL,
+ true);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "Failed to power on device\n");
+ goto err_poweroff;
+ }
+
+ return 0;
+
+err_poweroff:
+ bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true);
+ return ret;
+}
+
+static int bmc150_magn_reset_intr(struct bmc150_magn_data *data)
+{
+ int tmp;
+
+ /*
+ * Data Ready (DRDY) is always cleared after
+ * readout of data registers ends.
+ */
+ return regmap_read(data->regmap, BMC150_MAGN_REG_X_L, &tmp);
+}
+
+static int bmc150_magn_trig_try_reen(struct iio_trigger *trig)
+{
+ struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ int ret;
+
+ if (!data->dready_trigger_on)
+ return 0;
+
+ mutex_lock(&data->mutex);
+ ret = bmc150_magn_reset_intr(data);
+ mutex_unlock(&data->mutex);
+
+ return ret;
+}
+
+static int bmc150_magn_data_rdy_trigger_set_state(struct iio_trigger *trig,
+ bool state)
+{
+ struct iio_dev *indio_dev = iio_trigger_get_drvdata(trig);
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ int ret = 0;
+
+ mutex_lock(&data->mutex);
+ if (state == data->dready_trigger_on)
+ goto err_unlock;
+
+ ret = bmc150_magn_set_power_state(data, state);
+ if (ret < 0)
+ goto err_unlock;
+
+ ret = regmap_update_bits(data->regmap, BMC150_MAGN_REG_INT_DRDY,
+ BMC150_MAGN_MASK_DRDY_EN,
+ state << BMC150_MAGN_SHIFT_DRDY_EN);
+ if (ret < 0)
+ goto err_poweroff;
+
+ data->dready_trigger_on = state;
+
+ if (state) {
+ ret = bmc150_magn_reset_intr(data);
+ if (ret < 0)
+ goto err_poweroff;
+ }
+ mutex_unlock(&data->mutex);
+
+ return 0;
+
+err_poweroff:
+ bmc150_magn_set_power_state(data, false);
+err_unlock:
+ mutex_unlock(&data->mutex);
+ return ret;
+}
+
+static const struct iio_trigger_ops bmc150_magn_trigger_ops = {
+ .set_trigger_state = bmc150_magn_data_rdy_trigger_set_state,
+ .try_reenable = bmc150_magn_trig_try_reen,
+ .owner = THIS_MODULE,
+};
+
+static int bmc150_magn_gpio_probe(struct i2c_client *client)
+{
+ struct device *dev;
+ struct gpio_desc *gpio;
+ int ret;
+
+ if (!client)
+ return -EINVAL;
+
+ dev = &client->dev;
+
+ /* data ready GPIO interrupt pin */
+ gpio = devm_gpiod_get_index(dev, BMC150_MAGN_GPIO_INT, 0);
+ if (IS_ERR(gpio)) {
+ dev_err(dev, "ACPI GPIO get index failed\n");
+ return PTR_ERR(gpio);
+ }
+
+ ret = gpiod_direction_input(gpio);
+ if (ret)
+ return ret;
+
+ ret = gpiod_to_irq(gpio);
+
+ dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
+
+ return ret;
+}
+
+static const char *bmc150_magn_match_acpi_device(struct device *dev)
+{
+ const struct acpi_device_id *id;
+
+ id = acpi_match_device(dev->driver->acpi_match_table, dev);
+ if (!id)
+ return NULL;
+
+ return dev_name(dev);
+}
+
+static int bmc150_magn_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct bmc150_magn_data *data;
+ struct iio_dev *indio_dev;
+ const char *name = NULL;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ data = iio_priv(indio_dev);
+ i2c_set_clientdata(client, indio_dev);
+ data->client = client;
+
+ if (id)
+ name = id->name;
+ else if (ACPI_HANDLE(&client->dev))
+ name = bmc150_magn_match_acpi_device(&client->dev);
+ else
+ return -ENOSYS;
+
+ mutex_init(&data->mutex);
+ data->regmap = devm_regmap_init_i2c(client, &bmc150_magn_regmap_config);
+ if (IS_ERR(data->regmap)) {
+ dev_err(&client->dev, "Failed to allocate register map\n");
+ return PTR_ERR(data->regmap);
+ }
+
+ ret = bmc150_magn_init(data);
+ if (ret < 0)
+ return ret;
+
+ indio_dev->dev.parent = &client->dev;
+ indio_dev->channels = bmc150_magn_channels;
+ indio_dev->num_channels = ARRAY_SIZE(bmc150_magn_channels);
+ indio_dev->available_scan_masks = bmc150_magn_scan_masks;
+ indio_dev->name = name;
+ indio_dev->modes = INDIO_DIRECT_MODE;
+ indio_dev->info = &bmc150_magn_info;
+
+ if (client->irq <= 0)
+ client->irq = bmc150_magn_gpio_probe(client);
+
+ if (client->irq > 0) {
+ data->dready_trig = devm_iio_trigger_alloc(&client->dev,
+ "%s-dev%d",
+ indio_dev->name,
+ indio_dev->id);
+ if (!data->dready_trig) {
+ ret = -ENOMEM;
+ dev_err(&client->dev, "iio trigger alloc failed\n");
+ goto err_poweroff;
+ }
+
+ data->dready_trig->dev.parent = &client->dev;
+ data->dready_trig->ops = &bmc150_magn_trigger_ops;
+ iio_trigger_set_drvdata(data->dready_trig, indio_dev);
+ ret = iio_trigger_register(data->dready_trig);
+ if (ret) {
+ dev_err(&client->dev, "iio trigger register failed\n");
+ goto err_poweroff;
+ }
+
+ ret = iio_triggered_buffer_setup(indio_dev,
+ &iio_pollfunc_store_time,
+ bmc150_magn_trigger_handler,
+ NULL);
+ if (ret < 0) {
+ dev_err(&client->dev,
+ "iio triggered buffer setup failed\n");
+ goto err_trigger_unregister;
+ }
+
+ ret = request_threaded_irq(client->irq,
+ iio_trigger_generic_data_rdy_poll,
+ NULL,
+ IRQF_TRIGGER_RISING | IRQF_ONESHOT,
+ BMC150_MAGN_IRQ_NAME,
+ data->dready_trig);
+ if (ret < 0) {
+ dev_err(&client->dev, "request irq %d failed\n",
+ client->irq);
+ goto err_buffer_cleanup;
+ }
+ }
+
+ ret = iio_device_register(indio_dev);
+ if (ret < 0) {
+ dev_err(&client->dev, "unable to register iio device\n");
+ goto err_free_irq;
+ }
+
+ ret = pm_runtime_set_active(&client->dev);
+ if (ret)
+ goto err_iio_unregister;
+
+ pm_runtime_enable(&client->dev);
+ pm_runtime_set_autosuspend_delay(&client->dev,
+ BMC150_MAGN_AUTO_SUSPEND_DELAY_MS);
+ pm_runtime_use_autosuspend(&client->dev);
+
+ dev_dbg(&indio_dev->dev, "Registered device %s\n", name);
+
+ return 0;
+
+err_iio_unregister:
+ iio_device_unregister(indio_dev);
+err_free_irq:
+ if (client->irq > 0)
+ free_irq(client->irq, data->dready_trig);
+err_buffer_cleanup:
+ if (data->dready_trig)
+ iio_triggered_buffer_cleanup(indio_dev);
+err_trigger_unregister:
+ if (data->dready_trig)
+ iio_trigger_unregister(data->dready_trig);
+err_poweroff:
+ bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true);
+ return ret;
+}
+
+static int bmc150_magn_remove(struct i2c_client *client)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+
+ pm_runtime_disable(&client->dev);
+ pm_runtime_set_suspended(&client->dev);
+ pm_runtime_put_noidle(&client->dev);
+
+ iio_device_unregister(indio_dev);
+
+ if (client->irq > 0)
+ free_irq(data->client->irq, data->dready_trig);
+
+ if (data->dready_trig) {
+ iio_triggered_buffer_cleanup(indio_dev);
+ iio_trigger_unregister(data->dready_trig);
+ }
+
+ mutex_lock(&data->mutex);
+ bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SUSPEND, true);
+ mutex_unlock(&data->mutex);
+
+ return 0;
+}
+
+#ifdef CONFIG_PM
+static int bmc150_magn_runtime_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ int ret;
+
+ mutex_lock(&data->mutex);
+ ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SLEEP,
+ true);
+ mutex_unlock(&data->mutex);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "powering off device failed\n");
+ return ret;
+ }
+ return 0;
+}
+
+static int bmc150_magn_runtime_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+
+ return bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL,
+ true);
+}
+#endif
+
+#ifdef CONFIG_PM_SLEEP
+static int bmc150_magn_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ int ret;
+
+ mutex_lock(&data->mutex);
+ ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_SLEEP,
+ true);
+ mutex_unlock(&data->mutex);
+
+ return ret;
+}
+
+static int bmc150_magn_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct bmc150_magn_data *data = iio_priv(indio_dev);
+ int ret;
+
+ mutex_lock(&data->mutex);
+ ret = bmc150_magn_set_power_mode(data, BMC150_MAGN_POWER_MODE_NORMAL,
+ true);
+ mutex_unlock(&data->mutex);
+
+ return ret;
+}
+#endif
+
+static const struct dev_pm_ops bmc150_magn_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(bmc150_magn_suspend, bmc150_magn_resume)
+ SET_RUNTIME_PM_OPS(bmc150_magn_runtime_suspend,
+ bmc150_magn_runtime_resume, NULL)
+};
+
+static const struct acpi_device_id bmc150_magn_acpi_match[] = {
+ {"BMC150B", 0},
+ {},
+};
+MODULE_DEVICE_TABLE(acpi, bmc150_magn_acpi_match);
+
+static const struct i2c_device_id bmc150_magn_id[] = {
+ {"bmc150_magn", 0},
+ {},
+};
+MODULE_DEVICE_TABLE(i2c, bmc150_magn_id);
+
+static struct i2c_driver bmc150_magn_driver = {
+ .driver = {
+ .name = BMC150_MAGN_DRV_NAME,
+ .acpi_match_table = ACPI_PTR(bmc150_magn_acpi_match),
+ .pm = &bmc150_magn_pm_ops,
+ },
+ .probe = bmc150_magn_probe,
+ .remove = bmc150_magn_remove,
+ .id_table = bmc150_magn_id,
+};
+module_i2c_driver(bmc150_magn_driver);
+
+MODULE_AUTHOR("Irina Tirdea <irina.tirdea@intel.com>");
+MODULE_LICENSE("GPL v2");
+MODULE_DESCRIPTION("BMC150 magnetometer driver");
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
index 4f9c0be244518d..d8a0c8da8db045 100644
--- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c
+++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c
@@ -510,7 +510,7 @@ static int hid_magn_3d_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id hid_magn_3d_ids[] = {
+static const struct platform_device_id hid_magn_3d_ids[] = {
{
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200083",
diff --git a/drivers/iio/magnetometer/mmc35240.c b/drivers/iio/magnetometer/mmc35240.c
new file mode 100644
index 00000000000000..aa6e25d3bfc354
--- /dev/null
+++ b/drivers/iio/magnetometer/mmc35240.c
@@ -0,0 +1,512 @@
+/*
+ * MMC35240 - MEMSIC 3-axis Magnetic Sensor
+ *
+ * Copyright (c) 2015, Intel Corporation.
+ *
+ * This file is subject to the terms and conditions of version 2 of
+ * the GNU General Public License. See the file COPYING in the main
+ * directory of this archive for more details.
+ *
+ * IIO driver for MMC35240 (7-bit I2C slave address 0x30).
+ *
+ * TODO: offset, ACPI, continuous measurement mode, PM
+ */
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/i2c.h>
+#include <linux/delay.h>
+#include <linux/regmap.h>
+#include <linux/acpi.h>
+#include <linux/pm.h>
+
+#include <linux/iio/iio.h>
+#include <linux/iio/sysfs.h>
+
+#define MMC35240_DRV_NAME "mmc35240"
+#define MMC35240_REGMAP_NAME "mmc35240_regmap"
+
+#define MMC35240_REG_XOUT_L 0x00
+#define MMC35240_REG_XOUT_H 0x01
+#define MMC35240_REG_YOUT_L 0x02
+#define MMC35240_REG_YOUT_H 0x03
+#define MMC35240_REG_ZOUT_L 0x04
+#define MMC35240_REG_ZOUT_H 0x05
+
+#define MMC35240_REG_STATUS 0x06
+#define MMC35240_REG_CTRL0 0x07
+#define MMC35240_REG_CTRL1 0x08
+
+#define MMC35240_REG_ID 0x20
+
+#define MMC35240_STATUS_MEAS_DONE_BIT BIT(0)
+
+#define MMC35240_CTRL0_REFILL_BIT BIT(7)
+#define MMC35240_CTRL0_RESET_BIT BIT(6)
+#define MMC35240_CTRL0_SET_BIT BIT(5)
+#define MMC35240_CTRL0_CMM_BIT BIT(1)
+#define MMC35240_CTRL0_TM_BIT BIT(0)
+
+/* output resolution bits */
+#define MMC35240_CTRL1_BW0_BIT BIT(0)
+#define MMC35240_CTRL1_BW1_BIT BIT(1)
+
+#define MMC35240_CTRL1_BW_MASK (MMC35240_CTRL1_BW0_BIT | \
+ MMC35240_CTRL1_BW1_BIT)
+#define MMC35240_CTRL1_BW_SHIFT 0
+
+#define MMC35240_WAIT_CHARGE_PUMP 50000 /* us */
+#define MMC53240_WAIT_SET_RESET 1000 /* us */
+
+enum mmc35240_resolution {
+ MMC35240_16_BITS_SLOW = 0, /* 100 Hz */
+ MMC35240_16_BITS_FAST, /* 200 Hz */
+ MMC35240_14_BITS, /* 333 Hz */
+ MMC35240_12_BITS, /* 666 Hz */
+};
+
+enum mmc35240_axis {
+ AXIS_X = 0,
+ AXIS_Y,
+ AXIS_Z,
+};
+
+static const struct {
+ int sens[3]; /* sensitivity per X, Y, Z axis */
+ int nfo; /* null field output */
+} mmc35240_props_table[] = {
+ /* 16 bits, 100Hz ODR */
+ {
+ {1024, 1024, 770},
+ 32768,
+ },
+ /* 16 bits, 200Hz ODR */
+ {
+ {1024, 1024, 770},
+ 32768,
+ },
+ /* 14 bits, 333Hz ODR */
+ {
+ {256, 256, 193},
+ 8192,
+ },
+ /* 12 bits, 666Hz ODR */
+ {
+ {64, 64, 48},
+ 2048,
+ },
+};
+
+struct mmc35240_data {
+ struct i2c_client *client;
+ struct mutex mutex;
+ struct regmap *regmap;
+ enum mmc35240_resolution res;
+};
+
+static const int mmc35240_samp_freq[] = {100, 200, 333, 666};
+
+static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("100 200 333 666");
+
+#define MMC35240_CHANNEL(_axis) { \
+ .type = IIO_MAGN, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_ ## _axis, \
+ .address = AXIS_ ## _axis, \
+ .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), \
+ .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_SAMP_FREQ), \
+}
+
+static const struct iio_chan_spec mmc35240_channels[] = {
+ MMC35240_CHANNEL(X),
+ MMC35240_CHANNEL(Y),
+ MMC35240_CHANNEL(Z),
+};
+
+static struct attribute *mmc35240_attributes[] = {
+ &iio_const_attr_sampling_frequency_available.dev_attr.attr,
+};
+
+static const struct attribute_group mmc35240_attribute_group = {
+ .attrs = mmc35240_attributes,
+};
+
+static int mmc35240_get_samp_freq_index(struct mmc35240_data *data,
+ int val, int val2)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(mmc35240_samp_freq); i++)
+ if (mmc35240_samp_freq[i] == val)
+ return i;
+ return -EINVAL;
+}
+
+static int mmc35240_hw_set(struct mmc35240_data *data, bool set)
+{
+ int ret;
+ u8 coil_bit;
+
+ /*
+ * Recharge the capacitor at VCAP pin, requested to be issued
+ * before a SET/RESET command.
+ */
+ ret = regmap_update_bits(data->regmap, MMC35240_REG_CTRL0,
+ MMC35240_CTRL0_REFILL_BIT,
+ MMC35240_CTRL0_REFILL_BIT);
+ if (ret < 0)
+ return ret;
+ usleep_range(MMC35240_WAIT_CHARGE_PUMP, MMC35240_WAIT_CHARGE_PUMP + 1);
+
+ if (set)
+ coil_bit = MMC35240_CTRL0_SET_BIT;
+ else
+ coil_bit = MMC35240_CTRL0_RESET_BIT;
+
+ return regmap_update_bits(data->regmap, MMC35240_REG_CTRL0,
+ MMC35240_CTRL0_REFILL_BIT,
+ coil_bit);
+}
+
+static int mmc35240_init(struct mmc35240_data *data)
+{
+ int ret;
+ unsigned int reg_id;
+
+ ret = regmap_read(data->regmap, MMC35240_REG_ID, &reg_id);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "Error reading product id\n");
+ return ret;
+ }
+
+ dev_dbg(&data->client->dev, "MMC35240 chip id %x\n", reg_id);
+
+ /*
+ * make sure we restore sensor characteristics, by doing
+ * a RESET/SET sequence
+ */
+ ret = mmc35240_hw_set(data, false);
+ if (ret < 0)
+ return ret;
+ usleep_range(MMC53240_WAIT_SET_RESET, MMC53240_WAIT_SET_RESET + 1);
+
+ ret = mmc35240_hw_set(data, true);
+ if (ret < 0)
+ return ret;
+
+ /* set default sampling frequency */
+ return regmap_update_bits(data->regmap, MMC35240_REG_CTRL1,
+ MMC35240_CTRL1_BW_MASK,
+ data->res << MMC35240_CTRL1_BW_SHIFT);
+}
+
+static int mmc35240_take_measurement(struct mmc35240_data *data)
+{
+ int ret, tries = 100;
+ unsigned int reg_status;
+
+ ret = regmap_write(data->regmap, MMC35240_REG_CTRL0,
+ MMC35240_CTRL0_TM_BIT);
+ if (ret < 0)
+ return ret;
+
+ while (tries-- > 0) {
+ ret = regmap_read(data->regmap, MMC35240_REG_STATUS,
+ &reg_status);
+ if (ret < 0)
+ return ret;
+ if (reg_status & MMC35240_STATUS_MEAS_DONE_BIT)
+ break;
+ msleep(20);
+ }
+
+ if (tries < 0) {
+ dev_err(&data->client->dev, "data not ready\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static int mmc35240_read_measurement(struct mmc35240_data *data, __le16 buf[3])
+{
+ int ret;
+
+ ret = mmc35240_take_measurement(data);
+ if (ret < 0)
+ return ret;
+
+ return regmap_bulk_read(data->regmap, MMC35240_REG_XOUT_L, (u8 *)buf,
+ 3 * sizeof(__le16));
+}
+
+static int mmc35240_raw_to_gauss(struct mmc35240_data *data, int index,
+ __le16 buf[],
+ int *val, int *val2)
+{
+ int raw_x, raw_y, raw_z;
+ int sens_x, sens_y, sens_z;
+ int nfo;
+
+ raw_x = le16_to_cpu(buf[AXIS_X]);
+ raw_y = le16_to_cpu(buf[AXIS_Y]);
+ raw_z = le16_to_cpu(buf[AXIS_Z]);
+
+ sens_x = mmc35240_props_table[data->res].sens[AXIS_X];
+ sens_y = mmc35240_props_table[data->res].sens[AXIS_Y];
+ sens_z = mmc35240_props_table[data->res].sens[AXIS_Z];
+
+ nfo = mmc35240_props_table[data->res].nfo;
+
+ switch (index) {
+ case AXIS_X:
+ *val = (raw_x - nfo) / sens_x;
+ *val2 = ((raw_x - nfo) % sens_x) * 1000000;
+ break;
+ case AXIS_Y:
+ *val = (raw_y - nfo) / sens_y - (raw_z - nfo) / sens_z;
+ *val2 = (((raw_y - nfo) % sens_y - (raw_z - nfo) % sens_z))
+ * 1000000;
+ break;
+ case AXIS_Z:
+ *val = (raw_y - nfo) / sens_y + (raw_z - nfo) / sens_z;
+ *val2 = (((raw_y - nfo) % sens_y + (raw_z - nfo) % sens_z))
+ * 1000000;
+ break;
+ default:
+ return -EINVAL;
+ }
+ return 0;
+}
+
+static int mmc35240_read_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int *val,
+ int *val2, long mask)
+{
+ struct mmc35240_data *data = iio_priv(indio_dev);
+ int ret, i;
+ unsigned int reg;
+ __le16 buf[3];
+
+ switch (mask) {
+ case IIO_CHAN_INFO_PROCESSED:
+ mutex_lock(&data->mutex);
+ ret = mmc35240_read_measurement(data, buf);
+ mutex_unlock(&data->mutex);
+ if (ret < 0)
+ return ret;
+ ret = mmc35240_raw_to_gauss(data, chan->address,
+ buf, val, val2);
+ if (ret < 0)
+ return ret;
+ return IIO_VAL_INT_PLUS_MICRO;
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ mutex_lock(&data->mutex);
+ ret = regmap_read(data->regmap, MMC35240_REG_CTRL1, &reg);
+ mutex_unlock(&data->mutex);
+ if (ret < 0)
+ return ret;
+
+ i = (reg & MMC35240_CTRL1_BW_MASK) >> MMC35240_CTRL1_BW_SHIFT;
+ if (i < 0 || i > ARRAY_SIZE(mmc35240_samp_freq))
+ return -EINVAL;
+
+ *val = mmc35240_samp_freq[i];
+ *val2 = 0;
+ return IIO_VAL_INT;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int mmc35240_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, int val,
+ int val2, long mask)
+{
+ struct mmc35240_data *data = iio_priv(indio_dev);
+ int i, ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_SAMP_FREQ:
+ i = mmc35240_get_samp_freq_index(data, val, val2);
+ if (i < 0)
+ return -EINVAL;
+ mutex_lock(&data->mutex);
+ ret = regmap_update_bits(data->regmap, MMC35240_REG_CTRL1,
+ MMC35240_CTRL1_BW_MASK,
+ i << MMC35240_CTRL1_BW_SHIFT);
+ mutex_unlock(&data->mutex);
+ return ret;
+ default:
+ return -EINVAL;
+ }
+}
+
+static const struct iio_info mmc35240_info = {
+ .driver_module = THIS_MODULE,
+ .read_raw = mmc35240_read_raw,
+ .write_raw = mmc35240_write_raw,
+ .attrs = &mmc35240_attribute_group,
+};
+
+static bool mmc35240_is_writeable_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case MMC35240_REG_CTRL0:
+ case MMC35240_REG_CTRL1:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static bool mmc35240_is_readable_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case MMC35240_REG_XOUT_L:
+ case MMC35240_REG_XOUT_H:
+ case MMC35240_REG_YOUT_L:
+ case MMC35240_REG_YOUT_H:
+ case MMC35240_REG_ZOUT_L:
+ case MMC35240_REG_ZOUT_H:
+ case MMC35240_REG_STATUS:
+ case MMC35240_REG_ID:
+ return true;
+ default:
+ return false;
+ }
+}
+
+static bool mmc35240_is_volatile_reg(struct device *dev, unsigned int reg)
+{
+ switch (reg) {
+ case MMC35240_REG_CTRL0:
+ case MMC35240_REG_CTRL1:
+ return false;
+ default:
+ return true;
+ }
+}
+
+static struct reg_default mmc35240_reg_defaults[] = {
+ { MMC35240_REG_CTRL0, 0x00 },
+ { MMC35240_REG_CTRL1, 0x00 },
+};
+
+static const struct regmap_config mmc35240_regmap_config = {
+ .name = MMC35240_REGMAP_NAME,
+
+ .reg_bits = 8,
+ .val_bits = 8,
+
+ .max_register = MMC35240_REG_ID,
+ .cache_type = REGCACHE_FLAT,
+
+ .writeable_reg = mmc35240_is_writeable_reg,
+ .readable_reg = mmc35240_is_readable_reg,
+ .volatile_reg = mmc35240_is_volatile_reg,
+
+ .reg_defaults = mmc35240_reg_defaults,
+ .num_reg_defaults = ARRAY_SIZE(mmc35240_reg_defaults),
+};
+
+static int mmc35240_probe(struct i2c_client *client,
+ const struct i2c_device_id *id)
+{
+ struct mmc35240_data *data;
+ struct iio_dev *indio_dev;
+ struct regmap *regmap;
+ int ret;
+
+ indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ regmap = devm_regmap_init_i2c(client, &mmc35240_regmap_config);
+ if (IS_ERR(regmap)) {
+ dev_err(&client->dev, "regmap initialization failed\n");
+ return PTR_ERR(regmap);
+ }
+
+ data = iio_priv(indio_dev);
+ data->client = client;
+ data->regmap = regmap;
+ data->res = MMC35240_16_BITS_SLOW;
+
+ mutex_init(&data->mutex);
+
+ indio_dev->dev.parent = &client->dev;
+ indio_dev->info = &mmc35240_info;
+ indio_dev->name = MMC35240_DRV_NAME;
+ indio_dev->channels = mmc35240_channels;
+ indio_dev->num_channels = ARRAY_SIZE(mmc35240_channels);
+ indio_dev->modes = INDIO_DIRECT_MODE;
+
+ ret = mmc35240_init(data);
+ if (ret < 0) {
+ dev_err(&client->dev, "mmc35240 chip init failed\n");
+ return ret;
+ }
+ return devm_iio_device_register(&client->dev, indio_dev);
+}
+
+#ifdef CONFIG_PM_SLEEP
+static int mmc35240_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct mmc35240_data *data = iio_priv(indio_dev);
+
+ regcache_cache_only(data->regmap, true);
+
+ return 0;
+}
+
+static int mmc35240_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct mmc35240_data *data = iio_priv(indio_dev);
+ int ret;
+
+ regcache_mark_dirty(data->regmap);
+ ret = regcache_sync_region(data->regmap, MMC35240_REG_CTRL0,
+ MMC35240_REG_CTRL1);
+ if (ret < 0)
+ dev_err(dev, "Failed to restore control registers\n");
+
+ regcache_cache_only(data->regmap, false);
+
+ return 0;
+}
+#endif
+
+static const struct dev_pm_ops mmc35240_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(mmc35240_suspend, mmc35240_resume)
+};
+
+static const struct acpi_device_id mmc35240_acpi_match[] = {
+ {"MMC35240", 0},
+ { },
+};
+MODULE_DEVICE_TABLE(acpi, mmc35240_acpi_match);
+
+static const struct i2c_device_id mmc35240_id[] = {
+ {"MMC35240", 0},
+ {}
+};
+MODULE_DEVICE_TABLE(i2c, mmc35240_id);
+
+static struct i2c_driver mmc35240_driver = {
+ .driver = {
+ .name = MMC35240_DRV_NAME,
+ .pm = &mmc35240_pm_ops,
+ .acpi_match_table = ACPI_PTR(mmc35240_acpi_match),
+ },
+ .probe = mmc35240_probe,
+ .id_table = mmc35240_id,
+};
+
+module_i2c_driver(mmc35240_driver);
+
+MODULE_AUTHOR("Daniel Baluta <daniel.baluta@intel.com>");
+MODULE_DESCRIPTION("MEMSIC MMC35240 magnetic sensor driver");
+MODULE_LICENSE("GPL v2");
diff --git a/drivers/iio/magnetometer/st_magn.h b/drivers/iio/magnetometer/st_magn.h
index 7e81d00ef0c3d4..287691ca56c1f8 100644
--- a/drivers/iio/magnetometer/st_magn.h
+++ b/drivers/iio/magnetometer/st_magn.h
@@ -14,6 +14,7 @@
#include <linux/types.h>
#include <linux/iio/common/st_sensors.h>
+#define LSM303DLH_MAGN_DEV_NAME "lsm303dlh_magn"
#define LSM303DLHC_MAGN_DEV_NAME "lsm303dlhc_magn"
#define LSM303DLM_MAGN_DEV_NAME "lsm303dlm_magn"
#define LIS3MDL_MAGN_DEV_NAME "lis3mdl"
diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c
index 2e56f812a644d6..b4bcfb790f49fe 100644
--- a/drivers/iio/magnetometer/st_magn_core.c
+++ b/drivers/iio/magnetometer/st_magn_core.c
@@ -45,6 +45,46 @@
#define ST_MAGN_FS_AVL_12000MG 12000
#define ST_MAGN_FS_AVL_16000MG 16000
+/* CUSTOM VALUES FOR SENSOR 0 */
+#define ST_MAGN_0_ODR_ADDR 0x00
+#define ST_MAGN_0_ODR_MASK 0x1c
+#define ST_MAGN_0_ODR_AVL_1HZ_VAL 0x00
+#define ST_MAGN_0_ODR_AVL_2HZ_VAL 0x01
+#define ST_MAGN_0_ODR_AVL_3HZ_VAL 0x02
+#define ST_MAGN_0_ODR_AVL_8HZ_VAL 0x03
+#define ST_MAGN_0_ODR_AVL_15HZ_VAL 0x04
+#define ST_MAGN_0_ODR_AVL_30HZ_VAL 0x05
+#define ST_MAGN_0_ODR_AVL_75HZ_VAL 0x06
+#define ST_MAGN_0_ODR_AVL_220HZ_VAL 0x07
+#define ST_MAGN_0_PW_ADDR 0x02
+#define ST_MAGN_0_PW_MASK 0x03
+#define ST_MAGN_0_PW_ON 0x00
+#define ST_MAGN_0_PW_OFF 0x03
+#define ST_MAGN_0_FS_ADDR 0x01
+#define ST_MAGN_0_FS_MASK 0xe0
+#define ST_MAGN_0_FS_AVL_1300_VAL 0x01
+#define ST_MAGN_0_FS_AVL_1900_VAL 0x02
+#define ST_MAGN_0_FS_AVL_2500_VAL 0x03
+#define ST_MAGN_0_FS_AVL_4000_VAL 0x04
+#define ST_MAGN_0_FS_AVL_4700_VAL 0x05
+#define ST_MAGN_0_FS_AVL_5600_VAL 0x06
+#define ST_MAGN_0_FS_AVL_8100_VAL 0x07
+#define ST_MAGN_0_FS_AVL_1300_GAIN_XY 1100
+#define ST_MAGN_0_FS_AVL_1900_GAIN_XY 855
+#define ST_MAGN_0_FS_AVL_2500_GAIN_XY 670
+#define ST_MAGN_0_FS_AVL_4000_GAIN_XY 450
+#define ST_MAGN_0_FS_AVL_4700_GAIN_XY 400
+#define ST_MAGN_0_FS_AVL_5600_GAIN_XY 330
+#define ST_MAGN_0_FS_AVL_8100_GAIN_XY 230
+#define ST_MAGN_0_FS_AVL_1300_GAIN_Z 980
+#define ST_MAGN_0_FS_AVL_1900_GAIN_Z 760
+#define ST_MAGN_0_FS_AVL_2500_GAIN_Z 600
+#define ST_MAGN_0_FS_AVL_4000_GAIN_Z 400
+#define ST_MAGN_0_FS_AVL_4700_GAIN_Z 355
+#define ST_MAGN_0_FS_AVL_5600_GAIN_Z 295
+#define ST_MAGN_0_FS_AVL_8100_GAIN_Z 205
+#define ST_MAGN_0_MULTIREAD_BIT false
+
/* CUSTOM VALUES FOR SENSOR 1 */
#define ST_MAGN_1_WAI_EXP 0x3c
#define ST_MAGN_1_ODR_ADDR 0x00
@@ -151,6 +191,82 @@ static const struct iio_chan_spec st_magn_2_16bit_channels[] = {
static const struct st_sensor_settings st_magn_sensors_settings[] = {
{
+ .wai = 0, /* This sensor has no valid WhoAmI report 0 */
+ .sensors_supported = {
+ [0] = LSM303DLH_MAGN_DEV_NAME,
+ },
+ .ch = (struct iio_chan_spec *)st_magn_16bit_channels,
+ .odr = {
+ .addr = ST_MAGN_0_ODR_ADDR,
+ .mask = ST_MAGN_0_ODR_MASK,
+ .odr_avl = {
+ { 1, ST_MAGN_0_ODR_AVL_1HZ_VAL, },
+ { 2, ST_MAGN_0_ODR_AVL_2HZ_VAL, },
+ { 3, ST_MAGN_0_ODR_AVL_3HZ_VAL, },
+ { 8, ST_MAGN_0_ODR_AVL_8HZ_VAL, },
+ { 15, ST_MAGN_0_ODR_AVL_15HZ_VAL, },
+ { 30, ST_MAGN_0_ODR_AVL_30HZ_VAL, },
+ { 75, ST_MAGN_0_ODR_AVL_75HZ_VAL, },
+ },
+ },
+ .pw = {
+ .addr = ST_MAGN_0_PW_ADDR,
+ .mask = ST_MAGN_0_PW_MASK,
+ .value_on = ST_MAGN_0_PW_ON,
+ .value_off = ST_MAGN_0_PW_OFF,
+ },
+ .fs = {
+ .addr = ST_MAGN_0_FS_ADDR,
+ .mask = ST_MAGN_0_FS_MASK,
+ .fs_avl = {
+ [0] = {
+ .num = ST_MAGN_FS_AVL_1300MG,
+ .value = ST_MAGN_0_FS_AVL_1300_VAL,
+ .gain = ST_MAGN_0_FS_AVL_1300_GAIN_XY,
+ .gain2 = ST_MAGN_0_FS_AVL_1300_GAIN_Z,
+ },
+ [1] = {
+ .num = ST_MAGN_FS_AVL_1900MG,
+ .value = ST_MAGN_0_FS_AVL_1900_VAL,
+ .gain = ST_MAGN_0_FS_AVL_1900_GAIN_XY,
+ .gain2 = ST_MAGN_0_FS_AVL_1900_GAIN_Z,
+ },
+ [2] = {
+ .num = ST_MAGN_FS_AVL_2500MG,
+ .value = ST_MAGN_0_FS_AVL_2500_VAL,
+ .gain = ST_MAGN_0_FS_AVL_2500_GAIN_XY,
+ .gain2 = ST_MAGN_0_FS_AVL_2500_GAIN_Z,
+ },
+ [3] = {
+ .num = ST_MAGN_FS_AVL_4000MG,
+ .value = ST_MAGN_0_FS_AVL_4000_VAL,
+ .gain = ST_MAGN_0_FS_AVL_4000_GAIN_XY,
+ .gain2 = ST_MAGN_0_FS_AVL_4000_GAIN_Z,
+ },
+ [4] = {
+ .num = ST_MAGN_FS_AVL_4700MG,
+ .value = ST_MAGN_0_FS_AVL_4700_VAL,
+ .gain = ST_MAGN_0_FS_AVL_4700_GAIN_XY,
+ .gain2 = ST_MAGN_0_FS_AVL_4700_GAIN_Z,
+ },
+ [5] = {
+ .num = ST_MAGN_FS_AVL_5600MG,
+ .value = ST_MAGN_0_FS_AVL_5600_VAL,
+ .gain = ST_MAGN_0_FS_AVL_5600_GAIN_XY,
+ .gain2 = ST_MAGN_0_FS_AVL_5600_GAIN_Z,
+ },
+ [6] = {
+ .num = ST_MAGN_FS_AVL_8100MG,
+ .value = ST_MAGN_0_FS_AVL_8100_VAL,
+ .gain = ST_MAGN_0_FS_AVL_8100_GAIN_XY,
+ .gain2 = ST_MAGN_0_FS_AVL_8100_GAIN_Z,
+ },
+ },
+ },
+ .multi_read_bit = ST_MAGN_0_MULTIREAD_BIT,
+ .bootime = 2,
+ },
+ {
.wai = ST_MAGN_1_WAI_EXP,
.sensors_supported = {
[0] = LSM303DLHC_MAGN_DEV_NAME,
diff --git a/drivers/iio/magnetometer/st_magn_i2c.c b/drivers/iio/magnetometer/st_magn_i2c.c
index 92e5c15452a3e4..5311d8aea8cc13 100644
--- a/drivers/iio/magnetometer/st_magn_i2c.c
+++ b/drivers/iio/magnetometer/st_magn_i2c.c
@@ -21,6 +21,10 @@
#ifdef CONFIG_OF
static const struct of_device_id st_magn_of_match[] = {
{
+ .compatible = "st,lsm303dlh-magn",
+ .data = LSM303DLH_MAGN_DEV_NAME,
+ },
+ {
.compatible = "st,lsm303dlhc-magn",
.data = LSM303DLHC_MAGN_DEV_NAME,
},
@@ -71,6 +75,7 @@ static int st_magn_i2c_remove(struct i2c_client *client)
}
static const struct i2c_device_id st_magn_id_table[] = {
+ { LSM303DLH_MAGN_DEV_NAME },
{ LSM303DLHC_MAGN_DEV_NAME },
{ LSM303DLM_MAGN_DEV_NAME },
{ LIS3MDL_MAGN_DEV_NAME },
diff --git a/drivers/iio/orientation/hid-sensor-incl-3d.c b/drivers/iio/orientation/hid-sensor-incl-3d.c
index 5930fa32a2ab19..fd1b3696ee42ff 100644
--- a/drivers/iio/orientation/hid-sensor-incl-3d.c
+++ b/drivers/iio/orientation/hid-sensor-incl-3d.c
@@ -315,7 +315,6 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct incl_3d_state *incl_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct incl_3d_state));
@@ -336,21 +335,22 @@ static int hid_incl_3d_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(incl_3d_channels, sizeof(incl_3d_channels),
- GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(incl_3d_channels,
+ sizeof(incl_3d_channels), GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = incl_3d_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_INCLINOMETER_3D, incl_state);
+ ret = incl_3d_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_INCLINOMETER_3D,
+ incl_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels = ARRAY_SIZE(incl_3d_channels);
indio_dev->dev.parent = &pdev->dev;
indio_dev->info = &incl_3d_info;
@@ -417,7 +417,7 @@ static int hid_incl_3d_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id hid_incl_3d_ids[] = {
+static const struct platform_device_id hid_incl_3d_ids[] = {
{
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200086",
diff --git a/drivers/iio/orientation/hid-sensor-rotation.c b/drivers/iio/orientation/hid-sensor-rotation.c
index 4afb6c79ccbce8..b98b9d94d184cd 100644
--- a/drivers/iio/orientation/hid-sensor-rotation.c
+++ b/drivers/iio/orientation/hid-sensor-rotation.c
@@ -222,7 +222,6 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct dev_rot_state *rot_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct dev_rot_state));
@@ -243,21 +242,23 @@ static int hid_dev_rot_probe(struct platform_device *pdev)
return ret;
}
- channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
- sizeof(dev_rot_channels), GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = devm_kmemdup(&pdev->dev, dev_rot_channels,
+ sizeof(dev_rot_channels),
+ GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = dev_rot_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_DEVICE_ORIENTATION, rot_state);
+ ret = dev_rot_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_DEVICE_ORIENTATION,
+ rot_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
return ret;
}
- indio_dev->channels = channels;
indio_dev->num_channels = ARRAY_SIZE(dev_rot_channels);
indio_dev->dev.parent = &pdev->dev;
indio_dev->info = &dev_rot_info;
@@ -321,7 +322,7 @@ static int hid_dev_rot_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id hid_dev_rot_ids[] = {
+static const struct platform_device_id hid_dev_rot_ids[] = {
{
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-20008a",
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c
index 3cf0bd67d24ca8..6848d8c80effcf 100644
--- a/drivers/iio/pressure/hid-sensor-press.c
+++ b/drivers/iio/pressure/hid-sensor-press.c
@@ -260,7 +260,6 @@ static int hid_press_probe(struct platform_device *pdev)
struct iio_dev *indio_dev;
struct press_state *press_state;
struct hid_sensor_hub_device *hsdev = pdev->dev.platform_data;
- struct iio_chan_spec *channels;
indio_dev = devm_iio_device_alloc(&pdev->dev,
sizeof(struct press_state));
@@ -280,20 +279,21 @@ static int hid_press_probe(struct platform_device *pdev)
return ret;
}
- channels = kmemdup(press_channels, sizeof(press_channels), GFP_KERNEL);
- if (!channels) {
+ indio_dev->channels = kmemdup(press_channels, sizeof(press_channels),
+ GFP_KERNEL);
+ if (!indio_dev->channels) {
dev_err(&pdev->dev, "failed to duplicate channels\n");
return -ENOMEM;
}
- ret = press_parse_report(pdev, hsdev, channels,
- HID_USAGE_SENSOR_PRESSURE, press_state);
+ ret = press_parse_report(pdev, hsdev,
+ (struct iio_chan_spec *)indio_dev->channels,
+ HID_USAGE_SENSOR_PRESSURE, press_state);
if (ret) {
dev_err(&pdev->dev, "failed to setup attributes\n");
goto error_free_dev_mem;
}
- indio_dev->channels = channels;
indio_dev->num_channels =
ARRAY_SIZE(press_channels);
indio_dev->dev.parent = &pdev->dev;
@@ -360,7 +360,7 @@ static int hid_press_remove(struct platform_device *pdev)
return 0;
}
-static struct platform_device_id hid_press_ids[] = {
+static const struct platform_device_id hid_press_ids[] = {
{
/* Format: HID-SENSOR-usage_id_in_hex_lowercase */
.name = "HID-SENSOR-200031",
diff --git a/drivers/iio/proximity/sx9500.c b/drivers/iio/proximity/sx9500.c
index fa40f6d0ca394f..2042e375f8351d 100644
--- a/drivers/iio/proximity/sx9500.c
+++ b/drivers/iio/proximity/sx9500.c
@@ -18,6 +18,8 @@
#include <linux/acpi.h>
#include <linux/gpio/consumer.h>
#include <linux/regmap.h>
+#include <linux/pm.h>
+#include <linux/delay.h>
#include <linux/iio/iio.h>
#include <linux/iio/buffer.h>
@@ -29,7 +31,9 @@
#define SX9500_DRIVER_NAME "sx9500"
#define SX9500_IRQ_NAME "sx9500_event"
-#define SX9500_GPIO_NAME "sx9500_gpio"
+
+#define SX9500_GPIO_INT "interrupt"
+#define SX9500_GPIO_RESET "reset"
/* Register definitions. */
#define SX9500_REG_IRQ_SRC 0x00
@@ -73,6 +77,7 @@
#define SX9500_CONVDONE_IRQ BIT(3)
#define SX9500_PROXSTAT_SHIFT 4
+#define SX9500_COMPSTAT_MASK GENMASK(3, 0)
#define SX9500_NUM_CHANNELS 4
@@ -81,6 +86,7 @@ struct sx9500_data {
struct i2c_client *client;
struct iio_trigger *trig;
struct regmap *regmap;
+ struct gpio_desc *gpiod_rst;
/*
* Last reading of the proximity status for each channel. We
* only send an event to user space when this changes.
@@ -89,6 +95,11 @@ struct sx9500_data {
bool event_enabled[SX9500_NUM_CHANNELS];
bool trigger_enabled;
u16 *buffer;
+ /* Remember enabled channels and sample rate during suspend. */
+ unsigned int suspend_ctrl0;
+ struct completion completion;
+ int data_rdy_users, close_far_users;
+ int channel_users[SX9500_NUM_CHANNELS];
};
static const struct iio_event_spec sx9500_events[] = {
@@ -139,6 +150,10 @@ static const struct {
{2, 500000},
};
+static const unsigned int sx9500_scan_period_table[] = {
+ 30, 60, 90, 120, 150, 200, 300, 400,
+};
+
static const struct regmap_range sx9500_writable_reg_ranges[] = {
regmap_reg_range(SX9500_REG_IRQ_MSK, SX9500_REG_IRQ_MSK),
regmap_reg_range(SX9500_REG_PROX_CTRL0, SX9500_REG_PROX_CTRL8),
@@ -191,7 +206,67 @@ static const struct regmap_config sx9500_regmap_config = {
.volatile_table = &sx9500_volatile_regs,
};
-static int sx9500_read_proximity(struct sx9500_data *data,
+static int sx9500_inc_users(struct sx9500_data *data, int *counter,
+ unsigned int reg, unsigned int bitmask)
+{
+ (*counter)++;
+ if (*counter != 1)
+ /* Bit is already active, nothing to do. */
+ return 0;
+
+ return regmap_update_bits(data->regmap, reg, bitmask, bitmask);
+}
+
+static int sx9500_dec_users(struct sx9500_data *data, int *counter,
+ unsigned int reg, unsigned int bitmask)
+{
+ (*counter)--;
+ if (*counter != 0)
+ /* There are more users, do not deactivate. */
+ return 0;
+
+ return regmap_update_bits(data->regmap, reg, bitmask, 0);
+}
+
+static int sx9500_inc_chan_users(struct sx9500_data *data, int chan)
+{
+ return sx9500_inc_users(data, &data->channel_users[chan],
+ SX9500_REG_PROX_CTRL0, BIT(chan));
+}
+
+static int sx9500_dec_chan_users(struct sx9500_data *data, int chan)
+{
+ return sx9500_dec_users(data, &data->channel_users[chan],
+ SX9500_REG_PROX_CTRL0, BIT(chan));
+}
+
+static int sx9500_inc_data_rdy_users(struct sx9500_data *data)
+{
+ return sx9500_inc_users(data, &data->data_rdy_users,
+ SX9500_REG_IRQ_MSK, SX9500_CONVDONE_IRQ);
+}
+
+static int sx9500_dec_data_rdy_users(struct sx9500_data *data)
+{
+ return sx9500_dec_users(data, &data->data_rdy_users,
+ SX9500_REG_IRQ_MSK, SX9500_CONVDONE_IRQ);
+}
+
+static int sx9500_inc_close_far_users(struct sx9500_data *data)
+{
+ return sx9500_inc_users(data, &data->close_far_users,
+ SX9500_REG_IRQ_MSK,
+ SX9500_CLOSE_IRQ | SX9500_FAR_IRQ);
+}
+
+static int sx9500_dec_close_far_users(struct sx9500_data *data)
+{
+ return sx9500_dec_users(data, &data->close_far_users,
+ SX9500_REG_IRQ_MSK,
+ SX9500_CLOSE_IRQ | SX9500_FAR_IRQ);
+}
+
+static int sx9500_read_prox_data(struct sx9500_data *data,
const struct iio_chan_spec *chan,
int *val)
{
@@ -211,6 +286,79 @@ static int sx9500_read_proximity(struct sx9500_data *data,
return IIO_VAL_INT;
}
+/*
+ * If we have no interrupt support, we have to wait for a scan period
+ * after enabling a channel to get a result.
+ */
+static int sx9500_wait_for_sample(struct sx9500_data *data)
+{
+ int ret;
+ unsigned int val;
+
+ ret = regmap_read(data->regmap, SX9500_REG_PROX_CTRL0, &val);
+ if (ret < 0)
+ return ret;
+
+ val = (val & SX9500_SCAN_PERIOD_MASK) >> SX9500_SCAN_PERIOD_SHIFT;
+
+ msleep(sx9500_scan_period_table[val]);
+
+ return 0;
+}
+
+static int sx9500_read_proximity(struct sx9500_data *data,
+ const struct iio_chan_spec *chan,
+ int *val)
+{
+ int ret;
+
+ mutex_lock(&data->mutex);
+
+ ret = sx9500_inc_chan_users(data, chan->channel);
+ if (ret < 0)
+ goto out;
+
+ ret = sx9500_inc_data_rdy_users(data);
+ if (ret < 0)
+ goto out_dec_chan;
+
+ mutex_unlock(&data->mutex);
+
+ if (data->client->irq > 0)
+ ret = wait_for_completion_interruptible(&data->completion);
+ else
+ ret = sx9500_wait_for_sample(data);
+
+ if (ret < 0)
+ return ret;
+
+ mutex_lock(&data->mutex);
+
+ ret = sx9500_read_prox_data(data, chan, val);
+ if (ret < 0)
+ goto out;
+
+ ret = sx9500_dec_chan_users(data, chan->channel);
+ if (ret < 0)
+ goto out;
+
+ ret = sx9500_dec_data_rdy_users(data);
+ if (ret < 0)
+ goto out;
+
+ ret = IIO_VAL_INT;
+
+ goto out;
+
+out_dec_chan:
+ sx9500_dec_chan_users(data, chan->channel);
+out:
+ mutex_unlock(&data->mutex);
+ reinit_completion(&data->completion);
+
+ return ret;
+}
+
static int sx9500_read_samp_freq(struct sx9500_data *data,
int *val, int *val2)
{
@@ -236,7 +384,6 @@ static int sx9500_read_raw(struct iio_dev *indio_dev,
int *val, int *val2, long mask)
{
struct sx9500_data *data = iio_priv(indio_dev);
- int ret;
switch (chan->type) {
case IIO_PROXIMITY:
@@ -244,10 +391,7 @@ static int sx9500_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_RAW:
if (iio_buffer_enabled(indio_dev))
return -EBUSY;
- mutex_lock(&data->mutex);
- ret = sx9500_read_proximity(data, chan, val);
- mutex_unlock(&data->mutex);
- return ret;
+ return sx9500_read_proximity(data, chan, val);
case IIO_CHAN_INFO_SAMP_FREQ:
return sx9500_read_samp_freq(data, val, val2);
default:
@@ -318,28 +462,16 @@ static irqreturn_t sx9500_irq_handler(int irq, void *private)
return IRQ_WAKE_THREAD;
}
-static irqreturn_t sx9500_irq_thread_handler(int irq, void *private)
+static void sx9500_push_events(struct iio_dev *indio_dev)
{
- struct iio_dev *indio_dev = private;
- struct sx9500_data *data = iio_priv(indio_dev);
int ret;
unsigned int val, chan;
-
- mutex_lock(&data->mutex);
-
- ret = regmap_read(data->regmap, SX9500_REG_IRQ_SRC, &val);
- if (ret < 0) {
- dev_err(&data->client->dev, "i2c transfer error in irq\n");
- goto out;
- }
-
- if (!(val & (SX9500_CLOSE_IRQ | SX9500_FAR_IRQ)))
- goto out;
+ struct sx9500_data *data = iio_priv(indio_dev);
ret = regmap_read(data->regmap, SX9500_REG_STAT, &val);
if (ret < 0) {
dev_err(&data->client->dev, "i2c transfer error in irq\n");
- goto out;
+ return;
}
val >>= SX9500_PROXSTAT_SHIFT;
@@ -354,15 +486,34 @@ static irqreturn_t sx9500_irq_thread_handler(int irq, void *private)
/* No change on this channel. */
continue;
- dir = new_prox ? IIO_EV_DIR_FALLING :
- IIO_EV_DIR_RISING;
- ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY,
- chan,
- IIO_EV_TYPE_THRESH,
- dir);
+ dir = new_prox ? IIO_EV_DIR_FALLING : IIO_EV_DIR_RISING;
+ ev = IIO_UNMOD_EVENT_CODE(IIO_PROXIMITY, chan,
+ IIO_EV_TYPE_THRESH, dir);
iio_push_event(indio_dev, ev, iio_get_time_ns());
data->prox_stat[chan] = new_prox;
}
+}
+
+static irqreturn_t sx9500_irq_thread_handler(int irq, void *private)
+{
+ struct iio_dev *indio_dev = private;
+ struct sx9500_data *data = iio_priv(indio_dev);
+ int ret;
+ unsigned int val;
+
+ mutex_lock(&data->mutex);
+
+ ret = regmap_read(data->regmap, SX9500_REG_IRQ_SRC, &val);
+ if (ret < 0) {
+ dev_err(&data->client->dev, "i2c transfer error in irq\n");
+ goto out;
+ }
+
+ if (val & (SX9500_CLOSE_IRQ | SX9500_FAR_IRQ))
+ sx9500_push_events(indio_dev);
+
+ if (val & SX9500_CONVDONE_IRQ)
+ complete_all(&data->completion);
out:
mutex_unlock(&data->mutex);
@@ -391,9 +542,7 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,
int state)
{
struct sx9500_data *data = iio_priv(indio_dev);
- int ret, i;
- bool any_active = false;
- unsigned int irqmask;
+ int ret;
if (chan->type != IIO_PROXIMITY || type != IIO_EV_TYPE_THRESH ||
dir != IIO_EV_DIR_EITHER)
@@ -401,24 +550,32 @@ static int sx9500_write_event_config(struct iio_dev *indio_dev,
mutex_lock(&data->mutex);
- data->event_enabled[chan->channel] = state;
+ if (state == 1) {
+ ret = sx9500_inc_chan_users(data, chan->channel);
+ if (ret < 0)
+ goto out_unlock;
+ ret = sx9500_inc_close_far_users(data);
+ if (ret < 0)
+ goto out_undo_chan;
+ } else {
+ ret = sx9500_dec_chan_users(data, chan->channel);
+ if (ret < 0)
+ goto out_unlock;
+ ret = sx9500_dec_close_far_users(data);
+ if (ret < 0)
+ goto out_undo_chan;
+ }
- for (i = 0; i < SX9500_NUM_CHANNELS; i++)
- if (data->event_enabled[i]) {
- any_active = true;
- break;
- }
+ data->event_enabled[chan->channel] = state;
+ goto out_unlock;
- irqmask = SX9500_CLOSE_IRQ | SX9500_FAR_IRQ;
- if (any_active)
- ret = regmap_update_bits(data->regmap, SX9500_REG_IRQ_MSK,
- irqmask, irqmask);
+out_undo_chan:
+ if (state == 1)
+ sx9500_dec_chan_users(data, chan->channel);
else
- ret = regmap_update_bits(data->regmap, SX9500_REG_IRQ_MSK,
- irqmask, 0);
-
+ sx9500_inc_chan_users(data, chan->channel);
+out_unlock:
mutex_unlock(&data->mutex);
-
return ret;
}
@@ -469,12 +626,16 @@ static int sx9500_set_trigger_state(struct iio_trigger *trig,
mutex_lock(&data->mutex);
- ret = regmap_update_bits(data->regmap, SX9500_REG_IRQ_MSK,
- SX9500_CONVDONE_IRQ,
- state ? SX9500_CONVDONE_IRQ : 0);
- if (ret == 0)
- data->trigger_enabled = state;
+ if (state)
+ ret = sx9500_inc_data_rdy_users(data);
+ else
+ ret = sx9500_dec_data_rdy_users(data);
+ if (ret < 0)
+ goto out;
+
+ data->trigger_enabled = state;
+out:
mutex_unlock(&data->mutex);
return ret;
@@ -496,7 +657,7 @@ static irqreturn_t sx9500_trigger_handler(int irq, void *private)
for_each_set_bit(bit, indio_dev->active_scan_mask,
indio_dev->masklength) {
- ret = sx9500_read_proximity(data, &indio_dev->channels[bit],
+ ret = sx9500_read_prox_data(data, &indio_dev->channels[bit],
&val);
if (ret < 0)
goto out;
@@ -515,6 +676,62 @@ out:
return IRQ_HANDLED;
}
+static int sx9500_buffer_preenable(struct iio_dev *indio_dev)
+{
+ struct sx9500_data *data = iio_priv(indio_dev);
+ int ret, i;
+
+ mutex_lock(&data->mutex);
+
+ for (i = 0; i < SX9500_NUM_CHANNELS; i++)
+ if (test_bit(i, indio_dev->active_scan_mask)) {
+ ret = sx9500_inc_chan_users(data, i);
+ if (ret)
+ break;
+ }
+
+ if (ret)
+ for (i = i - 1; i >= 0; i--)
+ if (test_bit(i, indio_dev->active_scan_mask))
+ sx9500_dec_chan_users(data, i);
+
+ mutex_unlock(&data->mutex);
+
+ return ret;
+}
+
+static int sx9500_buffer_predisable(struct iio_dev *indio_dev)
+{
+ struct sx9500_data *data = iio_priv(indio_dev);
+ int ret, i;
+
+ iio_triggered_buffer_predisable(indio_dev);
+
+ mutex_lock(&data->mutex);
+
+ for (i = 0; i < SX9500_NUM_CHANNELS; i++)
+ if (test_bit(i, indio_dev->active_scan_mask)) {
+ ret = sx9500_dec_chan_users(data, i);
+ if (ret)
+ break;
+ }
+
+ if (ret)
+ for (i = i - 1; i >= 0; i--)
+ if (test_bit(i, indio_dev->active_scan_mask))
+ sx9500_inc_chan_users(data, i);
+
+ mutex_unlock(&data->mutex);
+
+ return ret;
+}
+
+static const struct iio_buffer_setup_ops sx9500_buffer_setup_ops = {
+ .preenable = sx9500_buffer_preenable,
+ .postenable = iio_triggered_buffer_postenable,
+ .predisable = sx9500_buffer_predisable,
+};
+
struct sx9500_reg_default {
u8 reg;
u8 def;
@@ -570,17 +787,57 @@ static const struct sx9500_reg_default sx9500_default_regs[] = {
},
{
.reg = SX9500_REG_PROX_CTRL0,
- /* Scan period: 30ms, all sensors enabled. */
- .def = 0x0f,
+ /* Scan period: 30ms, all sensors disabled. */
+ .def = 0x00,
},
};
+/* Activate all channels and perform an initial compensation. */
+static int sx9500_init_compensation(struct iio_dev *indio_dev)
+{
+ struct sx9500_data *data = iio_priv(indio_dev);
+ int i, ret;
+ unsigned int val;
+
+ ret = regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0,
+ GENMASK(SX9500_NUM_CHANNELS, 0),
+ GENMASK(SX9500_NUM_CHANNELS, 0));
+ if (ret < 0)
+ return ret;
+
+ for (i = 10; i >= 0; i--) {
+ usleep_range(10000, 20000);
+ ret = regmap_read(data->regmap, SX9500_REG_STAT, &val);
+ if (ret < 0)
+ goto out;
+ if (!(val & SX9500_COMPSTAT_MASK))
+ break;
+ }
+
+ if (i < 0) {
+ dev_err(&data->client->dev, "initial compensation timed out");
+ ret = -ETIMEDOUT;
+ }
+
+out:
+ regmap_update_bits(data->regmap, SX9500_REG_PROX_CTRL0,
+ GENMASK(SX9500_NUM_CHANNELS, 0), 0);
+ return ret;
+}
+
static int sx9500_init_device(struct iio_dev *indio_dev)
{
struct sx9500_data *data = iio_priv(indio_dev);
int ret, i;
unsigned int val;
+ if (data->gpiod_rst) {
+ gpiod_set_value_cansleep(data->gpiod_rst, 0);
+ usleep_range(1000, 2000);
+ gpiod_set_value_cansleep(data->gpiod_rst, 1);
+ usleep_range(1000, 2000);
+ }
+
ret = regmap_write(data->regmap, SX9500_REG_IRQ_MSK, 0);
if (ret < 0)
return ret;
@@ -602,33 +859,34 @@ static int sx9500_init_device(struct iio_dev *indio_dev)
return ret;
}
- return 0;
+ return sx9500_init_compensation(indio_dev);
}
-static int sx9500_gpio_probe(struct i2c_client *client,
- struct sx9500_data *data)
+static void sx9500_gpio_probe(struct i2c_client *client,
+ struct sx9500_data *data)
{
struct device *dev;
struct gpio_desc *gpio;
- int ret;
if (!client)
- return -EINVAL;
+ return;
dev = &client->dev;
- /* data ready gpio interrupt pin */
- gpio = devm_gpiod_get_index(dev, SX9500_GPIO_NAME, 0, GPIOD_IN);
- if (IS_ERR(gpio)) {
- dev_err(dev, "acpi gpio get index failed\n");
- return PTR_ERR(gpio);
+ if (client->irq <= 0) {
+ gpio = devm_gpiod_get_index(dev, SX9500_GPIO_INT, 0, GPIOD_IN);
+ if (IS_ERR(gpio))
+ dev_err(dev, "gpio get irq failed\n");
+ else
+ client->irq = gpiod_to_irq(gpio);
}
- ret = gpiod_to_irq(gpio);
-
- dev_dbg(dev, "GPIO resource, no:%d irq:%d\n", desc_to_gpio(gpio), ret);
-
- return ret;
+ data->gpiod_rst = devm_gpiod_get_index(dev, SX9500_GPIO_RESET,
+ 0, GPIOD_OUT_HIGH);
+ if (IS_ERR(data->gpiod_rst)) {
+ dev_warn(dev, "gpio get reset pin failed\n");
+ data->gpiod_rst = NULL;
+ }
}
static int sx9500_probe(struct i2c_client *client,
@@ -645,14 +903,13 @@ static int sx9500_probe(struct i2c_client *client,
data = iio_priv(indio_dev);
data->client = client;
mutex_init(&data->mutex);
+ init_completion(&data->completion);
data->trigger_enabled = false;
data->regmap = devm_regmap_init_i2c(client, &sx9500_regmap_config);
if (IS_ERR(data->regmap))
return PTR_ERR(data->regmap);
- sx9500_init_device(indio_dev);
-
indio_dev->dev.parent = &client->dev;
indio_dev->name = SX9500_DRIVER_NAME;
indio_dev->channels = sx9500_channels;
@@ -661,10 +918,15 @@ static int sx9500_probe(struct i2c_client *client,
indio_dev->modes = INDIO_DIRECT_MODE;
i2c_set_clientdata(client, indio_dev);
- if (client->irq <= 0)
- client->irq = sx9500_gpio_probe(client, data);
+ sx9500_gpio_probe(client, data);
- if (client->irq > 0) {
+ ret = sx9500_init_device(indio_dev);
+ if (ret < 0)
+ return ret;
+
+ if (client->irq <= 0)
+ dev_warn(&client->dev, "no valid irq found\n");
+ else {
ret = devm_request_threaded_irq(&client->dev, client->irq,
sx9500_irq_handler, sx9500_irq_thread_handler,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
@@ -687,7 +949,8 @@ static int sx9500_probe(struct i2c_client *client,
}
ret = iio_triggered_buffer_setup(indio_dev, NULL,
- sx9500_trigger_handler, NULL);
+ sx9500_trigger_handler,
+ &sx9500_buffer_setup_ops);
if (ret < 0)
goto out_trigger_unregister;
@@ -720,6 +983,49 @@ static int sx9500_remove(struct i2c_client *client)
return 0;
}
+#ifdef CONFIG_PM_SLEEP
+static int sx9500_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct sx9500_data *data = iio_priv(indio_dev);
+ int ret;
+
+ mutex_lock(&data->mutex);
+ ret = regmap_read(data->regmap, SX9500_REG_PROX_CTRL0,
+ &data->suspend_ctrl0);
+ if (ret < 0)
+ goto out;
+
+ /*
+ * Scan period doesn't matter because when all the sensors are
+ * deactivated the device is in sleep mode.
+ */
+ ret = regmap_write(data->regmap, SX9500_REG_PROX_CTRL0, 0);
+
+out:
+ mutex_unlock(&data->mutex);
+ return ret;
+}
+
+static int sx9500_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct sx9500_data *data = iio_priv(indio_dev);
+ int ret;
+
+ mutex_lock(&data->mutex);
+ ret = regmap_write(data->regmap, SX9500_REG_PROX_CTRL0,
+ data->suspend_ctrl0);
+ mutex_unlock(&data->mutex);
+
+ return ret;
+}
+#endif /* CONFIG_PM_SLEEP */
+
+static const struct dev_pm_ops sx9500_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(sx9500_suspend, sx9500_resume)
+};
+
static const struct acpi_device_id sx9500_acpi_match[] = {
{"SSX9500", 0},
{ },
@@ -728,7 +1034,7 @@ MODULE_DEVICE_TABLE(acpi, sx9500_acpi_match);
static const struct i2c_device_id sx9500_id[] = {
{"sx9500", 0},
- {}
+ { },
};
MODULE_DEVICE_TABLE(i2c, sx9500_id);
@@ -736,6 +1042,7 @@ static struct i2c_driver sx9500_driver = {
.driver = {
.name = SX9500_DRIVER_NAME,
.acpi_match_table = ACPI_PTR(sx9500_acpi_match),
+ .pm = &sx9500_pm_ops,
},
.probe = sx9500_probe,
.remove = sx9500_remove,
diff --git a/drivers/iio/temperature/mlx90614.c b/drivers/iio/temperature/mlx90614.c
index a112fc9abf4346..cb2e8ad8bfdcd0 100644
--- a/drivers/iio/temperature/mlx90614.c
+++ b/drivers/iio/temperature/mlx90614.c
@@ -12,12 +12,24 @@
*
* (7-bit I2C slave address 0x5a, 100KHz bus speed only!)
*
- * TODO: sleep mode, configuration EEPROM
+ * To wake up from sleep mode, the SDA line must be held low while SCL is high
+ * for at least 33ms. This is achieved with an extra GPIO that can be connected
+ * directly to the SDA line. In normal operation, the GPIO is set as input and
+ * will not interfere in I2C communication. While the GPIO is driven low, the
+ * i2c adapter is locked since it cannot be used by other clients. The SCL line
+ * always has a pull-up so we do not need an extra GPIO to drive it high. If
+ * the "wakeup" GPIO is not given, power management will be disabled.
+ *
+ * TODO: filter configuration
*/
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/module.h>
+#include <linux/delay.h>
+#include <linux/jiffies.h>
+#include <linux/gpio/consumer.h>
+#include <linux/pm_runtime.h>
#include <linux/iio/iio.h>
@@ -51,10 +63,101 @@
#define MLX90614_TIMING_WAKEUP 34 /* time to hold SDA low for wake-up */
#define MLX90614_TIMING_STARTUP 250 /* time before first data after wake-up */
+#define MLX90614_AUTOSLEEP_DELAY 5000 /* default autosleep delay */
+
struct mlx90614_data {
struct i2c_client *client;
+ struct mutex lock; /* for EEPROM access only */
+ struct gpio_desc *wakeup_gpio; /* NULL to disable sleep/wake-up */
+ unsigned long ready_timestamp; /* in jiffies */
};
+/*
+ * Erase an address and write word.
+ * The mutex must be locked before calling.
+ */
+static s32 mlx90614_write_word(const struct i2c_client *client, u8 command,
+ u16 value)
+{
+ /*
+ * Note: The mlx90614 requires a PEC on writing but does not send us a
+ * valid PEC on reading. Hence, we cannot set I2C_CLIENT_PEC in
+ * i2c_client.flags. As a workaround, we use i2c_smbus_xfer here.
+ */
+ union i2c_smbus_data data;
+ s32 ret;
+
+ dev_dbg(&client->dev, "Writing 0x%x to address 0x%x", value, command);
+
+ data.word = 0x0000; /* erase command */
+ ret = i2c_smbus_xfer(client->adapter, client->addr,
+ client->flags | I2C_CLIENT_PEC,
+ I2C_SMBUS_WRITE, command,
+ I2C_SMBUS_WORD_DATA, &data);
+ if (ret < 0)
+ return ret;
+
+ msleep(MLX90614_TIMING_EEPROM);
+
+ data.word = value; /* actual write */
+ ret = i2c_smbus_xfer(client->adapter, client->addr,
+ client->flags | I2C_CLIENT_PEC,
+ I2C_SMBUS_WRITE, command,
+ I2C_SMBUS_WORD_DATA, &data);
+
+ msleep(MLX90614_TIMING_EEPROM);
+
+ return ret;
+}
+
+#ifdef CONFIG_PM
+/*
+ * If @startup is true, make sure MLX90614_TIMING_STARTUP ms have elapsed since
+ * the last wake-up. This is normally only needed to get a valid temperature
+ * reading. EEPROM access does not need such delay.
+ * Return 0 on success, <0 on error.
+ */
+static int mlx90614_power_get(struct mlx90614_data *data, bool startup)
+{
+ unsigned long now;
+
+ if (!data->wakeup_gpio)
+ return 0;
+
+ pm_runtime_get_sync(&data->client->dev);
+
+ if (startup) {
+ now = jiffies;
+ if (time_before(now, data->ready_timestamp) &&
+ msleep_interruptible(jiffies_to_msecs(
+ data->ready_timestamp - now)) != 0) {
+ pm_runtime_put_autosuspend(&data->client->dev);
+ return -EINTR;
+ }
+ }
+
+ return 0;
+}
+
+static void mlx90614_power_put(struct mlx90614_data *data)
+{
+ if (!data->wakeup_gpio)
+ return;
+
+ pm_runtime_mark_last_busy(&data->client->dev);
+ pm_runtime_put_autosuspend(&data->client->dev);
+}
+#else
+static inline int mlx90614_power_get(struct mlx90614_data *data, bool startup)
+{
+ return 0;
+}
+
+static inline void mlx90614_power_put(struct mlx90614_data *data)
+{
+}
+#endif
+
static int mlx90614_read_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *channel, int *val,
int *val2, long mask)
@@ -85,9 +188,19 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
return -EINVAL;
}
+ ret = mlx90614_power_get(data, true);
+ if (ret < 0)
+ return ret;
ret = i2c_smbus_read_word_data(data->client, cmd);
+ mlx90614_power_put(data);
+
if (ret < 0)
return ret;
+
+ /* MSB is an error flag */
+ if (ret & 0x8000)
+ return -EIO;
+
*val = ret;
return IIO_VAL_INT;
case IIO_CHAN_INFO_OFFSET:
@@ -97,6 +210,63 @@ static int mlx90614_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_SCALE:
*val = 20;
return IIO_VAL_INT;
+ case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
+ mlx90614_power_get(data, false);
+ mutex_lock(&data->lock);
+ ret = i2c_smbus_read_word_data(data->client,
+ MLX90614_EMISSIVITY);
+ mutex_unlock(&data->lock);
+ mlx90614_power_put(data);
+
+ if (ret < 0)
+ return ret;
+
+ if (ret == 65535) {
+ *val = 1;
+ *val2 = 0;
+ } else {
+ *val = 0;
+ *val2 = ret * 15259; /* 1/65535 ~ 0.000015259 */
+ }
+ return IIO_VAL_INT_PLUS_NANO;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int mlx90614_write_raw(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *channel, int val,
+ int val2, long mask)
+{
+ struct mlx90614_data *data = iio_priv(indio_dev);
+ s32 ret;
+
+ switch (mask) {
+ case IIO_CHAN_INFO_CALIBEMISSIVITY: /* 1/65535 / LSB */
+ if (val < 0 || val2 < 0 || val > 1 || (val == 1 && val2 != 0))
+ return -EINVAL;
+ val = val * 65535 + val2 / 15259; /* 1/65535 ~ 0.000015259 */
+
+ mlx90614_power_get(data, false);
+ mutex_lock(&data->lock);
+ ret = mlx90614_write_word(data->client, MLX90614_EMISSIVITY,
+ val);
+ mutex_unlock(&data->lock);
+ mlx90614_power_put(data);
+
+ return ret;
+ default:
+ return -EINVAL;
+ }
+}
+
+static int mlx90614_write_raw_get_fmt(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *channel,
+ long mask)
+{
+ switch (mask) {
+ case IIO_CHAN_INFO_CALIBEMISSIVITY:
+ return IIO_VAL_INT_PLUS_NANO;
default:
return -EINVAL;
}
@@ -115,7 +285,8 @@ static const struct iio_chan_spec mlx90614_channels[] = {
.type = IIO_TEMP,
.modified = 1,
.channel2 = IIO_MOD_TEMP_OBJECT,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_CALIBEMISSIVITY),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE),
},
@@ -125,7 +296,8 @@ static const struct iio_chan_spec mlx90614_channels[] = {
.modified = 1,
.channel = 1,
.channel2 = IIO_MOD_TEMP_OBJECT,
- .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
+ BIT(IIO_CHAN_INFO_CALIBEMISSIVITY),
.info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) |
BIT(IIO_CHAN_INFO_SCALE),
},
@@ -133,9 +305,103 @@ static const struct iio_chan_spec mlx90614_channels[] = {
static const struct iio_info mlx90614_info = {
.read_raw = mlx90614_read_raw,
+ .write_raw = mlx90614_write_raw,
+ .write_raw_get_fmt = mlx90614_write_raw_get_fmt,
.driver_module = THIS_MODULE,
};
+#ifdef CONFIG_PM
+static int mlx90614_sleep(struct mlx90614_data *data)
+{
+ s32 ret;
+
+ if (!data->wakeup_gpio) {
+ dev_dbg(&data->client->dev, "Sleep disabled");
+ return -ENOSYS;
+ }
+
+ dev_dbg(&data->client->dev, "Requesting sleep");
+
+ mutex_lock(&data->lock);
+ ret = i2c_smbus_xfer(data->client->adapter, data->client->addr,
+ data->client->flags | I2C_CLIENT_PEC,
+ I2C_SMBUS_WRITE, MLX90614_OP_SLEEP,
+ I2C_SMBUS_BYTE, NULL);
+ mutex_unlock(&data->lock);
+
+ return ret;
+}
+
+static int mlx90614_wakeup(struct mlx90614_data *data)
+{
+ if (!data->wakeup_gpio) {
+ dev_dbg(&data->client->dev, "Wake-up disabled");
+ return -ENOSYS;
+ }
+
+ dev_dbg(&data->client->dev, "Requesting wake-up");
+
+ i2c_lock_adapter(data->client->adapter);
+ gpiod_direction_output(data->wakeup_gpio, 0);
+ msleep(MLX90614_TIMING_WAKEUP);
+ gpiod_direction_input(data->wakeup_gpio);
+ i2c_unlock_adapter(data->client->adapter);
+
+ data->ready_timestamp = jiffies +
+ msecs_to_jiffies(MLX90614_TIMING_STARTUP);
+
+ /*
+ * Quirk: the i2c controller may get confused right after the
+ * wake-up signal has been sent. As a workaround, do a dummy read.
+ * If the read fails, the controller will probably be reset so that
+ * further reads will work.
+ */
+ i2c_smbus_read_word_data(data->client, MLX90614_CONFIG);
+
+ return 0;
+}
+
+/* Return wake-up GPIO or NULL if sleep functionality should be disabled. */
+static struct gpio_desc *mlx90614_probe_wakeup(struct i2c_client *client)
+{
+ struct gpio_desc *gpio;
+
+ if (!i2c_check_functionality(client->adapter,
+ I2C_FUNC_SMBUS_WRITE_BYTE)) {
+ dev_info(&client->dev,
+ "i2c adapter does not support SMBUS_WRITE_BYTE, sleep disabled");
+ return NULL;
+ }
+
+ gpio = devm_gpiod_get_optional(&client->dev, "wakeup", GPIOD_IN);
+
+ if (IS_ERR(gpio)) {
+ dev_warn(&client->dev,
+ "gpio acquisition failed with error %ld, sleep disabled",
+ PTR_ERR(gpio));
+ return NULL;
+ } else if (!gpio) {
+ dev_info(&client->dev,
+ "wakeup-gpio not found, sleep disabled");
+ }
+
+ return gpio;
+}
+#else
+static inline int mlx90614_sleep(struct mlx90614_data *data)
+{
+ return -ENOSYS;
+}
+static inline int mlx90614_wakeup(struct mlx90614_data *data)
+{
+ return -ENOSYS;
+}
+static inline struct gpio_desc *mlx90614_probe_wakeup(struct i2c_client *client)
+{
+ return NULL;
+}
+#endif
+
/* Return 0 for single sensor, 1 for dual sensor, <0 on error. */
static int mlx90614_probe_num_ir_sensors(struct i2c_client *client)
{
@@ -166,6 +432,10 @@ static int mlx90614_probe(struct i2c_client *client,
data = iio_priv(indio_dev);
i2c_set_clientdata(client, indio_dev);
data->client = client;
+ mutex_init(&data->lock);
+ data->wakeup_gpio = mlx90614_probe_wakeup(client);
+
+ mlx90614_wakeup(data);
indio_dev->dev.parent = &client->dev;
indio_dev->name = id->name;
@@ -188,12 +458,30 @@ static int mlx90614_probe(struct i2c_client *client,
return ret;
}
+ if (data->wakeup_gpio) {
+ pm_runtime_set_autosuspend_delay(&client->dev,
+ MLX90614_AUTOSLEEP_DELAY);
+ pm_runtime_use_autosuspend(&client->dev);
+ pm_runtime_set_active(&client->dev);
+ pm_runtime_enable(&client->dev);
+ }
+
return iio_device_register(indio_dev);
}
static int mlx90614_remove(struct i2c_client *client)
{
- iio_device_unregister(i2c_get_clientdata(client));
+ struct iio_dev *indio_dev = i2c_get_clientdata(client);
+ struct mlx90614_data *data = iio_priv(indio_dev);
+
+ iio_device_unregister(indio_dev);
+
+ if (data->wakeup_gpio) {
+ pm_runtime_disable(&client->dev);
+ if (!pm_runtime_status_suspended(&client->dev))
+ mlx90614_sleep(data);
+ pm_runtime_set_suspended(&client->dev);
+ }
return 0;
}
@@ -204,10 +492,67 @@ static const struct i2c_device_id mlx90614_id[] = {
};
MODULE_DEVICE_TABLE(i2c, mlx90614_id);
+#ifdef CONFIG_PM_SLEEP
+static int mlx90614_pm_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct mlx90614_data *data = iio_priv(indio_dev);
+
+ if (data->wakeup_gpio && pm_runtime_active(dev))
+ return mlx90614_sleep(data);
+
+ return 0;
+}
+
+static int mlx90614_pm_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct mlx90614_data *data = iio_priv(indio_dev);
+ int err;
+
+ if (data->wakeup_gpio) {
+ err = mlx90614_wakeup(data);
+ if (err < 0)
+ return err;
+
+ pm_runtime_disable(dev);
+ pm_runtime_set_active(dev);
+ pm_runtime_enable(dev);
+ }
+
+ return 0;
+}
+#endif
+
+#ifdef CONFIG_PM
+static int mlx90614_pm_runtime_suspend(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct mlx90614_data *data = iio_priv(indio_dev);
+
+ return mlx90614_sleep(data);
+}
+
+static int mlx90614_pm_runtime_resume(struct device *dev)
+{
+ struct iio_dev *indio_dev = i2c_get_clientdata(to_i2c_client(dev));
+ struct mlx90614_data *data = iio_priv(indio_dev);
+
+ return mlx90614_wakeup(data);
+}
+#endif
+
+static const struct dev_pm_ops mlx90614_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(mlx90614_pm_suspend, mlx90614_pm_resume)
+ SET_RUNTIME_PM_OPS(mlx90614_pm_runtime_suspend,
+ mlx90614_pm_runtime_resume, NULL)
+};
+
static struct i2c_driver mlx90614_driver = {
.driver = {
.name = "mlx90614",
.owner = THIS_MODULE,
+ .pm = &mlx90614_pm_ops,
},
.probe = mlx90614_probe,
.remove = mlx90614_remove,
diff --git a/drivers/iio/temperature/tmp006.c b/drivers/iio/temperature/tmp006.c
index 84a0789c3d9688..fcc49f89b9464c 100644
--- a/drivers/iio/temperature/tmp006.c
+++ b/drivers/iio/temperature/tmp006.c
@@ -41,8 +41,8 @@
#define TMP006_CONFIG_CR_MASK 0x0e00
#define TMP006_CONFIG_CR_SHIFT 9
-#define MANUFACTURER_MAGIC 0x5449
-#define DEVICE_MAGIC 0x0067
+#define TMP006_MANUFACTURER_MAGIC 0x5449
+#define TMP006_DEVICE_MAGIC 0x0067
struct tmp006_data {
struct i2c_client *client;
@@ -191,7 +191,7 @@ static bool tmp006_check_identification(struct i2c_client *client)
if (did < 0)
return false;
- return mid == MANUFACTURER_MAGIC && did == DEVICE_MAGIC;
+ return mid == TMP006_MANUFACTURER_MAGIC && did == TMP006_DEVICE_MAGIC;
}
static int tmp006_probe(struct i2c_client *client,
diff --git a/drivers/platform/goldfish/goldfish_pipe.c b/drivers/platform/goldfish/goldfish_pipe.c
index d9a09d9637d9a0..aad16bc9e63075 100644
--- a/drivers/platform/goldfish/goldfish_pipe.c
+++ b/drivers/platform/goldfish/goldfish_pipe.c
@@ -158,8 +158,8 @@ static u32 goldfish_cmd_status(struct goldfish_pipe *pipe, u32 cmd)
struct goldfish_pipe_dev *dev = pipe->dev;
spin_lock_irqsave(&dev->lock, flags);
- gf_write64((u64)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL,
- dev->base + PIPE_REG_CHANNEL_HIGH);
+ gf_write_ptr(pipe, dev->base + PIPE_REG_CHANNEL,
+ dev->base + PIPE_REG_CHANNEL_HIGH);
writel(cmd, dev->base + PIPE_REG_COMMAND);
status = readl(dev->base + PIPE_REG_STATUS);
spin_unlock_irqrestore(&dev->lock, flags);
@@ -172,8 +172,8 @@ static void goldfish_cmd(struct goldfish_pipe *pipe, u32 cmd)
struct goldfish_pipe_dev *dev = pipe->dev;
spin_lock_irqsave(&dev->lock, flags);
- gf_write64((u64)(unsigned long)pipe, dev->base + PIPE_REG_CHANNEL,
- dev->base + PIPE_REG_CHANNEL_HIGH);
+ gf_write_ptr(pipe, dev->base + PIPE_REG_CHANNEL,
+ dev->base + PIPE_REG_CHANNEL_HIGH);
writel(cmd, dev->base + PIPE_REG_COMMAND);
spin_unlock_irqrestore(&dev->lock, flags);
}
@@ -327,12 +327,12 @@ static ssize_t goldfish_pipe_read_write(struct file *filp, char __user *buffer,
spin_lock_irqsave(&dev->lock, irq_flags);
if (access_with_param(dev, CMD_WRITE_BUFFER + cmd_offset,
address, avail, pipe, &status)) {
- gf_write64((u64)(unsigned long)pipe,
- dev->base + PIPE_REG_CHANNEL,
- dev->base + PIPE_REG_CHANNEL_HIGH);
+ gf_write_ptr(pipe, dev->base + PIPE_REG_CHANNEL,
+ dev->base + PIPE_REG_CHANNEL_HIGH);
writel(avail, dev->base + PIPE_REG_SIZE);
- gf_write64(address, dev->base + PIPE_REG_ADDRESS,
- dev->base + PIPE_REG_ADDRESS_HIGH);
+ gf_write_ptr((void *)address,
+ dev->base + PIPE_REG_ADDRESS,
+ dev->base + PIPE_REG_ADDRESS_HIGH);
writel(CMD_WRITE_BUFFER + cmd_offset,
dev->base + PIPE_REG_COMMAND);
status = readl(dev->base + PIPE_REG_STATUS);
diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig
index bfacf69f68f4c5..7f6cae5beb90fc 100644
--- a/drivers/staging/Kconfig
+++ b/drivers/staging/Kconfig
@@ -108,8 +108,8 @@ source "drivers/staging/clocking-wizard/Kconfig"
source "drivers/staging/fbtft/Kconfig"
-source "drivers/staging/i2o/Kconfig"
-
source "drivers/staging/fsl-mc/Kconfig"
+source "drivers/staging/wilc1000/Kconfig"
+
endif # STAGING
diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile
index 2bbd1bf04c55d5..347f6477aa3eb4 100644
--- a/drivers/staging/Makefile
+++ b/drivers/staging/Makefile
@@ -23,7 +23,7 @@ obj-$(CONFIG_VT6656) += vt6656/
obj-$(CONFIG_VME_BUS) += vme/
obj-$(CONFIG_IIO) += iio/
obj-$(CONFIG_FB_SM7XX) += sm7xxfb/
-obj-$(CONFIG_FB_SM7XX) += sm750fb/
+obj-$(CONFIG_FB_SM750) += sm750fb/
obj-$(CONFIG_FB_XGI) += xgifb/
obj-$(CONFIG_USB_EMXX) += emxx_udc/
obj-$(CONFIG_FT1000) += ft1000/
@@ -46,5 +46,5 @@ obj-$(CONFIG_CRYPTO_SKEIN) += skein/
obj-$(CONFIG_UNISYSSPAR) += unisys/
obj-$(CONFIG_COMMON_CLK_XLNX_CLKWZRD) += clocking-wizard/
obj-$(CONFIG_FB_TFT) += fbtft/
-obj-$(CONFIG_I2O) += i2o/
obj-$(CONFIG_FSL_MC_BUS) += fsl-mc/
+obj-$(CONFIG_WILC1000) += wilc1000/
diff --git a/drivers/staging/android/Kconfig b/drivers/staging/android/Kconfig
index 8feb9048e62ffa..24d657b3ab9946 100644
--- a/drivers/staging/android/Kconfig
+++ b/drivers/staging/android/Kconfig
@@ -22,11 +22,20 @@ config ANDROID_TIMED_GPIO
tristate "Android timed gpio driver"
depends on GPIOLIB && ANDROID_TIMED_OUTPUT
default n
+ ---help---
+ Unlike generic gpio is to allow programs to access and manipulate gpio
+ registers from user space, timed output/gpio is a system to allow changing
+ a gpio pin and restore it automatically after a specified timeout.
config ANDROID_LOW_MEMORY_KILLER
bool "Android Low Memory Killer"
---help---
- Registers processes to be killed when memory is low
+ Registers processes to be killed when low memory conditions, this is useful
+ as there is no particular swap space on android.
+
+ The registered process will kills according to the priorities in android init
+ scripts (/init.rc), and it defines priority values with minimum free memory size
+ for each priority.
config SYNC
bool "Synchronization framework"
diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c
index b0b96ab31954a9..6f48112635571f 100644
--- a/drivers/staging/android/ion/ion.c
+++ b/drivers/staging/android/ion/ion.c
@@ -1579,6 +1579,7 @@ struct ion_device *ion_device_create(long (*custom_ioctl)
ret = misc_register(&idev->dev);
if (ret) {
pr_err("ion: failed to register misc device.\n");
+ kfree(idev);
return ERR_PTR(ret);
}
diff --git a/drivers/staging/android/ion/ion_chunk_heap.c b/drivers/staging/android/ion/ion_chunk_heap.c
index 3e6ec2ee680289..54746157d799a6 100644
--- a/drivers/staging/android/ion/ion_chunk_heap.c
+++ b/drivers/staging/android/ion/ion_chunk_heap.c
@@ -173,7 +173,7 @@ struct ion_heap *ion_chunk_heap_create(struct ion_platform_heap *heap_data)
chunk_heap->heap.ops = &chunk_heap_ops;
chunk_heap->heap.type = ION_HEAP_TYPE_CHUNK;
chunk_heap->heap.flags = ION_HEAP_FLAG_DEFER_FREE;
- pr_info("%s: base %lu size %zu align %ld\n", __func__, chunk_heap->base,
+ pr_debug("%s: base %lu size %zu align %ld\n", __func__, chunk_heap->base,
heap_data->size, heap_data->align);
return &chunk_heap->heap;
diff --git a/drivers/staging/android/ion/ion_priv.h b/drivers/staging/android/ion/ion_priv.h
index 18a5f93e13b71b..52f1cd1a67ed7c 100644
--- a/drivers/staging/android/ion/ion_priv.h
+++ b/drivers/staging/android/ion/ion_priv.h
@@ -33,7 +33,7 @@ struct ion_buffer *ion_handle_buffer(struct ion_handle *handle);
/**
* struct ion_buffer - metadata for a particular buffer
- * @ref: refernce count
+ * @ref: reference count
* @node: node in the ion_device buffers tree
* @dev: back pointer to the ion_device
* @heap: back pointer to the heap the buffer came from
@@ -46,7 +46,7 @@ struct ion_buffer *ion_handle_buffer(struct ion_handle *handle);
* an ion_phys_addr_t (and someday a phys_addr_t)
* @lock: protects the buffers cnt fields
* @kmap_cnt: number of times the buffer is mapped to the kernel
- * @vaddr: the kenrel mapping if kmap_cnt is not zero
+ * @vaddr: the kernel mapping if kmap_cnt is not zero
* @dmap_cnt: number of times the buffer is mapped for dma
* @sg_table: the sg table for the buffer if dmap_cnt is not zero
* @pages: flat array of pages in the buffer -- used by fault
@@ -266,7 +266,7 @@ void ion_heap_freelist_add(struct ion_heap *heap, struct ion_buffer *buffer);
/**
* ion_heap_freelist_drain - drain the deferred free list
* @heap: the heap
- * @size: ammount of memory to drain in bytes
+ * @size: amount of memory to drain in bytes
*
* Drains the indicated amount of memory from the deferred freelist immediately.
* Returns the total amount freed. The total freed may be higher depending
diff --git a/drivers/staging/android/ion/ion_test.c b/drivers/staging/android/ion/ion_test.c
index 3bc461cbbfa3d0..7d6e6b6bc894c9 100644
--- a/drivers/staging/android/ion/ion_test.c
+++ b/drivers/staging/android/ion/ion_test.c
@@ -261,7 +261,20 @@ static int __init ion_test_probe(struct platform_device *pdev)
return 0;
}
+static int ion_test_remove(struct platform_device *pdev)
+{
+ struct ion_test_device *testdev;
+
+ testdev = platform_get_drvdata(pdev);
+ if (!testdev)
+ return -ENODATA;
+
+ return misc_deregister(&testdev->misc);
+}
+
+static struct platform_device *ion_test_pdev;
static struct platform_driver ion_test_platform_driver = {
+ .remove = ion_test_remove,
.driver = {
.name = "ion-test",
},
@@ -269,13 +282,18 @@ static struct platform_driver ion_test_platform_driver = {
static int __init ion_test_init(void)
{
- platform_device_register_simple("ion-test", -1, NULL, 0);
+ ion_test_pdev = platform_device_register_simple("ion-test",
+ -1, NULL, 0);
+ if (!ion_test_pdev)
+ return -ENODEV;
+
return platform_driver_probe(&ion_test_platform_driver, ion_test_probe);
}
static void __exit ion_test_exit(void)
{
platform_driver_unregister(&ion_test_platform_driver);
+ platform_device_unregister(ion_test_pdev);
}
module_init(ion_test_init);
diff --git a/drivers/staging/android/ion/tegra/tegra_ion.c b/drivers/staging/android/ion/tegra/tegra_ion.c
index 5b8ef0e66010e4..4d3c516cc15e9c 100644
--- a/drivers/staging/android/ion/tegra/tegra_ion.c
+++ b/drivers/staging/android/ion/tegra/tegra_ion.c
@@ -15,6 +15,7 @@
*/
#include <linux/err.h>
+#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
#include "../ion.h"
diff --git a/drivers/staging/android/lowmemorykiller.c b/drivers/staging/android/lowmemorykiller.c
index feafa172b155a2..defddf5f80dddf 100644
--- a/drivers/staging/android/lowmemorykiller.c
+++ b/drivers/staging/android/lowmemorykiller.c
@@ -156,20 +156,27 @@ static unsigned long lowmem_scan(struct shrinker *s, struct shrink_control *sc)
p->pid, p->comm, oom_score_adj, tasksize);
}
if (selected) {
- lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n",
- selected->pid, selected->comm,
- selected_oom_score_adj, selected_tasksize);
- lowmem_deathpending_timeout = jiffies + HZ;
+ task_lock(selected);
+ if (!selected->mm) {
+ /* Already exited, cannot do mark_tsk_oom_victim() */
+ task_unlock(selected);
+ goto out;
+ }
/*
* FIXME: lowmemorykiller shouldn't abuse global OOM killer
* infrastructure. There is no real reason why the selected
* task should have access to the memory reserves.
*/
mark_tsk_oom_victim(selected);
+ task_unlock(selected);
+ lowmem_print(1, "send sigkill to %d (%s), adj %hd, size %d\n",
+ selected->pid, selected->comm,
+ selected_oom_score_adj, selected_tasksize);
+ lowmem_deathpending_timeout = jiffies + HZ;
send_sig(SIGKILL, selected, 0);
rem += selected_tasksize;
}
-
+out:
lowmem_print(4, "lowmem_scan %lu, %x, return %lu\n",
sc->nr_to_scan, sc->gfp_mask, rem);
rcu_read_unlock();
diff --git a/drivers/staging/android/uapi/ion.h b/drivers/staging/android/uapi/ion.h
index 6aa4956733708b..68a14b4e21cb3e 100644
--- a/drivers/staging/android/uapi/ion.h
+++ b/drivers/staging/android/uapi/ion.h
@@ -179,7 +179,7 @@ struct ion_custom_data {
* DOC: ION_IOC_SYNC - syncs a shared file descriptors to memory
*
* Deprecated in favor of using the dma_buf api's correctly (syncing
- * will happend automatically when the buffer is mapped to a device).
+ * will happen automatically when the buffer is mapped to a device).
* If necessary should be used after touching a cached buffer from the cpu,
* this will make the buffer in memory coherent.
*/
diff --git a/drivers/staging/comedi/Kconfig b/drivers/staging/comedi/Kconfig
index 61c6351f55ac4c..7dee73dfbf88ff 100644
--- a/drivers/staging/comedi/Kconfig
+++ b/drivers/staging/comedi/Kconfig
@@ -1247,16 +1247,22 @@ config COMEDI_8254
tristate
config COMEDI_8255
- tristate "Generic 8255 support"
+ tristate
+
+config COMEDI_8255_SA
+ tristate "Standalone 8255 support"
+ select COMEDI_8255
---help---
- Enable generic 8255 support.
+ Enable support for 8255 digital I/O as a standalone driver.
You should enable compilation this driver if you plan to use a board
- that has an 8255 chip. For multifunction boards, the main driver will
- configure the 8255 subdevice automatically.
+ that has an 8255 chip at a known I/O base address and there are no
+ other Comedi drivers for the board.
- Note that most PCI based 8255 boards use the 8255_pci driver as a
- wrapper around this driver.
+ Note that Comedi drivers for most multi-function boards incorporating
+ an 8255 chip use the 'comedi_8255' module. Most PCI-based 8255
+ boards use the 8255_pci driver as a wrapper around the 'comedi_8255'
+ module.
To compile this driver as a module, choose M here: the module will be
called 8255.
diff --git a/drivers/staging/comedi/comedi.h b/drivers/staging/comedi/comedi.h
index 7455740773527c..66edda190b75cd 100644
--- a/drivers/staging/comedi/comedi.h
+++ b/drivers/staging/comedi/comedi.h
@@ -217,7 +217,7 @@
#define SDF_RUNNING 0x08000000 /* subdevice is acquiring data */
#define SDF_LSAMPL 0x10000000 /* subdevice uses 32-bit samples */
#define SDF_PACKED 0x20000000 /* subdevice can do packed DIO */
-/* re recyle these flags for PWM */
+/* re recycle these flags for PWM */
#define SDF_PWM_COUNTER SDF_MODE0 /* PWM can automatically switch off */
#define SDF_PWM_HBRIDGE SDF_MODE1 /* PWM is signed (H-bridge) */
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index e78ddbe5a954f9..146ab009d5f7a3 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -44,6 +44,23 @@
#include "comedi_internal.h"
/**
+ * comedi_subdevice "runflags"
+ * @COMEDI_SRF_RT: DEPRECATED: command is running real-time
+ * @COMEDI_SRF_ERROR: indicates an COMEDI_CB_ERROR event has occurred
+ * since the last command was started
+ * @COMEDI_SRF_RUNNING: command is running
+ * @COMEDI_SRF_FREE_SPRIV: free s->private on detach
+ *
+ * @COMEDI_SRF_BUSY_MASK: runflags that indicate the subdevice is "busy"
+ */
+#define COMEDI_SRF_RT BIT(1)
+#define COMEDI_SRF_ERROR BIT(2)
+#define COMEDI_SRF_RUNNING BIT(27)
+#define COMEDI_SRF_FREE_SPRIV BIT(31)
+
+#define COMEDI_SRF_BUSY_MASK (COMEDI_SRF_ERROR | COMEDI_SRF_RUNNING)
+
+/**
* struct comedi_file - per-file private data for comedi device
* @dev: comedi_device struct
* @read_subdev: current "read" subdevice
@@ -679,8 +696,28 @@ static bool comedi_is_subdevice_idle(struct comedi_subdevice *s)
return !(runflags & COMEDI_SRF_BUSY_MASK);
}
+bool comedi_can_auto_free_spriv(struct comedi_subdevice *s)
+{
+ unsigned runflags = __comedi_get_subdevice_runflags(s);
+
+ return runflags & COMEDI_SRF_FREE_SPRIV;
+}
+
+/**
+ * comedi_set_spriv_auto_free - mark subdevice private data as freeable
+ * @s: comedi_subdevice struct
+ *
+ * Mark the subdevice as having a pointer to private data that can be
+ * automatically freed by the comedi core during the detach.
+ */
+void comedi_set_spriv_auto_free(struct comedi_subdevice *s)
+{
+ __comedi_set_subdevice_runflags(s, COMEDI_SRF_FREE_SPRIV);
+}
+EXPORT_SYMBOL_GPL(comedi_set_spriv_auto_free);
+
/**
- * comedi_alloc_spriv() - Allocate memory for the subdevice private data.
+ * comedi_alloc_spriv - Allocate memory for the subdevice private data.
* @s: comedi_subdevice struct
* @size: size of the memory to allocate
*
@@ -691,7 +728,7 @@ void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size)
{
s->private = kzalloc(size, GFP_KERNEL);
if (s->private)
- s->runflags |= COMEDI_SRF_FREE_SPRIV;
+ comedi_set_spriv_auto_free(s);
return s->private;
}
EXPORT_SYMBOL_GPL(comedi_alloc_spriv);
@@ -1725,7 +1762,7 @@ cleanup:
/*
* COMEDI_CMDTEST ioctl
- * asynchronous aquisition command testing
+ * asynchronous acquisition command testing
*
* arg:
* pointer to comedi_cmd structure
diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h
index 3b918538847e61..cd9437f72c3535 100644
--- a/drivers/staging/comedi/comedi_internal.h
+++ b/drivers/staging/comedi/comedi_internal.h
@@ -33,6 +33,7 @@ struct comedi_buf_map *comedi_buf_map_from_subdev_get(
struct comedi_subdevice *s);
unsigned int comedi_buf_write_n_allocated(struct comedi_subdevice *s);
void comedi_device_cancel_all(struct comedi_device *dev);
+bool comedi_can_auto_free_spriv(struct comedi_subdevice *s);
extern unsigned int comedi_default_buf_size_kb;
extern unsigned int comedi_default_buf_maxsize_kb;
diff --git a/drivers/staging/comedi/comedidev.h b/drivers/staging/comedi/comedidev.h
index dfab5a84b011f5..28f26062a54c75 100644
--- a/drivers/staging/comedi/comedidev.h
+++ b/drivers/staging/comedi/comedidev.h
@@ -303,26 +303,10 @@ void comedi_event(struct comedi_device *dev, struct comedi_subdevice *s);
struct comedi_device *comedi_dev_get_from_minor(unsigned minor);
int comedi_dev_put(struct comedi_device *dev);
-/**
- * comedi_subdevice "runflags"
- * @COMEDI_SRF_RT: DEPRECATED: command is running real-time
- * @COMEDI_SRF_ERROR: indicates an COMEDI_CB_ERROR event has occurred
- * since the last command was started
- * @COMEDI_SRF_RUNNING: command is running
- * @COMEDI_SRF_FREE_SPRIV: free s->private on detach
- *
- * @COMEDI_SRF_BUSY_MASK: runflags that indicate the subdevice is "busy"
- */
-#define COMEDI_SRF_RT BIT(1)
-#define COMEDI_SRF_ERROR BIT(2)
-#define COMEDI_SRF_RUNNING BIT(27)
-#define COMEDI_SRF_FREE_SPRIV BIT(31)
-
-#define COMEDI_SRF_BUSY_MASK (COMEDI_SRF_ERROR | COMEDI_SRF_RUNNING)
-
bool comedi_is_subdevice_running(struct comedi_subdevice *s);
void *comedi_alloc_spriv(struct comedi_subdevice *s, size_t size);
+void comedi_set_spriv_auto_free(struct comedi_subdevice *s);
int comedi_check_chanlist(struct comedi_subdevice *s,
int n,
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 57dcffe0020458..ed0b60c925def8 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -125,7 +125,7 @@ static void comedi_device_detach_cleanup(struct comedi_device *dev)
if (dev->subdevices) {
for (i = 0; i < dev->n_subdevices; i++) {
s = &dev->subdevices[i];
- if (s->runflags & COMEDI_SRF_FREE_SPRIV)
+ if (comedi_can_auto_free_spriv(s))
kfree(s->private);
comedi_free_subdevice_minor(s);
if (s->async) {
diff --git a/drivers/staging/comedi/drivers/8255.c b/drivers/staging/comedi/drivers/8255.c
index ba89321df65d8e..b79d3764a8a0a7 100644
--- a/drivers/staging/comedi/drivers/8255.c
+++ b/drivers/staging/comedi/drivers/8255.c
@@ -53,221 +53,6 @@
#include "8255.h"
-struct subdev_8255_private {
- unsigned long regbase;
- int (*io)(struct comedi_device *, int, int, int, unsigned long);
-};
-
-static int subdev_8255_io(struct comedi_device *dev,
- int dir, int port, int data, unsigned long regbase)
-{
- if (dir) {
- outb(data, dev->iobase + regbase + port);
- return 0;
- }
- return inb(dev->iobase + regbase + port);
-}
-
-static int subdev_8255_mmio(struct comedi_device *dev,
- int dir, int port, int data, unsigned long regbase)
-{
- if (dir) {
- writeb(data, dev->mmio + regbase + port);
- return 0;
- }
- return readb(dev->mmio + regbase + port);
-}
-
-static int subdev_8255_insn(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
- struct subdev_8255_private *spriv = s->private;
- unsigned long regbase = spriv->regbase;
- unsigned int mask;
- unsigned int v;
-
- mask = comedi_dio_update_state(s, data);
- if (mask) {
- if (mask & 0xff)
- spriv->io(dev, 1, I8255_DATA_A_REG,
- s->state & 0xff, regbase);
- if (mask & 0xff00)
- spriv->io(dev, 1, I8255_DATA_B_REG,
- (s->state >> 8) & 0xff, regbase);
- if (mask & 0xff0000)
- spriv->io(dev, 1, I8255_DATA_C_REG,
- (s->state >> 16) & 0xff, regbase);
- }
-
- v = spriv->io(dev, 0, I8255_DATA_A_REG, 0, regbase);
- v |= (spriv->io(dev, 0, I8255_DATA_B_REG, 0, regbase) << 8);
- v |= (spriv->io(dev, 0, I8255_DATA_C_REG, 0, regbase) << 16);
-
- data[1] = v;
-
- return insn->n;
-}
-
-static void subdev_8255_do_config(struct comedi_device *dev,
- struct comedi_subdevice *s)
-{
- struct subdev_8255_private *spriv = s->private;
- unsigned long regbase = spriv->regbase;
- int config;
-
- config = I8255_CTRL_CW;
- /* 1 in io_bits indicates output, 1 in config indicates input */
- if (!(s->io_bits & 0x0000ff))
- config |= I8255_CTRL_A_IO;
- if (!(s->io_bits & 0x00ff00))
- config |= I8255_CTRL_B_IO;
- if (!(s->io_bits & 0x0f0000))
- config |= I8255_CTRL_C_LO_IO;
- if (!(s->io_bits & 0xf00000))
- config |= I8255_CTRL_C_HI_IO;
-
- spriv->io(dev, 1, I8255_CTRL_REG, config, regbase);
-}
-
-static int subdev_8255_insn_config(struct comedi_device *dev,
- struct comedi_subdevice *s,
- struct comedi_insn *insn,
- unsigned int *data)
-{
- unsigned int chan = CR_CHAN(insn->chanspec);
- unsigned int mask;
- int ret;
-
- if (chan < 8)
- mask = 0x0000ff;
- else if (chan < 16)
- mask = 0x00ff00;
- else if (chan < 20)
- mask = 0x0f0000;
- else
- mask = 0xf00000;
-
- ret = comedi_dio_insn_config(dev, s, insn, data, mask);
- if (ret)
- return ret;
-
- subdev_8255_do_config(dev, s);
-
- return insn->n;
-}
-
-static int __subdev_8255_init(struct comedi_device *dev,
- struct comedi_subdevice *s,
- int (*io)(struct comedi_device *,
- int, int, int, unsigned long),
- unsigned long regbase,
- bool is_mmio)
-{
- struct subdev_8255_private *spriv;
-
- spriv = comedi_alloc_spriv(s, sizeof(*spriv));
- if (!spriv)
- return -ENOMEM;
-
- if (io)
- spriv->io = io;
- else if (is_mmio)
- spriv->io = subdev_8255_mmio;
- else
- spriv->io = subdev_8255_io;
- spriv->regbase = regbase;
-
- s->type = COMEDI_SUBD_DIO;
- s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
- s->n_chan = 24;
- s->range_table = &range_digital;
- s->maxdata = 1;
- s->insn_bits = subdev_8255_insn;
- s->insn_config = subdev_8255_insn_config;
-
- subdev_8255_do_config(dev, s);
-
- return 0;
-}
-
-/**
- * subdev_8255_init - initialize DIO subdevice for driving I/O mapped 8255
- * @dev: comedi device owning subdevice
- * @s: comedi subdevice to initialize
- * @io: (optional) register I/O call-back function
- * @regbase: offset of 8255 registers from dev->iobase, or call-back context
- *
- * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip.
- *
- * If the optional I/O call-back function is provided, its prototype is of
- * the following form:
- *
- * int my_8255_callback(struct comedi_device *dev,
- * struct comedi_subdevice *s, int dir, int port,
- * int data, unsigned long regbase);
- *
- * where 'dev', 's', and 'regbase' match the values passed to this function,
- * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir'
- * is the direction (0 for read, 1 for write) and 'data' is the value to be
- * written. It should return 0 if writing or the value read if reading.
- *
- * If the optional I/O call-back function is not provided, an internal
- * call-back function is used which uses consecutive I/O port addresses
- * starting at dev->iobase + regbase.
- *
- * Return: -ENOMEM if failed to allocate memory, zero on success.
- */
-int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*io)(struct comedi_device *,
- int, int, int, unsigned long),
- unsigned long regbase)
-{
- return __subdev_8255_init(dev, s, io, regbase, false);
-}
-EXPORT_SYMBOL_GPL(subdev_8255_init);
-
-/**
- * subdev_8255_mm_init - initialize DIO subdevice for driving mmio-mapped 8255
- * @dev: comedi device owning subdevice
- * @s: comedi subdevice to initialize
- * @io: (optional) register I/O call-back function
- * @regbase: offset of 8255 registers from dev->mmio, or call-back context
- *
- * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip.
- *
- * If the optional I/O call-back function is provided, its prototype is of
- * the following form:
- *
- * int my_8255_callback(struct comedi_device *dev,
- * struct comedi_subdevice *s, int dir, int port,
- * int data, unsigned long regbase);
- *
- * where 'dev', 's', and 'regbase' match the values passed to this function,
- * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir'
- * is the direction (0 for read, 1 for write) and 'data' is the value to be
- * written. It should return 0 if writing or the value read if reading.
- *
- * If the optional I/O call-back function is not provided, an internal
- * call-back function is used which uses consecutive MMIO virtual addresses
- * starting at dev->mmio + regbase.
- *
- * Return: -ENOMEM if failed to allocate memory, zero on success.
- */
-int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s,
- int (*io)(struct comedi_device *,
- int, int, int, unsigned long),
- unsigned long regbase)
-{
- return __subdev_8255_init(dev, s, io, regbase, true);
-}
-EXPORT_SYMBOL_GPL(subdev_8255_mm_init);
-
-/*
- * Start of the 8255 standalone device
- */
-
static int dev_8255_attach(struct comedi_device *dev,
struct comedi_devconfig *it)
{
@@ -306,8 +91,15 @@ static int dev_8255_attach(struct comedi_device *dev,
s->type = COMEDI_SUBD_UNUSED;
} else {
ret = subdev_8255_init(dev, s, NULL, iobase);
- if (ret)
+ if (ret) {
+ /*
+ * Release the I/O port region here, as the
+ * "detach" handler cannot find it.
+ */
+ release_region(iobase, I8255_SIZE);
+ s->type = COMEDI_SUBD_UNUSED;
return ret;
+ }
}
}
@@ -317,14 +109,14 @@ static int dev_8255_attach(struct comedi_device *dev,
static void dev_8255_detach(struct comedi_device *dev)
{
struct comedi_subdevice *s;
- struct subdev_8255_private *spriv;
int i;
for (i = 0; i < dev->n_subdevices; i++) {
s = &dev->subdevices[i];
if (s->type != COMEDI_SUBD_UNUSED) {
- spriv = s->private;
- release_region(spriv->regbase, I8255_SIZE);
+ unsigned long regbase = subdev_8255_regbase(s);
+
+ release_region(regbase, I8255_SIZE);
}
}
}
@@ -338,5 +130,5 @@ static struct comedi_driver dev_8255_driver = {
module_comedi_driver(dev_8255_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("Comedi driver for standalone 8255 devices");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/8255.h b/drivers/staging/comedi/drivers/8255.h
index 934b940ebd3cfa..41823de69b77c1 100644
--- a/drivers/staging/comedi/drivers/8255.h
+++ b/drivers/staging/comedi/drivers/8255.h
@@ -19,8 +19,6 @@
#ifndef _8255_H
#define _8255_H
-#include "../comedidev.h"
-
#define I8255_SIZE 0x04
#define I8255_DATA_A_REG 0x00
@@ -35,14 +33,19 @@
#define I8255_CTRL_A_MODE(x) ((x) << 5)
#define I8255_CTRL_CW (1 << 7)
-int subdev_8255_init(struct comedi_device *, struct comedi_subdevice *,
- int (*io)(struct comedi_device *,
- int, int, int, unsigned long),
+struct comedi_device;
+struct comedi_subdevice;
+
+int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
+ int (*io)(struct comedi_device *dev, int dir, int port,
+ int data, unsigned long regbase),
unsigned long regbase);
-int subdev_8255_mm_init(struct comedi_device *, struct comedi_subdevice *,
- int (*io)(struct comedi_device *,
- int, int, int, unsigned long),
+int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s,
+ int (*io)(struct comedi_device *dev, int dir, int port,
+ int data, unsigned long regbase),
unsigned long regbase);
+unsigned long subdev_8255_regbase(struct comedi_subdevice *s);
+
#endif
diff --git a/drivers/staging/comedi/drivers/Makefile b/drivers/staging/comedi/drivers/Makefile
index d6d83400601583..5764dc9a68933a 100644
--- a/drivers/staging/comedi/drivers/Makefile
+++ b/drivers/staging/comedi/drivers/Makefile
@@ -139,7 +139,8 @@ obj-$(CONFIG_COMEDI_NI_TIOCMD) += ni_tiocmd.o
obj-$(CONFIG_COMEDI_NI_LABPC) += ni_labpc_common.o
obj-$(CONFIG_COMEDI_NI_LABPC_ISADMA) += ni_labpc_isadma.o
-obj-$(CONFIG_COMEDI_8255) += 8255.o
+obj-$(CONFIG_COMEDI_8255) += comedi_8255.o
+obj-$(CONFIG_COMEDI_8255_SA) += 8255.o
obj-$(CONFIG_COMEDI_AMPLC_DIO200) += amplc_dio200_common.o
obj-$(CONFIG_COMEDI_AMPLC_PC236) += amplc_pc236_common.o
obj-$(CONFIG_COMEDI_DAS08) += das08.o
diff --git a/drivers/staging/comedi/drivers/addi_watchdog.h b/drivers/staging/comedi/drivers/addi_watchdog.h
index 83b47befa4d17e..3f8e7388bbca2d 100644
--- a/drivers/staging/comedi/drivers/addi_watchdog.h
+++ b/drivers/staging/comedi/drivers/addi_watchdog.h
@@ -1,7 +1,7 @@
#ifndef _ADDI_WATCHDOG_H
#define _ADDI_WATCHDOG_H
-#include "../comedidev.h"
+struct comedi_subdevice;
void addi_watchdog_reset(unsigned long iobase);
int addi_watchdog_init(struct comedi_subdevice *, unsigned long iobase);
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.c b/drivers/staging/comedi/drivers/amplc_dio200.c
index 4fe118380218b4..f5cfa71a90c6c5 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200.c
@@ -1,23 +1,24 @@
/*
- comedi/drivers/amplc_dio200.c
-
- Driver for Amplicon PC212E, PC214E, PC215E, PC218E, PC272E.
-
- Copyright (C) 2005-2013 MEV Ltd. <http://www.mev.co.uk/>
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1998,2000 David A. Schleef <ds@schleef.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 2 of the License, or
- (at your option) any later version.
+ * comedi/drivers/amplc_dio200.c
+ *
+ * Driver for Amplicon PC212E, PC214E, PC215E, PC218E, PC272E.
+ *
+ * Copyright (C) 2005-2013 MEV Ltd. <http://www.mev.co.uk/>
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1998,2000 David A. Schleef <ds@schleef.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 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.
+ */
- 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.
-*/
/*
* Driver: amplc_dio200
* Description: Amplicon 200 Series ISA Digital I/O
diff --git a/drivers/staging/comedi/drivers/amplc_dio200.h b/drivers/staging/comedi/drivers/amplc_dio200.h
index d6d6a265c4610b..53fb86d59fc3a0 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200.h
+++ b/drivers/staging/comedi/drivers/amplc_dio200.h
@@ -1,28 +1,32 @@
/*
- comedi/drivers/amplc_dio.h
-
- Header for amplc_dio200.c, amplc_dio200_common.c and
- amplc_dio200_pci.c.
-
- Copyright (C) 2005-2013 MEV Ltd. <http://www.mev.co.uk/>
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1998,2000 David A. Schleef <ds@schleef.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 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.
-*/
+ * comedi/drivers/amplc_dio.h
+ *
+ * Header for amplc_dio200.c, amplc_dio200_common.c and
+ * amplc_dio200_pci.c.
+ *
+ * Copyright (C) 2005-2013 MEV Ltd. <http://www.mev.co.uk/>
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1998,2000 David A. Schleef <ds@schleef.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 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.
+ */
#ifndef AMPLC_DIO200_H_INCLUDED
#define AMPLC_DIO200_H_INCLUDED
+#include <linux/types.h>
+
+struct comedi_device;
+
/*
* Subdevice types.
*/
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_common.c b/drivers/staging/comedi/drivers/amplc_dio200_common.c
index d15a3dc1216a0a..d1539e798ffdf2 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_common.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_common.c
@@ -1,23 +1,23 @@
/*
- comedi/drivers/amplc_dio200_common.c
-
- Common support code for "amplc_dio200" and "amplc_dio200_pci".
-
- Copyright (C) 2005-2013 MEV Ltd. <http://www.mev.co.uk/>
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1998,2000 David A. Schleef <ds@schleef.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 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.
-*/
+ * comedi/drivers/amplc_dio200_common.c
+ *
+ * Common support code for "amplc_dio200" and "amplc_dio200_pci".
+ *
+ * Copyright (C) 2005-2013 MEV Ltd. <http://www.mev.co.uk/>
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1998,2000 David A. Schleef <ds@schleef.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 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.
+ */
#include <linux/module.h>
#include <linux/interrupt.h>
@@ -337,9 +337,10 @@ static int dio200_handle_read_intr(struct comedi_device *dev,
* interested in (just in case there's a race
* condition).
*/
- if (triggered & subpriv->enabled_isns)
+ if (triggered & subpriv->enabled_isns) {
/* Collect scan data. */
dio200_read_scan_intr(dev, s, triggered);
+ }
}
}
spin_unlock_irqrestore(&subpriv->spinlock, flags);
@@ -576,12 +577,13 @@ static int dio200_subdev_8254_init(struct comedi_device *dev,
regshift = 0;
}
- if (dev->mmio)
+ if (dev->mmio) {
i8254 = comedi_8254_mm_init(dev->mmio + offset,
0, I8254_IO8, regshift);
- else
+ } else {
i8254 = comedi_8254_init(dev->iobase + offset,
0, I8254_IO8, regshift);
+ }
if (!i8254)
return -ENOMEM;
@@ -593,10 +595,10 @@ static int dio200_subdev_8254_init(struct comedi_device *dev,
* There could be multiple timers so this driver does not
* use dev->pacer to save the i8254 pointer. Instead,
* comedi_8254_subdevice_init() saved the i8254 pointer in
- * s->private. Set the runflag bit so that the core will
- * automatically free it when the driver is detached.
+ * s->private. Mark the subdevice as having private data
+ * to be automatically freed when the device is detached.
*/
- s->runflags |= COMEDI_SRF_FREE_SPRIV;
+ comedi_set_spriv_auto_free(s);
/* Initialize channels. */
if (board->has_clk_gat_sce) {
@@ -641,15 +643,18 @@ static int dio200_subdev_8255_bits(struct comedi_device *dev,
mask = comedi_dio_update_state(s, data);
if (mask) {
- if (mask & 0xff)
+ if (mask & 0xff) {
dio200_write8(dev, subpriv->ofs + I8255_DATA_A_REG,
s->state & 0xff);
- if (mask & 0xff00)
+ }
+ if (mask & 0xff00) {
dio200_write8(dev, subpriv->ofs + I8255_DATA_B_REG,
(s->state >> 8) & 0xff);
- if (mask & 0xff0000)
+ }
+ if (mask & 0xff0000) {
dio200_write8(dev, subpriv->ofs + I8255_DATA_C_REG,
(s->state >> 16) & 0xff);
+ }
}
val = dio200_read8(dev, subpriv->ofs + I8255_DATA_A_REG);
diff --git a/drivers/staging/comedi/drivers/amplc_dio200_pci.c b/drivers/staging/comedi/drivers/amplc_dio200_pci.c
index d9850c917163ae..2598e6e7d47d30 100644
--- a/drivers/staging/comedi/drivers/amplc_dio200_pci.c
+++ b/drivers/staging/comedi/drivers/amplc_dio200_pci.c
@@ -1,22 +1,23 @@
/* comedi/drivers/amplc_dio200_pci.c
+ *
+ * Driver for Amplicon PCI215, PCI272, PCIe215, PCIe236, PCIe296.
+ *
+ * Copyright (C) 2005-2013 MEV Ltd. <http://www.mev.co.uk/>
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1998,2000 David A. Schleef <ds@schleef.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 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.
+ */
- Driver for Amplicon PCI215, PCI272, PCIe215, PCIe236, PCIe296.
-
- Copyright (C) 2005-2013 MEV Ltd. <http://www.mev.co.uk/>
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1998,2000 David A. Schleef <ds@schleef.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 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.
-*/
/*
* Driver: amplc_dio200_pci
* Description: Amplicon 200 Series PCI Digital I/O
diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c
index a94c33c3d962d8..3d646c19f352e2 100644
--- a/drivers/staging/comedi/drivers/cb_pcidas64.c
+++ b/drivers/staging/comedi/drivers/cb_pcidas64.c
@@ -155,8 +155,10 @@ static inline unsigned int dac_msb_4020_reg(unsigned int channel)
}
enum read_only_registers {
- /* hardware status register,
- * reading this apparently clears pending interrupts as well */
+ /*
+ * hardware status register,
+ * reading this apparently clears pending interrupts as well
+ */
HW_STATUS_REG = 0x0,
PIPE1_READ_REG = 0x4,
ADC_READ_PNTR_REG = 0x8,
@@ -243,7 +245,8 @@ enum adc_control0_contents {
ADC_SOFT_GATE_BITS = 0x1, /* software gate */
ADC_EXT_GATE_BITS = 0x2, /* external digital gate */
ADC_ANALOG_GATE_BITS = 0x3, /* analog level gate */
- ADC_GATE_LEVEL_BIT = 0x4, /* level-sensitive gate (for digital) */
+ /* level-sensitive gate (for digital) */
+ ADC_GATE_LEVEL_BIT = 0x4,
ADC_GATE_POLARITY_BIT = 0x8, /* gate active low */
ADC_START_TRIG_SOFT_BITS = 0x10,
ADC_START_TRIG_EXT_BITS = 0x20,
@@ -300,7 +303,8 @@ enum calibration_contents {
CAL_GAIN_BIT = 0x800,
};
-/* calibration sources for 6025 are:
+/*
+ * calibration sources for 6025 are:
* 0 : ground
* 1 : 10V
* 2 : 5V
@@ -660,8 +664,10 @@ static const struct hw_fifo_info ai_fifo_60xx = {
.fifo_size_reg_mask = 0x7f,
};
-/* maximum number of dma transfers we will chain together into a ring
- * (and the maximum number of dma buffers we maintain) */
+/*
+ * maximum number of dma transfers we will chain together into a ring
+ * (and the maximum number of dma buffers we maintain)
+ */
#define MAX_AI_DMA_RING_COUNT (0x80000 / DMA_BUFFER_SIZE)
#define MIN_AI_DMA_RING_COUNT (0x10000 / DMA_BUFFER_SIZE)
#define AO_DMA_RING_COUNT (0x10000 / DMA_BUFFER_SIZE)
@@ -1260,8 +1266,10 @@ static void enable_ai_interrupts(struct comedi_device *dev,
bits = EN_ADC_OVERRUN_BIT | EN_ADC_DONE_INTR_BIT |
EN_ADC_ACTIVE_INTR_BIT | EN_ADC_STOP_INTR_BIT;
- /* Use pio transfer and interrupt on end of conversion
- * if CMDF_WAKE_EOS flag is set. */
+ /*
+ * Use pio transfer and interrupt on end of conversion
+ * if CMDF_WAKE_EOS flag is set.
+ */
if (cmd->flags & CMDF_WAKE_EOS) {
/* 4020 doesn't support pio transfers except for fifo dregs */
if (thisboard->layout != LAYOUT_4020)
@@ -1381,7 +1389,9 @@ static int set_ai_fifo_segment_length(struct comedi_device *dev,
return devpriv->ai_fifo_segment_length;
}
-/* adjusts the size of hardware fifo (which determines block size for dma xfers) */
+/*
+ * adjusts the size of hardware fifo (which determines block size for dma xfers)
+ */
static int set_ai_fifo_size(struct comedi_device *dev, unsigned int num_samples)
{
const struct pcidas64_board *thisboard = dev->board_ptr;
@@ -1422,8 +1432,10 @@ static void init_stc_registers(struct comedi_device *dev)
spin_lock_irqsave(&dev->spinlock, flags);
- /* bit should be set for 6025,
- * although docs say boards with <= 16 chans should be cleared XXX */
+ /*
+ * bit should be set for 6025,
+ * although docs say boards with <= 16 chans should be cleared XXX
+ */
if (1)
devpriv->adc_control1_bits |= ADC_QUEUE_CONFIG_BIT;
writew(devpriv->adc_control1_bits,
@@ -1588,7 +1600,9 @@ static inline void warn_external_queue(struct comedi_device *dev)
"Use internal AI channel queue (channels must be consecutive and use same range/aref)\n");
}
-/* Their i2c requires a huge delay on setting clock or data high for some reason */
+/*
+ * their i2c requires a huge delay on setting clock or data high for some reason
+ */
static const int i2c_high_udelay = 1000;
static const int i2c_low_udelay = 10;
@@ -1684,8 +1698,10 @@ static void i2c_write(struct comedi_device *dev, unsigned int address,
uint8_t bitstream;
static const int read_bit = 0x1;
- /* XXX need mutex to prevent simultaneous attempts to access
- * eeprom and i2c bus */
+ /*
+ * XXX need mutex to prevent simultaneous attempts to access
+ * eeprom and i2c bus
+ */
/* make sure we dont send anything to eeprom */
devpriv->plx_control_bits &= ~CTL_EE_CS;
@@ -1777,14 +1793,18 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
cal_en_bit = CAL_EN_60XX_BIT;
else
cal_en_bit = CAL_EN_64XX_BIT;
- /* select internal reference source to connect
- * to channel 0 */
+ /*
+ * select internal reference source to connect
+ * to channel 0
+ */
writew(cal_en_bit |
adc_src_bits(devpriv->calibration_source),
devpriv->main_iobase + CALIBRATION_REG);
} else {
- /* make sure internal calibration source
- * is turned off */
+ /*
+ * make sure internal calibration source
+ * is turned off
+ */
writew(0, devpriv->main_iobase + CALIBRATION_REG);
}
/* load internal queue */
@@ -1816,8 +1836,10 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
devpriv->i2c_cal_range_bits |= attenuate_bit(channel);
else
devpriv->i2c_cal_range_bits &= ~attenuate_bit(channel);
- /* update calibration/range i2c register only if necessary,
- * as it is very slow */
+ /*
+ * update calibration/range i2c register only if necessary,
+ * as it is very slow
+ */
if (old_cal_range_bits != devpriv->i2c_cal_range_bits) {
uint8_t i2c_data = devpriv->i2c_cal_range_bits;
@@ -1825,10 +1847,12 @@ static int ai_rinsn(struct comedi_device *dev, struct comedi_subdevice *s,
sizeof(i2c_data));
}
- /* 4020 manual asks that sample interval register to be set
+ /*
+ * 4020 manual asks that sample interval register to be set
* before writing to convert register.
* Using somewhat arbitrary setting of 4 master clock ticks
- * = 0.1 usec */
+ * = 0.1 usec
+ */
writew(0, devpriv->main_iobase + ADC_SAMPLE_INTERVAL_UPPER_REG);
writew(2, devpriv->main_iobase + ADC_SAMPLE_INTERVAL_LOWER_REG);
}
@@ -1963,9 +1987,11 @@ static int ai_config_insn(struct comedi_device *dev, struct comedi_subdevice *s,
return -EINVAL;
}
-/* Gets nearest achievable timing given master clock speed, does not
+/*
+ * Gets nearest achievable timing given master clock speed, does not
* take into account possible minimum/maximum divisor values. Used
- * by other timing checking functions. */
+ * by other timing checking functions.
+ */
static unsigned int get_divisor(unsigned int ns, unsigned int flags)
{
unsigned int divisor;
@@ -1985,9 +2011,11 @@ static unsigned int get_divisor(unsigned int ns, unsigned int flags)
return divisor;
}
-/* utility function that rounds desired timing to an achievable time, and
+/*
+ * utility function that rounds desired timing to an achievable time, and
* sets cmd members appropriately.
- * adc paces conversions from master clock by dividing by (x + 3) where x is 24 bit number
+ * adc paces conversions from master clock by dividing by (x + 3) where x is
+ * 24 bit number
*/
static void check_adc_timing(struct comedi_device *dev, struct comedi_cmd *cmd)
{
@@ -2468,8 +2496,10 @@ static int setup_channel_queue(struct comedi_device *dev,
devpriv->main_iobase +
ADC_QUEUE_FIFO_REG);
}
- /* doing a queue clear is not specified in board docs,
- * but required for reliable operation */
+ /*
+ * doing a queue clear is not specified in board docs,
+ * but required for reliable operation
+ */
writew(0, devpriv->main_iobase + ADC_QUEUE_CLEAR_REG);
/* prime queue holding register */
writew(0, devpriv->main_iobase + ADC_QUEUE_LOAD_REG);
@@ -2492,8 +2522,10 @@ static int setup_channel_queue(struct comedi_device *dev,
devpriv->i2c_cal_range_bits &=
~attenuate_bit(channel);
}
- /* update calibration/range i2c register only if necessary,
- * as it is very slow */
+ /*
+ * update calibration/range i2c register only if necessary,
+ * as it is very slow
+ */
if (old_cal_range_bits != devpriv->i2c_cal_range_bits) {
uint8_t i2c_data = devpriv->i2c_cal_range_bits;
@@ -2510,11 +2542,13 @@ static inline void load_first_dma_descriptor(struct comedi_device *dev,
{
struct pcidas64_private *devpriv = dev->private;
- /* The transfer size, pci address, and local address registers
+ /*
+ * The transfer size, pci address, and local address registers
* are supposedly unused during chained dma,
* but I have found that left over values from last operation
* occasionally cause problems with transfer of first dma
- * block. Initializing them to zero seems to fix the problem. */
+ * block. Initializing them to zero seems to fix the problem.
+ */
if (dma_channel) {
writel(0,
devpriv->plx9080_iobase + PLX_DMA1_TRANSFER_SIZE_REG);
@@ -2669,15 +2703,19 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
0x7fff;
write_index = readw(devpriv->main_iobase + ADC_WRITE_PNTR_REG) &
0x7fff;
- /* Get most significant bits (grey code).
+ /*
+ * Get most significant bits (grey code).
* Different boards use different code so use a scheme
* that doesn't depend on encoding. This read must
* occur after reading least significant 15 bits to avoid race
- * with fifo switching to next segment. */
+ * with fifo switching to next segment.
+ */
prepost_bits = readw(devpriv->main_iobase + PREPOST_REG);
- /* if read and write pointers are not on the same fifo segment,
- * read to the end of the read segment */
+ /*
+ * if read and write pointers are not on the same fifo segment,
+ * read to the end of the read segment
+ */
read_segment = adc_upper_read_ptr_code(prepost_bits);
write_segment = adc_upper_write_ptr_code(prepost_bits);
@@ -2706,7 +2744,8 @@ static void pio_drain_ai_fifo_16(struct comedi_device *dev)
} while (read_segment != write_segment);
}
-/* Read from 32 bit wide ai fifo of 4020 - deal with insane grey coding of
+/*
+ * Read from 32 bit wide ai fifo of 4020 - deal with insane grey coding of
* pointers. The pci-4020 hardware only supports dma transfers (it only
* supports the use of pio for draining the last remaining points from the
* fifo when a data acquisition operation has completed).
@@ -2784,8 +2823,10 @@ static void drain_dma_buffers(struct comedi_device *dev, unsigned int channel)
devpriv->ai_dma_index = (devpriv->ai_dma_index + 1) %
ai_dma_ring_count(thisboard);
}
- /* XXX check for dma ring buffer overrun
- * (use end-of-chain bit to mark last unused buffer) */
+ /*
+ * XXX check for dma ring buffer overrun
+ * (use end-of-chain bit to mark last unused buffer)
+ */
}
static void handle_ai_interrupt(struct comedi_device *dev,
@@ -2933,8 +2974,10 @@ static unsigned int load_ao_dma_buffer(struct comedi_device *dev,
next_bits = le32_to_cpu(devpriv->ao_dma_desc[buffer_index].next);
next_bits |= PLX_END_OF_CHAIN_BIT;
devpriv->ao_dma_desc[buffer_index].next = cpu_to_le32(next_bits);
- /* clear end of chain bit on previous buffer now that we have set it
- * for the last buffer */
+ /*
+ * clear end of chain bit on previous buffer now that we have set it
+ * for the last buffer
+ */
next_bits = le32_to_cpu(devpriv->ao_dma_desc[prev_buffer_index].next);
next_bits &= ~PLX_END_OF_CHAIN_BIT;
devpriv->ao_dma_desc[prev_buffer_index].next = cpu_to_le32(next_bits);
@@ -3027,9 +3070,11 @@ static irqreturn_t handle_interrupt(int irq, void *d)
plx_status = readl(devpriv->plx9080_iobase + PLX_INTRCS_REG);
status = readw(devpriv->main_iobase + HW_STATUS_REG);
- /* an interrupt before all the postconfig stuff gets done could
+ /*
+ * an interrupt before all the postconfig stuff gets done could
* cause a NULL dereference if we continue through the
- * interrupt handler */
+ * interrupt handler
+ */
if (!dev->attached)
return IRQ_HANDLED;
@@ -3189,8 +3234,10 @@ static int prep_ao_dma(struct comedi_device *dev, const struct comedi_cmd *cmd)
unsigned int nbytes;
int i;
- /* clear queue pointer too, since external queue has
- * weird interactions with ao fifo */
+ /*
+ * clear queue pointer too, since external queue has
+ * weird interactions with ao fifo
+ */
writew(0, devpriv->main_iobase + ADC_QUEUE_CLEAR_REG);
writew(0, devpriv->main_iobase + DAC_BUFFER_CLEAR_REG);
@@ -3459,7 +3506,8 @@ static int dio_60xx_wbits(struct comedi_device *dev,
return insn->n;
}
-/* pci-6025 8800 caldac:
+/*
+ * pci-6025 8800 caldac:
* address 0 == dac channel 0 offset
* address 1 == dac channel 0 gain
* address 2 == dac channel 1 offset
@@ -3469,7 +3517,8 @@ static int dio_60xx_wbits(struct comedi_device *dev,
* address 6 == coarse adc gain
* address 7 == fine adc gain
*/
-/* pci-6402/16 uses all 8 channels for dac:
+/*
+ * pci-6402/16 uses all 8 channels for dac:
* address 0 == dac channel 0 fine gain
* address 1 == dac channel 0 coarse gain
* address 2 == dac channel 0 coarse offset
@@ -3478,7 +3527,7 @@ static int dio_60xx_wbits(struct comedi_device *dev,
* address 5 == dac channel 1 coarse gain
* address 6 == dac channel 0 fine offset
* address 7 == dac channel 1 fine offset
-*/
+ */
static int caldac_8800_write(struct comedi_device *dev, unsigned int address,
uint8_t value)
@@ -3738,7 +3787,8 @@ static int eeprom_read_insn(struct comedi_device *dev,
return 1;
}
-/* Allocate and initialize the subdevice structures.
+/*
+ * Allocate and initialize the subdevice structures.
*/
static int setup_subdevices(struct comedi_device *dev)
{
@@ -3773,8 +3823,10 @@ static int setup_subdevices(struct comedi_device *dev)
s->cancel = ai_cancel;
if (thisboard->layout == LAYOUT_4020) {
uint8_t data;
- /* set adc to read from inputs
- * (not internal calibration sources) */
+ /*
+ * set adc to read from inputs
+ * (not internal calibration sources)
+ */
devpriv->i2c_cal_range_bits = adc_src_4020_bits(4);
/* set channels to +-5 volt input ranges */
for (i = 0; i < s->n_chan; i++)
diff --git a/drivers/staging/comedi/drivers/cb_pcimdda.c b/drivers/staging/comedi/drivers/cb_pcimdda.c
index a4781dbbdd82e6..19210d89f2b23d 100644
--- a/drivers/staging/comedi/drivers/cb_pcimdda.c
+++ b/drivers/staging/comedi/drivers/cb_pcimdda.c
@@ -164,11 +164,7 @@ static int cb_pcimdda_auto_attach(struct comedi_device *dev,
s = &dev->subdevices[1];
/* digital i/o subdevice */
- ret = subdev_8255_init(dev, s, NULL, PCIMDDA_8255_BASE_REG);
- if (ret)
- return ret;
-
- return 0;
+ return subdev_8255_init(dev, s, NULL, PCIMDDA_8255_BASE_REG);
}
static struct comedi_driver cb_pcimdda_driver = {
diff --git a/drivers/staging/comedi/drivers/comedi_8254.h b/drivers/staging/comedi/drivers/comedi_8254.h
index d89f6d94f8aa62..f4610ead617263 100644
--- a/drivers/staging/comedi/drivers/comedi_8254.h
+++ b/drivers/staging/comedi/drivers/comedi_8254.h
@@ -20,6 +20,12 @@
#ifndef _COMEDI_8254_H
#define _COMEDI_8254_H
+#include <linux/types.h>
+
+struct comedi_device;
+struct comedi_insn;
+struct comedi_subdevice;
+
/*
* Common oscillator base values in nanoseconds
*/
diff --git a/drivers/staging/comedi/drivers/comedi_8255.c b/drivers/staging/comedi/drivers/comedi_8255.c
new file mode 100644
index 00000000000000..b2441efc61ccc7
--- /dev/null
+++ b/drivers/staging/comedi/drivers/comedi_8255.c
@@ -0,0 +1,285 @@
+/*
+ * comedi_8255.c
+ * Generic 8255 digital I/O support
+ *
+ * Split from the Comedi "8255" driver module.
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1998 David A. Schleef <ds@schleef.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 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.
+ */
+
+/*
+ * Module: comedi_8255
+ * Description: Generic 8255 support
+ * Author: ds
+ * Updated: Fri, 22 May 2015 12:14:17 +0000
+ * Status: works
+ *
+ * This module is not used directly by end-users. Rather, it is used by
+ * other drivers to provide support for an 8255 "Programmable Peripheral
+ * Interface" (PPI) chip.
+ *
+ * The classic in digital I/O. The 8255 appears in Comedi as a single
+ * digital I/O subdevice with 24 channels. The channel 0 corresponds to
+ * the 8255's port A, bit 0; channel 23 corresponds to port C, bit 7.
+ * Direction configuration is done in blocks, with channels 0-7, 8-15,
+ * 16-19, and 20-23 making up the 4 blocks. The only 8255 mode
+ * supported is mode 0.
+ */
+
+#include <linux/module.h>
+#include "../comedidev.h"
+
+#include "8255.h"
+
+struct subdev_8255_private {
+ unsigned long regbase;
+ int (*io)(struct comedi_device *dev, int dir, int port, int data,
+ unsigned long regbase);
+};
+
+static int subdev_8255_io(struct comedi_device *dev,
+ int dir, int port, int data, unsigned long regbase)
+{
+ if (dir) {
+ outb(data, dev->iobase + regbase + port);
+ return 0;
+ }
+ return inb(dev->iobase + regbase + port);
+}
+
+static int subdev_8255_mmio(struct comedi_device *dev,
+ int dir, int port, int data, unsigned long regbase)
+{
+ if (dir) {
+ writeb(data, dev->mmio + regbase + port);
+ return 0;
+ }
+ return readb(dev->mmio + regbase + port);
+}
+
+static int subdev_8255_insn(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
+{
+ struct subdev_8255_private *spriv = s->private;
+ unsigned long regbase = spriv->regbase;
+ unsigned int mask;
+ unsigned int v;
+
+ mask = comedi_dio_update_state(s, data);
+ if (mask) {
+ if (mask & 0xff)
+ spriv->io(dev, 1, I8255_DATA_A_REG,
+ s->state & 0xff, regbase);
+ if (mask & 0xff00)
+ spriv->io(dev, 1, I8255_DATA_B_REG,
+ (s->state >> 8) & 0xff, regbase);
+ if (mask & 0xff0000)
+ spriv->io(dev, 1, I8255_DATA_C_REG,
+ (s->state >> 16) & 0xff, regbase);
+ }
+
+ v = spriv->io(dev, 0, I8255_DATA_A_REG, 0, regbase);
+ v |= (spriv->io(dev, 0, I8255_DATA_B_REG, 0, regbase) << 8);
+ v |= (spriv->io(dev, 0, I8255_DATA_C_REG, 0, regbase) << 16);
+
+ data[1] = v;
+
+ return insn->n;
+}
+
+static void subdev_8255_do_config(struct comedi_device *dev,
+ struct comedi_subdevice *s)
+{
+ struct subdev_8255_private *spriv = s->private;
+ unsigned long regbase = spriv->regbase;
+ int config;
+
+ config = I8255_CTRL_CW;
+ /* 1 in io_bits indicates output, 1 in config indicates input */
+ if (!(s->io_bits & 0x0000ff))
+ config |= I8255_CTRL_A_IO;
+ if (!(s->io_bits & 0x00ff00))
+ config |= I8255_CTRL_B_IO;
+ if (!(s->io_bits & 0x0f0000))
+ config |= I8255_CTRL_C_LO_IO;
+ if (!(s->io_bits & 0xf00000))
+ config |= I8255_CTRL_C_HI_IO;
+
+ spriv->io(dev, 1, I8255_CTRL_REG, config, regbase);
+}
+
+static int subdev_8255_insn_config(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ struct comedi_insn *insn,
+ unsigned int *data)
+{
+ unsigned int chan = CR_CHAN(insn->chanspec);
+ unsigned int mask;
+ int ret;
+
+ if (chan < 8)
+ mask = 0x0000ff;
+ else if (chan < 16)
+ mask = 0x00ff00;
+ else if (chan < 20)
+ mask = 0x0f0000;
+ else
+ mask = 0xf00000;
+
+ ret = comedi_dio_insn_config(dev, s, insn, data, mask);
+ if (ret)
+ return ret;
+
+ subdev_8255_do_config(dev, s);
+
+ return insn->n;
+}
+
+static int __subdev_8255_init(struct comedi_device *dev,
+ struct comedi_subdevice *s,
+ int (*io)(struct comedi_device *dev,
+ int dir, int port, int data,
+ unsigned long regbase),
+ unsigned long regbase,
+ bool is_mmio)
+{
+ struct subdev_8255_private *spriv;
+
+ spriv = comedi_alloc_spriv(s, sizeof(*spriv));
+ if (!spriv)
+ return -ENOMEM;
+
+ if (io)
+ spriv->io = io;
+ else if (is_mmio)
+ spriv->io = subdev_8255_mmio;
+ else
+ spriv->io = subdev_8255_io;
+ spriv->regbase = regbase;
+
+ s->type = COMEDI_SUBD_DIO;
+ s->subdev_flags = SDF_READABLE | SDF_WRITABLE;
+ s->n_chan = 24;
+ s->range_table = &range_digital;
+ s->maxdata = 1;
+ s->insn_bits = subdev_8255_insn;
+ s->insn_config = subdev_8255_insn_config;
+
+ subdev_8255_do_config(dev, s);
+
+ return 0;
+}
+
+/**
+ * subdev_8255_init - initialize DIO subdevice for driving I/O mapped 8255
+ * @dev: comedi device owning subdevice
+ * @s: comedi subdevice to initialize
+ * @io: (optional) register I/O call-back function
+ * @regbase: offset of 8255 registers from dev->iobase, or call-back context
+ *
+ * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip.
+ *
+ * If the optional I/O call-back function is provided, its prototype is of
+ * the following form:
+ *
+ * int my_8255_callback(struct comedi_device *dev, int dir, int port,
+ * int data, unsigned long regbase);
+ *
+ * where 'dev', and 'regbase' match the values passed to this function,
+ * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir'
+ * is the direction (0 for read, 1 for write) and 'data' is the value to be
+ * written. It should return 0 if writing or the value read if reading.
+ *
+ * If the optional I/O call-back function is not provided, an internal
+ * call-back function is used which uses consecutive I/O port addresses
+ * starting at dev->iobase + regbase.
+ *
+ * Return: -ENOMEM if failed to allocate memory, zero on success.
+ */
+int subdev_8255_init(struct comedi_device *dev, struct comedi_subdevice *s,
+ int (*io)(struct comedi_device *dev, int dir, int port,
+ int data, unsigned long regbase),
+ unsigned long regbase)
+{
+ return __subdev_8255_init(dev, s, io, regbase, false);
+}
+EXPORT_SYMBOL_GPL(subdev_8255_init);
+
+/**
+ * subdev_8255_mm_init - initialize DIO subdevice for driving mmio-mapped 8255
+ * @dev: comedi device owning subdevice
+ * @s: comedi subdevice to initialize
+ * @io: (optional) register I/O call-back function
+ * @regbase: offset of 8255 registers from dev->mmio, or call-back context
+ *
+ * Initializes a comedi subdevice as a DIO subdevice driving an 8255 chip.
+ *
+ * If the optional I/O call-back function is provided, its prototype is of
+ * the following form:
+ *
+ * int my_8255_callback(struct comedi_device *dev, int dir, int port,
+ * int data, unsigned long regbase);
+ *
+ * where 'dev', and 'regbase' match the values passed to this function,
+ * 'port' is the 8255 port number 0 to 3 (including the control port), 'dir'
+ * is the direction (0 for read, 1 for write) and 'data' is the value to be
+ * written. It should return 0 if writing or the value read if reading.
+ *
+ * If the optional I/O call-back function is not provided, an internal
+ * call-back function is used which uses consecutive MMIO virtual addresses
+ * starting at dev->mmio + regbase.
+ *
+ * Return: -ENOMEM if failed to allocate memory, zero on success.
+ */
+int subdev_8255_mm_init(struct comedi_device *dev, struct comedi_subdevice *s,
+ int (*io)(struct comedi_device *dev, int dir, int port,
+ int data, unsigned long regbase),
+ unsigned long regbase)
+{
+ return __subdev_8255_init(dev, s, io, regbase, true);
+}
+EXPORT_SYMBOL_GPL(subdev_8255_mm_init);
+
+/**
+ * subdev_8255_regbase - get offset of 8255 registers or call-back context
+ * @s: comedi subdevice
+ *
+ * Returns the 'regbase' parameter that was previously passed to to
+ * subdev_8255_init() or subdev_8255_mm_init() to set up the subdevice.
+ * Only valid if the subdevice was set up successfully.
+ */
+unsigned long subdev_8255_regbase(struct comedi_subdevice *s)
+{
+ struct subdev_8255_private *spriv = s->private;
+
+ return spriv->regbase;
+}
+EXPORT_SYMBOL_GPL(subdev_8255_regbase);
+
+static int __init comedi_8255_module_init(void)
+{
+ return 0;
+}
+module_init(comedi_8255_module_init);
+
+static void __exit comedi_8255_module_exit(void)
+{
+}
+module_exit(comedi_8255_module_exit);
+
+MODULE_AUTHOR("Comedi http://www.comedi.org");
+MODULE_DESCRIPTION("Comedi: Generic 8255 digital I/O support");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
index 96db0c2686a1e6..50b76eccb7d708 100644
--- a/drivers/staging/comedi/drivers/comedi_bond.c
+++ b/drivers/staging/comedi/drivers/comedi_bond.c
@@ -101,7 +101,8 @@ static int bonding_dio_insn_bits(struct comedi_device *dev,
b_chans = bdev->nchans - base_chan;
if (b_chans > n_left)
b_chans = n_left;
- b_mask = (1U << b_chans) - 1;
+ b_mask = (b_chans < 32) ? ((1 << b_chans) - 1)
+ : 0xffffffff;
b_write_mask = (write_mask >> n_done) & b_mask;
b_data_bits = (data_bits >> n_done) & b_mask;
/* Read/Write the new digital lines. */
diff --git a/drivers/staging/comedi/drivers/comedi_isadma.h b/drivers/staging/comedi/drivers/comedi_isadma.h
index c7c524faf595ce..2fb6573ba9e405 100644
--- a/drivers/staging/comedi/drivers/comedi_isadma.h
+++ b/drivers/staging/comedi/drivers/comedi_isadma.h
@@ -16,6 +16,10 @@
#ifndef _COMEDI_ISADMA_H
#define _COMEDI_ISADMA_H
+#include <linux/types.h>
+
+struct comedi_device;
+
/*
* These are used to avoid issues when <asm/dma.h> and the DMA_MODE_
* defines are not available.
diff --git a/drivers/staging/comedi/drivers/daqboard2000.c b/drivers/staging/comedi/drivers/daqboard2000.c
index f97d18d92255bf..611b0a3ef5d758 100644
--- a/drivers/staging/comedi/drivers/daqboard2000.c
+++ b/drivers/staging/comedi/drivers/daqboard2000.c
@@ -1,105 +1,105 @@
/*
- comedi/drivers/daqboard2000.c
- hardware driver for IOtech DAQboard/2000
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1999 Anders Blomdell <anders.blomdell@control.lth.se>
-
- 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.
+ * comedi/drivers/daqboard2000.c
+ * hardware driver for IOtech DAQboard/2000
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1999 Anders Blomdell <anders.blomdell@control.lth.se>
+ *
+ * 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.
*/
/*
-Driver: daqboard2000
-Description: IOTech DAQBoard/2000
-Author: Anders Blomdell <anders.blomdell@control.lth.se>
-Status: works
-Updated: Mon, 14 Apr 2008 15:28:52 +0100
-Devices: [IOTech] DAQBoard/2000 (daqboard2000)
-
-Much of the functionality of this driver was determined from reading
-the source code for the Windows driver.
-
-The FPGA on the board requires fimware, which is available from
-http://www.comedi.org in the comedi_nonfree_firmware tarball.
-
-Configuration options: not applicable, uses PCI auto config
-*/
+ * Driver: daqboard2000
+ * Description: IOTech DAQBoard/2000
+ * Author: Anders Blomdell <anders.blomdell@control.lth.se>
+ * Status: works
+ * Updated: Mon, 14 Apr 2008 15:28:52 +0100
+ * Devices: [IOTech] DAQBoard/2000 (daqboard2000)
+ *
+ * Much of the functionality of this driver was determined from reading
+ * the source code for the Windows driver.
+ *
+ * The FPGA on the board requires fimware, which is available from
+ * http://www.comedi.org in the comedi_nonfree_firmware tarball.
+ *
+ * Configuration options: not applicable, uses PCI auto config
+ */
/*
- This card was obviously never intended to leave the Windows world,
- since it lacked all kind of hardware documentation (except for cable
- pinouts, plug and pray has something to catch up with yet).
-
- With some help from our swedish distributor, we got the Windows sourcecode
- for the card, and here are the findings so far.
-
- 1. A good document that describes the PCI interface chip is 9080db-106.pdf
- available from http://www.plxtech.com/products/io/pci9080
-
- 2. The initialization done so far is:
- a. program the FPGA (windows code sans a lot of error messages)
- b.
-
- 3. Analog out seems to work OK with DAC's disabled, if DAC's are enabled,
- you have to output values to all enabled DAC's until result appears, I
- guess that it has something to do with pacer clocks, but the source
- gives me no clues. I'll keep it simple so far.
-
- 4. Analog in.
- Each channel in the scanlist seems to be controlled by four
- control words:
-
- Word0:
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! | | | ! | | | ! | | | ! | | | !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
-
- Word1:
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! | | | ! | | | ! | | | ! | | | !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | | | | | | |
- +------+------+ | | | | +-- Digital input (??)
- | | | | +---- 10 us settling time
- | | | +------ Suspend acquisition (last to scan)
- | | +-------- Simultaneous sample and hold
- | +---------- Signed data format
- +------------------------- Correction offset low
-
- Word2:
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! | | | ! | | | ! | | | ! | | | !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | | | | | | | | | |
- +-----+ +--+--+ +++ +++ +--+--+
- | | | | +----- Expansion channel
- | | | +----------- Expansion gain
- | | +--------------- Channel (low)
- | +--------------------- Correction offset high
- +----------------------------- Correction gain low
- Word3:
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- ! | | | ! | | | ! | | | ! | | | !
- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- | | | | | | | | |
- +------+------+ | | +-+-+ | | +-- Low bank enable
- | | | | | +---- High bank enable
- | | | | +------ Hi/low select
- | | | +---------- Gain (1,?,2,4,8,16,32,64)
- | | +-------------- differential/single ended
- | +---------------- Unipolar
- +------------------------- Correction gain high
-
- 999. The card seems to have an incredible amount of capabilities, but
- trying to reverse engineer them from the Windows source is beyond my
- patience.
-
+ * This card was obviously never intended to leave the Windows world,
+ * since it lacked all kind of hardware documentation (except for cable
+ * pinouts, plug and pray has something to catch up with yet).
+ *
+ * With some help from our swedish distributor, we got the Windows sourcecode
+ * for the card, and here are the findings so far.
+ *
+ * 1. A good document that describes the PCI interface chip is 9080db-106.pdf
+ * available from http://www.plxtech.com/products/io/pci9080
+ *
+ * 2. The initialization done so far is:
+ * a. program the FPGA (windows code sans a lot of error messages)
+ * b.
+ *
+ * 3. Analog out seems to work OK with DAC's disabled, if DAC's are enabled,
+ * you have to output values to all enabled DAC's until result appears, I
+ * guess that it has something to do with pacer clocks, but the source
+ * gives me no clues. I'll keep it simple so far.
+ *
+ * 4. Analog in.
+ * Each channel in the scanlist seems to be controlled by four
+ * control words:
+ *
+ * Word0:
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * ! | | | ! | | | ! | | | ! | | | !
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * Word1:
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * ! | | | ! | | | ! | | | ! | | | !
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | | | | | | |
+ * +------+------+ | | | | +-- Digital input (??)
+ * | | | | +---- 10 us settling time
+ * | | | +------ Suspend acquisition (last to scan)
+ * | | +-------- Simultaneous sample and hold
+ * | +---------- Signed data format
+ * +------------------------- Correction offset low
+ *
+ * Word2:
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * ! | | | ! | | | ! | | | ! | | | !
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | | | | | | | | | |
+ * +-----+ +--+--+ +++ +++ +--+--+
+ * | | | | +----- Expansion channel
+ * | | | +----------- Expansion gain
+ * | | +--------------- Channel (low)
+ * | +--------------------- Correction offset high
+ * +----------------------------- Correction gain low
+ * Word3:
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * ! | | | ! | | | ! | | | ! | | | !
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | | | | | | | | |
+ * +------+------+ | | +-+-+ | | +-- Low bank enable
+ * | | | | | +---- High bank enable
+ * | | | | +------ Hi/low select
+ * | | | +---------- Gain (1,?,2,4,8,16,32,64)
+ * | | +-------------- differential/single ended
+ * | +---------------- Unipolar
+ * +------------------------- Correction gain high
+ *
+ * 999. The card seems to have an incredible amount of capabilities, but
+ * trying to reverse engineer them from the Windows source is beyond my
+ * patience.
+ *
*/
#include <linux/module.h>
diff --git a/drivers/staging/comedi/drivers/das16m1.c b/drivers/staging/comedi/drivers/das16m1.c
index 1adf6a71a9f3f0..a18a8878bdb8ab 100644
--- a/drivers/staging/comedi/drivers/das16m1.c
+++ b/drivers/staging/comedi/drivers/das16m1.c
@@ -46,8 +46,8 @@ list has 2 or more channels in it, then two conditions must be satisfied:
(2) - the list must have an even number of entries.
Options:
- [0] - base io address
- [1] - irq (optional, but you probably want it)
+ [0] - base io address
+ [1] - irq (optional, but you probably want it)
irq can be omitted, although the cmd interface will not work without it.
*/
diff --git a/drivers/staging/comedi/drivers/gsc_hpdi.c b/drivers/staging/comedi/drivers/gsc_hpdi.c
index 3cb6409c4f0183..e9296182236e85 100644
--- a/drivers/staging/comedi/drivers/gsc_hpdi.c
+++ b/drivers/staging/comedi/drivers/gsc_hpdi.c
@@ -52,45 +52,45 @@
* PCI BAR2 Register map (dev->mmio)
*/
#define FIRMWARE_REV_REG 0x00
-#define FEATURES_REG_PRESENT_BIT (1 << 15)
+#define FEATURES_REG_PRESENT_BIT BIT(15)
#define BOARD_CONTROL_REG 0x04
-#define BOARD_RESET_BIT (1 << 0)
-#define TX_FIFO_RESET_BIT (1 << 1)
-#define RX_FIFO_RESET_BIT (1 << 2)
-#define TX_ENABLE_BIT (1 << 4)
-#define RX_ENABLE_BIT (1 << 5)
-#define DEMAND_DMA_DIRECTION_TX_BIT (1 << 6) /* ch 0 only */
-#define LINE_VALID_ON_STATUS_VALID_BIT (1 << 7)
-#define START_TX_BIT (1 << 8)
-#define CABLE_THROTTLE_ENABLE_BIT (1 << 9)
-#define TEST_MODE_ENABLE_BIT (1 << 31)
+#define BOARD_RESET_BIT BIT(0)
+#define TX_FIFO_RESET_BIT BIT(1)
+#define RX_FIFO_RESET_BIT BIT(2)
+#define TX_ENABLE_BIT BIT(4)
+#define RX_ENABLE_BIT BIT(5)
+#define DEMAND_DMA_DIRECTION_TX_BIT BIT(6) /* ch 0 only */
+#define LINE_VALID_ON_STATUS_VALID_BIT BIT(7)
+#define START_TX_BIT BIT(8)
+#define CABLE_THROTTLE_ENABLE_BIT BIT(9)
+#define TEST_MODE_ENABLE_BIT BIT(31)
#define BOARD_STATUS_REG 0x08
#define COMMAND_LINE_STATUS_MASK (0x7f << 0)
-#define TX_IN_PROGRESS_BIT (1 << 7)
-#define TX_NOT_EMPTY_BIT (1 << 8)
-#define TX_NOT_ALMOST_EMPTY_BIT (1 << 9)
-#define TX_NOT_ALMOST_FULL_BIT (1 << 10)
-#define TX_NOT_FULL_BIT (1 << 11)
-#define RX_NOT_EMPTY_BIT (1 << 12)
-#define RX_NOT_ALMOST_EMPTY_BIT (1 << 13)
-#define RX_NOT_ALMOST_FULL_BIT (1 << 14)
-#define RX_NOT_FULL_BIT (1 << 15)
-#define BOARD_JUMPER0_INSTALLED_BIT (1 << 16)
-#define BOARD_JUMPER1_INSTALLED_BIT (1 << 17)
-#define TX_OVERRUN_BIT (1 << 21)
-#define RX_UNDERRUN_BIT (1 << 22)
-#define RX_OVERRUN_BIT (1 << 23)
+#define TX_IN_PROGRESS_BIT BIT(7)
+#define TX_NOT_EMPTY_BIT BIT(8)
+#define TX_NOT_ALMOST_EMPTY_BIT BIT(9)
+#define TX_NOT_ALMOST_FULL_BIT BIT(10)
+#define TX_NOT_FULL_BIT BIT(11)
+#define RX_NOT_EMPTY_BIT BIT(12)
+#define RX_NOT_ALMOST_EMPTY_BIT BIT(13)
+#define RX_NOT_ALMOST_FULL_BIT BIT(14)
+#define RX_NOT_FULL_BIT BIT(15)
+#define BOARD_JUMPER0_INSTALLED_BIT BIT(16)
+#define BOARD_JUMPER1_INSTALLED_BIT BIT(17)
+#define TX_OVERRUN_BIT BIT(21)
+#define RX_UNDERRUN_BIT BIT(22)
+#define RX_OVERRUN_BIT BIT(23)
#define TX_PROG_ALMOST_REG 0x0c
#define RX_PROG_ALMOST_REG 0x10
#define ALMOST_EMPTY_BITS(x) (((x) & 0xffff) << 0)
#define ALMOST_FULL_BITS(x) (((x) & 0xff) << 16)
#define FEATURES_REG 0x14
-#define FIFO_SIZE_PRESENT_BIT (1 << 0)
-#define FIFO_WORDS_PRESENT_BIT (1 << 1)
-#define LEVEL_EDGE_INTERRUPTS_PRESENT_BIT (1 << 2)
-#define GPIO_SUPPORTED_BIT (1 << 3)
-#define PLX_DMA_CH1_SUPPORTED_BIT (1 << 4)
-#define OVERRUN_UNDERRUN_SUPPORTED_BIT (1 << 5)
+#define FIFO_SIZE_PRESENT_BIT BIT(0)
+#define FIFO_WORDS_PRESENT_BIT BIT(1)
+#define LEVEL_EDGE_INTERRUPTS_PRESENT_BIT BIT(2)
+#define GPIO_SUPPORTED_BIT BIT(3)
+#define PLX_DMA_CH1_SUPPORTED_BIT BIT(4)
+#define OVERRUN_UNDERRUN_SUPPORTED_BIT BIT(5)
#define FIFO_REG 0x18
#define TX_STATUS_COUNT_REG 0x1c
#define TX_LINE_VALID_COUNT_REG 0x20,
@@ -98,16 +98,16 @@
#define RX_STATUS_COUNT_REG 0x28
#define RX_LINE_COUNT_REG 0x2c
#define INTERRUPT_CONTROL_REG 0x30
-#define FRAME_VALID_START_INTR (1 << 0)
-#define FRAME_VALID_END_INTR (1 << 1)
-#define TX_FIFO_EMPTY_INTR (1 << 8)
-#define TX_FIFO_ALMOST_EMPTY_INTR (1 << 9)
-#define TX_FIFO_ALMOST_FULL_INTR (1 << 10)
-#define TX_FIFO_FULL_INTR (1 << 11)
-#define RX_EMPTY_INTR (1 << 12)
-#define RX_ALMOST_EMPTY_INTR (1 << 13)
-#define RX_ALMOST_FULL_INTR (1 << 14)
-#define RX_FULL_INTR (1 << 15)
+#define FRAME_VALID_START_INTR BIT(0)
+#define FRAME_VALID_END_INTR BIT(1)
+#define TX_FIFO_EMPTY_INTR BIT(8)
+#define TX_FIFO_ALMOST_EMPTY_INTR BIT(9)
+#define TX_FIFO_ALMOST_FULL_INTR BIT(10)
+#define TX_FIFO_FULL_INTR BIT(11)
+#define RX_EMPTY_INTR BIT(12)
+#define RX_ALMOST_EMPTY_INTR BIT(13)
+#define RX_ALMOST_FULL_INTR BIT(14)
+#define RX_FULL_INTR BIT(15)
#define INTERRUPT_STATUS_REG 0x34
#define TX_CLOCK_DIVIDER_REG 0x38
#define TX_FIFO_SIZE_REG 0x40
@@ -123,34 +123,15 @@
#define NUM_DMA_BUFFERS 4
#define NUM_DMA_DESCRIPTORS 256
-struct hpdi_board {
- const char *name;
- int device_id;
- int subdevice_id;
-};
-
-static const struct hpdi_board hpdi_boards[] = {
- {
- .name = "pci-hpdi32",
- .device_id = PCI_DEVICE_ID_PLX_9080,
- .subdevice_id = 0x2400,
- },
-#if 0
- {
- .name = "pxi-hpdi32",
- .device_id = 0x9656,
- .subdevice_id = 0x2705,
- },
-#endif
-};
-
struct hpdi_private {
void __iomem *plx9080_mmio;
- uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */
+ uint32_t *dio_buffer[NUM_DMA_BUFFERS]; /* dma buffers */
/* physical addresses of dma buffers */
dma_addr_t dio_buffer_phys_addr[NUM_DMA_BUFFERS];
- /* array of dma descriptors read by plx9080, allocated to get proper
- * alignment */
+ /*
+ * array of dma descriptors read by plx9080, allocated to get proper
+ * alignment
+ */
struct plx_dma_desc *dma_desc;
/* physical address of dma descriptor array */
dma_addr_t dma_desc_phys_addr;
@@ -202,7 +183,7 @@ static void gsc_hpdi_drain_dma(struct comedi_device *dev, unsigned int channel)
devpriv->dma_desc_index = idx;
}
- /* XXX check for buffer overrun somehow */
+ /* XXX check for buffer overrun somehow */
}
static irqreturn_t gsc_hpdi_interrupt(int irq, void *d)
@@ -230,10 +211,11 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d)
if (hpdi_intr_status)
writel(hpdi_intr_status, dev->mmio + INTERRUPT_STATUS_REG);
- /* spin lock makes sure no one else changes plx dma control reg */
+ /* spin lock makes sure no one else changes plx dma control reg */
spin_lock_irqsave(&dev->spinlock, flags);
dma0_status = readb(devpriv->plx9080_mmio + PLX_DMA0_CS_REG);
- if (plx_status & ICS_DMA0_A) { /* dma chan 0 interrupt */
+ if (plx_status & ICS_DMA0_A) {
+ /* dma chan 0 interrupt */
writeb((dma0_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
devpriv->plx9080_mmio + PLX_DMA0_CS_REG);
@@ -242,17 +224,19 @@ static irqreturn_t gsc_hpdi_interrupt(int irq, void *d)
}
spin_unlock_irqrestore(&dev->spinlock, flags);
- /* spin lock makes sure no one else changes plx dma control reg */
+ /* spin lock makes sure no one else changes plx dma control reg */
spin_lock_irqsave(&dev->spinlock, flags);
dma1_status = readb(devpriv->plx9080_mmio + PLX_DMA1_CS_REG);
- if (plx_status & ICS_DMA1_A) { /* XXX *//* dma chan 1 interrupt */
+ if (plx_status & ICS_DMA1_A) {
+ /* XXX */ /* dma chan 1 interrupt */
writeb((dma1_status & PLX_DMA_EN_BIT) | PLX_CLEAR_DMA_INTR_BIT,
devpriv->plx9080_mmio + PLX_DMA1_CS_REG);
}
spin_unlock_irqrestore(&dev->spinlock, flags);
- /* clear possible plx9080 interrupt sources */
- if (plx_status & ICS_LDIA) { /* clear local doorbell interrupt */
+ /* clear possible plx9080 interrupt sources */
+ if (plx_status & ICS_LDIA) {
+ /* clear local doorbell interrupt */
plx_bits = readl(devpriv->plx9080_mmio + PLX_DBR_OUT_REG);
writel(plx_bits, devpriv->plx9080_mmio + PLX_DBR_OUT_REG);
}
@@ -280,7 +264,7 @@ static void gsc_hpdi_abort_dma(struct comedi_device *dev, unsigned int channel)
struct hpdi_private *devpriv = dev->private;
unsigned long flags;
- /* spinlock for plx dma control/status reg */
+ /* spinlock for plx dma control/status reg */
spin_lock_irqsave(&dev->spinlock, flags);
plx9080_abort_dma(devpriv->plx9080_mmio, channel);
@@ -536,7 +520,7 @@ static int gsc_hpdi_init(struct comedi_device *dev)
/* wait 10usec after reset before accessing fifos */
writel(BOARD_RESET_BIT, dev->mmio + BOARD_CONTROL_REG);
- udelay(10);
+ usleep_range(10, 1000);
writel(ALMOST_EMPTY_BITS(32) | ALMOST_FULL_BITS(32),
dev->mmio + RX_PROG_ALMOST_REG);
@@ -550,7 +534,7 @@ static int gsc_hpdi_init(struct comedi_device *dev)
writel(0, dev->mmio + INTERRUPT_CONTROL_REG);
- /* enable interrupts */
+ /* enable interrupts */
plx_intcsr_bits =
ICS_AERR | ICS_PERR | ICS_PIE | ICS_PLIE | ICS_PAIE | ICS_LIE |
ICS_DMA0_E;
@@ -577,57 +561,42 @@ static void gsc_hpdi_init_plx9080(struct comedi_device *dev)
gsc_hpdi_abort_dma(dev, 0);
gsc_hpdi_abort_dma(dev, 1);
- /* configure dma0 mode */
+ /* configure dma0 mode */
bits = 0;
- /* enable ready input */
+ /* enable ready input */
bits |= PLX_DMA_EN_READYIN_BIT;
- /* enable dma chaining */
+ /* enable dma chaining */
bits |= PLX_EN_CHAIN_BIT;
- /* enable interrupt on dma done
- * (probably don't need this, since chain never finishes) */
+ /*
+ * enable interrupt on dma done
+ * (probably don't need this, since chain never finishes)
+ */
bits |= PLX_EN_DMA_DONE_INTR_BIT;
- /* don't increment local address during transfers
- * (we are transferring from a fixed fifo register) */
+ /*
+ * don't increment local address during transfers
+ * (we are transferring from a fixed fifo register)
+ */
bits |= PLX_LOCAL_ADDR_CONST_BIT;
- /* route dma interrupt to pci bus */
+ /* route dma interrupt to pci bus */
bits |= PLX_DMA_INTR_PCI_BIT;
- /* enable demand mode */
+ /* enable demand mode */
bits |= PLX_DEMAND_MODE_BIT;
- /* enable local burst mode */
+ /* enable local burst mode */
bits |= PLX_DMA_LOCAL_BURST_EN_BIT;
bits |= PLX_LOCAL_BUS_32_WIDE_BITS;
writel(bits, plx_iobase + PLX_DMA0_MODE_REG);
}
-static const struct hpdi_board *gsc_hpdi_find_board(struct pci_dev *pcidev)
-{
- unsigned int i;
-
- for (i = 0; i < ARRAY_SIZE(hpdi_boards); i++)
- if (pcidev->device == hpdi_boards[i].device_id &&
- pcidev->subsystem_device == hpdi_boards[i].subdevice_id)
- return &hpdi_boards[i];
- return NULL;
-}
-
static int gsc_hpdi_auto_attach(struct comedi_device *dev,
unsigned long context_unused)
{
struct pci_dev *pcidev = comedi_to_pci_dev(dev);
- const struct hpdi_board *thisboard;
struct hpdi_private *devpriv;
struct comedi_subdevice *s;
int i;
int retval;
- thisboard = gsc_hpdi_find_board(pcidev);
- if (!thisboard) {
- dev_err(dev->class_dev, "gsc_hpdi: pci %s not supported\n",
- pci_name(pcidev));
- return -EINVAL;
- }
- dev->board_ptr = thisboard;
- dev->board_name = thisboard->name;
+ dev->board_name = "pci-hpdi32";
devpriv = comedi_alloc_devpriv(dev, sizeof(*devpriv));
if (!devpriv)
@@ -647,7 +616,7 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev,
gsc_hpdi_init_plx9080(dev);
- /* get irq */
+ /* get irq */
if (request_irq(pcidev->irq, gsc_hpdi_interrupt, IRQF_SHARED,
dev->board_name, dev)) {
dev_warn(dev->class_dev,
@@ -658,13 +627,13 @@ static int gsc_hpdi_auto_attach(struct comedi_device *dev,
dev_dbg(dev->class_dev, " irq %u\n", dev->irq);
- /* allocate pci dma buffers */
+ /* allocate pci dma buffers */
for (i = 0; i < NUM_DMA_BUFFERS; i++) {
devpriv->dio_buffer[i] =
pci_alloc_consistent(pcidev, DMA_BUFFER_SIZE,
&devpriv->dio_buffer_phys_addr[i]);
}
- /* allocate dma descriptors */
+ /* allocate dma descriptors */
devpriv->dma_desc = pci_alloc_consistent(pcidev,
sizeof(struct plx_dma_desc) *
NUM_DMA_DESCRIPTORS,
@@ -733,8 +702,8 @@ static int gsc_hpdi_pci_probe(struct pci_dev *dev,
}
static const struct pci_device_id gsc_hpdi_pci_table[] = {
- { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080, PCI_VENDOR_ID_PLX,
- 0x2400, 0, 0, 0},
+ { PCI_DEVICE_SUB(PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9080,
+ PCI_VENDOR_ID_PLX, 0x2400) },
{ 0 }
};
MODULE_DEVICE_TABLE(pci, gsc_hpdi_pci_table);
@@ -748,5 +717,5 @@ static struct pci_driver gsc_hpdi_pci_driver = {
module_comedi_pci_driver(gsc_hpdi_driver, gsc_hpdi_pci_driver);
MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("Comedi driver for General Standards PCI-HPDI32/PMC-HPDI32");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/me_daq.c b/drivers/staging/comedi/drivers/me_daq.c
index d78e9195fbce30..9ea1ba4b1b6fe8 100644
--- a/drivers/staging/comedi/drivers/me_daq.c
+++ b/drivers/staging/comedi/drivers/me_daq.c
@@ -173,8 +173,7 @@ struct me_private_data {
static inline void sleep(unsigned sec)
{
- __set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(sec * HZ);
+ schedule_timeout_interruptible(sec * HZ);
}
static int me_dio_insn_config(struct comedi_device *dev,
diff --git a/drivers/staging/comedi/drivers/mite.c b/drivers/staging/comedi/drivers/mite.c
index e43a0c8323c18e..fa7ae2c0455637 100644
--- a/drivers/staging/comedi/drivers/mite.c
+++ b/drivers/staging/comedi/drivers/mite.c
@@ -1,52 +1,51 @@
/*
- comedi/drivers/mite.c
- Hardware driver for NI Mite PCI interface chip
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1997-2002 David A. Schleef <ds@schleef.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 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.
-*/
+ * comedi/drivers/mite.c
+ * Hardware driver for NI Mite PCI interface chip
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1997-2002 David A. Schleef <ds@schleef.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 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.
+ */
/*
- The PCI-MIO E series driver was originally written by
- Tomasz Motylewski <...>, and ported to comedi by ds.
-
- References for specifications:
-
- 321747b.pdf Register Level Programmer Manual (obsolete)
- 321747c.pdf Register Level Programmer Manual (new)
- DAQ-STC reference manual
-
- Other possibly relevant info:
-
- 320517c.pdf User manual (obsolete)
- 320517f.pdf User manual (new)
- 320889a.pdf delete
- 320906c.pdf maximum signal ratings
- 321066a.pdf about 16x
- 321791a.pdf discontinuation of at-mio-16e-10 rev. c
- 321808a.pdf about at-mio-16e-10 rev P
- 321837a.pdf discontinuation of at-mio-16de-10 rev d
- 321838a.pdf about at-mio-16de-10 rev N
-
- ISSUES:
-
-*/
-
-/* #define USE_KMALLOC */
+ * The PCI-MIO E series driver was originally written by
+ * Tomasz Motylewski <...>, and ported to comedi by ds.
+ *
+ * References for specifications:
+ *
+ * 321747b.pdf Register Level Programmer Manual (obsolete)
+ * 321747c.pdf Register Level Programmer Manual (new)
+ * DAQ-STC reference manual
+ *
+ * Other possibly relevant info:
+ *
+ * 320517c.pdf User manual (obsolete)
+ * 320517f.pdf User manual (new)
+ * 320889a.pdf delete
+ * 320906c.pdf maximum signal ratings
+ * 321066a.pdf about 16x
+ * 321791a.pdf discontinuation of at-mio-16e-10 rev. c
+ * 321808a.pdf about at-mio-16e-10 rev P
+ * 321837a.pdf discontinuation of at-mio-16de-10 rev d
+ * 321838a.pdf about at-mio-16de-10 rev N
+ *
+ * ISSUES:
+ *
+ */
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/module.h>
+#include <linux/slab.h>
#include "../comedi_pci.h"
@@ -132,7 +131,7 @@ int mite_setup2(struct comedi_device *dev,
mite->mite_io_addr + MITE_IODWBSR);
}
/*
- * make sure dma bursts work. I got this from running a bus analyzer
+ * Make sure dma bursts work. I got this from running a bus analyzer
* on a pxi-6281 and a pxi-6713. 6713 powered up with register value
* of 0x61f and bursts worked. 6281 powered up with register value of
* 0x1f and bursts didn't work. The NI windows driver reads the
@@ -224,7 +223,8 @@ struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
unsigned long flags;
struct mite_channel *channel = NULL;
- /* spin lock so mite_release_channel can be called safely
+ /*
+ * spin lock so mite_release_channel can be called safely
* from interrupts
*/
spin_lock_irqsave(&mite->lock, flags);
@@ -246,15 +246,15 @@ void mite_release_channel(struct mite_channel *mite_chan)
struct mite_struct *mite = mite_chan->mite;
unsigned long flags;
- /* spin lock to prevent races with mite_request_channel */
+ /* spin lock to prevent races with mite_request_channel */
spin_lock_irqsave(&mite->lock, flags);
if (mite->channel_allocated[mite_chan->channel]) {
mite_dma_disarm(mite_chan);
mite_dma_reset(mite_chan);
- /*
- * disable all channel's interrupts (do it after disarm/reset so
- * MITE_CHCR reg isn't changed while dma is still active!)
- */
+ /*
+ * disable all channel's interrupts (do it after disarm/reset so
+ * MITE_CHCR reg isn't changed while dma is still active!)
+ */
writel(CHCR_CLR_DMA_IE | CHCR_CLR_LINKP_IE |
CHCR_CLR_SAR_IE | CHCR_CLR_DONE_IE |
CHCR_CLR_MRDY_IE | CHCR_CLR_DRDY_IE |
@@ -286,7 +286,7 @@ void mite_dma_arm(struct mite_channel *mite_chan)
writel(chor, mite->mite_io_addr + MITE_CHOR(mite_chan->channel));
mmiowb();
spin_unlock_irqrestore(&mite->lock, flags);
-/* mite_dma_tcr(mite, channel); */
+ /* mite_dma_tcr(mite, channel); */
}
EXPORT_SYMBOL_GPL(mite_dma_arm);
@@ -529,8 +529,10 @@ int mite_sync_input_dma(struct mite_channel *mite_chan,
}
count = nbytes - async->buf_write_count;
- /* it's possible count will be negative due to
- * conservative value returned by mite_bytes_written_to_memory_lb */
+ /*
+ * it's possible count will be negative due to conservative value
+ * returned by mite_bytes_written_to_memory_lb
+ */
if (count <= 0)
return 0;
@@ -551,7 +553,7 @@ int mite_sync_output_dma(struct mite_channel *mite_chan,
u32 nbytes_ub, nbytes_lb;
int count;
- /* read alloc as much as we can */
+ /* read alloc as much as we can */
comedi_buf_read_alloc(s, async->prealloc_bufsz);
nbytes_lb = mite_bytes_read_from_memory_lb(mite_chan);
if (cmd->stop_src == TRIG_COUNT && (int)(nbytes_lb - stop_count) > 0)
@@ -622,5 +624,5 @@ module_init(mite_module_init);
module_exit(mite_module_exit);
MODULE_AUTHOR("Comedi http://www.comedi.org");
-MODULE_DESCRIPTION("Comedi low-level driver");
+MODULE_DESCRIPTION("Comedi helper for NI Mite PCI interface chip");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/comedi/drivers/mite.h b/drivers/staging/comedi/drivers/mite.h
index b3ca7fc3a31e7d..c32d4e4ddccc52 100644
--- a/drivers/staging/comedi/drivers/mite.h
+++ b/drivers/staging/comedi/drivers/mite.h
@@ -1,32 +1,35 @@
/*
- module/mite.h
- Hardware driver for NI Mite PCI interface chip
-
- COMEDI - Linux Control and Measurement Device Interface
- Copyright (C) 1999 David A. Schleef <ds@schleef.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 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.
-*/
+ * module/mite.h
+ * Hardware driver for NI Mite PCI interface chip
+ *
+ * COMEDI - Linux Control and Measurement Device Interface
+ * Copyright (C) 1999 David A. Schleef <ds@schleef.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 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.
+ */
#ifndef _MITE_H_
#define _MITE_H_
+#include <linux/io.h>
#include <linux/log2.h>
-#include <linux/slab.h>
-#include "../comedi_pci.h"
-
-#define PCIMIO_COMPAT
+#include <linux/spinlock.h>
#define MAX_MITE_DMA_CHANNELS 8
+struct comedi_device;
+struct comedi_subdevice;
+struct device;
+struct pci_dev;
+
struct mite_dma_descriptor {
__le32 count;
__le32 addr;
@@ -74,16 +77,13 @@ static inline int mite_setup(struct comedi_device *dev,
void mite_detach(struct mite_struct *mite);
struct mite_dma_descriptor_ring *mite_alloc_ring(struct mite_struct *mite);
void mite_free_ring(struct mite_dma_descriptor_ring *ring);
-struct mite_channel *mite_request_channel_in_range(struct mite_struct *mite,
- struct
- mite_dma_descriptor_ring
- *ring, unsigned min_channel,
- unsigned max_channel);
-static inline struct mite_channel *mite_request_channel(struct mite_struct
- *mite,
- struct
- mite_dma_descriptor_ring
- *ring)
+struct mite_channel *
+mite_request_channel_in_range(struct mite_struct *mite,
+ struct mite_dma_descriptor_ring *ring,
+ unsigned min_channel, unsigned max_channel);
+static inline struct mite_channel *
+mite_request_channel(struct mite_struct *mite,
+ struct mite_dma_descriptor_ring *ring)
{
return mite_request_channel_in_range(mite, ring, 0,
mite->num_channels - 1);
@@ -112,12 +112,14 @@ int mite_buf_change(struct mite_dma_descriptor_ring *ring,
struct comedi_subdevice *s);
enum mite_registers {
- /* The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be
- written and read back. The bits 0x1f always read as 1.
- The rest always read as zero. */
+ /*
+ * The bits 0x90180700 in MITE_UNKNOWN_DMA_BURST_REG can be
+ * written and read back. The bits 0x1f always read as 1.
+ * The rest always read as zero.
+ */
MITE_UNKNOWN_DMA_BURST_REG = 0x28,
MITE_IODWBSR = 0xc0, /* IO Device Window Base Size Register */
- MITE_IODWBSR_1 = 0xc4, /* IO Device Window Base Size Register 1 */
+ MITE_IODWBSR_1 = 0xc4, /* IO Device Window Base Size Register 1 */
MITE_IODWCR_1 = 0xf4,
MITE_PCI_CONFIG_OFFSET = 0x300,
MITE_CSIGR = 0x460 /* chip signature */
@@ -143,7 +145,7 @@ enum mite_registers {
#define MITE_FCR(x) (0x40 + MITE_CHAN(x)) /* fifo count */
enum MITE_IODWBSR_bits {
- WENAB = 0x80, /* window enable */
+ WENAB = 0x80, /* window enable */
};
static inline unsigned MITE_IODWBSR_1_WSIZE_bits(unsigned size)
@@ -166,27 +168,27 @@ static inline int mite_csigr_version(u32 csigr_bits)
};
static inline int mite_csigr_type(u32 csigr_bits)
-{ /* original mite = 0, minimite = 1 */
+{ /* original mite = 0, minimite = 1 */
return (csigr_bits >> 4) & 0xf;
};
static inline int mite_csigr_mmode(u32 csigr_bits)
-{ /* mite mode, minimite = 1 */
+{ /* mite mode, minimite = 1 */
return (csigr_bits >> 8) & 0x3;
};
static inline int mite_csigr_imode(u32 csigr_bits)
-{ /* cpu port interface mode, pci = 0x3 */
+{ /* cpu port interface mode, pci = 0x3 */
return (csigr_bits >> 12) & 0x3;
};
static inline int mite_csigr_dmac(u32 csigr_bits)
-{ /* number of dma channels */
+{ /* number of dma channels */
return (csigr_bits >> 16) & 0xf;
};
static inline int mite_csigr_wpdep(u32 csigr_bits)
-{ /* write post fifo depth */
+{ /* write post fifo depth */
unsigned int wpdep_bits = (csigr_bits >> 20) & 0x7;
return (wpdep_bits) ? (1 << (wpdep_bits - 1)) : 0;
@@ -198,7 +200,7 @@ static inline int mite_csigr_wins(u32 csigr_bits)
};
static inline int mite_csigr_iowins(u32 csigr_bits)
-{ /* number of io windows */
+{ /* number of io windows */
return (csigr_bits >> 29) & 0x7;
};
@@ -280,6 +282,7 @@ enum ConfigRegister_bits {
CR_PORTMXI = (3 << 6),
CR_AMDEVICE = (1 << 0),
};
+
static inline int CR_REQS(int source)
{
return (source & 0x7) << 16;
@@ -287,8 +290,7 @@ static inline int CR_REQS(int source)
static inline int CR_REQSDRQ(unsigned drq_line)
{
- /* This also works on m-series when
- using channels (drq_line) 4 or 5. */
+ /* This also works on m-series when using channels (drq_line) 4 or 5. */
return CR_REQS((drq_line & 0x3) | 0x4);
}
diff --git a/drivers/staging/comedi/drivers/ni_mio_common.c b/drivers/staging/comedi/drivers/ni_mio_common.c
index c66affd993aa98..6cc304a4c59bfc 100644
--- a/drivers/staging/comedi/drivers/ni_mio_common.c
+++ b/drivers/staging/comedi/drivers/ni_mio_common.c
@@ -60,7 +60,6 @@
/* A timeout count */
#define NI_TIMEOUT 1000
-static const unsigned old_RTSI_clock_channel = 7;
/* Note: this table must match the ai_gain_* definitions */
static const short ni_gainlkup[][16] = {
@@ -308,262 +307,154 @@ static uint8_t ni_readb(struct comedi_device *dev, int reg)
* windowed STC registers to the m series register offsets.
*/
-static void m_series_stc_writel(struct comedi_device *dev,
- uint32_t data, int reg)
+struct mio_regmap {
+ unsigned int mio_reg;
+ int size;
+};
+
+static const struct mio_regmap m_series_stc_write_regmap[] = {
+ [NISTC_INTA_ACK_REG] = { 0x104, 2 },
+ [NISTC_INTB_ACK_REG] = { 0x106, 2 },
+ [NISTC_AI_CMD2_REG] = { 0x108, 2 },
+ [NISTC_AO_CMD2_REG] = { 0x10a, 2 },
+ [NISTC_G0_CMD_REG] = { 0x10c, 2 },
+ [NISTC_G1_CMD_REG] = { 0x10e, 2 },
+ [NISTC_AI_CMD1_REG] = { 0x110, 2 },
+ [NISTC_AO_CMD1_REG] = { 0x112, 2 },
+ /*
+ * NISTC_DIO_OUT_REG maps to:
+ * { NI_M_DIO_REG, 4 } and { NI_M_SCXI_SER_DO_REG, 1 }
+ */
+ [NISTC_DIO_OUT_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */
+ [NISTC_DIO_CTRL_REG] = { 0, 0 }, /* DOES NOT MAP CLEANLY */
+ [NISTC_AI_MODE1_REG] = { 0x118, 2 },
+ [NISTC_AI_MODE2_REG] = { 0x11a, 2 },
+ [NISTC_AI_SI_LOADA_REG] = { 0x11c, 4 },
+ [NISTC_AI_SI_LOADB_REG] = { 0x120, 4 },
+ [NISTC_AI_SC_LOADA_REG] = { 0x124, 4 },
+ [NISTC_AI_SC_LOADB_REG] = { 0x128, 4 },
+ [NISTC_AI_SI2_LOADA_REG] = { 0x12c, 4 },
+ [NISTC_AI_SI2_LOADB_REG] = { 0x130, 4 },
+ [NISTC_G0_MODE_REG] = { 0x134, 2 },
+ [NISTC_G1_MODE_REG] = { 0x136, 2 },
+ [NISTC_G0_LOADA_REG] = { 0x138, 4 },
+ [NISTC_G0_LOADB_REG] = { 0x13c, 4 },
+ [NISTC_G1_LOADA_REG] = { 0x140, 4 },
+ [NISTC_G1_LOADB_REG] = { 0x144, 4 },
+ [NISTC_G0_INPUT_SEL_REG] = { 0x148, 2 },
+ [NISTC_G1_INPUT_SEL_REG] = { 0x14a, 2 },
+ [NISTC_AO_MODE1_REG] = { 0x14c, 2 },
+ [NISTC_AO_MODE2_REG] = { 0x14e, 2 },
+ [NISTC_AO_UI_LOADA_REG] = { 0x150, 4 },
+ [NISTC_AO_UI_LOADB_REG] = { 0x154, 4 },
+ [NISTC_AO_BC_LOADA_REG] = { 0x158, 4 },
+ [NISTC_AO_BC_LOADB_REG] = { 0x15c, 4 },
+ [NISTC_AO_UC_LOADA_REG] = { 0x160, 4 },
+ [NISTC_AO_UC_LOADB_REG] = { 0x164, 4 },
+ [NISTC_CLK_FOUT_REG] = { 0x170, 2 },
+ [NISTC_IO_BIDIR_PIN_REG] = { 0x172, 2 },
+ [NISTC_RTSI_TRIG_DIR_REG] = { 0x174, 2 },
+ [NISTC_INT_CTRL_REG] = { 0x176, 2 },
+ [NISTC_AI_OUT_CTRL_REG] = { 0x178, 2 },
+ [NISTC_ATRIG_ETC_REG] = { 0x17a, 2 },
+ [NISTC_AI_START_STOP_REG] = { 0x17c, 2 },
+ [NISTC_AI_TRIG_SEL_REG] = { 0x17e, 2 },
+ [NISTC_AI_DIV_LOADA_REG] = { 0x180, 4 },
+ [NISTC_AO_START_SEL_REG] = { 0x184, 2 },
+ [NISTC_AO_TRIG_SEL_REG] = { 0x186, 2 },
+ [NISTC_G0_AUTOINC_REG] = { 0x188, 2 },
+ [NISTC_G1_AUTOINC_REG] = { 0x18a, 2 },
+ [NISTC_AO_MODE3_REG] = { 0x18c, 2 },
+ [NISTC_RESET_REG] = { 0x190, 2 },
+ [NISTC_INTA_ENA_REG] = { 0x192, 2 },
+ [NISTC_INTA2_ENA_REG] = { 0, 0 }, /* E-Series only */
+ [NISTC_INTB_ENA_REG] = { 0x196, 2 },
+ [NISTC_INTB2_ENA_REG] = { 0, 0 }, /* E-Series only */
+ [NISTC_AI_PERSONAL_REG] = { 0x19a, 2 },
+ [NISTC_AO_PERSONAL_REG] = { 0x19c, 2 },
+ [NISTC_RTSI_TRIGA_OUT_REG] = { 0x19e, 2 },
+ [NISTC_RTSI_TRIGB_OUT_REG] = { 0x1a0, 2 },
+ [NISTC_RTSI_BOARD_REG] = { 0, 0 }, /* Unknown */
+ [NISTC_CFG_MEM_CLR_REG] = { 0x1a4, 2 },
+ [NISTC_ADC_FIFO_CLR_REG] = { 0x1a6, 2 },
+ [NISTC_DAC_FIFO_CLR_REG] = { 0x1a8, 2 },
+ [NISTC_AO_OUT_CTRL_REG] = { 0x1ac, 2 },
+ [NISTC_AI_MODE3_REG] = { 0x1ae, 2 },
+};
+
+static void m_series_stc_write(struct comedi_device *dev,
+ unsigned int data, unsigned int reg)
{
- unsigned offset;
+ const struct mio_regmap *regmap;
- switch (reg) {
- case AI_SC_Load_A_Registers:
- offset = M_Offset_AI_SC_Load_A;
- break;
- case AI_SI_Load_A_Registers:
- offset = M_Offset_AI_SI_Load_A;
- break;
- case AO_BC_Load_A_Register:
- offset = M_Offset_AO_BC_Load_A;
- break;
- case AO_UC_Load_A_Register:
- offset = M_Offset_AO_UC_Load_A;
- break;
- case AO_UI_Load_A_Register:
- offset = M_Offset_AO_UI_Load_A;
- break;
- case G_Load_A_Register(0):
- offset = M_Offset_G0_Load_A;
- break;
- case G_Load_A_Register(1):
- offset = M_Offset_G1_Load_A;
- break;
- case G_Load_B_Register(0):
- offset = M_Offset_G0_Load_B;
- break;
- case G_Load_B_Register(1):
- offset = M_Offset_G1_Load_B;
- break;
- default:
- dev_warn(dev->class_dev,
- "%s: bug! unhandled register=0x%x in switch\n",
+ if (reg < ARRAY_SIZE(m_series_stc_write_regmap)) {
+ regmap = &m_series_stc_write_regmap[reg];
+ } else {
+ dev_warn(dev->class_dev, "%s: unhandled register=0x%x\n",
__func__, reg);
return;
}
- ni_writel(dev, data, offset);
-}
-static void m_series_stc_writew(struct comedi_device *dev,
- uint16_t data, int reg)
-{
- unsigned offset;
-
- switch (reg) {
- case ADC_FIFO_Clear:
- offset = M_Offset_AI_FIFO_Clear;
- break;
- case AI_Command_1_Register:
- offset = M_Offset_AI_Command_1;
- break;
- case AI_Command_2_Register:
- offset = M_Offset_AI_Command_2;
- break;
- case AI_Mode_1_Register:
- offset = M_Offset_AI_Mode_1;
- break;
- case AI_Mode_2_Register:
- offset = M_Offset_AI_Mode_2;
- break;
- case AI_Mode_3_Register:
- offset = M_Offset_AI_Mode_3;
- break;
- case AI_Output_Control_Register:
- offset = M_Offset_AI_Output_Control;
- break;
- case AI_Personal_Register:
- offset = M_Offset_AI_Personal;
- break;
- case AI_SI2_Load_A_Register:
- /* this is a 32 bit register on m series boards */
- ni_writel(dev, data, M_Offset_AI_SI2_Load_A);
- return;
- case AI_SI2_Load_B_Register:
- /* this is a 32 bit register on m series boards */
- ni_writel(dev, data, M_Offset_AI_SI2_Load_B);
- return;
- case AI_START_STOP_Select_Register:
- offset = M_Offset_AI_START_STOP_Select;
- break;
- case AI_Trigger_Select_Register:
- offset = M_Offset_AI_Trigger_Select;
- break;
- case Analog_Trigger_Etc_Register:
- offset = M_Offset_Analog_Trigger_Etc;
- break;
- case AO_Command_1_Register:
- offset = M_Offset_AO_Command_1;
- break;
- case AO_Command_2_Register:
- offset = M_Offset_AO_Command_2;
- break;
- case AO_Mode_1_Register:
- offset = M_Offset_AO_Mode_1;
- break;
- case AO_Mode_2_Register:
- offset = M_Offset_AO_Mode_2;
- break;
- case AO_Mode_3_Register:
- offset = M_Offset_AO_Mode_3;
- break;
- case AO_Output_Control_Register:
- offset = M_Offset_AO_Output_Control;
- break;
- case AO_Personal_Register:
- offset = M_Offset_AO_Personal;
- break;
- case AO_Start_Select_Register:
- offset = M_Offset_AO_Start_Select;
- break;
- case AO_Trigger_Select_Register:
- offset = M_Offset_AO_Trigger_Select;
- break;
- case Clock_and_FOUT_Register:
- offset = M_Offset_Clock_and_FOUT;
- break;
- case Configuration_Memory_Clear:
- offset = M_Offset_Configuration_Memory_Clear;
- break;
- case DAC_FIFO_Clear:
- offset = M_Offset_AO_FIFO_Clear;
- break;
- case DIO_Control_Register:
- dev_dbg(dev->class_dev,
- "%s: FIXME: register 0x%x does not map cleanly on to m-series boards\n",
- __func__, reg);
- return;
- case G_Autoincrement_Register(0):
- offset = M_Offset_G0_Autoincrement;
- break;
- case G_Autoincrement_Register(1):
- offset = M_Offset_G1_Autoincrement;
- break;
- case G_Command_Register(0):
- offset = M_Offset_G0_Command;
- break;
- case G_Command_Register(1):
- offset = M_Offset_G1_Command;
- break;
- case G_Input_Select_Register(0):
- offset = M_Offset_G0_Input_Select;
- break;
- case G_Input_Select_Register(1):
- offset = M_Offset_G1_Input_Select;
- break;
- case G_Mode_Register(0):
- offset = M_Offset_G0_Mode;
- break;
- case G_Mode_Register(1):
- offset = M_Offset_G1_Mode;
- break;
- case Interrupt_A_Ack_Register:
- offset = M_Offset_Interrupt_A_Ack;
- break;
- case Interrupt_A_Enable_Register:
- offset = M_Offset_Interrupt_A_Enable;
- break;
- case Interrupt_B_Ack_Register:
- offset = M_Offset_Interrupt_B_Ack;
- break;
- case Interrupt_B_Enable_Register:
- offset = M_Offset_Interrupt_B_Enable;
- break;
- case Interrupt_Control_Register:
- offset = M_Offset_Interrupt_Control;
- break;
- case IO_Bidirection_Pin_Register:
- offset = M_Offset_IO_Bidirection_Pin;
- break;
- case Joint_Reset_Register:
- offset = M_Offset_Joint_Reset;
- break;
- case RTSI_Trig_A_Output_Register:
- offset = M_Offset_RTSI_Trig_A_Output;
- break;
- case RTSI_Trig_B_Output_Register:
- offset = M_Offset_RTSI_Trig_B_Output;
+ switch (regmap->size) {
+ case 4:
+ ni_writel(dev, data, regmap->mio_reg);
break;
- case RTSI_Trig_Direction_Register:
- offset = M_Offset_RTSI_Trig_Direction;
+ case 2:
+ ni_writew(dev, data, regmap->mio_reg);
break;
- /*
- * FIXME: DIO_Output_Register (16 bit reg) is replaced by
- * M_Offset_Static_Digital_Output (32 bit) and
- * M_Offset_SCXI_Serial_Data_Out (8 bit)
- */
default:
- dev_warn(dev->class_dev,
- "%s: bug! unhandled register=0x%x in switch\n",
+ dev_warn(dev->class_dev, "%s: unmapped register=0x%x\n",
__func__, reg);
- return;
+ break;
}
- ni_writew(dev, data, offset);
}
-static uint32_t m_series_stc_readl(struct comedi_device *dev, int reg)
+static const struct mio_regmap m_series_stc_read_regmap[] = {
+ [NISTC_AI_STATUS1_REG] = { 0x104, 2 },
+ [NISTC_AO_STATUS1_REG] = { 0x106, 2 },
+ [NISTC_G01_STATUS_REG] = { 0x108, 2 },
+ [NISTC_AI_STATUS2_REG] = { 0, 0 }, /* Unknown */
+ [NISTC_AO_STATUS2_REG] = { 0x10c, 2 },
+ [NISTC_DIO_IN_REG] = { 0, 0 }, /* Unknown */
+ [NISTC_G0_HW_SAVE_REG] = { 0x110, 4 },
+ [NISTC_G1_HW_SAVE_REG] = { 0x114, 4 },
+ [NISTC_G0_SAVE_REG] = { 0x118, 4 },
+ [NISTC_G1_SAVE_REG] = { 0x11c, 4 },
+ [NISTC_AO_UI_SAVE_REG] = { 0x120, 4 },
+ [NISTC_AO_BC_SAVE_REG] = { 0x124, 4 },
+ [NISTC_AO_UC_SAVE_REG] = { 0x128, 4 },
+ [NISTC_STATUS1_REG] = { 0x136, 2 },
+ [NISTC_DIO_SERIAL_IN_REG] = { 0x009, 1 },
+ [NISTC_STATUS2_REG] = { 0x13a, 2 },
+ [NISTC_AI_SI_SAVE_REG] = { 0x180, 4 },
+ [NISTC_AI_SC_SAVE_REG] = { 0x184, 4 },
+};
+
+static unsigned int m_series_stc_read(struct comedi_device *dev,
+ unsigned int reg)
{
- unsigned offset;
+ const struct mio_regmap *regmap;
- switch (reg) {
- case G_HW_Save_Register(0):
- offset = M_Offset_G0_HW_Save;
- break;
- case G_HW_Save_Register(1):
- offset = M_Offset_G1_HW_Save;
- break;
- case G_Save_Register(0):
- offset = M_Offset_G0_Save;
- break;
- case G_Save_Register(1):
- offset = M_Offset_G1_Save;
- break;
- default:
- dev_warn(dev->class_dev,
- "%s: bug! unhandled register=0x%x in switch\n",
+ if (reg < ARRAY_SIZE(m_series_stc_read_regmap)) {
+ regmap = &m_series_stc_read_regmap[reg];
+ } else {
+ dev_warn(dev->class_dev, "%s: unhandled register=0x%x\n",
__func__, reg);
return 0;
}
- return ni_readl(dev, offset);
-}
-static uint16_t m_series_stc_readw(struct comedi_device *dev, int reg)
-{
- unsigned offset;
-
- switch (reg) {
- case AI_Status_1_Register:
- offset = M_Offset_AI_Status_1;
- break;
- case AO_Status_1_Register:
- offset = M_Offset_AO_Status_1;
- break;
- case AO_Status_2_Register:
- offset = M_Offset_AO_Status_2;
- break;
- case DIO_Serial_Input_Register:
- return ni_readb(dev, M_Offset_SCXI_Serial_Data_In);
- case Joint_Status_1_Register:
- offset = M_Offset_Joint_Status_1;
- break;
- case Joint_Status_2_Register:
- offset = M_Offset_Joint_Status_2;
- break;
- case G_Status_Register:
- offset = M_Offset_G01_Status;
- break;
+ switch (regmap->size) {
+ case 4:
+ return ni_readl(dev, regmap->mio_reg);
+ case 2:
+ return ni_readw(dev, regmap->mio_reg);
+ case 1:
+ return ni_readb(dev, regmap->mio_reg);
default:
- dev_warn(dev->class_dev,
- "%s: bug! unhandled register=0x%x in switch\n",
+ dev_warn(dev->class_dev, "%s: unmapped register=0x%x\n",
__func__, reg);
return 0;
}
- return ni_readw(dev, offset);
}
static void ni_stc_writew(struct comedi_device *dev, uint16_t data, int reg)
@@ -572,14 +463,14 @@ static void ni_stc_writew(struct comedi_device *dev, uint16_t data, int reg)
unsigned long flags;
if (devpriv->is_m_series) {
- m_series_stc_writew(dev, data, reg);
+ m_series_stc_write(dev, data, reg);
} else {
spin_lock_irqsave(&devpriv->window_lock, flags);
if (!devpriv->mite && reg < 8) {
ni_writew(dev, data, reg * 2);
} else {
- ni_writew(dev, reg, Window_Address);
- ni_writew(dev, data, Window_Data);
+ ni_writew(dev, reg, NI_E_STC_WINDOW_ADDR_REG);
+ ni_writew(dev, data, NI_E_STC_WINDOW_DATA_REG);
}
spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
@@ -590,7 +481,7 @@ static void ni_stc_writel(struct comedi_device *dev, uint32_t data, int reg)
struct ni_private *devpriv = dev->private;
if (devpriv->is_m_series) {
- m_series_stc_writel(dev, data, reg);
+ m_series_stc_write(dev, data, reg);
} else {
ni_stc_writew(dev, data >> 16, reg);
ni_stc_writew(dev, data & 0xffff, reg + 1);
@@ -604,14 +495,14 @@ static uint16_t ni_stc_readw(struct comedi_device *dev, int reg)
uint16_t val;
if (devpriv->is_m_series) {
- val = m_series_stc_readw(dev, reg);
+ val = m_series_stc_read(dev, reg);
} else {
spin_lock_irqsave(&devpriv->window_lock, flags);
if (!devpriv->mite && reg < 8) {
val = ni_readw(dev, reg * 2);
} else {
- ni_writew(dev, reg, Window_Address);
- val = ni_readw(dev, Window_Data);
+ ni_writew(dev, reg, NI_E_STC_WINDOW_ADDR_REG);
+ val = ni_readw(dev, NI_E_STC_WINDOW_DATA_REG);
}
spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
@@ -624,7 +515,7 @@ static uint32_t ni_stc_readl(struct comedi_device *dev, int reg)
uint32_t val;
if (devpriv->is_m_series) {
- val = m_series_stc_readl(dev, reg);
+ val = m_series_stc_read(dev, reg);
} else {
val = ni_stc_readw(dev, reg) << 16;
val |= ni_stc_readw(dev, reg + 1);
@@ -640,33 +531,30 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags);
switch (reg) {
- case Interrupt_A_Enable_Register:
+ case NISTC_INTA_ENA_REG:
devpriv->int_a_enable_reg &= ~bit_mask;
devpriv->int_a_enable_reg |= bit_values & bit_mask;
- ni_stc_writew(dev, devpriv->int_a_enable_reg,
- Interrupt_A_Enable_Register);
+ ni_stc_writew(dev, devpriv->int_a_enable_reg, reg);
break;
- case Interrupt_B_Enable_Register:
+ case NISTC_INTB_ENA_REG:
devpriv->int_b_enable_reg &= ~bit_mask;
devpriv->int_b_enable_reg |= bit_values & bit_mask;
- ni_stc_writew(dev, devpriv->int_b_enable_reg,
- Interrupt_B_Enable_Register);
+ ni_stc_writew(dev, devpriv->int_b_enable_reg, reg);
break;
- case IO_Bidirection_Pin_Register:
+ case NISTC_IO_BIDIR_PIN_REG:
devpriv->io_bidirection_pin_reg &= ~bit_mask;
devpriv->io_bidirection_pin_reg |= bit_values & bit_mask;
- ni_stc_writew(dev, devpriv->io_bidirection_pin_reg,
- IO_Bidirection_Pin_Register);
+ ni_stc_writew(dev, devpriv->io_bidirection_pin_reg, reg);
break;
- case AI_AO_Select:
+ case NI_E_DMA_AI_AO_SEL_REG:
devpriv->ai_ao_select_reg &= ~bit_mask;
devpriv->ai_ao_select_reg |= bit_values & bit_mask;
- ni_writeb(dev, devpriv->ai_ao_select_reg, AI_AO_Select);
+ ni_writeb(dev, devpriv->ai_ao_select_reg, reg);
break;
- case G0_G1_Select:
+ case NI_E_DMA_G0_G1_SEL_REG:
devpriv->g0_g1_select_reg &= ~bit_mask;
devpriv->g0_g1_select_reg |= bit_values & bit_mask;
- ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select);
+ ni_writeb(dev, devpriv->g0_g1_select_reg, reg);
break;
default:
dev_err(dev->class_dev, "called with invalid register %d\n",
@@ -679,48 +567,55 @@ static inline void ni_set_bitfield(struct comedi_device *dev, int reg,
#ifdef PCIDMA
/* DMA channel setup */
+static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel)
+{
+ if (channel < 4)
+ return 1 << channel;
+ if (channel == 4)
+ return 0x3;
+ if (channel == 5)
+ return 0x5;
+ BUG();
+ return 0;
+}
/* negative channel means no channel */
static inline void ni_set_ai_dma_channel(struct comedi_device *dev, int channel)
{
- unsigned bitfield;
+ unsigned bits = 0;
if (channel >= 0)
- bitfield =
- (ni_stc_dma_channel_select_bitfield(channel) <<
- AI_DMA_Select_Shift) & AI_DMA_Select_Mask;
- else
- bitfield = 0;
- ni_set_bitfield(dev, AI_AO_Select, AI_DMA_Select_Mask, bitfield);
+ bits = ni_stc_dma_channel_select_bitfield(channel);
+
+ ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG,
+ NI_E_DMA_AI_SEL_MASK, NI_E_DMA_AI_SEL(bits));
}
/* negative channel means no channel */
static inline void ni_set_ao_dma_channel(struct comedi_device *dev, int channel)
{
- unsigned bitfield;
+ unsigned bits = 0;
if (channel >= 0)
- bitfield =
- (ni_stc_dma_channel_select_bitfield(channel) <<
- AO_DMA_Select_Shift) & AO_DMA_Select_Mask;
- else
- bitfield = 0;
- ni_set_bitfield(dev, AI_AO_Select, AO_DMA_Select_Mask, bitfield);
+ bits = ni_stc_dma_channel_select_bitfield(channel);
+
+ ni_set_bitfield(dev, NI_E_DMA_AI_AO_SEL_REG,
+ NI_E_DMA_AO_SEL_MASK, NI_E_DMA_AO_SEL(bits));
}
-/* negative mite_channel means no channel */
+/* negative channel means no channel */
static inline void ni_set_gpct_dma_channel(struct comedi_device *dev,
unsigned gpct_index,
- int mite_channel)
+ int channel)
{
- unsigned bitfield;
+ unsigned bits = 0;
- if (mite_channel >= 0)
- bitfield = GPCT_DMA_Select_Bits(gpct_index, mite_channel);
- else
- bitfield = 0;
- ni_set_bitfield(dev, G0_G1_Select, GPCT_DMA_Select_Mask(gpct_index),
- bitfield);
+ if (channel >= 0)
+ bits = ni_stc_dma_channel_select_bitfield(channel);
+
+ ni_set_bitfield(dev, NI_E_DMA_G0_G1_SEL_REG,
+ NI_E_DMA_G0_G1_SEL_MASK(gpct_index),
+ NI_E_DMA_G0_G1_SEL(gpct_index, bits));
}
/* negative mite_channel means no channel */
@@ -729,18 +624,21 @@ static inline void ni_set_cdo_dma_channel(struct comedi_device *dev,
{
struct ni_private *devpriv = dev->private;
unsigned long flags;
+ unsigned bits;
spin_lock_irqsave(&devpriv->soft_reg_copy_lock, flags);
- devpriv->cdio_dma_select_reg &= ~CDO_DMA_Select_Mask;
+ devpriv->cdio_dma_select_reg &= ~NI_M_CDIO_DMA_SEL_CDO_MASK;
if (mite_channel >= 0) {
- /*XXX just guessing ni_stc_dma_channel_select_bitfield() returns the right bits,
- under the assumption the cdio dma selection works just like ai/ao/gpct.
- Definitely works for dma channels 0 and 1. */
- devpriv->cdio_dma_select_reg |=
- (ni_stc_dma_channel_select_bitfield(mite_channel) <<
- CDO_DMA_Select_Shift) & CDO_DMA_Select_Mask;
- }
- ni_writeb(dev, devpriv->cdio_dma_select_reg, M_Offset_CDIO_DMA_Select);
+ /*
+ * XXX just guessing ni_stc_dma_channel_select_bitfield()
+ * returns the right bits, under the assumption the cdio dma
+ * selection works just like ai/ao/gpct.
+ * Definitely works for dma channels 0 and 1.
+ */
+ bits = ni_stc_dma_channel_select_bitfield(mite_channel);
+ devpriv->cdio_dma_select_reg |= NI_M_CDIO_DMA_SEL_CDO(bits);
+ }
+ ni_writeb(dev, devpriv->cdio_dma_select_reg, NI_M_CDIO_DMA_SEL_REG);
mmiowb();
spin_unlock_irqrestore(&devpriv->soft_reg_copy_lock, flags);
}
@@ -795,7 +693,6 @@ static int ni_request_gpct_mite_channel(struct comedi_device *dev,
unsigned long flags;
struct mite_channel *mite_chan;
- BUG_ON(gpct_index >= NUM_GPCT);
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
BUG_ON(devpriv->counter_dev->counters[gpct_index].mite_chan);
mite_chan =
@@ -879,7 +776,6 @@ static void ni_release_gpct_mite_channel(struct comedi_device *dev,
struct ni_private *devpriv = dev->private;
unsigned long flags;
- BUG_ON(gpct_index >= NUM_GPCT);
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->counter_dev->counters[gpct_index].mite_chan) {
struct mite_channel *mite_chan =
@@ -927,13 +823,13 @@ static void ni_e_series_enable_second_irq(struct comedi_device *dev,
* dma requests for their counters
*/
if (gpct_index == 0) {
- reg = Second_IRQ_A_Enable_Register;
+ reg = NISTC_INTA2_ENA_REG;
if (enable)
- val = G0_Gate_Second_Irq_Enable;
+ val = NISTC_INTA_ENA_G0_GATE;
} else {
- reg = Second_IRQ_B_Enable_Register;
+ reg = NISTC_INTB2_ENA_REG;
if (enable)
- val = G1_Gate_Second_Irq_Enable;
+ val = NISTC_INTB_ENA_G1_GATE;
}
ni_stc_writew(dev, val, reg);
}
@@ -947,30 +843,30 @@ static void ni_clear_ai_fifo(struct comedi_device *dev)
if (devpriv->is_6143) {
/* Flush the 6143 data FIFO */
- ni_writel(dev, 0x10, AIFIFO_Control_6143);
- ni_writel(dev, 0x00, AIFIFO_Control_6143);
+ ni_writel(dev, 0x10, NI6143_AI_FIFO_CTRL_REG);
+ ni_writel(dev, 0x00, NI6143_AI_FIFO_CTRL_REG);
/* Wait for complete */
for (i = 0; i < timeout; i++) {
- if (!(ni_readl(dev, AIFIFO_Status_6143) & 0x10))
+ if (!(ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x10))
break;
udelay(1);
}
if (i == timeout)
dev_err(dev->class_dev, "FIFO flush timeout\n");
} else {
- ni_stc_writew(dev, 1, ADC_FIFO_Clear);
+ ni_stc_writew(dev, 1, NISTC_ADC_FIFO_CLR_REG);
if (devpriv->is_625x) {
- ni_writeb(dev, 0, M_Offset_Static_AI_Control(0));
- ni_writeb(dev, 1, M_Offset_Static_AI_Control(0));
+ ni_writeb(dev, 0, NI_M_STATIC_AI_CTRL_REG(0));
+ ni_writeb(dev, 1, NI_M_STATIC_AI_CTRL_REG(0));
#if 0
/* the NI example code does 3 convert pulses for 625x boards,
but that appears to be wrong in practice. */
- ni_stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
- ni_stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
- ni_stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE,
+ NISTC_AI_CMD1_REG);
+ ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE,
+ NISTC_AI_CMD1_REG);
+ ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE,
+ NISTC_AI_CMD1_REG);
#endif
}
}
@@ -983,8 +879,8 @@ static inline void ni_ao_win_outw(struct comedi_device *dev, uint16_t data,
unsigned long flags;
spin_lock_irqsave(&devpriv->window_lock, flags);
- ni_writew(dev, addr, AO_Window_Address_611x);
- ni_writew(dev, data, AO_Window_Data_611x);
+ ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG);
+ ni_writew(dev, data, NI611X_AO_WINDOW_DATA_REG);
spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
@@ -995,8 +891,8 @@ static inline void ni_ao_win_outl(struct comedi_device *dev, uint32_t data,
unsigned long flags;
spin_lock_irqsave(&devpriv->window_lock, flags);
- ni_writew(dev, addr, AO_Window_Address_611x);
- ni_writel(dev, data, AO_Window_Data_611x);
+ ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG);
+ ni_writel(dev, data, NI611X_AO_WINDOW_DATA_REG);
spin_unlock_irqrestore(&devpriv->window_lock, flags);
}
@@ -1007,8 +903,8 @@ static inline unsigned short ni_ao_win_inw(struct comedi_device *dev, int addr)
unsigned short data;
spin_lock_irqsave(&devpriv->window_lock, flags);
- ni_writew(dev, addr, AO_Window_Address_611x);
- data = ni_readw(dev, AO_Window_Data_611x);
+ ni_writew(dev, addr, NI611X_AO_WINDOW_ADDR_REG);
+ data = ni_readw(dev, NI611X_AO_WINDOW_DATA_REG);
spin_unlock_irqrestore(&devpriv->window_lock, flags);
return data;
}
@@ -1059,8 +955,8 @@ static int ni_ai_drain_dma(struct comedi_device *dev)
spin_lock_irqsave(&devpriv->mite_channel_lock, flags);
if (devpriv->ai_mite_chan) {
for (i = 0; i < timeout; i++) {
- if ((ni_stc_readw(dev, AI_Status_1_Register) &
- AI_FIFO_Empty_St)
+ if ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+ NISTC_AI_STATUS1_FIFO_E)
&& mite_bytes_in_transit(devpriv->ai_mite_chan) ==
0)
break;
@@ -1071,7 +967,7 @@ static int ni_ai_drain_dma(struct comedi_device *dev)
dev_err(dev->class_dev,
"mite_bytes_in_transit=%i, AI_Status1_Register=0x%x\n",
mite_bytes_in_transit(devpriv->ai_mite_chan),
- ni_stc_readw(dev, AI_Status_1_Register));
+ ni_stc_readw(dev, NISTC_AI_STATUS1_REG));
retval = -1;
}
}
@@ -1103,8 +999,8 @@ static int ni_ao_wait_for_dma_load(struct comedi_device *dev)
for (i = 0; i < timeout; i++) {
unsigned short b_status;
- b_status = ni_stc_readw(dev, AO_Status_1_Register);
- if (b_status & AO_FIFO_Half_Full_St)
+ b_status = ni_stc_readw(dev, NISTC_AO_STATUS1_REG);
+ if (b_status & NISTC_AO_STATUS1_FIFO_HF)
break;
/* if we poll too often, the pci bus activity seems
to slow the dma transfer down */
@@ -1139,9 +1035,9 @@ static void ni_ao_fifo_load(struct comedi_device *dev,
i++;
packed_data |= (d << 16) & 0xffff0000;
}
- ni_writel(dev, packed_data, DAC_FIFO_Data_611x);
+ ni_writel(dev, packed_data, NI611X_AO_FIFO_DATA_REG);
} else {
- ni_writew(dev, d, DAC_FIFO_Data);
+ ni_writew(dev, d, NI_E_AO_FIFO_DATA_REG);
}
}
}
@@ -1193,9 +1089,9 @@ static int ni_ao_prep_fifo(struct comedi_device *dev,
unsigned int nsamples;
/* reset fifo */
- ni_stc_writew(dev, 1, DAC_FIFO_Clear);
+ ni_stc_writew(dev, 1, NISTC_DAC_FIFO_CLR_REG);
if (devpriv->is_6xxx)
- ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x);
+ ni_ao_win_outl(dev, 0x6, NI611X_AO_FIFO_OFFSET_LOAD_REG);
/* load some data */
nbytes = comedi_buf_read_n_available(s);
@@ -1222,7 +1118,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
if (devpriv->is_611x) {
for (i = 0; i < n / 2; i++) {
- dl = ni_readl(dev, ADC_FIFO_Data_611x);
+ dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
/* This may get the hi/lo data in the wrong order */
data = (dl >> 16) & 0xffff;
comedi_buf_write_samples(s, &data, 1);
@@ -1231,14 +1127,14 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
}
/* Check if there's a single sample stuck in the FIFO */
if (n % 2) {
- dl = ni_readl(dev, ADC_FIFO_Data_611x);
+ dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
data = dl & 0xffff;
comedi_buf_write_samples(s, &data, 1);
}
} else if (devpriv->is_6143) {
/* This just reads the FIFO assuming the data is present, no checks on the FIFO status are performed */
for (i = 0; i < n / 2; i++) {
- dl = ni_readl(dev, AIFIFO_Data_6143);
+ dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
data = (dl >> 16) & 0xffff;
comedi_buf_write_samples(s, &data, 1);
@@ -1248,8 +1144,8 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
if (n % 2) {
/* Assume there is a single sample stuck in the FIFO */
/* Get stranded sample into FIFO */
- ni_writel(dev, 0x01, AIFIFO_Control_6143);
- dl = ni_readl(dev, AIFIFO_Data_6143);
+ ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG);
+ dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
data = (dl >> 16) & 0xffff;
comedi_buf_write_samples(s, &data, 1);
}
@@ -1263,7 +1159,7 @@ static void ni_ai_fifo_read(struct comedi_device *dev,
}
for (i = 0; i < n; i++) {
devpriv->ai_fifo_buffer[i] =
- ni_readw(dev, ADC_FIFO_Data_Register);
+ ni_readw(dev, NI_E_AI_FIFO_DATA_REG);
}
comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, n);
}
@@ -1294,9 +1190,9 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
int i;
if (devpriv->is_611x) {
- while ((ni_stc_readw(dev, AI_Status_1_Register) &
- AI_FIFO_Empty_St) == 0) {
- dl = ni_readl(dev, ADC_FIFO_Data_611x);
+ while ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+ NISTC_AI_STATUS1_FIFO_E) == 0) {
+ dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
/* This may get the hi/lo data in the wrong order */
data = dl >> 16;
@@ -1306,8 +1202,8 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
}
} else if (devpriv->is_6143) {
i = 0;
- while (ni_readl(dev, AIFIFO_Status_6143) & 0x04) {
- dl = ni_readl(dev, AIFIFO_Data_6143);
+ while (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x04) {
+ dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
/* This may get the hi/lo data in the wrong order */
data = dl >> 16;
@@ -1317,29 +1213,29 @@ static void ni_handle_fifo_dregs(struct comedi_device *dev)
i += 2;
}
/* Check if stranded sample is present */
- if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) {
+ if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x01) {
/* Get stranded sample into FIFO */
- ni_writel(dev, 0x01, AIFIFO_Control_6143);
- dl = ni_readl(dev, AIFIFO_Data_6143);
+ ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG);
+ dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
data = (dl >> 16) & 0xffff;
comedi_buf_write_samples(s, &data, 1);
}
} else {
- fifo_empty = ni_stc_readw(dev, AI_Status_1_Register) &
- AI_FIFO_Empty_St;
+ fifo_empty = ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+ NISTC_AI_STATUS1_FIFO_E;
while (fifo_empty == 0) {
for (i = 0;
i <
sizeof(devpriv->ai_fifo_buffer) /
sizeof(devpriv->ai_fifo_buffer[0]); i++) {
fifo_empty = ni_stc_readw(dev,
- AI_Status_1_Register) &
- AI_FIFO_Empty_St;
+ NISTC_AI_STATUS1_REG) &
+ NISTC_AI_STATUS1_FIFO_E;
if (fifo_empty)
break;
devpriv->ai_fifo_buffer[i] =
- ni_readw(dev, ADC_FIFO_Data_Register);
+ ni_readw(dev, NI_E_AI_FIFO_DATA_REG);
}
comedi_buf_write_samples(s, devpriv->ai_fifo_buffer, i);
}
@@ -1357,8 +1253,8 @@ static void get_last_sample_611x(struct comedi_device *dev)
return;
/* Check if there's a single sample stuck in the FIFO */
- if (ni_readb(dev, XXX_Status) & 0x80) {
- dl = ni_readl(dev, ADC_FIFO_Data_611x);
+ if (ni_readb(dev, NI_E_STATUS_REG) & 0x80) {
+ dl = ni_readl(dev, NI611X_AI_FIFO_DATA_REG);
data = dl & 0xffff;
comedi_buf_write_samples(s, &data, 1);
}
@@ -1375,10 +1271,10 @@ static void get_last_sample_6143(struct comedi_device *dev)
return;
/* Check if there's a single sample stuck in the FIFO */
- if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) {
+ if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) & 0x01) {
/* Get stranded sample into FIFO */
- ni_writel(dev, 0x01, AIFIFO_Control_6143);
- dl = ni_readl(dev, AIFIFO_Data_6143);
+ ni_writel(dev, 0x01, NI6143_AI_FIFO_CTRL_REG);
+ dl = ni_readl(dev, NI6143_AI_FIFO_DATA_REG);
/* This may get the hi/lo data in the wrong order */
data = (dl >> 16) & 0xffff;
@@ -1420,8 +1316,8 @@ static void ni_handle_eos(struct comedi_device *dev, struct comedi_subdevice *s)
s->async->events |= COMEDI_CB_EOS;
#endif
}
- /* handle special case of single scan using AI_End_On_End_Of_Scan */
- if ((devpriv->ai_cmd2 & AI_End_On_End_Of_Scan))
+ /* handle special case of single scan */
+ if (devpriv->ai_cmd2 & NISTC_AI_CMD2_END_ON_EOS)
shutdown_ai_command(dev);
}
@@ -1444,17 +1340,16 @@ static void ack_a_interrupt(struct comedi_device *dev, unsigned short a_status)
{
unsigned short ack = 0;
- if (a_status & AI_SC_TC_St)
- ack |= AI_SC_TC_Interrupt_Ack;
- if (a_status & AI_START1_St)
- ack |= AI_START1_Interrupt_Ack;
- if (a_status & AI_START_St)
- ack |= AI_START_Interrupt_Ack;
- if (a_status & AI_STOP_St)
- /* not sure why we used to ack the START here also, instead of doing it independently. Frank Hess 2007-07-06 */
- ack |= AI_STOP_Interrupt_Ack /*| AI_START_Interrupt_Ack */;
+ if (a_status & NISTC_AI_STATUS1_SC_TC)
+ ack |= NISTC_INTA_ACK_AI_SC_TC;
+ if (a_status & NISTC_AI_STATUS1_START1)
+ ack |= NISTC_INTA_ACK_AI_START1;
+ if (a_status & NISTC_AI_STATUS1_START)
+ ack |= NISTC_INTA_ACK_AI_START;
+ if (a_status & NISTC_AI_STATUS1_STOP)
+ ack |= NISTC_INTA_ACK_AI_STOP;
if (ack)
- ni_stc_writew(dev, ack, Interrupt_A_Ack_Register);
+ ni_stc_writew(dev, ack, NISTC_INTA_ACK_REG);
}
static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
@@ -1483,8 +1378,8 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
#endif
/* test for all uncommon interrupt events at the same time */
- if (status & (AI_Overrun_St | AI_Overflow_St | AI_SC_TC_Error_St |
- AI_SC_TC_St | AI_START1_St)) {
+ if (status & (NISTC_AI_STATUS1_ERR |
+ NISTC_AI_STATUS1_SC_TC | NISTC_AI_STATUS1_START1)) {
if (status == 0xffff) {
dev_err(dev->class_dev, "Card removed?\n");
/* we probably aren't even running a command now,
@@ -1495,41 +1390,40 @@ static void handle_a_interrupt(struct comedi_device *dev, unsigned short status,
}
return;
}
- if (status & (AI_Overrun_St | AI_Overflow_St |
- AI_SC_TC_Error_St)) {
+ if (status & NISTC_AI_STATUS1_ERR) {
dev_err(dev->class_dev, "ai error a_status=%04x\n",
status);
shutdown_ai_command(dev);
s->async->events |= COMEDI_CB_ERROR;
- if (status & (AI_Overrun_St | AI_Overflow_St))
+ if (status & NISTC_AI_STATUS1_OVER)
s->async->events |= COMEDI_CB_OVERFLOW;
comedi_handle_events(dev, s);
return;
}
- if (status & AI_SC_TC_St) {
+ if (status & NISTC_AI_STATUS1_SC_TC) {
if (cmd->stop_src == TRIG_COUNT)
shutdown_ai_command(dev);
}
}
#ifndef PCIDMA
- if (status & AI_FIFO_Half_Full_St) {
+ if (status & NISTC_AI_STATUS1_FIFO_HF) {
int i;
static const int timeout = 10;
/* pcmcia cards (at least 6036) seem to stop producing interrupts if we
*fail to get the fifo less than half full, so loop to be sure.*/
for (i = 0; i < timeout; ++i) {
ni_handle_fifo_half_full(dev);
- if ((ni_stc_readw(dev, AI_Status_1_Register) &
- AI_FIFO_Half_Full_St) == 0)
+ if ((ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+ NISTC_AI_STATUS1_FIFO_HF) == 0)
break;
}
}
#endif /* !PCIDMA */
- if ((status & AI_STOP_St))
+ if (status & NISTC_AI_STATUS1_STOP)
ni_handle_eos(dev, s);
comedi_handle_events(dev, s);
@@ -1539,22 +1433,22 @@ static void ack_b_interrupt(struct comedi_device *dev, unsigned short b_status)
{
unsigned short ack = 0;
- if (b_status & AO_BC_TC_St)
- ack |= AO_BC_TC_Interrupt_Ack;
- if (b_status & AO_Overrun_St)
- ack |= AO_Error_Interrupt_Ack;
- if (b_status & AO_START_St)
- ack |= AO_START_Interrupt_Ack;
- if (b_status & AO_START1_St)
- ack |= AO_START1_Interrupt_Ack;
- if (b_status & AO_UC_TC_St)
- ack |= AO_UC_TC_Interrupt_Ack;
- if (b_status & AO_UI2_TC_St)
- ack |= AO_UI2_TC_Interrupt_Ack;
- if (b_status & AO_UPDATE_St)
- ack |= AO_UPDATE_Interrupt_Ack;
+ if (b_status & NISTC_AO_STATUS1_BC_TC)
+ ack |= NISTC_INTB_ACK_AO_BC_TC;
+ if (b_status & NISTC_AO_STATUS1_OVERRUN)
+ ack |= NISTC_INTB_ACK_AO_ERR;
+ if (b_status & NISTC_AO_STATUS1_START)
+ ack |= NISTC_INTB_ACK_AO_START;
+ if (b_status & NISTC_AO_STATUS1_START1)
+ ack |= NISTC_INTB_ACK_AO_START1;
+ if (b_status & NISTC_AO_STATUS1_UC_TC)
+ ack |= NISTC_INTB_ACK_AO_UC_TC;
+ if (b_status & NISTC_AO_STATUS1_UI2_TC)
+ ack |= NISTC_INTB_ACK_AO_UI2_TC;
+ if (b_status & NISTC_AO_STATUS1_UPDATE)
+ ack |= NISTC_INTB_ACK_AO_UPDATE;
if (ack)
- ni_stc_writew(dev, ack, Interrupt_B_Ack_Register);
+ ni_stc_writew(dev, ack, NISTC_INTB_ACK_REG);
}
static void handle_b_interrupt(struct comedi_device *dev,
@@ -1583,26 +1477,26 @@ static void handle_b_interrupt(struct comedi_device *dev,
if (b_status == 0xffff)
return;
- if (b_status & AO_Overrun_St) {
+ if (b_status & NISTC_AO_STATUS1_OVERRUN) {
dev_err(dev->class_dev,
"AO FIFO underrun status=0x%04x status2=0x%04x\n",
- b_status, ni_stc_readw(dev, AO_Status_2_Register));
+ b_status, ni_stc_readw(dev, NISTC_AO_STATUS2_REG));
s->async->events |= COMEDI_CB_OVERFLOW;
}
- if (b_status & AO_BC_TC_St)
+ if (b_status & NISTC_AO_STATUS1_BC_TC)
s->async->events |= COMEDI_CB_EOA;
#ifndef PCIDMA
- if (b_status & AO_FIFO_Request_St) {
+ if (b_status & NISTC_AO_STATUS1_FIFO_REQ) {
int ret;
ret = ni_ao_fifo_half_empty(dev, s);
if (!ret) {
dev_err(dev->class_dev, "AO buffer underrun\n");
- ni_set_bits(dev, Interrupt_B_Enable_Register,
- AO_FIFO_Interrupt_Enable |
- AO_Error_Interrupt_Enable, 0);
+ ni_set_bits(dev, NISTC_INTB_ENA_REG,
+ NISTC_INTB_ENA_AO_FIFO |
+ NISTC_INTB_ENA_AO_ERR, 0);
s->async->events |= COMEDI_CB_OVERFLOW;
}
}
@@ -1718,101 +1612,65 @@ static int ni_ao_setup_MITE_dma(struct comedi_device *dev)
static int ni_ai_reset(struct comedi_device *dev, struct comedi_subdevice *s)
{
struct ni_private *devpriv = dev->private;
+ unsigned ai_personal;
+ unsigned ai_out_ctrl;
ni_release_ai_mite_channel(dev);
/* ai configuration */
- ni_stc_writew(dev, AI_Configuration_Start | AI_Reset,
- Joint_Reset_Register);
+ ni_stc_writew(dev, NISTC_RESET_AI_CFG_START | NISTC_RESET_AI,
+ NISTC_RESET_REG);
- ni_set_bits(dev, Interrupt_A_Enable_Register,
- AI_SC_TC_Interrupt_Enable | AI_START1_Interrupt_Enable |
- AI_START2_Interrupt_Enable | AI_START_Interrupt_Enable |
- AI_STOP_Interrupt_Enable | AI_Error_Interrupt_Enable |
- AI_FIFO_Interrupt_Enable, 0);
+ ni_set_bits(dev, NISTC_INTA_ENA_REG, NISTC_INTA_ENA_AI_MASK, 0);
ni_clear_ai_fifo(dev);
if (!devpriv->is_6143)
- ni_writeb(dev, 0, Misc_Command);
-
- ni_stc_writew(dev, AI_Disarm, AI_Command_1_Register); /* reset pulses */
- ni_stc_writew(dev, AI_Start_Stop | AI_Mode_1_Reserved
- /*| AI_Trigger_Once */,
- AI_Mode_1_Register);
- ni_stc_writew(dev, 0x0000, AI_Mode_2_Register);
+ ni_writeb(dev, NI_E_MISC_CMD_EXT_ATRIG, NI_E_MISC_CMD_REG);
+
+ ni_stc_writew(dev, NISTC_AI_CMD1_DISARM, NISTC_AI_CMD1_REG);
+ ni_stc_writew(dev, NISTC_AI_MODE1_START_STOP |
+ NISTC_AI_MODE1_RSVD
+ /*| NISTC_AI_MODE1_TRIGGER_ONCE */,
+ NISTC_AI_MODE1_REG);
+ ni_stc_writew(dev, 0, NISTC_AI_MODE2_REG);
/* generate FIFO interrupts on non-empty */
- ni_stc_writew(dev, (0 << 6) | 0x0000, AI_Mode_3_Register);
+ ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE,
+ NISTC_AI_MODE3_REG);
+
+ ai_personal = NISTC_AI_PERSONAL_SHIFTIN_PW |
+ NISTC_AI_PERSONAL_SOC_POLARITY |
+ NISTC_AI_PERSONAL_LOCALMUX_CLK_PW;
+ ai_out_ctrl = NISTC_AI_OUT_CTRL_SCAN_IN_PROG_SEL(3) |
+ NISTC_AI_OUT_CTRL_EXTMUX_CLK_SEL(0) |
+ NISTC_AI_OUT_CTRL_LOCALMUX_CLK_SEL(2) |
+ NISTC_AI_OUT_CTRL_SC_TC_SEL(3);
if (devpriv->is_611x) {
- ni_stc_writew(dev,
- AI_SHIFTIN_Pulse_Width |
- AI_SOC_Polarity |
- AI_LOCALMUX_CLK_Pulse_Width,
- AI_Personal_Register);
- ni_stc_writew(dev,
- AI_SCAN_IN_PROG_Output_Select(3) |
- AI_EXTMUX_CLK_Output_Select(0) |
- AI_LOCALMUX_CLK_Output_Select(2) |
- AI_SC_TC_Output_Select(3) |
- AI_CONVERT_Output_Select
- (AI_CONVERT_Output_Enable_High),
- AI_Output_Control_Register);
+ ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_HIGH;
} else if (devpriv->is_6143) {
- ni_stc_writew(dev, AI_SHIFTIN_Pulse_Width |
- AI_SOC_Polarity |
- AI_LOCALMUX_CLK_Pulse_Width,
- AI_Personal_Register);
- ni_stc_writew(dev,
- AI_SCAN_IN_PROG_Output_Select(3) |
- AI_EXTMUX_CLK_Output_Select(0) |
- AI_LOCALMUX_CLK_Output_Select(2) |
- AI_SC_TC_Output_Select(3) |
- AI_CONVERT_Output_Select
- (AI_CONVERT_Output_Enable_Low),
- AI_Output_Control_Register);
+ ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_LOW;
} else {
- unsigned ai_output_control_bits;
-
- ni_stc_writew(dev,
- AI_SHIFTIN_Pulse_Width |
- AI_SOC_Polarity |
- AI_CONVERT_Pulse_Width |
- AI_LOCALMUX_CLK_Pulse_Width,
- AI_Personal_Register);
- ai_output_control_bits =
- AI_SCAN_IN_PROG_Output_Select(3) |
- AI_EXTMUX_CLK_Output_Select(0) |
- AI_LOCALMUX_CLK_Output_Select(2) |
- AI_SC_TC_Output_Select(3);
+ ai_personal |= NISTC_AI_PERSONAL_CONVERT_PW;
if (devpriv->is_622x)
- ai_output_control_bits |=
- AI_CONVERT_Output_Select
- (AI_CONVERT_Output_Enable_High);
+ ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_HIGH;
else
- ai_output_control_bits |=
- AI_CONVERT_Output_Select
- (AI_CONVERT_Output_Enable_Low);
- ni_stc_writew(dev, ai_output_control_bits,
- AI_Output_Control_Register);
+ ai_out_ctrl |= NISTC_AI_OUT_CTRL_CONVERT_LOW;
}
+ ni_stc_writew(dev, ai_personal, NISTC_AI_PERSONAL_REG);
+ ni_stc_writew(dev, ai_out_ctrl, NISTC_AI_OUT_CTRL_REG);
+
/* the following registers should not be changed, because there
* are no backup registers in devpriv. If you want to change
* any of these, add a backup register and other appropriate code:
- * AI_Mode_1_Register
- * AI_Mode_3_Register
- * AI_Personal_Register
- * AI_Output_Control_Register
+ * NISTC_AI_MODE1_REG
+ * NISTC_AI_MODE3_REG
+ * NISTC_AI_PERSONAL_REG
+ * NISTC_AI_OUT_CTRL_REG
*/
- ni_stc_writew(dev,
- AI_SC_TC_Error_Confirm |
- AI_START_Interrupt_Ack |
- AI_START2_Interrupt_Ack |
- AI_START1_Interrupt_Ack |
- AI_SC_TC_Interrupt_Ack |
- AI_Error_Interrupt_Ack |
- AI_STOP_Interrupt_Ack,
- Interrupt_A_Ack_Register); /* clear interrupts */
-
- ni_stc_writew(dev, AI_Configuration_End, Joint_Reset_Register);
+
+ /* clear interrupts */
+ ni_stc_writew(dev, NISTC_INTA_ACK_AI_ALL, NISTC_INTA_ACK_REG);
+
+ ni_stc_writew(dev, NISTC_RESET_AI_CFG_END, NISTC_RESET_REG);
return 0;
}
@@ -1839,11 +1697,11 @@ static void ni_prime_channelgain_list(struct comedi_device *dev)
{
int i;
- ni_stc_writew(dev, AI_CONVERT_Pulse, AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE, NISTC_AI_CMD1_REG);
for (i = 0; i < NI_TIMEOUT; ++i) {
- if (!(ni_stc_readw(dev, AI_Status_1_Register) &
- AI_FIFO_Empty_St)) {
- ni_stc_writew(dev, 1, ADC_FIFO_Clear);
+ if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+ NISTC_AI_STATUS1_FIFO_E)) {
+ ni_stc_writew(dev, 1, NISTC_ADC_FIFO_CLR_REG);
return;
}
udelay(1);
@@ -1862,7 +1720,7 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
unsigned int dither;
unsigned range_code;
- ni_stc_writew(dev, 1, Configuration_Memory_Clear);
+ ni_stc_writew(dev, 1, NISTC_CFG_MEM_CLR_REG);
if ((list[0] & CR_ALT_SOURCE)) {
unsigned bypass_bits;
@@ -1871,22 +1729,17 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
range = CR_RANGE(list[0]);
range_code = ni_gainlkup[board->gainlkup][range];
dither = (list[0] & CR_ALT_FILTER) != 0;
- bypass_bits = MSeries_AI_Bypass_Config_FIFO_Bit;
- bypass_bits |= chan;
- bypass_bits |=
- (devpriv->ai_calib_source) &
- (MSeries_AI_Bypass_Cal_Sel_Pos_Mask |
- MSeries_AI_Bypass_Cal_Sel_Neg_Mask |
- MSeries_AI_Bypass_Mode_Mux_Mask |
- MSeries_AO_Bypass_AO_Cal_Sel_Mask);
- bypass_bits |= MSeries_AI_Bypass_Gain_Bits(range_code);
+ bypass_bits = NI_M_CFG_BYPASS_FIFO |
+ NI_M_CFG_BYPASS_AI_CHAN(chan) |
+ NI_M_CFG_BYPASS_AI_GAIN(range_code) |
+ devpriv->ai_calib_source;
if (dither)
- bypass_bits |= MSeries_AI_Bypass_Dither_Bit;
+ bypass_bits |= NI_M_CFG_BYPASS_AI_DITHER;
/* don't use 2's complement encoding */
- bypass_bits |= MSeries_AI_Bypass_Polarity_Bit;
- ni_writel(dev, bypass_bits, M_Offset_AI_Config_FIFO_Bypass);
+ bypass_bits |= NI_M_CFG_BYPASS_AI_POLARITY;
+ ni_writel(dev, bypass_bits, NI_M_CFG_BYPASS_FIFO_REG);
} else {
- ni_writel(dev, 0, M_Offset_AI_Config_FIFO_Bypass);
+ ni_writel(dev, 0, NI_M_CFG_BYPASS_FIFO_REG);
}
for (i = 0; i < n_chan; i++) {
unsigned config_bits = 0;
@@ -1900,31 +1753,27 @@ static void ni_m_series_load_channelgain_list(struct comedi_device *dev,
devpriv->ai_offset[i] = 0;
switch (aref) {
case AREF_DIFF:
- config_bits |=
- MSeries_AI_Config_Channel_Type_Differential_Bits;
+ config_bits |= NI_M_AI_CFG_CHAN_TYPE_DIFF;
break;
case AREF_COMMON:
- config_bits |=
- MSeries_AI_Config_Channel_Type_Common_Ref_Bits;
+ config_bits |= NI_M_AI_CFG_CHAN_TYPE_COMMON;
break;
case AREF_GROUND:
- config_bits |=
- MSeries_AI_Config_Channel_Type_Ground_Ref_Bits;
+ config_bits |= NI_M_AI_CFG_CHAN_TYPE_GROUND;
break;
case AREF_OTHER:
break;
}
- config_bits |= MSeries_AI_Config_Channel_Bits(chan);
- config_bits |=
- MSeries_AI_Config_Bank_Bits(board->reg_type, chan);
- config_bits |= MSeries_AI_Config_Gain_Bits(range_code);
+ config_bits |= NI_M_AI_CFG_CHAN_SEL(chan);
+ config_bits |= NI_M_AI_CFG_BANK_SEL(chan);
+ config_bits |= NI_M_AI_CFG_GAIN(range_code);
if (i == n_chan - 1)
- config_bits |= MSeries_AI_Config_Last_Channel_Bit;
+ config_bits |= NI_M_AI_CFG_LAST_CHAN;
if (dither)
- config_bits |= MSeries_AI_Config_Dither_Bit;
+ config_bits |= NI_M_AI_CFG_DITHER;
/* don't use 2's complement encoding */
- config_bits |= MSeries_AI_Config_Polarity_Bit;
- ni_writew(dev, config_bits, M_Offset_AI_Config_FIFO_Data);
+ config_bits |= NI_M_AI_CFG_POLARITY;
+ ni_writew(dev, config_bits, NI_M_AI_CFG_FIFO_DATA_REG);
}
ni_prime_channelgain_list(dev);
}
@@ -1986,7 +1835,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
devpriv->changain_state = 0;
}
- ni_stc_writew(dev, 1, Configuration_Memory_Clear);
+ ni_stc_writew(dev, 1, NISTC_CFG_MEM_CLR_REG);
/* Set up Calibration mode if required */
if (devpriv->is_6143) {
@@ -1994,20 +1843,20 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
&& !devpriv->ai_calib_source_enabled) {
/* Strobe Relay enable bit */
ni_writew(dev, devpriv->ai_calib_source |
- Calibration_Channel_6143_RelayOn,
- Calibration_Channel_6143);
+ NI6143_CALIB_CHAN_RELAY_ON,
+ NI6143_CALIB_CHAN_REG);
ni_writew(dev, devpriv->ai_calib_source,
- Calibration_Channel_6143);
+ NI6143_CALIB_CHAN_REG);
devpriv->ai_calib_source_enabled = 1;
msleep_interruptible(100); /* Allow relays to change */
} else if (!(list[0] & CR_ALT_SOURCE)
&& devpriv->ai_calib_source_enabled) {
/* Strobe Relay disable bit */
ni_writew(dev, devpriv->ai_calib_source |
- Calibration_Channel_6143_RelayOff,
- Calibration_Channel_6143);
+ NI6143_CALIB_CHAN_RELAY_OFF,
+ NI6143_CALIB_CHAN_REG);
ni_writew(dev, devpriv->ai_calib_source,
- Calibration_Channel_6143);
+ NI6143_CALIB_CHAN_REG);
devpriv->ai_calib_source_enabled = 0;
msleep_interruptible(100); /* Allow relays to change */
}
@@ -2033,7 +1882,7 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
if ((list[i] & CR_ALT_SOURCE)) {
if (devpriv->is_611x)
ni_writew(dev, CR_CHAN(list[i]) & 0x0003,
- Calibration_Channel_Select_611x);
+ NI611X_CALIB_CHAN_SEL_REG);
} else {
if (devpriv->is_611x)
aref = AREF_DIFF;
@@ -2041,30 +1890,31 @@ static void ni_load_channelgain_list(struct comedi_device *dev,
aref = AREF_OTHER;
switch (aref) {
case AREF_DIFF:
- hi |= AI_DIFFERENTIAL;
+ hi |= NI_E_AI_CFG_HI_TYPE_DIFF;
break;
case AREF_COMMON:
- hi |= AI_COMMON;
+ hi |= NI_E_AI_CFG_HI_TYPE_COMMON;
break;
case AREF_GROUND:
- hi |= AI_GROUND;
+ hi |= NI_E_AI_CFG_HI_TYPE_GROUND;
break;
case AREF_OTHER:
break;
}
}
- hi |= AI_CONFIG_CHANNEL(chan);
+ hi |= NI_E_AI_CFG_HI_CHAN(chan);
- ni_writew(dev, hi, Configuration_Memory_High);
+ ni_writew(dev, hi, NI_E_AI_CFG_HI_REG);
if (!devpriv->is_6143) {
- lo = range;
+ lo = NI_E_AI_CFG_LO_GAIN(range);
+
if (i == n_chan - 1)
- lo |= AI_LAST_CHANNEL;
+ lo |= NI_E_AI_CFG_LO_LAST_CHAN;
if (dither)
- lo |= AI_DITHER;
+ lo |= NI_E_AI_CFG_LO_DITHER;
- ni_writew(dev, lo, Configuration_Memory_Low);
+ ni_writew(dev, lo, NI_E_AI_CFG_LO_REG);
}
}
@@ -2092,25 +1942,27 @@ static int ni_ai_insn_read(struct comedi_device *dev,
signbits = devpriv->ai_offset[0];
if (devpriv->is_611x) {
for (n = 0; n < num_adc_stages_611x; n++) {
- ni_stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE,
+ NISTC_AI_CMD1_REG);
udelay(1);
}
for (n = 0; n < insn->n; n++) {
- ni_stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE,
+ NISTC_AI_CMD1_REG);
/* The 611x has screwy 32-bit FIFOs. */
d = 0;
for (i = 0; i < NI_TIMEOUT; i++) {
- if (ni_readb(dev, XXX_Status) & 0x80) {
- d = ni_readl(dev, ADC_FIFO_Data_611x);
+ if (ni_readb(dev, NI_E_STATUS_REG) & 0x80) {
+ d = ni_readl(dev,
+ NI611X_AI_FIFO_DATA_REG);
d >>= 16;
d &= 0xffff;
break;
}
- if (!(ni_stc_readw(dev, AI_Status_1_Register) &
- AI_FIFO_Empty_St)) {
- d = ni_readl(dev, ADC_FIFO_Data_611x);
+ if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+ NISTC_AI_STATUS1_FIFO_E)) {
+ d = ni_readl(dev,
+ NI611X_AI_FIFO_DATA_REG);
d &= 0xffff;
break;
}
@@ -2124,17 +1976,19 @@ static int ni_ai_insn_read(struct comedi_device *dev,
}
} else if (devpriv->is_6143) {
for (n = 0; n < insn->n; n++) {
- ni_stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE,
+ NISTC_AI_CMD1_REG);
/* The 6143 has 32-bit FIFOs. You need to strobe a bit to move a single 16bit stranded sample into the FIFO */
dl = 0;
for (i = 0; i < NI_TIMEOUT; i++) {
- if (ni_readl(dev, AIFIFO_Status_6143) & 0x01) {
+ if (ni_readl(dev, NI6143_AI_FIFO_STATUS_REG) &
+ 0x01) {
/* Get stranded sample into FIFO */
ni_writel(dev, 0x01,
- AIFIFO_Control_6143);
- dl = ni_readl(dev, AIFIFO_Data_6143);
+ NI6143_AI_FIFO_CTRL_REG);
+ dl = ni_readl(dev,
+ NI6143_AI_FIFO_DATA_REG);
break;
}
}
@@ -2146,11 +2000,11 @@ static int ni_ai_insn_read(struct comedi_device *dev,
}
} else {
for (n = 0; n < insn->n; n++) {
- ni_stc_writew(dev, AI_CONVERT_Pulse,
- AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_CONVERT_PULSE,
+ NISTC_AI_CMD1_REG);
for (i = 0; i < NI_TIMEOUT; i++) {
- if (!(ni_stc_readw(dev, AI_Status_1_Register) &
- AI_FIFO_Empty_St))
+ if (!(ni_stc_readw(dev, NISTC_AI_STATUS1_REG) &
+ NISTC_AI_STATUS1_FIFO_E))
break;
}
if (i == NI_TIMEOUT) {
@@ -2158,11 +2012,11 @@ static int ni_ai_insn_read(struct comedi_device *dev,
return -ETIME;
}
if (devpriv->is_m_series) {
- dl = ni_readl(dev, M_Offset_AI_FIFO_Data);
+ dl = ni_readl(dev, NI_M_AI_FIFO_DATA_REG);
dl &= mask;
data[n] = dl;
} else {
- d = ni_readw(dev, ADC_FIFO_Data_Register);
+ d = ni_readw(dev, NI_E_AI_FIFO_DATA_REG);
d += signbits; /* subtle: needs to be short addition */
data[n] = d;
}
@@ -2374,8 +2228,8 @@ static int ni_ai_inttrig(struct comedi_device *dev,
if (trig_num != cmd->start_arg)
return -EINVAL;
- ni_stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2,
- AI_Command_2_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD2_START1_PULSE | devpriv->ai_cmd2,
+ NISTC_AI_CMD2_REG);
s->async->inttrig = NULL;
return 1;
@@ -2391,6 +2245,7 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
int start_stop_select = 0;
unsigned int stop_count;
int interrupt_a_enable = 0;
+ unsigned ai_trig;
if (dev->irq == 0) {
dev_err(dev->class_dev, "cannot run command without an irq\n");
@@ -2401,51 +2256,47 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
ni_load_channelgain_list(dev, s, cmd->chanlist_len, cmd->chanlist);
/* start configuration */
- ni_stc_writew(dev, AI_Configuration_Start, Joint_Reset_Register);
+ ni_stc_writew(dev, NISTC_RESET_AI_CFG_START, NISTC_RESET_REG);
/* disable analog triggering for now, since it
* interferes with the use of pfi0 */
- devpriv->an_trig_etc_reg &= ~Analog_Trigger_Enable;
- ni_stc_writew(dev, devpriv->an_trig_etc_reg,
- Analog_Trigger_Etc_Register);
+ devpriv->an_trig_etc_reg &= ~NISTC_ATRIG_ETC_ENA;
+ ni_stc_writew(dev, devpriv->an_trig_etc_reg, NISTC_ATRIG_ETC_REG);
+ ai_trig = NISTC_AI_TRIG_START2_SEL(0) | NISTC_AI_TRIG_START1_SYNC;
switch (cmd->start_src) {
case TRIG_INT:
case TRIG_NOW:
- ni_stc_writew(dev,
- AI_START2_Select(0) |
- AI_START1_Sync | AI_START1_Edge |
- AI_START1_Select(0),
- AI_Trigger_Select_Register);
+ ai_trig |= NISTC_AI_TRIG_START1_EDGE |
+ NISTC_AI_TRIG_START1_SEL(0);
break;
case TRIG_EXT:
- {
- int chan = CR_CHAN(cmd->start_arg);
- unsigned int bits = AI_START2_Select(0) |
- AI_START1_Sync | AI_START1_Select(chan + 1);
-
- if (cmd->start_arg & CR_INVERT)
- bits |= AI_START1_Polarity;
- if (cmd->start_arg & CR_EDGE)
- bits |= AI_START1_Edge;
- ni_stc_writew(dev, bits, AI_Trigger_Select_Register);
- break;
- }
+ ai_trig |= NISTC_AI_TRIG_START1_SEL(CR_CHAN(cmd->start_arg) +
+ 1);
+
+ if (cmd->start_arg & CR_INVERT)
+ ai_trig |= NISTC_AI_TRIG_START1_POLARITY;
+ if (cmd->start_arg & CR_EDGE)
+ ai_trig |= NISTC_AI_TRIG_START1_EDGE;
+ break;
}
+ ni_stc_writew(dev, ai_trig, NISTC_AI_TRIG_SEL_REG);
- mode2 &= ~AI_Pre_Trigger;
- mode2 &= ~AI_SC_Initial_Load_Source;
- mode2 &= ~AI_SC_Reload_Mode;
- ni_stc_writew(dev, mode2, AI_Mode_2_Register);
+ mode2 &= ~NISTC_AI_MODE2_PRE_TRIGGER;
+ mode2 &= ~NISTC_AI_MODE2_SC_INIT_LOAD_SRC;
+ mode2 &= ~NISTC_AI_MODE2_SC_RELOAD_MODE;
+ ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG);
if (cmd->chanlist_len == 1 || devpriv->is_611x || devpriv->is_6143) {
- start_stop_select |= AI_STOP_Polarity;
- start_stop_select |= AI_STOP_Select(31); /* logic low */
- start_stop_select |= AI_STOP_Sync;
+ /* logic low */
+ start_stop_select |= NISTC_AI_STOP_POLARITY |
+ NISTC_AI_STOP_SEL(31) |
+ NISTC_AI_STOP_SYNC;
} else {
- start_stop_select |= AI_STOP_Select(19); /* ai configuration memory */
+ /* ai configuration memory */
+ start_stop_select |= NISTC_AI_STOP_SEL(19);
}
- ni_stc_writew(dev, start_stop_select, AI_START_STOP_Select_Register);
+ ni_stc_writew(dev, start_stop_select, NISTC_AI_START_STOP_REG);
devpriv->ai_cmd2 = 0;
switch (cmd->stop_src) {
@@ -2457,80 +2308,80 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
stop_count += num_adc_stages_611x;
}
/* stage number of scans */
- ni_stc_writel(dev, stop_count, AI_SC_Load_A_Registers);
+ ni_stc_writel(dev, stop_count, NISTC_AI_SC_LOADA_REG);
- mode1 |= AI_Start_Stop | AI_Mode_1_Reserved | AI_Trigger_Once;
- ni_stc_writew(dev, mode1, AI_Mode_1_Register);
+ mode1 |= NISTC_AI_MODE1_START_STOP |
+ NISTC_AI_MODE1_RSVD |
+ NISTC_AI_MODE1_TRIGGER_ONCE;
+ ni_stc_writew(dev, mode1, NISTC_AI_MODE1_REG);
/* load SC (Scan Count) */
- ni_stc_writew(dev, AI_SC_Load, AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_SC_LOAD, NISTC_AI_CMD1_REG);
if (stop_count == 0) {
- devpriv->ai_cmd2 |= AI_End_On_End_Of_Scan;
- interrupt_a_enable |= AI_STOP_Interrupt_Enable;
+ devpriv->ai_cmd2 |= NISTC_AI_CMD2_END_ON_EOS;
+ interrupt_a_enable |= NISTC_INTA_ENA_AI_STOP;
/* this is required to get the last sample for chanlist_len > 1, not sure why */
if (cmd->chanlist_len > 1)
- start_stop_select |=
- AI_STOP_Polarity | AI_STOP_Edge;
+ start_stop_select |= NISTC_AI_STOP_POLARITY |
+ NISTC_AI_STOP_EDGE;
}
break;
case TRIG_NONE:
/* stage number of scans */
- ni_stc_writel(dev, 0, AI_SC_Load_A_Registers);
+ ni_stc_writel(dev, 0, NISTC_AI_SC_LOADA_REG);
- mode1 |= AI_Start_Stop | AI_Mode_1_Reserved | AI_Continuous;
- ni_stc_writew(dev, mode1, AI_Mode_1_Register);
+ mode1 |= NISTC_AI_MODE1_START_STOP |
+ NISTC_AI_MODE1_RSVD |
+ NISTC_AI_MODE1_CONTINUOUS;
+ ni_stc_writew(dev, mode1, NISTC_AI_MODE1_REG);
/* load SC (Scan Count) */
- ni_stc_writew(dev, AI_SC_Load, AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_SC_LOAD, NISTC_AI_CMD1_REG);
break;
}
switch (cmd->scan_begin_src) {
case TRIG_TIMER:
/*
- stop bits for non 611x boards
- AI_SI_Special_Trigger_Delay=0
- AI_Pre_Trigger=0
- AI_START_STOP_Select_Register:
- AI_START_Polarity=0 (?) rising edge
- AI_START_Edge=1 edge triggered
- AI_START_Sync=1 (?)
- AI_START_Select=0 SI_TC
- AI_STOP_Polarity=0 rising edge
- AI_STOP_Edge=0 level
- AI_STOP_Sync=1
- AI_STOP_Select=19 external pin (configuration mem)
+ * stop bits for non 611x boards
+ * NISTC_AI_MODE3_SI_TRIG_DELAY=0
+ * NISTC_AI_MODE2_PRE_TRIGGER=0
+ * NISTC_AI_START_STOP_REG:
+ * NISTC_AI_START_POLARITY=0 (?) rising edge
+ * NISTC_AI_START_EDGE=1 edge triggered
+ * NISTC_AI_START_SYNC=1 (?)
+ * NISTC_AI_START_SEL=0 SI_TC
+ * NISTC_AI_STOP_POLARITY=0 rising edge
+ * NISTC_AI_STOP_EDGE=0 level
+ * NISTC_AI_STOP_SYNC=1
+ * NISTC_AI_STOP_SEL=19 external pin (configuration mem)
*/
- start_stop_select |= AI_START_Edge | AI_START_Sync;
- ni_stc_writew(dev, start_stop_select,
- AI_START_STOP_Select_Register);
+ start_stop_select |= NISTC_AI_START_EDGE | NISTC_AI_START_SYNC;
+ ni_stc_writew(dev, start_stop_select, NISTC_AI_START_STOP_REG);
- mode2 |= AI_SI_Reload_Mode(0);
- /* AI_SI_Initial_Load_Source=A */
- mode2 &= ~AI_SI_Initial_Load_Source;
- /* mode2 |= AI_SC_Reload_Mode; */
- ni_stc_writew(dev, mode2, AI_Mode_2_Register);
+ mode2 &= ~NISTC_AI_MODE2_SI_INIT_LOAD_SRC; /* A */
+ mode2 |= NISTC_AI_MODE2_SI_RELOAD_MODE(0);
+ /* mode2 |= NISTC_AI_MODE2_SC_RELOAD_MODE; */
+ ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG);
/* load SI */
timer = ni_ns_to_timer(dev, cmd->scan_begin_arg,
CMDF_ROUND_NEAREST);
- ni_stc_writel(dev, timer, AI_SI_Load_A_Registers);
- ni_stc_writew(dev, AI_SI_Load, AI_Command_1_Register);
+ ni_stc_writel(dev, timer, NISTC_AI_SI_LOADA_REG);
+ ni_stc_writew(dev, NISTC_AI_CMD1_SI_LOAD, NISTC_AI_CMD1_REG);
break;
case TRIG_EXT:
if (cmd->scan_begin_arg & CR_EDGE)
- start_stop_select |= AI_START_Edge;
- /* AI_START_Polarity==1 is falling edge */
- if (cmd->scan_begin_arg & CR_INVERT)
- start_stop_select |= AI_START_Polarity;
+ start_stop_select |= NISTC_AI_START_EDGE;
+ if (cmd->scan_begin_arg & CR_INVERT) /* falling edge */
+ start_stop_select |= NISTC_AI_START_POLARITY;
if (cmd->scan_begin_src != cmd->convert_src ||
(cmd->scan_begin_arg & ~CR_EDGE) !=
(cmd->convert_arg & ~CR_EDGE))
- start_stop_select |= AI_START_Sync;
+ start_stop_select |= NISTC_AI_START_SYNC;
start_stop_select |=
- AI_START_Select(1 + CR_CHAN(cmd->scan_begin_arg));
- ni_stc_writew(dev, start_stop_select,
- AI_START_STOP_Select_Register);
+ NISTC_AI_START_SEL(1 + CR_CHAN(cmd->scan_begin_arg));
+ ni_stc_writew(dev, start_stop_select, NISTC_AI_START_STOP_REG);
break;
}
@@ -2543,46 +2394,43 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
timer = ni_ns_to_timer(dev, cmd->convert_arg,
CMDF_ROUND_NEAREST);
/* 0,0 does not work */
- ni_stc_writew(dev, 1, AI_SI2_Load_A_Register);
- ni_stc_writew(dev, timer, AI_SI2_Load_B_Register);
+ ni_stc_writew(dev, 1, NISTC_AI_SI2_LOADA_REG);
+ ni_stc_writew(dev, timer, NISTC_AI_SI2_LOADB_REG);
- /* AI_SI2_Reload_Mode = alternate */
- /* AI_SI2_Initial_Load_Source = A */
- mode2 &= ~AI_SI2_Initial_Load_Source;
- mode2 |= AI_SI2_Reload_Mode;
- ni_stc_writew(dev, mode2, AI_Mode_2_Register);
+ mode2 &= ~NISTC_AI_MODE2_SI2_INIT_LOAD_SRC; /* A */
+ mode2 |= NISTC_AI_MODE2_SI2_RELOAD_MODE; /* alternate */
+ ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG);
- /* AI_SI2_Load */
- ni_stc_writew(dev, AI_SI2_Load, AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_SI2_LOAD, NISTC_AI_CMD1_REG);
- mode2 |= AI_SI2_Reload_Mode; /* alternate */
- mode2 |= AI_SI2_Initial_Load_Source; /* B */
-
- ni_stc_writew(dev, mode2, AI_Mode_2_Register);
+ mode2 |= NISTC_AI_MODE2_SI2_INIT_LOAD_SRC; /* B */
+ mode2 |= NISTC_AI_MODE2_SI2_RELOAD_MODE; /* alternate */
+ ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG);
break;
case TRIG_EXT:
- mode1 |= AI_CONVERT_Source_Select(1 + cmd->convert_arg);
+ mode1 |= NISTC_AI_MODE1_CONVERT_SRC(1 + cmd->convert_arg);
if ((cmd->convert_arg & CR_INVERT) == 0)
- mode1 |= AI_CONVERT_Source_Polarity;
- ni_stc_writew(dev, mode1, AI_Mode_1_Register);
+ mode1 |= NISTC_AI_MODE1_CONVERT_POLARITY;
+ ni_stc_writew(dev, mode1, NISTC_AI_MODE1_REG);
- mode2 |= AI_Start_Stop_Gate_Enable | AI_SC_Gate_Enable;
- ni_stc_writew(dev, mode2, AI_Mode_2_Register);
+ mode2 |= NISTC_AI_MODE2_SC_GATE_ENA |
+ NISTC_AI_MODE2_START_STOP_GATE_ENA;
+ ni_stc_writew(dev, mode2, NISTC_AI_MODE2_REG);
break;
}
if (dev->irq) {
/* interrupt on FIFO, errors, SC_TC */
- interrupt_a_enable |= AI_Error_Interrupt_Enable |
- AI_SC_TC_Interrupt_Enable;
+ interrupt_a_enable |= NISTC_INTA_ENA_AI_ERR |
+ NISTC_INTA_ENA_AI_SC_TC;
#ifndef PCIDMA
- interrupt_a_enable |= AI_FIFO_Interrupt_Enable;
+ interrupt_a_enable |= NISTC_INTA_ENA_AI_FIFO;
#endif
- if (cmd->flags & CMDF_WAKE_EOS
- || (devpriv->ai_cmd2 & AI_End_On_End_Of_Scan)) {
+ if ((cmd->flags & CMDF_WAKE_EOS) ||
+ (devpriv->ai_cmd2 & NISTC_AI_CMD2_END_ON_EOS)) {
/* wake on end-of-scan */
devpriv->aimode = AIMODE_SCAN;
} else {
@@ -2593,66 +2441,60 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
case AIMODE_HALF_FULL:
/*generate FIFO interrupts and DMA requests on half-full */
#ifdef PCIDMA
- ni_stc_writew(dev, AI_FIFO_Mode_HF_to_E,
- AI_Mode_3_Register);
+ ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF_E,
+ NISTC_AI_MODE3_REG);
#else
- ni_stc_writew(dev, AI_FIFO_Mode_HF,
- AI_Mode_3_Register);
+ ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF,
+ NISTC_AI_MODE3_REG);
#endif
break;
case AIMODE_SAMPLE:
/*generate FIFO interrupts on non-empty */
- ni_stc_writew(dev, AI_FIFO_Mode_NE,
- AI_Mode_3_Register);
+ ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE,
+ NISTC_AI_MODE3_REG);
break;
case AIMODE_SCAN:
#ifdef PCIDMA
- ni_stc_writew(dev, AI_FIFO_Mode_NE,
- AI_Mode_3_Register);
+ ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_NE,
+ NISTC_AI_MODE3_REG);
#else
- ni_stc_writew(dev, AI_FIFO_Mode_HF,
- AI_Mode_3_Register);
+ ni_stc_writew(dev, NISTC_AI_MODE3_FIFO_MODE_HF,
+ NISTC_AI_MODE3_REG);
#endif
- interrupt_a_enable |= AI_STOP_Interrupt_Enable;
+ interrupt_a_enable |= NISTC_INTA_ENA_AI_STOP;
break;
default:
break;
}
/* clear interrupts */
- ni_stc_writew(dev,
- AI_Error_Interrupt_Ack |
- AI_STOP_Interrupt_Ack |
- AI_START_Interrupt_Ack |
- AI_START2_Interrupt_Ack |
- AI_START1_Interrupt_Ack |
- AI_SC_TC_Interrupt_Ack |
- AI_SC_TC_Error_Confirm,
- Interrupt_A_Ack_Register);
-
- ni_set_bits(dev, Interrupt_A_Enable_Register,
- interrupt_a_enable, 1);
+ ni_stc_writew(dev, NISTC_INTA_ACK_AI_ALL, NISTC_INTA_ACK_REG);
+
+ ni_set_bits(dev, NISTC_INTA_ENA_REG, interrupt_a_enable, 1);
} else {
/* interrupt on nothing */
- ni_set_bits(dev, Interrupt_A_Enable_Register, ~0, 0);
+ ni_set_bits(dev, NISTC_INTA_ENA_REG, ~0, 0);
/* XXX start polling if necessary */
}
/* end configuration */
- ni_stc_writew(dev, AI_Configuration_End, Joint_Reset_Register);
+ ni_stc_writew(dev, NISTC_RESET_AI_CFG_END, NISTC_RESET_REG);
switch (cmd->scan_begin_src) {
case TRIG_TIMER:
- ni_stc_writew(dev,
- AI_SI2_Arm | AI_SI_Arm | AI_DIV_Arm | AI_SC_Arm,
- AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_SI2_ARM |
+ NISTC_AI_CMD1_SI_ARM |
+ NISTC_AI_CMD1_DIV_ARM |
+ NISTC_AI_CMD1_SC_ARM,
+ NISTC_AI_CMD1_REG);
break;
case TRIG_EXT:
- /* XXX AI_SI_Arm? */
- ni_stc_writew(dev,
- AI_SI2_Arm | AI_SI_Arm | AI_DIV_Arm | AI_SC_Arm,
- AI_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD1_SI2_ARM |
+ NISTC_AI_CMD1_SI_ARM | /* XXX ? */
+ NISTC_AI_CMD1_DIV_ARM |
+ NISTC_AI_CMD1_SC_ARM,
+ NISTC_AI_CMD1_REG);
break;
}
@@ -2666,9 +2508,9 @@ static int ni_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
#endif
if (cmd->start_src == TRIG_NOW) {
- /* AI_START1_Pulse */
- ni_stc_writew(dev, AI_START1_Pulse | devpriv->ai_cmd2,
- AI_Command_2_Register);
+ ni_stc_writew(dev, NISTC_AI_CMD2_START1_PULSE |
+ devpriv->ai_cmd2,
+ NISTC_AI_CMD2_REG);
s->async->inttrig = NULL;
} else if (cmd->start_src == TRIG_EXT) {
s->async->inttrig = NULL;
@@ -2691,12 +2533,8 @@ static int ni_ai_insn_config(struct comedi_device *dev,
switch (data[0]) {
case INSN_CONFIG_ALT_SOURCE:
if (devpriv->is_m_series) {
- if (data[1] & ~(MSeries_AI_Bypass_Cal_Sel_Pos_Mask |
- MSeries_AI_Bypass_Cal_Sel_Neg_Mask |
- MSeries_AI_Bypass_Mode_Mux_Mask |
- MSeries_AO_Bypass_AO_Cal_Sel_Mask)) {
+ if (data[1] & ~NI_M_CFG_BYPASS_AI_CAL_MASK)
return -EINVAL;
- }
devpriv->ai_calib_source = data[1];
} else if (devpriv->is_6143) {
unsigned int calib_source;
@@ -2704,7 +2542,7 @@ static int ni_ai_insn_config(struct comedi_device *dev,
calib_source = data[1] & 0xf;
devpriv->ai_calib_source = calib_source;
- ni_writew(dev, calib_source, Calibration_Channel_6143);
+ ni_writew(dev, calib_source, NI6143_CALIB_CHAN_REG);
} else {
unsigned int calib_source;
unsigned int calib_source_adjust;
@@ -2717,7 +2555,7 @@ static int ni_ai_insn_config(struct comedi_device *dev,
devpriv->ai_calib_source = calib_source;
if (devpriv->is_611x) {
ni_writeb(dev, calib_source_adjust,
- Cal_Gain_Select_611x);
+ NI611X_CAL_GAIN_SEL_REG);
}
}
return 2;
@@ -2771,10 +2609,10 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
if (timed) {
for (i = 0; i < s->n_chan; ++i) {
- devpriv->ao_conf[i] &= ~MSeries_AO_Update_Timed_Bit;
+ devpriv->ao_conf[i] &= ~NI_M_AO_CFG_BANK_UPDATE_TIMED;
ni_writeb(dev, devpriv->ao_conf[i],
- M_Offset_AO_Config_Bank(i));
- ni_writeb(dev, 0xf, M_Offset_AO_Waveform_Order(i));
+ NI_M_AO_CFG_BANK_REG(i));
+ ni_writeb(dev, 0xf, NI_M_AO_WAVEFORM_ORDER_REG(i));
}
}
for (i = 0; i < n_chans; i++) {
@@ -2787,24 +2625,22 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
conf = 0;
switch (krange->max - krange->min) {
case 20000000:
- conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits;
- ni_writeb(dev, 0,
- M_Offset_AO_Reference_Attenuation(chan));
+ conf |= NI_M_AO_CFG_BANK_REF_INT_10V;
+ ni_writeb(dev, 0, NI_M_AO_REF_ATTENUATION_REG(chan));
break;
case 10000000:
- conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits;
- ni_writeb(dev, 0,
- M_Offset_AO_Reference_Attenuation(chan));
+ conf |= NI_M_AO_CFG_BANK_REF_INT_5V;
+ ni_writeb(dev, 0, NI_M_AO_REF_ATTENUATION_REG(chan));
break;
case 4000000:
- conf |= MSeries_AO_DAC_Reference_10V_Internal_Bits;
- ni_writeb(dev, MSeries_Attenuate_x5_Bit,
- M_Offset_AO_Reference_Attenuation(chan));
+ conf |= NI_M_AO_CFG_BANK_REF_INT_10V;
+ ni_writeb(dev, NI_M_AO_REF_ATTENUATION_X5,
+ NI_M_AO_REF_ATTENUATION_REG(chan));
break;
case 2000000:
- conf |= MSeries_AO_DAC_Reference_5V_Internal_Bits;
- ni_writeb(dev, MSeries_Attenuate_x5_Bit,
- M_Offset_AO_Reference_Attenuation(chan));
+ conf |= NI_M_AO_CFG_BANK_REF_INT_5V;
+ ni_writeb(dev, NI_M_AO_REF_ATTENUATION_X5,
+ NI_M_AO_REF_ATTENUATION_REG(chan));
break;
default:
dev_err(dev->class_dev,
@@ -2813,10 +2649,10 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
}
switch (krange->max + krange->min) {
case 0:
- conf |= MSeries_AO_DAC_Offset_0V_Bits;
+ conf |= NI_M_AO_CFG_BANK_OFFSET_0V;
break;
case 10000000:
- conf |= MSeries_AO_DAC_Offset_5V_Bits;
+ conf |= NI_M_AO_CFG_BANK_OFFSET_5V;
break;
default:
dev_err(dev->class_dev,
@@ -2824,10 +2660,10 @@ static int ni_m_series_ao_config_chanlist(struct comedi_device *dev,
break;
}
if (timed)
- conf |= MSeries_AO_Update_Timed_Bit;
- ni_writeb(dev, conf, M_Offset_AO_Config_Bank(chan));
+ conf |= NI_M_AO_CFG_BANK_UPDATE_TIMED;
+ ni_writeb(dev, conf, NI_M_AO_CFG_BANK_REG(chan));
devpriv->ao_conf[chan] = conf;
- ni_writeb(dev, i, M_Offset_AO_Waveform_Order(chan));
+ ni_writeb(dev, i, NI_M_AO_WAVEFORM_ORDER_REG(chan));
}
return invert;
}
@@ -2847,27 +2683,27 @@ static int ni_old_ao_config_chanlist(struct comedi_device *dev,
for (i = 0; i < n_chans; i++) {
chan = CR_CHAN(chanspec[i]);
range = CR_RANGE(chanspec[i]);
- conf = AO_Channel(chan);
+ conf = NI_E_AO_DACSEL(chan);
if (comedi_range_is_bipolar(s, range)) {
- conf |= AO_Bipolar;
+ conf |= NI_E_AO_CFG_BIP;
invert = (s->maxdata + 1) >> 1;
} else {
invert = 0;
}
if (comedi_range_is_external(s, range))
- conf |= AO_Ext_Ref;
+ conf |= NI_E_AO_EXT_REF;
/* not all boards can deglitch, but this shouldn't hurt */
if (chanspec[i] & CR_DEGLITCH)
- conf |= AO_Deglitch;
+ conf |= NI_E_AO_DEGLITCH;
/* analog reference */
/* AREF_OTHER connects AO ground to AI ground, i think */
- conf |= (CR_AREF(chanspec[i]) ==
- AREF_OTHER) ? AO_Ground_Ref : 0;
+ if (CR_AREF(chanspec[i]) == AREF_OTHER)
+ conf |= NI_E_AO_GROUND_REF;
- ni_writew(dev, conf, AO_Configuration);
+ ni_writew(dev, conf, NI_E_AO_CFG_REG);
devpriv->ao_conf[chan] = conf;
}
return invert;
@@ -2899,13 +2735,13 @@ static int ni_ao_insn_write(struct comedi_device *dev,
int i;
if (devpriv->is_6xxx) {
- ni_ao_win_outw(dev, 1 << chan, AO_Immediate_671x);
+ ni_ao_win_outw(dev, 1 << chan, NI671X_AO_IMMEDIATE_REG);
- reg = DACx_Direct_Data_671x(chan);
+ reg = NI671X_DAC_DIRECT_DATA_REG(chan);
} else if (devpriv->is_m_series) {
- reg = M_Offset_DAC_Direct_Data(chan);
+ reg = NI_M_DAC_DIRECT_DATA_REG(chan);
} else {
- reg = (chan) ? DAC1_Direct_Data : DAC0_Direct_Data;
+ reg = NI_E_DAC_DIRECT_DATA_REG(chan);
}
ni_ao_config_chanlist(dev, s, &insn->chanspec, 1, 0);
@@ -2995,13 +2831,13 @@ static int ni_ao_inttrig(struct comedi_device *dev,
multiple times) */
s->async->inttrig = NULL;
- ni_set_bits(dev, Interrupt_B_Enable_Register,
- AO_FIFO_Interrupt_Enable | AO_Error_Interrupt_Enable, 0);
- interrupt_b_bits = AO_Error_Interrupt_Enable;
+ ni_set_bits(dev, NISTC_INTB_ENA_REG,
+ NISTC_INTB_ENA_AO_FIFO | NISTC_INTB_ENA_AO_ERR, 0);
+ interrupt_b_bits = NISTC_INTB_ENA_AO_ERR;
#ifdef PCIDMA
- ni_stc_writew(dev, 1, DAC_FIFO_Clear);
+ ni_stc_writew(dev, 1, NISTC_DAC_FIFO_CLR_REG);
if (devpriv->is_6xxx)
- ni_ao_win_outl(dev, 0x6, AO_FIFO_Offset_Load_611x);
+ ni_ao_win_outl(dev, 0x6, NI611X_AO_FIFO_OFFSET_LOAD_REG);
ret = ni_ao_setup_MITE_dma(dev);
if (ret)
return ret;
@@ -3013,17 +2849,17 @@ static int ni_ao_inttrig(struct comedi_device *dev,
if (ret == 0)
return -EPIPE;
- interrupt_b_bits |= AO_FIFO_Interrupt_Enable;
+ interrupt_b_bits |= NISTC_INTB_ENA_AO_FIFO;
#endif
- ni_stc_writew(dev, devpriv->ao_mode3 | AO_Not_An_UPDATE,
- AO_Mode_3_Register);
- ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register);
+ ni_stc_writew(dev, devpriv->ao_mode3 | NISTC_AO_MODE3_NOT_AN_UPDATE,
+ NISTC_AO_MODE3_REG);
+ ni_stc_writew(dev, devpriv->ao_mode3, NISTC_AO_MODE3_REG);
/* wait for DACs to be loaded */
for (i = 0; i < timeout; i++) {
udelay(1);
- if ((ni_stc_readw(dev, Joint_Status_2_Register) &
- AO_TMRDACWRs_In_Progress_St) == 0)
+ if ((ni_stc_readw(dev, NISTC_STATUS2_REG) &
+ NISTC_STATUS2_AO_TMRDACWRS_IN_PROGRESS) == 0)
break;
}
if (i == timeout) {
@@ -3035,17 +2871,20 @@ static int ni_ao_inttrig(struct comedi_device *dev,
* stc manual says we are need to clear error interrupt after
* AO_TMRDACWRs_In_Progress_St clears
*/
- ni_stc_writew(dev, AO_Error_Interrupt_Ack, Interrupt_B_Ack_Register);
+ ni_stc_writew(dev, NISTC_INTB_ACK_AO_ERR, NISTC_INTB_ACK_REG);
- ni_set_bits(dev, Interrupt_B_Enable_Register, interrupt_b_bits, 1);
+ ni_set_bits(dev, NISTC_INTB_ENA_REG, interrupt_b_bits, 1);
- ni_stc_writew(dev, devpriv->ao_cmd1 |
- AO_UI_Arm | AO_UC_Arm | AO_BC_Arm |
- AO_DAC1_Update_Mode | AO_DAC0_Update_Mode,
- AO_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AO_CMD1_UI_ARM |
+ NISTC_AO_CMD1_UC_ARM |
+ NISTC_AO_CMD1_BC_ARM |
+ NISTC_AO_CMD1_DAC1_UPDATE_MODE |
+ NISTC_AO_CMD1_DAC0_UPDATE_MODE |
+ devpriv->ao_cmd1,
+ NISTC_AO_CMD1_REG);
- ni_stc_writew(dev, devpriv->ao_cmd2 | AO_START1_Pulse,
- AO_Command_2_Register);
+ ni_stc_writew(dev, NISTC_AO_CMD2_START1_PULSE | devpriv->ao_cmd2,
+ NISTC_AO_CMD2_REG);
return 0;
}
@@ -3058,18 +2897,20 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
int bits;
int i;
unsigned trigvar;
+ unsigned val;
if (dev->irq == 0) {
dev_err(dev->class_dev, "cannot run command without an irq\n");
return -EIO;
}
- ni_stc_writew(dev, AO_Configuration_Start, Joint_Reset_Register);
+ ni_stc_writew(dev, NISTC_RESET_AO_CFG_START, NISTC_RESET_REG);
- ni_stc_writew(dev, AO_Disarm, AO_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG);
if (devpriv->is_6xxx) {
- ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x);
+ ni_ao_win_outw(dev, NI611X_AO_MISC_CLEAR_WG,
+ NI611X_AO_MISC_REG);
bits = 0;
for (i = 0; i < cmd->chanlist_len; i++) {
@@ -3077,172 +2918,186 @@ static int ni_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
chan = CR_CHAN(cmd->chanlist[i]);
bits |= 1 << chan;
- ni_ao_win_outw(dev, chan, AO_Waveform_Generation_611x);
+ ni_ao_win_outw(dev, chan, NI611X_AO_WAVEFORM_GEN_REG);
}
- ni_ao_win_outw(dev, bits, AO_Timed_611x);
+ ni_ao_win_outw(dev, bits, NI611X_AO_TIMED_REG);
}
ni_ao_config_chanlist(dev, s, cmd->chanlist, cmd->chanlist_len, 1);
if (cmd->stop_src == TRIG_NONE) {
- devpriv->ao_mode1 |= AO_Continuous;
- devpriv->ao_mode1 &= ~AO_Trigger_Once;
+ devpriv->ao_mode1 |= NISTC_AO_MODE1_CONTINUOUS;
+ devpriv->ao_mode1 &= ~NISTC_AO_MODE1_TRIGGER_ONCE;
} else {
- devpriv->ao_mode1 &= ~AO_Continuous;
- devpriv->ao_mode1 |= AO_Trigger_Once;
+ devpriv->ao_mode1 &= ~NISTC_AO_MODE1_CONTINUOUS;
+ devpriv->ao_mode1 |= NISTC_AO_MODE1_TRIGGER_ONCE;
}
- ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register);
+ ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG);
+
+ val = devpriv->ao_trigger_select;
switch (cmd->start_src) {
case TRIG_INT:
case TRIG_NOW:
- devpriv->ao_trigger_select &=
- ~(AO_START1_Polarity | AO_START1_Select(-1));
- devpriv->ao_trigger_select |= AO_START1_Edge | AO_START1_Sync;
- ni_stc_writew(dev, devpriv->ao_trigger_select,
- AO_Trigger_Select_Register);
+ val &= ~(NISTC_AO_TRIG_START1_POLARITY |
+ NISTC_AO_TRIG_START1_SEL_MASK);
+ val |= NISTC_AO_TRIG_START1_EDGE |
+ NISTC_AO_TRIG_START1_SYNC;
break;
case TRIG_EXT:
- devpriv->ao_trigger_select =
- AO_START1_Select(CR_CHAN(cmd->start_arg) + 1);
- if (cmd->start_arg & CR_INVERT)
- devpriv->ao_trigger_select |= AO_START1_Polarity; /* 0=active high, 1=active low. see daq-stc 3-24 (p186) */
- if (cmd->start_arg & CR_EDGE)
- devpriv->ao_trigger_select |= AO_START1_Edge; /* 0=edge detection disabled, 1=enabled */
+ val = NISTC_AO_TRIG_START1_SEL(CR_CHAN(cmd->start_arg) + 1);
+ if (cmd->start_arg & CR_INVERT) {
+ /* 0=active high, 1=active low. see daq-stc 3-24 (p186) */
+ val |= NISTC_AO_TRIG_START1_POLARITY;
+ }
+ if (cmd->start_arg & CR_EDGE) {
+ /* 0=edge detection disabled, 1=enabled */
+ val |= NISTC_AO_TRIG_START1_EDGE;
+ }
ni_stc_writew(dev, devpriv->ao_trigger_select,
- AO_Trigger_Select_Register);
+ NISTC_AO_TRIG_SEL_REG);
break;
default:
BUG();
break;
}
- devpriv->ao_mode3 &= ~AO_Trigger_Length;
- ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register);
+ devpriv->ao_trigger_select = val;
+ ni_stc_writew(dev, devpriv->ao_trigger_select, NISTC_AO_TRIG_SEL_REG);
+
+ devpriv->ao_mode3 &= ~NISTC_AO_MODE3_TRIG_LEN;
+ ni_stc_writew(dev, devpriv->ao_mode3, NISTC_AO_MODE3_REG);
- ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register);
- devpriv->ao_mode2 &= ~AO_BC_Initial_Load_Source;
- ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
+ ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG);
+ devpriv->ao_mode2 &= ~NISTC_AO_MODE2_BC_INIT_LOAD_SRC;
+ ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG);
if (cmd->stop_src == TRIG_NONE)
- ni_stc_writel(dev, 0xffffff, AO_BC_Load_A_Register);
+ ni_stc_writel(dev, 0xffffff, NISTC_AO_BC_LOADA_REG);
else
- ni_stc_writel(dev, 0, AO_BC_Load_A_Register);
- ni_stc_writew(dev, AO_BC_Load, AO_Command_1_Register);
- devpriv->ao_mode2 &= ~AO_UC_Initial_Load_Source;
- ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
+ ni_stc_writel(dev, 0, NISTC_AO_BC_LOADA_REG);
+ ni_stc_writew(dev, NISTC_AO_CMD1_BC_LOAD, NISTC_AO_CMD1_REG);
+ devpriv->ao_mode2 &= ~NISTC_AO_MODE2_UC_INIT_LOAD_SRC;
+ ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG);
switch (cmd->stop_src) {
case TRIG_COUNT:
if (devpriv->is_m_series) {
/* this is how the NI example code does it for m-series boards, verified correct with 6259 */
ni_stc_writel(dev, cmd->stop_arg - 1,
- AO_UC_Load_A_Register);
- ni_stc_writew(dev, AO_UC_Load, AO_Command_1_Register);
+ NISTC_AO_UC_LOADA_REG);
+ ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD,
+ NISTC_AO_CMD1_REG);
} else {
ni_stc_writel(dev, cmd->stop_arg,
- AO_UC_Load_A_Register);
- ni_stc_writew(dev, AO_UC_Load, AO_Command_1_Register);
+ NISTC_AO_UC_LOADA_REG);
+ ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD,
+ NISTC_AO_CMD1_REG);
ni_stc_writel(dev, cmd->stop_arg - 1,
- AO_UC_Load_A_Register);
+ NISTC_AO_UC_LOADA_REG);
}
break;
case TRIG_NONE:
- ni_stc_writel(dev, 0xffffff, AO_UC_Load_A_Register);
- ni_stc_writew(dev, AO_UC_Load, AO_Command_1_Register);
- ni_stc_writel(dev, 0xffffff, AO_UC_Load_A_Register);
+ ni_stc_writel(dev, 0xffffff, NISTC_AO_UC_LOADA_REG);
+ ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, NISTC_AO_CMD1_REG);
+ ni_stc_writel(dev, 0xffffff, NISTC_AO_UC_LOADA_REG);
break;
default:
- ni_stc_writel(dev, 0, AO_UC_Load_A_Register);
- ni_stc_writew(dev, AO_UC_Load, AO_Command_1_Register);
- ni_stc_writel(dev, cmd->stop_arg, AO_UC_Load_A_Register);
+ ni_stc_writel(dev, 0, NISTC_AO_UC_LOADA_REG);
+ ni_stc_writew(dev, NISTC_AO_CMD1_UC_LOAD, NISTC_AO_CMD1_REG);
+ ni_stc_writel(dev, cmd->stop_arg, NISTC_AO_UC_LOADA_REG);
}
- devpriv->ao_mode1 &=
- ~(AO_UI_Source_Select(0x1f) | AO_UI_Source_Polarity |
- AO_UPDATE_Source_Select(0x1f) | AO_UPDATE_Source_Polarity);
+ devpriv->ao_mode1 &= ~(NISTC_AO_MODE1_UPDATE_SRC_MASK |
+ NISTC_AO_MODE1_UI_SRC_MASK |
+ NISTC_AO_MODE1_UPDATE_SRC_POLARITY |
+ NISTC_AO_MODE1_UI_SRC_POLARITY);
switch (cmd->scan_begin_src) {
case TRIG_TIMER:
- devpriv->ao_cmd2 &= ~AO_BC_Gate_Enable;
+ devpriv->ao_cmd2 &= ~NISTC_AO_CMD2_BC_GATE_ENA;
trigvar =
ni_ns_to_timer(dev, cmd->scan_begin_arg,
CMDF_ROUND_NEAREST);
- ni_stc_writel(dev, 1, AO_UI_Load_A_Register);
- ni_stc_writew(dev, AO_UI_Load, AO_Command_1_Register);
- ni_stc_writel(dev, trigvar, AO_UI_Load_A_Register);
+ ni_stc_writel(dev, 1, NISTC_AO_UI_LOADA_REG);
+ ni_stc_writew(dev, NISTC_AO_CMD1_UI_LOAD, NISTC_AO_CMD1_REG);
+ ni_stc_writel(dev, trigvar, NISTC_AO_UI_LOADA_REG);
break;
case TRIG_EXT:
devpriv->ao_mode1 |=
- AO_UPDATE_Source_Select(cmd->scan_begin_arg);
+ NISTC_AO_MODE1_UPDATE_SRC(cmd->scan_begin_arg);
if (cmd->scan_begin_arg & CR_INVERT)
- devpriv->ao_mode1 |= AO_UPDATE_Source_Polarity;
- devpriv->ao_cmd2 |= AO_BC_Gate_Enable;
+ devpriv->ao_mode1 |= NISTC_AO_MODE1_UPDATE_SRC_POLARITY;
+ devpriv->ao_cmd2 |= NISTC_AO_CMD2_BC_GATE_ENA;
break;
default:
BUG();
break;
}
- ni_stc_writew(dev, devpriv->ao_cmd2, AO_Command_2_Register);
- ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register);
- devpriv->ao_mode2 &=
- ~(AO_UI_Reload_Mode(3) | AO_UI_Initial_Load_Source);
- ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
+ ni_stc_writew(dev, devpriv->ao_cmd2, NISTC_AO_CMD2_REG);
+ ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG);
+ devpriv->ao_mode2 &= ~(NISTC_AO_MODE2_UI_RELOAD_MODE(3) |
+ NISTC_AO_MODE2_UI_INIT_LOAD_SRC);
+ ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG);
if (cmd->scan_end_arg > 1) {
- devpriv->ao_mode1 |= AO_Multiple_Channels;
+ devpriv->ao_mode1 |= NISTC_AO_MODE1_MULTI_CHAN;
ni_stc_writew(dev,
- AO_Number_Of_Channels(cmd->scan_end_arg - 1) |
- AO_UPDATE_Output_Select(AO_Update_Output_High_Z),
- AO_Output_Control_Register);
+ NISTC_AO_OUT_CTRL_CHANS(cmd->scan_end_arg - 1) |
+ NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ,
+ NISTC_AO_OUT_CTRL_REG);
} else {
unsigned bits;
- devpriv->ao_mode1 &= ~AO_Multiple_Channels;
- bits = AO_UPDATE_Output_Select(AO_Update_Output_High_Z);
+ devpriv->ao_mode1 &= ~NISTC_AO_MODE1_MULTI_CHAN;
+ bits = NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ;
if (devpriv->is_m_series || devpriv->is_6xxx) {
- bits |= AO_Number_Of_Channels(0);
+ bits |= NISTC_AO_OUT_CTRL_CHANS(0);
} else {
bits |=
- AO_Number_Of_Channels(CR_CHAN(cmd->chanlist[0]));
+ NISTC_AO_OUT_CTRL_CHANS(CR_CHAN(cmd->chanlist[0]));
}
- ni_stc_writew(dev, bits, AO_Output_Control_Register);
+ ni_stc_writew(dev, bits, NISTC_AO_OUT_CTRL_REG);
}
- ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register);
+ ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG);
- ni_stc_writew(dev, AO_DAC0_Update_Mode | AO_DAC1_Update_Mode,
- AO_Command_1_Register);
+ ni_stc_writew(dev, NISTC_AO_CMD1_DAC1_UPDATE_MODE |
+ NISTC_AO_CMD1_DAC0_UPDATE_MODE,
+ NISTC_AO_CMD1_REG);
- devpriv->ao_mode3 |= AO_Stop_On_Overrun_Error;
- ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register);
+ devpriv->ao_mode3 |= NISTC_AO_MODE3_STOP_ON_OVERRUN_ERR;
+ ni_stc_writew(dev, devpriv->ao_mode3, NISTC_AO_MODE3_REG);
- devpriv->ao_mode2 &= ~AO_FIFO_Mode_Mask;
+ devpriv->ao_mode2 &= ~NISTC_AO_MODE2_FIFO_MODE_MASK;
#ifdef PCIDMA
- devpriv->ao_mode2 |= AO_FIFO_Mode_HF_to_F;
+ devpriv->ao_mode2 |= NISTC_AO_MODE2_FIFO_MODE_HF_F;
#else
- devpriv->ao_mode2 |= AO_FIFO_Mode_HF;
+ devpriv->ao_mode2 |= NISTC_AO_MODE2_FIFO_MODE_HF;
#endif
- devpriv->ao_mode2 &= ~AO_FIFO_Retransmit_Enable;
- ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
+ devpriv->ao_mode2 &= ~NISTC_AO_MODE2_FIFO_REXMIT_ENA;
+ ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG);
- bits = AO_BC_Source_Select | AO_UPDATE_Pulse_Width |
- AO_TMRDACWR_Pulse_Width;
+ bits = NISTC_AO_PERSONAL_BC_SRC_SEL |
+ NISTC_AO_PERSONAL_UPDATE_PW |
+ NISTC_AO_PERSONAL_TMRDACWR_PW;
if (board->ao_fifo_depth)
- bits |= AO_FIFO_Enable;
+ bits |= NISTC_AO_PERSONAL_FIFO_ENA;
else
- bits |= AO_DMA_PIO_Control;
+ bits |= NISTC_AO_PERSONAL_DMA_PIO_CTRL;
#if 0
- /* F Hess: windows driver does not set AO_Number_Of_DAC_Packages bit for 6281,
- verified with bus analyzer. */
+ /*
+ * F Hess: windows driver does not set NISTC_AO_PERSONAL_NUM_DAC bit
+ * for 6281, verified with bus analyzer.
+ */
if (devpriv->is_m_series)
- bits |= AO_Number_Of_DAC_Packages;
+ bits |= NISTC_AO_PERSONAL_NUM_DAC;
#endif
- ni_stc_writew(dev, bits, AO_Personal_Register);
+ ni_stc_writew(dev, bits, NISTC_AO_PERSONAL_REG);
/* enable sending of ao dma requests */
- ni_stc_writew(dev, AO_AOFREQ_Enable, AO_Start_Select_Register);
+ ni_stc_writew(dev, NISTC_AO_START_AOFREQ_ENA, NISTC_AO_START_SEL_REG);
- ni_stc_writew(dev, AO_Configuration_End, Joint_Reset_Register);
+ ni_stc_writew(dev, NISTC_RESET_AO_CFG_END, NISTC_RESET_REG);
if (cmd->stop_src == TRIG_COUNT) {
- ni_stc_writew(dev, AO_BC_TC_Interrupt_Ack,
- Interrupt_B_Ack_Register);
- ni_set_bits(dev, Interrupt_B_Enable_Register,
- AO_BC_TC_Interrupt_Enable, 1);
+ ni_stc_writew(dev, NISTC_INTB_ACK_AO_BC_TC,
+ NISTC_INTB_ACK_REG);
+ ni_set_bits(dev, NISTC_INTB_ENA_REG,
+ NISTC_INTB_ENA_AO_BC_TC, 1);
}
s->async->inttrig = ni_ao_inttrig;
@@ -3339,41 +3194,44 @@ static int ni_ao_reset(struct comedi_device *dev, struct comedi_subdevice *s)
ni_release_ao_mite_channel(dev);
- ni_stc_writew(dev, AO_Configuration_Start, Joint_Reset_Register);
- ni_stc_writew(dev, AO_Disarm, AO_Command_1_Register);
- ni_set_bits(dev, Interrupt_B_Enable_Register, ~0, 0);
- ni_stc_writew(dev, AO_BC_Source_Select, AO_Personal_Register);
- ni_stc_writew(dev, 0x3f98, Interrupt_B_Ack_Register);
- ni_stc_writew(dev, AO_BC_Source_Select | AO_UPDATE_Pulse_Width |
- AO_TMRDACWR_Pulse_Width, AO_Personal_Register);
- ni_stc_writew(dev, 0, AO_Output_Control_Register);
- ni_stc_writew(dev, 0, AO_Start_Select_Register);
+ ni_stc_writew(dev, NISTC_RESET_AO_CFG_START, NISTC_RESET_REG);
+ ni_stc_writew(dev, NISTC_AO_CMD1_DISARM, NISTC_AO_CMD1_REG);
+ ni_set_bits(dev, NISTC_INTB_ENA_REG, ~0, 0);
+ ni_stc_writew(dev, NISTC_AO_PERSONAL_BC_SRC_SEL, NISTC_AO_PERSONAL_REG);
+ ni_stc_writew(dev, NISTC_INTB_ACK_AO_ALL, NISTC_INTB_ACK_REG);
+ ni_stc_writew(dev, NISTC_AO_PERSONAL_BC_SRC_SEL |
+ NISTC_AO_PERSONAL_UPDATE_PW |
+ NISTC_AO_PERSONAL_TMRDACWR_PW,
+ NISTC_AO_PERSONAL_REG);
+ ni_stc_writew(dev, 0, NISTC_AO_OUT_CTRL_REG);
+ ni_stc_writew(dev, 0, NISTC_AO_START_SEL_REG);
devpriv->ao_cmd1 = 0;
- ni_stc_writew(dev, devpriv->ao_cmd1, AO_Command_1_Register);
+ ni_stc_writew(dev, devpriv->ao_cmd1, NISTC_AO_CMD1_REG);
devpriv->ao_cmd2 = 0;
- ni_stc_writew(dev, devpriv->ao_cmd2, AO_Command_2_Register);
+ ni_stc_writew(dev, devpriv->ao_cmd2, NISTC_AO_CMD2_REG);
devpriv->ao_mode1 = 0;
- ni_stc_writew(dev, devpriv->ao_mode1, AO_Mode_1_Register);
+ ni_stc_writew(dev, devpriv->ao_mode1, NISTC_AO_MODE1_REG);
devpriv->ao_mode2 = 0;
- ni_stc_writew(dev, devpriv->ao_mode2, AO_Mode_2_Register);
+ ni_stc_writew(dev, devpriv->ao_mode2, NISTC_AO_MODE2_REG);
if (devpriv->is_m_series)
- devpriv->ao_mode3 = AO_Last_Gate_Disable;
+ devpriv->ao_mode3 = NISTC_AO_MODE3_LAST_GATE_DISABLE;
else
devpriv->ao_mode3 = 0;
- ni_stc_writew(dev, devpriv->ao_mode3, AO_Mode_3_Register);
+ ni_stc_writew(dev, devpriv->ao_mode3, NISTC_AO_MODE3_REG);
devpriv->ao_trigger_select = 0;
ni_stc_writew(dev, devpriv->ao_trigger_select,
- AO_Trigger_Select_Register);
+ NISTC_AO_TRIG_SEL_REG);
if (devpriv->is_6xxx) {
unsigned immediate_bits = 0;
unsigned i;
for (i = 0; i < s->n_chan; ++i)
immediate_bits |= 1 << i;
- ni_ao_win_outw(dev, immediate_bits, AO_Immediate_671x);
- ni_ao_win_outw(dev, CLEAR_WG, AO_Misc_611x);
+ ni_ao_win_outw(dev, immediate_bits, NI671X_AO_IMMEDIATE_REG);
+ ni_ao_win_outw(dev, NI611X_AO_MISC_CLEAR_WG,
+ NI611X_AO_MISC_REG);
}
- ni_stc_writew(dev, AO_Configuration_End, Joint_Reset_Register);
+ ni_stc_writew(dev, NISTC_RESET_AO_CFG_END, NISTC_RESET_REG);
return 0;
}
@@ -3392,9 +3250,9 @@ static int ni_dio_insn_config(struct comedi_device *dev,
if (ret)
return ret;
- devpriv->dio_control &= ~DIO_Pins_Dir_Mask;
- devpriv->dio_control |= DIO_Pins_Dir(s->io_bits);
- ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register);
+ devpriv->dio_control &= ~NISTC_DIO_CTRL_DIR_MASK;
+ devpriv->dio_control |= NISTC_DIO_CTRL_DIR(s->io_bits);
+ ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG);
return insn->n;
}
@@ -3407,16 +3265,17 @@ static int ni_dio_insn_bits(struct comedi_device *dev,
struct ni_private *devpriv = dev->private;
/* Make sure we're not using the serial part of the dio */
- if ((data[0] & (DIO_SDIN | DIO_SDOUT)) && devpriv->serial_interval_ns)
+ if ((data[0] & (NISTC_DIO_SDIN | NISTC_DIO_SDOUT)) &&
+ devpriv->serial_interval_ns)
return -EBUSY;
if (comedi_dio_update_state(s, data)) {
- devpriv->dio_output &= ~DIO_Parallel_Data_Mask;
- devpriv->dio_output |= DIO_Parallel_Data_Out(s->state);
- ni_stc_writew(dev, devpriv->dio_output, DIO_Output_Register);
+ devpriv->dio_output &= ~NISTC_DIO_OUT_PARALLEL_MASK;
+ devpriv->dio_output |= NISTC_DIO_OUT_PARALLEL(s->state);
+ ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG);
}
- data[1] = ni_stc_readw(dev, DIO_Parallel_Input_Register);
+ data[1] = ni_stc_readw(dev, NISTC_DIO_IN_REG);
return insn->n;
}
@@ -3432,7 +3291,7 @@ static int ni_m_series_dio_insn_config(struct comedi_device *dev,
if (ret)
return ret;
- ni_writel(dev, s->io_bits, M_Offset_DIO_Direction);
+ ni_writel(dev, s->io_bits, NI_M_DIO_DIR_REG);
return insn->n;
}
@@ -3443,9 +3302,9 @@ static int ni_m_series_dio_insn_bits(struct comedi_device *dev,
unsigned int *data)
{
if (comedi_dio_update_state(s, data))
- ni_writel(dev, s->state, M_Offset_Static_Digital_Output);
+ ni_writel(dev, s->state, NI_M_DIO_REG);
- data[1] = ni_readl(dev, M_Offset_Static_Digital_Input);
+ data[1] = ni_readl(dev, NI_M_DIO_REG);
return insn->n;
}
@@ -3491,7 +3350,7 @@ static int ni_cdio_cmdtest(struct comedi_device *dev,
err |= comedi_check_trigger_arg_is(&cmd->start_arg, 0);
tmp = cmd->scan_begin_arg;
- tmp &= CR_PACK_FLAGS(CDO_Sample_Source_Select_Mask, 0, 0, CR_INVERT);
+ tmp &= CR_PACK_FLAGS(NI_M_CDO_MODE_SAMPLE_SRC_MASK, 0, 0, CR_INVERT);
if (tmp != cmd->scan_begin_arg)
err |= -EINVAL;
@@ -3550,13 +3409,14 @@ static int ni_cdo_inttrig(struct comedi_device *dev,
if (retval < 0)
return retval;
#endif
-/*
-* XXX not sure what interrupt C group does
-* ni_writeb(dev, Interrupt_Group_C_Enable_Bit,
-* M_Offset_Interrupt_C_Enable); wait for dma to fill output fifo
-*/
+ /*
+ * XXX not sure what interrupt C group does
+ * wait for dma to fill output fifo
+ * ni_writeb(dev, NI_M_INTC_ENA, NI_M_INTC_ENA_REG);
+ */
for (i = 0; i < timeout; ++i) {
- if (ni_readl(dev, M_Offset_CDIO_Status) & CDO_FIFO_Full_Bit)
+ if (ni_readl(dev, NI_M_CDIO_STATUS_REG) &
+ NI_M_CDIO_STATUS_CDO_FIFO_FULL)
break;
udelay(10);
}
@@ -3565,36 +3425,30 @@ static int ni_cdo_inttrig(struct comedi_device *dev,
s->cancel(dev, s);
return -EIO;
}
- ni_writel(dev, CDO_Arm_Bit | CDO_Error_Interrupt_Enable_Set_Bit |
- CDO_Empty_FIFO_Interrupt_Enable_Set_Bit,
- M_Offset_CDIO_Command);
+ ni_writel(dev, NI_M_CDO_CMD_ARM |
+ NI_M_CDO_CMD_ERR_INT_ENA_SET |
+ NI_M_CDO_CMD_F_E_INT_ENA_SET,
+ NI_M_CDIO_CMD_REG);
return retval;
}
static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
{
const struct comedi_cmd *cmd = &s->async->cmd;
- unsigned cdo_mode_bits = CDO_FIFO_Mode_Bit | CDO_Halt_On_Error_Bit;
+ unsigned cdo_mode_bits;
int retval;
- ni_writel(dev, CDO_Reset_Bit, M_Offset_CDIO_Command);
- switch (cmd->scan_begin_src) {
- case TRIG_EXT:
- cdo_mode_bits |=
- CR_CHAN(cmd->scan_begin_arg) &
- CDO_Sample_Source_Select_Mask;
- break;
- default:
- BUG();
- break;
- }
+ ni_writel(dev, NI_M_CDO_CMD_RESET, NI_M_CDIO_CMD_REG);
+ cdo_mode_bits = NI_M_CDO_MODE_FIFO_MODE |
+ NI_M_CDO_MODE_HALT_ON_ERROR |
+ NI_M_CDO_MODE_SAMPLE_SRC(CR_CHAN(cmd->scan_begin_arg));
if (cmd->scan_begin_arg & CR_INVERT)
- cdo_mode_bits |= CDO_Polarity_Bit;
- ni_writel(dev, cdo_mode_bits, M_Offset_CDO_Mode);
+ cdo_mode_bits |= NI_M_CDO_MODE_POLARITY;
+ ni_writel(dev, cdo_mode_bits, NI_M_CDO_MODE_REG);
if (s->io_bits) {
- ni_writel(dev, s->state, M_Offset_CDO_FIFO_Data);
- ni_writel(dev, CDO_SW_Update_Bit, M_Offset_CDIO_Command);
- ni_writel(dev, s->io_bits, M_Offset_CDO_Mask_Enable);
+ ni_writel(dev, s->state, NI_M_CDO_FIFO_DATA_REG);
+ ni_writel(dev, NI_M_CDO_CMD_SW_UPDATE, NI_M_CDIO_CMD_REG);
+ ni_writel(dev, s->io_bits, NI_M_CDO_MASK_ENA_REG);
} else {
dev_err(dev->class_dev,
"attempted to run digital output command with no lines configured as outputs\n");
@@ -3611,15 +3465,16 @@ static int ni_cdio_cmd(struct comedi_device *dev, struct comedi_subdevice *s)
static int ni_cdio_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
{
- ni_writel(dev, CDO_Disarm_Bit | CDO_Error_Interrupt_Enable_Clear_Bit |
- CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit |
- CDO_FIFO_Request_Interrupt_Enable_Clear_Bit,
- M_Offset_CDIO_Command);
-/*
-* XXX not sure what interrupt C group does ni_writeb(dev, 0,
-* M_Offset_Interrupt_C_Enable);
-*/
- ni_writel(dev, 0, M_Offset_CDO_Mask_Enable);
+ ni_writel(dev, NI_M_CDO_CMD_DISARM |
+ NI_M_CDO_CMD_ERR_INT_ENA_CLR |
+ NI_M_CDO_CMD_F_E_INT_ENA_CLR |
+ NI_M_CDO_CMD_F_REQ_INT_ENA_CLR,
+ NI_M_CDIO_CMD_REG);
+ /*
+ * XXX not sure what interrupt C group does
+ * ni_writeb(dev, 0, NI_M_INTC_ENA_REG);
+ */
+ ni_writel(dev, 0, NI_M_CDO_MASK_ENA_REG);
ni_release_cdo_mite_channel(dev);
return 0;
}
@@ -3650,16 +3505,16 @@ static void handle_cdio_interrupt(struct comedi_device *dev)
spin_unlock_irqrestore(&devpriv->mite_channel_lock, flags);
#endif
- cdio_status = ni_readl(dev, M_Offset_CDIO_Status);
- if (cdio_status & (CDO_Overrun_Bit | CDO_Underflow_Bit)) {
+ cdio_status = ni_readl(dev, NI_M_CDIO_STATUS_REG);
+ if (cdio_status & NI_M_CDIO_STATUS_CDO_ERROR) {
/* XXX just guessing this is needed and does something useful */
- ni_writel(dev, CDO_Error_Interrupt_Confirm_Bit,
- M_Offset_CDIO_Command);
+ ni_writel(dev, NI_M_CDO_CMD_ERR_INT_CONFIRM,
+ NI_M_CDIO_CMD_REG);
s->async->events |= COMEDI_CB_OVERFLOW;
}
- if (cdio_status & CDO_FIFO_Empty_Bit) {
- ni_writel(dev, CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit,
- M_Offset_CDIO_Command);
+ if (cdio_status & NI_M_CDIO_STATUS_CDO_FIFO_EMPTY) {
+ ni_writel(dev, NI_M_CDO_CMD_F_E_INT_ENA_CLR,
+ NI_M_CDIO_CMD_REG);
/* s->async->events |= COMEDI_CB_EOA; */
}
comedi_handle_events(dev, s);
@@ -3674,23 +3529,23 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev,
unsigned int status1;
int err = 0, count = 20;
- devpriv->dio_output &= ~DIO_Serial_Data_Mask;
- devpriv->dio_output |= DIO_Serial_Data_Out(data_out);
- ni_stc_writew(dev, devpriv->dio_output, DIO_Output_Register);
+ devpriv->dio_output &= ~NISTC_DIO_OUT_SERIAL_MASK;
+ devpriv->dio_output |= NISTC_DIO_OUT_SERIAL(data_out);
+ ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG);
- status1 = ni_stc_readw(dev, Joint_Status_1_Register);
- if (status1 & DIO_Serial_IO_In_Progress_St) {
+ status1 = ni_stc_readw(dev, NISTC_STATUS1_REG);
+ if (status1 & NISTC_STATUS1_SERIO_IN_PROG) {
err = -EBUSY;
goto Error;
}
- devpriv->dio_control |= DIO_HW_Serial_Start;
- ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register);
- devpriv->dio_control &= ~DIO_HW_Serial_Start;
+ devpriv->dio_control |= NISTC_DIO_CTRL_HW_SER_START;
+ ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG);
+ devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_START;
/* Wait until STC says we're done, but don't loop infinitely. */
- while ((status1 = ni_stc_readw(dev, Joint_Status_1_Register)) &
- DIO_Serial_IO_In_Progress_St) {
+ while ((status1 = ni_stc_readw(dev, NISTC_STATUS1_REG)) &
+ NISTC_STATUS1_SERIO_IN_PROG) {
/* Delay one bit per loop */
udelay((devpriv->serial_interval_ns + 999) / 1000);
if (--count < 0) {
@@ -3701,15 +3556,17 @@ static int ni_serial_hw_readwrite8(struct comedi_device *dev,
}
}
- /* Delay for last bit. This delay is absolutely necessary, because
- DIO_Serial_IO_In_Progress_St goes high one bit too early. */
+ /*
+ * Delay for last bit. This delay is absolutely necessary, because
+ * NISTC_STATUS1_SERIO_IN_PROG goes high one bit too early.
+ */
udelay((devpriv->serial_interval_ns + 999) / 1000);
if (data_in)
- *data_in = ni_stc_readw(dev, DIO_Serial_Input_Register);
+ *data_in = ni_stc_readw(dev, NISTC_DIO_SERIAL_IN_REG);
Error:
- ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register);
+ ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG);
return err;
}
@@ -3729,25 +3586,25 @@ static int ni_serial_sw_readwrite8(struct comedi_device *dev,
/* Output current bit; note that we cannot touch s->state
because it is a per-subdevice field, and serial is
a separate subdevice from DIO. */
- devpriv->dio_output &= ~DIO_SDOUT;
+ devpriv->dio_output &= ~NISTC_DIO_SDOUT;
if (data_out & mask)
- devpriv->dio_output |= DIO_SDOUT;
- ni_stc_writew(dev, devpriv->dio_output, DIO_Output_Register);
+ devpriv->dio_output |= NISTC_DIO_SDOUT;
+ ni_stc_writew(dev, devpriv->dio_output, NISTC_DIO_OUT_REG);
/* Assert SDCLK (active low, inverted), wait for half of
the delay, deassert SDCLK, and wait for the other half. */
- devpriv->dio_control |= DIO_Software_Serial_Control;
- ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register);
+ devpriv->dio_control |= NISTC_DIO_SDCLK;
+ ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG);
udelay((devpriv->serial_interval_ns + 999) / 2000);
- devpriv->dio_control &= ~DIO_Software_Serial_Control;
- ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register);
+ devpriv->dio_control &= ~NISTC_DIO_SDCLK;
+ ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG);
udelay((devpriv->serial_interval_ns + 999) / 2000);
/* Input current bit */
- if (ni_stc_readw(dev, DIO_Parallel_Input_Register) & DIO_SDIN)
+ if (ni_stc_readw(dev, NISTC_DIO_IN_REG) & NISTC_DIO_SDIN)
input |= mask;
}
@@ -3763,6 +3620,7 @@ static int ni_serial_insn_config(struct comedi_device *dev,
unsigned int *data)
{
struct ni_private *devpriv = dev->private;
+ unsigned clk_fout = devpriv->clock_and_fout;
int err = insn->n;
unsigned char byte_out, byte_in = 0;
@@ -3772,49 +3630,49 @@ static int ni_serial_insn_config(struct comedi_device *dev,
switch (data[0]) {
case INSN_CONFIG_SERIAL_CLOCK:
devpriv->serial_hw_mode = 1;
- devpriv->dio_control |= DIO_HW_Serial_Enable;
+ devpriv->dio_control |= NISTC_DIO_CTRL_HW_SER_ENA;
if (data[1] == SERIAL_DISABLED) {
devpriv->serial_hw_mode = 0;
- devpriv->dio_control &= ~(DIO_HW_Serial_Enable |
- DIO_Software_Serial_Control);
+ devpriv->dio_control &= ~(NISTC_DIO_CTRL_HW_SER_ENA |
+ NISTC_DIO_SDCLK);
data[1] = SERIAL_DISABLED;
devpriv->serial_interval_ns = data[1];
} else if (data[1] <= SERIAL_600NS) {
/* Warning: this clock speed is too fast to reliably
control SCXI. */
- devpriv->dio_control &= ~DIO_HW_Serial_Timebase;
- devpriv->clock_and_fout |= Slow_Internal_Timebase;
- devpriv->clock_and_fout &= ~DIO_Serial_Out_Divide_By_2;
+ devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_TIMEBASE;
+ clk_fout |= NISTC_CLK_FOUT_SLOW_TIMEBASE;
+ clk_fout &= ~NISTC_CLK_FOUT_DIO_SER_OUT_DIV2;
data[1] = SERIAL_600NS;
devpriv->serial_interval_ns = data[1];
} else if (data[1] <= SERIAL_1_2US) {
- devpriv->dio_control &= ~DIO_HW_Serial_Timebase;
- devpriv->clock_and_fout |= Slow_Internal_Timebase |
- DIO_Serial_Out_Divide_By_2;
+ devpriv->dio_control &= ~NISTC_DIO_CTRL_HW_SER_TIMEBASE;
+ clk_fout |= NISTC_CLK_FOUT_SLOW_TIMEBASE |
+ NISTC_CLK_FOUT_DIO_SER_OUT_DIV2;
data[1] = SERIAL_1_2US;
devpriv->serial_interval_ns = data[1];
} else if (data[1] <= SERIAL_10US) {
- devpriv->dio_control |= DIO_HW_Serial_Timebase;
- devpriv->clock_and_fout |= Slow_Internal_Timebase |
- DIO_Serial_Out_Divide_By_2;
- /* Note: DIO_Serial_Out_Divide_By_2 only affects
+ devpriv->dio_control |= NISTC_DIO_CTRL_HW_SER_TIMEBASE;
+ clk_fout |= NISTC_CLK_FOUT_SLOW_TIMEBASE |
+ NISTC_CLK_FOUT_DIO_SER_OUT_DIV2;
+ /* Note: NISTC_CLK_FOUT_DIO_SER_OUT_DIV2 only affects
600ns/1.2us. If you turn divide_by_2 off with the
slow clock, you will still get 10us, except then
all your delays are wrong. */
data[1] = SERIAL_10US;
devpriv->serial_interval_ns = data[1];
} else {
- devpriv->dio_control &= ~(DIO_HW_Serial_Enable |
- DIO_Software_Serial_Control);
+ devpriv->dio_control &= ~(NISTC_DIO_CTRL_HW_SER_ENA |
+ NISTC_DIO_SDCLK);
devpriv->serial_hw_mode = 0;
data[1] = (data[1] / 1000) * 1000;
devpriv->serial_interval_ns = data[1];
}
+ devpriv->clock_and_fout = clk_fout;
- ni_stc_writew(dev, devpriv->dio_control, DIO_Control_Register);
- ni_stc_writew(dev, devpriv->clock_and_fout,
- Clock_and_FOUT_Register);
+ ni_stc_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG);
+ ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG);
return 1;
case INSN_CONFIG_BIDIRECTIONAL_DATA:
@@ -3850,141 +3708,91 @@ static void init_ao_67xx(struct comedi_device *dev, struct comedi_subdevice *s)
int i;
for (i = 0; i < s->n_chan; i++) {
- ni_ao_win_outw(dev, AO_Channel(i) | 0x0,
- AO_Configuration_2_67xx);
- }
- ni_ao_win_outw(dev, 0x0, AO_Later_Single_Point_Updates);
-}
+ ni_ao_win_outw(dev, NI_E_AO_DACSEL(i) | 0x0,
+ NI67XX_AO_CFG2_REG);
+ }
+ ni_ao_win_outw(dev, 0x0, NI67XX_AO_SP_UPDATES_REG);
+}
+
+static const struct mio_regmap ni_gpct_to_stc_regmap[] = {
+ [NITIO_G0_AUTO_INC] = { NISTC_G0_AUTOINC_REG, 2 },
+ [NITIO_G1_AUTO_INC] = { NISTC_G1_AUTOINC_REG, 2 },
+ [NITIO_G0_CMD] = { NISTC_G0_CMD_REG, 2 },
+ [NITIO_G1_CMD] = { NISTC_G1_CMD_REG, 2 },
+ [NITIO_G0_HW_SAVE] = { NISTC_G0_HW_SAVE_REG, 4 },
+ [NITIO_G1_HW_SAVE] = { NISTC_G1_HW_SAVE_REG, 4 },
+ [NITIO_G0_SW_SAVE] = { NISTC_G0_SAVE_REG, 4 },
+ [NITIO_G1_SW_SAVE] = { NISTC_G1_SAVE_REG, 4 },
+ [NITIO_G0_MODE] = { NISTC_G0_MODE_REG, 2 },
+ [NITIO_G1_MODE] = { NISTC_G1_MODE_REG, 2 },
+ [NITIO_G0_LOADA] = { NISTC_G0_LOADA_REG, 4 },
+ [NITIO_G1_LOADA] = { NISTC_G1_LOADA_REG, 4 },
+ [NITIO_G0_LOADB] = { NISTC_G0_LOADB_REG, 4 },
+ [NITIO_G1_LOADB] = { NISTC_G1_LOADB_REG, 4 },
+ [NITIO_G0_INPUT_SEL] = { NISTC_G0_INPUT_SEL_REG, 2 },
+ [NITIO_G1_INPUT_SEL] = { NISTC_G1_INPUT_SEL_REG, 2 },
+ [NITIO_G0_CNT_MODE] = { 0x1b0, 2 }, /* M-Series only */
+ [NITIO_G1_CNT_MODE] = { 0x1b2, 2 }, /* M-Series only */
+ [NITIO_G0_GATE2] = { 0x1b4, 2 }, /* M-Series only */
+ [NITIO_G1_GATE2] = { 0x1b6, 2 }, /* M-Series only */
+ [NITIO_G01_STATUS] = { NISTC_G01_STATUS_REG, 2 },
+ [NITIO_G01_RESET] = { NISTC_RESET_REG, 2 },
+ [NITIO_G01_STATUS1] = { NISTC_STATUS1_REG, 2 },
+ [NITIO_G01_STATUS2] = { NISTC_STATUS2_REG, 2 },
+ [NITIO_G0_DMA_CFG] = { 0x1b8, 2 }, /* M-Series only */
+ [NITIO_G1_DMA_CFG] = { 0x1ba, 2 }, /* M-Series only */
+ [NITIO_G0_DMA_STATUS] = { 0x1b8, 2 }, /* M-Series only */
+ [NITIO_G1_DMA_STATUS] = { 0x1ba, 2 }, /* M-Series only */
+ [NITIO_G0_ABZ] = { 0x1c0, 2 }, /* M-Series only */
+ [NITIO_G1_ABZ] = { 0x1c2, 2 }, /* M-Series only */
+ [NITIO_G0_INT_ACK] = { NISTC_INTA_ACK_REG, 2 },
+ [NITIO_G1_INT_ACK] = { NISTC_INTB_ACK_REG, 2 },
+ [NITIO_G0_STATUS] = { NISTC_AI_STATUS1_REG, 2 },
+ [NITIO_G1_STATUS] = { NISTC_AO_STATUS1_REG, 2 },
+ [NITIO_G0_INT_ENA] = { NISTC_INTA_ENA_REG, 2 },
+ [NITIO_G1_INT_ENA] = { NISTC_INTB_ENA_REG, 2 },
+};
-static unsigned ni_gpct_to_stc_register(enum ni_gpct_register reg)
+static unsigned int ni_gpct_to_stc_register(struct comedi_device *dev,
+ enum ni_gpct_register reg)
{
- unsigned stc_register;
+ const struct mio_regmap *regmap;
- switch (reg) {
- case NITIO_G0_AUTO_INC:
- stc_register = G_Autoincrement_Register(0);
- break;
- case NITIO_G1_AUTO_INC:
- stc_register = G_Autoincrement_Register(1);
- break;
- case NITIO_G0_CMD:
- stc_register = G_Command_Register(0);
- break;
- case NITIO_G1_CMD:
- stc_register = G_Command_Register(1);
- break;
- case NITIO_G0_HW_SAVE:
- stc_register = G_HW_Save_Register(0);
- break;
- case NITIO_G1_HW_SAVE:
- stc_register = G_HW_Save_Register(1);
- break;
- case NITIO_G0_SW_SAVE:
- stc_register = G_Save_Register(0);
- break;
- case NITIO_G1_SW_SAVE:
- stc_register = G_Save_Register(1);
- break;
- case NITIO_G0_MODE:
- stc_register = G_Mode_Register(0);
- break;
- case NITIO_G1_MODE:
- stc_register = G_Mode_Register(1);
- break;
- case NITIO_G0_LOADA:
- stc_register = G_Load_A_Register(0);
- break;
- case NITIO_G1_LOADA:
- stc_register = G_Load_A_Register(1);
- break;
- case NITIO_G0_LOADB:
- stc_register = G_Load_B_Register(0);
- break;
- case NITIO_G1_LOADB:
- stc_register = G_Load_B_Register(1);
- break;
- case NITIO_G0_INPUT_SEL:
- stc_register = G_Input_Select_Register(0);
- break;
- case NITIO_G1_INPUT_SEL:
- stc_register = G_Input_Select_Register(1);
- break;
- case NITIO_G01_STATUS:
- stc_register = G_Status_Register;
- break;
- case NITIO_G01_RESET:
- stc_register = Joint_Reset_Register;
- break;
- case NITIO_G01_STATUS1:
- stc_register = Joint_Status_1_Register;
- break;
- case NITIO_G01_STATUS2:
- stc_register = Joint_Status_2_Register;
- break;
- case NITIO_G0_INT_ACK:
- stc_register = Interrupt_A_Ack_Register;
- break;
- case NITIO_G1_INT_ACK:
- stc_register = Interrupt_B_Ack_Register;
- break;
- case NITIO_G0_STATUS:
- stc_register = AI_Status_1_Register;
- break;
- case NITIO_G1_STATUS:
- stc_register = AO_Status_1_Register;
- break;
- case NITIO_G0_INT_ENA:
- stc_register = Interrupt_A_Enable_Register;
- break;
- case NITIO_G1_INT_ENA:
- stc_register = Interrupt_B_Enable_Register;
- break;
- default:
- pr_err("%s: unhandled register 0x%x in switch.\n",
- __func__, reg);
- BUG();
+ if (reg < ARRAY_SIZE(ni_gpct_to_stc_regmap)) {
+ regmap = &ni_gpct_to_stc_regmap[reg];
+ } else {
+ dev_warn(dev->class_dev, "%s: unhandled register=0x%x\n",
+ __func__, reg);
return 0;
}
- return stc_register;
+
+ return regmap->mio_reg;
}
static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
enum ni_gpct_register reg)
{
struct comedi_device *dev = counter->counter_dev->dev;
- unsigned stc_register;
- /* bits in the join reset register which are relevant to counters */
- static const unsigned gpct_joint_reset_mask = G0_Reset | G1_Reset;
+ unsigned int stc_register = ni_gpct_to_stc_register(dev, reg);
static const unsigned gpct_interrupt_a_enable_mask =
- G0_Gate_Interrupt_Enable | G0_TC_Interrupt_Enable;
+ NISTC_INTA_ENA_G0_GATE | NISTC_INTA_ENA_G0_TC;
static const unsigned gpct_interrupt_b_enable_mask =
- G1_Gate_Interrupt_Enable | G1_TC_Interrupt_Enable;
+ NISTC_INTB_ENA_G1_GATE | NISTC_INTB_ENA_G1_TC;
+
+ if (stc_register == 0)
+ return;
switch (reg) {
- /* m-series-only registers */
+ /* m-series only registers */
case NITIO_G0_CNT_MODE:
- ni_writew(dev, bits, M_Offset_G0_Counting_Mode);
- break;
case NITIO_G1_CNT_MODE:
- ni_writew(dev, bits, M_Offset_G1_Counting_Mode);
- break;
case NITIO_G0_GATE2:
- ni_writew(dev, bits, M_Offset_G0_Second_Gate);
- break;
case NITIO_G1_GATE2:
- ni_writew(dev, bits, M_Offset_G1_Second_Gate);
- break;
case NITIO_G0_DMA_CFG:
- ni_writew(dev, bits, M_Offset_G0_DMA_Config);
- break;
case NITIO_G1_DMA_CFG:
- ni_writew(dev, bits, M_Offset_G1_DMA_Config);
- break;
case NITIO_G0_ABZ:
- ni_writew(dev, bits, M_Offset_G0_MSeries_ABZ);
- break;
case NITIO_G1_ABZ:
- ni_writew(dev, bits, M_Offset_G1_MSeries_ABZ);
+ ni_writew(dev, bits, stc_register);
break;
/* 32 bit registers */
@@ -3992,26 +3800,24 @@ static void ni_gpct_write_register(struct ni_gpct *counter, unsigned bits,
case NITIO_G1_LOADA:
case NITIO_G0_LOADB:
case NITIO_G1_LOADB:
- stc_register = ni_gpct_to_stc_register(reg);
ni_stc_writel(dev, bits, stc_register);
break;
/* 16 bit registers */
case NITIO_G0_INT_ENA:
BUG_ON(bits & ~gpct_interrupt_a_enable_mask);
- ni_set_bitfield(dev, Interrupt_A_Enable_Register,
+ ni_set_bitfield(dev, stc_register,
gpct_interrupt_a_enable_mask, bits);
break;
case NITIO_G1_INT_ENA:
BUG_ON(bits & ~gpct_interrupt_b_enable_mask);
- ni_set_bitfield(dev, Interrupt_B_Enable_Register,
+ ni_set_bitfield(dev, stc_register,
gpct_interrupt_b_enable_mask, bits);
break;
case NITIO_G01_RESET:
- BUG_ON(bits & ~gpct_joint_reset_mask);
+ BUG_ON(bits & ~(NISTC_RESET_G0 | NISTC_RESET_G1));
/* fall-through */
default:
- stc_register = ni_gpct_to_stc_register(reg);
ni_stc_writew(dev, bits, stc_register);
}
}
@@ -4020,29 +3826,28 @@ static unsigned ni_gpct_read_register(struct ni_gpct *counter,
enum ni_gpct_register reg)
{
struct comedi_device *dev = counter->counter_dev->dev;
- unsigned stc_register;
+ unsigned int stc_register = ni_gpct_to_stc_register(dev, reg);
+
+ if (stc_register == 0)
+ return 0;
switch (reg) {
/* m-series only registers */
case NITIO_G0_DMA_STATUS:
- return ni_readw(dev, M_Offset_G0_DMA_Status);
case NITIO_G1_DMA_STATUS:
- return ni_readw(dev, M_Offset_G1_DMA_Status);
+ return ni_readw(dev, stc_register);
/* 32 bit registers */
case NITIO_G0_HW_SAVE:
case NITIO_G1_HW_SAVE:
case NITIO_G0_SW_SAVE:
case NITIO_G1_SW_SAVE:
- stc_register = ni_gpct_to_stc_register(reg);
return ni_stc_readl(dev, stc_register);
/* 16 bit registers */
default:
- stc_register = ni_gpct_to_stc_register(reg);
return ni_stc_readw(dev, stc_register);
}
- return 0;
}
static int ni_freq_out_insn_read(struct comedi_device *dev,
@@ -4051,7 +3856,7 @@ static int ni_freq_out_insn_read(struct comedi_device *dev,
unsigned int *data)
{
struct ni_private *devpriv = dev->private;
- unsigned int val = devpriv->clock_and_fout & FOUT_Divider_mask;
+ unsigned int val = NISTC_CLK_FOUT_TO_DIVIDER(devpriv->clock_and_fout);
int i;
for (i = 0; i < insn->n; i++)
@@ -4068,17 +3873,17 @@ static int ni_freq_out_insn_write(struct comedi_device *dev,
struct ni_private *devpriv = dev->private;
if (insn->n) {
- devpriv->clock_and_fout &= ~FOUT_Enable;
- ni_stc_writew(dev, devpriv->clock_and_fout,
- Clock_and_FOUT_Register);
- devpriv->clock_and_fout &= ~FOUT_Divider_mask;
+ unsigned int val = data[insn->n - 1];
+
+ devpriv->clock_and_fout &= ~NISTC_CLK_FOUT_ENA;
+ ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG);
+ devpriv->clock_and_fout &= ~NISTC_CLK_FOUT_DIVIDER_MASK;
/* use the last data value to set the fout divider */
- devpriv->clock_and_fout |= FOUT_Divider(data[insn->n - 1]);
+ devpriv->clock_and_fout |= NISTC_CLK_FOUT_DIVIDER(val);
- devpriv->clock_and_fout |= FOUT_Enable;
- ni_stc_writew(dev, devpriv->clock_and_fout,
- Clock_and_FOUT_Register);
+ devpriv->clock_and_fout |= NISTC_CLK_FOUT_ENA;
+ ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG);
}
return insn->n;
}
@@ -4094,19 +3899,18 @@ static int ni_freq_out_insn_config(struct comedi_device *dev,
case INSN_CONFIG_SET_CLOCK_SRC:
switch (data[1]) {
case NI_FREQ_OUT_TIMEBASE_1_DIV_2_CLOCK_SRC:
- devpriv->clock_and_fout &= ~FOUT_Timebase_Select;
+ devpriv->clock_and_fout &= ~NISTC_CLK_FOUT_TIMEBASE_SEL;
break;
case NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC:
- devpriv->clock_and_fout |= FOUT_Timebase_Select;
+ devpriv->clock_and_fout |= NISTC_CLK_FOUT_TIMEBASE_SEL;
break;
default:
return -EINVAL;
}
- ni_stc_writew(dev, devpriv->clock_and_fout,
- Clock_and_FOUT_Register);
+ ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG);
break;
case INSN_CONFIG_GET_CLOCK_SRC:
- if (devpriv->clock_and_fout & FOUT_Timebase_Select) {
+ if (devpriv->clock_and_fout & NISTC_CLK_FOUT_TIMEBASE_SEL) {
data[1] = NI_FREQ_OUT_TIMEBASE_2_CLOCK_SRC;
data[2] = TIMEBASE_2_NS;
} else {
@@ -4190,9 +3994,9 @@ static int ni_m_series_pwm_config(struct comedi_device *dev,
data[4] = down_count * devpriv->clock_ns;
return -EAGAIN;
}
- ni_writel(dev, MSeries_Cal_PWM_High_Time_Bits(up_count) |
- MSeries_Cal_PWM_Low_Time_Bits(down_count),
- M_Offset_Cal_PWM);
+ ni_writel(dev, NI_M_CAL_PWM_HIGH_TIME(up_count) |
+ NI_M_CAL_PWM_LOW_TIME(down_count),
+ NI_M_CAL_PWM_REG);
devpriv->pwm_up_count = up_count;
devpriv->pwm_down_count = down_count;
return 5;
@@ -4254,9 +4058,9 @@ static int ni_6143_pwm_config(struct comedi_device *dev,
data[4] = down_count * devpriv->clock_ns;
return -EAGAIN;
}
- ni_writel(dev, up_count, Calibration_HighTime_6143);
+ ni_writel(dev, up_count, NI6143_CALIB_HI_TIME_REG);
devpriv->pwm_up_count = up_count;
- ni_writel(dev, down_count, Calibration_LowTime_6143);
+ ni_writel(dev, down_count, NI6143_CALIB_LO_TIME_REG);
devpriv->pwm_down_count = down_count;
return 5;
case INSN_CONFIG_GET_PWM_OUTPUT:
@@ -4336,6 +4140,7 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val)
const struct ni_board_struct *board = dev->board_ptr;
struct ni_private *devpriv = dev->private;
unsigned int loadbit = 0, bits = 0, bit, bitstring = 0;
+ unsigned int cmd;
int i;
int type;
@@ -4349,22 +4154,26 @@ static void ni_write_caldac(struct comedi_device *dev, int addr, int val)
break;
if (addr < caldacs[type].n_chans) {
bits = caldacs[type].packbits(addr, val, &bitstring);
- loadbit = SerDacLd(i);
+ loadbit = NI_E_SERIAL_CMD_DAC_LD(i);
break;
}
addr -= caldacs[type].n_chans;
}
+ /* bits will be 0 if there is no caldac for the given addr */
+ if (bits == 0)
+ return;
+
for (bit = 1 << (bits - 1); bit; bit >>= 1) {
- ni_writeb(dev, ((bit & bitstring) ? 0x02 : 0), Serial_Command);
+ cmd = (bit & bitstring) ? NI_E_SERIAL_CMD_SDATA : 0;
+ ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG);
udelay(1);
- ni_writeb(dev, 1 | ((bit & bitstring) ? 0x02 : 0),
- Serial_Command);
+ ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG);
udelay(1);
}
- ni_writeb(dev, loadbit, Serial_Command);
+ ni_writeb(dev, loadbit, NI_E_SERIAL_CMD_REG);
udelay(1);
- ni_writeb(dev, 0, Serial_Command);
+ ni_writeb(dev, 0, NI_E_SERIAL_CMD_REG);
}
static int ni_calib_insn_write(struct comedi_device *dev,
@@ -4446,24 +4255,30 @@ static void caldac_setup(struct comedi_device *dev, struct comedi_subdevice *s)
static int ni_read_eeprom(struct comedi_device *dev, int addr)
{
+ unsigned int cmd = NI_E_SERIAL_CMD_EEPROM_CS;
int bit;
int bitstring;
bitstring = 0x0300 | ((addr & 0x100) << 3) | (addr & 0xff);
- ni_writeb(dev, 0x04, Serial_Command);
+ ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG);
for (bit = 0x8000; bit; bit >>= 1) {
- ni_writeb(dev, 0x04 | ((bit & bitstring) ? 0x02 : 0),
- Serial_Command);
- ni_writeb(dev, 0x05 | ((bit & bitstring) ? 0x02 : 0),
- Serial_Command);
+ if (bit & bitstring)
+ cmd |= NI_E_SERIAL_CMD_SDATA;
+ else
+ cmd &= ~NI_E_SERIAL_CMD_SDATA;
+
+ ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG);
+ ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG);
}
+ cmd = NI_E_SERIAL_CMD_EEPROM_CS;
bitstring = 0;
for (bit = 0x80; bit; bit >>= 1) {
- ni_writeb(dev, 0x04, Serial_Command);
- ni_writeb(dev, 0x05, Serial_Command);
- bitstring |= ((ni_readb(dev, XXX_Status) & PROMOUT) ? bit : 0);
+ ni_writeb(dev, cmd, NI_E_SERIAL_CMD_REG);
+ ni_writeb(dev, NI_E_SERIAL_CMD_SCLK | cmd, NI_E_SERIAL_CMD_REG);
+ if (ni_readb(dev, NI_E_STATUS_REG) & NI_E_STATUS_PROMOUT)
+ bitstring |= bit;
}
- ni_writeb(dev, 0x00, Serial_Command);
+ ni_writeb(dev, 0, NI_E_SERIAL_CMD_REG);
return bitstring;
}
@@ -4537,7 +4352,7 @@ static unsigned ni_m_series_get_pfi_routing(struct comedi_device *dev,
struct ni_private *devpriv = dev->private;
const unsigned array_offset = chan / 3;
- return MSeries_PFI_Output_Select_Source(chan,
+ return NI_M_PFI_OUT_SEL_TO_SRC(chan,
devpriv->pfi_output_select_reg[array_offset]);
}
@@ -4545,19 +4360,17 @@ static int ni_m_series_set_pfi_routing(struct comedi_device *dev,
unsigned chan, unsigned source)
{
struct ni_private *devpriv = dev->private;
- unsigned pfi_reg_index;
- unsigned array_offset;
+ unsigned index = chan / 3;
+ unsigned short val = devpriv->pfi_output_select_reg[index];
if ((source & 0x1f) != source)
return -EINVAL;
- pfi_reg_index = 1 + chan / 3;
- array_offset = pfi_reg_index - 1;
- devpriv->pfi_output_select_reg[array_offset] &=
- ~MSeries_PFI_Output_Select_Mask(chan);
- devpriv->pfi_output_select_reg[array_offset] |=
- MSeries_PFI_Output_Select_Bits(chan, source);
- ni_writew(dev, devpriv->pfi_output_select_reg[array_offset],
- M_Offset_PFI_Output_Select(pfi_reg_index));
+
+ val &= ~NI_M_PFI_OUT_SEL_MASK(chan);
+ val |= NI_M_PFI_OUT_SEL(chan, source);
+ ni_writew(dev, val, NI_M_PFI_OUT_SEL_REG(index));
+ devpriv->pfi_output_select_reg[index] = val;
+
return 2;
}
@@ -4590,10 +4403,10 @@ static int ni_config_filter(struct comedi_device *dev,
if (!devpriv->is_m_series)
return -ENOTSUPP;
- bits = ni_readl(dev, M_Offset_PFI_Filter);
- bits &= ~MSeries_PFI_Filter_Select_Mask(pfi_channel);
- bits |= MSeries_PFI_Filter_Select_Bits(pfi_channel, filter);
- ni_writel(dev, bits, M_Offset_PFI_Filter);
+ bits = ni_readl(dev, NI_M_PFI_FILTER_REG);
+ bits &= ~NI_M_PFI_FILTER_SEL_MASK(pfi_channel);
+ bits |= NI_M_PFI_FILTER_SEL(pfi_channel, filter);
+ ni_writel(dev, bits, NI_M_PFI_FILTER_REG);
return 0;
}
@@ -4612,10 +4425,10 @@ static int ni_pfi_insn_config(struct comedi_device *dev,
switch (data[0]) {
case COMEDI_OUTPUT:
- ni_set_bits(dev, IO_Bidirection_Pin_Register, 1 << chan, 1);
+ ni_set_bits(dev, NISTC_IO_BIDIR_PIN_REG, 1 << chan, 1);
break;
case COMEDI_INPUT:
- ni_set_bits(dev, IO_Bidirection_Pin_Register, 1 << chan, 0);
+ ni_set_bits(dev, NISTC_IO_BIDIR_PIN_REG, 1 << chan, 0);
break;
case INSN_CONFIG_DIO_QUERY:
data[1] =
@@ -4646,9 +4459,9 @@ static int ni_pfi_insn_bits(struct comedi_device *dev,
return -ENOTSUPP;
if (comedi_dio_update_state(s, data))
- ni_writew(dev, s->state, M_Offset_PFI_DO);
+ ni_writew(dev, s->state, NI_M_PFI_DO_REG);
- data[1] = ni_readw(dev, M_Offset_PFI_DI);
+ data[1] = ni_readw(dev, NI_M_PFI_DI_REG);
return insn->n;
}
@@ -4660,8 +4473,8 @@ static int cs5529_wait_for_idle(struct comedi_device *dev)
int i;
for (i = 0; i < timeout; i++) {
- status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx);
- if ((status & CSS_ADC_BUSY) == 0)
+ status = ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG);
+ if ((status & NI67XX_CAL_STATUS_BUSY) == 0)
break;
set_current_state(TASK_INTERRUPTIBLE);
if (schedule_timeout(1))
@@ -4679,13 +4492,14 @@ static void cs5529_command(struct comedi_device *dev, unsigned short value)
static const int timeout = 100;
int i;
- ni_ao_win_outw(dev, value, CAL_ADC_Command_67xx);
+ ni_ao_win_outw(dev, value, NI67XX_CAL_CMD_REG);
/* give time for command to start being serially clocked into cs5529.
- * this insures that the CSS_ADC_BUSY bit will get properly
+ * this insures that the NI67XX_CAL_STATUS_BUSY bit will get properly
* set before we exit this function.
*/
for (i = 0; i < timeout; i++) {
- if ((ni_ao_win_inw(dev, CAL_ADC_Status_67xx) & CSS_ADC_BUSY))
+ if (ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG) &
+ NI67XX_CAL_STATUS_BUSY)
break;
udelay(1);
}
@@ -4700,25 +4514,25 @@ static int cs5529_do_conversion(struct comedi_device *dev,
int retval;
unsigned short status;
- cs5529_command(dev, CSCMD_COMMAND | CSCMD_SINGLE_CONVERSION);
+ cs5529_command(dev, CS5529_CMD_CB | CS5529_CMD_SINGLE_CONV);
retval = cs5529_wait_for_idle(dev);
if (retval) {
dev_err(dev->class_dev,
"timeout or signal in cs5529_do_conversion()\n");
return -ETIME;
}
- status = ni_ao_win_inw(dev, CAL_ADC_Status_67xx);
- if (status & CSS_OSC_DETECT) {
+ status = ni_ao_win_inw(dev, NI67XX_CAL_STATUS_REG);
+ if (status & NI67XX_CAL_STATUS_OSC_DETECT) {
dev_err(dev->class_dev,
"cs5529 conversion error, status CSS_OSC_DETECT\n");
return -EIO;
}
- if (status & CSS_OVERRANGE) {
+ if (status & NI67XX_CAL_STATUS_OVERRANGE) {
dev_err(dev->class_dev,
"cs5529 conversion error, overrange (ignoring)\n");
}
if (data) {
- *data = ni_ao_win_inw(dev, CAL_ADC_Data_67xx);
+ *data = ni_ao_win_inw(dev, NI67XX_CAL_DATA_REG);
/* cs5529 returns 16 bit signed data in bipolar mode */
*data ^= (1 << 15);
}
@@ -4742,7 +4556,7 @@ static int cs5529_ai_insn_read(struct comedi_device *dev,
channel_select = INTERNAL_REF;
else
channel_select = CR_CHAN(insn->chanspec);
- ni_ao_win_outw(dev, channel_select, AO_Calibration_Channel_Select_67xx);
+ ni_ao_win_outw(dev, channel_select, NI67XX_AO_CAL_CHAN_SEL_REG);
for (n = 0; n < insn->n; n++) {
retval = cs5529_do_conversion(dev, &sample);
@@ -4756,12 +4570,10 @@ static int cs5529_ai_insn_read(struct comedi_device *dev,
static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
unsigned int reg_select_bits)
{
- ni_ao_win_outw(dev, ((value >> 16) & 0xff),
- CAL_ADC_Config_Data_High_Word_67xx);
- ni_ao_win_outw(dev, (value & 0xffff),
- CAL_ADC_Config_Data_Low_Word_67xx);
- reg_select_bits &= CSCMD_REGISTER_SELECT_MASK;
- cs5529_command(dev, CSCMD_COMMAND | reg_select_bits);
+ ni_ao_win_outw(dev, (value >> 16) & 0xff, NI67XX_CAL_CFG_HI_REG);
+ ni_ao_win_outw(dev, value & 0xffff, NI67XX_CAL_CFG_LO_REG);
+ reg_select_bits &= CS5529_CMD_REG_MASK;
+ cs5529_command(dev, CS5529_CMD_CB | reg_select_bits);
if (cs5529_wait_for_idle(dev))
dev_err(dev->class_dev,
"timeout or signal in %s\n", __func__);
@@ -4769,20 +4581,20 @@ static void cs5529_config_write(struct comedi_device *dev, unsigned int value,
static int init_cs5529(struct comedi_device *dev)
{
- unsigned int config_bits =
- CSCFG_PORT_MODE | CSCFG_WORD_RATE_2180_CYCLES;
+ unsigned int config_bits = CS5529_CFG_PORT_FLAG |
+ CS5529_CFG_WORD_RATE_2180;
#if 1
/* do self-calibration */
- cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET_GAIN,
- CSCMD_CONFIG_REGISTER);
+ cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_BOTH_SELF,
+ CS5529_CFG_REG);
/* need to force a conversion for calibration to run */
cs5529_do_conversion(dev, NULL);
#else
/* force gain calibration to 1 */
- cs5529_config_write(dev, 0x400000, CSCMD_GAIN_REGISTER);
- cs5529_config_write(dev, config_bits | CSCFG_SELF_CAL_OFFSET,
- CSCMD_CONFIG_REGISTER);
+ cs5529_config_write(dev, 0x400000, CS5529_GAIN_REG);
+ cs5529_config_write(dev, config_bits | CS5529_CFG_CALIB_OFFSET_SELF,
+ CS5529_CFG_REG);
if (cs5529_wait_for_idle(dev))
dev_err(dev->class_dev,
"timeout or signal in %s\n", __func__);
@@ -4801,10 +4613,8 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns,
{
unsigned div;
unsigned best_div = 1;
- static const unsigned max_div = 0x10;
unsigned mult;
unsigned best_mult = 1;
- static const unsigned max_mult = 0x100;
static const unsigned pico_per_nano = 1000;
const unsigned reference_picosec = reference_period_ns * pico_per_nano;
@@ -4814,8 +4624,8 @@ static int ni_mseries_get_pll_parameters(unsigned reference_period_ns,
static const unsigned fudge_factor_80_to_20Mhz = 4;
int best_period_picosec = 0;
- for (div = 1; div <= max_div; ++div) {
- for (mult = 1; mult <= max_mult; ++mult) {
+ for (div = 1; div <= NI_M_PLL_MAX_DIVISOR; ++div) {
+ for (mult = 1; mult <= NI_M_PLL_MAX_MULTIPLIER; ++mult) {
unsigned new_period_ps =
(reference_picosec * div) / mult;
if (abs(new_period_ps - target_picosec) <
@@ -4847,6 +4657,7 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev,
unsigned pll_control_bits;
unsigned freq_divider;
unsigned freq_multiplier;
+ unsigned rtsi;
unsigned i;
int retval;
@@ -4859,42 +4670,31 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev,
__func__, min_period_ns, max_period_ns);
return -EINVAL;
}
- devpriv->rtsi_trig_direction_reg &= ~Use_RTSI_Clock_Bit;
+ devpriv->rtsi_trig_direction_reg &= ~NISTC_RTSI_TRIG_USE_CLK;
ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
- pll_control_bits =
- MSeries_PLL_Enable_Bit | MSeries_PLL_VCO_Mode_75_150MHz_Bits;
- devpriv->clock_and_fout2 |=
- MSeries_Timebase1_Select_Bit | MSeries_Timebase3_Select_Bit;
- devpriv->clock_and_fout2 &= ~MSeries_PLL_In_Source_Select_Mask;
+ NISTC_RTSI_TRIG_DIR_REG);
+ pll_control_bits = NI_M_PLL_CTRL_ENA | NI_M_PLL_CTRL_VCO_MODE_75_150MHZ;
+ devpriv->clock_and_fout2 |= NI_M_CLK_FOUT2_TIMEBASE1_PLL |
+ NI_M_CLK_FOUT2_TIMEBASE3_PLL;
+ devpriv->clock_and_fout2 &= ~NI_M_CLK_FOUT2_PLL_SRC_MASK;
switch (source) {
case NI_MIO_PLL_PXI_STAR_TRIGGER_CLOCK:
- devpriv->clock_and_fout2 |=
- MSeries_PLL_In_Source_Select_Star_Trigger_Bits;
+ devpriv->clock_and_fout2 |= NI_M_CLK_FOUT2_PLL_SRC_STAR;
break;
case NI_MIO_PLL_PXI10_CLOCK:
/* pxi clock is 10MHz */
- devpriv->clock_and_fout2 |=
- MSeries_PLL_In_Source_Select_PXI_Clock10;
+ devpriv->clock_and_fout2 |= NI_M_CLK_FOUT2_PLL_SRC_PXI10;
break;
default:
- {
- unsigned rtsi_channel;
- static const unsigned max_rtsi_channel = 7;
-
- for (rtsi_channel = 0; rtsi_channel <= max_rtsi_channel;
- ++rtsi_channel) {
- if (source ==
- NI_MIO_PLL_RTSI_CLOCK(rtsi_channel)) {
- devpriv->clock_and_fout2 |=
- MSeries_PLL_In_Source_Select_RTSI_Bits
- (rtsi_channel);
- break;
- }
+ for (rtsi = 0; rtsi <= NI_M_MAX_RTSI_CHAN; ++rtsi) {
+ if (source == NI_MIO_PLL_RTSI_CLOCK(rtsi)) {
+ devpriv->clock_and_fout2 |=
+ NI_M_CLK_FOUT2_PLL_SRC_RTSI(rtsi);
+ break;
}
- if (rtsi_channel > max_rtsi_channel)
- return -EINVAL;
}
+ if (rtsi > NI_M_MAX_RTSI_CHAN)
+ return -EINVAL;
break;
}
retval = ni_mseries_get_pll_parameters(period_ns,
@@ -4907,16 +4707,15 @@ static int ni_mseries_set_pll_master_clock(struct comedi_device *dev,
return retval;
}
- ni_writew(dev, devpriv->clock_and_fout2, M_Offset_Clock_and_Fout2);
- pll_control_bits |=
- MSeries_PLL_Divisor_Bits(freq_divider) |
- MSeries_PLL_Multiplier_Bits(freq_multiplier);
+ ni_writew(dev, devpriv->clock_and_fout2, NI_M_CLK_FOUT2_REG);
+ pll_control_bits |= NI_M_PLL_CTRL_DIVISOR(freq_divider) |
+ NI_M_PLL_CTRL_MULTIPLIER(freq_multiplier);
- ni_writew(dev, pll_control_bits, M_Offset_PLL_Control);
+ ni_writew(dev, pll_control_bits, NI_M_PLL_CTRL_REG);
devpriv->clock_source = source;
/* it seems to typically take a few hundred microseconds for PLL to lock */
for (i = 0; i < timeout; ++i) {
- if (ni_readw(dev, M_Offset_PLL_Status) & MSeries_PLL_Locked_Bit)
+ if (ni_readw(dev, NI_M_PLL_STATUS_REG) & NI_M_PLL_STATUS_LOCKED)
break;
udelay(1);
}
@@ -4935,17 +4734,17 @@ static int ni_set_master_clock(struct comedi_device *dev,
struct ni_private *devpriv = dev->private;
if (source == NI_MIO_INTERNAL_CLOCK) {
- devpriv->rtsi_trig_direction_reg &= ~Use_RTSI_Clock_Bit;
+ devpriv->rtsi_trig_direction_reg &= ~NISTC_RTSI_TRIG_USE_CLK;
ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ NISTC_RTSI_TRIG_DIR_REG);
devpriv->clock_ns = TIMEBASE_1_NS;
if (devpriv->is_m_series) {
devpriv->clock_and_fout2 &=
- ~(MSeries_Timebase1_Select_Bit |
- MSeries_Timebase3_Select_Bit);
+ ~(NI_M_CLK_FOUT2_TIMEBASE1_PLL |
+ NI_M_CLK_FOUT2_TIMEBASE3_PLL);
ni_writew(dev, devpriv->clock_and_fout2,
- M_Offset_Clock_and_Fout2);
- ni_writew(dev, 0, M_Offset_PLL_Control);
+ NI_M_CLK_FOUT2_REG);
+ ni_writew(dev, 0, NI_M_PLL_CTRL_REG);
}
devpriv->clock_source = source;
} else {
@@ -4955,10 +4754,10 @@ static int ni_set_master_clock(struct comedi_device *dev,
} else {
if (source == NI_MIO_RTSI_CLOCK) {
devpriv->rtsi_trig_direction_reg |=
- Use_RTSI_Clock_Bit;
+ NISTC_RTSI_TRIG_USE_CLK;
ni_stc_writew(dev,
devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ NISTC_RTSI_TRIG_DIR_REG);
if (period_ns == 0) {
dev_err(dev->class_dev,
"we don't handle an unspecified clock period correctly yet, returning error\n");
@@ -4974,26 +4773,19 @@ static int ni_set_master_clock(struct comedi_device *dev,
return 3;
}
-static unsigned num_configurable_rtsi_channels(struct comedi_device *dev)
-{
- struct ni_private *devpriv = dev->private;
-
- return (devpriv->is_m_series) ? 8 : 7;
-}
-
static int ni_valid_rtsi_output_source(struct comedi_device *dev,
unsigned chan, unsigned source)
{
struct ni_private *devpriv = dev->private;
- if (chan >= num_configurable_rtsi_channels(dev)) {
- if (chan == old_RTSI_clock_channel) {
+ if (chan >= NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) {
+ if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) {
if (source == NI_RTSI_OUTPUT_RTSI_OSC)
return 1;
dev_err(dev->class_dev,
"%s: invalid source for channel=%i, channel %i is always the RTSI clock for pre-m-series boards\n",
- __func__, chan, old_RTSI_clock_channel);
+ __func__, chan, NISTC_RTSI_TRIG_OLD_CLK_CHAN);
return 0;
}
return 0;
@@ -5017,24 +4809,22 @@ static int ni_valid_rtsi_output_source(struct comedi_device *dev,
}
static int ni_set_rtsi_routing(struct comedi_device *dev,
- unsigned chan, unsigned source)
+ unsigned chan, unsigned src)
{
struct ni_private *devpriv = dev->private;
- if (ni_valid_rtsi_output_source(dev, chan, source) == 0)
+ if (ni_valid_rtsi_output_source(dev, chan, src) == 0)
return -EINVAL;
if (chan < 4) {
- devpriv->rtsi_trig_a_output_reg &= ~RTSI_Trig_Output_Mask(chan);
- devpriv->rtsi_trig_a_output_reg |=
- RTSI_Trig_Output_Bits(chan, source);
+ devpriv->rtsi_trig_a_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan);
+ devpriv->rtsi_trig_a_output_reg |= NISTC_RTSI_TRIG(chan, src);
ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg,
- RTSI_Trig_A_Output_Register);
+ NISTC_RTSI_TRIGA_OUT_REG);
} else if (chan < 8) {
- devpriv->rtsi_trig_b_output_reg &= ~RTSI_Trig_Output_Mask(chan);
- devpriv->rtsi_trig_b_output_reg |=
- RTSI_Trig_Output_Bits(chan, source);
+ devpriv->rtsi_trig_b_output_reg &= ~NISTC_RTSI_TRIG_MASK(chan);
+ devpriv->rtsi_trig_b_output_reg |= NISTC_RTSI_TRIG(chan, src);
ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
- RTSI_Trig_B_Output_Register);
+ NISTC_RTSI_TRIGB_OUT_REG);
}
return 2;
}
@@ -5044,13 +4834,13 @@ static unsigned ni_get_rtsi_routing(struct comedi_device *dev, unsigned chan)
struct ni_private *devpriv = dev->private;
if (chan < 4) {
- return RTSI_Trig_Output_Source(chan,
- devpriv->rtsi_trig_a_output_reg);
- } else if (chan < num_configurable_rtsi_channels(dev)) {
- return RTSI_Trig_Output_Source(chan,
- devpriv->rtsi_trig_b_output_reg);
+ return NISTC_RTSI_TRIG_TO_SRC(chan,
+ devpriv->rtsi_trig_a_output_reg);
+ } else if (chan < NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series)) {
+ return NISTC_RTSI_TRIG_TO_SRC(chan,
+ devpriv->rtsi_trig_b_output_reg);
} else {
- if (chan == old_RTSI_clock_channel)
+ if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN)
return NI_RTSI_OUTPUT_RTSI_OSC;
dev_err(dev->class_dev, "bug! should never get here?\n");
return 0;
@@ -5064,42 +4854,43 @@ static int ni_rtsi_insn_config(struct comedi_device *dev,
{
struct ni_private *devpriv = dev->private;
unsigned int chan = CR_CHAN(insn->chanspec);
+ unsigned int max_chan = NISTC_RTSI_TRIG_NUM_CHAN(devpriv->is_m_series);
switch (data[0]) {
case INSN_CONFIG_DIO_OUTPUT:
- if (chan < num_configurable_rtsi_channels(dev)) {
+ if (chan < max_chan) {
devpriv->rtsi_trig_direction_reg |=
- RTSI_Output_Bit(chan, devpriv->is_m_series);
- } else if (chan == old_RTSI_clock_channel) {
+ NISTC_RTSI_TRIG_DIR(chan, devpriv->is_m_series);
+ } else if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) {
devpriv->rtsi_trig_direction_reg |=
- Drive_RTSI_Clock_Bit;
+ NISTC_RTSI_TRIG_DRV_CLK;
}
ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ NISTC_RTSI_TRIG_DIR_REG);
break;
case INSN_CONFIG_DIO_INPUT:
- if (chan < num_configurable_rtsi_channels(dev)) {
+ if (chan < max_chan) {
devpriv->rtsi_trig_direction_reg &=
- ~RTSI_Output_Bit(chan, devpriv->is_m_series);
- } else if (chan == old_RTSI_clock_channel) {
+ ~NISTC_RTSI_TRIG_DIR(chan, devpriv->is_m_series);
+ } else if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) {
devpriv->rtsi_trig_direction_reg &=
- ~Drive_RTSI_Clock_Bit;
+ ~NISTC_RTSI_TRIG_DRV_CLK;
}
ni_stc_writew(dev, devpriv->rtsi_trig_direction_reg,
- RTSI_Trig_Direction_Register);
+ NISTC_RTSI_TRIG_DIR_REG);
break;
case INSN_CONFIG_DIO_QUERY:
- if (chan < num_configurable_rtsi_channels(dev)) {
+ if (chan < max_chan) {
data[1] =
(devpriv->rtsi_trig_direction_reg &
- RTSI_Output_Bit(chan, devpriv->is_m_series))
+ NISTC_RTSI_TRIG_DIR(chan, devpriv->is_m_series))
? INSN_CONFIG_DIO_OUTPUT
: INSN_CONFIG_DIO_INPUT;
- } else if (chan == old_RTSI_clock_channel) {
- data[1] =
- (devpriv->rtsi_trig_direction_reg &
- Drive_RTSI_Clock_Bit)
- ? INSN_CONFIG_DIO_OUTPUT : INSN_CONFIG_DIO_INPUT;
+ } else if (chan == NISTC_RTSI_TRIG_OLD_CLK_CHAN) {
+ data[1] = (devpriv->rtsi_trig_direction_reg &
+ NISTC_RTSI_TRIG_DRV_CLK)
+ ? INSN_CONFIG_DIO_OUTPUT
+ : INSN_CONFIG_DIO_INPUT;
}
return 2;
case INSN_CONFIG_SET_CLOCK_SRC:
@@ -5135,37 +4926,37 @@ static void ni_rtsi_init(struct comedi_device *dev)
/* Initialises the RTSI bus signal switch to a default state */
+ /*
+ * Use 10MHz instead of 20MHz for RTSI clock frequency. Appears
+ * to have no effect, at least on pxi-6281, which always uses
+ * 20MHz rtsi clock frequency
+ */
+ devpriv->clock_and_fout2 = NI_M_CLK_FOUT2_RTSI_10MHZ;
/* Set clock mode to internal */
- devpriv->clock_and_fout2 = MSeries_RTSI_10MHz_Bit;
if (ni_set_master_clock(dev, NI_MIO_INTERNAL_CLOCK, 0) < 0)
dev_err(dev->class_dev, "ni_set_master_clock failed, bug?\n");
/* default internal lines routing to RTSI bus lines */
devpriv->rtsi_trig_a_output_reg =
- RTSI_Trig_Output_Bits(0,
- NI_RTSI_OUTPUT_ADR_START1) |
- RTSI_Trig_Output_Bits(1,
- NI_RTSI_OUTPUT_ADR_START2) |
- RTSI_Trig_Output_Bits(2,
- NI_RTSI_OUTPUT_SCLKG) |
- RTSI_Trig_Output_Bits(3, NI_RTSI_OUTPUT_DACUPDN);
+ NISTC_RTSI_TRIG(0, NI_RTSI_OUTPUT_ADR_START1) |
+ NISTC_RTSI_TRIG(1, NI_RTSI_OUTPUT_ADR_START2) |
+ NISTC_RTSI_TRIG(2, NI_RTSI_OUTPUT_SCLKG) |
+ NISTC_RTSI_TRIG(3, NI_RTSI_OUTPUT_DACUPDN);
ni_stc_writew(dev, devpriv->rtsi_trig_a_output_reg,
- RTSI_Trig_A_Output_Register);
+ NISTC_RTSI_TRIGA_OUT_REG);
devpriv->rtsi_trig_b_output_reg =
- RTSI_Trig_Output_Bits(4,
- NI_RTSI_OUTPUT_DA_START1) |
- RTSI_Trig_Output_Bits(5,
- NI_RTSI_OUTPUT_G_SRC0) |
- RTSI_Trig_Output_Bits(6, NI_RTSI_OUTPUT_G_GATE0);
+ NISTC_RTSI_TRIG(4, NI_RTSI_OUTPUT_DA_START1) |
+ NISTC_RTSI_TRIG(5, NI_RTSI_OUTPUT_G_SRC0) |
+ NISTC_RTSI_TRIG(6, NI_RTSI_OUTPUT_G_GATE0);
if (devpriv->is_m_series)
devpriv->rtsi_trig_b_output_reg |=
- RTSI_Trig_Output_Bits(7, NI_RTSI_OUTPUT_RTSI_OSC);
+ NISTC_RTSI_TRIG(7, NI_RTSI_OUTPUT_RTSI_OSC);
ni_stc_writew(dev, devpriv->rtsi_trig_b_output_reg,
- RTSI_Trig_B_Output_Register);
+ NISTC_RTSI_TRIGB_OUT_REG);
-/*
-* Sets the source and direction of the 4 on board lines
-* ni_stc_writew(dev, 0x0000, RTSI_Board_Register);
-*/
+ /*
+ * Sets the source and direction of the 4 on board lines
+ * ni_stc_writew(dev, 0, NISTC_RTSI_BOARD_REG);
+ */
}
#ifdef PCIDMA
@@ -5199,88 +4990,6 @@ static int ni_gpct_cancel(struct comedi_device *dev, struct comedi_subdevice *s)
}
#endif
-#if 0
-/*
- * Read the GPCTs current value.
- */
-static int GPCT_G_Watch(struct comedi_device *dev, int chan)
-{
- unsigned int hi1, hi2, lo;
-
- devpriv->gpct_command[chan] &= ~G_Save_Trace;
- ni_stc_writew(dev, devpriv->gpct_command[chan],
- G_Command_Register(chan));
-
- devpriv->gpct_command[chan] |= G_Save_Trace;
- ni_stc_writew(dev, devpriv->gpct_command[chan],
- G_Command_Register(chan));
-
- /* This procedure is used because the two registers cannot
- * be read atomically. */
- do {
- hi1 = ni_stc_readw(dev, G_Save_Register_High(chan));
- lo = ni_stc_readw(dev, G_Save_Register_Low(chan));
- hi2 = ni_stc_readw(dev, G_Save_Register_High(chan));
- } while (hi1 != hi2);
-
- return (hi1 << 16) | lo;
-}
-
-static void GPCT_Reset(struct comedi_device *dev, int chan)
-{
- int temp_ack_reg = 0;
-
- devpriv->gpct_cur_operation[chan] = GPCT_RESET;
-
- switch (chan) {
- case 0:
- ni_stc_writew(dev, G0_Reset, Joint_Reset_Register);
- ni_set_bits(dev, Interrupt_A_Enable_Register,
- G0_TC_Interrupt_Enable, 0);
- ni_set_bits(dev, Interrupt_A_Enable_Register,
- G0_Gate_Interrupt_Enable, 0);
- temp_ack_reg |= G0_Gate_Error_Confirm;
- temp_ack_reg |= G0_TC_Error_Confirm;
- temp_ack_reg |= G0_TC_Interrupt_Ack;
- temp_ack_reg |= G0_Gate_Interrupt_Ack;
- ni_stc_writew(dev, temp_ack_reg, Interrupt_A_Ack_Register);
-
- /* problem...this interferes with the other ctr... */
- devpriv->an_trig_etc_reg |= GPFO_0_Output_Enable;
- ni_stc_writew(dev, devpriv->an_trig_etc_reg,
- Analog_Trigger_Etc_Register);
- break;
- case 1:
- ni_stc_writew(dev, G1_Reset, Joint_Reset_Register);
- ni_set_bits(dev, Interrupt_B_Enable_Register,
- G1_TC_Interrupt_Enable, 0);
- ni_set_bits(dev, Interrupt_B_Enable_Register,
- G0_Gate_Interrupt_Enable, 0);
- temp_ack_reg |= G1_Gate_Error_Confirm;
- temp_ack_reg |= G1_TC_Error_Confirm;
- temp_ack_reg |= G1_TC_Interrupt_Ack;
- temp_ack_reg |= G1_Gate_Interrupt_Ack;
- ni_stc_writew(dev, temp_ack_reg, Interrupt_B_Ack_Register);
-
- devpriv->an_trig_etc_reg |= GPFO_1_Output_Enable;
- ni_stc_writew(dev, devpriv->an_trig_etc_reg,
- Analog_Trigger_Etc_Register);
- break;
- }
-
- devpriv->gpct_mode[chan] = 0;
- devpriv->gpct_input_select[chan] = 0;
- devpriv->gpct_command[chan] = 0;
-
- devpriv->gpct_command[chan] |= G_Synchronized_Gate;
-
- ni_stc_writew(dev, devpriv->gpct_mode[chan], G_Mode_Register(chan));
- ni_stc_writew(dev, devpriv->gpct_input_select[chan],
- G_Input_Select_Register(chan));
- ni_stc_writew(dev, 0, G_Autoincrement_Register(chan));
-}
-#endif
-
static irqreturn_t ni_E_interrupt(int irq, void *d)
{
struct comedi_device *dev = d;
@@ -5300,8 +5009,8 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
/* lock to avoid race with comedi_poll */
spin_lock_irqsave(&dev->spinlock, flags);
- a_status = ni_stc_readw(dev, AI_Status_1_Register);
- b_status = ni_stc_readw(dev, AO_Status_1_Register);
+ a_status = ni_stc_readw(dev, NISTC_AI_STATUS1_REG);
+ b_status = ni_stc_readw(dev, NISTC_AO_STATUS1_REG);
#ifdef PCIDMA
if (mite) {
struct ni_private *devpriv = dev->private;
@@ -5329,9 +5038,9 @@ static irqreturn_t ni_E_interrupt(int irq, void *d)
#endif
ack_a_interrupt(dev, a_status);
ack_b_interrupt(dev, b_status);
- if ((a_status & Interrupt_A_St) || (ai_mite_status & CHSR_INT))
+ if ((a_status & NISTC_AI_STATUS1_INTA) || (ai_mite_status & CHSR_INT))
handle_a_interrupt(dev, a_status, ai_mite_status);
- if ((b_status & Interrupt_B_St) || (ao_mite_status & CHSR_INT))
+ if ((b_status & NISTC_AO_STATUS1_INTB) || (ao_mite_status & CHSR_INT))
handle_b_interrupt(dev, b_status, ao_mite_status);
handle_gpct_interrupt(dev, 0);
handle_gpct_interrupt(dev, 1);
@@ -5371,16 +5080,16 @@ static int ni_E_init(struct comedi_device *dev,
}
/* initialize clock dividers */
- devpriv->clock_and_fout = Slow_Internal_Time_Divide_By_2 |
- Slow_Internal_Timebase |
- Clock_To_Board_Divide_By_2 |
- Clock_To_Board;
+ devpriv->clock_and_fout = NISTC_CLK_FOUT_SLOW_DIV2 |
+ NISTC_CLK_FOUT_SLOW_TIMEBASE |
+ NISTC_CLK_FOUT_TO_BOARD_DIV2 |
+ NISTC_CLK_FOUT_TO_BOARD;
if (!devpriv->is_6xxx) {
/* BEAM is this needed for PCI-6143 ?? */
- devpriv->clock_and_fout |= (AI_Output_Divide_By_2 |
- AO_Output_Divide_By_2);
+ devpriv->clock_and_fout |= (NISTC_CLK_FOUT_AI_OUT_DIV2 |
+ NISTC_CLK_FOUT_AO_OUT_DIV2);
}
- ni_stc_writew(dev, devpriv->clock_and_fout, Clock_and_FOUT_Register);
+ ni_stc_writew(dev, devpriv->clock_and_fout, NISTC_CLK_FOUT_REG);
ret = comedi_alloc_subdevices(dev, NI_NUM_SUBDEVICES);
if (ret)
@@ -5489,22 +5198,24 @@ static int ni_E_init(struct comedi_device *dev,
}
/* reset DIO and set all channels to inputs */
- ni_writel(dev, CDO_Reset_Bit | CDI_Reset_Bit,
- M_Offset_CDIO_Command);
- ni_writel(dev, s->io_bits, M_Offset_DIO_Direction);
+ ni_writel(dev, NI_M_CDO_CMD_RESET |
+ NI_M_CDI_CMD_RESET,
+ NI_M_CDIO_CMD_REG);
+ ni_writel(dev, s->io_bits, NI_M_DIO_DIR_REG);
} else {
s->insn_bits = ni_dio_insn_bits;
s->insn_config = ni_dio_insn_config;
/* set all channels to inputs */
- devpriv->dio_control = DIO_Pins_Dir(s->io_bits);
- ni_writew(dev, devpriv->dio_control, DIO_Control_Register);
+ devpriv->dio_control = NISTC_DIO_CTRL_DIR(s->io_bits);
+ ni_writew(dev, devpriv->dio_control, NISTC_DIO_CTRL_REG);
}
/* 8255 device */
s = &dev->subdevices[NI_8255_DIO_SUBDEV];
if (board->has_8255) {
- ret = subdev_8255_init(dev, s, ni_8255_callback, Port_A);
+ ret = subdev_8255_init(dev, s, ni_8255_callback,
+ NI_E_8255_BASE);
if (ret)
return ret;
} else {
@@ -5525,7 +5236,7 @@ static int ni_E_init(struct comedi_device *dev,
/* internal PWM output used for AI nonlinearity calibration */
s->insn_config = ni_m_series_pwm_config;
- ni_writel(dev, 0x0, M_Offset_Cal_PWM);
+ ni_writel(dev, 0x0, NI_M_CAL_PWM_REG);
} else if (devpriv->is_6143) {
/* internal PWM output used for AI nonlinearity calibration */
s->insn_config = ni_6143_pwm_config;
@@ -5560,17 +5271,17 @@ static int ni_E_init(struct comedi_device *dev,
s->n_chan = 16;
s->insn_bits = ni_pfi_insn_bits;
- ni_writew(dev, s->state, M_Offset_PFI_DO);
+ ni_writew(dev, s->state, NI_M_PFI_DO_REG);
for (i = 0; i < NUM_PFI_OUTPUT_SELECT_REGS; ++i) {
ni_writew(dev, devpriv->pfi_output_select_reg[i],
- M_Offset_PFI_Output_Select(i + 1));
+ NI_M_PFI_OUT_SEL_REG(i));
}
} else {
s->n_chan = 10;
}
s->insn_config = ni_pfi_insn_config;
- ni_set_bits(dev, IO_Bidirection_Pin_Register, ~0, 0);
+ ni_set_bits(dev, NISTC_IO_BIDIR_PIN_REG, ~0, 0);
/* cs5529 calibration adc */
s = &dev->subdevices[NI_CS5529_CALIBRATION_SUBDEV];
@@ -5663,30 +5374,31 @@ static int ni_E_init(struct comedi_device *dev,
if (dev->irq) {
ni_stc_writew(dev,
- (irq_polarity ? Interrupt_Output_Polarity : 0) |
- (Interrupt_Output_On_3_Pins & 0) |
- Interrupt_A_Enable | Interrupt_B_Enable |
- Interrupt_A_Output_Select(interrupt_pin) |
- Interrupt_B_Output_Select(interrupt_pin),
- Interrupt_Control_Register);
+ (irq_polarity ? NISTC_INT_CTRL_INT_POL : 0) |
+ (NISTC_INT_CTRL_3PIN_INT & 0) |
+ NISTC_INT_CTRL_INTA_ENA |
+ NISTC_INT_CTRL_INTB_ENA |
+ NISTC_INT_CTRL_INTA_SEL(interrupt_pin) |
+ NISTC_INT_CTRL_INTB_SEL(interrupt_pin),
+ NISTC_INT_CTRL_REG);
}
/* DMA setup */
- ni_writeb(dev, devpriv->ai_ao_select_reg, AI_AO_Select);
- ni_writeb(dev, devpriv->g0_g1_select_reg, G0_G1_Select);
+ ni_writeb(dev, devpriv->ai_ao_select_reg, NI_E_DMA_AI_AO_SEL_REG);
+ ni_writeb(dev, devpriv->g0_g1_select_reg, NI_E_DMA_G0_G1_SEL_REG);
if (devpriv->is_6xxx) {
- ni_writeb(dev, 0, Magic_611x);
+ ni_writeb(dev, 0, NI611X_MAGIC_REG);
} else if (devpriv->is_m_series) {
int channel;
for (channel = 0; channel < board->n_aochan; ++channel) {
ni_writeb(dev, 0xf,
- M_Offset_AO_Waveform_Order(channel));
+ NI_M_AO_WAVEFORM_ORDER_REG(channel));
ni_writeb(dev, 0x0,
- M_Offset_AO_Reference_Attenuation(channel));
+ NI_M_AO_REF_ATTENUATION_REG(channel));
}
- ni_writeb(dev, 0x0, M_Offset_AO_Calibration);
+ ni_writeb(dev, 0x0, NI_M_AO_CALIB_REG);
}
return 0;
diff --git a/drivers/staging/comedi/drivers/ni_pcimio.c b/drivers/staging/comedi/drivers/ni_pcimio.c
index 1481f71a31b1b3..30a5a75d1fe7b5 100644
--- a/drivers/staging/comedi/drivers/ni_pcimio.c
+++ b/drivers/staging/comedi/drivers/ni_pcimio.c
@@ -1085,26 +1085,25 @@ static void init_6143(struct comedi_device *dev)
struct ni_private *devpriv = dev->private;
/* Disable interrupts */
- ni_stc_writew(dev, 0, Interrupt_Control_Register);
+ ni_stc_writew(dev, 0, NISTC_INT_CTRL_REG);
/* Initialise 6143 AI specific bits */
/* Set G0,G1 DMA mode to E series version */
- ni_writeb(dev, 0x00, Magic_6143);
+ ni_writeb(dev, 0x00, NI6143_MAGIC_REG);
/* Set EOCMode, ADCMode and pipelinedelay */
- ni_writeb(dev, 0x80, PipelineDelay_6143);
+ ni_writeb(dev, 0x80, NI6143_PIPELINE_DELAY_REG);
/* Set EOC Delay */
- ni_writeb(dev, 0x00, EOC_Set_6143);
+ ni_writeb(dev, 0x00, NI6143_EOC_SET_REG);
/* Set the FIFO half full level */
- ni_writel(dev, board->ai_fifo_depth / 2, AIFIFO_Flag_6143);
+ ni_writel(dev, board->ai_fifo_depth / 2, NI6143_AI_FIFO_FLAG_REG);
/* Strobe Relay disable bit */
devpriv->ai_calib_source_enabled = 0;
- ni_writew(dev, devpriv->ai_calib_source |
- Calibration_Channel_6143_RelayOff,
- Calibration_Channel_6143);
- ni_writew(dev, devpriv->ai_calib_source, Calibration_Channel_6143);
+ ni_writew(dev, devpriv->ai_calib_source | NI6143_CALIB_CHAN_RELAY_OFF,
+ NI6143_CALIB_CHAN_REG);
+ ni_writew(dev, devpriv->ai_calib_source, NI6143_CALIB_CHAN_REG);
}
static void pcimio_detach(struct comedi_device *dev)
diff --git a/drivers/staging/comedi/drivers/ni_stc.h b/drivers/staging/comedi/drivers/ni_stc.h
index bd69c3f0acdc82..1d5af25b92a879 100644
--- a/drivers/staging/comedi/drivers/ni_stc.h
+++ b/drivers/staging/comedi/drivers/ni_stc.h
@@ -26,884 +26,907 @@
#include "ni_tio.h"
-#define _bit15 0x8000
-#define _bit14 0x4000
-#define _bit13 0x2000
-#define _bit12 0x1000
-#define _bit11 0x0800
-#define _bit10 0x0400
-#define _bit9 0x0200
-#define _bit8 0x0100
-#define _bit7 0x0080
-#define _bit6 0x0040
-#define _bit5 0x0020
-#define _bit4 0x0010
-#define _bit3 0x0008
-#define _bit2 0x0004
-#define _bit1 0x0002
-#define _bit0 0x0001
-
-#define NUM_PFI_OUTPUT_SELECT_REGS 6
-
-/* Registers in the National Instruments DAQ-STC chip */
-
-#define Interrupt_A_Ack_Register 2
-#define G0_Gate_Interrupt_Ack _bit15
-#define G0_TC_Interrupt_Ack _bit14
-#define AI_Error_Interrupt_Ack _bit13
-#define AI_STOP_Interrupt_Ack _bit12
-#define AI_START_Interrupt_Ack _bit11
-#define AI_START2_Interrupt_Ack _bit10
-#define AI_START1_Interrupt_Ack _bit9
-#define AI_SC_TC_Interrupt_Ack _bit8
-#define AI_SC_TC_Error_Confirm _bit7
-#define G0_TC_Error_Confirm _bit6
-#define G0_Gate_Error_Confirm _bit5
-
-#define AI_Status_1_Register 2
-#define Interrupt_A_St 0x8000
-#define AI_FIFO_Full_St 0x4000
-#define AI_FIFO_Half_Full_St 0x2000
-#define AI_FIFO_Empty_St 0x1000
-#define AI_Overrun_St 0x0800
-#define AI_Overflow_St 0x0400
-#define AI_SC_TC_Error_St 0x0200
-#define AI_START2_St 0x0100
-#define AI_START1_St 0x0080
-#define AI_SC_TC_St 0x0040
-#define AI_START_St 0x0020
-#define AI_STOP_St 0x0010
-#define G0_TC_St 0x0008
-#define G0_Gate_Interrupt_St 0x0004
-#define AI_FIFO_Request_St 0x0002
-#define Pass_Thru_0_Interrupt_St 0x0001
-
-#define AI_Status_2_Register 5
-
-#define Interrupt_B_Ack_Register 3
-enum Interrupt_B_Ack_Bits {
- G1_Gate_Error_Confirm = _bit1,
- G1_TC_Error_Confirm = _bit2,
- AO_BC_TC_Trigger_Error_Confirm = _bit3,
- AO_BC_TC_Error_Confirm = _bit4,
- AO_UI2_TC_Error_Confrim = _bit5,
- AO_UI2_TC_Interrupt_Ack = _bit6,
- AO_UC_TC_Interrupt_Ack = _bit7,
- AO_BC_TC_Interrupt_Ack = _bit8,
- AO_START1_Interrupt_Ack = _bit9,
- AO_UPDATE_Interrupt_Ack = _bit10,
- AO_START_Interrupt_Ack = _bit11,
- AO_STOP_Interrupt_Ack = _bit12,
- AO_Error_Interrupt_Ack = _bit13,
- G1_TC_Interrupt_Ack = _bit14,
- G1_Gate_Interrupt_Ack = _bit15
-};
-
-#define AO_Status_1_Register 3
-#define Interrupt_B_St _bit15
-#define AO_FIFO_Full_St _bit14
-#define AO_FIFO_Half_Full_St _bit13
-#define AO_FIFO_Empty_St _bit12
-#define AO_BC_TC_Error_St _bit11
-#define AO_START_St _bit10
-#define AO_Overrun_St _bit9
-#define AO_START1_St _bit8
-#define AO_BC_TC_St _bit7
-#define AO_UC_TC_St _bit6
-#define AO_UPDATE_St _bit5
-#define AO_UI2_TC_St _bit4
-#define G1_TC_St _bit3
-#define G1_Gate_Interrupt_St _bit2
-#define AO_FIFO_Request_St _bit1
-#define Pass_Thru_1_Interrupt_St _bit0
-
-#define AI_Command_2_Register 4
-#define AI_End_On_SC_TC _bit15
-#define AI_End_On_End_Of_Scan _bit14
-#define AI_START1_Disable _bit11
-#define AI_SC_Save_Trace _bit10
-#define AI_SI_Switch_Load_On_SC_TC _bit9
-#define AI_SI_Switch_Load_On_STOP _bit8
-#define AI_SI_Switch_Load_On_TC _bit7
-#define AI_SC_Switch_Load_On_TC _bit4
-#define AI_STOP_Pulse _bit3
-#define AI_START_Pulse _bit2
-#define AI_START2_Pulse _bit1
-#define AI_START1_Pulse _bit0
-
-#define AO_Command_2_Register 5
-#define AO_End_On_BC_TC(x) (((x) & 0x3) << 14)
-#define AO_Start_Stop_Gate_Enable _bit13
-#define AO_UC_Save_Trace _bit12
-#define AO_BC_Gate_Enable _bit11
-#define AO_BC_Save_Trace _bit10
-#define AO_UI_Switch_Load_On_BC_TC _bit9
-#define AO_UI_Switch_Load_On_Stop _bit8
-#define AO_UI_Switch_Load_On_TC _bit7
-#define AO_UC_Switch_Load_On_BC_TC _bit6
-#define AO_UC_Switch_Load_On_TC _bit5
-#define AO_BC_Switch_Load_On_TC _bit4
-#define AO_Mute_B _bit3
-#define AO_Mute_A _bit2
-#define AO_UPDATE2_Pulse _bit1
-#define AO_START1_Pulse _bit0
-
-#define AO_Status_2_Register 6
-
-#define DIO_Parallel_Input_Register 7
-
-#define AI_Command_1_Register 8
-#define AI_Analog_Trigger_Reset _bit14
-#define AI_Disarm _bit13
-#define AI_SI2_Arm _bit12
-#define AI_SI2_Load _bit11
-#define AI_SI_Arm _bit10
-#define AI_SI_Load _bit9
-#define AI_DIV_Arm _bit8
-#define AI_DIV_Load _bit7
-#define AI_SC_Arm _bit6
-#define AI_SC_Load _bit5
-#define AI_SCAN_IN_PROG_Pulse _bit4
-#define AI_EXTMUX_CLK_Pulse _bit3
-#define AI_LOCALMUX_CLK_Pulse _bit2
-#define AI_SC_TC_Pulse _bit1
-#define AI_CONVERT_Pulse _bit0
-
-#define AO_Command_1_Register 9
-#define AO_Analog_Trigger_Reset _bit15
-#define AO_START_Pulse _bit14
-#define AO_Disarm _bit13
-#define AO_UI2_Arm_Disarm _bit12
-#define AO_UI2_Load _bit11
-#define AO_UI_Arm _bit10
-#define AO_UI_Load _bit9
-#define AO_UC_Arm _bit8
-#define AO_UC_Load _bit7
-#define AO_BC_Arm _bit6
-#define AO_BC_Load _bit5
-#define AO_DAC1_Update_Mode _bit4
-#define AO_LDAC1_Source_Select _bit3
-#define AO_DAC0_Update_Mode _bit2
-#define AO_LDAC0_Source_Select _bit1
-#define AO_UPDATE_Pulse _bit0
-
-#define DIO_Output_Register 10
-#define DIO_Parallel_Data_Out(a) ((a)&0xff)
-#define DIO_Parallel_Data_Mask 0xff
-#define DIO_SDOUT _bit0
-#define DIO_SDIN _bit4
-#define DIO_Serial_Data_Out(a) (((a)&0xff)<<8)
-#define DIO_Serial_Data_Mask 0xff00
-
-#define DIO_Control_Register 11
-#define DIO_Software_Serial_Control _bit11
-#define DIO_HW_Serial_Timebase _bit10
-#define DIO_HW_Serial_Enable _bit9
-#define DIO_HW_Serial_Start _bit8
-#define DIO_Pins_Dir(a) ((a)&0xff)
-#define DIO_Pins_Dir_Mask 0xff
-
-#define AI_Mode_1_Register 12
-#define AI_CONVERT_Source_Select(a) (((a) & 0x1f) << 11)
-#define AI_SI_Source_select(a) (((a) & 0x1f) << 6)
-#define AI_CONVERT_Source_Polarity _bit5
-#define AI_SI_Source_Polarity _bit4
-#define AI_Start_Stop _bit3
-#define AI_Mode_1_Reserved _bit2
-#define AI_Continuous _bit1
-#define AI_Trigger_Once _bit0
-
-#define AI_Mode_2_Register 13
-#define AI_SC_Gate_Enable _bit15
-#define AI_Start_Stop_Gate_Enable _bit14
-#define AI_Pre_Trigger _bit13
-#define AI_External_MUX_Present _bit12
-#define AI_SI2_Initial_Load_Source _bit9
-#define AI_SI2_Reload_Mode _bit8
-#define AI_SI_Initial_Load_Source _bit7
-#define AI_SI_Reload_Mode(a) (((a) & 0x7)<<4)
-#define AI_SI_Write_Switch _bit3
-#define AI_SC_Initial_Load_Source _bit2
-#define AI_SC_Reload_Mode _bit1
-#define AI_SC_Write_Switch _bit0
-
-#define AI_SI_Load_A_Registers 14
-#define AI_SI_Load_B_Registers 16
-#define AI_SC_Load_A_Registers 18
-#define AI_SC_Load_B_Registers 20
-#define AI_SI_Save_Registers 64
-#define AI_SC_Save_Registers 66
-
-#define AI_SI2_Load_A_Register 23
-#define AI_SI2_Load_B_Register 25
-
-#define Joint_Status_1_Register 27
-#define DIO_Serial_IO_In_Progress_St _bit12
-
-#define DIO_Serial_Input_Register 28
-#define Joint_Status_2_Register 29
-enum Joint_Status_2_Bits {
- AO_TMRDACWRs_In_Progress_St = 0x20,
-};
-
-#define AO_Mode_1_Register 38
-#define AO_UPDATE_Source_Select(x) (((x)&0x1f)<<11)
-#define AO_UI_Source_Select(x) (((x)&0x1f)<<6)
-#define AO_Multiple_Channels _bit5
-#define AO_UPDATE_Source_Polarity _bit4
-#define AO_UI_Source_Polarity _bit3
-#define AO_UC_Switch_Load_Every_TC _bit2
-#define AO_Continuous _bit1
-#define AO_Trigger_Once _bit0
-
-#define AO_Mode_2_Register 39
-#define AO_FIFO_Mode_Mask (0x3 << 14)
-enum AO_FIFO_Mode_Bits {
- AO_FIFO_Mode_HF_to_F = (3 << 14),
- AO_FIFO_Mode_F = (2 << 14),
- AO_FIFO_Mode_HF = (1 << 14),
- AO_FIFO_Mode_E = (0 << 14),
-};
-#define AO_FIFO_Retransmit_Enable _bit13
-#define AO_START1_Disable _bit12
-#define AO_UC_Initial_Load_Source _bit11
-#define AO_UC_Write_Switch _bit10
-#define AO_UI2_Initial_Load_Source _bit9
-#define AO_UI2_Reload_Mode _bit8
-#define AO_UI_Initial_Load_Source _bit7
-#define AO_UI_Reload_Mode(x) (((x) & 0x7) << 4)
-#define AO_UI_Write_Switch _bit3
-#define AO_BC_Initial_Load_Source _bit2
-#define AO_BC_Reload_Mode _bit1
-#define AO_BC_Write_Switch _bit0
-
-#define AO_UI_Load_A_Register 40
-#define AO_UI_Load_A_Register_High 40
-#define AO_UI_Load_A_Register_Low 41
-#define AO_UI_Load_B_Register 42
-#define AO_UI_Save_Registers 16
-#define AO_BC_Load_A_Register 44
-#define AO_BC_Load_A_Register_High 44
-#define AO_BC_Load_A_Register_Low 45
-#define AO_BC_Load_B_Register 46
-#define AO_BC_Load_B_Register_High 46
-#define AO_BC_Load_B_Register_Low 47
-#define AO_BC_Save_Registers 18
-#define AO_UC_Load_A_Register 48
-#define AO_UC_Load_A_Register_High 48
-#define AO_UC_Load_A_Register_Low 49
-#define AO_UC_Load_B_Register 50
-#define AO_UC_Save_Registers 20
-
-#define Clock_and_FOUT_Register 56
-enum Clock_and_FOUT_bits {
- FOUT_Enable = _bit15,
- FOUT_Timebase_Select = _bit14,
- DIO_Serial_Out_Divide_By_2 = _bit13,
- Slow_Internal_Time_Divide_By_2 = _bit12,
- Slow_Internal_Timebase = _bit11,
- G_Source_Divide_By_2 = _bit10,
- Clock_To_Board_Divide_By_2 = _bit9,
- Clock_To_Board = _bit8,
- AI_Output_Divide_By_2 = _bit7,
- AI_Source_Divide_By_2 = _bit6,
- AO_Output_Divide_By_2 = _bit5,
- AO_Source_Divide_By_2 = _bit4,
- FOUT_Divider_mask = 0xf
-};
-static inline unsigned FOUT_Divider(unsigned divider)
-{
- return divider & FOUT_Divider_mask;
-}
-
-#define IO_Bidirection_Pin_Register 57
-#define RTSI_Trig_Direction_Register 58
-enum RTSI_Trig_Direction_Bits {
- Drive_RTSI_Clock_Bit = 0x1,
- Use_RTSI_Clock_Bit = 0x2,
-};
-static inline unsigned RTSI_Output_Bit(unsigned channel, int is_mseries)
-{
- unsigned max_channel;
- unsigned base_bit_shift;
- if (is_mseries) {
- base_bit_shift = 8;
- max_channel = 7;
- } else {
- base_bit_shift = 9;
- max_channel = 6;
- }
- if (channel > max_channel) {
- pr_err("%s: bug, invalid RTSI_channel=%i\n", __func__, channel);
- return 0;
- }
- return 1 << (base_bit_shift + channel);
-}
-
-#define Interrupt_Control_Register 59
-#define Interrupt_B_Enable _bit15
-#define Interrupt_B_Output_Select(x) ((x)<<12)
-#define Interrupt_A_Enable _bit11
-#define Interrupt_A_Output_Select(x) ((x)<<8)
-#define Pass_Thru_0_Interrupt_Polarity _bit3
-#define Pass_Thru_1_Interrupt_Polarity _bit2
-#define Interrupt_Output_On_3_Pins _bit1
-#define Interrupt_Output_Polarity _bit0
-
-#define AI_Output_Control_Register 60
-#define AI_START_Output_Select _bit10
-#define AI_SCAN_IN_PROG_Output_Select(x) (((x) & 0x3) << 8)
-#define AI_EXTMUX_CLK_Output_Select(x) (((x) & 0x3) << 6)
-#define AI_LOCALMUX_CLK_Output_Select(x) ((x)<<4)
-#define AI_SC_TC_Output_Select(x) ((x)<<2)
-enum ai_convert_output_selection {
- AI_CONVERT_Output_High_Z = 0,
- AI_CONVERT_Output_Ground = 1,
- AI_CONVERT_Output_Enable_Low = 2,
- AI_CONVERT_Output_Enable_High = 3
-};
-static unsigned AI_CONVERT_Output_Select(enum ai_convert_output_selection
- selection)
-{
- return selection & 0x3;
-}
-
-#define AI_START_STOP_Select_Register 62
-#define AI_START_Polarity _bit15
-#define AI_STOP_Polarity _bit14
-#define AI_STOP_Sync _bit13
-#define AI_STOP_Edge _bit12
-#define AI_STOP_Select(a) (((a) & 0x1f)<<7)
-#define AI_START_Sync _bit6
-#define AI_START_Edge _bit5
-#define AI_START_Select(a) ((a) & 0x1f)
-
-#define AI_Trigger_Select_Register 63
-#define AI_START1_Polarity _bit15
-#define AI_START2_Polarity _bit14
-#define AI_START2_Sync _bit13
-#define AI_START2_Edge _bit12
-#define AI_START2_Select(a) (((a) & 0x1f) << 7)
-#define AI_START1_Sync _bit6
-#define AI_START1_Edge _bit5
-#define AI_START1_Select(a) ((a) & 0x1f)
-
-#define AI_DIV_Load_A_Register 64
-
-#define AO_Start_Select_Register 66
-#define AO_UI2_Software_Gate _bit15
-#define AO_UI2_External_Gate_Polarity _bit14
-#define AO_START_Polarity _bit13
-#define AO_AOFREQ_Enable _bit12
-#define AO_UI2_External_Gate_Select(a) (((a) & 0x1f) << 7)
-#define AO_START_Sync _bit6
-#define AO_START_Edge _bit5
-#define AO_START_Select(a) ((a) & 0x1f)
-
-#define AO_Trigger_Select_Register 67
-#define AO_UI2_External_Gate_Enable _bit15
-#define AO_Delayed_START1 _bit14
-#define AO_START1_Polarity _bit13
-#define AO_UI2_Source_Polarity _bit12
-#define AO_UI2_Source_Select(x) (((x)&0x1f)<<7)
-#define AO_START1_Sync _bit6
-#define AO_START1_Edge _bit5
-#define AO_START1_Select(x) (((x)&0x1f)<<0)
-
-#define AO_Mode_3_Register 70
-#define AO_UI2_Switch_Load_Next_TC _bit13
-#define AO_UC_Switch_Load_Every_BC_TC _bit12
-#define AO_Trigger_Length _bit11
-#define AO_Stop_On_Overrun_Error _bit5
-#define AO_Stop_On_BC_TC_Trigger_Error _bit4
-#define AO_Stop_On_BC_TC_Error _bit3
-#define AO_Not_An_UPDATE _bit2
-#define AO_Software_Gate _bit1
-#define AO_Last_Gate_Disable _bit0 /* M Series only */
-
-#define Joint_Reset_Register 72
-#define Software_Reset _bit11
-#define AO_Configuration_End _bit9
-#define AI_Configuration_End _bit8
-#define AO_Configuration_Start _bit5
-#define AI_Configuration_Start _bit4
-#define G1_Reset _bit3
-#define G0_Reset _bit2
-#define AO_Reset _bit1
-#define AI_Reset _bit0
-
-#define Interrupt_A_Enable_Register 73
-#define Pass_Thru_0_Interrupt_Enable _bit9
-#define G0_Gate_Interrupt_Enable _bit8
-#define AI_FIFO_Interrupt_Enable _bit7
-#define G0_TC_Interrupt_Enable _bit6
-#define AI_Error_Interrupt_Enable _bit5
-#define AI_STOP_Interrupt_Enable _bit4
-#define AI_START_Interrupt_Enable _bit3
-#define AI_START2_Interrupt_Enable _bit2
-#define AI_START1_Interrupt_Enable _bit1
-#define AI_SC_TC_Interrupt_Enable _bit0
-
-#define Interrupt_B_Enable_Register 75
-#define Pass_Thru_1_Interrupt_Enable _bit11
-#define G1_Gate_Interrupt_Enable _bit10
-#define G1_TC_Interrupt_Enable _bit9
-#define AO_FIFO_Interrupt_Enable _bit8
-#define AO_UI2_TC_Interrupt_Enable _bit7
-#define AO_UC_TC_Interrupt_Enable _bit6
-#define AO_Error_Interrupt_Enable _bit5
-#define AO_STOP_Interrupt_Enable _bit4
-#define AO_START_Interrupt_Enable _bit3
-#define AO_UPDATE_Interrupt_Enable _bit2
-#define AO_START1_Interrupt_Enable _bit1
-#define AO_BC_TC_Interrupt_Enable _bit0
-
-#define Second_IRQ_A_Enable_Register 74
-enum Second_IRQ_A_Enable_Bits {
- AI_SC_TC_Second_Irq_Enable = _bit0,
- AI_START1_Second_Irq_Enable = _bit1,
- AI_START2_Second_Irq_Enable = _bit2,
- AI_START_Second_Irq_Enable = _bit3,
- AI_STOP_Second_Irq_Enable = _bit4,
- AI_Error_Second_Irq_Enable = _bit5,
- G0_TC_Second_Irq_Enable = _bit6,
- AI_FIFO_Second_Irq_Enable = _bit7,
- G0_Gate_Second_Irq_Enable = _bit8,
- Pass_Thru_0_Second_Irq_Enable = _bit9
-};
+/*
+ * Registers in the National Instruments DAQ-STC chip
+ */
+
+#define NISTC_INTA_ACK_REG 2
+#define NISTC_INTA_ACK_G0_GATE BIT(15)
+#define NISTC_INTA_ACK_G0_TC BIT(14)
+#define NISTC_INTA_ACK_AI_ERR BIT(13)
+#define NISTC_INTA_ACK_AI_STOP BIT(12)
+#define NISTC_INTA_ACK_AI_START BIT(11)
+#define NISTC_INTA_ACK_AI_START2 BIT(10)
+#define NISTC_INTA_ACK_AI_START1 BIT(9)
+#define NISTC_INTA_ACK_AI_SC_TC BIT(8)
+#define NISTC_INTA_ACK_AI_SC_TC_ERR BIT(7)
+#define NISTC_INTA_ACK_G0_TC_ERR BIT(6)
+#define NISTC_INTA_ACK_G0_GATE_ERR BIT(5)
+#define NISTC_INTA_ACK_AI_ALL (NISTC_INTA_ACK_AI_ERR | \
+ NISTC_INTA_ACK_AI_STOP | \
+ NISTC_INTA_ACK_AI_START | \
+ NISTC_INTA_ACK_AI_START2 | \
+ NISTC_INTA_ACK_AI_START1 | \
+ NISTC_INTA_ACK_AI_SC_TC | \
+ NISTC_INTA_ACK_AI_SC_TC_ERR)
+
+#define NISTC_INTB_ACK_REG 3
+#define NISTC_INTB_ACK_G1_GATE BIT(15)
+#define NISTC_INTB_ACK_G1_TC BIT(14)
+#define NISTC_INTB_ACK_AO_ERR BIT(13)
+#define NISTC_INTB_ACK_AO_STOP BIT(12)
+#define NISTC_INTB_ACK_AO_START BIT(11)
+#define NISTC_INTB_ACK_AO_UPDATE BIT(10)
+#define NISTC_INTB_ACK_AO_START1 BIT(9)
+#define NISTC_INTB_ACK_AO_BC_TC BIT(8)
+#define NISTC_INTB_ACK_AO_UC_TC BIT(7)
+#define NISTC_INTB_ACK_AO_UI2_TC BIT(6)
+#define NISTC_INTB_ACK_AO_UI2_TC_ERR BIT(5)
+#define NISTC_INTB_ACK_AO_BC_TC_ERR BIT(4)
+#define NISTC_INTB_ACK_AO_BC_TC_TRIG_ERR BIT(3)
+#define NISTC_INTB_ACK_G1_TC_ERR BIT(2)
+#define NISTC_INTB_ACK_G1_GATE_ERR BIT(1)
+#define NISTC_INTB_ACK_AO_ALL (NISTC_INTB_ACK_AO_ERR | \
+ NISTC_INTB_ACK_AO_STOP | \
+ NISTC_INTB_ACK_AO_START | \
+ NISTC_INTB_ACK_AO_UPDATE | \
+ NISTC_INTB_ACK_AO_START1 | \
+ NISTC_INTB_ACK_AO_BC_TC | \
+ NISTC_INTB_ACK_AO_UC_TC | \
+ NISTC_INTB_ACK_AO_BC_TC_ERR | \
+ NISTC_INTB_ACK_AO_BC_TC_TRIG_ERR)
+
+#define NISTC_AI_CMD2_REG 4
+#define NISTC_AI_CMD2_END_ON_SC_TC BIT(15)
+#define NISTC_AI_CMD2_END_ON_EOS BIT(14)
+#define NISTC_AI_CMD2_START1_DISABLE BIT(11)
+#define NISTC_AI_CMD2_SC_SAVE_TRACE BIT(10)
+#define NISTC_AI_CMD2_SI_SW_ON_SC_TC BIT(9)
+#define NISTC_AI_CMD2_SI_SW_ON_STOP BIT(8)
+#define NISTC_AI_CMD2_SI_SW_ON_TC BIT(7)
+#define NISTC_AI_CMD2_SC_SW_ON_TC BIT(4)
+#define NISTC_AI_CMD2_STOP_PULSE BIT(3)
+#define NISTC_AI_CMD2_START_PULSE BIT(2)
+#define NISTC_AI_CMD2_START2_PULSE BIT(1)
+#define NISTC_AI_CMD2_START1_PULSE BIT(0)
+
+#define NISTC_AO_CMD2_REG 5
+#define NISTC_AO_CMD2_END_ON_BC_TC(x) (((x) & 0x3) << 14)
+#define NISTC_AO_CMD2_START_STOP_GATE_ENA BIT(13)
+#define NISTC_AO_CMD2_UC_SAVE_TRACE BIT(12)
+#define NISTC_AO_CMD2_BC_GATE_ENA BIT(11)
+#define NISTC_AO_CMD2_BC_SAVE_TRACE BIT(10)
+#define NISTC_AO_CMD2_UI_SW_ON_BC_TC BIT(9)
+#define NISTC_AO_CMD2_UI_SW_ON_STOP BIT(8)
+#define NISTC_AO_CMD2_UI_SW_ON_TC BIT(7)
+#define NISTC_AO_CMD2_UC_SW_ON_BC_TC BIT(6)
+#define NISTC_AO_CMD2_UC_SW_ON_TC BIT(5)
+#define NISTC_AO_CMD2_BC_SW_ON_TC BIT(4)
+#define NISTC_AO_CMD2_MUTE_B BIT(3)
+#define NISTC_AO_CMD2_MUTE_A BIT(2)
+#define NISTC_AO_CMD2_UPDATE2_PULSE BIT(1)
+#define NISTC_AO_CMD2_START1_PULSE BIT(0)
+
+#define NISTC_G0_CMD_REG 6
+#define NISTC_G1_CMD_REG 7
+
+#define NISTC_AI_CMD1_REG 8
+#define NISTC_AI_CMD1_ATRIG_RESET BIT(14)
+#define NISTC_AI_CMD1_DISARM BIT(13)
+#define NISTC_AI_CMD1_SI2_ARM BIT(12)
+#define NISTC_AI_CMD1_SI2_LOAD BIT(11)
+#define NISTC_AI_CMD1_SI_ARM BIT(10)
+#define NISTC_AI_CMD1_SI_LOAD BIT(9)
+#define NISTC_AI_CMD1_DIV_ARM BIT(8)
+#define NISTC_AI_CMD1_DIV_LOAD BIT(7)
+#define NISTC_AI_CMD1_SC_ARM BIT(6)
+#define NISTC_AI_CMD1_SC_LOAD BIT(5)
+#define NISTC_AI_CMD1_SCAN_IN_PROG_PULSE BIT(4)
+#define NISTC_AI_CMD1_EXTMUX_CLK_PULSE BIT(3)
+#define NISTC_AI_CMD1_LOCALMUX_CLK_PULSE BIT(2)
+#define NISTC_AI_CMD1_SC_TC_PULSE BIT(1)
+#define NISTC_AI_CMD1_CONVERT_PULSE BIT(0)
+
+#define NISTC_AO_CMD1_REG 9
+#define NISTC_AO_CMD1_ATRIG_RESET BIT(15)
+#define NISTC_AO_CMD1_START_PULSE BIT(14)
+#define NISTC_AO_CMD1_DISARM BIT(13)
+#define NISTC_AO_CMD1_UI2_ARM_DISARM BIT(12)
+#define NISTC_AO_CMD1_UI2_LOAD BIT(11)
+#define NISTC_AO_CMD1_UI_ARM BIT(10)
+#define NISTC_AO_CMD1_UI_LOAD BIT(9)
+#define NISTC_AO_CMD1_UC_ARM BIT(8)
+#define NISTC_AO_CMD1_UC_LOAD BIT(7)
+#define NISTC_AO_CMD1_BC_ARM BIT(6)
+#define NISTC_AO_CMD1_BC_LOAD BIT(5)
+#define NISTC_AO_CMD1_DAC1_UPDATE_MODE BIT(4)
+#define NISTC_AO_CMD1_LDAC1_SRC_SEL BIT(3)
+#define NISTC_AO_CMD1_DAC0_UPDATE_MODE BIT(2)
+#define NISTC_AO_CMD1_LDAC0_SRC_SEL BIT(1)
+#define NISTC_AO_CMD1_UPDATE_PULSE BIT(0)
+
+#define NISTC_DIO_OUT_REG 10
+#define NISTC_DIO_OUT_SERIAL(x) (((x) & 0xff) << 8)
+#define NISTC_DIO_OUT_SERIAL_MASK NISTC_DIO_OUT_SERIAL(0xff)
+#define NISTC_DIO_OUT_PARALLEL(x) ((x) & 0xff)
+#define NISTC_DIO_OUT_PARALLEL_MASK NISTC_DIO_OUT_PARALLEL(0xff)
+#define NISTC_DIO_SDIN BIT(4)
+#define NISTC_DIO_SDOUT BIT(0)
+
+#define NISTC_DIO_CTRL_REG 11
+#define NISTC_DIO_SDCLK BIT(11)
+#define NISTC_DIO_CTRL_HW_SER_TIMEBASE BIT(10)
+#define NISTC_DIO_CTRL_HW_SER_ENA BIT(9)
+#define NISTC_DIO_CTRL_HW_SER_START BIT(8)
+#define NISTC_DIO_CTRL_DIR(x) ((x) & 0xff)
+#define NISTC_DIO_CTRL_DIR_MASK NISTC_DIO_CTRL_DIR(0xff)
+
+#define NISTC_AI_MODE1_REG 12
+#define NISTC_AI_MODE1_CONVERT_SRC(x) (((x) & 0x1f) << 11)
+#define NISTC_AI_MODE1_SI_SRC(x) (((x) & 0x1f) << 6)
+#define NISTC_AI_MODE1_CONVERT_POLARITY BIT(5)
+#define NISTC_AI_MODE1_SI_POLARITY BIT(4)
+#define NISTC_AI_MODE1_START_STOP BIT(3)
+#define NISTC_AI_MODE1_RSVD BIT(2)
+#define NISTC_AI_MODE1_CONTINUOUS BIT(1)
+#define NISTC_AI_MODE1_TRIGGER_ONCE BIT(0)
+
+#define NISTC_AI_MODE2_REG 13
+#define NISTC_AI_MODE2_SC_GATE_ENA BIT(15)
+#define NISTC_AI_MODE2_START_STOP_GATE_ENA BIT(14)
+#define NISTC_AI_MODE2_PRE_TRIGGER BIT(13)
+#define NISTC_AI_MODE2_EXTMUX_PRESENT BIT(12)
+#define NISTC_AI_MODE2_SI2_INIT_LOAD_SRC BIT(9)
+#define NISTC_AI_MODE2_SI2_RELOAD_MODE BIT(8)
+#define NISTC_AI_MODE2_SI_INIT_LOAD_SRC BIT(7)
+#define NISTC_AI_MODE2_SI_RELOAD_MODE(x) (((x) & 0x7) << 4)
+#define NISTC_AI_MODE2_SI_WR_SWITCH BIT(3)
+#define NISTC_AI_MODE2_SC_INIT_LOAD_SRC BIT(2)
+#define NISTC_AI_MODE2_SC_RELOAD_MODE BIT(1)
+#define NISTC_AI_MODE2_SC_WR_SWITCH BIT(0)
+
+#define NISTC_AI_SI_LOADA_REG 14
+#define NISTC_AI_SI_LOADB_REG 16
+#define NISTC_AI_SC_LOADA_REG 18
+#define NISTC_AI_SC_LOADB_REG 20
+#define NISTC_AI_SI2_LOADA_REG 23
+#define NISTC_AI_SI2_LOADB_REG 25
+
+#define NISTC_G0_MODE_REG 26
+#define NISTC_G1_MODE_REG 27
+#define NISTC_G0_LOADA_REG 28
+#define NISTC_G0_LOADB_REG 30
+#define NISTC_G1_LOADA_REG 32
+#define NISTC_G1_LOADB_REG 34
+#define NISTC_G0_INPUT_SEL_REG 36
+#define NISTC_G1_INPUT_SEL_REG 37
+
+#define NISTC_AO_MODE1_REG 38
+#define NISTC_AO_MODE1_UPDATE_SRC(x) (((x) & 0x1f) << 11)
+#define NISTC_AO_MODE1_UPDATE_SRC_MASK NISTC_AO_MODE1_UPDATE_SRC(0x1f)
+#define NISTC_AO_MODE1_UI_SRC(x) (((x) & 0x1f) << 6)
+#define NISTC_AO_MODE1_UI_SRC_MASK NISTC_AO_MODE1_UI_SRC(0x1f)
+#define NISTC_AO_MODE1_MULTI_CHAN BIT(5)
+#define NISTC_AO_MODE1_UPDATE_SRC_POLARITY BIT(4)
+#define NISTC_AO_MODE1_UI_SRC_POLARITY BIT(3)
+#define NISTC_AO_MODE1_UC_SW_EVERY_TC BIT(2)
+#define NISTC_AO_MODE1_CONTINUOUS BIT(1)
+#define NISTC_AO_MODE1_TRIGGER_ONCE BIT(0)
+
+#define NISTC_AO_MODE2_REG 39
+#define NISTC_AO_MODE2_FIFO_MODE(x) (((x) & 0x3) << 14)
+#define NISTC_AO_MODE2_FIFO_MODE_MASK NISTC_AO_MODE2_FIFO_MODE(3)
+#define NISTC_AO_MODE2_FIFO_MODE_E NISTC_AO_MODE2_FIFO_MODE(0)
+#define NISTC_AO_MODE2_FIFO_MODE_HF NISTC_AO_MODE2_FIFO_MODE(1)
+#define NISTC_AO_MODE2_FIFO_MODE_F NISTC_AO_MODE2_FIFO_MODE(2)
+#define NISTC_AO_MODE2_FIFO_MODE_HF_F NISTC_AO_MODE2_FIFO_MODE(3)
+#define NISTC_AO_MODE2_FIFO_REXMIT_ENA BIT(13)
+#define NISTC_AO_MODE2_START1_DISABLE BIT(12)
+#define NISTC_AO_MODE2_UC_INIT_LOAD_SRC BIT(11)
+#define NISTC_AO_MODE2_UC_WR_SWITCH BIT(10)
+#define NISTC_AO_MODE2_UI2_INIT_LOAD_SRC BIT(9)
+#define NISTC_AO_MODE2_UI2_RELOAD_MODE BIT(8)
+#define NISTC_AO_MODE2_UI_INIT_LOAD_SRC BIT(7)
+#define NISTC_AO_MODE2_UI_RELOAD_MODE(x) (((x) & 0x7) << 4)
+#define NISTC_AO_MODE2_UI_WR_SWITCH BIT(3)
+#define NISTC_AO_MODE2_BC_INIT_LOAD_SRC BIT(2)
+#define NISTC_AO_MODE2_BC_RELOAD_MODE BIT(1)
+#define NISTC_AO_MODE2_BC_WR_SWITCH BIT(0)
+
+#define NISTC_AO_UI_LOADA_REG 40
+#define NISTC_AO_UI_LOADB_REG 42
+#define NISTC_AO_BC_LOADA_REG 44
+#define NISTC_AO_BC_LOADB_REG 46
+#define NISTC_AO_UC_LOADA_REG 48
+#define NISTC_AO_UC_LOADB_REG 50
+
+#define NISTC_CLK_FOUT_REG 56
+#define NISTC_CLK_FOUT_ENA BIT(15)
+#define NISTC_CLK_FOUT_TIMEBASE_SEL BIT(14)
+#define NISTC_CLK_FOUT_DIO_SER_OUT_DIV2 BIT(13)
+#define NISTC_CLK_FOUT_SLOW_DIV2 BIT(12)
+#define NISTC_CLK_FOUT_SLOW_TIMEBASE BIT(11)
+#define NISTC_CLK_FOUT_G_SRC_DIV2 BIT(10)
+#define NISTC_CLK_FOUT_TO_BOARD_DIV2 BIT(9)
+#define NISTC_CLK_FOUT_TO_BOARD BIT(8)
+#define NISTC_CLK_FOUT_AI_OUT_DIV2 BIT(7)
+#define NISTC_CLK_FOUT_AI_SRC_DIV2 BIT(6)
+#define NISTC_CLK_FOUT_AO_OUT_DIV2 BIT(5)
+#define NISTC_CLK_FOUT_AO_SRC_DIV2 BIT(4)
+#define NISTC_CLK_FOUT_DIVIDER(x) (((x) & 0xf) << 0)
+#define NISTC_CLK_FOUT_TO_DIVIDER(x) (((x) >> 0) & 0xf)
+#define NISTC_CLK_FOUT_DIVIDER_MASK NISTC_CLK_FOUT_DIVIDER(0xf)
+
+#define NISTC_IO_BIDIR_PIN_REG 57
+
+#define NISTC_RTSI_TRIG_DIR_REG 58
+#define NISTC_RTSI_TRIG_OLD_CLK_CHAN 7
+#define NISTC_RTSI_TRIG_NUM_CHAN(_m) ((_m) ? 8 : 7)
+#define NISTC_RTSI_TRIG_DIR(_c, _m) ((_m) ? BIT(8 + (_c)) : BIT(7 + (_c)))
+#define NISTC_RTSI_TRIG_USE_CLK BIT(1)
+#define NISTC_RTSI_TRIG_DRV_CLK BIT(0)
+
+#define NISTC_INT_CTRL_REG 59
+#define NISTC_INT_CTRL_INTB_ENA BIT(15)
+#define NISTC_INT_CTRL_INTB_SEL(x) (((x) & 0x7) << 12)
+#define NISTC_INT_CTRL_INTA_ENA BIT(11)
+#define NISTC_INT_CTRL_INTA_SEL(x) (((x) & 0x7) << 8)
+#define NISTC_INT_CTRL_PASSTHRU0_POL BIT(3)
+#define NISTC_INT_CTRL_PASSTHRU1_POL BIT(2)
+#define NISTC_INT_CTRL_3PIN_INT BIT(1)
+#define NISTC_INT_CTRL_INT_POL BIT(0)
+
+#define NISTC_AI_OUT_CTRL_REG 60
+#define NISTC_AI_OUT_CTRL_START_SEL BIT(10)
+#define NISTC_AI_OUT_CTRL_SCAN_IN_PROG_SEL(x) (((x) & 0x3) << 8)
+#define NISTC_AI_OUT_CTRL_EXTMUX_CLK_SEL(x) (((x) & 0x3) << 6)
+#define NISTC_AI_OUT_CTRL_LOCALMUX_CLK_SEL(x) (((x) & 0x3) << 4)
+#define NISTC_AI_OUT_CTRL_SC_TC_SEL(x) (((x) & 0x3) << 2)
+#define NISTC_AI_OUT_CTRL_CONVERT_SEL(x) (((x) & 0x3) << 0)
+#define NISTC_AI_OUT_CTRL_CONVERT_HIGH_Z NISTC_AI_OUT_CTRL_CONVERT_SEL(0)
+#define NISTC_AI_OUT_CTRL_CONVERT_GND NISTC_AI_OUT_CTRL_CONVERT_SEL(1)
+#define NISTC_AI_OUT_CTRL_CONVERT_LOW NISTC_AI_OUT_CTRL_CONVERT_SEL(2)
+#define NISTC_AI_OUT_CTRL_CONVERT_HIGH NISTC_AI_OUT_CTRL_CONVERT_SEL(3)
+
+#define NISTC_ATRIG_ETC_REG 61
+#define NISTC_ATRIG_ETC_GPFO_1_ENA BIT(15)
+#define NISTC_ATRIG_ETC_GPFO_0_ENA BIT(14)
+#define NISTC_ATRIG_ETC_GPFO_0_SEL(x) (((x) & 0x3) << 11)
+#define NISTC_ATRIG_ETC_GPFO_1_SEL BIT(7)
+#define NISTC_ATRIG_ETC_DRV BIT(4)
+#define NISTC_ATRIG_ETC_ENA BIT(3)
+#define NISTC_ATRIG_ETC_MODE(x) (((x) & 0x7) << 0)
+
+#define NISTC_AI_START_STOP_REG 62
+#define NISTC_AI_START_POLARITY BIT(15)
+#define NISTC_AI_STOP_POLARITY BIT(14)
+#define NISTC_AI_STOP_SYNC BIT(13)
+#define NISTC_AI_STOP_EDGE BIT(12)
+#define NISTC_AI_STOP_SEL(x) (((x) & 0x1f) << 7)
+#define NISTC_AI_START_SYNC BIT(6)
+#define NISTC_AI_START_EDGE BIT(5)
+#define NISTC_AI_START_SEL(x) (((x) & 0x1f) << 0)
+
+#define NISTC_AI_TRIG_SEL_REG 63
+#define NISTC_AI_TRIG_START1_POLARITY BIT(15)
+#define NISTC_AI_TRIG_START2_POLARITY BIT(14)
+#define NISTC_AI_TRIG_START2_SYNC BIT(13)
+#define NISTC_AI_TRIG_START2_EDGE BIT(12)
+#define NISTC_AI_TRIG_START2_SEL(x) (((x) & 0x1f) << 7)
+#define NISTC_AI_TRIG_START1_SYNC BIT(6)
+#define NISTC_AI_TRIG_START1_EDGE BIT(5)
+#define NISTC_AI_TRIG_START1_SEL(x) (((x) & 0x1f) << 0)
+
+#define NISTC_AI_DIV_LOADA_REG 64
+
+#define NISTC_AO_START_SEL_REG 66
+#define NISTC_AO_START_UI2_SW_GATE BIT(15)
+#define NISTC_AO_START_UI2_EXT_GATE_POL BIT(14)
+#define NISTC_AO_START_POLARITY BIT(13)
+#define NISTC_AO_START_AOFREQ_ENA BIT(12)
+#define NISTC_AO_START_UI2_EXT_GATE_SEL(x) (((x) & 0x1f) << 7)
+#define NISTC_AO_START_SYNC BIT(6)
+#define NISTC_AO_START_EDGE BIT(5)
+#define NISTC_AO_START_SEL(x) (((x) & 0x1f) << 0)
+
+#define NISTC_AO_TRIG_SEL_REG 67
+#define NISTC_AO_TRIG_UI2_EXT_GATE_ENA BIT(15)
+#define NISTC_AO_TRIG_DELAYED_START1 BIT(14)
+#define NISTC_AO_TRIG_START1_POLARITY BIT(13)
+#define NISTC_AO_TRIG_UI2_SRC_POLARITY BIT(12)
+#define NISTC_AO_TRIG_UI2_SRC_SEL(x) (((x) & 0x1f) << 7)
+#define NISTC_AO_TRIG_START1_SYNC BIT(6)
+#define NISTC_AO_TRIG_START1_EDGE BIT(5)
+#define NISTC_AO_TRIG_START1_SEL(x) (((x) & 0x1f) << 0)
+#define NISTC_AO_TRIG_START1_SEL_MASK NISTC_AO_TRIG_START1_SEL(0x1f)
+
+#define NISTC_G0_AUTOINC_REG 68
+#define NISTC_G1_AUTOINC_REG 69
+
+#define NISTC_AO_MODE3_REG 70
+#define NISTC_AO_MODE3_UI2_SW_NEXT_TC BIT(13)
+#define NISTC_AO_MODE3_UC_SW_EVERY_BC_TC BIT(12)
+#define NISTC_AO_MODE3_TRIG_LEN BIT(11)
+#define NISTC_AO_MODE3_STOP_ON_OVERRUN_ERR BIT(5)
+#define NISTC_AO_MODE3_STOP_ON_BC_TC_TRIG_ERR BIT(4)
+#define NISTC_AO_MODE3_STOP_ON_BC_TC_ERR BIT(3)
+#define NISTC_AO_MODE3_NOT_AN_UPDATE BIT(2)
+#define NISTC_AO_MODE3_SW_GATE BIT(1)
+#define NISTC_AO_MODE3_LAST_GATE_DISABLE BIT(0) /* M-Series only */
+
+#define NISTC_RESET_REG 72
+#define NISTC_RESET_SOFTWARE BIT(11)
+#define NISTC_RESET_AO_CFG_END BIT(9)
+#define NISTC_RESET_AI_CFG_END BIT(8)
+#define NISTC_RESET_AO_CFG_START BIT(5)
+#define NISTC_RESET_AI_CFG_START BIT(4)
+#define NISTC_RESET_G1 BIT(3)
+#define NISTC_RESET_G0 BIT(2)
+#define NISTC_RESET_AO BIT(1)
+#define NISTC_RESET_AI BIT(0)
+
+#define NISTC_INTA_ENA_REG 73
+#define NISTC_INTA2_ENA_REG 74
+#define NISTC_INTA_ENA_PASSTHRU0 BIT(9)
+#define NISTC_INTA_ENA_G0_GATE BIT(8)
+#define NISTC_INTA_ENA_AI_FIFO BIT(7)
+#define NISTC_INTA_ENA_G0_TC BIT(6)
+#define NISTC_INTA_ENA_AI_ERR BIT(5)
+#define NISTC_INTA_ENA_AI_STOP BIT(4)
+#define NISTC_INTA_ENA_AI_START BIT(3)
+#define NISTC_INTA_ENA_AI_START2 BIT(2)
+#define NISTC_INTA_ENA_AI_START1 BIT(1)
+#define NISTC_INTA_ENA_AI_SC_TC BIT(0)
+#define NISTC_INTA_ENA_AI_MASK (NISTC_INTA_ENA_AI_FIFO | \
+ NISTC_INTA_ENA_AI_ERR | \
+ NISTC_INTA_ENA_AI_STOP | \
+ NISTC_INTA_ENA_AI_START | \
+ NISTC_INTA_ENA_AI_START2 | \
+ NISTC_INTA_ENA_AI_START1 | \
+ NISTC_INTA_ENA_AI_SC_TC)
+
+#define NISTC_INTB_ENA_REG 75
+#define NISTC_INTB2_ENA_REG 76
+#define NISTC_INTB_ENA_PASSTHRU1 BIT(11)
+#define NISTC_INTB_ENA_G1_GATE BIT(10)
+#define NISTC_INTB_ENA_G1_TC BIT(9)
+#define NISTC_INTB_ENA_AO_FIFO BIT(8)
+#define NISTC_INTB_ENA_AO_UI2_TC BIT(7)
+#define NISTC_INTB_ENA_AO_UC_TC BIT(6)
+#define NISTC_INTB_ENA_AO_ERR BIT(5)
+#define NISTC_INTB_ENA_AO_STOP BIT(4)
+#define NISTC_INTB_ENA_AO_START BIT(3)
+#define NISTC_INTB_ENA_AO_UPDATE BIT(2)
+#define NISTC_INTB_ENA_AO_START1 BIT(1)
+#define NISTC_INTB_ENA_AO_BC_TC BIT(0)
+
+#define NISTC_AI_PERSONAL_REG 77
+#define NISTC_AI_PERSONAL_SHIFTIN_PW BIT(15)
+#define NISTC_AI_PERSONAL_EOC_POLARITY BIT(14)
+#define NISTC_AI_PERSONAL_SOC_POLARITY BIT(13)
+#define NISTC_AI_PERSONAL_SHIFTIN_POL BIT(12)
+#define NISTC_AI_PERSONAL_CONVERT_TIMEBASE BIT(11)
+#define NISTC_AI_PERSONAL_CONVERT_PW BIT(10)
+#define NISTC_AI_PERSONAL_CONVERT_ORIG_PULSE BIT(9)
+#define NISTC_AI_PERSONAL_FIFO_FLAGS_POL BIT(8)
+#define NISTC_AI_PERSONAL_OVERRUN_MODE BIT(7)
+#define NISTC_AI_PERSONAL_EXTMUX_CLK_PW BIT(6)
+#define NISTC_AI_PERSONAL_LOCALMUX_CLK_PW BIT(5)
+#define NISTC_AI_PERSONAL_AIFREQ_POL BIT(4)
+
+#define NISTC_AO_PERSONAL_REG 78
+#define NISTC_AO_PERSONAL_MULTI_DACS BIT(15) /* M-Series only */
+#define NISTC_AO_PERSONAL_NUM_DAC BIT(14) /* 1:single; 0:dual */
+#define NISTC_AO_PERSONAL_FAST_CPU BIT(13) /* M-Series reserved */
+#define NISTC_AO_PERSONAL_TMRDACWR_PW BIT(12)
+#define NISTC_AO_PERSONAL_FIFO_FLAGS_POL BIT(11) /* M-Series reserved */
+#define NISTC_AO_PERSONAL_FIFO_ENA BIT(10)
+#define NISTC_AO_PERSONAL_AOFREQ_POL BIT(9) /* M-Series reserved */
+#define NISTC_AO_PERSONAL_DMA_PIO_CTRL BIT(8) /* M-Series reserved */
+#define NISTC_AO_PERSONAL_UPDATE_ORIG_PULSE BIT(7)
+#define NISTC_AO_PERSONAL_UPDATE_TIMEBASE BIT(6)
+#define NISTC_AO_PERSONAL_UPDATE_PW BIT(5)
+#define NISTC_AO_PERSONAL_BC_SRC_SEL BIT(4)
+#define NISTC_AO_PERSONAL_INTERVAL_BUFFER_MODE BIT(3)
+
+#define NISTC_RTSI_TRIGA_OUT_REG 79
+#define NISTC_RTSI_TRIGB_OUT_REG 80
+#define NISTC_RTSI_TRIGB_SUB_SEL1 BIT(15) /* not for M-Series */
+#define NISTC_RTSI_TRIG(_c, _s) (((_s) & 0xf) << (((_c) % 4) * 4))
+#define NISTC_RTSI_TRIG_MASK(_c) NISTC_RTSI_TRIG((_c), 0xf)
+#define NISTC_RTSI_TRIG_TO_SRC(_c, _b) (((_b) >> (((_c) % 4) * 4)) & 0xf)
+
+#define NISTC_RTSI_BOARD_REG 81
+
+#define NISTC_CFG_MEM_CLR_REG 82
+#define NISTC_ADC_FIFO_CLR_REG 83
+#define NISTC_DAC_FIFO_CLR_REG 84
+#define NISTC_WR_STROBE3_REG 85
+
+#define NISTC_AO_OUT_CTRL_REG 86
+#define NISTC_AO_OUT_CTRL_EXT_GATE_ENA BIT(15)
+#define NISTC_AO_OUT_CTRL_EXT_GATE_SEL(x) (((x) & 0x1f) << 10)
+#define NISTC_AO_OUT_CTRL_CHANS(x) (((x) & 0xf) << 6)
+#define NISTC_AO_OUT_CTRL_UPDATE2_SEL(x) (((x) & 0x3) << 4)
+#define NISTC_AO_OUT_CTRL_EXT_GATE_POL BIT(3)
+#define NISTC_AO_OUT_CTRL_UPDATE2_TOGGLE BIT(2)
+#define NISTC_AO_OUT_CTRL_UPDATE_SEL(x) (((x) & 0x3) << 0)
+#define NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGHZ NISTC_AO_OUT_CTRL_UPDATE_SEL(0)
+#define NISTC_AO_OUT_CTRL_UPDATE_SEL_GND NISTC_AO_OUT_CTRL_UPDATE_SEL(1)
+#define NISTC_AO_OUT_CTRL_UPDATE_SEL_LOW NISTC_AO_OUT_CTRL_UPDATE_SEL(2)
+#define NISTC_AO_OUT_CTRL_UPDATE_SEL_HIGH NISTC_AO_OUT_CTRL_UPDATE_SEL(3)
+
+#define NISTC_AI_MODE3_REG 87
+#define NISTC_AI_MODE3_TRIG_LEN BIT(15)
+#define NISTC_AI_MODE3_DELAY_START BIT(14)
+#define NISTC_AI_MODE3_SOFTWARE_GATE BIT(13)
+#define NISTC_AI_MODE3_SI_TRIG_DELAY BIT(12)
+#define NISTC_AI_MODE3_SI2_SRC_SEL BIT(11)
+#define NISTC_AI_MODE3_DELAYED_START2 BIT(10)
+#define NISTC_AI_MODE3_DELAYED_START1 BIT(9)
+#define NISTC_AI_MODE3_EXT_GATE_MODE BIT(8)
+#define NISTC_AI_MODE3_FIFO_MODE(x) (((x) & 0x3) << 6)
+#define NISTC_AI_MODE3_FIFO_MODE_NE NISTC_AI_MODE3_FIFO_MODE(0)
+#define NISTC_AI_MODE3_FIFO_MODE_HF NISTC_AI_MODE3_FIFO_MODE(1)
+#define NISTC_AI_MODE3_FIFO_MODE_F NISTC_AI_MODE3_FIFO_MODE(2)
+#define NISTC_AI_MODE3_FIFO_MODE_HF_E NISTC_AI_MODE3_FIFO_MODE(3)
+#define NISTC_AI_MODE3_EXT_GATE_POL BIT(5)
+#define NISTC_AI_MODE3_EXT_GATE_SEL(x) (((x) & 0x1f) << 0)
+
+#define NISTC_AI_STATUS1_REG 2
+#define NISTC_AI_STATUS1_INTA BIT(15)
+#define NISTC_AI_STATUS1_FIFO_F BIT(14)
+#define NISTC_AI_STATUS1_FIFO_HF BIT(13)
+#define NISTC_AI_STATUS1_FIFO_E BIT(12)
+#define NISTC_AI_STATUS1_OVERRUN BIT(11)
+#define NISTC_AI_STATUS1_OVERFLOW BIT(10)
+#define NISTC_AI_STATUS1_SC_TC_ERR BIT(9)
+#define NISTC_AI_STATUS1_OVER (NISTC_AI_STATUS1_OVERRUN | \
+ NISTC_AI_STATUS1_OVERFLOW)
+#define NISTC_AI_STATUS1_ERR (NISTC_AI_STATUS1_OVER | \
+ NISTC_AI_STATUS1_SC_TC_ERR)
+#define NISTC_AI_STATUS1_START2 BIT(8)
+#define NISTC_AI_STATUS1_START1 BIT(7)
+#define NISTC_AI_STATUS1_SC_TC BIT(6)
+#define NISTC_AI_STATUS1_START BIT(5)
+#define NISTC_AI_STATUS1_STOP BIT(4)
+#define NISTC_AI_STATUS1_G0_TC BIT(3)
+#define NISTC_AI_STATUS1_G0_GATE BIT(2)
+#define NISTC_AI_STATUS1_FIFO_REQ BIT(1)
+#define NISTC_AI_STATUS1_PASSTHRU0 BIT(0)
+
+#define NISTC_AO_STATUS1_REG 3
+#define NISTC_AO_STATUS1_INTB BIT(15)
+#define NISTC_AO_STATUS1_FIFO_F BIT(14)
+#define NISTC_AO_STATUS1_FIFO_HF BIT(13)
+#define NISTC_AO_STATUS1_FIFO_E BIT(12)
+#define NISTC_AO_STATUS1_BC_TC_ERR BIT(11)
+#define NISTC_AO_STATUS1_START BIT(10)
+#define NISTC_AO_STATUS1_OVERRUN BIT(9)
+#define NISTC_AO_STATUS1_START1 BIT(8)
+#define NISTC_AO_STATUS1_BC_TC BIT(7)
+#define NISTC_AO_STATUS1_UC_TC BIT(6)
+#define NISTC_AO_STATUS1_UPDATE BIT(5)
+#define NISTC_AO_STATUS1_UI2_TC BIT(4)
+#define NISTC_AO_STATUS1_G1_TC BIT(3)
+#define NISTC_AO_STATUS1_G1_GATE BIT(2)
+#define NISTC_AO_STATUS1_FIFO_REQ BIT(1)
+#define NISTC_AO_STATUS1_PASSTHRU1 BIT(0)
+
+#define NISTC_G01_STATUS_REG 4
+
+#define NISTC_AI_STATUS2_REG 5
+
+#define NISTC_AO_STATUS2_REG 6
+
+#define NISTC_DIO_IN_REG 7
+
+#define NISTC_G0_HW_SAVE_REG 8
+#define NISTC_G1_HW_SAVE_REG 10
+
+#define NISTC_G0_SAVE_REG 12
+#define NISTC_G1_SAVE_REG 14
+
+#define NISTC_AO_UI_SAVE_REG 16
+#define NISTC_AO_BC_SAVE_REG 18
+#define NISTC_AO_UC_SAVE_REG 20
+
+#define NISTC_STATUS1_REG 27
+#define NISTC_STATUS1_SERIO_IN_PROG BIT(12)
+
+#define NISTC_DIO_SERIAL_IN_REG 28
+
+#define NISTC_STATUS2_REG 29
+#define NISTC_STATUS2_AO_TMRDACWRS_IN_PROGRESS BIT(5)
+
+#define NISTC_AI_SI_SAVE_REG 64
+#define NISTC_AI_SC_SAVE_REG 66
-#define Second_IRQ_B_Enable_Register 76
-enum Second_IRQ_B_Enable_Bits {
- AO_BC_TC_Second_Irq_Enable = _bit0,
- AO_START1_Second_Irq_Enable = _bit1,
- AO_UPDATE_Second_Irq_Enable = _bit2,
- AO_START_Second_Irq_Enable = _bit3,
- AO_STOP_Second_Irq_Enable = _bit4,
- AO_Error_Second_Irq_Enable = _bit5,
- AO_UC_TC_Second_Irq_Enable = _bit6,
- AO_UI2_TC_Second_Irq_Enable = _bit7,
- AO_FIFO_Second_Irq_Enable = _bit8,
- G1_TC_Second_Irq_Enable = _bit9,
- G1_Gate_Second_Irq_Enable = _bit10,
- Pass_Thru_1_Second_Irq_Enable = _bit11
-};
+/*
+ * PCI E Series Registers
+ */
+#define NI_E_STC_WINDOW_ADDR_REG 0x00 /* rw16 */
+#define NI_E_STC_WINDOW_DATA_REG 0x02 /* rw16 */
+
+#define NI_E_STATUS_REG 0x01 /* r8 */
+#define NI_E_STATUS_AI_FIFO_LOWER_NE BIT(3)
+#define NI_E_STATUS_PROMOUT BIT(0)
+
+#define NI_E_DMA_AI_AO_SEL_REG 0x09 /* w8 */
+#define NI_E_DMA_AI_SEL(x) (((x) & 0xf) << 0)
+#define NI_E_DMA_AI_SEL_MASK NI_E_DMA_AI_SEL(0xf)
+#define NI_E_DMA_AO_SEL(x) (((x) & 0xf) << 4)
+#define NI_E_DMA_AO_SEL_MASK NI_E_DMA_AO_SEL(0xf)
+
+#define NI_E_DMA_G0_G1_SEL_REG 0x0b /* w8 */
+#define NI_E_DMA_G0_G1_SEL(_g, _c) (((_c) & 0xf) << ((_g) * 4))
+#define NI_E_DMA_G0_G1_SEL_MASK(_g) NI_E_DMA_G0_G1_SEL((_g), 0xf)
+
+#define NI_E_SERIAL_CMD_REG 0x0d /* w8 */
+#define NI_E_SERIAL_CMD_DAC_LD(x) BIT(3 + (x))
+#define NI_E_SERIAL_CMD_EEPROM_CS BIT(2)
+#define NI_E_SERIAL_CMD_SDATA BIT(1)
+#define NI_E_SERIAL_CMD_SCLK BIT(0)
+
+#define NI_E_MISC_CMD_REG 0x0f /* w8 */
+#define NI_E_MISC_CMD_INTEXT_ATRIG(x) (((x) & 0x1) << 7)
+#define NI_E_MISC_CMD_EXT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(0)
+#define NI_E_MISC_CMD_INT_ATRIG NI_E_MISC_CMD_INTEXT_ATRIG(1)
+
+#define NI_E_AI_CFG_LO_REG 0x10 /* w16 */
+#define NI_E_AI_CFG_LO_LAST_CHAN BIT(15)
+#define NI_E_AI_CFG_LO_GEN_TRIG BIT(12)
+#define NI_E_AI_CFG_LO_DITHER BIT(9)
+#define NI_E_AI_CFG_LO_UNI BIT(8)
+#define NI_E_AI_CFG_LO_GAIN(x) ((x) << 0)
+
+#define NI_E_AI_CFG_HI_REG 0x12 /* w16 */
+#define NI_E_AI_CFG_HI_TYPE(x) (((x) & 0x7) << 12)
+#define NI_E_AI_CFG_HI_TYPE_DIFF NI_E_AI_CFG_HI_TYPE(1)
+#define NI_E_AI_CFG_HI_TYPE_COMMON NI_E_AI_CFG_HI_TYPE(2)
+#define NI_E_AI_CFG_HI_TYPE_GROUND NI_E_AI_CFG_HI_TYPE(3)
+#define NI_E_AI_CFG_HI_AC_COUPLE BIT(11)
+#define NI_E_AI_CFG_HI_CHAN(x) (((x) & 0x3f) << 0)
+
+#define NI_E_AO_CFG_REG 0x16 /* w16 */
+#define NI_E_AO_DACSEL(x) ((x) << 8)
+#define NI_E_AO_GROUND_REF BIT(3)
+#define NI_E_AO_EXT_REF BIT(2)
+#define NI_E_AO_DEGLITCH BIT(1)
+#define NI_E_AO_CFG_BIP BIT(0)
+
+#define NI_E_DAC_DIRECT_DATA_REG(x) (0x18 + ((x) * 2)) /* w16 */
+
+#define NI_E_8255_BASE 0x19 /* rw8 */
+
+#define NI_E_AI_FIFO_DATA_REG 0x1c /* r16 */
+
+#define NI_E_AO_FIFO_DATA_REG 0x1e /* w16 */
-#define AI_Personal_Register 77
-#define AI_SHIFTIN_Pulse_Width _bit15
-#define AI_EOC_Polarity _bit14
-#define AI_SOC_Polarity _bit13
-#define AI_SHIFTIN_Polarity _bit12
-#define AI_CONVERT_Pulse_Timebase _bit11
-#define AI_CONVERT_Pulse_Width _bit10
-#define AI_CONVERT_Original_Pulse _bit9
-#define AI_FIFO_Flags_Polarity _bit8
-#define AI_Overrun_Mode _bit7
-#define AI_EXTMUX_CLK_Pulse_Width _bit6
-#define AI_LOCALMUX_CLK_Pulse_Width _bit5
-#define AI_AIFREQ_Polarity _bit4
-
-#define AO_Personal_Register 78
-enum AO_Personal_Bits {
- AO_Interval_Buffer_Mode = 1 << 3,
- AO_BC_Source_Select = 1 << 4,
- AO_UPDATE_Pulse_Width = 1 << 5,
- AO_UPDATE_Pulse_Timebase = 1 << 6,
- AO_UPDATE_Original_Pulse = 1 << 7,
- AO_DMA_PIO_Control = 1 << 8, /* M Series: reserved */
- AO_AOFREQ_Polarity = 1 << 9, /* M Series: reserved */
- AO_FIFO_Enable = 1 << 10,
- AO_FIFO_Flags_Polarity = 1 << 11, /* M Series: reserved */
- AO_TMRDACWR_Pulse_Width = 1 << 12,
- AO_Fast_CPU = 1 << 13, /* M Series: reserved */
- AO_Number_Of_DAC_Packages = 1 << 14, /* 1 for "single" mode, 0 for "dual" */
- AO_Multiple_DACS_Per_Package = 1 << 15 /* m-series only */
-};
-#define RTSI_Trig_A_Output_Register 79
-#define RTSI_Trig_B_Output_Register 80
-enum RTSI_Trig_B_Output_Bits {
- RTSI_Sub_Selection_1_Bit = 0x8000 /* not for m-series */
-};
-static inline unsigned RTSI_Trig_Output_Bits(unsigned rtsi_channel,
- unsigned source)
-{
- return (source & 0xf) << ((rtsi_channel % 4) * 4);
-};
+/*
+ * 611x registers (these boards differ from the e-series)
+ */
+#define NI611X_MAGIC_REG 0x19 /* w8 (new) */
+#define NI611X_CALIB_CHAN_SEL_REG 0x1a /* w16 (new) */
+#define NI611X_AI_FIFO_DATA_REG 0x1c /* r32 (incompatible) */
+#define NI611X_AI_FIFO_OFFSET_LOAD_REG 0x05 /* r8 (new) */
+#define NI611X_AO_FIFO_DATA_REG 0x14 /* w32 (incompatible) */
+#define NI611X_CAL_GAIN_SEL_REG 0x05 /* w8 (new) */
+
+#define NI611X_AO_WINDOW_ADDR_REG 0x18
+#define NI611X_AO_WINDOW_DATA_REG 0x1e
-static inline unsigned RTSI_Trig_Output_Mask(unsigned rtsi_channel)
-{
- return 0xf << ((rtsi_channel % 4) * 4);
-};
+/*
+ * 6143 registers
+ */
+#define NI6143_MAGIC_REG 0x19 /* w8 */
+#define NI6143_DMA_G0_G1_SEL_REG 0x0b /* w8 */
+#define NI6143_PIPELINE_DELAY_REG 0x1f /* w8 */
+#define NI6143_EOC_SET_REG 0x1d /* w8 */
+#define NI6143_DMA_AI_SEL_REG 0x09 /* w8 */
+#define NI6143_AI_FIFO_DATA_REG 0x8c /* r32 */
+#define NI6143_AI_FIFO_FLAG_REG 0x84 /* w32 */
+#define NI6143_AI_FIFO_CTRL_REG 0x88 /* w32 */
+#define NI6143_AI_FIFO_STATUS_REG 0x88 /* r32 */
+#define NI6143_AI_FIFO_DMA_THRESH_REG 0x90 /* w32 */
+#define NI6143_AI_FIFO_WORDS_AVAIL_REG 0x94 /* w32 */
+
+#define NI6143_CALIB_CHAN_REG 0x42 /* w16 */
+#define NI6143_CALIB_CHAN_RELAY_ON BIT(15)
+#define NI6143_CALIB_CHAN_RELAY_OFF BIT(14)
+#define NI6143_CALIB_CHAN(x) (((x) & 0xf) << 0)
+#define NI6143_CALIB_CHAN_GND_GND NI6143_CALIB_CHAN(0) /* Offset Cal */
+#define NI6143_CALIB_CHAN_2V5_GND NI6143_CALIB_CHAN(2) /* 2.5V ref */
+#define NI6143_CALIB_CHAN_PWM_GND NI6143_CALIB_CHAN(5) /* +-5V Self Cal */
+#define NI6143_CALIB_CHAN_2V5_PWM NI6143_CALIB_CHAN(10) /* PWM Cal */
+#define NI6143_CALIB_CHAN_PWM_PWM NI6143_CALIB_CHAN(13) /* CMRR */
+#define NI6143_CALIB_CHAN_GND_PWM NI6143_CALIB_CHAN(14) /* PWM Cal */
+#define NI6143_CALIB_LO_TIME_REG 0x20 /* w16 */
+#define NI6143_CALIB_HI_TIME_REG 0x22 /* w16 */
+#define NI6143_RELAY_COUNTER_LOAD_REG 0x4c /* w32 */
+#define NI6143_SIGNATURE_REG 0x50 /* w32 */
+#define NI6143_RELEASE_DATE_REG 0x54 /* w32 */
+#define NI6143_RELEASE_OLDEST_DATE_REG 0x58 /* w32 */
-/* inverse to RTSI_Trig_Output_Bits() */
-static inline unsigned RTSI_Trig_Output_Source(unsigned rtsi_channel,
- unsigned bits)
-{
- return (bits >> ((rtsi_channel % 4) * 4)) & 0xf;
-};
+/*
+ * 671x, 611x windowed ao registers
+ */
+#define NI671X_DAC_DIRECT_DATA_REG(x) (0x00 + (x)) /* w16 */
+#define NI611X_AO_TIMED_REG 0x10 /* w16 */
+#define NI671X_AO_IMMEDIATE_REG 0x11 /* w16 */
+#define NI611X_AO_FIFO_OFFSET_LOAD_REG 0x13 /* w32 */
+#define NI67XX_AO_SP_UPDATES_REG 0x14 /* w16 */
+#define NI611X_AO_WAVEFORM_GEN_REG 0x15 /* w16 */
+#define NI611X_AO_MISC_REG 0x16 /* w16 */
+#define NI611X_AO_MISC_CLEAR_WG BIT(0)
+#define NI67XX_AO_CAL_CHAN_SEL_REG 0x17 /* w16 */
+#define NI67XX_AO_CFG2_REG 0x18 /* w16 */
+#define NI67XX_CAL_CMD_REG 0x19 /* w16 */
+#define NI67XX_CAL_STATUS_REG 0x1a /* r8 */
+#define NI67XX_CAL_STATUS_BUSY BIT(0)
+#define NI67XX_CAL_STATUS_OSC_DETECT BIT(1)
+#define NI67XX_CAL_STATUS_OVERRANGE BIT(2)
+#define NI67XX_CAL_DATA_REG 0x1b /* r16 */
+#define NI67XX_CAL_CFG_HI_REG 0x1c /* rw16 */
+#define NI67XX_CAL_CFG_LO_REG 0x1d /* rw16 */
+
+#define CS5529_CMD_CB BIT(7)
+#define CS5529_CMD_SINGLE_CONV BIT(6)
+#define CS5529_CMD_CONT_CONV BIT(5)
+#define CS5529_CMD_READ BIT(4)
+#define CS5529_CMD_REG(x) (((x) & 0x7) << 1)
+#define CS5529_CMD_REG_MASK CS5529_CMD_REG(7)
+#define CS5529_CMD_PWR_SAVE BIT(0)
+
+#define CS5529_OFFSET_REG CS5529_CMD_REG(0)
+#define CS5529_GAIN_REG CS5529_CMD_REG(1)
+#define CS5529_CONV_DATA_REG CS5529_CMD_REG(3)
+#define CS5529_SETUP_REG CS5529_CMD_REG(4)
+
+#define CS5529_CFG_REG CS5529_CMD_REG(2)
+#define CS5529_CFG_AOUT(x) BIT(22 + (x))
+#define CS5529_CFG_DOUT(x) BIT(18 + (x))
+#define CS5529_CFG_LOW_PWR_MODE BIT(16)
+#define CS5529_CFG_WORD_RATE(x) (((x) & 0x7) << 13)
+#define CS5529_CFG_WORD_RATE_MASK CS5529_CFG_WORD_RATE(0x7)
+#define CS5529_CFG_WORD_RATE_2180 CS5529_CFG_WORD_RATE(0)
+#define CS5529_CFG_WORD_RATE_1092 CS5529_CFG_WORD_RATE(1)
+#define CS5529_CFG_WORD_RATE_532 CS5529_CFG_WORD_RATE(2)
+#define CS5529_CFG_WORD_RATE_388 CS5529_CFG_WORD_RATE(3)
+#define CS5529_CFG_WORD_RATE_324 CS5529_CFG_WORD_RATE(4)
+#define CS5529_CFG_WORD_RATE_17444 CS5529_CFG_WORD_RATE(5)
+#define CS5529_CFG_WORD_RATE_8724 CS5529_CFG_WORD_RATE(6)
+#define CS5529_CFG_WORD_RATE_4364 CS5529_CFG_WORD_RATE(7)
+#define CS5529_CFG_UNIPOLAR BIT(12)
+#define CS5529_CFG_RESET BIT(7)
+#define CS5529_CFG_RESET_VALID BIT(6)
+#define CS5529_CFG_PORT_FLAG BIT(5)
+#define CS5529_CFG_PWR_SAVE_SEL BIT(4)
+#define CS5529_CFG_DONE_FLAG BIT(3)
+#define CS5529_CFG_CALIB(x) (((x) & 0x7) << 0)
+#define CS5529_CFG_CALIB_NONE CS5529_CFG_CALIB(0)
+#define CS5529_CFG_CALIB_OFFSET_SELF CS5529_CFG_CALIB(1)
+#define CS5529_CFG_CALIB_GAIN_SELF CS5529_CFG_CALIB(2)
+#define CS5529_CFG_CALIB_BOTH_SELF CS5529_CFG_CALIB(3)
+#define CS5529_CFG_CALIB_OFFSET_SYS CS5529_CFG_CALIB(5)
+#define CS5529_CFG_CALIB_GAIN_SYS CS5529_CFG_CALIB(6)
-#define RTSI_Board_Register 81
-#define Write_Strobe_0_Register 82
-#define Write_Strobe_1_Register 83
-#define Write_Strobe_2_Register 84
-#define Write_Strobe_3_Register 85
-
-#define AO_Output_Control_Register 86
-#define AO_External_Gate_Enable _bit15
-#define AO_External_Gate_Select(x) (((x)&0x1f)<<10)
-#define AO_Number_Of_Channels(x) (((x)&0xf)<<6)
-#define AO_UPDATE2_Output_Select(x) (((x)&0x3)<<4)
-#define AO_External_Gate_Polarity _bit3
-#define AO_UPDATE2_Output_Toggle _bit2
-enum ao_update_output_selection {
- AO_Update_Output_High_Z = 0,
- AO_Update_Output_Ground = 1,
- AO_Update_Output_Enable_Low = 2,
- AO_Update_Output_Enable_High = 3
-};
-static unsigned AO_UPDATE_Output_Select(enum ao_update_output_selection
- selection)
-{
- return selection & 0x3;
-}
-
-#define AI_Mode_3_Register 87
-#define AI_Trigger_Length _bit15
-#define AI_Delay_START _bit14
-#define AI_Software_Gate _bit13
-#define AI_SI_Special_Trigger_Delay _bit12
-#define AI_SI2_Source_Select _bit11
-#define AI_Delayed_START2 _bit10
-#define AI_Delayed_START1 _bit9
-#define AI_External_Gate_Mode _bit8
-#define AI_FIFO_Mode_HF_to_E (3<<6)
-#define AI_FIFO_Mode_F (2<<6)
-#define AI_FIFO_Mode_HF (1<<6)
-#define AI_FIFO_Mode_NE (0<<6)
-#define AI_External_Gate_Polarity _bit5
-#define AI_External_Gate_Select(a) ((a) & 0x1f)
-
-#define G_Autoincrement_Register(a) (68+(a))
-#define G_Command_Register(a) (6+(a))
-#define G_HW_Save_Register(a) (8+(a)*2)
-#define G_HW_Save_Register_High(a) (8+(a)*2)
-#define G_HW_Save_Register_Low(a) (9+(a)*2)
-#define G_Input_Select_Register(a) (36+(a))
-#define G_Load_A_Register(a) (28+(a)*4)
-#define G_Load_A_Register_High(a) (28+(a)*4)
-#define G_Load_A_Register_Low(a) (29+(a)*4)
-#define G_Load_B_Register(a) (30+(a)*4)
-#define G_Load_B_Register_High(a) (30+(a)*4)
-#define G_Load_B_Register_Low(a) (31+(a)*4)
-#define G_Mode_Register(a) (26+(a))
-#define G_Save_Register(a) (12+(a)*2)
-#define G_Save_Register_High(a) (12+(a)*2)
-#define G_Save_Register_Low(a) (13+(a)*2)
-#define G_Status_Register 4
-#define Analog_Trigger_Etc_Register 61
-
-/* command register */
-#define G_Disarm_Copy _bit15 /* strobe */
-#define G_Save_Trace_Copy _bit14
-#define G_Arm_Copy _bit13 /* strobe */
-#define G_Bank_Switch_Start _bit10 /* strobe */
-#define G_Little_Big_Endian _bit9
-#define G_Synchronized_Gate _bit8
-#define G_Write_Switch _bit7
-#define G_Up_Down(a) (((a)&0x03)<<5)
-#define G_Disarm _bit4 /* strobe */
-#define G_Analog_Trigger_Reset _bit3 /* strobe */
-#define G_Save_Trace _bit1
-#define G_Arm _bit0 /* strobe */
-
-/*channel agnostic names for the command register #defines */
-#define G_Bank_Switch_Enable _bit12
-#define G_Bank_Switch_Mode _bit11
-#define G_Load _bit2 /* strobe */
-
-/* input select register */
-#define G_Gate_Select(a) (((a)&0x1f)<<7)
-#define G_Source_Select(a) (((a)&0x1f)<<2)
-#define G_Write_Acknowledges_Irq _bit1
-#define G_Read_Acknowledges_Irq _bit0
-
-/* same input select register, but with channel agnostic names */
-#define G_Source_Polarity _bit15
-#define G_Output_Polarity _bit14
-#define G_OR_Gate _bit13
-#define G_Gate_Select_Load_Source _bit12
-
-/* mode register */
-#define G_Loading_On_TC _bit12
-#define G_Output_Mode(a) (((a)&0x03)<<8)
-#define G_Trigger_Mode_For_Edge_Gate(a) (((a)&0x03)<<3)
-#define G_Gating_Mode(a) (((a)&0x03)<<0)
-
-/* same input mode register, but with channel agnostic names */
-#define G_Load_Source_Select _bit7
-#define G_Reload_Source_Switching _bit15
-#define G_Loading_On_Gate _bit14
-#define G_Gate_Polarity _bit13
-
-#define G_Counting_Once(a) (((a)&0x03)<<10)
-#define G_Stop_Mode(a) (((a)&0x03)<<5)
-#define G_Gate_On_Both_Edges _bit2
-
-/* G_Status_Register */
-#define G1_Gate_Error_St _bit15
-#define G0_Gate_Error_St _bit14
-#define G1_TC_Error_St _bit13
-#define G0_TC_Error_St _bit12
-#define G1_No_Load_Between_Gates_St _bit11
-#define G0_No_Load_Between_Gates_St _bit10
-#define G1_Armed_St _bit9
-#define G0_Armed_St _bit8
-#define G1_Stale_Data_St _bit7
-#define G0_Stale_Data_St _bit6
-#define G1_Next_Load_Source_St _bit5
-#define G0_Next_Load_Source_St _bit4
-#define G1_Counting_St _bit3
-#define G0_Counting_St _bit2
-#define G1_Save_St _bit1
-#define G0_Save_St _bit0
-
-/* general purpose counter timer */
-#define G_Autoincrement(a) ((a)<<0)
-
-/*Analog_Trigger_Etc_Register*/
-#define Analog_Trigger_Mode(x) ((x) & 0x7)
-#define Analog_Trigger_Enable _bit3
-#define Analog_Trigger_Drive _bit4
-#define GPFO_1_Output_Select _bit7
-#define GPFO_0_Output_Select(a) ((a)<<11)
-#define GPFO_0_Output_Enable _bit14
-#define GPFO_1_Output_Enable _bit15
-
-/* Additional windowed registers unique to E series */
-
-/* 16 bit registers shadowed from DAQ-STC */
-#define Window_Address 0x00
-#define Window_Data 0x02
-
-#define Configuration_Memory_Clear 82
-#define ADC_FIFO_Clear 83
-#define DAC_FIFO_Clear 84
-
-/* i/o port offsets */
-
-/* 8 bit registers */
-#define XXX_Status 0x01
-enum XXX_Status_Bits {
- PROMOUT = 0x1,
- AI_FIFO_LOWER_NOT_EMPTY = 0x8,
-};
-#define Serial_Command 0x0d
-#define Misc_Command 0x0f
-#define Port_A 0x19
-#define Port_B 0x1b
-#define Port_C 0x1d
-#define Configuration 0x1f
-#define Strobes 0x01
-#define Channel_A_Mode 0x03
-#define Channel_B_Mode 0x05
-#define Channel_C_Mode 0x07
-#define AI_AO_Select 0x09
-enum AI_AO_Select_Bits {
- AI_DMA_Select_Shift = 0,
- AI_DMA_Select_Mask = 0xf,
- AO_DMA_Select_Shift = 4,
- AO_DMA_Select_Mask = 0xf << AO_DMA_Select_Shift
-};
-#define G0_G1_Select 0x0b
-static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel)
-{
- if (channel < 4)
- return 1 << channel;
- if (channel == 4)
- return 0x3;
- if (channel == 5)
- return 0x5;
- BUG();
- return 0;
-}
-
-static inline unsigned GPCT_DMA_Select_Bits(unsigned gpct_index,
- unsigned mite_channel)
-{
- BUG_ON(gpct_index > 1);
- return ni_stc_dma_channel_select_bitfield(mite_channel) << (4 *
- gpct_index);
-}
-
-static inline unsigned GPCT_DMA_Select_Mask(unsigned gpct_index)
-{
- BUG_ON(gpct_index > 1);
- return 0xf << (4 * gpct_index);
-}
-
-/* 16 bit registers */
-
-#define Configuration_Memory_Low 0x10
-enum Configuration_Memory_Low_Bits {
- AI_DITHER = 0x200,
- AI_LAST_CHANNEL = 0x8000,
-};
-#define Configuration_Memory_High 0x12
-enum Configuration_Memory_High_Bits {
- AI_AC_COUPLE = 0x800,
- AI_DIFFERENTIAL = 0x1000,
- AI_COMMON = 0x2000,
- AI_GROUND = 0x3000,
-};
-static inline unsigned int AI_CONFIG_CHANNEL(unsigned int channel)
-{
- return channel & 0x3f;
-}
-
-#define ADC_FIFO_Data_Register 0x1c
-
-#define AO_Configuration 0x16
-#define AO_Bipolar _bit0
-#define AO_Deglitch _bit1
-#define AO_Ext_Ref _bit2
-#define AO_Ground_Ref _bit3
-#define AO_Channel(x) ((x) << 8)
-
-#define DAC_FIFO_Data 0x1e
-#define DAC0_Direct_Data 0x18
-#define DAC1_Direct_Data 0x1a
-
-/* 611x registers (these boards differ from the e-series) */
-
-#define Magic_611x 0x19 /* w8 (new) */
-#define Calibration_Channel_Select_611x 0x1a /* w16 (new) */
-#define ADC_FIFO_Data_611x 0x1c /* r32 (incompatible) */
-#define AI_FIFO_Offset_Load_611x 0x05 /* r8 (new) */
-#define DAC_FIFO_Data_611x 0x14 /* w32 (incompatible) */
-#define Cal_Gain_Select_611x 0x05 /* w8 (new) */
-
-#define AO_Window_Address_611x 0x18
-#define AO_Window_Data_611x 0x1e
-
-/* 6143 registers */
-#define Magic_6143 0x19 /* w8 */
-#define G0G1_DMA_Select_6143 0x0B /* w8 */
-#define PipelineDelay_6143 0x1f /* w8 */
-#define EOC_Set_6143 0x1D /* w8 */
-#define AIDMA_Select_6143 0x09 /* w8 */
-#define AIFIFO_Data_6143 0x8C /* w32 */
-#define AIFIFO_Flag_6143 0x84 /* w32 */
-#define AIFIFO_Control_6143 0x88 /* w32 */
-#define AIFIFO_Status_6143 0x88 /* w32 */
-#define AIFIFO_DMAThreshold_6143 0x90 /* w32 */
-#define AIFIFO_Words_Available_6143 0x94 /* w32 */
-
-#define Calibration_Channel_6143 0x42 /* w16 */
-#define Calibration_LowTime_6143 0x20 /* w16 */
-#define Calibration_HighTime_6143 0x22 /* w16 */
-#define Relay_Counter_Load_Val__6143 0x4C /* w32 */
-#define Signature_6143 0x50 /* w32 */
-#define Release_Date_6143 0x54 /* w32 */
-#define Release_Oldest_Date_6143 0x58 /* w32 */
-
-#define Calibration_Channel_6143_RelayOn 0x8000 /* Calibration relay switch On */
-#define Calibration_Channel_6143_RelayOff 0x4000 /* Calibration relay switch Off */
-#define Calibration_Channel_Gnd_Gnd 0x00 /* Offset Calibration */
-#define Calibration_Channel_2v5_Gnd 0x02 /* 2.5V Reference */
-#define Calibration_Channel_Pwm_Gnd 0x05 /* +/- 5V Self Cal */
-#define Calibration_Channel_2v5_Pwm 0x0a /* PWM Calibration */
-#define Calibration_Channel_Pwm_Pwm 0x0d /* CMRR */
-#define Calibration_Channel_Gnd_Pwm 0x0e /* PWM Calibration */
-
-/* 671x, 611x registers */
-
-/* 671xi, 611x windowed ao registers */
-enum windowed_regs_67xx_61xx {
- AO_Immediate_671x = 0x11, /* W 16 */
- AO_Timed_611x = 0x10, /* W 16 */
- AO_FIFO_Offset_Load_611x = 0x13, /* W32 */
- AO_Later_Single_Point_Updates = 0x14, /* W 16 */
- AO_Waveform_Generation_611x = 0x15, /* W 16 */
- AO_Misc_611x = 0x16, /* W 16 */
- AO_Calibration_Channel_Select_67xx = 0x17, /* W 16 */
- AO_Configuration_2_67xx = 0x18, /* W 16 */
- CAL_ADC_Command_67xx = 0x19, /* W 8 */
- CAL_ADC_Status_67xx = 0x1a, /* R 8 */
- CAL_ADC_Data_67xx = 0x1b, /* R 16 */
- CAL_ADC_Config_Data_High_Word_67xx = 0x1c, /* RW 16 */
- CAL_ADC_Config_Data_Low_Word_67xx = 0x1d, /* RW 16 */
+/*
+ * M-Series specific registers not handled by the DAQ-STC and GPCT register
+ * remapping.
+ */
+#define NI_M_CDIO_DMA_SEL_REG 0x007
+#define NI_M_CDIO_DMA_SEL_CDO(x) (((x) & 0xf) << 4)
+#define NI_M_CDIO_DMA_SEL_CDO_MASK NI_M_CDIO_DMA_SEL_CDO(0xf)
+#define NI_M_CDIO_DMA_SEL_CDI(x) (((x) & 0xf) << 0)
+#define NI_M_CDIO_DMA_SEL_CDI_MASK NI_M_CDIO_DMA_SEL_CDI(0xf)
+#define NI_M_SCXI_STATUS_REG 0x007
+#define NI_M_AI_AO_SEL_REG 0x009
+#define NI_M_G0_G1_SEL_REG 0x00b
+#define NI_M_MISC_CMD_REG 0x00f
+#define NI_M_SCXI_SER_DO_REG 0x011
+#define NI_M_SCXI_CTRL_REG 0x013
+#define NI_M_SCXI_OUT_ENA_REG 0x015
+#define NI_M_AI_FIFO_DATA_REG 0x01c
+#define NI_M_DIO_REG 0x024
+#define NI_M_DIO_DIR_REG 0x028
+#define NI_M_CAL_PWM_REG 0x040
+#define NI_M_CAL_PWM_HIGH_TIME(x) (((x) & 0xffff) << 16)
+#define NI_M_CAL_PWM_LOW_TIME(x) (((x) & 0xffff) << 0)
+#define NI_M_GEN_PWM_REG(x) (0x044 + ((x) * 2))
+#define NI_M_AI_CFG_FIFO_DATA_REG 0x05e
+#define NI_M_AI_CFG_LAST_CHAN BIT(14)
+#define NI_M_AI_CFG_DITHER BIT(13)
+#define NI_M_AI_CFG_POLARITY BIT(12)
+#define NI_M_AI_CFG_GAIN(x) (((x) & 0x7) << 9)
+#define NI_M_AI_CFG_CHAN_TYPE(x) (((x) & 0x7) << 6)
+#define NI_M_AI_CFG_CHAN_TYPE_MASK NI_M_AI_CFG_CHAN_TYPE(7)
+#define NI_M_AI_CFG_CHAN_TYPE_CALIB NI_M_AI_CFG_CHAN_TYPE(0)
+#define NI_M_AI_CFG_CHAN_TYPE_DIFF NI_M_AI_CFG_CHAN_TYPE(1)
+#define NI_M_AI_CFG_CHAN_TYPE_COMMON NI_M_AI_CFG_CHAN_TYPE(2)
+#define NI_M_AI_CFG_CHAN_TYPE_GROUND NI_M_AI_CFG_CHAN_TYPE(3)
+#define NI_M_AI_CFG_CHAN_TYPE_AUX NI_M_AI_CFG_CHAN_TYPE(5)
+#define NI_M_AI_CFG_CHAN_TYPE_GHOST NI_M_AI_CFG_CHAN_TYPE(7)
+#define NI_M_AI_CFG_BANK_SEL(x) ((((x) & 0x40) << 4) | ((x) & 0x30))
+#define NI_M_AI_CFG_CHAN_SEL(x) (((x) & 0xf) << 0)
+#define NI_M_INTC_ENA_REG 0x088
+#define NI_M_INTC_ENA BIT(0)
+#define NI_M_INTC_STATUS_REG 0x088
+#define NI_M_INTC_STATUS BIT(0)
+#define NI_M_ATRIG_CTRL_REG 0x08c
+#define NI_M_AO_SER_INT_ENA_REG 0x0a0
+#define NI_M_AO_SER_INT_ACK_REG 0x0a1
+#define NI_M_AO_SER_INT_STATUS_REG 0x0a1
+#define NI_M_AO_CALIB_REG 0x0a3
+#define NI_M_AO_FIFO_DATA_REG 0x0a4
+#define NI_M_PFI_FILTER_REG 0x0b0
+#define NI_M_PFI_FILTER_SEL(_c, _f) (((_f) & 0x3) << ((_c) * 2))
+#define NI_M_PFI_FILTER_SEL_MASK(_c) NI_M_PFI_FILTER_SEL((_c), 0x3)
+#define NI_M_RTSI_FILTER_REG 0x0b4
+#define NI_M_SCXI_LEGACY_COMPAT_REG 0x0bc
+#define NI_M_DAC_DIRECT_DATA_REG(x) (0x0c0 + ((x) * 4))
+#define NI_M_AO_WAVEFORM_ORDER_REG(x) (0x0c2 + ((x) * 4))
+#define NI_M_AO_CFG_BANK_REG(x) (0x0c3 + ((x) * 4))
+#define NI_M_AO_CFG_BANK_BIPOLAR BIT(7)
+#define NI_M_AO_CFG_BANK_UPDATE_TIMED BIT(6)
+#define NI_M_AO_CFG_BANK_REF(x) (((x) & 0x7) << 3)
+#define NI_M_AO_CFG_BANK_REF_MASK NI_M_AO_CFG_BANK_REF(7)
+#define NI_M_AO_CFG_BANK_REF_INT_10V NI_M_AO_CFG_BANK_REF(0)
+#define NI_M_AO_CFG_BANK_REF_INT_5V NI_M_AO_CFG_BANK_REF(1)
+#define NI_M_AO_CFG_BANK_OFFSET(x) (((x) & 0x7) << 0)
+#define NI_M_AO_CFG_BANK_OFFSET_MASK NI_M_AO_CFG_BANK_OFFSET(7)
+#define NI_M_AO_CFG_BANK_OFFSET_0V NI_M_AO_CFG_BANK_OFFSET(0)
+#define NI_M_AO_CFG_BANK_OFFSET_5V NI_M_AO_CFG_BANK_OFFSET(1)
+#define NI_M_RTSI_SHARED_MUX_REG 0x1a2
+#define NI_M_CLK_FOUT2_REG 0x1c4
+#define NI_M_CLK_FOUT2_RTSI_10MHZ BIT(7)
+#define NI_M_CLK_FOUT2_TIMEBASE3_PLL BIT(6)
+#define NI_M_CLK_FOUT2_TIMEBASE1_PLL BIT(5)
+#define NI_M_CLK_FOUT2_PLL_SRC(x) (((x) & 0x1f) << 0)
+#define NI_M_CLK_FOUT2_PLL_SRC_MASK NI_M_CLK_FOUT2_PLL_SRC(0x1f)
+#define NI_M_MAX_RTSI_CHAN 7
+#define NI_M_CLK_FOUT2_PLL_SRC_RTSI(x) (((x) == NI_M_MAX_RTSI_CHAN) \
+ ? NI_M_CLK_FOUT2_PLL_SRC(0x1b) \
+ : NI_M_CLK_FOUT2_PLL_SRC(0xb + (x)))
+#define NI_M_CLK_FOUT2_PLL_SRC_STAR NI_M_CLK_FOUT2_PLL_SRC(0x14)
+#define NI_M_CLK_FOUT2_PLL_SRC_PXI10 NI_M_CLK_FOUT2_PLL_SRC(0x1d)
+#define NI_M_PLL_CTRL_REG 0x1c6
+#define NI_M_PLL_CTRL_VCO_MODE(x) (((x) & 0x3) << 13)
+#define NI_M_PLL_CTRL_VCO_MODE_200_325MHZ NI_M_PLL_CTRL_VCO_MODE(0)
+#define NI_M_PLL_CTRL_VCO_MODE_175_225MHZ NI_M_PLL_CTRL_VCO_MODE(1)
+#define NI_M_PLL_CTRL_VCO_MODE_100_225MHZ NI_M_PLL_CTRL_VCO_MODE(2)
+#define NI_M_PLL_CTRL_VCO_MODE_75_150MHZ NI_M_PLL_CTRL_VCO_MODE(3)
+#define NI_M_PLL_CTRL_ENA BIT(12)
+#define NI_M_PLL_MAX_DIVISOR 0x10
+#define NI_M_PLL_CTRL_DIVISOR(x) (((x) & 0xf) << 8)
+#define NI_M_PLL_MAX_MULTIPLIER 0x100
+#define NI_M_PLL_CTRL_MULTIPLIER(x) (((x) & 0xff) << 0)
+#define NI_M_PLL_STATUS_REG 0x1c8
+#define NI_M_PLL_STATUS_LOCKED BIT(0)
+#define NI_M_PFI_OUT_SEL_REG(x) (0x1d0 + ((x) * 2))
+#define NI_M_PFI_CHAN(_c) (((_c) % 3) * 5)
+#define NI_M_PFI_OUT_SEL(_c, _s) (((_s) & 0x1f) << NI_M_PFI_CHAN(_c))
+#define NI_M_PFI_OUT_SEL_MASK(_c) (0x1f << NI_M_PFI_CHAN(_c))
+#define NI_M_PFI_OUT_SEL_TO_SRC(_c, _b) (((_b) >> NI_M_PFI_CHAN(_c)) & 0x1f)
+#define NI_M_PFI_DI_REG 0x1dc
+#define NI_M_PFI_DO_REG 0x1de
+#define NI_M_CFG_BYPASS_FIFO_REG 0x218
+#define NI_M_CFG_BYPASS_FIFO BIT(31)
+#define NI_M_CFG_BYPASS_AI_POLARITY BIT(22)
+#define NI_M_CFG_BYPASS_AI_DITHER BIT(21)
+#define NI_M_CFG_BYPASS_AI_GAIN(x) (((x) & 0x7) << 18)
+#define NI_M_CFG_BYPASS_AO_CAL(x) (((x) & 0xf) << 15)
+#define NI_M_CFG_BYPASS_AO_CAL_MASK NI_M_CFG_BYPASS_AO_CAL(0xf)
+#define NI_M_CFG_BYPASS_AI_MODE_MUX(x) (((x) & 0x3) << 13)
+#define NI_M_CFG_BYPASS_AI_MODE_MUX_MASK NI_M_CFG_BYPASS_AI_MODE_MUX(3)
+#define NI_M_CFG_BYPASS_AI_CAL_NEG(x) (((x) & 0x7) << 10)
+#define NI_M_CFG_BYPASS_AI_CAL_NEG_MASK NI_M_CFG_BYPASS_AI_CAL_NEG(7)
+#define NI_M_CFG_BYPASS_AI_CAL_POS(x) (((x) & 0x7) << 7)
+#define NI_M_CFG_BYPASS_AI_CAL_POS_MASK NI_M_CFG_BYPASS_AI_CAL_POS(7)
+#define NI_M_CFG_BYPASS_AI_CAL_MASK (NI_M_CFG_BYPASS_AI_CAL_POS_MASK | \
+ NI_M_CFG_BYPASS_AI_CAL_NEG_MASK | \
+ NI_M_CFG_BYPASS_AI_MODE_MUX_MASK | \
+ NI_M_CFG_BYPASS_AO_CAL_MASK)
+#define NI_M_CFG_BYPASS_AI_BANK(x) (((x) & 0xf) << 3)
+#define NI_M_CFG_BYPASS_AI_BANK_MASK NI_M_CFG_BYPASS_AI_BANK(0xf)
+#define NI_M_CFG_BYPASS_AI_CHAN(x) (((x) & 0x7) << 0)
+#define NI_M_CFG_BYPASS_AI_CHAN_MASK NI_M_CFG_BYPASS_AI_CHAN(7)
+#define NI_M_SCXI_DIO_ENA_REG 0x21c
+#define NI_M_CDI_FIFO_DATA_REG 0x220
+#define NI_M_CDO_FIFO_DATA_REG 0x220
+#define NI_M_CDIO_STATUS_REG 0x224
+#define NI_M_CDIO_STATUS_CDI_OVERFLOW BIT(20)
+#define NI_M_CDIO_STATUS_CDI_OVERRUN BIT(19)
+#define NI_M_CDIO_STATUS_CDI_ERROR (NI_M_CDIO_STATUS_CDI_OVERFLOW | \
+ NI_M_CDIO_STATUS_CDI_OVERRUN)
+#define NI_M_CDIO_STATUS_CDI_FIFO_REQ BIT(18)
+#define NI_M_CDIO_STATUS_CDI_FIFO_FULL BIT(17)
+#define NI_M_CDIO_STATUS_CDI_FIFO_EMPTY BIT(16)
+#define NI_M_CDIO_STATUS_CDO_UNDERFLOW BIT(4)
+#define NI_M_CDIO_STATUS_CDO_OVERRUN BIT(3)
+#define NI_M_CDIO_STATUS_CDO_ERROR (NI_M_CDIO_STATUS_CDO_UNDERFLOW | \
+ NI_M_CDIO_STATUS_CDO_OVERRUN)
+#define NI_M_CDIO_STATUS_CDO_FIFO_REQ BIT(2)
+#define NI_M_CDIO_STATUS_CDO_FIFO_FULL BIT(1)
+#define NI_M_CDIO_STATUS_CDO_FIFO_EMPTY BIT(0)
+#define NI_M_CDIO_CMD_REG 0x224
+#define NI_M_CDI_CMD_SW_UPDATE BIT(20)
+#define NI_M_CDO_CMD_SW_UPDATE BIT(19)
+#define NI_M_CDO_CMD_F_E_INT_ENA_CLR BIT(17)
+#define NI_M_CDO_CMD_F_E_INT_ENA_SET BIT(16)
+#define NI_M_CDI_CMD_ERR_INT_CONFIRM BIT(15)
+#define NI_M_CDO_CMD_ERR_INT_CONFIRM BIT(14)
+#define NI_M_CDI_CMD_F_REQ_INT_ENA_CLR BIT(13)
+#define NI_M_CDI_CMD_F_REQ_INT_ENA_SET BIT(12)
+#define NI_M_CDO_CMD_F_REQ_INT_ENA_CLR BIT(11)
+#define NI_M_CDO_CMD_F_REQ_INT_ENA_SET BIT(10)
+#define NI_M_CDI_CMD_ERR_INT_ENA_CLR BIT(9)
+#define NI_M_CDI_CMD_ERR_INT_ENA_SET BIT(8)
+#define NI_M_CDO_CMD_ERR_INT_ENA_CLR BIT(7)
+#define NI_M_CDO_CMD_ERR_INT_ENA_SET BIT(6)
+#define NI_M_CDI_CMD_RESET BIT(5)
+#define NI_M_CDO_CMD_RESET BIT(4)
+#define NI_M_CDI_CMD_ARM BIT(3)
+#define NI_M_CDI_CMD_DISARM BIT(2)
+#define NI_M_CDO_CMD_ARM BIT(1)
+#define NI_M_CDO_CMD_DISARM BIT(0)
+#define NI_M_CDI_MODE_REG 0x228
+#define NI_M_CDI_MODE_DATA_LANE(x) (((x) & 0x3) << 12)
+#define NI_M_CDI_MODE_DATA_LANE_MASK NI_M_CDI_MODE_DATA_LANE(3)
+#define NI_M_CDI_MODE_DATA_LANE_0_15 NI_M_CDI_MODE_DATA_LANE(0)
+#define NI_M_CDI_MODE_DATA_LANE_16_31 NI_M_CDI_MODE_DATA_LANE(1)
+#define NI_M_CDI_MODE_DATA_LANE_0_7 NI_M_CDI_MODE_DATA_LANE(0)
+#define NI_M_CDI_MODE_DATA_LANE_8_15 NI_M_CDI_MODE_DATA_LANE(1)
+#define NI_M_CDI_MODE_DATA_LANE_16_23 NI_M_CDI_MODE_DATA_LANE(2)
+#define NI_M_CDI_MODE_DATA_LANE_24_31 NI_M_CDI_MODE_DATA_LANE(3)
+#define NI_M_CDI_MODE_FIFO_MODE BIT(11)
+#define NI_M_CDI_MODE_POLARITY BIT(10)
+#define NI_M_CDI_MODE_HALT_ON_ERROR BIT(9)
+#define NI_M_CDI_MODE_SAMPLE_SRC(x) (((x) & 0x3f) << 0)
+#define NI_M_CDI_MODE_SAMPLE_SRC_MASK NI_M_CDI_MODE_SAMPLE_SRC(0x3f)
+#define NI_M_CDO_MODE_REG 0x22c
+#define NI_M_CDO_MODE_DATA_LANE(x) (((x) & 0x3) << 12)
+#define NI_M_CDO_MODE_DATA_LANE_MASK NI_M_CDO_MODE_DATA_LANE(3)
+#define NI_M_CDO_MODE_DATA_LANE_0_15 NI_M_CDO_MODE_DATA_LANE(0)
+#define NI_M_CDO_MODE_DATA_LANE_16_31 NI_M_CDO_MODE_DATA_LANE(1)
+#define NI_M_CDO_MODE_DATA_LANE_0_7 NI_M_CDO_MODE_DATA_LANE(0)
+#define NI_M_CDO_MODE_DATA_LANE_8_15 NI_M_CDO_MODE_DATA_LANE(1)
+#define NI_M_CDO_MODE_DATA_LANE_16_23 NI_M_CDO_MODE_DATA_LANE(2)
+#define NI_M_CDO_MODE_DATA_LANE_24_31 NI_M_CDO_MODE_DATA_LANE(3)
+#define NI_M_CDO_MODE_FIFO_MODE BIT(11)
+#define NI_M_CDO_MODE_POLARITY BIT(10)
+#define NI_M_CDO_MODE_HALT_ON_ERROR BIT(9)
+#define NI_M_CDO_MODE_RETRANSMIT BIT(8)
+#define NI_M_CDO_MODE_SAMPLE_SRC(x) (((x) & 0x3f) << 0)
+#define NI_M_CDO_MODE_SAMPLE_SRC_MASK NI_M_CDO_MODE_SAMPLE_SRC(0x3f)
+#define NI_M_CDI_MASK_ENA_REG 0x230
+#define NI_M_CDO_MASK_ENA_REG 0x234
+#define NI_M_STATIC_AI_CTRL_REG(x) ((x) ? (0x260 + (x)) : 0x064)
+#define NI_M_AO_REF_ATTENUATION_REG(x) (0x264 + (x))
+#define NI_M_AO_REF_ATTENUATION_X5 BIT(0)
+
+enum {
+ ai_gain_16 = 0,
+ ai_gain_8,
+ ai_gain_14,
+ ai_gain_4,
+ ai_gain_611x,
+ ai_gain_622x,
+ ai_gain_628x,
+ ai_gain_6143
};
-static inline unsigned int DACx_Direct_Data_671x(int channel)
-{
- return channel;
-}
-enum AO_Misc_611x_Bits {
- CLEAR_WG = 1,
+enum caldac_enum {
+ caldac_none = 0,
+ mb88341,
+ dac8800,
+ dac8043,
+ ad8522,
+ ad8804,
+ ad8842,
+ ad8804_debug
};
-enum cs5529_configuration_bits {
- CSCFG_CAL_CONTROL_MASK = 0x7,
- CSCFG_SELF_CAL_OFFSET = 0x1,
- CSCFG_SELF_CAL_GAIN = 0x2,
- CSCFG_SELF_CAL_OFFSET_GAIN = 0x3,
- CSCFG_SYSTEM_CAL_OFFSET = 0x5,
- CSCFG_SYSTEM_CAL_GAIN = 0x6,
- CSCFG_DONE = 1 << 3,
- CSCFG_POWER_SAVE_SELECT = 1 << 4,
- CSCFG_PORT_MODE = 1 << 5,
- CSCFG_RESET_VALID = 1 << 6,
- CSCFG_RESET = 1 << 7,
- CSCFG_UNIPOLAR = 1 << 12,
- CSCFG_WORD_RATE_2180_CYCLES = 0x0 << 13,
- CSCFG_WORD_RATE_1092_CYCLES = 0x1 << 13,
- CSCFG_WORD_RATE_532_CYCLES = 0x2 << 13,
- CSCFG_WORD_RATE_388_CYCLES = 0x3 << 13,
- CSCFG_WORD_RATE_324_CYCLES = 0x4 << 13,
- CSCFG_WORD_RATE_17444_CYCLES = 0x5 << 13,
- CSCFG_WORD_RATE_8724_CYCLES = 0x6 << 13,
- CSCFG_WORD_RATE_4364_CYCLES = 0x7 << 13,
- CSCFG_WORD_RATE_MASK = 0x7 << 13,
- CSCFG_LOW_POWER = 1 << 16,
-};
-static inline unsigned int CS5529_CONFIG_DOUT(int output)
-{
- return 1 << (18 + output);
-}
-
-static inline unsigned int CS5529_CONFIG_AOUT(int output)
-{
- return 1 << (22 + output);
-}
-
-enum cs5529_command_bits {
- CSCMD_POWER_SAVE = 0x1,
- CSCMD_REGISTER_SELECT_MASK = 0xe,
- CSCMD_OFFSET_REGISTER = 0x0,
- CSCMD_GAIN_REGISTER = 0x2,
- CSCMD_CONFIG_REGISTER = 0x4,
- CSCMD_READ = 0x10,
- CSCMD_CONTINUOUS_CONVERSIONS = 0x20,
- CSCMD_SINGLE_CONVERSION = 0x40,
- CSCMD_COMMAND = 0x80,
-};
-enum cs5529_status_bits {
- CSS_ADC_BUSY = 0x1,
- CSS_OSC_DETECT = 0x2, /* indicates adc error */
- CSS_OVERRANGE = 0x4,
-};
-#define SerDacLd(x) (0x08<<(x))
-
-/*
- This is stuff unique to the NI E series drivers,
- but I thought I'd put it here anyway.
-*/
-enum { ai_gain_16 =
- 0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x, ai_gain_622x,
- ai_gain_628x, ai_gain_6143
-};
-enum caldac_enum { caldac_none = 0, mb88341, dac8800, dac8043, ad8522,
- ad8804, ad8842, ad8804_debug
-};
enum ni_reg_type {
ni_reg_normal = 0x0,
ni_reg_611x = 0x1,
@@ -918,467 +941,6 @@ enum ni_reg_type {
ni_reg_6143 = 0x20
};
-static const struct comedi_lrange range_ni_E_ao_ext;
-
-enum m_series_register_offsets {
- M_Offset_CDIO_DMA_Select = 0x7, /* write */
- M_Offset_SCXI_Status = 0x7, /* read */
- M_Offset_AI_AO_Select = 0x9, /* write, same offset as e-series */
- M_Offset_SCXI_Serial_Data_In = 0x9, /* read */
- M_Offset_G0_G1_Select = 0xb, /* write, same offset as e-series */
- M_Offset_Misc_Command = 0xf,
- M_Offset_SCXI_Serial_Data_Out = 0x11,
- M_Offset_SCXI_Control = 0x13,
- M_Offset_SCXI_Output_Enable = 0x15,
- M_Offset_AI_FIFO_Data = 0x1c,
- M_Offset_Static_Digital_Output = 0x24, /* write */
- M_Offset_Static_Digital_Input = 0x24, /* read */
- M_Offset_DIO_Direction = 0x28,
- M_Offset_Cal_PWM = 0x40,
- M_Offset_AI_Config_FIFO_Data = 0x5e,
- M_Offset_Interrupt_C_Enable = 0x88, /* write */
- M_Offset_Interrupt_C_Status = 0x88, /* read */
- M_Offset_Analog_Trigger_Control = 0x8c,
- M_Offset_AO_Serial_Interrupt_Enable = 0xa0,
- M_Offset_AO_Serial_Interrupt_Ack = 0xa1, /* write */
- M_Offset_AO_Serial_Interrupt_Status = 0xa1, /* read */
- M_Offset_AO_Calibration = 0xa3,
- M_Offset_AO_FIFO_Data = 0xa4,
- M_Offset_PFI_Filter = 0xb0,
- M_Offset_RTSI_Filter = 0xb4,
- M_Offset_SCXI_Legacy_Compatibility = 0xbc,
- M_Offset_Interrupt_A_Ack = 0x104, /* write */
- M_Offset_AI_Status_1 = 0x104, /* read */
- M_Offset_Interrupt_B_Ack = 0x106, /* write */
- M_Offset_AO_Status_1 = 0x106, /* read */
- M_Offset_AI_Command_2 = 0x108, /* write */
- M_Offset_G01_Status = 0x108, /* read */
- M_Offset_AO_Command_2 = 0x10a,
- M_Offset_AO_Status_2 = 0x10c, /* read */
- M_Offset_G0_Command = 0x10c, /* write */
- M_Offset_G1_Command = 0x10e, /* write */
- M_Offset_G0_HW_Save = 0x110,
- M_Offset_G0_HW_Save_High = 0x110,
- M_Offset_AI_Command_1 = 0x110,
- M_Offset_G0_HW_Save_Low = 0x112,
- M_Offset_AO_Command_1 = 0x112,
- M_Offset_G1_HW_Save = 0x114,
- M_Offset_G1_HW_Save_High = 0x114,
- M_Offset_G1_HW_Save_Low = 0x116,
- M_Offset_AI_Mode_1 = 0x118,
- M_Offset_G0_Save = 0x118,
- M_Offset_G0_Save_High = 0x118,
- M_Offset_AI_Mode_2 = 0x11a,
- M_Offset_G0_Save_Low = 0x11a,
- M_Offset_AI_SI_Load_A = 0x11c,
- M_Offset_G1_Save = 0x11c,
- M_Offset_G1_Save_High = 0x11c,
- M_Offset_G1_Save_Low = 0x11e,
- M_Offset_AI_SI_Load_B = 0x120, /* write */
- M_Offset_AO_UI_Save = 0x120, /* read */
- M_Offset_AI_SC_Load_A = 0x124, /* write */
- M_Offset_AO_BC_Save = 0x124, /* read */
- M_Offset_AI_SC_Load_B = 0x128, /* write */
- M_Offset_AO_UC_Save = 0x128, /* read */
- M_Offset_AI_SI2_Load_A = 0x12c,
- M_Offset_AI_SI2_Load_B = 0x130,
- M_Offset_G0_Mode = 0x134,
- M_Offset_G1_Mode = 0x136, /* write */
- M_Offset_Joint_Status_1 = 0x136, /* read */
- M_Offset_G0_Load_A = 0x138,
- M_Offset_Joint_Status_2 = 0x13a,
- M_Offset_G0_Load_B = 0x13c,
- M_Offset_G1_Load_A = 0x140,
- M_Offset_G1_Load_B = 0x144,
- M_Offset_G0_Input_Select = 0x148,
- M_Offset_G1_Input_Select = 0x14a,
- M_Offset_AO_Mode_1 = 0x14c,
- M_Offset_AO_Mode_2 = 0x14e,
- M_Offset_AO_UI_Load_A = 0x150,
- M_Offset_AO_UI_Load_B = 0x154,
- M_Offset_AO_BC_Load_A = 0x158,
- M_Offset_AO_BC_Load_B = 0x15c,
- M_Offset_AO_UC_Load_A = 0x160,
- M_Offset_AO_UC_Load_B = 0x164,
- M_Offset_Clock_and_FOUT = 0x170,
- M_Offset_IO_Bidirection_Pin = 0x172,
- M_Offset_RTSI_Trig_Direction = 0x174,
- M_Offset_Interrupt_Control = 0x176,
- M_Offset_AI_Output_Control = 0x178,
- M_Offset_Analog_Trigger_Etc = 0x17a,
- M_Offset_AI_START_STOP_Select = 0x17c,
- M_Offset_AI_Trigger_Select = 0x17e,
- M_Offset_AI_SI_Save = 0x180, /* read */
- M_Offset_AI_DIV_Load_A = 0x180, /* write */
- M_Offset_AI_SC_Save = 0x184, /* read */
- M_Offset_AO_Start_Select = 0x184, /* write */
- M_Offset_AO_Trigger_Select = 0x186,
- M_Offset_AO_Mode_3 = 0x18c,
- M_Offset_G0_Autoincrement = 0x188,
- M_Offset_G1_Autoincrement = 0x18a,
- M_Offset_Joint_Reset = 0x190,
- M_Offset_Interrupt_A_Enable = 0x192,
- M_Offset_Interrupt_B_Enable = 0x196,
- M_Offset_AI_Personal = 0x19a,
- M_Offset_AO_Personal = 0x19c,
- M_Offset_RTSI_Trig_A_Output = 0x19e,
- M_Offset_RTSI_Trig_B_Output = 0x1a0,
- M_Offset_RTSI_Shared_MUX = 0x1a2,
- M_Offset_AO_Output_Control = 0x1ac,
- M_Offset_AI_Mode_3 = 0x1ae,
- M_Offset_Configuration_Memory_Clear = 0x1a4,
- M_Offset_AI_FIFO_Clear = 0x1a6,
- M_Offset_AO_FIFO_Clear = 0x1a8,
- M_Offset_G0_Counting_Mode = 0x1b0,
- M_Offset_G1_Counting_Mode = 0x1b2,
- M_Offset_G0_Second_Gate = 0x1b4,
- M_Offset_G1_Second_Gate = 0x1b6,
- M_Offset_G0_DMA_Config = 0x1b8, /* write */
- M_Offset_G0_DMA_Status = 0x1b8, /* read */
- M_Offset_G1_DMA_Config = 0x1ba, /* write */
- M_Offset_G1_DMA_Status = 0x1ba, /* read */
- M_Offset_G0_MSeries_ABZ = 0x1c0,
- M_Offset_G1_MSeries_ABZ = 0x1c2,
- M_Offset_Clock_and_Fout2 = 0x1c4,
- M_Offset_PLL_Control = 0x1c6,
- M_Offset_PLL_Status = 0x1c8,
- M_Offset_PFI_Output_Select_1 = 0x1d0,
- M_Offset_PFI_Output_Select_2 = 0x1d2,
- M_Offset_PFI_Output_Select_3 = 0x1d4,
- M_Offset_PFI_Output_Select_4 = 0x1d6,
- M_Offset_PFI_Output_Select_5 = 0x1d8,
- M_Offset_PFI_Output_Select_6 = 0x1da,
- M_Offset_PFI_DI = 0x1dc,
- M_Offset_PFI_DO = 0x1de,
- M_Offset_AI_Config_FIFO_Bypass = 0x218,
- M_Offset_SCXI_DIO_Enable = 0x21c,
- M_Offset_CDI_FIFO_Data = 0x220, /* read */
- M_Offset_CDO_FIFO_Data = 0x220, /* write */
- M_Offset_CDIO_Status = 0x224, /* read */
- M_Offset_CDIO_Command = 0x224, /* write */
- M_Offset_CDI_Mode = 0x228,
- M_Offset_CDO_Mode = 0x22c,
- M_Offset_CDI_Mask_Enable = 0x230,
- M_Offset_CDO_Mask_Enable = 0x234,
-};
-static inline int M_Offset_AO_Waveform_Order(int channel)
-{
- return 0xc2 + 0x4 * channel;
-};
-
-static inline int M_Offset_AO_Config_Bank(int channel)
-{
- return 0xc3 + 0x4 * channel;
-};
-
-static inline int M_Offset_DAC_Direct_Data(int channel)
-{
- return 0xc0 + 0x4 * channel;
-}
-
-static inline int M_Offset_Gen_PWM(int channel)
-{
- return 0x44 + 0x2 * channel;
-}
-
-static inline int M_Offset_Static_AI_Control(int i)
-{
- int offset[] = {
- 0x64,
- 0x261,
- 0x262,
- 0x263,
- };
- if (((unsigned)i) >= ARRAY_SIZE(offset)) {
- pr_err("%s: invalid channel=%i\n", __func__, i);
- return offset[0];
- }
- return offset[i];
-};
-
-static inline int M_Offset_AO_Reference_Attenuation(int channel)
-{
- int offset[] = {
- 0x264,
- 0x265,
- 0x266,
- 0x267
- };
- if (((unsigned)channel) >= ARRAY_SIZE(offset)) {
- pr_err("%s: invalid channel=%i\n", __func__, channel);
- return offset[0];
- }
- return offset[channel];
-};
-
-static inline unsigned M_Offset_PFI_Output_Select(unsigned n)
-{
- if (n < 1 || n > NUM_PFI_OUTPUT_SELECT_REGS) {
- pr_err("%s: invalid pfi output select register=%i\n",
- __func__, n);
- return M_Offset_PFI_Output_Select_1;
- }
- return M_Offset_PFI_Output_Select_1 + (n - 1) * 2;
-}
-
-enum MSeries_AI_Config_FIFO_Data_Bits {
- MSeries_AI_Config_Channel_Type_Mask = 0x7 << 6,
- MSeries_AI_Config_Channel_Type_Calibration_Bits = 0x0,
- MSeries_AI_Config_Channel_Type_Differential_Bits = 0x1 << 6,
- MSeries_AI_Config_Channel_Type_Common_Ref_Bits = 0x2 << 6,
- MSeries_AI_Config_Channel_Type_Ground_Ref_Bits = 0x3 << 6,
- MSeries_AI_Config_Channel_Type_Aux_Bits = 0x5 << 6,
- MSeries_AI_Config_Channel_Type_Ghost_Bits = 0x7 << 6,
- MSeries_AI_Config_Polarity_Bit = 0x1000, /* 0 for 2's complement encoding */
- MSeries_AI_Config_Dither_Bit = 0x2000,
- MSeries_AI_Config_Last_Channel_Bit = 0x4000,
-};
-static inline unsigned MSeries_AI_Config_Channel_Bits(unsigned channel)
-{
- return channel & 0xf;
-}
-
-static inline unsigned MSeries_AI_Config_Bank_Bits(enum ni_reg_type reg_type,
- unsigned channel)
-{
- unsigned bits = channel & 0x30;
- if (reg_type == ni_reg_622x) {
- if (channel & 0x40)
- bits |= 0x400;
- }
- return bits;
-}
-
-static inline unsigned MSeries_AI_Config_Gain_Bits(unsigned range)
-{
- return (range & 0x7) << 9;
-}
-
-enum MSeries_Clock_and_Fout2_Bits {
- MSeries_PLL_In_Source_Select_RTSI0_Bits = 0xb,
- MSeries_PLL_In_Source_Select_Star_Trigger_Bits = 0x14,
- MSeries_PLL_In_Source_Select_RTSI7_Bits = 0x1b,
- MSeries_PLL_In_Source_Select_PXI_Clock10 = 0x1d,
- MSeries_PLL_In_Source_Select_Mask = 0x1f,
- MSeries_Timebase1_Select_Bit = 0x20, /* use PLL for timebase 1 */
- MSeries_Timebase3_Select_Bit = 0x40, /* use PLL for timebase 3 */
- /* use 10MHz instead of 20MHz for RTSI clock frequency. Appears
- to have no effect, at least on pxi-6281, which always uses
- 20MHz rtsi clock frequency */
- MSeries_RTSI_10MHz_Bit = 0x80
-};
-static inline unsigned MSeries_PLL_In_Source_Select_RTSI_Bits(unsigned
- RTSI_channel)
-{
- if (RTSI_channel > 7) {
- pr_err("%s: bug, invalid RTSI_channel=%i\n", __func__,
- RTSI_channel);
- return 0;
- }
- if (RTSI_channel == 7)
- return MSeries_PLL_In_Source_Select_RTSI7_Bits;
- else
- return MSeries_PLL_In_Source_Select_RTSI0_Bits + RTSI_channel;
-}
-
-enum MSeries_PLL_Control_Bits {
- MSeries_PLL_Enable_Bit = 0x1000,
- MSeries_PLL_VCO_Mode_200_325MHz_Bits = 0x0,
- MSeries_PLL_VCO_Mode_175_225MHz_Bits = 0x2000,
- MSeries_PLL_VCO_Mode_100_225MHz_Bits = 0x4000,
- MSeries_PLL_VCO_Mode_75_150MHz_Bits = 0x6000,
-};
-static inline unsigned MSeries_PLL_Divisor_Bits(unsigned divisor)
-{
- static const unsigned max_divisor = 0x10;
- if (divisor < 1 || divisor > max_divisor) {
- pr_err("%s: bug, invalid divisor=%i\n", __func__, divisor);
- return 0;
- }
- return (divisor & 0xf) << 8;
-}
-
-static inline unsigned MSeries_PLL_Multiplier_Bits(unsigned multiplier)
-{
- static const unsigned max_multiplier = 0x100;
- if (multiplier < 1 || multiplier > max_multiplier) {
- pr_err("%s: bug, invalid multiplier=%i\n", __func__,
- multiplier);
- return 0;
- }
- return multiplier & 0xff;
-}
-
-enum MSeries_PLL_Status {
- MSeries_PLL_Locked_Bit = 0x1
-};
-
-enum MSeries_AI_Config_FIFO_Bypass_Bits {
- MSeries_AI_Bypass_Channel_Mask = 0x7,
- MSeries_AI_Bypass_Bank_Mask = 0x78,
- MSeries_AI_Bypass_Cal_Sel_Pos_Mask = 0x380,
- MSeries_AI_Bypass_Cal_Sel_Neg_Mask = 0x1c00,
- MSeries_AI_Bypass_Mode_Mux_Mask = 0x6000,
- MSeries_AO_Bypass_AO_Cal_Sel_Mask = 0x38000,
- MSeries_AI_Bypass_Gain_Mask = 0x1c0000,
- MSeries_AI_Bypass_Dither_Bit = 0x200000,
- MSeries_AI_Bypass_Polarity_Bit = 0x400000, /* 0 for 2's complement encoding */
- MSeries_AI_Bypass_Config_FIFO_Bit = 0x80000000
-};
-static inline unsigned MSeries_AI_Bypass_Cal_Sel_Pos_Bits(int
- calibration_source)
-{
- return (calibration_source << 7) & MSeries_AI_Bypass_Cal_Sel_Pos_Mask;
-}
-
-static inline unsigned MSeries_AI_Bypass_Cal_Sel_Neg_Bits(int
- calibration_source)
-{
- return (calibration_source << 10) & MSeries_AI_Bypass_Cal_Sel_Pos_Mask;
-}
-
-static inline unsigned MSeries_AI_Bypass_Gain_Bits(int gain)
-{
- return (gain << 18) & MSeries_AI_Bypass_Gain_Mask;
-}
-
-enum MSeries_AO_Config_Bank_Bits {
- MSeries_AO_DAC_Offset_Select_Mask = 0x7,
- MSeries_AO_DAC_Offset_0V_Bits = 0x0,
- MSeries_AO_DAC_Offset_5V_Bits = 0x1,
- MSeries_AO_DAC_Reference_Mask = 0x38,
- MSeries_AO_DAC_Reference_10V_Internal_Bits = 0x0,
- MSeries_AO_DAC_Reference_5V_Internal_Bits = 0x8,
- MSeries_AO_Update_Timed_Bit = 0x40,
- MSeries_AO_Bipolar_Bit = 0x80 /* turns on 2's complement encoding */
-};
-
-enum MSeries_AO_Reference_Attenuation_Bits {
- MSeries_Attenuate_x5_Bit = 0x1
-};
-
-static inline unsigned MSeries_Cal_PWM_High_Time_Bits(unsigned count)
-{
- return (count << 16) & 0xffff0000;
-}
-
-static inline unsigned MSeries_Cal_PWM_Low_Time_Bits(unsigned count)
-{
- return count & 0xffff;
-}
-
-static inline unsigned MSeries_PFI_Output_Select_Mask(unsigned channel)
-{
- return 0x1f << (channel % 3) * 5;
-};
-
-static inline unsigned MSeries_PFI_Output_Select_Bits(unsigned channel,
- unsigned source)
-{
- return (source & 0x1f) << ((channel % 3) * 5);
-};
-
-/* inverse to MSeries_PFI_Output_Select_Bits */
-static inline unsigned MSeries_PFI_Output_Select_Source(unsigned channel,
- unsigned bits)
-{
- return (bits >> ((channel % 3) * 5)) & 0x1f;
-};
-
-static inline unsigned MSeries_PFI_Filter_Select_Mask(unsigned channel)
-{
- return 0x3 << (channel * 2);
-}
-
-static inline unsigned MSeries_PFI_Filter_Select_Bits(unsigned channel,
- unsigned filter)
-{
- return (filter << (channel *
- 2)) & MSeries_PFI_Filter_Select_Mask(channel);
-}
-
-enum CDIO_DMA_Select_Bits {
- CDI_DMA_Select_Shift = 0,
- CDI_DMA_Select_Mask = 0xf,
- CDO_DMA_Select_Shift = 4,
- CDO_DMA_Select_Mask = 0xf << CDO_DMA_Select_Shift
-};
-
-enum CDIO_Status_Bits {
- CDO_FIFO_Empty_Bit = 0x1,
- CDO_FIFO_Full_Bit = 0x2,
- CDO_FIFO_Request_Bit = 0x4,
- CDO_Overrun_Bit = 0x8,
- CDO_Underflow_Bit = 0x10,
- CDI_FIFO_Empty_Bit = 0x10000,
- CDI_FIFO_Full_Bit = 0x20000,
- CDI_FIFO_Request_Bit = 0x40000,
- CDI_Overrun_Bit = 0x80000,
- CDI_Overflow_Bit = 0x100000
-};
-
-enum CDIO_Command_Bits {
- CDO_Disarm_Bit = 0x1,
- CDO_Arm_Bit = 0x2,
- CDI_Disarm_Bit = 0x4,
- CDI_Arm_Bit = 0x8,
- CDO_Reset_Bit = 0x10,
- CDI_Reset_Bit = 0x20,
- CDO_Error_Interrupt_Enable_Set_Bit = 0x40,
- CDO_Error_Interrupt_Enable_Clear_Bit = 0x80,
- CDI_Error_Interrupt_Enable_Set_Bit = 0x100,
- CDI_Error_Interrupt_Enable_Clear_Bit = 0x200,
- CDO_FIFO_Request_Interrupt_Enable_Set_Bit = 0x400,
- CDO_FIFO_Request_Interrupt_Enable_Clear_Bit = 0x800,
- CDI_FIFO_Request_Interrupt_Enable_Set_Bit = 0x1000,
- CDI_FIFO_Request_Interrupt_Enable_Clear_Bit = 0x2000,
- CDO_Error_Interrupt_Confirm_Bit = 0x4000,
- CDI_Error_Interrupt_Confirm_Bit = 0x8000,
- CDO_Empty_FIFO_Interrupt_Enable_Set_Bit = 0x10000,
- CDO_Empty_FIFO_Interrupt_Enable_Clear_Bit = 0x20000,
- CDO_SW_Update_Bit = 0x80000,
- CDI_SW_Update_Bit = 0x100000
-};
-
-enum CDI_Mode_Bits {
- CDI_Sample_Source_Select_Mask = 0x3f,
- CDI_Halt_On_Error_Bit = 0x200,
- CDI_Polarity_Bit = 0x400, /* sample clock on falling edge */
- CDI_FIFO_Mode_Bit = 0x800, /* set for half full mode, clear for not empty mode */
- CDI_Data_Lane_Mask = 0x3000, /* data lanes specify which dio channels map to byte or word accesses to the dio fifos */
- CDI_Data_Lane_0_15_Bits = 0x0,
- CDI_Data_Lane_16_31_Bits = 0x1000,
- CDI_Data_Lane_0_7_Bits = 0x0,
- CDI_Data_Lane_8_15_Bits = 0x1000,
- CDI_Data_Lane_16_23_Bits = 0x2000,
- CDI_Data_Lane_24_31_Bits = 0x3000
-};
-
-enum CDO_Mode_Bits {
- CDO_Sample_Source_Select_Mask = 0x3f,
- CDO_Retransmit_Bit = 0x100,
- CDO_Halt_On_Error_Bit = 0x200,
- CDO_Polarity_Bit = 0x400, /* sample clock on falling edge */
- CDO_FIFO_Mode_Bit = 0x800, /* set for half full mode, clear for not full mode */
- CDO_Data_Lane_Mask = 0x3000, /* data lanes specify which dio channels map to byte or word accesses to the dio fifos */
- CDO_Data_Lane_0_15_Bits = 0x0,
- CDO_Data_Lane_16_31_Bits = 0x1000,
- CDO_Data_Lane_0_7_Bits = 0x0,
- CDO_Data_Lane_8_15_Bits = 0x1000,
- CDO_Data_Lane_16_23_Bits = 0x2000,
- CDO_Data_Lane_24_31_Bits = 0x3000
-};
-
-enum Interrupt_C_Enable_Bits {
- Interrupt_Group_C_Enable_Bit = 0x1
-};
-
-enum Interrupt_C_Status_Bits {
- Interrupt_Group_C_Status_Bit = 0x1
-};
-
-#define M_SERIES_EEPROM_SIZE 1024
-
struct ni_board_struct {
const char *name;
int device_id;
@@ -1405,9 +967,13 @@ struct ni_board_struct {
enum caldac_enum caldac[3];
};
-#define MAX_N_CALDACS 34
-#define MAX_N_AO_CHAN 8
-#define NUM_GPCT 2
+#define MAX_N_CALDACS 34
+#define MAX_N_AO_CHAN 8
+#define NUM_GPCT 2
+
+#define NUM_PFI_OUTPUT_SELECT_REGS 6
+
+#define M_SERIES_EEPROM_SIZE 1024
struct ni_private {
unsigned short dio_output;
@@ -1415,8 +981,11 @@ struct ni_private {
int aimode;
unsigned int ai_calib_source;
unsigned int ai_calib_source_enabled;
+ /* protects access to windowed registers */
spinlock_t window_lock;
+ /* protects interrupt/dma register access */
spinlock_t soft_reg_copy_lock;
+ /* protects mite DMA channel request/release */
spinlock_t mite_channel_lock;
int changain_state;
@@ -1488,4 +1057,6 @@ struct ni_private {
unsigned int is_6713:1;
};
+static const struct comedi_lrange range_ni_E_ao_ext;
+
#endif /* _COMEDI_NI_STC_H */
diff --git a/drivers/staging/comedi/drivers/pcl812.c b/drivers/staging/comedi/drivers/pcl812.c
index 03a3fd6cd918b4..48f6cdf440b991 100644
--- a/drivers/staging/comedi/drivers/pcl812.c
+++ b/drivers/staging/comedi/drivers/pcl812.c
@@ -507,11 +507,11 @@ static const struct pcl812_board boardtypes[] = {
struct pcl812_private {
struct comedi_isadma *dma;
- unsigned char range_correction; /* =1 we must add 1 to range number */
+ unsigned char range_correction; /* =1 we must add 1 to range number */
unsigned int last_ai_chanspec;
- unsigned char mode_reg_int; /* there is stored INT number for some card */
- unsigned int ai_poll_ptr; /* how many sampes transfer poll */
- unsigned int max_812_ai_mode0_rangewait; /* setling time for gain */
+ unsigned char mode_reg_int; /* stored INT number for some cards */
+ unsigned int ai_poll_ptr; /* how many samples transfer poll */
+ unsigned int max_812_ai_mode0_rangewait; /* settling time for gain */
unsigned int use_diff:1;
unsigned int use_mpc508:1;
unsigned int use_ext_trg:1;
@@ -1155,7 +1155,7 @@ static int pcl812_attach(struct comedi_device *dev, struct comedi_devconfig *it)
/* we need an IRQ to do DMA on channel 3 or 1 */
if (dev->irq && board->has_dma)
- pcl812_alloc_dma(dev, it->options[2]);
+ pcl812_alloc_dma(dev, it->options[2]);
/* differential analog inputs? */
switch (board->board_type) {
diff --git a/drivers/staging/comedi/drivers/pcl816.c b/drivers/staging/comedi/drivers/pcl816.c
index 1ccb2f19f4be68..781b321587dc60 100644
--- a/drivers/staging/comedi/drivers/pcl816.c
+++ b/drivers/staging/comedi/drivers/pcl816.c
@@ -323,7 +323,7 @@ static int check_channel_list(struct comedi_device *dev,
/* check whole chanlist */
for (i = 0, segpos = 0; i < chanlen; i++) {
- if (chanlist[i] != chansegment[i % seglen]) {
+ if (chanlist[i] != chansegment[i % seglen]) {
dev_dbg(dev->class_dev,
"bad channel or range number! chanlist[%i]=%d,%d,%d and not %d,%d,%d!\n",
i, CR_CHAN(chansegment[i]),
diff --git a/drivers/staging/comedi/drivers/serial2002.c b/drivers/staging/comedi/drivers/serial2002.c
index 304ebff119eeac..83da162deb526c 100644
--- a/drivers/staging/comedi/drivers/serial2002.c
+++ b/drivers/staging/comedi/drivers/serial2002.c
@@ -373,7 +373,7 @@ static int serial2002_setup_subdevice(struct comedi_subdevice *s,
if (cfg[j].kind == kind) {
if (mapping)
mapping[chan] = j;
- if (range) {
+ if (range && range_table_list) {
range[j].length = 1;
range[j].range.min = cfg[j].min;
range[j].range.max = cfg[j].max;
diff --git a/drivers/staging/dgap/dgap.c b/drivers/staging/dgap/dgap.c
index 6766d5a91a9080..26b0446d943af6 100644
--- a/drivers/staging/dgap/dgap.c
+++ b/drivers/staging/dgap/dgap.c
@@ -290,8 +290,7 @@ static struct toklist dgap_tlist[] = {
/*
* dgap_sindex: much like index(), but it looks for a match of any character in
- * the group, and returns that position. If the first character is a ^, then
- * this will match the first occurrence not in that group.
+ * the group, and returns that position.
*/
static char *dgap_sindex(char *string, char *group)
{
@@ -300,23 +299,11 @@ static char *dgap_sindex(char *string, char *group)
if (!string || !group)
return NULL;
- if (*group == '^') {
- group++;
- for (; *string; string++) {
- for (ptr = group; *ptr; ptr++) {
- if (*ptr == *string)
- break;
- }
- if (*ptr == '\0')
+ for (; *string; string++) {
+ for (ptr = group; *ptr; ptr++) {
+ if (*ptr == *string)
return string;
}
- } else {
- for (; *string; string++) {
- for (ptr = group; *ptr; ptr++) {
- if (*ptr == *string)
- return string;
- }
- }
}
return NULL;
@@ -2658,7 +2645,7 @@ static void dgap_cmdw_ext(struct channel_t *ch, u16 cmd, u16 word, uint ncmds)
* dgap_wmove - Write data to FEP buffer.
*
* ch - Pointer to channel structure.
- * buf - Poiter to characters to be moved.
+ * buf - Pointer to characters to be moved.
* cnt - Number of characters to move.
*
*=======================================================================*/
@@ -6987,9 +6974,62 @@ cleanup_brd:
return rc;
}
+/*
+ * dgap_cleanup_board()
+ *
+ * Free all the memory associated with a board
+ */
+static void dgap_cleanup_board(struct board_t *brd)
+{
+ unsigned int i;
+
+ if (!brd || brd->magic != DGAP_BOARD_MAGIC)
+ return;
+
+ dgap_free_irq(brd);
+
+ tasklet_kill(&brd->helper_tasklet);
+
+ dgap_unmap(brd);
+
+ /* Free all allocated channels structs */
+ for (i = 0; i < MAXPORTS ; i++)
+ kfree(brd->channels[i]);
+
+ kfree(brd->flipbuf);
+ kfree(brd->flipflagbuf);
+
+ dgap_board[brd->boardnum] = NULL;
+
+ kfree(brd);
+}
+
static void dgap_remove_one(struct pci_dev *dev)
{
- /* Do Nothing */
+ unsigned int i;
+ ulong lock_flags;
+ struct pci_driver *drv = to_pci_driver(dev->dev.driver);
+
+ spin_lock_irqsave(&dgap_poll_lock, lock_flags);
+ dgap_poll_stop = 1;
+ spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
+
+ /* Turn off poller right away. */
+ del_timer_sync(&dgap_poll_timer);
+
+ dgap_remove_driver_sysfiles(drv);
+
+ device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
+ class_destroy(dgap_class);
+ unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
+
+ for (i = 0; i < dgap_numboards; ++i) {
+ dgap_remove_ports_sysfiles(dgap_board[i]);
+ dgap_cleanup_tty(dgap_board[i]);
+ dgap_cleanup_board(dgap_board[i]);
+ }
+
+ dgap_cleanup_nodes();
}
static struct pci_driver dgap_driver = {
@@ -7071,37 +7111,6 @@ static void dgap_stop(void)
unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
}
-/*
- * dgap_cleanup_board()
- *
- * Free all the memory associated with a board
- */
-static void dgap_cleanup_board(struct board_t *brd)
-{
- unsigned int i;
-
- if (!brd || brd->magic != DGAP_BOARD_MAGIC)
- return;
-
- dgap_free_irq(brd);
-
- tasklet_kill(&brd->helper_tasklet);
-
- dgap_unmap(brd);
-
- /* Free all allocated channels structs */
- for (i = 0; i < MAXPORTS ; i++)
- kfree(brd->channels[i]);
-
- kfree(brd->flipbuf);
- kfree(brd->flipflagbuf);
-
- dgap_board[brd->boardnum] = NULL;
-
- kfree(brd);
-}
-
-
/************************************************************************
*
* Driver load/unload functions
@@ -7150,30 +7159,6 @@ err_stop:
*/
static void dgap_cleanup_module(void)
{
- unsigned int i;
- ulong lock_flags;
-
- spin_lock_irqsave(&dgap_poll_lock, lock_flags);
- dgap_poll_stop = 1;
- spin_unlock_irqrestore(&dgap_poll_lock, lock_flags);
-
- /* Turn off poller right away. */
- del_timer_sync(&dgap_poll_timer);
-
- dgap_remove_driver_sysfiles(&dgap_driver);
-
- device_destroy(dgap_class, MKDEV(DIGI_DGAP_MAJOR, 0));
- class_destroy(dgap_class);
- unregister_chrdev(DIGI_DGAP_MAJOR, "dgap");
-
- for (i = 0; i < dgap_numboards; ++i) {
- dgap_remove_ports_sysfiles(dgap_board[i]);
- dgap_cleanup_tty(dgap_board[i]);
- dgap_cleanup_board(dgap_board[i]);
- }
-
- dgap_cleanup_nodes();
-
if (dgap_numboards)
pci_unregister_driver(&dgap_driver);
}
diff --git a/drivers/staging/dgap/dgap.h b/drivers/staging/dgap/dgap.h
index a2e5b26c673ad1..e707ed5fe94937 100644
--- a/drivers/staging/dgap/dgap.h
+++ b/drivers/staging/dgap/dgap.h
@@ -172,7 +172,7 @@
/*
* Define a local default termios struct. All ports will be created
* with this termios initially. This is the same structure that is defined
- * as the default in tty_io.c with the same settings overriden as in serial.c
+ * as the default in tty_io.c with the same settings overridden as in serial.c
*
* In short, this should match the internal serial ports' defaults.
*/
diff --git a/drivers/staging/dgnc/TODO b/drivers/staging/dgnc/TODO
index 2b2c6ea03c615e..0e0825bd70aee2 100644
--- a/drivers/staging/dgnc/TODO
+++ b/drivers/staging/dgnc/TODO
@@ -1,9 +1,9 @@
* checkpatch fixes
-* remove unecessary comments
-* remove unecessary error messages. Example kzalloc() has its
+* remove unnecessary comments
+* remove unnecessary error messages. Example kzalloc() has its
own error message. Adding an extra one is useless.
* use goto statements for error handling when appropriate
-* there is a lot of unecessary code in the driver. It was
+* there is a lot of unnecessary code in the driver. It was
originally a standalone driver. Remove uneeded code.
Please send patches to Greg Kroah-Hartman <greg@kroah.com> and
diff --git a/drivers/staging/dgnc/dgnc_cls.c b/drivers/staging/dgnc/dgnc_cls.c
index e3564d278d917d..a629a78964ce0d 100644
--- a/drivers/staging/dgnc/dgnc_cls.c
+++ b/drivers/staging/dgnc/dgnc_cls.c
@@ -379,7 +379,7 @@ static inline void cls_parse_isr(struct dgnc_board *brd, uint port)
return;
ch = brd->channels[port];
- if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
+ if (ch->magic != DGNC_CHANNEL_MAGIC)
return;
/* Here we try to figure out what caused the interrupt to happen */
@@ -714,8 +714,6 @@ static void cls_tasklet(unsigned long data)
/* Loop on each port */
for (i = 0; i < ports; i++) {
ch = bd->channels[i];
- if (!ch)
- continue;
/*
* NOTE: Remember you CANNOT hold any channel
diff --git a/drivers/staging/dgnc/dgnc_driver.c b/drivers/staging/dgnc/dgnc_driver.c
index 805dc617e3a787..7546aff6500243 100644
--- a/drivers/staging/dgnc/dgnc_driver.c
+++ b/drivers/staging/dgnc/dgnc_driver.c
@@ -355,7 +355,6 @@ static void dgnc_cleanup_board(struct dgnc_board *brd)
}
}
- kfree(brd->flipbuf);
dgnc_Board[brd->boardnum] = NULL;
@@ -581,14 +580,6 @@ static int dgnc_found_board(struct pci_dev *pdev, int id)
brd->msgbuf_head = NULL;
spin_unlock_irqrestore(&dgnc_global_lock, flags);
- /*
- * allocate flip buffer for board.
- *
- * Okay to malloc with GFP_KERNEL, we are not at interrupt
- * context, and there are no locks held.
- */
- brd->flipbuf = kzalloc(MYFLIPLEN, GFP_KERNEL);
-
wake_up_interruptible(&brd->state_wait);
return 0;
diff --git a/drivers/staging/dgnc/dgnc_driver.h b/drivers/staging/dgnc/dgnc_driver.h
index f77fed57b87362..3dee9f392fb3bf 100644
--- a/drivers/staging/dgnc/dgnc_driver.h
+++ b/drivers/staging/dgnc/dgnc_driver.h
@@ -212,8 +212,6 @@ struct dgnc_board {
uint TtyRefCnt;
- char *flipbuf; /* Our flip buffer, alloced if board is found */
-
u16 dpatype; /* The board "type", as defined by DPA */
u16 dpastatus; /* The board "status", as defined by DPA */
@@ -288,7 +286,6 @@ struct un_t {
#define CH_TX_FIFO_LWM 0x0800 /* TX Fifo is below Low Water */
#define CH_BREAK_SENDING 0x1000 /* Break is being sent */
#define CH_LOOPBACK 0x2000 /* Channel is in lookback mode */
-#define CH_FLIPBUF_IN_USE 0x4000 /* Channel's flipbuf is in use */
#define CH_BAUD0 0x08000 /* Used for checking B0 transitions */
#define CH_FORCED_STOP 0x20000 /* Output is forcibly stopped */
#define CH_FORCED_STOPI 0x40000 /* Input is forcibly stopped */
diff --git a/drivers/staging/dgnc/dgnc_neo.c b/drivers/staging/dgnc/dgnc_neo.c
index f5a4d365115fdc..900e3ae55a38fc 100644
--- a/drivers/staging/dgnc/dgnc_neo.c
+++ b/drivers/staging/dgnc/dgnc_neo.c
@@ -395,7 +395,7 @@ static inline void neo_parse_isr(struct dgnc_board *brd, uint port)
return;
ch = brd->channels[port];
- if (!ch || ch->magic != DGNC_CHANNEL_MAGIC)
+ if (ch->magic != DGNC_CHANNEL_MAGIC)
return;
/* Here we try to figure out what caused the interrupt to happen */
@@ -1203,7 +1203,7 @@ static void neo_copy_data_from_uart_to_queue(struct channel_t *ch)
memcpy_fromio(ch->ch_rqueue + head, &ch->ch_neo_uart->txrxburst, n);
/*
- * Since RX_FIFO_DATA_ERROR was 0, we are guarenteed
+ * Since RX_FIFO_DATA_ERROR was 0, we are guaranteed
* that all the data currently in the FIFO is free of
* breaks and parity/frame/orun errors.
*/
diff --git a/drivers/staging/dgnc/dgnc_sysfs.c b/drivers/staging/dgnc/dgnc_sysfs.c
index 65551d19051529..44db8703eba47f 100644
--- a/drivers/staging/dgnc/dgnc_sysfs.c
+++ b/drivers/staging/dgnc/dgnc_sysfs.c
@@ -53,7 +53,8 @@ static ssize_t dgnc_driver_pollrate_show(struct device_driver *ddp, char *buf)
return snprintf(buf, PAGE_SIZE, "%dms\n", dgnc_poll_tick);
}
-static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char *buf, size_t count)
+static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp,
+ const char *buf, size_t count)
{
int ret;
@@ -62,7 +63,8 @@ static ssize_t dgnc_driver_pollrate_store(struct device_driver *ddp, const char
return -EINVAL;
return count;
}
-static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show, dgnc_driver_pollrate_store);
+static DRIVER_ATTR(pollrate, (S_IRUSR | S_IWUSR), dgnc_driver_pollrate_show,
+ dgnc_driver_pollrate_store);
void dgnc_create_driver_sysfiles(struct pci_driver *dgnc_driver)
@@ -104,7 +106,8 @@ void dgnc_remove_driver_sysfiles(struct pci_driver *dgnc_driver)
-static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr,
+ char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -112,7 +115,8 @@ static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, ch
DGNC_VERIFY_BOARD(p, bd);
- count += sprintf(buf + count, "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F");
+ count += sprintf(buf + count,
+ "\n 0 1 2 3 4 5 6 7 8 9 A B C D E F");
for (i = 0; i < 0x40 * 2; i++) {
if (!(i % 16))
count += sprintf(buf + count, "\n%04X ", i * 2);
@@ -124,7 +128,8 @@ static ssize_t dgnc_vpd_show(struct device *p, struct device_attribute *attr, ch
}
static DEVICE_ATTR(vpd, S_IRUSR, dgnc_vpd_show, NULL);
-static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_serial_number_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -141,7 +146,8 @@ static ssize_t dgnc_serial_number_show(struct device *p, struct device_attribute
static DEVICE_ATTR(serial_number, S_IRUSR, dgnc_serial_number_show, NULL);
-static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_state_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -159,7 +165,8 @@ static ssize_t dgnc_ports_state_show(struct device *p, struct device_attribute *
static DEVICE_ATTR(ports_state, S_IRUSR, dgnc_ports_state_show, NULL);
-static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_baud_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -169,14 +176,17 @@ static ssize_t dgnc_ports_baud_show(struct device *p, struct device_attribute *a
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count,
- "%d %d\n", bd->channels[i]->ch_portnum, bd->channels[i]->ch_old_baud);
+ "%d %d\n", bd->channels[i]->ch_portnum,
+ bd->channels[i]->ch_old_baud);
}
return count;
}
static DEVICE_ATTR(ports_baud, S_IRUSR, dgnc_ports_baud_show, NULL);
-static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_msignals_show(struct device *p,
+ struct device_attribute *attr,
+ char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -187,7 +197,8 @@ static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribut
for (i = 0; i < bd->nasync; i++) {
if (bd->channels[i]->ch_open_count) {
count += snprintf(buf + count, PAGE_SIZE - count,
- "%d %s %s %s %s %s %s\n", bd->channels[i]->ch_portnum,
+ "%d %s %s %s %s %s %s\n",
+ bd->channels[i]->ch_portnum,
(bd->channels[i]->ch_mostat & UART_MCR_RTS) ? "RTS" : "",
(bd->channels[i]->ch_mistat & UART_MSR_CTS) ? "CTS" : "",
(bd->channels[i]->ch_mostat & UART_MCR_DTR) ? "DTR" : "",
@@ -204,7 +215,8 @@ static ssize_t dgnc_ports_msignals_show(struct device *p, struct device_attribut
static DEVICE_ATTR(ports_msignals, S_IRUSR, dgnc_ports_msignals_show, NULL);
-static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_iflag_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -214,14 +226,16 @@ static ssize_t dgnc_ports_iflag_show(struct device *p, struct device_attribute *
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
- bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_iflag);
+ bd->channels[i]->ch_portnum,
+ bd->channels[i]->ch_c_iflag);
}
return count;
}
static DEVICE_ATTR(ports_iflag, S_IRUSR, dgnc_ports_iflag_show, NULL);
-static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_cflag_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -231,14 +245,16 @@ static ssize_t dgnc_ports_cflag_show(struct device *p, struct device_attribute *
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
- bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_cflag);
+ bd->channels[i]->ch_portnum,
+ bd->channels[i]->ch_c_cflag);
}
return count;
}
static DEVICE_ATTR(ports_cflag, S_IRUSR, dgnc_ports_cflag_show, NULL);
-static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_oflag_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -248,14 +264,16 @@ static ssize_t dgnc_ports_oflag_show(struct device *p, struct device_attribute *
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
- bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_oflag);
+ bd->channels[i]->ch_portnum,
+ bd->channels[i]->ch_c_oflag);
}
return count;
}
static DEVICE_ATTR(ports_oflag, S_IRUSR, dgnc_ports_oflag_show, NULL);
-static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_lflag_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -265,14 +283,17 @@ static ssize_t dgnc_ports_lflag_show(struct device *p, struct device_attribute *
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
- bd->channels[i]->ch_portnum, bd->channels[i]->ch_c_lflag);
+ bd->channels[i]->ch_portnum,
+ bd->channels[i]->ch_c_lflag);
}
return count;
}
static DEVICE_ATTR(ports_lflag, S_IRUSR, dgnc_ports_lflag_show, NULL);
-static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_digi_flag_show(struct device *p,
+ struct device_attribute *attr,
+ char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -282,14 +303,16 @@ static ssize_t dgnc_ports_digi_flag_show(struct device *p, struct device_attribu
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %x\n",
- bd->channels[i]->ch_portnum, bd->channels[i]->ch_digi.digi_flags);
+ bd->channels[i]->ch_portnum,
+ bd->channels[i]->ch_digi.digi_flags);
}
return count;
}
static DEVICE_ATTR(ports_digi_flag, S_IRUSR, dgnc_ports_digi_flag_show, NULL);
-static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_rxcount_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -299,14 +322,16 @@ static ssize_t dgnc_ports_rxcount_show(struct device *p, struct device_attribute
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n",
- bd->channels[i]->ch_portnum, bd->channels[i]->ch_rxcount);
+ bd->channels[i]->ch_portnum,
+ bd->channels[i]->ch_rxcount);
}
return count;
}
static DEVICE_ATTR(ports_rxcount, S_IRUSR, dgnc_ports_rxcount_show, NULL);
-static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_ports_txcount_show(struct device *p,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
int count = 0;
@@ -316,7 +341,8 @@ static ssize_t dgnc_ports_txcount_show(struct device *p, struct device_attribute
for (i = 0; i < bd->nasync; i++) {
count += snprintf(buf + count, PAGE_SIZE - count, "%d %ld\n",
- bd->channels[i]->ch_portnum, bd->channels[i]->ch_txcount);
+ bd->channels[i]->ch_portnum,
+ bd->channels[i]->ch_txcount);
}
return count;
}
@@ -366,7 +392,8 @@ void dgnc_remove_ports_sysfiles(struct dgnc_board *bd)
}
-static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_state_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -386,12 +413,14 @@ static ssize_t dgnc_tty_state_show(struct device *d, struct device_attribute *at
if (bd->state != BOARD_READY)
return 0;
- return snprintf(buf, PAGE_SIZE, "%s", un->un_open_count ? "Open" : "Closed");
+ return snprintf(buf, PAGE_SIZE, "%s",
+ un->un_open_count ? "Open" : "Closed");
}
static DEVICE_ATTR(state, S_IRUSR, dgnc_tty_state_show, NULL);
-static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_baud_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -416,7 +445,8 @@ static ssize_t dgnc_tty_baud_show(struct device *d, struct device_attribute *att
static DEVICE_ATTR(baud, S_IRUSR, dgnc_tty_baud_show, NULL);
-static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_msignals_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -450,7 +480,8 @@ static ssize_t dgnc_tty_msignals_show(struct device *d, struct device_attribute
static DEVICE_ATTR(msignals, S_IRUSR, dgnc_tty_msignals_show, NULL);
-static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_iflag_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -475,7 +506,8 @@ static ssize_t dgnc_tty_iflag_show(struct device *d, struct device_attribute *at
static DEVICE_ATTR(iflag, S_IRUSR, dgnc_tty_iflag_show, NULL);
-static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_cflag_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -500,7 +532,8 @@ static ssize_t dgnc_tty_cflag_show(struct device *d, struct device_attribute *at
static DEVICE_ATTR(cflag, S_IRUSR, dgnc_tty_cflag_show, NULL);
-static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_oflag_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -525,7 +558,8 @@ static ssize_t dgnc_tty_oflag_show(struct device *d, struct device_attribute *at
static DEVICE_ATTR(oflag, S_IRUSR, dgnc_tty_oflag_show, NULL);
-static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_lflag_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -550,7 +584,8 @@ static ssize_t dgnc_tty_lflag_show(struct device *d, struct device_attribute *at
static DEVICE_ATTR(lflag, S_IRUSR, dgnc_tty_lflag_show, NULL);
-static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_digi_flag_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -575,7 +610,8 @@ static ssize_t dgnc_tty_digi_flag_show(struct device *d, struct device_attribute
static DEVICE_ATTR(digi_flag, S_IRUSR, dgnc_tty_digi_flag_show, NULL);
-static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_rxcount_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -600,7 +636,8 @@ static ssize_t dgnc_tty_rxcount_show(struct device *d, struct device_attribute *
static DEVICE_ATTR(rxcount, S_IRUSR, dgnc_tty_rxcount_show, NULL);
-static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_txcount_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
@@ -625,7 +662,8 @@ static ssize_t dgnc_tty_txcount_show(struct device *d, struct device_attribute *
static DEVICE_ATTR(txcount, S_IRUSR, dgnc_tty_txcount_show, NULL);
-static ssize_t dgnc_tty_name_show(struct device *d, struct device_attribute *attr, char *buf)
+static ssize_t dgnc_tty_name_show(struct device *d,
+ struct device_attribute *attr, char *buf)
{
struct dgnc_board *bd;
struct channel_t *ch;
diff --git a/drivers/staging/dgnc/dgnc_tty.c b/drivers/staging/dgnc/dgnc_tty.c
index ce4187f60cb457..5c5c4b77425668 100644
--- a/drivers/staging/dgnc/dgnc_tty.c
+++ b/drivers/staging/dgnc/dgnc_tty.c
@@ -42,16 +42,11 @@
#include "dgnc_sysfs.h"
#include "dgnc_utils.h"
-#define init_MUTEX(sem) sema_init(sem, 1)
-#define DECLARE_MUTEX(name) \
- struct semaphore name = __SEMAPHORE_INITIALIZER(name, 1)
-
/*
* internal variables
*/
static struct dgnc_board *dgnc_BoardsByMajor[256];
static unsigned char *dgnc_TmpWriteBuf;
-static DECLARE_MUTEX(dgnc_TmpWriteSem);
/*
* Default transparent print information.
@@ -304,19 +299,15 @@ int dgnc_tty_init(struct dgnc_board *brd)
brd->nasync = brd->maxports;
- /*
- * Allocate channel memory that might not have been allocated
- * when the driver was first loaded.
- */
for (i = 0; i < brd->nasync; i++) {
- if (!brd->channels[i]) {
-
- /*
- * Okay to malloc with GFP_KERNEL, we are not at
- * interrupt context, and there are no locks held.
- */
- brd->channels[i] = kzalloc(sizeof(*brd->channels[i]), GFP_KERNEL);
- }
+ /*
+ * Okay to malloc with GFP_KERNEL, we are not at
+ * interrupt context, and there are no locks held.
+ */
+ brd->channels[i] = kzalloc(sizeof(*brd->channels[i]),
+ GFP_KERNEL);
+ if (!brd->channels[i])
+ goto err_free_channels;
}
ch = brd->channels[0];
@@ -324,10 +315,6 @@ int dgnc_tty_init(struct dgnc_board *brd)
/* Set up channel variables */
for (i = 0; i < brd->nasync; i++, ch = brd->channels[i]) {
-
- if (!brd->channels[i])
- continue;
-
spin_lock_init(&ch->ch_lock);
/* Store all our magic numbers */
@@ -375,6 +362,13 @@ int dgnc_tty_init(struct dgnc_board *brd)
}
return 0;
+
+err_free_channels:
+ for (i = i - 1; i >= 0; --i) {
+ kfree(brd->channels[i]);
+ brd->channels[i] = NULL;
+ }
+ return -ENOMEM;
}
@@ -404,7 +398,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
dgnc_BoardsByMajor[brd->SerialDriver.major] = NULL;
brd->dgnc_Serial_Major = 0;
for (i = 0; i < brd->nasync; i++) {
- dgnc_remove_tty_sysfs(brd->channels[i]->ch_tun.un_sysfs);
+ if (brd->channels[i])
+ dgnc_remove_tty_sysfs(brd->channels[i]->
+ ch_tun.un_sysfs);
tty_unregister_device(&brd->SerialDriver, i);
}
tty_unregister_driver(&brd->SerialDriver);
@@ -415,7 +411,9 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
dgnc_BoardsByMajor[brd->PrintDriver.major] = NULL;
brd->dgnc_TransparentPrint_Major = 0;
for (i = 0; i < brd->nasync; i++) {
- dgnc_remove_tty_sysfs(brd->channels[i]->ch_pun.un_sysfs);
+ if (brd->channels[i])
+ dgnc_remove_tty_sysfs(brd->channels[i]->
+ ch_pun.un_sysfs);
tty_unregister_device(&brd->PrintDriver, i);
}
tty_unregister_driver(&brd->PrintDriver);
@@ -428,9 +426,6 @@ void dgnc_tty_uninit(struct dgnc_board *brd)
brd->PrintDriver.ttys = NULL;
}
-
-#define TMPBUFLEN (1024)
-
/*=======================================================================
*
* dgnc_wmove - Write data to transmit queue.
@@ -555,15 +550,6 @@ void dgnc_input(struct channel_t *ch)
ld = tty_ldisc_ref(tp);
-#ifdef TTY_DONT_FLIP
- /*
- * If the DONT_FLIP flag is on, don't flush our buffer, and act
- * like the ld doesn't have any space to put the data right now.
- */
- if (test_bit(TTY_DONT_FLIP, &tp->flags))
- len = 0;
-#endif
-
/*
* If we were unable to get a reference to the ld,
* don't flush our buffer, and act like the ld doesn't
@@ -897,10 +883,6 @@ void dgnc_check_queue_flow_control(struct channel_t *ch)
ch->ch_stops_sent = 0;
ch->ch_bd->bd_ops->send_start_character(ch);
}
- /* No FLOW */
- else {
- /* Nothing needed. */
- }
}
}
@@ -1705,7 +1687,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
ushort tail;
ushort tmask;
uint remain;
- int from_user = 0;
if (tty == NULL || dgnc_TmpWriteBuf == NULL)
return 0;
@@ -1779,44 +1760,6 @@ static int dgnc_tty_write(struct tty_struct *tty,
ch->ch_flags &= ~CH_PRON;
}
- /*
- * If there is nothing left to copy, or I can't handle any more data, leave.
- */
- if (count <= 0)
- goto exit_retry;
-
- if (from_user) {
-
- count = min(count, WRITEBUFLEN);
-
- spin_unlock_irqrestore(&ch->ch_lock, flags);
-
- /*
- * If data is coming from user space, copy it into a temporary
- * buffer so we don't get swapped out while doing the copy to
- * the board.
- */
- /* we're allowed to block if it's from_user */
- if (down_interruptible(&dgnc_TmpWriteSem))
- return -EINTR;
-
- /*
- * copy_from_user() returns the number
- * of bytes that could *NOT* be copied.
- */
- count -= copy_from_user(dgnc_TmpWriteBuf, (const unsigned char __user *) buf, count);
-
- if (!count) {
- up(&dgnc_TmpWriteSem);
- return -EFAULT;
- }
-
- spin_lock_irqsave(&ch->ch_lock, flags);
-
- buf = dgnc_TmpWriteBuf;
-
- }
-
n = count;
/*
@@ -1853,12 +1796,7 @@ static int dgnc_tty_write(struct tty_struct *tty,
ch->ch_cpstime += (HZ * count) / ch->ch_digi.digi_maxcps;
}
- if (from_user) {
- spin_unlock_irqrestore(&ch->ch_lock, flags);
- up(&dgnc_TmpWriteSem);
- } else {
- spin_unlock_irqrestore(&ch->ch_lock, flags);
- }
+ spin_unlock_irqrestore(&ch->ch_lock, flags);
if (count) {
/*
diff --git a/drivers/staging/dgnc/digi.h b/drivers/staging/dgnc/digi.h
index d637a7802168e1..cf9dcae7cc3fcf 100644
--- a/drivers/staging/dgnc/digi.h
+++ b/drivers/staging/dgnc/digi.h
@@ -130,19 +130,19 @@ struct digi_getcounter {
#define BD_RUNNING 0x0
#define BD_NOFEP 0x5
-#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */
-#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */
+#define DIGI_SETCUSTOMBAUD _IOW('e', 106, int) /* Set integer baud rate */
+#define DIGI_GETCUSTOMBAUD _IOR('e', 107, int) /* Get integer baud rate */
#define DIGI_REALPORT_GETBUFFERS (('e'<<8) | 108)
#define DIGI_REALPORT_SENDIMMEDIATE (('e'<<8) | 109)
#define DIGI_REALPORT_GETCOUNTERS (('e'<<8) | 110)
#define DIGI_REALPORT_GETEVENTS (('e'<<8) | 111)
-#define EV_OPU 0x0001 /* !<Output paused by client */
-#define EV_OPS 0x0002 /* !<Output paused by reqular sw flowctrl */
-#define EV_IPU 0x0010 /* !<Input paused unconditionally by user */
-#define EV_IPS 0x0020 /* !<Input paused by high/low water marks */
-#define EV_TXB 0x0040 /* !<Transmit break pending */
+#define EV_OPU 0x0001 /* !<Output paused by client */
+#define EV_OPS 0x0002 /* !<Output paused by reqular sw flowctrl */
+#define EV_IPU 0x0010 /* !<Input paused unconditionally by user */
+#define EV_IPS 0x0020 /* !<Input paused by high/low water marks */
+#define EV_TXB 0x0040 /* !<Transmit break pending */
/*
* This structure holds data needed for the intelligent <--> nonintelligent
diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index fbf82bc735cff6..163ca56a11ab64 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -1223,7 +1223,7 @@ static int _nbu2ss_epn_in_transfer(
}
/*-------------------------------------------------------------*/
- /* Start tranfer */
+ /* Start transfer */
iBufSize = req->req.length - req->req.actual;
if (iBufSize > 0)
result = _nbu2ss_epn_in_data(udc, ep, req, iBufSize);
@@ -2199,18 +2199,6 @@ static void _nbu2ss_ep0_enable(struct nbu2ss_udc *udc)
_nbu2ss_writel(&udc->p_regs->EP0_INT_ENA, EP0_INT_EN_BIT);
}
-#if 0
-/*-------------------------------------------------------------------------*/
-static void _nbu2ss_ep0_disable(struct nbu2ss_udc *udc)
-{
- _nbu2ss_bitclr(&udc->p_regs->EP0_INT_ENA, EP0_INT_EN_BIT);
-
- _nbu2ss_bitset(&udc->p_regs->EP0_CONTROL
- , (EP0_BCLR | EP0_INAK | EP0_ONAK | EP0_BCLR));
-
- _nbu2ss_bitclr(&udc->p_regs->EP0_CONTROL, EP0_AUTO);
-}
-#endif
/*-------------------------------------------------------------------------*/
static int _nbu2ss_nuke(struct nbu2ss_udc *udc,
@@ -2311,12 +2299,6 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc)
if (udc->udc_enabled)
return 0;
-#if 0
- emxx_open_clockgate(EMXX_CLK_USB1);
- /* emxx_clkctrl_off(EMXX_CLKCTRL_USB1); */
- /* emxx_clkctrl_on(EMXX_CLKCTRL_USB1); */
- emxx_unreset_device(EMXX_RST_USB1);
-#endif
/*
Reset
*/
@@ -2330,13 +2312,6 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc)
_nbu2ss_writel(&udc->p_regs->AHBSCTR, WAIT_MODE);
-#if 0
- /* DMA Mode Setting */
- if ((system_rev & EMXX_REV_MASK) == EMXX_REV_ES1) {
- _nbu2ss_bitset(&udc->p_regs->AHBMCTR, BURST_TYPE);
- _nbu2ss_bitclr(&udc->p_regs->AHBMCTR, HTRANS_MODE);
- } else
-#endif
_nbu2ss_writel(&udc->p_regs->AHBMCTR,
HBUSREQ_MODE | HTRANS_MODE | WBURST_TYPE);
@@ -2347,11 +2322,8 @@ static int _nbu2ss_enable_controller(struct nbu2ss_udc *udc)
dev_err(udc->dev, "*** Reset Cancel failed\n");
return -EINVAL;
}
- };
+ }
-#if 0
- if ((system_rev & EMXX_REV_MASK) < EMXX_REV_ES3)
-#endif
_nbu2ss_bitset(&udc->p_regs->UTMI_CHARACTER_1, USB_SQUSET);
_nbu2ss_bitset(&udc->p_regs->USB_CONTROL, (INT_SEL | SOF_RCV));
@@ -2383,11 +2355,6 @@ static void _nbu2ss_disable_controller(struct nbu2ss_udc *udc)
_nbu2ss_reset_controller(udc);
_nbu2ss_bitset(&udc->p_regs->EPCTR, (DIRPD | EPC_RST));
}
-#if 0
- emxx_reset_device(EMXX_RST_USB1);
- /* emxx_clkctrl_on(EMXX_CLKCTRL_USB1); */
- emxx_close_clockgate(EMXX_CLK_USB1);
-#endif
}
/*-------------------------------------------------------------------------*/
@@ -2998,7 +2965,7 @@ static void nbu2ss_ep_fifo_flush(struct usb_ep *_ep)
}
ep = container_of(_ep, struct nbu2ss_ep, ep);
- if (!_ep) {
+ if (!ep) {
pr_err("udc: %s, bad ep\n", __func__);
return;
}
diff --git a/drivers/staging/fbtft/Kconfig b/drivers/staging/fbtft/Kconfig
index 6cf0c58f538bc7..d4018780ce588d 100644
--- a/drivers/staging/fbtft/Kconfig
+++ b/drivers/staging/fbtft/Kconfig
@@ -12,7 +12,7 @@ config FB_TFT_AGM1264K_FL
tristate "FB driver for the AGM1264K-FL LCD display"
depends on FB_TFT
help
- Framebuffer support for the AGM1264K-FL LCD display (two Samsung KS0108 compatable chips)
+ Framebuffer support for the AGM1264K-FL LCD display (two Samsung KS0108 compatible chips)
config FB_TFT_BD663474
tristate "FB driver for the BD663474 LCD Controller"
@@ -38,6 +38,12 @@ config FB_TFT_HX8353D
help
Generic Framebuffer support for HX8353D
+config FB_TFT_HX8357D
+ tristate "FB driver for the HX8357D LCD Controller"
+ depends on FB_TFT
+ help
+ Generic Framebuffer support for HX8357D
+
config FB_TFT_ILI9163
tristate "FB driver for the ILI9163 LCD Controller"
depends on FB_TFT
diff --git a/drivers/staging/fbtft/Makefile b/drivers/staging/fbtft/Makefile
index 9e73beee23f4bd..554b5260b0ee84 100644
--- a/drivers/staging/fbtft/Makefile
+++ b/drivers/staging/fbtft/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_FB_TFT_BD663474) += fb_bd663474.o
obj-$(CONFIG_FB_TFT_HX8340BN) += fb_hx8340bn.o
obj-$(CONFIG_FB_TFT_HX8347D) += fb_hx8347d.o
obj-$(CONFIG_FB_TFT_HX8353D) += fb_hx8353d.o
+obj-$(CONFIG_FB_TFT_HX8357D) += fb_hx8357d.o
obj-$(CONFIG_FB_TFT_ILI9163) += fb_ili9163.o
obj-$(CONFIG_FB_TFT_ILI9320) += fb_ili9320.o
obj-$(CONFIG_FB_TFT_ILI9325) += fb_ili9325.o
diff --git a/drivers/staging/fbtft/fb_hx8357d.c b/drivers/staging/fbtft/fb_hx8357d.c
new file mode 100644
index 00000000000000..8c7bb3ac803050
--- /dev/null
+++ b/drivers/staging/fbtft/fb_hx8357d.c
@@ -0,0 +1,222 @@
+/*
+ * FB driver for the HX8357D LCD Controller
+ * Copyright (C) 2015 Adafruit Industries
+ *
+ * Based on the HX8347D FB driver
+ * Copyright (C) 2013 Christian Vogelgsang
+ *
+ * Based on driver code found here: https://github.com/watterott/r61505u-Adapter
+ *
+ * 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/kernel.h>
+#include <linux/init.h>
+#include <linux/delay.h>
+
+#include "fbtft.h"
+#include "fb_hx8357d.h"
+
+#define DRVNAME "fb_hx8357d"
+#define WIDTH 320
+#define HEIGHT 480
+
+
+static int init_display(struct fbtft_par *par)
+{
+ fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
+
+ par->fbtftops.reset(par);
+
+ /* Reset things like Gamma */
+ write_reg(par, HX8357B_SWRESET);
+ usleep_range(5000, 7000);
+
+ /* setextc */
+ write_reg(par, HX8357D_SETC, 0xFF, 0x83, 0x57);
+ msleep(150);
+
+ /* setRGB which also enables SDO */
+ write_reg(par, HX8357_SETRGB, 0x00, 0x00, 0x06, 0x06);
+
+ /* -1.52V */
+ write_reg(par, HX8357D_SETCOM, 0x25);
+
+ /* Normal mode 70Hz, Idle mode 55 Hz */
+ write_reg(par, HX8357_SETOSC, 0x68);
+
+ /* Set Panel - BGR, Gate direction swapped */
+ write_reg(par, HX8357_SETPANEL, 0x05);
+
+ write_reg(par, HX8357_SETPWR1,
+ 0x00, /* Not deep standby */
+ 0x15, /* BT */
+ 0x1C, /* VSPR */
+ 0x1C, /* VSNR */
+ 0x83, /* AP */
+ 0xAA); /* FS */
+
+ write_reg(par, HX8357D_SETSTBA,
+ 0x50, /* OPON normal */
+ 0x50, /* OPON idle */
+ 0x01, /* STBA */
+ 0x3C, /* STBA */
+ 0x1E, /* STBA */
+ 0x08); /* GEN */
+
+ write_reg(par, HX8357D_SETCYC,
+ 0x02, /* NW 0x02 */
+ 0x40, /* RTN */
+ 0x00, /* DIV */
+ 0x2A, /* DUM */
+ 0x2A, /* DUM */
+ 0x0D, /* GDON */
+ 0x78); /* GDOFF */
+
+ write_reg(par, HX8357D_SETGAMMA,
+ 0x02,
+ 0x0A,
+ 0x11,
+ 0x1d,
+ 0x23,
+ 0x35,
+ 0x41,
+ 0x4b,
+ 0x4b,
+ 0x42,
+ 0x3A,
+ 0x27,
+ 0x1B,
+ 0x08,
+ 0x09,
+ 0x03,
+ 0x02,
+ 0x0A,
+ 0x11,
+ 0x1d,
+ 0x23,
+ 0x35,
+ 0x41,
+ 0x4b,
+ 0x4b,
+ 0x42,
+ 0x3A,
+ 0x27,
+ 0x1B,
+ 0x08,
+ 0x09,
+ 0x03,
+ 0x00,
+ 0x01);
+
+ /* 16 bit */
+ write_reg(par, HX8357_COLMOD, 0x55);
+
+ write_reg(par, HX8357_MADCTL, 0xC0);
+
+ /* TE off */
+ write_reg(par, HX8357_TEON, 0x00);
+
+ /* tear line */
+ write_reg(par, HX8357_TEARLINE, 0x00, 0x02);
+
+ /* Exit Sleep */
+ write_reg(par, HX8357_SLPOUT);
+ msleep(150);
+
+ /* display on */
+ write_reg(par, HX8357_DISPON);
+ usleep_range(5000, 7000);
+
+ return 0;
+}
+
+static void set_addr_win(struct fbtft_par *par, int xs, int ys, int xe, int ye)
+{
+ fbtft_par_dbg(DEBUG_SET_ADDR_WIN, par,
+ "%s(xs=%d, ys=%d, xe=%d, ye=%d)\n", __func__, xs, ys, xe, ye);
+
+ /* Column addr set */
+ write_reg(par, HX8357_CASET,
+ xs >> 8, xs & 0xff, /* XSTART */
+ xe >> 8, xe & 0xff); /* XEND */
+
+ /* Row addr set */
+ write_reg(par, HX8357_PASET,
+ ys >> 8, ys & 0xff, /* YSTART */
+ ye >> 8, ye & 0xff); /* YEND */
+
+ /* write to RAM */
+ write_reg(par, HX8357_RAMWR);
+}
+
+#define HX8357D_MADCTL_MY 0x80
+#define HX8357D_MADCTL_MX 0x40
+#define HX8357D_MADCTL_MV 0x20
+#define HX8357D_MADCTL_ML 0x10
+#define HX8357D_MADCTL_RGB 0x00
+#define HX8357D_MADCTL_BGR 0x08
+#define HX8357D_MADCTL_MH 0x04
+static int set_var(struct fbtft_par *par)
+{
+ u8 val;
+
+ fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, "%s()\n", __func__);
+
+ switch (par->info->var.rotate) {
+ case 270:
+ val = HX8357D_MADCTL_MV | HX8357D_MADCTL_MX;
+ break;
+ case 180:
+ val = 0;
+ break;
+ case 90:
+ val = HX8357D_MADCTL_MV | HX8357D_MADCTL_MY;
+ break;
+ default:
+ val = HX8357D_MADCTL_MX | HX8357D_MADCTL_MY;
+ break;
+ }
+
+ val |= (par->bgr ? HX8357D_MADCTL_RGB : HX8357D_MADCTL_BGR);
+
+ /* Memory Access Control */
+ write_reg(par, HX8357_MADCTL, val);
+
+ return 0;
+}
+
+static struct fbtft_display display = {
+ .regwidth = 8,
+ .width = WIDTH,
+ .height = HEIGHT,
+ .gamma_num = 2,
+ .gamma_len = 14,
+ .fbtftops = {
+ .init_display = init_display,
+ .set_addr_win = set_addr_win,
+ .set_var = set_var,
+ },
+};
+FBTFT_REGISTER_DRIVER(DRVNAME, "himax,hx8357d", &display);
+
+MODULE_ALIAS("spi:" DRVNAME);
+MODULE_ALIAS("platform:" DRVNAME);
+MODULE_ALIAS("spi:hx8357d");
+MODULE_ALIAS("platform:hx8357d");
+
+MODULE_DESCRIPTION("FB driver for the HX8357D LCD Controller");
+MODULE_AUTHOR("Sean Cross <xobs@kosagi.com>");
+MODULE_LICENSE("GPL");
diff --git a/drivers/staging/fbtft/fb_hx8357d.h b/drivers/staging/fbtft/fb_hx8357d.h
new file mode 100644
index 00000000000000..de05e8cdf04cde
--- /dev/null
+++ b/drivers/staging/fbtft/fb_hx8357d.h
@@ -0,0 +1,102 @@
+/***************************************************
+ This is our library for the Adafruit ILI9341 Breakout and Shield
+ ----> http://www.adafruit.com/products/1651
+
+ Check out the links above for our tutorials and wiring diagrams
+ These displays use SPI to communicate, 4 or 5 pins are required to
+ interface (RST is optional)
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit and open-source hardware by purchasing
+ products from Adafruit!
+
+ Written by Limor Fried/Ladyada for Adafruit Industries.
+ MIT license, all text above must be included in any redistribution
+ ****************************************************/
+
+#ifndef __HX8357_H__
+#define __HX8357_H__
+
+#define HX8357D 0xD
+#define HX8357B 0xB
+
+#define HX8357_TFTWIDTH 320
+#define HX8357_TFTHEIGHT 480
+
+#define HX8357B_NOP 0x00
+#define HX8357B_SWRESET 0x01
+#define HX8357B_RDDID 0x04
+#define HX8357B_RDDST 0x09
+
+#define HX8357B_RDPOWMODE 0x0A
+#define HX8357B_RDMADCTL 0x0B
+#define HX8357B_RDCOLMOD 0x0C
+#define HX8357B_RDDIM 0x0D
+#define HX8357B_RDDSDR 0x0F
+
+#define HX8357_SLPIN 0x10
+#define HX8357_SLPOUT 0x11
+#define HX8357B_PTLON 0x12
+#define HX8357B_NORON 0x13
+
+#define HX8357_INVOFF 0x20
+#define HX8357_INVON 0x21
+#define HX8357_DISPOFF 0x28
+#define HX8357_DISPON 0x29
+
+#define HX8357_CASET 0x2A
+#define HX8357_PASET 0x2B
+#define HX8357_RAMWR 0x2C
+#define HX8357_RAMRD 0x2E
+
+#define HX8357B_PTLAR 0x30
+#define HX8357_TEON 0x35
+#define HX8357_TEARLINE 0x44
+#define HX8357_MADCTL 0x36
+#define HX8357_COLMOD 0x3A
+
+#define HX8357_SETOSC 0xB0
+#define HX8357_SETPWR1 0xB1
+#define HX8357B_SETDISPLAY 0xB2
+#define HX8357_SETRGB 0xB3
+#define HX8357D_SETCOM 0xB6
+
+#define HX8357B_SETDISPMODE 0xB4
+#define HX8357D_SETCYC 0xB4
+#define HX8357B_SETOTP 0xB7
+#define HX8357D_SETC 0xB9
+
+#define HX8357B_SET_PANEL_DRIVING 0xC0
+#define HX8357D_SETSTBA 0xC0
+#define HX8357B_SETDGC 0xC1
+#define HX8357B_SETID 0xC3
+#define HX8357B_SETDDB 0xC4
+#define HX8357B_SETDISPLAYFRAME 0xC5
+#define HX8357B_GAMMASET 0xC8
+#define HX8357B_SETCABC 0xC9
+#define HX8357_SETPANEL 0xCC
+
+#define HX8357B_SETPOWER 0xD0
+#define HX8357B_SETVCOM 0xD1
+#define HX8357B_SETPWRNORMAL 0xD2
+
+#define HX8357B_RDID1 0xDA
+#define HX8357B_RDID2 0xDB
+#define HX8357B_RDID3 0xDC
+#define HX8357B_RDID4 0xDD
+
+#define HX8357D_SETGAMMA 0xE0
+
+#define HX8357B_SETGAMMA 0xC8
+#define HX8357B_SETPANELRELATED 0xE9
+
+/* Color definitions */
+#define HX8357_BLACK 0x0000
+#define HX8357_BLUE 0x001F
+#define HX8357_RED 0xF800
+#define HX8357_GREEN 0x07E0
+#define HX8357_CYAN 0x07FF
+#define HX8357_MAGENTA 0xF81F
+#define HX8357_YELLOW 0xFFE0
+#define HX8357_WHITE 0xFFFF
+
+#endif /* __HX8357_H__ */
diff --git a/drivers/staging/fbtft/fb_st7735r.c b/drivers/staging/fbtft/fb_st7735r.c
index 9d874308447e05..f6522431861024 100644
--- a/drivers/staging/fbtft/fb_st7735r.c
+++ b/drivers/staging/fbtft/fb_st7735r.c
@@ -25,8 +25,8 @@
#include "fbtft.h"
#define DRVNAME "fb_st7735r"
-#define DEFAULT_GAMMA "0F 1A 0F 18 2F 28 20 22 1F 1B 23 37 00 07 02 10\n" \
- "0F 1B 0F 17 33 2C 29 2E 30 30 39 3F 00 07 03 10"
+#define DEFAULT_GAMMA "0F 1A 0F 18 2F 28 20 22 1F 1B 23 37 00 07 02 10\n" \
+ "0F 1B 0F 17 33 2C 29 2E 30 30 39 3F 00 07 03 10"
static int default_init_sequence[] = {
@@ -119,9 +119,9 @@ static int set_var(struct fbtft_par *par)
/* MADCTL - Memory data access control
RGB/BGR:
1. Mode selection pin SRGB
- RGB H/W pin for color filter setting: 0=RGB, 1=BGR
+ RGB H/W pin for color filter setting: 0=RGB, 1=BGR
2. MADCTL RGB bit
- RGB-BGR ORDER color filter panel: 0=RGB, 1=BGR */
+ RGB-BGR ORDER color filter panel: 0=RGB, 1=BGR */
switch (par->info->var.rotate) {
case 0:
write_reg(par, 0x36, MX | MY | (par->bgr << 3));
diff --git a/drivers/staging/fbtft/fb_tls8204.c b/drivers/staging/fbtft/fb_tls8204.c
index fcd38bf2ed79f9..5ea73b5ce45a4a 100644
--- a/drivers/staging/fbtft/fb_tls8204.c
+++ b/drivers/staging/fbtft/fb_tls8204.c
@@ -115,6 +115,7 @@ static int write_vmem(struct fbtft_par *par, size_t offset, size_t len)
for (x = 0; x < WIDTH; x++) {
u8 ch = 0;
+
for (i = 0; i < 8*WIDTH; i += WIDTH) {
ch >>= 1;
if (vmem16[(y*8*WIDTH)+i+x])
diff --git a/drivers/staging/fbtft/fbtft-bus.c b/drivers/staging/fbtft/fbtft-bus.c
index 52af9cbbc2a688..912c6328fb872b 100644
--- a/drivers/staging/fbtft/fbtft-bus.c
+++ b/drivers/staging/fbtft/fbtft-bus.c
@@ -184,7 +184,7 @@ EXPORT_SYMBOL(fbtft_write_vmem16_bus8);
/* 16 bit pixel over 9-bit SPI bus: dc + high byte, dc + low byte */
int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len)
{
- u8 *vmem8;
+ u8 __iomem *vmem8;
u16 *txbuf16 = par->txbuf.buf;
size_t remain;
size_t to_copy;
@@ -212,12 +212,12 @@ int fbtft_write_vmem16_bus9(struct fbtft_par *par, size_t offset, size_t len)
#ifdef __LITTLE_ENDIAN
for (i = 0; i < to_copy; i += 2) {
- txbuf16[i] = 0x0100 | vmem8[i+1];
- txbuf16[i+1] = 0x0100 | vmem8[i];
+ txbuf16[i] = 0x0100 | ioread8(vmem8 + i + 1);
+ txbuf16[i + 1] = 0x0100 | ioread8(vmem8 + i);
}
#else
for (i = 0; i < to_copy; i++)
- txbuf16[i] = 0x0100 | vmem8[i];
+ txbuf16[i] = 0x0100 | ioread8(vmem8 + i);
#endif
vmem8 = vmem8 + to_copy;
ret = par->fbtftops.write(par, par->txbuf.buf, to_copy*2);
diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c
index 53b748be271247..ce645213a5393b 100644
--- a/drivers/staging/fbtft/fbtft-core.c
+++ b/drivers/staging/fbtft/fbtft-core.c
@@ -47,9 +47,11 @@ static unsigned long debug;
module_param(debug, ulong, 0);
MODULE_PARM_DESC(debug, "override device debug level");
+#ifdef CONFIG_HAS_DMA
static bool dma = true;
module_param(dma, bool, 0);
MODULE_PARM_DESC(dma, "Use DMA buffer");
+#endif
void fbtft_dbg_hex(const struct device *dev, int groupsize,
@@ -856,10 +858,13 @@ struct fb_info *fbtft_framebuffer_alloc(struct fbtft_display *display,
#endif
if (txbuflen > 0) {
+#ifdef CONFIG_HAS_DMA
if (dma) {
dev->coherent_dma_mask = ~0;
txbuf = dmam_alloc_coherent(dev, txbuflen, &par->txbuf.dma, GFP_DMA);
- } else {
+ } else
+#endif
+ {
txbuf = devm_kzalloc(par->info->device, txbuflen, GFP_KERNEL);
}
if (!txbuf)
diff --git a/drivers/staging/fbtft/internal.h b/drivers/staging/fbtft/internal.h
index f69db82891516a..eea0ec5ff4d39b 100644
--- a/drivers/staging/fbtft/internal.h
+++ b/drivers/staging/fbtft/internal.h
@@ -13,7 +13,7 @@
*
*/
-#ifndef __LINUX_FBTFT__INTERNAL_H
+#ifndef __LINUX_FBTFT_INTERNAL_H
#define __LINUX_FBTFT_INTERNAL_H
void fbtft_sysfs_init(struct fbtft_par *par);
diff --git a/drivers/staging/fsl-mc/bus/mc-bus.c b/drivers/staging/fsl-mc/bus/mc-bus.c
index 23512d09642728..766a65959b011d 100644
--- a/drivers/staging/fsl-mc/bus/mc-bus.c
+++ b/drivers/staging/fsl-mc/bus/mc-bus.c
@@ -713,7 +713,6 @@ MODULE_DEVICE_TABLE(of, fsl_mc_bus_match_table);
static struct platform_driver fsl_mc_bus_driver = {
.driver = {
.name = "fsl_mc_bus",
- .owner = THIS_MODULE,
.pm = NULL,
.of_match_table = fsl_mc_bus_match_table,
},
diff --git a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
index 2d758fb26eac3c..2593413412a35f 100644
--- a/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
+++ b/drivers/staging/ft1000/ft1000-usb/ft1000_debug.c
@@ -588,8 +588,7 @@ static long ft1000_ioctl(struct file *file, unsigned int command,
/* Check message qtype type which is the lower byte within qos_class */
qtype = ntohs(dpram_data->pseudohdr.qos_class) & 0xff;
/* pr_debug("qtype = %d\n", qtype); */
- if (qtype) {
- } else {
+ if (!qtype) {
/* Put message into Slow Queue */
/* Only put a message into the DPRAM if msg doorbell is available */
status = ft1000_read_register(ft1000dev, &tempword, FT1000_REG_DOORBELL);
diff --git a/drivers/staging/fwserial/dma_fifo.c b/drivers/staging/fwserial/dma_fifo.c
index 027906249598a4..7a3347c3d02b5b 100644
--- a/drivers/staging/fwserial/dma_fifo.c
+++ b/drivers/staging/fwserial/dma_fifo.c
@@ -56,7 +56,7 @@ void dma_fifo_init(struct dma_fifo *fifo)
* @size: 'apparent' size, in bytes, of fifo
* @align: dma alignment to maintain (should be at least cpu cache alignment),
* must be power of 2
- * @tx_limit: maximum # of bytes transmissable per dma (rounded down to
+ * @tx_limit: maximum # of bytes transmissible per dma (rounded down to
* multiple of alignment, but at least align size)
* @open_limit: maximum # of outstanding dma transactions allowed
* @gfp_mask: get_free_pages mask, passed to kmalloc()
diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c
index fdb2418c5f888b..b3ea4bb54e2c7a 100644
--- a/drivers/staging/fwserial/fwserial.c
+++ b/drivers/staging/fwserial/fwserial.c
@@ -2815,13 +2815,14 @@ static int __init fwserial_init(void)
/* num_ttys/num_ports must not be set above the static alloc avail */
if (num_ttys + num_loops > MAX_CARD_PORTS)
num_ttys = MAX_CARD_PORTS - num_loops;
+
num_ports = num_ttys + num_loops;
fwtty_driver = tty_alloc_driver(MAX_TOTAL_PORTS, TTY_DRIVER_REAL_RAW
| TTY_DRIVER_DYNAMIC_DEV);
if (IS_ERR(fwtty_driver)) {
err = PTR_ERR(fwtty_driver);
- return err;
+ goto remove_debugfs;
}
fwtty_driver->driver_name = KBUILD_MODNAME;
@@ -2923,7 +2924,9 @@ unregister_driver:
tty_unregister_driver(fwtty_driver);
put_tty:
put_tty_driver(fwtty_driver);
+remove_debugfs:
debugfs_remove_recursive(fwserial_debugfs);
+
return err;
}
diff --git a/drivers/staging/fwserial/fwserial.h b/drivers/staging/fwserial/fwserial.h
index 98b853d4acbcf1..787aa4f3a41b27 100644
--- a/drivers/staging/fwserial/fwserial.h
+++ b/drivers/staging/fwserial/fwserial.h
@@ -218,7 +218,7 @@ struct fwconsole_ops {
* prevented with the IN_TX flag. Scheduled under lock to
* limit scheduling when fifo has just been drained.
* @tx_fifo: fifo used to store & block-up writes for dma to remote
- * @max_payload: max bytes transmissable per dma (based on peer's max_payload)
+ * @max_payload: max bytes transmissible per dma (based on peer's max_payload)
* @status_mask: UART_LSR_* bitmask significant to rx (based on termios)
* @ignore_mask: UART_LSR_* bitmask of states to ignore (also based on termios)
* @break_ctl: if set, port is 'sending break' to remote
diff --git a/drivers/staging/gdm724x/gdm_endian.c b/drivers/staging/gdm724x/gdm_endian.c
index f6cc90ae9ba698..d7144e7afa329c 100644
--- a/drivers/staging/gdm724x/gdm_endian.c
+++ b/drivers/staging/gdm724x/gdm_endian.c
@@ -11,57 +11,45 @@
* GNU General Public License for more details.
*/
-#include <linux/slab.h>
+#include <linux/kernel.h>
#include "gdm_endian.h"
void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian)
{
- u8 a[2] = {0x12, 0x34};
- u8 b[2] = {0, };
- u16 c = 0x1234;
-
if (dev_endian == ENDIANNESS_BIG)
ed->dev_ed = ENDIANNESS_BIG;
else
ed->dev_ed = ENDIANNESS_LITTLE;
-
- memcpy(b, &c, 2);
-
- if (a[0] != b[0])
- ed->host_ed = ENDIANNESS_LITTLE;
- else
- ed->host_ed = ENDIANNESS_BIG;
-
}
u16 gdm_cpu_to_dev16(struct gdm_endian *ed, u16 x)
{
- if (ed->dev_ed == ed->host_ed)
- return x;
-
- return Endian16_Swap(x);
+ if (ed->dev_ed == ENDIANNESS_LITTLE)
+ return cpu_to_le16(x);
+ else
+ return cpu_to_be16(x);
}
u16 gdm_dev16_to_cpu(struct gdm_endian *ed, u16 x)
{
- if (ed->dev_ed == ed->host_ed)
- return x;
-
- return Endian16_Swap(x);
+ if (ed->dev_ed == ENDIANNESS_LITTLE)
+ return le16_to_cpu(x);
+ else
+ return be16_to_cpu(x);
}
u32 gdm_cpu_to_dev32(struct gdm_endian *ed, u32 x)
{
- if (ed->dev_ed == ed->host_ed)
- return x;
-
- return Endian32_Swap(x);
+ if (ed->dev_ed == ENDIANNESS_LITTLE)
+ return cpu_to_le32(x);
+ else
+ return cpu_to_be32(x);
}
u32 gdm_dev32_to_cpu(struct gdm_endian *ed, u32 x)
{
- if (ed->dev_ed == ed->host_ed)
- return x;
-
- return Endian32_Swap(x);
+ if (ed->dev_ed == ENDIANNESS_LITTLE)
+ return le32_to_cpu(x);
+ else
+ return be32_to_cpu(x);
}
diff --git a/drivers/staging/gdm724x/gdm_endian.h b/drivers/staging/gdm724x/gdm_endian.h
index 9b2531ff908e2f..6177870830e5b9 100644
--- a/drivers/staging/gdm724x/gdm_endian.h
+++ b/drivers/staging/gdm724x/gdm_endian.h
@@ -16,16 +16,6 @@
#include <linux/types.h>
-#define Endian16_Swap(value) \
- ((((u16)((value) & 0x00FF)) << 8) | \
- (((u16)((value) & 0xFF00)) >> 8))
-
-#define Endian32_Swap(value) \
- ((((u32)((value) & 0x000000FF)) << 24) | \
- (((u32)((value) & 0x0000FF00)) << 8) | \
- (((u32)((value) & 0x00FF0000)) >> 8) | \
- (((u32)((value) & 0xFF000000)) >> 24))
-
enum {
ENDIANNESS_MIN = 0,
ENDIANNESS_UNKNOWN,
@@ -37,7 +27,6 @@ enum {
struct gdm_endian {
u8 dev_ed;
- u8 host_ed;
};
void gdm_set_endian(struct gdm_endian *ed, u8 dev_endian);
diff --git a/drivers/staging/gdm72xx/gdm_wimax.c b/drivers/staging/gdm72xx/gdm_wimax.c
index 61d168e820110d..08290d901b0c88 100644
--- a/drivers/staging/gdm72xx/gdm_wimax.c
+++ b/drivers/staging/gdm72xx/gdm_wimax.c
@@ -584,7 +584,7 @@ static int gdm_wimax_get_prepared_info(struct net_device *dev, char *buf,
if (T == TLV_T(T_MAC_ADDRESS)) {
if (L != dev->addr_len) {
netdev_err(dev,
- "%s Invalid inofrmation result T/L [%x/%d]\n",
+ "%s Invalid information result T/L [%x/%d]\n",
__func__, T, L);
return -1;
}
diff --git a/drivers/staging/gdm72xx/netlink_k.c b/drivers/staging/gdm72xx/netlink_k.c
index 9d78bfcdb2c363..f3cdaa6c468cfd 100644
--- a/drivers/staging/gdm72xx/netlink_k.c
+++ b/drivers/staging/gdm72xx/netlink_k.c
@@ -121,7 +121,7 @@ int netlink_send(struct sock *sock, int group, u16 type, void *msg, int len)
int ret = 0;
if (group > ND_MAX_GROUP) {
- pr_err("Group %d is invalied.\n", group);
+ pr_err("Group %d is invalid.\n", group);
pr_err("Valid group is 0 ~ %d.\n", ND_MAX_GROUP);
return -EINVAL;
}
diff --git a/drivers/staging/goldfish/goldfish_audio.c b/drivers/staging/goldfish/goldfish_audio.c
index 702ae04df91227..b0927e49d0a81f 100644
--- a/drivers/staging/goldfish/goldfish_audio.c
+++ b/drivers/staging/goldfish/goldfish_audio.c
@@ -63,7 +63,7 @@ struct goldfish_audio {
#define AUDIO_READ(data, addr) (readl(data->reg_base + addr))
#define AUDIO_WRITE(data, addr, x) (writel(x, data->reg_base + addr))
#define AUDIO_WRITE64(data, addr, addr2, x) \
- (gf_write64((u64)(x), data->reg_base + addr, data->reg_base+addr2))
+ (gf_write_dma_addr((x), data->reg_base + addr, data->reg_base+addr2))
/*
* temporary variable used between goldfish_audio_probe() and
diff --git a/drivers/staging/goldfish/goldfish_nand.c b/drivers/staging/goldfish/goldfish_nand.c
index 213877a2c43039..66ae48fcc2b20e 100644
--- a/drivers/staging/goldfish/goldfish_nand.c
+++ b/drivers/staging/goldfish/goldfish_nand.c
@@ -87,7 +87,7 @@ static u32 goldfish_nand_cmd(struct mtd_info *mtd, enum nand_cmd cmd,
writel((u32)(addr >> 32), base + NAND_ADDR_HIGH);
writel((u32)addr, base + NAND_ADDR_LOW);
writel(len, base + NAND_TRANSFER_SIZE);
- gf_write64((u64)ptr, base + NAND_DATA, base + NAND_DATA_HIGH);
+ gf_write_ptr(ptr, base + NAND_DATA, base + NAND_DATA_HIGH);
writel(cmd, base + NAND_COMMAND);
rv = readl(base + NAND_RESULT);
}
diff --git a/drivers/staging/i2o/Kconfig b/drivers/staging/i2o/Kconfig
deleted file mode 100644
index 286c53f4b13d8c..00000000000000
--- a/drivers/staging/i2o/Kconfig
+++ /dev/null
@@ -1,120 +0,0 @@
-menuconfig I2O
- tristate "I2O device support"
- depends on PCI
- ---help---
- The Intelligent Input/Output (I2O) architecture allows hardware
- drivers to be split into two parts: an operating system specific
- module called the OSM and an hardware specific module called the
- HDM. The OSM can talk to a whole range of HDM's, and ideally the
- HDM's are not OS dependent. This allows for the same HDM driver to
- be used under different operating systems if the relevant OSM is in
- place. In order for this to work, you need to have an I2O interface
- adapter card in your computer. This card contains a special I/O
- processor (IOP), thus allowing high speeds since the CPU does not
- have to deal with I/O.
-
- If you say Y here, you will get a choice of interface adapter
- drivers and OSM's with the following questions.
-
- To compile this support as a module, choose M here: the
- modules will be called i2o_core.
-
- If unsure, say N.
-
-if I2O
-
-config I2O_LCT_NOTIFY_ON_CHANGES
- bool "Enable LCT notification"
- default y
- ---help---
- Only say N here if you have a I2O controller from SUN. The SUN
- firmware doesn't support LCT notification on changes. If this option
- is enabled on such a controller the driver will hang up in a endless
- loop. On all other controllers say Y.
-
- If unsure, say Y.
-
-config I2O_EXT_ADAPTEC
- bool "Enable Adaptec extensions"
- default y
- ---help---
- Say Y for support of raidutils for Adaptec I2O controllers. You also
- have to say Y to "I2O Configuration support", "I2O SCSI OSM" below
- and to "SCSI generic support" under "SCSI device configuration".
-
-config I2O_EXT_ADAPTEC_DMA64
- bool "Enable 64-bit DMA"
- depends on I2O_EXT_ADAPTEC && ( 64BIT || HIGHMEM64G )
- default y
- ---help---
- Say Y for support of 64-bit DMA transfer mode on Adaptec I2O
- controllers.
- Note: You need at least firmware version 3709.
-
-config I2O_CONFIG
- tristate "I2O Configuration support"
- depends on VIRT_TO_BUS
- ---help---
- Say Y for support of the configuration interface for the I2O adapters.
- If you have a RAID controller from Adaptec and you want to use the
- raidutils to manage your RAID array, you have to say Y here.
-
- To compile this support as a module, choose M here: the
- module will be called i2o_config.
-
- Note: If you want to use the new API you have to download the
- i2o_config patch from http://i2o.shadowconnect.com/
-
-config I2O_CONFIG_OLD_IOCTL
- bool "Enable ioctls (OBSOLETE)"
- depends on I2O_CONFIG
- default y
- ---help---
- Enables old ioctls.
-
-config I2O_BUS
- tristate "I2O Bus Adapter OSM"
- ---help---
- Include support for the I2O Bus Adapter OSM. The Bus Adapter OSM
- provides access to the busses on the I2O controller. The main purpose
- is to rescan the bus to find new devices.
-
- To compile this support as a module, choose M here: the
- module will be called i2o_bus.
-
-config I2O_BLOCK
- tristate "I2O Block OSM"
- depends on BLOCK
- ---help---
- Include support for the I2O Block OSM. The Block OSM presents disk
- and other structured block devices to the operating system. If you
- are using an RAID controller, you could access the array only by
- the Block OSM driver. But it is possible to access the single disks
- by the SCSI OSM driver, for example to monitor the disks.
-
- To compile this support as a module, choose M here: the
- module will be called i2o_block.
-
-config I2O_SCSI
- tristate "I2O SCSI OSM"
- depends on SCSI
- ---help---
- Allows direct SCSI access to SCSI devices on a SCSI or FibreChannel
- I2O controller. You can use both the SCSI and Block OSM together if
- you wish. To access a RAID array, you must use the Block OSM driver.
- But you could use the SCSI OSM driver to monitor the single disks.
-
- To compile this support as a module, choose M here: the
- module will be called i2o_scsi.
-
-config I2O_PROC
- tristate "I2O /proc support"
- ---help---
- If you say Y here and to "/proc file system support", you will be
- able to read I2O related information from the virtual directory
- /proc/i2o.
-
- To compile this support as a module, choose M here: the
- module will be called i2o_proc.
-
-endif # I2O
diff --git a/drivers/staging/i2o/Makefile b/drivers/staging/i2o/Makefile
deleted file mode 100644
index b0982dacfd0ac0..00000000000000
--- a/drivers/staging/i2o/Makefile
+++ /dev/null
@@ -1,16 +0,0 @@
-#
-# Makefile for the kernel I2O OSM.
-#
-# Note : at this point, these files are compiled on all systems.
-# In the future, some of these should be built conditionally.
-#
-
-i2o_core-y += iop.o driver.o device.o debug.o pci.o exec-osm.o memory.o
-i2o_bus-y += bus-osm.o
-i2o_config-y += config-osm.o
-obj-$(CONFIG_I2O) += i2o_core.o
-obj-$(CONFIG_I2O_CONFIG)+= i2o_config.o
-obj-$(CONFIG_I2O_BUS) += i2o_bus.o
-obj-$(CONFIG_I2O_BLOCK) += i2o_block.o
-obj-$(CONFIG_I2O_SCSI) += i2o_scsi.o
-obj-$(CONFIG_I2O_PROC) += i2o_proc.o
diff --git a/drivers/staging/i2o/README b/drivers/staging/i2o/README
deleted file mode 100644
index f072a8eb3041cd..00000000000000
--- a/drivers/staging/i2o/README
+++ /dev/null
@@ -1,98 +0,0 @@
-
- Linux I2O Support (c) Copyright 1999 Red Hat Software
- and others.
-
- 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.
-
-AUTHORS (so far)
-
-Alan Cox, Building Number Three Ltd.
- Core code, SCSI and Block OSMs
-
-Steve Ralston, LSI Logic Corp.
- Debugging SCSI and Block OSM
-
-Deepak Saxena, Intel Corp.
- Various core/block extensions
- /proc interface, bug fixes
- Ioctl interfaces for control
- Debugging LAN OSM
-
-Philip Rumpf
- Fixed assorted dumb SMP locking bugs
-
-Juha Sievanen, University of Helsinki Finland
- LAN OSM code
- /proc interface to LAN class
- Bug fixes
- Core code extensions
-
-Auvo Häkkinen, University of Helsinki Finland
- LAN OSM code
- /Proc interface to LAN class
- Bug fixes
- Core code extensions
-
-Taneli Vähäkangas, University of Helsinki Finland
- Fixes to i2o_config
-
-CREDITS
-
- This work was made possible by
-
-Red Hat Software
- Funding for the Building #3 part of the project
-
-Symbios Logic (Now LSI)
- Host adapters, hints, known to work platforms when I hit
- compatibility problems
-
-BoxHill Corporation
- Loan of initial FibreChannel disk array used for development work.
-
-European Commission
- Funding the work done by the University of Helsinki
-
-SysKonnect
- Loan of FDDI and Gigabit Ethernet cards
-
-ASUSTeK
- Loan of I2O motherboard
-
-STATUS:
-
-o The core setup works within limits.
-o The scsi layer seems to almost work.
- I'm still chasing down the hang bug.
-o The block OSM is mostly functional
-o LAN OSM works with FDDI and Ethernet cards.
-
-TO DO:
-
-General:
-o Provide hidden address space if asked
-o Long term message flow control
-o PCI IOP's without interrupts are not supported yet
-o Push FAIL handling into the core
-o DDM control interfaces for module load etc
-o Add I2O 2.0 support (Deffered to 2.5 kernel)
-
-Block:
-o Multiple major numbers
-o Read ahead and cache handling stuff. Talk to Ingo and people
-o Power management
-o Finish Media changers
-
-SCSI:
-o Find the right way to associate drives/luns/busses
-
-Lan:
-o Performance tuning
-o Test Fibre Channel code
-
-Tape:
-o Anyone seen anything implementing this ?
- (D.S: Will attempt to do so if spare cycles permit)
diff --git a/drivers/staging/i2o/README.ioctl b/drivers/staging/i2o/README.ioctl
deleted file mode 100644
index 4a7d2ebdfc97e7..00000000000000
--- a/drivers/staging/i2o/README.ioctl
+++ /dev/null
@@ -1,394 +0,0 @@
-
-Linux I2O User Space Interface
-rev 0.3 - 04/20/99
-
-=============================================================================
-Originally written by Deepak Saxena(deepak@plexity.net)
-Currently maintained by Deepak Saxena(deepak@plexity.net)
-=============================================================================
-
-I. Introduction
-
-The Linux I2O subsystem provides a set of ioctl() commands that can be
-utilized by user space applications to communicate with IOPs and devices
-on individual IOPs. This document defines the specific ioctl() commands
-that are available to the user and provides examples of their uses.
-
-This document assumes the reader is familiar with or has access to the
-I2O specification as no I2O message parameters are outlined. For information
-on the specification, see http://www.i2osig.org
-
-This document and the I2O user space interface are currently maintained
-by Deepak Saxena. Please send all comments, errata, and bug fixes to
-deepak@csociety.purdue.edu
-
-II. IOP Access
-
-Access to the I2O subsystem is provided through the device file named
-/dev/i2o/ctl. This file is a character file with major number 10 and minor
-number 166. It can be created through the following command:
-
- mknod /dev/i2o/ctl c 10 166
-
-III. Determining the IOP Count
-
- SYNOPSIS
-
- ioctl(fd, I2OGETIOPS, int *count);
-
- u8 count[MAX_I2O_CONTROLLERS];
-
- DESCRIPTION
-
- This function returns the system's active IOP table. count should
- point to a buffer containing MAX_I2O_CONTROLLERS entries. Upon
- returning, each entry will contain a non-zero value if the given
- IOP unit is active, and NULL if it is inactive or non-existent.
-
- RETURN VALUE.
-
- Returns 0 if no errors occur, and -1 otherwise. If an error occurs,
- errno is set appropriately:
-
- EFAULT Invalid user space pointer was passed
-
-IV. Getting Hardware Resource Table
-
- SYNOPSIS
-
- ioctl(fd, I2OHRTGET, struct i2o_cmd_hrt *hrt);
-
- struct i2o_cmd_hrtlct
- {
- u32 iop; /* IOP unit number */
- void *resbuf; /* Buffer for result */
- u32 *reslen; /* Buffer length in bytes */
- };
-
- DESCRIPTION
-
- This function returns the Hardware Resource Table of the IOP specified
- by hrt->iop in the buffer pointed to by hrt->resbuf. The actual size of
- the data is written into *(hrt->reslen).
-
- RETURNS
-
- This function returns 0 if no errors occur. If an error occurs, -1
- is returned and errno is set appropriately:
-
- EFAULT Invalid user space pointer was passed
- ENXIO Invalid IOP number
- ENOBUFS Buffer not large enough. If this occurs, the required
- buffer length is written into *(hrt->reslen)
-
-V. Getting Logical Configuration Table
-
- SYNOPSIS
-
- ioctl(fd, I2OLCTGET, struct i2o_cmd_lct *lct);
-
- struct i2o_cmd_hrtlct
- {
- u32 iop; /* IOP unit number */
- void *resbuf; /* Buffer for result */
- u32 *reslen; /* Buffer length in bytes */
- };
-
- DESCRIPTION
-
- This function returns the Logical Configuration Table of the IOP specified
- by lct->iop in the buffer pointed to by lct->resbuf. The actual size of
- the data is written into *(lct->reslen).
-
- RETURNS
-
- This function returns 0 if no errors occur. If an error occurs, -1
- is returned and errno is set appropriately:
-
- EFAULT Invalid user space pointer was passed
- ENXIO Invalid IOP number
- ENOBUFS Buffer not large enough. If this occurs, the required
- buffer length is written into *(lct->reslen)
-
-VI. Setting Parameters
-
- SYNOPSIS
-
- ioctl(fd, I2OPARMSET, struct i2o_parm_setget *ops);
-
- struct i2o_cmd_psetget
- {
- u32 iop; /* IOP unit number */
- u32 tid; /* Target device TID */
- void *opbuf; /* Operation List buffer */
- u32 oplen; /* Operation List buffer length in bytes */
- void *resbuf; /* Result List buffer */
- u32 *reslen; /* Result List buffer length in bytes */
- };
-
- DESCRIPTION
-
- This function posts a UtilParamsSet message to the device identified
- by ops->iop and ops->tid. The operation list for the message is
- sent through the ops->opbuf buffer, and the result list is written
- into the buffer pointed to by ops->resbuf. The number of bytes
- written is placed into *(ops->reslen).
-
- RETURNS
-
- The return value is the size in bytes of the data written into
- ops->resbuf if no errors occur. If an error occurs, -1 is returned
- and errno is set appropriately:
-
- EFAULT Invalid user space pointer was passed
- ENXIO Invalid IOP number
- ENOBUFS Buffer not large enough. If this occurs, the required
- buffer length is written into *(ops->reslen)
- ETIMEDOUT Timeout waiting for reply message
- ENOMEM Kernel memory allocation error
-
- A return value of 0 does not mean that the value was actually
- changed properly on the IOP. The user should check the result
- list to determine the specific status of the transaction.
-
-VII. Getting Parameters
-
- SYNOPSIS
-
- ioctl(fd, I2OPARMGET, struct i2o_parm_setget *ops);
-
- struct i2o_parm_setget
- {
- u32 iop; /* IOP unit number */
- u32 tid; /* Target device TID */
- void *opbuf; /* Operation List buffer */
- u32 oplen; /* Operation List buffer length in bytes */
- void *resbuf; /* Result List buffer */
- u32 *reslen; /* Result List buffer length in bytes */
- };
-
- DESCRIPTION
-
- This function posts a UtilParamsGet message to the device identified
- by ops->iop and ops->tid. The operation list for the message is
- sent through the ops->opbuf buffer, and the result list is written
- into the buffer pointed to by ops->resbuf. The actual size of data
- written is placed into *(ops->reslen).
-
- RETURNS
-
- EFAULT Invalid user space pointer was passed
- ENXIO Invalid IOP number
- ENOBUFS Buffer not large enough. If this occurs, the required
- buffer length is written into *(ops->reslen)
- ETIMEDOUT Timeout waiting for reply message
- ENOMEM Kernel memory allocation error
-
- A return value of 0 does not mean that the value was actually
- properly retrieved. The user should check the result list
- to determine the specific status of the transaction.
-
-VIII. Downloading Software
-
- SYNOPSIS
-
- ioctl(fd, I2OSWDL, struct i2o_sw_xfer *sw);
-
- struct i2o_sw_xfer
- {
- u32 iop; /* IOP unit number */
- u8 flags; /* DownloadFlags field */
- u8 sw_type; /* Software type */
- u32 sw_id; /* Software ID */
- void *buf; /* Pointer to software buffer */
- u32 *swlen; /* Length of software buffer */
- u32 *maxfrag; /* Number of fragments */
- u32 *curfrag; /* Current fragment number */
- };
-
- DESCRIPTION
-
- This function downloads a software fragment pointed by sw->buf
- to the iop identified by sw->iop. The DownloadFlags, SwID, SwType
- and SwSize fields of the ExecSwDownload message are filled in with
- the values of sw->flags, sw->sw_id, sw->sw_type and *(sw->swlen).
-
- The fragments _must_ be sent in order and be 8K in size. The last
- fragment _may_ be shorter, however. The kernel will compute its
- size based on information in the sw->swlen field.
-
- Please note that SW transfers can take a long time.
-
- RETURNS
-
- This function returns 0 no errors occur. If an error occurs, -1
- is returned and errno is set appropriately:
-
- EFAULT Invalid user space pointer was passed
- ENXIO Invalid IOP number
- ETIMEDOUT Timeout waiting for reply message
- ENOMEM Kernel memory allocation error
-
-IX. Uploading Software
-
- SYNOPSIS
-
- ioctl(fd, I2OSWUL, struct i2o_sw_xfer *sw);
-
- struct i2o_sw_xfer
- {
- u32 iop; /* IOP unit number */
- u8 flags; /* UploadFlags */
- u8 sw_type; /* Software type */
- u32 sw_id; /* Software ID */
- void *buf; /* Pointer to software buffer */
- u32 *swlen; /* Length of software buffer */
- u32 *maxfrag; /* Number of fragments */
- u32 *curfrag; /* Current fragment number */
- };
-
- DESCRIPTION
-
- This function uploads a software fragment from the IOP identified
- by sw->iop, sw->sw_type, sw->sw_id and optionally sw->swlen fields.
- The UploadFlags, SwID, SwType and SwSize fields of the ExecSwUpload
- message are filled in with the values of sw->flags, sw->sw_id,
- sw->sw_type and *(sw->swlen).
-
- The fragments _must_ be requested in order and be 8K in size. The
- user is responsible for allocating memory pointed by sw->buf. The
- last fragment _may_ be shorter.
-
- Please note that SW transfers can take a long time.
-
- RETURNS
-
- This function returns 0 if no errors occur. If an error occurs, -1
- is returned and errno is set appropriately:
-
- EFAULT Invalid user space pointer was passed
- ENXIO Invalid IOP number
- ETIMEDOUT Timeout waiting for reply message
- ENOMEM Kernel memory allocation error
-
-X. Removing Software
-
- SYNOPSIS
-
- ioctl(fd, I2OSWDEL, struct i2o_sw_xfer *sw);
-
- struct i2o_sw_xfer
- {
- u32 iop; /* IOP unit number */
- u8 flags; /* RemoveFlags */
- u8 sw_type; /* Software type */
- u32 sw_id; /* Software ID */
- void *buf; /* Unused */
- u32 *swlen; /* Length of the software data */
- u32 *maxfrag; /* Unused */
- u32 *curfrag; /* Unused */
- };
-
- DESCRIPTION
-
- This function removes software from the IOP identified by sw->iop.
- The RemoveFlags, SwID, SwType and SwSize fields of the ExecSwRemove message
- are filled in with the values of sw->flags, sw->sw_id, sw->sw_type and
- *(sw->swlen). Give zero in *(sw->len) if the value is unknown. IOP uses
- *(sw->swlen) value to verify correct identication of the module to remove.
- The actual size of the module is written into *(sw->swlen).
-
- RETURNS
-
- This function returns 0 if no errors occur. If an error occurs, -1
- is returned and errno is set appropriately:
-
- EFAULT Invalid user space pointer was passed
- ENXIO Invalid IOP number
- ETIMEDOUT Timeout waiting for reply message
- ENOMEM Kernel memory allocation error
-
-X. Validating Configuration
-
- SYNOPSIS
-
- ioctl(fd, I2OVALIDATE, int *iop);
- u32 iop;
-
- DESCRIPTION
-
- This function posts an ExecConfigValidate message to the controller
- identified by iop. This message indicates that the current
- configuration is accepted. The iop changes the status of suspect drivers
- to valid and may delete old drivers from its store.
-
- RETURNS
-
- This function returns 0 if no erro occur. If an error occurs, -1 is
- returned and errno is set appropriately:
-
- ETIMEDOUT Timeout waiting for reply message
- ENXIO Invalid IOP number
-
-XI. Configuration Dialog
-
- SYNOPSIS
-
- ioctl(fd, I2OHTML, struct i2o_html *htquery);
- struct i2o_html
- {
- u32 iop; /* IOP unit number */
- u32 tid; /* Target device ID */
- u32 page; /* HTML page */
- void *resbuf; /* Buffer for reply HTML page */
- u32 *reslen; /* Length in bytes of reply buffer */
- void *qbuf; /* Pointer to HTTP query string */
- u32 qlen; /* Length in bytes of query string buffer */
- };
-
- DESCRIPTION
-
- This function posts an UtilConfigDialog message to the device identified
- by htquery->iop and htquery->tid. The requested HTML page number is
- provided by the htquery->page field, and the resultant data is stored
- in the buffer pointed to by htquery->resbuf. If there is an HTTP query
- string that is to be sent to the device, it should be sent in the buffer
- pointed to by htquery->qbuf. If there is no query string, this field
- should be set to NULL. The actual size of the reply received is written
- into *(htquery->reslen).
-
- RETURNS
-
- This function returns 0 if no error occur. If an error occurs, -1
- is returned and errno is set appropriately:
-
- EFAULT Invalid user space pointer was passed
- ENXIO Invalid IOP number
- ENOBUFS Buffer not large enough. If this occurs, the required
- buffer length is written into *(ops->reslen)
- ETIMEDOUT Timeout waiting for reply message
- ENOMEM Kernel memory allocation error
-
-XII. Events
-
- In the process of determining this. Current idea is to have use
- the select() interface to allow user apps to periodically poll
- the /dev/i2o/ctl device for events. When select() notifies the user
- that an event is available, the user would call read() to retrieve
- a list of all the events that are pending for the specific device.
-
-=============================================================================
-Revision History
-=============================================================================
-
-Rev 0.1 - 04/01/99
-- Initial revision
-
-Rev 0.2 - 04/06/99
-- Changed return values to match UNIX ioctl() standard. Only return values
- are 0 and -1. All errors are reported through errno.
-- Added summary of proposed possible event interfaces
-
-Rev 0.3 - 04/20/99
-- Changed all ioctls() to use pointers to user data instead of actual data
-- Updated error values to match the code
diff --git a/drivers/staging/i2o/bus-osm.c b/drivers/staging/i2o/bus-osm.c
deleted file mode 100644
index 43e357eeeb672a..00000000000000
--- a/drivers/staging/i2o/bus-osm.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Bus Adapter OSM
- *
- * Copyright (C) 2005 Markus Lidel <Markus.Lidel@shadowconnect.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.
- *
- * Fixes/additions:
- * Markus Lidel <Markus.Lidel@shadowconnect.com>
- * initial version.
- */
-
-#include <linux/module.h>
-#include "i2o.h"
-
-#define OSM_NAME "bus-osm"
-#define OSM_VERSION "1.317"
-#define OSM_DESCRIPTION "I2O Bus Adapter OSM"
-
-static struct i2o_driver i2o_bus_driver;
-
-/* Bus OSM class handling definition */
-static struct i2o_class_id i2o_bus_class_id[] = {
- {I2O_CLASS_BUS_ADAPTER},
- {I2O_CLASS_END}
-};
-
-/**
- * i2o_bus_scan - Scan the bus for new devices
- * @dev: I2O device of the bus, which should be scanned
- *
- * Scans the bus dev for new / removed devices. After the scan a new LCT
- * will be fetched automatically.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_bus_scan(struct i2o_device *dev)
-{
- struct i2o_message *msg;
-
- msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return -ETIMEDOUT;
-
- msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_BUS_SCAN << 24 | HOST_TID << 12 | dev->lct_data.
- tid);
-
- return i2o_msg_post_wait(dev->iop, msg, 60);
-};
-
-/**
- * i2o_bus_store_scan - Scan the I2O Bus Adapter
- * @d: device which should be scanned
- * @attr: device_attribute
- * @buf: output buffer
- * @count: buffer size
- *
- * Returns count.
- */
-static ssize_t i2o_bus_store_scan(struct device *d,
- struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct i2o_device *i2o_dev = to_i2o_device(d);
- int rc;
-
- rc = i2o_bus_scan(i2o_dev);
- if (rc)
- osm_warn("bus scan failed %d\n", rc);
-
- return count;
-}
-
-/* Bus Adapter OSM device attributes */
-static DEVICE_ATTR(scan, S_IWUSR, NULL, i2o_bus_store_scan);
-
-/**
- * i2o_bus_probe - verify if dev is a I2O Bus Adapter device and install it
- * @dev: device to verify if it is a I2O Bus Adapter device
- *
- * Because we want all Bus Adapters always return 0.
- * Except when we fail. Then we are sad.
- *
- * Returns 0, except when we fail to excel.
- */
-static int i2o_bus_probe(struct device *dev)
-{
- struct i2o_device *i2o_dev = to_i2o_device(get_device(dev));
- int rc;
-
- rc = device_create_file(dev, &dev_attr_scan);
- if (rc)
- goto err_out;
-
- osm_info("device added (TID: %03x)\n", i2o_dev->lct_data.tid);
-
- return 0;
-
-err_out:
- put_device(dev);
- return rc;
-};
-
-/**
- * i2o_bus_remove - remove the I2O Bus Adapter device from the system again
- * @dev: I2O Bus Adapter device which should be removed
- *
- * Always returns 0.
- */
-static int i2o_bus_remove(struct device *dev)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
-
- device_remove_file(dev, &dev_attr_scan);
-
- put_device(dev);
-
- osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid);
-
- return 0;
-};
-
-/* Bus Adapter OSM driver struct */
-static struct i2o_driver i2o_bus_driver = {
- .name = OSM_NAME,
- .classes = i2o_bus_class_id,
- .driver = {
- .probe = i2o_bus_probe,
- .remove = i2o_bus_remove,
- },
-};
-
-/**
- * i2o_bus_init - Bus Adapter OSM initialization function
- *
- * Only register the Bus Adapter OSM in the I2O core.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int __init i2o_bus_init(void)
-{
- int rc;
-
- printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
-
- /* Register Bus Adapter OSM into I2O core */
- rc = i2o_driver_register(&i2o_bus_driver);
- if (rc) {
- osm_err("Could not register Bus Adapter OSM\n");
- return rc;
- }
-
- return 0;
-};
-
-/**
- * i2o_bus_exit - Bus Adapter OSM exit function
- *
- * Unregisters Bus Adapter OSM from I2O core.
- */
-static void __exit i2o_bus_exit(void)
-{
- i2o_driver_unregister(&i2o_bus_driver);
-};
-
-MODULE_AUTHOR("Markus Lidel <Markus.Lidel@shadowconnect.com>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(OSM_DESCRIPTION);
-MODULE_VERSION(OSM_VERSION);
-
-module_init(i2o_bus_init);
-module_exit(i2o_bus_exit);
diff --git a/drivers/staging/i2o/config-osm.c b/drivers/staging/i2o/config-osm.c
deleted file mode 100644
index 45091ac66154b2..00000000000000
--- a/drivers/staging/i2o/config-osm.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Configuration OSM
- *
- * Copyright (C) 2005 Markus Lidel <Markus.Lidel@shadowconnect.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.
- *
- * Fixes/additions:
- * Markus Lidel <Markus.Lidel@shadowconnect.com>
- * initial version.
- */
-
-#include <linux/module.h>
-#include "i2o.h"
-#include <linux/dcache.h>
-#include <linux/namei.h>
-#include <linux/fs.h>
-
-#include <linux/uaccess.h>
-
-#define OSM_NAME "config-osm"
-#define OSM_VERSION "1.323"
-#define OSM_DESCRIPTION "I2O Configuration OSM"
-
-/* access mode user rw */
-#define S_IWRSR (S_IRUSR | S_IWUSR)
-
-static struct i2o_driver i2o_config_driver;
-
-/* Config OSM driver struct */
-static struct i2o_driver i2o_config_driver = {
- .name = OSM_NAME,
-};
-
-#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL
-#include "i2o_config.c"
-#endif
-
-/**
- * i2o_config_init - Configuration OSM initialization function
- *
- * Registers Configuration OSM in the I2O core and if old ioctl's are
- * compiled in initialize them.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int __init i2o_config_init(void)
-{
- printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
-
- if (i2o_driver_register(&i2o_config_driver)) {
- osm_err("handler register failed.\n");
- return -EBUSY;
- }
-#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL
- if (i2o_config_old_init()) {
- osm_err("old config handler initialization failed\n");
- i2o_driver_unregister(&i2o_config_driver);
- return -EBUSY;
- }
-#endif
-
- return 0;
-}
-
-/**
- * i2o_config_exit - Configuration OSM exit function
- *
- * If old ioctl's are compiled in exit remove them and unregisters
- * Configuration OSM from I2O core.
- */
-static void i2o_config_exit(void)
-{
-#ifdef CONFIG_I2O_CONFIG_OLD_IOCTL
- i2o_config_old_exit();
-#endif
-
- i2o_driver_unregister(&i2o_config_driver);
-}
-
-MODULE_AUTHOR("Markus Lidel <Markus.Lidel@shadowconnect.com>");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(OSM_DESCRIPTION);
-MODULE_VERSION(OSM_VERSION);
-
-module_init(i2o_config_init);
-module_exit(i2o_config_exit);
diff --git a/drivers/staging/i2o/core.h b/drivers/staging/i2o/core.h
deleted file mode 100644
index 91614f11f89a38..00000000000000
--- a/drivers/staging/i2o/core.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * I2O core internal declarations
- *
- * Copyright (C) 2005 Markus Lidel <Markus.Lidel@shadowconnect.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.
- *
- * Fixes/additions:
- * Markus Lidel <Markus.Lidel@shadowconnect.com>
- * initial version.
- */
-
-/* Exec-OSM */
-extern struct i2o_driver i2o_exec_driver;
-extern int i2o_exec_lct_get(struct i2o_controller *);
-
-extern int __init i2o_exec_init(void);
-extern void i2o_exec_exit(void);
-
-/* driver */
-extern struct bus_type i2o_bus_type;
-
-extern int i2o_driver_dispatch(struct i2o_controller *, u32);
-
-extern int __init i2o_driver_init(void);
-extern void i2o_driver_exit(void);
-
-/* PCI */
-extern int __init i2o_pci_init(void);
-extern void __exit i2o_pci_exit(void);
-
-/* device */
-extern const struct attribute_group *i2o_device_groups[];
-
-extern void i2o_device_remove(struct i2o_device *);
-extern int i2o_device_parse_lct(struct i2o_controller *);
-
-int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
- int oplen, void *reslist, int reslen);
-
-/* IOP */
-extern struct i2o_controller *i2o_iop_alloc(void);
-
-/**
- * i2o_iop_free - Free the i2o_controller struct
- * @c: I2O controller to free
- */
-static inline void i2o_iop_free(struct i2o_controller *c)
-{
- i2o_pool_free(&c->in_msg);
- kfree(c);
-}
-
-extern int i2o_iop_add(struct i2o_controller *);
-extern void i2o_iop_remove(struct i2o_controller *);
-
-/* control registers relative to c->base */
-#define I2O_IRQ_STATUS 0x30
-#define I2O_IRQ_MASK 0x34
-#define I2O_IN_PORT 0x40
-#define I2O_OUT_PORT 0x44
-
-/* Motorola/Freescale specific register offset */
-#define I2O_MOTOROLA_PORT_OFFSET 0x10400
-
-#define I2O_IRQ_OUTBOUND_POST 0x00000008
diff --git a/drivers/staging/i2o/debug.c b/drivers/staging/i2o/debug.c
deleted file mode 100644
index 12b783b2a86c8f..00000000000000
--- a/drivers/staging/i2o/debug.c
+++ /dev/null
@@ -1,473 +0,0 @@
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include "i2o.h"
-
-static void i2o_report_util_cmd(u8 cmd);
-static void i2o_report_exec_cmd(u8 cmd);
-static void i2o_report_fail_status(u8 req_status, u32 *msg);
-static void i2o_report_common_status(u8 req_status);
-static void i2o_report_common_dsc(u16 detailed_status);
-
-/*
- * Used for error reporting/debugging purposes.
- * Report Cmd name, Request status, Detailed Status.
- */
-void i2o_report_status(const char *severity, const char *str,
- struct i2o_message *m)
-{
- u32 *msg = (u32 *) m;
- u8 cmd = (msg[1] >> 24) & 0xFF;
- u8 req_status = (msg[4] >> 24) & 0xFF;
- u16 detailed_status = msg[4] & 0xFFFF;
-
- if (cmd == I2O_CMD_UTIL_EVT_REGISTER)
- return; /* No status in this reply */
-
- printk("%s%s: ", severity, str);
-
- if (cmd < 0x1F) // Utility cmd
- i2o_report_util_cmd(cmd);
-
- else if (cmd >= 0xA0 && cmd <= 0xEF) // Executive cmd
- i2o_report_exec_cmd(cmd);
- else
- printk("Cmd = %0#2x, ", cmd); // Other cmds
-
- if (msg[0] & MSG_FAIL) {
- i2o_report_fail_status(req_status, msg);
- return;
- }
-
- i2o_report_common_status(req_status);
-
- if (cmd < 0x1F || (cmd >= 0xA0 && cmd <= 0xEF))
- i2o_report_common_dsc(detailed_status);
- else
- printk(" / DetailedStatus = %0#4x.\n",
- detailed_status);
-}
-
-/* Used to dump a message to syslog during debugging */
-void i2o_dump_message(struct i2o_message *m)
-{
-#ifdef DEBUG
- u32 *msg = (u32 *) m;
- int i;
-
- printk(KERN_INFO "Dumping I2O message size %d @ %p\n",
- msg[0] >> 16 & 0xffff, msg);
- for (i = 0; i < ((msg[0] >> 16) & 0xffff); i++)
- printk(KERN_INFO " msg[%d] = %0#10x\n", i, msg[i]);
-#endif
-}
-
-/*
- * Used for error reporting/debugging purposes.
- * Following fail status are common to all classes.
- * The preserved message must be handled in the reply handler.
- */
-static void i2o_report_fail_status(u8 req_status, u32 *msg)
-{
- static char *FAIL_STATUS[] = {
- "0x80", /* not used */
- "SERVICE_SUSPENDED", /* 0x81 */
- "SERVICE_TERMINATED", /* 0x82 */
- "CONGESTION",
- "FAILURE",
- "STATE_ERROR",
- "TIME_OUT",
- "ROUTING_FAILURE",
- "INVALID_VERSION",
- "INVALID_OFFSET",
- "INVALID_MSG_FLAGS",
- "FRAME_TOO_SMALL",
- "FRAME_TOO_LARGE",
- "INVALID_TARGET_ID",
- "INVALID_INITIATOR_ID",
- "INVALID_INITIATOR_CONTEX", /* 0x8F */
- "UNKNOWN_FAILURE" /* 0xFF */
- };
-
- if (req_status == I2O_FSC_TRANSPORT_UNKNOWN_FAILURE)
- printk("TRANSPORT_UNKNOWN_FAILURE (%0#2x).\n",
- req_status);
- else
- printk("TRANSPORT_%s.\n",
- FAIL_STATUS[req_status & 0x0F]);
-
- /* Dump some details */
-
- printk(KERN_ERR " InitiatorId = %d, TargetId = %d\n",
- (msg[1] >> 12) & 0xFFF, msg[1] & 0xFFF);
- printk(KERN_ERR " LowestVersion = 0x%02X, HighestVersion = 0x%02X\n",
- (msg[4] >> 8) & 0xFF, msg[4] & 0xFF);
- printk(KERN_ERR " FailingHostUnit = 0x%04X, FailingIOP = 0x%03X\n",
- msg[5] >> 16, msg[5] & 0xFFF);
-
- printk(KERN_ERR " Severity: 0x%02X\n", (msg[4] >> 16) & 0xFF);
- if (msg[4] & (1 << 16))
- printk(KERN_DEBUG "(FormatError), "
- "this msg can never be delivered/processed.\n");
- if (msg[4] & (1 << 17))
- printk(KERN_DEBUG "(PathError), "
- "this msg can no longer be delivered/processed.\n");
- if (msg[4] & (1 << 18))
- printk(KERN_DEBUG "(PathState), "
- "the system state does not allow delivery.\n");
- if (msg[4] & (1 << 19))
- printk(KERN_DEBUG
- "(Congestion), resources temporarily not available;"
- "do not retry immediately.\n");
-}
-
-/*
- * Used for error reporting/debugging purposes.
- * Following reply status are common to all classes.
- */
-static void i2o_report_common_status(u8 req_status)
-{
- static char *REPLY_STATUS[] = {
- "SUCCESS",
- "ABORT_DIRTY",
- "ABORT_NO_DATA_TRANSFER",
- "ABORT_PARTIAL_TRANSFER",
- "ERROR_DIRTY",
- "ERROR_NO_DATA_TRANSFER",
- "ERROR_PARTIAL_TRANSFER",
- "PROCESS_ABORT_DIRTY",
- "PROCESS_ABORT_NO_DATA_TRANSFER",
- "PROCESS_ABORT_PARTIAL_TRANSFER",
- "TRANSACTION_ERROR",
- "PROGRESS_REPORT"
- };
-
- if (req_status >= ARRAY_SIZE(REPLY_STATUS))
- printk("RequestStatus = %0#2x", req_status);
- else
- printk("%s", REPLY_STATUS[req_status]);
-}
-
-/*
- * Used for error reporting/debugging purposes.
- * Following detailed status are valid for executive class,
- * utility class, DDM class and for transaction error replies.
- */
-static void i2o_report_common_dsc(u16 detailed_status)
-{
- static char *COMMON_DSC[] = {
- "SUCCESS",
- "0x01", // not used
- "BAD_KEY",
- "TCL_ERROR",
- "REPLY_BUFFER_FULL",
- "NO_SUCH_PAGE",
- "INSUFFICIENT_RESOURCE_SOFT",
- "INSUFFICIENT_RESOURCE_HARD",
- "0x08", // not used
- "CHAIN_BUFFER_TOO_LARGE",
- "UNSUPPORTED_FUNCTION",
- "DEVICE_LOCKED",
- "DEVICE_RESET",
- "INAPPROPRIATE_FUNCTION",
- "INVALID_INITIATOR_ADDRESS",
- "INVALID_MESSAGE_FLAGS",
- "INVALID_OFFSET",
- "INVALID_PARAMETER",
- "INVALID_REQUEST",
- "INVALID_TARGET_ADDRESS",
- "MESSAGE_TOO_LARGE",
- "MESSAGE_TOO_SMALL",
- "MISSING_PARAMETER",
- "TIMEOUT",
- "UNKNOWN_ERROR",
- "UNKNOWN_FUNCTION",
- "UNSUPPORTED_VERSION",
- "DEVICE_BUSY",
- "DEVICE_NOT_AVAILABLE"
- };
-
- if (detailed_status > I2O_DSC_DEVICE_NOT_AVAILABLE)
- printk(" / DetailedStatus = %0#4x.\n",
- detailed_status);
- else
- printk(" / %s.\n", COMMON_DSC[detailed_status]);
-}
-
-/*
- * Used for error reporting/debugging purposes
- */
-static void i2o_report_util_cmd(u8 cmd)
-{
- switch (cmd) {
- case I2O_CMD_UTIL_NOP:
- printk("UTIL_NOP, ");
- break;
- case I2O_CMD_UTIL_ABORT:
- printk("UTIL_ABORT, ");
- break;
- case I2O_CMD_UTIL_CLAIM:
- printk("UTIL_CLAIM, ");
- break;
- case I2O_CMD_UTIL_RELEASE:
- printk("UTIL_CLAIM_RELEASE, ");
- break;
- case I2O_CMD_UTIL_CONFIG_DIALOG:
- printk("UTIL_CONFIG_DIALOG, ");
- break;
- case I2O_CMD_UTIL_DEVICE_RESERVE:
- printk("UTIL_DEVICE_RESERVE, ");
- break;
- case I2O_CMD_UTIL_DEVICE_RELEASE:
- printk("UTIL_DEVICE_RELEASE, ");
- break;
- case I2O_CMD_UTIL_EVT_ACK:
- printk("UTIL_EVENT_ACKNOWLEDGE, ");
- break;
- case I2O_CMD_UTIL_EVT_REGISTER:
- printk("UTIL_EVENT_REGISTER, ");
- break;
- case I2O_CMD_UTIL_LOCK:
- printk("UTIL_LOCK, ");
- break;
- case I2O_CMD_UTIL_LOCK_RELEASE:
- printk("UTIL_LOCK_RELEASE, ");
- break;
- case I2O_CMD_UTIL_PARAMS_GET:
- printk("UTIL_PARAMS_GET, ");
- break;
- case I2O_CMD_UTIL_PARAMS_SET:
- printk("UTIL_PARAMS_SET, ");
- break;
- case I2O_CMD_UTIL_REPLY_FAULT_NOTIFY:
- printk("UTIL_REPLY_FAULT_NOTIFY, ");
- break;
- default:
- printk("Cmd = %0#2x, ", cmd);
- }
-}
-
-/*
- * Used for error reporting/debugging purposes
- */
-static void i2o_report_exec_cmd(u8 cmd)
-{
- switch (cmd) {
- case I2O_CMD_ADAPTER_ASSIGN:
- printk("EXEC_ADAPTER_ASSIGN, ");
- break;
- case I2O_CMD_ADAPTER_READ:
- printk("EXEC_ADAPTER_READ, ");
- break;
- case I2O_CMD_ADAPTER_RELEASE:
- printk("EXEC_ADAPTER_RELEASE, ");
- break;
- case I2O_CMD_BIOS_INFO_SET:
- printk("EXEC_BIOS_INFO_SET, ");
- break;
- case I2O_CMD_BOOT_DEVICE_SET:
- printk("EXEC_BOOT_DEVICE_SET, ");
- break;
- case I2O_CMD_CONFIG_VALIDATE:
- printk("EXEC_CONFIG_VALIDATE, ");
- break;
- case I2O_CMD_CONN_SETUP:
- printk("EXEC_CONN_SETUP, ");
- break;
- case I2O_CMD_DDM_DESTROY:
- printk("EXEC_DDM_DESTROY, ");
- break;
- case I2O_CMD_DDM_ENABLE:
- printk("EXEC_DDM_ENABLE, ");
- break;
- case I2O_CMD_DDM_QUIESCE:
- printk("EXEC_DDM_QUIESCE, ");
- break;
- case I2O_CMD_DDM_RESET:
- printk("EXEC_DDM_RESET, ");
- break;
- case I2O_CMD_DDM_SUSPEND:
- printk("EXEC_DDM_SUSPEND, ");
- break;
- case I2O_CMD_DEVICE_ASSIGN:
- printk("EXEC_DEVICE_ASSIGN, ");
- break;
- case I2O_CMD_DEVICE_RELEASE:
- printk("EXEC_DEVICE_RELEASE, ");
- break;
- case I2O_CMD_HRT_GET:
- printk("EXEC_HRT_GET, ");
- break;
- case I2O_CMD_ADAPTER_CLEAR:
- printk("EXEC_IOP_CLEAR, ");
- break;
- case I2O_CMD_ADAPTER_CONNECT:
- printk("EXEC_IOP_CONNECT, ");
- break;
- case I2O_CMD_ADAPTER_RESET:
- printk("EXEC_IOP_RESET, ");
- break;
- case I2O_CMD_LCT_NOTIFY:
- printk("EXEC_LCT_NOTIFY, ");
- break;
- case I2O_CMD_OUTBOUND_INIT:
- printk("EXEC_OUTBOUND_INIT, ");
- break;
- case I2O_CMD_PATH_ENABLE:
- printk("EXEC_PATH_ENABLE, ");
- break;
- case I2O_CMD_PATH_QUIESCE:
- printk("EXEC_PATH_QUIESCE, ");
- break;
- case I2O_CMD_PATH_RESET:
- printk("EXEC_PATH_RESET, ");
- break;
- case I2O_CMD_STATIC_MF_CREATE:
- printk("EXEC_STATIC_MF_CREATE, ");
- break;
- case I2O_CMD_STATIC_MF_RELEASE:
- printk("EXEC_STATIC_MF_RELEASE, ");
- break;
- case I2O_CMD_STATUS_GET:
- printk("EXEC_STATUS_GET, ");
- break;
- case I2O_CMD_SW_DOWNLOAD:
- printk("EXEC_SW_DOWNLOAD, ");
- break;
- case I2O_CMD_SW_UPLOAD:
- printk("EXEC_SW_UPLOAD, ");
- break;
- case I2O_CMD_SW_REMOVE:
- printk("EXEC_SW_REMOVE, ");
- break;
- case I2O_CMD_SYS_ENABLE:
- printk("EXEC_SYS_ENABLE, ");
- break;
- case I2O_CMD_SYS_MODIFY:
- printk("EXEC_SYS_MODIFY, ");
- break;
- case I2O_CMD_SYS_QUIESCE:
- printk("EXEC_SYS_QUIESCE, ");
- break;
- case I2O_CMD_SYS_TAB_SET:
- printk("EXEC_SYS_TAB_SET, ");
- break;
- default:
- printk("Cmd = %#02x, ", cmd);
- }
-}
-
-void i2o_debug_state(struct i2o_controller *c)
-{
- printk(KERN_INFO "%s: State = ", c->name);
- switch (((i2o_status_block *) c->status_block.virt)->iop_state) {
- case 0x01:
- printk("INIT\n");
- break;
- case 0x02:
- printk("RESET\n");
- break;
- case 0x04:
- printk("HOLD\n");
- break;
- case 0x05:
- printk("READY\n");
- break;
- case 0x08:
- printk("OPERATIONAL\n");
- break;
- case 0x10:
- printk("FAILED\n");
- break;
- case 0x11:
- printk("FAULTED\n");
- break;
- default:
- printk("%x (unknown !!)\n",
- ((i2o_status_block *) c->status_block.virt)->iop_state);
- }
-};
-
-void i2o_dump_hrt(struct i2o_controller *c)
-{
- u32 *rows = (u32 *) c->hrt.virt;
- u8 *p = (u8 *) c->hrt.virt;
- u8 *d;
- int count;
- int length;
- int i;
- int state;
-
- if (p[3] != 0) {
- printk(KERN_ERR
- "%s: HRT table for controller is too new a version.\n",
- c->name);
- return;
- }
-
- count = p[0] | (p[1] << 8);
- length = p[2];
-
- printk(KERN_INFO "%s: HRT has %d entries of %d bytes each.\n",
- c->name, count, length << 2);
-
- rows += 2;
-
- for (i = 0; i < count; i++) {
- printk(KERN_INFO "Adapter %08X: ", rows[0]);
- p = (u8 *) (rows + 1);
- d = (u8 *) (rows + 2);
- state = p[1] << 8 | p[0];
-
- printk("TID %04X:[", state & 0xFFF);
- state >>= 12;
- if (state & (1 << 0))
- printk("H"); /* Hidden */
- if (state & (1 << 2)) {
- printk("P"); /* Present */
- if (state & (1 << 1))
- printk("C"); /* Controlled */
- }
- if (state > 9)
- printk("*"); /* Hard */
-
- printk("]:");
-
- switch (p[3] & 0xFFFF) {
- case 0:
- /* Adapter private bus - easy */
- printk("Local bus %d: I/O at 0x%04X Mem 0x%08X", p[2],
- d[1] << 8 | d[0], *(u32 *) (d + 4));
- break;
- case 1:
- /* ISA bus */
- printk("ISA %d: CSN %d I/O at 0x%04X Mem 0x%08X", p[2],
- d[2], d[1] << 8 | d[0], *(u32 *) (d + 4));
- break;
-
- case 2: /* EISA bus */
- printk("EISA %d: Slot %d I/O at 0x%04X Mem 0x%08X",
- p[2], d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
- break;
-
- case 3: /* MCA bus */
- printk("MCA %d: Slot %d I/O at 0x%04X Mem 0x%08X", p[2],
- d[3], d[1] << 8 | d[0], *(u32 *) (d + 4));
- break;
-
- case 4: /* PCI bus */
- printk("PCI %d: Bus %d Device %d Function %d", p[2],
- d[2], d[1], d[0]);
- break;
-
- case 0x80: /* Other */
- default:
- printk("Unsupported bus type.");
- break;
- }
- printk("\n");
- rows += length;
- }
-}
-
-EXPORT_SYMBOL(i2o_dump_message);
diff --git a/drivers/staging/i2o/device.c b/drivers/staging/i2o/device.c
deleted file mode 100644
index e47496cb0ac218..00000000000000
--- a/drivers/staging/i2o/device.c
+++ /dev/null
@@ -1,592 +0,0 @@
-/*
- * Functions to handle I2O devices
- *
- * Copyright (C) 2004 Markus Lidel <Markus.Lidel@shadowconnect.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.
- *
- * Fixes/additions:
- * Markus Lidel <Markus.Lidel@shadowconnect.com>
- * initial version.
- */
-
-#include <linux/module.h>
-#include "i2o.h"
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include "core.h"
-
-/**
- * i2o_device_issue_claim - claim or release a device
- * @dev: I2O device to claim or release
- * @cmd: claim or release command
- * @type: type of claim
- *
- * Issue I2O UTIL_CLAIM or UTIL_RELEASE messages. The message to be sent
- * is set by cmd. dev is the I2O device which should be claim or
- * released and the type is the claim type (see the I2O spec).
- *
- * Returs 0 on success or negative error code on failure.
- */
-static inline int i2o_device_issue_claim(struct i2o_device *dev, u32 cmd,
- u32 type)
-{
- struct i2o_message *msg;
-
- msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(cmd << 24 | HOST_TID << 12 | dev->lct_data.tid);
- msg->body[0] = cpu_to_le32(type);
-
- return i2o_msg_post_wait(dev->iop, msg, 60);
-}
-
-/**
- * i2o_device_claim - claim a device for use by an OSM
- * @dev: I2O device to claim
- *
- * Do the leg work to assign a device to a given OSM. If the claim succeeds,
- * the owner is the primary. If the attempt fails a negative errno code
- * is returned. On success zero is returned.
- */
-int i2o_device_claim(struct i2o_device *dev)
-{
- int rc = 0;
-
- mutex_lock(&dev->lock);
-
- rc = i2o_device_issue_claim(dev, I2O_CMD_UTIL_CLAIM, I2O_CLAIM_PRIMARY);
- if (!rc)
- pr_debug("i2o: claim of device %d succeeded\n",
- dev->lct_data.tid);
- else
- pr_debug("i2o: claim of device %d failed %d\n",
- dev->lct_data.tid, rc);
-
- mutex_unlock(&dev->lock);
-
- return rc;
-}
-
-/**
- * i2o_device_claim_release - release a device that the OSM is using
- * @dev: device to release
- *
- * Drop a claim by an OSM on a given I2O device.
- *
- * AC - some devices seem to want to refuse an unclaim until they have
- * finished internal processing. It makes sense since you don't want a
- * new device to go reconfiguring the entire system until you are done.
- * Thus we are prepared to wait briefly.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_device_claim_release(struct i2o_device *dev)
-{
- int tries;
- int rc = 0;
-
- mutex_lock(&dev->lock);
-
- /*
- * If the controller takes a nonblocking approach to
- * releases we have to sleep/poll for a few times.
- */
- for (tries = 0; tries < 10; tries++) {
- rc = i2o_device_issue_claim(dev, I2O_CMD_UTIL_RELEASE,
- I2O_CLAIM_PRIMARY);
- if (!rc)
- break;
-
- ssleep(1);
- }
-
- if (!rc)
- pr_debug("i2o: claim release of device %d succeeded\n",
- dev->lct_data.tid);
- else
- pr_debug("i2o: claim release of device %d failed %d\n",
- dev->lct_data.tid, rc);
-
- mutex_unlock(&dev->lock);
-
- return rc;
-}
-
-/**
- * i2o_device_release - release the memory for a I2O device
- * @dev: I2O device which should be released
- *
- * Release the allocated memory. This function is called if refcount of
- * device reaches 0 automatically.
- */
-static void i2o_device_release(struct device *dev)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
-
- pr_debug("i2o: device %s released\n", dev_name(dev));
-
- kfree(i2o_dev);
-}
-
-/**
- * class_id_show - Displays class id of I2O device
- * @dev: device of which the class id should be displayed
- * @attr: pointer to device attribute
- * @buf: buffer into which the class id should be printed
- *
- * Returns the number of bytes which are printed into the buffer.
- */
-static ssize_t class_id_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
-
- sprintf(buf, "0x%03x\n", i2o_dev->lct_data.class_id);
- return strlen(buf) + 1;
-}
-static DEVICE_ATTR_RO(class_id);
-
-/**
- * tid_show - Displays TID of I2O device
- * @dev: device of which the TID should be displayed
- * @attr: pointer to device attribute
- * @buf: buffer into which the TID should be printed
- *
- * Returns the number of bytes which are printed into the buffer.
- */
-static ssize_t tid_show(struct device *dev, struct device_attribute *attr,
- char *buf)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
-
- sprintf(buf, "0x%03x\n", i2o_dev->lct_data.tid);
- return strlen(buf) + 1;
-}
-static DEVICE_ATTR_RO(tid);
-
-/* I2O device attributes */
-static struct attribute *i2o_device_attrs[] = {
- &dev_attr_class_id.attr,
- &dev_attr_tid.attr,
- NULL,
-};
-
-static const struct attribute_group i2o_device_group = {
- .attrs = i2o_device_attrs,
-};
-
-const struct attribute_group *i2o_device_groups[] = {
- &i2o_device_group,
- NULL,
-};
-
-/**
- * i2o_device_alloc - Allocate a I2O device and initialize it
- *
- * Allocate the memory for a I2O device and initialize locks and lists
- *
- * Returns the allocated I2O device or a negative error code if the device
- * could not be allocated.
- */
-static struct i2o_device *i2o_device_alloc(void)
-{
- struct i2o_device *dev;
-
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (!dev)
- return ERR_PTR(-ENOMEM);
-
- INIT_LIST_HEAD(&dev->list);
- mutex_init(&dev->lock);
-
- dev->device.bus = &i2o_bus_type;
- dev->device.release = &i2o_device_release;
-
- return dev;
-}
-
-/**
- * i2o_device_add - allocate a new I2O device and add it to the IOP
- * @c: I2O controller that the device is on
- * @entry: LCT entry of the I2O device
- *
- * Allocate a new I2O device and initialize it with the LCT entry. The
- * device is appended to the device list of the controller.
- *
- * Returns zero on success, or a -ve errno.
- */
-static int i2o_device_add(struct i2o_controller *c, i2o_lct_entry *entry)
-{
- struct i2o_device *i2o_dev, *tmp;
- int rc;
-
- i2o_dev = i2o_device_alloc();
- if (IS_ERR(i2o_dev)) {
- printk(KERN_ERR "i2o: unable to allocate i2o device\n");
- return PTR_ERR(i2o_dev);
- }
-
- i2o_dev->lct_data = *entry;
-
- dev_set_name(&i2o_dev->device, "%d:%03x", c->unit,
- i2o_dev->lct_data.tid);
-
- i2o_dev->iop = c;
- i2o_dev->device.parent = &c->device;
-
- rc = device_register(&i2o_dev->device);
- if (rc)
- goto err;
-
- list_add_tail(&i2o_dev->list, &c->devices);
-
- /* create user entries for this device */
- tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.user_tid);
- if (tmp && (tmp != i2o_dev)) {
- rc = sysfs_create_link(&i2o_dev->device.kobj,
- &tmp->device.kobj, "user");
- if (rc)
- goto unreg_dev;
- }
-
- /* create user entries referring to this device */
- list_for_each_entry(tmp, &c->devices, list)
- if ((tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
- && (tmp != i2o_dev)) {
- rc = sysfs_create_link(&tmp->device.kobj,
- &i2o_dev->device.kobj, "user");
- if (rc)
- goto rmlink1;
- }
-
- /* create parent entries for this device */
- tmp = i2o_iop_find_device(i2o_dev->iop, i2o_dev->lct_data.parent_tid);
- if (tmp && (tmp != i2o_dev)) {
- rc = sysfs_create_link(&i2o_dev->device.kobj,
- &tmp->device.kobj, "parent");
- if (rc)
- goto rmlink1;
- }
-
- /* create parent entries referring to this device */
- list_for_each_entry(tmp, &c->devices, list)
- if ((tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
- && (tmp != i2o_dev)) {
- rc = sysfs_create_link(&tmp->device.kobj,
- &i2o_dev->device.kobj, "parent");
- if (rc)
- goto rmlink2;
- }
-
- i2o_driver_notify_device_add_all(i2o_dev);
-
- pr_debug("i2o: device %s added\n", dev_name(&i2o_dev->device));
-
- return 0;
-
-rmlink2:
- /* If link creating failed halfway, we loop whole list to cleanup.
- * And we don't care wrong removing of link, because sysfs_remove_link
- * will take care of it.
- */
- list_for_each_entry(tmp, &c->devices, list) {
- if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
- sysfs_remove_link(&tmp->device.kobj, "parent");
- }
- sysfs_remove_link(&i2o_dev->device.kobj, "parent");
-rmlink1:
- list_for_each_entry(tmp, &c->devices, list)
- if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
- sysfs_remove_link(&tmp->device.kobj, "user");
- sysfs_remove_link(&i2o_dev->device.kobj, "user");
-unreg_dev:
- list_del(&i2o_dev->list);
- device_unregister(&i2o_dev->device);
-err:
- kfree(i2o_dev);
- return rc;
-}
-
-/**
- * i2o_device_remove - remove an I2O device from the I2O core
- * @i2o_dev: I2O device which should be released
- *
- * Is used on I2O controller removal or LCT modification, when the device
- * is removed from the system. Note that the device could still hang
- * around until the refcount reaches 0.
- */
-void i2o_device_remove(struct i2o_device *i2o_dev)
-{
- struct i2o_device *tmp;
- struct i2o_controller *c = i2o_dev->iop;
-
- i2o_driver_notify_device_remove_all(i2o_dev);
-
- sysfs_remove_link(&i2o_dev->device.kobj, "parent");
- sysfs_remove_link(&i2o_dev->device.kobj, "user");
-
- list_for_each_entry(tmp, &c->devices, list) {
- if (tmp->lct_data.parent_tid == i2o_dev->lct_data.tid)
- sysfs_remove_link(&tmp->device.kobj, "parent");
- if (tmp->lct_data.user_tid == i2o_dev->lct_data.tid)
- sysfs_remove_link(&tmp->device.kobj, "user");
- }
- list_del(&i2o_dev->list);
-
- device_unregister(&i2o_dev->device);
-}
-
-/**
- * i2o_device_parse_lct - Parse a previously fetched LCT and create devices
- * @c: I2O controller from which the LCT should be parsed.
- *
- * The Logical Configuration Table tells us what we can talk to on the
- * board. For every entry we create an I2O device, which is registered in
- * the I2O core.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_device_parse_lct(struct i2o_controller *c)
-{
- struct i2o_device *dev, *tmp;
- i2o_lct *lct;
- u32 *dlct = c->dlct.virt;
- int max = 0, i = 0;
- u16 table_size;
- u32 buf;
-
- mutex_lock(&c->lct_lock);
-
- kfree(c->lct);
-
- buf = le32_to_cpu(*dlct++);
- table_size = buf & 0xffff;
-
- lct = c->lct = kmalloc(table_size * 4, GFP_KERNEL);
- if (!lct) {
- mutex_unlock(&c->lct_lock);
- return -ENOMEM;
- }
-
- lct->lct_ver = buf >> 28;
- lct->boot_tid = buf >> 16 & 0xfff;
- lct->table_size = table_size;
- lct->change_ind = le32_to_cpu(*dlct++);
- lct->iop_flags = le32_to_cpu(*dlct++);
-
- table_size -= 3;
-
- pr_debug("%s: LCT has %d entries (LCT size: %d)\n", c->name, max,
- lct->table_size);
-
- while (table_size > 0) {
- i2o_lct_entry *entry = &lct->lct_entry[max];
- int found = 0;
-
- buf = le32_to_cpu(*dlct++);
- entry->entry_size = buf & 0xffff;
- entry->tid = buf >> 16 & 0xfff;
-
- entry->change_ind = le32_to_cpu(*dlct++);
- entry->device_flags = le32_to_cpu(*dlct++);
-
- buf = le32_to_cpu(*dlct++);
- entry->class_id = buf & 0xfff;
- entry->version = buf >> 12 & 0xf;
- entry->vendor_id = buf >> 16;
-
- entry->sub_class = le32_to_cpu(*dlct++);
-
- buf = le32_to_cpu(*dlct++);
- entry->user_tid = buf & 0xfff;
- entry->parent_tid = buf >> 12 & 0xfff;
- entry->bios_info = buf >> 24;
-
- memcpy(&entry->identity_tag, dlct, 8);
- dlct += 2;
-
- entry->event_capabilities = le32_to_cpu(*dlct++);
-
- /* add new devices, which are new in the LCT */
- list_for_each_entry_safe(dev, tmp, &c->devices, list) {
- if (entry->tid == dev->lct_data.tid) {
- found = 1;
- break;
- }
- }
-
- if (!found)
- i2o_device_add(c, entry);
-
- table_size -= 9;
- max++;
- }
-
- /* remove devices, which are not in the LCT anymore */
- list_for_each_entry_safe(dev, tmp, &c->devices, list) {
- int found = 0;
-
- for (i = 0; i < max; i++) {
- if (lct->lct_entry[i].tid == dev->lct_data.tid) {
- found = 1;
- break;
- }
- }
-
- if (!found)
- i2o_device_remove(dev);
- }
-
- mutex_unlock(&c->lct_lock);
-
- return 0;
-}
-
-/*
- * Run time support routines
- */
-
-/* Issue UTIL_PARAMS_GET or UTIL_PARAMS_SET
- *
- * This function can be used for all UtilParamsGet/Set operations.
- * The OperationList is given in oplist-buffer,
- * and results are returned in reslist-buffer.
- * Note that the minimum sized reslist is 8 bytes and contains
- * ResultCount, ErrorInfoSize, BlockStatus and BlockSize.
- */
-int i2o_parm_issue(struct i2o_device *i2o_dev, int cmd, void *oplist,
- int oplen, void *reslist, int reslen)
-{
- struct i2o_message *msg;
- int i = 0;
- int rc;
- struct i2o_dma res;
- struct i2o_controller *c = i2o_dev->iop;
- struct device *dev = &c->pdev->dev;
-
- res.virt = NULL;
-
- if (i2o_dma_alloc(dev, &res, reslen))
- return -ENOMEM;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg)) {
- i2o_dma_free(dev, &res);
- return PTR_ERR(msg);
- }
-
- i = 0;
- msg->u.head[1] =
- cpu_to_le32(cmd << 24 | HOST_TID << 12 | i2o_dev->lct_data.tid);
- msg->body[i++] = cpu_to_le32(0x00000000);
- msg->body[i++] = cpu_to_le32(0x4C000000 | oplen); /* OperationList */
- memcpy(&msg->body[i], oplist, oplen);
- i += (oplen / 4 + (oplen % 4 ? 1 : 0));
- msg->body[i++] = cpu_to_le32(0xD0000000 | res.len); /* ResultList */
- msg->body[i++] = cpu_to_le32(res.phys);
-
- msg->u.head[0] =
- cpu_to_le32(I2O_MESSAGE_SIZE(i + sizeof(struct i2o_message) / 4) |
- SGL_OFFSET_5);
-
- rc = i2o_msg_post_wait_mem(c, msg, 10, &res);
-
- /* This only looks like a memory leak - don't "fix" it. */
- if (rc == -ETIMEDOUT)
- return rc;
-
- memcpy(reslist, res.virt, res.len);
- i2o_dma_free(dev, &res);
-
- return rc;
-}
-
-/*
- * Query one field group value or a whole scalar group.
- */
-int i2o_parm_field_get(struct i2o_device *i2o_dev, int group, int field,
- void *buf, int buflen)
-{
- u32 opblk[] = { cpu_to_le32(0x00000001),
- cpu_to_le32((u16) group << 16 | I2O_PARAMS_FIELD_GET),
- cpu_to_le32((s16) field << 16 | 0x00000001)
- };
- u8 *resblk; /* 8 bytes for header */
- int rc;
-
- resblk = kmalloc(buflen + 8, GFP_KERNEL);
- if (!resblk)
- return -ENOMEM;
-
- rc = i2o_parm_issue(i2o_dev, I2O_CMD_UTIL_PARAMS_GET, opblk,
- sizeof(opblk), resblk, buflen + 8);
-
- memcpy(buf, resblk + 8, buflen); /* cut off header */
-
- kfree(resblk);
-
- return rc;
-}
-
-/*
- * if oper == I2O_PARAMS_TABLE_GET, get from all rows
- * if fieldcount == -1 return all fields
- * ibuf and ibuflen are unused (use NULL, 0)
- * else return specific fields
- * ibuf contains fieldindexes
- *
- * if oper == I2O_PARAMS_LIST_GET, get from specific rows
- * if fieldcount == -1 return all fields
- * ibuf contains rowcount, keyvalues
- * else return specific fields
- * fieldcount is # of fieldindexes
- * ibuf contains fieldindexes, rowcount, keyvalues
- *
- * You could also use directly function i2o_issue_params().
- */
-int i2o_parm_table_get(struct i2o_device *dev, int oper, int group,
- int fieldcount, void *ibuf, int ibuflen, void *resblk,
- int reslen)
-{
- u16 *opblk;
- int size;
-
- size = 10 + ibuflen;
- if (size % 4)
- size += 4 - size % 4;
-
- opblk = kmalloc(size, GFP_KERNEL);
- if (opblk == NULL)
- return -ENOMEM;
-
- opblk[0] = 1; /* operation count */
- opblk[1] = 0; /* pad */
- opblk[2] = oper;
- opblk[3] = group;
- opblk[4] = fieldcount;
- memcpy(opblk + 5, ibuf, ibuflen); /* other params */
-
- size = i2o_parm_issue(dev, I2O_CMD_UTIL_PARAMS_GET, opblk,
- size, resblk, reslen);
-
- kfree(opblk);
- if (size > reslen)
- return reslen;
-
- return size;
-}
-
-EXPORT_SYMBOL(i2o_device_claim);
-EXPORT_SYMBOL(i2o_device_claim_release);
-EXPORT_SYMBOL(i2o_parm_field_get);
-EXPORT_SYMBOL(i2o_parm_table_get);
-EXPORT_SYMBOL(i2o_parm_issue);
diff --git a/drivers/staging/i2o/driver.c b/drivers/staging/i2o/driver.c
deleted file mode 100644
index 06119bb3eb5fb5..00000000000000
--- a/drivers/staging/i2o/driver.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Functions to handle I2O drivers (OSMs) and I2O bus type for sysfs
- *
- * Copyright (C) 2004 Markus Lidel <Markus.Lidel@shadowconnect.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.
- *
- * Fixes/additions:
- * Markus Lidel <Markus.Lidel@shadowconnect.com>
- * initial version.
- */
-
-#include <linux/device.h>
-#include <linux/module.h>
-#include <linux/rwsem.h>
-#include "i2o.h"
-#include <linux/workqueue.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include "core.h"
-
-#define OSM_NAME "i2o"
-
-/* max_drivers - Maximum I2O drivers (OSMs) which could be registered */
-static unsigned int i2o_max_drivers = I2O_MAX_DRIVERS;
-module_param_named(max_drivers, i2o_max_drivers, uint, 0);
-MODULE_PARM_DESC(max_drivers, "maximum number of OSM's to support");
-
-/* I2O drivers lock and array */
-static spinlock_t i2o_drivers_lock;
-static struct i2o_driver **i2o_drivers;
-
-/**
- * i2o_bus_match - Tell if I2O device class id matches the class ids of the I2O driver (OSM)
- * @dev: device which should be verified
- * @drv: the driver to match against
- *
- * Used by the bus to check if the driver wants to handle the device.
- *
- * Returns 1 if the class ids of the driver match the class id of the
- * device, otherwise 0.
- */
-static int i2o_bus_match(struct device *dev, struct device_driver *drv)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
- struct i2o_driver *i2o_drv = to_i2o_driver(drv);
- struct i2o_class_id *ids = i2o_drv->classes;
-
- if (ids)
- while (ids->class_id != I2O_CLASS_END) {
- if (ids->class_id == i2o_dev->lct_data.class_id)
- return 1;
- ids++;
- }
- return 0;
-};
-
-/* I2O bus type */
-struct bus_type i2o_bus_type = {
- .name = "i2o",
- .match = i2o_bus_match,
- .dev_groups = i2o_device_groups,
-};
-
-/**
- * i2o_driver_register - Register a I2O driver (OSM) in the I2O core
- * @drv: I2O driver which should be registered
- *
- * Registers the OSM drv in the I2O core and creates an event queues if
- * necessary.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_driver_register(struct i2o_driver *drv)
-{
- struct i2o_controller *c;
- int i;
- int rc = 0;
- unsigned long flags;
-
- osm_debug("Register driver %s\n", drv->name);
-
- if (drv->event) {
- drv->event_queue = alloc_workqueue("%s", WQ_MEM_RECLAIM, 1,
- drv->name);
- if (!drv->event_queue) {
- osm_err("Could not initialize event queue for driver "
- "%s\n", drv->name);
- return -EFAULT;
- }
- osm_debug("Event queue initialized for driver %s\n", drv->name);
- } else
- drv->event_queue = NULL;
-
- drv->driver.name = drv->name;
- drv->driver.bus = &i2o_bus_type;
-
- spin_lock_irqsave(&i2o_drivers_lock, flags);
-
- for (i = 0; i2o_drivers[i]; i++)
- if (i >= i2o_max_drivers) {
- osm_err("too many drivers registered, increase max_drivers\n");
- spin_unlock_irqrestore(&i2o_drivers_lock, flags);
- rc = -EFAULT;
- goto out;
- }
-
- drv->context = i;
- i2o_drivers[i] = drv;
-
- spin_unlock_irqrestore(&i2o_drivers_lock, flags);
-
- osm_debug("driver %s gets context id %d\n", drv->name, drv->context);
-
- list_for_each_entry(c, &i2o_controllers, list) {
- struct i2o_device *i2o_dev;
-
- i2o_driver_notify_controller_add(drv, c);
- list_for_each_entry(i2o_dev, &c->devices, list)
- i2o_driver_notify_device_add(drv, i2o_dev);
- }
-
- rc = driver_register(&drv->driver);
- if (rc)
- goto out;
-
- return 0;
-out:
- if (drv->event_queue) {
- destroy_workqueue(drv->event_queue);
- drv->event_queue = NULL;
- }
-
- return rc;
-};
-
-/**
- * i2o_driver_unregister - Unregister a I2O driver (OSM) from the I2O core
- * @drv: I2O driver which should be unregistered
- *
- * Unregisters the OSM drv from the I2O core and cleanup event queues if
- * necessary.
- */
-void i2o_driver_unregister(struct i2o_driver *drv)
-{
- struct i2o_controller *c;
- unsigned long flags;
-
- osm_debug("unregister driver %s\n", drv->name);
-
- driver_unregister(&drv->driver);
-
- list_for_each_entry(c, &i2o_controllers, list) {
- struct i2o_device *i2o_dev;
-
- list_for_each_entry(i2o_dev, &c->devices, list)
- i2o_driver_notify_device_remove(drv, i2o_dev);
-
- i2o_driver_notify_controller_remove(drv, c);
- }
-
- spin_lock_irqsave(&i2o_drivers_lock, flags);
- i2o_drivers[drv->context] = NULL;
- spin_unlock_irqrestore(&i2o_drivers_lock, flags);
-
- if (drv->event_queue) {
- destroy_workqueue(drv->event_queue);
- drv->event_queue = NULL;
- osm_debug("event queue removed for %s\n", drv->name);
- }
-};
-
-/**
- * i2o_driver_dispatch - dispatch an I2O reply message
- * @c: I2O controller of the message
- * @m: I2O message number
- *
- * The reply is delivered to the driver from which the original message
- * was. This function is only called from interrupt context.
- *
- * Returns 0 on success and the message should not be flushed. Returns > 0
- * on success and if the message should be flushed afterwords. Returns
- * negative error code on failure (the message will be flushed too).
- */
-int i2o_driver_dispatch(struct i2o_controller *c, u32 m)
-{
- struct i2o_driver *drv;
- struct i2o_message *msg = i2o_msg_out_to_virt(c, m);
- u32 context = le32_to_cpu(msg->u.s.icntxt);
- unsigned long flags;
-
- if (unlikely(context >= i2o_max_drivers)) {
- osm_warn("%s: Spurious reply to unknown driver %d\n", c->name,
- context);
- return -EIO;
- }
-
- spin_lock_irqsave(&i2o_drivers_lock, flags);
- drv = i2o_drivers[context];
- spin_unlock_irqrestore(&i2o_drivers_lock, flags);
-
- if (unlikely(!drv)) {
- osm_warn("%s: Spurious reply to unknown driver %d\n", c->name,
- context);
- return -EIO;
- }
-
- if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_UTIL_EVT_REGISTER) {
- struct i2o_device *dev, *tmp;
- struct i2o_event *evt;
- u16 size;
- u16 tid = le32_to_cpu(msg->u.head[1]) & 0xfff;
-
- osm_debug("event received from device %d\n", tid);
-
- if (!drv->event)
- return -EIO;
-
- /* cut of header from message size (in 32-bit words) */
- size = (le32_to_cpu(msg->u.head[0]) >> 16) - 5;
-
- evt = kzalloc(size * 4 + sizeof(*evt), GFP_ATOMIC);
- if (!evt)
- return -ENOMEM;
-
- evt->size = size;
- evt->tcntxt = le32_to_cpu(msg->u.s.tcntxt);
- evt->event_indicator = le32_to_cpu(msg->body[0]);
- memcpy(&evt->data, &msg->body[1], size * 4);
-
- list_for_each_entry_safe(dev, tmp, &c->devices, list)
- if (dev->lct_data.tid == tid) {
- evt->i2o_dev = dev;
- break;
- }
-
- INIT_WORK(&evt->work, drv->event);
- queue_work(drv->event_queue, &evt->work);
- return 1;
- }
-
- if (unlikely(!drv->reply)) {
- osm_debug("%s: Reply to driver %s, but no reply function defined!\n",
- c->name, drv->name);
- return -EIO;
- }
-
- return drv->reply(c, m, msg);
-}
-
-/**
- * i2o_driver_notify_controller_add_all - Send notify of added controller
- * @c: newly added controller
- *
- * Send notifications to all registered drivers that a new controller was
- * added.
- */
-void i2o_driver_notify_controller_add_all(struct i2o_controller *c)
-{
- int i;
- struct i2o_driver *drv;
-
- for (i = 0; i < i2o_max_drivers; i++) {
- drv = i2o_drivers[i];
-
- if (drv)
- i2o_driver_notify_controller_add(drv, c);
- }
-}
-
-/**
- * i2o_driver_notify_controller_remove_all - Send notify of removed controller
- * @c: controller that is being removed
- *
- * Send notifications to all registered drivers that a controller was
- * removed.
- */
-void i2o_driver_notify_controller_remove_all(struct i2o_controller *c)
-{
- int i;
- struct i2o_driver *drv;
-
- for (i = 0; i < i2o_max_drivers; i++) {
- drv = i2o_drivers[i];
-
- if (drv)
- i2o_driver_notify_controller_remove(drv, c);
- }
-}
-
-/**
- * i2o_driver_notify_device_add_all - Send notify of added device
- * @i2o_dev: newly added I2O device
- *
- * Send notifications to all registered drivers that a device was added.
- */
-void i2o_driver_notify_device_add_all(struct i2o_device *i2o_dev)
-{
- int i;
- struct i2o_driver *drv;
-
- for (i = 0; i < i2o_max_drivers; i++) {
- drv = i2o_drivers[i];
-
- if (drv)
- i2o_driver_notify_device_add(drv, i2o_dev);
- }
-}
-
-/**
- * i2o_driver_notify_device_remove_all - Send notify of removed device
- * @i2o_dev: device that is being removed
- *
- * Send notifications to all registered drivers that a device was removed.
- */
-void i2o_driver_notify_device_remove_all(struct i2o_device *i2o_dev)
-{
- int i;
- struct i2o_driver *drv;
-
- for (i = 0; i < i2o_max_drivers; i++) {
- drv = i2o_drivers[i];
-
- if (drv)
- i2o_driver_notify_device_remove(drv, i2o_dev);
- }
-}
-
-/**
- * i2o_driver_init - initialize I2O drivers (OSMs)
- *
- * Registers the I2O bus and allocate memory for the array of OSMs.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int __init i2o_driver_init(void)
-{
- int rc = 0;
-
- spin_lock_init(&i2o_drivers_lock);
-
- if ((i2o_max_drivers < 2) || (i2o_max_drivers > 64)) {
- osm_warn("max_drivers set to %d, but must be >=2 and <= 64\n",
- i2o_max_drivers);
- i2o_max_drivers = I2O_MAX_DRIVERS;
- }
- osm_info("max drivers = %d\n", i2o_max_drivers);
-
- i2o_drivers =
- kcalloc(i2o_max_drivers, sizeof(*i2o_drivers), GFP_KERNEL);
- if (!i2o_drivers)
- return -ENOMEM;
-
- rc = bus_register(&i2o_bus_type);
-
- if (rc < 0)
- kfree(i2o_drivers);
-
- return rc;
-};
-
-/**
- * i2o_driver_exit - clean up I2O drivers (OSMs)
- *
- * Unregisters the I2O bus and frees driver array.
- */
-void i2o_driver_exit(void)
-{
- bus_unregister(&i2o_bus_type);
- kfree(i2o_drivers);
-};
-
-EXPORT_SYMBOL(i2o_driver_register);
-EXPORT_SYMBOL(i2o_driver_unregister);
-EXPORT_SYMBOL(i2o_driver_notify_controller_add_all);
-EXPORT_SYMBOL(i2o_driver_notify_controller_remove_all);
-EXPORT_SYMBOL(i2o_driver_notify_device_add_all);
-EXPORT_SYMBOL(i2o_driver_notify_device_remove_all);
diff --git a/drivers/staging/i2o/exec-osm.c b/drivers/staging/i2o/exec-osm.c
deleted file mode 100644
index dce16e425a6e5f..00000000000000
--- a/drivers/staging/i2o/exec-osm.c
+++ /dev/null
@@ -1,612 +0,0 @@
-/*
- * Executive OSM
- *
- * Copyright (C) 1999-2002 Red Hat Software
- *
- * Written by Alan Cox, Building Number Three Ltd
- *
- * 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.
- *
- * A lot of the I2O message side code from this is taken from the Red
- * Creek RCPCI45 adapter driver by Red Creek Communications
- *
- * Fixes/additions:
- * Philipp Rumpf
- * Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
- * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
- * Deepak Saxena <deepak@plexity.net>
- * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
- * Alan Cox <alan@lxorguk.ukuu.org.uk>:
- * Ported to Linux 2.5.
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Minor fixes for 2.6.
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Support for sysfs included.
- */
-
-#include <linux/module.h>
-#include "i2o.h"
-#include <linux/delay.h>
-#include <linux/workqueue.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/sched.h> /* wait_event_interruptible_timeout() needs this */
-#include <asm/param.h> /* HZ */
-#include "core.h"
-
-#define OSM_NAME "exec-osm"
-
-struct i2o_driver i2o_exec_driver;
-
-/* global wait list for POST WAIT */
-static LIST_HEAD(i2o_exec_wait_list);
-
-/* Wait struct needed for POST WAIT */
-struct i2o_exec_wait {
- wait_queue_head_t *wq; /* Pointer to Wait queue */
- struct i2o_dma dma; /* DMA buffers to free on failure */
- u32 tcntxt; /* transaction context from reply */
- int complete; /* 1 if reply received otherwise 0 */
- u32 m; /* message id */
- struct i2o_message *msg; /* pointer to the reply message */
- struct list_head list; /* node in global wait list */
- spinlock_t lock; /* lock before modifying */
-};
-
-/* Work struct needed to handle LCT NOTIFY replies */
-struct i2o_exec_lct_notify_work {
- struct work_struct work; /* work struct */
- struct i2o_controller *c; /* controller on which the LCT NOTIFY
- was received */
-};
-
-/* Exec OSM class handling definition */
-static struct i2o_class_id i2o_exec_class_id[] = {
- {I2O_CLASS_EXECUTIVE},
- {I2O_CLASS_END}
-};
-
-/**
- * i2o_exec_wait_alloc - Allocate a i2o_exec_wait struct an initialize it
- *
- * Allocate the i2o_exec_wait struct and initialize the wait.
- *
- * Returns i2o_exec_wait pointer on success or negative error code on
- * failure.
- */
-static struct i2o_exec_wait *i2o_exec_wait_alloc(void)
-{
- struct i2o_exec_wait *wait;
-
- wait = kzalloc(sizeof(*wait), GFP_KERNEL);
- if (!wait)
- return NULL;
-
- INIT_LIST_HEAD(&wait->list);
- spin_lock_init(&wait->lock);
-
- return wait;
-};
-
-/**
- * i2o_exec_wait_free - Free an i2o_exec_wait struct
- * @wait: I2O wait data which should be cleaned up
- */
-static void i2o_exec_wait_free(struct i2o_exec_wait *wait)
-{
- kfree(wait);
-};
-
-/**
- * i2o_msg_post_wait_mem - Post and wait a message with DMA buffers
- * @c: controller
- * @msg: message to post
- * @timeout: time in seconds to wait
- * @dma: i2o_dma struct of the DMA buffer to free on failure
- *
- * This API allows an OSM to post a message and then be told whether or
- * not the system received a successful reply. If the message times out
- * then the value '-ETIMEDOUT' is returned. This is a special case. In
- * this situation the message may (should) complete at an indefinite time
- * in the future. When it completes it will use the memory buffer
- * attached to the request. If -ETIMEDOUT is returned then the memory
- * buffer must not be freed. Instead the event completion will free them
- * for you. In all other cases the buffer are your problem.
- *
- * Returns 0 on success, negative error code on timeout or positive error
- * code from reply.
- */
-int i2o_msg_post_wait_mem(struct i2o_controller *c, struct i2o_message *msg,
- unsigned long timeout, struct i2o_dma *dma)
-{
- DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq);
- struct i2o_exec_wait *wait;
- static u32 tcntxt = 0x80000000;
- unsigned long flags;
- int rc = 0;
-
- wait = i2o_exec_wait_alloc();
- if (!wait) {
- i2o_msg_nop(c, msg);
- return -ENOMEM;
- }
-
- if (tcntxt == 0xffffffff)
- tcntxt = 0x80000000;
-
- if (dma)
- wait->dma = *dma;
-
- /*
- * Fill in the message initiator context and transaction context.
- * We will only use transaction contexts >= 0x80000000 for POST WAIT,
- * so we could find a POST WAIT reply easier in the reply handler.
- */
- msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
- wait->tcntxt = tcntxt++;
- msg->u.s.tcntxt = cpu_to_le32(wait->tcntxt);
-
- wait->wq = &wq;
- /*
- * we add elements to the head, because if a entry in the list will
- * never be removed, we have to iterate over it every time
- */
- list_add(&wait->list, &i2o_exec_wait_list);
-
- /*
- * Post the message to the controller. At some point later it will
- * return. If we time out before it returns then complete will be zero.
- */
- i2o_msg_post(c, msg);
-
- wait_event_interruptible_timeout(wq, wait->complete, timeout * HZ);
-
- spin_lock_irqsave(&wait->lock, flags);
-
- wait->wq = NULL;
-
- if (wait->complete)
- rc = le32_to_cpu(wait->msg->body[0]) >> 24;
- else {
- /*
- * We cannot remove it now. This is important. When it does
- * terminate (which it must do if the controller has not
- * died...) then it will otherwise scribble on stuff.
- *
- * FIXME: try abort message
- */
- if (dma)
- dma->virt = NULL;
-
- rc = -ETIMEDOUT;
- }
-
- spin_unlock_irqrestore(&wait->lock, flags);
-
- if (rc != -ETIMEDOUT) {
- i2o_flush_reply(c, wait->m);
- i2o_exec_wait_free(wait);
- }
-
- return rc;
-};
-
-/**
- * i2o_msg_post_wait_complete - Reply to a i2o_msg_post request from IOP
- * @c: I2O controller which answers
- * @m: message id
- * @msg: pointer to the I2O reply message
- * @context: transaction context of request
- *
- * This function is called in interrupt context only. If the reply reached
- * before the timeout, the i2o_exec_wait struct is filled with the message
- * and the task will be waked up. The task is now responsible for returning
- * the message m back to the controller! If the message reaches us after
- * the timeout clean up the i2o_exec_wait struct (including allocated
- * DMA buffer).
- *
- * Return 0 on success and if the message m should not be given back to the
- * I2O controller, or >0 on success and if the message should be given back
- * afterwords. Returns negative error code on failure. In this case the
- * message must also be given back to the controller.
- */
-static int i2o_msg_post_wait_complete(struct i2o_controller *c, u32 m,
- struct i2o_message *msg, u32 context)
-{
- struct i2o_exec_wait *wait, *tmp;
- unsigned long flags;
- int rc = 1;
-
- /*
- * We need to search through the i2o_exec_wait_list to see if the given
- * message is still outstanding. If not, it means that the IOP took
- * longer to respond to the message than we had allowed and timer has
- * already expired. Not much we can do about that except log it for
- * debug purposes, increase timeout, and recompile.
- */
- list_for_each_entry_safe(wait, tmp, &i2o_exec_wait_list, list) {
- if (wait->tcntxt == context) {
- spin_lock_irqsave(&wait->lock, flags);
-
- list_del(&wait->list);
-
- wait->m = m;
- wait->msg = msg;
- wait->complete = 1;
-
- if (wait->wq)
- rc = 0;
- else
- rc = -1;
-
- spin_unlock_irqrestore(&wait->lock, flags);
-
- if (rc) {
- struct device *dev;
-
- dev = &c->pdev->dev;
-
- pr_debug("%s: timedout reply received!\n",
- c->name);
- i2o_dma_free(dev, &wait->dma);
- i2o_exec_wait_free(wait);
- } else
- wake_up_interruptible(wait->wq);
-
- return rc;
- }
- }
-
- osm_warn("%s: Bogus reply in POST WAIT (tr-context: %08x)!\n", c->name,
- context);
-
- return -1;
-};
-
-/**
- * i2o_exec_show_vendor_id - Displays Vendor ID of controller
- * @d: device of which the Vendor ID should be displayed
- * @attr: device_attribute to display
- * @buf: buffer into which the Vendor ID should be printed
- *
- * Returns number of bytes printed into buffer.
- */
-static ssize_t i2o_exec_show_vendor_id(struct device *d,
- struct device_attribute *attr, char *buf)
-{
- struct i2o_device *dev = to_i2o_device(d);
- u16 id;
-
- if (!i2o_parm_field_get(dev, 0x0000, 0, &id, 2)) {
- sprintf(buf, "0x%04x", le16_to_cpu(id));
- return strlen(buf) + 1;
- }
-
- return 0;
-};
-
-/**
- * i2o_exec_show_product_id - Displays Product ID of controller
- * @d: device of which the Product ID should be displayed
- * @attr: device_attribute to display
- * @buf: buffer into which the Product ID should be printed
- *
- * Returns number of bytes printed into buffer.
- */
-static ssize_t i2o_exec_show_product_id(struct device *d,
- struct device_attribute *attr,
- char *buf)
-{
- struct i2o_device *dev = to_i2o_device(d);
- u16 id;
-
- if (!i2o_parm_field_get(dev, 0x0000, 1, &id, 2)) {
- sprintf(buf, "0x%04x", le16_to_cpu(id));
- return strlen(buf) + 1;
- }
-
- return 0;
-};
-
-/* Exec-OSM device attributes */
-static DEVICE_ATTR(vendor_id, S_IRUGO, i2o_exec_show_vendor_id, NULL);
-static DEVICE_ATTR(product_id, S_IRUGO, i2o_exec_show_product_id, NULL);
-
-/**
- * i2o_exec_probe - Called if a new I2O device (executive class) appears
- * @dev: I2O device which should be probed
- *
- * Registers event notification for every event from Executive device. The
- * return is always 0, because we want all devices of class Executive.
- *
- * Returns 0 on success.
- */
-static int i2o_exec_probe(struct device *dev)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
- int rc;
-
- rc = i2o_event_register(i2o_dev, &i2o_exec_driver, 0, 0xffffffff);
- if (rc) goto err_out;
-
- rc = device_create_file(dev, &dev_attr_vendor_id);
- if (rc) goto err_evtreg;
- rc = device_create_file(dev, &dev_attr_product_id);
- if (rc) goto err_vid;
-
- i2o_dev->iop->exec = i2o_dev;
-
- return 0;
-
-err_vid:
- device_remove_file(dev, &dev_attr_vendor_id);
-err_evtreg:
- i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0);
-err_out:
- return rc;
-};
-
-/**
- * i2o_exec_remove - Called on I2O device removal
- * @dev: I2O device which was removed
- *
- * Unregisters event notification from Executive I2O device.
- *
- * Returns 0 on success.
- */
-static int i2o_exec_remove(struct device *dev)
-{
- device_remove_file(dev, &dev_attr_product_id);
- device_remove_file(dev, &dev_attr_vendor_id);
-
- i2o_event_register(to_i2o_device(dev), &i2o_exec_driver, 0, 0);
-
- return 0;
-};
-
-#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES
-/**
- * i2o_exec_lct_notify - Send a asynchronus LCT NOTIFY request
- * @c: I2O controller to which the request should be send
- * @change_ind: change indicator
- *
- * This function sends a LCT NOTIFY request to the I2O controller with
- * the change indicator change_ind. If the change_ind == 0 the controller
- * replies immediately after the request. If change_ind > 0 the reply is
- * send after change indicator of the LCT is > change_ind.
- */
-static int i2o_exec_lct_notify(struct i2o_controller *c, u32 change_ind)
-{
- i2o_status_block *sb = c->status_block.virt;
- struct device *dev;
- struct i2o_message *msg;
-
- mutex_lock(&c->lct_lock);
-
- dev = &c->pdev->dev;
-
- if (i2o_dma_realloc(dev, &c->dlct,
- le32_to_cpu(sb->expected_lct_size))) {
- mutex_unlock(&c->lct_lock);
- return -ENOMEM;
- }
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg)) {
- mutex_unlock(&c->lct_lock);
- return PTR_ERR(msg);
- }
-
- msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
- msg->u.head[1] = cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
- ADAPTER_TID);
- msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
- msg->u.s.tcntxt = cpu_to_le32(0x00000000);
- msg->body[0] = cpu_to_le32(0xffffffff);
- msg->body[1] = cpu_to_le32(change_ind);
- msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
- msg->body[3] = cpu_to_le32(c->dlct.phys);
-
- i2o_msg_post(c, msg);
-
- mutex_unlock(&c->lct_lock);
-
- return 0;
-}
-#endif
-
-/**
- * i2o_exec_lct_modified - Called on LCT NOTIFY reply
- * @_work: work struct for a specific controller
- *
- * This function handles asynchronus LCT NOTIFY replies. It parses the
- * new LCT and if the buffer for the LCT was to small sends a LCT NOTIFY
- * again, otherwise send LCT NOTIFY to get informed on next LCT change.
- */
-static void i2o_exec_lct_modified(struct work_struct *_work)
-{
- struct i2o_exec_lct_notify_work *work =
- container_of(_work, struct i2o_exec_lct_notify_work, work);
- u32 change_ind = 0;
- struct i2o_controller *c = work->c;
-
- kfree(work);
-
- if (i2o_device_parse_lct(c) != -EAGAIN)
- change_ind = c->lct->change_ind + 1;
-
-#ifdef CONFIG_I2O_LCT_NOTIFY_ON_CHANGES
- i2o_exec_lct_notify(c, change_ind);
-#endif
-};
-
-/**
- * i2o_exec_reply - I2O Executive reply handler
- * @c: I2O controller from which the reply comes
- * @m: message id
- * @msg: pointer to the I2O reply message
- *
- * This function is always called from interrupt context. If a POST WAIT
- * reply was received, pass it to the complete function. If a LCT NOTIFY
- * reply was received, a new event is created to handle the update.
- *
- * Returns 0 on success and if the reply should not be flushed or > 0
- * on success and if the reply should be flushed. Returns negative error
- * code on failure and if the reply should be flushed.
- */
-static int i2o_exec_reply(struct i2o_controller *c, u32 m,
- struct i2o_message *msg)
-{
- u32 context;
-
- if (le32_to_cpu(msg->u.head[0]) & MSG_FAIL) {
- struct i2o_message __iomem *pmsg;
- u32 pm;
-
- /*
- * If Fail bit is set we must take the transaction context of
- * the preserved message to find the right request again.
- */
-
- pm = le32_to_cpu(msg->body[3]);
- pmsg = i2o_msg_in_to_virt(c, pm);
- context = readl(&pmsg->u.s.tcntxt);
-
- i2o_report_status(KERN_INFO, "i2o_core", msg);
-
- /* Release the preserved msg */
- i2o_msg_nop_mfa(c, pm);
- } else
- context = le32_to_cpu(msg->u.s.tcntxt);
-
- if (context & 0x80000000)
- return i2o_msg_post_wait_complete(c, m, msg, context);
-
- if ((le32_to_cpu(msg->u.head[1]) >> 24) == I2O_CMD_LCT_NOTIFY) {
- struct i2o_exec_lct_notify_work *work;
-
- pr_debug("%s: LCT notify received\n", c->name);
-
- work = kmalloc(sizeof(*work), GFP_ATOMIC);
- if (!work)
- return -ENOMEM;
-
- work->c = c;
-
- INIT_WORK(&work->work, i2o_exec_lct_modified);
- queue_work(i2o_exec_driver.event_queue, &work->work);
- return 1;
- }
-
- /*
- * If this happens, we want to dump the message to the syslog so
- * it can be sent back to the card manufacturer by the end user
- * to aid in debugging.
- *
- */
- printk(KERN_WARNING "%s: Unsolicited message reply sent to core! Message dumped to syslog\n",
- c->name);
- i2o_dump_message(msg);
-
- return -EFAULT;
-}
-
-/**
- * i2o_exec_event - Event handling function
- * @work: Work item in occurring event
- *
- * Handles events send by the Executive device. At the moment does not do
- * anything useful.
- */
-static void i2o_exec_event(struct work_struct *work)
-{
- struct i2o_event *evt = container_of(work, struct i2o_event, work);
-
- if (likely(evt->i2o_dev))
- osm_debug("Event received from device: %d\n",
- evt->i2o_dev->lct_data.tid);
- kfree(evt);
-};
-
-/**
- * i2o_exec_lct_get - Get the IOP's Logical Configuration Table
- * @c: I2O controller from which the LCT should be fetched
- *
- * Send a LCT NOTIFY request to the controller, and wait
- * I2O_TIMEOUT_LCT_GET seconds until arrival of response. If the LCT is
- * to large, retry it.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_exec_lct_get(struct i2o_controller *c)
-{
- struct i2o_message *msg;
- int i = 0;
- int rc = -EAGAIN;
-
- for (i = 1; i <= I2O_LCT_GET_TRIES; i++) {
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] =
- cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_LCT_NOTIFY << 24 | HOST_TID << 12 |
- ADAPTER_TID);
- msg->body[0] = cpu_to_le32(0xffffffff);
- msg->body[1] = cpu_to_le32(0x00000000);
- msg->body[2] = cpu_to_le32(0xd0000000 | c->dlct.len);
- msg->body[3] = cpu_to_le32(c->dlct.phys);
-
- rc = i2o_msg_post_wait(c, msg, I2O_TIMEOUT_LCT_GET);
- if (rc < 0)
- break;
-
- rc = i2o_device_parse_lct(c);
- if (rc != -EAGAIN)
- break;
- }
-
- return rc;
-}
-
-/* Exec OSM driver struct */
-struct i2o_driver i2o_exec_driver = {
- .name = OSM_NAME,
- .reply = i2o_exec_reply,
- .event = i2o_exec_event,
- .classes = i2o_exec_class_id,
- .driver = {
- .probe = i2o_exec_probe,
- .remove = i2o_exec_remove,
- },
-};
-
-/**
- * i2o_exec_init - Registers the Exec OSM
- *
- * Registers the Exec OSM in the I2O core.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int __init i2o_exec_init(void)
-{
- return i2o_driver_register(&i2o_exec_driver);
-};
-
-/**
- * i2o_exec_exit - Removes the Exec OSM
- *
- * Unregisters the Exec OSM from the I2O core.
- */
-void i2o_exec_exit(void)
-{
- i2o_driver_unregister(&i2o_exec_driver);
-};
-
-EXPORT_SYMBOL(i2o_msg_post_wait_mem);
-EXPORT_SYMBOL(i2o_exec_lct_get);
diff --git a/drivers/staging/i2o/i2o.h b/drivers/staging/i2o/i2o.h
deleted file mode 100644
index d23c3c20b2014e..00000000000000
--- a/drivers/staging/i2o/i2o.h
+++ /dev/null
@@ -1,988 +0,0 @@
-/*
- * I2O kernel space accessible structures/APIs
- *
- * (c) Copyright 1999, 2000 Red Hat Software
- *
- * 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 header file defined the I2O APIs/structures for use by
- * the I2O kernel modules.
- *
- */
-
-#ifndef _I2O_H
-#define _I2O_H
-
-#include <linux/i2o-dev.h>
-
-/* How many different OSM's are we allowing */
-#define I2O_MAX_DRIVERS 8
-
-#include <linux/pci.h>
-#include <linux/bug.h>
-#include <linux/dma-mapping.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/workqueue.h> /* work_struct */
-#include <linux/mempool.h>
-#include <linux/mutex.h>
-#include <linux/scatterlist.h>
-#include <linux/semaphore.h> /* Needed for MUTEX init macros */
-
-#include <asm/io.h>
-
-/* message queue empty */
-#define I2O_QUEUE_EMPTY 0xffffffff
-
-/*
- * Cache strategies
- */
-
-/* The NULL strategy leaves everything up to the controller. This tends to be a
- * pessimal but functional choice.
- */
-#define CACHE_NULL 0
-/* Prefetch data when reading. We continually attempt to load the next 32 sectors
- * into the controller cache.
- */
-#define CACHE_PREFETCH 1
-/* Prefetch data when reading. We sometimes attempt to load the next 32 sectors
- * into the controller cache. When an I/O is less <= 8K we assume its probably
- * not sequential and don't prefetch (default)
- */
-#define CACHE_SMARTFETCH 2
-/* Data is written to the cache and then out on to the disk. The I/O must be
- * physically on the medium before the write is acknowledged (default without
- * NVRAM)
- */
-#define CACHE_WRITETHROUGH 17
-/* Data is written to the cache and then out on to the disk. The controller
- * is permitted to write back the cache any way it wants. (default if battery
- * backed NVRAM is present). It can be useful to set this for swap regardless of
- * battery state.
- */
-#define CACHE_WRITEBACK 18
-/* Optimise for under powered controllers, especially on RAID1 and RAID0. We
- * write large I/O's directly to disk bypassing the cache to avoid the extra
- * memory copy hits. Small writes are writeback cached
- */
-#define CACHE_SMARTBACK 19
-/* Optimise for under powered controllers, especially on RAID1 and RAID0. We
- * write large I/O's directly to disk bypassing the cache to avoid the extra
- * memory copy hits. Small writes are writethrough cached. Suitable for devices
- * lacking battery backup
- */
-#define CACHE_SMARTTHROUGH 20
-
-/*
- * Ioctl structures
- */
-
-#define BLKI2OGRSTRAT _IOR('2', 1, int)
-#define BLKI2OGWSTRAT _IOR('2', 2, int)
-#define BLKI2OSRSTRAT _IOW('2', 3, int)
-#define BLKI2OSWSTRAT _IOW('2', 4, int)
-
-/*
- * I2O Function codes
- */
-
-/*
- * Executive Class
- */
-#define I2O_CMD_ADAPTER_ASSIGN 0xB3
-#define I2O_CMD_ADAPTER_READ 0xB2
-#define I2O_CMD_ADAPTER_RELEASE 0xB5
-#define I2O_CMD_BIOS_INFO_SET 0xA5
-#define I2O_CMD_BOOT_DEVICE_SET 0xA7
-#define I2O_CMD_CONFIG_VALIDATE 0xBB
-#define I2O_CMD_CONN_SETUP 0xCA
-#define I2O_CMD_DDM_DESTROY 0xB1
-#define I2O_CMD_DDM_ENABLE 0xD5
-#define I2O_CMD_DDM_QUIESCE 0xC7
-#define I2O_CMD_DDM_RESET 0xD9
-#define I2O_CMD_DDM_SUSPEND 0xAF
-#define I2O_CMD_DEVICE_ASSIGN 0xB7
-#define I2O_CMD_DEVICE_RELEASE 0xB9
-#define I2O_CMD_HRT_GET 0xA8
-#define I2O_CMD_ADAPTER_CLEAR 0xBE
-#define I2O_CMD_ADAPTER_CONNECT 0xC9
-#define I2O_CMD_ADAPTER_RESET 0xBD
-#define I2O_CMD_LCT_NOTIFY 0xA2
-#define I2O_CMD_OUTBOUND_INIT 0xA1
-#define I2O_CMD_PATH_ENABLE 0xD3
-#define I2O_CMD_PATH_QUIESCE 0xC5
-#define I2O_CMD_PATH_RESET 0xD7
-#define I2O_CMD_STATIC_MF_CREATE 0xDD
-#define I2O_CMD_STATIC_MF_RELEASE 0xDF
-#define I2O_CMD_STATUS_GET 0xA0
-#define I2O_CMD_SW_DOWNLOAD 0xA9
-#define I2O_CMD_SW_UPLOAD 0xAB
-#define I2O_CMD_SW_REMOVE 0xAD
-#define I2O_CMD_SYS_ENABLE 0xD1
-#define I2O_CMD_SYS_MODIFY 0xC1
-#define I2O_CMD_SYS_QUIESCE 0xC3
-#define I2O_CMD_SYS_TAB_SET 0xA3
-
-/*
- * Utility Class
- */
-#define I2O_CMD_UTIL_NOP 0x00
-#define I2O_CMD_UTIL_ABORT 0x01
-#define I2O_CMD_UTIL_CLAIM 0x09
-#define I2O_CMD_UTIL_RELEASE 0x0B
-#define I2O_CMD_UTIL_PARAMS_GET 0x06
-#define I2O_CMD_UTIL_PARAMS_SET 0x05
-#define I2O_CMD_UTIL_EVT_REGISTER 0x13
-#define I2O_CMD_UTIL_EVT_ACK 0x14
-#define I2O_CMD_UTIL_CONFIG_DIALOG 0x10
-#define I2O_CMD_UTIL_DEVICE_RESERVE 0x0D
-#define I2O_CMD_UTIL_DEVICE_RELEASE 0x0F
-#define I2O_CMD_UTIL_LOCK 0x17
-#define I2O_CMD_UTIL_LOCK_RELEASE 0x19
-#define I2O_CMD_UTIL_REPLY_FAULT_NOTIFY 0x15
-
-/*
- * SCSI Host Bus Adapter Class
- */
-#define I2O_CMD_SCSI_EXEC 0x81
-#define I2O_CMD_SCSI_ABORT 0x83
-#define I2O_CMD_SCSI_BUSRESET 0x27
-
-/*
- * Bus Adapter Class
- */
-#define I2O_CMD_BUS_ADAPTER_RESET 0x85
-#define I2O_CMD_BUS_RESET 0x87
-#define I2O_CMD_BUS_SCAN 0x89
-#define I2O_CMD_BUS_QUIESCE 0x8b
-
-/*
- * Random Block Storage Class
- */
-#define I2O_CMD_BLOCK_READ 0x30
-#define I2O_CMD_BLOCK_WRITE 0x31
-#define I2O_CMD_BLOCK_CFLUSH 0x37
-#define I2O_CMD_BLOCK_MLOCK 0x49
-#define I2O_CMD_BLOCK_MUNLOCK 0x4B
-#define I2O_CMD_BLOCK_MMOUNT 0x41
-#define I2O_CMD_BLOCK_MEJECT 0x43
-#define I2O_CMD_BLOCK_POWER 0x70
-
-#define I2O_CMD_PRIVATE 0xFF
-
-/* Command status values */
-
-#define I2O_CMD_IN_PROGRESS 0x01
-#define I2O_CMD_REJECTED 0x02
-#define I2O_CMD_FAILED 0x03
-#define I2O_CMD_COMPLETED 0x04
-
-/* I2O API function return values */
-
-#define I2O_RTN_NO_ERROR 0
-#define I2O_RTN_NOT_INIT 1
-#define I2O_RTN_FREE_Q_EMPTY 2
-#define I2O_RTN_TCB_ERROR 3
-#define I2O_RTN_TRANSACTION_ERROR 4
-#define I2O_RTN_ADAPTER_ALREADY_INIT 5
-#define I2O_RTN_MALLOC_ERROR 6
-#define I2O_RTN_ADPTR_NOT_REGISTERED 7
-#define I2O_RTN_MSG_REPLY_TIMEOUT 8
-#define I2O_RTN_NO_STATUS 9
-#define I2O_RTN_NO_FIRM_VER 10
-#define I2O_RTN_NO_LINK_SPEED 11
-
-/* Reply message status defines for all messages */
-
-#define I2O_REPLY_STATUS_SUCCESS 0x00
-#define I2O_REPLY_STATUS_ABORT_DIRTY 0x01
-#define I2O_REPLY_STATUS_ABORT_NO_DATA_TRANSFER 0x02
-#define I2O_REPLY_STATUS_ABORT_PARTIAL_TRANSFER 0x03
-#define I2O_REPLY_STATUS_ERROR_DIRTY 0x04
-#define I2O_REPLY_STATUS_ERROR_NO_DATA_TRANSFER 0x05
-#define I2O_REPLY_STATUS_ERROR_PARTIAL_TRANSFER 0x06
-#define I2O_REPLY_STATUS_PROCESS_ABORT_DIRTY 0x08
-#define I2O_REPLY_STATUS_PROCESS_ABORT_NO_DATA_TRANSFER 0x09
-#define I2O_REPLY_STATUS_PROCESS_ABORT_PARTIAL_TRANSFER 0x0A
-#define I2O_REPLY_STATUS_TRANSACTION_ERROR 0x0B
-#define I2O_REPLY_STATUS_PROGRESS_REPORT 0x80
-
-/* Status codes and Error Information for Parameter functions */
-
-#define I2O_PARAMS_STATUS_SUCCESS 0x00
-#define I2O_PARAMS_STATUS_BAD_KEY_ABORT 0x01
-#define I2O_PARAMS_STATUS_BAD_KEY_CONTINUE 0x02
-#define I2O_PARAMS_STATUS_BUFFER_FULL 0x03
-#define I2O_PARAMS_STATUS_BUFFER_TOO_SMALL 0x04
-#define I2O_PARAMS_STATUS_FIELD_UNREADABLE 0x05
-#define I2O_PARAMS_STATUS_FIELD_UNWRITEABLE 0x06
-#define I2O_PARAMS_STATUS_INSUFFICIENT_FIELDS 0x07
-#define I2O_PARAMS_STATUS_INVALID_GROUP_ID 0x08
-#define I2O_PARAMS_STATUS_INVALID_OPERATION 0x09
-#define I2O_PARAMS_STATUS_NO_KEY_FIELD 0x0A
-#define I2O_PARAMS_STATUS_NO_SUCH_FIELD 0x0B
-#define I2O_PARAMS_STATUS_NON_DYNAMIC_GROUP 0x0C
-#define I2O_PARAMS_STATUS_OPERATION_ERROR 0x0D
-#define I2O_PARAMS_STATUS_SCALAR_ERROR 0x0E
-#define I2O_PARAMS_STATUS_TABLE_ERROR 0x0F
-#define I2O_PARAMS_STATUS_WRONG_GROUP_TYPE 0x10
-
-/* DetailedStatusCode defines for Executive, DDM, Util and Transaction error
- * messages: Table 3-2 Detailed Status Codes.*/
-
-#define I2O_DSC_SUCCESS 0x0000
-#define I2O_DSC_BAD_KEY 0x0002
-#define I2O_DSC_TCL_ERROR 0x0003
-#define I2O_DSC_REPLY_BUFFER_FULL 0x0004
-#define I2O_DSC_NO_SUCH_PAGE 0x0005
-#define I2O_DSC_INSUFFICIENT_RESOURCE_SOFT 0x0006
-#define I2O_DSC_INSUFFICIENT_RESOURCE_HARD 0x0007
-#define I2O_DSC_CHAIN_BUFFER_TOO_LARGE 0x0009
-#define I2O_DSC_UNSUPPORTED_FUNCTION 0x000A
-#define I2O_DSC_DEVICE_LOCKED 0x000B
-#define I2O_DSC_DEVICE_RESET 0x000C
-#define I2O_DSC_INAPPROPRIATE_FUNCTION 0x000D
-#define I2O_DSC_INVALID_INITIATOR_ADDRESS 0x000E
-#define I2O_DSC_INVALID_MESSAGE_FLAGS 0x000F
-#define I2O_DSC_INVALID_OFFSET 0x0010
-#define I2O_DSC_INVALID_PARAMETER 0x0011
-#define I2O_DSC_INVALID_REQUEST 0x0012
-#define I2O_DSC_INVALID_TARGET_ADDRESS 0x0013
-#define I2O_DSC_MESSAGE_TOO_LARGE 0x0014
-#define I2O_DSC_MESSAGE_TOO_SMALL 0x0015
-#define I2O_DSC_MISSING_PARAMETER 0x0016
-#define I2O_DSC_TIMEOUT 0x0017
-#define I2O_DSC_UNKNOWN_ERROR 0x0018
-#define I2O_DSC_UNKNOWN_FUNCTION 0x0019
-#define I2O_DSC_UNSUPPORTED_VERSION 0x001A
-#define I2O_DSC_DEVICE_BUSY 0x001B
-#define I2O_DSC_DEVICE_NOT_AVAILABLE 0x001C
-
-/* DetailedStatusCode defines for Block Storage Operation: Table 6-7 Detailed
- Status Codes.*/
-
-#define I2O_BSA_DSC_SUCCESS 0x0000
-#define I2O_BSA_DSC_MEDIA_ERROR 0x0001
-#define I2O_BSA_DSC_ACCESS_ERROR 0x0002
-#define I2O_BSA_DSC_DEVICE_FAILURE 0x0003
-#define I2O_BSA_DSC_DEVICE_NOT_READY 0x0004
-#define I2O_BSA_DSC_MEDIA_NOT_PRESENT 0x0005
-#define I2O_BSA_DSC_MEDIA_LOCKED 0x0006
-#define I2O_BSA_DSC_MEDIA_FAILURE 0x0007
-#define I2O_BSA_DSC_PROTOCOL_FAILURE 0x0008
-#define I2O_BSA_DSC_BUS_FAILURE 0x0009
-#define I2O_BSA_DSC_ACCESS_VIOLATION 0x000A
-#define I2O_BSA_DSC_WRITE_PROTECTED 0x000B
-#define I2O_BSA_DSC_DEVICE_RESET 0x000C
-#define I2O_BSA_DSC_VOLUME_CHANGED 0x000D
-#define I2O_BSA_DSC_TIMEOUT 0x000E
-
-/* FailureStatusCodes, Table 3-3 Message Failure Codes */
-
-#define I2O_FSC_TRANSPORT_SERVICE_SUSPENDED 0x81
-#define I2O_FSC_TRANSPORT_SERVICE_TERMINATED 0x82
-#define I2O_FSC_TRANSPORT_CONGESTION 0x83
-#define I2O_FSC_TRANSPORT_FAILURE 0x84
-#define I2O_FSC_TRANSPORT_STATE_ERROR 0x85
-#define I2O_FSC_TRANSPORT_TIME_OUT 0x86
-#define I2O_FSC_TRANSPORT_ROUTING_FAILURE 0x87
-#define I2O_FSC_TRANSPORT_INVALID_VERSION 0x88
-#define I2O_FSC_TRANSPORT_INVALID_OFFSET 0x89
-#define I2O_FSC_TRANSPORT_INVALID_MSG_FLAGS 0x8A
-#define I2O_FSC_TRANSPORT_FRAME_TOO_SMALL 0x8B
-#define I2O_FSC_TRANSPORT_FRAME_TOO_LARGE 0x8C
-#define I2O_FSC_TRANSPORT_INVALID_TARGET_ID 0x8D
-#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_ID 0x8E
-#define I2O_FSC_TRANSPORT_INVALID_INITIATOR_CONTEXT 0x8F
-#define I2O_FSC_TRANSPORT_UNKNOWN_FAILURE 0xFF
-
-/* Device Claim Types */
-#define I2O_CLAIM_PRIMARY 0x01000000
-#define I2O_CLAIM_MANAGEMENT 0x02000000
-#define I2O_CLAIM_AUTHORIZED 0x03000000
-#define I2O_CLAIM_SECONDARY 0x04000000
-
-/* Message header defines for VersionOffset */
-#define I2OVER15 0x0001
-#define I2OVER20 0x0002
-
-/* Default is 1.5 */
-#define I2OVERSION I2OVER15
-
-#define SGL_OFFSET_0 I2OVERSION
-#define SGL_OFFSET_4 (0x0040 | I2OVERSION)
-#define SGL_OFFSET_5 (0x0050 | I2OVERSION)
-#define SGL_OFFSET_6 (0x0060 | I2OVERSION)
-#define SGL_OFFSET_7 (0x0070 | I2OVERSION)
-#define SGL_OFFSET_8 (0x0080 | I2OVERSION)
-#define SGL_OFFSET_9 (0x0090 | I2OVERSION)
-#define SGL_OFFSET_10 (0x00A0 | I2OVERSION)
-#define SGL_OFFSET_11 (0x00B0 | I2OVERSION)
-#define SGL_OFFSET_12 (0x00C0 | I2OVERSION)
-#define SGL_OFFSET(x) (((x)<<4) | I2OVERSION)
-
-/* Transaction Reply Lists (TRL) Control Word structure */
-#define TRL_SINGLE_FIXED_LENGTH 0x00
-#define TRL_SINGLE_VARIABLE_LENGTH 0x40
-#define TRL_MULTIPLE_FIXED_LENGTH 0x80
-
- /* msg header defines for MsgFlags */
-#define MSG_STATIC 0x0100
-#define MSG_64BIT_CNTXT 0x0200
-#define MSG_MULTI_TRANS 0x1000
-#define MSG_FAIL 0x2000
-#define MSG_FINAL 0x4000
-#define MSG_REPLY 0x8000
-
- /* minimum size msg */
-#define THREE_WORD_MSG_SIZE 0x00030000
-#define FOUR_WORD_MSG_SIZE 0x00040000
-#define FIVE_WORD_MSG_SIZE 0x00050000
-#define SIX_WORD_MSG_SIZE 0x00060000
-#define SEVEN_WORD_MSG_SIZE 0x00070000
-#define EIGHT_WORD_MSG_SIZE 0x00080000
-#define NINE_WORD_MSG_SIZE 0x00090000
-#define TEN_WORD_MSG_SIZE 0x000A0000
-#define ELEVEN_WORD_MSG_SIZE 0x000B0000
-#define I2O_MESSAGE_SIZE(x) ((x)<<16)
-
-/* special TID assignments */
-#define ADAPTER_TID 0
-#define HOST_TID 1
-
-/* outbound queue defines */
-#define I2O_MAX_OUTBOUND_MSG_FRAMES 128
-#define I2O_OUTBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */
-
-/* inbound queue definitions */
-#define I2O_MSG_INPOOL_MIN 32
-#define I2O_INBOUND_MSG_FRAME_SIZE 128 /* in 32-bit words */
-
-#define I2O_POST_WAIT_OK 0
-#define I2O_POST_WAIT_TIMEOUT -ETIMEDOUT
-
-#define I2O_CONTEXT_LIST_MIN_LENGTH 15
-#define I2O_CONTEXT_LIST_USED 0x01
-#define I2O_CONTEXT_LIST_DELETED 0x02
-
-/* timeouts */
-#define I2O_TIMEOUT_INIT_OUTBOUND_QUEUE 15
-#define I2O_TIMEOUT_MESSAGE_GET 5
-#define I2O_TIMEOUT_RESET 30
-#define I2O_TIMEOUT_STATUS_GET 5
-#define I2O_TIMEOUT_LCT_GET 360
-#define I2O_TIMEOUT_SCSI_SCB_ABORT 240
-
-/* retries */
-#define I2O_HRT_GET_TRIES 3
-#define I2O_LCT_GET_TRIES 3
-
-/* defines for max_sectors and max_phys_segments */
-#define I2O_MAX_SECTORS 1024
-#define I2O_MAX_SECTORS_LIMITED 128
-#define I2O_MAX_PHYS_SEGMENTS BLK_MAX_SEGMENTS
-
-/*
- * Message structures
- */
-struct i2o_message {
- union {
- struct {
- u8 version_offset;
- u8 flags;
- u16 size;
- u32 target_tid:12;
- u32 init_tid:12;
- u32 function:8;
- u32 icntxt; /* initiator context */
- u32 tcntxt; /* transaction context */
- } s;
- u32 head[4];
- } u;
- /* List follows */
- u32 body[0];
-};
-
-/* MFA and I2O message used by mempool */
-struct i2o_msg_mfa {
- u32 mfa; /* MFA returned by the controller */
- struct i2o_message msg; /* I2O message */
-};
-
-/*
- * Each I2O device entity has one of these. There is one per device.
- */
-struct i2o_device {
- i2o_lct_entry lct_data; /* Device LCT information */
-
- struct i2o_controller *iop; /* Controlling IOP */
- struct list_head list; /* node in IOP devices list */
-
- struct device device;
-
- struct mutex lock; /* device lock */
-};
-
-/*
- * Event structure provided to the event handling function
- */
-struct i2o_event {
- struct work_struct work;
- struct i2o_device *i2o_dev; /* I2O device pointer from which the
- event reply was initiated */
- u16 size; /* Size of data in 32-bit words */
- u32 tcntxt; /* Transaction context used at
- registration */
- u32 event_indicator; /* Event indicator from reply */
- u32 data[0]; /* Event data from reply */
-};
-
-/*
- * I2O classes which could be handled by the OSM
- */
-struct i2o_class_id {
- u16 class_id:12;
-};
-
-/*
- * I2O driver structure for OSMs
- */
-struct i2o_driver {
- char *name; /* OSM name */
- int context; /* Low 8 bits of the transaction info */
- struct i2o_class_id *classes; /* I2O classes that this OSM handles */
-
- /* Message reply handler */
- int (*reply) (struct i2o_controller *, u32, struct i2o_message *);
-
- /* Event handler */
- work_func_t event;
-
- struct workqueue_struct *event_queue; /* Event queue */
-
- struct device_driver driver;
-
- /* notification of changes */
- void (*notify_controller_add) (struct i2o_controller *);
- void (*notify_controller_remove) (struct i2o_controller *);
- void (*notify_device_add) (struct i2o_device *);
- void (*notify_device_remove) (struct i2o_device *);
-
- struct semaphore lock;
-};
-
-/*
- * Contains DMA mapped address information
- */
-struct i2o_dma {
- void *virt;
- dma_addr_t phys;
- size_t len;
-};
-
-/*
- * Contains slab cache and mempool information
- */
-struct i2o_pool {
- char *name;
- struct kmem_cache *slab;
- mempool_t *mempool;
-};
-
-/*
- * Contains IO mapped address information
- */
-struct i2o_io {
- void __iomem *virt;
- unsigned long phys;
- unsigned long len;
-};
-
-/*
- * Context queue entry, used for 32-bit context on 64-bit systems
- */
-struct i2o_context_list_element {
- struct list_head list;
- u32 context;
- void *ptr;
- unsigned long timestamp;
-};
-
-/*
- * Each I2O controller has one of these objects
- */
-struct i2o_controller {
- char name[16];
- int unit;
- int type;
-
- struct pci_dev *pdev; /* PCI device */
-
- unsigned int promise:1; /* Promise controller */
- unsigned int adaptec:1; /* DPT / Adaptec controller */
- unsigned int raptor:1; /* split bar */
- unsigned int no_quiesce:1; /* dont quiesce before reset */
- unsigned int short_req:1; /* use small block sizes */
- unsigned int limit_sectors:1; /* limit number of sectors / request */
- unsigned int pae_support:1; /* controller has 64-bit SGL support */
-
- struct list_head devices; /* list of I2O devices */
- struct list_head list; /* Controller list */
-
- void __iomem *in_port; /* Inbout port address */
- void __iomem *out_port; /* Outbound port address */
- void __iomem *irq_status; /* Interrupt status register address */
- void __iomem *irq_mask; /* Interrupt mask register address */
-
- struct i2o_dma status; /* IOP status block */
-
- struct i2o_dma hrt; /* HW Resource Table */
- i2o_lct *lct; /* Logical Config Table */
- struct i2o_dma dlct; /* Temp LCT */
- struct mutex lct_lock; /* Lock for LCT updates */
- struct i2o_dma status_block; /* IOP status block */
-
- struct i2o_io base; /* controller messaging unit */
- struct i2o_io in_queue; /* inbound message queue Host->IOP */
- struct i2o_dma out_queue; /* outbound message queue IOP->Host */
-
- struct i2o_pool in_msg; /* mempool for inbound messages */
-
- unsigned int battery:1; /* Has a battery backup */
- unsigned int io_alloc:1; /* An I/O resource was allocated */
- unsigned int mem_alloc:1; /* A memory resource was allocated */
-
- struct resource io_resource; /* I/O resource allocated to the IOP */
- struct resource mem_resource; /* Mem resource allocated to the IOP */
-
- struct device device;
- struct i2o_device *exec; /* Executive */
-#if BITS_PER_LONG == 64
- spinlock_t context_list_lock; /* lock for context_list */
- atomic_t context_list_counter; /* needed for unique contexts */
- struct list_head context_list; /* list of context id's
- and pointers */
-#endif
- spinlock_t lock; /* lock for controller
- configuration */
- void *driver_data[I2O_MAX_DRIVERS]; /* storage for drivers */
-};
-
-/*
- * I2O System table entry
- *
- * The system table contains information about all the IOPs in the
- * system. It is sent to all IOPs so that they can create peer2peer
- * connections between them.
- */
-struct i2o_sys_tbl_entry {
- u16 org_id;
- u16 reserved1;
- u32 iop_id:12;
- u32 reserved2:20;
- u16 seg_num:12;
- u16 i2o_version:4;
- u8 iop_state;
- u8 msg_type;
- u16 frame_size;
- u16 reserved3;
- u32 last_changed;
- u32 iop_capabilities;
- u32 inbound_low;
- u32 inbound_high;
-};
-
-struct i2o_sys_tbl {
- u8 num_entries;
- u8 version;
- u16 reserved1;
- u32 change_ind;
- u32 reserved2;
- u32 reserved3;
- struct i2o_sys_tbl_entry iops[0];
-};
-
-extern struct list_head i2o_controllers;
-
-/* Message functions */
-extern struct i2o_message *i2o_msg_get_wait(struct i2o_controller *, int);
-extern int i2o_msg_post_wait_mem(struct i2o_controller *, struct i2o_message *,
- unsigned long, struct i2o_dma *);
-
-/* IOP functions */
-extern int i2o_status_get(struct i2o_controller *);
-
-extern int i2o_event_register(struct i2o_device *, struct i2o_driver *, int,
- u32);
-extern struct i2o_device *i2o_iop_find_device(struct i2o_controller *, u16);
-extern struct i2o_controller *i2o_find_iop(int);
-
-/* Functions needed for handling 64-bit pointers in 32-bit context */
-#if BITS_PER_LONG == 64
-extern u32 i2o_cntxt_list_add(struct i2o_controller *, void *);
-extern void *i2o_cntxt_list_get(struct i2o_controller *, u32);
-extern u32 i2o_cntxt_list_remove(struct i2o_controller *, void *);
-extern u32 i2o_cntxt_list_get_ptr(struct i2o_controller *, void *);
-
-static inline u32 i2o_ptr_low(void *ptr)
-{
- return (u32) (u64) ptr;
-};
-
-static inline u32 i2o_ptr_high(void *ptr)
-{
- return (u32) ((u64) ptr >> 32);
-};
-
-static inline u32 i2o_dma_low(dma_addr_t dma_addr)
-{
- return (u32) (u64) dma_addr;
-};
-
-static inline u32 i2o_dma_high(dma_addr_t dma_addr)
-{
- return (u32) ((u64) dma_addr >> 32);
-};
-#else
-static inline u32 i2o_cntxt_list_add(struct i2o_controller *c, void *ptr)
-{
- return (u32) ptr;
-};
-
-static inline void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context)
-{
- return (void *)context;
-};
-
-static inline u32 i2o_cntxt_list_remove(struct i2o_controller *c, void *ptr)
-{
- return (u32) ptr;
-};
-
-static inline u32 i2o_cntxt_list_get_ptr(struct i2o_controller *c, void *ptr)
-{
- return (u32) ptr;
-};
-
-static inline u32 i2o_ptr_low(void *ptr)
-{
- return (u32) ptr;
-};
-
-static inline u32 i2o_ptr_high(void *ptr)
-{
- return 0;
-};
-
-static inline u32 i2o_dma_low(dma_addr_t dma_addr)
-{
- return (u32) dma_addr;
-};
-
-static inline u32 i2o_dma_high(dma_addr_t dma_addr)
-{
- return 0;
-};
-#endif
-
-extern u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size);
-extern dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
- size_t size,
- enum dma_data_direction direction,
- u32 ** sg_ptr);
-extern int i2o_dma_map_sg(struct i2o_controller *c,
- struct scatterlist *sg, int sg_count,
- enum dma_data_direction direction,
- u32 ** sg_ptr);
-extern int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len);
-extern void i2o_dma_free(struct device *dev, struct i2o_dma *addr);
-extern int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr,
- size_t len);
-extern int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
- size_t size, int min_nr);
-extern void i2o_pool_free(struct i2o_pool *pool);
-/* I2O driver (OSM) functions */
-extern int i2o_driver_register(struct i2o_driver *);
-extern void i2o_driver_unregister(struct i2o_driver *);
-
-/**
- * i2o_driver_notify_controller_add - Send notification of added controller
- * @drv: I2O driver
- * @c: I2O controller
- *
- * Send notification of added controller to a single registered driver.
- */
-static inline void i2o_driver_notify_controller_add(struct i2o_driver *drv,
- struct i2o_controller *c)
-{
- if (drv->notify_controller_add)
- drv->notify_controller_add(c);
-};
-
-/**
- * i2o_driver_notify_controller_remove - Send notification of removed controller
- * @drv: I2O driver
- * @c: I2O controller
- *
- * Send notification of removed controller to a single registered driver.
- */
-static inline void i2o_driver_notify_controller_remove(struct i2o_driver *drv,
- struct i2o_controller *c)
-{
- if (drv->notify_controller_remove)
- drv->notify_controller_remove(c);
-};
-
-/**
- * i2o_driver_notify_device_add - Send notification of added device
- * @drv: I2O driver
- * @i2o_dev: the added i2o_device
- *
- * Send notification of added device to a single registered driver.
- */
-static inline void i2o_driver_notify_device_add(struct i2o_driver *drv,
- struct i2o_device *i2o_dev)
-{
- if (drv->notify_device_add)
- drv->notify_device_add(i2o_dev);
-};
-
-/**
- * i2o_driver_notify_device_remove - Send notification of removed device
- * @drv: I2O driver
- * @i2o_dev: the added i2o_device
- *
- * Send notification of removed device to a single registered driver.
- */
-static inline void i2o_driver_notify_device_remove(struct i2o_driver *drv,
- struct i2o_device *i2o_dev)
-{
- if (drv->notify_device_remove)
- drv->notify_device_remove(i2o_dev);
-};
-
-extern void i2o_driver_notify_controller_add_all(struct i2o_controller *);
-extern void i2o_driver_notify_controller_remove_all(struct i2o_controller *);
-extern void i2o_driver_notify_device_add_all(struct i2o_device *);
-extern void i2o_driver_notify_device_remove_all(struct i2o_device *);
-
-/* I2O device functions */
-extern int i2o_device_claim(struct i2o_device *);
-extern int i2o_device_claim_release(struct i2o_device *);
-
-/* Exec OSM functions */
-extern int i2o_exec_lct_get(struct i2o_controller *);
-
-/* device / driver / kobject conversion functions */
-#define to_i2o_driver(drv) container_of(drv,struct i2o_driver, driver)
-#define to_i2o_device(dev) container_of(dev, struct i2o_device, device)
-#define to_i2o_controller(dev) container_of(dev, struct i2o_controller, device)
-
-/**
- * i2o_out_to_virt - Turn an I2O message to a virtual address
- * @c: controller
- * @m: message engine value
- *
- * Turn a receive message from an I2O controller bus address into
- * a Linux virtual address. The shared page frame is a linear block
- * so we simply have to shift the offset. This function does not
- * work for sender side messages as they are ioremap objects
- * provided by the I2O controller.
- */
-static inline struct i2o_message *i2o_msg_out_to_virt(struct i2o_controller *c,
- u32 m)
-{
- BUG_ON(m < c->out_queue.phys
- || m >= c->out_queue.phys + c->out_queue.len);
-
- return c->out_queue.virt + (m - c->out_queue.phys);
-};
-
-/**
- * i2o_msg_in_to_virt - Turn an I2O message to a virtual address
- * @c: controller
- * @m: message engine value
- *
- * Turn a send message from an I2O controller bus address into
- * a Linux virtual address. The shared page frame is a linear block
- * so we simply have to shift the offset. This function does not
- * work for receive side messages as they are kmalloc objects
- * in a different pool.
- */
-static inline struct i2o_message __iomem *i2o_msg_in_to_virt(struct
- i2o_controller *c,
- u32 m)
-{
- return c->in_queue.virt + m;
-};
-
-/**
- * i2o_msg_get - obtain an I2O message from the IOP
- * @c: I2O controller
- *
- * This function tries to get a message frame. If no message frame is
- * available do not wait until one is available (see also i2o_msg_get_wait).
- * The returned pointer to the message frame is not in I/O memory, it is
- * allocated from a mempool. But because a MFA is allocated from the
- * controller too it is guaranteed that i2o_msg_post() will never fail.
- *
- * On a success a pointer to the message frame is returned. If the message
- * queue is empty -EBUSY is returned and if no memory is available -ENOMEM
- * is returned.
- */
-static inline struct i2o_message *i2o_msg_get(struct i2o_controller *c)
-{
- struct i2o_msg_mfa *mmsg = mempool_alloc(c->in_msg.mempool, GFP_ATOMIC);
- if (!mmsg)
- return ERR_PTR(-ENOMEM);
-
- mmsg->mfa = readl(c->in_port);
- if (unlikely(mmsg->mfa >= c->in_queue.len)) {
- u32 mfa = mmsg->mfa;
-
- mempool_free(mmsg, c->in_msg.mempool);
-
- if (mfa == I2O_QUEUE_EMPTY)
- return ERR_PTR(-EBUSY);
- return ERR_PTR(-EFAULT);
- }
-
- return &mmsg->msg;
-};
-
-/**
- * i2o_msg_post - Post I2O message to I2O controller
- * @c: I2O controller to which the message should be send
- * @msg: message returned by i2o_msg_get()
- *
- * Post the message to the I2O controller and return immediately.
- */
-static inline void i2o_msg_post(struct i2o_controller *c,
- struct i2o_message *msg)
-{
- struct i2o_msg_mfa *mmsg;
-
- mmsg = container_of(msg, struct i2o_msg_mfa, msg);
- memcpy_toio(i2o_msg_in_to_virt(c, mmsg->mfa), msg,
- (le32_to_cpu(msg->u.head[0]) >> 16) << 2);
- writel(mmsg->mfa, c->in_port);
- mempool_free(mmsg, c->in_msg.mempool);
-};
-
-/**
- * i2o_msg_post_wait - Post and wait a message and wait until return
- * @c: controller
- * @msg: message to post
- * @timeout: time in seconds to wait
- *
- * This API allows an OSM to post a message and then be told whether or
- * not the system received a successful reply. If the message times out
- * then the value '-ETIMEDOUT' is returned.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static inline int i2o_msg_post_wait(struct i2o_controller *c,
- struct i2o_message *msg,
- unsigned long timeout)
-{
- return i2o_msg_post_wait_mem(c, msg, timeout, NULL);
-};
-
-/**
- * i2o_msg_nop_mfa - Returns a fetched MFA back to the controller
- * @c: I2O controller from which the MFA was fetched
- * @mfa: MFA which should be returned
- *
- * This function must be used for preserved messages, because i2o_msg_nop()
- * also returns the allocated memory back to the msg_pool mempool.
- */
-static inline void i2o_msg_nop_mfa(struct i2o_controller *c, u32 mfa)
-{
- struct i2o_message __iomem *msg;
- u32 nop[3] = {
- THREE_WORD_MSG_SIZE | SGL_OFFSET_0,
- I2O_CMD_UTIL_NOP << 24 | HOST_TID << 12 | ADAPTER_TID,
- 0x00000000
- };
-
- msg = i2o_msg_in_to_virt(c, mfa);
- memcpy_toio(msg, nop, sizeof(nop));
- writel(mfa, c->in_port);
-};
-
-/**
- * i2o_msg_nop - Returns a message which is not used
- * @c: I2O controller from which the message was created
- * @msg: message which should be returned
- *
- * If you fetch a message via i2o_msg_get, and can't use it, you must
- * return the message with this function. Otherwise the MFA is lost as well
- * as the allocated memory from the mempool.
- */
-static inline void i2o_msg_nop(struct i2o_controller *c,
- struct i2o_message *msg)
-{
- struct i2o_msg_mfa *mmsg;
- mmsg = container_of(msg, struct i2o_msg_mfa, msg);
-
- i2o_msg_nop_mfa(c, mmsg->mfa);
- mempool_free(mmsg, c->in_msg.mempool);
-};
-
-/**
- * i2o_flush_reply - Flush reply from I2O controller
- * @c: I2O controller
- * @m: the message identifier
- *
- * The I2O controller must be informed that the reply message is not needed
- * anymore. If you forget to flush the reply, the message frame can't be
- * used by the controller anymore and is therefore lost.
- */
-static inline void i2o_flush_reply(struct i2o_controller *c, u32 m)
-{
- writel(m, c->out_port);
-};
-
-/*
- * Endian handling wrapped into the macro - keeps the core code
- * cleaner.
- */
-
-#define i2o_raw_writel(val, mem) __raw_writel(cpu_to_le32(val), mem)
-
-extern int i2o_parm_field_get(struct i2o_device *, int, int, void *, int);
-extern int i2o_parm_table_get(struct i2o_device *, int, int, int, void *, int,
- void *, int);
-
-/* debugging and troubleshooting/diagnostic helpers. */
-#define osm_printk(level, format, arg...) \
- printk(level "%s: " format, OSM_NAME , ## arg)
-
-#ifdef DEBUG
-#define osm_debug(format, arg...) \
- osm_printk(KERN_DEBUG, format , ## arg)
-#else
-#define osm_debug(format, arg...) \
- do { } while (0)
-#endif
-
-#define osm_err(format, arg...) \
- osm_printk(KERN_ERR, format , ## arg)
-#define osm_info(format, arg...) \
- osm_printk(KERN_INFO, format , ## arg)
-#define osm_warn(format, arg...) \
- osm_printk(KERN_WARNING, format , ## arg)
-
-/* debugging functions */
-extern void i2o_report_status(const char *, const char *, struct i2o_message *);
-extern void i2o_dump_message(struct i2o_message *);
-extern void i2o_dump_hrt(struct i2o_controller *c);
-extern void i2o_debug_state(struct i2o_controller *c);
-
-#endif /* _I2O_H */
diff --git a/drivers/staging/i2o/i2o_block.c b/drivers/staging/i2o/i2o_block.c
deleted file mode 100644
index 406758f755ee43..00000000000000
--- a/drivers/staging/i2o/i2o_block.c
+++ /dev/null
@@ -1,1228 +0,0 @@
-/*
- * Block OSM
- *
- * Copyright (C) 1999-2002 Red Hat Software
- *
- * Written by Alan Cox, Building Number Three Ltd
- *
- * 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.
- *
- * For the purpose of avoiding doubt the preferred form of the work
- * for making modifications shall be a standards compliant form such
- * gzipped tar and not one requiring a proprietary or patent encumbered
- * tool to unpack.
- *
- * Fixes/additions:
- * Steve Ralston:
- * Multiple device handling error fixes,
- * Added a queue depth.
- * Alan Cox:
- * FC920 has an rmw bug. Dont or in the end marker.
- * Removed queue walk, fixed for 64bitness.
- * Rewrote much of the code over time
- * Added indirect block lists
- * Handle 64K limits on many controllers
- * Don't use indirects on the Promise (breaks)
- * Heavily chop down the queue depths
- * Deepak Saxena:
- * Independent queues per IOP
- * Support for dynamic device creation/deletion
- * Code cleanup
- * Support for larger I/Os through merge* functions
- * (taken from DAC960 driver)
- * Boji T Kannanthanam:
- * Set the I2O Block devices to be detected in increasing
- * order of TIDs during boot.
- * Search and set the I2O block device that we boot off
- * from as the first device to be claimed (as /dev/i2o/hda)
- * Properly attach/detach I2O gendisk structure from the
- * system gendisk list. The I2O block devices now appear in
- * /proc/partitions.
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Minor bugfixes for 2.6.
- */
-
-#include <linux/module.h>
-#include <linux/slab.h>
-#include "i2o.h"
-#include <linux/mutex.h>
-
-#include <linux/mempool.h>
-
-#include <linux/genhd.h>
-#include <linux/blkdev.h>
-#include <linux/hdreg.h>
-
-#include <scsi/scsi.h>
-
-#include "i2o_block.h"
-
-#define OSM_NAME "block-osm"
-#define OSM_VERSION "1.325"
-#define OSM_DESCRIPTION "I2O Block Device OSM"
-
-static DEFINE_MUTEX(i2o_block_mutex);
-static struct i2o_driver i2o_block_driver;
-
-/* global Block OSM request mempool */
-static struct i2o_block_mempool i2o_blk_req_pool;
-
-/* Block OSM class handling definition */
-static struct i2o_class_id i2o_block_class_id[] = {
- {I2O_CLASS_RANDOM_BLOCK_STORAGE},
- {I2O_CLASS_END}
-};
-
-/**
- * i2o_block_device_free - free the memory of the I2O Block device
- * @dev: I2O Block device, which should be cleaned up
- *
- * Frees the request queue, gendisk and the i2o_block_device structure.
- */
-static void i2o_block_device_free(struct i2o_block_device *dev)
-{
- blk_cleanup_queue(dev->gd->queue);
-
- put_disk(dev->gd);
-
- kfree(dev);
-};
-
-/**
- * i2o_block_remove - remove the I2O Block device from the system again
- * @dev: I2O Block device which should be removed
- *
- * Remove gendisk from system and free all allocated memory.
- *
- * Always returns 0.
- */
-static int i2o_block_remove(struct device *dev)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
- struct i2o_block_device *i2o_blk_dev = dev_get_drvdata(dev);
-
- osm_info("device removed (TID: %03x): %s\n", i2o_dev->lct_data.tid,
- i2o_blk_dev->gd->disk_name);
-
- i2o_event_register(i2o_dev, &i2o_block_driver, 0, 0);
-
- del_gendisk(i2o_blk_dev->gd);
-
- dev_set_drvdata(dev, NULL);
-
- i2o_device_claim_release(i2o_dev);
-
- i2o_block_device_free(i2o_blk_dev);
-
- return 0;
-};
-
-/**
- * i2o_block_device flush - Flush all dirty data of I2O device dev
- * @dev: I2O device which should be flushed
- *
- * Flushes all dirty data on device dev.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_block_device_flush(struct i2o_device *dev)
-{
- struct i2o_message *msg;
-
- msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_BLOCK_CFLUSH << 24 | HOST_TID << 12 | dev->
- lct_data.tid);
- msg->body[0] = cpu_to_le32(60 << 16);
- osm_debug("Flushing...\n");
-
- return i2o_msg_post_wait(dev->iop, msg, 60);
-};
-
-/**
- * i2o_block_device_mount - Mount (load) the media of device dev
- * @dev: I2O device which should receive the mount request
- * @media_id: Media Identifier
- *
- * Load a media into drive. Identifier should be set to -1, because the
- * spec does not support any other value.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_block_device_mount(struct i2o_device *dev, u32 media_id)
-{
- struct i2o_message *msg;
-
- msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_BLOCK_MMOUNT << 24 | HOST_TID << 12 | dev->
- lct_data.tid);
- msg->body[0] = cpu_to_le32(-1);
- msg->body[1] = cpu_to_le32(0x00000000);
- osm_debug("Mounting...\n");
-
- return i2o_msg_post_wait(dev->iop, msg, 2);
-};
-
-/**
- * i2o_block_device_lock - Locks the media of device dev
- * @dev: I2O device which should receive the lock request
- * @media_id: Media Identifier
- *
- * Lock media of device dev to prevent removal. The media identifier
- * should be set to -1, because the spec does not support any other value.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_block_device_lock(struct i2o_device *dev, u32 media_id)
-{
- struct i2o_message *msg;
-
- msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_BLOCK_MLOCK << 24 | HOST_TID << 12 | dev->
- lct_data.tid);
- msg->body[0] = cpu_to_le32(-1);
- osm_debug("Locking...\n");
-
- return i2o_msg_post_wait(dev->iop, msg, 2);
-};
-
-/**
- * i2o_block_device_unlock - Unlocks the media of device dev
- * @dev: I2O device which should receive the unlocked request
- * @media_id: Media Identifier
- *
- * Unlocks the media in device dev. The media identifier should be set to
- * -1, because the spec does not support any other value.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_block_device_unlock(struct i2o_device *dev, u32 media_id)
-{
- struct i2o_message *msg;
-
- msg = i2o_msg_get_wait(dev->iop, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_BLOCK_MUNLOCK << 24 | HOST_TID << 12 | dev->
- lct_data.tid);
- msg->body[0] = cpu_to_le32(media_id);
- osm_debug("Unlocking...\n");
-
- return i2o_msg_post_wait(dev->iop, msg, 2);
-};
-
-/**
- * i2o_block_device_power - Power management for device dev
- * @dev: I2O device which should receive the power management request
- * @op: Operation to send
- *
- * Send a power management request to the device dev.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_block_device_power(struct i2o_block_device *dev, u8 op)
-{
- struct i2o_device *i2o_dev = dev->i2o_dev;
- struct i2o_controller *c = i2o_dev->iop;
- struct i2o_message *msg;
- int rc;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_BLOCK_POWER << 24 | HOST_TID << 12 | i2o_dev->
- lct_data.tid);
- msg->body[0] = cpu_to_le32(op << 24);
- osm_debug("Power...\n");
-
- rc = i2o_msg_post_wait(c, msg, 60);
- if (!rc)
- dev->power = op;
-
- return rc;
-};
-
-/**
- * i2o_block_request_alloc - Allocate an I2O block request struct
- *
- * Allocates an I2O block request struct and initialize the list.
- *
- * Returns a i2o_block_request pointer on success or negative error code
- * on failure.
- */
-static inline struct i2o_block_request *i2o_block_request_alloc(void)
-{
- struct i2o_block_request *ireq;
-
- ireq = mempool_alloc(i2o_blk_req_pool.pool, GFP_ATOMIC);
- if (!ireq)
- return ERR_PTR(-ENOMEM);
-
- INIT_LIST_HEAD(&ireq->queue);
- sg_init_table(ireq->sg_table, I2O_MAX_PHYS_SEGMENTS);
-
- return ireq;
-};
-
-/**
- * i2o_block_request_free - Frees a I2O block request
- * @ireq: I2O block request which should be freed
- *
- * Frees the allocated memory (give it back to the request mempool).
- */
-static inline void i2o_block_request_free(struct i2o_block_request *ireq)
-{
- mempool_free(ireq, i2o_blk_req_pool.pool);
-};
-
-/**
- * i2o_block_sglist_alloc - Allocate the SG list and map it
- * @c: I2O controller to which the request belongs
- * @ireq: I2O block request
- * @mptr: message body pointer
- *
- * Builds the SG list and map it to be accessible by the controller.
- *
- * Returns 0 on failure or 1 on success.
- */
-static inline int i2o_block_sglist_alloc(struct i2o_controller *c,
- struct i2o_block_request *ireq,
- u32 ** mptr)
-{
- int nents;
- enum dma_data_direction direction;
-
- ireq->dev = &c->pdev->dev;
- nents = blk_rq_map_sg(ireq->req->q, ireq->req, ireq->sg_table);
-
- if (rq_data_dir(ireq->req) == READ)
- direction = PCI_DMA_FROMDEVICE;
- else
- direction = PCI_DMA_TODEVICE;
-
- ireq->sg_nents = nents;
-
- return i2o_dma_map_sg(c, ireq->sg_table, nents, direction, mptr);
-};
-
-/**
- * i2o_block_sglist_free - Frees the SG list
- * @ireq: I2O block request from which the SG should be freed
- *
- * Frees the SG list from the I2O block request.
- */
-static inline void i2o_block_sglist_free(struct i2o_block_request *ireq)
-{
- enum dma_data_direction direction;
-
- if (rq_data_dir(ireq->req) == READ)
- direction = PCI_DMA_FROMDEVICE;
- else
- direction = PCI_DMA_TODEVICE;
-
- dma_unmap_sg(ireq->dev, ireq->sg_table, ireq->sg_nents, direction);
-};
-
-/**
- * i2o_block_prep_req_fn - Allocates I2O block device specific struct
- * @q: request queue for the request
- * @req: the request to prepare
- *
- * Allocate the necessary i2o_block_request struct and connect it to
- * the request. This is needed that we not lose the SG list later on.
- *
- * Returns BLKPREP_OK on success or BLKPREP_DEFER on failure.
- */
-static int i2o_block_prep_req_fn(struct request_queue *q, struct request *req)
-{
- struct i2o_block_device *i2o_blk_dev = q->queuedata;
- struct i2o_block_request *ireq;
-
- if (unlikely(!i2o_blk_dev)) {
- osm_err("block device already removed\n");
- return BLKPREP_KILL;
- }
-
- /* connect the i2o_block_request to the request */
- if (!req->special) {
- ireq = i2o_block_request_alloc();
- if (IS_ERR(ireq)) {
- osm_debug("unable to allocate i2o_block_request!\n");
- return BLKPREP_DEFER;
- }
-
- ireq->i2o_blk_dev = i2o_blk_dev;
- req->special = ireq;
- ireq->req = req;
- }
- /* do not come back here */
- req->cmd_flags |= REQ_DONTPREP;
-
- return BLKPREP_OK;
-};
-
-/**
- * i2o_block_delayed_request_fn - delayed request queue function
- * @work: the delayed request with the queue to start
- *
- * If the request queue is stopped for a disk, and there is no open
- * request, a new event is created, which calls this function to start
- * the queue after I2O_BLOCK_REQUEST_TIME. Otherwise the queue will never
- * be started again.
- */
-static void i2o_block_delayed_request_fn(struct work_struct *work)
-{
- struct i2o_block_delayed_request *dreq =
- container_of(work, struct i2o_block_delayed_request,
- work.work);
- struct request_queue *q = dreq->queue;
- unsigned long flags;
-
- spin_lock_irqsave(q->queue_lock, flags);
- blk_start_queue(q);
- spin_unlock_irqrestore(q->queue_lock, flags);
- kfree(dreq);
-};
-
-/**
- * i2o_block_end_request - Post-processing of completed commands
- * @req: request which should be completed
- * @error: 0 for success, < 0 for error
- * @nr_bytes: number of bytes to complete
- *
- * Mark the request as complete. The lock must not be held when entering.
- *
- */
-static void i2o_block_end_request(struct request *req, int error,
- int nr_bytes)
-{
- struct i2o_block_request *ireq = req->special;
- struct i2o_block_device *dev = ireq->i2o_blk_dev;
- struct request_queue *q = req->q;
- unsigned long flags;
-
- if (blk_end_request(req, error, nr_bytes))
- if (error)
- blk_end_request_all(req, -EIO);
-
- spin_lock_irqsave(q->queue_lock, flags);
-
- if (likely(dev)) {
- dev->open_queue_depth--;
- list_del(&ireq->queue);
- }
-
- blk_start_queue(q);
-
- spin_unlock_irqrestore(q->queue_lock, flags);
-
- i2o_block_sglist_free(ireq);
- i2o_block_request_free(ireq);
-};
-
-/**
- * i2o_block_reply - Block OSM reply handler.
- * @c: I2O controller from which the message arrives
- * @m: message id of reply
- * @msg: the actual I2O message reply
- *
- * This function gets all the message replies.
- *
- */
-static int i2o_block_reply(struct i2o_controller *c, u32 m,
- struct i2o_message *msg)
-{
- struct request *req;
- int error = 0;
-
- req = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));
- if (unlikely(!req)) {
- osm_err("NULL reply received!\n");
- return -1;
- }
-
- /*
- * Lets see what is cooking. We stuffed the
- * request in the context.
- */
-
- if ((le32_to_cpu(msg->body[0]) >> 24) != 0) {
- u32 status = le32_to_cpu(msg->body[0]);
- /*
- * Device not ready means two things. One is that the
- * the thing went offline (but not a removal media)
- *
- * The second is that you have a SuperTrak 100 and the
- * firmware got constipated. Unlike standard i2o card
- * setups the supertrak returns an error rather than
- * blocking for the timeout in these cases.
- *
- * Don't stick a supertrak100 into cache aggressive modes
- */
-
- osm_err("TID %03x error status: 0x%02x, detailed status: "
- "0x%04x\n", (le32_to_cpu(msg->u.head[1]) >> 12 & 0xfff),
- status >> 24, status & 0xffff);
-
- req->errors++;
-
- error = -EIO;
- }
-
- i2o_block_end_request(req, error, le32_to_cpu(msg->body[1]));
-
- return 1;
-};
-
-static void i2o_block_event(struct work_struct *work)
-{
- struct i2o_event *evt = container_of(work, struct i2o_event, work);
- osm_debug("event received\n");
- kfree(evt);
-};
-
-/*
- * SCSI-CAM for ioctl geometry mapping
- * Duplicated with SCSI - this should be moved into somewhere common
- * perhaps genhd ?
- *
- * LBA -> CHS mapping table taken from:
- *
- * "Incorporating the I2O Architecture into BIOS for Intel Architecture
- * Platforms"
- *
- * This is an I2O document that is only available to I2O members,
- * not developers.
- *
- * From my understanding, this is how all the I2O cards do this
- *
- * Disk Size | Sectors | Heads | Cylinders
- * ---------------+---------+-------+-------------------
- * 1 < X <= 528M | 63 | 16 | X/(63 * 16 * 512)
- * 528M < X <= 1G | 63 | 32 | X/(63 * 32 * 512)
- * 1 < X <528M | 63 | 16 | X/(63 * 16 * 512)
- * 1 < X <528M | 63 | 16 | X/(63 * 16 * 512)
- *
- */
-#define BLOCK_SIZE_528M 1081344
-#define BLOCK_SIZE_1G 2097152
-#define BLOCK_SIZE_21G 4403200
-#define BLOCK_SIZE_42G 8806400
-#define BLOCK_SIZE_84G 17612800
-
-static void i2o_block_biosparam(unsigned long capacity, unsigned short *cyls,
- unsigned char *hds, unsigned char *secs)
-{
- unsigned long heads, sectors, cylinders;
-
- sectors = 63L; /* Maximize sectors per track */
- if (capacity <= BLOCK_SIZE_528M)
- heads = 16;
- else if (capacity <= BLOCK_SIZE_1G)
- heads = 32;
- else if (capacity <= BLOCK_SIZE_21G)
- heads = 64;
- else if (capacity <= BLOCK_SIZE_42G)
- heads = 128;
- else
- heads = 255;
-
- cylinders = (unsigned long)capacity / (heads * sectors);
-
- *cyls = (unsigned short)cylinders; /* Stuff return values */
- *secs = (unsigned char)sectors;
- *hds = (unsigned char)heads;
-}
-
-/**
- * i2o_block_open - Open the block device
- * @bdev: block device being opened
- * @mode: file open mode
- *
- * Power up the device, mount and lock the media. This function is called,
- * if the block device is opened for access.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_block_open(struct block_device *bdev, fmode_t mode)
-{
- struct i2o_block_device *dev = bdev->bd_disk->private_data;
-
- if (!dev->i2o_dev)
- return -ENODEV;
-
- mutex_lock(&i2o_block_mutex);
- if (dev->power > 0x1f)
- i2o_block_device_power(dev, 0x02);
-
- i2o_block_device_mount(dev->i2o_dev, -1);
-
- i2o_block_device_lock(dev->i2o_dev, -1);
-
- osm_debug("Ready.\n");
- mutex_unlock(&i2o_block_mutex);
-
- return 0;
-};
-
-/**
- * i2o_block_release - Release the I2O block device
- * @disk: gendisk device being released
- * @mode: file open mode
- *
- * Unlock and unmount the media, and power down the device. Gets called if
- * the block device is closed.
- */
-static void i2o_block_release(struct gendisk *disk, fmode_t mode)
-{
- struct i2o_block_device *dev = disk->private_data;
- u8 operation;
-
- /*
- * This is to deal with the case of an application
- * opening a device and then the device disappears while
- * it's in use, and then the application tries to release
- * it. ex: Unmounting a deleted RAID volume at reboot.
- * If we send messages, it will just cause FAILs since
- * the TID no longer exists.
- */
- if (!dev->i2o_dev)
- return;
-
- mutex_lock(&i2o_block_mutex);
- i2o_block_device_flush(dev->i2o_dev);
-
- i2o_block_device_unlock(dev->i2o_dev, -1);
-
- if (dev->flags & (1 << 3 | 1 << 4)) /* Removable */
- operation = 0x21;
- else
- operation = 0x24;
-
- i2o_block_device_power(dev, operation);
- mutex_unlock(&i2o_block_mutex);
-}
-
-static int i2o_block_getgeo(struct block_device *bdev, struct hd_geometry *geo)
-{
- i2o_block_biosparam(get_capacity(bdev->bd_disk),
- &geo->cylinders, &geo->heads, &geo->sectors);
- return 0;
-}
-
-/**
- * i2o_block_ioctl - Issue device specific ioctl calls.
- * @bdev: block device being opened
- * @mode: file open mode
- * @cmd: ioctl command
- * @arg: arg
- *
- * Handles ioctl request for the block device.
- *
- * Return 0 on success or negative error on failure.
- */
-static int i2o_block_ioctl(struct block_device *bdev, fmode_t mode,
- unsigned int cmd, unsigned long arg)
-{
- struct gendisk *disk = bdev->bd_disk;
- struct i2o_block_device *dev = disk->private_data;
- int ret = -ENOTTY;
-
- /* Anyone capable of this syscall can do *real bad* things */
-
- if (!capable(CAP_SYS_ADMIN))
- return -EPERM;
-
- mutex_lock(&i2o_block_mutex);
- switch (cmd) {
- case BLKI2OGRSTRAT:
- ret = put_user(dev->rcache, (int __user *)arg);
- break;
- case BLKI2OGWSTRAT:
- ret = put_user(dev->wcache, (int __user *)arg);
- break;
- case BLKI2OSRSTRAT:
- ret = -EINVAL;
- if (arg < 0 || arg > CACHE_SMARTFETCH)
- break;
- dev->rcache = arg;
- ret = 0;
- break;
- case BLKI2OSWSTRAT:
- ret = -EINVAL;
- if (arg != 0
- && (arg < CACHE_WRITETHROUGH || arg > CACHE_SMARTBACK))
- break;
- dev->wcache = arg;
- ret = 0;
- break;
- }
- mutex_unlock(&i2o_block_mutex);
-
- return ret;
-};
-
-/**
- * i2o_block_check_events - Have we seen a media change?
- * @disk: gendisk which should be verified
- * @clearing: events being cleared
- *
- * Verifies if the media has changed.
- *
- * Returns 1 if the media was changed or 0 otherwise.
- */
-static unsigned int i2o_block_check_events(struct gendisk *disk,
- unsigned int clearing)
-{
- struct i2o_block_device *p = disk->private_data;
-
- if (p->media_change_flag) {
- p->media_change_flag = 0;
- return DISK_EVENT_MEDIA_CHANGE;
- }
- return 0;
-}
-
-/**
- * i2o_block_transfer - Transfer a request to/from the I2O controller
- * @req: the request which should be transferred
- *
- * This function converts the request into a I2O message. The necessary
- * DMA buffers are allocated and after everything is setup post the message
- * to the I2O controller. No cleanup is done by this function. It is done
- * on the interrupt side when the reply arrives.
- *
- * Return 0 on success or negative error code on failure.
- */
-static int i2o_block_transfer(struct request *req)
-{
- struct i2o_block_device *dev = req->rq_disk->private_data;
- struct i2o_controller *c;
- u32 tid;
- struct i2o_message *msg;
- u32 *mptr;
- struct i2o_block_request *ireq = req->special;
- u32 tcntxt;
- u32 sgl_offset = SGL_OFFSET_8;
- u32 ctl_flags = 0x00000000;
- int rc;
- u32 cmd;
-
- if (unlikely(!dev->i2o_dev)) {
- osm_err("transfer to removed drive\n");
- rc = -ENODEV;
- goto exit;
- }
-
- tid = dev->i2o_dev->lct_data.tid;
- c = dev->i2o_dev->iop;
-
- msg = i2o_msg_get(c);
- if (IS_ERR(msg)) {
- rc = PTR_ERR(msg);
- goto exit;
- }
-
- tcntxt = i2o_cntxt_list_add(c, req);
- if (!tcntxt) {
- rc = -ENOMEM;
- goto nop_msg;
- }
-
- msg->u.s.icntxt = cpu_to_le32(i2o_block_driver.context);
- msg->u.s.tcntxt = cpu_to_le32(tcntxt);
-
- mptr = &msg->body[0];
-
- if (rq_data_dir(req) == READ) {
- cmd = I2O_CMD_BLOCK_READ << 24;
-
- switch (dev->rcache) {
- case CACHE_PREFETCH:
- ctl_flags = 0x201F0008;
- break;
-
- case CACHE_SMARTFETCH:
- if (blk_rq_sectors(req) > 16)
- ctl_flags = 0x201F0008;
- else
- ctl_flags = 0x001F0000;
- break;
-
- default:
- break;
- }
- } else {
- cmd = I2O_CMD_BLOCK_WRITE << 24;
-
- switch (dev->wcache) {
- case CACHE_WRITETHROUGH:
- ctl_flags = 0x001F0008;
- break;
- case CACHE_WRITEBACK:
- ctl_flags = 0x001F0010;
- break;
- case CACHE_SMARTBACK:
- if (blk_rq_sectors(req) > 16)
- ctl_flags = 0x001F0004;
- else
- ctl_flags = 0x001F0010;
- break;
- case CACHE_SMARTTHROUGH:
- if (blk_rq_sectors(req) > 16)
- ctl_flags = 0x001F0004;
- else
- ctl_flags = 0x001F0010;
- default:
- break;
- }
- }
-
-#ifdef CONFIG_I2O_EXT_ADAPTEC
- if (c->adaptec) {
- u8 cmd[10];
- u32 scsi_flags;
- u16 hwsec;
-
- hwsec = queue_logical_block_size(req->q) >> KERNEL_SECTOR_SHIFT;
- memset(cmd, 0, 10);
-
- sgl_offset = SGL_OFFSET_12;
-
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_PRIVATE << 24 | HOST_TID << 12 | tid);
-
- *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC);
- *mptr++ = cpu_to_le32(tid);
-
- /*
- * ENABLE_DISCONNECT
- * SIMPLE_TAG
- * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME
- */
- if (rq_data_dir(req) == READ) {
- cmd[0] = READ_10;
- scsi_flags = 0x60a0000a;
- } else {
- cmd[0] = WRITE_10;
- scsi_flags = 0xa0a0000a;
- }
-
- *mptr++ = cpu_to_le32(scsi_flags);
-
- *((u32 *) & cmd[2]) = cpu_to_be32(blk_rq_pos(req) * hwsec);
- *((u16 *) & cmd[7]) = cpu_to_be16(blk_rq_sectors(req) * hwsec);
-
- memcpy(mptr, cmd, 10);
- mptr += 4;
- *mptr++ = cpu_to_le32(blk_rq_bytes(req));
- } else
-#endif
- {
- msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid);
- *mptr++ = cpu_to_le32(ctl_flags);
- *mptr++ = cpu_to_le32(blk_rq_bytes(req));
- *mptr++ =
- cpu_to_le32((u32) (blk_rq_pos(req) << KERNEL_SECTOR_SHIFT));
- *mptr++ =
- cpu_to_le32(blk_rq_pos(req) >> (32 - KERNEL_SECTOR_SHIFT));
- }
-
- if (!i2o_block_sglist_alloc(c, ireq, &mptr)) {
- rc = -ENOMEM;
- goto context_remove;
- }
-
- msg->u.head[0] =
- cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset);
-
- list_add_tail(&ireq->queue, &dev->open_queue);
- dev->open_queue_depth++;
-
- i2o_msg_post(c, msg);
-
- return 0;
-
-context_remove:
- i2o_cntxt_list_remove(c, req);
-
-nop_msg:
- i2o_msg_nop(c, msg);
-
-exit:
- return rc;
-};
-
-/**
- * i2o_block_request_fn - request queue handling function
- * @q: request queue from which the request could be fetched
- *
- * Takes the next request from the queue, transfers it and if no error
- * occurs dequeue it from the queue. On arrival of the reply the message
- * will be processed further. If an error occurs requeue the request.
- */
-static void i2o_block_request_fn(struct request_queue *q)
-{
- struct request *req;
-
- while ((req = blk_peek_request(q)) != NULL) {
- if (req->cmd_type == REQ_TYPE_FS) {
- struct i2o_block_delayed_request *dreq;
- struct i2o_block_request *ireq = req->special;
- unsigned int queue_depth;
-
- queue_depth = ireq->i2o_blk_dev->open_queue_depth;
-
- if (queue_depth < I2O_BLOCK_MAX_OPEN_REQUESTS) {
- if (!i2o_block_transfer(req)) {
- blk_start_request(req);
- continue;
- } else
- osm_info("transfer error\n");
- }
-
- if (queue_depth)
- break;
-
- /* stop the queue and retry later */
- dreq = kmalloc(sizeof(*dreq), GFP_ATOMIC);
- if (!dreq)
- continue;
-
- dreq->queue = q;
- INIT_DELAYED_WORK(&dreq->work,
- i2o_block_delayed_request_fn);
-
- if (!queue_delayed_work(i2o_block_driver.event_queue,
- &dreq->work,
- I2O_BLOCK_RETRY_TIME))
- kfree(dreq);
- else {
- blk_stop_queue(q);
- break;
- }
- } else {
- blk_start_request(req);
- __blk_end_request_all(req, -EIO);
- }
- }
-};
-
-/* I2O Block device operations definition */
-static const struct block_device_operations i2o_block_fops = {
- .owner = THIS_MODULE,
- .open = i2o_block_open,
- .release = i2o_block_release,
- .ioctl = i2o_block_ioctl,
- .compat_ioctl = i2o_block_ioctl,
- .getgeo = i2o_block_getgeo,
- .check_events = i2o_block_check_events,
-};
-
-/**
- * i2o_block_device_alloc - Allocate memory for a I2O Block device
- *
- * Allocate memory for the i2o_block_device struct, gendisk and request
- * queue and initialize them as far as no additional information is needed.
- *
- * Returns a pointer to the allocated I2O Block device on success or a
- * negative error code on failure.
- */
-static struct i2o_block_device *i2o_block_device_alloc(void)
-{
- struct i2o_block_device *dev;
- struct gendisk *gd;
- struct request_queue *queue;
- int rc;
-
- dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (!dev) {
- osm_err("Insufficient memory to allocate I2O Block disk.\n");
- rc = -ENOMEM;
- goto exit;
- }
-
- INIT_LIST_HEAD(&dev->open_queue);
- spin_lock_init(&dev->lock);
- dev->rcache = CACHE_PREFETCH;
- dev->wcache = CACHE_WRITEBACK;
-
- /* allocate a gendisk with 16 partitions */
- gd = alloc_disk(16);
- if (!gd) {
- osm_err("Insufficient memory to allocate gendisk.\n");
- rc = -ENOMEM;
- goto cleanup_dev;
- }
-
- /* initialize the request queue */
- queue = blk_init_queue(i2o_block_request_fn, &dev->lock);
- if (!queue) {
- osm_err("Insufficient memory to allocate request queue.\n");
- rc = -ENOMEM;
- goto cleanup_queue;
- }
-
- blk_queue_prep_rq(queue, i2o_block_prep_req_fn);
-
- gd->major = I2O_MAJOR;
- gd->queue = queue;
- gd->fops = &i2o_block_fops;
- gd->private_data = dev;
-
- dev->gd = gd;
-
- return dev;
-
-cleanup_queue:
- put_disk(gd);
-
-cleanup_dev:
- kfree(dev);
-
-exit:
- return ERR_PTR(rc);
-};
-
-/**
- * i2o_block_probe - verify if dev is a I2O Block device and install it
- * @dev: device to verify if it is a I2O Block device
- *
- * We only verify if the user_tid of the device is 0xfff and then install
- * the device. Otherwise it is used by some other device (e. g. RAID).
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_block_probe(struct device *dev)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
- struct i2o_controller *c = i2o_dev->iop;
- struct i2o_block_device *i2o_blk_dev;
- struct gendisk *gd;
- struct request_queue *queue;
- static int unit;
- int rc;
- u64 size;
- u32 blocksize;
- u16 body_size = 4;
- u16 power;
- unsigned short max_sectors;
-
-#ifdef CONFIG_I2O_EXT_ADAPTEC
- if (c->adaptec)
- body_size = 8;
-#endif
-
- if (c->limit_sectors)
- max_sectors = I2O_MAX_SECTORS_LIMITED;
- else
- max_sectors = I2O_MAX_SECTORS;
-
- /* skip devices which are used by IOP */
- if (i2o_dev->lct_data.user_tid != 0xfff) {
- osm_debug("skipping used device %03x\n", i2o_dev->lct_data.tid);
- return -ENODEV;
- }
-
- if (i2o_device_claim(i2o_dev)) {
- osm_warn("Unable to claim device. Installation aborted\n");
- rc = -EFAULT;
- goto exit;
- }
-
- i2o_blk_dev = i2o_block_device_alloc();
- if (IS_ERR(i2o_blk_dev)) {
- osm_err("could not alloc a new I2O block device");
- rc = PTR_ERR(i2o_blk_dev);
- goto claim_release;
- }
-
- i2o_blk_dev->i2o_dev = i2o_dev;
- dev_set_drvdata(dev, i2o_blk_dev);
-
- /* setup gendisk */
- gd = i2o_blk_dev->gd;
- gd->first_minor = unit << 4;
- sprintf(gd->disk_name, "i2o/hd%c", 'a' + unit);
- gd->driverfs_dev = &i2o_dev->device;
-
- /* setup request queue */
- queue = gd->queue;
- queue->queuedata = i2o_blk_dev;
-
- blk_queue_max_hw_sectors(queue, max_sectors);
- blk_queue_max_segments(queue, i2o_sg_tablesize(c, body_size));
-
- osm_debug("max sectors = %d\n", queue->max_sectors);
- osm_debug("phys segments = %d\n", queue->max_phys_segments);
- osm_debug("max hw segments = %d\n", queue->max_hw_segments);
-
- /*
- * Ask for the current media data. If that isn't supported
- * then we ask for the device capacity data
- */
- if (!i2o_parm_field_get(i2o_dev, 0x0004, 1, &blocksize, 4) ||
- !i2o_parm_field_get(i2o_dev, 0x0000, 3, &blocksize, 4)) {
- blk_queue_logical_block_size(queue, le32_to_cpu(blocksize));
- } else
- osm_warn("unable to get blocksize of %s\n", gd->disk_name);
-
- if (!i2o_parm_field_get(i2o_dev, 0x0004, 0, &size, 8) ||
- !i2o_parm_field_get(i2o_dev, 0x0000, 4, &size, 8)) {
- set_capacity(gd, le64_to_cpu(size) >> KERNEL_SECTOR_SHIFT);
- } else
- osm_warn("could not get size of %s\n", gd->disk_name);
-
- if (!i2o_parm_field_get(i2o_dev, 0x0000, 2, &power, 2))
- i2o_blk_dev->power = power;
-
- i2o_event_register(i2o_dev, &i2o_block_driver, 0, 0xffffffff);
-
- add_disk(gd);
-
- unit++;
-
- osm_info("device added (TID: %03x): %s\n", i2o_dev->lct_data.tid,
- i2o_blk_dev->gd->disk_name);
-
- return 0;
-
-claim_release:
- i2o_device_claim_release(i2o_dev);
-
-exit:
- return rc;
-};
-
-/* Block OSM driver struct */
-static struct i2o_driver i2o_block_driver = {
- .name = OSM_NAME,
- .event = i2o_block_event,
- .reply = i2o_block_reply,
- .classes = i2o_block_class_id,
- .driver = {
- .probe = i2o_block_probe,
- .remove = i2o_block_remove,
- },
-};
-
-/**
- * i2o_block_init - Block OSM initialization function
- *
- * Allocate the slab and mempool for request structs, registers i2o_block
- * block device and finally register the Block OSM in the I2O core.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int __init i2o_block_init(void)
-{
- int rc;
- int size;
-
- printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
-
- /* Allocate request mempool and slab */
- size = sizeof(struct i2o_block_request);
- i2o_blk_req_pool.slab = kmem_cache_create("i2o_block_req", size, 0,
- SLAB_HWCACHE_ALIGN, NULL);
- if (!i2o_blk_req_pool.slab) {
- osm_err("can't init request slab\n");
- rc = -ENOMEM;
- goto exit;
- }
-
- i2o_blk_req_pool.pool =
- mempool_create_slab_pool(I2O_BLOCK_REQ_MEMPOOL_SIZE,
- i2o_blk_req_pool.slab);
- if (!i2o_blk_req_pool.pool) {
- osm_err("can't init request mempool\n");
- rc = -ENOMEM;
- goto free_slab;
- }
-
- /* Register the block device interfaces */
- rc = register_blkdev(I2O_MAJOR, "i2o_block");
- if (rc) {
- osm_err("unable to register block device\n");
- goto free_mempool;
- }
-#ifdef MODULE
- osm_info("registered device at major %d\n", I2O_MAJOR);
-#endif
-
- /* Register Block OSM into I2O core */
- rc = i2o_driver_register(&i2o_block_driver);
- if (rc) {
- osm_err("Could not register Block driver\n");
- goto unregister_blkdev;
- }
-
- return 0;
-
-unregister_blkdev:
- unregister_blkdev(I2O_MAJOR, "i2o_block");
-
-free_mempool:
- mempool_destroy(i2o_blk_req_pool.pool);
-
-free_slab:
- kmem_cache_destroy(i2o_blk_req_pool.slab);
-
-exit:
- return rc;
-};
-
-/**
- * i2o_block_exit - Block OSM exit function
- *
- * Unregisters Block OSM from I2O core, unregisters i2o_block block device
- * and frees the mempool and slab.
- */
-static void __exit i2o_block_exit(void)
-{
- /* Unregister I2O Block OSM from I2O core */
- i2o_driver_unregister(&i2o_block_driver);
-
- /* Unregister block device */
- unregister_blkdev(I2O_MAJOR, "i2o_block");
-
- /* Free request mempool and slab */
- mempool_destroy(i2o_blk_req_pool.pool);
- kmem_cache_destroy(i2o_blk_req_pool.slab);
-};
-
-MODULE_AUTHOR("Red Hat");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(OSM_DESCRIPTION);
-MODULE_VERSION(OSM_VERSION);
-
-module_init(i2o_block_init);
-module_exit(i2o_block_exit);
diff --git a/drivers/staging/i2o/i2o_block.h b/drivers/staging/i2o/i2o_block.h
deleted file mode 100644
index cf8873cbca3f23..00000000000000
--- a/drivers/staging/i2o/i2o_block.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Block OSM structures/API
- *
- * Copyright (C) 1999-2002 Red Hat Software
- *
- * Written by Alan Cox, Building Number Three Ltd
- *
- * 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.
- *
- * For the purpose of avoiding doubt the preferred form of the work
- * for making modifications shall be a standards compliant form such
- * gzipped tar and not one requiring a proprietary or patent encumbered
- * tool to unpack.
- *
- * Fixes/additions:
- * Steve Ralston:
- * Multiple device handling error fixes,
- * Added a queue depth.
- * Alan Cox:
- * FC920 has an rmw bug. Dont or in the end marker.
- * Removed queue walk, fixed for 64bitness.
- * Rewrote much of the code over time
- * Added indirect block lists
- * Handle 64K limits on many controllers
- * Don't use indirects on the Promise (breaks)
- * Heavily chop down the queue depths
- * Deepak Saxena:
- * Independent queues per IOP
- * Support for dynamic device creation/deletion
- * Code cleanup
- * Support for larger I/Os through merge* functions
- * (taken from DAC960 driver)
- * Boji T Kannanthanam:
- * Set the I2O Block devices to be detected in increasing
- * order of TIDs during boot.
- * Search and set the I2O block device that we boot off
- * from as the first device to be claimed (as /dev/i2o/hda)
- * Properly attach/detach I2O gendisk structure from the
- * system gendisk list. The I2O block devices now appear in
- * /proc/partitions.
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Minor bugfixes for 2.6.
- */
-
-#ifndef I2O_BLOCK_OSM_H
-#define I2O_BLOCK_OSM_H
-
-#define I2O_BLOCK_RETRY_TIME HZ/4
-#define I2O_BLOCK_MAX_OPEN_REQUESTS 50
-
-/* request queue sizes */
-#define I2O_BLOCK_REQ_MEMPOOL_SIZE 32
-
-#define KERNEL_SECTOR_SHIFT 9
-#define KERNEL_SECTOR_SIZE (1 << KERNEL_SECTOR_SHIFT)
-
-/* I2O Block OSM mempool struct */
-struct i2o_block_mempool {
- struct kmem_cache *slab;
- mempool_t *pool;
-};
-
-/* I2O Block device descriptor */
-struct i2o_block_device {
- struct i2o_device *i2o_dev; /* pointer to I2O device */
- struct gendisk *gd;
- spinlock_t lock; /* queue lock */
- struct list_head open_queue; /* list of transferred, but unfinished
- requests */
- unsigned int open_queue_depth; /* number of requests in the queue */
-
- int rcache; /* read cache flags */
- int wcache; /* write cache flags */
- int flags;
- u16 power; /* power state */
- int media_change_flag; /* media changed flag */
-};
-
-/* I2O Block device request */
-struct i2o_block_request {
- struct list_head queue;
- struct request *req; /* corresponding request */
- struct i2o_block_device *i2o_blk_dev; /* I2O block device */
- struct device *dev; /* device used for DMA */
- int sg_nents; /* number of SG elements */
- struct scatterlist sg_table[I2O_MAX_PHYS_SEGMENTS]; /* SG table */
-};
-
-/* I2O Block device delayed request */
-struct i2o_block_delayed_request {
- struct delayed_work work;
- struct request_queue *queue;
-};
-
-#endif
diff --git a/drivers/staging/i2o/i2o_config.c b/drivers/staging/i2o/i2o_config.c
deleted file mode 100644
index cd7ca5eb18ff30..00000000000000
--- a/drivers/staging/i2o/i2o_config.c
+++ /dev/null
@@ -1,1162 +0,0 @@
-/*
- * I2O Configuration Interface Driver
- *
- * (C) Copyright 1999-2002 Red Hat
- *
- * Written by Alan Cox, Building Number Three Ltd
- *
- * Fixes/additions:
- * Deepak Saxena (04/20/1999):
- * Added basic ioctl() support
- * Deepak Saxena (06/07/1999):
- * Added software download ioctl (still testing)
- * Auvo Häkkinen (09/10/1999):
- * Changes to i2o_cfg_reply(), ioctl_parms()
- * Added ioct_validate()
- * Taneli Vähäkangas (09/30/1999):
- * Fixed ioctl_swdl()
- * Taneli Vähäkangas (10/04/1999):
- * Changed ioctl_swdl(), implemented ioctl_swul() and ioctl_swdel()
- * Deepak Saxena (11/18/1999):
- * Added event managmenet support
- * Alan Cox <alan@lxorguk.ukuu.org.uk>:
- * 2.4 rewrite ported to 2.5
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Added pass-thru support for Adaptec's raidutils
- *
- * 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/miscdevice.h>
-#include <linux/mutex.h>
-#include <linux/compat.h>
-#include <linux/slab.h>
-#include <linux/uaccess.h>
-
-#include "core.h"
-
-#define SG_TABLESIZE 30
-
-static DEFINE_MUTEX(i2o_cfg_mutex);
-static long i2o_cfg_ioctl(struct file *, unsigned int, unsigned long);
-
-static spinlock_t i2o_config_lock;
-
-#define MODINC(x,y) ((x) = ((x) + 1) % (y))
-
-struct sg_simple_element {
- u32 flag_count;
- u32 addr_bus;
-};
-
-struct i2o_cfg_info {
- struct file *fp;
- struct fasync_struct *fasync;
- struct i2o_evt_info event_q[I2O_EVT_Q_LEN];
- u16 q_in; // Queue head index
- u16 q_out; // Queue tail index
- u16 q_len; // Queue length
- u16 q_lost; // Number of lost events
- ulong q_id; // Event queue ID...used as tx_context
- struct i2o_cfg_info *next;
-};
-static struct i2o_cfg_info *open_files = NULL;
-static ulong i2o_cfg_info_id;
-
-static int i2o_cfg_getiops(unsigned long arg)
-{
- struct i2o_controller *c;
- u8 __user *user_iop_table = (void __user *)arg;
- u8 tmp[MAX_I2O_CONTROLLERS];
- int ret = 0;
-
- memset(tmp, 0, MAX_I2O_CONTROLLERS);
-
- list_for_each_entry(c, &i2o_controllers, list)
- tmp[c->unit] = 1;
-
- if (copy_to_user(user_iop_table, tmp, MAX_I2O_CONTROLLERS))
- ret = -EFAULT;
-
- return ret;
-};
-
-static int i2o_cfg_gethrt(unsigned long arg)
-{
- struct i2o_controller *c;
- struct i2o_cmd_hrtlct __user *cmd = (struct i2o_cmd_hrtlct __user *)arg;
- struct i2o_cmd_hrtlct kcmd;
- i2o_hrt *hrt;
- int len;
- u32 reslen;
- int ret = 0;
-
- if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_hrtlct)))
- return -EFAULT;
-
- if (get_user(reslen, kcmd.reslen) < 0)
- return -EFAULT;
-
- if (kcmd.resbuf == NULL)
- return -EFAULT;
-
- c = i2o_find_iop(kcmd.iop);
- if (!c)
- return -ENXIO;
-
- hrt = (i2o_hrt *) c->hrt.virt;
-
- len = 8 + ((hrt->entry_len * hrt->num_entries) << 2);
-
- if (put_user(len, kcmd.reslen))
- ret = -EFAULT;
- else if (len > reslen)
- ret = -ENOBUFS;
- else if (copy_to_user(kcmd.resbuf, (void *)hrt, len))
- ret = -EFAULT;
-
- return ret;
-};
-
-static int i2o_cfg_getlct(unsigned long arg)
-{
- struct i2o_controller *c;
- struct i2o_cmd_hrtlct __user *cmd = (struct i2o_cmd_hrtlct __user *)arg;
- struct i2o_cmd_hrtlct kcmd;
- i2o_lct *lct;
- int len;
- int ret = 0;
- u32 reslen;
-
- if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_hrtlct)))
- return -EFAULT;
-
- if (get_user(reslen, kcmd.reslen) < 0)
- return -EFAULT;
-
- if (kcmd.resbuf == NULL)
- return -EFAULT;
-
- c = i2o_find_iop(kcmd.iop);
- if (!c)
- return -ENXIO;
-
- lct = (i2o_lct *) c->lct;
-
- len = (unsigned int)lct->table_size << 2;
- if (put_user(len, kcmd.reslen))
- ret = -EFAULT;
- else if (len > reslen)
- ret = -ENOBUFS;
- else if (copy_to_user(kcmd.resbuf, lct, len))
- ret = -EFAULT;
-
- return ret;
-};
-
-static int i2o_cfg_parms(unsigned long arg, unsigned int type)
-{
- int ret = 0;
- struct i2o_controller *c;
- struct i2o_device *dev;
- struct i2o_cmd_psetget __user *cmd =
- (struct i2o_cmd_psetget __user *)arg;
- struct i2o_cmd_psetget kcmd;
- u32 reslen;
- u8 *ops;
- u8 *res;
- int len = 0;
-
- u32 i2o_cmd = (type == I2OPARMGET ?
- I2O_CMD_UTIL_PARAMS_GET : I2O_CMD_UTIL_PARAMS_SET);
-
- if (copy_from_user(&kcmd, cmd, sizeof(struct i2o_cmd_psetget)))
- return -EFAULT;
-
- if (get_user(reslen, kcmd.reslen))
- return -EFAULT;
-
- c = i2o_find_iop(kcmd.iop);
- if (!c)
- return -ENXIO;
-
- dev = i2o_iop_find_device(c, kcmd.tid);
- if (!dev)
- return -ENXIO;
-
- /*
- * Stop users being able to try and allocate arbitrary amounts
- * of DMA space. 64K is way more than sufficient for this.
- */
- if (kcmd.oplen > 65536)
- return -EMSGSIZE;
-
- ops = memdup_user(kcmd.opbuf, kcmd.oplen);
- if (IS_ERR(ops))
- return PTR_ERR(ops);
-
- /*
- * It's possible to have a _very_ large table
- * and that the user asks for all of it at once...
- */
- res = kmalloc(65536, GFP_KERNEL);
- if (!res) {
- kfree(ops);
- return -ENOMEM;
- }
-
- len = i2o_parm_issue(dev, i2o_cmd, ops, kcmd.oplen, res, 65536);
- kfree(ops);
-
- if (len < 0) {
- kfree(res);
- return -EAGAIN;
- }
-
- if (put_user(len, kcmd.reslen))
- ret = -EFAULT;
- else if (len > reslen)
- ret = -ENOBUFS;
- else if (copy_to_user(kcmd.resbuf, res, len))
- ret = -EFAULT;
-
- kfree(res);
-
- return ret;
-};
-
-static int i2o_cfg_swdl(unsigned long arg)
-{
- struct i2o_sw_xfer kxfer;
- struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
- unsigned char maxfrag = 0, curfrag = 1;
- struct i2o_dma buffer;
- struct i2o_message *msg;
- unsigned int status = 0, swlen = 0, fragsize = 8192;
- struct i2o_controller *c;
-
- if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer)))
- return -EFAULT;
-
- if (get_user(swlen, kxfer.swlen) < 0)
- return -EFAULT;
-
- if (get_user(maxfrag, kxfer.maxfrag) < 0)
- return -EFAULT;
-
- if (get_user(curfrag, kxfer.curfrag) < 0)
- return -EFAULT;
-
- if (curfrag == maxfrag)
- fragsize = swlen - (maxfrag - 1) * 8192;
-
- if (!kxfer.buf || !access_ok(VERIFY_READ, kxfer.buf, fragsize))
- return -EFAULT;
-
- c = i2o_find_iop(kxfer.iop);
- if (!c)
- return -ENXIO;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize)) {
- i2o_msg_nop(c, msg);
- return -ENOMEM;
- }
-
- if (__copy_from_user(buffer.virt, kxfer.buf, fragsize)) {
- i2o_msg_nop(c, msg);
- i2o_dma_free(&c->pdev->dev, &buffer);
- return -EFAULT;
- }
-
- msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_SW_DOWNLOAD << 24 | HOST_TID << 12 |
- ADAPTER_TID);
- msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
- msg->u.head[3] = cpu_to_le32(0);
- msg->body[0] =
- cpu_to_le32((((u32) kxfer.flags) << 24) | (((u32) kxfer.
- sw_type) << 16) |
- (((u32) maxfrag) << 8) | (((u32) curfrag)));
- msg->body[1] = cpu_to_le32(swlen);
- msg->body[2] = cpu_to_le32(kxfer.sw_id);
- msg->body[3] = cpu_to_le32(0xD0000000 | fragsize);
- msg->body[4] = cpu_to_le32(buffer.phys);
-
- osm_debug("swdl frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
- status = i2o_msg_post_wait_mem(c, msg, 60, &buffer);
-
- if (status != -ETIMEDOUT)
- i2o_dma_free(&c->pdev->dev, &buffer);
-
- if (status != I2O_POST_WAIT_OK) {
- // it fails if you try and send frags out of order
- // and for some yet unknown reasons too
- osm_info("swdl failed, DetailedStatus = %d\n", status);
- return status;
- }
-
- return 0;
-};
-
-static int i2o_cfg_swul(unsigned long arg)
-{
- struct i2o_sw_xfer kxfer;
- struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
- unsigned char maxfrag = 0, curfrag = 1;
- struct i2o_dma buffer;
- struct i2o_message *msg;
- unsigned int status = 0, swlen = 0, fragsize = 8192;
- struct i2o_controller *c;
- int ret = 0;
-
- if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer)))
- return -EFAULT;
-
- if (get_user(swlen, kxfer.swlen) < 0)
- return -EFAULT;
-
- if (get_user(maxfrag, kxfer.maxfrag) < 0)
- return -EFAULT;
-
- if (get_user(curfrag, kxfer.curfrag) < 0)
- return -EFAULT;
-
- if (curfrag == maxfrag)
- fragsize = swlen - (maxfrag - 1) * 8192;
-
- if (!kxfer.buf)
- return -EFAULT;
-
- c = i2o_find_iop(kxfer.iop);
- if (!c)
- return -ENXIO;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- if (i2o_dma_alloc(&c->pdev->dev, &buffer, fragsize)) {
- i2o_msg_nop(c, msg);
- return -ENOMEM;
- }
-
- msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_7);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_SW_UPLOAD << 24 | HOST_TID << 12 | ADAPTER_TID);
- msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
- msg->u.head[3] = cpu_to_le32(0);
- msg->body[0] =
- cpu_to_le32((u32) kxfer.flags << 24 | (u32) kxfer.
- sw_type << 16 | (u32) maxfrag << 8 | (u32) curfrag);
- msg->body[1] = cpu_to_le32(swlen);
- msg->body[2] = cpu_to_le32(kxfer.sw_id);
- msg->body[3] = cpu_to_le32(0xD0000000 | fragsize);
- msg->body[4] = cpu_to_le32(buffer.phys);
-
- osm_debug("swul frag %d/%d (size %d)\n", curfrag, maxfrag, fragsize);
- status = i2o_msg_post_wait_mem(c, msg, 60, &buffer);
-
- if (status != I2O_POST_WAIT_OK) {
- if (status != -ETIMEDOUT)
- i2o_dma_free(&c->pdev->dev, &buffer);
-
- osm_info("swul failed, DetailedStatus = %d\n", status);
- return status;
- }
-
- if (copy_to_user(kxfer.buf, buffer.virt, fragsize))
- ret = -EFAULT;
-
- i2o_dma_free(&c->pdev->dev, &buffer);
-
- return ret;
-}
-
-static int i2o_cfg_swdel(unsigned long arg)
-{
- struct i2o_controller *c;
- struct i2o_sw_xfer kxfer;
- struct i2o_sw_xfer __user *pxfer = (struct i2o_sw_xfer __user *)arg;
- struct i2o_message *msg;
- unsigned int swlen;
- int token;
-
- if (copy_from_user(&kxfer, pxfer, sizeof(struct i2o_sw_xfer)))
- return -EFAULT;
-
- if (get_user(swlen, kxfer.swlen) < 0)
- return -EFAULT;
-
- c = i2o_find_iop(kxfer.iop);
- if (!c)
- return -ENXIO;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(SEVEN_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_SW_REMOVE << 24 | HOST_TID << 12 | ADAPTER_TID);
- msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
- msg->u.head[3] = cpu_to_le32(0);
- msg->body[0] =
- cpu_to_le32((u32) kxfer.flags << 24 | (u32) kxfer.sw_type << 16);
- msg->body[1] = cpu_to_le32(swlen);
- msg->body[2] = cpu_to_le32(kxfer.sw_id);
-
- token = i2o_msg_post_wait(c, msg, 10);
-
- if (token != I2O_POST_WAIT_OK) {
- osm_info("swdel failed, DetailedStatus = %d\n", token);
- return -ETIMEDOUT;
- }
-
- return 0;
-};
-
-static int i2o_cfg_validate(unsigned long arg)
-{
- int token;
- int iop = (int)arg;
- struct i2o_message *msg;
- struct i2o_controller *c;
-
- c = i2o_find_iop(iop);
- if (!c)
- return -ENXIO;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_CONFIG_VALIDATE << 24 | HOST_TID << 12 | iop);
- msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
- msg->u.head[3] = cpu_to_le32(0);
-
- token = i2o_msg_post_wait(c, msg, 10);
-
- if (token != I2O_POST_WAIT_OK) {
- osm_info("Can't validate configuration, ErrorStatus = %d\n",
- token);
- return -ETIMEDOUT;
- }
-
- return 0;
-};
-
-static int i2o_cfg_evt_reg(unsigned long arg, struct file *fp)
-{
- struct i2o_message *msg;
- struct i2o_evt_id __user *pdesc = (struct i2o_evt_id __user *)arg;
- struct i2o_evt_id kdesc;
- struct i2o_controller *c;
- struct i2o_device *d;
-
- if (copy_from_user(&kdesc, pdesc, sizeof(struct i2o_evt_id)))
- return -EFAULT;
-
- /* IOP exists? */
- c = i2o_find_iop(kdesc.iop);
- if (!c)
- return -ENXIO;
-
- /* Device exists? */
- d = i2o_iop_find_device(c, kdesc.tid);
- if (!d)
- return -ENODEV;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 |
- kdesc.tid);
- msg->u.head[2] = cpu_to_le32(i2o_config_driver.context);
- msg->u.head[3] = cpu_to_le32(i2o_cntxt_list_add(c, fp->private_data));
- msg->body[0] = cpu_to_le32(kdesc.evt_mask);
-
- i2o_msg_post(c, msg);
-
- return 0;
-}
-
-static int i2o_cfg_evt_get(unsigned long arg, struct file *fp)
-{
- struct i2o_cfg_info *p = NULL;
- struct i2o_evt_get __user *uget = (struct i2o_evt_get __user *)arg;
- struct i2o_evt_get kget;
- unsigned long flags;
-
- for (p = open_files; p; p = p->next)
- if (p->q_id == (ulong) fp->private_data)
- break;
-
- if (!p->q_len)
- return -ENOENT;
-
- memcpy(&kget.info, &p->event_q[p->q_out], sizeof(struct i2o_evt_info));
- MODINC(p->q_out, I2O_EVT_Q_LEN);
- spin_lock_irqsave(&i2o_config_lock, flags);
- p->q_len--;
- kget.pending = p->q_len;
- kget.lost = p->q_lost;
- spin_unlock_irqrestore(&i2o_config_lock, flags);
-
- if (copy_to_user(uget, &kget, sizeof(struct i2o_evt_get)))
- return -EFAULT;
- return 0;
-}
-
-#ifdef CONFIG_COMPAT
-static int i2o_cfg_passthru32(struct file *file, unsigned cmnd,
- unsigned long arg)
-{
- struct i2o_cmd_passthru32 __user *cmd;
- struct i2o_controller *c;
- u32 __user *user_msg;
- u32 *reply = NULL;
- u32 __user *user_reply = NULL;
- u32 size = 0;
- u32 reply_size = 0;
- u32 rcode = 0;
- struct i2o_dma sg_list[SG_TABLESIZE];
- u32 sg_offset = 0;
- u32 sg_count = 0;
- u32 i = 0;
- u32 sg_index = 0;
- i2o_status_block *sb;
- struct i2o_message *msg;
- unsigned int iop;
-
- cmd = (struct i2o_cmd_passthru32 __user *)arg;
-
- if (get_user(iop, &cmd->iop) || get_user(i, &cmd->msg))
- return -EFAULT;
-
- user_msg = compat_ptr(i);
-
- c = i2o_find_iop(iop);
- if (!c) {
- osm_debug("controller %d not found\n", iop);
- return -ENXIO;
- }
-
- sb = c->status_block.virt;
-
- if (get_user(size, &user_msg[0])) {
- osm_warn("unable to get size!\n");
- return -EFAULT;
- }
- size = size >> 16;
-
- if (size > sb->inbound_frame_size) {
- osm_warn("size of message > inbound_frame_size");
- return -EFAULT;
- }
-
- user_reply = &user_msg[size];
-
- size <<= 2; // Convert to bytes
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- rcode = -EFAULT;
- /* Copy in the user's I2O command */
- if (copy_from_user(msg, user_msg, size)) {
- osm_warn("unable to copy user message\n");
- goto out;
- }
- i2o_dump_message(msg);
-
- if (get_user(reply_size, &user_reply[0]) < 0)
- goto out;
-
- reply_size >>= 16;
- reply_size <<= 2;
-
- rcode = -ENOMEM;
- reply = kzalloc(reply_size, GFP_KERNEL);
- if (!reply) {
- printk(KERN_WARNING "%s: Could not allocate reply buffer\n",
- c->name);
- goto out;
- }
-
- sg_offset = (msg->u.head[0] >> 4) & 0x0f;
-
- memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE);
- if (sg_offset) {
- struct sg_simple_element *sg;
-
- if (sg_offset * 4 >= size) {
- rcode = -EFAULT;
- goto cleanup;
- }
- // TODO 64bit fix
- sg = (struct sg_simple_element *)((&msg->u.head[0]) +
- sg_offset);
- sg_count =
- (size - sg_offset * 4) / sizeof(struct sg_simple_element);
- if (sg_count > SG_TABLESIZE) {
- printk(KERN_DEBUG "%s:IOCTL SG List too large (%u)\n",
- c->name, sg_count);
- rcode = -EINVAL;
- goto cleanup;
- }
-
- for (i = 0; i < sg_count; i++) {
- int sg_size;
- struct i2o_dma *p;
-
- if (!(sg[i].flag_count & 0x10000000
- /*I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT */ )) {
- printk(KERN_DEBUG
- "%s:Bad SG element %d - not simple (%x)\n",
- c->name, i, sg[i].flag_count);
- rcode = -EINVAL;
- goto cleanup;
- }
- sg_size = sg[i].flag_count & 0xffffff;
- p = &(sg_list[sg_index]);
- /* Allocate memory for the transfer */
- if (i2o_dma_alloc(&c->pdev->dev, p, sg_size)) {
- printk(KERN_DEBUG
- "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
- c->name, sg_size, i, sg_count);
- rcode = -ENOMEM;
- goto sg_list_cleanup;
- }
- sg_index++;
- /* Copy in the user's SG buffer if necessary */
- if (sg[i].
- flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) {
- // TODO 64bit fix
- if (copy_from_user
- (p->virt,
- (void __user *)(unsigned long)sg[i].
- addr_bus, sg_size)) {
- printk(KERN_DEBUG
- "%s: Could not copy SG buf %d FROM user\n",
- c->name, i);
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
- }
- //TODO 64bit fix
- sg[i].addr_bus = (u32) p->phys;
- }
- }
-
- rcode = i2o_msg_post_wait(c, msg, 60);
- msg = NULL;
- if (rcode) {
- reply[4] = ((u32) rcode) << 24;
- goto sg_list_cleanup;
- }
-
- if (sg_offset) {
- u32 rmsg[I2O_OUTBOUND_MSG_FRAME_SIZE];
- /* Copy back the Scatter Gather buffers back to user space */
- u32 j;
- // TODO 64bit fix
- struct sg_simple_element *sg;
- int sg_size;
-
- // re-acquire the original message to handle correctly the sg copy operation
- memset(&rmsg, 0, I2O_OUTBOUND_MSG_FRAME_SIZE * 4);
- // get user msg size in u32s
- if (get_user(size, &user_msg[0])) {
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
- size = size >> 16;
- size *= 4;
- if (size > sizeof(rmsg)) {
- rcode = -EINVAL;
- goto sg_list_cleanup;
- }
-
- /* Copy in the user's I2O command */
- if (copy_from_user(rmsg, user_msg, size)) {
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
- sg_count =
- (size - sg_offset * 4) / sizeof(struct sg_simple_element);
-
- // TODO 64bit fix
- sg = (struct sg_simple_element *)(rmsg + sg_offset);
- for (j = 0; j < sg_count; j++) {
- /* Copy out the SG list to user's buffer if necessary */
- if (!
- (sg[j].
- flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR */ )) {
- sg_size = sg[j].flag_count & 0xffffff;
- // TODO 64bit fix
- if (copy_to_user
- ((void __user *)(u64) sg[j].addr_bus,
- sg_list[j].virt, sg_size)) {
- printk(KERN_WARNING
- "%s: Could not copy %p TO user %x\n",
- c->name, sg_list[j].virt,
- sg[j].addr_bus);
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
- }
- }
- }
-
-sg_list_cleanup:
- /* Copy back the reply to user space */
- if (reply_size) {
- // we wrote our own values for context - now restore the user supplied ones
- if (copy_from_user(reply + 2, user_msg + 2, sizeof(u32) * 2)) {
- printk(KERN_WARNING
- "%s: Could not copy message context FROM user\n",
- c->name);
- rcode = -EFAULT;
- }
- if (copy_to_user(user_reply, reply, reply_size)) {
- printk(KERN_WARNING
- "%s: Could not copy reply TO user\n", c->name);
- rcode = -EFAULT;
- }
- }
- for (i = 0; i < sg_index; i++)
- i2o_dma_free(&c->pdev->dev, &sg_list[i]);
-
-cleanup:
- kfree(reply);
-out:
- if (msg)
- i2o_msg_nop(c, msg);
- return rcode;
-}
-
-static long i2o_cfg_compat_ioctl(struct file *file, unsigned cmd,
- unsigned long arg)
-{
- int ret;
- switch (cmd) {
- case I2OGETIOPS:
- ret = i2o_cfg_ioctl(file, cmd, arg);
- break;
- case I2OPASSTHRU32:
- mutex_lock(&i2o_cfg_mutex);
- ret = i2o_cfg_passthru32(file, cmd, arg);
- mutex_unlock(&i2o_cfg_mutex);
- break;
- default:
- ret = -ENOIOCTLCMD;
- break;
- }
- return ret;
-}
-
-#endif
-
-#ifdef CONFIG_I2O_EXT_ADAPTEC
-static int i2o_cfg_passthru(unsigned long arg)
-{
- struct i2o_cmd_passthru __user *cmd =
- (struct i2o_cmd_passthru __user *)arg;
- struct i2o_controller *c;
- u32 __user *user_msg;
- u32 *reply = NULL;
- u32 __user *user_reply = NULL;
- u32 size = 0;
- u32 reply_size = 0;
- u32 rcode = 0;
- struct i2o_dma sg_list[SG_TABLESIZE];
- u32 sg_offset = 0;
- u32 sg_count = 0;
- int sg_index = 0;
- u32 i = 0;
- i2o_status_block *sb;
- struct i2o_message *msg;
- unsigned int iop;
-
- if (get_user(iop, &cmd->iop) || get_user(user_msg, &cmd->msg))
- return -EFAULT;
-
- c = i2o_find_iop(iop);
- if (!c) {
- osm_warn("controller %d not found\n", iop);
- return -ENXIO;
- }
-
- sb = c->status_block.virt;
-
- if (get_user(size, &user_msg[0]))
- return -EFAULT;
- size = size >> 16;
-
- if (size > sb->inbound_frame_size) {
- osm_warn("size of message > inbound_frame_size");
- return -EFAULT;
- }
-
- user_reply = &user_msg[size];
-
- size <<= 2; // Convert to bytes
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- rcode = -EFAULT;
- /* Copy in the user's I2O command */
- if (copy_from_user(msg, user_msg, size))
- goto out;
-
- if (get_user(reply_size, &user_reply[0]) < 0)
- goto out;
-
- reply_size >>= 16;
- reply_size <<= 2;
-
- reply = kzalloc(reply_size, GFP_KERNEL);
- if (!reply) {
- printk(KERN_WARNING "%s: Could not allocate reply buffer\n",
- c->name);
- rcode = -ENOMEM;
- goto out;
- }
-
- sg_offset = (msg->u.head[0] >> 4) & 0x0f;
-
- memset(sg_list, 0, sizeof(sg_list[0]) * SG_TABLESIZE);
- if (sg_offset) {
- struct sg_simple_element *sg;
- struct i2o_dma *p;
-
- if (sg_offset * 4 >= size) {
- rcode = -EFAULT;
- goto cleanup;
- }
- // TODO 64bit fix
- sg = (struct sg_simple_element *)((&msg->u.head[0]) +
- sg_offset);
- sg_count =
- (size - sg_offset * 4) / sizeof(struct sg_simple_element);
- if (sg_count > SG_TABLESIZE) {
- printk(KERN_DEBUG "%s:IOCTL SG List too large (%u)\n",
- c->name, sg_count);
- rcode = -EINVAL;
- goto cleanup;
- }
-
- for (i = 0; i < sg_count; i++) {
- int sg_size;
-
- if (!(sg[i].flag_count & 0x10000000
- /*I2O_SGL_FLAGS_SIMPLE_ADDRESS_ELEMENT */ )) {
- printk(KERN_DEBUG
- "%s:Bad SG element %d - not simple (%x)\n",
- c->name, i, sg[i].flag_count);
- rcode = -EINVAL;
- goto sg_list_cleanup;
- }
- sg_size = sg[i].flag_count & 0xffffff;
- p = &(sg_list[sg_index]);
- if (i2o_dma_alloc(&c->pdev->dev, p, sg_size)) {
- /* Allocate memory for the transfer */
- printk(KERN_DEBUG
- "%s: Could not allocate SG buffer - size = %d buffer number %d of %d\n",
- c->name, sg_size, i, sg_count);
- rcode = -ENOMEM;
- goto sg_list_cleanup;
- }
- sg_index++;
- /* Copy in the user's SG buffer if necessary */
- if (sg[i].
- flag_count & 0x04000000 /*I2O_SGL_FLAGS_DIR */ ) {
- // TODO 64bit fix
- if (copy_from_user
- (p->virt, (void __user *)sg[i].addr_bus,
- sg_size)) {
- printk(KERN_DEBUG
- "%s: Could not copy SG buf %d FROM user\n",
- c->name, i);
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
- }
- sg[i].addr_bus = p->phys;
- }
- }
-
- rcode = i2o_msg_post_wait(c, msg, 60);
- msg = NULL;
- if (rcode) {
- reply[4] = ((u32) rcode) << 24;
- goto sg_list_cleanup;
- }
-
- if (sg_offset) {
- u32 rmsg[I2O_OUTBOUND_MSG_FRAME_SIZE];
- /* Copy back the Scatter Gather buffers back to user space */
- u32 j;
- // TODO 64bit fix
- struct sg_simple_element *sg;
- int sg_size;
-
- // re-acquire the original message to handle correctly the sg copy operation
- memset(&rmsg, 0, I2O_OUTBOUND_MSG_FRAME_SIZE * 4);
- // get user msg size in u32s
- if (get_user(size, &user_msg[0])) {
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
- size = size >> 16;
- size *= 4;
- if (size > sizeof(rmsg)) {
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
-
- /* Copy in the user's I2O command */
- if (copy_from_user(rmsg, user_msg, size)) {
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
- sg_count =
- (size - sg_offset * 4) / sizeof(struct sg_simple_element);
-
- // TODO 64bit fix
- sg = (struct sg_simple_element *)(rmsg + sg_offset);
- for (j = 0; j < sg_count; j++) {
- /* Copy out the SG list to user's buffer if necessary */
- if (!
- (sg[j].
- flag_count & 0x4000000 /*I2O_SGL_FLAGS_DIR */ )) {
- sg_size = sg[j].flag_count & 0xffffff;
- // TODO 64bit fix
- if (copy_to_user
- ((void __user *)sg[j].addr_bus, sg_list[j].virt,
- sg_size)) {
- printk(KERN_WARNING
- "%s: Could not copy %p TO user %x\n",
- c->name, sg_list[j].virt,
- sg[j].addr_bus);
- rcode = -EFAULT;
- goto sg_list_cleanup;
- }
- }
- }
- }
-
-sg_list_cleanup:
- /* Copy back the reply to user space */
- if (reply_size) {
- // we wrote our own values for context - now restore the user supplied ones
- if (copy_from_user(reply + 2, user_msg + 2, sizeof(u32) * 2)) {
- printk(KERN_WARNING
- "%s: Could not copy message context FROM user\n",
- c->name);
- rcode = -EFAULT;
- }
- if (copy_to_user(user_reply, reply, reply_size)) {
- printk(KERN_WARNING
- "%s: Could not copy reply TO user\n", c->name);
- rcode = -EFAULT;
- }
- }
-
- for (i = 0; i < sg_index; i++)
- i2o_dma_free(&c->pdev->dev, &sg_list[i]);
-
-cleanup:
- kfree(reply);
-out:
- if (msg)
- i2o_msg_nop(c, msg);
- return rcode;
-}
-#endif
-
-/*
- * IOCTL Handler
- */
-static long i2o_cfg_ioctl(struct file *fp, unsigned int cmd, unsigned long arg)
-{
- int ret;
-
- mutex_lock(&i2o_cfg_mutex);
- switch (cmd) {
- case I2OGETIOPS:
- ret = i2o_cfg_getiops(arg);
- break;
-
- case I2OHRTGET:
- ret = i2o_cfg_gethrt(arg);
- break;
-
- case I2OLCTGET:
- ret = i2o_cfg_getlct(arg);
- break;
-
- case I2OPARMSET:
- ret = i2o_cfg_parms(arg, I2OPARMSET);
- break;
-
- case I2OPARMGET:
- ret = i2o_cfg_parms(arg, I2OPARMGET);
- break;
-
- case I2OSWDL:
- ret = i2o_cfg_swdl(arg);
- break;
-
- case I2OSWUL:
- ret = i2o_cfg_swul(arg);
- break;
-
- case I2OSWDEL:
- ret = i2o_cfg_swdel(arg);
- break;
-
- case I2OVALIDATE:
- ret = i2o_cfg_validate(arg);
- break;
-
- case I2OEVTREG:
- ret = i2o_cfg_evt_reg(arg, fp);
- break;
-
- case I2OEVTGET:
- ret = i2o_cfg_evt_get(arg, fp);
- break;
-
-#ifdef CONFIG_I2O_EXT_ADAPTEC
- case I2OPASSTHRU:
- ret = i2o_cfg_passthru(arg);
- break;
-#endif
-
- default:
- osm_debug("unknown ioctl called!\n");
- ret = -EINVAL;
- }
- mutex_unlock(&i2o_cfg_mutex);
- return ret;
-}
-
-static int cfg_open(struct inode *inode, struct file *file)
-{
- struct i2o_cfg_info *tmp = kmalloc(sizeof(struct i2o_cfg_info),
- GFP_KERNEL);
- unsigned long flags;
-
- if (!tmp)
- return -ENOMEM;
-
- mutex_lock(&i2o_cfg_mutex);
- file->private_data = (void *)(i2o_cfg_info_id++);
- tmp->fp = file;
- tmp->fasync = NULL;
- tmp->q_id = (ulong) file->private_data;
- tmp->q_len = 0;
- tmp->q_in = 0;
- tmp->q_out = 0;
- tmp->q_lost = 0;
- tmp->next = open_files;
-
- spin_lock_irqsave(&i2o_config_lock, flags);
- open_files = tmp;
- spin_unlock_irqrestore(&i2o_config_lock, flags);
- mutex_unlock(&i2o_cfg_mutex);
-
- return 0;
-}
-
-static int cfg_fasync(int fd, struct file *fp, int on)
-{
- ulong id = (ulong) fp->private_data;
- struct i2o_cfg_info *p;
- int ret = -EBADF;
-
- mutex_lock(&i2o_cfg_mutex);
- for (p = open_files; p; p = p->next)
- if (p->q_id == id)
- break;
-
- if (p)
- ret = fasync_helper(fd, fp, on, &p->fasync);
- mutex_unlock(&i2o_cfg_mutex);
- return ret;
-}
-
-static int cfg_release(struct inode *inode, struct file *file)
-{
- ulong id = (ulong) file->private_data;
- struct i2o_cfg_info *p, **q;
- unsigned long flags;
-
- mutex_lock(&i2o_cfg_mutex);
- spin_lock_irqsave(&i2o_config_lock, flags);
- for (q = &open_files; (p = *q) != NULL; q = &p->next) {
- if (p->q_id == id) {
- *q = p->next;
- kfree(p);
- break;
- }
- }
- spin_unlock_irqrestore(&i2o_config_lock, flags);
- mutex_unlock(&i2o_cfg_mutex);
-
- return 0;
-}
-
-static const struct file_operations config_fops = {
- .owner = THIS_MODULE,
- .llseek = no_llseek,
- .unlocked_ioctl = i2o_cfg_ioctl,
-#ifdef CONFIG_COMPAT
- .compat_ioctl = i2o_cfg_compat_ioctl,
-#endif
- .open = cfg_open,
- .release = cfg_release,
- .fasync = cfg_fasync,
-};
-
-static struct miscdevice i2o_miscdev = {
- I2O_MINOR,
- "i2octl",
- &config_fops
-};
-
-static int __init i2o_config_old_init(void)
-{
- spin_lock_init(&i2o_config_lock);
-
- if (misc_register(&i2o_miscdev) < 0) {
- osm_err("can't register device.\n");
- return -EBUSY;
- }
-
- return 0;
-}
-
-static void i2o_config_old_exit(void)
-{
- misc_deregister(&i2o_miscdev);
-}
-
-MODULE_AUTHOR("Red Hat Software");
diff --git a/drivers/staging/i2o/i2o_proc.c b/drivers/staging/i2o/i2o_proc.c
deleted file mode 100644
index 780fee3224ead8..00000000000000
--- a/drivers/staging/i2o/i2o_proc.c
+++ /dev/null
@@ -1,2049 +0,0 @@
-/*
- * procfs handler for Linux I2O subsystem
- *
- * (c) Copyright 1999 Deepak Saxena
- *
- * Originally written by Deepak Saxena(deepak@plexity.net)
- *
- * 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 is an initial test release. The code is based on the design of the
- * ide procfs system (drivers/block/ide-proc.c). Some code taken from
- * i2o-core module by Alan Cox.
- *
- * DISCLAIMER: This code is still under development/test and may cause
- * your system to behave unpredictably. Use at your own discretion.
- *
- *
- * Fixes/additions:
- * Juha Sievänen (Juha.Sievanen@cs.Helsinki.FI),
- * Auvo Häkkinen (Auvo.Hakkinen@cs.Helsinki.FI)
- * University of Helsinki, Department of Computer Science
- * LAN entries
- * Markus Lidel <Markus.Lidel@shadowconnect.com>
- * Changes for new I2O API
- */
-
-#define OSM_NAME "proc-osm"
-#define OSM_VERSION "1.316"
-#define OSM_DESCRIPTION "I2O ProcFS OSM"
-
-#define I2O_MAX_MODULES 4
-// FIXME!
-#define FMT_U64_HEX "0x%08x%08x"
-#define U64_VAL(pu64) *((u32*)(pu64)+1), *((u32*)(pu64))
-
-#include <linux/types.h>
-#include <linux/kernel.h>
-#include <linux/pci.h>
-#include "i2o.h"
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
-#include <linux/seq_file.h>
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/errno.h>
-#include <linux/spinlock.h>
-#include <linux/workqueue.h>
-#include <linux/uaccess.h>
-
-#include <asm/io.h>
-#include <asm/byteorder.h>
-
-/* Structure used to define /proc entries */
-typedef struct _i2o_proc_entry_t {
- char *name; /* entry name */
- umode_t mode; /* mode */
- const struct file_operations *fops; /* open function */
-} i2o_proc_entry;
-
-/* global I2O /proc/i2o entry */
-static struct proc_dir_entry *i2o_proc_dir_root;
-
-/* proc OSM driver struct */
-static struct i2o_driver i2o_proc_driver = {
- .name = OSM_NAME,
-};
-
-static int print_serial_number(struct seq_file *seq, u8 * serialno, int max_len)
-{
- int i;
-
- /* 19990419 -sralston
- * The I2O v1.5 (and v2.0 so far) "official specification"
- * got serial numbers WRONG!
- * Apparently, and despite what Section 3.4.4 says and
- * Figure 3-35 shows (pg 3-39 in the pdf doc),
- * the convention / consensus seems to be:
- * + First byte is SNFormat
- * + Second byte is SNLen (but only if SNFormat==7 (?))
- * + (v2.0) SCSI+BS may use IEEE Registered (64 or 128 bit) format
- */
- switch (serialno[0]) {
- case I2O_SNFORMAT_BINARY: /* Binary */
- seq_printf(seq, "0x");
- for (i = 0; i < serialno[1]; i++)
- seq_printf(seq, "%02X", serialno[2 + i]);
- break;
-
- case I2O_SNFORMAT_ASCII: /* ASCII */
- if (serialno[1] < ' ') { /* printable or SNLen? */
- /* sanity */
- max_len =
- (max_len < serialno[1]) ? max_len : serialno[1];
- serialno[1 + max_len] = '\0';
-
- /* just print it */
- seq_printf(seq, "%s", &serialno[2]);
- } else {
- /* print chars for specified length */
- for (i = 0; i < serialno[1]; i++)
- seq_printf(seq, "%c", serialno[2 + i]);
- }
- break;
-
- case I2O_SNFORMAT_UNICODE: /* UNICODE */
- seq_printf(seq, "UNICODE Format. Can't Display\n");
- break;
-
- case I2O_SNFORMAT_LAN48_MAC: /* LAN-48 MAC Address */
- seq_printf(seq, "LAN-48 MAC address @ %pM", &serialno[2]);
- break;
-
- case I2O_SNFORMAT_WAN: /* WAN MAC Address */
- /* FIXME: Figure out what a WAN access address looks like?? */
- seq_printf(seq, "WAN Access Address");
- break;
-
-/* plus new in v2.0 */
- case I2O_SNFORMAT_LAN64_MAC: /* LAN-64 MAC Address */
- /* FIXME: Figure out what a LAN-64 address really looks like?? */
- seq_printf(seq,
- "LAN-64 MAC address @ [?:%02X:%02X:?] %pM",
- serialno[8], serialno[9], &serialno[2]);
- break;
-
- case I2O_SNFORMAT_DDM: /* I2O DDM */
- seq_printf(seq,
- "DDM: Tid=%03Xh, Rsvd=%04Xh, OrgId=%04Xh",
- *(u16 *) & serialno[2],
- *(u16 *) & serialno[4], *(u16 *) & serialno[6]);
- break;
-
- case I2O_SNFORMAT_IEEE_REG64: /* IEEE Registered (64-bit) */
- case I2O_SNFORMAT_IEEE_REG128: /* IEEE Registered (128-bit) */
- /* FIXME: Figure if this is even close?? */
- seq_printf(seq,
- "IEEE NodeName(hi,lo)=(%08Xh:%08Xh), PortName(hi,lo)=(%08Xh:%08Xh)\n",
- *(u32 *) & serialno[2],
- *(u32 *) & serialno[6],
- *(u32 *) & serialno[10], *(u32 *) & serialno[14]);
- break;
-
- case I2O_SNFORMAT_UNKNOWN: /* Unknown 0 */
- case I2O_SNFORMAT_UNKNOWN2: /* Unknown 0xff */
- default:
- seq_printf(seq, "Unknown data format (0x%02x)", serialno[0]);
- break;
- }
-
- return 0;
-}
-
-/**
- * i2o_get_class_name - do i2o class name lookup
- * @class: class number
- *
- * Return a descriptive string for an i2o class.
- */
-static const char *i2o_get_class_name(int class)
-{
- int idx = 16;
- static char *i2o_class_name[] = {
- "Executive",
- "Device Driver Module",
- "Block Device",
- "Tape Device",
- "LAN Interface",
- "WAN Interface",
- "Fibre Channel Port",
- "Fibre Channel Device",
- "SCSI Device",
- "ATE Port",
- "ATE Device",
- "Floppy Controller",
- "Floppy Device",
- "Secondary Bus Port",
- "Peer Transport Agent",
- "Peer Transport",
- "Unknown"
- };
-
- switch (class & 0xfff) {
- case I2O_CLASS_EXECUTIVE:
- idx = 0;
- break;
- case I2O_CLASS_DDM:
- idx = 1;
- break;
- case I2O_CLASS_RANDOM_BLOCK_STORAGE:
- idx = 2;
- break;
- case I2O_CLASS_SEQUENTIAL_STORAGE:
- idx = 3;
- break;
- case I2O_CLASS_LAN:
- idx = 4;
- break;
- case I2O_CLASS_WAN:
- idx = 5;
- break;
- case I2O_CLASS_FIBRE_CHANNEL_PORT:
- idx = 6;
- break;
- case I2O_CLASS_FIBRE_CHANNEL_PERIPHERAL:
- idx = 7;
- break;
- case I2O_CLASS_SCSI_PERIPHERAL:
- idx = 8;
- break;
- case I2O_CLASS_ATE_PORT:
- idx = 9;
- break;
- case I2O_CLASS_ATE_PERIPHERAL:
- idx = 10;
- break;
- case I2O_CLASS_FLOPPY_CONTROLLER:
- idx = 11;
- break;
- case I2O_CLASS_FLOPPY_DEVICE:
- idx = 12;
- break;
- case I2O_CLASS_BUS_ADAPTER:
- idx = 13;
- break;
- case I2O_CLASS_PEER_TRANSPORT_AGENT:
- idx = 14;
- break;
- case I2O_CLASS_PEER_TRANSPORT:
- idx = 15;
- break;
- }
-
- return i2o_class_name[idx];
-}
-
-#define SCSI_TABLE_SIZE 13
-static char *scsi_devices[] = {
- "Direct-Access Read/Write",
- "Sequential-Access Storage",
- "Printer",
- "Processor",
- "WORM Device",
- "CD-ROM Device",
- "Scanner Device",
- "Optical Memory Device",
- "Medium Changer Device",
- "Communications Device",
- "Graphics Art Pre-Press Device",
- "Graphics Art Pre-Press Device",
- "Array Controller Device"
-};
-
-static char *chtostr(char *tmp, u8 *chars, int n)
-{
- tmp[0] = 0;
- return strncat(tmp, (char *)chars, n);
-}
-
-static int i2o_report_query_status(struct seq_file *seq, int block_status,
- char *group)
-{
- switch (block_status) {
- case -ETIMEDOUT:
- seq_printf(seq, "Timeout reading group %s.\n", group);
- break;
- case -ENOMEM:
- seq_puts(seq, "No free memory to read the table.\n");
- break;
- case -I2O_PARAMS_STATUS_INVALID_GROUP_ID:
- seq_printf(seq, "Group %s not supported.\n", group);
- break;
- default:
- seq_printf(seq,
- "Error reading group %s. BlockStatus 0x%02X\n",
- group, -block_status);
- break;
- }
-
- return 0;
-}
-
-static char *bus_strings[] = {
- "Local Bus",
- "ISA",
- "EISA",
- "PCI",
- "PCMCIA",
- "NUBUS",
- "CARDBUS"
-};
-
-static int i2o_seq_show_hrt(struct seq_file *seq, void *v)
-{
- struct i2o_controller *c = (struct i2o_controller *)seq->private;
- i2o_hrt *hrt = (i2o_hrt *) c->hrt.virt;
- u32 bus;
- int i;
-
- if (hrt->hrt_version) {
- seq_printf(seq,
- "HRT table for controller is too new a version.\n");
- return 0;
- }
-
- seq_printf(seq, "HRT has %d entries of %d bytes each.\n",
- hrt->num_entries, hrt->entry_len << 2);
-
- for (i = 0; i < hrt->num_entries; i++) {
- seq_printf(seq, "Entry %d:\n", i);
- seq_printf(seq, " Adapter ID: %0#10x\n",
- hrt->hrt_entry[i].adapter_id);
- seq_printf(seq, " Controlling tid: %0#6x\n",
- hrt->hrt_entry[i].parent_tid);
-
- if (hrt->hrt_entry[i].bus_type != 0x80) {
- bus = hrt->hrt_entry[i].bus_type;
- seq_printf(seq, " %s Information\n",
- bus_strings[bus]);
-
- switch (bus) {
- case I2O_BUS_LOCAL:
- seq_printf(seq, " IOBase: %0#6x,",
- hrt->hrt_entry[i].bus.local_bus.
- LbBaseIOPort);
- seq_printf(seq, " MemoryBase: %0#10x\n",
- hrt->hrt_entry[i].bus.local_bus.
- LbBaseMemoryAddress);
- break;
-
- case I2O_BUS_ISA:
- seq_printf(seq, " IOBase: %0#6x,",
- hrt->hrt_entry[i].bus.isa_bus.
- IsaBaseIOPort);
- seq_printf(seq, " MemoryBase: %0#10x,",
- hrt->hrt_entry[i].bus.isa_bus.
- IsaBaseMemoryAddress);
- seq_printf(seq, " CSN: %0#4x,",
- hrt->hrt_entry[i].bus.isa_bus.CSN);
- break;
-
- case I2O_BUS_EISA:
- seq_printf(seq, " IOBase: %0#6x,",
- hrt->hrt_entry[i].bus.eisa_bus.
- EisaBaseIOPort);
- seq_printf(seq, " MemoryBase: %0#10x,",
- hrt->hrt_entry[i].bus.eisa_bus.
- EisaBaseMemoryAddress);
- seq_printf(seq, " Slot: %0#4x,",
- hrt->hrt_entry[i].bus.eisa_bus.
- EisaSlotNumber);
- break;
-
- case I2O_BUS_PCI:
- seq_printf(seq, " Bus: %0#4x",
- hrt->hrt_entry[i].bus.pci_bus.
- PciBusNumber);
- seq_printf(seq, " Dev: %0#4x",
- hrt->hrt_entry[i].bus.pci_bus.
- PciDeviceNumber);
- seq_printf(seq, " Func: %0#4x",
- hrt->hrt_entry[i].bus.pci_bus.
- PciFunctionNumber);
- seq_printf(seq, " Vendor: %0#6x",
- hrt->hrt_entry[i].bus.pci_bus.
- PciVendorID);
- seq_printf(seq, " Device: %0#6x\n",
- hrt->hrt_entry[i].bus.pci_bus.
- PciDeviceID);
- break;
-
- default:
- seq_printf(seq, " Unsupported Bus Type\n");
- }
- } else
- seq_printf(seq, " Unknown Bus Type\n");
- }
-
- return 0;
-}
-
-static int i2o_seq_show_lct(struct seq_file *seq, void *v)
-{
- struct i2o_controller *c = (struct i2o_controller *)seq->private;
- i2o_lct *lct = (i2o_lct *) c->lct;
- int entries;
- int i;
-
-#define BUS_TABLE_SIZE 3
- static char *bus_ports[] = {
- "Generic Bus",
- "SCSI Bus",
- "Fibre Channel Bus"
- };
-
- entries = (lct->table_size - 3) / 9;
-
- seq_printf(seq, "LCT contains %d %s\n", entries,
- entries == 1 ? "entry" : "entries");
- if (lct->boot_tid)
- seq_printf(seq, "Boot Device @ ID %d\n", lct->boot_tid);
-
- seq_printf(seq, "Current Change Indicator: %#10x\n", lct->change_ind);
-
- for (i = 0; i < entries; i++) {
- seq_printf(seq, "Entry %d\n", i);
- seq_printf(seq, " Class, SubClass : %s",
- i2o_get_class_name(lct->lct_entry[i].class_id));
-
- /*
- * Classes which we'll print subclass info for
- */
- switch (lct->lct_entry[i].class_id & 0xFFF) {
- case I2O_CLASS_RANDOM_BLOCK_STORAGE:
- switch (lct->lct_entry[i].sub_class) {
- case 0x00:
- seq_printf(seq, ", Direct-Access Read/Write");
- break;
-
- case 0x04:
- seq_printf(seq, ", WORM Drive");
- break;
-
- case 0x05:
- seq_printf(seq, ", CD-ROM Drive");
- break;
-
- case 0x07:
- seq_printf(seq, ", Optical Memory Device");
- break;
-
- default:
- seq_printf(seq, ", Unknown (0x%02x)",
- lct->lct_entry[i].sub_class);
- break;
- }
- break;
-
- case I2O_CLASS_LAN:
- switch (lct->lct_entry[i].sub_class & 0xFF) {
- case 0x30:
- seq_printf(seq, ", Ethernet");
- break;
-
- case 0x40:
- seq_printf(seq, ", 100base VG");
- break;
-
- case 0x50:
- seq_printf(seq, ", IEEE 802.5/Token-Ring");
- break;
-
- case 0x60:
- seq_printf(seq, ", ANSI X3T9.5 FDDI");
- break;
-
- case 0x70:
- seq_printf(seq, ", Fibre Channel");
- break;
-
- default:
- seq_printf(seq, ", Unknown Sub-Class (0x%02x)",
- lct->lct_entry[i].sub_class & 0xFF);
- break;
- }
- break;
-
- case I2O_CLASS_SCSI_PERIPHERAL:
- if (lct->lct_entry[i].sub_class < SCSI_TABLE_SIZE)
- seq_printf(seq, ", %s",
- scsi_devices[lct->lct_entry[i].
- sub_class]);
- else
- seq_printf(seq, ", Unknown Device Type");
- break;
-
- case I2O_CLASS_BUS_ADAPTER:
- if (lct->lct_entry[i].sub_class < BUS_TABLE_SIZE)
- seq_printf(seq, ", %s",
- bus_ports[lct->lct_entry[i].
- sub_class]);
- else
- seq_printf(seq, ", Unknown Bus Type");
- break;
- }
- seq_printf(seq, "\n");
-
- seq_printf(seq, " Local TID : 0x%03x\n",
- lct->lct_entry[i].tid);
- seq_printf(seq, " User TID : 0x%03x\n",
- lct->lct_entry[i].user_tid);
- seq_printf(seq, " Parent TID : 0x%03x\n",
- lct->lct_entry[i].parent_tid);
- seq_printf(seq, " Identity Tag : 0x%x%x%x%x%x%x%x%x\n",
- lct->lct_entry[i].identity_tag[0],
- lct->lct_entry[i].identity_tag[1],
- lct->lct_entry[i].identity_tag[2],
- lct->lct_entry[i].identity_tag[3],
- lct->lct_entry[i].identity_tag[4],
- lct->lct_entry[i].identity_tag[5],
- lct->lct_entry[i].identity_tag[6],
- lct->lct_entry[i].identity_tag[7]);
- seq_printf(seq, " Change Indicator : %0#10x\n",
- lct->lct_entry[i].change_ind);
- seq_printf(seq, " Event Capab Mask : %0#10x\n",
- lct->lct_entry[i].device_flags);
- }
-
- return 0;
-}
-
-static int i2o_seq_show_status(struct seq_file *seq, void *v)
-{
- struct i2o_controller *c = (struct i2o_controller *)seq->private;
- char prodstr[25];
- int version;
- i2o_status_block *sb = c->status_block.virt;
-
- i2o_status_get(c); // reread the status block
-
- seq_printf(seq, "Organization ID : %0#6x\n", sb->org_id);
-
- version = sb->i2o_version;
-
-/* FIXME for Spec 2.0
- if (version == 0x02) {
- seq_printf(seq, "Lowest I2O version supported: ");
- switch(workspace[2]) {
- case 0x00:
- seq_printf(seq, "1.0\n");
- break;
- case 0x01:
- seq_printf(seq, "1.5\n");
- break;
- case 0x02:
- seq_printf(seq, "2.0\n");
- break;
- }
-
- seq_printf(seq, "Highest I2O version supported: ");
- switch(workspace[3]) {
- case 0x00:
- seq_printf(seq, "1.0\n");
- break;
- case 0x01:
- seq_printf(seq, "1.5\n");
- break;
- case 0x02:
- seq_printf(seq, "2.0\n");
- break;
- }
- }
-*/
- seq_printf(seq, "IOP ID : %0#5x\n", sb->iop_id);
- seq_printf(seq, "Host Unit ID : %0#6x\n", sb->host_unit_id);
- seq_printf(seq, "Segment Number : %0#5x\n", sb->segment_number);
-
- seq_printf(seq, "I2O version : ");
- switch (version) {
- case 0x00:
- seq_printf(seq, "1.0\n");
- break;
- case 0x01:
- seq_printf(seq, "1.5\n");
- break;
- case 0x02:
- seq_printf(seq, "2.0\n");
- break;
- default:
- seq_printf(seq, "Unknown version\n");
- }
-
- seq_printf(seq, "IOP State : ");
- switch (sb->iop_state) {
- case 0x01:
- seq_printf(seq, "INIT\n");
- break;
-
- case 0x02:
- seq_printf(seq, "RESET\n");
- break;
-
- case 0x04:
- seq_printf(seq, "HOLD\n");
- break;
-
- case 0x05:
- seq_printf(seq, "READY\n");
- break;
-
- case 0x08:
- seq_printf(seq, "OPERATIONAL\n");
- break;
-
- case 0x10:
- seq_printf(seq, "FAILED\n");
- break;
-
- case 0x11:
- seq_printf(seq, "FAULTED\n");
- break;
-
- default:
- seq_printf(seq, "Unknown\n");
- break;
- }
-
- seq_printf(seq, "Messenger Type : ");
- switch (sb->msg_type) {
- case 0x00:
- seq_printf(seq, "Memory mapped\n");
- break;
- case 0x01:
- seq_printf(seq, "Memory mapped only\n");
- break;
- case 0x02:
- seq_printf(seq, "Remote only\n");
- break;
- case 0x03:
- seq_printf(seq, "Memory mapped and remote\n");
- break;
- default:
- seq_printf(seq, "Unknown\n");
- }
-
- seq_printf(seq, "Inbound Frame Size : %d bytes\n",
- sb->inbound_frame_size << 2);
- seq_printf(seq, "Max Inbound Frames : %d\n",
- sb->max_inbound_frames);
- seq_printf(seq, "Current Inbound Frames : %d\n",
- sb->cur_inbound_frames);
- seq_printf(seq, "Max Outbound Frames : %d\n",
- sb->max_outbound_frames);
-
- /* Spec doesn't say if NULL terminated or not... */
- memcpy(prodstr, sb->product_id, 24);
- prodstr[24] = '\0';
- seq_printf(seq, "Product ID : %s\n", prodstr);
- seq_printf(seq, "Expected LCT Size : %d bytes\n",
- sb->expected_lct_size);
-
- seq_printf(seq, "IOP Capabilities\n");
- seq_printf(seq, " Context Field Size Support : ");
- switch (sb->iop_capabilities & 0x0000003) {
- case 0:
- seq_printf(seq, "Supports only 32-bit context fields\n");
- break;
- case 1:
- seq_printf(seq, "Supports only 64-bit context fields\n");
- break;
- case 2:
- seq_printf(seq, "Supports 32-bit and 64-bit context fields, "
- "but not concurrently\n");
- break;
- case 3:
- seq_printf(seq, "Supports 32-bit and 64-bit context fields "
- "concurrently\n");
- break;
- default:
- seq_printf(seq, "0x%08x\n", sb->iop_capabilities);
- }
- seq_printf(seq, " Current Context Field Size : ");
- switch (sb->iop_capabilities & 0x0000000C) {
- case 0:
- seq_printf(seq, "not configured\n");
- break;
- case 4:
- seq_printf(seq, "Supports only 32-bit context fields\n");
- break;
- case 8:
- seq_printf(seq, "Supports only 64-bit context fields\n");
- break;
- case 12:
- seq_printf(seq, "Supports both 32-bit or 64-bit context fields "
- "concurrently\n");
- break;
- default:
- seq_printf(seq, "\n");
- }
- seq_printf(seq, " Inbound Peer Support : %s\n",
- (sb->
- iop_capabilities & 0x00000010) ? "Supported" :
- "Not supported");
- seq_printf(seq, " Outbound Peer Support : %s\n",
- (sb->
- iop_capabilities & 0x00000020) ? "Supported" :
- "Not supported");
- seq_printf(seq, " Peer to Peer Support : %s\n",
- (sb->
- iop_capabilities & 0x00000040) ? "Supported" :
- "Not supported");
-
- seq_printf(seq, "Desired private memory size : %d kB\n",
- sb->desired_mem_size >> 10);
- seq_printf(seq, "Allocated private memory size : %d kB\n",
- sb->current_mem_size >> 10);
- seq_printf(seq, "Private memory base address : %0#10x\n",
- sb->current_mem_base);
- seq_printf(seq, "Desired private I/O size : %d kB\n",
- sb->desired_io_size >> 10);
- seq_printf(seq, "Allocated private I/O size : %d kB\n",
- sb->current_io_size >> 10);
- seq_printf(seq, "Private I/O base address : %0#10x\n",
- sb->current_io_base);
-
- return 0;
-}
-
-static int i2o_seq_show_hw(struct seq_file *seq, void *v)
-{
- struct i2o_controller *c = (struct i2o_controller *)seq->private;
- static u32 work32[5];
- static u8 *work8 = (u8 *) work32;
- static u16 *work16 = (u16 *) work32;
- int token;
- u32 hwcap;
-
- static char *cpu_table[] = {
- "Intel 80960 series",
- "AMD2900 series",
- "Motorola 68000 series",
- "ARM series",
- "MIPS series",
- "Sparc series",
- "PowerPC series",
- "Intel x86 series"
- };
-
- token =
- i2o_parm_field_get(c->exec, 0x0000, -1, &work32, sizeof(work32));
-
- if (token < 0) {
- i2o_report_query_status(seq, token, "0x0000 IOP Hardware");
- return 0;
- }
-
- seq_printf(seq, "I2O Vendor ID : %0#6x\n", work16[0]);
- seq_printf(seq, "Product ID : %0#6x\n", work16[1]);
- seq_printf(seq, "CPU : ");
- if (work8[16] > 8)
- seq_printf(seq, "Unknown\n");
- else
- seq_printf(seq, "%s\n", cpu_table[work8[16]]);
- /* Anyone using ProcessorVersion? */
-
- seq_printf(seq, "RAM : %dkB\n", work32[1] >> 10);
- seq_printf(seq, "Non-Volatile Mem : %dkB\n", work32[2] >> 10);
-
- hwcap = work32[3];
- seq_printf(seq, "Capabilities : 0x%08x\n", hwcap);
- seq_printf(seq, " [%s] Self booting\n",
- (hwcap & 0x00000001) ? "+" : "-");
- seq_printf(seq, " [%s] Upgradable IRTOS\n",
- (hwcap & 0x00000002) ? "+" : "-");
- seq_printf(seq, " [%s] Supports downloading DDMs\n",
- (hwcap & 0x00000004) ? "+" : "-");
- seq_printf(seq, " [%s] Supports installing DDMs\n",
- (hwcap & 0x00000008) ? "+" : "-");
- seq_printf(seq, " [%s] Battery-backed RAM\n",
- (hwcap & 0x00000010) ? "+" : "-");
-
- return 0;
-}
-
-/* Executive group 0003h - Executing DDM List (table) */
-static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
-{
- struct i2o_controller *c = (struct i2o_controller *)seq->private;
- int token;
- int i;
-
- typedef struct _i2o_exec_execute_ddm_table {
- u16 ddm_tid;
- u8 module_type;
- u8 reserved;
- u16 i2o_vendor_id;
- u16 module_id;
- u8 module_name_version[28];
- u32 data_size;
- u32 code_size;
- } i2o_exec_execute_ddm_table;
-
- struct {
- u16 result_count;
- u16 pad;
- u16 block_size;
- u8 block_status;
- u8 error_info_size;
- u16 row_count;
- u16 more_flag;
- i2o_exec_execute_ddm_table ddm_table[I2O_MAX_MODULES];
- } *result;
-
- i2o_exec_execute_ddm_table ddm_table;
- char tmp[28 + 1];
-
- result = kmalloc(sizeof(*result), GFP_KERNEL);
- if (!result)
- return -ENOMEM;
-
- token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0003, -1,
- NULL, 0, result, sizeof(*result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token,
- "0x0003 Executing DDM List");
- goto out;
- }
-
- seq_printf(seq,
- "Tid Module_type Vendor Mod_id Module_name Vrs Data_size Code_size\n");
- ddm_table = result->ddm_table[0];
-
- for (i = 0; i < result->row_count; ddm_table = result->ddm_table[++i]) {
- seq_printf(seq, "0x%03x ", ddm_table.ddm_tid & 0xFFF);
-
- switch (ddm_table.module_type) {
- case 0x01:
- seq_printf(seq, "Downloaded DDM ");
- break;
- case 0x22:
- seq_printf(seq, "Embedded DDM ");
- break;
- default:
- seq_printf(seq, " ");
- }
-
- seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
- seq_printf(seq, "%-#8x", ddm_table.module_id);
- seq_printf(seq, "%-29s",
- chtostr(tmp, ddm_table.module_name_version, 28));
- seq_printf(seq, "%9d ", ddm_table.data_size);
- seq_printf(seq, "%8d", ddm_table.code_size);
-
- seq_printf(seq, "\n");
- }
- out:
- kfree(result);
- return 0;
-}
-
-/* Executive group 0004h - Driver Store (scalar) */
-static int i2o_seq_show_driver_store(struct seq_file *seq, void *v)
-{
- struct i2o_controller *c = (struct i2o_controller *)seq->private;
- u32 work32[8];
- int token;
-
- token =
- i2o_parm_field_get(c->exec, 0x0004, -1, &work32, sizeof(work32));
- if (token < 0) {
- i2o_report_query_status(seq, token, "0x0004 Driver Store");
- return 0;
- }
-
- seq_printf(seq, "Module limit : %d\n"
- "Module count : %d\n"
- "Current space : %d kB\n"
- "Free space : %d kB\n",
- work32[0], work32[1], work32[2] >> 10, work32[3] >> 10);
-
- return 0;
-}
-
-/* Executive group 0005h - Driver Store Table (table) */
-static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
-{
- typedef struct _i2o_driver_store {
- u16 stored_ddm_index;
- u8 module_type;
- u8 reserved;
- u16 i2o_vendor_id;
- u16 module_id;
- u8 module_name_version[28];
- u8 date[8];
- u32 module_size;
- u32 mpb_size;
- u32 module_flags;
- } i2o_driver_store_table;
-
- struct i2o_controller *c = (struct i2o_controller *)seq->private;
- int token;
- int i;
-
- typedef struct {
- u16 result_count;
- u16 pad;
- u16 block_size;
- u8 block_status;
- u8 error_info_size;
- u16 row_count;
- u16 more_flag;
- i2o_driver_store_table dst[I2O_MAX_MODULES];
- } i2o_driver_result_table;
-
- i2o_driver_result_table *result;
- i2o_driver_store_table *dst;
- char tmp[28 + 1];
-
- result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
- if (result == NULL)
- return -ENOMEM;
-
- token = i2o_parm_table_get(c->exec, I2O_PARAMS_TABLE_GET, 0x0005, -1,
- NULL, 0, result, sizeof(*result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token,
- "0x0005 DRIVER STORE TABLE");
- kfree(result);
- return 0;
- }
-
- seq_printf(seq,
- "# Module_type Vendor Mod_id Module_name Vrs"
- "Date Mod_size Par_size Flags\n");
- for (i = 0, dst = &result->dst[0]; i < result->row_count;
- dst = &result->dst[++i]) {
- seq_printf(seq, "%-3d", dst->stored_ddm_index);
- switch (dst->module_type) {
- case 0x01:
- seq_printf(seq, "Downloaded DDM ");
- break;
- case 0x22:
- seq_printf(seq, "Embedded DDM ");
- break;
- default:
- seq_printf(seq, " ");
- }
-
- seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
- seq_printf(seq, "%-#8x", dst->module_id);
- seq_printf(seq, "%-29s",
- chtostr(tmp, dst->module_name_version, 28));
- seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
- seq_printf(seq, "%8d ", dst->module_size);
- seq_printf(seq, "%8d ", dst->mpb_size);
- seq_printf(seq, "0x%04x", dst->module_flags);
- seq_printf(seq, "\n");
- }
-
- kfree(result);
- return 0;
-}
-
-/* Generic group F000h - Params Descriptor (table) */
-static int i2o_seq_show_groups(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
- int i;
- u8 properties;
-
- typedef struct _i2o_group_info {
- u16 group_number;
- u16 field_count;
- u16 row_count;
- u8 properties;
- u8 reserved;
- } i2o_group_info;
-
- struct {
- u16 result_count;
- u16 pad;
- u16 block_size;
- u8 block_status;
- u8 error_info_size;
- u16 row_count;
- u16 more_flag;
- i2o_group_info group[256];
- } *result;
-
- result = kmalloc(sizeof(*result), GFP_KERNEL);
- if (!result)
- return -ENOMEM;
-
- token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0,
- result, sizeof(*result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token, "0xF000 Params Descriptor");
- goto out;
- }
-
- seq_printf(seq,
- "# Group FieldCount RowCount Type Add Del Clear\n");
-
- for (i = 0; i < result->row_count; i++) {
- seq_printf(seq, "%-3d", i);
- seq_printf(seq, "0x%04X ", result->group[i].group_number);
- seq_printf(seq, "%10d ", result->group[i].field_count);
- seq_printf(seq, "%8d ", result->group[i].row_count);
-
- properties = result->group[i].properties;
- if (properties & 0x1)
- seq_printf(seq, "Table ");
- else
- seq_printf(seq, "Scalar ");
- if (properties & 0x2)
- seq_printf(seq, " + ");
- else
- seq_printf(seq, " - ");
- if (properties & 0x4)
- seq_printf(seq, " + ");
- else
- seq_printf(seq, " - ");
- if (properties & 0x8)
- seq_printf(seq, " + ");
- else
- seq_printf(seq, " - ");
-
- seq_printf(seq, "\n");
- }
-
- if (result->more_flag)
- seq_printf(seq, "There is more...\n");
- out:
- kfree(result);
- return 0;
-}
-
-/* Generic group F001h - Physical Device Table (table) */
-static int i2o_seq_show_phys_device(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
- int i;
-
- struct {
- u16 result_count;
- u16 pad;
- u16 block_size;
- u8 block_status;
- u8 error_info_size;
- u16 row_count;
- u16 more_flag;
- u32 adapter_id[64];
- } result;
-
- token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF001, -1, NULL, 0,
- &result, sizeof(result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token,
- "0xF001 Physical Device Table");
- return 0;
- }
-
- if (result.row_count)
- seq_printf(seq, "# AdapterId\n");
-
- for (i = 0; i < result.row_count; i++) {
- seq_printf(seq, "%-2d", i);
- seq_printf(seq, "%#7x\n", result.adapter_id[i]);
- }
-
- if (result.more_flag)
- seq_printf(seq, "There is more...\n");
-
- return 0;
-}
-
-/* Generic group F002h - Claimed Table (table) */
-static int i2o_seq_show_claimed(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
- int i;
-
- struct {
- u16 result_count;
- u16 pad;
- u16 block_size;
- u8 block_status;
- u8 error_info_size;
- u16 row_count;
- u16 more_flag;
- u16 claimed_tid[64];
- } result;
-
- token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF002, -1, NULL, 0,
- &result, sizeof(result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token, "0xF002 Claimed Table");
- return 0;
- }
-
- if (result.row_count)
- seq_printf(seq, "# ClaimedTid\n");
-
- for (i = 0; i < result.row_count; i++) {
- seq_printf(seq, "%-2d", i);
- seq_printf(seq, "%#7x\n", result.claimed_tid[i]);
- }
-
- if (result.more_flag)
- seq_printf(seq, "There is more...\n");
-
- return 0;
-}
-
-/* Generic group F003h - User Table (table) */
-static int i2o_seq_show_users(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
- int i;
-
- typedef struct _i2o_user_table {
- u16 instance;
- u16 user_tid;
- u8 claim_type;
- u8 reserved1;
- u16 reserved2;
- } i2o_user_table;
-
- struct {
- u16 result_count;
- u16 pad;
- u16 block_size;
- u8 block_status;
- u8 error_info_size;
- u16 row_count;
- u16 more_flag;
- i2o_user_table user[64];
- } *result;
-
- result = kmalloc(sizeof(*result), GFP_KERNEL);
- if (!result)
- return -ENOMEM;
-
- token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF003, -1, NULL, 0,
- result, sizeof(*result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token, "0xF003 User Table");
- goto out;
- }
-
- seq_printf(seq, "# Instance UserTid ClaimType\n");
-
- for (i = 0; i < result->row_count; i++) {
- seq_printf(seq, "%-3d", i);
- seq_printf(seq, "%#8x ", result->user[i].instance);
- seq_printf(seq, "%#7x ", result->user[i].user_tid);
- seq_printf(seq, "%#9x\n", result->user[i].claim_type);
- }
-
- if (result->more_flag)
- seq_printf(seq, "There is more...\n");
- out:
- kfree(result);
- return 0;
-}
-
-/* Generic group F005h - Private message extensions (table) (optional) */
-static int i2o_seq_show_priv_msgs(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
- int i;
-
- typedef struct _i2o_private {
- u16 ext_instance;
- u16 organization_id;
- u16 x_function_code;
- } i2o_private;
-
- struct {
- u16 result_count;
- u16 pad;
- u16 block_size;
- u8 block_status;
- u8 error_info_size;
- u16 row_count;
- u16 more_flag;
- i2o_private extension[64];
- } result;
-
- token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF000, -1, NULL, 0,
- &result, sizeof(result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token,
- "0xF005 Private Message Extensions (optional)");
- return 0;
- }
-
- seq_printf(seq, "Instance# OrgId FunctionCode\n");
-
- for (i = 0; i < result.row_count; i++) {
- seq_printf(seq, "%0#9x ", result.extension[i].ext_instance);
- seq_printf(seq, "%0#6x ", result.extension[i].organization_id);
- seq_printf(seq, "%0#6x", result.extension[i].x_function_code);
-
- seq_printf(seq, "\n");
- }
-
- if (result.more_flag)
- seq_printf(seq, "There is more...\n");
-
- return 0;
-}
-
-/* Generic group F006h - Authorized User Table (table) */
-static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
- int i;
-
- struct {
- u16 result_count;
- u16 pad;
- u16 block_size;
- u8 block_status;
- u8 error_info_size;
- u16 row_count;
- u16 more_flag;
- u32 alternate_tid[64];
- } result;
-
- token = i2o_parm_table_get(d, I2O_PARAMS_TABLE_GET, 0xF006, -1, NULL, 0,
- &result, sizeof(result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token,
- "0xF006 Autohorized User Table");
- return 0;
- }
-
- if (result.row_count)
- seq_printf(seq, "# AlternateTid\n");
-
- for (i = 0; i < result.row_count; i++) {
- seq_printf(seq, "%-2d", i);
- seq_printf(seq, "%#7x ", result.alternate_tid[i]);
- }
-
- if (result.more_flag)
- seq_printf(seq, "There is more...\n");
-
- return 0;
-}
-
-/* Generic group F100h - Device Identity (scalar) */
-static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
- // == (allow) 512d bytes (max)
- static u16 *work16 = (u16 *) work32;
- int token;
- char tmp[16 + 1];
-
- token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
-
- if (token < 0) {
- i2o_report_query_status(seq, token, "0xF100 Device Identity");
- return 0;
- }
-
- seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
- seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
- seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
- seq_printf(seq, "Vendor info : %s\n",
- chtostr(tmp, (u8 *) (work32 + 2), 16));
- seq_printf(seq, "Product info : %s\n",
- chtostr(tmp, (u8 *) (work32 + 6), 16));
- seq_printf(seq, "Description : %s\n",
- chtostr(tmp, (u8 *) (work32 + 10), 16));
- seq_printf(seq, "Product rev. : %s\n",
- chtostr(tmp, (u8 *) (work32 + 14), 8));
-
- seq_printf(seq, "Serial number : ");
- print_serial_number(seq, (u8 *) (work32 + 16),
- /* allow for SNLen plus
- * possible trailing '\0'
- */
- sizeof(work32) - (16 * sizeof(u32)) - 2);
- seq_printf(seq, "\n");
-
- return 0;
-}
-
-static int i2o_seq_show_dev_name(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
-
- seq_printf(seq, "%s\n", dev_name(&d->device));
-
- return 0;
-}
-
-/* Generic group F101h - DDM Identity (scalar) */
-static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
-
- struct {
- u16 ddm_tid;
- u8 module_name[24];
- u8 module_rev[8];
- u8 sn_format;
- u8 serial_number[12];
- u8 pad[256]; // allow up to 256 byte (max) serial number
- } result;
-
- char tmp[24 + 1];
-
- token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token, "0xF101 DDM Identity");
- return 0;
- }
-
- seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
- seq_printf(seq, "Module name : %s\n",
- chtostr(tmp, result.module_name, 24));
- seq_printf(seq, "Module revision : %s\n",
- chtostr(tmp, result.module_rev, 8));
-
- seq_printf(seq, "Serial number : ");
- print_serial_number(seq, result.serial_number, sizeof(result) - 36);
- /* allow for SNLen plus possible trailing '\0' */
-
- seq_printf(seq, "\n");
-
- return 0;
-}
-
-/* Generic group F102h - User Information (scalar) */
-static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
-
- struct {
- u8 device_name[64];
- u8 service_name[64];
- u8 physical_location[64];
- u8 instance_number[4];
- } result;
-
- char tmp[64 + 1];
-
- token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token, "0xF102 User Information");
- return 0;
- }
-
- seq_printf(seq, "Device name : %s\n",
- chtostr(tmp, result.device_name, 64));
- seq_printf(seq, "Service name : %s\n",
- chtostr(tmp, result.service_name, 64));
- seq_printf(seq, "Physical name : %s\n",
- chtostr(tmp, result.physical_location, 64));
- seq_printf(seq, "Instance number : %s\n",
- chtostr(tmp, result.instance_number, 4));
-
- return 0;
-}
-
-/* Generic group F103h - SGL Operating Limits (scalar) */
-static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- static u32 work32[12];
- static u16 *work16 = (u16 *) work32;
- static u8 *work8 = (u8 *) work32;
- int token;
-
- token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
-
- if (token < 0) {
- i2o_report_query_status(seq, token,
- "0xF103 SGL Operating Limits");
- return 0;
- }
-
- seq_printf(seq, "SGL chain size : %d\n", work32[0]);
- seq_printf(seq, "Max SGL chain size : %d\n", work32[1]);
- seq_printf(seq, "SGL chain size target : %d\n", work32[2]);
- seq_printf(seq, "SGL frag count : %d\n", work16[6]);
- seq_printf(seq, "Max SGL frag count : %d\n", work16[7]);
- seq_printf(seq, "SGL frag count target : %d\n", work16[8]);
-
-/* FIXME
- if (d->i2oversion == 0x02)
- {
-*/
- seq_printf(seq, "SGL data alignment : %d\n", work16[8]);
- seq_printf(seq, "SGL addr limit : %d\n", work8[20]);
- seq_printf(seq, "SGL addr sizes supported : ");
- if (work8[21] & 0x01)
- seq_printf(seq, "32 bit ");
- if (work8[21] & 0x02)
- seq_printf(seq, "64 bit ");
- if (work8[21] & 0x04)
- seq_printf(seq, "96 bit ");
- if (work8[21] & 0x08)
- seq_printf(seq, "128 bit ");
- seq_printf(seq, "\n");
-/*
- }
-*/
-
- return 0;
-}
-
-/* Generic group F200h - Sensors (scalar) */
-static int i2o_seq_show_sensors(struct seq_file *seq, void *v)
-{
- struct i2o_device *d = (struct i2o_device *)seq->private;
- int token;
-
- struct {
- u16 sensor_instance;
- u8 component;
- u16 component_instance;
- u8 sensor_class;
- u8 sensor_type;
- u8 scaling_exponent;
- u32 actual_reading;
- u32 minimum_reading;
- u32 low2lowcat_treshold;
- u32 lowcat2low_treshold;
- u32 lowwarn2low_treshold;
- u32 low2lowwarn_treshold;
- u32 norm2lowwarn_treshold;
- u32 lowwarn2norm_treshold;
- u32 nominal_reading;
- u32 hiwarn2norm_treshold;
- u32 norm2hiwarn_treshold;
- u32 high2hiwarn_treshold;
- u32 hiwarn2high_treshold;
- u32 hicat2high_treshold;
- u32 hi2hicat_treshold;
- u32 maximum_reading;
- u8 sensor_state;
- u16 event_enable;
- } result;
-
- token = i2o_parm_field_get(d, 0xF200, -1, &result, sizeof(result));
-
- if (token < 0) {
- i2o_report_query_status(seq, token,
- "0xF200 Sensors (optional)");
- return 0;
- }
-
- seq_printf(seq, "Sensor instance : %d\n", result.sensor_instance);
-
- seq_printf(seq, "Component : %d = ", result.component);
- switch (result.component) {
- case 0:
- seq_printf(seq, "Other");
- break;
- case 1:
- seq_printf(seq, "Planar logic Board");
- break;
- case 2:
- seq_printf(seq, "CPU");
- break;
- case 3:
- seq_printf(seq, "Chassis");
- break;
- case 4:
- seq_printf(seq, "Power Supply");
- break;
- case 5:
- seq_printf(seq, "Storage");
- break;
- case 6:
- seq_printf(seq, "External");
- break;
- }
- seq_printf(seq, "\n");
-
- seq_printf(seq, "Component instance : %d\n",
- result.component_instance);
- seq_printf(seq, "Sensor class : %s\n",
- result.sensor_class ? "Analog" : "Digital");
-
- seq_printf(seq, "Sensor type : %d = ", result.sensor_type);
- switch (result.sensor_type) {
- case 0:
- seq_printf(seq, "Other\n");
- break;
- case 1:
- seq_printf(seq, "Thermal\n");
- break;
- case 2:
- seq_printf(seq, "DC voltage (DC volts)\n");
- break;
- case 3:
- seq_printf(seq, "AC voltage (AC volts)\n");
- break;
- case 4:
- seq_printf(seq, "DC current (DC amps)\n");
- break;
- case 5:
- seq_printf(seq, "AC current (AC volts)\n");
- break;
- case 6:
- seq_printf(seq, "Door open\n");
- break;
- case 7:
- seq_printf(seq, "Fan operational\n");
- break;
- }
-
- seq_printf(seq, "Scaling exponent : %d\n",
- result.scaling_exponent);
- seq_printf(seq, "Actual reading : %d\n", result.actual_reading);
- seq_printf(seq, "Minimum reading : %d\n", result.minimum_reading);
- seq_printf(seq, "Low2LowCat treshold : %d\n",
- result.low2lowcat_treshold);
- seq_printf(seq, "LowCat2Low treshold : %d\n",
- result.lowcat2low_treshold);
- seq_printf(seq, "LowWarn2Low treshold : %d\n",
- result.lowwarn2low_treshold);
- seq_printf(seq, "Low2LowWarn treshold : %d\n",
- result.low2lowwarn_treshold);
- seq_printf(seq, "Norm2LowWarn treshold : %d\n",
- result.norm2lowwarn_treshold);
- seq_printf(seq, "LowWarn2Norm treshold : %d\n",
- result.lowwarn2norm_treshold);
- seq_printf(seq, "Nominal reading : %d\n", result.nominal_reading);
- seq_printf(seq, "HiWarn2Norm treshold : %d\n",
- result.hiwarn2norm_treshold);
- seq_printf(seq, "Norm2HiWarn treshold : %d\n",
- result.norm2hiwarn_treshold);
- seq_printf(seq, "High2HiWarn treshold : %d\n",
- result.high2hiwarn_treshold);
- seq_printf(seq, "HiWarn2High treshold : %d\n",
- result.hiwarn2high_treshold);
- seq_printf(seq, "HiCat2High treshold : %d\n",
- result.hicat2high_treshold);
- seq_printf(seq, "High2HiCat treshold : %d\n",
- result.hi2hicat_treshold);
- seq_printf(seq, "Maximum reading : %d\n", result.maximum_reading);
-
- seq_printf(seq, "Sensor state : %d = ", result.sensor_state);
- switch (result.sensor_state) {
- case 0:
- seq_printf(seq, "Normal\n");
- break;
- case 1:
- seq_printf(seq, "Abnormal\n");
- break;
- case 2:
- seq_printf(seq, "Unknown\n");
- break;
- case 3:
- seq_printf(seq, "Low Catastrophic (LoCat)\n");
- break;
- case 4:
- seq_printf(seq, "Low (Low)\n");
- break;
- case 5:
- seq_printf(seq, "Low Warning (LoWarn)\n");
- break;
- case 6:
- seq_printf(seq, "High Warning (HiWarn)\n");
- break;
- case 7:
- seq_printf(seq, "High (High)\n");
- break;
- case 8:
- seq_printf(seq, "High Catastrophic (HiCat)\n");
- break;
- }
-
- seq_printf(seq, "Event_enable : 0x%02X\n", result.event_enable);
- seq_printf(seq, " [%s] Operational state change. \n",
- (result.event_enable & 0x01) ? "+" : "-");
- seq_printf(seq, " [%s] Low catastrophic. \n",
- (result.event_enable & 0x02) ? "+" : "-");
- seq_printf(seq, " [%s] Low reading. \n",
- (result.event_enable & 0x04) ? "+" : "-");
- seq_printf(seq, " [%s] Low warning. \n",
- (result.event_enable & 0x08) ? "+" : "-");
- seq_printf(seq,
- " [%s] Change back to normal from out of range state. \n",
- (result.event_enable & 0x10) ? "+" : "-");
- seq_printf(seq, " [%s] High warning. \n",
- (result.event_enable & 0x20) ? "+" : "-");
- seq_printf(seq, " [%s] High reading. \n",
- (result.event_enable & 0x40) ? "+" : "-");
- seq_printf(seq, " [%s] High catastrophic. \n",
- (result.event_enable & 0x80) ? "+" : "-");
-
- return 0;
-}
-
-static int i2o_seq_open_hrt(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_hrt, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_lct(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_lct, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_status(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_status, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_hw(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_hw, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_ddm_table(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_ddm_table, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_driver_store(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_driver_store, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_drivers_stored(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_drivers_stored, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_groups(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_groups, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_phys_device(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_phys_device, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_claimed(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_claimed, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_users(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_users, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_priv_msgs(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_priv_msgs, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_authorized_users(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_authorized_users,
- PDE_DATA(inode));
-};
-
-static int i2o_seq_open_dev_identity(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_dev_identity, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_ddm_identity(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_ddm_identity, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_uinfo(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_uinfo, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_sgl_limits(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_sgl_limits, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_sensors(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_sensors, PDE_DATA(inode));
-};
-
-static int i2o_seq_open_dev_name(struct inode *inode, struct file *file)
-{
- return single_open(file, i2o_seq_show_dev_name, PDE_DATA(inode));
-};
-
-static const struct file_operations i2o_seq_fops_lct = {
- .open = i2o_seq_open_lct,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_hrt = {
- .open = i2o_seq_open_hrt,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_status = {
- .open = i2o_seq_open_status,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_hw = {
- .open = i2o_seq_open_hw,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_ddm_table = {
- .open = i2o_seq_open_ddm_table,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_driver_store = {
- .open = i2o_seq_open_driver_store,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_drivers_stored = {
- .open = i2o_seq_open_drivers_stored,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_groups = {
- .open = i2o_seq_open_groups,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_phys_device = {
- .open = i2o_seq_open_phys_device,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_claimed = {
- .open = i2o_seq_open_claimed,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_users = {
- .open = i2o_seq_open_users,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_priv_msgs = {
- .open = i2o_seq_open_priv_msgs,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_authorized_users = {
- .open = i2o_seq_open_authorized_users,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_dev_name = {
- .open = i2o_seq_open_dev_name,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_dev_identity = {
- .open = i2o_seq_open_dev_identity,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_ddm_identity = {
- .open = i2o_seq_open_ddm_identity,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_uinfo = {
- .open = i2o_seq_open_uinfo,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_sgl_limits = {
- .open = i2o_seq_open_sgl_limits,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-static const struct file_operations i2o_seq_fops_sensors = {
- .open = i2o_seq_open_sensors,
- .read = seq_read,
- .llseek = seq_lseek,
- .release = single_release,
-};
-
-/*
- * IOP specific entries...write field just in case someone
- * ever wants one.
- */
-static i2o_proc_entry i2o_proc_generic_iop_entries[] = {
- {"hrt", S_IFREG | S_IRUGO, &i2o_seq_fops_hrt},
- {"lct", S_IFREG | S_IRUGO, &i2o_seq_fops_lct},
- {"status", S_IFREG | S_IRUGO, &i2o_seq_fops_status},
- {"hw", S_IFREG | S_IRUGO, &i2o_seq_fops_hw},
- {"ddm_table", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_table},
- {"driver_store", S_IFREG | S_IRUGO, &i2o_seq_fops_driver_store},
- {"drivers_stored", S_IFREG | S_IRUGO, &i2o_seq_fops_drivers_stored},
- {NULL, 0, NULL}
-};
-
-/*
- * Device specific entries
- */
-static i2o_proc_entry generic_dev_entries[] = {
- {"groups", S_IFREG | S_IRUGO, &i2o_seq_fops_groups},
- {"phys_dev", S_IFREG | S_IRUGO, &i2o_seq_fops_phys_device},
- {"claimed", S_IFREG | S_IRUGO, &i2o_seq_fops_claimed},
- {"users", S_IFREG | S_IRUGO, &i2o_seq_fops_users},
- {"priv_msgs", S_IFREG | S_IRUGO, &i2o_seq_fops_priv_msgs},
- {"authorized_users", S_IFREG | S_IRUGO, &i2o_seq_fops_authorized_users},
- {"dev_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_identity},
- {"ddm_identity", S_IFREG | S_IRUGO, &i2o_seq_fops_ddm_identity},
- {"user_info", S_IFREG | S_IRUGO, &i2o_seq_fops_uinfo},
- {"sgl_limits", S_IFREG | S_IRUGO, &i2o_seq_fops_sgl_limits},
- {"sensors", S_IFREG | S_IRUGO, &i2o_seq_fops_sensors},
- {NULL, 0, NULL}
-};
-
-/*
- * Storage unit specific entries (SCSI Periph, BS) with device names
- */
-static i2o_proc_entry rbs_dev_entries[] = {
- {"dev_name", S_IFREG | S_IRUGO, &i2o_seq_fops_dev_name},
- {NULL, 0, NULL}
-};
-
-/**
- * i2o_proc_create_entries - Creates proc dir entries
- * @dir: proc dir entry under which the entries should be placed
- * @i2o_pe: pointer to the entries which should be added
- * @data: pointer to I2O controller or device
- *
- * Create proc dir entries for a I2O controller or I2O device.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_proc_create_entries(struct proc_dir_entry *dir,
- i2o_proc_entry * i2o_pe, void *data)
-{
- struct proc_dir_entry *tmp;
-
- while (i2o_pe->name) {
- tmp = proc_create_data(i2o_pe->name, i2o_pe->mode, dir,
- i2o_pe->fops, data);
- if (!tmp)
- return -1;
-
- i2o_pe++;
- }
-
- return 0;
-}
-
-/**
- * i2o_proc_device_add - Add an I2O device to the proc dir
- * @dir: proc dir entry to which the device should be added
- * @dev: I2O device which should be added
- *
- * Add an I2O device to the proc dir entry dir and create the entries for
- * the device depending on the class of the I2O device.
- */
-static void i2o_proc_device_add(struct proc_dir_entry *dir,
- struct i2o_device *dev)
-{
- char buff[10];
- struct proc_dir_entry *devdir;
- i2o_proc_entry *i2o_pe = NULL;
-
- sprintf(buff, "%03x", dev->lct_data.tid);
-
- osm_debug("adding device /proc/i2o/%s/%s\n", dev->iop->name, buff);
-
- devdir = proc_mkdir_data(buff, 0, dir, dev);
- if (!devdir) {
- osm_warn("Could not allocate procdir!\n");
- return;
- }
-
- i2o_proc_create_entries(devdir, generic_dev_entries, dev);
-
- /* Inform core that we want updates about this device's status */
- switch (dev->lct_data.class_id) {
- case I2O_CLASS_SCSI_PERIPHERAL:
- case I2O_CLASS_RANDOM_BLOCK_STORAGE:
- i2o_pe = rbs_dev_entries;
- break;
- default:
- break;
- }
- if (i2o_pe)
- i2o_proc_create_entries(devdir, i2o_pe, dev);
-}
-
-/**
- * i2o_proc_iop_add - Add an I2O controller to the i2o proc tree
- * @dir: parent proc dir entry
- * @c: I2O controller which should be added
- *
- * Add the entries to the parent proc dir entry. Also each device is added
- * to the controllers proc dir entry.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_proc_iop_add(struct proc_dir_entry *dir,
- struct i2o_controller *c)
-{
- struct proc_dir_entry *iopdir;
- struct i2o_device *dev;
-
- osm_debug("adding IOP /proc/i2o/%s\n", c->name);
-
- iopdir = proc_mkdir_data(c->name, 0, dir, c);
- if (!iopdir)
- return -1;
-
- i2o_proc_create_entries(iopdir, i2o_proc_generic_iop_entries, c);
-
- list_for_each_entry(dev, &c->devices, list)
- i2o_proc_device_add(iopdir, dev);
-
- return 0;
-}
-
-/**
- * i2o_proc_fs_create - Create the i2o proc fs.
- *
- * Iterate over each I2O controller and create the entries for it.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int __init i2o_proc_fs_create(void)
-{
- struct i2o_controller *c;
-
- i2o_proc_dir_root = proc_mkdir("i2o", NULL);
- if (!i2o_proc_dir_root)
- return -1;
-
- list_for_each_entry(c, &i2o_controllers, list)
- i2o_proc_iop_add(i2o_proc_dir_root, c);
-
- return 0;
-};
-
-/**
- * i2o_proc_fs_destroy - Cleanup the all i2o proc entries
- *
- * Iterate over each I2O controller and remove the entries for it.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int __exit i2o_proc_fs_destroy(void)
-{
- remove_proc_subtree("i2o", NULL);
-
- return 0;
-};
-
-/**
- * i2o_proc_init - Init function for procfs
- *
- * Registers Proc OSM and creates procfs entries.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int __init i2o_proc_init(void)
-{
- int rc;
-
- printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
-
- rc = i2o_driver_register(&i2o_proc_driver);
- if (rc)
- return rc;
-
- rc = i2o_proc_fs_create();
- if (rc) {
- i2o_driver_unregister(&i2o_proc_driver);
- return rc;
- }
-
- return 0;
-};
-
-/**
- * i2o_proc_exit - Exit function for procfs
- *
- * Unregisters Proc OSM and removes procfs entries.
- */
-static void __exit i2o_proc_exit(void)
-{
- i2o_driver_unregister(&i2o_proc_driver);
- i2o_proc_fs_destroy();
-};
-
-MODULE_AUTHOR("Deepak Saxena");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(OSM_DESCRIPTION);
-MODULE_VERSION(OSM_VERSION);
-
-module_init(i2o_proc_init);
-module_exit(i2o_proc_exit);
diff --git a/drivers/staging/i2o/i2o_scsi.c b/drivers/staging/i2o/i2o_scsi.c
deleted file mode 100644
index 1b11dcb3faea7b..00000000000000
--- a/drivers/staging/i2o/i2o_scsi.c
+++ /dev/null
@@ -1,814 +0,0 @@
-/*
- * 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.
- *
- * For the avoidance of doubt the "preferred form" of this code is one which
- * is in an open non patent encumbered format. Where cryptographic key signing
- * forms part of the process of creating an executable the information
- * including keys needed to generate an equivalently functional executable
- * are deemed to be part of the source code.
- *
- * Complications for I2O scsi
- *
- * o Each (bus,lun) is a logical device in I2O. We keep a map
- * table. We spoof failed selection for unmapped units
- * o Request sense buffers can come back for free.
- * o Scatter gather is a bit dynamic. We have to investigate at
- * setup time.
- * o Some of our resources are dynamically shared. The i2o core
- * needs a message reservation protocol to avoid swap v net
- * deadlocking. We need to back off queue requests.
- *
- * In general the firmware wants to help. Where its help isn't performance
- * useful we just ignore the aid. Its not worth the code in truth.
- *
- * Fixes/additions:
- * Steve Ralston:
- * Scatter gather now works
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Minor fixes for 2.6.
- *
- * To Do:
- * 64bit cleanups
- * Fix the resource management problems.
- */
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/string.h>
-#include <linux/ioport.h>
-#include <linux/jiffies.h>
-#include <linux/interrupt.h>
-#include <linux/timer.h>
-#include <linux/delay.h>
-#include <linux/proc_fs.h>
-#include <linux/prefetch.h>
-#include <linux/pci.h>
-#include <linux/blkdev.h>
-#include "i2o.h"
-#include <linux/scatterlist.h>
-
-#include <asm/dma.h>
-#include <asm/io.h>
-#include <linux/atomic.h>
-
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_device.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/sg.h>
-
-#define OSM_NAME "scsi-osm"
-#define OSM_VERSION "1.316"
-#define OSM_DESCRIPTION "I2O SCSI Peripheral OSM"
-
-static struct i2o_driver i2o_scsi_driver;
-
-static unsigned int i2o_scsi_max_id = 16;
-static unsigned int i2o_scsi_max_lun = 255;
-
-struct i2o_scsi_host {
- struct Scsi_Host *scsi_host; /* pointer to the SCSI host */
- struct i2o_controller *iop; /* pointer to the I2O controller */
- u64 lun; /* lun's used for block devices */
- struct i2o_device *channel[0]; /* channel->i2o_dev mapping table */
-};
-
-static struct scsi_host_template i2o_scsi_host_template;
-
-#define I2O_SCSI_CAN_QUEUE 4
-
-/* SCSI OSM class handling definition */
-static struct i2o_class_id i2o_scsi_class_id[] = {
- {I2O_CLASS_SCSI_PERIPHERAL},
- {I2O_CLASS_END}
-};
-
-static struct i2o_scsi_host *i2o_scsi_host_alloc(struct i2o_controller *c)
-{
- struct i2o_scsi_host *i2o_shost;
- struct i2o_device *i2o_dev;
- struct Scsi_Host *scsi_host;
- int max_channel = 0;
- u8 type;
- int i;
- size_t size;
- u16 body_size = 6;
-
-#ifdef CONFIG_I2O_EXT_ADAPTEC
- if (c->adaptec)
- body_size = 8;
-#endif
-
- list_for_each_entry(i2o_dev, &c->devices, list)
- if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) {
- if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1)
- && (type == 0x01)) /* SCSI bus */
- max_channel++;
- }
-
- if (!max_channel) {
- osm_warn("no channels found on %s\n", c->name);
- return ERR_PTR(-EFAULT);
- }
-
- size = max_channel * sizeof(struct i2o_device *)
- + sizeof(struct i2o_scsi_host);
-
- scsi_host = scsi_host_alloc(&i2o_scsi_host_template, size);
- if (!scsi_host) {
- osm_warn("Could not allocate SCSI host\n");
- return ERR_PTR(-ENOMEM);
- }
-
- scsi_host->max_channel = max_channel - 1;
- scsi_host->max_id = i2o_scsi_max_id;
- scsi_host->max_lun = i2o_scsi_max_lun;
- scsi_host->this_id = c->unit;
- scsi_host->sg_tablesize = i2o_sg_tablesize(c, body_size);
-
- i2o_shost = (struct i2o_scsi_host *)scsi_host->hostdata;
- i2o_shost->scsi_host = scsi_host;
- i2o_shost->iop = c;
- i2o_shost->lun = 1;
-
- i = 0;
- list_for_each_entry(i2o_dev, &c->devices, list)
- if (i2o_dev->lct_data.class_id == I2O_CLASS_BUS_ADAPTER) {
- if (!i2o_parm_field_get(i2o_dev, 0x0000, 0, &type, 1)
- && (type == 0x01)) /* only SCSI bus */
- i2o_shost->channel[i++] = i2o_dev;
-
- if (i >= max_channel)
- break;
- }
-
- return i2o_shost;
-};
-
-/**
- * i2o_scsi_get_host - Get an I2O SCSI host
- * @c: I2O controller to for which to get the SCSI host
- *
- * If the I2O controller already exists as SCSI host, the SCSI host
- * is returned, otherwise the I2O controller is added to the SCSI
- * core.
- *
- * Returns pointer to the I2O SCSI host on success or NULL on failure.
- */
-static struct i2o_scsi_host *i2o_scsi_get_host(struct i2o_controller *c)
-{
- return c->driver_data[i2o_scsi_driver.context];
-};
-
-/**
- * i2o_scsi_remove - Remove I2O device from SCSI core
- * @dev: device which should be removed
- *
- * Removes the I2O device from the SCSI core again.
- *
- * Returns 0 on success.
- */
-static int i2o_scsi_remove(struct device *dev)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
- struct i2o_controller *c = i2o_dev->iop;
- struct i2o_scsi_host *i2o_shost;
- struct scsi_device *scsi_dev;
-
- osm_info("device removed (TID: %03x)\n", i2o_dev->lct_data.tid);
-
- i2o_shost = i2o_scsi_get_host(c);
-
- shost_for_each_device(scsi_dev, i2o_shost->scsi_host)
- if (scsi_dev->hostdata == i2o_dev) {
- sysfs_remove_link(&i2o_dev->device.kobj, "scsi");
- scsi_remove_device(scsi_dev);
- scsi_device_put(scsi_dev);
- break;
- }
-
- return 0;
-};
-
-/**
- * i2o_scsi_probe - verify if dev is a I2O SCSI device and install it
- * @dev: device to verify if it is a I2O SCSI device
- *
- * Retrieve channel, id and lun for I2O device. If everything goes well
- * register the I2O device as SCSI device on the I2O SCSI controller.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_scsi_probe(struct device *dev)
-{
- struct i2o_device *i2o_dev = to_i2o_device(dev);
- struct i2o_controller *c = i2o_dev->iop;
- struct i2o_scsi_host *i2o_shost;
- struct Scsi_Host *scsi_host;
- struct i2o_device *parent;
- struct scsi_device *scsi_dev;
- u32 id = -1;
- u64 lun = -1;
- int channel = -1;
- int i, rc;
-
- i2o_shost = i2o_scsi_get_host(c);
- if (!i2o_shost)
- return -EFAULT;
-
- scsi_host = i2o_shost->scsi_host;
-
- switch (i2o_dev->lct_data.class_id) {
- case I2O_CLASS_RANDOM_BLOCK_STORAGE:
- case I2O_CLASS_EXECUTIVE:
-#ifdef CONFIG_I2O_EXT_ADAPTEC
- if (c->adaptec) {
- u8 type;
- struct i2o_device *d = i2o_shost->channel[0];
-
- if (!i2o_parm_field_get(d, 0x0000, 0, &type, 1)
- && (type == 0x01)) /* SCSI bus */
- if (!i2o_parm_field_get(d, 0x0200, 4, &id, 4)) {
- channel = 0;
- if (i2o_dev->lct_data.class_id ==
- I2O_CLASS_RANDOM_BLOCK_STORAGE)
- lun =
- cpu_to_le64(i2o_shost->
- lun++);
- else
- lun = 0;
- }
- }
-#endif
- break;
-
- case I2O_CLASS_SCSI_PERIPHERAL:
- if (i2o_parm_field_get(i2o_dev, 0x0000, 3, &id, 4))
- return -EFAULT;
-
- if (i2o_parm_field_get(i2o_dev, 0x0000, 4, &lun, 8))
- return -EFAULT;
-
- parent = i2o_iop_find_device(c, i2o_dev->lct_data.parent_tid);
- if (!parent) {
- osm_warn("can not find parent of device %03x\n",
- i2o_dev->lct_data.tid);
- return -EFAULT;
- }
-
- for (i = 0; i <= i2o_shost->scsi_host->max_channel; i++)
- if (i2o_shost->channel[i] == parent)
- channel = i;
- break;
-
- default:
- return -EFAULT;
- }
-
- if (channel == -1) {
- osm_warn("can not find channel of device %03x\n",
- i2o_dev->lct_data.tid);
- return -EFAULT;
- }
-
- if (le32_to_cpu(id) >= scsi_host->max_id) {
- osm_warn("SCSI device id (%d) >= max_id of I2O host (%d)",
- le32_to_cpu(id), scsi_host->max_id);
- return -EFAULT;
- }
-
- if (le64_to_cpu(lun) >= scsi_host->max_lun) {
- osm_warn("SCSI device lun (%llu) >= max_lun of I2O host (%llu)",
- le64_to_cpu(lun), scsi_host->max_lun);
- return -EFAULT;
- }
-
- scsi_dev =
- __scsi_add_device(i2o_shost->scsi_host, channel, le32_to_cpu(id),
- le64_to_cpu(lun), i2o_dev);
-
- if (IS_ERR(scsi_dev)) {
- osm_warn("can not add SCSI device %03x\n",
- i2o_dev->lct_data.tid);
- return PTR_ERR(scsi_dev);
- }
-
- rc = sysfs_create_link(&i2o_dev->device.kobj,
- &scsi_dev->sdev_gendev.kobj, "scsi");
- if (rc)
- goto err;
-
- osm_info("device added (TID: %03x) channel: %d, id: %d, lun: %llu\n",
- i2o_dev->lct_data.tid, channel, le32_to_cpu(id),
- le64_to_cpu(lun));
-
- return 0;
-
-err:
- scsi_remove_device(scsi_dev);
- return rc;
-};
-
-static const char *i2o_scsi_info(struct Scsi_Host *SChost)
-{
- struct i2o_scsi_host *hostdata;
- hostdata = (struct i2o_scsi_host *)SChost->hostdata;
- return hostdata->iop->name;
-}
-
-/**
- * i2o_scsi_reply - SCSI OSM message reply handler
- * @c: controller issuing the reply
- * @m: message id for flushing
- * @msg: the message from the controller
- *
- * Process reply messages (interrupts in normal scsi controller think).
- * We can get a variety of messages to process. The normal path is
- * scsi command completions. We must also deal with IOP failures,
- * the reply to a bus reset and the reply to a LUN query.
- *
- * Returns 0 on success and if the reply should not be flushed or > 0
- * on success and if the reply should be flushed. Returns negative error
- * code on failure and if the reply should be flushed.
- */
-static int i2o_scsi_reply(struct i2o_controller *c, u32 m,
- struct i2o_message *msg)
-{
- struct scsi_cmnd *cmd;
- u32 error;
- struct device *dev;
-
- cmd = i2o_cntxt_list_get(c, le32_to_cpu(msg->u.s.tcntxt));
- if (unlikely(!cmd)) {
- osm_err("NULL reply received!\n");
- return -1;
- }
-
- /*
- * Low byte is device status, next is adapter status,
- * (then one byte reserved), then request status.
- */
- error = le32_to_cpu(msg->body[0]);
-
- osm_debug("Completed %0x%p\n", cmd);
-
- cmd->result = error & 0xff;
- /*
- * if DeviceStatus is not SCSI_SUCCESS copy over the sense data and let
- * the SCSI layer handle the error
- */
- if (cmd->result)
- memcpy(cmd->sense_buffer, &msg->body[3],
- min(SCSI_SENSE_BUFFERSIZE, 40));
-
- /* only output error code if AdapterStatus is not HBA_SUCCESS */
- if ((error >> 8) & 0xff)
- osm_err("SCSI error %08x\n", error);
-
- dev = &c->pdev->dev;
-
- scsi_dma_unmap(cmd);
-
- cmd->scsi_done(cmd);
-
- return 1;
-};
-
-/**
- * i2o_scsi_notify_device_add - Retrieve notifications of added devices
- * @i2o_dev: the I2O device which was added
- *
- * If a I2O device is added we catch the notification, because I2O classes
- * other than SCSI peripheral will not be received through
- * i2o_scsi_probe().
- */
-static void i2o_scsi_notify_device_add(struct i2o_device *i2o_dev)
-{
- switch (i2o_dev->lct_data.class_id) {
- case I2O_CLASS_EXECUTIVE:
- case I2O_CLASS_RANDOM_BLOCK_STORAGE:
- i2o_scsi_probe(&i2o_dev->device);
- break;
-
- default:
- break;
- }
-};
-
-/**
- * i2o_scsi_notify_device_remove - Retrieve notifications of removed devices
- * @i2o_dev: the I2O device which was removed
- *
- * If a I2O device is removed, we catch the notification to remove the
- * corresponding SCSI device.
- */
-static void i2o_scsi_notify_device_remove(struct i2o_device *i2o_dev)
-{
- switch (i2o_dev->lct_data.class_id) {
- case I2O_CLASS_EXECUTIVE:
- case I2O_CLASS_RANDOM_BLOCK_STORAGE:
- i2o_scsi_remove(&i2o_dev->device);
- break;
-
- default:
- break;
- }
-};
-
-/**
- * i2o_scsi_notify_controller_add - Retrieve notifications of added controllers
- * @c: the controller which was added
- *
- * If a I2O controller is added, we catch the notification to add a
- * corresponding Scsi_Host.
- */
-static void i2o_scsi_notify_controller_add(struct i2o_controller *c)
-{
- struct i2o_scsi_host *i2o_shost;
- int rc;
-
- i2o_shost = i2o_scsi_host_alloc(c);
- if (IS_ERR(i2o_shost)) {
- osm_err("Could not initialize SCSI host\n");
- return;
- }
-
- rc = scsi_add_host(i2o_shost->scsi_host, &c->device);
- if (rc) {
- osm_err("Could not add SCSI host\n");
- scsi_host_put(i2o_shost->scsi_host);
- return;
- }
-
- c->driver_data[i2o_scsi_driver.context] = i2o_shost;
-
- osm_debug("new I2O SCSI host added\n");
-};
-
-/**
- * i2o_scsi_notify_controller_remove - Retrieve notifications of removed controllers
- * @c: the controller which was removed
- *
- * If a I2O controller is removed, we catch the notification to remove the
- * corresponding Scsi_Host.
- */
-static void i2o_scsi_notify_controller_remove(struct i2o_controller *c)
-{
- struct i2o_scsi_host *i2o_shost;
- i2o_shost = i2o_scsi_get_host(c);
- if (!i2o_shost)
- return;
-
- c->driver_data[i2o_scsi_driver.context] = NULL;
-
- scsi_remove_host(i2o_shost->scsi_host);
- scsi_host_put(i2o_shost->scsi_host);
- osm_debug("I2O SCSI host removed\n");
-};
-
-/* SCSI OSM driver struct */
-static struct i2o_driver i2o_scsi_driver = {
- .name = OSM_NAME,
- .reply = i2o_scsi_reply,
- .classes = i2o_scsi_class_id,
- .notify_device_add = i2o_scsi_notify_device_add,
- .notify_device_remove = i2o_scsi_notify_device_remove,
- .notify_controller_add = i2o_scsi_notify_controller_add,
- .notify_controller_remove = i2o_scsi_notify_controller_remove,
- .driver = {
- .probe = i2o_scsi_probe,
- .remove = i2o_scsi_remove,
- },
-};
-
-/**
- * i2o_scsi_queuecommand - queue a SCSI command
- * @SCpnt: scsi command pointer
- * @done: callback for completion
- *
- * Issue a scsi command asynchronously. Return 0 on success or 1 if
- * we hit an error (normally message queue congestion). The only
- * minor complication here is that I2O deals with the device addressing
- * so we have to map the bus/dev/lun back to an I2O handle as well
- * as faking absent devices ourself.
- *
- * Locks: takes the controller lock on error path only
- */
-
-static int i2o_scsi_queuecommand_lck(struct scsi_cmnd *SCpnt,
- void (*done) (struct scsi_cmnd *))
-{
- struct i2o_controller *c;
- struct i2o_device *i2o_dev;
- int tid;
- struct i2o_message *msg;
- /*
- * ENABLE_DISCONNECT
- * SIMPLE_TAG
- * RETURN_SENSE_DATA_IN_REPLY_MESSAGE_FRAME
- */
- u32 scsi_flags = 0x20a00000;
- u32 sgl_offset;
- u32 *mptr;
- u32 cmd = I2O_CMD_SCSI_EXEC << 24;
- int rc = 0;
-
- /*
- * Do the incoming paperwork
- */
- i2o_dev = SCpnt->device->hostdata;
-
- SCpnt->scsi_done = done;
-
- if (unlikely(!i2o_dev)) {
- osm_warn("no I2O device in request\n");
- SCpnt->result = DID_NO_CONNECT << 16;
- done(SCpnt);
- goto exit;
- }
- c = i2o_dev->iop;
- tid = i2o_dev->lct_data.tid;
-
- osm_debug("qcmd: Tid = %03x\n", tid);
- osm_debug("Real scsi messages.\n");
-
- /*
- * Put together a scsi execscb message
- */
- switch (SCpnt->sc_data_direction) {
- case PCI_DMA_NONE:
- /* DATA NO XFER */
- sgl_offset = SGL_OFFSET_0;
- break;
-
- case PCI_DMA_TODEVICE:
- /* DATA OUT (iop-->dev) */
- scsi_flags |= 0x80000000;
- sgl_offset = SGL_OFFSET_10;
- break;
-
- case PCI_DMA_FROMDEVICE:
- /* DATA IN (iop<--dev) */
- scsi_flags |= 0x40000000;
- sgl_offset = SGL_OFFSET_10;
- break;
-
- default:
- /* Unknown - kill the command */
- SCpnt->result = DID_NO_CONNECT << 16;
- done(SCpnt);
- goto exit;
- }
-
- /*
- * Obtain an I2O message. If there are none free then
- * throw it back to the scsi layer
- */
-
- msg = i2o_msg_get(c);
- if (IS_ERR(msg)) {
- rc = SCSI_MLQUEUE_HOST_BUSY;
- goto exit;
- }
-
- mptr = &msg->body[0];
-
-#if 0 /* this code can't work */
-#ifdef CONFIG_I2O_EXT_ADAPTEC
- if (c->adaptec) {
- u32 adpt_flags = 0;
-
- if (SCpnt->sc_request && SCpnt->sc_request->upper_private_data) {
- i2o_sg_io_hdr_t __user *usr_ptr =
- ((Sg_request *) (SCpnt->sc_request->
- upper_private_data))->header.
- usr_ptr;
-
- if (usr_ptr)
- get_user(adpt_flags, &usr_ptr->flags);
- }
-
- switch (i2o_dev->lct_data.class_id) {
- case I2O_CLASS_EXECUTIVE:
- case I2O_CLASS_RANDOM_BLOCK_STORAGE:
- /* interpret flag has to be set for executive */
- adpt_flags ^= I2O_DPT_SG_FLAG_INTERPRET;
- break;
-
- default:
- break;
- }
-
- /*
- * for Adaptec controllers we use the PRIVATE command, because
- * the normal SCSI EXEC doesn't support all SCSI commands on
- * all controllers (for example READ CAPACITY).
- */
- if (sgl_offset == SGL_OFFSET_10)
- sgl_offset = SGL_OFFSET_12;
- cmd = I2O_CMD_PRIVATE << 24;
- *mptr++ = cpu_to_le32(I2O_VENDOR_DPT << 16 | I2O_CMD_SCSI_EXEC);
- *mptr++ = cpu_to_le32(adpt_flags | tid);
- }
-#endif
-#endif
-
- msg->u.head[1] = cpu_to_le32(cmd | HOST_TID << 12 | tid);
- msg->u.s.icntxt = cpu_to_le32(i2o_scsi_driver.context);
-
- /* We want the SCSI control block back */
- msg->u.s.tcntxt = cpu_to_le32(i2o_cntxt_list_add(c, SCpnt));
-
- /* LSI_920_PCI_QUIRK
- *
- * Intermittant observations of msg frame word data corruption
- * observed on msg[4] after:
- * WRITE, READ-MODIFY-WRITE
- * operations. 19990606 -sralston
- *
- * (Hence we build this word via tag. Its good practice anyway
- * we don't want fetches over PCI needlessly)
- */
-
- /* Attach tags to the devices */
- /* FIXME: implement
- if(SCpnt->device->tagged_supported) {
- if(SCpnt->tag == HEAD_OF_QUEUE_TAG)
- scsi_flags |= 0x01000000;
- else if(SCpnt->tag == ORDERED_QUEUE_TAG)
- scsi_flags |= 0x01800000;
- }
- */
-
- *mptr++ = cpu_to_le32(scsi_flags | SCpnt->cmd_len);
-
- /* Write SCSI command into the message - always 16 byte block */
- memcpy(mptr, SCpnt->cmnd, 16);
- mptr += 4;
-
- if (sgl_offset != SGL_OFFSET_0) {
- /* write size of data addressed by SGL */
- *mptr++ = cpu_to_le32(scsi_bufflen(SCpnt));
-
- /* Now fill in the SGList and command */
-
- if (scsi_sg_count(SCpnt)) {
- if (!i2o_dma_map_sg(c, scsi_sglist(SCpnt),
- scsi_sg_count(SCpnt),
- SCpnt->sc_data_direction, &mptr))
- goto nomem;
- }
- }
-
- /* Stick the headers on */
- msg->u.head[0] =
- cpu_to_le32(I2O_MESSAGE_SIZE(mptr - &msg->u.head[0]) | sgl_offset);
-
- /* Queue the message */
- i2o_msg_post(c, msg);
-
- osm_debug("Issued %0x%p\n", SCpnt);
-
- return 0;
-
- nomem:
- rc = -ENOMEM;
- i2o_msg_nop(c, msg);
-
- exit:
- return rc;
-}
-
-static DEF_SCSI_QCMD(i2o_scsi_queuecommand)
-
-/**
- * i2o_scsi_abort - abort a running command
- * @SCpnt: command to abort
- *
- * Ask the I2O controller to abort a command. This is an asynchrnous
- * process and our callback handler will see the command complete with an
- * aborted message if it succeeds.
- *
- * Returns 0 if the command is successfully aborted or negative error code
- * on failure.
- */
-static int i2o_scsi_abort(struct scsi_cmnd *SCpnt)
-{
- struct i2o_device *i2o_dev;
- struct i2o_controller *c;
- struct i2o_message *msg;
- int tid;
- int status = FAILED;
-
- osm_warn("Aborting command block.\n");
-
- i2o_dev = SCpnt->device->hostdata;
- c = i2o_dev->iop;
- tid = i2o_dev->lct_data.tid;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return SCSI_MLQUEUE_HOST_BUSY;
-
- msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_SCSI_ABORT << 24 | HOST_TID << 12 | tid);
- msg->body[0] = cpu_to_le32(i2o_cntxt_list_get_ptr(c, SCpnt));
-
- if (!i2o_msg_post_wait(c, msg, I2O_TIMEOUT_SCSI_SCB_ABORT))
- status = SUCCESS;
-
- return status;
-}
-
-/**
- * i2o_scsi_bios_param - Invent disk geometry
- * @sdev: scsi device
- * @dev: block layer device
- * @capacity: size in sectors
- * @ip: geometry array
- *
- * This is anyone's guess quite frankly. We use the same rules everyone
- * else appears to and hope. It seems to work.
- */
-
-static int i2o_scsi_bios_param(struct scsi_device *sdev,
- struct block_device *dev, sector_t capacity,
- int *ip)
-{
- int size;
-
- size = capacity;
- ip[0] = 64; /* heads */
- ip[1] = 32; /* sectors */
- if ((ip[2] = size >> 11) > 1024) { /* cylinders, test for big disk */
- ip[0] = 255; /* heads */
- ip[1] = 63; /* sectors */
- ip[2] = size / (255 * 63); /* cylinders */
- }
- return 0;
-}
-
-static struct scsi_host_template i2o_scsi_host_template = {
- .proc_name = OSM_NAME,
- .name = OSM_DESCRIPTION,
- .info = i2o_scsi_info,
- .queuecommand = i2o_scsi_queuecommand,
- .eh_abort_handler = i2o_scsi_abort,
- .bios_param = i2o_scsi_bios_param,
- .can_queue = I2O_SCSI_CAN_QUEUE,
- .sg_tablesize = 8,
- .cmd_per_lun = 6,
- .use_clustering = ENABLE_CLUSTERING,
-};
-
-/**
- * i2o_scsi_init - SCSI OSM initialization function
- *
- * Register SCSI OSM into I2O core.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int __init i2o_scsi_init(void)
-{
- int rc;
-
- printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
-
- /* Register SCSI OSM into I2O core */
- rc = i2o_driver_register(&i2o_scsi_driver);
- if (rc) {
- osm_err("Could not register SCSI driver\n");
- return rc;
- }
-
- return 0;
-};
-
-/**
- * i2o_scsi_exit - SCSI OSM exit function
- *
- * Unregisters SCSI OSM from I2O core.
- */
-static void __exit i2o_scsi_exit(void)
-{
- /* Unregister I2O SCSI OSM from I2O core */
- i2o_driver_unregister(&i2o_scsi_driver);
-};
-
-MODULE_AUTHOR("Red Hat Software");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(OSM_DESCRIPTION);
-MODULE_VERSION(OSM_VERSION);
-
-module_init(i2o_scsi_init);
-module_exit(i2o_scsi_exit);
diff --git a/drivers/staging/i2o/iop.c b/drivers/staging/i2o/iop.c
deleted file mode 100644
index 23bdbe4aa48021..00000000000000
--- a/drivers/staging/i2o/iop.c
+++ /dev/null
@@ -1,1255 +0,0 @@
-/*
- * Functions to handle I2O controllers and I2O message handling
- *
- * Copyright (C) 1999-2002 Red Hat Software
- *
- * Written by Alan Cox, Building Number Three Ltd
- *
- * 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.
- *
- * A lot of the I2O message side code from this is taken from the
- * Red Creek RCPCI45 adapter driver by Red Creek Communications
- *
- * Fixes/additions:
- * Philipp Rumpf
- * Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
- * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
- * Deepak Saxena <deepak@plexity.net>
- * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
- * Alan Cox <alan@lxorguk.ukuu.org.uk>:
- * Ported to Linux 2.5.
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Minor fixes for 2.6.
- */
-
-#include <linux/module.h>
-#include "i2o.h"
-#include <linux/delay.h>
-#include <linux/sched.h>
-#include <linux/slab.h>
-#include "core.h"
-
-#define OSM_NAME "i2o"
-#define OSM_VERSION "1.325"
-#define OSM_DESCRIPTION "I2O subsystem"
-
-/* global I2O controller list */
-LIST_HEAD(i2o_controllers);
-
-/*
- * global I2O System Table. Contains information about all the IOPs in the
- * system. Used to inform IOPs about each others existence.
- */
-static struct i2o_dma i2o_systab;
-
-static int i2o_hrt_get(struct i2o_controller *c);
-
-/**
- * i2o_msg_get_wait - obtain an I2O message from the IOP
- * @c: I2O controller
- * @wait: how long to wait until timeout
- *
- * This function waits up to wait seconds for a message slot to be
- * available.
- *
- * On a success the message is returned and the pointer to the message is
- * set in msg. The returned message is the physical page frame offset
- * address from the read port (see the i2o spec). If no message is
- * available returns I2O_QUEUE_EMPTY and msg is leaved untouched.
- */
-struct i2o_message *i2o_msg_get_wait(struct i2o_controller *c, int wait)
-{
- unsigned long timeout = jiffies + wait * HZ;
- struct i2o_message *msg;
-
- while (IS_ERR(msg = i2o_msg_get(c))) {
- if (time_after(jiffies, timeout)) {
- osm_debug("%s: Timeout waiting for message frame.\n",
- c->name);
- return ERR_PTR(-ETIMEDOUT);
- }
- schedule_timeout_uninterruptible(1);
- }
-
- return msg;
-};
-
-#if BITS_PER_LONG == 64
-/**
- * i2o_cntxt_list_add - Append a pointer to context list and return a id
- * @c: controller to which the context list belong
- * @ptr: pointer to add to the context list
- *
- * Because the context field in I2O is only 32-bit large, on 64-bit the
- * pointer is to large to fit in the context field. The i2o_cntxt_list
- * functions therefore map pointers to context fields.
- *
- * Returns context id > 0 on success or 0 on failure.
- */
-u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
-{
- struct i2o_context_list_element *entry;
- unsigned long flags;
-
- if (!ptr)
- osm_err("%s: couldn't add NULL pointer to context list!\n",
- c->name);
-
- entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
- if (!entry) {
- osm_err("%s: Could not allocate memory for context list element"
- "\n", c->name);
- return 0;
- }
-
- entry->ptr = ptr;
- entry->timestamp = jiffies;
- INIT_LIST_HEAD(&entry->list);
-
- spin_lock_irqsave(&c->context_list_lock, flags);
-
- if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
- atomic_inc(&c->context_list_counter);
-
- entry->context = atomic_read(&c->context_list_counter);
-
- list_add(&entry->list, &c->context_list);
-
- spin_unlock_irqrestore(&c->context_list_lock, flags);
-
- osm_debug("%s: Add context to list %p -> %d\n", c->name, ptr, context);
-
- return entry->context;
-};
-
-/**
- * i2o_cntxt_list_remove - Remove a pointer from the context list
- * @c: controller to which the context list belong
- * @ptr: pointer which should be removed from the context list
- *
- * Removes a previously added pointer from the context list and returns
- * the matching context id.
- *
- * Returns context id on success or 0 on failure.
- */
-u32 i2o_cntxt_list_remove(struct i2o_controller * c, void *ptr)
-{
- struct i2o_context_list_element *entry;
- u32 context = 0;
- unsigned long flags;
-
- spin_lock_irqsave(&c->context_list_lock, flags);
- list_for_each_entry(entry, &c->context_list, list)
- if (entry->ptr == ptr) {
- list_del(&entry->list);
- context = entry->context;
- kfree(entry);
- break;
- }
- spin_unlock_irqrestore(&c->context_list_lock, flags);
-
- if (!context)
- osm_warn("%s: Could not remove nonexistent ptr %p\n", c->name,
- ptr);
-
- osm_debug("%s: remove ptr from context list %d -> %p\n", c->name,
- context, ptr);
-
- return context;
-};
-
-/**
- * i2o_cntxt_list_get - Get a pointer from the context list and remove it
- * @c: controller to which the context list belong
- * @context: context id to which the pointer belong
- *
- * Returns pointer to the matching context id on success or NULL on
- * failure.
- */
-void *i2o_cntxt_list_get(struct i2o_controller *c, u32 context)
-{
- struct i2o_context_list_element *entry;
- unsigned long flags;
- void *ptr = NULL;
-
- spin_lock_irqsave(&c->context_list_lock, flags);
- list_for_each_entry(entry, &c->context_list, list)
- if (entry->context == context) {
- list_del(&entry->list);
- ptr = entry->ptr;
- kfree(entry);
- break;
- }
- spin_unlock_irqrestore(&c->context_list_lock, flags);
-
- if (!ptr)
- osm_warn("%s: context id %d not found\n", c->name, context);
-
- osm_debug("%s: get ptr from context list %d -> %p\n", c->name, context,
- ptr);
-
- return ptr;
-};
-
-/**
- * i2o_cntxt_list_get_ptr - Get a context id from the context list
- * @c: controller to which the context list belong
- * @ptr: pointer to which the context id should be fetched
- *
- * Returns context id which matches to the pointer on success or 0 on
- * failure.
- */
-u32 i2o_cntxt_list_get_ptr(struct i2o_controller * c, void *ptr)
-{
- struct i2o_context_list_element *entry;
- u32 context = 0;
- unsigned long flags;
-
- spin_lock_irqsave(&c->context_list_lock, flags);
- list_for_each_entry(entry, &c->context_list, list)
- if (entry->ptr == ptr) {
- context = entry->context;
- break;
- }
- spin_unlock_irqrestore(&c->context_list_lock, flags);
-
- if (!context)
- osm_warn("%s: Could not find nonexistent ptr %p\n", c->name,
- ptr);
-
- osm_debug("%s: get context id from context list %p -> %d\n", c->name,
- ptr, context);
-
- return context;
-};
-#endif
-
-/**
- * i2o_iop_find - Find an I2O controller by id
- * @unit: unit number of the I2O controller to search for
- *
- * Lookup the I2O controller on the controller list.
- *
- * Returns pointer to the I2O controller on success or NULL if not found.
- */
-struct i2o_controller *i2o_find_iop(int unit)
-{
- struct i2o_controller *c;
-
- list_for_each_entry(c, &i2o_controllers, list) {
- if (c->unit == unit)
- return c;
- }
-
- return NULL;
-};
-
-/**
- * i2o_iop_find_device - Find a I2O device on an I2O controller
- * @c: I2O controller where the I2O device hangs on
- * @tid: TID of the I2O device to search for
- *
- * Searches the devices of the I2O controller for a device with TID tid and
- * returns it.
- *
- * Returns a pointer to the I2O device if found, otherwise NULL.
- */
-struct i2o_device *i2o_iop_find_device(struct i2o_controller *c, u16 tid)
-{
- struct i2o_device *dev;
-
- list_for_each_entry(dev, &c->devices, list)
- if (dev->lct_data.tid == tid)
- return dev;
-
- return NULL;
-};
-
-/**
- * i2o_quiesce_controller - quiesce controller
- * @c: controller
- *
- * Quiesce an IOP. Causes IOP to make external operation quiescent
- * (i2o 'READY' state). Internal operation of the IOP continues normally.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_iop_quiesce(struct i2o_controller *c)
-{
- struct i2o_message *msg;
- i2o_status_block *sb = c->status_block.virt;
- int rc;
-
- i2o_status_get(c);
-
- /* SysQuiesce discarded if IOP not in READY or OPERATIONAL state */
- if ((sb->iop_state != ADAPTER_STATE_READY) &&
- (sb->iop_state != ADAPTER_STATE_OPERATIONAL))
- return 0;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_SYS_QUIESCE << 24 | HOST_TID << 12 |
- ADAPTER_TID);
-
- /* Long timeout needed for quiesce if lots of devices */
- if ((rc = i2o_msg_post_wait(c, msg, 240)))
- osm_info("%s: Unable to quiesce (status=%#x).\n", c->name, -rc);
- else
- osm_debug("%s: Quiesced.\n", c->name);
-
- i2o_status_get(c); // Entered READY state
-
- return rc;
-};
-
-/**
- * i2o_iop_enable - move controller from ready to OPERATIONAL
- * @c: I2O controller
- *
- * Enable IOP. This allows the IOP to resume external operations and
- * reverses the effect of a quiesce. Returns zero or an error code if
- * an error occurs.
- */
-static int i2o_iop_enable(struct i2o_controller *c)
-{
- struct i2o_message *msg;
- i2o_status_block *sb = c->status_block.virt;
- int rc;
-
- i2o_status_get(c);
-
- /* Enable only allowed on READY state */
- if (sb->iop_state != ADAPTER_STATE_READY)
- return -EINVAL;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_SYS_ENABLE << 24 | HOST_TID << 12 |
- ADAPTER_TID);
-
- /* How long of a timeout do we need? */
- if ((rc = i2o_msg_post_wait(c, msg, 240)))
- osm_err("%s: Could not enable (status=%#x).\n", c->name, -rc);
- else
- osm_debug("%s: Enabled.\n", c->name);
-
- i2o_status_get(c); // entered OPERATIONAL state
-
- return rc;
-};
-
-/**
- * i2o_iop_quiesce_all - Quiesce all I2O controllers on the system
- *
- * Quiesce all I2O controllers which are connected to the system.
- */
-static inline void i2o_iop_quiesce_all(void)
-{
- struct i2o_controller *c, *tmp;
-
- list_for_each_entry_safe(c, tmp, &i2o_controllers, list) {
- if (!c->no_quiesce)
- i2o_iop_quiesce(c);
- }
-};
-
-/**
- * i2o_iop_enable_all - Enables all controllers on the system
- *
- * Enables all I2O controllers which are connected to the system.
- */
-static inline void i2o_iop_enable_all(void)
-{
- struct i2o_controller *c, *tmp;
-
- list_for_each_entry_safe(c, tmp, &i2o_controllers, list)
- i2o_iop_enable(c);
-};
-
-/**
- * i2o_clear_controller - Bring I2O controller into HOLD state
- * @c: controller
- *
- * Clear an IOP to HOLD state, ie. terminate external operations, clear all
- * input queues and prepare for a system restart. IOP's internal operation
- * continues normally and the outbound queue is alive. The IOP is not
- * expected to rebuild its LCT.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_iop_clear(struct i2o_controller *c)
-{
- struct i2o_message *msg;
- int rc;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- /* Quiesce all IOPs first */
- i2o_iop_quiesce_all();
-
- msg->u.head[0] = cpu_to_le32(FOUR_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_ADAPTER_CLEAR << 24 | HOST_TID << 12 |
- ADAPTER_TID);
-
- if ((rc = i2o_msg_post_wait(c, msg, 30)))
- osm_info("%s: Unable to clear (status=%#x).\n", c->name, -rc);
- else
- osm_debug("%s: Cleared.\n", c->name);
-
- /* Enable all IOPs */
- i2o_iop_enable_all();
-
- return rc;
-}
-
-/**
- * i2o_iop_init_outbound_queue - setup the outbound message queue
- * @c: I2O controller
- *
- * Clear and (re)initialize IOP's outbound queue and post the message
- * frames to the IOP.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_iop_init_outbound_queue(struct i2o_controller *c)
-{
- u32 m;
- volatile u8 *status = c->status.virt;
- struct i2o_message *msg;
- ulong timeout;
- int i;
-
- osm_debug("%s: Initializing Outbound Queue...\n", c->name);
-
- memset(c->status.virt, 0, 4);
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_6);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_OUTBOUND_INIT << 24 | HOST_TID << 12 |
- ADAPTER_TID);
- msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
- msg->u.s.tcntxt = cpu_to_le32(0x00000000);
- msg->body[0] = cpu_to_le32(PAGE_SIZE);
- /* Outbound msg frame size in words and Initcode */
- msg->body[1] = cpu_to_le32(I2O_OUTBOUND_MSG_FRAME_SIZE << 16 | 0x80);
- msg->body[2] = cpu_to_le32(0xd0000004);
- msg->body[3] = cpu_to_le32(i2o_dma_low(c->status.phys));
- msg->body[4] = cpu_to_le32(i2o_dma_high(c->status.phys));
-
- i2o_msg_post(c, msg);
-
- timeout = jiffies + I2O_TIMEOUT_INIT_OUTBOUND_QUEUE * HZ;
- while (*status <= I2O_CMD_IN_PROGRESS) {
- if (time_after(jiffies, timeout)) {
- osm_warn("%s: Timeout Initializing\n", c->name);
- return -ETIMEDOUT;
- }
- schedule_timeout_uninterruptible(1);
- }
-
- m = c->out_queue.phys;
-
- /* Post frames */
- for (i = 0; i < I2O_MAX_OUTBOUND_MSG_FRAMES; i++) {
- i2o_flush_reply(c, m);
- udelay(1); /* Promise */
- m += I2O_OUTBOUND_MSG_FRAME_SIZE * sizeof(u32);
- }
-
- return 0;
-}
-
-/**
- * i2o_iop_reset - reset an I2O controller
- * @c: controller to reset
- *
- * Reset the IOP into INIT state and wait until IOP gets into RESET state.
- * Terminate all external operations, clear IOP's inbound and outbound
- * queues, terminate all DDMs, and reload the IOP's operating environment
- * and all local DDMs. The IOP rebuilds its LCT.
- */
-static int i2o_iop_reset(struct i2o_controller *c)
-{
- volatile u8 *status = c->status.virt;
- struct i2o_message *msg;
- unsigned long timeout;
- i2o_status_block *sb = c->status_block.virt;
- int rc = 0;
-
- osm_debug("%s: Resetting controller\n", c->name);
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- memset(c->status_block.virt, 0, 8);
-
- /* Quiesce all IOPs first */
- i2o_iop_quiesce_all();
-
- msg->u.head[0] = cpu_to_le32(EIGHT_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_ADAPTER_RESET << 24 | HOST_TID << 12 |
- ADAPTER_TID);
- msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
- msg->u.s.tcntxt = cpu_to_le32(0x00000000);
- msg->body[0] = cpu_to_le32(0x00000000);
- msg->body[1] = cpu_to_le32(0x00000000);
- msg->body[2] = cpu_to_le32(i2o_dma_low(c->status.phys));
- msg->body[3] = cpu_to_le32(i2o_dma_high(c->status.phys));
-
- i2o_msg_post(c, msg);
-
- /* Wait for a reply */
- timeout = jiffies + I2O_TIMEOUT_RESET * HZ;
- while (!*status) {
- if (time_after(jiffies, timeout))
- break;
-
- schedule_timeout_uninterruptible(1);
- }
-
- switch (*status) {
- case I2O_CMD_REJECTED:
- osm_warn("%s: IOP reset rejected\n", c->name);
- rc = -EPERM;
- break;
-
- case I2O_CMD_IN_PROGRESS:
- /*
- * Once the reset is sent, the IOP goes into the INIT state
- * which is indeterminate. We need to wait until the IOP has
- * rebooted before we can let the system talk to it. We read
- * the inbound Free_List until a message is available. If we
- * can't read one in the given amount of time, we assume the
- * IOP could not reboot properly.
- */
- osm_debug("%s: Reset in progress, waiting for reboot...\n",
- c->name);
-
- while (IS_ERR(msg = i2o_msg_get_wait(c, I2O_TIMEOUT_RESET))) {
- if (time_after(jiffies, timeout)) {
- osm_err("%s: IOP reset timeout.\n", c->name);
- rc = PTR_ERR(msg);
- goto exit;
- }
- schedule_timeout_uninterruptible(1);
- }
- i2o_msg_nop(c, msg);
-
- /* from here all quiesce commands are safe */
- c->no_quiesce = 0;
-
- /* verify if controller is in state RESET */
- i2o_status_get(c);
-
- if (!c->promise && (sb->iop_state != ADAPTER_STATE_RESET))
- osm_warn("%s: reset completed, but adapter not in RESET"
- " state.\n", c->name);
- else
- osm_debug("%s: reset completed.\n", c->name);
-
- break;
-
- default:
- osm_err("%s: IOP reset timeout.\n", c->name);
- rc = -ETIMEDOUT;
- break;
- }
-
- exit:
- /* Enable all IOPs */
- i2o_iop_enable_all();
-
- return rc;
-};
-
-/**
- * i2o_iop_activate - Bring controller up to HOLD
- * @c: controller
- *
- * This function brings an I2O controller into HOLD state. The adapter
- * is reset if necessary and then the queues and resource table are read.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_iop_activate(struct i2o_controller *c)
-{
- i2o_status_block *sb = c->status_block.virt;
- int rc;
- int state;
-
- /* In INIT state, Wait Inbound Q to initialize (in i2o_status_get) */
- /* In READY state, Get status */
-
- rc = i2o_status_get(c);
- if (rc) {
- osm_info("%s: Unable to obtain status, attempting a reset.\n",
- c->name);
- rc = i2o_iop_reset(c);
- if (rc)
- return rc;
- }
-
- if (sb->i2o_version > I2OVER15) {
- osm_err("%s: Not running version 1.5 of the I2O Specification."
- "\n", c->name);
- return -ENODEV;
- }
-
- switch (sb->iop_state) {
- case ADAPTER_STATE_FAULTED:
- osm_err("%s: hardware fault\n", c->name);
- return -EFAULT;
-
- case ADAPTER_STATE_READY:
- case ADAPTER_STATE_OPERATIONAL:
- case ADAPTER_STATE_HOLD:
- case ADAPTER_STATE_FAILED:
- osm_debug("%s: already running, trying to reset...\n", c->name);
- rc = i2o_iop_reset(c);
- if (rc)
- return rc;
- }
-
- /* preserve state */
- state = sb->iop_state;
-
- rc = i2o_iop_init_outbound_queue(c);
- if (rc)
- return rc;
-
- /* if adapter was not in RESET state clear now */
- if (state != ADAPTER_STATE_RESET)
- i2o_iop_clear(c);
-
- i2o_status_get(c);
-
- if (sb->iop_state != ADAPTER_STATE_HOLD) {
- osm_err("%s: failed to bring IOP into HOLD state\n", c->name);
- return -EIO;
- }
-
- return i2o_hrt_get(c);
-};
-
-static void i2o_res_alloc(struct i2o_controller *c, unsigned long flags)
-{
- i2o_status_block *sb = c->status_block.virt;
- struct resource *res = &c->mem_resource;
- resource_size_t size, align;
- int err;
-
- res->name = c->pdev->bus->name;
- res->flags = flags;
- res->start = 0;
- res->end = 0;
- osm_info("%s: requires private memory resources.\n", c->name);
-
- if (flags & IORESOURCE_MEM) {
- size = sb->desired_mem_size;
- align = 1 << 20; /* unspecified, use 1Mb and play safe */
- } else {
- size = sb->desired_io_size;
- align = 1 << 12; /* unspecified, use 4Kb and play safe */
- }
-
- err = pci_bus_alloc_resource(c->pdev->bus, res, size, align, 0, 0,
- NULL, NULL);
- if (err < 0)
- return;
-
- if (flags & IORESOURCE_MEM) {
- c->mem_alloc = 1;
- sb->current_mem_size = resource_size(res);
- sb->current_mem_base = res->start;
- } else if (flags & IORESOURCE_IO) {
- c->io_alloc = 1;
- sb->current_io_size = resource_size(res);
- sb->current_io_base = res->start;
- }
- osm_info("%s: allocated PCI space %pR\n", c->name, res);
-}
-
-/**
- * i2o_iop_systab_set - Set the I2O System Table of the specified IOP
- * @c: I2O controller to which the system table should be send
- *
- * Before the systab could be set i2o_systab_build() must be called.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_iop_systab_set(struct i2o_controller *c)
-{
- struct i2o_message *msg;
- i2o_status_block *sb = c->status_block.virt;
- struct device *dev = &c->pdev->dev;
- int rc;
-
- if (sb->current_mem_size < sb->desired_mem_size)
- i2o_res_alloc(c, IORESOURCE_MEM);
-
- if (sb->current_io_size < sb->desired_io_size)
- i2o_res_alloc(c, IORESOURCE_IO);
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- i2o_systab.phys = dma_map_single(dev, i2o_systab.virt, i2o_systab.len,
- PCI_DMA_TODEVICE);
- if (!i2o_systab.phys) {
- i2o_msg_nop(c, msg);
- return -ENOMEM;
- }
-
- msg->u.head[0] = cpu_to_le32(I2O_MESSAGE_SIZE(12) | SGL_OFFSET_6);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_SYS_TAB_SET << 24 | HOST_TID << 12 |
- ADAPTER_TID);
-
- /*
- * Provide three SGL-elements:
- * System table (SysTab), Private memory space declaration and
- * Private i/o space declaration
- */
-
- msg->body[0] = cpu_to_le32(c->unit + 2);
- msg->body[1] = cpu_to_le32(0x00000000);
- msg->body[2] = cpu_to_le32(0x54000000 | i2o_systab.len);
- msg->body[3] = cpu_to_le32(i2o_systab.phys);
- msg->body[4] = cpu_to_le32(0x54000000 | sb->current_mem_size);
- msg->body[5] = cpu_to_le32(sb->current_mem_base);
- msg->body[6] = cpu_to_le32(0xd4000000 | sb->current_io_size);
- msg->body[6] = cpu_to_le32(sb->current_io_base);
-
- rc = i2o_msg_post_wait(c, msg, 120);
-
- dma_unmap_single(dev, i2o_systab.phys, i2o_systab.len,
- PCI_DMA_TODEVICE);
-
- if (rc < 0)
- osm_err("%s: Unable to set SysTab (status=%#x).\n", c->name,
- -rc);
- else
- osm_debug("%s: SysTab set.\n", c->name);
-
- return rc;
-}
-
-/**
- * i2o_iop_online - Bring a controller online into OPERATIONAL state.
- * @c: I2O controller
- *
- * Send the system table and enable the I2O controller.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_iop_online(struct i2o_controller *c)
-{
- int rc;
-
- rc = i2o_iop_systab_set(c);
- if (rc)
- return rc;
-
- /* In READY state */
- osm_debug("%s: Attempting to enable...\n", c->name);
- rc = i2o_iop_enable(c);
- if (rc)
- return rc;
-
- return 0;
-};
-
-/**
- * i2o_iop_remove - Remove the I2O controller from the I2O core
- * @c: I2O controller
- *
- * Remove the I2O controller from the I2O core. If devices are attached to
- * the controller remove these also and finally reset the controller.
- */
-void i2o_iop_remove(struct i2o_controller *c)
-{
- struct i2o_device *dev, *tmp;
-
- osm_debug("%s: deleting controller\n", c->name);
-
- i2o_driver_notify_controller_remove_all(c);
-
- list_del(&c->list);
-
- list_for_each_entry_safe(dev, tmp, &c->devices, list)
- i2o_device_remove(dev);
-
- device_del(&c->device);
-
- /* Ask the IOP to switch to RESET state */
- i2o_iop_reset(c);
-}
-
-/**
- * i2o_systab_build - Build system table
- *
- * The system table contains information about all the IOPs in the system
- * (duh) and is used by the Executives on the IOPs to establish peer2peer
- * connections. We're not supporting peer2peer at the moment, but this
- * will be needed down the road for things like lan2lan forwarding.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_systab_build(void)
-{
- struct i2o_controller *c, *tmp;
- int num_controllers = 0;
- u32 change_ind = 0;
- int count = 0;
- struct i2o_sys_tbl *systab = i2o_systab.virt;
-
- list_for_each_entry_safe(c, tmp, &i2o_controllers, list)
- num_controllers++;
-
- if (systab) {
- change_ind = systab->change_ind;
- kfree(i2o_systab.virt);
- }
-
- /* Header + IOPs */
- i2o_systab.len = sizeof(struct i2o_sys_tbl) + num_controllers *
- sizeof(struct i2o_sys_tbl_entry);
-
- systab = i2o_systab.virt = kzalloc(i2o_systab.len, GFP_KERNEL);
- if (!systab) {
- osm_err("unable to allocate memory for System Table\n");
- return -ENOMEM;
- }
-
- systab->version = I2OVERSION;
- systab->change_ind = change_ind + 1;
-
- list_for_each_entry_safe(c, tmp, &i2o_controllers, list) {
- i2o_status_block *sb;
-
- if (count >= num_controllers) {
- osm_err("controller added while building system table"
- "\n");
- break;
- }
-
- sb = c->status_block.virt;
-
- /*
- * Get updated IOP state so we have the latest information
- *
- * We should delete the controller at this point if it
- * doesn't respond since if it's not on the system table
- * it is techninically not part of the I2O subsystem...
- */
- if (unlikely(i2o_status_get(c))) {
- osm_err("%s: Deleting b/c could not get status while "
- "attempting to build system table\n", c->name);
- i2o_iop_remove(c);
- continue; // try the next one
- }
-
- systab->iops[count].org_id = sb->org_id;
- systab->iops[count].iop_id = c->unit + 2;
- systab->iops[count].seg_num = 0;
- systab->iops[count].i2o_version = sb->i2o_version;
- systab->iops[count].iop_state = sb->iop_state;
- systab->iops[count].msg_type = sb->msg_type;
- systab->iops[count].frame_size = sb->inbound_frame_size;
- systab->iops[count].last_changed = change_ind;
- systab->iops[count].iop_capabilities = sb->iop_capabilities;
- systab->iops[count].inbound_low =
- i2o_dma_low(c->base.phys + I2O_IN_PORT);
- systab->iops[count].inbound_high =
- i2o_dma_high(c->base.phys + I2O_IN_PORT);
-
- count++;
- }
-
- systab->num_entries = count;
-
- return 0;
-};
-
-/**
- * i2o_parse_hrt - Parse the hardware resource table.
- * @c: I2O controller
- *
- * We don't do anything with it except dumping it (in debug mode).
- *
- * Returns 0.
- */
-static int i2o_parse_hrt(struct i2o_controller *c)
-{
- i2o_dump_hrt(c);
- return 0;
-};
-
-/**
- * i2o_status_get - Get the status block from the I2O controller
- * @c: I2O controller
- *
- * Issue a status query on the controller. This updates the attached
- * status block. The status block could then be accessed through
- * c->status_block.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_status_get(struct i2o_controller *c)
-{
- struct i2o_message *msg;
- volatile u8 *status_block;
- unsigned long timeout;
-
- status_block = (u8 *) c->status_block.virt;
- memset(c->status_block.virt, 0, sizeof(i2o_status_block));
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(NINE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_STATUS_GET << 24 | HOST_TID << 12 |
- ADAPTER_TID);
- msg->u.s.icntxt = cpu_to_le32(i2o_exec_driver.context);
- msg->u.s.tcntxt = cpu_to_le32(0x00000000);
- msg->body[0] = cpu_to_le32(0x00000000);
- msg->body[1] = cpu_to_le32(0x00000000);
- msg->body[2] = cpu_to_le32(i2o_dma_low(c->status_block.phys));
- msg->body[3] = cpu_to_le32(i2o_dma_high(c->status_block.phys));
- msg->body[4] = cpu_to_le32(sizeof(i2o_status_block)); /* always 88 bytes */
-
- i2o_msg_post(c, msg);
-
- /* Wait for a reply */
- timeout = jiffies + I2O_TIMEOUT_STATUS_GET * HZ;
- while (status_block[87] != 0xFF) {
- if (time_after(jiffies, timeout)) {
- osm_err("%s: Get status timeout.\n", c->name);
- return -ETIMEDOUT;
- }
-
- schedule_timeout_uninterruptible(1);
- }
-
-#ifdef DEBUG
- i2o_debug_state(c);
-#endif
-
- return 0;
-}
-
-/*
- * i2o_hrt_get - Get the Hardware Resource Table from the I2O controller
- * @c: I2O controller from which the HRT should be fetched
- *
- * The HRT contains information about possible hidden devices but is
- * mostly useless to us.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_hrt_get(struct i2o_controller *c)
-{
- int rc;
- int i;
- i2o_hrt *hrt = c->hrt.virt;
- u32 size = sizeof(i2o_hrt);
- struct device *dev = &c->pdev->dev;
-
- for (i = 0; i < I2O_HRT_GET_TRIES; i++) {
- struct i2o_message *msg;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(SIX_WORD_MSG_SIZE | SGL_OFFSET_4);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_HRT_GET << 24 | HOST_TID << 12 |
- ADAPTER_TID);
- msg->body[0] = cpu_to_le32(0xd0000000 | c->hrt.len);
- msg->body[1] = cpu_to_le32(c->hrt.phys);
-
- rc = i2o_msg_post_wait_mem(c, msg, 20, &c->hrt);
-
- if (rc < 0) {
- osm_err("%s: Unable to get HRT (status=%#x)\n", c->name,
- -rc);
- return rc;
- }
-
- size = hrt->num_entries * hrt->entry_len << 2;
- if (size > c->hrt.len) {
- if (i2o_dma_realloc(dev, &c->hrt, size))
- return -ENOMEM;
- else
- hrt = c->hrt.virt;
- } else
- return i2o_parse_hrt(c);
- }
-
- osm_err("%s: Unable to get HRT after %d tries, giving up\n", c->name,
- I2O_HRT_GET_TRIES);
-
- return -EBUSY;
-}
-
-/**
- * i2o_iop_release - release the memory for a I2O controller
- * @dev: I2O controller which should be released
- *
- * Release the allocated memory. This function is called if refcount of
- * device reaches 0 automatically.
- */
-static void i2o_iop_release(struct device *dev)
-{
- struct i2o_controller *c = to_i2o_controller(dev);
-
- i2o_iop_free(c);
-};
-
-/**
- * i2o_iop_alloc - Allocate and initialize a i2o_controller struct
- *
- * Allocate the necessary memory for a i2o_controller struct and
- * initialize the lists and message mempool.
- *
- * Returns a pointer to the I2O controller or a negative error code on
- * failure.
- */
-struct i2o_controller *i2o_iop_alloc(void)
-{
- static int unit; /* 0 and 1 are NULL IOP and Local Host */
- struct i2o_controller *c;
- char poolname[32];
-
- c = kzalloc(sizeof(*c), GFP_KERNEL);
- if (!c) {
- osm_err("i2o: Insufficient memory to allocate a I2O controller."
- "\n");
- return ERR_PTR(-ENOMEM);
- }
-
- c->unit = unit++;
- sprintf(c->name, "iop%d", c->unit);
-
- snprintf(poolname, sizeof(poolname), "i2o_%s_msg_inpool", c->name);
- if (i2o_pool_alloc
- (&c->in_msg, poolname, I2O_INBOUND_MSG_FRAME_SIZE * 4 + sizeof(u32),
- I2O_MSG_INPOOL_MIN)) {
- kfree(c);
- return ERR_PTR(-ENOMEM);
- };
-
- INIT_LIST_HEAD(&c->devices);
- spin_lock_init(&c->lock);
- mutex_init(&c->lct_lock);
-
- device_initialize(&c->device);
-
- c->device.release = &i2o_iop_release;
-
- dev_set_name(&c->device, "iop%d", c->unit);
-
-#if BITS_PER_LONG == 64
- spin_lock_init(&c->context_list_lock);
- atomic_set(&c->context_list_counter, 0);
- INIT_LIST_HEAD(&c->context_list);
-#endif
-
- return c;
-};
-
-/**
- * i2o_iop_add - Initialize the I2O controller and add him to the I2O core
- * @c: controller
- *
- * Initialize the I2O controller and if no error occurs add him to the I2O
- * core.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_iop_add(struct i2o_controller *c)
-{
- int rc;
-
- rc = device_add(&c->device);
- if (rc) {
- osm_err("%s: could not add controller\n", c->name);
- goto iop_reset;
- }
-
- osm_info("%s: Activating I2O controller...\n", c->name);
- osm_info("%s: This may take a few minutes if there are many devices\n",
- c->name);
-
- rc = i2o_iop_activate(c);
- if (rc) {
- osm_err("%s: could not activate controller\n", c->name);
- goto device_del;
- }
-
- osm_debug("%s: building sys table...\n", c->name);
-
- rc = i2o_systab_build();
- if (rc)
- goto device_del;
-
- osm_debug("%s: online controller...\n", c->name);
-
- rc = i2o_iop_online(c);
- if (rc)
- goto device_del;
-
- osm_debug("%s: getting LCT...\n", c->name);
-
- rc = i2o_exec_lct_get(c);
- if (rc)
- goto device_del;
-
- list_add(&c->list, &i2o_controllers);
-
- i2o_driver_notify_controller_add_all(c);
-
- osm_info("%s: Controller added\n", c->name);
-
- return 0;
-
- device_del:
- device_del(&c->device);
-
- iop_reset:
- i2o_iop_reset(c);
-
- return rc;
-};
-
-/**
- * i2o_event_register - Turn on/off event notification for a I2O device
- * @dev: I2O device which should receive the event registration request
- * @drv: driver which want to get notified
- * @tcntxt: transaction context to use with this notifier
- * @evt_mask: mask of events
- *
- * Create and posts an event registration message to the task. No reply
- * is waited for, or expected. If you do not want further notifications,
- * call the i2o_event_register again with a evt_mask of 0.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_event_register(struct i2o_device *dev, struct i2o_driver *drv,
- int tcntxt, u32 evt_mask)
-{
- struct i2o_controller *c = dev->iop;
- struct i2o_message *msg;
-
- msg = i2o_msg_get_wait(c, I2O_TIMEOUT_MESSAGE_GET);
- if (IS_ERR(msg))
- return PTR_ERR(msg);
-
- msg->u.head[0] = cpu_to_le32(FIVE_WORD_MSG_SIZE | SGL_OFFSET_0);
- msg->u.head[1] =
- cpu_to_le32(I2O_CMD_UTIL_EVT_REGISTER << 24 | HOST_TID << 12 | dev->
- lct_data.tid);
- msg->u.s.icntxt = cpu_to_le32(drv->context);
- msg->u.s.tcntxt = cpu_to_le32(tcntxt);
- msg->body[0] = cpu_to_le32(evt_mask);
-
- i2o_msg_post(c, msg);
-
- return 0;
-};
-
-/**
- * i2o_iop_init - I2O main initialization function
- *
- * Initialize the I2O drivers (OSM) functions, register the Executive OSM,
- * initialize the I2O PCI part and finally initialize I2O device stuff.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int __init i2o_iop_init(void)
-{
- int rc = 0;
-
- printk(KERN_INFO OSM_DESCRIPTION " v" OSM_VERSION "\n");
-
- rc = i2o_driver_init();
- if (rc)
- goto exit;
-
- rc = i2o_exec_init();
- if (rc)
- goto driver_exit;
-
- rc = i2o_pci_init();
- if (rc)
- goto exec_exit;
-
- return 0;
-
- exec_exit:
- i2o_exec_exit();
-
- driver_exit:
- i2o_driver_exit();
-
- exit:
- return rc;
-}
-
-/**
- * i2o_iop_exit - I2O main exit function
- *
- * Removes I2O controllers from PCI subsystem and shut down OSMs.
- */
-static void __exit i2o_iop_exit(void)
-{
- i2o_pci_exit();
- i2o_exec_exit();
- i2o_driver_exit();
-};
-
-module_init(i2o_iop_init);
-module_exit(i2o_iop_exit);
-
-MODULE_AUTHOR("Red Hat Software");
-MODULE_LICENSE("GPL");
-MODULE_DESCRIPTION(OSM_DESCRIPTION);
-MODULE_VERSION(OSM_VERSION);
-
-#if BITS_PER_LONG == 64
-EXPORT_SYMBOL(i2o_cntxt_list_add);
-EXPORT_SYMBOL(i2o_cntxt_list_get);
-EXPORT_SYMBOL(i2o_cntxt_list_remove);
-EXPORT_SYMBOL(i2o_cntxt_list_get_ptr);
-#endif
-EXPORT_SYMBOL(i2o_msg_get_wait);
-EXPORT_SYMBOL(i2o_find_iop);
-EXPORT_SYMBOL(i2o_iop_find_device);
-EXPORT_SYMBOL(i2o_event_register);
-EXPORT_SYMBOL(i2o_status_get);
-EXPORT_SYMBOL(i2o_controllers);
diff --git a/drivers/staging/i2o/memory.c b/drivers/staging/i2o/memory.c
deleted file mode 100644
index 78b702c185371b..00000000000000
--- a/drivers/staging/i2o/memory.c
+++ /dev/null
@@ -1,312 +0,0 @@
-/*
- * Functions to handle I2O memory
- *
- * Pulled from the inlines in i2o headers and uninlined
- *
- *
- * 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 "i2o.h"
-#include <linux/delay.h>
-#include <linux/string.h>
-#include <linux/slab.h>
-#include "core.h"
-
-/* Protects our 32/64bit mask switching */
-static DEFINE_MUTEX(mem_lock);
-
-/**
- * i2o_sg_tablesize - Calculate the maximum number of elements in a SGL
- * @c: I2O controller for which the calculation should be done
- * @body_size: maximum body size used for message in 32-bit words.
- *
- * Return the maximum number of SG elements in a SG list.
- */
-u16 i2o_sg_tablesize(struct i2o_controller *c, u16 body_size)
-{
- i2o_status_block *sb = c->status_block.virt;
- u16 sg_count =
- (sb->inbound_frame_size - sizeof(struct i2o_message) / 4) -
- body_size;
-
- if (c->pae_support) {
- /*
- * for 64-bit a SG attribute element must be added and each
- * SG element needs 12 bytes instead of 8.
- */
- sg_count -= 2;
- sg_count /= 3;
- } else
- sg_count /= 2;
-
- if (c->short_req && (sg_count > 8))
- sg_count = 8;
-
- return sg_count;
-}
-EXPORT_SYMBOL_GPL(i2o_sg_tablesize);
-
-
-/**
- * i2o_dma_map_single - Map pointer to controller and fill in I2O message.
- * @c: I2O controller
- * @ptr: pointer to the data which should be mapped
- * @size: size of data in bytes
- * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
- * @sg_ptr: pointer to the SG list inside the I2O message
- *
- * This function does all necessary DMA handling and also writes the I2O
- * SGL elements into the I2O message. For details on DMA handling see also
- * dma_map_single(). The pointer sg_ptr will only be set to the end of the
- * SG list if the allocation was successful.
- *
- * Returns DMA address which must be checked for failures using
- * dma_mapping_error().
- */
-dma_addr_t i2o_dma_map_single(struct i2o_controller *c, void *ptr,
- size_t size,
- enum dma_data_direction direction,
- u32 ** sg_ptr)
-{
- u32 sg_flags;
- u32 *mptr = *sg_ptr;
- dma_addr_t dma_addr;
-
- switch (direction) {
- case DMA_TO_DEVICE:
- sg_flags = 0xd4000000;
- break;
- case DMA_FROM_DEVICE:
- sg_flags = 0xd0000000;
- break;
- default:
- return 0;
- }
-
- dma_addr = dma_map_single(&c->pdev->dev, ptr, size, direction);
- if (!dma_mapping_error(&c->pdev->dev, dma_addr)) {
-#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
- if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
- *mptr++ = cpu_to_le32(0x7C020002);
- *mptr++ = cpu_to_le32(PAGE_SIZE);
- }
-#endif
-
- *mptr++ = cpu_to_le32(sg_flags | size);
- *mptr++ = cpu_to_le32(i2o_dma_low(dma_addr));
-#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
- if ((sizeof(dma_addr_t) > 4) && c->pae_support)
- *mptr++ = cpu_to_le32(i2o_dma_high(dma_addr));
-#endif
- *sg_ptr = mptr;
- }
- return dma_addr;
-}
-EXPORT_SYMBOL_GPL(i2o_dma_map_single);
-
-/**
- * i2o_dma_map_sg - Map a SG List to controller and fill in I2O message.
- * @c: I2O controller
- * @sg: SG list to be mapped
- * @sg_count: number of elements in the SG list
- * @direction: DMA_TO_DEVICE / DMA_FROM_DEVICE
- * @sg_ptr: pointer to the SG list inside the I2O message
- *
- * This function does all necessary DMA handling and also writes the I2O
- * SGL elements into the I2O message. For details on DMA handling see also
- * dma_map_sg(). The pointer sg_ptr will only be set to the end of the SG
- * list if the allocation was successful.
- *
- * Returns 0 on failure or 1 on success.
- */
-int i2o_dma_map_sg(struct i2o_controller *c, struct scatterlist *sg,
- int sg_count, enum dma_data_direction direction, u32 ** sg_ptr)
-{
- u32 sg_flags;
- u32 *mptr = *sg_ptr;
-
- switch (direction) {
- case DMA_TO_DEVICE:
- sg_flags = 0x14000000;
- break;
- case DMA_FROM_DEVICE:
- sg_flags = 0x10000000;
- break;
- default:
- return 0;
- }
-
- sg_count = dma_map_sg(&c->pdev->dev, sg, sg_count, direction);
- if (!sg_count)
- return 0;
-
-#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
- if ((sizeof(dma_addr_t) > 4) && c->pae_support) {
- *mptr++ = cpu_to_le32(0x7C020002);
- *mptr++ = cpu_to_le32(PAGE_SIZE);
- }
-#endif
-
- while (sg_count-- > 0) {
- if (!sg_count)
- sg_flags |= 0xC0000000;
- *mptr++ = cpu_to_le32(sg_flags | sg_dma_len(sg));
- *mptr++ = cpu_to_le32(i2o_dma_low(sg_dma_address(sg)));
-#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
- if ((sizeof(dma_addr_t) > 4) && c->pae_support)
- *mptr++ = cpu_to_le32(i2o_dma_high(sg_dma_address(sg)));
-#endif
- sg = sg_next(sg);
- }
- *sg_ptr = mptr;
-
- return 1;
-}
-EXPORT_SYMBOL_GPL(i2o_dma_map_sg);
-
-/**
- * i2o_dma_alloc - Allocate DMA memory
- * @dev: struct device pointer to the PCI device of the I2O controller
- * @addr: i2o_dma struct which should get the DMA buffer
- * @len: length of the new DMA memory
- *
- * Allocate a coherent DMA memory and write the pointers into addr.
- *
- * Returns 0 on success or -ENOMEM on failure.
- */
-int i2o_dma_alloc(struct device *dev, struct i2o_dma *addr, size_t len)
-{
- struct pci_dev *pdev = to_pci_dev(dev);
- int dma_64 = 0;
-
- mutex_lock(&mem_lock);
- if ((sizeof(dma_addr_t) > 4) && (pdev->dma_mask == DMA_BIT_MASK(64))) {
- dma_64 = 1;
- if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
- mutex_unlock(&mem_lock);
- return -ENOMEM;
- }
- }
-
- addr->virt = dma_alloc_coherent(dev, len, &addr->phys, GFP_KERNEL);
-
- if ((sizeof(dma_addr_t) > 4) && dma_64)
- if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
- printk(KERN_WARNING "i2o: unable to set 64-bit DMA");
- mutex_unlock(&mem_lock);
-
- if (!addr->virt)
- return -ENOMEM;
-
- memset(addr->virt, 0, len);
- addr->len = len;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(i2o_dma_alloc);
-
-
-/**
- * i2o_dma_free - Free DMA memory
- * @dev: struct device pointer to the PCI device of the I2O controller
- * @addr: i2o_dma struct which contains the DMA buffer
- *
- * Free a coherent DMA memory and set virtual address of addr to NULL.
- */
-void i2o_dma_free(struct device *dev, struct i2o_dma *addr)
-{
- if (addr->virt) {
- if (addr->phys)
- dma_free_coherent(dev, addr->len, addr->virt,
- addr->phys);
- else
- kfree(addr->virt);
- addr->virt = NULL;
- }
-}
-EXPORT_SYMBOL_GPL(i2o_dma_free);
-
-
-/**
- * i2o_dma_realloc - Realloc DMA memory
- * @dev: struct device pointer to the PCI device of the I2O controller
- * @addr: pointer to a i2o_dma struct DMA buffer
- * @len: new length of memory
- *
- * If there was something allocated in the addr, free it first. If len > 0
- * than try to allocate it and write the addresses back to the addr
- * structure. If len == 0 set the virtual address to NULL.
- *
- * Returns the 0 on success or negative error code on failure.
- */
-int i2o_dma_realloc(struct device *dev, struct i2o_dma *addr, size_t len)
-{
- i2o_dma_free(dev, addr);
-
- if (len)
- return i2o_dma_alloc(dev, addr, len);
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(i2o_dma_realloc);
-
-/*
- * i2o_pool_alloc - Allocate an slab cache and mempool
- * @mempool: pointer to struct i2o_pool to write data into.
- * @name: name which is used to identify cache
- * @size: size of each object
- * @min_nr: minimum number of objects
- *
- * First allocates a slab cache with name and size. Then allocates a
- * mempool which uses the slab cache for allocation and freeing.
- *
- * Returns 0 on success or negative error code on failure.
- */
-int i2o_pool_alloc(struct i2o_pool *pool, const char *name,
- size_t size, int min_nr)
-{
- pool->name = kstrdup(name, GFP_KERNEL);
- if (!pool->name)
- goto exit;
-
- pool->slab =
- kmem_cache_create(pool->name, size, 0, SLAB_HWCACHE_ALIGN, NULL);
- if (!pool->slab)
- goto free_name;
-
- pool->mempool = mempool_create_slab_pool(min_nr, pool->slab);
- if (!pool->mempool)
- goto free_slab;
-
- return 0;
-
-free_slab:
- kmem_cache_destroy(pool->slab);
-
-free_name:
- kfree(pool->name);
-
-exit:
- return -ENOMEM;
-}
-EXPORT_SYMBOL_GPL(i2o_pool_alloc);
-
-/*
- * i2o_pool_free - Free slab cache and mempool again
- * @mempool: pointer to struct i2o_pool which should be freed
- *
- * Note that you have to return all objects to the mempool again before
- * calling i2o_pool_free().
- */
-void i2o_pool_free(struct i2o_pool *pool)
-{
- mempool_destroy(pool->mempool);
- kmem_cache_destroy(pool->slab);
- kfree(pool->name);
-};
-EXPORT_SYMBOL_GPL(i2o_pool_free);
diff --git a/drivers/staging/i2o/pci.c b/drivers/staging/i2o/pci.c
deleted file mode 100644
index 49804c9cf74f23..00000000000000
--- a/drivers/staging/i2o/pci.c
+++ /dev/null
@@ -1,500 +0,0 @@
-/*
- * PCI handling of I2O controller
- *
- * Copyright (C) 1999-2002 Red Hat Software
- *
- * Written by Alan Cox, Building Number Three Ltd
- *
- * 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.
- *
- * A lot of the I2O message side code from this is taken from the Red
- * Creek RCPCI45 adapter driver by Red Creek Communications
- *
- * Fixes/additions:
- * Philipp Rumpf
- * Juha Sievänen <Juha.Sievanen@cs.Helsinki.FI>
- * Auvo Häkkinen <Auvo.Hakkinen@cs.Helsinki.FI>
- * Deepak Saxena <deepak@plexity.net>
- * Boji T Kannanthanam <boji.t.kannanthanam@intel.com>
- * Alan Cox <alan@lxorguk.ukuu.org.uk>:
- * Ported to Linux 2.5.
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Minor fixes for 2.6.
- * Markus Lidel <Markus.Lidel@shadowconnect.com>:
- * Support for sysfs included.
- */
-
-#include <linux/pci.h>
-#include <linux/interrupt.h>
-#include <linux/slab.h>
-#include "i2o.h"
-#include <linux/module.h>
-#include "core.h"
-
-#define OSM_DESCRIPTION "I2O-subsystem"
-
-/* PCI device id table for all I2O controllers */
-static struct pci_device_id i2o_pci_ids[] = {
- {PCI_DEVICE_CLASS(PCI_CLASS_INTELLIGENT_I2O << 8, 0xffff00)},
- {PCI_DEVICE(PCI_VENDOR_ID_DPT, 0xa511)},
- {.vendor = PCI_VENDOR_ID_INTEL,.device = 0x1962,
- .subvendor = PCI_VENDOR_ID_PROMISE,.subdevice = PCI_ANY_ID},
- {0}
-};
-
-/**
- * i2o_pci_free - Frees the DMA memory for the I2O controller
- * @c: I2O controller to free
- *
- * Remove all allocated DMA memory and unmap memory IO regions. If MTRR
- * is enabled, also remove it again.
- */
-static void i2o_pci_free(struct i2o_controller *c)
-{
- struct device *dev;
-
- dev = &c->pdev->dev;
-
- i2o_dma_free(dev, &c->out_queue);
- i2o_dma_free(dev, &c->status_block);
- kfree(c->lct);
- i2o_dma_free(dev, &c->dlct);
- i2o_dma_free(dev, &c->hrt);
- i2o_dma_free(dev, &c->status);
-
- if (c->raptor && c->in_queue.virt)
- iounmap(c->in_queue.virt);
-
- if (c->base.virt)
- iounmap(c->base.virt);
-
- pci_release_regions(c->pdev);
-}
-
-/**
- * i2o_pci_alloc - Allocate DMA memory, map IO memory for I2O controller
- * @c: I2O controller
- *
- * Allocate DMA memory for a PCI (or in theory AGP) I2O controller. All
- * IO mappings are also done here. If MTRR is enabled, also do add memory
- * regions here.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_pci_alloc(struct i2o_controller *c)
-{
- struct pci_dev *pdev = c->pdev;
- struct device *dev = &pdev->dev;
- int i;
-
- if (pci_request_regions(pdev, OSM_DESCRIPTION)) {
- printk(KERN_ERR "%s: device already claimed\n", c->name);
- return -ENODEV;
- }
-
- for (i = 0; i < 6; i++) {
- /* Skip I/O spaces */
- if (!(pci_resource_flags(pdev, i) & IORESOURCE_IO)) {
- if (!c->base.phys) {
- c->base.phys = pci_resource_start(pdev, i);
- c->base.len = pci_resource_len(pdev, i);
-
- /*
- * If we know what card it is, set the size
- * correctly. Code is taken from dpt_i2o.c
- */
- if (pdev->device == 0xa501) {
- if (pdev->subsystem_device >= 0xc032 &&
- pdev->subsystem_device <= 0xc03b) {
- if (c->base.len > 0x400000)
- c->base.len = 0x400000;
- } else {
- if (c->base.len > 0x100000)
- c->base.len = 0x100000;
- }
- }
- if (!c->raptor)
- break;
- } else {
- c->in_queue.phys = pci_resource_start(pdev, i);
- c->in_queue.len = pci_resource_len(pdev, i);
- break;
- }
- }
- }
-
- if (i == 6) {
- printk(KERN_ERR "%s: I2O controller has no memory regions"
- " defined.\n", c->name);
- i2o_pci_free(c);
- return -EINVAL;
- }
-
- /* Map the I2O controller */
- if (c->raptor) {
- printk(KERN_INFO "%s: PCI I2O controller\n", c->name);
- printk(KERN_INFO " BAR0 at 0x%08lX size=%ld\n",
- (unsigned long)c->base.phys, (unsigned long)c->base.len);
- printk(KERN_INFO " BAR1 at 0x%08lX size=%ld\n",
- (unsigned long)c->in_queue.phys,
- (unsigned long)c->in_queue.len);
- } else
- printk(KERN_INFO "%s: PCI I2O controller at %08lX size=%ld\n",
- c->name, (unsigned long)c->base.phys,
- (unsigned long)c->base.len);
-
- c->base.virt = ioremap_nocache(c->base.phys, c->base.len);
- if (!c->base.virt) {
- printk(KERN_ERR "%s: Unable to map controller.\n", c->name);
- i2o_pci_free(c);
- return -ENOMEM;
- }
-
- if (c->raptor) {
- c->in_queue.virt =
- ioremap_nocache(c->in_queue.phys, c->in_queue.len);
- if (!c->in_queue.virt) {
- printk(KERN_ERR "%s: Unable to map controller.\n",
- c->name);
- i2o_pci_free(c);
- return -ENOMEM;
- }
- } else
- c->in_queue = c->base;
-
- c->irq_status = c->base.virt + I2O_IRQ_STATUS;
- c->irq_mask = c->base.virt + I2O_IRQ_MASK;
- c->in_port = c->base.virt + I2O_IN_PORT;
- c->out_port = c->base.virt + I2O_OUT_PORT;
-
- /* Motorola/Freescale chip does not follow spec */
- if (pdev->vendor == PCI_VENDOR_ID_MOTOROLA && pdev->device == 0x18c0) {
- /* Check if CPU is enabled */
- if (be32_to_cpu(readl(c->base.virt + 0x10000)) & 0x10000000) {
- printk(KERN_INFO "%s: MPC82XX needs CPU running to "
- "service I2O.\n", c->name);
- i2o_pci_free(c);
- return -ENODEV;
- } else {
- c->irq_status += I2O_MOTOROLA_PORT_OFFSET;
- c->irq_mask += I2O_MOTOROLA_PORT_OFFSET;
- c->in_port += I2O_MOTOROLA_PORT_OFFSET;
- c->out_port += I2O_MOTOROLA_PORT_OFFSET;
- printk(KERN_INFO "%s: MPC82XX workarounds activated.\n",
- c->name);
- }
- }
-
- if (i2o_dma_alloc(dev, &c->status, 8)) {
- i2o_pci_free(c);
- return -ENOMEM;
- }
-
- if (i2o_dma_alloc(dev, &c->hrt, sizeof(i2o_hrt))) {
- i2o_pci_free(c);
- return -ENOMEM;
- }
-
- if (i2o_dma_alloc(dev, &c->dlct, 8192)) {
- i2o_pci_free(c);
- return -ENOMEM;
- }
-
- if (i2o_dma_alloc(dev, &c->status_block, sizeof(i2o_status_block))) {
- i2o_pci_free(c);
- return -ENOMEM;
- }
-
- if (i2o_dma_alloc(dev, &c->out_queue,
- I2O_MAX_OUTBOUND_MSG_FRAMES * I2O_OUTBOUND_MSG_FRAME_SIZE *
- sizeof(u32))) {
- i2o_pci_free(c);
- return -ENOMEM;
- }
-
- pci_set_drvdata(pdev, c);
-
- return 0;
-}
-
-/**
- * i2o_pci_interrupt - Interrupt handler for I2O controller
- * @irq: interrupt line
- * @dev_id: pointer to the I2O controller
- *
- * Handle an interrupt from a PCI based I2O controller. This turns out
- * to be rather simple. We keep the controller pointer in the cookie.
- */
-static irqreturn_t i2o_pci_interrupt(int irq, void *dev_id)
-{
- struct i2o_controller *c = dev_id;
- u32 m;
- irqreturn_t rc = IRQ_NONE;
-
- while (readl(c->irq_status) & I2O_IRQ_OUTBOUND_POST) {
- m = readl(c->out_port);
- if (m == I2O_QUEUE_EMPTY) {
- /*
- * Old 960 steppings had a bug in the I2O unit that
- * caused the queue to appear empty when it wasn't.
- */
- m = readl(c->out_port);
- if (unlikely(m == I2O_QUEUE_EMPTY))
- break;
- }
-
- /* dispatch it */
- if (i2o_driver_dispatch(c, m))
- /* flush it if result != 0 */
- i2o_flush_reply(c, m);
-
- rc = IRQ_HANDLED;
- }
-
- return rc;
-}
-
-/**
- * i2o_pci_irq_enable - Allocate interrupt for I2O controller
- * @c: i2o_controller that the request is for
- *
- * Allocate an interrupt for the I2O controller, and activate interrupts
- * on the I2O controller.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_pci_irq_enable(struct i2o_controller *c)
-{
- struct pci_dev *pdev = c->pdev;
- int rc;
-
- writel(0xffffffff, c->irq_mask);
-
- if (pdev->irq) {
- rc = request_irq(pdev->irq, i2o_pci_interrupt, IRQF_SHARED,
- c->name, c);
- if (rc < 0) {
- printk(KERN_ERR "%s: unable to allocate interrupt %d."
- "\n", c->name, pdev->irq);
- return rc;
- }
- }
-
- writel(0x00000000, c->irq_mask);
-
- printk(KERN_INFO "%s: Installed at IRQ %d\n", c->name, pdev->irq);
-
- return 0;
-}
-
-/**
- * i2o_pci_irq_disable - Free interrupt for I2O controller
- * @c: I2O controller
- *
- * Disable interrupts in I2O controller and then free interrupt.
- */
-static void i2o_pci_irq_disable(struct i2o_controller *c)
-{
- writel(0xffffffff, c->irq_mask);
-
- if (c->pdev->irq > 0)
- free_irq(c->pdev->irq, c);
-}
-
-/**
- * i2o_pci_probe - Probe the PCI device for an I2O controller
- * @pdev: PCI device to test
- * @id: id which matched with the PCI device id table
- *
- * Probe the PCI device for any device which is a memory of the
- * Intelligent, I2O class or an Adaptec Zero Channel Controller. We
- * attempt to set up each such device and register it with the core.
- *
- * Returns 0 on success or negative error code on failure.
- */
-static int i2o_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
-{
- struct i2o_controller *c;
- int rc;
- struct pci_dev *i960 = NULL;
-
- printk(KERN_INFO "i2o: Checking for PCI I2O controllers...\n");
-
- if ((pdev->class & 0xff) > 1) {
- printk(KERN_WARNING "i2o: %s does not support I2O 1.5 "
- "(skipping).\n", pci_name(pdev));
- return -ENODEV;
- }
-
- rc = pci_enable_device(pdev);
- if (rc) {
- printk(KERN_WARNING "i2o: couldn't enable device %s\n",
- pci_name(pdev));
- return rc;
- }
-
- if (pci_set_dma_mask(pdev, DMA_BIT_MASK(32))) {
- printk(KERN_WARNING "i2o: no suitable DMA found for %s\n",
- pci_name(pdev));
- rc = -ENODEV;
- goto disable;
- }
-
- pci_set_master(pdev);
-
- c = i2o_iop_alloc();
- if (IS_ERR(c)) {
- printk(KERN_ERR "i2o: couldn't allocate memory for %s\n",
- pci_name(pdev));
- rc = PTR_ERR(c);
- goto disable;
- } else
- printk(KERN_INFO "%s: controller found (%s)\n", c->name,
- pci_name(pdev));
-
- c->pdev = pdev;
- c->device.parent = &pdev->dev;
-
- /* Cards that fall apart if you hit them with large I/O loads... */
- if (pdev->vendor == PCI_VENDOR_ID_NCR && pdev->device == 0x0630) {
- c->short_req = 1;
- printk(KERN_INFO "%s: Symbios FC920 workarounds activated.\n",
- c->name);
- }
-
- if (pdev->subsystem_vendor == PCI_VENDOR_ID_PROMISE) {
- /*
- * Expose the ship behind i960 for initialization, or it will
- * failed
- */
- i960 = pci_get_slot(c->pdev->bus,
- PCI_DEVFN(PCI_SLOT(c->pdev->devfn), 0));
-
- if (i960) {
- pci_write_config_word(i960, 0x42, 0);
- pci_dev_put(i960);
- }
-
- c->promise = 1;
- c->limit_sectors = 1;
- }
-
- if (pdev->subsystem_vendor == PCI_VENDOR_ID_DPT)
- c->adaptec = 1;
-
- /* Cards that go bananas if you quiesce them before you reset them. */
- if (pdev->vendor == PCI_VENDOR_ID_DPT) {
- c->no_quiesce = 1;
- if (pdev->device == 0xa511)
- c->raptor = 1;
-
- if (pdev->subsystem_device == 0xc05a) {
- c->limit_sectors = 1;
- printk(KERN_INFO
- "%s: limit sectors per request to %d\n", c->name,
- I2O_MAX_SECTORS_LIMITED);
- }
-#ifdef CONFIG_I2O_EXT_ADAPTEC_DMA64
- if (sizeof(dma_addr_t) > 4) {
- if (pci_set_dma_mask(pdev, DMA_BIT_MASK(64)))
- printk(KERN_INFO "%s: 64-bit DMA unavailable\n",
- c->name);
- else {
- c->pae_support = 1;
- printk(KERN_INFO "%s: using 64-bit DMA\n",
- c->name);
- }
- }
-#endif
- }
-
- rc = i2o_pci_alloc(c);
- if (rc) {
- printk(KERN_ERR "%s: DMA / IO allocation for I2O controller "
- "failed\n", c->name);
- goto free_controller;
- }
-
- if (i2o_pci_irq_enable(c)) {
- printk(KERN_ERR "%s: unable to enable interrupts for I2O "
- "controller\n", c->name);
- goto free_pci;
- }
-
- rc = i2o_iop_add(c);
- if (rc)
- goto uninstall;
-
- if (i960)
- pci_write_config_word(i960, 0x42, 0x03ff);
-
- return 0;
-
- uninstall:
- i2o_pci_irq_disable(c);
-
- free_pci:
- i2o_pci_free(c);
-
- free_controller:
- i2o_iop_free(c);
-
- disable:
- pci_disable_device(pdev);
-
- return rc;
-}
-
-/**
- * i2o_pci_remove - Removes a I2O controller from the system
- * @pdev: I2O controller which should be removed
- *
- * Reset the I2O controller, disable interrupts and remove all allocated
- * resources.
- */
-static void i2o_pci_remove(struct pci_dev *pdev)
-{
- struct i2o_controller *c;
- c = pci_get_drvdata(pdev);
-
- i2o_iop_remove(c);
- i2o_pci_irq_disable(c);
- i2o_pci_free(c);
-
- pci_disable_device(pdev);
-
- printk(KERN_INFO "%s: Controller removed.\n", c->name);
-
- put_device(&c->device);
-};
-
-/* PCI driver for I2O controller */
-static struct pci_driver i2o_pci_driver = {
- .name = "PCI_I2O",
- .id_table = i2o_pci_ids,
- .probe = i2o_pci_probe,
- .remove = i2o_pci_remove,
-};
-
-/**
- * i2o_pci_init - registers I2O PCI driver in PCI subsystem
- *
- * Returns > 0 on success or negative error code on failure.
- */
-int __init i2o_pci_init(void)
-{
- return pci_register_driver(&i2o_pci_driver);
-};
-
-/**
- * i2o_pci_exit - unregisters I2O PCI driver from PCI subsystem
- */
-void __exit i2o_pci_exit(void)
-{
- pci_unregister_driver(&i2o_pci_driver);
-};
-
-MODULE_DEVICE_TABLE(pci, i2o_pci_ids);
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt
index 8be32e5a0af129..54ef0deed28f30 100644
--- a/drivers/staging/iio/Documentation/device.txt
+++ b/drivers/staging/iio/Documentation/device.txt
@@ -52,7 +52,7 @@ Then fill in the following:
* info->write_event_value:
Write the value associated with on sensor event detectors. E.g.
a threshold above which an interrupt occurs. Note that the
- meaning of the value to be set is event type dependant.
+ meaning of the value to be set is event type dependent.
- indio_dev->modes:
Specify whether direct access and / or ring buffer access is supported.
diff --git a/drivers/staging/iio/accel/Kconfig b/drivers/staging/iio/accel/Kconfig
index 07b7ffa00ab53c..fa67da9408b6b3 100644
--- a/drivers/staging/iio/accel/Kconfig
+++ b/drivers/staging/iio/accel/Kconfig
@@ -79,7 +79,7 @@ config LIS3L02DQ
depends on SPI
select IIO_TRIGGER if IIO_BUFFER
depends on !IIO_BUFFER || IIO_KFIFO_BUF
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
help
Say Y here to build SPI support for the ST microelectronics
accelerometer. The driver supplies direct access via sysfs files
diff --git a/drivers/staging/iio/adc/Kconfig b/drivers/staging/iio/adc/Kconfig
index d0016ce6e65840..94ae4232ee7734 100644
--- a/drivers/staging/iio/adc/Kconfig
+++ b/drivers/staging/iio/adc/Kconfig
@@ -5,7 +5,7 @@ menu "Analog to digital converters"
config AD7606
tristate "Analog Devices AD7606 ADC driver"
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
select IIO_BUFFER
select IIO_TRIGGERED_BUFFER
help
@@ -39,7 +39,7 @@ config AD7606_IFACE_SPI
config AD7780
tristate "Analog Devices AD7780 and similar ADCs driver"
depends on SPI
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
select AD_SIGMA_DELTA
help
Say yes here to build support for Analog Devices AD7170, AD7171,
@@ -52,7 +52,7 @@ config AD7780
config AD7816
tristate "Analog Devices AD7816/7/8 temperature sensor and ADC driver"
depends on SPI
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
help
Say yes here to build support for Analog Devices AD7816/7/8
temperature sensors and ADC.
diff --git a/drivers/staging/iio/adc/ad7606_par.c b/drivers/staging/iio/adc/ad7606_par.c
index 9e24b4d4455f2e..1d48ae381d16c1 100644
--- a/drivers/staging/iio/adc/ad7606_par.c
+++ b/drivers/staging/iio/adc/ad7606_par.c
@@ -119,7 +119,7 @@ static const struct dev_pm_ops ad7606_pm_ops = {
#define AD7606_PAR_PM_OPS NULL
#endif /* CONFIG_PM */
-static struct platform_device_id ad7606_driver_ids[] = {
+static const struct platform_device_id ad7606_driver_ids[] = {
{
.name = "ad7606-8",
.driver_data = ID_AD7606_8,
diff --git a/drivers/staging/iio/addac/Kconfig b/drivers/staging/iio/addac/Kconfig
index 0ed7e13e2283ed..ba18b8432d9cce 100644
--- a/drivers/staging/iio/addac/Kconfig
+++ b/drivers/staging/iio/addac/Kconfig
@@ -5,7 +5,7 @@ menu "Analog digital bi-direction converters"
config ADT7316
tristate "Analog Devices ADT7316/7/8 ADT7516/7/9 temperature sensor, ADC and DAC driver"
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
help
Say yes here to build support for Analog Devices ADT7316, ADT7317, ADT7318
and ADT7516, ADT7517, ADT7519 temperature sensors, ADC and DAC.
diff --git a/drivers/staging/iio/iio_simple_dummy.h b/drivers/staging/iio/iio_simple_dummy.h
index 34989bf248a758..d86ccb76eb6dfb 100644
--- a/drivers/staging/iio/iio_simple_dummy.h
+++ b/drivers/staging/iio/iio_simple_dummy.h
@@ -25,7 +25,7 @@ struct iio_dummy_regs;
* @accel_calibscale: cache for acceleration calibscale
* @lock: lock to ensure state is consistent
* @event_irq: irq number for event line (faked)
- * @event_val: cache for event theshold value
+ * @event_val: cache for event threshold value
* @event_en: cache of whether event is enabled
*/
struct iio_dummy_state {
diff --git a/drivers/staging/iio/iio_simple_dummy_events.c b/drivers/staging/iio/iio_simple_dummy_events.c
index a5cd3bb219fe78..c32ef78d8e5f38 100644
--- a/drivers/staging/iio/iio_simple_dummy_events.c
+++ b/drivers/staging/iio/iio_simple_dummy_events.c
@@ -84,6 +84,7 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
default:
return -EINVAL;
}
+ break;
case IIO_STEPS:
switch (type) {
case IIO_EV_TYPE_CHANGE:
@@ -92,6 +93,7 @@ int iio_simple_dummy_write_event_config(struct iio_dev *indio_dev,
default:
return -EINVAL;
}
+ break;
default:
return -EINVAL;
}
diff --git a/drivers/staging/iio/light/isl29018.c b/drivers/staging/iio/light/isl29018.c
index a3489187aeb0c5..e646c5d2400460 100644
--- a/drivers/staging/iio/light/isl29018.c
+++ b/drivers/staging/iio/light/isl29018.c
@@ -66,58 +66,115 @@
#define ISL29035_BOUT_SHIFT 0x07
#define ISL29035_BOUT_MASK (0x01 << ISL29035_BOUT_SHIFT)
+#define ISL29018_INT_TIME_AVAIL "0.090000 0.005630 0.000351 0.000021"
+#define ISL29023_INT_TIME_AVAIL "0.090000 0.005600 0.000352 0.000022"
+#define ISL29035_INT_TIME_AVAIL "0.105000 0.006500 0.000410 0.000025"
+
+static const char * const int_time_avail[] = {
+ ISL29018_INT_TIME_AVAIL,
+ ISL29023_INT_TIME_AVAIL,
+ ISL29035_INT_TIME_AVAIL,
+};
+
+enum isl29018_int_time {
+ ISL29018_INT_TIME_16,
+ ISL29018_INT_TIME_12,
+ ISL29018_INT_TIME_8,
+ ISL29018_INT_TIME_4,
+};
+
+static const unsigned int isl29018_int_utimes[3][4] = {
+ {90000, 5630, 351, 21},
+ {90000, 5600, 352, 22},
+ {105000, 6500, 410, 25},
+};
+
+static const struct isl29018_scale {
+ unsigned int scale;
+ unsigned int uscale;
+} isl29018_scales[4][4] = {
+ { {0, 15258}, {0, 61035}, {0, 244140}, {0, 976562} },
+ { {0, 244140}, {0, 976562}, {3, 906250}, {15, 625000} },
+ { {3, 906250}, {15, 625000}, {62, 500000}, {250, 0} },
+ { {62, 500000}, {250, 0}, {1000, 0}, {4000, 0} }
+};
+
struct isl29018_chip {
struct device *dev;
struct regmap *regmap;
struct mutex lock;
int type;
- unsigned int lux_scale;
- unsigned int lux_uscale;
- unsigned int range;
- unsigned int adc_bit;
+ unsigned int calibscale;
+ unsigned int ucalibscale;
+ unsigned int int_time;
+ struct isl29018_scale scale;
int prox_scheme;
bool suspended;
};
-static int isl29018_set_range(struct isl29018_chip *chip, unsigned long range,
- unsigned int *new_range)
+static int isl29018_set_integration_time(struct isl29018_chip *chip,
+ unsigned int utime)
{
- static const unsigned long supp_ranges[] = {1000, 4000, 16000, 64000};
- int i;
-
- for (i = 0; i < ARRAY_SIZE(supp_ranges); ++i) {
- if (range <= supp_ranges[i]) {
- *new_range = (unsigned int)supp_ranges[i];
+ int i, ret;
+ unsigned int int_time, new_int_time;
+ struct isl29018_scale new_scale;
+
+ for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i) {
+ if (utime == isl29018_int_utimes[chip->type][i]) {
+ new_int_time = i;
+ new_scale = isl29018_scales[new_int_time][0];
break;
}
}
- if (i >= ARRAY_SIZE(supp_ranges))
+ if (i >= ARRAY_SIZE(isl29018_int_utimes[chip->type]))
return -EINVAL;
- return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
- COMMANDII_RANGE_MASK, i << COMMANDII_RANGE_SHIFT);
+ ret = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
+ COMMANDII_RESOLUTION_MASK,
+ i << COMMANDII_RESOLUTION_SHIFT);
+ if (ret < 0)
+ return ret;
+
+ /* keep the same range when integration time changes */
+ int_time = chip->int_time;
+ for (i = 0; i < ARRAY_SIZE(isl29018_scales[int_time]); ++i) {
+ if (chip->scale.scale == isl29018_scales[int_time][i].scale &&
+ chip->scale.uscale == isl29018_scales[int_time][i].uscale) {
+ chip->scale = isl29018_scales[new_int_time][i];
+ break;
+ }
+ }
+ chip->int_time = new_int_time;
+
+ return 0;
}
-static int isl29018_set_resolution(struct isl29018_chip *chip,
- unsigned long adcbit, unsigned int *conf_adc_bit)
+static int isl29018_set_scale(struct isl29018_chip *chip, int scale, int uscale)
{
- static const unsigned long supp_adcbit[] = {16, 12, 8, 4};
- int i;
+ int i, ret;
+ struct isl29018_scale new_scale;
- for (i = 0; i < ARRAY_SIZE(supp_adcbit); ++i) {
- if (adcbit >= supp_adcbit[i]) {
- *conf_adc_bit = (unsigned int)supp_adcbit[i];
+ for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i) {
+ if (scale == isl29018_scales[chip->int_time][i].scale &&
+ uscale == isl29018_scales[chip->int_time][i].uscale) {
+ new_scale = isl29018_scales[chip->int_time][i];
break;
}
}
- if (i >= ARRAY_SIZE(supp_adcbit))
+ if (i >= ARRAY_SIZE(isl29018_scales[chip->int_time]))
return -EINVAL;
- return regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
- COMMANDII_RESOLUTION_MASK,
- i << COMMANDII_RESOLUTION_SHIFT);
+ ret = regmap_update_bits(chip->regmap, ISL29018_REG_ADD_COMMANDII,
+ COMMANDII_RANGE_MASK,
+ i << COMMANDII_RANGE_SHIFT);
+ if (ret < 0)
+ return ret;
+
+ chip->scale = new_scale;
+
+ return 0;
}
static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode)
@@ -156,22 +213,17 @@ static int isl29018_read_sensor_input(struct isl29018_chip *chip, int mode)
static int isl29018_read_lux(struct isl29018_chip *chip, int *lux)
{
int lux_data;
- unsigned int data_x_range, lux_unshifted;
+ unsigned int data_x_range;
lux_data = isl29018_read_sensor_input(chip, COMMMAND1_OPMODE_ALS_ONCE);
if (lux_data < 0)
return lux_data;
- /* To support fractional scaling, separate the unshifted lux
- * into two calculations: int scaling and micro-scaling.
- * lux_uscale ranges from 0-999999, so about 20 bits. Split
- * the /1,000,000 in two to reduce the risk of over/underflow.
- */
- data_x_range = lux_data * chip->range;
- lux_unshifted = data_x_range * chip->lux_scale;
- lux_unshifted += data_x_range / 1000 * chip->lux_uscale / 1000;
- *lux = lux_unshifted >> chip->adc_bit;
+ data_x_range = lux_data * chip->scale.scale +
+ lux_data * chip->scale.uscale / 1000000;
+ *lux = data_x_range * chip->calibscale +
+ data_x_range * chip->ucalibscale / 1000000;
return 0;
}
@@ -229,86 +281,37 @@ static int isl29018_read_proximity_ir(struct isl29018_chip *chip, int scheme,
return 0;
}
-/* Sysfs interface */
-/* range */
-static ssize_t show_range(struct device *dev,
+static ssize_t show_scale_available(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
+ int i, len = 0;
- return sprintf(buf, "%u\n", chip->range);
-}
-
-static ssize_t store_range(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct isl29018_chip *chip = iio_priv(indio_dev);
- int status;
- unsigned long lval;
- unsigned int new_range;
-
- if (kstrtoul(buf, 10, &lval))
- return -EINVAL;
-
- if (!(lval == 1000UL || lval == 4000UL ||
- lval == 16000UL || lval == 64000UL)) {
- dev_err(dev, "The range is not supported\n");
- return -EINVAL;
- }
+ for (i = 0; i < ARRAY_SIZE(isl29018_scales[chip->int_time]); ++i)
+ len += sprintf(buf + len, "%d.%06d ",
+ isl29018_scales[chip->int_time][i].scale,
+ isl29018_scales[chip->int_time][i].uscale);
- mutex_lock(&chip->lock);
- status = isl29018_set_range(chip, lval, &new_range);
- if (status < 0) {
- mutex_unlock(&chip->lock);
- dev_err(dev,
- "Error in setting max range with err %d\n", status);
- return status;
- }
- chip->range = new_range;
- mutex_unlock(&chip->lock);
+ buf[len - 1] = '\n';
- return count;
+ return len;
}
-/* resolution */
-static ssize_t show_resolution(struct device *dev,
+static ssize_t show_int_time_available(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct isl29018_chip *chip = iio_priv(indio_dev);
+ int i, len = 0;
- return sprintf(buf, "%u\n", chip->adc_bit);
-}
+ for (i = 0; i < ARRAY_SIZE(isl29018_int_utimes[chip->type]); ++i)
+ len += sprintf(buf + len, "0.%06d ",
+ isl29018_int_utimes[chip->type][i]);
-static ssize_t store_resolution(struct device *dev,
- struct device_attribute *attr, const char *buf, size_t count)
-{
- struct iio_dev *indio_dev = dev_to_iio_dev(dev);
- struct isl29018_chip *chip = iio_priv(indio_dev);
- int status;
- unsigned int val;
- unsigned int new_adc_bit;
-
- if (kstrtouint(buf, 10, &val))
- return -EINVAL;
- if (!(val == 4 || val == 8 || val == 12 || val == 16)) {
- dev_err(dev, "The resolution is not supported\n");
- return -EINVAL;
- }
-
- mutex_lock(&chip->lock);
- status = isl29018_set_resolution(chip, val, &new_adc_bit);
- if (status < 0) {
- mutex_unlock(&chip->lock);
- dev_err(dev, "Error in setting resolution\n");
- return status;
- }
- chip->adc_bit = new_adc_bit;
- mutex_unlock(&chip->lock);
+ buf[len - 1] = '\n';
- return count;
+ return len;
}
/* proximity scheme */
@@ -357,11 +360,29 @@ static int isl29018_write_raw(struct iio_dev *indio_dev,
int ret = -EINVAL;
mutex_lock(&chip->lock);
- if (mask == IIO_CHAN_INFO_CALIBSCALE && chan->type == IIO_LIGHT) {
- chip->lux_scale = val;
- /* With no write_raw_get_fmt(), val2 is a MICRO fraction. */
- chip->lux_uscale = val2;
- ret = 0;
+ switch (mask) {
+ case IIO_CHAN_INFO_CALIBSCALE:
+ if (chan->type == IIO_LIGHT) {
+ chip->calibscale = val;
+ chip->ucalibscale = val2;
+ ret = 0;
+ }
+ break;
+ case IIO_CHAN_INFO_INT_TIME:
+ if (chan->type == IIO_LIGHT) {
+ if (val != 0) {
+ mutex_unlock(&chip->lock);
+ return -EINVAL;
+ }
+ ret = isl29018_set_integration_time(chip, val2);
+ }
+ break;
+ case IIO_CHAN_INFO_SCALE:
+ if (chan->type == IIO_LIGHT)
+ ret = isl29018_set_scale(chip, val, val2);
+ break;
+ default:
+ break;
}
mutex_unlock(&chip->lock);
@@ -402,10 +423,24 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
if (!ret)
ret = IIO_VAL_INT;
break;
+ case IIO_CHAN_INFO_INT_TIME:
+ if (chan->type == IIO_LIGHT) {
+ *val = 0;
+ *val2 = isl29018_int_utimes[chip->type][chip->int_time];
+ ret = IIO_VAL_INT_PLUS_MICRO;
+ }
+ break;
+ case IIO_CHAN_INFO_SCALE:
+ if (chan->type == IIO_LIGHT) {
+ *val = chip->scale.scale;
+ *val2 = chip->scale.uscale;
+ ret = IIO_VAL_INT_PLUS_MICRO;
+ }
+ break;
case IIO_CHAN_INFO_CALIBSCALE:
if (chan->type == IIO_LIGHT) {
- *val = chip->lux_scale;
- *val2 = chip->lux_uscale;
+ *val = chip->calibscale;
+ *val2 = chip->ucalibscale;
ret = IIO_VAL_INT_PLUS_MICRO;
}
break;
@@ -421,7 +456,9 @@ static int isl29018_read_raw(struct iio_dev *indio_dev,
.indexed = 1, \
.channel = 0, \
.info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED) | \
- BIT(IIO_CHAN_INFO_CALIBSCALE), \
+ BIT(IIO_CHAN_INFO_CALIBSCALE) | \
+ BIT(IIO_CHAN_INFO_SCALE) | \
+ BIT(IIO_CHAN_INFO_INT_TIME), \
}
#define ISL29018_IR_CHANNEL { \
@@ -447,32 +484,27 @@ static const struct iio_chan_spec isl29023_channels[] = {
ISL29018_IR_CHANNEL,
};
-static IIO_DEVICE_ATTR(range, S_IRUGO | S_IWUSR, show_range, store_range, 0);
-static IIO_CONST_ATTR(range_available, "1000 4000 16000 64000");
-static IIO_CONST_ATTR(adc_resolution_available, "4 8 12 16");
-static IIO_DEVICE_ATTR(adc_resolution, S_IRUGO | S_IWUSR,
- show_resolution, store_resolution, 0);
+static IIO_DEVICE_ATTR(in_illuminance_integration_time_available, S_IRUGO,
+ show_int_time_available, NULL, 0);
+static IIO_DEVICE_ATTR(in_illuminance_scale_available, S_IRUGO,
+ show_scale_available, NULL, 0);
static IIO_DEVICE_ATTR(proximity_on_chip_ambient_infrared_suppression,
S_IRUGO | S_IWUSR,
show_prox_infrared_suppression,
store_prox_infrared_suppression, 0);
#define ISL29018_DEV_ATTR(name) (&iio_dev_attr_##name.dev_attr.attr)
-#define ISL29018_CONST_ATTR(name) (&iio_const_attr_##name.dev_attr.attr)
+
static struct attribute *isl29018_attributes[] = {
- ISL29018_DEV_ATTR(range),
- ISL29018_CONST_ATTR(range_available),
- ISL29018_DEV_ATTR(adc_resolution),
- ISL29018_CONST_ATTR(adc_resolution_available),
+ ISL29018_DEV_ATTR(in_illuminance_scale_available),
+ ISL29018_DEV_ATTR(in_illuminance_integration_time_available),
ISL29018_DEV_ATTR(proximity_on_chip_ambient_infrared_suppression),
NULL
};
static struct attribute *isl29023_attributes[] = {
- ISL29018_DEV_ATTR(range),
- ISL29018_CONST_ATTR(range_available),
- ISL29018_DEV_ATTR(adc_resolution),
- ISL29018_CONST_ATTR(adc_resolution_available),
+ ISL29018_DEV_ATTR(in_illuminance_scale_available),
+ ISL29018_DEV_ATTR(in_illuminance_integration_time_available),
NULL
};
@@ -516,8 +548,6 @@ enum {
static int isl29018_chip_init(struct isl29018_chip *chip)
{
int status;
- unsigned int new_adc_bit;
- unsigned int new_range;
if (chip->type == isl29035) {
status = isl29035_detect(chip);
@@ -566,14 +596,19 @@ static int isl29018_chip_init(struct isl29018_chip *chip)
usleep_range(1000, 2000); /* per data sheet, page 10 */
/* set defaults */
- status = isl29018_set_range(chip, chip->range, &new_range);
+ status = isl29018_set_scale(chip, chip->scale.scale,
+ chip->scale.uscale);
if (status < 0) {
dev_err(chip->dev, "Init of isl29018 fails\n");
return status;
}
- status = isl29018_set_resolution(chip, chip->adc_bit,
- &new_adc_bit);
+ status = isl29018_set_integration_time(chip,
+ isl29018_int_utimes[chip->type][chip->int_time]);
+ if (status < 0) {
+ dev_err(chip->dev, "Init of isl29018 fails\n");
+ return status;
+ }
return 0;
}
@@ -701,10 +736,10 @@ static int isl29018_probe(struct i2c_client *client,
mutex_init(&chip->lock);
chip->type = dev_id;
- chip->lux_scale = 1;
- chip->lux_uscale = 0;
- chip->range = 1000;
- chip->adc_bit = 16;
+ chip->calibscale = 1;
+ chip->ucalibscale = 0;
+ chip->int_time = ISL29018_INT_TIME_16;
+ chip->scale = isl29018_scales[chip->int_time][0];
chip->suspended = false;
chip->regmap = devm_regmap_init_i2c(client,
diff --git a/drivers/staging/iio/resolver/Kconfig b/drivers/staging/iio/resolver/Kconfig
index c7a742ec122727..1c7e2860d6b75d 100644
--- a/drivers/staging/iio/resolver/Kconfig
+++ b/drivers/staging/iio/resolver/Kconfig
@@ -16,7 +16,7 @@ config AD2S90
config AD2S1200
tristate "Analog Devices ad2s1200/ad2s1205 driver"
depends on SPI
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
help
Say yes here to build support for Analog Devices spi resolver
to digital converters, ad2s1200 and ad2s1205, provides direct access
@@ -28,7 +28,7 @@ config AD2S1200
config AD2S1210
tristate "Analog Devices ad2s1210 driver"
depends on SPI
- depends on GPIOLIB
+ depends on GPIOLIB || COMPILE_TEST
help
Say yes here to build support for Analog Devices spi resolver
to digital converters, ad2s1210, provides direct access via sysfs.
diff --git a/drivers/staging/lustre/TODO b/drivers/staging/lustre/TODO
index 0512594b5199a1..f194417d0af732 100644
--- a/drivers/staging/lustre/TODO
+++ b/drivers/staging/lustre/TODO
@@ -1,6 +1,6 @@
* Possible remaining coding style fix.
* Remove deadcode.
-* Seperate client/server functionality. Functions only used by server can be
+* Separate client/server functionality. Functions only used by server can be
removed from client.
* Clean up libcfs layer. Ideally we can remove include/linux/libcfs entirely.
* Clean up CLIO layer. Lustre client readahead/writeback control needs to better
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 4410d7fdc1b445..a789559b81c2c5 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -37,34 +37,11 @@
#ifndef __LIBCFS_LIBCFS_H__
#define __LIBCFS_LIBCFS_H__
-#if !__GNUC__
-#define __attribute__(x)
-#endif
-
#include "linux/libcfs.h"
#include <linux/gfp.h>
#include "curproc.h"
-#ifndef offsetof
-# define offsetof(typ, memb) ((long)(long_ptr_t)((char *)&(((typ *)0)->memb)))
-#endif
-
-#ifndef ARRAY_SIZE
-#define ARRAY_SIZE(a) ((sizeof(a)) / (sizeof((a)[0])))
-#endif
-
-#if !defined(swap)
-#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
-#endif
-
-#if !defined(container_of)
-/* given a pointer @ptr to the field @member embedded into type (usually
- * struct) @type, return pointer to the embedding instance of @type. */
-#define container_of(ptr, type, member) \
- ((type *)((char *)(ptr)-(char *)(&((type *)0)->member)))
-#endif
-
static inline int __is_po2(unsigned long long val)
{
return !(val & (val - 1));
@@ -184,4 +161,8 @@ static inline void *__container_of(void *ptr, unsigned long shift)
#define _LIBCFS_H
+void *libcfs_kvzalloc(size_t size, gfp_t flags);
+void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size,
+ gfp_t flags);
+
#endif /* _LIBCFS_H */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index fef882530455f2..d8f8543de57329 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -496,19 +496,6 @@ static inline size_t cfs_round_strlen(char *fset)
return (size_t)cfs_size_round((int)strlen(fset) + 1);
}
-/* roundup \a val to power2 */
-static inline unsigned int cfs_power2_roundup(unsigned int val)
-{
- if (val != LOWEST_BIT_SET(val)) { /* not a power of 2 already */
- do {
- val &= ~LOWEST_BIT_SET(val);
- } while (val != LOWEST_BIT_SET(val));
- /* ...and round up */
- val <<= 1;
- }
- return val;
-}
-
#define LOGL(var, len, ptr) \
do { \
if (var) \
diff --git a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
index 4fe50841e8e3c3..3e2502a69bbd16 100644
--- a/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/linux/libcfs.h
@@ -61,7 +61,6 @@
#include <linux/moduleparam.h>
#include <linux/mutex.h>
#include <linux/notifier.h>
-#include <linux/proc_fs.h>
#include <linux/random.h>
#include <linux/rbtree.h>
#include <linux/rwsem.h>
diff --git a/drivers/staging/lustre/include/linux/lnet/api.h b/drivers/staging/lustre/include/linux/lnet/api.h
index cd865175703fc6..c4dc1b2f605d43 100644
--- a/drivers/staging/lustre/include/linux/lnet/api.h
+++ b/drivers/staging/lustre/include/linux/lnet/api.h
@@ -209,7 +209,6 @@ int LNetGet(lnet_nid_t self,
int LNetSetLazyPortal(int portal);
int LNetClearLazyPortal(int portal);
int LNetCtl(unsigned int cmd, void *arg);
-int LNetSetAsync(lnet_process_id_t id, int nasync);
/** @} lnet_misc */
diff --git a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
index 0038d29a37fe17..d84aa9a4c56d84 100644
--- a/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
+++ b/drivers/staging/lustre/include/linux/lnet/lib-lnet.h
@@ -172,8 +172,6 @@ lnet_net_lock_current(void)
#define lnet_eq_wait_unlock() spin_unlock(&the_lnet.ln_eq_wait_lock)
#define lnet_ni_lock(ni) spin_lock(&(ni)->ni_lock)
#define lnet_ni_unlock(ni) spin_unlock(&(ni)->ni_lock)
-#define LNET_MUTEX_LOCK(m) mutex_lock(m)
-#define LNET_MUTEX_UNLOCK(m) mutex_unlock(m)
#define MAX_PORTALS 64
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 3bad441de8dc90..a57c5c35ee68c8 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -42,21 +42,21 @@
#include <asm/div64.h>
static lnd_t the_o2iblnd = {
- .lnd_type = O2IBLND,
- .lnd_startup = kiblnd_startup,
- .lnd_shutdown = kiblnd_shutdown,
- .lnd_ctl = kiblnd_ctl,
- .lnd_query = kiblnd_query,
- .lnd_send = kiblnd_send,
- .lnd_recv = kiblnd_recv,
+ .lnd_type = O2IBLND,
+ .lnd_startup = kiblnd_startup,
+ .lnd_shutdown = kiblnd_shutdown,
+ .lnd_ctl = kiblnd_ctl,
+ .lnd_query = kiblnd_query,
+ .lnd_send = kiblnd_send,
+ .lnd_recv = kiblnd_recv,
};
-kib_data_t kiblnd_data;
+kib_data_t kiblnd_data;
static __u32 kiblnd_cksum(void *ptr, int nob)
{
- char *c = ptr;
- __u32 sum = 0;
+ char *c = ptr;
+ __u32 sum = 0;
while (nob-- > 0)
sum = ((sum << 1) | (sum >> 31)) + *c++;
@@ -138,10 +138,10 @@ static int kiblnd_msgtype2size(int type)
static int kiblnd_unpack_rd(kib_msg_t *msg, int flip)
{
- kib_rdma_desc_t *rd;
- int nob;
- int n;
- int i;
+ kib_rdma_desc_t *rd;
+ int nob;
+ int n;
+ int i;
LASSERT(msg->ibm_type == IBLND_MSG_GET_REQ ||
msg->ibm_type == IBLND_MSG_PUT_ACK);
@@ -210,10 +210,10 @@ void kiblnd_pack_msg(lnet_ni_t *ni, kib_msg_t *msg, int version,
int kiblnd_unpack_msg(kib_msg_t *msg, int nob)
{
const int hdr_size = offsetof(kib_msg_t, ibm_u);
- __u32 msg_cksum;
- __u16 version;
- int msg_nob;
- int flip;
+ __u32 msg_cksum;
+ __u16 version;
+ int msg_nob;
+ int flip;
/* 6 bytes are enough to have received magic + version */
if (nob < 6) {
@@ -320,10 +320,10 @@ int kiblnd_unpack_msg(kib_msg_t *msg, int nob)
int kiblnd_create_peer(lnet_ni_t *ni, kib_peer_t **peerp, lnet_nid_t nid)
{
- kib_peer_t *peer;
- kib_net_t *net = ni->ni_data;
- int cpt = lnet_cpt_of_nid(nid);
- unsigned long flags;
+ kib_peer_t *peer;
+ kib_net_t *net = ni->ni_data;
+ int cpt = lnet_cpt_of_nid(nid);
+ unsigned long flags;
LASSERT(net != NULL);
LASSERT(nid != LNET_NID_ANY);
@@ -385,9 +385,9 @@ kib_peer_t *kiblnd_find_peer_locked(lnet_nid_t nid)
{
/* the caller is responsible for accounting the additional reference
* that this creates */
- struct list_head *peer_list = kiblnd_nid2peerlist(nid);
- struct list_head *tmp;
- kib_peer_t *peer;
+ struct list_head *peer_list = kiblnd_nid2peerlist(nid);
+ struct list_head *tmp;
+ kib_peer_t *peer;
list_for_each(tmp, peer_list) {
@@ -422,10 +422,10 @@ void kiblnd_unlink_peer_locked(kib_peer_t *peer)
static int kiblnd_get_peer_info(lnet_ni_t *ni, int index,
lnet_nid_t *nidp, int *count)
{
- kib_peer_t *peer;
- struct list_head *ptmp;
- int i;
- unsigned long flags;
+ kib_peer_t *peer;
+ struct list_head *ptmp;
+ int i;
+ unsigned long flags;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -459,9 +459,9 @@ static int kiblnd_get_peer_info(lnet_ni_t *ni, int index,
static void kiblnd_del_peer_locked(kib_peer_t *peer)
{
- struct list_head *ctmp;
- struct list_head *cnxt;
- kib_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
+ kib_conn_t *conn;
if (list_empty(&peer->ibp_conns)) {
kiblnd_unlink_peer_locked(peer);
@@ -480,14 +480,14 @@ static void kiblnd_del_peer_locked(kib_peer_t *peer)
static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
{
LIST_HEAD(zombies);
- struct list_head *ptmp;
- struct list_head *pnxt;
- kib_peer_t *peer;
- int lo;
- int hi;
- int i;
- unsigned long flags;
- int rc = -ENOENT;
+ struct list_head *ptmp;
+ struct list_head *pnxt;
+ kib_peer_t *peer;
+ int lo;
+ int hi;
+ int i;
+ unsigned long flags;
+ int rc = -ENOENT;
write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -532,12 +532,12 @@ static int kiblnd_del_peer(lnet_ni_t *ni, lnet_nid_t nid)
static kib_conn_t *kiblnd_get_conn_by_idx(lnet_ni_t *ni, int index)
{
- kib_peer_t *peer;
- struct list_head *ptmp;
- kib_conn_t *conn;
- struct list_head *ctmp;
- int i;
- unsigned long flags;
+ kib_peer_t *peer;
+ struct list_head *ptmp;
+ kib_conn_t *conn;
+ struct list_head *ctmp;
+ int i;
+ unsigned long flags;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -593,7 +593,7 @@ int kiblnd_translate_mtu(int value)
static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid)
{
- int mtu;
+ int mtu;
/* XXX There is no path record for iWARP, set by netdev->change_mtu? */
if (cmid->route.path_rec == NULL)
@@ -607,11 +607,11 @@ static void kiblnd_setup_mtu_locked(struct rdma_cm_id *cmid)
static int kiblnd_get_completion_vector(kib_conn_t *conn, int cpt)
{
- cpumask_t *mask;
- int vectors;
- int off;
- int i;
- lnet_nid_t nid = conn->ibc_peer->ibp_nid;
+ cpumask_t *mask;
+ int vectors;
+ int off;
+ int i;
+ lnet_nid_t nid = conn->ibc_peer->ibp_nid;
vectors = conn->ibc_cmid->device->num_comp_vectors;
if (vectors <= 1)
@@ -642,17 +642,17 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
* she must dispose of 'cmid'. (Actually I'd block forever if I tried
* to destroy 'cmid' here since I'm called from the CM which still has
* its ref on 'cmid'). */
- rwlock_t *glock = &kiblnd_data.kib_global_lock;
- kib_net_t *net = peer->ibp_ni->ni_data;
- kib_dev_t *dev;
+ rwlock_t *glock = &kiblnd_data.kib_global_lock;
+ kib_net_t *net = peer->ibp_ni->ni_data;
+ kib_dev_t *dev;
struct ib_qp_init_attr *init_qp_attr;
- struct kib_sched_info *sched;
- kib_conn_t *conn;
- struct ib_cq *cq;
- unsigned long flags;
- int cpt;
- int rc;
- int i;
+ struct kib_sched_info *sched;
+ kib_conn_t *conn;
+ struct ib_cq *cq;
+ unsigned long flags;
+ int cpt;
+ int rc;
+ int i;
LASSERT(net != NULL);
LASSERT(!in_interrupt());
@@ -837,8 +837,8 @@ kib_conn_t *kiblnd_create_conn(kib_peer_t *peer, struct rdma_cm_id *cmid,
void kiblnd_destroy_conn(kib_conn_t *conn)
{
struct rdma_cm_id *cmid = conn->ibc_cmid;
- kib_peer_t *peer = conn->ibc_peer;
- int rc;
+ kib_peer_t *peer = conn->ibc_peer;
+ int rc;
LASSERT(!in_interrupt());
LASSERT(atomic_read(&conn->ibc_refcount) == 0);
@@ -904,10 +904,10 @@ void kiblnd_destroy_conn(kib_conn_t *conn)
int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why)
{
- kib_conn_t *conn;
- struct list_head *ctmp;
- struct list_head *cnxt;
- int count = 0;
+ kib_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
+ int count = 0;
list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
conn = list_entry(ctmp, kib_conn_t, ibc_list);
@@ -926,10 +926,10 @@ int kiblnd_close_peer_conns_locked(kib_peer_t *peer, int why)
int kiblnd_close_stale_conns_locked(kib_peer_t *peer,
int version, __u64 incarnation)
{
- kib_conn_t *conn;
- struct list_head *ctmp;
- struct list_head *cnxt;
- int count = 0;
+ kib_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
+ int count = 0;
list_for_each_safe(ctmp, cnxt, &peer->ibp_conns) {
conn = list_entry(ctmp, kib_conn_t, ibc_list);
@@ -953,14 +953,14 @@ int kiblnd_close_stale_conns_locked(kib_peer_t *peer,
static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
{
- kib_peer_t *peer;
- struct list_head *ptmp;
- struct list_head *pnxt;
- int lo;
- int hi;
- int i;
- unsigned long flags;
- int count = 0;
+ kib_peer_t *peer;
+ struct list_head *ptmp;
+ struct list_head *pnxt;
+ int lo;
+ int hi;
+ int i;
+ unsigned long flags;
+ int count = 0;
write_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -1001,17 +1001,17 @@ static int kiblnd_close_matching_conns(lnet_ni_t *ni, lnet_nid_t nid)
int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
{
struct libcfs_ioctl_data *data = arg;
- int rc = -EINVAL;
+ int rc = -EINVAL;
switch (cmd) {
case IOC_LIBCFS_GET_PEER: {
- lnet_nid_t nid = 0;
- int count = 0;
+ lnet_nid_t nid = 0;
+ int count = 0;
rc = kiblnd_get_peer_info(ni, data->ioc_count,
&nid, &count);
- data->ioc_nid = nid;
- data->ioc_count = count;
+ data->ioc_nid = nid;
+ data->ioc_count = count;
break;
}
@@ -1053,11 +1053,11 @@ int kiblnd_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
{
- unsigned long last_alive = 0;
- unsigned long now = cfs_time_current();
- rwlock_t *glock = &kiblnd_data.kib_global_lock;
- kib_peer_t *peer;
- unsigned long flags;
+ unsigned long last_alive = 0;
+ unsigned long now = cfs_time_current();
+ rwlock_t *glock = &kiblnd_data.kib_global_lock;
+ kib_peer_t *peer;
+ unsigned long flags;
read_lock_irqsave(glock, flags);
@@ -1086,8 +1086,8 @@ void kiblnd_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
void kiblnd_free_pages(kib_pages_t *p)
{
- int npages = p->ibp_npages;
- int i;
+ int npages = p->ibp_npages;
+ int i;
for (i = 0; i < npages; i++) {
if (p->ibp_pages[i] != NULL)
@@ -1099,8 +1099,8 @@ void kiblnd_free_pages(kib_pages_t *p)
int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
{
- kib_pages_t *p;
- int i;
+ kib_pages_t *p;
+ int i;
LIBCFS_CPT_ALLOC(p, lnet_cpt_table(), cpt,
offsetof(kib_pages_t, ibp_pages[npages]));
@@ -1130,7 +1130,7 @@ int kiblnd_alloc_pages(kib_pages_t **pp, int cpt, int npages)
void kiblnd_unmap_rx_descs(kib_conn_t *conn)
{
kib_rx_t *rx;
- int i;
+ int i;
LASSERT(conn->ibc_rxs != NULL);
LASSERT(conn->ibc_hdev != NULL);
@@ -1153,14 +1153,13 @@ void kiblnd_unmap_rx_descs(kib_conn_t *conn)
void kiblnd_map_rx_descs(kib_conn_t *conn)
{
- kib_rx_t *rx;
- struct page *pg;
- int pg_off;
- int ipg;
- int i;
+ kib_rx_t *rx;
+ struct page *pg;
+ int pg_off;
+ int ipg;
+ int i;
- for (pg_off = ipg = i = 0;
- i < IBLND_RX_MSGS(conn->ibc_version); i++) {
+ for (pg_off = ipg = i = 0; i < IBLND_RX_MSGS(conn->ibc_version); i++) {
pg = conn->ibc_rx_pages->ibp_pages[ipg];
rx = &conn->ibc_rxs[i];
@@ -1192,9 +1191,9 @@ void kiblnd_map_rx_descs(kib_conn_t *conn)
static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
{
- kib_hca_dev_t *hdev = tpo->tpo_hdev;
- kib_tx_t *tx;
- int i;
+ kib_hca_dev_t *hdev = tpo->tpo_hdev;
+ kib_tx_t *tx;
+ int i;
LASSERT(tpo->tpo_pool.po_allocated == 0);
@@ -1216,8 +1215,8 @@ static void kiblnd_unmap_tx_pool(kib_tx_pool_t *tpo)
static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev)
{
kib_hca_dev_t *hdev;
- unsigned long flags;
- int i = 0;
+ unsigned long flags;
+ int i = 0;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
while (dev->ibd_failover) {
@@ -1240,15 +1239,15 @@ static kib_hca_dev_t *kiblnd_current_hdev(kib_dev_t *dev)
static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
{
- kib_pages_t *txpgs = tpo->tpo_tx_pages;
- kib_pool_t *pool = &tpo->tpo_pool;
- kib_net_t *net = pool->po_owner->ps_net;
- kib_dev_t *dev;
- struct page *page;
- kib_tx_t *tx;
- int page_offset;
- int ipage;
- int i;
+ kib_pages_t *txpgs = tpo->tpo_tx_pages;
+ kib_pool_t *pool = &tpo->tpo_pool;
+ kib_net_t *net = pool->po_owner->ps_net;
+ kib_dev_t *dev;
+ struct page *page;
+ kib_tx_t *tx;
+ int page_offset;
+ int ipage;
+ int i;
LASSERT(net != NULL);
@@ -1291,7 +1290,7 @@ static void kiblnd_map_tx_pool(kib_tx_pool_t *tpo)
struct ib_mr *kiblnd_find_dma_mr(kib_hca_dev_t *hdev, __u64 addr, __u64 size)
{
- __u64 index;
+ __u64 index;
LASSERT(hdev->ibh_mrs[0] != NULL);
@@ -1311,7 +1310,7 @@ struct ib_mr *kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev, kib_rdma_desc_t *rd)
{
struct ib_mr *prev_mr;
struct ib_mr *mr;
- int i;
+ int i;
LASSERT(hdev->ibh_mrs[0] != NULL);
@@ -1382,18 +1381,18 @@ static int kiblnd_create_fmr_pool(kib_fmr_poolset_t *fps,
kib_fmr_pool_t **pp_fpo)
{
/* FMR pool for RDMA */
- kib_dev_t *dev = fps->fps_net->ibn_dev;
- kib_fmr_pool_t *fpo;
+ kib_dev_t *dev = fps->fps_net->ibn_dev;
+ kib_fmr_pool_t *fpo;
struct ib_fmr_pool_param param = {
.max_pages_per_fmr = LNET_MAX_PAYLOAD/PAGE_SIZE,
- .page_shift = PAGE_SHIFT,
- .access = (IB_ACCESS_LOCAL_WRITE |
- IB_ACCESS_REMOTE_WRITE),
- .pool_size = fps->fps_pool_size,
+ .page_shift = PAGE_SHIFT,
+ .access = (IB_ACCESS_LOCAL_WRITE |
+ IB_ACCESS_REMOTE_WRITE),
+ .pool_size = fps->fps_pool_size,
.dirty_watermark = fps->fps_flush_trigger,
.flush_function = NULL,
- .flush_arg = NULL,
- .cache = !!*kiblnd_tunables.kib_fmr_cache};
+ .flush_arg = NULL,
+ .cache = !!*kiblnd_tunables.kib_fmr_cache};
int rc;
LIBCFS_CPT_ALLOC(fpo, lnet_cpt_table(), fps->fps_cpt, sizeof(*fpo));
@@ -1454,7 +1453,7 @@ static int kiblnd_init_fmr_poolset(kib_fmr_poolset_t *fps, int cpt,
int flush_trigger)
{
kib_fmr_pool_t *fpo;
- int rc;
+ int rc;
memset(fps, 0, sizeof(kib_fmr_poolset_t));
@@ -1485,11 +1484,11 @@ static int kiblnd_fmr_pool_is_idle(kib_fmr_pool_t *fpo, unsigned long now)
void kiblnd_fmr_pool_unmap(kib_fmr_t *fmr, int status)
{
LIST_HEAD(zombies);
- kib_fmr_pool_t *fpo = fmr->fmr_pool;
+ kib_fmr_pool_t *fpo = fmr->fmr_pool;
kib_fmr_poolset_t *fps = fpo->fpo_owner;
- unsigned long now = cfs_time_current();
- kib_fmr_pool_t *tmp;
- int rc;
+ unsigned long now = cfs_time_current();
+ kib_fmr_pool_t *tmp;
+ int rc;
rc = ib_fmr_pool_unmap(fmr->fmr_pfmr);
LASSERT(rc == 0);
@@ -1525,9 +1524,9 @@ int kiblnd_fmr_pool_map(kib_fmr_poolset_t *fps, __u64 *pages, int npages,
__u64 iov, kib_fmr_t *fmr)
{
struct ib_pool_fmr *pfmr;
- kib_fmr_pool_t *fpo;
- __u64 version;
- int rc;
+ kib_fmr_pool_t *fpo;
+ __u64 version;
+ int rc;
again:
spin_lock(&fps->fps_lock);
@@ -1658,13 +1657,13 @@ static int kiblnd_init_poolset(kib_poolset_t *ps, int cpt,
kib_ps_node_init_t nd_init,
kib_ps_node_fini_t nd_fini)
{
- kib_pool_t *pool;
- int rc;
+ kib_pool_t *pool;
+ int rc;
memset(ps, 0, sizeof(kib_poolset_t));
- ps->ps_cpt = cpt;
- ps->ps_net = net;
+ ps->ps_cpt = cpt;
+ ps->ps_net = net;
ps->ps_pool_create = po_create;
ps->ps_pool_destroy = po_destroy;
ps->ps_node_init = nd_init;
@@ -1698,9 +1697,9 @@ static int kiblnd_pool_is_idle(kib_pool_t *pool, unsigned long now)
void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
{
LIST_HEAD(zombies);
- kib_poolset_t *ps = pool->po_owner;
- kib_pool_t *tmp;
- unsigned long now = cfs_time_current();
+ kib_poolset_t *ps = pool->po_owner;
+ kib_pool_t *tmp;
+ unsigned long now = cfs_time_current();
spin_lock(&ps->ps_lock);
@@ -1727,9 +1726,9 @@ void kiblnd_pool_free_node(kib_pool_t *pool, struct list_head *node)
struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps)
{
- struct list_head *node;
- kib_pool_t *pool;
- int rc;
+ struct list_head *node;
+ kib_pool_t *pool;
+ int rc;
again:
spin_lock(&ps->ps_lock);
@@ -1789,8 +1788,8 @@ struct list_head *kiblnd_pool_alloc_node(kib_poolset_t *ps)
void kiblnd_pmr_pool_unmap(kib_phys_mr_t *pmr)
{
- kib_pmr_pool_t *ppo = pmr->pmr_pool;
- struct ib_mr *mr = pmr->pmr_mr;
+ kib_pmr_pool_t *ppo = pmr->pmr_pool;
+ struct ib_mr *mr = pmr->pmr_mr;
pmr->pmr_mr = NULL;
kiblnd_pool_free_node(&ppo->ppo_pool, &pmr->pmr_list);
@@ -1802,9 +1801,9 @@ int kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
kib_rdma_desc_t *rd, __u64 *iova, kib_phys_mr_t **pp_pmr)
{
kib_phys_mr_t *pmr;
- struct list_head *node;
- int rc;
- int i;
+ struct list_head *node;
+ int rc;
+ int i;
node = kiblnd_pool_alloc_node(&pps->pps_poolset);
if (node == NULL) {
@@ -1846,7 +1845,7 @@ int kiblnd_pmr_pool_map(kib_pmr_poolset_t *pps, kib_hca_dev_t *hdev,
static void kiblnd_destroy_pmr_pool(kib_pool_t *pool)
{
kib_pmr_pool_t *ppo = container_of(pool, kib_pmr_pool_t, ppo_pool);
- kib_phys_mr_t *pmr;
+ kib_phys_mr_t *pmr;
kib_phys_mr_t *tmp;
LASSERT(pool->po_allocated == 0);
@@ -1881,10 +1880,10 @@ static inline int kiblnd_pmr_pool_size(int ncpts)
static int kiblnd_create_pmr_pool(kib_poolset_t *ps, int size,
kib_pool_t **pp_po)
{
- struct kib_pmr_pool *ppo;
- struct kib_pool *pool;
- kib_phys_mr_t *pmr;
- int i;
+ struct kib_pmr_pool *ppo;
+ struct kib_pool *pool;
+ kib_phys_mr_t *pmr;
+ int i;
LIBCFS_CPT_ALLOC(ppo, lnet_cpt_table(),
ps->ps_cpt, sizeof(kib_pmr_pool_t));
@@ -1923,8 +1922,8 @@ static int kiblnd_create_pmr_pool(kib_poolset_t *ps, int size,
static void kiblnd_destroy_tx_pool(kib_pool_t *pool)
{
- kib_tx_pool_t *tpo = container_of(pool, kib_tx_pool_t, tpo_pool);
- int i;
+ kib_tx_pool_t *tpo = container_of(pool, kib_tx_pool_t, tpo_pool);
+ int i;
LASSERT(pool->po_allocated == 0);
@@ -1979,9 +1978,9 @@ static int kiblnd_tx_pool_size(int ncpts)
static int kiblnd_create_tx_pool(kib_poolset_t *ps, int size,
kib_pool_t **pp_po)
{
- int i;
- int npg;
- kib_pool_t *pool;
+ int i;
+ int npg;
+ kib_pool_t *pool;
kib_tx_pool_t *tpo;
LIBCFS_CPT_ALLOC(tpo, lnet_cpt_table(), ps->ps_cpt, sizeof(*tpo));
@@ -2064,19 +2063,19 @@ static void kiblnd_tx_init(kib_pool_t *pool, struct list_head *node)
{
kib_tx_poolset_t *tps = container_of(pool->po_owner, kib_tx_poolset_t,
tps_poolset);
- kib_tx_t *tx = list_entry(node, kib_tx_t, tx_list);
+ kib_tx_t *tx = list_entry(node, kib_tx_t, tx_list);
tx->tx_cookie = tps->tps_next_tx_cookie++;
}
static void kiblnd_net_fini_pools(kib_net_t *net)
{
- int i;
+ int i;
cfs_cpt_for_each(i, lnet_cpt_table()) {
- kib_tx_poolset_t *tps;
- kib_fmr_poolset_t *fps;
- kib_pmr_poolset_t *pps;
+ kib_tx_poolset_t *tps;
+ kib_fmr_poolset_t *fps;
+ kib_pmr_poolset_t *pps;
if (net->ibn_tx_ps != NULL) {
tps = net->ibn_tx_ps[i];
@@ -2112,16 +2111,15 @@ static void kiblnd_net_fini_pools(kib_net_t *net)
static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
{
- unsigned long flags;
- int cpt;
- int rc;
- int i;
+ unsigned long flags;
+ int cpt;
+ int rc;
+ int i;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
if (*kiblnd_tunables.kib_map_on_demand == 0 &&
net->ibn_dev->ibd_hdev->ibh_nmrs == 1) {
- read_unlock_irqrestore(&kiblnd_data.kib_global_lock,
- flags);
+ read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
goto create_tx_pool;
}
@@ -2241,7 +2239,7 @@ static int kiblnd_net_init_pools(kib_net_t *net, __u32 *cpts, int ncpts)
static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev)
{
struct ib_device_attr *attr;
- int rc;
+ int rc;
/* It's safe to assume a HCA can handle a page size
* matching that of the native system */
@@ -2284,7 +2282,7 @@ static int kiblnd_hdev_get_attr(kib_hca_dev_t *hdev)
static void kiblnd_hdev_cleanup_mrs(kib_hca_dev_t *hdev)
{
- int i;
+ int i;
if (hdev->ibh_nmrs == 0 || hdev->ibh_mrs == NULL)
return;
@@ -2317,12 +2315,11 @@ void kiblnd_hdev_destroy(kib_hca_dev_t *hdev)
static int kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev)
{
struct ib_mr *mr;
- int i;
- int rc;
- __u64 mm_size;
- __u64 mr_size;
- int acflags = IB_ACCESS_LOCAL_WRITE |
- IB_ACCESS_REMOTE_WRITE;
+ int i;
+ int rc;
+ __u64 mm_size;
+ __u64 mr_size;
+ int acflags = IB_ACCESS_LOCAL_WRITE | IB_ACCESS_REMOTE_WRITE;
rc = kiblnd_hdev_get_attr(hdev);
if (rc != 0)
@@ -2371,11 +2368,11 @@ static int kiblnd_hdev_setup_mrs(kib_hca_dev_t *hdev)
for (i = 0; i < hdev->ibh_nmrs; i++) {
struct ib_phys_buf ipb;
- __u64 iova;
+ __u64 iova;
ipb.size = hdev->ibh_mr_size;
ipb.addr = i * mr_size;
- iova = ipb.addr;
+ iova = ipb.addr;
mr = ib_reg_phys_mr(hdev->ibh_pd, &ipb, 1, acflags, &iova);
if (IS_ERR(mr)) {
@@ -2406,10 +2403,10 @@ static int kiblnd_dummy_callback(struct rdma_cm_id *cmid,
static int kiblnd_dev_need_failover(kib_dev_t *dev)
{
- struct rdma_cm_id *cmid;
- struct sockaddr_in srcaddr;
- struct sockaddr_in dstaddr;
- int rc;
+ struct rdma_cm_id *cmid;
+ struct sockaddr_in srcaddr;
+ struct sockaddr_in dstaddr;
+ int rc;
if (dev->ibd_hdev == NULL || /* initializing */
dev->ibd_hdev->ibh_cmid == NULL || /* listener is dead */
@@ -2435,7 +2432,7 @@ static int kiblnd_dev_need_failover(kib_dev_t *dev)
}
memset(&srcaddr, 0, sizeof(srcaddr));
- srcaddr.sin_family = AF_INET;
+ srcaddr.sin_family = AF_INET;
srcaddr.sin_addr.s_addr = (__force u32)htonl(dev->ibd_ifip);
memset(&dstaddr, 0, sizeof(dstaddr));
@@ -2464,15 +2461,15 @@ int kiblnd_dev_failover(kib_dev_t *dev)
LIST_HEAD(zombie_tpo);
LIST_HEAD(zombie_ppo);
LIST_HEAD(zombie_fpo);
- struct rdma_cm_id *cmid = NULL;
- kib_hca_dev_t *hdev = NULL;
- kib_hca_dev_t *old;
- struct ib_pd *pd;
- kib_net_t *net;
- struct sockaddr_in addr;
- unsigned long flags;
- int rc = 0;
- int i;
+ struct rdma_cm_id *cmid = NULL;
+ kib_hca_dev_t *hdev = NULL;
+ kib_hca_dev_t *old;
+ struct ib_pd *pd;
+ kib_net_t *net;
+ struct sockaddr_in addr;
+ unsigned long flags;
+ int rc = 0;
+ int i;
LASSERT(*kiblnd_tunables.kib_dev_failover > 1 ||
dev->ibd_can_failover ||
@@ -2614,11 +2611,11 @@ void kiblnd_destroy_dev(kib_dev_t *dev)
static kib_dev_t *kiblnd_create_dev(char *ifname)
{
struct net_device *netdev;
- kib_dev_t *dev;
- __u32 netmask;
- __u32 ip;
- int up;
- int rc;
+ kib_dev_t *dev;
+ __u32 netmask;
+ __u32 ip;
+ int up;
+ int rc;
rc = libcfs_ipif_query(ifname, &up, &ip, &netmask);
if (rc != 0) {
@@ -2665,8 +2662,8 @@ static kib_dev_t *kiblnd_create_dev(char *ifname)
static void kiblnd_base_shutdown(void)
{
- struct kib_sched_info *sched;
- int i;
+ struct kib_sched_info *sched;
+ int i;
LASSERT(list_empty(&kiblnd_data.kib_devs));
@@ -2732,10 +2729,10 @@ static void kiblnd_base_shutdown(void)
void kiblnd_shutdown(lnet_ni_t *ni)
{
- kib_net_t *net = ni->ni_data;
- rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
- int i;
- unsigned long flags;
+ kib_net_t *net = ni->ni_data;
+ rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
+ int i;
+ unsigned long flags;
LASSERT(kiblnd_data.kib_init == IBLND_INIT_ALL);
@@ -2804,9 +2801,9 @@ out:
static int kiblnd_base_startup(void)
{
- struct kib_sched_info *sched;
- int rc;
- int i;
+ struct kib_sched_info *sched;
+ int rc;
+ int i;
LASSERT(kiblnd_data.kib_init == IBLND_INIT_NOTHING);
@@ -2821,8 +2818,7 @@ static int kiblnd_base_startup(void)
kiblnd_data.kib_peer_hash_size = IBLND_PEER_HASH_SIZE;
LIBCFS_ALLOC(kiblnd_data.kib_peers,
- sizeof(struct list_head) *
- kiblnd_data.kib_peer_hash_size);
+ sizeof(struct list_head) * kiblnd_data.kib_peer_hash_size);
if (kiblnd_data.kib_peers == NULL)
goto failed;
for (i = 0; i < kiblnd_data.kib_peer_hash_size; i++)
@@ -2840,7 +2836,7 @@ static int kiblnd_base_startup(void)
goto failed;
cfs_percpt_for_each(sched, i, kiblnd_data.kib_scheds) {
- int nthrs;
+ int nthrs;
spin_lock_init(&sched->ibs_lock);
INIT_LIST_HEAD(&sched->ibs_conns);
@@ -2893,9 +2889,9 @@ static int kiblnd_base_startup(void)
static int kiblnd_start_schedulers(struct kib_sched_info *sched)
{
- int rc = 0;
- int nthrs;
- int i;
+ int rc = 0;
+ int nthrs;
+ int i;
if (sched->ibs_nthreads == 0) {
if (*kiblnd_tunables.kib_nscheds > 0) {
@@ -2913,8 +2909,8 @@ static int kiblnd_start_schedulers(struct kib_sched_info *sched)
}
for (i = 0; i < nthrs; i++) {
- long id;
- char name[20];
+ long id;
+ char name[20];
id = KIB_THREAD_ID(sched->ibs_cpt, sched->ibs_nthreads + i);
snprintf(name, sizeof(name), "kiblnd_sd_%02ld_%02ld",
@@ -2935,9 +2931,9 @@ static int kiblnd_start_schedulers(struct kib_sched_info *sched)
static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts,
int ncpts)
{
- int cpt;
- int rc;
- int i;
+ int cpt;
+ int rc;
+ int i;
for (i = 0; i < ncpts; i++) {
struct kib_sched_info *sched;
@@ -2960,10 +2956,10 @@ static int kiblnd_dev_start_threads(kib_dev_t *dev, int newdev, __u32 *cpts,
static kib_dev_t *kiblnd_dev_search(char *ifname)
{
- kib_dev_t *alias = NULL;
- kib_dev_t *dev;
- char *colon;
- char *colon2;
+ kib_dev_t *alias = NULL;
+ kib_dev_t *dev;
+ char *colon;
+ char *colon2;
colon = strchr(ifname, ':');
list_for_each_entry(dev, &kiblnd_data.kib_devs, ibd_list) {
@@ -2992,13 +2988,13 @@ static kib_dev_t *kiblnd_dev_search(char *ifname)
int kiblnd_startup(lnet_ni_t *ni)
{
- char *ifname;
- kib_dev_t *ibdev = NULL;
- kib_net_t *net;
- struct timeval tv;
- unsigned long flags;
- int rc;
- int newdev;
+ char *ifname;
+ kib_dev_t *ibdev = NULL;
+ kib_net_t *net;
+ struct timeval tv;
+ unsigned long flags;
+ int rc;
+ int newdev;
LASSERT(ni->ni_lnd == &the_o2iblnd);
@@ -3091,7 +3087,7 @@ static void __exit kiblnd_module_fini(void)
static int __init kiblnd_module_init(void)
{
- int rc;
+ int rc;
CLASSERT(sizeof(kib_msg_t) <= IBLND_MSG_SIZE);
CLASSERT(offsetof(kib_msg_t,
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
index cd664d025f418d..7f52c696342737 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.h
@@ -80,42 +80,47 @@
#define IBLND_N_SCHED_HIGH 4
typedef struct {
- int *kib_dev_failover; /* HCA failover */
- unsigned int *kib_service; /* IB service number */
- int *kib_min_reconnect_interval; /* first failed connection retry... */
- int *kib_max_reconnect_interval; /* ...exponentially increasing to this */
- int *kib_cksum; /* checksum kib_msg_t? */
- int *kib_timeout; /* comms timeout (seconds) */
- int *kib_keepalive; /* keepalive timeout (seconds) */
- int *kib_ntx; /* # tx descs */
- int *kib_credits; /* # concurrent sends */
- int *kib_peertxcredits; /* # concurrent sends to 1 peer */
- int *kib_peerrtrcredits; /* # per-peer router buffer credits */
- int *kib_peercredits_hiw; /* # when eagerly to return credits */
- int *kib_peertimeout; /* seconds to consider peer dead */
- char **kib_default_ipif; /* default IPoIB interface */
- int *kib_retry_count;
- int *kib_rnr_retry_count;
- int *kib_concurrent_sends; /* send work queue sizing */
- int *kib_ib_mtu; /* IB MTU */
- int *kib_map_on_demand; /* map-on-demand if RD has more fragments
- * than this value, 0 disable map-on-demand */
- int *kib_pmr_pool_size; /* # physical MR in pool */
- int *kib_fmr_pool_size; /* # FMRs in pool */
- int *kib_fmr_flush_trigger; /* When to trigger FMR flush */
- int *kib_fmr_cache; /* enable FMR pool cache? */
- int *kib_require_priv_port;/* accept only privileged ports */
- int *kib_use_priv_port; /* use privileged port for active connect */
- /* # threads on each CPT */
- int *kib_nscheds;
+ int *kib_dev_failover; /* HCA failover */
+ unsigned int *kib_service; /* IB service number */
+ int *kib_min_reconnect_interval; /* first failed connection
+ * retry... */
+ int *kib_max_reconnect_interval; /* ...exponentially increasing
+ * to this */
+ int *kib_cksum; /* checksum kib_msg_t? */
+ int *kib_timeout; /* comms timeout (seconds) */
+ int *kib_keepalive; /* keepalive timeout (seconds) */
+ int *kib_ntx; /* # tx descs */
+ int *kib_credits; /* # concurrent sends */
+ int *kib_peertxcredits; /* # concurrent sends to 1 peer */
+ int *kib_peerrtrcredits; /* # per-peer router buffer
+ * credits */
+ int *kib_peercredits_hiw; /* # when eagerly to return
+ * credits */
+ int *kib_peertimeout; /* seconds to consider peer dead */
+ char **kib_default_ipif; /* default IPoIB interface */
+ int *kib_retry_count;
+ int *kib_rnr_retry_count;
+ int *kib_concurrent_sends; /* send work queue sizing */
+ int *kib_ib_mtu; /* IB MTU */
+ int *kib_map_on_demand; /* map-on-demand if RD has more
+ * fragments than this value, 0
+ * disable map-on-demand */
+ int *kib_pmr_pool_size; /* # physical MR in pool */
+ int *kib_fmr_pool_size; /* # FMRs in pool */
+ int *kib_fmr_flush_trigger; /* When to trigger FMR flush */
+ int *kib_fmr_cache; /* enable FMR pool cache? */
+ int *kib_require_priv_port; /* accept only privileged ports */
+ int *kib_use_priv_port; /* use privileged port for active
+ * connect */
+ int *kib_nscheds; /* # threads on each CPT */
} kib_tunables_t;
extern kib_tunables_t kiblnd_tunables;
-#define IBLND_MSG_QUEUE_SIZE_V1 8 /* V1 only : # messages/RDMAs in-flight */
-#define IBLND_CREDIT_HIGHWATER_V1 7 /* V1 only : when eagerly to return credits */
+#define IBLND_MSG_QUEUE_SIZE_V1 8 /* V1 only : # messages/RDMAs in-flight */
+#define IBLND_CREDIT_HIGHWATER_V1 7 /* V1 only : when eagerly to return credits */
-#define IBLND_CREDITS_DEFAULT 8 /* default # of peer credits */
+#define IBLND_CREDITS_DEFAULT 8 /* default # of peer credits */
#define IBLND_CREDITS_MAX ((typeof(((kib_msg_t*) 0)->ibm_credits)) - 1) /* Max # of peer credits */
#define IBLND_MSG_QUEUE_SIZE(v) ((v) == IBLND_MSG_VERSION_1 ? \
@@ -186,34 +191,36 @@ struct kib_hca_dev;
#endif
typedef struct {
- struct list_head ibd_list; /* chain on kib_devs */
- struct list_head ibd_fail_list; /* chain on kib_failed_devs */
- __u32 ibd_ifip; /* IPoIB interface IP */
- /** IPoIB interface name */
- char ibd_ifname[KIB_IFNAME_SIZE];
- int ibd_nnets; /* # nets extant */
-
- unsigned long ibd_next_failover;
- int ibd_failed_failover; /* # failover failures */
- unsigned int ibd_failover; /* failover in progress */
- unsigned int ibd_can_failover; /* IPoIB interface is a bonding master */
- struct list_head ibd_nets;
- struct kib_hca_dev *ibd_hdev;
+ struct list_head ibd_list; /* chain on kib_devs */
+ struct list_head ibd_fail_list; /* chain on kib_failed_devs */
+ __u32 ibd_ifip; /* IPoIB interface IP */
+
+ /* IPoIB interface name */
+ char ibd_ifname[KIB_IFNAME_SIZE];
+ int ibd_nnets; /* # nets extant */
+
+ unsigned long ibd_next_failover;
+ int ibd_failed_failover; /* # failover failures */
+ unsigned int ibd_failover; /* failover in progress */
+ unsigned int ibd_can_failover; /* IPoIB interface is a bonding
+ * master */
+ struct list_head ibd_nets;
+ struct kib_hca_dev *ibd_hdev;
} kib_dev_t;
typedef struct kib_hca_dev {
- struct rdma_cm_id *ibh_cmid; /* listener cmid */
- struct ib_device *ibh_ibdev; /* IB device */
- int ibh_page_shift; /* page shift of current HCA */
- int ibh_page_size; /* page size of current HCA */
- __u64 ibh_page_mask; /* page mask of current HCA */
- int ibh_mr_shift; /* bits shift of max MR size */
- __u64 ibh_mr_size; /* size of MR */
- int ibh_nmrs; /* # of global MRs */
- struct ib_mr **ibh_mrs; /* global MR */
- struct ib_pd *ibh_pd; /* PD */
- kib_dev_t *ibh_dev; /* owner */
- atomic_t ibh_ref; /* refcount */
+ struct rdma_cm_id *ibh_cmid; /* listener cmid */
+ struct ib_device *ibh_ibdev; /* IB device */
+ int ibh_page_shift; /* page shift of current HCA */
+ int ibh_page_size; /* page size of current HCA */
+ __u64 ibh_page_mask; /* page mask of current HCA */
+ int ibh_mr_shift; /* bits shift of max MR size */
+ __u64 ibh_mr_size; /* size of MR */
+ int ibh_nmrs; /* # of global MRs */
+ struct ib_mr **ibh_mrs; /* global MR */
+ struct ib_pd *ibh_pd; /* PD */
+ kib_dev_t *ibh_dev; /* owner */
+ atomic_t ibh_ref; /* refcount */
} kib_hca_dev_t;
/** # of seconds to keep pool alive */
@@ -222,19 +229,19 @@ typedef struct kib_hca_dev {
#define IBLND_POOL_RETRY 1
typedef struct {
- int ibp_npages; /* # pages */
- struct page *ibp_pages[0]; /* page array */
+ int ibp_npages; /* # pages */
+ struct page *ibp_pages[0]; /* page array */
} kib_pages_t;
struct kib_pmr_pool;
typedef struct {
- struct list_head pmr_list; /* chain node */
- struct ib_phys_buf *pmr_ipb; /* physical buffer */
- struct ib_mr *pmr_mr; /* IB MR */
- struct kib_pmr_pool *pmr_pool; /* owner of this MR */
- __u64 pmr_iova; /* Virtual I/O address */
- int pmr_refcount; /* reference count */
+ struct list_head pmr_list; /* chain node */
+ struct ib_phys_buf *pmr_ipb; /* physical buffer */
+ struct ib_mr *pmr_mr; /* IB MR */
+ struct kib_pmr_pool *pmr_pool; /* owner of this MR */
+ __u64 pmr_iova; /* Virtual I/O address */
+ int pmr_refcount; /* reference count */
} kib_phys_mr_t;
struct kib_pool;
@@ -251,97 +258,99 @@ struct kib_net;
#define IBLND_POOL_NAME_LEN 32
typedef struct kib_poolset {
- spinlock_t ps_lock; /* serialize */
- struct kib_net *ps_net; /* network it belongs to */
- char ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */
- struct list_head ps_pool_list; /* list of pools */
- struct list_head ps_failed_pool_list; /* failed pool list */
- unsigned long ps_next_retry; /* time stamp for retry if failed to allocate */
- int ps_increasing; /* is allocating new pool */
- int ps_pool_size; /* new pool size */
- int ps_cpt; /* CPT id */
-
- kib_ps_pool_create_t ps_pool_create; /* create a new pool */
- kib_ps_pool_destroy_t ps_pool_destroy; /* destroy a pool */
- kib_ps_node_init_t ps_node_init; /* initialize new allocated node */
- kib_ps_node_fini_t ps_node_fini; /* finalize node */
+ spinlock_t ps_lock; /* serialize */
+ struct kib_net *ps_net; /* network it belongs to */
+ char ps_name[IBLND_POOL_NAME_LEN]; /* pool set name */
+ struct list_head ps_pool_list; /* list of pools */
+ struct list_head ps_failed_pool_list;/* failed pool list */
+ unsigned long ps_next_retry; /* time stamp for retry if
+ * failed to allocate */
+ int ps_increasing; /* is allocating new pool */
+ int ps_pool_size; /* new pool size */
+ int ps_cpt; /* CPT id */
+
+ kib_ps_pool_create_t ps_pool_create; /* create a new pool */
+ kib_ps_pool_destroy_t ps_pool_destroy; /* destroy a pool */
+ kib_ps_node_init_t ps_node_init; /* initialize new allocated
+ * node */
+ kib_ps_node_fini_t ps_node_fini; /* finalize node */
} kib_poolset_t;
typedef struct kib_pool {
- struct list_head po_list; /* chain on pool list */
- struct list_head po_free_list; /* pre-allocated node */
- kib_poolset_t *po_owner; /* pool_set of this pool */
- unsigned long po_deadline; /* deadline of this pool */
- int po_allocated; /* # of elements in use */
- int po_failed; /* pool is created on failed HCA */
- int po_size; /* # of pre-allocated elements */
+ struct list_head po_list; /* chain on pool list */
+ struct list_head po_free_list; /* pre-allocated node */
+ kib_poolset_t *po_owner; /* pool_set of this pool */
+ unsigned long po_deadline; /* deadline of this pool */
+ int po_allocated; /* # of elements in use */
+ int po_failed; /* pool is created on failed
+ * HCA */
+ int po_size; /* # of pre-allocated elements */
} kib_pool_t;
typedef struct {
- kib_poolset_t tps_poolset; /* pool-set */
- __u64 tps_next_tx_cookie; /* cookie of TX */
+ kib_poolset_t tps_poolset; /* pool-set */
+ __u64 tps_next_tx_cookie; /* cookie of TX */
} kib_tx_poolset_t;
typedef struct {
- kib_pool_t tpo_pool; /* pool */
- struct kib_hca_dev *tpo_hdev; /* device for this pool */
- struct kib_tx *tpo_tx_descs; /* all the tx descriptors */
- kib_pages_t *tpo_tx_pages; /* premapped tx msg pages */
+ kib_pool_t tpo_pool; /* pool */
+ struct kib_hca_dev *tpo_hdev; /* device for this pool */
+ struct kib_tx *tpo_tx_descs; /* all the tx descriptors */
+ kib_pages_t *tpo_tx_pages; /* premapped tx msg pages */
} kib_tx_pool_t;
typedef struct {
- kib_poolset_t pps_poolset; /* pool-set */
+ kib_poolset_t pps_poolset; /* pool-set */
} kib_pmr_poolset_t;
typedef struct kib_pmr_pool {
- struct kib_hca_dev *ppo_hdev; /* device for this pool */
- kib_pool_t ppo_pool; /* pool */
+ struct kib_hca_dev *ppo_hdev; /* device for this pool */
+ kib_pool_t ppo_pool; /* pool */
} kib_pmr_pool_t;
typedef struct {
- spinlock_t fps_lock; /* serialize */
- struct kib_net *fps_net; /* IB network */
- struct list_head fps_pool_list; /* FMR pool list */
- struct list_head fps_failed_pool_list; /* FMR pool list */
- __u64 fps_version; /* validity stamp */
- int fps_cpt; /* CPT id */
- int fps_pool_size;
- int fps_flush_trigger;
- /* is allocating new pool */
- int fps_increasing;
- /* time stamp for retry if failed to allocate */
- unsigned long fps_next_retry;
+ spinlock_t fps_lock; /* serialize */
+ struct kib_net *fps_net; /* IB network */
+ struct list_head fps_pool_list; /* FMR pool list */
+ struct list_head fps_failed_pool_list;/* FMR pool list */
+ __u64 fps_version; /* validity stamp */
+ int fps_cpt; /* CPT id */
+ int fps_pool_size;
+ int fps_flush_trigger;
+ int fps_increasing; /* is allocating new pool */
+ unsigned long fps_next_retry; /* time stamp for retry if
+ * failed to allocate */
} kib_fmr_poolset_t;
typedef struct {
- struct list_head fpo_list; /* chain on pool list */
- struct kib_hca_dev *fpo_hdev; /* device for this pool */
- kib_fmr_poolset_t *fpo_owner; /* owner of this pool */
- struct ib_fmr_pool *fpo_fmr_pool; /* IB FMR pool */
- unsigned long fpo_deadline; /* deadline of this pool */
- int fpo_failed; /* fmr pool is failed */
- int fpo_map_count; /* # of mapped FMR */
+ struct list_head fpo_list; /* chain on pool list */
+ struct kib_hca_dev *fpo_hdev; /* device for this pool */
+ kib_fmr_poolset_t *fpo_owner; /* owner of this pool */
+ struct ib_fmr_pool *fpo_fmr_pool; /* IB FMR pool */
+ unsigned long fpo_deadline; /* deadline of this pool */
+ int fpo_failed; /* fmr pool is failed */
+ int fpo_map_count; /* # of mapped FMR */
} kib_fmr_pool_t;
typedef struct {
- struct ib_pool_fmr *fmr_pfmr; /* IB pool fmr */
- kib_fmr_pool_t *fmr_pool; /* pool of FMR */
+ struct ib_pool_fmr *fmr_pfmr; /* IB pool fmr */
+ kib_fmr_pool_t *fmr_pool; /* pool of FMR */
} kib_fmr_t;
typedef struct kib_net {
- struct list_head ibn_list; /* chain on kib_dev_t::ibd_nets */
- __u64 ibn_incarnation; /* my epoch */
- int ibn_init; /* initialisation state */
- int ibn_shutdown; /* shutting down? */
+ struct list_head ibn_list; /* chain on kib_dev_t::ibd_nets */
+ __u64 ibn_incarnation;/* my epoch */
+ int ibn_init; /* initialisation state */
+ int ibn_shutdown; /* shutting down? */
- atomic_t ibn_npeers; /* # peers extant */
- atomic_t ibn_nconns; /* # connections extant */
+ atomic_t ibn_npeers; /* # peers extant */
+ atomic_t ibn_nconns; /* # connections extant */
- kib_tx_poolset_t **ibn_tx_ps; /* tx pool-set */
- kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */
- kib_pmr_poolset_t **ibn_pmr_ps; /* pmr pool-set */
+ kib_tx_poolset_t **ibn_tx_ps; /* tx pool-set */
+ kib_fmr_poolset_t **ibn_fmr_ps; /* fmr pool-set */
+ kib_pmr_poolset_t **ibn_pmr_ps; /* pmr pool-set */
- kib_dev_t *ibn_dev; /* underlying IB device */
+ kib_dev_t *ibn_dev; /* underlying IB device */
} kib_net_t;
#define KIB_THREAD_SHIFT 16
@@ -350,51 +359,45 @@ typedef struct kib_net {
#define KIB_THREAD_TID(id) ((id) & ((1UL << KIB_THREAD_SHIFT) - 1))
struct kib_sched_info {
- /* serialise */
- spinlock_t ibs_lock;
- /* schedulers sleep here */
- wait_queue_head_t ibs_waitq;
- /* conns to check for rx completions */
- struct list_head ibs_conns;
- /* number of scheduler threads */
- int ibs_nthreads;
- /* max allowed scheduler threads */
- int ibs_nthreads_max;
- int ibs_cpt; /* CPT id */
+ spinlock_t ibs_lock; /* serialise */
+ wait_queue_head_t ibs_waitq; /* schedulers sleep here */
+ struct list_head ibs_conns; /* conns to check for rx completions */
+ int ibs_nthreads; /* number of scheduler threads */
+ int ibs_nthreads_max; /* max allowed scheduler threads */
+ int ibs_cpt; /* CPT id */
};
typedef struct {
- int kib_init; /* initialisation state */
- int kib_shutdown; /* shut down? */
- struct list_head kib_devs; /* IB devices extant */
- /* list head of failed devices */
- struct list_head kib_failed_devs;
- /* schedulers sleep here */
- wait_queue_head_t kib_failover_waitq;
- atomic_t kib_nthreads; /* # live threads */
- /* stabilize net/dev/peer/conn ops */
- rwlock_t kib_global_lock;
- /* hash table of all my known peers */
- struct list_head *kib_peers;
- /* size of kib_peers */
- int kib_peer_hash_size;
- /* the connd task (serialisation assertions) */
- void *kib_connd;
- /* connections to setup/teardown */
- struct list_head kib_connd_conns;
- /* connections with zero refcount */
- struct list_head kib_connd_zombies;
- /* connection daemon sleeps here */
- wait_queue_head_t kib_connd_waitq;
- spinlock_t kib_connd_lock; /* serialise */
- struct ib_qp_attr kib_error_qpa; /* QP->ERROR */
- /* percpt data for schedulers */
- struct kib_sched_info **kib_scheds;
+ int kib_init; /* initialisation state */
+ int kib_shutdown; /* shut down? */
+ struct list_head kib_devs; /* IB devices extant */
+ struct list_head kib_failed_devs; /* list head of failed
+ * devices */
+ wait_queue_head_t kib_failover_waitq; /* schedulers sleep here */
+ atomic_t kib_nthreads; /* # live threads */
+ rwlock_t kib_global_lock; /* stabilize net/dev/peer/conn
+ * ops */
+ struct list_head *kib_peers; /* hash table of all my known
+ * peers */
+ int kib_peer_hash_size; /* size of kib_peers */
+ void *kib_connd; /* the connd task
+ * (serialisation assertions)
+ */
+ struct list_head kib_connd_conns; /* connections to
+ * setup/teardown */
+ struct list_head kib_connd_zombies; /* connections with zero
+ * refcount */
+ wait_queue_head_t kib_connd_waitq; /* connection daemon sleeps
+ * here */
+ spinlock_t kib_connd_lock; /* serialise */
+ struct ib_qp_attr kib_error_qpa; /* QP->ERROR */
+ struct kib_sched_info **kib_scheds; /* percpt data for schedulers
+ */
} kib_data_t;
-#define IBLND_INIT_NOTHING 0
-#define IBLND_INIT_DATA 1
-#define IBLND_INIT_ALL 2
+#define IBLND_INIT_NOTHING 0
+#define IBLND_INIT_DATA 1
+#define IBLND_INIT_ALL 2
/************************************************************************
* IB Wire message format.
@@ -402,228 +405,243 @@ typedef struct {
*/
typedef struct kib_connparams {
- __u16 ibcp_queue_depth;
- __u16 ibcp_max_frags;
- __u32 ibcp_max_msg_size;
+ __u16 ibcp_queue_depth;
+ __u16 ibcp_max_frags;
+ __u32 ibcp_max_msg_size;
} WIRE_ATTR kib_connparams_t;
typedef struct {
- lnet_hdr_t ibim_hdr; /* portals header */
- char ibim_payload[0]; /* piggy-backed payload */
+ lnet_hdr_t ibim_hdr; /* portals header */
+ char ibim_payload[0]; /* piggy-backed payload */
} WIRE_ATTR kib_immediate_msg_t;
typedef struct {
- __u32 rf_nob; /* # bytes this frag */
- __u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */
+ __u32 rf_nob; /* # bytes this frag */
+ __u64 rf_addr; /* CAVEAT EMPTOR: misaligned!! */
} WIRE_ATTR kib_rdma_frag_t;
typedef struct {
- __u32 rd_key; /* local/remote key */
- __u32 rd_nfrags; /* # fragments */
- kib_rdma_frag_t rd_frags[0]; /* buffer frags */
+ __u32 rd_key; /* local/remote key */
+ __u32 rd_nfrags; /* # fragments */
+ kib_rdma_frag_t rd_frags[0]; /* buffer frags */
} WIRE_ATTR kib_rdma_desc_t;
typedef struct {
- lnet_hdr_t ibprm_hdr; /* portals header */
- __u64 ibprm_cookie; /* opaque completion cookie */
+ lnet_hdr_t ibprm_hdr; /* portals header */
+ __u64 ibprm_cookie; /* opaque completion cookie */
} WIRE_ATTR kib_putreq_msg_t;
typedef struct {
- __u64 ibpam_src_cookie; /* reflected completion cookie */
- __u64 ibpam_dst_cookie; /* opaque completion cookie */
- kib_rdma_desc_t ibpam_rd; /* sender's sink buffer */
+ __u64 ibpam_src_cookie; /* reflected completion cookie */
+ __u64 ibpam_dst_cookie; /* opaque completion cookie */
+ kib_rdma_desc_t ibpam_rd; /* sender's sink buffer */
} WIRE_ATTR kib_putack_msg_t;
typedef struct {
- lnet_hdr_t ibgm_hdr; /* portals header */
- __u64 ibgm_cookie; /* opaque completion cookie */
- kib_rdma_desc_t ibgm_rd; /* rdma descriptor */
+ lnet_hdr_t ibgm_hdr; /* portals header */
+ __u64 ibgm_cookie; /* opaque completion cookie */
+ kib_rdma_desc_t ibgm_rd; /* rdma descriptor */
} WIRE_ATTR kib_get_msg_t;
typedef struct {
- __u64 ibcm_cookie; /* opaque completion cookie */
- __s32 ibcm_status; /* < 0 failure: >= 0 length */
+ __u64 ibcm_cookie; /* opaque completion cookie */
+ __s32 ibcm_status; /* < 0 failure: >= 0 length */
} WIRE_ATTR kib_completion_msg_t;
typedef struct {
/* First 2 fields fixed FOR ALL TIME */
- __u32 ibm_magic; /* I'm an ibnal message */
- __u16 ibm_version; /* this is my version number */
-
- __u8 ibm_type; /* msg type */
- __u8 ibm_credits; /* returned credits */
- __u32 ibm_nob; /* # bytes in whole message */
- __u32 ibm_cksum; /* checksum (0 == no checksum) */
- __u64 ibm_srcnid; /* sender's NID */
- __u64 ibm_srcstamp; /* sender's incarnation */
- __u64 ibm_dstnid; /* destination's NID */
- __u64 ibm_dststamp; /* destination's incarnation */
+ __u32 ibm_magic; /* I'm an ibnal message */
+ __u16 ibm_version; /* this is my version number */
+
+ __u8 ibm_type; /* msg type */
+ __u8 ibm_credits; /* returned credits */
+ __u32 ibm_nob; /* # bytes in whole message */
+ __u32 ibm_cksum; /* checksum (0 == no checksum) */
+ __u64 ibm_srcnid; /* sender's NID */
+ __u64 ibm_srcstamp; /* sender's incarnation */
+ __u64 ibm_dstnid; /* destination's NID */
+ __u64 ibm_dststamp; /* destination's incarnation */
union {
- kib_connparams_t connparams;
- kib_immediate_msg_t immediate;
- kib_putreq_msg_t putreq;
- kib_putack_msg_t putack;
- kib_get_msg_t get;
- kib_completion_msg_t completion;
+ kib_connparams_t connparams;
+ kib_immediate_msg_t immediate;
+ kib_putreq_msg_t putreq;
+ kib_putack_msg_t putack;
+ kib_get_msg_t get;
+ kib_completion_msg_t completion;
} WIRE_ATTR ibm_u;
} WIRE_ATTR kib_msg_t;
-#define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */
+#define IBLND_MSG_MAGIC LNET_PROTO_IB_MAGIC /* unique magic */
-#define IBLND_MSG_VERSION_1 0x11
-#define IBLND_MSG_VERSION_2 0x12
-#define IBLND_MSG_VERSION IBLND_MSG_VERSION_2
+#define IBLND_MSG_VERSION_1 0x11
+#define IBLND_MSG_VERSION_2 0x12
+#define IBLND_MSG_VERSION IBLND_MSG_VERSION_2
-#define IBLND_MSG_CONNREQ 0xc0 /* connection request */
-#define IBLND_MSG_CONNACK 0xc1 /* connection acknowledge */
-#define IBLND_MSG_NOOP 0xd0 /* nothing (just credits) */
-#define IBLND_MSG_IMMEDIATE 0xd1 /* immediate */
-#define IBLND_MSG_PUT_REQ 0xd2 /* putreq (src->sink) */
-#define IBLND_MSG_PUT_NAK 0xd3 /* completion (sink->src) */
-#define IBLND_MSG_PUT_ACK 0xd4 /* putack (sink->src) */
-#define IBLND_MSG_PUT_DONE 0xd5 /* completion (src->sink) */
-#define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */
-#define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */
+#define IBLND_MSG_CONNREQ 0xc0 /* connection request */
+#define IBLND_MSG_CONNACK 0xc1 /* connection acknowledge */
+#define IBLND_MSG_NOOP 0xd0 /* nothing (just credits) */
+#define IBLND_MSG_IMMEDIATE 0xd1 /* immediate */
+#define IBLND_MSG_PUT_REQ 0xd2 /* putreq (src->sink) */
+#define IBLND_MSG_PUT_NAK 0xd3 /* completion (sink->src) */
+#define IBLND_MSG_PUT_ACK 0xd4 /* putack (sink->src) */
+#define IBLND_MSG_PUT_DONE 0xd5 /* completion (src->sink) */
+#define IBLND_MSG_GET_REQ 0xd6 /* getreq (sink->src) */
+#define IBLND_MSG_GET_DONE 0xd7 /* completion (src->sink: all OK) */
typedef struct {
- __u32 ibr_magic; /* sender's magic */
- __u16 ibr_version; /* sender's version */
- __u8 ibr_why; /* reject reason */
- __u8 ibr_padding; /* padding */
- __u64 ibr_incarnation; /* incarnation of peer */
- kib_connparams_t ibr_cp; /* connection parameters */
+ __u32 ibr_magic; /* sender's magic */
+ __u16 ibr_version; /* sender's version */
+ __u8 ibr_why; /* reject reason */
+ __u8 ibr_padding; /* padding */
+ __u64 ibr_incarnation; /* incarnation of peer */
+ kib_connparams_t ibr_cp; /* connection parameters */
} WIRE_ATTR kib_rej_t;
/* connection rejection reasons */
-#define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */
-#define IBLND_REJECT_NO_RESOURCES 2 /* Out of memory/conns etc */
-#define IBLND_REJECT_FATAL 3 /* Anything else */
-
-#define IBLND_REJECT_CONN_UNCOMPAT 4 /* incompatible version peer */
-#define IBLND_REJECT_CONN_STALE 5 /* stale peer */
-
-#define IBLND_REJECT_RDMA_FRAGS 6 /* Fatal: peer's rdma frags can't match mine */
-#define IBLND_REJECT_MSG_QUEUE_SIZE 7 /* Fatal: peer's msg queue size can't match mine */
+#define IBLND_REJECT_CONN_RACE 1 /* You lost connection race */
+#define IBLND_REJECT_NO_RESOURCES 2 /* Out of memory/conns etc */
+#define IBLND_REJECT_FATAL 3 /* Anything else */
+#define IBLND_REJECT_CONN_UNCOMPAT 4 /* incompatible version peer */
+#define IBLND_REJECT_CONN_STALE 5 /* stale peer */
+#define IBLND_REJECT_RDMA_FRAGS 6 /* Fatal: peer's rdma frags can't match
+ * mine */
+#define IBLND_REJECT_MSG_QUEUE_SIZE 7 /* Fatal: peer's msg queue size can't
+ * match mine */
/***********************************************************************/
-typedef struct kib_rx /* receive message */
+typedef struct kib_rx /* receive message */
{
- struct list_head rx_list; /* queue for attention */
- struct kib_conn *rx_conn; /* owning conn */
- int rx_nob; /* # bytes received (-1 while posted) */
- enum ib_wc_status rx_status; /* completion status */
- kib_msg_t *rx_msg; /* message buffer (host vaddr) */
- __u64 rx_msgaddr; /* message buffer (I/O addr) */
- DECLARE_PCI_UNMAP_ADDR (rx_msgunmap); /* for dma_unmap_single() */
- struct ib_recv_wr rx_wrq; /* receive work item... */
- struct ib_sge rx_sge; /* ...and its memory */
+ struct list_head rx_list; /* queue for attention */
+ struct kib_conn *rx_conn; /* owning conn */
+ int rx_nob; /* # bytes received (-1 while
+ * posted) */
+ enum ib_wc_status rx_status; /* completion status */
+ kib_msg_t *rx_msg; /* message buffer (host vaddr) */
+ __u64 rx_msgaddr; /* message buffer (I/O addr) */
+ DECLARE_PCI_UNMAP_ADDR (rx_msgunmap); /* for dma_unmap_single() */
+ struct ib_recv_wr rx_wrq; /* receive work item... */
+ struct ib_sge rx_sge; /* ...and its memory */
} kib_rx_t;
-#define IBLND_POSTRX_DONT_POST 0 /* don't post */
-#define IBLND_POSTRX_NO_CREDIT 1 /* post: no credits */
-#define IBLND_POSTRX_PEER_CREDIT 2 /* post: give peer back 1 credit */
-#define IBLND_POSTRX_RSRVD_CREDIT 3 /* post: give myself back 1 reserved credit */
+#define IBLND_POSTRX_DONT_POST 0 /* don't post */
+#define IBLND_POSTRX_NO_CREDIT 1 /* post: no credits */
+#define IBLND_POSTRX_PEER_CREDIT 2 /* post: give peer back 1 credit */
+#define IBLND_POSTRX_RSRVD_CREDIT 3 /* post: give myself back 1 reserved
+ * credit */
-typedef struct kib_tx /* transmit message */
+typedef struct kib_tx /* transmit message */
{
- struct list_head tx_list; /* queue on idle_txs ibc_tx_queue etc. */
- kib_tx_pool_t *tx_pool; /* pool I'm from */
- struct kib_conn *tx_conn; /* owning conn */
- short tx_sending; /* # tx callbacks outstanding */
- short tx_queued; /* queued for sending */
- short tx_waiting; /* waiting for peer */
- int tx_status; /* LNET completion status */
- unsigned long tx_deadline; /* completion deadline */
- __u64 tx_cookie; /* completion cookie */
- lnet_msg_t *tx_lntmsg[2]; /* lnet msgs to finalize on completion */
- kib_msg_t *tx_msg; /* message buffer (host vaddr) */
- __u64 tx_msgaddr; /* message buffer (I/O addr) */
- DECLARE_PCI_UNMAP_ADDR (tx_msgunmap); /* for dma_unmap_single() */
- int tx_nwrq; /* # send work items */
- struct ib_send_wr *tx_wrq; /* send work items... */
- struct ib_sge *tx_sge; /* ...and their memory */
- kib_rdma_desc_t *tx_rd; /* rdma descriptor */
- int tx_nfrags; /* # entries in... */
- struct scatterlist *tx_frags; /* dma_map_sg descriptor */
- __u64 *tx_pages; /* rdma phys page addrs */
+ struct list_head tx_list; /* queue on idle_txs ibc_tx_queue
+ * etc. */
+ kib_tx_pool_t *tx_pool; /* pool I'm from */
+ struct kib_conn *tx_conn; /* owning conn */
+ short tx_sending; /* # tx callbacks outstanding */
+ short tx_queued; /* queued for sending */
+ short tx_waiting; /* waiting for peer */
+ int tx_status; /* LNET completion status */
+ unsigned long tx_deadline; /* completion deadline */
+ __u64 tx_cookie; /* completion cookie */
+ lnet_msg_t *tx_lntmsg[2]; /* lnet msgs to finalize on
+ * completion */
+ kib_msg_t *tx_msg; /* message buffer (host vaddr) */
+ __u64 tx_msgaddr; /* message buffer (I/O addr) */
+ DECLARE_PCI_UNMAP_ADDR (tx_msgunmap); /* for dma_unmap_single() */
+ int tx_nwrq; /* # send work items */
+ struct ib_send_wr *tx_wrq; /* send work items... */
+ struct ib_sge *tx_sge; /* ...and their memory */
+ kib_rdma_desc_t *tx_rd; /* rdma descriptor */
+ int tx_nfrags; /* # entries in... */
+ struct scatterlist *tx_frags; /* dma_map_sg descriptor */
+ __u64 *tx_pages; /* rdma phys page addrs */
union {
- kib_phys_mr_t *pmr; /* MR for physical buffer */
- kib_fmr_t fmr; /* FMR */
- } tx_u;
- int tx_dmadir; /* dma direction */
+ kib_phys_mr_t *pmr; /* MR for physical buffer */
+ kib_fmr_t fmr; /* FMR */
+ } tx_u;
+ int tx_dmadir; /* dma direction */
} kib_tx_t;
typedef struct kib_connvars {
- /* connection-in-progress variables */
- kib_msg_t cv_msg;
+ kib_msg_t cv_msg; /* connection-in-progress variables */
} kib_connvars_t;
typedef struct kib_conn {
- struct kib_sched_info *ibc_sched; /* scheduler information */
- struct kib_peer *ibc_peer; /* owning peer */
- kib_hca_dev_t *ibc_hdev; /* HCA bound on */
- struct list_head ibc_list; /* stash on peer's conn list */
- struct list_head ibc_sched_list; /* schedule for attention */
- __u16 ibc_version; /* version of connection */
- __u64 ibc_incarnation; /* which instance of the peer */
- atomic_t ibc_refcount; /* # users */
- int ibc_state; /* what's happening */
- int ibc_nsends_posted; /* # uncompleted sends */
- int ibc_noops_posted; /* # uncompleted NOOPs */
- int ibc_credits; /* # credits I have */
- int ibc_outstanding_credits; /* # credits to return */
- int ibc_reserved_credits;/* # ACK/DONE msg credits */
- int ibc_comms_error; /* set on comms error */
- unsigned int ibc_nrx:16; /* receive buffers owned */
- unsigned int ibc_scheduled:1; /* scheduled for attention */
- unsigned int ibc_ready:1; /* CQ callback fired */
- /* time of last send */
- unsigned long ibc_last_send;
- /** link chain for kiblnd_check_conns only */
- struct list_head ibc_connd_list;
- /** rxs completed before ESTABLISHED */
- struct list_head ibc_early_rxs;
- /** IBLND_MSG_NOOPs for IBLND_MSG_VERSION_1 */
- struct list_head ibc_tx_noops;
- struct list_head ibc_tx_queue; /* sends that need a credit */
- struct list_head ibc_tx_queue_nocred;/* sends that don't need a credit */
- struct list_head ibc_tx_queue_rsrvd; /* sends that need to reserve an ACK/DONE msg */
- struct list_head ibc_active_txs; /* active tx awaiting completion */
- spinlock_t ibc_lock; /* serialise */
- kib_rx_t *ibc_rxs; /* the rx descs */
- kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */
-
- struct rdma_cm_id *ibc_cmid; /* CM id */
- struct ib_cq *ibc_cq; /* completion queue */
-
- kib_connvars_t *ibc_connvars; /* in-progress connection state */
+ struct kib_sched_info *ibc_sched; /* scheduler information */
+ struct kib_peer *ibc_peer; /* owning peer */
+ kib_hca_dev_t *ibc_hdev; /* HCA bound on */
+ struct list_head ibc_list; /* stash on peer's conn
+ * list */
+ struct list_head ibc_sched_list; /* schedule for attention */
+ __u16 ibc_version; /* version of connection */
+ __u64 ibc_incarnation; /* which instance of the
+ * peer */
+ atomic_t ibc_refcount; /* # users */
+ int ibc_state; /* what's happening */
+ int ibc_nsends_posted; /* # uncompleted sends */
+ int ibc_noops_posted; /* # uncompleted NOOPs */
+ int ibc_credits; /* # credits I have */
+ int ibc_outstanding_credits; /* # credits to return */
+ int ibc_reserved_credits; /* # ACK/DONE msg credits */
+ int ibc_comms_error; /* set on comms error */
+ unsigned int ibc_nrx:16; /* receive buffers owned */
+ unsigned int ibc_scheduled:1; /* scheduled for attention
+ */
+ unsigned int ibc_ready:1; /* CQ callback fired */
+ unsigned long ibc_last_send; /* time of last send */
+ struct list_head ibc_connd_list; /* link chain for
+ * kiblnd_check_conns only
+ */
+ struct list_head ibc_early_rxs; /* rxs completed before
+ * ESTABLISHED */
+ struct list_head ibc_tx_noops; /* IBLND_MSG_NOOPs for
+ * IBLND_MSG_VERSION_1 */
+ struct list_head ibc_tx_queue; /* sends that need a credit
+ */
+ struct list_head ibc_tx_queue_nocred; /* sends that don't need a
+ * credit */
+ struct list_head ibc_tx_queue_rsrvd; /* sends that need to
+ * reserve an ACK/DONE msg
+ */
+ struct list_head ibc_active_txs; /* active tx awaiting
+ * completion */
+ spinlock_t ibc_lock; /* serialise */
+ kib_rx_t *ibc_rxs; /* the rx descs */
+ kib_pages_t *ibc_rx_pages; /* premapped rx msg pages */
+
+ struct rdma_cm_id *ibc_cmid; /* CM id */
+ struct ib_cq *ibc_cq; /* completion queue */
+
+ kib_connvars_t *ibc_connvars; /* in-progress connection
+ * state */
} kib_conn_t;
-#define IBLND_CONN_INIT 0 /* being initialised */
-#define IBLND_CONN_ACTIVE_CONNECT 1 /* active sending req */
-#define IBLND_CONN_PASSIVE_WAIT 2 /* passive waiting for rtu */
-#define IBLND_CONN_ESTABLISHED 3 /* connection established */
-#define IBLND_CONN_CLOSING 4 /* being closed */
-#define IBLND_CONN_DISCONNECTED 5 /* disconnected */
+#define IBLND_CONN_INIT 0 /* being initialised */
+#define IBLND_CONN_ACTIVE_CONNECT 1 /* active sending req */
+#define IBLND_CONN_PASSIVE_WAIT 2 /* passive waiting for rtu */
+#define IBLND_CONN_ESTABLISHED 3 /* connection established */
+#define IBLND_CONN_CLOSING 4 /* being closed */
+#define IBLND_CONN_DISCONNECTED 5 /* disconnected */
typedef struct kib_peer {
- struct list_head ibp_list; /* stash on global peer list */
- lnet_nid_t ibp_nid; /* who's on the other end(s) */
- lnet_ni_t *ibp_ni; /* LNet interface */
- atomic_t ibp_refcount; /* # users */
- struct list_head ibp_conns; /* all active connections */
- struct list_head ibp_tx_queue; /* msgs waiting for a conn */
- __u16 ibp_version; /* version of peer */
- __u64 ibp_incarnation; /* incarnation of peer */
- int ibp_connecting; /* current active connection attempts */
- int ibp_accepting; /* current passive connection attempts */
- int ibp_error; /* errno on closing this peer */
- unsigned long ibp_last_alive; /* when (in jiffies) I was last alive */
+ struct list_head ibp_list; /* stash on global peer list */
+ lnet_nid_t ibp_nid; /* who's on the other end(s) */
+ lnet_ni_t *ibp_ni; /* LNet interface */
+ atomic_t ibp_refcount; /* # users */
+ struct list_head ibp_conns; /* all active connections */
+ struct list_head ibp_tx_queue; /* msgs waiting for a conn */
+ __u16 ibp_version; /* version of peer */
+ __u64 ibp_incarnation; /* incarnation of peer */
+ int ibp_connecting; /* current active connection attempts
+ */
+ int ibp_accepting; /* current passive connection attempts
+ */
+ int ibp_error; /* errno on closing this peer */
+ unsigned long ibp_last_alive; /* when (in jiffies) I was last alive
+ */
} kib_peer_t;
-extern kib_data_t kiblnd_data;
+extern kib_data_t kiblnd_data;
extern void kiblnd_hdev_destroy(kib_hca_dev_t *hdev);
@@ -941,8 +959,8 @@ static inline unsigned int kiblnd_sg_dma_len(struct ib_device *dev,
* right because OFED1.2 defines it as const, to use it we have to add
* (void *) cast to overcome "const" */
-#define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data)
-#define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len)
+#define KIBLND_CONN_PARAM(e) ((e)->param.conn.private_data)
+#define KIBLND_CONN_PARAM_LEN(e) ((e)->param.conn.private_data_len)
struct ib_mr *kiblnd_find_rd_dma_mr(kib_hca_dev_t *hdev,
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
index dbf3749831f9c5..477aa8b76f327a 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_cb.c
@@ -44,9 +44,9 @@ static void
kiblnd_tx_done(lnet_ni_t *ni, kib_tx_t *tx)
{
lnet_msg_t *lntmsg[2];
- kib_net_t *net = ni->ni_data;
- int rc;
- int i;
+ kib_net_t *net = ni->ni_data;
+ int rc;
+ int i;
LASSERT(net != NULL);
LASSERT(!in_interrupt());
@@ -102,10 +102,10 @@ kiblnd_txlist_done(lnet_ni_t *ni, struct list_head *txlist, int status)
static kib_tx_t *
kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target)
{
- kib_net_t *net = (kib_net_t *)ni->ni_data;
- struct list_head *node;
- kib_tx_t *tx;
- kib_tx_poolset_t *tps;
+ kib_net_t *net = (kib_net_t *)ni->ni_data;
+ struct list_head *node;
+ kib_tx_t *tx;
+ kib_tx_poolset_t *tps;
tps = net->ibn_tx_ps[lnet_cpt_of_nid(target)];
node = kiblnd_pool_alloc_node(&tps->tps_poolset);
@@ -130,9 +130,9 @@ kiblnd_get_idle_tx(lnet_ni_t *ni, lnet_nid_t target)
static void
kiblnd_drop_rx(kib_rx_t *rx)
{
- kib_conn_t *conn = rx->rx_conn;
- struct kib_sched_info *sched = conn->ibc_sched;
- unsigned long flags;
+ kib_conn_t *conn = rx->rx_conn;
+ struct kib_sched_info *sched = conn->ibc_sched;
+ unsigned long flags;
spin_lock_irqsave(&sched->ibs_lock, flags);
LASSERT(conn->ibc_nrx > 0);
@@ -145,11 +145,11 @@ kiblnd_drop_rx(kib_rx_t *rx)
int
kiblnd_post_rx(kib_rx_t *rx, int credit)
{
- kib_conn_t *conn = rx->rx_conn;
- kib_net_t *net = conn->ibc_peer->ibp_ni->ni_data;
- struct ib_recv_wr *bad_wrq = NULL;
- struct ib_mr *mr;
- int rc;
+ kib_conn_t *conn = rx->rx_conn;
+ kib_net_t *net = conn->ibc_peer->ibp_ni->ni_data;
+ struct ib_recv_wr *bad_wrq = NULL;
+ struct ib_mr *mr;
+ int rc;
LASSERT(net != NULL);
LASSERT(!in_interrupt());
@@ -164,10 +164,10 @@ kiblnd_post_rx(kib_rx_t *rx, int credit)
rx->rx_sge.addr = rx->rx_msgaddr;
rx->rx_sge.length = IBLND_MSG_SIZE;
- rx->rx_wrq.next = NULL;
+ rx->rx_wrq.next = NULL;
rx->rx_wrq.sg_list = &rx->rx_sge;
rx->rx_wrq.num_sge = 1;
- rx->rx_wrq.wr_id = kiblnd_ptr2wreqid(rx, IBLND_WID_RX);
+ rx->rx_wrq.wr_id = kiblnd_ptr2wreqid(rx, IBLND_WID_RX);
LASSERT(conn->ibc_state >= IBLND_CONN_INIT);
LASSERT(rx->rx_nob >= 0); /* not posted */
@@ -212,7 +212,7 @@ kiblnd_post_rx(kib_rx_t *rx, int credit)
static kib_tx_t *
kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie)
{
- struct list_head *tmp;
+ struct list_head *tmp;
list_for_each(tmp, &conn->ibc_active_txs) {
kib_tx_t *tx = list_entry(tmp, kib_tx_t, tx_list);
@@ -237,9 +237,9 @@ kiblnd_find_waiting_tx_locked(kib_conn_t *conn, int txtype, __u64 cookie)
static void
kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie)
{
- kib_tx_t *tx;
- lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- int idle;
+ kib_tx_t *tx;
+ lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+ int idle;
spin_lock(&conn->ibc_lock);
@@ -276,8 +276,8 @@ kiblnd_handle_completion(kib_conn_t *conn, int txtype, int status, __u64 cookie)
static void
kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie)
{
- lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- kib_tx_t *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid);
+ lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+ kib_tx_t *tx = kiblnd_get_idle_tx(ni, conn->ibc_peer->ibp_nid);
if (tx == NULL) {
CERROR("Can't get tx for completion %x for %s\n",
@@ -295,14 +295,14 @@ kiblnd_send_completion(kib_conn_t *conn, int type, int status, __u64 cookie)
static void
kiblnd_handle_rx(kib_rx_t *rx)
{
- kib_msg_t *msg = rx->rx_msg;
- kib_conn_t *conn = rx->rx_conn;
- lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- int credits = msg->ibm_credits;
- kib_tx_t *tx;
- int rc = 0;
- int rc2;
- int post_credit;
+ kib_msg_t *msg = rx->rx_msg;
+ kib_conn_t *conn = rx->rx_conn;
+ lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+ int credits = msg->ibm_credits;
+ kib_tx_t *tx;
+ int rc = 0;
+ int rc2;
+ int post_credit;
LASSERT(conn->ibc_state >= IBLND_CONN_ESTABLISHED);
@@ -456,12 +456,12 @@ kiblnd_handle_rx(kib_rx_t *rx)
static void
kiblnd_rx_complete(kib_rx_t *rx, int status, int nob)
{
- kib_msg_t *msg = rx->rx_msg;
- kib_conn_t *conn = rx->rx_conn;
- lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- kib_net_t *net = ni->ni_data;
- int rc;
- int err = -EIO;
+ kib_msg_t *msg = rx->rx_msg;
+ kib_conn_t *conn = rx->rx_conn;
+ lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
+ kib_net_t *net = ni->ni_data;
+ int rc;
+ int err = -EIO;
LASSERT(net != NULL);
LASSERT(rx->rx_nob < 0); /* was posted */
@@ -502,8 +502,8 @@ kiblnd_rx_complete(kib_rx_t *rx, int status, int nob)
/* racing with connection establishment/teardown! */
if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
- rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
- unsigned long flags;
+ rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
+ unsigned long flags;
write_lock_irqsave(g_lock, flags);
/* must check holding global lock to eliminate race */
@@ -550,19 +550,19 @@ kiblnd_kvaddr_to_page(unsigned long vaddr)
static int
kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
{
- kib_hca_dev_t *hdev;
- __u64 *pages = tx->tx_pages;
- kib_fmr_poolset_t *fps;
- int npages;
- int size;
- int cpt;
- int rc;
- int i;
+ kib_hca_dev_t *hdev;
+ __u64 *pages = tx->tx_pages;
+ kib_fmr_poolset_t *fps;
+ int npages;
+ int size;
+ int cpt;
+ int rc;
+ int i;
LASSERT(tx->tx_pool != NULL);
LASSERT(tx->tx_pool->tpo_pool.po_owner != NULL);
- hdev = tx->tx_pool->tpo_hdev;
+ hdev = tx->tx_pool->tpo_hdev;
for (i = 0, npages = 0; i < rd->rd_nfrags; i++) {
for (size = 0; size < rd->rd_frags[i].rf_nob;
@@ -586,7 +586,7 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
rd->rd_key = (rd != tx->tx_rd) ? tx->tx_u.fmr.fmr_pfmr->fmr->rkey :
tx->tx_u.fmr.fmr_pfmr->fmr->lkey;
rd->rd_frags[0].rf_addr &= ~hdev->ibh_page_mask;
- rd->rd_frags[0].rf_nob = nob;
+ rd->rd_frags[0].rf_nob = nob;
rd->rd_nfrags = 1;
return 0;
@@ -595,11 +595,11 @@ kiblnd_fmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
static int
kiblnd_pmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
{
- kib_hca_dev_t *hdev;
- kib_pmr_poolset_t *pps;
- __u64 iova;
- int cpt;
- int rc;
+ kib_hca_dev_t *hdev;
+ kib_pmr_poolset_t *pps;
+ __u64 iova;
+ int cpt;
+ int rc;
LASSERT(tx->tx_pool != NULL);
LASSERT(tx->tx_pool->tpo_pool.po_owner != NULL);
@@ -623,7 +623,7 @@ kiblnd_pmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
tx->tx_u.pmr->pmr_mr->lkey;
rd->rd_nfrags = 1;
rd->rd_frags[0].rf_addr = iova;
- rd->rd_frags[0].rf_nob = nob;
+ rd->rd_frags[0].rf_nob = nob;
return 0;
}
@@ -631,7 +631,7 @@ kiblnd_pmr_map_tx(kib_net_t *net, kib_tx_t *tx, kib_rdma_desc_t *rd, int nob)
void
kiblnd_unmap_tx(lnet_ni_t *ni, kib_tx_t *tx)
{
- kib_net_t *net = ni->ni_data;
+ kib_net_t *net = ni->ni_data;
LASSERT(net != NULL);
@@ -655,20 +655,19 @@ int
kiblnd_map_tx(lnet_ni_t *ni, kib_tx_t *tx,
kib_rdma_desc_t *rd, int nfrags)
{
- kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
- kib_net_t *net = ni->ni_data;
- struct ib_mr *mr = NULL;
- __u32 nob;
- int i;
+ kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
+ kib_net_t *net = ni->ni_data;
+ struct ib_mr *mr = NULL;
+ __u32 nob;
+ int i;
/* If rd is not tx_rd, it's going to get sent to a peer and I'm the
* RDMA sink */
tx->tx_dmadir = (rd != tx->tx_rd) ? DMA_FROM_DEVICE : DMA_TO_DEVICE;
tx->tx_nfrags = nfrags;
- rd->rd_nfrags =
- kiblnd_dma_map_sg(hdev->ibh_ibdev,
- tx->tx_frags, tx->tx_nfrags, tx->tx_dmadir);
+ rd->rd_nfrags = kiblnd_dma_map_sg(hdev->ibh_ibdev, tx->tx_frags,
+ tx->tx_nfrags, tx->tx_dmadir);
for (i = 0, nob = 0; i < rd->rd_nfrags; i++) {
rd->rd_frags[i].rf_nob = kiblnd_sg_dma_len(
@@ -699,12 +698,12 @@ static int
kiblnd_setup_rd_iov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
unsigned int niov, struct kvec *iov, int offset, int nob)
{
- kib_net_t *net = ni->ni_data;
- struct page *page;
+ kib_net_t *net = ni->ni_data;
+ struct page *page;
struct scatterlist *sg;
- unsigned long vaddr;
- int fragnob;
- int page_offset;
+ unsigned long vaddr;
+ int fragnob;
+ int page_offset;
LASSERT(nob > 0);
LASSERT(niov > 0);
@@ -752,9 +751,9 @@ static int
kiblnd_setup_rd_kiov(lnet_ni_t *ni, kib_tx_t *tx, kib_rdma_desc_t *rd,
int nkiov, lnet_kiov_t *kiov, int offset, int nob)
{
- kib_net_t *net = ni->ni_data;
+ kib_net_t *net = ni->ni_data;
struct scatterlist *sg;
- int fragnob;
+ int fragnob;
CDEBUG(D_NET, "niov %d offset %d nob %d\n", nkiov, offset, nob);
@@ -793,11 +792,11 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit)
__releases(conn->ibc_lock)
__acquires(conn->ibc_lock)
{
- kib_msg_t *msg = tx->tx_msg;
- kib_peer_t *peer = conn->ibc_peer;
- int ver = conn->ibc_version;
- int rc;
- int done;
+ kib_msg_t *msg = tx->tx_msg;
+ kib_peer_t *peer = conn->ibc_peer;
+ int ver = conn->ibc_version;
+ int rc;
+ int done;
struct ib_send_wr *bad_wrq;
LASSERT(tx->tx_queued);
@@ -878,8 +877,7 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit)
/* close_conn will launch failover */
rc = -ENETDOWN;
} else {
- rc = ib_post_send(conn->ibc_cmid->qp,
- tx->tx_wrq, &bad_wrq);
+ rc = ib_post_send(conn->ibc_cmid->qp, tx->tx_wrq, &bad_wrq);
}
conn->ibc_last_send = jiffies;
@@ -925,9 +923,9 @@ kiblnd_post_tx_locked(kib_conn_t *conn, kib_tx_t *tx, int credit)
void
kiblnd_check_sends(kib_conn_t *conn)
{
- int ver = conn->ibc_version;
+ int ver = conn->ibc_version;
lnet_ni_t *ni = conn->ibc_peer->ibp_ni;
- kib_tx_t *tx;
+ kib_tx_t *tx;
/* Don't send anything until after the connection is established */
if (conn->ibc_state < IBLND_CONN_ESTABLISHED) {
@@ -997,9 +995,9 @@ kiblnd_check_sends(kib_conn_t *conn)
static void
kiblnd_tx_complete(kib_tx_t *tx, int status)
{
- int failed = (status != IB_WC_SUCCESS);
- kib_conn_t *conn = tx->tx_conn;
- int idle;
+ int failed = (status != IB_WC_SUCCESS);
+ kib_conn_t *conn = tx->tx_conn;
+ int idle;
LASSERT(tx->tx_sending > 0);
@@ -1051,11 +1049,11 @@ kiblnd_tx_complete(kib_tx_t *tx, int status)
void
kiblnd_init_tx_msg(lnet_ni_t *ni, kib_tx_t *tx, int type, int body_nob)
{
- kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
- struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq];
+ kib_hca_dev_t *hdev = tx->tx_pool->tpo_hdev;
+ struct ib_sge *sge = &tx->tx_sge[tx->tx_nwrq];
struct ib_send_wr *wrq = &tx->tx_wrq[tx->tx_nwrq];
- int nob = offsetof(kib_msg_t, ibm_u) + body_nob;
- struct ib_mr *mr;
+ int nob = offsetof(kib_msg_t, ibm_u) + body_nob;
+ struct ib_mr *mr;
LASSERT(tx->tx_nwrq >= 0);
LASSERT(tx->tx_nwrq < IBLND_MAX_RDMA_FRAGS + 1);
@@ -1086,14 +1084,14 @@ int
kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type,
int resid, kib_rdma_desc_t *dstrd, __u64 dstcookie)
{
- kib_msg_t *ibmsg = tx->tx_msg;
- kib_rdma_desc_t *srcrd = tx->tx_rd;
- struct ib_sge *sge = &tx->tx_sge[0];
+ kib_msg_t *ibmsg = tx->tx_msg;
+ kib_rdma_desc_t *srcrd = tx->tx_rd;
+ struct ib_sge *sge = &tx->tx_sge[0];
struct ib_send_wr *wrq = &tx->tx_wrq[0];
- int rc = resid;
- int srcidx;
- int dstidx;
- int wrknob;
+ int rc = resid;
+ int srcidx;
+ int dstidx;
+ int wrknob;
LASSERT(!in_interrupt());
LASSERT(tx->tx_nwrq == 0);
@@ -1144,7 +1142,7 @@ kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type,
wrq->send_flags = 0;
wrq->wr.rdma.remote_addr = kiblnd_rd_frag_addr(dstrd, dstidx);
- wrq->wr.rdma.rkey = kiblnd_rd_frag_key(dstrd, dstidx);
+ wrq->wr.rdma.rkey = kiblnd_rd_frag_key(dstrd, dstidx);
srcidx = kiblnd_rd_consume_frag(srcrd, srcidx, wrknob);
dstidx = kiblnd_rd_consume_frag(dstrd, dstidx, wrknob);
@@ -1170,7 +1168,7 @@ kiblnd_init_rdma(kib_conn_t *conn, kib_tx_t *tx, int type,
void
kiblnd_queue_tx_locked(kib_tx_t *tx, kib_conn_t *conn)
{
- struct list_head *q;
+ struct list_head *q;
LASSERT(tx->tx_nwrq > 0); /* work items set up */
LASSERT(!tx->tx_queued); /* not queued for sending already */
@@ -1271,11 +1269,11 @@ static void
kiblnd_connect_peer(kib_peer_t *peer)
{
struct rdma_cm_id *cmid;
- kib_dev_t *dev;
- kib_net_t *net = peer->ibp_ni->ni_data;
+ kib_dev_t *dev;
+ kib_net_t *net = peer->ibp_ni->ni_data;
struct sockaddr_in srcaddr;
struct sockaddr_in dstaddr;
- int rc;
+ int rc;
LASSERT(net != NULL);
LASSERT(peer->ibp_connecting > 0);
@@ -1335,12 +1333,12 @@ kiblnd_connect_peer(kib_peer_t *peer)
void
kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
{
- kib_peer_t *peer;
- kib_peer_t *peer2;
- kib_conn_t *conn;
- rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
- unsigned long flags;
- int rc;
+ kib_peer_t *peer;
+ kib_peer_t *peer2;
+ kib_conn_t *conn;
+ rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
+ unsigned long flags;
+ int rc;
/* If I get here, I've committed to send, so I complete the tx with
* failure on any problems */
@@ -1456,20 +1454,20 @@ kiblnd_launch_tx(lnet_ni_t *ni, kib_tx_t *tx, lnet_nid_t nid)
int
kiblnd_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
{
- lnet_hdr_t *hdr = &lntmsg->msg_hdr;
- int type = lntmsg->msg_type;
+ lnet_hdr_t *hdr = &lntmsg->msg_hdr;
+ int type = lntmsg->msg_type;
lnet_process_id_t target = lntmsg->msg_target;
- int target_is_router = lntmsg->msg_target_is_router;
- int routing = lntmsg->msg_routing;
- unsigned int payload_niov = lntmsg->msg_niov;
- struct kvec *payload_iov = lntmsg->msg_iov;
- lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
- unsigned int payload_offset = lntmsg->msg_offset;
- unsigned int payload_nob = lntmsg->msg_len;
- kib_msg_t *ibmsg;
- kib_tx_t *tx;
- int nob;
- int rc;
+ int target_is_router = lntmsg->msg_target_is_router;
+ int routing = lntmsg->msg_routing;
+ unsigned int payload_niov = lntmsg->msg_niov;
+ struct kvec *payload_iov = lntmsg->msg_iov;
+ lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
+ unsigned int payload_offset = lntmsg->msg_offset;
+ unsigned int payload_nob = lntmsg->msg_len;
+ kib_msg_t *ibmsg;
+ kib_tx_t *tx;
+ int nob;
+ int rc;
/* NB 'private' is different depending on what we're sending.... */
@@ -1628,13 +1626,13 @@ static void
kiblnd_reply(lnet_ni_t *ni, kib_rx_t *rx, lnet_msg_t *lntmsg)
{
lnet_process_id_t target = lntmsg->msg_target;
- unsigned int niov = lntmsg->msg_niov;
- struct kvec *iov = lntmsg->msg_iov;
- lnet_kiov_t *kiov = lntmsg->msg_kiov;
- unsigned int offset = lntmsg->msg_offset;
- unsigned int nob = lntmsg->msg_len;
- kib_tx_t *tx;
- int rc;
+ unsigned int niov = lntmsg->msg_niov;
+ struct kvec *iov = lntmsg->msg_iov;
+ lnet_kiov_t *kiov = lntmsg->msg_kiov;
+ unsigned int offset = lntmsg->msg_offset;
+ unsigned int nob = lntmsg->msg_len;
+ kib_tx_t *tx;
+ int rc;
tx = kiblnd_get_idle_tx(ni, rx->rx_conn->ibc_peer->ibp_nid);
if (tx == NULL) {
@@ -1691,14 +1689,14 @@ kiblnd_recv(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg, int delayed,
unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
- kib_rx_t *rx = private;
- kib_msg_t *rxmsg = rx->rx_msg;
- kib_conn_t *conn = rx->rx_conn;
- kib_tx_t *tx;
- kib_msg_t *txmsg;
- int nob;
- int post_credit = IBLND_POSTRX_PEER_CREDIT;
- int rc = 0;
+ kib_rx_t *rx = private;
+ kib_msg_t *rxmsg = rx->rx_msg;
+ kib_conn_t *conn = rx->rx_conn;
+ kib_tx_t *tx;
+ kib_msg_t *txmsg;
+ int nob;
+ int post_credit = IBLND_POSTRX_PEER_CREDIT;
+ int rc = 0;
LASSERT(mlen <= rlen);
LASSERT(!in_interrupt());
@@ -1828,8 +1826,8 @@ kiblnd_peer_alive(kib_peer_t *peer)
static void
kiblnd_peer_notify(kib_peer_t *peer)
{
- int error = 0;
- unsigned long last_alive = 0;
+ int error = 0;
+ unsigned long last_alive = 0;
unsigned long flags;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
@@ -1860,9 +1858,9 @@ kiblnd_close_conn_locked(kib_conn_t *conn, int error)
* connection to be finished off by the connd. Otherwise the connd is
* already dealing with it (either to set it up or tear it down).
* Caller holds kib_global_lock exclusively in irq context */
- kib_peer_t *peer = conn->ibc_peer;
- kib_dev_t *dev;
- unsigned long flags;
+ kib_peer_t *peer = conn->ibc_peer;
+ kib_dev_t *dev;
+ unsigned long flags;
LASSERT(error != 0 || conn->ibc_state >= IBLND_CONN_ESTABLISHED);
@@ -1934,8 +1932,8 @@ kiblnd_close_conn(kib_conn_t *conn, int error)
static void
kiblnd_handle_early_rxs(kib_conn_t *conn)
{
- unsigned long flags;
- kib_rx_t *rx;
+ unsigned long flags;
+ kib_rx_t *rx;
kib_rx_t *tmp;
LASSERT(!in_interrupt());
@@ -1957,9 +1955,9 @@ static void
kiblnd_abort_txs(kib_conn_t *conn, struct list_head *txs)
{
LIST_HEAD(zombies);
- struct list_head *tmp;
- struct list_head *nxt;
- kib_tx_t *tx;
+ struct list_head *tmp;
+ struct list_head *nxt;
+ kib_tx_t *tx;
spin_lock(&conn->ibc_lock);
@@ -2018,7 +2016,7 @@ void
kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error)
{
LIST_HEAD(zombies);
- unsigned long flags;
+ unsigned long flags;
LASSERT(error != 0);
LASSERT(!in_interrupt());
@@ -2071,12 +2069,12 @@ kiblnd_peer_connect_failed(kib_peer_t *peer, int active, int error)
void
kiblnd_connreq_done(kib_conn_t *conn, int status)
{
- kib_peer_t *peer = conn->ibc_peer;
- kib_tx_t *tx;
+ kib_peer_t *peer = conn->ibc_peer;
+ kib_tx_t *tx;
kib_tx_t *tmp;
- struct list_head txs;
- unsigned long flags;
- int active;
+ struct list_head txs;
+ unsigned long flags;
+ int active;
active = (conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
@@ -2166,7 +2164,7 @@ kiblnd_connreq_done(kib_conn_t *conn, int status)
static void
kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej)
{
- int rc;
+ int rc;
rc = rdma_reject(cmid, rej, sizeof(*rej));
@@ -2177,22 +2175,22 @@ kiblnd_reject(struct rdma_cm_id *cmid, kib_rej_t *rej)
static int
kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
{
- rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
- kib_msg_t *reqmsg = priv;
- kib_msg_t *ackmsg;
- kib_dev_t *ibdev;
- kib_peer_t *peer;
- kib_peer_t *peer2;
- kib_conn_t *conn;
- lnet_ni_t *ni = NULL;
- kib_net_t *net = NULL;
- lnet_nid_t nid;
+ rwlock_t *g_lock = &kiblnd_data.kib_global_lock;
+ kib_msg_t *reqmsg = priv;
+ kib_msg_t *ackmsg;
+ kib_dev_t *ibdev;
+ kib_peer_t *peer;
+ kib_peer_t *peer2;
+ kib_conn_t *conn;
+ lnet_ni_t *ni = NULL;
+ kib_net_t *net = NULL;
+ lnet_nid_t nid;
struct rdma_conn_param cp;
- kib_rej_t rej;
- int version = IBLND_MSG_VERSION;
- unsigned long flags;
- int rc;
- struct sockaddr_in *peer_addr;
+ kib_rej_t rej;
+ int version = IBLND_MSG_VERSION;
+ unsigned long flags;
+ int rc;
+ struct sockaddr_in *peer_addr;
LASSERT(!in_interrupt());
/* cmid inherits 'context' from the corresponding listener id */
@@ -2200,8 +2198,8 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
LASSERT(ibdev != NULL);
memset(&rej, 0, sizeof(rej));
- rej.ibr_magic = IBLND_MSG_MAGIC;
- rej.ibr_why = IBLND_REJECT_FATAL;
+ rej.ibr_magic = IBLND_MSG_MAGIC;
+ rej.ibr_why = IBLND_REJECT_FATAL;
rej.ibr_cp.ibcp_max_msg_size = IBLND_MSG_SIZE;
peer_addr = (struct sockaddr_in *)&(cmid->route.addr.dst_addr);
@@ -2243,7 +2241,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
}
nid = reqmsg->ibm_srcnid;
- ni = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid));
+ ni = lnet_net2ni(LNET_NIDNET(reqmsg->ibm_dstnid));
if (ni != NULL) {
net = (kib_net_t *)ni->ni_data;
@@ -2394,7 +2392,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
* CM callback doesn't destroy cmid. */
conn->ibc_incarnation = reqmsg->ibm_srcstamp;
- conn->ibc_credits = IBLND_MSG_QUEUE_SIZE(version);
+ conn->ibc_credits = IBLND_MSG_QUEUE_SIZE(version);
conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(version);
LASSERT(conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(version)
<= IBLND_RX_MSGS(version));
@@ -2412,12 +2410,12 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
memset(&cp, 0, sizeof(cp));
cp.private_data = ackmsg;
- cp.private_data_len = ackmsg->ibm_nob;
+ cp.private_data_len = ackmsg->ibm_nob;
cp.responder_resources = 0; /* No atomic ops or RDMA reads */
- cp.initiator_depth = 0;
+ cp.initiator_depth = 0;
cp.flow_control = 1;
- cp.retry_count = *kiblnd_tunables.kib_retry_count;
- cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count;
+ cp.retry_count = *kiblnd_tunables.kib_retry_count;
+ cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count;
CDEBUG(D_NET, "Accept %s\n", libcfs_nid2str(nid));
@@ -2439,7 +2437,7 @@ kiblnd_passive_connect(struct rdma_cm_id *cmid, void *priv, int priv_nob)
if (ni != NULL)
lnet_ni_decref(ni);
- rej.ibr_version = version;
+ rej.ibr_version = version;
rej.ibr_cp.ibcp_queue_depth = IBLND_MSG_QUEUE_SIZE(version);
rej.ibr_cp.ibcp_max_frags = IBLND_RDMA_FRAGS(version);
kiblnd_reject(cmid, &rej);
@@ -2451,10 +2449,10 @@ static void
kiblnd_reconnect(kib_conn_t *conn, int version,
__u64 incarnation, int why, kib_connparams_t *cp)
{
- kib_peer_t *peer = conn->ibc_peer;
- char *reason;
- int retry = 0;
- unsigned long flags;
+ kib_peer_t *peer = conn->ibc_peer;
+ char *reason;
+ int retry = 0;
+ unsigned long flags;
LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
LASSERT(peer->ibp_connecting > 0); /* 'conn' at least */
@@ -2513,7 +2511,7 @@ kiblnd_reconnect(kib_conn_t *conn, int version,
static void
kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob)
{
- kib_peer_t *peer = conn->ibc_peer;
+ kib_peer_t *peer = conn->ibc_peer;
LASSERT(!in_interrupt());
LASSERT(conn->ibc_state == IBLND_CONN_ACTIVE_CONNECT);
@@ -2532,10 +2530,10 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob)
case IB_CM_REJ_CONSUMER_DEFINED:
if (priv_nob >= offsetof(kib_rej_t, ibr_padding)) {
- kib_rej_t *rej = priv;
- kib_connparams_t *cp = NULL;
- int flip = 0;
- __u64 incarnation = -1;
+ kib_rej_t *rej = priv;
+ kib_connparams_t *cp = NULL;
+ int flip = 0;
+ __u64 incarnation = -1;
/* NB. default incarnation is -1 because:
* a) V1 will ignore dst incarnation in connreq.
@@ -2652,13 +2650,13 @@ kiblnd_rejected(kib_conn_t *conn, int reason, void *priv, int priv_nob)
static void
kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob)
{
- kib_peer_t *peer = conn->ibc_peer;
- lnet_ni_t *ni = peer->ibp_ni;
- kib_net_t *net = ni->ni_data;
- kib_msg_t *msg = priv;
- int ver = conn->ibc_version;
- int rc = kiblnd_unpack_msg(msg, priv_nob);
- unsigned long flags;
+ kib_peer_t *peer = conn->ibc_peer;
+ lnet_ni_t *ni = peer->ibp_ni;
+ kib_net_t *net = ni->ni_data;
+ kib_msg_t *msg = priv;
+ int ver = conn->ibc_version;
+ int rc = kiblnd_unpack_msg(msg, priv_nob);
+ unsigned long flags;
LASSERT(net != NULL);
@@ -2726,8 +2724,8 @@ kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob)
goto failed;
}
- conn->ibc_incarnation = msg->ibm_srcstamp;
- conn->ibc_credits =
+ conn->ibc_incarnation = msg->ibm_srcstamp;
+ conn->ibc_credits =
conn->ibc_reserved_credits = IBLND_MSG_QUEUE_SIZE(ver);
LASSERT(conn->ibc_credits + conn->ibc_reserved_credits + IBLND_OOB_MSGS(ver)
<= IBLND_RX_MSGS(ver));
@@ -2749,20 +2747,20 @@ kiblnd_check_connreply(kib_conn_t *conn, void *priv, int priv_nob)
static int
kiblnd_active_connect(struct rdma_cm_id *cmid)
{
- kib_peer_t *peer = (kib_peer_t *)cmid->context;
- kib_conn_t *conn;
- kib_msg_t *msg;
- struct rdma_conn_param cp;
- int version;
- __u64 incarnation;
- unsigned long flags;
- int rc;
+ kib_peer_t *peer = (kib_peer_t *)cmid->context;
+ kib_conn_t *conn;
+ kib_msg_t *msg;
+ struct rdma_conn_param cp;
+ int version;
+ __u64 incarnation;
+ unsigned long flags;
+ int rc;
read_lock_irqsave(&kiblnd_data.kib_global_lock, flags);
incarnation = peer->ibp_incarnation;
- version = (peer->ibp_version == 0) ? IBLND_MSG_VERSION :
- peer->ibp_version;
+ version = (peer->ibp_version == 0) ? IBLND_MSG_VERSION :
+ peer->ibp_version;
read_unlock_irqrestore(&kiblnd_data.kib_global_lock, flags);
@@ -2793,8 +2791,8 @@ kiblnd_active_connect(struct rdma_cm_id *cmid)
cp.private_data_len = msg->ibm_nob;
cp.responder_resources = 0; /* No atomic ops or RDMA reads */
cp.initiator_depth = 0;
- cp.flow_control = 1;
- cp.retry_count = *kiblnd_tunables.kib_retry_count;
+ cp.flow_control = 1;
+ cp.retry_count = *kiblnd_tunables.kib_retry_count;
cp.rnr_retry_count = *kiblnd_tunables.kib_rnr_retry_count;
LASSERT(cmid->context == (void *)conn);
@@ -2814,9 +2812,9 @@ kiblnd_active_connect(struct rdma_cm_id *cmid)
int
kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
{
- kib_peer_t *peer;
- kib_conn_t *conn;
- int rc;
+ kib_peer_t *peer;
+ kib_conn_t *conn;
+ int rc;
switch (event->event) {
default:
@@ -2983,8 +2981,8 @@ kiblnd_cm_callback(struct rdma_cm_id *cmid, struct rdma_cm_event *event)
static int
kiblnd_check_txs_locked(kib_conn_t *conn, struct list_head *txs)
{
- kib_tx_t *tx;
- struct list_head *ttmp;
+ kib_tx_t *tx;
+ struct list_head *ttmp;
list_for_each(ttmp, txs) {
tx = list_entry(ttmp, kib_tx_t, tx_list);
@@ -3022,13 +3020,13 @@ kiblnd_check_conns(int idx)
{
LIST_HEAD(closes);
LIST_HEAD(checksends);
- struct list_head *peers = &kiblnd_data.kib_peers[idx];
- struct list_head *ptmp;
- kib_peer_t *peer;
- kib_conn_t *conn;
+ struct list_head *peers = &kiblnd_data.kib_peers[idx];
+ struct list_head *ptmp;
+ kib_peer_t *peer;
+ kib_conn_t *conn;
kib_conn_t *tmp;
- struct list_head *ctmp;
- unsigned long flags;
+ struct list_head *ctmp;
+ unsigned long flags;
/* NB. We expect to have a look at all the peers and not find any
* RDMAs to time out, so we just use a shared lock while we
@@ -3114,14 +3112,14 @@ kiblnd_disconnect_conn(kib_conn_t *conn)
int
kiblnd_connd(void *arg)
{
- wait_queue_t wait;
- unsigned long flags;
- kib_conn_t *conn;
- int timeout;
- int i;
- int dropped_lock;
- int peer_index = 0;
- unsigned long deadline = jiffies;
+ wait_queue_t wait;
+ unsigned long flags;
+ kib_conn_t *conn;
+ int timeout;
+ int i;
+ int dropped_lock;
+ int peer_index = 0;
+ unsigned long deadline = jiffies;
cfs_block_allsigs();
@@ -3169,7 +3167,7 @@ kiblnd_connd(void *arg)
if (timeout <= 0) {
const int n = 4;
const int p = 1;
- int chunk = kiblnd_data.kib_peer_hash_size;
+ int chunk = kiblnd_data.kib_peer_hash_size;
spin_unlock_irqrestore(&kiblnd_data.kib_connd_lock, flags);
dropped_lock = 1;
@@ -3273,9 +3271,9 @@ kiblnd_cq_completion(struct ib_cq *cq, void *arg)
* consuming my CQ I could be called after all completions have
* occurred. But in this case, ibc_nrx == 0 && ibc_nsends_posted == 0
* and this CQ is about to be destroyed so I NOOP. */
- kib_conn_t *conn = (kib_conn_t *)arg;
- struct kib_sched_info *sched = conn->ibc_sched;
- unsigned long flags;
+ kib_conn_t *conn = (kib_conn_t *)arg;
+ struct kib_sched_info *sched = conn->ibc_sched;
+ unsigned long flags;
LASSERT(cq == conn->ibc_cq);
@@ -3309,15 +3307,15 @@ kiblnd_cq_event(struct ib_event *event, void *arg)
int
kiblnd_scheduler(void *arg)
{
- long id = (long)arg;
- struct kib_sched_info *sched;
- kib_conn_t *conn;
- wait_queue_t wait;
- unsigned long flags;
- struct ib_wc wc;
- int did_something;
- int busy_loops = 0;
- int rc;
+ long id = (long)arg;
+ struct kib_sched_info *sched;
+ kib_conn_t *conn;
+ wait_queue_t wait;
+ unsigned long flags;
+ struct ib_wc wc;
+ int did_something;
+ int busy_loops = 0;
+ int rc;
cfs_block_allsigs();
@@ -3432,11 +3430,11 @@ kiblnd_scheduler(void *arg)
int
kiblnd_failover_thread(void *arg)
{
- rwlock_t *glock = &kiblnd_data.kib_global_lock;
- kib_dev_t *dev;
- wait_queue_t wait;
- unsigned long flags;
- int rc;
+ rwlock_t *glock = &kiblnd_data.kib_global_lock;
+ kib_dev_t *dev;
+ wait_queue_t wait;
+ unsigned long flags;
+ int rc;
LASSERT(*kiblnd_tunables.kib_dev_failover != 0);
@@ -3446,8 +3444,8 @@ kiblnd_failover_thread(void *arg)
write_lock_irqsave(glock, flags);
while (!kiblnd_data.kib_shutdown) {
- int do_failover = 0;
- int long_sleep;
+ int do_failover = 0;
+ int long_sleep;
list_for_each_entry(dev, &kiblnd_data.kib_failed_devs,
ibd_fail_list) {
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
index eedf01afd57f72..b0e00361cfcefa 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd_modparams.c
@@ -150,30 +150,30 @@ module_param(use_privileged_port, int, 0644);
MODULE_PARM_DESC(use_privileged_port, "use privileged port when initiating connection");
kib_tunables_t kiblnd_tunables = {
- .kib_dev_failover = &dev_failover,
- .kib_service = &service,
- .kib_cksum = &cksum,
- .kib_timeout = &timeout,
- .kib_keepalive = &keepalive,
- .kib_ntx = &ntx,
- .kib_credits = &credits,
- .kib_peertxcredits = &peer_credits,
- .kib_peercredits_hiw = &peer_credits_hiw,
- .kib_peerrtrcredits = &peer_buffer_credits,
- .kib_peertimeout = &peer_timeout,
- .kib_default_ipif = &ipif_name,
- .kib_retry_count = &retry_count,
- .kib_rnr_retry_count = &rnr_retry_count,
- .kib_concurrent_sends = &concurrent_sends,
- .kib_ib_mtu = &ib_mtu,
- .kib_map_on_demand = &map_on_demand,
- .kib_fmr_pool_size = &fmr_pool_size,
- .kib_fmr_flush_trigger = &fmr_flush_trigger,
- .kib_fmr_cache = &fmr_cache,
- .kib_pmr_pool_size = &pmr_pool_size,
- .kib_require_priv_port = &require_privileged_port,
- .kib_use_priv_port = &use_privileged_port,
- .kib_nscheds = &nscheds
+ .kib_dev_failover = &dev_failover,
+ .kib_service = &service,
+ .kib_cksum = &cksum,
+ .kib_timeout = &timeout,
+ .kib_keepalive = &keepalive,
+ .kib_ntx = &ntx,
+ .kib_credits = &credits,
+ .kib_peertxcredits = &peer_credits,
+ .kib_peercredits_hiw = &peer_credits_hiw,
+ .kib_peerrtrcredits = &peer_buffer_credits,
+ .kib_peertimeout = &peer_timeout,
+ .kib_default_ipif = &ipif_name,
+ .kib_retry_count = &retry_count,
+ .kib_rnr_retry_count = &rnr_retry_count,
+ .kib_concurrent_sends = &concurrent_sends,
+ .kib_ib_mtu = &ib_mtu,
+ .kib_map_on_demand = &map_on_demand,
+ .kib_fmr_pool_size = &fmr_pool_size,
+ .kib_fmr_flush_trigger = &fmr_flush_trigger,
+ .kib_fmr_cache = &fmr_cache,
+ .kib_pmr_pool_size = &pmr_pool_size,
+ .kib_require_priv_port = &require_privileged_port,
+ .kib_use_priv_port = &use_privileged_port,
+ .kib_nscheds = &nscheds
};
int
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 7586b7e4040bdc..7b5d4078ba4e87 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -49,8 +49,8 @@ ksock_nal_data_t ksocknal_data;
static ksock_interface_t *
ksocknal_ip2iface(lnet_ni_t *ni, __u32 ip)
{
- ksock_net_t *net = ni->ni_data;
- int i;
+ ksock_net_t *net = ni->ni_data;
+ int i;
ksock_interface_t *iface;
for (i = 0; i < net->ksnn_ninterfaces; i++) {
@@ -102,8 +102,8 @@ ksocknal_destroy_route(ksock_route_t *route)
static int
ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
{
- ksock_net_t *net = ni->ni_data;
- ksock_peer_t *peer;
+ ksock_net_t *net = ni->ni_data;
+ ksock_peer_t *peer;
LASSERT(id.nid != LNET_NID_ANY);
LASSERT(id.pid != LNET_PID_ANY);
@@ -149,7 +149,7 @@ ksocknal_create_peer(ksock_peer_t **peerp, lnet_ni_t *ni, lnet_process_id_t id)
void
ksocknal_destroy_peer(ksock_peer_t *peer)
{
- ksock_net_t *net = peer->ksnp_ni->ni_data;
+ ksock_net_t *net = peer->ksnp_ni->ni_data;
CDEBUG(D_NET, "peer %s %p deleted\n",
libcfs_id2str(peer->ksnp_id), peer);
@@ -175,9 +175,9 @@ ksocknal_destroy_peer(ksock_peer_t *peer)
ksock_peer_t *
ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id)
{
- struct list_head *peer_list = ksocknal_nid2peerlist(id.nid);
- struct list_head *tmp;
- ksock_peer_t *peer;
+ struct list_head *peer_list = ksocknal_nid2peerlist(id.nid);
+ struct list_head *tmp;
+ ksock_peer_t *peer;
list_for_each(tmp, peer_list) {
@@ -203,7 +203,7 @@ ksocknal_find_peer_locked(lnet_ni_t *ni, lnet_process_id_t id)
ksock_peer_t *
ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id)
{
- ksock_peer_t *peer;
+ ksock_peer_t *peer;
read_lock(&ksocknal_data.ksnd_global_lock);
peer = ksocknal_find_peer_locked(ni, id);
@@ -217,8 +217,8 @@ ksocknal_find_peer(lnet_ni_t *ni, lnet_process_id_t id)
static void
ksocknal_unlink_peer_locked(ksock_peer_t *peer)
{
- int i;
- __u32 ip;
+ int i;
+ __u32 ip;
ksock_interface_t *iface;
for (i = 0; i < peer->ksnp_n_passive_ips; i++) {
@@ -249,13 +249,13 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index,
lnet_process_id_t *id, __u32 *myip, __u32 *peer_ip,
int *port, int *conn_count, int *share_count)
{
- ksock_peer_t *peer;
- struct list_head *ptmp;
- ksock_route_t *route;
- struct list_head *rtmp;
- int i;
- int j;
- int rc = -ENOENT;
+ ksock_peer_t *peer;
+ struct list_head *ptmp;
+ ksock_route_t *route;
+ struct list_head *rtmp;
+ int i;
+ int j;
+ int rc = -ENOENT;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -322,8 +322,8 @@ ksocknal_get_peer_info(lnet_ni_t *ni, int index,
static void
ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn)
{
- ksock_peer_t *peer = route->ksnr_peer;
- int type = conn->ksnc_type;
+ ksock_peer_t *peer = route->ksnr_peer;
+ int type = conn->ksnc_type;
ksock_interface_t *iface;
conn->ksnc_route = route;
@@ -366,9 +366,9 @@ ksocknal_associate_route_conn_locked(ksock_route_t *route, ksock_conn_t *conn)
static void
ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route)
{
- struct list_head *tmp;
- ksock_conn_t *conn;
- ksock_route_t *route2;
+ struct list_head *tmp;
+ ksock_conn_t *conn;
+ ksock_route_t *route2;
LASSERT(!peer->ksnp_closing);
LASSERT(route->ksnr_peer == NULL);
@@ -407,11 +407,11 @@ ksocknal_add_route_locked(ksock_peer_t *peer, ksock_route_t *route)
static void
ksocknal_del_route_locked(ksock_route_t *route)
{
- ksock_peer_t *peer = route->ksnr_peer;
+ ksock_peer_t *peer = route->ksnr_peer;
ksock_interface_t *iface;
- ksock_conn_t *conn;
- struct list_head *ctmp;
- struct list_head *cnxt;
+ ksock_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
LASSERT(!route->ksnr_deleted);
@@ -447,12 +447,12 @@ ksocknal_del_route_locked(ksock_route_t *route)
int
ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
{
- struct list_head *tmp;
- ksock_peer_t *peer;
- ksock_peer_t *peer2;
- ksock_route_t *route;
- ksock_route_t *route2;
- int rc;
+ struct list_head *tmp;
+ ksock_peer_t *peer;
+ ksock_peer_t *peer2;
+ ksock_route_t *route;
+ ksock_route_t *route2;
+ int rc;
if (id.nid == LNET_NID_ANY ||
id.pid == LNET_PID_ANY)
@@ -509,11 +509,11 @@ ksocknal_add_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ipaddr, int port)
static void
ksocknal_del_peer_locked(ksock_peer_t *peer, __u32 ip)
{
- ksock_conn_t *conn;
- ksock_route_t *route;
- struct list_head *tmp;
- struct list_head *nxt;
- int nshared;
+ ksock_conn_t *conn;
+ ksock_route_t *route;
+ struct list_head *tmp;
+ struct list_head *nxt;
+ int nshared;
LASSERT(!peer->ksnp_closing);
@@ -565,13 +565,13 @@ static int
ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
{
LIST_HEAD(zombies);
- struct list_head *ptmp;
- struct list_head *pnxt;
- ksock_peer_t *peer;
- int lo;
- int hi;
- int i;
- int rc = -ENOENT;
+ struct list_head *ptmp;
+ struct list_head *pnxt;
+ ksock_peer_t *peer;
+ int lo;
+ int hi;
+ int i;
+ int rc = -ENOENT;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -623,11 +623,11 @@ ksocknal_del_peer(lnet_ni_t *ni, lnet_process_id_t id, __u32 ip)
static ksock_conn_t *
ksocknal_get_conn_by_idx(lnet_ni_t *ni, int index)
{
- ksock_peer_t *peer;
- struct list_head *ptmp;
- ksock_conn_t *conn;
- struct list_head *ctmp;
- int i;
+ ksock_peer_t *peer;
+ struct list_head *ptmp;
+ ksock_conn_t *conn;
+ struct list_head *ctmp;
+ int i;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -661,8 +661,8 @@ static ksock_sched_t *
ksocknal_choose_scheduler_locked(unsigned int cpt)
{
struct ksock_sched_info *info = ksocknal_data.ksnd_sched_info[cpt];
- ksock_sched_t *sched;
- int i;
+ ksock_sched_t *sched;
+ int i;
LASSERT(info->ksi_nthreads > 0);
@@ -683,9 +683,9 @@ ksocknal_choose_scheduler_locked(unsigned int cpt)
static int
ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs)
{
- ksock_net_t *net = ni->ni_data;
- int i;
- int nip;
+ ksock_net_t *net = ni->ni_data;
+ int i;
+ int nip;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -711,12 +711,12 @@ ksocknal_local_ipvec(lnet_ni_t *ni, __u32 *ipaddrs)
static int
ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips)
{
- int best_netmatch = 0;
- int best_xor = 0;
- int best = -1;
- int this_xor;
- int this_netmatch;
- int i;
+ int best_netmatch = 0;
+ int best_xor = 0;
+ int best = -1;
+ int this_xor;
+ int this_netmatch;
+ int i;
for (i = 0; i < nips; i++) {
if (ips[i] == 0)
@@ -743,19 +743,19 @@ ksocknal_match_peerip(ksock_interface_t *iface, __u32 *ips, int nips)
static int
ksocknal_select_ips(ksock_peer_t *peer, __u32 *peerips, int n_peerips)
{
- rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
- ksock_net_t *net = peer->ksnp_ni->ni_data;
- ksock_interface_t *iface;
- ksock_interface_t *best_iface;
- int n_ips;
- int i;
- int j;
- int k;
- __u32 ip;
- __u32 xor;
- int this_netmatch;
- int best_netmatch;
- int best_npeers;
+ rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
+ ksock_net_t *net = peer->ksnp_ni->ni_data;
+ ksock_interface_t *iface;
+ ksock_interface_t *best_iface;
+ int n_ips;
+ int i;
+ int j;
+ int k;
+ __u32 ip;
+ __u32 xor;
+ int this_netmatch;
+ int best_netmatch;
+ int best_npeers;
/* CAVEAT EMPTOR: We do all our interface matching with an
* exclusive hold of global lock at IRQ priority. We're only
@@ -846,19 +846,19 @@ static void
ksocknal_create_routes(ksock_peer_t *peer, int port,
__u32 *peer_ipaddrs, int npeer_ipaddrs)
{
- ksock_route_t *newroute = NULL;
- rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
- lnet_ni_t *ni = peer->ksnp_ni;
- ksock_net_t *net = ni->ni_data;
- struct list_head *rtmp;
- ksock_route_t *route;
- ksock_interface_t *iface;
- ksock_interface_t *best_iface;
- int best_netmatch;
- int this_netmatch;
- int best_nroutes;
- int i;
- int j;
+ ksock_route_t *newroute = NULL;
+ rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
+ lnet_ni_t *ni = peer->ksnp_ni;
+ ksock_net_t *net = ni->ni_data;
+ struct list_head *rtmp;
+ ksock_route_t *route;
+ ksock_interface_t *iface;
+ ksock_interface_t *best_iface;
+ int best_netmatch;
+ int this_netmatch;
+ int best_nroutes;
+ int i;
+ int j;
/* CAVEAT EMPTOR: We do all our interface matching with an
* exclusive hold of global lock at IRQ priority. We're only
@@ -963,10 +963,10 @@ ksocknal_create_routes(ksock_peer_t *peer, int port,
int
ksocknal_accept(lnet_ni_t *ni, struct socket *sock)
{
- ksock_connreq_t *cr;
- int rc;
- __u32 peer_ip;
- int peer_port;
+ ksock_connreq_t *cr;
+ int rc;
+ __u32 peer_ip;
+ int peer_port;
rc = libcfs_sock_getaddr(sock, 1, &peer_ip, &peer_port);
LASSERT(rc == 0); /* we succeeded before */
@@ -994,7 +994,7 @@ ksocknal_accept(lnet_ni_t *ni, struct socket *sock)
static int
ksocknal_connecting(ksock_peer_t *peer, __u32 ipaddr)
{
- ksock_route_t *route;
+ ksock_route_t *route;
list_for_each_entry(route, &peer->ksnp_routes, ksnr_list) {
@@ -1008,23 +1008,23 @@ int
ksocknal_create_conn(lnet_ni_t *ni, ksock_route_t *route,
struct socket *sock, int type)
{
- rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
+ rwlock_t *global_lock = &ksocknal_data.ksnd_global_lock;
LIST_HEAD(zombies);
- lnet_process_id_t peerid;
- struct list_head *tmp;
- __u64 incarnation;
- ksock_conn_t *conn;
- ksock_conn_t *conn2;
- ksock_peer_t *peer = NULL;
- ksock_peer_t *peer2;
- ksock_sched_t *sched;
+ lnet_process_id_t peerid;
+ struct list_head *tmp;
+ __u64 incarnation;
+ ksock_conn_t *conn;
+ ksock_conn_t *conn2;
+ ksock_peer_t *peer = NULL;
+ ksock_peer_t *peer2;
+ ksock_sched_t *sched;
ksock_hello_msg_t *hello;
- int cpt;
- ksock_tx_t *tx;
- ksock_tx_t *txtmp;
- int rc;
- int active;
- char *warn = NULL;
+ int cpt;
+ ksock_tx_t *tx;
+ ksock_tx_t *txtmp;
+ int rc;
+ int active;
+ char *warn = NULL;
active = (route != NULL);
@@ -1396,10 +1396,10 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error)
/* This just does the immmediate housekeeping, and queues the
* connection for the reaper to terminate.
* Caller holds ksnd_global_lock exclusively in irq context */
- ksock_peer_t *peer = conn->ksnc_peer;
- ksock_route_t *route;
- ksock_conn_t *conn2;
- struct list_head *tmp;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_route_t *route;
+ ksock_conn_t *conn2;
+ struct list_head *tmp;
LASSERT(peer->ksnp_error == 0);
LASSERT(!conn->ksnc_closing);
@@ -1479,7 +1479,7 @@ ksocknal_close_conn_locked(ksock_conn_t *conn, int error)
void
ksocknal_peer_failed(ksock_peer_t *peer)
{
- int notify = 0;
+ int notify = 0;
unsigned long last_alive = 0;
/* There has been a connection failure or comms error; but I'll only
@@ -1506,9 +1506,9 @@ ksocknal_peer_failed(ksock_peer_t *peer)
void
ksocknal_finalize_zcreq(ksock_conn_t *conn)
{
- ksock_peer_t *peer = conn->ksnc_peer;
- ksock_tx_t *tx;
- ksock_tx_t *tmp;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_tx_t *tx;
+ ksock_tx_t *tmp;
LIST_HEAD(zlist);
/* NB safe to finalize TXs because closing of socket will
@@ -1546,9 +1546,9 @@ ksocknal_terminate_conn(ksock_conn_t *conn)
* disengage the socket from its callbacks and close it.
* ksnc_refcount will eventually hit zero, and then the reaper will
* destroy it. */
- ksock_peer_t *peer = conn->ksnc_peer;
- ksock_sched_t *sched = conn->ksnc_scheduler;
- int failed = 0;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_sched_t *sched = conn->ksnc_scheduler;
+ int failed = 0;
LASSERT(conn->ksnc_closing);
@@ -1617,7 +1617,7 @@ ksocknal_queue_zombie_conn(ksock_conn_t *conn)
void
ksocknal_destroy_conn(ksock_conn_t *conn)
{
- unsigned long last_rcv;
+ unsigned long last_rcv;
/* Final coup-de-grace of the reaper */
CDEBUG(D_NET, "connection %p\n", conn);
@@ -1677,10 +1677,10 @@ ksocknal_destroy_conn(ksock_conn_t *conn)
int
ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why)
{
- ksock_conn_t *conn;
- struct list_head *ctmp;
- struct list_head *cnxt;
- int count = 0;
+ ksock_conn_t *conn;
+ struct list_head *ctmp;
+ struct list_head *cnxt;
+ int count = 0;
list_for_each_safe(ctmp, cnxt, &peer->ksnp_conns) {
conn = list_entry(ctmp, ksock_conn_t, ksnc_list);
@@ -1698,9 +1698,9 @@ ksocknal_close_peer_conns_locked(ksock_peer_t *peer, __u32 ipaddr, int why)
int
ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why)
{
- ksock_peer_t *peer = conn->ksnc_peer;
- __u32 ipaddr = conn->ksnc_ipaddr;
- int count;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ __u32 ipaddr = conn->ksnc_ipaddr;
+ int count;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -1714,13 +1714,13 @@ ksocknal_close_conn_and_siblings(ksock_conn_t *conn, int why)
int
ksocknal_close_matching_conns(lnet_process_id_t id, __u32 ipaddr)
{
- ksock_peer_t *peer;
- struct list_head *ptmp;
- struct list_head *pnxt;
- int lo;
- int hi;
- int i;
- int count = 0;
+ ksock_peer_t *peer;
+ struct list_head *ptmp;
+ struct list_head *pnxt;
+ int lo;
+ int hi;
+ int i;
+ int count = 0;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -1762,7 +1762,7 @@ ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
{
/* The router is telling me she's been notified of a change in
* gateway state.... */
- lnet_process_id_t id = {0};
+ lnet_process_id_t id = {0};
id.nid = gw_nid;
id.pid = LNET_PID_ANY;
@@ -1783,20 +1783,20 @@ ksocknal_notify(lnet_ni_t *ni, lnet_nid_t gw_nid, int alive)
void
ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
{
- int connect = 1;
- unsigned long last_alive = 0;
- unsigned long now = cfs_time_current();
- ksock_peer_t *peer = NULL;
- rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
- lnet_process_id_t id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID};
+ int connect = 1;
+ unsigned long last_alive = 0;
+ unsigned long now = cfs_time_current();
+ ksock_peer_t *peer = NULL;
+ rwlock_t *glock = &ksocknal_data.ksnd_global_lock;
+ lnet_process_id_t id = {.nid = nid, .pid = LUSTRE_SRV_LNET_PID};
read_lock(glock);
peer = ksocknal_find_peer_locked(ni, id);
if (peer != NULL) {
- struct list_head *tmp;
- ksock_conn_t *conn;
- int bufnob;
+ struct list_head *tmp;
+ ksock_conn_t *conn;
+ int bufnob;
list_for_each(tmp, &peer->ksnp_conns) {
conn = list_entry(tmp, ksock_conn_t, ksnc_list);
@@ -1844,10 +1844,10 @@ ksocknal_query(lnet_ni_t *ni, lnet_nid_t nid, unsigned long *when)
static void
ksocknal_push_peer(ksock_peer_t *peer)
{
- int index;
- int i;
- struct list_head *tmp;
- ksock_conn_t *conn;
+ int index;
+ int i;
+ struct list_head *tmp;
+ ksock_conn_t *conn;
for (index = 0; ; index++) {
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -1877,12 +1877,12 @@ ksocknal_push_peer(ksock_peer_t *peer)
static int
ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id)
{
- ksock_peer_t *peer;
- struct list_head *tmp;
- int index;
- int i;
- int j;
- int rc = -ENOENT;
+ ksock_peer_t *peer;
+ struct list_head *tmp;
+ int index;
+ int i;
+ int j;
+ int rc = -ENOENT;
for (i = 0; i < ksocknal_data.ksnd_peer_hash_size; i++) {
for (j = 0; ; j++) {
@@ -1926,15 +1926,15 @@ ksocknal_push(lnet_ni_t *ni, lnet_process_id_t id)
static int
ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask)
{
- ksock_net_t *net = ni->ni_data;
+ ksock_net_t *net = ni->ni_data;
ksock_interface_t *iface;
- int rc;
- int i;
- int j;
- struct list_head *ptmp;
- ksock_peer_t *peer;
- struct list_head *rtmp;
- ksock_route_t *route;
+ int rc;
+ int i;
+ int j;
+ struct list_head *ptmp;
+ ksock_peer_t *peer;
+ struct list_head *rtmp;
+ ksock_route_t *route;
if (ipaddress == 0 ||
netmask == 0)
@@ -1988,12 +1988,12 @@ ksocknal_add_interface(lnet_ni_t *ni, __u32 ipaddress, __u32 netmask)
static void
ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
{
- struct list_head *tmp;
- struct list_head *nxt;
- ksock_route_t *route;
- ksock_conn_t *conn;
- int i;
- int j;
+ struct list_head *tmp;
+ struct list_head *nxt;
+ ksock_route_t *route;
+ ksock_conn_t *conn;
+ int i;
+ int j;
for (i = 0; i < peer->ksnp_n_passive_ips; i++)
if (peer->ksnp_passive_ips[i] == ipaddr) {
@@ -2029,14 +2029,14 @@ ksocknal_peer_del_interface_locked(ksock_peer_t *peer, __u32 ipaddr)
static int
ksocknal_del_interface(lnet_ni_t *ni, __u32 ipaddress)
{
- ksock_net_t *net = ni->ni_data;
- int rc = -ENOENT;
- struct list_head *tmp;
- struct list_head *nxt;
- ksock_peer_t *peer;
- __u32 this_ip;
- int i;
- int j;
+ ksock_net_t *net = ni->ni_data;
+ int rc = -ENOENT;
+ struct list_head *tmp;
+ struct list_head *nxt;
+ ksock_peer_t *peer;
+ __u32 this_ip;
+ int i;
+ int j;
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -2114,11 +2114,11 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
data->ioc_u32[0]); /* IP address */
case IOC_LIBCFS_GET_PEER: {
- __u32 myip = 0;
- __u32 ip = 0;
- int port = 0;
- int conn_count = 0;
- int share_count = 0;
+ __u32 myip = 0;
+ __u32 ip = 0;
+ int port = 0;
+ int conn_count = 0;
+ int share_count = 0;
rc = ksocknal_get_peer_info(ni, data->ioc_count,
&id, &myip, &ip, &port,
@@ -2150,9 +2150,9 @@ ksocknal_ctl(lnet_ni_t *ni, unsigned int cmd, void *arg)
data->ioc_u32[0]); /* IP */
case IOC_LIBCFS_GET_CONN: {
- int txmem;
- int rxmem;
- int nagle;
+ int txmem;
+ int rxmem;
+ int nagle;
ksock_conn_t *conn = ksocknal_get_conn_by_idx(ni, data->ioc_count);
if (conn == NULL)
@@ -2207,8 +2207,8 @@ ksocknal_free_buffers(void)
LASSERT(atomic_read(&ksocknal_data.ksnd_nactive_txs) == 0);
if (ksocknal_data.ksnd_sched_info != NULL) {
- struct ksock_sched_info *info;
- int i;
+ struct ksock_sched_info *info;
+ int i;
cfs_percpt_for_each(info, i, ksocknal_data.ksnd_sched_info) {
if (info->ksi_scheds != NULL) {
@@ -2227,8 +2227,8 @@ ksocknal_free_buffers(void)
spin_lock(&ksocknal_data.ksnd_tx_lock);
if (!list_empty(&ksocknal_data.ksnd_idle_noop_txs)) {
- struct list_head zlist;
- ksock_tx_t *tx;
+ struct list_head zlist;
+ ksock_tx_t *tx;
list_add(&zlist, &ksocknal_data.ksnd_idle_noop_txs);
list_del_init(&ksocknal_data.ksnd_idle_noop_txs);
@@ -2248,9 +2248,9 @@ static void
ksocknal_base_shutdown(void)
{
struct ksock_sched_info *info;
- ksock_sched_t *sched;
- int i;
- int j;
+ ksock_sched_t *sched;
+ int i;
+ int j;
CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n",
atomic_read(&libcfs_kmemory));
@@ -2351,8 +2351,8 @@ static int
ksocknal_base_startup(void)
{
struct ksock_sched_info *info;
- int rc;
- int i;
+ int rc;
+ int i;
LASSERT(ksocknal_data.ksnd_init == SOCKNAL_INIT_NOTHING);
LASSERT(ksocknal_data.ksnd_nnets == 0);
@@ -2398,8 +2398,8 @@ ksocknal_base_startup(void)
goto failed;
cfs_percpt_for_each(info, i, ksocknal_data.ksnd_sched_info) {
- ksock_sched_t *sched;
- int nthrs;
+ ksock_sched_t *sched;
+ int nthrs;
nthrs = cfs_cpt_weight(lnet_cpt_table(), i);
if (*ksocknal_tunables.ksnd_nscheds > 0) {
@@ -2430,9 +2430,9 @@ ksocknal_base_startup(void)
}
}
- ksocknal_data.ksnd_connd_starting = 0;
- ksocknal_data.ksnd_connd_failed_stamp = 0;
- ksocknal_data.ksnd_connd_starting_stamp = get_seconds();
+ ksocknal_data.ksnd_connd_starting = 0;
+ ksocknal_data.ksnd_connd_failed_stamp = 0;
+ ksocknal_data.ksnd_connd_starting_stamp = get_seconds();
/* must have at least 2 connds to remain responsive to accepts while
* connecting */
if (*ksocknal_tunables.ksnd_nconnds < SOCKNAL_CONND_RESV + 1)
@@ -2482,9 +2482,9 @@ ksocknal_base_startup(void)
static void
ksocknal_debug_peerhash(lnet_ni_t *ni)
{
- ksock_peer_t *peer = NULL;
- struct list_head *tmp;
- int i;
+ ksock_peer_t *peer = NULL;
+ struct list_head *tmp;
+ int i;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -2536,12 +2536,12 @@ ksocknal_debug_peerhash(lnet_ni_t *ni)
void
ksocknal_shutdown(lnet_ni_t *ni)
{
- ksock_net_t *net = ni->ni_data;
- int i;
+ ksock_net_t *net = ni->ni_data;
+ int i;
lnet_process_id_t anyid = {0};
- anyid.nid = LNET_NID_ANY;
- anyid.pid = LNET_PID_ANY;
+ anyid.nid = LNET_NID_ANY;
+ anyid.pid = LNET_PID_ANY;
LASSERT(ksocknal_data.ksnd_init == SOCKNAL_INIT_ALL);
LASSERT(ksocknal_data.ksnd_nnets > 0);
@@ -2588,11 +2588,11 @@ ksocknal_shutdown(lnet_ni_t *ni)
static int
ksocknal_enumerate_interfaces(ksock_net_t *net)
{
- char **names;
- int i;
- int j;
- int rc;
- int n;
+ char **names;
+ int i;
+ int j;
+ int rc;
+ int n;
n = libcfs_ipif_enumerate(&names);
if (n <= 0) {
@@ -2601,9 +2601,9 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
}
for (i = j = 0; i < n; i++) {
- int up;
- __u32 ip;
- __u32 mask;
+ int up;
+ __u32 ip;
+ __u32 mask;
if (!strcmp(names[i], "lo")) /* skip the loopback IF */
continue;
@@ -2645,15 +2645,15 @@ ksocknal_enumerate_interfaces(ksock_net_t *net)
static int
ksocknal_search_new_ipif(ksock_net_t *net)
{
- int new_ipif = 0;
- int i;
+ int new_ipif = 0;
+ int i;
for (i = 0; i < net->ksnn_ninterfaces; i++) {
- char *ifnam = &net->ksnn_interfaces[i].ksni_name[0];
- char *colon = strchr(ifnam, ':');
- int found = 0;
- ksock_net_t *tmp;
- int j;
+ char *ifnam = &net->ksnn_interfaces[i].ksni_name[0];
+ char *colon = strchr(ifnam, ':');
+ int found = 0;
+ ksock_net_t *tmp;
+ int j;
if (colon != NULL) /* ignore alias device */
*colon = 0;
@@ -2687,9 +2687,9 @@ ksocknal_search_new_ipif(ksock_net_t *net)
static int
ksocknal_start_schedulers(struct ksock_sched_info *info)
{
- int nthrs;
- int rc = 0;
- int i;
+ int nthrs;
+ int rc = 0;
+ int i;
if (info->ksi_nthreads == 0) {
if (*ksocknal_tunables.ksnd_nscheds > 0) {
@@ -2708,9 +2708,9 @@ ksocknal_start_schedulers(struct ksock_sched_info *info)
}
for (i = 0; i < nthrs; i++) {
- long id;
- char name[20];
- ksock_sched_t *sched;
+ long id;
+ char name[20];
+ ksock_sched_t *sched;
id = KSOCK_THREAD_ID(info->ksi_cpt, info->ksi_nthreads + i);
sched = &info->ksi_scheds[KSOCK_THREAD_SID(id)];
snprintf(name, sizeof(name), "socknal_sd%02d_%02d",
@@ -2733,14 +2733,14 @@ ksocknal_start_schedulers(struct ksock_sched_info *info)
static int
ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts)
{
- int newif = ksocknal_search_new_ipif(net);
- int rc;
- int i;
+ int newif = ksocknal_search_new_ipif(net);
+ int rc;
+ int i;
LASSERT(ncpts > 0 && ncpts <= cfs_cpt_number(lnet_cpt_table()));
for (i = 0; i < ncpts; i++) {
- struct ksock_sched_info *info;
+ struct ksock_sched_info *info;
int cpt = (cpts == NULL) ? i : cpts[i];
LASSERT(cpt < cfs_cpt_number(lnet_cpt_table()));
@@ -2759,9 +2759,9 @@ ksocknal_net_start_threads(ksock_net_t *net, __u32 *cpts, int ncpts)
int
ksocknal_startup(lnet_ni_t *ni)
{
- ksock_net_t *net;
- int rc;
- int i;
+ ksock_net_t *net;
+ int rc;
+ int i;
LASSERT(ni->ni_lnd == &the_ksocklnd);
@@ -2791,7 +2791,7 @@ ksocknal_startup(lnet_ni_t *ni)
net->ksnn_ninterfaces = 1;
} else {
for (i = 0; i < LNET_MAX_INTERFACES; i++) {
- int up;
+ int up;
if (ni->ni_interfaces[i] == NULL)
break;
@@ -2851,7 +2851,7 @@ ksocknal_module_fini(void)
static int __init
ksocknal_module_init(void)
{
- int rc;
+ int rc;
/* check ksnr_connected/connecting field large enough */
CLASSERT(SOCKLND_CONN_NTYPES <= 4);
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
index c54c9955164eda..c34378c0220a77 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.h
@@ -36,15 +36,15 @@
#include "../../../include/linux/lnet/socklnd.h"
#include "../../../include/linux/lnet/lnet-sysctl.h"
-#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */
-#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */
-#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */
-#define SOCKNAL_ENOMEM_RETRY CFS_TICK /* jiffies between retries */
+#define SOCKNAL_PEER_HASH_SIZE 101 /* # peer lists */
+#define SOCKNAL_RESCHED 100 /* # scheduler loops before reschedule */
+#define SOCKNAL_INSANITY_RECONN 5000 /* connd is trying on reconn infinitely */
+#define SOCKNAL_ENOMEM_RETRY CFS_TICK /* jiffies between retries */
-#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */
-#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */
+#define SOCKNAL_SINGLE_FRAG_TX 0 /* disable multi-fragment sends */
+#define SOCKNAL_SINGLE_FRAG_RX 0 /* disable multi-fragment receives */
-#define SOCKNAL_VERSION_DEBUG 0 /* enable protocol version debugging */
+#define SOCKNAL_VERSION_DEBUG 0 /* enable protocol version debugging */
/* risk kmap deadlock on multi-frag I/O (backs off to single-frag if disabled).
* no risk if we're not running on a CONFIG_HIGHMEM platform. */
@@ -58,33 +58,31 @@ struct ksock_sched_info;
typedef struct /* per scheduler state */
{
- spinlock_t kss_lock; /* serialise */
- struct list_head kss_rx_conns; /* conn waiting to be read */
- /* conn waiting to be written */
- struct list_head kss_tx_conns;
- /* zombie noop tx list */
- struct list_head kss_zombie_noop_txs;
- wait_queue_head_t kss_waitq; /* where scheduler sleeps */
- /* # connections assigned to this scheduler */
- int kss_nconns;
- struct ksock_sched_info *kss_info; /* owner of it */
- struct page *kss_rx_scratch_pgs[LNET_MAX_IOV];
- struct kvec kss_scratch_iov[LNET_MAX_IOV];
+ spinlock_t kss_lock; /* serialise */
+ struct list_head kss_rx_conns; /* conn waiting to be read */
+ struct list_head kss_tx_conns; /* conn waiting to be written */
+ struct list_head kss_zombie_noop_txs; /* zombie noop tx list */
+ wait_queue_head_t kss_waitq; /* where scheduler sleeps */
+ int kss_nconns; /* # connections assigned to
+ * this scheduler */
+ struct ksock_sched_info *kss_info; /* owner of it */
+ struct page *kss_rx_scratch_pgs[LNET_MAX_IOV];
+ struct kvec kss_scratch_iov[LNET_MAX_IOV];
} ksock_sched_t;
struct ksock_sched_info {
- int ksi_nthreads_max; /* max allowed threads */
- int ksi_nthreads; /* number of threads */
- int ksi_cpt; /* CPT id */
- ksock_sched_t *ksi_scheds; /* array of schedulers */
+ int ksi_nthreads_max; /* max allowed threads */
+ int ksi_nthreads; /* number of threads */
+ int ksi_cpt; /* CPT id */
+ ksock_sched_t *ksi_scheds; /* array of schedulers */
};
-#define KSOCK_CPT_SHIFT 16
-#define KSOCK_THREAD_ID(cpt, sid) (((cpt) << KSOCK_CPT_SHIFT) | (sid))
-#define KSOCK_THREAD_CPT(id) ((id) >> KSOCK_CPT_SHIFT)
-#define KSOCK_THREAD_SID(id) ((id) & ((1UL << KSOCK_CPT_SHIFT) - 1))
+#define KSOCK_CPT_SHIFT 16
+#define KSOCK_THREAD_ID(cpt, sid) (((cpt) << KSOCK_CPT_SHIFT) | (sid))
+#define KSOCK_THREAD_CPT(id) ((id) >> KSOCK_CPT_SHIFT)
+#define KSOCK_THREAD_SID(id) ((id) & ((1UL << KSOCK_CPT_SHIFT) - 1))
-typedef struct /* in-use interface */
+typedef struct /* in-use interface */
{
__u32 ksni_ipaddr; /* interface's IP address */
__u32 ksni_netmask; /* interface's network mask */
@@ -94,35 +92,48 @@ typedef struct /* in-use interface */
} ksock_interface_t;
typedef struct {
- /* "stuck" socket timeout (seconds) */
- int *ksnd_timeout;
- /* # scheduler threads in each pool while starting */
- int *ksnd_nscheds;
- int *ksnd_nconnds; /* # connection daemons */
- int *ksnd_nconnds_max; /* max # connection daemons */
- int *ksnd_min_reconnectms; /* first connection retry after (ms)... */
- int *ksnd_max_reconnectms; /* ...exponentially increasing to this */
- int *ksnd_eager_ack; /* make TCP ack eagerly? */
- int *ksnd_typed_conns; /* drive sockets by type? */
- int *ksnd_min_bulk; /* smallest "large" message */
- int *ksnd_tx_buffer_size; /* socket tx buffer size */
- int *ksnd_rx_buffer_size; /* socket rx buffer size */
- int *ksnd_nagle; /* enable NAGLE? */
- int *ksnd_round_robin; /* round robin for multiple interfaces */
- int *ksnd_keepalive; /* # secs for sending keepalive NOOP */
- int *ksnd_keepalive_idle; /* # idle secs before 1st probe */
- int *ksnd_keepalive_count; /* # probes */
- int *ksnd_keepalive_intvl; /* time between probes */
- int *ksnd_credits; /* # concurrent sends */
- int *ksnd_peertxcredits; /* # concurrent sends to 1 peer */
- int *ksnd_peerrtrcredits; /* # per-peer router buffer credits */
- int *ksnd_peertimeout; /* seconds to consider peer dead */
- int *ksnd_enable_csum; /* enable check sum */
- int *ksnd_inject_csum_error; /* set non-zero to inject checksum error */
- int *ksnd_nonblk_zcack; /* always send zc-ack on non-blocking connection */
- unsigned int *ksnd_zc_min_payload; /* minimum zero copy payload size */
- int *ksnd_zc_recv; /* enable ZC receive (for Chelsio TOE) */
- int *ksnd_zc_recv_min_nfrags; /* minimum # of fragments to enable ZC receive */
+ int *ksnd_timeout; /* "stuck" socket timeout
+ * (seconds) */
+ int *ksnd_nscheds; /* # scheduler threads in each
+ * pool while starting */
+ int *ksnd_nconnds; /* # connection daemons */
+ int *ksnd_nconnds_max; /* max # connection daemons */
+ int *ksnd_min_reconnectms; /* first connection retry after
+ * (ms)... */
+ int *ksnd_max_reconnectms; /* ...exponentially increasing to
+ * this */
+ int *ksnd_eager_ack; /* make TCP ack eagerly? */
+ int *ksnd_typed_conns; /* drive sockets by type? */
+ int *ksnd_min_bulk; /* smallest "large" message */
+ int *ksnd_tx_buffer_size; /* socket tx buffer size */
+ int *ksnd_rx_buffer_size; /* socket rx buffer size */
+ int *ksnd_nagle; /* enable NAGLE? */
+ int *ksnd_round_robin; /* round robin for multiple
+ * interfaces */
+ int *ksnd_keepalive; /* # secs for sending keepalive
+ * NOOP */
+ int *ksnd_keepalive_idle; /* # idle secs before 1st probe
+ */
+ int *ksnd_keepalive_count; /* # probes */
+ int *ksnd_keepalive_intvl; /* time between probes */
+ int *ksnd_credits; /* # concurrent sends */
+ int *ksnd_peertxcredits; /* # concurrent sends to 1 peer
+ */
+ int *ksnd_peerrtrcredits; /* # per-peer router buffer
+ * credits */
+ int *ksnd_peertimeout; /* seconds to consider peer dead
+ */
+ int *ksnd_enable_csum; /* enable check sum */
+ int *ksnd_inject_csum_error; /* set non-zero to inject
+ * checksum error */
+ int *ksnd_nonblk_zcack; /* always send zc-ack on
+ * non-blocking connection */
+ unsigned int *ksnd_zc_min_payload; /* minimum zero copy payload
+ * size */
+ int *ksnd_zc_recv; /* enable ZC receive (for
+ * Chelsio TOE) */
+ int *ksnd_zc_recv_min_nfrags; /* minimum # of fragments to
+ * enable ZC receive */
} ksock_tunables_t;
typedef struct {
@@ -141,55 +152,67 @@ typedef struct {
#define SOCKNAL_CONND_RESV 1
typedef struct {
- int ksnd_init; /* initialisation state */
- int ksnd_nnets; /* # networks set up */
- struct list_head ksnd_nets; /* list of nets */
- /* stabilize peer/conn ops */
- rwlock_t ksnd_global_lock;
- /* hash table of all my known peers */
- struct list_head *ksnd_peers;
- int ksnd_peer_hash_size; /* size of ksnd_peers */
-
- int ksnd_nthreads; /* # live threads */
- int ksnd_shuttingdown; /* tell threads to exit */
- /* schedulers information */
- struct ksock_sched_info **ksnd_sched_info;
-
- atomic_t ksnd_nactive_txs; /* #active txs */
-
- struct list_head ksnd_deathrow_conns; /* conns to close: reaper_lock*/
- struct list_head ksnd_zombie_conns; /* conns to free: reaper_lock */
- struct list_head ksnd_enomem_conns; /* conns to retry: reaper_lock*/
- wait_queue_head_t ksnd_reaper_waitq; /* reaper sleeps here */
- unsigned long ksnd_reaper_waketime;/* when reaper will wake */
- spinlock_t ksnd_reaper_lock; /* serialise */
-
- int ksnd_enomem_tx; /* test ENOMEM sender */
- int ksnd_stall_tx; /* test sluggish sender */
- int ksnd_stall_rx; /* test sluggish receiver */
-
- struct list_head ksnd_connd_connreqs; /* incoming connection requests */
- struct list_head ksnd_connd_routes; /* routes waiting to be connected */
- wait_queue_head_t ksnd_connd_waitq; /* connds sleep here */
- int ksnd_connd_connecting;/* # connds connecting */
- /** time stamp of the last failed connecting attempt */
- long ksnd_connd_failed_stamp;
- /** # starting connd */
- unsigned ksnd_connd_starting;
- /** time stamp of the last starting connd */
- long ksnd_connd_starting_stamp;
- /** # running connd */
- unsigned ksnd_connd_running;
- spinlock_t ksnd_connd_lock; /* serialise */
-
- struct list_head ksnd_idle_noop_txs; /* list head for freed noop tx */
- spinlock_t ksnd_tx_lock; /* serialise, g_lock unsafe */
+ int ksnd_init; /* initialisation state
+ */
+ int ksnd_nnets; /* # networks set up */
+ struct list_head ksnd_nets; /* list of nets */
+ rwlock_t ksnd_global_lock; /* stabilize peer/conn
+ * ops */
+ struct list_head *ksnd_peers; /* hash table of all my
+ * known peers */
+ int ksnd_peer_hash_size; /* size of ksnd_peers */
+
+ int ksnd_nthreads; /* # live threads */
+ int ksnd_shuttingdown; /* tell threads to exit
+ */
+ struct ksock_sched_info **ksnd_sched_info; /* schedulers info */
+
+ atomic_t ksnd_nactive_txs; /* #active txs */
+
+ struct list_head ksnd_deathrow_conns; /* conns to close:
+ * reaper_lock*/
+ struct list_head ksnd_zombie_conns; /* conns to free:
+ * reaper_lock */
+ struct list_head ksnd_enomem_conns; /* conns to retry:
+ * reaper_lock*/
+ wait_queue_head_t ksnd_reaper_waitq; /* reaper sleeps here */
+ unsigned long ksnd_reaper_waketime; /* when reaper will wake
+ */
+ spinlock_t ksnd_reaper_lock; /* serialise */
+
+ int ksnd_enomem_tx; /* test ENOMEM sender */
+ int ksnd_stall_tx; /* test sluggish sender
+ */
+ int ksnd_stall_rx; /* test sluggish
+ * receiver */
+
+ struct list_head ksnd_connd_connreqs; /* incoming connection
+ * requests */
+ struct list_head ksnd_connd_routes; /* routes waiting to be
+ * connected */
+ wait_queue_head_t ksnd_connd_waitq; /* connds sleep here */
+ int ksnd_connd_connecting; /* # connds connecting
+ */
+ long ksnd_connd_failed_stamp;/* time stamp of the
+ * last failed
+ * connecting attempt */
+ unsigned ksnd_connd_starting; /* # starting connd */
+ long ksnd_connd_starting_stamp;/* time stamp of the
+ * last starting connd
+ */
+ unsigned ksnd_connd_running; /* # running connd */
+ spinlock_t ksnd_connd_lock; /* serialise */
+
+ struct list_head ksnd_idle_noop_txs; /* list head for freed
+ * noop tx */
+ spinlock_t ksnd_tx_lock; /* serialise, g_lock
+ * unsafe */
} ksock_nal_data_t;
-#define SOCKNAL_INIT_NOTHING 0
-#define SOCKNAL_INIT_DATA 1
-#define SOCKNAL_INIT_ALL 2
+#define SOCKNAL_INIT_NOTHING 0
+#define SOCKNAL_INIT_DATA 1
+#define SOCKNAL_INIT_ALL 2
/* A packet just assembled for transmission is represented by 1 or more
* struct iovec fragments (the first frag contains the portals header),
@@ -200,43 +223,45 @@ typedef struct {
* received into either struct iovec or lnet_kiov_t fragments, depending on
* what the header matched or whether the message needs forwarding. */
-struct ksock_conn; /* forward ref */
-struct ksock_peer; /* forward ref */
-struct ksock_route; /* forward ref */
-struct ksock_proto; /* forward ref */
+struct ksock_conn; /* forward ref */
+struct ksock_peer; /* forward ref */
+struct ksock_route; /* forward ref */
+struct ksock_proto; /* forward ref */
-typedef struct /* transmit packet */
+typedef struct /* transmit packet */
{
- struct list_head tx_list; /* queue on conn for transmission etc */
- struct list_head tx_zc_list; /* queue on peer for ZC request */
- atomic_t tx_refcount; /* tx reference count */
- int tx_nob; /* # packet bytes */
- int tx_resid; /* residual bytes */
- int tx_niov; /* # packet iovec frags */
- struct kvec *tx_iov; /* packet iovec frags */
- int tx_nkiov; /* # packet page frags */
- unsigned short tx_zc_aborted; /* aborted ZC request */
- unsigned short tx_zc_capable:1; /* payload is large enough for ZC */
- unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */
- unsigned short tx_nonblk:1; /* it's a non-blocking ACK */
- lnet_kiov_t *tx_kiov; /* packet page frags */
- struct ksock_conn *tx_conn; /* owning conn */
- lnet_msg_t *tx_lnetmsg; /* lnet message for lnet_finalize() */
- unsigned long tx_deadline; /* when (in jiffies) tx times out */
- ksock_msg_t tx_msg; /* socklnd message buffer */
- int tx_desc_size; /* size of this descriptor */
+ struct list_head tx_list; /* queue on conn for transmission etc
+ */
+ struct list_head tx_zc_list; /* queue on peer for ZC request */
+ atomic_t tx_refcount; /* tx reference count */
+ int tx_nob; /* # packet bytes */
+ int tx_resid; /* residual bytes */
+ int tx_niov; /* # packet iovec frags */
+ struct kvec *tx_iov; /* packet iovec frags */
+ int tx_nkiov; /* # packet page frags */
+ unsigned short tx_zc_aborted; /* aborted ZC request */
+ unsigned short tx_zc_capable:1; /* payload is large enough for ZC */
+ unsigned short tx_zc_checked:1; /* Have I checked if I should ZC? */
+ unsigned short tx_nonblk:1; /* it's a non-blocking ACK */
+ lnet_kiov_t *tx_kiov; /* packet page frags */
+ struct ksock_conn *tx_conn; /* owning conn */
+ lnet_msg_t *tx_lnetmsg; /* lnet message for lnet_finalize()
+ */
+ unsigned long tx_deadline; /* when (in jiffies) tx times out */
+ ksock_msg_t tx_msg; /* socklnd message buffer */
+ int tx_desc_size; /* size of this descriptor */
union {
struct {
- struct kvec iov; /* virt hdr */
- lnet_kiov_t kiov[0]; /* paged payload */
- } paged;
+ struct kvec iov; /* virt hdr */
+ lnet_kiov_t kiov[0]; /* paged payload */
+ } paged;
struct {
- struct kvec iov[1]; /* virt hdr + payload */
- } virt;
- } tx_frags;
+ struct kvec iov[1]; /* virt hdr + payload */
+ } virt;
+ } tx_frags;
} ksock_tx_t;
-#define KSOCK_NOOP_TX_SIZE ((int)offsetof(ksock_tx_t, tx_frags.paged.kiov[0]))
+#define KSOCK_NOOP_TX_SIZE ((int)offsetof(ksock_tx_t, tx_frags.paged.kiov[0]))
/* network zero copy callback descriptor embedded in ksock_tx_t */
@@ -247,148 +272,189 @@ typedef union {
lnet_kiov_t kiov[LNET_MAX_IOV];
} ksock_rxiovspace_t;
-#define SOCKNAL_RX_KSM_HEADER 1 /* reading ksock message header */
-#define SOCKNAL_RX_LNET_HEADER 2 /* reading lnet message header */
-#define SOCKNAL_RX_PARSE 3 /* Calling lnet_parse() */
-#define SOCKNAL_RX_PARSE_WAIT 4 /* waiting to be told to read the body */
-#define SOCKNAL_RX_LNET_PAYLOAD 5 /* reading lnet payload (to deliver here) */
-#define SOCKNAL_RX_SLOP 6 /* skipping body */
+#define SOCKNAL_RX_KSM_HEADER 1 /* reading ksock message header */
+#define SOCKNAL_RX_LNET_HEADER 2 /* reading lnet message header */
+#define SOCKNAL_RX_PARSE 3 /* Calling lnet_parse() */
+#define SOCKNAL_RX_PARSE_WAIT 4 /* waiting to be told to read the body */
+#define SOCKNAL_RX_LNET_PAYLOAD 5 /* reading lnet payload (to deliver here) */
+#define SOCKNAL_RX_SLOP 6 /* skipping body */
typedef struct ksock_conn {
- struct ksock_peer *ksnc_peer; /* owning peer */
- struct ksock_route *ksnc_route; /* owning route */
- struct list_head ksnc_list; /* stash on peer's conn list */
- struct socket *ksnc_sock; /* actual socket */
- void *ksnc_saved_data_ready; /* socket's original data_ready() callback */
- void *ksnc_saved_write_space; /* socket's original write_space() callback */
- atomic_t ksnc_conn_refcount; /* conn refcount */
- atomic_t ksnc_sock_refcount; /* sock refcount */
- ksock_sched_t *ksnc_scheduler; /* who schedules this connection */
- __u32 ksnc_myipaddr; /* my IP */
- __u32 ksnc_ipaddr; /* peer's IP */
- int ksnc_port; /* peer's port */
- signed int ksnc_type:3; /* type of connection,
- * should be signed value */
- unsigned int ksnc_closing:1; /* being shut down */
- unsigned int ksnc_flip:1; /* flip or not, only for V2.x */
- unsigned int ksnc_zc_capable:1; /* enable to ZC */
- struct ksock_proto *ksnc_proto; /* protocol for the connection */
+ struct ksock_peer *ksnc_peer; /* owning peer */
+ struct ksock_route *ksnc_route; /* owning route */
+ struct list_head ksnc_list; /* stash on peer's conn list */
+ struct socket *ksnc_sock; /* actual socket */
+ void *ksnc_saved_data_ready; /* socket's original
+ * data_ready() callback */
+ void *ksnc_saved_write_space; /* socket's original
+ * write_space() callback */
+ atomic_t ksnc_conn_refcount;/* conn refcount */
+ atomic_t ksnc_sock_refcount;/* sock refcount */
+ ksock_sched_t *ksnc_scheduler; /* who schedules this connection
+ */
+ __u32 ksnc_myipaddr; /* my IP */
+ __u32 ksnc_ipaddr; /* peer's IP */
+ int ksnc_port; /* peer's port */
+ signed int ksnc_type:3; /* type of connection, should be
+ * signed value */
+ unsigned int ksnc_closing:1; /* being shut down */
+ unsigned int ksnc_flip:1; /* flip or not, only for V2.x */
+ unsigned int ksnc_zc_capable:1; /* enable to ZC */
+ struct ksock_proto *ksnc_proto; /* protocol for the connection */
/* reader */
- struct list_head ksnc_rx_list; /* where I enq waiting input or a forwarding descriptor */
- unsigned long ksnc_rx_deadline; /* when (in jiffies) receive times out */
- __u8 ksnc_rx_started; /* started receiving a message */
- __u8 ksnc_rx_ready; /* data ready to read */
- __u8 ksnc_rx_scheduled;/* being progressed */
- __u8 ksnc_rx_state; /* what is being read */
- int ksnc_rx_nob_left; /* # bytes to next hdr/body */
- int ksnc_rx_nob_wanted; /* bytes actually wanted */
- int ksnc_rx_niov; /* # iovec frags */
- struct kvec *ksnc_rx_iov; /* the iovec frags */
- int ksnc_rx_nkiov; /* # page frags */
- lnet_kiov_t *ksnc_rx_kiov; /* the page frags */
- ksock_rxiovspace_t ksnc_rx_iov_space;/* space for frag descriptors */
- __u32 ksnc_rx_csum; /* partial checksum for incoming data */
- void *ksnc_cookie; /* rx lnet_finalize passthru arg */
- ksock_msg_t ksnc_msg; /* incoming message buffer:
- * V2.x message takes the
- * whole struct
- * V1.x message is a bare
- * lnet_hdr_t, it's stored in
- * ksnc_msg.ksm_u.lnetmsg */
+ struct list_head ksnc_rx_list; /* where I enq waiting input or a
+ * forwarding descriptor */
+ unsigned long ksnc_rx_deadline; /* when (in jiffies) receive times
+ * out */
+ __u8 ksnc_rx_started; /* started receiving a message */
+ __u8 ksnc_rx_ready; /* data ready to read */
+ __u8 ksnc_rx_scheduled; /* being progressed */
+ __u8 ksnc_rx_state; /* what is being read */
+ int ksnc_rx_nob_left; /* # bytes to next hdr/body */
+ int ksnc_rx_nob_wanted;/* bytes actually wanted */
+ int ksnc_rx_niov; /* # iovec frags */
+ struct kvec *ksnc_rx_iov; /* the iovec frags */
+ int ksnc_rx_nkiov; /* # page frags */
+ lnet_kiov_t *ksnc_rx_kiov; /* the page frags */
+ ksock_rxiovspace_t ksnc_rx_iov_space; /* space for frag descriptors */
+ __u32 ksnc_rx_csum; /* partial checksum for incoming
+ * data */
+ void *ksnc_cookie; /* rx lnet_finalize passthru arg
+ */
+ ksock_msg_t ksnc_msg; /* incoming message buffer:
+ * V2.x message takes the
+ * whole struct
+ * V1.x message is a bare
+ * lnet_hdr_t, it's stored in
+ * ksnc_msg.ksm_u.lnetmsg */
/* WRITER */
- struct list_head ksnc_tx_list; /* where I enq waiting for output space */
- struct list_head ksnc_tx_queue; /* packets waiting to be sent */
- ksock_tx_t *ksnc_tx_carrier; /* next TX that can carry a LNet message or ZC-ACK */
- unsigned long ksnc_tx_deadline; /* when (in jiffies) tx times out */
- int ksnc_tx_bufnob; /* send buffer marker */
- atomic_t ksnc_tx_nob; /* # bytes queued */
- int ksnc_tx_ready; /* write space */
- int ksnc_tx_scheduled; /* being progressed */
- unsigned long ksnc_tx_last_post; /* time stamp of the last posted TX */
+ struct list_head ksnc_tx_list; /* where I enq waiting for output
+ * space */
+ struct list_head ksnc_tx_queue; /* packets waiting to be sent */
+ ksock_tx_t *ksnc_tx_carrier; /* next TX that can carry a LNet
+ * message or ZC-ACK */
+ unsigned long ksnc_tx_deadline; /* when (in jiffies) tx times out
+ */
+ int ksnc_tx_bufnob; /* send buffer marker */
+ atomic_t ksnc_tx_nob; /* # bytes queued */
+ int ksnc_tx_ready; /* write space */
+ int ksnc_tx_scheduled; /* being progressed */
+ unsigned long ksnc_tx_last_post; /* time stamp of the last posted
+ * TX */
} ksock_conn_t;
typedef struct ksock_route {
- struct list_head ksnr_list; /* chain on peer route list */
- struct list_head ksnr_connd_list; /* chain on ksnr_connd_routes */
- struct ksock_peer *ksnr_peer; /* owning peer */
- atomic_t ksnr_refcount; /* # users */
- unsigned long ksnr_timeout; /* when (in jiffies) reconnection can happen next */
- long ksnr_retry_interval; /* how long between retries */
- __u32 ksnr_myipaddr; /* my IP */
- __u32 ksnr_ipaddr; /* IP address to connect to */
- int ksnr_port; /* port to connect to */
- unsigned int ksnr_scheduled:1; /* scheduled for attention */
- unsigned int ksnr_connecting:1;/* connection establishment in progress */
- unsigned int ksnr_connected:4; /* connections established by type */
- unsigned int ksnr_deleted:1; /* been removed from peer? */
- unsigned int ksnr_share_count; /* created explicitly? */
- int ksnr_conn_count; /* # conns established by this route */
+ struct list_head ksnr_list; /* chain on peer route list */
+ struct list_head ksnr_connd_list; /* chain on ksnr_connd_routes */
+ struct ksock_peer *ksnr_peer; /* owning peer */
+ atomic_t ksnr_refcount; /* # users */
+ unsigned long ksnr_timeout; /* when (in jiffies) reconnection
+ * can happen next */
+ long ksnr_retry_interval; /* how long between retries */
+ __u32 ksnr_myipaddr; /* my IP */
+ __u32 ksnr_ipaddr; /* IP address to connect to */
+ int ksnr_port; /* port to connect to */
+ unsigned int ksnr_scheduled:1; /* scheduled for attention */
+ unsigned int ksnr_connecting:1; /* connection establishment in
+ * progress */
+ unsigned int ksnr_connected:4; /* connections established by
+ * type */
+ unsigned int ksnr_deleted:1; /* been removed from peer? */
+ unsigned int ksnr_share_count; /* created explicitly? */
+ int ksnr_conn_count; /* # conns established by this
+ * route */
} ksock_route_t;
-#define SOCKNAL_KEEPALIVE_PING 1 /* cookie for keepalive ping */
+#define SOCKNAL_KEEPALIVE_PING 1 /* cookie for keepalive ping */
typedef struct ksock_peer {
- struct list_head ksnp_list; /* stash on global peer list */
- unsigned long ksnp_last_alive; /* when (in jiffies) I was last alive */
- lnet_process_id_t ksnp_id; /* who's on the other end(s) */
- atomic_t ksnp_refcount; /* # users */
- int ksnp_sharecount; /* lconf usage counter */
- int ksnp_closing; /* being closed */
- int ksnp_accepting;/* # passive connections pending */
- int ksnp_error; /* errno on closing last conn */
- __u64 ksnp_zc_next_cookie;/* ZC completion cookie */
- __u64 ksnp_incarnation; /* latest known peer incarnation */
- struct ksock_proto *ksnp_proto; /* latest known peer protocol */
- struct list_head ksnp_conns; /* all active connections */
- struct list_head ksnp_routes; /* routes */
- struct list_head ksnp_tx_queue; /* waiting packets */
- spinlock_t ksnp_lock; /* serialize, g_lock unsafe */
- struct list_head ksnp_zc_req_list; /* zero copy requests wait for ACK */
- unsigned long ksnp_send_keepalive; /* time to send keepalive */
- lnet_ni_t *ksnp_ni; /* which network */
- int ksnp_n_passive_ips; /* # of... */
- __u32 ksnp_passive_ips[LNET_MAX_INTERFACES]; /* preferred local interfaces */
+ struct list_head ksnp_list; /* stash on global peer list */
+ unsigned long ksnp_last_alive; /* when (in jiffies) I was last
+ * alive */
+ lnet_process_id_t ksnp_id; /* who's on the other end(s) */
+ atomic_t ksnp_refcount; /* # users */
+ int ksnp_sharecount; /* lconf usage counter */
+ int ksnp_closing; /* being closed */
+ int ksnp_accepting; /* # passive connections pending
+ */
+ int ksnp_error; /* errno on closing last conn */
+ __u64 ksnp_zc_next_cookie; /* ZC completion cookie */
+ __u64 ksnp_incarnation; /* latest known peer incarnation
+ */
+ struct ksock_proto *ksnp_proto; /* latest known peer protocol */
+ struct list_head ksnp_conns; /* all active connections */
+ struct list_head ksnp_routes; /* routes */
+ struct list_head ksnp_tx_queue; /* waiting packets */
+ spinlock_t ksnp_lock; /* serialize, g_lock unsafe */
+ struct list_head ksnp_zc_req_list; /* zero copy requests wait for
+ * ACK */
+ unsigned long ksnp_send_keepalive; /* time to send keepalive */
+ lnet_ni_t *ksnp_ni; /* which network */
+ int ksnp_n_passive_ips; /* # of... */
+
+ /* preferred local interfaces */
+ __u32 ksnp_passive_ips[LNET_MAX_INTERFACES];
} ksock_peer_t;
typedef struct ksock_connreq {
- struct list_head ksncr_list; /* stash on ksnd_connd_connreqs */
- lnet_ni_t *ksncr_ni; /* chosen NI */
- struct socket *ksncr_sock; /* accepted socket */
+ struct list_head ksncr_list; /* stash on ksnd_connd_connreqs */
+ lnet_ni_t *ksncr_ni; /* chosen NI */
+ struct socket *ksncr_sock; /* accepted socket */
} ksock_connreq_t;
extern ksock_nal_data_t ksocknal_data;
extern ksock_tunables_t ksocknal_tunables;
-#define SOCKNAL_MATCH_NO 0 /* TX can't match type of connection */
-#define SOCKNAL_MATCH_YES 1 /* TX matches type of connection */
-#define SOCKNAL_MATCH_MAY 2 /* TX can be sent on the connection, but not preferred */
+#define SOCKNAL_MATCH_NO 0 /* TX can't match type of connection */
+#define SOCKNAL_MATCH_YES 1 /* TX matches type of connection */
+#define SOCKNAL_MATCH_MAY 2 /* TX can be sent on the connection, but not
+ * preferred */
typedef struct ksock_proto {
- int pro_version; /* version number of protocol */
- int (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *); /* handshake function */
- int (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int);/* handshake function */
- void (*pro_pack)(ksock_tx_t *); /* message pack */
- void (*pro_unpack)(ksock_msg_t *); /* message unpack */
- ksock_tx_t *(*pro_queue_tx_msg)(ksock_conn_t *, ksock_tx_t *); /* queue tx on the connection */
- int (*pro_queue_tx_zcack)(ksock_conn_t *, ksock_tx_t *, __u64); /* queue ZC ack on the connection */
- int (*pro_handle_zcreq)(ksock_conn_t *, __u64, int); /* handle ZC request */
- int (*pro_handle_zcack)(ksock_conn_t *, __u64, __u64); /* handle ZC ACK */
- int (*pro_match_tx)(ksock_conn_t *, ksock_tx_t *, int); /* msg type matches the connection type:
- * return value:
- * return MATCH_NO : no
- * return MATCH_YES : matching type
- * return MATCH_MAY : can be backup */
+ /* version number of protocol */
+ int pro_version;
+
+ /* handshake function */
+ int (*pro_send_hello)(ksock_conn_t *, ksock_hello_msg_t *);
+
+ /* handshake function */
+ int (*pro_recv_hello)(ksock_conn_t *, ksock_hello_msg_t *, int);
+
+ /* message pack */
+ void (*pro_pack)(ksock_tx_t *);
+
+ /* message unpack */
+ void (*pro_unpack)(ksock_msg_t *);
+
+ /* queue tx on the connection */
+ ksock_tx_t *(*pro_queue_tx_msg)(ksock_conn_t *, ksock_tx_t *);
+
+ /* queue ZC ack on the connection */
+ int (*pro_queue_tx_zcack)(ksock_conn_t *, ksock_tx_t *, __u64);
+
+ /* handle ZC request */
+ int (*pro_handle_zcreq)(ksock_conn_t *, __u64, int);
+
+ /* handle ZC ACK */
+ int (*pro_handle_zcack)(ksock_conn_t *, __u64, __u64);
+
+ /* msg type matches the connection type:
+ * return value:
+ * return MATCH_NO : no
+ * return MATCH_YES : matching type
+ * return MATCH_MAY : can be backup */
+ int (*pro_match_tx)(ksock_conn_t *, ksock_tx_t *, int);
} ksock_proto_t;
extern ksock_proto_t ksocknal_protocol_v1x;
extern ksock_proto_t ksocknal_protocol_v2x;
extern ksock_proto_t ksocknal_protocol_v3x;
-#define KSOCK_PROTO_V1_MAJOR LNET_PROTO_TCP_VERSION_MAJOR
-#define KSOCK_PROTO_V1_MINOR LNET_PROTO_TCP_VERSION_MINOR
-#define KSOCK_PROTO_V1 KSOCK_PROTO_V1_MAJOR
+#define KSOCK_PROTO_V1_MAJOR LNET_PROTO_TCP_VERSION_MAJOR
+#define KSOCK_PROTO_V1_MINOR LNET_PROTO_TCP_VERSION_MINOR
+#define KSOCK_PROTO_V1 KSOCK_PROTO_V1_MAJOR
#ifndef CPU_MASK_NONE
#define CPU_MASK_NONE 0UL
@@ -434,7 +500,7 @@ ksocknal_conn_decref(ksock_conn_t *conn)
static inline int
ksocknal_connsock_addref(ksock_conn_t *conn)
{
- int rc = -ESHUTDOWN;
+ int rc = -ESHUTDOWN;
read_lock(&ksocknal_data.ksnd_global_lock);
if (!conn->ksnc_closing) {
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index fa7ad883bda933..a1a4ac027fb578 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -75,13 +75,13 @@ ksocknal_alloc_tx_noop(__u64 cookie, int nonblk)
return NULL;
}
- tx->tx_conn = NULL;
- tx->tx_lnetmsg = NULL;
- tx->tx_kiov = NULL;
- tx->tx_nkiov = 0;
- tx->tx_iov = tx->tx_frags.virt.iov;
- tx->tx_niov = 1;
- tx->tx_nonblk = nonblk;
+ tx->tx_conn = NULL;
+ tx->tx_lnetmsg = NULL;
+ tx->tx_kiov = NULL;
+ tx->tx_nkiov = 0;
+ tx->tx_iov = tx->tx_frags.virt.iov;
+ tx->tx_niov = 1;
+ tx->tx_nonblk = nonblk;
socklnd_init_msg(&tx->tx_msg, KSOCK_MSG_NOOP);
tx->tx_msg.ksm_zc_cookies[1] = cookie;
@@ -110,11 +110,11 @@ ksocknal_free_tx (ksock_tx_t *tx)
static int
ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
{
- struct kvec *iov = tx->tx_iov;
- int nob;
- int rc;
+ struct kvec *iov = tx->tx_iov;
+ int nob;
+ int rc;
- LASSERT (tx->tx_niov > 0);
+ LASSERT(tx->tx_niov > 0);
/* Never touch tx->tx_iov inside ksocknal_lib_send_iov() */
rc = ksocknal_lib_send_iov(conn, tx);
@@ -128,7 +128,7 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
/* "consume" iov */
do {
- LASSERT (tx->tx_niov > 0);
+ LASSERT(tx->tx_niov > 0);
if (nob < (int) iov->iov_len) {
iov->iov_base = (void *)((char *)iov->iov_base + nob);
@@ -147,12 +147,12 @@ ksocknal_send_iov (ksock_conn_t *conn, ksock_tx_t *tx)
static int
ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
{
- lnet_kiov_t *kiov = tx->tx_kiov;
- int nob;
- int rc;
+ lnet_kiov_t *kiov = tx->tx_kiov;
+ int nob;
+ int rc;
- LASSERT (tx->tx_niov == 0);
- LASSERT (tx->tx_nkiov > 0);
+ LASSERT(tx->tx_niov == 0);
+ LASSERT(tx->tx_nkiov > 0);
/* Never touch tx->tx_kiov inside ksocknal_lib_send_kiov() */
rc = ksocknal_lib_send_kiov(conn, tx);
@@ -185,15 +185,15 @@ ksocknal_send_kiov (ksock_conn_t *conn, ksock_tx_t *tx)
static int
ksocknal_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
{
- int rc;
- int bufnob;
+ int rc;
+ int bufnob;
if (ksocknal_data.ksnd_stall_tx != 0) {
set_current_state(TASK_UNINTERRUPTIBLE);
schedule_timeout(cfs_time_seconds(ksocknal_data.ksnd_stall_tx));
}
- LASSERT (tx->tx_resid != 0);
+ LASSERT(tx->tx_resid != 0);
rc = ksocknal_connsock_addref(conn);
if (rc != 0) {
@@ -252,10 +252,10 @@ static int
ksocknal_recv_iov (ksock_conn_t *conn)
{
struct kvec *iov = conn->ksnc_rx_iov;
- int nob;
- int rc;
+ int nob;
+ int rc;
- LASSERT (conn->ksnc_rx_niov > 0);
+ LASSERT(conn->ksnc_rx_niov > 0);
/* Never touch conn->ksnc_rx_iov or change connection
* status inside ksocknal_lib_recv_iov */
@@ -277,7 +277,7 @@ ksocknal_recv_iov (ksock_conn_t *conn)
conn->ksnc_rx_nob_left -= nob;
do {
- LASSERT (conn->ksnc_rx_niov > 0);
+ LASSERT(conn->ksnc_rx_niov > 0);
if (nob < (int)iov->iov_len) {
iov->iov_len -= nob;
@@ -296,10 +296,10 @@ ksocknal_recv_iov (ksock_conn_t *conn)
static int
ksocknal_recv_kiov (ksock_conn_t *conn)
{
- lnet_kiov_t *kiov = conn->ksnc_rx_kiov;
- int nob;
- int rc;
- LASSERT (conn->ksnc_rx_nkiov > 0);
+ lnet_kiov_t *kiov = conn->ksnc_rx_kiov;
+ int nob;
+ int rc;
+ LASSERT(conn->ksnc_rx_nkiov > 0);
/* Never touch conn->ksnc_rx_kiov or change connection
* status inside ksocknal_lib_recv_iov */
@@ -321,7 +321,7 @@ ksocknal_recv_kiov (ksock_conn_t *conn)
conn->ksnc_rx_nob_left -= nob;
do {
- LASSERT (conn->ksnc_rx_nkiov > 0);
+ LASSERT(conn->ksnc_rx_nkiov > 0);
if (nob < (int) kiov->kiov_len) {
kiov->kiov_offset += nob;
@@ -343,7 +343,7 @@ ksocknal_receive (ksock_conn_t *conn)
/* Return 1 on success, 0 on EOF, < 0 on error.
* Caller checks ksnc_rx_nob_wanted to determine
* progress/completion. */
- int rc;
+ int rc;
if (ksocknal_data.ksnd_stall_rx != 0) {
set_current_state(TASK_UNINTERRUPTIBLE);
@@ -388,8 +388,8 @@ ksocknal_receive (ksock_conn_t *conn)
void
ksocknal_tx_done (lnet_ni_t *ni, ksock_tx_t *tx)
{
- lnet_msg_t *lnetmsg = tx->tx_lnetmsg;
- int rc = (tx->tx_resid == 0 && !tx->tx_zc_aborted) ? 0 : -EIO;
+ lnet_msg_t *lnetmsg = tx->tx_lnetmsg;
+ int rc = (tx->tx_resid == 0 && !tx->tx_zc_aborted) ? 0 : -EIO;
LASSERT(ni != NULL || tx->tx_conn != NULL);
@@ -410,7 +410,7 @@ ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int error)
ksock_tx_t *tx;
while (!list_empty (txlist)) {
- tx = list_entry (txlist->next, ksock_tx_t, tx_list);
+ tx = list_entry(txlist->next, ksock_tx_t, tx_list);
if (error && tx->tx_lnetmsg != NULL) {
CNETERR("Deleting packet type %d len %d %s->%s\n",
@@ -422,18 +422,18 @@ ksocknal_txlist_done (lnet_ni_t *ni, struct list_head *txlist, int error)
CNETERR("Deleting noop packet\n");
}
- list_del (&tx->tx_list);
+ list_del(&tx->tx_list);
- LASSERT (atomic_read(&tx->tx_refcount) == 1);
- ksocknal_tx_done (ni, tx);
+ LASSERT(atomic_read(&tx->tx_refcount) == 1);
+ ksocknal_tx_done(ni, tx);
}
}
static void
ksocknal_check_zc_req(ksock_tx_t *tx)
{
- ksock_conn_t *conn = tx->tx_conn;
- ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_conn_t *conn = tx->tx_conn;
+ ksock_peer_t *peer = conn->ksnc_peer;
/* Set tx_msg.ksm_zc_cookies[0] to a unique non-zero cookie and add tx
* to ksnp_zc_req_list if some fragment of this message should be sent
@@ -441,8 +441,8 @@ ksocknal_check_zc_req(ksock_tx_t *tx)
* she has received this message to tell us we can signal completion.
* tx_msg.ksm_zc_cookies[0] remains non-zero while tx is on
* ksnp_zc_req_list. */
- LASSERT (tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
- LASSERT (tx->tx_zc_capable);
+ LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
+ LASSERT(tx->tx_zc_capable);
tx->tx_zc_checked = 1;
@@ -461,7 +461,7 @@ ksocknal_check_zc_req(ksock_tx_t *tx)
tx->tx_deadline =
cfs_time_shift(*ksocknal_tunables.ksnd_timeout);
- LASSERT (tx->tx_msg.ksm_zc_cookies[0] == 0);
+ LASSERT(tx->tx_msg.ksm_zc_cookies[0] == 0);
tx->tx_msg.ksm_zc_cookies[0] = peer->ksnp_zc_next_cookie++;
@@ -476,7 +476,7 @@ ksocknal_check_zc_req(ksock_tx_t *tx)
static void
ksocknal_uncheck_zc_req(ksock_tx_t *tx)
{
- ksock_peer_t *peer = tx->tx_conn->ksnc_peer;
+ ksock_peer_t *peer = tx->tx_conn->ksnc_peer;
LASSERT(tx->tx_msg.ksm_type != KSOCK_MSG_NOOP);
LASSERT(tx->tx_zc_capable);
@@ -502,14 +502,14 @@ ksocknal_uncheck_zc_req(ksock_tx_t *tx)
static int
ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
{
- int rc;
+ int rc;
if (tx->tx_zc_capable && !tx->tx_zc_checked)
ksocknal_check_zc_req(tx);
rc = ksocknal_transmit (conn, tx);
- CDEBUG (D_NET, "send(%d) %d\n", tx->tx_resid, rc);
+ CDEBUG(D_NET, "send(%d) %d\n", tx->tx_resid, rc);
if (tx->tx_resid == 0) {
/* Sent everything OK */
@@ -546,7 +546,7 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
}
/* Actual error */
- LASSERT (rc < 0);
+ LASSERT(rc < 0);
if (!conn->ksnc_closing) {
switch (rc) {
@@ -582,9 +582,9 @@ ksocknal_launch_connection_locked (ksock_route_t *route)
/* called holding write lock on ksnd_global_lock */
- LASSERT (!route->ksnr_scheduled);
- LASSERT (!route->ksnr_connecting);
- LASSERT ((ksocknal_route_mask() & ~route->ksnr_connected) != 0);
+ LASSERT(!route->ksnr_scheduled);
+ LASSERT(!route->ksnr_connecting);
+ LASSERT((ksocknal_route_mask() & ~route->ksnr_connected) != 0);
route->ksnr_scheduled = 1; /* scheduling conn for connd */
ksocknal_route_addref(route); /* extra ref for connd */
@@ -617,22 +617,22 @@ ksocknal_launch_all_connections_locked (ksock_peer_t *peer)
ksock_conn_t *
ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk)
{
- struct list_head *tmp;
- ksock_conn_t *conn;
- ksock_conn_t *typed = NULL;
- ksock_conn_t *fallback = NULL;
- int tnob = 0;
- int fnob = 0;
+ struct list_head *tmp;
+ ksock_conn_t *conn;
+ ksock_conn_t *typed = NULL;
+ ksock_conn_t *fallback = NULL;
+ int tnob = 0;
+ int fnob = 0;
list_for_each (tmp, &peer->ksnp_conns) {
ksock_conn_t *c = list_entry(tmp, ksock_conn_t, ksnc_list);
- int nob = atomic_read(&c->ksnc_tx_nob) +
- c->ksnc_sock->sk->sk_wmem_queued;
- int rc;
+ int nob = atomic_read(&c->ksnc_tx_nob) +
+ c->ksnc_sock->sk->sk_wmem_queued;
+ int rc;
- LASSERT (!c->ksnc_closing);
- LASSERT (c->ksnc_proto != NULL &&
- c->ksnc_proto->pro_match_tx != NULL);
+ LASSERT(!c->ksnc_closing);
+ LASSERT(c->ksnc_proto != NULL &&
+ c->ksnc_proto->pro_match_tx != NULL);
rc = c->ksnc_proto->pro_match_tx(c, tx, nonblk);
@@ -656,7 +656,7 @@ ksocknal_find_conn_locked(ksock_peer_t *peer, ksock_tx_t *tx, int nonblk)
(fnob == nob && *ksocknal_tunables.ksnd_round_robin &&
cfs_time_after(fallback->ksnc_tx_last_post, c->ksnc_tx_last_post))) {
fallback = c;
- fnob = nob;
+ fnob = nob;
}
break;
}
@@ -685,9 +685,9 @@ void
ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
{
ksock_sched_t *sched = conn->ksnc_scheduler;
- ksock_msg_t *msg = &tx->tx_msg;
- ksock_tx_t *ztx = NULL;
- int bufnob = 0;
+ ksock_msg_t *msg = &tx->tx_msg;
+ ksock_tx_t *ztx = NULL;
+ int bufnob = 0;
/* called holding global lock (read or irq-write) and caller may
* not have dropped this lock between finding conn and calling me,
@@ -708,11 +708,11 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
*
* We always expect at least 1 mapped fragment containing the
* complete ksocknal message header. */
- LASSERT (lnet_iov_nob (tx->tx_niov, tx->tx_iov) +
- lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) ==
- (unsigned int)tx->tx_nob);
- LASSERT (tx->tx_niov >= 1);
- LASSERT (tx->tx_resid == tx->tx_nob);
+ LASSERT(lnet_iov_nob (tx->tx_niov, tx->tx_iov) +
+ lnet_kiov_nob(tx->tx_nkiov, tx->tx_kiov) ==
+ (unsigned int)tx->tx_nob);
+ LASSERT(tx->tx_niov >= 1);
+ LASSERT(tx->tx_resid == tx->tx_nob);
CDEBUG (D_NET, "Packet %p type %d, nob %d niov %d nkiov %d\n",
tx, (tx->tx_lnetmsg != NULL) ? tx->tx_lnetmsg->msg_hdr.type:
@@ -739,8 +739,8 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
if (msg->ksm_type == KSOCK_MSG_NOOP) {
/* The packet is noop ZC ACK, try to piggyback the ack_cookie
* on a normal packet so I don't need to send it */
- LASSERT (msg->ksm_zc_cookies[1] != 0);
- LASSERT (conn->ksnc_proto->pro_queue_tx_zcack != NULL);
+ LASSERT(msg->ksm_zc_cookies[1] != 0);
+ LASSERT(conn->ksnc_proto->pro_queue_tx_zcack != NULL);
if (conn->ksnc_proto->pro_queue_tx_zcack(conn, tx, 0))
ztx = tx; /* ZC ACK piggybacked on ztx release tx later */
@@ -748,8 +748,8 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
} else {
/* It's a normal packet - can it piggback a noop zc-ack that
* has been queued already? */
- LASSERT (msg->ksm_zc_cookies[1] == 0);
- LASSERT (conn->ksnc_proto->pro_queue_tx_msg != NULL);
+ LASSERT(msg->ksm_zc_cookies[1] == 0);
+ LASSERT(conn->ksnc_proto->pro_queue_tx_msg != NULL);
ztx = conn->ksnc_proto->pro_queue_tx_msg(conn, tx);
/* ztx will be released later */
@@ -777,14 +777,14 @@ ksocknal_queue_tx_locked (ksock_tx_t *tx, ksock_conn_t *conn)
ksock_route_t *
ksocknal_find_connectable_route_locked (ksock_peer_t *peer)
{
- unsigned long now = cfs_time_current();
- struct list_head *tmp;
+ unsigned long now = cfs_time_current();
+ struct list_head *tmp;
ksock_route_t *route;
list_for_each (tmp, &peer->ksnp_routes) {
route = list_entry (tmp, ksock_route_t, ksnr_list);
- LASSERT (!route->ksnr_connecting || route->ksnr_scheduled);
+ LASSERT(!route->ksnr_connecting || route->ksnr_scheduled);
if (route->ksnr_scheduled) /* connections being established */
continue;
@@ -813,13 +813,13 @@ ksocknal_find_connectable_route_locked (ksock_peer_t *peer)
ksock_route_t *
ksocknal_find_connecting_route_locked (ksock_peer_t *peer)
{
- struct list_head *tmp;
- ksock_route_t *route;
+ struct list_head *tmp;
+ ksock_route_t *route;
list_for_each (tmp, &peer->ksnp_routes) {
route = list_entry (tmp, ksock_route_t, ksnr_list);
- LASSERT (!route->ksnr_connecting || route->ksnr_scheduled);
+ LASSERT(!route->ksnr_connecting || route->ksnr_scheduled);
if (route->ksnr_scheduled)
return route;
@@ -831,13 +831,13 @@ ksocknal_find_connecting_route_locked (ksock_peer_t *peer)
int
ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id)
{
- ksock_peer_t *peer;
- ksock_conn_t *conn;
- rwlock_t *g_lock;
- int retry;
- int rc;
+ ksock_peer_t *peer;
+ ksock_conn_t *conn;
+ rwlock_t *g_lock;
+ int retry;
+ int rc;
- LASSERT (tx->tx_conn == NULL);
+ LASSERT(tx->tx_conn == NULL);
g_lock = &ksocknal_data.ksnd_global_lock;
@@ -922,17 +922,17 @@ ksocknal_launch_packet (lnet_ni_t *ni, ksock_tx_t *tx, lnet_process_id_t id)
int
ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
{
- int mpflag = 1;
- int type = lntmsg->msg_type;
+ int mpflag = 1;
+ int type = lntmsg->msg_type;
lnet_process_id_t target = lntmsg->msg_target;
- unsigned int payload_niov = lntmsg->msg_niov;
- struct kvec *payload_iov = lntmsg->msg_iov;
- lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
- unsigned int payload_offset = lntmsg->msg_offset;
- unsigned int payload_nob = lntmsg->msg_len;
- ksock_tx_t *tx;
- int desc_size;
- int rc;
+ unsigned int payload_niov = lntmsg->msg_niov;
+ struct kvec *payload_iov = lntmsg->msg_iov;
+ lnet_kiov_t *payload_kiov = lntmsg->msg_kiov;
+ unsigned int payload_offset = lntmsg->msg_offset;
+ unsigned int payload_nob = lntmsg->msg_len;
+ ksock_tx_t *tx;
+ int desc_size;
+ int rc;
/* NB 'private' is different depending on what we're sending.
* Just ignore it... */
@@ -940,8 +940,8 @@ ksocknal_send(lnet_ni_t *ni, void *private, lnet_msg_t *lntmsg)
CDEBUG(D_NET, "sending %u bytes in %d frags to %s\n",
payload_nob, payload_niov, libcfs_id2str(target));
- LASSERT (payload_nob == 0 || payload_niov > 0);
- LASSERT (payload_niov <= LNET_MAX_IOV);
+ LASSERT(payload_nob == 0 || payload_niov > 0);
+ LASSERT(payload_niov <= LNET_MAX_IOV);
/* payload is either all vaddrs or all pages */
LASSERT (!(payload_kiov != NULL && payload_iov != NULL));
LASSERT (!in_interrupt ());
@@ -1028,9 +1028,9 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
{
static char ksocknal_slop_buffer[4096];
- int nob;
- unsigned int niov;
- int skipped;
+ int nob;
+ unsigned int niov;
+ int skipped;
LASSERT(conn->ksnc_proto != NULL);
@@ -1063,7 +1063,7 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
conn->ksnc_rx_iov = (struct kvec *)&conn->ksnc_rx_iov_space;
conn->ksnc_rx_iov[0].iov_base = &conn->ksnc_msg.ksm_u.lnetmsg;
- conn->ksnc_rx_iov[0].iov_len = sizeof (lnet_hdr_t);
+ conn->ksnc_rx_iov[0].iov_len = sizeof (lnet_hdr_t);
break;
default:
@@ -1108,18 +1108,18 @@ ksocknal_new_packet (ksock_conn_t *conn, int nob_to_skip)
static int
ksocknal_process_receive (ksock_conn_t *conn)
{
- lnet_hdr_t *lhdr;
+ lnet_hdr_t *lhdr;
lnet_process_id_t *id;
- int rc;
+ int rc;
LASSERT (atomic_read(&conn->ksnc_conn_refcount) > 0);
/* NB: sched lock NOT held */
/* SOCKNAL_RX_LNET_HEADER is here for backward compatibility */
- LASSERT (conn->ksnc_rx_state == SOCKNAL_RX_KSM_HEADER ||
- conn->ksnc_rx_state == SOCKNAL_RX_LNET_PAYLOAD ||
- conn->ksnc_rx_state == SOCKNAL_RX_LNET_HEADER ||
- conn->ksnc_rx_state == SOCKNAL_RX_SLOP);
+ LASSERT(conn->ksnc_rx_state == SOCKNAL_RX_KSM_HEADER ||
+ conn->ksnc_rx_state == SOCKNAL_RX_LNET_PAYLOAD ||
+ conn->ksnc_rx_state == SOCKNAL_RX_LNET_HEADER ||
+ conn->ksnc_rx_state == SOCKNAL_RX_SLOP);
again:
if (conn->ksnc_rx_nob_wanted != 0) {
rc = ksocknal_receive(conn);
@@ -1229,7 +1229,7 @@ ksocknal_process_receive (ksock_conn_t *conn)
if ((conn->ksnc_peer->ksnp_id.pid & LNET_PID_USERFLAG) != 0) {
/* Userspace peer */
lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
- id = &conn->ksnc_peer->ksnp_id;
+ id = &conn->ksnc_peer->ksnp_id;
/* Substitute process ID assigned at connection time */
lhdr->src_pid = cpu_to_le32(id->pid);
@@ -1277,7 +1277,7 @@ ksocknal_process_receive (ksock_conn_t *conn)
LASSERT(conn->ksnc_proto != &ksocknal_protocol_v1x);
lhdr = &conn->ksnc_msg.ksm_u.lnetmsg.ksnm_hdr;
- id = &conn->ksnc_peer->ksnp_id;
+ id = &conn->ksnc_peer->ksnp_id;
rc = conn->ksnc_proto->pro_handle_zcreq(conn,
conn->ksnc_msg.ksm_zc_cookies[0],
@@ -1305,7 +1305,7 @@ ksocknal_process_receive (ksock_conn_t *conn)
}
/* Not Reached */
- LBUG ();
+ LBUG();
return -EINVAL; /* keep gcc happy */
}
@@ -1314,15 +1314,15 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
unsigned int niov, struct kvec *iov, lnet_kiov_t *kiov,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
- ksock_conn_t *conn = (ksock_conn_t *)private;
+ ksock_conn_t *conn = (ksock_conn_t *)private;
ksock_sched_t *sched = conn->ksnc_scheduler;
- LASSERT (mlen <= rlen);
- LASSERT (niov <= LNET_MAX_IOV);
+ LASSERT(mlen <= rlen);
+ LASSERT(niov <= LNET_MAX_IOV);
conn->ksnc_cookie = msg;
conn->ksnc_rx_nob_wanted = mlen;
- conn->ksnc_rx_nob_left = rlen;
+ conn->ksnc_rx_nob_left = rlen;
if (mlen == 0 || iov != NULL) {
conn->ksnc_rx_nkiov = 0;
@@ -1333,18 +1333,18 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
niov, iov, offset, mlen);
} else {
conn->ksnc_rx_niov = 0;
- conn->ksnc_rx_iov = NULL;
+ conn->ksnc_rx_iov = NULL;
conn->ksnc_rx_kiov = conn->ksnc_rx_iov_space.kiov;
conn->ksnc_rx_nkiov =
lnet_extract_kiov(LNET_MAX_IOV, conn->ksnc_rx_kiov,
niov, kiov, offset, mlen);
}
- LASSERT (mlen ==
- lnet_iov_nob (conn->ksnc_rx_niov, conn->ksnc_rx_iov) +
- lnet_kiov_nob (conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov));
+ LASSERT(mlen ==
+ lnet_iov_nob(conn->ksnc_rx_niov, conn->ksnc_rx_iov) +
+ lnet_kiov_nob(conn->ksnc_rx_nkiov, conn->ksnc_rx_kiov));
- LASSERT (conn->ksnc_rx_scheduled);
+ LASSERT(conn->ksnc_rx_scheduled);
spin_lock_bh(&sched->kss_lock);
@@ -1370,7 +1370,7 @@ ksocknal_recv (lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
static inline int
ksocknal_sched_cansleep(ksock_sched_t *sched)
{
- int rc;
+ int rc;
spin_lock_bh(&sched->kss_lock);
@@ -1384,13 +1384,13 @@ ksocknal_sched_cansleep(ksock_sched_t *sched)
int ksocknal_scheduler(void *arg)
{
- struct ksock_sched_info *info;
- ksock_sched_t *sched;
- ksock_conn_t *conn;
- ksock_tx_t *tx;
- int rc;
- int nloops = 0;
- long id = (long)arg;
+ struct ksock_sched_info *info;
+ ksock_sched_t *sched;
+ ksock_conn_t *conn;
+ ksock_tx_t *tx;
+ int rc;
+ int nloops = 0;
+ long id = (long)arg;
info = ksocknal_data.ksnd_sched_info[KSOCK_THREAD_CPT(id)];
sched = &info->ksi_scheds[KSOCK_THREAD_SID(id)];
@@ -1455,7 +1455,7 @@ int ksocknal_scheduler(void *arg)
}
if (!list_empty (&sched->kss_tx_conns)) {
- LIST_HEAD (zlist);
+ LIST_HEAD(zlist);
if (!list_empty(&sched->kss_zombie_noop_txs)) {
list_add(&zlist,
@@ -1513,9 +1513,9 @@ int ksocknal_scheduler(void *arg)
/* Do nothing; after a short timeout, this
* conn will be reposted on kss_tx_conns. */
} else if (conn->ksnc_tx_ready &&
- !list_empty (&conn->ksnc_tx_queue)) {
+ !list_empty(&conn->ksnc_tx_queue)) {
/* reschedule for tx */
- list_add_tail (&conn->ksnc_tx_list,
+ list_add_tail(&conn->ksnc_tx_list,
&sched->kss_tx_conns);
} else {
conn->ksnc_tx_scheduled = 0;
@@ -1606,7 +1606,7 @@ void ksocknal_write_callback (ksock_conn_t *conn)
static ksock_proto_t *
ksocknal_parse_proto_version (ksock_hello_msg_t *hello)
{
- __u32 version = 0;
+ __u32 version = 0;
if (hello->kshm_magic == LNET_PROTO_MAGIC)
version = hello->kshm_version;
@@ -1634,8 +1634,8 @@ ksocknal_parse_proto_version (ksock_hello_msg_t *hello)
if (hello->kshm_magic == le32_to_cpu(LNET_PROTO_TCP_MAGIC)) {
lnet_magicversion_t *hmv = (lnet_magicversion_t *)hello;
- CLASSERT (sizeof (lnet_magicversion_t) ==
- offsetof (ksock_hello_msg_t, kshm_src_nid));
+ CLASSERT(sizeof (lnet_magicversion_t) ==
+ offsetof (ksock_hello_msg_t, kshm_src_nid));
if (hmv->version_major == cpu_to_le16 (KSOCK_PROTO_V1_MAJOR) &&
hmv->version_minor == cpu_to_le16 (KSOCK_PROTO_V1_MINOR))
@@ -1650,19 +1650,19 @@ ksocknal_send_hello (lnet_ni_t *ni, ksock_conn_t *conn,
lnet_nid_t peer_nid, ksock_hello_msg_t *hello)
{
/* CAVEAT EMPTOR: this byte flips 'ipaddrs' */
- ksock_net_t *net = (ksock_net_t *)ni->ni_data;
+ ksock_net_t *net = (ksock_net_t *)ni->ni_data;
- LASSERT (hello->kshm_nips <= LNET_MAX_INTERFACES);
+ LASSERT(hello->kshm_nips <= LNET_MAX_INTERFACES);
/* rely on caller to hold a ref on socket so it wouldn't disappear */
- LASSERT (conn->ksnc_proto != NULL);
+ LASSERT(conn->ksnc_proto != NULL);
- hello->kshm_src_nid = ni->ni_nid;
- hello->kshm_dst_nid = peer_nid;
- hello->kshm_src_pid = the_lnet.ln_pid;
+ hello->kshm_src_nid = ni->ni_nid;
+ hello->kshm_dst_nid = peer_nid;
+ hello->kshm_src_pid = the_lnet.ln_pid;
hello->kshm_src_incarnation = net->ksnn_incarnation;
- hello->kshm_ctype = conn->ksnc_type;
+ hello->kshm_ctype = conn->ksnc_type;
return conn->ksnc_proto->pro_send_hello(conn, hello);
}
@@ -1693,16 +1693,16 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
* EALREADY lost connection race
* EPROTO protocol version mismatch
*/
- struct socket *sock = conn->ksnc_sock;
- int active = (conn->ksnc_proto != NULL);
- int timeout;
- int proto_match;
- int rc;
- ksock_proto_t *proto;
- lnet_process_id_t recv_id;
+ struct socket *sock = conn->ksnc_sock;
+ int active = (conn->ksnc_proto != NULL);
+ int timeout;
+ int proto_match;
+ int rc;
+ ksock_proto_t *proto;
+ lnet_process_id_t recv_id;
/* socket type set on active connections - not set on passive */
- LASSERT (!active == !(conn->ksnc_type != SOCKLND_CONN_NONE));
+ LASSERT(!active == !(conn->ksnc_type != SOCKLND_CONN_NONE));
timeout = active ? *ksocknal_tunables.ksnd_timeout :
lnet_acceptor_timeout();
@@ -1731,7 +1731,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
if (rc != 0) {
CERROR("Error %d reading HELLO from %pI4h\n",
rc, &conn->ksnc_ipaddr);
- LASSERT (rc < 0);
+ LASSERT(rc < 0);
return rc;
}
@@ -1765,7 +1765,7 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
if (rc != 0) {
CERROR("Error %d reading or checking hello from from %pI4h\n",
rc, &conn->ksnc_ipaddr);
- LASSERT (rc < 0);
+ LASSERT(rc < 0);
return rc;
}
@@ -1830,22 +1830,22 @@ ksocknal_recv_hello (lnet_ni_t *ni, ksock_conn_t *conn,
static int
ksocknal_connect (ksock_route_t *route)
{
- LIST_HEAD (zombies);
- ksock_peer_t *peer = route->ksnr_peer;
- int type;
- int wanted;
- struct socket *sock;
- unsigned long deadline;
- int retry_later = 0;
- int rc = 0;
+ LIST_HEAD(zombies);
+ ksock_peer_t *peer = route->ksnr_peer;
+ int type;
+ int wanted;
+ struct socket *sock;
+ unsigned long deadline;
+ int retry_later = 0;
+ int rc = 0;
deadline = cfs_time_add(cfs_time_current(),
cfs_time_seconds(*ksocknal_tunables.ksnd_timeout));
write_lock_bh(&ksocknal_data.ksnd_global_lock);
- LASSERT (route->ksnr_scheduled);
- LASSERT (!route->ksnr_connecting);
+ LASSERT(route->ksnr_scheduled);
+ LASSERT(!route->ksnr_connecting);
route->ksnr_connecting = 1;
@@ -2101,7 +2101,7 @@ static ksock_route_t *
ksocknal_connd_get_route_locked(signed long *timeout_p)
{
ksock_route_t *route;
- unsigned long now;
+ unsigned long now;
now = cfs_time_current();
@@ -2124,13 +2124,13 @@ ksocknal_connd_get_route_locked(signed long *timeout_p)
int
ksocknal_connd (void *arg)
{
- spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock;
- ksock_connreq_t *cr;
- wait_queue_t wait;
- int nloops = 0;
- int cons_retry = 0;
+ spinlock_t *connd_lock = &ksocknal_data.ksnd_connd_lock;
+ ksock_connreq_t *cr;
+ wait_queue_t wait;
+ int nloops = 0;
+ int cons_retry = 0;
- cfs_block_allsigs ();
+ cfs_block_allsigs();
init_waitqueue_entry(&wait, current);
@@ -2144,7 +2144,7 @@ ksocknal_connd (void *arg)
ksock_route_t *route = NULL;
long sec = get_seconds();
long timeout = MAX_SCHEDULE_TIMEOUT;
- int dropped_lock = 0;
+ int dropped_lock = 0;
if (ksocknal_connd_check_stop(sec, &timeout)) {
/* wakeup another one to check stop */
@@ -2236,15 +2236,15 @@ static ksock_conn_t *
ksocknal_find_timed_out_conn (ksock_peer_t *peer)
{
/* We're called with a shared lock on ksnd_global_lock */
- ksock_conn_t *conn;
- struct list_head *ctmp;
+ ksock_conn_t *conn;
+ struct list_head *ctmp;
list_for_each (ctmp, &peer->ksnp_conns) {
- int error;
+ int error;
conn = list_entry (ctmp, ksock_conn_t, ksnc_list);
/* Don't need the {get,put}connsock dance to deref ksnc_sock */
- LASSERT (!conn->ksnc_closing);
+ LASSERT(!conn->ksnc_closing);
/* SOCK_ERROR will reset error code of socket in
* some platform (like Darwin8.x) */
@@ -2313,8 +2313,8 @@ ksocknal_find_timed_out_conn (ksock_peer_t *peer)
static inline void
ksocknal_flush_stale_txs(ksock_peer_t *peer)
{
- ksock_tx_t *tx;
- LIST_HEAD (stale_txs);
+ ksock_tx_t *tx;
+ LIST_HEAD(stale_txs);
write_lock_bh(&ksocknal_data.ksnd_global_lock);
@@ -2338,9 +2338,9 @@ ksocknal_flush_stale_txs(ksock_peer_t *peer)
static int
ksocknal_send_keepalive_locked(ksock_peer_t *peer)
{
- ksock_sched_t *sched;
- ksock_conn_t *conn;
- ksock_tx_t *tx;
+ ksock_sched_t *sched;
+ ksock_conn_t *conn;
+ ksock_tx_t *tx;
if (list_empty(&peer->ksnp_conns)) /* last_alive will be updated by create_conn */
return 0;
@@ -2399,10 +2399,10 @@ ksocknal_send_keepalive_locked(ksock_peer_t *peer)
static void
ksocknal_check_peer_timeouts (int idx)
{
- struct list_head *peers = &ksocknal_data.ksnd_peers[idx];
- ksock_peer_t *peer;
- ksock_conn_t *conn;
- ksock_tx_t *tx;
+ struct list_head *peers = &ksocknal_data.ksnd_peers[idx];
+ ksock_peer_t *peer;
+ ksock_conn_t *conn;
+ ksock_tx_t *tx;
again:
/* NB. We expect to have a look at all the peers and not find any
@@ -2411,9 +2411,9 @@ ksocknal_check_peer_timeouts (int idx)
read_lock(&ksocknal_data.ksnd_global_lock);
list_for_each_entry(peer, peers, ksnp_list) {
- unsigned long deadline = 0;
- int resid = 0;
- int n = 0;
+ unsigned long deadline = 0;
+ int resid = 0;
+ int n = 0;
if (ksocknal_send_keepalive_locked(peer) != 0) {
read_unlock(&ksocknal_data.ksnd_global_lock);
@@ -2476,8 +2476,8 @@ ksocknal_check_peer_timeouts (int idx)
tx = list_entry(peer->ksnp_zc_req_list.next,
ksock_tx_t, tx_zc_list);
deadline = tx->tx_deadline;
- resid = tx->tx_resid;
- conn = tx->tx_conn;
+ resid = tx->tx_resid;
+ conn = tx->tx_conn;
ksocknal_conn_addref(conn);
spin_unlock(&peer->ksnp_lock);
@@ -2499,17 +2499,17 @@ ksocknal_check_peer_timeouts (int idx)
int
ksocknal_reaper (void *arg)
{
- wait_queue_t wait;
- ksock_conn_t *conn;
- ksock_sched_t *sched;
- struct list_head enomem_conns;
- int nenomem_conns;
- long timeout;
- int i;
- int peer_index = 0;
- unsigned long deadline = cfs_time_current();
-
- cfs_block_allsigs ();
+ wait_queue_t wait;
+ ksock_conn_t *conn;
+ ksock_sched_t *sched;
+ struct list_head enomem_conns;
+ int nenomem_conns;
+ long timeout;
+ int i;
+ int peer_index = 0;
+ unsigned long deadline = cfs_time_current();
+
+ cfs_block_allsigs();
INIT_LIST_HEAD(&enomem_conns);
init_waitqueue_entry(&wait, current);
@@ -2580,7 +2580,7 @@ ksocknal_reaper (void *arg)
cfs_time_current())) <= 0) {
const int n = 4;
const int p = 1;
- int chunk = ksocknal_data.ksnd_peer_hash_size;
+ int chunk = ksocknal_data.ksnd_peer_hash_size;
/* Time to check for timeouts on a few more peers: I do
* checks every 'p' seconds on a proportion of the peer
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
index f5e8ab06070c1a..caeb3477da9702 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_lib-linux.c
@@ -64,7 +64,7 @@ ksocknal_lib_get_conn_addrs(ksock_conn_t *conn)
int
ksocknal_lib_zc_capable(ksock_conn_t *conn)
{
- int caps = conn->ksnc_sock->sk->sk_route_caps;
+ int caps = conn->ksnc_sock->sk->sk_route_caps;
if (conn->ksnc_proto == &ksocknal_protocol_v1x)
return 0;
@@ -78,8 +78,8 @@ int
ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
{
struct socket *sock = conn->ksnc_sock;
- int nob;
- int rc;
+ int nob;
+ int rc;
if (*ksocknal_tunables.ksnd_enable_csum && /* checksum enabled */
conn->ksnc_proto == &ksocknal_protocol_v2x && /* V2.x connection */
@@ -92,15 +92,15 @@ ksocknal_lib_send_iov(ksock_conn_t *conn, ksock_tx_t *tx)
{
#if SOCKNAL_SINGLE_FRAG_TX
- struct kvec scratch;
- struct kvec *scratchiov = &scratch;
- unsigned int niov = 1;
+ struct kvec scratch;
+ struct kvec *scratchiov = &scratch;
+ unsigned int niov = 1;
#else
- struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- unsigned int niov = tx->tx_niov;
+ struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
+ unsigned int niov = tx->tx_niov;
#endif
struct msghdr msg = {.msg_flags = MSG_DONTWAIT};
- int i;
+ int i;
for (nob = i = 0; i < niov; i++) {
scratchiov[i] = tx->tx_iov[i];
@@ -120,9 +120,9 @@ int
ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
{
struct socket *sock = conn->ksnc_sock;
- lnet_kiov_t *kiov = tx->tx_kiov;
- int rc;
- int nob;
+ lnet_kiov_t *kiov = tx->tx_kiov;
+ int rc;
+ int nob;
/* Not NOOP message */
LASSERT(tx->tx_lnetmsg != NULL);
@@ -131,11 +131,11 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
* or leave them alone. */
if (tx->tx_msg.ksm_zc_cookies[0] != 0) {
/* Zero copy is enabled */
- struct sock *sk = sock->sk;
- struct page *page = kiov->kiov_page;
- int offset = kiov->kiov_offset;
- int fragsize = kiov->kiov_len;
- int msgflg = MSG_DONTWAIT;
+ struct sock *sk = sock->sk;
+ struct page *page = kiov->kiov_page;
+ int offset = kiov->kiov_offset;
+ int fragsize = kiov->kiov_len;
+ int msgflg = MSG_DONTWAIT;
CDEBUG(D_NET, "page %p + offset %x for %d\n",
page, offset, kiov->kiov_len);
@@ -153,18 +153,18 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
}
} else {
#if SOCKNAL_SINGLE_FRAG_TX || !SOCKNAL_RISK_KMAP_DEADLOCK
- struct kvec scratch;
+ struct kvec scratch;
struct kvec *scratchiov = &scratch;
- unsigned int niov = 1;
+ unsigned int niov = 1;
#else
#ifdef CONFIG_HIGHMEM
#warning "XXX risk of kmap deadlock on multiple frags..."
#endif
struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- unsigned int niov = tx->tx_nkiov;
+ unsigned int niov = tx->tx_nkiov;
#endif
struct msghdr msg = {.msg_flags = MSG_DONTWAIT};
- int i;
+ int i;
for (nob = i = 0; i < niov; i++) {
scratchiov[i].iov_base = kmap(kiov[i].kiov_page) +
@@ -187,7 +187,7 @@ ksocknal_lib_send_kiov(ksock_conn_t *conn, ksock_tx_t *tx)
void
ksocknal_lib_eager_ack(ksock_conn_t *conn)
{
- int opt = 1;
+ int opt = 1;
struct socket *sock = conn->ksnc_sock;
/* Remind the socket to ACK eagerly. If I don't, the socket might
@@ -203,23 +203,23 @@ int
ksocknal_lib_recv_iov(ksock_conn_t *conn)
{
#if SOCKNAL_SINGLE_FRAG_RX
- struct kvec scratch;
+ struct kvec scratch;
struct kvec *scratchiov = &scratch;
- unsigned int niov = 1;
+ unsigned int niov = 1;
#else
struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- unsigned int niov = conn->ksnc_rx_niov;
+ unsigned int niov = conn->ksnc_rx_niov;
#endif
struct kvec *iov = conn->ksnc_rx_iov;
struct msghdr msg = {
- .msg_flags = 0
+ .msg_flags = 0
};
- int nob;
- int i;
- int rc;
- int fragnob;
- int sum;
- __u32 saved_csum;
+ int nob;
+ int i;
+ int rc;
+ int fragnob;
+ int sum;
+ __u32 saved_csum;
/* NB we can't trust socket ops to either consume our iovs
* or leave them alone. */
@@ -271,9 +271,9 @@ static void *
ksocknal_lib_kiov_vmap(lnet_kiov_t *kiov, int niov,
struct kvec *iov, struct page **pages)
{
- void *addr;
- int nob;
- int i;
+ void *addr;
+ int nob;
+ int i;
if (!*ksocknal_tunables.ksnd_zc_recv || pages == NULL)
return NULL;
@@ -307,29 +307,29 @@ int
ksocknal_lib_recv_kiov(ksock_conn_t *conn)
{
#if SOCKNAL_SINGLE_FRAG_RX || !SOCKNAL_RISK_KMAP_DEADLOCK
- struct kvec scratch;
- struct kvec *scratchiov = &scratch;
- struct page **pages = NULL;
- unsigned int niov = 1;
+ struct kvec scratch;
+ struct kvec *scratchiov = &scratch;
+ struct page **pages = NULL;
+ unsigned int niov = 1;
#else
#ifdef CONFIG_HIGHMEM
#warning "XXX risk of kmap deadlock on multiple frags..."
#endif
- struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
- struct page **pages = conn->ksnc_scheduler->kss_rx_scratch_pgs;
- unsigned int niov = conn->ksnc_rx_nkiov;
+ struct kvec *scratchiov = conn->ksnc_scheduler->kss_scratch_iov;
+ struct page **pages = conn->ksnc_scheduler->kss_rx_scratch_pgs;
+ unsigned int niov = conn->ksnc_rx_nkiov;
#endif
lnet_kiov_t *kiov = conn->ksnc_rx_kiov;
struct msghdr msg = {
- .msg_flags = 0
+ .msg_flags = 0
};
- int nob;
- int i;
- int rc;
- void *base;
- void *addr;
- int sum;
- int fragnob;
+ int nob;
+ int i;
+ int rc;
+ void *base;
+ void *addr;
+ int sum;
+ int fragnob;
int n;
/* NB we can't trust socket ops to either consume our iovs
@@ -357,10 +357,10 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn)
for (i = 0, sum = rc; sum > 0; i++, sum -= fragnob) {
LASSERT(i < niov);
- /* Dang! have to kmap again because I have nowhere to stash the
- * mapped address. But by doing it while the page is still
- * mapped, the kernel just bumps the map count and returns me
- * the address it stashed. */
+ /* Dang! have to kmap again because I have nowhere to
+ * stash the mapped address. But by doing it while the
+ * page is still mapped, the kernel just bumps the map
+ * count and returns me the address it stashed. */
base = kmap(kiov[i].kiov_page) + kiov[i].kiov_offset;
fragnob = kiov[i].kiov_len;
if (fragnob > sum)
@@ -386,9 +386,9 @@ ksocknal_lib_recv_kiov(ksock_conn_t *conn)
void
ksocknal_lib_csum_tx(ksock_tx_t *tx)
{
- int i;
- __u32 csum;
- void *base;
+ int i;
+ __u32 csum;
+ void *base;
LASSERT(tx->tx_iov[0].iov_base == &tx->tx_msg);
LASSERT(tx->tx_conn != NULL);
@@ -426,8 +426,8 @@ int
ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *nagle)
{
struct socket *sock = conn->ksnc_sock;
- int len;
- int rc;
+ int len;
+ int rc;
rc = ksocknal_connsock_addref(conn);
if (rc != 0) {
@@ -456,13 +456,13 @@ ksocknal_lib_get_conn_tunables(ksock_conn_t *conn, int *txmem, int *rxmem, int *
int
ksocknal_lib_setup_sock(struct socket *sock)
{
- int rc;
- int option;
- int keep_idle;
- int keep_intvl;
- int keep_count;
- int do_keepalive;
- struct linger linger;
+ int rc;
+ int option;
+ int keep_idle;
+ int keep_intvl;
+ int keep_count;
+ int do_keepalive;
+ struct linger linger;
sock->sk->sk_allocation = GFP_NOFS;
@@ -555,11 +555,11 @@ ksocknal_lib_setup_sock(struct socket *sock)
void
ksocknal_lib_push_conn(ksock_conn_t *conn)
{
- struct sock *sk;
+ struct sock *sk;
struct tcp_sock *tp;
- int nonagle;
- int val = 1;
- int rc;
+ int nonagle;
+ int val = 1;
+ int rc;
rc = ksocknal_connsock_addref(conn);
if (rc != 0) /* being shut down */
@@ -592,7 +592,7 @@ extern void ksocknal_write_callback(ksock_conn_t *conn);
static void
ksocknal_data_ready(struct sock *sk)
{
- ksock_conn_t *conn;
+ ksock_conn_t *conn;
/* interleave correctly with closing sockets... */
LASSERT(!in_irq());
@@ -611,9 +611,9 @@ ksocknal_data_ready(struct sock *sk)
static void
ksocknal_write_space(struct sock *sk)
{
- ksock_conn_t *conn;
- int wspace;
- int min_wpace;
+ ksock_conn_t *conn;
+ int wspace;
+ int min_wpace;
/* interleave correctly with closing sockets... */
LASSERT(!in_irq());
@@ -689,7 +689,7 @@ ksocknal_lib_reset_callback(struct socket *sock, ksock_conn_t *conn)
int
ksocknal_lib_memory_pressure(ksock_conn_t *conn)
{
- int rc = 0;
+ int rc = 0;
ksock_sched_t *sched;
sched = conn->ksnc_scheduler;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
index 86b88db1cf2086..c3ac6769812535 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_modparams.c
@@ -145,40 +145,37 @@ ksock_tunables_t ksocknal_tunables;
int ksocknal_tunables_init(void)
{
-
/* initialize ksocknal_tunables structure */
- ksocknal_tunables.ksnd_timeout = &sock_timeout;
- ksocknal_tunables.ksnd_nscheds = &nscheds;
- ksocknal_tunables.ksnd_nconnds = &nconnds;
- ksocknal_tunables.ksnd_nconnds_max = &nconnds_max;
+ ksocknal_tunables.ksnd_timeout = &sock_timeout;
+ ksocknal_tunables.ksnd_nscheds = &nscheds;
+ ksocknal_tunables.ksnd_nconnds = &nconnds;
+ ksocknal_tunables.ksnd_nconnds_max = &nconnds_max;
ksocknal_tunables.ksnd_min_reconnectms = &min_reconnectms;
ksocknal_tunables.ksnd_max_reconnectms = &max_reconnectms;
- ksocknal_tunables.ksnd_eager_ack = &eager_ack;
- ksocknal_tunables.ksnd_typed_conns = &typed_conns;
- ksocknal_tunables.ksnd_min_bulk = &min_bulk;
+ ksocknal_tunables.ksnd_eager_ack = &eager_ack;
+ ksocknal_tunables.ksnd_typed_conns = &typed_conns;
+ ksocknal_tunables.ksnd_min_bulk = &min_bulk;
ksocknal_tunables.ksnd_tx_buffer_size = &tx_buffer_size;
ksocknal_tunables.ksnd_rx_buffer_size = &rx_buffer_size;
- ksocknal_tunables.ksnd_nagle = &nagle;
- ksocknal_tunables.ksnd_round_robin = &round_robin;
- ksocknal_tunables.ksnd_keepalive = &keepalive;
+ ksocknal_tunables.ksnd_nagle = &nagle;
+ ksocknal_tunables.ksnd_round_robin = &round_robin;
+ ksocknal_tunables.ksnd_keepalive = &keepalive;
ksocknal_tunables.ksnd_keepalive_idle = &keepalive_idle;
ksocknal_tunables.ksnd_keepalive_count = &keepalive_count;
ksocknal_tunables.ksnd_keepalive_intvl = &keepalive_intvl;
- ksocknal_tunables.ksnd_credits = &credits;
+ ksocknal_tunables.ksnd_credits = &credits;
ksocknal_tunables.ksnd_peertxcredits = &peer_credits;
ksocknal_tunables.ksnd_peerrtrcredits = &peer_buffer_credits;
- ksocknal_tunables.ksnd_peertimeout = &peer_timeout;
- ksocknal_tunables.ksnd_enable_csum = &enable_csum;
+ ksocknal_tunables.ksnd_peertimeout = &peer_timeout;
+ ksocknal_tunables.ksnd_enable_csum = &enable_csum;
ksocknal_tunables.ksnd_inject_csum_error = &inject_csum_error;
ksocknal_tunables.ksnd_nonblk_zcack = &nonblk_zcack;
ksocknal_tunables.ksnd_zc_min_payload = &zc_min_payload;
- ksocknal_tunables.ksnd_zc_recv = &zc_recv;
+ ksocknal_tunables.ksnd_zc_recv = &zc_recv;
ksocknal_tunables.ksnd_zc_recv_min_nfrags = &zc_recv_min_nfrags;
-
-
#if SOCKNAL_VERSION_DEBUG
- ksocknal_tunables.ksnd_protocol = &protocol;
+ ksocknal_tunables.ksnd_protocol = &protocol;
#endif
if (*ksocknal_tunables.ksnd_zc_min_payload < (2 << 10))
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
index 8596581f54ff60..1938d6a9b3a4de 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_proto.c
@@ -52,7 +52,7 @@ ksocknal_queue_tx_msg_v1(ksock_conn_t *conn, ksock_tx_t *tx_msg)
void
ksocknal_next_tx_carrier(ksock_conn_t *conn)
{
- ksock_tx_t *tx = conn->ksnc_tx_carrier;
+ ksock_tx_t *tx = conn->ksnc_tx_carrier;
/* Called holding BH lock: conn->ksnc_scheduler->kss_lock */
LASSERT(!list_empty(&conn->ksnc_tx_queue));
@@ -119,7 +119,7 @@ ksocknal_queue_tx_zcack_v2(ksock_conn_t *conn,
static ksock_tx_t *
ksocknal_queue_tx_msg_v2(ksock_conn_t *conn, ksock_tx_t *tx_msg)
{
- ksock_tx_t *tx = conn->ksnc_tx_carrier;
+ ksock_tx_t *tx = conn->ksnc_tx_carrier;
/*
* Enqueue tx_msg:
@@ -361,10 +361,10 @@ ksocknal_match_tx_v3(ksock_conn_t *conn, ksock_tx_t *tx, int nonblk)
static int
ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote)
{
- ksock_peer_t *peer = c->ksnc_peer;
- ksock_conn_t *conn;
- ksock_tx_t *tx;
- int rc;
+ ksock_peer_t *peer = c->ksnc_peer;
+ ksock_conn_t *conn;
+ ksock_tx_t *tx;
+ int rc;
read_lock(&ksocknal_data.ksnd_global_lock);
@@ -405,11 +405,11 @@ ksocknal_handle_zcreq(ksock_conn_t *c, __u64 cookie, int remote)
static int
ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2)
{
- ksock_peer_t *peer = conn->ksnc_peer;
- ksock_tx_t *tx;
- ksock_tx_t *tmp;
+ ksock_peer_t *peer = conn->ksnc_peer;
+ ksock_tx_t *tx;
+ ksock_tx_t *tmp;
LIST_HEAD(zlist);
- int count;
+ int count;
if (cookie1 == 0)
cookie1 = cookie2;
@@ -452,11 +452,11 @@ ksocknal_handle_zcack(ksock_conn_t *conn, __u64 cookie1, __u64 cookie2)
static int
ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
{
- struct socket *sock = conn->ksnc_sock;
- lnet_hdr_t *hdr;
+ struct socket *sock = conn->ksnc_sock;
+ lnet_hdr_t *hdr;
lnet_magicversion_t *hmv;
- int rc;
- int i;
+ int rc;
+ int i;
CLASSERT(sizeof(lnet_magicversion_t) == offsetof(lnet_hdr_t, src_nid));
@@ -470,7 +470,7 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
/* Re-organize V2.x message header to V1.x (lnet_hdr_t)
* header and send out */
- hmv->magic = cpu_to_le32 (LNET_PROTO_TCP_MAGIC);
+ hmv->magic = cpu_to_le32 (LNET_PROTO_TCP_MAGIC);
hmv->version_major = cpu_to_le16 (KSOCK_PROTO_V1_MAJOR);
hmv->version_minor = cpu_to_le16 (KSOCK_PROTO_V1_MINOR);
@@ -488,9 +488,9 @@ ksocknal_send_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello)
LNET_UNLOCK();
}
- hdr->src_nid = cpu_to_le64 (hello->kshm_src_nid);
- hdr->src_pid = cpu_to_le32 (hello->kshm_src_pid);
- hdr->type = cpu_to_le32 (LNET_MSG_HELLO);
+ hdr->src_nid = cpu_to_le64 (hello->kshm_src_nid);
+ hdr->src_pid = cpu_to_le32 (hello->kshm_src_pid);
+ hdr->type = cpu_to_le32 (LNET_MSG_HELLO);
hdr->payload_length = cpu_to_le32 (hello->kshm_nips * sizeof(__u32));
hdr->msg.hello.type = cpu_to_le32 (hello->kshm_ctype);
hdr->msg.hello.incarnation = cpu_to_le64 (hello->kshm_src_incarnation);
@@ -529,7 +529,7 @@ static int
ksocknal_send_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello)
{
struct socket *sock = conn->ksnc_sock;
- int rc;
+ int rc;
hello->kshm_magic = LNET_PROTO_MAGIC;
hello->kshm_version = conn->ksnc_proto->pro_version;
@@ -572,10 +572,10 @@ static int
ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
int timeout)
{
- struct socket *sock = conn->ksnc_sock;
- lnet_hdr_t *hdr;
- int rc;
- int i;
+ struct socket *sock = conn->ksnc_sock;
+ lnet_hdr_t *hdr;
+ int rc;
+ int i;
LIBCFS_ALLOC(hdr, sizeof(*hdr));
if (hdr == NULL) {
@@ -602,12 +602,12 @@ ksocknal_recv_hello_v1(ksock_conn_t *conn, ksock_hello_msg_t *hello,
goto out;
}
- hello->kshm_src_nid = le64_to_cpu(hdr->src_nid);
- hello->kshm_src_pid = le32_to_cpu(hdr->src_pid);
+ hello->kshm_src_nid = le64_to_cpu(hdr->src_nid);
+ hello->kshm_src_pid = le32_to_cpu(hdr->src_pid);
hello->kshm_src_incarnation = le64_to_cpu(hdr->msg.hello.incarnation);
- hello->kshm_ctype = le32_to_cpu(hdr->msg.hello.type);
- hello->kshm_nips = le32_to_cpu(hdr->payload_length) /
- sizeof(__u32);
+ hello->kshm_ctype = le32_to_cpu(hdr->msg.hello.type);
+ hello->kshm_nips = le32_to_cpu(hdr->payload_length) /
+ sizeof(__u32);
if (hello->kshm_nips > LNET_MAX_INTERFACES) {
CERROR("Bad nips %d from ip %pI4h\n",
@@ -647,9 +647,9 @@ out:
static int
ksocknal_recv_hello_v2(ksock_conn_t *conn, ksock_hello_msg_t *hello, int timeout)
{
- struct socket *sock = conn->ksnc_sock;
- int rc;
- int i;
+ struct socket *sock = conn->ksnc_sock;
+ int rc;
+ int i;
if (hello->kshm_magic == LNET_PROTO_MAGIC)
conn->ksnc_flip = 0;
@@ -746,9 +746,9 @@ ksocknal_pack_msg_v2(ksock_tx_t *tx)
static void
ksocknal_unpack_msg_v1(ksock_msg_t *msg)
{
- msg->ksm_csum = 0;
- msg->ksm_type = KSOCK_MSG_LNET;
- msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0;
+ msg->ksm_csum = 0;
+ msg->ksm_type = KSOCK_MSG_LNET;
+ msg->ksm_zc_cookies[0] = msg->ksm_zc_cookies[1] = 0;
}
static void
@@ -758,40 +758,40 @@ ksocknal_unpack_msg_v2(ksock_msg_t *msg)
}
ksock_proto_t ksocknal_protocol_v1x = {
- .pro_version = KSOCK_PROTO_V1,
- .pro_send_hello = ksocknal_send_hello_v1,
- .pro_recv_hello = ksocknal_recv_hello_v1,
- .pro_pack = ksocknal_pack_msg_v1,
- .pro_unpack = ksocknal_unpack_msg_v1,
- .pro_queue_tx_msg = ksocknal_queue_tx_msg_v1,
- .pro_handle_zcreq = NULL,
- .pro_handle_zcack = NULL,
- .pro_queue_tx_zcack = NULL,
- .pro_match_tx = ksocknal_match_tx
+ .pro_version = KSOCK_PROTO_V1,
+ .pro_send_hello = ksocknal_send_hello_v1,
+ .pro_recv_hello = ksocknal_recv_hello_v1,
+ .pro_pack = ksocknal_pack_msg_v1,
+ .pro_unpack = ksocknal_unpack_msg_v1,
+ .pro_queue_tx_msg = ksocknal_queue_tx_msg_v1,
+ .pro_handle_zcreq = NULL,
+ .pro_handle_zcack = NULL,
+ .pro_queue_tx_zcack = NULL,
+ .pro_match_tx = ksocknal_match_tx
};
ksock_proto_t ksocknal_protocol_v2x = {
- .pro_version = KSOCK_PROTO_V2,
- .pro_send_hello = ksocknal_send_hello_v2,
- .pro_recv_hello = ksocknal_recv_hello_v2,
- .pro_pack = ksocknal_pack_msg_v2,
- .pro_unpack = ksocknal_unpack_msg_v2,
- .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
- .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v2,
- .pro_handle_zcreq = ksocknal_handle_zcreq,
- .pro_handle_zcack = ksocknal_handle_zcack,
- .pro_match_tx = ksocknal_match_tx
+ .pro_version = KSOCK_PROTO_V2,
+ .pro_send_hello = ksocknal_send_hello_v2,
+ .pro_recv_hello = ksocknal_recv_hello_v2,
+ .pro_pack = ksocknal_pack_msg_v2,
+ .pro_unpack = ksocknal_unpack_msg_v2,
+ .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
+ .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v2,
+ .pro_handle_zcreq = ksocknal_handle_zcreq,
+ .pro_handle_zcack = ksocknal_handle_zcack,
+ .pro_match_tx = ksocknal_match_tx
};
ksock_proto_t ksocknal_protocol_v3x = {
- .pro_version = KSOCK_PROTO_V3,
- .pro_send_hello = ksocknal_send_hello_v2,
- .pro_recv_hello = ksocknal_recv_hello_v2,
- .pro_pack = ksocknal_pack_msg_v2,
- .pro_unpack = ksocknal_unpack_msg_v2,
- .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
- .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v3,
- .pro_handle_zcreq = ksocknal_handle_zcreq,
- .pro_handle_zcack = ksocknal_handle_zcack,
- .pro_match_tx = ksocknal_match_tx_v3
+ .pro_version = KSOCK_PROTO_V3,
+ .pro_send_hello = ksocknal_send_hello_v2,
+ .pro_recv_hello = ksocknal_recv_hello_v2,
+ .pro_pack = ksocknal_pack_msg_v2,
+ .pro_unpack = ksocknal_unpack_msg_v2,
+ .pro_queue_tx_msg = ksocknal_queue_tx_msg_v2,
+ .pro_queue_tx_zcack = ksocknal_queue_tx_zcack_v3,
+ .pro_handle_zcreq = ksocknal_handle_zcreq,
+ .pro_handle_zcack = ksocknal_handle_zcack,
+ .pro_match_tx = ksocknal_match_tx_v3
};
diff --git a/drivers/staging/lustre/lnet/lnet/acceptor.c b/drivers/staging/lustre/lnet/lnet/acceptor.c
index 72fd1bf70ca050..69d4b193dd75c3 100644
--- a/drivers/staging/lustre/lnet/lnet/acceptor.c
+++ b/drivers/staging/lustre/lnet/lnet/acceptor.c
@@ -143,10 +143,10 @@ lnet_connect(struct socket **sockp, lnet_nid_t peer_nid,
__u32 local_ip, __u32 peer_ip, int peer_port)
{
lnet_acceptor_connreq_t cr;
- struct socket *sock;
- int rc;
- int port;
- int fatal;
+ struct socket *sock;
+ int rc;
+ int port;
+ int fatal;
CLASSERT(sizeof(cr) <= 16); /* not too big to be on the stack */
@@ -211,12 +211,12 @@ static int
lnet_accept(struct socket *sock, __u32 magic)
{
lnet_acceptor_connreq_t cr;
- __u32 peer_ip;
- int peer_port;
- int rc;
- int flip;
- lnet_ni_t *ni;
- char *str;
+ __u32 peer_ip;
+ int peer_port;
+ int rc;
+ int flip;
+ lnet_ni_t *ni;
+ char *str;
LASSERT(sizeof(cr) <= 16); /* not too big for the stack */
@@ -333,11 +333,11 @@ static int
lnet_acceptor(void *arg)
{
struct socket *newsock;
- int rc;
- __u32 magic;
- __u32 peer_ip;
- int peer_port;
- int secure = (int)((long_ptr_t)arg);
+ int rc;
+ __u32 magic;
+ __u32 peer_ip;
+ int peer_port;
+ int secure = (int)((long_ptr_t)arg);
LASSERT(lnet_acceptor_state.pta_sock == NULL);
@@ -444,7 +444,7 @@ accept2secure(const char *acc, long *sec)
int
lnet_acceptor_start(void)
{
- int rc;
+ int rc;
long rc2;
long secure;
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 4a14e510982178..2230eb0193a1d0 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -41,7 +41,7 @@
#define D_LNI D_CONSOLE
-lnet_t the_lnet; /* THE state of the network */
+lnet_t the_lnet; /* THE state of the network */
EXPORT_SYMBOL(the_lnet);
@@ -70,8 +70,8 @@ lnet_get_routes(void)
static char *
lnet_get_networks(void)
{
- char *nets;
- int rc;
+ char *nets;
+ int rc;
if (*networks != 0 && *ip2nets != 0) {
LCONSOLE_ERROR_MSG(0x101, "Please specify EITHER 'networks' or 'ip2nets' but not both at once\n");
@@ -98,17 +98,11 @@ lnet_init_locks(void)
mutex_init(&the_lnet.ln_api_mutex);
}
-static void
-lnet_fini_locks(void)
-{
-}
-
-
static int
lnet_create_remote_nets_table(void)
{
- int i;
- struct list_head *hash;
+ int i;
+ struct list_head *hash;
LASSERT(the_lnet.ln_remote_nets_hash == NULL);
LASSERT(the_lnet.ln_remote_nets_hbits > 0);
@@ -153,8 +147,6 @@ lnet_destroy_locks(void)
cfs_percpt_lock_free(the_lnet.ln_net_lock);
the_lnet.ln_net_lock = NULL;
}
-
- lnet_fini_locks();
}
static int
@@ -273,8 +265,8 @@ static void lnet_assert_wire_constants(void)
static lnd_t *
lnet_find_lnd_by_type(int type)
{
- lnd_t *lnd;
- struct list_head *tmp;
+ lnd_t *lnd;
+ struct list_head *tmp;
/* holding lnd mutex */
list_for_each(tmp, &the_lnet.ln_lnds) {
@@ -290,7 +282,7 @@ lnet_find_lnd_by_type(int type)
void
lnet_register_lnd(lnd_t *lnd)
{
- LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex);
+ mutex_lock(&the_lnet.ln_lnd_mutex);
LASSERT(the_lnet.ln_init);
LASSERT(libcfs_isknown_lnd(lnd->lnd_type));
@@ -301,14 +293,14 @@ lnet_register_lnd(lnd_t *lnd)
CDEBUG(D_NET, "%s LND registered\n", libcfs_lnd2str(lnd->lnd_type));
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
}
EXPORT_SYMBOL(lnet_register_lnd);
void
lnet_unregister_lnd(lnd_t *lnd)
{
- LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex);
+ mutex_lock(&the_lnet.ln_lnd_mutex);
LASSERT(the_lnet.ln_init);
LASSERT(lnet_find_lnd_by_type(lnd->lnd_type) == lnd);
@@ -317,7 +309,7 @@ lnet_unregister_lnd(lnd_t *lnd)
list_del(&lnd->lnd_list);
CDEBUG(D_NET, "%s LND unregistered\n", libcfs_lnd2str(lnd->lnd_type));
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
}
EXPORT_SYMBOL(lnet_unregister_lnd);
@@ -325,7 +317,7 @@ void
lnet_counters_get(lnet_counters_t *counters)
{
lnet_counters_t *ctr;
- int i;
+ int i;
memset(counters, 0, sizeof(*counters));
@@ -353,7 +345,7 @@ void
lnet_counters_reset(void)
{
lnet_counters_t *counters;
- int i;
+ int i;
lnet_net_lock(LNET_LOCK_EX);
@@ -396,8 +388,8 @@ lnet_freelist_init(lnet_freelist_t *fl, int n, int size)
void
lnet_freelist_fini(lnet_freelist_t *fl)
{
- struct list_head *el;
- int count;
+ struct list_head *el;
+ int count;
if (fl->fl_nobjs == 0)
return;
@@ -441,7 +433,7 @@ lnet_res_type2str(int type)
static void
lnet_res_container_cleanup(struct lnet_res_container *rec)
{
- int count = 0;
+ int count = 0;
if (rec->rec_type == 0) /* not set yet, it's uninitialized */
return;
@@ -486,8 +478,8 @@ static int
lnet_res_container_setup(struct lnet_res_container *rec,
int cpt, int type, int objnum, int objsz)
{
- int rc = 0;
- int i;
+ int rc = 0;
+ int i;
LASSERT(rec->rec_type == 0);
@@ -525,8 +517,8 @@ out:
static void
lnet_res_containers_destroy(struct lnet_res_container **recs)
{
- struct lnet_res_container *rec;
- int i;
+ struct lnet_res_container *rec;
+ int i;
cfs_percpt_for_each(rec, i, recs)
lnet_res_container_cleanup(rec);
@@ -537,10 +529,10 @@ lnet_res_containers_destroy(struct lnet_res_container **recs)
static struct lnet_res_container **
lnet_res_containers_create(int type, int objnum, int objsz)
{
- struct lnet_res_container **recs;
- struct lnet_res_container *rec;
- int rc;
- int i;
+ struct lnet_res_container **recs;
+ struct lnet_res_container *rec;
+ int rc;
+ int i;
recs = cfs_percpt_alloc(lnet_cpt_table(), sizeof(*rec));
if (recs == NULL) {
@@ -564,9 +556,9 @@ lnet_libhandle_t *
lnet_res_lh_lookup(struct lnet_res_container *rec, __u64 cookie)
{
/* ALWAYS called with lnet_res_lock held */
- struct list_head *head;
- lnet_libhandle_t *lh;
- unsigned int hash;
+ struct list_head *head;
+ lnet_libhandle_t *lh;
+ unsigned int hash;
if ((cookie & LNET_COOKIE_MASK) != rec->rec_type)
return NULL;
@@ -586,8 +578,8 @@ void
lnet_res_lh_initialize(struct lnet_res_container *rec, lnet_libhandle_t *lh)
{
/* ALWAYS called with lnet_res_lock held */
- unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS;
- unsigned int hash;
+ unsigned int ibits = LNET_COOKIE_TYPE_BITS + LNET_CPT_BITS;
+ unsigned int hash;
lh->lh_cookie = rec->rec_lh_cookie;
rec->rec_lh_cookie += 1 << ibits;
@@ -605,7 +597,7 @@ lnet_prepare(lnet_pid_t requested_pid)
{
/* Prepare to bring up the network */
struct lnet_res_container **recs;
- int rc = 0;
+ int rc = 0;
LASSERT(the_lnet.ln_refcount == 0);
@@ -725,8 +717,8 @@ lnet_unprepare(void)
lnet_ni_t *
lnet_net2ni_locked(__u32 net, int cpt)
{
- struct list_head *tmp;
- lnet_ni_t *ni;
+ struct list_head *tmp;
+ lnet_ni_t *ni;
LASSERT(cpt != LNET_LOCK_EX);
@@ -758,8 +750,8 @@ EXPORT_SYMBOL(lnet_net2ni);
static unsigned int
lnet_nid_cpt_hash(lnet_nid_t nid, unsigned int number)
{
- __u64 key = nid;
- unsigned int val;
+ __u64 key = nid;
+ unsigned int val;
LASSERT(number >= 1 && number <= LNET_CPT_NUMBER);
@@ -801,8 +793,8 @@ lnet_cpt_of_nid_locked(lnet_nid_t nid)
int
lnet_cpt_of_nid(lnet_nid_t nid)
{
- int cpt;
- int cpt2;
+ int cpt;
+ int cpt2;
if (LNET_CPT_NUMBER == 1)
return 0; /* the only one */
@@ -821,8 +813,8 @@ EXPORT_SYMBOL(lnet_cpt_of_nid);
int
lnet_islocalnet(__u32 net)
{
- struct lnet_ni *ni;
- int cpt;
+ struct lnet_ni *ni;
+ int cpt;
cpt = lnet_net_lock_current();
@@ -838,8 +830,8 @@ lnet_islocalnet(__u32 net)
lnet_ni_t *
lnet_nid2ni_locked(lnet_nid_t nid, int cpt)
{
- struct lnet_ni *ni;
- struct list_head *tmp;
+ struct lnet_ni *ni;
+ struct list_head *tmp;
LASSERT(cpt != LNET_LOCK_EX);
@@ -858,8 +850,8 @@ lnet_nid2ni_locked(lnet_nid_t nid, int cpt)
int
lnet_islocalnid(lnet_nid_t nid)
{
- struct lnet_ni *ni;
- int cpt;
+ struct lnet_ni *ni;
+ int cpt;
cpt = lnet_net_lock_current();
ni = lnet_nid2ni_locked(nid, cpt);
@@ -874,10 +866,10 @@ int
lnet_count_acceptor_nis(void)
{
/* Return the # of NIs that need the acceptor. */
- int count = 0;
- struct list_head *tmp;
- struct lnet_ni *ni;
- int cpt;
+ int count = 0;
+ struct list_head *tmp;
+ struct lnet_ni *ni;
+ int cpt;
cpt = lnet_net_lock_current();
list_for_each(tmp, &the_lnet.ln_nis) {
@@ -895,7 +887,7 @@ lnet_count_acceptor_nis(void)
static int
lnet_ni_tq_credits(lnet_ni_t *ni)
{
- int credits;
+ int credits;
LASSERT(ni->ni_ncpts >= 1);
@@ -912,9 +904,9 @@ lnet_ni_tq_credits(lnet_ni_t *ni)
static void
lnet_shutdown_lndnis(void)
{
- int i;
- int islo;
- lnet_ni_t *ni;
+ int i;
+ int islo;
+ lnet_ni_t *ni;
/* NB called holding the global mutex */
@@ -968,8 +960,8 @@ lnet_shutdown_lndnis(void)
* and shut them down in guaranteed thread context */
i = 2;
while (!list_empty(&the_lnet.ln_nis_zombie)) {
- int *ref;
- int j;
+ int *ref;
+ int j;
ni = list_entry(the_lnet.ln_nis_zombie.next,
lnet_ni_t, ni_list);
@@ -1029,15 +1021,15 @@ lnet_shutdown_lndnis(void)
static int
lnet_startup_lndnis(void)
{
- lnd_t *lnd;
- struct lnet_ni *ni;
- struct lnet_tx_queue *tq;
- struct list_head nilist;
- int i;
- int rc = 0;
- int lnd_type;
- int nicount = 0;
- char *nets = lnet_get_networks();
+ lnd_t *lnd;
+ struct lnet_ni *ni;
+ struct lnet_tx_queue *tq;
+ struct list_head nilist;
+ int i;
+ int rc = 0;
+ int lnd_type;
+ int nicount = 0;
+ char *nets = lnet_get_networks();
INIT_LIST_HEAD(&nilist);
@@ -1063,18 +1055,18 @@ lnet_startup_lndnis(void)
goto failed;
}
- LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex);
+ mutex_lock(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type);
if (lnd == NULL) {
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
rc = request_module("%s",
libcfs_lnd2modname(lnd_type));
- LNET_MUTEX_LOCK(&the_lnet.ln_lnd_mutex);
+ mutex_lock(&the_lnet.ln_lnd_mutex);
lnd = lnet_find_lnd_by_type(lnd_type);
if (lnd == NULL) {
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
CERROR("Can't load LND %s, module %s, rc=%d\n",
libcfs_lnd2str(lnd_type),
libcfs_lnd2modname(lnd_type), rc);
@@ -1090,7 +1082,7 @@ lnet_startup_lndnis(void)
rc = (lnd->lnd_startup)(ni);
- LNET_MUTEX_UNLOCK(&the_lnet.ln_lnd_mutex);
+ mutex_unlock(&the_lnet.ln_lnd_mutex);
if (rc != 0) {
LCONSOLE_ERROR_MSG(0x105, "Error %d starting up LNI %s\n",
@@ -1181,7 +1173,7 @@ lnet_startup_lndnis(void)
int
LNetInit(void)
{
- int rc;
+ int rc;
lnet_assert_wire_constants();
LASSERT(!the_lnet.ln_init);
@@ -1277,10 +1269,10 @@ EXPORT_SYMBOL(LNetFini);
int
LNetNIInit(lnet_pid_t requested_pid)
{
- int im_a_router = 0;
- int rc;
+ int im_a_router = 0;
+ int rc;
- LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
+ mutex_lock(&the_lnet.ln_api_mutex);
LASSERT(the_lnet.ln_init);
CDEBUG(D_OTHER, "refs %d\n", the_lnet.ln_refcount);
@@ -1351,7 +1343,7 @@ LNetNIInit(lnet_pid_t requested_pid)
failed0:
LASSERT(rc < 0);
out:
- LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
+ mutex_unlock(&the_lnet.ln_api_mutex);
return rc;
}
EXPORT_SYMBOL(LNetNIInit);
@@ -1368,7 +1360,7 @@ EXPORT_SYMBOL(LNetNIInit);
int
LNetNIFini(void)
{
- LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
+ mutex_lock(&the_lnet.ln_api_mutex);
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -1391,7 +1383,7 @@ LNetNIFini(void)
lnet_unprepare();
}
- LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
+ mutex_unlock(&the_lnet.ln_api_mutex);
return 0;
}
EXPORT_SYMBOL(LNetNIFini);
@@ -1413,9 +1405,9 @@ int
LNetCtl(unsigned int cmd, void *arg)
{
struct libcfs_ioctl_data *data = arg;
- lnet_process_id_t id = {0};
- lnet_ni_t *ni;
- int rc;
+ lnet_process_id_t id = {0};
+ lnet_ni_t *ni;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -1531,10 +1523,10 @@ EXPORT_SYMBOL(LNetCtl);
int
LNetGetId(unsigned int index, lnet_process_id_t *id)
{
- struct lnet_ni *ni;
- struct list_head *tmp;
- int cpt;
- int rc = -ENOENT;
+ struct lnet_ni *ni;
+ struct list_head *tmp;
+ int cpt;
+ int rc = -ENOENT;
LASSERT(the_lnet.ln_init);
@@ -1575,11 +1567,11 @@ EXPORT_SYMBOL(LNetSnprintHandle);
static int
lnet_create_ping_info(void)
{
- int i;
- int n;
- int rc;
- unsigned int infosz;
- lnet_ni_t *ni;
+ int i;
+ int n;
+ int rc;
+ unsigned int infosz;
+ lnet_ni_t *ni;
lnet_process_id_t id;
lnet_ping_info_t *pinfo;
@@ -1633,7 +1625,7 @@ lnet_create_ping_info(void)
static void
lnet_destroy_ping_info(void)
{
- struct lnet_ni *ni;
+ struct lnet_ni *ni;
lnet_net_lock(0);
@@ -1654,12 +1646,12 @@ lnet_destroy_ping_info(void)
int
lnet_ping_target_init(void)
{
- lnet_md_t md = { NULL };
- lnet_handle_me_t meh;
+ lnet_md_t md = { NULL };
+ lnet_handle_me_t meh;
lnet_process_id_t id;
- int rc;
- int rc2;
- int infosz;
+ int rc;
+ int rc2;
+ int infosz;
rc = lnet_create_ping_info();
if (rc != 0)
@@ -1722,11 +1714,11 @@ lnet_ping_target_init(void)
void
lnet_ping_target_fini(void)
{
- lnet_event_t event;
- int rc;
- int which;
- int timeout_ms = 1000;
- sigset_t blocked = cfs_block_allsigs();
+ lnet_event_t event;
+ int rc;
+ int which;
+ int timeout_ms = 1000;
+ sigset_t blocked = cfs_block_allsigs();
LNetMDUnlink(the_lnet.ln_ping_target_md);
/* NB md could be busy; this just starts the unlink */
@@ -1759,22 +1751,22 @@ lnet_ping_target_fini(void)
int
lnet_ping(lnet_process_id_t id, int timeout_ms, lnet_process_id_t *ids, int n_ids)
{
- lnet_handle_eq_t eqh;
- lnet_handle_md_t mdh;
- lnet_event_t event;
- lnet_md_t md = { NULL };
- int which;
- int unlinked = 0;
- int replied = 0;
- const int a_long_time = 60000; /* mS */
- int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]);
- lnet_ping_info_t *info;
- lnet_process_id_t tmpid;
- int i;
- int nob;
- int rc;
- int rc2;
- sigset_t blocked;
+ lnet_handle_eq_t eqh;
+ lnet_handle_md_t mdh;
+ lnet_event_t event;
+ lnet_md_t md = { NULL };
+ int which;
+ int unlinked = 0;
+ int replied = 0;
+ const int a_long_time = 60000; /* mS */
+ int infosz = offsetof(lnet_ping_info_t, pi_ni[n_ids]);
+ lnet_ping_info_t *info;
+ lnet_process_id_t tmpid;
+ int i;
+ int nob;
+ int rc;
+ int rc2;
+ sigset_t blocked;
if (n_ids <= 0 ||
id.nid == LNET_NID_ANY ||
diff --git a/drivers/staging/lustre/lnet/lnet/config.c b/drivers/staging/lustre/lnet/lnet/config.c
index 2dc4c4a1afd0cf..70bc8096b66b5c 100644
--- a/drivers/staging/lustre/lnet/lnet/config.c
+++ b/drivers/staging/lustre/lnet/lnet/config.c
@@ -38,9 +38,9 @@
#include "../../include/linux/lnet/lib-lnet.h"
struct lnet_text_buf_t { /* tmp struct for parsing routes */
- struct list_head ltb_list; /* stash on lists */
- int ltb_size; /* allocated size */
- char ltb_text[0]; /* text buffer */
+ struct list_head ltb_list; /* stash on lists */
+ int ltb_size; /* allocated size */
+ char ltb_text[0]; /* text buffer */
};
static int lnet_tbnob; /* track text buf allocation */
@@ -80,8 +80,8 @@ lnet_issep(char c)
static int
lnet_net_unique(__u32 net, struct list_head *nilist)
{
- struct list_head *tmp;
- lnet_ni_t *ni;
+ struct list_head *tmp;
+ lnet_ni_t *ni;
list_for_each(tmp, nilist) {
ni = list_entry(tmp, lnet_ni_t, ni_list);
@@ -111,10 +111,10 @@ lnet_ni_free(struct lnet_ni *ni)
static lnet_ni_t *
lnet_ni_alloc(__u32 net, struct cfs_expr_list *el, struct list_head *nilist)
{
- struct lnet_tx_queue *tq;
- struct lnet_ni *ni;
- int rc;
- int i;
+ struct lnet_tx_queue *tq;
+ struct lnet_ni *ni;
+ int rc;
+ int i;
if (!lnet_net_unique(net, nilist)) {
LCONSOLE_ERROR_MSG(0x111, "Duplicate network specified: %s\n",
@@ -178,13 +178,13 @@ int
lnet_parse_networks(struct list_head *nilist, char *networks)
{
struct cfs_expr_list *el = NULL;
- int tokensize = strlen(networks) + 1;
- char *tokens;
- char *str;
- char *tmp;
- struct lnet_ni *ni;
- __u32 net;
- int nnets = 0;
+ int tokensize = strlen(networks) + 1;
+ char *tokens;
+ char *str;
+ char *tmp;
+ struct lnet_ni *ni;
+ __u32 net;
+ int nnets = 0;
if (strlen(networks) > LNET_SINGLE_TEXTBUF_NOB) {
/* _WAY_ conservative */
@@ -210,12 +210,12 @@ lnet_parse_networks(struct list_head *nilist, char *networks)
goto failed;
while (str != NULL && *str != 0) {
- char *comma = strchr(str, ',');
- char *bracket = strchr(str, '(');
- char *square = strchr(str, '[');
- char *iface;
- int niface;
- int rc;
+ char *comma = strchr(str, ',');
+ char *bracket = strchr(str, '(');
+ char *square = strchr(str, '[');
+ char *iface;
+ int niface;
+ int rc;
/* NB we don't check interface conflicts here; it's the LNDs
* responsibility (if it cares at all) */
@@ -369,7 +369,7 @@ static struct lnet_text_buf_t *
lnet_new_text_buf(int str_len)
{
struct lnet_text_buf_t *ltb;
- int nob;
+ int nob;
/* NB allocate space for the terminating 0 */
nob = offsetof(struct lnet_text_buf_t, ltb_text[str_len + 1]);
@@ -404,7 +404,7 @@ lnet_free_text_buf(struct lnet_text_buf_t *ltb)
static void
lnet_free_text_bufs(struct list_head *tbs)
{
- struct lnet_text_buf_t *ltb;
+ struct lnet_text_buf_t *ltb;
while (!list_empty(tbs)) {
ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list);
@@ -417,11 +417,11 @@ lnet_free_text_bufs(struct list_head *tbs)
static int
lnet_str2tbs_sep(struct list_head *tbs, char *str)
{
- struct list_head pending;
- char *sep;
- int nob;
- int i;
- struct lnet_text_buf_t *ltb;
+ struct list_head pending;
+ char *sep;
+ int nob;
+ int i;
+ struct lnet_text_buf_t *ltb;
INIT_LIST_HEAD(&pending);
@@ -477,8 +477,8 @@ lnet_expand1tb(struct list_head *list,
char *str, char *sep1, char *sep2,
char *item, int itemlen)
{
- int len1 = (int)(sep1 - str);
- int len2 = strlen(sep2 + 1);
+ int len1 = (int)(sep1 - str);
+ int len2 = strlen(sep2 + 1);
struct lnet_text_buf_t *ltb;
LASSERT(*sep1 == '[');
@@ -500,18 +500,18 @@ lnet_expand1tb(struct list_head *list,
static int
lnet_str2tbs_expand(struct list_head *tbs, char *str)
{
- char num[16];
- struct list_head pending;
- char *sep;
- char *sep2;
- char *parsed;
- char *enditem;
- int lo;
- int hi;
- int stride;
- int i;
- int nob;
- int scanned;
+ char num[16];
+ struct list_head pending;
+ char *sep;
+ char *sep2;
+ char *parsed;
+ char *enditem;
+ int lo;
+ int hi;
+ int stride;
+ int i;
+ int nob;
+ int scanned;
INIT_LIST_HEAD(&pending);
@@ -584,8 +584,8 @@ lnet_str2tbs_expand(struct list_head *tbs, char *str)
static int
lnet_parse_hops(char *str, unsigned int *hops)
{
- int len = strlen(str);
- int nob = len;
+ int len = strlen(str);
+ int nob = len;
return (sscanf(str, "%u%n", hops, &nob) >= 1 &&
nob == len &&
@@ -597,9 +597,9 @@ lnet_parse_hops(char *str, unsigned int *hops)
static int
lnet_parse_priority(char *str, unsigned int *priority, char **token)
{
- int nob;
+ int nob;
char *sep;
- int len;
+ int len;
sep = strchr(str, LNET_PRIORITY_SEPARATOR);
if (sep == NULL) {
@@ -628,23 +628,23 @@ static int
lnet_parse_route(char *str, int *im_a_router)
{
/* static scratch buffer OK (single threaded) */
- static char cmd[LNET_SINGLE_TEXTBUF_NOB];
-
- struct list_head nets;
- struct list_head gateways;
- struct list_head *tmp1;
- struct list_head *tmp2;
- __u32 net;
- lnet_nid_t nid;
- struct lnet_text_buf_t *ltb;
- int rc;
- char *sep;
- char *token = str;
- int ntokens = 0;
- int myrc = -1;
- unsigned int hops;
- int got_hops = 0;
- unsigned int priority = 0;
+ static char cmd[LNET_SINGLE_TEXTBUF_NOB];
+
+ struct list_head nets;
+ struct list_head gateways;
+ struct list_head *tmp1;
+ struct list_head *tmp2;
+ __u32 net;
+ lnet_nid_t nid;
+ struct lnet_text_buf_t *ltb;
+ int rc;
+ char *sep;
+ char *token = str;
+ int ntokens = 0;
+ int myrc = -1;
+ unsigned int hops;
+ int got_hops = 0;
+ unsigned int priority = 0;
INIT_LIST_HEAD(&gateways);
INIT_LIST_HEAD(&nets);
@@ -772,7 +772,7 @@ lnet_parse_route(char *str, int *im_a_router)
static int
lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router)
{
- struct lnet_text_buf_t *ltb;
+ struct lnet_text_buf_t *ltb;
while (!list_empty(tbs)) {
ltb = list_entry(tbs->next, struct lnet_text_buf_t, ltb_list);
@@ -792,8 +792,8 @@ lnet_parse_route_tbs(struct list_head *tbs, int *im_a_router)
int
lnet_parse_routes(char *routes, int *im_a_router)
{
- struct list_head tbs;
- int rc = 0;
+ struct list_head tbs;
+ int rc = 0;
*im_a_router = 0;
@@ -814,8 +814,8 @@ static int
lnet_match_network_token(char *token, int len, __u32 *ipaddrs, int nip)
{
LIST_HEAD(list);
- int rc;
- int i;
+ int rc;
+ int i;
rc = cfs_ip_addr_parse(token, len, &list);
if (rc != 0)
@@ -834,13 +834,13 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
{
static char tokens[LNET_SINGLE_TEXTBUF_NOB];
- int matched = 0;
- int ntokens = 0;
- int len;
+ int matched = 0;
+ int ntokens = 0;
+ int len;
char *net = NULL;
char *sep;
char *token;
- int rc;
+ int rc;
LASSERT(strlen(net_entry) < sizeof(tokens));
@@ -889,8 +889,8 @@ lnet_match_network_tokens(char *net_entry, __u32 *ipaddrs, int nip)
static __u32
lnet_netspec2net(char *netspec)
{
- char *bracket = strchr(netspec, '(');
- __u32 net;
+ char *bracket = strchr(netspec, '(');
+ __u32 net;
if (bracket != NULL)
*bracket = 0;
@@ -906,15 +906,15 @@ lnet_netspec2net(char *netspec)
static int
lnet_splitnets(char *source, struct list_head *nets)
{
- int offset = 0;
- int offset2;
- int len;
- struct lnet_text_buf_t *tb;
- struct lnet_text_buf_t *tb2;
- struct list_head *t;
- char *sep;
- char *bracket;
- __u32 net;
+ int offset = 0;
+ int offset2;
+ int len;
+ struct lnet_text_buf_t *tb;
+ struct lnet_text_buf_t *tb2;
+ struct list_head *t;
+ char *sep;
+ char *bracket;
+ __u32 net;
LASSERT(!list_empty(nets));
LASSERT(nets->next == nets->prev); /* single entry */
@@ -986,22 +986,22 @@ lnet_splitnets(char *source, struct list_head *nets)
static int
lnet_match_networks(char **networksp, char *ip2nets, __u32 *ipaddrs, int nip)
{
- static char networks[LNET_SINGLE_TEXTBUF_NOB];
- static char source[LNET_SINGLE_TEXTBUF_NOB];
-
- struct list_head raw_entries;
- struct list_head matched_nets;
- struct list_head current_nets;
- struct list_head *t;
- struct list_head *t2;
- struct lnet_text_buf_t *tb;
- struct lnet_text_buf_t *tb2;
- __u32 net1;
- __u32 net2;
- int len;
- int count;
- int dup;
- int rc;
+ static char networks[LNET_SINGLE_TEXTBUF_NOB];
+ static char source[LNET_SINGLE_TEXTBUF_NOB];
+
+ struct list_head raw_entries;
+ struct list_head matched_nets;
+ struct list_head current_nets;
+ struct list_head *t;
+ struct list_head *t2;
+ struct lnet_text_buf_t *tb;
+ struct lnet_text_buf_t *tb2;
+ __u32 net1;
+ __u32 net2;
+ int len;
+ int count;
+ int dup;
+ int rc;
INIT_LIST_HEAD(&raw_entries);
if (lnet_str2tbs_sep(&raw_entries, ip2nets) < 0) {
@@ -1112,15 +1112,15 @@ lnet_ipaddr_free_enumeration(__u32 *ipaddrs, int nip)
static int
lnet_ipaddr_enumerate(__u32 **ipaddrsp)
{
- int up;
- __u32 netmask;
- __u32 *ipaddrs;
- __u32 *ipaddrs2;
- int nip;
- char **ifnames;
- int nif = libcfs_ipif_enumerate(&ifnames);
- int i;
- int rc;
+ int up;
+ __u32 netmask;
+ __u32 *ipaddrs;
+ __u32 *ipaddrs2;
+ int nip;
+ char **ifnames;
+ int nif = libcfs_ipif_enumerate(&ifnames);
+ int i;
+ int rc;
if (nif <= 0)
return nif;
@@ -1178,9 +1178,9 @@ lnet_ipaddr_enumerate(__u32 **ipaddrsp)
int
lnet_parse_ip2nets(char **networksp, char *ip2nets)
{
- __u32 *ipaddrs = NULL;
- int nip = lnet_ipaddr_enumerate(&ipaddrs);
- int rc;
+ __u32 *ipaddrs = NULL;
+ int nip = lnet_ipaddr_enumerate(&ipaddrs);
+ int rc;
if (nip < 0) {
LCONSOLE_ERROR_MSG(0x117,
@@ -1215,14 +1215,14 @@ lnet_parse_ip2nets(char **networksp, char *ip2nets)
int
lnet_set_ip_niaddr(lnet_ni_t *ni)
{
- __u32 net = LNET_NIDNET(ni->ni_nid);
+ __u32 net = LNET_NIDNET(ni->ni_nid);
char **names;
- int n;
- __u32 ip;
- __u32 netmask;
- int up;
- int i;
- int rc;
+ int n;
+ __u32 ip;
+ __u32 netmask;
+ int up;
+ int i;
+ int rc;
/* Convenience for LNDs that use the IP address of a local interface as
* the local address part of their NID */
diff --git a/drivers/staging/lustre/lnet/lnet/lib-eq.c b/drivers/staging/lustre/lnet/lnet/lib-eq.c
index 5470148f5b64a2..28858fb215c3a6 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-eq.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-eq.c
@@ -70,7 +70,7 @@ int
LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
lnet_handle_eq_t *handle)
{
- lnet_eq_t *eq;
+ lnet_eq_t *eq;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -79,7 +79,7 @@ LNetEQAlloc(unsigned int count, lnet_eq_handler_t callback,
* overflow, they don't skip entries, so the queue has the same
* apparent capacity at all times */
- count = cfs_power2_roundup(count);
+ count = roundup_pow_of_two(count);
if (callback != LNET_EQ_HANDLER_NONE && count != 0)
CWARN("EQ callback is guaranteed to get every event, do you still want to set eqcount %d for polling event which will have locking overhead? Please contact with developer to confirm\n", count);
@@ -151,13 +151,13 @@ EXPORT_SYMBOL(LNetEQAlloc);
int
LNetEQFree(lnet_handle_eq_t eqh)
{
- struct lnet_eq *eq;
- lnet_event_t *events = NULL;
- int **refs = NULL;
- int *ref;
- int rc = 0;
- int size = 0;
- int i;
+ struct lnet_eq *eq;
+ lnet_event_t *events = NULL;
+ int **refs = NULL;
+ int *ref;
+ int rc = 0;
+ int size = 0;
+ int i;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -185,9 +185,9 @@ LNetEQFree(lnet_handle_eq_t eqh)
}
/* stash for free after lock dropped */
- events = eq->eq_events;
- size = eq->eq_size;
- refs = eq->eq_refs;
+ events = eq->eq_events;
+ size = eq->eq_size;
+ refs = eq->eq_refs;
lnet_res_lh_invalidate(&eq->eq_lh);
list_del(&eq->eq_list);
@@ -237,9 +237,9 @@ lnet_eq_enqueue_event(lnet_eq_t *eq, lnet_event_t *ev)
static int
lnet_eq_dequeue_event(lnet_eq_t *eq, lnet_event_t *ev)
{
- int new_index = eq->eq_deq_seq & (eq->eq_size - 1);
- lnet_event_t *new_event = &eq->eq_events[new_index];
- int rc;
+ int new_index = eq->eq_deq_seq & (eq->eq_size - 1);
+ lnet_event_t *new_event = &eq->eq_events[new_index];
+ int rc;
/* must called with lnet_eq_wait_lock hold */
if (LNET_SEQ_GT(eq->eq_deq_seq, new_event->sequence))
@@ -323,10 +323,10 @@ static int
lnet_eq_wait_locked(int *timeout_ms)
__must_hold(&the_lnet.ln_eq_wait_lock)
{
- int tms = *timeout_ms;
- int wait;
- wait_queue_t wl;
- unsigned long now;
+ int tms = *timeout_ms;
+ int wait;
+ wait_queue_t wl;
+ unsigned long now;
if (tms == 0)
return -1; /* don't want to wait and no new event */
@@ -392,9 +392,9 @@ int
LNetEQPoll(lnet_handle_eq_t *eventqs, int neq, int timeout_ms,
lnet_event_t *event, int *which)
{
- int wait = 1;
- int rc;
- int i;
+ int wait = 1;
+ int rc;
+ int i;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-md.c b/drivers/staging/lustre/lnet/lnet/lib-md.c
index 89d660fefd4896..5856c30503eae8 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-md.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-md.c
@@ -74,7 +74,7 @@ lnet_md_unlink(lnet_libmd_t *md)
CDEBUG(D_NET, "Unlinking md %p\n", md);
if (md->md_eq != NULL) {
- int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie);
+ int cpt = lnet_cpt_of_cookie(md->md_lh.lh_cookie);
LASSERT(*md->md_eq->eq_refs[cpt] > 0);
(*md->md_eq->eq_refs[cpt])--;
@@ -88,9 +88,9 @@ lnet_md_unlink(lnet_libmd_t *md)
static int
lnet_md_build(lnet_libmd_t *lmd, lnet_md_t *umd, int unlink)
{
- int i;
+ int i;
unsigned int niov;
- int total_length = 0;
+ int total_length = 0;
lmd->md_me = NULL;
lmd->md_start = umd->start;
@@ -268,10 +268,10 @@ LNetMDAttach(lnet_handle_me_t meh, lnet_md_t umd,
{
LIST_HEAD(matches);
LIST_HEAD(drops);
- struct lnet_me *me;
- struct lnet_libmd *md;
- int cpt;
- int rc;
+ struct lnet_me *me;
+ struct lnet_libmd *md;
+ int cpt;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -346,9 +346,9 @@ EXPORT_SYMBOL(LNetMDAttach);
int
LNetMDBind(lnet_md_t umd, lnet_unlink_t unlink, lnet_handle_md_t *handle)
{
- lnet_libmd_t *md;
- int cpt;
- int rc;
+ lnet_libmd_t *md;
+ int cpt;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -421,9 +421,9 @@ EXPORT_SYMBOL(LNetMDBind);
int
LNetMDUnlink(lnet_handle_md_t mdh)
{
- lnet_event_t ev;
- lnet_libmd_t *md;
- int cpt;
+ lnet_event_t ev;
+ lnet_libmd_t *md;
+ int cpt;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-me.c b/drivers/staging/lustre/lnet/lnet/lib-me.c
index a3f92924471123..09e90087c74ae8 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-me.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-me.c
@@ -80,8 +80,8 @@ LNetMEAttach(unsigned int portal,
lnet_handle_me_t *handle)
{
struct lnet_match_table *mtable;
- struct lnet_me *me;
- struct list_head *head;
+ struct lnet_me *me;
+ struct list_head *head;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -151,10 +151,10 @@ LNetMEInsert(lnet_handle_me_t current_meh,
lnet_unlink_t unlink, lnet_ins_pos_t pos,
lnet_handle_me_t *handle)
{
- struct lnet_me *current_me;
- struct lnet_me *new_me;
- struct lnet_portal *ptl;
- int cpt;
+ struct lnet_me *current_me;
+ struct lnet_me *new_me;
+ struct lnet_portal *ptl;
+ int cpt;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -228,10 +228,10 @@ EXPORT_SYMBOL(LNetMEInsert);
int
LNetMEUnlink(lnet_handle_me_t meh)
{
- lnet_me_t *me;
- lnet_libmd_t *md;
- lnet_event_t ev;
- int cpt;
+ lnet_me_t *me;
+ lnet_libmd_t *md;
+ lnet_event_t ev;
+ int cpt;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-move.c b/drivers/staging/lustre/lnet/lnet/lib-move.c
index c2fb70e5fc4e08..433faae9a2ff3b 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-move.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-move.c
@@ -49,10 +49,10 @@ MODULE_PARM_DESC(local_nid_dist_zero, "Reserved");
int
lnet_fail_nid(lnet_nid_t nid, unsigned int threshold)
{
- lnet_test_peer_t *tp;
- struct list_head *el;
- struct list_head *next;
- struct list_head cull;
+ lnet_test_peer_t *tp;
+ struct list_head *el;
+ struct list_head *next;
+ struct list_head cull;
LASSERT(the_lnet.ln_init);
@@ -103,10 +103,10 @@ static int
fail_peer(lnet_nid_t nid, int outgoing)
{
lnet_test_peer_t *tp;
- struct list_head *el;
- struct list_head *next;
- struct list_head cull;
- int fail = 0;
+ struct list_head *el;
+ struct list_head *next;
+ struct list_head cull;
+ int fail = 0;
INIT_LIST_HEAD(&cull);
@@ -175,7 +175,7 @@ lnet_copy_iov2iov(unsigned int ndiov, struct kvec *diov, unsigned int doffset,
unsigned int nob)
{
/* NB diov, siov are READ-ONLY */
- unsigned int this_nob;
+ unsigned int this_nob;
if (nob == 0)
return;
@@ -236,8 +236,8 @@ lnet_extract_iov(int dst_niov, struct kvec *dst,
/* Initialise 'dst' to the subset of 'src' starting at 'offset',
* for exactly 'len' bytes, and return the number of entries.
* NB not destructive to 'src' */
- unsigned int frag_len;
- unsigned int niov;
+ unsigned int frag_len;
+ unsigned int niov;
if (len == 0) /* no data => */
return 0; /* no frags */
@@ -279,7 +279,7 @@ EXPORT_SYMBOL(lnet_extract_iov);
unsigned int
lnet_kiov_nob(unsigned int niov, lnet_kiov_t *kiov)
{
- unsigned int nob = 0;
+ unsigned int nob = 0;
while (niov-- > 0)
nob += (kiov++)->kiov_len;
@@ -294,9 +294,9 @@ lnet_copy_kiov2kiov(unsigned int ndiov, lnet_kiov_t *diov, unsigned int doffset,
unsigned int nob)
{
/* NB diov, siov are READ-ONLY */
- unsigned int this_nob;
- char *daddr = NULL;
- char *saddr = NULL;
+ unsigned int this_nob;
+ char *daddr = NULL;
+ char *saddr = NULL;
if (nob == 0)
return;
@@ -376,8 +376,8 @@ lnet_copy_kiov2iov(unsigned int niov, struct kvec *iov, unsigned int iovoffset,
unsigned int kiovoffset, unsigned int nob)
{
/* NB iov, kiov are READ-ONLY */
- unsigned int this_nob;
- char *addr = NULL;
+ unsigned int this_nob;
+ char *addr = NULL;
if (nob == 0)
return;
@@ -447,8 +447,8 @@ lnet_copy_iov2kiov(unsigned int nkiov, lnet_kiov_t *kiov,
unsigned int nob)
{
/* NB kiov, iov are READ-ONLY */
- unsigned int this_nob;
- char *addr = NULL;
+ unsigned int this_nob;
+ char *addr = NULL;
if (nob == 0)
return;
@@ -518,8 +518,8 @@ lnet_extract_kiov(int dst_niov, lnet_kiov_t *dst,
/* Initialise 'dst' to the subset of 'src' starting at 'offset',
* for exactly 'len' bytes, and return the number of entries.
* NB not destructive to 'src' */
- unsigned int frag_len;
- unsigned int niov;
+ unsigned int frag_len;
+ unsigned int niov;
if (len == 0) /* no data => */
return 0; /* no frags */
@@ -565,10 +565,10 @@ static void
lnet_ni_recv(lnet_ni_t *ni, void *private, lnet_msg_t *msg, int delayed,
unsigned int offset, unsigned int mlen, unsigned int rlen)
{
- unsigned int niov = 0;
+ unsigned int niov = 0;
struct kvec *iov = NULL;
- lnet_kiov_t *kiov = NULL;
- int rc;
+ lnet_kiov_t *kiov = NULL;
+ int rc;
LASSERT(!in_interrupt());
LASSERT(mlen == 0 || msg != NULL);
@@ -642,8 +642,8 @@ lnet_prep_send(lnet_msg_t *msg, int type, lnet_process_id_t target,
static void
lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
{
- void *priv = msg->msg_private;
- int rc;
+ void *priv = msg->msg_private;
+ int rc;
LASSERT(!in_interrupt());
LASSERT(LNET_NETTYP(LNET_NIDNET(ni->ni_nid)) == LOLND ||
@@ -657,7 +657,7 @@ lnet_ni_send(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_ni_eager_recv(lnet_ni_t *ni, lnet_msg_t *msg)
{
- int rc;
+ int rc;
LASSERT(!msg->msg_sending);
LASSERT(msg->msg_receiving);
@@ -700,7 +700,7 @@ lnet_ni_query_locked(lnet_ni_t *ni, lnet_peer_t *lp)
static inline int
lnet_peer_is_alive(lnet_peer_t *lp, unsigned long now)
{
- int alive;
+ int alive;
unsigned long deadline;
LASSERT(lnet_peer_aliveness_enabled(lp));
@@ -785,10 +785,10 @@ lnet_peer_alive_locked(lnet_peer_t *lp)
static int
lnet_post_send_locked(lnet_msg_t *msg, int do_send)
{
- lnet_peer_t *lp = msg->msg_txpeer;
- lnet_ni_t *ni = lp->lp_ni;
- int cpt = msg->msg_tx_cpt;
- struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt];
+ lnet_peer_t *lp = msg->msg_txpeer;
+ lnet_ni_t *ni = lp->lp_ni;
+ int cpt = msg->msg_tx_cpt;
+ struct lnet_tx_queue *tq = ni->ni_tx_queues[cpt];
/* non-lnet_send() callers have checked before */
LASSERT(!do_send || msg->msg_tx_delayed);
@@ -871,8 +871,8 @@ lnet_post_send_locked(lnet_msg_t *msg, int do_send)
static lnet_rtrbufpool_t *
lnet_msg2bufpool(lnet_msg_t *msg)
{
- lnet_rtrbufpool_t *rbp;
- int cpt;
+ lnet_rtrbufpool_t *rbp;
+ int cpt;
LASSERT(msg->msg_rx_committed);
@@ -894,9 +894,9 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv)
/* lnet_parse is going to lnet_net_unlock immediately after this, so it
* sets do_recv FALSE and I don't do the unlock/send/lock bit. I
* return EAGAIN if msg blocked and 0 if received or OK to receive */
- lnet_peer_t *lp = msg->msg_rxpeer;
- lnet_rtrbufpool_t *rbp;
- lnet_rtrbuf_t *rb;
+ lnet_peer_t *lp = msg->msg_rxpeer;
+ lnet_rtrbufpool_t *rbp;
+ lnet_rtrbuf_t *rb;
LASSERT(msg->msg_iov == NULL);
LASSERT(msg->msg_kiov == NULL);
@@ -967,11 +967,11 @@ lnet_post_routed_recv_locked(lnet_msg_t *msg, int do_recv)
void
lnet_return_tx_credits_locked(lnet_msg_t *msg)
{
- lnet_peer_t *txpeer = msg->msg_txpeer;
- lnet_msg_t *msg2;
+ lnet_peer_t *txpeer = msg->msg_txpeer;
+ lnet_msg_t *msg2;
if (msg->msg_txcredit) {
- struct lnet_ni *ni = txpeer->lp_ni;
+ struct lnet_ni *ni = txpeer->lp_ni;
struct lnet_tx_queue *tq = ni->ni_tx_queues[msg->msg_tx_cpt];
/* give back NI txcredits */
@@ -1025,12 +1025,12 @@ lnet_return_tx_credits_locked(lnet_msg_t *msg)
void
lnet_return_rx_credits_locked(lnet_msg_t *msg)
{
- lnet_peer_t *rxpeer = msg->msg_rxpeer;
- lnet_msg_t *msg2;
+ lnet_peer_t *rxpeer = msg->msg_rxpeer;
+ lnet_msg_t *msg2;
if (msg->msg_rtrcredit) {
/* give back global router credits */
- lnet_rtrbuf_t *rb;
+ lnet_rtrbuf_t *rb;
lnet_rtrbufpool_t *rbp;
/* NB If a msg ever blocks for a buffer in rbp_msgs, it stays
@@ -1122,13 +1122,13 @@ lnet_compare_routes(lnet_route_t *r1, lnet_route_t *r2)
static lnet_peer_t *
lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid)
{
- lnet_remotenet_t *rnet;
- lnet_route_t *rtr;
- lnet_route_t *rtr_best;
- lnet_route_t *rtr_last;
- struct lnet_peer *lp_best;
- struct lnet_peer *lp;
- int rc;
+ lnet_remotenet_t *rnet;
+ lnet_route_t *rtr;
+ lnet_route_t *rtr_best;
+ lnet_route_t *rtr_last;
+ struct lnet_peer *lp_best;
+ struct lnet_peer *lp;
+ int rc;
/* If @rtr_nid is not LNET_NID_ANY, return the gateway with
* rtr_nid nid, otherwise find the best gateway I can use */
@@ -1182,13 +1182,13 @@ lnet_find_route_locked(lnet_ni_t *ni, lnet_nid_t target, lnet_nid_t rtr_nid)
int
lnet_send(lnet_nid_t src_nid, lnet_msg_t *msg, lnet_nid_t rtr_nid)
{
- lnet_nid_t dst_nid = msg->msg_target.nid;
- struct lnet_ni *src_ni;
- struct lnet_ni *local_ni;
- struct lnet_peer *lp;
- int cpt;
- int cpt2;
- int rc;
+ lnet_nid_t dst_nid = msg->msg_target.nid;
+ struct lnet_ni *src_ni;
+ struct lnet_ni *local_ni;
+ struct lnet_peer *lp;
+ int cpt;
+ int cpt2;
+ int rc;
/* NB: rtr_nid is set to LNET_NID_ANY for all current use-cases,
* but we might want to use pre-determined router for ACK/REPLY
@@ -1364,7 +1364,7 @@ lnet_drop_message(lnet_ni_t *ni, int cpt, void *private, unsigned int nob)
static void
lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg)
{
- lnet_hdr_t *hdr = &msg->msg_hdr;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
if (msg->msg_wanted != 0)
lnet_setpayloadbuffer(msg);
@@ -1383,9 +1383,9 @@ lnet_recv_put(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
{
- lnet_hdr_t *hdr = &msg->msg_hdr;
- struct lnet_match_info info;
- int rc;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
+ struct lnet_match_info info;
+ int rc;
/* Convert put fields to host byte order */
hdr->msg.put.match_bits = le64_to_cpu(hdr->msg.put.match_bits);
@@ -1433,24 +1433,24 @@ lnet_parse_put(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get)
{
- struct lnet_match_info info;
- lnet_hdr_t *hdr = &msg->msg_hdr;
- lnet_handle_wire_t reply_wmd;
- int rc;
+ struct lnet_match_info info;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
+ lnet_handle_wire_t reply_wmd;
+ int rc;
/* Convert get fields to host byte order */
- hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits);
- hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index);
- hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length);
- hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset);
-
- info.mi_id.nid = hdr->src_nid;
- info.mi_id.pid = hdr->src_pid;
- info.mi_opc = LNET_MD_OP_GET;
- info.mi_portal = hdr->msg.get.ptl_index;
- info.mi_rlength = hdr->msg.get.sink_length;
- info.mi_roffset = hdr->msg.get.src_offset;
- info.mi_mbits = hdr->msg.get.match_bits;
+ hdr->msg.get.match_bits = le64_to_cpu(hdr->msg.get.match_bits);
+ hdr->msg.get.ptl_index = le32_to_cpu(hdr->msg.get.ptl_index);
+ hdr->msg.get.sink_length = le32_to_cpu(hdr->msg.get.sink_length);
+ hdr->msg.get.src_offset = le32_to_cpu(hdr->msg.get.src_offset);
+
+ info.mi_id.nid = hdr->src_nid;
+ info.mi_id.pid = hdr->src_pid;
+ info.mi_opc = LNET_MD_OP_GET;
+ info.mi_portal = hdr->msg.get.ptl_index;
+ info.mi_rlength = hdr->msg.get.sink_length;
+ info.mi_roffset = hdr->msg.get.src_offset;
+ info.mi_mbits = hdr->msg.get.match_bits;
rc = lnet_ptl_match_md(&info, msg);
if (rc == LNET_MATCHMD_DROP) {
@@ -1497,13 +1497,13 @@ lnet_parse_get(lnet_ni_t *ni, lnet_msg_t *msg, int rdma_get)
static int
lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
{
- void *private = msg->msg_private;
- lnet_hdr_t *hdr = &msg->msg_hdr;
+ void *private = msg->msg_private;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
lnet_process_id_t src = {0};
- lnet_libmd_t *md;
- int rlength;
- int mlength;
- int cpt;
+ lnet_libmd_t *md;
+ int rlength;
+ int mlength;
+ int cpt;
cpt = lnet_cpt_of_cookie(hdr->msg.reply.dst_wmd.wh_object_cookie);
lnet_res_lock(cpt);
@@ -1562,10 +1562,10 @@ lnet_parse_reply(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
{
- lnet_hdr_t *hdr = &msg->msg_hdr;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
lnet_process_id_t src = {0};
- lnet_libmd_t *md;
- int cpt;
+ lnet_libmd_t *md;
+ int cpt;
src.nid = hdr->src_nid;
src.pid = hdr->src_pid;
@@ -1612,7 +1612,7 @@ lnet_parse_ack(lnet_ni_t *ni, lnet_msg_t *msg)
static int
lnet_parse_forward_locked(lnet_ni_t *ni, lnet_msg_t *msg)
{
- int rc = 0;
+ int rc = 0;
if (msg->msg_rxpeer->lp_rtrcredits <= 0 ||
lnet_msg2bufpool(msg)->rbp_credits <= 0) {
@@ -1713,15 +1713,15 @@ int
lnet_parse(lnet_ni_t *ni, lnet_hdr_t *hdr, lnet_nid_t from_nid,
void *private, int rdma_req)
{
- int rc = 0;
- int cpt;
- int for_me;
- struct lnet_msg *msg;
- lnet_pid_t dest_pid;
- lnet_nid_t dest_nid;
- lnet_nid_t src_nid;
- __u32 payload_length;
- __u32 type;
+ int rc = 0;
+ int cpt;
+ int for_me;
+ struct lnet_msg *msg;
+ lnet_pid_t dest_pid;
+ lnet_nid_t dest_nid;
+ lnet_nid_t src_nid;
+ __u32 payload_length;
+ __u32 type;
LASSERT(!in_interrupt());
@@ -1945,8 +1945,8 @@ void
lnet_drop_delayed_msg_list(struct list_head *head, char *reason)
{
while (!list_empty(head)) {
- lnet_process_id_t id = {0};
- lnet_msg_t *msg;
+ lnet_process_id_t id = {0};
+ lnet_msg_t *msg;
msg = list_entry(head->next, lnet_msg_t, msg_list);
list_del(&msg->msg_list);
@@ -1986,8 +1986,8 @@ void
lnet_recv_delayed_msg_list(struct list_head *head)
{
while (!list_empty(head)) {
- lnet_msg_t *msg;
- lnet_process_id_t id;
+ lnet_msg_t *msg;
+ lnet_process_id_t id;
msg = list_entry(head->next, lnet_msg_t, msg_list);
list_del(&msg->msg_list);
@@ -2063,10 +2063,10 @@ LNetPut(lnet_nid_t self, lnet_handle_md_t mdh, lnet_ack_req_t ack,
__u64 match_bits, unsigned int offset,
__u64 hdr_data)
{
- struct lnet_msg *msg;
- struct lnet_libmd *md;
- int cpt;
- int rc;
+ struct lnet_msg *msg;
+ struct lnet_libmd *md;
+ int cpt;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -2153,10 +2153,10 @@ lnet_create_reply_msg(lnet_ni_t *ni, lnet_msg_t *getmsg)
* CAVEAT EMPTOR: 'getmsg' is the original GET, which is freed when
* lnet_finalize() is called on it, so the LND must call this first */
- struct lnet_msg *msg = lnet_msg_alloc();
- struct lnet_libmd *getmd = getmsg->msg_md;
- lnet_process_id_t peer_id = getmsg->msg_target;
- int cpt;
+ struct lnet_msg *msg = lnet_msg_alloc();
+ struct lnet_libmd *getmd = getmsg->msg_md;
+ lnet_process_id_t peer_id = getmsg->msg_target;
+ int cpt;
LASSERT(!getmsg->msg_target_is_router);
LASSERT(!getmsg->msg_routing);
@@ -2263,10 +2263,10 @@ LNetGet(lnet_nid_t self, lnet_handle_md_t mdh,
lnet_process_id_t target, unsigned int portal,
__u64 match_bits, unsigned int offset)
{
- struct lnet_msg *msg;
- struct lnet_libmd *md;
- int cpt;
- int rc;
+ struct lnet_msg *msg;
+ struct lnet_libmd *md;
+ int cpt;
+ int rc;
LASSERT(the_lnet.ln_init);
LASSERT(the_lnet.ln_refcount > 0);
@@ -2353,14 +2353,14 @@ EXPORT_SYMBOL(LNetGet);
int
LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
{
- struct list_head *e;
- struct lnet_ni *ni;
- lnet_remotenet_t *rnet;
- __u32 dstnet = LNET_NIDNET(dstnid);
- int hops;
- int cpt;
- __u32 order = 2;
- struct list_head *rn_list;
+ struct list_head *e;
+ struct lnet_ni *ni;
+ lnet_remotenet_t *rnet;
+ __u32 dstnet = LNET_NIDNET(dstnid);
+ int hops;
+ int cpt;
+ __u32 order = 2;
+ struct list_head *rn_list;
/* if !local_nid_dist_zero, I don't return a distance of 0 ever
* (when lustre sees a distance of 0, it substitutes 0@lo), so I
@@ -2434,27 +2434,3 @@ LNetDist(lnet_nid_t dstnid, lnet_nid_t *srcnidp, __u32 *orderp)
return -EHOSTUNREACH;
}
EXPORT_SYMBOL(LNetDist);
-
-/**
- * Set the number of asynchronous messages expected from a target process.
- *
- * This function is only meaningful for userspace callers. It's a no-op when
- * called from kernel.
- *
- * Asynchronous messages are those that can come from a target when the
- * userspace process is not waiting for IO to complete; e.g., AST callbacks
- * from Lustre servers. Specifying the expected number of such messages
- * allows them to be eagerly received when user process is not running in
- * LNet; otherwise network errors may occur.
- *
- * \param id Process ID of the target process.
- * \param nasync Number of asynchronous messages expected from the target.
- *
- * \return 0 on success, and an error code otherwise.
- */
-int
-LNetSetAsync(lnet_process_id_t id, int nasync)
-{
- return 0;
-}
-EXPORT_SYMBOL(LNetSetAsync);
diff --git a/drivers/staging/lustre/lnet/lnet/lib-msg.c b/drivers/staging/lustre/lnet/lnet/lib-msg.c
index a46ccbf6608fb1..65d7595d655505 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-msg.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-msg.c
@@ -60,8 +60,8 @@ lnet_build_unlink_event(lnet_libmd_t *md, lnet_event_t *ev)
void
lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
{
- lnet_hdr_t *hdr = &msg->msg_hdr;
- lnet_event_t *ev = &msg->msg_ev;
+ lnet_hdr_t *hdr = &msg->msg_hdr;
+ lnet_event_t *ev = &msg->msg_ev;
LASSERT(!msg->msg_routing);
@@ -73,7 +73,7 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
ev->target.pid = le32_to_cpu(hdr->dest_pid);
ev->initiator.nid = LNET_NID_ANY;
ev->initiator.pid = the_lnet.ln_pid;
- ev->sender = LNET_NID_ANY;
+ ev->sender = LNET_NID_ANY;
} else {
/* event for passive message */
@@ -82,9 +82,9 @@ lnet_build_msg_event(lnet_msg_t *msg, lnet_event_kind_t ev_type)
ev->initiator.pid = hdr->src_pid;
ev->initiator.nid = hdr->src_nid;
ev->rlength = hdr->payload_length;
- ev->sender = msg->msg_from;
- ev->mlength = msg->msg_wanted;
- ev->offset = msg->msg_offset;
+ ev->sender = msg->msg_from;
+ ev->mlength = msg->msg_wanted;
+ ev->offset = msg->msg_offset;
}
switch (ev_type) {
@@ -137,7 +137,7 @@ void
lnet_msg_commit(lnet_msg_t *msg, int cpt)
{
struct lnet_msg_container *container = the_lnet.ln_msg_containers[cpt];
- lnet_counters_t *counters = the_lnet.ln_counters[cpt];
+ lnet_counters_t *counters = the_lnet.ln_counters[cpt];
/* routed message can be committed for both receiving and sending */
LASSERT(!msg->msg_tx_committed);
@@ -170,7 +170,7 @@ static void
lnet_msg_decommit_tx(lnet_msg_t *msg, int status)
{
lnet_counters_t *counters;
- lnet_event_t *ev = &msg->msg_ev;
+ lnet_event_t *ev = &msg->msg_ev;
LASSERT(msg->msg_tx_committed);
if (status != 0)
@@ -219,8 +219,8 @@ lnet_msg_decommit_tx(lnet_msg_t *msg, int status)
static void
lnet_msg_decommit_rx(lnet_msg_t *msg, int status)
{
- lnet_counters_t *counters;
- lnet_event_t *ev = &msg->msg_ev;
+ lnet_counters_t *counters;
+ lnet_event_t *ev = &msg->msg_ev;
LASSERT(!msg->msg_tx_committed); /* decommitted or never committed */
LASSERT(msg->msg_rx_committed);
@@ -273,7 +273,7 @@ lnet_msg_decommit_rx(lnet_msg_t *msg, int status)
void
lnet_msg_decommit(lnet_msg_t *msg, int cpt, int status)
{
- int cpt2 = cpt;
+ int cpt2 = cpt;
LASSERT(msg->msg_tx_committed || msg->msg_rx_committed);
LASSERT(msg->msg_onactivelist);
@@ -335,8 +335,8 @@ lnet_msg_attach_md(lnet_msg_t *msg, lnet_libmd_t *md,
void
lnet_msg_detach_md(lnet_msg_t *msg, int status)
{
- lnet_libmd_t *md = msg->msg_md;
- int unlink;
+ lnet_libmd_t *md = msg->msg_md;
+ int unlink;
/* Now it's safe to drop my caller's ref */
md->md_refcount--;
@@ -359,8 +359,8 @@ static int
lnet_complete_msg_locked(lnet_msg_t *msg, int cpt)
{
lnet_handle_wire_t ack_wmd;
- int rc;
- int status = msg->msg_ev.status;
+ int rc;
+ int status = msg->msg_ev.status;
LASSERT(msg->msg_onactivelist);
@@ -434,11 +434,11 @@ lnet_complete_msg_locked(lnet_msg_t *msg, int cpt)
void
lnet_finalize(lnet_ni_t *ni, lnet_msg_t *msg, int status)
{
- struct lnet_msg_container *container;
- int my_slot;
- int cpt;
- int rc;
- int i;
+ struct lnet_msg_container *container;
+ int my_slot;
+ int cpt;
+ int rc;
+ int i;
LASSERT(!in_interrupt());
@@ -534,7 +534,7 @@ EXPORT_SYMBOL(lnet_finalize);
void
lnet_msg_container_cleanup(struct lnet_msg_container *container)
{
- int count = 0;
+ int count = 0;
if (container->msc_init == 0)
return;
@@ -568,7 +568,7 @@ lnet_msg_container_cleanup(struct lnet_msg_container *container)
int
lnet_msg_container_setup(struct lnet_msg_container *container, int cpt)
{
- int rc;
+ int rc;
container->msc_init = 1;
@@ -608,7 +608,7 @@ void
lnet_msg_containers_destroy(void)
{
struct lnet_msg_container *container;
- int i;
+ int i;
if (the_lnet.ln_msg_containers == NULL)
return;
@@ -624,8 +624,8 @@ int
lnet_msg_containers_create(void)
{
struct lnet_msg_container *container;
- int rc;
- int i;
+ int rc;
+ int i;
the_lnet.ln_msg_containers = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*container));
diff --git a/drivers/staging/lustre/lnet/lnet/lib-ptl.c b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
index 3ba0da919b4188..84707c5cb46472 100644
--- a/drivers/staging/lustre/lnet/lnet/lib-ptl.c
+++ b/drivers/staging/lustre/lnet/lnet/lib-ptl.c
@@ -39,7 +39,7 @@
#include "../../include/linux/lnet/lib-lnet.h"
/* NB: add /proc interfaces in upcoming patches */
-int portal_rotor = LNET_PTL_ROTOR_HASH_RT;
+int portal_rotor = LNET_PTL_ROTOR_HASH_RT;
module_param(portal_rotor, int, 0644);
MODULE_PARM_DESC(portal_rotor, "redirect PUTs to different cpu-partitions");
@@ -47,8 +47,8 @@ static int
lnet_ptl_match_type(unsigned int index, lnet_process_id_t match_id,
__u64 mbits, __u64 ignore_bits)
{
- struct lnet_portal *ptl = the_lnet.ln_portals[index];
- int unique;
+ struct lnet_portal *ptl = the_lnet.ln_portals[index];
+ int unique;
unique = ignore_bits == 0 &&
match_id.nid != LNET_NID_ANY &&
@@ -89,7 +89,7 @@ static void
lnet_ptl_enable_mt(struct lnet_portal *ptl, int cpt)
{
struct lnet_match_table *mtable = ptl->ptl_mtables[cpt];
- int i;
+ int i;
/* with hold of both lnet_res_lock(cpt) and lnet_ptl_lock */
LASSERT(lnet_ptl_is_wildcard(ptl));
@@ -114,7 +114,7 @@ static void
lnet_ptl_disable_mt(struct lnet_portal *ptl, int cpt)
{
struct lnet_match_table *mtable = ptl->ptl_mtables[cpt];
- int i;
+ int i;
/* with hold of both lnet_res_lock(cpt) and lnet_ptl_lock */
LASSERT(lnet_ptl_is_wildcard(ptl));
@@ -141,9 +141,9 @@ lnet_try_match_md(lnet_libmd_t *md,
{
/* ALWAYS called holding the lnet_res_lock, and can't lnet_res_unlock;
* lnet_match_blocked_msg() relies on this to avoid races */
- unsigned int offset;
- unsigned int mlength;
- lnet_me_t *me = md->md_me;
+ unsigned int offset;
+ unsigned int mlength;
+ lnet_me_t *me = md->md_me;
/* MD exhausted */
if (lnet_md_exhausted(md))
@@ -227,7 +227,7 @@ struct lnet_match_table *
lnet_mt_of_attach(unsigned int index, lnet_process_id_t id,
__u64 mbits, __u64 ignore_bits, lnet_ins_pos_t pos)
{
- struct lnet_portal *ptl;
+ struct lnet_portal *ptl;
struct lnet_match_table *mtable;
/* NB: called w/o lock */
@@ -261,11 +261,11 @@ static struct lnet_match_table *
lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg)
{
struct lnet_match_table *mtable;
- struct lnet_portal *ptl;
- unsigned int nmaps;
- unsigned int rotor;
- unsigned int cpt;
- bool routed;
+ struct lnet_portal *ptl;
+ unsigned int nmaps;
+ unsigned int rotor;
+ unsigned int cpt;
+ bool routed;
/* NB: called w/o lock */
LASSERT(info->mi_portal < the_lnet.ln_nportals);
@@ -312,8 +312,8 @@ lnet_mt_of_match(struct lnet_match_info *info, struct lnet_msg *msg)
static int
lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos)
{
- __u64 *bmap;
- int i;
+ __u64 *bmap;
+ int i;
if (!lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal]))
return 0;
@@ -337,7 +337,7 @@ lnet_mt_test_exhausted(struct lnet_match_table *mtable, int pos)
static void
lnet_mt_set_exhausted(struct lnet_match_table *mtable, int pos, int exhausted)
{
- __u64 *bmap;
+ __u64 *bmap;
LASSERT(lnet_ptl_is_wildcard(the_lnet.ln_portals[mtable->mt_portal]));
LASSERT(pos <= LNET_MT_HASH_IGNORE);
@@ -373,11 +373,11 @@ int
lnet_mt_match_md(struct lnet_match_table *mtable,
struct lnet_match_info *info, struct lnet_msg *msg)
{
- struct list_head *head;
- lnet_me_t *me;
- lnet_me_t *tmp;
- int exhausted = 0;
- int rc;
+ struct list_head *head;
+ lnet_me_t *me;
+ lnet_me_t *tmp;
+ int exhausted = 0;
+ int rc;
/* any ME with ignore bits? */
if (!list_empty(&mtable->mt_mhash[LNET_MT_HASH_IGNORE]))
@@ -428,7 +428,7 @@ lnet_mt_match_md(struct lnet_match_table *mtable,
static int
lnet_ptl_match_early(struct lnet_portal *ptl, struct lnet_msg *msg)
{
- int rc;
+ int rc;
/* message arrived before any buffer posting on this portal,
* simply delay or drop this message */
@@ -461,9 +461,9 @@ static int
lnet_ptl_match_delay(struct lnet_portal *ptl,
struct lnet_match_info *info, struct lnet_msg *msg)
{
- int first = ptl->ptl_mt_maps[0]; /* read w/o lock */
- int rc = 0;
- int i;
+ int first = ptl->ptl_mt_maps[0]; /* read w/o lock */
+ int rc = 0;
+ int i;
/* steal buffer from other CPTs, and delay it if nothing to steal,
* this function is more expensive than a regular match, but we
@@ -472,7 +472,7 @@ lnet_ptl_match_delay(struct lnet_portal *ptl,
for (i = 0; i < LNET_CPT_NUMBER; i++) {
struct lnet_match_table *mtable;
- int cpt;
+ int cpt;
cpt = (first + i) % LNET_CPT_NUMBER;
mtable = ptl->ptl_mtables[cpt];
@@ -536,8 +536,8 @@ int
lnet_ptl_match_md(struct lnet_match_info *info, struct lnet_msg *msg)
{
struct lnet_match_table *mtable;
- struct lnet_portal *ptl;
- int rc;
+ struct lnet_portal *ptl;
+ int rc;
CDEBUG(D_NET, "Request from %s of length %d into portal %d MB=%#llx\n",
libcfs_id2str(info->mi_id), info->mi_rlength, info->mi_portal,
@@ -622,13 +622,13 @@ void
lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
struct list_head *matches, struct list_head *drops)
{
- struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal];
+ struct lnet_portal *ptl = the_lnet.ln_portals[me->me_portal];
struct lnet_match_table *mtable;
- struct list_head *head;
- lnet_msg_t *tmp;
- lnet_msg_t *msg;
- int exhausted = 0;
- int cpt;
+ struct list_head *head;
+ lnet_msg_t *tmp;
+ lnet_msg_t *msg;
+ int exhausted = 0;
+ int cpt;
LASSERT(md->md_refcount == 0); /* a brand new MD */
@@ -647,20 +647,20 @@ lnet_ptl_attach_md(lnet_me_t *me, lnet_libmd_t *md,
head = &ptl->ptl_msg_stealing;
again:
list_for_each_entry_safe(msg, tmp, head, msg_list) {
- struct lnet_match_info info;
- lnet_hdr_t *hdr;
- int rc;
+ struct lnet_match_info info;
+ lnet_hdr_t *hdr;
+ int rc;
LASSERT(msg->msg_rx_delayed || head == &ptl->ptl_msg_stealing);
- hdr = &msg->msg_hdr;
- info.mi_id.nid = hdr->src_nid;
- info.mi_id.pid = hdr->src_pid;
- info.mi_opc = LNET_MD_OP_PUT;
- info.mi_portal = hdr->msg.put.ptl_index;
- info.mi_rlength = hdr->payload_length;
- info.mi_roffset = hdr->msg.put.offset;
- info.mi_mbits = hdr->msg.put.match_bits;
+ hdr = &msg->msg_hdr;
+ info.mi_id.nid = hdr->src_nid;
+ info.mi_id.pid = hdr->src_pid;
+ info.mi_opc = LNET_MD_OP_PUT;
+ info.mi_portal = hdr->msg.put.ptl_index;
+ info.mi_rlength = hdr->payload_length;
+ info.mi_roffset = hdr->msg.put.offset;
+ info.mi_mbits = hdr->msg.put.match_bits;
rc = lnet_try_match_md(md, &info, msg);
@@ -715,7 +715,7 @@ static void
lnet_ptl_cleanup(struct lnet_portal *ptl)
{
struct lnet_match_table *mtable;
- int i;
+ int i;
if (ptl->ptl_mtables == NULL) /* uninitialized portal */
return;
@@ -723,9 +723,9 @@ lnet_ptl_cleanup(struct lnet_portal *ptl)
LASSERT(list_empty(&ptl->ptl_msg_delayed));
LASSERT(list_empty(&ptl->ptl_msg_stealing));
cfs_percpt_for_each(mtable, i, ptl->ptl_mtables) {
- struct list_head *mhash;
- lnet_me_t *me;
- int j;
+ struct list_head *mhash;
+ lnet_me_t *me;
+ int j;
if (mtable->mt_mhash == NULL) /* uninitialized match-table */
continue;
@@ -753,9 +753,9 @@ static int
lnet_ptl_setup(struct lnet_portal *ptl, int index)
{
struct lnet_match_table *mtable;
- struct list_head *mhash;
- int i;
- int j;
+ struct list_head *mhash;
+ int i;
+ int j;
ptl->ptl_mtables = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(struct lnet_match_table));
@@ -798,7 +798,7 @@ lnet_ptl_setup(struct lnet_portal *ptl, int index)
void
lnet_portals_destroy(void)
{
- int i;
+ int i;
if (the_lnet.ln_portals == NULL)
return;
@@ -813,8 +813,8 @@ lnet_portals_destroy(void)
int
lnet_portals_create(void)
{
- int size;
- int i;
+ int size;
+ int i;
size = offsetof(struct lnet_portal, ptl_mt_maps[LNET_CPT_NUMBER]);
@@ -898,8 +898,8 @@ EXPORT_SYMBOL(LNetSetLazyPortal);
int
LNetClearLazyPortal(int portal)
{
- struct lnet_portal *ptl;
- LIST_HEAD (zombies);
+ struct lnet_portal *ptl;
+ LIST_HEAD(zombies);
if (portal < 0 || portal >= the_lnet.ln_nportals)
return -EINVAL;
diff --git a/drivers/staging/lustre/lnet/lnet/lo.c b/drivers/staging/lustre/lnet/lnet/lo.c
index f708c2e649d790..2a137f46800fdd 100644
--- a/drivers/staging/lustre/lnet/lnet/lo.c
+++ b/drivers/staging/lustre/lnet/lnet/lo.c
@@ -111,7 +111,7 @@ lnd_t the_lolnd = {
/* .lnd_type = */ LOLND,
/* .lnd_startup = */ lolnd_startup,
/* .lnd_shutdown = */ lolnd_shutdown,
- /* .lnt_ctl = */ NULL,
+ /* .lnt_ctl = */ NULL,
/* .lnd_send = */ lolnd_send,
/* .lnd_recv = */ lolnd_recv,
/* .lnd_eager_recv = */ NULL,
diff --git a/drivers/staging/lustre/lnet/lnet/module.c b/drivers/staging/lustre/lnet/lnet/module.c
index 72b7fbc837180b..6881b9cf32ce8d 100644
--- a/drivers/staging/lustre/lnet/lnet/module.c
+++ b/drivers/staging/lustre/lnet/lnet/module.c
@@ -47,9 +47,9 @@ static int
lnet_configure(void *arg)
{
/* 'arg' only there so I can be passed to cfs_create_thread() */
- int rc = 0;
+ int rc = 0;
- LNET_MUTEX_LOCK(&lnet_config_mutex);
+ mutex_lock(&lnet_config_mutex);
if (!the_lnet.ln_niinit_self) {
rc = LNetNIInit(LUSTRE_SRV_LNET_PID);
@@ -59,34 +59,34 @@ lnet_configure(void *arg)
}
}
- LNET_MUTEX_UNLOCK(&lnet_config_mutex);
+ mutex_unlock(&lnet_config_mutex);
return rc;
}
static int
lnet_unconfigure(void)
{
- int refcount;
+ int refcount;
- LNET_MUTEX_LOCK(&lnet_config_mutex);
+ mutex_lock(&lnet_config_mutex);
if (the_lnet.ln_niinit_self) {
the_lnet.ln_niinit_self = 0;
LNetNIFini();
}
- LNET_MUTEX_LOCK(&the_lnet.ln_api_mutex);
+ mutex_lock(&the_lnet.ln_api_mutex);
refcount = the_lnet.ln_refcount;
- LNET_MUTEX_UNLOCK(&the_lnet.ln_api_mutex);
+ mutex_unlock(&the_lnet.ln_api_mutex);
- LNET_MUTEX_UNLOCK(&lnet_config_mutex);
+ mutex_unlock(&lnet_config_mutex);
return (refcount == 0) ? 0 : -EBUSY;
}
static int
lnet_ioctl(unsigned int cmd, struct libcfs_ioctl_data *data)
{
- int rc;
+ int rc;
switch (cmd) {
case IOC_LIBCFS_CONFIGURE:
@@ -113,7 +113,7 @@ static DECLARE_IOCTL_HANDLER(lnet_ioctl_handler, lnet_ioctl);
static int __init
init_lnet(void)
{
- int rc;
+ int rc;
mutex_init(&lnet_config_mutex);
@@ -147,7 +147,7 @@ fini_lnet(void)
}
MODULE_AUTHOR("Peter J. Braam <braam@clusterfs.com>");
-MODULE_DESCRIPTION("Portals v3.1");
+MODULE_DESCRIPTION("LNet v3.1");
MODULE_LICENSE("GPL");
MODULE_VERSION("1.0.0");
diff --git a/drivers/staging/lustre/lnet/lnet/peer.c b/drivers/staging/lustre/lnet/lnet/peer.c
index 45b5742f1bd270..1fceed3c8fc0c2 100644
--- a/drivers/staging/lustre/lnet/lnet/peer.c
+++ b/drivers/staging/lustre/lnet/lnet/peer.c
@@ -43,10 +43,10 @@
int
lnet_peer_tables_create(void)
{
- struct lnet_peer_table *ptable;
- struct list_head *hash;
- int i;
- int j;
+ struct lnet_peer_table *ptable;
+ struct list_head *hash;
+ int i;
+ int j;
the_lnet.ln_peer_tables = cfs_percpt_alloc(lnet_cpt_table(),
sizeof(*ptable));
@@ -77,10 +77,10 @@ lnet_peer_tables_create(void)
void
lnet_peer_tables_destroy(void)
{
- struct lnet_peer_table *ptable;
- struct list_head *hash;
- int i;
- int j;
+ struct lnet_peer_table *ptable;
+ struct list_head *hash;
+ int i;
+ int j;
if (the_lnet.ln_peer_tables == NULL)
return;
@@ -106,9 +106,9 @@ lnet_peer_tables_destroy(void)
void
lnet_peer_tables_cleanup(void)
{
- struct lnet_peer_table *ptable;
- int i;
- int j;
+ struct lnet_peer_table *ptable;
+ int i;
+ int j;
LASSERT(the_lnet.ln_shutdown); /* i.e. no new peers */
@@ -133,7 +133,7 @@ lnet_peer_tables_cleanup(void)
cfs_percpt_for_each(ptable, i, the_lnet.ln_peer_tables) {
LIST_HEAD(deathrow);
- lnet_peer_t *lp;
+ lnet_peer_t *lp;
lnet_net_lock(i);
@@ -186,8 +186,8 @@ lnet_destroy_peer_locked(lnet_peer_t *lp)
lnet_peer_t *
lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid)
{
- struct list_head *peers;
- lnet_peer_t *lp;
+ struct list_head *peers;
+ lnet_peer_t *lp;
LASSERT(!the_lnet.ln_shutdown);
@@ -205,11 +205,11 @@ lnet_find_peer_locked(struct lnet_peer_table *ptable, lnet_nid_t nid)
int
lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt)
{
- struct lnet_peer_table *ptable;
- lnet_peer_t *lp = NULL;
- lnet_peer_t *lp2;
- int cpt2;
- int rc = 0;
+ struct lnet_peer_table *ptable;
+ lnet_peer_t *lp = NULL;
+ lnet_peer_t *lp2;
+ int cpt2;
+ int rc = 0;
*lpp = NULL;
if (the_lnet.ln_shutdown) /* it's shutting down */
@@ -287,8 +287,8 @@ lnet_nid2peer_locked(lnet_peer_t **lpp, lnet_nid_t nid, int cpt)
goto out;
}
- lp->lp_txcredits =
- lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
+ lp->lp_txcredits =
+ lp->lp_mintxcredits = lp->lp_ni->ni_peertxcredits;
lp->lp_rtrcredits =
lp->lp_minrtrcredits = lnet_peer_buffer_credits(lp->lp_ni);
@@ -308,10 +308,10 @@ out:
void
lnet_debug_peer(lnet_nid_t nid)
{
- char *aliveness = "NA";
- lnet_peer_t *lp;
- int rc;
- int cpt;
+ char *aliveness = "NA";
+ lnet_peer_t *lp;
+ int rc;
+ int cpt;
cpt = lnet_cpt_of_nid(nid);
lnet_net_lock(cpt);
diff --git a/drivers/staging/lustre/lnet/lnet/router.c b/drivers/staging/lustre/lnet/lnet/router.c
index 8510bae4822a8f..96886a2b45719a 100644
--- a/drivers/staging/lustre/lnet/lnet/router.c
+++ b/drivers/staging/lustre/lnet/lnet/router.c
@@ -139,8 +139,8 @@ lnet_notify_locked(lnet_peer_t *lp, int notifylnd, int alive,
static void
lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
{
- int alive;
- int notifylnd;
+ int alive;
+ int notifylnd;
/* Notify only in 1 thread at any time to ensure ordered notification.
* NB individual events can be missed; the only guarantee is that you
@@ -152,7 +152,7 @@ lnet_ni_notify_locked(lnet_ni_t *ni, lnet_peer_t *lp)
lp->lp_notifying = 1;
while (lp->lp_notify) {
- alive = lp->lp_alive;
+ alive = lp->lp_alive;
notifylnd = lp->lp_notifylnd;
lp->lp_notifylnd = 0;
@@ -228,9 +228,9 @@ lnet_rtr_decref_locked(lnet_peer_t *lp)
lnet_remotenet_t *
lnet_find_net_locked(__u32 net)
{
- lnet_remotenet_t *rnet;
- struct list_head *tmp;
- struct list_head *rn_list;
+ lnet_remotenet_t *rnet;
+ struct list_head *tmp;
+ struct list_head *rn_list;
LASSERT(!the_lnet.ln_shutdown);
@@ -276,9 +276,9 @@ static void lnet_shuffle_seed(void)
static void
lnet_add_route_to_rnet(lnet_remotenet_t *rnet, lnet_route_t *route)
{
- unsigned int len = 0;
- unsigned int offset = 0;
- struct list_head *e;
+ unsigned int len = 0;
+ unsigned int offset = 0;
+ struct list_head *e;
lnet_shuffle_seed();
@@ -304,13 +304,13 @@ int
lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
unsigned int priority)
{
- struct list_head *e;
- lnet_remotenet_t *rnet;
- lnet_remotenet_t *rnet2;
- lnet_route_t *route;
- lnet_ni_t *ni;
- int add_route;
- int rc;
+ struct list_head *e;
+ lnet_remotenet_t *rnet;
+ lnet_remotenet_t *rnet2;
+ lnet_route_t *route;
+ lnet_ni_t *ni;
+ int add_route;
+ int rc;
CDEBUG(D_NET, "Add route: net %s hops %u priority %u gw %s\n",
libcfs_net2str(net), hops, priority, libcfs_nid2str(gateway));
@@ -416,14 +416,14 @@ lnet_add_route(__u32 net, unsigned int hops, lnet_nid_t gateway,
int
lnet_check_routes(void)
{
- lnet_remotenet_t *rnet;
- lnet_route_t *route;
- lnet_route_t *route2;
- struct list_head *e1;
- struct list_head *e2;
- int cpt;
- struct list_head *rn_list;
- int i;
+ lnet_remotenet_t *rnet;
+ lnet_route_t *route;
+ lnet_route_t *route2;
+ struct list_head *e1;
+ struct list_head *e2;
+ int cpt;
+ struct list_head *rn_list;
+ int i;
cpt = lnet_net_lock_current();
@@ -434,9 +434,9 @@ lnet_check_routes(void)
route2 = NULL;
list_for_each(e2, &rnet->lrn_routes) {
- lnet_nid_t nid1;
- lnet_nid_t nid2;
- int net;
+ lnet_nid_t nid1;
+ lnet_nid_t nid2;
+ int net;
route = list_entry(e2, lnet_route_t,
lr_list);
@@ -472,14 +472,14 @@ lnet_check_routes(void)
int
lnet_del_route(__u32 net, lnet_nid_t gw_nid)
{
- struct lnet_peer *gateway;
- lnet_remotenet_t *rnet;
- lnet_route_t *route;
- struct list_head *e1;
- struct list_head *e2;
- int rc = -ENOENT;
- struct list_head *rn_list;
- int idx = 0;
+ struct lnet_peer *gateway;
+ lnet_remotenet_t *rnet;
+ lnet_route_t *route;
+ struct list_head *e1;
+ struct list_head *e2;
+ int rc = -ENOENT;
+ struct list_head *rn_list;
+ int idx = 0;
CDEBUG(D_NET, "Del route: net %s : gw %s\n",
libcfs_net2str(net), libcfs_nid2str(gw_nid));
@@ -554,13 +554,13 @@ int
lnet_get_route(int idx, __u32 *net, __u32 *hops,
lnet_nid_t *gateway, __u32 *alive, __u32 *priority)
{
- struct list_head *e1;
- struct list_head *e2;
- lnet_remotenet_t *rnet;
- lnet_route_t *route;
- int cpt;
- int i;
- struct list_head *rn_list;
+ struct list_head *e1;
+ struct list_head *e2;
+ lnet_remotenet_t *rnet;
+ lnet_route_t *route;
+ int cpt;
+ int i;
+ struct list_head *rn_list;
cpt = lnet_net_lock_current();
@@ -574,11 +574,11 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops,
lr_list);
if (idx-- == 0) {
- *net = rnet->lrn_net;
- *hops = route->lr_hops;
+ *net = rnet->lrn_net;
+ *hops = route->lr_hops;
*priority = route->lr_priority;
*gateway = route->lr_gateway->lp_nid;
- *alive = route->lr_gateway->lp_alive;
+ *alive = route->lr_gateway->lp_alive;
lnet_net_unlock(cpt);
return 0;
}
@@ -593,7 +593,7 @@ lnet_get_route(int idx, __u32 *net, __u32 *hops,
void
lnet_swap_pinginfo(lnet_ping_info_t *info)
{
- int i;
+ int i;
lnet_ni_status_t *stat;
__swab32s(&info->pi_magic);
@@ -614,9 +614,9 @@ lnet_swap_pinginfo(lnet_ping_info_t *info)
static void
lnet_parse_rc_info(lnet_rc_data_t *rcd)
{
- lnet_ping_info_t *info = rcd->rcd_pinginfo;
- struct lnet_peer *gw = rcd->rcd_gateway;
- lnet_route_t *rtr;
+ lnet_ping_info_t *info = rcd->rcd_pinginfo;
+ struct lnet_peer *gw = rcd->rcd_gateway;
+ lnet_route_t *rtr;
if (!gw->lp_alive)
return;
@@ -643,14 +643,14 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd)
return; /* can't carry NI status info */
list_for_each_entry(rtr, &gw->lp_routes, lr_gwlist) {
- int ptl_status = LNET_NI_STATUS_INVALID;
- int down = 0;
- int up = 0;
- int i;
+ int ptl_status = LNET_NI_STATUS_INVALID;
+ int down = 0;
+ int up = 0;
+ int i;
for (i = 0; i < info->pi_nnis && i < LNET_MAX_RTR_NIS; i++) {
lnet_ni_status_t *stat = &info->pi_ni[i];
- lnet_nid_t nid = stat->ns_nid;
+ lnet_nid_t nid = stat->ns_nid;
if (nid == LNET_NID_ANY) {
CDEBUG(D_NET, "%s: unexpected LNET_NID_ANY\n",
@@ -699,8 +699,8 @@ lnet_parse_rc_info(lnet_rc_data_t *rcd)
static void
lnet_router_checker_event(lnet_event_t *event)
{
- lnet_rc_data_t *rcd = event->md.user_ptr;
- struct lnet_peer *lp;
+ lnet_rc_data_t *rcd = event->md.user_ptr;
+ struct lnet_peer *lp;
LASSERT(rcd != NULL);
@@ -752,14 +752,14 @@ lnet_router_checker_event(lnet_event_t *event)
static void
lnet_wait_known_routerstate(void)
{
- lnet_peer_t *rtr;
- struct list_head *entry;
- int all_known;
+ lnet_peer_t *rtr;
+ struct list_head *entry;
+ int all_known;
LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
for (;;) {
- int cpt = lnet_net_lock_current();
+ int cpt = lnet_net_lock_current();
all_known = 1;
list_for_each(entry, &the_lnet.ln_routers) {
@@ -799,9 +799,9 @@ lnet_router_ni_update_locked(lnet_peer_t *gw, __u32 net)
static void
lnet_update_ni_status_locked(void)
{
- lnet_ni_t *ni;
- long now;
- int timeout;
+ lnet_ni_t *ni;
+ long now;
+ int timeout;
LASSERT(the_lnet.ln_routing);
@@ -860,10 +860,10 @@ lnet_destroy_rc_data(lnet_rc_data_t *rcd)
static lnet_rc_data_t *
lnet_create_rc_data_locked(lnet_peer_t *gateway)
{
- lnet_rc_data_t *rcd = NULL;
- lnet_ping_info_t *pi;
- int rc;
- int i;
+ lnet_rc_data_t *rcd = NULL;
+ lnet_ping_info_t *pi;
+ int rc;
+ int i;
lnet_net_unlock(gateway->lp_cpt);
@@ -943,8 +943,8 @@ static void
lnet_ping_router_locked(lnet_peer_t *rtr)
{
lnet_rc_data_t *rcd = NULL;
- unsigned long now = cfs_time_current();
- int secs;
+ unsigned long now = cfs_time_current();
+ int secs;
lnet_peer_addref_locked(rtr);
@@ -979,9 +979,9 @@ lnet_ping_router_locked(lnet_peer_t *rtr)
if (secs != 0 && !rtr->lp_ping_notsent &&
cfs_time_after(now, cfs_time_add(rtr->lp_ping_timestamp,
cfs_time_seconds(secs)))) {
- int rc;
+ int rc;
lnet_process_id_t id;
- lnet_handle_md_t mdh;
+ lnet_handle_md_t mdh;
id.nid = rtr->lp_nid;
id.pid = LUSTRE_SRV_LNET_PID;
@@ -1013,8 +1013,8 @@ lnet_ping_router_locked(lnet_peer_t *rtr)
int
lnet_router_checker_start(void)
{
- int rc;
- int eqsz;
+ int rc;
+ int eqsz;
LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_SHUTDOWN);
@@ -1085,11 +1085,11 @@ lnet_router_checker_stop(void)
static void
lnet_prune_rc_data(int wait_unlink)
{
- lnet_rc_data_t *rcd;
- lnet_rc_data_t *tmp;
- lnet_peer_t *lp;
- struct list_head head;
- int i = 2;
+ lnet_rc_data_t *rcd;
+ lnet_rc_data_t *tmp;
+ lnet_peer_t *lp;
+ struct list_head head;
+ int i = 2;
if (likely(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING &&
list_empty(&the_lnet.ln_rcd_deathrow) &&
@@ -1169,17 +1169,17 @@ lnet_prune_rc_data(int wait_unlink)
static int
lnet_router_checker(void *arg)
{
- lnet_peer_t *rtr;
- struct list_head *entry;
+ lnet_peer_t *rtr;
+ struct list_head *entry;
cfs_block_allsigs();
LASSERT(the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING);
while (the_lnet.ln_rc_state == LNET_RC_STATE_RUNNING) {
- __u64 version;
- int cpt;
- int cpt2;
+ __u64 version;
+ int cpt;
+ int cpt2;
cpt = lnet_net_lock_current();
rescan:
@@ -1245,11 +1245,11 @@ lnet_destroy_rtrbuf(lnet_rtrbuf_t *rb, int npages)
static lnet_rtrbuf_t *
lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
{
- int npages = rbp->rbp_npages;
- int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
- struct page *page;
+ int npages = rbp->rbp_npages;
+ int sz = offsetof(lnet_rtrbuf_t, rb_kiov[npages]);
+ struct page *page;
lnet_rtrbuf_t *rb;
- int i;
+ int i;
LIBCFS_CPT_ALLOC(rb, lnet_cpt_table(), cpt, sz);
if (rb == NULL)
@@ -1280,9 +1280,9 @@ lnet_new_rtrbuf(lnet_rtrbufpool_t *rbp, int cpt)
static void
lnet_rtrpool_free_bufs(lnet_rtrbufpool_t *rbp)
{
- int npages = rbp->rbp_npages;
- int nbuffers = 0;
- lnet_rtrbuf_t *rb;
+ int npages = rbp->rbp_npages;
+ int nbuffers = 0;
+ lnet_rtrbuf_t *rb;
if (rbp->rbp_nbuffers == 0) /* not initialized or already freed */
return;
@@ -1310,7 +1310,7 @@ static int
lnet_rtrpool_alloc_bufs(lnet_rtrbufpool_t *rbp, int nbufs, int cpt)
{
lnet_rtrbuf_t *rb;
- int i;
+ int i;
if (rbp->rbp_nbuffers != 0) {
LASSERT(rbp->rbp_nbuffers == nbufs);
@@ -1355,7 +1355,7 @@ void
lnet_rtrpools_free(void)
{
lnet_rtrbufpool_t *rtrp;
- int i;
+ int i;
if (the_lnet.ln_rtrpools == NULL) /* uninitialized or freed */
return;
@@ -1373,7 +1373,7 @@ lnet_rtrpools_free(void)
static int
lnet_nrb_tiny_calculate(int npages)
{
- int nrbs = LNET_NRB_TINY;
+ int nrbs = LNET_NRB_TINY;
if (tiny_router_buffers < 0) {
LCONSOLE_ERROR_MSG(0x10c,
@@ -1392,7 +1392,7 @@ lnet_nrb_tiny_calculate(int npages)
static int
lnet_nrb_small_calculate(int npages)
{
- int nrbs = LNET_NRB_SMALL;
+ int nrbs = LNET_NRB_SMALL;
if (small_router_buffers < 0) {
LCONSOLE_ERROR_MSG(0x10c,
@@ -1411,7 +1411,7 @@ lnet_nrb_small_calculate(int npages)
static int
lnet_nrb_large_calculate(int npages)
{
- int nrbs = LNET_NRB_LARGE;
+ int nrbs = LNET_NRB_LARGE;
if (large_router_buffers < 0) {
LCONSOLE_ERROR_MSG(0x10c,
@@ -1431,13 +1431,13 @@ int
lnet_rtrpools_alloc(int im_a_router)
{
lnet_rtrbufpool_t *rtrp;
- int large_pages;
- int small_pages = 1;
- int nrb_tiny;
- int nrb_small;
- int nrb_large;
- int rc;
- int i;
+ int large_pages;
+ int small_pages = 1;
+ int nrb_tiny;
+ int nrb_small;
+ int nrb_large;
+ int rc;
+ int i;
large_pages = (LNET_MTU + PAGE_CACHE_SIZE - 1) >> PAGE_CACHE_SHIFT;
@@ -1507,9 +1507,9 @@ lnet_rtrpools_alloc(int im_a_router)
int
lnet_notify(lnet_ni_t *ni, lnet_nid_t nid, int alive, unsigned long when)
{
- struct lnet_peer *lp = NULL;
- unsigned long now = cfs_time_current();
- int cpt = lnet_cpt_of_nid(nid);
+ struct lnet_peer *lp = NULL;
+ unsigned long now = cfs_time_current();
+ int cpt = lnet_cpt_of_nid(nid);
LASSERT(!in_interrupt ());
@@ -1591,13 +1591,13 @@ void
lnet_router_checker(void)
{
static time_t last;
- static int running;
+ static int running;
- time_t now = get_seconds();
- int interval = now - last;
- int rc;
- __u64 version;
- lnet_peer_t *rtr;
+ time_t now = get_seconds();
+ int interval = now - last;
+ int rc;
+ __u64 version;
+ lnet_peer_t *rtr;
/* It's no use to call me again within a sec - all intervals and
* timeouts are measured in seconds */
@@ -1625,7 +1625,7 @@ lnet_router_checker(void)
/* consume all pending events */
while (1) {
- int i;
+ int i;
lnet_event_t ev;
/* NB ln_rc_eqh must be the 1st in 'eventqs' otherwise the
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index c055afc86eb44f..ee902dc43823ff 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -112,11 +112,11 @@ static int proc_call_handler(void *data, int write, loff_t *ppos,
static int __proc_lnet_stats(void *data, int write,
loff_t pos, void __user *buffer, int nob)
{
- int rc;
+ int rc;
lnet_counters_t *ctrs;
- int len;
- char *tmpstr;
- const int tmpsiz = 256; /* 7 %u and 4 %llu */
+ int len;
+ char *tmpstr;
+ const int tmpsiz = 256; /* 7 %u and 4 %llu */
if (write) {
lnet_counters_reset();
@@ -167,13 +167,13 @@ static int proc_lnet_stats(struct ctl_table *table, int write,
static int proc_lnet_routes(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- const int tmpsiz = 256;
- char *tmpstr;
- char *s;
- int rc = 0;
- int len;
- int ver;
- int off;
+ const int tmpsiz = 256;
+ char *tmpstr;
+ char *s;
+ int rc = 0;
+ int len;
+ int ver;
+ int off;
CLASSERT(sizeof(loff_t) >= 4);
@@ -205,13 +205,13 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
lnet_net_unlock(0);
*ppos = LNET_PROC_POS_MAKE(0, ver, 0, off);
} else {
- struct list_head *n;
- struct list_head *r;
- lnet_route_t *route = NULL;
- lnet_remotenet_t *rnet = NULL;
- int skip = off - 1;
- struct list_head *rn_list;
- int i;
+ struct list_head *n;
+ struct list_head *r;
+ lnet_route_t *route = NULL;
+ lnet_remotenet_t *rnet = NULL;
+ int skip = off - 1;
+ struct list_head *rn_list;
+ int i;
lnet_net_lock(0);
@@ -251,11 +251,11 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
}
if (route != NULL) {
- __u32 net = rnet->lrn_net;
- unsigned int hops = route->lr_hops;
- unsigned int priority = route->lr_priority;
- lnet_nid_t nid = route->lr_gateway->lp_nid;
- int alive = route->lr_gateway->lp_alive;
+ __u32 net = rnet->lrn_net;
+ unsigned int hops = route->lr_hops;
+ unsigned int priority = route->lr_priority;
+ lnet_nid_t nid = route->lr_gateway->lp_nid;
+ int alive = route->lr_gateway->lp_alive;
s += snprintf(s, tmpstr + tmpsiz - s,
"%-8s %4u %8u %7s %s\n",
@@ -293,13 +293,13 @@ static int proc_lnet_routes(struct ctl_table *table, int write,
static int proc_lnet_routers(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- int rc = 0;
- char *tmpstr;
- char *s;
- const int tmpsiz = 256;
- int len;
- int ver;
- int off;
+ int rc = 0;
+ char *tmpstr;
+ char *s;
+ const int tmpsiz = 256;
+ int len;
+ int ver;
+ int off;
off = LNET_PROC_HOFF_GET(*ppos);
ver = LNET_PROC_VER_GET(*ppos);
@@ -328,9 +328,9 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
lnet_net_unlock(0);
*ppos = LNET_PROC_POS_MAKE(0, ver, 0, off);
} else {
- struct list_head *r;
- struct lnet_peer *peer = NULL;
- int skip = off - 1;
+ struct list_head *r;
+ struct lnet_peer *peer = NULL;
+ int skip = off - 1;
lnet_net_lock(0);
@@ -360,14 +360,14 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
lnet_nid_t nid = peer->lp_nid;
unsigned long now = cfs_time_current();
unsigned long deadline = peer->lp_ping_deadline;
- int nrefs = peer->lp_refcount;
- int nrtrrefs = peer->lp_rtr_refcount;
+ int nrefs = peer->lp_refcount;
+ int nrtrrefs = peer->lp_rtr_refcount;
int alive_cnt = peer->lp_alive_count;
- int alive = peer->lp_alive;
- int pingsent = !peer->lp_ping_notsent;
+ int alive = peer->lp_alive;
+ int pingsent = !peer->lp_ping_notsent;
int last_ping = cfs_duration_sec(cfs_time_sub(now,
peer->lp_ping_timestamp));
- int down_ni = 0;
+ int down_ni = 0;
lnet_route_t *rtr;
if ((peer->lp_ping_feats &
@@ -428,16 +428,16 @@ static int proc_lnet_routers(struct ctl_table *table, int write,
static int proc_lnet_peers(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- const int tmpsiz = 256;
- struct lnet_peer_table *ptable;
- char *tmpstr;
- char *s;
- int cpt = LNET_PROC_CPT_GET(*ppos);
- int ver = LNET_PROC_VER_GET(*ppos);
- int hash = LNET_PROC_HASH_GET(*ppos);
- int hoff = LNET_PROC_HOFF_GET(*ppos);
- int rc = 0;
- int len;
+ const int tmpsiz = 256;
+ struct lnet_peer_table *ptable;
+ char *tmpstr;
+ char *s;
+ int cpt = LNET_PROC_CPT_GET(*ppos);
+ int ver = LNET_PROC_VER_GET(*ppos);
+ int hash = LNET_PROC_HASH_GET(*ppos);
+ int hoff = LNET_PROC_HOFF_GET(*ppos);
+ int rc = 0;
+ int len;
CLASSERT(LNET_PROC_HASH_BITS >= LNET_PEER_HASH_BITS);
LASSERT(!write);
@@ -465,9 +465,9 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
hoff++;
} else {
- struct lnet_peer *peer;
- struct list_head *p;
- int skip;
+ struct lnet_peer *peer;
+ struct list_head *p;
+ int skip;
again:
p = NULL;
peer = NULL;
@@ -521,23 +521,23 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
}
if (peer != NULL) {
- lnet_nid_t nid = peer->lp_nid;
- int nrefs = peer->lp_refcount;
- int lastalive = -1;
- char *aliveness = "NA";
- int maxcr = peer->lp_ni->ni_peertxcredits;
- int txcr = peer->lp_txcredits;
- int mintxcr = peer->lp_mintxcredits;
- int rtrcr = peer->lp_rtrcredits;
- int minrtrcr = peer->lp_minrtrcredits;
- int txqnob = peer->lp_txqnob;
+ lnet_nid_t nid = peer->lp_nid;
+ int nrefs = peer->lp_refcount;
+ int lastalive = -1;
+ char *aliveness = "NA";
+ int maxcr = peer->lp_ni->ni_peertxcredits;
+ int txcr = peer->lp_txcredits;
+ int mintxcr = peer->lp_mintxcredits;
+ int rtrcr = peer->lp_rtrcredits;
+ int minrtrcr = peer->lp_minrtrcredits;
+ int txqnob = peer->lp_txqnob;
if (lnet_isrouter(peer) ||
lnet_peer_aliveness_enabled(peer))
aliveness = peer->lp_alive ? "up" : "down";
if (lnet_peer_aliveness_enabled(peer)) {
- unsigned long now = cfs_time_current();
+ unsigned long now = cfs_time_current();
long delta;
delta = cfs_time_sub(now, peer->lp_last_alive);
@@ -595,13 +595,13 @@ static int proc_lnet_peers(struct ctl_table *table, int write,
static int __proc_lnet_buffers(void *data, int write,
loff_t pos, void __user *buffer, int nob)
{
- char *s;
- char *tmpstr;
- int tmpsiz;
- int idx;
- int len;
- int rc;
- int i;
+ char *s;
+ char *tmpstr;
+ int tmpsiz;
+ int idx;
+ int len;
+ int rc;
+ int i;
LASSERT(!write);
@@ -660,11 +660,11 @@ static int proc_lnet_buffers(struct ctl_table *table, int write,
static int proc_lnet_nis(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
- int tmpsiz = 128 * LNET_CPT_NUMBER;
- int rc = 0;
- char *tmpstr;
- char *s;
- int len;
+ int tmpsiz = 128 * LNET_CPT_NUMBER;
+ int rc = 0;
+ char *tmpstr;
+ char *s;
+ int len;
LASSERT(!write);
@@ -684,9 +684,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
"rtr", "max", "tx", "min");
LASSERT(tmpstr + tmpsiz - s > 0);
} else {
- struct list_head *n;
- lnet_ni_t *ni = NULL;
- int skip = *ppos - 1;
+ struct list_head *n;
+ lnet_ni_t *ni = NULL;
+ int skip = *ppos - 1;
lnet_net_lock(0);
@@ -705,12 +705,12 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
}
if (ni != NULL) {
- struct lnet_tx_queue *tq;
- char *stat;
- long now = get_seconds();
- int last_alive = -1;
- int i;
- int j;
+ struct lnet_tx_queue *tq;
+ char *stat;
+ long now = get_seconds();
+ int last_alive = -1;
+ int i;
+ int j;
if (the_lnet.ln_routing)
last_alive = now - ni->ni_last_alive;
@@ -777,9 +777,9 @@ static int proc_lnet_nis(struct ctl_table *table, int write,
}
struct lnet_portal_rotors {
- int pr_value;
- const char *pr_name;
- const char *pr_desc;
+ int pr_value;
+ const char *pr_name;
+ const char *pr_desc;
};
static struct lnet_portal_rotors portal_rotors[] = {
@@ -815,11 +815,11 @@ extern int portal_rotor;
static int __proc_lnet_portal_rotor(void *data, int write,
loff_t pos, void __user *buffer, int nob)
{
- const int buf_len = 128;
- char *buf;
- char *tmp;
- int rc;
- int i;
+ const int buf_len = 128;
+ char *buf;
+ char *tmp;
+ int rc;
+ int i;
LIBCFS_ALLOC(buf, buf_len);
if (buf == NULL)
@@ -887,38 +887,38 @@ static struct ctl_table lnet_table[] = {
* to go via /proc for portability.
*/
{
- .procname = "stats",
- .mode = 0644,
+ .procname = "stats",
+ .mode = 0644,
.proc_handler = &proc_lnet_stats,
},
{
- .procname = "routes",
- .mode = 0444,
+ .procname = "routes",
+ .mode = 0444,
.proc_handler = &proc_lnet_routes,
},
{
- .procname = "routers",
- .mode = 0444,
+ .procname = "routers",
+ .mode = 0444,
.proc_handler = &proc_lnet_routers,
},
{
- .procname = "peers",
- .mode = 0444,
+ .procname = "peers",
+ .mode = 0444,
.proc_handler = &proc_lnet_peers,
},
{
- .procname = "buffers",
- .mode = 0444,
+ .procname = "buffers",
+ .mode = 0444,
.proc_handler = &proc_lnet_buffers,
},
{
- .procname = "nis",
- .mode = 0444,
+ .procname = "nis",
+ .mode = 0444,
.proc_handler = &proc_lnet_nis,
},
{
- .procname = "portal_rotor",
- .mode = 0644,
+ .procname = "portal_rotor",
+ .mode = 0644,
.proc_handler = &proc_lnet_portal_rotor,
},
{
diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
index 658f4584fff868..de11f1bc8be767 100644
--- a/drivers/staging/lustre/lnet/selftest/brw_test.c
+++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
@@ -91,7 +91,7 @@ brw_client_init(sfw_test_instance_t *tsi)
len = npg * PAGE_CACHE_SIZE;
} else {
- test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1;
+ test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1;
/* I should never get this step if it's unknown feature
* because make_session will reject unknown feature */
@@ -223,7 +223,7 @@ bad_data:
static void
brw_fill_bulk(srpc_bulk_t *bk, int pattern, __u64 magic)
{
- int i;
+ int i;
struct page *pg;
for (i = 0; i < bk->bk_niov; i++) {
@@ -235,7 +235,7 @@ brw_fill_bulk(srpc_bulk_t *bk, int pattern, __u64 magic)
static int
brw_check_bulk(srpc_bulk_t *bk, int pattern, __u64 magic)
{
- int i;
+ int i;
struct page *pg;
for (i = 0; i < bk->bk_niov; i++) {
@@ -254,16 +254,16 @@ static int
brw_client_prep_rpc(sfw_test_unit_t *tsu,
lnet_process_id_t dest, srpc_client_rpc_t **rpcpp)
{
- srpc_bulk_t *bulk = tsu->tsu_private;
+ srpc_bulk_t *bulk = tsu->tsu_private;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_session_t *sn = tsi->tsi_batch->bat_session;
- srpc_client_rpc_t *rpc;
- srpc_brw_reqst_t *req;
- int flags;
- int npg;
- int len;
- int opc;
- int rc;
+ sfw_session_t *sn = tsi->tsi_batch->bat_session;
+ srpc_client_rpc_t *rpc;
+ srpc_brw_reqst_t *req;
+ int flags;
+ int npg;
+ int len;
+ int opc;
+ int rc;
LASSERT(sn != NULL);
LASSERT(bulk != NULL);
@@ -277,7 +277,7 @@ brw_client_prep_rpc(sfw_test_unit_t *tsu,
len = npg * PAGE_CACHE_SIZE;
} else {
- test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1;
+ test_bulk_req_v1_t *breq = &tsi->tsi_u.bulk_v1;
/* I should never get this step if it's unknown feature
* because make_session will reject unknown feature */
@@ -311,12 +311,12 @@ brw_client_prep_rpc(sfw_test_unit_t *tsu,
static void
brw_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
{
- __u64 magic = BRW_MAGIC;
+ __u64 magic = BRW_MAGIC;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_session_t *sn = tsi->tsi_batch->bat_session;
- srpc_msg_t *msg = &rpc->crpc_replymsg;
- srpc_brw_reply_t *reply = &msg->msg_body.brw_reply;
- srpc_brw_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.brw_reqst;
+ sfw_session_t *sn = tsi->tsi_batch->bat_session;
+ srpc_msg_t *msg = &rpc->crpc_replymsg;
+ srpc_brw_reply_t *reply = &msg->msg_body.brw_reply;
+ srpc_brw_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.brw_reqst;
LASSERT(sn != NULL);
@@ -380,10 +380,10 @@ brw_server_rpc_done(srpc_server_rpc_t *rpc)
static int
brw_bulk_ready(srpc_server_rpc_t *rpc, int status)
{
- __u64 magic = BRW_MAGIC;
+ __u64 magic = BRW_MAGIC;
srpc_brw_reply_t *reply = &rpc->srpc_replymsg.msg_body.brw_reply;
srpc_brw_reqst_t *reqst;
- srpc_msg_t *reqstmsg;
+ srpc_msg_t *reqstmsg;
LASSERT(rpc->srpc_bulk != NULL);
LASSERT(rpc->srpc_reqstbuf != NULL);
@@ -416,13 +416,13 @@ brw_bulk_ready(srpc_server_rpc_t *rpc, int status)
static int
brw_server_handle(struct srpc_server_rpc *rpc)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- srpc_msg_t *replymsg = &rpc->srpc_replymsg;
- srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ srpc_msg_t *replymsg = &rpc->srpc_replymsg;
+ srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
srpc_brw_reply_t *reply = &replymsg->msg_body.brw_reply;
srpc_brw_reqst_t *reqst = &reqstmsg->msg_body.brw_reqst;
- int npg;
- int rc;
+ int npg;
+ int rc;
LASSERT(sv->sv_id == SRPC_SERVICE_BRW);
@@ -490,17 +490,17 @@ brw_server_handle(struct srpc_server_rpc *rpc)
sfw_test_client_ops_t brw_test_client;
void brw_init_test_client(void)
{
- brw_test_client.tso_init = brw_client_init;
- brw_test_client.tso_fini = brw_client_fini;
- brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
- brw_test_client.tso_done_rpc = brw_client_done_rpc;
+ brw_test_client.tso_init = brw_client_init;
+ brw_test_client.tso_fini = brw_client_fini;
+ brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
+ brw_test_client.tso_done_rpc = brw_client_done_rpc;
};
srpc_service_t brw_test_service;
void brw_init_test_service(void)
{
- brw_test_service.sv_id = SRPC_SERVICE_BRW;
+ brw_test_service.sv_id = SRPC_SERVICE_BRW;
brw_test_service.sv_name = "brw_test";
brw_test_service.sv_handler = brw_server_handle;
brw_test_service.sv_bulk_ready = brw_bulk_ready;
diff --git a/drivers/staging/lustre/lnet/selftest/conctl.c b/drivers/staging/lustre/lnet/selftest/conctl.c
index 045fe295ad5409..1a7870e91f23a5 100644
--- a/drivers/staging/lustre/lnet/selftest/conctl.c
+++ b/drivers/staging/lustre/lnet/selftest/conctl.c
@@ -48,11 +48,11 @@
static int
lst_session_new_ioctl(lstio_session_new_args_t *args)
{
- char *name;
- int rc;
+ char *name;
+ int rc;
if (args->lstio_ses_idp == NULL || /* address for output sid */
- args->lstio_ses_key == 0 || /* no key is specified */
+ args->lstio_ses_key == 0 || /* no key is specified */
args->lstio_ses_namep == NULL || /* session name */
args->lstio_ses_nmlen <= 0 ||
args->lstio_ses_nmlen > LST_NAME_SIZE)
@@ -96,12 +96,12 @@ lst_session_info_ioctl(lstio_session_info_args_t *args)
{
/* no checking of key */
- if (args->lstio_ses_idp == NULL || /* address for output sid */
- args->lstio_ses_keyp == NULL || /* address for output key */
+ if (args->lstio_ses_idp == NULL || /* address for output sid */
+ args->lstio_ses_keyp == NULL || /* address for output key */
args->lstio_ses_featp == NULL || /* address for output features */
args->lstio_ses_ndinfo == NULL || /* address for output ndinfo */
- args->lstio_ses_namep == NULL || /* address for output name */
- args->lstio_ses_nmlen <= 0 ||
+ args->lstio_ses_namep == NULL || /* address for output name */
+ args->lstio_ses_nmlen <= 0 ||
args->lstio_ses_nmlen > LST_NAME_SIZE)
return -EINVAL;
@@ -197,8 +197,8 @@ out:
static int
lst_group_add_ioctl(lstio_group_add_args_t *args)
{
- char *name;
- int rc;
+ char *name;
+ int rc;
if (args->lstio_grp_key != console_session.ses_key)
return -EACCES;
@@ -324,8 +324,8 @@ static int
lst_nodes_add_ioctl(lstio_group_nodes_args_t *args)
{
unsigned feats;
- int rc;
- char *name;
+ int rc;
+ char *name;
if (args->lstio_grp_key != console_session.ses_key)
return -EACCES;
@@ -385,10 +385,10 @@ lst_group_list_ioctl(lstio_group_list_args_t *args)
static int
lst_group_info_ioctl(lstio_group_info_args_t *args)
{
- char *name;
- int ndent;
- int index;
- int rc;
+ char *name;
+ int ndent;
+ int index;
+ int rc;
if (args->lstio_grp_key != console_session.ses_key)
return -EACCES;
@@ -449,8 +449,8 @@ lst_group_info_ioctl(lstio_group_info_args_t *args)
static int
lst_batch_add_ioctl(lstio_batch_add_args_t *args)
{
- int rc;
- char *name;
+ int rc;
+ char *name;
if (args->lstio_bat_key != console_session.ses_key)
return -EACCES;
@@ -483,8 +483,8 @@ lst_batch_add_ioctl(lstio_batch_add_args_t *args)
static int
lst_batch_run_ioctl(lstio_batch_run_args_t *args)
{
- int rc;
- char *name;
+ int rc;
+ char *name;
if (args->lstio_bat_key != console_session.ses_key)
return -EACCES;
@@ -518,8 +518,8 @@ lst_batch_run_ioctl(lstio_batch_run_args_t *args)
static int
lst_batch_stop_ioctl(lstio_batch_stop_args_t *args)
{
- int rc;
- char *name;
+ int rc;
+ char *name;
if (args->lstio_bat_key != console_session.ses_key)
return -EACCES;
@@ -613,10 +613,10 @@ lst_batch_list_ioctl(lstio_batch_list_args_t *args)
static int
lst_batch_info_ioctl(lstio_batch_info_args_t *args)
{
- char *name;
- int rc;
- int index;
- int ndent;
+ char *name;
+ int rc;
+ int index;
+ int ndent;
if (args->lstio_bat_key != console_session.ses_key)
return -EACCES;
@@ -678,8 +678,8 @@ lst_batch_info_ioctl(lstio_batch_info_args_t *args)
static int
lst_stat_query_ioctl(lstio_stat_args_t *args)
{
- int rc;
- char *name;
+ int rc;
+ char *name;
/* TODO: not finished */
if (args->lstio_sta_key != console_session.ses_key)
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.c b/drivers/staging/lustre/lnet/selftest/conrpc.c
index 77f02b76128e0a..a1a4e08f739155 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.c
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.c
@@ -117,8 +117,8 @@ static int
lstcon_rpc_prep(lstcon_node_t *nd, int service, unsigned feats,
int bulk_npg, int bulk_len, lstcon_rpc_t **crpcpp)
{
- lstcon_rpc_t *crpc = NULL;
- int rc;
+ lstcon_rpc_t *crpc = NULL;
+ int rc;
spin_lock(&console_session.ses_rpc_lock);
@@ -151,7 +151,7 @@ void
lstcon_rpc_put(lstcon_rpc_t *crpc)
{
srpc_bulk_t *bulk = &crpc->crp_rpc->crpc_bulk;
- int i;
+ int i;
LASSERT(list_empty(&crpc->crp_link));
@@ -336,8 +336,8 @@ lstcon_rpc_trans_check(lstcon_rpc_trans_t *trans)
int
lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
{
- lstcon_rpc_t *crpc;
- int rc;
+ lstcon_rpc_t *crpc;
+ int rc;
if (list_empty(&trans->tas_rpcs_list))
return 0;
@@ -386,8 +386,8 @@ lstcon_rpc_trans_postwait(lstcon_rpc_trans_t *trans, int timeout)
static int
lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
{
- lstcon_node_t *nd = crpc->crp_node;
- srpc_client_rpc_t *rpc = crpc->crp_rpc;
+ lstcon_node_t *nd = crpc->crp_node;
+ srpc_client_rpc_t *rpc = crpc->crp_rpc;
srpc_generic_reply_t *rep;
LASSERT(nd != NULL && rpc != NULL);
@@ -423,9 +423,9 @@ lstcon_rpc_get_reply(lstcon_rpc_t *crpc, srpc_msg_t **msgpp)
void
lstcon_rpc_trans_stat(lstcon_rpc_trans_t *trans, lstcon_trans_stat_t *stat)
{
- lstcon_rpc_t *crpc;
- srpc_msg_t *rep;
- int error;
+ lstcon_rpc_t *crpc;
+ srpc_msg_t *rep;
+ int error;
LASSERT(stat != NULL);
@@ -470,16 +470,16 @@ lstcon_rpc_trans_interpreter(lstcon_rpc_trans_t *trans,
struct list_head *head_up,
lstcon_rpc_readent_func_t readent)
{
- struct list_head tmp;
- struct list_head *next;
- lstcon_rpc_ent_t *ent;
+ struct list_head tmp;
+ struct list_head *next;
+ lstcon_rpc_ent_t *ent;
srpc_generic_reply_t *rep;
- lstcon_rpc_t *crpc;
- srpc_msg_t *msg;
- lstcon_node_t *nd;
- long dur;
- struct timeval tv;
- int error;
+ lstcon_rpc_t *crpc;
+ srpc_msg_t *msg;
+ lstcon_node_t *nd;
+ long dur;
+ struct timeval tv;
+ int error;
LASSERT(head_up != NULL);
@@ -544,9 +544,9 @@ void
lstcon_rpc_trans_destroy(lstcon_rpc_trans_t *trans)
{
srpc_client_rpc_t *rpc;
- lstcon_rpc_t *crpc;
- lstcon_rpc_t *tmp;
- int count = 0;
+ lstcon_rpc_t *crpc;
+ lstcon_rpc_t *tmp;
+ int count = 0;
list_for_each_entry_safe(crpc, tmp, &trans->tas_rpcs_list,
crp_link) {
@@ -601,7 +601,7 @@ lstcon_sesrpc_prep(lstcon_node_t *nd, int transop,
{
srpc_mksn_reqst_t *msrq;
srpc_rmsn_reqst_t *rsrq;
- int rc;
+ int rc;
switch (transop) {
case LST_TRANS_SESNEW:
@@ -638,7 +638,7 @@ int
lstcon_dbgrpc_prep(lstcon_node_t *nd, unsigned feats, lstcon_rpc_t **crpc)
{
srpc_debug_reqst_t *drq;
- int rc;
+ int rc;
rc = lstcon_rpc_prep(nd, SRPC_SERVICE_DEBUG, feats, 0, 0, crpc);
if (rc != 0)
@@ -707,7 +707,7 @@ static lnet_process_id_packed_t *
lstcon_next_id(int idx, int nkiov, lnet_kiov_t *kiov)
{
lnet_process_id_packed_t *pid;
- int i;
+ int i;
i = idx / SFW_ID_PER_PAGE;
@@ -723,11 +723,11 @@ lstcon_dstnodes_prep(lstcon_group_t *grp, int idx,
int dist, int span, int nkiov, lnet_kiov_t *kiov)
{
lnet_process_id_packed_t *pid;
- lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- int start;
- int end;
- int i = 0;
+ lstcon_ndlink_t *ndl;
+ lstcon_node_t *nd;
+ int start;
+ int end;
+ int i = 0;
LASSERT(dist >= 1);
LASSERT(span >= 1);
@@ -777,8 +777,8 @@ lstcon_pingrpc_prep(lst_test_ping_param_t *param, srpc_test_reqst_t *req)
{
test_ping_req_t *prq = &req->tsr_u.ping;
- prq->png_size = param->png_size;
- prq->png_flags = param->png_flags;
+ prq->png_size = param->png_size;
+ prq->png_flags = param->png_flags;
/* TODO dest */
return 0;
}
@@ -788,9 +788,10 @@ lstcon_bulkrpc_v0_prep(lst_test_bulk_param_t *param, srpc_test_reqst_t *req)
{
test_bulk_req_t *brq = &req->tsr_u.bulk_v0;
- brq->blk_opc = param->blk_opc;
- brq->blk_npg = (param->blk_size + PAGE_CACHE_SIZE - 1) / PAGE_CACHE_SIZE;
- brq->blk_flags = param->blk_flags;
+ brq->blk_opc = param->blk_opc;
+ brq->blk_npg = (param->blk_size + PAGE_CACHE_SIZE - 1) /
+ PAGE_CACHE_SIZE;
+ brq->blk_flags = param->blk_flags;
return 0;
}
@@ -816,7 +817,7 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
lstcon_group_t *dgrp = test->tes_dst_grp;
srpc_test_reqst_t *trq;
srpc_bulk_t *bulk;
- int i;
+ int i;
int npg = 0;
int nob = 0;
int rc = 0;
@@ -835,8 +836,10 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
trq = &(*crpc)->crp_rpc->crpc_reqstmsg.msg_body.tes_reqst;
if (transop == LST_TRANS_TSBSRVADD) {
- int ndist = (sgrp->grp_nnode + test->tes_dist - 1) / test->tes_dist;
- int nspan = (dgrp->grp_nnode + test->tes_span - 1) / test->tes_span;
+ int ndist = (sgrp->grp_nnode + test->tes_dist - 1) /
+ test->tes_dist;
+ int nspan = (dgrp->grp_nnode + test->tes_span - 1) /
+ test->tes_span;
int nmax = (ndist + nspan - 1) / nspan;
trq->tsr_ndest = 0;
@@ -851,7 +854,8 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
LASSERT(nob > 0);
len = (feats & LST_FEAT_BULK_LEN) == 0 ?
- PAGE_CACHE_SIZE : min_t(int, nob, PAGE_CACHE_SIZE);
+ PAGE_CACHE_SIZE :
+ min_t(int, nob, PAGE_CACHE_SIZE);
nob -= len;
bulk->bk_iovs[i].kiov_offset = 0;
@@ -883,8 +887,8 @@ lstcon_testrpc_prep(lstcon_node_t *nd, int transop, unsigned feats,
trq->tsr_loop = test->tes_loop;
}
- trq->tsr_sid = console_session.ses_id;
- trq->tsr_bid = test->tes_hdr.tsb_id;
+ trq->tsr_sid = console_session.ses_id;
+ trq->tsr_bid = test->tes_hdr.tsb_id;
trq->tsr_concur = test->tes_concur;
trq->tsr_is_client = (transop == LST_TRANS_TSBCLIADD) ? 1 : 0;
trq->tsr_stop_onerr = !!test->tes_stop_onerr;
@@ -966,7 +970,7 @@ lstcon_rpc_stat_reply(lstcon_rpc_trans_t *trans, srpc_msg_t *msg,
srpc_batch_reply_t *bat_rep;
srpc_test_reply_t *test_rep;
srpc_stat_reply_t *stat_rep;
- int rc = 0;
+ int rc = 0;
switch (trans->tas_opc) {
case LST_TRANS_SESNEW:
@@ -1084,11 +1088,11 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
lstcon_rpc_trans_t **transpp)
{
lstcon_rpc_trans_t *trans;
- lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- lstcon_rpc_t *rpc;
- unsigned feats;
- int rc;
+ lstcon_ndlink_t *ndl;
+ lstcon_node_t *nd;
+ lstcon_rpc_t *rpc;
+ unsigned feats;
+ int rc;
/* Creating session RPG for list of nodes */
@@ -1165,16 +1169,16 @@ lstcon_rpc_trans_ndlist(struct list_head *ndlist,
static void
lstcon_rpc_pinger(void *arg)
{
- stt_timer_t *ptimer = (stt_timer_t *)arg;
+ stt_timer_t *ptimer = (stt_timer_t *)arg;
lstcon_rpc_trans_t *trans;
- lstcon_rpc_t *crpc;
- srpc_msg_t *rep;
+ lstcon_rpc_t *crpc;
+ srpc_msg_t *rep;
srpc_debug_reqst_t *drq;
- lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- time_t intv;
- int count = 0;
- int rc;
+ lstcon_ndlink_t *ndl;
+ lstcon_node_t *nd;
+ time_t intv;
+ int count = 0;
+ int rc;
/* RPC pinger is a special case of transaction,
* it's called by timer at 8 seconds interval.
@@ -1283,8 +1287,8 @@ lstcon_rpc_pinger(void *arg)
int
lstcon_rpc_pinger_start(void)
{
- stt_timer_t *ptimer;
- int rc;
+ stt_timer_t *ptimer;
+ int rc;
LASSERT(list_empty(&console_session.ses_rpc_freelist));
LASSERT(atomic_read(&console_session.ses_rpc_counter) == 0);
@@ -1324,9 +1328,9 @@ void
lstcon_rpc_cleanup_wait(void)
{
lstcon_rpc_trans_t *trans;
- lstcon_rpc_t *crpc;
- struct list_head *pacer;
- struct list_head zlist;
+ lstcon_rpc_t *crpc;
+ struct list_head *pacer;
+ struct list_head zlist;
/* Called with hold of global mutex */
diff --git a/drivers/staging/lustre/lnet/selftest/conrpc.h b/drivers/staging/lustre/lnet/selftest/conrpc.h
index 2353889c6eacc9..7d33cf9e9d998e 100644
--- a/drivers/staging/lustre/lnet/selftest/conrpc.h
+++ b/drivers/staging/lustre/lnet/selftest/conrpc.h
@@ -64,31 +64,29 @@ struct lstcon_test;
struct lstcon_node;
typedef struct lstcon_rpc {
- struct list_head crp_link; /* chain on rpc transaction */
+ struct list_head crp_link; /* chain on rpc transaction */
srpc_client_rpc_t *crp_rpc; /* client rpc */
- struct lstcon_node *crp_node; /* destination node */
+ struct lstcon_node *crp_node; /* destination node */
struct lstcon_rpc_trans *crp_trans; /* conrpc transaction */
- unsigned int crp_posted:1; /* rpc is posted */
- unsigned int crp_finished:1; /* rpc is finished */
- unsigned int crp_unpacked:1; /* reply is unpacked */
+ unsigned int crp_posted:1; /* rpc is posted */
+ unsigned int crp_finished:1; /* rpc is finished */
+ unsigned int crp_unpacked:1; /* reply is unpacked */
/** RPC is embedded in other structure and can't free it */
- unsigned int crp_embedded:1;
- int crp_status; /* console rpc errors */
- unsigned long crp_stamp; /* replied time stamp */
+ unsigned int crp_embedded:1;
+ int crp_status; /* console rpc errors */
+ unsigned long crp_stamp; /* replied time stamp */
} lstcon_rpc_t;
typedef struct lstcon_rpc_trans {
- struct list_head tas_olink; /* link chain on owner list */
- struct list_head tas_link; /* link chain on global list */
- int tas_opc; /* operation code of transaction */
- /* features mask is uptodate */
- unsigned tas_feats_updated;
- /* test features mask */
- unsigned tas_features;
- wait_queue_head_t tas_waitq; /* wait queue head */
- atomic_t tas_remaining; /* # of un-scheduled rpcs */
- struct list_head tas_rpcs_list; /* queued requests */
+ struct list_head tas_olink; /* link chain on owner list */
+ struct list_head tas_link; /* link chain on global list */
+ int tas_opc; /* operation code of transaction */
+ unsigned tas_feats_updated; /* features mask is uptodate */
+ unsigned tas_features; /* test features mask */
+ wait_queue_head_t tas_waitq; /* wait queue head */
+ atomic_t tas_remaining; /* # of un-scheduled rpcs */
+ struct list_head tas_rpcs_list; /* queued requests */
} lstcon_rpc_trans_t;
#define LST_TRANS_PRIVATE 0x1000
diff --git a/drivers/staging/lustre/lnet/selftest/console.c b/drivers/staging/lustre/lnet/selftest/console.c
index 2b5f53c7a73001..f47c8f27f975a8 100644
--- a/drivers/staging/lustre/lnet/selftest/console.c
+++ b/drivers/staging/lustre/lnet/selftest/console.c
@@ -59,7 +59,7 @@ do { \
(p)->nle_nnode++; \
} while (0)
-lstcon_session_t console_session;
+lstcon_session_t console_session;
static void
lstcon_node_get(lstcon_node_t *nd)
@@ -73,7 +73,7 @@ static int
lstcon_node_find(lnet_process_id_t id, lstcon_node_t **ndpp, int create)
{
lstcon_ndlink_t *ndl;
- unsigned int idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE;
+ unsigned int idx = LNET_NIDADDR(id.nid) % LST_GLOBAL_HASHSIZE;
LASSERT(id.nid != LNET_NID_ANY);
@@ -117,7 +117,7 @@ lstcon_node_find(lnet_process_id_t id, lstcon_node_t **ndpp, int create)
static void
lstcon_node_put(lstcon_node_t *nd)
{
- lstcon_ndlink_t *ndl;
+ lstcon_ndlink_t *ndl;
LASSERT(nd->nd_ref > 0);
@@ -140,10 +140,10 @@ static int
lstcon_ndlink_find(struct list_head *hash,
lnet_process_id_t id, lstcon_ndlink_t **ndlpp, int create)
{
- unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
+ unsigned int idx = LNET_NIDADDR(id.nid) % LST_NODE_HASHSIZE;
lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- int rc;
+ lstcon_node_t *nd;
+ int rc;
if (id.nid == LNET_NID_ANY)
return -EINVAL;
@@ -197,7 +197,7 @@ static int
lstcon_group_alloc(char *name, lstcon_group_t **grpp)
{
lstcon_group_t *grp;
- int i;
+ int i;
LIBCFS_ALLOC(grp, offsetof(lstcon_group_t,
grp_ndl_hash[LST_NODE_HASHSIZE]));
@@ -243,7 +243,7 @@ lstcon_group_drain(lstcon_group_t *grp, int keep)
static void
lstcon_group_decref(lstcon_group_t *grp)
{
- int i;
+ int i;
if (--grp->grp_ref > 0)
return;
@@ -264,7 +264,7 @@ lstcon_group_decref(lstcon_group_t *grp)
static int
lstcon_group_find(const char *name, lstcon_group_t **grpp)
{
- lstcon_group_t *grp;
+ lstcon_group_t *grp;
list_for_each_entry(grp, &console_session.ses_grp_list, grp_link) {
if (strncmp(grp->grp_name, name, LST_NAME_SIZE) != 0)
@@ -288,7 +288,7 @@ static int
lstcon_group_ndlink_find(lstcon_group_t *grp, lnet_process_id_t id,
lstcon_ndlink_t **ndlpp, int create)
{
- int rc;
+ int rc;
rc = lstcon_ndlink_find(&grp->grp_ndl_hash[0], id, ndlpp, create);
if (rc != 0)
@@ -404,12 +404,12 @@ lstcon_group_nodes_add(lstcon_group_t *grp,
int count, lnet_process_id_t *ids_up,
unsigned *featp, struct list_head *result_up)
{
- lstcon_rpc_trans_t *trans;
- lstcon_ndlink_t *ndl;
- lstcon_group_t *tmp;
- lnet_process_id_t id;
- int i;
- int rc;
+ lstcon_rpc_trans_t *trans;
+ lstcon_ndlink_t *ndl;
+ lstcon_group_t *tmp;
+ lnet_process_id_t id;
+ int i;
+ int rc;
rc = lstcon_group_alloc(NULL, &tmp);
if (rc != 0) {
@@ -471,12 +471,12 @@ lstcon_group_nodes_remove(lstcon_group_t *grp,
int count, lnet_process_id_t *ids_up,
struct list_head *result_up)
{
- lstcon_rpc_trans_t *trans;
- lstcon_ndlink_t *ndl;
- lstcon_group_t *tmp;
- lnet_process_id_t id;
- int rc;
- int i;
+ lstcon_rpc_trans_t *trans;
+ lstcon_ndlink_t *ndl;
+ lstcon_group_t *tmp;
+ lnet_process_id_t id;
+ int rc;
+ int i;
/* End session and remove node from the group */
@@ -525,7 +525,7 @@ int
lstcon_group_add(char *name)
{
lstcon_group_t *grp;
- int rc;
+ int rc;
rc = (lstcon_group_find(name, &grp) == 0)? -EEXIST: 0;
if (rc != 0) {
@@ -549,8 +549,8 @@ int
lstcon_nodes_add(char *name, int count, lnet_process_id_t *ids_up,
unsigned *featp, struct list_head *result_up)
{
- lstcon_group_t *grp;
- int rc;
+ lstcon_group_t *grp;
+ int rc;
LASSERT(count > 0);
LASSERT(ids_up != NULL);
@@ -580,8 +580,8 @@ int
lstcon_group_del(char *name)
{
lstcon_rpc_trans_t *trans;
- lstcon_group_t *grp;
- int rc;
+ lstcon_group_t *grp;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -621,7 +621,7 @@ int
lstcon_group_clean(char *name, int args)
{
lstcon_group_t *grp = NULL;
- int rc;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -654,7 +654,7 @@ lstcon_nodes_remove(char *name, int count,
lnet_process_id_t *ids_up, struct list_head *result_up)
{
lstcon_group_t *grp = NULL;
- int rc;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -682,9 +682,9 @@ lstcon_nodes_remove(char *name, int count,
int
lstcon_group_refresh(char *name, struct list_head *result_up)
{
- lstcon_rpc_trans_t *trans;
- lstcon_group_t *grp;
- int rc;
+ lstcon_rpc_trans_t *trans;
+ lstcon_group_t *grp;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -743,10 +743,10 @@ static int
lstcon_nodes_getent(struct list_head *head, int *index_p,
int *count_p, lstcon_node_ent_t *dents_up)
{
- lstcon_ndlink_t *ndl;
- lstcon_node_t *nd;
- int count = 0;
- int index = 0;
+ lstcon_ndlink_t *ndl;
+ lstcon_node_t *nd;
+ int count = 0;
+ int index = 0;
LASSERT(index_p != NULL && count_p != NULL);
LASSERT(dents_up != NULL);
@@ -784,9 +784,9 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t *gents_p,
int *index_p, int *count_p, lstcon_node_ent_t *dents_up)
{
lstcon_ndlist_ent_t *gentp;
- lstcon_group_t *grp;
- lstcon_ndlink_t *ndl;
- int rc;
+ lstcon_group_t *grp;
+ lstcon_ndlink_t *ndl;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0) {
@@ -828,7 +828,7 @@ lstcon_group_info(char *name, lstcon_ndlist_ent_t *gents_p,
static int
lstcon_batch_find(const char *name, lstcon_batch_t **batpp)
{
- lstcon_batch_t *bat;
+ lstcon_batch_t *bat;
list_for_each_entry(bat, &console_session.ses_bat_list, bat_link) {
if (strncmp(bat->bat_name, name, LST_NAME_SIZE) == 0) {
@@ -843,9 +843,9 @@ lstcon_batch_find(const char *name, lstcon_batch_t **batpp)
int
lstcon_batch_add(char *name)
{
- lstcon_batch_t *bat;
- int i;
- int rc;
+ lstcon_batch_t *bat;
+ int i;
+ int rc;
rc = (lstcon_batch_find(name, &bat) == 0)? -EEXIST: 0;
if (rc != 0) {
@@ -903,7 +903,7 @@ lstcon_batch_add(char *name)
int
lstcon_batch_list(int index, int len, char *name_up)
{
- lstcon_batch_t *bat;
+ lstcon_batch_t *bat;
LASSERT(name_up != NULL);
LASSERT(index >= 0);
@@ -924,12 +924,12 @@ lstcon_batch_info(char *name, lstcon_test_batch_ent_t *ent_up, int server,
lstcon_node_ent_t *dents_up)
{
lstcon_test_batch_ent_t *entp;
- struct list_head *clilst;
- struct list_head *srvlst;
- lstcon_test_t *test = NULL;
- lstcon_batch_t *bat;
- lstcon_ndlink_t *ndl;
- int rc;
+ struct list_head *clilst;
+ struct list_head *srvlst;
+ lstcon_test_t *test = NULL;
+ lstcon_batch_t *bat;
+ lstcon_ndlink_t *ndl;
+ int rc;
rc = lstcon_batch_find(name, &bat);
if (rc != 0) {
@@ -1018,7 +1018,7 @@ lstcon_batch_op(lstcon_batch_t *bat, int transop,
struct list_head *result_up)
{
lstcon_rpc_trans_t *trans;
- int rc;
+ int rc;
rc = lstcon_rpc_trans_ndlist(&bat->bat_cli_list,
&bat->bat_trans_list, transop,
@@ -1041,7 +1041,7 @@ int
lstcon_batch_run(char *name, int timeout, struct list_head *result_up)
{
lstcon_batch_t *bat;
- int rc;
+ int rc;
if (lstcon_batch_find(name, &bat) != 0) {
CDEBUG(D_NET, "Can't find batch %s\n", name);
@@ -1063,7 +1063,7 @@ int
lstcon_batch_stop(char *name, int force, struct list_head *result_up)
{
lstcon_batch_t *bat;
- int rc;
+ int rc;
if (lstcon_batch_find(name, &bat) != 0) {
CDEBUG(D_NET, "Can't find batch %s\n", name);
@@ -1084,9 +1084,9 @@ lstcon_batch_stop(char *name, int force, struct list_head *result_up)
static void
lstcon_batch_destroy(lstcon_batch_t *bat)
{
- lstcon_ndlink_t *ndl;
- lstcon_test_t *test;
- int i;
+ lstcon_ndlink_t *ndl;
+ lstcon_test_t *test;
+ int i;
list_del(&bat->bat_link);
@@ -1137,11 +1137,11 @@ lstcon_batch_destroy(lstcon_batch_t *bat)
static int
lstcon_testrpc_condition(int transop, lstcon_node_t *nd, void *arg)
{
- lstcon_test_t *test;
- lstcon_batch_t *batch;
- lstcon_ndlink_t *ndl;
- struct list_head *hash;
- struct list_head *head;
+ lstcon_test_t *test;
+ lstcon_batch_t *batch;
+ lstcon_ndlink_t *ndl;
+ struct list_head *hash;
+ struct list_head *head;
test = (lstcon_test_t *)arg;
LASSERT(test != NULL);
@@ -1181,10 +1181,10 @@ lstcon_testrpc_condition(int transop, lstcon_node_t *nd, void *arg)
static int
lstcon_test_nodes_add(lstcon_test_t *test, struct list_head *result_up)
{
- lstcon_rpc_trans_t *trans;
- lstcon_group_t *grp;
- int transop;
- int rc;
+ lstcon_rpc_trans_t *trans;
+ lstcon_group_t *grp;
+ int transop;
+ int rc;
LASSERT(test->tes_src_grp != NULL);
LASSERT(test->tes_dst_grp != NULL);
@@ -1251,8 +1251,8 @@ lstcon_verify_batch(const char *name, lstcon_batch_t **batch)
static int
lstcon_verify_group(const char *name, lstcon_group_t **grp)
{
- int rc;
- lstcon_ndlink_t *ndl;
+ int rc;
+ lstcon_ndlink_t *ndl;
rc = lstcon_group_find(name, grp);
if (rc != 0) {
@@ -1398,13 +1398,13 @@ lstcon_test_batch_query(char *name, int testidx, int client,
int timeout, struct list_head *result_up)
{
lstcon_rpc_trans_t *trans;
- struct list_head *translist;
- struct list_head *ndlist;
- lstcon_tsb_hdr_t *hdr;
- lstcon_batch_t *batch;
- lstcon_test_t *test = NULL;
- int transop;
- int rc;
+ struct list_head *translist;
+ struct list_head *ndlist;
+ lstcon_tsb_hdr_t *hdr;
+ lstcon_batch_t *batch;
+ lstcon_test_t *test = NULL;
+ int transop;
+ int rc;
rc = lstcon_batch_find(name, &batch);
if (rc != 0) {
@@ -1460,9 +1460,9 @@ lstcon_statrpc_readent(int transop, srpc_msg_t *msg,
lstcon_rpc_ent_t *ent_up)
{
srpc_stat_reply_t *rep = &msg->msg_body.stat_reply;
- sfw_counters_t *sfwk_stat;
- srpc_counters_t *srpc_stat;
- lnet_counters_t *lnet_stat;
+ sfw_counters_t *sfwk_stat;
+ srpc_counters_t *srpc_stat;
+ lnet_counters_t *lnet_stat;
if (rep->str_status != 0)
return 0;
@@ -1483,9 +1483,9 @@ static int
lstcon_ndlist_stat(struct list_head *ndlist,
int timeout, struct list_head *result_up)
{
- struct list_head head;
+ struct list_head head;
lstcon_rpc_trans_t *trans;
- int rc;
+ int rc;
INIT_LIST_HEAD(&head);
@@ -1508,8 +1508,8 @@ lstcon_ndlist_stat(struct list_head *ndlist,
int
lstcon_group_stat(char *grp_name, int timeout, struct list_head *result_up)
{
- lstcon_group_t *grp;
- int rc;
+ lstcon_group_t *grp;
+ int rc;
rc = lstcon_group_find(grp_name, &grp);
if (rc != 0) {
@@ -1528,11 +1528,11 @@ int
lstcon_nodes_stat(int count, lnet_process_id_t *ids_up,
int timeout, struct list_head *result_up)
{
- lstcon_ndlink_t *ndl;
- lstcon_group_t *tmp;
- lnet_process_id_t id;
- int i;
- int rc;
+ lstcon_ndlink_t *ndl;
+ lstcon_group_t *tmp;
+ lnet_process_id_t id;
+ int i;
+ int rc;
rc = lstcon_group_alloc(NULL, &tmp);
if (rc != 0) {
@@ -1604,7 +1604,7 @@ lstcon_batch_debug(int timeout, char *name,
int client, struct list_head *result_up)
{
lstcon_batch_t *bat;
- int rc;
+ int rc;
rc = lstcon_batch_find(name, &bat);
if (rc != 0)
@@ -1622,7 +1622,7 @@ lstcon_group_debug(int timeout, char *name,
struct list_head *result_up)
{
lstcon_group_t *grp;
- int rc;
+ int rc;
rc = lstcon_group_find(name, &grp);
if (rc != 0)
@@ -1640,11 +1640,11 @@ lstcon_nodes_debug(int timeout,
int count, lnet_process_id_t *ids_up,
struct list_head *result_up)
{
- lnet_process_id_t id;
- lstcon_ndlink_t *ndl;
- lstcon_group_t *grp;
- int i;
- int rc;
+ lnet_process_id_t id;
+ lstcon_ndlink_t *ndl;
+ lstcon_group_t *grp;
+ int i;
+ int rc;
rc = lstcon_group_alloc(NULL, &grp);
if (rc != 0) {
@@ -1689,7 +1689,7 @@ lstcon_session_match(lst_sid_t sid)
static void
lstcon_new_session_id(lst_sid_t *sid)
{
- lnet_process_id_t id;
+ lnet_process_id_t id;
LASSERT(console_session.ses_state == LST_SESSION_NONE);
@@ -1704,8 +1704,8 @@ int
lstcon_session_new(char *name, int key, unsigned feats,
int timeout, int force, lst_sid_t *sid_up)
{
- int rc = 0;
- int i;
+ int rc = 0;
+ int i;
if (console_session.ses_state != LST_SESSION_NONE) {
/* session exists */
@@ -1733,9 +1733,9 @@ lstcon_session_new(char *name, int key, unsigned feats,
lstcon_new_session_id(&console_session.ses_id);
- console_session.ses_key = key;
- console_session.ses_state = LST_SESSION_ACTIVE;
- console_session.ses_force = !!force;
+ console_session.ses_key = key;
+ console_session.ses_state = LST_SESSION_ACTIVE;
+ console_session.ses_force = !!force;
console_session.ses_features = feats;
console_session.ses_feats_updated = 0;
console_session.ses_timeout = (timeout <= 0) ?
@@ -1770,8 +1770,8 @@ lstcon_session_info(lst_sid_t *sid_up, int *key_up, unsigned *featp,
lstcon_ndlist_ent_t *ndinfo_up, char *name_up, int len)
{
lstcon_ndlist_ent_t *entp;
- lstcon_ndlink_t *ndl;
- int rc = 0;
+ lstcon_ndlink_t *ndl;
+ int rc = 0;
if (console_session.ses_state != LST_SESSION_ACTIVE)
return -ESRCH;
@@ -1802,9 +1802,9 @@ int
lstcon_session_end(void)
{
lstcon_rpc_trans_t *trans;
- lstcon_group_t *grp;
- lstcon_batch_t *bat;
- int rc = 0;
+ lstcon_group_t *grp;
+ lstcon_batch_t *bat;
+ int rc = 0;
LASSERT(console_session.ses_state == LST_SESSION_ACTIVE);
@@ -1894,13 +1894,13 @@ lstcon_session_feats_check(unsigned feats)
static int
lstcon_acceptor_handle(srpc_server_rpc_t *rpc)
{
- srpc_msg_t *rep = &rpc->srpc_replymsg;
- srpc_msg_t *req = &rpc->srpc_reqstbuf->buf_msg;
+ srpc_msg_t *rep = &rpc->srpc_replymsg;
+ srpc_msg_t *req = &rpc->srpc_reqstbuf->buf_msg;
srpc_join_reqst_t *jreq = &req->msg_body.join_reqst;
srpc_join_reply_t *jrep = &rep->msg_body.join_reply;
- lstcon_group_t *grp = NULL;
- lstcon_ndlink_t *ndl;
- int rc = 0;
+ lstcon_group_t *grp = NULL;
+ lstcon_ndlink_t *ndl;
+ int rc = 0;
sfw_unpack_message(req);
@@ -1978,9 +1978,9 @@ srpc_service_t lstcon_acceptor_service;
static void lstcon_init_acceptor_service(void)
{
/* initialize selftest console acceptor service table */
- lstcon_acceptor_service.sv_name = "join session";
- lstcon_acceptor_service.sv_handler = lstcon_acceptor_handle;
- lstcon_acceptor_service.sv_id = SRPC_SERVICE_JOIN;
+ lstcon_acceptor_service.sv_name = "join session";
+ lstcon_acceptor_service.sv_handler = lstcon_acceptor_handle;
+ lstcon_acceptor_service.sv_id = SRPC_SERVICE_JOIN;
lstcon_acceptor_service.sv_wi_total = SFW_FRWK_WI_MAX;
}
@@ -1992,19 +1992,19 @@ static DECLARE_IOCTL_HANDLER(lstcon_ioctl_handler, lstcon_ioctl_entry);
int
lstcon_console_init(void)
{
- int i;
- int rc;
+ int i;
+ int rc;
memset(&console_session, 0, sizeof(lstcon_session_t));
- console_session.ses_id = LST_INVALID_SID;
- console_session.ses_state = LST_SESSION_NONE;
- console_session.ses_timeout = 0;
- console_session.ses_force = 0;
- console_session.ses_expired = 0;
- console_session.ses_feats_updated = 0;
- console_session.ses_features = LST_FEATS_MASK;
- console_session.ses_laststamp = get_seconds();
+ console_session.ses_id = LST_INVALID_SID;
+ console_session.ses_state = LST_SESSION_NONE;
+ console_session.ses_timeout = 0;
+ console_session.ses_force = 0;
+ console_session.ses_expired = 0;
+ console_session.ses_feats_updated = 0;
+ console_session.ses_features = LST_FEATS_MASK;
+ console_session.ses_laststamp = get_seconds();
mutex_init(&console_session.ses_mutex);
@@ -2062,7 +2062,7 @@ out:
int
lstcon_console_fini(void)
{
- int i;
+ int i;
libcfs_deregister_ioctl(&lstcon_ioctl_handler);
diff --git a/drivers/staging/lustre/lnet/selftest/console.h b/drivers/staging/lustre/lnet/selftest/console.h
index e41ca89f10ba0c..c4cf0aed80e184 100644
--- a/drivers/staging/lustre/lnet/selftest/console.h
+++ b/drivers/staging/lustre/lnet/selftest/console.h
@@ -52,119 +52,121 @@
#include "conrpc.h"
typedef struct lstcon_node {
- lnet_process_id_t nd_id; /* id of the node */
- int nd_ref; /* reference count */
- int nd_state; /* state of the node */
- int nd_timeout; /* session timeout */
- unsigned long nd_stamp; /* timestamp of last replied RPC */
- struct lstcon_rpc nd_ping; /* ping rpc */
-} lstcon_node_t; /*** node descriptor */
+ lnet_process_id_t nd_id; /* id of the node */
+ int nd_ref; /* reference count */
+ int nd_state; /* state of the node */
+ int nd_timeout; /* session timeout */
+ unsigned long nd_stamp; /* timestamp of last replied RPC */
+ struct lstcon_rpc nd_ping; /* ping rpc */
+} lstcon_node_t; /* node descriptor */
typedef struct {
- struct list_head ndl_link; /* chain on list */
- struct list_head ndl_hlink; /* chain on hash */
- lstcon_node_t *ndl_node; /* pointer to node */
-} lstcon_ndlink_t; /*** node link descriptor */
+ struct list_head ndl_link; /* chain on list */
+ struct list_head ndl_hlink; /* chain on hash */
+ lstcon_node_t *ndl_node; /* pointer to node */
+} lstcon_ndlink_t; /* node link descriptor */
typedef struct {
- struct list_head grp_link; /* chain on global group list */
- int grp_ref; /* reference count */
- int grp_userland; /* has userland nodes */
- int grp_nnode; /* # of nodes */
- char grp_name[LST_NAME_SIZE]; /* group name */
+ struct list_head grp_link; /* chain on global group list
+ */
+ int grp_ref; /* reference count */
+ int grp_userland; /* has userland nodes */
+ int grp_nnode; /* # of nodes */
+ char grp_name[LST_NAME_SIZE]; /* group name */
- struct list_head grp_trans_list; /* transaction list */
- struct list_head grp_ndl_list; /* nodes list */
- struct list_head grp_ndl_hash[0];/* hash table for nodes */
-} lstcon_group_t; /*** (alias of nodes) group descriptor */
+ struct list_head grp_trans_list; /* transaction list */
+ struct list_head grp_ndl_list; /* nodes list */
+ struct list_head grp_ndl_hash[0]; /* hash table for nodes */
+} lstcon_group_t; /* (alias of nodes) group descriptor */
-#define LST_BATCH_IDLE 0xB0 /* idle batch */
-#define LST_BATCH_RUNNING 0xB1 /* running batch */
+#define LST_BATCH_IDLE 0xB0 /* idle batch */
+#define LST_BATCH_RUNNING 0xB1 /* running batch */
typedef struct lstcon_tsb_hdr {
- lst_bid_t tsb_id; /* batch ID */
- int tsb_index; /* test index */
+ lst_bid_t tsb_id; /* batch ID */
+ int tsb_index; /* test index */
} lstcon_tsb_hdr_t;
typedef struct {
- lstcon_tsb_hdr_t bat_hdr; /* test_batch header */
- struct list_head bat_link; /* chain on session's batches list */
- int bat_ntest; /* # of test */
- int bat_state; /* state of the batch */
- int bat_arg; /* parameter for run|stop, timeout for run, force for stop */
- char bat_name[LST_NAME_SIZE]; /* name of batch */
-
- struct list_head bat_test_list; /* list head of tests (lstcon_test_t) */
- struct list_head bat_trans_list; /* list head of transaction */
- struct list_head bat_cli_list; /* list head of client nodes (lstcon_node_t) */
- struct list_head *bat_cli_hash; /* hash table of client nodes */
- struct list_head bat_srv_list; /* list head of server nodes */
- struct list_head *bat_srv_hash; /* hash table of server nodes */
-} lstcon_batch_t; /*** (tests ) batch descriptor */
+ lstcon_tsb_hdr_t bat_hdr; /* test_batch header */
+ struct list_head bat_link; /* chain on session's batches list */
+ int bat_ntest; /* # of test */
+ int bat_state; /* state of the batch */
+ int bat_arg; /* parameter for run|stop, timeout
+ * for run, force for stop */
+ char bat_name[LST_NAME_SIZE];/* name of batch */
+
+ struct list_head bat_test_list; /* list head of tests (lstcon_test_t)
+ */
+ struct list_head bat_trans_list; /* list head of transaction */
+ struct list_head bat_cli_list; /* list head of client nodes
+ * (lstcon_node_t) */
+ struct list_head *bat_cli_hash; /* hash table of client nodes */
+ struct list_head bat_srv_list; /* list head of server nodes */
+ struct list_head *bat_srv_hash; /* hash table of server nodes */
+} lstcon_batch_t; /* (tests ) batch descriptor */
typedef struct lstcon_test {
- lstcon_tsb_hdr_t tes_hdr; /* test batch header */
- struct list_head tes_link; /* chain on batch's tests list */
- lstcon_batch_t *tes_batch; /* pointer to batch */
+ lstcon_tsb_hdr_t tes_hdr; /* test batch header */
+ struct list_head tes_link; /* chain on batch's tests list */
+ lstcon_batch_t *tes_batch; /* pointer to batch */
- int tes_type; /* type of the test, i.e: bulk, ping */
- int tes_stop_onerr; /* stop on error */
- int tes_oneside; /* one-sided test */
- int tes_concur; /* concurrency */
- int tes_loop; /* loop count */
- int tes_dist; /* nodes distribution of target group */
- int tes_span; /* nodes span of target group */
- int tes_cliidx; /* client index, used for RPC creating */
+ int tes_type; /* type of the test, i.e: bulk, ping */
+ int tes_stop_onerr; /* stop on error */
+ int tes_oneside; /* one-sided test */
+ int tes_concur; /* concurrency */
+ int tes_loop; /* loop count */
+ int tes_dist; /* nodes distribution of target group */
+ int tes_span; /* nodes span of target group */
+ int tes_cliidx; /* client index, used for RPC creating */
- struct list_head tes_trans_list; /* transaction list */
- lstcon_group_t *tes_src_grp; /* group run the test */
- lstcon_group_t *tes_dst_grp; /* target group */
+ struct list_head tes_trans_list; /* transaction list */
+ lstcon_group_t *tes_src_grp; /* group run the test */
+ lstcon_group_t *tes_dst_grp; /* target group */
- int tes_paramlen; /* test parameter length */
- char tes_param[0]; /* test parameter */
-} lstcon_test_t; /*** a single test descriptor */
+ int tes_paramlen; /* test parameter length */
+ char tes_param[0]; /* test parameter */
+} lstcon_test_t; /* a single test descriptor */
-#define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
-#define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
+#define LST_GLOBAL_HASHSIZE 503 /* global nodes hash table size */
+#define LST_NODE_HASHSIZE 239 /* node hash table (for batch or group) */
-#define LST_SESSION_NONE 0x0 /* no session */
-#define LST_SESSION_ACTIVE 0x1 /* working session */
+#define LST_SESSION_NONE 0x0 /* no session */
+#define LST_SESSION_ACTIVE 0x1 /* working session */
-#define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
+#define LST_CONSOLE_TIMEOUT 300 /* default console timeout */
typedef struct {
- struct mutex ses_mutex; /* only 1 thread in session */
- lst_sid_t ses_id; /* global session id */
- int ses_key; /* local session key */
- int ses_state; /* state of session */
- int ses_timeout; /* timeout in seconds */
- time_t ses_laststamp; /* last operation stamp (seconds) */
- /** tests features of the session */
- unsigned ses_features;
- /** features are synced with remote test nodes */
- unsigned ses_feats_updated:1;
- /** force creating */
- unsigned ses_force:1;
- /** session is shutting down */
- unsigned ses_shutdown:1;
- /** console is timedout */
- unsigned ses_expired:1;
- __u64 ses_id_cookie; /* batch id cookie */
- char ses_name[LST_NAME_SIZE]; /* session name */
- lstcon_rpc_trans_t *ses_ping; /* session pinger */
- stt_timer_t ses_ping_timer; /* timer for pinger */
- lstcon_trans_stat_t ses_trans_stat; /* transaction stats */
-
- struct list_head ses_trans_list; /* global list of transaction */
- struct list_head ses_grp_list; /* global list of groups */
- struct list_head ses_bat_list; /* global list of batches */
- struct list_head ses_ndl_list; /* global list of nodes */
- struct list_head *ses_ndl_hash; /* hash table of nodes */
-
- spinlock_t ses_rpc_lock; /* serialize */
- atomic_t ses_rpc_counter;/* # of initialized RPCs */
- struct list_head ses_rpc_freelist; /* idle console rpc */
-} lstcon_session_t; /*** session descriptor */
+ struct mutex ses_mutex; /* only 1 thread in session */
+ lst_sid_t ses_id; /* global session id */
+ int ses_key; /* local session key */
+ int ses_state; /* state of session */
+ int ses_timeout; /* timeout in seconds */
+ time_t ses_laststamp; /* last operation stamp (seconds)
+ */
+ unsigned ses_features; /* tests features of the session
+ */
+ unsigned ses_feats_updated:1; /* features are synced with
+ * remote test nodes */
+ unsigned ses_force:1; /* force creating */
+ unsigned ses_shutdown:1; /* session is shutting down */
+ unsigned ses_expired:1; /* console is timedout */
+ __u64 ses_id_cookie; /* batch id cookie */
+ char ses_name[LST_NAME_SIZE];/* session name */
+ lstcon_rpc_trans_t *ses_ping; /* session pinger */
+ stt_timer_t ses_ping_timer; /* timer for pinger */
+ lstcon_trans_stat_t ses_trans_stat; /* transaction stats */
+
+ struct list_head ses_trans_list; /* global list of transaction */
+ struct list_head ses_grp_list; /* global list of groups */
+ struct list_head ses_bat_list; /* global list of batches */
+ struct list_head ses_ndl_list; /* global list of nodes */
+ struct list_head *ses_ndl_hash; /* hash table of nodes */
+
+ spinlock_t ses_rpc_lock; /* serialize */
+ atomic_t ses_rpc_counter; /* # of initialized RPCs */
+ struct list_head ses_rpc_freelist; /* idle console rpc */
+} lstcon_session_t; /* session descriptor */
extern lstcon_session_t console_session;
diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
index a93a90de0f8580..7c5185a2a7950b 100644
--- a/drivers/staging/lustre/lnet/selftest/framework.c
+++ b/drivers/staging/lustre/lnet/selftest/framework.c
@@ -53,20 +53,20 @@ static int rpc_timeout = 64;
module_param(rpc_timeout, int, 0644);
MODULE_PARM_DESC(rpc_timeout, "rpc timeout in seconds (64 by default, 0 == never)");
-#define sfw_unpack_id(id) \
-do { \
+#define sfw_unpack_id(id) \
+do { \
__swab64s(&(id).nid); \
__swab32s(&(id).pid); \
} while (0)
-#define sfw_unpack_sid(sid) \
-do { \
+#define sfw_unpack_sid(sid) \
+do { \
__swab64s(&(sid).ses_nid); \
__swab64s(&(sid).ses_stamp); \
} while (0)
-#define sfw_unpack_fw_counters(fc) \
-do { \
+#define sfw_unpack_fw_counters(fc) \
+do { \
__swab32s(&(fc).running_ms); \
__swab32s(&(fc).active_batches); \
__swab32s(&(fc).zombie_sessions); \
@@ -75,7 +75,7 @@ do { \
} while (0)
#define sfw_unpack_rpc_counters(rc) \
-do { \
+do { \
__swab32s(&(rc).errors); \
__swab32s(&(rc).rpcs_sent); \
__swab32s(&(rc).rpcs_rcvd); \
@@ -86,7 +86,7 @@ do { \
} while (0)
#define sfw_unpack_lnet_counters(lc) \
-do { \
+do { \
__swab32s(&(lc).errors); \
__swab32s(&(lc).msgs_max); \
__swab32s(&(lc).msgs_alloc); \
@@ -104,14 +104,14 @@ do { \
#define sfw_batch_active(b) (atomic_read(&(b)->bat_nactive) != 0)
static struct smoketest_framework {
- struct list_head fw_zombie_rpcs; /* RPCs to be recycled */
- struct list_head fw_zombie_sessions; /* stopping sessions */
- struct list_head fw_tests; /* registered test cases */
- atomic_t fw_nzombies; /* # zombie sessions */
- spinlock_t fw_lock; /* serialise */
- sfw_session_t *fw_session; /* _the_ session */
- int fw_shuttingdown; /* shutdown in progress */
- srpc_server_rpc_t *fw_active_srpc; /* running RPC */
+ struct list_head fw_zombie_rpcs; /* RPCs to be recycled */
+ struct list_head fw_zombie_sessions; /* stopping sessions */
+ struct list_head fw_tests; /* registered test cases */
+ atomic_t fw_nzombies; /* # zombie sessions */
+ spinlock_t fw_lock; /* serialise */
+ sfw_session_t *fw_session; /* _the_ session */
+ int fw_shuttingdown; /* shutdown in progress */
+ srpc_server_rpc_t *fw_active_srpc; /* running RPC */
} sfw_data;
/* forward ref's */
@@ -160,7 +160,7 @@ static void
sfw_add_session_timer(void)
{
sfw_session_t *sn = sfw_data.fw_session;
- stt_timer_t *timer = &sn->sn_timer;
+ stt_timer_t *timer = &sn->sn_timer;
LASSERT(!sfw_data.fw_shuttingdown);
@@ -199,8 +199,8 @@ sfw_deactivate_session(void)
__must_hold(&sfw_data.fw_lock)
{
sfw_session_t *sn = sfw_data.fw_session;
- int nactive = 0;
- sfw_batch_t *tsb;
+ int nactive = 0;
+ sfw_batch_t *tsb;
sfw_test_case_t *tsc;
if (sn == NULL) return;
@@ -273,7 +273,7 @@ sfw_init_session(sfw_session_t *sn, lst_sid_t sid,
strlcpy(&sn->sn_name[0], name, sizeof(sn->sn_name));
sn->sn_timer_active = 0;
- sn->sn_id = sid;
+ sn->sn_id = sid;
sn->sn_features = features;
sn->sn_timeout = session_timeout;
sn->sn_started = cfs_time_current();
@@ -287,8 +287,8 @@ sfw_init_session(sfw_session_t *sn, lst_sid_t sid,
static void
sfw_server_rpc_done(struct srpc_server_rpc *rpc)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- int status = rpc->srpc_status;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ int status = rpc->srpc_status;
CDEBUG(D_NET,
"Incoming framework RPC done: service %s, peer %s, status %s:%d\n",
@@ -327,7 +327,7 @@ static sfw_batch_t *
sfw_find_batch(lst_bid_t bid)
{
sfw_session_t *sn = sfw_data.fw_session;
- sfw_batch_t *bat;
+ sfw_batch_t *bat;
LASSERT(sn != NULL);
@@ -343,7 +343,7 @@ static sfw_batch_t *
sfw_bid2batch(lst_bid_t bid)
{
sfw_session_t *sn = sfw_data.fw_session;
- sfw_batch_t *bat;
+ sfw_batch_t *bat;
LASSERT(sn != NULL);
@@ -368,10 +368,10 @@ sfw_bid2batch(lst_bid_t bid)
static int
sfw_get_stats(srpc_stat_reqst_t *request, srpc_stat_reply_t *reply)
{
- sfw_session_t *sn = sfw_data.fw_session;
+ sfw_session_t *sn = sfw_data.fw_session;
sfw_counters_t *cnt = &reply->str_fw;
- sfw_batch_t *bat;
- struct timeval tv;
+ sfw_batch_t *bat;
+ struct timeval tv;
reply->str_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -412,9 +412,9 @@ int
sfw_make_session(srpc_mksn_reqst_t *request, srpc_mksn_reply_t *reply)
{
sfw_session_t *sn = sfw_data.fw_session;
- srpc_msg_t *msg = container_of(request, srpc_msg_t,
+ srpc_msg_t *msg = container_of(request, srpc_msg_t,
msg_body.mksn_reqst);
- int cplen = 0;
+ int cplen = 0;
if (request->mksn_sid.ses_nid == LNET_NID_ANY) {
reply->mksn_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -533,7 +533,7 @@ sfw_debug_session(srpc_debug_reqst_t *request, srpc_debug_reply_t *reply)
static void
sfw_test_rpc_fini(srpc_client_rpc_t *rpc)
{
- sfw_test_unit_t *tsu = rpc->crpc_priv;
+ sfw_test_unit_t *tsu = rpc->crpc_priv;
sfw_test_instance_t *tsi = tsu->tsu_instance;
/* Called with hold of tsi->tsi_lock */
@@ -544,9 +544,9 @@ sfw_test_rpc_fini(srpc_client_rpc_t *rpc)
static inline int
sfw_test_buffers(sfw_test_instance_t *tsi)
{
- struct sfw_test_case *tsc = sfw_find_test_case(tsi->tsi_service);
- struct srpc_service *svc = tsc->tsc_srv_service;
- int nbuf;
+ struct sfw_test_case *tsc = sfw_find_test_case(tsi->tsi_service);
+ struct srpc_service *svc = tsc->tsc_srv_service;
+ int nbuf;
nbuf = min(svc->sv_wi_total, tsi->tsi_loop) / svc->sv_ncpts;
return max(SFW_TEST_WI_MIN, nbuf + SFW_TEST_WI_EXTRA);
@@ -555,10 +555,10 @@ sfw_test_buffers(sfw_test_instance_t *tsi)
static int
sfw_load_test(struct sfw_test_instance *tsi)
{
- struct sfw_test_case *tsc;
- struct srpc_service *svc;
- int nbuf;
- int rc;
+ struct sfw_test_case *tsc;
+ struct srpc_service *svc;
+ int nbuf;
+ int rc;
LASSERT(tsi != NULL);
tsc = sfw_find_test_case(tsi->tsi_service);
@@ -611,7 +611,7 @@ static void
sfw_destroy_test_instance(sfw_test_instance_t *tsi)
{
srpc_client_rpc_t *rpc;
- sfw_test_unit_t *tsu;
+ sfw_test_unit_t *tsu;
if (!tsi->tsi_is_client) goto clean;
@@ -728,14 +728,14 @@ sfw_unpack_addtest_req(srpc_msg_t *msg)
static int
sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
{
- srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg;
- srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
- srpc_bulk_t *bk = rpc->srpc_bulk;
- int ndest = req->tsr_ndest;
- sfw_test_unit_t *tsu;
+ srpc_msg_t *msg = &rpc->srpc_reqstbuf->buf_msg;
+ srpc_test_reqst_t *req = &msg->msg_body.tes_reqst;
+ srpc_bulk_t *bk = rpc->srpc_bulk;
+ int ndest = req->tsr_ndest;
+ sfw_test_unit_t *tsu;
sfw_test_instance_t *tsi;
- int i;
- int rc;
+ int i;
+ int rc;
LIBCFS_ALLOC(tsi, sizeof(*tsi));
if (tsi == NULL) {
@@ -751,9 +751,9 @@ sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
INIT_LIST_HEAD(&tsi->tsi_active_rpcs);
tsi->tsi_stopping = 0;
- tsi->tsi_batch = tsb;
- tsi->tsi_loop = req->tsr_loop;
- tsi->tsi_concur = req->tsr_concur;
+ tsi->tsi_batch = tsb;
+ tsi->tsi_loop = req->tsr_loop;
+ tsi->tsi_concur = req->tsr_concur;
tsi->tsi_service = req->tsr_service;
tsi->tsi_is_client = !!(req->tsr_is_client);
tsi->tsi_stoptsu_onerr = !!(req->tsr_stop_onerr);
@@ -782,8 +782,8 @@ sfw_add_test_instance(sfw_batch_t *tsb, srpc_server_rpc_t *rpc)
for (i = 0; i < ndest; i++) {
lnet_process_id_packed_t *dests;
- lnet_process_id_packed_t id;
- int j;
+ lnet_process_id_packed_t id;
+ int j;
dests = page_address(bk->bk_iovs[i / SFW_ID_PER_PAGE].kiov_page);
LASSERT(dests != NULL); /* my pages are within KVM always */
@@ -824,8 +824,8 @@ static void
sfw_test_unit_done(sfw_test_unit_t *tsu)
{
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_batch_t *tsb = tsi->tsi_batch;
- sfw_session_t *sn = tsb->bat_session;
+ sfw_batch_t *tsb = tsi->tsi_batch;
+ sfw_session_t *sn = tsb->bat_session;
LASSERT(sfw_test_active(tsi));
@@ -866,9 +866,9 @@ sfw_test_unit_done(sfw_test_unit_t *tsu)
static void
sfw_test_rpc_done(srpc_client_rpc_t *rpc)
{
- sfw_test_unit_t *tsu = rpc->crpc_priv;
+ sfw_test_unit_t *tsu = rpc->crpc_priv;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- int done = 0;
+ int done = 0;
tsi->tsi_ops->tso_done_rpc(tsu, rpc);
@@ -904,7 +904,7 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
unsigned features, int nblk, int blklen,
srpc_client_rpc_t **rpcpp)
{
- srpc_client_rpc_t *rpc = NULL;
+ srpc_client_rpc_t *rpc = NULL;
sfw_test_instance_t *tsi = tsu->tsu_instance;
spin_lock(&tsi->tsi_lock);
@@ -945,9 +945,9 @@ sfw_create_test_rpc(sfw_test_unit_t *tsu, lnet_process_id_t peer,
static int
sfw_run_test(swi_workitem_t *wi)
{
- sfw_test_unit_t *tsu = wi->swi_workitem.wi_data;
+ sfw_test_unit_t *tsu = wi->swi_workitem.wi_data;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- srpc_client_rpc_t *rpc = NULL;
+ srpc_client_rpc_t *rpc = NULL;
LASSERT(wi == &tsu->tsu_worker);
@@ -995,8 +995,8 @@ test_done:
static int
sfw_run_batch(sfw_batch_t *tsb)
{
- swi_workitem_t *wi;
- sfw_test_unit_t *tsu;
+ swi_workitem_t *wi;
+ sfw_test_unit_t *tsu;
sfw_test_instance_t *tsi;
if (sfw_batch_active(tsb)) {
@@ -1032,7 +1032,7 @@ int
sfw_stop_batch(sfw_batch_t *tsb, int force)
{
sfw_test_instance_t *tsi;
- srpc_client_rpc_t *rpc;
+ srpc_client_rpc_t *rpc;
if (!sfw_batch_active(tsb)) {
CDEBUG(D_NET, "Batch %llu inactive\n", tsb->bat_id.bat_id);
@@ -1118,11 +1118,11 @@ sfw_alloc_pages(struct srpc_server_rpc *rpc, int cpt, int npages, int len,
static int
sfw_add_test(srpc_server_rpc_t *rpc)
{
- sfw_session_t *sn = sfw_data.fw_session;
+ sfw_session_t *sn = sfw_data.fw_session;
srpc_test_reply_t *reply = &rpc->srpc_replymsg.msg_body.tes_reply;
srpc_test_reqst_t *request;
- int rc;
- sfw_batch_t *bat;
+ int rc;
+ sfw_batch_t *bat;
request = &rpc->srpc_reqstbuf->buf_msg.msg_body.tes_reqst;
reply->tsr_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -1160,8 +1160,8 @@ sfw_add_test(srpc_server_rpc_t *rpc)
if (request->tsr_is_client && rpc->srpc_bulk == NULL) {
/* rpc will be resumed later in sfw_bulk_ready */
- int npg = sfw_id_pages(request->tsr_ndest);
- int len;
+ int npg = sfw_id_pages(request->tsr_ndest);
+ int len;
if ((sn->sn_features & LST_FEAT_BULK_LEN) == 0) {
len = npg * PAGE_CACHE_SIZE;
@@ -1189,8 +1189,8 @@ static int
sfw_control_batch(srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
{
sfw_session_t *sn = sfw_data.fw_session;
- int rc = 0;
- sfw_batch_t *bat;
+ int rc = 0;
+ sfw_batch_t *bat;
reply->bar_sid = (sn == NULL) ? LST_INVALID_SID : sn->sn_id;
@@ -1229,11 +1229,11 @@ sfw_control_batch(srpc_batch_reqst_t *request, srpc_batch_reply_t *reply)
static int
sfw_handle_server_rpc(struct srpc_server_rpc *rpc)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- srpc_msg_t *reply = &rpc->srpc_replymsg;
- srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg;
- unsigned features = LST_FEATS_MASK;
- int rc = 0;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ srpc_msg_t *reply = &rpc->srpc_replymsg;
+ srpc_msg_t *request = &rpc->srpc_reqstbuf->buf_msg;
+ unsigned features = LST_FEATS_MASK;
+ int rc = 0;
LASSERT(sfw_data.fw_active_srpc == NULL);
LASSERT(sv->sv_id <= SRPC_FRAMEWORK_SERVICE_MAX_ID);
@@ -1334,8 +1334,8 @@ sfw_handle_server_rpc(struct srpc_server_rpc *rpc)
static int
sfw_bulk_ready(struct srpc_server_rpc *rpc, int status)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- int rc;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ int rc;
LASSERT(rpc->srpc_bulk != NULL);
LASSERT(sv->sv_id == SRPC_SERVICE_TEST);
@@ -1640,10 +1640,10 @@ extern void brw_init_test_service(void);
int
sfw_startup(void)
{
- int i;
- int rc;
- int error;
- srpc_service_t *sv;
+ int i;
+ int rc;
+ int error;
+ srpc_service_t *sv;
sfw_test_case_t *tsc;
@@ -1735,9 +1735,9 @@ sfw_startup(void)
void
sfw_shutdown(void)
{
- srpc_service_t *sv;
+ srpc_service_t *sv;
sfw_test_case_t *tsc;
- int i;
+ int i;
spin_lock(&sfw_data.fw_lock);
diff --git a/drivers/staging/lustre/lnet/selftest/module.c b/drivers/staging/lustre/lnet/selftest/module.c
index 7ad62f167ceaa0..09b8f4649796e3 100644
--- a/drivers/staging/lustre/lnet/selftest/module.c
+++ b/drivers/staging/lustre/lnet/selftest/module.c
@@ -39,7 +39,7 @@
#include "selftest.h"
enum {
- LST_INIT_NONE = 0,
+ LST_INIT_NONE = 0,
LST_INIT_WI_SERIAL,
LST_INIT_WI_TEST,
LST_INIT_RPC,
@@ -58,7 +58,7 @@ struct cfs_wi_sched **lst_sched_test;
static void
lnet_selftest_fini(void)
{
- int i;
+ int i;
switch (lst_init_step) {
case LST_INIT_CONSOLE:
@@ -92,9 +92,9 @@ lnet_selftest_fini(void)
static int
lnet_selftest_init(void)
{
- int nscheds;
- int rc;
- int i;
+ int nscheds;
+ int rc;
+ int i;
rc = cfs_wi_sched_create("lst_s", lnet_cpt_table(), CFS_CPT_ANY,
1, &lst_sched_serial);
diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
index 644069a9fe4e93..1dab9984c58e00 100644
--- a/drivers/staging/lustre/lnet/selftest/ping_test.c
+++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
@@ -73,7 +73,7 @@ static void
ping_client_fini(sfw_test_instance_t *tsi)
{
sfw_session_t *sn = tsi->tsi_batch->bat_session;
- int errors;
+ int errors;
LASSERT(sn != NULL);
LASSERT(tsi->tsi_is_client);
@@ -89,11 +89,11 @@ static int
ping_client_prep_rpc(sfw_test_unit_t *tsu,
lnet_process_id_t dest, srpc_client_rpc_t **rpc)
{
- srpc_ping_reqst_t *req;
+ srpc_ping_reqst_t *req;
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_session_t *sn = tsi->tsi_batch->bat_session;
- struct timeval tv;
- int rc;
+ sfw_session_t *sn = tsi->tsi_batch->bat_session;
+ struct timeval tv;
+ int rc;
LASSERT(sn != NULL);
LASSERT((sn->sn_features & ~LST_FEATS_MASK) == 0);
@@ -121,10 +121,10 @@ static void
ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
{
sfw_test_instance_t *tsi = tsu->tsu_instance;
- sfw_session_t *sn = tsi->tsi_batch->bat_session;
- srpc_ping_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.ping_reqst;
- srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply;
- struct timeval tv;
+ sfw_session_t *sn = tsi->tsi_batch->bat_session;
+ srpc_ping_reqst_t *reqst = &rpc->crpc_reqstmsg.msg_body.ping_reqst;
+ srpc_ping_reply_t *reply = &rpc->crpc_replymsg.msg_body.ping_reply;
+ struct timeval tv;
LASSERT(sn != NULL);
@@ -171,9 +171,9 @@ ping_client_done_rpc(sfw_test_unit_t *tsu, srpc_client_rpc_t *rpc)
static int
ping_server_handle(struct srpc_server_rpc *rpc)
{
- struct srpc_service *sv = rpc->srpc_scd->scd_svc;
- srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
- srpc_msg_t *replymsg = &rpc->srpc_replymsg;
+ struct srpc_service *sv = rpc->srpc_scd->scd_svc;
+ srpc_msg_t *reqstmsg = &rpc->srpc_reqstbuf->buf_msg;
+ srpc_msg_t *replymsg = &rpc->srpc_replymsg;
srpc_ping_reqst_t *req = &reqstmsg->msg_body.ping_reqst;
srpc_ping_reply_t *rep = &rpc->srpc_replymsg.msg_body.ping_reply;
diff --git a/drivers/staging/lustre/lnet/selftest/rpc.c b/drivers/staging/lustre/lnet/selftest/rpc.c
index 080788ab749ef9..59cf01ff43349d 100644
--- a/drivers/staging/lustre/lnet/selftest/rpc.c
+++ b/drivers/staging/lustre/lnet/selftest/rpc.c
@@ -104,7 +104,7 @@ srpc_add_bulk_page(srpc_bulk_t *bk, struct page *pg, int i, int nob)
void
srpc_free_bulk(srpc_bulk_t *bk)
{
- int i;
+ int i;
struct page *pg;
LASSERT(bk != NULL);
@@ -124,8 +124,8 @@ srpc_free_bulk(srpc_bulk_t *bk)
srpc_bulk_t *
srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
{
- srpc_bulk_t *bk;
- int i;
+ srpc_bulk_t *bk;
+ int i;
LASSERT(bulk_npg > 0 && bulk_npg <= LNET_MAX_IOV);
@@ -143,7 +143,7 @@ srpc_alloc_bulk(int cpt, unsigned bulk_npg, unsigned bulk_len, int sink)
for (i = 0; i < bulk_npg; i++) {
struct page *pg;
- int nob;
+ int nob;
pg = alloc_pages_node(cfs_cpt_spread_node(lnet_cpt_table(), cpt),
GFP_IOFS, 0);
@@ -193,11 +193,11 @@ srpc_init_server_rpc(struct srpc_server_rpc *rpc,
static void
srpc_service_fini(struct srpc_service *svc)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- struct srpc_buffer *buf;
- struct list_head *q;
- int i;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ struct srpc_buffer *buf;
+ struct list_head *q;
+ int i;
if (svc->sv_cpt_data == NULL)
return;
@@ -249,11 +249,11 @@ int srpc_add_buffer(struct swi_workitem *wi);
static int
srpc_service_init(struct srpc_service *svc)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- int nrpcs;
- int i;
- int j;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ int nrpcs;
+ int i;
+ int j;
svc->sv_shuttingdown = 0;
@@ -357,8 +357,8 @@ srpc_post_passive_rdma(int portal, int local, __u64 matchbits, void *buf,
int len, int options, lnet_process_id_t peer,
lnet_handle_md_t *mdh, srpc_event_t *ev)
{
- int rc;
- lnet_md_t md;
+ int rc;
+ lnet_md_t md;
lnet_handle_me_t meh;
rc = LNetMEAttach(portal, peer, matchbits, 0, LNET_UNLINK,
@@ -397,7 +397,7 @@ srpc_post_active_rdma(int portal, __u64 matchbits, void *buf, int len,
int options, lnet_process_id_t peer, lnet_nid_t self,
lnet_handle_md_t *mdh, srpc_event_t *ev)
{
- int rc;
+ int rc;
lnet_md_t md;
md.user_ptr = ev;
@@ -471,9 +471,9 @@ static int
srpc_service_post_buffer(struct srpc_service_cd *scd, struct srpc_buffer *buf)
__must_hold(&scd->scd_lock)
{
- struct srpc_service *sv = scd->scd_svc;
- struct srpc_msg *msg = &buf->buf_msg;
- int rc;
+ struct srpc_service *sv = scd->scd_svc;
+ struct srpc_msg *msg = &buf->buf_msg;
+ int rc;
LNetInvalidateHandle(&buf->buf_mdh);
list_add(&buf->buf_list, &scd->scd_buf_posted);
@@ -519,9 +519,9 @@ srpc_service_post_buffer(struct srpc_service_cd *scd, struct srpc_buffer *buf)
int
srpc_add_buffer(struct swi_workitem *wi)
{
- struct srpc_service_cd *scd = wi->swi_workitem.wi_data;
- struct srpc_buffer *buf;
- int rc = 0;
+ struct srpc_service_cd *scd = wi->swi_workitem.wi_data;
+ struct srpc_buffer *buf;
+ int rc = 0;
/* it's called by workitem scheduler threads, these threads
* should have been set CPT affinity, so buffers will be posted
@@ -579,9 +579,9 @@ srpc_add_buffer(struct swi_workitem *wi)
int
srpc_service_add_buffers(struct srpc_service *sv, int nbuffer)
{
- struct srpc_service_cd *scd;
- int rc = 0;
- int i;
+ struct srpc_service_cd *scd;
+ int rc = 0;
+ int i;
LASSERTF(nbuffer > 0, "nbuffer must be positive: %d\n", nbuffer);
@@ -633,9 +633,9 @@ srpc_service_add_buffers(struct srpc_service *sv, int nbuffer)
void
srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer)
{
- struct srpc_service_cd *scd;
- int num;
- int i;
+ struct srpc_service_cd *scd;
+ int num;
+ int i;
LASSERT(!sv->sv_shuttingdown);
@@ -653,9 +653,9 @@ srpc_service_remove_buffers(struct srpc_service *sv, int nbuffer)
int
srpc_finish_service(struct srpc_service *sv)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- int i;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ int i;
LASSERT(sv->sv_shuttingdown); /* srpc_shutdown_service called */
@@ -731,9 +731,9 @@ srpc_service_recycle_buffer(struct srpc_service_cd *scd, srpc_buffer_t *buf)
void
srpc_abort_service(struct srpc_service *sv)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- int i;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ int i;
CDEBUG(D_NET, "Aborting service: id %d, name %s\n",
sv->sv_id, sv->sv_name);
@@ -756,10 +756,10 @@ srpc_abort_service(struct srpc_service *sv)
void
srpc_shutdown_service(srpc_service_t *sv)
{
- struct srpc_service_cd *scd;
- struct srpc_server_rpc *rpc;
- srpc_buffer_t *buf;
- int i;
+ struct srpc_service_cd *scd;
+ struct srpc_server_rpc *rpc;
+ srpc_buffer_t *buf;
+ int i;
CDEBUG(D_NET, "Shutting down service: id %d, name %s\n",
sv->sv_id, sv->sv_name);
@@ -792,7 +792,7 @@ static int
srpc_send_request(srpc_client_rpc_t *rpc)
{
srpc_event_t *ev = &rpc->crpc_reqstev;
- int rc;
+ int rc;
ev->ev_fired = 0;
ev->ev_data = rpc;
@@ -812,8 +812,8 @@ static int
srpc_prepare_reply(srpc_client_rpc_t *rpc)
{
srpc_event_t *ev = &rpc->crpc_replyev;
- __u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.rpyid;
- int rc;
+ __u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.rpyid;
+ int rc;
ev->ev_fired = 0;
ev->ev_data = rpc;
@@ -835,11 +835,11 @@ srpc_prepare_reply(srpc_client_rpc_t *rpc)
static int
srpc_prepare_bulk(srpc_client_rpc_t *rpc)
{
- srpc_bulk_t *bk = &rpc->crpc_bulk;
+ srpc_bulk_t *bk = &rpc->crpc_bulk;
srpc_event_t *ev = &rpc->crpc_bulkev;
__u64 *id = &rpc->crpc_reqstmsg.msg_body.reqst.bulkid;
- int rc;
- int opt;
+ int rc;
+ int opt;
LASSERT(bk->bk_niov <= LNET_MAX_IOV);
@@ -868,11 +868,11 @@ srpc_prepare_bulk(srpc_client_rpc_t *rpc)
static int
srpc_do_bulk(srpc_server_rpc_t *rpc)
{
- srpc_event_t *ev = &rpc->srpc_ev;
- srpc_bulk_t *bk = rpc->srpc_bulk;
- __u64 id = rpc->srpc_reqstbuf->buf_msg.msg_body.reqst.bulkid;
- int rc;
- int opt;
+ srpc_event_t *ev = &rpc->srpc_ev;
+ srpc_bulk_t *bk = rpc->srpc_bulk;
+ __u64 id = rpc->srpc_reqstbuf->buf_msg.msg_body.reqst.bulkid;
+ int rc;
+ int opt;
LASSERT(bk != NULL);
@@ -896,9 +896,9 @@ srpc_do_bulk(srpc_server_rpc_t *rpc)
static void
srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status)
{
- struct srpc_service_cd *scd = rpc->srpc_scd;
- struct srpc_service *sv = scd->scd_svc;
- srpc_buffer_t *buffer;
+ struct srpc_service_cd *scd = rpc->srpc_scd;
+ struct srpc_service *sv = scd->scd_svc;
+ srpc_buffer_t *buffer;
LASSERT(status != 0 || rpc->srpc_wi.swi_state == SWI_STATE_DONE);
@@ -959,11 +959,11 @@ srpc_server_rpc_done(srpc_server_rpc_t *rpc, int status)
int
srpc_handle_rpc(swi_workitem_t *wi)
{
- struct srpc_server_rpc *rpc = wi->swi_workitem.wi_data;
- struct srpc_service_cd *scd = rpc->srpc_scd;
- struct srpc_service *sv = scd->scd_svc;
- srpc_event_t *ev = &rpc->srpc_ev;
- int rc = 0;
+ struct srpc_server_rpc *rpc = wi->swi_workitem.wi_data;
+ struct srpc_service_cd *scd = rpc->srpc_scd;
+ struct srpc_service *sv = scd->scd_svc;
+ srpc_event_t *ev = &rpc->srpc_ev;
+ int rc = 0;
LASSERT(wi == &rpc->srpc_wi);
@@ -989,7 +989,7 @@ srpc_handle_rpc(swi_workitem_t *wi)
default:
LBUG();
case SWI_STATE_NEWBORN: {
- srpc_msg_t *msg;
+ srpc_msg_t *msg;
srpc_generic_reply_t *reply;
msg = &rpc->srpc_reqstbuf->buf_msg;
@@ -1173,10 +1173,10 @@ srpc_client_rpc_done(srpc_client_rpc_t *rpc, int status)
int
srpc_send_rpc(swi_workitem_t *wi)
{
- int rc = 0;
+ int rc = 0;
srpc_client_rpc_t *rpc;
- srpc_msg_t *reply;
- int do_bulk;
+ srpc_msg_t *reply;
+ int do_bulk;
LASSERT(wi != NULL);
@@ -1359,13 +1359,13 @@ srpc_post_rpc(srpc_client_rpc_t *rpc)
int
srpc_send_reply(struct srpc_server_rpc *rpc)
{
- srpc_event_t *ev = &rpc->srpc_ev;
- struct srpc_msg *msg = &rpc->srpc_replymsg;
- struct srpc_buffer *buffer = rpc->srpc_reqstbuf;
- struct srpc_service_cd *scd = rpc->srpc_scd;
- struct srpc_service *sv = scd->scd_svc;
- __u64 rpyid;
- int rc;
+ srpc_event_t *ev = &rpc->srpc_ev;
+ struct srpc_msg *msg = &rpc->srpc_replymsg;
+ struct srpc_buffer *buffer = rpc->srpc_reqstbuf;
+ struct srpc_service_cd *scd = rpc->srpc_scd;
+ struct srpc_service *sv = scd->scd_svc;
+ __u64 rpyid;
+ int rc;
LASSERT(buffer != NULL);
rpyid = buffer->buf_msg.msg_body.reqst.rpyid;
@@ -1403,14 +1403,14 @@ srpc_send_reply(struct srpc_server_rpc *rpc)
static void
srpc_lnet_ev_handler(lnet_event_t *ev)
{
- struct srpc_service_cd *scd;
- srpc_event_t *rpcev = ev->md.user_ptr;
+ struct srpc_service_cd *scd;
+ srpc_event_t *rpcev = ev->md.user_ptr;
srpc_client_rpc_t *crpc;
srpc_server_rpc_t *srpc;
- srpc_buffer_t *buffer;
- srpc_service_t *sv;
- srpc_msg_t *msg;
- srpc_msg_type_t type;
+ srpc_buffer_t *buffer;
+ srpc_service_t *sv;
+ srpc_msg_t *msg;
+ srpc_msg_type_t type;
LASSERT(!in_interrupt());
diff --git a/drivers/staging/lustre/lnet/selftest/rpc.h b/drivers/staging/lustre/lnet/selftest/rpc.h
index fbeb75fe592201..b7b00c6b100431 100644
--- a/drivers/staging/lustre/lnet/selftest/rpc.h
+++ b/drivers/staging/lustre/lnet/selftest/rpc.h
@@ -79,60 +79,61 @@ typedef struct {
} WIRE_ATTR srpc_generic_reqst_t;
typedef struct {
- __u32 status;
- lst_sid_t sid;
+ __u32 status;
+ lst_sid_t sid;
} WIRE_ATTR srpc_generic_reply_t;
/* FRAMEWORK RPCs */
typedef struct {
- __u64 mksn_rpyid; /* reply buffer matchbits */
- lst_sid_t mksn_sid; /* session id */
- __u32 mksn_force; /* use brute force */
+ __u64 mksn_rpyid; /* reply buffer matchbits */
+ lst_sid_t mksn_sid; /* session id */
+ __u32 mksn_force; /* use brute force */
char mksn_name[LST_NAME_SIZE];
-} WIRE_ATTR srpc_mksn_reqst_t; /* make session request */
+} WIRE_ATTR srpc_mksn_reqst_t; /* make session request */
typedef struct {
- __u32 mksn_status; /* session status */
- lst_sid_t mksn_sid; /* session id */
- __u32 mksn_timeout; /* session timeout */
- char mksn_name[LST_NAME_SIZE];
+ __u32 mksn_status; /* session status */
+ lst_sid_t mksn_sid; /* session id */
+ __u32 mksn_timeout; /* session timeout */
+ char mksn_name[LST_NAME_SIZE];
} WIRE_ATTR srpc_mksn_reply_t; /* make session reply */
typedef struct {
- __u64 rmsn_rpyid; /* reply buffer matchbits */
- lst_sid_t rmsn_sid; /* session id */
+ __u64 rmsn_rpyid; /* reply buffer matchbits */
+ lst_sid_t rmsn_sid; /* session id */
} WIRE_ATTR srpc_rmsn_reqst_t; /* remove session request */
typedef struct {
- __u32 rmsn_status;
- lst_sid_t rmsn_sid; /* session id */
+ __u32 rmsn_status;
+ lst_sid_t rmsn_sid; /* session id */
} WIRE_ATTR srpc_rmsn_reply_t; /* remove session reply */
typedef struct {
- __u64 join_rpyid; /* reply buffer matchbits */
- lst_sid_t join_sid; /* session id to join */
- char join_group[LST_NAME_SIZE]; /* group name */
+ __u64 join_rpyid; /* reply buffer matchbits */
+ lst_sid_t join_sid; /* session id to join */
+ char join_group[LST_NAME_SIZE]; /* group name */
} WIRE_ATTR srpc_join_reqst_t;
typedef struct {
- __u32 join_status; /* returned status */
- lst_sid_t join_sid; /* session id */
- __u32 join_timeout; /* # seconds' inactivity to expire */
- char join_session[LST_NAME_SIZE]; /* session name */
+ __u32 join_status; /* returned status */
+ lst_sid_t join_sid; /* session id */
+ __u32 join_timeout; /* # seconds' inactivity to
+ * expire */
+ char join_session[LST_NAME_SIZE]; /* session name */
} WIRE_ATTR srpc_join_reply_t;
typedef struct {
- __u64 dbg_rpyid; /* reply buffer matchbits */
- lst_sid_t dbg_sid; /* session id */
- __u32 dbg_flags; /* bitmap of debug */
+ __u64 dbg_rpyid; /* reply buffer matchbits */
+ lst_sid_t dbg_sid; /* session id */
+ __u32 dbg_flags; /* bitmap of debug */
} WIRE_ATTR srpc_debug_reqst_t;
typedef struct {
- __u32 dbg_status; /* returned code */
- lst_sid_t dbg_sid; /* session id */
- __u32 dbg_timeout; /* session timeout */
- __u32 dbg_nbatch; /* # of batches in the node */
- char dbg_name[LST_NAME_SIZE]; /* session name */
+ __u32 dbg_status; /* returned code */
+ lst_sid_t dbg_sid; /* session id */
+ __u32 dbg_timeout; /* session timeout */
+ __u32 dbg_nbatch; /* # of batches in the node */
+ char dbg_name[LST_NAME_SIZE]; /* session name */
} WIRE_ATTR srpc_debug_reply_t;
#define SRPC_BATCH_OPC_RUN 1
@@ -140,55 +141,51 @@ typedef struct {
#define SRPC_BATCH_OPC_QUERY 3
typedef struct {
- __u64 bar_rpyid; /* reply buffer matchbits */
- lst_sid_t bar_sid; /* session id */
- lst_bid_t bar_bid; /* batch id */
- __u32 bar_opc; /* create/start/stop batch */
- __u32 bar_testidx; /* index of test */
- __u32 bar_arg; /* parameters */
+ __u64 bar_rpyid; /* reply buffer matchbits */
+ lst_sid_t bar_sid; /* session id */
+ lst_bid_t bar_bid; /* batch id */
+ __u32 bar_opc; /* create/start/stop batch */
+ __u32 bar_testidx; /* index of test */
+ __u32 bar_arg; /* parameters */
} WIRE_ATTR srpc_batch_reqst_t;
typedef struct {
- __u32 bar_status; /* status of request */
- lst_sid_t bar_sid; /* session id */
- __u32 bar_active; /* # of active tests in batch/test */
- __u32 bar_time; /* remained time */
+ __u32 bar_status; /* status of request */
+ lst_sid_t bar_sid; /* session id */
+ __u32 bar_active; /* # of active tests in batch/test */
+ __u32 bar_time; /* remained time */
} WIRE_ATTR srpc_batch_reply_t;
typedef struct {
- __u64 str_rpyid; /* reply buffer matchbits */
- lst_sid_t str_sid; /* session id */
- __u32 str_type; /* type of stat */
+ __u64 str_rpyid; /* reply buffer matchbits */
+ lst_sid_t str_sid; /* session id */
+ __u32 str_type; /* type of stat */
} WIRE_ATTR srpc_stat_reqst_t;
typedef struct {
- __u32 str_status;
- lst_sid_t str_sid;
- sfw_counters_t str_fw;
- srpc_counters_t str_rpc;
- lnet_counters_t str_lnet;
+ __u32 str_status;
+ lst_sid_t str_sid;
+ sfw_counters_t str_fw;
+ srpc_counters_t str_rpc;
+ lnet_counters_t str_lnet;
} WIRE_ATTR srpc_stat_reply_t;
typedef struct {
- __u32 blk_opc; /* bulk operation code */
- __u32 blk_npg; /* # of pages */
- __u32 blk_flags; /* reserved flags */
+ __u32 blk_opc; /* bulk operation code */
+ __u32 blk_npg; /* # of pages */
+ __u32 blk_flags; /* reserved flags */
} WIRE_ATTR test_bulk_req_t;
typedef struct {
- /** bulk operation code */
- __u16 blk_opc;
- /** data check flags */
- __u16 blk_flags;
- /** data length */
- __u32 blk_len;
- /** reserved: offset */
- __u32 blk_offset;
+ __u16 blk_opc; /* bulk operation code */
+ __u16 blk_flags; /* data check flags */
+ __u32 blk_len; /* data length */
+ __u32 blk_offset; /* reserved: offset */
} WIRE_ATTR test_bulk_req_v1_t;
typedef struct {
- __u32 png_size; /* size of ping message */
- __u32 png_flags; /* reserved flags */
+ __u32 png_size; /* size of ping message */
+ __u32 png_flags; /* reserved flags */
} WIRE_ATTR test_ping_req_t;
typedef struct {
@@ -197,8 +194,8 @@ typedef struct {
lst_sid_t tsr_sid; /* session id */
lst_bid_t tsr_bid; /* batch id */
__u32 tsr_service; /* test type: bulk|ping|... */
- /* test client loop count or # server buffers needed */
- __u32 tsr_loop;
+ __u32 tsr_loop; /* test client loop count or
+ * # server buffers needed */
__u32 tsr_concur; /* concurrency of test */
__u8 tsr_is_client; /* is test client or not */
__u8 tsr_stop_onerr; /* stop on error */
@@ -234,8 +231,8 @@ typedef struct {
typedef struct {
__u64 brw_rpyid; /* reply buffer matchbits */
__u64 brw_bulkid; /* bulk buffer matchbits */
- __u32 brw_rw; /* read or write */
- __u32 brw_len; /* bulk data len */
+ __u32 brw_rw; /* read or write */
+ __u32 brw_len; /* bulk data len */
__u32 brw_flags; /* bulk data patterns */
} WIRE_ATTR srpc_brw_reqst_t; /* bulk r/w request */
@@ -243,20 +240,16 @@ typedef struct {
__u32 brw_status;
} WIRE_ATTR srpc_brw_reply_t; /* bulk r/w reply */
-#define SRPC_MSG_MAGIC 0xeeb0f00d
-#define SRPC_MSG_VERSION 1
+#define SRPC_MSG_MAGIC 0xeeb0f00d
+#define SRPC_MSG_VERSION 1
typedef struct srpc_msg {
- /** magic number */
- __u32 msg_magic;
- /** message version number */
- __u32 msg_version;
- /** type of message body: srpc_msg_type_t */
- __u32 msg_type;
+ __u32 msg_magic; /* magic number */
+ __u32 msg_version; /* message version number */
+ __u32 msg_type; /* type of message body: srpc_msg_type_t */
__u32 msg_reserved0;
__u32 msg_reserved1;
- /** test session features */
- __u32 msg_ses_feats;
+ __u32 msg_ses_feats; /* test session features */
union {
srpc_generic_reqst_t reqst;
srpc_generic_reply_t reply;
diff --git a/drivers/staging/lustre/lnet/selftest/selftest.h b/drivers/staging/lustre/lnet/selftest/selftest.h
index d48701834b185d..7939e4e04d90a7 100644
--- a/drivers/staging/lustre/lnet/selftest/selftest.h
+++ b/drivers/staging/lustre/lnet/selftest/selftest.h
@@ -57,14 +57,14 @@
#endif
-#define SWI_STATE_NEWBORN 0
-#define SWI_STATE_REPLY_SUBMITTED 1
-#define SWI_STATE_REPLY_SENT 2
-#define SWI_STATE_REQUEST_SUBMITTED 3
-#define SWI_STATE_REQUEST_SENT 4
-#define SWI_STATE_REPLY_RECEIVED 5
-#define SWI_STATE_BULK_STARTED 6
-#define SWI_STATE_DONE 10
+#define SWI_STATE_NEWBORN 0
+#define SWI_STATE_REPLY_SUBMITTED 1
+#define SWI_STATE_REPLY_SENT 2
+#define SWI_STATE_REQUEST_SUBMITTED 3
+#define SWI_STATE_REQUEST_SENT 4
+#define SWI_STATE_REPLY_RECEIVED 5
+#define SWI_STATE_BULK_STARTED 6
+#define SWI_STATE_DONE 10
/* forward refs */
struct srpc_service;
@@ -75,24 +75,24 @@ struct sfw_test_instance;
/* services below SRPC_FRAMEWORK_SERVICE_MAX_ID are framework
* services, e.g. create/modify session.
*/
-#define SRPC_SERVICE_DEBUG 0
-#define SRPC_SERVICE_MAKE_SESSION 1
-#define SRPC_SERVICE_REMOVE_SESSION 2
-#define SRPC_SERVICE_BATCH 3
-#define SRPC_SERVICE_TEST 4
-#define SRPC_SERVICE_QUERY_STAT 5
-#define SRPC_SERVICE_JOIN 6
-#define SRPC_FRAMEWORK_SERVICE_MAX_ID 10
+#define SRPC_SERVICE_DEBUG 0
+#define SRPC_SERVICE_MAKE_SESSION 1
+#define SRPC_SERVICE_REMOVE_SESSION 2
+#define SRPC_SERVICE_BATCH 3
+#define SRPC_SERVICE_TEST 4
+#define SRPC_SERVICE_QUERY_STAT 5
+#define SRPC_SERVICE_JOIN 6
+#define SRPC_FRAMEWORK_SERVICE_MAX_ID 10
/* other services start from SRPC_FRAMEWORK_SERVICE_MAX_ID+1 */
-#define SRPC_SERVICE_BRW 11
-#define SRPC_SERVICE_PING 12
-#define SRPC_SERVICE_MAX_ID 12
+#define SRPC_SERVICE_BRW 11
+#define SRPC_SERVICE_PING 12
+#define SRPC_SERVICE_MAX_ID 12
-#define SRPC_REQUEST_PORTAL 50
+#define SRPC_REQUEST_PORTAL 50
/* a lazy portal for framework RPC requests */
-#define SRPC_FRAMEWORK_REQUEST_PORTAL 51
+#define SRPC_FRAMEWORK_REQUEST_PORTAL 51
/* all reply/bulk RDMAs go to this portal */
-#define SRPC_RDMA_PORTAL 52
+#define SRPC_RDMA_PORTAL 52
static inline srpc_msg_type_t
srpc_service2request (int service)
@@ -136,7 +136,8 @@ srpc_service2reply (int service)
}
typedef enum {
- SRPC_BULK_REQ_RCVD = 1, /* passive bulk request(PUT sink/GET source) received */
+ SRPC_BULK_REQ_RCVD = 1, /* passive bulk request(PUT sink/GET source)
+ * received */
SRPC_BULK_PUT_SENT = 2, /* active bulk PUT sent (source) */
SRPC_BULK_GET_RPLD = 3, /* active bulk GET replied (sink) */
SRPC_REPLY_RCVD = 4, /* incoming reply received */
@@ -149,114 +150,114 @@ typedef enum {
typedef struct {
srpc_event_type_t ev_type; /* what's up */
lnet_event_kind_t ev_lnet; /* LNet event type */
- int ev_fired; /* LNet event fired? */
- int ev_status; /* LNet event status */
- void *ev_data; /* owning server/client RPC */
+ int ev_fired; /* LNet event fired? */
+ int ev_status; /* LNet event status */
+ void *ev_data; /* owning server/client RPC */
} srpc_event_t;
typedef struct {
- int bk_len; /* len of bulk data */
+ int bk_len; /* len of bulk data */
lnet_handle_md_t bk_mdh;
- int bk_sink; /* sink/source */
- int bk_niov; /* # iov in bk_iovs */
+ int bk_sink; /* sink/source */
+ int bk_niov; /* # iov in bk_iovs */
lnet_kiov_t bk_iovs[0];
} srpc_bulk_t; /* bulk descriptor */
/* message buffer descriptor */
typedef struct srpc_buffer {
- struct list_head buf_list; /* chain on srpc_service::*_msgq */
- srpc_msg_t buf_msg;
- lnet_handle_md_t buf_mdh;
- lnet_nid_t buf_self;
- lnet_process_id_t buf_peer;
+ struct list_head buf_list; /* chain on srpc_service::*_msgq */
+ srpc_msg_t buf_msg;
+ lnet_handle_md_t buf_mdh;
+ lnet_nid_t buf_self;
+ lnet_process_id_t buf_peer;
} srpc_buffer_t;
struct swi_workitem;
typedef int (*swi_action_t) (struct swi_workitem *);
typedef struct swi_workitem {
- struct cfs_wi_sched *swi_sched;
- cfs_workitem_t swi_workitem;
- swi_action_t swi_action;
- int swi_state;
+ struct cfs_wi_sched *swi_sched;
+ cfs_workitem_t swi_workitem;
+ swi_action_t swi_action;
+ int swi_state;
} swi_workitem_t;
/* server-side state of a RPC */
typedef struct srpc_server_rpc {
/* chain on srpc_service::*_rpcq */
- struct list_head srpc_list;
+ struct list_head srpc_list;
struct srpc_service_cd *srpc_scd;
- swi_workitem_t srpc_wi;
- srpc_event_t srpc_ev; /* bulk/reply event */
- lnet_nid_t srpc_self;
- lnet_process_id_t srpc_peer;
- srpc_msg_t srpc_replymsg;
- lnet_handle_md_t srpc_replymdh;
- srpc_buffer_t *srpc_reqstbuf;
- srpc_bulk_t *srpc_bulk;
-
- unsigned int srpc_aborted; /* being given up */
- int srpc_status;
- void (*srpc_done)(struct srpc_server_rpc *);
+ swi_workitem_t srpc_wi;
+ srpc_event_t srpc_ev; /* bulk/reply event */
+ lnet_nid_t srpc_self;
+ lnet_process_id_t srpc_peer;
+ srpc_msg_t srpc_replymsg;
+ lnet_handle_md_t srpc_replymdh;
+ srpc_buffer_t *srpc_reqstbuf;
+ srpc_bulk_t *srpc_bulk;
+
+ unsigned int srpc_aborted; /* being given up */
+ int srpc_status;
+ void (*srpc_done)(struct srpc_server_rpc *);
} srpc_server_rpc_t;
/* client-side state of a RPC */
typedef struct srpc_client_rpc {
- struct list_head crpc_list; /* chain on user's lists */
- spinlock_t crpc_lock; /* serialize */
- int crpc_service;
- atomic_t crpc_refcount;
- int crpc_timeout; /* # seconds to wait for reply */
- stt_timer_t crpc_timer;
- swi_workitem_t crpc_wi;
- lnet_process_id_t crpc_dest;
-
- void (*crpc_done)(struct srpc_client_rpc *);
- void (*crpc_fini)(struct srpc_client_rpc *);
- int crpc_status; /* completion status */
- void *crpc_priv; /* caller data */
+ struct list_head crpc_list; /* chain on user's lists */
+ spinlock_t crpc_lock; /* serialize */
+ int crpc_service;
+ atomic_t crpc_refcount;
+ int crpc_timeout; /* # seconds to wait for reply */
+ stt_timer_t crpc_timer;
+ swi_workitem_t crpc_wi;
+ lnet_process_id_t crpc_dest;
+
+ void (*crpc_done)(struct srpc_client_rpc *);
+ void (*crpc_fini)(struct srpc_client_rpc *);
+ int crpc_status; /* completion status */
+ void *crpc_priv; /* caller data */
/* state flags */
- unsigned int crpc_aborted:1; /* being given up */
- unsigned int crpc_closed:1; /* completed */
+ unsigned int crpc_aborted:1; /* being given up */
+ unsigned int crpc_closed:1; /* completed */
/* RPC events */
- srpc_event_t crpc_bulkev; /* bulk event */
- srpc_event_t crpc_reqstev; /* request event */
- srpc_event_t crpc_replyev; /* reply event */
+ srpc_event_t crpc_bulkev; /* bulk event */
+ srpc_event_t crpc_reqstev; /* request event */
+ srpc_event_t crpc_replyev; /* reply event */
/* bulk, request(reqst), and reply exchanged on wire */
- srpc_msg_t crpc_reqstmsg;
- srpc_msg_t crpc_replymsg;
- lnet_handle_md_t crpc_reqstmdh;
- lnet_handle_md_t crpc_replymdh;
- srpc_bulk_t crpc_bulk;
+ srpc_msg_t crpc_reqstmsg;
+ srpc_msg_t crpc_replymsg;
+ lnet_handle_md_t crpc_reqstmdh;
+ lnet_handle_md_t crpc_replymdh;
+ srpc_bulk_t crpc_bulk;
} srpc_client_rpc_t;
-#define srpc_client_rpc_size(rpc) \
+#define srpc_client_rpc_size(rpc) \
offsetof(srpc_client_rpc_t, crpc_bulk.bk_iovs[(rpc)->crpc_bulk.bk_niov])
-#define srpc_client_rpc_addref(rpc) \
-do { \
- CDEBUG(D_NET, "RPC[%p] -> %s (%d)++\n", \
- (rpc), libcfs_id2str((rpc)->crpc_dest), \
- atomic_read(&(rpc)->crpc_refcount)); \
- LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
- atomic_inc(&(rpc)->crpc_refcount); \
+#define srpc_client_rpc_addref(rpc) \
+do { \
+ CDEBUG(D_NET, "RPC[%p] -> %s (%d)++\n", \
+ (rpc), libcfs_id2str((rpc)->crpc_dest), \
+ atomic_read(&(rpc)->crpc_refcount)); \
+ LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
+ atomic_inc(&(rpc)->crpc_refcount); \
} while (0)
-#define srpc_client_rpc_decref(rpc) \
-do { \
- CDEBUG(D_NET, "RPC[%p] -> %s (%d)--\n", \
- (rpc), libcfs_id2str((rpc)->crpc_dest), \
- atomic_read(&(rpc)->crpc_refcount)); \
- LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
- if (atomic_dec_and_test(&(rpc)->crpc_refcount)) \
- srpc_destroy_client_rpc(rpc); \
+#define srpc_client_rpc_decref(rpc) \
+do { \
+ CDEBUG(D_NET, "RPC[%p] -> %s (%d)--\n", \
+ (rpc), libcfs_id2str((rpc)->crpc_dest), \
+ atomic_read(&(rpc)->crpc_refcount)); \
+ LASSERT(atomic_read(&(rpc)->crpc_refcount) > 0); \
+ if (atomic_dec_and_test(&(rpc)->crpc_refcount)) \
+ srpc_destroy_client_rpc(rpc); \
} while (0)
-#define srpc_event_pending(rpc) ((rpc)->crpc_bulkev.ev_fired == 0 || \
- (rpc)->crpc_reqstev.ev_fired == 0 || \
+#define srpc_event_pending(rpc) ((rpc)->crpc_bulkev.ev_fired == 0 || \
+ (rpc)->crpc_reqstev.ev_fired == 0 || \
(rpc)->crpc_replyev.ev_fired == 0)
/* CPU partition data of srpc service */
@@ -268,9 +269,9 @@ struct srpc_service_cd {
/** event buffer */
srpc_event_t scd_ev;
/** free RPC descriptors */
- struct list_head scd_rpc_free;
+ struct list_head scd_rpc_free;
/** in-flight RPCs */
- struct list_head scd_rpc_active;
+ struct list_head scd_rpc_active;
/** workitem for posting buffer */
swi_workitem_t scd_buf_wi;
/** CPT id */
@@ -278,7 +279,7 @@ struct srpc_service_cd {
/** error code for scd_buf_wi */
int scd_buf_err;
/** timestamp for scd_buf_err */
- unsigned long scd_buf_err_stamp;
+ unsigned long scd_buf_err_stamp;
/** total # request buffers */
int scd_buf_total;
/** # posted request buffers */
@@ -290,9 +291,9 @@ struct srpc_service_cd {
/** increase/decrease some buffers */
int scd_buf_adjust;
/** posted message buffers */
- struct list_head scd_buf_posted;
+ struct list_head scd_buf_posted;
/** blocked for RPC descriptor */
- struct list_head scd_buf_blocked;
+ struct list_head scd_buf_blocked;
};
/* number of server workitems (mini-thread) for testing service */
@@ -318,40 +319,42 @@ typedef struct srpc_service {
* - sv_handler: process incoming RPC request
* - sv_bulk_ready: notify bulk data
*/
- int (*sv_handler) (srpc_server_rpc_t *);
- int (*sv_bulk_ready) (srpc_server_rpc_t *, int);
+ int (*sv_handler) (srpc_server_rpc_t *);
+ int (*sv_bulk_ready) (srpc_server_rpc_t *, int);
} srpc_service_t;
typedef struct {
- struct list_head sn_list; /* chain on fw_zombie_sessions */
- lst_sid_t sn_id; /* unique identifier */
- unsigned int sn_timeout; /* # seconds' inactivity to expire */
- int sn_timer_active;
- unsigned int sn_features;
- stt_timer_t sn_timer;
- struct list_head sn_batches; /* list of batches */
- char sn_name[LST_NAME_SIZE];
- atomic_t sn_refcount;
- atomic_t sn_brw_errors;
- atomic_t sn_ping_errors;
- unsigned long sn_started;
+ struct list_head sn_list; /* chain on fw_zombie_sessions */
+ lst_sid_t sn_id; /* unique identifier */
+ unsigned int sn_timeout; /* # seconds' inactivity to expire */
+ int sn_timer_active;
+ unsigned int sn_features;
+ stt_timer_t sn_timer;
+ struct list_head sn_batches; /* list of batches */
+ char sn_name[LST_NAME_SIZE];
+ atomic_t sn_refcount;
+ atomic_t sn_brw_errors;
+ atomic_t sn_ping_errors;
+ unsigned long sn_started;
} sfw_session_t;
#define sfw_sid_equal(sid0, sid1) ((sid0).ses_nid == (sid1).ses_nid && \
(sid0).ses_stamp == (sid1).ses_stamp)
typedef struct {
- struct list_head bat_list; /* chain on sn_batches */
- lst_bid_t bat_id; /* batch id */
- int bat_error; /* error code of batch */
- sfw_session_t *bat_session; /* batch's session */
- atomic_t bat_nactive; /* # of active tests */
- struct list_head bat_tests; /* test instances */
+ struct list_head bat_list; /* chain on sn_batches */
+ lst_bid_t bat_id; /* batch id */
+ int bat_error; /* error code of batch */
+ sfw_session_t *bat_session; /* batch's session */
+ atomic_t bat_nactive; /* # of active tests */
+ struct list_head bat_tests; /* test instances */
} sfw_batch_t;
typedef struct {
- int (*tso_init)(struct sfw_test_instance *tsi); /* initialize test client */
- void (*tso_fini)(struct sfw_test_instance *tsi); /* finalize test client */
+ int (*tso_init)(struct sfw_test_instance *tsi); /* initialize test
+ * client */
+ void (*tso_fini)(struct sfw_test_instance *tsi); /* finalize test
+ * client */
int (*tso_prep_rpc)(struct sfw_test_unit *tsu,
lnet_process_id_t dest,
srpc_client_rpc_t **rpc); /* prep a tests rpc */
@@ -360,29 +363,31 @@ typedef struct {
} sfw_test_client_ops_t;
typedef struct sfw_test_instance {
- struct list_head tsi_list; /* chain on batch */
- int tsi_service; /* test type */
- sfw_batch_t *tsi_batch; /* batch */
- sfw_test_client_ops_t *tsi_ops; /* test client operations */
+ struct list_head tsi_list; /* chain on batch */
+ int tsi_service; /* test type */
+ sfw_batch_t *tsi_batch; /* batch */
+ sfw_test_client_ops_t *tsi_ops; /* test client operation
+ */
/* public parameter for all test units */
- unsigned int tsi_is_client:1; /* is test client */
- unsigned int tsi_stoptsu_onerr:1; /* stop tsu on error */
- int tsi_concur; /* concurrency */
- int tsi_loop; /* loop count */
+ unsigned int tsi_is_client:1; /* is test client */
+ unsigned int tsi_stoptsu_onerr:1; /* stop tsu on error */
+ int tsi_concur; /* concurrency */
+ int tsi_loop; /* loop count */
/* status of test instance */
- spinlock_t tsi_lock; /* serialize */
- unsigned int tsi_stopping:1; /* test is stopping */
- atomic_t tsi_nactive; /* # of active test unit */
- struct list_head tsi_units; /* test units */
- struct list_head tsi_free_rpcs; /* free rpcs */
- struct list_head tsi_active_rpcs; /* active rpcs */
+ spinlock_t tsi_lock; /* serialize */
+ unsigned int tsi_stopping:1; /* test is stopping */
+ atomic_t tsi_nactive; /* # of active test
+ * unit */
+ struct list_head tsi_units; /* test units */
+ struct list_head tsi_free_rpcs; /* free rpcs */
+ struct list_head tsi_active_rpcs; /* active rpcs */
union {
- test_ping_req_t ping; /* ping parameter */
- test_bulk_req_t bulk_v0; /* bulk parameter */
- test_bulk_req_v1_t bulk_v1; /* bulk v1 parameter */
+ test_ping_req_t ping; /* ping parameter */
+ test_bulk_req_t bulk_v0; /* bulk parameter */
+ test_bulk_req_v1_t bulk_v1; /* bulk v1 parameter */
} tsi_u;
} sfw_test_instance_t;
@@ -394,18 +399,18 @@ typedef struct sfw_test_instance {
#define sfw_id_pages(n) (((n) + SFW_ID_PER_PAGE - 1) / SFW_ID_PER_PAGE)
typedef struct sfw_test_unit {
- struct list_head tsu_list; /* chain on lst_test_instance */
- lnet_process_id_t tsu_dest; /* id of dest node */
- int tsu_loop; /* loop count of the test */
- sfw_test_instance_t *tsu_instance; /* pointer to test instance */
- void *tsu_private; /* private data */
- swi_workitem_t tsu_worker; /* workitem of the test unit */
+ struct list_head tsu_list; /* chain on lst_test_instance */
+ lnet_process_id_t tsu_dest; /* id of dest node */
+ int tsu_loop; /* loop count of the test */
+ sfw_test_instance_t *tsu_instance; /* pointer to test instance */
+ void *tsu_private; /* private data */
+ swi_workitem_t tsu_worker; /* workitem of the test unit */
} sfw_test_unit_t;
typedef struct sfw_test_case {
- struct list_head tsc_list; /* chain on fw_tests */
- srpc_service_t *tsc_srv_service; /* test service */
- sfw_test_client_ops_t *tsc_cli_ops; /* ops of test client */
+ struct list_head tsc_list; /* chain on fw_tests */
+ srpc_service_t *tsc_srv_service; /* test service */
+ sfw_test_client_ops_t *tsc_cli_ops; /* ops of test client */
} sfw_test_case_t;
srpc_client_rpc_t *
@@ -501,9 +506,9 @@ void srpc_shutdown(void);
static inline void
srpc_destroy_client_rpc (srpc_client_rpc_t *rpc)
{
- LASSERT (rpc != NULL);
- LASSERT (!srpc_event_pending(rpc));
- LASSERT (atomic_read(&rpc->crpc_refcount) == 0);
+ LASSERT(rpc != NULL);
+ LASSERT(!srpc_event_pending(rpc));
+ LASSERT(atomic_read(&rpc->crpc_refcount) == 0);
if (rpc->crpc_fini == NULL) {
LIBCFS_FREE(rpc, srpc_client_rpc_size(rpc));
@@ -520,7 +525,7 @@ srpc_init_client_rpc (srpc_client_rpc_t *rpc, lnet_process_id_t peer,
void (*rpc_done)(srpc_client_rpc_t *),
void (*rpc_fini)(srpc_client_rpc_t *), void *priv)
{
- LASSERT (nbulkiov <= LNET_MAX_IOV);
+ LASSERT(nbulkiov <= LNET_MAX_IOV);
memset(rpc, 0, offsetof(srpc_client_rpc_t,
crpc_bulk.bk_iovs[nbulkiov]));
@@ -531,13 +536,13 @@ srpc_init_client_rpc (srpc_client_rpc_t *rpc, lnet_process_id_t peer,
spin_lock_init(&rpc->crpc_lock);
atomic_set(&rpc->crpc_refcount, 1); /* 1 ref for caller */
- rpc->crpc_dest = peer;
- rpc->crpc_priv = priv;
+ rpc->crpc_dest = peer;
+ rpc->crpc_priv = priv;
rpc->crpc_service = service;
rpc->crpc_bulk.bk_len = bulklen;
rpc->crpc_bulk.bk_niov = nbulkiov;
- rpc->crpc_done = rpc_done;
- rpc->crpc_fini = rpc_fini;
+ rpc->crpc_done = rpc_done;
+ rpc->crpc_fini = rpc_fini;
LNetInvalidateHandle(&rpc->crpc_reqstmdh);
LNetInvalidateHandle(&rpc->crpc_replymdh);
LNetInvalidateHandle(&rpc->crpc_bulk.bk_mdh);
diff --git a/drivers/staging/lustre/lnet/selftest/timer.c b/drivers/staging/lustre/lnet/selftest/timer.c
index 441f9472a834c6..6133b54f4a8204 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.c
+++ b/drivers/staging/lustre/lnet/selftest/timer.c
@@ -50,7 +50,7 @@
* sorted by increasing expiry time. The number of slots is 2**7 (128),
* to cover a time period of 1024 seconds into the future before wrapping.
*/
-#define STTIMER_MINPOLL 3 /* log2 min poll interval (8 s) */
+#define STTIMER_MINPOLL 3 /* log2 min poll interval (8 s) */
#define STTIMER_SLOTTIME (1 << STTIMER_MINPOLL)
#define STTIMER_SLOTTIMEMASK (~(STTIMER_SLOTTIME - 1))
#define STTIMER_NSLOTS (1 << 7)
@@ -58,13 +58,13 @@
(STTIMER_NSLOTS - 1))])
static struct st_timer_data {
- spinlock_t stt_lock;
- /* start time of the slot processed previously */
- unsigned long stt_prev_slot;
- struct list_head stt_hash[STTIMER_NSLOTS];
- int stt_shuttingdown;
- wait_queue_head_t stt_waitq;
- int stt_nthreads;
+ spinlock_t stt_lock;
+ unsigned long stt_prev_slot; /* start time of the slot processed
+ * previously */
+ struct list_head stt_hash[STTIMER_NSLOTS];
+ int stt_shuttingdown;
+ wait_queue_head_t stt_waitq;
+ int stt_nthreads;
} stt_data;
void
@@ -124,7 +124,7 @@ stt_del_timer(stt_timer_t *timer)
static int
stt_expire_list(struct list_head *slot, unsigned long now)
{
- int expired = 0;
+ int expired = 0;
stt_timer_t *timer;
while (!list_empty(slot)) {
@@ -148,7 +148,7 @@ stt_expire_list(struct list_head *slot, unsigned long now)
static int
stt_check_timers(unsigned long *last)
{
- int expired = 0;
+ int expired = 0;
unsigned long now;
unsigned long this_slot;
diff --git a/drivers/staging/lustre/lnet/selftest/timer.h b/drivers/staging/lustre/lnet/selftest/timer.h
index d727c1e2b0ce12..2a8803d89de463 100644
--- a/drivers/staging/lustre/lnet/selftest/timer.h
+++ b/drivers/staging/lustre/lnet/selftest/timer.h
@@ -39,15 +39,15 @@
#define __SELFTEST_TIMER_H__
typedef struct {
- struct list_head stt_list;
- unsigned long stt_expires;
- void (*stt_func) (void *);
- void *stt_data;
+ struct list_head stt_list;
+ unsigned long stt_expires;
+ void (*stt_func) (void *);
+ void *stt_data;
} stt_timer_t;
-void stt_add_timer (stt_timer_t *timer);
-int stt_del_timer (stt_timer_t *timer);
-int stt_startup (void);
-void stt_shutdown (void);
+void stt_add_timer(stt_timer_t *timer);
+int stt_del_timer(stt_timer_t *timer);
+int stt_startup(void);
+void stt_shutdown(void);
#endif /* __SELFTEST_TIMER_H__ */
diff --git a/drivers/staging/lustre/lustre/fid/Makefile b/drivers/staging/lustre/lustre/fid/Makefile
index 5513ce416a35e5..b7ef314b4b848f 100644
--- a/drivers/staging/lustre/lustre/fid/Makefile
+++ b/drivers/staging/lustre/lustre/fid/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += fid.o
-fid-y := fid_request.o fid_lib.o
-fid-$(CONFIG_PROC_FS) += lproc_fid.o
+fid-y := fid_request.o fid_lib.o lproc_fid.o
diff --git a/drivers/staging/lustre/lustre/fid/fid_internal.h b/drivers/staging/lustre/lustre/fid/fid_internal.h
index b5e8da8956f2bd..84daee1154dc5e 100644
--- a/drivers/staging/lustre/lustre/fid/fid_internal.h
+++ b/drivers/staging/lustre/lustre/fid/fid_internal.h
@@ -47,10 +47,6 @@
int seq_client_alloc_super(struct lu_client_seq *seq,
const struct lu_env *env);
-#if defined(CONFIG_PROC_FS)
-extern struct lprocfs_vars seq_client_proc_list[];
-#endif
-
-extern struct proc_dir_entry *seq_type_proc_dir;
+extern struct lprocfs_vars seq_client_debugfs_list[];
#endif /* __FID_INTERNAL_H */
diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c b/drivers/staging/lustre/lustre/fid/fid_request.c
index 063441abfcfc16..7b4e3c6782c3d3 100644
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -53,6 +53,8 @@
#include "../include/lustre_mdc.h"
#include "fid_internal.h"
+static struct dentry *seq_debugfs_dir;
+
static int seq_client_rpc(struct lu_client_seq *seq,
struct lu_seq_range *output, __u32 opc,
const char *opcname)
@@ -400,37 +402,32 @@ void seq_client_flush(struct lu_client_seq *seq)
}
EXPORT_SYMBOL(seq_client_flush);
-static void seq_client_proc_fini(struct lu_client_seq *seq)
+static void seq_client_debugfs_fini(struct lu_client_seq *seq)
{
-#if defined(CONFIG_PROC_FS)
- if (seq->lcs_proc_dir) {
- if (!IS_ERR(seq->lcs_proc_dir))
- lprocfs_remove(&seq->lcs_proc_dir);
- seq->lcs_proc_dir = NULL;
- }
-#endif /* CONFIG_PROC_FS */
+ if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry))
+ ldebugfs_remove(&seq->lcs_debugfs_entry);
}
-static int seq_client_proc_init(struct lu_client_seq *seq)
+static int seq_client_debugfs_init(struct lu_client_seq *seq)
{
-#if defined(CONFIG_PROC_FS)
int rc;
- seq->lcs_proc_dir = lprocfs_register(seq->lcs_name,
- seq_type_proc_dir,
- NULL, NULL);
+ seq->lcs_debugfs_entry = ldebugfs_register(seq->lcs_name,
+ seq_debugfs_dir,
+ NULL, NULL);
- if (IS_ERR(seq->lcs_proc_dir)) {
- CERROR("%s: LProcFS failed in seq-init\n",
- seq->lcs_name);
- rc = PTR_ERR(seq->lcs_proc_dir);
+ if (IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) {
+ CERROR("%s: LdebugFS failed in seq-init\n", seq->lcs_name);
+ rc = seq->lcs_debugfs_entry ? PTR_ERR(seq->lcs_debugfs_entry)
+ : -ENOMEM;
+ seq->lcs_debugfs_entry = NULL;
return rc;
}
- rc = lprocfs_add_vars(seq->lcs_proc_dir,
- seq_client_proc_list, seq);
+ rc = ldebugfs_add_vars(seq->lcs_debugfs_entry,
+ seq_client_debugfs_list, seq);
if (rc) {
- CERROR("%s: Can't init sequence manager proc, rc %d\n",
+ CERROR("%s: Can't init sequence manager debugfs, rc %d\n",
seq->lcs_name, rc);
goto out_cleanup;
}
@@ -438,12 +435,8 @@ static int seq_client_proc_init(struct lu_client_seq *seq)
return 0;
out_cleanup:
- seq_client_proc_fini(seq);
+ seq_client_debugfs_fini(seq);
return rc;
-
-#else /* CONFIG_PROC_FS */
- return 0;
-#endif
}
int seq_client_init(struct lu_client_seq *seq,
@@ -478,7 +471,7 @@ int seq_client_init(struct lu_client_seq *seq,
snprintf(seq->lcs_name, sizeof(seq->lcs_name),
"cli-%s", prefix);
- rc = seq_client_proc_init(seq);
+ rc = seq_client_debugfs_init(seq);
if (rc)
seq_client_fini(seq);
return rc;
@@ -487,7 +480,7 @@ EXPORT_SYMBOL(seq_client_init);
void seq_client_fini(struct lu_client_seq *seq)
{
- seq_client_proc_fini(seq);
+ seq_client_debugfs_fini(seq);
if (seq->lcs_exp != NULL) {
class_export_put(seq->lcs_exp);
@@ -505,11 +498,11 @@ int client_fid_init(struct obd_device *obd,
char *prefix;
int rc;
- OBD_ALLOC_PTR(cli->cl_seq);
+ cli->cl_seq = kzalloc(sizeof(*cli->cl_seq), GFP_NOFS);
if (cli->cl_seq == NULL)
return -ENOMEM;
- OBD_ALLOC(prefix, MAX_OBD_NAME + 5);
+ prefix = kzalloc(MAX_OBD_NAME + 5, GFP_NOFS);
if (prefix == NULL) {
rc = -ENOMEM;
goto out_free_seq;
@@ -519,13 +512,13 @@ int client_fid_init(struct obd_device *obd,
/* Init client side sequence-manager */
rc = seq_client_init(cli->cl_seq, exp, type, prefix, NULL);
- OBD_FREE(prefix, MAX_OBD_NAME + 5);
+ kfree(prefix);
if (rc)
goto out_free_seq;
return rc;
out_free_seq:
- OBD_FREE_PTR(cli->cl_seq);
+ kfree(cli->cl_seq);
cli->cl_seq = NULL;
return rc;
}
@@ -537,7 +530,7 @@ int client_fid_fini(struct obd_device *obd)
if (cli->cl_seq != NULL) {
seq_client_fini(cli->cl_seq);
- OBD_FREE_PTR(cli->cl_seq);
+ kfree(cli->cl_seq);
cli->cl_seq = NULL;
}
@@ -545,22 +538,18 @@ int client_fid_fini(struct obd_device *obd)
}
EXPORT_SYMBOL(client_fid_fini);
-struct proc_dir_entry *seq_type_proc_dir;
-
static int __init fid_mod_init(void)
{
- seq_type_proc_dir = lprocfs_register(LUSTRE_SEQ_NAME,
- proc_lustre_root,
- NULL, NULL);
- return PTR_ERR_OR_ZERO(seq_type_proc_dir);
+ seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME,
+ debugfs_lustre_root,
+ NULL, NULL);
+ return PTR_ERR_OR_ZERO(seq_debugfs_dir);
}
static void __exit fid_mod_exit(void)
{
- if (seq_type_proc_dir != NULL && !IS_ERR(seq_type_proc_dir)) {
- lprocfs_remove(&seq_type_proc_dir);
- seq_type_proc_dir = NULL;
- }
+ if (!IS_ERR_OR_NULL(seq_debugfs_dir))
+ ldebugfs_remove(&seq_debugfs_dir);
}
MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
diff --git a/drivers/staging/lustre/lustre/fid/lproc_fid.c b/drivers/staging/lustre/lustre/fid/lproc_fid.c
index 783939dbd4db13..41ab2eeaf18c7c 100644
--- a/drivers/staging/lustre/lustre/fid/lproc_fid.c
+++ b/drivers/staging/lustre/lustre/fid/lproc_fid.c
@@ -59,8 +59,9 @@
* Note: this function is only used for testing, it is no safe for production
* use.
*/
-static int lprocfs_fid_write_common(const char __user *buffer, size_t count,
- struct lu_seq_range *range)
+static int
+ldebugfs_fid_write_common(const char __user *buffer, size_t count,
+ struct lu_seq_range *range)
{
struct lu_seq_range tmp;
int rc;
@@ -92,10 +93,11 @@ static int lprocfs_fid_write_common(const char __user *buffer, size_t count,
return count;
}
-/* Client side procfs stuff */
-static ssize_t lprocfs_fid_space_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+/* Client side debugfs stuff */
+static ssize_t
+ldebugfs_fid_space_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct lu_client_seq *seq;
int rc;
@@ -104,7 +106,7 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file,
LASSERT(seq != NULL);
mutex_lock(&seq->lcs_mutex);
- rc = lprocfs_fid_write_common(buffer, count, &seq->lcs_space);
+ rc = ldebugfs_fid_write_common(buffer, count, &seq->lcs_space);
if (rc == 0) {
CDEBUG(D_INFO, "%s: Space: "DRANGE"\n",
@@ -117,7 +119,7 @@ static ssize_t lprocfs_fid_space_seq_write(struct file *file,
}
static int
-lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
+ldebugfs_fid_space_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
@@ -130,9 +132,10 @@ lprocfs_fid_space_seq_show(struct seq_file *m, void *unused)
return 0;
}
-static ssize_t lprocfs_fid_width_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t
+ldebugfs_fid_width_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct lu_client_seq *seq;
__u64 max;
@@ -166,7 +169,7 @@ static ssize_t lprocfs_fid_width_seq_write(struct file *file,
}
static int
-lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
+ldebugfs_fid_width_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
@@ -180,7 +183,7 @@ lprocfs_fid_width_seq_show(struct seq_file *m, void *unused)
}
static int
-lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
+ldebugfs_fid_fid_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
@@ -194,7 +197,7 @@ lprocfs_fid_fid_seq_show(struct seq_file *m, void *unused)
}
static int
-lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
+ldebugfs_fid_server_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_seq *seq = (struct lu_client_seq *)m->private;
struct client_obd *cli;
@@ -211,15 +214,15 @@ lprocfs_fid_server_seq_show(struct seq_file *m, void *unused)
return 0;
}
-LPROC_SEQ_FOPS(lprocfs_fid_space);
-LPROC_SEQ_FOPS(lprocfs_fid_width);
-LPROC_SEQ_FOPS_RO(lprocfs_fid_server);
-LPROC_SEQ_FOPS_RO(lprocfs_fid_fid);
+LPROC_SEQ_FOPS(ldebugfs_fid_space);
+LPROC_SEQ_FOPS(ldebugfs_fid_width);
+LPROC_SEQ_FOPS_RO(ldebugfs_fid_server);
+LPROC_SEQ_FOPS_RO(ldebugfs_fid_fid);
-struct lprocfs_vars seq_client_proc_list[] = {
- { "space", &lprocfs_fid_space_fops },
- { "width", &lprocfs_fid_width_fops },
- { "server", &lprocfs_fid_server_fops },
- { "fid", &lprocfs_fid_fid_fops },
+struct lprocfs_vars seq_client_debugfs_list[] = {
+ { "space", &ldebugfs_fid_space_fops },
+ { "width", &ldebugfs_fid_width_fops },
+ { "server", &ldebugfs_fid_server_fops },
+ { "fid", &ldebugfs_fid_fid_fops },
{ NULL }
};
diff --git a/drivers/staging/lustre/lustre/fld/Makefile b/drivers/staging/lustre/lustre/fld/Makefile
index 2bbf08433dcaae..646e315d1aa899 100644
--- a/drivers/staging/lustre/lustre/fld/Makefile
+++ b/drivers/staging/lustre/lustre/fld/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += fld.o
-fld-y := fld_request.o fld_cache.o
-fld-$(CONFIG_PROC_FS) += lproc_fld.o
+fld-y := fld_request.o fld_cache.o lproc_fld.o
diff --git a/drivers/staging/lustre/lustre/fld/fld_cache.c b/drivers/staging/lustre/lustre/fld/fld_cache.c
index 0d0a73745065ee..ec2fc4339a2e75 100644
--- a/drivers/staging/lustre/lustre/fld/fld_cache.c
+++ b/drivers/staging/lustre/lustre/fld/fld_cache.c
@@ -69,7 +69,7 @@ struct fld_cache *fld_cache_init(const char *name,
LASSERT(name != NULL);
LASSERT(cache_threshold < cache_size);
- OBD_ALLOC_PTR(cache);
+ cache = kzalloc(sizeof(*cache), GFP_NOFS);
if (cache == NULL)
return ERR_PTR(-ENOMEM);
@@ -116,7 +116,7 @@ void fld_cache_fini(struct fld_cache *cache)
CDEBUG(D_INFO, " Cache reqs: %llu\n", cache->fci_stat.fst_cache);
CDEBUG(D_INFO, " Cache hits: %llu%%\n", pct);
- OBD_FREE_PTR(cache);
+ kfree(cache);
}
/**
@@ -128,7 +128,7 @@ void fld_cache_entry_delete(struct fld_cache *cache,
list_del(&node->fce_list);
list_del(&node->fce_lru);
cache->fci_cache_count--;
- OBD_FREE_PTR(node);
+ kfree(node);
}
/**
@@ -268,7 +268,7 @@ static void fld_cache_punch_hole(struct fld_cache *cache,
OBD_ALLOC_GFP(fldt, sizeof(*fldt), GFP_ATOMIC);
if (!fldt) {
- OBD_FREE_PTR(f_new);
+ kfree(f_new);
/* overlap is not allowed, so dont mess up list. */
return;
}
@@ -315,7 +315,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache,
f_curr->fce_range.lsr_end = max(f_curr->fce_range.lsr_end,
new_end);
- OBD_FREE_PTR(f_new);
+ kfree(f_new);
fld_fix_new_list(cache);
} else if (new_start <= f_curr->fce_range.lsr_start &&
@@ -324,7 +324,7 @@ static void fld_cache_overlap_handle(struct fld_cache *cache,
* e.g. whole range migrated. update fld cache entry */
f_curr->fce_range = *range;
- OBD_FREE_PTR(f_new);
+ kfree(f_new);
fld_fix_new_list(cache);
} else if (f_curr->fce_range.lsr_start < new_start &&
@@ -364,7 +364,7 @@ struct fld_cache_entry
LASSERT(range_is_sane(range));
- OBD_ALLOC_PTR(f_new);
+ f_new = kzalloc(sizeof(*f_new), GFP_NOFS);
if (!f_new)
return ERR_PTR(-ENOMEM);
@@ -440,7 +440,7 @@ int fld_cache_insert(struct fld_cache *cache,
rc = fld_cache_insert_nolock(cache, flde);
write_unlock(&cache->fci_lock);
if (rc)
- OBD_FREE_PTR(flde);
+ kfree(flde);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/fld/fld_internal.h b/drivers/staging/lustre/lustre/fld/fld_internal.h
index 68bec76584632a..844576b9bc6f54 100644
--- a/drivers/staging/lustre/lustre/fld/fld_internal.h
+++ b/drivers/staging/lustre/lustre/fld/fld_internal.h
@@ -142,10 +142,7 @@ extern struct lu_fld_hash fld_hash[];
int fld_client_rpc(struct obd_export *exp,
struct lu_seq_range *range, __u32 fld_op);
-#if defined(CONFIG_PROC_FS)
-extern struct lprocfs_vars fld_client_proc_list[];
-#endif
-
+extern struct lprocfs_vars fld_client_debugfs_list[];
struct fld_cache *fld_cache_init(const char *name,
int cache_size, int cache_threshold);
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c b/drivers/staging/lustre/lustre/fld/fld_request.c
index 6ac225e90ee079..c3b47f2346df6b 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -221,7 +221,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
CDEBUG(D_INFO, "%s: Adding target %s (idx %llu)\n",
fld->lcf_name, name, tar->ft_idx);
- OBD_ALLOC_PTR(target);
+ target = kzalloc(sizeof(*target), GFP_NOFS);
if (target == NULL)
return -ENOMEM;
@@ -229,7 +229,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
list_for_each_entry(tmp, &fld->lcf_targets, ft_chain) {
if (tmp->ft_idx == tar->ft_idx) {
spin_unlock(&fld->lcf_lock);
- OBD_FREE_PTR(target);
+ kfree(target);
CERROR("Target %s exists in FLD and known as %s:#%llu\n",
name, fld_target_name(tmp), tmp->ft_idx);
return -EEXIST;
@@ -268,7 +268,7 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
if (target->ft_exp != NULL)
class_export_put(target->ft_exp);
- OBD_FREE_PTR(target);
+ kfree(target);
return 0;
}
}
@@ -277,58 +277,44 @@ int fld_client_del_target(struct lu_client_fld *fld, __u64 idx)
}
EXPORT_SYMBOL(fld_client_del_target);
-static struct proc_dir_entry *fld_type_proc_dir;
+static struct dentry *fld_debugfs_dir;
-#if defined(CONFIG_PROC_FS)
-static int fld_client_proc_init(struct lu_client_fld *fld)
+static int fld_client_debugfs_init(struct lu_client_fld *fld)
{
int rc;
- fld->lcf_proc_dir = lprocfs_register(fld->lcf_name,
- fld_type_proc_dir,
- NULL, NULL);
+ fld->lcf_debugfs_entry = ldebugfs_register(fld->lcf_name,
+ fld_debugfs_dir,
+ NULL, NULL);
- if (IS_ERR(fld->lcf_proc_dir)) {
- CERROR("%s: LProcFS failed in fld-init\n",
- fld->lcf_name);
- rc = PTR_ERR(fld->lcf_proc_dir);
+ if (IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) {
+ CERROR("%s: LdebugFS failed in fld-init\n", fld->lcf_name);
+ rc = fld->lcf_debugfs_entry ? PTR_ERR(fld->lcf_debugfs_entry)
+ : -ENOMEM;
+ fld->lcf_debugfs_entry = NULL;
return rc;
}
- rc = lprocfs_add_vars(fld->lcf_proc_dir,
- fld_client_proc_list, fld);
+ rc = ldebugfs_add_vars(fld->lcf_debugfs_entry,
+ fld_client_debugfs_list, fld);
if (rc) {
- CERROR("%s: Can't init FLD proc, rc %d\n",
- fld->lcf_name, rc);
+ CERROR("%s: Can't init FLD debufs, rc %d\n", fld->lcf_name, rc);
goto out_cleanup;
}
return 0;
out_cleanup:
- fld_client_proc_fini(fld);
+ fld_client_debugfs_fini(fld);
return rc;
}
-void fld_client_proc_fini(struct lu_client_fld *fld)
+void fld_client_debugfs_fini(struct lu_client_fld *fld)
{
- if (fld->lcf_proc_dir) {
- if (!IS_ERR(fld->lcf_proc_dir))
- lprocfs_remove(&fld->lcf_proc_dir);
- fld->lcf_proc_dir = NULL;
- }
-}
-#else
-static int fld_client_proc_init(struct lu_client_fld *fld)
-{
- return 0;
+ if (!IS_ERR_OR_NULL(fld->lcf_debugfs_entry))
+ ldebugfs_remove(&fld->lcf_debugfs_entry);
}
-
-void fld_client_proc_fini(struct lu_client_fld *fld)
-{
-}
-#endif
-EXPORT_SYMBOL(fld_client_proc_fini);
+EXPORT_SYMBOL(fld_client_debugfs_fini);
static inline int hash_is_sane(int hash)
{
@@ -372,7 +358,7 @@ int fld_client_init(struct lu_client_fld *fld,
goto out;
}
- rc = fld_client_proc_init(fld);
+ rc = fld_client_debugfs_init(fld);
if (rc)
goto out;
out:
@@ -396,7 +382,7 @@ void fld_client_fini(struct lu_client_fld *fld)
list_del(&target->ft_chain);
if (target->ft_exp != NULL)
class_export_put(target->ft_exp);
- OBD_FREE_PTR(target);
+ kfree(target);
}
spin_unlock(&fld->lcf_lock);
@@ -504,18 +490,16 @@ EXPORT_SYMBOL(fld_client_flush);
static int __init fld_mod_init(void)
{
- fld_type_proc_dir = lprocfs_register(LUSTRE_FLD_NAME,
- proc_lustre_root,
- NULL, NULL);
- return PTR_ERR_OR_ZERO(fld_type_proc_dir);
+ fld_debugfs_dir = ldebugfs_register(LUSTRE_FLD_NAME,
+ debugfs_lustre_root,
+ NULL, NULL);
+ return PTR_ERR_OR_ZERO(fld_debugfs_dir);
}
static void __exit fld_mod_exit(void)
{
- if (fld_type_proc_dir != NULL && !IS_ERR(fld_type_proc_dir)) {
- lprocfs_remove(&fld_type_proc_dir);
- fld_type_proc_dir = NULL;
- }
+ if (!IS_ERR_OR_NULL(fld_debugfs_dir))
+ ldebugfs_remove(&fld_debugfs_dir);
}
MODULE_AUTHOR("Sun Microsystems, Inc. <http://www.lustre.org/>");
diff --git a/drivers/staging/lustre/lustre/fld/lproc_fld.c b/drivers/staging/lustre/lustre/fld/lproc_fld.c
index f53fdcfae34e2a..b35ff288dbd5ea 100644
--- a/drivers/staging/lustre/lustre/fld/lproc_fld.c
+++ b/drivers/staging/lustre/lustre/fld/lproc_fld.c
@@ -56,7 +56,7 @@
#include "fld_internal.h"
static int
-fld_proc_targets_seq_show(struct seq_file *m, void *unused)
+fld_debugfs_targets_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
struct lu_fld_target *target;
@@ -73,7 +73,7 @@ fld_proc_targets_seq_show(struct seq_file *m, void *unused)
}
static int
-fld_proc_hash_seq_show(struct seq_file *m, void *unused)
+fld_debugfs_hash_seq_show(struct seq_file *m, void *unused)
{
struct lu_client_fld *fld = (struct lu_client_fld *)m->private;
@@ -87,9 +87,9 @@ fld_proc_hash_seq_show(struct seq_file *m, void *unused)
}
static ssize_t
-fld_proc_hash_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+fld_debugfs_hash_seq_write(struct file *file,
+ const char __user *buffer,
+ size_t count, loff_t *off)
{
struct lu_client_fld *fld;
struct lu_fld_hash *hash = NULL;
@@ -128,8 +128,8 @@ fld_proc_hash_seq_write(struct file *file,
}
static ssize_t
-fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *pos)
+fld_debugfs_cache_flush_write(struct file *file, const char __user *buffer,
+ size_t count, loff_t *pos)
{
struct lu_client_fld *fld = file->private_data;
@@ -142,31 +142,33 @@ fld_proc_cache_flush_write(struct file *file, const char __user *buffer,
return count;
}
-static int fld_proc_cache_flush_open(struct inode *inode, struct file *file)
+static int
+fld_debugfs_cache_flush_open(struct inode *inode, struct file *file)
{
- file->private_data = PDE_DATA(inode);
+ file->private_data = inode->i_private;
return 0;
}
-static int fld_proc_cache_flush_release(struct inode *inode, struct file *file)
+static int
+fld_debugfs_cache_flush_release(struct inode *inode, struct file *file)
{
file->private_data = NULL;
return 0;
}
-static struct file_operations fld_proc_cache_flush_fops = {
+static struct file_operations fld_debugfs_cache_flush_fops = {
.owner = THIS_MODULE,
- .open = fld_proc_cache_flush_open,
- .write = fld_proc_cache_flush_write,
- .release = fld_proc_cache_flush_release,
+ .open = fld_debugfs_cache_flush_open,
+ .write = fld_debugfs_cache_flush_write,
+ .release = fld_debugfs_cache_flush_release,
};
-LPROC_SEQ_FOPS_RO(fld_proc_targets);
-LPROC_SEQ_FOPS(fld_proc_hash);
+LPROC_SEQ_FOPS_RO(fld_debugfs_targets);
+LPROC_SEQ_FOPS(fld_debugfs_hash);
-struct lprocfs_vars fld_client_proc_list[] = {
- { "targets", &fld_proc_targets_fops },
- { "hash", &fld_proc_hash_fops },
- { "cache_flush", &fld_proc_cache_flush_fops },
+struct lprocfs_vars fld_client_debugfs_list[] = {
+ { "targets", &fld_debugfs_targets_fops },
+ { "hash", &fld_debugfs_hash_fops },
+ { "cache_flush", &fld_debugfs_cache_flush_fops },
{ NULL }
};
diff --git a/drivers/staging/lustre/lustre/include/dt_object.h b/drivers/staging/lustre/lustre/include/dt_object.h
index be4c7d95e7884f..abae31b41e744f 100644
--- a/drivers/staging/lustre/lustre/include/dt_object.h
+++ b/drivers/staging/lustre/lustre/include/dt_object.h
@@ -58,7 +58,6 @@
#include "../../include/linux/libcfs/libcfs.h"
struct seq_file;
-struct proc_dir_entry;
struct lustre_cfg;
struct thandle;
@@ -1481,7 +1480,6 @@ static inline struct dt_thread_info *dt_info(const struct lu_env *env)
int dt_global_init(void);
void dt_global_fini(void);
-#if defined (CONFIG_PROC_FS)
int lprocfs_dt_rd_blksize(char *page, char **start, off_t off,
int count, int *eof, void *data);
int lprocfs_dt_rd_kbytestotal(char *page, char **start, off_t off,
@@ -1494,6 +1492,5 @@ int lprocfs_dt_rd_filestotal(char *page, char **start, off_t off,
int count, int *eof, void *data);
int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off,
int count, int *eof, void *data);
-#endif /* CONFIG_PROC_FS */
#endif /* __LUSTRE_DT_OBJECT_H */
diff --git a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h
index a7658a99a08d87..45651caf42ccf6 100644
--- a/drivers/staging/lustre/lustre/include/linux/lustre_lite.h
+++ b/drivers/staging/lustre/lustre/include/linux/lustre_lite.h
@@ -44,7 +44,6 @@
#include <linux/fs.h>
#include <linux/dcache.h>
-#include <linux/proc_fs.h>
#include "../obd_class.h"
#include "../lustre_net.h"
diff --git a/drivers/staging/lustre/lustre/include/linux/obd.h b/drivers/staging/lustre/lustre/include/linux/obd.h
index 9cd8683573ce61..2817e88e014a45 100644
--- a/drivers/staging/lustre/lustre/include/linux/obd.h
+++ b/drivers/staging/lustre/lustre/include/linux/obd.h
@@ -43,11 +43,11 @@
#include "../obd_support.h"
-# include <linux/fs.h>
-# include <linux/list.h>
-# include <linux/sched.h> /* for struct task_struct, for current.h */
-# include <linux/proc_fs.h>
-# include <linux/mount.h>
+#include <linux/fs.h>
+#include <linux/list.h>
+#include <linux/sched.h> /* for struct task_struct, for current.h */
+#include <linux/mount.h>
+
#include "../lustre_intent.h"
struct ll_iattr {
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index d030847e51bada..3292fd3c588a56 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -42,7 +42,7 @@
#ifndef _LPROCFS_SNMP_H
#define _LPROCFS_SNMP_H
-#include <linux/proc_fs.h>
+#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/types.h>
@@ -60,8 +60,8 @@ struct lprocfs_vars {
};
struct lprocfs_static_vars {
- struct lprocfs_vars *module_vars;
struct lprocfs_vars *obd_vars;
+ struct attribute_group *sysfs_vars;
};
/* if we find more consumers this could be generalized */
@@ -348,7 +348,8 @@ enum {
#define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
/* class_obd.c */
-extern struct proc_dir_entry *proc_lustre_root;
+extern struct dentry *debugfs_lustre_root;
+extern struct kobject *lustre_kobj;
struct obd_device;
struct obd_histogram;
@@ -378,8 +379,6 @@ extern int lprocfs_write_frac_helper(const char __user *buffer,
unsigned long count, int *val, int mult);
extern int lprocfs_read_frac_helper(char *buffer, unsigned long count,
long val, int mult);
-#if defined (CONFIG_PROC_FS)
-
extern int lprocfs_stats_alloc_one(struct lprocfs_stats *stats,
unsigned int cpuid);
/*
@@ -556,53 +555,45 @@ extern void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
extern void lprocfs_free_obd_stats(struct obd_device *obddev);
extern void lprocfs_free_md_stats(struct obd_device *obddev);
struct obd_export;
-struct nid_stat;
-extern int lprocfs_add_clear_entry(struct obd_device *obd,
- struct proc_dir_entry *entry);
-extern int lprocfs_exp_setup(struct obd_export *exp,
- lnet_nid_t *peer_nid, int *newnid);
extern int lprocfs_exp_cleanup(struct obd_export *exp);
-extern struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root,
- char *name,
- void *data,
- struct file_operations *fops);
-extern struct proc_dir_entry *
-lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
+extern struct dentry *ldebugfs_add_simple(struct dentry *root,
+ char *name,
+ void *data,
+ struct file_operations *fops);
+extern struct dentry *
+ldebugfs_add_symlink(const char *name, struct dentry *parent,
const char *format, ...);
-extern void lprocfs_free_per_client_stats(struct obd_device *obd);
-extern int
-lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
- unsigned long count, void *data);
-extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data);
-extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
- struct lprocfs_stats *stats);
+extern int ldebugfs_register_stats(struct dentry *parent,
+ const char *name,
+ struct lprocfs_stats *stats);
/* lprocfs_status.c */
-extern int lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *var,
- void *data);
+extern int ldebugfs_add_vars(struct dentry *parent,
+ struct lprocfs_vars *var,
+ void *data);
-extern struct proc_dir_entry *lprocfs_register(const char *name,
- struct proc_dir_entry *parent,
- struct lprocfs_vars *list,
- void *data);
+extern struct dentry *ldebugfs_register(const char *name,
+ struct dentry *parent,
+ struct lprocfs_vars *list,
+ void *data);
-extern void lprocfs_remove(struct proc_dir_entry **root);
-extern void lprocfs_remove_proc_entry(const char *name,
- struct proc_dir_entry *parent);
+extern void ldebugfs_remove(struct dentry **entryp);
-extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
+extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
+ struct attribute_group *attrs);
extern int lprocfs_obd_cleanup(struct obd_device *obd);
-extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
- umode_t mode,
- const struct file_operations *seq_fops,
- void *data);
-extern int lprocfs_obd_seq_create(struct obd_device *dev, const char *name,
- umode_t mode,
- const struct file_operations *seq_fops,
- void *data);
+extern int ldebugfs_seq_create(struct dentry *parent,
+ const char *name,
+ umode_t mode,
+ const struct file_operations *seq_fops,
+ void *data);
+extern int ldebugfs_obd_seq_create(struct obd_device *dev,
+ const char *name,
+ umode_t mode,
+ const struct file_operations *seq_fops,
+ void *data);
/* Generic callbacks */
@@ -613,15 +604,12 @@ extern int lprocfs_wr_atomic(struct file *file, const char __user *buffer,
extern int lprocfs_rd_uint(struct seq_file *m, void *data);
extern int lprocfs_wr_uint(struct file *file, const char __user *buffer,
unsigned long count, void *data);
-extern int lprocfs_rd_uuid(struct seq_file *m, void *data);
extern int lprocfs_rd_name(struct seq_file *m, void *data);
extern int lprocfs_rd_server_uuid(struct seq_file *m, void *data);
extern int lprocfs_rd_conn_uuid(struct seq_file *m, void *data);
extern int lprocfs_rd_import(struct seq_file *m, void *data);
extern int lprocfs_rd_state(struct seq_file *m, void *data);
extern int lprocfs_rd_connect_flags(struct seq_file *m, void *data);
-extern int lprocfs_rd_num_exports(struct seq_file *m, void *data);
-extern int lprocfs_rd_numrefs(struct seq_file *m, void *data);
struct adaptive_timeout;
extern int lprocfs_at_hist_helper(struct seq_file *m,
@@ -640,12 +628,6 @@ extern int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
size_t count, loff_t *off);
/* Statfs helpers */
-extern int lprocfs_rd_blksize(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytestotal(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytesfree(struct seq_file *m, void *data);
-extern int lprocfs_rd_kbytesavail(struct seq_file *m, void *data);
-extern int lprocfs_rd_filestotal(struct seq_file *m, void *data);
-extern int lprocfs_rd_filesfree(struct seq_file *m, void *data);
extern int lprocfs_write_helper(const char __user *buffer, unsigned long count,
int *val);
@@ -685,11 +667,11 @@ extern int lprocfs_seq_release(struct inode *, struct file *);
/* write the name##_seq_show function, call LPROC_SEQ_FOPS_RO for read-only
proc entries; otherwise, you will define name##_seq_write function also for
a read-write proc entry, and then call LPROC_SEQ_SEQ instead. Finally,
- call lprocfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
+ call ldebugfs_obd_seq_create(obd, filename, 0444, &name#_fops, data); */
#define __LPROC_SEQ_FOPS(name, custom_seq_write) \
static int name##_single_open(struct inode *inode, struct file *file) \
{ \
- return single_open(file, name##_seq_show, PDE_DATA(inode)); \
+ return single_open(file, name##_seq_show, inode->i_private); \
} \
static struct file_operations name##_fops = { \
.owner = THIS_MODULE, \
@@ -734,7 +716,7 @@ static struct file_operations name##_fops = { \
} \
static int name##_##type##_open(struct inode *inode, struct file *file) \
{ \
- return single_open(file, NULL, PDE_DATA(inode)); \
+ return single_open(file, NULL, inode->i_private); \
} \
static struct file_operations name##_##type##_fops = { \
.open = name##_##type##_open, \
@@ -742,6 +724,27 @@ static struct file_operations name##_fops = { \
.release = lprocfs_single_release, \
}
+struct lustre_attr {
+ struct attribute attr;
+ ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len);
+};
+
+#define LUSTRE_ATTR(name, mode, show, store) \
+static struct lustre_attr lustre_attr_##name = __ATTR(name, mode, show, store)
+
+#define LUSTRE_RO_ATTR(name) LUSTRE_ATTR(name, 0444, name##_show, NULL)
+#define LUSTRE_RW_ATTR(name) LUSTRE_ATTR(name, 0644, name##_show, name##_store)
+
+ssize_t lustre_attr_show(struct kobject *kobj, struct attribute *attr,
+ char *buf);
+ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len);
+
+extern const struct sysfs_ops lustre_sysfs_ops;
+
/* lproc_ptlrpc.c */
struct ptlrpc_request;
extern void target_print_req(void *seq_file, struct ptlrpc_request *req);
@@ -810,206 +813,4 @@ extern int lprocfs_quota_rd_qs_factor(char *page, char **start, loff_t off,
extern int lprocfs_quota_wr_qs_factor(struct file *file,
const char *buffer,
unsigned long count, void *data);
-#else
-/* CONFIG_PROC_FS is not defined */
-
-#define proc_lustre_root NULL
-
-static inline void lprocfs_counter_add(struct lprocfs_stats *stats,
- int index, long amount)
-{ return; }
-static inline void lprocfs_counter_incr(struct lprocfs_stats *stats,
- int index)
-{ return; }
-static inline void lprocfs_counter_sub(struct lprocfs_stats *stats,
- int index, long amount)
-{ return; }
-static inline void lprocfs_counter_decr(struct lprocfs_stats *stats,
- int index)
-{ return; }
-static inline void lprocfs_counter_init(struct lprocfs_stats *stats,
- int index, unsigned conf,
- const char *name, const char *units)
-{ return; }
-
-static inline __u64 lc_read_helper(struct lprocfs_counter *lc,
- enum lprocfs_fields_flags field)
-{ return 0; }
-
-/* NB: we return !NULL to satisfy error checker */
-static inline struct lprocfs_stats *
-lprocfs_alloc_stats(unsigned int num, enum lprocfs_stats_flags flags)
-{ return (struct lprocfs_stats *)1; }
-static inline void lprocfs_clear_stats(struct lprocfs_stats *stats)
-{ return; }
-static inline void lprocfs_free_stats(struct lprocfs_stats **stats)
-{ return; }
-static inline int lprocfs_register_stats(struct proc_dir_entry *root,
- const char *name,
- struct lprocfs_stats *stats)
-{ return 0; }
-static inline void lprocfs_init_ops_stats(int num_private_stats,
- struct lprocfs_stats *stats)
-{ return; }
-static inline void lprocfs_init_mps_stats(int num_private_stats,
- struct lprocfs_stats *stats)
-{ return; }
-static inline void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
-{ return; }
-static inline int lprocfs_alloc_obd_stats(struct obd_device *obddev,
- unsigned int num_private_stats)
-{ return 0; }
-static inline int lprocfs_alloc_md_stats(struct obd_device *obddev,
- unsigned int num_private_stats)
-{ return 0; }
-static inline void lprocfs_free_obd_stats(struct obd_device *obddev)
-{ return; }
-static inline void lprocfs_free_md_stats(struct obd_device *obddev)
-{ return; }
-
-struct obd_export;
-static inline int lprocfs_add_clear_entry(struct obd_export *exp)
-{ return 0; }
-static inline int lprocfs_exp_setup(struct obd_export *exp,
- lnet_nid_t *peer_nid,
- int *newnid)
-{ return 0; }
-static inline int lprocfs_exp_cleanup(struct obd_export *exp)
-{ return 0; }
-static inline struct proc_dir_entry *
-lprocfs_add_simple(struct proc_dir_entry *root, char *name,
- void *data, struct file_operations *fops)
-{return 0; }
-static inline struct proc_dir_entry *
-lprocfs_add_symlink(const char *name, struct proc_dir_entry *parent,
- const char *format, ...)
-{return NULL; }
-static inline void lprocfs_free_per_client_stats(struct obd_device *obd)
-{ return; }
-static inline
-int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{return count;}
-static inline
-int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
-{ return 0; }
-
-static inline struct proc_dir_entry *
-lprocfs_register(const char *name, struct proc_dir_entry *parent,
- struct lprocfs_vars *list, void *data)
-{ return NULL; }
-static inline int lprocfs_add_vars(struct proc_dir_entry *root,
- struct lprocfs_vars *var,
- void *data)
-{ return 0; }
-static inline void lprocfs_remove(struct proc_dir_entry **root)
-{ return; }
-static inline void lprocfs_remove_proc_entry(const char *name,
- struct proc_dir_entry *parent)
-{ return; }
-static inline int lprocfs_obd_setup(struct obd_device *dev,
- struct lprocfs_vars *list)
-{ return 0; }
-static inline int lprocfs_obd_cleanup(struct obd_device *dev)
-{ return 0; }
-static inline int lprocfs_rd_u64(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_uuid(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_name(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_conn_uuid(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_import(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_pinger_recov(struct seq_file *m, void *n)
-{ return 0; }
-static inline int lprocfs_rd_state(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_rd_num_exports(struct seq_file *m, void *data)
-{ return 0; }
-extern inline int lprocfs_rd_numrefs(struct seq_file *m, void *data)
-{ return 0; }
-struct adaptive_timeout;
-static inline int lprocfs_at_hist_helper(struct seq_file *m,
- struct adaptive_timeout *at)
-{ return 0; }
-static inline int lprocfs_rd_timeouts(struct seq_file *m, void *data)
-{ return 0; }
-static inline int lprocfs_wr_timeouts(struct file *file,
- const char __user *buffer,
- unsigned long count, void *data)
-{ return 0; }
-static inline int lprocfs_wr_evict_client(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{ return 0; }
-static inline int lprocfs_wr_ping(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{ return 0; }
-static inline int lprocfs_wr_import(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{ return 0; }
-static inline int lprocfs_wr_pinger_recov(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{ return 0; }
-
-/* Statfs helpers */
-static inline
-int lprocfs_rd_blksize(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_filestotal(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-int lprocfs_rd_filesfree(struct seq_file *m, void *data)
-{ return 0; }
-static inline
-void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
-{ return; }
-static inline
-void lprocfs_oh_tally_log2(struct obd_histogram *oh, unsigned int value)
-{ return; }
-static inline
-void lprocfs_oh_clear(struct obd_histogram *oh)
-{ return; }
-static inline
-unsigned long lprocfs_oh_sum(struct obd_histogram *oh)
-{ return 0; }
-static inline
-void lprocfs_stats_collect(struct lprocfs_stats *stats, int idx,
- struct lprocfs_counter *cnt)
-{ return; }
-static inline
-__u64 lprocfs_stats_collector(struct lprocfs_stats *stats, int idx,
- enum lprocfs_fields_flags field)
-{ return (__u64)0; }
-
-#define LPROC_SEQ_FOPS_RO(name)
-#define LPROC_SEQ_FOPS(name)
-#define LPROC_SEQ_FOPS_RO_TYPE(name, type)
-#define LPROC_SEQ_FOPS_RW_TYPE(name, type)
-#define LPROC_SEQ_FOPS_WR_ONLY(name, type)
-
-/* lproc_ptlrpc.c */
-#define target_print_req NULL
-
-#endif /* CONFIG_PROC_FS */
-
#endif /* LPROCFS_SNMP_H */
diff --git a/drivers/staging/lustre/lustre/include/lu_object.h b/drivers/staging/lustre/lustre/include/lu_object.h
index c8cc48f0002690..e1d72a7a5c2dd5 100644
--- a/drivers/staging/lustre/lustre/include/lu_object.h
+++ b/drivers/staging/lustre/lustre/include/lu_object.h
@@ -43,7 +43,6 @@
#include "lu_ref.h"
struct seq_file;
-struct proc_dir_entry;
struct lustre_cfg;
struct lprocfs_stats;
@@ -277,7 +276,6 @@ struct lu_device {
* Stack this device belongs to.
*/
struct lu_site *ld_site;
- struct proc_dir_entry *ld_proc_entry;
/** \todo XXX: temporary back pointer into obd. */
struct obd_device *ld_obd;
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
index bac9902b56bbf4..f6f4c037fb301b 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
@@ -60,11 +60,13 @@
struct obd_ops;
struct obd_device;
+extern struct kset *ldlm_ns_kset;
+extern struct kset *ldlm_svc_kset;
+
#define OBD_LDLM_DEVICENAME "ldlm"
#define LDLM_DEFAULT_LRU_SIZE (100 * num_online_cpus())
#define LDLM_DEFAULT_MAX_ALIVE (cfs_time_seconds(36000))
-#define LDLM_CTIME_AGE_LIMIT (10)
#define LDLM_DEFAULT_PARALLEL_AST_LIMIT 1024
/**
@@ -232,8 +234,8 @@ struct ldlm_pool_ops {
* This feature is commonly referred to as lru_resize.
*/
struct ldlm_pool {
- /** Pool proc directory. */
- struct proc_dir_entry *pl_proc_dir;
+ /** Pool debugfs directory. */
+ struct dentry *pl_debugfs_entry;
/** Pool name, must be long enough to hold compound proc entry name. */
char pl_name[100];
/** Lock for protecting SLV/CLV updates. */
@@ -263,6 +265,10 @@ struct ldlm_pool {
int pl_grant_plan;
/** Pool statistics. */
struct lprocfs_stats *pl_stats;
+
+ /* sysfs object */
+ struct kobject pl_kobj;
+ struct completion pl_kobj_unregister;
};
typedef int (*ldlm_res_policy)(struct ldlm_namespace *, struct ldlm_lock **,
@@ -302,14 +308,6 @@ typedef enum {
LDLM_NAMESPACE_MODEST = 1 << 1
} ldlm_appetite_t;
-/**
- * Default values for the "max_nolock_size", "contention_time" and
- * "contended_locks" namespace tunables.
- */
-#define NS_DEFAULT_MAX_NOLOCK_BYTES 0
-#define NS_DEFAULT_CONTENTION_SECONDS 2
-#define NS_DEFAULT_CONTENDED_LOCKS 32
-
struct ldlm_ns_bucket {
/** back pointer to namespace */
struct ldlm_namespace *nsb_namespace;
@@ -390,8 +388,8 @@ struct ldlm_namespace {
/** Client side original connect flags supported by server. */
__u64 ns_orig_connect_flags;
- /* namespace proc dir entry */
- struct proc_dir_entry *ns_proc_dir_entry;
+ /* namespace debugfs dir entry */
+ struct dentry *ns_debugfs_entry;
/**
* Position in global namespace list linking all namespaces on
@@ -421,18 +419,6 @@ struct ldlm_namespace {
unsigned int ns_max_unused;
/** Maximum allowed age (last used time) for locks in the LRU */
unsigned int ns_max_age;
- /**
- * Server only: number of times we evicted clients due to lack of reply
- * to ASTs.
- */
- unsigned int ns_timeouts;
- /**
- * Number of seconds since the file change time after which the
- * MDT will return an UPDATE lock along with a LOOKUP lock.
- * This allows the client to start caching negative dentries
- * for a directory and may save an RPC for a later stat.
- */
- unsigned int ns_ctime_age_limit;
/**
* Used to rate-limit ldlm_namespace_dump calls.
@@ -466,27 +452,6 @@ struct ldlm_namespace {
/** Definition of how eagerly unused locks will be released from LRU */
ldlm_appetite_t ns_appetite;
- /**
- * If more than \a ns_contended_locks are found, the resource is
- * considered to be contended. Lock enqueues might specify that no
- * contended locks should be granted
- */
- unsigned ns_contended_locks;
-
- /**
- * The resources in this namespace remember contended state during
- * \a ns_contention_time, in seconds.
- */
- unsigned ns_contention_time;
-
- /**
- * Limit size of contended extent locks, in bytes.
- * If extended lock is requested for more then this many bytes and
- * caller instructs us not to grant contended locks, we would disregard
- * such a request.
- */
- unsigned ns_max_nolock_size;
-
/** Limit of parallel AST RPC count. */
unsigned ns_max_parallel_ast;
@@ -501,6 +466,9 @@ struct ldlm_namespace {
* recalculation of LDLM pool statistics should be skipped.
*/
unsigned ns_stopping:1;
+
+ struct kobject ns_kobj; /* sysfs object */
+ struct completion ns_kobj_unregister;
};
/**
@@ -1283,13 +1251,8 @@ void ldlm_namespace_register(struct ldlm_namespace *ns, ldlm_side_t client);
void ldlm_namespace_unregister(struct ldlm_namespace *ns, ldlm_side_t client);
void ldlm_namespace_get(struct ldlm_namespace *ns);
void ldlm_namespace_put(struct ldlm_namespace *ns);
-#if defined (CONFIG_PROC_FS)
-int ldlm_proc_setup(void);
-void ldlm_proc_cleanup(void);
-#else
-static inline int ldlm_proc_setup(void) { return 0; }
-static inline void ldlm_proc_cleanup(void) {}
-#endif
+int ldlm_debugfs_setup(void);
+void ldlm_debugfs_cleanup(void);
/* resource.c - internal */
struct ldlm_resource *ldlm_resource_get(struct ldlm_namespace *ns,
diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
index 16dcdbfae689cd..d4cc096352712e 100644
--- a/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
+++ b/drivers/staging/lustre/lustre/include/lustre_dlm_flags.h
@@ -1,17 +1,10 @@
/* -*- buffer-read-only: t -*- vi: set ro:
*
- * DO NOT EDIT THIS FILE (lustre_dlm_flags.h)
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
*
- * It has been AutoGen-ed
- * From the definitions lustre_dlm_flags.def
- * and the template file lustre_dlm_flags.tpl
- *
- * lustre 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.
- *
- * lustre is distributed in the hope that it will be useful, but
+ * Lustre 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.
@@ -22,8 +15,6 @@
/**
* \file lustre_dlm_flags.h
* The flags and collections of flags (masks) for \see struct ldlm_lock.
- * This file is derived from flag definitions in lustre_dlm_flags.def.
- * The format is defined in the lustre_dlm_flags.tpl template file.
*
* \addtogroup LDLM Lustre Distributed Lock Manager
* @{
diff --git a/drivers/staging/lustre/lustre/include/lustre_export.h b/drivers/staging/lustre/lustre/include/lustre_export.h
index 9c06a49f12a4f8..3b992b42fd91b8 100644
--- a/drivers/staging/lustre/lustre/include/lustre_export.h
+++ b/drivers/staging/lustre/lustre/include/lustre_export.h
@@ -106,34 +106,6 @@ struct mgs_export_data {
spinlock_t med_lock; /* protect med_clients */
};
-/**
- * per-NID statistics structure.
- * It tracks access patterns to this export on a per-client-NID basis
- */
-struct nid_stat {
- lnet_nid_t nid;
- struct hlist_node nid_hash;
- struct list_head nid_list;
- struct obd_device *nid_obd;
- struct proc_dir_entry *nid_proc;
- struct lprocfs_stats *nid_stats;
- struct lprocfs_stats *nid_ldlm_stats;
- atomic_t nid_exp_ref_count; /* for obd_nid_stats_hash
- exp_nid_stats */
-};
-
-#define nidstat_getref(nidstat) \
-do { \
- atomic_inc(&(nidstat)->nid_exp_ref_count); \
-} while (0)
-
-#define nidstat_putref(nidstat) \
-do { \
- atomic_dec(&(nidstat)->nid_exp_ref_count); \
- LASSERTF(atomic_read(&(nidstat)->nid_exp_ref_count) >= 0, \
- "stat %p nid_exp_ref_count < 0\n", nidstat); \
-} while (0)
-
enum obd_option {
OBD_OPT_FORCE = 0x0001,
OBD_OPT_FAILOVER = 0x0002,
@@ -190,7 +162,6 @@ struct obd_export {
* exp_lock protect its change
*/
struct obd_import *exp_imp_reverse;
- struct nid_stat *exp_nid_stats;
struct lprocfs_stats *exp_md_stats;
/** Active connection */
struct ptlrpc_connection *exp_connection;
diff --git a/drivers/staging/lustre/lustre/include/lustre_fid.h b/drivers/staging/lustre/lustre/include/lustre_fid.h
index 0a0929fd9023ee..c7c8fe4cdbcc6a 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fid.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fid.h
@@ -346,7 +346,7 @@ struct lu_client_seq {
struct lu_seq_range lcs_space;
/* Seq related proc */
- struct proc_dir_entry *lcs_proc_dir;
+ struct dentry *lcs_debugfs_entry;
/* This holds last allocated fid in last obtained seq */
struct lu_fid lcs_fid;
@@ -392,9 +392,6 @@ struct lu_server_seq {
/* /seq file object device */
struct dt_object *lss_obj;
- /* Seq related proc */
- struct proc_dir_entry *lss_proc_dir;
-
/* LUSTRE_SEQ_SERVER or LUSTRE_SEQ_CONTROLLER */
enum lu_mgr_type lss_type;
diff --git a/drivers/staging/lustre/lustre/include/lustre_fld.h b/drivers/staging/lustre/lustre/include/lustre_fld.h
index 5ee4b1ed099502..c1f08dee3bd661 100644
--- a/drivers/staging/lustre/lustre/include/lustre_fld.h
+++ b/drivers/staging/lustre/lustre/include/lustre_fld.h
@@ -71,10 +71,6 @@ struct lu_fld_target {
struct lu_server_fld {
/**
- * Fld dir proc entry. */
- struct proc_dir_entry *lsf_proc_dir;
-
- /**
* /fld file object device */
struct dt_object *lsf_obj;
@@ -99,8 +95,8 @@ struct lu_server_fld {
struct lu_client_fld {
/**
- * Client side proc entry. */
- struct proc_dir_entry *lcf_proc_dir;
+ * Client side debugfs entry. */
+ struct dentry *lcf_debugfs_entry;
/**
* List of exports client FLD knows about. */
@@ -123,10 +119,10 @@ struct lu_client_fld {
struct fld_cache *lcf_cache;
/**
- * Client fld proc entry name. */
- char lcf_name[LUSTRE_MDT_MAXNAMELEN];
+ * Client fld debugfs entry name. */
+ char lcf_name[LUSTRE_MDT_MAXNAMELEN];
- int lcf_flags;
+ int lcf_flags;
};
/* Client methods */
@@ -153,7 +149,7 @@ int fld_client_add_target(struct lu_client_fld *fld,
int fld_client_del_target(struct lu_client_fld *fld,
__u64 idx);
-void fld_client_proc_fini(struct lu_client_fld *fld);
+void fld_client_debugfs_fini(struct lu_client_fld *fld);
/** @} fld */
diff --git a/drivers/staging/lustre/lustre/include/lustre_lib.h b/drivers/staging/lustre/lustre/include/lustre_lib.h
index bf135630c39a78..43ee9f0eb4d47f 100644
--- a/drivers/staging/lustre/lustre/include/lustre_lib.h
+++ b/drivers/staging/lustre/lustre/include/lustre_lib.h
@@ -549,19 +549,13 @@ do { \
__blocked = cfs_block_sigsinv(0); \
\
for (;;) { \
- unsigned __wstate; \
- \
- __wstate = info->lwi_on_signal != NULL && \
- (__timeout == 0 || __allow_intr) ? \
- TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE; \
- \
- set_current_state(TASK_INTERRUPTIBLE); \
- \
if (condition) \
break; \
\
+ set_current_state(TASK_INTERRUPTIBLE); \
+ \
if (__timeout == 0) { \
- schedule(); \
+ schedule(); \
} else { \
long interval = info->lwi_interval? \
min_t(long, \
@@ -582,6 +576,8 @@ do { \
} \
} \
\
+ set_current_state(TASK_RUNNING); \
+ \
if (condition) \
break; \
if (cfs_signal_pending()) { \
@@ -605,7 +601,6 @@ do { \
\
cfs_restore_sigs(__blocked); \
\
- set_current_state(TASK_RUNNING); \
remove_wait_queue(&wq, &__wait); \
} while (0)
diff --git a/drivers/staging/lustre/lustre/include/lustre_net.h b/drivers/staging/lustre/lustre/include/lustre_net.h
index e2805bd1acf107..998dcd94c1b20d 100644
--- a/drivers/staging/lustre/lustre/include/lustre_net.h
+++ b/drivers/staging/lustre/lustre/include/lustre_net.h
@@ -1978,8 +1978,8 @@ struct ptlrpc_service {
int srv_nthrs_cpt_init;
/** limit of threads number for each partition */
int srv_nthrs_cpt_limit;
- /** Root of /proc dir tree for this service */
- struct proc_dir_entry *srv_procroot;
+ /** Root of debugfs dir tree for this service */
+ struct dentry *srv_debugfs_entry;
/** Pointer to statistic data for this service */
struct lprocfs_stats *srv_stats;
/** # hp per lp reqs to handle */
@@ -2016,6 +2016,10 @@ struct ptlrpc_service {
int srv_cpt_bits;
/** CPT table this service is running over */
struct cfs_cpt_table *srv_cptable;
+
+ /* sysfs object */
+ struct kobject srv_kobj;
+ struct completion srv_kobj_unregister;
/**
* partition data for ptlrpc service
*/
@@ -2525,7 +2529,8 @@ void ptlrpc_schedule_difficult_reply(struct ptlrpc_reply_state *rs);
int ptlrpc_hpreq_handler(struct ptlrpc_request *req);
struct ptlrpc_service *ptlrpc_register_service(
struct ptlrpc_service_conf *conf,
- struct proc_dir_entry *proc_entry);
+ struct kset *parent,
+ struct dentry *debugfs_entry);
void ptlrpc_stop_all_threads(struct ptlrpc_service *svc);
int ptlrpc_start_threads(struct ptlrpc_service *svc);
@@ -2947,15 +2952,9 @@ void ptlrpcd_decref(void);
* @{
*/
const char *ll_opcode2str(__u32 opcode);
-#if defined (CONFIG_PROC_FS)
void ptlrpc_lprocfs_register_obd(struct obd_device *obd);
void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd);
void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes);
-#else
-static inline void ptlrpc_lprocfs_register_obd(struct obd_device *obd) {}
-static inline void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd) {}
-static inline void ptlrpc_lprocfs_brw(struct ptlrpc_request *req, int bytes) {}
-#endif
/** @} */
/* ptlrpc/llog_client.c */
diff --git a/drivers/staging/lustre/lustre/include/lustre_quota.h b/drivers/staging/lustre/lustre/include/lustre_quota.h
deleted file mode 100644
index 2643f28070a22b..00000000000000
--- a/drivers/staging/lustre/lustre/include/lustre_quota.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2011, 2012, Intel Corporation.
- * Use is subject to license terms.
- */
-
-#ifndef _LUSTRE_QUOTA_H
-#define _LUSTRE_QUOTA_H
-
-/** \defgroup quota quota
- *
- */
-
-#include <linux/fs.h>
-#include <linux/quota.h>
-#include <linux/quotaops.h>
-
-#include "dt_object.h"
-#include "lustre_fid.h"
-#include "lustre_dlm.h"
-
-#ifndef MAX_IQ_TIME
-#define MAX_IQ_TIME 604800 /* (7*24*60*60) 1 week */
-#endif
-
-#ifndef MAX_DQ_TIME
-#define MAX_DQ_TIME 604800 /* (7*24*60*60) 1 week */
-#endif
-
-struct lquota_id_info;
-struct lquota_trans;
-
-/* Gather all quota record type in an union that can be used to read any records
- * from disk. All fields of these records must be 64-bit aligned, otherwise the
- * OSD layer may swab them incorrectly. */
-union lquota_rec {
- struct lquota_glb_rec lqr_glb_rec;
- struct lquota_slv_rec lqr_slv_rec;
- struct lquota_acct_rec lqr_acct_rec;
-};
-
-/* Index features supported by the global index objects
- * Only used for migration purpose and should be removed once on-disk migration
- * is no longer needed */
-extern struct dt_index_features dt_quota_iusr_features;
-extern struct dt_index_features dt_quota_busr_features;
-extern struct dt_index_features dt_quota_igrp_features;
-extern struct dt_index_features dt_quota_bgrp_features;
-
-/* Name used in the configuration logs to identify the default metadata pool
- * (composed of all the MDTs, with pool ID 0) and the default data pool (all
- * the OSTs, with pool ID 0 too). */
-#define QUOTA_METAPOOL_NAME "mdt="
-#define QUOTA_DATAPOOL_NAME "ost="
-
-/*
- * Quota Master Target support
- */
-
-/* Request handlers for quota master operations.
- * This is used by the MDT to pass quota/lock requests to the quota master
- * target. This won't be needed any more once the QMT is a real target and
- * does not rely any more on the MDT service threads and namespace. */
-struct qmt_handlers {
- /* Handle quotactl request from client. */
- int (*qmth_quotactl)(const struct lu_env *, struct lu_device *,
- struct obd_quotactl *);
-
- /* Handle dqacq/dqrel request from slave. */
- int (*qmth_dqacq)(const struct lu_env *, struct lu_device *,
- struct ptlrpc_request *);
-
- /* LDLM intent policy associated with quota locks */
- int (*qmth_intent_policy)(const struct lu_env *, struct lu_device *,
- struct ptlrpc_request *, struct ldlm_lock **,
- int);
-
- /* Initialize LVB of ldlm resource associated with quota objects */
- int (*qmth_lvbo_init)(struct lu_device *, struct ldlm_resource *);
-
- /* Update LVB of ldlm resource associated with quota objects */
- int (*qmth_lvbo_update)(struct lu_device *, struct ldlm_resource *,
- struct ptlrpc_request *, int);
-
- /* Return size of LVB to be packed in ldlm message */
- int (*qmth_lvbo_size)(struct lu_device *, struct ldlm_lock *);
-
- /* Fill request buffer with lvb */
- int (*qmth_lvbo_fill)(struct lu_device *, struct ldlm_lock *, void *,
- int);
-
- /* Free lvb associated with ldlm resource */
- int (*qmth_lvbo_free)(struct lu_device *, struct ldlm_resource *);
-};
-
-/* actual handlers are defined in lustre/quota/qmt_handler.c */
-extern struct qmt_handlers qmt_hdls;
-
-/*
- * Quota enforcement support on slaves
- */
-
-struct qsd_instance;
-
-/* The quota slave feature is implemented under the form of a library.
- * The API is the following:
- *
- * - qsd_init(): the user (mostly the OSD layer) should first allocate a qsd
- * instance via qsd_init(). This creates all required structures
- * to manage quota enforcement for this target and performs all
- * low-level initialization which does not involve any lustre
- * object. qsd_init() should typically be called when the OSD
- * is being set up.
- *
- * - qsd_prepare(): This sets up on-disk objects associated with the quota slave
- * feature and initiates the quota reintegration procedure if
- * needed. qsd_prepare() should typically be called when
- * ->ldo_prepare is invoked.
- *
- * - qsd_start(): a qsd instance should be started once recovery is completed
- * (i.e. when ->ldo_recovery_complete is called). This is used
- * to notify the qsd layer that quota should now be enforced
- * again via the qsd_op_begin/end functions. The last step of the
- * reintegration procedure (namely usage reconciliation) will be
- * completed during start.
- *
- * - qsd_fini(): is used to release a qsd_instance structure allocated with
- * qsd_init(). This releases all quota slave objects and frees the
- * structures associated with the qsd_instance.
- *
- * - qsd_op_begin(): is used to enforce quota, it must be called in the
- * declaration of each operation. qsd_op_end() should then be
- * invoked later once all operations have been completed in
- * order to release/adjust the quota space.
- * Running qsd_op_begin() before qsd_start() isn't fatal and
- * will return success.
- * Once qsd_start() has been run, qsd_op_begin() will block
- * until the reintegration procedure is completed.
- *
- * - qsd_op_end(): performs the post operation quota processing. This must be
- * called after the operation transaction stopped.
- * While qsd_op_begin() must be invoked each time a new
- * operation is declared, qsd_op_end() should be called only
- * once for the whole transaction.
- *
- * - qsd_op_adjust(): triggers pre-acquire/release if necessary.
- *
- * Below are the function prototypes to be used by OSD layer to manage quota
- * enforcement. Arguments are documented where each function is defined. */
-
-struct qsd_instance *qsd_init(const struct lu_env *, char *, struct dt_device *,
- struct proc_dir_entry *);
-int qsd_prepare(const struct lu_env *, struct qsd_instance *);
-int qsd_start(const struct lu_env *, struct qsd_instance *);
-void qsd_fini(const struct lu_env *, struct qsd_instance *);
-int qsd_op_begin(const struct lu_env *, struct qsd_instance *,
- struct lquota_trans *, struct lquota_id_info *, int *);
-void qsd_op_end(const struct lu_env *, struct qsd_instance *,
- struct lquota_trans *);
-void qsd_op_adjust(const struct lu_env *, struct qsd_instance *,
- union lquota_id *, int);
-/* This is exported for the ldiskfs quota migration only,
- * see convert_quota_file() */
-int lquota_disk_write_glb(const struct lu_env *, struct dt_object *,
- __u64, struct lquota_glb_rec *);
-
-/*
- * Quota information attached to a transaction
- */
-
-struct lquota_entry;
-
-struct lquota_id_info {
- /* quota identifier */
- union lquota_id lqi_id;
-
- /* USRQUOTA or GRPQUOTA for now, could be expanded for
- * directory quota or other types later. */
- int lqi_type;
-
- /* inodes or kbytes to be consumed or released, it could
- * be negative when releasing space. */
- long long lqi_space;
-
- /* quota slave entry structure associated with this ID */
- struct lquota_entry *lqi_qentry;
-
- /* whether we are reporting blocks or inodes */
- bool lqi_is_blk;
-};
-
-/* Since we enforce only inode quota in meta pool (MDTs), and block quota in
- * data pool (OSTs), there are at most 4 quota ids being enforced in a single
- * transaction, which is chown transaction:
- * original uid and gid, new uid and gid.
- *
- * This value might need to be revised when directory quota is added. */
-#define QUOTA_MAX_TRANSIDS 4
-
-/* all qids involved in a single transaction */
-struct lquota_trans {
- unsigned short lqt_id_cnt;
- struct lquota_id_info lqt_ids[QUOTA_MAX_TRANSIDS];
-};
-
-/* flags for quota local enforcement */
-#define QUOTA_FL_OVER_USRQUOTA 0x01
-#define QUOTA_FL_OVER_GRPQUOTA 0x02
-#define QUOTA_FL_SYNC 0x04
-
-#define IS_LQUOTA_RES(res) \
- (res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA || \
- res->lr_name.name[LUSTRE_RES_ID_SEQ_OFF] == FID_SEQ_QUOTA_GLB)
-
-/* helper function used by MDT & OFD to retrieve quota accounting information
- * on slave */
-int lquotactl_slv(const struct lu_env *, struct dt_device *,
- struct obd_quotactl *);
-/** @} quota */
-#endif /* _LUSTRE_QUOTA_H */
diff --git a/drivers/staging/lustre/lustre/include/lustre_sec.h b/drivers/staging/lustre/lustre/include/lustre_sec.h
index dff70a5b9bc497..707ff69717c672 100644
--- a/drivers/staging/lustre/lustre/include/lustre_sec.h
+++ b/drivers/staging/lustre/lustre/include/lustre_sec.h
@@ -1061,15 +1061,7 @@ const char *sec2target_str(struct ptlrpc_sec *sec);
/*
* lprocfs
*/
-#if defined (CONFIG_PROC_FS)
-struct proc_dir_entry;
-extern struct proc_dir_entry *sptlrpc_proc_root;
int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev);
-#else
-#define sptlrpc_proc_root NULL
-static inline int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
-{ return 0; }
-#endif
/*
* server side
diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
index 2a88b806fca561..55452e562bd482 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -244,11 +244,12 @@ struct obd_type {
struct list_head typ_chain;
struct obd_ops *typ_dt_ops;
struct md_ops *typ_md_ops;
- struct proc_dir_entry *typ_procroot;
+ struct dentry *typ_debugfs_entry;
char *typ_name;
int typ_refcnt;
struct lu_device_type *typ_lu;
spinlock_t obd_type_lock;
+ struct kobject *typ_kobj;
};
struct brw_page {
@@ -544,7 +545,7 @@ struct pool_desc {
struct lov_qos_rr pool_rr; /* round robin qos */
struct hlist_node pool_hash; /* access by poolname */
struct list_head pool_list; /* serial access */
- struct proc_dir_entry *pool_proc_entry; /* file in /proc */
+ struct dentry *pool_debugfs_entry; /* file in /proc */
struct obd_device *pool_lobd; /* obd of the lov/lod to which
* this pool belongs */
};
@@ -565,13 +566,15 @@ struct lov_obd {
int lov_pool_count;
struct cfs_hash *lov_pools_hash_body; /* used for key access */
struct list_head lov_pool_list; /* used for sequential access */
- struct proc_dir_entry *lov_pool_proc_entry;
+ struct dentry *lov_pool_debugfs_entry;
enum lustre_sec_part lov_sp_me;
/* Cached LRU pages from upper layer */
void *lov_cache;
struct rw_semaphore lov_notify_lock;
+
+ struct kobject *lov_tgts_kobj;
};
struct lmv_tgt_desc {
@@ -610,6 +613,7 @@ struct lmv_obd {
struct lmv_tgt_desc **tgts;
struct obd_connect_data conn_data;
+ struct kobject *lmv_tgts_kobj;
};
struct niobuf_local {
@@ -841,9 +845,6 @@ struct obd_device {
struct cfs_hash *obd_uuid_hash;
/* nid-export hash body */
struct cfs_hash *obd_nid_hash;
- /* nid stats body */
- struct cfs_hash *obd_nid_stats_hash;
- struct list_head obd_nid_stats;
atomic_t obd_refcount;
wait_queue_head_t obd_refcount_waitq;
struct list_head obd_exports;
@@ -913,10 +914,8 @@ struct obd_device {
unsigned int md_cntr_base;
struct lprocfs_stats *md_stats;
- struct proc_dir_entry *obd_proc_entry;
- void *obd_proc_private; /* type private PDEs */
- struct proc_dir_entry *obd_proc_exports_entry;
- struct proc_dir_entry *obd_svc_procroot;
+ struct dentry *obd_debugfs_entry;
+ struct dentry *obd_svc_debugfs_entry;
struct lprocfs_stats *obd_svc_stats;
atomic_t obd_evict_inprogress;
wait_queue_head_t obd_evict_inprogress_waitq;
@@ -936,6 +935,9 @@ struct obd_device {
struct lu_ref obd_reference;
int obd_conn_inprogress;
+
+ struct kobject obd_kobj; /* sysfs object */
+ struct completion obd_kobj_unregister;
};
#define OBD_LLOG_FL_SENDNOW 0x0001
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 34b5fa3f081ce3..36ed78127830b0 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -75,8 +75,7 @@ struct lu_device_type;
extern struct list_head obd_types;
struct obd_export *class_conn2export(struct lustre_handle *);
int class_register_type(struct obd_ops *, struct md_ops *,
- struct lprocfs_vars *, const char *nm,
- struct lu_device_type *ldt);
+ const char *nm, struct lu_device_type *ldt);
int class_unregister_type(const char *nm);
struct obd_device *class_newdev(const char *type_name, const char *name);
@@ -140,14 +139,7 @@ int class_add_conn(struct obd_device *obd, struct lustre_cfg *lcfg);
int class_add_uuid(const char *uuid, __u64 nid);
/*obdecho*/
-#if defined (CONFIG_PROC_FS)
extern void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
#define CFG_F_START 0x01 /* Set when we start updating from a log */
#define CFG_F_MARKER 0x02 /* We are within a maker */
@@ -357,7 +349,6 @@ static inline int obd_check_dev_active(struct obd_device *obd)
return rc;
}
-#if defined (CONFIG_PROC_FS)
#define OBD_COUNTER_OFFSET(op) \
((offsetof(struct obd_ops, o_ ## op) - \
offsetof(struct obd_ops, o_iocontrol)) \
@@ -379,10 +370,6 @@ static inline int obd_check_dev_active(struct obd_device *obd)
OBD_COUNTER_OFFSET(op); \
LASSERT(coffset < (export)->exp_obd->obd_stats->ls_num); \
lprocfs_counter_incr((export)->exp_obd->obd_stats, coffset); \
- if ((export)->exp_nid_stats != NULL && \
- (export)->exp_nid_stats->nid_stats != NULL) \
- lprocfs_counter_incr( \
- (export)->exp_nid_stats->nid_stats, coffset);\
}
#define MD_COUNTER_OFFSET(op) \
@@ -411,27 +398,6 @@ static inline int obd_check_dev_active(struct obd_device *obd)
(export)->exp_md_stats, coffset); \
}
-#else
-#define OBD_COUNTER_OFFSET(op)
-#define OBD_COUNTER_INCREMENT(obd, op)
-#define EXP_COUNTER_INCREMENT(exp, op)
-#define MD_COUNTER_INCREMENT(obd, op)
-#define EXP_MD_COUNTER_INCREMENT(exp, op)
-#endif
-
-static inline int lprocfs_nid_ldlm_stats_init(struct nid_stat *tmp)
-{
- /* Always add in ldlm_stats */
- tmp->nid_ldlm_stats = lprocfs_alloc_stats(LDLM_LAST_OPC - LDLM_FIRST_OPC
- ,LPROCFS_STATS_FLAG_NOPERCPU);
- if (tmp->nid_ldlm_stats == NULL)
- return -ENOMEM;
-
- lprocfs_init_ldlm_stats(tmp->nid_ldlm_stats);
-
- return lprocfs_register_stats(tmp->nid_proc, "ldlm_stats",
- tmp->nid_ldlm_stats);
-}
#define OBD_CHECK_MD_OP(obd, op, err) \
do { \
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index 2991d2ee780bfe..73e2d4880b9b39 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -509,7 +509,6 @@ extern atomic_t libcfs_kmemory;
extern void obd_update_maxusage(void);
-#if defined (CONFIG_PROC_FS)
#define obd_memory_add(size) \
lprocfs_counter_add(obd_memory, OBD_MEMORY_STAT, (long)(size))
#define obd_memory_sub(size) \
@@ -530,46 +529,6 @@ extern void obd_update_maxusage(void);
extern __u64 obd_memory_max(void);
extern __u64 obd_pages_max(void);
-#else
-
-extern __u64 obd_alloc;
-extern __u64 obd_pages;
-
-extern __u64 obd_max_alloc;
-extern __u64 obd_max_pages;
-
-static inline void obd_memory_add(long size)
-{
- obd_alloc += size;
- if (obd_alloc > obd_max_alloc)
- obd_max_alloc = obd_alloc;
-}
-
-static inline void obd_memory_sub(long size)
-{
- obd_alloc -= size;
-}
-
-static inline void obd_pages_add(int order)
-{
- obd_pages += 1<< order;
- if (obd_pages > obd_max_pages)
- obd_max_pages = obd_pages;
-}
-
-static inline void obd_pages_sub(int order)
-{
- obd_pages -= 1<< order;
-}
-
-#define obd_memory_sum() (obd_alloc)
-#define obd_pages_sum() (obd_pages)
-
-#define obd_memory_max() (obd_max_alloc)
-#define obd_pages_max() (obd_max_pages)
-
-#endif
-
#define OBD_DEBUG_MEMUSAGE (1)
#if OBD_DEBUG_MEMUSAGE
@@ -676,37 +635,20 @@ do { \
__OBD_VMALLOC_VEROBSE(ptr, cptab, cpt, size)
-/* Allocations above this size are considered too big and could not be done
- * atomically.
- *
- * Be very careful when changing this value, especially when decreasing it,
- * since vmalloc in Linux doesn't perform well on multi-cores system, calling
- * vmalloc in critical path would hurt performance badly. See LU-66.
- */
-#define OBD_ALLOC_BIG (4 * PAGE_CACHE_SIZE)
-
#define OBD_ALLOC_LARGE(ptr, size) \
do { \
- if (size > OBD_ALLOC_BIG) \
- OBD_VMALLOC(ptr, size); \
- else \
- OBD_ALLOC(ptr, size); \
+ ptr = libcfs_kvzalloc(size, GFP_NOFS); \
} while (0)
#define OBD_CPT_ALLOC_LARGE(ptr, cptab, cpt, size) \
do { \
- if (size > OBD_ALLOC_BIG) \
- OBD_CPT_VMALLOC(ptr, cptab, cpt, size); \
- else \
- OBD_CPT_ALLOC(ptr, cptab, cpt, size); \
+ ptr = libcfs_kvzalloc_cpt(cptab, cpt, size, GFP_NOFS); \
} while (0)
#define OBD_FREE_LARGE(ptr, size) \
do { \
- if (size > OBD_ALLOC_BIG) \
- OBD_VFREE(ptr, size); \
- else \
- OBD_FREE(ptr, size); \
+ (void)(size); \
+ kvfree(ptr); \
} while (0)
diff --git a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
index ab6cb419302fb2..e0c1ccafbd6356 100644
--- a/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
+++ b/drivers/staging/lustre/lustre/lclient/lcommon_cl.c
@@ -202,7 +202,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env,
struct cl_site *site;
int rc;
- OBD_ALLOC_PTR(vdv);
+ vdv = kzalloc(sizeof(*vdv), GFP_NOFS);
if (vdv == NULL)
return ERR_PTR(-ENOMEM);
@@ -211,7 +211,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env,
ccc2lu_dev(vdv)->ld_ops = luops;
vdv->cdv_cl.cd_ops = clops;
- OBD_ALLOC_PTR(site);
+ site = kzalloc(sizeof(*site), GFP_NOFS);
if (site != NULL) {
rc = cl_site_init(site, &vdv->cdv_cl);
if (rc == 0)
@@ -219,7 +219,7 @@ struct lu_device *ccc_device_alloc(const struct lu_env *env,
else {
LASSERT(lud->ld_site == NULL);
CERROR("Cannot init lu_site, rc %d.\n", rc);
- OBD_FREE_PTR(site);
+ kfree(site);
}
} else
rc = -ENOMEM;
@@ -239,10 +239,10 @@ struct lu_device *ccc_device_free(const struct lu_env *env,
if (d->ld_site != NULL) {
cl_site_fini(site);
- OBD_FREE_PTR(site);
+ kfree(site);
}
cl_device_fini(lu2cl_dev(d));
- OBD_FREE_PTR(vdv);
+ kfree(vdv);
return next;
}
@@ -836,25 +836,24 @@ int ccc_prep_size(const struct lu_env *env, struct cl_object *obj,
*exceed = 1;
}
return result;
- } else {
- /*
- * region is within kms and, hence, within real file
- * size (A). We need to increase i_size to cover the
- * read region so that generic_file_read() will do its
- * job, but that doesn't mean the kms size is
- * _correct_, it is only the _minimum_ size. If
- * someone does a stat they will get the correct size
- * which will always be >= the kms value here.
- * b=11081
- */
- if (cl_isize_read(inode) < kms) {
- cl_isize_write_nolock(inode, kms);
- CDEBUG(D_VFSTRACE,
- DFID" updating i_size %llu\n",
- PFID(lu_object_fid(&obj->co_lu)),
- (__u64)cl_isize_read(inode));
+ }
+ /*
+ * region is within kms and, hence, within real file
+ * size (A). We need to increase i_size to cover the
+ * read region so that generic_file_read() will do its
+ * job, but that doesn't mean the kms size is
+ * _correct_, it is only the _minimum_ size. If
+ * someone does a stat they will get the correct size
+ * which will always be >= the kms value here.
+ * b=11081
+ */
+ if (cl_isize_read(inode) < kms) {
+ cl_isize_write_nolock(inode, kms);
+ CDEBUG(D_VFSTRACE,
+ DFID" updating i_size %llu\n",
+ PFID(lu_object_fid(&obj->co_lu)),
+ (__u64)cl_isize_read(inode));
- }
}
}
ccc_object_size_unlock(obj);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
index 70b909f55861a8..6601e6b12c32df 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_internal.h
@@ -197,8 +197,7 @@ void ldlm_destroy_flock_export(struct obd_export *exp);
void l_check_ns_lock(struct ldlm_namespace *ns);
void l_check_no_ns_lock(struct ldlm_namespace *ns);
-extern struct proc_dir_entry *ldlm_svc_proc_dir;
-extern struct proc_dir_entry *ldlm_type_proc_dir;
+extern struct dentry *ldlm_svc_debugfs_dir;
struct ldlm_state {
struct ptlrpc_service *ldlm_cb_service;
@@ -238,40 +237,85 @@ enum ldlm_policy_res {
typedef enum ldlm_policy_res ldlm_policy_res_t;
-#define LDLM_POOL_PROC_READER_SEQ_SHOW(var, type) \
- static int lprocfs_##var##_seq_show(struct seq_file *m, void *v) \
+#define LDLM_POOL_SYSFS_PRINT_int(v) sprintf(buf, "%d\n", v)
+#define LDLM_POOL_SYSFS_SET_int(a, b) { a = b; }
+#define LDLM_POOL_SYSFS_PRINT_u64(v) sprintf(buf, "%lld\n", v)
+#define LDLM_POOL_SYSFS_SET_u64(a, b) { a = b; }
+#define LDLM_POOL_SYSFS_PRINT_atomic(v) sprintf(buf, "%d\n", atomic_read(&v))
+#define LDLM_POOL_SYSFS_SET_atomic(a, b) atomic_set(&a, b)
+
+#define LDLM_POOL_SYSFS_READER_SHOW(var, type) \
+ static ssize_t var##_show(struct kobject *kobj, \
+ struct attribute *attr, \
+ char *buf) \
{ \
- struct ldlm_pool *pl = m->private; \
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \
+ pl_kobj); \
type tmp; \
\
spin_lock(&pl->pl_lock); \
tmp = pl->pl_##var; \
spin_unlock(&pl->pl_lock); \
\
- return lprocfs_rd_uint(m, &tmp); \
+ return LDLM_POOL_SYSFS_PRINT_##type(tmp); \
} \
struct __##var##__dummy_read {; } /* semicolon catcher */
-#define LDLM_POOL_PROC_WRITER(var, type) \
- static int lprocfs_wr_##var(struct file *file, \
- const char __user *buffer, \
- unsigned long count, void *data) \
+#define LDLM_POOL_SYSFS_WRITER_STORE(var, type) \
+ static ssize_t var##_store(struct kobject *kobj, \
+ struct attribute *attr, \
+ const char *buffer, \
+ size_t count) \
{ \
- struct ldlm_pool *pl = data; \
- type tmp; \
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \
+ pl_kobj); \
+ unsigned long tmp; \
int rc; \
\
- rc = lprocfs_wr_uint(file, buffer, count, &tmp); \
+ rc = kstrtoul(buffer, 10, &tmp); \
if (rc < 0) { \
- CERROR("Can't parse user input, rc = %d\n", rc); \
return rc; \
} \
\
spin_lock(&pl->pl_lock); \
- pl->pl_##var = tmp; \
+ LDLM_POOL_SYSFS_SET_##type(pl->pl_##var, tmp); \
spin_unlock(&pl->pl_lock); \
\
- return rc; \
+ return count; \
+ } \
+ struct __##var##__dummy_write {; } /* semicolon catcher */
+
+#define LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(var, type) \
+ static ssize_t var##_show(struct kobject *kobj, \
+ struct attribute *attr, \
+ char *buf) \
+ { \
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \
+ pl_kobj); \
+ \
+ return LDLM_POOL_SYSFS_PRINT_##type(pl->pl_##var); \
+ } \
+ struct __##var##__dummy_read {; } /* semicolon catcher */
+
+#define LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(var, type) \
+ static ssize_t var##_store(struct kobject *kobj, \
+ struct attribute *attr, \
+ const char *buffer, \
+ size_t count) \
+ { \
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool, \
+ pl_kobj); \
+ unsigned long tmp; \
+ int rc; \
+ \
+ rc = kstrtoul(buffer, 10, &tmp); \
+ if (rc < 0) { \
+ return rc; \
+ } \
+ \
+ LDLM_POOL_SYSFS_SET_##type(pl->pl_##var, tmp); \
+ \
+ return count; \
} \
struct __##var##__dummy_write {; } /* semicolon catcher */
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
index c5c86e73ca52ed..0a0b435f11fcfa 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lib.c
@@ -73,7 +73,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid,
}
if (create) {
- OBD_ALLOC(imp_conn, sizeof(*imp_conn));
+ imp_conn = kzalloc(sizeof(*imp_conn), GFP_NOFS);
if (!imp_conn) {
rc = -ENOMEM;
goto out_put;
@@ -119,8 +119,7 @@ static int import_set_conn(struct obd_import *imp, struct obd_uuid *uuid,
spin_unlock(&imp->imp_lock);
return 0;
out_free:
- if (imp_conn)
- OBD_FREE(imp_conn, sizeof(*imp_conn));
+ kfree(imp_conn);
out_put:
ptlrpc_connection_put(ptlrpc_conn);
return rc;
@@ -179,7 +178,7 @@ int client_import_del_conn(struct obd_import *imp, struct obd_uuid *uuid)
list_del(&imp_conn->oic_item);
ptlrpc_connection_put(imp_conn->oic_conn);
- OBD_FREE(imp_conn, sizeof(*imp_conn));
+ kfree(imp_conn);
CDEBUG(D_HA, "imp %p@%s: remove connection %s\n",
imp, imp->imp_obd->obd_name, uuid->uuid);
rc = 0;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 84b111eb48fad5..6a22f4183b3087 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -208,8 +208,7 @@ void ldlm_lock_put(struct ldlm_lock *lock)
lock->l_export = NULL;
}
- if (lock->l_lvb_data != NULL)
- OBD_FREE(lock->l_lvb_data, lock->l_lvb_len);
+ kfree(lock->l_lvb_data);
ldlm_interval_free(ldlm_interval_detach(lock));
lu_ref_fini(&lock->l_reference);
@@ -1527,7 +1526,7 @@ struct ldlm_lock *ldlm_lock_create(struct ldlm_namespace *ns,
if (lvb_len) {
lock->l_lvb_len = lvb_len;
- OBD_ALLOC(lock->l_lvb_data, lvb_len);
+ lock->l_lvb_data = kzalloc(lvb_len, GFP_NOFS);
if (lock->l_lvb_data == NULL)
goto out;
}
@@ -1791,7 +1790,7 @@ int ldlm_work_gl_ast_lock(struct ptlrpc_request_set *rqset, void *opaq)
LDLM_LOCK_RELEASE(lock);
if ((gl_work->gl_flags & LDLM_GL_WORK_NOFREE) == 0)
- OBD_FREE_PTR(gl_work);
+ kfree(gl_work);
return rc;
}
@@ -1812,7 +1811,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
if (list_empty(rpc_list))
return 0;
- OBD_ALLOC_PTR(arg);
+ arg = kzalloc(sizeof(*arg), GFP_NOFS);
if (arg == NULL)
return -ENOMEM;
@@ -1857,7 +1856,7 @@ int ldlm_run_ast_work(struct ldlm_namespace *ns, struct list_head *rpc_list,
rc = atomic_read(&arg->restart) ? -ERESTART : 0;
goto out;
out:
- OBD_FREE_PTR(arg);
+ kfree(arg);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index 08a91f5d91b166..b7b6ca1196b7fb 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -58,6 +58,10 @@ MODULE_PARM_DESC(ldlm_cpts, "CPU partitions ldlm threads should run on");
static struct mutex ldlm_ref_mutex;
static int ldlm_refcount;
+struct kobject *ldlm_kobj;
+struct kset *ldlm_ns_kset;
+struct kset *ldlm_svc_kset;
+
struct ldlm_cb_async_args {
struct ldlm_cb_set_arg *ca_set_arg;
struct ldlm_lock *ca_lock;
@@ -220,7 +224,7 @@ static void ldlm_handle_cp_callback(struct ptlrpc_request *req,
* variable length */
void *lvb_data;
- OBD_ALLOC(lvb_data, lvb_len);
+ lvb_data = kzalloc(lvb_len, GFP_NOFS);
if (lvb_data == NULL) {
LDLM_ERROR(lock, "No memory: %d.\n", lvb_len);
rc = -ENOMEM;
@@ -448,7 +452,7 @@ static int ldlm_bl_to_thread(struct ldlm_namespace *ns,
if (cancel_flags & LCF_ASYNC) {
struct ldlm_bl_work_item *blwi;
- OBD_ALLOC(blwi, sizeof(*blwi));
+ blwi = kzalloc(sizeof(*blwi), GFP_NOFS);
if (blwi == NULL)
return -ENOMEM;
init_blwi(blwi, ns, ld, cancels, count, lock, cancel_flags);
@@ -849,7 +853,7 @@ static int ldlm_bl_thread_main(void *arg)
memory_pressure_clr();
if (blwi->blwi_flags & LCF_ASYNC)
- OBD_FREE(blwi, sizeof(*blwi));
+ kfree(blwi);
else
complete(&blwi->blwi_comp);
}
@@ -1002,6 +1006,42 @@ void ldlm_destroy_export(struct obd_export *exp)
}
EXPORT_SYMBOL(ldlm_destroy_export);
+extern unsigned int ldlm_cancel_unused_locks_before_replay;
+
+static ssize_t cancel_unused_locks_before_replay_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ return sprintf(buf, "%d\n", ldlm_cancel_unused_locks_before_replay);
+}
+static ssize_t cancel_unused_locks_before_replay_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
+{
+ int rc;
+ unsigned long val;
+
+ rc = kstrtoul(buffer, 10, &val);
+ if (rc)
+ return rc;
+
+ ldlm_cancel_unused_locks_before_replay = val;
+
+ return count;
+}
+LUSTRE_RW_ATTR(cancel_unused_locks_before_replay);
+
+/* These are for root of /sys/fs/lustre/ldlm */
+static struct attribute *ldlm_attrs[] = {
+ &lustre_attr_cancel_unused_locks_before_replay.attr,
+ NULL,
+};
+
+static struct attribute_group ldlm_attr_group = {
+ .attrs = ldlm_attrs,
+};
+
static int ldlm_setup(void)
{
static struct ptlrpc_service_conf conf;
@@ -1012,11 +1052,33 @@ static int ldlm_setup(void)
if (ldlm_state != NULL)
return -EALREADY;
- OBD_ALLOC(ldlm_state, sizeof(*ldlm_state));
+ ldlm_state = kzalloc(sizeof(*ldlm_state), GFP_NOFS);
if (ldlm_state == NULL)
return -ENOMEM;
- rc = ldlm_proc_setup();
+ ldlm_kobj = kobject_create_and_add("ldlm", lustre_kobj);
+ if (!ldlm_kobj) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ rc = sysfs_create_group(ldlm_kobj, &ldlm_attr_group);
+ if (rc)
+ goto out;
+
+ ldlm_ns_kset = kset_create_and_add("namespaces", NULL, ldlm_kobj);
+ if (!ldlm_ns_kset) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ ldlm_svc_kset = kset_create_and_add("services", NULL, ldlm_kobj);
+ if (!ldlm_svc_kset) {
+ rc = -ENOMEM;
+ goto out;
+ }
+
+ rc = ldlm_debugfs_setup();
if (rc != 0)
goto out;
@@ -1050,7 +1112,8 @@ static int ldlm_setup(void)
},
};
ldlm_state->ldlm_cb_service =
- ptlrpc_register_service(&conf, ldlm_svc_proc_dir);
+ ptlrpc_register_service(&conf, ldlm_svc_kset,
+ ldlm_svc_debugfs_dir);
if (IS_ERR(ldlm_state->ldlm_cb_service)) {
CERROR("failed to start service\n");
rc = PTR_ERR(ldlm_state->ldlm_cb_service);
@@ -1059,7 +1122,7 @@ static int ldlm_setup(void)
}
- OBD_ALLOC(blp, sizeof(*blp));
+ blp = kzalloc(sizeof(*blp), GFP_NOFS);
if (blp == NULL) {
rc = -ENOMEM;
goto out;
@@ -1088,7 +1151,6 @@ static int ldlm_setup(void)
goto out;
}
-
rc = ldlm_pools_init();
if (rc) {
CERROR("Failed to initialize LDLM pools: %d\n", rc);
@@ -1129,16 +1191,22 @@ static int ldlm_cleanup(void)
wait_for_completion(&blp->blp_comp);
}
- OBD_FREE(blp, sizeof(*blp));
+ kfree(blp);
}
if (ldlm_state->ldlm_cb_service != NULL)
ptlrpc_unregister_service(ldlm_state->ldlm_cb_service);
- ldlm_proc_cleanup();
+ if (ldlm_ns_kset)
+ kset_unregister(ldlm_ns_kset);
+ if (ldlm_svc_kset)
+ kset_unregister(ldlm_svc_kset);
+ if (ldlm_kobj)
+ kobject_put(ldlm_kobj);
+ ldlm_debugfs_cleanup();
- OBD_FREE(ldlm_state, sizeof(*ldlm_state));
+ kfree(ldlm_state);
ldlm_state = NULL;
return 0;
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index a9f4833e03e5f6..310cc60252fa67 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -90,10 +90,10 @@
* pl_server_lock_volume - Current server lock volume (calculated);
*
* As it may be seen from list above, we have few possible tunables which may
- * affect behavior much. They all may be modified via proc. However, they also
+ * affect behavior much. They all may be modified via sysfs. However, they also
* give a possibility for constructing few pre-defined behavior policies. If
* none of predefines is suitable for a working pattern being used, new one may
- * be "constructed" via proc tunables.
+ * be "constructed" via sysfs tunables.
*/
#define DEBUG_SUBSYSTEM S_LDLM
@@ -654,7 +654,6 @@ int ldlm_pool_setup(struct ldlm_pool *pl, int limit)
}
EXPORT_SYMBOL(ldlm_pool_setup);
-#if defined(CONFIG_PROC_FS)
static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
{
int granted, grant_rate, cancel_rate, grant_step;
@@ -696,9 +695,12 @@ static int lprocfs_pool_state_seq_show(struct seq_file *m, void *unused)
}
LPROC_SEQ_FOPS_RO(lprocfs_pool_state);
-static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused)
+static ssize_t grant_speed_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_pool *pl = m->private;
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool,
+ pl_kobj);
+
int grant_speed;
spin_lock(&pl->pl_lock);
@@ -706,63 +708,109 @@ static int lprocfs_grant_speed_seq_show(struct seq_file *m, void *unused)
grant_speed = atomic_read(&pl->pl_grant_rate) -
atomic_read(&pl->pl_cancel_rate);
spin_unlock(&pl->pl_lock);
- return lprocfs_rd_uint(m, &grant_speed);
+ return sprintf(buf, "%d\n", grant_speed);
}
+LUSTRE_RO_ATTR(grant_speed);
-LDLM_POOL_PROC_READER_SEQ_SHOW(grant_plan, int);
-LPROC_SEQ_FOPS_RO(lprocfs_grant_plan);
+LDLM_POOL_SYSFS_READER_SHOW(grant_plan, int);
+LUSTRE_RO_ATTR(grant_plan);
-LDLM_POOL_PROC_READER_SEQ_SHOW(recalc_period, int);
-LDLM_POOL_PROC_WRITER(recalc_period, int);
-static ssize_t lprocfs_recalc_period_seq_write(struct file *file,
- const char __user *buf,
- size_t len, loff_t *off)
-{
- struct seq_file *seq = file->private_data;
+LDLM_POOL_SYSFS_READER_SHOW(recalc_period, int);
+LDLM_POOL_SYSFS_WRITER_STORE(recalc_period, int);
+LUSTRE_RW_ATTR(recalc_period);
- return lprocfs_wr_recalc_period(file, buf, len, seq->private);
-}
-LPROC_SEQ_FOPS(lprocfs_recalc_period);
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(server_lock_volume, u64);
+LUSTRE_RO_ATTR(server_lock_volume);
-LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, u64);
-LPROC_SEQ_FOPS_RO_TYPE(ldlm_pool, atomic);
-LPROC_SEQ_FOPS_RW_TYPE(ldlm_pool_rw, atomic);
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(limit, atomic);
+LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(limit, atomic);
+LUSTRE_RW_ATTR(limit);
-LPROC_SEQ_FOPS_RO(lprocfs_grant_speed);
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(granted, atomic);
+LUSTRE_RO_ATTR(granted);
+
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(cancel_rate, atomic);
+LUSTRE_RO_ATTR(cancel_rate);
+
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(grant_rate, atomic);
+LUSTRE_RO_ATTR(grant_rate);
+
+LDLM_POOL_SYSFS_READER_NOLOCK_SHOW(lock_volume_factor, atomic);
+LDLM_POOL_SYSFS_WRITER_NOLOCK_STORE(lock_volume_factor, atomic);
+LUSTRE_RW_ATTR(lock_volume_factor);
#define LDLM_POOL_ADD_VAR(name, var, ops) \
do { \
snprintf(var_name, MAX_STRING_SIZE, #name); \
pool_vars[0].data = var; \
pool_vars[0].fops = ops; \
- lprocfs_add_vars(pl->pl_proc_dir, pool_vars, NULL);\
+ ldebugfs_add_vars(pl->pl_debugfs_entry, pool_vars, NULL);\
} while (0)
-static int ldlm_pool_proc_init(struct ldlm_pool *pl)
+/* These are for pools in /sys/fs/lustre/ldlm/namespaces/.../pool */
+static struct attribute *ldlm_pl_attrs[] = {
+ &lustre_attr_grant_speed.attr,
+ &lustre_attr_grant_plan.attr,
+ &lustre_attr_recalc_period.attr,
+ &lustre_attr_server_lock_volume.attr,
+ &lustre_attr_limit.attr,
+ &lustre_attr_granted.attr,
+ &lustre_attr_cancel_rate.attr,
+ &lustre_attr_grant_rate.attr,
+ &lustre_attr_lock_volume_factor.attr,
+ NULL,
+};
+
+static void ldlm_pl_release(struct kobject *kobj)
+{
+ struct ldlm_pool *pl = container_of(kobj, struct ldlm_pool,
+ pl_kobj);
+ complete(&pl->pl_kobj_unregister);
+}
+
+static struct kobj_type ldlm_pl_ktype = {
+ .default_attrs = ldlm_pl_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = ldlm_pl_release,
+};
+
+static int ldlm_pool_sysfs_init(struct ldlm_pool *pl)
+{
+ struct ldlm_namespace *ns = ldlm_pl2ns(pl);
+ int err;
+
+ init_completion(&pl->pl_kobj_unregister);
+ err = kobject_init_and_add(&pl->pl_kobj, &ldlm_pl_ktype, &ns->ns_kobj,
+ "pool");
+
+ return err;
+}
+
+static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
{
struct ldlm_namespace *ns = ldlm_pl2ns(pl);
- struct proc_dir_entry *parent_ns_proc;
+ struct dentry *debugfs_ns_parent;
struct lprocfs_vars pool_vars[2];
char *var_name = NULL;
int rc = 0;
- OBD_ALLOC(var_name, MAX_STRING_SIZE + 1);
+ var_name = kzalloc(MAX_STRING_SIZE + 1, GFP_NOFS);
if (!var_name)
return -ENOMEM;
- parent_ns_proc = ns->ns_proc_dir_entry;
- if (parent_ns_proc == NULL) {
- CERROR("%s: proc entry is not initialized\n",
+ debugfs_ns_parent = ns->ns_debugfs_entry;
+ if (IS_ERR_OR_NULL(debugfs_ns_parent)) {
+ CERROR("%s: debugfs entry is not initialized\n",
ldlm_ns_name(ns));
rc = -EINVAL;
goto out_free_name;
}
- pl->pl_proc_dir = lprocfs_register("pool", parent_ns_proc,
- NULL, NULL);
- if (IS_ERR(pl->pl_proc_dir)) {
- CERROR("LProcFS failed in ldlm-pool-init\n");
- rc = PTR_ERR(pl->pl_proc_dir);
- pl->pl_proc_dir = NULL;
+ pl->pl_debugfs_entry = ldebugfs_register("pool", debugfs_ns_parent,
+ NULL, NULL);
+ if (IS_ERR(pl->pl_debugfs_entry)) {
+ CERROR("LdebugFS failed in ldlm-pool-init\n");
+ rc = PTR_ERR(pl->pl_debugfs_entry);
+ pl->pl_debugfs_entry = NULL;
goto out_free_name;
}
@@ -770,20 +818,7 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
memset(pool_vars, 0, sizeof(pool_vars));
pool_vars[0].name = var_name;
- LDLM_POOL_ADD_VAR("server_lock_volume", &pl->pl_server_lock_volume,
- &ldlm_pool_u64_fops);
- LDLM_POOL_ADD_VAR("limit", &pl->pl_limit, &ldlm_pool_rw_atomic_fops);
- LDLM_POOL_ADD_VAR("granted", &pl->pl_granted, &ldlm_pool_atomic_fops);
- LDLM_POOL_ADD_VAR("grant_speed", pl, &lprocfs_grant_speed_fops);
- LDLM_POOL_ADD_VAR("cancel_rate", &pl->pl_cancel_rate,
- &ldlm_pool_atomic_fops);
- LDLM_POOL_ADD_VAR("grant_rate", &pl->pl_grant_rate,
- &ldlm_pool_atomic_fops);
- LDLM_POOL_ADD_VAR("grant_plan", pl, &lprocfs_grant_plan_fops);
- LDLM_POOL_ADD_VAR("recalc_period", pl, &lprocfs_recalc_period_fops);
- LDLM_POOL_ADD_VAR("lock_volume_factor", &pl->pl_lock_volume_factor,
- &ldlm_pool_rw_atomic_fops);
- LDLM_POOL_ADD_VAR("state", pl, &lprocfs_pool_state_fops);
+ LDLM_POOL_ADD_VAR(state, pl, &lprocfs_pool_state_fops);
pl->pl_stats = lprocfs_alloc_stats(LDLM_POOL_LAST_STAT -
LDLM_POOL_FIRST_STAT, 0);
@@ -825,32 +860,31 @@ static int ldlm_pool_proc_init(struct ldlm_pool *pl)
lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT,
LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
"recalc_timing", "sec");
- rc = lprocfs_register_stats(pl->pl_proc_dir, "stats", pl->pl_stats);
+ rc = ldebugfs_register_stats(pl->pl_debugfs_entry, "stats",
+ pl->pl_stats);
out_free_name:
- OBD_FREE(var_name, MAX_STRING_SIZE + 1);
+ kfree(var_name);
return rc;
}
-static void ldlm_pool_proc_fini(struct ldlm_pool *pl)
+static void ldlm_pool_sysfs_fini(struct ldlm_pool *pl)
+{
+ kobject_put(&pl->pl_kobj);
+ wait_for_completion(&pl->pl_kobj_unregister);
+}
+
+static void ldlm_pool_debugfs_fini(struct ldlm_pool *pl)
{
if (pl->pl_stats != NULL) {
lprocfs_free_stats(&pl->pl_stats);
pl->pl_stats = NULL;
}
- if (pl->pl_proc_dir != NULL) {
- lprocfs_remove(&pl->pl_proc_dir);
- pl->pl_proc_dir = NULL;
+ if (pl->pl_debugfs_entry != NULL) {
+ ldebugfs_remove(&pl->pl_debugfs_entry);
+ pl->pl_debugfs_entry = NULL;
}
}
-#else /* !CONFIG_PROC_FS */
-static int ldlm_pool_proc_init(struct ldlm_pool *pl)
-{
- return 0;
-}
-
-static void ldlm_pool_proc_fini(struct ldlm_pool *pl) {}
-#endif /* CONFIG_PROC_FS */
int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
int idx, ldlm_side_t client)
@@ -881,7 +915,11 @@ int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
pl->pl_recalc_period = LDLM_POOL_CLI_DEF_RECALC_PERIOD;
}
pl->pl_client_lock_volume = 0;
- rc = ldlm_pool_proc_init(pl);
+ rc = ldlm_pool_debugfs_init(pl);
+ if (rc)
+ return rc;
+
+ rc = ldlm_pool_sysfs_init(pl);
if (rc)
return rc;
@@ -893,7 +931,8 @@ EXPORT_SYMBOL(ldlm_pool_init);
void ldlm_pool_fini(struct ldlm_pool *pl)
{
- ldlm_pool_proc_fini(pl);
+ ldlm_pool_sysfs_fini(pl);
+ ldlm_pool_debugfs_fini(pl);
/*
* Pool should not be used after this point. We can't free it here as
@@ -1383,7 +1422,7 @@ static int ldlm_pools_thread_start(void)
if (ldlm_pools_thread != NULL)
return -EALREADY;
- OBD_ALLOC_PTR(ldlm_pools_thread);
+ ldlm_pools_thread = kzalloc(sizeof(*ldlm_pools_thread), GFP_NOFS);
if (ldlm_pools_thread == NULL)
return -ENOMEM;
@@ -1394,7 +1433,7 @@ static int ldlm_pools_thread_start(void)
"ldlm_poold");
if (IS_ERR(task)) {
CERROR("Can't start pool thread, error %ld\n", PTR_ERR(task));
- OBD_FREE(ldlm_pools_thread, sizeof(*ldlm_pools_thread));
+ kfree(ldlm_pools_thread);
ldlm_pools_thread = NULL;
return PTR_ERR(task);
}
@@ -1417,7 +1456,7 @@ static void ldlm_pools_thread_stop(void)
* in pools thread.
*/
wait_for_completion(&ldlm_pools_comp);
- OBD_FREE_PTR(ldlm_pools_thread);
+ kfree(ldlm_pools_thread);
ldlm_pools_thread = NULL;
}
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
index 4f713183145bb8..6245a2c36a0f6e 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_request.c
@@ -1462,7 +1462,7 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
lock->l_last_used));
lv = lvf * la * unused;
- /* Inform pool about current CLV to see it via proc. */
+ /* Inform pool about current CLV to see it via debugfs. */
ldlm_pool_set_clv(pl, lv);
/* Stop when SLV is not yet come from server or lv is smaller than
@@ -1472,7 +1472,7 @@ static ldlm_policy_res_t ldlm_cancel_lrur_policy(struct ldlm_namespace *ns,
}
/**
- * Callback function for proc used policy. Makes decision whether to keep
+ * Callback function for debugfs used policy. Makes decision whether to keep
* \a lock in LRU for current \a LRU size \a unused, added in current scan \a
* added and number of locks to be preferably canceled \a count.
*
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index f750d42a7ad555..cdb63665a11389 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -61,19 +61,17 @@ LIST_HEAD(ldlm_cli_active_namespace_list);
/* Client namespaces that don't have any locks in them */
LIST_HEAD(ldlm_cli_inactive_namespace_list);
-struct proc_dir_entry *ldlm_type_proc_dir = NULL;
-static struct proc_dir_entry *ldlm_ns_proc_dir = NULL;
-struct proc_dir_entry *ldlm_svc_proc_dir = NULL;
-
-extern unsigned int ldlm_cancel_unused_locks_before_replay;
+static struct dentry *ldlm_debugfs_dir;
+static struct dentry *ldlm_ns_debugfs_dir;
+struct dentry *ldlm_svc_debugfs_dir;
/* during debug dump certain amount of granted locks for one resource to avoid
* DDOS. */
unsigned int ldlm_dump_granted_max = 256;
-#if defined(CONFIG_PROC_FS)
-static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t
+lprocfs_wr_dump_ns(struct file *file, const char __user *buffer,
+ size_t count, loff_t *off)
{
ldlm_dump_all_namespaces(LDLM_NAMESPACE_SERVER, D_DLMTRACE);
ldlm_dump_all_namespaces(LDLM_NAMESPACE_CLIENT, D_DLMTRACE);
@@ -82,81 +80,82 @@ static ssize_t lprocfs_wr_dump_ns(struct file *file, const char __user *buffer,
LPROC_SEQ_FOPS_WR_ONLY(ldlm, dump_ns);
LPROC_SEQ_FOPS_RW_TYPE(ldlm_rw, uint);
-LPROC_SEQ_FOPS_RO_TYPE(ldlm, uint);
-int ldlm_proc_setup(void)
+static struct lprocfs_vars ldlm_debugfs_list[] = {
+ { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 },
+ { "dump_granted_max", &ldlm_rw_uint_fops, &ldlm_dump_granted_max },
+ { NULL }
+};
+
+int ldlm_debugfs_setup(void)
{
int rc;
- struct lprocfs_vars list[] = {
- { "dump_namespaces", &ldlm_dump_ns_fops, NULL, 0222 },
- { "dump_granted_max", &ldlm_rw_uint_fops,
- &ldlm_dump_granted_max },
- { "cancel_unused_locks_before_replay", &ldlm_rw_uint_fops,
- &ldlm_cancel_unused_locks_before_replay },
- { NULL } };
- LASSERT(ldlm_ns_proc_dir == NULL);
-
- ldlm_type_proc_dir = lprocfs_register(OBD_LDLM_DEVICENAME,
- proc_lustre_root,
- NULL, NULL);
- if (IS_ERR(ldlm_type_proc_dir)) {
+
+ ldlm_debugfs_dir = ldebugfs_register(OBD_LDLM_DEVICENAME,
+ debugfs_lustre_root,
+ NULL, NULL);
+ if (IS_ERR_OR_NULL(ldlm_debugfs_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
- rc = PTR_ERR(ldlm_type_proc_dir);
+ rc = ldlm_debugfs_dir ? PTR_ERR(ldlm_debugfs_dir) : -ENOMEM;
goto err;
}
- ldlm_ns_proc_dir = lprocfs_register("namespaces",
- ldlm_type_proc_dir,
- NULL, NULL);
- if (IS_ERR(ldlm_ns_proc_dir)) {
+ ldlm_ns_debugfs_dir = ldebugfs_register("namespaces",
+ ldlm_debugfs_dir,
+ NULL, NULL);
+ if (IS_ERR_OR_NULL(ldlm_ns_debugfs_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
- rc = PTR_ERR(ldlm_ns_proc_dir);
+ rc = ldlm_ns_debugfs_dir ? PTR_ERR(ldlm_ns_debugfs_dir)
+ : -ENOMEM;
goto err_type;
}
- ldlm_svc_proc_dir = lprocfs_register("services",
- ldlm_type_proc_dir,
- NULL, NULL);
- if (IS_ERR(ldlm_svc_proc_dir)) {
+ ldlm_svc_debugfs_dir = ldebugfs_register("services",
+ ldlm_debugfs_dir,
+ NULL, NULL);
+ if (IS_ERR_OR_NULL(ldlm_svc_debugfs_dir)) {
CERROR("LProcFS failed in ldlm-init\n");
- rc = PTR_ERR(ldlm_svc_proc_dir);
+ rc = ldlm_svc_debugfs_dir ? PTR_ERR(ldlm_svc_debugfs_dir)
+ : -ENOMEM;
goto err_ns;
}
- rc = lprocfs_add_vars(ldlm_type_proc_dir, list, NULL);
+ rc = ldebugfs_add_vars(ldlm_debugfs_dir, ldlm_debugfs_list, NULL);
return 0;
err_ns:
- lprocfs_remove(&ldlm_ns_proc_dir);
+ ldebugfs_remove(&ldlm_ns_debugfs_dir);
err_type:
- lprocfs_remove(&ldlm_type_proc_dir);
+ ldebugfs_remove(&ldlm_debugfs_dir);
err:
- ldlm_svc_proc_dir = NULL;
- ldlm_type_proc_dir = NULL;
- ldlm_ns_proc_dir = NULL;
+ ldlm_svc_debugfs_dir = NULL;
+ ldlm_ns_debugfs_dir = NULL;
+ ldlm_debugfs_dir = NULL;
return rc;
}
-void ldlm_proc_cleanup(void)
+void ldlm_debugfs_cleanup(void)
{
- if (ldlm_svc_proc_dir)
- lprocfs_remove(&ldlm_svc_proc_dir);
+ if (!IS_ERR_OR_NULL(ldlm_svc_debugfs_dir))
+ ldebugfs_remove(&ldlm_svc_debugfs_dir);
- if (ldlm_ns_proc_dir)
- lprocfs_remove(&ldlm_ns_proc_dir);
+ if (!IS_ERR_OR_NULL(ldlm_ns_debugfs_dir))
+ ldebugfs_remove(&ldlm_ns_debugfs_dir);
- if (ldlm_type_proc_dir)
- lprocfs_remove(&ldlm_type_proc_dir);
+ if (!IS_ERR_OR_NULL(ldlm_debugfs_dir))
+ ldebugfs_remove(&ldlm_debugfs_dir);
- ldlm_svc_proc_dir = NULL;
- ldlm_type_proc_dir = NULL;
- ldlm_ns_proc_dir = NULL;
+ ldlm_svc_debugfs_dir = NULL;
+ ldlm_ns_debugfs_dir = NULL;
+ ldlm_debugfs_dir = NULL;
}
-static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
+static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_namespace *ns = m->private;
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
__u64 res = 0;
struct cfs_hash_bd bd;
int i;
@@ -164,46 +163,56 @@ static int lprocfs_ns_resources_seq_show(struct seq_file *m, void *v)
/* result is not strictly consistent */
cfs_hash_for_each_bucket(ns->ns_rs_hash, &bd, i)
res += cfs_hash_bd_count_get(&bd);
- return lprocfs_rd_u64(m, &res);
+ return sprintf(buf, "%lld\n", res);
}
-LPROC_SEQ_FOPS_RO(lprocfs_ns_resources);
+LUSTRE_RO_ATTR(resource_count);
-static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v)
+static ssize_t lock_count_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_namespace *ns = m->private;
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
__u64 locks;
locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS,
LPROCFS_FIELDS_FLAGS_SUM);
- return lprocfs_rd_u64(m, &locks);
+ return sprintf(buf, "%lld\n", locks);
+}
+LUSTRE_RO_ATTR(lock_count);
+
+static ssize_t lock_unused_count_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+
+ return sprintf(buf, "%d\n", ns->ns_nr_unused);
}
-LPROC_SEQ_FOPS_RO(lprocfs_ns_locks);
+LUSTRE_RO_ATTR(lock_unused_count);
-static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v)
+static ssize_t lru_size_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_namespace *ns = m->private;
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
__u32 *nr = &ns->ns_max_unused;
if (ns_connect_lru_resize(ns))
nr = &ns->ns_nr_unused;
- return lprocfs_rd_uint(m, nr);
+ return sprintf(buf, "%u", *nr);
}
-static ssize_t lprocfs_lru_size_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
- char dummy[MAX_STRING_SIZE + 1];
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
unsigned long tmp;
int lru_resize;
int err;
- dummy[MAX_STRING_SIZE] = '\0';
- if (copy_from_user(dummy, buffer, MAX_STRING_SIZE))
- return -EFAULT;
-
- if (strncmp(dummy, "clear", 5) == 0) {
+ if (strncmp(buffer, "clear", 5) == 0) {
CDEBUG(D_DLMTRACE,
"dropping all unused locks from namespace %s\n",
ldlm_ns_name(ns));
@@ -229,9 +238,9 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file,
return count;
}
- err = kstrtoul(dummy, 10, &tmp);
+ err = kstrtoul(buffer, 10, &tmp);
if (err != 0) {
- CERROR("invalid value written\n");
+ CERROR("lru_size: invalid value written\n");
return -EINVAL;
}
lru_resize = (tmp == 0);
@@ -277,25 +286,56 @@ static ssize_t lprocfs_lru_size_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(lprocfs_lru_size);
+LUSTRE_RW_ATTR(lru_size);
-static int lprocfs_elc_seq_show(struct seq_file *m, void *v)
+static ssize_t lru_max_age_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ldlm_namespace *ns = m->private;
- unsigned int supp = ns_connect_cancelset(ns);
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
- return lprocfs_rd_uint(m, &supp);
+ return sprintf(buf, "%u", ns->ns_max_age);
}
-static ssize_t lprocfs_elc_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t lru_max_age_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct ldlm_namespace *ns = ((struct seq_file *)file->private_data)->private;
- unsigned int supp = -1;
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+ unsigned long tmp;
+ int err;
+
+ err = kstrtoul(buffer, 10, &tmp);
+ if (err != 0)
+ return -EINVAL;
+
+ ns->ns_max_age = tmp;
+
+ return count;
+}
+LUSTRE_RW_ATTR(lru_max_age);
+
+static ssize_t early_lock_cancel_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
+{
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+
+ return sprintf(buf, "%d\n", ns_connect_cancelset(ns));
+}
+
+static ssize_t early_lock_cancel_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
+{
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+ unsigned long supp = -1;
int rc;
- rc = lprocfs_wr_uint(file, buffer, count, &supp);
+ rc = kstrtoul(buffer, 10, &supp);
if (rc < 0)
return rc;
@@ -305,91 +345,88 @@ static ssize_t lprocfs_elc_seq_write(struct file *file,
ns->ns_connect_flags |= OBD_CONNECT_CANCELSET;
return count;
}
-LPROC_SEQ_FOPS(lprocfs_elc);
+LUSTRE_RW_ATTR(early_lock_cancel);
+
+/* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */
+static struct attribute *ldlm_ns_attrs[] = {
+ &lustre_attr_resource_count.attr,
+ &lustre_attr_lock_count.attr,
+ &lustre_attr_lock_unused_count.attr,
+ &lustre_attr_lru_size.attr,
+ &lustre_attr_lru_max_age.attr,
+ &lustre_attr_early_lock_cancel.attr,
+ NULL,
+};
+
+static void ldlm_ns_release(struct kobject *kobj)
+{
+ struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+ ns_kobj);
+ complete(&ns->ns_kobj_unregister);
+}
-void ldlm_namespace_proc_unregister(struct ldlm_namespace *ns)
+static struct kobj_type ldlm_ns_ktype = {
+ .default_attrs = ldlm_ns_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = ldlm_ns_release,
+};
+
+static void ldlm_namespace_debugfs_unregister(struct ldlm_namespace *ns)
{
- if (ns->ns_proc_dir_entry == NULL)
+ if (IS_ERR_OR_NULL(ns->ns_debugfs_entry))
CERROR("dlm namespace %s has no procfs dir?\n",
ldlm_ns_name(ns));
else
- lprocfs_remove(&ns->ns_proc_dir_entry);
+ ldebugfs_remove(&ns->ns_debugfs_entry);
if (ns->ns_stats != NULL)
lprocfs_free_stats(&ns->ns_stats);
}
-#define LDLM_NS_ADD_VAR(name, var, ops) \
- do { \
- snprintf(lock_name, MAX_STRING_SIZE, name); \
- lock_vars[0].data = var; \
- lock_vars[0].fops = ops; \
- lprocfs_add_vars(ns_pde, lock_vars, NULL); \
- } while (0)
-
-int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
+void ldlm_namespace_sysfs_unregister(struct ldlm_namespace *ns)
{
- struct lprocfs_vars lock_vars[2];
- char lock_name[MAX_STRING_SIZE + 1];
- struct proc_dir_entry *ns_pde;
+ kobject_put(&ns->ns_kobj);
+ wait_for_completion(&ns->ns_kobj_unregister);
+}
- LASSERT(ns != NULL);
- LASSERT(ns->ns_rs_hash != NULL);
+int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns)
+{
+ int err;
- if (ns->ns_proc_dir_entry != NULL) {
- ns_pde = ns->ns_proc_dir_entry;
- } else {
- ns_pde = proc_mkdir(ldlm_ns_name(ns), ldlm_ns_proc_dir);
- if (ns_pde == NULL)
- return -ENOMEM;
- ns->ns_proc_dir_entry = ns_pde;
- }
+ ns->ns_kobj.kset = ldlm_ns_kset;
+ init_completion(&ns->ns_kobj_unregister);
+ err = kobject_init_and_add(&ns->ns_kobj, &ldlm_ns_ktype, NULL,
+ "%s", ldlm_ns_name(ns));
ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0);
- if (ns->ns_stats == NULL)
+ if (ns->ns_stats == NULL) {
+ kobject_put(&ns->ns_kobj);
return -ENOMEM;
+ }
lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS,
LPROCFS_CNTR_AVGMINMAX, "locks", "locks");
- lock_name[MAX_STRING_SIZE] = '\0';
-
- memset(lock_vars, 0, sizeof(lock_vars));
- lock_vars[0].name = lock_name;
+ return err;
+}
- LDLM_NS_ADD_VAR("resource_count", ns, &lprocfs_ns_resources_fops);
- LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops);
+static int ldlm_namespace_debugfs_register(struct ldlm_namespace *ns)
+{
+ struct dentry *ns_entry;
- if (ns_is_client(ns)) {
- LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused,
- &ldlm_uint_fops);
- LDLM_NS_ADD_VAR("lru_size", ns, &lprocfs_lru_size_fops);
- LDLM_NS_ADD_VAR("lru_max_age", &ns->ns_max_age,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("early_lock_cancel", ns, &lprocfs_elc_fops);
+ if (!IS_ERR_OR_NULL(ns->ns_debugfs_entry)) {
+ ns_entry = ns->ns_debugfs_entry;
} else {
- LDLM_NS_ADD_VAR("ctime_age_limit", &ns->ns_ctime_age_limit,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("lock_timeouts", &ns->ns_timeouts,
- &ldlm_uint_fops);
- LDLM_NS_ADD_VAR("max_nolock_bytes", &ns->ns_max_nolock_size,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("contention_seconds", &ns->ns_contention_time,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("contended_locks", &ns->ns_contended_locks,
- &ldlm_rw_uint_fops);
- LDLM_NS_ADD_VAR("max_parallel_ast", &ns->ns_max_parallel_ast,
- &ldlm_rw_uint_fops);
+ ns_entry = debugfs_create_dir(ldlm_ns_name(ns),
+ ldlm_ns_debugfs_dir);
+ if (ns_entry == NULL)
+ return -ENOMEM;
+ ns->ns_debugfs_entry = ns_entry;
}
+
return 0;
}
#undef MAX_STRING_SIZE
-#else /* CONFIG_PROC_FS */
-
-#define ldlm_namespace_proc_unregister(ns) ({; })
-#define ldlm_namespace_proc_register(ns) ({0; })
-
-#endif /* CONFIG_PROC_FS */
static unsigned ldlm_res_hop_hash(struct cfs_hash *hs,
const void *key, unsigned mask)
@@ -590,7 +627,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
break;
}
- OBD_ALLOC_PTR(ns);
+ ns = kzalloc(sizeof(*ns), GFP_NOFS);
if (!ns)
goto out_ref;
@@ -623,25 +660,26 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
atomic_set(&ns->ns_bref, 0);
init_waitqueue_head(&ns->ns_waitq);
- ns->ns_max_nolock_size = NS_DEFAULT_MAX_NOLOCK_BYTES;
- ns->ns_contention_time = NS_DEFAULT_CONTENTION_SECONDS;
- ns->ns_contended_locks = NS_DEFAULT_CONTENDED_LOCKS;
-
ns->ns_max_parallel_ast = LDLM_DEFAULT_PARALLEL_AST_LIMIT;
ns->ns_nr_unused = 0;
ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
ns->ns_max_age = LDLM_DEFAULT_MAX_ALIVE;
- ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT;
- ns->ns_timeouts = 0;
ns->ns_orig_connect_flags = 0;
ns->ns_connect_flags = 0;
ns->ns_stopping = 0;
- rc = ldlm_namespace_proc_register(ns);
+
+ rc = ldlm_namespace_sysfs_register(ns);
if (rc != 0) {
- CERROR("Can't initialize ns proc, rc %d\n", rc);
+ CERROR("Can't initialize ns sysfs, rc %d\n", rc);
goto out_hash;
}
+ rc = ldlm_namespace_debugfs_register(ns);
+ if (rc != 0) {
+ CERROR("Can't initialize ns proc, rc %d\n", rc);
+ goto out_sysfs;
+ }
+
idx = ldlm_namespace_nr_read(client);
rc = ldlm_pool_init(&ns->ns_pool, ns, idx, client);
if (rc) {
@@ -652,12 +690,14 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
ldlm_namespace_register(ns, client);
return ns;
out_proc:
- ldlm_namespace_proc_unregister(ns);
+ ldlm_namespace_debugfs_unregister(ns);
+out_sysfs:
+ ldlm_namespace_sysfs_unregister(ns);
ldlm_namespace_cleanup(ns, 0);
out_hash:
cfs_hash_putref(ns->ns_rs_hash);
out_ns:
- OBD_FREE_PTR(ns);
+ kfree(ns);
out_ref:
ldlm_put_ref();
return NULL;
@@ -898,13 +938,13 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns)
* Removing it after @dir may cause oops. */
ldlm_pool_fini(&ns->ns_pool);
- ldlm_namespace_proc_unregister(ns);
+ ldlm_namespace_debugfs_unregister(ns);
cfs_hash_putref(ns->ns_rs_hash);
/* Namespace \a ns should be not on list at this time, otherwise
* this will cause issues related to using freed \a ns in poold
* thread. */
LASSERT(list_empty(&ns->ns_list_chain));
- OBD_FREE_PTR(ns);
+ kfree(ns);
ldlm_put_ref();
}
@@ -915,7 +955,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns)
* proc1: destroy import
* class_disconnect_export(grab cl_sem) ->
* -> ldlm_namespace_free ->
- * -> lprocfs_remove(grab _lprocfs_lock).
+ * -> ldebugfs_remove(grab _lprocfs_lock).
* proc2: read proc info
* lprocfs_fops_read(grab _lprocfs_lock) ->
* -> osc_rd_active, etc(grab cl_sem).
@@ -1137,10 +1177,8 @@ ldlm_resource_get(struct ldlm_namespace *ns, struct ldlm_resource *parent,
CERROR("%s: lvbo_init failed for resource %#llx:%#llx: rc = %d\n",
ns->ns_obd->obd_name, name->name[0],
name->name[1], rc);
- if (res->lr_lvb_data) {
- OBD_FREE(res->lr_lvb_data, res->lr_lvb_len);
- res->lr_lvb_data = NULL;
- }
+ kfree(res->lr_lvb_data);
+ res->lr_lvb_data = NULL;
res->lr_lvb_len = rc;
mutex_unlock(&res->lr_lvb_mutex);
ldlm_resource_putref(res);
diff --git a/drivers/staging/lustre/lustre/libcfs/Makefile b/drivers/staging/lustre/lustre/libcfs/Makefile
index 2996a48a31fb67..fabdd3e5de9e61 100644
--- a/drivers/staging/lustre/lustre/libcfs/Makefile
+++ b/drivers/staging/lustre/lustre/libcfs/Makefile
@@ -7,6 +7,7 @@ libcfs-linux-objs += linux-curproc.o
libcfs-linux-objs += linux-module.o
libcfs-linux-objs += linux-crypto.o
libcfs-linux-objs += linux-crypto-adler.o
+libcfs-linux-objs += linux-mem.o
libcfs-linux-objs := $(addprefix linux/,$(libcfs-linux-objs))
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c
new file mode 100644
index 00000000000000..025e2f0028ab1e
--- /dev/null
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-mem.c
@@ -0,0 +1,59 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * 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 version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
+ *
+ */
+/*
+ * This file creates a memory allocation primitive for Lustre, that
+ * allows to fallback to vmalloc allocations should regular kernel allocations
+ * fail due to size or system memory fragmentation.
+ *
+ * Author: Oleg Drokin <green@linuxhacker.ru>
+ *
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Seagate Technology.
+ */
+#include <linux/slab.h>
+#include <linux/vmalloc.h>
+
+#include "../../../include/linux/libcfs/libcfs.h"
+
+void *libcfs_kvzalloc(size_t size, gfp_t flags)
+{
+ void *ret;
+
+ ret = kzalloc(size, flags | __GFP_NOWARN);
+ if (!ret)
+ ret = __vmalloc(size, flags | __GFP_ZERO, PAGE_KERNEL);
+ return ret;
+}
+EXPORT_SYMBOL(libcfs_kvzalloc);
+
+void *libcfs_kvzalloc_cpt(struct cfs_cpt_table *cptab, int cpt, size_t size,
+ gfp_t flags)
+{
+ void *ret;
+
+ ret = kzalloc_node(size, flags | __GFP_NOWARN,
+ cfs_cpt_spread_node(cptab, cpt));
+ if (!ret) {
+ WARN_ON(!(flags & (__GFP_FS|__GFP_HIGH)));
+ ret = vmalloc_node(size, cfs_cpt_spread_node(cptab, cpt));
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(libcfs_kvzalloc_cpt);
diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
index c8e293002e070b..483cbc82e53889 100644
--- a/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
+++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-tracefile.c
@@ -102,11 +102,10 @@ void cfs_tracefile_fini_arch(void)
int j;
for (i = 0; i < num_possible_cpus(); i++)
- for (j = 0; j < 3; j++)
- if (cfs_trace_console_buffers[i][j] != NULL) {
- kfree(cfs_trace_console_buffers[i][j]);
- cfs_trace_console_buffers[i][j] = NULL;
- }
+ for (j = 0; j < 3; j++) {
+ kfree(cfs_trace_console_buffers[i][j]);
+ cfs_trace_console_buffers[i][j] = NULL;
+ }
for (i = 0; cfs_trace_data[i] != NULL; i++) {
kfree(cfs_trace_data[i]);
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index f0ee76abfd5a4a..83b1a708b1e3d6 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -49,7 +49,6 @@
#include <linux/file.h>
#include <linux/list.h>
-#include <linux/proc_fs.h>
#include <linux/sysctl.h>
# define DEBUG_SUBSYSTEM S_LNET
diff --git a/drivers/staging/lustre/lustre/llite/Makefile b/drivers/staging/lustre/lustre/llite/Makefile
index 7d70115d5bc783..2cbc46838fdd83 100644
--- a/drivers/staging/lustre/lustre/llite/Makefile
+++ b/drivers/staging/lustre/lustre/llite/Makefile
@@ -5,7 +5,6 @@ lustre-y := dcache.o dir.o file.o llite_close.o llite_lib.o llite_nfs.o \
xattr.o xattr_cache.o remote_perm.o llite_rmtacl.o llite_capa.o \
rw26.o super25.o statahead.o \
../lclient/glimpse.o ../lclient/lcommon_cl.o ../lclient/lcommon_misc.o \
- vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o
+ vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o lproc_llite.o
-lustre-$(CONFIG_PROC_FS) += lproc_llite.o
llite_lloop-y := lloop.o
diff --git a/drivers/staging/lustre/lustre/llite/dcache.c b/drivers/staging/lustre/lustre/llite/dcache.c
index 5af01351306d3d..7b008a64707d7a 100644
--- a/drivers/staging/lustre/lustre/llite/dcache.c
+++ b/drivers/staging/lustre/lustre/llite/dcache.c
@@ -52,7 +52,7 @@ static void free_dentry_data(struct rcu_head *head)
struct ll_dentry_data *lld;
lld = container_of(head, struct ll_dentry_data, lld_rcu_head);
- OBD_FREE_PTR(lld);
+ kfree(lld);
}
/* should NOT be called with the dcache lock, see fs/dcache.c */
@@ -67,7 +67,7 @@ static void ll_release(struct dentry *de)
if (lld->lld_it) {
ll_intent_release(lld->lld_it);
- OBD_FREE(lld->lld_it, sizeof(*lld->lld_it));
+ kfree(lld->lld_it);
}
de->d_fsdata = NULL;
@@ -194,7 +194,7 @@ int ll_d_init(struct dentry *de)
de->d_fsdata = lld;
__d_lustre_invalidate(de);
} else {
- OBD_FREE_PTR(lld);
+ kfree(lld);
}
spin_unlock(&de->d_lock);
} else {
diff --git a/drivers/staging/lustre/lustre/llite/dir.c b/drivers/staging/lustre/lustre/llite/dir.c
index a5bc694dcb64aa..4b0de8d89e5c54 100644
--- a/drivers/staging/lustre/lustre/llite/dir.c
+++ b/drivers/staging/lustre/lustre/llite/dir.c
@@ -239,7 +239,7 @@ static int ll_dir_filler(void *_hash, struct page *page0)
ll_pagevec_lru_add_file(&lru_pvec);
if (page_pool != &page0)
- OBD_FREE(page_pool, sizeof(struct page *) * max_pages);
+ kfree(page_pool);
return rc;
}
@@ -650,7 +650,7 @@ static int ll_send_mgc_param(struct obd_export *mgc, char *string)
sizeof(struct mgs_send_param), msp, NULL);
if (rc)
CERROR("Failed to set parameter: %d\n", rc);
- OBD_FREE_PTR(msp);
+ kfree(msp);
return rc;
}
@@ -754,10 +754,8 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
char *buf;
param = kzalloc(MGS_PARAM_MAXLEN, GFP_NOFS);
- if (!param) {
- rc = -ENOMEM;
- goto end;
- }
+ if (!param)
+ return -ENOMEM;
buf = param;
/* Get fsname and assume devname to be -MDT0000. */
@@ -786,8 +784,7 @@ int ll_dir_setstripe(struct inode *inode, struct lov_user_md *lump,
rc = ll_send_mgc_param(mgc->u.cli.cl_mgc_mgsexp, param);
end:
- if (param != NULL)
- OBD_FREE(param, MGS_PARAM_MAXLEN);
+ kfree(param);
}
return rc;
}
@@ -1072,7 +1069,7 @@ static int copy_and_ioctl(int cmd, struct obd_export *exp,
rc = obd_iocontrol(cmd, exp, size, copy, NULL);
out:
- OBD_FREE(copy, size);
+ kfree(copy);
return rc;
}
@@ -1163,7 +1160,7 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
oqctl->qc_cmd = Q_QUOTAOFF;
obd_quotactl(sbi->ll_md_exp, oqctl);
}
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
return rc;
}
/* If QIF_SPACE is not set, client should collect the
@@ -1206,11 +1203,11 @@ static int quotactl_ioctl(struct ll_sb_info *sbi, struct if_quotactl *qctl)
oqctl->qc_dqblk.dqb_valid &= ~QIF_SPACE;
}
- OBD_FREE_PTR(oqctl_tmp);
+ kfree(oqctl_tmp);
}
out:
QCTL_COPY(qctl, oqctl);
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
}
return rc;
@@ -1436,8 +1433,7 @@ lmv_out_free:
goto free_lmv;
}
free_lmv:
- if (tmp)
- OBD_FREE(tmp, lum_size);
+ kfree(tmp);
return rc;
}
case LL_IOC_REMOVE_ENTRY: {
@@ -1657,7 +1653,7 @@ free_lmm:
if (rc < 0)
CDEBUG(D_INFO, "obd_quotacheck failed: rc %d\n", rc);
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
return error ?: rc;
}
case OBD_IOC_POLL_QUOTACHECK: {
@@ -1691,7 +1687,7 @@ free_lmm:
goto out_poll;
}
out_poll:
- OBD_FREE_PTR(check);
+ kfree(check);
return rc;
}
case LL_IOC_QUOTACTL: {
@@ -1712,7 +1708,7 @@ out_poll:
rc = -EFAULT;
out_quotactl:
- OBD_FREE_PTR(qctl);
+ kfree(qctl);
return rc;
}
case OBD_IOC_GETDTNAME:
@@ -1781,13 +1777,13 @@ out_quotactl:
/* We don't know the true size yet; copy the fixed-size part */
if (copy_from_user(hur, (void *)arg, sizeof(*hur))) {
- OBD_FREE_PTR(hur);
+ kfree(hur);
return -EFAULT;
}
/* Compute the whole struct size */
totalsize = hur_len(hur);
- OBD_FREE_PTR(hur);
+ kfree(hur);
if (totalsize < 0)
return -E2BIG;
@@ -1865,7 +1861,7 @@ out_quotactl:
if (!copy)
return -ENOMEM;
if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
- OBD_FREE_PTR(copy);
+ kfree(copy);
return -EFAULT;
}
@@ -1873,7 +1869,7 @@ out_quotactl:
if (copy_to_user((char *)arg, copy, sizeof(*copy)))
rc = -EFAULT;
- OBD_FREE_PTR(copy);
+ kfree(copy);
return rc;
}
case LL_IOC_HSM_COPY_END: {
@@ -1884,7 +1880,7 @@ out_quotactl:
if (!copy)
return -ENOMEM;
if (copy_from_user(copy, (char *)arg, sizeof(*copy))) {
- OBD_FREE_PTR(copy);
+ kfree(copy);
return -EFAULT;
}
@@ -1892,7 +1888,7 @@ out_quotactl:
if (copy_to_user((char *)arg, copy, sizeof(*copy)))
rc = -EFAULT;
- OBD_FREE_PTR(copy);
+ kfree(copy);
return rc;
}
default:
diff --git a/drivers/staging/lustre/lustre/llite/file.c b/drivers/staging/lustre/lustre/llite/file.c
index 4b44c634fcc3de..5c05f41d357518 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -213,7 +213,7 @@ out:
md_clear_open_replay_data(md_exp, och);
/* Free @och if it is not waiting for DONE_WRITING. */
och->och_fh.cookie = DEAD_HANDLE_MAGIC;
- OBD_FREE_PTR(och);
+ kfree(och);
}
if (req) /* This is close request */
ptlrpc_req_finished(req);
@@ -693,7 +693,7 @@ restart:
out_och_free:
if (rc) {
if (och_p && *och_p) {
- OBD_FREE(*och_p, sizeof(struct obd_client_handle));
+ kfree(*och_p);
*och_p = NULL; /* OBD_FREE writes some magic there */
(*och_usecount)--;
}
@@ -875,7 +875,7 @@ out_close:
out_release_it:
ll_intent_release(&it);
out:
- OBD_FREE_PTR(och);
+ kfree(och);
return ERR_PTR(rc);
}
@@ -1779,7 +1779,7 @@ int ll_fid2path(struct inode *inode, void __user *arg)
rc = -EFAULT;
gf_free:
- OBD_FREE(gfout, outsize);
+ kfree(gfout);
return rc;
}
@@ -1883,7 +1883,7 @@ int ll_data_version(struct inode *inode, __u64 *data_version,
*data_version = obdo->o_data_version;
}
- OBD_FREE_PTR(obdo);
+ kfree(obdo);
out:
ccc_inode_lsm_put(inode, lsm);
return rc;
@@ -2109,8 +2109,7 @@ putgl:
}
free:
- if (llss != NULL)
- OBD_FREE_PTR(llss);
+ kfree(llss);
return rc;
}
@@ -2152,22 +2151,20 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
/* set HSM flags */
hss = kzalloc(sizeof(*hss), GFP_NOFS);
- if (!hss) {
- rc = -ENOMEM;
- goto out;
- }
+ if (!hss)
+ return -ENOMEM;
hss->hss_valid = HSS_SETMASK | HSS_ARCHIVE_ID;
hss->hss_archive_id = hui->hui_archive_id;
hss->hss_setmask = HS_ARCHIVED | HS_EXISTS | HS_RELEASED;
rc = ll_hsm_state_set(inode, hss);
if (rc != 0)
- goto out;
+ goto free_hss;
attr = kzalloc(sizeof(*attr), GFP_NOFS);
if (!attr) {
rc = -ENOMEM;
- goto out;
+ goto free_hss;
}
attr->ia_mode = hui->hui_mode & (S_IRWXU | S_IRWXG | S_IRWXO);
@@ -2193,13 +2190,9 @@ static int ll_hsm_import(struct inode *inode, struct file *file,
mutex_unlock(&inode->i_mutex);
-out:
- if (hss != NULL)
- OBD_FREE_PTR(hss);
-
- if (attr != NULL)
- OBD_FREE_PTR(attr);
-
+ kfree(attr);
+free_hss:
+ kfree(hss);
return rc;
}
@@ -2350,7 +2343,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
LUSTRE_OPC_ANY, hus);
if (IS_ERR(op_data)) {
- OBD_FREE_PTR(hus);
+ kfree(hus);
return PTR_ERR(op_data);
}
@@ -2361,7 +2354,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
rc = -EFAULT;
ll_finish_md_op_data(op_data);
- OBD_FREE_PTR(hus);
+ kfree(hus);
return rc;
}
case LL_IOC_HSM_STATE_SET: {
@@ -2373,13 +2366,13 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return -ENOMEM;
if (copy_from_user(hss, (char *)arg, sizeof(*hss))) {
- OBD_FREE_PTR(hss);
+ kfree(hss);
return -EFAULT;
}
rc = ll_hsm_state_set(inode, hss);
- OBD_FREE_PTR(hss);
+ kfree(hss);
return rc;
}
case LL_IOC_HSM_ACTION: {
@@ -2394,7 +2387,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
op_data = ll_prep_md_op_data(NULL, inode, NULL, NULL, 0, 0,
LUSTRE_OPC_ANY, hca);
if (IS_ERR(op_data)) {
- OBD_FREE_PTR(hca);
+ kfree(hca);
return PTR_ERR(op_data);
}
@@ -2405,7 +2398,7 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
rc = -EFAULT;
ll_finish_md_op_data(op_data);
- OBD_FREE_PTR(hca);
+ kfree(hca);
return rc;
}
case LL_IOC_SET_LEASE: {
@@ -2500,13 +2493,13 @@ ll_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
return -ENOMEM;
if (copy_from_user(hui, (void *)arg, sizeof(*hui))) {
- OBD_FREE_PTR(hui);
+ kfree(hui);
return -EFAULT;
}
rc = ll_hsm_import(inode, file, hui);
- OBD_FREE_PTR(hui);
+ kfree(hui);
return rc;
}
default: {
@@ -3246,12 +3239,10 @@ void ll_iocontrol_unregister(void *magic)
down_write(&llioc.ioc_sem);
list_for_each_entry(tmp, &llioc.ioc_head, iocd_list) {
if (tmp == magic) {
- unsigned int size = tmp->iocd_size;
-
list_del(&tmp->iocd_list);
up_write(&llioc.ioc_sem);
- OBD_FREE(tmp, size);
+ kfree(tmp);
return;
}
}
@@ -3619,6 +3610,6 @@ int ll_layout_restore(struct inode *inode)
hur->hur_request.hr_itemcount = 1;
rc = obd_iocontrol(LL_IOC_HSM_REQUEST, cl_i2sbi(inode)->ll_md_exp,
len, hur, NULL);
- OBD_FREE(hur, len);
+ kfree(hur);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/llite/llite_close.c b/drivers/staging/lustre/lustre/llite/llite_close.c
index a94ba02ccf02ea..7bdae723fedde6 100644
--- a/drivers/staging/lustre/lustre/llite/llite_close.c
+++ b/drivers/staging/lustre/lustre/llite/llite_close.c
@@ -305,7 +305,7 @@ out:
ll_finish_md_op_data(op_data);
if (och) {
md_clear_open_replay_data(ll_i2sbi(inode)->ll_md_exp, och);
- OBD_FREE_PTR(och);
+ kfree(och);
}
}
@@ -374,7 +374,7 @@ int ll_close_thread_start(struct ll_close_queue **lcq_ret)
task = kthread_run(ll_close_thread, lcq, "ll_close");
if (IS_ERR(task)) {
- OBD_FREE(lcq, sizeof(*lcq));
+ kfree(lcq);
return PTR_ERR(task);
}
@@ -389,5 +389,5 @@ void ll_close_thread_shutdown(struct ll_close_queue *lcq)
atomic_inc(&lcq->lcq_stop);
wake_up(&lcq->lcq_waitq);
wait_for_completion(&lcq->lcq_comp);
- OBD_FREE(lcq, sizeof(*lcq));
+ kfree(lcq);
}
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 528af9011653d1..f097d4d167d525 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -465,7 +465,7 @@ struct ll_sb_info {
struct obd_uuid ll_sb_uuid;
struct obd_export *ll_md_exp;
struct obd_export *ll_dt_exp;
- struct proc_dir_entry* ll_proc_root;
+ struct dentry *ll_debugfs_entry;
struct lu_fid ll_root_fid; /* root object fid */
int ll_flags;
@@ -487,9 +487,6 @@ struct ll_sb_info {
unsigned int ll_namelen;
struct file_operations *ll_fop;
- /* =0 - hold lock over whole read/write
- * >0 - max. chunk to be read/written w/o lock re-acquiring */
- unsigned long ll_max_rw_chunk;
unsigned int ll_md_brw_size; /* used by readdir */
struct lu_site *ll_site;
@@ -518,10 +515,11 @@ struct ll_sb_info {
struct rmtacl_ctl_table ll_rct;
struct eacl_table ll_et;
__kernel_fsid_t ll_fsid;
+ struct kobject ll_kobj; /* sysfs object */
+ struct super_block *ll_sb; /* struct super_block (for sysfs code)*/
+ struct completion ll_kobj_unregister;
};
-#define LL_DEFAULT_MAX_RW_CHUNK (32 * 1024 * 1024)
-
struct ll_ra_read {
pgoff_t lrr_start;
pgoff_t lrr_count;
@@ -638,7 +636,8 @@ struct lov_stripe_md;
extern spinlock_t inode_lock;
-extern struct proc_dir_entry *proc_lustre_fs_root;
+extern struct dentry *llite_root;
+extern struct kset *llite_kset;
static inline struct inode *ll_info2i(struct ll_inode_info *lli)
{
@@ -664,30 +663,14 @@ void ll_ra_read_ex(struct file *f, struct ll_ra_read *rar);
struct ll_ra_read *ll_ra_read_get(struct file *f);
/* llite/lproc_llite.c */
-#if defined (CONFIG_PROC_FS)
-int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
- struct super_block *sb, char *osc, char *mdc);
-void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi);
+int ldebugfs_register_mountpoint(struct dentry *parent,
+ struct super_block *sb, char *osc, char *mdc);
+void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi);
void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count);
void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars);
void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
struct ll_file_data *file, loff_t pos,
size_t count, int rw);
-#else
-static inline int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
- struct super_block *sb, char *osc, char *mdc){return 0;}
-static inline void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi) {}
-static inline
-void ll_stats_ops_tally(struct ll_sb_info *sbi, int op, int count) {}
-static inline void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-static inline void ll_rw_stats_tally(struct ll_sb_info *sbi, pid_t pid,
- struct ll_file_data *file, loff_t pos,
- size_t count, int rw) {}
-#endif
-
/* llite/dir.c */
void ll_release_page(struct page *page, int remove);
@@ -721,11 +704,7 @@ int ll_readahead(const struct lu_env *env, struct cl_io *io,
struct ll_readahead_state *ras, struct address_space *mapping,
struct cl_page_list *queue, int flags);
-#ifndef MS_HAS_NEW_AOPS
extern const struct address_space_operations ll_aops;
-#else
-extern const struct address_space_operations_ext ll_aops;
-#endif
/* llite/file.c */
extern struct file_operations ll_file_operations;
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c b/drivers/staging/lustre/lustre/llite/llite_lib.c
index a27af7882170f4..25139885b5a769 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -57,7 +57,8 @@
#include "llite_internal.h"
struct kmem_cache *ll_file_data_slab;
-struct proc_dir_entry *proc_lustre_fs_root;
+struct dentry *llite_root;
+struct kset *llite_kset;
static LIST_HEAD(ll_super_blocks);
static DEFINE_SPINLOCK(ll_sb_lock);
@@ -66,7 +67,7 @@ static DEFINE_SPINLOCK(ll_sb_lock);
#define log2(n) ffz(~(n))
#endif
-static struct ll_sb_info *ll_init_sbi(void)
+static struct ll_sb_info *ll_init_sbi(struct super_block *sb)
{
struct ll_sb_info *sbi = NULL;
unsigned long pages;
@@ -134,6 +135,8 @@ static struct ll_sb_info *ll_init_sbi(void)
atomic_set(&sbi->ll_agl_total, 0);
sbi->ll_flags |= LL_SBI_AGL_ENABLED;
+ sbi->ll_sb = sb;
+
return sbi;
}
@@ -145,7 +148,7 @@ static void ll_free_sbi(struct super_block *sb)
spin_lock(&ll_sb_lock);
list_del(&sbi->ll_list);
spin_unlock(&ll_sb_lock);
- OBD_FREE(sbi, sizeof(*sbi));
+ kfree(sbi);
}
}
@@ -177,15 +180,14 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
osfs = kzalloc(sizeof(*osfs), GFP_NOFS);
if (!osfs) {
- OBD_FREE_PTR(data);
+ kfree(data);
return -ENOMEM;
}
- if (proc_lustre_fs_root) {
- err = lprocfs_register_mountpoint(proc_lustre_fs_root, sb,
- dt, md);
+ if (llite_root != NULL) {
+ err = ldebugfs_register_mountpoint(llite_root, sb, dt, md);
if (err < 0)
- CERROR("could not register mount in /proc/fs/lustre\n");
+ CERROR("could not register mount in <debugfs>/lustre/llite\n");
}
/* indicate the features supported by this client */
@@ -227,14 +229,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (sbi->ll_flags & LL_SBI_USER_XATTR)
data->ocd_connect_flags |= OBD_CONNECT_XATTR;
-#ifdef HAVE_MS_FLOCK_LOCK
- /* force vfs to use lustre handler for flock() calls - bug 10743 */
- sb->s_flags |= MS_FLOCK_LOCK;
-#endif
-#ifdef MS_HAS_NEW_AOPS
- sb->s_flags |= MS_HAS_NEW_AOPS;
-#endif
-
if (sbi->ll_flags & LL_SBI_FLOCK)
sbi->ll_fop = &ll_file_operations_flock;
else if (sbi->ll_flags & LL_SBI_LOCALFLOCK)
@@ -292,11 +286,15 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
char *buf;
buf = kzalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
+ if (!buf) {
+ err = -ENOMEM;
+ goto out_md_fid;
+ }
obd_connect_flags2str(buf, PAGE_CACHE_SIZE,
valid ^ CLIENT_CONNECT_MDT_REQD, ",");
LCONSOLE_ERROR_MSG(0x170, "Server %s does not support feature(s) needed for correct operation of this client (%s). Please upgrade server or downgrade client.\n",
sbi->ll_md_exp->exp_obd->obd_name, buf);
- OBD_FREE(buf, PAGE_CACHE_SIZE);
+ kfree(buf);
err = -EPROTO;
goto out_md_fid;
}
@@ -316,7 +314,6 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
sb->s_magic = LL_SUPER_MAGIC;
sb->s_maxbytes = MAX_LFS_FILESIZE;
sbi->ll_namelen = osfs->os_namelen;
- sbi->ll_max_rw_chunk = LL_DEFAULT_MAX_RW_CHUNK;
if ((sbi->ll_flags & LL_SBI_USER_XATTR) &&
!(data->ocd_connect_flags & OBD_CONNECT_XATTR)) {
@@ -408,7 +405,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
if (!OBD_FAIL_CHECK(OBD_FAIL_OSC_CONNECT_CKSUM)) {
/* OBD_CONNECT_CKSUM should always be set, even if checksums are
* disabled by default, because it can still be enabled on the
- * fly via /proc. As a consequence, we still need to come to an
+ * fly via /sys. As a consequence, we still need to come to an
* agreement on the supported algorithms at connect time */
data->ocd_connect_flags |= OBD_CONNECT_CKSUM;
@@ -501,7 +498,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
err = md_getattr(sbi->ll_md_exp, op_data, &request);
if (oc)
capa_put(oc);
- OBD_FREE_PTR(op_data);
+ kfree(op_data);
if (err) {
CERROR("%s: md_getattr failed for root: rc = %d\n",
sbi->ll_md_exp->exp_obd->obd_name, err);
@@ -582,10 +579,8 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt,
get_uuid2fsid(uuid->uuid, strlen(uuid->uuid), &sbi->ll_fsid);
}
- if (data != NULL)
- OBD_FREE_PTR(data);
- if (osfs != NULL)
- OBD_FREE_PTR(osfs);
+ kfree(data);
+ kfree(osfs);
return err;
out_root:
@@ -603,11 +598,9 @@ out_md:
obd_disconnect(sbi->ll_md_exp);
sbi->ll_md_exp = NULL;
out:
- if (data != NULL)
- OBD_FREE_PTR(data);
- if (osfs != NULL)
- OBD_FREE_PTR(osfs);
- lprocfs_unregister_mountpoint(sbi);
+ kfree(data);
+ kfree(osfs);
+ ldebugfs_unregister_mountpoint(sbi);
return err;
}
@@ -688,7 +681,7 @@ static void client_common_put_super(struct super_block *sb)
* see LU-2543. */
obd_zombie_barrier();
- lprocfs_unregister_mountpoint(sbi);
+ ldebugfs_unregister_mountpoint(sbi);
obd_fid_fini(sbi->ll_md_exp->exp_obd);
obd_disconnect(sbi->ll_md_exp);
@@ -916,8 +909,6 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
char *dt = NULL, *md = NULL;
char *profilenm = get_profile_name(sb);
struct config_llog_instance *cfg;
- /* %p for void* in printf needs 16+2 characters: 0xffffffffffffffff */
- const int instlen = sizeof(cfg->cfg_instance) * 2 + 2;
int err;
CDEBUG(D_VFSTRACE, "VFS Op: sb %p\n", sb);
@@ -929,10 +920,10 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
try_module_get(THIS_MODULE);
/* client additional sb info */
- lsi->lsi_llsbi = sbi = ll_init_sbi();
+ lsi->lsi_llsbi = sbi = ll_init_sbi(sb);
if (!sbi) {
module_put(THIS_MODULE);
- OBD_FREE_PTR(cfg);
+ kfree(cfg);
return -ENOMEM;
}
@@ -993,16 +984,14 @@ int ll_fill_super(struct super_block *sb, struct vfsmount *mnt)
err = client_common_fill_super(sb, md, dt, mnt);
out_free:
- if (md)
- OBD_FREE(md, strlen(lprof->lp_md) + instlen + 2);
- if (dt)
- OBD_FREE(dt, strlen(lprof->lp_dt) + instlen + 2);
+ kfree(md);
+ kfree(dt);
if (err)
ll_put_super(sb);
else if (sbi->ll_flags & LL_SBI_VERBOSE)
LCONSOLE_WARN("Mounted %s\n", profilenm);
- OBD_FREE_PTR(cfg);
+ kfree(cfg);
return err;
} /* ll_fill_super */
@@ -1126,8 +1115,7 @@ void ll_clear_inode(struct inode *inode)
ll_md_real_close(inode, FMODE_READ);
if (S_ISLNK(inode->i_mode) && lli->lli_symlink_name) {
- OBD_FREE(lli->lli_symlink_name,
- strlen(lli->lli_symlink_name) + 1);
+ kfree(lli->lli_symlink_name);
lli->lli_symlink_name = NULL;
}
@@ -1957,7 +1945,7 @@ void ll_umount_begin(struct super_block *sb)
obd_iocontrol(IOC_OSC_SET_ACTIVE, sbi->ll_dt_exp,
sizeof(*ioc_data), ioc_data, NULL);
- OBD_FREE_PTR(ioc_data);
+ kfree(ioc_data);
}
/* Really, we'd like to wait until there are no requests outstanding,
@@ -2236,7 +2224,7 @@ void ll_finish_md_op_data(struct md_op_data *op_data)
{
capa_put(op_data->op_capa1);
capa_put(op_data->op_capa2);
- OBD_FREE_PTR(op_data);
+ kfree(op_data);
}
int ll_show_options(struct seq_file *seq, struct dentry *dentry)
diff --git a/drivers/staging/lustre/lustre/llite/llite_nfs.c b/drivers/staging/lustre/lustre/llite/llite_nfs.c
index db43b81386f7ae..8d1c253d4669b3 100644
--- a/drivers/staging/lustre/lustre/llite/llite_nfs.c
+++ b/drivers/staging/lustre/lustre/llite/llite_nfs.c
@@ -116,7 +116,7 @@ struct inode *search_inode_for_lustre(struct super_block *sb,
/* mds_fid2dentry ignores f_type */
rc = md_getattr(sbi->ll_md_exp, op_data, &req);
- OBD_FREE_PTR(op_data);
+ kfree(op_data);
if (rc) {
CERROR("can't get object attrs, fid "DFID", rc %d\n",
PFID(fid), rc);
diff --git a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c
index f4da156f387492..c8a450b5cb180b 100644
--- a/drivers/staging/lustre/lustre/llite/llite_rmtacl.c
+++ b/drivers/staging/lustre/lustre/llite/llite_rmtacl.c
@@ -94,7 +94,7 @@ static void rce_free(struct rmtacl_ctl_entry *rce)
if (!list_empty(&rce->rce_list))
list_del(&rce->rce_list);
- OBD_FREE_PTR(rce);
+ kfree(rce);
}
static struct rmtacl_ctl_entry *__rct_search(struct rmtacl_ctl_table *rct,
@@ -205,7 +205,7 @@ void ee_free(struct eacl_entry *ee)
if (ee->ee_acl)
lustre_ext_acl_xattr_free(ee->ee_acl);
- OBD_FREE_PTR(ee);
+ kfree(ee);
}
static struct eacl_entry *__et_search_del(struct eacl_table *et, pid_t key,
diff --git a/drivers/staging/lustre/lustre/llite/lloop.c b/drivers/staging/lustre/lustre/llite/lloop.c
index 413a8408e3f5b9..cc00fd10fbcf77 100644
--- a/drivers/staging/lustre/lustre/llite/lloop.c
+++ b/drivers/staging/lustre/lustre/llite/lloop.c
@@ -840,9 +840,9 @@ out_mem4:
out_mem3:
while (i--)
put_disk(disks[i]);
- OBD_FREE(disks, max_loop * sizeof(*disks));
+ kfree(disks);
out_mem2:
- OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev));
+ kfree(loop_dev);
out_mem1:
unregister_blkdev(lloop_major, "lloop");
ll_iocontrol_unregister(ll_iocontrol_magic);
@@ -863,8 +863,8 @@ static void lloop_exit(void)
unregister_blkdev(lloop_major, "lloop");
- OBD_FREE(disks, max_loop * sizeof(*disks));
- OBD_FREE(loop_dev, max_loop * sizeof(*loop_dev));
+ kfree(disks);
+ kfree(loop_dev);
}
module_init(lloop_init);
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 83a9b85474e129..486dca6077de2e 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -48,31 +48,33 @@ static struct file_operations ll_rw_extents_stats_fops;
static struct file_operations ll_rw_extents_stats_pp_fops;
static struct file_operations ll_rw_offset_stats_fops;
-static int ll_blksize_seq_show(struct seq_file *m, void *v)
+static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%u\n", osfs.os_bsize);
+ return sprintf(buf, "%u\n", osfs.os_bsize);
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_blksize);
+LUSTRE_RO_ATTR(blocksize);
-static int ll_kbytestotal_seq_show(struct seq_file *m, void *v)
+static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
@@ -82,21 +84,22 @@ static int ll_kbytestotal_seq_show(struct seq_file *m, void *v)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ rc = sprintf(buf, "%llu\n", result);
}
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_kbytestotal);
+LUSTRE_RO_ATTR(kbytestotal);
-static int ll_kbytesfree_seq_show(struct seq_file *m, void *v)
+static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
@@ -106,21 +109,22 @@ static int ll_kbytesfree_seq_show(struct seq_file *m, void *v)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ rc = sprintf(buf, "%llu\n", result);
}
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_kbytesfree);
+LUSTRE_RO_ATTR(kbytesfree);
-static int ll_kbytesavail_seq_show(struct seq_file *m, void *v)
+static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc) {
@@ -130,81 +134,79 @@ static int ll_kbytesavail_seq_show(struct seq_file *m, void *v)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ rc = sprintf(buf, "%llu\n", result);
}
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_kbytesavail);
+LUSTRE_RO_ATTR(kbytesavail);
-static int ll_filestotal_seq_show(struct seq_file *m, void *v)
+static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%llu\n", osfs.os_files);
+ return sprintf(buf, "%llu\n", osfs.os_files);
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_filestotal);
+LUSTRE_RO_ATTR(filestotal);
-static int ll_filesfree_seq_show(struct seq_file *m, void *v)
+static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
struct obd_statfs osfs;
int rc;
- LASSERT(sb != NULL);
- rc = ll_statfs_internal(sb, &osfs,
+ rc = ll_statfs_internal(sbi->ll_sb, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%llu\n", osfs.os_ffree);
+ return sprintf(buf, "%llu\n", osfs.os_ffree);
return rc;
}
-LPROC_SEQ_FOPS_RO(ll_filesfree);
+LUSTRE_RO_ATTR(filesfree);
-static int ll_client_type_seq_show(struct seq_file *m, void *v)
+static ssize_t client_type_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ll_sb_info *sbi = ll_s2sbi((struct super_block *)m->private);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- LASSERT(sbi != NULL);
-
- if (sbi->ll_flags & LL_SBI_RMT_CLIENT)
- seq_puts(m, "remote client\n");
- else
- seq_puts(m, "local client\n");
-
- return 0;
+ return sprintf(buf, "%s client\n",
+ sbi->ll_flags & LL_SBI_RMT_CLIENT ? "remote" : "local");
}
-LPROC_SEQ_FOPS_RO(ll_client_type);
+LUSTRE_RO_ATTR(client_type);
-static int ll_fstype_seq_show(struct seq_file *m, void *v)
+static ssize_t fstype_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- LASSERT(sb != NULL);
- seq_printf(m, "%s\n", sb->s_type->name);
- return 0;
+ return sprintf(buf, "%s\n", sbi->ll_sb->s_type->name);
}
-LPROC_SEQ_FOPS_RO(ll_fstype);
+LUSTRE_RO_ATTR(fstype);
-static int ll_sb_uuid_seq_show(struct seq_file *m, void *v)
+static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = (struct super_block *)m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- LASSERT(sb != NULL);
- seq_printf(m, "%s\n", ll_s2sbi(sb)->ll_sb_uuid.uuid);
- return 0;
+ return sprintf(buf, "%s\n", sbi->ll_sb_uuid.uuid);
}
-LPROC_SEQ_FOPS_RO(ll_sb_uuid);
+LUSTRE_RO_ATTR(uuid);
static int ll_site_stats_seq_show(struct seq_file *m, void *v)
{
@@ -218,10 +220,11 @@ static int ll_site_stats_seq_show(struct seq_file *m, void *v)
}
LPROC_SEQ_FOPS_RO(ll_site_stats);
-static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v)
+static ssize_t max_read_ahead_mb_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
long pages_number;
int mult;
@@ -230,23 +233,27 @@ static int ll_max_readahead_mb_seq_show(struct seq_file *m, void *v)
spin_unlock(&sbi->ll_lock);
mult = 1 << (20 - PAGE_CACHE_SHIFT);
- return lprocfs_seq_read_frac_helper(m, pages_number, mult);
+ return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult);
}
-static ssize_t ll_max_readahead_mb_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_read_ahead_mb_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int mult, rc, pages_number;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long pages_number;
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
- rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+ rc = kstrtoul(buffer, 10, &pages_number);
if (rc)
return rc;
- if (pages_number < 0 || pages_number > totalram_pages / 2) {
+ pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */
+
+ if (pages_number > totalram_pages / 2) {
+
CERROR("can't set file readahead more than %lu MB\n",
totalram_pages >> (20 - PAGE_CACHE_SHIFT + 1)); /*1/2 of RAM*/
return -ERANGE;
@@ -258,12 +265,14 @@ static ssize_t ll_max_readahead_mb_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_max_readahead_mb);
+LUSTRE_RW_ATTR(max_read_ahead_mb);
-static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v)
+static ssize_t max_read_ahead_per_file_mb_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
long pages_number;
int mult;
@@ -272,24 +281,24 @@ static int ll_max_readahead_per_file_mb_seq_show(struct seq_file *m, void *v)
spin_unlock(&sbi->ll_lock);
mult = 1 << (20 - PAGE_CACHE_SHIFT);
- return lprocfs_seq_read_frac_helper(m, pages_number, mult);
+ return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult);
}
-static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_read_ahead_per_file_mb_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int mult, rc, pages_number;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long pages_number;
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
- rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+ rc = kstrtoul(buffer, 10, &pages_number);
if (rc)
return rc;
- if (pages_number < 0 ||
- pages_number > sbi->ll_ra_info.ra_max_pages) {
+ if (pages_number > sbi->ll_ra_info.ra_max_pages) {
CERROR("can't set file readahead more than max_read_ahead_mb %lu MB\n",
sbi->ll_ra_info.ra_max_pages);
return -ERANGE;
@@ -301,12 +310,14 @@ static ssize_t ll_max_readahead_per_file_mb_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_max_readahead_per_file_mb);
+LUSTRE_RW_ATTR(max_read_ahead_per_file_mb);
-static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused)
+static ssize_t max_read_ahead_whole_mb_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
long pages_number;
int mult;
@@ -315,26 +326,26 @@ static int ll_max_read_ahead_whole_mb_seq_show(struct seq_file *m, void *unused)
spin_unlock(&sbi->ll_lock);
mult = 1 << (20 - PAGE_CACHE_SHIFT);
- return lprocfs_seq_read_frac_helper(m, pages_number, mult);
+ return lprocfs_read_frac_helper(buf, PAGE_SIZE, pages_number, mult);
}
-static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_read_ahead_whole_mb_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int mult, rc, pages_number;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long pages_number;
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
- rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+ rc = kstrtoul(buffer, 10, &pages_number);
if (rc)
return rc;
/* Cap this at the current max readahead window size, the readahead
* algorithm does this anyway so it's pointless to set it larger. */
- if (pages_number < 0 ||
- pages_number > sbi->ll_ra_info.ra_max_pages_per_file) {
+ if (pages_number > sbi->ll_ra_info.ra_max_pages_per_file) {
CERROR("can't set max_read_ahead_whole_mb more than max_read_ahead_per_file_mb: %lu\n",
sbi->ll_ra_info.ra_max_pages_per_file >> (20 - PAGE_CACHE_SHIFT));
return -ERANGE;
@@ -346,7 +357,7 @@ static ssize_t ll_max_read_ahead_whole_mb_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_max_read_ahead_whole_mb);
+LUSTRE_RW_ATTR(max_read_ahead_whole_mb);
static int ll_max_cached_mb_seq_show(struct seq_file *m, void *v)
{
@@ -469,28 +480,30 @@ out:
}
LPROC_SEQ_FOPS(ll_max_cached_mb);
-static int ll_checksum_seq_show(struct seq_file *m, void *v)
+static ssize_t checksum_pages_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
- return 0;
+ return sprintf(buf, "%u\n", (sbi->ll_flags & LL_SBI_CHECKSUM) ? 1 : 0);
}
-static ssize_t ll_checksum_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t checksum_pages_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
if (!sbi->ll_dt_exp)
/* Not set up yet */
return -EAGAIN;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
if (val)
@@ -505,154 +518,146 @@ static ssize_t ll_checksum_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_checksum);
-
-static int ll_max_rw_chunk_seq_show(struct seq_file *m, void *v)
-{
- struct super_block *sb = m->private;
-
- seq_printf(m, "%lu\n", ll_s2sbi(sb)->ll_max_rw_chunk);
- return 0;
-}
-
-static ssize_t ll_max_rw_chunk_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
-{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- int rc, val;
-
- rc = lprocfs_write_helper(buffer, count, &val);
- if (rc)
- return rc;
- ll_s2sbi(sb)->ll_max_rw_chunk = val;
- return count;
-}
-LPROC_SEQ_FOPS(ll_max_rw_chunk);
+LUSTRE_RW_ATTR(checksum_pages);
-static int ll_rd_track_id(struct seq_file *m, enum stats_track_type type)
+static ssize_t ll_rd_track_id(struct kobject *kobj, char *buf,
+ enum stats_track_type type)
{
- struct super_block *sb = m->private;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- if (ll_s2sbi(sb)->ll_stats_track_type == type)
- seq_printf(m, "%d\n", ll_s2sbi(sb)->ll_stats_track_id);
- else if (ll_s2sbi(sb)->ll_stats_track_type == STATS_TRACK_ALL)
- seq_puts(m, "0 (all)\n");
+ if (sbi->ll_stats_track_type == type)
+ return sprintf(buf, "%d\n", sbi->ll_stats_track_id);
+ else if (sbi->ll_stats_track_type == STATS_TRACK_ALL)
+ return sprintf(buf, "0 (all)\n");
else
- seq_puts(m, "untracked\n");
-
- return 0;
+ return sprintf(buf, "untracked\n");
}
-static int ll_wr_track_id(const char __user *buffer, unsigned long count,
- void *data, enum stats_track_type type)
+static ssize_t ll_wr_track_id(struct kobject *kobj, const char *buffer,
+ size_t count,
+ enum stats_track_type type)
{
- struct super_block *sb = data;
- int rc, pid;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long pid;
- rc = lprocfs_write_helper(buffer, count, &pid);
+ rc = kstrtoul(buffer, 10, &pid);
if (rc)
return rc;
- ll_s2sbi(sb)->ll_stats_track_id = pid;
+ sbi->ll_stats_track_id = pid;
if (pid == 0)
- ll_s2sbi(sb)->ll_stats_track_type = STATS_TRACK_ALL;
+ sbi->ll_stats_track_type = STATS_TRACK_ALL;
else
- ll_s2sbi(sb)->ll_stats_track_type = type;
- lprocfs_clear_stats(ll_s2sbi(sb)->ll_stats);
+ sbi->ll_stats_track_type = type;
+ lprocfs_clear_stats(sbi->ll_stats);
return count;
}
-static int ll_track_pid_seq_show(struct seq_file *m, void *v)
+static ssize_t stats_track_pid_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return ll_rd_track_id(m, STATS_TRACK_PID);
+ return ll_rd_track_id(kobj, buf, STATS_TRACK_PID);
}
-static ssize_t ll_track_pid_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t stats_track_pid_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *seq = file->private_data;
- return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PID);
+ return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_PID);
}
-LPROC_SEQ_FOPS(ll_track_pid);
+LUSTRE_RW_ATTR(stats_track_pid);
-static int ll_track_ppid_seq_show(struct seq_file *m, void *v)
+static ssize_t stats_track_ppid_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return ll_rd_track_id(m, STATS_TRACK_PPID);
+ return ll_rd_track_id(kobj, buf, STATS_TRACK_PPID);
}
-static ssize_t ll_track_ppid_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t stats_track_ppid_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *seq = file->private_data;
- return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_PPID);
+ return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_PPID);
}
-LPROC_SEQ_FOPS(ll_track_ppid);
+LUSTRE_RW_ATTR(stats_track_ppid);
-static int ll_track_gid_seq_show(struct seq_file *m, void *v)
+static ssize_t stats_track_gid_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return ll_rd_track_id(m, STATS_TRACK_GID);
+ return ll_rd_track_id(kobj, buf, STATS_TRACK_GID);
}
-static ssize_t ll_track_gid_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t stats_track_gid_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *seq = file->private_data;
- return ll_wr_track_id(buffer, count, seq->private, STATS_TRACK_GID);
+ return ll_wr_track_id(kobj, buffer, count, STATS_TRACK_GID);
}
-LPROC_SEQ_FOPS(ll_track_gid);
+LUSTRE_RW_ATTR(stats_track_gid);
-static int ll_statahead_max_seq_show(struct seq_file *m, void *v)
+static ssize_t statahead_max_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", sbi->ll_sa_max);
- return 0;
+ return sprintf(buf, "%u\n", sbi->ll_sa_max);
}
-static ssize_t ll_statahead_max_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t statahead_max_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
- if (val >= 0 && val <= LL_SA_RPC_MAX)
+ if (val <= LL_SA_RPC_MAX)
sbi->ll_sa_max = val;
else
- CERROR("Bad statahead_max value %d. Valid values are in the range [0, %d]\n",
+ CERROR("Bad statahead_max value %lu. Valid values are in the range [0, %d]\n",
val, LL_SA_RPC_MAX);
return count;
}
-LPROC_SEQ_FOPS(ll_statahead_max);
+LUSTRE_RW_ATTR(statahead_max);
-static int ll_statahead_agl_seq_show(struct seq_file *m, void *v)
+static ssize_t statahead_agl_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0);
- return 0;
+ return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_AGL_ENABLED ? 1 : 0);
}
-static ssize_t ll_statahead_agl_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t statahead_agl_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -663,7 +668,7 @@ static ssize_t ll_statahead_agl_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_statahead_agl);
+LUSTRE_RW_ATTR(statahead_agl);
static int ll_statahead_stats_seq_show(struct seq_file *m, void *v)
{
@@ -681,24 +686,27 @@ static int ll_statahead_stats_seq_show(struct seq_file *m, void *v)
}
LPROC_SEQ_FOPS_RO(ll_statahead_stats);
-static int ll_lazystatfs_seq_show(struct seq_file *m, void *v)
+static ssize_t lazystatfs_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0);
- return 0;
+ return sprintf(buf, "%u\n", sbi->ll_flags & LL_SBI_LAZYSTATFS ? 1 : 0);
}
-static ssize_t ll_lazystatfs_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t lazystatfs_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct super_block *sb = ((struct seq_file *)file->private_data)->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -709,12 +717,14 @@ static ssize_t ll_lazystatfs_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_lazystatfs);
+LUSTRE_RW_ATTR(lazystatfs);
-static int ll_max_easize_seq_show(struct seq_file *m, void *v)
+static ssize_t max_easize_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
unsigned int ealen;
int rc;
@@ -722,15 +732,16 @@ static int ll_max_easize_seq_show(struct seq_file *m, void *v)
if (rc)
return rc;
- seq_printf(m, "%u\n", ealen);
- return 0;
+ return sprintf(buf, "%u\n", ealen);
}
-LPROC_SEQ_FOPS_RO(ll_max_easize);
+LUSTRE_RO_ATTR(max_easize);
-static int ll_default_easize_seq_show(struct seq_file *m, void *v)
+static ssize_t default_easize_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
unsigned int ealen;
int rc;
@@ -738,42 +749,9 @@ static int ll_default_easize_seq_show(struct seq_file *m, void *v)
if (rc)
return rc;
- seq_printf(m, "%u\n", ealen);
- return 0;
-}
-LPROC_SEQ_FOPS_RO(ll_default_easize);
-
-static int ll_max_cookiesize_seq_show(struct seq_file *m, void *v)
-{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- unsigned int cookielen;
- int rc;
-
- rc = ll_get_max_cookiesize(sbi, &cookielen);
- if (rc)
- return rc;
-
- seq_printf(m, "%u\n", cookielen);
- return 0;
-}
-LPROC_SEQ_FOPS_RO(ll_max_cookiesize);
-
-static int ll_default_cookiesize_seq_show(struct seq_file *m, void *v)
-{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- unsigned int cookielen;
- int rc;
-
- rc = ll_get_default_cookiesize(sbi, &cookielen);
- if (rc)
- return rc;
-
- seq_printf(m, "%u\n", cookielen);
- return 0;
+ return sprintf(buf, "%u\n", ealen);
}
-LPROC_SEQ_FOPS_RO(ll_default_cookiesize);
+LUSTRE_RO_ATTR(default_easize);
static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
{
@@ -799,26 +777,27 @@ static int ll_sbi_flags_seq_show(struct seq_file *m, void *v)
}
LPROC_SEQ_FOPS_RO(ll_sbi_flags);
-static int ll_xattr_cache_seq_show(struct seq_file *m, void *v)
+static ssize_t xattr_cache_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct super_block *sb = m->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
- seq_printf(m, "%u\n", sbi->ll_xattr_cache_enabled);
-
- return 0;
+ return sprintf(buf, "%u\n", sbi->ll_xattr_cache_enabled);
}
-static ssize_t ll_xattr_cache_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t xattr_cache_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct seq_file *seq = file->private_data;
- struct super_block *sb = seq->private;
- struct ll_sb_info *sbi = ll_s2sbi(sb);
- int val, rc;
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -832,46 +811,59 @@ static ssize_t ll_xattr_cache_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ll_xattr_cache);
+LUSTRE_RW_ATTR(xattr_cache);
static struct lprocfs_vars lprocfs_llite_obd_vars[] = {
- { "uuid", &ll_sb_uuid_fops, NULL, 0 },
/* { "mntpt_path", ll_rd_path, 0, 0 }, */
- { "fstype", &ll_fstype_fops, NULL, 0 },
{ "site", &ll_site_stats_fops, NULL, 0 },
- { "blocksize", &ll_blksize_fops, NULL, 0 },
- { "kbytestotal", &ll_kbytestotal_fops, NULL, 0 },
- { "kbytesfree", &ll_kbytesfree_fops, NULL, 0 },
- { "kbytesavail", &ll_kbytesavail_fops, NULL, 0 },
- { "filestotal", &ll_filestotal_fops, NULL, 0 },
- { "filesfree", &ll_filesfree_fops, NULL, 0 },
- { "client_type", &ll_client_type_fops, NULL, 0 },
/* { "filegroups", lprocfs_rd_filegroups, 0, 0 }, */
- { "max_read_ahead_mb", &ll_max_readahead_mb_fops, NULL },
- { "max_read_ahead_per_file_mb", &ll_max_readahead_per_file_mb_fops,
- NULL },
- { "max_read_ahead_whole_mb", &ll_max_read_ahead_whole_mb_fops, NULL },
{ "max_cached_mb", &ll_max_cached_mb_fops, NULL },
- { "checksum_pages", &ll_checksum_fops, NULL },
- { "max_rw_chunk", &ll_max_rw_chunk_fops, NULL },
- { "stats_track_pid", &ll_track_pid_fops, NULL },
- { "stats_track_ppid", &ll_track_ppid_fops, NULL },
- { "stats_track_gid", &ll_track_gid_fops, NULL },
- { "statahead_max", &ll_statahead_max_fops, NULL },
- { "statahead_agl", &ll_statahead_agl_fops, NULL },
{ "statahead_stats", &ll_statahead_stats_fops, NULL, 0 },
- { "lazystatfs", &ll_lazystatfs_fops, NULL },
- { "max_easize", &ll_max_easize_fops, NULL, 0 },
- { "default_easize", &ll_default_easize_fops, NULL, 0 },
- { "max_cookiesize", &ll_max_cookiesize_fops, NULL, 0 },
- { "default_cookiesize", &ll_default_cookiesize_fops, NULL, 0 },
{ "sbi_flags", &ll_sbi_flags_fops, NULL, 0 },
- { "xattr_cache", &ll_xattr_cache_fops, NULL, 0 },
{ NULL }
};
#define MAX_STRING_SIZE 128
+static struct attribute *llite_attrs[] = {
+ &lustre_attr_blocksize.attr,
+ &lustre_attr_kbytestotal.attr,
+ &lustre_attr_kbytesfree.attr,
+ &lustre_attr_kbytesavail.attr,
+ &lustre_attr_filestotal.attr,
+ &lustre_attr_filesfree.attr,
+ &lustre_attr_client_type.attr,
+ &lustre_attr_fstype.attr,
+ &lustre_attr_uuid.attr,
+ &lustre_attr_max_read_ahead_mb.attr,
+ &lustre_attr_max_read_ahead_per_file_mb.attr,
+ &lustre_attr_max_read_ahead_whole_mb.attr,
+ &lustre_attr_checksum_pages.attr,
+ &lustre_attr_stats_track_pid.attr,
+ &lustre_attr_stats_track_ppid.attr,
+ &lustre_attr_stats_track_gid.attr,
+ &lustre_attr_statahead_max.attr,
+ &lustre_attr_statahead_agl.attr,
+ &lustre_attr_lazystatfs.attr,
+ &lustre_attr_max_easize.attr,
+ &lustre_attr_default_easize.attr,
+ &lustre_attr_xattr_cache.attr,
+ NULL,
+};
+
+static void llite_sb_release(struct kobject *kobj)
+{
+ struct ll_sb_info *sbi = container_of(kobj, struct ll_sb_info,
+ ll_kobj);
+ complete(&sbi->ll_kobj_unregister);
+}
+
+static struct kobj_type llite_ktype = {
+ .default_attrs = llite_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = llite_sb_release,
+};
+
static const struct llite_file_opcode {
__u32 opcode;
__u32 type;
@@ -958,24 +950,18 @@ static const char *ra_stat_string[] = {
[RA_STAT_WRONG_GRAB_PAGE] = "wrong page from grab_cache_page",
};
-LPROC_SEQ_FOPS_RO_TYPE(llite, name);
-LPROC_SEQ_FOPS_RO_TYPE(llite, uuid);
-
-int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
- struct super_block *sb, char *osc, char *mdc)
+int ldebugfs_register_mountpoint(struct dentry *parent,
+ struct super_block *sb, char *osc, char *mdc)
{
- struct lprocfs_vars lvars[2];
struct lustre_sb_info *lsi = s2lsi(sb);
struct ll_sb_info *sbi = ll_s2sbi(sb);
struct obd_device *obd;
- struct proc_dir_entry *dir;
+ struct dentry *dir;
char name[MAX_STRING_SIZE + 1], *ptr;
int err, id, len, rc;
- memset(lvars, 0, sizeof(lvars));
name[MAX_STRING_SIZE] = '\0';
- lvars[0].name = name;
LASSERT(sbi != NULL);
LASSERT(mdc != NULL);
@@ -991,30 +977,32 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
snprintf(name, MAX_STRING_SIZE, "%.*s-%p", len,
lsi->lsi_lmd->lmd_profile, sb);
- sbi->ll_proc_root = lprocfs_register(name, parent, NULL, NULL);
- if (IS_ERR(sbi->ll_proc_root)) {
- err = PTR_ERR(sbi->ll_proc_root);
- sbi->ll_proc_root = NULL;
+ dir = ldebugfs_register(name, parent, NULL, NULL);
+ if (IS_ERR_OR_NULL(dir)) {
+ err = dir ? PTR_ERR(dir) : -ENOMEM;
+ sbi->ll_debugfs_entry = NULL;
return err;
}
+ sbi->ll_debugfs_entry = dir;
- rc = lprocfs_seq_create(sbi->ll_proc_root, "dump_page_cache", 0444,
- &vvp_dump_pgcache_file_ops, sbi);
+ rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "dump_page_cache", 0444,
+ &vvp_dump_pgcache_file_ops, sbi);
if (rc)
CWARN("Error adding the dump_page_cache file\n");
- rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats", 0644,
- &ll_rw_extents_stats_fops, sbi);
+ rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "extents_stats", 0644,
+ &ll_rw_extents_stats_fops, sbi);
if (rc)
CWARN("Error adding the extent_stats file\n");
- rc = lprocfs_seq_create(sbi->ll_proc_root, "extents_stats_per_process",
- 0644, &ll_rw_extents_stats_pp_fops, sbi);
+ rc = ldebugfs_seq_create(sbi->ll_debugfs_entry,
+ "extents_stats_per_process",
+ 0644, &ll_rw_extents_stats_pp_fops, sbi);
if (rc)
CWARN("Error adding the extents_stats_per_process file\n");
- rc = lprocfs_seq_create(sbi->ll_proc_root, "offset_stats", 0644,
- &ll_rw_offset_stats_fops, sbi);
+ rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "offset_stats", 0644,
+ &ll_rw_offset_stats_fops, sbi);
if (rc)
CWARN("Error adding the offset_stats file\n");
@@ -1040,7 +1028,8 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
(type & LPROCFS_CNTR_AVGMINMAX),
llite_opcode_table[id].opname, ptr);
}
- err = lprocfs_register_stats(sbi->ll_proc_root, "stats", sbi->ll_stats);
+ err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "stats",
+ sbi->ll_stats);
if (err)
goto out;
@@ -1054,76 +1043,53 @@ int lprocfs_register_mountpoint(struct proc_dir_entry *parent,
for (id = 0; id < ARRAY_SIZE(ra_stat_string); id++)
lprocfs_counter_init(sbi->ll_ra_stats, id, 0,
ra_stat_string[id], "pages");
- err = lprocfs_register_stats(sbi->ll_proc_root, "read_ahead_stats",
+
+ err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "read_ahead_stats",
sbi->ll_ra_stats);
if (err)
goto out;
- err = lprocfs_add_vars(sbi->ll_proc_root, lprocfs_llite_obd_vars, sb);
+ err = ldebugfs_add_vars(sbi->ll_debugfs_entry,
+ lprocfs_llite_obd_vars, sb);
if (err)
goto out;
- /* MDC info */
- obd = class_name2obd(mdc);
-
- LASSERT(obd != NULL);
- LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(obd->obd_type->typ_name != NULL);
-
- dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root);
- if (dir == NULL) {
- err = -ENOMEM;
- goto out;
- }
-
- snprintf(name, MAX_STRING_SIZE, "common_name");
- lvars[0].fops = &llite_name_fops;
- err = lprocfs_add_vars(dir, lvars, obd);
+ sbi->ll_kobj.kset = llite_kset;
+ init_completion(&sbi->ll_kobj_unregister);
+ err = kobject_init_and_add(&sbi->ll_kobj, &llite_ktype, NULL,
+ "%s", name);
if (err)
goto out;
- snprintf(name, MAX_STRING_SIZE, "uuid");
- lvars[0].fops = &llite_uuid_fops;
- err = lprocfs_add_vars(dir, lvars, obd);
+ /* MDC info */
+ obd = class_name2obd(mdc);
+
+ err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj,
+ obd->obd_type->typ_name);
if (err)
goto out;
/* OSC */
obd = class_name2obd(osc);
- LASSERT(obd != NULL);
- LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(obd->obd_type->typ_name != NULL);
-
- dir = proc_mkdir(obd->obd_type->typ_name, sbi->ll_proc_root);
- if (dir == NULL) {
- err = -ENOMEM;
- goto out;
- }
-
- snprintf(name, MAX_STRING_SIZE, "common_name");
- lvars[0].fops = &llite_name_fops;
- err = lprocfs_add_vars(dir, lvars, obd);
- if (err)
- goto out;
-
- snprintf(name, MAX_STRING_SIZE, "uuid");
- lvars[0].fops = &llite_uuid_fops;
- err = lprocfs_add_vars(dir, lvars, obd);
+ err = sysfs_create_link(&sbi->ll_kobj, &obd->obd_kobj,
+ obd->obd_type->typ_name);
out:
if (err) {
- lprocfs_remove(&sbi->ll_proc_root);
+ ldebugfs_remove(&sbi->ll_debugfs_entry);
lprocfs_free_stats(&sbi->ll_ra_stats);
lprocfs_free_stats(&sbi->ll_stats);
}
return err;
}
-void lprocfs_unregister_mountpoint(struct ll_sb_info *sbi)
+void ldebugfs_unregister_mountpoint(struct ll_sb_info *sbi)
{
- if (sbi->ll_proc_root) {
- lprocfs_remove(&sbi->ll_proc_root);
+ if (sbi->ll_debugfs_entry) {
+ ldebugfs_remove(&sbi->ll_debugfs_entry);
+ kobject_put(&sbi->ll_kobj);
+ wait_for_completion(&sbi->ll_kobj_unregister);
lprocfs_free_stats(&sbi->ll_ra_stats);
lprocfs_free_stats(&sbi->ll_stats);
}
@@ -1531,6 +1497,5 @@ LPROC_SEQ_FOPS(ll_rw_offset_stats);
void lprocfs_llite_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = NULL;
lvars->obd_vars = lprocfs_llite_obd_vars;
}
diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index 5a25dcd10126c1..72ce6e72845fdd 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -665,7 +665,7 @@ static int ll_atomic_open(struct inode *dir, struct dentry *dentry,
out_release:
ll_intent_release(it);
- OBD_FREE(it, sizeof(*it));
+ kfree(it);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/llite/rw26.c b/drivers/staging/lustre/lustre/llite/rw26.c
index c6c824356464c7..7c643130499f86 100644
--- a/drivers/staging/lustre/lustre/llite/rw26.c
+++ b/drivers/staging/lustre/lustre/llite/rw26.c
@@ -517,7 +517,6 @@ static int ll_migratepage(struct address_space *mapping,
}
#endif
-#ifndef MS_HAS_NEW_AOPS
const struct address_space_operations ll_aops = {
.readpage = ll_readpage,
.direct_IO = ll_direct_IO_26,
@@ -532,22 +531,3 @@ const struct address_space_operations ll_aops = {
.migratepage = ll_migratepage,
#endif
};
-#else
-const struct address_space_operations_ext ll_aops = {
- .orig_aops.readpage = ll_readpage,
-/* .orig_aops.readpages = ll_readpages, */
- .orig_aops.direct_IO = ll_direct_IO_26,
- .orig_aops.writepage = ll_writepage,
- .orig_aops.writepages = ll_writepages,
- .orig_aops.set_page_dirty = ll_set_page_dirty,
- .orig_aops.prepare_write = ll_prepare_write,
- .orig_aops.commit_write = ll_commit_write,
- .orig_aops.invalidatepage = ll_invalidatepage,
- .orig_aops.releasepage = ll_releasepage,
-#ifdef CONFIG_MIGRATION
- .orig_aops.migratepage = ll_migratepage,
-#endif
- .write_begin = ll_write_begin,
- .write_end = ll_write_end
-};
-#endif
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 7f8071242f2344..f97371dd8539f6 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -312,7 +312,7 @@ static void ll_sa_entry_cleanup(struct ll_statahead_info *sai,
entry->se_minfo = NULL;
ll_intent_release(&minfo->mi_it);
iput(minfo->mi_dir);
- OBD_FREE_PTR(minfo);
+ kfree(minfo);
}
if (req) {
@@ -336,7 +336,7 @@ static void ll_sa_entry_put(struct ll_statahead_info *sai,
ll_sa_entry_cleanup(sai, entry);
iput(entry->se_inode);
- OBD_FREE(entry, entry->se_size);
+ kfree(entry);
atomic_dec(&sai->sai_cache_count);
}
}
@@ -544,7 +544,7 @@ static void ll_sai_put(struct ll_statahead_info *sai)
LASSERT(agl_list_empty(sai));
iput(inode);
- OBD_FREE_PTR(sai);
+ kfree(sai);
}
}
@@ -772,7 +772,7 @@ out:
if (rc != 0) {
ll_intent_release(it);
iput(dir);
- OBD_FREE_PTR(minfo);
+ kfree(minfo);
}
if (sai != NULL)
ll_sai_put(sai);
@@ -786,8 +786,8 @@ static void sa_args_fini(struct md_enqueue_info *minfo,
iput(minfo->mi_dir);
capa_put(minfo->mi_data.op_capa1);
capa_put(minfo->mi_data.op_capa2);
- OBD_FREE_PTR(minfo);
- OBD_FREE_PTR(einfo);
+ kfree(minfo);
+ kfree(einfo);
}
/**
@@ -816,15 +816,15 @@ static int sa_args_init(struct inode *dir, struct inode *child,
minfo = kzalloc(sizeof(*minfo), GFP_NOFS);
if (!minfo) {
- OBD_FREE_PTR(einfo);
+ kfree(einfo);
return -ENOMEM;
}
op_data = ll_prep_md_op_data(&minfo->mi_data, dir, child, qstr->name,
qstr->len, 0, LUSTRE_OPC_ANY, NULL);
if (IS_ERR(op_data)) {
- OBD_FREE_PTR(einfo);
- OBD_FREE_PTR(minfo);
+ kfree(einfo);
+ kfree(minfo);
return PTR_ERR(op_data);
}
@@ -1719,8 +1719,7 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
return -EAGAIN;
out:
- if (sai != NULL)
- OBD_FREE_PTR(sai);
+ kfree(sai);
spin_lock(&lli->lli_sa_lock);
lli->lli_opendir_key = NULL;
lli->lli_opendir_pid = 0;
diff --git a/drivers/staging/lustre/lustre/llite/super25.c b/drivers/staging/lustre/lustre/llite/super25.c
index a494f6271fa0b6..e4020ce8cb7b85 100644
--- a/drivers/staging/lustre/lustre/llite/super25.c
+++ b/drivers/staging/lustre/lustre/llite/super25.c
@@ -89,7 +89,6 @@ void lustre_register_client_process_config(int (*cpc)(struct lustre_cfg *lcfg));
static int __init init_lustre_lite(void)
{
- struct proc_dir_entry *entry;
lnet_process_id_t lnet_id;
struct timeval tv;
int i, rc, seed[2];
@@ -128,15 +127,18 @@ static int __init init_lustre_lite(void)
if (ll_rmtperm_hash_cachep == NULL)
goto out_cache;
- entry = lprocfs_register("llite", proc_lustre_root, NULL, NULL);
- if (IS_ERR(entry)) {
- rc = PTR_ERR(entry);
- CERROR("cannot register '/proc/fs/lustre/llite': rc = %d\n",
- rc);
+ llite_root = debugfs_create_dir("llite", debugfs_lustre_root);
+ if (IS_ERR_OR_NULL(llite_root)) {
+ rc = llite_root ? PTR_ERR(llite_root) : -ENOMEM;
+ llite_root = NULL;
goto out_cache;
}
- proc_lustre_fs_root = entry;
+ llite_kset = kset_create_and_add("llite", NULL, lustre_kobj);
+ if (!llite_kset) {
+ rc = -ENOMEM;
+ goto out_debugfs;
+ }
cfs_get_random_bytes(seed, sizeof(seed));
@@ -155,7 +157,7 @@ static int __init init_lustre_lite(void)
setup_timer(&ll_capa_timer, ll_capa_timer_callback, 0);
rc = ll_capa_thread_start();
if (rc != 0)
- goto out_proc;
+ goto out_sysfs;
rc = vvp_global_init();
if (rc != 0)
@@ -176,8 +178,10 @@ out_vvp:
out_capa:
del_timer(&ll_capa_timer);
ll_capa_thread_stop();
-out_proc:
- lprocfs_remove(&proc_lustre_fs_root);
+out_sysfs:
+ kset_unregister(llite_kset);
+out_debugfs:
+ debugfs_remove(llite_root);
out_cache:
if (ll_inode_cachep != NULL)
kmem_cache_destroy(ll_inode_cachep);
@@ -200,7 +204,8 @@ static void __exit exit_lustre_lite(void)
lustre_register_kill_super_cb(NULL);
lustre_register_client_process_config(NULL);
- lprocfs_remove(&proc_lustre_fs_root);
+ debugfs_remove(llite_root);
+ kset_unregister(llite_kset);
ll_xattr_fini();
vvp_global_fini();
diff --git a/drivers/staging/lustre/lustre/llite/vvp_dev.c b/drivers/staging/lustre/lustre/llite/vvp_dev.c
index fde41d7c5e3d8e..2aae5f5fa8ea7a 100644
--- a/drivers/staging/lustre/lustre/llite/vvp_dev.c
+++ b/drivers/staging/lustre/lustre/llite/vvp_dev.c
@@ -253,7 +253,7 @@ int cl_sb_fini(struct super_block *sb)
/****************************************************************************
*
- * /proc/fs/lustre/llite/$MNT/dump_page_cache
+ * debugfs/lustre/llite/$MNT/dump_page_cache
*
****************************************************************************/
@@ -526,16 +526,17 @@ static struct seq_operations vvp_pgcache_ops = {
static int vvp_dump_pgcache_seq_open(struct inode *inode, struct file *filp)
{
- struct ll_sb_info *sbi = PDE_DATA(inode);
- struct seq_file *seq;
- int result;
+ struct seq_file *seq;
+ int rc;
- result = seq_open(filp, &vvp_pgcache_ops);
- if (result == 0) {
- seq = filp->private_data;
- seq->private = sbi;
- }
- return result;
+ rc = seq_open(filp, &vvp_pgcache_ops);
+ if (rc)
+ return rc;
+
+ seq = filp->private_data;
+ seq->private = inode->i_private;
+
+ return 0;
}
const struct file_operations vvp_dump_pgcache_file_ops = {
diff --git a/drivers/staging/lustre/lustre/llite/xattr.c b/drivers/staging/lustre/lustre/llite/xattr.c
index e0fcbe1395fd31..362a87d0d0d349 100644
--- a/drivers/staging/lustre/lustre/llite/xattr.c
+++ b/drivers/staging/lustre/lustre/llite/xattr.c
@@ -188,11 +188,11 @@ int ll_setxattr_common(struct inode *inode, const char *name,
valid |= rce_ops2valid(rce->rce_ops);
}
#endif
- oc = ll_mdscapa_get(inode);
- rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
- valid, name, pv, size, 0, flags,
- ll_i2suppgid(inode), &req);
- capa_put(oc);
+ oc = ll_mdscapa_get(inode);
+ rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode), oc,
+ valid, name, pv, size, 0, flags,
+ ll_i2suppgid(inode), &req);
+ capa_put(oc);
#ifdef CONFIG_FS_POSIX_ACL
if (new_value != NULL)
lustre_posix_acl_xattr_free(new_value, size);
diff --git a/drivers/staging/lustre/lustre/llite/xattr_cache.c b/drivers/staging/lustre/lustre/llite/xattr_cache.c
index 69ea92adf4f1ff..6956dec53fcc5d 100644
--- a/drivers/staging/lustre/lustre/llite/xattr_cache.c
+++ b/drivers/staging/lustre/lustre/llite/xattr_cache.c
@@ -144,7 +144,7 @@ static int ll_xattr_cache_add(struct list_head *cache,
return 0;
err_value:
- OBD_FREE(xattr->xe_name, xattr->xe_namelen);
+ kfree(xattr->xe_name);
err_name:
OBD_SLAB_FREE_PTR(xattr, xattr_kmem);
@@ -170,8 +170,8 @@ static int ll_xattr_cache_del(struct list_head *cache,
if (ll_xattr_cache_find(cache, xattr_name, &xattr) == 0) {
list_del(&xattr->xe_list);
- OBD_FREE(xattr->xe_name, xattr->xe_namelen);
- OBD_FREE(xattr->xe_value, xattr->xe_vallen);
+ kfree(xattr->xe_name);
+ kfree(xattr->xe_value);
OBD_SLAB_FREE_PTR(xattr, xattr_kmem);
return 0;
diff --git a/drivers/staging/lustre/lustre/lmv/Makefile b/drivers/staging/lustre/lustre/lmv/Makefile
index a7a15369af1598..1a24299791d79a 100644
--- a/drivers/staging/lustre/lustre/lmv/Makefile
+++ b/drivers/staging/lustre/lustre/lmv/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += lmv.o
-lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o
-lmv-$(CONFIG_PROC_FS) += lproc_lmv.o
+lmv-y := lmv_obd.o lmv_intent.o lmv_fld.o lproc_lmv.o
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_intent.c b/drivers/staging/lustre/lustre/lmv/lmv_intent.c
index d22d57b4ff38d5..cb35f6341fb2d9 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_intent.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_intent.c
@@ -99,7 +99,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
goto out;
}
- OBD_ALLOC_PTR(op_data);
+ op_data = kzalloc(sizeof(*op_data), GFP_NOFS);
if (op_data == NULL) {
rc = -ENOMEM;
goto out;
@@ -142,7 +142,7 @@ static int lmv_intent_remote(struct obd_export *exp, void *lmm,
it->d.lustre.it_lock_mode = pmode;
out_free_op_data:
- OBD_FREE_PTR(op_data);
+ kfree(op_data);
out:
if (rc && pmode)
ldlm_lock_decref(&plock, pmode);
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_internal.h b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
index 852d78721ca9c5..b808728daee7ad 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_internal.h
+++ b/drivers/staging/lustre/lustre/lmv/lmv_internal.h
@@ -144,14 +144,8 @@ struct lmv_tgt_desc
*lmv_locate_mds(struct lmv_obd *lmv, struct md_op_data *op_data,
struct lu_fid *fid);
/* lproc_lmv.c */
-#if defined(CONFIG_PROC_FS)
void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
+
extern struct file_operations lmv_proc_target_fops;
#endif
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index b9459faf8645a6..aca686a2ca10fa 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -199,7 +199,6 @@ static int lmv_connect(const struct lu_env *env,
struct obd_uuid *cluuid, struct obd_connect_data *data,
void *localdata)
{
- struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv;
struct lustre_handle conn = { 0 };
int rc = 0;
@@ -230,19 +229,8 @@ static int lmv_connect(const struct lu_env *env,
if (data)
lmv->conn_data = *data;
- if (obd->obd_proc_private != NULL) {
- lmv_proc_dir = obd->obd_proc_private;
- } else {
- lmv_proc_dir = lprocfs_register("target_obds", obd->obd_proc_entry,
- NULL, NULL);
- if (IS_ERR(lmv_proc_dir)) {
- CERROR("could not register /proc/fs/lustre/%s/%s/target_obds.",
- obd->obd_type->typ_name, obd->obd_name);
- lmv_proc_dir = NULL;
- }
- obd->obd_proc_private = lmv_proc_dir;
- }
-
+ lmv->lmv_tgts_kobj = kobject_create_and_add("target_obds",
+ &obd->obd_kobj);
/*
* All real clients should perform actual connection right away, because
* it is possible, that LMV will not have opportunity to connect targets
@@ -252,10 +240,8 @@ static int lmv_connect(const struct lu_env *env,
if (data->ocd_connect_flags & OBD_CONNECT_REAL)
rc = lmv_check_connect(obd);
- if (rc && lmv_proc_dir) {
- lprocfs_remove(&lmv_proc_dir);
- obd->obd_proc_private = NULL;
- }
+ if (rc && lmv->lmv_tgts_kobj)
+ kobject_put(lmv->lmv_tgts_kobj);
return rc;
}
@@ -337,7 +323,6 @@ static int lmv_init_ea_size(struct obd_export *exp, int easize,
static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
{
- struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv;
struct obd_uuid *cluuid = &lmv->cluuid;
struct obd_uuid lmv_mdc_uuid = { "LMV_MDC_UUID" };
@@ -415,25 +400,10 @@ static int lmv_connect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
mdc_obd->obd_name, mdc_obd->obd_uuid.uuid,
atomic_read(&obd->obd_refcount));
- lmv_proc_dir = obd->obd_proc_private;
- if (lmv_proc_dir) {
- struct proc_dir_entry *mdc_symlink;
-
- LASSERT(mdc_obd->obd_type != NULL);
- LASSERT(mdc_obd->obd_type->typ_name != NULL);
- mdc_symlink = lprocfs_add_symlink(mdc_obd->obd_name,
- lmv_proc_dir,
- "../../../%s/%s",
- mdc_obd->obd_type->typ_name,
- mdc_obd->obd_name);
- if (mdc_symlink == NULL) {
- CERROR("Could not register LMV target /proc/fs/lustre/%s/%s/target_obds/%s.",
- obd->obd_type->typ_name, obd->obd_name,
- mdc_obd->obd_name);
- lprocfs_remove(&lmv_proc_dir);
- obd->obd_proc_private = NULL;
- }
- }
+ if (lmv->lmv_tgts_kobj)
+ /* Even if we failed to create the link, that's fine */
+ rc = sysfs_create_link(lmv->lmv_tgts_kobj, &mdc_obd->obd_kobj,
+ mdc_obd->obd_name);
return 0;
}
@@ -442,7 +412,7 @@ static void lmv_del_target(struct lmv_obd *lmv, int index)
if (lmv->tgts[index] == NULL)
return;
- OBD_FREE_PTR(lmv->tgts[index]);
+ kfree(lmv->tgts[index]);
lmv->tgts[index] = NULL;
return;
}
@@ -488,7 +458,7 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
while (newsize < index + 1)
newsize <<= 1;
- OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
+ newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS);
if (newtgts == NULL) {
lmv_init_unlock(lmv);
return -ENOMEM;
@@ -504,14 +474,13 @@ static int lmv_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
lmv->tgts = newtgts;
lmv->tgts_size = newsize;
smp_rmb();
- if (old)
- OBD_FREE(old, sizeof(*old) * oldsize);
+ kfree(old);
CDEBUG(D_CONFIG, "tgts: %p size: %d\n", lmv->tgts,
lmv->tgts_size);
}
- OBD_ALLOC_PTR(tgt);
+ tgt = kzalloc(sizeof(*tgt), GFP_NOFS);
if (!tgt) {
lmv_init_unlock(lmv);
return -ENOMEM;
@@ -611,7 +580,6 @@ int lmv_check_connect(struct obd_device *obd)
static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
{
- struct proc_dir_entry *lmv_proc_dir;
struct lmv_obd *lmv = &obd->u.lmv;
struct obd_device *mdc_obd;
int rc;
@@ -627,9 +595,9 @@ static int lmv_disconnect_mdc(struct obd_device *obd, struct lmv_tgt_desc *tgt)
mdc_obd->obd_no_recov = obd->obd_no_recov;
}
- lmv_proc_dir = obd->obd_proc_private;
- if (lmv_proc_dir)
- lprocfs_remove_proc_entry(mdc_obd->obd_name, lmv_proc_dir);
+ if (lmv->lmv_tgts_kobj)
+ sysfs_remove_link(lmv->lmv_tgts_kobj,
+ mdc_obd->obd_name);
rc = obd_fid_fini(tgt->ltd_exp->exp_obd);
if (rc)
@@ -677,11 +645,8 @@ static int lmv_disconnect(struct obd_export *exp)
lmv_disconnect_mdc(obd, lmv->tgts[i]);
}
- if (obd->obd_proc_private)
- lprocfs_remove((struct proc_dir_entry **)&obd->obd_proc_private);
- else
- CERROR("/proc/fs/lustre/%s/%s/target_obds missing\n",
- obd->obd_type->typ_name, obd->obd_name);
+ if (lmv->lmv_tgts_kobj)
+ kobject_put(lmv->lmv_tgts_kobj);
out_local:
/*
@@ -750,7 +715,7 @@ repeat_fid2path:
/* sigh, has to go to another MDT to do path building further */
if (remote_gf == NULL) {
remote_gf_size = sizeof(*remote_gf) + PATH_MAX;
- OBD_ALLOC(remote_gf, remote_gf_size);
+ remote_gf = kzalloc(remote_gf_size, GFP_NOFS);
if (remote_gf == NULL) {
rc = -ENOMEM;
goto out_fid2path;
@@ -780,8 +745,7 @@ repeat_fid2path:
goto repeat_fid2path;
out_fid2path:
- if (remote_gf != NULL)
- OBD_FREE(remote_gf, remote_gf_size);
+ kfree(remote_gf);
return rc;
}
@@ -984,7 +948,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
return -EAGAIN;
LASSERT(tgt && tgt->ltd_exp);
- OBD_ALLOC_PTR(oqctl);
+ oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (!oqctl)
return -ENOMEM;
@@ -995,7 +959,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp,
qctl->qc_valid = QC_MDTIDX;
qctl->obd_uuid = tgt->ltd_uuid;
}
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
break;
}
case OBD_IOC_CHANGELOG_SEND:
@@ -1311,7 +1275,7 @@ int lmv_fid_alloc(struct obd_export *exp, struct lu_fid *fid,
static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
struct lmv_obd *lmv = &obd->u.lmv;
- struct lprocfs_static_vars lvars;
+ struct lprocfs_static_vars lvars = { NULL };
struct lmv_desc *desc;
int rc;
@@ -1327,7 +1291,7 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
return -EINVAL;
}
- OBD_ALLOC(lmv->tgts, sizeof(*lmv->tgts) * 32);
+ lmv->tgts = kcalloc(32, sizeof(*lmv->tgts), GFP_NOFS);
if (lmv->tgts == NULL)
return -ENOMEM;
lmv->tgts_size = 32;
@@ -1345,16 +1309,12 @@ static int lmv_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
lprocfs_lmv_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
-#if defined (CONFIG_PROC_FS)
- {
- rc = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
- 0444, &lmv_proc_target_fops, obd);
- if (rc)
- CWARN("%s: error adding LMV target_obd file: rc = %d\n",
- obd->obd_name, rc);
- }
-#endif
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
+ rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd",
+ 0444, &lmv_proc_target_fops, obd);
+ if (rc)
+ CWARN("%s: error adding LMV target_obd file: rc = %d\n",
+ obd->obd_name, rc);
rc = fld_client_init(&lmv->lmv_fld, obd->obd_name,
LUSTRE_CLI_FLD_HASH_DHT);
if (rc) {
@@ -1380,7 +1340,7 @@ static int lmv_cleanup(struct obd_device *obd)
continue;
lmv_del_target(lmv, i);
}
- OBD_FREE(lmv->tgts, sizeof(*lmv->tgts) * lmv->tgts_size);
+ kfree(lmv->tgts);
lmv->tgts_size = 0;
}
return 0;
@@ -1437,7 +1397,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
if (rc)
return rc;
- OBD_ALLOC(temp, sizeof(*temp));
+ temp = kzalloc(sizeof(*temp), GFP_NOFS);
if (temp == NULL)
return -ENOMEM;
@@ -1473,7 +1433,7 @@ static int lmv_statfs(const struct lu_env *env, struct obd_export *exp,
}
out_free_temp:
- OBD_FREE(temp, sizeof(*temp));
+ kfree(temp);
return rc;
}
@@ -1769,7 +1729,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
goto out;
}
- OBD_ALLOC_PTR(rdata);
+ rdata = kzalloc(sizeof(*rdata), GFP_NOFS);
if (rdata == NULL) {
rc = -ENOMEM;
goto out;
@@ -1780,7 +1740,7 @@ lmv_enqueue_remote(struct obd_export *exp, struct ldlm_enqueue_info *einfo,
rc = md_enqueue(tgt->ltd_exp, einfo, it, rdata, lockh,
lmm, lmmsize, NULL, extra_lock_flags);
- OBD_FREE_PTR(rdata);
+ kfree(rdata);
out:
ldlm_lock_decref(&plock, pmode);
return rc;
@@ -2313,7 +2273,7 @@ static int lmv_precleanup(struct obd_device *obd, enum obd_cleanup_stage stage)
* stack. */
break;
case OBD_CLEANUP_EXPORTS:
- fld_client_proc_fini(&lmv->lmv_fld);
+ fld_client_debugfs_fini(&lmv->lmv_fld);
lprocfs_obd_cleanup(obd);
break;
default:
@@ -2875,7 +2835,7 @@ static int __init lmv_init(void)
lprocfs_lmv_init_vars(&lvars);
rc = class_register_type(&lmv_obd_ops, &lmv_md_ops,
- lvars.module_vars, LUSTRE_LMV_NAME, NULL);
+ LUSTRE_LMV_NAME, NULL);
return rc;
}
diff --git a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
index 22e5c315faa42d..8583fe229cdd72 100644
--- a/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
+++ b/drivers/staging/lustre/lustre/lmv/lproc_lmv.c
@@ -42,17 +42,17 @@
#include "../include/obd_class.h"
#include "lmv_internal.h"
-static int lmv_numobd_seq_show(struct seq_file *m, void *v)
+static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
- struct lmv_desc *desc;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct lmv_desc *desc;
- LASSERT(dev != NULL);
desc = &dev->u.lmv.desc;
- seq_printf(m, "%u\n", desc->ld_tgt_count);
- return 0;
+ return sprintf(buf, "%u\n", desc->ld_tgt_count);
}
-LPROC_SEQ_FOPS_RO(lmv_numobd);
+LUSTRE_RO_ATTR(numobd);
static const char *placement_name[] = {
[PLACEMENT_CHAR_POLICY] = "CHAR",
@@ -77,66 +77,61 @@ static const char *placement_policy2name(enum placement_policy placement)
return placement_name[placement];
}
-static int lmv_placement_seq_show(struct seq_file *m, void *v)
+static ssize_t placement_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
- struct lmv_obd *lmv;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct lmv_obd *lmv;
- LASSERT(dev != NULL);
lmv = &dev->u.lmv;
- seq_printf(m, "%s\n", placement_policy2name(lmv->lmv_placement));
- return 0;
+ return sprintf(buf, "%s\n", placement_policy2name(lmv->lmv_placement));
}
#define MAX_POLICY_STRING_SIZE 64
-static ssize_t lmv_placement_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t placement_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
- char dummy[MAX_POLICY_STRING_SIZE + 1];
- int len = count;
- enum placement_policy policy;
- struct lmv_obd *lmv;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ char dummy[MAX_POLICY_STRING_SIZE + 1];
+ enum placement_policy policy;
+ struct lmv_obd *lmv = &dev->u.lmv;
- if (copy_from_user(dummy, buffer, MAX_POLICY_STRING_SIZE))
- return -EFAULT;
+ memcpy(dummy, buffer, MAX_POLICY_STRING_SIZE);
- LASSERT(dev != NULL);
- lmv = &dev->u.lmv;
+ if (count > MAX_POLICY_STRING_SIZE)
+ count = MAX_POLICY_STRING_SIZE;
- if (len > MAX_POLICY_STRING_SIZE)
- len = MAX_POLICY_STRING_SIZE;
+ if (dummy[count - 1] == '\n')
+ count--;
+ dummy[count] = '\0';
- if (dummy[len - 1] == '\n')
- len--;
- dummy[len] = '\0';
-
- policy = placement_name2policy(dummy, len);
+ policy = placement_name2policy(dummy, count);
if (policy != PLACEMENT_INVAL_POLICY) {
spin_lock(&lmv->lmv_lock);
lmv->lmv_placement = policy;
spin_unlock(&lmv->lmv_lock);
} else {
- CERROR("Invalid placement policy \"%s\"!\n", dummy);
return -EINVAL;
}
return count;
}
-LPROC_SEQ_FOPS(lmv_placement);
+LUSTRE_RW_ATTR(placement);
-static int lmv_activeobd_seq_show(struct seq_file *m, void *v)
+static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
- struct lmv_desc *desc;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct lmv_desc *desc;
- LASSERT(dev != NULL);
desc = &dev->u.lmv.desc;
- seq_printf(m, "%u\n", desc->ld_active_tgt_count);
- return 0;
+ return sprintf(buf, "%u\n", desc->ld_active_tgt_count);
}
-LPROC_SEQ_FOPS_RO(lmv_activeobd);
+LUSTRE_RO_ATTR(activeobd);
static int lmv_desc_uuid_seq_show(struct seq_file *m, void *v)
{
@@ -199,29 +194,16 @@ static int lmv_target_seq_open(struct inode *inode, struct file *file)
return rc;
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private;
return 0;
}
-LPROC_SEQ_FOPS_RO_TYPE(lmv, uuid);
-
static struct lprocfs_vars lprocfs_lmv_obd_vars[] = {
- { "numobd", &lmv_numobd_fops, NULL, 0 },
- { "placement", &lmv_placement_fops, NULL, 0 },
- { "activeobd", &lmv_activeobd_fops, NULL, 0 },
- { "uuid", &lmv_uuid_fops, NULL, 0 },
{ "desc_uuid", &lmv_desc_uuid_fops, NULL, 0 },
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(lmv, numrefs);
-
-static struct lprocfs_vars lprocfs_lmv_module_vars[] = {
- { "num_refs", &lmv_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
struct file_operations lmv_proc_target_fops = {
.owner = THIS_MODULE,
.open = lmv_target_seq_open,
@@ -230,8 +212,19 @@ struct file_operations lmv_proc_target_fops = {
.release = seq_release,
};
+static struct attribute *lmv_attrs[] = {
+ &lustre_attr_activeobd.attr,
+ &lustre_attr_numobd.attr,
+ &lustre_attr_placement.attr,
+ NULL,
+};
+
+static struct attribute_group lmv_attr_group = {
+ .attrs = lmv_attrs,
+};
+
void lprocfs_lmv_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_lmv_module_vars;
+ lvars->sysfs_vars = &lmv_attr_group;
lvars->obd_vars = lprocfs_lmv_obd_vars;
}
diff --git a/drivers/staging/lustre/lustre/lov/Makefile b/drivers/staging/lustre/lustre/lov/Makefile
index 6fe56a24b16570..e4cc0db21014fa 100644
--- a/drivers/staging/lustre/lustre/lov/Makefile
+++ b/drivers/staging/lustre/lustre/lov/Makefile
@@ -2,5 +2,4 @@ obj-$(CONFIG_LUSTRE_FS) += lov.o
lov-y := lov_obd.o lov_pack.o lov_offset.o lov_merge.o \
lov_request.o lov_ea.o lov_dev.o lov_object.o lov_page.o \
lov_lock.o lov_io.o lovsub_dev.o lovsub_object.o lovsub_page.o \
- lovsub_lock.o lovsub_io.o lov_pool.o
-lov-$(CONFIG_PROC_FS) += lproc_lov.o
+ lovsub_lock.o lovsub_io.o lov_pool.o lproc_lov.o
diff --git a/drivers/staging/lustre/lustre/lov/lov_dev.c b/drivers/staging/lustre/lustre/lov/lov_dev.c
index 711b837ddba23a..504b24a468fc13 100644
--- a/drivers/staging/lustre/lustre/lov/lov_dev.c
+++ b/drivers/staging/lustre/lustre/lov/lov_dev.c
@@ -285,10 +285,10 @@ static void lov_emerg_free(struct lov_device_emerg **emrg, int nr)
LASSERT(em->emrg_page_list.pl_nr == 0);
if (em->emrg_env != NULL)
cl_env_put(em->emrg_env, &em->emrg_refcheck);
- OBD_FREE_PTR(em);
+ kfree(em);
}
}
- OBD_FREE(emrg, nr * sizeof(emrg[0]));
+ kfree(emrg);
}
static struct lu_device *lov_device_free(const struct lu_env *env,
@@ -298,11 +298,10 @@ static struct lu_device *lov_device_free(const struct lu_env *env,
const int nr = ld->ld_target_nr;
cl_device_fini(lu2cl_dev(d));
- if (ld->ld_target != NULL)
- OBD_FREE(ld->ld_target, nr * sizeof(ld->ld_target[0]));
+ kfree(ld->ld_target);
if (ld->ld_emrg != NULL)
lov_emerg_free(ld->ld_emrg, nr);
- OBD_FREE_PTR(ld);
+ kfree(ld);
return NULL;
}
@@ -323,13 +322,13 @@ static struct lov_device_emerg **lov_emerg_alloc(int nr)
int i;
int result;
- OBD_ALLOC(emerg, nr * sizeof(emerg[0]));
+ emerg = kcalloc(nr, sizeof(emerg[0]), GFP_NOFS);
if (emerg == NULL)
return ERR_PTR(-ENOMEM);
for (result = i = 0; i < nr && result == 0; i++) {
struct lov_device_emerg *em;
- OBD_ALLOC_PTR(em);
+ em = kzalloc(sizeof(*em), GFP_NOFS);
if (em != NULL) {
emerg[i] = em;
cl_page_list_init(&em->emrg_page_list);
@@ -369,12 +368,12 @@ static int lov_expand_targets(const struct lu_env *env, struct lov_device *dev)
if (IS_ERR(emerg))
return PTR_ERR(emerg);
- OBD_ALLOC(newd, tgt_size * sz);
+ newd = kcalloc(tgt_size, sz, GFP_NOFS);
if (newd != NULL) {
mutex_lock(&dev->ld_mutex);
if (sub_size > 0) {
memcpy(newd, dev->ld_target, sub_size * sz);
- OBD_FREE(dev->ld_target, sub_size * sz);
+ kfree(dev->ld_target);
}
dev->ld_target = newd;
dev->ld_target_nr = tgt_size;
@@ -478,7 +477,7 @@ static struct lu_device *lov_device_alloc(const struct lu_env *env,
struct obd_device *obd;
int rc;
- OBD_ALLOC_PTR(ld);
+ ld = kzalloc(sizeof(*ld), GFP_NOFS);
if (ld == NULL)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
index b644acc9b034c0..5e8bcc6ba01a3f 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -265,15 +265,8 @@ void lsm_free_plain(struct lov_stripe_md *lsm);
void dump_lsm(unsigned int level, const struct lov_stripe_md *lsm);
/* lproc_lov.c */
-#if defined (CONFIG_PROC_FS)
extern const struct file_operations lov_proc_target_fops;
void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
/* lov_cl.c */
extern struct lu_device_type lov_device_type;
diff --git a/drivers/staging/lustre/lustre/lov/lov_io.c b/drivers/staging/lustre/lustre/lov/lov_io.c
index cf96e0d01e22d5..a043df0c519f76 100644
--- a/drivers/staging/lustre/lustre/lov/lov_io.c
+++ b/drivers/staging/lustre/lustre/lov/lov_io.c
@@ -70,7 +70,7 @@ static void lov_io_sub_fini(const struct lu_env *env, struct lov_io *lio,
if (sub->sub_stripe == lio->lis_single_subio_index)
lio->lis_single_subio_index = -1;
else if (!sub->sub_borrowed)
- OBD_FREE_PTR(sub->sub_io);
+ kfree(sub->sub_io);
sub->sub_io = NULL;
}
if (sub->sub_env != NULL && !IS_ERR(sub->sub_env)) {
@@ -179,7 +179,8 @@ static int lov_io_sub_init(const struct lu_env *env, struct lov_io *lio,
sub->sub_io = &lio->lis_single_subio;
lio->lis_single_subio_index = stripe;
} else {
- OBD_ALLOC_PTR(sub->sub_io);
+ sub->sub_io = kzalloc(sizeof(*sub->sub_io),
+ GFP_NOFS);
if (sub->sub_io == NULL)
result = -ENOMEM;
}
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 02781576637edd..b5dc9e138d3069 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -127,7 +127,6 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
struct obd_device *tgt_obd;
static struct obd_uuid lov_osc_uuid = { "LOV_OSC_UUID" };
struct obd_import *imp;
- struct proc_dir_entry *lov_proc_dir;
int rc;
if (!lov->lov_tgts[index])
@@ -186,28 +185,10 @@ int lov_connect_obd(struct obd_device *obd, __u32 index, int activate,
CDEBUG(D_CONFIG, "Connected tgt idx %d %s (%s) %sactive\n", index,
obd_uuid2str(tgt_uuid), tgt_obd->obd_name, activate ? "":"in");
- lov_proc_dir = obd->obd_proc_private;
- if (lov_proc_dir) {
- struct obd_device *osc_obd = lov->lov_tgts[index]->ltd_exp->exp_obd;
- struct proc_dir_entry *osc_symlink;
-
- LASSERT(osc_obd != NULL);
- LASSERT(osc_obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(osc_obd->obd_type->typ_name != NULL);
-
- osc_symlink = lprocfs_add_symlink(osc_obd->obd_name,
- lov_proc_dir,
- "../../../%s/%s",
- osc_obd->obd_type->typ_name,
- osc_obd->obd_name);
- if (osc_symlink == NULL) {
- CERROR("could not register LOV target /proc/fs/lustre/%s/%s/target_obds/%s.",
- obd->obd_type->typ_name, obd->obd_name,
- osc_obd->obd_name);
- lprocfs_remove(&lov_proc_dir);
- obd->obd_proc_private = NULL;
- }
- }
+ if (lov->lov_tgts_kobj)
+ /* Even if we failed, that's ok */
+ rc = sysfs_create_link(lov->lov_tgts_kobj, &tgt_obd->obd_kobj,
+ tgt_obd->obd_name);
return 0;
}
@@ -239,6 +220,10 @@ static int lov_connect(const struct lu_env *env,
lov->lov_ocd = *data;
obd_getref(obd);
+
+ lov->lov_tgts_kobj = kobject_create_and_add("target_obds",
+ &obd->obd_kobj);
+
for (i = 0; i < lov->desc.ld_tgt_count; i++) {
tgt = lov->lov_tgts[i];
if (!tgt || obd_uuid_empty(&tgt->ltd_uuid))
@@ -268,7 +253,6 @@ static int lov_connect(const struct lu_env *env,
static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
{
- struct proc_dir_entry *lov_proc_dir;
struct lov_obd *lov = &obd->u.lov;
struct obd_device *osc_obd;
int rc;
@@ -284,10 +268,10 @@ static int lov_disconnect_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
}
if (osc_obd) {
- lov_proc_dir = obd->obd_proc_private;
- if (lov_proc_dir) {
- lprocfs_remove_proc_entry(osc_obd->obd_name, lov_proc_dir);
- }
+ if (lov->lov_tgts_kobj)
+ sysfs_remove_link(lov->lov_tgts_kobj,
+ osc_obd->obd_name);
+
/* Pass it on to our clients.
* XXX This should be an argument to disconnect,
* XXX not a back-door flag on the OBD. Ah well.
@@ -337,6 +321,10 @@ static int lov_disconnect(struct obd_export *exp)
lov_del_target(obd, i, NULL, lov->lov_tgts[i]->ltd_gen);
}
}
+
+ if (lov->lov_tgts_kobj)
+ kobject_put(lov->lov_tgts_kobj);
+
obd_putref(obd);
out:
@@ -554,7 +542,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
newsize = max_t(__u32, lov->lov_tgt_size, 2);
while (newsize < index + 1)
newsize <<= 1;
- OBD_ALLOC(newtgts, sizeof(*newtgts) * newsize);
+ newtgts = kcalloc(newsize, sizeof(*newtgts), GFP_NOFS);
if (newtgts == NULL) {
mutex_unlock(&lov->lov_lock);
return -ENOMEM;
@@ -570,14 +558,13 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
lov->lov_tgts = newtgts;
lov->lov_tgt_size = newsize;
smp_rmb();
- if (old)
- OBD_FREE(old, sizeof(*old) * oldsize);
+ kfree(old);
CDEBUG(D_CONFIG, "tgts: %p size: %d\n",
lov->lov_tgts, lov->lov_tgt_size);
}
- OBD_ALLOC_PTR(tgt);
+ tgt = kzalloc(sizeof(*tgt), GFP_NOFS);
if (!tgt) {
mutex_unlock(&lov->lov_lock);
return -ENOMEM;
@@ -586,7 +573,7 @@ static int lov_add_target(struct obd_device *obd, struct obd_uuid *uuidp,
rc = lov_ost_pool_add(&lov->lov_packed, index, lov->lov_tgt_size);
if (rc) {
mutex_unlock(&lov->lov_lock);
- OBD_FREE_PTR(tgt);
+ kfree(tgt);
return rc;
}
@@ -712,7 +699,7 @@ static void __lov_del_obd(struct obd_device *obd, struct lov_tgt_desc *tgt)
if (tgt->ltd_exp)
lov_disconnect_obd(obd, tgt);
- OBD_FREE_PTR(tgt);
+ kfree(tgt);
/* Manual cleanup - no cleanup logs to clean up the osc's. We must
do it ourselves. And we can't do it from lov_cleanup,
@@ -822,21 +809,16 @@ int lov_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
goto out;
lprocfs_lov_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
-#if defined (CONFIG_PROC_FS)
- {
- int rc1;
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
- rc1 = lprocfs_seq_create(obd->obd_proc_entry, "target_obd",
- 0444, &lov_proc_target_fops, obd);
- if (rc1)
- CWARN("Error adding the target_obd file\n");
- }
-#endif
- lov->lov_pool_proc_entry = lprocfs_register("pools",
- obd->obd_proc_entry,
- NULL, NULL);
+ rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd",
+ 0444, &lov_proc_target_fops, obd);
+ if (rc)
+ CWARN("Error adding the target_obd file\n");
+ lov->lov_pool_debugfs_entry = ldebugfs_register("pools",
+ obd->obd_debugfs_entry,
+ NULL, NULL);
return 0;
out:
@@ -903,8 +885,7 @@ static int lov_cleanup(struct obd_device *obd)
lov_del_target(obd, i, NULL, 0);
}
obd_putref(obd);
- OBD_FREE(lov->lov_tgts, sizeof(*lov->lov_tgts) *
- lov->lov_tgt_size);
+ kfree(lov->lov_tgts);
lov->lov_tgt_size = 0;
}
return 0;
@@ -994,7 +975,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
LASSERT(src_oa->o_valid & OBD_MD_FLFLAGS &&
src_oa->o_flags & OBD_FL_RECREATE_OBJS);
- OBD_ALLOC(obj_mdp, sizeof(*obj_mdp));
+ obj_mdp = kzalloc(sizeof(*obj_mdp), GFP_NOFS);
if (obj_mdp == NULL)
return -ENOMEM;
@@ -1032,7 +1013,7 @@ static int lov_recreate(struct obd_export *exp, struct obdo *src_oa,
rc = obd_create(NULL, lov->lov_tgts[ost_idx]->ltd_exp,
src_oa, &obj_mdp, oti);
out:
- OBD_FREE(obj_mdp, sizeof(*obj_mdp));
+ kfree(obj_mdp);
return rc;
}
@@ -1532,7 +1513,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
return -EAGAIN;
LASSERT(tgt && tgt->ltd_exp);
- OBD_ALLOC_PTR(oqctl);
+ oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (!oqctl)
return -ENOMEM;
@@ -1543,7 +1524,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
qctl->qc_valid = QC_OSTIDX;
qctl->obd_uuid = tgt->ltd_uuid;
}
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
break;
}
default: {
@@ -2367,7 +2348,7 @@ static int __init lov_init(void)
}
lprocfs_lov_init_vars(&lvars);
- rc = class_register_type(&lov_obd_ops, NULL, lvars.module_vars,
+ rc = class_register_type(&lov_obd_ops, NULL,
LUSTRE_LOV_NAME, &lov_device_type);
if (rc) {
diff --git a/drivers/staging/lustre/lustre/lov/lov_pack.c b/drivers/staging/lustre/lustre/lov/lov_pack.c
index 5356d532417639..92b9ffece4a088 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pack.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pack.c
@@ -367,9 +367,11 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
if (rc)
return rc;
magic = le32_to_cpu(lmm->lmm_magic);
+ pattern = le32_to_cpu(lmm->lmm_pattern);
} else {
magic = LOV_MAGIC;
stripe_count = lov_get_stripecnt(lov, magic, 0);
+ pattern = LOV_PATTERN_RAID0;
}
/* If we aren't passed an lsmp struct, we just want the size */
@@ -384,7 +386,6 @@ int lov_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
return 0;
}
- pattern = le32_to_cpu(lmm->lmm_pattern);
lsm_size = lov_alloc_memmd(lsmp, stripe_count, pattern, magic);
if (lsm_size < 0)
return lsm_size;
diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c b/drivers/staging/lustre/lustre/lov/lov_pool.c
index d96163de773f75..3c46c368cf134f 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pool.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pool.c
@@ -64,10 +64,10 @@ void lov_pool_putref(struct pool_desc *pool)
if (atomic_dec_and_test(&pool->pool_refcount)) {
LASSERT(hlist_unhashed(&pool->pool_hash));
LASSERT(list_empty(&pool->pool_list));
- LASSERT(pool->pool_proc_entry == NULL);
+ LASSERT(pool->pool_debugfs_entry == NULL);
lov_ost_pool_free(&(pool->pool_rr.lqr_pool));
lov_ost_pool_free(&(pool->pool_obds));
- OBD_FREE_PTR(pool);
+ kfree(pool);
}
}
@@ -152,7 +152,6 @@ cfs_hash_ops_t pool_hash_operations = {
};
-#if defined (CONFIG_PROC_FS)
/* ifdef needed for liblustre support */
/*
* pool /proc seq_file methods
@@ -210,7 +209,7 @@ static void *pool_proc_start(struct seq_file *s, loff_t *pos)
return NULL;
}
- OBD_ALLOC_PTR(iter);
+ iter = kzalloc(sizeof(*iter), GFP_NOFS);
if (!iter)
return ERR_PTR(-ENOMEM);
iter->magic = POOL_IT_MAGIC;
@@ -246,7 +245,7 @@ static void pool_proc_stop(struct seq_file *s, void *v)
* will work */
s->private = iter->pool;
lov_pool_putref(iter->pool);
- OBD_FREE_PTR(iter);
+ kfree(iter);
}
return;
}
@@ -283,7 +282,7 @@ static int pool_proc_open(struct inode *inode, struct file *file)
rc = seq_open(file, &pool_proc_ops);
if (!rc) {
struct seq_file *s = file->private_data;
- s->private = PDE_DATA(inode);
+ s->private = inode->i_private;
}
return rc;
}
@@ -294,7 +293,6 @@ static struct file_operations pool_proc_operations = {
.llseek = seq_lseek,
.release = seq_release,
};
-#endif /* CONFIG_PROC_FS */
void lov_dump_pool(int level, struct pool_desc *pool)
{
@@ -327,7 +325,7 @@ int lov_ost_pool_init(struct ost_pool *op, unsigned int count)
op->op_count = 0;
init_rwsem(&op->op_rw_sem);
op->op_size = count;
- OBD_ALLOC(op->op_array, op->op_size * sizeof(op->op_array[0]));
+ op->op_array = kcalloc(op->op_size, sizeof(op->op_array[0]), GFP_NOFS);
if (op->op_array == NULL) {
op->op_size = 0;
return -ENOMEM;
@@ -347,13 +345,13 @@ int lov_ost_pool_extend(struct ost_pool *op, unsigned int min_count)
return 0;
new_size = max(min_count, 2 * op->op_size);
- OBD_ALLOC(new, new_size * sizeof(op->op_array[0]));
+ new = kcalloc(new_size, sizeof(op->op_array[0]), GFP_NOFS);
if (new == NULL)
return -ENOMEM;
/* copy old array to new one */
memcpy(new, op->op_array, op->op_size * sizeof(op->op_array[0]));
- OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
+ kfree(op->op_array);
op->op_array = new;
op->op_size = new_size;
return 0;
@@ -411,7 +409,7 @@ int lov_ost_pool_free(struct ost_pool *op)
down_write(&op->op_rw_sem);
- OBD_FREE(op->op_array, op->op_size * sizeof(op->op_array[0]));
+ kfree(op->op_array);
op->op_array = NULL;
op->op_count = 0;
op->op_size = 0;
@@ -432,7 +430,7 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
if (strlen(poolname) > LOV_MAXPOOLNAME)
return -ENAMETOOLONG;
- OBD_ALLOC_PTR(new_pool);
+ new_pool = kzalloc(sizeof(*new_pool), GFP_NOFS);
if (new_pool == NULL)
return -ENOMEM;
@@ -454,20 +452,21 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
INIT_HLIST_NODE(&new_pool->pool_hash);
-#if defined (CONFIG_PROC_FS)
/* we need this assert seq_file is not implemented for liblustre */
/* get ref for /proc file */
lov_pool_getref(new_pool);
- new_pool->pool_proc_entry = lprocfs_add_simple(lov->lov_pool_proc_entry,
- poolname, new_pool,
- &pool_proc_operations);
- if (IS_ERR(new_pool->pool_proc_entry)) {
- CWARN("Cannot add proc pool entry "LOV_POOLNAMEF"\n", poolname);
- new_pool->pool_proc_entry = NULL;
+ new_pool->pool_debugfs_entry = ldebugfs_add_simple(
+ lov->lov_pool_debugfs_entry,
+ poolname, new_pool,
+ &pool_proc_operations);
+ if (IS_ERR_OR_NULL(new_pool->pool_debugfs_entry)) {
+ CWARN("Cannot add debugfs pool entry "LOV_POOLNAMEF"\n",
+ poolname);
+ new_pool->pool_debugfs_entry = NULL;
lov_pool_putref(new_pool);
}
- CDEBUG(D_INFO, "pool %p - proc %p\n", new_pool, new_pool->pool_proc_entry);
-#endif
+ CDEBUG(D_INFO, "pool %p - proc %p\n",
+ new_pool, new_pool->pool_debugfs_entry);
spin_lock(&obd->obd_dev_lock);
list_add_tail(&new_pool->pool_list, &lov->lov_pool_list);
@@ -493,12 +492,12 @@ out_err:
lov->lov_pool_count--;
spin_unlock(&obd->obd_dev_lock);
- lprocfs_remove(&new_pool->pool_proc_entry);
+ ldebugfs_remove(&new_pool->pool_debugfs_entry);
lov_ost_pool_free(&new_pool->pool_rr.lqr_pool);
out_free_pool_obds:
lov_ost_pool_free(&new_pool->pool_obds);
- OBD_FREE_PTR(new_pool);
+ kfree(new_pool);
return rc;
}
@@ -514,9 +513,9 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
if (pool == NULL)
return -ENOENT;
- if (pool->pool_proc_entry != NULL) {
- CDEBUG(D_INFO, "proc entry %p\n", pool->pool_proc_entry);
- lprocfs_remove(&pool->pool_proc_entry);
+ if (!IS_ERR_OR_NULL(pool->pool_debugfs_entry)) {
+ CDEBUG(D_INFO, "proc entry %p\n", pool->pool_debugfs_entry);
+ ldebugfs_remove(&pool->pool_debugfs_entry);
lov_pool_putref(pool);
}
diff --git a/drivers/staging/lustre/lustre/lov/lov_request.c b/drivers/staging/lustre/lustre/lov/lov_request.c
index 933e2d1f8127e1..f6e13149d2ad37 100644
--- a/drivers/staging/lustre/lustre/lov/lov_request.c
+++ b/drivers/staging/lustre/lustre/lov/lov_request.c
@@ -70,10 +70,8 @@ void lov_finish_set(struct lov_request_set *set)
OBDO_FREE(req->rq_oi.oi_oa);
if (req->rq_oi.oi_md)
OBD_FREE_LARGE(req->rq_oi.oi_md, req->rq_buflen);
- if (req->rq_oi.oi_osfs)
- OBD_FREE(req->rq_oi.oi_osfs,
- sizeof(*req->rq_oi.oi_osfs));
- OBD_FREE(req, sizeof(*req));
+ kfree(req->rq_oi.oi_osfs);
+ kfree(req);
}
if (set->set_pga) {
@@ -83,7 +81,7 @@ void lov_finish_set(struct lov_request_set *set)
if (set->set_lockh)
lov_llh_put(set->set_lockh);
- OBD_FREE(set, sizeof(*set));
+ kfree(set);
}
int lov_set_finished(struct lov_request_set *set, int idempotent)
@@ -286,7 +284,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
struct lov_obd *lov = &exp->exp_obd->u.lov;
int rc = 0, i;
- OBD_ALLOC(set, sizeof(*set));
+ set = kzalloc(sizeof(*set), GFP_NOFS);
if (set == NULL)
return -ENOMEM;
lov_init_set(set);
@@ -312,7 +310,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
continue;
}
- OBD_ALLOC(req, sizeof(*req));
+ req = kzalloc(sizeof(*req), GFP_NOFS);
if (req == NULL) {
rc = -ENOMEM;
goto out_set;
@@ -323,7 +321,7 @@ int lov_prep_getattr_set(struct obd_export *exp, struct obd_info *oinfo,
OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
- OBD_FREE(req, sizeof(*req));
+ kfree(req);
rc = -ENOMEM;
goto out_set;
}
@@ -369,7 +367,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
struct lov_obd *lov = &exp->exp_obd->u.lov;
int rc = 0, i;
- OBD_ALLOC(set, sizeof(*set));
+ set = kzalloc(sizeof(*set), GFP_NOFS);
if (set == NULL)
return -ENOMEM;
lov_init_set(set);
@@ -395,7 +393,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
continue;
}
- OBD_ALLOC(req, sizeof(*req));
+ req = kzalloc(sizeof(*req), GFP_NOFS);
if (req == NULL) {
rc = -ENOMEM;
goto out_set;
@@ -406,7 +404,7 @@ int lov_prep_destroy_set(struct obd_export *exp, struct obd_info *oinfo,
OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
- OBD_FREE(req, sizeof(*req));
+ kfree(req);
rc = -ENOMEM;
goto out_set;
}
@@ -488,7 +486,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
struct lov_obd *lov = &exp->exp_obd->u.lov;
int rc = 0, i;
- OBD_ALLOC(set, sizeof(*set));
+ set = kzalloc(sizeof(*set), GFP_NOFS);
if (set == NULL)
return -ENOMEM;
lov_init_set(set);
@@ -511,7 +509,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
continue;
}
- OBD_ALLOC(req, sizeof(*req));
+ req = kzalloc(sizeof(*req), GFP_NOFS);
if (req == NULL) {
rc = -ENOMEM;
goto out_set;
@@ -521,7 +519,7 @@ int lov_prep_setattr_set(struct obd_export *exp, struct obd_info *oinfo,
OBDO_ALLOC(req->rq_oi.oi_oa);
if (req->rq_oi.oi_oa == NULL) {
- OBD_FREE(req, sizeof(*req));
+ kfree(req);
rc = -ENOMEM;
goto out_set;
}
@@ -716,7 +714,7 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
struct lov_obd *lov = &obd->u.lov;
int rc = 0, i;
- OBD_ALLOC(set, sizeof(*set));
+ set = kzalloc(sizeof(*set), GFP_NOFS);
if (set == NULL)
return -ENOMEM;
lov_init_set(set);
@@ -742,15 +740,16 @@ int lov_prep_statfs_set(struct obd_device *obd, struct obd_info *oinfo,
continue;
}
- OBD_ALLOC(req, sizeof(*req));
+ req = kzalloc(sizeof(*req), GFP_NOFS);
if (req == NULL) {
rc = -ENOMEM;
goto out_set;
}
- OBD_ALLOC(req->rq_oi.oi_osfs, sizeof(*req->rq_oi.oi_osfs));
+ req->rq_oi.oi_osfs = kzalloc(sizeof(*req->rq_oi.oi_osfs),
+ GFP_NOFS);
if (req->rq_oi.oi_osfs == NULL) {
- OBD_FREE(req, sizeof(*req));
+ kfree(req);
rc = -ENOMEM;
goto out_set;
}
diff --git a/drivers/staging/lustre/lustre/lov/lovsub_dev.c b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
index 42336f13a76f6f..90d9ec386a1a7c 100644
--- a/drivers/staging/lustre/lustre/lov/lovsub_dev.c
+++ b/drivers/staging/lustre/lustre/lov/lovsub_dev.c
@@ -136,7 +136,7 @@ static struct lu_device *lovsub_device_free(const struct lu_env *env,
lu_site_print(env, d->ld_site, &msgdata, lu_cdebug_printer);
}
cl_device_fini(lu2cl_dev(d));
- OBD_FREE_PTR(lsd);
+ kfree(lsd);
return next;
}
@@ -172,7 +172,7 @@ static struct lu_device *lovsub_device_alloc(const struct lu_env *env,
struct lu_device *d;
struct lovsub_device *lsd;
- OBD_ALLOC_PTR(lsd);
+ lsd = kzalloc(sizeof(*lsd), GFP_NOFS);
if (lsd != NULL) {
int result;
diff --git a/drivers/staging/lustre/lustre/lov/lproc_lov.c b/drivers/staging/lustre/lustre/lov/lproc_lov.c
index 174cbf5c138f87..380b8271bf24ad 100644
--- a/drivers/staging/lustre/lustre/lov/lproc_lov.c
+++ b/drivers/staging/lustre/lustre/lov/lproc_lov.c
@@ -166,29 +166,29 @@ static ssize_t lov_stripecount_seq_write(struct file *file,
}
LPROC_SEQ_FOPS(lov_stripecount);
-static int lov_numobd_seq_show(struct seq_file *m, void *v)
+static ssize_t numobd_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct lov_desc *desc;
- LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
- seq_printf(m, "%u\n", desc->ld_tgt_count);
- return 0;
+ return sprintf(buf, "%u\n", desc->ld_tgt_count);
}
-LPROC_SEQ_FOPS_RO(lov_numobd);
+LUSTRE_RO_ATTR(numobd);
-static int lov_activeobd_seq_show(struct seq_file *m, void *v)
+static ssize_t activeobd_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = (struct obd_device *)m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct lov_desc *desc;
- LASSERT(dev != NULL);
desc = &dev->u.lov.desc;
- seq_printf(m, "%u\n", desc->ld_active_tgt_count);
- return 0;
+ return sprintf(buf, "%u\n", desc->ld_active_tgt_count);
}
-LPROC_SEQ_FOPS_RO(lov_activeobd);
+LUSTRE_RO_ATTR(activeobd);
static int lov_desc_uuid_seq_show(struct seq_file *m, void *v)
{
@@ -258,48 +258,34 @@ static int lov_target_seq_open(struct inode *inode, struct file *file)
return rc;
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private;
return 0;
}
-LPROC_SEQ_FOPS_RO_TYPE(lov, uuid);
-LPROC_SEQ_FOPS_RO_TYPE(lov, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(lov, filesfree);
-LPROC_SEQ_FOPS_RO_TYPE(lov, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(lov, kbytesavail);
-
static struct lprocfs_vars lprocfs_lov_obd_vars[] = {
- { "uuid", &lov_uuid_fops, NULL, 0 },
{ "stripesize", &lov_stripesize_fops, NULL },
{ "stripeoffset", &lov_stripeoffset_fops, NULL },
{ "stripecount", &lov_stripecount_fops, NULL },
{ "stripetype", &lov_stripetype_fops, NULL },
- { "numobd", &lov_numobd_fops, NULL, 0 },
- { "activeobd", &lov_activeobd_fops, NULL, 0 },
- { "filestotal", &lov_filestotal_fops, NULL, 0 },
- { "filesfree", &lov_filesfree_fops, NULL, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
- { "blocksize", &lov_blksize_fops, NULL, 0 },
- { "kbytestotal", &lov_kbytestotal_fops, NULL, 0 },
- { "kbytesfree", &lov_kbytesfree_fops, NULL, 0 },
- { "kbytesavail", &lov_kbytesavail_fops, NULL, 0 },
{ "desc_uuid", &lov_desc_uuid_fops, NULL, 0 },
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(lov, numrefs);
+static struct attribute *lov_attrs[] = {
+ &lustre_attr_activeobd.attr,
+ &lustre_attr_numobd.attr,
+ NULL,
+};
-static struct lprocfs_vars lprocfs_lov_module_vars[] = {
- { "num_refs", &lov_numrefs_fops, NULL, 0 },
- { NULL }
+static struct attribute_group lov_attr_group = {
+ .attrs = lov_attrs,
};
void lprocfs_lov_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_lov_module_vars;
- lvars->obd_vars = lprocfs_lov_obd_vars;
+ lvars->sysfs_vars = &lov_attr_group;
+ lvars->obd_vars = lprocfs_lov_obd_vars;
}
const struct file_operations lov_proc_target_fops = {
diff --git a/drivers/staging/lustre/lustre/mdc/Makefile b/drivers/staging/lustre/lustre/mdc/Makefile
index 2516551a6dc35d..99ba9ff0d83a72 100644
--- a/drivers/staging/lustre/lustre/mdc/Makefile
+++ b/drivers/staging/lustre/lustre/mdc/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += mdc.o
-mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o
-mdc-$(CONFIG_PROC_FS) += lproc_mdc.o
+mdc-y := mdc_request.o mdc_reint.o mdc_lib.o mdc_locks.o lproc_mdc.o
diff --git a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
index acfe08e459c0c5..1c95f87a0e2ae6 100644
--- a/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
+++ b/drivers/staging/lustre/lustre/mdc/lproc_mdc.c
@@ -40,29 +40,34 @@
#include "../include/lprocfs_status.h"
#include "mdc_internal.h"
-static int mdc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
+static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ int len;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
+ len = sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return len;
}
-static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
- const char __user *buffer,
- size_t count,
- loff_t *off)
+static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev =
- ((struct seq_file *)file->private_data)->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
- int val, rc;
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -75,11 +80,11 @@ static ssize_t mdc_max_rpcs_in_flight_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(mdc_max_rpcs_in_flight);
+LUSTRE_RW_ATTR(max_rpcs_in_flight);
static int mdc_kuc_open(struct inode *inode, struct file *file)
{
- return single_open(file, NULL, PDE_DATA(inode));
+ return single_open(file, NULL, inode->i_private);
}
/* temporary for testing */
@@ -106,7 +111,7 @@ static ssize_t mdc_kuc_write(struct file *file,
len = sizeof(*lh) + sizeof(*hal) + MTI_NAME_MAXLEN +
/* for mockup below */ 2 * cfs_size_round(sizeof(*hai));
- OBD_ALLOC(lh, len);
+ lh = kzalloc(len, GFP_NOFS);
if (!lh)
return -ENOMEM;
@@ -141,13 +146,13 @@ static ssize_t mdc_kuc_write(struct file *file,
rc = libcfs_kkuc_msg_put(fp, lh);
fput(fp);
}
- OBD_FREE(lh, len);
+ kfree(lh);
if (rc < 0)
return rc;
return count;
}
-struct file_operations mdc_kuc_fops = {
+static struct file_operations mdc_kuc_fops = {
.open = mdc_kuc_open,
.write = mdc_kuc_write,
.release = single_release,
@@ -155,49 +160,39 @@ struct file_operations mdc_kuc_fops = {
LPROC_SEQ_FOPS_WR_ONLY(mdc, ping);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, connect_flags);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, kbytesavail);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(mdc, filesfree);
LPROC_SEQ_FOPS_RO_TYPE(mdc, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, conn_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mdc, timeouts);
LPROC_SEQ_FOPS_RO_TYPE(mdc, state);
-static int mdc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
+/*
+ * Note: below sysfs entry is provided, but not currently in use, instead
+ * sbi->sb_md_brw_size is used, the per obd variable should be used
+ * when DNE is enabled, and dir pages are managed in MDC layer.
+ * Don't forget to enable sysfs store function then.
+ */
+static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return lprocfs_obd_rd_max_pages_per_rpc(m, m->private);
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct client_obd *cli = &dev->u.cli;
+
+ return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
}
-LPROC_SEQ_FOPS_RO(mdc_obd_max_pages_per_rpc);
+LUSTRE_RO_ATTR(max_pages_per_rpc);
LPROC_SEQ_FOPS_RW_TYPE(mdc, import);
LPROC_SEQ_FOPS_RW_TYPE(mdc, pinger_recov);
static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
- { "uuid", &mdc_uuid_fops, NULL, 0 },
{ "ping", &mdc_ping_fops, NULL, 0222 },
{ "connect_flags", &mdc_connect_flags_fops, NULL, 0 },
- { "blocksize", &mdc_blksize_fops, NULL, 0 },
- { "kbytestotal", &mdc_kbytestotal_fops, NULL, 0 },
- { "kbytesfree", &mdc_kbytesfree_fops, NULL, 0 },
- { "kbytesavail", &mdc_kbytesavail_fops, NULL, 0 },
- { "filestotal", &mdc_filestotal_fops, NULL, 0 },
- { "filesfree", &mdc_filesfree_fops, NULL, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
{ "mds_server_uuid", &mdc_server_uuid_fops, NULL, 0 },
{ "mds_conn_uuid", &mdc_conn_uuid_fops, NULL, 0 },
- /*
- * FIXME: below proc entry is provided, but not in used, instead
- * sbi->sb_md_brw_size is used, the per obd variable should be used
- * when CMD is enabled, and dir pages are managed in MDC layer.
- * Remember to enable proc write function.
- */
- { "max_pages_per_rpc", &mdc_obd_max_pages_per_rpc_fops, NULL, 0 },
- { "max_rpcs_in_flight", &mdc_max_rpcs_in_flight_fops, NULL, 0 },
{ "timeouts", &mdc_timeouts_fops, NULL, 0 },
{ "import", &mdc_import_fops, NULL, 0 },
{ "state", &mdc_state_fops, NULL, 0 },
@@ -206,15 +201,18 @@ static struct lprocfs_vars lprocfs_mdc_obd_vars[] = {
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(mdc, numrefs);
+static struct attribute *mdc_attrs[] = {
+ &lustre_attr_max_rpcs_in_flight.attr,
+ &lustre_attr_max_pages_per_rpc.attr,
+ NULL,
+};
-static struct lprocfs_vars lprocfs_mdc_module_vars[] = {
- { "num_refs", &mdc_numrefs_fops, NULL, 0 },
- { NULL }
+static struct attribute_group mdc_attr_group = {
+ .attrs = mdc_attrs,
};
void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_mdc_module_vars;
+ lvars->sysfs_vars = &mdc_attr_group;
lvars->obd_vars = lprocfs_mdc_obd_vars;
}
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_internal.h b/drivers/staging/lustre/lustre/mdc/mdc_internal.h
index 81780c943a08aa..4d149435e949ac 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_internal.h
+++ b/drivers/staging/lustre/lustre/mdc/mdc_internal.h
@@ -40,14 +40,7 @@
#include "../include/lustre_mdc.h"
#include "../include/lustre_mds.h"
-#if defined CONFIG_PROC_FS
void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline void lprocfs_mdc_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
void mdc_pack_body(struct ptlrpc_request *req, const struct lu_fid *fid,
struct obd_capa *oc, __u64 valid, int ea_size,
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index d1c224ecd2b78c..f9357973908390 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -1251,7 +1251,7 @@ static int mdc_intent_getattr_async_interpret(const struct lu_env *env,
rc = mdc_finish_intent_lock(exp, req, &minfo->mi_data, it, lockh);
out:
- OBD_FREE_PTR(einfo);
+ kfree(einfo);
minfo->mi_cb(req, minfo, rc);
return 0;
}
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c
index f8ef5fe5e771d0..c9639413b105b9 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_request.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c
@@ -1201,7 +1201,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
/* Key is KEY_FID2PATH + getinfo_fid2path description */
keylen = cfs_size_round(sizeof(KEY_FID2PATH)) + sizeof(*gf);
- OBD_ALLOC(key, keylen);
+ key = kzalloc(keylen, GFP_NOFS);
if (key == NULL)
return -ENOMEM;
memcpy(key, KEY_FID2PATH, sizeof(KEY_FID2PATH));
@@ -1234,7 +1234,7 @@ static int mdc_ioc_fid2path(struct obd_export *exp, struct getinfo_fid2path *gf)
PFID(&gf->gf_fid), gf->gf_recno, gf->gf_linkno, gf->gf_path);
out:
- OBD_FREE(key, keylen);
+ kfree(key);
return rc;
}
@@ -1604,7 +1604,7 @@ static int mdc_changelog_send_thread(void *csdata)
CDEBUG(D_CHANGELOG, "changelog to fp=%p start %llu\n",
cs->cs_fp, cs->cs_startrec);
- OBD_ALLOC(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE);
+ cs->cs_buf = kzalloc(KUC_CHANGELOG_MSG_MAXSIZE, GFP_NOFS);
if (cs->cs_buf == NULL) {
rc = -ENOMEM;
goto out;
@@ -1644,9 +1644,8 @@ out:
llog_cat_close(NULL, llh);
if (ctxt)
llog_ctxt_put(ctxt);
- if (cs->cs_buf)
- OBD_FREE(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE);
- OBD_FREE_PTR(cs);
+ kfree(cs->cs_buf);
+ kfree(cs);
return rc;
}
@@ -1657,7 +1656,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
int rc;
/* Freed in mdc_changelog_send_thread */
- OBD_ALLOC_PTR(cs);
+ cs = kzalloc(sizeof(*cs), GFP_NOFS);
if (!cs)
return -ENOMEM;
@@ -1679,7 +1678,7 @@ static int mdc_ioc_changelog_send(struct obd_device *obd,
}
CERROR("Failed to start changelog thread: %d\n", rc);
- OBD_FREE_PTR(cs);
+ kfree(cs);
return rc;
}
@@ -1819,10 +1818,7 @@ static int mdc_ioc_swap_layouts(struct obd_export *exp,
ptlrpc_request_set_replen(req);
rc = ptlrpc_queue_wait(req);
- if (rc)
- goto out;
-out:
ptlrpc_req_finished(req);
return rc;
}
@@ -1937,7 +1933,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
struct if_quotactl *qctl = karg;
struct obd_quotactl *oqctl;
- OBD_ALLOC_PTR(oqctl);
+ oqctl = kzalloc(sizeof(*oqctl), GFP_NOFS);
if (oqctl == NULL) {
rc = -ENOMEM;
goto out;
@@ -1951,7 +1947,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
qctl->obd_uuid = obd->u.cli.cl_target_uuid;
}
- OBD_FREE_PTR(oqctl);
+ kfree(oqctl);
goto out;
}
case LL_IOC_GET_CONNECT_FLAGS:
@@ -2430,14 +2426,14 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
struct lprocfs_static_vars lvars = { NULL };
int rc;
- OBD_ALLOC(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock));
+ cli->cl_rpc_lock = kzalloc(sizeof(*cli->cl_rpc_lock), GFP_NOFS);
if (!cli->cl_rpc_lock)
return -ENOMEM;
mdc_init_rpc_lock(cli->cl_rpc_lock);
ptlrpcd_addref();
- OBD_ALLOC(cli->cl_close_lock, sizeof(*cli->cl_close_lock));
+ cli->cl_close_lock = kzalloc(sizeof(*cli->cl_close_lock), GFP_NOFS);
if (!cli->cl_close_lock) {
rc = -ENOMEM;
goto err_rpc_lock;
@@ -2448,7 +2444,7 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
if (rc)
goto err_close_lock;
lprocfs_mdc_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
sptlrpc_lprocfs_cliobd_attach(obd);
ptlrpc_lprocfs_register_obd(obd);
@@ -2465,9 +2461,9 @@ static int mdc_setup(struct obd_device *obd, struct lustre_cfg *cfg)
return rc;
err_close_lock:
- OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock));
+ kfree(cli->cl_close_lock);
err_rpc_lock:
- OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock));
+ kfree(cli->cl_rpc_lock);
ptlrpcd_decref();
return rc;
}
@@ -2525,8 +2521,8 @@ static int mdc_cleanup(struct obd_device *obd)
{
struct client_obd *cli = &obd->u.cli;
- OBD_FREE(cli->cl_rpc_lock, sizeof(*cli->cl_rpc_lock));
- OBD_FREE(cli->cl_close_lock, sizeof(*cli->cl_close_lock));
+ kfree(cli->cl_rpc_lock);
+ kfree(cli->cl_close_lock);
ptlrpcd_decref();
@@ -2714,7 +2710,7 @@ static int __init mdc_init(void)
lprocfs_mdc_init_vars(&lvars);
- return class_register_type(&mdc_obd_ops, &mdc_md_ops, lvars.module_vars,
+ return class_register_type(&mdc_obd_ops, &mdc_md_ops,
LUSTRE_MDC_NAME, NULL);
}
diff --git a/drivers/staging/lustre/lustre/mgc/Makefile b/drivers/staging/lustre/lustre/mgc/Makefile
index cc6e9f51a8e889..8ea29a89cf508e 100644
--- a/drivers/staging/lustre/lustre/mgc/Makefile
+++ b/drivers/staging/lustre/lustre/mgc/Makefile
@@ -1,3 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += mgc.o
-mgc-y := mgc_request.o
-mgc-$(CONFIG_PROC_FS) += lproc_mgc.o
+mgc-y := mgc_request.o lproc_mgc.o
diff --git a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
index c4ea38e5f07763..34a9317d6d63cf 100644
--- a/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
+++ b/drivers/staging/lustre/lustre/mgc/lproc_mgc.c
@@ -40,7 +40,6 @@
#include "../include/lprocfs_status.h"
#include "mgc_internal.h"
-LPROC_SEQ_FOPS_RO_TYPE(mgc, uuid);
LPROC_SEQ_FOPS_RO_TYPE(mgc, connect_flags);
LPROC_SEQ_FOPS_RO_TYPE(mgc, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(mgc, conn_uuid);
@@ -56,7 +55,6 @@ static int mgc_ir_state_seq_show(struct seq_file *m, void *v)
LPROC_SEQ_FOPS_RO(mgc_ir_state);
static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
- { "uuid", &mgc_uuid_fops, NULL, 0 },
{ "ping", &mgc_ping_fops, NULL, 0222 },
{ "connect_flags", &mgc_connect_flags_fops, NULL, 0 },
{ "mgs_server_uuid", &mgc_server_uuid_fops, NULL, 0 },
@@ -67,14 +65,7 @@ static struct lprocfs_vars lprocfs_mgc_obd_vars[] = {
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(mgc, numrefs);
-static struct lprocfs_vars lprocfs_mgc_module_vars[] = {
- { "num_refs", &mgc_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_mgc_module_vars;
lvars->obd_vars = lprocfs_mgc_obd_vars;
}
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_internal.h b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
index a6f8b3ced2e7d9..82fb8f46e037d6 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_internal.h
+++ b/drivers/staging/lustre/lustre/mgc/mgc_internal.h
@@ -44,19 +44,8 @@
#include "../include/lustre_log.h"
#include "../include/lustre_export.h"
-#if defined (CONFIG_PROC_FS)
void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars);
int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data);
-#else
-static inline void lprocfs_mgc_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-static inline int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
-{
- return 0;
-}
-#endif /* CONFIG_PROC_FS */
int mgc_process_log(struct obd_device *mgc, struct config_llog_data *cld);
diff --git a/drivers/staging/lustre/lustre/mgc/mgc_request.c b/drivers/staging/lustre/lustre/mgc/mgc_request.c
index 7947aec5c847ca..174dfc32876b58 100644
--- a/drivers/staging/lustre/lustre/mgc/mgc_request.c
+++ b/drivers/staging/lustre/lustre/mgc/mgc_request.c
@@ -149,7 +149,7 @@ static void config_log_put(struct config_llog_data *cld)
sptlrpc_conf_log_stop(cld->cld_logname);
class_export_put(cld->cld_mgcexp);
- OBD_FREE(cld, sizeof(*cld) + strlen(cld->cld_logname) + 1);
+ kfree(cld);
}
}
@@ -198,7 +198,7 @@ struct config_llog_data *do_config_log_add(struct obd_device *obd,
CDEBUG(D_MGC, "do adding config log %s:%p\n", logname,
cfg ? cfg->cfg_instance : NULL);
- OBD_ALLOC(cld, sizeof(*cld) + strlen(logname) + 1);
+ cld = kzalloc(sizeof(*cld) + strlen(logname) + 1, GFP_NOFS);
if (!cld)
return ERR_PTR(-ENOMEM);
@@ -448,7 +448,6 @@ static int config_log_end(char *logname, struct config_llog_instance *cfg)
return rc;
}
-#if defined (CONFIG_PROC_FS)
int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
{
struct obd_device *obd = data;
@@ -477,7 +476,6 @@ int lprocfs_mgc_rd_ir_state(struct seq_file *m, void *data)
LPROCFS_CLIMP_EXIT(obd);
return 0;
}
-#endif
/* reenqueue any lost locks */
#define RQ_RUNNING 0x1
@@ -722,7 +720,7 @@ static int mgc_cleanup(struct obd_device *obd)
static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
{
- struct lprocfs_static_vars lvars;
+ struct lprocfs_static_vars lvars = { NULL };
int rc;
ptlrpcd_addref();
@@ -738,7 +736,7 @@ static int mgc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
}
lprocfs_mgc_init_vars(&lvars);
- lprocfs_obd_setup(obd, lvars.obd_vars);
+ lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
sptlrpc_lprocfs_cliobd_attach(obd);
if (atomic_inc_return(&mgc_count) == 1) {
@@ -1129,14 +1127,14 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
LASSERT(cfg->cfg_instance != NULL);
LASSERT(cfg->cfg_sb == cfg->cfg_instance);
- OBD_ALLOC(inst, PAGE_CACHE_SIZE);
+ inst = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
if (inst == NULL)
return -ENOMEM;
if (!IS_SERVER(lsi)) {
pos = snprintf(inst, PAGE_CACHE_SIZE, "%p", cfg->cfg_instance);
if (pos >= PAGE_CACHE_SIZE) {
- OBD_FREE(inst, PAGE_CACHE_SIZE);
+ kfree(inst);
return -E2BIG;
}
} else {
@@ -1144,7 +1142,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
rc = server_name2svname(lsi->lsi_svname, inst, NULL,
PAGE_CACHE_SIZE);
if (rc) {
- OBD_FREE(inst, PAGE_CACHE_SIZE);
+ kfree(inst);
return -EINVAL;
}
pos = strlen(inst);
@@ -1302,7 +1300,7 @@ static int mgc_apply_recover_logs(struct obd_device *mgc,
/* continue, even one with error */
}
- OBD_FREE(inst, PAGE_CACHE_SIZE);
+ kfree(inst);
return rc;
}
@@ -1336,7 +1334,7 @@ static int mgc_process_recover_log(struct obd_device *obd,
if (cfg->cfg_last_idx == 0) /* the first time */
nrpages = CONFIG_READ_NRPAGES_INIT;
- OBD_ALLOC(pages, sizeof(*pages) * nrpages);
+ pages = kcalloc(nrpages, sizeof(*pages), GFP_NOFS);
if (pages == NULL) {
rc = -ENOMEM;
goto out;
@@ -1466,7 +1464,7 @@ out:
break;
__free_page(pages[i]);
}
- OBD_FREE(pages, sizeof(*pages) * nrpages);
+ kfree(pages);
}
return rc;
}
@@ -1494,7 +1492,7 @@ static int mgc_process_cfg_log(struct obd_device *mgc,
if (cld->cld_cfg.cfg_sb)
lsi = s2lsi(cld->cld_cfg.cfg_sb);
- OBD_ALLOC_PTR(env);
+ env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL)
return -ENOMEM;
@@ -1540,7 +1538,7 @@ out_pop:
lu_env_fini(env);
out_free:
- OBD_FREE_PTR(env);
+ kfree(env);
return rc;
}
@@ -1745,7 +1743,7 @@ struct obd_ops mgc_obd_ops = {
static int __init mgc_init(void)
{
- return class_register_type(&mgc_obd_ops, NULL, NULL,
+ return class_register_type(&mgc_obd_ops, NULL,
LUSTRE_MGC_NAME, NULL);
}
diff --git a/drivers/staging/lustre/lustre/obdclass/Makefile b/drivers/staging/lustre/lustre/obdclass/Makefile
index e894681797c238..d0f70b41acf6f0 100644
--- a/drivers/staging/lustre/lustre/obdclass/Makefile
+++ b/drivers/staging/lustre/lustre/obdclass/Makefile
@@ -6,6 +6,4 @@ obdclass-y := linux/linux-module.o linux/linux-obdo.o linux/linux-sysctl.o \
lustre_handles.o lustre_peer.o \
statfs_pack.o obdo.o obd_config.o obd_mount.o \
lu_object.o dt_object.o capa.o cl_object.o \
- cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o
-
-obdclass-$(CONFIG_PROC_FS) += lprocfs_counters.o
+ cl_page.o cl_lock.o cl_io.o lu_ref.o acl.o lprocfs_counters.o
diff --git a/drivers/staging/lustre/lustre/obdclass/acl.c b/drivers/staging/lustre/lustre/obdclass/acl.c
index 9a69f6b35a0ea3..bc3fc4780cb9e5 100644
--- a/drivers/staging/lustre/lustre/obdclass/acl.c
+++ b/drivers/staging/lustre/lustre/obdclass/acl.c
@@ -104,12 +104,12 @@ static int lustre_posix_acl_xattr_reduce_space(posix_acl_xattr_header **header,
if (unlikely(old_count <= new_count))
return old_size;
- OBD_ALLOC(new, new_size);
+ new = kzalloc(new_size, GFP_NOFS);
if (unlikely(new == NULL))
return -ENOMEM;
memcpy(new, *header, new_size);
- OBD_FREE(*header, old_size);
+ kfree(*header);
*header = new;
return new_size;
}
@@ -120,18 +120,17 @@ static int lustre_ext_acl_xattr_reduce_space(ext_acl_xattr_header **header,
{
int ext_count = le32_to_cpu((*header)->a_count);
int ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr);
- int old_size = CFS_ACL_XATTR_SIZE(old_count, ext_acl_xattr);
ext_acl_xattr_header *new;
if (unlikely(old_count <= ext_count))
return 0;
- OBD_ALLOC(new, ext_size);
+ new = kzalloc(ext_size, GFP_NOFS);
if (unlikely(new == NULL))
return -ENOMEM;
memcpy(new, *header, ext_size);
- OBD_FREE(*header, old_size);
+ kfree(*header);
*header = new;
return 0;
}
@@ -152,7 +151,7 @@ lustre_posix_acl_xattr_2ext(posix_acl_xattr_header *header, int size)
else
count = CFS_ACL_XATTR_COUNT(size, posix_acl_xattr);
esize = CFS_ACL_XATTR_SIZE(count, ext_acl_xattr);
- OBD_ALLOC(new, esize);
+ new = kzalloc(esize, GFP_NOFS);
if (unlikely(new == NULL))
return ERR_PTR(-ENOMEM);
@@ -183,7 +182,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
if (size < sizeof(*new))
return -EINVAL;
- OBD_ALLOC(new, size);
+ new = kzalloc(size, GFP_NOFS);
if (unlikely(new == NULL))
return -ENOMEM;
@@ -232,7 +231,7 @@ int lustre_posix_acl_xattr_filter(posix_acl_xattr_header *header, size_t size,
_out:
if (rc) {
- OBD_FREE(new, size);
+ kfree(new);
size = rc;
}
return size;
@@ -244,7 +243,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_filter);
*/
void lustre_posix_acl_xattr_free(posix_acl_xattr_header *header, int size)
{
- OBD_FREE(header, size);
+ kfree(header);
}
EXPORT_SYMBOL(lustre_posix_acl_xattr_free);
@@ -253,8 +252,7 @@ EXPORT_SYMBOL(lustre_posix_acl_xattr_free);
*/
void lustre_ext_acl_xattr_free(ext_acl_xattr_header *header)
{
- OBD_FREE(header, CFS_ACL_XATTR_SIZE(le32_to_cpu(header->a_count), \
- ext_acl_xattr));
+ kfree(header);
}
EXPORT_SYMBOL(lustre_ext_acl_xattr_free);
@@ -309,7 +307,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
/* there are only base ACL entries at most. */
posix_count = 3;
posix_size = CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr);
- OBD_ALLOC(new, posix_size);
+ new = kzalloc(posix_size, GFP_NOFS);
if (unlikely(new == NULL))
return -ENOMEM;
@@ -360,7 +358,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
posix_count = ori_posix_count + ext_count;
posix_size =
CFS_ACL_XATTR_SIZE(posix_count, posix_acl_xattr);
- OBD_ALLOC(new, posix_size);
+ new = kzalloc(posix_size, GFP_NOFS);
if (unlikely(new == NULL))
return -ENOMEM;
@@ -402,7 +400,7 @@ int lustre_acl_xattr_merge2posix(posix_acl_xattr_header *posix_header, int size,
_out:
if (rc) {
- OBD_FREE(new, posix_size);
+ kfree(new);
posix_size = rc;
}
return posix_size;
@@ -432,7 +430,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size,
ext_count = posix_count + ori_ext_count;
ext_size = CFS_ACL_XATTR_SIZE(ext_count, ext_acl_xattr);
- OBD_ALLOC(new, ext_size);
+ new = kzalloc(ext_size, GFP_NOFS);
if (unlikely(new == NULL))
return ERR_PTR(-ENOMEM);
@@ -538,7 +536,7 @@ lustre_acl_xattr_merge2ext(posix_acl_xattr_header *posix_header, int size,
out:
if (rc) {
- OBD_FREE(new, ext_size);
+ kfree(new);
new = ERR_PTR(rc);
}
return new;
diff --git a/drivers/staging/lustre/lustre/obdclass/capa.c b/drivers/staging/lustre/lustre/obdclass/capa.c
index d206b1046a18b8..d8d1a66ad68ef3 100644
--- a/drivers/staging/lustre/lustre/obdclass/capa.c
+++ b/drivers/staging/lustre/lustre/obdclass/capa.c
@@ -87,7 +87,7 @@ struct hlist_head *init_capa_hash(void)
struct hlist_head *hash;
int nr_hash, i;
- OBD_ALLOC(hash, PAGE_CACHE_SIZE);
+ hash = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
if (!hash)
return NULL;
@@ -129,7 +129,7 @@ void cleanup_capa_hash(struct hlist_head *hash)
}
spin_unlock(&capa_lock);
- OBD_FREE(hash, PAGE_CACHE_SIZE);
+ kfree(hash);
}
EXPORT_SYMBOL(cleanup_capa_hash);
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_io.c b/drivers/staging/lustre/lustre/obdclass/cl_io.c
index 3141b604370815..fd1a4c5421e8fc 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_io.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_io.c
@@ -612,7 +612,7 @@ EXPORT_SYMBOL(cl_io_lock_add);
static void cl_free_io_lock_link(const struct lu_env *env,
struct cl_io_lock_link *link)
{
- OBD_FREE_PTR(link);
+ kfree(link);
}
/**
@@ -624,7 +624,7 @@ int cl_io_lock_alloc_add(const struct lu_env *env, struct cl_io *io,
struct cl_io_lock_link *link;
int result;
- OBD_ALLOC_PTR(link);
+ link = kzalloc(sizeof(*link), GFP_NOFS);
if (link != NULL) {
link->cill_descr = *descr;
link->cill_fini = cl_free_io_lock_link;
@@ -1387,9 +1387,9 @@ static void cl_req_free(const struct lu_env *env, struct cl_req *req)
cl_object_put(env, obj);
}
}
- OBD_FREE(req->crq_o, req->crq_nrobjs * sizeof(req->crq_o[0]));
+ kfree(req->crq_o);
}
- OBD_FREE_PTR(req);
+ kfree(req);
}
static int cl_req_init(const struct lu_env *env, struct cl_req *req,
@@ -1448,7 +1448,7 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page,
LINVRNT(nr_objects > 0);
- OBD_ALLOC_PTR(req);
+ req = kzalloc(sizeof(*req), GFP_NOFS);
if (req != NULL) {
int result;
@@ -1456,7 +1456,8 @@ struct cl_req *cl_req_alloc(const struct lu_env *env, struct cl_page *page,
INIT_LIST_HEAD(&req->crq_pages);
INIT_LIST_HEAD(&req->crq_layers);
- OBD_ALLOC(req->crq_o, nr_objects * sizeof(req->crq_o[0]));
+ req->crq_o = kcalloc(nr_objects, sizeof(req->crq_o[0]),
+ GFP_NOFS);
if (req->crq_o != NULL) {
req->crq_nrobjs = nr_objects;
result = cl_req_init(env, req, page);
diff --git a/drivers/staging/lustre/lustre/obdclass/cl_page.c b/drivers/staging/lustre/lustre/obdclass/cl_page.c
index b7dd048080604b..a7f3032f34dd83 100644
--- a/drivers/staging/lustre/lustre/obdclass/cl_page.c
+++ b/drivers/staging/lustre/lustre/obdclass/cl_page.c
@@ -62,12 +62,6 @@ static void cl_page_delete0(const struct lu_env *env, struct cl_page *pg,
# define PINVRNT(env, page, exp) \
((void)sizeof(env), (void)sizeof(page), (void)sizeof !!(exp))
-/* Disable page statistic by default due to huge performance penalty. */
-#define CS_PAGE_INC(o, item)
-#define CS_PAGE_DEC(o, item)
-#define CS_PAGESTATE_INC(o, state)
-#define CS_PAGESTATE_DEC(o, state)
-
/**
* Internal version of cl_page_top, it should be called if the page is
* known to be not freed, says with page referenced, or radix tree lock held,
@@ -248,7 +242,6 @@ EXPORT_SYMBOL(cl_page_gang_lookup);
static void cl_page_free(const struct lu_env *env, struct cl_page *page)
{
struct cl_object *obj = page->cp_obj;
- int pagesize = cl_object_header(obj)->coh_page_bufsize;
PASSERT(env, page, list_empty(&page->cp_batch));
PASSERT(env, page, page->cp_owner == NULL);
@@ -265,12 +258,10 @@ static void cl_page_free(const struct lu_env *env, struct cl_page *page)
list_del_init(page->cp_layers.next);
slice->cpl_ops->cpo_fini(env, slice);
}
- CS_PAGE_DEC(obj, total);
- CS_PAGESTATE_DEC(obj, page->cp_state);
lu_object_ref_del_at(&obj->co_lu, &page->cp_obj_ref, "cl_page", page);
cl_object_put(env, obj);
lu_ref_fini(&page->cp_reference);
- OBD_FREE(page, pagesize);
+ kfree(page);
}
/**
@@ -324,11 +315,6 @@ static struct cl_page *cl_page_alloc(const struct lu_env *env,
}
}
}
- if (result == 0) {
- CS_PAGE_INC(o, total);
- CS_PAGE_INC(o, create);
- CS_PAGESTATE_DEC(o, CPS_CACHED);
- }
} else {
page = ERR_PTR(-ENOMEM);
}
@@ -361,7 +347,6 @@ static struct cl_page *cl_page_find0(const struct lu_env *env,
might_sleep();
hdr = cl_object_header(o);
- CS_PAGE_INC(o, lookup);
CDEBUG(D_PAGE, "%lu@"DFID" %p %lx %d\n",
idx, PFID(&hdr->coh_lu.loh_fid), vmpage, vmpage->private, type);
@@ -388,7 +373,6 @@ static struct cl_page *cl_page_find0(const struct lu_env *env,
}
if (page != NULL) {
- CS_PAGE_INC(o, hit);
return page;
}
@@ -555,8 +539,6 @@ static void cl_page_state_set0(const struct lu_env *env,
PASSERT(env, page,
equi(state == CPS_OWNED, page->cp_owner != NULL));
- CS_PAGESTATE_DEC(page->cp_obj, page->cp_state);
- CS_PAGESTATE_INC(page->cp_obj, state);
cl_page_state_set_trust(page, state);
}
}
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index d4b74b670c43df..1bc37566b3a50a 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -231,7 +231,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
err = -EINVAL;
goto out;
}
- OBD_ALLOC(lcfg, data->ioc_plen1);
+ lcfg = kzalloc(data->ioc_plen1, GFP_NOFS);
if (lcfg == NULL) {
err = -ENOMEM;
goto out;
@@ -243,7 +243,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg)
if (!err)
err = class_process_config(lcfg);
- OBD_FREE(lcfg, data->ioc_plen1);
+ kfree(lcfg);
goto out;
}
@@ -506,15 +506,8 @@ int obd_init_checks(void)
return ret;
}
-#if defined (CONFIG_PROC_FS)
extern int class_procfs_init(void);
extern int class_procfs_clean(void);
-#else
-static inline int class_procfs_init(void)
-{ return 0; }
-static inline int class_procfs_clean(void)
-{ return 0; }
-#endif
static int __init init_obdclass(void)
{
@@ -529,24 +522,22 @@ static int __init init_obdclass(void)
spin_lock_init(&obd_types_lock);
obd_zombie_impexp_init();
- if (IS_ENABLED(CONFIG_PROC_FS)) {
- obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
- LPROCFS_STATS_FLAG_NONE |
- LPROCFS_STATS_FLAG_IRQ_SAFE);
+ obd_memory = lprocfs_alloc_stats(OBD_STATS_NUM,
+ LPROCFS_STATS_FLAG_NONE |
+ LPROCFS_STATS_FLAG_IRQ_SAFE);
- if (obd_memory == NULL) {
- CERROR("kmalloc of 'obd_memory' failed\n");
- return -ENOMEM;
- }
-
- lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
- LPROCFS_CNTR_AVGMINMAX,
- "memused", "bytes");
- lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
- LPROCFS_CNTR_AVGMINMAX,
- "pagesused", "pages");
+ if (obd_memory == NULL) {
+ CERROR("kmalloc of 'obd_memory' failed\n");
+ return -ENOMEM;
}
+ lprocfs_counter_init(obd_memory, OBD_MEMORY_STAT,
+ LPROCFS_CNTR_AVGMINMAX,
+ "memused", "bytes");
+ lprocfs_counter_init(obd_memory, OBD_MEMORY_PAGES_STAT,
+ LPROCFS_CNTR_AVGMINMAX,
+ "pagesused", "pages");
+
err = obd_init_checks();
if (err == -EOVERFLOW)
return err;
@@ -620,7 +611,6 @@ void obd_update_maxusage(void)
}
EXPORT_SYMBOL(obd_update_maxusage);
-#if defined (CONFIG_PROC_FS)
__u64 obd_memory_max(void)
{
__u64 ret;
@@ -644,7 +634,6 @@ __u64 obd_pages_max(void)
return ret;
}
EXPORT_SYMBOL(obd_pages_max);
-#endif
/* liblustre doesn't call cleanup_obdclass, apparently. we carry on in this
* ifdef to the end of the file to cover module and versioning goo.*/
diff --git a/drivers/staging/lustre/lustre/obdclass/dt_object.c b/drivers/staging/lustre/lustre/obdclass/dt_object.c
index b1eee0a6dc9a1e..6ce407ff8318c1 100644
--- a/drivers/staging/lustre/lustre/obdclass/dt_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/dt_object.c
@@ -49,8 +49,6 @@
/* fid_be_to_cpu() */
#include "../include/lustre_fid.h"
-#include "../include/lustre_quota.h"
-
/* context key constructor/destructor: dt_global_key_init, dt_global_key_fini */
LU_KEY_INIT(dt_global, struct dt_thread_info);
LU_KEY_FINI(dt_global, struct dt_thread_info);
@@ -939,8 +937,6 @@ out:
}
EXPORT_SYMBOL(dt_index_read);
-#if defined (CONFIG_PROC_FS)
-
int lprocfs_dt_rd_blksize(char *page, char **start, off_t off,
int count, int *eof, void *data)
{
@@ -1055,5 +1051,3 @@ int lprocfs_dt_rd_filesfree(char *page, char **start, off_t off,
return rc;
}
EXPORT_SYMBOL(lprocfs_dt_rd_filesfree);
-
-#endif /* CONFIG_PROC_FS */
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index 66b56784f674e2..978c3c5c460a15 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -156,7 +156,7 @@ EXPORT_SYMBOL(class_put_type);
#define CLASS_MAX_NAME 1024
int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
- struct lprocfs_vars *vars, const char *name,
+ const char *name,
struct lu_device_type *ldt)
{
struct obd_type *type;
@@ -171,13 +171,13 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
}
rc = -ENOMEM;
- OBD_ALLOC(type, sizeof(*type));
+ type = kzalloc(sizeof(*type), GFP_NOFS);
if (type == NULL)
return rc;
- OBD_ALLOC_PTR(type->typ_dt_ops);
- OBD_ALLOC_PTR(type->typ_md_ops);
- OBD_ALLOC(type->typ_name, strlen(name) + 1);
+ type->typ_dt_ops = kzalloc(sizeof(*type->typ_dt_ops), GFP_NOFS);
+ type->typ_md_ops = kzalloc(sizeof(*type->typ_md_ops), GFP_NOFS);
+ type->typ_name = kzalloc(strlen(name) + 1, GFP_NOFS);
if (type->typ_dt_ops == NULL ||
type->typ_md_ops == NULL ||
@@ -191,11 +191,19 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
strcpy(type->typ_name, name);
spin_lock_init(&type->obd_type_lock);
- type->typ_procroot = lprocfs_register(type->typ_name, proc_lustre_root,
- vars, type);
- if (IS_ERR(type->typ_procroot)) {
- rc = PTR_ERR(type->typ_procroot);
- type->typ_procroot = NULL;
+ type->typ_debugfs_entry = ldebugfs_register(type->typ_name,
+ debugfs_lustre_root,
+ NULL, type);
+ if (IS_ERR_OR_NULL(type->typ_debugfs_entry)) {
+ rc = type->typ_debugfs_entry ? PTR_ERR(type->typ_debugfs_entry)
+ : -ENOMEM;
+ type->typ_debugfs_entry = NULL;
+ goto failed;
+ }
+
+ type->typ_kobj = kobject_create_and_add(type->typ_name, lustre_kobj);
+ if (!type->typ_kobj) {
+ rc = -ENOMEM;
goto failed;
}
@@ -213,13 +221,12 @@ int class_register_type(struct obd_ops *dt_ops, struct md_ops *md_ops,
return 0;
failed:
- if (type->typ_name != NULL)
- OBD_FREE(type->typ_name, strlen(name) + 1);
- if (type->typ_md_ops != NULL)
- OBD_FREE_PTR(type->typ_md_ops);
- if (type->typ_dt_ops != NULL)
- OBD_FREE_PTR(type->typ_dt_ops);
- OBD_FREE(type, sizeof(*type));
+ if (type->typ_kobj)
+ kobject_put(type->typ_kobj);
+ kfree(type->typ_name);
+ kfree(type->typ_md_ops);
+ kfree(type->typ_dt_ops);
+ kfree(type);
return rc;
}
EXPORT_SYMBOL(class_register_type);
@@ -237,14 +244,16 @@ int class_unregister_type(const char *name)
CERROR("type %s has refcount (%d)\n", name, type->typ_refcnt);
/* This is a bad situation, let's make the best of it */
/* Remove ops, but leave the name for debugging */
- OBD_FREE_PTR(type->typ_dt_ops);
- OBD_FREE_PTR(type->typ_md_ops);
+ kfree(type->typ_dt_ops);
+ kfree(type->typ_md_ops);
return -EBUSY;
}
- if (type->typ_procroot) {
- lprocfs_remove(&type->typ_procroot);
- }
+ if (type->typ_kobj)
+ kobject_put(type->typ_kobj);
+
+ if (!IS_ERR_OR_NULL(type->typ_debugfs_entry))
+ ldebugfs_remove(&type->typ_debugfs_entry);
if (type->typ_lu)
lu_device_type_fini(type->typ_lu);
@@ -252,12 +261,10 @@ int class_unregister_type(const char *name)
spin_lock(&obd_types_lock);
list_del(&type->typ_chain);
spin_unlock(&obd_types_lock);
- OBD_FREE(type->typ_name, strlen(name) + 1);
- if (type->typ_dt_ops != NULL)
- OBD_FREE_PTR(type->typ_dt_ops);
- if (type->typ_md_ops != NULL)
- OBD_FREE_PTR(type->typ_md_ops);
- OBD_FREE(type, sizeof(*type));
+ kfree(type->typ_name);
+ kfree(type->typ_dt_ops);
+ kfree(type->typ_md_ops);
+ kfree(type);
return 0;
} /* class_unregister_type */
EXPORT_SYMBOL(class_unregister_type);
@@ -819,7 +826,7 @@ struct obd_export *class_new_export(struct obd_device *obd,
struct cfs_hash *hash = NULL;
int rc = 0;
- OBD_ALLOC_PTR(export);
+ export = kzalloc(sizeof(*export), GFP_NOFS);
if (!export)
return ERR_PTR(-ENOMEM);
@@ -904,7 +911,7 @@ exit_err:
class_handle_unhash(&export->exp_handle);
LASSERT(hlist_unhashed(&export->exp_uuid_hash));
obd_destroy_export(export);
- OBD_FREE_PTR(export);
+ kfree(export);
return ERR_PTR(rc);
}
EXPORT_SYMBOL(class_new_export);
@@ -945,7 +952,7 @@ static void class_import_destroy(struct obd_import *imp)
struct obd_import_conn, oic_item);
list_del_init(&imp_conn->oic_item);
ptlrpc_put_connection_superhack(imp_conn->oic_conn);
- OBD_FREE(imp_conn, sizeof(*imp_conn));
+ kfree(imp_conn);
}
LASSERT(imp->imp_sec == NULL);
@@ -1008,7 +1015,7 @@ struct obd_import *class_new_import(struct obd_device *obd)
{
struct obd_import *imp;
- OBD_ALLOC(imp, sizeof(*imp));
+ imp = kzalloc(sizeof(*imp), GFP_NOFS);
if (imp == NULL)
return NULL;
@@ -1811,7 +1818,7 @@ void *kuc_alloc(int payload_len, int transport, int type)
struct kuc_hdr *lh;
int len = kuc_len(payload_len);
- OBD_ALLOC(lh, len);
+ lh = kzalloc(len, GFP_NOFS);
if (lh == NULL)
return ERR_PTR(-ENOMEM);
@@ -1828,6 +1835,6 @@ EXPORT_SYMBOL(kuc_alloc);
inline void kuc_free(void *p, int payload_len)
{
struct kuc_hdr *lh = kuc_ptr(p);
- OBD_FREE(lh, kuc_len(payload_len));
+ kfree(lh);
}
EXPORT_SYMBOL(kuc_free);
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index 06944b863d16ec..e3c6dcb42cffb3 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -53,7 +53,6 @@
#include <linux/fcntl.h>
#include <linux/delay.h>
#include <linux/skbuff.h>
-#include <linux/proc_fs.h>
#include <linux/fs.h>
#include <linux/poll.h>
#include <linux/list.h>
@@ -64,6 +63,7 @@
#include <linux/uaccess.h>
#include <linux/miscdevice.h>
#include <linux/seq_file.h>
+#include <linux/kobject.h>
#include "../../../include/linux/libcfs/libcfs.h"
#include "../../../include/linux/lnet/lnetctl.h"
@@ -216,29 +216,27 @@ struct miscdevice obd_psdev = {
};
-#if defined (CONFIG_PROC_FS)
-static int obd_proc_version_seq_show(struct seq_file *m, void *v)
+static ssize_t version_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- seq_printf(m, "lustre: %s\nkernel: %s\nbuild: %s\n",
- LUSTRE_VERSION_STRING, "patchless_client", BUILD_VERSION);
- return 0;
+ return sprintf(buf, "%s\n", LUSTRE_VERSION_STRING);
}
-LPROC_SEQ_FOPS_RO(obd_proc_version);
-int obd_proc_pinger_seq_show(struct seq_file *m, void *v)
+static ssize_t pinger_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- seq_printf(m, "%s\n", "on");
- return 0;
+ return sprintf(buf, "%s\n", "on");
}
-LPROC_SEQ_FOPS_RO(obd_proc_pinger);
-static int obd_proc_health_seq_show(struct seq_file *m, void *v)
+static ssize_t health_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
bool healthy = true;
int i;
+ size_t len = 0;
if (libcfs_catastrophe)
- seq_printf(m, "LBUG\n");
+ return sprintf(buf, "LBUG\n");
read_lock(&obd_dev_lock);
for (i = 0; i < class_devno_max(); i++) {
@@ -256,8 +254,6 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
read_unlock(&obd_dev_lock);
if (obd_health_check(NULL, obd)) {
- seq_printf(m, "device %s reported unhealthy\n",
- obd->obd_name);
healthy = false;
}
class_decref(obd, __func__, current);
@@ -266,32 +262,29 @@ static int obd_proc_health_seq_show(struct seq_file *m, void *v)
read_unlock(&obd_dev_lock);
if (healthy)
- seq_puts(m, "healthy\n");
+ len = sprintf(buf, "healthy\n");
else
- seq_puts(m, "NOT HEALTHY\n");
+ len = sprintf(buf, "NOT HEALTHY\n");
- return 0;
+ return len;
}
-LPROC_SEQ_FOPS_RO(obd_proc_health);
-static int obd_proc_jobid_var_seq_show(struct seq_file *m, void *v)
+static ssize_t jobid_var_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- seq_printf(m, "%s\n", obd_jobid_var);
- return 0;
+ return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_var);
}
-static ssize_t obd_proc_jobid_var_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t jobid_var_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
if (!count || count > JOBSTATS_JOBID_VAR_MAX_LEN)
return -EINVAL;
memset(obd_jobid_var, 0, JOBSTATS_JOBID_VAR_MAX_LEN + 1);
- /* This might leave the var invalid on error, which is probably fine.*/
- if (copy_from_user(obd_jobid_var, buffer, count))
- return -EFAULT;
+ memcpy(obd_jobid_var, buffer, count);
/* Trim the trailing '\n' if any */
if (obd_jobid_var[count - 1] == '\n')
@@ -299,23 +292,21 @@ static ssize_t obd_proc_jobid_var_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(obd_proc_jobid_var);
-static int obd_proc_jobid_name_seq_show(struct seq_file *m, void *v)
+static ssize_t jobid_name_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- seq_printf(m, "%s\n", obd_jobid_var);
- return 0;
+ return snprintf(buf, PAGE_SIZE, "%s\n", obd_jobid_node);
}
-static ssize_t obd_proc_jobid_name_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
if (!count || count > JOBSTATS_JOBID_SIZE)
return -EINVAL;
- if (copy_from_user(obd_jobid_node, buffer, count))
- return -EFAULT;
+ memcpy(obd_jobid_node, buffer, count);
obd_jobid_node[count] = 0;
@@ -325,20 +316,24 @@ static ssize_t obd_proc_jobid_name_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(obd_proc_jobid_name);
-
-/* Root for /proc/fs/lustre */
-struct proc_dir_entry *proc_lustre_root = NULL;
-EXPORT_SYMBOL(proc_lustre_root);
-
-struct lprocfs_vars lprocfs_base[] = {
- { "version", &obd_proc_version_fops },
- { "pinger", &obd_proc_pinger_fops },
- { "health_check", &obd_proc_health_fops },
- { "jobid_var", &obd_proc_jobid_var_fops },
- { .name = "jobid_name",
- .fops = &obd_proc_jobid_name_fops},
- { NULL }
+
+/* Root for /sys/kernel/debug/lustre */
+struct dentry *debugfs_lustre_root;
+EXPORT_SYMBOL_GPL(debugfs_lustre_root);
+
+LUSTRE_RO_ATTR(version);
+LUSTRE_RO_ATTR(pinger);
+LUSTRE_RO_ATTR(health);
+LUSTRE_RW_ATTR(jobid_var);
+LUSTRE_RW_ATTR(jobid_name);
+
+static struct attribute *lustre_attrs[] = {
+ &lustre_attr_version.attr,
+ &lustre_attr_pinger.attr,
+ &lustre_attr_health.attr,
+ &lustre_attr_jobid_name.attr,
+ &lustre_attr_jobid_var.attr,
+ NULL,
};
static void *obd_device_list_seq_start(struct seq_file *p, loff_t *pos)
@@ -406,7 +401,7 @@ static int obd_device_list_open(struct inode *inode, struct file *file)
return rc;
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private;
return 0;
}
@@ -419,31 +414,57 @@ struct file_operations obd_device_list_fops = {
.release = seq_release,
};
+struct kobject *lustre_kobj;
+EXPORT_SYMBOL_GPL(lustre_kobj);
+
+static struct attribute_group lustre_attr_group = {
+ .attrs = lustre_attrs,
+};
+
int class_procfs_init(void)
{
int rc = 0;
+ struct dentry *file;
+
+ lustre_kobj = kobject_create_and_add("lustre", fs_kobj);
+ if (lustre_kobj == NULL)
+ goto out;
+
+ /* Create the files associated with this kobject */
+ rc = sysfs_create_group(lustre_kobj, &lustre_attr_group);
+ if (rc) {
+ kobject_put(lustre_kobj);
+ goto out;
+ }
- proc_lustre_root = lprocfs_register("fs/lustre", NULL,
- lprocfs_base, NULL);
- if (IS_ERR(proc_lustre_root)) {
- rc = PTR_ERR(proc_lustre_root);
- proc_lustre_root = NULL;
+ debugfs_lustre_root = debugfs_create_dir("lustre", NULL);
+ if (IS_ERR_OR_NULL(debugfs_lustre_root)) {
+ rc = debugfs_lustre_root ? PTR_ERR(debugfs_lustre_root)
+ : -ENOMEM;
+ debugfs_lustre_root = NULL;
+ kobject_put(lustre_kobj);
goto out;
}
- rc = lprocfs_seq_create(proc_lustre_root, "devices", 0444,
- &obd_device_list_fops, NULL);
+ file = debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL,
+ &obd_device_list_fops);
+ if (IS_ERR_OR_NULL(file)) {
+ rc = file ? PTR_ERR(file) : -ENOMEM;
+ kobject_put(lustre_kobj);
+ goto out;
+ }
out:
- if (rc)
- CERROR("error adding /proc/fs/lustre/devices file\n");
- return 0;
+ return rc;
}
int class_procfs_clean(void)
{
- if (proc_lustre_root) {
- lprocfs_remove(&proc_lustre_root);
- }
+ if (debugfs_lustre_root != NULL)
+ debugfs_remove_recursive(debugfs_lustre_root);
+
+ debugfs_lustre_root = NULL;
+
+ kobject_put(lustre_kobj);
+
return 0;
}
-#endif /* CONFIG_PROC_FS */
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index 4b62d25764ad79..54f0a81f7b518d 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -38,7 +38,6 @@
#include <linux/sysctl.h>
#include <linux/sched.h>
#include <linux/mm.h>
-#include <linux/proc_fs.h>
#include <linux/slab.h>
#include <linux/stat.h>
#include <linux/ctype.h>
@@ -55,30 +54,6 @@
static struct ctl_table_header *obd_table_header;
#endif
-
-#define OBD_SYSCTL 300
-
-enum {
- OBD_TIMEOUT = 3, /* RPC timeout before recovery/intr */
- OBD_DUMP_ON_TIMEOUT, /* dump kernel debug log upon eviction */
- OBD_MEMUSED, /* bytes currently OBD_ALLOCated */
- OBD_PAGESUSED, /* pages currently OBD_PAGE_ALLOCated */
- OBD_MAXMEMUSED, /* maximum bytes OBD_ALLOCated concurrently */
- OBD_MAXPAGESUSED, /* maximum pages OBD_PAGE_ALLOCated concurrently */
- OBD_SYNCFILTER, /* XXX temporary, as we play with sync osts.. */
- OBD_LDLM_TIMEOUT, /* LDLM timeout for ASTs before client eviction */
- OBD_DUMP_ON_EVICTION, /* dump kernel debug log upon eviction */
- OBD_DEBUG_PEER_ON_TIMEOUT, /* dump peer debug when RPC times out */
- OBD_ALLOC_FAIL_RATE, /* memory allocation random failure rate */
- OBD_MAX_DIRTY_PAGES, /* maximum dirty pages */
- OBD_AT_MIN, /* Adaptive timeouts params */
- OBD_AT_MAX,
- OBD_AT_EXTRA,
- OBD_AT_EARLY_MARGIN,
- OBD_AT_HISTORY,
-};
-
-
#ifdef CONFIG_SYSCTL
static int proc_set_timeout(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
diff --git a/drivers/staging/lustre/lustre/obdclass/llog.c b/drivers/staging/lustre/lustre/obdclass/llog.c
index 114be4a78ccfd5..4fa52d1b79d122 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog.c
@@ -60,7 +60,7 @@ static struct llog_handle *llog_alloc_handle(void)
{
struct llog_handle *loghandle;
- OBD_ALLOC_PTR(loghandle);
+ loghandle = kzalloc(sizeof(*loghandle), GFP_NOFS);
if (loghandle == NULL)
return NULL;
@@ -88,9 +88,9 @@ static void llog_free_handle(struct llog_handle *loghandle)
else if (loghandle->lgh_hdr->llh_flags & LLOG_F_IS_CAT)
LASSERT(list_empty(&loghandle->u.chd.chd_head));
LASSERT(sizeof(*(loghandle->lgh_hdr)) == LLOG_CHUNK_SIZE);
- OBD_FREE(loghandle->lgh_hdr, LLOG_CHUNK_SIZE);
+ kfree(loghandle->lgh_hdr);
out:
- OBD_FREE_PTR(loghandle);
+ kfree(loghandle);
}
void llog_handle_get(struct llog_handle *loghandle)
@@ -207,7 +207,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
LASSERT(handle->lgh_hdr == NULL);
- OBD_ALLOC_PTR(llh);
+ llh = kzalloc(sizeof(*llh), GFP_NOFS);
if (llh == NULL)
return -ENOMEM;
handle->lgh_hdr = llh;
@@ -261,7 +261,7 @@ int llog_init_handle(const struct lu_env *env, struct llog_handle *handle,
}
out:
if (rc) {
- OBD_FREE_PTR(llh);
+ kfree(llh);
handle->lgh_hdr = NULL;
}
return rc;
@@ -283,7 +283,7 @@ static int llog_process_thread(void *arg)
LASSERT(llh);
- OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
+ buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS);
if (!buf) {
lpi->lpi_rc = -ENOMEM;
return 0;
@@ -400,7 +400,7 @@ out:
if (cd != NULL)
cd->lpcd_last_idx = last_called_index;
- OBD_FREE(buf, LLOG_CHUNK_SIZE);
+ kfree(buf);
lpi->lpi_rc = rc;
return 0;
}
@@ -434,7 +434,7 @@ int llog_process_or_fork(const struct lu_env *env,
struct llog_process_info *lpi;
int rc;
- OBD_ALLOC_PTR(lpi);
+ lpi = kzalloc(sizeof(*lpi), GFP_NOFS);
if (lpi == NULL) {
CERROR("cannot alloc pointer\n");
return -ENOMEM;
@@ -454,7 +454,7 @@ int llog_process_or_fork(const struct lu_env *env,
if (IS_ERR_VALUE(rc)) {
CERROR("%s: cannot start thread: rc = %d\n",
loghandle->lgh_ctxt->loc_obd->obd_name, rc);
- OBD_FREE_PTR(lpi);
+ kfree(lpi);
return rc;
}
wait_for_completion(&lpi->lpi_completion);
@@ -463,7 +463,7 @@ int llog_process_or_fork(const struct lu_env *env,
llog_process_thread(lpi);
}
rc = lpi->lpi_rc;
- OBD_FREE_PTR(lpi);
+ kfree(lpi);
return rc;
}
EXPORT_SYMBOL(llog_process_or_fork);
@@ -484,7 +484,7 @@ int llog_reverse_process(const struct lu_env *env,
void *buf;
int rc = 0, first_index = 1, index, idx;
- OBD_ALLOC(buf, LLOG_CHUNK_SIZE);
+ buf = kzalloc(LLOG_CHUNK_SIZE, GFP_NOFS);
if (!buf)
return -ENOMEM;
@@ -563,8 +563,7 @@ int llog_reverse_process(const struct lu_env *env,
}
out:
- if (buf)
- OBD_FREE(buf, LLOG_CHUNK_SIZE);
+ kfree(buf);
return rc;
}
EXPORT_SYMBOL(llog_reverse_process);
diff --git a/drivers/staging/lustre/lustre/obdclass/llog_obd.c b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
index 978d886a110393..81ab27e7376f12 100644
--- a/drivers/staging/lustre/lustre/obdclass/llog_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/llog_obd.c
@@ -46,7 +46,7 @@ static struct llog_ctxt *llog_new_ctxt(struct obd_device *obd)
{
struct llog_ctxt *ctxt;
- OBD_ALLOC_PTR(ctxt);
+ ctxt = kzalloc(sizeof(*ctxt), GFP_NOFS);
if (!ctxt)
return NULL;
@@ -66,7 +66,7 @@ static void llog_ctxt_destroy(struct llog_ctxt *ctxt)
class_import_put(ctxt->loc_imp);
ctxt->loc_imp = NULL;
}
- OBD_FREE_PTR(ctxt);
+ kfree(ctxt);
}
int __llog_ctxt_put(const struct lu_env *env, struct llog_ctxt *ctxt)
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index c171c6c6c457cd..17e7c18078639d 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -221,8 +221,6 @@ int lprocfs_write_frac_helper(const char __user *buffer, unsigned long count,
}
EXPORT_SYMBOL(lprocfs_write_frac_helper);
-#if defined (CONFIG_PROC_FS)
-
static int lprocfs_no_percpu_stats;
module_param(lprocfs_no_percpu_stats, int, 0644);
MODULE_PARM_DESC(lprocfs_no_percpu_stats, "Do not alloc percpu data for lprocfs stats");
@@ -243,11 +241,11 @@ EXPORT_SYMBOL(lprocfs_seq_release);
/* lprocfs API calls */
-struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root,
- char *name, void *data,
- struct file_operations *fops)
+struct dentry *ldebugfs_add_simple(struct dentry *root,
+ char *name, void *data,
+ struct file_operations *fops)
{
- struct proc_dir_entry *proc;
+ struct dentry *entry;
umode_t mode = 0;
if (root == NULL || name == NULL || fops == NULL)
@@ -257,26 +255,26 @@ struct proc_dir_entry *lprocfs_add_simple(struct proc_dir_entry *root,
mode = 0444;
if (fops->write)
mode |= 0200;
- proc = proc_create_data(name, mode, root, fops, data);
- if (!proc) {
- CERROR("LprocFS: No memory to create /proc entry %s", name);
- return ERR_PTR(-ENOMEM);
+ entry = debugfs_create_file(name, mode, root, data, fops);
+ if (IS_ERR_OR_NULL(entry)) {
+ CERROR("LprocFS: No memory to create <debugfs> entry %s", name);
+ return entry ?: ERR_PTR(-ENOMEM);
}
- return proc;
+ return entry;
}
-EXPORT_SYMBOL(lprocfs_add_simple);
+EXPORT_SYMBOL(ldebugfs_add_simple);
-struct proc_dir_entry *lprocfs_add_symlink(const char *name,
- struct proc_dir_entry *parent, const char *format, ...)
+struct dentry *ldebugfs_add_symlink(const char *name, struct dentry *parent,
+ const char *format, ...)
{
- struct proc_dir_entry *entry;
+ struct dentry *entry;
char *dest;
va_list ap;
if (parent == NULL || format == NULL)
return NULL;
- OBD_ALLOC_WAIT(dest, MAX_STRING_SIZE + 1);
+ dest = kzalloc(MAX_STRING_SIZE + 1, GFP_KERNEL);
if (dest == NULL)
return NULL;
@@ -284,37 +282,29 @@ struct proc_dir_entry *lprocfs_add_symlink(const char *name,
vsnprintf(dest, MAX_STRING_SIZE, format, ap);
va_end(ap);
- entry = proc_symlink(name, parent, dest);
- if (entry == NULL)
- CERROR("LprocFS: Could not create symbolic link from %s to %s",
+ entry = debugfs_create_symlink(name, parent, dest);
+ if (IS_ERR_OR_NULL(entry)) {
+ CERROR("LdebugFS: Could not create symbolic link from %s to %s",
name, dest);
+ entry = NULL;
+ }
- OBD_FREE(dest, MAX_STRING_SIZE + 1);
+ kfree(dest);
return entry;
}
-EXPORT_SYMBOL(lprocfs_add_symlink);
+EXPORT_SYMBOL(ldebugfs_add_symlink);
static struct file_operations lprocfs_generic_fops = { };
-/**
- * Add /proc entries.
- *
- * \param root [in] The parent proc entry on which new entry will be added.
- * \param list [in] Array of proc entries to be added.
- * \param data [in] The argument to be passed when entries read/write routines
- * are called through /proc file.
- *
- * \retval 0 on success
- * < 0 on error
- */
-int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
- void *data)
+int ldebugfs_add_vars(struct dentry *parent,
+ struct lprocfs_vars *list,
+ void *data)
{
- if (root == NULL || list == NULL)
+ if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list))
return -EINVAL;
while (list->name != NULL) {
- struct proc_dir_entry *proc;
+ struct dentry *entry;
umode_t mode = 0;
if (list->proc_mode != 0000) {
@@ -325,54 +315,50 @@ int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
if (list->fops->write)
mode |= 0200;
}
- proc = proc_create_data(list->name, mode, root,
- list->fops ?: &lprocfs_generic_fops,
- list->data ?: data);
- if (proc == NULL)
- return -ENOMEM;
+ entry = debugfs_create_file(list->name, mode, parent,
+ list->data ?: data,
+ list->fops ?: &lprocfs_generic_fops
+ );
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
list++;
}
return 0;
}
-EXPORT_SYMBOL(lprocfs_add_vars);
-
-void lprocfs_remove(struct proc_dir_entry **rooth)
-{
- proc_remove(*rooth);
- *rooth = NULL;
-}
-EXPORT_SYMBOL(lprocfs_remove);
+EXPORT_SYMBOL(ldebugfs_add_vars);
-void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent)
+void ldebugfs_remove(struct dentry **entryp)
{
- LASSERT(parent != NULL);
- remove_proc_entry(name, parent);
+ debugfs_remove(*entryp);
+ *entryp = NULL;
}
-EXPORT_SYMBOL(lprocfs_remove_proc_entry);
+EXPORT_SYMBOL(ldebugfs_remove);
-struct proc_dir_entry *lprocfs_register(const char *name,
- struct proc_dir_entry *parent,
- struct lprocfs_vars *list, void *data)
+struct dentry *ldebugfs_register(const char *name,
+ struct dentry *parent,
+ struct lprocfs_vars *list, void *data)
{
- struct proc_dir_entry *entry;
+ struct dentry *entry;
- entry = proc_mkdir(name, parent);
- if (entry == NULL) {
- entry = ERR_PTR(-ENOMEM);
+ entry = debugfs_create_dir(name, parent);
+ if (IS_ERR_OR_NULL(entry)) {
+ entry = entry ?: ERR_PTR(-ENOMEM);
goto out;
}
- if (list != NULL) {
- int rc = lprocfs_add_vars(entry, list, data);
+ if (!IS_ERR_OR_NULL(list)) {
+ int rc;
+
+ rc = ldebugfs_add_vars(entry, list, data);
if (rc != 0) {
- lprocfs_remove(&entry);
+ debugfs_remove(entry);
entry = ERR_PTR(rc);
}
}
out:
return entry;
}
-EXPORT_SYMBOL(lprocfs_register);
+EXPORT_SYMBOL(ldebugfs_register);
/* Generic callbacks */
int lprocfs_rd_uint(struct seq_file *m, void *data)
@@ -437,15 +423,15 @@ int lprocfs_wr_atomic(struct file *file, const char __user *buffer,
}
EXPORT_SYMBOL(lprocfs_wr_atomic);
-int lprocfs_rd_uuid(struct seq_file *m, void *data)
+static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- LASSERT(obd != NULL);
- seq_printf(m, "%s\n", obd->obd_uuid.uuid);
- return 0;
+ return sprintf(buf, "%s\n", obd->obd_uuid.uuid);
}
-EXPORT_SYMBOL(lprocfs_rd_uuid);
+LUSTRE_RO_ATTR(uuid);
int lprocfs_rd_name(struct seq_file *m, void *data)
{
@@ -457,23 +443,27 @@ int lprocfs_rd_name(struct seq_file *m, void *data)
}
EXPORT_SYMBOL(lprocfs_rd_name);
-int lprocfs_rd_blksize(struct seq_file *m, void *data)
+static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%u\n", osfs.os_bsize);
+ return sprintf(buf, "%u\n", osfs.os_bsize);
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_blksize);
+LUSTRE_RO_ATTR(blocksize);
-int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
+static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -485,16 +475,18 @@ int lprocfs_rd_kbytestotal(struct seq_file *m, void *data)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ return sprintf(buf, "%llu\n", result);
}
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_kbytestotal);
+LUSTRE_RO_ATTR(kbytestotal);
-int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
+static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -506,16 +498,18 @@ int lprocfs_rd_kbytesfree(struct seq_file *m, void *data)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ return sprintf(buf, "%llu\n", result);
}
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_kbytesfree);
+LUSTRE_RO_ATTR(kbytesfree);
-int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
+static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
@@ -527,40 +521,44 @@ int lprocfs_rd_kbytesavail(struct seq_file *m, void *data)
while (blk_size >>= 1)
result <<= 1;
- seq_printf(m, "%llu\n", result);
+ return sprintf(buf, "%llu\n", result);
}
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_kbytesavail);
+LUSTRE_RO_ATTR(kbytesavail);
-int lprocfs_rd_filestotal(struct seq_file *m, void *data)
+static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%llu\n", osfs.os_files);
+ return sprintf(buf, "%llu\n", osfs.os_files);
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_filestotal);
+LUSTRE_RO_ATTR(filestotal);
-int lprocfs_rd_filesfree(struct seq_file *m, void *data)
+static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct obd_statfs osfs;
int rc = obd_statfs(NULL, obd->obd_self_export, &osfs,
cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS),
OBD_STATFS_NODELAY);
if (!rc)
- seq_printf(m, "%llu\n", osfs.os_ffree);
+ return sprintf(buf, "%llu\n", osfs.os_ffree);
return rc;
}
-EXPORT_SYMBOL(lprocfs_rd_filesfree);
+LUSTRE_RO_ATTR(filesfree);
int lprocfs_rd_server_uuid(struct seq_file *m, void *data)
{
@@ -930,43 +928,62 @@ int lprocfs_rd_connect_flags(struct seq_file *m, void *data)
}
EXPORT_SYMBOL(lprocfs_rd_connect_flags);
-int lprocfs_rd_num_exports(struct seq_file *m, void *data)
-{
- struct obd_device *obd = data;
-
- LASSERT(obd != NULL);
- seq_printf(m, "%u\n", obd->obd_num_exports);
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_rd_num_exports);
+static struct attribute *obd_def_attrs[] = {
+ &lustre_attr_blocksize.attr,
+ &lustre_attr_kbytestotal.attr,
+ &lustre_attr_kbytesfree.attr,
+ &lustre_attr_kbytesavail.attr,
+ &lustre_attr_filestotal.attr,
+ &lustre_attr_filesfree.attr,
+ &lustre_attr_uuid.attr,
+ NULL,
+};
-int lprocfs_rd_numrefs(struct seq_file *m, void *data)
+static void obd_sysfs_release(struct kobject *kobj)
{
- struct obd_type *class = (struct obd_type *) data;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- LASSERT(class != NULL);
- seq_printf(m, "%d\n", class->typ_refcnt);
- return 0;
+ complete(&obd->obd_kobj_unregister);
}
-EXPORT_SYMBOL(lprocfs_rd_numrefs);
-int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list)
+static struct kobj_type obd_ktype = {
+ .default_attrs = obd_def_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = obd_sysfs_release,
+};
+
+int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
+ struct attribute_group *attrs)
{
int rc = 0;
- LASSERT(obd != NULL);
- LASSERT(obd->obd_magic == OBD_DEVICE_MAGIC);
- LASSERT(obd->obd_type->typ_procroot != NULL);
-
- obd->obd_proc_entry = lprocfs_register(obd->obd_name,
- obd->obd_type->typ_procroot,
- list, obd);
- if (IS_ERR(obd->obd_proc_entry)) {
- rc = PTR_ERR(obd->obd_proc_entry);
+ init_completion(&obd->obd_kobj_unregister);
+ rc = kobject_init_and_add(&obd->obd_kobj, &obd_ktype,
+ obd->obd_type->typ_kobj,
+ "%s", obd->obd_name);
+ if (rc)
+ return rc;
+
+ if (attrs) {
+ rc = sysfs_create_group(&obd->obd_kobj, attrs);
+ if (rc) {
+ kobject_put(&obd->obd_kobj);
+ return rc;
+ }
+ }
+
+ obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
+ obd->obd_type->typ_debugfs_entry,
+ list, obd);
+ if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
+ rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
+ : -ENOMEM;
CERROR("error %d setting up lprocfs for %s\n",
rc, obd->obd_name);
- obd->obd_proc_entry = NULL;
+ obd->obd_debugfs_entry = NULL;
}
+
return rc;
}
EXPORT_SYMBOL(lprocfs_obd_setup);
@@ -975,58 +992,16 @@ int lprocfs_obd_cleanup(struct obd_device *obd)
{
if (!obd)
return -EINVAL;
- if (obd->obd_proc_exports_entry) {
- /* Should be no exports left */
- lprocfs_remove(&obd->obd_proc_exports_entry);
- obd->obd_proc_exports_entry = NULL;
- }
- if (obd->obd_proc_entry) {
- lprocfs_remove(&obd->obd_proc_entry);
- obd->obd_proc_entry = NULL;
- }
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_obd_cleanup);
-
-static void lprocfs_free_client_stats(struct nid_stat *client_stat)
-{
- CDEBUG(D_CONFIG, "stat %p - data %p/%p\n", client_stat,
- client_stat->nid_proc, client_stat->nid_stats);
-
- LASSERTF(atomic_read(&client_stat->nid_exp_ref_count) == 0,
- "nid %s:count %d\n", libcfs_nid2str(client_stat->nid),
- atomic_read(&client_stat->nid_exp_ref_count));
-
- if (client_stat->nid_proc)
- lprocfs_remove(&client_stat->nid_proc);
- if (client_stat->nid_stats)
- lprocfs_free_stats(&client_stat->nid_stats);
+ if (!IS_ERR_OR_NULL(obd->obd_debugfs_entry))
+ ldebugfs_remove(&obd->obd_debugfs_entry);
- if (client_stat->nid_ldlm_stats)
- lprocfs_free_stats(&client_stat->nid_ldlm_stats);
+ kobject_put(&obd->obd_kobj);
+ wait_for_completion(&obd->obd_kobj_unregister);
- OBD_FREE_PTR(client_stat);
- return;
-
-}
-
-void lprocfs_free_per_client_stats(struct obd_device *obd)
-{
- struct cfs_hash *hash = obd->obd_nid_stats_hash;
- struct nid_stat *stat;
-
- /* we need extra list - because hash_exit called to early */
- /* not need locking because all clients is died */
- while (!list_empty(&obd->obd_nid_stats)) {
- stat = list_entry(obd->obd_nid_stats.next,
- struct nid_stat, nid_list);
- list_del_init(&stat->nid_list);
- cfs_hash_del(hash, &stat->nid, &stat->nid_hash);
- lprocfs_free_client_stats(stat);
- }
+ return 0;
}
-EXPORT_SYMBOL(lprocfs_free_per_client_stats);
+EXPORT_SYMBOL(lprocfs_obd_cleanup);
int lprocfs_stats_alloc_one(struct lprocfs_stats *stats, unsigned int cpuid)
{
@@ -1257,8 +1232,10 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
rc = seq_open(file, &lprocfs_stats_seq_sops);
if (rc)
return rc;
+
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private;
+
return 0;
}
@@ -1271,20 +1248,21 @@ struct file_operations lprocfs_stats_seq_fops = {
.release = lprocfs_seq_release,
};
-int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
+int ldebugfs_register_stats(struct dentry *parent, const char *name,
struct lprocfs_stats *stats)
{
- struct proc_dir_entry *entry;
- LASSERT(root != NULL);
+ struct dentry *entry;
- entry = proc_create_data(name, 0644, root,
- &lprocfs_stats_seq_fops, stats);
- if (entry == NULL)
- return -ENOMEM;
+ LASSERT(!IS_ERR_OR_NULL(parent));
+
+ entry = debugfs_create_file(name, 0644, parent, stats,
+ &lprocfs_stats_seq_fops);
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
return 0;
}
-EXPORT_SYMBOL(lprocfs_register_stats);
+EXPORT_SYMBOL(ldebugfs_register_stats);
void lprocfs_counter_init(struct lprocfs_stats *stats, int index,
unsigned conf, const char *name, const char *units)
@@ -1388,7 +1366,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats)
int rc, i;
LASSERT(obd->obd_stats == NULL);
- LASSERT(obd->obd_proc_entry != NULL);
+ LASSERT(obd->obd_debugfs_entry != NULL);
LASSERT(obd->obd_cntr_base == 0);
num_stats = ((int)sizeof(*obd->obd_type->typ_dt_ops) / sizeof(void *)) +
@@ -1409,7 +1387,7 @@ int lprocfs_alloc_obd_stats(struct obd_device *obd, unsigned num_private_stats)
"Missing obd_stat initializer obd_op operation at offset %d.\n",
i - num_private_stats);
}
- rc = lprocfs_register_stats(obd->obd_proc_entry, "stats", stats);
+ rc = ldebugfs_register_stats(obd->obd_debugfs_entry, "stats", stats);
if (rc < 0) {
lprocfs_free_stats(&stats);
} else {
@@ -1479,7 +1457,7 @@ int lprocfs_alloc_md_stats(struct obd_device *obd,
int rc, i;
LASSERT(obd->md_stats == NULL);
- LASSERT(obd->obd_proc_entry != NULL);
+ LASSERT(obd->obd_debugfs_entry != NULL);
LASSERT(obd->md_cntr_base == 0);
num_stats = 1 + MD_COUNTER_OFFSET(revalidate_lock) +
@@ -1497,7 +1475,7 @@ int lprocfs_alloc_md_stats(struct obd_device *obd,
LBUG();
}
}
- rc = lprocfs_register_stats(obd->obd_proc_entry, "md_stats", stats);
+ rc = ldebugfs_register_stats(obd->obd_debugfs_entry, "md_stats", stats);
if (rc < 0) {
lprocfs_free_stats(&stats);
} else {
@@ -1543,241 +1521,8 @@ void lprocfs_init_ldlm_stats(struct lprocfs_stats *ldlm_stats)
}
EXPORT_SYMBOL(lprocfs_init_ldlm_stats);
-int lprocfs_exp_print_uuid(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- struct hlist_node *hnode, void *data)
-
-{
- struct obd_export *exp = cfs_hash_object(hs, hnode);
- struct seq_file *m = (struct seq_file *)data;
-
- if (exp->exp_nid_stats)
- seq_printf(m, "%s\n", obd_uuid2str(&exp->exp_client_uuid));
-
- return 0;
-}
-
-static int
-lproc_exp_uuid_seq_show(struct seq_file *m, void *unused)
-{
- struct nid_stat *stats = (struct nid_stat *)m->private;
- struct obd_device *obd = stats->nid_obd;
-
- cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
- lprocfs_exp_print_uuid, m);
- return 0;
-}
-
-LPROC_SEQ_FOPS_RO(lproc_exp_uuid);
-
-struct exp_hash_cb_data {
- struct seq_file *m;
- bool first;
-};
-
-int lprocfs_exp_print_hash(struct cfs_hash *hs, struct cfs_hash_bd *bd,
- struct hlist_node *hnode, void *cb_data)
-
-{
- struct exp_hash_cb_data *data = (struct exp_hash_cb_data *)cb_data;
- struct obd_export *exp = cfs_hash_object(hs, hnode);
-
- if (exp->exp_lock_hash != NULL) {
- if (data->first) {
- cfs_hash_debug_header(data->m);
- data->first = false;
- }
- cfs_hash_debug_str(hs, data->m);
- }
-
- return 0;
-}
-
-static int
-lproc_exp_hash_seq_show(struct seq_file *m, void *unused)
-{
- struct nid_stat *stats = (struct nid_stat *)m->private;
- struct obd_device *obd = stats->nid_obd;
- struct exp_hash_cb_data cb_data = {
- .m = m,
- .first = true
- };
-
- cfs_hash_for_each_key(obd->obd_nid_hash, &stats->nid,
- lprocfs_exp_print_hash, &cb_data);
- return 0;
-}
-
-LPROC_SEQ_FOPS_RO(lproc_exp_hash);
-
-int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data)
-{
- seq_printf(m, "%s\n",
- "Write into this file to clear all nid stats and stale nid entries");
- return 0;
-}
-EXPORT_SYMBOL(lprocfs_nid_stats_clear_read);
-
-static int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
-{
- struct nid_stat *stat = obj;
-
- CDEBUG(D_INFO, "refcnt %d\n", atomic_read(&stat->nid_exp_ref_count));
- if (atomic_read(&stat->nid_exp_ref_count) == 1) {
- /* object has only hash references. */
- spin_lock(&stat->nid_obd->obd_nid_lock);
- list_move(&stat->nid_list, data);
- spin_unlock(&stat->nid_obd->obd_nid_lock);
- return 1;
- }
- /* we has reference to object - only clear data*/
- if (stat->nid_stats)
- lprocfs_clear_stats(stat->nid_stats);
-
- return 0;
-}
-
-int lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
- unsigned long count, void *data)
-{
- struct obd_device *obd = (struct obd_device *)data;
- struct nid_stat *client_stat;
- LIST_HEAD(free_list);
-
- cfs_hash_cond_del(obd->obd_nid_stats_hash,
- lprocfs_nid_stats_clear_write_cb, &free_list);
-
- while (!list_empty(&free_list)) {
- client_stat = list_entry(free_list.next, struct nid_stat,
- nid_list);
- list_del_init(&client_stat->nid_list);
- lprocfs_free_client_stats(client_stat);
- }
-
- return count;
-}
-EXPORT_SYMBOL(lprocfs_nid_stats_clear_write);
-
-int lprocfs_exp_setup(struct obd_export *exp, lnet_nid_t *nid, int *newnid)
-{
- struct nid_stat *new_stat, *old_stat;
- struct obd_device *obd = NULL;
- struct proc_dir_entry *entry;
- char *buffer = NULL;
- int rc = 0;
-
- *newnid = 0;
-
- if (!exp || !exp->exp_obd || !exp->exp_obd->obd_proc_exports_entry ||
- !exp->exp_obd->obd_nid_stats_hash)
- return -EINVAL;
-
- /* not test against zero because eric say:
- * You may only test nid against another nid, or LNET_NID_ANY.
- * Anything else is nonsense.*/
- if (!nid || *nid == LNET_NID_ANY)
- return 0;
-
- obd = exp->exp_obd;
-
- CDEBUG(D_CONFIG, "using hash %p\n", obd->obd_nid_stats_hash);
-
- OBD_ALLOC_PTR(new_stat);
- if (new_stat == NULL)
- return -ENOMEM;
-
- new_stat->nid = *nid;
- new_stat->nid_obd = exp->exp_obd;
- /* we need set default refcount to 1 to balance obd_disconnect */
- atomic_set(&new_stat->nid_exp_ref_count, 1);
-
- old_stat = cfs_hash_findadd_unique(obd->obd_nid_stats_hash,
- nid, &new_stat->nid_hash);
- CDEBUG(D_INFO, "Found stats %p for nid %s - ref %d\n",
- old_stat, libcfs_nid2str(*nid),
- atomic_read(&new_stat->nid_exp_ref_count));
-
- /* We need to release old stats because lprocfs_exp_cleanup() hasn't
- * been and will never be called. */
- if (exp->exp_nid_stats) {
- nidstat_putref(exp->exp_nid_stats);
- exp->exp_nid_stats = NULL;
- }
-
- /* Return -EALREADY here so that we know that the /proc
- * entry already has been created */
- if (old_stat != new_stat) {
- exp->exp_nid_stats = old_stat;
- rc = -EALREADY;
- goto destroy_new;
- }
- /* not found - create */
- OBD_ALLOC(buffer, LNET_NIDSTR_SIZE);
- if (buffer == NULL) {
- rc = -ENOMEM;
- goto destroy_new;
- }
-
- memcpy(buffer, libcfs_nid2str(*nid), LNET_NIDSTR_SIZE);
- new_stat->nid_proc = lprocfs_register(buffer,
- obd->obd_proc_exports_entry,
- NULL, NULL);
- OBD_FREE(buffer, LNET_NIDSTR_SIZE);
-
- if (IS_ERR(new_stat->nid_proc)) {
- CERROR("Error making export directory for nid %s\n",
- libcfs_nid2str(*nid));
- rc = PTR_ERR(new_stat->nid_proc);
- new_stat->nid_proc = NULL;
- goto destroy_new_ns;
- }
-
- entry = lprocfs_add_simple(new_stat->nid_proc, "uuid",
- new_stat, &lproc_exp_uuid_fops);
- if (IS_ERR(entry)) {
- CWARN("Error adding the NID stats file\n");
- rc = PTR_ERR(entry);
- goto destroy_new_ns;
- }
-
- entry = lprocfs_add_simple(new_stat->nid_proc, "hash",
- new_stat, &lproc_exp_hash_fops);
- if (IS_ERR(entry)) {
- CWARN("Error adding the hash file\n");
- rc = PTR_ERR(entry);
- goto destroy_new_ns;
- }
-
- exp->exp_nid_stats = new_stat;
- *newnid = 1;
- /* protect competitive add to list, not need locking on destroy */
- spin_lock(&obd->obd_nid_lock);
- list_add(&new_stat->nid_list, &obd->obd_nid_stats);
- spin_unlock(&obd->obd_nid_lock);
-
- return rc;
-
-destroy_new_ns:
- if (new_stat->nid_proc != NULL)
- lprocfs_remove(&new_stat->nid_proc);
- cfs_hash_del(obd->obd_nid_stats_hash, nid, &new_stat->nid_hash);
-
-destroy_new:
- nidstat_putref(new_stat);
- OBD_FREE_PTR(new_stat);
- return rc;
-}
-EXPORT_SYMBOL(lprocfs_exp_setup);
-
int lprocfs_exp_cleanup(struct obd_export *exp)
{
- struct nid_stat *stat = exp->exp_nid_stats;
-
- if (!stat || !exp->exp_obd)
- return 0;
-
- nidstat_putref(exp->exp_nid_stats);
- exp->exp_nid_stats = NULL;
-
return 0;
}
EXPORT_SYMBOL(lprocfs_exp_cleanup);
@@ -1972,35 +1717,35 @@ char *lprocfs_find_named_value(const char *buffer, const char *name,
}
EXPORT_SYMBOL(lprocfs_find_named_value);
-int lprocfs_seq_create(struct proc_dir_entry *parent,
+int ldebugfs_seq_create(struct dentry *parent,
const char *name,
umode_t mode,
const struct file_operations *seq_fops,
void *data)
{
- struct proc_dir_entry *entry;
+ struct dentry *entry;
/* Disallow secretly (un)writable entries. */
LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0));
- entry = proc_create_data(name, mode, parent, seq_fops, data);
- if (entry == NULL)
- return -ENOMEM;
+ entry = debugfs_create_file(name, mode, parent, data, seq_fops);
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
return 0;
}
-EXPORT_SYMBOL(lprocfs_seq_create);
+EXPORT_SYMBOL(ldebugfs_seq_create);
-int lprocfs_obd_seq_create(struct obd_device *dev,
- const char *name,
- umode_t mode,
- const struct file_operations *seq_fops,
- void *data)
+int ldebugfs_obd_seq_create(struct obd_device *dev,
+ const char *name,
+ umode_t mode,
+ const struct file_operations *seq_fops,
+ void *data)
{
- return lprocfs_seq_create(dev->obd_proc_entry, name,
- mode, seq_fops, data);
+ return ldebugfs_seq_create(dev->obd_debugfs_entry, name,
+ mode, seq_fops, data);
}
-EXPORT_SYMBOL(lprocfs_obd_seq_create);
+EXPORT_SYMBOL(ldebugfs_obd_seq_create);
void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
{
@@ -2056,4 +1801,26 @@ int lprocfs_obd_rd_max_pages_per_rpc(struct seq_file *m, void *data)
}
EXPORT_SYMBOL(lprocfs_obd_rd_max_pages_per_rpc);
-#endif
+ssize_t lustre_attr_show(struct kobject *kobj,
+ struct attribute *attr, char *buf)
+{
+ struct lustre_attr *a = container_of(attr, struct lustre_attr, attr);
+
+ return a->show ? a->show(kobj, attr, buf) : 0;
+}
+EXPORT_SYMBOL_GPL(lustre_attr_show);
+
+ssize_t lustre_attr_store(struct kobject *kobj, struct attribute *attr,
+ const char *buf, size_t len)
+{
+ struct lustre_attr *a = container_of(attr, struct lustre_attr, attr);
+
+ return a->store ? a->store(kobj, attr, buf, len) : len;
+}
+EXPORT_SYMBOL_GPL(lustre_attr_store);
+
+const struct sysfs_ops lustre_sysfs_ops = {
+ .show = lustre_attr_show,
+ .store = lustre_attr_store,
+};
+EXPORT_SYMBOL_GPL(lustre_sysfs_ops);
diff --git a/drivers/staging/lustre/lustre/obdclass/lu_object.c b/drivers/staging/lustre/lustre/obdclass/lu_object.c
index 20c0779951fd7c..eae66066035890 100644
--- a/drivers/staging/lustre/lustre/obdclass/lu_object.c
+++ b/drivers/staging/lustre/lustre/obdclass/lu_object.c
@@ -1532,7 +1532,7 @@ static void keys_fini(struct lu_context *ctx)
for (i = 0; i < ARRAY_SIZE(lu_keys); ++i)
key_fini(ctx, i);
- OBD_FREE(ctx->lc_value, ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0]));
+ kfree(ctx->lc_value);
ctx->lc_value = NULL;
}
@@ -1581,8 +1581,8 @@ static int keys_fill(struct lu_context *ctx)
static int keys_init(struct lu_context *ctx)
{
- OBD_ALLOC(ctx->lc_value,
- ARRAY_SIZE(lu_keys) * sizeof(ctx->lc_value[0]));
+ ctx->lc_value = kcalloc(ARRAY_SIZE(lu_keys), sizeof(ctx->lc_value[0]),
+ GFP_NOFS);
if (likely(ctx->lc_value != NULL))
return keys_fill(ctx);
@@ -1989,14 +1989,10 @@ void lu_global_fini(void)
static __u32 ls_stats_read(struct lprocfs_stats *stats, int idx)
{
-#if defined (CONFIG_PROC_FS)
struct lprocfs_counter ret;
lprocfs_stats_collect(stats, idx, &ret);
return (__u32)ret.lc_count;
-#else
- return 0;
-#endif
}
/**
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index f720e31832952e..1cfaabfef6e349 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -186,7 +186,7 @@ void class_handle_free_cb(struct rcu_head *rcu)
if (h->h_ops->hop_free != NULL)
h->h_ops->hop_free(ptr, h->h_size);
else
- OBD_FREE(ptr, h->h_size);
+ kfree(ptr);
}
EXPORT_SYMBOL(class_handle_free_cb);
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
index 64b2f35e224f3b..5cc6435cc47a2c 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_peer.c
@@ -104,7 +104,7 @@ int class_add_uuid(const char *uuid, __u64 nid)
if (strlen(uuid) > UUID_MAX - 1)
return -EOVERFLOW;
- OBD_ALLOC_PTR(data);
+ data = kzalloc(sizeof(*data), GFP_NOFS);
if (data == NULL)
return -ENOMEM;
@@ -136,7 +136,7 @@ int class_add_uuid(const char *uuid, __u64 nid)
if (found) {
CDEBUG(D_INFO, "found uuid %s %s cnt=%d\n", uuid,
libcfs_nid2str(nid), entry->un_nid_count);
- OBD_FREE(data, sizeof(*data));
+ kfree(data);
} else {
CDEBUG(D_INFO, "add uuid %s %s\n", uuid, libcfs_nid2str(nid));
}
@@ -180,7 +180,7 @@ int class_del_uuid(const char *uuid)
libcfs_nid2str(data->un_nids[0]),
data->un_nid_count);
- OBD_FREE(data, sizeof(*data));
+ kfree(data);
}
return 0;
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index 6ce9adc2f11c88..fbdb748a36b9e2 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -49,7 +49,6 @@
static cfs_hash_ops_t uuid_hash_ops;
static cfs_hash_ops_t nid_hash_ops;
-static cfs_hash_ops_t nid_stat_hash_ops;
/*********** string parsing utils *********/
@@ -383,7 +382,6 @@ int class_attach(struct lustre_cfg *lcfg)
INIT_LIST_HEAD(&obd->obd_unlinked_exports);
INIT_LIST_HEAD(&obd->obd_delayed_exports);
INIT_LIST_HEAD(&obd->obd_exports_timed);
- INIT_LIST_HEAD(&obd->obd_nid_stats);
spin_lock_init(&obd->obd_nid_lock);
spin_lock_init(&obd->obd_dev_lock);
mutex_init(&obd->obd_dev_mutex);
@@ -486,7 +484,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
obd->obd_starting = 1;
obd->obd_uuid_hash = NULL;
obd->obd_nid_hash = NULL;
- obd->obd_nid_stats_hash = NULL;
spin_unlock(&obd->obd_dev_lock);
/* create an uuid-export lustre hash */
@@ -515,19 +512,6 @@ int class_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
goto err_hash;
}
- /* create a nid-stats lustre hash */
- obd->obd_nid_stats_hash = cfs_hash_create("NID_STATS",
- HASH_NID_STATS_CUR_BITS,
- HASH_NID_STATS_MAX_BITS,
- HASH_NID_STATS_BKT_BITS, 0,
- CFS_HASH_MIN_THETA,
- CFS_HASH_MAX_THETA,
- &nid_stat_hash_ops, CFS_HASH_DEFAULT);
- if (!obd->obd_nid_stats_hash) {
- err = -ENOMEM;
- goto err_hash;
- }
-
exp = class_new_export(obd, &obd->obd_uuid);
if (IS_ERR(exp)) {
err = PTR_ERR(exp);
@@ -567,10 +551,6 @@ err_hash:
cfs_hash_putref(obd->obd_nid_hash);
obd->obd_nid_hash = NULL;
}
- if (obd->obd_nid_stats_hash) {
- cfs_hash_putref(obd->obd_nid_stats_hash);
- obd->obd_nid_stats_hash = NULL;
- }
obd->obd_starting = 0;
CERROR("setup %s failed (%d)\n", obd->obd_name, err);
return err;
@@ -694,12 +674,6 @@ int class_cleanup(struct obd_device *obd, struct lustre_cfg *lcfg)
obd->obd_nid_hash = NULL;
}
- /* destroy a nid-stats hash body */
- if (obd->obd_nid_stats_hash) {
- cfs_hash_putref(obd->obd_nid_stats_hash);
- obd->obd_nid_stats_hash = NULL;
- }
-
class_decref(obd, "setup", obd);
obd->obd_set_up = 0;
@@ -860,48 +834,43 @@ int class_add_profile(int proflen, char *prof, int osclen, char *osc,
CDEBUG(D_CONFIG, "Add profile %s\n", prof);
- OBD_ALLOC(lprof, sizeof(*lprof));
+ lprof = kzalloc(sizeof(*lprof), GFP_NOFS);
if (lprof == NULL)
return -ENOMEM;
INIT_LIST_HEAD(&lprof->lp_list);
LASSERT(proflen == (strlen(prof) + 1));
- OBD_ALLOC(lprof->lp_profile, proflen);
+ lprof->lp_profile = kmemdup(prof, proflen, GFP_NOFS);
if (lprof->lp_profile == NULL) {
err = -ENOMEM;
- goto out;
+ goto free_lprof;
}
- memcpy(lprof->lp_profile, prof, proflen);
LASSERT(osclen == (strlen(osc) + 1));
- OBD_ALLOC(lprof->lp_dt, osclen);
+ lprof->lp_dt = kmemdup(osc, osclen, GFP_NOFS);
if (lprof->lp_dt == NULL) {
err = -ENOMEM;
- goto out;
+ goto free_lp_profile;
}
- memcpy(lprof->lp_dt, osc, osclen);
if (mdclen > 0) {
LASSERT(mdclen == (strlen(mdc) + 1));
- OBD_ALLOC(lprof->lp_md, mdclen);
+ lprof->lp_md = kmemdup(mdc, mdclen, GFP_NOFS);
if (lprof->lp_md == NULL) {
err = -ENOMEM;
- goto out;
+ goto free_lp_dt;
}
- memcpy(lprof->lp_md, mdc, mdclen);
}
list_add(&lprof->lp_list, &lustre_profile_list);
return err;
-out:
- if (lprof->lp_md)
- OBD_FREE(lprof->lp_md, mdclen);
- if (lprof->lp_dt)
- OBD_FREE(lprof->lp_dt, osclen);
- if (lprof->lp_profile)
- OBD_FREE(lprof->lp_profile, proflen);
- OBD_FREE(lprof, sizeof(*lprof));
+free_lp_dt:
+ kfree(lprof->lp_dt);
+free_lp_profile:
+ kfree(lprof->lp_profile);
+free_lprof:
+ kfree(lprof);
return err;
}
@@ -914,11 +883,10 @@ void class_del_profile(const char *prof)
lprof = class_get_profile(prof);
if (lprof) {
list_del(&lprof->lp_list);
- OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1);
- OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1);
- if (lprof->lp_md)
- OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1);
- OBD_FREE(lprof, sizeof(*lprof));
+ kfree(lprof->lp_profile);
+ kfree(lprof->lp_dt);
+ kfree(lprof->lp_md);
+ kfree(lprof);
}
}
EXPORT_SYMBOL(class_del_profile);
@@ -930,11 +898,10 @@ void class_del_profiles(void)
list_for_each_entry_safe(lprof, n, &lustre_profile_list, lp_list) {
list_del(&lprof->lp_list);
- OBD_FREE(lprof->lp_profile, strlen(lprof->lp_profile) + 1);
- OBD_FREE(lprof->lp_dt, strlen(lprof->lp_dt) + 1);
- if (lprof->lp_md)
- OBD_FREE(lprof->lp_md, strlen(lprof->lp_md) + 1);
- OBD_FREE(lprof, sizeof(*lprof));
+ kfree(lprof->lp_profile);
+ kfree(lprof->lp_dt);
+ kfree(lprof->lp_md);
+ kfree(lprof);
}
}
EXPORT_SYMBOL(class_del_profiles);
@@ -1011,7 +978,7 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
new_len = LUSTRE_CFG_BUFLEN(cfg, 1) + strlen(new_name) - name_len;
- OBD_ALLOC(new_param, new_len);
+ new_param = kzalloc(new_len, GFP_NOFS);
if (new_param == NULL)
return ERR_PTR(-ENOMEM);
@@ -1019,9 +986,9 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
if (value != NULL)
strcat(new_param, value);
- OBD_ALLOC_PTR(bufs);
+ bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
if (bufs == NULL) {
- OBD_FREE(new_param, new_len);
+ kfree(new_param);
return ERR_PTR(-ENOMEM);
}
@@ -1031,8 +998,8 @@ struct lustre_cfg *lustre_cfg_rename(struct lustre_cfg *cfg,
new_cfg = lustre_cfg_new(cfg->lcfg_command, bufs);
- OBD_FREE(new_param, new_len);
- OBD_FREE_PTR(bufs);
+ kfree(new_param);
+ kfree(bufs);
if (new_cfg == NULL)
return ERR_PTR(-ENOMEM);
@@ -1493,7 +1460,7 @@ int class_config_llog_handler(const struct lu_env *env,
inst = 1;
inst_len = LUSTRE_CFG_BUFLEN(lcfg, 0) +
sizeof(clli->cfg_instance) * 2 + 4;
- OBD_ALLOC(inst_name, inst_len);
+ inst_name = kzalloc(inst_len, GFP_NOFS);
if (inst_name == NULL) {
rc = -ENOMEM;
goto out;
@@ -1556,7 +1523,7 @@ int class_config_llog_handler(const struct lu_env *env,
lustre_cfg_free(lcfg_new);
if (inst)
- OBD_FREE(inst_name, inst_len);
+ kfree(inst_name);
break;
}
default:
@@ -1671,7 +1638,7 @@ int class_config_dump_handler(const struct lu_env *env,
char *outstr;
int rc = 0;
- OBD_ALLOC(outstr, 256);
+ outstr = kzalloc(256, GFP_NOFS);
if (outstr == NULL)
return -ENOMEM;
@@ -1683,7 +1650,7 @@ int class_config_dump_handler(const struct lu_env *env,
rc = -EINVAL;
}
- OBD_FREE(outstr, 256);
+ kfree(outstr);
return rc;
}
@@ -1897,57 +1864,3 @@ static cfs_hash_ops_t nid_hash_ops = {
.hs_get = nid_export_get,
.hs_put_locked = nid_export_put_locked,
};
-
-
-/*
- * nid<->nidstats hash operations
- */
-
-static void *
-nidstats_key(struct hlist_node *hnode)
-{
- struct nid_stat *ns;
-
- ns = hlist_entry(hnode, struct nid_stat, nid_hash);
-
- return &ns->nid;
-}
-
-static int
-nidstats_keycmp(const void *key, struct hlist_node *hnode)
-{
- return *(lnet_nid_t *)nidstats_key(hnode) == *(lnet_nid_t *)key;
-}
-
-static void *
-nidstats_object(struct hlist_node *hnode)
-{
- return hlist_entry(hnode, struct nid_stat, nid_hash);
-}
-
-static void
-nidstats_get(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct nid_stat *ns;
-
- ns = hlist_entry(hnode, struct nid_stat, nid_hash);
- nidstat_getref(ns);
-}
-
-static void
-nidstats_put_locked(struct cfs_hash *hs, struct hlist_node *hnode)
-{
- struct nid_stat *ns;
-
- ns = hlist_entry(hnode, struct nid_stat, nid_hash);
- nidstat_putref(ns);
-}
-
-static cfs_hash_ops_t nid_stat_hash_ops = {
- .hs_hash = nid_hash,
- .hs_key = nidstats_key,
- .hs_keycmp = nidstats_keycmp,
- .hs_object = nidstats_object,
- .hs_get = nidstats_get,
- .hs_put_locked = nidstats_put_locked,
-};
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_mount.c b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
index 3437b2ecfc0287..1f9a5f7841ae00 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_mount.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_mount.c
@@ -84,7 +84,7 @@ int lustre_process_log(struct super_block *sb, char *logname,
LASSERT(mgc);
LASSERT(cfg);
- OBD_ALLOC_PTR(bufs);
+ bufs = kzalloc(sizeof(*bufs), GFP_NOFS);
if (bufs == NULL)
return -ENOMEM;
@@ -97,7 +97,7 @@ int lustre_process_log(struct super_block *sb, char *logname,
rc = obd_process_config(mgc, sizeof(*lcfg), lcfg);
lustre_cfg_free(lcfg);
- OBD_FREE_PTR(bufs);
+ kfree(bufs);
if (rc == -EINVAL)
LCONSOLE_ERROR_MSG(0x15b, "%s: The configuration from log '%s' failed from the MGS (%d). Make sure this client and the MGS are running compatible versions of Lustre.\n",
@@ -247,8 +247,8 @@ int lustre_start_mgc(struct super_block *sb)
mutex_lock(&mgc_start_lock);
len = strlen(LUSTRE_MGC_OBDNAME) + strlen(libcfs_nid2str(nid)) + 1;
- OBD_ALLOC(mgcname, len);
- OBD_ALLOC(niduuid, len + 2);
+ mgcname = kzalloc(len, GFP_NOFS);
+ niduuid = kzalloc(len + 2, GFP_NOFS);
if (!mgcname || !niduuid) {
rc = -ENOMEM;
goto out_free;
@@ -257,7 +257,7 @@ int lustre_start_mgc(struct super_block *sb)
mgssec = lsi->lsi_lmd->lmd_mgssec ? lsi->lsi_lmd->lmd_mgssec : "";
- OBD_ALLOC_PTR(data);
+ data = kzalloc(sizeof(*data), GFP_NOFS);
if (data == NULL) {
rc = -ENOMEM;
goto out_free;
@@ -375,7 +375,7 @@ int lustre_start_mgc(struct super_block *sb)
lsi->lsi_lmd->lmd_mgs_failnodes = 1;
/* Random uuid for MGC allows easier reconnects */
- OBD_ALLOC_PTR(uuid);
+ uuid = kzalloc(sizeof(*uuid), GFP_NOFS);
if (!uuid) {
rc = -ENOMEM;
goto out_free;
@@ -388,7 +388,7 @@ int lustre_start_mgc(struct super_block *sb)
rc = lustre_start_simple(mgcname, LUSTRE_MGC_NAME,
(char *)uuid->uuid, LUSTRE_MGS_OBDNAME,
niduuid, NULL, NULL);
- OBD_FREE_PTR(uuid);
+ kfree(uuid);
if (rc)
goto out_free;
@@ -464,12 +464,9 @@ out:
out_free:
mutex_unlock(&mgc_start_lock);
- if (data)
- OBD_FREE_PTR(data);
- if (mgcname)
- OBD_FREE(mgcname, len);
- if (niduuid)
- OBD_FREE(niduuid, len + 2);
+ kfree(data);
+ kfree(mgcname);
+ kfree(niduuid);
return rc;
}
@@ -513,7 +510,7 @@ static int lustre_stop_mgc(struct super_block *sb)
/* Save the obdname for cleaning the nid uuids, which are
obdname_XX */
len = strlen(obd->obd_name) + 6;
- OBD_ALLOC(niduuid, len);
+ niduuid = kzalloc(len, GFP_NOFS);
if (niduuid) {
strcpy(niduuid, obd->obd_name);
ptr = niduuid + strlen(niduuid);
@@ -538,8 +535,7 @@ static int lustre_stop_mgc(struct super_block *sb)
niduuid, rc);
}
out:
- if (niduuid)
- OBD_FREE(niduuid, len);
+ kfree(niduuid);
/* class_import_put will get rid of the additional connections */
mutex_unlock(&mgc_start_lock);
@@ -552,12 +548,12 @@ struct lustre_sb_info *lustre_init_lsi(struct super_block *sb)
{
struct lustre_sb_info *lsi;
- OBD_ALLOC_PTR(lsi);
+ lsi = kzalloc(sizeof(*lsi), GFP_NOFS);
if (!lsi)
return NULL;
- OBD_ALLOC_PTR(lsi->lsi_lmd);
+ lsi->lsi_lmd = kzalloc(sizeof(*lsi->lsi_lmd), GFP_NOFS);
if (!lsi->lsi_lmd) {
- OBD_FREE_PTR(lsi);
+ kfree(lsi);
return NULL;
}
@@ -585,36 +581,21 @@ static int lustre_free_lsi(struct super_block *sb)
LASSERT(atomic_read(&lsi->lsi_mounts) == 0);
if (lsi->lsi_lmd != NULL) {
- if (lsi->lsi_lmd->lmd_dev != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_dev,
- strlen(lsi->lsi_lmd->lmd_dev) + 1);
- if (lsi->lsi_lmd->lmd_profile != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_profile,
- strlen(lsi->lsi_lmd->lmd_profile) + 1);
- if (lsi->lsi_lmd->lmd_mgssec != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_mgssec,
- strlen(lsi->lsi_lmd->lmd_mgssec) + 1);
- if (lsi->lsi_lmd->lmd_opts != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_opts,
- strlen(lsi->lsi_lmd->lmd_opts) + 1);
+ kfree(lsi->lsi_lmd->lmd_dev);
+ kfree(lsi->lsi_lmd->lmd_profile);
+ kfree(lsi->lsi_lmd->lmd_mgssec);
+ kfree(lsi->lsi_lmd->lmd_opts);
if (lsi->lsi_lmd->lmd_exclude_count)
- OBD_FREE(lsi->lsi_lmd->lmd_exclude,
- sizeof(lsi->lsi_lmd->lmd_exclude[0]) *
- lsi->lsi_lmd->lmd_exclude_count);
- if (lsi->lsi_lmd->lmd_mgs != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_mgs,
- strlen(lsi->lsi_lmd->lmd_mgs) + 1);
- if (lsi->lsi_lmd->lmd_osd_type != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_osd_type,
- strlen(lsi->lsi_lmd->lmd_osd_type) + 1);
- if (lsi->lsi_lmd->lmd_params != NULL)
- OBD_FREE(lsi->lsi_lmd->lmd_params, 4096);
-
- OBD_FREE(lsi->lsi_lmd, sizeof(*lsi->lsi_lmd));
+ kfree(lsi->lsi_lmd->lmd_exclude);
+ kfree(lsi->lsi_lmd->lmd_mgs);
+ kfree(lsi->lsi_lmd->lmd_osd_type);
+ kfree(lsi->lsi_lmd->lmd_params);
+
+ kfree(lsi->lsi_lmd);
}
LASSERT(lsi->lsi_llsbi == NULL);
- OBD_FREE(lsi, sizeof(*lsi));
+ kfree(lsi);
s2lsi_nocast(sb) = NULL;
return 0;
@@ -846,7 +827,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
devmax = strlen(ptr) / 8 + 1;
/* temp storage until we figure out how many we have */
- OBD_ALLOC(exclude_list, sizeof(index) * devmax);
+ exclude_list = kcalloc(devmax, sizeof(index), GFP_NOFS);
if (!exclude_list)
return -ENOMEM;
@@ -875,8 +856,8 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
if (lmd->lmd_exclude_count) {
/* permanent, freed in lustre_free_lsi */
- OBD_ALLOC(lmd->lmd_exclude, sizeof(index) *
- lmd->lmd_exclude_count);
+ lmd->lmd_exclude = kcalloc(lmd->lmd_exclude_count,
+ sizeof(index), GFP_NOFS);
if (lmd->lmd_exclude) {
memcpy(lmd->lmd_exclude, exclude_list,
sizeof(index) * lmd->lmd_exclude_count);
@@ -885,7 +866,7 @@ static int lmd_make_exclusion(struct lustre_mount_data *lmd, const char *ptr)
lmd->lmd_exclude_count = 0;
}
}
- OBD_FREE(exclude_list, sizeof(index) * devmax);
+ kfree(exclude_list);
return rc;
}
@@ -894,10 +875,8 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
char *tail;
int length;
- if (lmd->lmd_mgssec != NULL) {
- OBD_FREE(lmd->lmd_mgssec, strlen(lmd->lmd_mgssec) + 1);
- lmd->lmd_mgssec = NULL;
- }
+ kfree(lmd->lmd_mgssec);
+ lmd->lmd_mgssec = NULL;
tail = strchr(ptr, ',');
if (tail == NULL)
@@ -905,7 +884,7 @@ static int lmd_parse_mgssec(struct lustre_mount_data *lmd, char *ptr)
else
length = tail - ptr;
- OBD_ALLOC(lmd->lmd_mgssec, length + 1);
+ lmd->lmd_mgssec = kzalloc(length + 1, GFP_NOFS);
if (lmd->lmd_mgssec == NULL)
return -ENOMEM;
@@ -922,10 +901,8 @@ static int lmd_parse_string(char **handle, char *ptr)
if ((handle == NULL) || (ptr == NULL))
return -EINVAL;
- if (*handle != NULL) {
- OBD_FREE(*handle, strlen(*handle) + 1);
- *handle = NULL;
- }
+ kfree(*handle);
+ *handle = NULL;
tail = strchr(ptr, ',');
if (tail == NULL)
@@ -933,7 +910,7 @@ static int lmd_parse_string(char **handle, char *ptr)
else
length = tail - ptr;
- OBD_ALLOC(*handle, length + 1);
+ *handle = kzalloc(length + 1, GFP_NOFS);
if (*handle == NULL)
return -ENOMEM;
@@ -963,7 +940,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
if (lmd->lmd_mgs != NULL)
oldlen = strlen(lmd->lmd_mgs) + 1;
- OBD_ALLOC(mgsnid, oldlen + length + 1);
+ mgsnid = kzalloc(oldlen + length + 1, GFP_NOFS);
if (mgsnid == NULL)
return -ENOMEM;
@@ -971,7 +948,7 @@ static int lmd_parse_mgs(struct lustre_mount_data *lmd, char **ptr)
/* Multiple mgsnid= are taken to mean failover locations */
memcpy(mgsnid, lmd->lmd_mgs, oldlen);
mgsnid[oldlen - 1] = ':';
- OBD_FREE(lmd->lmd_mgs, oldlen);
+ kfree(lmd->lmd_mgs);
}
memcpy(mgsnid + oldlen, *ptr, length);
mgsnid[oldlen + length] = '\0';
@@ -1005,7 +982,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
}
lmd->lmd_magic = LMD_MAGIC;
- OBD_ALLOC(lmd->lmd_params, 4096);
+ lmd->lmd_params = kzalloc(4096, GFP_NOFS);
if (lmd->lmd_params == NULL)
return -ENOMEM;
lmd->lmd_params[0] = '\0';
@@ -1143,14 +1120,14 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
/* Remove leading /s from fsname */
while (*++s1 == '/') ;
/* Freed in lustre_free_lsi */
- OBD_ALLOC(lmd->lmd_profile, strlen(s1) + 8);
+ lmd->lmd_profile = kzalloc(strlen(s1) + 8, GFP_NOFS);
if (!lmd->lmd_profile)
return -ENOMEM;
sprintf(lmd->lmd_profile, "%s-client", s1);
}
/* Freed in lustre_free_lsi */
- OBD_ALLOC(lmd->lmd_dev, strlen(devname) + 1);
+ lmd->lmd_dev = kzalloc(strlen(devname) + 1, GFP_NOFS);
if (!lmd->lmd_dev)
return -ENOMEM;
strcpy(lmd->lmd_dev, devname);
@@ -1161,7 +1138,7 @@ static int lmd_parse(char *options, struct lustre_mount_data *lmd)
*s1-- = 0;
if (*options != 0) {
/* Freed in lustre_free_lsi */
- OBD_ALLOC(lmd->lmd_opts, strlen(options) + 1);
+ lmd->lmd_opts = kzalloc(strlen(options) + 1, GFP_NOFS);
if (!lmd->lmd_opts)
return -ENOMEM;
strcpy(lmd->lmd_opts, options);
diff --git a/drivers/staging/lustre/lustre/obdecho/Makefile b/drivers/staging/lustre/lustre/obdecho/Makefile
index 672028fc7f6e2e..a659a37a7e93e7 100644
--- a/drivers/staging/lustre/lustre/obdecho/Makefile
+++ b/drivers/staging/lustre/lustre/obdecho/Makefile
@@ -1,2 +1,2 @@
obj-$(CONFIG_LUSTRE_FS) += obdecho.o
-obdecho-y := echo_client.o lproc_echo.o
+obdecho-y := echo_client.o
diff --git a/drivers/staging/lustre/lustre/obdecho/echo_client.c b/drivers/staging/lustre/lustre/obdecho/echo_client.c
index d542e06d6cd38e..0222fd2e475743 100644
--- a/drivers/staging/lustre/lustre/obdecho/echo_client.c
+++ b/drivers/staging/lustre/lustre/obdecho/echo_client.c
@@ -479,13 +479,13 @@ static int echo_alloc_memmd(struct echo_device *ed,
lsm_size = lov_stripe_md_size(1);
LASSERT(*lsmp == NULL);
- OBD_ALLOC(*lsmp, lsm_size);
+ *lsmp = kzalloc(lsm_size, GFP_NOFS);
if (*lsmp == NULL)
return -ENOMEM;
- OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo));
+ (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo), GFP_NOFS);
if ((*lsmp)->lsm_oinfo[0] == NULL) {
- OBD_FREE(*lsmp, lsm_size);
+ kfree(*lsmp);
return -ENOMEM;
}
@@ -507,8 +507,8 @@ static int echo_free_memmd(struct echo_device *ed, struct lov_stripe_md **lsmp)
lsm_size = lov_stripe_md_size(1);
LASSERT(*lsmp != NULL);
- OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo));
- OBD_FREE(*lsmp, lsm_size);
+ kfree((*lsmp)->lsm_oinfo[0]);
+ kfree(*lsmp);
*lsmp = NULL;
return 0;
}
@@ -700,7 +700,7 @@ static struct lu_device *echo_device_alloc(const struct lu_env *env,
int rc;
int cleanup = 0;
- OBD_ALLOC_PTR(ed);
+ ed = kzalloc(sizeof(*ed), GFP_NOFS);
if (ed == NULL) {
rc = -ENOMEM;
goto out;
@@ -798,7 +798,7 @@ out:
case 2:
cl_device_fini(&ed->ed_cl);
case 1:
- OBD_FREE_PTR(ed);
+ kfree(ed);
case 0:
default:
break;
@@ -895,7 +895,7 @@ static struct lu_device *echo_device_free(const struct lu_env *env,
LASSERT(ed->ed_site == lu2cl_site(d->ld_site));
echo_site_fini(env, ed);
cl_device_fini(&ed->ed_cl);
- OBD_FREE_PTR(ed);
+ kfree(ed);
return NULL;
}
@@ -1577,13 +1577,13 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
if (rw == OBD_BRW_WRITE)
brw_flags = OBD_BRW_ASYNC;
- OBD_ALLOC(pga, npages * sizeof(*pga));
+ pga = kcalloc(npages, sizeof(*pga), GFP_NOFS);
if (pga == NULL)
return -ENOMEM;
- OBD_ALLOC(pages, npages * sizeof(*pages));
+ pages = kcalloc(npages, sizeof(*pages), GFP_NOFS);
if (pages == NULL) {
- OBD_FREE(pga, npages * sizeof(*pga));
+ kfree(pga);
return -ENOMEM;
}
@@ -1632,8 +1632,8 @@ static int echo_client_kbrw(struct echo_device *ed, int rw, struct obdo *oa,
}
OBD_PAGE_FREE(pgp->pg);
}
- OBD_FREE(pga, npages * sizeof(*pga));
- OBD_FREE(pages, npages * sizeof(*pages));
+ kfree(pga);
+ kfree(pages);
return rc;
}
@@ -1659,8 +1659,8 @@ static int echo_client_prep_commit(const struct lu_env *env,
npages = batch >> PAGE_CACHE_SHIFT;
tot_pages = count >> PAGE_CACHE_SHIFT;
- OBD_ALLOC(lnb, npages * sizeof(struct niobuf_local));
- OBD_ALLOC(rnb, npages * sizeof(struct niobuf_remote));
+ lnb = kcalloc(npages, sizeof(struct niobuf_local), GFP_NOFS);
+ rnb = kcalloc(npages, sizeof(struct niobuf_remote), GFP_NOFS);
if (lnb == NULL || rnb == NULL) {
ret = -ENOMEM;
@@ -1737,10 +1737,8 @@ static int echo_client_prep_commit(const struct lu_env *env,
}
out:
- if (lnb)
- OBD_FREE(lnb, npages * sizeof(struct niobuf_local));
- if (rnb)
- OBD_FREE(rnb, npages * sizeof(struct niobuf_remote));
+ kfree(lnb);
+ kfree(rnb);
return ret;
}
@@ -1879,7 +1877,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
if (rc < 0)
return rc;
- OBD_ALLOC_PTR(env);
+ env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL)
return -ENOMEM;
@@ -2010,7 +2008,7 @@ echo_client_iocontrol(unsigned int cmd, struct obd_export *exp, int len,
out:
lu_env_fini(env);
- OBD_FREE_PTR(env);
+ kfree(env);
/* XXX this should be in a helper also called by target_send_reply */
for (ack_lock = dummy_oti.oti_ack_locks, i = 0; i < 4;
@@ -2050,7 +2048,7 @@ static int echo_client_setup(const struct lu_env *env,
ec->ec_unique = 0;
ec->ec_nstripes = 0;
- OBD_ALLOC(ocd, sizeof(*ocd));
+ ocd = kzalloc(sizeof(*ocd), GFP_NOFS);
if (ocd == NULL) {
CERROR("Can't alloc ocd connecting to %s\n",
lustre_cfg_string(lcfg, 1));
@@ -2074,7 +2072,7 @@ static int echo_client_setup(const struct lu_env *env,
spin_unlock(&tgt->obd_dev_lock);
}
- OBD_FREE(ocd, sizeof(*ocd));
+ kfree(ocd);
if (rc != 0) {
CERROR("fail to connect to device %s\n",
@@ -2143,15 +2141,11 @@ static struct obd_ops echo_client_obd_ops = {
int echo_client_init(void)
{
- struct lprocfs_static_vars lvars = { NULL };
int rc;
- lprocfs_echo_init_vars(&lvars);
-
rc = lu_kmem_init(echo_caches);
if (rc == 0) {
rc = class_register_type(&echo_client_obd_ops, NULL,
- lvars.module_vars,
LUSTRE_ECHO_CLIENT_NAME,
&echo_device_type);
if (rc)
@@ -2168,15 +2162,10 @@ void echo_client_exit(void)
static int __init obdecho_init(void)
{
- struct lprocfs_static_vars lvars;
-
LCONSOLE_INFO("Echo OBD driver; http://www.lustre.org/\n");
LASSERT(PAGE_CACHE_SIZE % OBD_ECHO_BLOCK_SIZE == 0);
- lprocfs_echo_init_vars(&lvars);
-
-
return echo_client_init();
}
diff --git a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c b/drivers/staging/lustre/lustre/obdecho/lproc_echo.c
deleted file mode 100644
index 0beb97db7c7d9d..00000000000000
--- a/drivers/staging/lustre/lustre/obdecho/lproc_echo.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * GPL HEADER START
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 only,
- * 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 version 2 for more details (a copy is included
- * in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU General Public License
- * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
- *
- * GPL HEADER END
- */
-/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
- * Use is subject to license terms.
- */
-/*
- * This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
- */
-#define DEBUG_SUBSYSTEM S_ECHO
-
-#include "../include/lprocfs_status.h"
-#include "../include/obd_class.h"
-
-#if defined(CONFIG_PROC_FS)
-LPROC_SEQ_FOPS_RO_TYPE(echo, uuid);
-static struct lprocfs_vars lprocfs_echo_obd_vars[] = {
- { "uuid", &echo_uuid_fops, NULL, 0 },
- { NULL }
-};
-
-LPROC_SEQ_FOPS_RO_TYPE(echo, numrefs);
-static struct lprocfs_vars lprocfs_echo_module_vars[] = {
- { "num_refs", &echo_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
-void lprocfs_echo_init_vars(struct lprocfs_static_vars *lvars)
-{
- lvars->module_vars = lprocfs_echo_module_vars;
- lvars->obd_vars = lprocfs_echo_obd_vars;
-}
-#endif /* CONFIG_PROC_FS */
diff --git a/drivers/staging/lustre/lustre/osc/Makefile b/drivers/staging/lustre/lustre/osc/Makefile
index 54927fba4eb463..37cdeea9ac4964 100644
--- a/drivers/staging/lustre/lustre/osc/Makefile
+++ b/drivers/staging/lustre/lustre/osc/Makefile
@@ -1,4 +1,3 @@
obj-$(CONFIG_LUSTRE_FS) += osc.o
osc-y := osc_request.o osc_dev.o osc_object.o \
- osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o
-osc-$(CONFIG_PROC_FS) += lproc_osc.o
+ osc_page.o osc_lock.o osc_io.o osc_quota.o osc_cache.o lproc_osc.o
diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index 15a66209831c56..9dc84ba7aa5502 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -42,25 +42,25 @@
#include <linux/seq_file.h>
#include "osc_internal.h"
-static int osc_active_seq_show(struct seq_file *m, void *v)
+static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
-
- LPROCFS_CLIMP_CHECK(dev);
- seq_printf(m, "%d\n", !dev->u.cli.cl_import->imp_deactive);
- LPROCFS_CLIMP_EXIT(dev);
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
- return 0;
+ return sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive);
}
-static ssize_t osc_active_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
- int val, rc;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
if (val < 0 || val > 1)
@@ -70,41 +70,43 @@ static ssize_t osc_active_seq_write(struct file *file,
if (dev->u.cli.cl_import->imp_deactive == val)
rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
else
- CDEBUG(D_CONFIG, "activate %d: ignoring repeat request\n", val);
+ CDEBUG(D_CONFIG, "activate %ld: ignoring repeat request\n",
+ val);
return count;
}
-LPROC_SEQ_FOPS(osc_active);
+LUSTRE_RW_ATTR(active);
-static int osc_max_rpcs_in_flight_seq_show(struct seq_file *m, void *v)
+static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
- client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%u\n", cli->cl_max_rpcs_in_flight);
- client_obd_list_unlock(&cli->cl_loi_list_lock);
-
- return 0;
+ return sprintf(buf, "%u\n", cli->cl_max_rpcs_in_flight);
}
-static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
struct ptlrpc_request_pool *pool = cli->cl_import->imp_rq_pool;
- int val, rc;
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
if (val < 1 || val > OSC_MAX_RIF_MAX)
return -ERANGE;
- LPROCFS_CLIMP_CHECK(dev);
if (pool && val > cli->cl_max_rpcs_in_flight)
pool->prp_populate(pool, val-cli->cl_max_rpcs_in_flight);
@@ -112,14 +114,16 @@ static ssize_t osc_max_rpcs_in_flight_seq_write(struct file *file,
cli->cl_max_rpcs_in_flight = val;
client_obd_list_unlock(&cli->cl_loi_list_lock);
- LPROCFS_CLIMP_EXIT(dev);
return count;
}
-LPROC_SEQ_FOPS(osc_max_rpcs_in_flight);
+LUSTRE_RW_ATTR(max_rpcs_in_flight);
-static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
+static ssize_t max_dirty_mb_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
long val;
int mult;
@@ -129,22 +133,26 @@ static int osc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
client_obd_list_unlock(&cli->cl_loi_list_lock);
mult = 1 << 20;
- return lprocfs_seq_read_frac_helper(m, val, mult);
+ return lprocfs_read_frac_helper(buf, PAGE_SIZE, val, mult);
}
-static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_dirty_mb_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
- int pages_number, mult, rc;
+ int rc;
+ unsigned long pages_number;
- mult = 1 << (20 - PAGE_CACHE_SHIFT);
- rc = lprocfs_write_frac_helper(buffer, count, &pages_number, mult);
+ rc = kstrtoul(buffer, 10, &pages_number);
if (rc)
return rc;
+ pages_number *= 1 << (20 - PAGE_CACHE_SHIFT); /* MB -> pages */
+
if (pages_number <= 0 ||
pages_number > OSC_MAX_DIRTY_MB_MAX << (20 - PAGE_CACHE_SHIFT) ||
pages_number > totalram_pages / 4) /* 1/4 of RAM */
@@ -157,7 +165,7 @@ static ssize_t osc_max_dirty_mb_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(osc_max_dirty_mb);
+LUSTRE_RW_ATTR(max_dirty_mb);
static int osc_cached_mb_seq_show(struct seq_file *m, void *v)
{
@@ -210,44 +218,51 @@ static ssize_t osc_cached_mb_seq_write(struct file *file,
}
LPROC_SEQ_FOPS(osc_cached_mb);
-static int osc_cur_dirty_bytes_seq_show(struct seq_file *m, void *v)
+static ssize_t cur_dirty_bytes_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
+ int len;
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%lu\n", cli->cl_dirty);
+ len = sprintf(buf, "%lu\n", cli->cl_dirty);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return len;
}
-LPROC_SEQ_FOPS_RO(osc_cur_dirty_bytes);
+LUSTRE_RO_ATTR(cur_dirty_bytes);
-static int osc_cur_grant_bytes_seq_show(struct seq_file *m, void *v)
+static ssize_t cur_grant_bytes_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
+ int len;
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%lu\n", cli->cl_avail_grant);
+ len = sprintf(buf, "%lu\n", cli->cl_avail_grant);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return len;
}
-static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t cur_grant_bytes_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &obd->u.cli;
- int rc;
- __u64 val;
-
- if (obd == NULL)
- return 0;
+ int rc;
+ unsigned long long val;
- rc = lprocfs_write_u64_helper(buffer, count, &val);
+ rc = kstrtoull(buffer, 10, &val);
if (rc)
return rc;
@@ -255,54 +270,56 @@ static ssize_t osc_cur_grant_bytes_seq_write(struct file *file,
client_obd_list_lock(&cli->cl_loi_list_lock);
if (val >= cli->cl_avail_grant) {
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return -EINVAL;
}
client_obd_list_unlock(&cli->cl_loi_list_lock);
- LPROCFS_CLIMP_CHECK(obd);
if (cli->cl_import->imp_state == LUSTRE_IMP_FULL)
rc = osc_shrink_grant_to_target(cli, val);
- LPROCFS_CLIMP_EXIT(obd);
if (rc)
return rc;
return count;
}
-LPROC_SEQ_FOPS(osc_cur_grant_bytes);
+LUSTRE_RW_ATTR(cur_grant_bytes);
-static int osc_cur_lost_grant_bytes_seq_show(struct seq_file *m, void *v)
+static ssize_t cur_lost_grant_bytes_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *dev = m->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
+ int len;
client_obd_list_lock(&cli->cl_loi_list_lock);
- seq_printf(m, "%lu\n", cli->cl_lost_grant);
+ len = sprintf(buf, "%lu\n", cli->cl_lost_grant);
client_obd_list_unlock(&cli->cl_loi_list_lock);
- return 0;
+ return len;
}
-LPROC_SEQ_FOPS_RO(osc_cur_lost_grant_bytes);
+LUSTRE_RO_ATTR(cur_lost_grant_bytes);
-static int osc_grant_shrink_interval_seq_show(struct seq_file *m, void *v)
+static ssize_t grant_shrink_interval_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- if (obd == NULL)
- return 0;
- seq_printf(m, "%d\n", obd->u.cli.cl_grant_shrink_interval);
- return 0;
+ return sprintf(buf, "%d\n", obd->u.cli.cl_grant_shrink_interval);
}
-static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t grant_shrink_interval_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
- int val, rc;
-
- if (obd == NULL)
- return 0;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -313,30 +330,29 @@ static ssize_t osc_grant_shrink_interval_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(osc_grant_shrink_interval);
+LUSTRE_RW_ATTR(grant_shrink_interval);
-static int osc_checksum_seq_show(struct seq_file *m, void *v)
+static ssize_t checksums_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
-
- if (obd == NULL)
- return 0;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- seq_printf(m, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
- return 0;
+ return sprintf(buf, "%d\n", obd->u.cli.cl_checksum ? 1 : 0);
}
-static ssize_t osc_checksum_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t checksums_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
- int val, rc;
-
- if (obd == NULL)
- return 0;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -344,7 +360,7 @@ static ssize_t osc_checksum_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(osc_checksum);
+LUSTRE_RW_ATTR(checksums);
static int osc_checksum_type_seq_show(struct seq_file *m, void *v)
{
@@ -400,22 +416,27 @@ static ssize_t osc_checksum_type_seq_write(struct file *file,
}
LPROC_SEQ_FOPS(osc_checksum_type);
-static int osc_resend_count_seq_show(struct seq_file *m, void *v)
+static ssize_t resend_count_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_resends));
- return 0;
+ return sprintf(buf, "%u\n", atomic_read(&obd->u.cli.cl_resends));
}
-static ssize_t osc_resend_count_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t resend_count_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
- int val, rc;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc)
return rc;
@@ -426,75 +447,94 @@ static ssize_t osc_resend_count_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(osc_resend_count);
+LUSTRE_RW_ATTR(resend_count);
-static int osc_contention_seconds_seq_show(struct seq_file *m, void *v)
+static ssize_t contention_seconds_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct osc_device *od = obd2osc_dev(obd);
- seq_printf(m, "%u\n", od->od_contention_time);
- return 0;
+ return sprintf(buf, "%u\n", od->od_contention_time);
}
-static ssize_t osc_contention_seconds_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t contention_seconds_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct osc_device *od = obd2osc_dev(obd);
return lprocfs_write_helper(buffer, count, &od->od_contention_time) ?:
count;
}
-LPROC_SEQ_FOPS(osc_contention_seconds);
+LUSTRE_RW_ATTR(contention_seconds);
-static int osc_lockless_truncate_seq_show(struct seq_file *m, void *v)
+static ssize_t lockless_truncate_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct osc_device *od = obd2osc_dev(obd);
- seq_printf(m, "%u\n", od->od_lockless_truncate);
- return 0;
+ return sprintf(buf, "%u\n", od->od_lockless_truncate);
}
-static ssize_t osc_lockless_truncate_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t lockless_truncate_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *obd = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
struct osc_device *od = obd2osc_dev(obd);
return lprocfs_write_helper(buffer, count, &od->od_lockless_truncate) ?:
count;
}
-LPROC_SEQ_FOPS(osc_lockless_truncate);
+LUSTRE_RW_ATTR(lockless_truncate);
-static int osc_destroys_in_flight_seq_show(struct seq_file *m, void *v)
+static ssize_t destroys_in_flight_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct obd_device *obd = m->private;
+ struct obd_device *obd = container_of(kobj, struct obd_device,
+ obd_kobj);
- seq_printf(m, "%u\n", atomic_read(&obd->u.cli.cl_destroy_in_flight));
- return 0;
+ return sprintf(buf, "%u\n",
+ atomic_read(&obd->u.cli.cl_destroy_in_flight));
}
-LPROC_SEQ_FOPS_RO(osc_destroys_in_flight);
+LUSTRE_RO_ATTR(destroys_in_flight);
-static int osc_obd_max_pages_per_rpc_seq_show(struct seq_file *m, void *v)
+static ssize_t max_pages_per_rpc_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- return lprocfs_obd_rd_max_pages_per_rpc(m, m->private);
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
+ struct client_obd *cli = &dev->u.cli;
+
+ return sprintf(buf, "%d\n", cli->cl_max_pages_per_rpc);
}
-static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t max_pages_per_rpc_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct obd_device *dev = ((struct seq_file *)file->private_data)->private;
+ struct obd_device *dev = container_of(kobj, struct obd_device,
+ obd_kobj);
struct client_obd *cli = &dev->u.cli;
struct obd_connect_data *ocd = &cli->cl_import->imp_connect_data;
int chunk_mask, rc;
- __u64 val;
+ unsigned long long val;
- rc = lprocfs_write_u64_helper(buffer, count, &val);
+ rc = kstrtoull(buffer, 10, &val);
if (rc)
return rc;
@@ -502,32 +542,21 @@ static ssize_t osc_obd_max_pages_per_rpc_seq_write(struct file *file,
if (val >= ONE_MB_BRW_SIZE)
val >>= PAGE_CACHE_SHIFT;
- LPROCFS_CLIMP_CHECK(dev);
-
chunk_mask = ~((1 << (cli->cl_chunkbits - PAGE_CACHE_SHIFT)) - 1);
/* max_pages_per_rpc must be chunk aligned */
val = (val + ~chunk_mask) & chunk_mask;
if (val == 0 || val > ocd->ocd_brw_size >> PAGE_CACHE_SHIFT) {
- LPROCFS_CLIMP_EXIT(dev);
return -ERANGE;
}
client_obd_list_lock(&cli->cl_loi_list_lock);
cli->cl_max_pages_per_rpc = val;
client_obd_list_unlock(&cli->cl_loi_list_lock);
- LPROCFS_CLIMP_EXIT(dev);
return count;
}
-LPROC_SEQ_FOPS(osc_obd_max_pages_per_rpc);
+LUSTRE_RW_ATTR(max_pages_per_rpc);
-LPROC_SEQ_FOPS_RO_TYPE(osc, uuid);
LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
-LPROC_SEQ_FOPS_RO_TYPE(osc, blksize);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytestotal);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesfree);
-LPROC_SEQ_FOPS_RO_TYPE(osc, kbytesavail);
-LPROC_SEQ_FOPS_RO_TYPE(osc, filestotal);
-LPROC_SEQ_FOPS_RO_TYPE(osc, filesfree);
LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
LPROC_SEQ_FOPS_RO_TYPE(osc, conn_uuid);
LPROC_SEQ_FOPS_RO_TYPE(osc, timeouts);
@@ -539,46 +568,20 @@ LPROC_SEQ_FOPS_RW_TYPE(osc, import);
LPROC_SEQ_FOPS_RW_TYPE(osc, pinger_recov);
static struct lprocfs_vars lprocfs_osc_obd_vars[] = {
- { "uuid", &osc_uuid_fops, NULL, 0 },
{ "ping", &osc_ping_fops, NULL, 0222 },
{ "connect_flags", &osc_connect_flags_fops, NULL, 0 },
- { "blocksize", &osc_blksize_fops, NULL, 0 },
- { "kbytestotal", &osc_kbytestotal_fops, NULL, 0 },
- { "kbytesfree", &osc_kbytesfree_fops, NULL, 0 },
- { "kbytesavail", &osc_kbytesavail_fops, NULL, 0 },
- { "filestotal", &osc_filestotal_fops, NULL, 0 },
- { "filesfree", &osc_filesfree_fops, NULL, 0 },
/*{ "filegroups", lprocfs_rd_filegroups, NULL, 0 },*/
{ "ost_server_uuid", &osc_server_uuid_fops, NULL, 0 },
{ "ost_conn_uuid", &osc_conn_uuid_fops, NULL, 0 },
- { "active", &osc_active_fops, NULL },
- { "max_pages_per_rpc", &osc_obd_max_pages_per_rpc_fops, NULL },
- { "max_rpcs_in_flight", &osc_max_rpcs_in_flight_fops, NULL },
- { "destroys_in_flight", &osc_destroys_in_flight_fops, NULL, 0 },
- { "max_dirty_mb", &osc_max_dirty_mb_fops, NULL },
{ "osc_cached_mb", &osc_cached_mb_fops, NULL },
- { "cur_dirty_bytes", &osc_cur_dirty_bytes_fops, NULL, 0 },
- { "cur_grant_bytes", &osc_cur_grant_bytes_fops, NULL },
- { "cur_lost_grant_bytes", &osc_cur_lost_grant_bytes_fops, NULL, 0},
- { "grant_shrink_interval", &osc_grant_shrink_interval_fops, NULL },
- { "checksums", &osc_checksum_fops, NULL },
{ "checksum_type", &osc_checksum_type_fops, NULL },
- { "resend_count", &osc_resend_count_fops, NULL},
{ "timeouts", &osc_timeouts_fops, NULL, 0 },
- { "contention_seconds", &osc_contention_seconds_fops, NULL },
- { "lockless_truncate", &osc_lockless_truncate_fops, NULL },
{ "import", &osc_import_fops, NULL },
{ "state", &osc_state_fops, NULL, 0 },
{ "pinger_recov", &osc_pinger_recov_fops, NULL },
{ NULL }
};
-LPROC_SEQ_FOPS_RO_TYPE(osc, numrefs);
-static struct lprocfs_vars lprocfs_osc_module_vars[] = {
- { "num_refs", &osc_numrefs_fops, NULL, 0 },
- { NULL }
-};
-
#define pct(a, b) (b ? a * 100 / b : 0)
static int osc_rpc_stats_seq_show(struct seq_file *seq, void *v)
@@ -735,17 +738,38 @@ int lproc_osc_attach_seqstat(struct obd_device *dev)
{
int rc;
- rc = lprocfs_seq_create(dev->obd_proc_entry, "osc_stats", 0644,
- &osc_stats_fops, dev);
+ rc = ldebugfs_seq_create(dev->obd_debugfs_entry, "osc_stats", 0644,
+ &osc_stats_fops, dev);
if (rc == 0)
- rc = lprocfs_obd_seq_create(dev, "rpc_stats", 0644,
- &osc_rpc_stats_fops, dev);
+ rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644,
+ &osc_rpc_stats_fops, dev);
return rc;
}
+static struct attribute *osc_attrs[] = {
+ &lustre_attr_active.attr,
+ &lustre_attr_checksums.attr,
+ &lustre_attr_contention_seconds.attr,
+ &lustre_attr_cur_dirty_bytes.attr,
+ &lustre_attr_cur_grant_bytes.attr,
+ &lustre_attr_cur_lost_grant_bytes.attr,
+ &lustre_attr_destroys_in_flight.attr,
+ &lustre_attr_grant_shrink_interval.attr,
+ &lustre_attr_lockless_truncate.attr,
+ &lustre_attr_max_dirty_mb.attr,
+ &lustre_attr_max_pages_per_rpc.attr,
+ &lustre_attr_max_rpcs_in_flight.attr,
+ &lustre_attr_resend_count.attr,
+ NULL,
+};
+
+static struct attribute_group osc_attr_group = {
+ .attrs = osc_attrs,
+};
+
void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
{
- lvars->module_vars = lprocfs_osc_module_vars;
+ lvars->sysfs_vars = &osc_attr_group;
lvars->obd_vars = lprocfs_osc_obd_vars;
}
diff --git a/drivers/staging/lustre/lustre/osc/osc_dev.c b/drivers/staging/lustre/lustre/osc/osc_dev.c
index 4935fc7c0706ba..ce5c3af1237b48 100644
--- a/drivers/staging/lustre/lustre/osc/osc_dev.c
+++ b/drivers/staging/lustre/lustre/osc/osc_dev.c
@@ -204,7 +204,7 @@ static struct lu_device *osc_device_free(const struct lu_env *env,
struct osc_device *od = lu2osc_dev(d);
cl_device_fini(lu2cl_dev(d));
- OBD_FREE_PTR(od);
+ kfree(od);
return NULL;
}
@@ -217,7 +217,7 @@ static struct lu_device *osc_device_alloc(const struct lu_env *env,
struct obd_device *obd;
int rc;
- OBD_ALLOC_PTR(od);
+ od = kzalloc(sizeof(*od), GFP_NOFS);
if (od == NULL)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h b/drivers/staging/lustre/lustre/osc/osc_internal.h
index af96c7bc7764d7..470698b0dd7528 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -136,16 +136,8 @@ extern spinlock_t osc_ast_guard;
int osc_cleanup(struct obd_device *obd);
int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
-#if defined (CONFIG_PROC_FS)
int lproc_osc_attach_seqstat(struct obd_device *dev);
void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
-#else
-static inline int lproc_osc_attach_seqstat(struct obd_device *dev) {return 0;}
-static inline void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars)
-{
- memset(lvars, 0, sizeof(*lvars));
-}
-#endif
extern struct lu_device_type osc_device_type;
diff --git a/drivers/staging/lustre/lustre/osc/osc_request.c b/drivers/staging/lustre/lustre/osc/osc_request.c
index d7a9b650df09ce..6b6851ad399030 100644
--- a/drivers/staging/lustre/lustre/osc/osc_request.c
+++ b/drivers/staging/lustre/lustre/osc/osc_request.c
@@ -110,7 +110,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
return lmm_size;
if (*lmmp != NULL && lsm == NULL) {
- OBD_FREE(*lmmp, lmm_size);
+ kfree(*lmmp);
*lmmp = NULL;
return 0;
} else if (unlikely(lsm != NULL && ostid_id(&lsm->lsm_oi) == 0)) {
@@ -118,7 +118,7 @@ static int osc_packmd(struct obd_export *exp, struct lov_mds_md **lmmp,
}
if (*lmmp == NULL) {
- OBD_ALLOC(*lmmp, lmm_size);
+ *lmmp = kzalloc(lmm_size, GFP_NOFS);
if (*lmmp == NULL)
return -ENOMEM;
}
@@ -157,19 +157,20 @@ static int osc_unpackmd(struct obd_export *exp, struct lov_stripe_md **lsmp,
return lsm_size;
if (*lsmp != NULL && lmm == NULL) {
- OBD_FREE((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo));
- OBD_FREE(*lsmp, lsm_size);
+ kfree((*lsmp)->lsm_oinfo[0]);
+ kfree(*lsmp);
*lsmp = NULL;
return 0;
}
if (*lsmp == NULL) {
- OBD_ALLOC(*lsmp, lsm_size);
+ *lsmp = kzalloc(lsm_size, GFP_NOFS);
if (unlikely(*lsmp == NULL))
return -ENOMEM;
- OBD_ALLOC((*lsmp)->lsm_oinfo[0], sizeof(struct lov_oinfo));
+ (*lsmp)->lsm_oinfo[0] = kzalloc(sizeof(struct lov_oinfo),
+ GFP_NOFS);
if (unlikely((*lsmp)->lsm_oinfo[0] == NULL)) {
- OBD_FREE(*lsmp, lsm_size);
+ kfree(*lsmp);
return -ENOMEM;
}
loi_init((*lsmp)->lsm_oinfo[0]);
@@ -962,7 +963,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
}
client_obd_list_unlock(&cli->cl_loi_list_lock);
- OBD_ALLOC_PTR(body);
+ body = kzalloc(sizeof(*body), GFP_NOFS);
if (!body)
return -ENOMEM;
@@ -984,7 +985,7 @@ int osc_shrink_grant_to_target(struct client_obd *cli, __u64 target_bytes)
sizeof(*body), body, NULL);
if (rc != 0)
__osc_update_grant(cli, body->oa.o_grant);
- OBD_FREE_PTR(body);
+ kfree(body);
return rc;
}
@@ -1748,7 +1749,7 @@ static void sort_brw_pages(struct brw_page **array, int num)
static void osc_release_ppga(struct brw_page **ppga, u32 count)
{
LASSERT(ppga != NULL);
- OBD_FREE(ppga, sizeof(*ppga) * count);
+ kfree(ppga);
}
static int brw_interpret(const struct lu_env *env,
@@ -1908,13 +1909,13 @@ int osc_build_rpc(const struct lu_env *env, struct client_obd *cli,
if (mem_tight)
mpflag = cfs_memory_pressure_get_and_set();
- OBD_ALLOC(crattr, sizeof(*crattr));
+ crattr = kzalloc(sizeof(*crattr), GFP_NOFS);
if (crattr == NULL) {
rc = -ENOMEM;
goto out;
}
- OBD_ALLOC(pga, sizeof(*pga) * page_count);
+ pga = kcalloc(page_count, sizeof(*pga), GFP_NOFS);
if (pga == NULL) {
rc = -ENOMEM;
goto out;
@@ -2055,7 +2056,7 @@ out:
if (crattr != NULL) {
capa_put(crattr->cra_capa);
- OBD_FREE(crattr, sizeof(*crattr));
+ kfree(crattr);
}
if (rc != 0) {
@@ -2063,8 +2064,7 @@ out:
if (oa)
OBDO_FREE(oa);
- if (pga)
- OBD_FREE(pga, sizeof(*pga) * page_count);
+ kfree(pga);
/* this should happen rarely and is pretty bad, it makes the
* pending list not follow the dirty order */
while (!list_empty(ext_list)) {
@@ -2617,7 +2617,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
* because lov_user_md_vX and lov_mds_md_vX have the same size */
if (lum.lmm_stripe_count > 0) {
lum_size = lov_mds_md_size(lum.lmm_stripe_count, lum.lmm_magic);
- OBD_ALLOC(lumk, lum_size);
+ lumk = kzalloc(lum_size, GFP_NOFS);
if (!lumk)
return -ENOMEM;
@@ -2639,7 +2639,7 @@ static int osc_getstripe(struct lov_stripe_md *lsm, struct lov_user_md *lump)
rc = -EFAULT;
if (lumk != &lum)
- OBD_FREE(lumk, lum_size);
+ kfree(lumk);
return rc;
}
@@ -3184,7 +3184,7 @@ int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
cli->cl_grant_shrink_interval = GRANT_SHRINK_INTERVAL;
lprocfs_osc_init_vars(&lvars);
- if (lprocfs_obd_setup(obd, lvars.obd_vars) == 0) {
+ if (lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars) == 0) {
lproc_osc_attach_seqstat(obd);
sptlrpc_lprocfs_cliobd_attach(obd);
ptlrpc_lprocfs_register_obd(obd);
@@ -3351,7 +3351,7 @@ static int __init osc_init(void)
lprocfs_osc_init_vars(&lvars);
- rc = class_register_type(&osc_obd_ops, NULL, lvars.module_vars,
+ rc = class_register_type(&osc_obd_ops, NULL,
LUSTRE_OSC_NAME, &osc_device_type);
if (rc) {
lu_kmem_fini(osc_caches);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/Makefile b/drivers/staging/lustre/lustre/ptlrpc/Makefile
index fb50cd4c65b653..24bbac19ddd1bd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/Makefile
+++ b/drivers/staging/lustre/lustre/ptlrpc/Makefile
@@ -15,6 +15,5 @@ ptlrpc_objs += pers.o lproc_ptlrpc.o wiretest.o layout.o
ptlrpc_objs += sec.o sec_bulk.o sec_gc.o sec_config.o
ptlrpc_objs += sec_null.o sec_plain.o nrs.o nrs_fifo.o
-ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs)
-ptlrpc-$(CONFIG_PROC_FS) += sec_lproc.o
+ptlrpc-y := $(ldlm_objs) $(ptlrpc_objs) sec_lproc.o
ptlrpc-$(CONFIG_LUSTRE_TRANSLATE_ERRNOS) += errno.o
diff --git a/drivers/staging/lustre/lustre/ptlrpc/client.c b/drivers/staging/lustre/lustre/ptlrpc/client.c
index 0357f1d4532f37..347110e6e822e6 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/client.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/client.c
@@ -103,7 +103,8 @@ struct ptlrpc_bulk_desc *ptlrpc_new_bulk(unsigned npages, unsigned max_brw,
struct ptlrpc_bulk_desc *desc;
int i;
- OBD_ALLOC(desc, offsetof(struct ptlrpc_bulk_desc, bd_iov[npages]));
+ desc = kzalloc(offsetof(struct ptlrpc_bulk_desc, bd_iov[npages]),
+ GFP_NOFS);
if (!desc)
return NULL;
@@ -205,8 +206,7 @@ void __ptlrpc_free_bulk(struct ptlrpc_bulk_desc *desc, int unpin)
page_cache_release(desc->bd_iov[i].kiov_page);
}
- OBD_FREE(desc, offsetof(struct ptlrpc_bulk_desc,
- bd_iov[desc->bd_max_iov]));
+ kfree(desc);
}
EXPORT_SYMBOL(__ptlrpc_free_bulk);
@@ -390,7 +390,7 @@ static int ptlrpc_at_recv_early_reply(struct ptlrpc_request *req)
return rc;
}
-struct kmem_cache *request_cache;
+static struct kmem_cache *request_cache;
int ptlrpc_request_cache_init(void)
{
@@ -439,7 +439,7 @@ void ptlrpc_free_rq_pool(struct ptlrpc_request_pool *pool)
ptlrpc_request_cache_free(req);
}
spin_unlock(&pool->prp_lock);
- OBD_FREE(pool, sizeof(*pool));
+ kfree(pool);
}
EXPORT_SYMBOL(ptlrpc_free_rq_pool);
@@ -498,7 +498,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize,
{
struct ptlrpc_request_pool *pool;
- OBD_ALLOC(pool, sizeof(struct ptlrpc_request_pool));
+ pool = kzalloc(sizeof(struct ptlrpc_request_pool), GFP_NOFS);
if (!pool)
return NULL;
@@ -514,7 +514,7 @@ ptlrpc_init_rq_pool(int num_rq, int msgsize,
if (list_empty(&pool->prp_req_list)) {
/* have not allocated a single request for the pool */
- OBD_FREE(pool, sizeof(struct ptlrpc_request_pool));
+ kfree(pool);
pool = NULL;
}
return pool;
@@ -856,7 +856,7 @@ struct ptlrpc_request_set *ptlrpc_prep_set(void)
{
struct ptlrpc_request_set *set;
- OBD_ALLOC(set, sizeof(*set));
+ set = kzalloc(sizeof(*set), GFP_NOFS);
if (!set)
return NULL;
atomic_set(&set->set_refcount, 1);
@@ -970,7 +970,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
{
struct ptlrpc_set_cbdata *cbdata;
- OBD_ALLOC_PTR(cbdata);
+ cbdata = kzalloc(sizeof(*cbdata), GFP_NOFS);
if (cbdata == NULL)
return -ENOMEM;
@@ -2214,7 +2214,7 @@ int ptlrpc_set_wait(struct ptlrpc_request_set *set)
err = cbdata->psc_interpret(set, cbdata->psc_data, rc);
if (err && !rc)
rc = err;
- OBD_FREE_PTR(cbdata);
+ kfree(cbdata);
}
}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/connection.c b/drivers/staging/lustre/lustre/ptlrpc/connection.c
index 7e27397ce384c2..ffe36e22245feb 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/connection.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/connection.c
@@ -54,7 +54,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
if (conn)
goto out;
- OBD_ALLOC_PTR(conn);
+ conn = kzalloc(sizeof(*conn), GFP_NOFS);
if (!conn)
return NULL;
@@ -76,7 +76,7 @@ ptlrpc_connection_get(lnet_process_id_t peer, lnet_nid_t self,
/* coverity[overrun-buffer-val] */
conn2 = cfs_hash_findadd_unique(conn_hash, &peer, &conn->c_hash);
if (conn != conn2) {
- OBD_FREE_PTR(conn);
+ kfree(conn);
conn = conn2;
}
out:
@@ -227,7 +227,7 @@ conn_exit(struct cfs_hash *hs, struct hlist_node *hnode)
LASSERTF(atomic_read(&conn->c_refcount) == 0,
"Busy connection with %d refs\n",
atomic_read(&conn->c_refcount));
- OBD_FREE_PTR(conn);
+ kfree(conn);
}
static cfs_hash_ops_t conn_hash_ops = {
diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
index 9533ab976a33a2..1362160983a9e3 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
@@ -181,19 +181,19 @@ static const char *ll_eopcode2str(__u32 opcode)
return ll_eopcode_table[opcode].opname;
}
-#if defined(CONFIG_PROC_FS)
-static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
- char *name,
- struct proc_dir_entry **procroot_ret,
- struct lprocfs_stats **stats_ret)
+static void
+ptlrpc_ldebugfs_register(struct dentry *root, char *dir,
+ char *name,
+ struct dentry **debugfs_root_ret,
+ struct lprocfs_stats **stats_ret)
{
- struct proc_dir_entry *svc_procroot;
+ struct dentry *svc_debugfs_entry;
struct lprocfs_stats *svc_stats;
int i, rc;
unsigned int svc_counter_config = LPROCFS_CNTR_AVGMINMAX |
LPROCFS_CNTR_STDDEV;
- LASSERT(*procroot_ret == NULL);
+ LASSERT(*debugfs_root_ret == NULL);
LASSERT(*stats_ret == NULL);
svc_stats = lprocfs_alloc_stats(EXTRA_MAX_OPCODES+LUSTRE_MAX_OPCODES,
@@ -201,14 +201,14 @@ static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
if (svc_stats == NULL)
return;
- if (dir) {
- svc_procroot = lprocfs_register(dir, root, NULL, NULL);
- if (IS_ERR(svc_procroot)) {
+ if (dir != NULL) {
+ svc_debugfs_entry = ldebugfs_register(dir, root, NULL, NULL);
+ if (IS_ERR(svc_debugfs_entry)) {
lprocfs_free_stats(&svc_stats);
return;
}
} else {
- svc_procroot = root;
+ svc_debugfs_entry = root;
}
lprocfs_counter_init(svc_stats, PTLRPC_REQWAIT_CNTR,
@@ -244,14 +244,14 @@ static void ptlrpc_lprocfs_register(struct proc_dir_entry *root, char *dir,
ll_opcode2str(opcode), "usec");
}
- rc = lprocfs_register_stats(svc_procroot, name, svc_stats);
+ rc = ldebugfs_register_stats(svc_debugfs_entry, name, svc_stats);
if (rc < 0) {
- if (dir)
- lprocfs_remove(&svc_procroot);
+ if (dir != NULL)
+ ldebugfs_remove(&svc_debugfs_entry);
lprocfs_free_stats(&svc_stats);
} else {
- if (dir)
- *procroot_ret = svc_procroot;
+ if (dir != NULL)
+ *debugfs_root_ret = svc_debugfs_entry;
*stats_ret = svc_stats;
}
}
@@ -324,23 +324,23 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file,
}
LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max);
-static int
-ptlrpc_lprocfs_threads_min_seq_show(struct seq_file *m, void *n)
+
+static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ptlrpc_service *svc = m->private;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
- seq_printf(m, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts);
- return 0;
+ return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts);
}
-static ssize_t
-ptlrpc_lprocfs_threads_min_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t threads_min_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
- int val;
- int rc = lprocfs_write_helper(buffer, count, &val);
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+ unsigned long val;
+ int rc = kstrtoul(buffer, 10, &val);
if (rc < 0)
return rc;
@@ -360,41 +360,41 @@ ptlrpc_lprocfs_threads_min_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_min);
+LUSTRE_RW_ATTR(threads_min);
-static int
-ptlrpc_lprocfs_threads_started_seq_show(struct seq_file *m, void *n)
+static ssize_t threads_started_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct ptlrpc_service *svc = m->private;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
struct ptlrpc_service_part *svcpt;
- int total = 0;
- int i;
+ int total = 0;
+ int i;
ptlrpc_service_for_each_part(svcpt, i, svc)
total += svcpt->scp_nthrs_running;
- seq_printf(m, "%d\n", total);
- return 0;
+ return sprintf(buf, "%d\n", total);
}
-LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_threads_started);
+LUSTRE_RO_ATTR(threads_started);
-static int
-ptlrpc_lprocfs_threads_max_seq_show(struct seq_file *m, void *n)
+static ssize_t threads_max_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- struct ptlrpc_service *svc = m->private;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
- seq_printf(m, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts);
- return 0;
+ return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts);
}
-static ssize_t
-ptlrpc_lprocfs_threads_max_seq_write(struct file *file,
- const char __user *buffer,
- size_t count, loff_t *off)
+static ssize_t threads_max_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
{
- struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
- int val;
- int rc = lprocfs_write_helper(buffer, count, &val);
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+ unsigned long val;
+ int rc = kstrtoul(buffer, 10, &val);
if (rc < 0)
return rc;
@@ -414,7 +414,7 @@ ptlrpc_lprocfs_threads_max_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_max);
+LUSTRE_RW_ATTR(threads_max);
/**
* \addtogoup nrs
@@ -507,10 +507,10 @@ static int ptlrpc_lprocfs_nrs_seq_show(struct seq_file *m, void *n)
num_pols = svc->srv_parts[0]->scp_nrs_reg.nrs_num_pols;
spin_unlock(&nrs->nrs_lock);
- OBD_ALLOC(infos, num_pols * sizeof(*infos));
+ infos = kcalloc(num_pols, sizeof(*infos), GFP_NOFS);
if (infos == NULL) {
rc = -ENOMEM;
- goto out;
+ goto unlock;
}
again:
@@ -617,10 +617,8 @@ again:
goto again;
}
-out:
- if (infos)
- OBD_FREE(infos, num_pols * sizeof(*infos));
-
+ kfree(infos);
+unlock:
mutex_unlock(&nrs_core.nrs_mutex);
return rc;
@@ -650,16 +648,12 @@ static ssize_t ptlrpc_lprocfs_nrs_seq_write(struct file *file,
char *token;
int rc = 0;
- if (count >= LPROCFS_NRS_WR_MAX_CMD) {
- rc = -EINVAL;
- goto out;
- }
+ if (count >= LPROCFS_NRS_WR_MAX_CMD)
+ return -EINVAL;
- OBD_ALLOC(cmd, LPROCFS_NRS_WR_MAX_CMD);
- if (cmd == NULL) {
- rc = -ENOMEM;
- goto out;
- }
+ cmd = kzalloc(LPROCFS_NRS_WR_MAX_CMD, GFP_NOFS);
+ if (cmd == NULL)
+ return -ENOMEM;
/**
* strsep() modifies its argument, so keep a copy
*/
@@ -716,8 +710,7 @@ default_queue:
mutex_unlock(&nrs_core.nrs_mutex);
out:
- if (cmd_copy)
- OBD_FREE(cmd_copy, LPROCFS_NRS_WR_MAX_CMD);
+ kfree(cmd_copy);
return rc < 0 ? rc : count;
}
@@ -825,7 +818,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
return NULL;
}
- OBD_ALLOC(srhi, sizeof(*srhi));
+ srhi = kzalloc(sizeof(*srhi), GFP_NOFS);
if (srhi == NULL)
return NULL;
@@ -851,7 +844,7 @@ ptlrpc_lprocfs_svc_req_history_start(struct seq_file *s, loff_t *pos)
}
}
- OBD_FREE(srhi, sizeof(*srhi));
+ kfree(srhi);
return NULL;
}
@@ -860,8 +853,7 @@ ptlrpc_lprocfs_svc_req_history_stop(struct seq_file *s, void *iter)
{
struct ptlrpc_srh_iterator *srhi = iter;
- if (srhi != NULL)
- OBD_FREE(srhi, sizeof(*srhi));
+ kfree(srhi);
}
static void *
@@ -895,7 +887,7 @@ ptlrpc_lprocfs_svc_req_history_next(struct seq_file *s,
}
}
- OBD_FREE(srhi, sizeof(*srhi));
+ kfree(srhi);
return NULL;
}
@@ -988,7 +980,7 @@ ptlrpc_lprocfs_svc_req_history_open(struct inode *inode, struct file *file)
return rc;
seqf = file->private_data;
- seqf->private = PDE_DATA(inode);
+ seqf->private = inode->i_private;
return 0;
}
@@ -1026,23 +1018,26 @@ static int ptlrpc_lprocfs_timeouts_seq_show(struct seq_file *m, void *n)
}
LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_timeouts);
-static int ptlrpc_lprocfs_hp_ratio_seq_show(struct seq_file *m, void *v)
+static ssize_t high_priority_ratio_show(struct kobject *kobj,
+ struct attribute *attr,
+ char *buf)
{
- struct ptlrpc_service *svc = m->private;
- seq_printf(m, "%d", svc->srv_hpreq_ratio);
- return 0;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+ return sprintf(buf, "%d\n", svc->srv_hpreq_ratio);
}
-static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file,
- const char __user *buffer,
- size_t count,
- loff_t *off)
+static ssize_t high_priority_ratio_store(struct kobject *kobj,
+ struct attribute *attr,
+ const char *buffer,
+ size_t count)
{
- struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private;
- int rc;
- int val;
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+ int rc;
+ unsigned long val;
- rc = lprocfs_write_helper(buffer, count, &val);
+ rc = kstrtoul(buffer, 10, &val);
if (rc < 0)
return rc;
@@ -1055,30 +1050,62 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file,
return count;
}
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio);
+LUSTRE_RW_ATTR(high_priority_ratio);
+
+static struct attribute *ptlrpc_svc_attrs[] = {
+ &lustre_attr_threads_min.attr,
+ &lustre_attr_threads_started.attr,
+ &lustre_attr_threads_max.attr,
+ &lustre_attr_high_priority_ratio.attr,
+ NULL,
+};
+
+static void ptlrpc_sysfs_svc_release(struct kobject *kobj)
+{
+ struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service,
+ srv_kobj);
+
+ complete(&svc->srv_kobj_unregister);
+}
+
+static struct kobj_type ptlrpc_svc_ktype = {
+ .default_attrs = ptlrpc_svc_attrs,
+ .sysfs_ops = &lustre_sysfs_ops,
+ .release = ptlrpc_sysfs_svc_release,
+};
+
+void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc)
+{
+ /* Let's see if we had a chance at initialization first */
+ if (svc->srv_kobj.kset) {
+ kobject_put(&svc->srv_kobj);
+ wait_for_completion(&svc->srv_kobj_unregister);
+ }
+}
-void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry,
- struct ptlrpc_service *svc)
+int ptlrpc_sysfs_register_service(struct kset *parent,
+ struct ptlrpc_service *svc)
+{
+ int rc;
+
+ svc->srv_kobj.kset = parent;
+ init_completion(&svc->srv_kobj_unregister);
+ rc = kobject_init_and_add(&svc->srv_kobj, &ptlrpc_svc_ktype, NULL,
+ "%s", svc->srv_name);
+
+ return rc;
+}
+
+void ptlrpc_ldebugfs_register_service(struct dentry *entry,
+ struct ptlrpc_service *svc)
{
struct lprocfs_vars lproc_vars[] = {
- {.name = "high_priority_ratio",
- .fops = &ptlrpc_lprocfs_hp_ratio_fops,
- .data = svc},
{.name = "req_buffer_history_len",
.fops = &ptlrpc_lprocfs_req_history_len_fops,
.data = svc},
{.name = "req_buffer_history_max",
.fops = &ptlrpc_lprocfs_req_history_max_fops,
.data = svc},
- {.name = "threads_min",
- .fops = &ptlrpc_lprocfs_threads_min_fops,
- .data = svc},
- {.name = "threads_max",
- .fops = &ptlrpc_lprocfs_threads_max_fops,
- .data = svc},
- {.name = "threads_started",
- .fops = &ptlrpc_lprocfs_threads_started_fops,
- .data = svc},
{.name = "timeouts",
.fops = &ptlrpc_lprocfs_timeouts_fops,
.data = svc},
@@ -1097,26 +1124,26 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry,
int rc;
- ptlrpc_lprocfs_register(entry, svc->srv_name,
- "stats", &svc->srv_procroot,
- &svc->srv_stats);
+ ptlrpc_ldebugfs_register(entry, svc->srv_name,
+ "stats", &svc->srv_debugfs_entry,
+ &svc->srv_stats);
- if (svc->srv_procroot == NULL)
+ if (svc->srv_debugfs_entry == NULL)
return;
- lprocfs_add_vars(svc->srv_procroot, lproc_vars, NULL);
+ ldebugfs_add_vars(svc->srv_debugfs_entry, lproc_vars, NULL);
- rc = lprocfs_seq_create(svc->srv_procroot, "req_history",
- 0400, &req_history_fops, svc);
+ rc = ldebugfs_seq_create(svc->srv_debugfs_entry, "req_history",
+ 0400, &req_history_fops, svc);
if (rc)
CWARN("Error adding the req_history file\n");
}
void ptlrpc_lprocfs_register_obd(struct obd_device *obddev)
{
- ptlrpc_lprocfs_register(obddev->obd_proc_entry, NULL, "stats",
- &obddev->obd_svc_procroot,
- &obddev->obd_svc_stats);
+ ptlrpc_ldebugfs_register(obddev->obd_debugfs_entry, NULL, "stats",
+ &obddev->obd_svc_debugfs_entry,
+ &obddev->obd_svc_stats);
}
EXPORT_SYMBOL(ptlrpc_lprocfs_register_obd);
@@ -1164,8 +1191,8 @@ EXPORT_SYMBOL(ptlrpc_lprocfs_brw);
void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
{
- if (svc->srv_procroot != NULL)
- lprocfs_remove(&svc->srv_procroot);
+ if (svc->srv_debugfs_entry != NULL)
+ ldebugfs_remove(&svc->srv_debugfs_entry);
if (svc->srv_stats)
lprocfs_free_stats(&svc->srv_stats);
@@ -1173,8 +1200,8 @@ void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc)
void ptlrpc_lprocfs_unregister_obd(struct obd_device *obd)
{
- if (obd->obd_svc_procroot)
- lprocfs_remove(&obd->obd_svc_procroot);
+ if (!IS_ERR_OR_NULL(obd->obd_svc_debugfs_entry))
+ ldebugfs_remove(&obd->obd_svc_debugfs_entry);
if (obd->obd_svc_stats)
lprocfs_free_stats(&obd->obd_svc_stats);
@@ -1191,7 +1218,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
char *kbuf;
char *tmpbuf;
- OBD_ALLOC(kbuf, BUFLEN);
+ kbuf = kzalloc(BUFLEN, GFP_NOFS);
if (kbuf == NULL)
return -ENOMEM;
@@ -1209,7 +1236,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
/* Kludge code(deadlock situation): the lprocfs lock has been held
* since the client is evicted by writing client's
* uuid/nid to procfs "evict_client" entry. However,
- * obd_export_evict_by_uuid() will call lprocfs_remove() to destroy
+ * obd_export_evict_by_uuid() will call ldebugfs_remove() to destroy
* the proc entries under the being destroyed export{}, so I have
* to drop the lock at first here.
* - jay, jxiong@clusterfs.com */
@@ -1225,7 +1252,7 @@ int lprocfs_wr_evict_client(struct file *file, const char __user *buffer,
class_decref(obd, __func__, current);
out:
- OBD_FREE(kbuf, BUFLEN);
+ kfree(kbuf);
return count;
}
EXPORT_SYMBOL(lprocfs_wr_evict_client);
@@ -1275,7 +1302,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
if (count > PAGE_CACHE_SIZE - 1 || count <= prefix_len)
return -EINVAL;
- OBD_ALLOC(kbuf, count + 1);
+ kbuf = kzalloc(count + 1, GFP_NOFS);
if (kbuf == NULL)
return -ENOMEM;
@@ -1319,7 +1346,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
ptlrpc_recover_import(imp, uuid, 1);
out:
- OBD_FREE(kbuf, count + 1);
+ kfree(kbuf);
return count;
}
EXPORT_SYMBOL(lprocfs_wr_import);
@@ -1362,5 +1389,3 @@ int lprocfs_wr_pinger_recov(struct file *file, const char __user *buffer,
}
EXPORT_SYMBOL(lprocfs_wr_pinger_recov);
-
-#endif /* CONFIG_PROC_FS */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs.c b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
index 81ad7473242eda..d38a1af8bfd746 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs.c
@@ -478,7 +478,7 @@ static void nrs_resource_get_safe(struct ptlrpc_nrs *nrs,
*
* \param resp the resource hierarchy that is being released
*
- * \see ptlrpcnrs_req_hp_move()
+ * \see ptlrpc_nrs_req_hp_move()
* \see ptlrpc_nrs_req_finalize()
*/
static void nrs_resource_put_safe(struct ptlrpc_nrs_resource **resp)
@@ -715,7 +715,7 @@ static int nrs_policy_unregister(struct ptlrpc_nrs *nrs, char *name)
nrs_policy_fini(policy);
LASSERT(policy->pol_private == NULL);
- OBD_FREE_PTR(policy);
+ kfree(policy);
return 0;
}
@@ -746,8 +746,9 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
LASSERT(desc->pd_ops->op_req_dequeue != NULL);
LASSERT(desc->pd_compat != NULL);
- OBD_CPT_ALLOC_GFP(policy, svcpt->scp_service->srv_cptable,
- svcpt->scp_cpt, sizeof(*policy), GFP_NOFS);
+ policy = kzalloc_node(sizeof(*policy), GFP_NOFS,
+ cfs_cpt_spread_node(svcpt->scp_service->srv_cptable,
+ svcpt->scp_cpt));
if (policy == NULL)
return -ENOMEM;
@@ -761,7 +762,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
rc = nrs_policy_init(policy);
if (rc != 0) {
- OBD_FREE_PTR(policy);
+ kfree(policy);
return rc;
}
@@ -776,7 +777,7 @@ static int nrs_policy_register(struct ptlrpc_nrs *nrs,
spin_unlock(&nrs->nrs_lock);
nrs_policy_fini(policy);
- OBD_FREE_PTR(policy);
+ kfree(policy);
return -EEXIST;
}
@@ -961,9 +962,10 @@ static int nrs_svcpt_setup_locked(struct ptlrpc_service_part *svcpt)
if (svcpt->scp_service->srv_ops.so_hpreq_handler == NULL)
goto out;
- OBD_CPT_ALLOC_PTR(svcpt->scp_nrs_hp,
- svcpt->scp_service->srv_cptable,
- svcpt->scp_cpt);
+ svcpt->scp_nrs_hp =
+ kzalloc_node(sizeof(*svcpt->scp_nrs_hp), GFP_NOFS,
+ cfs_cpt_spread_node(svcpt->scp_service->srv_cptable,
+ svcpt->scp_cpt));
if (svcpt->scp_nrs_hp == NULL) {
rc = -ENOMEM;
goto out;
@@ -1013,7 +1015,7 @@ again:
}
if (hp)
- OBD_FREE_PTR(nrs);
+ kfree(nrs);
}
/**
@@ -1153,7 +1155,7 @@ int ptlrpc_nrs_policy_register(struct ptlrpc_nrs_pol_conf *conf)
goto fail;
}
- OBD_ALLOC_PTR(desc);
+ desc = kzalloc(sizeof(*desc), GFP_NOFS);
if (desc == NULL) {
rc = -ENOMEM;
goto fail;
@@ -1210,7 +1212,7 @@ again:
*/
LASSERT(rc2 == 0);
mutex_unlock(&ptlrpc_all_services_mutex);
- OBD_FREE_PTR(desc);
+ kfree(desc);
goto fail;
}
@@ -1233,7 +1235,7 @@ again:
*/
LASSERT(rc2 == 0);
mutex_unlock(&ptlrpc_all_services_mutex);
- OBD_FREE_PTR(desc);
+ kfree(desc);
goto fail;
}
}
@@ -1301,7 +1303,7 @@ int ptlrpc_nrs_policy_unregister(struct ptlrpc_nrs_pol_conf *conf)
conf->nc_name);
list_del(&desc->pd_list);
- OBD_FREE_PTR(desc);
+ kfree(desc);
fail:
mutex_unlock(&ptlrpc_all_services_mutex);
@@ -1747,7 +1749,7 @@ void ptlrpc_nrs_fini(void)
list_for_each_entry_safe(desc, tmp, &nrs_core.nrs_policies,
pd_list) {
list_del_init(&desc->pd_list);
- OBD_FREE_PTR(desc);
+ kfree(desc);
}
}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
index eb40c01db61276..6a61c85cfb11c1 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/nrs_fifo.c
@@ -80,7 +80,9 @@ static int nrs_fifo_start(struct ptlrpc_nrs_policy *policy)
{
struct nrs_fifo_head *head;
- OBD_CPT_ALLOC_PTR(head, nrs_pol2cptab(policy), nrs_pol2cptid(policy));
+ head = kzalloc_node(sizeof(*head), GFP_NOFS,
+ cfs_cpt_spread_node(nrs_pol2cptab(policy),
+ nrs_pol2cptid(policy)));
if (head == NULL)
return -ENOMEM;
@@ -105,7 +107,7 @@ static void nrs_fifo_stop(struct ptlrpc_nrs_policy *policy)
LASSERT(head != NULL);
LASSERT(list_empty(&head->fh_list));
- OBD_FREE_PTR(head);
+ kfree(head);
}
/**
diff --git a/drivers/staging/lustre/lustre/ptlrpc/pinger.c b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
index 9dbda9332dd828..9fc815676eb8ea 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/pinger.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/pinger.c
@@ -91,7 +91,7 @@ int ptlrpc_obd_ping(struct obd_device *obd)
}
EXPORT_SYMBOL(ptlrpc_obd_ping);
-int ptlrpc_ping(struct obd_import *imp)
+static int ptlrpc_ping(struct obd_import *imp)
{
struct ptlrpc_request *req;
@@ -110,7 +110,7 @@ int ptlrpc_ping(struct obd_import *imp)
return 0;
}
-void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
+static void ptlrpc_update_next_ping(struct obd_import *imp, int soon)
{
int time = soon ? PING_INTERVAL_SHORT : PING_INTERVAL;
if (imp->imp_state == LUSTRE_IMP_DISCON) {
@@ -141,7 +141,7 @@ static inline int ptlrpc_next_reconnect(struct obd_import *imp)
return cfs_time_shift(obd_timeout);
}
-long pinger_check_timeout(unsigned long time)
+static long pinger_check_timeout(unsigned long time)
{
struct timeout_item *item;
unsigned long timeout = PING_INTERVAL;
@@ -422,12 +422,12 @@ EXPORT_SYMBOL(ptlrpc_pinger_del_import);
* Register a timeout callback to the pinger list, and the callback will
* be called when timeout happens.
*/
-struct timeout_item *ptlrpc_new_timeout(int time, enum timeout_event event,
- timeout_cb_t cb, void *data)
+static struct timeout_item *ptlrpc_new_timeout(int time,
+ enum timeout_event event, timeout_cb_t cb, void *data)
{
struct timeout_item *ti;
- OBD_ALLOC_PTR(ti);
+ ti = kzalloc(sizeof(*ti), GFP_NOFS);
if (!ti)
return NULL;
@@ -514,7 +514,7 @@ int ptlrpc_del_timeout_client(struct list_head *obd_list,
LASSERTF(ti != NULL, "ti is NULL !\n");
if (list_empty(&ti->ti_obd_list)) {
list_del(&ti->ti_chain);
- OBD_FREE_PTR(ti);
+ kfree(ti);
}
mutex_unlock(&pinger_mutex);
return 0;
@@ -529,7 +529,7 @@ int ptlrpc_pinger_remove_timeouts(void)
list_for_each_entry_safe(item, tmp, &timeout_list, ti_chain) {
LASSERT(list_empty(&item->ti_obd_list));
list_del(&item->ti_chain);
- OBD_FREE_PTR(item);
+ kfree(item);
}
mutex_unlock(&pinger_mutex);
return 0;
@@ -548,7 +548,7 @@ void ptlrpc_pinger_wake_up(void)
static int pet_refcount;
static int pet_state;
static wait_queue_head_t pet_waitq;
-LIST_HEAD(pet_list);
+static LIST_HEAD(pet_list);
static DEFINE_SPINLOCK(pet_lock);
int ping_evictor_wake(struct obd_export *exp)
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
index a66dc3c6da419d..6dc3998dcd248c 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
@@ -76,19 +76,16 @@ void ptlrpc_initiate_recovery(struct obd_import *imp);
int lustre_unpack_req_ptlrpc_body(struct ptlrpc_request *req, int offset);
int lustre_unpack_rep_ptlrpc_body(struct ptlrpc_request *req, int offset);
-#if defined(CONFIG_PROC_FS)
-void ptlrpc_lprocfs_register_service(struct proc_dir_entry *proc_entry,
- struct ptlrpc_service *svc);
+int ptlrpc_sysfs_register_service(struct kset *parent,
+ struct ptlrpc_service *svc);
+void ptlrpc_sysfs_unregister_service(struct ptlrpc_service *svc);
+
+void ptlrpc_ldebugfs_register_service(struct dentry *debugfs_entry,
+ struct ptlrpc_service *svc);
void ptlrpc_lprocfs_unregister_service(struct ptlrpc_service *svc);
void ptlrpc_lprocfs_rpc_sent(struct ptlrpc_request *req, long amount);
void ptlrpc_lprocfs_do_request_stat(struct ptlrpc_request *req,
long q_usec, long work_usec);
-#else
-#define ptlrpc_lprocfs_register_service(params...) do {} while (0)
-#define ptlrpc_lprocfs_unregister_service(params...) do {} while (0)
-#define ptlrpc_lprocfs_rpc_sent(params...) do {} while (0)
-#define ptlrpc_lprocfs_do_request_stat(params...) do {} while (0)
-#endif /* CONFIG_PROC_FS */
/* NRS */
@@ -263,14 +260,8 @@ void sptlrpc_enc_pool_fini(void);
int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v);
/* sec_lproc.c */
-#if defined(CONFIG_PROC_FS)
int sptlrpc_lproc_init(void);
void sptlrpc_lproc_fini(void);
-#else
-static inline int sptlrpc_lproc_init(void)
-{ return 0; }
-static inline void sptlrpc_lproc_fini(void) {}
-#endif
/* sec_gc.c */
int sptlrpc_gc_init(void);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
index 0c178ec0e48796..5ba3e6ed5289dd 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpcd.c
@@ -528,8 +528,9 @@ static int ptlrpcd_bind(int index, int max)
}
if (rc == 0 && pc->pc_npartners > 0) {
- OBD_ALLOC(pc->pc_partners,
- sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners);
+ pc->pc_partners = kcalloc(pc->pc_npartners,
+ sizeof(struct ptlrpcd_ctl *),
+ GFP_NOFS);
if (pc->pc_partners == NULL) {
pc->pc_npartners = 0;
rc = -ENOMEM;
@@ -699,8 +700,7 @@ out:
if (pc->pc_npartners > 0) {
LASSERT(pc->pc_partners != NULL);
- OBD_FREE(pc->pc_partners,
- sizeof(struct ptlrpcd_ctl *) * pc->pc_npartners);
+ kfree(pc->pc_partners);
pc->pc_partners = NULL;
}
pc->pc_npartners = 0;
@@ -717,7 +717,7 @@ static void ptlrpcd_fini(void)
ptlrpcd_free(&ptlrpcds->pd_threads[i]);
ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0);
ptlrpcd_free(&ptlrpcds->pd_thread_rcv);
- OBD_FREE(ptlrpcds, ptlrpcds->pd_size);
+ kfree(ptlrpcds);
ptlrpcds = NULL;
}
}
@@ -738,7 +738,7 @@ static int ptlrpcd_init(void)
nthreads &= ~1; /* make sure it is even */
size = offsetof(struct ptlrpcd, pd_threads[nthreads]);
- OBD_ALLOC(ptlrpcds, size);
+ ptlrpcds = kzalloc(size, GFP_NOFS);
if (ptlrpcds == NULL) {
rc = -ENOMEM;
goto out;
@@ -781,7 +781,7 @@ out:
ptlrpcd_free(&ptlrpcds->pd_threads[j]);
ptlrpcd_stop(&ptlrpcds->pd_thread_rcv, 0);
ptlrpcd_free(&ptlrpcds->pd_thread_rcv);
- OBD_FREE(ptlrpcds, size);
+ kfree(ptlrpcds);
ptlrpcds = NULL;
}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 21e9dc9d5580b3..bcfd0b0b6f93c0 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -866,7 +866,7 @@ void sptlrpc_request_out_callback(struct ptlrpc_request *req)
if (req->rq_pool || !req->rq_reqbuf)
return;
- OBD_FREE(req->rq_reqbuf, req->rq_reqbuf_len);
+ kfree(req->rq_reqbuf);
req->rq_reqbuf = NULL;
req->rq_reqbuf_len = 0;
}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
index c05a8554d737dc..97edc9174da379 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_bulk.c
@@ -210,7 +210,7 @@ static void enc_pools_release_free_pages(long npages)
/* free unused pools */
while (p_idx_max1 < p_idx_max2) {
LASSERT(page_pools.epp_pools[p_idx_max2]);
- OBD_FREE(page_pools.epp_pools[p_idx_max2], PAGE_CACHE_SIZE);
+ kfree(page_pools.epp_pools[p_idx_max2]);
page_pools.epp_pools[p_idx_max2] = NULL;
p_idx_max2--;
}
@@ -294,7 +294,7 @@ static unsigned long enc_pools_cleanup(struct page ***pools, int npools)
cleaned++;
}
}
- OBD_FREE(pools[i], PAGE_CACHE_SIZE);
+ kfree(pools[i]);
pools[i] = NULL;
}
}
@@ -409,12 +409,12 @@ static int enc_pools_add_pages(int npages)
page_pools.epp_st_grows++;
npools = npages_to_npools(npages);
- OBD_ALLOC(pools, npools * sizeof(*pools));
+ pools = kcalloc(npools, sizeof(*pools), GFP_NOFS);
if (pools == NULL)
goto out;
for (i = 0; i < npools; i++) {
- OBD_ALLOC(pools[i], PAGE_CACHE_SIZE);
+ pools[i] = kzalloc(PAGE_CACHE_SIZE, GFP_NOFS);
if (pools[i] == NULL)
goto out_pools;
@@ -435,7 +435,7 @@ static int enc_pools_add_pages(int npages)
out_pools:
enc_pools_cleanup(pools, npools);
- OBD_FREE(pools, npools * sizeof(*pools));
+ kfree(pools);
out:
if (rc) {
page_pools.epp_st_grow_fails++;
@@ -508,8 +508,8 @@ int sptlrpc_enc_pool_get_pages(struct ptlrpc_bulk_desc *desc)
if (desc->bd_enc_iov != NULL)
return 0;
- OBD_ALLOC(desc->bd_enc_iov,
- desc->bd_iov_count * sizeof(*desc->bd_enc_iov));
+ desc->bd_enc_iov = kcalloc(desc->bd_iov_count,
+ sizeof(*desc->bd_enc_iov), GFP_NOFS);
if (desc->bd_enc_iov == NULL)
return -ENOMEM;
@@ -646,8 +646,7 @@ void sptlrpc_enc_pool_put_pages(struct ptlrpc_bulk_desc *desc)
spin_unlock(&page_pools.epp_lock);
- OBD_FREE(desc->bd_enc_iov,
- desc->bd_iov_count * sizeof(*desc->bd_enc_iov));
+ kfree(desc->bd_enc_iov);
desc->bd_enc_iov = NULL;
}
EXPORT_SYMBOL(sptlrpc_enc_pool_put_pages);
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
index 56ba9e4e5297ed..16dbf3fcfc8487 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_config.c
@@ -242,8 +242,7 @@ void sptlrpc_rule_set_free(struct sptlrpc_rule_set *rset)
(rset->srs_nrule == 0 && rset->srs_rules == NULL));
if (rset->srs_nslot) {
- OBD_FREE(rset->srs_rules,
- rset->srs_nslot * sizeof(*rset->srs_rules));
+ kfree(rset->srs_rules);
sptlrpc_rule_set_init(rset);
}
}
@@ -265,7 +264,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
nslot = rset->srs_nslot + 8;
/* better use realloc() if available */
- OBD_ALLOC(rules, nslot * sizeof(*rset->srs_rules));
+ rules = kcalloc(nslot, sizeof(*rset->srs_rules), GFP_NOFS);
if (rules == NULL)
return -ENOMEM;
@@ -274,8 +273,7 @@ int sptlrpc_rule_set_expand(struct sptlrpc_rule_set *rset)
memcpy(rules, rset->srs_rules,
rset->srs_nrule * sizeof(*rset->srs_rules));
- OBD_FREE(rset->srs_rules,
- rset->srs_nslot * sizeof(*rset->srs_rules));
+ kfree(rset->srs_rules);
}
rset->srs_rules = rules;
@@ -509,7 +507,7 @@ static void sptlrpc_conf_free_rsets(struct sptlrpc_conf *conf)
&conf->sc_tgts, sct_list) {
sptlrpc_rule_set_free(&conf_tgt->sct_rset);
list_del(&conf_tgt->sct_list);
- OBD_FREE_PTR(conf_tgt);
+ kfree(conf_tgt);
}
LASSERT(list_empty(&conf->sc_tgts));
@@ -523,7 +521,7 @@ static void sptlrpc_conf_free(struct sptlrpc_conf *conf)
sptlrpc_conf_free_rsets(conf);
list_del(&conf->sc_list);
- OBD_FREE_PTR(conf);
+ kfree(conf);
}
static
@@ -541,7 +539,7 @@ struct sptlrpc_conf_tgt *sptlrpc_conf_get_tgt(struct sptlrpc_conf *conf,
if (!create)
return NULL;
- OBD_ALLOC_PTR(conf_tgt);
+ conf_tgt = kzalloc(sizeof(*conf_tgt), GFP_NOFS);
if (conf_tgt) {
strlcpy(conf_tgt->sct_name, name, sizeof(conf_tgt->sct_name));
sptlrpc_rule_set_init(&conf_tgt->sct_rset);
@@ -565,7 +563,7 @@ struct sptlrpc_conf *sptlrpc_conf_get(const char *fsname,
if (!create)
return NULL;
- OBD_ALLOC_PTR(conf);
+ conf = kzalloc(sizeof(*conf), GFP_NOFS);
if (conf == NULL)
return NULL;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
index 0d08145a6c7e3c..982512febf05fc 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
@@ -51,10 +51,6 @@
#include "ptlrpc_internal.h"
-
-struct proc_dir_entry *sptlrpc_proc_root = NULL;
-EXPORT_SYMBOL(sptlrpc_proc_root);
-
static char *sec_flags2str(unsigned long flags, char *buf, int bufsize)
{
buf[0] = '\0';
@@ -148,16 +144,16 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
return -EINVAL;
}
- rc = lprocfs_obd_seq_create(dev, "srpc_info", 0444,
- &sptlrpc_info_lprocfs_fops, dev);
+ rc = ldebugfs_obd_seq_create(dev, "srpc_info", 0444,
+ &sptlrpc_info_lprocfs_fops, dev);
if (rc) {
CERROR("create proc entry srpc_info for %s: %d\n",
dev->obd_name, rc);
return rc;
}
- rc = lprocfs_obd_seq_create(dev, "srpc_contexts", 0444,
- &sptlrpc_ctxs_lprocfs_fops, dev);
+ rc = ldebugfs_obd_seq_create(dev, "srpc_contexts", 0444,
+ &sptlrpc_ctxs_lprocfs_fops, dev);
if (rc) {
CERROR("create proc entry srpc_contexts for %s: %d\n",
dev->obd_name, rc);
@@ -174,17 +170,20 @@ static struct lprocfs_vars sptlrpc_lprocfs_vars[] = {
{ NULL }
};
+static struct dentry *sptlrpc_debugfs_dir;
+
int sptlrpc_lproc_init(void)
{
- int rc;
+ int rc;
- LASSERT(sptlrpc_proc_root == NULL);
+ LASSERT(sptlrpc_debugfs_dir == NULL);
- sptlrpc_proc_root = lprocfs_register("sptlrpc", proc_lustre_root,
- sptlrpc_lprocfs_vars, NULL);
- if (IS_ERR(sptlrpc_proc_root)) {
- rc = PTR_ERR(sptlrpc_proc_root);
- sptlrpc_proc_root = NULL;
+ sptlrpc_debugfs_dir = ldebugfs_register("sptlrpc", debugfs_lustre_root,
+ sptlrpc_lprocfs_vars, NULL);
+ if (IS_ERR_OR_NULL(sptlrpc_debugfs_dir)) {
+ rc = sptlrpc_debugfs_dir ? PTR_ERR(sptlrpc_debugfs_dir)
+ : -ENOMEM;
+ sptlrpc_debugfs_dir = NULL;
return rc;
}
return 0;
@@ -192,8 +191,6 @@ int sptlrpc_lproc_init(void)
void sptlrpc_lproc_fini(void)
{
- if (sptlrpc_proc_root) {
- lprocfs_remove(&sptlrpc_proc_root);
- sptlrpc_proc_root = NULL;
- }
+ if (!IS_ERR_OR_NULL(sptlrpc_debugfs_dir))
+ ldebugfs_remove(&sptlrpc_debugfs_dir);
}
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
index a79cd53010a4cf..65f3ab42829c5d 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_plain.c
@@ -376,7 +376,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec)
{
struct ptlrpc_cli_ctx *ctx, *ctx_new;
- OBD_ALLOC_PTR(ctx_new);
+ ctx_new = kzalloc(sizeof(*ctx_new), GFP_NOFS);
write_lock(&plsec->pls_lock);
@@ -384,8 +384,7 @@ struct ptlrpc_cli_ctx *plain_sec_install_ctx(struct plain_sec *plsec)
if (ctx) {
atomic_inc(&ctx->cc_refcount);
- if (ctx_new)
- OBD_FREE_PTR(ctx_new);
+ kfree(ctx_new);
} else if (ctx_new) {
ctx = ctx_new;
@@ -424,7 +423,7 @@ void plain_destroy_sec(struct ptlrpc_sec *sec)
class_import_put(sec->ps_import);
- OBD_FREE_PTR(plsec);
+ kfree(plsec);
}
static
@@ -444,7 +443,7 @@ struct ptlrpc_sec *plain_create_sec(struct obd_import *imp,
LASSERT(SPTLRPC_FLVR_POLICY(sf->sf_rpc) == SPTLRPC_POLICY_PLAIN);
- OBD_ALLOC_PTR(plsec);
+ plsec = kzalloc(sizeof(*plsec), GFP_NOFS);
if (plsec == NULL)
return NULL;
@@ -508,7 +507,7 @@ void plain_release_ctx(struct ptlrpc_sec *sec,
LASSERT(atomic_read(&ctx->cc_refcount) == 0);
LASSERT(ctx->cc_sec == sec);
- OBD_FREE_PTR(ctx);
+ kfree(ctx);
atomic_dec(&sec->ps_nctx);
sptlrpc_sec_put(sec);
@@ -871,7 +870,7 @@ int plain_authorize(struct ptlrpc_request *req)
lustre_msg_buf(msg, PLAIN_PACK_MSG_OFF, 0),
lustre_msg_buflen(msg, PLAIN_PACK_MSG_OFF),
NULL, 0, (unsigned char *)&msg->lm_cksum, &hsize);
- req->rq_reply_off = 0;
+ req->rq_reply_off = 0;
}
return 0;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c b/drivers/staging/lustre/lustre/ptlrpc/service.c
index 344189ac5698a5..bd9ed378c6cfd4 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -75,7 +75,9 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt)
struct ptlrpc_service *svc = svcpt->scp_service;
struct ptlrpc_request_buffer_desc *rqbd;
- OBD_CPT_ALLOC_PTR(rqbd, svc->srv_cptable, svcpt->scp_cpt);
+ rqbd = kzalloc_node(sizeof(*rqbd), GFP_NOFS,
+ cfs_cpt_spread_node(svc->srv_cptable,
+ svcpt->scp_cpt));
if (rqbd == NULL)
return NULL;
@@ -87,7 +89,7 @@ ptlrpc_alloc_rqbd(struct ptlrpc_service_part *svcpt)
OBD_CPT_ALLOC_LARGE(rqbd->rqbd_buffer, svc->srv_cptable,
svcpt->scp_cpt, svc->srv_buf_size);
if (rqbd->rqbd_buffer == NULL) {
- OBD_FREE_PTR(rqbd);
+ kfree(rqbd);
return NULL;
}
@@ -113,7 +115,7 @@ ptlrpc_free_rqbd(struct ptlrpc_request_buffer_desc *rqbd)
spin_unlock(&svcpt->scp_lock);
OBD_FREE_LARGE(rqbd->rqbd_buffer, svcpt->scp_service->srv_buf_size);
- OBD_FREE_PTR(rqbd);
+ kfree(rqbd);
}
int
@@ -630,18 +632,20 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
array->paa_deadline = -1;
/* allocate memory for scp_at_array (ptlrpc_at_array) */
- OBD_CPT_ALLOC(array->paa_reqs_array,
- svc->srv_cptable, cpt, sizeof(struct list_head) * size);
+ array->paa_reqs_array =
+ kzalloc_node(sizeof(struct list_head) * size, GFP_NOFS,
+ cfs_cpt_spread_node(svc->srv_cptable, cpt));
if (array->paa_reqs_array == NULL)
return -ENOMEM;
for (index = 0; index < size; index++)
INIT_LIST_HEAD(&array->paa_reqs_array[index]);
- OBD_CPT_ALLOC(array->paa_reqs_count,
- svc->srv_cptable, cpt, sizeof(__u32) * size);
+ array->paa_reqs_count =
+ kzalloc_node(sizeof(__u32) * size, GFP_NOFS,
+ cfs_cpt_spread_node(svc->srv_cptable, cpt));
if (array->paa_reqs_count == NULL)
- goto failed;
+ goto free_reqs_array;
cfs_timer_init(&svcpt->scp_at_timer, ptlrpc_at_timer, svcpt);
/* At SOW, service time should be quick; 10s seems generous. If client
@@ -655,21 +659,16 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
/* We shouldn't be under memory pressure at startup, so
* fail if we can't allocate all our buffers at this time. */
if (rc != 0)
- goto failed;
+ goto free_reqs_count;
return 0;
- failed:
- if (array->paa_reqs_count != NULL) {
- OBD_FREE(array->paa_reqs_count, sizeof(__u32) * size);
- array->paa_reqs_count = NULL;
- }
-
- if (array->paa_reqs_array != NULL) {
- OBD_FREE(array->paa_reqs_array,
- sizeof(struct list_head) * array->paa_size);
- array->paa_reqs_array = NULL;
- }
+free_reqs_count:
+ kfree(array->paa_reqs_count);
+ array->paa_reqs_count = NULL;
+free_reqs_array:
+ kfree(array->paa_reqs_array);
+ array->paa_reqs_array = NULL;
return -ENOMEM;
}
@@ -681,7 +680,8 @@ ptlrpc_service_part_init(struct ptlrpc_service *svc,
*/
struct ptlrpc_service *
ptlrpc_register_service(struct ptlrpc_service_conf *conf,
- struct proc_dir_entry *proc_entry)
+ struct kset *parent,
+ struct dentry *debugfs_entry)
{
struct ptlrpc_service_cpt_conf *cconf = &conf->psc_cpt;
struct ptlrpc_service *service;
@@ -723,18 +723,17 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
if (rc <= 0) {
CERROR("%s: failed to parse CPT array %s: %d\n",
conf->psc_name, cconf->cc_pattern, rc);
- if (cpts != NULL)
- OBD_FREE(cpts, sizeof(*cpts) * ncpts);
+ kfree(cpts);
return ERR_PTR(rc < 0 ? rc : -EINVAL);
}
ncpts = rc;
}
}
- OBD_ALLOC(service, offsetof(struct ptlrpc_service, srv_parts[ncpts]));
+ service = kzalloc(offsetof(struct ptlrpc_service, srv_parts[ncpts]),
+ GFP_NOFS);
if (service == NULL) {
- if (cpts != NULL)
- OBD_FREE(cpts, sizeof(*cpts) * ncpts);
+ kfree(cpts);
return ERR_PTR(-ENOMEM);
}
@@ -778,7 +777,8 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
else
cpt = cpts != NULL ? cpts[i] : i;
- OBD_CPT_ALLOC(svcpt, cptable, cpt, sizeof(*svcpt));
+ svcpt = kzalloc_node(sizeof(*svcpt), GFP_NOFS,
+ cfs_cpt_spread_node(cptable, cpt));
if (svcpt == NULL) {
rc = -ENOMEM;
goto failed;
@@ -799,8 +799,14 @@ ptlrpc_register_service(struct ptlrpc_service_conf *conf,
list_add(&service->srv_list, &ptlrpc_all_services);
mutex_unlock(&ptlrpc_all_services_mutex);
- if (proc_entry != NULL)
- ptlrpc_lprocfs_register_service(proc_entry, service);
+ if (parent) {
+ rc = ptlrpc_sysfs_register_service(parent, service);
+ if (rc)
+ goto failed;
+ }
+
+ if (!IS_ERR_OR_NULL(debugfs_entry))
+ ptlrpc_ldebugfs_register_service(debugfs_entry, service);
rc = ptlrpc_service_nrs_setup(service);
if (rc != 0)
@@ -2291,7 +2297,7 @@ static int ptlrpc_main(void *arg)
goto out;
}
- OBD_ALLOC_PTR(env);
+ env = kzalloc(sizeof(*env), GFP_NOFS);
if (env == NULL) {
rc = -ENOMEM;
goto out_srv_fini;
@@ -2414,7 +2420,7 @@ out_srv_fini:
if (env != NULL) {
lu_context_fini(&env->le_ctx);
- OBD_FREE_PTR(env);
+ kfree(env);
}
out:
CDEBUG(D_RPCTRACE, "service thread [ %p : %u ] %d exiting: rc %d\n",
@@ -2596,7 +2602,7 @@ static void ptlrpc_svcpt_stop_threads(struct ptlrpc_service_part *svcpt)
thread = list_entry(zombie.next,
struct ptlrpc_thread, t_link);
list_del(&thread->t_link);
- OBD_FREE_PTR(thread);
+ kfree(thread);
}
}
@@ -2670,7 +2676,9 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
svcpt->scp_nthrs_running == svc->srv_nthrs_cpt_init - 1))
return -EMFILE;
- OBD_CPT_ALLOC_PTR(thread, svc->srv_cptable, svcpt->scp_cpt);
+ thread = kzalloc_node(sizeof(*thread), GFP_NOFS,
+ cfs_cpt_spread_node(svc->srv_cptable,
+ svcpt->scp_cpt));
if (thread == NULL)
return -ENOMEM;
init_waitqueue_head(&thread->t_ctl_waitq);
@@ -2678,7 +2686,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
spin_lock(&svcpt->scp_lock);
if (!ptlrpc_threads_increasable(svcpt)) {
spin_unlock(&svcpt->scp_lock);
- OBD_FREE_PTR(thread);
+ kfree(thread);
return -EMFILE;
}
@@ -2687,7 +2695,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
* might require unique and contiguous t_id */
LASSERT(svcpt->scp_nthrs_starting == 1);
spin_unlock(&svcpt->scp_lock);
- OBD_FREE_PTR(thread);
+ kfree(thread);
if (wait) {
CDEBUG(D_INFO, "Waiting for creating thread %s #%d\n",
svc->srv_thread_name, svcpt->scp_thr_nextid);
@@ -2733,7 +2741,7 @@ int ptlrpc_start_thread(struct ptlrpc_service_part *svcpt, int wait)
} else {
list_del(&thread->t_link);
spin_unlock(&svcpt->scp_lock);
- OBD_FREE_PTR(thread);
+ kfree(thread);
}
return rc;
}
@@ -2780,8 +2788,10 @@ int ptlrpc_hr_init(void)
hrp->hrp_nthrs /= weight;
LASSERT(hrp->hrp_nthrs > 0);
- OBD_CPT_ALLOC(hrp->hrp_thrs, ptlrpc_hr.hr_cpt_table, i,
- hrp->hrp_nthrs * sizeof(*hrt));
+ hrp->hrp_thrs =
+ kzalloc_node(hrp->hrp_nthrs * sizeof(*hrt), GFP_NOFS,
+ cfs_cpt_spread_node(ptlrpc_hr.hr_cpt_table,
+ i));
if (hrp->hrp_thrs == NULL) {
rc = -ENOMEM;
goto out;
@@ -2817,8 +2827,7 @@ void ptlrpc_hr_fini(void)
cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
if (hrp->hrp_thrs != NULL) {
- OBD_FREE(hrp->hrp_thrs,
- hrp->hrp_nthrs * sizeof(hrp->hrp_thrs[0]));
+ kfree(hrp->hrp_thrs);
}
}
@@ -2998,27 +3007,19 @@ ptlrpc_service_free(struct ptlrpc_service *svc)
cfs_timer_disarm(&svcpt->scp_at_timer);
array = &svcpt->scp_at_array;
- if (array->paa_reqs_array != NULL) {
- OBD_FREE(array->paa_reqs_array,
- sizeof(struct list_head) * array->paa_size);
- array->paa_reqs_array = NULL;
- }
-
- if (array->paa_reqs_count != NULL) {
- OBD_FREE(array->paa_reqs_count,
- sizeof(__u32) * array->paa_size);
- array->paa_reqs_count = NULL;
- }
+ kfree(array->paa_reqs_array);
+ array->paa_reqs_array = NULL;
+ kfree(array->paa_reqs_count);
+ array->paa_reqs_count = NULL;
}
ptlrpc_service_for_each_part(svcpt, i, svc)
- OBD_FREE_PTR(svcpt);
+ kfree(svcpt);
if (svc->srv_cpts != NULL)
cfs_expr_list_values_free(svc->srv_cpts, svc->srv_ncpts);
- OBD_FREE(svc, offsetof(struct ptlrpc_service,
- srv_parts[svc->srv_ncpts]));
+ kfree(svc);
}
int ptlrpc_unregister_service(struct ptlrpc_service *service)
@@ -3039,6 +3040,7 @@ int ptlrpc_unregister_service(struct ptlrpc_service *service)
ptlrpc_service_nrs_cleanup(service);
ptlrpc_lprocfs_unregister_service(service);
+ ptlrpc_sysfs_unregister_service(service);
ptlrpc_service_free(service);
diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre
new file mode 100644
index 00000000000000..1e302e8516ce55
--- /dev/null
+++ b/drivers/staging/lustre/sysfs-fs-lustre
@@ -0,0 +1,543 @@
+What: /sys/fs/lustre/version
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows current running lustre version.
+
+What: /sys/fs/lustre/pinger
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows if the lustre module has pinger support.
+ "on" means yes and "off" means no.
+
+What: /sys/fs/lustre/health
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows whenever current system state believed to be "healthy",
+ "NOT HEALTHY", or "LBUG" whenever lustre has experienced
+ an internal assertion failure
+
+What: /sys/fs/lustre/jobid_name
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Currently running job "name" for this node to be transferred
+ to Lustre servers for purposes of QoS and statistics gathering.
+ Writing into this file will change the name, reading outputs
+ currently set value.
+
+What: /sys/fs/lustre/jobid_var
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Control file for lustre "jobstats" functionality, write new
+ value from the list below to change the mode:
+ disable - disable job name reporting to the servers (default)
+ procname_uid - form the job name as the current running
+ command name and pid with a dot in between
+ e.g. dd.1253
+ nodelocal - use jobid_name value from above.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Biggest blocksize on object storage server for this filesystem.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/kbytestotal
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows total number of kilobytes of space on this filesystem
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/kbytesfree
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows total number of free kilobytes of space on this filesystem
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/kbytesavail
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows total number of free kilobytes of space on this filesystem
+ actually available for use (taking into account per-client
+ grants and filesystem reservations).
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/filestotal
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows total number of inodes on the filesystem.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/filesfree
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows estimated number of free inodes on the filesystem
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/client_type
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows whenever this filesystem considers this client to be
+ compute cluster-local or remote. Remote clients have
+ additional uid/gid convrting logic applied.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/fstype
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows filesystem type of the filesystem
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/uuid
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows this filesystem superblock uuid
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/max_read_ahead_mb
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Sets maximum number of megabytes in system memory to be
+ given to read-ahead cache.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/max_read_ahead_per_file_mb
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Sets maximum number of megabytes to read-ahead for a single file
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/max_read_ahead_whole_mb
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ For small reads, how many megabytes to actually request from
+ the server as initial read-ahead.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/checksum_pages
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Enables or disables per-page checksum at llite layer, before
+ the pages are actually given to lower level for network transfer
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/stats_track_pid
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Limit Lustre vfs operations gathering to just a single pid.
+ 0 to track everything.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/stats_track_ppid
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Limit Lustre vfs operations gathering to just a single ppid.
+ 0 to track everything.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/stats_track_gid
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Limit Lustre vfs operations gathering to just a single gid.
+ 0 to track everything.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/statahead_max
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls maximum number of statahead requests to send when
+ sequential readdir+stat pattern is detected.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/statahead_agl
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls if AGL (async glimpse ahead - obtain object information
+ from OSTs in parallel with MDS during statahead) should be
+ enabled or disabled.
+ 0 to disable, 1 to enable.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/lazystatfs
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls statfs(2) behaviour in the face of down servers.
+ If 0, always wait for all servers to come online,
+ if 1, ignote inactive servers.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/max_easize
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows maximum number of bytes file striping data could be
+ in current configuration of storage.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/default_easize
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows maximum observed file striping data seen by this
+ filesystem client instance.
+
+What: /sys/fs/lustre/llite/<fsname>-<uuid>/xattr_cache
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls extended attributes client-side cache.
+ 1 to enable, 0 to disable.
+
+What: /sys/fs/lustre/ldlm/cancel_unused_locks_before_replay
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls if client should replay unused locks during recovery
+ If a client tends to have a lot of unused locks in LRU,
+ recovery times might become prolonged.
+ 1 - just locally cancel unused locks (default)
+ 0 - replay unused locks.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/resource_count
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Displays number of lock resources (objects on which individual
+ locks are taken) currently allocated in this namespace.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/lock_count
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Displays number or locks allocated in this namespace.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/lru_size
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls and displays LRU size limit for unused locks for this
+ namespace.
+ 0 - LRU size is unlimited, controlled by server resources
+ positive number - number of locks to allow in lock LRU list
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/lock_unused_count
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Display number of locks currently sitting in the LRU list
+ of this namespace
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/lru_max_age
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Maximum number of milliseconds a lock could sit in LRU list
+ before client would voluntarily cancel it as unused.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/early_lock_cancel
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls "early lock cancellation" feature on this namespace
+ if supported by the server.
+ When enabled, tries to preemtively cancel locks that would be
+ cancelled by verious operations and bundle the cancellation
+ requests in the same RPC as the main operation, which results
+ in significant speedups due to reduced lock-pingpong RPCs.
+ 0 - disabled
+ 1 - enabled (default)
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/granted
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Displays number of granted locks in this namespace
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/grant_rate
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of granted locks in this namespace during last
+ time interval
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/cancel_rate
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of lock cancellations in this namespace during
+ last time interval
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/grant_speed
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Calculated speed of lock granting (grant_rate - cancel_rate)
+ in this namespace
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/grant_plan
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Estimated number of locks to be granted in the next time
+ interval in this namespace
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/limit
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls number of allowed locks in this pool.
+ When lru_size is 0, this is the actual limit then.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/lock_volume_factor
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Multiplier for all lock volume calculations above.
+ Default is 1. Increase to make the client to more agressively
+ clean it's lock LRU list for this namespace.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/server_lock_volume
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Calculated server lock volume.
+
+What: /sys/fs/lustre/ldlm/namespaces/<name>/pool/recalc_period
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls length of time between recalculation of above
+ values (in seconds).
+
+What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_min
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls minimum number of ldlm callback threads to start.
+
+What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_max
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls maximum number of ldlm callback threads to start.
+
+What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_started
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows actual number of ldlm callback threads running.
+
+What: /sys/fs/lustre/ldlm/services/ldlm_cbd/high_priority_ratio
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls what percentage of ldlm callback threads is dedicated
+ to "high priority" incoming requests.
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/blocksize
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Blocksize on backend filesystem for service behind this obd
+ device (or biggest blocksize for compound devices like lov
+ and lmv)
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytestotal
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Total number of kilobytes of space on backend filesystem
+ for service behind this obd (or total amount for compound
+ devices like lov lmv)
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytesfree
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of free kilobytes on backend filesystem for service
+ behind this obd (or total amount for compound devices
+ like lov lmv)
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/kbytesavail
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of kilobytes of free space on backend filesystem
+ for service behind this obd (or total amount for compound
+ devices like lov lmv) that is actually available for use
+ (taking into account per-client and filesystem reservations).
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/filestotal
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of inodes on backend filesystem for service behind this
+ obd.
+
+What: /sys/fs/lustre/{obdtype}/{connection_name}/filesfree
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of free inodes on backend filesystem for service
+ behind this obd.
+
+What: /sys/fs/lustre/mdc/{connection_name}/max_pages_per_rpc
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Maximum number of readdir pages to fit into a single readdir
+ RPC.
+
+What: /sys/fs/lustre/{mdc,osc}/{connection_name}/max_rpcs_in_flight
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Maximum number of parallel RPCs on the wire to allow on
+ this connection. Increasing this number would help on higher
+ latency links, but has a chance of overloading a server
+ if you have too many clients like this.
+ Default: 8
+
+What: /sys/fs/lustre/osc/{connection_name}/max_pages_per_rpc
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Maximum number of pages to fit into a single RPC.
+ Typically bigger RPCs allow for better performance.
+ Default: however many pages to form 1M of data (256 pages
+ for 4K page sized platforms)
+
+What: /sys/fs/lustre/osc/{connection_name}/active
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls accessibility of this connection. If set to 0,
+ fail all accesses immediately.
+
+What: /sys/fs/lustre/osc/{connection_name}/checksums
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls whenever to checksum bulk RPC data over the wire
+ to this target.
+ 1: enable (default) ; 0: disable
+
+What: /sys/fs/lustre/osc/{connection_name}/contention_seconds
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls for how long to consider a file contended once
+ indicated as such by the server.
+ When a file is considered contended, all operations switch to
+ synchronous lockless mode to avoid cache and lock pingpong.
+
+What: /sys/fs/lustre/osc/{connection_name}/cur_dirty_bytes
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Displays how many dirty bytes is presently in the cache for this
+ target.
+
+What: /sys/fs/lustre/osc/{connection_name}/cur_grant_bytes
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows how many bytes we have as a "dirty cache" grant from the
+ server. Writing a value smaller than shown allows to release
+ some grant back to the server.
+ Dirty cache grant is a way Lustre ensures that cached successful
+ writes on client do not end up discarded by the server due to
+ lack of space later on.
+
+What: /sys/fs/lustre/osc/{connection_name}/cur_lost_grant_bytes
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Shows how many granted bytes were released to the server due
+ to lack of write activity on this client.
+
+What: /sys/fs/lustre/osc/{connection_name}/grant_shrink_interval
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of seconds with no write activity for this target
+ to start releasing dirty grant back to the server.
+
+What: /sys/fs/lustre/osc/{connection_name}/destroys_in_flight
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of DESTROY RPCs currently in flight to this target.
+
+What: /sys/fs/lustre/osc/{connection_name}/lockless_truncate
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls whether lockless truncate RPCs are allowed to this
+ target.
+ Lockless truncate causes server to perform the locking which
+ is beneficial if the truncate is not followed by a write
+ immediately.
+ 1: enable ; 0: disable (default)
+
+What: /sys/fs/lustre/osc/{connection_name}/max_dirty_mb
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls how much dirty data this client can accumulate
+ for this target. This is orthogonal to dirty grant and is
+ a hard limit even if the server would allow a bigger dirty
+ cache.
+ While allowing higher dirty cache is beneficial for write
+ performance, flushing write cache takes longer and as such
+ the node might be more prone to OOMs.
+ Having this value set too low might result in not being able
+ to sent too many parallel WRITE RPCs.
+ Default: 32
+
+What: /sys/fs/lustre/osc/{connection_name}/resend_count
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Controls how many times to try and resend RPCs to this target
+ that failed with "recoverable" status, such as EAGAIN,
+ ENOMEM.
+
+What: /sys/fs/lustre/lov/{connection_name}/numobd
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of OSC targets managed by this LOV instance.
+
+What: /sys/fs/lustre/lov/{connection_name}/activeobd
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of OSC targets managed by this LOV instance that are
+ actually active.
+
+What: /sys/fs/lustre/lmv/{connection_name}/numobd
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of MDC targets managed by this LMV instance.
+
+What: /sys/fs/lustre/lmv/{connection_name}/activeobd
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Number of MDC targets managed by this LMV instance that are
+ actually active.
+
+What: /sys/fs/lustre/lmv/{connection_name}/placement
+Date: May 2015
+Contact: "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+ Determines policy of inode placement in case of multiple
+ metadata servers:
+ CHAR - based on a hash of the file name used at creation time
+ (Default)
+ NID - based on a hash of creating client network id.
diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 5e11a78ceef3c5..8bc68e2b4052be 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -217,7 +217,7 @@
#define BCM2048_FREQ_ERROR_FLOOR -20
#define BCM2048_FREQ_ERROR_ROOF 20
-/* -60 dB is reported as full signal strenght */
+/* -60 dB is reported as full signal strength */
#define BCM2048_RSSI_LEVEL_BASE -60
#define BCM2048_RSSI_LEVEL_ROOF -100
#define BCM2048_RSSI_LEVEL_ROOF_NEG 100
@@ -2468,7 +2468,7 @@ static int bcm2048_vidioc_g_tuner(struct file *file, void *priv,
} else {
/*
* RSSI level -60 dB is defined to report full
- * signal strenght
+ * signal strength
*/
rssi = bcm2048_get_fm_rssi(bdev);
if (rssi >= BCM2048_RSSI_LEVEL_BASE) {
diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c
index 1bdc8d001e65da..164634d61ac588 100644
--- a/drivers/staging/nvec/nvec.c
+++ b/drivers/staging/nvec/nvec.c
@@ -916,7 +916,7 @@ static int tegra_nvec_remove(struct platform_device *pdev)
nvec_unregister_notifier(nvec, &nvec->nvec_status_notifier);
cancel_work_sync(&nvec->rx_work);
cancel_work_sync(&nvec->tx_work);
- /* FIXME: needs check wether nvec is responsible for power off */
+ /* FIXME: needs check whether nvec is responsible for power off */
pm_power_off = NULL;
return 0;
diff --git a/drivers/staging/octeon-usb/octeon-hcd.c b/drivers/staging/octeon-usb/octeon-hcd.c
index 9e5476e352b4b3..9bd73ea5a1fa62 100644
--- a/drivers/staging/octeon-usb/octeon-hcd.c
+++ b/drivers/staging/octeon-usb/octeon-hcd.c
@@ -499,15 +499,21 @@ static int octeon_alloc_temp_buffer(struct urb *urb, gfp_t mem_flags)
static void octeon_free_temp_buffer(struct urb *urb)
{
struct octeon_temp_buffer *temp;
+ size_t length;
if (!(urb->transfer_flags & URB_ALIGNED_TEMP_BUFFER))
return;
temp = container_of(urb->transfer_buffer, struct octeon_temp_buffer,
data);
- if (usb_urb_dir_in(urb))
- memcpy(temp->orig_buffer, urb->transfer_buffer,
- urb->actual_length);
+ if (usb_urb_dir_in(urb)) {
+ if (usb_pipeisoc(urb->pipe))
+ length = urb->transfer_buffer_length;
+ else
+ length = urb->actual_length;
+
+ memcpy(temp->orig_buffer, urb->transfer_buffer, length);
+ }
urb->transfer_buffer = temp->orig_buffer;
urb->transfer_flags &= ~URB_ALIGNED_TEMP_BUFFER;
kfree(temp);
@@ -1233,7 +1239,7 @@ static int cvmx_usb_fill_tx_hw(struct cvmx_usb_state *usb,
usb->index) ^ 4;
int words = available;
- /* Limit the amount of data to waht the SW fifo has */
+ /* Limit the amount of data to what the SW fifo has */
if (fifo->entry[i].size <= available) {
words = fifo->entry[i].size;
fifo->tail++;
@@ -1843,7 +1849,7 @@ static void cvmx_usb_start_channel(struct cvmx_usb_state *usb, int channel,
transaction->xfersize = usbc_hctsiz.s.xfersize;
transaction->pktcnt = usbc_hctsiz.s.pktcnt;
}
- /* Remeber when we start a split transaction */
+ /* Remember when we start a split transaction */
if (cvmx_usb_pipe_needs_split(usb, pipe))
usb->active_split = transaction;
USB_SET_FIELD32(CVMX_USBCX_HCCHARX(channel, usb->index),
diff --git a/drivers/staging/octeon-usb/octeon-hcd.h b/drivers/staging/octeon-usb/octeon-hcd.h
index 3e351ab7465ace..70e7fa5e37d944 100644
--- a/drivers/staging/octeon-usb/octeon-hcd.h
+++ b/drivers/staging/octeon-usb/octeon-hcd.h
@@ -1693,7 +1693,7 @@ union cvmx_usbnx_usbp_ctl_status {
* struct cvmx_usbnx_usbp_ctl_status_s
* @txrisetune: HS Transmitter Rise/Fall Time Adjustment
* @txvreftune: HS DC Voltage Level Adjustment
- * @txfslstune: FS/LS Source Impedence Adjustment
+ * @txfslstune: FS/LS Source Impedance Adjustment
* @txhsxvtune: Transmitter High-Speed Crossover Adjustment
* @sqrxtune: Squelch Threshold Adjustment
* @compdistune: Disconnect Threshold Adjustment
diff --git a/drivers/staging/octeon/ethernet-defines.h b/drivers/staging/octeon/ethernet-defines.h
index 2a98a2153e1646..f92e0c478e1686 100644
--- a/drivers/staging/octeon/ethernet-defines.h
+++ b/drivers/staging/octeon/ethernet-defines.h
@@ -1,46 +1,15 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
/*
* A few defines are used to control the operation of this driver:
- * CONFIG_CAVIUM_RESERVE32
- * This kernel config options controls the amount of memory configured
- * in a wired TLB entry for all processes to share. If this is set, the
- * driver will use this memory instead of kernel memory for pools. This
- * allows 32bit userspace application to access the buffers, but also
- * requires all received packets to be copied.
- * USE_SKBUFFS_IN_HW
- * Tells the driver to populate the packet buffers with kernel skbuffs.
- * This allows the driver to receive packets without copying them. It also
- * means that 32bit userspace can't access the packet buffers.
- * USE_HW_TCPUDP_CHECKSUM
- * Controls if the Octeon TCP/UDP checksum engine is used for packet
- * output. If this is zero, the kernel will perform the checksum in
- * software.
* USE_ASYNC_IOBDMA
* Use asynchronous IO access to hardware. This uses Octeon's asynchronous
* IOBDMAs to issue IO accesses without stalling. Set this to zero
@@ -57,39 +26,14 @@
#include <asm/octeon/cvmx-config.h>
-
-#define OCTEON_ETHERNET_VERSION "1.9"
-
-#ifndef CONFIG_CAVIUM_RESERVE32
-#define CONFIG_CAVIUM_RESERVE32 0
-#endif
-
-#define USE_SKBUFFS_IN_HW 1
#ifdef CONFIG_NETFILTER
#define REUSE_SKBUFFS_WITHOUT_FREE 0
#else
#define REUSE_SKBUFFS_WITHOUT_FREE 1
#endif
-#define USE_HW_TCPUDP_CHECKSUM 1
-
-/* Enable Random Early Dropping under load */
-#define USE_RED 1
#define USE_ASYNC_IOBDMA (CONFIG_CAVIUM_OCTEON_CVMSEG_SIZE > 0)
-/*
- * Allow SW based preamble removal at 10Mbps to workaround PHYs giving
- * us bad preambles.
- */
-#define USE_10MBPS_PREAMBLE_WORKAROUND 1
-/*
- * Use this to have all FPA frees also tell the L2 not to write data
- * to memory.
- */
-#define DONT_WRITEBACK(x) (x)
-/* Use this to not have FPA frees control L2 */
-/*#define DONT_WRITEBACK(x) 0 */
-
/* Maximum number of SKBs to try to free per xmit packet. */
#define MAX_OUT_QUEUE_DEPTH 1000
diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c
index 40dab11e533382..fd9b3d899c1ffc 100644
--- a/drivers/staging/octeon/ethernet-mdio.c
+++ b/drivers/staging/octeon/ethernet-mdio.c
@@ -1,35 +1,19 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
+
#include <linux/kernel.h>
#include <linux/ethtool.h>
#include <linux/phy.h>
#include <linux/ratelimit.h>
#include <linux/of_mdio.h>
-
+#include <generated/utsrelease.h>
#include <net/dst.h>
#include <asm/octeon/octeon.h>
@@ -39,15 +23,14 @@
#include "ethernet-mdio.h"
#include "ethernet-util.h"
-#include <asm/octeon/cvmx-helper-board.h>
-
+#include <asm/octeon/cvmx-gmxx-defs.h>
#include <asm/octeon/cvmx-smix-defs.h>
static void cvm_oct_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
- strlcpy(info->driver, "cavium-ethernet", sizeof(info->driver));
- strlcpy(info->version, OCTEON_ETHERNET_VERSION, sizeof(info->version));
+ strlcpy(info->driver, KBUILD_MODNAME, sizeof(info->driver));
+ strlcpy(info->version, UTS_RELEASE, sizeof(info->version));
strlcpy(info->bus_info, "Builtin", sizeof(info->bus_info));
}
@@ -116,14 +99,14 @@ int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return phy_mii_ioctl(priv->phydev, rq, cmd);
}
-static void cvm_oct_note_carrier(struct octeon_ethernet *priv,
- cvmx_helper_link_info_t li)
+void cvm_oct_note_carrier(struct octeon_ethernet *priv,
+ cvmx_helper_link_info_t li)
{
if (li.s.link_up) {
- pr_notice_ratelimited("%s: %u Mbps %s duplex, port %d\n",
+ pr_notice_ratelimited("%s: %u Mbps %s duplex, port %d, queue %d\n",
netdev_name(priv->netdev), li.s.speed,
(li.s.full_duplex) ? "Full" : "Half",
- priv->port);
+ priv->port, priv->queue);
} else {
pr_notice_ratelimited("%s: Link down\n",
netdev_name(priv->netdev));
@@ -150,7 +133,14 @@ void cvm_oct_adjust_link(struct net_device *dev)
int cvm_oct_common_stop(struct net_device *dev)
{
struct octeon_ethernet *priv = netdev_priv(dev);
+ int interface = INTERFACE(priv->port);
cvmx_helper_link_info_t link_info;
+ union cvmx_gmxx_prtx_cfg gmx_cfg;
+ int index = INDEX(priv->port);
+
+ gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
+ gmx_cfg.s.en = 0;
+ cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
priv->poll = NULL;
diff --git a/drivers/staging/octeon/ethernet-mdio.h b/drivers/staging/octeon/ethernet-mdio.h
index 6191b085064606..a530b55f27d89d 100644
--- a/drivers/staging/octeon/ethernet-mdio.h
+++ b/drivers/staging/octeon/ethernet-mdio.h
@@ -1,29 +1,13 @@
-/*********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-*********************************************************************/
+ */
+
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
diff --git a/drivers/staging/octeon/ethernet-mem.c b/drivers/staging/octeon/ethernet-mem.c
index 964da860f4c45f..5a5cdb3cd740b2 100644
--- a/drivers/staging/octeon/ethernet-mem.c
+++ b/drivers/staging/octeon/ethernet-mem.c
@@ -1,29 +1,13 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2010 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
+
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/slab.h>
@@ -54,7 +38,7 @@ static int cvm_oct_fill_hw_skbuff(int pool, int size, int elements)
break;
skb_reserve(skb, 256 - (((unsigned long)skb->data) & 0x7f));
*(struct sk_buff **)(skb->data - sizeof(void *)) = skb;
- cvmx_fpa_free(skb->data, pool, DONT_WRITEBACK(size / 128));
+ cvmx_fpa_free(skb->data, pool, size / 128);
freed--;
}
return elements - freed;
@@ -160,7 +144,7 @@ int cvm_oct_mem_fill_fpa(int pool, int size, int elements)
{
int freed;
- if (USE_SKBUFFS_IN_HW && pool == CVMX_FPA_PACKET_POOL)
+ if (pool == CVMX_FPA_PACKET_POOL)
freed = cvm_oct_fill_hw_skbuff(pool, size, elements);
else
freed = cvm_oct_fill_hw_memory(pool, size, elements);
@@ -169,7 +153,7 @@ int cvm_oct_mem_fill_fpa(int pool, int size, int elements)
void cvm_oct_mem_empty_fpa(int pool, int size, int elements)
{
- if (USE_SKBUFFS_IN_HW && pool == CVMX_FPA_PACKET_POOL)
+ if (pool == CVMX_FPA_PACKET_POOL)
cvm_oct_free_hw_skbuff(pool, size, elements);
else
cvm_oct_free_hw_memory(pool, size, elements);
diff --git a/drivers/staging/octeon/ethernet-mem.h b/drivers/staging/octeon/ethernet-mem.h
index 713f2edc8b4fd4..62d07c426f89fd 100644
--- a/drivers/staging/octeon/ethernet-mem.h
+++ b/drivers/staging/octeon/ethernet-mem.h
@@ -1,29 +1,12 @@
-/*********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-********************************************************************/
+ */
int cvm_oct_mem_fill_fpa(int pool, int size, int elements);
void cvm_oct_mem_empty_fpa(int pool, int size, int elements);
diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c
index e36f9bc695430b..beb7aac9c28907 100644
--- a/drivers/staging/octeon/ethernet-rgmii.c
+++ b/drivers/staging/octeon/ethernet-rgmii.c
@@ -1,29 +1,13 @@
-/*********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
+
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/interrupt.h>
@@ -48,6 +32,37 @@ static DEFINE_SPINLOCK(global_register_lock);
static int number_rgmii_ports;
+static void cvm_oct_set_hw_preamble(struct octeon_ethernet *priv, bool enable)
+{
+ union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl;
+ union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs;
+ union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg;
+ int interface = INTERFACE(priv->port);
+ int index = INDEX(priv->port);
+
+ /* Set preamble checking. */
+ gmxx_rxx_frm_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index,
+ interface));
+ gmxx_rxx_frm_ctl.s.pre_chk = enable;
+ cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface),
+ gmxx_rxx_frm_ctl.u64);
+
+ /* Set FCS stripping. */
+ ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS);
+ if (enable)
+ ipd_sub_port_fcs.s.port_bit |= 1ull << priv->port;
+ else
+ ipd_sub_port_fcs.s.port_bit &=
+ 0xffffffffull ^ (1ull << priv->port);
+ cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64);
+
+ /* Clear any error bits. */
+ gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index,
+ interface));
+ cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface),
+ gmxx_rxx_int_reg.u64);
+}
+
static void cvm_oct_rgmii_poll(struct net_device *dev)
{
struct octeon_ethernet *priv = netdev_priv(dev);
@@ -68,14 +83,7 @@ static void cvm_oct_rgmii_poll(struct net_device *dev)
link_info = cvmx_helper_link_get(priv->port);
if (link_info.u64 == priv->link_info) {
-
- /*
- * If the 10Mbps preamble workaround is supported and we're
- * at 10Mbps we may need to do some special checking.
- */
- if (USE_10MBPS_PREAMBLE_WORKAROUND &&
- (link_info.s.speed == 10)) {
-
+ if (link_info.s.speed == 10) {
/*
* Read the GMXX_RXX_INT_REG[PCTERR] bit and
* see if we are getting preamble errors.
@@ -88,7 +96,6 @@ static void cvm_oct_rgmii_poll(struct net_device *dev)
cvmx_read_csr(CVMX_GMXX_RXX_INT_REG
(index, interface));
if (gmxx_rxx_int_reg.s.pcterr) {
-
/*
* We are getting preamble errors at
* 10Mbps. Most likely the PHY is
@@ -97,30 +104,7 @@ static void cvm_oct_rgmii_poll(struct net_device *dev)
* packets we need to disable preamble
* checking and do it in software.
*/
- union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl;
- union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs;
-
- /* Disable preamble checking */
- gmxx_rxx_frm_ctl.u64 =
- cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL
- (index, interface));
- gmxx_rxx_frm_ctl.s.pre_chk = 0;
- cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL
- (index, interface),
- gmxx_rxx_frm_ctl.u64);
-
- /* Disable FCS stripping */
- ipd_sub_port_fcs.u64 =
- cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS);
- ipd_sub_port_fcs.s.port_bit &=
- 0xffffffffull ^ (1ull << priv->port);
- cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS,
- ipd_sub_port_fcs.u64);
-
- /* Clear any error bits */
- cvmx_write_csr(CVMX_GMXX_RXX_INT_REG
- (index, interface),
- gmxx_rxx_int_reg.u64);
+ cvm_oct_set_hw_preamble(priv, false);
printk_ratelimited("%s: Using 10Mbps with software preamble removal\n",
dev->name);
}
@@ -133,34 +117,12 @@ static void cvm_oct_rgmii_poll(struct net_device *dev)
return;
}
- /* If the 10Mbps preamble workaround is allowed we need to on
+ /* Since the 10Mbps preamble workaround is allowed we need to enable
preamble checking, FCS stripping, and clear error bits on
every speed change. If errors occur during 10Mbps operation
the above code will change this stuff */
- if (USE_10MBPS_PREAMBLE_WORKAROUND) {
-
- union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl;
- union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs;
- union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg;
- int interface = INTERFACE(priv->port);
- int index = INDEX(priv->port);
-
- /* Enable preamble checking */
- gmxx_rxx_frm_ctl.u64 =
- cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface));
- gmxx_rxx_frm_ctl.s.pre_chk = 1;
- cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface),
- gmxx_rxx_frm_ctl.u64);
- /* Enable FCS stripping */
- ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS);
- ipd_sub_port_fcs.s.port_bit |= 1ull << priv->port;
- cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64);
- /* Clear any error bits */
- gmxx_rxx_int_reg.u64 =
- cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index, interface));
- cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface),
- gmxx_rxx_int_reg.u64);
- }
+ cvm_oct_set_hw_preamble(priv, true);
+
if (priv->phydev == NULL) {
link_info = cvmx_helper_link_autoconf(priv->port);
priv->link_info = link_info.u64;
@@ -176,172 +138,75 @@ static void cvm_oct_rgmii_poll(struct net_device *dev)
if (link_info.s.link_up) {
if (!netif_carrier_ok(dev))
netif_carrier_on(dev);
- if (priv->queue != -1)
- printk_ratelimited("%s: %u Mbps %s duplex, port %2d, queue %2d\n",
- dev->name, link_info.s.speed,
- (link_info.s.full_duplex) ?
- "Full" : "Half",
- priv->port, priv->queue);
- else
- printk_ratelimited("%s: %u Mbps %s duplex, port %2d, POW\n",
- dev->name, link_info.s.speed,
- (link_info.s.full_duplex) ?
- "Full" : "Half",
- priv->port);
- } else {
- if (netif_carrier_ok(dev))
- netif_carrier_off(dev);
- printk_ratelimited("%s: Link down\n", dev->name);
+ } else if (netif_carrier_ok(dev)) {
+ netif_carrier_off(dev);
}
+ cvm_oct_note_carrier(priv, link_info);
}
}
-static irqreturn_t cvm_oct_rgmii_rml_interrupt(int cpl, void *dev_id)
+static int cmv_oct_rgmii_gmx_interrupt(int interface)
{
- union cvmx_npi_rsl_int_blocks rsl_int_blocks;
int index;
- irqreturn_t return_status = IRQ_NONE;
+ int count = 0;
- rsl_int_blocks.u64 = cvmx_read_csr(CVMX_NPI_RSL_INT_BLOCKS);
-
- /* Check and see if this interrupt was caused by the GMX0 block */
- if (rsl_int_blocks.s.gmx0) {
-
- int interface = 0;
- /* Loop through every port of this interface */
- for (index = 0;
- index < cvmx_helper_ports_on_interface(interface);
- index++) {
+ /* Loop through every port of this interface */
+ for (index = 0;
+ index < cvmx_helper_ports_on_interface(interface);
+ index++) {
+ union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg;
- /* Read the GMX interrupt status bits */
- union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg;
-
- gmx_rx_int_reg.u64 =
- cvmx_read_csr(CVMX_GMXX_RXX_INT_REG
+ /* Read the GMX interrupt status bits */
+ gmx_rx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG
(index, interface));
- gmx_rx_int_reg.u64 &=
- cvmx_read_csr(CVMX_GMXX_RXX_INT_EN
+ gmx_rx_int_reg.u64 &= cvmx_read_csr(CVMX_GMXX_RXX_INT_EN
(index, interface));
- /* Poll the port if inband status changed */
- if (gmx_rx_int_reg.s.phy_dupx
- || gmx_rx_int_reg.s.phy_link
- || gmx_rx_int_reg.s.phy_spd) {
- struct net_device *dev =
+ /* Poll the port if inband status changed */
+ if (gmx_rx_int_reg.s.phy_dupx || gmx_rx_int_reg.s.phy_link ||
+ gmx_rx_int_reg.s.phy_spd) {
+ struct net_device *dev =
cvm_oct_device[cvmx_helper_get_ipd_port
(interface, index)];
- struct octeon_ethernet *priv = netdev_priv(dev);
-
- if (dev &&
- !atomic_read(&cvm_oct_poll_queue_stopping))
- queue_work(cvm_oct_poll_queue,
- &priv->port_work);
-
- gmx_rx_int_reg.u64 = 0;
- gmx_rx_int_reg.s.phy_dupx = 1;
- gmx_rx_int_reg.s.phy_link = 1;
- gmx_rx_int_reg.s.phy_spd = 1;
- cvmx_write_csr(CVMX_GMXX_RXX_INT_REG
- (index, interface),
- gmx_rx_int_reg.u64);
- return_status = IRQ_HANDLED;
- }
+ struct octeon_ethernet *priv = netdev_priv(dev);
+
+ if (dev && !atomic_read(&cvm_oct_poll_queue_stopping))
+ queue_work(cvm_oct_poll_queue,
+ &priv->port_work);
+
+ gmx_rx_int_reg.u64 = 0;
+ gmx_rx_int_reg.s.phy_dupx = 1;
+ gmx_rx_int_reg.s.phy_link = 1;
+ gmx_rx_int_reg.s.phy_spd = 1;
+ cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface),
+ gmx_rx_int_reg.u64);
+ count++;
}
}
+ return count;
+}
- /* Check and see if this interrupt was caused by the GMX1 block */
- if (rsl_int_blocks.s.gmx1) {
+static irqreturn_t cvm_oct_rgmii_rml_interrupt(int cpl, void *dev_id)
+{
+ union cvmx_npi_rsl_int_blocks rsl_int_blocks;
+ int count = 0;
- int interface = 1;
- /* Loop through every port of this interface */
- for (index = 0;
- index < cvmx_helper_ports_on_interface(interface);
- index++) {
+ rsl_int_blocks.u64 = cvmx_read_csr(CVMX_NPI_RSL_INT_BLOCKS);
- /* Read the GMX interrupt status bits */
- union cvmx_gmxx_rxx_int_reg gmx_rx_int_reg;
+ /* Check and see if this interrupt was caused by the GMX0 block */
+ if (rsl_int_blocks.s.gmx0)
+ count += cmv_oct_rgmii_gmx_interrupt(0);
- gmx_rx_int_reg.u64 =
- cvmx_read_csr(CVMX_GMXX_RXX_INT_REG
- (index, interface));
- gmx_rx_int_reg.u64 &=
- cvmx_read_csr(CVMX_GMXX_RXX_INT_EN
- (index, interface));
- /* Poll the port if inband status changed */
- if (gmx_rx_int_reg.s.phy_dupx
- || gmx_rx_int_reg.s.phy_link
- || gmx_rx_int_reg.s.phy_spd) {
+ /* Check and see if this interrupt was caused by the GMX1 block */
+ if (rsl_int_blocks.s.gmx1)
+ count += cmv_oct_rgmii_gmx_interrupt(1);
- struct net_device *dev =
- cvm_oct_device[cvmx_helper_get_ipd_port
- (interface, index)];
- struct octeon_ethernet *priv = netdev_priv(dev);
-
- if (dev &&
- !atomic_read(&cvm_oct_poll_queue_stopping))
- queue_work(cvm_oct_poll_queue,
- &priv->port_work);
-
- gmx_rx_int_reg.u64 = 0;
- gmx_rx_int_reg.s.phy_dupx = 1;
- gmx_rx_int_reg.s.phy_link = 1;
- gmx_rx_int_reg.s.phy_spd = 1;
- cvmx_write_csr(CVMX_GMXX_RXX_INT_REG
- (index, interface),
- gmx_rx_int_reg.u64);
- return_status = IRQ_HANDLED;
- }
- }
- }
- return return_status;
+ return count ? IRQ_HANDLED : IRQ_NONE;
}
int cvm_oct_rgmii_open(struct net_device *dev)
{
- union cvmx_gmxx_prtx_cfg gmx_cfg;
- struct octeon_ethernet *priv = netdev_priv(dev);
- int interface = INTERFACE(priv->port);
- int index = INDEX(priv->port);
- cvmx_helper_link_info_t link_info;
- int rv;
-
- rv = cvm_oct_phy_setup_device(dev);
- if (rv)
- return rv;
-
- gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
- gmx_cfg.s.en = 1;
- cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
-
- if (!octeon_is_simulation()) {
- if (priv->phydev) {
- int r = phy_read_status(priv->phydev);
-
- if (r == 0 && priv->phydev->link == 0)
- netif_carrier_off(dev);
- cvm_oct_adjust_link(dev);
- } else {
- link_info = cvmx_helper_link_get(priv->port);
- if (!link_info.s.link_up)
- netif_carrier_off(dev);
- priv->poll = cvm_oct_rgmii_poll;
- }
- }
-
- return 0;
-}
-
-int cvm_oct_rgmii_stop(struct net_device *dev)
-{
- union cvmx_gmxx_prtx_cfg gmx_cfg;
- struct octeon_ethernet *priv = netdev_priv(dev);
- int interface = INTERFACE(priv->port);
- int index = INDEX(priv->port);
-
- gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
- gmx_cfg.s.en = 0;
- cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
- return cvm_oct_common_stop(dev);
+ return cvm_oct_common_open(dev, cvm_oct_rgmii_poll, false);
}
static void cvm_oct_rgmii_immediate_poll(struct work_struct *work)
@@ -357,7 +222,6 @@ int cvm_oct_rgmii_init(struct net_device *dev)
int r;
cvm_oct_common_init(dev);
- dev->netdev_ops->ndo_stop(dev);
INIT_WORK(&priv->port_work, cvm_oct_rgmii_immediate_poll);
/*
* Due to GMX errata in CN3XXX series chips, it is necessary
diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
index 22667dbb10d825..22853d33da0525 100644
--- a/drivers/staging/octeon/ethernet-rx.c
+++ b/drivers/staging/octeon/ethernet-rx.c
@@ -1,29 +1,13 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2010 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
+
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/cache.h>
@@ -93,11 +77,8 @@ static inline int cvm_oct_check_rcv_error(cvmx_wqe_t *work)
* instead of 60+4FCS. Note these packets still get
* counted as frame errors.
*/
- } else
- if (USE_10MBPS_PREAMBLE_WORKAROUND
- && ((work->word2.snoip.err_code == 5)
- || (work->word2.snoip.err_code == 7))) {
-
+ } else if (work->word2.snoip.err_code == 5 ||
+ work->word2.snoip.err_code == 7) {
/*
* We received a packet with either an alignment error
* or a FCS error. This may be signalling that we are
@@ -233,7 +214,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
}
rx_count++;
- skb_in_hw = USE_SKBUFFS_IN_HW && work->word2.s.bufs == 1;
+ skb_in_hw = work->word2.s.bufs == 1;
if (likely(skb_in_hw)) {
skb = *pskb;
prefetch(&skb->head);
@@ -394,7 +375,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
* Check to see if the skbuff and work share the same
* packet buffer.
*/
- if (USE_SKBUFFS_IN_HW && likely(packet_not_copied)) {
+ if (likely(packet_not_copied)) {
/*
* This buffer needs to be replaced, increment
* the number of buffers we need to free by
@@ -403,8 +384,7 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
cvmx_fau_atomic_add32(FAU_NUM_PACKET_BUFFERS_TO_FREE,
1);
- cvmx_fpa_free(work, CVMX_FPA_WQE_POOL,
- DONT_WRITEBACK(1));
+ cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1);
} else {
cvm_oct_free_work(work);
}
diff --git a/drivers/staging/octeon/ethernet-rx.h b/drivers/staging/octeon/ethernet-rx.h
index 9240c85ce24178..a5973fd015fc7c 100644
--- a/drivers/staging/octeon/ethernet-rx.h
+++ b/drivers/staging/octeon/ethernet-rx.h
@@ -1,29 +1,13 @@
-/*********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-*********************************************************************/
+ */
+
#include <asm/octeon/cvmx-fau.h>
void cvm_oct_poll_controller(struct net_device *dev);
diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c
index 21a7a17acb79ca..8bceb769166cd0 100644
--- a/drivers/staging/octeon/ethernet-sgmii.c
+++ b/drivers/staging/octeon/ethernet-sgmii.c
@@ -1,29 +1,13 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
+
#include <linux/phy.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
@@ -41,101 +25,15 @@
#include <asm/octeon/cvmx-gmxx-defs.h>
-static void cvm_oct_sgmii_poll(struct net_device *dev)
-{
- struct octeon_ethernet *priv = netdev_priv(dev);
- cvmx_helper_link_info_t link_info;
-
- link_info = cvmx_helper_link_get(priv->port);
- if (link_info.u64 == priv->link_info)
- return;
-
- link_info = cvmx_helper_link_autoconf(priv->port);
- priv->link_info = link_info.u64;
-
- /* Tell Linux */
- if (link_info.s.link_up) {
-
- if (!netif_carrier_ok(dev))
- netif_carrier_on(dev);
- if (priv->queue != -1)
- printk_ratelimited
- ("%s: %u Mbps %s duplex, port %2d, queue %2d\n",
- dev->name, link_info.s.speed,
- (link_info.s.full_duplex) ? "Full" : "Half",
- priv->port, priv->queue);
- else
- printk_ratelimited
- ("%s: %u Mbps %s duplex, port %2d, POW\n",
- dev->name, link_info.s.speed,
- (link_info.s.full_duplex) ? "Full" : "Half",
- priv->port);
- } else {
- if (netif_carrier_ok(dev))
- netif_carrier_off(dev);
- printk_ratelimited("%s: Link down\n", dev->name);
- }
-}
-
int cvm_oct_sgmii_open(struct net_device *dev)
{
- union cvmx_gmxx_prtx_cfg gmx_cfg;
- struct octeon_ethernet *priv = netdev_priv(dev);
- int interface = INTERFACE(priv->port);
- int index = INDEX(priv->port);
- cvmx_helper_link_info_t link_info;
- int rv;
-
- rv = cvm_oct_phy_setup_device(dev);
- if (rv)
- return rv;
-
- gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
- gmx_cfg.s.en = 1;
- cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
-
- if (octeon_is_simulation())
- return 0;
-
- if (priv->phydev) {
- int r = phy_read_status(priv->phydev);
-
- if (r == 0 && priv->phydev->link == 0)
- netif_carrier_off(dev);
- cvm_oct_adjust_link(dev);
- } else {
- link_info = cvmx_helper_link_get(priv->port);
- if (!link_info.s.link_up)
- netif_carrier_off(dev);
- priv->poll = cvm_oct_sgmii_poll;
- cvm_oct_sgmii_poll(dev);
- }
- return 0;
-}
-
-int cvm_oct_sgmii_stop(struct net_device *dev)
-{
- union cvmx_gmxx_prtx_cfg gmx_cfg;
- struct octeon_ethernet *priv = netdev_priv(dev);
- int interface = INTERFACE(priv->port);
- int index = INDEX(priv->port);
-
- gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
- gmx_cfg.s.en = 0;
- cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
- return cvm_oct_common_stop(dev);
+ return cvm_oct_common_open(dev, cvm_oct_link_poll, true);
}
int cvm_oct_sgmii_init(struct net_device *dev)
{
cvm_oct_common_init(dev);
- dev->netdev_ops->ndo_stop(dev);
/* FIXME: Need autoneg logic */
return 0;
}
-
-void cvm_oct_sgmii_uninit(struct net_device *dev)
-{
- cvm_oct_common_uninit(dev);
-}
diff --git a/drivers/staging/octeon/ethernet-spi.c b/drivers/staging/octeon/ethernet-spi.c
index 5108bc0bb573e0..2ae1944b3a1bfb 100644
--- a/drivers/staging/octeon/ethernet-spi.c
+++ b/drivers/staging/octeon/ethernet-spi.c
@@ -1,29 +1,13 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
+
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <linux/interrupt.h>
@@ -44,141 +28,104 @@
static int number_spi_ports;
static int need_retrain[2] = { 0, 0 };
-static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id)
+static void cvm_oct_spxx_int_pr(union cvmx_spxx_int_reg spx_int_reg, int index)
{
- irqreturn_t return_status = IRQ_NONE;
- union cvmx_npi_rsl_int_blocks rsl_int_blocks;
-
- /* Check and see if this interrupt was caused by the GMX block */
- rsl_int_blocks.u64 = cvmx_read_csr(CVMX_NPI_RSL_INT_BLOCKS);
- if (rsl_int_blocks.s.spx1) { /* 19 - SPX1_INT_REG & STX1_INT_REG */
-
- union cvmx_spxx_int_reg spx_int_reg;
- union cvmx_stxx_int_reg stx_int_reg;
-
- spx_int_reg.u64 = cvmx_read_csr(CVMX_SPXX_INT_REG(1));
- cvmx_write_csr(CVMX_SPXX_INT_REG(1), spx_int_reg.u64);
- if (!need_retrain[1]) {
-
- spx_int_reg.u64 &= cvmx_read_csr(CVMX_SPXX_INT_MSK(1));
- if (spx_int_reg.s.spf)
- pr_err("SPI1: SRX Spi4 interface down\n");
- if (spx_int_reg.s.calerr)
- pr_err("SPI1: SRX Spi4 Calendar table parity error\n");
- if (spx_int_reg.s.syncerr)
- pr_err("SPI1: SRX Consecutive Spi4 DIP4 errors have exceeded SPX_ERR_CTL[ERRCNT]\n");
- if (spx_int_reg.s.diperr)
- pr_err("SPI1: SRX Spi4 DIP4 error\n");
- if (spx_int_reg.s.tpaovr)
- pr_err("SPI1: SRX Selected port has hit TPA overflow\n");
- if (spx_int_reg.s.rsverr)
- pr_err("SPI1: SRX Spi4 reserved control word detected\n");
- if (spx_int_reg.s.drwnng)
- pr_err("SPI1: SRX Spi4 receive FIFO drowning/overflow\n");
- if (spx_int_reg.s.clserr)
- pr_err("SPI1: SRX Spi4 packet closed on non-16B alignment without EOP\n");
- if (spx_int_reg.s.spiovr)
- pr_err("SPI1: SRX Spi4 async FIFO overflow\n");
- if (spx_int_reg.s.abnorm)
- pr_err("SPI1: SRX Abnormal packet termination (ERR bit)\n");
- if (spx_int_reg.s.prtnxa)
- pr_err("SPI1: SRX Port out of range\n");
- }
-
- stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(1));
- cvmx_write_csr(CVMX_STXX_INT_REG(1), stx_int_reg.u64);
- if (!need_retrain[1]) {
+ if (spx_int_reg.s.spf)
+ pr_err("SPI%d: SRX Spi4 interface down\n", index);
+ if (spx_int_reg.s.calerr)
+ pr_err("SPI%d: SRX Spi4 Calendar table parity error\n", index);
+ if (spx_int_reg.s.syncerr)
+ pr_err("SPI%d: SRX Consecutive Spi4 DIP4 errors have exceeded SPX_ERR_CTL[ERRCNT]\n",
+ index);
+ if (spx_int_reg.s.diperr)
+ pr_err("SPI%d: SRX Spi4 DIP4 error\n", index);
+ if (spx_int_reg.s.tpaovr)
+ pr_err("SPI%d: SRX Selected port has hit TPA overflow\n",
+ index);
+ if (spx_int_reg.s.rsverr)
+ pr_err("SPI%d: SRX Spi4 reserved control word detected\n",
+ index);
+ if (spx_int_reg.s.drwnng)
+ pr_err("SPI%d: SRX Spi4 receive FIFO drowning/overflow\n",
+ index);
+ if (spx_int_reg.s.clserr)
+ pr_err("SPI%d: SRX Spi4 packet closed on non-16B alignment without EOP\n",
+ index);
+ if (spx_int_reg.s.spiovr)
+ pr_err("SPI%d: SRX Spi4 async FIFO overflow\n", index);
+ if (spx_int_reg.s.abnorm)
+ pr_err("SPI%d: SRX Abnormal packet termination (ERR bit)\n",
+ index);
+ if (spx_int_reg.s.prtnxa)
+ pr_err("SPI%d: SRX Port out of range\n", index);
+}
- stx_int_reg.u64 &= cvmx_read_csr(CVMX_STXX_INT_MSK(1));
- if (stx_int_reg.s.syncerr)
- pr_err("SPI1: STX Interface encountered a fatal error\n");
- if (stx_int_reg.s.frmerr)
- pr_err("SPI1: STX FRMCNT has exceeded STX_DIP_CNT[MAXFRM]\n");
- if (stx_int_reg.s.unxfrm)
- pr_err("SPI1: STX Unexpected framing sequence\n");
- if (stx_int_reg.s.nosync)
- pr_err("SPI1: STX ERRCNT has exceeded STX_DIP_CNT[MAXDIP]\n");
- if (stx_int_reg.s.diperr)
- pr_err("SPI1: STX DIP2 error on the Spi4 Status channel\n");
- if (stx_int_reg.s.datovr)
- pr_err("SPI1: STX Spi4 FIFO overflow error\n");
- if (stx_int_reg.s.ovrbst)
- pr_err("SPI1: STX Transmit packet burst too big\n");
- if (stx_int_reg.s.calpar1)
- pr_err("SPI1: STX Calendar Table Parity Error Bank1\n");
- if (stx_int_reg.s.calpar0)
- pr_err("SPI1: STX Calendar Table Parity Error Bank0\n");
- }
+static void cvm_oct_stxx_int_pr(union cvmx_stxx_int_reg stx_int_reg, int index)
+{
+ if (stx_int_reg.s.syncerr)
+ pr_err("SPI%d: STX Interface encountered a fatal error\n",
+ index);
+ if (stx_int_reg.s.frmerr)
+ pr_err("SPI%d: STX FRMCNT has exceeded STX_DIP_CNT[MAXFRM]\n",
+ index);
+ if (stx_int_reg.s.unxfrm)
+ pr_err("SPI%d: STX Unexpected framing sequence\n", index);
+ if (stx_int_reg.s.nosync)
+ pr_err("SPI%d: STX ERRCNT has exceeded STX_DIP_CNT[MAXDIP]\n",
+ index);
+ if (stx_int_reg.s.diperr)
+ pr_err("SPI%d: STX DIP2 error on the Spi4 Status channel\n",
+ index);
+ if (stx_int_reg.s.datovr)
+ pr_err("SPI%d: STX Spi4 FIFO overflow error\n", index);
+ if (stx_int_reg.s.ovrbst)
+ pr_err("SPI%d: STX Transmit packet burst too big\n", index);
+ if (stx_int_reg.s.calpar1)
+ pr_err("SPI%d: STX Calendar Table Parity Error Bank%d\n",
+ index, 1);
+ if (stx_int_reg.s.calpar0)
+ pr_err("SPI%d: STX Calendar Table Parity Error Bank%d\n",
+ index, 0);
+}
- cvmx_write_csr(CVMX_SPXX_INT_MSK(1), 0);
- cvmx_write_csr(CVMX_STXX_INT_MSK(1), 0);
- need_retrain[1] = 1;
- return_status = IRQ_HANDLED;
+static irqreturn_t cvm_oct_spi_spx_int(int index)
+{
+ union cvmx_spxx_int_reg spx_int_reg;
+ union cvmx_stxx_int_reg stx_int_reg;
+
+ spx_int_reg.u64 = cvmx_read_csr(CVMX_SPXX_INT_REG(index));
+ cvmx_write_csr(CVMX_SPXX_INT_REG(index), spx_int_reg.u64);
+ if (!need_retrain[index]) {
+ spx_int_reg.u64 &= cvmx_read_csr(CVMX_SPXX_INT_MSK(index));
+ cvm_oct_spxx_int_pr(spx_int_reg, index);
}
- if (rsl_int_blocks.s.spx0) { /* 18 - SPX0_INT_REG & STX0_INT_REG */
- union cvmx_spxx_int_reg spx_int_reg;
- union cvmx_stxx_int_reg stx_int_reg;
+ stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(index));
+ cvmx_write_csr(CVMX_STXX_INT_REG(index), stx_int_reg.u64);
+ if (!need_retrain[index]) {
+ stx_int_reg.u64 &= cvmx_read_csr(CVMX_STXX_INT_MSK(index));
+ cvm_oct_stxx_int_pr(stx_int_reg, index);
+ }
- spx_int_reg.u64 = cvmx_read_csr(CVMX_SPXX_INT_REG(0));
- cvmx_write_csr(CVMX_SPXX_INT_REG(0), spx_int_reg.u64);
- if (!need_retrain[0]) {
+ cvmx_write_csr(CVMX_SPXX_INT_MSK(index), 0);
+ cvmx_write_csr(CVMX_STXX_INT_MSK(index), 0);
+ need_retrain[index] = 1;
- spx_int_reg.u64 &= cvmx_read_csr(CVMX_SPXX_INT_MSK(0));
- if (spx_int_reg.s.spf)
- pr_err("SPI0: SRX Spi4 interface down\n");
- if (spx_int_reg.s.calerr)
- pr_err("SPI0: SRX Spi4 Calendar table parity error\n");
- if (spx_int_reg.s.syncerr)
- pr_err("SPI0: SRX Consecutive Spi4 DIP4 errors have exceeded SPX_ERR_CTL[ERRCNT]\n");
- if (spx_int_reg.s.diperr)
- pr_err("SPI0: SRX Spi4 DIP4 error\n");
- if (spx_int_reg.s.tpaovr)
- pr_err("SPI0: SRX Selected port has hit TPA overflow\n");
- if (spx_int_reg.s.rsverr)
- pr_err("SPI0: SRX Spi4 reserved control word detected\n");
- if (spx_int_reg.s.drwnng)
- pr_err("SPI0: SRX Spi4 receive FIFO drowning/overflow\n");
- if (spx_int_reg.s.clserr)
- pr_err("SPI0: SRX Spi4 packet closed on non-16B alignment without EOP\n");
- if (spx_int_reg.s.spiovr)
- pr_err("SPI0: SRX Spi4 async FIFO overflow\n");
- if (spx_int_reg.s.abnorm)
- pr_err("SPI0: SRX Abnormal packet termination (ERR bit)\n");
- if (spx_int_reg.s.prtnxa)
- pr_err("SPI0: SRX Port out of range\n");
- }
+ return IRQ_HANDLED;
+}
- stx_int_reg.u64 = cvmx_read_csr(CVMX_STXX_INT_REG(0));
- cvmx_write_csr(CVMX_STXX_INT_REG(0), stx_int_reg.u64);
- if (!need_retrain[0]) {
+static irqreturn_t cvm_oct_spi_rml_interrupt(int cpl, void *dev_id)
+{
+ irqreturn_t return_status = IRQ_NONE;
+ union cvmx_npi_rsl_int_blocks rsl_int_blocks;
- stx_int_reg.u64 &= cvmx_read_csr(CVMX_STXX_INT_MSK(0));
- if (stx_int_reg.s.syncerr)
- pr_err("SPI0: STX Interface encountered a fatal error\n");
- if (stx_int_reg.s.frmerr)
- pr_err("SPI0: STX FRMCNT has exceeded STX_DIP_CNT[MAXFRM]\n");
- if (stx_int_reg.s.unxfrm)
- pr_err("SPI0: STX Unexpected framing sequence\n");
- if (stx_int_reg.s.nosync)
- pr_err("SPI0: STX ERRCNT has exceeded STX_DIP_CNT[MAXDIP]\n");
- if (stx_int_reg.s.diperr)
- pr_err("SPI0: STX DIP2 error on the Spi4 Status channel\n");
- if (stx_int_reg.s.datovr)
- pr_err("SPI0: STX Spi4 FIFO overflow error\n");
- if (stx_int_reg.s.ovrbst)
- pr_err("SPI0: STX Transmit packet burst too big\n");
- if (stx_int_reg.s.calpar1)
- pr_err("SPI0: STX Calendar Table Parity Error Bank1\n");
- if (stx_int_reg.s.calpar0)
- pr_err("SPI0: STX Calendar Table Parity Error Bank0\n");
- }
+ /* Check and see if this interrupt was caused by the GMX block */
+ rsl_int_blocks.u64 = cvmx_read_csr(CVMX_NPI_RSL_INT_BLOCKS);
+ if (rsl_int_blocks.s.spx1) /* 19 - SPX1_INT_REG & STX1_INT_REG */
+ return_status = cvm_oct_spi_spx_int(1);
- cvmx_write_csr(CVMX_SPXX_INT_MSK(0), 0);
- cvmx_write_csr(CVMX_STXX_INT_MSK(0), 0);
- need_retrain[0] = 1;
- return_status = IRQ_HANDLED;
- }
+ if (rsl_int_blocks.s.spx0) /* 18 - SPX0_INT_REG & STX0_INT_REG */
+ return_status = cvm_oct_spi_spx_int(0);
return return_status;
}
diff --git a/drivers/staging/octeon/ethernet-tx.c b/drivers/staging/octeon/ethernet-tx.c
index 5b9ac1f6d6f036..7c1c1b052b7d17 100644
--- a/drivers/staging/octeon/ethernet-tx.c
+++ b/drivers/staging/octeon/ethernet-tx.c
@@ -1,29 +1,13 @@
-/*********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2010 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-*********************************************************************/
+ */
+
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
@@ -411,7 +395,7 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
dont_put_skbuff_in_hw:
/* Check if we can use the hardware checksumming */
- if (USE_HW_TCPUDP_CHECKSUM && (skb->protocol == htons(ETH_P_IP)) &&
+ if ((skb->protocol == htons(ETH_P_IP)) &&
(ip_hdr(skb)->version == 4) && (ip_hdr(skb)->ihl == 5) &&
((ip_hdr(skb)->frag_off == 0) || (ip_hdr(skb)->frag_off == htons(1 << 14)))
&& ((ip_hdr(skb)->protocol == IPPROTO_TCP)
@@ -576,7 +560,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
if (unlikely(packet_buffer == NULL)) {
printk_ratelimited("%s: Failed to allocate a packet buffer\n",
dev->name);
- cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, DONT_WRITEBACK(1));
+ cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1);
priv->stats.tx_dropped++;
dev_kfree_skb_any(skb);
return 0;
diff --git a/drivers/staging/octeon/ethernet-tx.h b/drivers/staging/octeon/ethernet-tx.h
index 547680c6c371e0..84848e4c166421 100644
--- a/drivers/staging/octeon/ethernet-tx.h
+++ b/drivers/staging/octeon/ethernet-tx.h
@@ -1,29 +1,12 @@
-/*********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-*********************************************************************/
+ */
int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev);
int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev);
diff --git a/drivers/staging/octeon/ethernet-util.h b/drivers/staging/octeon/ethernet-util.h
index 0f9b4a18fc27ce..1ba789a7741bd2 100644
--- a/drivers/staging/octeon/ethernet-util.h
+++ b/drivers/staging/octeon/ethernet-util.h
@@ -1,29 +1,12 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-*********************************************************************/
+ */
/**
* cvm_oct_get_buffer_ptr - convert packet data address to pointer
diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c
index fd9d103d8e56cc..4b47bcfaabb15a 100644
--- a/drivers/staging/octeon/ethernet-xaui.c
+++ b/drivers/staging/octeon/ethernet-xaui.c
@@ -1,29 +1,13 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
+
#include <linux/phy.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
@@ -41,89 +25,9 @@
#include <asm/octeon/cvmx-gmxx-defs.h>
-static void cvm_oct_xaui_poll(struct net_device *dev)
-{
- struct octeon_ethernet *priv = netdev_priv(dev);
- cvmx_helper_link_info_t link_info;
-
- link_info = cvmx_helper_link_get(priv->port);
- if (link_info.u64 == priv->link_info)
- return;
-
- link_info = cvmx_helper_link_autoconf(priv->port);
- priv->link_info = link_info.u64;
-
- /* Tell Linux */
- if (link_info.s.link_up) {
-
- if (!netif_carrier_ok(dev))
- netif_carrier_on(dev);
- if (priv->queue != -1)
- printk_ratelimited
- ("%s: %u Mbps %s duplex, port %2d, queue %2d\n",
- dev->name, link_info.s.speed,
- (link_info.s.full_duplex) ? "Full" : "Half",
- priv->port, priv->queue);
- else
- printk_ratelimited
- ("%s: %u Mbps %s duplex, port %2d, POW\n",
- dev->name, link_info.s.speed,
- (link_info.s.full_duplex) ? "Full" : "Half",
- priv->port);
- } else {
- if (netif_carrier_ok(dev))
- netif_carrier_off(dev);
- printk_ratelimited("%s: Link down\n", dev->name);
- }
-}
-
int cvm_oct_xaui_open(struct net_device *dev)
{
- union cvmx_gmxx_prtx_cfg gmx_cfg;
- struct octeon_ethernet *priv = netdev_priv(dev);
- int interface = INTERFACE(priv->port);
- int index = INDEX(priv->port);
- cvmx_helper_link_info_t link_info;
- int rv;
-
- rv = cvm_oct_phy_setup_device(dev);
- if (rv)
- return rv;
-
- gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
- gmx_cfg.s.en = 1;
- cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
-
- if (octeon_is_simulation())
- return 0;
-
- if (priv->phydev) {
- int r = phy_read_status(priv->phydev);
-
- if (r == 0 && priv->phydev->link == 0)
- netif_carrier_off(dev);
- cvm_oct_adjust_link(dev);
- } else {
- link_info = cvmx_helper_link_get(priv->port);
- if (!link_info.s.link_up)
- netif_carrier_off(dev);
- priv->poll = cvm_oct_xaui_poll;
- cvm_oct_xaui_poll(dev);
- }
- return 0;
-}
-
-int cvm_oct_xaui_stop(struct net_device *dev)
-{
- union cvmx_gmxx_prtx_cfg gmx_cfg;
- struct octeon_ethernet *priv = netdev_priv(dev);
- int interface = INTERFACE(priv->port);
- int index = INDEX(priv->port);
-
- gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
- gmx_cfg.s.en = 0;
- cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
- return cvm_oct_common_stop(dev);
+ return cvm_oct_common_open(dev, cvm_oct_link_poll, true);
}
int cvm_oct_xaui_init(struct net_device *dev)
@@ -131,14 +35,8 @@ int cvm_oct_xaui_init(struct net_device *dev)
struct octeon_ethernet *priv = netdev_priv(dev);
cvm_oct_common_init(dev);
- dev->netdev_ops->ndo_stop(dev);
if (!octeon_is_simulation() && priv->phydev == NULL)
- priv->poll = cvm_oct_xaui_poll;
+ priv->poll = cvm_oct_link_poll;
return 0;
}
-
-void cvm_oct_xaui_uninit(struct net_device *dev)
-{
- cvm_oct_common_uninit(dev);
-}
diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
index fbbe866485c7c3..f9dba23a375914 100644
--- a/drivers/staging/octeon/ethernet.c
+++ b/drivers/staging/octeon/ethernet.c
@@ -1,29 +1,13 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2007 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
+
#include <linux/platform_device.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -180,10 +164,7 @@ static void cvm_oct_configure_common_hw(void)
}
#endif
- if (USE_RED)
- cvmx_helper_setup_red(num_packet_buffers / 4,
- num_packet_buffers / 8);
-
+ cvmx_helper_setup_red(num_packet_buffers / 4, num_packet_buffers / 8);
}
/**
@@ -206,11 +187,10 @@ int cvm_oct_free_work(void *work_queue_entry)
if (unlikely(!segment_ptr.s.i))
cvmx_fpa_free(cvm_oct_get_buffer_ptr(segment_ptr),
segment_ptr.s.pool,
- DONT_WRITEBACK(CVMX_FPA_PACKET_POOL_SIZE /
- 128));
+ CVMX_FPA_PACKET_POOL_SIZE / 128);
segment_ptr = next_ptr;
}
- cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, DONT_WRITEBACK(1));
+ cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1);
return 0;
}
@@ -468,11 +448,8 @@ int cvm_oct_common_init(struct net_device *dev)
&& (always_use_pow || strstr(pow_send_list, dev->name)))
priv->queue = -1;
- if (priv->queue != -1) {
- dev->features |= NETIF_F_SG;
- if (USE_HW_TCPUDP_CHECKSUM)
- dev->features |= NETIF_F_IP_CSUM;
- }
+ if (priv->queue != -1)
+ dev->features |= NETIF_F_SG | NETIF_F_IP_CSUM;
/* We do our own locking, Linux doesn't need to */
dev->features |= NETIF_F_LLTX;
@@ -488,6 +465,9 @@ int cvm_oct_common_init(struct net_device *dev)
memset(dev->netdev_ops->ndo_get_stats(dev), 0,
sizeof(struct net_device_stats));
+ if (dev->netdev_ops->ndo_stop)
+ dev->netdev_ops->ndo_stop(dev);
+
return 0;
}
@@ -499,6 +479,66 @@ void cvm_oct_common_uninit(struct net_device *dev)
phy_disconnect(priv->phydev);
}
+int cvm_oct_common_open(struct net_device *dev,
+ void (*link_poll)(struct net_device *), bool poll_now)
+{
+ union cvmx_gmxx_prtx_cfg gmx_cfg;
+ struct octeon_ethernet *priv = netdev_priv(dev);
+ int interface = INTERFACE(priv->port);
+ int index = INDEX(priv->port);
+ cvmx_helper_link_info_t link_info;
+ int rv;
+
+ rv = cvm_oct_phy_setup_device(dev);
+ if (rv)
+ return rv;
+
+ gmx_cfg.u64 = cvmx_read_csr(CVMX_GMXX_PRTX_CFG(index, interface));
+ gmx_cfg.s.en = 1;
+ cvmx_write_csr(CVMX_GMXX_PRTX_CFG(index, interface), gmx_cfg.u64);
+
+ if (octeon_is_simulation())
+ return 0;
+
+ if (priv->phydev) {
+ int r = phy_read_status(priv->phydev);
+
+ if (r == 0 && priv->phydev->link == 0)
+ netif_carrier_off(dev);
+ cvm_oct_adjust_link(dev);
+ } else {
+ link_info = cvmx_helper_link_get(priv->port);
+ if (!link_info.s.link_up)
+ netif_carrier_off(dev);
+ priv->poll = link_poll;
+ if (poll_now)
+ link_poll(dev);
+ }
+
+ return 0;
+}
+
+void cvm_oct_link_poll(struct net_device *dev)
+{
+ struct octeon_ethernet *priv = netdev_priv(dev);
+ cvmx_helper_link_info_t link_info;
+
+ link_info = cvmx_helper_link_get(priv->port);
+ if (link_info.u64 == priv->link_info)
+ return;
+
+ link_info = cvmx_helper_link_autoconf(priv->port);
+ priv->link_info = link_info.u64;
+
+ if (link_info.s.link_up) {
+ if (!netif_carrier_ok(dev))
+ netif_carrier_on(dev);
+ } else if (netif_carrier_ok(dev)) {
+ netif_carrier_off(dev);
+ }
+ cvm_oct_note_carrier(priv, link_info);
+}
+
static const struct net_device_ops cvm_oct_npi_netdev_ops = {
.ndo_init = cvm_oct_common_init,
.ndo_uninit = cvm_oct_common_uninit,
@@ -514,9 +554,9 @@ static const struct net_device_ops cvm_oct_npi_netdev_ops = {
};
static const struct net_device_ops cvm_oct_xaui_netdev_ops = {
.ndo_init = cvm_oct_xaui_init,
- .ndo_uninit = cvm_oct_xaui_uninit,
+ .ndo_uninit = cvm_oct_common_uninit,
.ndo_open = cvm_oct_xaui_open,
- .ndo_stop = cvm_oct_xaui_stop,
+ .ndo_stop = cvm_oct_common_stop,
.ndo_start_xmit = cvm_oct_xmit,
.ndo_set_rx_mode = cvm_oct_common_set_multicast_list,
.ndo_set_mac_address = cvm_oct_common_set_mac_address,
@@ -529,9 +569,9 @@ static const struct net_device_ops cvm_oct_xaui_netdev_ops = {
};
static const struct net_device_ops cvm_oct_sgmii_netdev_ops = {
.ndo_init = cvm_oct_sgmii_init,
- .ndo_uninit = cvm_oct_sgmii_uninit,
+ .ndo_uninit = cvm_oct_common_uninit,
.ndo_open = cvm_oct_sgmii_open,
- .ndo_stop = cvm_oct_sgmii_stop,
+ .ndo_stop = cvm_oct_common_stop,
.ndo_start_xmit = cvm_oct_xmit,
.ndo_set_rx_mode = cvm_oct_common_set_multicast_list,
.ndo_set_mac_address = cvm_oct_common_set_mac_address,
@@ -559,7 +599,7 @@ static const struct net_device_ops cvm_oct_rgmii_netdev_ops = {
.ndo_init = cvm_oct_rgmii_init,
.ndo_uninit = cvm_oct_rgmii_uninit,
.ndo_open = cvm_oct_rgmii_open,
- .ndo_stop = cvm_oct_rgmii_stop,
+ .ndo_stop = cvm_oct_common_stop,
.ndo_start_xmit = cvm_oct_xmit,
.ndo_set_rx_mode = cvm_oct_common_set_multicast_list,
.ndo_set_mac_address = cvm_oct_common_set_mac_address,
@@ -625,7 +665,6 @@ static int cvm_oct_probe(struct platform_device *pdev)
struct device_node *pip;
octeon_mdiobus_force_mod_depencency();
- pr_notice("cavium-ethernet %s\n", OCTEON_ETHERNET_VERSION);
pip = pdev->dev.of_node;
if (!pip) {
diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h
index f48dc766fadae3..e9d3e9a7e8a78b 100644
--- a/drivers/staging/octeon/octeon-ethernet.h
+++ b/drivers/staging/octeon/octeon-ethernet.h
@@ -1,29 +1,12 @@
-/**********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
*
* Copyright (c) 2003-2010 Cavium Networks
*
* This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-**********************************************************************/
+ */
/*
* External interface for the Cavium Octeon ethernet driver.
@@ -33,6 +16,8 @@
#include <linux/of.h>
+#include <asm/octeon/cvmx-helper-board.h>
+
/**
* This is the definition of the Ethernet driver's private
* driver state stored in netdev_priv(dev).
@@ -71,24 +56,24 @@ int cvm_oct_free_work(void *work_queue_entry);
extern int cvm_oct_rgmii_init(struct net_device *dev);
extern void cvm_oct_rgmii_uninit(struct net_device *dev);
extern int cvm_oct_rgmii_open(struct net_device *dev);
-extern int cvm_oct_rgmii_stop(struct net_device *dev);
extern int cvm_oct_sgmii_init(struct net_device *dev);
-extern void cvm_oct_sgmii_uninit(struct net_device *dev);
extern int cvm_oct_sgmii_open(struct net_device *dev);
-extern int cvm_oct_sgmii_stop(struct net_device *dev);
extern int cvm_oct_spi_init(struct net_device *dev);
extern void cvm_oct_spi_uninit(struct net_device *dev);
extern int cvm_oct_xaui_init(struct net_device *dev);
-extern void cvm_oct_xaui_uninit(struct net_device *dev);
extern int cvm_oct_xaui_open(struct net_device *dev);
-extern int cvm_oct_xaui_stop(struct net_device *dev);
extern int cvm_oct_common_init(struct net_device *dev);
extern void cvm_oct_common_uninit(struct net_device *dev);
void cvm_oct_adjust_link(struct net_device *dev);
int cvm_oct_common_stop(struct net_device *dev);
+int cvm_oct_common_open(struct net_device *dev,
+ void (*link_poll)(struct net_device *), bool poll_now);
+void cvm_oct_note_carrier(struct octeon_ethernet *priv,
+ cvmx_helper_link_info_t li);
+void cvm_oct_link_poll(struct net_device *dev);
extern int always_use_pow;
extern int pow_send_group;
diff --git a/drivers/staging/panel/panel.c b/drivers/staging/panel/panel.c
index ea54fb4ec837ea..d6704945525311 100644
--- a/drivers/staging/panel/panel.c
+++ b/drivers/staging/panel/panel.c
@@ -775,12 +775,10 @@ static void pin_to_bits(int pin, unsigned char *d_val, unsigned char *c_val)
/* sleeps that many milliseconds with a reschedule */
static void long_sleep(int ms)
{
- if (in_interrupt()) {
+ if (in_interrupt())
mdelay(ms);
- } else {
- __set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout((ms * HZ + 999) / 1000);
- }
+ else
+ schedule_timeout_interruptible(msecs_to_jiffies(ms));
}
/* send a serial byte to the LCD panel. The caller is responsible for locking
@@ -2250,22 +2248,28 @@ static void panel_detach(struct parport *port)
__func__, port->number, parport);
return;
}
+ if (scan_timer.function != NULL)
+ del_timer_sync(&scan_timer);
- unregister_reboot_notifier(&panel_notifier);
+ if (pprt != NULL) {
+ if (keypad.enabled) {
+ misc_deregister(&keypad_dev);
+ keypad_initialized = 0;
+ }
- if (keypad.enabled && keypad_initialized) {
- misc_deregister(&keypad_dev);
- keypad_initialized = 0;
- }
+ if (lcd.enabled) {
+ panel_lcd_print("\x0cLCD driver " PANEL_VERSION
+ "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
+ misc_deregister(&lcd_dev);
+ lcd.initialized = false;
+ }
- if (lcd.enabled && lcd.initialized) {
- misc_deregister(&lcd_dev);
- lcd.initialized = false;
+ /* TODO: free all input signals */
+ parport_release(pprt);
+ parport_unregister_device(pprt);
+ pprt = NULL;
+ unregister_reboot_notifier(&panel_notifier);
}
-
- parport_release(pprt);
- parport_unregister_device(pprt);
- pprt = NULL;
}
static struct parport_driver panel_driver = {
@@ -2398,28 +2402,6 @@ static int __init panel_init_module(void)
static void __exit panel_cleanup_module(void)
{
-
- if (scan_timer.function != NULL)
- del_timer_sync(&scan_timer);
-
- if (pprt != NULL) {
- if (keypad.enabled) {
- misc_deregister(&keypad_dev);
- keypad_initialized = 0;
- }
-
- if (lcd.enabled) {
- panel_lcd_print("\x0cLCD driver " PANEL_VERSION
- "\nunloaded.\x1b[Lc\x1b[Lb\x1b[L-");
- misc_deregister(&lcd_dev);
- lcd.initialized = false;
- }
-
- /* TODO: free all input signals */
- parport_release(pprt);
- parport_unregister_device(pprt);
- pprt = NULL;
- }
parport_unregister_driver(&panel_driver);
}
diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c
index e65ee6e858a8b1..2b09972d4cb5fb 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -19,6 +19,8 @@
******************************************************************************/
#define _RTW_AP_C_
+#include <linux/ieee80211.h>
+
#include <osdep_service.h>
#include <drv_types.h>
#include <wifi.h>
@@ -81,12 +83,14 @@ static void update_BCNTIM(struct adapter *padapter)
u8 *pbackup_remainder_ie = NULL;
uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;
- p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
+ p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen,
+ pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
if (p != NULL && tim_ielen > 0) {
tim_ielen += 2;
premainder_ie = p+tim_ielen;
tim_ie_offset = (int)(p - pie);
- remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen;
+ remainder_ielen = pnetwork_mlmeext->IELength -
+ tim_ie_offset - tim_ielen;
/* append TIM IE from dst_ie offset */
dst_ie = p;
} else {
@@ -97,7 +101,10 @@ static void update_BCNTIM(struct adapter *padapter)
offset += pnetwork_mlmeext->Ssid.SsidLength + 2;
/* get supported rates len */
- p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_));
+ p = rtw_get_ie(pie + _BEACON_IE_OFFSET_,
+ _SUPPORTEDRATES_IE_, &tmp_len,
+ (pnetwork_mlmeext->IELength -
+ _BEACON_IE_OFFSET_));
if (p != NULL)
offset += tmp_len+2;
@@ -106,7 +113,8 @@ static void update_BCNTIM(struct adapter *padapter)
premainder_ie = pie + offset;
- remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen;
+ remainder_ielen = pnetwork_mlmeext->IELength -
+ offset - tim_ielen;
/* append TIM IE from offset */
dst_ie = pie + offset;
@@ -115,11 +123,13 @@ static void update_BCNTIM(struct adapter *padapter)
if (remainder_ielen > 0) {
pbackup_remainder_ie = rtw_malloc(remainder_ielen);
if (pbackup_remainder_ie && premainder_ie)
- memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
+ memcpy(pbackup_remainder_ie,
+ premainder_ie, remainder_ielen);
}
*dst_ie++ = _TIM_IE_;
- if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc))
+ if ((pstapriv->tim_bitmap&0xff00) &&
+ (pstapriv->tim_bitmap&0x00fc))
tim_ielen = 5;
else
tim_ielen = 4;
@@ -154,7 +164,8 @@ static void update_BCNTIM(struct adapter *padapter)
set_tx_beacon_cmd(padapter);
}
-void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index, u8 *data, u8 len)
+void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork,
+ u8 index, u8 *data, u8 len)
{
struct ndis_802_11_var_ie *pIE;
u8 bmatch = false;
@@ -168,7 +179,8 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8
if (pIE->ElementID > index) {
break;
- } else if (pIE->ElementID == index) { /* already exist the same IE */
+ /* already exist the same IE */
+ } else if (pIE->ElementID == index) {
p = (u8 *)pIE;
ielen = pIE->Length;
bmatch = true;
@@ -197,7 +209,8 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8
if (remainder_ielen > 0) {
pbackup_remainder_ie = rtw_malloc(remainder_ielen);
if (pbackup_remainder_ie && premainder_ie)
- memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
+ memcpy(pbackup_remainder_ie,
+ premainder_ie, remainder_ielen);
}
*dst_ie++ = index;
@@ -217,7 +230,8 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8
pnetwork->IELength = offset + remainder_ielen;
}
-void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index)
+void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork,
+ u8 index)
{
u8 *p, *dst_ie = NULL, *premainder_ie = NULL;
u8 *pbackup_remainder_ie = NULL;
@@ -241,7 +255,8 @@ void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork,
if (remainder_ielen > 0) {
pbackup_remainder_ie = rtw_malloc(remainder_ielen);
if (pbackup_remainder_ie && premainder_ie)
- memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen);
+ memcpy(pbackup_remainder_ie,
+ premainder_ie, remainder_ielen);
}
/* copy remainder IE */
@@ -259,8 +274,10 @@ static u8 chk_sta_is_alive(struct sta_info *psta)
{
u8 ret = false;
- if ((psta->sta_stats.last_rx_data_pkts + psta->sta_stats.last_rx_ctrl_pkts) ==
- (psta->sta_stats.rx_data_pkts + psta->sta_stats.rx_ctrl_pkts))
+ if ((psta->sta_stats.last_rx_data_pkts +
+ psta->sta_stats.last_rx_ctrl_pkts) ==
+ (psta->sta_stats.rx_data_pkts +
+ psta->sta_stats.rx_ctrl_pkts))
;
else
ret = true;
@@ -342,13 +359,18 @@ void expire_timeout_chk(struct adapter *padapter)
if (psta->state & WIFI_SLEEP_STATE) {
if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) {
- /* to check if alive by another methods if station is at ps mode. */
+ /* to check if alive by another methods
+ * if station is at ps mode.
+ */
psta->expire_to = pstapriv->expire_to;
psta->state |= WIFI_STA_ALIVE_CHK_STATE;
- /* to update bcn with tim_bitmap for this station */
+ /* to update bcn with tim_bitmap
+ * for this station
+ */
pstapriv->tim_bitmap |= BIT(psta->aid);
- update_beacon(padapter, _TIM_IE_, NULL, false);
+ update_beacon(padapter, _TIM_IE_,
+ NULL, false);
if (!pmlmeext->active_keep_alive_check)
continue;
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
index be9e34a0daef83..0169a7d3e4c207 100644
--- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
+++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c
@@ -19,6 +19,8 @@
******************************************************************************/
#define _RTW_MLME_EXT_C_
+#include <linux/ieee80211.h>
+
#include <osdep_service.h>
#include <drv_types.h>
#include <wifi.h>
@@ -792,9 +794,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame)
/* Now, we are going to issue_auth... */
pstat->auth_seq = seq + 1;
-#ifdef CONFIG_88EU_AP_MODE
issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_));
-#endif
if (pstat->state & WIFI_FW_AUTH_SUCCESS)
pstat->auth_seq = 0;
@@ -811,11 +811,9 @@ auth_fail:
pstat->auth_seq = 2;
memcpy(pstat->hwaddr, sa, 6);
-#ifdef CONFIG_88EU_AP_MODE
issue_auth(padapter, pstat, (unsigned short)status);
-#endif
-#endif
+#endif /* CONFIG_88EU_AP_MODE */
return _FAIL;
}
@@ -1048,10 +1046,10 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame
pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher;
if (!pstat->wpa2_group_cipher)
- status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
+ status = WLAN_STATUS_INVALID_GROUP_CIPHER;
if (!pstat->wpa2_pairwise_cipher)
- status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
+ status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER;
} else {
status = WLAN_STATUS_INVALID_IE;
}
@@ -1069,10 +1067,10 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame
pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher;
if (!pstat->wpa_group_cipher)
- status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID;
+ status = WLAN_STATUS_INVALID_GROUP_CIPHER;
if (!pstat->wpa_pairwise_cipher)
- status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID;
+ status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER;
} else {
status = WLAN_STATUS_INVALID_IE;
}
@@ -1293,7 +1291,6 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame
/* now the station is qualified to join our BSS... */
if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) {
-#ifdef CONFIG_88EU_AP_MODE
/* 1 bss_cap_update & sta_info_update */
bss_cap_update_on_sta_join(padapter, pstat);
sta_info_update(padapter, pstat);
@@ -1310,30 +1307,23 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame
/* 3-(1) report sta add event */
report_add_sta_event(padapter, pstat->hwaddr, pstat->aid);
-#endif
}
return _SUCCESS;
asoc_class2_error:
-#ifdef CONFIG_88EU_AP_MODE
issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status);
-#endif
return _FAIL;
OnAssocReqFail:
-
-#ifdef CONFIG_88EU_AP_MODE
pstat->aid = 0;
if (frame_type == WIFI_ASSOCREQ)
issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP);
else
issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP);
-#endif
-
#endif /* CONFIG_88EU_AP_MODE */
diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c
index cda725a8f9cdf2..8501eb89882491 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -19,6 +19,8 @@
******************************************************************************/
#define _RTW_RECV_C_
+#include <linux/ieee80211.h>
+
#include <osdep_service.h>
#include <drv_types.h>
#include <recv_osdep.h>
diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
index dc9d0ddf6b3ae4..0b1cb03ab7b2a6 100644
--- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
+++ b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c
@@ -54,14 +54,12 @@ static void _rtw_init_stainfo(struct sta_info *psta)
psta->bpairwise_key_installed = false;
-#ifdef CONFIG_88EU_AP_MODE
psta->nonerp_set = 0;
psta->no_short_slot_time_set = 0;
psta->no_short_preamble_set = 0;
psta->no_ht_gf_set = 0;
psta->no_ht_set = 0;
psta->ht_20mhz_set = 0;
-#endif
psta->under_exist_checking = 0;
diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c
index 4bdbed28774ebd..5edb5c41c8e705 100644
--- a/drivers/staging/rtl8188eu/hal/hal_intf.c
+++ b/drivers/staging/rtl8188eu/hal/hal_intf.c
@@ -202,6 +202,7 @@ s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe)
s32 rtw_hal_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe)
{
s32 ret = _FAIL;
+
if (adapt->HalFunc.mgnt_xmit)
ret = adapt->HalFunc.mgnt_xmit(adapt, pmgntframe);
return ret;
@@ -236,6 +237,7 @@ void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level)
#ifdef CONFIG_88EU_AP_MODE
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &adapt->stapriv;
+
if ((mac_id-1) > 0)
psta = pstapriv->sta_aid[(mac_id-1) - 1];
if (psta)
diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h
index c81317906adcae..bcc74dcd82077c 100644
--- a/drivers/staging/rtl8188eu/include/drv_types.h
+++ b/drivers/staging/rtl8188eu/include/drv_types.h
@@ -175,7 +175,6 @@ static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj)
};
struct adapter {
- int pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */
u16 chip_type;
struct dvobj_priv *dvobj;
diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h
index 8fd35dcdbb94b2..b129ad148b4728 100644
--- a/drivers/staging/rtl8188eu/include/ieee80211.h
+++ b/drivers/staging/rtl8188eu/include/ieee80211.h
@@ -493,34 +493,7 @@ struct ieee80211_snap_hdr {
#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
-/* Status codes */
-#define WLAN_STATUS_SUCCESS 0
-#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
-#define WLAN_STATUS_CAPS_UNSUPPORTED 10
-#define WLAN_STATUS_REASSOC_NO_ASSOC 11
-#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
-#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
-#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
-#define WLAN_STATUS_CHALLENGE_FAIL 15
-#define WLAN_STATUS_AUTH_TIMEOUT 16
-#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
-#define WLAN_STATUS_ASSOC_DENIED_RATES 18
-/* 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
-
-/* Reason codes */
-#define WLAN_REASON_UNSPECIFIED 1
-#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
-#define WLAN_REASON_DEAUTH_LEAVING 3
-#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
-#define WLAN_REASON_DISASSOC_AP_BUSY 5
-#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
-#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
-#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
-#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
-#define WLAN_REASON_JOIN_WRONG_CHANNEL 65534
+/* Non standard? Not in <linux/ieee80211.h> */
#define WLAN_REASON_EXPIRATION_CHK 65535
/* Information Element IDs */
diff --git a/drivers/staging/rtl8188eu/include/osdep_intf.h b/drivers/staging/rtl8188eu/include/osdep_intf.h
index efa786887962fc..1521744d626cd2 100644
--- a/drivers/staging/rtl8188eu/include/osdep_intf.h
+++ b/drivers/staging/rtl8188eu/include/osdep_intf.h
@@ -31,7 +31,6 @@ u8 rtw_init_drv_sw(struct adapter *padapter);
u8 rtw_free_drv_sw(struct adapter *padapter);
u8 rtw_reset_drv_sw(struct adapter *padapter);
-u32 rtw_start_drv_threads(struct adapter *padapter);
void rtw_stop_drv_threads (struct adapter *padapter);
void rtw_cancel_all_timer(struct adapter *padapter);
@@ -40,7 +39,6 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname);
struct net_device *rtw_init_netdev(struct adapter *padapter);
u16 rtw_recv_select_queue(struct sk_buff *skb);
-void rtw_proc_init_one(struct net_device *dev);
void rtw_proc_remove_one(struct net_device *dev);
int pm_netdev_open(struct net_device *pnetdev, u8 bnormal);
diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h
index 515e949629e278..00472e0c00a057 100644
--- a/drivers/staging/rtl8188eu/include/osdep_service.h
+++ b/drivers/staging/rtl8188eu/include/osdep_service.h
@@ -157,8 +157,6 @@ void rtw_free_netdev(struct net_device *netdev);
#define FUNC_ADPT_FMT "%s(%s)"
#define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name
-#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)), (sig), 1)
-
u64 rtw_modular64(u64 x, u64 y);
/* Macros for handling unaligned memory accesses */
diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h
index 5aabd3984e5824..0809963ce6aa89 100644
--- a/drivers/staging/rtl8188eu/include/recv_osdep.h
+++ b/drivers/staging/rtl8188eu/include/recv_osdep.h
@@ -44,8 +44,5 @@ int rtw_os_recv_resource_alloc(struct adapter *adapt,
int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf);
void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl);
-int _netdev_open(struct net_device *pnetdev);
-int netdev_open(struct net_device *pnetdev);
-int netdev_close(struct net_device *pnetdev);
#endif /* */
diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
index b8c42eed98c4f3..5015748a9f4237 100644
--- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
+++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h
@@ -159,7 +159,7 @@ struct txpowerinfo24g {
/* | 1byte|----8bytes----|1byte|--5bytes--| */
/* | | Reserved(14bytes) | */
-/* PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte. */
+/* PG data exclude header, dummy 6 bytes from CP test and reserved 1byte. */
#define EFUSE_OOB_PROTECT_BYTES 15
#define HWSET_MAX_SIZE_88E 512
@@ -177,7 +177,7 @@ struct txpowerinfo24g {
/* 9bytes + 1byt + 5bytes and pre 1byte. */
/* For worst case: */
/* | 2byte|----8bytes----|1byte|--7bytes--| 92D */
-/* PG data exclude header, dummy 7 bytes frome CP test and reserved 1byte. */
+/* PG data exclude header, dummy 7 bytes from CP test and reserved 1byte. */
#define EFUSE_OOB_PROTECT_BYTES_88E 18
#define EFUSE_PROTECT_BYTES_BANK_88E 16
diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h b/drivers/staging/rtl8188eu/include/rtw_ap.h
index 92334015979887..6128ccce91ba54 100644
--- a/drivers/staging/rtl8188eu/include/rtw_ap.h
+++ b/drivers/staging/rtl8188eu/include/rtw_ap.h
@@ -47,7 +47,6 @@ void rtw_set_macaddr_acl(struct adapter *padapter, int mode);
int rtw_acl_add_sta(struct adapter *padapter, u8 *addr);
int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr);
-#ifdef CONFIG_88EU_AP_MODE
void associated_clients_update(struct adapter *padapter, u8 updated);
void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta);
u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta);
@@ -59,7 +58,6 @@ int rtw_sta_flush(struct adapter *padapter);
int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset);
void start_ap_mode(struct adapter *padapter);
void stop_ap_mode(struct adapter *padapter);
-#endif
#endif /* end of CONFIG_88EU_AP_MODE */
#endif
diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
index f3aa924f202913..ee2cb54a755235 100644
--- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h
+++ b/drivers/staging/rtl8188eu/include/rtw_ioctl.h
@@ -117,6 +117,4 @@ int drv_set_info(struct net_device *MiniportAdapterContext,
u32 informationbufferlength, u32 *bytesread,
u32 *bytesneeded);
-extern int ui_pid[3];
-
#endif /* #ifndef __INC_CEINFO_ */
diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h
index 3f7d1e631ef963..8c7e8a36aa13a3 100644
--- a/drivers/staging/rtl8188eu/include/rtw_mlme.h
+++ b/drivers/staging/rtl8188eu/include/rtw_mlme.h
@@ -65,7 +65,7 @@
#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR
enum dot11AuthAlgrthmNum {
- dot11AuthAlgrthm_Open = 0,
+ dot11AuthAlgrthm_Open = 0, /* open system */
dot11AuthAlgrthm_Shared,
dot11AuthAlgrthm_8021X,
dot11AuthAlgrthm_Auto,
diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h
index a89275e0e0e054..a08a2e045e594a 100644
--- a/drivers/staging/rtl8188eu/include/wifi.h
+++ b/drivers/staging/rtl8188eu/include/wifi.h
@@ -130,35 +130,6 @@ enum WIFI_REASON_CODE {
_RSON_TDLS_TEAR_UN_RSN_ = 26,
};
-/* Reason codes (IEEE 802.11-2007, 7.3.1.7, Table 7-22)
-
-#define WLAN_REASON_UNSPECIFIED 1
-#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
-#define WLAN_REASON_DEAUTH_LEAVING 3
-#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
-#define WLAN_REASON_DISASSOC_AP_BUSY 5
-#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
-#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
-#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
-#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 */
-/* IEEE 802.11h */
-#define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10
-#define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11
-
-/* IEEE 802.11i
-#define WLAN_REASON_INVALID_IE 13
-#define WLAN_REASON_MICHAEL_MIC_FAILURE 14
-#define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15
-#define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16
-#define WLAN_REASON_IE_IN_4WAY_DIFFERS 17
-#define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18
-#define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19
-#define WLAN_REASON_AKMP_NOT_VALID 20
-#define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21
-#define WLAN_REASON_INVALID_RSN_IE_CAPAB 22
-#define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23
-#define WLAN_REASON_CIPHER_SUITE_REJECTED 24 */
-
enum WIFI_STATUS_CODE {
_STATS_SUCCESSFUL_ = 0,
_STATS_FAILURE_ = 1,
@@ -173,54 +144,6 @@ enum WIFI_STATUS_CODE {
_STATS_RATE_FAIL_ = 18,
};
-/* Status codes (IEEE 802.11-2007, 7.3.1.9, Table 7-23)
-#define WLAN_STATUS_SUCCESS 0
-#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
-#define WLAN_STATUS_CAPS_UNSUPPORTED 10
-#define WLAN_STATUS_REASSOC_NO_ASSOC 11
-#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
-#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
-#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
-#define WLAN_STATUS_CHALLENGE_FAIL 15
-#define WLAN_STATUS_AUTH_TIMEOUT 16
-#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
-#define WLAN_STATUS_ASSOC_DENIED_RATES 18 */
-
-/* entended */
-/* IEEE 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
-/* IEEE 802.11h */
-#define WLAN_STATUS_SPEC_MGMT_REQUIRED 22
-#define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23
-#define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24
-/* IEEE 802.11g */
-#define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25
-#define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26
-#define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27
-/* IEEE 802.11w */
-#define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30
-#define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31
-/* IEEE 802.11i */
-#define WLAN_STATUS_INVALID_IE 40
-#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41
-#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42
-#define WLAN_STATUS_AKMP_NOT_VALID 43
-#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44
-#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45
-#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46
-#define WLAN_STATUS_TS_NOT_CREATED 47
-#define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48
-#define WLAN_STATUS_DEST_STA_NOT_PRESENT 49
-#define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50
-#define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51
-/* IEEE 802.11r */
-#define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52
-#define WLAN_STATUS_INVALID_PMKID 53
-#define WLAN_STATUS_INVALID_MDIE 54
-#define WLAN_STATUS_INVALID_FTIE 55
-
enum WIFI_REG_DOMAIN {
DOMAIN_FCC = 1,
DOMAIN_IC = 2,
diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
index 96c1c2d4a112c2..38dba1435c1ee2 100644
--- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c
@@ -19,6 +19,8 @@
******************************************************************************/
#define _IOCTL_LINUX_C_
+#include <linux/ieee80211.h>
+
#include <osdep_service.h>
#include <drv_types.h>
#include <wlan_bssdef.h>
@@ -1625,7 +1627,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
- padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
+ padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
authmode = Ndis802_11AuthModeOpen;
padapter->securitypriv.ndisauthtype = authmode;
@@ -1664,7 +1666,7 @@ static int rtw_wx_set_enc(struct net_device *dev,
DBG_88E("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags);
padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */
- padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
+ padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
authmode = Ndis802_11AuthModeOpen;
@@ -1855,7 +1857,7 @@ static int rtw_wx_set_auth(struct net_device *dev,
padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled;
padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_;
padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_;
- padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
+ padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
}
diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
index baff1e2661d55b..218adaa574b58f 100644
--- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
+++ b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c
@@ -41,8 +41,6 @@ void rtw_os_indicate_connect(struct adapter *adapter)
{
rtw_indicate_wx_assoc_event(adapter);
netif_carrier_on(adapter->pnetdev);
- if (adapter->pid[2] != 0)
- rtw_signal_process(adapter->pid[2], SIGALRM);
}
void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted)
@@ -82,7 +80,7 @@ void rtw_reset_securitypriv(struct adapter *adapter)
/* reset values in securitypriv */
struct security_priv *psec_priv = &adapter->securitypriv;
- psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
+ psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
psec_priv->dot11PrivacyKeyIndex = 0;
psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_;
diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
index 750c87b46365bd..2e96234cd2534f 100644
--- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8188eu/os_dep/os_intfs.c
@@ -41,7 +41,8 @@ MODULE_VERSION(DRIVERVERSION);
static int rtw_chip_version;
static int rtw_rfintfs = HWPI;
static int rtw_lbkmode;/* RTL8712_AIR_TRX; */
-static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; infra, ad-hoc, auto */
+/* Ndis802_11Infrastructure; infra, ad-hoc, auto */
+static int rtw_network_mode = Ndis802_11IBSS;
static int rtw_channel = 1;/* ad-hoc support requirement */
static int rtw_wireless_mode = WIRELESS_11BG_24N;
static int rtw_vrtl_carrier_sense = AUTO_VCS;
@@ -81,21 +82,37 @@ static int rtw_uapsd_acvi_en;
static int rtw_uapsd_acvo_en;
static int rtw_ht_enable = 1;
-static int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */
+/* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */
+static int rtw_cbw40_enable = 3;
static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */
-static int rtw_rx_stbc = 1;/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */
+
+/* 0: disable
+ * bit(0):enable 2.4g
+ * bit(1):enable 5g
+ * default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ
+ */
+static int rtw_rx_stbc = 1;
static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */
-static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and legacy mode */
+/* Use 2 path Tx to transmit MCS0~7 and legacy mode */
+static int rtw_lowrate_two_xmit = 1;
static int rtw_rf_config = RF_819X_MAX_TYPE; /* auto */
static int rtw_low_power;
static int rtw_wifi_spec;
static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX;
-static int rtw_AcceptAddbaReq = true;/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */
+/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */
+static int rtw_AcceptAddbaReq = true;
static int rtw_antdiv_cfg = 2; /* 0:OFF , 1:ON, 2:decide by Efuse config */
-static int rtw_antdiv_type; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */
+
+/* 0: decide by efuse
+ * 1: for 88EE, 1Tx and 1RxCG are diversity (2 Ant with SPDT)
+ * 2: for 88EE, 1Tx and 2Rx are diversity (2 Ant, Tx and RxCG are both on aux
+ * port, RxCS is on main port)
+ * 3: for 88EE, 1Tx and 1RxCG are fixed (1Ant, Tx and RxCG are both on aux port)
+ */
+static int rtw_antdiv_type;
static int rtw_enusbss;/* 0:disable, 1:enable */
@@ -117,7 +134,8 @@ static char *if2name = "wlan%d";
module_param(if2name, charp, 0644);
MODULE_PARM_DESC(if2name, "The default name to allocate for second interface");
-char *rtw_initmac; /* temp mac address if users want to use instead of the mac address in Efuse */
+/* temp mac address if users want to use instead of the mac address in Efuse */
+char *rtw_initmac;
module_param(rtw_initmac, charp, 0644);
module_param(rtw_channel_plan, int, 0644);
@@ -167,17 +185,20 @@ MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P")
module_param_named(debug, rtw_debug, int, 0444);
MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)");
+static int netdev_open(struct net_device *pnetdev);
+static int netdev_close(struct net_device *pnetdev);
+
/* dummy routines */
void rtw_proc_remove_one(struct net_device *dev)
{
}
-void rtw_proc_init_one(struct net_device *dev)
+static void rtw_proc_init_one(struct net_device *dev)
{
}
#if 0 /* TODO: Convert these to /sys */
-void rtw_proc_init_one(struct net_device *dev)
+static void rtw_proc_init_one(struct net_device *dev)
{
struct proc_dir_entry *dir_dev = NULL;
struct proc_dir_entry *entry = NULL;
@@ -187,13 +208,16 @@ void rtw_proc_init_one(struct net_device *dev)
if (rtw_proc == NULL) {
memcpy(rtw_proc_name, DRV_NAME, sizeof(DRV_NAME));
- rtw_proc = create_proc_entry(rtw_proc_name, S_IFDIR, init_net.proc_net);
+ rtw_proc = create_proc_entry(rtw_proc_name, S_IFDIR,
+ init_net.proc_net);
if (rtw_proc == NULL) {
DBG_88E(KERN_ERR "Unable to create rtw_proc directory\n");
return;
}
- entry = create_proc_read_entry("ver_info", S_IFREG | S_IRUGO, rtw_proc, proc_get_drv_version, dev);
+ entry = create_proc_read_entry("ver_info", S_IFREG | S_IRUGO,
+ rtw_proc, proc_get_drv_version,
+ dev);
if (!entry) {
pr_info("Unable to create_proc_read_entry!\n");
return;
@@ -206,11 +230,9 @@ void rtw_proc_init_one(struct net_device *dev)
rtw_proc);
dir_dev = padapter->dir_dev;
if (dir_dev == NULL) {
- if (rtw_proc_cnt == 0) {
- if (rtw_proc) {
- remove_proc_entry(rtw_proc_name, init_net.proc_net);
- rtw_proc = NULL;
- }
+ if (rtw_proc_cnt == 0 && rtw_proc) {
+ remove_proc_entry(rtw_proc_name, init_net.proc_net);
+ rtw_proc = NULL;
}
pr_info("Unable to create dir_dev directory\n");
@@ -360,15 +382,17 @@ void rtw_proc_init_one(struct net_device *dev)
rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type));
if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) {
- entry = create_proc_read_entry("rf_reg_dump3", S_IFREG | S_IRUGO,
- dir_dev, proc_get_rf_reg_dump3, dev);
+ entry = create_proc_read_entry("rf_reg_dump3",
+ S_IFREG | S_IRUGO, dir_dev,
+ proc_get_rf_reg_dump3, dev);
if (!entry) {
pr_info("Unable to create_proc_read_entry!\n");
return;
}
- entry = create_proc_read_entry("rf_reg_dump4", S_IFREG | S_IRUGO,
- dir_dev, proc_get_rf_reg_dump4, dev);
+ entry = create_proc_read_entry("rf_reg_dump4",
+ S_IFREG | S_IRUGO, dir_dev,
+ proc_get_rf_reg_dump4, dev);
if (!entry) {
pr_info("Unable to create_proc_read_entry!\n");
return;
@@ -510,11 +534,10 @@ void rtw_proc_remove_one(struct net_device *dev)
}
#endif
-static uint loadparam(struct adapter *padapter, struct net_device *pnetdev)
+static void loadparam(struct adapter *padapter, struct net_device *pnetdev)
{
struct registry_priv *registry_par = &padapter->registrypriv;
-
GlobalDebugLevel = rtw_debug;
registry_par->chip_version = (u8)rtw_chip_version;
registry_par->rfintfs = (u8)rtw_rfintfs;
@@ -569,8 +592,8 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev)
registry_par->bAcceptAddbaReq = (u8)rtw_AcceptAddbaReq;
registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg;
registry_par->antdiv_type = (u8)rtw_antdiv_type;
- registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode;/* 0:disable, 1:enable, 2:by EFUSE config */
- registry_par->hwpwrp_detect = (u8)rtw_hwpwrp_detect;/* 0:disable, 1:enable */
+ registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode;
+ registry_par->hwpwrp_detect = (u8)rtw_hwpwrp_detect;
registry_par->hw_wps_pbc = (u8)rtw_hw_wps_pbc;
registry_par->max_roaming_times = (u8)rtw_max_roaming_times;
@@ -581,7 +604,6 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev)
snprintf(registry_par->ifname, 16, "%s", ifname);
snprintf(registry_par->if2name, 16, "%s", if2name);
registry_par->notch_filter = (u8)rtw_notch_filter;
- return _SUCCESS;
}
static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
@@ -601,8 +623,8 @@ static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev)
struct xmit_priv *pxmitpriv = &(padapter->xmitpriv);
struct recv_priv *precvpriv = &(padapter->recvpriv);
- padapter->stats.tx_packets = pxmitpriv->tx_pkts;/* pxmitpriv->tx_pkts++; */
- padapter->stats.rx_packets = precvpriv->rx_pkts;/* precvpriv->rx_pkts++; */
+ padapter->stats.tx_packets = pxmitpriv->tx_pkts;
+ padapter->stats.rx_packets = precvpriv->rx_pkts;
padapter->stats.tx_dropped = pxmitpriv->tx_drop;
padapter->stats.rx_dropped = precvpriv->rx_drop;
padapter->stats.tx_bytes = pxmitpriv->tx_bytes;
@@ -725,25 +747,26 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter)
pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */
pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def;
- /* step 2. */
loadparam(padapter, pnetdev);
return pnetdev;
}
-u32 rtw_start_drv_threads(struct adapter *padapter)
+static int rtw_start_drv_threads(struct adapter *padapter)
{
- u32 _status = _SUCCESS;
+ int err = 0;
RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n"));
- padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD");
+ padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter,
+ "RTW_CMD_THREAD");
if (IS_ERR(padapter->cmdThread))
- _status = _FAIL;
+ err = PTR_ERR(padapter->cmdThread);
else
- _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */
+ /* wait for cmd_thread to run */
+ _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema);
- return _status;
+ return err;
}
void rtw_stop_drv_threads(struct adapter *padapter)
@@ -781,7 +804,7 @@ static u8 rtw_init_default_value(struct adapter *padapter)
psecuritypriv->binstallGrpkey = _FAIL;
psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt;
psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt;
- psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
+ psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open;
psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
psecuritypriv->dot11PrivacyKeyIndex = 0;
psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_;
@@ -931,7 +954,8 @@ u8 rtw_free_drv_sw(struct adapter *padapter)
rtw_free_mlme_priv(&padapter->mlmepriv);
_rtw_free_xmit_priv(&padapter->xmitpriv);
- _rtw_free_sta_priv(&padapter->stapriv); /* will free bcmc_stainfo here */
+ /* will free bcmc_stainfo here */
+ _rtw_free_sta_priv(&padapter->stapriv);
_rtw_free_recv_priv(&padapter->recvpriv);
@@ -952,9 +976,10 @@ u8 rtw_free_drv_sw(struct adapter *padapter)
return _SUCCESS;
}
-int _netdev_open(struct net_device *pnetdev)
+static int _netdev_open(struct net_device *pnetdev)
{
uint status;
+ int err;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv;
@@ -978,8 +1003,8 @@ int _netdev_open(struct net_device *pnetdev)
pr_info("MAC Address = %pM\n", pnetdev->dev_addr);
- status = rtw_start_drv_threads(padapter);
- if (status == _FAIL) {
+ err = rtw_start_drv_threads(padapter);
+ if (err) {
pr_info("Initialize driver software resource Failed!\n");
goto netdev_open_error;
}
@@ -1023,7 +1048,7 @@ netdev_open_error:
return -1;
}
-int netdev_open(struct net_device *pnetdev)
+static int netdev_open(struct net_device *pnetdev)
{
int ret;
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
@@ -1037,6 +1062,7 @@ int netdev_open(struct net_device *pnetdev)
static int ips_netdrv_open(struct adapter *padapter)
{
int status = _SUCCESS;
+
padapter->net_closed = false;
DBG_88E("===> %s.........\n", __func__);
@@ -1069,6 +1095,7 @@ int rtw_ips_pwr_up(struct adapter *padapter)
{
int result;
u32 start_time = jiffies;
+
DBG_88E("===> rtw_ips_pwr_up..............\n");
rtw_reset_drv_sw(padapter);
@@ -1083,6 +1110,7 @@ int rtw_ips_pwr_up(struct adapter *padapter)
void rtw_ips_pwr_down(struct adapter *padapter)
{
u32 start_time = jiffies;
+
DBG_88E("===> rtw_ips_pwr_down...................\n");
padapter->net_closed = true;
@@ -1118,7 +1146,7 @@ int pm_netdev_open(struct net_device *pnetdev, u8 bnormal)
return status;
}
-int netdev_close(struct net_device *pnetdev)
+static int netdev_close(struct net_device *pnetdev)
{
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
struct hal_data_8188e *rtlhal = GET_HAL_DATA(padapter);
diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
index ef3c73e3817258..d0d4335b444c3e 100644
--- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c
+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c
@@ -32,8 +32,6 @@
#include <usb_hal.h>
#include <rtw_ioctl.h>
-int ui_pid[3] = {0, 0, 0};
-
#define USB_VENDER_ID_REALTEK 0x0bda
/* DID_USB_v916_20130116 */
@@ -330,11 +328,6 @@ static int rtw_resume_process(struct adapter *padapter)
_exit_pwrlock(&pwrpriv->lock);
- if (padapter->pid[1] != 0) {
- DBG_88E("pid[1]:%d\n", padapter->pid[1]);
- rtw_signal_process(padapter->pid[1], SIGUSR2);
- }
-
rtw_roaming(padapter, NULL);
ret = 0;
@@ -511,11 +504,6 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device
goto free_dvobj;
}
- if (ui_pid[1] != 0) {
- DBG_88E("ui_pid[1]:%d\n", ui_pid[1]);
- rtw_signal_process(ui_pid[1], SIGUSR2);
- }
-
RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-871x_drv - drv_init, success!\n"));
status = _SUCCESS;
diff --git a/drivers/staging/rtl8192e/dot11d.h b/drivers/staging/rtl8192e/dot11d.h
index aad3394392fee2..69e0f8f7e3f8b3 100644
--- a/drivers/staging/rtl8192e/dot11d.h
+++ b/drivers/staging/rtl8192e/dot11d.h
@@ -74,8 +74,8 @@ static inline void cpMacAddr(unsigned char *des, unsigned char *src)
(GET_DOT11D_INFO(__pIeeeDev)->CountryIeLen > 0)
#define IS_EQUAL_CIE_SRC(__pIeeeDev, __pTa) \
- ether_addr_equal_unaligned(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, \
- __pTa)
+ ether_addr_equal_unaligned( \
+ GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
#define UPDATE_CIE_SRC(__pIeeeDev, __pTa) \
cpMacAddr(GET_DOT11D_INFO(__pIeeeDev)->CountryIeSrcAddr, __pTa)
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
index 01d2201afc94da..facc6f1f302bf2 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8190P_rtl8256.c
@@ -47,8 +47,8 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev,
0x0e, bMask12Bits, 0x021);
} else {
- RT_TRACE(COMP_ERR,
- "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
+ netdev_warn(dev, "%s(): Unknown HW version.\n",
+ __func__);
}
break;
@@ -66,16 +66,15 @@ void PHY_SetRF8256Bandwidth(struct net_device *dev,
0x0e, bMask12Bits, 0x0e1);
} else {
- RT_TRACE(COMP_ERR,
- "PHY_SetRF8256Bandwidth(): unknown hardware version\n");
+ netdev_warn(dev, "%s(): Unknown HW version.\n",
+ __func__);
}
break;
default:
- RT_TRACE(COMP_ERR,
- "PHY_SetRF8256Bandwidth(): unknown Bandwidth: %#X\n",
- Bandwidth);
+ netdev_err(dev, "%s(): Unknown bandwidth: %#X\n",
+ __func__, Bandwidth);
break;
}
@@ -139,9 +138,8 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
rtStatus = rtl8192_phy_checkBBAndRF(dev, HW90_BLOCK_RF,
(enum rf90_radio_path)eRFPath);
if (!rtStatus) {
- RT_TRACE(COMP_ERR,
- "PHY_RF8256_Config():Check Radio[%d] Fail!!\n",
- eRFPath);
+ netdev_err(dev, "%s(): Failed to check RF Path %d.\n",
+ __func__, eRFPath);
goto phy_RF8256_Config_ParaFile_Fail;
}
@@ -227,9 +225,9 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
}
if (ret) {
- RT_TRACE(COMP_ERR,
- "phy_RF8256_Config_ParaFile():Radio[%d] Fail!!",
- eRFPath);
+ netdev_err(dev,
+ "%s(): Failed to initialize RF Path %d.\n",
+ __func__, eRFPath);
goto phy_RF8256_Config_ParaFile_Fail;
}
@@ -239,7 +237,6 @@ bool phy_RF8256_Config_ParaFile(struct net_device *dev)
return true;
phy_RF8256_Config_ParaFile_Fail:
- RT_TRACE(COMP_ERR, "PHY Initialization failed\n");
return false;
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
index 2869602436ef15..b5e4d35ee6d4a8 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c
@@ -30,7 +30,8 @@
#include "rtl_dm.h"
#include "rtl_wx.h"
-static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO};
+static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI,
+ EDCAPARA_VO};
void rtl8192e_start_beacon(struct net_device *dev)
{
@@ -187,22 +188,21 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val)
u8 u1bAIFS;
u32 u4bAcParam;
u8 mode = priv->rtllib->mode;
- struct rtllib_qos_parameters *qos_parameters =
+ struct rtllib_qos_parameters *qop =
&priv->rtllib->current_network.qos_data.parameters;
- u1bAIFS = qos_parameters->aifs[pAcParam] *
+ u1bAIFS = qop->aifs[pAcParam] *
((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime;
dm_init_edca_turbo(dev);
- u4bAcParam = (((le16_to_cpu(
- qos_parameters->tx_op_limit[pAcParam])) <<
- AC_PARAM_TXOP_LIMIT_OFFSET) |
- ((le16_to_cpu(qos_parameters->cw_max[pAcParam])) <<
- AC_PARAM_ECW_MAX_OFFSET) |
- ((le16_to_cpu(qos_parameters->cw_min[pAcParam])) <<
- AC_PARAM_ECW_MIN_OFFSET) |
- (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET));
+ u4bAcParam = (le16_to_cpu(qop->tx_op_limit[pAcParam]) <<
+ AC_PARAM_TXOP_LIMIT_OFFSET) |
+ ((le16_to_cpu(qop->cw_max[pAcParam])) <<
+ AC_PARAM_ECW_MAX_OFFSET) |
+ ((le16_to_cpu(qop->cw_min[pAcParam])) <<
+ AC_PARAM_ECW_MIN_OFFSET) |
+ (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET);
RT_TRACE(COMP_DBG, "%s():HW_VAR_AC_PARAM eACI:%x:%x\n",
__func__, eACI, u4bAcParam);
@@ -316,19 +316,18 @@ void rtl8192e_SetHwReg(struct net_device *dev, u8 variable, u8 *val)
static void rtl8192_read_eeprom_info(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
-
+ const u8 bMac_Tmp_Addr[ETH_ALEN] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01};
u8 tempval;
u8 ICVer8192, ICVer8256;
u16 i, usValue, IC_Version;
u16 EEPROMId;
- u8 bMac_Tmp_Addr[6] = {0x00, 0xe0, 0x4c, 0x00, 0x00, 0x01};
RT_TRACE(COMP_INIT, "====> rtl8192_read_eeprom_info\n");
EEPROMId = eprom_read(dev, 0);
if (EEPROMId != RTL8190_EEPROM_ID) {
- RT_TRACE(COMP_ERR, "EEPROM ID is invalid:%x, %x\n",
- EEPROMId, RTL8190_EEPROM_ID);
+ netdev_err(dev, "%s(): Invalid EEPROM ID: %x\n", __func__,
+ EEPROMId);
priv->AutoloadFailFlag = true;
} else {
priv->AutoloadFailFlag = false;
@@ -383,7 +382,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev)
*(u16 *)(&dev->dev_addr[i]) = usValue;
}
} else {
- memcpy(dev->dev_addr, bMac_Tmp_Addr, 6);
+ ether_addr_copy(dev->dev_addr, bMac_Tmp_Addr);
}
RT_TRACE(COMP_INIT, "Permanent Address = %pM\n",
@@ -737,9 +736,8 @@ start:
else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY)
ulRegRead |= CPU_GEN_FIRMWARE_RESET;
else
- RT_TRACE(COMP_ERR,
- "ERROR in %s(): undefined firmware state(%d)\n",
- __func__, priv->pFirmware->firmware_status);
+ netdev_err(dev, "%s(): undefined firmware state: %d.\n",
+ __func__, priv->pFirmware->firmware_status);
write_nic_dword(dev, CPU_GEN, ulRegRead);
@@ -755,7 +753,7 @@ start:
RT_TRACE(COMP_INIT, "BB Config Start!\n");
rtStatus = rtl8192_BBConfig(dev);
if (!rtStatus) {
- RT_TRACE(COMP_ERR, "BB Config failed\n");
+ netdev_warn(dev, "%s(): Failed to configure BB\n", __func__);
return rtStatus;
}
RT_TRACE(COMP_INIT, "BB Config Finished!\n");
@@ -769,8 +767,8 @@ start:
else if (priv->LoopbackMode == RTL819X_MAC_LOOPBACK)
ulRegRead |= CPU_CCK_LOOPBACK;
else
- RT_TRACE(COMP_ERR,
- "Serious error: wrong loopback mode setting\n");
+ netdev_err(dev, "%s: Invalid loopback mode setting.\n",
+ __func__);
write_nic_dword(dev, CPU_GEN, ulRegRead);
@@ -868,7 +866,7 @@ start:
RT_TRACE(COMP_INIT, "RF Config Started!\n");
rtStatus = rtl8192_phy_RFConfig(dev);
if (!rtStatus) {
- RT_TRACE(COMP_ERR, "RF Config failed\n");
+ netdev_info(dev, "RF Config failed\n");
return rtStatus;
}
RT_TRACE(COMP_INIT, "RF Config Finished!\n");
@@ -918,8 +916,7 @@ start:
tmpRegC = rtl8192_QueryBBReg(dev,
rOFDM0_XCTxIQImbalance, bMaskDWord);
for (i = 0; i < TxBBGainTableLength; i++) {
- if (tmpRegA ==
- priv->txbbgain_table[i].txbbgain_value) {
+ if (tmpRegA == dm_tx_bb_gain[i]) {
priv->rfa_txpowertrackingindex = (u8)i;
priv->rfa_txpowertrackingindex_real =
(u8)i;
@@ -933,7 +930,7 @@ start:
rCCK0_TxFilter1, bMaskByte2);
for (i = 0; i < CCKTxBBGainTableLength; i++) {
- if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) {
+ if (TempCCk == dm_cck_tx_bb_gain[i][0]) {
priv->CCKPresentAttentuation_20Mdefault = (u8)i;
break;
}
@@ -1139,7 +1136,8 @@ static u8 MRateToHwRate8190Pci(u8 rate)
return ret;
}
-static u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority)
+static u8 rtl8192_MapHwQueueToFirmwareQueue(struct net_device *dev, u8 QueueID,
+ u8 priority)
{
u8 QueueSelect = 0x0;
@@ -1172,9 +1170,8 @@ static u8 rtl8192_MapHwQueueToFirmwareQueue(u8 QueueID, u8 priority)
QueueSelect = QSLT_HIGH;
break;
default:
- RT_TRACE(COMP_ERR,
- "TransmitTCB(): Impossible Queue Selection: %d\n",
- QueueID);
+ netdev_warn(dev, "%s(): Impossible Queue Selection: %d\n",
+ __func__, QueueID);
break;
}
return QueueSelect;
@@ -1198,7 +1195,7 @@ void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc,
cb_desc);
if (pci_dma_mapping_error(priv->pdev, mapping))
- RT_TRACE(COMP_ERR, "DMA Mapping error\n");
+ netdev_err(dev, "%s(): DMA Mapping error\n", __func__);
if (cb_desc->bAMPDUEnable) {
pTxFwInfo->AllowAggregation = 1;
pTxFwInfo->RxMF = cb_desc->ampdu_factor;
@@ -1274,7 +1271,7 @@ void rtl8192_tx_fill_desc(struct net_device *dev, struct tx_desc *pdesc,
pdesc->PktId = 0x0;
- pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue(
+ pdesc->QueueSelect = rtl8192_MapHwQueueToFirmwareQueue(dev,
cb_desc->queue_index,
cb_desc->priority);
pdesc->TxFWInfoSize = sizeof(struct tx_fwinfo_8190pci);
@@ -1298,7 +1295,7 @@ void rtl8192_tx_fill_cmd_desc(struct net_device *dev,
PCI_DMA_TODEVICE);
if (pci_dma_mapping_error(priv->pdev, mapping))
- RT_TRACE(COMP_ERR, "DMA Mapping error\n");
+ netdev_err(dev, "%s(): DMA Mapping error\n", __func__);
memset(entry, 0, 12);
entry->LINIP = cb_desc->bLastIniPkt;
entry->FirstSeg = 1;
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
index c465f8749acda2..17d2a1540cc8b3 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_firmware.c
@@ -116,7 +116,7 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
}
if (!(CPU_status&CPU_GEN_PUT_CODE_OK)) {
- RT_TRACE(COMP_ERR, "Download Firmware: Put code fail!\n");
+ netdev_err(dev, "Firmware download failed.\n");
goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
} else {
RT_TRACE(COMP_FIRMWARE, "Download Firmware: Put code ok!\n");
@@ -135,15 +135,16 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev)
mdelay(2);
}
- if (!(CPU_status&CPU_GEN_BOOT_RDY))
+ if (!(CPU_status&CPU_GEN_BOOT_RDY)) {
+ netdev_err(dev, "Firmware boot failed.\n");
goto CPUCheckMainCodeOKAndTurnOnCPU_Fail;
- else
- RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n");
+ }
+
+ RT_TRACE(COMP_FIRMWARE, "Download Firmware: Boot ready!\n");
return rt_status;
CPUCheckMainCodeOKAndTurnOnCPU_Fail:
- RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
rt_status = false;
return rt_status;
}
@@ -171,7 +172,6 @@ static bool CPUcheck_firmware_ready(struct net_device *dev)
return rt_status;
CPUCheckFirmwareReady_Fail:
- RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
rt_status = false;
return rt_status;
@@ -230,7 +230,7 @@ bool init_firmware(struct net_device *dev)
u32 file_length = 0;
u8 *mapped_file = NULL;
- u8 init_step = 0;
+ u8 i = 0;
enum opt_rst_type rst_opt = OPT_SYSTEM_RESET;
enum firmware_init_step starting_state = FW_INIT_STEP0_BOOT;
@@ -250,10 +250,9 @@ bool init_firmware(struct net_device *dev)
"PlatformInitFirmware: undefined firmware state\n");
}
- for (init_step = starting_state; init_step <= FW_INIT_STEP2_DATA;
- init_step++) {
+ for (i = starting_state; i <= FW_INIT_STEP2_DATA; i++) {
if (rst_opt == OPT_SYSTEM_RESET) {
- if (pfirmware->firmware_buf_size[init_step] == 0) {
+ if (pfirmware->firmware_buf_size[i] == 0) {
const char *fw_name[3] = {
RTL8192E_BOOT_IMG_FW,
RTL8192E_MAIN_IMG_FW,
@@ -263,7 +262,7 @@ bool init_firmware(struct net_device *dev)
int rc;
rc = request_firmware(&fw_entry,
- fw_name[init_step],
+ fw_name[i],
&priv->pdev->dev);
if (rc < 0) {
RT_TRACE(COMP_FIRMWARE,
@@ -271,24 +270,24 @@ bool init_firmware(struct net_device *dev)
goto download_firmware_fail;
}
if (fw_entry->size >
- sizeof(pfirmware->firmware_buf[init_step])) {
+ sizeof(pfirmware->firmware_buf[i])) {
RT_TRACE(COMP_FIRMWARE,
"img file size exceed the container struct buffer fail!\n");
goto download_firmware_fail;
}
- if (init_step != FW_INIT_STEP1_MAIN) {
- memcpy(pfirmware->firmware_buf[init_step],
+ if (i != FW_INIT_STEP1_MAIN) {
+ memcpy(pfirmware->firmware_buf[i],
fw_entry->data, fw_entry->size);
- pfirmware->firmware_buf_size[init_step] =
+ pfirmware->firmware_buf_size[i] =
fw_entry->size;
} else {
- memset(pfirmware->firmware_buf[init_step],
+ memset(pfirmware->firmware_buf[i],
0, 128);
- memcpy(&pfirmware->firmware_buf[init_step][128],
+ memcpy(&pfirmware->firmware_buf[i][128],
fw_entry->data, fw_entry->size);
- pfirmware->firmware_buf_size[init_step] =
+ pfirmware->firmware_buf_size[i] =
fw_entry->size + 128;
}
@@ -297,14 +296,14 @@ bool init_firmware(struct net_device *dev)
}
}
- mapped_file = pfirmware->firmware_buf[init_step];
- file_length = pfirmware->firmware_buf_size[init_step];
+ mapped_file = pfirmware->firmware_buf[i];
+ file_length = pfirmware->firmware_buf_size[i];
rt_status = fw_download_code(dev, mapped_file, file_length);
if (!rt_status)
goto download_firmware_fail;
- if (!firmware_check_ready(dev, init_step))
+ if (!firmware_check_ready(dev, i))
goto download_firmware_fail;
}
@@ -312,7 +311,7 @@ bool init_firmware(struct net_device *dev)
return rt_status;
download_firmware_fail:
- RT_TRACE(COMP_ERR, "ERR in %s()\n", __func__);
+ netdev_err(dev, "%s: Failed to initialize firmware.\n", __func__);
rt_status = false;
return rt_status;
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
index 4664a4fd1e48cd..fba7654160e807 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c
@@ -504,13 +504,15 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev,
WriteAddr[HW90_BLOCK_RF] = 0x3;
RT_TRACE(COMP_PHY, "=======>%s(), CheckBlock:%d\n", __func__,
CheckBlock);
+
+ if (CheckBlock == HW90_BLOCK_MAC) {
+ netdev_warn(dev, "%s(): No checks available for MAC block.\n",
+ __func__);
+ return ret;
+ }
+
for (i = 0; i < CheckTimes; i++) {
switch (CheckBlock) {
- case HW90_BLOCK_MAC:
- RT_TRACE(COMP_ERR,
- "PHY_CheckBBRFOK(): Never Write 0x100 here!");
- break;
-
case HW90_BLOCK_PHY0:
case HW90_BLOCK_PHY1:
write_nic_dword(dev, WriteAddr[CheckBlock],
@@ -537,9 +539,7 @@ bool rtl8192_phy_checkBBAndRF(struct net_device *dev,
if (dwRegRead != WriteData[i]) {
- RT_TRACE(COMP_ERR,
- "====>error=====dwRegRead: %x, WriteData: %x\n",
- dwRegRead, WriteData[i]);
+ netdev_warn(dev, "%s(): Check failed.\n", __func__);
ret = false;
break;
}
@@ -628,8 +628,8 @@ void rtl8192_phy_getTxPower(struct net_device *dev)
priv->DefaultInitialGain[3] = read_nic_byte(dev, rOFDM0_XDAGCCore1);
RT_TRACE(COMP_INIT,
"Default initial gain (c50=0x%x, c58=0x%x, c60=0x%x, c68=0x%x)\n",
- priv->DefaultInitialGain[0], priv->DefaultInitialGain[1],
- priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]);
+ priv->DefaultInitialGain[0], priv->DefaultInitialGain[1],
+ priv->DefaultInitialGain[2], priv->DefaultInitialGain[3]);
priv->framesync = read_nic_byte(dev, rOFDM0_RxDetector3);
priv->framesyncC34 = read_nic_dword(dev, rOFDM0_RxDetector2);
@@ -685,8 +685,7 @@ void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel)
case RF_8258:
break;
default:
- RT_TRACE(COMP_ERR, "unknown rf chip in function %s()\n",
- __func__);
+ netdev_err(dev, "Invalid RF Chip ID.\n");
break;
}
}
@@ -709,7 +708,7 @@ bool rtl8192_phy_RFConfig(struct net_device *dev)
break;
default:
- RT_TRACE(COMP_ERR, "error chip id\n");
+ netdev_err(dev, "Invalid RF Chip ID.\n");
break;
}
return rtStatus;
@@ -802,13 +801,13 @@ static void rtl8192_SetTxPowerLevel(struct net_device *dev, u8 channel)
case RF_8258:
break;
default:
- RT_TRACE(COMP_ERR,
- "unknown rf chip ID in rtl8192_SetTxPowerLevel()\n");
+ netdev_warn(dev, "%s(): Invalid RF Chip ID\n", __func__);
break;
}
}
-static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable,
+static u8 rtl8192_phy_SetSwChnlCmdArray(struct net_device *dev,
+ struct sw_chnl_cmd *CmdTable,
u32 CmdTableIdx, u32 CmdTableSz,
enum sw_chnl_cmd_id CmdID,
u32 Para1, u32 Para2, u32 msDelay)
@@ -816,14 +815,11 @@ static u8 rtl8192_phy_SetSwChnlCmdArray(struct sw_chnl_cmd *CmdTable,
struct sw_chnl_cmd *pCmd;
if (CmdTable == NULL) {
- RT_TRACE(COMP_ERR,
- "phy_SetSwChnlCmdArray(): CmdTable cannot be NULL.\n");
+ netdev_err(dev, "%s(): CmdTable cannot be NULL.\n", __func__);
return false;
}
if (CmdTableIdx >= CmdTableSz) {
- RT_TRACE(COMP_ERR,
- "phy_SetSwChnlCmdArray(): Access invalid index, please check size of the table, CmdTableIdx:%d, CmdTableSz:%d\n",
- CmdTableIdx, CmdTableSz);
+ netdev_err(dev, "%s(): Invalid index requested.\n", __func__);
return false;
}
@@ -851,24 +847,23 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
__func__, *stage, *step, channel);
if (!rtllib_legal_channel(priv->rtllib, channel)) {
- RT_TRACE(COMP_ERR, "=============>set to illegal channel:%d\n",
- channel);
+ netdev_err(dev, "Invalid channel requested: %d\n", channel);
return true;
}
{
PreCommonCmdCnt = 0;
- rtl8192_phy_SetSwChnlCmdArray(ieee->PreCommonCmd,
+ rtl8192_phy_SetSwChnlCmdArray(dev, ieee->PreCommonCmd,
PreCommonCmdCnt++,
MAX_PRECMD_CNT, CmdID_SetTxPowerLevel,
0, 0, 0);
- rtl8192_phy_SetSwChnlCmdArray(ieee->PreCommonCmd,
+ rtl8192_phy_SetSwChnlCmdArray(dev, ieee->PreCommonCmd,
PreCommonCmdCnt++,
MAX_PRECMD_CNT, CmdID_End, 0, 0, 0);
PostCommonCmdCnt = 0;
- rtl8192_phy_SetSwChnlCmdArray(ieee->PostCommonCmd,
+ rtl8192_phy_SetSwChnlCmdArray(dev, ieee->PostCommonCmd,
PostCommonCmdCnt++,
MAX_POSTCMD_CNT, CmdID_End, 0, 0, 0);
@@ -876,32 +871,32 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
switch (priv->rf_chip) {
case RF_8225:
if (!(channel >= 1 && channel <= 14)) {
- RT_TRACE(COMP_ERR,
- "illegal channel for Zebra 8225: %d\n",
- channel);
+ netdev_err(dev,
+ "Invalid channel requested for 8225: %d\n",
+ channel);
return false;
}
- rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd,
+ rtl8192_phy_SetSwChnlCmdArray(dev, ieee->RfDependCmd,
RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
CmdID_RF_WriteReg, rZebra1_Channel,
RF_CHANNEL_TABLE_ZEBRA[channel], 10);
- rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd,
+ rtl8192_phy_SetSwChnlCmdArray(dev, ieee->RfDependCmd,
RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
CmdID_End, 0, 0, 0);
break;
case RF_8256:
if (!(channel >= 1 && channel <= 14)) {
- RT_TRACE(COMP_ERR,
- "illegal channel for Zebra 8256: %d\n",
- channel);
+ netdev_err(dev,
+ "Invalid channel requested for 8256: %d\n",
+ channel);
return false;
}
- rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd,
+ rtl8192_phy_SetSwChnlCmdArray(dev, ieee->RfDependCmd,
RfDependCmdCnt++, MAX_RFDEPENDCMD_CNT,
CmdID_RF_WriteReg, rZebra1_Channel, channel,
10);
- rtl8192_phy_SetSwChnlCmdArray(ieee->RfDependCmd,
+ rtl8192_phy_SetSwChnlCmdArray(dev, ieee->RfDependCmd,
RfDependCmdCnt++,
MAX_RFDEPENDCMD_CNT,
@@ -912,8 +907,7 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel,
break;
default:
- RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n",
- priv->rf_chip);
+ netdev_warn(dev, "Unknown RF Chip ID\n");
return false;
}
@@ -1002,7 +996,7 @@ void rtl8192_SwChnl_WorkItem(struct net_device *dev)
RT_TRACE(COMP_TRACE, "=====>--%s(), set chan:%d, priv:%p\n", __func__,
priv->chan, priv);
- rtl8192_phy_FinishSwChnlNow(dev , priv->chan);
+ rtl8192_phy_FinishSwChnlNow(dev, priv->chan);
RT_TRACE(COMP_TRACE, "<== SwChnlCallback819xUsbWorkItem()\n");
}
@@ -1013,7 +1007,7 @@ u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel)
RT_TRACE(COMP_PHY, "=====>%s()\n", __func__);
if (!priv->up) {
- RT_TRACE(COMP_ERR, "%s(): ERR !! driver is not up\n", __func__);
+ netdev_err(dev, "%s(): Driver is not initialized\n", __func__);
return false;
}
if (priv->SwChnlInProgress)
@@ -1024,20 +1018,26 @@ u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel)
case WIRELESS_MODE_A:
case WIRELESS_MODE_N_5G:
if (channel <= 14) {
- RT_TRACE(COMP_ERR, "WIRELESS_MODE_A but channel<=14");
+ netdev_warn(dev,
+ "Channel %d not available in 802.11a.\n",
+ channel);
return false;
}
break;
case WIRELESS_MODE_B:
if (channel > 14) {
- RT_TRACE(COMP_ERR, "WIRELESS_MODE_B but channel>14");
+ netdev_warn(dev,
+ "Channel %d not available in 802.11b.\n",
+ channel);
return false;
}
break;
case WIRELESS_MODE_G:
case WIRELESS_MODE_N_24G:
if (channel > 14) {
- RT_TRACE(COMP_ERR, "WIRELESS_MODE_G but channel>14");
+ netdev_warn(dev,
+ "Channel %d not available in 802.11g.\n",
+ channel);
return false;
}
break;
@@ -1180,7 +1180,7 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
return;
}
if (!priv->up) {
- RT_TRACE(COMP_ERR, "%s(): ERR!! driver is not up\n", __func__);
+ netdev_err(dev, "%s(): Driver is not initialized\n", __func__);
return;
}
regBwOpMode = read_nic_byte(dev, BW_OPMODE);
@@ -1197,9 +1197,8 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
break;
default:
- RT_TRACE(COMP_ERR,
- "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",
- priv->CurrentChannelBW);
+ netdev_err(dev, "%s(): unknown Bandwidth: %#X\n", __func__,
+ priv->CurrentChannelBW);
break;
}
@@ -1239,9 +1238,8 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
rtl8192_setBBreg(dev, rFPGA0_AnalogParameter1, 0x00100000, 0);
break;
default:
- RT_TRACE(COMP_ERR,
- "SetChannelBandwidth819xUsb(): unknown Bandwidth: %#X\n",
- priv->CurrentChannelBW);
+ netdev_err(dev, "%s(): unknown Bandwidth: %#X\n", __func__,
+ priv->CurrentChannelBW);
break;
}
@@ -1261,7 +1259,8 @@ void rtl8192_SetBWModeWorkItem(struct net_device *dev)
break;
default:
- RT_TRACE(COMP_ERR, "Unknown RFChipID: %d\n", priv->rf_chip);
+ netdev_info(dev, "%s(): Unknown RFChipID: %d\n", __func__,
+ priv->rf_chip);
break;
}
@@ -1452,9 +1451,9 @@ static bool SetRFPowerState8190(struct net_device *dev,
} while (!rtstatus && (InitilizeCount > 0));
if (!rtstatus) {
- RT_TRACE(COMP_ERR,
- "%s():Initialize Adapter fail,return\n",
- __func__);
+ netdev_err(dev,
+ "%s(): Failed to initialize Adapter.\n",
+ __func__);
priv->SetRFPowerStateInProgress = false;
return false;
}
@@ -1555,16 +1554,16 @@ static bool SetRFPowerState8190(struct net_device *dev,
default:
bResult = false;
- RT_TRACE(COMP_ERR,
- "SetRFPowerState8190(): unknown state to set: 0x%X!!!\n",
- eRFPowerState);
+ netdev_warn(dev,
+ "%s(): Unknown state requested: 0x%X.\n",
+ __func__, eRFPowerState);
break;
}
break;
default:
- RT_TRACE(COMP_ERR, "SetRFPowerState8190(): Unknown RF type\n");
+ netdev_warn(dev, "%s(): Unknown RF type\n", __func__);
break;
}
@@ -1576,8 +1575,7 @@ static bool SetRFPowerState8190(struct net_device *dev,
break;
default:
- RT_TRACE(COMP_ERR,
- "SetRFPowerState8190(): Unknown RF type\n");
+ netdev_warn(dev, "%s(): Unknown RF type\n", __func__);
break;
}
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
index 7899dd538dcd73..8a1d91e05da927 100644
--- a/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
+++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_phyreg.h
@@ -3,7 +3,7 @@
*
* 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
+ * 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
@@ -20,48 +20,48 @@
#define _R819XU_PHYREG_H
-#define RF_DATA 0x1d4
-
-#define rPMAC_Reset 0x100
-#define rPMAC_TxStart 0x104
-#define rPMAC_TxLegacySIG 0x108
-#define rPMAC_TxHTSIG1 0x10c
-#define rPMAC_TxHTSIG2 0x110
-#define rPMAC_PHYDebug 0x114
-#define rPMAC_TxPacketNum 0x118
-#define rPMAC_TxIdle 0x11c
-#define rPMAC_TxMACHeader0 0x120
-#define rPMAC_TxMACHeader1 0x124
-#define rPMAC_TxMACHeader2 0x128
-#define rPMAC_TxMACHeader3 0x12c
-#define rPMAC_TxMACHeader4 0x130
-#define rPMAC_TxMACHeader5 0x134
-#define rPMAC_TxDataType 0x138
-#define rPMAC_TxRandomSeed 0x13c
-#define rPMAC_CCKPLCPPreamble 0x140
-#define rPMAC_CCKPLCPHeader 0x144
-#define rPMAC_CCKCRC16 0x148
-#define rPMAC_OFDMRxCRC32OK 0x170
-#define rPMAC_OFDMRxCRC32Er 0x174
-#define rPMAC_OFDMRxParityEr 0x178
-#define rPMAC_OFDMRxCRC8Er 0x17c
-#define rPMAC_CCKCRxRC16Er 0x180
-#define rPMAC_CCKCRxRC32Er 0x184
-#define rPMAC_CCKCRxRC32OK 0x188
-#define rPMAC_TxStatus 0x18c
-
-#define MCS_TXAGC 0x340
-#define CCK_TXAGC 0x348
-
-/*---------------------0x400~0x4ff----------------------*/
-#define MacBlkCtrl 0x403
-
-#define rFPGA0_RFMOD 0x800
-#define rFPGA0_TxInfo 0x804
-#define rFPGA0_PSDFunction 0x808
-#define rFPGA0_TxGainStage 0x80c
-#define rFPGA0_RFTiming1 0x810
-#define rFPGA0_RFTiming2 0x814
+#define RF_DATA 0x1d4
+
+#define rPMAC_Reset 0x100
+#define rPMAC_TxStart 0x104
+#define rPMAC_TxLegacySIG 0x108
+#define rPMAC_TxHTSIG1 0x10c
+#define rPMAC_TxHTSIG2 0x110
+#define rPMAC_PHYDebug 0x114
+#define rPMAC_TxPacketNum 0x118
+#define rPMAC_TxIdle 0x11c
+#define rPMAC_TxMACHeader0 0x120
+#define rPMAC_TxMACHeader1 0x124
+#define rPMAC_TxMACHeader2 0x128
+#define rPMAC_TxMACHeader3 0x12c
+#define rPMAC_TxMACHeader4 0x130
+#define rPMAC_TxMACHeader5 0x134
+#define rPMAC_TxDataType 0x138
+#define rPMAC_TxRandomSeed 0x13c
+#define rPMAC_CCKPLCPPreamble 0x140
+#define rPMAC_CCKPLCPHeader 0x144
+#define rPMAC_CCKCRC16 0x148
+#define rPMAC_OFDMRxCRC32OK 0x170
+#define rPMAC_OFDMRxCRC32Er 0x174
+#define rPMAC_OFDMRxParityEr 0x178
+#define rPMAC_OFDMRxCRC8Er 0x17c
+#define rPMAC_CCKCRxRC16Er 0x180
+#define rPMAC_CCKCRxRC32Er 0x184
+#define rPMAC_CCKCRxRC32OK 0x188
+#define rPMAC_TxStatus 0x18c
+
+#define MCS_TXAGC 0x340
+#define CCK_TXAGC 0x348
+
+/* Mac block on/off control register */
+#define MacBlkCtrl 0x403
+
+#define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC */
+#define rFPGA0_TxInfo 0x804
+#define rFPGA0_PSDFunction 0x808
+#define rFPGA0_TxGainStage 0x80c
+#define rFPGA0_RFTiming1 0x810
+#define rFPGA0_RFTiming2 0x814
#define rFPGA0_XA_HSSIParameter1 0x820
#define rFPGA0_XA_HSSIParameter2 0x824
#define rFPGA0_XB_HSSIParameter1 0x828
@@ -94,52 +94,57 @@
#define rFPGA0_XB_LSSIReadBack 0x8a4
#define rFPGA0_XC_LSSIReadBack 0x8a8
#define rFPGA0_XD_LSSIReadBack 0x8ac
-#define rFPGA0_PSDReport 0x8b4
+#define rFPGA0_PSDReport 0x8b4
#define rFPGA0_XAB_RFInterfaceRB 0x8e0
#define rFPGA0_XCD_RFInterfaceRB 0x8e4
-#define rFPGA1_RFMOD 0x900
-#define rFPGA1_TxBlock 0x904
-#define rFPGA1_DebugSelect 0x908
-#define rFPGA1_TxInfo 0x90c
-
-#define rCCK0_System 0xa00
-#define rCCK0_AFESetting 0xa04
-#define rCCK0_CCA 0xa08
-#define rCCK0_RxAGC1 0xa0c
-#define rCCK0_RxAGC2 0xa10
-#define rCCK0_RxHP 0xa14
+/* Page 9 - RF mode & OFDM TxSC */
+#define rFPGA1_RFMOD 0x900
+#define rFPGA1_TxBlock 0x904
+#define rFPGA1_DebugSelect 0x908
+#define rFPGA1_TxInfo 0x90c
+
+#define rCCK0_System 0xa00
+#define rCCK0_AFESetting 0xa04
+#define rCCK0_CCA 0xa08
+/* AGC default value, saturation level */
+#define rCCK0_RxAGC1 0xa0c
+#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */
+#define rCCK0_RxHP 0xa14
+/* Timing recovery & channel estimation threshold */
#define rCCK0_DSPParameter1 0xa18
-#define rCCK0_DSPParameter2 0xa1c
-#define rCCK0_TxFilter1 0xa20
-#define rCCK0_TxFilter2 0xa24
-#define rCCK0_DebugPort 0xa28
+#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */
+#define rCCK0_TxFilter1 0xa20
+#define rCCK0_TxFilter2 0xa24
+#define rCCK0_DebugPort 0xa28 /* Debug port and TX filter 3 */
#define rCCK0_FalseAlarmReport 0xa2c
-#define rCCK0_TRSSIReport 0xa50
-#define rCCK0_RxReport 0xa54
+#define rCCK0_TRSSIReport 0xa50
+#define rCCK0_RxReport 0xa54
#define rCCK0_FACounterLower 0xa5c
#define rCCK0_FACounterUpper 0xa58
-#define rOFDM0_LSTF 0xc00
+#define rOFDM0_LSTF 0xc00
#define rOFDM0_TRxPathEnable 0xc04
-#define rOFDM0_TRMuxPar 0xc08
-#define rOFDM0_TRSWIsolation 0xc0c
-#define rOFDM0_XARxAFE 0xc10
-#define rOFDM0_XARxIQImbalance 0xc14
-#define rOFDM0_XBRxAFE 0xc18
+#define rOFDM0_TRMuxPar 0xc08
+#define rOFDM0_TRSWIsolation 0xc0c
+/* RxIQ DC offset, Rx digital filter, DC notch filter */
+#define rOFDM0_XARxAFE 0xc10
+#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */
+#define rOFDM0_XBRxAFE 0xc18
#define rOFDM0_XBRxIQImbalance 0xc1c
-#define rOFDM0_XCRxAFE 0xc20
+#define rOFDM0_XCRxAFE 0xc20
#define rOFDM0_XCRxIQImbalance 0xc24
-#define rOFDM0_XDRxAFE 0xc28
+#define rOFDM0_XDRxAFE 0xc28
#define rOFDM0_XDRxIQImbalance 0xc2c
-#define rOFDM0_RxDetector1 0xc30
-#define rOFDM0_RxDetector2 0xc34
-#define rOFDM0_RxDetector3 0xc38
-#define rOFDM0_RxDetector4 0xc3c
-#define rOFDM0_RxDSP 0xc40
-#define rOFDM0_CFOandDAGC 0xc44
+#define rOFDM0_RxDetector1 0xc30 /* PD, BW & SBD */
+#define rOFDM0_RxDetector2 0xc34 /* SBD */
+#define rOFDM0_RxDetector3 0xc38 /* Frame Sync */
+/* PD, SBD, Frame Sync & Short-GI */
+#define rOFDM0_RxDetector4 0xc3c
+#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */
+#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */
#define rOFDM0_CCADropThreshold 0xc48
-#define rOFDM0_ECCAThreshold 0xc4c
+#define rOFDM0_ECCAThreshold 0xc4c /* Energy CCA */
#define rOFDM0_XAAGCCore1 0xc50
#define rOFDM0_XAAGCCore2 0xc54
#define rOFDM0_XBAGCCore1 0xc58
@@ -151,702 +156,735 @@
#define rOFDM0_AGCParameter1 0xc70
#define rOFDM0_AGCParameter2 0xc74
#define rOFDM0_AGCRSSITable 0xc78
-#define rOFDM0_HTSTFAGC 0xc7c
+#define rOFDM0_HTSTFAGC 0xc7c
#define rOFDM0_XATxIQImbalance 0xc80
-#define rOFDM0_XATxAFE 0xc84
+#define rOFDM0_XATxAFE 0xc84
#define rOFDM0_XBTxIQImbalance 0xc88
-#define rOFDM0_XBTxAFE 0xc8c
+#define rOFDM0_XBTxAFE 0xc8c
#define rOFDM0_XCTxIQImbalance 0xc90
-#define rOFDM0_XCTxAFE 0xc94
+#define rOFDM0_XCTxAFE 0xc94
#define rOFDM0_XDTxIQImbalance 0xc98
-#define rOFDM0_XDTxAFE 0xc9c
+#define rOFDM0_XDTxAFE 0xc9c
#define rOFDM0_RxHPParameter 0xce0
#define rOFDM0_TxPseudoNoiseWgt 0xce4
-#define rOFDM0_FrameSync 0xcf0
-#define rOFDM0_DFSReport 0xcf4
-#define rOFDM0_TxCoeff1 0xca4
-#define rOFDM0_TxCoeff2 0xca8
-#define rOFDM0_TxCoeff3 0xcac
-#define rOFDM0_TxCoeff4 0xcb0
-#define rOFDM0_TxCoeff5 0xcb4
-#define rOFDM0_TxCoeff6 0xcb8
+#define rOFDM0_FrameSync 0xcf0
+#define rOFDM0_DFSReport 0xcf4
+#define rOFDM0_TxCoeff1 0xca4
+#define rOFDM0_TxCoeff2 0xca8
+#define rOFDM0_TxCoeff3 0xcac
+#define rOFDM0_TxCoeff4 0xcb0
+#define rOFDM0_TxCoeff5 0xcb4
+#define rOFDM0_TxCoeff6 0xcb8
-#define rOFDM1_LSTF 0xd00
+#define rOFDM1_LSTF 0xd00
#define rOFDM1_TRxPathEnable 0xd04
-#define rOFDM1_CFO 0xd08
-#define rOFDM1_CSI1 0xd10
-#define rOFDM1_SBD 0xd14
-#define rOFDM1_CSI2 0xd18
-#define rOFDM1_CFOTracking 0xd2c
+#define rOFDM1_CFO 0xd08
+#define rOFDM1_CSI1 0xd10
+#define rOFDM1_SBD 0xd14
+#define rOFDM1_CSI2 0xd18
+#define rOFDM1_CFOTracking 0xd2c
#define rOFDM1_TRxMesaure1 0xd34
-#define rOFDM1_IntfDet 0xd3c
-#define rOFDM1_PseudoNoiseStateAB 0xd50
-#define rOFDM1_PseudoNoiseStateCD 0xd54
-#define rOFDM1_RxPseudoNoiseWgt 0xd58
-#define rOFDM_PHYCounter1 0xda0
-#define rOFDM_PHYCounter2 0xda4
-#define rOFDM_PHYCounter3 0xda8
-#define rOFDM_ShortCFOAB 0xdac
-#define rOFDM_ShortCFOCD 0xdb0
-#define rOFDM_LongCFOAB 0xdb4
-#define rOFDM_LongCFOCD 0xdb8
-#define rOFDM_TailCFOAB 0xdbc
-#define rOFDM_TailCFOCD 0xdc0
+#define rOFDM1_IntfDet 0xd3c
+#define rOFDM1_PseudoNoiseStateAB 0xd50
+#define rOFDM1_PseudoNoiseStateCD 0xd54
+#define rOFDM1_RxPseudoNoiseWgt 0xd58
+#define rOFDM_PHYCounter1 0xda0 /* cca, parity fail */
+#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */
+#define rOFDM_PHYCounter3 0xda8 /* MCS not supported */
+#define rOFDM_ShortCFOAB 0xdac
+#define rOFDM_ShortCFOCD 0xdb0
+#define rOFDM_LongCFOAB 0xdb4
+#define rOFDM_LongCFOCD 0xdb8
+#define rOFDM_TailCFOAB 0xdbc
+#define rOFDM_TailCFOCD 0xdc0
#define rOFDM_PWMeasure1 0xdc4
#define rOFDM_PWMeasure2 0xdc8
-#define rOFDM_BWReport 0xdcc
-#define rOFDM_AGCReport 0xdd0
-#define rOFDM_RxSNR 0xdd4
-#define rOFDM_RxEVMCSI 0xdd8
-#define rOFDM_SIGReport 0xddc
+#define rOFDM_BWReport 0xdcc
+#define rOFDM_AGCReport 0xdd0
+#define rOFDM_RxSNR 0xdd4
+#define rOFDM_RxEVMCSI 0xdd8
+#define rOFDM_SIGReport 0xddc
-#define rTxAGC_Rate18_06 0xe00
-#define rTxAGC_Rate54_24 0xe04
-#define rTxAGC_CCK_Mcs32 0xe08
-#define rTxAGC_Mcs03_Mcs00 0xe10
-#define rTxAGC_Mcs07_Mcs04 0xe14
-#define rTxAGC_Mcs11_Mcs08 0xe18
-#define rTxAGC_Mcs15_Mcs12 0xe1c
+#define rTxAGC_Rate18_06 0xe00
+#define rTxAGC_Rate54_24 0xe04
+#define rTxAGC_CCK_Mcs32 0xe08
+#define rTxAGC_Mcs03_Mcs00 0xe10
+#define rTxAGC_Mcs07_Mcs04 0xe14
+#define rTxAGC_Mcs11_Mcs08 0xe18
+#define rTxAGC_Mcs15_Mcs12 0xe1c
#define rZebra1_HSSIEnable 0x0
#define rZebra1_TRxEnable1 0x1
#define rZebra1_TRxEnable2 0x2
-#define rZebra1_AGC 0x4
+#define rZebra1_AGC 0x4
#define rZebra1_ChargePump 0x5
-#define rZebra1_Channel 0x7
-#define rZebra1_TxGain 0x8
-#define rZebra1_TxLPF 0x9
-#define rZebra1_RxLPF 0xb
+#define rZebra1_Channel 0x7
+#define rZebra1_TxGain 0x8
+#define rZebra1_TxLPF 0x9
+#define rZebra1_RxLPF 0xb
#define rZebra1_RxHPFCorner 0xc
-#define rGlobalCtrl 0
-#define rRTL8256_TxLPF 19
-#define rRTL8256_RxLPF 11
+/* Zebra 4 */
+#define rGlobalCtrl 0
+#define rRTL8256_TxLPF 19
+#define rRTL8256_RxLPF 11
-#define rRTL8258_TxLPF 0x11
-#define rRTL8258_RxLPF 0x13
+/* RTL8258 */
+#define rRTL8258_TxLPF 0x11
+#define rRTL8258_RxLPF 0x13
#define rRTL8258_RSSILPF 0xa
-#define bBBResetB 0x100
-#define bGlobalResetB 0x200
-#define bOFDMTxStart 0x4
-#define bCCKTxStart 0x8
-#define bCRC32Debug 0x100
-#define bPMACLoopback 0x10
-#define bTxLSIG 0xffffff
-#define bOFDMTxRate 0xf
-#define bOFDMTxReserved 0x10
-#define bOFDMTxLength 0x1ffe0
-#define bOFDMTxParity 0x20000
-#define bTxHTSIG1 0xffffff
-#define bTxHTMCSRate 0x7f
-#define bTxHTBW 0x80
-#define bTxHTLength 0xffff00
-#define bTxHTSIG2 0xffffff
-#define bTxHTSmoothing 0x1
-#define bTxHTSounding 0x2
-#define bTxHTReserved 0x4
-#define bTxHTAggreation 0x8
-#define bTxHTSTBC 0x30
-#define bTxHTAdvanceCoding 0x40
-#define bTxHTShortGI 0x80
-#define bTxHTNumberHT_LTF 0x300
-#define bTxHTCRC8 0x3fc00
-#define bCounterReset 0x10000
-#define bNumOfOFDMTx 0xffff
-#define bNumOfCCKTx 0xffff0000
-#define bTxIdleInterval 0xffff
-#define bOFDMService 0xffff0000
-#define bTxMACHeader 0xffffffff
-#define bTxDataInit 0xff
-#define bTxHTMode 0x100
-#define bTxDataType 0x30000
-#define bTxRandomSeed 0xffffffff
-#define bCCKTxPreamble 0x1
-#define bCCKTxSFD 0xffff0000
-#define bCCKTxSIG 0xff
-#define bCCKTxService 0xff00
-#define bCCKLengthExt 0x8000
-#define bCCKTxLength 0xffff0000
-#define bCCKTxCRC16 0xffff
-#define bCCKTxStatus 0x1
-#define bOFDMTxStatus 0x2
-
-#define bRFMOD 0x1
-#define bJapanMode 0x2
-#define bCCKTxSC 0x30
-#define bCCKEn 0x1000000
-#define bOFDMEn 0x2000000
-#define bOFDMRxADCPhase 0x10000
-#define bOFDMTxDACPhase 0x40000
-#define bXATxAGC 0x3f
-#define bXBTxAGC 0xf00
-#define bXCTxAGC 0xf000
-#define bXDTxAGC 0xf0000
-#define bPAStart 0xf0000000
-#define bTRStart 0x00f00000
-#define bRFStart 0x0000f000
-#define bBBStart 0x000000f0
-#define bBBCCKStart 0x0000000f
-#define bPAEnd 0xf
-#define bTREnd 0x0f000000
-#define bRFEnd 0x000f0000
-#define bCCAMask 0x000000f0
-#define bR2RCCAMask 0x00000f00
-#define bHSSI_R2TDelay 0xf8000000
-#define bHSSI_T2RDelay 0xf80000
-#define bContTxHSSI 0x400
-#define bIGFromCCK 0x200
-#define bAGCAddress 0x3f
-#define bRxHPTx 0x7000
-#define bRxHPT2R 0x38000
-#define bRxHPCCKIni 0xc0000
-#define bAGCTxCode 0xc00000
-#define bAGCRxCode 0x300000
-#define b3WireDataLength 0x800
-#define b3WireAddressLength 0x400
-#define b3WireRFPowerDown 0x1
-#define b5GPAPEPolarity 0x40000000
-#define b2GPAPEPolarity 0x80000000
-#define bRFSW_TxDefaultAnt 0x3
-#define bRFSW_TxOptionAnt 0x30
-#define bRFSW_RxDefaultAnt 0x300
-#define bRFSW_RxOptionAnt 0x3000
-#define bRFSI_3WireData 0x1
-#define bRFSI_3WireClock 0x2
-#define bRFSI_3WireLoad 0x4
-#define bRFSI_3WireRW 0x8
-#define bRFSI_3Wire 0xf
-#define bRFSI_RFENV 0x10
-#define bRFSI_TRSW 0x20
-#define bRFSI_TRSWB 0x40
-#define bRFSI_ANTSW 0x100
-#define bRFSI_ANTSWB 0x200
-#define bRFSI_PAPE 0x400
-#define bRFSI_PAPE5G 0x800
-#define bBandSelect 0x1
-#define bHTSIG2_GI 0x80
-#define bHTSIG2_Smoothing 0x01
-#define bHTSIG2_Sounding 0x02
-#define bHTSIG2_Aggreaton 0x08
-#define bHTSIG2_STBC 0x30
-#define bHTSIG2_AdvCoding 0x40
+/* Bit Mask - Page 1*/
+#define bBBResetB 0x100
+#define bGlobalResetB 0x200
+#define bOFDMTxStart 0x4
+#define bCCKTxStart 0x8
+#define bCRC32Debug 0x100
+#define bPMACLoopback 0x10
+#define bTxLSIG 0xffffff
+#define bOFDMTxRate 0xf
+#define bOFDMTxReserved 0x10
+#define bOFDMTxLength 0x1ffe0
+#define bOFDMTxParity 0x20000
+#define bTxHTSIG1 0xffffff
+#define bTxHTMCSRate 0x7f
+#define bTxHTBW 0x80
+#define bTxHTLength 0xffff00
+#define bTxHTSIG2 0xffffff
+#define bTxHTSmoothing 0x1
+#define bTxHTSounding 0x2
+#define bTxHTReserved 0x4
+#define bTxHTAggreation 0x8
+#define bTxHTSTBC 0x30
+#define bTxHTAdvanceCoding 0x40
+#define bTxHTShortGI 0x80
+#define bTxHTNumberHT_LTF 0x300
+#define bTxHTCRC8 0x3fc00
+#define bCounterReset 0x10000
+#define bNumOfOFDMTx 0xffff
+#define bNumOfCCKTx 0xffff0000
+#define bTxIdleInterval 0xffff
+#define bOFDMService 0xffff0000
+#define bTxMACHeader 0xffffffff
+#define bTxDataInit 0xff
+#define bTxHTMode 0x100
+#define bTxDataType 0x30000
+#define bTxRandomSeed 0xffffffff
+#define bCCKTxPreamble 0x1
+#define bCCKTxSFD 0xffff0000
+#define bCCKTxSIG 0xff
+#define bCCKTxService 0xff00
+#define bCCKLengthExt 0x8000
+#define bCCKTxLength 0xffff0000
+#define bCCKTxCRC16 0xffff
+#define bCCKTxStatus 0x1
+#define bOFDMTxStatus 0x2
+/* Bit Mask - Page 8 */
+#define bRFMOD 0x1
+#define bJapanMode 0x2
+#define bCCKTxSC 0x30
+#define bCCKEn 0x1000000
+#define bOFDMEn 0x2000000
+#define bOFDMRxADCPhase 0x10000
+#define bOFDMTxDACPhase 0x40000
+#define bXATxAGC 0x3f
+#define bXBTxAGC 0xf00
+#define bXCTxAGC 0xf000
+#define bXDTxAGC 0xf0000
+#define bPAStart 0xf0000000
+#define bTRStart 0x00f00000
+#define bRFStart 0x0000f000
+#define bBBStart 0x000000f0
+#define bBBCCKStart 0x0000000f
+/* Bit Mask - rFPGA0_RFTiming2 */
+#define bPAEnd 0xf
+#define bTREnd 0x0f000000
+#define bRFEnd 0x000f0000
+/* T2R */
+#define bCCAMask 0x000000f0
+#define bR2RCCAMask 0x00000f00
+#define bHSSI_R2TDelay 0xf8000000
+#define bHSSI_T2RDelay 0xf80000
+/* Channel gain at continue TX. */
+#define bContTxHSSI 0x400
+#define bIGFromCCK 0x200
+#define bAGCAddress 0x3f
+#define bRxHPTx 0x7000
+#define bRxHPT2R 0x38000
+#define bRxHPCCKIni 0xc0000
+#define bAGCTxCode 0xc00000
+#define bAGCRxCode 0x300000
+#define b3WireDataLength 0x800
+#define b3WireAddressLength 0x400
+#define b3WireRFPowerDown 0x1
+/*#define bHWSISelect 0x8 */
+#define b5GPAPEPolarity 0x40000000
+#define b2GPAPEPolarity 0x80000000
+#define bRFSW_TxDefaultAnt 0x3
+#define bRFSW_TxOptionAnt 0x30
+#define bRFSW_RxDefaultAnt 0x300
+#define bRFSW_RxOptionAnt 0x3000
+#define bRFSI_3WireData 0x1
+#define bRFSI_3WireClock 0x2
+#define bRFSI_3WireLoad 0x4
+#define bRFSI_3WireRW 0x8
+/* 3-wire total control */
+#define bRFSI_3Wire 0xf
+#define bRFSI_RFENV 0x10
+#define bRFSI_TRSW 0x20
+#define bRFSI_TRSWB 0x40
+#define bRFSI_ANTSW 0x100
+#define bRFSI_ANTSWB 0x200
+#define bRFSI_PAPE 0x400
+#define bRFSI_PAPE5G 0x800
+#define bBandSelect 0x1
+#define bHTSIG2_GI 0x80
+#define bHTSIG2_Smoothing 0x01
+#define bHTSIG2_Sounding 0x02
+#define bHTSIG2_Aggreaton 0x08
+#define bHTSIG2_STBC 0x30
+#define bHTSIG2_AdvCoding 0x40
#define bHTSIG2_NumOfHTLTF 0x300
-#define bHTSIG2_CRC8 0x3fc
-#define bHTSIG1_MCS 0x7f
-#define bHTSIG1_BandWidth 0x80
-#define bHTSIG1_HTLength 0xffff
-#define bLSIG_Rate 0xf
-#define bLSIG_Reserved 0x10
-#define bLSIG_Length 0x1fffe
-#define bLSIG_Parity 0x20
-#define bCCKRxPhase 0x4
-#define bLSSIReadAddress 0x3f000000
-#define bLSSIReadEdge 0x80000000
-#define bLSSIReadBackData 0xfff
-#define bLSSIReadOKFlag 0x1000
-#define bCCKSampleRate 0x8
-
-#define bRegulator0Standby 0x1
-#define bRegulatorPLLStandby 0x2
-#define bRegulator1Standby 0x4
-#define bPLLPowerUp 0x8
-#define bDPLLPowerUp 0x10
-#define bDA10PowerUp 0x20
-#define bAD7PowerUp 0x200
-#define bDA6PowerUp 0x2000
-#define bXtalPowerUp 0x4000
-#define b40MDClkPowerUP 0x8000
-#define bDA6DebugMode 0x20000
-#define bDA6Swing 0x380000
-#define bADClkPhase 0x4000000
-#define b80MClkDelay 0x18000000
-#define bAFEWatchDogEnable 0x20000000
-#define bXtalCap 0x0f000000
-#define bXtalCap01 0xc0000000
-#define bXtalCap23 0x3
-#define bXtalCap92x 0x0f000000
-#define bIntDifClkEnable 0x400
-#define bExtSigClkEnable 0x800
+#define bHTSIG2_CRC8 0x3fc
+#define bHTSIG1_MCS 0x7f
+#define bHTSIG1_BandWidth 0x80
+#define bHTSIG1_HTLength 0xffff
+#define bLSIG_Rate 0xf
+#define bLSIG_Reserved 0x10
+#define bLSIG_Length 0x1fffe
+#define bLSIG_Parity 0x20
+#define bCCKRxPhase 0x4
+#define bLSSIReadAddress 0x3f000000 /* LSSI "read" address */
+#define bLSSIReadEdge 0x80000000 /* LSSI "read" edge signal */
+#define bLSSIReadBackData 0xfff
+#define bLSSIReadOKFlag 0x1000
+#define bCCKSampleRate 0x8 /* 0: 44 MHz, 1: 88MHz */
+
+#define bRegulator0Standby 0x1
+#define bRegulatorPLLStandby 0x2
+#define bRegulator1Standby 0x4
+#define bPLLPowerUp 0x8
+#define bDPLLPowerUp 0x10
+#define bDA10PowerUp 0x20
+#define bAD7PowerUp 0x200
+#define bDA6PowerUp 0x2000
+#define bXtalPowerUp 0x4000
+#define b40MDClkPowerUP 0x8000
+#define bDA6DebugMode 0x20000
+#define bDA6Swing 0x380000
+#define bADClkPhase 0x4000000
+#define b80MClkDelay 0x18000000
+#define bAFEWatchDogEnable 0x20000000
+#define bXtalCap 0x0f000000
+#define bXtalCap01 0xc0000000
+#define bXtalCap23 0x3
+#define bXtalCap92x 0x0f000000
+#define bIntDifClkEnable 0x400
+#define bExtSigClkEnable 0x800
#define bBandgapMbiasPowerUp 0x10000
-#define bAD11SHGain 0xc0000
-#define bAD11InputRange 0x700000
-#define bAD11OPCurrent 0x3800000
-#define bIPathLoopback 0x4000000
-#define bQPathLoopback 0x8000000
-#define bAFELoopback 0x10000000
-#define bDA10Swing 0x7e0
-#define bDA10Reverse 0x800
-#define bDAClkSource 0x1000
-#define bAD7InputRange 0x6000
-#define bAD7Gain 0x38000
-#define bAD7OutputCMMode 0x40000
-#define bAD7InputCMMode 0x380000
-#define bAD7Current 0xc00000
-#define bRegulatorAdjust 0x7000000
-#define bAD11PowerUpAtTx 0x1
-#define bDA10PSAtTx 0x10
-#define bAD11PowerUpAtRx 0x100
-#define bDA10PSAtRx 0x1000
-
-#define bCCKRxAGCFormat 0x200
-
-#define bPSDFFTSamplepPoint 0xc000
-#define bPSDAverageNum 0x3000
-#define bIQPathControl 0xc00
-#define bPSDFreq 0x3ff
-#define bPSDAntennaPath 0x30
-#define bPSDIQSwitch 0x40
-#define bPSDRxTrigger 0x400000
-#define bPSDTxTrigger 0x80000000
-#define bPSDSineToneScale 0x7f000000
-#define bPSDReport 0xffff
-
-#define bOFDMTxSC 0x30000000
-#define bCCKTxOn 0x1
-#define bOFDMTxOn 0x2
-#define bDebugPage 0xfff
-#define bDebugItem 0xff
-#define bAntL 0x10
-#define bAntNonHT 0x100
-#define bAntHT1 0x1000
-#define bAntHT2 0x10000
-#define bAntHT1S1 0x100000
-#define bAntNonHTS1 0x1000000
-
-#define bCCKBBMode 0x3
-#define bCCKTxPowerSaving 0x80
-#define bCCKRxPowerSaving 0x40
-#define bCCKSideBand 0x10
-#define bCCKScramble 0x8
-#define bCCKAntDiversity 0x8000
+#define bAD11SHGain 0xc0000
+#define bAD11InputRange 0x700000
+#define bAD11OPCurrent 0x3800000
+#define bIPathLoopback 0x4000000
+#define bQPathLoopback 0x8000000
+#define bAFELoopback 0x10000000
+#define bDA10Swing 0x7e0
+#define bDA10Reverse 0x800
+#define bDAClkSource 0x1000
+#define bAD7InputRange 0x6000
+#define bAD7Gain 0x38000
+#define bAD7OutputCMMode 0x40000
+#define bAD7InputCMMode 0x380000
+#define bAD7Current 0xc00000
+#define bRegulatorAdjust 0x7000000
+#define bAD11PowerUpAtTx 0x1
+#define bDA10PSAtTx 0x10
+#define bAD11PowerUpAtRx 0x100
+#define bDA10PSAtRx 0x1000
+
+#define bCCKRxAGCFormat 0x200
+
+#define bPSDFFTSamplepPoint 0xc000
+#define bPSDAverageNum 0x3000
+#define bIQPathControl 0xc00
+#define bPSDFreq 0x3ff
+#define bPSDAntennaPath 0x30
+#define bPSDIQSwitch 0x40
+#define bPSDRxTrigger 0x400000
+#define bPSDTxTrigger 0x80000000
+#define bPSDSineToneScale 0x7f000000
+#define bPSDReport 0xffff
+
+/* Page 8 */
+#define bOFDMTxSC 0x30000000
+#define bCCKTxOn 0x1
+#define bOFDMTxOn 0x2
+/* Reset debug page and also HWord, LWord */
+#define bDebugPage 0xfff
+/* Reset debug page and LWord */
+#define bDebugItem 0xff
+#define bAntL 0x10
+#define bAntNonHT 0x100
+#define bAntHT1 0x1000
+#define bAntHT2 0x10000
+#define bAntHT1S1 0x100000
+#define bAntNonHTS1 0x1000000
+
+/* Page a */
+#define bCCKBBMode 0x3
+#define bCCKTxPowerSaving 0x80
+#define bCCKRxPowerSaving 0x40
+#define bCCKSideBand 0x10
+#define bCCKScramble 0x8
+#define bCCKAntDiversity 0x8000
#define bCCKCarrierRecovery 0x4000
-#define bCCKTxRate 0x3000
-#define bCCKDCCancel 0x0800
-#define bCCKISICancel 0x0400
-#define bCCKMatchFilter 0x0200
-#define bCCKEqualizer 0x0100
-#define bCCKPreambleDetect 0x800000
-#define bCCKFastFalseCCA 0x400000
-#define bCCKChEstStart 0x300000
-#define bCCKCCACount 0x080000
-#define bCCKcs_lim 0x070000
-#define bCCKBistMode 0x80000000
-#define bCCKCCAMask 0x40000000
+#define bCCKTxRate 0x3000
+#define bCCKDCCancel 0x0800
+#define bCCKISICancel 0x0400
+#define bCCKMatchFilter 0x0200
+#define bCCKEqualizer 0x0100
+#define bCCKPreambleDetect 0x800000
+#define bCCKFastFalseCCA 0x400000
+#define bCCKChEstStart 0x300000
+#define bCCKCCACount 0x080000
+#define bCCKcs_lim 0x070000
+#define bCCKBistMode 0x80000000
+#define bCCKCCAMask 0x40000000
#define bCCKTxDACPhase 0x4
-#define bCCKRxADCPhase 0x20000000
+#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */
#define bCCKr_cp_mode0 0x0100
-#define bCCKTxDCOffset 0xf0
-#define bCCKRxDCOffset 0xf
-#define bCCKCCAMode 0xc000
-#define bCCKFalseCS_lim 0x3f00
-#define bCCKCS_ratio 0xc00000
-#define bCCKCorgBit_sel 0x300000
-#define bCCKPD_lim 0x0f0000
-#define bCCKNewCCA 0x80000000
-#define bCCKRxHPofIG 0x8000
-#define bCCKRxIG 0x7f00
-#define bCCKLNAPolarity 0x800000
-#define bCCKRx1stGain 0x7f0000
-#define bCCKRFExtend 0x20000000
-#define bCCKRxAGCSatLevel 0x1f000000
-#define bCCKRxAGCSatCount 0xe0
-#define bCCKRxRFSettle 0x1f
-#define bCCKFixedRxAGC 0x8000
-#define bCCKAntennaPolarity 0x2000
-#define bCCKTxFilterType 0x0c00
+#define bCCKTxDCOffset 0xf0
+#define bCCKRxDCOffset 0xf
+#define bCCKCCAMode 0xc000
+#define bCCKFalseCS_lim 0x3f00
+#define bCCKCS_ratio 0xc00000
+#define bCCKCorgBit_sel 0x300000
+#define bCCKPD_lim 0x0f0000
+#define bCCKNewCCA 0x80000000
+#define bCCKRxHPofIG 0x8000
+#define bCCKRxIG 0x7f00
+#define bCCKLNAPolarity 0x800000
+#define bCCKRx1stGain 0x7f0000
+/* CCK Rx Initial gain polarity */
+#define bCCKRFExtend 0x20000000
+#define bCCKRxAGCSatLevel 0x1f000000
+#define bCCKRxAGCSatCount 0xe0
+/* AGCSAmp_dly */
+#define bCCKRxRFSettle 0x1f
+#define bCCKFixedRxAGC 0x8000
+/*#define bCCKRxAGCFormat 0x4000 remove to HSSI register 0x824 */
+#define bCCKAntennaPolarity 0x2000
+#define bCCKTxFilterType 0x0c00
#define bCCKRxAGCReportType 0x0300
-#define bCCKRxDAGCEn 0x80000000
-#define bCCKRxDAGCPeriod 0x20000000
+#define bCCKRxDAGCEn 0x80000000
+#define bCCKRxDAGCPeriod 0x20000000
#define bCCKRxDAGCSatLevel 0x1f000000
-#define bCCKTimingRecovery 0x800000
-#define bCCKTxC0 0x3f0000
-#define bCCKTxC1 0x3f000000
-#define bCCKTxC2 0x3f
-#define bCCKTxC3 0x3f00
-#define bCCKTxC4 0x3f0000
-#define bCCKTxC5 0x3f000000
-#define bCCKTxC6 0x3f
-#define bCCKTxC7 0x3f00
-#define bCCKDebugPort 0xff0000
-#define bCCKDACDebug 0x0f000000
-#define bCCKFalseAlarmEnable 0x8000
-#define bCCKFalseAlarmRead 0x4000
-#define bCCKTRSSI 0x7f
-#define bCCKRxAGCReport 0xfe
-#define bCCKRxReport_AntSel 0x80000000
-#define bCCKRxReport_MFOff 0x40000000
+#define bCCKTimingRecovery 0x800000
+#define bCCKTxC0 0x3f0000
+#define bCCKTxC1 0x3f000000
+#define bCCKTxC2 0x3f
+#define bCCKTxC3 0x3f00
+#define bCCKTxC4 0x3f0000
+#define bCCKTxC5 0x3f000000
+#define bCCKTxC6 0x3f
+#define bCCKTxC7 0x3f00
+#define bCCKDebugPort 0xff0000
+#define bCCKDACDebug 0x0f000000
+#define bCCKFalseAlarmEnable 0x8000
+#define bCCKFalseAlarmRead 0x4000
+#define bCCKTRSSI 0x7f
+#define bCCKRxAGCReport 0xfe
+#define bCCKRxReport_AntSel 0x80000000
+#define bCCKRxReport_MFOff 0x40000000
#define bCCKRxRxReport_SQLoss 0x20000000
-#define bCCKRxReport_Pktloss 0x10000000
+#define bCCKRxReport_Pktloss 0x10000000
#define bCCKRxReport_Lockedbit 0x08000000
#define bCCKRxReport_RateError 0x04000000
-#define bCCKRxReport_RxRate 0x03000000
+#define bCCKRxReport_RxRate 0x03000000
#define bCCKRxFACounterLower 0xff
#define bCCKRxFACounterUpper 0xff000000
-#define bCCKRxHPAGCStart 0xe000
-#define bCCKRxHPAGCFinal 0x1c00
+#define bCCKRxHPAGCStart 0xe000
+#define bCCKRxHPAGCFinal 0x1c00
#define bCCKRxFalseAlarmEnable 0x8000
-#define bCCKFACounterFreeze 0x4000
-
-#define bCCKTxPathSel 0x10000000
-#define bCCKDefaultRxPath 0xc000000
-#define bCCKOptionRxPath 0x3000000
-
-#define bNumOfSTF 0x3
-#define bShift_L 0xc0
-#define bGI_TH 0xc
-#define bRxPathA 0x1
-#define bRxPathB 0x2
-#define bRxPathC 0x4
-#define bRxPathD 0x8
-#define bTxPathA 0x1
-#define bTxPathB 0x2
-#define bTxPathC 0x4
-#define bTxPathD 0x8
-#define bTRSSIFreq 0x200
-#define bADCBackoff 0x3000
-#define bDFIRBackoff 0xc000
-#define bTRSSILatchPhase 0x10000
-#define bRxIDCOffset 0xff
-#define bRxQDCOffset 0xff00
-#define bRxDFIRMode 0x1800000
-#define bRxDCNFType 0xe000000
-#define bRXIQImb_A 0x3ff
-#define bRXIQImb_B 0xfc00
-#define bRXIQImb_C 0x3f0000
-#define bRXIQImb_D 0xffc00000
-#define bDC_dc_Notch 0x60000
-#define bRxNBINotch 0x1f000000
-#define bPD_TH 0xf
-#define bPD_TH_Opt2 0xc000
-#define bPWED_TH 0x700
-#define bIfMF_Win_L 0x800
-#define bPD_Option 0x1000
-#define bMF_Win_L 0xe000
-#define bBW_Search_L 0x30000
-#define bwin_enh_L 0xc0000
-#define bBW_TH 0x700000
-#define bED_TH2 0x3800000
-#define bBW_option 0x4000000
-#define bRatio_TH 0x18000000
-#define bWindow_L 0xe0000000
-#define bSBD_Option 0x1
-#define bFrame_TH 0x1c
-#define bFS_Option 0x60
-#define bDC_Slope_check 0x80
-#define bFGuard_Counter_DC_L 0xe00
-#define bFrame_Weight_Short 0x7000
-#define bSub_Tune 0xe00000
-#define bFrame_DC_Length 0xe000000
-#define bSBD_start_offset 0x30000000
-#define bFrame_TH_2 0x7
-#define bFrame_GI2_TH 0x38
-#define bGI2_Sync_en 0x40
-#define bSarch_Short_Early 0x300
-#define bSarch_Short_Late 0xc00
-#define bSarch_GI2_Late 0x70000
-#define bCFOAntSum 0x1
-#define bCFOAcc 0x2
-#define bCFOStartOffset 0xc
-#define bCFOLookBack 0x70
-#define bCFOSumWeight 0x80
-#define bDAGCEnable 0x10000
-#define bTXIQImb_A 0x3ff
-#define bTXIQImb_B 0xfc00
-#define bTXIQImb_C 0x3f0000
-#define bTXIQImb_D 0xffc00000
-#define bTxIDCOffset 0xff
-#define bTxQDCOffset 0xff00
-#define bTxDFIRMode 0x10000
-#define bTxPesudoNoiseOn 0x4000000
-#define bTxPesudoNoise_A 0xff
-#define bTxPesudoNoise_B 0xff00
-#define bTxPesudoNoise_C 0xff0000
-#define bTxPesudoNoise_D 0xff000000
-#define bCCADropOption 0x20000
-#define bCCADropThres 0xfff00000
-#define bEDCCA_H 0xf
-#define bEDCCA_L 0xf0
-#define bLambda_ED 0x300
-#define bRxInitialGain 0x7f
-#define bRxAntDivEn 0x80
-#define bRxAGCAddressForLNA 0x7f00
-#define bRxHighPowerFlow 0x8000
-#define bRxAGCFreezeThres 0xc0000
-#define bRxFreezeStep_AGC1 0x300000
-#define bRxFreezeStep_AGC2 0xc00000
-#define bRxFreezeStep_AGC3 0x3000000
-#define bRxFreezeStep_AGC0 0xc000000
-#define bRxRssi_Cmp_En 0x10000000
-#define bRxQuickAGCEn 0x20000000
-#define bRxAGCFreezeThresMode 0x40000000
-#define bRxOverFlowCheckType 0x80000000
-#define bRxAGCShift 0x7f
-#define bTRSW_Tri_Only 0x80
-#define bPowerThres 0x300
-#define bRxAGCEn 0x1
-#define bRxAGCTogetherEn 0x2
-#define bRxAGCMin 0x4
-#define bRxHP_Ini 0x7
-#define bRxHP_TRLNA 0x70
-#define bRxHP_RSSI 0x700
-#define bRxHP_BBP1 0x7000
-#define bRxHP_BBP2 0x70000
-#define bRxHP_BBP3 0x700000
-#define bRSSI_H 0x7f0000
-#define bRSSI_Gen 0x7f000000
-#define bRxSettle_TRSW 0x7
-#define bRxSettle_LNA 0x38
-#define bRxSettle_RSSI 0x1c0
-#define bRxSettle_BBP 0xe00
-#define bRxSettle_RxHP 0x7000
-#define bRxSettle_AntSW_RSSI 0x38000
-#define bRxSettle_AntSW 0xc0000
-#define bRxProcessTime_DAGC 0x300000
-#define bRxSettle_HSSI 0x400000
-#define bRxProcessTime_BBPPW 0x800000
-#define bRxAntennaPowerShift 0x3000000
-#define bRSSITableSelect 0xc000000
-#define bRxHP_Final 0x7000000
-#define bRxHTSettle_BBP 0x7
-#define bRxHTSettle_HSSI 0x8
-#define bRxHTSettle_RxHP 0x70
-#define bRxHTSettle_BBPPW 0x80
-#define bRxHTSettle_Idle 0x300
-#define bRxHTSettle_Reserved 0x1c00
-#define bRxHTRxHPEn 0x8000
-#define bRxHTAGCFreezeThres 0x30000
-#define bRxHTAGCTogetherEn 0x40000
-#define bRxHTAGCMin 0x80000
-#define bRxHTAGCEn 0x100000
-#define bRxHTDAGCEn 0x200000
-#define bRxHTRxHP_BBP 0x1c00000
-#define bRxHTRxHP_Final 0xe0000000
-#define bRxPWRatioTH 0x3
-#define bRxPWRatioEn 0x4
-#define bRxMFHold 0x3800
-#define bRxPD_Delay_TH1 0x38
-#define bRxPD_Delay_TH2 0x1c0
-#define bRxPD_DC_COUNT_MAX 0x600
-#define bRxPD_Delay_TH 0x8000
-#define bRxProcess_Delay 0xf0000
-#define bRxSearchrange_GI2_Early 0x700000
-#define bRxFrame_Guard_Counter_L 0x3800000
-#define bRxSGI_Guard_L 0xc000000
-#define bRxSGI_Search_L 0x30000000
-#define bRxSGI_TH 0xc0000000
-#define bDFSCnt0 0xff
-#define bDFSCnt1 0xff00
-#define bDFSFlag 0xf0000
-
-#define bMFWeightSum 0x300000
-#define bMinIdxTH 0x7f000000
-
-#define bDAFormat 0x40000
-
-#define bTxChEmuEnable 0x01000000
-
-#define bTRSWIsolation_A 0x7f
-#define bTRSWIsolation_B 0x7f00
-#define bTRSWIsolation_C 0x7f0000
-#define bTRSWIsolation_D 0x7f000000
-
-#define bExtLNAGain 0x7c00
-
-#define bSTBCEn 0x4
-#define bAntennaMapping 0x10
-#define bNss 0x20
-#define bCFOAntSumD 0x200
-#define bPHYCounterReset 0x8000000
-#define bCFOReportGet 0x4000000
-#define bOFDMContinueTx 0x10000000
-#define bOFDMSingleCarrier 0x20000000
-#define bOFDMSingleTone 0x40000000
-#define bHTDetect 0x100
-#define bCFOEn 0x10000
-#define bCFOValue 0xfff00000
-#define bSigTone_Re 0x3f
-#define bSigTone_Im 0x7f00
-#define bCounter_CCA 0xffff
-#define bCounter_ParityFail 0xffff0000
-#define bCounter_RateIllegal 0xffff
-#define bCounter_CRC8Fail 0xffff0000
-#define bCounter_MCSNoSupport 0xffff
-#define bCounter_FastSync 0xffff
-#define bShortCFO 0xfff
-#define bShortCFOTLength 12
-#define bShortCFOFLength 11
-#define bLongCFO 0x7ff
-#define bLongCFOTLength 11
-#define bLongCFOFLength 11
-#define bTailCFO 0x1fff
-#define bTailCFOTLength 13
-#define bTailCFOFLength 12
-
-#define bmax_en_pwdB 0xffff
-#define bCC_power_dB 0xffff0000
-#define bnoise_pwdB 0xffff
-#define bPowerMeasTLength 10
-#define bPowerMeasFLength 3
-#define bRx_HT_BW 0x1
-#define bRxSC 0x6
-#define bRx_HT 0x8
-
-#define bNB_intf_det_on 0x1
-#define bIntf_win_len_cfg 0x30
-#define bNB_Intf_TH_cfg 0x1c0
-
-#define bRFGain 0x3f
-#define bTableSel 0x40
-#define bTRSW 0x80
-
-#define bRxSNR_A 0xff
-#define bRxSNR_B 0xff00
-#define bRxSNR_C 0xff0000
-#define bRxSNR_D 0xff000000
-#define bSNREVMTLength 8
-#define bSNREVMFLength 1
-
-#define bCSI1st 0xff
-#define bCSI2nd 0xff00
-#define bRxEVM1st 0xff0000
-#define bRxEVM2nd 0xff000000
-
-#define bSIGEVM 0xff
-#define bPWDB 0xff00
-#define bSGIEN 0x10000
-
-#define bSFactorQAM1 0xf
-#define bSFactorQAM2 0xf0
-#define bSFactorQAM3 0xf00
-#define bSFactorQAM4 0xf000
-#define bSFactorQAM5 0xf0000
-#define bSFactorQAM6 0xf0000
-#define bSFactorQAM7 0xf00000
-#define bSFactorQAM8 0xf000000
-#define bSFactorQAM9 0xf0000000
-#define bCSIScheme 0x100000
-
-#define bNoiseLvlTopSet 0x3
-#define bChSmooth 0x4
-#define bChSmoothCfg1 0x38
-#define bChSmoothCfg2 0x1c0
-#define bChSmoothCfg3 0xe00
-#define bChSmoothCfg4 0x7000
-#define bMRCMode 0x800000
-#define bTHEVMCfg 0x7000000
-
-#define bLoopFitType 0x1
-#define bUpdCFO 0x40
-#define bUpdCFOOffData 0x80
-#define bAdvUpdCFO 0x100
-#define bAdvTimeCtrl 0x800
-#define bUpdClko 0x1000
-#define bFC 0x6000
-#define bTrackingMode 0x8000
-#define bPhCmpEnable 0x10000
-#define bUpdClkoLTF 0x20000
-#define bComChCFO 0x40000
-#define bCSIEstiMode 0x80000
-#define bAdvUpdEqz 0x100000
-#define bUChCfg 0x7000000
-#define bUpdEqz 0x8000000
-
-#define bTxAGCRate18_06 0x7f7f7f7f
-#define bTxAGCRate54_24 0x7f7f7f7f
+#define bCCKFACounterFreeze 0x4000
+
+#define bCCKTxPathSel 0x10000000
+#define bCCKDefaultRxPath 0xc000000
+#define bCCKOptionRxPath 0x3000000
+
+/* Page c */
+#define bNumOfSTF 0x3
+#define bShift_L 0xc0
+#define bGI_TH 0xc
+#define bRxPathA 0x1
+#define bRxPathB 0x2
+#define bRxPathC 0x4
+#define bRxPathD 0x8
+#define bTxPathA 0x1
+#define bTxPathB 0x2
+#define bTxPathC 0x4
+#define bTxPathD 0x8
+#define bTRSSIFreq 0x200
+#define bADCBackoff 0x3000
+#define bDFIRBackoff 0xc000
+#define bTRSSILatchPhase 0x10000
+#define bRxIDCOffset 0xff
+#define bRxQDCOffset 0xff00
+#define bRxDFIRMode 0x1800000
+#define bRxDCNFType 0xe000000
+#define bRXIQImb_A 0x3ff
+#define bRXIQImb_B 0xfc00
+#define bRXIQImb_C 0x3f0000
+#define bRXIQImb_D 0xffc00000
+#define bDC_dc_Notch 0x60000
+#define bRxNBINotch 0x1f000000
+#define bPD_TH 0xf
+#define bPD_TH_Opt2 0xc000
+#define bPWED_TH 0x700
+#define bIfMF_Win_L 0x800
+#define bPD_Option 0x1000
+#define bMF_Win_L 0xe000
+#define bBW_Search_L 0x30000
+#define bwin_enh_L 0xc0000
+#define bBW_TH 0x700000
+#define bED_TH2 0x3800000
+#define bBW_option 0x4000000
+#define bRatio_TH 0x18000000
+#define bWindow_L 0xe0000000
+#define bSBD_Option 0x1
+#define bFrame_TH 0x1c
+#define bFS_Option 0x60
+#define bDC_Slope_check 0x80
+#define bFGuard_Counter_DC_L 0xe00
+#define bFrame_Weight_Short 0x7000
+#define bSub_Tune 0xe00000
+#define bFrame_DC_Length 0xe000000
+#define bSBD_start_offset 0x30000000
+#define bFrame_TH_2 0x7
+#define bFrame_GI2_TH 0x38
+#define bGI2_Sync_en 0x40
+#define bSarch_Short_Early 0x300
+#define bSarch_Short_Late 0xc00
+#define bSarch_GI2_Late 0x70000
+#define bCFOAntSum 0x1
+#define bCFOAcc 0x2
+#define bCFOStartOffset 0xc
+#define bCFOLookBack 0x70
+#define bCFOSumWeight 0x80
+#define bDAGCEnable 0x10000
+#define bTXIQImb_A 0x3ff
+#define bTXIQImb_B 0xfc00
+#define bTXIQImb_C 0x3f0000
+#define bTXIQImb_D 0xffc00000
+#define bTxIDCOffset 0xff
+#define bTxQDCOffset 0xff00
+#define bTxDFIRMode 0x10000
+#define bTxPesudoNoiseOn 0x4000000
+#define bTxPesudoNoise_A 0xff
+#define bTxPesudoNoise_B 0xff00
+#define bTxPesudoNoise_C 0xff0000
+#define bTxPesudoNoise_D 0xff000000
+#define bCCADropOption 0x20000
+#define bCCADropThres 0xfff00000
+#define bEDCCA_H 0xf
+#define bEDCCA_L 0xf0
+#define bLambda_ED 0x300
+#define bRxInitialGain 0x7f
+#define bRxAntDivEn 0x80
+#define bRxAGCAddressForLNA 0x7f00
+#define bRxHighPowerFlow 0x8000
+#define bRxAGCFreezeThres 0xc0000
+#define bRxFreezeStep_AGC1 0x300000
+#define bRxFreezeStep_AGC2 0xc00000
+#define bRxFreezeStep_AGC3 0x3000000
+#define bRxFreezeStep_AGC0 0xc000000
+#define bRxRssi_Cmp_En 0x10000000
+#define bRxQuickAGCEn 0x20000000
+#define bRxAGCFreezeThresMode 0x40000000
+#define bRxOverFlowCheckType 0x80000000
+#define bRxAGCShift 0x7f
+#define bTRSW_Tri_Only 0x80
+#define bPowerThres 0x300
+#define bRxAGCEn 0x1
+#define bRxAGCTogetherEn 0x2
+#define bRxAGCMin 0x4
+#define bRxHP_Ini 0x7
+#define bRxHP_TRLNA 0x70
+#define bRxHP_RSSI 0x700
+#define bRxHP_BBP1 0x7000
+#define bRxHP_BBP2 0x70000
+#define bRxHP_BBP3 0x700000
+/* The threshold for high power */
+#define bRSSI_H 0x7f0000
+/* The threshold for ant diversity */
+#define bRSSI_Gen 0x7f000000
+#define bRxSettle_TRSW 0x7
+#define bRxSettle_LNA 0x38
+#define bRxSettle_RSSI 0x1c0
+#define bRxSettle_BBP 0xe00
+#define bRxSettle_RxHP 0x7000
+#define bRxSettle_AntSW_RSSI 0x38000
+#define bRxSettle_AntSW 0xc0000
+#define bRxProcessTime_DAGC 0x300000
+#define bRxSettle_HSSI 0x400000
+#define bRxProcessTime_BBPPW 0x800000
+#define bRxAntennaPowerShift 0x3000000
+#define bRSSITableSelect 0xc000000
+#define bRxHP_Final 0x7000000
+#define bRxHTSettle_BBP 0x7
+#define bRxHTSettle_HSSI 0x8
+#define bRxHTSettle_RxHP 0x70
+#define bRxHTSettle_BBPPW 0x80
+#define bRxHTSettle_Idle 0x300
+#define bRxHTSettle_Reserved 0x1c00
+#define bRxHTRxHPEn 0x8000
+#define bRxHTAGCFreezeThres 0x30000
+#define bRxHTAGCTogetherEn 0x40000
+#define bRxHTAGCMin 0x80000
+#define bRxHTAGCEn 0x100000
+#define bRxHTDAGCEn 0x200000
+#define bRxHTRxHP_BBP 0x1c00000
+#define bRxHTRxHP_Final 0xe0000000
+#define bRxPWRatioTH 0x3
+#define bRxPWRatioEn 0x4
+#define bRxMFHold 0x3800
+#define bRxPD_Delay_TH1 0x38
+#define bRxPD_Delay_TH2 0x1c0
+#define bRxPD_DC_COUNT_MAX 0x600
+/*#define bRxMF_Hold 0x3800*/
+#define bRxPD_Delay_TH 0x8000
+#define bRxProcess_Delay 0xf0000
+#define bRxSearchrange_GI2_Early 0x700000
+#define bRxFrame_Guard_Counter_L 0x3800000
+#define bRxSGI_Guard_L 0xc000000
+#define bRxSGI_Search_L 0x30000000
+#define bRxSGI_TH 0xc0000000
+#define bDFSCnt0 0xff
+#define bDFSCnt1 0xff00
+#define bDFSFlag 0xf0000
+
+#define bMFWeightSum 0x300000
+#define bMinIdxTH 0x7f000000
+
+#define bDAFormat 0x40000
+
+#define bTxChEmuEnable 0x01000000
+
+#define bTRSWIsolation_A 0x7f
+#define bTRSWIsolation_B 0x7f00
+#define bTRSWIsolation_C 0x7f0000
+#define bTRSWIsolation_D 0x7f000000
+
+#define bExtLNAGain 0x7c00
+
+/* Page d */
+#define bSTBCEn 0x4
+#define bAntennaMapping 0x10
+#define bNss 0x20
+#define bCFOAntSumD 0x200
+#define bPHYCounterReset 0x8000000
+#define bCFOReportGet 0x4000000
+#define bOFDMContinueTx 0x10000000
+#define bOFDMSingleCarrier 0x20000000
+#define bOFDMSingleTone 0x40000000
+/* #define bRxPath1 0x01
+ * #define bRxPath2 0x02
+ * #define bRxPath3 0x04
+ * #define bRxPath4 0x08
+ * #define bTxPath1 0x10
+ * #define bTxPath2 0x20
+*/
+#define bHTDetect 0x100
+#define bCFOEn 0x10000
+#define bCFOValue 0xfff00000
+#define bSigTone_Re 0x3f
+#define bSigTone_Im 0x7f00
+#define bCounter_CCA 0xffff
+#define bCounter_ParityFail 0xffff0000
+#define bCounter_RateIllegal 0xffff
+#define bCounter_CRC8Fail 0xffff0000
+#define bCounter_MCSNoSupport 0xffff
+#define bCounter_FastSync 0xffff
+#define bShortCFO 0xfff
+#define bShortCFOTLength 12 /* total */
+#define bShortCFOFLength 11 /* fraction */
+#define bLongCFO 0x7ff
+#define bLongCFOTLength 11
+#define bLongCFOFLength 11
+#define bTailCFO 0x1fff
+#define bTailCFOTLength 13
+#define bTailCFOFLength 12
+
+#define bmax_en_pwdB 0xffff
+#define bCC_power_dB 0xffff0000
+#define bnoise_pwdB 0xffff
+#define bPowerMeasTLength 10
+#define bPowerMeasFLength 3
+#define bRx_HT_BW 0x1
+#define bRxSC 0x6
+#define bRx_HT 0x8
+
+#define bNB_intf_det_on 0x1
+#define bIntf_win_len_cfg 0x30
+#define bNB_Intf_TH_cfg 0x1c0
+
+#define bRFGain 0x3f
+#define bTableSel 0x40
+#define bTRSW 0x80
+
+#define bRxSNR_A 0xff
+#define bRxSNR_B 0xff00
+#define bRxSNR_C 0xff0000
+#define bRxSNR_D 0xff000000
+#define bSNREVMTLength 8
+#define bSNREVMFLength 1
+
+#define bCSI1st 0xff
+#define bCSI2nd 0xff00
+#define bRxEVM1st 0xff0000
+#define bRxEVM2nd 0xff000000
+
+#define bSIGEVM 0xff
+#define bPWDB 0xff00
+#define bSGIEN 0x10000
+
+#define bSFactorQAM1 0xf
+#define bSFactorQAM2 0xf0
+#define bSFactorQAM3 0xf00
+#define bSFactorQAM4 0xf000
+#define bSFactorQAM5 0xf0000
+#define bSFactorQAM6 0xf0000
+#define bSFactorQAM7 0xf00000
+#define bSFactorQAM8 0xf000000
+#define bSFactorQAM9 0xf0000000
+#define bCSIScheme 0x100000
+
+#define bNoiseLvlTopSet 0x3
+#define bChSmooth 0x4
+#define bChSmoothCfg1 0x38
+#define bChSmoothCfg2 0x1c0
+#define bChSmoothCfg3 0xe00
+#define bChSmoothCfg4 0x7000
+#define bMRCMode 0x800000
+#define bTHEVMCfg 0x7000000
+
+#define bLoopFitType 0x1
+#define bUpdCFO 0x40
+#define bUpdCFOOffData 0x80
+#define bAdvUpdCFO 0x100
+#define bAdvTimeCtrl 0x800
+#define bUpdClko 0x1000
+#define bFC 0x6000
+#define bTrackingMode 0x8000
+#define bPhCmpEnable 0x10000
+#define bUpdClkoLTF 0x20000
+#define bComChCFO 0x40000
+#define bCSIEstiMode 0x80000
+#define bAdvUpdEqz 0x100000
+#define bUChCfg 0x7000000
+#define bUpdEqz 0x8000000
+
+/* Page e */
+#define bTxAGCRate18_06 0x7f7f7f7f
+#define bTxAGCRate54_24 0x7f7f7f7f
#define bTxAGCRateMCS32 0x7f
-#define bTxAGCRateCCK 0x7f00
+#define bTxAGCRateCCK 0x7f00
#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f
#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f
#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f
#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f
-
-#define bRxPesudoNoiseOn 0x20000000
-#define bRxPesudoNoise_A 0xff
-#define bRxPesudoNoise_B 0xff00
-#define bRxPesudoNoise_C 0xff0000
-#define bRxPesudoNoise_D 0xff000000
-#define bPesudoNoiseState_A 0xffff
-#define bPesudoNoiseState_B 0xffff0000
-#define bPesudoNoiseState_C 0xffff
-#define bPesudoNoiseState_D 0xffff0000
-
-#define bZebra1_HSSIEnable 0x8
-#define bZebra1_TRxControl 0xc00
-#define bZebra1_TRxGainSetting 0x07f
-#define bZebra1_RxCorner 0xc00
-#define bZebra1_TxChargePump 0x38
-#define bZebra1_RxChargePump 0x7
-#define bZebra1_ChannelNum 0xf80
-#define bZebra1_TxLPFBW 0x400
-#define bZebra1_RxLPFBW 0x600
-
-#define bRTL8256RegModeCtrl1 0x100
-#define bRTL8256RegModeCtrl0 0x40
-#define bRTL8256_TxLPFBW 0x18
-#define bRTL8256_RxLPFBW 0x600
-
-#define bRTL8258_TxLPFBW 0xc
-#define bRTL8258_RxLPFBW 0xc00
-#define bRTL8258_RSSILPFBW 0xc0
-
-#define bByte0 0x1
-#define bByte1 0x2
-#define bByte2 0x4
-#define bByte3 0x8
-#define bWord0 0x3
-#define bWord1 0xc
-#define bDWord 0xf
-
-#define bMaskByte0 0xff
-#define bMaskByte1 0xff00
-#define bMaskByte2 0xff0000
-#define bMaskByte3 0xff000000
-#define bMaskHWord 0xffff0000
-#define bMaskLWord 0x0000ffff
-#define bMaskDWord 0xffffffff
-
-#define bMask12Bits 0xfff
-
-#define bEnable 0x1
-#define bDisable 0x0
-
-#define LeftAntenna 0x0
-#define RightAntenna 0x1
-
-#define tCheckTxStatus 500
-#define tUpdateRxCounter 100
-
-#define rateCCK 0
-#define rateOFDM 1
-#define rateHT 2
-
-#define bPMAC_End 0x1ff
-#define bFPGAPHY0_End 0x8ff
-#define bFPGAPHY1_End 0x9ff
-#define bCCKPHY0_End 0xaff
-#define bOFDMPHY0_End 0xcff
-#define bOFDMPHY1_End 0xdff
-
-
-#define bPMACControl 0x0
-#define bWMACControl 0x1
-#define bWNICControl 0x2
-
-#define PathA 0x0
-#define PathB 0x1
-#define PathC 0x2
-#define PathD 0x3
-
-#define rRTL8256RxMixerPole 0xb
-#define bZebraRxMixerPole 0x6
-#define rRTL8256TxBBOPBias 0x9
-#define bRTL8256TxBBOPBias 0x400
-#define rRTL8256TxBBBW 19
-#define bRTL8256TxBBBW 0x18
+#define bRxPesudoNoiseOn 0x20000000 /* Rx Pseduo noise */
+#define bRxPesudoNoise_A 0xff
+#define bRxPesudoNoise_B 0xff00
+#define bRxPesudoNoise_C 0xff0000
+#define bRxPesudoNoise_D 0xff000000
+#define bPesudoNoiseState_A 0xffff
+#define bPesudoNoiseState_B 0xffff0000
+#define bPesudoNoiseState_C 0xffff
+#define bPesudoNoiseState_D 0xffff0000
+
+/* RF Zebra 1 */
+#define bZebra1_HSSIEnable 0x8
+#define bZebra1_TRxControl 0xc00
+#define bZebra1_TRxGainSetting 0x07f
+#define bZebra1_RxCorner 0xc00
+#define bZebra1_TxChargePump 0x38
+#define bZebra1_RxChargePump 0x7
+#define bZebra1_ChannelNum 0xf80
+#define bZebra1_TxLPFBW 0x400
+#define bZebra1_RxLPFBW 0x600
+
+/* Zebra4 */
+#define bRTL8256RegModeCtrl1 0x100
+#define bRTL8256RegModeCtrl0 0x40
+#define bRTL8256_TxLPFBW 0x18
+#define bRTL8256_RxLPFBW 0x600
+
+/* RTL8258 */
+#define bRTL8258_TxLPFBW 0xc
+#define bRTL8258_RxLPFBW 0xc00
+#define bRTL8258_RSSILPFBW 0xc0
+
+/* byte enable for sb_write */
+#define bByte0 0x1
+#define bByte1 0x2
+#define bByte2 0x4
+#define bByte3 0x8
+#define bWord0 0x3
+#define bWord1 0xc
+#define bDWord 0xf
+
+/* for PutRegsetting & GetRegSetting BitMask */
+#define bMaskByte0 0xff
+#define bMaskByte1 0xff00
+#define bMaskByte2 0xff0000
+#define bMaskByte3 0xff000000
+#define bMaskHWord 0xffff0000
+#define bMaskLWord 0x0000ffff
+#define bMaskDWord 0xffffffff
+
+/* for PutRFRegsetting & GetRFRegSetting BitMask */
+#define bMask12Bits 0xfff
+
+#define bEnable 0x1
+#define bDisable 0x0
+
+#define LeftAntenna 0x0
+#define RightAntenna 0x1
+
+#define tCheckTxStatus 500 /* 500 ms */
+#define tUpdateRxCounter 100 /* 100 ms */
+
+#define rateCCK 0
+#define rateOFDM 1
+#define rateHT 2
+
+#define bPMAC_End 0x1ff /* define Register-End */
+#define bFPGAPHY0_End 0x8ff
+#define bFPGAPHY1_End 0x9ff
+#define bCCKPHY0_End 0xaff
+#define bOFDMPHY0_End 0xcff
+#define bOFDMPHY1_End 0xdff
+
+
+#define bPMACControl 0x0
+#define bWMACControl 0x1
+#define bWNICControl 0x2
+
+#define PathA 0x0
+#define PathB 0x1
+#define PathC 0x2
+#define PathD 0x3
+
+#define rRTL8256RxMixerPole 0xb
+#define bZebraRxMixerPole 0x6
+#define rRTL8256TxBBOPBias 0x9
+#define bRTL8256TxBBOPBias 0x400
+#define rRTL8256TxBBBW 19
+#define bRTL8256TxBBBW 0x18
#endif
diff --git a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h b/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
deleted file mode 100644
index 03eee3d059c6f6..00000000000000
--- a/drivers/staging/rtl8192e/rtl8192e/r819xE_phyreg.h
+++ /dev/null
@@ -1,908 +0,0 @@
-#ifndef _R819XU_PHYREG_H
-#define _R819XU_PHYREG_H
-
-
-#define RF_DATA 0x1d4 // FW will write RF data in the register.
-
-//Register //duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF
-//page 1
-#define rPMAC_Reset 0x100
-#define rPMAC_TxStart 0x104
-#define rPMAC_TxLegacySIG 0x108
-#define rPMAC_TxHTSIG1 0x10c
-#define rPMAC_TxHTSIG2 0x110
-#define rPMAC_PHYDebug 0x114
-#define rPMAC_TxPacketNum 0x118
-#define rPMAC_TxIdle 0x11c
-#define rPMAC_TxMACHeader0 0x120
-#define rPMAC_TxMACHeader1 0x124
-#define rPMAC_TxMACHeader2 0x128
-#define rPMAC_TxMACHeader3 0x12c
-#define rPMAC_TxMACHeader4 0x130
-#define rPMAC_TxMACHeader5 0x134
-#define rPMAC_TxDataType 0x138
-#define rPMAC_TxRandomSeed 0x13c
-#define rPMAC_CCKPLCPPreamble 0x140
-#define rPMAC_CCKPLCPHeader 0x144
-#define rPMAC_CCKCRC16 0x148
-#define rPMAC_OFDMRxCRC32OK 0x170
-#define rPMAC_OFDMRxCRC32Er 0x174
-#define rPMAC_OFDMRxParityEr 0x178
-#define rPMAC_OFDMRxCRC8Er 0x17c
-#define rPMAC_CCKCRxRC16Er 0x180
-#define rPMAC_CCKCRxRC32Er 0x184
-#define rPMAC_CCKCRxRC32OK 0x188
-#define rPMAC_TxStatus 0x18c
-
-//90P
-#define MCS_TXAGC 0x340 // MCS AGC
-#define CCK_TXAGC 0x348 // CCK AGC
-
-#define MacBlkCtrl 0x403 // Mac block on/off control register
-
-//page8
-#define rFPGA0_RFMOD 0x800 //RF mode & CCK TxSC
-#define rFPGA0_TxInfo 0x804
-#define rFPGA0_PSDFunction 0x808
-#define rFPGA0_TxGainStage 0x80c
-#define rFPGA0_RFTiming1 0x810
-#define rFPGA0_RFTiming2 0x814
-//#define rFPGA0_XC_RFTiming 0x818
-//#define rFPGA0_XD_RFTiming 0x81c
-#define rFPGA0_XA_HSSIParameter1 0x820
-#define rFPGA0_XA_HSSIParameter2 0x824
-#define rFPGA0_XB_HSSIParameter1 0x828
-#define rFPGA0_XB_HSSIParameter2 0x82c
-#define rFPGA0_XC_HSSIParameter1 0x830
-#define rFPGA0_XC_HSSIParameter2 0x834
-#define rFPGA0_XD_HSSIParameter1 0x838
-#define rFPGA0_XD_HSSIParameter2 0x83c
-#define rFPGA0_XA_LSSIParameter 0x840
-#define rFPGA0_XB_LSSIParameter 0x844
-#define rFPGA0_XC_LSSIParameter 0x848
-#define rFPGA0_XD_LSSIParameter 0x84c
-#define rFPGA0_RFWakeUpParameter 0x850
-#define rFPGA0_RFSleepUpParameter 0x854
-#define rFPGA0_XAB_SwitchControl 0x858
-#define rFPGA0_XCD_SwitchControl 0x85c
-#define rFPGA0_XA_RFInterfaceOE 0x860
-#define rFPGA0_XB_RFInterfaceOE 0x864
-#define rFPGA0_XC_RFInterfaceOE 0x868
-#define rFPGA0_XD_RFInterfaceOE 0x86c
-#define rFPGA0_XAB_RFInterfaceSW 0x870
-#define rFPGA0_XCD_RFInterfaceSW 0x874
-#define rFPGA0_XAB_RFParameter 0x878
-#define rFPGA0_XCD_RFParameter 0x87c
-#define rFPGA0_AnalogParameter1 0x880
-#define rFPGA0_AnalogParameter2 0x884
-#define rFPGA0_AnalogParameter3 0x888
-#define rFPGA0_AnalogParameter4 0x88c
-#define rFPGA0_XA_LSSIReadBack 0x8a0
-#define rFPGA0_XB_LSSIReadBack 0x8a4
-#define rFPGA0_XC_LSSIReadBack 0x8a8
-#define rFPGA0_XD_LSSIReadBack 0x8ac
-#define rFPGA0_PSDReport 0x8b4
-#define rFPGA0_XAB_RFInterfaceRB 0x8e0
-#define rFPGA0_XCD_RFInterfaceRB 0x8e4
-
-/* Page 9 - RF mode & OFDM TxSC */
-#define rFPGA1_RFMOD 0x900
-#define rFPGA1_TxBlock 0x904
-#define rFPGA1_DebugSelect 0x908
-#define rFPGA1_TxInfo 0x90c
-
-/* Page a */
-#define rCCK0_System 0xa00
-#define rCCK0_AFESetting 0xa04
-#define rCCK0_CCA 0xa08
-/* AGC default value, saturation level */
-#define rCCK0_RxAGC1 0xa0c
-/* AGC & DAGC */
-#define rCCK0_RxAGC2 0xa10
-#define rCCK0_RxHP 0xa14
-/* Timing recovery & channel estimation threshold */
-#define rCCK0_DSPParameter1 0xa18
-/* SQ threshold */
-#define rCCK0_DSPParameter2 0xa1c
-#define rCCK0_TxFilter1 0xa20
-#define rCCK0_TxFilter2 0xa24
-/* Debug port and TX filter 3 */
-#define rCCK0_DebugPort 0xa28
-#define rCCK0_FalseAlarmReport 0xa2c
-#define rCCK0_TRSSIReport 0xa50
-#define rCCK0_RxReport 0xa54
-#define rCCK0_FACounterLower 0xa5c
-#define rCCK0_FACounterUpper 0xa58
-
-/* Page c */
-#define rOFDM0_LSTF 0xc00
-#define rOFDM0_TRxPathEnable 0xc04
-#define rOFDM0_TRMuxPar 0xc08
-#define rOFDM0_TRSWIsolation 0xc0c
-/* RxIQ DC offset, Rx digital filter, DC notch filter */
-#define rOFDM0_XARxAFE 0xc10
-/* RxIQ imblance matrix */
-#define rOFDM0_XARxIQImbalance 0xc14
-#define rOFDM0_XBRxAFE 0xc18
-#define rOFDM0_XBRxIQImbalance 0xc1c
-#define rOFDM0_XCRxAFE 0xc20
-#define rOFDM0_XCRxIQImbalance 0xc24
-#define rOFDM0_XDRxAFE 0xc28
-#define rOFDM0_XDRxIQImbalance 0xc2c
-/* PD, BW & SBD */
-#define rOFDM0_RxDetector1 0xc30
-/* SBD */
-#define rOFDM0_RxDetector2 0xc34
-/* Frame Sync */
-#define rOFDM0_RxDetector3 0xc38
-/* PD, SBD, Frame Sync & Short-GI */
-#define rOFDM0_RxDetector4 0xc3c
-/* Rx Sync Path */
-#define rOFDM0_RxDSP 0xc40
-/* CFO & DAGC */
-#define rOFDM0_CFOandDAGC 0xc44
-/* CCA Drop threshold */
-#define rOFDM0_CCADropThreshold 0xc48
-/* Energy CCA */
-#define rOFDM0_ECCAThreshold 0xc4c
-#define rOFDM0_XAAGCCore1 0xc50
-#define rOFDM0_XAAGCCore2 0xc54
-#define rOFDM0_XBAGCCore1 0xc58
-#define rOFDM0_XBAGCCore2 0xc5c
-#define rOFDM0_XCAGCCore1 0xc60
-#define rOFDM0_XCAGCCore2 0xc64
-#define rOFDM0_XDAGCCore1 0xc68
-#define rOFDM0_XDAGCCore2 0xc6c
-#define rOFDM0_AGCParameter1 0xc70
-#define rOFDM0_AGCParameter2 0xc74
-#define rOFDM0_AGCRSSITable 0xc78
-#define rOFDM0_HTSTFAGC 0xc7c
-#define rOFDM0_XATxIQImbalance 0xc80
-#define rOFDM0_XATxAFE 0xc84
-#define rOFDM0_XBTxIQImbalance 0xc88
-#define rOFDM0_XBTxAFE 0xc8c
-#define rOFDM0_XCTxIQImbalance 0xc90
-#define rOFDM0_XCTxAFE 0xc94
-#define rOFDM0_XDTxIQImbalance 0xc98
-#define rOFDM0_XDTxAFE 0xc9c
-#define rOFDM0_RxHPParameter 0xce0
-#define rOFDM0_TxPseudoNoiseWgt 0xce4
-#define rOFDM0_FrameSync 0xcf0
-#define rOFDM0_DFSReport 0xcf4
-#define rOFDM0_TxCoeff1 0xca4
-#define rOFDM0_TxCoeff2 0xca8
-#define rOFDM0_TxCoeff3 0xcac
-#define rOFDM0_TxCoeff4 0xcb0
-#define rOFDM0_TxCoeff5 0xcb4
-#define rOFDM0_TxCoeff6 0xcb8
-
-
-/* Page d */
-#define rOFDM1_LSTF 0xd00
-#define rOFDM1_TRxPathEnable 0xd04
-#define rOFDM1_CFO 0xd08
-#define rOFDM1_CSI1 0xd10
-#define rOFDM1_SBD 0xd14
-#define rOFDM1_CSI2 0xd18
-#define rOFDM1_CFOTracking 0xd2c
-#define rOFDM1_TRxMesaure1 0xd34
-#define rOFDM1_IntfDet 0xd3c
-#define rOFDM1_PseudoNoiseStateAB 0xd50
-#define rOFDM1_PseudoNoiseStateCD 0xd54
-#define rOFDM1_RxPseudoNoiseWgt 0xd58
-/* cca, parity fail */
-#define rOFDM_PHYCounter1 0xda0
-/* rate illegal, crc8 fail */
-#define rOFDM_PHYCounter2 0xda4
-/* MCS not supported */
-#define rOFDM_PHYCounter3 0xda8
-#define rOFDM_ShortCFOAB 0xdac
-#define rOFDM_ShortCFOCD 0xdb0
-#define rOFDM_LongCFOAB 0xdb4
-#define rOFDM_LongCFOCD 0xdb8
-#define rOFDM_TailCFOAB 0xdbc
-#define rOFDM_TailCFOCD 0xdc0
-#define rOFDM_PWMeasure1 0xdc4
-#define rOFDM_PWMeasure2 0xdc8
-#define rOFDM_BWReport 0xdcc
-#define rOFDM_AGCReport 0xdd0
-#define rOFDM_RxSNR 0xdd4
-#define rOFDM_RxEVMCSI 0xdd8
-#define rOFDM_SIGReport 0xddc
-
-/* Page e */
-#define rTxAGC_Rate18_06 0xe00
-#define rTxAGC_Rate54_24 0xe04
-#define rTxAGC_CCK_Mcs32 0xe08
-#define rTxAGC_Mcs03_Mcs00 0xe10
-#define rTxAGC_Mcs07_Mcs04 0xe14
-#define rTxAGC_Mcs11_Mcs08 0xe18
-#define rTxAGC_Mcs15_Mcs12 0xe1c
-
-
-/* RF Zebra 1 */
-#define rZebra1_HSSIEnable 0x0
-#define rZebra1_TRxEnable1 0x1
-#define rZebra1_TRxEnable2 0x2
-#define rZebra1_AGC 0x4
-#define rZebra1_ChargePump 0x5
-#define rZebra1_Channel 0x7
-#define rZebra1_TxGain 0x8
-#define rZebra1_TxLPF 0x9
-#define rZebra1_RxLPF 0xb
-#define rZebra1_RxHPFCorner 0xc
-
-/* Zebra 4 */
-#define rGlobalCtrl 0
-#define rRTL8256_TxLPF 19
-#define rRTL8256_RxLPF 11
-
-/* RTL8258 */
-#define rRTL8258_TxLPF 0x11
-#define rRTL8258_RxLPF 0x13
-#define rRTL8258_RSSILPF 0xa
-
-/* Bit Mask */
-/* Page 1 */
-#define bBBResetB 0x100
-#define bGlobalResetB 0x200
-#define bOFDMTxStart 0x4
-#define bCCKTxStart 0x8
-#define bCRC32Debug 0x100
-#define bPMACLoopback 0x10
-#define bTxLSIG 0xffffff
-#define bOFDMTxRate 0xf
-#define bOFDMTxReserved 0x10
-#define bOFDMTxLength 0x1ffe0
-#define bOFDMTxParity 0x20000
-#define bTxHTSIG1 0xffffff
-#define bTxHTMCSRate 0x7f
-#define bTxHTBW 0x80
-#define bTxHTLength 0xffff00
-#define bTxHTSIG2 0xffffff
-#define bTxHTSmoothing 0x1
-#define bTxHTSounding 0x2
-#define bTxHTReserved 0x4
-#define bTxHTAggreation 0x8
-#define bTxHTSTBC 0x30
-#define bTxHTAdvanceCoding 0x40
-#define bTxHTShortGI 0x80
-#define bTxHTNumberHT_LTF 0x300
-#define bTxHTCRC8 0x3fc00
-#define bCounterReset 0x10000
-#define bNumOfOFDMTx 0xffff
-#define bNumOfCCKTx 0xffff0000
-#define bTxIdleInterval 0xffff
-#define bOFDMService 0xffff0000
-#define bTxMACHeader 0xffffffff
-#define bTxDataInit 0xff
-#define bTxHTMode 0x100
-#define bTxDataType 0x30000
-#define bTxRandomSeed 0xffffffff
-#define bCCKTxPreamble 0x1
-#define bCCKTxSFD 0xffff0000
-#define bCCKTxSIG 0xff
-#define bCCKTxService 0xff00
-#define bCCKLengthExt 0x8000
-#define bCCKTxLength 0xffff0000
-#define bCCKTxCRC16 0xffff
-#define bCCKTxStatus 0x1
-#define bOFDMTxStatus 0x2
-
-/* Page 8 */
-#define bRFMOD 0x1
-#define bJapanMode 0x2
-#define bCCKTxSC 0x30
-#define bCCKEn 0x1000000
-#define bOFDMEn 0x2000000
-#define bOFDMRxADCPhase 0x10000
-#define bOFDMTxDACPhase 0x40000
-#define bXATxAGC 0x3f
-#define bXBTxAGC 0xf00
-#define bXCTxAGC 0xf000
-#define bXDTxAGC 0xf0000
-#define bPAStart 0xf0000000
-#define bTRStart 0x00f00000
-#define bRFStart 0x0000f000
-#define bBBStart 0x000000f0
-#define bBBCCKStart 0x0000000f
-/* Reg x814 */
-#define bPAEnd 0xf
-#define bTREnd 0x0f000000
-#define bRFEnd 0x000f0000
-/* T2R */
-#define bCCAMask 0x000000f0
-#define bR2RCCAMask 0x00000f00
-#define bHSSI_R2TDelay 0xf8000000
-#define bHSSI_T2RDelay 0xf80000
-/* Channel gain at continue TX. */
-#define bContTxHSSI 0x400
-#define bIGFromCCK 0x200
-#define bAGCAddress 0x3f
-#define bRxHPTx 0x7000
-#define bRxHPT2R 0x38000
-#define bRxHPCCKIni 0xc0000
-#define bAGCTxCode 0xc00000
-#define bAGCRxCode 0x300000
-#define b3WireDataLength 0x800
-#define b3WireAddressLength 0x400
-#define b3WireRFPowerDown 0x1
-/*#define bHWSISelect 0x8 */
-#define b5GPAPEPolarity 0x40000000
-#define b2GPAPEPolarity 0x80000000
-#define bRFSW_TxDefaultAnt 0x3
-#define bRFSW_TxOptionAnt 0x30
-#define bRFSW_RxDefaultAnt 0x300
-#define bRFSW_RxOptionAnt 0x3000
-#define bRFSI_3WireData 0x1
-#define bRFSI_3WireClock 0x2
-#define bRFSI_3WireLoad 0x4
-#define bRFSI_3WireRW 0x8
-/* 3-wire total control */
-#define bRFSI_3Wire 0xf
-#define bRFSI_RFENV 0x10
-#define bRFSI_TRSW 0x20
-#define bRFSI_TRSWB 0x40
-#define bRFSI_ANTSW 0x100
-#define bRFSI_ANTSWB 0x200
-#define bRFSI_PAPE 0x400
-#define bRFSI_PAPE5G 0x800
-#define bBandSelect 0x1
-#define bHTSIG2_GI 0x80
-#define bHTSIG2_Smoothing 0x01
-#define bHTSIG2_Sounding 0x02
-#define bHTSIG2_Aggreaton 0x08
-#define bHTSIG2_STBC 0x30
-#define bHTSIG2_AdvCoding 0x40
-#define bHTSIG2_NumOfHTLTF 0x300
-#define bHTSIG2_CRC8 0x3fc
-#define bHTSIG1_MCS 0x7f
-#define bHTSIG1_BandWidth 0x80
-#define bHTSIG1_HTLength 0xffff
-#define bLSIG_Rate 0xf
-#define bLSIG_Reserved 0x10
-#define bLSIG_Length 0x1fffe
-#define bLSIG_Parity 0x20
-#define bCCKRxPhase 0x4
-/* LSSI "read" address */
-#define bLSSIReadAddress 0x3f000000
-/* LSSI "read" edge signal */
-#define bLSSIReadEdge 0x80000000
-#define bLSSIReadBackData 0xfff
-#define bLSSIReadOKFlag 0x1000
-/* 0: 44 MHz, 1: 88MHz */
-#define bCCKSampleRate 0x8
-
-#define bRegulator0Standby 0x1
-#define bRegulatorPLLStandby 0x2
-#define bRegulator1Standby 0x4
-#define bPLLPowerUp 0x8
-#define bDPLLPowerUp 0x10
-#define bDA10PowerUp 0x20
-#define bAD7PowerUp 0x200
-#define bDA6PowerUp 0x2000
-#define bXtalPowerUp 0x4000
-#define b40MDClkPowerUP 0x8000
-#define bDA6DebugMode 0x20000
-#define bDA6Swing 0x380000
-#define bADClkPhase 0x4000000
-#define b80MClkDelay 0x18000000
-#define bAFEWatchDogEnable 0x20000000
-#define bXtalCap 0x0f000000
-#define bXtalCap01 0xc0000000
-#define bXtalCap23 0x3
-#define bXtalCap92x 0x0f000000
-#define bIntDifClkEnable 0x400
-#define bExtSigClkEnable 0x800
-#define bBandgapMbiasPowerUp 0x10000
-#define bAD11SHGain 0xc0000
-#define bAD11InputRange 0x700000
-#define bAD11OPCurrent 0x3800000
-#define bIPathLoopback 0x4000000
-#define bQPathLoopback 0x8000000
-#define bAFELoopback 0x10000000
-#define bDA10Swing 0x7e0
-#define bDA10Reverse 0x800
-#define bDAClkSource 0x1000
-#define bAD7InputRange 0x6000
-#define bAD7Gain 0x38000
-#define bAD7OutputCMMode 0x40000
-#define bAD7InputCMMode 0x380000
-#define bAD7Current 0xc00000
-#define bRegulatorAdjust 0x7000000
-#define bAD11PowerUpAtTx 0x1
-#define bDA10PSAtTx 0x10
-#define bAD11PowerUpAtRx 0x100
-#define bDA10PSAtRx 0x1000
-
-#define bCCKRxAGCFormat 0x200
-
-#define bPSDFFTSamplepPoint 0xc000
-#define bPSDAverageNum 0x3000
-#define bIQPathControl 0xc00
-#define bPSDFreq 0x3ff
-#define bPSDAntennaPath 0x30
-#define bPSDIQSwitch 0x40
-#define bPSDRxTrigger 0x400000
-#define bPSDTxTrigger 0x80000000
-#define bPSDSineToneScale 0x7f000000
-#define bPSDReport 0xffff
-
-/* Page 8 */
-#define bOFDMTxSC 0x30000000
-#define bCCKTxOn 0x1
-#define bOFDMTxOn 0x2
-/* Reset debug page and also HWord, LWord */
-#define bDebugPage 0xfff
-/* Reset debug page and LWord */
-#define bDebugItem 0xff
-#define bAntL 0x10
-#define bAntNonHT 0x100
-#define bAntHT1 0x1000
-#define bAntHT2 0x10000
-#define bAntHT1S1 0x100000
-#define bAntNonHTS1 0x1000000
-
-/* Page a */
-#define bCCKBBMode 0x3
-#define bCCKTxPowerSaving 0x80
-#define bCCKRxPowerSaving 0x40
-#define bCCKSideBand 0x10
-#define bCCKScramble 0x8
-#define bCCKAntDiversity 0x8000
-#define bCCKCarrierRecovery 0x4000
-#define bCCKTxRate 0x3000
-#define bCCKDCCancel 0x0800
-#define bCCKISICancel 0x0400
-#define bCCKMatchFilter 0x0200
-#define bCCKEqualizer 0x0100
-#define bCCKPreambleDetect 0x800000
-#define bCCKFastFalseCCA 0x400000
-#define bCCKChEstStart 0x300000
-#define bCCKCCACount 0x080000
-#define bCCKcs_lim 0x070000
-#define bCCKBistMode 0x80000000
-#define bCCKCCAMask 0x40000000
-#define bCCKTxDACPhase 0x4
-/* r_rx_clk */
-#define bCCKRxADCPhase 0x20000000
-#define bCCKr_cp_mode0 0x0100
-#define bCCKTxDCOffset 0xf0
-#define bCCKRxDCOffset 0xf
-#define bCCKCCAMode 0xc000
-#define bCCKFalseCS_lim 0x3f00
-#define bCCKCS_ratio 0xc00000
-#define bCCKCorgBit_sel 0x300000
-#define bCCKPD_lim 0x0f0000
-#define bCCKNewCCA 0x80000000
-#define bCCKRxHPofIG 0x8000
-#define bCCKRxIG 0x7f00
-#define bCCKLNAPolarity 0x800000
-#define bCCKRx1stGain 0x7f0000
-/* CCK Rx Initial gain polarity */
-#define bCCKRFExtend 0x20000000
-#define bCCKRxAGCSatLevel 0x1f000000
-#define bCCKRxAGCSatCount 0xe0
-/* AGCSAmp_dly */
-#define bCCKRxRFSettle 0x1f
-#define bCCKFixedRxAGC 0x8000
-/*#define bCCKRxAGCFormat 0x4000 remove to HSSI register 0x824 */
-#define bCCKAntennaPolarity 0x2000
-#define bCCKTxFilterType 0x0c00
-#define bCCKRxAGCReportType 0x0300
-#define bCCKRxDAGCEn 0x80000000
-#define bCCKRxDAGCPeriod 0x20000000
-#define bCCKRxDAGCSatLevel 0x1f000000
-#define bCCKTimingRecovery 0x800000
-#define bCCKTxC0 0x3f0000
-#define bCCKTxC1 0x3f000000
-#define bCCKTxC2 0x3f
-#define bCCKTxC3 0x3f00
-#define bCCKTxC4 0x3f0000
-#define bCCKTxC5 0x3f000000
-#define bCCKTxC6 0x3f
-#define bCCKTxC7 0x3f00
-#define bCCKDebugPort 0xff0000
-#define bCCKDACDebug 0x0f000000
-#define bCCKFalseAlarmEnable 0x8000
-#define bCCKFalseAlarmRead 0x4000
-#define bCCKTRSSI 0x7f
-#define bCCKRxAGCReport 0xfe
-#define bCCKRxReport_AntSel 0x80000000
-#define bCCKRxReport_MFOff 0x40000000
-#define bCCKRxRxReport_SQLoss 0x20000000
-#define bCCKRxReport_Pktloss 0x10000000
-#define bCCKRxReport_Lockedbit 0x08000000
-#define bCCKRxReport_RateError 0x04000000
-#define bCCKRxReport_RxRate 0x03000000
-#define bCCKRxFACounterLower 0xff
-#define bCCKRxFACounterUpper 0xff000000
-#define bCCKRxHPAGCStart 0xe000
-#define bCCKRxHPAGCFinal 0x1c00
-
-#define bCCKRxFalseAlarmEnable 0x8000
-#define bCCKFACounterFreeze 0x4000
-
-#define bCCKTxPathSel 0x10000000
-#define bCCKDefaultRxPath 0xc000000
-#define bCCKOptionRxPath 0x3000000
-
-/* Page c */
-#define bNumOfSTF 0x3
-#define bShift_L 0xc0
-#define bGI_TH 0xc
-#define bRxPathA 0x1
-#define bRxPathB 0x2
-#define bRxPathC 0x4
-#define bRxPathD 0x8
-#define bTxPathA 0x1
-#define bTxPathB 0x2
-#define bTxPathC 0x4
-#define bTxPathD 0x8
-#define bTRSSIFreq 0x200
-#define bADCBackoff 0x3000
-#define bDFIRBackoff 0xc000
-#define bTRSSILatchPhase 0x10000
-#define bRxIDCOffset 0xff
-#define bRxQDCOffset 0xff00
-#define bRxDFIRMode 0x1800000
-#define bRxDCNFType 0xe000000
-#define bRXIQImb_A 0x3ff
-#define bRXIQImb_B 0xfc00
-#define bRXIQImb_C 0x3f0000
-#define bRXIQImb_D 0xffc00000
-#define bDC_dc_Notch 0x60000
-#define bRxNBINotch 0x1f000000
-#define bPD_TH 0xf
-#define bPD_TH_Opt2 0xc000
-#define bPWED_TH 0x700
-#define bIfMF_Win_L 0x800
-#define bPD_Option 0x1000
-#define bMF_Win_L 0xe000
-#define bBW_Search_L 0x30000
-#define bwin_enh_L 0xc0000
-#define bBW_TH 0x700000
-#define bED_TH2 0x3800000
-#define bBW_option 0x4000000
-#define bRatio_TH 0x18000000
-#define bWindow_L 0xe0000000
-#define bSBD_Option 0x1
-#define bFrame_TH 0x1c
-#define bFS_Option 0x60
-#define bDC_Slope_check 0x80
-#define bFGuard_Counter_DC_L 0xe00
-#define bFrame_Weight_Short 0x7000
-#define bSub_Tune 0xe00000
-#define bFrame_DC_Length 0xe000000
-#define bSBD_start_offset 0x30000000
-#define bFrame_TH_2 0x7
-#define bFrame_GI2_TH 0x38
-#define bGI2_Sync_en 0x40
-#define bSarch_Short_Early 0x300
-#define bSarch_Short_Late 0xc00
-#define bSarch_GI2_Late 0x70000
-#define bCFOAntSum 0x1
-#define bCFOAcc 0x2
-#define bCFOStartOffset 0xc
-#define bCFOLookBack 0x70
-#define bCFOSumWeight 0x80
-#define bDAGCEnable 0x10000
-#define bTXIQImb_A 0x3ff
-#define bTXIQImb_B 0xfc00
-#define bTXIQImb_C 0x3f0000
-#define bTXIQImb_D 0xffc00000
-#define bTxIDCOffset 0xff
-#define bTxQDCOffset 0xff00
-#define bTxDFIRMode 0x10000
-#define bTxPesudoNoiseOn 0x4000000
-#define bTxPesudoNoise_A 0xff
-#define bTxPesudoNoise_B 0xff00
-#define bTxPesudoNoise_C 0xff0000
-#define bTxPesudoNoise_D 0xff000000
-#define bCCADropOption 0x20000
-#define bCCADropThres 0xfff00000
-#define bEDCCA_H 0xf
-#define bEDCCA_L 0xf0
-#define bLambda_ED 0x300
-#define bRxInitialGain 0x7f
-#define bRxAntDivEn 0x80
-#define bRxAGCAddressForLNA 0x7f00
-#define bRxHighPowerFlow 0x8000
-#define bRxAGCFreezeThres 0xc0000
-#define bRxFreezeStep_AGC1 0x300000
-#define bRxFreezeStep_AGC2 0xc00000
-#define bRxFreezeStep_AGC3 0x3000000
-#define bRxFreezeStep_AGC0 0xc000000
-#define bRxRssi_Cmp_En 0x10000000
-#define bRxQuickAGCEn 0x20000000
-#define bRxAGCFreezeThresMode 0x40000000
-#define bRxOverFlowCheckType 0x80000000
-#define bRxAGCShift 0x7f
-#define bTRSW_Tri_Only 0x80
-#define bPowerThres 0x300
-#define bRxAGCEn 0x1
-#define bRxAGCTogetherEn 0x2
-#define bRxAGCMin 0x4
-#define bRxHP_Ini 0x7
-#define bRxHP_TRLNA 0x70
-#define bRxHP_RSSI 0x700
-#define bRxHP_BBP1 0x7000
-#define bRxHP_BBP2 0x70000
-#define bRxHP_BBP3 0x700000
-/* The threshold for high power */
-#define bRSSI_H 0x7f0000
-/* The threshold for ant diversity */
-#define bRSSI_Gen 0x7f000000
-#define bRxSettle_TRSW 0x7
-#define bRxSettle_LNA 0x38
-#define bRxSettle_RSSI 0x1c0
-#define bRxSettle_BBP 0xe00
-#define bRxSettle_RxHP 0x7000
-#define bRxSettle_AntSW_RSSI 0x38000
-#define bRxSettle_AntSW 0xc0000
-#define bRxProcessTime_DAGC 0x300000
-#define bRxSettle_HSSI 0x400000
-#define bRxProcessTime_BBPPW 0x800000
-#define bRxAntennaPowerShift 0x3000000
-#define bRSSITableSelect 0xc000000
-#define bRxHP_Final 0x7000000
-#define bRxHTSettle_BBP 0x7
-#define bRxHTSettle_HSSI 0x8
-#define bRxHTSettle_RxHP 0x70
-#define bRxHTSettle_BBPPW 0x80
-#define bRxHTSettle_Idle 0x300
-#define bRxHTSettle_Reserved 0x1c00
-#define bRxHTRxHPEn 0x8000
-#define bRxHTAGCFreezeThres 0x30000
-#define bRxHTAGCTogetherEn 0x40000
-#define bRxHTAGCMin 0x80000
-#define bRxHTAGCEn 0x100000
-#define bRxHTDAGCEn 0x200000
-#define bRxHTRxHP_BBP 0x1c00000
-#define bRxHTRxHP_Final 0xe0000000
-#define bRxPWRatioTH 0x3
-#define bRxPWRatioEn 0x4
-#define bRxMFHold 0x3800
-#define bRxPD_Delay_TH1 0x38
-#define bRxPD_Delay_TH2 0x1c0
-#define bRxPD_DC_COUNT_MAX 0x600
-/*#define bRxMF_Hold 0x3800*/
-#define bRxPD_Delay_TH 0x8000
-#define bRxProcess_Delay 0xf0000
-#define bRxSearchrange_GI2_Early 0x700000
-#define bRxFrame_Guard_Counter_L 0x3800000
-#define bRxSGI_Guard_L 0xc000000
-#define bRxSGI_Search_L 0x30000000
-#define bRxSGI_TH 0xc0000000
-#define bDFSCnt0 0xff
-#define bDFSCnt1 0xff00
-#define bDFSFlag 0xf0000
-
-#define bMFWeightSum 0x300000
-#define bMinIdxTH 0x7f000000
-
-#define bDAFormat 0x40000
-
-#define bTxChEmuEnable 0x01000000
-
-#define bTRSWIsolation_A 0x7f
-#define bTRSWIsolation_B 0x7f00
-#define bTRSWIsolation_C 0x7f0000
-#define bTRSWIsolation_D 0x7f000000
-
-#define bExtLNAGain 0x7c00
-
-/* Page d */
-#define bSTBCEn 0x4
-#define bAntennaMapping 0x10
-#define bNss 0x20
-#define bCFOAntSumD 0x200
-#define bPHYCounterReset 0x8000000
-#define bCFOReportGet 0x4000000
-#define bOFDMContinueTx 0x10000000
-#define bOFDMSingleCarrier 0x20000000
-#define bOFDMSingleTone 0x40000000
-/*#define bRxPath1 0x01
-#define bRxPath2 0x02
-#define bRxPath3 0x04
-#define bRxPath4 0x08
-#define bTxPath1 0x10
-#define bTxPath2 0x20*/
-#define bHTDetect 0x100
-#define bCFOEn 0x10000
-#define bCFOValue 0xfff00000
-#define bSigTone_Re 0x3f
-#define bSigTone_Im 0x7f00
-#define bCounter_CCA 0xffff
-#define bCounter_ParityFail 0xffff0000
-#define bCounter_RateIllegal 0xffff
-#define bCounter_CRC8Fail 0xffff0000
-#define bCounter_MCSNoSupport 0xffff
-#define bCounter_FastSync 0xffff
-#define bShortCFO 0xfff
-/* total */
-#define bShortCFOTLength 12
-/* fraction */
-#define bShortCFOFLength 11
-#define bLongCFO 0x7ff
-#define bLongCFOTLength 11
-#define bLongCFOFLength 11
-#define bTailCFO 0x1fff
-#define bTailCFOTLength 13
-#define bTailCFOFLength 12
-
-#define bmax_en_pwdB 0xffff
-#define bCC_power_dB 0xffff0000
-#define bnoise_pwdB 0xffff
-#define bPowerMeasTLength 10
-#define bPowerMeasFLength 3
-#define bRx_HT_BW 0x1
-#define bRxSC 0x6
-#define bRx_HT 0x8
-
-#define bNB_intf_det_on 0x1
-#define bIntf_win_len_cfg 0x30
-#define bNB_Intf_TH_cfg 0x1c0
-
-#define bRFGain 0x3f
-#define bTableSel 0x40
-#define bTRSW 0x80
-
-#define bRxSNR_A 0xff
-#define bRxSNR_B 0xff00
-#define bRxSNR_C 0xff0000
-#define bRxSNR_D 0xff000000
-#define bSNREVMTLength 8
-#define bSNREVMFLength 1
-
-#define bCSI1st 0xff
-#define bCSI2nd 0xff00
-#define bRxEVM1st 0xff0000
-#define bRxEVM2nd 0xff000000
-
-#define bSIGEVM 0xff
-#define bPWDB 0xff00
-#define bSGIEN 0x10000
-
-#define bSFactorQAM1 0xf
-#define bSFactorQAM2 0xf0
-#define bSFactorQAM3 0xf00
-#define bSFactorQAM4 0xf000
-#define bSFactorQAM5 0xf0000
-#define bSFactorQAM6 0xf0000
-#define bSFactorQAM7 0xf00000
-#define bSFactorQAM8 0xf000000
-#define bSFactorQAM9 0xf0000000
-#define bCSIScheme 0x100000
-
-#define bNoiseLvlTopSet 0x3
-#define bChSmooth 0x4
-#define bChSmoothCfg1 0x38
-#define bChSmoothCfg2 0x1c0
-#define bChSmoothCfg3 0xe00
-#define bChSmoothCfg4 0x7000
-#define bMRCMode 0x800000
-#define bTHEVMCfg 0x7000000
-
-#define bLoopFitType 0x1
-#define bUpdCFO 0x40
-#define bUpdCFOOffData 0x80
-#define bAdvUpdCFO 0x100
-#define bAdvTimeCtrl 0x800
-#define bUpdClko 0x1000
-#define bFC 0x6000
-#define bTrackingMode 0x8000
-#define bPhCmpEnable 0x10000
-#define bUpdClkoLTF 0x20000
-#define bComChCFO 0x40000
-#define bCSIEstiMode 0x80000
-#define bAdvUpdEqz 0x100000
-#define bUChCfg 0x7000000
-#define bUpdEqz 0x8000000
-
-/* Page e */
-#define bTxAGCRate18_06 0x7f7f7f7f
-#define bTxAGCRate54_24 0x7f7f7f7f
-#define bTxAGCRateMCS32 0x7f
-#define bTxAGCRateCCK 0x7f00
-#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f
-#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f
-#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f
-#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f
-
-
-/* Rx Pseduo noise */
-#define bRxPesudoNoiseOn 0x20000000
-#define bRxPesudoNoise_A 0xff
-#define bRxPesudoNoise_B 0xff00
-#define bRxPesudoNoise_C 0xff0000
-#define bRxPesudoNoise_D 0xff000000
-#define bPesudoNoiseState_A 0xffff
-#define bPesudoNoiseState_B 0xffff0000
-#define bPesudoNoiseState_C 0xffff
-#define bPesudoNoiseState_D 0xffff0000
-
-/* RF Zebra 1 */
-#define bZebra1_HSSIEnable 0x8
-#define bZebra1_TRxControl 0xc00
-#define bZebra1_TRxGainSetting 0x07f
-#define bZebra1_RxCorner 0xc00
-#define bZebra1_TxChargePump 0x38
-#define bZebra1_RxChargePump 0x7
-#define bZebra1_ChannelNum 0xf80
-#define bZebra1_TxLPFBW 0x400
-#define bZebra1_RxLPFBW 0x600
-
-/* Zebra4 */
-#define bRTL8256RegModeCtrl1 0x100
-#define bRTL8256RegModeCtrl0 0x40
-#define bRTL8256_TxLPFBW 0x18
-#define bRTL8256_RxLPFBW 0x600
-
-//RTL8258
-#define bRTL8258_TxLPFBW 0xc
-#define bRTL8258_RxLPFBW 0xc00
-#define bRTL8258_RSSILPFBW 0xc0
-
-/* byte enable for sb_write */
-#define bByte0 0x1
-#define bByte1 0x2
-#define bByte2 0x4
-#define bByte3 0x8
-#define bWord0 0x3
-#define bWord1 0xc
-#define bDWord 0xf
-
-/* for PutRegsetting & GetRegSetting BitMask */
-#define bMaskByte0 0xff
-#define bMaskByte1 0xff00
-#define bMaskByte2 0xff0000
-#define bMaskByte3 0xff000000
-#define bMaskHWord 0xffff0000
-#define bMaskLWord 0x0000ffff
-#define bMaskDWord 0xffffffff
-
-/* for PutRFRegsetting & GetRFRegSetting BitMask */
-#define bMask12Bits 0xfff
-
-#define bEnable 0x1
-#define bDisable 0x0
-
-#define LeftAntenna 0x0
-#define RightAntenna 0x1
-
-/* 500 ms */
-#define tCheckTxStatus 500
-/* 100 ms */
-#define tUpdateRxCounter 100
-
-#define rateCCK 0
-#define rateOFDM 1
-#define rateHT 2
-
-/* define Register-End */
-#define bPMAC_End 0x1ff
-#define bFPGAPHY0_End 0x8ff
-#define bFPGAPHY1_End 0x9ff
-#define bCCKPHY0_End 0xaff
-#define bOFDMPHY0_End 0xcff
-#define bOFDMPHY1_End 0xdff
-
-#define bPMACControl 0x0
-#define bWMACControl 0x1
-#define bWNICControl 0x2
-
-#define PathA 0x0
-#define PathB 0x1
-#define PathC 0x2
-#define PathD 0x3
-
-#define rRTL8256RxMixerPole 0xb
-#define bZebraRxMixerPole 0x6
-#define rRTL8256TxBBOPBias 0x9
-#define bRTL8256TxBBOPBias 0x400
-#define rRTL8256TxBBBW 19
-#define bRTL8256TxBBBW 0x18
-
-
-#endif /* __INC_HAL8190PCIPHYREG_H */
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
index 41b025e250fed6..89c3d3318e51e6 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.c
@@ -81,7 +81,7 @@ void EnableHWSecurityConfig8192(struct net_device *dev)
}
void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
- u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh)
+ const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh)
{
struct r8192_priv *priv = rtllib_priv(dev);
struct rtllib_device *ieee = priv->rtllib;
@@ -100,7 +100,7 @@ void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
}
void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
- u8 *MacAddr, u8 DefaultKey, u32 *KeyContent)
+ const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent)
{
u32 TargetCommand = 0;
u32 TargetContent = 0;
@@ -113,8 +113,8 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
if (priv->rtllib->PowerSaveControl.bInactivePs) {
if (rtState == eRfOff) {
if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) {
- RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",
- __func__);
+ netdev_warn(dev, "%s(): RF is OFF.\n",
+ __func__);
return;
}
down(&priv->rtllib->ips_sem);
@@ -124,7 +124,7 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
}
priv->rtllib->is_set_key = true;
if (EntryNo >= TOTAL_CAM_ENTRY)
- RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n");
+ netdev_info(dev, "%s(): Invalid CAM entry\n", __func__);
RT_TRACE(COMP_SEC,
"====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d,KeyType:%d, MacAddr %pM\n",
@@ -243,9 +243,9 @@ void CamRestoreAllEntry(struct net_device *dev)
(u32 *)(&priv->rtllib->swcamtable[0].key_buf[0])
);
} else {
- RT_TRACE(COMP_ERR,
- "===>%s():ERR!! ADHOC TKIP ,but 0 entry is have no data\n",
- __func__);
+ netdev_warn(dev,
+ "%s(): ADHOC TKIP: missing key entry.\n",
+ __func__);
return;
}
}
@@ -267,9 +267,9 @@ void CamRestoreAllEntry(struct net_device *dev)
CAM_CONST_ADDR[0], 0,
(u32 *)(&priv->rtllib->swcamtable[0].key_buf[0]));
} else {
- RT_TRACE(COMP_ERR,
- "===>%s():ERR!! ADHOC CCMP ,but 0 entry is have no data\n",
- __func__);
+ netdev_warn(dev,
+ "%s(): ADHOC CCMP: missing key entry.\n",
+ __func__);
return;
}
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
index 3c4c0e61c18187..864a7f607bca7b 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_cam.h
@@ -31,9 +31,9 @@ struct net_device;
void CamResetAllEntry(struct net_device *dev);
void EnableHWSecurityConfig8192(struct net_device *dev);
void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
- u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
+ const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent);
void set_swcam(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType,
- u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh);
+ const u8 *MacAddr, u8 DefaultKey, u32 *KeyContent, u8 is_mesh);
void CamPrintDbgReg(struct net_device *dev);
u32 read_cam(struct net_device *dev, u8 addr);
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
index 352d381b7c4ae5..fcc9188a209f37 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c
@@ -44,6 +44,7 @@
#include <linux/uaccess.h>
#include <linux/pci.h>
#include <linux/vmalloc.h>
+#include <linux/ieee80211.h>
#include "rtl_core.h"
#include "r8192E_phy.h"
#include "r8192E_phyreg.h"
@@ -342,8 +343,9 @@ bool MgntActSet_RF_State(struct net_device *dev,
mdelay(1);
if (RFWaitCounter > 100) {
- RT_TRACE(COMP_ERR,
- "MgntActSet_RF_State(): Wait too logn to set RF\n");
+ netdev_warn(dev,
+ "%s(): Timeout waiting for RF change.\n",
+ __func__);
return false;
}
}
@@ -391,7 +393,7 @@ bool MgntActSet_RF_State(struct net_device *dev,
else
priv->blinked_ingpio = false;
rtllib_MgntDisconnect(priv->rtllib,
- disas_lv_ss);
+ WLAN_REASON_DISASSOC_STA_HAS_LEFT);
}
}
if ((ChangeSource == RF_CHANGE_BY_HW) && !priv->bHwRadioOff)
@@ -896,9 +898,9 @@ void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode)
} else if ((bSupportMode & WIRELESS_MODE_B)) {
wireless_mode = WIRELESS_MODE_B;
} else {
- RT_TRACE(COMP_ERR,
- "%s(), No valid wireless mode supported (%x)!!!\n",
- __func__, bSupportMode);
+ netdev_info(dev,
+ "%s(): Unsupported mode requested. Fallback to 802.11b\n",
+ __func__);
wireless_mode = WIRELESS_MODE_B;
}
}
@@ -945,8 +947,7 @@ static int _rtl8192_sta_up(struct net_device *dev, bool is_silent_reset)
priv->bfirst_init = true;
init_status = priv->ops->initialize_adapter(dev);
if (!init_status) {
- RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n",
- __func__);
+ netdev_err(dev, "%s(): Initialization failed!\n", __func__);
priv->bfirst_init = false;
return -1;
}
@@ -1117,7 +1118,6 @@ static void rtl8192_init_priv_variable(struct net_device *dev)
priv->bDriverIsGoingToUnload = false;
priv->being_init_adapter = false;
priv->initialized_at_probe = false;
- priv->sw_radio_on = true;
priv->bdisable_nic = false;
priv->bfirst_init = false;
priv->txringcount = 64;
@@ -1267,9 +1267,8 @@ static short rtl8192_get_channel_map(struct net_device *dev)
if ((priv->rf_chip != RF_8225) && (priv->rf_chip != RF_8256)
&& (priv->rf_chip != RF_6052)) {
- RT_TRACE(COMP_ERR,
- "%s: unknown rf chip, can't set channel map\n",
- __func__);
+ netdev_err(dev, "%s: unknown rf chip, can't set channel map\n",
+ __func__);
return -1;
}
@@ -1498,9 +1497,8 @@ RESET_START:
LeisurePSLeave(dev);
if (priv->up) {
- RT_TRACE(COMP_ERR,
- "%s():the driver is not up! return\n",
- __func__);
+ netdev_info(dev, "%s():the driver is not up.\n",
+ __func__);
up(&priv->wx_sem);
return;
}
@@ -1533,7 +1531,7 @@ RESET_START:
SEM_UP_IEEE_WX(&ieee->wx_sem);
} else {
netdev_info(dev, "ieee->state is NOT LINKED\n");
- rtllib_softmac_stop_protocol(priv->rtllib, 0 , true);
+ rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
}
dm_backup_dynamic_mechanism_state(dev);
@@ -1554,9 +1552,8 @@ RESET_START:
reset_times++;
goto RESET_START;
} else {
- RT_TRACE(COMP_ERR,
- " ERR!!! %s(): Reset Failed!!\n",
- __func__);
+ netdev_warn(dev, "%s(): Reset Failed\n",
+ __func__);
}
}
@@ -1729,7 +1726,7 @@ void rtl819x_watchdog_wqcallback(void *data)
if (priv->check_roaming_cnt > 0) {
if (ieee->eRFPowerState == eRfOff)
- RT_TRACE(COMP_ERR, "========>%s()\n", __func__);
+ netdev_info(dev, "%s(): RF is off\n", __func__);
netdev_info(dev,
"===>%s(): AP is power off, chan:%d, connect another one\n",
@@ -1884,8 +1881,9 @@ void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev,
return;
}
- assert(queue_index != TXCMD_QUEUE);
-
+ if (queue_index != TXCMD_QUEUE)
+ netdev_warn(dev, "%s(): queue index != TXCMD_QUEUE\n",
+ __func__);
memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev));
skb_push(skb, priv->rtllib->tx_headroom);
@@ -1998,9 +1996,8 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
u32 fwinfo_size = 0;
if (priv->bdisable_nic) {
- RT_TRACE(COMP_ERR,
- "%s: ERR!! Nic is disabled! Can't tx packet len=%d qidx=%d!!!\n",
- __func__, skb->len, tcb_desc->queue_index);
+ netdev_warn(dev, "%s: Nic is disabled! Can't tx packet.\n",
+ __func__);
return skb->len;
}
@@ -2037,10 +2034,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb)
pdesc = &ring->desc[idx];
if ((pdesc->OWN == 1) && (tcb_desc->queue_index != BEACON_QUEUE)) {
- RT_TRACE(COMP_ERR,
- "No more TX desc@%d, ring->idx = %d, idx = %d, skblen = 0x%x queuelen=%d",
- tcb_desc->queue_index, ring->idx, idx, skb->len,
- skb_queue_len(&ring->queue));
+ netdev_warn(dev,
+ "No more TX desc@%d, ring->idx = %d, idx = %d, skblen = 0x%x queuelen=%d",
+ tcb_desc->queue_index, ring->idx, idx, skb->len,
+ skb_queue_len(&ring->queue));
spin_unlock_irqrestore(&priv->irq_th_lock, flags);
return skb->len;
}
@@ -2066,13 +2063,12 @@ static short rtl8192_alloc_rx_desc_ring(struct net_device *dev)
int i, rx_queue_idx;
for (rx_queue_idx = 0; rx_queue_idx < MAX_RX_QUEUE; rx_queue_idx++) {
- priv->rx_ring[rx_queue_idx] =
- pci_zalloc_consistent(priv->pdev,
+ priv->rx_ring[rx_queue_idx] = pci_zalloc_consistent(priv->pdev,
sizeof(*priv->rx_ring[rx_queue_idx]) * priv->rxringcount,
&priv->rx_ring_dma[rx_queue_idx]);
if (!priv->rx_ring[rx_queue_idx] ||
(unsigned long)priv->rx_ring[rx_queue_idx] & 0xFF) {
- RT_TRACE(COMP_ERR, "Cannot allocate RX ring\n");
+ netdev_warn(dev, "Cannot allocate RX ring\n");
return -ENOMEM;
}
@@ -2102,7 +2098,7 @@ static short rtl8192_alloc_rx_desc_ring(struct net_device *dev)
entry->OWN = 1;
}
- if(entry)
+ if (entry)
entry->EOR = 1;
}
return 0;
@@ -2118,8 +2114,7 @@ static int rtl8192_alloc_tx_desc_ring(struct net_device *dev,
ring = pci_zalloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma);
if (!ring || (unsigned long)ring & 0xFF) {
- RT_TRACE(COMP_ERR, "Cannot allocate TX ring (prio = %d)\n",
- prio);
+ netdev_warn(dev, "Cannot allocate TX ring (prio = %d)\n", prio);
return -ENOMEM;
}
@@ -2310,7 +2305,7 @@ static void rtl8192_rx_normal(struct net_device *dev)
struct rtllib_rx_stats stats = {
.signal = 0,
- .noise = -98,
+ .noise = (u8) -98,
.rate = 0,
.freq = RTLLIB_24GHZ_BAND,
};
@@ -2519,7 +2514,7 @@ void rtl8192_commit(struct net_device *dev)
if (priv->up == 0)
return;
- rtllib_softmac_stop_protocol(priv->rtllib, 0 , true);
+ rtllib_softmac_stop_protocol(priv->rtllib, 0, true);
rtl8192_irq_disable(dev);
priv->ops->stop_adapter(dev, true);
_rtl8192_up(dev, false);
@@ -2572,8 +2567,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
int ret = -1;
struct rtllib_device *ieee = priv->rtllib;
u32 key[4];
- u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- u8 zero_addr[6] = {0};
+ const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
struct iw_point *p = &wrq->u.data;
struct ieee_param *ipw = NULL;
@@ -2610,8 +2604,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
}
if (ieee->pairwise_key_type) {
- if (memcmp(ieee->ap_mac_addr, zero_addr,
- 6) == 0)
+ if (is_zero_ether_addr(ieee->ap_mac_addr))
ieee->iw_mode = IW_MODE_ADHOC;
memcpy((u8 *)key, ipw->u.crypt.key, 16);
EnableHWSecurityConfig8192(dev);
@@ -2850,7 +2843,7 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
RT_TRACE(COMP_INIT, "Configuring chip resources");
if (pci_enable_device(pdev)) {
- RT_TRACE(COMP_ERR, "Failed to enable PCI device");
+ dev_err(&pdev->dev, "Failed to enable PCI device");
return -EIO;
}
@@ -2888,21 +2881,21 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
pmem_flags = pci_resource_flags(pdev, 1);
if (!(pmem_flags & IORESOURCE_MEM)) {
- RT_TRACE(COMP_ERR, "region #1 not a MMIO resource, aborting");
+ netdev_err(dev, "region #1 not a MMIO resource, aborting");
goto err_rel_rtllib;
}
dev_info(&pdev->dev, "Memory mapped space start: 0x%08lx\n",
pmem_start);
if (!request_mem_region(pmem_start, pmem_len, DRV_NAME)) {
- RT_TRACE(COMP_ERR, "request_mem_region failed!");
+ netdev_err(dev, "request_mem_region failed!");
goto err_rel_rtllib;
}
ioaddr = (unsigned long)ioremap_nocache(pmem_start, pmem_len);
if (ioaddr == (unsigned long)NULL) {
- RT_TRACE(COMP_ERR, "ioremap failed!");
+ netdev_err(dev, "ioremap failed!");
goto err_rel_mem;
}
@@ -2938,7 +2931,7 @@ static int rtl8192_pci_probe(struct pci_dev *pdev,
RT_TRACE(COMP_INIT, "Driver probe completed1\n");
if (rtl8192_init(dev) != 0) {
- RT_TRACE(COMP_ERR, "Initialization failed");
+ netdev_warn(dev, "Initialization failed");
goto err_free_irq;
}
@@ -3024,8 +3017,7 @@ bool NicIFEnableNIC(struct net_device *dev)
(&(priv->rtllib->PowerSaveControl));
if (!priv->up) {
- RT_TRACE(COMP_ERR, "ERR!!! %s(): Driver is already down!\n",
- __func__);
+ netdev_warn(dev, "%s(): Driver is already down!\n", __func__);
priv->bdisable_nic = false;
return false;
}
@@ -3034,8 +3026,7 @@ bool NicIFEnableNIC(struct net_device *dev)
priv->bfirst_init = true;
init_status = priv->ops->initialize_adapter(dev);
if (!init_status) {
- RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization is failed!\n",
- __func__);
+ netdev_warn(dev, "%s(): Initialization failed!\n", __func__);
priv->bdisable_nic = false;
return false;
}
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
index d365af6ebdc7b5..6127e92d8b9309 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.h
@@ -84,7 +84,7 @@
#define RTL_PCI_DEVICE(vend, dev, cfg) \
.vendor = (vend), .device = (dev), \
- .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID , \
+ .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, \
.driver_data = (kernel_ulong_t)&(cfg)
#define RTL_MAX_SCAN_SIZE 128
@@ -303,9 +303,9 @@ enum pci_bridge_vendor {
PCI_BRIDGE_VENDOR_INTEL = 0x0,
PCI_BRIDGE_VENDOR_ATI,
PCI_BRIDGE_VENDOR_AMD,
- PCI_BRIDGE_VENDOR_SIS ,
+ PCI_BRIDGE_VENDOR_SIS,
PCI_BRIDGE_VENDOR_UNKNOWN,
- PCI_BRIDGE_VENDOR_MAX ,
+ PCI_BRIDGE_VENDOR_MAX,
};
struct buffer {
@@ -451,15 +451,6 @@ enum two_port_status {
TWO_PORT_STATUS__WITHOUT_ANY_ASSOCIATE
};
-struct txbbgain_struct {
- long txbb_iq_amplifygain;
- u32 txbbgain_value;
-};
-
-struct ccktxbbgain {
- u8 ccktxbb_valuearray[8];
-};
-
struct init_gain {
u8 xaagccore1;
u8 xbagccore1;
@@ -567,11 +558,6 @@ struct r8192_priv {
struct bb_reg_definition PHYRegDef[4];
struct rate_adaptive rate_adaptive;
- struct ccktxbbgain cck_txbbgain_table[CCKTxBBGainTableLength];
- struct ccktxbbgain cck_txbbgain_ch14_table[CCKTxBBGainTableLength];
-
- struct txbbgain_struct txbbgain_table[TxBBGainTableLength];
-
enum acm_method AcmMethod;
struct rt_firmware *pFirmware;
@@ -640,7 +626,6 @@ struct r8192_priv {
u8 RegCWinMin;
u8 keepAliveLevel;
- bool sw_radio_on;
bool bHwRadioOff;
bool pwrdown;
bool blinked_ingpio;
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h b/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h
deleted file mode 100644
index ee57c0f4fa692f..00000000000000
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_crypto.h
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Scatterlist Cryptographic API.
- *
- * Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
- * Copyright (c) 2002 David S. Miller (davem@redhat.com)
- *
- * Portions derived from Cryptoapi, by Alexander Kjeldaas <astor@fast.no>
- * and Nettle, by Niels Mé°ˆler.
- *
- * 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.
- *
- */
-#ifndef _LINUX_CRYPTO_H
-#define _LINUX_CRYPTO_H
-
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/types.h>
-#include <linux/list.h>
-#include <linux/string.h>
-#include <asm/page.h>
-#include <linux/errno.h>
-
-#define crypto_register_alg crypto_register_alg_rsl
-#define crypto_unregister_alg crypto_unregister_alg_rsl
-#define crypto_alloc_tfm crypto_alloc_tfm_rsl
-#define crypto_free_tfm crypto_free_tfm_rsl
-#define crypto_alg_available crypto_alg_available_rsl
-
-/*
- * Algorithm masks and types.
- */
-#define CRYPTO_ALG_TYPE_MASK 0x000000ff
-#define CRYPTO_ALG_TYPE_CIPHER 0x00000001
-#define CRYPTO_ALG_TYPE_DIGEST 0x00000002
-#define CRYPTO_ALG_TYPE_COMPRESS 0x00000004
-
-/*
- * Transform masks and values (for crt_flags).
- */
-#define CRYPTO_TFM_MODE_MASK 0x000000ff
-#define CRYPTO_TFM_REQ_MASK 0x000fff00
-#define CRYPTO_TFM_RES_MASK 0xfff00000
-
-#define CRYPTO_TFM_MODE_ECB 0x00000001
-#define CRYPTO_TFM_MODE_CBC 0x00000002
-#define CRYPTO_TFM_MODE_CFB 0x00000004
-#define CRYPTO_TFM_MODE_CTR 0x00000008
-
-#define CRYPTO_TFM_REQ_WEAK_KEY 0x00000100
-#define CRYPTO_TFM_RES_WEAK_KEY 0x00100000
-#define CRYPTO_TFM_RES_BAD_KEY_LEN 0x00200000
-#define CRYPTO_TFM_RES_BAD_KEY_SCHED 0x00400000
-#define CRYPTO_TFM_RES_BAD_BLOCK_LEN 0x00800000
-#define CRYPTO_TFM_RES_BAD_FLAGS 0x01000000
-
-/*
- * Miscellaneous stuff.
- */
-#define CRYPTO_UNSPEC 0
-#define CRYPTO_MAX_ALG_NAME 64
-
-struct scatterlist;
-
-/*
- * Algorithms: modular crypto algorithm implementations, managed
- * via crypto_register_alg() and crypto_unregister_alg().
- */
-struct cipher_alg {
- unsigned int cia_min_keysize;
- unsigned int cia_max_keysize;
- int (*cia_setkey)(void *ctx, const u8 *key,
- unsigned int keylen, u32 *flags);
- void (*cia_encrypt)(void *ctx, u8 *dst, const u8 *src);
- void (*cia_decrypt)(void *ctx, u8 *dst, const u8 *src);
-};
-
-struct digest_alg {
- unsigned int dia_digestsize;
- void (*dia_init)(void *ctx);
- void (*dia_update)(void *ctx, const u8 *data, unsigned int len);
- void (*dia_final)(void *ctx, u8 *out);
- int (*dia_setkey)(void *ctx, const u8 *key,
- unsigned int keylen, u32 *flags);
-};
-
-struct compress_alg {
- int (*coa_init)(void *ctx);
- void (*coa_exit)(void *ctx);
- int (*coa_compress)(void *ctx, const u8 *src, unsigned int slen,
- u8 *dst, unsigned int *dlen);
- int (*coa_decompress)(void *ctx, const u8 *src, unsigned int slen,
- u8 *dst, unsigned int *dlen);
-};
-
-#define cra_cipher cra_u.cipher
-#define cra_digest cra_u.digest
-#define cra_compress cra_u.compress
-
-struct crypto_alg {
- struct list_head cra_list;
- u32 cra_flags;
- unsigned int cra_blocksize;
- unsigned int cra_ctxsize;
- const char cra_name[CRYPTO_MAX_ALG_NAME];
-
- union {
- struct cipher_alg cipher;
- struct digest_alg digest;
- struct compress_alg compress;
- } cra_u;
-
- struct module *cra_module;
-};
-
-/*
- * Algorithm registration interface.
- */
-int crypto_register_alg(struct crypto_alg *alg);
-int crypto_unregister_alg(struct crypto_alg *alg);
-
-/*
- * Algorithm query interface.
- */
-int crypto_alg_available(const char *name, u32 flags);
-
-/*
- * Transforms: user-instantiated objects which encapsulate algorithms
- * and core processing logic. Managed via crypto_alloc_tfm() and
- * crypto_free_tfm(), as well as the various helpers below.
- */
-struct crypto_tfm;
-
-struct cipher_tfm {
- void *cit_iv;
- unsigned int cit_ivsize;
- u32 cit_mode;
- int (*cit_setkey)(struct crypto_tfm *tfm,
- const u8 *key, unsigned int keylen);
- int (*cit_encrypt)(struct crypto_tfm *tfm,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes);
- int (*cit_encrypt_iv)(struct crypto_tfm *tfm,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes, u8 *iv);
- int (*cit_decrypt)(struct crypto_tfm *tfm,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes);
- int (*cit_decrypt_iv)(struct crypto_tfm *tfm,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes, u8 *iv);
- void (*cit_xor_block)(u8 *dst, const u8 *src);
-};
-
-struct digest_tfm {
- void (*dit_init)(struct crypto_tfm *tfm);
- void (*dit_update)(struct crypto_tfm *tfm,
- struct scatterlist *sg, unsigned int nsg);
- void (*dit_final)(struct crypto_tfm *tfm, u8 *out);
- void (*dit_digest)(struct crypto_tfm *tfm, struct scatterlist *sg,
- unsigned int nsg, u8 *out);
- int (*dit_setkey)(struct crypto_tfm *tfm,
- const u8 *key, unsigned int keylen);
-};
-
-struct compress_tfm {
- int (*cot_compress)(struct crypto_tfm *tfm,
- const u8 *src, unsigned int slen,
- u8 *dst, unsigned int *dlen);
- int (*cot_decompress)(struct crypto_tfm *tfm,
- const u8 *src, unsigned int slen,
- u8 *dst, unsigned int *dlen);
-};
-
-#define crt_cipher crt_u.cipher
-#define crt_digest crt_u.digest
-#define crt_compress crt_u.compress
-
-struct crypto_tfm {
-
- u32 crt_flags;
-
- union {
- struct cipher_tfm cipher;
- struct digest_tfm digest;
- struct compress_tfm compress;
- } crt_u;
-
- struct crypto_alg *__crt_alg;
-};
-
-/*
- * Transform user interface.
- */
-
-/*
- * crypto_alloc_tfm() will first attempt to locate an already loaded algorithm.
- * If that fails and the kernel supports dynamically loadable modules, it
- * will then attempt to load a module of the same name or alias. A refcount
- * is grabbed on the algorithm which is then associated with the new transform.
- *
- * crypto_free_tfm() frees up the transform and any associated resources,
- * then drops the refcount on the associated algorithm.
- */
-struct crypto_tfm *crypto_alloc_tfm(const char *alg_name, u32 tfm_flags);
-void crypto_free_tfm(struct crypto_tfm *tfm);
-
-/*
- * Transform helpers which query the underlying algorithm.
- */
-static inline const char *crypto_tfm_alg_name(struct crypto_tfm *tfm)
-{
- return tfm->__crt_alg->cra_name;
-}
-
-static inline const char *crypto_tfm_alg_modname(struct crypto_tfm *tfm)
-{
- struct crypto_alg *alg = tfm->__crt_alg;
-
- if (alg->cra_module)
- return alg->cra_module->name;
- else
- return NULL;
-}
-
-static inline u32 crypto_tfm_alg_type(struct crypto_tfm *tfm)
-{
- return tfm->__crt_alg->cra_flags & CRYPTO_ALG_TYPE_MASK;
-}
-
-static inline unsigned int crypto_tfm_alg_min_keysize(struct crypto_tfm *tfm)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- return tfm->__crt_alg->cra_cipher.cia_min_keysize;
-}
-
-static inline unsigned int crypto_tfm_alg_max_keysize(struct crypto_tfm *tfm)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- return tfm->__crt_alg->cra_cipher.cia_max_keysize;
-}
-
-static inline unsigned int crypto_tfm_alg_ivsize(struct crypto_tfm *tfm)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- return tfm->crt_cipher.cit_ivsize;
-}
-
-static inline unsigned int crypto_tfm_alg_blocksize(struct crypto_tfm *tfm)
-{
- return tfm->__crt_alg->cra_blocksize;
-}
-
-static inline unsigned int crypto_tfm_alg_digestsize(struct crypto_tfm *tfm)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
- return tfm->__crt_alg->cra_digest.dia_digestsize;
-}
-
-/*
- * API wrappers.
- */
-static inline void crypto_digest_init(struct crypto_tfm *tfm)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
- tfm->crt_digest.dit_init(tfm);
-}
-
-static inline void crypto_digest_update(struct crypto_tfm *tfm,
- struct scatterlist *sg,
- unsigned int nsg)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
- tfm->crt_digest.dit_update(tfm, sg, nsg);
-}
-
-static inline void crypto_digest_final(struct crypto_tfm *tfm, u8 *out)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
- tfm->crt_digest.dit_final(tfm, out);
-}
-
-static inline void crypto_digest_digest(struct crypto_tfm *tfm,
- struct scatterlist *sg,
- unsigned int nsg, u8 *out)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
- tfm->crt_digest.dit_digest(tfm, sg, nsg, out);
-}
-
-static inline int crypto_digest_setkey(struct crypto_tfm *tfm,
- const u8 *key, unsigned int keylen)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST);
- if (tfm->crt_digest.dit_setkey == NULL)
- return -ENOSYS;
- return tfm->crt_digest.dit_setkey(tfm, key, keylen);
-}
-
-static inline int crypto_cipher_setkey(struct crypto_tfm *tfm,
- const u8 *key, unsigned int keylen)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- return tfm->crt_cipher.cit_setkey(tfm, key, keylen);
-}
-
-static inline int crypto_cipher_encrypt(struct crypto_tfm *tfm,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- return tfm->crt_cipher.cit_encrypt(tfm, dst, src, nbytes);
-}
-
-static inline int crypto_cipher_encrypt_iv(struct crypto_tfm *tfm,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes, u8 *iv)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
- return tfm->crt_cipher.cit_encrypt_iv(tfm, dst, src, nbytes, iv);
-}
-
-static inline int crypto_cipher_decrypt(struct crypto_tfm *tfm,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- return tfm->crt_cipher.cit_decrypt(tfm, dst, src, nbytes);
-}
-
-static inline int crypto_cipher_decrypt_iv(struct crypto_tfm *tfm,
- struct scatterlist *dst,
- struct scatterlist *src,
- unsigned int nbytes, u8 *iv)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- BUG_ON(tfm->crt_cipher.cit_mode == CRYPTO_TFM_MODE_ECB);
- return tfm->crt_cipher.cit_decrypt_iv(tfm, dst, src, nbytes, iv);
-}
-
-static inline void crypto_cipher_set_iv(struct crypto_tfm *tfm,
- const u8 *src, unsigned int len)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- memcpy(tfm->crt_cipher.cit_iv, src, len);
-}
-
-static inline void crypto_cipher_get_iv(struct crypto_tfm *tfm,
- u8 *dst, unsigned int len)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_CIPHER);
- memcpy(dst, tfm->crt_cipher.cit_iv, len);
-}
-
-static inline int crypto_comp_compress(struct crypto_tfm *tfm,
- const u8 *src, unsigned int slen,
- u8 *dst, unsigned int *dlen)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
- return tfm->crt_compress.cot_compress(tfm, src, slen, dst, dlen);
-}
-
-static inline int crypto_comp_decompress(struct crypto_tfm *tfm,
- const u8 *src, unsigned int slen,
- u8 *dst, unsigned int *dlen)
-{
- BUG_ON(crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_COMPRESS);
- return tfm->crt_compress.cot_decompress(tfm, src, slen, dst, dlen);
-}
-
-#endif /* _LINUX_CRYPTO_H */
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
index df4bbcf38bae90..d480229394a540 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.c
@@ -60,6 +60,99 @@ static u32 edca_setting_UL[HT_IOT_PEER_MAX] = {
#define RTK_UL_EDCA 0xa44f
#define RTK_DL_EDCA 0x5e4322
+
+const u32 dm_tx_bb_gain[TxBBGainTableLength] = {
+ 0x7f8001fe, /* 12 dB */
+ 0x788001e2, /* 11 dB */
+ 0x71c001c7,
+ 0x6b8001ae,
+ 0x65400195,
+ 0x5fc0017f,
+ 0x5a400169,
+ 0x55400155,
+ 0x50800142,
+ 0x4c000130,
+ 0x47c0011f,
+ 0x43c0010f,
+ 0x40000100,
+ 0x3c8000f2,
+ 0x390000e4,
+ 0x35c000d7,
+ 0x32c000cb,
+ 0x300000c0,
+ 0x2d4000b5,
+ 0x2ac000ab,
+ 0x288000a2,
+ 0x26000098,
+ 0x24000090,
+ 0x22000088,
+ 0x20000080,
+ 0x1a00006c,
+ 0x1c800072,
+ 0x18000060,
+ 0x19800066,
+ 0x15800056,
+ 0x26c0005b,
+ 0x14400051,
+ 0x24400051,
+ 0x1300004c,
+ 0x12000048,
+ 0x11000044,
+ 0x10000040, /* -24 dB */
+};
+
+const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8] = {
+ {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04},
+ {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04},
+ {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03},
+ {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03},
+ {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03},
+ {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03},
+ {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03},
+ {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03},
+ {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02},
+ {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02},
+ {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02},
+ {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02},
+ {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02},
+ {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02},
+ {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02},
+ {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02},
+ {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01},
+ {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02},
+ {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01},
+ {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
+ {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01},
+ {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01},
+ {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}
+};
+
+const u8 dm_cck_tx_bb_gain_ch14[CCKTxBBGainTableLength][8] = {
+ {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00},
+ {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00},
+ {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00},
+ {0x2d, 0x2d, 0x27, 0x17, 0x00, 0x00, 0x00, 0x00},
+ {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00},
+ {0x28, 0x28, 0x22, 0x14, 0x00, 0x00, 0x00, 0x00},
+ {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00},
+ {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00},
+ {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00},
+ {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00},
+ {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00},
+ {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00},
+ {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00},
+ {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00},
+ {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00},
+ {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00},
+ {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00},
+ {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00},
+ {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00},
+ {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
+ {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00},
+ {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00},
+ {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}
+};
+
/*---------------------------Define Local Constant---------------------------*/
@@ -155,7 +248,8 @@ void init_hal_dm(struct net_device *dev)
if (IS_HARDWARE_TYPE_8192SE(dev))
dm_Init_WA_Broadcom_IOT(dev);
- INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq, (void *)dm_CheckRfCtrlGPIO, dev);
+ INIT_DELAYED_WORK_RSL(&priv->gpio_change_rf_wq,
+ (void *)dm_CheckRfCtrlGPIO, dev);
}
void deinit_hal_dm(struct net_device *dev)
@@ -195,8 +289,8 @@ void hal_dm_watchdog(struct net_device *dev)
static void dm_check_ac_dc_power(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
- static char *ac_dc_check_script_path = "/etc/acpi/wireless-rtl-ac-dc-power.sh";
- char *argv[] = {ac_dc_check_script_path, DRV_NAME, NULL};
+ static char *ac_dc_script = "/etc/acpi/wireless-rtl-ac-dc-power.sh";
+ char *argv[] = {ac_dc_script, DRV_NAME, NULL};
static char *envp[] = {"HOME=/",
"TERM=linux",
"PATH=/usr/bin:/bin",
@@ -210,7 +304,7 @@ static void dm_check_ac_dc_power(struct net_device *dev)
if (priv->rtllib->state != RTLLIB_LINKED)
return;
- call_usermodehelper(ac_dc_check_script_path, argv, envp, UMH_WAIT_PROC);
+ call_usermodehelper(ac_dc_script, argv, envp, UMH_WAIT_PROC);
return;
};
@@ -220,7 +314,7 @@ void init_rate_adaptive(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
- struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive;
+ struct rate_adaptive *pra = &priv->rate_adaptive;
pra->ratr_state = DM_RATR_STA_MAX;
pra->high2low_rssi_thresh_for_ra = RateAdaptiveTH_High;
@@ -261,14 +355,15 @@ static void dm_check_rate_adaptive(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
struct rt_hi_throughput *pHTInfo = priv->rtllib->pHTInfo;
- struct rate_adaptive *pra = (struct rate_adaptive *)&priv->rate_adaptive;
+ struct rate_adaptive *pra = &priv->rate_adaptive;
u32 currentRATR, targetRATR = 0;
u32 LowRSSIThreshForRA = 0, HighRSSIThreshForRA = 0;
bool bshort_gi_enabled = false;
static u8 ping_rssi_state;
if (!priv->up) {
- RT_TRACE(COMP_RATE, "<---- dm_check_rate_adaptive(): driver is going to unload\n");
+ RT_TRACE(COMP_RATE,
+ "<---- dm_check_rate_adaptive(): driver is going to unload\n");
return;
}
@@ -281,44 +376,52 @@ static void dm_check_rate_adaptive(struct net_device *dev)
if (priv->rtllib->state == RTLLIB_LINKED) {
- bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI40MHz) ||
- (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz);
-
+ bshort_gi_enabled = (pHTInfo->bCurTxBW40MHz &&
+ pHTInfo->bCurShortGI40MHz) ||
+ (!pHTInfo->bCurTxBW40MHz &&
+ pHTInfo->bCurShortGI20MHz);
pra->upper_rssi_threshold_ratr =
- (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0);
+ (pra->upper_rssi_threshold_ratr & (~BIT31)) |
+ ((bshort_gi_enabled) ? BIT31 : 0);
pra->middle_rssi_threshold_ratr =
- (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0);
+ (pra->middle_rssi_threshold_ratr & (~BIT31)) |
+ ((bshort_gi_enabled) ? BIT31 : 0);
if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) {
pra->low_rssi_threshold_ratr =
- (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0);
+ (pra->low_rssi_threshold_ratr_40M & (~BIT31)) |
+ ((bshort_gi_enabled) ? BIT31 : 0);
} else {
pra->low_rssi_threshold_ratr =
- (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0);
+ (pra->low_rssi_threshold_ratr_20M & (~BIT31)) |
+ ((bshort_gi_enabled) ? BIT31 : 0);
}
pra->ping_rssi_ratr =
- (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31 : 0);
+ (pra->ping_rssi_ratr & (~BIT31)) |
+ ((bshort_gi_enabled) ? BIT31 : 0);
if (pra->ratr_state == DM_RATR_STA_HIGH) {
- HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra;
- LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ?
+ HighRSSIThreshForRA = pra->high2low_rssi_thresh_for_ra;
+ LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ?
(pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M);
} else if (pra->ratr_state == DM_RATR_STA_LOW) {
- HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
- LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ?
+ HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
+ LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ?
(pra->low2high_rssi_thresh_for_ra40M) : (pra->low2high_rssi_thresh_for_ra20M);
} else {
- HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
- LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ?
+ HighRSSIThreshForRA = pra->high_rssi_thresh_for_ra;
+ LowRSSIThreshForRA = (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) ?
(pra->low_rssi_thresh_for_ra40M) : (pra->low_rssi_thresh_for_ra20M);
}
- if (priv->undecorated_smoothed_pwdb >= (long)HighRSSIThreshForRA) {
+ if (priv->undecorated_smoothed_pwdb >=
+ (long)HighRSSIThreshForRA) {
pra->ratr_state = DM_RATR_STA_HIGH;
targetRATR = pra->upper_rssi_threshold_ratr;
- } else if (priv->undecorated_smoothed_pwdb >= (long)LowRSSIThreshForRA) {
+ } else if (priv->undecorated_smoothed_pwdb >=
+ (long)LowRSSIThreshForRA) {
pra->ratr_state = DM_RATR_STA_MIDDLE;
targetRATR = pra->middle_rssi_threshold_ratr;
} else {
@@ -327,8 +430,10 @@ static void dm_check_rate_adaptive(struct net_device *dev)
}
if (pra->ping_rssi_enable) {
- if (priv->undecorated_smoothed_pwdb < (long)(pra->ping_rssi_thresh_for_ra+5)) {
- if ((priv->undecorated_smoothed_pwdb < (long)pra->ping_rssi_thresh_for_ra) ||
+ if (priv->undecorated_smoothed_pwdb <
+ (long)(pra->ping_rssi_thresh_for_ra+5)) {
+ if ((priv->undecorated_smoothed_pwdb <
+ (long)pra->ping_rssi_thresh_for_ra) ||
ping_rssi_state) {
pra->ratr_state = DM_RATR_STA_LOW;
targetRATR = pra->ping_rssi_ratr;
@@ -449,6 +554,97 @@ static u8 CCKSwingTable_Ch14[CCK_Table_length][8] = {
#define Tssi_Report_Value2 0x13e
#define FW_Busy_Flag 0x13f
+static void dm_tx_update_tssi_weak_signal(struct net_device *dev, u8 RF_Type)
+{
+ struct r8192_priv *p = rtllib_priv(dev);
+
+ if (RF_Type == RF_2T4R) {
+ if ((p->rfa_txpowertrackingindex > 0) &&
+ (p->rfc_txpowertrackingindex > 0)) {
+ p->rfa_txpowertrackingindex--;
+ if (p->rfa_txpowertrackingindex_real > 4) {
+ p->rfa_txpowertrackingindex_real--;
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+ }
+
+ p->rfc_txpowertrackingindex--;
+ if (p->rfc_txpowertrackingindex_real > 4) {
+ p->rfc_txpowertrackingindex_real--;
+ rtl8192_setBBreg(dev,
+ rOFDM0_XCTxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]);
+ }
+ } else {
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[4]);
+ rtl8192_setBBreg(dev,
+ rOFDM0_XCTxIQImbalance,
+ bMaskDWord, dm_tx_bb_gain[4]);
+ }
+ } else {
+ if (p->rfa_txpowertrackingindex > 0) {
+ p->rfa_txpowertrackingindex--;
+ if (p->rfa_txpowertrackingindex_real > 4) {
+ p->rfa_txpowertrackingindex_real--;
+ rtl8192_setBBreg(dev,
+ rOFDM0_XATxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+ }
+ } else {
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+ bMaskDWord, dm_tx_bb_gain[4]);
+ }
+ }
+}
+
+static void dm_tx_update_tssi_strong_signal(struct net_device *dev, u8 RF_Type)
+{
+ struct r8192_priv *p = rtllib_priv(dev);
+
+ if (RF_Type == RF_2T4R) {
+ if ((p->rfa_txpowertrackingindex < TxBBGainTableLength - 1) &&
+ (p->rfc_txpowertrackingindex < TxBBGainTableLength - 1)) {
+ p->rfa_txpowertrackingindex++;
+ p->rfa_txpowertrackingindex_real++;
+ rtl8192_setBBreg(dev,
+ rOFDM0_XATxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+ p->rfc_txpowertrackingindex++;
+ p->rfc_txpowertrackingindex_real++;
+ rtl8192_setBBreg(dev,
+ rOFDM0_XCTxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[p->rfc_txpowertrackingindex_real]);
+ } else {
+ rtl8192_setBBreg(dev,
+ rOFDM0_XATxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[TxBBGainTableLength - 1]);
+ rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[TxBBGainTableLength - 1]);
+ }
+ } else {
+ if (p->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) {
+ p->rfa_txpowertrackingindex++;
+ p->rfa_txpowertrackingindex_real++;
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[p->rfa_txpowertrackingindex_real]);
+ } else {
+ rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
+ bMaskDWord,
+ dm_tx_bb_gain[TxBBGainTableLength - 1]);
+ }
+ }
+}
+
static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
{
struct r8192_priv *priv = rtllib_priv(dev);
@@ -538,7 +734,8 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
if (viviflag) {
write_nic_byte(dev, Pw_Track_Flag, 0);
viviflag = false;
- RT_TRACE(COMP_POWER_TRACKING, "we filted this data\n");
+ RT_TRACE(COMP_POWER_TRACKING,
+ "we filted this data\n");
for (k = 0; k < 5; k++)
tmp_report[k] = 0;
break;
@@ -547,12 +744,13 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
for (k = 0; k < 5; k++)
Avg_TSSI_Meas_from_driver += tmp_report[k];
- Avg_TSSI_Meas_from_driver = Avg_TSSI_Meas_from_driver*100/5;
+ Avg_TSSI_Meas_from_driver *= 100 / 5;
RT_TRACE(COMP_POWER_TRACKING,
"Avg_TSSI_Meas_from_driver = %d\n",
Avg_TSSI_Meas_from_driver);
TSSI_13dBm = priv->TSSI_13dBm;
- RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n", TSSI_13dBm);
+ RT_TRACE(COMP_POWER_TRACKING, "TSSI_13dBm = %d\n",
+ TSSI_13dBm);
if (Avg_TSSI_Meas_from_driver > TSSI_13dBm)
delta = Avg_TSSI_Meas_from_driver - TSSI_13dBm;
@@ -579,92 +777,11 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
priv->CCKPresentAttentuation);
return;
}
- if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK) {
- if (RF_Type == RF_2T4R) {
-
- if ((priv->rfa_txpowertrackingindex > 0) &&
- (priv->rfc_txpowertrackingindex > 0)) {
- priv->rfa_txpowertrackingindex--;
- if (priv->rfa_txpowertrackingindex_real > 4) {
- priv->rfa_txpowertrackingindex_real--;
- rtl8192_setBBreg(dev,
- rOFDM0_XATxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
- }
-
- priv->rfc_txpowertrackingindex--;
- if (priv->rfc_txpowertrackingindex_real > 4) {
- priv->rfc_txpowertrackingindex_real--;
- rtl8192_setBBreg(dev,
- rOFDM0_XCTxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
- }
- } else {
- rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table[4].txbbgain_value);
- rtl8192_setBBreg(dev,
- rOFDM0_XCTxIQImbalance,
- bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
- }
- } else {
- if (priv->rfa_txpowertrackingindex > 0) {
- priv->rfa_txpowertrackingindex--;
- if (priv->rfa_txpowertrackingindex_real > 4) {
- priv->rfa_txpowertrackingindex_real--;
- rtl8192_setBBreg(dev,
- rOFDM0_XATxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
- }
- } else
- rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
- bMaskDWord, priv->txbbgain_table[4].txbbgain_value);
+ if (Avg_TSSI_Meas_from_driver < TSSI_13dBm - E_FOR_TX_POWER_TRACK)
+ dm_tx_update_tssi_weak_signal(dev, RF_Type);
+ else
+ dm_tx_update_tssi_strong_signal(dev, RF_Type);
- }
- } else {
- if (RF_Type == RF_2T4R) {
- if ((priv->rfa_txpowertrackingindex <
- TxBBGainTableLength - 1) &&
- (priv->rfc_txpowertrackingindex <
- TxBBGainTableLength - 1)) {
- priv->rfa_txpowertrackingindex++;
- priv->rfa_txpowertrackingindex_real++;
- rtl8192_setBBreg(dev,
- rOFDM0_XATxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table
- [priv->rfa_txpowertrackingindex_real].txbbgain_value);
- priv->rfc_txpowertrackingindex++;
- priv->rfc_txpowertrackingindex_real++;
- rtl8192_setBBreg(dev,
- rOFDM0_XCTxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table[priv->rfc_txpowertrackingindex_real].txbbgain_value);
- } else {
- rtl8192_setBBreg(dev,
- rOFDM0_XATxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
- rtl8192_setBBreg(dev,
- rOFDM0_XCTxIQImbalance,
- bMaskDWord, priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
- }
- } else {
- if (priv->rfa_txpowertrackingindex < (TxBBGainTableLength - 1)) {
- priv->rfa_txpowertrackingindex++;
- priv->rfa_txpowertrackingindex_real++;
- rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table[priv->rfa_txpowertrackingindex_real].txbbgain_value);
- } else
- rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance,
- bMaskDWord,
- priv->txbbgain_table[TxBBGainTableLength - 1].txbbgain_value);
- }
- }
if (RF_Type == RF_2T4R) {
priv->CCKPresentAttentuation_difference
= priv->rfa_txpowertrackingindex - priv->rfa_txpowertracking_default;
@@ -712,11 +829,13 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev)
"priv->CCKPresentAttentuation = %d\n",
priv->CCKPresentAttentuation);
- if (priv->CCKPresentAttentuation_difference <= -12 || priv->CCKPresentAttentuation_difference >= 24) {
+ if (priv->CCKPresentAttentuation_difference <= -12 ||
+ priv->CCKPresentAttentuation_difference >= 24) {
priv->rtllib->bdynamic_txpower_enable = true;
write_nic_byte(dev, Pw_Track_Flag, 0);
write_nic_byte(dev, FW_Busy_Flag, 0);
- RT_TRACE(COMP_POWER_TRACKING, "tx power track--->limited\n");
+ RT_TRACE(COMP_POWER_TRACKING,
+ "tx power track--->limited\n");
return;
}
@@ -741,12 +860,15 @@ static void dm_TXPowerTrackingCallback_ThermalMeter(struct net_device *dev)
int i = 0, CCKSwingNeedUpdate = 0;
if (!priv->btxpower_trackingInit) {
- tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord);
+ tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance,
+ bMaskDWord);
for (i = 0; i < OFDM_Table_Length; i++) {
if (tmpRegA == OFDMSwingTable[i]) {
priv->OFDM_index[0] = (u8)i;
- RT_TRACE(COMP_POWER_TRACKING, "Initial reg0x%x = 0x%x, OFDM_index = 0x%x\n",
- rOFDM0_XATxIQImbalance, tmpRegA, priv->OFDM_index[0]);
+ RT_TRACE(COMP_POWER_TRACKING,
+ "Initial reg0x%x = 0x%x, OFDM_index = 0x%x\n",
+ rOFDM0_XATxIQImbalance, tmpRegA,
+ priv->OFDM_index[0]);
}
}
@@ -849,495 +971,6 @@ static void dm_InitializeTXPowerTracking_TSSI(struct net_device *dev)
struct r8192_priv *priv = rtllib_priv(dev);
- priv->txbbgain_table[0].txbb_iq_amplifygain = 12;
- priv->txbbgain_table[0].txbbgain_value = 0x7f8001fe;
- priv->txbbgain_table[1].txbb_iq_amplifygain = 11;
- priv->txbbgain_table[1].txbbgain_value = 0x788001e2;
- priv->txbbgain_table[2].txbb_iq_amplifygain = 10;
- priv->txbbgain_table[2].txbbgain_value = 0x71c001c7;
- priv->txbbgain_table[3].txbb_iq_amplifygain = 9;
- priv->txbbgain_table[3].txbbgain_value = 0x6b8001ae;
- priv->txbbgain_table[4].txbb_iq_amplifygain = 8;
- priv->txbbgain_table[4].txbbgain_value = 0x65400195;
- priv->txbbgain_table[5].txbb_iq_amplifygain = 7;
- priv->txbbgain_table[5].txbbgain_value = 0x5fc0017f;
- priv->txbbgain_table[6].txbb_iq_amplifygain = 6;
- priv->txbbgain_table[6].txbbgain_value = 0x5a400169;
- priv->txbbgain_table[7].txbb_iq_amplifygain = 5;
- priv->txbbgain_table[7].txbbgain_value = 0x55400155;
- priv->txbbgain_table[8].txbb_iq_amplifygain = 4;
- priv->txbbgain_table[8].txbbgain_value = 0x50800142;
- priv->txbbgain_table[9].txbb_iq_amplifygain = 3;
- priv->txbbgain_table[9].txbbgain_value = 0x4c000130;
- priv->txbbgain_table[10].txbb_iq_amplifygain = 2;
- priv->txbbgain_table[10].txbbgain_value = 0x47c0011f;
- priv->txbbgain_table[11].txbb_iq_amplifygain = 1;
- priv->txbbgain_table[11].txbbgain_value = 0x43c0010f;
- priv->txbbgain_table[12].txbb_iq_amplifygain = 0;
- priv->txbbgain_table[12].txbbgain_value = 0x40000100;
- priv->txbbgain_table[13].txbb_iq_amplifygain = -1;
- priv->txbbgain_table[13].txbbgain_value = 0x3c8000f2;
- priv->txbbgain_table[14].txbb_iq_amplifygain = -2;
- priv->txbbgain_table[14].txbbgain_value = 0x390000e4;
- priv->txbbgain_table[15].txbb_iq_amplifygain = -3;
- priv->txbbgain_table[15].txbbgain_value = 0x35c000d7;
- priv->txbbgain_table[16].txbb_iq_amplifygain = -4;
- priv->txbbgain_table[16].txbbgain_value = 0x32c000cb;
- priv->txbbgain_table[17].txbb_iq_amplifygain = -5;
- priv->txbbgain_table[17].txbbgain_value = 0x300000c0;
- priv->txbbgain_table[18].txbb_iq_amplifygain = -6;
- priv->txbbgain_table[18].txbbgain_value = 0x2d4000b5;
- priv->txbbgain_table[19].txbb_iq_amplifygain = -7;
- priv->txbbgain_table[19].txbbgain_value = 0x2ac000ab;
- priv->txbbgain_table[20].txbb_iq_amplifygain = -8;
- priv->txbbgain_table[20].txbbgain_value = 0x288000a2;
- priv->txbbgain_table[21].txbb_iq_amplifygain = -9;
- priv->txbbgain_table[21].txbbgain_value = 0x26000098;
- priv->txbbgain_table[22].txbb_iq_amplifygain = -10;
- priv->txbbgain_table[22].txbbgain_value = 0x24000090;
- priv->txbbgain_table[23].txbb_iq_amplifygain = -11;
- priv->txbbgain_table[23].txbbgain_value = 0x22000088;
- priv->txbbgain_table[24].txbb_iq_amplifygain = -12;
- priv->txbbgain_table[24].txbbgain_value = 0x20000080;
- priv->txbbgain_table[25].txbb_iq_amplifygain = -13;
- priv->txbbgain_table[25].txbbgain_value = 0x1a00006c;
- priv->txbbgain_table[26].txbb_iq_amplifygain = -14;
- priv->txbbgain_table[26].txbbgain_value = 0x1c800072;
- priv->txbbgain_table[27].txbb_iq_amplifygain = -15;
- priv->txbbgain_table[27].txbbgain_value = 0x18000060;
- priv->txbbgain_table[28].txbb_iq_amplifygain = -16;
- priv->txbbgain_table[28].txbbgain_value = 0x19800066;
- priv->txbbgain_table[29].txbb_iq_amplifygain = -17;
- priv->txbbgain_table[29].txbbgain_value = 0x15800056;
- priv->txbbgain_table[30].txbb_iq_amplifygain = -18;
- priv->txbbgain_table[30].txbbgain_value = 0x26c0005b;
- priv->txbbgain_table[31].txbb_iq_amplifygain = -19;
- priv->txbbgain_table[31].txbbgain_value = 0x14400051;
- priv->txbbgain_table[32].txbb_iq_amplifygain = -20;
- priv->txbbgain_table[32].txbbgain_value = 0x24400051;
- priv->txbbgain_table[33].txbb_iq_amplifygain = -21;
- priv->txbbgain_table[33].txbbgain_value = 0x1300004c;
- priv->txbbgain_table[34].txbb_iq_amplifygain = -22;
- priv->txbbgain_table[34].txbbgain_value = 0x12000048;
- priv->txbbgain_table[35].txbb_iq_amplifygain = -23;
- priv->txbbgain_table[35].txbbgain_value = 0x11000044;
- priv->txbbgain_table[36].txbb_iq_amplifygain = -24;
- priv->txbbgain_table[36].txbbgain_value = 0x10000040;
-
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[0] = 0x36;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[1] = 0x35;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[2] = 0x2e;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[3] = 0x25;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[4] = 0x1c;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[5] = 0x12;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[6] = 0x09;
- priv->cck_txbbgain_table[0].ccktxbb_valuearray[7] = 0x04;
-
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[0] = 0x33;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[1] = 0x32;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[2] = 0x2b;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[3] = 0x23;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[4] = 0x1a;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[5] = 0x11;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[6] = 0x08;
- priv->cck_txbbgain_table[1].ccktxbb_valuearray[7] = 0x04;
-
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[0] = 0x30;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[1] = 0x2f;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[2] = 0x29;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[3] = 0x21;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[4] = 0x19;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[5] = 0x10;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[6] = 0x08;
- priv->cck_txbbgain_table[2].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[0] = 0x2d;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[1] = 0x2d;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[2] = 0x27;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[3] = 0x1f;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[4] = 0x18;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[5] = 0x0f;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[6] = 0x08;
- priv->cck_txbbgain_table[3].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[0] = 0x2b;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[1] = 0x2a;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[2] = 0x25;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[3] = 0x1e;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[4] = 0x16;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[5] = 0x0e;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[6] = 0x07;
- priv->cck_txbbgain_table[4].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[0] = 0x28;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[1] = 0x28;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[2] = 0x22;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[3] = 0x1c;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[4] = 0x15;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[5] = 0x0d;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[6] = 0x07;
- priv->cck_txbbgain_table[5].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[0] = 0x26;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[1] = 0x25;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[2] = 0x21;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[3] = 0x1b;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[4] = 0x14;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[5] = 0x0d;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[6] = 0x06;
- priv->cck_txbbgain_table[6].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[0] = 0x24;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[1] = 0x23;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[2] = 0x1f;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[3] = 0x19;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[4] = 0x13;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[5] = 0x0c;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[6] = 0x06;
- priv->cck_txbbgain_table[7].ccktxbb_valuearray[7] = 0x03;
-
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[0] = 0x22;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[1] = 0x21;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[2] = 0x1d;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[3] = 0x18;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[4] = 0x11;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[5] = 0x0b;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[6] = 0x06;
- priv->cck_txbbgain_table[8].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[0] = 0x20;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[1] = 0x20;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[2] = 0x1b;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[3] = 0x16;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[4] = 0x11;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[5] = 0x08;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[6] = 0x05;
- priv->cck_txbbgain_table[9].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[0] = 0x1f;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[1] = 0x1e;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[2] = 0x1a;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[3] = 0x15;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[4] = 0x10;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[5] = 0x0a;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[6] = 0x05;
- priv->cck_txbbgain_table[10].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[0] = 0x1d;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[1] = 0x1c;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[2] = 0x18;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[3] = 0x14;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[4] = 0x0f;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[5] = 0x0a;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[6] = 0x05;
- priv->cck_txbbgain_table[11].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[0] = 0x1b;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[1] = 0x1a;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[2] = 0x17;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[3] = 0x13;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[4] = 0x0e;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[5] = 0x09;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[12].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[0] = 0x1a;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[1] = 0x19;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[2] = 0x16;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[3] = 0x12;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[4] = 0x0d;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[5] = 0x09;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[13].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[0] = 0x18;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[1] = 0x17;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[2] = 0x15;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[3] = 0x11;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[4] = 0x0c;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[5] = 0x08;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[14].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[0] = 0x17;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[1] = 0x16;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[2] = 0x13;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[3] = 0x10;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[4] = 0x0c;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[5] = 0x08;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[15].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[0] = 0x16;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[1] = 0x15;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[2] = 0x12;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[3] = 0x0f;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[4] = 0x0b;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[5] = 0x07;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[6] = 0x04;
- priv->cck_txbbgain_table[16].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[0] = 0x14;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[1] = 0x14;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[2] = 0x11;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[3] = 0x0e;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[4] = 0x0b;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[5] = 0x07;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[17].ccktxbb_valuearray[7] = 0x02;
-
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[0] = 0x13;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[1] = 0x13;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[2] = 0x10;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[3] = 0x0d;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[4] = 0x0a;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[5] = 0x06;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[18].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[0] = 0x12;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[1] = 0x12;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[2] = 0x0f;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[3] = 0x0c;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[4] = 0x09;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[5] = 0x06;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[19].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[0] = 0x11;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[1] = 0x11;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[2] = 0x0f;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[3] = 0x0c;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[4] = 0x09;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[5] = 0x06;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[20].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[0] = 0x10;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[1] = 0x10;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[2] = 0x0e;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[3] = 0x0b;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[4] = 0x08;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[5] = 0x05;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[21].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[0] = 0x0f;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[1] = 0x0f;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[2] = 0x0d;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[3] = 0x0b;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[4] = 0x08;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[5] = 0x05;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[6] = 0x03;
- priv->cck_txbbgain_table[22].ccktxbb_valuearray[7] = 0x01;
-
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[0] = 0x36;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[1] = 0x35;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[2] = 0x2e;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[3] = 0x1b;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[0].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[0] = 0x33;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[1] = 0x32;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[2] = 0x2b;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[3] = 0x19;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[1].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[0] = 0x30;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[1] = 0x2f;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[2] = 0x29;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[3] = 0x18;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[2].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[0] = 0x2d;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[1] = 0x2d;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[2] = 0x27;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[3] = 0x17;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[3].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[0] = 0x2b;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[1] = 0x2a;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[2] = 0x25;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[3] = 0x15;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[4].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[0] = 0x28;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[1] = 0x28;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[2] = 0x22;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[3] = 0x14;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[5].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[0] = 0x26;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[1] = 0x25;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[2] = 0x21;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[3] = 0x13;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[6].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[0] = 0x24;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[1] = 0x23;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[2] = 0x1f;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[3] = 0x12;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[7].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[0] = 0x22;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[1] = 0x21;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[2] = 0x1d;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[3] = 0x11;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[8].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[0] = 0x20;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[1] = 0x20;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[2] = 0x1b;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[3] = 0x10;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[9].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[0] = 0x1f;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[1] = 0x1e;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[2] = 0x1a;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[3] = 0x0f;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[10].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[0] = 0x1d;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[1] = 0x1c;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[2] = 0x18;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[3] = 0x0e;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[11].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[0] = 0x1b;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[1] = 0x1a;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[2] = 0x17;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[3] = 0x0e;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[12].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[0] = 0x1a;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[1] = 0x19;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[2] = 0x16;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[3] = 0x0d;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[13].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[0] = 0x18;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[1] = 0x17;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[2] = 0x15;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[3] = 0x0c;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[14].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[0] = 0x17;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[1] = 0x16;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[2] = 0x13;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[3] = 0x0b;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[15].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[0] = 0x16;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[1] = 0x15;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[2] = 0x12;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[3] = 0x0b;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[16].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[0] = 0x14;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[1] = 0x14;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[2] = 0x11;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[3] = 0x0a;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[17].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[0] = 0x13;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[1] = 0x13;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[2] = 0x10;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[3] = 0x0a;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[18].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[0] = 0x12;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[1] = 0x12;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[2] = 0x0f;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[3] = 0x09;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[19].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[0] = 0x11;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[1] = 0x11;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[2] = 0x0f;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[3] = 0x09;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[20].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[0] = 0x10;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[1] = 0x10;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[2] = 0x0e;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[3] = 0x08;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[21].ccktxbb_valuearray[7] = 0x00;
-
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[0] = 0x0f;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[1] = 0x0f;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[2] = 0x0d;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[3] = 0x08;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[4] = 0x00;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[5] = 0x00;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[6] = 0x00;
- priv->cck_txbbgain_ch14_table[22].ccktxbb_valuearray[7] = 0x00;
-
priv->btxpower_tracking = true;
priv->txpower_count = 0;
priv->btxpower_trackingInit = false;
@@ -1383,7 +1016,8 @@ static void dm_CheckTXPowerTracking_TSSI(struct net_device *dev)
if (tx_power_track_counter >= 180) {
- queue_delayed_work_rsl(priv->priv_wq, &priv->txpower_tracking_wq, 0);
+ queue_delayed_work_rsl(priv->priv_wq,
+ &priv->txpower_tracking_wq, 0);
tx_power_track_counter = 0;
}
@@ -1436,88 +1070,91 @@ static void dm_CCKTxPowerAdjust_TSSI(struct net_device *dev, bool bInCH14)
{
u32 TempVal;
struct r8192_priv *priv = rtllib_priv(dev);
+ u8 attenuation = (u8)priv->CCKPresentAttentuation;
TempVal = 0;
if (!bInCH14) {
- TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] +
- (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8));
+ TempVal = (u32)(dm_cck_tx_bb_gain[attenuation][0] +
+ (dm_cck_tx_bb_gain[attenuation][1] << 8));
rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
- TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] +
- (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) +
- (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+
- (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24));
+ TempVal = (u32)((dm_cck_tx_bb_gain[attenuation][2]) +
+ (dm_cck_tx_bb_gain[attenuation][3] << 8) +
+ (dm_cck_tx_bb_gain[attenuation][4] << 16)+
+ (dm_cck_tx_bb_gain[attenuation][5] << 24));
rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
- TempVal = (u32)(priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] +
- (priv->cck_txbbgain_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8));
+ TempVal = (u32)(dm_cck_tx_bb_gain[attenuation][6] +
+ (dm_cck_tx_bb_gain[attenuation][7] << 8));
rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
} else {
- TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[0] +
- (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[1]<<8));
+ TempVal = (u32)((dm_cck_tx_bb_gain_ch14[attenuation][0]) +
+ (dm_cck_tx_bb_gain_ch14[attenuation][1] << 8));
rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
- TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[2] +
- (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[3]<<8) +
- (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[4]<<16)+
- (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[5]<<24));
+ TempVal = (u32)((dm_cck_tx_bb_gain_ch14[attenuation][2]) +
+ (dm_cck_tx_bb_gain_ch14[attenuation][3] << 8) +
+ (dm_cck_tx_bb_gain_ch14[attenuation][4] << 16)+
+ (dm_cck_tx_bb_gain_ch14[attenuation][5] << 24));
rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
- TempVal = (u32)(priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[6] +
- (priv->cck_txbbgain_ch14_table[(u8)(priv->CCKPresentAttentuation)].ccktxbb_valuearray[7]<<8));
+ TempVal = (u32)((dm_cck_tx_bb_gain_ch14[attenuation][6]) +
+ (dm_cck_tx_bb_gain_ch14[attenuation][7] << 8));
rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
}
-
-
}
-static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev, bool bInCH14)
+static void dm_CCKTxPowerAdjust_ThermalMeter(struct net_device *dev,
+ bool bInCH14)
{
u32 TempVal;
struct r8192_priv *priv = rtllib_priv(dev);
TempVal = 0;
if (!bInCH14) {
- TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] +
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1]<<8);
+ TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][0] +
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][1] << 8);
rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_TxFilter1, TempVal);
- TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] +
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3]<<8) +
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4]<<16)+
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5]<<24);
+ RT_TRACE(COMP_POWER_TRACKING,
+ "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter1,
+ TempVal);
+ TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][2] +
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][3] << 8) +
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][4] << 16)+
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][5] << 24);
rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_TxFilter2, TempVal);
- TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
- (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7]<<8);
+ RT_TRACE(COMP_POWER_TRACKING,
+ "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_TxFilter2,
+ TempVal);
+ TempVal = CCKSwingTable_Ch1_Ch13[priv->CCK_index][6] +
+ (CCKSwingTable_Ch1_Ch13[priv->CCK_index][7] << 8);
rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
- RT_TRACE(COMP_POWER_TRACKING, "CCK not chnl 14, reg 0x%x = 0x%x\n",
- rCCK0_DebugPort, TempVal);
+ RT_TRACE(COMP_POWER_TRACKING,
+ "CCK not chnl 14, reg 0x%x = 0x%x\n", rCCK0_DebugPort,
+ TempVal);
} else {
- TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] +
- (CCKSwingTable_Ch14[priv->CCK_index][1]<<8);
+ TempVal = CCKSwingTable_Ch14[priv->CCK_index][0] +
+ (CCKSwingTable_Ch14[priv->CCK_index][1] << 8);
rtl8192_setBBreg(dev, rCCK0_TxFilter1, bMaskHWord, TempVal);
RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
rCCK0_TxFilter1, TempVal);
- TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] +
- (CCKSwingTable_Ch14[priv->CCK_index][3]<<8) +
- (CCKSwingTable_Ch14[priv->CCK_index][4]<<16)+
- (CCKSwingTable_Ch14[priv->CCK_index][5]<<24);
+ TempVal = CCKSwingTable_Ch14[priv->CCK_index][2] +
+ (CCKSwingTable_Ch14[priv->CCK_index][3] << 8) +
+ (CCKSwingTable_Ch14[priv->CCK_index][4] << 16)+
+ (CCKSwingTable_Ch14[priv->CCK_index][5] << 24);
rtl8192_setBBreg(dev, rCCK0_TxFilter2, bMaskDWord, TempVal);
RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
rCCK0_TxFilter2, TempVal);
- TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] +
- (CCKSwingTable_Ch14[priv->CCK_index][7]<<8);
+ TempVal = CCKSwingTable_Ch14[priv->CCK_index][6] +
+ (CCKSwingTable_Ch14[priv->CCK_index][7]<<8);
rtl8192_setBBreg(dev, rCCK0_DebugPort, bMaskLWord, TempVal);
RT_TRACE(COMP_POWER_TRACKING, "CCK chnl 14, reg 0x%x = 0x%x\n",
rCCK0_DebugPort, TempVal);
}
- }
+}
void dm_cck_txpower_adjust(struct net_device *dev, bool binch14)
{
@@ -1535,26 +1172,30 @@ static void dm_txpower_reset_recovery(struct net_device *dev)
RT_TRACE(COMP_POWER_TRACKING, "Start Reset Recovery ==>\n");
rtl8192_setBBreg(dev, rOFDM0_XATxIQImbalance, bMaskDWord,
- priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value);
+ dm_tx_bb_gain[priv->rfa_txpowertrackingindex]);
RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc80 is %08x\n",
- priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbbgain_value);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",
+ dm_tx_bb_gain[priv->rfa_txpowertrackingindex]);
+ RT_TRACE(COMP_POWER_TRACKING,
+ "Reset Recovery: Fill in RFA_txPowerTrackingIndex is %x\n",
priv->rfa_txpowertrackingindex);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF A I/Q Amplify Gain is %ld\n",
- priv->txbbgain_table[priv->rfa_txpowertrackingindex].txbb_iq_amplifygain);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: CCK Attenuation is %d dB\n",
+ RT_TRACE(COMP_POWER_TRACKING,
+ "Reset Recovery : RF A I/Q Amplify Gain is %d\n",
+ dm_tx_bb_gain_idx_to_amplify(priv->rfa_txpowertrackingindex));
+ RT_TRACE(COMP_POWER_TRACKING,
+ "Reset Recovery: CCK Attenuation is %d dB\n",
priv->CCKPresentAttentuation);
dm_cck_txpower_adjust(dev, priv->bcck_in_ch14);
rtl8192_setBBreg(dev, rOFDM0_XCTxIQImbalance, bMaskDWord,
- priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value);
+ dm_tx_bb_gain[priv->rfc_txpowertrackingindex]);
RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in 0xc90 is %08x\n",
- priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbbgain_value);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",
+ dm_tx_bb_gain[priv->rfc_txpowertrackingindex]);
+ RT_TRACE(COMP_POWER_TRACKING,
+ "Reset Recovery: Fill in RFC_txPowerTrackingIndex is %x\n",
priv->rfc_txpowertrackingindex);
- RT_TRACE(COMP_POWER_TRACKING, "Reset Recovery : RF C I/Q Amplify Gain is %ld\n",
- priv->txbbgain_table[priv->rfc_txpowertrackingindex].txbb_iq_amplifygain);
-
+ RT_TRACE(COMP_POWER_TRACKING,
+ "Reset Recovery : RF C I/Q Amplify Gain is %d\n",
+ dm_tx_bb_gain_idx_to_amplify(priv->rfc_txpowertrackingindex));
}
void dm_restore_dynamic_mechanism_state(struct net_device *dev)
@@ -1564,7 +1205,8 @@ void dm_restore_dynamic_mechanism_state(struct net_device *dev)
u32 ratr_value;
if (!priv->up) {
- RT_TRACE(COMP_RATE, "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
+ RT_TRACE(COMP_RATE,
+ "<---- dm_restore_dynamic_mechanism_state(): driver is going to unload\n");
return;
}
@@ -1594,18 +1236,28 @@ static void dm_bb_initialgain_restore(struct net_device *dev)
return;
rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x8);
- rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask, (u32)priv->initgain_backup.xaagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask, (u32)priv->initgain_backup.xbagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask, (u32)priv->initgain_backup.xcagccore1);
- rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask, (u32)priv->initgain_backup.xdagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XAAGCCore1, bit_mask,
+ (u32)priv->initgain_backup.xaagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XBAGCCore1, bit_mask,
+ (u32)priv->initgain_backup.xbagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XCAGCCore1, bit_mask,
+ (u32)priv->initgain_backup.xcagccore1);
+ rtl8192_setBBreg(dev, rOFDM0_XDAGCCore1, bit_mask,
+ (u32)priv->initgain_backup.xdagccore1);
bit_mask = bMaskByte2;
- rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask, (u32)priv->initgain_backup.cca);
-
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n", priv->initgain_backup.xaagccore1);
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n", priv->initgain_backup.xbagccore1);
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n", priv->initgain_backup.xcagccore1);
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n", priv->initgain_backup.xdagccore1);
- RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n", priv->initgain_backup.cca);
+ rtl8192_setBBreg(dev, rCCK0_CCA, bit_mask,
+ (u32)priv->initgain_backup.cca);
+
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc50 is %x\n",
+ priv->initgain_backup.xaagccore1);
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc58 is %x\n",
+ priv->initgain_backup.xbagccore1);
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc60 is %x\n",
+ priv->initgain_backup.xcagccore1);
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xc68 is %x\n",
+ priv->initgain_backup.xdagccore1);
+ RT_TRACE(COMP_DIG, "dm_BBInitialGainRestore 0xa0a is %x\n",
+ priv->initgain_backup.cca);
rtl8192_setBBreg(dev, UFWP, bMaskByte1, 0x1);
}
@@ -1638,11 +1290,16 @@ static void dm_bb_initialgain_backup(struct net_device *dev)
bit_mask = bMaskByte2;
priv->initgain_backup.cca = (u8)rtl8192_QueryBBReg(dev, rCCK0_CCA, bit_mask);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n", priv->initgain_backup.xaagccore1);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n", priv->initgain_backup.xbagccore1);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n", priv->initgain_backup.xcagccore1);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n", priv->initgain_backup.xdagccore1);
- RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n", priv->initgain_backup.cca);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc50 is %x\n",
+ priv->initgain_backup.xaagccore1);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc58 is %x\n",
+ priv->initgain_backup.xbagccore1);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc60 is %x\n",
+ priv->initgain_backup.xcagccore1);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xc68 is %x\n",
+ priv->initgain_backup.xdagccore1);
+ RT_TRACE(COMP_DIG, "BBInitialGainBackup 0xa0a is %x\n",
+ priv->initgain_backup.cca);
}
@@ -1708,8 +1365,10 @@ static void dm_dig_init(struct net_device *dev)
dm_digtable.dig_state = DM_STA_DIG_MAX;
dm_digtable.dig_highpwr_state = DM_STA_DIG_MAX;
- dm_digtable.CurSTAConnectState = dm_digtable.PreSTAConnectState = DIG_STA_DISCONNECT;
- dm_digtable.CurAPConnectState = dm_digtable.PreAPConnectState = DIG_AP_DISCONNECT;
+ dm_digtable.CurSTAConnectState = DIG_STA_DISCONNECT;
+ dm_digtable.PreSTAConnectState = DIG_STA_DISCONNECT;
+ dm_digtable.CurAPConnectState = DIG_AP_DISCONNECT;
+ dm_digtable.PreAPConnectState = DIG_AP_DISCONNECT;
dm_digtable.initialgain_lowerbound_state = false;
dm_digtable.rssi_low_thresh = DM_DIG_THRESH_LOW;
@@ -1895,11 +1554,14 @@ static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev)
struct r8192_priv *priv = rtllib_priv(dev);
static u32 reset_cnt_highpwr;
- if ((priv->undecorated_smoothed_pwdb > dm_digtable.rssi_high_power_lowthresh) &&
- (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_highthresh))
+ if ((priv->undecorated_smoothed_pwdb >
+ dm_digtable.rssi_high_power_lowthresh) &&
+ (priv->undecorated_smoothed_pwdb <
+ dm_digtable.rssi_high_power_highthresh))
return;
- if (priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_power_highthresh) {
+ if (priv->undecorated_smoothed_pwdb >=
+ dm_digtable.rssi_high_power_highthresh) {
if (dm_digtable.dig_highpwr_state == DM_STA_DIG_ON &&
(priv->reset_count == reset_cnt_highpwr))
return;
@@ -1915,8 +1577,10 @@ static void dm_ctrl_initgain_byrssi_highpwr(struct net_device *dev)
return;
dm_digtable.dig_highpwr_state = DM_STA_DIG_OFF;
- if (priv->undecorated_smoothed_pwdb < dm_digtable.rssi_high_power_lowthresh &&
- priv->undecorated_smoothed_pwdb >= dm_digtable.rssi_high_thresh) {
+ if ((priv->undecorated_smoothed_pwdb <
+ dm_digtable.rssi_high_power_lowthresh) &&
+ (priv->undecorated_smoothed_pwdb >=
+ dm_digtable.rssi_high_thresh)) {
if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
else
@@ -1945,12 +1609,12 @@ static void dm_initial_gain(struct net_device *dev)
if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) {
if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) {
- if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) > dm_digtable.rx_gain_range_max)
- dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_max;
- else if ((dm_digtable.rssi_val+10-dm_digtable.backoff_val) < dm_digtable.rx_gain_range_min)
- dm_digtable.cur_ig_value = dm_digtable.rx_gain_range_min;
- else
- dm_digtable.cur_ig_value = dm_digtable.rssi_val+10-dm_digtable.backoff_val;
+ long gain_range = dm_digtable.rssi_val + 10 -
+ dm_digtable.backoff_val;
+ gain_range = clamp_t(long, gain_range,
+ dm_digtable.rx_gain_range_min,
+ dm_digtable.rx_gain_range_max);
+ dm_digtable.cur_ig_value = gain_range;
} else {
if (dm_digtable.cur_ig_value == 0)
dm_digtable.cur_ig_value = priv->DefaultInitialGain[0];
@@ -1996,15 +1660,23 @@ static void dm_pd_th(struct net_device *dev)
if (dm_digtable.PreSTAConnectState == dm_digtable.CurSTAConnectState) {
if (dm_digtable.CurSTAConnectState == DIG_STA_CONNECT) {
- if (dm_digtable.rssi_val >= dm_digtable.rssi_high_power_highthresh)
- dm_digtable.curpd_thstate = DIG_PD_AT_HIGH_POWER;
- else if (dm_digtable.rssi_val <= dm_digtable.rssi_low_thresh)
- dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
- else if ((dm_digtable.rssi_val >= dm_digtable.rssi_high_thresh) &&
- (dm_digtable.rssi_val < dm_digtable.rssi_high_power_lowthresh))
- dm_digtable.curpd_thstate = DIG_PD_AT_NORMAL_POWER;
+ if (dm_digtable.rssi_val >=
+ dm_digtable.rssi_high_power_highthresh)
+ dm_digtable.curpd_thstate =
+ DIG_PD_AT_HIGH_POWER;
+ else if (dm_digtable.rssi_val <=
+ dm_digtable.rssi_low_thresh)
+ dm_digtable.curpd_thstate =
+ DIG_PD_AT_LOW_POWER;
+ else if ((dm_digtable.rssi_val >=
+ dm_digtable.rssi_high_thresh) &&
+ (dm_digtable.rssi_val <
+ dm_digtable.rssi_high_power_lowthresh))
+ dm_digtable.curpd_thstate =
+ DIG_PD_AT_NORMAL_POWER;
else
- dm_digtable.curpd_thstate = dm_digtable.prepd_thstate;
+ dm_digtable.curpd_thstate =
+ dm_digtable.prepd_thstate;
} else {
dm_digtable.curpd_thstate = DIG_PD_AT_LOW_POWER;
}
@@ -2024,7 +1696,8 @@ static void dm_pd_th(struct net_device *dev)
write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x00);
else
write_nic_byte(dev, rOFDM0_RxDetector1, 0x42);
- } else if (dm_digtable.curpd_thstate == DIG_PD_AT_NORMAL_POWER) {
+ } else if (dm_digtable.curpd_thstate ==
+ DIG_PD_AT_NORMAL_POWER) {
if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20)
write_nic_byte(dev, (rOFDM0_XATxAFE+3), 0x20);
else
@@ -2143,10 +1816,12 @@ static void dm_check_edca_turbo(struct net_device *dev)
if (!priv->bis_cur_rdlstate ||
!priv->bcurrent_turbo_EDCA) {
if (priv->rtllib->mode == WIRELESS_MODE_G)
- write_nic_dword(dev, EDCAPARA_BE,
+ write_nic_dword(dev,
+ EDCAPARA_BE,
edca_setting_DL_GMode[pHTInfo->IOTPeer]);
else
- write_nic_dword(dev, EDCAPARA_BE,
+ write_nic_dword(dev,
+ EDCAPARA_BE,
edca_setting_DL[pHTInfo->IOTPeer]);
priv->bis_cur_rdlstate = true;
}
@@ -2154,12 +1829,15 @@ static void dm_check_edca_turbo(struct net_device *dev)
priv->bcurrent_turbo_EDCA = true;
} else {
if (curRxOkCnt > 4*curTxOkCnt) {
- if (!priv->bis_cur_rdlstate || !priv->bcurrent_turbo_EDCA) {
+ if (!priv->bis_cur_rdlstate ||
+ !priv->bcurrent_turbo_EDCA) {
if (priv->rtllib->mode == WIRELESS_MODE_G)
- write_nic_dword(dev, EDCAPARA_BE,
+ write_nic_dword(dev,
+ EDCAPARA_BE,
edca_setting_DL_GMode[pHTInfo->IOTPeer]);
else
- write_nic_dword(dev, EDCAPARA_BE,
+ write_nic_dword(dev,
+ EDCAPARA_BE,
edca_setting_DL[pHTInfo->IOTPeer]);
priv->bis_cur_rdlstate = true;
}
@@ -2179,7 +1857,8 @@ static void dm_check_edca_turbo(struct net_device *dev)
if (priv->bcurrent_turbo_EDCA) {
u8 tmp = AC0_BE;
- priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM, (u8 *)(&tmp));
+ priv->rtllib->SetHwRegHandler(dev, HW_VAR_AC_PARAM,
+ (u8 *)(&tmp));
priv->bcurrent_turbo_EDCA = false;
}
}
@@ -2249,7 +1928,8 @@ void dm_CheckRfCtrlGPIO(void *data)
bool bActuallySet = false;
char *argv[3];
static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh";
- static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL};
+ static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin",
+ NULL};
bActuallySet = false;
@@ -2280,7 +1960,8 @@ void dm_CheckRfCtrlGPIO(void *data)
if (bActuallySet) {
mdelay(1000);
priv->bHwRfOffAction = 1;
- MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW, true);
+ MgntActSet_RF_State(dev, eRfPowerStateToSet, RF_CHANGE_BY_HW,
+ true);
if (priv->bHwRadioOff)
argv[1] = "RFOFF";
else
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h
index 3f02e11cfc57ec..6be8e8bd640af1 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_dm.h
@@ -252,11 +252,20 @@ extern u8 dm_shadow[16][256];
extern struct drx_path_sel DM_RxPathSelTable;
extern u8 test_flag;
+
+/* Pre-calculated gain tables */
+extern const u32 dm_tx_bb_gain[TxBBGainTableLength];
+extern const u8 dm_cck_tx_bb_gain[CCKTxBBGainTableLength][8];
+extern const u8 dm_cck_tx_bb_gain_ch14[CCKTxBBGainTableLength][8];
+/* Maps table index to iq amplify gain (dB, 12 to -24dB) */
+#define dm_tx_bb_gain_idx_to_amplify(idx) (-idx + 12)
+
/*------------------------Export global variable----------------------------*/
/*--------------------------Exported Function prototype---------------------*/
/*--------------------------Exported Function prototype---------------------*/
+
extern void init_hal_dm(struct net_device *dev);
extern void deinit_hal_dm(struct net_device *dev);
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c
index 51f53be2de17f0..e8065c0ed05fb4 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pci.c
@@ -62,7 +62,7 @@ bool rtl8192_pci_findadapter(struct pci_dev *pdev, struct net_device *dev)
priv->card_8192 = priv->ops->nic_type;
- if (DeviceID == 0x8172) {
+ if (DeviceID == 0x8192) {
switch (RevisionID) {
case HAL_HW_PCI_REVISION_ID_8192PCIE:
dev_info(&pdev->dev,
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
index ca6ecfc8299e88..e4908672421ce1 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_pm.c
@@ -57,10 +57,8 @@ int rtl8192E_suspend(struct pci_dev *pdev, pm_message_t state)
write_nic_byte(dev, MacBlkCtrl, 0xa);
}
out_pci_suspend:
- netdev_info(dev, "r8192E support WOL call??????????????????????\n");
- if (priv->rtllib->bSupportRemoteWakeUp)
- RT_TRACE(COMP_POWER,
- "r8192E support WOL call!!!!!!!!!!!!!!!!!!.\n");
+ netdev_info(dev, "WOL is %s\n", priv->rtllib->bSupportRemoteWakeUp ?
+ "Supported" : "Not supported");
pci_save_state(pdev);
pci_disable_device(pdev);
pci_enable_wake(pdev, pci_choose_state(pdev, state),
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
index 0bbffec0c2ae2e..404cb83153d940 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_ps.c
@@ -28,6 +28,7 @@
#include "r8192E_phyreg.h"
#include "r8190P_rtl8256.h" /* RTL8225 Radio frontend */
#include "r8192E_cmdpkt.h"
+#include <linux/jiffies.h>
static void rtl8192_hw_sleep_down(struct net_device *dev)
{
@@ -93,19 +94,21 @@ void rtl8192_hw_to_sleep(struct net_device *dev, u64 time)
u32 tmp;
unsigned long flags;
+ unsigned long timeout;
spin_lock_irqsave(&priv->ps_lock, flags);
time -= msecs_to_jiffies(8 + 16 + 7);
- if ((time - jiffies) <= msecs_to_jiffies(MIN_SLEEP_TIME)) {
+ timeout = jiffies + msecs_to_jiffies(MIN_SLEEP_TIME);
+ if (time_before((unsigned long)time, timeout)) {
spin_unlock_irqrestore(&priv->ps_lock, flags);
netdev_info(dev, "too short to sleep::%lld < %ld\n",
time - jiffies, msecs_to_jiffies(MIN_SLEEP_TIME));
return;
}
-
- if ((time - jiffies) > msecs_to_jiffies(MAX_SLEEP_TIME)) {
+ timeout = jiffies + msecs_to_jiffies(MAX_SLEEP_TIME);
+ if (time_after((unsigned long)time, timeout)) {
netdev_info(dev, "========>too long to sleep:%lld > %ld\n",
time - jiffies, msecs_to_jiffies(MAX_SLEEP_TIME));
spin_unlock_irqrestore(&priv->ps_lock, flags);
@@ -199,8 +202,8 @@ void rtllib_ips_leave_wq(struct net_device *dev)
if (priv->rtllib->PowerSaveControl.bInactivePs) {
if (rtState == eRfOff) {
if (priv->rtllib->RfOffReason > RF_CHANGE_BY_IPS) {
- RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",
- __func__);
+ netdev_warn(dev, "%s(): RF is OFF.\n",
+ __func__);
return;
}
netdev_info(dev, "=========>%s(): IPSLeave\n",
diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
index 8d6a109e023bd8..f5e4961677d2f5 100644
--- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c
@@ -116,9 +116,8 @@ static int r8192_wx_set_power(struct net_device *dev,
struct r8192_priv *priv = rtllib_priv(dev);
if (priv->bHwRadioOff) {
- RT_TRACE(COMP_ERR,
- "%s():Hw is Radio Off, we can't set Power,return\n",
- __func__);
+ netdev_warn(dev, "%s(): Can't set Power: Radio is Off.\n",
+ __func__);
return 0;
}
down(&priv->wx_sem);
@@ -175,48 +174,6 @@ static int r8192_wx_force_reset(struct net_device *dev,
}
-static int r8192_wx_force_mic_error(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = rtllib_priv(dev);
- struct rtllib_device *ieee = priv->rtllib;
-
- down(&priv->wx_sem);
-
- RT_TRACE(COMP_DBG, "%s(): force mic error !\n", __func__);
- ieee->force_mic_error = true;
- up(&priv->wx_sem);
- return 0;
-
-}
-
-#define MAX_ADHOC_PEER_NUM 64
-struct adhoc_peer_entry {
- unsigned char MacAddr[ETH_ALEN];
- unsigned char WirelessMode;
- unsigned char bCurTxBW40MHz;
-};
-struct adhoc_peers_info {
- struct adhoc_peer_entry Entry[MAX_ADHOC_PEER_NUM];
- unsigned char num;
-};
-
-static int r8192_wx_get_adhoc_peers(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- return 0;
-}
-
-
-static int r8191se_wx_get_firm_version(struct net_device *dev,
- struct iw_request_info *info,
- struct iw_param *wrqu, char *extra)
-{
- return 0;
-}
-
static int r8192_wx_adapter_power_status(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
@@ -247,28 +204,6 @@ static int r8192_wx_adapter_power_status(struct net_device *dev,
return 0;
}
-static int r8192se_wx_set_radio(struct net_device *dev,
- struct iw_request_info *info,
- union iwreq_data *wrqu, char *extra)
-{
- struct r8192_priv *priv = rtllib_priv(dev);
-
- down(&priv->wx_sem);
-
- netdev_info(dev, "%s(): set radio ! extra is %d\n", __func__, *extra);
- if ((*extra != 0) && (*extra != 1)) {
- RT_TRACE(COMP_ERR,
- "%s(): set radio an err value,must 0(radio off) or 1(radio on)\n",
- __func__);
- up(&priv->wx_sem);
- return -1;
- }
- priv->sw_radio_on = *extra;
- up(&priv->wx_sem);
- return 0;
-
-}
-
static int r8192se_wx_set_lps_awake_interval(struct net_device *dev,
struct iw_request_info *info,
union iwreq_data *wrqu, char *extra)
@@ -342,8 +277,8 @@ static int r8192_wx_set_mode(struct net_device *dev, struct iw_request_info *a,
if (rtState == eRfOff) {
if (priv->rtllib->RfOffReason >
RF_CHANGE_BY_IPS) {
- RT_TRACE(COMP_ERR, "%s(): RF is OFF.\n",
- __func__);
+ netdev_warn(dev, "%s(): RF is OFF.\n",
+ __func__);
up(&priv->wx_sem);
return -1;
}
@@ -502,9 +437,8 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a,
if (rtState == eRfOff) {
if (priv->rtllib->RfOffReason >
RF_CHANGE_BY_IPS) {
- RT_TRACE(COMP_ERR,
- "%s(): RF is OFF.\n",
- __func__);
+ netdev_warn(dev, "%s(): RF is OFF.\n",
+ __func__);
up(&priv->wx_sem);
return -1;
}
@@ -613,7 +547,8 @@ static int r8192_wx_set_nick(struct net_device *dev,
if (wrqu->data.length > IW_ESSID_MAX_SIZE)
return -E2BIG;
down(&priv->wx_sem);
- wrqu->data.length = min_t(size_t, wrqu->data.length, sizeof(priv->nick));
+ wrqu->data.length = min_t(size_t, wrqu->data.length,
+ sizeof(priv->nick));
memset(priv->nick, 0, sizeof(priv->nick));
memcpy(priv->nick, extra, wrqu->data.length);
up(&priv->wx_sem);
@@ -987,8 +922,8 @@ static int r8192_wx_set_enc_ext(struct net_device *dev,
ret = rtllib_wx_set_encode_ext(ieee, info, wrqu, extra);
{
- u8 broadcast_addr[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
- u8 zero[6] = {0};
+ const u8 broadcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ const u8 zero[ETH_ALEN] = {0};
u32 key[4] = {0};
struct iw_encode_ext *ext = (struct iw_encode_ext *)extra;
struct iw_point *encoding = &wrqu->encoding;
@@ -1239,21 +1174,10 @@ static const struct iw_priv_args r8192_private_args[] = {
SIOCIWFIRSTPRIV + 0x3,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "forcereset"
}, {
- SIOCIWFIRSTPRIV + 0x4,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "force_mic_error"
- }, {
- SIOCIWFIRSTPRIV + 0x5,
- IW_PRIV_TYPE_NONE, IW_PRIV_TYPE_INT|IW_PRIV_SIZE_FIXED|1,
- "firm_ver"
- }, {
SIOCIWFIRSTPRIV + 0x6,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
"set_power"
}, {
- SIOCIWFIRSTPRIV + 0x9,
- IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
- "radio"
- }, {
SIOCIWFIRSTPRIV + 0xa,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
"lps_interv"
@@ -1262,9 +1186,6 @@ static const struct iw_priv_args r8192_private_args[] = {
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED|1, IW_PRIV_TYPE_NONE,
"lps_force"
}, {
- SIOCIWFIRSTPRIV + 0xc,
- 0, IW_PRIV_TYPE_CHAR|2047, "adhoc_peer_list"
- }, {
SIOCIWFIRSTPRIV + 0x16,
IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "setpromisc"
}, {
@@ -1279,15 +1200,15 @@ static iw_handler r8192_private_handler[] = {
(iw_handler)r8192_wx_set_scan_type,
(iw_handler)r8192_wx_set_rawtx,
(iw_handler)r8192_wx_force_reset,
- (iw_handler)r8192_wx_force_mic_error,
- (iw_handler)r8191se_wx_get_firm_version,
+ (iw_handler)NULL,
+ (iw_handler)NULL,
(iw_handler)r8192_wx_adapter_power_status,
(iw_handler)NULL,
(iw_handler)NULL,
- (iw_handler)r8192se_wx_set_radio,
+ (iw_handler)NULL,
(iw_handler)r8192se_wx_set_lps_awake_interval,
(iw_handler)r8192se_wx_set_force_lps,
- (iw_handler)r8192_wx_get_adhoc_peers,
+ (iw_handler)NULL,
(iw_handler)NULL,
(iw_handler)NULL,
(iw_handler)NULL,
diff --git a/drivers/staging/rtl8192e/rtl819x_BAProc.c b/drivers/staging/rtl8192e/rtl819x_BAProc.c
index 26258ea8de4aa5..60f536c295abe3 100644
--- a/drivers/staging/rtl8192e/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_BAProc.c
@@ -18,6 +18,7 @@
******************************************************************************/
#include <asm/byteorder.h>
#include <asm/unaligned.h>
+#include <linux/etherdevice.h>
#include "rtllib.h"
#include "rtl819x_BA.h"
@@ -83,18 +84,16 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
u8 *tag = NULL;
u16 len = ieee->tx_headroom + 9;
- RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA,
- "========>%s(), frame(%d) sentd to: %pM, ieee->dev:%p\n",
- __func__, type, Dst, ieee->dev);
+ netdev_dbg(ieee->dev, "%s(): frame(%d) sentd to: %pM, ieee->dev:%p\n",
+ __func__, type, Dst, ieee->dev);
+
if (pBA == NULL) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "pBA is NULL\n");
+ netdev_warn(ieee->dev, "pBA is NULL\n");
return NULL;
}
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
- if (skb == NULL) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
+ if (skb == NULL)
return NULL;
- }
memset(skb->data, 0, sizeof(struct rtllib_hdr_3addr));
@@ -103,10 +102,10 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
BAReq = (struct rtllib_hdr_3addr *)skb_put(skb,
sizeof(struct rtllib_hdr_3addr));
- memcpy(BAReq->addr1, Dst, ETH_ALEN);
- memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
+ ether_addr_copy(BAReq->addr1, Dst);
+ ether_addr_copy(BAReq->addr2, ieee->dev->dev_addr);
- memcpy(BAReq->addr3, ieee->current_network.bssid, ETH_ALEN);
+ ether_addr_copy(BAReq->addr3, ieee->current_network.bssid);
BAReq->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
tag = (u8 *)skb_put(skb, 9);
@@ -132,7 +131,10 @@ static struct sk_buff *rtllib_ADDBA(struct rtllib_device *ieee, u8 *Dst,
tag += 2;
}
- RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+ print_hex_dump_bytes("rtllib_ADDBA(): ", DUMP_PREFIX_NONE, skb->data,
+ skb->len);
+#endif
return skb;
}
@@ -147,9 +149,8 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
u16 len = 6 + ieee->tx_headroom;
if (net_ratelimit())
- RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA,
- "========>%s(), ReasonCode(%d) sentd to: %pM\n",
- __func__, ReasonCode, dst);
+ netdev_dbg(ieee->dev, "%s(): ReasonCode(%d) sentd to: %pM\n",
+ __func__, ReasonCode, dst);
memset(&DelbaParamSet, 0, 2);
@@ -157,19 +158,17 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
skb = dev_alloc_skb(len + sizeof(struct rtllib_hdr_3addr));
- if (skb == NULL) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
+ if (skb == NULL)
return NULL;
- }
skb_reserve(skb, ieee->tx_headroom);
Delba = (struct rtllib_hdr_3addr *) skb_put(skb,
sizeof(struct rtllib_hdr_3addr));
- memcpy(Delba->addr1, dst, ETH_ALEN);
- memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(Delba->addr3, ieee->current_network.bssid, ETH_ALEN);
+ ether_addr_copy(Delba->addr1, dst);
+ ether_addr_copy(Delba->addr2, ieee->dev->dev_addr);
+ ether_addr_copy(Delba->addr3, ieee->current_network.bssid);
Delba->frame_ctl = cpu_to_le16(RTLLIB_STYPE_MANAGE_ACT);
tag = (u8 *)skb_put(skb, 6);
@@ -184,10 +183,10 @@ static struct sk_buff *rtllib_DELBA(struct rtllib_device *ieee, u8 *dst,
put_unaligned_le16(ReasonCode, tag);
tag += 2;
- RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
- if (net_ratelimit())
- RTLLIB_DEBUG(RTLLIB_DL_TRACE | RTLLIB_DL_BA, "<=====%s()\n",
- __func__);
+#ifdef VERBOSE_DEBUG
+ print_hex_dump_bytes("rtllib_DELBA(): ", DUMP_PREFIX_NONE, skb->data,
+ skb->len);
+#endif
return skb;
}
@@ -202,8 +201,7 @@ static void rtllib_send_ADDBAReq(struct rtllib_device *ieee, u8 *dst,
RT_TRACE(COMP_DBG, "====>to send ADDBAREQ!!!!!\n");
softmac_mgmt_xmit(skb, ieee);
} else {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "alloc skb error in function %s()\n", __func__);
+ netdev_dbg(ieee->dev, "Failed to generate ADDBAReq packet.\n");
}
}
@@ -216,8 +214,7 @@ static void rtllib_send_ADDBARsp(struct rtllib_device *ieee, u8 *dst,
if (skb)
softmac_mgmt_xmit(skb, ieee);
else
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "alloc skb error in function %s()\n", __func__);
+ netdev_dbg(ieee->dev, "Failed to generate ADDBARsp packet.\n");
}
static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst,
@@ -230,8 +227,7 @@ static void rtllib_send_DELBA(struct rtllib_device *ieee, u8 *dst,
if (skb)
softmac_mgmt_xmit(skb, ieee);
else
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "alloc skb error in function %s()\n", __func__);
+ netdev_dbg(ieee->dev, "Failed to generate DELBA packet.\n");
}
int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
@@ -246,14 +242,16 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
struct rx_ts_record *pTS = NULL;
if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- " Invalid skb len in BAREQ(%d / %d)\n",
- (int)skb->len,
- (int)(sizeof(struct rtllib_hdr_3addr) + 9));
+ netdev_warn(ieee->dev, "Invalid skb len in BAREQ(%d / %d)\n",
+ (int)skb->len,
+ (int)(sizeof(struct rtllib_hdr_3addr) + 9));
return -1;
}
- RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+ print_hex_dump_bytes("rtllib_rx_ADDBAReq(): ", DUMP_PREFIX_NONE,
+ skb->data, skb->len);
+#endif
req = (struct rtllib_hdr_3addr *) skb->data;
tag = (u8 *)req;
@@ -269,24 +267,24 @@ int rtllib_rx_ADDBAReq(struct rtllib_device *ieee, struct sk_buff *skb)
(ieee->pHTInfo->bCurrentHTSupport == false) ||
(ieee->pHTInfo->IOTAction & HT_IOT_ACT_REJECT_ADDBA_REQ)) {
rc = ADDBA_STATUS_REFUSED;
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n",
- ieee->current_network.qos_data.active,
- ieee->pHTInfo->bCurrentHTSupport);
+ netdev_warn(ieee->dev,
+ "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n",
+ ieee->current_network.qos_data.active,
+ ieee->pHTInfo->bCurrentHTSupport);
goto OnADDBAReq_Fail;
}
if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
(u8)(pBaParamSet->field.TID), RX_DIR, true)) {
rc = ADDBA_STATUS_REFUSED;
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__);
+ netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__);
goto OnADDBAReq_Fail;
}
pBA = &pTS->RxAdmittedBARecord;
if (pBaParamSet->field.BAPolicy == BA_POLICY_DELAYED) {
rc = ADDBA_STATUS_INVALID_PARAM;
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "BA Policy is not correct in %s()\n", __func__);
+ netdev_warn(ieee->dev, "%s(): BA Policy is not correct\n",
+ __func__);
goto OnADDBAReq_Fail;
}
@@ -333,10 +331,9 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
u16 ReasonCode;
if (skb->len < sizeof(struct rtllib_hdr_3addr) + 9) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "Invalid skb len in BARSP(%d / %d)\n",
- (int)skb->len,
- (int)(sizeof(struct rtllib_hdr_3addr) + 9));
+ netdev_warn(ieee->dev, "Invalid skb len in BARSP(%d / %d)\n",
+ (int)skb->len,
+ (int)(sizeof(struct rtllib_hdr_3addr) + 9));
return -1;
}
rsp = (struct rtllib_hdr_3addr *)skb->data;
@@ -352,11 +349,11 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
if (ieee->current_network.qos_data.active == 0 ||
ieee->pHTInfo->bCurrentHTSupport == false ||
ieee->pHTInfo->bCurrentAMPDUEnable == false) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",
- ieee->current_network.qos_data.active,
- ieee->pHTInfo->bCurrentHTSupport,
- ieee->pHTInfo->bCurrentAMPDUEnable);
+ netdev_warn(ieee->dev,
+ "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",
+ ieee->current_network.qos_data.active,
+ ieee->pHTInfo->bCurrentHTSupport,
+ ieee->pHTInfo->bCurrentAMPDUEnable);
ReasonCode = DELBA_REASON_UNKNOWN_BA;
goto OnADDBARsp_Reject;
}
@@ -364,7 +361,7 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst,
(u8)(pBaParamSet->field.TID), TX_DIR, false)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't get TS in %s()\n", __func__);
+ netdev_warn(ieee->dev, "%s(): can't get TS\n", __func__);
ReasonCode = DELBA_REASON_UNKNOWN_BA;
goto OnADDBARsp_Reject;
}
@@ -375,19 +372,20 @@ int rtllib_rx_ADDBARsp(struct rtllib_device *ieee, struct sk_buff *skb)
if (pAdmittedBA->bValid == true) {
- RTLLIB_DEBUG(RTLLIB_DL_BA,
- "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it!\n");
+ netdev_dbg(ieee->dev, "%s(): ADDBA response already admitted\n",
+ __func__);
return -1;
} else if ((pPendingBA->bValid == false) ||
(*pDialogToken != pPendingBA->DialogToken)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA!\n");
+ netdev_warn(ieee->dev,
+ "%s(): ADDBA Rsp. BA invalid, DELBA!\n",
+ __func__);
ReasonCode = DELBA_REASON_UNKNOWN_BA;
goto OnADDBARsp_Reject;
} else {
- RTLLIB_DEBUG(RTLLIB_DL_BA,
- "OnADDBARsp(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n",
- *pStatusCode);
+ netdev_dbg(ieee->dev,
+ "%s(): Recv ADDBA Rsp. BA is admitted! Status code:%X\n",
+ __func__, *pStatusCode);
DeActivateBAEntry(ieee, pPendingBA);
}
@@ -434,23 +432,25 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
u8 *dst = NULL;
if (skb->len < sizeof(struct rtllib_hdr_3addr) + 6) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "Invalid skb len in DELBA(%d / %d)\n",
- (int)skb->len,
- (int)(sizeof(struct rtllib_hdr_3addr) + 6));
+ netdev_warn(ieee->dev, "Invalid skb len in DELBA(%d / %d)\n",
+ (int)skb->len,
+ (int)(sizeof(struct rtllib_hdr_3addr) + 6));
return -1;
}
if (ieee->current_network.qos_data.active == 0 ||
ieee->pHTInfo->bCurrentHTSupport == false) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "received DELBA while QOS or HT is not supported(%d, %d)\n",
- ieee->current_network. qos_data.active,
- ieee->pHTInfo->bCurrentHTSupport);
+ netdev_warn(ieee->dev,
+ "received DELBA while QOS or HT is not supported(%d, %d)\n",
+ ieee->current_network. qos_data.active,
+ ieee->pHTInfo->bCurrentHTSupport);
return -1;
}
- RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA|RTLLIB_DL_BA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+ print_hex_dump_bytes("rtllib_rx_DELBA(): ", DUMP_PREFIX_NONE, skb->data,
+ skb->len);
+#endif
delba = (struct rtllib_hdr_3addr *)skb->data;
dst = (u8 *)(&delba->addr2[0]);
delba += sizeof(struct rtllib_hdr_3addr);
@@ -462,10 +462,10 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
if (!GetTs(ieee, (struct ts_common_info **)&pRxTs, dst,
(u8)pDelBaParamSet->field.TID, RX_DIR, false)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "can't get TS for RXTS in %s().dst: %pM TID:%d\n",
- __func__, dst,
- (u8)pDelBaParamSet->field.TID);
+ netdev_warn(ieee->dev,
+ "%s(): can't get TS for RXTS. dst:%pM TID:%d\n",
+ __func__, dst,
+ (u8)pDelBaParamSet->field.TID);
return -1;
}
@@ -475,9 +475,8 @@ int rtllib_rx_DELBA(struct rtllib_device *ieee, struct sk_buff *skb)
if (!GetTs(ieee, (struct ts_common_info **)&pTxTs, dst,
(u8)pDelBaParamSet->field.TID, TX_DIR, false)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "can't get TS for TXTS in %s()\n",
- __func__);
+ netdev_warn(ieee->dev, "%s(): can't get TS for TXTS\n",
+ __func__);
return -1;
}
diff --git a/drivers/staging/rtl8192e/rtl819x_HTProc.c b/drivers/staging/rtl8192e/rtl819x_HTProc.c
index 7f103114d5d2a3..dcf8db1a7d29c4 100644
--- a/drivers/staging/rtl8192e/rtl819x_HTProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_HTProc.c
@@ -217,8 +217,7 @@ static void HTIOTPeerDetermine(struct rtllib_device *ieee)
else
pHTInfo->IOTPeer = HT_IOT_PEER_UNKNOWN;
- RTLLIB_DEBUG(RTLLIB_DL_IOT, "Joseph debug!! IOTPEER: %x\n",
- pHTInfo->IOTPeer);
+ netdev_dbg(ieee->dev, "IOTPEER: %x\n", pHTInfo->IOTPeer);
}
static u8 HTIOTActIsDisableMCS14(struct rtllib_device *ieee, u8 *PeerMacAddr)
@@ -237,7 +236,8 @@ static bool HTIOTActIsDisableMCSTwoSpatialStream(struct rtllib_device *ieee)
return false;
}
-static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee, u8 *PeerMacAddr)
+static u8 HTIOTActIsDisableEDCATurbo(struct rtllib_device *ieee,
+ u8 *PeerMacAddr)
{
return false;
}
@@ -291,8 +291,8 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap,
struct ht_capab_ele *pCapELE = NULL;
if ((posHTCap == NULL) || (pHT == NULL)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "posHTCap or pHTInfo can't be null in HTConstructCapabilityElement()\n");
+ netdev_warn(ieee->dev,
+ "%s(): posHTCap and pHTInfo are null\n", __func__);
return;
}
memset(posHTCap, 0, *len);
@@ -328,9 +328,9 @@ void HTConstructCapabilityElement(struct rtllib_device *ieee, u8 *posHTCap,
pCapELE->LSigTxopProtect = 0;
- RTLLIB_DEBUG(RTLLIB_DL_HT,
- "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n",
- pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
+ netdev_dbg(ieee->dev,
+ "TX HT cap/info ele BW=%d MaxAMSDUSize:%d DssCCk:%d\n",
+ pCapELE->ChlWidth, pCapELE->MaxAMSDUSize, pCapELE->DssCCk);
if (IsEncrypt) {
pCapELE->MPDUDensity = 7;
@@ -373,8 +373,9 @@ void HTConstructInfoElement(struct rtllib_device *ieee, u8 *posHTInfo,
struct ht_info_ele *pHTInfoEle = (struct ht_info_ele *)posHTInfo;
if ((posHTInfo == NULL) || (pHTInfoEle == NULL)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "posHTInfo or pHTInfoEle can't be null in HTConstructInfoElement()\n");
+ netdev_warn(ieee->dev,
+ "%s(): posHTInfo and pHTInfoEle are null\n",
+ __func__);
return;
}
@@ -413,8 +414,7 @@ void HTConstructRT2RTAggElement(struct rtllib_device *ieee, u8 *posRT2RTAgg,
u8 *len)
{
if (posRT2RTAgg == NULL) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "posRT2RTAgg can't be null in HTConstructRT2RTAggElement()\n");
+ netdev_warn(ieee->dev, "%s(): posRT2RTAgg is null\n", __func__);
return;
}
memset(posRT2RTAgg, 0, *len);
@@ -437,8 +437,7 @@ static u8 HT_PickMCSRate(struct rtllib_device *ieee, u8 *pOperateMCS)
u8 i;
if (pOperateMCS == NULL) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "pOperateMCS can't be null in HT_PickMCSRate()\n");
+ netdev_warn(ieee->dev, "%s(): pOperateMCS is null\n", __func__);
return false;
}
@@ -472,8 +471,9 @@ u8 HTGetHighestMCSRate(struct rtllib_device *ieee, u8 *pMCSRateSet,
u8 availableMcsRate[16];
if (pMCSRateSet == NULL || pMCSFilter == NULL) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "pMCSRateSet or pMCSFilter can't be null in HTGetHighestMCSRate()\n");
+ netdev_warn(ieee->dev,
+ "%s(): pMCSRateSet and pMCSFilter are null\n",
+ __func__);
return false;
}
for (i = 0; i < 16; i++)
@@ -538,11 +538,10 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34};
if (pHTInfo->bCurrentHTSupport == false) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "<=== HTOnAssocRsp(): HT_DISABLE\n");
+ netdev_warn(ieee->dev, "%s(): HT_DISABLE\n", __func__);
return;
}
- RTLLIB_DEBUG(RTLLIB_DL_HT, "===> HTOnAssocRsp_wq(): HT_ENABLE\n");
+ netdev_dbg(ieee->dev, "%s(): HT_ENABLE\n", __func__);
if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap)))
pPeerHTCap = (struct ht_capab_ele *)(&pHTInfo->PeerHTCapBuf[4]);
@@ -555,8 +554,11 @@ void HTOnAssocRsp(struct rtllib_device *ieee)
else
pPeerHTInfo = (struct ht_info_ele *)(pHTInfo->PeerHTInfoBuf);
- RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA | RTLLIB_DL_HT, pPeerHTCap,
- sizeof(struct ht_capab_ele));
+
+#ifdef VERBOSE_DEBUG
+ print_hex_dump_bytes("HTOnAssocRsp(): ", DUMP_PREFIX_NONE,
+ pPeerHTCap, sizeof(struct ht_capab_ele));
+#endif
HTSetConnectBwMode(ieee, (enum ht_channel_width)(pPeerHTCap->ChlWidth),
(enum ht_extchnl_offset)(pPeerHTInfo->ExtChlOffset));
pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1) ?
@@ -647,7 +649,7 @@ void HTInitializeHTInfo(struct rtllib_device *ieee)
{
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
- RTLLIB_DEBUG(RTLLIB_DL_HT, "===========>%s()\n", __func__);
+ netdev_vdbg(ieee->dev, "%s()\n", __func__);
pHTInfo->bCurrentHTSupport = false;
pHTInfo->bCurBW40MHz = false;
@@ -717,7 +719,7 @@ void HTResetSelfAndSavePeerSetting(struct rtllib_device *ieee,
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
u8 bIOTAction = 0;
- RTLLIB_DEBUG(RTLLIB_DL_HT, "==============>%s()\n", __func__);
+ netdev_vdbg(ieee->dev, "%s()\n", __func__);
/* unmark bEnableHT flag here is the same reason why unmarked in
* function rtllib_softmac_new_net. WB 2008.09.10
*/
@@ -841,8 +843,7 @@ u8 HTCCheck(struct rtllib_device *ieee, u8 *pFrame)
{
if (ieee->pHTInfo->bCurrentHTSupport) {
if ((IsQoSDataFrame(pFrame) && Frame_Order(pFrame)) == 1) {
- RTLLIB_DEBUG(RTLLIB_DL_HT,
- "HT CONTROL FILED EXIST!!\n");
+ netdev_dbg(ieee->dev, "HT CONTROL FILED EXIST!!\n");
return true;
}
}
@@ -853,7 +854,8 @@ static void HTSetConnectBwModeCallback(struct rtllib_device *ieee)
{
struct rt_hi_throughput *pHTInfo = ieee->pHTInfo;
- RTLLIB_DEBUG(RTLLIB_DL_HT, "======>%s()\n", __func__);
+ netdev_vdbg(ieee->dev, "%s()\n", __func__);
+
if (pHTInfo->bCurBW40MHz) {
if (pHTInfo->CurSTAExtChnlOffset == HT_EXTCHNL_OFFSET_UPPER)
ieee->set_chan(ieee->dev,
diff --git a/drivers/staging/rtl8192e/rtl819x_Qos.h b/drivers/staging/rtl8192e/rtl819x_Qos.h
index 55ef7ec33f650f..b3e7dae982a736 100644
--- a/drivers/staging/rtl8192e/rtl819x_Qos.h
+++ b/drivers/staging/rtl8192e/rtl819x_Qos.h
@@ -255,8 +255,8 @@ union qos_tclas {
u8 Priority;
u8 ClassifierType;
u8 Mask;
- u8 SrcAddr[6];
- u8 DstAddr[6];
+ u8 SrcAddr[ETH_ALEN];
+ u8 DstAddr[ETH_ALEN];
u16 Type;
} TYPE0_ETH;
diff --git a/drivers/staging/rtl8192e/rtl819x_TS.h b/drivers/staging/rtl8192e/rtl819x_TS.h
index 8601b1ad217d5c..b3e721bf975cc8 100644
--- a/drivers/staging/rtl8192e/rtl819x_TS.h
+++ b/drivers/staging/rtl8192e/rtl819x_TS.h
@@ -35,7 +35,7 @@ struct ts_common_info {
struct list_head List;
struct timer_list SetupTimer;
struct timer_list InactTimer;
- u8 Addr[6];
+ u8 Addr[ETH_ALEN];
union tspec_body TSpec;
union qos_tclas TClass[TCLAS_NUM];
u8 TClasProc;
diff --git a/drivers/staging/rtl8192e/rtl819x_TSProc.c b/drivers/staging/rtl8192e/rtl819x_TSProc.c
index 7d77d056228d35..8a5dd6ef807456 100644
--- a/drivers/staging/rtl8192e/rtl819x_TSProc.c
+++ b/drivers/staging/rtl8192e/rtl819x_TSProc.c
@@ -49,8 +49,10 @@ static void RxPktPendingTimeout(unsigned long data)
if (index == 0)
pRxTs->RxIndicateSeq = pReorderEntry->SeqNum;
- if (SN_LESS(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq) ||
- SN_EQUAL(pReorderEntry->SeqNum, pRxTs->RxIndicateSeq)) {
+ if (SN_LESS(pReorderEntry->SeqNum,
+ pRxTs->RxIndicateSeq) ||
+ SN_EQUAL(pReorderEntry->SeqNum,
+ pRxTs->RxIndicateSeq)) {
list_del_init(&pReorderEntry->List);
if (SN_EQUAL(pReorderEntry->SeqNum,
@@ -58,9 +60,9 @@ static void RxPktPendingTimeout(unsigned long data)
pRxTs->RxIndicateSeq =
(pRxTs->RxIndicateSeq + 1) % 4096;
- RTLLIB_DEBUG(RTLLIB_DL_REORDER,
- "%s(): Indicate SeqNum: %d\n",
- __func__, pReorderEntry->SeqNum);
+ netdev_dbg(ieee->dev,
+ "%s(): Indicate SeqNum: %d\n",
+ __func__, pReorderEntry->SeqNum);
ieee->stats_IndicateArray[index] =
pReorderEntry->prxb;
index++;
@@ -78,8 +80,9 @@ static void RxPktPendingTimeout(unsigned long data)
pRxTs->RxTimeoutIndicateSeq = 0xffff;
if (index > REORDER_WIN_SIZE) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "RxReorderIndicatePacket(): Rx Reorder struct buffer full!!\n");
+ netdev_warn(ieee->dev,
+ "%s(): Rx Reorder struct buffer full\n",
+ __func__);
spin_unlock_irqrestore(&(ieee->reorder_spinlock),
flags);
return;
@@ -91,7 +94,8 @@ static void RxPktPendingTimeout(unsigned long data)
if (bPktInBuf && (pRxTs->RxTimeoutIndicateSeq == 0xffff)) {
pRxTs->RxTimeoutIndicateSeq = pRxTs->RxIndicateSeq;
mod_timer(&pRxTs->RxPktPendingTimer, jiffies +
- msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime));
+ msecs_to_jiffies(ieee->pHTInfo->RxReorderPendingTime)
+ );
}
spin_unlock_irqrestore(&(ieee->reorder_spinlock), flags);
}
@@ -104,8 +108,7 @@ static void TsAddBaProcess(unsigned long data)
TxTsRecord[num]);
TsInitAddBA(ieee, pTxTs, BA_POLICY_IMMEDIATE, false);
- RTLLIB_DEBUG(RTLLIB_DL_BA,
- "TsAddBaProcess(): ADDBA Req is started!!\n");
+ netdev_dbg(ieee->dev, "%s(): ADDBA Req is started\n", __func__);
}
static void ResetTsCommonInfo(struct ts_common_info *pTsCommonInfo)
@@ -144,7 +147,7 @@ void TSInitialize(struct rtllib_device *ieee)
struct rx_reorder_entry *pRxReorderEntry = ieee->RxReorderEntry;
u8 count = 0;
- RTLLIB_DEBUG(RTLLIB_DL_TS, "==========>%s()\n", __func__);
+ netdev_vdbg(ieee->dev, "%s()\n", __func__);
INIT_LIST_HEAD(&ieee->Tx_TS_Admit_List);
INIT_LIST_HEAD(&ieee->Tx_TS_Pending_List);
INIT_LIST_HEAD(&ieee->Tx_TS_Unused_List);
@@ -269,10 +272,10 @@ static struct ts_common_info *SearchAdmitTRStream(struct rtllib_device *ieee,
if (!search_dir[dir])
continue;
list_for_each_entry(pRet, psearch_list, List) {
- if (memcmp(pRet->Addr, Addr, 6) == 0)
- if (pRet->TSpec.f.TSInfo.field.ucTSID == TID)
- if (pRet->TSpec.f.TSInfo.field.ucDirection == dir)
- break;
+ if (memcmp(pRet->Addr, Addr, 6) == 0 &&
+ pRet->TSpec.f.TSInfo.field.ucTSID == TID &&
+ pRet->TSpec.f.TSInfo.field.ucDirection == dir)
+ break;
}
if (&pRet->List != psearch_list)
@@ -318,17 +321,15 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
enum direction_value Dir;
if (is_multicast_ether_addr(Addr)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "ERR! get TS for Broadcast or Multicast\n");
+ netdev_warn(ieee->dev, "Get TS for Broadcast or Multicast\n");
return false;
}
if (ieee->current_network.qos_data.supported == 0) {
UP = 0;
} else {
if (!IsACValid(TID)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "ERR! in %s(), TID(%d) is not valid\n",
- __func__, TID);
+ netdev_warn(ieee->dev, "%s(): TID(%d) is not valid\n",
+ __func__, TID);
return false;
}
@@ -357,8 +358,7 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
return true;
if (!bAddNewTs) {
- RTLLIB_DEBUG(RTLLIB_DL_TS,
- "add new TS failed(tid:%d)\n", UP);
+ netdev_dbg(ieee->dev, "add new TS failed(tid:%d)\n", UP);
return false;
}
@@ -374,7 +374,6 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
((TxRxSelect == TX_DIR) ? DIR_DOWN : DIR_UP) :
((TxRxSelect == TX_DIR) ? DIR_UP : DIR_DOWN);
- RTLLIB_DEBUG(RTLLIB_DL_TS, "to add Ts\n");
if (!list_empty(pUnusedList)) {
(*ppTS) = list_entry(pUnusedList->next,
struct ts_common_info, List);
@@ -393,9 +392,9 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
ResetRxTsEntry(tmp);
}
- RTLLIB_DEBUG(RTLLIB_DL_TS,
- "to init current TS, UP:%d, Dir:%d, addr: %pM ppTs=%p\n",
- UP, Dir, Addr, *ppTS);
+ netdev_dbg(ieee->dev,
+ "to init current TS, UP:%d, Dir:%d, addr: %pM ppTs=%p\n",
+ UP, Dir, Addr, *ppTS);
pTSInfo->field.ucTrafficType = 0;
pTSInfo->field.ucTSID = UP;
pTSInfo->field.ucDirection = Dir;
@@ -413,14 +412,14 @@ bool GetTs(struct rtllib_device *ieee, struct ts_common_info **ppTS,
return true;
}
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "ERR!!in function %s() There is not enough dir=%d(0=up down=1) TS record to be used!!",
- __func__, Dir);
+ netdev_warn(ieee->dev,
+ "There is not enough dir=%d(0=up down=1) TS record to be used!",
+ Dir);
return false;
}
-static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs,
- enum tr_select TxRxSelect)
+static void RemoveTsEntry(struct rtllib_device *ieee,
+ struct ts_common_info *pTs, enum tr_select TxRxSelect)
{
del_timer_sync(&pTs->SetupTimer);
del_timer_sync(&pTs->InactTimer);
@@ -437,9 +436,8 @@ static void RemoveTsEntry(struct rtllib_device *ieee, struct ts_common_info *pTs
pRxReorderEntry = (struct rx_reorder_entry *)
list_entry(pRxTS->RxPendingPktList.prev,
struct rx_reorder_entry, List);
- RTLLIB_DEBUG(RTLLIB_DL_REORDER,
- "%s(): Delete SeqNum %d!\n", __func__,
- pRxReorderEntry->SeqNum);
+ netdev_dbg(ieee->dev, "%s(): Delete SeqNum %d!\n",
+ __func__, pRxReorderEntry->SeqNum);
list_del_init(&pRxReorderEntry->List);
{
int i = 0;
@@ -539,16 +537,13 @@ void TsStartAddBaProcess(struct rtllib_device *ieee, struct tx_ts_record *pTxTS)
pTxTS->bAddBaReqInProgress = true;
if (pTxTS->bAddBaReqDelayed) {
- RTLLIB_DEBUG(RTLLIB_DL_BA,
- "TsStartAddBaProcess(): Delayed Start ADDBA after 60 sec!!\n");
+ netdev_dbg(ieee->dev, "Start ADDBA after 60 sec!!\n");
mod_timer(&pTxTS->TsAddBaTimer, jiffies +
msecs_to_jiffies(TS_ADDBA_DELAY));
} else {
- RTLLIB_DEBUG(RTLLIB_DL_BA,
- "TsStartAddBaProcess(): Immediately Start ADDBA now!!\n");
+ netdev_dbg(ieee->dev, "Immediately Start ADDBA\n");
mod_timer(&pTxTS->TsAddBaTimer, jiffies+10);
}
} else
- RTLLIB_DEBUG(RTLLIB_DL_BA, "%s()==>BA timer is already added\n",
- __func__);
+ netdev_dbg(ieee->dev, "BA timer is already added\n");
}
diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h
index 3c8b708df5c37a..5c3a9793171be6 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -261,45 +261,6 @@ struct sw_chnl_cmd {
#define MGN_MCS14_SG 0x9e
#define MGN_MCS15_SG 0x9f
-
-enum _ReasonCode {
- unspec_reason = 0x1,
- auth_not_valid = 0x2,
- deauth_lv_ss = 0x3,
- inactivity = 0x4,
- ap_overload = 0x5,
- class2_err = 0x6,
- class3_err = 0x7,
- disas_lv_ss = 0x8,
- asoc_not_auth = 0x9,
-
- mic_failure = 0xe,
-
- invalid_IE = 0x0d,
- four_way_tmout = 0x0f,
- two_way_tmout = 0x10,
- IE_dismatch = 0x11,
- invalid_Gcipher = 0x12,
- invalid_Pcipher = 0x13,
- invalid_AKMP = 0x14,
- unsup_RSNIEver = 0x15,
- invalid_RSNIE = 0x16,
- auth_802_1x_fail = 0x17,
- ciper_reject = 0x18,
-
- QoS_unspec = 0x20,
- QAP_bandwidth = 0x21,
- poor_condition = 0x22,
- no_facility = 0x23,
- req_declined = 0x25,
- invalid_param = 0x26,
- req_not_honored = 0x27,
- TS_not_created = 0x2F,
- DL_not_allowed = 0x30,
- dest_not_exist = 0x31,
- dest_not_QSTA = 0x32,
-};
-
enum hal_def_variable {
HAL_DEF_TPC_ENABLE,
HAL_DEF_INIT_GAIN,
@@ -680,81 +641,6 @@ enum wireless_network_type {
#define OUI_SUBTYPE_WMM_PARAM 1
#define OUI_SUBTYPE_QOS_CAPABI 5
-/* debug macros */
-extern u32 rtllib_debug_level;
-#define RTLLIB_DEBUG(level, fmt, args...) \
-do { \
- if (rtllib_debug_level & (level)) \
- printk(KERN_DEBUG "rtllib: " fmt, ## args); \
-} while (0)
-
-#define RTLLIB_DEBUG_DATA(level, data, datalen) \
- do { \
- if ((rtllib_debug_level & (level)) == (level)) { \
- printk(KERN_DEBUG "rtllib: %s()\n", __func__); \
- print_hex_dump_bytes(KERN_DEBUG, DUMP_PREFIX_NONE, \
- data, datalen); \
- } \
- } while (0)
-
-/* To use the debug system;
- *
- * If you are defining a new debug classification, simply add it to the #define
- * list here in the form of:
- *
- * #define RTLLIB_DL_xxxx VALUE
- *
- * shifting value to the left one bit from the previous entry. xxxx should be
- * the name of the classification (for example, WEP)
- *
- * You then need to either add a RTLLIB_xxxx_DEBUG() macro definition for your
- * classification, or use RTLLIB_DEBUG(RTLLIB_DL_xxxx, ...) whenever you want
- * to send output to that classification.
- *
- * To add your debug level to the list of levels seen when you perform
- *
- * % cat /proc/net/ipw/debug_level
- *
- * you simply need to add your entry to the ipw_debug_levels array.
- */
-
-#define RTLLIB_DL_INFO (1<<0)
-#define RTLLIB_DL_WX (1<<1)
-#define RTLLIB_DL_SCAN (1<<2)
-#define RTLLIB_DL_STATE (1<<3)
-#define RTLLIB_DL_MGMT (1<<4)
-#define RTLLIB_DL_FRAG (1<<5)
-#define RTLLIB_DL_EAP (1<<6)
-#define RTLLIB_DL_DROP (1<<7)
-
-#define RTLLIB_DL_TX (1<<8)
-#define RTLLIB_DL_RX (1<<9)
-
-#define RTLLIB_DL_HT (1<<10)
-#define RTLLIB_DL_BA (1<<11)
-#define RTLLIB_DL_TS (1<<12)
-#define RTLLIB_DL_QOS (1<<13)
-#define RTLLIB_DL_REORDER (1<<14)
-#define RTLLIB_DL_IOT (1<<15)
-#define RTLLIB_DL_IPS (1<<16)
-#define RTLLIB_DL_TRACE (1<<29)
-#define RTLLIB_DL_DATA (1<<30)
-#define RTLLIB_DL_ERR (1<<31)
-#define RTLLIB_ERROR(f, a...) pr_err("rtllib: " f, ## a)
-#define RTLLIB_WARNING(f, a...) pr_warn("rtllib: " f, ## a)
-#define RTLLIB_DEBUG_INFO(f, a...) RTLLIB_DEBUG(RTLLIB_DL_INFO, f, ## a)
-
-#define RTLLIB_DEBUG_WX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_WX, f, ## a)
-#define RTLLIB_DEBUG_SCAN(f, a...) RTLLIB_DEBUG(RTLLIB_DL_SCAN, f, ## a)
-#define RTLLIB_DEBUG_STATE(f, a...) RTLLIB_DEBUG(RTLLIB_DL_STATE, f, ## a)
-#define RTLLIB_DEBUG_MGMT(f, a...) RTLLIB_DEBUG(RTLLIB_DL_MGMT, f, ## a)
-#define RTLLIB_DEBUG_FRAG(f, a...) RTLLIB_DEBUG(RTLLIB_DL_FRAG, f, ## a)
-#define RTLLIB_DEBUG_EAP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_EAP, f, ## a)
-#define RTLLIB_DEBUG_DROP(f, a...) RTLLIB_DEBUG(RTLLIB_DL_DROP, f, ## a)
-#define RTLLIB_DEBUG_TX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_TX, f, ## a)
-#define RTLLIB_DEBUG_RX(f, a...) RTLLIB_DEBUG(RTLLIB_DL_RX, f, ## a)
-#define RTLLIB_DEBUG_QOS(f, a...) RTLLIB_DEBUG(RTLLIB_DL_QOS, f, ## a)
-
#ifndef ETH_P_PAE
#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */
#define ETH_P_IP 0x0800 /* Internet Protocol packet */
@@ -1570,7 +1456,7 @@ struct rtllib_network {
u16 CcxRmState[2];
bool bMBssidValid;
u8 MBssidMask;
- u8 MBssid[6];
+ u8 MBssid[ETH_ALEN];
bool bWithCcxVerNum;
u8 BssCcxVerNumber;
/* These are network statistics */
@@ -1905,7 +1791,7 @@ struct rt_link_detect {
struct sw_cam_table {
- u8 macaddr[6];
+ u8 macaddr[ETH_ALEN];
bool bused;
u8 key_buf[16];
u16 key_type;
@@ -1951,10 +1837,10 @@ enum ratr_table_mode_8192s {
#define NUM_PMKID_CACHE 16
struct rt_pmkid_list {
- u8 bUsed;
- u8 Bssid[6];
+ u8 Bssid[ETH_ALEN];
u8 PMKID[16];
u8 SsidBuf[33];
+ u8 bUsed;
u8 *ssid_octet;
u16 ssid_length;
};
@@ -2018,7 +1904,6 @@ struct rtllib_device {
u8 hwsec_active;
bool is_silent_reset;
- bool force_mic_error;
bool is_roaming;
bool ieee_up;
bool cannot_notify;
@@ -2122,7 +2007,7 @@ struct rtllib_device {
u8 *wpa_ie;
size_t wps_ie_len;
u8 *wps_ie;
- u8 ap_mac_addr[6];
+ u8 ap_mac_addr[ETH_ALEN];
u16 pairwise_key_type;
u16 group_key_type;
diff --git a/drivers/staging/rtl8192e/rtllib_crypt.c b/drivers/staging/rtl8192e/rtllib_crypt.c
deleted file mode 100644
index 1e6ae9bead2331..00000000000000
--- a/drivers/staging/rtl8192e/rtllib_crypt.c
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Host AP crypto routines
- *
- * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
- * Portions Copyright (C) 2004, Intel Corporation <jketreno@linux.intel.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. See README and COPYING for
- * more details.
- *
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/slab.h>
-#include <linux/string.h>
-#include <linux/errno.h>
-
-#include "rtllib.h"
-
-struct rtllib_crypto_alg {
- struct list_head list;
- struct lib80211_crypto_ops *ops;
-};
-
-
-struct rtllib_crypto {
- struct list_head algs;
- spinlock_t lock;
-};
-
-static struct rtllib_crypto *hcrypt;
-
-void rtllib_crypt_deinit_entries(struct lib80211_crypt_info *info,
- int force)
-{
- struct list_head *ptr, *n;
- struct lib80211_crypt_data *entry;
-
- for (ptr = info->crypt_deinit_list.next, n = ptr->next;
- ptr != &info->crypt_deinit_list; ptr = n, n = ptr->next) {
- entry = list_entry(ptr, struct lib80211_crypt_data, list);
-
- if (atomic_read(&entry->refcnt) != 0 && !force)
- continue;
-
- list_del(ptr);
-
- if (entry->ops)
- entry->ops->deinit(entry->priv);
- kfree(entry);
- }
-}
-EXPORT_SYMBOL(rtllib_crypt_deinit_entries);
-
-void rtllib_crypt_deinit_handler(unsigned long data)
-{
- struct lib80211_crypt_info *info = (struct lib80211_crypt_info *)data;
- unsigned long flags;
-
- spin_lock_irqsave(info->lock, flags);
- rtllib_crypt_deinit_entries(info, 0);
- if (!list_empty(&info->crypt_deinit_list)) {
- printk(KERN_DEBUG
- "%s: entries remaining in delayed crypt deletion list\n",
- info->name);
- info->crypt_deinit_timer.expires = jiffies + HZ;
- add_timer(&info->crypt_deinit_timer);
- }
- spin_unlock_irqrestore(info->lock, flags);
-
-}
-EXPORT_SYMBOL(rtllib_crypt_deinit_handler);
-
-void rtllib_crypt_delayed_deinit(struct lib80211_crypt_info *info,
- struct lib80211_crypt_data **crypt)
-{
- struct lib80211_crypt_data *tmp;
- unsigned long flags;
-
- if (*crypt == NULL)
- return;
-
- tmp = *crypt;
- *crypt = NULL;
-
- /* must not run ops->deinit() while there may be pending encrypt or
- * decrypt operations. Use a list of delayed deinits to avoid needing
- * locking.
- */
-
- spin_lock_irqsave(info->lock, flags);
- list_add(&tmp->list, &info->crypt_deinit_list);
- if (!timer_pending(&info->crypt_deinit_timer)) {
- info->crypt_deinit_timer.expires = jiffies + HZ;
- add_timer(&info->crypt_deinit_timer);
- }
- spin_unlock_irqrestore(info->lock, flags);
-}
-EXPORT_SYMBOL(rtllib_crypt_delayed_deinit);
-
-int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops)
-{
- unsigned long flags;
- struct rtllib_crypto_alg *alg;
-
- if (hcrypt == NULL)
- return -1;
-
- alg = kzalloc(sizeof(*alg), GFP_KERNEL);
- if (alg == NULL)
- return -ENOMEM;
-
- alg->ops = ops;
-
- spin_lock_irqsave(&hcrypt->lock, flags);
- list_add(&alg->list, &hcrypt->algs);
- spin_unlock_irqrestore(&hcrypt->lock, flags);
-
- printk(KERN_DEBUG "rtllib_crypt: registered algorithm '%s'\n",
- ops->name);
-
- return 0;
-}
-EXPORT_SYMBOL(rtllib_register_crypto_ops);
-
-int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops)
-{
- unsigned long flags;
- struct list_head *ptr;
- struct rtllib_crypto_alg *del_alg = NULL;
-
- if (hcrypt == NULL)
- return -1;
-
- spin_lock_irqsave(&hcrypt->lock, flags);
- for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
- struct rtllib_crypto_alg *alg =
- (struct rtllib_crypto_alg *) ptr;
- if (alg->ops == ops) {
- list_del(&alg->list);
- del_alg = alg;
- break;
- }
- }
- spin_unlock_irqrestore(&hcrypt->lock, flags);
-
- if (del_alg) {
- printk(KERN_DEBUG "rtllib_crypt: unregistered algorithm '%s'\n",
- ops->name);
- kfree(del_alg);
- }
-
- return del_alg ? 0 : -1;
-}
-EXPORT_SYMBOL(rtllib_unregister_crypto_ops);
-
-
-struct lib80211_crypto_ops *rtllib_get_crypto_ops(const char *name)
-{
- unsigned long flags;
- struct list_head *ptr;
- struct rtllib_crypto_alg *found_alg = NULL;
-
- if (hcrypt == NULL)
- return NULL;
-
- spin_lock_irqsave(&hcrypt->lock, flags);
- for (ptr = hcrypt->algs.next; ptr != &hcrypt->algs; ptr = ptr->next) {
- struct rtllib_crypto_alg *alg =
- (struct rtllib_crypto_alg *) ptr;
- if (strcmp(alg->ops->name, name) == 0) {
- found_alg = alg;
- break;
- }
- }
- spin_unlock_irqrestore(&hcrypt->lock, flags);
-
- if (found_alg)
- return found_alg->ops;
- else
- return NULL;
-}
-EXPORT_SYMBOL(rtllib_get_crypto_ops);
-
-
-static void *rtllib_crypt_null_init(int keyidx) { return (void *) 1; }
-static void rtllib_crypt_null_deinit(void *priv) {}
-
-static struct lib80211_crypto_ops rtllib_crypt_null = {
- .name = "NULL",
- .init = rtllib_crypt_null_init,
- .deinit = rtllib_crypt_null_deinit,
- .encrypt_mpdu = NULL,
- .decrypt_mpdu = NULL,
- .encrypt_msdu = NULL,
- .decrypt_msdu = NULL,
- .set_key = NULL,
- .get_key = NULL,
- .extra_mpdu_prefix_len = 0,
- .extra_mpdu_postfix_len = 0,
- .extra_msdu_prefix_len = 0,
- .extra_msdu_postfix_len = 0,
- .owner = THIS_MODULE,
-};
-
-
-int __init rtllib_crypto_init(void)
-{
- int ret = -ENOMEM;
-
- hcrypt = kzalloc(sizeof(*hcrypt), GFP_KERNEL);
- if (!hcrypt)
- goto out;
-
- INIT_LIST_HEAD(&hcrypt->algs);
- spin_lock_init(&hcrypt->lock);
-
- ret = lib80211_register_crypto_ops(&rtllib_crypt_null);
- if (ret < 0) {
- kfree(hcrypt);
- hcrypt = NULL;
- }
-out:
- return ret;
-}
-
-
-void __exit rtllib_crypto_deinit(void)
-{
- struct list_head *ptr, *n;
-
- if (hcrypt == NULL)
- return;
-
- for (ptr = hcrypt->algs.next, n = ptr->next; ptr != &hcrypt->algs;
- ptr = n, n = ptr->next) {
- struct rtllib_crypto_alg *alg =
- (struct rtllib_crypto_alg *) ptr;
- list_del(ptr);
- printk(KERN_DEBUG
- "rtllib_crypt: unregistered algorithm '%s' (deinit)\n",
- alg->ops->name);
- kfree(alg);
- }
-
- kfree(hcrypt);
-}
-
-module_init(rtllib_crypto_init);
-module_exit(rtllib_crypto_deinit);
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/rtl8192e/rtllib_crypt.h b/drivers/staging/rtl8192e/rtllib_crypt.h
deleted file mode 100644
index b8cf59f39a6093..00000000000000
--- a/drivers/staging/rtl8192e/rtllib_crypt.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Original code based on Host AP (software wireless LAN access point) driver
- * for Intersil Prism2/2.5/3.
- *
- * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen
- * <jkmaline@cc.hut.fi>
- * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi>
- *
- * Adaption to a generic IEEE 802.11 stack by James Ketrenos
- * <jketreno@linux.intel.com>
- *
- * Copyright (c) 2004, Intel Corporation
- *
- * 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. See README and COPYING for
- * more details.
- */
-
-/* This file defines the interface to the rtllib crypto module.
- */
-#ifndef RTLLIB_CRYPT_H
-#define RTLLIB_CRYPT_H
-
-#include <linux/skbuff.h>
-
-int rtllib_register_crypto_ops(struct lib80211_crypto_ops *ops);
-int rtllib_unregister_crypto_ops(struct lib80211_crypto_ops *ops);
-struct lib80211_crypto_ops *rtllib_get_crypto_ops(const char *name);
-void rtllib_crypt_deinit_entries(struct lib80211_crypt_info *info, int force);
-void rtllib_crypt_deinit_handler(unsigned long data);
-void rtllib_crypt_delayed_deinit(struct lib80211_crypt_info *info,
- struct lib80211_crypt_data **crypt);
-#endif
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
index 7d486e8887f84c..496de4f6a7bcd3 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c
@@ -69,7 +69,7 @@ static void *rtllib_ccmp_init(int key_idx)
priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tfm)) {
- pr_debug("rtllib_crypt_ccmp: could not allocate crypto API aes\n");
+ pr_debug("Could not allocate crypto API aes\n");
priv->tfm = NULL;
goto fail;
}
diff --git a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
index 656b4b359c5047..2096d78913bd90 100644
--- a/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
+++ b/drivers/staging/rtl8192e/rtllib_crypt_tkip.c
@@ -21,6 +21,7 @@
#include <linux/crypto.h>
#include <linux/scatterlist.h>
#include <linux/crc32.h>
+#include <linux/etherdevice.h>
#include "rtllib.h"
@@ -52,7 +53,8 @@ struct rtllib_tkip_data {
struct crypto_blkcipher *tx_tfm_arc4;
struct crypto_hash *tx_tfm_michael;
/* scratch buffers for virt_to_page() (crypto API) */
- u8 rx_hdr[16], tx_hdr[16];
+ u8 rx_hdr[16];
+ u8 tx_hdr[16];
};
static void *rtllib_tkip_init(int key_idx)
@@ -66,8 +68,7 @@ static void *rtllib_tkip_init(int key_idx)
priv->tx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm_arc4)) {
- printk(KERN_DEBUG
- "rtllib_crypt_tkip: could not allocate crypto API arc4\n");
+ pr_debug("Could not allocate crypto API arc4\n");
priv->tx_tfm_arc4 = NULL;
goto fail;
}
@@ -75,8 +76,7 @@ static void *rtllib_tkip_init(int key_idx)
priv->tx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->tx_tfm_michael)) {
- printk(KERN_DEBUG
- "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
+ pr_debug("Could not allocate crypto API michael_mic\n");
priv->tx_tfm_michael = NULL;
goto fail;
}
@@ -84,8 +84,7 @@ static void *rtllib_tkip_init(int key_idx)
priv->rx_tfm_arc4 = crypto_alloc_blkcipher("ecb(arc4)", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm_arc4)) {
- printk(KERN_DEBUG
- "rtllib_crypt_tkip: could not allocate crypto API arc4\n");
+ pr_debug("Could not allocate crypto API arc4\n");
priv->rx_tfm_arc4 = NULL;
goto fail;
}
@@ -93,8 +92,7 @@ static void *rtllib_tkip_init(int key_idx)
priv->rx_tfm_michael = crypto_alloc_hash("michael_mic", 0,
CRYPTO_ALG_ASYNC);
if (IS_ERR(priv->rx_tfm_michael)) {
- printk(KERN_DEBUG
- "rtllib_crypt_tkip: could not allocate crypto API michael_mic\n");
+ pr_debug("Could not allocate crypto API michael_mic\n");
priv->rx_tfm_michael = NULL;
goto fail;
}
@@ -401,24 +399,24 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
if (net_ratelimit()) {
- printk(KERN_DEBUG
- "TKIP: received packet without ExtIV flag from %pM\n",
- hdr->addr2);
+ netdev_dbg(skb->dev,
+ "Received packet without ExtIV flag from %pM\n",
+ hdr->addr2);
}
return -2;
}
keyidx >>= 6;
if (tkey->key_idx != keyidx) {
- printk(KERN_DEBUG
- "TKIP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
- tkey->key_idx, keyidx, priv);
+ netdev_dbg(skb->dev,
+ "RX tkey->key_idx=%d frame keyidx=%d priv=%p\n",
+ tkey->key_idx, keyidx, priv);
return -6;
}
if (!tkey->key_set) {
if (net_ratelimit()) {
- printk(KERN_DEBUG
- "TKIP: received packet from %pM with keyid=%d that does not have a configured key\n",
- hdr->addr2, keyidx);
+ netdev_dbg(skb->dev,
+ "Received packet from %pM with keyid=%d that does not have a configured key\n",
+ hdr->addr2, keyidx);
}
return -3;
}
@@ -431,10 +429,10 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
(iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) &&
tkey->initialized) {
if (net_ratelimit()) {
- printk(KERN_DEBUG
- "TKIP: replay detected: STA= %pM previous TSC %08x%04x received TSC %08x%04x\n",
- hdr->addr2, tkey->rx_iv32, tkey->rx_iv16,
- iv32, iv16);
+ netdev_dbg(skb->dev,
+ "Replay detected: STA= %pM previous TSC %08x%04x received TSC %08x%04x\n",
+ hdr->addr2, tkey->rx_iv32,
+ tkey->rx_iv16, iv32, iv16);
}
tkey->dot11RSNAStatsTKIPReplays++;
return -4;
@@ -455,9 +453,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
crypto_blkcipher_setkey(tkey->rx_tfm_arc4, rc4key, 16);
if (crypto_blkcipher_decrypt(&desc, &sg, &sg, plen + 4)) {
if (net_ratelimit()) {
- printk(KERN_DEBUG
- ": TKIP: failed to decrypt received packet from %pM\n",
- hdr->addr2);
+ netdev_dbg(skb->dev,
+ "Failed to decrypt received packet from %pM\n",
+ hdr->addr2);
}
return -7;
}
@@ -477,9 +475,9 @@ static int rtllib_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
tkey->rx_phase1_done = 0;
}
if (net_ratelimit()) {
- printk(KERN_DEBUG
- "TKIP: ICV error detected: STA= %pM\n",
- hdr->addr2);
+ netdev_dbg(skb->dev,
+ "ICV error detected: STA= %pM\n",
+ hdr->addr2);
}
tkey->dot11RSNAStatsTKIPICVErrors++;
return -5;
@@ -532,20 +530,20 @@ static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
switch (le16_to_cpu(hdr11->frame_ctl) &
(RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
case RTLLIB_FCTL_TODS:
- memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+ ether_addr_copy(hdr, hdr11->addr3); /* DA */
+ ether_addr_copy(hdr + ETH_ALEN, hdr11->addr2); /* SA */
break;
case RTLLIB_FCTL_FROMDS:
- memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr3, ETH_ALEN); /* SA */
+ ether_addr_copy(hdr, hdr11->addr1); /* DA */
+ ether_addr_copy(hdr + ETH_ALEN, hdr11->addr3); /* SA */
break;
case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
- memcpy(hdr, hdr11->addr3, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr4, ETH_ALEN); /* SA */
+ ether_addr_copy(hdr, hdr11->addr3); /* DA */
+ ether_addr_copy(hdr + ETH_ALEN, hdr11->addr4); /* SA */
break;
case 0:
- memcpy(hdr, hdr11->addr1, ETH_ALEN); /* DA */
- memcpy(hdr + ETH_ALEN, hdr11->addr2, ETH_ALEN); /* SA */
+ ether_addr_copy(hdr, hdr11->addr1); /* DA */
+ ether_addr_copy(hdr + ETH_ALEN, hdr11->addr2); /* SA */
break;
}
@@ -564,9 +562,9 @@ static int rtllib_michael_mic_add(struct sk_buff *skb, int hdr_len, void *priv)
hdr = (struct rtllib_hdr_4addr *) skb->data;
if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
- printk(KERN_DEBUG
- "Invalid packet for Michael MIC add (tailroom=%d hdr_len=%d skb->len=%d)\n",
- skb_tailroom(skb), hdr_len, skb->len);
+ netdev_dbg(skb->dev,
+ "Invalid packet for Michael MIC add (tailroom=%d hdr_len=%d skb->len=%d)\n",
+ skb_tailroom(skb), hdr_len, skb->len);
return -1;
}
@@ -598,7 +596,7 @@ static void rtllib_michael_mic_failure(struct net_device *dev,
else
ev.flags |= IW_MICFAILURE_PAIRWISE;
ev.src_addr.sa_family = ARPHRD_ETHER;
- memcpy(ev.src_addr.sa_data, hdr->addr2, ETH_ALEN);
+ ether_addr_copy(ev.src_addr.sa_data, hdr->addr2);
memset(&wrqu, 0, sizeof(wrqu));
wrqu.data.length = sizeof(ev);
wireless_send_event(dev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);
@@ -628,12 +626,11 @@ static int rtllib_michael_mic_verify(struct sk_buff *skb, int keyidx,
struct rtllib_hdr_4addr *hdr;
hdr = (struct rtllib_hdr_4addr *) skb->data;
- printk(KERN_DEBUG
- "%s: Michael MIC verification failed for MSDU from %pM keyidx=%d\n",
- skb->dev ? skb->dev->name : "N/A", hdr->addr2,
- keyidx);
- printk(KERN_DEBUG "%d\n",
- memcmp(mic, skb->data + skb->len - 8, 8) != 0);
+ netdev_dbg(skb->dev,
+ "Michael MIC verification failed for MSDU from %pM keyidx=%d\n",
+ hdr->addr2, keyidx);
+ netdev_dbg(skb->dev, "%d\n",
+ memcmp(mic, skb->data + skb->len - 8, 8) != 0);
if (skb->dev) {
pr_info("skb->dev != NULL\n");
rtllib_michael_mic_failure(skb->dev, hdr, keyidx);
diff --git a/drivers/staging/rtl8192e/rtllib_debug.h b/drivers/staging/rtl8192e/rtllib_debug.h
index 119729d31c7470..42e88d69ae63c0 100644
--- a/drivers/staging/rtl8192e/rtllib_debug.h
+++ b/drivers/staging/rtl8192e/rtllib_debug.h
@@ -73,16 +73,7 @@ enum RTL_DEBUG {
#define RT_TRACE(component, x, args...) \
do { \
if (rt_global_debug_component & component) \
- printk(KERN_DEBUG DRV_NAME ":" x "\n" , \
- ##args);\
-} while (0)
-
-#define assert(expr) \
-do { \
- if (!(expr)) { \
- pr_info("Assertion failed! %s,%s,%s,line=%d\n", \
- #expr, __FILE__, __func__, __LINE__); \
- } \
+ printk(KERN_DEBUG DRV_NAME ":" x "\n", ##args);\
} while (0)
#endif
diff --git a/drivers/staging/rtl8192e/rtllib_module.c b/drivers/staging/rtl8192e/rtllib_module.c
index 32cc8df9d3a76a..845d9b8a4aa2e5 100644
--- a/drivers/staging/rtl8192e/rtllib_module.c
+++ b/drivers/staging/rtl8192e/rtllib_module.c
@@ -103,11 +103,11 @@ struct net_device *alloc_rtllib(int sizeof_priv)
struct net_device *dev;
int i, err;
- RTLLIB_DEBUG_INFO("Initializing...\n");
+ pr_debug("rtllib: Initializing...\n");
dev = alloc_etherdev(sizeof(struct rtllib_device) + sizeof_priv);
if (!dev) {
- RTLLIB_ERROR("Unable to network device.\n");
+ pr_err("Unable to allocate net_device.\n");
return NULL;
}
ieee = (struct rtllib_device *)netdev_priv_rsl(dev);
@@ -116,8 +116,7 @@ struct net_device *alloc_rtllib(int sizeof_priv)
err = rtllib_networks_allocate(ieee);
if (err) {
- RTLLIB_ERROR("Unable to allocate beacon storage: %d\n",
- err);
+ pr_err("Unable to allocate beacon storage: %d\n", err);
goto failed;
}
rtllib_networks_initialize(ieee);
@@ -197,69 +196,13 @@ void free_rtllib(struct net_device *dev)
}
EXPORT_SYMBOL(free_rtllib);
-u32 rtllib_debug_level;
-static int debug = RTLLIB_DL_ERR;
-static struct proc_dir_entry *rtllib_proc;
-
-static int show_debug_level(struct seq_file *m, void *v)
-{
- seq_printf(m, "0x%08X\n", rtllib_debug_level);
-
- return 0;
-}
-
-static ssize_t write_debug_level(struct file *file, const char __user *buffer,
- size_t count, loff_t *ppos)
-{
- unsigned long val;
- int err = kstrtoul_from_user(buffer, count, 0, &val);
-
- if (err)
- return err;
- rtllib_debug_level = val;
- return count;
-}
-
-static int open_debug_level(struct inode *inode, struct file *file)
-{
- return single_open(file, show_debug_level, NULL);
-}
-
-static const struct file_operations fops = {
- .open = open_debug_level,
- .read = seq_read,
- .llseek = seq_lseek,
- .write = write_debug_level,
- .release = single_release,
-};
-
static int __init rtllib_init(void)
{
- struct proc_dir_entry *e;
-
- rtllib_debug_level = debug;
- rtllib_proc = proc_mkdir(DRV_NAME, init_net.proc_net);
- if (rtllib_proc == NULL) {
- RTLLIB_ERROR("Unable to create " DRV_NAME
- " proc directory\n");
- return -EIO;
- }
- e = proc_create("debug_level", S_IRUGO | S_IWUSR, rtllib_proc, &fops);
- if (!e) {
- remove_proc_entry(DRV_NAME, init_net.proc_net);
- rtllib_proc = NULL;
- return -EIO;
- }
return 0;
}
static void __exit rtllib_exit(void)
{
- if (rtllib_proc) {
- remove_proc_entry("debug_level", rtllib_proc);
- remove_proc_entry(DRV_NAME, init_net.proc_net);
- rtllib_proc = NULL;
- }
}
module_init(rtllib_init);
diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c
index fe3e7e1273ff82..6977f04ccd4dce 100644
--- a/drivers/staging/rtl8192e/rtllib_rx.c
+++ b/drivers/staging/rtl8192e/rtllib_rx.c
@@ -45,8 +45,9 @@
#include "dot11d.h"
static inline void rtllib_monitor_rx(struct rtllib_device *ieee,
- struct sk_buff *skb, struct rtllib_rx_stats *rx_status,
- size_t hdr_length)
+ struct sk_buff *skb,
+ struct rtllib_rx_stats *rx_status,
+ size_t hdr_length)
{
skb->dev = ieee->dev;
skb_reset_mac_header(skb);
@@ -69,9 +70,9 @@ rtllib_frag_cache_find(struct rtllib_device *ieee, unsigned int seq,
entry = &ieee->frag_cache[tid][i];
if (entry->skb != NULL &&
time_after(jiffies, entry->first_frag_time + 2 * HZ)) {
- RTLLIB_DEBUG_FRAG(
- "expiring fragment cache entry seq=%u last_frag=%u\n",
- entry->seq, entry->last_frag);
+ netdev_dbg(ieee->dev,
+ "expiring fragment cache entry seq=%u last_frag=%u\n",
+ entry->seq, entry->last_frag);
dev_kfree_skb_any(entry->skb);
entry->skb = NULL;
}
@@ -101,7 +102,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
struct rtllib_hdr_4addrqos *hdr_4addrqos;
u8 tid;
- if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
+ if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+ RTLLIB_QOS_HAS_SEQ(fc)) {
hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr;
tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
tid = UP2AC(tid);
@@ -123,7 +125,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
2 /* alignment */ +
8 /* WEP */ +
ETH_ALEN /* WDS */ +
- (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0) /* QOS Control */);
+ /* QOS Control */
+ (RTLLIB_QOS_HAS_SEQ(fc) ? 2 : 0));
if (skb == NULL)
return NULL;
@@ -139,8 +142,8 @@ rtllib_frag_cache_get(struct rtllib_device *ieee,
entry->seq = seq;
entry->last_frag = frag;
entry->skb = skb;
- memcpy(entry->src_addr, hdr->addr2, ETH_ALEN);
- memcpy(entry->dst_addr, hdr->addr1, ETH_ALEN);
+ ether_addr_copy(entry->src_addr, hdr->addr2);
+ ether_addr_copy(entry->dst_addr, hdr->addr1);
} else {
/* received a fragment of a frame for which the head fragment
* should have already been received
@@ -169,7 +172,8 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee,
struct rtllib_hdr_4addrqos *hdr_4addrqos;
u8 tid;
- if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
+ if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+ RTLLIB_QOS_HAS_SEQ(fc)) {
hdr_4addrqos = (struct rtllib_hdr_4addrqos *)hdr;
tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
tid = UP2AC(tid);
@@ -187,8 +191,9 @@ static int rtllib_frag_cache_invalidate(struct rtllib_device *ieee,
hdr->addr1);
if (entry == NULL) {
- RTLLIB_DEBUG_FRAG(
- "could not invalidate fragment cache entry (seq=%u)\n", seq);
+ netdev_dbg(ieee->dev,
+ "Couldn't invalidate fragment cache entry (seq=%u)\n",
+ seq);
return -1;
}
@@ -290,7 +295,8 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
return 0;
if (ieee->hwsec_active) {
- struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ struct cb_desc *tcb_desc = (struct cb_desc *)
+ (skb->cb + MAX_DEV_ADDR_SIZE);
tcb_desc->bHwSec = 1;
@@ -305,11 +311,12 @@ rtllib_rx_frame_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
res = crypt->ops->decrypt_mpdu(skb, hdrlen, crypt->priv);
atomic_dec(&crypt->refcnt);
if (res < 0) {
- RTLLIB_DEBUG_DROP(
- "decryption failed (SA= %pM) res=%d\n", hdr->addr2, res);
+ netdev_dbg(ieee->dev, "decryption failed (SA= %pM) res=%d\n",
+ hdr->addr2, res);
if (res == -2)
- RTLLIB_DEBUG_DROP("Decryption failed ICV mismatch (key %d)\n",
- skb->data[hdrlen + 3] >> 6);
+ netdev_dbg(ieee->dev,
+ "Decryption failed ICV mismatch (key %d)\n",
+ skb->data[hdrlen + 3] >> 6);
ieee->ieee_stats.rx_discards_undecryptable++;
return -1;
}
@@ -329,7 +336,8 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,
if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
return 0;
if (ieee->hwsec_active) {
- struct cb_desc *tcb_desc = (struct cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
+ struct cb_desc *tcb_desc = (struct cb_desc *)
+ (skb->cb + MAX_DEV_ADDR_SIZE);
tcb_desc->bHwSec = 1;
@@ -344,8 +352,9 @@ rtllib_rx_frame_decrypt_msdu(struct rtllib_device *ieee, struct sk_buff *skb,
res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv);
atomic_dec(&crypt->refcnt);
if (res < 0) {
- printk(KERN_DEBUG "%s: MSDU decryption/MIC verification failed (SA= %pM keyidx=%d)\n",
- ieee->dev->name, hdr->addr2, keyidx);
+ netdev_dbg(ieee->dev,
+ "MSDU decryption/MIC verification failed (SA= %pM keyidx=%d)\n",
+ hdr->addr2, keyidx);
return -1;
}
@@ -368,7 +377,8 @@ static int is_duplicate_packet(struct rtllib_device *ieee,
struct rtllib_hdr_4addrqos *hdr_4addrqos;
u8 tid;
- if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) && RTLLIB_QOS_HAS_SEQ(fc)) {
+ if (((fc & RTLLIB_FCTL_DSTODS) == RTLLIB_FCTL_DSTODS) &&
+ RTLLIB_QOS_HAS_SEQ(fc)) {
hdr_4addrqos = (struct rtllib_hdr_4addrqos *)header;
tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & RTLLIB_QCTL_TID;
tid = UP2AC(tid);
@@ -396,11 +406,12 @@ static int is_duplicate_packet(struct rtllib_device *ieee,
break;
}
if (p == &ieee->ibss_mac_hash[index]) {
- entry = kmalloc(sizeof(struct ieee_ibss_seq), GFP_ATOMIC);
+ entry = kmalloc(sizeof(struct ieee_ibss_seq),
+ GFP_ATOMIC);
if (!entry)
return 0;
- memcpy(entry->mac, mac, ETH_ALEN);
+ ether_addr_copy(entry->mac, mac);
entry->seq_num[tid] = seq;
entry->frag_num[tid] = frag;
entry->packet_time[tid] = jiffies;
@@ -466,10 +477,11 @@ static bool AddReorderEntry(struct rx_ts_record *pTS,
return true;
}
-void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prxbIndicateArray, u8 index)
+void rtllib_indicate_packets(struct rtllib_device *ieee,
+ struct rtllib_rxb **prxbIndicateArray, u8 index)
{
struct net_device_stats *stats = &ieee->stats;
- u8 i = 0 , j = 0;
+ u8 i = 0, j = 0;
u16 ethertype;
for (j = 0; j < index; j++) {
@@ -481,9 +493,12 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx
/* convert hdr + possible LLC headers into Ethernet header */
ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
if (sub_skb->len >= 8 &&
- ((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
- ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
- memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
+ ((memcmp(sub_skb->data, rfc1042_header,
+ SNAP_SIZE) == 0 &&
+ ethertype != ETH_P_AARP &&
+ ethertype != ETH_P_IPX) ||
+ memcmp(sub_skb->data, bridge_tunnel_header,
+ SNAP_SIZE) == 0)) {
/* remove RFC1042 or Bridge-Tunnel encapsulation
* and replace EtherType
*/
@@ -505,11 +520,13 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx
stats->rx_bytes += sub_skb->len;
memset(sub_skb->cb, 0, sizeof(sub_skb->cb));
- sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev);
+ sub_skb->protocol = eth_type_trans(sub_skb,
+ ieee->dev);
sub_skb->dev = ieee->dev;
sub_skb->dev->stats.rx_packets++;
sub_skb->dev->stats.rx_bytes += sub_skb->len;
- sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
+ /* 802.11 crc not sufficient */
+ sub_skb->ip_summed = CHECKSUM_NONE;
ieee->last_rx_ps_time = jiffies;
netif_rx(sub_skb);
}
@@ -519,7 +536,8 @@ void rtllib_indicate_packets(struct rtllib_device *ieee, struct rtllib_rxb **prx
}
}
-void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record *pTS)
+void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee,
+ struct rx_ts_record *pTS)
{
struct rx_reorder_entry *pRxReorderEntry;
u8 RfdCnt = 0;
@@ -533,14 +551,18 @@ void rtllib_FlushRxTsPendingPkts(struct rtllib_device *ieee, struct rx_ts_record
break;
}
- pRxReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev, struct rx_reorder_entry, List);
- RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pRxReorderEntry->SeqNum);
+ pRxReorderEntry = (struct rx_reorder_entry *)
+ list_entry(pTS->RxPendingPktList.prev,
+ struct rx_reorder_entry, List);
+ netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n", __func__,
+ pRxReorderEntry->SeqNum);
list_del_init(&pRxReorderEntry->List);
ieee->RfdArray[RfdCnt] = pRxReorderEntry->prxb;
RfdCnt = RfdCnt + 1;
- list_add_tail(&pRxReorderEntry->List, &ieee->RxReorder_Unused_List);
+ list_add_tail(&pRxReorderEntry->List,
+ &ieee->RxReorder_Unused_List);
}
rtllib_indicate_packets(ieee, ieee->RfdArray, RfdCnt);
@@ -559,8 +581,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
bool bMatchWinStart = false, bPktInBuf = false;
unsigned long flags;
- RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Seq is %d, pTS->RxIndicateSeq is %d, WinSize is %d\n", __func__, SeqNum,
- pTS->RxIndicateSeq, WinSize);
+ netdev_dbg(ieee->dev,
+ "%s(): Seq is %d, pTS->RxIndicateSeq is %d, WinSize is %d\n",
+ __func__, SeqNum, pTS->RxIndicateSeq, WinSize);
spin_lock_irqsave(&(ieee->reorder_spinlock), flags);
@@ -571,8 +594,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
/* Drop out the packet which SeqNum is smaller than WinStart */
if (SN_LESS(SeqNum, pTS->RxIndicateSeq)) {
- RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
- pTS->RxIndicateSeq, SeqNum);
+ netdev_dbg(ieee->dev,
+ "Packet Drop! IndicateSeq: %d, NewSeq: %d\n",
+ pTS->RxIndicateSeq, SeqNum);
pHTInfo->RxReorderDropCounter++;
{
int i;
@@ -597,8 +621,11 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
if (SeqNum >= (WinSize - 1))
pTS->RxIndicateSeq = SeqNum + 1 - WinSize;
else
- pTS->RxIndicateSeq = 4095 - (WinSize - (SeqNum + 1)) + 1;
- RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Window Shift! IndicateSeq: %d, NewSeq: %d\n", pTS->RxIndicateSeq, SeqNum);
+ pTS->RxIndicateSeq = 4095 -
+ (WinSize - (SeqNum + 1)) + 1;
+ netdev_dbg(ieee->dev,
+ "Window Shift! IndicateSeq: %d, NewSeq: %d\n",
+ pTS->RxIndicateSeq, SeqNum);
}
/* Indication process.
@@ -613,8 +640,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
*/
if (bMatchWinStart) {
/* Current packet is going to be indicated.*/
- RTLLIB_DEBUG(RTLLIB_DL_REORDER, "Packets indication!! IndicateSeq: %d, NewSeq: %d\n",
- pTS->RxIndicateSeq, SeqNum);
+ netdev_dbg(ieee->dev,
+ "Packets indication! IndicateSeq: %d, NewSeq: %d\n",
+ pTS->RxIndicateSeq, SeqNum);
ieee->prxbIndicateArray[0] = prxb;
index = 1;
} else {
@@ -625,28 +653,30 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
struct rx_reorder_entry, List);
list_del_init(&pReorderEntry->List);
- /* Make a reorder entry and insert into a the packet list.*/
+ /* Make a reorder entry and insert
+ * into a the packet list.
+ */
pReorderEntry->SeqNum = SeqNum;
pReorderEntry->prxb = prxb;
if (!AddReorderEntry(pTS, pReorderEntry)) {
- RTLLIB_DEBUG(RTLLIB_DL_REORDER,
- "%s(): Duplicate packet is dropped!! IndicateSeq: %d, NewSeq: %d\n",
- __func__, pTS->RxIndicateSeq,
- SeqNum);
+ int i;
+
+ netdev_dbg(ieee->dev,
+ "%s(): Duplicate packet is dropped. IndicateSeq: %d, NewSeq: %d\n",
+ __func__, pTS->RxIndicateSeq,
+ SeqNum);
list_add_tail(&pReorderEntry->List,
- &ieee->RxReorder_Unused_List); {
- int i;
+ &ieee->RxReorder_Unused_List);
- for (i = 0; i < prxb->nr_subframes; i++)
- dev_kfree_skb(prxb->subframes[i]);
- kfree(prxb);
- prxb = NULL;
- }
+ for (i = 0; i < prxb->nr_subframes; i++)
+ dev_kfree_skb(prxb->subframes[i]);
+ kfree(prxb);
+ prxb = NULL;
} else {
- RTLLIB_DEBUG(RTLLIB_DL_REORDER,
- "Pkt insert into struct buffer!! IndicateSeq: %d, NewSeq: %d\n",
- pTS->RxIndicateSeq, SeqNum);
+ netdev_dbg(ieee->dev,
+ "Pkt insert into struct buffer. IndicateSeq: %d, NewSeq: %d\n",
+ pTS->RxIndicateSeq, SeqNum);
}
} else {
/* Packets are dropped if there are not enough reorder
@@ -654,7 +684,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
* indicate all the packets in struct buffer and get
* reorder entries.
*/
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): There is no reorder entry!! Packet is dropped!!\n");
+ netdev_err(ieee->dev,
+ "%s(): There is no reorder entry! Packet is dropped!\n",
+ __func__);
{
int i;
@@ -668,15 +700,20 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
/* Check if there is any packet need indicate.*/
while (!list_empty(&pTS->RxPendingPktList)) {
- RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): start RREORDER indicate\n", __func__);
+ netdev_dbg(ieee->dev, "%s(): start RREORDER indicate\n",
+ __func__);
- pReorderEntry = (struct rx_reorder_entry *)list_entry(pTS->RxPendingPktList.prev,
- struct rx_reorder_entry, List);
+ pReorderEntry = (struct rx_reorder_entry *)
+ list_entry(pTS->RxPendingPktList.prev,
+ struct rx_reorder_entry,
+ List);
if (SN_LESS(pReorderEntry->SeqNum, pTS->RxIndicateSeq) ||
- SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) {
+ SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq)) {
/* This protect struct buffer from overflow. */
if (index >= REORDER_WIN_SIZE) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Buffer overflow!!\n");
+ netdev_err(ieee->dev,
+ "%s(): Buffer overflow!\n",
+ __func__);
bPktInBuf = true;
break;
}
@@ -684,10 +721,12 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
list_del_init(&pReorderEntry->List);
if (SN_EQUAL(pReorderEntry->SeqNum, pTS->RxIndicateSeq))
- pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) % 4096;
+ pTS->RxIndicateSeq = (pTS->RxIndicateSeq + 1) %
+ 4096;
ieee->prxbIndicateArray[index] = pReorderEntry->prxb;
- RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): Indicate SeqNum %d!\n", __func__, pReorderEntry->SeqNum);
+ netdev_dbg(ieee->dev, "%s(): Indicate SeqNum %d!\n",
+ __func__, pReorderEntry->SeqNum);
index++;
list_add_tail(&pReorderEntry->List,
@@ -707,7 +746,9 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
pTS->RxTimeoutIndicateSeq = 0xffff;
if (index > REORDER_WIN_SIZE) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "RxReorderIndicatePacket(): Rx Reorder struct buffer full!!\n");
+ netdev_err(ieee->dev,
+ "%s(): Rx Reorder struct buffer full!\n",
+ __func__);
spin_unlock_irqrestore(&(ieee->reorder_spinlock),
flags);
return;
@@ -717,8 +758,7 @@ static void RxReorderIndicatePacket(struct rtllib_device *ieee,
}
if (bPktInBuf && pTS->RxTimeoutIndicateSeq == 0xffff) {
- RTLLIB_DEBUG(RTLLIB_DL_REORDER, "%s(): SET rx timeout timer\n",
- __func__);
+ netdev_dbg(ieee->dev, "%s(): SET rx timeout timer\n", __func__);
pTS->RxTimeoutIndicateSeq = pTS->RxIndicateSeq;
mod_timer(&pTS->RxPktPendingTimer, jiffies +
msecs_to_jiffies(pHTInfo->RxReorderPendingTime));
@@ -834,7 +874,8 @@ static u8 parse_subframe(struct rtllib_device *ieee, struct sk_buff *skb,
sub_skb->dev = ieee->dev;
rxb->subframes[rxb->nr_subframes++] = sub_skb;
if (rxb->nr_subframes >= MAX_SUBFRAME_COUNT) {
- RTLLIB_DEBUG_RX("ParseSubframe(): Too many Subframes! Packets dropped!\n");
+ netdev_dbg(ieee->dev,
+ "ParseSubframe(): Too many Subframes! Packets dropped!\n");
break;
}
skb_pull(skb, nSubframe_Length);
@@ -896,7 +937,8 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
!ieee->current_network.qos_data.active ||
!IsDataFrame(skb->data) ||
IsLegacyDataFrame(skb->data)) {
- if (!((type == RTLLIB_FTYPE_MGMT) && (stype == RTLLIB_STYPE_BEACON))) {
+ if (!((type == RTLLIB_FTYPE_MGMT) &&
+ (stype == RTLLIB_STYPE_BEACON))) {
if (is_duplicate_packet(ieee, hdr))
return -1;
}
@@ -911,7 +953,8 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee,
pRxTS->RxLastFragNum = frag;
pRxTS->RxLastSeqNum = WLAN_GET_SEQ_SEQ(sc);
} else {
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "ERR!!%s(): No TS!! Skip the check!!\n", __func__);
+ netdev_warn(ieee->dev, "%s(): No TS! Skip the check!\n",
+ __func__);
return -1;
}
}
@@ -927,24 +970,24 @@ static void rtllib_rx_extract_addr(struct rtllib_device *ieee,
switch (fc & (RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS)) {
case RTLLIB_FCTL_FROMDS:
- memcpy(dst, hdr->addr1, ETH_ALEN);
- memcpy(src, hdr->addr3, ETH_ALEN);
- memcpy(bssid, hdr->addr2, ETH_ALEN);
+ ether_addr_copy(dst, hdr->addr1);
+ ether_addr_copy(src, hdr->addr3);
+ ether_addr_copy(bssid, hdr->addr2);
break;
case RTLLIB_FCTL_TODS:
- memcpy(dst, hdr->addr3, ETH_ALEN);
- memcpy(src, hdr->addr2, ETH_ALEN);
- memcpy(bssid, hdr->addr1, ETH_ALEN);
+ ether_addr_copy(dst, hdr->addr3);
+ ether_addr_copy(src, hdr->addr2);
+ ether_addr_copy(bssid, hdr->addr1);
break;
case RTLLIB_FCTL_FROMDS | RTLLIB_FCTL_TODS:
- memcpy(dst, hdr->addr3, ETH_ALEN);
- memcpy(src, hdr->addr4, ETH_ALEN);
- memcpy(bssid, ieee->current_network.bssid, ETH_ALEN);
+ ether_addr_copy(dst, hdr->addr3);
+ ether_addr_copy(src, hdr->addr4);
+ ether_addr_copy(bssid, ieee->current_network.bssid);
break;
case 0:
- memcpy(dst, hdr->addr1, ETH_ALEN);
- memcpy(src, hdr->addr2, ETH_ALEN);
- memcpy(bssid, hdr->addr3, ETH_ALEN);
+ ether_addr_copy(dst, hdr->addr1);
+ ether_addr_copy(src, hdr->addr2);
+ ether_addr_copy(bssid, hdr->addr3);
break;
}
}
@@ -984,9 +1027,9 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
stype != RTLLIB_STYPE_DATA_CFACKPOLL &&
stype != RTLLIB_STYPE_QOS_DATA) {
if (stype != RTLLIB_STYPE_NULLFUNC)
- RTLLIB_DEBUG_DROP(
- "RX: dropped data frame with no data (type=0x%02x, subtype=0x%02x)\n",
- type, stype);
+ netdev_dbg(ieee->dev,
+ "RX: dropped data frame with no data (type=0x%02x, subtype=0x%02x)\n",
+ type, stype);
return -1;
}
}
@@ -998,7 +1041,8 @@ static int rtllib_rx_data_filter(struct rtllib_device *ieee, u16 fc,
/* {broad,multi}cast packets to our BSS go through */
if (is_multicast_ether_addr(dst)) {
- if (memcmp(bssid, ieee->current_network.bssid, ETH_ALEN))
+ if (memcmp(bssid, ieee->current_network.bssid,
+ ETH_ALEN))
return -1;
}
}
@@ -1030,8 +1074,9 @@ static int rtllib_rx_get_crypt(struct rtllib_device *ieee, struct sk_buff *skb,
* frames silently instead of filling system log with
* these reports.
*/
- RTLLIB_DEBUG_DROP("Decryption failed (not set) (SA= %pM)\n",
- hdr->addr2);
+ netdev_dbg(ieee->dev,
+ "Decryption failed (not set) (SA= %pM)\n",
+ hdr->addr2);
ieee->ieee_stats.rx_discards_undecryptable++;
return -1;
}
@@ -1070,13 +1115,13 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
int flen;
struct sk_buff *frag_skb = rtllib_frag_cache_get(ieee, hdr);
- RTLLIB_DEBUG_FRAG("Rx Fragment received (%u)\n", frag);
+ netdev_dbg(ieee->dev, "Rx Fragment received (%u)\n", frag);
if (!frag_skb) {
- RTLLIB_DEBUG(RTLLIB_DL_RX | RTLLIB_DL_FRAG,
- "Rx cannot get skb from fragment cache (morefrag=%d seq=%u frag=%u)\n",
- (fc & RTLLIB_FCTL_MOREFRAGS) != 0,
- WLAN_GET_SEQ_SEQ(sc), frag);
+ netdev_dbg(ieee->dev,
+ "Rx cannot get skb from fragment cache (morefrag=%d seq=%u frag=%u)\n",
+ (fc & RTLLIB_FCTL_MOREFRAGS) != 0,
+ WLAN_GET_SEQ_SEQ(sc), frag);
return -1;
}
flen = skb->len;
@@ -1141,12 +1186,13 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
*/
struct eapol *eap = (struct eapol *)(skb->data +
24);
- RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
- eap_get_type(eap->type));
+ netdev_dbg(ieee->dev,
+ "RX: IEEE 802.1X EAPOL frame: %s\n",
+ eap_get_type(eap->type));
} else {
- RTLLIB_DEBUG_DROP(
- "encryption configured, but RX frame not encrypted (SA= %pM)\n",
- hdr->addr2);
+ netdev_dbg(ieee->dev,
+ "encryption configured, but RX frame not encrypted (SA= %pM)\n",
+ hdr->addr2);
return -1;
}
}
@@ -1155,15 +1201,16 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
struct eapol *eap = (struct eapol *)(skb->data +
24);
- RTLLIB_DEBUG_EAP("RX: IEEE 802.1X EAPOL frame: %s\n",
- eap_get_type(eap->type));
+ netdev_dbg(ieee->dev,
+ "RX: IEEE 802.1X EAPOL frame: %s\n",
+ eap_get_type(eap->type));
}
if (crypt && !(fc & RTLLIB_FCTL_WEP) && !ieee->open_wep &&
!rtllib_is_eapol_frame(ieee, skb, hdrlen)) {
- RTLLIB_DEBUG_DROP(
- "dropped unencrypted RX data frame from %pM (drop_unencrypted=1)\n",
- hdr->addr2);
+ netdev_dbg(ieee->dev,
+ "dropped unencrypted RX data frame from %pM (drop_unencrypted=1)\n",
+ hdr->addr2);
return -1;
}
@@ -1173,7 +1220,8 @@ static int rtllib_rx_decrypt(struct rtllib_device *ieee, struct sk_buff *skb,
return 0;
}
-static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast, u8 nr_subframes)
+static void rtllib_rx_check_leave_lps(struct rtllib_device *ieee, u8 unicast,
+ u8 nr_subframes)
{
if (unicast) {
@@ -1208,25 +1256,33 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
struct sk_buff *sub_skb = rxb->subframes[i];
if (sub_skb) {
- /* convert hdr + possible LLC headers into Ethernet header */
+ /* convert hdr + possible LLC headers
+ * into Ethernet header
+ */
ethertype = (sub_skb->data[6] << 8) | sub_skb->data[7];
if (sub_skb->len >= 8 &&
((memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) == 0 &&
ethertype != ETH_P_AARP && ethertype != ETH_P_IPX) ||
memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE) == 0)) {
- /* remove RFC1042 or Bridge-Tunnel encapsulation and
- * replace EtherType
+ /* remove RFC1042 or Bridge-Tunnel encapsulation
+ * and replace EtherType
*/
skb_pull(sub_skb, SNAP_SIZE);
- memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
- memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
+ ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
+ src);
+ ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
+ dst);
} else {
u16 len;
- /* Leave Ethernet header part of hdr and full payload */
+ /* Leave Ethernet header part of hdr
+ * and full payload
+ */
len = sub_skb->len;
memcpy(skb_push(sub_skb, 2), &len, 2);
- memcpy(skb_push(sub_skb, ETH_ALEN), src, ETH_ALEN);
- memcpy(skb_push(sub_skb, ETH_ALEN), dst, ETH_ALEN);
+ ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
+ src);
+ ether_addr_copy(skb_push(sub_skb, ETH_ALEN),
+ dst);
}
ieee->stats.rx_packets++;
@@ -1241,7 +1297,8 @@ static void rtllib_rx_indicate_pkt_legacy(struct rtllib_device *ieee,
sub_skb->dev = dev;
sub_skb->dev->stats.rx_packets++;
sub_skb->dev->stats.rx_bytes += sub_skb->len;
- sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */
+ /* 802.11 crc not sufficient */
+ sub_skb->ip_summed = CHECKSUM_NONE;
netif_rx(sub_skb);
}
}
@@ -1258,7 +1315,11 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
struct rx_ts_record *pTS = NULL;
u16 fc, sc, SeqNum = 0;
u8 type, stype, multicast = 0, unicast = 0, nr_subframes = 0, TID = 0;
- u8 dst[ETH_ALEN], src[ETH_ALEN], bssid[ETH_ALEN] = {0}, *payload;
+ u8 *payload;
+ u8 dst[ETH_ALEN];
+ u8 src[ETH_ALEN];
+ u8 bssid[ETH_ALEN] = {0};
+
size_t hdrlen = 0;
bool bToOtherSTA = false;
int ret = 0, i = 0;
@@ -1282,7 +1343,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
/*Filter pkt has too small length */
hdrlen = rtllib_rx_get_hdrlen(ieee, skb, rx_stats);
if (skb->len < hdrlen) {
- netdev_info(dev, "%s():ERR!!! skb->len is smaller than hdrlen\n",
+ netdev_info(dev,
+ "%s():ERR!!! skb->len is smaller than hdrlen\n",
__func__);
goto rx_dropped;
}
@@ -1327,10 +1389,13 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
goto rx_dropped;
/* Send pspoll based on moredata */
- if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->sta_sleep == LPS_IS_SLEEP)
- && (ieee->polling) && (!bToOtherSTA)) {
+ if ((ieee->iw_mode == IW_MODE_INFRA) &&
+ (ieee->sta_sleep == LPS_IS_SLEEP) &&
+ (ieee->polling) && (!bToOtherSTA)) {
if (WLAN_FC_MORE_DATA(fc)) {
- /* more data bit is set, let's request a new frame from the AP */
+ /* more data bit is set, let's request a new frame
+ * from the AP
+ */
rtllib_sta_ps_send_pspoll_frame(ieee);
} else {
ieee->polling = false;
@@ -1356,7 +1421,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
&& (!bToOtherSTA)) {
TID = Frame_QoSTID(skb->data);
SeqNum = WLAN_GET_SEQ_SEQ(sc);
- GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID, RX_DIR, true);
+ GetTs(ieee, (struct ts_common_info **) &pTS, hdr->addr2, TID,
+ RX_DIR, true);
if (TID != 0 && TID != 3)
ieee->bis_any_nonbepkts = true;
}
@@ -1371,7 +1437,9 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
/* to parse amsdu packets */
/* qos data packets & reserved bit is 1 */
if (parse_subframe(ieee, skb, rx_stats, rxb, src, dst) == 0) {
- /* only to free rxb, and not submit the packets to upper layer */
+ /* only to free rxb, and not submit the packets
+ * to upper layer
+ */
for (i = 0; i < rxb->nr_subframes; i++)
dev_kfree_skb(rxb->subframes[i]);
kfree(rxb);
@@ -1393,7 +1461,8 @@ static int rtllib_rx_InfraAdhoc(struct rtllib_device *ieee, struct sk_buff *skb,
}
/* Indicate packets to upper layer or Rx Reorder */
- if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL || bToOtherSTA)
+ if (ieee->pHTInfo->bCurRxReorderEnable == false || pTS == NULL ||
+ bToOtherSTA)
rtllib_rx_indicate_pkt_legacy(ieee, rx_stats, rxb, dst, src);
else
RxReorderIndicatePacket(ieee, rxb, pTS, SeqNum);
@@ -1522,8 +1591,9 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element
/* Parse a QoS parameter element */
static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info
- *element_param, struct rtllib_info_element
- *info_element)
+ *element_param,
+ struct rtllib_info_element
+ *info_element)
{
int ret = 0;
u16 size = sizeof(struct rtllib_qos_parameter_info) - 2;
@@ -1545,10 +1615,10 @@ static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info
}
/* Parse a QoS information element */
-static int rtllib_read_qos_info_element(struct
- rtllib_qos_information_element
- *element_info, struct rtllib_info_element
- *info_element)
+static int rtllib_read_qos_info_element(struct rtllib_qos_information_element
+ *element_info,
+ struct rtllib_info_element
+ *info_element)
{
int ret = 0;
u16 size = sizeof(struct rtllib_qos_information_element) - 2;
@@ -1558,7 +1628,8 @@ static int rtllib_read_qos_info_element(struct
if (info_element == NULL)
return -1;
- if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) {
+ if ((info_element->id == QOS_ELEMENT_ID) &&
+ (info_element->len == size)) {
memcpy(element_info->qui, info_element->data,
info_element->len);
element_info->elementID = info_element->id;
@@ -1568,14 +1639,14 @@ static int rtllib_read_qos_info_element(struct
if (ret == 0)
ret = rtllib_verify_qos_info(element_info,
- QOS_OUI_INFO_SUB_TYPE);
+ QOS_OUI_INFO_SUB_TYPE);
return ret;
}
/* Write QoS parameters from the ac parameters. */
static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info *param_elm,
- struct rtllib_qos_data *qos_data)
+ struct rtllib_qos_data *qos_data)
{
struct rtllib_qos_ac_parameter *ac_params;
struct rtllib_qos_parameters *qos_param = &(qos_data->parameters);
@@ -1619,11 +1690,13 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info
qos_param->aifs[aci] = (ac_params->aci_aifsn) & 0x0f;
/* WMM spec P.11: The minimum value for AIFSN shall be 2 */
- qos_param->aifs[aci] = (qos_param->aifs[aci] < 2) ? 2 : qos_param->aifs[aci];
+ qos_param->aifs[aci] = max_t(u8, qos_param->aifs[aci], 2);
- qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max & 0x0F);
+ qos_param->cw_min[aci] = cpu_to_le16(ac_params->ecw_min_max &
+ 0x0F);
- qos_param->cw_max[aci] = cpu_to_le16((ac_params->ecw_min_max & 0xF0) >> 4);
+ qos_param->cw_max[aci] = cpu_to_le16((ac_params->ecw_min_max &
+ 0xF0) >> 4);
qos_param->flag[aci] =
(ac_params->aci_aifsn & 0x10) ? 0x01 : 0x00;
@@ -1636,9 +1709,10 @@ static int rtllib_qos_convert_ac_to_parameters(struct rtllib_qos_parameter_info
* parameters element. check the information element length to decide
* which type to read
*/
-static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element
+static int rtllib_parse_qos_info_param_IE(struct rtllib_device *ieee,
+ struct rtllib_info_element
*info_element,
- struct rtllib_network *network)
+ struct rtllib_network *network)
{
int rc = 0;
struct rtllib_qos_information_element qos_info_element;
@@ -1663,7 +1737,7 @@ static int rtllib_parse_qos_info_param_IE(struct rtllib_info_element
}
if (rc == 0) {
- RTLLIB_DEBUG_QOS("QoS is supported\n");
+ netdev_dbg(ieee->dev, "QoS is supported\n");
network->qos_data.supported = 1;
}
return rc;
@@ -1713,15 +1787,19 @@ static inline void rtllib_extract_country_ie(
{
if (IS_DOT11D_ENABLE(ieee)) {
if (info_element->len != 0) {
- memcpy(network->CountryIeBuf, info_element->data, info_element->len);
+ memcpy(network->CountryIeBuf, info_element->data,
+ info_element->len);
network->CountryIeLen = info_element->len;
if (!IS_COUNTRY_IE_VALID(ieee)) {
- if (rtllib_act_scanning(ieee, false) && ieee->FirstIe_InScan)
+ if (rtllib_act_scanning(ieee, false) &&
+ ieee->FirstIe_InScan)
netdev_info(ieee->dev,
"Received beacon ContryIE, SSID: <%s>\n",
network->ssid);
- Dot11d_UpdateCountryIe(ieee, addr2, info_element->len, info_element->data);
+ Dot11d_UpdateCountryIe(ieee, addr2,
+ info_element->len,
+ info_element->data);
}
}
@@ -1731,6 +1809,238 @@ static inline void rtllib_extract_country_ie(
}
+static void rtllib_parse_mife_generic(struct rtllib_device *ieee,
+ struct rtllib_info_element *info_element,
+ struct rtllib_network *network,
+ u16 *tmp_htcap_len,
+ u16 *tmp_htinfo_len)
+{
+ u16 ht_realtek_agg_len = 0;
+ u8 ht_realtek_agg_buf[MAX_IE_LEN];
+
+ if (!rtllib_parse_qos_info_param_IE(ieee, info_element, network))
+ return;
+ if (info_element->len >= 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x50 &&
+ info_element->data[2] == 0xf2 &&
+ info_element->data[3] == 0x01) {
+ network->wpa_ie_len = min(info_element->len + 2,
+ MAX_WPA_IE_LEN);
+ memcpy(network->wpa_ie, info_element, network->wpa_ie_len);
+ return;
+ }
+ if (info_element->len == 7 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0xe0 &&
+ info_element->data[2] == 0x4c &&
+ info_element->data[3] == 0x01 &&
+ info_element->data[4] == 0x02)
+ network->Turbo_Enable = 1;
+
+ if (*tmp_htcap_len == 0) {
+ if (info_element->len >= 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x90 &&
+ info_element->data[2] == 0x4c &&
+ info_element->data[3] == 0x033) {
+ *tmp_htcap_len = min_t(u8, info_element->len,
+ MAX_IE_LEN);
+ if (*tmp_htcap_len != 0) {
+ network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+ network->bssht.bdHTCapLen = min_t(u16, *tmp_htcap_len, sizeof(network->bssht.bdHTCapBuf));
+ memcpy(network->bssht.bdHTCapBuf,
+ info_element->data,
+ network->bssht.bdHTCapLen);
+ }
+ }
+ if (*tmp_htcap_len != 0) {
+ network->bssht.bdSupportHT = true;
+ network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
+ } else {
+ network->bssht.bdSupportHT = false;
+ network->bssht.bdHT1R = false;
+ }
+ }
+
+
+ if (*tmp_htinfo_len == 0) {
+ if (info_element->len >= 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x90 &&
+ info_element->data[2] == 0x4c &&
+ info_element->data[3] == 0x034) {
+ *tmp_htinfo_len = min_t(u8, info_element->len,
+ MAX_IE_LEN);
+ if (*tmp_htinfo_len != 0) {
+ network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
+ network->bssht.bdHTInfoLen = min_t(u16, *tmp_htinfo_len, sizeof(network->bssht.bdHTInfoBuf));
+ memcpy(network->bssht.bdHTInfoBuf,
+ info_element->data,
+ network->bssht.bdHTInfoLen);
+ }
+
+ }
+ }
+
+ if (ieee->aggregation) {
+ if (network->bssht.bdSupportHT) {
+ if (info_element->len >= 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0xe0 &&
+ info_element->data[2] == 0x4c &&
+ info_element->data[3] == 0x02) {
+ ht_realtek_agg_len = min_t(u8,
+ info_element->len,
+ MAX_IE_LEN);
+ memcpy(ht_realtek_agg_buf,
+ info_element->data,
+ info_element->len);
+ }
+ if (ht_realtek_agg_len >= 5) {
+ network->realtek_cap_exit = true;
+ network->bssht.bdRT2RTAggregation = true;
+
+ if ((ht_realtek_agg_buf[4] == 1) &&
+ (ht_realtek_agg_buf[5] & 0x02))
+ network->bssht.bdRT2RTLongSlotTime = true;
+
+ if ((ht_realtek_agg_buf[4] == 1) &&
+ (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
+ network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
+ }
+ }
+ if (ht_realtek_agg_len >= 5) {
+ if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP))
+ network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
+ }
+ }
+
+ if ((info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x05 &&
+ info_element->data[2] == 0xb5) ||
+ (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x0a &&
+ info_element->data[2] == 0xf7) ||
+ (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x10 &&
+ info_element->data[2] == 0x18)) {
+ network->broadcom_cap_exist = true;
+ }
+ if (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x0c &&
+ info_element->data[2] == 0x43)
+ network->ralink_cap_exist = true;
+ if ((info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x03 &&
+ info_element->data[2] == 0x7f) ||
+ (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x13 &&
+ info_element->data[2] == 0x74))
+ network->atheros_cap_exist = true;
+
+ if ((info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x50 &&
+ info_element->data[2] == 0x43))
+ network->marvell_cap_exist = true;
+ if (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x40 &&
+ info_element->data[2] == 0x96)
+ network->cisco_cap_exist = true;
+
+
+ if (info_element->len >= 3 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x0a &&
+ info_element->data[2] == 0xf5)
+ network->airgo_cap_exist = true;
+
+ if (info_element->len > 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x40 &&
+ info_element->data[2] == 0x96 &&
+ info_element->data[3] == 0x01) {
+ if (info_element->len == 6) {
+ memcpy(network->CcxRmState, &info_element[4], 2);
+ if (network->CcxRmState[0] != 0)
+ network->bCcxRmEnable = true;
+ else
+ network->bCcxRmEnable = false;
+ network->MBssidMask = network->CcxRmState[1] & 0x07;
+ if (network->MBssidMask != 0) {
+ network->bMBssidValid = true;
+ network->MBssidMask = 0xff <<
+ (network->MBssidMask);
+ ether_addr_copy(network->MBssid,
+ network->bssid);
+ network->MBssid[5] &= network->MBssidMask;
+ } else {
+ network->bMBssidValid = false;
+ }
+ } else {
+ network->bCcxRmEnable = false;
+ }
+ }
+ if (info_element->len > 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x40 &&
+ info_element->data[2] == 0x96 &&
+ info_element->data[3] == 0x03) {
+ if (info_element->len == 5) {
+ network->bWithCcxVerNum = true;
+ network->BssCcxVerNumber = info_element->data[4];
+ } else {
+ network->bWithCcxVerNum = false;
+ network->BssCcxVerNumber = 0;
+ }
+ }
+ if (info_element->len > 4 &&
+ info_element->data[0] == 0x00 &&
+ info_element->data[1] == 0x50 &&
+ info_element->data[2] == 0xf2 &&
+ info_element->data[3] == 0x04) {
+ netdev_dbg(ieee->dev, "MFIE_TYPE_WZC: %d bytes\n",
+ info_element->len);
+ network->wzc_ie_len = min(info_element->len+2, MAX_WZC_IE_LEN);
+ memcpy(network->wzc_ie, info_element, network->wzc_ie_len);
+ }
+}
+
+static void rtllib_parse_mfie_ht_cap(struct rtllib_info_element *info_element,
+ struct rtllib_network *network,
+ u16 *tmp_htcap_len)
+{
+ struct bss_ht *ht = &network->bssht;
+
+ *tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
+ if (*tmp_htcap_len != 0) {
+ ht->bdHTSpecVer = HT_SPEC_VER_EWC;
+ ht->bdHTCapLen = min_t(u16, *tmp_htcap_len,
+ sizeof(ht->bdHTCapBuf));
+ memcpy(ht->bdHTCapBuf, info_element->data, ht->bdHTCapLen);
+
+ ht->bdSupportHT = true;
+ ht->bdHT1R = ((((struct ht_capab_ele *)
+ ht->bdHTCapBuf))->MCS[1]) == 0;
+
+ ht->bdBandWidth = (enum ht_channel_width)
+ (((struct ht_capab_ele *)
+ (ht->bdHTCapBuf))->ChlWidth);
+ } else {
+ ht->bdSupportHT = false;
+ ht->bdHT1R = false;
+ ht->bdBandWidth = HT_CHANNEL_WIDTH_20;
+ }
+}
+
int rtllib_parse_info_param(struct rtllib_device *ieee,
struct rtllib_info_element *info_element,
u16 length,
@@ -1741,17 +2051,15 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
short offset;
u16 tmp_htcap_len = 0;
u16 tmp_htinfo_len = 0;
- u16 ht_realtek_agg_len = 0;
- u8 ht_realtek_agg_buf[MAX_IE_LEN];
char rates_str[64];
char *p;
while (length >= sizeof(*info_element)) {
if (sizeof(*info_element) + info_element->len > length) {
- RTLLIB_DEBUG_MGMT("Info elem: parse failed: info_element->len + 2 > left : info_element->len+2=%zd left=%d, id=%d.\n",
- info_element->len +
- sizeof(*info_element),
- length, info_element->id);
+ netdev_dbg(ieee->dev,
+ "Info elem: parse failed: info_element->len + 2 > left : info_element->len+2=%zd left=%d, id=%d.\n",
+ info_element->len + sizeof(*info_element),
+ length, info_element->id);
/* We stop processing but don't return an error here
* because some misbehaviour APs break this rule. ie.
* Orinoco AP1000.
@@ -1769,13 +2077,14 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
network->ssid_len = min(info_element->len,
(u8) IW_ESSID_MAX_SIZE);
- memcpy(network->ssid, info_element->data, network->ssid_len);
+ memcpy(network->ssid, info_element->data,
+ network->ssid_len);
if (network->ssid_len < IW_ESSID_MAX_SIZE)
memset(network->ssid + network->ssid_len, 0,
IW_ESSID_MAX_SIZE - network->ssid_len);
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_SSID: '%s' len=%d.\n",
- network->ssid, network->ssid_len);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_SSID: '%s' len=%d.\n",
+ network->ssid, network->ssid_len);
break;
case MFIE_TYPE_RATES:
@@ -1802,8 +2111,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
}
}
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES: '%s' (%d)\n",
- rates_str, network->rates_len);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_RATES: '%s' (%d)\n",
+ rates_str, network->rates_len);
break;
case MFIE_TYPE_RATES_EX:
@@ -1825,22 +2134,22 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
}
}
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_RATES_EX: '%s' (%d)\n",
- rates_str, network->rates_ex_len);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_RATES_EX: '%s' (%d)\n",
+ rates_str, network->rates_ex_len);
break;
case MFIE_TYPE_DS_SET:
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_DS_SET: %d\n",
- info_element->data[0]);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_DS_SET: %d\n",
+ info_element->data[0]);
network->channel = info_element->data[0];
break;
case MFIE_TYPE_FH_SET:
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_FH_SET: ignored\n");
+ netdev_dbg(ieee->dev, "MFIE_TYPE_FH_SET: ignored\n");
break;
case MFIE_TYPE_CF_SET:
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_CF_SET: ignored\n");
+ netdev_dbg(ieee->dev, "MFIE_TYPE_CF_SET: ignored\n");
break;
case MFIE_TYPE_TIM:
@@ -1879,217 +2188,31 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
case MFIE_TYPE_ERP:
network->erp_value = info_element->data[0];
network->flags |= NETWORK_HAS_ERP_VALUE;
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_ERP_SET: %d\n",
- network->erp_value);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_ERP_SET: %d\n",
+ network->erp_value);
break;
case MFIE_TYPE_IBSS_SET:
network->atim_window = info_element->data[0];
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_IBSS_SET: %d\n",
- network->atim_window);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_IBSS_SET: %d\n",
+ network->atim_window);
break;
case MFIE_TYPE_CHALLENGE:
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_CHALLENGE: ignored\n");
+ netdev_dbg(ieee->dev, "MFIE_TYPE_CHALLENGE: ignored\n");
break;
case MFIE_TYPE_GENERIC:
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_GENERIC: %d bytes\n",
- info_element->len);
- if (!rtllib_parse_qos_info_param_IE(info_element,
- network))
- break;
- if (info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x50 &&
- info_element->data[2] == 0xf2 &&
- info_element->data[3] == 0x01) {
- network->wpa_ie_len = min(info_element->len + 2,
- MAX_WPA_IE_LEN);
- memcpy(network->wpa_ie, info_element,
- network->wpa_ie_len);
- break;
- }
- if (info_element->len == 7 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0xe0 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x01 &&
- info_element->data[4] == 0x02)
- network->Turbo_Enable = 1;
-
- if (tmp_htcap_len == 0) {
- if (info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x90 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x033) {
-
- tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
- if (tmp_htcap_len != 0) {
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ?
- sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len;
- memcpy(network->bssht.bdHTCapBuf, info_element->data, network->bssht.bdHTCapLen);
- }
- }
- if (tmp_htcap_len != 0) {
- network->bssht.bdSupportHT = true;
- network->bssht.bdHT1R = ((((struct ht_capab_ele *)(network->bssht.bdHTCapBuf))->MCS[1]) == 0);
- } else {
- network->bssht.bdSupportHT = false;
- network->bssht.bdHT1R = false;
- }
- }
-
-
- if (tmp_htinfo_len == 0) {
- if (info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x90 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x034) {
- tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN);
- if (tmp_htinfo_len != 0) {
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- if (tmp_htinfo_len) {
- network->bssht.bdHTInfoLen = tmp_htinfo_len > sizeof(network->bssht.bdHTInfoBuf) ?
- sizeof(network->bssht.bdHTInfoBuf) : tmp_htinfo_len;
- memcpy(network->bssht.bdHTInfoBuf, info_element->data, network->bssht.bdHTInfoLen);
- }
+ netdev_dbg(ieee->dev, "MFIE_TYPE_GENERIC: %d bytes\n",
+ info_element->len);
- }
-
- }
- }
-
- if (ieee->aggregation) {
- if (network->bssht.bdSupportHT) {
- if (info_element->len >= 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0xe0 &&
- info_element->data[2] == 0x4c &&
- info_element->data[3] == 0x02) {
- ht_realtek_agg_len = min_t(u8, info_element->len, MAX_IE_LEN);
- memcpy(ht_realtek_agg_buf, info_element->data, info_element->len);
- }
- if (ht_realtek_agg_len >= 5) {
- network->realtek_cap_exit = true;
- network->bssht.bdRT2RTAggregation = true;
-
- if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & 0x02))
- network->bssht.bdRT2RTLongSlotTime = true;
-
- if ((ht_realtek_agg_buf[4] == 1) && (ht_realtek_agg_buf[5] & RT_HT_CAP_USE_92SE))
- network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_92SE;
- }
- }
- if (ht_realtek_agg_len >= 5) {
- if ((ht_realtek_agg_buf[5] & RT_HT_CAP_USE_SOFTAP))
- network->bssht.RT2RT_HT_Mode |= RT_HT_CAP_USE_SOFTAP;
- }
- }
-
- if ((info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x05 &&
- info_element->data[2] == 0xb5) ||
- (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x0a &&
- info_element->data[2] == 0xf7) ||
- (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x10 &&
- info_element->data[2] == 0x18)) {
- network->broadcom_cap_exist = true;
- }
- if (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x0c &&
- info_element->data[2] == 0x43)
- network->ralink_cap_exist = true;
- if ((info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x03 &&
- info_element->data[2] == 0x7f) ||
- (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x13 &&
- info_element->data[2] == 0x74))
- network->atheros_cap_exist = true;
-
- if ((info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x50 &&
- info_element->data[2] == 0x43))
- network->marvell_cap_exist = true;
- if (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 &&
- info_element->data[2] == 0x96)
- network->cisco_cap_exist = true;
-
-
- if (info_element->len >= 3 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x0a &&
- info_element->data[2] == 0xf5)
- network->airgo_cap_exist = true;
-
- if (info_element->len > 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 &&
- info_element->data[2] == 0x96 &&
- info_element->data[3] == 0x01) {
- if (info_element->len == 6) {
- memcpy(network->CcxRmState, &info_element[4], 2);
- if (network->CcxRmState[0] != 0)
- network->bCcxRmEnable = true;
- else
- network->bCcxRmEnable = false;
- network->MBssidMask = network->CcxRmState[1] & 0x07;
- if (network->MBssidMask != 0) {
- network->bMBssidValid = true;
- network->MBssidMask = 0xff << (network->MBssidMask);
- memcpy(network->MBssid, network->bssid, ETH_ALEN);
- network->MBssid[5] &= network->MBssidMask;
- } else {
- network->bMBssidValid = false;
- }
- } else {
- network->bCcxRmEnable = false;
- }
- }
- if (info_element->len > 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x40 &&
- info_element->data[2] == 0x96 &&
- info_element->data[3] == 0x03) {
- if (info_element->len == 5) {
- network->bWithCcxVerNum = true;
- network->BssCcxVerNumber = info_element->data[4];
- } else {
- network->bWithCcxVerNum = false;
- network->BssCcxVerNumber = 0;
- }
- }
- if (info_element->len > 4 &&
- info_element->data[0] == 0x00 &&
- info_element->data[1] == 0x50 &&
- info_element->data[2] == 0xf2 &&
- info_element->data[3] == 0x04) {
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_WZC: %d bytes\n",
- info_element->len);
- network->wzc_ie_len = min(info_element->len+2,
- MAX_WZC_IE_LEN);
- memcpy(network->wzc_ie, info_element,
- network->wzc_ie_len);
- }
+ rtllib_parse_mife_generic(ieee, info_element, network,
+ &tmp_htcap_len,
+ &tmp_htinfo_len);
break;
case MFIE_TYPE_RSN:
- RTLLIB_DEBUG_MGMT("MFIE_TYPE_RSN: %d bytes\n",
- info_element->len);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_RSN: %d bytes\n",
+ info_element->len);
network->rsn_ie_len = min(info_element->len + 2,
MAX_WPA_IE_LEN);
memcpy(network->rsn_ie, info_element,
@@ -2097,36 +2220,19 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
case MFIE_TYPE_HT_CAP:
- RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_CAP: %d bytes\n",
- info_element->len);
- tmp_htcap_len = min_t(u8, info_element->len, MAX_IE_LEN);
- if (tmp_htcap_len != 0) {
- network->bssht.bdHTSpecVer = HT_SPEC_VER_EWC;
- network->bssht.bdHTCapLen = tmp_htcap_len > sizeof(network->bssht.bdHTCapBuf) ?
- sizeof(network->bssht.bdHTCapBuf) : tmp_htcap_len;
- memcpy(network->bssht.bdHTCapBuf,
- info_element->data,
- network->bssht.bdHTCapLen);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_HT_CAP: %d bytes\n",
+ info_element->len);
- network->bssht.bdSupportHT = true;
- network->bssht.bdHT1R = ((((struct ht_capab_ele *)
- network->bssht.bdHTCapBuf))->MCS[1]) == 0;
-
- network->bssht.bdBandWidth = (enum ht_channel_width)
- (((struct ht_capab_ele *)
- (network->bssht.bdHTCapBuf))->ChlWidth);
- } else {
- network->bssht.bdSupportHT = false;
- network->bssht.bdHT1R = false;
- network->bssht.bdBandWidth = HT_CHANNEL_WIDTH_20;
- }
+ rtllib_parse_mfie_ht_cap(info_element, network,
+ &tmp_htcap_len);
break;
case MFIE_TYPE_HT_INFO:
- RTLLIB_DEBUG_SCAN("MFIE_TYPE_HT_INFO: %d bytes\n",
- info_element->len);
- tmp_htinfo_len = min_t(u8, info_element->len, MAX_IE_LEN);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_HT_INFO: %d bytes\n",
+ info_element->len);
+ tmp_htinfo_len = min_t(u8, info_element->len,
+ MAX_IE_LEN);
if (tmp_htinfo_len) {
network->bssht.bdHTSpecVer = HT_SPEC_VER_IEEE;
network->bssht.bdHTInfoLen = tmp_htinfo_len >
@@ -2140,8 +2246,8 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
case MFIE_TYPE_AIRONET:
- RTLLIB_DEBUG_SCAN("MFIE_TYPE_AIRONET: %d bytes\n",
- info_element->len);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_AIRONET: %d bytes\n",
+ info_element->len);
if (info_element->len > IE_CISCO_FLAG_POSITION) {
network->bWithAironetIE = true;
@@ -2163,17 +2269,17 @@ int rtllib_parse_info_param(struct rtllib_device *ieee,
break;
case MFIE_TYPE_COUNTRY:
- RTLLIB_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n",
- info_element->len);
+ netdev_dbg(ieee->dev, "MFIE_TYPE_COUNTRY: %d bytes\n",
+ info_element->len);
rtllib_extract_country_ie(ieee, info_element, network,
network->bssid);
break;
/* TODO */
default:
- RTLLIB_DEBUG_MGMT
- ("Unsupported info element: %s (%d)\n",
- get_info_element_string(info_element->id),
- info_element->id);
+ netdev_dbg(ieee->dev,
+ "Unsupported info element: %s (%d)\n",
+ get_info_element_string(info_element->id),
+ info_element->id);
break;
}
@@ -2211,7 +2317,7 @@ static inline int rtllib_network_init(
memset(&network->qos_data, 0, sizeof(struct rtllib_qos_data));
/* Pull out fixed field data */
- memcpy(network->bssid, beacon->header.addr3, ETH_ALEN);
+ ether_addr_copy(network->bssid, beacon->header.addr3);
network->capability = le16_to_cpu(beacon->capability);
network->last_scanned = jiffies;
network->time_stamp[0] = beacon->time_stamp[0];
@@ -2271,10 +2377,9 @@ static inline int rtllib_network_init(
}
if (network->mode == 0) {
- RTLLIB_DEBUG_SCAN("Filtered out '%s (%pM)' network.\n",
- escape_essid(network->ssid,
- network->ssid_len),
- network->bssid);
+ netdev_dbg(ieee->dev, "Filtered out '%s (%pM)' network.\n",
+ escape_essid(network->ssid, network->ssid_len),
+ network->bssid);
return 1;
}
@@ -2314,7 +2419,8 @@ static inline int is_same_network(struct rtllib_network *src,
}
-static inline void update_network(struct rtllib_network *dst,
+static inline void update_network(struct rtllib_device *ieee,
+ struct rtllib_network *dst,
struct rtllib_network *src)
{
int qos_active;
@@ -2388,12 +2494,12 @@ static inline void update_network(struct rtllib_network *dst,
sizeof(struct rtllib_qos_data));
if (dst->qos_data.supported == 1) {
if (dst->ssid_len)
- RTLLIB_DEBUG_QOS
- ("QoS the network %s is QoS supported\n",
- dst->ssid);
+ netdev_dbg(ieee->dev,
+ "QoS the network %s is QoS supported\n",
+ dst->ssid);
else
- RTLLIB_DEBUG_QOS
- ("QoS the network is QoS supported\n");
+ netdev_dbg(ieee->dev,
+ "QoS the network is QoS supported\n");
}
dst->qos_data.active = qos_active;
dst->qos_data.old_param_count = old_param;
@@ -2424,9 +2530,9 @@ static inline void update_network(struct rtllib_network *dst,
dst->BssCcxVerNumber = src->BssCcxVerNumber;
}
-static inline int is_beacon(__le16 fc)
+static inline int is_beacon(u16 fc)
{
- return (WLAN_FC_GET_STYPE(le16_to_cpu(fc)) == RTLLIB_STYPE_BEACON);
+ return (WLAN_FC_GET_STYPE(fc) == RTLLIB_STYPE_BEACON);
}
static int IsPassiveChannel(struct rtllib_device *rtllib, u8 channel)
@@ -2467,40 +2573,37 @@ static inline void rtllib_process_probe_response(
short renew;
struct rtllib_network *network = kzalloc(sizeof(struct rtllib_network),
GFP_ATOMIC);
+ u16 frame_ctl = le16_to_cpu(beacon->header.frame_ctl);
if (!network)
return;
- RTLLIB_DEBUG_SCAN(
- "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
- escape_essid(info_element->data, info_element->len),
- beacon->header.addr3,
- (le16_to_cpu(beacon->capability) & (1<<0xf)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0xe)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0xd)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0xc)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0xb)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0xa)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x9)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x8)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x7)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x6)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x5)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x4)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x3)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x2)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x1)) ? '1' : '0',
- (le16_to_cpu(beacon->capability) & (1<<0x0)) ? '1' : '0');
+ netdev_dbg(ieee->dev,
+ "'%s' ( %pM ): %c%c%c%c %c%c%c%c-%c%c%c%c %c%c%c%c\n",
+ escape_essid(info_element->data, info_element->len),
+ beacon->header.addr3,
+ (le16_to_cpu(beacon->capability) & (1<<0xf)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0xe)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0xd)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0xc)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0xb)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0xa)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x9)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x8)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x7)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x6)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x5)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x4)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x3)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x2)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x1)) ? '1' : '0',
+ (le16_to_cpu(beacon->capability) & (1<<0x0)) ? '1' : '0');
if (rtllib_network_init(ieee, beacon, network, stats)) {
- RTLLIB_DEBUG_SCAN("Dropped '%s' ( %pM) via %s.\n",
- escape_essid(info_element->data,
- info_element->len),
- beacon->header.addr3,
- WLAN_FC_GET_STYPE(
- le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
+ netdev_dbg(ieee->dev, "Dropped '%s' ( %pM) via %s.\n",
+ escape_essid(info_element->data, info_element->len),
+ beacon->header.addr3,
+ is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
goto free_network;
}
@@ -2508,8 +2611,7 @@ static inline void rtllib_process_probe_response(
if (!rtllib_legal_channel(ieee, network->channel))
goto free_network;
- if (WLAN_FC_GET_STYPE(le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP) {
+ if (WLAN_FC_GET_STYPE(frame_ctl) == RTLLIB_STYPE_PROBE_RESP) {
if (IsPassiveChannel(ieee, network->channel)) {
netdev_info(ieee->dev,
"GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n",
@@ -2533,7 +2635,7 @@ static inline void rtllib_process_probe_response(
spin_lock_irqsave(&ieee->lock, flags);
if (is_same_network(&ieee->current_network, network,
(network->ssid_len ? 1 : 0))) {
- update_network(&ieee->current_network, network);
+ update_network(ieee, &ieee->current_network, network);
if ((ieee->current_network.mode == IEEE_N_24G ||
ieee->current_network.mode == IEEE_G)
&& ieee->current_network.berp_info_valid) {
@@ -2542,7 +2644,7 @@ static inline void rtllib_process_probe_response(
else
ieee->current_network.buseprotection = false;
}
- if (is_beacon(beacon->header.frame_ctl)) {
+ if (is_beacon(frame_ctl)) {
if (ieee->state >= RTLLIB_LINKED)
ieee->LinkDetectInfo.NumRecvBcnInPeriod++;
}
@@ -2564,10 +2666,10 @@ static inline void rtllib_process_probe_response(
/* If there are no more slots, expire the oldest */
list_del(&oldest->list);
target = oldest;
- RTLLIB_DEBUG_SCAN("Expired '%s' ( %pM) from network list.\n",
- escape_essid(target->ssid,
- target->ssid_len),
- target->bssid);
+ netdev_dbg(ieee->dev,
+ "Expired '%s' ( %pM) from network list.\n",
+ escape_essid(target->ssid, target->ssid_len),
+ target->bssid);
} else {
/* Otherwise just pull from the free list */
target = list_entry(ieee->network_free_list.next,
@@ -2575,26 +2677,20 @@ static inline void rtllib_process_probe_response(
list_del(ieee->network_free_list.next);
}
+ netdev_dbg(ieee->dev, "Adding '%s' ( %pM) via %s.\n",
+ escape_essid(network->ssid, network->ssid_len),
+ network->bssid,
+ is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
- RTLLIB_DEBUG_SCAN("Adding '%s' ( %pM) via %s.\n",
- escape_essid(network->ssid,
- network->ssid_len), network->bssid,
- WLAN_FC_GET_STYPE(
- le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
memcpy(target, network, sizeof(*target));
list_add_tail(&target->list, &ieee->network_list);
if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE)
rtllib_softmac_new_net(ieee, network);
} else {
- RTLLIB_DEBUG_SCAN("Updating '%s' ( %pM) via %s.\n",
- escape_essid(target->ssid,
- target->ssid_len), target->bssid,
- WLAN_FC_GET_STYPE(
- le16_to_cpu(beacon->header.frame_ctl)) ==
- RTLLIB_STYPE_PROBE_RESP ?
- "PROBE RESPONSE" : "BEACON");
+ netdev_dbg(ieee->dev, "Updating '%s' ( %pM) via %s.\n",
+ escape_essid(target->ssid, target->ssid_len),
+ target->bssid,
+ is_beacon(frame_ctl) ? "BEACON" : "PROBE RESPONSE");
/* we have an entry and we are going to update it. But this
* entry may be already expired. In this case we do the same
@@ -2609,13 +2705,13 @@ static inline void rtllib_process_probe_response(
network->ssid_len) == 0) &&
(ieee->state == RTLLIB_NOLINK))))
renew = 1;
- update_network(target, network);
+ update_network(ieee, target, network);
if (renew && (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE))
rtllib_softmac_new_net(ieee, network);
}
spin_unlock_irqrestore(&ieee->lock, flags);
- if (is_beacon(beacon->header.frame_ctl) &&
+ if (is_beacon(frame_ctl) &&
is_same_network(&ieee->current_network, network,
(network->ssid_len ? 1 : 0)) &&
(ieee->state == RTLLIB_LINKED)) {
@@ -2642,9 +2738,8 @@ void rtllib_rx_mgt(struct rtllib_device *ieee,
switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl))) {
case RTLLIB_STYPE_BEACON:
- RTLLIB_DEBUG_MGMT("received BEACON (%d)\n",
- WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
- RTLLIB_DEBUG_SCAN("Beacon\n");
+ netdev_dbg(ieee->dev, "received BEACON (%d)\n",
+ WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
rtllib_process_probe_response(
ieee, (struct rtllib_probe_response *)header,
stats);
@@ -2657,17 +2752,14 @@ void rtllib_rx_mgt(struct rtllib_device *ieee,
break;
case RTLLIB_STYPE_PROBE_RESP:
- RTLLIB_DEBUG_MGMT("received PROBE RESPONSE (%d)\n",
- WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
- RTLLIB_DEBUG_SCAN("Probe response\n");
+ netdev_dbg(ieee->dev, "received PROBE RESPONSE (%d)\n",
+ WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
rtllib_process_probe_response(ieee,
(struct rtllib_probe_response *)header, stats);
break;
case RTLLIB_STYPE_PROBE_REQ:
- RTLLIB_DEBUG_MGMT("received PROBE RESQUEST (%d)\n",
- WLAN_FC_GET_STYPE(
- le16_to_cpu(header->frame_ctl)));
- RTLLIB_DEBUG_SCAN("Probe request\n");
+ netdev_dbg(ieee->dev, "received PROBE RESQUEST (%d)\n",
+ WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)));
if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) &&
((ieee->iw_mode == IW_MODE_ADHOC ||
ieee->iw_mode == IW_MODE_MASTER) &&
diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c
index 23b7a4c3b6993a..9dce121d660e01 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac.c
@@ -20,6 +20,7 @@
#include <linux/delay.h>
#include <linux/uaccess.h>
#include <linux/etherdevice.h>
+#include <linux/ieee80211.h>
#include "dot11d.h"
short rtllib_is_54g(struct rtllib_network *net)
@@ -271,9 +272,10 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee)
ieee->seq_ctrl[0]++;
/* check whether the managed packet queued greater than 5 */
- if (!ieee->check_nic_enough_desc(ieee->dev, tcb_desc->queue_index) ||
- (skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) != 0) ||
- (ieee->queue_stop)) {
+ if (!ieee->check_nic_enough_desc(ieee->dev,
+ tcb_desc->queue_index) ||
+ skb_queue_len(&ieee->skb_waitQ[tcb_desc->queue_index]) ||
+ ieee->queue_stop) {
/* insert the skb packet to the management queue
*
* as for the completion function, it does not need
@@ -371,7 +373,7 @@ static inline struct sk_buff *rtllib_probe_req(struct rtllib_device *ieee)
req->header.duration_id = 0;
memset(req->header.addr1, 0xff, ETH_ALEN);
- memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ ether_addr_copy(req->header.addr2, ieee->dev->dev_addr);
memset(req->header.addr3, 0xff, ETH_ALEN);
tag = (u8 *) skb_put(skb, len + 2 + rate_len);
@@ -814,9 +816,9 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon,
auth->header.frame_ctl |= cpu_to_le16(RTLLIB_FCTL_WEP);
auth->header.duration_id = cpu_to_le16(0x013a);
- memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN);
- memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(auth->header.addr3, beacon->bssid, ETH_ALEN);
+ ether_addr_copy(auth->header.addr1, beacon->bssid);
+ ether_addr_copy(auth->header.addr2, ieee->dev->dev_addr);
+ ether_addr_copy(auth->header.addr3, beacon->bssid);
if (ieee->auth_mode == 0)
auth->algorithm = WLAN_AUTH_OPEN;
else if (ieee->auth_mode == 1)
@@ -831,7 +833,8 @@ inline struct sk_buff *rtllib_authentication_req(struct rtllib_network *beacon,
return skb;
}
-static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
+static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee,
+ const u8 *dest)
{
u8 *tag;
int beacon_size;
@@ -907,9 +910,9 @@ static struct sk_buff *rtllib_probe_resp(struct rtllib_device *ieee, u8 *dest)
beacon_buf = (struct rtllib_probe_response *) skb_put(skb,
(beacon_size - ieee->tx_headroom));
- memcpy(beacon_buf->header.addr1, dest, ETH_ALEN);
- memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN);
+ ether_addr_copy(beacon_buf->header.addr1, dest);
+ ether_addr_copy(beacon_buf->header.addr2, ieee->dev->dev_addr);
+ ether_addr_copy(beacon_buf->header.addr3, ieee->current_network.bssid);
beacon_buf->header.duration_id = 0;
beacon_buf->beacon_interval =
@@ -1004,9 +1007,9 @@ static struct sk_buff *rtllib_assoc_resp(struct rtllib_device *ieee, u8 *dest)
skb_put(skb, sizeof(struct rtllib_assoc_response_frame));
assoc->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_ASSOC_RESP);
- memcpy(assoc->header.addr1, dest, ETH_ALEN);
- memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
+ ether_addr_copy(assoc->header.addr1, dest);
+ ether_addr_copy(assoc->header.addr3, ieee->dev->dev_addr);
+ ether_addr_copy(assoc->header.addr2, ieee->dev->dev_addr);
assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ?
WLAN_CAPABILITY_ESS : WLAN_CAPABILITY_IBSS);
@@ -1061,9 +1064,9 @@ static struct sk_buff *rtllib_auth_resp(struct rtllib_device *ieee, int status,
auth->transaction = cpu_to_le16(2);
auth->algorithm = cpu_to_le16(WLAN_AUTH_OPEN);
- memcpy(auth->header.addr3, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(auth->header.addr1, dest, ETH_ALEN);
+ ether_addr_copy(auth->header.addr3, ieee->dev->dev_addr);
+ ether_addr_copy(auth->header.addr2, ieee->dev->dev_addr);
+ ether_addr_copy(auth->header.addr1, dest);
auth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_AUTH);
return skb;
@@ -1084,9 +1087,9 @@ static struct sk_buff *rtllib_null_func(struct rtllib_device *ieee, short pwr)
hdr = (struct rtllib_hdr_3addr *)skb_put(skb,
sizeof(struct rtllib_hdr_3addr));
- memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
- memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(hdr->addr3, ieee->current_network.bssid, ETH_ALEN);
+ ether_addr_copy(hdr->addr1, ieee->current_network.bssid);
+ ether_addr_copy(hdr->addr2, ieee->dev->dev_addr);
+ ether_addr_copy(hdr->addr3, ieee->current_network.bssid);
hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_DATA |
RTLLIB_STYPE_NULLFUNC | RTLLIB_FCTL_TODS |
@@ -1111,8 +1114,8 @@ static struct sk_buff *rtllib_pspoll_func(struct rtllib_device *ieee)
hdr = (struct rtllib_pspoll_hdr *)skb_put(skb,
sizeof(struct rtllib_pspoll_hdr));
- memcpy(hdr->bssid, ieee->current_network.bssid, ETH_ALEN);
- memcpy(hdr->ta, ieee->dev->dev_addr, ETH_ALEN);
+ ether_addr_copy(hdr->bssid, ieee->current_network.bssid);
+ ether_addr_copy(hdr->ta, ieee->dev->dev_addr);
hdr->aid = cpu_to_le16(ieee->assoc_id | 0xc000);
hdr->frame_ctl = cpu_to_le16(RTLLIB_FTYPE_CTL | RTLLIB_STYPE_PSPOLL |
@@ -1264,11 +1267,11 @@ inline struct sk_buff *rtllib_association_req(struct rtllib_network *beacon,
hdr->header.frame_ctl = RTLLIB_STYPE_ASSOC_REQ;
hdr->header.duration_id = cpu_to_le16(37);
- memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN);
- memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN);
+ ether_addr_copy(hdr->header.addr1, beacon->bssid);
+ ether_addr_copy(hdr->header.addr2, ieee->dev->dev_addr);
+ ether_addr_copy(hdr->header.addr3, beacon->bssid);
- memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN);
+ ether_addr_copy(ieee->ap_mac_addr, beacon->bssid);
hdr->capability = cpu_to_le16(WLAN_CAPABILITY_ESS);
if (beacon->capability & WLAN_CAPABILITY_PRIVACY)
@@ -1437,10 +1440,10 @@ void rtllib_associate_abort(struct rtllib_device *ieee)
* with, so we retry or just get back to NO_LINK and scanning
*/
if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING) {
- RTLLIB_DEBUG_MGMT("Authentication failed\n");
+ netdev_dbg(ieee->dev, "Authentication failed\n");
ieee->softmac_stats.no_auth_rs++;
} else {
- RTLLIB_DEBUG_MGMT("Association failed\n");
+ netdev_dbg(ieee->dev, "Association failed\n");
ieee->softmac_stats.no_ass_rs++;
}
@@ -1462,7 +1465,7 @@ static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr)
struct rtllib_network *beacon = &ieee->current_network;
struct sk_buff *skb;
- RTLLIB_DEBUG_MGMT("Stopping scan\n");
+ netdev_dbg(ieee->dev, "Stopping scan\n");
ieee->softmac_stats.tx_auth_rq++;
@@ -1472,7 +1475,7 @@ static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr)
rtllib_associate_abort(ieee);
else {
ieee->state = RTLLIB_ASSOCIATING_AUTHENTICATING;
- RTLLIB_DEBUG_MGMT("Sending authentication request\n");
+ netdev_dbg(ieee->dev, "Sending authentication request\n");
softmac_mgmt_xmit(skb, ieee);
if (!timer_pending(&ieee->associate_timer)) {
ieee->associate_timer.expires = jiffies + (HZ / 2);
@@ -1481,7 +1484,8 @@ static void rtllib_associate_step1(struct rtllib_device *ieee, u8 *daddr)
}
}
-static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int chlen)
+static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge,
+ int chlen)
{
u8 *c;
struct sk_buff *skb;
@@ -1500,7 +1504,8 @@ static void rtllib_auth_challenge(struct rtllib_device *ieee, u8 *challenge, int
*(c++) = chlen;
memcpy(c, challenge, chlen);
- RTLLIB_DEBUG_MGMT("Sending authentication challenge response\n");
+ netdev_dbg(ieee->dev,
+ "Sending authentication challenge response\n");
rtllib_encrypt_fragment(ieee, skb,
sizeof(struct rtllib_hdr_3addr));
@@ -1518,7 +1523,7 @@ static void rtllib_associate_step2(struct rtllib_device *ieee)
del_timer_sync(&ieee->associate_timer);
- RTLLIB_DEBUG_MGMT("Sending association request\n");
+ netdev_dbg(ieee->dev, "Sending association request\n");
ieee->softmac_stats.tx_ass_rq++;
skb = rtllib_association_req(beacon, ieee);
@@ -1737,7 +1742,7 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
/* Join the network for the first time */
ieee->AsocRetryCount = 0;
if ((ieee->current_network.qos_data.supported == 1) &&
- ieee->current_network.bssht.bdSupportHT)
+ ieee->current_network.bssht.bdSupportHT)
HTResetSelfAndSavePeerSetting(ieee,
&(ieee->current_network));
else
@@ -1752,14 +1757,19 @@ inline void rtllib_softmac_new_net(struct rtllib_device *ieee,
&ieee->associate_procedure_wq, 0);
} else {
if (rtllib_is_54g(&ieee->current_network) &&
- (ieee->modulation & RTLLIB_OFDM_MODULATION)) {
+ (ieee->modulation &
+ RTLLIB_OFDM_MODULATION)) {
ieee->rate = 108;
- ieee->SetWirelessMode(ieee->dev, IEEE_G);
- netdev_info(ieee->dev, "Using G rates\n");
+ ieee->SetWirelessMode(ieee->dev,
+ IEEE_G);
+ netdev_info(ieee->dev,
+ "Using G rates\n");
} else {
ieee->rate = 22;
- ieee->SetWirelessMode(ieee->dev, IEEE_B);
- netdev_info(ieee->dev, "Using B rates\n");
+ ieee->SetWirelessMode(ieee->dev,
+ IEEE_B);
+ netdev_info(ieee->dev,
+ "Using B rates\n");
}
memset(ieee->dot11HTOperationalRateSet, 0, 16);
ieee->state = RTLLIB_LINKED;
@@ -1791,14 +1801,15 @@ void rtllib_softmac_check_all_nets(struct rtllib_device *ieee)
spin_unlock_irqrestore(&ieee->lock, flags);
}
-static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
+static inline u16 auth_parse(struct net_device *dev, struct sk_buff *skb,
+ u8 **challenge, int *chlen)
{
struct rtllib_authentication *a;
u8 *t;
if (skb->len < (sizeof(struct rtllib_authentication) -
sizeof(struct rtllib_info_element))) {
- RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
+ netdev_dbg(dev, "invalid len in auth resp: %d\n", skb->len);
return 0xcafe;
}
*challenge = NULL;
@@ -1813,22 +1824,21 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen)
return -ENOMEM;
}
}
- return cpu_to_le16(a->status);
+ return le16_to_cpu(a->status);
}
-static int auth_rq_parse(struct sk_buff *skb, u8 *dest)
+static int auth_rq_parse(struct net_device *dev, struct sk_buff *skb, u8 *dest)
{
struct rtllib_authentication *a;
if (skb->len < (sizeof(struct rtllib_authentication) -
sizeof(struct rtllib_info_element))) {
- RTLLIB_DEBUG_MGMT("invalid len in auth request: %d\n",
- skb->len);
+ netdev_dbg(dev, "invalid len in auth request: %d\n", skb->len);
return -1;
}
a = (struct rtllib_authentication *) skb->data;
- memcpy(dest, a->header.addr2, ETH_ALEN);
+ ether_addr_copy(dest, a->header.addr2);
if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN)
return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG;
@@ -1851,12 +1861,12 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb,
return -1; /* corrupted */
bssid_match =
- (memcmp(header->addr3, ieee->current_network.bssid, ETH_ALEN) != 0) &&
+ (!ether_addr_equal(header->addr3, ieee->current_network.bssid)) &&
(!is_broadcast_ether_addr(header->addr3));
if (bssid_match)
return -1;
- memcpy(src, header->addr2, ETH_ALEN);
+ ether_addr_copy(src, header->addr2);
skbend = (u8 *)skb->data + skb->len;
@@ -1882,20 +1892,19 @@ static short probe_rq_parse(struct rtllib_device *ieee, struct sk_buff *skb,
return !strncmp(ssid, ieee->current_network.ssid, ssidlen);
}
-static int assoc_rq_parse(struct sk_buff *skb, u8 *dest)
+static int assoc_rq_parse(struct net_device *dev, struct sk_buff *skb, u8 *dest)
{
struct rtllib_assoc_request_frame *a;
if (skb->len < (sizeof(struct rtllib_assoc_request_frame) -
sizeof(struct rtllib_info_element))) {
-
- RTLLIB_DEBUG_MGMT("invalid len in auth request:%d\n", skb->len);
+ netdev_dbg(dev, "invalid len in auth request:%d\n", skb->len);
return -1;
}
a = (struct rtllib_assoc_request_frame *) skb->data;
- memcpy(dest, a->header.addr2, ETH_ALEN);
+ ether_addr_copy(dest, a->header.addr2);
return 0;
}
@@ -1907,7 +1916,8 @@ static inline u16 assoc_parse(struct rtllib_device *ieee, struct sk_buff *skb,
u16 status_code;
if (skb->len < sizeof(struct rtllib_assoc_response_frame)) {
- RTLLIB_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len);
+ netdev_dbg(ieee->dev, "Invalid len in auth resp: %d\n",
+ skb->len);
return 0xcafe;
}
@@ -1947,7 +1957,7 @@ static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee,
ieee->softmac_stats.rx_auth_rq++;
- status = auth_rq_parse(skb, dest);
+ status = auth_rq_parse(ieee->dev, skb, dest);
if (status != -1)
rtllib_resp_to_auth(ieee, status, dest);
}
@@ -1955,11 +1965,11 @@ static inline void rtllib_rx_auth_rq(struct rtllib_device *ieee,
static inline void rtllib_rx_assoc_rq(struct rtllib_device *ieee,
struct sk_buff *skb)
{
-
u8 dest[ETH_ALEN];
+
ieee->softmac_stats.rx_ass_rq++;
- if (assoc_rq_parse(skb, dest) != -1)
+ if (assoc_rq_parse(ieee->dev, skb, dest) != -1)
rtllib_resp_to_assoc_rq(ieee, dest);
netdev_info(ieee->dev, "New client associated: %pM\n", dest);
@@ -2020,7 +2030,7 @@ static short rtllib_sta_ps_sleep(struct rtllib_device *ieee, u64 *time)
if (ieee->bAwakePktSent) {
pPSC->LPSAwakeIntvl = 1;
} else {
- u8 MaxPeriod = 1;
+ u8 MaxPeriod = 1;
if (pPSC->LPSAwakeIntvl == 0)
pPSC->LPSAwakeIntvl = 1;
@@ -2191,15 +2201,16 @@ void rtllib_ps_tx_ack(struct rtllib_device *ieee, short success)
}
EXPORT_SYMBOL(rtllib_ps_tx_ack);
-static void rtllib_process_action(struct rtllib_device *ieee, struct sk_buff *skb)
+static void rtllib_process_action(struct rtllib_device *ieee,
+ struct sk_buff *skb)
{
struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data;
u8 *act = rtllib_get_payload((struct rtllib_hdr *)header);
u8 category = 0;
if (act == NULL) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "error to get payload of action frame\n");
+ netdev_warn(ieee->dev,
+ "Error getting payload of action frame\n");
return;
}
@@ -2233,8 +2244,8 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
struct rtllib_assoc_response_frame *assoc_resp;
struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *) skb->data;
- RTLLIB_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n",
- WLAN_FC_GET_STYPE(header->frame_ctl));
+ netdev_dbg(ieee->dev, "received [RE]ASSOCIATION RESPONSE (%d)\n",
+ WLAN_FC_GET_STYPE(header->frame_ctl));
if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) &&
ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATED &&
@@ -2295,9 +2306,6 @@ inline int rtllib_rx_assoc_resp(struct rtllib_device *ieee, struct sk_buff *skb,
netdev_info(ieee->dev,
"Association response status code 0x%x\n",
errcode);
- RTLLIB_DEBUG_MGMT(
- "Association response status code 0x%x\n",
- errcode);
if (ieee->AsocRetryCount < RT_ASOC_RETRY_LIMIT)
queue_delayed_work_rsl(ieee->wq,
&ieee->associate_procedure_wq, 0);
@@ -2315,13 +2323,10 @@ static void rtllib_rx_auth_resp(struct rtllib_device *ieee, struct sk_buff *skb)
int chlen = 0;
bool bSupportNmode = true, bHalfSupportNmode = false;
- errcode = auth_parse(skb, &challenge, &chlen);
+ errcode = auth_parse(ieee->dev, skb, &challenge, &chlen);
if (errcode) {
ieee->softmac_stats.rx_auth_rs_err++;
- RTLLIB_DEBUG_MGMT("Authentication respose status code 0x%x",
- errcode);
-
netdev_info(ieee->dev,
"Authentication respose status code 0x%x", errcode);
rtllib_associate_abort(ieee);
@@ -2371,7 +2376,8 @@ inline int rtllib_rx_auth(struct rtllib_device *ieee, struct sk_buff *skb,
if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) {
if (ieee->state == RTLLIB_ASSOCIATING_AUTHENTICATING &&
(ieee->iw_mode == IW_MODE_INFRA)) {
- RTLLIB_DEBUG_MGMT("Received authentication response");
+ netdev_dbg(ieee->dev,
+ "Received authentication response");
rtllib_rx_auth_resp(ieee, skb);
} else if (ieee->iw_mode == IW_MODE_MASTER) {
rtllib_rx_auth_rq(ieee, skb);
@@ -2650,7 +2656,7 @@ void rtllib_start_master_bss(struct rtllib_device *ieee)
ieee->ssid_set = 1;
}
- memcpy(ieee->current_network.bssid, ieee->dev->dev_addr, ETH_ALEN);
+ ether_addr_copy(ieee->current_network.bssid, ieee->dev->dev_addr);
ieee->set_chan(ieee->dev, ieee->current_network.channel);
ieee->state = RTLLIB_LINKED;
@@ -2910,7 +2916,7 @@ exit:
struct sk_buff *rtllib_get_beacon_(struct rtllib_device *ieee)
{
- u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+ const u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
struct sk_buff *skb;
struct rtllib_probe_response *b;
@@ -2983,7 +2989,7 @@ void rtllib_stop_protocol(struct rtllib_device *ieee, u8 shutdown)
if (ieee->state == RTLLIB_LINKED) {
if (ieee->iw_mode == IW_MODE_INFRA)
- SendDisassociation(ieee, 1, deauth_lv_ss);
+ SendDisassociation(ieee, 1, WLAN_REASON_DEAUTH_LEAVING);
rtllib_disassociate(ieee);
}
@@ -3072,7 +3078,7 @@ void rtllib_softmac_init(struct rtllib_device *ieee)
ieee->seq_ctrl[i] = 0;
ieee->pDot11dInfo = kzalloc(sizeof(struct rt_dot11d_info), GFP_ATOMIC);
if (!ieee->pDot11dInfo)
- RTLLIB_DEBUG(RTLLIB_DL_ERR, "can't alloc memory for DOT11D\n");
+ netdev_err(ieee->dev, "Can't alloc memory for DOT11D\n");
ieee->LinkDetectInfo.SlotIndex = 0;
ieee->LinkDetectInfo.SlotNum = 2;
ieee->LinkDetectInfo.NumRecvBcnInPeriod = 0;
@@ -3517,9 +3523,9 @@ inline struct sk_buff *rtllib_disauth_skb(struct rtllib_network *beacon,
disauth->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DEAUTH);
disauth->header.duration_id = 0;
- memcpy(disauth->header.addr1, beacon->bssid, ETH_ALEN);
- memcpy(disauth->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(disauth->header.addr3, beacon->bssid, ETH_ALEN);
+ ether_addr_copy(disauth->header.addr1, beacon->bssid);
+ ether_addr_copy(disauth->header.addr2, ieee->dev->dev_addr);
+ ether_addr_copy(disauth->header.addr3, beacon->bssid);
disauth->reason = cpu_to_le16(asRsn);
return skb;
@@ -3544,9 +3550,9 @@ inline struct sk_buff *rtllib_disassociate_skb(struct rtllib_network *beacon,
disass->header.frame_ctl = cpu_to_le16(RTLLIB_STYPE_DISASSOC);
disass->header.duration_id = 0;
- memcpy(disass->header.addr1, beacon->bssid, ETH_ALEN);
- memcpy(disass->header.addr2, ieee->dev->dev_addr, ETH_ALEN);
- memcpy(disass->header.addr3, beacon->bssid, ETH_ALEN);
+ ether_addr_copy(disass->header.addr1, beacon->bssid);
+ ether_addr_copy(disass->header.addr2, ieee->dev->dev_addr);
+ ether_addr_copy(disass->header.addr3, beacon->bssid);
disass->reason = cpu_to_le16(asRsn);
return skb;
@@ -3676,8 +3682,8 @@ static void rtllib_MgntDisconnectIBSS(struct rtllib_device *rtllib)
}
-static void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib, u8 *asSta,
- u8 asRsn)
+static void rtllib_MlmeDisassociateRequest(struct rtllib_device *rtllib,
+ u8 *asSta, u8 asRsn)
{
u8 i;
u8 OpMode;
diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
index 9715a793fd3735..86f52ac7d33eda 100644
--- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c
@@ -160,7 +160,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee,
if (is_zero_ether_addr(temp->sa_data)) {
spin_lock_irqsave(&ieee->lock, flags);
- memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
+ ether_addr_copy(ieee->current_network.bssid, temp->sa_data);
ieee->wap_set = 0;
spin_unlock_irqrestore(&ieee->lock, flags);
ret = -1;
@@ -177,7 +177,7 @@ int rtllib_wx_set_wap(struct rtllib_device *ieee,
spin_lock_irqsave(&ieee->lock, flags);
ieee->cannot_notify = false;
- memcpy(ieee->current_network.bssid, temp->sa_data, ETH_ALEN);
+ ether_addr_copy(ieee->current_network.bssid, temp->sa_data);
ieee->wap_set = !is_zero_ether_addr(temp->sa_data);
spin_unlock_irqrestore(&ieee->lock, flags);
@@ -454,13 +454,7 @@ int rtllib_wx_set_essid(struct rtllib_device *ieee,
proto_started = ieee->proto_started;
- len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length :
- IW_ESSID_MAX_SIZE;
-
- if (len > IW_ESSID_MAX_SIZE) {
- ret = -E2BIG;
- goto out;
- }
+ len = min_t(__u16, wrqu->essid.length, IW_ESSID_MAX_SIZE);
if (ieee->iw_mode == IW_MODE_MONITOR) {
ret = -1;
@@ -575,9 +569,9 @@ int rtllib_wx_set_power(struct rtllib_device *ieee,
if ((!ieee->sta_wake_up) ||
(!ieee->enter_sleep_state) ||
(!ieee->ps_is_queue_empty)) {
- RTLLIB_DEBUG(RTLLIB_DL_ERR,
- "%s(): PS mode is tried to be use but driver missed a callback\n\n",
- __func__);
+ netdev_warn(ieee->dev,
+ "%s(): PS mode is tried to be use but driver missed a callback\n",
+ __func__);
return -1;
}
diff --git a/drivers/staging/rtl8192e/rtllib_tx.c b/drivers/staging/rtl8192e/rtllib_tx.c
index 3b159638bba2ad..e99ea5e67ef98c 100644
--- a/drivers/staging/rtl8192e/rtllib_tx.c
+++ b/drivers/staging/rtl8192e/rtllib_tx.c
@@ -57,18 +57,19 @@
*
*
* 802.11 frame_control for data frames - 2 bytes
- * ,-----------------------------------------------------------------------------------------.
- * bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e |
- * |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
- * val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x |
- * |----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|-----|------|
- * desc | ^-ver-^ | ^type-^ | ^-----subtype-----^ | to |from |more |retry| pwr |more |wep |
- * | | | x=0 data,x=1 data+ack | DS | DS |frag | | mgm |data | |
- * '-----------------------------------------------------------------------------------------'
- * /\
- * |
- * 802.11 Data Frame |
- * ,--------- 'ctrl' expands to >-----------'
+ * ,--------------------------------------------------------------------.
+ * bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e |
+ * |---|---|---|---|---|---|---|---|---|----|----|-----|-----|-----|----|
+ * val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x |
+ * |---|---|---|---|---|---|---|---|---|----|----|-----|-----|-----|----|
+ * desc | ver | type | ^-subtype-^ |to |from|more|retry| pwr |more |wep |
+ * | | | x=0 data |DS | DS |frag| | mgm |data | |
+ * | | | x=1 data+ack | | | | | | | |
+ * '--------------------------------------------------------------------'
+ * /\
+ * |
+ * 802.11 Data Frame |
+ * ,--------- 'ctrl' expands to >---'
* |
* ,--'---,-------------------------------------------------------------.
* Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 |
@@ -112,15 +113,15 @@
* `-----------------------------------------'
* Total: 18 non-data bytes
*
- * In the event that fragmentation is required, the incoming payload is split into
- * N parts of size ieee->fts. The first fragment contains the SNAP header and the
- * remaining packets are just data.
+ * In the event that fragmentation is required, the incoming payload is split
+ * into N parts of size ieee->fts. The first fragment contains the SNAP header
+ * and the remaining packets are just data.
*
- * If encryption is enabled, each fragment payload size is reduced by enough space
- * to add the prefix and postfix (IV and ICV totalling 8 bytes in the case of WEP)
- * So if you have 1500 bytes of payload with ieee->fts set to 500 without
- * encryption it will take 3 frames. With WEP it will take 4 frames as the
- * payload of each frame is reduced to 492 bytes.
+ * If encryption is enabled, each fragment payload size is reduced by enough
+ * space to add the prefix and postfix (IV and ICV totalling 8 bytes in
+ * the case of WEP) So if you have 1500 bytes of payload with ieee->fts set to
+ * 500 without encryption it will take 3 frames. With WEP it will take 4 frames
+ * as the payload of each frame is reduced to 492 bytes.
*
* SKB visualization
*
@@ -260,7 +261,10 @@ static int rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu)
if (eth->h_proto != htons(ETH_P_IP))
return 0;
- RTLLIB_DEBUG_DATA(RTLLIB_DL_DATA, skb->data, skb->len);
+#ifdef VERBOSE_DEBUG
+ print_hex_dump_bytes("rtllib_classify(): ", DUMP_PREFIX_NONE, skb->data,
+ skb->len);
+#endif
ip = ip_hdr(skb);
switch (ip->tos & 0xfc) {
case 0x20:
@@ -579,8 +583,9 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
.seq_ctl = 0,
.qos_ctl = 0
};
- u8 dest[ETH_ALEN], src[ETH_ALEN];
int qos_actived = ieee->current_network.qos_data.active;
+ u8 dest[ETH_ALEN];
+ u8 src[ETH_ALEN];
struct lib80211_crypt_data *crypt = NULL;
struct cb_desc *tcb_desc;
u8 bIsMulticast = false;
@@ -608,8 +613,8 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
goto success;
}
/* Save source and destination addresses */
- memcpy(dest, skb->data, ETH_ALEN);
- memcpy(src, skb->data+ETH_ALEN, ETH_ALEN);
+ ether_addr_copy(dest, skb->data);
+ ether_addr_copy(src, skb->data + ETH_ALEN);
memset(skb->cb, 0, sizeof(skb->cb));
ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto);
@@ -669,8 +674,9 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
struct eapol *eap = (struct eapol *)(skb->data +
sizeof(struct ethhdr) - SNAP_SIZE -
sizeof(u16));
- RTLLIB_DEBUG_EAP("TX: IEEE 802.11 EAPOL frame: %s\n",
- eap_get_type(eap->type));
+ netdev_dbg(ieee->dev,
+ "TX: IEEE 802.11 EAPOL frame: %s\n",
+ eap_get_type(eap->type));
}
/* Advance the SKB to the start of the payload */
@@ -694,22 +700,22 @@ int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev)
/* To DS: Addr1 = BSSID, Addr2 = SA,
* Addr3 = DA
*/
- memcpy(&header.addr1, ieee->current_network.bssid,
- ETH_ALEN);
- memcpy(&header.addr2, &src, ETH_ALEN);
+ ether_addr_copy(header.addr1,
+ ieee->current_network.bssid);
+ ether_addr_copy(header.addr2, src);
if (IsAmsdu)
- memcpy(&header.addr3,
- ieee->current_network.bssid, ETH_ALEN);
+ ether_addr_copy(header.addr3,
+ ieee->current_network.bssid);
else
- memcpy(&header.addr3, &dest, ETH_ALEN);
+ ether_addr_copy(header.addr3, dest);
} else if (ieee->iw_mode == IW_MODE_ADHOC) {
/* not From/To DS: Addr1 = DA, Addr2 = SA,
* Addr3 = BSSID
*/
- memcpy(&header.addr1, dest, ETH_ALEN);
- memcpy(&header.addr2, src, ETH_ALEN);
- memcpy(&header.addr3, ieee->current_network.bssid,
- ETH_ALEN);
+ ether_addr_copy(header.addr1, dest);
+ ether_addr_copy(header.addr2, src);
+ ether_addr_copy(header.addr3,
+ ieee->current_network.bssid);
}
bIsMulticast = is_multicast_ether_addr(header.addr1);
diff --git a/drivers/staging/rtl8192e/rtllib_wx.c b/drivers/staging/rtl8192e/rtllib_wx.c
index 6234aae5b069ea..f31d864df6ccbe 100644
--- a/drivers/staging/rtl8192e/rtllib_wx.c
+++ b/drivers/staging/rtl8192e/rtllib_wx.c
@@ -266,7 +266,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
int i = 0;
int err = 0;
- RTLLIB_DEBUG_WX("Getting scan\n");
+ netdev_dbg(ieee->dev, "Getting scan\n");
down(&ieee->wx_sem);
spin_lock_irqsave(&ieee->lock, flags);
@@ -281,11 +281,13 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
ev = rtl819x_translate_scan(ieee, ev, stop, network,
info);
else
- RTLLIB_DEBUG_SCAN("Not showing network '%s ( %pM)' due to age (%lums).\n",
- escape_essid(network->ssid,
- network->ssid_len),
- network->bssid,
- (jiffies - network->last_scanned) / (HZ / 100));
+ netdev_dbg(ieee->dev,
+ "Network '%s ( %pM)' hidden due to age (%lums).\n",
+ escape_essid(network->ssid,
+ network->ssid_len),
+ network->bssid,
+ (jiffies - network->last_scanned) /
+ (HZ / 100));
}
spin_unlock_irqrestore(&ieee->lock, flags);
@@ -293,7 +295,7 @@ int rtllib_wx_get_scan(struct rtllib_device *ieee,
wrqu->data.length = ev - extra;
wrqu->data.flags = 0;
- RTLLIB_DEBUG_WX("exit: %d networks returned.\n", i);
+ netdev_dbg(ieee->dev, "%s(): %d networks returned.\n", __func__, i);
return err;
}
@@ -311,7 +313,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
int i, key, key_provided, len;
struct lib80211_crypt_data **crypt;
- RTLLIB_DEBUG_WX("SET_ENCODE\n");
+ netdev_dbg(ieee->dev, "%s()\n", __func__);
key = erq->flags & IW_ENCODE_INDEX;
if (key) {
@@ -324,16 +326,16 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
key = ieee->crypt_info.tx_keyidx;
}
- RTLLIB_DEBUG_WX("Key: %d [%s]\n", key, key_provided ?
+ netdev_dbg(ieee->dev, "Key: %d [%s]\n", key, key_provided ?
"provided" : "default");
crypt = &ieee->crypt_info.crypt[key];
if (erq->flags & IW_ENCODE_DISABLED) {
if (key_provided && *crypt) {
- RTLLIB_DEBUG_WX("Disabling encryption on key %d.\n",
- key);
+ netdev_dbg(ieee->dev,
+ "Disabling encryption on key %d.\n", key);
lib80211_crypt_delayed_deinit(&ieee->crypt_info, crypt);
} else
- RTLLIB_DEBUG_WX("Disabling encryption.\n");
+ netdev_dbg(ieee->dev, "Disabling encryption.\n");
/* Check all the keys to see if any are still configured,
* and if no key index was provided, de-init them all
@@ -405,9 +407,9 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
if (len > erq->length)
memset(sec.keys[key] + erq->length, 0,
len - erq->length);
- RTLLIB_DEBUG_WX("Setting key %d to '%s' (%d:%d bytes)\n",
- key, escape_essid(sec.keys[key], len),
- erq->length, len);
+ netdev_dbg(ieee->dev, "Setting key %d to '%s' (%d:%d bytes)\n",
+ key, escape_essid(sec.keys[key], len), erq->length,
+ len);
sec.key_sizes[key] = len;
(*crypt)->ops->set_key(sec.keys[key], len, NULL,
(*crypt)->priv);
@@ -436,8 +438,8 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
/* No key data - just set the default TX key index */
if (key_provided) {
- RTLLIB_DEBUG_WX("Setting key %d to default Tx key.\n",
- key);
+ netdev_dbg(ieee->dev,
+ "Setting key %d as default Tx key.\n", key);
ieee->crypt_info.tx_keyidx = key;
sec.active_key = key;
sec.flags |= SEC_ACTIVE_KEY;
@@ -449,7 +451,7 @@ int rtllib_wx_set_encode(struct rtllib_device *ieee,
WLAN_AUTH_SHARED_KEY;
sec.auth_mode = ieee->open_wep ? WLAN_AUTH_OPEN : WLAN_AUTH_SHARED_KEY;
sec.flags |= SEC_AUTH_MODE;
- RTLLIB_DEBUG_WX("Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ?
+ netdev_dbg(ieee->dev, "Auth: %s\n", sec.auth_mode == WLAN_AUTH_OPEN ?
"OPEN" : "SHARED KEY");
/* For now we just support WEP, so only set that security level...
@@ -485,7 +487,7 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee,
int len, key;
struct lib80211_crypt_data *crypt;
- RTLLIB_DEBUG_WX("GET_ENCODE\n");
+ netdev_dbg(ieee->dev, "%s()\n", __func__);
if (ieee->iw_mode == IW_MODE_MONITOR)
return -1;
@@ -508,7 +510,8 @@ int rtllib_wx_get_encode(struct rtllib_device *ieee,
return 0;
}
len = crypt->ops->get_key(keybuf, SCM_KEY_LEN, NULL, crypt->priv);
- erq->length = (len >= 0 ? len : 0);
+
+ erq->length = max(len, 0);
erq->flags |= IW_ENCODE_ENABLED;
@@ -592,8 +595,7 @@ int rtllib_wx_set_encode_ext(struct rtllib_device *ieee,
module = "rtllib_crypt_ccmp";
break;
default:
- RTLLIB_DEBUG_WX("%s: unknown crypto alg %d\n",
- dev->name, ext->alg);
+ netdev_dbg(ieee->dev, "Unknown crypto alg %d\n", ext->alg);
ret = -EINVAL;
goto done;
}
@@ -673,7 +675,7 @@ done:
if (ieee->reset_on_keychange &&
ieee->iw_mode != IW_MODE_INFRA &&
ieee->reset_port && ieee->reset_port(dev)) {
- RTLLIB_DEBUG_WX("%s: reset_port failed\n", dev->name);
+ netdev_dbg(ieee->dev, "Port reset failed\n");
return -EINVAL;
}
return ret;
@@ -850,8 +852,7 @@ int rtllib_wx_set_gen_ie(struct rtllib_device *ieee, u8 *ie, size_t len)
if ((eid == MFIE_TYPE_GENERIC) && (!memcmp(&ie[2],
wps_oui, 4))) {
- ieee->wps_ie_len = (len < MAX_WZC_IE_LEN) ? (len) :
- (MAX_WZC_IE_LEN);
+ ieee->wps_ie_len = min_t(size_t, len, MAX_WZC_IE_LEN);
buf = kmemdup(ie, ieee->wps_ie_len, GFP_KERNEL);
if (buf == NULL)
return -ENOMEM;
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index 0f53c6a9757850..23af2aad458e15 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -24,7 +24,7 @@
#ifndef IEEE80211_H
#define IEEE80211_H
#include <linux/if_ether.h> /* ETH_ALEN */
-#include <linux/kernel.h> /* ARRAY_SIZE */
+#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/jiffies.h>
#include <linux/timer.h>
@@ -34,6 +34,7 @@
#include <linux/delay.h>
#include <linux/wireless.h>
+#include <linux/ieee80211.h>
#include "rtl819x_HT.h"
#include "rtl819x_BA.h"
@@ -48,21 +49,6 @@
#define IWEVCUSTOM 0x8c02
#endif
-
-#ifndef container_of
-/**
- * container_of - cast a member of a structure out to the containing structure
- *
- * @ptr: the pointer to the member.
- * @type: the type of the container struct this is embedded in.
- * @member: the name of the member within the struct.
- *
- */
-#define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
- (type *)( (char *)__mptr - offsetof(type,member) );})
-#endif
-
#define KEY_TYPE_NA 0x0
#define KEY_TYPE_WEP40 0x1
#define KEY_TYPE_TKIP 0x2
@@ -187,54 +173,6 @@ typedef struct cb_desc {
#define MGN_MCS14 0x8e
#define MGN_MCS15 0x8f
-//----------------------------------------------------------------------------
-// 802.11 Management frame Reason Code field
-//----------------------------------------------------------------------------
-enum _ReasonCode{
- unspec_reason = 0x1,
- auth_not_valid = 0x2,
- deauth_lv_ss = 0x3,
- inactivity = 0x4,
- ap_overload = 0x5,
- class2_err = 0x6,
- class3_err = 0x7,
- disas_lv_ss = 0x8,
- asoc_not_auth = 0x9,
-
- //----MIC_CHECK
- mic_failure = 0xe,
- //----END MIC_CHECK
-
- // Reason code defined in 802.11i D10.0 p.28.
- invalid_IE = 0x0d,
- four_way_tmout = 0x0f,
- two_way_tmout = 0x10,
- IE_dismatch = 0x11,
- invalid_Gcipher = 0x12,
- invalid_Pcipher = 0x13,
- invalid_AKMP = 0x14,
- unsup_RSNIEver = 0x15,
- invalid_RSNIE = 0x16,
- auth_802_1x_fail= 0x17,
- ciper_reject = 0x18,
-
- // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15.
- QoS_unspec = 0x20, // 32
- QAP_bandwidth = 0x21, // 33
- poor_condition = 0x22, // 34
- no_facility = 0x23, // 35
- // Where is 36???
- req_declined = 0x25, // 37
- invalid_param = 0x26, // 38
- req_not_honored= 0x27, // 39
- TS_not_created = 0x2F, // 47
- DL_not_allowed = 0x30, // 48
- dest_not_exist = 0x31, // 49
- dest_not_QSTA = 0x32, // 50
-};
-
-
-
#define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A || \
priv->ieee80211->current_network.mode == IEEE_N_24G || \
priv->ieee80211->current_network.mode == IEEE_N_5G) ? \
@@ -646,13 +584,6 @@ struct ieee80211_snap_hdr {
#define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG)
#define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4)
-/* Authentication algorithms */
-#define WLAN_AUTH_OPEN 0
-#define WLAN_AUTH_SHARED_KEY 1
-#define WLAN_AUTH_LEAP 2
-
-#define WLAN_AUTH_CHALLENGE_LEN 128
-
#define WLAN_CAPABILITY_BSS (1<<0)
#define WLAN_CAPABILITY_IBSS (1<<1)
#define WLAN_CAPABILITY_CF_POLLABLE (1<<2)
@@ -671,69 +602,6 @@ struct ieee80211_snap_hdr {
#define WLAN_ERP_USE_PROTECTION (1<<1)
#define WLAN_ERP_BARKER_PREAMBLE (1<<2)
-/* Status codes */
-enum ieee80211_statuscode {
- WLAN_STATUS_SUCCESS = 0,
- WLAN_STATUS_UNSPECIFIED_FAILURE = 1,
- WLAN_STATUS_CAPS_UNSUPPORTED = 10,
- WLAN_STATUS_REASSOC_NO_ASSOC = 11,
- WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12,
- WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13,
- WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14,
- WLAN_STATUS_CHALLENGE_FAIL = 15,
- WLAN_STATUS_AUTH_TIMEOUT = 16,
- WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17,
- WLAN_STATUS_ASSOC_DENIED_RATES = 18,
- /* 802.11b */
- WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19,
- WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20,
- WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21,
- /* 802.11h */
- WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22,
- WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23,
- WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24,
- /* 802.11g */
- WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25,
- WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26,
- /* 802.11i */
- WLAN_STATUS_INVALID_IE = 40,
- WLAN_STATUS_INVALID_GROUP_CIPHER = 41,
- WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42,
- WLAN_STATUS_INVALID_AKMP = 43,
- WLAN_STATUS_UNSUPP_RSN_VERSION = 44,
- WLAN_STATUS_INVALID_RSN_IE_CAP = 45,
- WLAN_STATUS_CIPHER_SUITE_REJECTED = 46,
-};
-
-/* Reason codes */
-enum ieee80211_reasoncode {
- WLAN_REASON_UNSPECIFIED = 1,
- WLAN_REASON_PREV_AUTH_NOT_VALID = 2,
- WLAN_REASON_DEAUTH_LEAVING = 3,
- WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4,
- WLAN_REASON_DISASSOC_AP_BUSY = 5,
- WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6,
- WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7,
- WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8,
- WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9,
- /* 802.11h */
- WLAN_REASON_DISASSOC_BAD_POWER = 10,
- WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11,
- /* 802.11i */
- WLAN_REASON_INVALID_IE = 13,
- WLAN_REASON_MIC_FAILURE = 14,
- WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
- WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16,
- WLAN_REASON_IE_DIFFERENT = 17,
- WLAN_REASON_INVALID_GROUP_CIPHER = 18,
- WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19,
- WLAN_REASON_INVALID_AKMP = 20,
- WLAN_REASON_UNSUPP_RSN_VERSION = 21,
- WLAN_REASON_INVALID_RSN_IE_CAP = 22,
- WLAN_REASON_IEEE8021X_FAILED = 23,
- WLAN_REASON_CIPHER_SUITE_REJECTED = 24,
-};
-
#define IEEE80211_STATMASK_SIGNAL (1<<0)
#define IEEE80211_STATMASK_RSSI (1<<1)
#define IEEE80211_STATMASK_NOISE (1<<2)
@@ -961,10 +829,10 @@ struct ieee80211_device;
struct ieee80211_security {
u16 active_key:2,
enabled:1,
- auth_mode:2,
auth_algo:4,
unicast_uses_group:1,
encrypt:1;
+ u8 auth_mode;
u8 key_sizes[WEP_KEYS];
u8 keys[WEP_KEYS][SCM_KEY_LEN];
u8 level;
@@ -1020,20 +888,20 @@ enum ieee80211_mfie {
/* Minimal header; can be used for passing 802.11 frames with sufficient
* information to determine what type of underlying data type is actually
* stored in the data. */
-struct ieee80211_hdr {
+struct rtl_80211_hdr {
__le16 frame_ctl;
__le16 duration_id;
u8 payload[0];
} __packed;
-struct ieee80211_hdr_1addr {
+struct rtl_80211_hdr_1addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
u8 payload[0];
} __packed;
-struct ieee80211_hdr_2addr {
+struct rtl_80211_hdr_2addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1041,7 +909,7 @@ struct ieee80211_hdr_2addr {
u8 payload[0];
} __packed;
-struct ieee80211_hdr_3addr {
+struct rtl_80211_hdr_3addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1051,7 +919,7 @@ struct ieee80211_hdr_3addr {
u8 payload[0];
} __packed;
-struct ieee80211_hdr_4addr {
+struct rtl_80211_hdr_4addr {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1062,7 +930,7 @@ struct ieee80211_hdr_4addr {
u8 payload[0];
} __packed;
-struct ieee80211_hdr_3addrqos {
+struct rtl_80211_hdr_3addrqos {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1073,7 +941,7 @@ struct ieee80211_hdr_3addrqos {
__le16 qos_ctl;
} __packed;
-struct ieee80211_hdr_4addrqos {
+struct rtl_80211_hdr_4addrqos {
__le16 frame_ctl;
__le16 duration_id;
u8 addr1[ETH_ALEN];
@@ -1092,7 +960,7 @@ struct ieee80211_info_element {
} __packed;
struct ieee80211_authentication {
- struct ieee80211_hdr_3addr header;
+ struct rtl_80211_hdr_3addr header;
__le16 algorithm;
__le16 transaction;
__le16 status;
@@ -1101,18 +969,18 @@ struct ieee80211_authentication {
} __packed;
struct ieee80211_disassoc {
- struct ieee80211_hdr_3addr header;
+ struct rtl_80211_hdr_3addr header;
__le16 reason;
} __packed;
struct ieee80211_probe_request {
- struct ieee80211_hdr_3addr header;
+ struct rtl_80211_hdr_3addr header;
/* SSID, supported rates */
struct ieee80211_info_element info_element[0];
} __packed;
struct ieee80211_probe_response {
- struct ieee80211_hdr_3addr header;
+ struct rtl_80211_hdr_3addr header;
__le32 time_stamp[2];
__le16 beacon_interval;
__le16 capability;
@@ -1125,7 +993,7 @@ struct ieee80211_probe_response {
#define ieee80211_beacon ieee80211_probe_response
struct ieee80211_assoc_request_frame {
- struct ieee80211_hdr_3addr header;
+ struct rtl_80211_hdr_3addr header;
__le16 capability;
__le16 listen_interval;
/* SSID, supported rates, RSN */
@@ -1133,7 +1001,7 @@ struct ieee80211_assoc_request_frame {
} __packed;
struct ieee80211_reassoc_request_frame {
- struct ieee80211_hdr_3addr header;
+ struct rtl_80211_hdr_3addr header;
__le16 capability;
__le16 listen_interval;
u8 current_ap[ETH_ALEN];
@@ -1142,7 +1010,7 @@ struct ieee80211_reassoc_request_frame {
} __packed;
struct ieee80211_assoc_response_frame {
- struct ieee80211_hdr_3addr header;
+ struct rtl_80211_hdr_3addr header;
__le16 capability;
__le16 status;
__le16 aid;
@@ -1276,12 +1144,6 @@ struct ieee80211_tim_parameters {
} __packed;
//#else
-struct ieee80211_wmm_ac_param {
- u8 ac_aci_acm_aifsn;
- u8 ac_ecwmin_ecwmax;
- u16 ac_txop_limit;
-};
-
struct ieee80211_wmm_ts_info {
u8 ac_dir_tid;
u8 ac_up_psb;
@@ -1329,9 +1191,9 @@ static inline const char *eap_get_type(int type)
//added by amy for reorder
static inline u8 Frame_QoSTID(u8 *buf)
{
- struct ieee80211_hdr_3addr *hdr;
+ struct rtl_80211_hdr_3addr *hdr;
u16 fc;
- hdr = (struct ieee80211_hdr_3addr *)buf;
+ hdr = (struct rtl_80211_hdr_3addr *)buf;
fc = le16_to_cpu(hdr->frame_ctl);
return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid;
}
@@ -2262,17 +2124,17 @@ static inline int ieee80211_get_hdrlen(u16 fc)
return hdrlen;
}
-static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr)
+static inline u8 *ieee80211_get_payload(struct rtl_80211_hdr *hdr)
{
switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) {
case IEEE80211_1ADDR_LEN:
- return ((struct ieee80211_hdr_1addr *)hdr)->payload;
+ return ((struct rtl_80211_hdr_1addr *)hdr)->payload;
case IEEE80211_2ADDR_LEN:
- return ((struct ieee80211_hdr_2addr *)hdr)->payload;
+ return ((struct rtl_80211_hdr_2addr *)hdr)->payload;
case IEEE80211_3ADDR_LEN:
- return ((struct ieee80211_hdr_3addr *)hdr)->payload;
+ return ((struct rtl_80211_hdr_3addr *)hdr)->payload;
case IEEE80211_4ADDR_LEN:
- return ((struct ieee80211_hdr_4addr *)hdr)->payload;
+ return ((struct rtl_80211_hdr_4addr *)hdr)->payload;
}
return NULL;
}
@@ -2328,7 +2190,7 @@ extern void ieee80211_txb_free(struct ieee80211_txb *);
extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
struct ieee80211_rx_stats *rx_stats);
extern void ieee80211_rx_mgt(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *header,
+ struct rtl_80211_hdr_4addr *header,
struct ieee80211_rx_stats *stats);
/* ieee80211_wx.c */
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
index 788704b800c400..a66141647f2df5 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c
@@ -112,7 +112,7 @@ static inline void xor_block(u8 *b, u8 *a, size_t len)
static void ccmp_init_blocks(struct crypto_tfm *tfm,
- struct ieee80211_hdr_4addr *hdr,
+ struct rtl_80211_hdr_4addr *hdr,
u8 *pn, size_t dlen, u8 *b0, u8 *auth,
u8 *s0)
{
@@ -196,7 +196,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
struct ieee80211_ccmp_data *key = priv;
int data_len, i;
u8 *pos;
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
if (skb_headroom(skb) < CCMP_HDR_LEN ||
@@ -228,7 +228,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
*pos++ = key->tx_pn[0];
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
if (!tcb_desc->bHwSec)
{
int blocks, last, len;
@@ -270,7 +270,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
{
struct ieee80211_ccmp_data *key = priv;
u8 keyidx, *pos;
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
u8 pn[6];
@@ -279,7 +279,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
return -1;
}
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
pos = skb->data + hdr_len;
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
index e815c81b45dc59..1f80c52a49c490 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c
@@ -306,7 +306,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
struct ieee80211_tkip_data *tkey = priv;
int len;
u8 *pos;
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4};
int ret = 0;
@@ -318,7 +318,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
skb->len < hdr_len)
return -1;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
if (!tcb_desc->bHwSec)
{
@@ -390,7 +390,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
u8 keyidx, *pos;
u32 iv32;
u16 iv16;
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE);
struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4};
u8 rc4key[16];
@@ -401,7 +401,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
if (skb->len < hdr_len + 8 + 4)
return -1;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
pos = skb->data + hdr_len;
keyidx = pos[3];
if (!(keyidx & (1 << 5))) {
@@ -523,9 +523,9 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr,
static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr)
{
- struct ieee80211_hdr_4addr *hdr11;
+ struct rtl_80211_hdr_4addr *hdr11;
- hdr11 = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr11 = (struct rtl_80211_hdr_4addr *) skb->data;
switch (le16_to_cpu(hdr11->frame_ctl) &
(IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) {
case IEEE80211_FCTL_TODS:
@@ -556,9 +556,9 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri
{
struct ieee80211_tkip_data *tkey = priv;
u8 *pos;
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
if (skb_tailroom(skb) < 8 || skb->len < hdr_len) {
printk(KERN_DEBUG "Invalid packet for Michael MIC add "
@@ -585,7 +585,7 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri
}
static void ieee80211_michael_mic_failure(struct net_device *dev,
- struct ieee80211_hdr_4addr *hdr,
+ struct rtl_80211_hdr_4addr *hdr,
int keyidx)
{
union iwreq_data wrqu;
@@ -610,9 +610,9 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
{
struct ieee80211_tkip_data *tkey = priv;
u8 mic[8];
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
if (!tkey->key_set)
return -1;
@@ -629,8 +629,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx,
skb->data + hdr_len, skb->len - 8 - hdr_len, mic))
return -1;
if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) {
- struct ieee80211_hdr_4addr *hdr;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ struct rtl_80211_hdr_4addr *hdr;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
printk(KERN_DEBUG "%s: Michael MIC verification failed for "
"MSDU from %pM keyidx=%d\n",
skb->dev ? skb->dev->name : "N/A", hdr->addr2,
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
index 0a17f84bb80912..26f2fb15e2a354 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c
@@ -19,7 +19,7 @@
#include "ieee80211.h"
#include <linux/crypto.h>
- #include <linux/scatterlist.h>
+#include <linux/scatterlist.h>
#include <linux/crc32.h>
MODULE_AUTHOR("Jouni Malinen");
@@ -142,9 +142,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv)
/* Copy rest of the WEP key (the secret part) */
memcpy(key + 3, wep->key, wep->key_len);
- if (!tcb_desc->bHwSec)
- {
-
+ if (!tcb_desc->bHwSec) {
/* Append little-endian CRC32 and encrypt it to produce ICV */
crc = ~crc32_le(~0, pos, len);
icv = skb_put(skb, 4);
@@ -201,8 +199,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv)
/* Apply RC4 to data and compute CRC32 over decrypted data */
plen = skb->len - hdr_len - 8;
- if (!tcb_desc->bHwSec)
- {
+ if (!tcb_desc->bHwSec) {
crypto_blkcipher_setkey(wep->rx_tfm, key, klen);
sg_init_one(&sg, pos, plen+4);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
index 9fbb53d8c6bfb8..b374088c5ff87c 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c
@@ -47,7 +47,7 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee,
struct sk_buff *skb,
struct ieee80211_rx_stats *rx_stats)
{
- struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ struct rtl_80211_hdr_4addr *hdr = (struct rtl_80211_hdr_4addr *)skb->data;
u16 fc = le16_to_cpu(hdr->frame_ctl);
skb->dev = ieee->dev;
@@ -94,7 +94,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq,
/* Called only as a tasklet (software IRQ) */
static struct sk_buff *
ieee80211_frag_cache_get(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *hdr)
+ struct rtl_80211_hdr_4addr *hdr)
{
struct sk_buff *skb = NULL;
u16 fc = le16_to_cpu(hdr->frame_ctl);
@@ -102,17 +102,17 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee,
unsigned int frag = WLAN_GET_SEQ_FRAG(sc);
unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
struct ieee80211_frag_entry *entry;
- struct ieee80211_hdr_3addrqos *hdr_3addrqos;
- struct ieee80211_hdr_4addrqos *hdr_4addrqos;
+ struct rtl_80211_hdr_3addrqos *hdr_3addrqos;
+ struct rtl_80211_hdr_4addrqos *hdr_4addrqos;
u8 tid;
if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr;
+ hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)hdr;
tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
tid = UP2AC(tid);
tid ++;
} else if (IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr;
+ hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)hdr;
tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
tid = UP2AC(tid);
tid ++;
@@ -123,7 +123,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee,
if (frag == 0) {
/* Reserve enough space to fit maximum frame length */
skb = dev_alloc_skb(ieee->dev->mtu +
- sizeof(struct ieee80211_hdr_4addr) +
+ sizeof(struct rtl_80211_hdr_4addr) +
8 /* LLC */ +
2 /* alignment */ +
8 /* WEP */ +
@@ -163,23 +163,23 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee,
/* Called only as a tasklet (software IRQ) */
static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *hdr)
+ struct rtl_80211_hdr_4addr *hdr)
{
u16 fc = le16_to_cpu(hdr->frame_ctl);
u16 sc = le16_to_cpu(hdr->seq_ctl);
unsigned int seq = WLAN_GET_SEQ_SEQ(sc);
struct ieee80211_frag_entry *entry;
- struct ieee80211_hdr_3addrqos *hdr_3addrqos;
- struct ieee80211_hdr_4addrqos *hdr_4addrqos;
+ struct rtl_80211_hdr_3addrqos *hdr_3addrqos;
+ struct rtl_80211_hdr_4addrqos *hdr_4addrqos;
u8 tid;
if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr;
+ hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)hdr;
tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
tid = UP2AC(tid);
tid ++;
} else if (IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr;
+ hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)hdr;
tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
tid = UP2AC(tid);
tid ++;
@@ -217,10 +217,10 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb,
* this is not mandatory.... but seems that the probe
* response parser uses it
*/
- struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)skb->data;
+ struct rtl_80211_hdr_3addr *hdr = (struct rtl_80211_hdr_3addr *)skb->data;
rx_stats->len = skb->len;
- ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats);
+ ieee80211_rx_mgt(ieee,(struct rtl_80211_hdr_4addr *)skb->data,rx_stats);
/* if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN))) */
if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))/* use ADDR1 to perform address matching for Management frames */
{
@@ -298,13 +298,13 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee,
{
struct net_device *dev = ieee->dev;
u16 fc, ethertype;
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
u8 *pos;
if (skb->len < 24)
return 0;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
fc = le16_to_cpu(hdr->frame_ctl);
/* check that the frame is unicast frame to us */
@@ -338,7 +338,7 @@ static inline int
ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
struct ieee80211_crypt_data *crypt)
{
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
int res, hdrlen;
if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL)
@@ -348,7 +348,7 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb,
cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE);
tcb_desc->bHwSec = 1;
}
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
if (ieee->tkip_countermeasures &&
@@ -385,7 +385,7 @@ static inline int
ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *skb,
int keyidx, struct ieee80211_crypt_data *crypt)
{
- struct ieee80211_hdr_4addr *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
int res, hdrlen;
if (crypt == NULL || crypt->ops->decrypt_msdu == NULL)
@@ -396,7 +396,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *s
tcb_desc->bHwSec = 1;
}
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl));
atomic_inc(&crypt->refcnt);
@@ -416,7 +416,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *s
/* this function is stolen from ipw2200 driver*/
#define IEEE_PACKET_RETRY_TIME (5*HZ)
static int is_duplicate_packet(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *header)
+ struct rtl_80211_hdr_4addr *header)
{
u16 fc = le16_to_cpu(header->frame_ctl);
u16 sc = le16_to_cpu(header->seq_ctl);
@@ -424,19 +424,19 @@ static int is_duplicate_packet(struct ieee80211_device *ieee,
u16 frag = WLAN_GET_SEQ_FRAG(sc);
u16 *last_seq, *last_frag;
unsigned long *last_time;
- struct ieee80211_hdr_3addrqos *hdr_3addrqos;
- struct ieee80211_hdr_4addrqos *hdr_4addrqos;
+ struct rtl_80211_hdr_3addrqos *hdr_3addrqos;
+ struct rtl_80211_hdr_4addrqos *hdr_4addrqos;
u8 tid;
//TO2DS and QoS
if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) {
- hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)header;
+ hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)header;
tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID;
tid = UP2AC(tid);
tid ++;
} else if(IEEE80211_QOS_HAS_SEQ(fc)) { //QoS
- hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)header;
+ hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)header;
tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID;
tid = UP2AC(tid);
tid ++;
@@ -768,10 +768,10 @@ static u8 parse_subframe(struct sk_buff *skb,
struct ieee80211_rx_stats *rx_stats,
struct ieee80211_rxb *rxb, u8 *src, u8 *dst)
{
- struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)skb->data;
+ struct rtl_80211_hdr_3addr *hdr = (struct rtl_80211_hdr_3addr *)skb->data;
u16 fc = le16_to_cpu(hdr->frame_ctl);
- u16 LLCOffset= sizeof(struct ieee80211_hdr_3addr);
+ u16 LLCOffset= sizeof(struct rtl_80211_hdr_3addr);
u16 ChkLength;
bool bIsAggregateFrame = false;
u16 nSubframe_Length;
@@ -888,8 +888,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
struct ieee80211_rx_stats *rx_stats)
{
struct net_device *dev = ieee->dev;
- struct ieee80211_hdr_4addr *hdr;
- //struct ieee80211_hdr_3addrqos *hdr;
+ struct rtl_80211_hdr_4addr *hdr;
+ //struct rtl_80211_hdr_3addrqos *hdr;
size_t hdrlen;
u16 fc, type, stype, sc;
@@ -921,7 +921,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
int i;
struct ieee80211_rxb *rxb = NULL;
// cheat the the hdr type
- hdr = (struct ieee80211_hdr_4addr *)skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *)skb->data;
stats = &ieee->stats;
if (skb->len < 10) {
@@ -1156,7 +1156,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
}
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
/* skb: hdr + (possibly fragmented) plaintext payload */
// PR: FIXME: hostap has additional conditions in the "if" below:
@@ -1209,7 +1209,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
/* this was the last fragment and the frame will be
* delivered, so remove skb from fragment cache */
skb = frag_skb;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
ieee80211_frag_cache_invalidate(ieee, hdr);
}
@@ -1226,7 +1226,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb,
ieee->LinkDetectInfo.NumRecvDataInPeriod++;
ieee->LinkDetectInfo.NumRxOkInPeriod++;
- hdr = (struct ieee80211_hdr_4addr *) skb->data;
+ hdr = (struct rtl_80211_hdr_4addr *) skb->data;
if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) {
if (/*ieee->ieee802_1x &&*/
ieee80211_is_eapol_frame(ieee, skb, hdrlen)) {
@@ -2366,10 +2366,10 @@ static inline void update_network(struct ieee80211_network *dst,
/* dst->last_associate is not overwritten */
dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame.
- if (src->wmm_param[0].ac_aci_acm_aifsn|| \
- src->wmm_param[1].ac_aci_acm_aifsn|| \
- src->wmm_param[2].ac_aci_acm_aifsn|| \
- src->wmm_param[3].ac_aci_acm_aifsn) {
+ if (src->wmm_param[0].aci_aifsn|| \
+ src->wmm_param[1].aci_aifsn|| \
+ src->wmm_param[2].aci_aifsn|| \
+ src->wmm_param[3].aci_aifsn) {
memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN);
}
//dst->QoS_Enable = src->QoS_Enable;
@@ -2612,7 +2612,7 @@ static inline void ieee80211_process_probe_response(
}
void ieee80211_rx_mgt(struct ieee80211_device *ieee,
- struct ieee80211_hdr_4addr *header,
+ struct rtl_80211_hdr_4addr *header,
struct ieee80211_rx_stats *stats)
{
switch (WLAN_FC_GET_STYPE(header->frame_ctl)) {
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
index c2388812d4fd71..d2e8b125b9891a 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c
@@ -222,8 +222,8 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee
{
unsigned long flags;
short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
- struct ieee80211_hdr_3addr *header=
- (struct ieee80211_hdr_3addr *) skb->data;
+ struct rtl_80211_hdr_3addr *header=
+ (struct rtl_80211_hdr_3addr *) skb->data;
cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8);
spin_lock_irqsave(&ieee->lock, flags);
@@ -289,8 +289,8 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *i
{
short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE;
- struct ieee80211_hdr_3addr *header =
- (struct ieee80211_hdr_3addr *) skb->data;
+ struct rtl_80211_hdr_3addr *header =
+ (struct rtl_80211_hdr_3addr *) skb->data;
if(single){
@@ -928,14 +928,14 @@ static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee,
short pwr)
{
struct sk_buff *skb;
- struct ieee80211_hdr_3addr *hdr;
+ struct rtl_80211_hdr_3addr *hdr;
- skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr));
+ skb = dev_alloc_skb(sizeof(struct rtl_80211_hdr_3addr));
if (!skb)
return NULL;
- hdr = (struct ieee80211_hdr_3addr *)skb_put(skb,sizeof(struct ieee80211_hdr_3addr));
+ hdr = (struct rtl_80211_hdr_3addr *)skb_put(skb,sizeof(struct rtl_80211_hdr_3addr));
memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN);
memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN);
@@ -1304,7 +1304,7 @@ static void ieee80211_auth_challenge(struct ieee80211_device *ieee,
IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n");
- ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr ));
+ ieee80211_encrypt_fragment(ieee, skb, sizeof(struct rtl_80211_hdr_3addr ));
softmac_mgmt_xmit(skb, ieee);
mod_timer(&ieee->associate_timer, jiffies + (HZ/2));
@@ -1588,17 +1588,17 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb,
u8 *ssid=NULL;
u8 ssidlen = 0;
- struct ieee80211_hdr_3addr *header =
- (struct ieee80211_hdr_3addr *) skb->data;
+ struct rtl_80211_hdr_3addr *header =
+ (struct rtl_80211_hdr_3addr *) skb->data;
- if (skb->len < sizeof (struct ieee80211_hdr_3addr ))
+ if (skb->len < sizeof (struct rtl_80211_hdr_3addr ))
return -1; /* corrupted */
memcpy(src,header->addr2, ETH_ALEN);
skbend = (u8 *)skb->data + skb->len;
- tag = skb->data + sizeof (struct ieee80211_hdr_3addr );
+ tag = skb->data + sizeof (struct rtl_80211_hdr_3addr );
while (tag+1 < skbend){
if (*tag == 0) {
@@ -1894,7 +1894,7 @@ EXPORT_SYMBOL(ieee80211_ps_tx_ack);
static void ieee80211_process_action(struct ieee80211_device *ieee,
struct sk_buff *skb)
{
- struct ieee80211_hdr *header = (struct ieee80211_hdr *)skb->data;
+ struct rtl_80211_hdr *header = (struct rtl_80211_hdr *)skb->data;
u8 *act = ieee80211_get_payload(header);
u8 tmp = 0;
// IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
@@ -1985,7 +1985,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb,
struct ieee80211_rx_stats *rx_stats, u16 type,
u16 stype)
{
- struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data;
+ struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *) skb->data;
u16 errcode;
int aid;
struct ieee80211_assoc_response_frame *assoc_resp;
@@ -2243,7 +2243,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee)
unsigned long flags;
struct sk_buff *skb;
- struct ieee80211_hdr_3addr *header;
+ struct rtl_80211_hdr_3addr *header;
spin_lock_irqsave(&ieee->lock, flags);
if (! ieee->queue_stop) goto exit;
@@ -2253,7 +2253,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee)
if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) {
while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){
- header = (struct ieee80211_hdr_3addr *) skb->data;
+ header = (struct rtl_80211_hdr_3addr *) skb->data;
header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4);
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
index 9f68c652fb2bf8..5353a45ffdffd4 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c
@@ -194,9 +194,9 @@ int ieee80211_encrypt_fragment(
if (ieee->tkip_countermeasures &&
crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) {
if (net_ratelimit()) {
- struct ieee80211_hdr_3addrqos *header;
+ struct rtl_80211_hdr_3addrqos *header;
- header = (struct ieee80211_hdr_3addrqos *)frag->data;
+ header = (struct rtl_80211_hdr_3addrqos *)frag->data;
printk(KERN_DEBUG "%s: TKIP countermeasures: dropped "
"TX packet to %pM\n",
ieee->dev->name, header->addr1);
@@ -308,7 +308,7 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee,
{
PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo;
PTX_TS_RECORD pTxTs = NULL;
- struct ieee80211_hdr_1addr *hdr = (struct ieee80211_hdr_1addr *)skb->data;
+ struct rtl_80211_hdr_1addr *hdr = (struct rtl_80211_hdr_1addr *)skb->data;
if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT)
return;
@@ -598,14 +598,14 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct ieee80211_device *ieee = netdev_priv(dev);
struct ieee80211_txb *txb = NULL;
- struct ieee80211_hdr_3addrqos *frag_hdr;
+ struct rtl_80211_hdr_3addrqos *frag_hdr;
int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size;
unsigned long flags;
struct net_device_stats *stats = &ieee->stats;
int ether_type = 0, encrypt;
int bytes, fc, qos_ctl = 0, hdr_len;
struct sk_buff *skb_frag;
- struct ieee80211_hdr_3addrqos header = { /* Ensure zero initialized */
+ struct rtl_80211_hdr_3addrqos header = { /* Ensure zero initialized */
.duration_id = 0,
.seq_ctl = 0,
.qos_ctl = 0
@@ -787,7 +787,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
{
tcb_desc->bHwSec = 0;
}
- frag_hdr = (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len);
+ frag_hdr = (struct rtl_80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len);
memcpy(frag_hdr, &header, hdr_len);
/* If this is not the last fragment, then add the MOREFRAGS
@@ -845,7 +845,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev)
ieee->seq_ctrl[0]++;
}
}else{
- if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) {
+ if (unlikely(skb->len < sizeof(struct rtl_80211_hdr_3addr))) {
printk(KERN_WARNING "%s: skb too small (%d).\n",
ieee->dev->name, skb->len);
goto success;
diff --git a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
index 618d2cbc049ec0..9ff8e056ab7f10 100644
--- a/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
+++ b/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c
@@ -110,7 +110,7 @@ void ResetBaEntry(PBA_RECORD pBA)
static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, PBA_RECORD pBA, u16 StatusCode, u8 type)
{
struct sk_buff *skb = NULL;
- struct ieee80211_hdr_3addr *BAReq = NULL;
+ struct rtl_80211_hdr_3addr *BAReq = NULL;
u8 *tag = NULL;
u16 len = ieee->tx_headroom + 9;
//category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2))
@@ -120,17 +120,17 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P
IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA is NULL\n");
return NULL;
}
- skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
+ skb = dev_alloc_skb(len + sizeof( struct rtl_80211_hdr_3addr)); //need to add something others? FIXME
if (skb == NULL)
{
IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
return NULL;
}
- memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
+ memset(skb->data, 0, sizeof( struct rtl_80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb.
skb_reserve(skb, ieee->tx_headroom);
- BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
+ BAReq = ( struct rtl_80211_hdr_3addr *) skb_put(skb,sizeof( struct rtl_80211_hdr_3addr));
memcpy(BAReq->addr1, Dst, ETH_ALEN);
memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN);
@@ -139,7 +139,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P
BAReq->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame
- //tag += sizeof( struct ieee80211_hdr_3addr); //move to action field
+ //tag += sizeof( struct rtl_80211_hdr_3addr); //move to action field
tag = (u8 *)skb_put(skb, 9);
*tag ++= ACT_CAT_BA;
*tag ++= type;
@@ -195,7 +195,7 @@ static struct sk_buff *ieee80211_DELBA(
{
DELBA_PARAM_SET DelbaParamSet;
struct sk_buff *skb = NULL;
- struct ieee80211_hdr_3addr *Delba = NULL;
+ struct rtl_80211_hdr_3addr *Delba = NULL;
u8 *tag = NULL;
//len = head len + DELBA Parameter Set(2) + Reason Code(2)
u16 len = 6 + ieee->tx_headroom;
@@ -208,16 +208,16 @@ static struct sk_buff *ieee80211_DELBA(
DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0;
DelbaParamSet.field.TID = pBA->BaParamSet.field.TID;
- skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME
+ skb = dev_alloc_skb(len + sizeof( struct rtl_80211_hdr_3addr)); //need to add something others? FIXME
if (skb == NULL)
{
IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n");
return NULL;
}
-// memset(skb->data, 0, len+sizeof( struct ieee80211_hdr_3addr));
+// memset(skb->data, 0, len+sizeof( struct rtl_80211_hdr_3addr));
skb_reserve(skb, ieee->tx_headroom);
- Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr));
+ Delba = ( struct rtl_80211_hdr_3addr *) skb_put(skb,sizeof( struct rtl_80211_hdr_3addr));
memcpy(Delba->addr1, dst, ETH_ALEN);
memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN);
@@ -333,7 +333,7 @@ static void ieee80211_send_DELBA(struct ieee80211_device *ieee, u8 *dst,
********************************************************************************************************************/
int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb)
{
- struct ieee80211_hdr_3addr *req = NULL;
+ struct rtl_80211_hdr_3addr *req = NULL;
u16 rc = 0;
u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL;
PBA_RECORD pBA = NULL;
@@ -342,20 +342,20 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb)
PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL;
PRX_TS_RECORD pTS = NULL;
- if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) {
+ if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) {
IEEE80211_DEBUG(IEEE80211_DL_ERR,
" Invalid skb len in BAREQ(%d / %zu)\n",
skb->len,
- (sizeof(struct ieee80211_hdr_3addr) + 9));
+ (sizeof(struct rtl_80211_hdr_3addr) + 9));
return -1;
}
IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
- req = (struct ieee80211_hdr_3addr *) skb->data;
+ req = (struct rtl_80211_hdr_3addr *) skb->data;
tag = (u8 *)req;
dst = (u8 *)(&req->addr2[0]);
- tag += sizeof(struct ieee80211_hdr_3addr);
+ tag += sizeof(struct rtl_80211_hdr_3addr);
pDialogToken = tag + 2; //category+action
pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken
pBaTimeoutVal = (u16 *)(tag + 5);
@@ -435,7 +435,7 @@ OnADDBAReq_Fail:
********************************************************************************************************************/
int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb)
{
- struct ieee80211_hdr_3addr *rsp = NULL;
+ struct rtl_80211_hdr_3addr *rsp = NULL;
PBA_RECORD pPendingBA, pAdmittedBA;
PTX_TS_RECORD pTS = NULL;
u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL;
@@ -443,17 +443,17 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb)
PBA_PARAM_SET pBaParamSet = NULL;
u16 ReasonCode;
- if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) {
+ if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) {
IEEE80211_DEBUG(IEEE80211_DL_ERR,
" Invalid skb len in BARSP(%d / %zu)\n",
skb->len,
- (sizeof(struct ieee80211_hdr_3addr) + 9));
+ (sizeof(struct rtl_80211_hdr_3addr) + 9));
return -1;
}
- rsp = (struct ieee80211_hdr_3addr *)skb->data;
+ rsp = (struct rtl_80211_hdr_3addr *)skb->data;
tag = (u8 *)rsp;
dst = (u8 *)(&rsp->addr2[0]);
- tag += sizeof(struct ieee80211_hdr_3addr);
+ tag += sizeof(struct rtl_80211_hdr_3addr);
pDialogToken = tag + 2;
pStatusCode = (u16 *)(tag + 3);
pBaParamSet = (PBA_PARAM_SET)(tag + 5);
@@ -569,16 +569,16 @@ OnADDBARsp_Reject:
********************************************************************************************************************/
int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb)
{
- struct ieee80211_hdr_3addr *delba = NULL;
+ struct rtl_80211_hdr_3addr *delba = NULL;
PDELBA_PARAM_SET pDelBaParamSet = NULL;
u16 *pReasonCode = NULL;
u8 *dst = NULL;
- if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 6) {
+ if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 6) {
IEEE80211_DEBUG(IEEE80211_DL_ERR,
" Invalid skb len in DELBA(%d / %zu)\n",
skb->len,
- (sizeof(struct ieee80211_hdr_3addr) + 6));
+ (sizeof(struct rtl_80211_hdr_3addr) + 6));
return -1;
}
@@ -590,9 +590,9 @@ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb)
}
IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len);
- delba = (struct ieee80211_hdr_3addr *)skb->data;
+ delba = (struct rtl_80211_hdr_3addr *)skb->data;
dst = (u8 *)(&delba->addr2[0]);
- delba += sizeof(struct ieee80211_hdr_3addr);
+ delba += sizeof(struct rtl_80211_hdr_3addr);
pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2);
pReasonCode = (u16 *)(delba+4);
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c
index a4795afeeb9ca6..b852396d21e6af 100644
--- a/drivers/staging/rtl8192u/r8192U_core.c
+++ b/drivers/staging/rtl8192u/r8192U_core.c
@@ -3209,7 +3209,7 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum,
}
-void rtl819x_watchdog_wqcallback(struct work_struct *work)
+static void rtl819x_watchdog_wqcallback(struct work_struct *work)
{
struct delayed_work *dwork = container_of(work, struct delayed_work, work);
struct r8192_priv *priv = container_of(dwork, struct r8192_priv, watch_dog_wq);
@@ -3273,13 +3273,13 @@ void rtl819x_watchdog_wqcallback(struct work_struct *work)
}
-void watch_dog_timer_callback(unsigned long data)
+static void watch_dog_timer_callback(unsigned long data)
{
struct r8192_priv *priv = ieee80211_priv((struct net_device *) data);
queue_delayed_work(priv->priv_wq, &priv->watch_dog_wq, 0);
mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME));
}
-int _rtl8192_up(struct net_device *dev)
+static int _rtl8192_up(struct net_device *dev)
{
struct r8192_priv *priv = ieee80211_priv(dev);
int init_status = 0;
@@ -3330,7 +3330,7 @@ int rtl8192_up(struct net_device *dev)
}
-int rtl8192_close(struct net_device *dev)
+static int rtl8192_close(struct net_device *dev)
{
struct r8192_priv *priv = ieee80211_priv(dev);
int ret;
@@ -3403,7 +3403,7 @@ void rtl8192_commit(struct net_device *dev)
}
-void rtl8192_restart(struct work_struct *work)
+static void rtl8192_restart(struct work_struct *work)
{
struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq);
struct net_device *dev = priv->ieee80211->dev;
@@ -3711,10 +3711,10 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer,
static u32 slide_beacon_adc_pwdb_index, slide_beacon_adc_pwdb_statistics;
static u32 last_beacon_adc_pwdb;
- struct ieee80211_hdr_3addr *hdr;
+ struct rtl_80211_hdr_3addr *hdr;
u16 sc;
unsigned int frag, seq;
- hdr = (struct ieee80211_hdr_3addr *)buffer;
+ hdr = (struct rtl_80211_hdr_3addr *)buffer;
sc = le16_to_cpu(hdr->seq_ctl);
frag = WLAN_GET_SEQ_FRAG(sc);
seq = WLAN_GET_SEQ_SEQ(sc);
@@ -4205,7 +4205,7 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
bool bpacket_match_bssid, bpacket_toself;
bool bPacketBeacon = false, bToSelfBA = false;
static struct ieee80211_rx_stats previous_stats;
- struct ieee80211_hdr_3addr *hdr;//by amy
+ struct rtl_80211_hdr_3addr *hdr;//by amy
u16 fc, type;
// Get Signal Quality for only RX data queue (but not command queue)
@@ -4216,7 +4216,7 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb,
/* Get MAC frame start address. */
tmp_buf = (u8 *)skb->data;
- hdr = (struct ieee80211_hdr_3addr *)tmp_buf;
+ hdr = (struct rtl_80211_hdr_3addr *)tmp_buf;
fc = le16_to_cpu(hdr->frame_ctl);
type = WLAN_FC_GET_TYPE(fc);
praddr = hdr->addr1;
@@ -4487,7 +4487,7 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
.freq = IEEE80211_24GHZ_BAND,
};
u32 rx_pkt_len = 0;
- struct ieee80211_hdr_1addr *ieee80211_hdr = NULL;
+ struct rtl_80211_hdr_1addr *ieee80211_hdr = NULL;
bool unicast_packet = false;
/* 20 is for ps-poll */
@@ -4500,7 +4500,7 @@ static void rtl8192_rx_nomal(struct sk_buff *skb)
skb_trim(skb, skb->len - 4/*sCrcLng*/);
rx_pkt_len = skb->len;
- ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data;
+ ieee80211_hdr = (struct rtl_80211_hdr_1addr *)skb->data;
unicast_packet = false;
if (is_broadcast_ether_addr(ieee80211_hdr->addr1)) {
//TODO
@@ -4615,7 +4615,7 @@ static void rtl8192_rx_cmd(struct sk_buff *skb)
}
}
-void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
+static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv)
{
struct sk_buff *skb;
struct rtl8192_rx_info *info;
@@ -4733,7 +4733,7 @@ fail:
}
//detach all the work and timer structure declared or inititialize in r8192U_init function.
-void rtl8192_cancel_deferred_work(struct r8192_priv *priv)
+static void rtl8192_cancel_deferred_work(struct r8192_priv *priv)
{
cancel_work_sync(&priv->reset_wq);
diff --git a/drivers/staging/rtl8192u/r8192U_dm.c b/drivers/staging/rtl8192u/r8192U_dm.c
index 12dd19e1159bd4..416a1ddb3ac575 100644
--- a/drivers/staging/rtl8192u/r8192U_dm.c
+++ b/drivers/staging/rtl8192u/r8192U_dm.c
@@ -120,7 +120,7 @@ static void dm_ctstoself(struct net_device *dev);
* Prepare SW resource for HW dynamic mechanism.
*
* Assumption:
- * This function is only invoked at driver intialization once.
+ * This function is only invoked at driver initialization once.
*/
void init_hal_dm(struct net_device *dev)
{
diff --git a/drivers/staging/rtl8712/ieee80211.h b/drivers/staging/rtl8712/ieee80211.h
index 8269be80437ac7..6e813a9c1aa26d 100644
--- a/drivers/staging/rtl8712/ieee80211.h
+++ b/drivers/staging/rtl8712/ieee80211.h
@@ -314,35 +314,6 @@ struct ieee80211_snap_hdr {
#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7)
#define WLAN_CAPABILITY_SHORT_SLOT (1<<10)
-/* Status codes */
-#define WLAN_STATUS_SUCCESS 0
-#define WLAN_STATUS_UNSPECIFIED_FAILURE 1
-#define WLAN_STATUS_CAPS_UNSUPPORTED 10
-#define WLAN_STATUS_REASSOC_NO_ASSOC 11
-#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12
-#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13
-#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14
-#define WLAN_STATUS_CHALLENGE_FAIL 15
-#define WLAN_STATUS_AUTH_TIMEOUT 16
-#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17
-#define WLAN_STATUS_ASSOC_DENIED_RATES 18
-/* 802.11b */
-#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19
-#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20
-#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21
-
-/* Reason codes */
-#define WLAN_REASON_UNSPECIFIED 1
-#define WLAN_REASON_PREV_AUTH_NOT_VALID 2
-#define WLAN_REASON_DEAUTH_LEAVING 3
-#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4
-#define WLAN_REASON_DISASSOC_AP_BUSY 5
-#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6
-#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7
-#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8
-#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9
-
-
/* Information Element IDs */
#define WLAN_EID_SSID 0
#define WLAN_EID_SUPP_RATES 1
diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c
index 6e776e5433f67b..5d551a1ba3dc44 100644
--- a/drivers/staging/rtl8712/os_intfs.c
+++ b/drivers/staging/rtl8712/os_intfs.c
@@ -122,13 +122,11 @@ module_param(low_power, int, 0644);
MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default");
MODULE_PARM_DESC(initmac, "MAC-Address, default: use FUSE");
-static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev);
static int netdev_open(struct net_device *pnetdev);
static int netdev_close(struct net_device *pnetdev);
-static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev)
+static void loadparam(struct _adapter *padapter, struct net_device *pnetdev)
{
- uint status = _SUCCESS;
struct registry_priv *registry_par = &padapter->registrypriv;
registry_par->chip_version = (u8)chip_version;
@@ -172,7 +170,6 @@ static uint loadparam(struct _adapter *padapter, struct net_device *pnetdev)
registry_par->low_power = (u8)low_power;
registry_par->wifi_test = (u8) wifi_test;
r8712_initmac = initmac;
- return status;
}
static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
@@ -181,7 +178,7 @@ static int r871x_net_set_mac_address(struct net_device *pnetdev, void *p)
struct sockaddr *addr = p;
if (padapter->bup == false)
- memcpy(pnetdev->dev_addr, addr->sa_data, ETH_ALEN);
+ ether_addr_copy(pnetdev->dev_addr, addr->sa_data);
return 0;
}
@@ -228,7 +225,6 @@ struct net_device *r8712_init_netdev(void)
pnetdev->watchdog_timeo = HZ; /* 1 second timeout */
pnetdev->wireless_handlers = (struct iw_handler_def *)
&r871x_handlers_def;
- /*step 2.*/
loadparam(padapter, pnetdev);
netif_carrier_off(pnetdev);
padapter->pid = 0; /* Initial the PID value used for HW PBC.*/
diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index 50227b598e0c3c..fcb8c61b28844f 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -1056,7 +1056,8 @@ static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb)
/* for first fragment packet, driver need allocate 1536 +
* drvinfo_sz + RXDESC_SIZE to defrag packet. */
if ((mf == 1) && (frag == 0))
- alloc_sz = 1658;/*1658+6=1664, 1664 is 128 alignment.*/
+ /*1658+6=1664, 1664 is 128 alignment.*/
+ alloc_sz = max_t(u16, tmp_len, 1658);
else
alloc_sz = tmp_len;
/* 2 is for IP header 4 bytes alignment in QoS packet case.
diff --git a/drivers/staging/rtl8712/rtl8712_xmit.c b/drivers/staging/rtl8712/rtl8712_xmit.c
index a3093ac1204bfd..8c756df0438dc1 100644
--- a/drivers/staging/rtl8712/rtl8712_xmit.c
+++ b/drivers/staging/rtl8712/rtl8712_xmit.c
@@ -340,7 +340,7 @@ u8 r8712_append_mpdu_unit(struct xmit_buf *pxmitbuf,
u8 r8712_xmitframe_aggr_1st(struct xmit_buf *pxmitbuf,
struct xmit_frame *pxmitframe)
{
- /* linux complete context doesnt need to protect */
+ /* linux complete context doesn't need to protect */
pxmitframe->pxmitbuf = pxmitbuf;
pxmitbuf->priv_data = pxmitframe;
pxmitframe->pxmit_urb[0] = pxmitbuf->pxmit_urb[0];
diff --git a/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h b/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
index 8e2586231ffd49..2e9120a21a0be8 100644
--- a/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
+++ b/drivers/staging/rtl8712/rtl871x_mp_phy_regdef.h
@@ -603,7 +603,7 @@
#define bCCKRxIG 0x7f00
#define bCCKLNAPolarity 0x800000
#define bCCKRx1stGain 0x7f0000
-#define bCCKRFExtend 0x20000000 /* CCK Rx inital gain polarity */
+#define bCCKRFExtend 0x20000000 /* CCK Rx initial gain polarity */
#define bCCKRxAGCSatLevel 0x1f000000
#define bCCKRxAGCSatCount 0xe0
#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */
diff --git a/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c b/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c
index ae090ab115856d..0a3d96e840ccdb 100644
--- a/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c
+++ b/drivers/staging/rtl8723au/hal/HalPwrSeqCmd.c
@@ -92,7 +92,7 @@ u8 HalPwrSeqCmdParsing23a(struct rtw_adapter *padapter, u8 CutVersion,
value |= (GET_PWR_CFG_VALUE(PwrCfgCmd) &
GET_PWR_CFG_MASK(PwrCfgCmd));
- /* Write the value back to sytem register */
+ /* Write the value back to system register */
rtl8723au_write8(padapter, offset, value);
break;
diff --git a/drivers/staging/rtl8723au/hal/odm.c b/drivers/staging/rtl8723au/hal/odm.c
index ec543cfe1b45d2..f354f5e11a3028 100644
--- a/drivers/staging/rtl8723au/hal/odm.c
+++ b/drivers/staging/rtl8723au/hal/odm.c
@@ -40,7 +40,7 @@ static u32 EDCAParam[HT_IOT_PEER_MAX][3] = { /* UL DL */
{0x5ea42b, 0xa630, 0x5e431c}, /* 11:airgocap AP */
};
-/* EDCA Paramter for AP/ADSL by Mingzhi 2011-11-22 */
+/* EDCA Parameter for AP/ADSL by Mingzhi 2011-11-22 */
/* Global var */
u32 OFDMSwingTable23A[OFDM_TABLE_SIZE_92D] = {
@@ -388,7 +388,7 @@ void odm_CommonInfoSelfInit23a(struct dm_odm_t *pDM_Odm)
pDM_Odm->bCckHighPower = true;
else
pDM_Odm->bCckHighPower = false;
-
+
pDM_Odm->RFPathRxEnable =
rtl8723au_read32(pDM_Odm->Adapter, rOFDM0_TRxPathEnable) & 0x0F;
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
index 11e1108d0c56f1..9733aa6ef908c4 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_cmd.c
@@ -55,7 +55,7 @@ int FillH2CCmd(struct rtw_adapter *padapter, u8 ElementID, u32 CmdLen,
u8 h2c_box_num;
u32 msgbox_addr;
u32 msgbox_ex_addr;
- struct hal_data_8723a *pHalData = GET_HAL_DATA(padapter);
+ struct hal_data_8723a *pHalData;
u32 h2c_cmd = 0;
u16 h2c_cmd_ex = 0;
int ret = _FAIL;
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
index 04d01833dc3044..cb5076abda8bc1 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
@@ -1396,7 +1396,7 @@ static void _DisableAnalog(struct rtw_adapter *padapter, bool bWithoutHWSM)
/* value16 |= (APDM_HOST | FSM_HSUS |/PFM_ALDN); */
/* 2010/08/31 According to Filen description, we need to
use HW to shut down 8051 automatically. */
- /* Becasue suspend operatione need the asistance of 8051
+ /* Because suspend operation need the asistance of 8051
to wait for 3ms. */
value16 = APDM_HOST | AFSM_HSUS | PFM_ALDN;
} else {
@@ -1485,7 +1485,7 @@ void Hal_EfuseParseIDCode(struct rtw_adapter *padapter, u8 *hwinfo)
u16 EEPROMId;
/* Checl 0x8129 again for making sure autoload status!! */
- EEPROMId = le16_to_cpu(*((u16 *) hwinfo));
+ EEPROMId = le16_to_cpu(*((__le16 *) hwinfo));
if (EEPROMId != RTL_EEPROM_ID) {
DBG_8723A("EEPROM ID(%#x) is invalid!!\n", EEPROMId);
pEEPROM->bautoload_fail_flag = true;
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c
index 46a30659c96f5f..7fa97808b9511a 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_phycfg.c
@@ -660,7 +660,7 @@ phy_BB8723a_Config_ParaFile(struct rtw_adapter *Adapter)
/* */
/* 1. Read PHY_REG.TXT BB INIT!! */
- /* We will seperate as 88C / 92C according to chip version */
+ /* We will separate as 88C / 92C according to chip version */
/* */
ODM_ReadAndConfig_PHY_REG_1T_8723A(&pHalData->odmpriv);
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c
index 3e3f18634ffef5..4909835cc5409b 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_rf6052.c
@@ -138,7 +138,7 @@ void rtl823a_phy_rf6052setccktxpower(struct rtw_adapter *Adapter,
/* Currently, we cannot fully disable driver dynamic tx power
* mechanism because it is referenced by BT coexist mechanism. */
/* In the future, two mechanism shall be separated from each other
- * and maintained independantly. Thanks for Lanhsin's reminder. */
+ * and maintained independently. Thanks for Lanhsin's reminder. */
if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) {
TxAGC[RF_PATH_A] = 0x10101010;
TxAGC[RF_PATH_B] = 0x10101010;
@@ -300,7 +300,7 @@ getTxPowerWriteValByRegulatory(struct rtw_adapter *Adapter, u8 Channel,
/* Currently, we cannot fully disable driver dynamic tx power mechanism
because it is referenced by BT coexist mechanism. */
/* In the future, two mechanism shall be separated from each other and
- maintained independantly. Thanks for Lanhsin's reminder. */
+ maintained independently. Thanks for Lanhsin's reminder. */
if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1)
writeVal = 0x14141414;
diff --git a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
index 6bf87fe866445a..14746dd8db7830 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723au_xmit.c
@@ -252,7 +252,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz)
}
/* (1) The sequence number of each non-Qos frame / broadcast / multicast / */
- /* mgnt frame should be controled by Hw because Fw will also send null data */
+ /* mgnt frame should be controlled by Hw because Fw will also send null data */
/* which we cannot control when Fw LPS enable. */
/* --> default enable non-Qos data sequense number. 2010.06.23. by tynli. */
/* (2) Enable HW SEQ control for beacon packet, because we use Hw beacon. */
diff --git a/drivers/staging/rtl8723au/hal/usb_halinit.c b/drivers/staging/rtl8723au/hal/usb_halinit.c
index 42ae29d26302d4..68156a13d00f01 100644
--- a/drivers/staging/rtl8723au/hal/usb_halinit.c
+++ b/drivers/staging/rtl8723au/hal/usb_halinit.c
@@ -360,7 +360,7 @@ static void _InitWMACSetting(struct rtw_adapter *Adapter)
/* 2010.09.08 hpfan */
/* Since ADF is removed from RCR, ps-poll will not be indicate
to driver, */
- /* RxFilterMap should mask ps-poll to gurantee AP mode can
+ /* RxFilterMap should mask ps-poll to guarantee AP mode can
rx ps-poll. */
/* value16 = 0x400; */
/* rtl8723au_write16(Adapter, REG_RXFLTMAP1, value16); */
diff --git a/drivers/staging/rtl8723au/include/odm_debug.h b/drivers/staging/rtl8723au/include/odm_debug.h
index 83be5bab9e0909..c4b375a6f40980 100644
--- a/drivers/staging/rtl8723au/include/odm_debug.h
+++ b/drivers/staging/rtl8723au/include/odm_debug.h
@@ -22,7 +22,7 @@
/* Define the debug levels */
/* */
/* 1. DBG_TRACE and DBG_LOUD are used for normal cases. */
-/* So that, they can help SW engineer to develope or trace states changed */
+/* So that, they can help SW engineer to develop or trace states changed */
/* and also help HW enginner to trace every operation to and from HW, */
/* e.g IO, Tx, Rx. */
/* */
diff --git a/drivers/staging/rtl8723au/include/rtl8723a_hal.h b/drivers/staging/rtl8723au/include/rtl8723a_hal.h
index ad3a442bc000cb..8ee301b44f0f86 100644
--- a/drivers/staging/rtl8723au/include/rtl8723a_hal.h
+++ b/drivers/staging/rtl8723au/include/rtl8723a_hal.h
@@ -193,7 +193,7 @@ enum ChannelPlan
/* | | Reserved(14bytes) | */
/* */
-/* PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte. */
+/* PG data exclude header, dummy 6 bytes from CP test and reserved 1byte. */
#define EFUSE_OOB_PROTECT_BYTES 15
#define EFUSE_REAL_CONTENT_LEN_8723A 512
diff --git a/drivers/staging/rtl8723au/include/rtw_cmd.h b/drivers/staging/rtl8723au/include/rtw_cmd.h
index 775dcdc1e7b9a8..4dcc9253be5155 100644
--- a/drivers/staging/rtl8723au/include/rtw_cmd.h
+++ b/drivers/staging/rtl8723au/include/rtw_cmd.h
@@ -657,7 +657,7 @@ struct TDLSoption_param {
Result:
0x00: success
-0x01: sucess, and check Response.
+0x01: success, and check Response.
0x02: cmd ignored due to duplicated sequcne number
0x03: cmd dropped due to invalid cmd code
0x04: reserved.
diff --git a/drivers/staging/rtl8723au/include/rtw_mlme.h b/drivers/staging/rtl8723au/include/rtw_mlme.h
index a6751f138336de..dbd3a5f5c52333 100644
--- a/drivers/staging/rtl8723au/include/rtw_mlme.h
+++ b/drivers/staging/rtl8723au/include/rtw_mlme.h
@@ -50,11 +50,11 @@
#define WIFI_SITE_MONITOR 0x00000800
#define WIFI_MP_STATE 0x00010000
-#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continous tx background */
-#define WIFI_MP_CTX_ST 0x00040000 /* in continous tx with single-tone */
-#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continous tx background due to out of skb */
-#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continous tx */
-#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continous tx with carrier suppression */
+#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continuous tx background */
+#define WIFI_MP_CTX_ST 0x00040000 /* in continuous tx with single-tone */
+#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continuous tx background due to out of skb */
+#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continuous tx */
+#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continuous tx with carrier suppression */
#define WIFI_MP_LPBK_STATE 0x00400000
#define _FW_UNDER_LINKING WIFI_UNDER_LINKING
diff --git a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
index ffb37b252fc17b..ea2a6c914d38c5 100644
--- a/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
+++ b/drivers/staging/rtl8723au/include/rtw_mlme_ext.h
@@ -103,7 +103,7 @@ extern unsigned char WMM_PARA_OUI23A[];
/* Note: */
/* We just add new channel plan when the new channel plan is different from any of the following */
/* channel plan. */
-/* If you just wnat to customize the acitions(scan period or join actions) about one of the channel plan, */
+/* If you just want to customize the actions(scan period or join actions) about one of the channel plan, */
/* customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */
/* */
enum { /* _RT_CHANNEL_DOMAIN */
diff --git a/drivers/staging/rtl8723au/include/sta_info.h b/drivers/staging/rtl8723au/include/sta_info.h
index c756b4f7f5d52a..e7260050e533f2 100644
--- a/drivers/staging/rtl8723au/include/sta_info.h
+++ b/drivers/staging/rtl8723au/include/sta_info.h
@@ -332,7 +332,7 @@ struct sta_priv {
*/
struct sta_info *sta_aid[NUM_STA];
- u16 sta_dz_bitmap;/* only support 15 stations, staion aid bitmap
+ u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap
* for sleeping sta. */
u16 tim_bitmap;/* only support 15 stations,
* aid=0~15 mapping bit0~bit15 */
diff --git a/drivers/staging/rtl8723au/os_dep/os_intfs.c b/drivers/staging/rtl8723au/os_dep/os_intfs.c
index 83696360c2932d..b8848c25beb4e4 100644
--- a/drivers/staging/rtl8723au/os_dep/os_intfs.c
+++ b/drivers/staging/rtl8723au/os_dep/os_intfs.c
@@ -172,7 +172,7 @@ MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)");
static int netdev_close(struct net_device *pnetdev);
-static int loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev)
+static void loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev)
{
struct registry_priv *registry_par = &padapter->registrypriv;
@@ -233,7 +233,6 @@ static int loadparam(struct rtw_adapter *padapter, struct net_device *pnetdev)
snprintf(registry_par->if2name, 16, "%s", if2name);
registry_par->notch_filter = (u8)rtw_notch_filter;
registry_par->regulatory_tid = (u8)rtw_regulatory_id;
- return _SUCCESS;
}
static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p)
@@ -372,7 +371,6 @@ struct net_device *rtw_init_netdev23a(struct rtw_adapter *old_padapter)
pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */
- /* step 2. */
loadparam(padapter, pnetdev);
return pnetdev;
}
diff --git a/drivers/staging/rts5208/rtsx.c b/drivers/staging/rts5208/rtsx.c
index d64b6ed9c0c967..1bcadba07fd0f9 100644
--- a/drivers/staging/rts5208/rtsx.c
+++ b/drivers/staging/rts5208/rtsx.c
@@ -537,7 +537,7 @@ static int rtsx_polling_thread(void *__dev)
for (;;) {
set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(POLLING_INTERVAL);
+ schedule_timeout(msecs_to_jiffies(POLLING_INTERVAL));
/* lock the device pointers */
mutex_lock(&(dev->dev_mutex));
diff --git a/drivers/staging/rts5208/rtsx.h b/drivers/staging/rts5208/rtsx.h
index 262441bcfc41ab..aa1e034f7f4552 100644
--- a/drivers/staging/rts5208/rtsx.h
+++ b/drivers/staging/rts5208/rtsx.h
@@ -37,7 +37,7 @@
#include <linux/cdrom.h>
#include <linux/workqueue.h>
#include <linux/timer.h>
-#include <linux/time.h>
+#include <linux/time64.h>
#include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h>
@@ -148,21 +148,24 @@ static inline struct rtsx_dev *host_to_rtsx(struct Scsi_Host *host)
static inline void get_current_time(u8 *timeval_buf, int buf_len)
{
- struct timeval tv;
+ struct timespec64 ts64;
+ u32 tv_usec;
if (!timeval_buf || (buf_len < 8))
return;
- do_gettimeofday(&tv);
+ getnstimeofday64(&ts64);
- timeval_buf[0] = (u8)(tv.tv_sec >> 24);
- timeval_buf[1] = (u8)(tv.tv_sec >> 16);
- timeval_buf[2] = (u8)(tv.tv_sec >> 8);
- timeval_buf[3] = (u8)(tv.tv_sec);
- timeval_buf[4] = (u8)(tv.tv_usec >> 24);
- timeval_buf[5] = (u8)(tv.tv_usec >> 16);
- timeval_buf[6] = (u8)(tv.tv_usec >> 8);
- timeval_buf[7] = (u8)(tv.tv_usec);
+ tv_usec = ts64.tv_nsec/NSEC_PER_USEC;
+
+ timeval_buf[0] = (u8)(ts64.tv_sec >> 24);
+ timeval_buf[1] = (u8)(ts64.tv_sec >> 16);
+ timeval_buf[2] = (u8)(ts64.tv_sec >> 8);
+ timeval_buf[3] = (u8)(ts64.tv_sec);
+ timeval_buf[4] = (u8)(tv_usec >> 24);
+ timeval_buf[5] = (u8)(tv_usec >> 16);
+ timeval_buf[6] = (u8)(tv_usec >> 8);
+ timeval_buf[7] = (u8)(tv_usec);
}
/* The scsi_lock() and scsi_unlock() macros protect the sm_state and the
diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c
index 8a5d6a8e780f3a..60871f3022b1c8 100644
--- a/drivers/staging/rts5208/rtsx_scsi.c
+++ b/drivers/staging/rts5208/rtsx_scsi.c
@@ -915,6 +915,8 @@ static int read_write(struct scsi_cmnd *srb, struct rtsx_chip *chip)
start_sec = ((u32)(srb->cmnd[1] & 0x1F) << 16) |
((u32)srb->cmnd[2] << 8) | ((u32)srb->cmnd[3]);
sec_cnt = srb->cmnd[4];
+ if (sec_cnt == 0)
+ sec_cnt = 256;
} else if ((srb->cmnd[0] == VENDOR_CMND) &&
(srb->cmnd[1] == SCSI_APP_CMD) &&
((srb->cmnd[2] == PP_READ10) || (srb->cmnd[2] == PP_WRITE10))) {
@@ -2904,9 +2906,11 @@ void led_shine(struct scsi_cmnd *srb, struct rtsx_chip *chip)
if ((srb->cmnd[0] == READ_10) || (srb->cmnd[0] == WRITE_10))
sec_cnt = ((u16)(srb->cmnd[7]) << 8) | srb->cmnd[8];
- else if ((srb->cmnd[0] == READ_6) || (srb->cmnd[0] == WRITE_6))
+ else if ((srb->cmnd[0] == READ_6) || (srb->cmnd[0] == WRITE_6)) {
sec_cnt = srb->cmnd[4];
- else
+ if (sec_cnt == 0)
+ sec_cnt = 256;
+ } else
return;
if (chip->rw_cap[lun] >= GPIO_TOGGLE_THRESHOLD) {
diff --git a/drivers/staging/skein/skein_api.h b/drivers/staging/skein/skein_api.h
index 171b87549548fa..7da8b386a28c4e 100644
--- a/drivers/staging/skein/skein_api.h
+++ b/drivers/staging/skein/skein_api.h
@@ -121,7 +121,7 @@ struct skein_ctx {
* @param size
* Which Skein size to use.
* @return
- * SKEIN_SUCESS of SKEIN_FAIL
+ * SKEIN_SUCCESS of SKEIN_FAIL
*/
int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size);
@@ -136,7 +136,7 @@ int skein_ctx_prepare(struct skein_ctx *ctx, enum skein_size size);
* @param hash_bit_len
* Number of MAC hash bits to compute
* @return
- * SKEIN_SUCESS of SKEIN_FAIL
+ * SKEIN_SUCCESS of SKEIN_FAIL
* @see skein_reset
*/
int skein_init(struct skein_ctx *ctx, size_t hash_bit_len);
@@ -171,7 +171,7 @@ void skein_reset(struct skein_ctx *ctx);
* @param hash_bit_len
* Number of MAC hash bits to compute
* @return
- * SKEIN_SUCESS of SKEIN_FAIL
+ * SKEIN_SUCCESS of SKEIN_FAIL
*/
int skein_mac_init(struct skein_ctx *ctx, const u8 *key, size_t key_len,
size_t hash_bit_len);
diff --git a/drivers/staging/slicoss/TODO b/drivers/staging/slicoss/TODO
index 20cc9abdc46691..9019729b7be690 100644
--- a/drivers/staging/slicoss/TODO
+++ b/drivers/staging/slicoss/TODO
@@ -25,7 +25,6 @@ TODO:
- state variables for things that are
easily available and shouldn't be kept in card structure, cardnum, ...
slotnumber, events, ...
- - get rid of slic_spinlock wrapper
- volatile == bad design => bad code
- locking too fine grained, not designed just throw more locks
at problem
diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index 3a5aa882b957c5..67a8c9eb2dca6f 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -56,11 +56,6 @@ static u32 OasisRcvUCodeLen = 512;
static u32 GBRcvUCodeLen = 512;
#define SECTION_SIZE 65536
-struct slic_spinlock {
- spinlock_t lock;
- unsigned long flags;
-};
-
#define SLIC_RSPQ_PAGES_GB 10
#define SLIC_RSPQ_BUFSINPAGE (PAGE_SIZE / SLIC_RSPBUF_SIZE)
@@ -165,7 +160,7 @@ struct slic_cmdqueue {
struct slic_hostcmd *head;
struct slic_hostcmd *tail;
int count;
- struct slic_spinlock lock;
+ spinlock_t lock;
};
#define SLIC_MAX_CARDS 32
@@ -346,7 +341,7 @@ struct physcard {
};
struct base_driver {
- struct slic_spinlock driver_lock;
+ spinlock_t driver_lock;
u32 num_slic_cards;
u32 num_slic_ports;
u32 num_slic_ports_active;
@@ -401,8 +396,8 @@ struct adapter {
uint card_size;
uint chipid;
struct net_device *netdev;
- struct slic_spinlock adapter_lock;
- struct slic_spinlock reset_lock;
+ spinlock_t adapter_lock;
+ spinlock_t reset_lock;
struct pci_dev *pcidev;
uint busnumber;
uint slotnumber;
@@ -419,7 +414,6 @@ struct adapter {
u32 intrregistered;
uint isp_initialized;
uint gennumber;
- u32 curaddrupper;
struct slic_shmem *pshmem;
dma_addr_t phys_shmem;
u32 isrcopy;
@@ -441,8 +435,8 @@ struct adapter {
u32 pingtimerset;
struct timer_list loadtimer;
u32 loadtimerset;
- struct slic_spinlock upr_lock;
- struct slic_spinlock bit64reglock;
+ spinlock_t upr_lock;
+ spinlock_t bit64reglock;
struct slic_rspqueue rspqueue;
struct slic_rcvqueue rcvqueue;
struct slic_cmdqueue cmdq_free;
@@ -457,7 +451,7 @@ struct adapter {
/* Free object handles*/
struct slic_handle *pfree_slic_handles;
/* Object handle list lock*/
- struct slic_spinlock handle_lock;
+ spinlock_t handle_lock;
ushort slic_handle_ix;
u32 xmitq_full;
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index c2bda1d38e41c1..a609f3e67256ab 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -144,17 +144,14 @@ static inline void slic_reg64_write(struct adapter *adapter, void __iomem *reg,
u32 value, void __iomem *regh, u32 paddrh,
bool flush)
{
- spin_lock_irqsave(&adapter->bit64reglock.lock,
- adapter->bit64reglock.flags);
- if (paddrh != adapter->curaddrupper) {
- adapter->curaddrupper = paddrh;
- writel(paddrh, regh);
- }
+ unsigned long flags;
+
+ spin_lock_irqsave(&adapter->bit64reglock, flags);
+ writel(paddrh, regh);
writel(value, reg);
if (flush)
mb();
- spin_unlock_irqrestore(&adapter->bit64reglock.lock,
- adapter->bit64reglock.flags);
+ spin_unlock_irqrestore(&adapter->bit64reglock, flags);
}
static void slic_mcast_set_bit(struct adapter *adapter, char *address)
@@ -936,9 +933,10 @@ static int slic_upr_request(struct adapter *adapter,
u32 upr_data_h,
u32 upr_buffer, u32 upr_buffer_h)
{
+ unsigned long flags;
int rc;
- spin_lock_irqsave(&adapter->upr_lock.lock, adapter->upr_lock.flags);
+ spin_lock_irqsave(&adapter->upr_lock, flags);
rc = slic_upr_queue_request(adapter,
upr_request,
upr_data,
@@ -948,8 +946,7 @@ static int slic_upr_request(struct adapter *adapter,
slic_upr_start(adapter);
err_unlock_irq:
- spin_unlock_irqrestore(&adapter->upr_lock.lock,
- adapter->upr_lock.flags);
+ spin_unlock_irqrestore(&adapter->upr_lock, flags);
return rc;
}
@@ -1029,12 +1026,12 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
{
struct sliccard *card = adapter->card;
struct slic_upr *upr;
+ unsigned long flags;
- spin_lock_irqsave(&adapter->upr_lock.lock, adapter->upr_lock.flags);
+ spin_lock_irqsave(&adapter->upr_lock, flags);
upr = adapter->upr_list;
if (!upr) {
- spin_unlock_irqrestore(&adapter->upr_lock.lock,
- adapter->upr_lock.flags);
+ spin_unlock_irqrestore(&adapter->upr_lock, flags);
return;
}
adapter->upr_list = upr->next;
@@ -1127,8 +1124,7 @@ static void slic_upr_request_complete(struct adapter *adapter, u32 isr)
}
kfree(upr);
slic_upr_start(adapter);
- spin_unlock_irqrestore(&adapter->upr_lock.lock,
- adapter->upr_lock.flags);
+ spin_unlock_irqrestore(&adapter->upr_lock, flags);
}
static int slic_config_get(struct adapter *adapter, u32 config, u32 config_h)
@@ -1310,6 +1306,7 @@ static void slic_cmdq_addcmdpage(struct adapter *adapter, u32 *page)
u32 phys_addrl;
u32 phys_addrh;
struct slic_handle *pslic_handle;
+ unsigned long flags;
cmdaddr = page;
cmd = (struct slic_hostcmd *)cmdaddr;
@@ -1324,12 +1321,10 @@ static void slic_cmdq_addcmdpage(struct adapter *adapter, u32 *page)
while ((cmdcnt < SLIC_CMDQ_CMDSINPAGE) &&
(adapter->slic_handle_ix < 256)) {
/* Allocate and initialize a SLIC_HANDLE for this command */
- spin_lock_irqsave(&adapter->handle_lock.lock,
- adapter->handle_lock.flags);
+ spin_lock_irqsave(&adapter->handle_lock, flags);
pslic_handle = adapter->pfree_slic_handles;
adapter->pfree_slic_handles = pslic_handle->next;
- spin_unlock_irqrestore(&adapter->handle_lock.lock,
- adapter->handle_lock.flags);
+ spin_unlock_irqrestore(&adapter->handle_lock, flags);
pslic_handle->type = SLIC_HANDLE_CMD;
pslic_handle->address = (void *) cmd;
pslic_handle->offset = (ushort) adapter->slic_handle_ix++;
@@ -1356,11 +1351,11 @@ static void slic_cmdq_addcmdpage(struct adapter *adapter, u32 *page)
tail->next_all = cmdq->head;
cmdq->head = prev;
cmdq = &adapter->cmdq_free;
- spin_lock_irqsave(&cmdq->lock.lock, cmdq->lock.flags);
+ spin_lock_irqsave(&cmdq->lock, flags);
cmdq->count += cmdcnt; /* SLIC_CMDQ_CMDSINPAGE; mooktodo */
tail->next = cmdq->head;
cmdq->head = prev;
- spin_unlock_irqrestore(&cmdq->lock.lock, cmdq->lock.flags);
+ spin_unlock_irqrestore(&cmdq->lock, flags);
}
static int slic_cmdq_init(struct adapter *adapter)
@@ -1371,9 +1366,9 @@ static int slic_cmdq_init(struct adapter *adapter)
memset(&adapter->cmdq_all, 0, sizeof(struct slic_cmdqueue));
memset(&adapter->cmdq_free, 0, sizeof(struct slic_cmdqueue));
memset(&adapter->cmdq_done, 0, sizeof(struct slic_cmdqueue));
- spin_lock_init(&adapter->cmdq_all.lock.lock);
- spin_lock_init(&adapter->cmdq_free.lock.lock);
- spin_lock_init(&adapter->cmdq_done.lock.lock);
+ spin_lock_init(&adapter->cmdq_all.lock);
+ spin_lock_init(&adapter->cmdq_free.lock);
+ spin_lock_init(&adapter->cmdq_done.lock);
memset(&adapter->cmdqmem, 0, sizeof(struct slic_cmdqmem));
adapter->slic_handle_ix = 1;
for (i = 0; i < SLIC_CMDQ_INITPAGES; i++) {
@@ -1394,11 +1389,10 @@ static void slic_cmdq_reset(struct adapter *adapter)
struct slic_hostcmd *hcmd;
struct sk_buff *skb;
u32 outstanding;
+ unsigned long flags;
- spin_lock_irqsave(&adapter->cmdq_free.lock.lock,
- adapter->cmdq_free.lock.flags);
- spin_lock_irqsave(&adapter->cmdq_done.lock.lock,
- adapter->cmdq_done.lock.flags);
+ spin_lock_irqsave(&adapter->cmdq_free.lock, flags);
+ spin_lock(&adapter->cmdq_done.lock);
outstanding = adapter->cmdq_all.count - adapter->cmdq_done.count;
outstanding -= adapter->cmdq_free.count;
hcmd = adapter->cmdq_all.head;
@@ -1429,40 +1423,40 @@ static void slic_cmdq_reset(struct adapter *adapter)
"free_count %d != all count %d\n",
adapter->cmdq_free.count, adapter->cmdq_all.count);
}
- spin_unlock_irqrestore(&adapter->cmdq_done.lock.lock,
- adapter->cmdq_done.lock.flags);
- spin_unlock_irqrestore(&adapter->cmdq_free.lock.lock,
- adapter->cmdq_free.lock.flags);
+ spin_unlock(&adapter->cmdq_done.lock);
+ spin_unlock_irqrestore(&adapter->cmdq_free.lock, flags);
}
static void slic_cmdq_getdone(struct adapter *adapter)
{
struct slic_cmdqueue *done_cmdq = &adapter->cmdq_done;
struct slic_cmdqueue *free_cmdq = &adapter->cmdq_free;
+ unsigned long flags;
- spin_lock_irqsave(&done_cmdq->lock.lock, done_cmdq->lock.flags);
+ spin_lock_irqsave(&done_cmdq->lock, flags);
free_cmdq->head = done_cmdq->head;
free_cmdq->count = done_cmdq->count;
done_cmdq->head = NULL;
done_cmdq->tail = NULL;
done_cmdq->count = 0;
- spin_unlock_irqrestore(&done_cmdq->lock.lock, done_cmdq->lock.flags);
+ spin_unlock_irqrestore(&done_cmdq->lock, flags);
}
static struct slic_hostcmd *slic_cmdq_getfree(struct adapter *adapter)
{
struct slic_cmdqueue *cmdq = &adapter->cmdq_free;
struct slic_hostcmd *cmd = NULL;
+ unsigned long flags;
lock_and_retry:
- spin_lock_irqsave(&cmdq->lock.lock, cmdq->lock.flags);
+ spin_lock_irqsave(&cmdq->lock, flags);
retry:
cmd = cmdq->head;
if (cmd) {
cmdq->head = cmd->next;
cmdq->count--;
- spin_unlock_irqrestore(&cmdq->lock.lock, cmdq->lock.flags);
+ spin_unlock_irqrestore(&cmdq->lock, flags);
} else {
slic_cmdq_getdone(adapter);
cmd = cmdq->head;
@@ -1471,8 +1465,7 @@ retry:
} else {
u32 *pageaddr;
- spin_unlock_irqrestore(&cmdq->lock.lock,
- cmdq->lock.flags);
+ spin_unlock_irqrestore(&cmdq->lock, flags);
pageaddr = slic_cmdqmem_addpage(adapter);
if (pageaddr) {
slic_cmdq_addcmdpage(adapter, pageaddr);
@@ -1488,14 +1481,14 @@ static void slic_cmdq_putdone_irq(struct adapter *adapter,
{
struct slic_cmdqueue *cmdq = &adapter->cmdq_done;
- spin_lock(&cmdq->lock.lock);
+ spin_lock(&cmdq->lock);
cmd->busy = 0;
cmd->next = cmdq->head;
cmdq->head = cmd;
cmdq->count++;
if ((adapter->xmitq_full) && (cmdq->count > 10))
netif_wake_queue(adapter->netdev);
- spin_unlock(&cmdq->lock.lock);
+ spin_unlock(&cmdq->lock);
}
static int slic_rcvqueue_fill(struct adapter *adapter)
@@ -2250,21 +2243,20 @@ static void slic_adapter_freeresources(struct adapter *adapter)
adapter->rcv_unicasts = 0;
}
-static int slic_adapter_allocresources(struct adapter *adapter)
+static int slic_adapter_allocresources(struct adapter *adapter,
+ unsigned long *flags)
{
if (!adapter->intrregistered) {
int retval;
- spin_unlock_irqrestore(&slic_global.driver_lock.lock,
- slic_global.driver_lock.flags);
+ spin_unlock_irqrestore(&slic_global.driver_lock, *flags);
retval = request_irq(adapter->netdev->irq,
&slic_interrupt,
IRQF_SHARED,
adapter->netdev->name, adapter->netdev);
- spin_lock_irqsave(&slic_global.driver_lock.lock,
- slic_global.driver_lock.flags);
+ spin_lock_irqsave(&slic_global.driver_lock, *flags);
if (retval) {
dev_err(&adapter->netdev->dev,
@@ -2283,7 +2275,7 @@ static int slic_adapter_allocresources(struct adapter *adapter)
* Perform initialization of our slic interface.
*
*/
-static int slic_if_init(struct adapter *adapter)
+static int slic_if_init(struct adapter *adapter, unsigned long *flags)
{
struct sliccard *card = adapter->card;
struct net_device *dev = adapter->netdev;
@@ -2311,7 +2303,7 @@ static int slic_if_init(struct adapter *adapter)
if (dev->flags & IFF_MULTICAST)
adapter->macopts |= MAC_MCAST;
}
- rc = slic_adapter_allocresources(adapter);
+ rc = slic_adapter_allocresources(adapter, flags);
if (rc) {
dev_err(&dev->dev, "slic_adapter_allocresources FAILED %x\n",
rc);
@@ -2336,11 +2328,11 @@ static int slic_if_init(struct adapter *adapter)
mdelay(1);
if (!adapter->isp_initialized) {
+ unsigned long flags;
pshmem = (struct slic_shmem *)(unsigned long)
adapter->phys_shmem;
- spin_lock_irqsave(&adapter->bit64reglock.lock,
- adapter->bit64reglock.flags);
+ spin_lock_irqsave(&adapter->bit64reglock, flags);
#if BITS_PER_LONG == 64
slic_reg32_write(&slic_regs->slic_addr_upper,
@@ -2352,8 +2344,7 @@ static int slic_if_init(struct adapter *adapter)
slic_reg32_write(&slic_regs->slic_isp, (u32)&pshmem->isr,
FLUSH);
#endif
- spin_unlock_irqrestore(&adapter->bit64reglock.lock,
- adapter->bit64reglock.flags);
+ spin_unlock_irqrestore(&adapter->bit64reglock, flags);
adapter->isp_initialized = 1;
}
@@ -2396,18 +2387,18 @@ static int slic_entry_open(struct net_device *dev)
{
struct adapter *adapter = netdev_priv(dev);
struct sliccard *card = adapter->card;
+ unsigned long flags;
int status;
netif_stop_queue(adapter->netdev);
- spin_lock_irqsave(&slic_global.driver_lock.lock,
- slic_global.driver_lock.flags);
+ spin_lock_irqsave(&slic_global.driver_lock, flags);
if (!adapter->activated) {
card->adapters_activated++;
slic_global.num_slic_ports_active++;
adapter->activated = 1;
}
- status = slic_if_init(adapter);
+ status = slic_if_init(adapter, &flags);
if (status != 0) {
if (adapter->activated) {
@@ -2421,8 +2412,7 @@ static int slic_entry_open(struct net_device *dev)
card->master = adapter;
spin_unlock:
- spin_unlock_irqrestore(&slic_global.driver_lock.lock,
- slic_global.driver_lock.flags);
+ spin_unlock_irqrestore(&slic_global.driver_lock, flags);
return status;
}
@@ -2481,9 +2471,9 @@ static int slic_entry_halt(struct net_device *dev)
struct adapter *adapter = netdev_priv(dev);
struct sliccard *card = adapter->card;
__iomem struct slic_regs *slic_regs = adapter->slic_regs;
+ unsigned long flags;
- spin_lock_irqsave(&slic_global.driver_lock.lock,
- slic_global.driver_lock.flags);
+ spin_lock_irqsave(&slic_global.driver_lock, flags);
netif_stop_queue(adapter->netdev);
adapter->state = ADAPT_DOWN;
adapter->linkstate = LINK_DOWN;
@@ -2512,8 +2502,7 @@ static int slic_entry_halt(struct net_device *dev)
slic_card_init(card, adapter);
#endif
- spin_unlock_irqrestore(&slic_global.driver_lock.lock,
- slic_global.driver_lock.flags);
+ spin_unlock_irqrestore(&slic_global.driver_lock, flags);
return 0;
}
@@ -2663,6 +2652,7 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter)
unsigned char oemfruformat;
struct atk_fru *patkfru;
union oemfru *poemfru;
+ unsigned long flags;
/* Reset everything except PCI configuration space */
slic_soft_reset(adapter);
@@ -2693,14 +2683,12 @@ static int slic_card_init(struct sliccard *card, struct adapter *adapter)
pshmem = (struct slic_shmem *)(unsigned long)
adapter->phys_shmem;
- spin_lock_irqsave(&adapter->bit64reglock.lock,
- adapter->bit64reglock.flags);
+ spin_lock_irqsave(&adapter->bit64reglock, flags);
slic_reg32_write(&slic_regs->slic_addr_upper,
SLIC_GET_ADDR_HIGH(&pshmem->isr), DONT_FLUSH);
slic_reg32_write(&slic_regs->slic_isp,
SLIC_GET_ADDR_LOW(&pshmem->isr), FLUSH);
- spin_unlock_irqrestore(&adapter->bit64reglock.lock,
- adapter->bit64reglock.flags);
+ spin_unlock_irqrestore(&adapter->bit64reglock, flags);
status = slic_config_get(adapter, phys_configl, phys_configh);
if (status) {
@@ -2854,7 +2842,7 @@ static void slic_init_driver(void)
{
if (slic_first_init) {
slic_first_init = 0;
- spin_lock_init(&slic_global.driver_lock.lock);
+ spin_lock_init(&slic_global.driver_lock);
}
}
@@ -2880,11 +2868,11 @@ static void slic_init_adapter(struct net_device *netdev,
adapter->chipid = chip_idx;
adapter->port = 0; /*adapter->functionnumber;*/
adapter->cardindex = adapter->port;
- spin_lock_init(&adapter->upr_lock.lock);
- spin_lock_init(&adapter->bit64reglock.lock);
- spin_lock_init(&adapter->adapter_lock.lock);
- spin_lock_init(&adapter->reset_lock.lock);
- spin_lock_init(&adapter->handle_lock.lock);
+ spin_lock_init(&adapter->upr_lock);
+ spin_lock_init(&adapter->bit64reglock);
+ spin_lock_init(&adapter->adapter_lock);
+ spin_lock_init(&adapter->reset_lock);
+ spin_lock_init(&adapter->handle_lock);
adapter->card_size = 1;
/*
diff --git a/drivers/staging/sm750fb/TODO b/drivers/staging/sm750fb/TODO
index bc16172493950d..a3a877d90066f9 100644
--- a/drivers/staging/sm750fb/TODO
+++ b/drivers/staging/sm750fb/TODO
@@ -1,7 +1,8 @@
TODO:
-- lots of clechpatch cleanup
+- lots of checkpatch cleanup
- use kernel coding style
- refine the code and remove unused code
+- Implement hardware acceleration for imageblit if image->depth > 1
- check on hardware effects of removal of USE_HW_I2C and USE_DVICHIP (these two
are supposed to be sample code which is given here if someone wants to
use those functionalities)
diff --git a/drivers/staging/sm750fb/ddk750_chip.c b/drivers/staging/sm750fb/ddk750_chip.c
index 7b28328c92f851..8b47c1bfc401c8 100644
--- a/drivers/staging/sm750fb/ddk750_chip.c
+++ b/drivers/staging/sm750fb/ddk750_chip.c
@@ -285,7 +285,7 @@ int ddk750_initHw(initchip_param_t *pInitParam)
ulReg = FIELD_SET(ulReg, VGA_CONFIGURATION, MODE, GRAPHIC);
POKE32(VGA_CONFIGURATION, ulReg);
} else {
-#if defined(__i386__) || defined( __x86_64__)
+#if defined(__i386__) || defined(__x86_64__)
/* set graphic mode via IO method */
outb_p(0x88, 0x3d4);
outb_p(0x06, 0x3d5);
@@ -382,7 +382,7 @@ int ddk750_initHw(initchip_param_t *pInitParam)
unsigned int absDiff(unsigned int a, unsigned int b)
{
- if ( a > b )
+ if (a > b)
return(a - b);
else
return(b - a);
@@ -616,7 +616,7 @@ unsigned int formatPllReg(pll_value_t *pPLL)
| FIELD_VALUE(0, PANEL_PLL_CTRL, N, pPLL->N)
| FIELD_VALUE(0, PANEL_PLL_CTRL, M, pPLL->M);
- return ulPllReg;
+ return ulPllReg;
}
diff --git a/drivers/staging/sm750fb/ddk750_chip.h b/drivers/staging/sm750fb/ddk750_chip.h
index 04cb0d55924583..83821de68f407e 100644
--- a/drivers/staging/sm750fb/ddk750_chip.h
+++ b/drivers/staging/sm750fb/ddk750_chip.h
@@ -10,10 +10,10 @@
/* This is all the chips recognized by this library */
typedef enum _logical_chip_type_t
{
- SM_UNKNOWN,
- SM718,
- SM750,
- SM750LE,
+ SM_UNKNOWN,
+ SM718,
+ SM750,
+ SM750LE,
}
logical_chip_type_t;
@@ -30,42 +30,47 @@ clock_type_t;
typedef struct _pll_value_t
{
- clock_type_t clockType;
- unsigned long inputFreq; /* Input clock frequency to the PLL */
+ clock_type_t clockType;
+ unsigned long inputFreq; /* Input clock frequency to the PLL */
- /* Use this when clockType = PANEL_PLL */
- unsigned long M;
- unsigned long N;
- unsigned long OD;
- unsigned long POD;
+ /* Use this when clockType = PANEL_PLL */
+ unsigned long M;
+ unsigned long N;
+ unsigned long OD;
+ unsigned long POD;
}
pll_value_t;
/* input struct to initChipParam() function */
typedef struct _initchip_param_t
{
- unsigned short powerMode; /* Use power mode 0 or 1 */
- unsigned short chipClock; /* Speed of main chip clock in MHz unit
- 0 = keep the current clock setting
- Others = the new main chip clock
- */
- unsigned short memClock; /* Speed of memory clock in MHz unit
- 0 = keep the current clock setting
- Others = the new memory clock
- */
- unsigned short masterClock; /* Speed of master clock in MHz unit
- 0 = keep the current clock setting
- Others = the new master clock
- */
- unsigned short setAllEngOff; /* 0 = leave all engine state untouched.
- 1 = make sure they are off: 2D, Overlay,
- video alpha, alpha, hardware cursors
- */
- unsigned char resetMemory; /* 0 = Do not reset the memory controller
- 1 = Reset the memory controller
- */
+ unsigned short powerMode; /* Use power mode 0 or 1 */
+ unsigned short chipClock; /**
+ * Speed of main chip clock in MHz unit
+ * 0 = keep the current clock setting
+ * Others = the new main chip clock
+ */
+ unsigned short memClock; /**
+ * Speed of memory clock in MHz unit
+ * 0 = keep the current clock setting
+ * Others = the new memory clock
+ */
+ unsigned short masterClock; /**
+ * Speed of master clock in MHz unit
+ * 0 = keep the current clock setting
+ * Others = the new master clock
+ */
+ unsigned short setAllEngOff; /**
+ * 0 = leave all engine state untouched.
+ * 1 = make sure they are off: 2D, Overlay,
+ * video alpha, alpha, hardware cursors
+ */
+ unsigned char resetMemory; /**
+ * 0 = Do not reset the memory controller
+ * 1 = Reset the memory controller
+ */
- /* More initialization parameter can be added if needed */
+ /* More initialization parameter can be added if needed */
}
initchip_param_t;
diff --git a/drivers/staging/sm750fb/ddk750_help.h b/drivers/staging/sm750fb/ddk750_help.h
index 07c8264fac95bd..e7e49cebd303bc 100644
--- a/drivers/staging/sm750fb/ddk750_help.h
+++ b/drivers/staging/sm750fb/ddk750_help.h
@@ -14,7 +14,7 @@
#warning "big endian on target cpu and enable nature big endian support of 718 capability !"
#define PEEK32(addr) __raw_readl(mmio750 + addr)
#define POKE32(addr,data) __raw_writel(data, mmio750 + addr)
-#else /* software control endianess */
+#else /* software control endianness */
#define PEEK32(addr) readl(addr + mmio750)
#define POKE32(addr,data) writel(data, addr + mmio750)
#endif
diff --git a/drivers/staging/sm750fb/ddk750_mode.c b/drivers/staging/sm750fb/ddk750_mode.c
index 2e418fb6ffde92..021d4c3b2b10fc 100644
--- a/drivers/staging/sm750fb/ddk750_mode.c
+++ b/drivers/staging/sm750fb/ddk750_mode.c
@@ -162,7 +162,7 @@ static int programModeRegisters(mode_parameter_t * pModeParam,pll_value_t * pll)
/* May a hardware bug or just my test chip (not confirmed).
* PANEL_DISPLAY_CTRL register seems requiring few writes
- * before a value can be succesfully written in.
+ * before a value can be successfully written in.
* Added some masks to mask out the reserved bits.
* Note: This problem happens by design. The hardware will wait for the
* next vertical sync to turn on/off the plane.
diff --git a/drivers/staging/sm750fb/ddk750_reg.h b/drivers/staging/sm750fb/ddk750_reg.h
index 2016f97d2a3d28..1a40dc2a2f759b 100644
--- a/drivers/staging/sm750fb/ddk750_reg.h
+++ b/drivers/staging/sm750fb/ddk750_reg.h
@@ -1885,10 +1885,10 @@
#define DISPLAY_CONTROL_750LE 0x80288
/* Palette RAM */
-/* Panel Pallete register starts at 0x080400 ~ 0x0807FC */
+/* Panel Palette register starts at 0x080400 ~ 0x0807FC */
#define PANEL_PALETTE_RAM 0x080400
-/* Panel Pallete register starts at 0x080C00 ~ 0x080FFC */
+/* Panel Palette register starts at 0x080C00 ~ 0x080FFC */
#define CRT_PALETTE_RAM 0x080C00
/* 2D registers
diff --git a/drivers/staging/sm750fb/ddk750_sii164.c b/drivers/staging/sm750fb/ddk750_sii164.c
index 3d224d6a74ff59..84464c1bfdd8bf 100644
--- a/drivers/staging/sm750fb/ddk750_sii164.c
+++ b/drivers/staging/sm750fb/ddk750_sii164.c
@@ -256,7 +256,7 @@ long sii164InitChip(
-/* below sii164 function is not neccessary */
+/* below sii164 function is not necessary */
#ifdef SII164_FULL_FUNCTIONS
@@ -388,7 +388,7 @@ unsigned char sii164IsConnected(void)
/*
* sii164CheckInterrupt
- * Checks if interrupt has occured.
+ * Checks if interrupt has occurred.
*
* Output:
* 0 - No interrupt
diff --git a/drivers/staging/sm750fb/readme b/drivers/staging/sm750fb/readme
index ab9af791653dd5..cfa45958b9d275 100644
--- a/drivers/staging/sm750fb/readme
+++ b/drivers/staging/sm750fb/readme
@@ -5,7 +5,7 @@ Introduction:
- 2D acceleration
- 16MB integrated video memory
-About the kernel module paramter of driver:
+About the kernel module parameter of driver:
Use 1280,8bpp index color and 60 hz mode:
insmod ./sm750fb.ko g_option="1280x1024-8@60"
@@ -20,16 +20,16 @@ About the kernel module paramter of driver:
and user can use con2fb to link fbX and ttyX
Notes:
- 1) if you build the driver with built-in method, the paramter
+ 1) if you build the driver with built-in method, the parameter
you edited in the grub config file will be also the
- same format as above modular method,but additionaly add
+ same format as above modular method,but additionally add
"video=sm750fb:"
ahead of parameters,so,it looks like:
video=sm750fb:noaccel,1280x1024@60,otherparam,etc...
it equal to modular method with below command:
insmod ./sm750fb.ko g_option="noaccel:1280x1024@60:otherparm:etc..."
- 2) if you put 800x600 into the paramter without bpp and
+ 2) if you put 800x600 into the parameter without bpp and
refresh rate, kernel driver will defaulty use 16bpp and 60hz
Important:
diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index dbbb2f879a29fb..6b642d75b9b58d 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -16,9 +16,6 @@
#include<linux/vmalloc.h>
#include<linux/pagemap.h>
#include <linux/console.h>
-#ifdef CONFIG_MTRR
-#include <asm/mtrr.h>
-#endif
#include <asm/fb.h>
#include "sm750.h"
#include "sm750_hw.h"
@@ -47,9 +44,7 @@ typedef int (*PROC_SPEC_INITHW)(struct lynx_share*, struct pci_dev*);
/* common var for all device */
static int g_hwcursor = 1;
static int g_noaccel;
-#ifdef CONFIG_MTRR
static int g_nomtrr;
-#endif
static const char *g_fbmode[] = {NULL, NULL};
static const char *g_def_fbmode = "800x600-16@60";
static char *g_settings = NULL;
@@ -93,9 +88,6 @@ static const struct fb_videomode lynx750_ext[] = {
FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
FB_VMODE_NONINTERLACED},
- {NULL, 60, 1360, 768, 11804, 208, 64, 23, 1, 144, 3,
- FB_SYNC_HOR_HIGH_ACT|FB_VMODE_NONINTERLACED},
-
/* 1360 x 768 [1.77083:1] */
{NULL, 60, 1360, 768, 11804, 208, 64, 23, 1, 144, 3,
FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
@@ -207,7 +199,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info,
/*
* If not use spin_lock,system will die if user load driver
- * and immediatly unload driver frequently (dual)
+ * and immediately unload driver frequently (dual)
*/
if (share->dual)
spin_lock(&share->slock);
@@ -239,7 +231,7 @@ static void lynxfb_ops_copyarea(struct fb_info *info,
/*
* If not use spin_lock, system will die if user load driver
- * and immediatly unload driver frequently (dual)
+ * and immediately unload driver frequently (dual)
*/
if (share->dual)
spin_lock(&share->slock);
@@ -279,11 +271,14 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
}
goto _do_work;
}
+ /* TODO: Implement hardware acceleration for image->depth > 1 */
+ cfb_imageblit(info, image);
return;
+
_do_work:
/*
* If not use spin_lock, system will die if user load driver
- * and immediatly unload driver frequently (dual)
+ * and immediately unload driver frequently (dual)
*/
if (share->dual)
spin_lock(&share->slock);
@@ -479,7 +474,7 @@ static int lynxfb_resume(struct pci_dev *pdev)
ret = pci_set_power_state(pdev, PCI_D0);
if (ret) {
- pr_err("error:%d occured in pci_set_power_state\n", ret);
+ pr_err("error:%d occurred in pci_set_power_state\n", ret);
return ret;
}
@@ -488,7 +483,7 @@ static int lynxfb_resume(struct pci_dev *pdev)
pci_restore_state(pdev);
ret = pci_enable_device(pdev);
if (ret) {
- pr_err("error:%d occured in pci_enable_device\n", ret);
+ pr_err("error:%d occurred in pci_enable_device\n", ret);
return ret;
}
pci_set_master(pdev);
@@ -979,7 +974,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
ret = fb_alloc_cmap(&info->cmap, 256, 0);
if (ret < 0) {
- pr_err("Could not allcate memory for cmap.\n");
+ pr_err("Could not allocate memory for cmap.\n");
goto exit;
}
@@ -1126,11 +1121,8 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
pr_info("share->revid = %02x\n", share->revid);
share->pdev = pdev;
-#ifdef CONFIG_MTRR
share->mtrr_off = g_nomtrr;
share->mtrr.vram = 0;
- share->mtrr.vram_added = 0;
-#endif
share->accel_off = g_noaccel;
share->dual = g_dualview;
spin_lock_init(&share->slock);
@@ -1158,22 +1150,9 @@ static int lynxfb_pci_probe(struct pci_dev *pdev,
goto err_map;
}
-#ifdef CONFIG_MTRR
- if (!share->mtrr_off) {
- pr_info("enable mtrr\n");
- share->mtrr.vram = mtrr_add(share->vidmem_start,
- share->vidmem_size,
- MTRR_TYPE_WRCOMB, 1);
-
- if (share->mtrr.vram < 0) {
- /* don't block driver with the failure of MTRR */
- pr_err("Unable to setup MTRR.\n");
- } else {
- share->mtrr.vram_added = 1;
- pr_info("MTRR added succesfully\n");
- }
- }
-#endif
+ if (!share->mtrr_off)
+ share->mtrr.vram = arch_phys_wc_add(share->vidmem_start,
+ share->vidmem_size);
memset_io(share->pvMem, 0, share->vidmem_size);
@@ -1274,12 +1253,7 @@ static void lynxfb_pci_remove(struct pci_dev *pdev)
/* release frame buffer */
framebuffer_release(info);
}
-#ifdef CONFIG_MTRR
- if (share->mtrr.vram_added)
- mtrr_del(share->mtrr.vram,
- share->vidmem_start,
- share->vidmem_size);
-#endif
+ arch_phys_wc_del(share->mtrr.vram);
iounmap(share->pvReg);
iounmap(share->pvMem);
@@ -1321,10 +1295,8 @@ static int __init lynxfb_setup(char *options)
/* options that mean for any lynx chips are configured here */
if (!strncmp(opt, "noaccel", strlen("noaccel")))
g_noaccel = 1;
-#ifdef CONFIG_MTRR
else if (!strncmp(opt, "nomtrr", strlen("nomtrr")))
g_nomtrr = 1;
-#endif
else if (!strncmp(opt, "dual", strlen("dual")))
g_dualview = 1;
else {
diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h
index 0847d2bd95c8a3..55289126f72c29 100644
--- a/drivers/staging/sm750fb/sm750.h
+++ b/drivers/staging/sm750fb/sm750.h
@@ -51,13 +51,10 @@ struct lynx_share{
struct lynx_accel accel;
int accel_off;
int dual;
-#ifdef CONFIG_MTRR
int mtrr_off;
struct{
int vram;
- int vram_added;
}mtrr;
-#endif
/* all smi graphic adaptor got below attributes */
unsigned long vidmem_start;
unsigned long vidreg_start;
diff --git a/drivers/staging/sm750fb/sm750_accel.c b/drivers/staging/sm750fb/sm750_accel.c
index c5a37269073774..6a04ef86eb1339 100644
--- a/drivers/staging/sm750fb/sm750_accel.c
+++ b/drivers/staging/sm750fb/sm750_accel.c
@@ -246,7 +246,7 @@ unsigned int rop2) /* ROP value */
#if 0
/* Program pitch (distance between the 1st points of two adjacent lines).
Note that input pitch is BYTE value, but the 2D Pitch register uses
- pixel values. Need Byte to pixel convertion.
+ pixel values. Need Byte to pixel conversion.
*/
if(Bpp == 3){
sx *= 3;
@@ -362,7 +362,7 @@ int hw_imageblit(struct lynx_accel *accel,
#if 0
/* Program pitch (distance between the 1st points of two adjacent lines).
Note that input pitch is BYTE value, but the 2D Pitch register uses
- pixel values. Need Byte to pixel convertion.
+ pixel values. Need Byte to pixel conversion.
*/
if(bytePerPixel == 3 ){
dx *= 3;
diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c
index 9f0d06da12fb79..4b77eb1b927796 100644
--- a/drivers/staging/sm750fb/sm750_hw.c
+++ b/drivers/staging/sm750fb/sm750_hw.c
@@ -85,8 +85,7 @@ int hw_sm750_map(struct lynx_share* share, struct pci_dev* pdev)
}
#endif
- share->pvMem = ioremap(share->vidmem_start,
- share->vidmem_size);
+ share->pvMem = ioremap_wc(share->vidmem_start, share->vidmem_size);
if(!share->pvMem){
pr_err("Map video memory failed\n");
diff --git a/drivers/staging/sm750fb/sm750_hw.h b/drivers/staging/sm750fb/sm750_hw.h
index b05be5e99f51c7..c607d9b81cd84e 100644
--- a/drivers/staging/sm750fb/sm750_hw.h
+++ b/drivers/staging/sm750fb/sm750_hw.h
@@ -65,7 +65,7 @@ struct sm750_state{
};
/* sm750_share stands for a presentation of two frame buffer
- that use one sm750 adaptor, it is similiar to the super class of lynx_share
+ that use one sm750 adaptor, it is similar to the super class of lynx_share
in C++
*/
diff --git a/drivers/staging/sm7xxfb/sm7xxfb.c b/drivers/staging/sm7xxfb/sm7xxfb.c
index 77f51a07500470..5db26f16569c34 100644
--- a/drivers/staging/sm7xxfb/sm7xxfb.c
+++ b/drivers/staging/sm7xxfb/sm7xxfb.c
@@ -39,7 +39,7 @@
*/
struct smtcfb_info {
struct pci_dev *pdev;
- struct fb_info fb;
+ struct fb_info *fb;
u16 chip_id;
u8 chip_rev_id;
@@ -249,19 +249,20 @@ static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green,
if (regno > 255)
return 1;
- switch (sfb->fb.fix.visual) {
+ switch (sfb->fb->fix.visual) {
case FB_VISUAL_DIRECTCOLOR:
case FB_VISUAL_TRUECOLOR:
/*
* 16/32 bit true-colour, use pseudo-palette for 16 base color
*/
if (regno < 16) {
- if (sfb->fb.var.bits_per_pixel == 16) {
- u32 *pal = sfb->fb.pseudo_palette;
+ if (sfb->fb->var.bits_per_pixel == 16) {
+ u32 *pal = sfb->fb->pseudo_palette;
- val = chan_to_field(red, &sfb->fb.var.red);
- val |= chan_to_field(green, &sfb->fb.var.green);
- val |= chan_to_field(blue, &sfb->fb.var.blue);
+ val = chan_to_field(red, &sfb->fb->var.red);
+ val |= chan_to_field(green,
+ &sfb->fb->var.green);
+ val |= chan_to_field(blue, &sfb->fb->var.blue);
#ifdef __BIG_ENDIAN
pal[regno] =
((red & 0xf800) >> 8) |
@@ -272,11 +273,12 @@ static int smtc_setcolreg(unsigned regno, unsigned red, unsigned green,
pal[regno] = val;
#endif
} else {
- u32 *pal = sfb->fb.pseudo_palette;
+ u32 *pal = sfb->fb->pseudo_palette;
- val = chan_to_field(red, &sfb->fb.var.red);
- val |= chan_to_field(green, &sfb->fb.var.green);
- val |= chan_to_field(blue, &sfb->fb.var.blue);
+ val = chan_to_field(red, &sfb->fb->var.red);
+ val |= chan_to_field(green,
+ &sfb->fb->var.green);
+ val |= chan_to_field(blue, &sfb->fb->var.blue);
#ifdef __BIG_ENDIAN
val =
(val & 0xff00ff00 >> 8) |
@@ -472,13 +474,13 @@ static void sm7xx_set_timing(struct smtcfb_info *sfb)
u32 m_nscreenstride;
dev_dbg(&sfb->pdev->dev,
- "sfb->width=%d sfb->height=%d sfb->fb.var.bits_per_pixel=%d sfb->hz=%d\n",
- sfb->width, sfb->height, sfb->fb.var.bits_per_pixel, sfb->hz);
+ "sfb->width=%d sfb->height=%d sfb->fb->var.bits_per_pixel=%d sfb->hz=%d\n",
+ sfb->width, sfb->height, sfb->fb->var.bits_per_pixel, sfb->hz);
for (j = 0; j < numvgamodes; j++) {
if (vgamode[j].mmsizex == sfb->width &&
vgamode[j].mmsizey == sfb->height &&
- vgamode[j].bpp == sfb->fb.var.bits_per_pixel &&
+ vgamode[j].bpp == sfb->fb->var.bits_per_pixel &&
vgamode[j].hz == sfb->hz) {
dev_dbg(&sfb->pdev->dev,
"vgamode[j].mmsizex=%d vgamode[j].mmSizeY=%d vgamode[j].bpp=%d vgamode[j].hz=%d\n",
@@ -551,8 +553,8 @@ static void sm7xx_set_timing(struct smtcfb_info *sfb)
/* set data width */
m_nscreenstride =
- (sfb->width * sfb->fb.var.bits_per_pixel) / 64;
- switch (sfb->fb.var.bits_per_pixel) {
+ (sfb->width * sfb->fb->var.bits_per_pixel) / 64;
+ switch (sfb->fb->var.bits_per_pixel) {
case 8:
writel(0x0, sfb->vp_regs + 0x0);
break;
@@ -583,52 +585,52 @@ static void smtc_set_timing(struct smtcfb_info *sfb)
static void smtcfb_setmode(struct smtcfb_info *sfb)
{
- switch (sfb->fb.var.bits_per_pixel) {
+ switch (sfb->fb->var.bits_per_pixel) {
case 32:
- sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
- sfb->fb.fix.line_length = sfb->fb.var.xres * 4;
- sfb->fb.var.red.length = 8;
- sfb->fb.var.green.length = 8;
- sfb->fb.var.blue.length = 8;
- sfb->fb.var.red.offset = 16;
- sfb->fb.var.green.offset = 8;
- sfb->fb.var.blue.offset = 0;
+ sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR;
+ sfb->fb->fix.line_length = sfb->fb->var.xres * 4;
+ sfb->fb->var.red.length = 8;
+ sfb->fb->var.green.length = 8;
+ sfb->fb->var.blue.length = 8;
+ sfb->fb->var.red.offset = 16;
+ sfb->fb->var.green.offset = 8;
+ sfb->fb->var.blue.offset = 0;
break;
case 24:
- sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
- sfb->fb.fix.line_length = sfb->fb.var.xres * 3;
- sfb->fb.var.red.length = 8;
- sfb->fb.var.green.length = 8;
- sfb->fb.var.blue.length = 8;
- sfb->fb.var.red.offset = 16;
- sfb->fb.var.green.offset = 8;
- sfb->fb.var.blue.offset = 0;
+ sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR;
+ sfb->fb->fix.line_length = sfb->fb->var.xres * 3;
+ sfb->fb->var.red.length = 8;
+ sfb->fb->var.green.length = 8;
+ sfb->fb->var.blue.length = 8;
+ sfb->fb->var.red.offset = 16;
+ sfb->fb->var.green.offset = 8;
+ sfb->fb->var.blue.offset = 0;
break;
case 8:
- sfb->fb.fix.visual = FB_VISUAL_PSEUDOCOLOR;
- sfb->fb.fix.line_length = sfb->fb.var.xres;
- sfb->fb.var.red.length = 3;
- sfb->fb.var.green.length = 3;
- sfb->fb.var.blue.length = 2;
- sfb->fb.var.red.offset = 5;
- sfb->fb.var.green.offset = 2;
- sfb->fb.var.blue.offset = 0;
+ sfb->fb->fix.visual = FB_VISUAL_PSEUDOCOLOR;
+ sfb->fb->fix.line_length = sfb->fb->var.xres;
+ sfb->fb->var.red.length = 3;
+ sfb->fb->var.green.length = 3;
+ sfb->fb->var.blue.length = 2;
+ sfb->fb->var.red.offset = 5;
+ sfb->fb->var.green.offset = 2;
+ sfb->fb->var.blue.offset = 0;
break;
case 16:
default:
- sfb->fb.fix.visual = FB_VISUAL_TRUECOLOR;
- sfb->fb.fix.line_length = sfb->fb.var.xres * 2;
- sfb->fb.var.red.length = 5;
- sfb->fb.var.green.length = 6;
- sfb->fb.var.blue.length = 5;
- sfb->fb.var.red.offset = 11;
- sfb->fb.var.green.offset = 5;
- sfb->fb.var.blue.offset = 0;
+ sfb->fb->fix.visual = FB_VISUAL_TRUECOLOR;
+ sfb->fb->fix.line_length = sfb->fb->var.xres * 2;
+ sfb->fb->var.red.length = 5;
+ sfb->fb->var.green.length = 6;
+ sfb->fb->var.blue.length = 5;
+ sfb->fb->var.red.offset = 11;
+ sfb->fb->var.green.offset = 5;
+ sfb->fb->var.blue.offset = 0;
break;
}
- sfb->width = sfb->fb.var.xres;
- sfb->height = sfb->fb.var.yres;
+ sfb->width = sfb->fb->var.xres;
+ sfb->height = sfb->fb->var.yres;
sfb->hz = 60;
smtc_set_timing(sfb);
}
@@ -673,38 +675,6 @@ static struct fb_ops smtcfb_ops = {
};
/*
- * alloc struct smtcfb_info and assign default values
- */
-static struct smtcfb_info *smtc_alloc_fb_info(struct pci_dev *pdev)
-{
- struct smtcfb_info *sfb;
-
- sfb = kzalloc(sizeof(*sfb), GFP_KERNEL);
-
- if (!sfb)
- return NULL;
-
- sfb->pdev = pdev;
-
- sfb->fb.flags = FBINFO_FLAG_DEFAULT;
- sfb->fb.fbops = &smtcfb_ops;
- sfb->fb.fix = smtcfb_fix;
- sfb->fb.var = smtcfb_var;
- sfb->fb.pseudo_palette = sfb->colreg;
- sfb->fb.par = sfb;
-
- return sfb;
-}
-
-/*
- * free struct smtcfb_info
- */
-static void smtc_free_fb_info(struct smtcfb_info *sfb)
-{
- kfree(sfb);
-}
-
-/*
* Unmap in the memory mapped IO registers
*/
@@ -721,20 +691,20 @@ static void smtc_unmap_mmio(struct smtcfb_info *sfb)
static int smtc_map_smem(struct smtcfb_info *sfb,
struct pci_dev *pdev, u_long smem_len)
{
- sfb->fb.fix.smem_start = pci_resource_start(pdev, 0);
+ sfb->fb->fix.smem_start = pci_resource_start(pdev, 0);
#ifdef __BIG_ENDIAN
- if (sfb->fb.var.bits_per_pixel == 32)
- sfb->fb.fix.smem_start += 0x800000;
+ if (sfb->fb->var.bits_per_pixel == 32)
+ sfb->fb->fix.smem_start += 0x800000;
#endif
- sfb->fb.fix.smem_len = smem_len;
+ sfb->fb->fix.smem_len = smem_len;
- sfb->fb.screen_base = sfb->lfb;
+ sfb->fb->screen_base = sfb->lfb;
- if (!sfb->fb.screen_base) {
+ if (!sfb->fb->screen_base) {
dev_err(&pdev->dev,
- "%s: unable to map screen memory\n", sfb->fb.fix.id);
+ "%s: unable to map screen memory\n", sfb->fb->fix.id);
return -ENOMEM;
}
@@ -747,9 +717,9 @@ static int smtc_map_smem(struct smtcfb_info *sfb,
*/
static void smtc_unmap_smem(struct smtcfb_info *sfb)
{
- if (sfb && sfb->fb.screen_base) {
- iounmap(sfb->fb.screen_base);
- sfb->fb.screen_base = NULL;
+ if (sfb && sfb->fb->screen_base) {
+ iounmap(sfb->fb->screen_base);
+ sfb->fb->screen_base = NULL;
}
}
@@ -766,6 +736,7 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
struct smtcfb_info *sfb;
+ struct fb_info *info;
u_long smem_size = 0x00800000; /* default 8MB */
int err;
unsigned long mmio_base;
@@ -784,14 +755,23 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
sprintf(smtcfb_fix.id, "sm%Xfb", ent->device);
- sfb = smtc_alloc_fb_info(pdev);
-
- if (!sfb) {
+ info = framebuffer_alloc(sizeof(*sfb), &pdev->dev);
+ if (!info) {
+ dev_err(&pdev->dev, "framebuffer_alloc failed\n");
err = -ENOMEM;
goto failed_free;
}
+ sfb = info->par;
+ sfb->fb = info;
sfb->chip_id = ent->device;
+ sfb->pdev = pdev;
+ info->flags = FBINFO_FLAG_DEFAULT;
+ info->fbops = &smtcfb_ops;
+ info->fix = smtcfb_fix;
+ info->var = smtcfb_var;
+ info->pseudo_palette = sfb->colreg;
+ info->par = sfb;
pci_set_drvdata(pdev, sfb);
@@ -799,19 +779,19 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
/* get mode parameter from smtc_scr_info */
if (smtc_scr_info.lfb_width != 0) {
- sfb->fb.var.xres = smtc_scr_info.lfb_width;
- sfb->fb.var.yres = smtc_scr_info.lfb_height;
- sfb->fb.var.bits_per_pixel = smtc_scr_info.lfb_depth;
+ sfb->fb->var.xres = smtc_scr_info.lfb_width;
+ sfb->fb->var.yres = smtc_scr_info.lfb_height;
+ sfb->fb->var.bits_per_pixel = smtc_scr_info.lfb_depth;
} else {
/* default resolution 1024x600 16bit mode */
- sfb->fb.var.xres = SCREEN_X_RES;
- sfb->fb.var.yres = SCREEN_Y_RES;
- sfb->fb.var.bits_per_pixel = SCREEN_BPP;
+ sfb->fb->var.xres = SCREEN_X_RES;
+ sfb->fb->var.yres = SCREEN_Y_RES;
+ sfb->fb->var.bits_per_pixel = SCREEN_BPP;
}
#ifdef __BIG_ENDIAN
- if (sfb->fb.var.bits_per_pixel == 24)
- sfb->fb.var.bits_per_pixel = (smtc_scr_info.lfb_depth = 32);
+ if (sfb->fb->var.bits_per_pixel == 24)
+ sfb->fb->var.bits_per_pixel = (smtc_scr_info.lfb_depth = 32);
#endif
/* Map address and memory detection */
mmio_base = pci_resource_start(pdev, 0);
@@ -820,8 +800,8 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
switch (sfb->chip_id) {
case 0x710:
case 0x712:
- sfb->fb.fix.mmio_start = mmio_base + 0x00400000;
- sfb->fb.fix.mmio_len = 0x00400000;
+ sfb->fb->fix.mmio_start = mmio_base + 0x00400000;
+ sfb->fb->fix.mmio_len = 0x00400000;
smem_size = SM712_VIDEOMEMORYSIZE;
#ifdef __BIG_ENDIAN
sfb->lfb = ioremap(mmio_base, 0x00c00000);
@@ -833,7 +813,7 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
sfb->dp_regs = sfb->lfb + 0x00408000;
sfb->vp_regs = sfb->lfb + 0x0040c000;
#ifdef __BIG_ENDIAN
- if (sfb->fb.var.bits_per_pixel == 32) {
+ if (sfb->fb->var.bits_per_pixel == 32) {
sfb->lfb += 0x800000;
dev_info(&pdev->dev, "sfb->lfb=%p", sfb->lfb);
}
@@ -841,7 +821,7 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
if (!smtc_regbaseaddress) {
dev_err(&pdev->dev,
"%s: unable to map memory mapped IO!",
- sfb->fb.fix.id);
+ sfb->fb->fix.id);
err = -ENOMEM;
goto failed_fb;
}
@@ -854,13 +834,13 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
smtc_seqw(0x17, 0x20);
/* enable word swap */
#ifdef __BIG_ENDIAN
- if (sfb->fb.var.bits_per_pixel == 32)
+ if (sfb->fb->var.bits_per_pixel == 32)
smtc_seqw(0x17, 0x30);
#endif
break;
case 0x720:
- sfb->fb.fix.mmio_start = mmio_base;
- sfb->fb.fix.mmio_len = 0x00200000;
+ sfb->fb->fix.mmio_start = mmio_base;
+ sfb->fb->fix.mmio_len = 0x00200000;
smem_size = SM722_VIDEOMEMORYSIZE;
sfb->dp_regs = ioremap(mmio_base, 0x00a00000);
sfb->lfb = sfb->dp_regs + 0x00200000;
@@ -880,25 +860,25 @@ static int smtcfb_pci_probe(struct pci_dev *pdev,
}
/* can support 32 bpp */
- if (15 == sfb->fb.var.bits_per_pixel)
- sfb->fb.var.bits_per_pixel = 16;
+ if (15 == sfb->fb->var.bits_per_pixel)
+ sfb->fb->var.bits_per_pixel = 16;
- sfb->fb.var.xres_virtual = sfb->fb.var.xres;
- sfb->fb.var.yres_virtual = sfb->fb.var.yres;
+ sfb->fb->var.xres_virtual = sfb->fb->var.xres;
+ sfb->fb->var.yres_virtual = sfb->fb->var.yres;
err = smtc_map_smem(sfb, pdev, smem_size);
if (err)
goto failed;
smtcfb_setmode(sfb);
- err = register_framebuffer(&sfb->fb);
+ err = register_framebuffer(info);
if (err < 0)
goto failed;
dev_info(&pdev->dev,
"Silicon Motion SM%X Rev%X primary display mode %dx%d-%d Init Complete.",
- sfb->chip_id, sfb->chip_rev_id, sfb->fb.var.xres,
- sfb->fb.var.yres, sfb->fb.var.bits_per_pixel);
+ sfb->chip_id, sfb->chip_rev_id, sfb->fb->var.xres,
+ sfb->fb->var.yres, sfb->fb->var.bits_per_pixel);
return 0;
@@ -908,7 +888,7 @@ failed:
smtc_unmap_smem(sfb);
smtc_unmap_mmio(sfb);
failed_fb:
- smtc_free_fb_info(sfb);
+ framebuffer_release(info);
failed_free:
pci_release_region(pdev, 0);
@@ -940,8 +920,8 @@ static void smtcfb_pci_remove(struct pci_dev *pdev)
sfb = pci_get_drvdata(pdev);
smtc_unmap_smem(sfb);
smtc_unmap_mmio(sfb);
- unregister_framebuffer(&sfb->fb);
- smtc_free_fb_info(sfb);
+ unregister_framebuffer(sfb->fb);
+ framebuffer_release(sfb->fb);
pci_release_region(pdev, 0);
pci_disable_device(pdev);
}
@@ -961,7 +941,7 @@ static int smtcfb_pci_suspend(struct device *device)
smtc_seqw(0x69, (smtc_seqr(0x69) & 0xf7));
console_lock();
- fb_set_suspend(&sfb->fb, 1);
+ fb_set_suspend(sfb->fb, 1);
console_unlock();
/* additionally turn off all function blocks including internal PLLs */
@@ -989,7 +969,7 @@ static int smtcfb_pci_resume(struct device *device)
/* enable PCI burst */
smtc_seqw(0x17, 0x20);
#ifdef __BIG_ENDIAN
- if (sfb->fb.var.bits_per_pixel == 32)
+ if (sfb->fb->var.bits_per_pixel == 32)
smtc_seqw(0x17, 0x30);
#endif
break;
@@ -1006,7 +986,7 @@ static int smtcfb_pci_resume(struct device *device)
smtcfb_setmode(sfb);
console_lock();
- fb_set_suspend(&sfb->fb, 0);
+ fb_set_suspend(sfb->fb, 0);
console_unlock();
return 0;
diff --git a/drivers/staging/unisys/Kconfig b/drivers/staging/unisys/Kconfig
index 19fcb34655093a..0c3e9a1368a872 100644
--- a/drivers/staging/unisys/Kconfig
+++ b/drivers/staging/unisys/Kconfig
@@ -4,16 +4,13 @@
menuconfig UNISYSSPAR
bool "Unisys SPAR driver support"
depends on X86_64
+ select PCI
+ select ACPI
---help---
Support for the Unisys SPAR drivers
if UNISYSSPAR
-source "drivers/staging/unisys/visorutil/Kconfig"
-source "drivers/staging/unisys/visorchannel/Kconfig"
-source "drivers/staging/unisys/visorchipset/Kconfig"
-source "drivers/staging/unisys/uislib/Kconfig"
-source "drivers/staging/unisys/virtpci/Kconfig"
-source "drivers/staging/unisys/virthba/Kconfig"
+source "drivers/staging/unisys/visorbus/Kconfig"
endif # UNISYSSPAR
diff --git a/drivers/staging/unisys/Makefile b/drivers/staging/unisys/Makefile
index 68b9925e7d5eb3..566af8e39aea53 100644
--- a/drivers/staging/unisys/Makefile
+++ b/drivers/staging/unisys/Makefile
@@ -1,9 +1,4 @@
#
# Makefile for Unisys SPAR drivers
#
-obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil/
-obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel/
-obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset/
-obj-$(CONFIG_UNISYS_UISLIB) += uislib/
-obj-$(CONFIG_UNISYS_VIRTPCI) += virtpci/
-obj-$(CONFIG_UNISYS_VIRTHBA) += virthba/
+obj-$(CONFIG_UNISYS_VISORBUS) += visorbus/
diff --git a/drivers/staging/unisys/common-spar/include/channels/controlframework.h b/drivers/staging/unisys/common-spar/include/channels/controlframework.h
deleted file mode 100644
index 33d9caf337c806..00000000000000
--- a/drivers/staging/unisys/common-spar/include/channels/controlframework.h
+++ /dev/null
@@ -1,62 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/*
- * Module Name:
- * controlframework.h
- *
- * Abstract: This file defines common structures in the unmanaged
- * Ultravisor (mostly EFI) space.
- *
- */
-
-#ifndef _CONTROL_FRAMEWORK_H_
-#define _CONTROL_FRAMEWORK_H_
-
-#include <linux/types.h>
-#include "channel.h"
-
-struct spar_segment_state {
- u16 enabled:1; /* Bit 0: May enter other states */
- u16 active:1; /* Bit 1: Assigned to active partition */
- u16 alive:1; /* Bit 2: Configure message sent to
- * service/server */
- u16 revoked:1; /* Bit 3: similar to partition state
- * ShuttingDown */
- u16 allocated:1; /* Bit 4: memory (device/port number)
- * has been selected by Command */
- u16 known:1; /* Bit 5: has been introduced to the
- * service/guest partition */
- u16 ready:1; /* Bit 6: service/Guest partition has
- * responded to introduction */
- u16 operating:1; /* Bit 7: resource is configured and
- * operating */
- /* Note: don't use high bit unless we need to switch to ushort
- * which is non-compliant */
-};
-
-static const struct spar_segment_state segment_state_running = {
- 1, 1, 1, 0, 1, 1, 1, 1
-};
-
-static const struct spar_segment_state segment_state_paused = {
- 1, 1, 1, 0, 1, 1, 1, 0
-};
-
-static const struct spar_segment_state segment_state_standby = {
- 1, 1, 0, 0, 1, 1, 1, 0
-};
-
-#endif /* _CONTROL_FRAMEWORK_H_ not defined */
diff --git a/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h b/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h
deleted file mode 100644
index 18cc9ed2748bff..00000000000000
--- a/drivers/staging/unisys/common-spar/include/diagnostics/appos_subsystems.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/* Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/* Please note that this file is to be used ONLY for defining diagnostic
- * subsystem values for the appos (sPAR Linux service partitions) component.
- */
-#ifndef __APPOS_SUBSYSTEMS_H__
-#define __APPOS_SUBSYSTEMS_H__
-
-#ifdef __KERNEL__
-#include <linux/kernel.h>
-#include <linux/string.h>
-#else
-#include <stdio.h>
-#include <string.h>
-#endif
-
-static inline char *
-subsys_unknown_to_s(int subsys, char *s, int n)
-{
- snprintf(s, n, "SUBSYS-%-2.2d", subsys);
- s[n - 1] = '\0';
- return s;
-}
-
-#define SUBSYS_TO_MASK(subsys) (1ULL << (subsys))
-
-/* The first SUBSYS_APPOS_MAX subsystems are the same for each AppOS type
- * (IOVM, SMS, etc.) The rest have unique values for each AppOS type.
- */
-#define SUBSYS_APPOS_MAX 16
-
-#define SUBSYS_APPOS_DEFAULT 1 /* or "other" */
-#define SUBSYS_APPOS_CHIPSET 2 /* controlvm and other */
- /* low-level sPAR activity */
-#define SUBSYS_APPOS_BUS 3 /* sPAR bus */
-/* DAK #define SUBSYS_APPOS_DIAG 4 // diagnostics and dump */
-#define SUBSYS_APPOS_CHANNELACCESS 5 /* generic channel access */
-#define SUBSYS_APPOS_NICCLIENT 6 /* virtual NIC client */
-#define SUBSYS_APPOS_HBACLIENT 7 /* virtual HBA client */
-#define SUBSYS_APPOS_CONSOLESERIAL 8 /* sPAR virtual serial console */
-#define SUBSYS_APPOS_UISLIB 9 /* */
-#define SUBSYS_APPOS_VRTCUPDD 10 /* */
-#define SUBSYS_APPOS_WATCHDOG 11 /* watchdog timer and healthcheck */
-#define SUBSYS_APPOS_13 13 /* available */
-#define SUBSYS_APPOS_14 14 /* available */
-#define SUBSYS_APPOS_15 15 /* available */
-#define SUBSYS_APPOS_16 16 /* available */
-static inline char *
-subsys_generic_to_s(int subsys, char *s, int n)
-{
- switch (subsys) {
- case SUBSYS_APPOS_DEFAULT:
- strncpy(s, "APPOS_DEFAULT", n);
- break;
- case SUBSYS_APPOS_CHIPSET:
- strncpy(s, "APPOS_CHIPSET", n);
- break;
- case SUBSYS_APPOS_BUS:
- strncpy(s, "APPOS_BUS", n);
- break;
- case SUBSYS_APPOS_CHANNELACCESS:
- strncpy(s, "APPOS_CHANNELACCESS", n);
- break;
- case SUBSYS_APPOS_NICCLIENT:
- strncpy(s, "APPOS_NICCLIENT", n);
- break;
- case SUBSYS_APPOS_HBACLIENT:
- strncpy(s, "APPOS_HBACLIENT", n);
- break;
- case SUBSYS_APPOS_CONSOLESERIAL:
- strncpy(s, "APPOS_CONSOLESERIAL", n);
- break;
- case SUBSYS_APPOS_UISLIB:
- strncpy(s, "APPOS_UISLIB", n);
- break;
- case SUBSYS_APPOS_VRTCUPDD:
- strncpy(s, "APPOS_VRTCUPDD", n);
- break;
- case SUBSYS_APPOS_WATCHDOG:
- strncpy(s, "APPOS_WATCHDOG", n);
- break;
- case SUBSYS_APPOS_13:
- strncpy(s, "APPOS_13", n);
- break;
- case SUBSYS_APPOS_14:
- strncpy(s, "APPOS_14", n);
- break;
- case SUBSYS_APPOS_15:
- strncpy(s, "APPOS_15", n);
- break;
- case SUBSYS_APPOS_16:
- strncpy(s, "APPOS_16", n);
- break;
- default:
- subsys_unknown_to_s(subsys, s, n);
- break;
- }
- s[n - 1] = '\0';
- return s;
-}
-
-/* CONSOLE */
-
-#define SUBSYS_CONSOLE_VIDEO (SUBSYS_APPOS_MAX + 1) /* 17 */
-#define SUBSYS_CONSOLE_KBDMOU (SUBSYS_APPOS_MAX + 2) /* 18 */
-#define SUBSYS_CONSOLE_04 (SUBSYS_APPOS_MAX + 4)
-#define SUBSYS_CONSOLE_05 (SUBSYS_APPOS_MAX + 5)
-#define SUBSYS_CONSOLE_06 (SUBSYS_APPOS_MAX + 6)
-#define SUBSYS_CONSOLE_07 (SUBSYS_APPOS_MAX + 7)
-#define SUBSYS_CONSOLE_08 (SUBSYS_APPOS_MAX + 8)
-#define SUBSYS_CONSOLE_09 (SUBSYS_APPOS_MAX + 9)
-#define SUBSYS_CONSOLE_10 (SUBSYS_APPOS_MAX + 10)
-#define SUBSYS_CONSOLE_11 (SUBSYS_APPOS_MAX + 11)
-#define SUBSYS_CONSOLE_12 (SUBSYS_APPOS_MAX + 12)
-#define SUBSYS_CONSOLE_13 (SUBSYS_APPOS_MAX + 13)
-#define SUBSYS_CONSOLE_14 (SUBSYS_APPOS_MAX + 14)
-#define SUBSYS_CONSOLE_15 (SUBSYS_APPOS_MAX + 15)
-#define SUBSYS_CONSOLE_16 (SUBSYS_APPOS_MAX + 16)
-#define SUBSYS_CONSOLE_17 (SUBSYS_APPOS_MAX + 17)
-#define SUBSYS_CONSOLE_18 (SUBSYS_APPOS_MAX + 18)
-#define SUBSYS_CONSOLE_19 (SUBSYS_APPOS_MAX + 19)
-#define SUBSYS_CONSOLE_20 (SUBSYS_APPOS_MAX + 20)
-#define SUBSYS_CONSOLE_21 (SUBSYS_APPOS_MAX + 21)
-#define SUBSYS_CONSOLE_22 (SUBSYS_APPOS_MAX + 22)
-#define SUBSYS_CONSOLE_23 (SUBSYS_APPOS_MAX + 23)
-#define SUBSYS_CONSOLE_24 (SUBSYS_APPOS_MAX + 24)
-#define SUBSYS_CONSOLE_25 (SUBSYS_APPOS_MAX + 25)
-#define SUBSYS_CONSOLE_26 (SUBSYS_APPOS_MAX + 26)
-#define SUBSYS_CONSOLE_27 (SUBSYS_APPOS_MAX + 27)
-#define SUBSYS_CONSOLE_28 (SUBSYS_APPOS_MAX + 28)
-#define SUBSYS_CONSOLE_29 (SUBSYS_APPOS_MAX + 29)
-#define SUBSYS_CONSOLE_30 (SUBSYS_APPOS_MAX + 30)
-#define SUBSYS_CONSOLE_31 (SUBSYS_APPOS_MAX + 31)
-#define SUBSYS_CONSOLE_32 (SUBSYS_APPOS_MAX + 32)
-#define SUBSYS_CONSOLE_33 (SUBSYS_APPOS_MAX + 33)
-#define SUBSYS_CONSOLE_34 (SUBSYS_APPOS_MAX + 34)
-#define SUBSYS_CONSOLE_35 (SUBSYS_APPOS_MAX + 35)
-#define SUBSYS_CONSOLE_36 (SUBSYS_APPOS_MAX + 36)
-#define SUBSYS_CONSOLE_37 (SUBSYS_APPOS_MAX + 37)
-#define SUBSYS_CONSOLE_38 (SUBSYS_APPOS_MAX + 38)
-#define SUBSYS_CONSOLE_39 (SUBSYS_APPOS_MAX + 39)
-#define SUBSYS_CONSOLE_40 (SUBSYS_APPOS_MAX + 40)
-#define SUBSYS_CONSOLE_41 (SUBSYS_APPOS_MAX + 41)
-#define SUBSYS_CONSOLE_42 (SUBSYS_APPOS_MAX + 42)
-#define SUBSYS_CONSOLE_43 (SUBSYS_APPOS_MAX + 43)
-#define SUBSYS_CONSOLE_44 (SUBSYS_APPOS_MAX + 44)
-#define SUBSYS_CONSOLE_45 (SUBSYS_APPOS_MAX + 45)
-#define SUBSYS_CONSOLE_46 (SUBSYS_APPOS_MAX + 46)
-
-static inline char *
-subsys_console_to_s(int subsys, char *s, int n)
-{
- switch (subsys) {
- case SUBSYS_CONSOLE_VIDEO:
- strncpy(s, "CONSOLE_VIDEO", n);
- break;
- case SUBSYS_CONSOLE_KBDMOU:
- strncpy(s, "CONSOLE_KBDMOU", n);
- break;
- case SUBSYS_CONSOLE_04:
- strncpy(s, "CONSOLE_04", n);
- break;
- case SUBSYS_CONSOLE_05:
- strncpy(s, "CONSOLE_05", n);
- break;
- case SUBSYS_CONSOLE_06:
- strncpy(s, "CONSOLE_06", n);
- break;
- case SUBSYS_CONSOLE_07:
- strncpy(s, "CONSOLE_07", n);
- break;
- case SUBSYS_CONSOLE_08:
- strncpy(s, "CONSOLE_08", n);
- break;
- case SUBSYS_CONSOLE_09:
- strncpy(s, "CONSOLE_09", n);
- break;
- case SUBSYS_CONSOLE_10:
- strncpy(s, "CONSOLE_10", n);
- break;
- case SUBSYS_CONSOLE_11:
- strncpy(s, "CONSOLE_11", n);
- break;
- case SUBSYS_CONSOLE_12:
- strncpy(s, "CONSOLE_12", n);
- break;
- case SUBSYS_CONSOLE_13:
- strncpy(s, "CONSOLE_13", n);
- break;
- case SUBSYS_CONSOLE_14:
- strncpy(s, "CONSOLE_14", n);
- break;
- case SUBSYS_CONSOLE_15:
- strncpy(s, "CONSOLE_15", n);
- break;
- case SUBSYS_CONSOLE_16:
- strncpy(s, "CONSOLE_16", n);
- break;
- case SUBSYS_CONSOLE_17:
- strncpy(s, "CONSOLE_17", n);
- break;
- case SUBSYS_CONSOLE_18:
- strncpy(s, "CONSOLE_18", n);
- break;
- case SUBSYS_CONSOLE_19:
- strncpy(s, "CONSOLE_19", n);
- break;
- case SUBSYS_CONSOLE_20:
- strncpy(s, "CONSOLE_20", n);
- break;
- case SUBSYS_CONSOLE_21:
- strncpy(s, "CONSOLE_21", n);
- break;
- case SUBSYS_CONSOLE_22:
- strncpy(s, "CONSOLE_22", n);
- break;
- case SUBSYS_CONSOLE_23:
- strncpy(s, "CONSOLE_23", n);
- break;
- case SUBSYS_CONSOLE_24:
- strncpy(s, "CONSOLE_24", n);
- break;
- case SUBSYS_CONSOLE_25:
- strncpy(s, "CONSOLE_25", n);
- break;
- case SUBSYS_CONSOLE_26:
- strncpy(s, "CONSOLE_26", n);
- break;
- case SUBSYS_CONSOLE_27:
- strncpy(s, "CONSOLE_27", n);
- break;
- case SUBSYS_CONSOLE_28:
- strncpy(s, "CONSOLE_28", n);
- break;
- case SUBSYS_CONSOLE_29:
- strncpy(s, "CONSOLE_29", n);
- break;
- case SUBSYS_CONSOLE_30:
- strncpy(s, "CONSOLE_30", n);
- break;
- case SUBSYS_CONSOLE_31:
- strncpy(s, "CONSOLE_31", n);
- break;
- case SUBSYS_CONSOLE_32:
- strncpy(s, "CONSOLE_32", n);
- break;
- case SUBSYS_CONSOLE_33:
- strncpy(s, "CONSOLE_33", n);
- break;
- case SUBSYS_CONSOLE_34:
- strncpy(s, "CONSOLE_34", n);
- break;
- case SUBSYS_CONSOLE_35:
- strncpy(s, "CONSOLE_35", n);
- break;
- case SUBSYS_CONSOLE_36:
- strncpy(s, "CONSOLE_36", n);
- break;
- case SUBSYS_CONSOLE_37:
- strncpy(s, "CONSOLE_37", n);
- break;
- case SUBSYS_CONSOLE_38:
- strncpy(s, "CONSOLE_38", n);
- break;
- case SUBSYS_CONSOLE_39:
- strncpy(s, "CONSOLE_39", n);
- break;
- case SUBSYS_CONSOLE_40:
- strncpy(s, "CONSOLE_40", n);
- break;
- case SUBSYS_CONSOLE_41:
- strncpy(s, "CONSOLE_41", n);
- break;
- case SUBSYS_CONSOLE_42:
- strncpy(s, "CONSOLE_42", n);
- break;
- case SUBSYS_CONSOLE_43:
- strncpy(s, "CONSOLE_43", n);
- break;
- case SUBSYS_CONSOLE_44:
- strncpy(s, "CONSOLE_44", n);
- break;
- case SUBSYS_CONSOLE_45:
- strncpy(s, "CONSOLE_45", n);
- break;
- case SUBSYS_CONSOLE_46:
- strncpy(s, "CONSOLE_46", n);
- break;
- default:
- subsys_unknown_to_s(subsys, s, n);
- break;
- }
- s[n - 1] = '\0';
- return s;
-}
-
-#endif
diff --git a/drivers/staging/unisys/common-spar/include/channels/channel.h b/drivers/staging/unisys/include/channel.h
index 6fb6e5b3ddaf52..da0b5387f88434 100644
--- a/drivers/staging/unisys/common-spar/include/channels/channel.h
+++ b/drivers/staging/unisys/include/channel.h
@@ -114,41 +114,6 @@ ULTRA_CHANNELCLI_STRING(u32 v)
(((o) == CHANNELCLI_BUSY) && ((n) == CHANNELCLI_OWNED)) || (0)) \
? (1) : (0))
-#define SPAR_CHANNEL_CLIENT_CHK_TRANSITION(old, new, id, log, \
- file, line) \
- do { \
- if (!ULTRA_VALID_CHANNELCLI_TRANSITION(old, new)) \
- pr_info("%s Channel StateTransition INVALID! (%s) %s(%d)-->%s(%d) @%s:%d\n", \
- id, "CliState<x>", \
- ULTRA_CHANNELCLI_STRING(old), \
- old, \
- ULTRA_CHANNELCLI_STRING(new), \
- new, \
- pathname_last_n_nodes((u8 *)file, 4), \
- line); \
- } while (0)
-
-#define SPAR_CHANNEL_CLIENT_TRANSITION(ch, id, newstate, log) \
- do { \
- SPAR_CHANNEL_CLIENT_CHK_TRANSITION( \
- readl(&(((struct channel_header __iomem *)\
- (ch))->cli_state_os)), \
- newstate, id, log, __FILE__, __LINE__); \
- pr_info("%s Channel StateTransition (%s) %s(%d)-->%s(%d) @%s:%d\n", \
- id, "CliStateOS", \
- ULTRA_CHANNELCLI_STRING( \
- readl(&((struct channel_header __iomem *)\
- (ch))->cli_state_os)), \
- readl(&((struct channel_header __iomem *)\
- (ch))->cli_state_os), \
- ULTRA_CHANNELCLI_STRING(newstate), \
- newstate, \
- pathname_last_n_nodes(__FILE__, 4), __LINE__); \
- writel(newstate, &((struct channel_header __iomem *)\
- (ch))->cli_state_os); \
- mb(); /* required for channel synch */ \
- } while (0)
-
/* Values for ULTRA_CHANNEL_PROTOCOL.CliErrorBoot: */
/* throttling invalid boot channel statetransition error due to client
* disabled */
diff --git a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h b/drivers/staging/unisys/include/channel_guid.h
index 706363fc3e9a77..706363fc3e9a77 100644
--- a/drivers/staging/unisys/common-spar/include/channels/channel_guid.h
+++ b/drivers/staging/unisys/include/channel_guid.h
diff --git a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h b/drivers/staging/unisys/include/diagchannel.h
index e8fb8678a8e211..e8fb8678a8e211 100644
--- a/drivers/staging/unisys/common-spar/include/channels/diagchannel.h
+++ b/drivers/staging/unisys/include/diagchannel.h
diff --git a/drivers/staging/unisys/include/guestlinuxdebug.h b/drivers/staging/unisys/include/guestlinuxdebug.h
index 957a627d052747..82ee565395ba95 100644
--- a/drivers/staging/unisys/include/guestlinuxdebug.h
+++ b/drivers/staging/unisys/include/guestlinuxdebug.h
@@ -22,7 +22,6 @@
* ISSUE_IO_VMCALL_POSTCODE_SEVERITY */
/******* INFO ON ISSUE_POSTCODE_LINUX() BELOW *******/
-#include "vmcallinterface.h"
enum driver_pc { /* POSTCODE driver identifier tuples */
/* visorchipset driver files */
VISOR_CHIPSET_PC = 0xA0,
@@ -135,7 +134,7 @@ enum event_pc { /* POSTCODE event identifier tuples */
#define POSTCODE_SEVERITY_ERR DIAG_SEVERITY_ERR
#define POSTCODE_SEVERITY_WARNING DIAG_SEVERITY_WARNING
#define POSTCODE_SEVERITY_INFO DIAG_SEVERITY_PRINT /* TODO-> Info currently
- * doesnt show, so we
+ * doesn't show, so we
* set info=warning */
/* example call of POSTCODE_LINUX_2(VISOR_CHIPSET_PC, POSTCODE_SEVERITY_ERR);
* Please also note that the resulting postcode is in hex, so if you are
diff --git a/drivers/staging/unisys/common-spar/include/channels/iochannel.h b/drivers/staging/unisys/include/iochannel.h
index 3bd7579e1daf85..cbb58757e76ae1 100644
--- a/drivers/staging/unisys/common-spar/include/channels/iochannel.h
+++ b/drivers/staging/unisys/include/iochannel.h
@@ -4,29 +4,29 @@
#define __IOCHANNEL_H__
/*
-* Everything needed for IOPart-GuestPart communication is define in
-* this file. Note: Everything is OS-independent because this file is
-* used by Windows, Linux and possible EFI drivers. */
+ * Everything needed for IOPart-GuestPart communication is define in
+ * this file. Note: Everything is OS-independent because this file is
+ * used by Windows, Linux and possible EFI drivers. */
/*
-* Communication flow between the IOPart and GuestPart uses the channel headers
-* channel state. The following states are currently being used:
-* UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED
-*
-* additional states will be used later. No locking is needed to switch between
-* states due to the following rules:
-*
-* 1. IOPart is only the only partition allowed to change from UNIT
-* 2. IOPart is only the only partition allowed to change from
-* CHANNEL_ATTACHING
-* 3. GuestPart is only the only partition allowed to change from
-* CHANNEL_ATTACHED
-*
-* The state changes are the following: IOPart sees the channel is in UNINIT,
-* UNINIT -> CHANNEL_ATTACHING (performed only by IOPart)
-* CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart)
-* CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart)
-*/
+ * Communication flow between the IOPart and GuestPart uses the channel headers
+ * channel state. The following states are currently being used:
+ * UNINIT(All Zeroes), CHANNEL_ATTACHING, CHANNEL_ATTACHED, CHANNEL_OPENED
+ *
+ * additional states will be used later. No locking is needed to switch between
+ * states due to the following rules:
+ *
+ * 1. IOPart is only the only partition allowed to change from UNIT
+ * 2. IOPart is only the only partition allowed to change from
+ * CHANNEL_ATTACHING
+ * 3. GuestPart is only the only partition allowed to change from
+ * CHANNEL_ATTACHED
+ *
+ * The state changes are the following: IOPart sees the channel is in UNINIT,
+ * UNINIT -> CHANNEL_ATTACHING (performed only by IOPart)
+ * CHANNEL_ATTACHING -> CHANNEL_ATTACHED (performed only by IOPart)
+ * CHANNEL_ATTACHED -> CHANNEL_OPENED (performed only by GuestPart)
+ */
#include <linux/uuid.h>
@@ -38,11 +38,6 @@
#include "vbuschannel.h"
#undef _ULTRA_CONTROLVM_CHANNEL_INLINE_
#include "channel.h"
-
-/*
- * CHANNEL Guids
- */
-
#include "channel_guid.h"
#define ULTRA_VHBA_CHANNEL_PROTOCOL_SIGNATURE ULTRA_CHANNEL_PROTOCOL_SIGNATURE
@@ -51,10 +46,11 @@
ULTRA_CHANNEL_PROTOCOL_SIGNATURE
/* Must increment these whenever you insert or delete fields within this channel
-* struct. Also increment whenever you change the meaning of fields within this
-* channel struct so as to break pre-existing software. Note that you can
-* usually add fields to the END of the channel struct withOUT needing to
-* increment this. */
+ * struct. Also increment whenever you change the meaning of fields within this
+ * channel struct so as to break pre-existing software. Note that you can
+ * usually add fields to the END of the channel struct withOUT needing to
+ * increment this.
+ */
#define ULTRA_VHBA_CHANNEL_PROTOCOL_VERSIONID 2
#define ULTRA_VNIC_CHANNEL_PROTOCOL_VERSIONID 2
#define ULTRA_VSWITCH_CHANNEL_PROTOCOL_VERSIONID 1
@@ -72,55 +68,26 @@
ULTRA_VNIC_CHANNEL_PROTOCOL_SIGNATURE))
/*
-* Everything necessary to handle SCSI & NIC traffic between Guest Partition and
-* IO Partition is defined below. */
+ * Everything necessary to handle SCSI & NIC traffic between Guest Partition and
+ * IO Partition is defined below.
+ */
/*
-* Defines and enums.
-*/
+ * Defines and enums.
+ */
#define MINNUM(a, b) (((a) < (b)) ? (a) : (b))
#define MAXNUM(a, b) (((a) > (b)) ? (a) : (b))
/* these define the two queues per data channel between iopart and
- * ioguestparts */
+ * ioguestparts
+ */
#define IOCHAN_TO_IOPART 0 /* used by ioguestpart to 'insert' signals to
* iopart */
-#define IOCHAN_FROM_GUESTPART 0 /* used by iopart to 'remove' signals from
- * ioguestpart - same queue as previous queue */
-#define IOCHAN_TO_GUESTPART 1 /* used by iopart to 'insert' signals to
- * ioguestpart */
#define IOCHAN_FROM_IOPART 1 /* used by ioguestpart to 'remove' signals from
* iopart - same queue as previous queue */
-/* these define the two queues per control channel between controlpart and "its"
- * guests, which includes the iopart */
-#define CTRLCHAN_TO_CTRLGUESTPART 0 /* used by ctrlguestpart to 'insert' signals
- * to ctrlpart */
-#define CTLRCHAN_FROM_CTRLPART 0 /* used by ctrlpart to 'remove' signals from
- * ctrlquestpart - same queue as previous
- * queue */
-
-#define CTRLCHAN_TO_CTRLPART 1 /* used by ctrlpart to 'insert' signals to
- * ctrlguestpart */
-#define CTRLCHAN_FROM_CTRLGUESTPART 1 /* used by ctrguestpart to 'remove'
- * signals from ctrlpart - same queue as
- * previous queue */
-
-/* these define the Event & Ack queues per control channel Events are generated
-* by CTRLGUESTPART and sent to CTRLPART; Acks are generated by CTRLPART and sent
-* to CTRLGUESTPART. */
-#define CTRLCHAN_EVENT_TO_CTRLPART 2 /* used by ctrlguestpart to 'insert' Events
- * to ctrlpart */
-#define CTRLCHAN_EVENT_FROM_CTRLGUESTPART 2 /* used by ctrlpart to 'remove'
- * Events from ctrlguestpart */
-
-#define CTRLCHAN_ACK_TO_CTRLGUESTPART 3 /* used by ctrlpart to 'insert' Acks to
- * ctrlguestpart */
-#define CTRLCHAN_ACK_FROM_CTRLPART 3 /* used by ctrlguestpart to 'remove' Events
- * from ctrlpart */
-
/* size of cdb - i.e., scsi cmnd */
#define MAX_CMND_SIZE 16
@@ -128,28 +95,6 @@
#define MAX_PHYS_INFO 64
-/* Because GuestToGuestCopy is limited to 4KiB segments, and we have limited the
-* Emulex Driver to 256 scatter list segments via the lpfc_sg_seg_cnt parameter
-* to 256, the maximum I/O size is limited to 256 * 4 KiB = 1 MB */
-#define MAX_IO_SIZE (1024*1024) /* 1 MB */
-
-/* NOTE 1: lpfc defines its support for segments in
-* #define LPFC_SG_SEG_CNT 64
-*
-* NOTE 2: In Linux, frags array in skb is currently allocated to be
-* MAX_SKB_FRAGS size, which is 18 which is smaller than MAX_PHYS_INFO for
-* now. */
-
-#ifndef MAX_SERIAL_NUM
-#define MAX_SERIAL_NUM 32
-#endif /* MAX_SERIAL_NUM */
-
-#define MAX_SCSI_BUSES 1
-#define MAX_SCSI_TARGETS 8
-#define MAX_SCSI_LUNS 16
-#define MAX_SCSI_FROM_HOST 0xFFFFFFFF /* Indicator to use Physical HBA
- * SCSI Host value */
-
/* various types of network packets that can be sent in cmdrsp */
enum net_types {
NET_RCV_POST = 0, /* submit buffer to hold receiving
@@ -173,7 +118,7 @@ enum net_types {
/* uisnic -> virtnic */
NET_MACADDR, /* indicates the client has requested to update
* its MAC addr */
- NET_MACADDR_ACK, /* MAC address */
+ NET_MACADDR_ACK, /* MAC address */
};
@@ -182,19 +127,12 @@ enum net_types {
#define ETH_MIN_DATA_SIZE 46 /* minimum eth data size */
#define ETH_MIN_PACKET_SIZE (ETH_HEADER_SIZE + ETH_MIN_DATA_SIZE)
-#define ETH_DEF_DATA_SIZE 1500 /* default data size */
-#define ETH_DEF_PACKET_SIZE (ETH_HEADER_SIZE + ETH_DEF_DATA_SIZE)
-
#define ETH_MAX_MTU 16384 /* maximum data size */
#ifndef MAX_MACADDR_LEN
#define MAX_MACADDR_LEN 6 /* number of bytes in MAC address */
#endif /* MAX_MACADDR_LEN */
-#define ETH_IS_LOCALLY_ADMINISTERED(address) \
- (((u8 *)(address))[0] & ((u8)0x02))
-#define NIC_VENDOR_ID 0x0008000B
-
/* various types of scsi task mgmt commands */
enum task_mgmt_types {
TASK_MGMT_ABORT_TASK = 1,
@@ -209,22 +147,7 @@ enum vdisk_mgmt_types {
VDISK_MGMT_RELEASE,
};
-/* this is used in the vdest field */
-#define VDEST_ALL 0xFFFF
-
-#define MIN_NUMSIGNALS 64
-#define MAX_NUMSIGNALS 4096
-
-/* MAX_NET_RCV_BUF specifies the number of rcv buffers that are created by each
-* guest's virtnic and posted to uisnic. Uisnic, for each channel, keeps the rcv
-* buffers posted and uses them to receive data on behalf of the guest's virtnic.
-* NOTE: the num_rcv_bufs is configurable for each VNIC. So the following is
-* simply an upperlimit on what each VNIC can provide. Setting it to half of the
-* NUMSIGNALS to prevent queue full deadlocks */
-#define MAX_NET_RCV_BUFS (MIN_NUMSIGNALS / 2)
-
-/*
- * structs with pragma pack */
+/* structs with pragma pack */
/* ///////////// BEGIN PRAGMA PACK PUSH 1 ///////////////////////// */
/* ///////////// ONLY STRUCT TYPE SHOULD BE BELOW */
@@ -287,13 +210,7 @@ struct uiscmdrsp_scsi {
u8 scsistat; /* the scsi status */
u8 addlstat; /* non-scsi status - covers cases like timeout
* needed by windows guests */
-#define ADDL_RESET 1
-#define ADDL_TIMEOUT 2
-#define ADDL_INTERNAL_ERROR 3
#define ADDL_SEL_TIMEOUT 4
-#define ADDL_CMD_TIMEOUT 5
-#define ADDL_BAD_TARGET 6
-#define ADDL_RETRY 7
/* the following fields are need to determine the result of command */
u8 sensebuf[MAX_SENSE_SIZE]; /* sense info in case cmd failed; */
@@ -301,17 +218,19 @@ struct uiscmdrsp_scsi {
/* see that struct for details. */
void *vdisk; /* contains pointer to the vdisk so that we can clean up
* when the IO completes. */
- int no_disk_result; /* used to return no disk inquiry result */
- /* when no_disk_result is set to 1, */
- /* scsi.scsistat is SAM_STAT_GOOD */
- /* scsi.addlstat is 0 */
- /* scsi.linuxstat is SAM_STAT_GOOD */
- /* That is, there is NO error. */
+ int no_disk_result;
+ /* used to return no disk inquiry result
+ * when no_disk_result is set to 1,
+ * scsi.scsistat is SAM_STAT_GOOD
+ * scsi.addlstat is 0
+ * scsi.linuxstat is SAM_STAT_GOOD
+ * That is, there is NO error.
+ */
};
-/*
-* Defines to support sending correct inquiry result when no disk is
-* configured. */
+/* Defines to support sending correct inquiry result when no disk is
+ * configured.
+ */
/* From SCSI SPC2 -
*
@@ -324,26 +243,22 @@ struct uiscmdrsp_scsi {
*connected to this logical unit.
*/
-#define DEV_NOT_PRESENT 0x7f /* old name - compatibility */
#define DEV_NOT_CAPABLE 0x7f /* peripheral qualifier of 0x3 */
- /* peripheral type of 0x1f */
- /* specifies no device but target present */
+ /* peripheral type of 0x1f */
+ /* specifies no device but target present */
#define DEV_DISK_CAPABLE_NOT_PRESENT 0x20 /* peripheral qualifier of 0x1 */
/* peripheral type of 0 - disk */
/* specifies device capable, but not present */
-#define DEV_PROC_CAPABLE_NOT_PRESENT 0x23 /* peripheral qualifier of 0x1 */
- /* peripheral type of 3 - processor */
- /* specifies device capable, but not present */
-
#define DEV_HISUPPORT 0x10 /* HiSup = 1; shows support for report luns */
- /* must be returned for lun 0. */
+ /* must be returned for lun 0. */
/* NOTE: Linux code assumes inquiry contains 36 bytes. Without checking length
-* in buf[4] some linux code accesses bytes beyond 5 to retrieve vendor, product
-* & revision. Yikes! So let us always send back 36 bytes, the minimum for
-* inquiry result. */
+ * in buf[4] some linux code accesses bytes beyond 5 to retrieve vendor, product
+ * & revision. Yikes! So let us always send back 36 bytes, the minimum for
+ * inquiry result.
+ */
#define NO_DISK_INQUIRY_RESULT_LEN 36
#define MIN_INQUIRY_RESULT_LEN 5 /* we need at least 5 bytes minimum for inquiry
@@ -394,21 +309,21 @@ struct uiscmdrsp_scsi {
} while (0)
/*
-* Struct & Defines to support sense information.
-*/
+ * Struct & Defines to support sense information.
+ */
/* The following struct is returned in sensebuf field in uiscmdrsp_scsi. It is
-* initialized in exactly the manner that is recommended in Windows (hence the
-* odd values).
-* When set, these fields will have the following values:
-* ErrorCode = 0x70 indicates current error
-* Valid = 1 indicates sense info is valid
-* SenseKey contains sense key as defined by SCSI specs.
-* AdditionalSenseCode contains sense key as defined by SCSI specs.
-* AdditionalSenseCodeQualifier contains qualifier to sense code as defined by
-* scsi docs.
-* AdditionalSenseLength contains will be sizeof(sense_data)-8=10.
-*/
+ * initialized in exactly the manner that is recommended in Windows (hence the
+ * odd values).
+ * When set, these fields will have the following values:
+ * ErrorCode = 0x70 indicates current error
+ * Valid = 1 indicates sense info is valid
+ * SenseKey contains sense key as defined by SCSI specs.
+ * AdditionalSenseCode contains sense key as defined by SCSI specs.
+ * AdditionalSenseCodeQualifier contains qualifier to sense code as defined by
+ * scsi docs.
+ * AdditionalSenseLength contains will be sizeof(sense_data)-8=10.
+ */
struct sense_data {
u8 errorcode:7;
u8 valid:1;
@@ -427,37 +342,6 @@ struct sense_data {
u8 sense_key_specific[3];
};
-/* some SCSI ADSENSE codes */
-#ifndef SCSI_ADSENSE_LUN_NOT_READY
-#define SCSI_ADSENSE_LUN_NOT_READY 0x04
-#endif /* */
-#ifndef SCSI_ADSENSE_ILLEGAL_COMMAND
-#define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20
-#endif /* */
-#ifndef SCSI_ADSENSE_ILLEGAL_BLOCK
-#endif /* */
-#ifndef SCSI_ADSENSE_ILLEGAL_BLOCK
-#define SCSI_ADSENSE_ILLEGAL_BLOCK 0x21
-#endif /* */
-#ifndef SCSI_ADSENSE_INVALID_CDB
-#define SCSI_ADSENSE_INVALID_CDB 0x24
-#endif /* */
-#ifndef SCSI_ADSENSE_INVALID_LUN
-#define SCSI_ADSENSE_INVALID_LUN 0x25
-#endif /* */
-#ifndef SCSI_ADWRITE_PROTECT
-#define SCSI_ADWRITE_PROTECT 0x27
-#endif /* */
-#ifndef SCSI_ADSENSE_MEDIUM_CHANGED
-#define SCSI_ADSENSE_MEDIUM_CHANGED 0x28
-#endif /* */
-#ifndef SCSI_ADSENSE_BUS_RESET
-#define SCSI_ADSENSE_BUS_RESET 0x29
-#endif /* */
-#ifndef SCSI_ADSENSE_NO_MEDIA_IN_DEVICE
-#define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3a
-#endif /* */
-
struct net_pkt_xmt {
int len; /* full length of data in the packet */
int num_frags; /* number of fragments in frags containing data */
@@ -488,29 +372,28 @@ struct net_pkt_xmt {
struct net_pkt_xmtdone {
u32 xmt_done_result; /* result of NET_XMIT */
-#define XMIT_SUCCESS 0
-#define XMIT_FAILED 1
};
/* RCVPOST_BUF_SIZe must be at most page_size(4096) - cache_line_size (64) The
-* reason is because dev_skb_alloc which is used to generate RCV_POST skbs in
-* virtnic requires that there is "overhead" in the buffer, and pads 16 bytes. I
-* prefer to use 1 full cache line size for "overhead" so that transfers are
-* better. IOVM requires that a buffer be represented by 1 phys_info structure
-* which can only cover page_size. */
+ * reason is because dev_skb_alloc which is used to generate RCV_POST skbs in
+ * virtnic requires that there is "overhead" in the buffer, and pads 16 bytes. I
+ * prefer to use 1 full cache line size for "overhead" so that transfers are
+ * better. IOVM requires that a buffer be represented by 1 phys_info structure
+ * which can only cover page_size.
+ */
#define RCVPOST_BUF_SIZE 4032
#define MAX_NET_RCV_CHAIN \
((ETH_MAX_MTU+ETH_HEADER_SIZE + RCVPOST_BUF_SIZE-1) / RCVPOST_BUF_SIZE)
struct net_pkt_rcvpost {
/* rcv buf size must be large enough to include ethernet data len +
- * ethernet header len - we are choosing 2K because it is guaranteed
- * to be describable */
+ * ethernet header len - we are choosing 2K because it is guaranteed
+ * to be describable */
struct phys_info frag; /* physical page information for the
* single fragment 2K rcv buf */
u64 unique_num; /* This is used to make sure that
* receive posts are returned to */
- /* the Adapter which sent them origonally. */
+ /* the Adapter which we sent them originally. */
};
struct net_pkt_rcv {
@@ -542,14 +425,14 @@ struct uiscmdrsp_net {
enum net_types type;
void *buf;
union {
- struct net_pkt_xmt xmt; /* used for NET_XMIT */
+ struct net_pkt_xmt xmt; /* used for NET_XMIT */
struct net_pkt_xmtdone xmtdone; /* used for NET_XMIT_DONE */
struct net_pkt_rcvpost rcvpost; /* used for NET_RCV_POST */
- struct net_pkt_rcv rcv; /* used for NET_RCV */
+ struct net_pkt_rcv rcv; /* used for NET_RCV */
struct net_pkt_enbdis enbdis; /* used for NET_RCV_ENBDIS, */
- /* NET_RCV_ENBDIS_ACK, */
- /* NET_RCV_PROMSIC, */
- /* and NET_CONNECT_STATUS */
+ /* NET_RCV_ENBDIS_ACK, */
+ /* NET_RCV_PROMSIC, */
+ /* and NET_CONNECT_STATUS */
struct net_pkt_macaddr macaddr;
};
};
@@ -564,43 +447,45 @@ struct uiscmdrsp_scsitaskmgmt {
void *scsicmd;
/* This is some handle that the guest has saved off for its own use.
- * Its value is preserved by iopart & returned as is in the task mgmt
- * rsp. */
+ * Its value is preserved by iopart & returned as is in the task
+ * mgmt rsp.
+ */
void *notify;
- /* For linux guests, this is a pointer to wait_queue_head that a
+ /* For linux guests, this is a pointer to wait_queue_head that a
* thread is waiting on to see if the taskmgmt command has completed.
* For windows guests, this is a pointer to a location that a waiting
* thread is testing to see if the taskmgmt command has completed.
* When the rsp is received by guest, the thread receiving the
* response uses this to notify the thread waiting for taskmgmt
* command completion. Its value is preserved by iopart & returned
- * as is in the task mgmt rsp. */
+ * as is in the task mgmt rsp.
+ */
void *notifyresult;
/* this is a handle to location in guest where the result of the
- * taskmgmt command (result field) is to saved off when the response
- * is handled. Its value is preserved by iopart & returned as is in
- * the task mgmt rsp. */
+ * taskmgmt command (result field) is to saved off when the response
+ * is handled. Its value is preserved by iopart & returned as is in
+ * the task mgmt rsp.
+ */
char result;
/* result of taskmgmt command - set by IOPart - values are: */
#define TASK_MGMT_FAILED 0
-#define TASK_MGMT_SUCCESS 1
};
/* The following is used by uissd to send disk add/remove notifications to
* Guest */
/* Note that the vHba pointer is not used by the Client/Guest side. */
struct uiscmdrsp_disknotify {
- u8 add; /* 0-remove, 1-add */
+ u8 add; /* 0-remove, 1-add */
void *v_hba; /* Pointer to vhba_info for channel info to
* route msg */
u32 channel, id, lun; /* SCSI Path of Disk to added or removed */
};
/* The following is used by virthba/vSCSI to send the Acquire/Release commands
-* to the IOVM. */
+ * to the IOVM. */
struct uiscmdrsp_vdiskmgmt {
enum vdisk_mgmt_types vdisktype;
@@ -611,36 +496,38 @@ struct uiscmdrsp_vdiskmgmt {
void *scsicmd;
/* This is some handle that the guest has saved off for its own use.
- * Its value is preserved by iopart & returned as is in the task mgmt
- * rsp. */
+ * Its value is preserved by iopart & returned as is in the task
+ * mgmt rsp.
+ */
void *notify;
/* For linux guests, this is a pointer to wait_queue_head that a
- * thread is waiting on to see if the taskmgmt command has completed.
- * For windows guests, this is a pointer to a location that a waiting
- * thread is testing to see if the taskmgmt command has completed.
- * When the rsp is received by guest, the thread receiving the
- * response uses this to notify the thread waiting for taskmgmt
- * command completion. Its value is preserved by iopart & returned
- * as is in the task mgmt rsp. */
+ * thread is waiting on to see if the tskmgmt command has completed.
+ * For win32 guests, this is a pointer to a location that a waiting
+ * thread is testing to see if the taskmgmt command has completed.
+ * When the rsp is received by guest, the thread receiving the
+ * response uses this to notify the thread waiting for taskmgmt
+ * command completion. Its value is preserved by iopart & returned
+ * as is in the task mgmt rsp.
+ */
void *notifyresult;
/* this is a handle to location in guest where the result of the
- * taskmgmt command (result field) is to saved off when the response
- * is handled. Its value is preserved by iopart & returned as is in
- * the task mgmt rsp. */
+ * taskmgmt command (result field) is to saved off when the response
+ * is handled. Its value is preserved by iopart & returned as is in
+ * the task mgmt rsp.
+ */
char result;
/* result of taskmgmt command - set by IOPart - values are: */
#define VDISK_MGMT_FAILED 0
-#define VDISK_MGMT_SUCCESS 1
};
/* keeping cmd & rsp info in one structure for now cmd rsp packet for scsi */
struct uiscmdrsp {
char cmdtype;
- /* describes what type of information is in the struct */
+/* describes what type of information is in the struct */
#define CMD_SCSI_TYPE 1
#define CMD_NET_TYPE 2
#define CMD_SCSITASKMGMT_TYPE 3
@@ -654,30 +541,31 @@ struct uiscmdrsp {
struct uiscmdrsp_vdiskmgmt vdiskmgmt;
};
void *private_data; /* used to send the response when the cmd is
- * done (scsi & scsittaskmgmt). */
+ * done (scsi & scsittaskmgmt). */
struct uiscmdrsp *next; /* General Purpose Queue Link */
struct uiscmdrsp *activeQ_next; /* Used to track active commands */
- struct uiscmdrsp *activeQ_prev; /* Used to track active commands */
+ struct uiscmdrsp *activeQ_prev; /* Used to track active commands */
};
/* This is just the header of the IO channel. It is assumed that directly after
-* this header there is a large region of memory which contains the command and
-* response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS. */
+ * this header there is a large region of memory which contains the command and
+ * response queues as specified in cmd_q and rsp_q SIGNAL_QUEUE_HEADERS.
+ */
struct spar_io_channel_protocol {
struct channel_header channel_header;
struct signal_queue_header cmd_q;
struct signal_queue_header rsp_q;
union {
struct {
- struct vhba_wwnn wwnn; /* 8 bytes */
+ struct vhba_wwnn wwnn; /* 8 bytes */
struct vhba_config_max max; /* 20 bytes */
- } vhba; /* 28 */
+ } vhba; /* total = 28 bytes */
struct {
u8 macaddr[MAX_MACADDR_LEN]; /* 6 bytes */
- u32 num_rcv_bufs; /* 4 */
- u32 mtu; /* 4 */
- uuid_le zone_uuid; /* 16 */
- } vnic; /* total 30 */
+ u32 num_rcv_bufs; /* 4 bytes */
+ u32 mtu; /* 4 bytes */
+ uuid_le zone_uuid; /* 16 bytes */
+ } vnic; /* total = 30 bytes */
};
#define MAX_CLIENTSTRING_LEN 1024
@@ -688,29 +576,9 @@ struct spar_io_channel_protocol {
#pragma pack(pop)
/* ///////////// END PRAGMA PACK PUSH 1 /////////////////////////// */
-/* define offsets to members of struct uiscmdrsp */
-#define OFFSET_CMDTYPE offsetof(struct uiscmdrsp, cmdtype)
-#define OFFSET_SCSI offsetof(struct uiscmdrsp, scsi)
-#define OFFSET_NET offsetof(struct uiscmdrsp, net)
-#define OFFSET_SCSITASKMGMT offsetof(struct uiscmdrsp, scsitaskmgmt)
-#define OFFSET_NEXT offsetof(struct uiscmdrsp, next)
-
-/* define offsets to members of struct uiscmdrsp_net */
-#define OFFSET_TYPE offsetof(struct uiscmdrsp_net, type)
-#define OFFSET_BUF offsetof(struct uiscmdrsp_net, buf)
-#define OFFSET_XMT offsetof(struct uiscmdrsp_net, xmt)
-#define OFFSET_XMT_DONE_RESULT offsetof(struct uiscmdrsp_net, xmtdone)
-#define OFFSET_RCVPOST offsetof(struct uiscmdrsp_net, rcvpost)
-#define OFFSET_RCV_DONE_LEN offsetof(struct uiscmdrsp_net, rcv)
-#define OFFSET_ENBDIS offsetof(struct uiscmdrsp_net, enbdis)
-
-/* define offsets to members of struct net_pkt_rcvpost */
-#define OFFSET_TOTALLEN offsetof(struct net_pkt_rcvpost, totallen)
-#define OFFSET_FRAG offsetof(struct net_pkt_rcvpost, frag)
-
/*
-* INLINE functions for initializing and accessing I/O data channels
-*/
+ * INLINE functions for initializing and accessing I/O data channels
+ */
#define SIZEOF_PROTOCOL (COVER(sizeof(struct spar_io_channel_protocol), 64))
#define SIZEOF_CMDRSP (COVER(sizeof(struct uiscmdrsp), 64))
@@ -719,16 +587,15 @@ struct spar_io_channel_protocol {
2 * MIN_NUMSIGNALS * SIZEOF_CMDRSP, 4096)
/*
-* INLINE function for expanding a guest's pfn-off-size into multiple 4K page
-* pfn-off-size entires.
-*/
+ * INLINE function for expanding a guest's pfn-off-size into multiple 4K page
+ * pfn-off-size entires.
+ */
/* we deal with 4K page sizes when we it comes to passing page information
* between */
/* Guest and IOPartition. */
#define PI_PAGE_SIZE 0x1000
#define PI_PAGE_MASK 0x0FFF
-#define PI_PAGE_SHIFT 12
/* returns next non-zero index on success or zero on failure (i.e. out of
* room)
diff --git a/drivers/staging/unisys/include/periodic_work.h b/drivers/staging/unisys/include/periodic_work.h
index 26ec10bdfe655a..4e19c28dc3d0e1 100644
--- a/drivers/staging/unisys/include/periodic_work.h
+++ b/drivers/staging/unisys/include/periodic_work.h
@@ -18,7 +18,9 @@
#ifndef __PERIODIC_WORK_H__
#define __PERIODIC_WORK_H__
-#include "timskmod.h"
+#include <linux/seq_file.h>
+#include <linux/slab.h>
+
/* PERIODIC_WORK an opaque structure to users.
* Fields are declared only in the implementation .c files.
@@ -31,8 +33,8 @@ struct periodic_work *visor_periodic_work_create(ulong jiffy_interval,
void *workfuncarg,
const char *devnam);
void visor_periodic_work_destroy(struct periodic_work *pw);
-BOOL visor_periodic_work_nextperiod(struct periodic_work *pw);
-BOOL visor_periodic_work_start(struct periodic_work *pw);
-BOOL visor_periodic_work_stop(struct periodic_work *pw);
+bool visor_periodic_work_nextperiod(struct periodic_work *pw);
+bool visor_periodic_work_start(struct periodic_work *pw);
+bool visor_periodic_work_stop(struct periodic_work *pw);
#endif
diff --git a/drivers/staging/unisys/include/procobjecttree.h b/drivers/staging/unisys/include/procobjecttree.h
deleted file mode 100644
index 809c6794290ea0..00000000000000
--- a/drivers/staging/unisys/include/procobjecttree.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/* procobjecttree.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/** @file *********************************************************************
- *
- * This describes the interfaces necessary for creating a tree of types,
- * objects, and properties in /proc.
- *
- ******************************************************************************
- */
-
-#ifndef __PROCOBJECTTREE_H__
-#define __PROCOBJECTTREE_H__
-
-#include "timskmod.h"
-
-/* These are opaque structures to users.
- * Fields are declared only in the implementation .c files.
- */
-typedef struct MYPROCOBJECT_Tag MYPROCOBJECT;
-typedef struct MYPROCTYPE_Tag MYPROCTYPE;
-
-MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, const char *name,
- void *context);
-void visor_proc_DestroyObject(MYPROCOBJECT *obj);
-MYPROCTYPE *visor_proc_CreateType(struct proc_dir_entry *procRootDir,
- const char **name,
- const char **propertyNames,
- void (*show_property)(struct seq_file *,
- void *, int));
-void visor_proc_DestroyType(MYPROCTYPE *type);
-
-#endif
diff --git a/drivers/staging/unisys/include/sparstop.h b/drivers/staging/unisys/include/sparstop.h
deleted file mode 100644
index 05837399a741da..00000000000000
--- a/drivers/staging/unisys/include/sparstop.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* sparstop.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __SPARSTOP_H__
-#define __SPARSTOP_H__
-
-#include "timskmod.h"
-#include "version.h"
-#include <linux/ctype.h>
-
-typedef void (*SPARSTOP_COMPLETE_FUNC) (void *context, int status);
-
-int sp_stop(void *context, SPARSTOP_COMPLETE_FUNC get_complete_func);
-void test_remove_stop_device(void);
-
-#endif
diff --git a/drivers/staging/unisys/include/timskmod.h b/drivers/staging/unisys/include/timskmod.h
deleted file mode 100644
index cde2494ad896df..00000000000000
--- a/drivers/staging/unisys/include/timskmod.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/* timskmod.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __TIMSKMOD_H__
-#define __TIMSKMOD_H__
-
-#include <linux/version.h>
-#include <linux/init.h>
-#include <linux/kernel.h>
-#include <linux/device.h>
-#include <linux/kobject.h>
-#include <linux/sysfs.h>
-#include <linux/fs.h>
-#include <linux/string.h>
-#include <linux/sched.h>
-#include <linux/spinlock.h>
-#include <linux/slab.h>
-#include <linux/errno.h>
-#include <linux/interrupt.h>
-#include <linux/wait.h>
-#include <linux/vmalloc.h>
-#include <linux/proc_fs.h>
-#include <linux/cdev.h>
-#include <linux/types.h>
-#include <asm/irq.h>
-#include <linux/io.h>
-#include <asm/dma.h>
-#include <linux/uaccess.h>
-#include <linux/list.h>
-#include <linux/poll.h>
-/* #define EXPORT_SYMTAB */
-#include <linux/module.h>
-#include <linux/moduleparam.h>
-#include <linux/fcntl.h>
-#include <linux/workqueue.h>
-#include <linux/kthread.h>
-#include <linux/seq_file.h>
-#include <linux/mm.h>
-
-/* #define DEBUG */
-#ifndef BOOL
-#define BOOL int
-#endif
-#define FALSE 0
-#define TRUE 1
-#if !defined SUCCESS
-#define SUCCESS 0
-#endif
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-#define STRUCTSEQUAL(x, y) (memcmp(&x, &y, sizeof(x)) == 0)
-#ifndef HOSTADDRESS
-#define HOSTADDRESS unsigned long long
-#endif
-
-#define sizeofmember(TYPE, MEMBER) (sizeof(((TYPE *)0)->MEMBER))
-/** "Covered quotient" function */
-#define COVQ(v, d) (((v) + (d) - 1) / (d))
-#define SWAPPOINTERS(p1, p2) \
- do { \
- void *SWAPPOINTERS_TEMP = (void *)p1; \
- (void *)(p1) = (void *)(p2); \
- (void *)(p2) = SWAPPOINTERS_TEMP; \
- } while (0)
-
-#define WARNDRV(fmt, args...) LOGWRN(fmt, ## args)
-#define SECUREDRV(fmt, args...) LOGWRN(fmt, ## args)
-
-#define PRINTKDEV(devname, fmt, args...) LOGINFDEV(devname, fmt, ## args)
-#define TBDDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
-#define HUHDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
-#define ERRDEV(devname, fmt, args...) LOGERRDEV(devname, fmt, ## args)
-#define ERRDEVX(devno, fmt, args...) LOGERRDEVX(devno, fmt, ## args)
-#define WARNDEV(devname, fmt, args...) LOGWRNDEV(devname, fmt, ## args)
-#define SECUREDEV(devname, fmt, args...) LOGWRNDEV(devname, fmt, ## args)
-#define INFODEV(devname, fmt, args...) LOGINFDEV(devname, fmt, ## args)
-#define INFODEVX(devno, fmt, args...) LOGINFDEVX(devno, fmt, ## args)
-
-/** Verifies the consistency of your PRIVATEDEVICEDATA structure using
- * conventional "signature" fields:
- * <p>
- * - sig1 should contain the size of the structure
- * - sig2 should contain a pointer to the beginning of the structure
- */
-#define DDLOOKSVALID(dd) \
- ((dd != NULL) && \
- ((dd)->sig1 == sizeof(PRIVATEDEVICEDATA)) && \
- ((dd)->sig2 == dd))
-
-/** Verifies the consistency of your PRIVATEFILEDATA structure using
- * conventional "signature" fields:
- * <p>
- * - sig1 should contain the size of the structure
- * - sig2 should contain a pointer to the beginning of the structure
- */
-#define FDLOOKSVALID(fd) \
- ((fd != NULL) && \
- ((fd)->sig1 == sizeof(PRIVATEFILEDATA)) && \
- ((fd)->sig2 == fd))
-
-/** Sleep for an indicated number of seconds (for use in kernel mode).
- * x - the number of seconds to sleep.
- */
-#define SLEEP(x) \
- do { __set_current_state(TASK_INTERRUPTIBLE); \
- schedule_timeout((x)*HZ); \
- } while (0)
-
-/** Sleep for an indicated number of jiffies (for use in kernel mode).
- * x - the number of jiffies to sleep.
- */
-#define SLEEPJIFFIES(x) \
- do { __set_current_state(TASK_INTERRUPTIBLE); \
- schedule_timeout(x); \
- } while (0)
-
-static inline struct cdev *cdev_alloc_init(struct module *owner,
- const struct file_operations *fops)
-{
- struct cdev *cdev = NULL;
-
- cdev = cdev_alloc();
- if (!cdev)
- return NULL;
- cdev->ops = fops;
- cdev->owner = owner;
-
- /* Note that the memory allocated for cdev will be deallocated
- * when the usage count drops to 0, because it is controlled
- * by a kobject of type ktype_cdev_dynamic. (This
- * deallocation could very well happen outside of our kernel
- * module, like via the cdev_put in __fput() for example.)
- */
- return cdev;
-}
-
-extern int unisys_spar_platform;
-
-#endif
diff --git a/drivers/staging/unisys/include/uisqueue.h b/drivers/staging/unisys/include/uisqueue.h
deleted file mode 100644
index 08ba16ea840ee5..00000000000000
--- a/drivers/staging/unisys/include/uisqueue.h
+++ /dev/null
@@ -1,396 +0,0 @@
-/* uisqueue.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/*
- * Unisys IO Virtualization header NOTE: This file contains only Linux
- * specific structs. All OS-independent structs are in iochannel.h.xx
- */
-
-#ifndef __UISQUEUE_H__
-#define __UISQUEUE_H__
-
-#include "linux/version.h"
-#include "iochannel.h"
-#include <linux/atomic.h>
-#include <linux/semaphore.h>
-#include <linux/uuid.h>
-
-#include "controlvmchannel.h"
-#include "controlvmcompletionstatus.h"
-
-struct uisqueue_info {
- struct channel_header __iomem *chan;
- /* channel containing queues in which scsi commands &
- * responses are queued
- */
- u64 packets_sent;
- u64 packets_received;
- u64 interrupts_sent;
- u64 interrupts_received;
- u64 max_not_empty_cnt;
- u64 total_wakeup_cnt;
- u64 non_empty_wakeup_cnt;
-
- struct {
- struct signal_queue_header reserved1; /* */
- struct signal_queue_header reserved2; /* */
- } safe_uis_queue;
- unsigned int (*send_int_if_needed)(struct uisqueue_info *info,
- unsigned int whichcqueue,
- unsigned char issue_irq_if_empty,
- u64 irq_handle,
- unsigned char io_termination);
-};
-
-/* uisqueue_put_cmdrsp_with_lock_client queues a commmand or response
- * to the specified queue, at the tail if the queue is full but
- * oktowait == 0, then it return 0 indicating failure. otherwise it
- * wait for the queue to become non-full. If command is queued, return
- * 1 for success.
- */
-#define DONT_ISSUE_INTERRUPT 0
-#define ISSUE_INTERRUPT 1
-
-#define DONT_WAIT 0
-#define OK_TO_WAIT 1
-#define UISLIB_LOCK_PREFIX \
- ".section .smp_locks,\"a\"\n" \
- _ASM_ALIGN "\n" \
- _ASM_PTR "661f\n" /* address */ \
- ".previous\n" \
- "661:\n\tlock; "
-
-unsigned long long uisqueue_interlocked_or(unsigned long long __iomem *tgt,
- unsigned long long set);
-unsigned long long uisqueue_interlocked_and(unsigned long long __iomem *tgt,
- unsigned long long set);
-
-int uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo,
- struct uiscmdrsp *cmdrsp,
- unsigned int queue,
- void *insertlock,
- unsigned char issue_irq_if_empty,
- u64 irq_handle,
- char oktowait,
- u8 *channel_id);
-
-/* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue
- * and copies it to the area pointed by cmdrsp param.
- * returns 0 if queue is empty, 1 otherwise
- */
-int
-
-uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo, void *cmdrsp,
- unsigned int queue);
-
-#define MAX_NAME_SIZE_UISQUEUE 64
-
-struct extport_info {
- u8 valid:1;
- /* if 1, indicates this extport slot is occupied
- * if 0, indicates that extport slot is unoccupied */
-
- u32 num_devs_using;
- /* When extport is added, this is set to 0. For exports
- * located in NETWORK switches:
- * Each time a VNIC, i.e., intport, is added to the switch this
- * is used to assign a pref_pnic for the VNIC and when assigned
- * to a VNIC this counter is incremented. When a VNIC is
- * deleted, the extport corresponding to the VNIC's pref_pnic
- * is located and its num_devs_using is decremented. For VNICs,
- * num_devs_using is basically used to load-balance transmit
- * traffic from VNICs.
- */
-
- struct switch_info *swtch;
- struct pci_id pci_id;
- char name[MAX_NAME_SIZE_UISQUEUE];
- union {
- struct vhba_wwnn wwnn;
- unsigned char macaddr[MAX_MACADDR_LEN];
- };
-};
-
-struct device_info {
- void __iomem *chanptr;
- u64 channel_addr;
- u64 channel_bytes;
- uuid_le channel_uuid;
- uuid_le instance_uuid;
- struct irq_info intr;
- struct switch_info *swtch;
- char devid[30]; /* "vbus<busno>:dev<devno>" */
- u16 polling;
- struct semaphore interrupt_callback_lock;
- u32 bus_no;
- u32 dev_no;
- int (*interrupt)(void *);
- void *interrupt_context;
- void *private_data;
- struct list_head list_polling_device_channels;
- unsigned long long moved_to_tail_cnt;
- unsigned long long first_busy_cnt;
- unsigned long long last_on_list_cnt;
-};
-
-enum switch_type {
- RECOVERY_LAN = 1,
- IB_LAN = 2
-};
-
-struct bus_info {
- u32 bus_no, device_count;
- struct device_info **device;
- u64 guest_handle, recv_bus_irq_handle;
- uuid_le bus_inst_uuid;
- struct ultra_vbus_channel_protocol __iomem *bus_channel;
- int bus_channel_bytes;
- struct proc_dir_entry *proc_dir; /* proc/uislib/vbus/<x> */
- struct proc_dir_entry *proc_info; /* proc/uislib/vbus/<x>/info */
- char name[25];
- char partition_name[99];
- struct bus_info *next;
- u8 local_vnic; /* 1 if local vnic created internally
- * by IOVM; 0 otherwise... */
-};
-
-struct sn_list_entry {
- struct uisscsi_dest pdest; /* scsi bus, target, lun for
- * phys disk */
- u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical
- * disk.. The length is always
- * MAX_SERIAL_NUM, padded with
- * spaces */
- struct sn_list_entry *next;
-};
-
-/*
- * IO messages sent to UisnicControlChanFunc & UissdControlChanFunc by
- * code that processes the ControlVm channel messages.
- */
-
-enum iopart_msg_type {
- IOPART_ADD_VNIC,
- IOPART_DEL_VNIC,
- IOPART_DEL_ALL_VNICS,
- IOPART_ADD_VHBA,
- IOPART_ADD_VDISK,
- IOPART_DEL_VHBA,
- IOPART_DEL_VDISK,
- IOPART_DEL_ALL_VDISKS_FOR_VHBA,
- IOPART_DEL_ALL_VHBAS,
- IOPART_ATTACH_PHBA,
- IOPART_DETACH_PHBA, /* 10 */
- IOPART_ATTACH_PNIC,
- IOPART_DETACH_PNIC,
- IOPART_DETACH_VHBA,
- IOPART_DETACH_VNIC,
- IOPART_PAUSE_VDISK,
- IOPART_RESUME_VDISK,
- IOPART_ADD_DEVICE, /* add generic device */
- IOPART_DEL_DEVICE, /* del generic device */
-};
-
-struct add_virt_iopart {
- void *chanptr; /* pointer to data channel */
- u64 guest_handle; /* used to convert guest physical
- * address to real physical address
- * for DMA, for ex. */
- u64 recv_bus_irq_handle; /* used to register to receive
- * bus level interrupts. */
- struct irq_info intr; /* contains recv & send
- * interrupt info */
- /* recvInterruptHandle is used to register to receive
- * interrupts on the data channel. Used by GuestLinux/Windows
- * IO drivers to connect to interrupt. sendInterruptHandle is
- * used by IOPart drivers as parameter to
- * Issue_VMCALL_IO_QUEUE_TRANSITION to interrupt thread in
- * guest linux/windows IO drivers when data channel queue for
- * vhba/vnic goes from EMPTY to NON-EMPTY. */
- struct switch_info *swtch; /* pointer to the virtual
- * switch to which the vnic is
- * connected */
-
- u8 use_g2g_copy; /* Used to determine if a virtual HBA
- * needs to use G2G copy. */
- u8 filler[7];
-
- u32 bus_no;
- u32 dev_no;
- char *params;
- ulong params_bytes;
-
-};
-
-struct add_vdisk_iopart {
- void *chanptr; /* pointer to data channel */
- int implicit;
- struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */
- struct uisscsi_dest pdest; /* scsi bus, target, lun for phys disk */
- u8 sernum[MAX_SERIAL_NUM]; /* serial num of physical disk */
- u32 serlen; /* length of serial num */
-};
-
-struct del_vdisk_iopart {
- void *chanptr; /* pointer to data channel */
- struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */
-};
-
-struct del_virt_iopart {
- void *chanptr; /* pointer to data channel */
-};
-
-struct det_virt_iopart { /* detach internal port */
- void *chanptr; /* pointer to data channel */
- struct switch_info *swtch;
-};
-
-struct paures_vdisk_iopart {
- void *chanptr; /* pointer to data channel */
- struct uisscsi_dest vdest; /* scsi bus, target, lun for virt disk */
-};
-
-struct add_switch_iopart { /* add switch */
- struct switch_info *swtch;
- char *params;
- ulong params_bytes;
-};
-
-struct del_switch_iopart { /* destroy switch */
- struct switch_info *swtch;
-};
-
-struct io_msgs {
- enum iopart_msg_type msgtype;
-
- /* additional params needed by some messages */
- union {
- struct add_virt_iopart add_vhba;
- struct add_virt_iopart add_vnic;
- struct add_vdisk_iopart add_vdisk;
- struct del_virt_iopart del_vhba;
- struct del_virt_iopart del_vnic;
- struct det_virt_iopart det_vhba;
- struct det_virt_iopart det_vnic;
- struct del_vdisk_iopart del_vdisk;
- struct del_virt_iopart del_all_vdisks_for_vhba;
- struct add_virt_iopart add_device;
- struct del_virt_iopart del_device;
- struct det_virt_iopart det_intport;
- struct add_switch_iopart add_switch;
- struct del_switch_iopart del_switch;
- struct extport_info *ext_port; /* for attach or detach
- * pnic/generic delete all
- * vhbas/allvnics need no
- * parameters */
- struct paures_vdisk_iopart paures_vdisk;
- };
-};
-
-/*
-* Guest messages sent to VirtControlChanFunc by code that processes
-* the ControlVm channel messages.
-*/
-
-enum guestpart_msg_type {
- GUEST_ADD_VBUS,
- GUEST_ADD_VHBA,
- GUEST_ADD_VNIC,
- GUEST_DEL_VBUS,
- GUEST_DEL_VHBA,
- GUEST_DEL_VNIC,
- GUEST_DEL_ALL_VHBAS,
- GUEST_DEL_ALL_VNICS,
- GUEST_DEL_ALL_VBUSES, /* deletes all vhbas & vnics on all
- * buses and deletes all buses */
- GUEST_PAUSE_VHBA,
- GUEST_PAUSE_VNIC,
- GUEST_RESUME_VHBA,
- GUEST_RESUME_VNIC
-};
-
-struct add_vbus_guestpart {
- void __iomem *chanptr; /* pointer to data channel for bus -
- * NOT YET USED */
- u32 bus_no; /* bus number to be created/deleted */
- u32 dev_count; /* max num of devices on bus */
- uuid_le bus_uuid; /* indicates type of bus */
- uuid_le instance_uuid; /* instance guid for device */
-};
-
-struct del_vbus_guestpart {
- u32 bus_no; /* bus number to be deleted */
- /* once we start using the bus's channel, add can dump busNo
- * into the channel header and then delete will need only one
- * parameter, chanptr. */
-};
-
-struct add_virt_guestpart {
- void __iomem *chanptr; /* pointer to data channel */
- u32 bus_no; /* bus number for the operation */
- u32 device_no; /* number of device on the bus */
- uuid_le instance_uuid; /* instance guid for device */
- struct irq_info intr; /* recv/send interrupt info */
- /* recvInterruptHandle contains info needed in order to
- * register to receive interrupts on the data channel.
- * sendInterruptHandle contains handle which is provided to
- * monitor VMCALL that will cause an interrupt to be generated
- * for the other end.
- */
-};
-
-struct pause_virt_guestpart {
- void __iomem *chanptr; /* pointer to data channel */
-};
-
-struct resume_virt_guestpart {
- void __iomem *chanptr; /* pointer to data channel */
-};
-
-struct del_virt_guestpart {
- void __iomem *chanptr; /* pointer to data channel */
-};
-
-struct init_chipset_guestpart {
- u32 bus_count; /* indicates the max number of busses */
- u32 switch_count; /* indicates the max number of switches */
-};
-
-struct guest_msgs {
- enum guestpart_msg_type msgtype;
-
- /* additional params needed by messages */
- union {
- struct add_vbus_guestpart add_vbus;
- struct add_virt_guestpart add_vhba;
- struct add_virt_guestpart add_vnic;
- struct pause_virt_guestpart pause_vhba;
- struct pause_virt_guestpart pause_vnic;
- struct resume_virt_guestpart resume_vhba;
- struct resume_virt_guestpart resume_vnic;
- struct del_vbus_guestpart del_vbus;
- struct del_virt_guestpart del_vhba;
- struct del_virt_guestpart del_vnic;
- struct del_vbus_guestpart del_all_vhbas;
- struct del_vbus_guestpart del_all_vnics;
- /* del_all_vbuses needs no parameters */
- };
- struct init_chipset_guestpart init_chipset;
-
-};
-
-#endif /* __UISQUEUE_H__ */
diff --git a/drivers/staging/unisys/include/uisthread.h b/drivers/staging/unisys/include/uisthread.h
deleted file mode 100644
index 52c3eb4ded2c5c..00000000000000
--- a/drivers/staging/unisys/include/uisthread.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* uisthread.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/*****************************************************************************/
-/* Unisys thread utilities header */
-/*****************************************************************************/
-
-#ifndef __UISTHREAD_H__
-#define __UISTHREAD_H__
-
-#include "linux/completion.h"
-
-struct uisthread_info {
- struct task_struct *task;
- int id;
- struct completion has_stopped;
-};
-
-/* returns 0 for failure, 1 for success */
-int uisthread_start(
- struct uisthread_info *thrinfo,
- int (*threadfn)(void *),
- void *thrcontext,
- char *name);
-
-void uisthread_stop(struct uisthread_info *thrinfo);
-
-#endif /* __UISTHREAD_H__ */
diff --git a/drivers/staging/unisys/include/uisutils.h b/drivers/staging/unisys/include/uisutils.h
deleted file mode 100644
index c7d0ba8aafd8aa..00000000000000
--- a/drivers/staging/unisys/include/uisutils.h
+++ /dev/null
@@ -1,299 +0,0 @@
-/* uisutils.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/*
- * Unisys Virtual HBA utilities header
- */
-
-#ifndef __UISUTILS__H__
-#define __UISUTILS__H__
-#include <linux/string.h>
-#include <linux/io.h>
-#include <linux/sched.h>
-#include <linux/gfp.h>
-#include <linux/uuid.h>
-#include <linux/if_ether.h>
-
-#include "vmcallinterface.h"
-#include "channel.h"
-#include "uisthread.h"
-#include "uisqueue.h"
-#include "diagnostics/appos_subsystems.h"
-#include "vbusdeviceinfo.h"
-#include <linux/atomic.h>
-
-/* This is the MAGIC number stuffed by virthba in host->this_id. Used to
- * identify virtual hbas.
- */
-#define UIS_MAGIC_VHBA 707
-
-/* global function pointers that act as callback functions into
- * uisnicmod, uissdmod, and virtpcimod
- */
-extern int (*uisnic_control_chan_func)(struct io_msgs *);
-extern int (*uissd_control_chan_func)(struct io_msgs *);
-extern int (*virt_control_chan_func)(struct guest_msgs *);
-
-/* Return values of above callback functions: */
-#define CCF_ERROR 0 /* completed and failed */
-#define CCF_OK 1 /* completed successfully */
-#define CCF_PENDING 2 /* operation still pending */
-extern atomic_t uisutils_registered_services;
-
-struct req_handler_info {
- uuid_le switch_uuid;
- int (*controlfunc)(struct io_msgs *);
- unsigned long min_channel_bytes;
- int (*server_channel_ok)(unsigned long channel_bytes);
- int (*server_channel_init)(void *x, unsigned char *client_str,
- u32 client_str_len, u64 bytes);
- char switch_type_name[99];
- struct list_head list_link; /* links into ReqHandlerInfo_list */
-};
-
-struct req_handler_info *req_handler_find(uuid_le switch_uuid);
-
-#define uislib_ioremap_cache(addr, size) \
- dbg_ioremap_cache(addr, size, __FILE__, __LINE__)
-
-static inline void __iomem *
-dbg_ioremap_cache(u64 addr, unsigned long size, char *file, int line)
-{
- void __iomem *new;
-
- new = ioremap_cache(addr, size);
- return new;
-}
-
-#define uislib_ioremap(addr, size) dbg_ioremap(addr, size, __FILE__, __LINE__)
-
-static inline void *
-dbg_ioremap(u64 addr, unsigned long size, char *file, int line)
-{
- void *new;
-
- new = ioremap(addr, size);
- return new;
-}
-
-#define uislib_iounmap(addr) dbg_iounmap(addr, __FILE__, __LINE__)
-
-static inline void
-dbg_iounmap(void __iomem *addr, char *file, int line)
-{
- iounmap(addr);
-}
-
-#define PROC_READ_BUFFER_SIZE 131072 /* size of the buffer to allocate to
- * hold all of /proc/XXX/info */
-int uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining,
- char *format, ...);
-
-int uisctrl_register_req_handler(int type, void *fptr,
- struct ultra_vbus_deviceinfo *chipset_driver_info);
-
-unsigned char *util_map_virt(struct phys_info *sg);
-void util_unmap_virt(struct phys_info *sg);
-unsigned char *util_map_virt_atomic(struct phys_info *sg);
-void util_unmap_virt_atomic(void *buf);
-int uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid,
- u64 channel_addr, ulong n_channel_bytes);
-int uislib_client_inject_del_bus(u32 bus_no);
-
-int uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no,
- u64 phys_chan_addr, u32 chan_bytes,
- int is_test_addr, uuid_le inst_uuid,
- struct irq_info *intr);
-int uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no);
-int uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no);
-int uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no);
-int uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no,
- u64 phys_chan_addr, u32 chan_bytes,
- int is_test_addr, uuid_le inst_uuid,
- struct irq_info *intr);
-int uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no);
-int uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no);
-int uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no);
-#ifdef STORAGE_CHANNEL
-u64 uislib_storage_channel(int client_id);
-#endif
-int uislib_get_owned_pdest(struct uisscsi_dest *pdest);
-
-int uislib_send_event(enum controlvm_id id,
- struct controlvm_message_packet *event);
-
-/* structure used by vhba & vnic to keep track of queue & thread info */
-struct chaninfo {
- struct uisqueue_info *queueinfo;
- /* this specifies the queue structures for a channel */
- /* ALLOCATED BY THE OTHER END - WE JUST GET A POINTER TO THE MEMORY */
- spinlock_t insertlock;
- /* currently used only in virtnic when sending data to uisnic */
- /* to synchronize the inserts into the signal queue */
- struct uisthread_info threadinfo;
- /* this specifies the thread structures used by the thread that */
- /* handles this channel */
-};
-
-/* this is the wait code for all the threads - it is used to get
-* something from a queue choices: wait_for_completion_interruptible,
-* _timeout, interruptible_timeout
-*/
-#define UIS_THREAD_WAIT_MSEC(x) { \
- set_current_state(TASK_INTERRUPTIBLE); \
- schedule_timeout(msecs_to_jiffies(x)); \
-}
-
-#define UIS_THREAD_WAIT_USEC(x) { \
- set_current_state(TASK_INTERRUPTIBLE); \
- schedule_timeout(usecs_to_jiffies(x)); \
-}
-
-#define UIS_THREAD_WAIT UIS_THREAD_WAIT_MSEC(5)
-
-#define UIS_THREAD_WAIT_SEC(x) { \
- set_current_state(TASK_INTERRUPTIBLE); \
- schedule_timeout((x)*HZ); \
-}
-
-/* This is a hack until we fix IOVM to initialize the channel header
- * correctly at DEVICE_CREATE time, INSTEAD OF waiting until
- * DEVICE_CONFIGURE time.
- */
-static inline void
-wait_for_valid_guid(uuid_le __iomem *guid)
-{
- uuid_le tmpguid;
-
- while (1) {
- memcpy_fromio((void *)&tmpguid,
- (void __iomem *)guid, sizeof(uuid_le));
- if (uuid_le_cmp(tmpguid, NULL_UUID_LE) != 0)
- break;
- UIS_THREAD_WAIT_SEC(5);
- }
-}
-
-static inline unsigned int
-issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
-{
- struct vmcall_io_controlvm_addr_params params;
- int result = VMCALL_SUCCESS;
- u64 physaddr;
-
- physaddr = virt_to_phys(&params);
- ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result);
- if (VMCALL_SUCCESSFUL(result)) {
- *control_addr = params.address;
- *control_bytes = params.channel_bytes;
- }
- return result;
-}
-
-static inline unsigned int issue_vmcall_io_diag_addr(u64 *diag_channel_addr)
-{
- struct vmcall_io_diag_addr_params params;
- int result = VMCALL_SUCCESS;
- u64 physaddr;
-
- physaddr = virt_to_phys(&params);
- ISSUE_IO_VMCALL(VMCALL_IO_DIAG_ADDR, physaddr, result);
- if (VMCALL_SUCCESSFUL(result))
- *diag_channel_addr = params.address;
- return result;
-}
-
-static inline unsigned int issue_vmcall_io_visorserial_addr(u64 *channel_addr)
-{
- struct vmcall_io_visorserial_addr_params params;
- int result = VMCALL_SUCCESS;
- u64 physaddr;
-
- physaddr = virt_to_phys(&params);
- ISSUE_IO_VMCALL(VMCALL_IO_VISORSERIAL_ADDR, physaddr, result);
- if (VMCALL_SUCCESSFUL(result))
- *channel_addr = params.address;
- return result;
-}
-
-static inline s64 issue_vmcall_query_guest_virtual_time_offset(void)
-{
- u64 result = VMCALL_SUCCESS;
- u64 physaddr = 0;
-
- ISSUE_IO_VMCALL(VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET, physaddr,
- result);
- return result;
-}
-
-struct log_info_t {
- unsigned long long last_cycles;
- unsigned long long delta_sum[64];
- unsigned long long delta_cnt[64];
- unsigned long long max_delta[64];
- unsigned long long min_delta[64];
-};
-
-static inline int issue_vmcall_update_physical_time(u64 adjustment)
-{
- int result = VMCALL_SUCCESS;
-
- ISSUE_IO_VMCALL(VMCALL_UPDATE_PHYSICAL_TIME, adjustment, result);
- return result;
-}
-
-static inline unsigned int issue_vmcall_channel_mismatch(const char *chname,
- const char *item_name, u32 line_no,
- const char *path_n_fn)
-{
- struct vmcall_channel_version_mismatch_params params;
- int result = VMCALL_SUCCESS;
- u64 physaddr;
- char *last_slash = NULL;
-
- strlcpy(params.chname, chname, sizeof(params.chname));
- strlcpy(params.item_name, item_name, sizeof(params.item_name));
- params.line_no = line_no;
-
- last_slash = strrchr(path_n_fn, '/');
- if (last_slash != NULL) {
- last_slash++;
- strlcpy(params.file_name, last_slash, sizeof(params.file_name));
- } else
- strlcpy(params.file_name,
- "Cannot determine source filename",
- sizeof(params.file_name));
-
- physaddr = virt_to_phys(&params);
- ISSUE_IO_VMCALL(VMCALL_CHANNEL_VERSION_MISMATCH, physaddr, result);
- return result;
-}
-
-#define UIS_DAEMONIZE(nam)
-void *uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln);
-#define UISCACHEALLOC(cur_pool) uislib_cache_alloc(cur_pool, __FILE__, __LINE__)
-void uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln);
-#define UISCACHEFREE(cur_pool, p) \
- uislib_cache_free(cur_pool, p, __FILE__, __LINE__)
-
-void uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no,
- int (*interrupt)(void *),
- void *interrupt_context);
-void uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no);
-void uislib_force_channel_interrupt(u32 bus_no, u32 dev_no);
-
-#endif /* __UISUTILS__H__ */
diff --git a/drivers/staging/unisys/include/vbushelper.h b/drivers/staging/unisys/include/vbushelper.h
index 84abe5f99f5442..f272975b2920b6 100644
--- a/drivers/staging/unisys/include/vbushelper.h
+++ b/drivers/staging/unisys/include/vbushelper.h
@@ -18,8 +18,6 @@
#ifndef __VBUSHELPER_H__
#define __VBUSHELPER_H__
-#include "vbusdeviceinfo.h"
-
/* TARGET_HOSTNAME specified as -DTARGET_HOSTNAME=\"thename\" on the
* command line */
diff --git a/drivers/staging/unisys/common-spar/include/version.h b/drivers/staging/unisys/include/version.h
index 83d1da7a2f8134..83d1da7a2f8134 100644
--- a/drivers/staging/unisys/common-spar/include/version.h
+++ b/drivers/staging/unisys/include/version.h
diff --git a/drivers/staging/unisys/include/visorbus.h b/drivers/staging/unisys/include/visorbus.h
new file mode 100644
index 00000000000000..3152ba47c7028f
--- /dev/null
+++ b/drivers/staging/unisys/include/visorbus.h
@@ -0,0 +1,223 @@
+/* visorbus.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * 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 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, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ */
+
+/*
+ * This header file is to be included by other kernel mode components that
+ * implement a particular kind of visor_device. Each of these other kernel
+ * mode components is called a visor device driver. Refer to visortemplate
+ * for a minimal sample visor device driver.
+ *
+ * There should be nothing in this file that is private to the visorbus
+ * bus implementation itself.
+ *
+ */
+
+#ifndef __VISORBUS_H__
+#define __VISORBUS_H__
+
+#include <linux/device.h>
+#include <linux/module.h>
+#include <linux/poll.h>
+#include <linux/kernel.h>
+#include <linux/uuid.h>
+
+#include "periodic_work.h"
+#include "channel.h"
+
+struct visor_driver;
+struct visor_device;
+extern struct bus_type visorbus_type;
+
+typedef void (*visorbus_state_complete_func) (struct visor_device *dev,
+ int status, void *dev_info);
+struct visorchipset_state {
+ u32 created:1;
+ u32 attached:1;
+ u32 configured:1;
+ u32 running:1;
+ /* Add new fields above. */
+ /* Remaining bits in this 32-bit word are unused. */
+};
+
+/** This struct describes a specific Supervisor channel, by providing its
+ * GUID, name, and sizes.
+ */
+struct visor_channeltype_descriptor {
+ const uuid_le guid;
+ const char *name;
+ unsigned long min_size;
+ unsigned long max_size;
+};
+
+/** Information provided by each visor driver when it registers with the
+ * visorbus driver.
+ */
+struct visor_driver {
+ const char *name;
+ const char *version;
+ const char *vertag;
+ const char *build_date;
+ const char *build_time;
+ struct module *owner;
+
+ /** Types of channels handled by this driver, ending with 0 GUID.
+ * Our specialized BUS.match() method knows about this list, and
+ * uses it to determine whether this driver will in fact handle a
+ * new device that it has detected.
+ */
+ struct visor_channeltype_descriptor *channel_types;
+
+ /** Called when a new device comes online, by our probe() function
+ * specified by driver.probe() (triggered ultimately by some call
+ * to driver_register() / bus_add_driver() / driver_attach()).
+ */
+ int (*probe)(struct visor_device *dev);
+
+ /** Called when a new device is removed, by our remove() function
+ * specified by driver.remove() (triggered ultimately by some call
+ * to device_release_driver()).
+ */
+ void (*remove)(struct visor_device *dev);
+
+ /** Called periodically, whenever there is a possibility that
+ * "something interesting" may have happened to the channel state.
+ */
+ void (*channel_interrupt)(struct visor_device *dev);
+
+ /** Called to initiate a change of the device's state. If the return
+ * valu`e is < 0, there was an error and the state transition will NOT
+ * occur. If the return value is >= 0, then the state transition was
+ * INITIATED successfully, and complete_func() will be called (or was
+ * just called) with the final status when either the state transition
+ * fails or completes successfully.
+ */
+ int (*pause)(struct visor_device *dev,
+ visorbus_state_complete_func complete_func,
+ void *dev_info);
+ int (*resume)(struct visor_device *dev,
+ visorbus_state_complete_func complete_func,
+ void *dev_info);
+
+ /** These fields are for private use by the bus driver only. */
+ struct device_driver driver;
+ struct driver_attribute version_attr;
+};
+
+#define to_visor_driver(x) container_of(x, struct visor_driver, driver)
+
+/** A device type for things "plugged" into the visorbus bus */
+
+struct visor_device {
+ /** visor driver can use the visorchannel member with the functions
+ * defined in visorchannel.h to access the channel
+ */
+ struct visorchannel *visorchannel;
+ uuid_le channel_type_guid;
+ u64 channel_bytes;
+
+ /** These fields are for private use by the bus driver only.
+ * A notable exception is that the visor driver can use
+ * visor_get_drvdata() and visor_set_drvdata() to retrieve or stash
+ * private visor driver specific data within the device member.
+ */
+ struct device device;
+ struct list_head list_all;
+ struct periodic_work *periodic_work;
+ bool being_removed;
+ bool responded_to_device_create;
+ struct kobject kobjdevmajorminor; /* visorbus<x>/dev<y>/devmajorminor/*/
+ struct {
+ int major, minor;
+ void *attr; /* private use by devmajorminor_attr.c you can
+ * change this constant to whatever you
+ * want; */
+ } devnodes[5];
+ /* the code will detect and behave appropriately) */
+ struct semaphore visordriver_callback_lock;
+ bool pausing;
+ bool resuming;
+ unsigned long chipset_bus_no;
+ unsigned long chipset_dev_no;
+ struct visorchipset_state state;
+ uuid_le type;
+ uuid_le inst;
+ u8 *name;
+ u8 *description;
+ struct controlvm_message_header *pending_msg_hdr;
+ void *vbus_hdr_info;
+ u32 switch_no;
+ u32 internal_port_no;
+ uuid_le partition_uuid;
+};
+
+#define to_visor_device(x) container_of(x, struct visor_device, device)
+
+#ifndef STANDALONE_CLIENT
+int visorbus_register_visor_driver(struct visor_driver *);
+void visorbus_unregister_visor_driver(struct visor_driver *);
+int visorbus_read_channel(struct visor_device *dev,
+ unsigned long offset, void *dest,
+ unsigned long nbytes);
+int visorbus_write_channel(struct visor_device *dev,
+ unsigned long offset, void *src,
+ unsigned long nbytes);
+int visorbus_clear_channel(struct visor_device *dev,
+ unsigned long offset, u8 ch, unsigned long nbytes);
+int visorbus_registerdevnode(struct visor_device *dev,
+ const char *name, int major, int minor);
+void visorbus_enable_channel_interrupts(struct visor_device *dev);
+void visorbus_disable_channel_interrupts(struct visor_device *dev);
+#endif
+
+/* Note that for visorchannel_create()
+ * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
+ * In this case, the values can simply be read from the channel header.
+ */
+struct visorchannel *visorchannel_create(u64 physaddr,
+ unsigned long channel_bytes,
+ gfp_t gfp, uuid_le guid);
+struct visorchannel *visorchannel_create_with_lock(u64 physaddr,
+ unsigned long channel_bytes,
+ gfp_t gfp, uuid_le guid);
+void visorchannel_destroy(struct visorchannel *channel);
+int visorchannel_read(struct visorchannel *channel, ulong offset,
+ void *local, ulong nbytes);
+int visorchannel_write(struct visorchannel *channel, ulong offset,
+ void *local, ulong nbytes);
+int visorchannel_clear(struct visorchannel *channel, ulong offset,
+ u8 ch, ulong nbytes);
+bool visorchannel_signalremove(struct visorchannel *channel, u32 queue,
+ void *msg);
+bool visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
+ void *msg);
+int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
+ u32 queue);
+int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
+u64 visorchannel_get_physaddr(struct visorchannel *channel);
+ulong visorchannel_get_nbytes(struct visorchannel *channel);
+char *visorchannel_id(struct visorchannel *channel, char *s);
+char *visorchannel_zoneid(struct visorchannel *channel, char *s);
+u64 visorchannel_get_clientpartition(struct visorchannel *channel);
+int visorchannel_set_clientpartition(struct visorchannel *channel,
+ u64 partition_handle);
+uuid_le visorchannel_get_uuid(struct visorchannel *channel);
+char *visorchannel_uuid_id(uuid_le *guid, char *s);
+void visorchannel_debug(struct visorchannel *channel, int num_queues,
+ struct seq_file *seq, u32 off);
+void __iomem *visorchannel_get_header(struct visorchannel *channel);
+
+#endif
diff --git a/drivers/staging/unisys/uislib/Kconfig b/drivers/staging/unisys/uislib/Kconfig
deleted file mode 100644
index c39a0a21ae5fa7..00000000000000
--- a/drivers/staging/unisys/uislib/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# Unisys uislib configuration
-#
-
-config UNISYS_UISLIB
- tristate "Unisys uislib driver"
- select UNISYS_VISORCHIPSET
- ---help---
- If you say Y here, you will enable the Unisys uislib driver.
-
diff --git a/drivers/staging/unisys/uislib/Makefile b/drivers/staging/unisys/uislib/Makefile
deleted file mode 100644
index 860f494f132faf..00000000000000
--- a/drivers/staging/unisys/uislib/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Makefile for Unisys uislib
-#
-
-obj-$(CONFIG_UNISYS_UISLIB) += visoruislib.o
-
-visoruislib-y := uislib.o uisqueue.o uisthread.o uisutils.o
-
-ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/visorchipset
-ccflags-y += -Idrivers/staging/unisys/common-spar/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
diff --git a/drivers/staging/unisys/uislib/uislib.c b/drivers/staging/unisys/uislib/uislib.c
deleted file mode 100644
index f93d0bb11b12d6..00000000000000
--- a/drivers/staging/unisys/uislib/uislib.c
+++ /dev/null
@@ -1,1372 +0,0 @@
-/* uislib.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/* @ALL_INSPECTED */
-#define EXPORT_SYMTAB
-#include <linux/kernel.h>
-#include <linux/highmem.h>
-#ifdef CONFIG_MODVERSIONS
-#include <config/modversions.h>
-#endif
-#include <linux/module.h>
-#include <linux/debugfs.h>
-
-#include <linux/types.h>
-#include <linux/uuid.h>
-
-#include <linux/version.h>
-#include "diagnostics/appos_subsystems.h"
-#include "uisutils.h"
-#include "vbuschannel.h"
-
-#include <linux/proc_fs.h>
-#include <linux/uaccess.h> /* for copy_from_user */
-#include <linux/ctype.h> /* for toupper */
-#include <linux/list.h>
-
-#include "sparstop.h"
-#include "visorchipset.h"
-#include "version.h"
-#include "guestlinuxdebug.h"
-
-#define SET_PROC_OWNER(x, y)
-
-#define POLLJIFFIES_NORMAL 1
-/* Choose whether or not you want to wakeup the request-polling thread
- * after an IO termination:
- * this is shorter than using __FILE__ (full path name) in
- * debug/info/error messages
- */
-#define CURRENT_FILE_PC UISLIB_PC_uislib_c
-#define __MYFILE__ "uislib.c"
-
-/* global function pointers that act as callback functions into virtpcimod */
-int (*virt_control_chan_func)(struct guest_msgs *);
-
-static int debug_buf_valid;
-static char *debug_buf; /* Note this MUST be global,
- * because the contents must */
-static unsigned int chipset_inited;
-
-#define WAIT_ON_CALLBACK(handle) \
- do { \
- if (handle) \
- break; \
- UIS_THREAD_WAIT; \
- } while (1)
-
-static struct bus_info *bus_list;
-static rwlock_t bus_list_lock;
-static int bus_list_count; /* number of buses in the list */
-static int max_bus_count; /* maximum number of buses expected */
-static u64 phys_data_chan;
-static int platform_no;
-
-static struct uisthread_info incoming_ti;
-static BOOL incoming_started = FALSE;
-static LIST_HEAD(poll_dev_chan);
-static unsigned long long tot_moved_to_tail_cnt;
-static unsigned long long tot_wait_cnt;
-static unsigned long long tot_wakeup_cnt;
-static unsigned long long tot_schedule_cnt;
-static int en_smart_wakeup = 1;
-static DEFINE_SEMAPHORE(poll_dev_lock); /* unlocked */
-static DECLARE_WAIT_QUEUE_HEAD(poll_dev_wake_q);
-static int poll_dev_start;
-
-#define CALLHOME_PROC_ENTRY_FN "callhome"
-#define CALLHOME_THROTTLED_PROC_ENTRY_FN "callhome_throttled"
-
-#define DIR_DEBUGFS_ENTRY "uislib"
-static struct dentry *dir_debugfs;
-
-#define PLATFORMNUMBER_DEBUGFS_ENTRY_FN "platform"
-static struct dentry *platformnumber_debugfs_read;
-
-#define CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN "cycles_before_wait"
-static struct dentry *cycles_before_wait_debugfs_read;
-
-#define SMART_WAKEUP_DEBUGFS_ENTRY_FN "smart_wakeup"
-static struct dentry *smart_wakeup_debugfs_entry;
-
-#define INFO_DEBUGFS_ENTRY_FN "info"
-static struct dentry *info_debugfs_entry;
-
-static unsigned long long cycles_before_wait, wait_cycles;
-
-/*****************************************************/
-/* local functions */
-/*****************************************************/
-
-static ssize_t info_debugfs_read(struct file *file, char __user *buf,
- size_t len, loff_t *offset);
-static const struct file_operations debugfs_info_fops = {
- .read = info_debugfs_read,
-};
-
-static void
-init_msg_header(struct controlvm_message *msg, u32 id, uint rsp, uint svr)
-{
- memset(msg, 0, sizeof(struct controlvm_message));
- msg->hdr.id = id;
- msg->hdr.flags.response_expected = rsp;
- msg->hdr.flags.server = svr;
-}
-
-static __iomem void *init_vbus_channel(u64 ch_addr, u32 ch_bytes)
-{
- void __iomem *ch = uislib_ioremap_cache(ch_addr, ch_bytes);
-
- if (!ch)
- return NULL;
-
- if (!SPAR_VBUS_CHANNEL_OK_CLIENT(ch)) {
- uislib_iounmap(ch);
- return NULL;
- }
- return ch;
-}
-
-static int
-create_bus(struct controlvm_message *msg, char *buf)
-{
- u32 bus_no, dev_count;
- struct bus_info *tmp, *bus;
- size_t size;
-
- if (max_bus_count == bus_list_count) {
- POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, max_bus_count,
- POSTCODE_SEVERITY_ERR);
- return CONTROLVM_RESP_ERROR_MAX_BUSES;
- }
-
- bus_no = msg->cmd.create_bus.bus_no;
- dev_count = msg->cmd.create_bus.dev_count;
-
- POSTCODE_LINUX_4(BUS_CREATE_ENTRY_PC, bus_no, dev_count,
- POSTCODE_SEVERITY_INFO);
-
- size =
- sizeof(struct bus_info) +
- (dev_count * sizeof(struct device_info *));
- bus = kzalloc(size, GFP_ATOMIC);
- if (!bus) {
- POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
- POSTCODE_SEVERITY_ERR);
- return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
- }
-
- /* Currently by default, the bus Number is the GuestHandle.
- * Configure Bus message can override this.
- */
- if (msg->hdr.flags.test_message) {
- /* This implies we're the IOVM so set guest handle to 0... */
- bus->guest_handle = 0;
- bus->bus_no = bus_no;
- bus->local_vnic = 1;
- } else {
- bus->bus_no = bus_no;
- bus->guest_handle = bus_no;
- }
- sprintf(bus->name, "%d", (int)bus->bus_no);
- bus->device_count = dev_count;
- bus->device =
- (struct device_info **)((char *)bus + sizeof(struct bus_info));
- bus->bus_inst_uuid = msg->cmd.create_bus.bus_inst_uuid;
- bus->bus_channel_bytes = 0;
- bus->bus_channel = NULL;
-
- /* add bus to our bus list - but check for duplicates first */
- read_lock(&bus_list_lock);
- for (tmp = bus_list; tmp; tmp = tmp->next) {
- if (tmp->bus_no == bus->bus_no)
- break;
- }
- read_unlock(&bus_list_lock);
- if (tmp) {
- /* found a bus already in the list with same bus_no -
- * reject add
- */
- POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
- POSTCODE_SEVERITY_ERR);
- kfree(bus);
- return CONTROLVM_RESP_ERROR_ALREADY_DONE;
- }
- if ((msg->cmd.create_bus.channel_addr != 0) &&
- (msg->cmd.create_bus.channel_bytes != 0)) {
- bus->bus_channel_bytes = msg->cmd.create_bus.channel_bytes;
- bus->bus_channel =
- init_vbus_channel(msg->cmd.create_bus.channel_addr,
- msg->cmd.create_bus.channel_bytes);
- }
- /* the msg is bound for virtpci; send guest_msgs struct to callback */
- if (!msg->hdr.flags.server) {
- struct guest_msgs cmd;
-
- cmd.msgtype = GUEST_ADD_VBUS;
- cmd.add_vbus.bus_no = bus_no;
- cmd.add_vbus.chanptr = bus->bus_channel;
- cmd.add_vbus.dev_count = dev_count;
- cmd.add_vbus.bus_uuid = msg->cmd.create_bus.bus_data_type_uuid;
- cmd.add_vbus.instance_uuid = msg->cmd.create_bus.bus_inst_uuid;
- if (!virt_control_chan_func) {
- POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
- POSTCODE_SEVERITY_ERR);
- kfree(bus);
- return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
- }
- if (!virt_control_chan_func(&cmd)) {
- POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus->bus_no,
- POSTCODE_SEVERITY_ERR);
- kfree(bus);
- return
- CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
- }
- }
-
- /* add bus at the head of our list */
- write_lock(&bus_list_lock);
- if (!bus_list) {
- bus_list = bus;
- } else {
- bus->next = bus_list;
- bus_list = bus;
- }
- bus_list_count++;
- write_unlock(&bus_list_lock);
-
- POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus->bus_no,
- POSTCODE_SEVERITY_INFO);
- return CONTROLVM_RESP_SUCCESS;
-}
-
-static int
-destroy_bus(struct controlvm_message *msg, char *buf)
-{
- int i;
- struct bus_info *bus, *prev = NULL;
- struct guest_msgs cmd;
- u32 bus_no;
-
- bus_no = msg->cmd.destroy_bus.bus_no;
-
- read_lock(&bus_list_lock);
-
- bus = bus_list;
- while (bus) {
- if (bus->bus_no == bus_no)
- break;
- prev = bus;
- bus = bus->next;
- }
-
- if (!bus) {
- read_unlock(&bus_list_lock);
- return CONTROLVM_RESP_ERROR_ALREADY_DONE;
- }
-
- /* verify that this bus has no devices. */
- for (i = 0; i < bus->device_count; i++) {
- if (bus->device[i]) {
- read_unlock(&bus_list_lock);
- return CONTROLVM_RESP_ERROR_BUS_DEVICE_ATTACHED;
- }
- }
- read_unlock(&bus_list_lock);
-
- if (msg->hdr.flags.server)
- goto remove;
-
- /* client messages require us to call the virtpci callback associated
- with this bus. */
- cmd.msgtype = GUEST_DEL_VBUS;
- cmd.del_vbus.bus_no = bus_no;
- if (!virt_control_chan_func)
- return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
-
- if (!virt_control_chan_func(&cmd))
- return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
-
- /* finally, remove the bus from the list */
-remove:
- write_lock(&bus_list_lock);
- if (prev) /* not at head */
- prev->next = bus->next;
- else
- bus_list = bus->next;
- bus_list_count--;
- write_unlock(&bus_list_lock);
-
- if (bus->bus_channel) {
- uislib_iounmap(bus->bus_channel);
- bus->bus_channel = NULL;
- }
-
- kfree(bus);
- return CONTROLVM_RESP_SUCCESS;
-}
-
-static int create_device(struct controlvm_message *msg, char *buf)
-{
- struct device_info *dev;
- struct bus_info *bus;
- struct guest_msgs cmd;
- u32 bus_no, dev_no;
- int result = CONTROLVM_RESP_SUCCESS;
- u64 min_size = MIN_IO_CHANNEL_SIZE;
- struct req_handler_info *req_handler;
-
- bus_no = msg->cmd.create_device.bus_no;
- dev_no = msg->cmd.create_device.dev_no;
-
- POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_INFO);
-
- dev = kzalloc(sizeof(*dev), GFP_ATOMIC);
- if (!dev) {
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_ERR);
- return CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
- }
-
- dev->channel_uuid = msg->cmd.create_device.data_type_uuid;
- dev->intr = msg->cmd.create_device.intr;
- dev->channel_addr = msg->cmd.create_device.channel_addr;
- dev->bus_no = bus_no;
- dev->dev_no = dev_no;
- sema_init(&dev->interrupt_callback_lock, 1); /* unlocked */
- sprintf(dev->devid, "vbus%u:dev%u", (unsigned)bus_no, (unsigned)dev_no);
- /* map the channel memory for the device. */
- if (msg->hdr.flags.test_message) {
- dev->chanptr = (void __iomem *)__va(dev->channel_addr);
- } else {
- req_handler = req_handler_find(dev->channel_uuid);
- if (req_handler)
- /* generic service handler registered for this
- * channel
- */
- min_size = req_handler->min_channel_bytes;
- if (min_size > msg->cmd.create_device.channel_bytes) {
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
- bus_no, POSTCODE_SEVERITY_ERR);
- result = CONTROLVM_RESP_ERROR_CHANNEL_SIZE_TOO_SMALL;
- goto cleanup;
- }
- dev->chanptr =
- uislib_ioremap_cache(dev->channel_addr,
- msg->cmd.create_device.channel_bytes);
- if (!dev->chanptr) {
- result = CONTROLVM_RESP_ERROR_IOREMAP_FAILED;
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
- bus_no, POSTCODE_SEVERITY_ERR);
- goto cleanup;
- }
- }
- dev->instance_uuid = msg->cmd.create_device.dev_inst_uuid;
- dev->channel_bytes = msg->cmd.create_device.channel_bytes;
-
- read_lock(&bus_list_lock);
- for (bus = bus_list; bus; bus = bus->next) {
- if (bus->bus_no != bus_no)
- continue;
- /* make sure the device number is valid */
- if (dev_no >= bus->device_count) {
- result = CONTROLVM_RESP_ERROR_MAX_DEVICES;
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
- bus_no, POSTCODE_SEVERITY_ERR);
- read_unlock(&bus_list_lock);
- goto cleanup;
- }
- /* make sure this device is not already set */
- if (bus->device[dev_no]) {
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC,
- dev_no, bus_no,
- POSTCODE_SEVERITY_ERR);
- result = CONTROLVM_RESP_ERROR_ALREADY_DONE;
- read_unlock(&bus_list_lock);
- goto cleanup;
- }
- read_unlock(&bus_list_lock);
- /* the msg is bound for virtpci; send
- * guest_msgs struct to callback
- */
- if (msg->hdr.flags.server) {
- bus->device[dev_no] = dev;
- POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no,
- bus_no, POSTCODE_SEVERITY_INFO);
- return CONTROLVM_RESP_SUCCESS;
- }
- if (uuid_le_cmp(dev->channel_uuid,
- spar_vhba_channel_protocol_uuid) == 0) {
- wait_for_valid_guid(&((struct channel_header __iomem *)
- (dev->chanptr))->chtype);
- if (!SPAR_VHBA_CHANNEL_OK_CLIENT(dev->chanptr)) {
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC,
- dev_no, bus_no,
- POSTCODE_SEVERITY_ERR);
- result = CONTROLVM_RESP_ERROR_CHANNEL_INVALID;
- goto cleanup;
- }
- cmd.msgtype = GUEST_ADD_VHBA;
- cmd.add_vhba.chanptr = dev->chanptr;
- cmd.add_vhba.bus_no = bus_no;
- cmd.add_vhba.device_no = dev_no;
- cmd.add_vhba.instance_uuid = dev->instance_uuid;
- cmd.add_vhba.intr = dev->intr;
- } else if (uuid_le_cmp(dev->channel_uuid,
- spar_vnic_channel_protocol_uuid) == 0) {
- wait_for_valid_guid(&((struct channel_header __iomem *)
- (dev->chanptr))->chtype);
- if (!SPAR_VNIC_CHANNEL_OK_CLIENT(dev->chanptr)) {
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC,
- dev_no, bus_no,
- POSTCODE_SEVERITY_ERR);
- result = CONTROLVM_RESP_ERROR_CHANNEL_INVALID;
- goto cleanup;
- }
- cmd.msgtype = GUEST_ADD_VNIC;
- cmd.add_vnic.chanptr = dev->chanptr;
- cmd.add_vnic.bus_no = bus_no;
- cmd.add_vnic.device_no = dev_no;
- cmd.add_vnic.instance_uuid = dev->instance_uuid;
- cmd.add_vhba.intr = dev->intr;
- } else {
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
- bus_no, POSTCODE_SEVERITY_ERR);
- result = CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
- goto cleanup;
- }
-
- if (!virt_control_chan_func) {
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
- bus_no, POSTCODE_SEVERITY_ERR);
- result = CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
- goto cleanup;
- }
-
- if (!virt_control_chan_func(&cmd)) {
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no,
- bus_no, POSTCODE_SEVERITY_ERR);
- result =
- CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
- goto cleanup;
- }
-
- bus->device[dev_no] = dev;
- POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no,
- bus_no, POSTCODE_SEVERITY_INFO);
- return CONTROLVM_RESP_SUCCESS;
- }
- read_unlock(&bus_list_lock);
-
- POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_ERR);
- result = CONTROLVM_RESP_ERROR_BUS_INVALID;
-
-cleanup:
- if (!msg->hdr.flags.test_message) {
- uislib_iounmap(dev->chanptr);
- dev->chanptr = NULL;
- }
-
- kfree(dev);
- return result;
-}
-
-static int pause_device(struct controlvm_message *msg)
-{
- u32 bus_no, dev_no;
- struct bus_info *bus;
- struct device_info *dev;
- struct guest_msgs cmd;
- int retval = CONTROLVM_RESP_SUCCESS;
-
- bus_no = msg->cmd.device_change_state.bus_no;
- dev_no = msg->cmd.device_change_state.dev_no;
-
- read_lock(&bus_list_lock);
- for (bus = bus_list; bus; bus = bus->next) {
- if (bus->bus_no == bus_no) {
- /* make sure the device number is valid */
- if (dev_no >= bus->device_count) {
- retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
- } else {
- /* make sure this device exists */
- dev = bus->device[dev_no];
- if (!dev) {
- retval =
- CONTROLVM_RESP_ERROR_ALREADY_DONE;
- }
- }
- break;
- }
- }
- if (!bus)
- retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
-
- read_unlock(&bus_list_lock);
- if (retval == CONTROLVM_RESP_SUCCESS) {
- /* the msg is bound for virtpci; send
- * guest_msgs struct to callback
- */
- if (uuid_le_cmp(dev->channel_uuid,
- spar_vhba_channel_protocol_uuid) == 0) {
- cmd.msgtype = GUEST_PAUSE_VHBA;
- cmd.pause_vhba.chanptr = dev->chanptr;
- } else if (uuid_le_cmp(dev->channel_uuid,
- spar_vnic_channel_protocol_uuid) == 0) {
- cmd.msgtype = GUEST_PAUSE_VNIC;
- cmd.pause_vnic.chanptr = dev->chanptr;
- } else {
- return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
- }
- if (!virt_control_chan_func)
- return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
- if (!virt_control_chan_func(&cmd)) {
- return
- CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
- }
- }
- return retval;
-}
-
-static int resume_device(struct controlvm_message *msg)
-{
- u32 bus_no, dev_no;
- struct bus_info *bus;
- struct device_info *dev;
- struct guest_msgs cmd;
- int retval = CONTROLVM_RESP_SUCCESS;
-
- bus_no = msg->cmd.device_change_state.bus_no;
- dev_no = msg->cmd.device_change_state.dev_no;
-
- read_lock(&bus_list_lock);
- for (bus = bus_list; bus; bus = bus->next) {
- if (bus->bus_no == bus_no) {
- /* make sure the device number is valid */
- if (dev_no >= bus->device_count) {
- retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
- } else {
- /* make sure this device exists */
- dev = bus->device[dev_no];
- if (!dev) {
- retval =
- CONTROLVM_RESP_ERROR_ALREADY_DONE;
- }
- }
- break;
- }
- }
-
- if (!bus)
- retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
-
- read_unlock(&bus_list_lock);
- /* the msg is bound for virtpci; send
- * guest_msgs struct to callback
- */
- if (retval == CONTROLVM_RESP_SUCCESS) {
- if (uuid_le_cmp(dev->channel_uuid,
- spar_vhba_channel_protocol_uuid) == 0) {
- cmd.msgtype = GUEST_RESUME_VHBA;
- cmd.resume_vhba.chanptr = dev->chanptr;
- } else if (uuid_le_cmp(dev->channel_uuid,
- spar_vnic_channel_protocol_uuid) == 0) {
- cmd.msgtype = GUEST_RESUME_VNIC;
- cmd.resume_vnic.chanptr = dev->chanptr;
- } else {
- return CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
- }
- if (!virt_control_chan_func)
- return CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
- if (!virt_control_chan_func(&cmd)) {
- return
- CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
- }
- }
- return retval;
-}
-
-static int destroy_device(struct controlvm_message *msg, char *buf)
-{
- u32 bus_no, dev_no;
- struct bus_info *bus;
- struct device_info *dev;
- struct guest_msgs cmd;
- int retval = CONTROLVM_RESP_SUCCESS;
-
- bus_no = msg->cmd.destroy_device.bus_no;
- dev_no = msg->cmd.destroy_device.bus_no;
-
- read_lock(&bus_list_lock);
- for (bus = bus_list; bus; bus = bus->next) {
- if (bus->bus_no == bus_no) {
- /* make sure the device number is valid */
- if (dev_no >= bus->device_count) {
- retval = CONTROLVM_RESP_ERROR_DEVICE_INVALID;
- } else {
- /* make sure this device exists */
- dev = bus->device[dev_no];
- if (!dev) {
- retval =
- CONTROLVM_RESP_ERROR_ALREADY_DONE;
- }
- }
- break;
- }
- }
-
- if (!bus)
- retval = CONTROLVM_RESP_ERROR_BUS_INVALID;
- read_unlock(&bus_list_lock);
- if (retval == CONTROLVM_RESP_SUCCESS) {
- /* the msg is bound for virtpci; send
- * guest_msgs struct to callback
- */
- if (uuid_le_cmp(dev->channel_uuid,
- spar_vhba_channel_protocol_uuid) == 0) {
- cmd.msgtype = GUEST_DEL_VHBA;
- cmd.del_vhba.chanptr = dev->chanptr;
- } else if (uuid_le_cmp(dev->channel_uuid,
- spar_vnic_channel_protocol_uuid) == 0) {
- cmd.msgtype = GUEST_DEL_VNIC;
- cmd.del_vnic.chanptr = dev->chanptr;
- } else {
- return
- CONTROLVM_RESP_ERROR_CHANNEL_TYPE_UNKNOWN;
- }
- if (!virt_control_chan_func) {
- return
- CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_FAILURE;
- }
- if (!virt_control_chan_func(&cmd)) {
- return
- CONTROLVM_RESP_ERROR_VIRTPCI_DRIVER_CALLBACK_ERROR;
- }
-/* you must disable channel interrupts BEFORE you unmap the channel,
- * because if you unmap first, there may still be some activity going
- * on which accesses the channel and you will get a "unable to handle
- * kernel paging request"
- */
- if (dev->polling)
- uislib_disable_channel_interrupts(bus_no, dev_no);
- /* unmap the channel memory for the device. */
- if (!msg->hdr.flags.test_message)
- uislib_iounmap(dev->chanptr);
- kfree(dev);
- bus->device[dev_no] = NULL;
- }
- return retval;
-}
-
-static int
-init_chipset(struct controlvm_message *msg, char *buf)
-{
- POSTCODE_LINUX_2(CHIPSET_INIT_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-
- max_bus_count = msg->cmd.init_chipset.bus_count;
- platform_no = msg->cmd.init_chipset.platform_number;
- phys_data_chan = 0;
-
- /* We need to make sure we have our functions registered
- * before processing messages. If we are a test vehicle the
- * test_message for init_chipset will be set. We can ignore the
- * waits for the callbacks, since this will be manually entered
- * from a user. If no test_message is set, we will wait for the
- * functions.
- */
- if (!msg->hdr.flags.test_message)
- WAIT_ON_CALLBACK(virt_control_chan_func);
-
- chipset_inited = 1;
- POSTCODE_LINUX_2(CHIPSET_INIT_EXIT_PC, POSTCODE_SEVERITY_INFO);
-
- return CONTROLVM_RESP_SUCCESS;
-}
-
-static int delete_bus_glue(u32 bus_no)
-{
- struct controlvm_message msg;
-
- init_msg_header(&msg, CONTROLVM_BUS_DESTROY, 0, 0);
- msg.cmd.destroy_bus.bus_no = bus_no;
- if (destroy_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS)
- return 0;
- return 1;
-}
-
-static int delete_device_glue(u32 bus_no, u32 dev_no)
-{
- struct controlvm_message msg;
-
- init_msg_header(&msg, CONTROLVM_DEVICE_DESTROY, 0, 0);
- msg.cmd.destroy_device.bus_no = bus_no;
- msg.cmd.destroy_device.dev_no = dev_no;
- if (destroy_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS)
- return 0;
- return 1;
-}
-
-int
-uislib_client_inject_add_bus(u32 bus_no, uuid_le inst_uuid,
- u64 channel_addr, ulong n_channel_bytes)
-{
- struct controlvm_message msg;
-
- /* step 0: init the chipset */
- POSTCODE_LINUX_3(CHIPSET_INIT_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
-
- if (!chipset_inited) {
- /* step: initialize the chipset */
- init_msg_header(&msg, CONTROLVM_CHIPSET_INIT, 0, 0);
- /* this change is needed so that console will come up
- * OK even when the bus 0 create comes in late. If the
- * bus 0 create is the first create, then the add_vnic
- * will work fine, but if the bus 0 create arrives
- * after number 4, then the add_vnic will fail, and the
- * ultraboot will fail.
- */
- msg.cmd.init_chipset.bus_count = 23;
- msg.cmd.init_chipset.switch_count = 0;
- if (init_chipset(&msg, NULL) != CONTROLVM_RESP_SUCCESS)
- return 0;
- POSTCODE_LINUX_3(CHIPSET_INIT_EXIT_PC, bus_no,
- POSTCODE_SEVERITY_INFO);
- }
-
- /* step 1: create a bus */
- POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no,
- POSTCODE_SEVERITY_WARNING);
- init_msg_header(&msg, CONTROLVM_BUS_CREATE, 0, 0);
- msg.cmd.create_bus.bus_no = bus_no;
- msg.cmd.create_bus.dev_count = 23; /* devNo+1; */
- msg.cmd.create_bus.channel_addr = channel_addr;
- msg.cmd.create_bus.channel_bytes = n_channel_bytes;
- if (create_bus(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
- POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
- POSTCODE_SEVERITY_ERR);
- return 0;
- }
- POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
-
- return 1;
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_add_bus);
-
-int
-uislib_client_inject_del_bus(u32 bus_no)
-{
- return delete_bus_glue(bus_no);
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_del_bus);
-
-int
-uislib_client_inject_pause_vhba(u32 bus_no, u32 dev_no)
-{
- struct controlvm_message msg;
- int rc;
-
- init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0);
- msg.cmd.device_change_state.bus_no = bus_no;
- msg.cmd.device_change_state.dev_no = dev_no;
- msg.cmd.device_change_state.state = segment_state_standby;
- rc = pause_device(&msg);
- if (rc != CONTROLVM_RESP_SUCCESS)
- return rc;
- return 0;
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vhba);
-
-int
-uislib_client_inject_resume_vhba(u32 bus_no, u32 dev_no)
-{
- struct controlvm_message msg;
- int rc;
-
- init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0);
- msg.cmd.device_change_state.bus_no = bus_no;
- msg.cmd.device_change_state.dev_no = dev_no;
- msg.cmd.device_change_state.state = segment_state_running;
- rc = resume_device(&msg);
- if (rc != CONTROLVM_RESP_SUCCESS)
- return rc;
- return 0;
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vhba);
-
-int
-uislib_client_inject_add_vhba(u32 bus_no, u32 dev_no,
- u64 phys_chan_addr, u32 chan_bytes,
- int is_test_addr, uuid_le inst_uuid,
- struct irq_info *intr)
-{
- struct controlvm_message msg;
-
- /* chipset init'ed with bus bus has been previously created -
- * Verify it still exists step 2: create the VHBA device on the
- * bus
- */
- POSTCODE_LINUX_4(VHBA_CREATE_ENTRY_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_INFO);
-
- init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0);
- if (is_test_addr)
- /* signify that the physical channel address does NOT
- * need to be ioremap()ed
- */
- msg.hdr.flags.test_message = 1;
- msg.cmd.create_device.bus_no = bus_no;
- msg.cmd.create_device.dev_no = dev_no;
- msg.cmd.create_device.dev_inst_uuid = inst_uuid;
- if (intr)
- msg.cmd.create_device.intr = *intr;
- else
- memset(&msg.cmd.create_device.intr, 0,
- sizeof(struct irq_info));
- msg.cmd.create_device.channel_addr = phys_chan_addr;
- if (chan_bytes < MIN_IO_CHANNEL_SIZE) {
- POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, chan_bytes,
- MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR);
- return 0;
- }
- msg.cmd.create_device.channel_bytes = chan_bytes;
- msg.cmd.create_device.data_type_uuid = spar_vhba_channel_protocol_uuid;
- if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
- POSTCODE_LINUX_4(VHBA_CREATE_FAILURE_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_ERR);
- return 0;
- }
- POSTCODE_LINUX_4(VHBA_CREATE_SUCCESS_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_INFO);
- return 1;
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_add_vhba);
-
-int
-uislib_client_inject_del_vhba(u32 bus_no, u32 dev_no)
-{
- return delete_device_glue(bus_no, dev_no);
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_del_vhba);
-
-int
-uislib_client_inject_add_vnic(u32 bus_no, u32 dev_no,
- u64 phys_chan_addr, u32 chan_bytes,
- int is_test_addr, uuid_le inst_uuid,
- struct irq_info *intr)
-{
- struct controlvm_message msg;
-
- /* chipset init'ed with bus bus has been previously created -
- * Verify it still exists step 2: create the VNIC device on the
- * bus
- */
- POSTCODE_LINUX_4(VNIC_CREATE_ENTRY_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_INFO);
-
- init_msg_header(&msg, CONTROLVM_DEVICE_CREATE, 0, 0);
- if (is_test_addr)
- /* signify that the physical channel address does NOT
- * need to be ioremap()ed
- */
- msg.hdr.flags.test_message = 1;
- msg.cmd.create_device.bus_no = bus_no;
- msg.cmd.create_device.dev_no = dev_no;
- msg.cmd.create_device.dev_inst_uuid = inst_uuid;
- if (intr)
- msg.cmd.create_device.intr = *intr;
- else
- memset(&msg.cmd.create_device.intr, 0,
- sizeof(struct irq_info));
- msg.cmd.create_device.channel_addr = phys_chan_addr;
- if (chan_bytes < MIN_IO_CHANNEL_SIZE) {
- POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, chan_bytes,
- MIN_IO_CHANNEL_SIZE, POSTCODE_SEVERITY_ERR);
- return 0;
- }
- msg.cmd.create_device.channel_bytes = chan_bytes;
- msg.cmd.create_device.data_type_uuid = spar_vnic_channel_protocol_uuid;
- if (create_device(&msg, NULL) != CONTROLVM_RESP_SUCCESS) {
- POSTCODE_LINUX_4(VNIC_CREATE_FAILURE_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_ERR);
- return 0;
- }
-
- POSTCODE_LINUX_4(VNIC_CREATE_SUCCESS_PC, dev_no, bus_no,
- POSTCODE_SEVERITY_INFO);
- return 1;
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_add_vnic);
-
-int
-uislib_client_inject_pause_vnic(u32 bus_no, u32 dev_no)
-{
- struct controlvm_message msg;
- int rc;
-
- init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0);
- msg.cmd.device_change_state.bus_no = bus_no;
- msg.cmd.device_change_state.dev_no = dev_no;
- msg.cmd.device_change_state.state = segment_state_standby;
- rc = pause_device(&msg);
- if (rc != CONTROLVM_RESP_SUCCESS)
- return -1;
- return 0;
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_pause_vnic);
-
-int
-uislib_client_inject_resume_vnic(u32 bus_no, u32 dev_no)
-{
- struct controlvm_message msg;
- int rc;
-
- init_msg_header(&msg, CONTROLVM_DEVICE_CHANGESTATE, 0, 0);
- msg.cmd.device_change_state.bus_no = bus_no;
- msg.cmd.device_change_state.dev_no = dev_no;
- msg.cmd.device_change_state.state = segment_state_running;
- rc = resume_device(&msg);
- if (rc != CONTROLVM_RESP_SUCCESS)
- return -1;
- return 0;
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_resume_vnic);
-
-int
-uislib_client_inject_del_vnic(u32 bus_no, u32 dev_no)
-{
- return delete_device_glue(bus_no, dev_no);
-}
-EXPORT_SYMBOL_GPL(uislib_client_inject_del_vnic);
-
-void *
-uislib_cache_alloc(struct kmem_cache *cur_pool, char *fn, int ln)
-{
- /* __GFP_NORETRY means "ok to fail", meaning kmalloc() can
- * return NULL. If you do NOT specify __GFP_NORETRY, Linux
- * will go to extreme measures to get memory for you (like,
- * invoke oom killer), which will probably cripple the system.
- */
- void *p = kmem_cache_alloc(cur_pool, GFP_ATOMIC | __GFP_NORETRY);
-
- if (!p)
- return NULL;
- return p;
-}
-EXPORT_SYMBOL_GPL(uislib_cache_alloc);
-
-void
-uislib_cache_free(struct kmem_cache *cur_pool, void *p, char *fn, int ln)
-{
- if (!p)
- return;
- kmem_cache_free(cur_pool, p);
-}
-EXPORT_SYMBOL_GPL(uislib_cache_free);
-
-/*****************************************************/
-/* proc filesystem callback functions */
-/*****************************************************/
-
-#define PLINE(...) uisutil_add_proc_line_ex(&tot, buff, \
- buff_len, __VA_ARGS__)
-
-static int
-info_debugfs_read_helper(char **buff, int *buff_len)
-{
- int i, tot = 0;
- struct bus_info *bus;
-
- if (PLINE("\nBuses:\n") < 0)
- goto err_done;
-
- read_lock(&bus_list_lock);
- for (bus = bus_list; bus; bus = bus->next) {
- if (PLINE(" bus=0x%p, busNo=%d, deviceCount=%d\n",
- bus, bus->bus_no, bus->device_count) < 0)
- goto err_done_unlock;
-
- if (PLINE(" Devices:\n") < 0)
- goto err_done_unlock;
-
- for (i = 0; i < bus->device_count; i++) {
- if (bus->device[i]) {
- if (PLINE(" busNo %d, device[%i]: 0x%p, chanptr=0x%p, swtch=0x%p\n",
- bus->bus_no, i, bus->device[i],
- bus->device[i]->chanptr,
- bus->device[i]->swtch) < 0)
- goto err_done_unlock;
-
- if (PLINE(" first_busy_cnt=%llu, moved_to_tail_cnt=%llu, last_on_list_cnt=%llu\n",
- bus->device[i]->first_busy_cnt,
- bus->device[i]->moved_to_tail_cnt,
- bus->device[i]->last_on_list_cnt) < 0)
- goto err_done_unlock;
- }
- }
- }
- read_unlock(&bus_list_lock);
-
- if (PLINE("UisUtils_Registered_Services: %d\n",
- atomic_read(&uisutils_registered_services)) < 0)
- goto err_done;
- if (PLINE("cycles_before_wait %llu wait_cycles:%llu\n",
- cycles_before_wait, wait_cycles) < 0)
- goto err_done;
- if (PLINE("tot_wakeup_cnt %llu:tot_wait_cnt %llu:tot_schedule_cnt %llu\n",
- tot_wakeup_cnt, tot_wait_cnt, tot_schedule_cnt) < 0)
- goto err_done;
- if (PLINE("en_smart_wakeup %d\n", en_smart_wakeup) < 0)
- goto err_done;
- if (PLINE("tot_moved_to_tail_cnt %llu\n", tot_moved_to_tail_cnt) < 0)
- goto err_done;
-
- return tot;
-
-err_done_unlock:
- read_unlock(&bus_list_lock);
-err_done:
- return -1;
-}
-
-static ssize_t info_debugfs_read(struct file *file, char __user *buf,
- size_t len, loff_t *offset)
-{
- char *temp;
- int total_bytes = 0;
- int remaining_bytes = PROC_READ_BUFFER_SIZE;
-
-/* *start = buf; */
- if (!debug_buf) {
- debug_buf = vmalloc(PROC_READ_BUFFER_SIZE);
-
- if (!debug_buf)
- return -ENOMEM;
- }
-
- temp = debug_buf;
-
- if ((*offset == 0) || (!debug_buf_valid)) {
- /* if the read fails, then -1 will be returned */
- total_bytes = info_debugfs_read_helper(&temp, &remaining_bytes);
- debug_buf_valid = 1;
- } else {
- total_bytes = strlen(debug_buf);
- }
-
- return simple_read_from_buffer(buf, len, offset,
- debug_buf, total_bytes);
-}
-
-static struct device_info *find_dev(u32 bus_no, u32 dev_no)
-{
- struct bus_info *bus;
- struct device_info *dev = NULL;
-
- read_lock(&bus_list_lock);
- for (bus = bus_list; bus; bus = bus->next) {
- if (bus->bus_no == bus_no) {
- /* make sure the device number is valid */
- if (dev_no >= bus->device_count)
- break;
- dev = bus->device[dev_no];
- break;
- }
- }
- read_unlock(&bus_list_lock);
- return dev;
-}
-
-/* This thread calls the "interrupt" function for each device that has
- * enabled such using uislib_enable_channel_interrupts(). The "interrupt"
- * function typically reads and processes the devices's channel input
- * queue. This thread repeatedly does this, until the thread is told to stop
- * (via uisthread_stop()). Sleeping rules:
- * - If we have called the "interrupt" function for all devices, and all of
- * them have reported "nothing processed" (returned 0), then we will go to
- * sleep for a maximum of POLLJIFFIES_NORMAL jiffies.
- * - If anyone calls uislib_force_channel_interrupt(), the above jiffy
- * sleep will be interrupted, and we will resume calling the "interrupt"
- * function for all devices.
- * - The list of devices is dynamically re-ordered in order to
- * attempt to preserve fairness. Whenever we spin thru the list of
- * devices and call the dev->interrupt() function, if we find
- * devices which report that there is still more work to do, the
- * the first such device we find is moved to the end of the device
- * list. This ensures that extremely busy devices don't starve out
- * less-busy ones.
- *
- */
-static int process_incoming(void *v)
-{
- unsigned long long cur_cycles, old_cycles, idle_cycles, delta_cycles;
- struct list_head *new_tail = NULL;
- int i;
-
- UIS_DAEMONIZE("dev_incoming");
- for (i = 0; i < 16; i++) {
- old_cycles = get_cycles();
- wait_event_timeout(poll_dev_wake_q,
- 0, POLLJIFFIES_NORMAL);
- cur_cycles = get_cycles();
- if (wait_cycles == 0) {
- wait_cycles = (cur_cycles - old_cycles);
- } else {
- if (wait_cycles < (cur_cycles - old_cycles))
- wait_cycles = (cur_cycles - old_cycles);
- }
- }
- cycles_before_wait = wait_cycles;
- idle_cycles = 0;
- poll_dev_start = 0;
- while (1) {
- struct list_head *lelt, *tmp;
- struct device_info *dev = NULL;
-
- /* poll each channel for input */
- down(&poll_dev_lock);
- new_tail = NULL;
- list_for_each_safe(lelt, tmp, &poll_dev_chan) {
- int rc = 0;
-
- dev = list_entry(lelt, struct device_info,
- list_polling_device_channels);
- down(&dev->interrupt_callback_lock);
- if (dev->interrupt)
- rc = dev->interrupt(dev->interrupt_context);
- else
- continue;
- up(&dev->interrupt_callback_lock);
- if (rc) {
- /* dev->interrupt returned, but there
- * is still more work to do.
- * Reschedule work to occur as soon as
- * possible. */
- idle_cycles = 0;
- if (!new_tail) {
- dev->first_busy_cnt++;
- if (!
- (list_is_last
- (lelt,
- &poll_dev_chan))) {
- new_tail = lelt;
- dev->moved_to_tail_cnt++;
- } else {
- dev->last_on_list_cnt++;
- }
- }
- }
- if (kthread_should_stop())
- break;
- }
- if (new_tail) {
- tot_moved_to_tail_cnt++;
- list_move_tail(new_tail, &poll_dev_chan);
- }
- up(&poll_dev_lock);
- cur_cycles = get_cycles();
- delta_cycles = cur_cycles - old_cycles;
- old_cycles = cur_cycles;
-
- /* At this point, we have scanned thru all of the
- * channels, and at least one of the following is true:
- * - there is no input waiting on any of the channels
- * - we have received a signal to stop this thread
- */
- if (kthread_should_stop())
- break;
- if (en_smart_wakeup == 0xFF)
- break;
- /* wait for POLLJIFFIES_NORMAL jiffies, or until
- * someone wakes up poll_dev_wake_q,
- * whichever comes first only do a wait when we have
- * been idle for cycles_before_wait cycles.
- */
- if (idle_cycles > cycles_before_wait) {
- poll_dev_start = 0;
- tot_wait_cnt++;
- wait_event_timeout(poll_dev_wake_q,
- poll_dev_start,
- POLLJIFFIES_NORMAL);
- poll_dev_start = 1;
- } else {
- tot_schedule_cnt++;
- schedule();
- idle_cycles = idle_cycles + delta_cycles;
- }
- }
- complete_and_exit(&incoming_ti.has_stopped, 0);
-}
-
-static BOOL
-initialize_incoming_thread(void)
-{
- if (incoming_started)
- return TRUE;
- if (!uisthread_start(&incoming_ti,
- &process_incoming, NULL, "dev_incoming")) {
- return FALSE;
- }
- incoming_started = TRUE;
- return TRUE;
-}
-
-/* Add a new device/channel to the list being processed by
- * process_incoming().
- * <interrupt> - indicates the function to call periodically.
- * <interrupt_context> - indicates the data to pass to the <interrupt>
- * function.
- */
-void
-uislib_enable_channel_interrupts(u32 bus_no, u32 dev_no,
- int (*interrupt)(void *),
- void *interrupt_context)
-{
- struct device_info *dev;
-
- dev = find_dev(bus_no, dev_no);
- if (!dev)
- return;
-
- down(&poll_dev_lock);
- initialize_incoming_thread();
- dev->interrupt = interrupt;
- dev->interrupt_context = interrupt_context;
- dev->polling = TRUE;
- list_add_tail(&dev->list_polling_device_channels,
- &poll_dev_chan);
- up(&poll_dev_lock);
-}
-EXPORT_SYMBOL_GPL(uislib_enable_channel_interrupts);
-
-/* Remove a device/channel from the list being processed by
- * process_incoming().
- */
-void
-uislib_disable_channel_interrupts(u32 bus_no, u32 dev_no)
-{
- struct device_info *dev;
-
- dev = find_dev(bus_no, dev_no);
- if (!dev)
- return;
- down(&poll_dev_lock);
- list_del(&dev->list_polling_device_channels);
- dev->polling = FALSE;
- dev->interrupt = NULL;
- up(&poll_dev_lock);
-}
-EXPORT_SYMBOL_GPL(uislib_disable_channel_interrupts);
-
-static void
-do_wakeup_polling_device_channels(struct work_struct *dummy)
-{
- if (!poll_dev_start) {
- poll_dev_start = 1;
- wake_up(&poll_dev_wake_q);
- }
-}
-
-static DECLARE_WORK(work_wakeup_polling_device_channels,
- do_wakeup_polling_device_channels);
-
-/* Call this function when you want to send a hint to process_incoming() that
- * your device might have more requests.
- */
-void
-uislib_force_channel_interrupt(u32 bus_no, u32 dev_no)
-{
- if (en_smart_wakeup == 0)
- return;
- if (poll_dev_start)
- return;
- /* The point of using schedule_work() instead of just doing
- * the work inline is to force a slight delay before waking up
- * the process_incoming() thread.
- */
- tot_wakeup_cnt++;
- schedule_work(&work_wakeup_polling_device_channels);
-}
-EXPORT_SYMBOL_GPL(uislib_force_channel_interrupt);
-
-/*****************************************************/
-/* Module Init & Exit functions */
-/*****************************************************/
-
-static int __init
-uislib_mod_init(void)
-{
- if (!unisys_spar_platform)
- return -ENODEV;
-
- /* initialize global pointers to NULL */
- bus_list = NULL;
- bus_list_count = 0;
- max_bus_count = 0;
- rwlock_init(&bus_list_lock);
- virt_control_chan_func = NULL;
-
- /* Issue VMCALL_GET_CONTROLVM_ADDR to get CtrlChanPhysAddr and
- * then map this physical address to a virtual address. */
- POSTCODE_LINUX_2(DRIVER_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-
- dir_debugfs = debugfs_create_dir(DIR_DEBUGFS_ENTRY, NULL);
- if (dir_debugfs) {
- info_debugfs_entry = debugfs_create_file(
- INFO_DEBUGFS_ENTRY_FN, 0444, dir_debugfs, NULL,
- &debugfs_info_fops);
-
- platformnumber_debugfs_read = debugfs_create_u32(
- PLATFORMNUMBER_DEBUGFS_ENTRY_FN, 0444, dir_debugfs,
- &platform_no);
-
- cycles_before_wait_debugfs_read = debugfs_create_u64(
- CYCLES_BEFORE_WAIT_DEBUGFS_ENTRY_FN, 0666, dir_debugfs,
- &cycles_before_wait);
-
- smart_wakeup_debugfs_entry = debugfs_create_bool(
- SMART_WAKEUP_DEBUGFS_ENTRY_FN, 0666, dir_debugfs,
- &en_smart_wakeup);
- }
-
- POSTCODE_LINUX_3(DRIVER_EXIT_PC, 0, POSTCODE_SEVERITY_INFO);
- return 0;
-}
-
-static void __exit
-uislib_mod_exit(void)
-{
- if (debug_buf) {
- vfree(debug_buf);
- debug_buf = NULL;
- }
-
- debugfs_remove(info_debugfs_entry);
- debugfs_remove(smart_wakeup_debugfs_entry);
- debugfs_remove(cycles_before_wait_debugfs_read);
- debugfs_remove(platformnumber_debugfs_read);
- debugfs_remove(dir_debugfs);
-}
-
-module_init(uislib_mod_init);
-module_exit(uislib_mod_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Usha Srinivasan");
-MODULE_ALIAS("uislib");
- /* this is extracted during depmod and kept in modules.dep */
diff --git a/drivers/staging/unisys/uislib/uisqueue.c b/drivers/staging/unisys/uislib/uisqueue.c
deleted file mode 100644
index d46dd7428a30ab..00000000000000
--- a/drivers/staging/unisys/uislib/uisqueue.c
+++ /dev/null
@@ -1,322 +0,0 @@
-/* uisqueue.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/* @ALL_INSPECTED */
-#include <linux/kernel.h>
-#include <linux/module.h>
-
-#include "uisutils.h"
-
-/* this is shorter than using __FILE__ (full path name) in
- * debug/info/error messages */
-#define CURRENT_FILE_PC UISLIB_PC_uisqueue_c
-#define __MYFILE__ "uisqueue.c"
-
-#define CHECK_CACHE_ALIGN 0
-
-/*****************************************************/
-/* Exported functions */
-/*****************************************************/
-
-/*
- * Routine Description:
- * Tries to insert the prebuilt signal pointed to by pSignal into the nth
- * Queue of the Channel pointed to by pChannel
- *
- * Parameters:
- * pChannel: (IN) points to the IO Channel
- * Queue: (IN) nth Queue of the IO Channel
- * pSignal: (IN) pointer to the signal
- *
- * Assumptions:
- * - pChannel, Queue and pSignal are valid.
- * - If insertion fails due to a full queue, the caller will determine the
- * retry policy (e.g. wait & try again, report an error, etc.).
- *
- * Return value:
- * 1 if the insertion succeeds, 0 if the queue was full.
- */
-unsigned char spar_signal_insert(struct channel_header __iomem *ch, u32 queue,
- void *sig)
-{
- void __iomem *psignal;
- unsigned int head, tail, nof;
-
- struct signal_queue_header __iomem *pqhdr =
- (struct signal_queue_header __iomem *)
- ((char __iomem *)ch + readq(&ch->ch_space_offset))
- + queue;
-
- /* capture current head and tail */
- head = readl(&pqhdr->head);
- tail = readl(&pqhdr->tail);
-
- /* queue is full if (head + 1) % n equals tail */
- if (((head + 1) % readl(&pqhdr->max_slots)) == tail) {
- nof = readq(&pqhdr->num_overflows) + 1;
- writeq(nof, &pqhdr->num_overflows);
- return 0;
- }
-
- /* increment the head index */
- head = (head + 1) % readl(&pqhdr->max_slots);
-
- /* copy signal to the head location from the area pointed to
- * by pSignal
- */
- psignal = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) +
- (head * readl(&pqhdr->signal_size));
- memcpy_toio(psignal, sig, readl(&pqhdr->signal_size));
-
- mb(); /* channel synch */
- writel(head, &pqhdr->head);
-
- writeq(readq(&pqhdr->num_sent) + 1, &pqhdr->num_sent);
- return 1;
-}
-EXPORT_SYMBOL_GPL(spar_signal_insert);
-
-/*
- * Routine Description:
- * Removes one signal from Channel pChannel's nth Queue at the
- * time of the call and copies it into the memory pointed to by
- * pSignal.
- *
- * Parameters:
- * pChannel: (IN) points to the IO Channel
- * Queue: (IN) nth Queue of the IO Channel
- * pSignal: (IN) pointer to where the signals are to be copied
- *
- * Assumptions:
- * - pChannel and Queue are valid.
- * - pSignal points to a memory area large enough to hold queue's SignalSize
- *
- * Return value:
- * 1 if the removal succeeds, 0 if the queue was empty.
- */
-unsigned char
-spar_signal_remove(struct channel_header __iomem *ch, u32 queue, void *sig)
-{
- void __iomem *psource;
- unsigned int head, tail;
- struct signal_queue_header __iomem *pqhdr =
- (struct signal_queue_header __iomem *)((char __iomem *)ch +
- readq(&ch->ch_space_offset)) + queue;
-
- /* capture current head and tail */
- head = readl(&pqhdr->head);
- tail = readl(&pqhdr->tail);
-
- /* queue is empty if the head index equals the tail index */
- if (head == tail) {
- writeq(readq(&pqhdr->num_empty) + 1, &pqhdr->num_empty);
- return 0;
- }
-
- /* advance past the 'empty' front slot */
- tail = (tail + 1) % readl(&pqhdr->max_slots);
-
- /* copy signal from tail location to the area pointed to by pSignal */
- psource = (char __iomem *)pqhdr + readq(&pqhdr->sig_base_offset) +
- (tail * readl(&pqhdr->signal_size));
- memcpy_fromio(sig, psource, readl(&pqhdr->signal_size));
-
- mb(); /* channel synch */
- writel(tail, &pqhdr->tail);
-
- writeq(readq(&pqhdr->num_received) + 1,
- &pqhdr->num_received);
- return 1;
-}
-EXPORT_SYMBOL_GPL(spar_signal_remove);
-
-/*
- * Routine Description:
- * Removes all signals present in Channel pChannel's nth Queue at the
- * time of the call and copies them into the memory pointed to by
- * pSignal. Returns the # of signals copied as the value of the routine.
- *
- * Parameters:
- * pChannel: (IN) points to the IO Channel
- * Queue: (IN) nth Queue of the IO Channel
- * pSignal: (IN) pointer to where the signals are to be copied
- *
- * Assumptions:
- * - pChannel and Queue are valid.
- * - pSignal points to a memory area large enough to hold Queue's MaxSignals
- * # of signals, each of which is Queue's SignalSize.
- *
- * Return value:
- * # of signals copied.
- */
-unsigned int spar_signal_remove_all(struct channel_header *ch, u32 queue,
- void *sig)
-{
- void *psource;
- unsigned int head, tail, count = 0;
- struct signal_queue_header *pqhdr =
- (struct signal_queue_header *)((char *)ch +
- ch->ch_space_offset) + queue;
-
- /* capture current head and tail */
- head = pqhdr->head;
- tail = pqhdr->tail;
-
- /* queue is empty if the head index equals the tail index */
- if (head == tail)
- return 0;
-
- while (head != tail) {
- /* advance past the 'empty' front slot */
- tail = (tail + 1) % pqhdr->max_slots;
-
- /* copy signal from tail location to the area pointed
- * to by pSignal
- */
- psource =
- (char *)pqhdr + pqhdr->sig_base_offset +
- (tail * pqhdr->signal_size);
- memcpy((char *)sig + (pqhdr->signal_size * count),
- psource, pqhdr->signal_size);
-
- mb(); /* channel synch */
- pqhdr->tail = tail;
-
- count++;
- pqhdr->num_received++;
- }
-
- return count;
-}
-
-/*
- * Routine Description:
- * Determine whether a signal queue is empty.
- *
- * Parameters:
- * pChannel: (IN) points to the IO Channel
- * Queue: (IN) nth Queue of the IO Channel
- *
- * Return value:
- * 1 if the signal queue is empty, 0 otherwise.
- */
-unsigned char spar_signalqueue_empty(struct channel_header __iomem *ch,
- u32 queue)
-{
- struct signal_queue_header __iomem *pqhdr =
- (struct signal_queue_header __iomem *)((char __iomem *)ch +
- readq(&ch->ch_space_offset)) + queue;
- return readl(&pqhdr->head) == readl(&pqhdr->tail);
-}
-EXPORT_SYMBOL_GPL(spar_signalqueue_empty);
-
-unsigned long long
-uisqueue_interlocked_or(unsigned long long __iomem *tgt,
- unsigned long long set)
-{
- unsigned long long i;
- unsigned long long j;
-
- j = readq(tgt);
- do {
- i = j;
- j = cmpxchg((__force unsigned long long *)tgt, i, i | set);
-
- } while (i != j);
-
- return j;
-}
-EXPORT_SYMBOL_GPL(uisqueue_interlocked_or);
-
-unsigned long long
-uisqueue_interlocked_and(unsigned long long __iomem *tgt,
- unsigned long long set)
-{
- unsigned long long i;
- unsigned long long j;
-
- j = readq(tgt);
- do {
- i = j;
- j = cmpxchg((__force unsigned long long *)tgt, i, i & set);
-
- } while (i != j);
-
- return j;
-}
-EXPORT_SYMBOL_GPL(uisqueue_interlocked_and);
-
-static u8
-do_locked_client_insert(struct uisqueue_info *queueinfo,
- unsigned int whichqueue,
- void *signal,
- spinlock_t *lock,
- u8 *channel_id)
-{
- unsigned long flags;
- u8 rc = 0;
-
- spin_lock_irqsave(lock, flags);
- if (!spar_channel_client_acquire_os(queueinfo->chan, channel_id))
- goto unlock;
- if (spar_signal_insert(queueinfo->chan, whichqueue, signal)) {
- queueinfo->packets_sent++;
- rc = 1;
- }
- spar_channel_client_release_os(queueinfo->chan, channel_id);
-unlock:
- spin_unlock_irqrestore((spinlock_t *)lock, flags);
- return rc;
-}
-
-int
-uisqueue_put_cmdrsp_with_lock_client(struct uisqueue_info *queueinfo,
- struct uiscmdrsp *cmdrsp,
- unsigned int whichqueue,
- void *insertlock,
- unsigned char issue_irq_if_empty,
- u64 irq_handle,
- char oktowait, u8 *channel_id)
-{
- while (!do_locked_client_insert(queueinfo, whichqueue, cmdrsp,
- (spinlock_t *)insertlock,
- channel_id)) {
- if (oktowait != OK_TO_WAIT)
- return 0; /* failed to queue */
-
- /* try again */
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(msecs_to_jiffies(10));
- }
- return 1;
-}
-EXPORT_SYMBOL_GPL(uisqueue_put_cmdrsp_with_lock_client);
-
-/* uisqueue_get_cmdrsp gets the cmdrsp entry at the head of the queue
- * returns NULL if queue is empty */
-int
-uisqueue_get_cmdrsp(struct uisqueue_info *queueinfo,
- void *cmdrsp, unsigned int whichqueue)
-{
- if (!spar_signal_remove(queueinfo->chan, whichqueue, cmdrsp))
- return 0;
-
- queueinfo->packets_received++;
-
- return 1; /* Success */
-}
-EXPORT_SYMBOL_GPL(uisqueue_get_cmdrsp);
diff --git a/drivers/staging/unisys/uislib/uisthread.c b/drivers/staging/unisys/uislib/uisthread.c
deleted file mode 100644
index d3c973b617ee7f..00000000000000
--- a/drivers/staging/unisys/uislib/uisthread.c
+++ /dev/null
@@ -1,69 +0,0 @@
-/* uisthread.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/* @ALL_INSPECTED */
-#include <asm/processor.h>
-#include <linux/signal.h>
-#include <linux/sched.h>
-#include <linux/kthread.h>
-#include "uisutils.h"
-#include "uisthread.h"
-
-/* this is shorter than using __FILE__ (full path name) in
- * debug/info/error messages
- */
-#define CURRENT_FILE_PC UISLIB_PC_uisthread_c
-#define __MYFILE__ "uisthread.c"
-
-/*****************************************************/
-/* Exported functions */
-/*****************************************************/
-
-/* returns 0 for failure, 1 for success */
-int
-uisthread_start(struct uisthread_info *thrinfo,
- int (*threadfn)(void *), void *thrcontext, char *name)
-{
- /* used to stop the thread */
- init_completion(&thrinfo->has_stopped);
- thrinfo->task = kthread_run(threadfn, thrcontext, name);
- if (IS_ERR(thrinfo->task)) {
- thrinfo->id = 0;
- return 0; /* failure */
- }
- thrinfo->id = thrinfo->task->pid;
- return 1;
-}
-EXPORT_SYMBOL_GPL(uisthread_start);
-
-void
-uisthread_stop(struct uisthread_info *thrinfo)
-{
- int stopped = 0;
-
- if (thrinfo->id == 0)
- return; /* thread not running */
-
- kthread_stop(thrinfo->task);
- /* give up if the thread has NOT died in 1 minute */
- if (wait_for_completion_timeout(&thrinfo->has_stopped, 60 * HZ))
- stopped = 1;
-
- if (stopped)
- thrinfo->id = 0;
-}
-EXPORT_SYMBOL_GPL(uisthread_stop);
diff --git a/drivers/staging/unisys/uislib/uisutils.c b/drivers/staging/unisys/uislib/uisutils.c
deleted file mode 100644
index 26ab7652681371..00000000000000
--- a/drivers/staging/unisys/uislib/uisutils.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/* uisutils.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#include <linux/string.h>
-#include <linux/slab.h>
-#include <linux/types.h>
-#include <linux/uuid.h>
-#include <linux/spinlock.h>
-#include <linux/list.h>
-#include "uisutils.h"
-#include "version.h"
-#include "vbushelper.h"
-#include <linux/skbuff.h>
-#ifdef CONFIG_HIGHMEM
-#include <linux/highmem.h>
-#endif
-
-/* this is shorter than using __FILE__ (full path name) in
- * debug/info/error messages
- */
-#define CURRENT_FILE_PC UISLIB_PC_uisutils_c
-#define __MYFILE__ "uisutils.c"
-
-/* exports */
-atomic_t uisutils_registered_services = ATOMIC_INIT(0);
- /* num registrations via
- * uisctrl_register_req_handler() or
- * uisctrl_register_req_handler_ex() */
-
-/*****************************************************/
-/* Utility functions */
-/*****************************************************/
-
-int
-uisutil_add_proc_line_ex(int *total, char **buffer, int *buffer_remaining,
- char *format, ...)
-{
- va_list args;
- int len;
-
- va_start(args, format);
- len = vsnprintf(*buffer, *buffer_remaining, format, args);
- va_end(args);
- if (len >= *buffer_remaining) {
- *buffer += *buffer_remaining;
- *total += *buffer_remaining;
- *buffer_remaining = 0;
- return -1;
- }
- *buffer_remaining -= len;
- *buffer += len;
- *total += len;
- return len;
-}
-EXPORT_SYMBOL_GPL(uisutil_add_proc_line_ex);
-
-int
-uisctrl_register_req_handler(int type, void *fptr,
- struct ultra_vbus_deviceinfo *chipset_driver_info)
-{
- switch (type) {
- case 2:
- if (fptr) {
- if (!virt_control_chan_func)
- atomic_inc(&uisutils_registered_services);
- virt_control_chan_func = fptr;
- } else {
- if (virt_control_chan_func)
- atomic_dec(&uisutils_registered_services);
- virt_control_chan_func = NULL;
- }
- break;
-
- default:
- return 0;
- }
- if (chipset_driver_info)
- bus_device_info_init(chipset_driver_info, "chipset", "uislib",
- VERSION, NULL);
-
- return 1;
-}
-EXPORT_SYMBOL_GPL(uisctrl_register_req_handler);
-
-/*
- * unsigned int uisutil_copy_fragsinfo_from_skb(unsigned char *calling_ctx,
- * void *skb_in,
- * unsigned int firstfraglen,
- * unsigned int frags_max,
- * struct phys_info frags[])
- *
- * calling_ctx - input - a string that is displayed to show
- * who called * this func
- * void *skb_in - skb whose frag info we're copying type is hidden so we
- * don't need to include skbbuff in uisutils.h which is
- * included in non-networking code.
- * unsigned int firstfraglen - input - length of first fragment in skb
- * unsigned int frags_max - input - max len of frags array
- * struct phys_info frags[] - output - frags array filled in on output
- * return value indicates number of
- * entries filled in frags
- */
-
-static LIST_HEAD(req_handler_info_list); /* list of struct req_handler_info */
-static DEFINE_SPINLOCK(req_handler_info_list_lock);
-
-struct req_handler_info *
-req_handler_find(uuid_le switch_uuid)
-{
- struct list_head *lelt, *tmp;
- struct req_handler_info *entry = NULL;
-
- spin_lock(&req_handler_info_list_lock);
- list_for_each_safe(lelt, tmp, &req_handler_info_list) {
- entry = list_entry(lelt, struct req_handler_info, list_link);
- if (uuid_le_cmp(entry->switch_uuid, switch_uuid) == 0) {
- spin_unlock(&req_handler_info_list_lock);
- return entry;
- }
- }
- spin_unlock(&req_handler_info_list_lock);
- return NULL;
-}
diff --git a/drivers/staging/unisys/virthba/Kconfig b/drivers/staging/unisys/virthba/Kconfig
deleted file mode 100644
index dfadfc49114aba..00000000000000
--- a/drivers/staging/unisys/virthba/Kconfig
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# Unisys virthba configuration
-#
-
-config UNISYS_VIRTHBA
- tristate "Unisys virthba driver"
- depends on SCSI
- select UNISYS_VISORCHIPSET
- select UNISYS_UISLIB
- select UNISYS_VIRTPCI
- ---help---
- If you say Y here, you will enable the Unisys virthba driver.
-
diff --git a/drivers/staging/unisys/virthba/Makefile b/drivers/staging/unisys/virthba/Makefile
deleted file mode 100644
index a4e40373918327..00000000000000
--- a/drivers/staging/unisys/virthba/Makefile
+++ /dev/null
@@ -1,12 +0,0 @@
-#
-# Makefile for Unisys virthba
-#
-
-obj-$(CONFIG_UNISYS_VIRTHBA) += virthba.o
-
-ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/uislib
-ccflags-y += -Idrivers/staging/unisys/visorchipset
-ccflags-y += -Idrivers/staging/unisys/virtpci
-ccflags-y += -Idrivers/staging/unisys/common-spar/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
diff --git a/drivers/staging/unisys/virthba/virthba.c b/drivers/staging/unisys/virthba/virthba.c
deleted file mode 100644
index d9001cca0f7357..00000000000000
--- a/drivers/staging/unisys/virthba/virthba.c
+++ /dev/null
@@ -1,1572 +0,0 @@
-/* virthba.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#define EXPORT_SYMTAB
-
-/* if you want to turn on some debugging of write device data or read
- * device data, define these two undefs. You will probably want to
- * customize the code which is here since it was written assuming
- * reading and writing a specific data file df.64M.txt which is a
- * 64Megabyte file created by Art Nilson using a scritp I wrote called
- * cr_test_data.pl. The data file consists of 256 byte lines of text
- * which start with an 8 digit sequence number, a colon, and then
- * letters after that */
-
-#include <linux/kernel.h>
-#ifdef CONFIG_MODVERSIONS
-#include <config/modversions.h>
-#endif
-
-#include "diagnostics/appos_subsystems.h"
-#include "uisutils.h"
-#include "uisqueue.h"
-#include "uisthread.h"
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/spinlock.h>
-#include <linux/device.h>
-#include <linux/slab.h>
-#include <scsi/scsi.h>
-#include <scsi/scsi_host.h>
-#include <scsi/scsi_cmnd.h>
-#include <scsi/scsi_device.h>
-#include <asm/param.h>
-#include <linux/debugfs.h>
-#include <linux/types.h>
-
-#include "virthba.h"
-#include "virtpci.h"
-#include "visorchipset.h"
-#include "version.h"
-#include "guestlinuxdebug.h"
-/* this is shorter than using __FILE__ (full path name) in
- * debug/info/error messages
- */
-#define CURRENT_FILE_PC VIRT_HBA_PC_virthba_c
-#define __MYFILE__ "virthba.c"
-
-/* NOTE: L1_CACHE_BYTES >=128 */
-#define DEVICE_ATTRIBUTE struct device_attribute
-
- /* MAX_BUF = 6 lines x 10 MAXVHBA x 80 characters
- * = 4800 bytes ~ 2^13 = 8192 bytes
- */
-#define MAX_BUF 8192
-
-/*****************************************************/
-/* Forward declarations */
-/*****************************************************/
-static int virthba_probe(struct virtpci_dev *dev,
- const struct pci_device_id *id);
-static void virthba_remove(struct virtpci_dev *dev);
-static int virthba_abort_handler(struct scsi_cmnd *scsicmd);
-static int virthba_bus_reset_handler(struct scsi_cmnd *scsicmd);
-static int virthba_device_reset_handler(struct scsi_cmnd *scsicmd);
-static int virthba_host_reset_handler(struct scsi_cmnd *scsicmd);
-static const char *virthba_get_info(struct Scsi_Host *shp);
-static int virthba_ioctl(struct scsi_device *dev, int cmd, void __user *arg);
-static int virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
- void (*virthba_cmnd_done)
- (struct scsi_cmnd *));
-
-static const struct x86_cpu_id unisys_spar_ids[] = {
- { X86_VENDOR_INTEL, 6, 62, X86_FEATURE_ANY },
- {}
-};
-
-/* Autoload */
-MODULE_DEVICE_TABLE(x86cpu, unisys_spar_ids);
-
-#ifdef DEF_SCSI_QCMD
-static DEF_SCSI_QCMD(virthba_queue_command)
-#else
-#define virthba_queue_command virthba_queue_command_lck
-#endif
-
-static int virthba_slave_alloc(struct scsi_device *scsidev);
-static int virthba_slave_configure(struct scsi_device *scsidev);
-static void virthba_slave_destroy(struct scsi_device *scsidev);
-static int process_incoming_rsps(void *);
-static int virthba_serverup(struct virtpci_dev *virtpcidev);
-static int virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state);
-static void do_disk_add_remove(struct work_struct *work);
-static void virthba_serverdown_complete(struct work_struct *work);
-static ssize_t info_debugfs_read(struct file *file, char __user *buf,
- size_t len, loff_t *offset);
-static ssize_t enable_ints_write(struct file *file,
- const char __user *buffer, size_t count,
- loff_t *ppos);
-
-/*****************************************************/
-/* Globals */
-/*****************************************************/
-
-static int rsltq_wait_usecs = 4000; /* Default 4ms */
-static unsigned int max_buff_len;
-
-/* Module options */
-static char *virthba_options = "NONE";
-
-static const struct pci_device_id virthba_id_table[] = {
- {PCI_DEVICE(PCI_VENDOR_ID_UNISYS, PCI_DEVICE_ID_VIRTHBA)},
- {0},
-};
-
-/* export virthba_id_table */
-MODULE_DEVICE_TABLE(pci, virthba_id_table);
-
-static struct workqueue_struct *virthba_serverdown_workqueue;
-
-static struct virtpci_driver virthba_driver = {
- .name = "uisvirthba",
- .version = VERSION,
- .vertag = NULL,
- .id_table = virthba_id_table,
- .probe = virthba_probe,
- .remove = virthba_remove,
- .resume = virthba_serverup,
- .suspend = virthba_serverdown
-};
-
-/* The Send and Recive Buffers of the IO Queue may both be full */
-#define MAX_PENDING_REQUESTS (MIN_NUMSIGNALS*2)
-#define INTERRUPT_VECTOR_MASK 0x3F
-
-struct scsipending {
- char cmdtype; /* Type of pointer that is being stored */
- void *sent; /* The Data being tracked */
- /* struct scsi_cmnd *type for virthba_queue_command */
- /* struct uiscmdrsp *type for management commands */
-};
-
-#define VIRTHBA_ERROR_COUNT 30
-#define IOS_ERROR_THRESHOLD 1000
-struct virtdisk_info {
- u32 valid;
- u32 channel, id, lun; /* Disk Path */
- atomic_t ios_threshold;
- atomic_t error_count;
- struct virtdisk_info *next;
-};
-
-/* Each Scsi_Host has a host_data area that contains this struct. */
-struct virthba_info {
- struct Scsi_Host *scsihost;
- struct virtpci_dev *virtpcidev;
- struct list_head dev_info_list;
- struct chaninfo chinfo;
- struct irq_info intr; /* use recvInterrupt info to receive
- interrupts when IOs complete */
- int interrupt_vector;
- struct scsipending pending[MAX_PENDING_REQUESTS]; /* Tracks the requests
- that have been */
- /* forwarded to the IOVM and haven't returned yet */
- unsigned int nextinsert; /* Start search for next pending
- free slot here */
- spinlock_t privlock;
- bool serverdown;
- bool serverchangingstate;
- unsigned long long acquire_failed_cnt;
- unsigned long long interrupts_rcvd;
- unsigned long long interrupts_notme;
- unsigned long long interrupts_disabled;
- struct work_struct serverdown_completion;
- u64 __iomem *flags_addr;
- atomic_t interrupt_rcvd;
- wait_queue_head_t rsp_queue;
- struct virtdisk_info head;
-};
-
-/* Work Data for dar_work_queue */
-struct diskaddremove {
- u8 add; /* 0-remove, 1-add */
- struct Scsi_Host *shost; /* Scsi Host for this virthba instance */
- u32 channel, id, lun; /* Disk Path */
- struct diskaddremove *next;
-};
-
-#define virtpci_dev_to_virthba_virthba_get_info(d) \
- container_of(d, struct virthba_info, virtpcidev)
-
-static DEVICE_ATTRIBUTE *virthba_shost_attrs[];
-static struct scsi_host_template virthba_driver_template = {
- .name = "Unisys Virtual HBA",
- .info = virthba_get_info,
- .ioctl = virthba_ioctl,
- .queuecommand = virthba_queue_command,
- .eh_abort_handler = virthba_abort_handler,
- .eh_device_reset_handler = virthba_device_reset_handler,
- .eh_bus_reset_handler = virthba_bus_reset_handler,
- .eh_host_reset_handler = virthba_host_reset_handler,
- .shost_attrs = virthba_shost_attrs,
-
-#define VIRTHBA_MAX_CMNDS 128
- .can_queue = VIRTHBA_MAX_CMNDS,
- .sg_tablesize = 64, /* largest number of address/length pairs */
- .this_id = -1,
- .slave_alloc = virthba_slave_alloc,
- .slave_configure = virthba_slave_configure,
- .slave_destroy = virthba_slave_destroy,
- .use_clustering = ENABLE_CLUSTERING,
-};
-
-struct virthba_devices_open {
- struct virthba_info *virthbainfo;
-};
-
-static const struct file_operations debugfs_info_fops = {
- .read = info_debugfs_read,
-};
-
-static const struct file_operations debugfs_enable_ints_fops = {
- .write = enable_ints_write,
-};
-
-/*****************************************************/
-/* Structs */
-/*****************************************************/
-
-#define VIRTHBASOPENMAX 1
-/* array of open devices maintained by open() and close(); */
-static struct virthba_devices_open virthbas_open[VIRTHBASOPENMAX];
-static struct dentry *virthba_debugfs_dir;
-
-/*****************************************************/
-/* Local Functions */
-/*****************************************************/
-static int
-add_scsipending_entry(struct virthba_info *vhbainfo, char cmdtype, void *new)
-{
- unsigned long flags;
- int insert_location;
-
- spin_lock_irqsave(&vhbainfo->privlock, flags);
- insert_location = vhbainfo->nextinsert;
- while (vhbainfo->pending[insert_location].sent) {
- insert_location = (insert_location + 1) % MAX_PENDING_REQUESTS;
- if (insert_location == (int)vhbainfo->nextinsert) {
- spin_unlock_irqrestore(&vhbainfo->privlock, flags);
- return -1;
- }
- }
-
- vhbainfo->pending[insert_location].cmdtype = cmdtype;
- vhbainfo->pending[insert_location].sent = new;
- vhbainfo->nextinsert = (insert_location + 1) % MAX_PENDING_REQUESTS;
- spin_unlock_irqrestore(&vhbainfo->privlock, flags);
-
- return insert_location;
-}
-
-static unsigned int
-add_scsipending_entry_with_wait(struct virthba_info *vhbainfo, char cmdtype,
- void *new)
-{
- int insert_location = add_scsipending_entry(vhbainfo, cmdtype, new);
-
- while (insert_location == -1) {
- set_current_state(TASK_INTERRUPTIBLE);
- schedule_timeout(msecs_to_jiffies(10));
- insert_location = add_scsipending_entry(vhbainfo, cmdtype, new);
- }
-
- return (unsigned int)insert_location;
-}
-
-static void *
-del_scsipending_entry(struct virthba_info *vhbainfo, uintptr_t del)
-{
- unsigned long flags;
- void *sent = NULL;
-
- if (del < MAX_PENDING_REQUESTS) {
- spin_lock_irqsave(&vhbainfo->privlock, flags);
- sent = vhbainfo->pending[del].sent;
-
- vhbainfo->pending[del].cmdtype = 0;
- vhbainfo->pending[del].sent = NULL;
- spin_unlock_irqrestore(&vhbainfo->privlock, flags);
- }
-
- return sent;
-}
-
-/* dar_work_queue (Disk Add/Remove) */
-static struct work_struct dar_work_queue;
-static struct diskaddremove *dar_work_queue_head;
-static spinlock_t dar_work_queue_lock;
-static unsigned short dar_work_queue_sched;
-#define QUEUE_DISKADDREMOVE(dar) { \
- spin_lock_irqsave(&dar_work_queue_lock, flags); \
- if (!dar_work_queue_head) { \
- dar_work_queue_head = dar; \
- dar->next = NULL; \
- } \
- else { \
- dar->next = dar_work_queue_head; \
- dar_work_queue_head = dar; \
- } \
- if (!dar_work_queue_sched) { \
- schedule_work(&dar_work_queue); \
- dar_work_queue_sched = 1; \
- } \
- spin_unlock_irqrestore(&dar_work_queue_lock, flags); \
-}
-
-static inline void
-send_disk_add_remove(struct diskaddremove *dar)
-{
- struct scsi_device *sdev;
- int error;
-
- sdev = scsi_device_lookup(dar->shost, dar->channel, dar->id, dar->lun);
- if (sdev) {
- if (!(dar->add))
- scsi_remove_device(sdev);
- } else if (dar->add) {
- error =
- scsi_add_device(dar->shost, dar->channel, dar->id,
- dar->lun);
- }
- kfree(dar);
-}
-
-/*****************************************************/
-/* dar_work_queue Handler Thread */
-/*****************************************************/
-static void
-do_disk_add_remove(struct work_struct *work)
-{
- struct diskaddremove *dar;
- struct diskaddremove *tmphead;
- int i = 0;
- unsigned long flags;
-
- spin_lock_irqsave(&dar_work_queue_lock, flags);
- tmphead = dar_work_queue_head;
- dar_work_queue_head = NULL;
- dar_work_queue_sched = 0;
- spin_unlock_irqrestore(&dar_work_queue_lock, flags);
- while (tmphead) {
- dar = tmphead;
- tmphead = dar->next;
- send_disk_add_remove(dar);
- i++;
- }
-}
-
-/*****************************************************/
-/* Routine to add entry to dar_work_queue */
-/*****************************************************/
-static void
-process_disk_notify(struct Scsi_Host *shost, struct uiscmdrsp *cmdrsp)
-{
- struct diskaddremove *dar;
- unsigned long flags;
-
- dar = kzalloc(sizeof(*dar), GFP_ATOMIC);
- if (dar) {
- dar->add = cmdrsp->disknotify.add;
- dar->shost = shost;
- dar->channel = cmdrsp->disknotify.channel;
- dar->id = cmdrsp->disknotify.id;
- dar->lun = cmdrsp->disknotify.lun;
- QUEUE_DISKADDREMOVE(dar);
- }
-}
-
-/*****************************************************/
-/* Probe Remove Functions */
-/*****************************************************/
-static irqreturn_t
-virthba_isr(int irq, void *dev_id)
-{
- struct virthba_info *virthbainfo = (struct virthba_info *)dev_id;
- struct channel_header __iomem *channel_header;
- struct signal_queue_header __iomem *pqhdr;
- u64 mask;
- unsigned long long rc1;
-
- if (!virthbainfo)
- return IRQ_NONE;
- virthbainfo->interrupts_rcvd++;
- channel_header = virthbainfo->chinfo.queueinfo->chan;
- if (((readq(&channel_header->features)
- & ULTRA_IO_IOVM_IS_OK_WITH_DRIVER_DISABLING_INTS) != 0) &&
- ((readq(&channel_header->features) &
- ULTRA_IO_DRIVER_DISABLES_INTS) !=
- 0)) {
- virthbainfo->interrupts_disabled++;
- mask = ~ULTRA_CHANNEL_ENABLE_INTS;
- rc1 = uisqueue_interlocked_and(virthbainfo->flags_addr, mask);
- }
- if (spar_signalqueue_empty(channel_header, IOCHAN_FROM_IOPART)) {
- virthbainfo->interrupts_notme++;
- return IRQ_NONE;
- }
- pqhdr = (struct signal_queue_header __iomem *)
- ((char __iomem *)channel_header +
- readq(&channel_header->ch_space_offset)) + IOCHAN_FROM_IOPART;
- writeq(readq(&pqhdr->num_irq_received) + 1,
- &pqhdr->num_irq_received);
- atomic_set(&virthbainfo->interrupt_rcvd, 1);
- wake_up_interruptible(&virthbainfo->rsp_queue);
- return IRQ_HANDLED;
-}
-
-static int
-virthba_probe(struct virtpci_dev *virtpcidev, const struct pci_device_id *id)
-{
- int error;
- struct Scsi_Host *scsihost;
- struct virthba_info *virthbainfo;
- int rsp;
- int i;
- irq_handler_t handler = virthba_isr;
- struct channel_header __iomem *channel_header;
- struct signal_queue_header __iomem *pqhdr;
- u64 mask;
-
- POSTCODE_LINUX_2(VHBA_PROBE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
- /* call scsi_host_alloc to register a scsi host adapter
- * instance - this virthba that has just been created is an
- * instance of a scsi host adapter. This scsi_host_alloc
- * function allocates a new Scsi_Host struct & performs basic
- * initialization. The host is not published to the scsi
- * midlayer until scsi_add_host is called.
- */
-
- /* arg 2 passed in length of extra space we want allocated
- * with scsi_host struct for our own use scsi_host_alloc
- * assign host_no
- */
- scsihost = scsi_host_alloc(&virthba_driver_template,
- sizeof(struct virthba_info));
- if (!scsihost)
- return -ENODEV;
-
- scsihost->this_id = UIS_MAGIC_VHBA;
- /* linux treats max-channel differently than max-id & max-lun.
- * In the latter cases, those two values result in 0 to max-1
- * (inclusive) being scanned. But in the case of channels, the
- * scan is 0 to max (inclusive); so we will subtract one from
- * the max-channel value.
- */
- scsihost->max_channel = (unsigned)virtpcidev->scsi.max.max_channel;
- scsihost->max_id = (unsigned)virtpcidev->scsi.max.max_id;
- scsihost->max_lun = (unsigned)virtpcidev->scsi.max.max_lun;
- scsihost->cmd_per_lun = (unsigned)virtpcidev->scsi.max.cmd_per_lun;
- scsihost->max_sectors =
- (unsigned short)(virtpcidev->scsi.max.max_io_size >> 9);
- scsihost->sg_tablesize =
- (unsigned short)(virtpcidev->scsi.max.max_io_size / PAGE_SIZE);
- if (scsihost->sg_tablesize > MAX_PHYS_INFO)
- scsihost->sg_tablesize = MAX_PHYS_INFO;
-
- /* this creates "host%d" in sysfs. If 2nd argument is NULL,
- * then this generic /sys/devices/platform/host? device is
- * created and /sys/scsi_host/host? ->
- * /sys/devices/platform/host? If 2nd argument is not NULL,
- * then this generic /sys/devices/<path>/host? is created and
- * host? points to that device instead.
- */
- error = scsi_add_host(scsihost, &virtpcidev->generic_dev);
- if (error) {
- POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- /* decr refcount on scsihost which was incremented by
- * scsi_add_host so the scsi_host gets deleted
- */
- scsi_host_put(scsihost);
- return -ENODEV;
- }
-
- virthbainfo = (struct virthba_info *)scsihost->hostdata;
- memset(virthbainfo, 0, sizeof(struct virthba_info));
- for (i = 0; i < VIRTHBASOPENMAX; i++) {
- if (!virthbas_open[i].virthbainfo) {
- virthbas_open[i].virthbainfo = virthbainfo;
- break;
- }
- }
- virthbainfo->interrupt_vector = -1;
- virthbainfo->chinfo.queueinfo = &virtpcidev->queueinfo;
- virthbainfo->virtpcidev = virtpcidev;
- spin_lock_init(&virthbainfo->chinfo.insertlock);
-
- init_waitqueue_head(&virthbainfo->rsp_queue);
- spin_lock_init(&virthbainfo->privlock);
- memset(&virthbainfo->pending, 0, sizeof(virthbainfo->pending));
- virthbainfo->serverdown = false;
- virthbainfo->serverchangingstate = false;
-
- virthbainfo->intr = virtpcidev->intr;
- /* save of host within virthba_info */
- virthbainfo->scsihost = scsihost;
-
- /* save of host within virtpci_dev */
- virtpcidev->scsi.scsihost = scsihost;
-
- /* Setup workqueue for serverdown messages */
- INIT_WORK(&virthbainfo->serverdown_completion,
- virthba_serverdown_complete);
-
- writeq(readq(&virthbainfo->chinfo.queueinfo->chan->features) |
- ULTRA_IO_CHANNEL_IS_POLLING,
- &virthbainfo->chinfo.queueinfo->chan->features);
- /* start thread that will receive scsicmnd responses */
-
- channel_header = virthbainfo->chinfo.queueinfo->chan;
- pqhdr = (struct signal_queue_header __iomem *)
- ((char __iomem *)channel_header +
- readq(&channel_header->ch_space_offset)) + IOCHAN_FROM_IOPART;
- virthbainfo->flags_addr = &pqhdr->features;
-
- if (!uisthread_start(&virthbainfo->chinfo.threadinfo,
- process_incoming_rsps,
- virthbainfo, "vhba_incoming")) {
- /* decr refcount on scsihost which was incremented by
- * scsi_add_host so the scsi_host gets deleted
- */
- POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- scsi_host_put(scsihost);
- return -ENODEV;
- }
- virthbainfo->interrupt_vector =
- virthbainfo->intr.recv_irq_handle & INTERRUPT_VECTOR_MASK;
- rsp = request_irq(virthbainfo->interrupt_vector, handler, IRQF_SHARED,
- scsihost->hostt->name, virthbainfo);
- if (rsp != 0) {
- virthbainfo->interrupt_vector = -1;
- POSTCODE_LINUX_2(VHBA_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- } else {
- u64 __iomem *features_addr =
- &virthbainfo->chinfo.queueinfo->chan->features;
- mask = ~(ULTRA_IO_CHANNEL_IS_POLLING |
- ULTRA_IO_DRIVER_DISABLES_INTS);
- uisqueue_interlocked_and(features_addr, mask);
- mask = ULTRA_IO_DRIVER_ENABLES_INTS;
- uisqueue_interlocked_or(features_addr, mask);
- rsltq_wait_usecs = 4000000;
- }
-
- scsi_scan_host(scsihost);
-
- POSTCODE_LINUX_2(VHBA_PROBE_EXIT_PC, POSTCODE_SEVERITY_INFO);
- return 0;
-}
-
-static void
-virthba_remove(struct virtpci_dev *virtpcidev)
-{
- struct virthba_info *virthbainfo;
- struct Scsi_Host *scsihost =
- (struct Scsi_Host *)virtpcidev->scsi.scsihost;
-
- virthbainfo = (struct virthba_info *)scsihost->hostdata;
- if (virthbainfo->interrupt_vector != -1)
- free_irq(virthbainfo->interrupt_vector, virthbainfo);
-
- scsi_remove_host(scsihost);
-
- uisthread_stop(&virthbainfo->chinfo.threadinfo);
-
- /* decr refcount on scsihost which was incremented by
- * scsi_add_host so the scsi_host gets deleted
- */
- scsi_host_put(scsihost);
-}
-
-static int
-forward_vdiskmgmt_command(enum vdisk_mgmt_types vdiskcmdtype,
- struct Scsi_Host *scsihost,
- struct uisscsi_dest *vdest)
-{
- struct uiscmdrsp *cmdrsp;
- struct virthba_info *virthbainfo =
- (struct virthba_info *)scsihost->hostdata;
- int notifyresult = 0xffff;
- wait_queue_head_t notifyevent;
-
- if (virthbainfo->serverdown || virthbainfo->serverchangingstate)
- return FAILED;
-
- cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
- if (!cmdrsp)
- return FAILED; /* reject */
-
- init_waitqueue_head(&notifyevent);
-
- /* issue VDISK_MGMT_CMD
- * set type to command - as opposed to task mgmt
- */
- cmdrsp->cmdtype = CMD_VDISKMGMT_TYPE;
- /* specify the event that has to be triggered when this cmd is
- * complete
- */
- cmdrsp->vdiskmgmt.notify = (void *)&notifyevent;
- cmdrsp->vdiskmgmt.notifyresult = (void *)&notifyresult;
-
- /* save destination */
- cmdrsp->vdiskmgmt.vdisktype = vdiskcmdtype;
- cmdrsp->vdiskmgmt.vdest.channel = vdest->channel;
- cmdrsp->vdiskmgmt.vdest.id = vdest->id;
- cmdrsp->vdiskmgmt.vdest.lun = vdest->lun;
- cmdrsp->vdiskmgmt.scsicmd =
- (void *)(uintptr_t)
- add_scsipending_entry_with_wait(virthbainfo, CMD_VDISKMGMT_TYPE,
- (void *)cmdrsp);
-
- uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo,
- cmdrsp, IOCHAN_TO_IOPART,
- &virthbainfo->chinfo.insertlock,
- DONT_ISSUE_INTERRUPT, (u64)NULL,
- OK_TO_WAIT, "vhba");
- wait_event(notifyevent, notifyresult != 0xffff);
- kfree(cmdrsp);
- return SUCCESS;
-}
-
-/*****************************************************/
-/* Scsi Host support functions */
-/*****************************************************/
-
-static int
-forward_taskmgmt_command(enum task_mgmt_types tasktype,
- struct scsi_device *scsidev)
-{
- struct uiscmdrsp *cmdrsp;
- struct virthba_info *virthbainfo =
- (struct virthba_info *)scsidev->host->hostdata;
- int notifyresult = 0xffff;
- wait_queue_head_t notifyevent;
-
- if (virthbainfo->serverdown || virthbainfo->serverchangingstate)
- return FAILED;
-
- cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
- if (!cmdrsp)
- return FAILED; /* reject */
-
- init_waitqueue_head(&notifyevent);
-
- /* issue TASK_MGMT_ABORT_TASK */
- /* set type to command - as opposed to task mgmt */
- cmdrsp->cmdtype = CMD_SCSITASKMGMT_TYPE;
- /* specify the event that has to be triggered when this */
- /* cmd is complete */
- cmdrsp->scsitaskmgmt.notify = (void *)&notifyevent;
- cmdrsp->scsitaskmgmt.notifyresult = (void *)&notifyresult;
-
- /* save destination */
- cmdrsp->scsitaskmgmt.tasktype = tasktype;
- cmdrsp->scsitaskmgmt.vdest.channel = scsidev->channel;
- cmdrsp->scsitaskmgmt.vdest.id = scsidev->id;
- cmdrsp->scsitaskmgmt.vdest.lun = scsidev->lun;
- cmdrsp->scsitaskmgmt.scsicmd =
- (void *)(uintptr_t)
- add_scsipending_entry_with_wait(virthbainfo,
- CMD_SCSITASKMGMT_TYPE,
- (void *)cmdrsp);
-
- uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo,
- cmdrsp, IOCHAN_TO_IOPART,
- &virthbainfo->chinfo.insertlock,
- DONT_ISSUE_INTERRUPT, (u64)NULL,
- OK_TO_WAIT, "vhba");
- wait_event(notifyevent, notifyresult != 0xffff);
- kfree(cmdrsp);
- return SUCCESS;
-}
-
-/* The abort handler returns SUCCESS if it has succeeded to make LLDD
- * and all related hardware forget about the scmd.
- */
-static int
-virthba_abort_handler(struct scsi_cmnd *scsicmd)
-{
- /* issue TASK_MGMT_ABORT_TASK */
- struct scsi_device *scsidev;
- struct virtdisk_info *vdisk;
-
- scsidev = scsicmd->device;
- for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
- vdisk->next; vdisk = vdisk->next) {
- if ((scsidev->channel == vdisk->channel) &&
- (scsidev->id == vdisk->id) &&
- (scsidev->lun == vdisk->lun)) {
- if (atomic_read(&vdisk->error_count) <
- VIRTHBA_ERROR_COUNT) {
- atomic_inc(&vdisk->error_count);
- POSTCODE_LINUX_2(VHBA_COMMAND_HANDLER_PC,
- POSTCODE_SEVERITY_INFO);
- } else
- atomic_set(&vdisk->ios_threshold,
- IOS_ERROR_THRESHOLD);
- }
- }
- return forward_taskmgmt_command(TASK_MGMT_ABORT_TASK, scsicmd->device);
-}
-
-static int
-virthba_bus_reset_handler(struct scsi_cmnd *scsicmd)
-{
- /* issue TASK_MGMT_TARGET_RESET for each target on the bus */
- struct scsi_device *scsidev;
- struct virtdisk_info *vdisk;
-
- scsidev = scsicmd->device;
- for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
- vdisk->next; vdisk = vdisk->next) {
- if ((scsidev->channel == vdisk->channel) &&
- (scsidev->id == vdisk->id) &&
- (scsidev->lun == vdisk->lun)) {
- if (atomic_read(&vdisk->error_count) <
- VIRTHBA_ERROR_COUNT) {
- atomic_inc(&vdisk->error_count);
- POSTCODE_LINUX_2(VHBA_COMMAND_HANDLER_PC,
- POSTCODE_SEVERITY_INFO);
- } else
- atomic_set(&vdisk->ios_threshold,
- IOS_ERROR_THRESHOLD);
- }
- }
- return forward_taskmgmt_command(TASK_MGMT_BUS_RESET, scsicmd->device);
-}
-
-static int
-virthba_device_reset_handler(struct scsi_cmnd *scsicmd)
-{
- /* issue TASK_MGMT_LUN_RESET */
- struct scsi_device *scsidev;
- struct virtdisk_info *vdisk;
-
- scsidev = scsicmd->device;
- for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
- vdisk->next; vdisk = vdisk->next) {
- if ((scsidev->channel == vdisk->channel) &&
- (scsidev->id == vdisk->id) &&
- (scsidev->lun == vdisk->lun)) {
- if (atomic_read(&vdisk->error_count) <
- VIRTHBA_ERROR_COUNT) {
- atomic_inc(&vdisk->error_count);
- POSTCODE_LINUX_2(VHBA_COMMAND_HANDLER_PC,
- POSTCODE_SEVERITY_INFO);
- } else
- atomic_set(&vdisk->ios_threshold,
- IOS_ERROR_THRESHOLD);
- }
- }
- return forward_taskmgmt_command(TASK_MGMT_LUN_RESET, scsicmd->device);
-}
-
-static int
-virthba_host_reset_handler(struct scsi_cmnd *scsicmd)
-{
- /* issue TASK_MGMT_TARGET_RESET for each target on each bus for host */
- return SUCCESS;
-}
-
-static char virthba_get_info_str[256];
-
-static const char *
-virthba_get_info(struct Scsi_Host *shp)
-{
- /* Return version string */
- sprintf(virthba_get_info_str, "virthba, version %s\n", VIRTHBA_VERSION);
- return virthba_get_info_str;
-}
-
-static int
-virthba_ioctl(struct scsi_device *dev, int cmd, void __user *arg)
-{
- return -EINVAL;
-}
-
-/* This returns SCSI_MLQUEUE_DEVICE_BUSY if the signal queue to IOpart
- * is full.
- */
-static int
-virthba_queue_command_lck(struct scsi_cmnd *scsicmd,
- void (*virthba_cmnd_done)(struct scsi_cmnd *))
-{
- struct scsi_device *scsidev = scsicmd->device;
- int insert_location;
- unsigned char op;
- unsigned char *cdb = scsicmd->cmnd;
- struct Scsi_Host *scsihost = scsidev->host;
- struct uiscmdrsp *cmdrsp;
- unsigned int i;
- struct virthba_info *virthbainfo =
- (struct virthba_info *)scsihost->hostdata;
- struct scatterlist *sg = NULL;
- struct scatterlist *sgl = NULL;
- int sg_failed = 0;
-
- if (virthbainfo->serverdown || virthbainfo->serverchangingstate)
- return SCSI_MLQUEUE_DEVICE_BUSY;
- cmdrsp = kzalloc(SIZEOF_CMDRSP, GFP_ATOMIC);
- if (!cmdrsp)
- return 1; /* reject the command */
-
- /* now saving everything we need from scsi_cmd into cmdrsp
- * before we queue cmdrsp set type to command - as opposed to
- * task mgmt
- */
- cmdrsp->cmdtype = CMD_SCSI_TYPE;
- /* save the pending insertion location. Deletion from pending
- * will return the scsicmd pointer for completion
- */
- insert_location =
- add_scsipending_entry(virthbainfo, CMD_SCSI_TYPE, (void *)scsicmd);
- if (insert_location != -1) {
- cmdrsp->scsi.scsicmd = (void *)(uintptr_t)insert_location;
- } else {
- kfree(cmdrsp);
- return SCSI_MLQUEUE_DEVICE_BUSY;
- }
- /* save done function that we have call when cmd is complete */
- scsicmd->scsi_done = virthba_cmnd_done;
- /* save destination */
- cmdrsp->scsi.vdest.channel = scsidev->channel;
- cmdrsp->scsi.vdest.id = scsidev->id;
- cmdrsp->scsi.vdest.lun = scsidev->lun;
- /* save datadir */
- cmdrsp->scsi.data_dir = scsicmd->sc_data_direction;
- memcpy(cmdrsp->scsi.cmnd, cdb, MAX_CMND_SIZE);
-
- cmdrsp->scsi.bufflen = scsi_bufflen(scsicmd);
-
- /* keep track of the max buffer length so far. */
- if (cmdrsp->scsi.bufflen > max_buff_len)
- max_buff_len = cmdrsp->scsi.bufflen;
-
- if (scsi_sg_count(scsicmd) > MAX_PHYS_INFO) {
- del_scsipending_entry(virthbainfo, (uintptr_t)insert_location);
- kfree(cmdrsp);
- return 1; /* reject the command */
- }
-
- /* This is what we USED to do when we assumed we were running */
- /* uissd & virthba on the same Linux system. */
- /* cmdrsp->scsi.buffer = scsicmd->request_buffer; */
- /* The following code does NOT make that assumption. */
- /* convert buffer to phys information */
- if (scsi_sg_count(scsicmd) == 0) {
- if (scsi_bufflen(scsicmd) > 0) {
- BUG_ON(scsi_sg_count(scsicmd) == 0);
- }
- } else {
- /* buffer is scatterlist - copy it out */
- sgl = scsi_sglist(scsicmd);
-
- for_each_sg(sgl, sg, scsi_sg_count(scsicmd), i) {
- cmdrsp->scsi.gpi_list[i].address = sg_phys(sg);
- cmdrsp->scsi.gpi_list[i].length = sg->length;
- }
-
- if (sg_failed) {
- /* BUG(); ***** For now, let it fail in uissd
- * if it is a problem, as it might just
- * work
- */
- }
-
- cmdrsp->scsi.guest_phys_entries = scsi_sg_count(scsicmd);
- }
-
- op = cdb[0];
- i = uisqueue_put_cmdrsp_with_lock_client(virthbainfo->chinfo.queueinfo,
- cmdrsp, IOCHAN_TO_IOPART,
- &virthbainfo->chinfo.
- insertlock,
- DONT_ISSUE_INTERRUPT,
- (u64)NULL, DONT_WAIT, "vhba");
- if (i == 0) {
- /* queue must be full - and we said don't wait - return busy */
- kfree(cmdrsp);
- del_scsipending_entry(virthbainfo, (uintptr_t)insert_location);
- return SCSI_MLQUEUE_DEVICE_BUSY;
- }
-
- /* we're done with cmdrsp space - data from it has been copied
- * into channel - free it now.
- */
- kfree(cmdrsp);
- return 0; /* non-zero implies host/device is busy */
-}
-
-static int
-virthba_slave_alloc(struct scsi_device *scsidev)
-{
- /* this called by the midlayer before scan for new devices -
- * LLD can alloc any struct & do init if needed.
- */
- struct virtdisk_info *vdisk;
- struct virtdisk_info *tmpvdisk;
- struct virthba_info *virthbainfo;
- struct Scsi_Host *scsihost = (struct Scsi_Host *)scsidev->host;
-
- virthbainfo = (struct virthba_info *)scsihost->hostdata;
- if (!virthbainfo)
- return 0; /* even though we errored, treat as success */
-
- for (vdisk = &virthbainfo->head; vdisk->next; vdisk = vdisk->next) {
- if (vdisk->next->valid &&
- (vdisk->next->channel == scsidev->channel) &&
- (vdisk->next->id == scsidev->id) &&
- (vdisk->next->lun == scsidev->lun))
- return 0;
- }
- tmpvdisk = kzalloc(sizeof(*tmpvdisk), GFP_ATOMIC);
- if (!tmpvdisk)
- return 0;
-
- tmpvdisk->channel = scsidev->channel;
- tmpvdisk->id = scsidev->id;
- tmpvdisk->lun = scsidev->lun;
- tmpvdisk->valid = 1;
- vdisk->next = tmpvdisk;
- return 0; /* success */
-}
-
-static int
-virthba_slave_configure(struct scsi_device *scsidev)
-{
- return 0; /* success */
-}
-
-static void
-virthba_slave_destroy(struct scsi_device *scsidev)
-{
- /* midlevel calls this after device has been quiesced and
- * before it is to be deleted.
- */
- struct virtdisk_info *vdisk, *delvdisk;
- struct virthba_info *virthbainfo;
- struct Scsi_Host *scsihost = (struct Scsi_Host *)scsidev->host;
-
- virthbainfo = (struct virthba_info *)scsihost->hostdata;
- for (vdisk = &virthbainfo->head; vdisk->next; vdisk = vdisk->next) {
- if (vdisk->next->valid &&
- (vdisk->next->channel == scsidev->channel) &&
- (vdisk->next->id == scsidev->id) &&
- (vdisk->next->lun == scsidev->lun)) {
- delvdisk = vdisk->next;
- vdisk->next = vdisk->next->next;
- kfree(delvdisk);
- return;
- }
- }
-}
-
-/*****************************************************/
-/* Scsi Cmnd support thread */
-/*****************************************************/
-
-static void
-do_scsi_linuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
-{
- struct virtdisk_info *vdisk;
- struct scsi_device *scsidev;
- struct sense_data *sd;
-
- scsidev = scsicmd->device;
- memcpy(scsicmd->sense_buffer, cmdrsp->scsi.sensebuf, MAX_SENSE_SIZE);
- sd = (struct sense_data *)scsicmd->sense_buffer;
-
- /* Do not log errors for disk-not-present inquiries */
- if ((cmdrsp->scsi.cmnd[0] == INQUIRY) &&
- (host_byte(cmdrsp->scsi.linuxstat) == DID_NO_CONNECT) &&
- (cmdrsp->scsi.addlstat == ADDL_SEL_TIMEOUT))
- return;
-
- /* Okay see what our error_count is here.... */
- for (vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
- vdisk->next; vdisk = vdisk->next) {
- if ((scsidev->channel != vdisk->channel) ||
- (scsidev->id != vdisk->id) ||
- (scsidev->lun != vdisk->lun))
- continue;
-
- if (atomic_read(&vdisk->error_count) < VIRTHBA_ERROR_COUNT) {
- atomic_inc(&vdisk->error_count);
- atomic_set(&vdisk->ios_threshold, IOS_ERROR_THRESHOLD);
- }
- }
-}
-
-static void
-do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
-{
- struct scsi_device *scsidev;
- unsigned char buf[36];
- struct scatterlist *sg;
- unsigned int i;
- char *thispage;
- char *thispage_orig;
- int bufind = 0;
- struct virtdisk_info *vdisk;
-
- scsidev = scsicmd->device;
- if ((cmdrsp->scsi.cmnd[0] == INQUIRY) &&
- (cmdrsp->scsi.bufflen >= MIN_INQUIRY_RESULT_LEN)) {
- if (cmdrsp->scsi.no_disk_result == 0)
- return;
-
- /* Linux scsi code is weird; it wants
- * a device at Lun 0 to issue report
- * luns, but we don't want a disk
- * there so we'll present a processor
- * there. */
- SET_NO_DISK_INQUIRY_RESULT(buf, cmdrsp->scsi.bufflen,
- scsidev->lun,
- DEV_DISK_CAPABLE_NOT_PRESENT,
- DEV_NOT_CAPABLE);
-
- if (scsi_sg_count(scsicmd) == 0) {
- if (scsi_bufflen(scsicmd) > 0) {
- BUG_ON(scsi_sg_count(scsicmd) ==
- 0);
- }
- memcpy(scsi_sglist(scsicmd), buf,
- cmdrsp->scsi.bufflen);
- return;
- }
-
- sg = scsi_sglist(scsicmd);
- for (i = 0; i < scsi_sg_count(scsicmd); i++) {
- thispage_orig = kmap_atomic(sg_page(sg + i));
- thispage = (void *)((unsigned long)thispage_orig |
- sg[i].offset);
- memcpy(thispage, buf + bufind, sg[i].length);
- kunmap_atomic(thispage_orig);
- bufind += sg[i].length;
- }
- } else {
- vdisk = &((struct virthba_info *)scsidev->host->hostdata)->head;
- for ( ; vdisk->next; vdisk = vdisk->next) {
- if ((scsidev->channel != vdisk->channel) ||
- (scsidev->id != vdisk->id) ||
- (scsidev->lun != vdisk->lun))
- continue;
-
- if (atomic_read(&vdisk->ios_threshold) > 0) {
- atomic_dec(&vdisk->ios_threshold);
- if (atomic_read(&vdisk->ios_threshold) == 0) {
- atomic_set(&vdisk->error_count, 0);
- }
- }
- }
- }
-}
-
-static void
-complete_scsi_command(struct uiscmdrsp *cmdrsp, struct scsi_cmnd *scsicmd)
-{
- /* take what we need out of cmdrsp and complete the scsicmd */
- scsicmd->result = cmdrsp->scsi.linuxstat;
- if (cmdrsp->scsi.linuxstat)
- do_scsi_linuxstat(cmdrsp, scsicmd);
- else
- do_scsi_nolinuxstat(cmdrsp, scsicmd);
-
- if (scsicmd->scsi_done)
- scsicmd->scsi_done(scsicmd);
-}
-
-static inline void
-complete_vdiskmgmt_command(struct uiscmdrsp *cmdrsp)
-{
- /* copy the result of the taskmgmt and */
- /* wake up the error handler that is waiting for this */
- *(int *)cmdrsp->vdiskmgmt.notifyresult = cmdrsp->vdiskmgmt.result;
- wake_up_all((wait_queue_head_t *)cmdrsp->vdiskmgmt.notify);
-}
-
-static inline void
-complete_taskmgmt_command(struct uiscmdrsp *cmdrsp)
-{
- /* copy the result of the taskmgmt and */
- /* wake up the error handler that is waiting for this */
- *(int *)cmdrsp->scsitaskmgmt.notifyresult =
- cmdrsp->scsitaskmgmt.result;
- wake_up_all((wait_queue_head_t *)cmdrsp->scsitaskmgmt.notify);
-}
-
-static void
-drain_queue(struct virthba_info *virthbainfo, struct chaninfo *dc,
- struct uiscmdrsp *cmdrsp)
-{
- unsigned long flags;
- int qrslt = 0;
- struct scsi_cmnd *scsicmd;
- struct Scsi_Host *shost = virthbainfo->scsihost;
-
- while (1) {
- spin_lock_irqsave(&virthbainfo->chinfo.insertlock, flags);
- if (!spar_channel_client_acquire_os(dc->queueinfo->chan,
- "vhba")) {
- spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock,
- flags);
- virthbainfo->acquire_failed_cnt++;
- break;
- }
- qrslt = uisqueue_get_cmdrsp(dc->queueinfo, cmdrsp,
- IOCHAN_FROM_IOPART);
- spar_channel_client_release_os(dc->queueinfo->chan, "vhba");
- spin_unlock_irqrestore(&virthbainfo->chinfo.insertlock, flags);
- if (qrslt == 0)
- break;
- if (cmdrsp->cmdtype == CMD_SCSI_TYPE) {
- /* scsicmd location is returned by the
- * deletion
- */
- scsicmd = del_scsipending_entry(virthbainfo,
- (uintptr_t)
- cmdrsp->scsi.scsicmd);
- if (!scsicmd)
- break;
- /* complete the orig cmd */
- complete_scsi_command(cmdrsp, scsicmd);
- } else if (cmdrsp->cmdtype == CMD_SCSITASKMGMT_TYPE) {
- if (!del_scsipending_entry(virthbainfo,
- (uintptr_t)cmdrsp->scsitaskmgmt.scsicmd))
- break;
- complete_taskmgmt_command(cmdrsp);
- } else if (cmdrsp->cmdtype == CMD_NOTIFYGUEST_TYPE) {
- /* The vHba pointer has no meaning in
- * a Client/Guest Partition. Let's be
- * safe and set it to NULL now. Do
- * not use it here! */
- cmdrsp->disknotify.v_hba = NULL;
- process_disk_notify(shost, cmdrsp);
- } else if (cmdrsp->cmdtype == CMD_VDISKMGMT_TYPE) {
- if (!del_scsipending_entry(virthbainfo,
- (uintptr_t)
- cmdrsp->vdiskmgmt.scsicmd))
- break;
- complete_vdiskmgmt_command(cmdrsp);
- }
- /* cmdrsp is now available for reuse */
- }
-}
-
-/* main function for the thread that waits for scsi commands to arrive
- * in a specified queue
- */
-static int
-process_incoming_rsps(void *v)
-{
- struct virthba_info *virthbainfo = v;
- struct chaninfo *dc = &virthbainfo->chinfo;
- struct uiscmdrsp *cmdrsp = NULL;
- const int SZ = sizeof(struct uiscmdrsp);
- u64 mask;
- unsigned long long rc1;
-
- UIS_DAEMONIZE("vhba_incoming");
- /* alloc once and reuse */
- cmdrsp = kmalloc(SZ, GFP_ATOMIC);
- if (!cmdrsp) {
- complete_and_exit(&dc->threadinfo.has_stopped, 0);
- return 0;
- }
- mask = ULTRA_CHANNEL_ENABLE_INTS;
- while (1) {
- if (kthread_should_stop())
- break;
- wait_event_interruptible_timeout(virthbainfo->rsp_queue,
- (atomic_read(&virthbainfo->interrupt_rcvd) == 1),
- usecs_to_jiffies(rsltq_wait_usecs));
- atomic_set(&virthbainfo->interrupt_rcvd, 0);
- /* drain queue */
- drain_queue(virthbainfo, dc, cmdrsp);
- rc1 = uisqueue_interlocked_or(virthbainfo->flags_addr, mask);
- }
-
- kfree(cmdrsp);
-
- complete_and_exit(&dc->threadinfo.has_stopped, 0);
-}
-
-/*****************************************************/
-/* Debugfs filesystem functions */
-/*****************************************************/
-
-static ssize_t info_debugfs_read(struct file *file,
- char __user *buf, size_t len, loff_t *offset)
-{
- ssize_t bytes_read = 0;
- int str_pos = 0;
- u64 phys_flags_addr;
- int i;
- struct virthba_info *virthbainfo;
- char *vbuf;
-
- if (len > MAX_BUF)
- len = MAX_BUF;
- vbuf = kzalloc(len, GFP_KERNEL);
- if (!vbuf)
- return -ENOMEM;
-
- for (i = 0; i < VIRTHBASOPENMAX; i++) {
- if (!virthbas_open[i].virthbainfo)
- continue;
-
- virthbainfo = virthbas_open[i].virthbainfo;
-
- str_pos += scnprintf(vbuf + str_pos,
- len - str_pos, "max_buff_len:%u\n",
- max_buff_len);
-
- str_pos += scnprintf(vbuf + str_pos, len - str_pos,
- "\nvirthba result queue poll wait:%d usecs.\n",
- rsltq_wait_usecs);
- str_pos += scnprintf(vbuf + str_pos, len - str_pos,
- "\ninterrupts_rcvd = %llu, interrupts_disabled = %llu\n",
- virthbainfo->interrupts_rcvd,
- virthbainfo->interrupts_disabled);
- str_pos += scnprintf(vbuf + str_pos,
- len - str_pos, "\ninterrupts_notme = %llu,\n",
- virthbainfo->interrupts_notme);
- phys_flags_addr = virt_to_phys((__force void *)
- virthbainfo->flags_addr);
- str_pos += scnprintf(vbuf + str_pos, len - str_pos,
- "flags_addr = %p, phys_flags_addr=0x%016llx, FeatureFlags=%llu\n",
- virthbainfo->flags_addr, phys_flags_addr,
- (__le64)readq(virthbainfo->flags_addr));
- str_pos += scnprintf(vbuf + str_pos,
- len - str_pos, "acquire_failed_cnt:%llu\n",
- virthbainfo->acquire_failed_cnt);
- str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n");
- }
-
- bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos);
- kfree(vbuf);
- return bytes_read;
-}
-
-static ssize_t enable_ints_write(struct file *file, const char __user *buffer,
- size_t count, loff_t *ppos)
-{
- char buf[4];
- int i, new_value;
- struct virthba_info *virthbainfo;
-
- u64 __iomem *features_addr;
- u64 mask;
-
- if (count >= ARRAY_SIZE(buf))
- return -EINVAL;
-
- buf[count] = '\0';
- if (copy_from_user(buf, buffer, count))
- return -EFAULT;
-
- i = kstrtoint(buf, 10, &new_value);
-
- if (i != 0)
- return -EFAULT;
-
- /* set all counts to new_value usually 0 */
- for (i = 0; i < VIRTHBASOPENMAX; i++) {
- if (virthbas_open[i].virthbainfo) {
- virthbainfo = virthbas_open[i].virthbainfo;
- features_addr =
- &virthbainfo->chinfo.queueinfo->chan->features;
- if (new_value == 1) {
- mask = ~(ULTRA_IO_CHANNEL_IS_POLLING |
- ULTRA_IO_DRIVER_DISABLES_INTS);
- uisqueue_interlocked_and(features_addr, mask);
- mask = ULTRA_IO_DRIVER_ENABLES_INTS;
- uisqueue_interlocked_or(features_addr, mask);
- rsltq_wait_usecs = 4000000;
- } else {
- mask = ~(ULTRA_IO_DRIVER_ENABLES_INTS |
- ULTRA_IO_DRIVER_DISABLES_INTS);
- uisqueue_interlocked_and(features_addr, mask);
- mask = ULTRA_IO_CHANNEL_IS_POLLING;
- uisqueue_interlocked_or(features_addr, mask);
- rsltq_wait_usecs = 4000;
- }
- }
- }
- return count;
-}
-
-/* As per VirtpciFunc returns 1 for success and 0 for failure */
-static int
-virthba_serverup(struct virtpci_dev *virtpcidev)
-{
- struct virthba_info *virthbainfo =
- (struct virthba_info *)((struct Scsi_Host *)virtpcidev->scsi.
- scsihost)->hostdata;
-
- if (!virthbainfo->serverdown)
- return 1;
-
- if (virthbainfo->serverchangingstate)
- return 0;
-
- virthbainfo->serverchangingstate = true;
- /* Must transition channel to ATTACHED state BEFORE we
- * can start using the device again
- */
- SPAR_CHANNEL_CLIENT_TRANSITION(virthbainfo->chinfo.queueinfo->chan,
- dev_name(&virtpcidev->generic_dev),
- CHANNELCLI_ATTACHED, NULL);
-
- /* Start Processing the IOVM Response Queue Again */
- if (!uisthread_start(&virthbainfo->chinfo.threadinfo,
- process_incoming_rsps,
- virthbainfo, "vhba_incoming")) {
- return 0;
- }
- virthbainfo->serverdown = false;
- virthbainfo->serverchangingstate = false;
-
- return 1;
-}
-
-static void
-virthba_serverdown_complete(struct work_struct *work)
-{
- struct virthba_info *virthbainfo;
- struct virtpci_dev *virtpcidev;
- int i;
- struct scsipending *pendingdel = NULL;
- struct scsi_cmnd *scsicmd = NULL;
- struct uiscmdrsp *cmdrsp;
- unsigned long flags;
-
- virthbainfo = container_of(work, struct virthba_info,
- serverdown_completion);
-
- /* Stop Using the IOVM Response Queue (queue should be drained
- * by the end)
- */
- uisthread_stop(&virthbainfo->chinfo.threadinfo);
-
- /* Fail Commands that weren't completed */
- spin_lock_irqsave(&virthbainfo->privlock, flags);
- for (i = 0; i < MAX_PENDING_REQUESTS; i++) {
- pendingdel = &virthbainfo->pending[i];
- switch (pendingdel->cmdtype) {
- case CMD_SCSI_TYPE:
- scsicmd = (struct scsi_cmnd *)pendingdel->sent;
- scsicmd->result = DID_RESET << 16;
- if (scsicmd->scsi_done)
- scsicmd->scsi_done(scsicmd);
- break;
- case CMD_SCSITASKMGMT_TYPE:
- cmdrsp = (struct uiscmdrsp *)pendingdel->sent;
- wake_up_all((wait_queue_head_t *)
- cmdrsp->scsitaskmgmt.notify);
- *(int *)cmdrsp->scsitaskmgmt.notifyresult =
- TASK_MGMT_FAILED;
- break;
- case CMD_VDISKMGMT_TYPE:
- cmdrsp = (struct uiscmdrsp *)pendingdel->sent;
- *(int *)cmdrsp->vdiskmgmt.notifyresult =
- VDISK_MGMT_FAILED;
- wake_up_all((wait_queue_head_t *)
- cmdrsp->vdiskmgmt.notify);
- break;
- default:
- break;
- }
- pendingdel->cmdtype = 0;
- pendingdel->sent = NULL;
- }
- spin_unlock_irqrestore(&virthbainfo->privlock, flags);
-
- virtpcidev = virthbainfo->virtpcidev;
-
- virthbainfo->serverdown = true;
- virthbainfo->serverchangingstate = false;
- /* Return the ServerDown response to Command */
- visorchipset_device_pause_response(virtpcidev->bus_no,
- virtpcidev->device_no, 0);
-}
-
-/* As per VirtpciFunc returns 1 for success and 0 for failure */
-static int
-virthba_serverdown(struct virtpci_dev *virtpcidev, u32 state)
-{
- int stat = 1;
-
- struct virthba_info *virthbainfo =
- (struct virthba_info *)((struct Scsi_Host *)virtpcidev->scsi.
- scsihost)->hostdata;
-
- if (!virthbainfo->serverdown && !virthbainfo->serverchangingstate) {
- virthbainfo->serverchangingstate = true;
- queue_work(virthba_serverdown_workqueue,
- &virthbainfo->serverdown_completion);
- } else if (virthbainfo->serverchangingstate) {
- stat = 0;
- }
-
- return stat;
-}
-
-/*****************************************************/
-/* Module Init & Exit functions */
-/*****************************************************/
-
-static int __init
-virthba_parse_line(char *str)
-{
- return 1;
-}
-
-static void __init
-virthba_parse_options(char *line)
-{
- char *next = line;
-
- POSTCODE_LINUX_2(VHBA_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
- if (!line || !*line)
- return;
- while ((line = next)) {
- next = strchr(line, ' ');
- if (next)
- *next++ = 0;
- virthba_parse_line(line);
- }
-
- POSTCODE_LINUX_2(VHBA_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
-}
-
-static int __init
-virthba_mod_init(void)
-{
- int error;
- int i;
-
- if (!unisys_spar_platform)
- return -ENODEV;
-
- POSTCODE_LINUX_2(VHBA_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
- virthba_parse_options(virthba_options);
-
- error = virtpci_register_driver(&virthba_driver);
- if (error < 0) {
- POSTCODE_LINUX_3(VHBA_CREATE_FAILURE_PC, error,
- POSTCODE_SEVERITY_ERR);
- } else {
- /* create the debugfs directories and entries */
- virthba_debugfs_dir = debugfs_create_dir("virthba", NULL);
- debugfs_create_file("info", S_IRUSR, virthba_debugfs_dir,
- NULL, &debugfs_info_fops);
- debugfs_create_u32("rqwait_usecs", S_IRUSR | S_IWUSR,
- virthba_debugfs_dir, &rsltq_wait_usecs);
- debugfs_create_file("enable_ints", S_IWUSR,
- virthba_debugfs_dir, NULL,
- &debugfs_enable_ints_fops);
- /* Initialize dar_work_queue */
- INIT_WORK(&dar_work_queue, do_disk_add_remove);
- spin_lock_init(&dar_work_queue_lock);
-
- /* clear out array */
- for (i = 0; i < VIRTHBASOPENMAX; i++)
- virthbas_open[i].virthbainfo = NULL;
- /* Initialize the serverdown workqueue */
- virthba_serverdown_workqueue =
- create_singlethread_workqueue("virthba_serverdown");
- if (!virthba_serverdown_workqueue) {
- POSTCODE_LINUX_2(VHBA_CREATE_FAILURE_PC,
- POSTCODE_SEVERITY_ERR);
- error = -1;
- }
- }
-
- POSTCODE_LINUX_2(VHBA_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
- return error;
-}
-
-static ssize_t
-virthba_acquire_lun(struct device *cdev, struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct uisscsi_dest vdest;
- struct Scsi_Host *shost = class_to_shost(cdev);
- int i;
-
- i = sscanf(buf, "%d-%d-%d", &vdest.channel, &vdest.id, &vdest.lun);
- if (i != 3)
- return i;
-
- return forward_vdiskmgmt_command(VDISK_MGMT_ACQUIRE, shost, &vdest);
-}
-
-static ssize_t
-virthba_release_lun(struct device *cdev, struct device_attribute *attr,
- const char *buf, size_t count)
-{
- struct uisscsi_dest vdest;
- struct Scsi_Host *shost = class_to_shost(cdev);
- int i;
-
- i = sscanf(buf, "%d-%d-%d", &vdest.channel, &vdest.id, &vdest.lun);
- if (i != 3)
- return i;
-
- return forward_vdiskmgmt_command(VDISK_MGMT_RELEASE, shost, &vdest);
-}
-
-#define CLASS_DEVICE_ATTR(_name, _mode, _show, _store) \
- struct device_attribute class_device_attr_##_name = \
- __ATTR(_name, _mode, _show, _store)
-
-static CLASS_DEVICE_ATTR(acquire_lun, S_IWUSR, NULL, virthba_acquire_lun);
-static CLASS_DEVICE_ATTR(release_lun, S_IWUSR, NULL, virthba_release_lun);
-
-static DEVICE_ATTRIBUTE *virthba_shost_attrs[] = {
- &class_device_attr_acquire_lun,
- &class_device_attr_release_lun,
- NULL
-};
-
-static void __exit
-virthba_mod_exit(void)
-{
- virtpci_unregister_driver(&virthba_driver);
- /* unregister is going to call virthba_remove */
- /* destroy serverdown completion workqueue */
- if (virthba_serverdown_workqueue) {
- destroy_workqueue(virthba_serverdown_workqueue);
- virthba_serverdown_workqueue = NULL;
- }
-
- debugfs_remove_recursive(virthba_debugfs_dir);
-}
-
-/* specify function to be run at module insertion time */
-module_init(virthba_mod_init);
-
-/* specify function to be run when module is removed */
-module_exit(virthba_mod_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Usha Srinivasan");
-MODULE_ALIAS("uisvirthba");
- /* this is extracted during depmod and kept in modules.dep */
-/* module parameter */
-module_param(virthba_options, charp, S_IRUGO);
diff --git a/drivers/staging/unisys/virthba/virthba.h b/drivers/staging/unisys/virthba/virthba.h
deleted file mode 100644
index 59901668d4f458..00000000000000
--- a/drivers/staging/unisys/virthba/virthba.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* virthba.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/*
- * Unisys Virtual HBA driver header
- */
-
-#ifndef __VIRTHBA_H__
-#define __VIRTHBA_H__
-
-#define VIRTHBA_VERSION "01.00"
-
-#endif /* __VIRTHBA_H__ */
diff --git a/drivers/staging/unisys/virtpci/Kconfig b/drivers/staging/unisys/virtpci/Kconfig
deleted file mode 100644
index 6d19482ce11bad..00000000000000
--- a/drivers/staging/unisys/virtpci/Kconfig
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# Unisys virtpci configuration
-#
-
-config UNISYS_VIRTPCI
- tristate "Unisys virtpci driver"
- select UNISYS_UISLIB
- ---help---
- If you say Y here, you will enable the Unisys virtpci driver.
-
diff --git a/drivers/staging/unisys/virtpci/Makefile b/drivers/staging/unisys/virtpci/Makefile
deleted file mode 100644
index a26c696219a50c..00000000000000
--- a/drivers/staging/unisys/virtpci/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# Makefile for Unisys virtpci
-#
-
-obj-$(CONFIG_UNISYS_VIRTPCI) += virtpci.o
-
-ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/uislib
-ccflags-y += -Idrivers/staging/unisys/common-spar/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
diff --git a/drivers/staging/unisys/virtpci/virtpci.c b/drivers/staging/unisys/virtpci/virtpci.c
deleted file mode 100644
index d5ad01783c0721..00000000000000
--- a/drivers/staging/unisys/virtpci/virtpci.c
+++ /dev/null
@@ -1,1394 +0,0 @@
-/* virtpci.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#define EXPORT_SYMTAB
-
-#include <linux/kernel.h>
-#ifdef CONFIG_MODVERSIONS
-#include <config/modversions.h>
-#endif
-#include "diagnostics/appos_subsystems.h"
-#include "uisutils.h"
-#include "vbuschannel.h"
-#include "vbushelper.h"
-#include <linux/types.h>
-#include <linux/io.h>
-#include <linux/uuid.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/pci.h>
-#include <linux/device.h>
-#include <linux/list.h>
-#include <linux/slab.h>
-#include <linux/mod_devicetable.h>
-#include <linux/if_ether.h>
-#include <linux/version.h>
-#include <linux/debugfs.h>
-#include "version.h"
-#include "guestlinuxdebug.h"
-#include "timskmod.h"
-
-struct driver_private {
- struct kobject kobj;
- struct klist klist_devices;
- struct klist_node knode_bus;
- struct module_kobject *mkobj;
- struct device_driver *driver;
-};
-
-#define to_driver(obj) container_of(obj, struct driver_private, kobj)
-
-/* bus_id went away in 2.6.30 - the size was 20 bytes, so we'll define
- * it ourselves, and a macro to make getting the field a bit simpler.
- */
-#ifndef BUS_ID_SIZE
-#define BUS_ID_SIZE 20
-#endif
-
-#define BUS_ID(x) dev_name(x)
-
-/* MAX_BUF = 4 busses x ( 32 devices/bus + 1 busline) x 80 characters
- * = 10,560 bytes ~ 2^14 = 16,384 bytes
- */
-#define MAX_BUF 16384
-
-#include "virtpci.h"
-
-/* this is shorter than using __FILE__ (full path name) in
- * debug/info/error messages
- */
-#define CURRENT_FILE_PC VIRT_PCI_PC_virtpci_c
-#define __MYFILE__ "virtpci.c"
-
-#define VIRTPCI_VERSION "01.00"
-
-/*****************************************************/
-/* Forward declarations */
-/*****************************************************/
-
-static int delete_vbus_device(struct device *vbus, void *data);
-static int match_busid(struct device *dev, void *data);
-static void virtpci_bus_release(struct device *dev);
-static void virtpci_device_release(struct device *dev);
-static int virtpci_device_add(struct device *parentbus, int devtype,
- struct add_virt_guestpart *addparams,
- struct scsi_adap_info *scsi,
- struct net_adap_info *net);
-static int virtpci_device_del(struct device *parentbus, int devtype,
- struct vhba_wwnn *wwnn, unsigned char macaddr[]);
-static int virtpci_device_serverdown(struct device *parentbus, int devtype,
- struct vhba_wwnn *wwnn,
- unsigned char macaddr[]);
-static int virtpci_device_serverup(struct device *parentbus, int devtype,
- struct vhba_wwnn *wwnn,
- unsigned char macaddr[]);
-static ssize_t virtpci_driver_attr_show(struct kobject *kobj,
- struct attribute *attr, char *buf);
-static ssize_t virtpci_driver_attr_store(struct kobject *kobj,
- struct attribute *attr,
- const char *buf, size_t count);
-static int virtpci_bus_match(struct device *dev, struct device_driver *drv);
-static int virtpci_uevent(struct device *dev, struct kobj_uevent_env *env);
-static int virtpci_device_probe(struct device *dev);
-static int virtpci_device_remove(struct device *dev);
-
-static ssize_t info_debugfs_read(struct file *file, char __user *buf,
- size_t len, loff_t *offset);
-
-static const struct file_operations debugfs_info_fops = {
- .read = info_debugfs_read,
-};
-
-/*****************************************************/
-/* Globals */
-/*****************************************************/
-
-/* methods in bus_type struct allow the bus code to serve as an
- * intermediary between the device core and individual device core and
- * individual drivers
- */
-static struct bus_type virtpci_bus_type = {
- .name = "uisvirtpci",
- .match = virtpci_bus_match,
- .uevent = virtpci_uevent,
-};
-
-static struct device virtpci_rootbus_device = {
- .init_name = "vbusroot", /* root bus */
- .release = virtpci_bus_release
-};
-
-/* filled in with info about parent chipset driver when we register with it */
-static struct ultra_vbus_deviceinfo chipset_driver_info;
-
-static const struct sysfs_ops virtpci_driver_sysfs_ops = {
- .show = virtpci_driver_attr_show,
- .store = virtpci_driver_attr_store,
-};
-
-static struct kobj_type virtpci_driver_kobj_type = {
- .sysfs_ops = &virtpci_driver_sysfs_ops,
-};
-
-static struct virtpci_dev *vpcidev_list_head;
-static DEFINE_RWLOCK(vpcidev_list_lock);
-
-/* filled in with info about this driver, wrt it servicing client busses */
-static struct ultra_vbus_deviceinfo bus_driver_info;
-
-/*****************************************************/
-/* debugfs entries */
-/*****************************************************/
-/* dentry is used to create the debugfs entry directory
- * for virtpci
- */
-static struct dentry *virtpci_debugfs_dir;
-
-struct virtpci_busdev {
- struct device virtpci_bus_device;
-};
-
-/*****************************************************/
-/* Local functions */
-/*****************************************************/
-
-static inline
-int WAIT_FOR_IO_CHANNEL(struct spar_io_channel_protocol __iomem *chanptr)
-{
- int count = 120;
-
- while (count > 0) {
- if (SPAR_CHANNEL_SERVER_READY(&chanptr->channel_header))
- return 1;
- UIS_THREAD_WAIT_SEC(1);
- count--;
- }
- return 0;
-}
-
-/* Write the contents of <info> to the ULTRA_VBUS_CHANNEL_PROTOCOL.ChpInfo. */
-static int write_vbus_chp_info(struct spar_vbus_channel_protocol *chan,
- struct ultra_vbus_deviceinfo *info)
-{
- int off;
-
- if (!chan)
- return -1;
-
- off = sizeof(struct channel_header) + chan->hdr_info.chp_info_offset;
- if (chan->hdr_info.chp_info_offset == 0) {
- return -1;
- }
- memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
- return 0;
-}
-
-/* Write the contents of <info> to the ULTRA_VBUS_CHANNEL_PROTOCOL.BusInfo. */
-static int write_vbus_bus_info(struct spar_vbus_channel_protocol *chan,
- struct ultra_vbus_deviceinfo *info)
-{
- int off;
-
- if (!chan)
- return -1;
-
- off = sizeof(struct channel_header) + chan->hdr_info.bus_info_offset;
- if (chan->hdr_info.bus_info_offset == 0)
- return -1;
- memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
- return 0;
-}
-
-/* Write the contents of <info> to the
- * ULTRA_VBUS_CHANNEL_PROTOCOL.DevInfo[<devix>].
- */
-static int
-write_vbus_dev_info(struct spar_vbus_channel_protocol *chan,
- struct ultra_vbus_deviceinfo *info, int devix)
-{
- int off;
-
- if (!chan)
- return -1;
-
- off =
- (sizeof(struct channel_header) +
- chan->hdr_info.dev_info_offset) +
- (chan->hdr_info.device_info_struct_bytes * devix);
- if (chan->hdr_info.dev_info_offset == 0)
- return -1;
-
- memcpy(((u8 *)(chan)) + off, info, sizeof(*info));
- return 0;
-}
-
-/* adds a vbus
- * returns 0 failure, 1 success,
- */
-static int add_vbus(struct add_vbus_guestpart *addparams)
-{
- int ret;
- struct device *vbus;
-
- vbus = kzalloc(sizeof(*vbus), GFP_ATOMIC);
-
- POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
- if (!vbus)
- return 0;
-
- dev_set_name(vbus, "vbus%d", addparams->bus_no);
- vbus->release = virtpci_bus_release;
- vbus->parent = &virtpci_rootbus_device; /* root bus is parent */
- vbus->bus = &virtpci_bus_type; /* bus type */
- vbus->platform_data = (__force void *)addparams->chanptr;
-
- /* register a virt bus device -
- * this bus shows up under /sys/devices with .name value
- * "virtpci%d" any devices added to this bus then show up under
- * /sys/devices/virtpci0
- */
- ret = device_register(vbus);
- if (ret) {
- POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- return 0;
- }
- write_vbus_chp_info(vbus->platform_data /* chanptr */,
- &chipset_driver_info);
- write_vbus_bus_info(vbus->platform_data /* chanptr */,
- &bus_driver_info);
- POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
- return 1;
-}
-
-/* for CHANSOCK wwwnn/max are AUTO-GENERATED; for normal channels,
- * wwnn/max are in the channel header.
- */
-#define GET_SCSIADAPINFO_FROM_CHANPTR(chanptr) { \
- memcpy_fromio(&scsi.wwnn, \
- &((struct spar_io_channel_protocol __iomem *) \
- chanptr)->vhba.wwnn, \
- sizeof(struct vhba_wwnn)); \
- memcpy_fromio(&scsi.max, \
- &((struct spar_io_channel_protocol __iomem *) \
- chanptr)->vhba.max, \
- sizeof(struct vhba_config_max)); \
- }
-
-/* adds a vhba
- * returns 0 failure, 1 success,
- */
-static int add_vhba(struct add_virt_guestpart *addparams)
-{
- int i;
- struct scsi_adap_info scsi;
- struct device *vbus;
- unsigned char busid[BUS_ID_SIZE];
-
- POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
- if (!WAIT_FOR_IO_CHANNEL
- ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) {
- POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- return 0;
- }
-
- GET_SCSIADAPINFO_FROM_CHANPTR(addparams->chanptr);
-
- /* find bus device with the busid that matches match_busid */
- sprintf(busid, "vbus%d", addparams->bus_no);
- vbus = bus_find_device(&virtpci_bus_type, NULL,
- (void *)busid, match_busid);
- if (!vbus)
- return 0;
-
- i = virtpci_device_add(vbus, VIRTHBA_TYPE, addparams, &scsi, NULL);
- if (i) {
- POSTCODE_LINUX_3(VPCI_CREATE_EXIT_PC, i,
- POSTCODE_SEVERITY_INFO);
- }
- return i;
-}
-
-/* for CHANSOCK macaddr is AUTO-GENERATED; for normal channels,
- * macaddr is in the channel header.
- */
-#define GET_NETADAPINFO_FROM_CHANPTR(chanptr) { \
- memcpy_fromio(net.mac_addr, \
- ((struct spar_io_channel_protocol __iomem *) \
- chanptr)->vnic.macaddr, \
- MAX_MACADDR_LEN); \
- net.num_rcv_bufs = \
- readl(&((struct spar_io_channel_protocol __iomem *)\
- chanptr)->vnic.num_rcv_bufs); \
- net.mtu = readl(&((struct spar_io_channel_protocol __iomem *) \
- chanptr)->vnic.mtu); \
- memcpy_fromio(&net.zone_uuid, \
- &((struct spar_io_channel_protocol __iomem *)\
- chanptr)->vnic.zone_uuid, \
- sizeof(uuid_le)); \
-}
-
-/* adds a vnic
- * returns 0 failure, 1 success,
- */
-static int
-add_vnic(struct add_virt_guestpart *addparams)
-{
- int i;
- struct net_adap_info net;
- struct device *vbus;
- unsigned char busid[BUS_ID_SIZE];
-
- POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
- if (!WAIT_FOR_IO_CHANNEL
- ((struct spar_io_channel_protocol __iomem *)addparams->chanptr)) {
- POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- return 0;
- }
-
- GET_NETADAPINFO_FROM_CHANPTR(addparams->chanptr);
-
- /* find bus device with the busid that matches match_busid */
- sprintf(busid, "vbus%d", addparams->bus_no);
- vbus = bus_find_device(&virtpci_bus_type, NULL,
- (void *)busid, match_busid);
- if (!vbus)
- return 0;
-
- i = virtpci_device_add(vbus, VIRTNIC_TYPE, addparams, NULL, &net);
- if (i) {
- POSTCODE_LINUX_3(VPCI_CREATE_EXIT_PC, i,
- POSTCODE_SEVERITY_INFO);
- return 1;
- }
- return 0;
-}
-
-/* delete vbus
- * returns 0 failure, 1 success,
- */
-static int
-delete_vbus(struct del_vbus_guestpart *delparams)
-{
- struct device *vbus;
- unsigned char busid[BUS_ID_SIZE];
-
- /* find bus device with the busid that matches match_busid */
- sprintf(busid, "vbus%d", delparams->bus_no);
- vbus = bus_find_device(&virtpci_bus_type, NULL,
- (void *)busid, match_busid);
- if (!vbus)
- return 0;
-
- /* ensure that bus has no devices? -- TBD */
- return 1;
-}
-
-static int
-delete_vbus_device(struct device *vbus, void *data)
-{
- struct device *dev = &virtpci_rootbus_device;
-
- if ((data) && match_busid(vbus, (void *)BUS_ID(dev))) {
- /* skip it - don't delete root bus */
- return 0; /* pretend no error */
- }
- device_unregister(vbus);
- kfree(vbus);
- return 0; /* no error */
-}
-
-/* pause vhba
-* returns 0 failure, 1 success,
-*/
-static int pause_vhba(struct pause_virt_guestpart *pauseparams)
-{
- int i;
- struct scsi_adap_info scsi;
-
- GET_SCSIADAPINFO_FROM_CHANPTR(pauseparams->chanptr);
-
- i = virtpci_device_serverdown(NULL /*no parent bus */, VIRTHBA_TYPE,
- &scsi.wwnn, NULL);
- return i;
-}
-
-/* pause vnic
- * returns 0 failure, 1 success,
- */
-static int pause_vnic(struct pause_virt_guestpart *pauseparams)
-{
- int i;
- struct net_adap_info net;
-
- GET_NETADAPINFO_FROM_CHANPTR(pauseparams->chanptr);
-
- i = virtpci_device_serverdown(NULL /*no parent bus */, VIRTNIC_TYPE,
- NULL, net.mac_addr);
- return i;
-}
-
-/* resume vhba
- * returns 0 failure, 1 success,
- */
-static int resume_vhba(struct resume_virt_guestpart *resumeparams)
-{
- int i;
- struct scsi_adap_info scsi;
-
- GET_SCSIADAPINFO_FROM_CHANPTR(resumeparams->chanptr);
-
- i = virtpci_device_serverup(NULL /*no parent bus */, VIRTHBA_TYPE,
- &scsi.wwnn, NULL);
- return i;
-}
-
-/* resume vnic
-* returns 0 failure, 1 success,
-*/
-static int
-resume_vnic(struct resume_virt_guestpart *resumeparams)
-{
- int i;
- struct net_adap_info net;
-
- GET_NETADAPINFO_FROM_CHANPTR(resumeparams->chanptr);
-
- i = virtpci_device_serverup(NULL /*no parent bus */, VIRTNIC_TYPE,
- NULL, net.mac_addr);
- return i;
-}
-
-/* delete vhba
-* returns 0 failure, 1 success,
-*/
-static int delete_vhba(struct del_virt_guestpart *delparams)
-{
- int i;
- struct scsi_adap_info scsi;
-
- GET_SCSIADAPINFO_FROM_CHANPTR(delparams->chanptr);
-
- i = virtpci_device_del(NULL /*no parent bus */, VIRTHBA_TYPE,
- &scsi.wwnn, NULL);
- if (i) {
- return 1;
- }
- return 0;
-}
-
-/* deletes a vnic
- * returns 0 failure, 1 success,
- */
-static int delete_vnic(struct del_virt_guestpart *delparams)
-{
- int i;
- struct net_adap_info net;
-
- GET_NETADAPINFO_FROM_CHANPTR(delparams->chanptr);
-
- i = virtpci_device_del(NULL /*no parent bus */, VIRTNIC_TYPE, NULL,
- net.mac_addr);
- return i;
-}
-
-#define DELETE_ONE_VPCIDEV(vpcidev) { \
- device_unregister(&vpcidev->generic_dev); \
- kfree(vpcidev); \
-}
-
-/* deletes all vhbas and vnics
- * returns 0 failure, 1 success,
- */
-static void delete_all(void)
-{
- int count = 0;
- unsigned long flags;
- struct virtpci_dev *tmpvpcidev, *nextvpcidev;
-
- /* delete the entire vhba/vnic list in one shot */
- write_lock_irqsave(&vpcidev_list_lock, flags);
- tmpvpcidev = vpcidev_list_head;
- vpcidev_list_head = NULL;
- write_unlock_irqrestore(&vpcidev_list_lock, flags);
-
- /* delete one vhba/vnic at a time */
- while (tmpvpcidev) {
- nextvpcidev = tmpvpcidev->next;
- /* delete the vhba/vnic at tmpvpcidev */
- DELETE_ONE_VPCIDEV(tmpvpcidev);
- tmpvpcidev = nextvpcidev;
- count++;
- }
-
- /* now delete each vbus */
- bus_for_each_dev(&virtpci_bus_type, NULL, (void *)1,
- delete_vbus_device);
-}
-
-/* deletes all vnics or vhbas
- * returns 0 failure, 1 success,
- */
-static int delete_all_virt(enum virtpci_dev_type devtype,
- struct del_vbus_guestpart *delparams)
-{
- int i;
- unsigned char busid[BUS_ID_SIZE];
- struct device *vbus;
-
- /* find bus device with the busid that matches match_busid */
- sprintf(busid, "vbus%d", delparams->bus_no);
- vbus = bus_find_device(&virtpci_bus_type, NULL,
- (void *)busid, match_busid);
- if (!vbus)
- return 0;
-
- if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE))
- return 0;
-
- /* delete all vhbas/vnics */
- i = virtpci_device_del(vbus, devtype, NULL, NULL);
- return 1;
-}
-
-static int virtpci_ctrlchan_func(struct guest_msgs *msg)
-{
- switch (msg->msgtype) {
- case GUEST_ADD_VBUS:
- return add_vbus(&msg->add_vbus);
- case GUEST_ADD_VHBA:
- return add_vhba(&msg->add_vhba);
- case GUEST_ADD_VNIC:
- return add_vnic(&msg->add_vnic);
- case GUEST_DEL_VBUS:
- return delete_vbus(&msg->del_vbus);
- case GUEST_DEL_VHBA:
- return delete_vhba(&msg->del_vhba);
- case GUEST_DEL_VNIC:
- return delete_vnic(&msg->del_vhba);
- case GUEST_DEL_ALL_VHBAS:
- return delete_all_virt(VIRTHBA_TYPE, &msg->del_all_vhbas);
- case GUEST_DEL_ALL_VNICS:
- return delete_all_virt(VIRTNIC_TYPE, &msg->del_all_vnics);
- case GUEST_DEL_ALL_VBUSES:
- delete_all();
- return 1;
- case GUEST_PAUSE_VHBA:
- return pause_vhba(&msg->pause_vhba);
- case GUEST_PAUSE_VNIC:
- return pause_vnic(&msg->pause_vnic);
- case GUEST_RESUME_VHBA:
- return resume_vhba(&msg->resume_vhba);
- case GUEST_RESUME_VNIC:
- return resume_vnic(&msg->resume_vnic);
- default:
- return 0;
- }
-}
-
-/* same as driver_helper in bus.c linux */
-static int match_busid(struct device *dev, void *data)
-{
- const char *name = data;
-
- if (strcmp(name, BUS_ID(dev)) == 0)
- return 1;
- return 0;
-}
-
-/*****************************************************/
-/* Bus functions */
-/*****************************************************/
-
-static const struct pci_device_id *
-virtpci_match_device(const struct pci_device_id *ids,
- const struct virtpci_dev *dev)
-{
- while (ids->vendor || ids->subvendor || ids->class_mask) {
- if ((ids->vendor == dev->vendor) &&
- (ids->device == dev->device))
- return ids;
-
- ids++;
- }
- return NULL;
-}
-
-/* NOTE: !!!!!! This function is called when a new device is added
-* for this bus. Or, it is called for existing devices when a new
-* driver is added for this bus. It returns nonzero if a given device
-* can be handled by the given driver.
-*/
-static int virtpci_bus_match(struct device *dev, struct device_driver *drv)
-{
- struct virtpci_dev *virtpcidev = device_to_virtpci_dev(dev);
- struct virtpci_driver *virtpcidrv = driver_to_virtpci_driver(drv);
- int match = 0;
-
- /* check ids list for a match */
- if (virtpci_match_device(virtpcidrv->id_table, virtpcidev))
- match = 1;
-
- return match; /* 0 - no match; 1 - yes it matches */
-}
-
-static int virtpci_uevent(struct device *dev, struct kobj_uevent_env *env)
-{
- /* add variables to the environment prior to the generation of
- * hotplug events to user space
- */
- if (add_uevent_var(env, "VIRTPCI_VERSION=%s", VIRTPCI_VERSION))
- return -ENOMEM;
- return 0;
-}
-
-/* For a child device just created on a client bus, fill in
- * information about the driver that is controlling this device into
- * the appropriate slot within the vbus channel of the bus
- * instance.
- */
-static void fix_vbus_dev_info(struct device *dev, int dev_no, int dev_type,
- struct virtpci_driver *virtpcidrv)
-{
- struct device *vbus;
- void *chan;
- struct ultra_vbus_deviceinfo dev_info;
- const char *stype;
-
- if (!dev)
- return;
- if (!virtpcidrv)
- return;
-
- vbus = dev->parent;
- if (!vbus)
- return;
-
- chan = vbus->platform_data;
- if (!chan)
- return;
-
- switch (dev_type) {
- case PCI_DEVICE_ID_VIRTHBA:
- stype = "vHBA";
- break;
- case PCI_DEVICE_ID_VIRTNIC:
- stype = "vNIC";
- break;
- default:
- stype = "unknown";
- break;
- }
- bus_device_info_init(&dev_info, stype,
- virtpcidrv->name,
- virtpcidrv->version,
- virtpcidrv->vertag);
- write_vbus_dev_info(chan, &dev_info, dev_no);
-
- /* Re-write bus+chipset info, because it is possible that this
- * was previously written by our good counterpart, visorbus.
- */
- write_vbus_chp_info(chan, &chipset_driver_info);
- write_vbus_bus_info(chan, &bus_driver_info);
-}
-
-/* This function is called to query the existence of a specific device
-* and whether this driver can work with it. It should return -ENODEV
-* in case of failure.
-*/
-static int virtpci_device_probe(struct device *dev)
-{
- struct virtpci_dev *virtpcidev = device_to_virtpci_dev(dev);
- struct virtpci_driver *virtpcidrv =
- driver_to_virtpci_driver(dev->driver);
- const struct pci_device_id *id;
- int error = 0;
-
- POSTCODE_LINUX_2(VPCI_PROBE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
- /* static match and static probe vs dynamic match & dynamic
- * probe - do we care?.
- */
- if (!virtpcidrv->id_table)
- return -ENODEV;
-
- id = virtpci_match_device(virtpcidrv->id_table, virtpcidev);
- if (!id)
- return -ENODEV;
-
- /* increment reference count */
- get_device(dev);
-
- /* if virtpcidev is not already claimed & probe function is
- * valid, probe it
- */
- if (!virtpcidev->mydriver && virtpcidrv->probe) {
- /* call the probe function - virthba or virtnic probe
- * is what it should be
- */
- error = virtpcidrv->probe(virtpcidev, id);
- if (!error) {
- fix_vbus_dev_info(dev, virtpcidev->device_no,
- virtpcidev->device, virtpcidrv);
- virtpcidev->mydriver = virtpcidrv;
- POSTCODE_LINUX_2(VPCI_PROBE_EXIT_PC,
- POSTCODE_SEVERITY_INFO);
- } else {
- put_device(dev);
- }
- }
- POSTCODE_LINUX_2(VPCI_PROBE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- return error; /* -ENODEV for probe failure */
-}
-
-static int virtpci_device_remove(struct device *dev_)
-{
- /* dev_ passed in is the HBA device which we called
- * generic_dev in our virtpcidev struct
- */
- struct virtpci_dev *virtpcidev = device_to_virtpci_dev(dev_);
- struct virtpci_driver *virtpcidrv = virtpcidev->mydriver;
-
- if (virtpcidrv) {
- /* TEMP: assuming we have only one such driver for now */
- if (virtpcidrv->remove)
- virtpcidrv->remove(virtpcidev);
- virtpcidev->mydriver = NULL;
- }
-
- put_device(dev_);
- return 0;
-}
-
-/*****************************************************/
-/* Bus functions */
-/*****************************************************/
-
-static void virtpci_bus_release(struct device *dev)
-{
-}
-
-/*****************************************************/
-/* Adapter functions */
-/*****************************************************/
-
-/* scsi is expected to be NULL for VNIC add
- * net is expected to be NULL for VHBA add
- */
-static int virtpci_device_add(struct device *parentbus, int devtype,
- struct add_virt_guestpart *addparams,
- struct scsi_adap_info *scsi,
- struct net_adap_info *net)
-{
- struct virtpci_dev *virtpcidev = NULL;
- struct virtpci_dev *tmpvpcidev = NULL, *prev;
- unsigned long flags;
- int ret;
- struct spar_io_channel_protocol __iomem *io_chan = NULL;
- struct device *dev;
-
- POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-
- if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE)) {
- POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, devtype,
- POSTCODE_SEVERITY_ERR);
- return 0;
- }
-
- /* add a Virtual Device */
- virtpcidev = kzalloc(sizeof(*virtpcidev), GFP_ATOMIC);
- if (!virtpcidev) {
- POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- return 0;
- }
-
- /* initialize stuff unique to virtpci_dev struct */
- virtpcidev->devtype = devtype;
- if (devtype == VIRTHBA_TYPE) {
- virtpcidev->device = PCI_DEVICE_ID_VIRTHBA;
- virtpcidev->scsi = *scsi;
- } else {
- virtpcidev->device = PCI_DEVICE_ID_VIRTNIC;
- virtpcidev->net = *net;
- }
- virtpcidev->vendor = PCI_VENDOR_ID_UNISYS;
- virtpcidev->bus_no = addparams->bus_no;
- virtpcidev->device_no = addparams->device_no;
-
- virtpcidev->queueinfo.chan = addparams->chanptr;
- virtpcidev->queueinfo.send_int_if_needed = NULL;
-
- /* Set up safe queue... */
- io_chan = (struct spar_io_channel_protocol __iomem *)
- virtpcidev->queueinfo.chan;
-
- virtpcidev->intr = addparams->intr;
-
- /* initialize stuff in the device portion of the struct */
- virtpcidev->generic_dev.bus = &virtpci_bus_type;
- virtpcidev->generic_dev.parent = parentbus;
- virtpcidev->generic_dev.release = virtpci_device_release;
-
- dev_set_name(&virtpcidev->generic_dev, "%x:%x",
- addparams->bus_no, addparams->device_no);
-
- /* add the vhba/vnic to virtpci device list - but check for
- * duplicate wwnn/macaddr first
- */
- write_lock_irqsave(&vpcidev_list_lock, flags);
- for (tmpvpcidev = vpcidev_list_head; tmpvpcidev;
- tmpvpcidev = tmpvpcidev->next) {
- if (devtype == VIRTHBA_TYPE) {
- if ((tmpvpcidev->scsi.wwnn.wwnn1 == scsi->wwnn.wwnn1) &&
- (tmpvpcidev->scsi.wwnn.wwnn2 == scsi->wwnn.wwnn2)) {
- /* duplicate - already have vpcidev
- with this wwnn */
- break;
- }
- } else
- if (memcmp
- (tmpvpcidev->net.mac_addr, net->mac_addr,
- MAX_MACADDR_LEN) == 0) {
- /* duplicate - already have vnic with this wwnn */
- break;
- }
- }
- if (tmpvpcidev) {
- /* found a vhba/vnic already in the list with same
- * wwnn or macaddr - reject add
- */
- write_unlock_irqrestore(&vpcidev_list_lock, flags);
- kfree(virtpcidev);
- POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- return 0;
- }
-
- /* add it at the head */
- if (!vpcidev_list_head) {
- vpcidev_list_head = virtpcidev;
- } else {
- /* insert virtpcidev at the head of our linked list of
- * vpcidevs
- */
- virtpcidev->next = vpcidev_list_head;
- vpcidev_list_head = virtpcidev;
- }
-
- write_unlock_irqrestore(&vpcidev_list_lock, flags);
-
- /* Must transition channel to ATTACHED state BEFORE
- * registering the device, because polling of the channel
- * queues can begin at any time after device_register().
- */
- dev = &virtpcidev->generic_dev;
- SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr,
- BUS_ID(dev),
- CHANNELCLI_ATTACHED, NULL);
-
- /* don't register until device has been added to
- * list. Otherwise, a device_unregister from this function can
- * cause a "scheduling while atomic".
- */
- ret = device_register(&virtpcidev->generic_dev);
- /* NOTE: THIS IS CALLING HOTPLUG virtpci_hotplug!!!
- * This call to device_register results in virtpci_bus_match
- * being called !!!!! And, if match returns success, then
- * virtpcidev->generic_dev.driver is setup to core_driver,
- * i.e., virtpci and the probe function
- * virtpcidev->generic_dev.driver->probe is called which
- * results in virtpci_device_probe being called. And if
- * virtpci_device_probe is successful
- */
- if (ret) {
- dev = &virtpcidev->generic_dev;
- SPAR_CHANNEL_CLIENT_TRANSITION(addparams->chanptr,
- BUS_ID(dev),
- CHANNELCLI_DETACHED, NULL);
- /* remove virtpcidev, the one we just added, from the list */
- write_lock_irqsave(&vpcidev_list_lock, flags);
- for (tmpvpcidev = vpcidev_list_head, prev = NULL;
- tmpvpcidev;
- prev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) {
- if (tmpvpcidev == virtpcidev) {
- if (prev)
- prev->next = tmpvpcidev->next;
- else
- vpcidev_list_head = tmpvpcidev->next;
- break;
- }
- }
- write_unlock_irqrestore(&vpcidev_list_lock, flags);
- kfree(virtpcidev);
- return 0;
- }
-
- POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
- return 1;
-}
-
-static int virtpci_device_serverdown(struct device *parentbus,
- int devtype,
- struct vhba_wwnn *wwnn,
- unsigned char macaddr[])
-{
- int pausethisone = 0;
- bool found = false;
- struct virtpci_dev *tmpvpcidev, *prevvpcidev;
- struct virtpci_driver *vpcidriver;
- unsigned long flags;
- int rc = 0;
-
- if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE))
- return 0;
-
- /* find the vhba or vnic in virtpci device list */
- write_lock_irqsave(&vpcidev_list_lock, flags);
-
- for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL;
- (tmpvpcidev && !found);
- prevvpcidev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) {
- if (tmpvpcidev->devtype != devtype)
- continue;
-
- if (devtype == VIRTHBA_TYPE) {
- pausethisone =
- ((tmpvpcidev->scsi.wwnn.wwnn1 == wwnn->wwnn1) &&
- (tmpvpcidev->scsi.wwnn.wwnn2 == wwnn->wwnn2));
- /* devtype is vhba, we're pausing vhba whose
- * wwnn matches the current device's wwnn
- */
- } else { /* VIRTNIC_TYPE */
- pausethisone =
- memcmp(tmpvpcidev->net.mac_addr, macaddr,
- MAX_MACADDR_LEN) == 0;
- /* devtype is vnic, we're pausing vnic whose
- * macaddr matches the current device's macaddr */
- }
-
- if (!pausethisone)
- continue;
-
- found = true;
- vpcidriver = tmpvpcidev->mydriver;
- rc = vpcidriver->suspend(tmpvpcidev, 0);
- }
- write_unlock_irqrestore(&vpcidev_list_lock, flags);
-
- if (!found)
- return 0;
-
- return rc;
-}
-
-static int virtpci_device_serverup(struct device *parentbus,
- int devtype,
- struct vhba_wwnn *wwnn,
- unsigned char macaddr[])
-{
- int resumethisone = 0;
- bool found = false;
- struct virtpci_dev *tmpvpcidev, *prevvpcidev;
- struct virtpci_driver *vpcidriver;
- unsigned long flags;
- int rc = 0;
-
- if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE))
- return 0;
-
-
- /* find the vhba or vnic in virtpci device list */
- write_lock_irqsave(&vpcidev_list_lock, flags);
-
- for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL;
- (tmpvpcidev && !found);
- prevvpcidev = tmpvpcidev, tmpvpcidev = tmpvpcidev->next) {
- if (tmpvpcidev->devtype != devtype)
- continue;
-
- if (devtype == VIRTHBA_TYPE) {
- resumethisone =
- ((tmpvpcidev->scsi.wwnn.wwnn1 == wwnn->wwnn1) &&
- (tmpvpcidev->scsi.wwnn.wwnn2 == wwnn->wwnn2));
- /* devtype is vhba, we're resuming vhba whose
- * wwnn matches the current device's wwnn */
- } else { /* VIRTNIC_TYPE */
- resumethisone =
- memcmp(tmpvpcidev->net.mac_addr, macaddr,
- MAX_MACADDR_LEN) == 0;
- /* devtype is vnic, we're resuming vnic whose
- * macaddr matches the current device's macaddr */
- }
-
- if (!resumethisone)
- continue;
-
- found = true;
- vpcidriver = tmpvpcidev->mydriver;
- /* This should be done at BUS resume time, but an
- * existing problem prevents us from ever getting a bus
- * resume... This hack would fail to work should we
- * ever have a bus that contains NO devices, since we
- * would never even get here in that case.
- */
- fix_vbus_dev_info(&tmpvpcidev->generic_dev,
- tmpvpcidev->device_no,
- tmpvpcidev->device, vpcidriver);
- rc = vpcidriver->resume(tmpvpcidev);
- }
-
- write_unlock_irqrestore(&vpcidev_list_lock, flags);
-
- if (!found)
- return 0;
-
- return rc;
-}
-
-static int virtpci_device_del(struct device *parentbus,
- int devtype, struct vhba_wwnn *wwnn,
- unsigned char macaddr[])
-{
- int count = 0, all = 0, delthisone;
- struct virtpci_dev *tmpvpcidev, *prevvpcidev, *dellist = NULL;
- unsigned long flags;
-
-#define DEL_CONTINUE { \
- prevvpcidev = tmpvpcidev;\
- tmpvpcidev = tmpvpcidev->next;\
- continue; \
-}
-
- if ((devtype != VIRTHBA_TYPE) && (devtype != VIRTNIC_TYPE))
- return 0;
-
- /* see if we are to delete all - NOTE: all implies we have a
- * valid parentbus
- */
- all = ((devtype == VIRTHBA_TYPE) && (!wwnn)) ||
- ((devtype == VIRTNIC_TYPE) && (!macaddr));
-
- /* find all the vhba or vnic or both in virtpci device list
- * keep list of ones we are deleting so we can call
- * device_unregister after we release the lock; otherwise we
- * encounter "schedule while atomic"
- */
- write_lock_irqsave(&vpcidev_list_lock, flags);
- for (tmpvpcidev = vpcidev_list_head, prevvpcidev = NULL; tmpvpcidev;) {
- if (tmpvpcidev->devtype != devtype)
- DEL_CONTINUE;
-
- if (all) {
- delthisone =
- (tmpvpcidev->generic_dev.parent == parentbus);
- /* we're deleting all vhbas or vnics on the
- * specified parent bus
- */
- } else if (devtype == VIRTHBA_TYPE) {
- delthisone =
- ((tmpvpcidev->scsi.wwnn.wwnn1 == wwnn->wwnn1) &&
- (tmpvpcidev->scsi.wwnn.wwnn2 == wwnn->wwnn2));
- /* devtype is vhba, we're deleting vhba whose
- * wwnn matches the current device's wwnn
- */
- } else { /* VIRTNIC_TYPE */
- delthisone =
- memcmp(tmpvpcidev->net.mac_addr, macaddr,
- MAX_MACADDR_LEN) == 0;
- /* devtype is vnic, we're deleting vnic whose
- * macaddr matches the current device's macaddr
- */
- }
-
- if (!delthisone)
- DEL_CONTINUE;
-
- /* take vhba/vnic out of the list */
- if (prevvpcidev)
- /* not at head */
- prevvpcidev->next = tmpvpcidev->next;
- else
- vpcidev_list_head = tmpvpcidev->next;
-
- /* add it to our deletelist */
- tmpvpcidev->next = dellist;
- dellist = tmpvpcidev;
-
- count++;
- if (!all)
- break; /* done */
- /* going to top of loop again - set tmpvpcidev to next
- * one we're to process
- */
- if (prevvpcidev)
- tmpvpcidev = prevvpcidev->next;
- else
- tmpvpcidev = vpcidev_list_head;
- }
- write_unlock_irqrestore(&vpcidev_list_lock, flags);
-
- if (!all && (count == 0))
- return 0;
-
- /* now delete each one from delete list */
- while (dellist) {
- /* save next */
- tmpvpcidev = dellist->next;
- /* delete the vhba/vnic at dellist */
- DELETE_ONE_VPCIDEV(dellist);
- /* do next */
- dellist = tmpvpcidev;
- }
-
- return count;
-}
-
-static void virtpci_device_release(struct device *dev_)
-{
- /* this function is called when the last reference to the
- * device is removed
- */
-}
-
-/*****************************************************/
-/* Driver functions */
-/*****************************************************/
-
-#define kobj_to_device_driver(obj) container_of(obj, struct device_driver, kobj)
-#define attribute_to_driver_attribute(obj) \
- container_of(obj, struct driver_attribute, attr)
-
-static ssize_t virtpci_driver_attr_show(struct kobject *kobj,
- struct attribute *attr,
- char *buf)
-{
- struct driver_attribute *dattr = attribute_to_driver_attribute(attr);
- ssize_t ret = 0;
-
- struct driver_private *dprivate = to_driver(kobj);
- struct device_driver *driver = dprivate->driver;
-
- if (dattr->show)
- ret = dattr->show(driver, buf);
-
- return ret;
-}
-
-static ssize_t virtpci_driver_attr_store(struct kobject *kobj,
- struct attribute *attr,
- const char *buf, size_t count)
-{
- struct driver_attribute *dattr = attribute_to_driver_attribute(attr);
- ssize_t ret = 0;
-
- struct driver_private *dprivate = to_driver(kobj);
- struct device_driver *driver = dprivate->driver;
-
- if (dattr->store)
- ret = dattr->store(driver, buf, count);
-
- return ret;
-}
-
-/* register a new virtpci driver */
-int virtpci_register_driver(struct virtpci_driver *drv)
-{
- int result = 0;
-
- if (!drv->id_table)
- return 1;
- /* initialize core driver fields needed to call driver_register */
- drv->core_driver.name = drv->name; /* name of driver in sysfs */
- drv->core_driver.bus = &virtpci_bus_type; /* type of bus this
- * driver works with */
- drv->core_driver.probe = virtpci_device_probe; /* called to query the
- * existence of a
- * specific device and
- * whether this driver
- *can work with it */
- drv->core_driver.remove = virtpci_device_remove; /* called when the
- * device is removed
- * from the system */
- /* register with core */
- result = driver_register(&drv->core_driver);
- /* calls bus_add_driver which calls driver_attach and
- * module_add_driver
- */
- if (result)
- return result; /* failed */
-
- drv->core_driver.p->kobj.ktype = &virtpci_driver_kobj_type;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(virtpci_register_driver);
-
-void virtpci_unregister_driver(struct virtpci_driver *drv)
-{
- driver_unregister(&drv->core_driver);
- /* driver_unregister calls bus_remove_driver
- * bus_remove_driver calls device_detach
- * device_detach calls device_release_driver for each of the
- * driver's devices
- * device_release driver calls drv->remove which is
- * virtpci_device_remove
- * virtpci_device_remove calls virthba_remove
- */
-}
-EXPORT_SYMBOL_GPL(virtpci_unregister_driver);
-
-/*****************************************************/
-/* debugfs filesystem functions */
-/*****************************************************/
-struct print_vbus_info {
- int *str_pos;
- char *buf;
- size_t *len;
-};
-
-static int print_vbus(struct device *vbus, void *data)
-{
- struct print_vbus_info *p = (struct print_vbus_info *)data;
-
- *p->str_pos += scnprintf(p->buf + *p->str_pos, *p->len - *p->str_pos,
- "bus_id:%s\n", dev_name(vbus));
- return 0;
-}
-
-static ssize_t info_debugfs_read(struct file *file, char __user *buf,
- size_t len, loff_t *offset)
-{
- ssize_t bytes_read = 0;
- int str_pos = 0;
- struct virtpci_dev *tmpvpcidev;
- unsigned long flags;
- struct print_vbus_info printparam;
- char *vbuf;
-
- if (len > MAX_BUF)
- len = MAX_BUF;
- vbuf = kzalloc(len, GFP_KERNEL);
- if (!vbuf)
- return -ENOMEM;
-
- str_pos += scnprintf(vbuf + str_pos, len - str_pos,
- " Virtual PCI Bus devices\n");
- printparam.str_pos = &str_pos;
- printparam.buf = vbuf;
- printparam.len = &len;
- bus_for_each_dev(&virtpci_bus_type, NULL, (void *)&printparam,
- print_vbus);
-
- str_pos += scnprintf(vbuf + str_pos, len - str_pos,
- "\n Virtual PCI devices\n");
- read_lock_irqsave(&vpcidev_list_lock, flags);
- tmpvpcidev = vpcidev_list_head;
- while (tmpvpcidev) {
- if (tmpvpcidev->devtype == VIRTHBA_TYPE) {
- str_pos += scnprintf(vbuf + str_pos, len - str_pos,
- "[%d:%d] VHba:%08x:%08x max-config:%d-%d-%d-%d",
- tmpvpcidev->bus_no,
- tmpvpcidev->device_no,
- tmpvpcidev->scsi.wwnn.wwnn1,
- tmpvpcidev->scsi.wwnn.wwnn2,
- tmpvpcidev->scsi.max.max_channel,
- tmpvpcidev->scsi.max.max_id,
- tmpvpcidev->scsi.max.max_lun,
- tmpvpcidev->scsi.max.cmd_per_lun);
- } else {
- str_pos += scnprintf(vbuf + str_pos, len - str_pos,
- "[%d:%d] VNic:%pM num_rcv_bufs:%d mtu:%d",
- tmpvpcidev->bus_no,
- tmpvpcidev->device_no,
- tmpvpcidev->net.mac_addr,
- tmpvpcidev->net.num_rcv_bufs,
- tmpvpcidev->net.mtu);
- }
- str_pos += scnprintf(vbuf + str_pos,
- len - str_pos, " chanptr:%p\n",
- tmpvpcidev->queueinfo.chan);
- tmpvpcidev = tmpvpcidev->next;
- }
- read_unlock_irqrestore(&vpcidev_list_lock, flags);
-
- str_pos += scnprintf(vbuf + str_pos, len - str_pos, "\n");
- bytes_read = simple_read_from_buffer(buf, len, offset, vbuf, str_pos);
- kfree(vbuf);
- return bytes_read;
-}
-
-/*****************************************************/
-/* Module Init & Exit functions */
-/*****************************************************/
-
-static int __init virtpci_mod_init(void)
-{
- int ret;
-
- if (!unisys_spar_platform)
- return -ENODEV;
-
- POSTCODE_LINUX_2(VPCI_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
-
- ret = bus_register(&virtpci_bus_type);
- /* creates /sys/bus/uisvirtpci which contains devices &
- * drivers directory
- */
- if (ret) {
- POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, ret,
- POSTCODE_SEVERITY_ERR);
- return ret;
- }
- bus_device_info_init(&bus_driver_info, "clientbus", "virtpci",
- VERSION, NULL);
-
- /* create a root bus used to parent all the virtpci buses. */
- ret = device_register(&virtpci_rootbus_device);
- if (ret) {
- bus_unregister(&virtpci_bus_type);
- POSTCODE_LINUX_3(VPCI_CREATE_FAILURE_PC, ret,
- POSTCODE_SEVERITY_ERR);
- return ret;
- }
-
- if (!uisctrl_register_req_handler(2, (void *)&virtpci_ctrlchan_func,
- &chipset_driver_info)) {
- POSTCODE_LINUX_2(VPCI_CREATE_FAILURE_PC, POSTCODE_SEVERITY_ERR);
- device_unregister(&virtpci_rootbus_device);
- bus_unregister(&virtpci_bus_type);
- return -1;
- }
-
- /* create debugfs directory and info file inside. */
- virtpci_debugfs_dir = debugfs_create_dir("virtpci", NULL);
- debugfs_create_file("info", S_IRUSR, virtpci_debugfs_dir,
- NULL, &debugfs_info_fops);
- POSTCODE_LINUX_2(VPCI_CREATE_EXIT_PC, POSTCODE_SEVERITY_INFO);
- return 0;
-}
-
-static void __exit virtpci_mod_exit(void)
-{
- /* unregister the callback function */
- device_unregister(&virtpci_rootbus_device);
- bus_unregister(&virtpci_bus_type);
- debugfs_remove_recursive(virtpci_debugfs_dir);
-}
-
-module_init(virtpci_mod_init);
-module_exit(virtpci_mod_exit);
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Usha Srinivasan");
-MODULE_ALIAS("uisvirtpci");
-
diff --git a/drivers/staging/unisys/virtpci/virtpci.h b/drivers/staging/unisys/virtpci/virtpci.h
deleted file mode 100644
index 9d85f55e81696f..00000000000000
--- a/drivers/staging/unisys/virtpci/virtpci.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* virtpci.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/*
- * Unisys Virtual PCI driver header
- */
-
-#ifndef __VIRTPCI_H__
-#define __VIRTPCI_H__
-
-#include "uisqueue.h"
-#include <linux/version.h>
-#include <linux/uuid.h>
-
-#define PCI_DEVICE_ID_VIRTHBA 0xAA00
-#define PCI_DEVICE_ID_VIRTNIC 0xAB00
-
-struct scsi_adap_info {
- void *scsihost; /* scsi host if this device is a scsi hba */
- struct vhba_wwnn wwnn; /* the world wide node name of vhba */
- struct vhba_config_max max; /* various max specifications used
- * to config vhba */
-};
-
-struct net_adap_info {
- struct net_device *netdev; /* network device if this
- * device is a NIC */
- u8 mac_addr[MAX_MACADDR_LEN];
- int num_rcv_bufs;
- unsigned mtu;
- uuid_le zone_uuid;
-};
-
-enum virtpci_dev_type {
- VIRTHBA_TYPE = 0,
- VIRTNIC_TYPE = 1,
- VIRTBUS_TYPE = 6,
-};
-
-struct virtpci_dev {
- enum virtpci_dev_type devtype; /* indicates type of the
- * virtual pci device */
- struct virtpci_driver *mydriver; /* which driver has allocated
- * this device */
- unsigned short vendor; /* vendor id for device */
- unsigned short device; /* device id for device */
- u32 bus_no; /* number of bus on which device exists */
- u32 device_no; /* device's number on the bus */
- struct irq_info intr; /* interrupt info */
- struct device generic_dev; /* generic device */
- union {
- struct scsi_adap_info scsi;
- struct net_adap_info net;
- };
-
- struct uisqueue_info queueinfo; /* holds ptr to channel where cmds &
- * rsps are queued & retrieved */
- struct virtpci_dev *next; /* points to next virtpci device */
-};
-
-struct virtpci_driver {
- struct list_head node;
- const char *name; /* the name of the driver in sysfs */
- const char *version;
- const char *vertag;
- const struct pci_device_id *id_table; /* must be non-NULL for probe
- * to be called */
- int (*probe)(struct virtpci_dev *dev,
- const struct pci_device_id *id); /* device inserted */
- void (*remove)(struct virtpci_dev *dev); /* Device removed (NULL if
- * not a hot-plug capable
- * driver) */
- int (*suspend)(struct virtpci_dev *dev,
- u32 state); /* Device suspended */
- int (*resume)(struct virtpci_dev *dev); /* Device woken up */
- int (*enable_wake)(struct virtpci_dev *dev,
- u32 state, int enable); /* Enable wake event */
- struct device_driver core_driver; /* VIRTPCI core fills this in */
-};
-
-#define driver_to_virtpci_driver(in_drv) \
- container_of(in_drv, struct virtpci_driver, core_driver)
-#define device_to_virtpci_dev(in_dev) \
- container_of(in_dev, struct virtpci_dev, generic_dev)
-
-int virtpci_register_driver(struct virtpci_driver *);
-void virtpci_unregister_driver(struct virtpci_driver *);
-
-#endif /* __VIRTPCI_H__ */
diff --git a/drivers/staging/unisys/visorbus/Kconfig b/drivers/staging/unisys/visorbus/Kconfig
new file mode 100644
index 00000000000000..9b299ac86015e9
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/Kconfig
@@ -0,0 +1,9 @@
+#
+# Unisys visorbus configuration
+#
+
+config UNISYS_VISORBUS
+ tristate "Unisys visorbus driver"
+ depends on UNISYSSPAR
+ ---help---
+ If you say Y here, you will enable the Unisys visorbus driver.
diff --git a/drivers/staging/unisys/visorbus/Makefile b/drivers/staging/unisys/visorbus/Makefile
new file mode 100644
index 00000000000000..fa27ee5f336cbe
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/Makefile
@@ -0,0 +1,13 @@
+#
+# Makefile for Unisys visorbus
+#
+
+obj-$(CONFIG_UNISYS_VISORBUS) += visorbus.o
+
+visorbus-y := visorbus_main.o
+visorbus-y += visorchannel.o
+visorbus-y += visorchipset.o
+visorbus-y += periodic_work.o
+
+ccflags-y += -Idrivers/staging/unisys/include
+ccflags-y += -Idrivers/staging/unisys/visorutil
diff --git a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h b/drivers/staging/unisys/visorbus/controlvmchannel.h
index a66db7968d6cfe..a50d9cf4bed740 100644
--- a/drivers/staging/unisys/common-spar/include/channels/controlvmchannel.h
+++ b/drivers/staging/unisys/visorbus/controlvmchannel.h
@@ -18,59 +18,75 @@
#include <linux/uuid.h>
#include "channel.h"
-#include "controlframework.h"
-
-typedef u64 GUEST_PHYSICAL_ADDRESS;
-
-enum { INVALID_GUEST_FIRMWARE, SAMPLE_GUEST_FIRMWARE,
- TIANO32_GUEST_FIRMWARE, TIANO64_GUEST_FIRMWARE
-};
/* {2B3C2D10-7EF5-4ad8-B966-3448B7386B3D} */
#define SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID \
UUID_LE(0x2b3c2d10, 0x7ef5, 0x4ad8, \
- 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
-
-static const uuid_le spar_controlvm_channel_protocol_uuid =
- SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
+ 0xb9, 0x66, 0x34, 0x48, 0xb7, 0x38, 0x6b, 0x3d)
#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE \
ULTRA_CHANNEL_PROTOCOL_SIGNATURE
-#define CONTROLVM_MESSAGE_MAX 64
+#define CONTROLVM_MESSAGE_MAX 64
/* Must increment this whenever you insert or delete fields within
-* this channel struct. Also increment whenever you change the meaning
-* of fields within this channel struct so as to break pre-existing
-* software. Note that you can usually add fields to the END of the
-* channel struct withOUT needing to increment this. */
+ * this channel struct. Also increment whenever you change the meaning
+ * of fields within this channel struct so as to break pre-existing
+ * software. Note that you can usually add fields to the END of the
+ * channel struct withOUT needing to increment this.
+ */
#define ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID 1
#define SPAR_CONTROLVM_CHANNEL_OK_CLIENT(ch) \
spar_check_channel_client(ch, \
- spar_controlvm_channel_protocol_uuid, \
+ SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID, \
"controlvm", \
sizeof(struct spar_controlvm_channel_protocol), \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_VERSIONID, \
ULTRA_CONTROLVM_CHANNEL_PROTOCOL_SIGNATURE)
-#define MY_DEVICE_INDEX 0
-#define MAX_MACDATA_LEN 8 /* number of bytes for MAC address in config packet */
#define MAX_SERIAL_NUM 32
-#define DISK_ZERO_PUN_NUMBER 1 /* Target ID on the SCSI bus for LUN 0 */
-#define DISK_ZERO_LUN_NUMBER 3 /* Logical Unit Number */
-
-/* Defines for various channel queues... */
+/* Defines for various channel queues */
#define CONTROLVM_QUEUE_REQUEST 0
#define CONTROLVM_QUEUE_RESPONSE 1
-#define CONTROLVM_QUEUE_EVENT 2
+#define CONTROLVM_QUEUE_EVENT 2
#define CONTROLVM_QUEUE_ACK 3
-/* Max number of messages stored during IOVM creation to be reused
- * after crash */
+/* Max num of messages stored during IOVM creation to be reused after crash */
#define CONTROLVM_CRASHMSG_MAX 2
-/** Ids for commands that may appear in either queue of a ControlVm channel.
+struct spar_segment_state {
+ u16 enabled:1; /* Bit 0: May enter other states */
+ u16 active:1; /* Bit 1: Assigned to active partition */
+ u16 alive:1; /* Bit 2: Configure message sent to
+ * service/server */
+ u16 revoked:1; /* Bit 3: similar to partition state
+ * ShuttingDown */
+ u16 allocated:1; /* Bit 4: memory (device/port number)
+ * has been selected by Command */
+ u16 known:1; /* Bit 5: has been introduced to the
+ * service/guest partition */
+ u16 ready:1; /* Bit 6: service/Guest partition has
+ * responded to introduction */
+ u16 operating:1; /* Bit 7: resource is configured and
+ * operating */
+ /* Note: don't use high bit unless we need to switch to ushort
+ * which is non-compliant */
+};
+
+static const struct spar_segment_state segment_state_running = {
+ 1, 1, 1, 0, 1, 1, 1, 1
+};
+
+static const struct spar_segment_state segment_state_paused = {
+ 1, 1, 1, 0, 1, 1, 1, 0
+};
+
+static const struct spar_segment_state segment_state_standby = {
+ 1, 1, 0, 0, 1, 1, 1, 0
+};
+
+/* Ids for commands that may appear in either queue of a ControlVm channel.
*
* Commands that are initiated by the command partition (CP), by an IO or
* console service partition (SP), or by a guest partition (GP)are:
@@ -84,60 +100,49 @@ static const uuid_le spar_controlvm_channel_protocol_uuid =
*/
enum controlvm_id {
CONTROLVM_INVALID = 0,
- /* SWITCH commands required Parameter: SwitchNumber */
- /* BUS commands required Parameter: BusNumber */
- CONTROLVM_BUS_CREATE = 0x101, /* CP --> SP, GP */
- CONTROLVM_BUS_DESTROY = 0x102, /* CP --> SP, GP */
- CONTROLVM_BUS_CONFIGURE = 0x104, /* CP --> SP */
- CONTROLVM_BUS_CHANGESTATE = 0x105, /* CP --> SP, GP */
- CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106, /* SP, GP --> CP */
-/* DEVICE commands required Parameter: BusNumber, DeviceNumber */
-
- CONTROLVM_DEVICE_CREATE = 0x201, /* CP --> SP, GP */
- CONTROLVM_DEVICE_DESTROY = 0x202, /* CP --> SP, GP */
- CONTROLVM_DEVICE_CONFIGURE = 0x203, /* CP --> SP */
- CONTROLVM_DEVICE_CHANGESTATE = 0x204, /* CP --> SP, GP */
- CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */
- CONTROLVM_DEVICE_RECONFIGURE = 0x206, /* CP --> Boot */
-/* DISK commands required Parameter: BusNumber, DeviceNumber */
- CONTROLVM_DISK_CREATE = 0x221, /* CP --> SP */
- CONTROLVM_DISK_DESTROY = 0x222, /* CP --> SP */
- CONTROLVM_DISK_CONFIGURE = 0x223, /* CP --> SP */
- CONTROLVM_DISK_CHANGESTATE = 0x224, /* CP --> SP */
+ /* SWITCH commands required Parameter: SwitchNumber */
+ /* BUS commands required Parameter: BusNumber */
+ CONTROLVM_BUS_CREATE = 0x101, /* CP --> SP, GP */
+ CONTROLVM_BUS_DESTROY = 0x102, /* CP --> SP, GP */
+ CONTROLVM_BUS_CONFIGURE = 0x104, /* CP --> SP */
+ CONTROLVM_BUS_CHANGESTATE = 0x105, /* CP --> SP, GP */
+ CONTROLVM_BUS_CHANGESTATE_EVENT = 0x106, /* SP, GP --> CP */
+/* DEVICE commands required Parameter: BusNumber, DeviceNumber */
+
+ CONTROLVM_DEVICE_CREATE = 0x201, /* CP --> SP, GP */
+ CONTROLVM_DEVICE_DESTROY = 0x202, /* CP --> SP, GP */
+ CONTROLVM_DEVICE_CONFIGURE = 0x203, /* CP --> SP */
+ CONTROLVM_DEVICE_CHANGESTATE = 0x204, /* CP --> SP, GP */
+ CONTROLVM_DEVICE_CHANGESTATE_EVENT = 0x205, /* SP, GP --> CP */
+ CONTROLVM_DEVICE_RECONFIGURE = 0x206, /* CP --> Boot */
/* CHIPSET commands */
- CONTROLVM_CHIPSET_INIT = 0x301, /* CP --> SP, GP */
- CONTROLVM_CHIPSET_STOP = 0x302, /* CP --> SP, GP */
- CONTROLVM_CHIPSET_SHUTDOWN = 0x303, /* CP --> SP */
- CONTROLVM_CHIPSET_READY = 0x304, /* CP --> SP */
- CONTROLVM_CHIPSET_SELFTEST = 0x305, /* CP --> SP */
+ CONTROLVM_CHIPSET_INIT = 0x301, /* CP --> SP, GP */
+ CONTROLVM_CHIPSET_STOP = 0x302, /* CP --> SP, GP */
+ CONTROLVM_CHIPSET_READY = 0x304, /* CP --> SP */
+ CONTROLVM_CHIPSET_SELFTEST = 0x305, /* CP --> SP */
};
struct irq_info {
- /**< specifies interrupt info. It is used to send interrupts
- * for this channel. The peer at the end of this channel
- * who has registered an interrupt (using recv fields
- * above) will receive the interrupt. Passed as a parameter
- * to Issue_VMCALL_IO_QUEUE_TRANSITION, which generates the
- * interrupt. Currently this is used by IOPart-SP to wake
- * up GP when Data Channel transitions from empty to
- * non-empty.*/
- u64 send_irq_handle;
-
- /**< specifies interrupt handle. It is used to retrieve the
+ u64 reserved1;
+
+ /* specifies interrupt handle. It is used to retrieve the
* corresponding interrupt pin from Monitor; and the
* interrupt pin is used to connect to the corresponding
- * interrupt. Used by IOPart-GP only. */
+ * interrupt. Used by IOPart-GP only.
+ */
u64 recv_irq_handle;
- /**< specifies interrupt vector. It, interrupt pin, and shared are
+ /* specifies interrupt vector. It, interrupt pin, and shared are
* used to connect to the corresponding interrupt. Used by
- * IOPart-GP only. */
+ * IOPart-GP only.
+ */
u32 recv_irq_vector;
- /**< specifies if the recvInterrupt is shared. It, interrupt pin
- * and vector are used to connect to 0 = not shared; 1 = shared.
- * the corresponding interrupt. Used by IOPart-GP only. */
+ /* specifies if the recvInterrupt is shared. It, interrupt pin
+ * and vector are used to connect to 0 = not shared; 1 = shared.
+ * the corresponding interrupt. Used by IOPart-GP only.
+ */
u8 recv_irq_shared;
u8 reserved[3]; /* Natural alignment purposes */
};
@@ -151,20 +156,19 @@ struct pci_id {
};
struct efi_spar_indication {
- u64 boot_to_fw_ui:1; /* Bit 0: Stop in uefi ui */
- u64 clear_nvram:1; /* Bit 1: Clear NVRAM */
- u64 clear_cmos:1; /* Bit 2: Clear CMOS */
- u64 boot_to_tool:1; /* Bit 3: Run install tool */
+ u64 boot_to_fw_ui:1; /* Bit 0: Stop in uefi ui */
+ u64 clear_nvram:1; /* Bit 1: Clear NVRAM */
+ u64 clear_cmos:1; /* Bit 2: Clear CMOS */
+ u64 boot_to_tool:1; /* Bit 3: Run install tool */
/* remaining bits are available */
};
enum ultra_chipset_feature {
ULTRA_CHIPSET_FEATURE_REPLY = 0x00000001,
ULTRA_CHIPSET_FEATURE_PARA_HOTPLUG = 0x00000002,
- ULTRA_CHIPSET_FEATURE_PCIVBUS = 0x00000004
};
-/** This is the common structure that is at the beginning of every
+/* This is the common structure that is at the beginning of every
* ControlVm message (both commands and responses) in any ControlVm
* queue. Commands are easily distinguished from responses by
* looking at the flags.response field.
@@ -181,26 +185,26 @@ struct controlvm_message_header {
u32 completion_status; /* Error status code or result of
* message completion */
struct {
- u32 failed:1; /**< =1 in a response to * signify
+ u32 failed:1; /* =1 in a response to * signify
* failure */
- u32 response_expected:1; /**< =1 in all messages that expect a
- * response (Control ignores this
- * bit) */
- u32 server:1; /**< =1 in all bus & device-related
+ u32 response_expected:1; /* =1 in all messages that expect a
+ * response (Control ignores this
+ * bit) */
+ u32 server:1; /* =1 in all bus & device-related
* messages where the message
* receiver is to act as the bus or
* device server */
- u32 test_message:1; /**< =1 for testing use only
+ u32 test_message:1; /* =1 for testing use only
* (Control and Command ignore this
* bit) */
- u32 partial_completion:1; /**< =1 if there are forthcoming
- * responses/acks associated
- * with this message */
- u32 preserve:1; /**< =1 this is to let us know to
- * preserve channel contents
- * (for running guests)*/
- u32 writer_in_diag:1; /**< =1 the DiagWriter is active in the
- * Diagnostic Partition*/
+ u32 partial_completion:1; /* =1 if there are forthcoming
+ * responses/acks associated
+ * with this message */
+ u32 preserve:1; /* =1 this is to let us know to
+ * preserve channel contents
+ * (for running guests)*/
+ u32 writer_in_diag:1; /* =1 the DiagWriter is active in the
+ * Diagnostic Partition*/
} flags;
u32 reserved; /* Natural alignment */
u64 message_handle; /* Identifies the particular message instance,
@@ -216,8 +220,8 @@ struct controlvm_message_header {
};
struct controlvm_packet_device_create {
- u32 bus_no; /* bus # (0..n-1) from the msg receiver's end */
- u32 dev_no; /* bus-relative (0..n-1) device number */
+ u32 bus_no; /* bus # (0..n-1) from the msg receiver's end */
+ u32 dev_no; /* bus-relative (0..n-1) device number */
u64 channel_addr; /* Guest physical address of the channel, which
* can be dereferenced by the receiver of this
* ControlVm command */
@@ -228,11 +232,10 @@ struct controlvm_packet_device_create {
}; /* for CONTROLVM_DEVICE_CREATE */
struct controlvm_packet_device_configure {
- u32 bus_no; /**< bus # (0..n-1) from the msg
+ u32 bus_no; /* bus # (0..n-1) from the msg
* receiver's perspective */
-
- /* Control uses header SegmentIndex field to access bus number... */
- u32 dev_no; /**< bus-relative (0..n-1) device number */
+ /* Control uses header SegmentIndex field to access bus number... */
+ u32 dev_no; /* bus-relative (0..n-1) device number */
} ; /* for CONTROLVM_DEVICE_CONFIGURE */
struct controlvm_message_device_create {
@@ -342,77 +345,48 @@ struct controlvm_message {
struct controlvm_message_packet cmd;
};
-struct device_map {
- GUEST_PHYSICAL_ADDRESS device_channel_address;
- u64 device_channel_size;
- u32 ca_index;
- u32 reserved; /* natural alignment */
- u64 reserved2; /* Align structure on 32-byte boundary */
-};
-
-struct guest_devices {
- struct device_map video_channel;
- struct device_map keyboard_channel;
- struct device_map network_channel;
- struct device_map storage_channel;
- struct device_map console_channel;
- u32 partition_index;
- u32 pad;
-};
-
struct spar_controlvm_channel_protocol {
- struct channel_header header;
- GUEST_PHYSICAL_ADDRESS gp_controlvm; /* guest physical address of
- * this channel */
- GUEST_PHYSICAL_ADDRESS gp_partition_tables;/* guest physical address of
- * partition tables */
- GUEST_PHYSICAL_ADDRESS gp_diag_guest; /* guest physical address of
- * diagnostic channel */
- GUEST_PHYSICAL_ADDRESS gp_boot_romdisk;/* guest phys addr of (read
- * only) Boot ROM disk */
- GUEST_PHYSICAL_ADDRESS gp_boot_ramdisk;/* guest phys addr of writable
- * Boot RAM disk */
- GUEST_PHYSICAL_ADDRESS gp_acpi_table; /* guest phys addr of acpi
- * table */
- GUEST_PHYSICAL_ADDRESS gp_control_channel;/* guest phys addr of control
- * channel */
- GUEST_PHYSICAL_ADDRESS gp_diag_romdisk;/* guest phys addr of diagnostic
- * ROM disk */
- GUEST_PHYSICAL_ADDRESS gp_nvram; /* guest phys addr of NVRAM
- * channel */
- u64 request_payload_offset; /* Offset to request payload area */
- u64 event_payload_offset; /* Offset to event payload area */
- u32 request_payload_bytes; /* Bytes available in request payload
+ struct channel_header header;
+ u64 gp_controlvm; /* guest phys addr of this channel */
+ u64 gp_partition_tables;/* guest phys addr of partition tables */
+ u64 gp_diag_guest; /* guest phys addr of diagnostic channel */
+ u64 gp_boot_romdisk;/* guest phys addr of (read* only) Boot ROM disk */
+ u64 gp_boot_ramdisk;/* guest phys addr of writable Boot RAM disk */
+ u64 gp_acpi_table; /* guest phys addr of acpi table */
+ u64 gp_control_channel;/* guest phys addr of control channel */
+ u64 gp_diag_romdisk;/* guest phys addr of diagnostic ROM disk */
+ u64 gp_nvram; /* guest phys addr of NVRAM channel */
+ u64 request_payload_offset; /* Offset to request payload area */
+ u64 event_payload_offset; /* Offset to event payload area */
+ u32 request_payload_bytes; /* Bytes available in request payload
* area */
- u32 event_payload_bytes;/* Bytes available in event payload area */
- u32 control_channel_bytes;
- u32 nvram_channel_bytes; /* Bytes in PartitionNvram segment */
- u32 message_bytes; /* sizeof(CONTROLVM_MESSAGE) */
- u32 message_count; /* CONTROLVM_MESSAGE_MAX */
- GUEST_PHYSICAL_ADDRESS gp_smbios_table;/* guest phys addr of SMBIOS
- * tables */
- GUEST_PHYSICAL_ADDRESS gp_physical_smbios_table;/* guest phys addr of
- * SMBIOS table */
- /* ULTRA_MAX_GUESTS_PER_SERVICE */
- struct guest_devices gp_obsolete_guest_devices[16];
-
- /* guest physical address of EFI firmware image base */
- GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_image_base;
-
- /* guest physical address of EFI firmware entry point */
- GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_entry_point;
-
- /* guest EFI firmware image size */
- u64 virtual_guest_firmware_image_size;
-
- /* GPA = 1MB where EFI firmware image is copied to */
- GUEST_PHYSICAL_ADDRESS virtual_guest_firmware_boot_base;
- GUEST_PHYSICAL_ADDRESS virtual_guest_image_base;
- GUEST_PHYSICAL_ADDRESS virtual_guest_image_size;
- u64 prototype_control_channel_offset;
- GUEST_PHYSICAL_ADDRESS virtual_guest_partition_handle;
-
- u16 restore_action; /* Restore Action field to restore the guest
+ u32 event_payload_bytes;/* Bytes available in event payload area */
+ u32 control_channel_bytes;
+ u32 nvram_channel_bytes; /* Bytes in PartitionNvram segment */
+ u32 message_bytes; /* sizeof(CONTROLVM_MESSAGE) */
+ u32 message_count; /* CONTROLVM_MESSAGE_MAX */
+ u64 gp_smbios_table; /* guest phys addr of SMBIOS tables */
+ u64 gp_physical_smbios_table; /* guest phys addr of SMBIOS table */
+ /* ULTRA_MAX_GUESTS_PER_SERVICE */
+ char gp_reserved[2688];
+
+ /* guest physical address of EFI firmware image base */
+ u64 virtual_guest_firmware_image_base;
+
+ /* guest physical address of EFI firmware entry point */
+ u64 virtual_guest_firmware_entry_point;
+
+ /* guest EFI firmware image size */
+ u64 virtual_guest_firmware_image_size;
+
+ /* GPA = 1MB where EFI firmware image is copied to */
+ u64 virtual_guest_firmware_boot_base;
+ u64 virtual_guest_image_base;
+ u64 virtual_guest_image_size;
+ u64 prototype_control_channel_offset;
+ u64 virtual_guest_partition_handle;
+
+ u16 restore_action; /* Restore Action field to restore the guest
* partition */
u16 dump_action; /* For Windows guests it shows if the visordisk
* is running in dump mode */
@@ -462,7 +436,7 @@ struct spar_controlvm_channel_protocol {
struct controlvm_message saved_crash_msg[CONTROLVM_CRASHMSG_MAX];
};
-/* Offsets for VM channel attributes... */
+/* Offsets for VM channel attributes */
#define VM_CH_REQ_QUEUE_OFFSET \
offsetof(struct spar_controlvm_channel_protocol, request_queue)
#define VM_CH_RESP_QUEUE_OFFSET \
diff --git a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h b/drivers/staging/unisys/visorbus/controlvmcompletionstatus.h
index f74f5d8c282099..f74f5d8c282099 100644
--- a/drivers/staging/unisys/common-spar/include/controlvmcompletionstatus.h
+++ b/drivers/staging/unisys/visorbus/controlvmcompletionstatus.h
diff --git a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h
index 57dd93e0cc83f9..57dd93e0cc83f9 100644
--- a/drivers/staging/unisys/common-spar/include/iovmcall_gnuc.h
+++ b/drivers/staging/unisys/visorbus/iovmcall_gnuc.h
diff --git a/drivers/staging/unisys/visorutil/periodic_work.c b/drivers/staging/unisys/visorbus/periodic_work.c
index abbfb48894f309..5e56088cf8555f 100644
--- a/drivers/staging/unisys/visorutil/periodic_work.c
+++ b/drivers/staging/unisys/visorbus/periodic_work.c
@@ -18,8 +18,8 @@
/*
* Helper functions to schedule periodic work in Linux kernel mode.
*/
+#include <linux/sched.h>
-#include "timskmod.h"
#include "periodic_work.h"
#define MYDRVNAME "periodic_work"
@@ -29,8 +29,8 @@ struct periodic_work {
struct delayed_work work;
void (*workfunc)(void *);
void *workfuncarg;
- BOOL is_scheduled;
- BOOL want_to_stop;
+ bool is_scheduled;
+ bool want_to_stop;
ulong jiffy_interval;
struct workqueue_struct *workqueue;
const char *devnam;
@@ -74,64 +74,64 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_destroy);
/** Call this from your periodic work worker function to schedule the next
* call.
- * If this function returns FALSE, there was a failure and the
+ * If this function returns false, there was a failure and the
* periodic work is no longer scheduled
*/
-BOOL visor_periodic_work_nextperiod(struct periodic_work *pw)
+bool visor_periodic_work_nextperiod(struct periodic_work *pw)
{
- BOOL rc = FALSE;
+ bool rc = false;
write_lock(&pw->lock);
if (pw->want_to_stop) {
- pw->is_scheduled = FALSE;
- pw->want_to_stop = FALSE;
- rc = TRUE; /* yes, TRUE; see visor_periodic_work_stop() */
+ pw->is_scheduled = false;
+ pw->want_to_stop = false;
+ rc = true; /* yes, true; see visor_periodic_work_stop() */
goto unlock;
} else if (queue_delayed_work(pw->workqueue, &pw->work,
pw->jiffy_interval) < 0) {
- pw->is_scheduled = FALSE;
- rc = FALSE;
+ pw->is_scheduled = false;
+ rc = false;
goto unlock;
}
- rc = TRUE;
+ rc = true;
unlock:
write_unlock(&pw->lock);
return rc;
}
EXPORT_SYMBOL_GPL(visor_periodic_work_nextperiod);
-/** This function returns TRUE iff new periodic work was actually started.
- * If this function returns FALSE, then no work was started
+/** This function returns true iff new periodic work was actually started.
+ * If this function returns false, then no work was started
* (either because it was already started, or because of a failure).
*/
-BOOL visor_periodic_work_start(struct periodic_work *pw)
+bool visor_periodic_work_start(struct periodic_work *pw)
{
- BOOL rc = FALSE;
+ bool rc = false;
write_lock(&pw->lock);
if (pw->is_scheduled) {
- rc = FALSE;
+ rc = false;
goto unlock;
}
if (pw->want_to_stop) {
- rc = FALSE;
+ rc = false;
goto unlock;
}
INIT_DELAYED_WORK(&pw->work, &periodic_work_func);
if (queue_delayed_work(pw->workqueue, &pw->work,
pw->jiffy_interval) < 0) {
- rc = FALSE;
+ rc = false;
goto unlock;
}
- pw->is_scheduled = TRUE;
- rc = TRUE;
+ pw->is_scheduled = true;
+ rc = true;
unlock:
write_unlock(&pw->lock);
return rc;
}
EXPORT_SYMBOL_GPL(visor_periodic_work_start);
-/** This function returns TRUE iff your call actually stopped the periodic
+/** This function returns true iff your call actually stopped the periodic
* work.
*
* -- PAY ATTENTION... this is important --
@@ -165,20 +165,20 @@ EXPORT_SYMBOL_GPL(visor_periodic_work_start);
* this deadlock, you will get hung up in an infinite loop saying
* "waiting for delayed work...".
*/
-BOOL visor_periodic_work_stop(struct periodic_work *pw)
+bool visor_periodic_work_stop(struct periodic_work *pw)
{
- BOOL stopped_something = FALSE;
+ bool stopped_something = false;
write_lock(&pw->lock);
stopped_something = pw->is_scheduled && (!pw->want_to_stop);
while (pw->is_scheduled) {
- pw->want_to_stop = TRUE;
+ pw->want_to_stop = true;
if (cancel_delayed_work(&pw->work)) {
/* We get here if the delayed work was pending as
* delayed work, but was NOT run.
*/
WARN_ON(!pw->is_scheduled);
- pw->is_scheduled = FALSE;
+ pw->is_scheduled = false;
} else {
/* If we get here, either the delayed work:
* - was run, OR,
@@ -192,10 +192,10 @@ BOOL visor_periodic_work_stop(struct periodic_work *pw)
}
if (pw->is_scheduled) {
write_unlock(&pw->lock);
- SLEEPJIFFIES(10);
+ schedule_timeout_interruptible(msecs_to_jiffies(10));
write_lock(&pw->lock);
} else {
- pw->want_to_stop = FALSE;
+ pw->want_to_stop = false;
}
}
write_unlock(&pw->lock);
diff --git a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h b/drivers/staging/unisys/visorbus/vbuschannel.h
index 2c42ce16e0cf2d..5ed83a3f14281b 100644
--- a/drivers/staging/unisys/common-spar/include/channels/vbuschannel.h
+++ b/drivers/staging/unisys/visorbus/vbuschannel.h
@@ -54,7 +54,7 @@ static const uuid_le spar_vbus_channel_protocol_uuid =
#define SPAR_VBUS_CHANNEL_OK_SERVER(actual_bytes) \
(spar_check_channel_server(spar_vbus_channel_protocol_uuid, \
"vbus", \
- sizeof(struct ultra_vbus_channel_protocol),\
+ sizeof(struct spar_vbus_channel_protocol),\
actual_bytes))
#pragma pack(push, 1) /* both GCC and VC now allow this pragma */
diff --git a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h b/drivers/staging/unisys/visorbus/vbusdeviceinfo.h
index 9b6d3e69355c77..9b6d3e69355c77 100644
--- a/drivers/staging/unisys/common-spar/include/vbusdeviceinfo.h
+++ b/drivers/staging/unisys/visorbus/vbusdeviceinfo.h
diff --git a/drivers/staging/unisys/visorbus/visorbus_main.c b/drivers/staging/unisys/visorbus/visorbus_main.c
new file mode 100644
index 00000000000000..c7db6817f1b454
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorbus_main.c
@@ -0,0 +1,1791 @@
+/* visorbus_main.c
+ *
+ * Copyright � 2010 - 2013 UNISYS CORPORATION
+ * 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 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, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ */
+
+#include <linux/uuid.h>
+
+#include "visorbus.h"
+#include "visorbus_private.h"
+#include "version.h"
+#include "periodic_work.h"
+#include "vbuschannel.h"
+#include "guestlinuxdebug.h"
+#include "vmcallinterface.h"
+
+#define MYDRVNAME "visorbus"
+
+/* module parameters */
+static int visorbus_debug;
+static int visorbus_forcematch;
+static int visorbus_forcenomatch;
+#define MAXDEVICETEST 4
+static int visorbus_devicetest;
+static int visorbus_debugref;
+#define SERIALLOOPBACKCHANADDR (100 * 1024 * 1024)
+
+/** This is the private data that we store for each bus device instance.
+ */
+struct visorbus_devdata {
+ int devno; /* this is the chipset busNo */
+ struct list_head list_all;
+ struct device dev;
+ struct kobject kobj;
+ struct visorchannel *chan; /* channel area for bus itself */
+ bool vbus_valid;
+ void *vbus_hdr_info;
+};
+
+#define CURRENT_FILE_PC VISOR_BUS_PC_visorbus_main_c
+#define POLLJIFFIES_TESTWORK 100
+#define POLLJIFFIES_NORMALCHANNEL 10
+
+static int visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env);
+static int visorbus_match(struct device *xdev, struct device_driver *xdrv);
+static void fix_vbus_dev_info(struct visor_device *visordev);
+
+/* BUS type attributes
+ *
+ * define & implement display of bus attributes under
+ * /sys/bus/visorbus.
+ *
+ */
+
+static ssize_t version_show(struct bus_type *bus, char *buf)
+{
+ return snprintf(buf, PAGE_SIZE, "%s\n", VERSION);
+}
+
+static BUS_ATTR_RO(version);
+
+static struct attribute *visorbus_bus_attrs[] = {
+ &bus_attr_version.attr,
+ NULL,
+};
+
+static const struct attribute_group visorbus_bus_group = {
+ .attrs = visorbus_bus_attrs,
+};
+
+static const struct attribute_group *visorbus_bus_groups[] = {
+ &visorbus_bus_group,
+ NULL,
+};
+
+
+/** This describes the TYPE of bus.
+ * (Don't confuse this with an INSTANCE of the bus.)
+ */
+struct bus_type visorbus_type = {
+ .name = "visorbus",
+ .match = visorbus_match,
+ .uevent = visorbus_uevent,
+ .bus_groups = visorbus_bus_groups,
+};
+
+static struct delayed_work periodic_work;
+
+/* YES, we need 2 workqueues.
+ * The reason is, workitems on the test queue may need to cancel
+ * workitems on the other queue. You will be in for trouble if you try to
+ * do this with workitems queued on the same workqueue.
+ */
+static struct workqueue_struct *periodic_test_workqueue;
+static struct workqueue_struct *periodic_dev_workqueue;
+static long long bus_count; /** number of bus instances */
+static long long total_devices_created;
+ /** ever-increasing */
+
+static void chipset_bus_create(struct visorchipset_bus_info *bus_info);
+static void chipset_bus_destroy(struct visorchipset_bus_info *bus_info);
+static void chipset_device_create(struct visorchipset_device_info *dev_info);
+static void chipset_device_destroy(struct visorchipset_device_info *dev_info);
+static void chipset_device_pause(struct visorchipset_device_info *dev_info);
+static void chipset_device_resume(struct visorchipset_device_info *dev_info);
+
+/** These functions are implemented herein, and are called by the chipset
+ * driver to notify us about specific events.
+ */
+static struct visorchipset_busdev_notifiers chipset_notifiers = {
+ .bus_create = chipset_bus_create,
+ .bus_destroy = chipset_bus_destroy,
+ .device_create = chipset_device_create,
+ .device_destroy = chipset_device_destroy,
+ .device_pause = chipset_device_pause,
+ .device_resume = chipset_device_resume,
+};
+
+/** These functions are implemented in the chipset driver, and we call them
+ * herein when we want to acknowledge a specific event.
+ */
+static struct visorchipset_busdev_responders chipset_responders;
+
+/* filled in with info about parent chipset driver when we register with it */
+static struct ultra_vbus_deviceinfo chipset_driverinfo;
+/* filled in with info about this driver, wrt it servicing client busses */
+static struct ultra_vbus_deviceinfo clientbus_driverinfo;
+
+/** list of visorbus_devdata structs, linked via .list_all */
+static LIST_HEAD(list_all_bus_instances);
+/** list of visor_device structs, linked via .list_all */
+static LIST_HEAD(list_all_device_instances);
+
+static int
+visorbus_uevent(struct device *xdev, struct kobj_uevent_env *env)
+{
+ if (add_uevent_var(env, "VERSION=%s", VERSION))
+ return -ENOMEM;
+ return 0;
+}
+
+/* This is called automatically upon adding a visor_device (device_add), or
+ * adding a visor_driver (visorbus_register_visor_driver), and returns 1 iff the
+ * provided driver can control the specified device.
+ */
+static int
+visorbus_match(struct device *xdev, struct device_driver *xdrv)
+{
+ uuid_le channel_type;
+ int rc = 0;
+ int i;
+ struct visor_device *dev;
+ struct visor_driver *drv;
+
+ dev = to_visor_device(xdev);
+ drv = to_visor_driver(xdrv);
+ channel_type = visorchannel_get_uuid(dev->visorchannel);
+ if (visorbus_forcematch) {
+ rc = 1;
+ goto away;
+ }
+ if (visorbus_forcenomatch)
+ goto away;
+
+ if (!drv->channel_types)
+ goto away;
+ for (i = 0;
+ (uuid_le_cmp(drv->channel_types[i].guid, NULL_UUID_LE) != 0) ||
+ (drv->channel_types[i].name);
+ i++)
+ if (uuid_le_cmp(drv->channel_types[i].guid,
+ channel_type) == 0) {
+ rc = i + 1;
+ goto away;
+ }
+away:
+ return rc;
+}
+
+/** This is called when device_unregister() is called for the bus device
+ * instance, after all other tasks involved with destroying the device
+ * are complete.
+ */
+static void
+visorbus_release_busdevice(struct device *xdev)
+{
+ struct visorbus_devdata *devdata = dev_get_drvdata(xdev);
+
+ dev_set_drvdata(xdev, NULL);
+ kfree(devdata);
+ kfree(xdev);
+}
+
+/** This is called when device_unregister() is called for each child
+ * device instance.
+ */
+static void
+visorbus_release_device(struct device *xdev)
+{
+ struct visor_device *dev = to_visor_device(xdev);
+
+ if (dev->periodic_work) {
+ visor_periodic_work_destroy(dev->periodic_work);
+ dev->periodic_work = NULL;
+ }
+ if (dev->visorchannel) {
+ visorchannel_destroy(dev->visorchannel);
+ dev->visorchannel = NULL;
+ }
+ kfree(dev);
+}
+
+/* Implement publishing of device node attributes under:
+ *
+ * /sys/bus/visorbus<x>/dev<y>/devmajorminor
+ *
+ */
+
+#define to_devmajorminor_attr(_attr) \
+ container_of(_attr, struct devmajorminor_attribute, attr)
+#define to_visor_device_from_kobjdevmajorminor(obj) \
+ container_of(obj, struct visor_device, kobjdevmajorminor)
+
+struct devmajorminor_attribute {
+ struct attribute attr;
+ int slot;
+ ssize_t (*show)(struct visor_device *, int slot, char *buf);
+ ssize_t (*store)(struct visor_device *, int slot, const char *buf,
+ size_t count);
+};
+
+static ssize_t DEVMAJORMINOR_ATTR(struct visor_device *dev, int slot, char *buf)
+{
+ int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+
+ if (slot < 0 || slot >= maxdevnodes)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "%d:%d\n",
+ dev->devnodes[slot].major, dev->devnodes[slot].minor);
+}
+
+static ssize_t
+devmajorminor_attr_show(struct kobject *kobj, struct attribute *attr, char *buf)
+{
+ struct devmajorminor_attribute *devmajorminor_attr =
+ to_devmajorminor_attr(attr);
+ struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj);
+ ssize_t ret = 0;
+
+ if (devmajorminor_attr->show)
+ ret = devmajorminor_attr->show(dev,
+ devmajorminor_attr->slot, buf);
+ return ret;
+}
+
+static ssize_t
+devmajorminor_attr_store(struct kobject *kobj,
+ struct attribute *attr, const char *buf, size_t count)
+{
+ struct devmajorminor_attribute *devmajorminor_attr =
+ to_devmajorminor_attr(attr);
+ struct visor_device *dev = to_visor_device_from_kobjdevmajorminor(kobj);
+ ssize_t ret = 0;
+
+ if (devmajorminor_attr->store)
+ ret = devmajorminor_attr->store(dev,
+ devmajorminor_attr->slot,
+ buf, count);
+ return ret;
+}
+
+static int register_devmajorminor_attributes(struct visor_device *dev);
+
+static int
+devmajorminor_create_file(struct visor_device *dev, const char *name,
+ int major, int minor)
+{
+ int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+ struct devmajorminor_attribute *myattr = NULL;
+ int x = -1, rc = 0, slot = -1;
+
+ register_devmajorminor_attributes(dev);
+ for (slot = 0; slot < maxdevnodes; slot++)
+ if (!dev->devnodes[slot].attr)
+ break;
+ if (slot == maxdevnodes) {
+ rc = -ENOMEM;
+ goto away;
+ }
+ myattr = kmalloc(sizeof(*myattr), GFP_KERNEL);
+ if (!myattr) {
+ rc = -ENOMEM;
+ goto away;
+ }
+ memset(myattr, 0, sizeof(struct devmajorminor_attribute));
+ myattr->show = DEVMAJORMINOR_ATTR;
+ myattr->store = NULL;
+ myattr->slot = slot;
+ myattr->attr.name = name;
+ myattr->attr.mode = S_IRUGO;
+ dev->devnodes[slot].attr = myattr;
+ dev->devnodes[slot].major = major;
+ dev->devnodes[slot].minor = minor;
+ x = sysfs_create_file(&dev->kobjdevmajorminor, &myattr->attr);
+ if (x < 0) {
+ rc = x;
+ goto away;
+ }
+ kobject_uevent(&dev->device.kobj, KOBJ_ONLINE);
+away:
+ if (rc < 0) {
+ kfree(myattr);
+ myattr = NULL;
+ dev->devnodes[slot].attr = NULL;
+ }
+ return rc;
+}
+
+static void
+devmajorminor_remove_file(struct visor_device *dev, int slot)
+{
+ int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+ struct devmajorminor_attribute *myattr = NULL;
+
+ if (slot < 0 || slot >= maxdevnodes)
+ return;
+ myattr = (struct devmajorminor_attribute *)(dev->devnodes[slot].attr);
+ if (myattr)
+ return;
+ sysfs_remove_file(&dev->kobjdevmajorminor, &myattr->attr);
+ kobject_uevent(&dev->device.kobj, KOBJ_OFFLINE);
+ dev->devnodes[slot].attr = NULL;
+ kfree(myattr);
+}
+
+static void
+devmajorminor_remove_all_files(struct visor_device *dev)
+{
+ int i = 0;
+ int maxdevnodes = ARRAY_SIZE(dev->devnodes) / sizeof(dev->devnodes[0]);
+
+ for (i = 0; i < maxdevnodes; i++)
+ devmajorminor_remove_file(dev, i);
+}
+
+static const struct sysfs_ops devmajorminor_sysfs_ops = {
+ .show = devmajorminor_attr_show,
+ .store = devmajorminor_attr_store,
+};
+
+static struct kobj_type devmajorminor_kobj_type = {
+ .sysfs_ops = &devmajorminor_sysfs_ops
+};
+
+static int
+register_devmajorminor_attributes(struct visor_device *dev)
+{
+ int rc = 0, x = 0;
+
+ if (dev->kobjdevmajorminor.parent)
+ goto away; /* already registered */
+ x = kobject_init_and_add(&dev->kobjdevmajorminor,
+ &devmajorminor_kobj_type, &dev->device.kobj,
+ "devmajorminor");
+ if (x < 0) {
+ rc = x;
+ goto away;
+ }
+
+ kobject_uevent(&dev->kobjdevmajorminor, KOBJ_ADD);
+
+away:
+ return rc;
+}
+
+static void
+unregister_devmajorminor_attributes(struct visor_device *dev)
+{
+ if (!dev->kobjdevmajorminor.parent)
+ return; /* already unregistered */
+ devmajorminor_remove_all_files(dev);
+
+ kobject_del(&dev->kobjdevmajorminor);
+ kobject_put(&dev->kobjdevmajorminor);
+ dev->kobjdevmajorminor.parent = NULL;
+}
+
+/* begin implementation of specific channel attributes to appear under
+* /sys/bus/visorbus<x>/dev<y>/channel
+*/
+static ssize_t physaddr_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct visor_device *vdev = to_visor_device(dev);
+
+ if (!vdev->visorchannel)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
+ visorchannel_get_physaddr(vdev->visorchannel));
+}
+
+static ssize_t nbytes_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct visor_device *vdev = to_visor_device(dev);
+
+ if (!vdev->visorchannel)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "0x%lx\n",
+ visorchannel_get_nbytes(vdev->visorchannel));
+}
+
+static ssize_t clientpartition_show(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+ struct visor_device *vdev = to_visor_device(dev);
+
+ if (!vdev->visorchannel)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "0x%Lx\n",
+ visorchannel_get_clientpartition(vdev->visorchannel));
+}
+
+static ssize_t typeguid_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct visor_device *vdev = to_visor_device(dev);
+ char s[99];
+
+ if (!vdev->visorchannel)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "%s\n",
+ visorchannel_id(vdev->visorchannel, s));
+}
+
+static ssize_t zoneguid_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct visor_device *vdev = to_visor_device(dev);
+ char s[99];
+
+ if (!vdev->visorchannel)
+ return 0;
+ return snprintf(buf, PAGE_SIZE, "%s\n",
+ visorchannel_zoneid(vdev->visorchannel, s));
+}
+
+static ssize_t typename_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+ struct visor_device *vdev = to_visor_device(dev);
+ int i = 0;
+ struct bus_type *xbus = dev->bus;
+ struct device_driver *xdrv = dev->driver;
+ struct visor_driver *drv = NULL;
+
+ if (!vdev->visorchannel || !xbus || !xdrv)
+ return 0;
+ i = xbus->match(dev, xdrv);
+ if (!i)
+ return 0;
+ drv = to_visor_driver(xdrv);
+ return snprintf(buf, PAGE_SIZE, "%s\n", drv->channel_types[i - 1].name);
+}
+
+static ssize_t dump_show(struct device *dev, struct device_attribute *attr,
+ char *buf)
+{
+/* TODO: replace this with debugfs code
+ struct visor_device *vdev = to_visor_device(dev);
+ int count = 0;
+ struct seq_file *m = NULL;
+ if (vdev->visorchannel == NULL)
+ return 0;
+ m = visor_seq_file_new_buffer(buf, PAGE_SIZE - 1);
+ if (m == NULL)
+ return 0;
+ visorchannel_debug(vdev->visorchannel, 1, m, 0);
+ count = m->count;
+ visor_seq_file_done_buffer(m);
+ m = NULL;
+*/
+ return 0;
+}
+
+static DEVICE_ATTR_RO(physaddr);
+static DEVICE_ATTR_RO(nbytes);
+static DEVICE_ATTR_RO(clientpartition);
+static DEVICE_ATTR_RO(typeguid);
+static DEVICE_ATTR_RO(zoneguid);
+static DEVICE_ATTR_RO(typename);
+static DEVICE_ATTR_RO(dump);
+
+static struct attribute *channel_attrs[] = {
+ &dev_attr_physaddr.attr,
+ &dev_attr_nbytes.attr,
+ &dev_attr_clientpartition.attr,
+ &dev_attr_typeguid.attr,
+ &dev_attr_zoneguid.attr,
+ &dev_attr_typename.attr,
+ &dev_attr_dump.attr,
+};
+
+static struct attribute_group channel_attr_grp = {
+ .name = "channel",
+ .attrs = channel_attrs,
+};
+
+static const struct attribute_group *visorbus_dev_groups[] = {
+ &channel_attr_grp,
+ NULL
+};
+
+/* end implementation of specific channel attributes */
+
+#define to_visorbus_devdata(obj) \
+ container_of(obj, struct visorbus_devdata, dev)
+
+/* BUS instance attributes
+ *
+ * define & implement display of bus attributes under
+ * /sys/bus/visorbus/busses/visorbus<n>.
+ *
+ * This is a bit hoaky because the kernel does not yet have the infrastructure
+ * to separate bus INSTANCE attributes from bus TYPE attributes...
+ * so we roll our own. See businst.c / businst.h.
+ *
+ */
+
+static ssize_t partition_handle_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ struct visor_device *vdev = to_visor_device(dev);
+ u64 handle = visorchannel_get_clientpartition(vdev->visorchannel);
+
+ return snprintf(buf, PAGE_SIZE, "0x%Lx\n", handle);
+}
+
+static ssize_t partition_guid_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ struct visor_device *vdev = to_visor_device(dev);
+
+ return snprintf(buf, PAGE_SIZE, "{%pUb}\n", &vdev->partition_uuid);
+}
+
+static ssize_t partition_name_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ struct visor_device *vdev = to_visor_device(dev);
+
+ return snprintf(buf, PAGE_SIZE, "%s\n", vdev->name);
+}
+
+static ssize_t channel_addr_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ struct visor_device *vdev = to_visor_device(dev);
+ u64 addr = visorchannel_get_physaddr(vdev->visorchannel);
+
+ return snprintf(buf, PAGE_SIZE, "0x%Lx\n", addr);
+}
+
+static ssize_t channel_bytes_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ struct visor_device *vdev = to_visor_device(dev);
+ u64 nbytes = visorchannel_get_nbytes(vdev->visorchannel);
+
+ return snprintf(buf, PAGE_SIZE, "0x%Lx\n", nbytes);
+}
+
+static ssize_t channel_id_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ struct visor_device *vdev = to_visor_device(dev);
+ int len = 0;
+
+ if (vdev->visorchannel) {
+ visorchannel_id(vdev->visorchannel, buf);
+ len = strlen(buf);
+ buf[len++] = '\n';
+ }
+ return len;
+}
+
+static ssize_t client_bus_info_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buf) {
+ struct visor_device *vdev = to_visor_device(dev);
+ struct visorchannel *channel = vdev->visorchannel;
+
+ int i, x, remain = PAGE_SIZE;
+ unsigned long off;
+ char *p = buf;
+ u8 *partition_name;
+ struct ultra_vbus_deviceinfo dev_info;
+
+ partition_name = "";
+ if (channel) {
+ if (vdev->name)
+ partition_name = vdev->name;
+ x = snprintf(p, remain,
+ "Client device / client driver info for %s partition (vbus #%ld):\n",
+ partition_name, vdev->chipset_dev_no);
+ p += x;
+ remain -= x;
+ x = visorchannel_read(channel,
+ offsetof(struct
+ spar_vbus_channel_protocol,
+ chp_info),
+ &dev_info, sizeof(dev_info));
+ if (x >= 0) {
+ x = vbuschannel_devinfo_to_string(&dev_info, p,
+ remain, -1);
+ p += x;
+ remain -= x;
+ }
+ x = visorchannel_read(channel,
+ offsetof(struct
+ spar_vbus_channel_protocol,
+ bus_info),
+ &dev_info, sizeof(dev_info));
+ if (x >= 0) {
+ x = vbuschannel_devinfo_to_string(&dev_info, p,
+ remain, -1);
+ p += x;
+ remain -= x;
+ }
+ off = offsetof(struct spar_vbus_channel_protocol, dev_info);
+ i = 0;
+ while (off + sizeof(dev_info) <=
+ visorchannel_get_nbytes(channel)) {
+ x = visorchannel_read(channel,
+ off, &dev_info, sizeof(dev_info));
+ if (x >= 0) {
+ x = vbuschannel_devinfo_to_string
+ (&dev_info, p, remain, i);
+ p += x;
+ remain -= x;
+ }
+ off += sizeof(dev_info);
+ i++;
+ }
+ }
+ return PAGE_SIZE - remain;
+}
+
+static DEVICE_ATTR_RO(partition_handle);
+static DEVICE_ATTR_RO(partition_guid);
+static DEVICE_ATTR_RO(partition_name);
+static DEVICE_ATTR_RO(channel_addr);
+static DEVICE_ATTR_RO(channel_bytes);
+static DEVICE_ATTR_RO(channel_id);
+static DEVICE_ATTR_RO(client_bus_info);
+
+static struct attribute *dev_attrs[] = {
+ &dev_attr_partition_handle.attr,
+ &dev_attr_partition_guid.attr,
+ &dev_attr_partition_name.attr,
+ &dev_attr_channel_addr.attr,
+ &dev_attr_channel_bytes.attr,
+ &dev_attr_channel_id.attr,
+ &dev_attr_client_bus_info.attr,
+ NULL
+};
+
+static struct attribute_group dev_attr_grp = {
+ .attrs = dev_attrs,
+};
+
+static const struct attribute_group *visorbus_groups[] = {
+ &dev_attr_grp,
+ NULL
+};
+
+/* DRIVER attributes
+ *
+ * define & implement display of driver attributes under
+ * /sys/bus/visorbus/drivers/<drivername>.
+ *
+ */
+
+static ssize_t
+DRIVER_ATTR_version(struct device_driver *xdrv, char *buf)
+{
+ struct visor_driver *drv = to_visor_driver(xdrv);
+
+ return snprintf(buf, PAGE_SIZE, "%s\n", drv->version);
+}
+
+static int
+register_driver_attributes(struct visor_driver *drv)
+{
+ int rc;
+ struct driver_attribute version =
+ __ATTR(version, S_IRUGO, DRIVER_ATTR_version, NULL);
+ drv->version_attr = version;
+ rc = driver_create_file(&drv->driver, &drv->version_attr);
+ return rc;
+}
+
+static void
+unregister_driver_attributes(struct visor_driver *drv)
+{
+ driver_remove_file(&drv->driver, &drv->version_attr);
+}
+
+/* DEVICE attributes
+ *
+ * define & implement display of device attributes under
+ * /sys/bus/visorbus/devices/<devicename>.
+ *
+ */
+
+#define DEVATTR(nam, func) { \
+ .attr = { .name = __stringify(nam), \
+ .mode = 0444, \
+ .owner = THIS_MODULE }, \
+ .show = func, \
+}
+
+static struct device_attribute visor_device_attrs[] = {
+ /* DEVATTR(channel_nbytes, DEVICE_ATTR_channel_nbytes), */
+ __ATTR_NULL
+};
+
+static void
+dev_periodic_work(void *xdev)
+{
+ struct visor_device *dev = (struct visor_device *)xdev;
+ struct visor_driver *drv = to_visor_driver(dev->device.driver);
+
+ down(&dev->visordriver_callback_lock);
+ if (drv->channel_interrupt)
+ drv->channel_interrupt(dev);
+ up(&dev->visordriver_callback_lock);
+ if (!visor_periodic_work_nextperiod(dev->periodic_work))
+ put_device(&dev->device);
+}
+
+static void
+dev_start_periodic_work(struct visor_device *dev)
+{
+ if (dev->being_removed)
+ return;
+ /* now up by at least 2 */
+ get_device(&dev->device);
+ if (!visor_periodic_work_start(dev->periodic_work))
+ put_device(&dev->device);
+}
+
+static void
+dev_stop_periodic_work(struct visor_device *dev)
+{
+ if (visor_periodic_work_stop(dev->periodic_work))
+ put_device(&dev->device);
+}
+
+/** This is called automatically upon adding a visor_device (device_add), or
+ * adding a visor_driver (visorbus_register_visor_driver), but only after
+ * visorbus_match has returned 1 to indicate a successful match between
+ * driver and device.
+ */
+static int
+visordriver_probe_device(struct device *xdev)
+{
+ int rc;
+ struct visor_driver *drv;
+ struct visor_device *dev;
+
+ drv = to_visor_driver(xdev->driver);
+ dev = to_visor_device(xdev);
+ down(&dev->visordriver_callback_lock);
+ dev->being_removed = false;
+ /*
+ * ensure that the dev->being_removed flag is cleared before
+ * we start the probe
+ */
+ wmb();
+ get_device(&dev->device);
+ if (!drv->probe) {
+ up(&dev->visordriver_callback_lock);
+ rc = -1;
+ goto away;
+ }
+ rc = drv->probe(dev);
+ if (rc < 0)
+ goto away;
+
+ fix_vbus_dev_info(dev);
+ up(&dev->visordriver_callback_lock);
+ rc = 0;
+away:
+ if (rc != 0)
+ put_device(&dev->device);
+ /* We could get here more than once if the child driver module is
+ * unloaded and re-loaded while devices are present. That's why we
+ * need a flag to be sure that we only respond to the device_create
+ * once. We cannot respond to the device_create prior to here,
+ * because until we call drv->probe() above, the channel has not been
+ * initialized.
+ */
+ if (!dev->responded_to_device_create) {
+ struct visorchipset_device_info dev_info;
+
+ if (!visorchipset_get_device_info(dev->chipset_bus_no,
+ dev->chipset_dev_no,
+ &dev_info))
+ /* hmm, what to do here */
+ return rc;
+
+ dev->responded_to_device_create = true;
+ if (chipset_responders.device_create)
+ (*chipset_responders.device_create)(&dev_info, rc);
+ }
+ return rc;
+}
+
+/** This is called when device_unregister() is called for each child device
+ * instance, to notify the appropriate visorbus_driver that the device is
+ * going away, and to decrease the reference count of the device.
+ */
+static int
+visordriver_remove_device(struct device *xdev)
+{
+ int rc = 0;
+ struct visor_device *dev;
+ struct visor_driver *drv;
+
+ dev = to_visor_device(xdev);
+ drv = to_visor_driver(xdev->driver);
+ down(&dev->visordriver_callback_lock);
+ dev->being_removed = true;
+ /*
+ * ensure that the dev->being_removed flag is set before we start the
+ * actual removal
+ */
+ wmb();
+ if (drv) {
+ if (drv->remove)
+ drv->remove(dev);
+ }
+ up(&dev->visordriver_callback_lock);
+ dev_stop_periodic_work(dev);
+ devmajorminor_remove_all_files(dev);
+
+ put_device(&dev->device);
+
+ return rc;
+}
+
+/** A particular type of visor driver calls this function to register
+ * the driver. The caller MUST fill in the following fields within the
+ * #drv structure:
+ * name, version, owner, channel_types, probe, remove
+ *
+ * Here's how the whole Linux bus / driver / device model works.
+ *
+ * At system start-up, the visorbus kernel module is loaded, which registers
+ * visorbus_type as a bus type, using bus_register().
+ *
+ * All kernel modules that support particular device types on a
+ * visorbus bus are loaded. Each of these kernel modules calls
+ * visorbus_register_visor_driver() in their init functions, passing a
+ * visor_driver struct. visorbus_register_visor_driver() in turn calls
+ * register_driver(&visor_driver.driver). This .driver member is
+ * initialized with generic methods (like probe), whose sole responsibility
+ * is to act as a broker for the real methods, which are within the
+ * visor_driver struct. (This is the way the subclass behavior is
+ * implemented, since visor_driver is essentially a subclass of the
+ * generic driver.) Whenever a driver_register() happens, core bus code in
+ * the kernel does (see device_attach() in drivers/base/dd.c):
+ *
+ * for each dev associated with the bus (the bus that driver is on) that
+ * does not yet have a driver
+ * if bus.match(dev,newdriver) == yes_matched ** .match specified
+ * ** during bus_register().
+ * newdriver.probe(dev) ** for visor drivers, this will call
+ * ** the generic driver.probe implemented in visorbus.c,
+ * ** which in turn calls the probe specified within the
+ * ** struct visor_driver (which was specified by the
+ * ** actual device driver as part of
+ * ** visorbus_register_visor_driver()).
+ *
+ * The above dance also happens when a new device appears.
+ * So the question is, how are devices created within the system?
+ * Basically, just call device_add(dev). See pci_bus_add_devices().
+ * pci_scan_device() shows an example of how to build a device struct. It
+ * returns the newly-created struct to pci_scan_single_device(), who adds it
+ * to the list of devices at PCIBUS.devices. That list of devices is what
+ * is traversed by pci_bus_add_devices().
+ *
+ */
+int visorbus_register_visor_driver(struct visor_driver *drv)
+{
+ int rc = 0;
+
+ drv->driver.name = drv->name;
+ drv->driver.bus = &visorbus_type;
+ drv->driver.probe = visordriver_probe_device;
+ drv->driver.remove = visordriver_remove_device;
+ drv->driver.owner = drv->owner;
+
+ /* driver_register does this:
+ * bus_add_driver(drv)
+ * ->if (drv.bus) ** (bus_type) **
+ * driver_attach(drv)
+ * for each dev with bus type of drv.bus
+ * if (!dev.drv) ** no driver assigned yet **
+ * if (bus.match(dev,drv)) [visorbus_match]
+ * dev.drv = drv
+ * if (!drv.probe(dev)) [visordriver_probe_device]
+ * dev.drv = NULL
+ */
+
+ rc = driver_register(&drv->driver);
+ if (rc < 0)
+ return rc;
+ rc = register_driver_attributes(drv);
+ return rc;
+}
+EXPORT_SYMBOL_GPL(visorbus_register_visor_driver);
+
+/** A particular type of visor driver calls this function to unregister
+ * the driver, i.e., within its module_exit function.
+ */
+void
+visorbus_unregister_visor_driver(struct visor_driver *drv)
+{
+ unregister_driver_attributes(drv);
+ driver_unregister(&drv->driver);
+}
+EXPORT_SYMBOL_GPL(visorbus_unregister_visor_driver);
+
+int
+visorbus_read_channel(struct visor_device *dev, unsigned long offset,
+ void *dest, unsigned long nbytes)
+{
+ return visorchannel_read(dev->visorchannel, offset, dest, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorbus_read_channel);
+
+int
+visorbus_write_channel(struct visor_device *dev, unsigned long offset,
+ void *src, unsigned long nbytes)
+{
+ return visorchannel_write(dev->visorchannel, offset, src, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorbus_write_channel);
+
+int
+visorbus_clear_channel(struct visor_device *dev, unsigned long offset, u8 ch,
+ unsigned long nbytes)
+{
+ return visorchannel_clear(dev->visorchannel, offset, ch, nbytes);
+}
+EXPORT_SYMBOL_GPL(visorbus_clear_channel);
+
+int
+visorbus_registerdevnode(struct visor_device *dev,
+ const char *name, int major, int minor)
+{
+ return devmajorminor_create_file(dev, name, major, minor);
+}
+EXPORT_SYMBOL_GPL(visorbus_registerdevnode);
+
+/** We don't really have a real interrupt, so for now we just call the
+ * interrupt function periodically...
+ */
+void
+visorbus_enable_channel_interrupts(struct visor_device *dev)
+{
+ dev_start_periodic_work(dev);
+}
+EXPORT_SYMBOL_GPL(visorbus_enable_channel_interrupts);
+
+void
+visorbus_disable_channel_interrupts(struct visor_device *dev)
+{
+ dev_stop_periodic_work(dev);
+}
+EXPORT_SYMBOL_GPL(visorbus_disable_channel_interrupts);
+
+/** This is how everything starts from the device end.
+ * This function is called when a channel first appears via a ControlVM
+ * message. In response, this function allocates a visor_device to
+ * correspond to the new channel, and attempts to connect it the appropriate
+ * driver. If the appropriate driver is found, the visor_driver.probe()
+ * function for that driver will be called, and will be passed the new
+ * visor_device that we just created.
+ *
+ * It's ok if the appropriate driver is not yet loaded, because in that case
+ * the new device struct will just stick around in the bus' list of devices.
+ * When the appropriate driver calls visorbus_register_visor_driver(), the
+ * visor_driver.probe() for the new driver will be called with the new
+ * device.
+ */
+static int
+create_visor_device(struct visorbus_devdata *devdata,
+ struct visorchipset_device_info *dev_info,
+ u64 partition_handle)
+{
+ int rc = -1;
+ struct visor_device *dev = NULL;
+ bool gotten = false, registered1 = false, registered2 = false;
+ u32 chipset_bus_no = dev_info->bus_no;
+ u32 chipset_dev_no = dev_info->dev_no;
+
+ POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, chipset_dev_no, chipset_bus_no,
+ POSTCODE_SEVERITY_INFO);
+ dev = kmalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev) {
+ POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
+ DIAG_SEVERITY_ERR);
+ goto away;
+ }
+
+ memset(dev, 0, sizeof(struct visor_device));
+ dev->visorchannel = dev_info->visorchannel;
+ dev->channel_type_guid = dev_info->channel_type_guid;
+ dev->chipset_bus_no = chipset_bus_no;
+ dev->chipset_dev_no = chipset_dev_no;
+ dev->device.parent = &devdata->dev;
+ sema_init(&dev->visordriver_callback_lock, 1); /* unlocked */
+ dev->device.bus = &visorbus_type;
+ dev->device.groups = visorbus_dev_groups;
+ device_initialize(&dev->device);
+ dev->device.release = visorbus_release_device;
+ /* keep a reference just for us (now 2) */
+ get_device(&dev->device);
+ gotten = true;
+ dev->periodic_work =
+ visor_periodic_work_create(POLLJIFFIES_NORMALCHANNEL,
+ periodic_dev_workqueue,
+ dev_periodic_work,
+ dev, dev_name(&dev->device));
+ if (!dev->periodic_work) {
+ POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, chipset_dev_no,
+ DIAG_SEVERITY_ERR);
+ goto away;
+ }
+
+ /* bus_id must be a unique name with respect to this bus TYPE
+ * (NOT bus instance). That's why we need to include the bus
+ * number within the name.
+ */
+ dev_set_name(&dev->device, "vbus%u:dev%u",
+ chipset_bus_no, chipset_dev_no);
+
+ /* device_add does this:
+ * bus_add_device(dev)
+ * ->device_attach(dev)
+ * ->for each driver drv registered on the bus that dev is on
+ * if (dev.drv) ** device already has a driver **
+ * ** not sure we could ever get here... **
+ * else
+ * if (bus.match(dev,drv)) [visorbus_match]
+ * dev.drv = drv
+ * if (!drv.probe(dev)) [visordriver_probe_device]
+ * dev.drv = NULL
+ *
+ * Note that device_add does NOT fail if no driver failed to
+ * claim the device. The device will be linked onto
+ * bus_type.klist_devices regardless (use bus_for_each_dev).
+ */
+ rc = device_add(&dev->device);
+ if (rc < 0) {
+ POSTCODE_LINUX_3(DEVICE_ADD_PC, chipset_bus_no,
+ DIAG_SEVERITY_ERR);
+ goto away;
+ }
+
+ /* note: device_register is simply device_initialize + device_add */
+ registered1 = true;
+
+ rc = register_devmajorminor_attributes(dev);
+ if (rc < 0) {
+ POSTCODE_LINUX_3(DEVICE_REGISTER_FAILURE_PC, chipset_dev_no,
+ DIAG_SEVERITY_ERR);
+ goto away;
+ }
+
+ registered2 = true;
+ rc = 0;
+
+away:
+ if (rc < 0) {
+ if (registered2)
+ unregister_devmajorminor_attributes(dev);
+ if (gotten)
+ put_device(&dev->device);
+ kfree(dev);
+ } else {
+ total_devices_created++;
+ list_add_tail(&dev->list_all, &list_all_device_instances);
+ }
+ return rc;
+}
+
+static void
+remove_visor_device(struct visor_device *dev)
+{
+ list_del(&dev->list_all);
+ unregister_devmajorminor_attributes(dev);
+ put_device(&dev->device);
+ device_unregister(&dev->device);
+}
+
+static struct visor_device *
+find_visor_device_by_channel(struct visorchannel *channel)
+{
+ struct list_head *listentry, *listtmp;
+
+ list_for_each_safe(listentry, listtmp, &list_all_device_instances) {
+ struct visor_device *dev = list_entry(listentry,
+ struct visor_device,
+ list_all);
+ if (dev->visorchannel == channel)
+ return dev;
+ }
+ return NULL;
+}
+
+static int
+init_vbus_channel(struct visorchannel *chan)
+{
+ int rc = -1;
+ unsigned long allocated_bytes = visorchannel_get_nbytes(chan);
+ struct spar_vbus_channel_protocol *x =
+ kmalloc(sizeof(struct spar_vbus_channel_protocol),
+ GFP_KERNEL);
+
+ POSTCODE_LINUX_3(VBUS_CHANNEL_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO);
+
+ if (x) {
+ POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
+ goto away;
+ }
+ if (visorchannel_clear(chan, 0, 0, allocated_bytes) < 0) {
+ POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
+ POSTCODE_SEVERITY_ERR);
+ goto away;
+ }
+ if (visorchannel_read
+ (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) {
+ POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
+ POSTCODE_SEVERITY_ERR);
+ goto away;
+ }
+ if (!SPAR_VBUS_CHANNEL_OK_SERVER(allocated_bytes)) {
+ POSTCODE_LINUX_2(VBUS_CHANNEL_FAILURE_PC,
+ POSTCODE_SEVERITY_ERR);
+ goto away;
+ }
+
+ if (visorchannel_write
+ (chan, 0, x, sizeof(struct spar_vbus_channel_protocol)) < 0) {
+ POSTCODE_LINUX_3(VBUS_CHANNEL_FAILURE_PC, chan,
+ POSTCODE_SEVERITY_ERR);
+ goto away;
+ }
+
+ POSTCODE_LINUX_3(VBUS_CHANNEL_EXIT_PC, chan, POSTCODE_SEVERITY_INFO);
+ rc = 0;
+
+away:
+ kfree(x);
+ x = NULL;
+ return rc;
+}
+
+static int
+get_vbus_header_info(struct visorchannel *chan,
+ struct spar_vbus_headerinfo *hdr_info)
+{
+ int rc = -1;
+
+ if (!SPAR_VBUS_CHANNEL_OK_CLIENT(visorchannel_get_header(chan)))
+ goto away;
+ if (visorchannel_read(chan, sizeof(struct channel_header), hdr_info,
+ sizeof(*hdr_info)) < 0) {
+ goto away;
+ }
+ if (hdr_info->struct_bytes < sizeof(struct spar_vbus_headerinfo))
+ goto away;
+ if (hdr_info->device_info_struct_bytes <
+ sizeof(struct ultra_vbus_deviceinfo)) {
+ goto away;
+ }
+ rc = 0;
+away:
+ return rc;
+}
+
+/* Write the contents of <info> to the struct
+ * spar_vbus_channel_protocol.chp_info. */
+
+static int
+write_vbus_chp_info(struct visorchannel *chan,
+ struct spar_vbus_headerinfo *hdr_info,
+ struct ultra_vbus_deviceinfo *info)
+{
+ int off = sizeof(struct channel_header) + hdr_info->chp_info_offset;
+
+ if (hdr_info->chp_info_offset == 0)
+ return -1;
+
+ if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
+ return -1;
+ return 0;
+}
+
+/* Write the contents of <info> to the struct
+ * spar_vbus_channel_protocol.bus_info. */
+
+static int
+write_vbus_bus_info(struct visorchannel *chan,
+ struct spar_vbus_headerinfo *hdr_info,
+ struct ultra_vbus_deviceinfo *info)
+{
+ int off = sizeof(struct channel_header) + hdr_info->bus_info_offset;
+
+ if (hdr_info->bus_info_offset == 0)
+ return -1;
+
+ if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
+ return -1;
+ return 0;
+}
+
+/* Write the contents of <info> to the
+ * struct spar_vbus_channel_protocol.dev_info[<devix>].
+ */
+static int
+write_vbus_dev_info(struct visorchannel *chan,
+ struct spar_vbus_headerinfo *hdr_info,
+ struct ultra_vbus_deviceinfo *info, int devix)
+{
+ int off =
+ (sizeof(struct channel_header) + hdr_info->dev_info_offset) +
+ (hdr_info->device_info_struct_bytes * devix);
+
+ if (hdr_info->dev_info_offset == 0)
+ return -1;
+
+ if (visorchannel_write(chan, off, info, sizeof(*info)) < 0)
+ return -1;
+ return 0;
+}
+
+/* For a child device just created on a client bus, fill in
+ * information about the driver that is controlling this device into
+ * the the appropriate slot within the vbus channel of the bus
+ * instance.
+ */
+static void
+fix_vbus_dev_info(struct visor_device *visordev)
+{
+ int i;
+ struct visorchipset_bus_info bus_info;
+ struct visorbus_devdata *devdata = NULL;
+ struct visor_driver *visordrv;
+ int bus_no = visordev->chipset_bus_no;
+ int dev_no = visordev->chipset_dev_no;
+ struct ultra_vbus_deviceinfo dev_info;
+ const char *chan_type_name = NULL;
+ struct spar_vbus_headerinfo *hdr_info;
+
+ if (!visordev->device.driver)
+ return;
+
+ hdr_info = (struct spar_vbus_headerinfo *)visordev->vbus_hdr_info;
+
+ visordrv = to_visor_driver(visordev->device.driver);
+ if (!visorchipset_get_bus_info(bus_no, &bus_info))
+ return;
+
+ devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
+ if (!devdata)
+ return;
+
+ if (!hdr_info)
+ return;
+
+ /* Within the list of device types (by GUID) that the driver
+ * says it supports, find out which one of those types matches
+ * the type of this device, so that we can include the device
+ * type name
+ */
+ for (i = 0; visordrv->channel_types[i].name; i++) {
+ if (memcmp(&visordrv->channel_types[i].guid,
+ &visordev->channel_type_guid,
+ sizeof(visordrv->channel_types[i].guid)) == 0) {
+ chan_type_name = visordrv->channel_types[i].name;
+ break;
+ }
+ }
+
+ bus_device_info_init(&dev_info, chan_type_name,
+ visordrv->name, visordrv->version,
+ visordrv->vertag);
+ write_vbus_dev_info(devdata->chan, hdr_info, &dev_info, dev_no);
+
+ /* Re-write bus+chipset info, because it is possible that this
+ * was previously written by our evil counterpart, virtpci.
+ */
+ write_vbus_chp_info(devdata->chan, hdr_info, &chipset_driverinfo);
+ write_vbus_bus_info(devdata->chan, hdr_info, &clientbus_driverinfo);
+}
+
+/** Create a device instance for the visor bus itself.
+ */
+static struct visorbus_devdata *
+create_bus_instance(struct visorchipset_bus_info *bus_info)
+{
+ struct visorbus_devdata *rc = NULL;
+ struct visorbus_devdata *devdata = NULL;
+ int id = bus_info->bus_no;
+ struct spar_vbus_headerinfo *hdr_info;
+
+ POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, POSTCODE_SEVERITY_INFO);
+ devdata = kzalloc(sizeof(*devdata), GFP_KERNEL);
+ if (!devdata) {
+ POSTCODE_LINUX_2(MALLOC_FAILURE_PC, POSTCODE_SEVERITY_ERR);
+ rc = NULL;
+ goto away;
+ }
+
+ hdr_info = kzalloc(sizeof(*hdr_info), GFP_KERNEL);
+ if (!hdr_info) {
+ rc = NULL;
+ goto away_mem;
+ }
+
+ dev_set_name(&devdata->dev, "visorbus%d", id);
+ devdata->dev.bus = &visorbus_type;
+ devdata->dev.groups = visorbus_groups;
+ devdata->dev.release = visorbus_release_busdevice;
+ if (device_register(&devdata->dev) < 0) {
+ POSTCODE_LINUX_3(DEVICE_CREATE_FAILURE_PC, id,
+ POSTCODE_SEVERITY_ERR);
+ rc = NULL;
+ goto away_mem2;
+ }
+ devdata->devno = id;
+ devdata->chan = bus_info->visorchannel;
+ if (bus_info->flags.server) {
+ init_vbus_channel(devdata->chan);
+ } else {
+ if (get_vbus_header_info(devdata->chan, hdr_info) >= 0) {
+ devdata->vbus_hdr_info = (void *)hdr_info;
+ write_vbus_chp_info(devdata->chan, hdr_info,
+ &chipset_driverinfo);
+ write_vbus_bus_info(devdata->chan, hdr_info,
+ &clientbus_driverinfo);
+ }
+ }
+ bus_count++;
+ list_add_tail(&devdata->list_all, &list_all_bus_instances);
+ if (id == 0)
+ devdata = devdata; /* for testing ONLY */
+ dev_set_drvdata(&devdata->dev, devdata);
+ rc = devdata;
+ return rc;
+
+away_mem2:
+ kfree(hdr_info);
+away_mem:
+ kfree(devdata);
+away:
+ return rc;
+}
+
+/** Remove a device instance for the visor bus itself.
+ */
+static void
+remove_bus_instance(struct visorbus_devdata *devdata)
+{
+ /* Note that this will result in the release method for
+ * devdata->dev being called, which will call
+ * visorbus_release_busdevice(). This has something to do with
+ * the put_device() done in device_unregister(), but I have never
+ * successfully been able to trace thru the code to see where/how
+ * release() gets called. But I know it does.
+ */
+ bus_count--;
+ if (devdata->chan) {
+ visorchannel_destroy(devdata->chan);
+ devdata->chan = NULL;
+ }
+ kfree(devdata->vbus_hdr_info);
+ list_del(&devdata->list_all);
+ device_unregister(&devdata->dev);
+}
+
+/** Create and register the one-and-only one instance of
+ * the visor bus type (visorbus_type).
+ */
+static int
+create_bus_type(void)
+{
+ int rc = 0;
+
+ visorbus_type.dev_attrs = visor_device_attrs;
+ rc = bus_register(&visorbus_type);
+ return rc;
+}
+
+/** Remove the one-and-only one instance of the visor bus type (visorbus_type).
+ */
+static void
+remove_bus_type(void)
+{
+ bus_unregister(&visorbus_type);
+}
+
+/** Remove all child visor bus device instances.
+ */
+static void
+remove_all_visor_devices(void)
+{
+ struct list_head *listentry, *listtmp;
+
+ list_for_each_safe(listentry, listtmp, &list_all_device_instances) {
+ struct visor_device *dev = list_entry(listentry,
+ struct visor_device,
+ list_all);
+ remove_visor_device(dev);
+ }
+}
+
+static bool entered_testing_mode;
+static struct visorchannel *test_channel_infos[MAXDEVICETEST];
+static unsigned long test_bus_nos[MAXDEVICETEST];
+static unsigned long test_dev_nos[MAXDEVICETEST];
+
+static void
+chipset_bus_create(struct visorchipset_bus_info *bus_info)
+{
+ struct visorbus_devdata *devdata;
+ int rc = -1;
+ u32 bus_no = bus_info->bus_no;
+
+ POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
+ devdata = create_bus_instance(bus_info);
+ if (!devdata)
+ goto away;
+ if (!visorchipset_set_bus_context(bus_info, devdata))
+ goto away;
+ POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
+ rc = 0;
+away:
+ if (rc < 0) {
+ POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
+ POSTCODE_SEVERITY_ERR);
+ return;
+ }
+ POSTCODE_LINUX_3(CHIPSET_INIT_SUCCESS_PC, bus_no,
+ POSTCODE_SEVERITY_INFO);
+ if (chipset_responders.bus_create)
+ (*chipset_responders.bus_create) (bus_info, rc);
+}
+
+static void
+chipset_bus_destroy(struct visorchipset_bus_info *bus_info)
+{
+ struct visorbus_devdata *devdata;
+ int rc = -1;
+
+ devdata = (struct visorbus_devdata *)(bus_info->bus_driver_context);
+ if (!devdata)
+ goto away;
+ remove_bus_instance(devdata);
+ if (!visorchipset_set_bus_context(bus_info, NULL))
+ goto away;
+ rc = 0;
+away:
+ if (rc < 0)
+ return;
+ if (chipset_responders.bus_destroy)
+ (*chipset_responders.bus_destroy)(bus_info, rc);
+}
+
+static void
+chipset_device_create(struct visorchipset_device_info *dev_info)
+{
+ struct visorchipset_bus_info bus_info;
+ struct visorbus_devdata *devdata = NULL;
+ int rc = -1;
+ u32 bus_no = dev_info->bus_no;
+ u32 dev_no = dev_info->dev_no;
+
+ POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
+ POSTCODE_SEVERITY_INFO);
+
+ if (entered_testing_mode)
+ return;
+ if (!visorchipset_get_bus_info(bus_no, &bus_info))
+ goto away;
+ if (visorbus_devicetest)
+ if (total_devices_created < MAXDEVICETEST) {
+ test_channel_infos[total_devices_created] =
+ dev_info->visorchannel;
+ test_bus_nos[total_devices_created] = bus_no;
+ test_dev_nos[total_devices_created] = dev_no;
+ }
+ POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
+ POSTCODE_SEVERITY_INFO);
+ rc = 0;
+away:
+ if (rc < 0) {
+ POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
+ POSTCODE_SEVERITY_ERR);
+ return;
+ }
+ devdata = (struct visorbus_devdata *)(bus_info.bus_driver_context);
+ rc = create_visor_device(devdata, dev_info, bus_info.partition_handle);
+ POSTCODE_LINUX_4(DEVICE_CREATE_SUCCESS_PC, dev_no, bus_no,
+ POSTCODE_SEVERITY_INFO);
+ if (rc < 0)
+ if (chipset_responders.device_create)
+ (*chipset_responders.device_create)(dev_info, rc);
+}
+
+static void
+chipset_device_destroy(struct visorchipset_device_info *dev_info)
+{
+ struct visor_device *dev;
+ int rc = -1;
+
+ if (entered_testing_mode)
+ return;
+ dev = find_visor_device_by_channel(dev_info->visorchannel);
+ if (!dev)
+ goto away;
+ rc = 0;
+away:
+ if (rc < 0)
+ return;
+
+ if (chipset_responders.device_destroy)
+ (*chipset_responders.device_destroy) (dev_info, rc);
+ remove_visor_device(dev);
+}
+
+/* This is the callback function specified for a function driver, to
+ * be called when a pending "pause device" operation has been
+ * completed.
+ */
+static void
+pause_state_change_complete(struct visor_device *dev, int status,
+ void *info)
+{
+ struct visorchipset_device_info *dev_info = info;
+
+ if (!dev->pausing)
+ return;
+
+ dev->pausing = false;
+ if (!chipset_responders.device_pause) /* this can never happen! */
+ return;
+
+ /* Notify the chipset driver that the pause is complete, which
+ * will presumably want to send some sort of response to the
+ * initiator. */
+ (*chipset_responders.device_pause) (dev_info, status);
+}
+
+/* This is the callback function specified for a function driver, to
+ * be called when a pending "resume device" operation has been
+ * completed.
+ */
+static void
+resume_state_change_complete(struct visor_device *dev, int status,
+ void *info)
+{
+ struct visorchipset_device_info *dev_info = info;
+
+ if (!dev->resuming)
+ return;
+
+ dev->resuming = false;
+ if (!chipset_responders.device_resume) /* this can never happen! */
+ return;
+
+ /* Notify the chipset driver that the resume is complete,
+ * which will presumably want to send some sort of response to
+ * the initiator. */
+ (*chipset_responders.device_resume) (dev_info, status);
+}
+
+/* Tell the subordinate function driver for a specific device to pause
+ * or resume that device. Result is returned asynchronously via a
+ * callback function.
+ */
+static void
+initiate_chipset_device_pause_resume(struct visorchipset_device_info *dev_info,
+ bool is_pause)
+{
+ struct visor_device *dev = NULL;
+ int rc = -1, x;
+ struct visor_driver *drv = NULL;
+ void (*notify_func)(struct visorchipset_device_info *dev_info,
+ int response) = NULL;
+
+ if (is_pause)
+ notify_func = chipset_responders.device_pause;
+ else
+ notify_func = chipset_responders.device_resume;
+ if (!notify_func)
+ goto away;
+
+ dev = find_visor_device_by_channel(dev_info->visorchannel);
+ if (!dev)
+ goto away;
+
+ drv = to_visor_driver(dev->device.driver);
+ if (!drv)
+ goto away;
+
+ if (dev->pausing || dev->resuming)
+ goto away;
+
+ /* Note that even though both drv->pause() and drv->resume
+ * specify a callback function, it is NOT necessary for us to
+ * increment our local module usage count. Reason is, there
+ * is already a linkage dependency between child function
+ * drivers and visorbus, so it is already IMPOSSIBLE to unload
+ * visorbus while child function drivers are still running.
+ */
+ if (is_pause) {
+ if (!drv->pause)
+ goto away;
+
+ dev->pausing = true;
+ x = drv->pause(dev, pause_state_change_complete,
+ (void *)dev_info);
+ } else {
+ /* This should be done at BUS resume time, but an
+ * existing problem prevents us from ever getting a bus
+ * resume... This hack would fail to work should we
+ * ever have a bus that contains NO devices, since we
+ * would never even get here in that case. */
+ fix_vbus_dev_info(dev);
+ if (!drv->resume)
+ goto away;
+
+ dev->resuming = true;
+ x = drv->resume(dev, resume_state_change_complete,
+ (void *)dev_info);
+ }
+ if (x < 0) {
+ if (is_pause)
+ dev->pausing = false;
+ else
+ dev->resuming = false;
+ goto away;
+ }
+ rc = 0;
+away:
+ if (rc < 0) {
+ if (notify_func)
+ (*notify_func)(dev_info, rc);
+ }
+}
+
+static void
+chipset_device_pause(struct visorchipset_device_info *dev_info)
+{
+ initiate_chipset_device_pause_resume(dev_info, true);
+}
+
+static void
+chipset_device_resume(struct visorchipset_device_info *dev_info)
+{
+ initiate_chipset_device_pause_resume(dev_info, false);
+}
+
+struct channel_size_info {
+ uuid_le guid;
+ unsigned long min_size;
+ unsigned long max_size;
+};
+
+int
+visorbus_init(void)
+{
+ int rc = 0;
+
+ POSTCODE_LINUX_3(DRIVER_ENTRY_PC, rc, POSTCODE_SEVERITY_INFO);
+ bus_device_info_init(&clientbus_driverinfo,
+ "clientbus", "visorbus",
+ VERSION, NULL);
+
+ /* process module options */
+
+ if (visorbus_devicetest > MAXDEVICETEST)
+ visorbus_devicetest = MAXDEVICETEST;
+
+ rc = create_bus_type();
+ if (rc < 0) {
+ POSTCODE_LINUX_2(BUS_CREATE_ENTRY_PC, DIAG_SEVERITY_ERR);
+ goto away;
+ }
+
+ periodic_dev_workqueue = create_singlethread_workqueue("visorbus_dev");
+ if (!periodic_dev_workqueue) {
+ POSTCODE_LINUX_2(CREATE_WORKQUEUE_PC, DIAG_SEVERITY_ERR);
+ rc = -ENOMEM;
+ goto away;
+ }
+
+ /* This enables us to receive notifications when devices appear for
+ * which this service partition is to be a server for.
+ */
+ visorchipset_register_busdev(&chipset_notifiers,
+ &chipset_responders,
+ &chipset_driverinfo);
+
+ rc = 0;
+
+away:
+ if (rc)
+ POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
+ POSTCODE_SEVERITY_ERR);
+ return rc;
+}
+
+void
+visorbus_exit(void)
+{
+ struct list_head *listentry, *listtmp;
+
+ visorchipset_register_busdev(NULL, NULL, NULL);
+ remove_all_visor_devices();
+
+ flush_workqueue(periodic_dev_workqueue); /* better not be any work! */
+ destroy_workqueue(periodic_dev_workqueue);
+ periodic_dev_workqueue = NULL;
+
+ if (periodic_test_workqueue) {
+ cancel_delayed_work(&periodic_work);
+ flush_workqueue(periodic_test_workqueue);
+ destroy_workqueue(periodic_test_workqueue);
+ periodic_test_workqueue = NULL;
+ }
+
+ list_for_each_safe(listentry, listtmp, &list_all_bus_instances) {
+ struct visorbus_devdata *devdata = list_entry(listentry,
+ struct
+ visorbus_devdata,
+ list_all);
+ remove_bus_instance(devdata);
+ }
+ remove_bus_type();
+}
+
+module_param_named(debug, visorbus_debug, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_debug, "1 to debug");
+
+module_param_named(forcematch, visorbus_forcematch, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_forcematch,
+ "1 to force a successful dev <--> drv match");
+
+module_param_named(forcenomatch, visorbus_forcenomatch, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_forcenomatch,
+ "1 to force an UNsuccessful dev <--> drv match");
+
+module_param_named(devicetest, visorbus_devicetest, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_devicetest,
+ "non-0 to just test device creation and destruction");
+
+module_param_named(debugref, visorbus_debugref, int, S_IRUGO);
+MODULE_PARM_DESC(visorbus_debugref, "1 to debug reference counting");
+
+MODULE_AUTHOR("Unisys");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Supervisor bus driver for service partition: ver " VERSION);
+MODULE_VERSION(VERSION);
diff --git a/drivers/staging/unisys/visorbus/visorbus_private.h b/drivers/staging/unisys/visorbus/visorbus_private.h
new file mode 100644
index 00000000000000..f371f9d646a561
--- /dev/null
+++ b/drivers/staging/unisys/visorbus/visorbus_private.h
@@ -0,0 +1,142 @@
+/* visorchipset.h
+ *
+ * Copyright (C) 2010 - 2013 UNISYS CORPORATION
+ * 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 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, GOOD TITLE or
+ * NON INFRINGEMENT. See the GNU General Public License for more
+ * details.
+ */
+
+#ifndef __VISORCHIPSET_H__
+#define __VISORCHIPSET_H__
+
+#include <linux/uuid.h>
+
+#include "channel.h"
+#include "controlvmchannel.h"
+#include "vbusdeviceinfo.h"
+#include "vbushelper.h"
+
+struct visorchannel;
+
+enum visorchipset_addresstype {
+ /** address is guest physical, but outside of the physical memory
+ * region that is controlled by the running OS (this is the normal
+ * address type for Supervisor channels)
+ */
+ ADDRTYPE_LOCALPHYSICAL,
+
+ /** address is guest physical, and withIN the confines of the
+ * physical memory controlled by the running OS.
+ */
+ ADDRTYPE_LOCALTEST,
+};
+
+/** Attributes for a particular Supervisor device.
+ * Any visorchipset client can query these attributes using
+ * visorchipset_get_client_device_info() or
+ * visorchipset_get_server_device_info().
+ */
+struct visorchipset_device_info {
+ struct list_head entry;
+ u32 bus_no;
+ u32 dev_no;
+ uuid_le dev_inst_uuid;
+ struct visorchipset_state state;
+ struct visorchannel *visorchannel;
+ uuid_le channel_type_guid;
+ u32 reserved1; /* control_vm_id */
+ u64 reserved2;
+ u32 switch_no; /* when devState.attached==1 */
+ u32 internal_port_no; /* when devState.attached==1 */
+ struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM_MESSAGE */
+ /** For private use by the bus driver */
+ void *bus_driver_context;
+};
+
+/** Attributes for a particular Supervisor bus.
+ * (For a service partition acting as the server for buses/devices, there
+ * is a 1-to-1 relationship between busses and guest partitions.)
+ * Any visorchipset client can query these attributes using
+ * visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
+ */
+struct visorchipset_bus_info {
+ struct list_head entry;
+ u32 bus_no;
+ struct visorchipset_state state;
+ struct visorchannel *visorchannel;
+ uuid_le partition_uuid;
+ u64 partition_handle;
+ u8 *name; /* UTF8 */
+ u8 *description; /* UTF8 */
+ u64 reserved1;
+ u32 reserved2;
+ struct {
+ u32 server:1;
+ /* Add new fields above. */
+ /* Remaining bits in this 32-bit word are unused. */
+ } flags;
+ struct controlvm_message_header *pending_msg_hdr;/* CONTROLVM MsgHdr */
+ /** For private use by the bus driver */
+ void *bus_driver_context;
+};
+
+/* These functions will be called from within visorchipset when certain
+ * events happen. (The implementation of these functions is outside of
+ * visorchipset.)
+ */
+struct visorchipset_busdev_notifiers {
+ void (*bus_create)(struct visorchipset_bus_info *bus_info);
+ void (*bus_destroy)(struct visorchipset_bus_info *bus_info);
+ void (*device_create)(struct visorchipset_device_info *bus_info);
+ void (*device_destroy)(struct visorchipset_device_info *bus_info);
+ void (*device_pause)(struct visorchipset_device_info *bus_info);
+ void (*device_resume)(struct visorchipset_device_info *bus_info);
+};
+
+/* These functions live inside visorchipset, and will be called to indicate
+ * responses to specific events (by code outside of visorchipset).
+ * For now, the value for each response is simply either:
+ * 0 = it worked
+ * -1 = it failed
+ */
+struct visorchipset_busdev_responders {
+ void (*bus_create)(struct visorchipset_bus_info *p, int response);
+ void (*bus_destroy)(struct visorchipset_bus_info *p, int response);
+ void (*device_create)(struct visorchipset_device_info *p, int response);
+ void (*device_destroy)(struct visorchipset_device_info *p,
+ int response);
+ void (*device_pause)(struct visorchipset_device_info *p, int response);
+ void (*device_resume)(struct visorchipset_device_info *p, int response);
+};
+
+/** Register functions (in the bus driver) to get called by visorchipset
+ * whenever a bus or device appears for which this guest is to be the
+ * client for. visorchipset will fill in <responders>, to indicate
+ * functions the bus driver should call to indicate message responses.
+ */
+void
+visorchipset_register_busdev(
+ struct visorchipset_busdev_notifiers *notifiers,
+ struct visorchipset_busdev_responders *responders,
+ struct ultra_vbus_deviceinfo *driver_info);
+
+bool visorchipset_get_bus_info(u32 bus_no,
+ struct visorchipset_bus_info *bus_info);
+bool visorchipset_get_device_info(u32 bus_no, u32 dev_no,
+ struct visorchipset_device_info *dev_info);
+bool visorchipset_set_bus_context(struct visorchipset_bus_info *bus_info,
+ void *context);
+
+/* visorbus init and exit functions */
+int visorbus_init(void);
+void visorbus_exit(void);
+#endif
diff --git a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c b/drivers/staging/unisys/visorbus/visorchannel.c
index 7a9a7242f75d92..e0dfaa9c955d5c 100644
--- a/drivers/staging/unisys/visorchannel/visorchannel_funcs.c
+++ b/drivers/staging/unisys/visorbus/visorchannel.c
@@ -17,23 +17,24 @@
/*
* This provides Supervisor channel communication primitives, which are
- * independent of the mechanism used to access the channel data. All channel
- * data is accessed using the memregion abstraction. (memregion has both
- * a CM2 implementation and a direct memory implementation.)
+ * independent of the mechanism used to access the channel data.
*/
-#include "globals.h"
-#include "visorchannel.h"
+#include "version.h"
+#include "visorbus.h"
#include <linux/uuid.h>
+#include "controlvmchannel.h"
#define MYDRVNAME "visorchannel"
struct visorchannel {
- struct memregion *memregion; /* from visor_memregion_create() */
+ u64 physaddr;
+ ulong nbytes;
+ void __iomem *mapped;
struct channel_header chan_hdr;
uuid_le guid;
ulong size;
- BOOL needs_lock; /* channel creator knows if more than one
+ bool needs_lock; /* channel creator knows if more than one
* thread will be inserting or removing */
spinlock_t insert_lock; /* protect head writes in chan_hdr */
spinlock_t remove_lock; /* protect tail writes in chan_hdr */
@@ -44,126 +45,114 @@ struct visorchannel {
struct signal_queue_header event_queue;
struct signal_queue_header ack_queue;
} safe_uis_queue;
+ uuid_le type;
+ uuid_le inst;
};
/* Creates the struct visorchannel abstraction for a data area in memory,
* but does NOT modify this data area.
*/
static struct visorchannel *
-visorchannel_create_guts(HOSTADDRESS physaddr, ulong channel_bytes,
- struct visorchannel *parent, ulong off, uuid_le guid,
- BOOL needs_lock)
+visorchannel_create_guts(u64 physaddr, unsigned long channel_bytes,
+ gfp_t gfp, unsigned long off,
+ uuid_le guid, bool needs_lock)
{
- struct visorchannel *p = NULL;
- void *rc = NULL;
+ struct visorchannel *channel;
+ int err;
+ size_t size = sizeof(struct channel_header);
- p = kmalloc(sizeof(*p), GFP_KERNEL|__GFP_NORETRY);
- if (!p) {
- rc = NULL;
+ if (physaddr == 0)
+ return NULL;
+
+ channel = kzalloc(sizeof(*channel), gfp);
+ if (!channel)
goto cleanup;
- }
- p->memregion = NULL;
- p->needs_lock = needs_lock;
- spin_lock_init(&p->insert_lock);
- spin_lock_init(&p->remove_lock);
-
- /* prepare chan_hdr (abstraction to read/write channel memory) */
- if (!parent)
- p->memregion =
- visor_memregion_create(physaddr,
- sizeof(struct channel_header));
- else
- p->memregion =
- visor_memregion_create_overlapped(parent->memregion,
- off, sizeof(struct channel_header));
- if (!p->memregion) {
- rc = NULL;
+
+ channel->needs_lock = needs_lock;
+ spin_lock_init(&channel->insert_lock);
+ spin_lock_init(&channel->remove_lock);
+
+ if (!request_mem_region(physaddr, size, MYDRVNAME))
goto cleanup;
- }
- if (visor_memregion_read(p->memregion, 0, &p->chan_hdr,
- sizeof(struct channel_header)) < 0) {
- rc = NULL;
+
+ channel->mapped = ioremap_cache(physaddr, size);
+ if (!channel->mapped) {
+ release_mem_region(physaddr, size);
goto cleanup;
}
+
+ channel->physaddr = physaddr;
+ channel->nbytes = size;
+
+ err = visorchannel_read(channel, 0, &channel->chan_hdr,
+ sizeof(struct channel_header));
+ if (err)
+ goto cleanup;
+
+ /* we had better be a CLIENT of this channel */
if (channel_bytes == 0)
- /* we had better be a CLIENT of this channel */
- channel_bytes = (ulong)p->chan_hdr.size;
+ channel_bytes = (ulong)channel->chan_hdr.size;
if (uuid_le_cmp(guid, NULL_UUID_LE) == 0)
- /* we had better be a CLIENT of this channel */
- guid = p->chan_hdr.chtype;
- if (visor_memregion_resize(p->memregion, channel_bytes) < 0) {
- rc = NULL;
+ guid = channel->chan_hdr.chtype;
+
+ iounmap(channel->mapped);
+ release_mem_region(channel->physaddr, channel->nbytes);
+ channel->mapped = NULL;
+ if (!request_mem_region(channel->physaddr, channel_bytes, MYDRVNAME))
+ goto cleanup;
+
+ channel->mapped = ioremap_cache(channel->physaddr, channel_bytes);
+ if (!channel->mapped) {
+ release_mem_region(channel->physaddr, channel_bytes);
goto cleanup;
}
- p->size = channel_bytes;
- p->guid = guid;
- rc = p;
-cleanup:
+ channel->nbytes = channel_bytes;
- if (!rc) {
- if (!p) {
- visorchannel_destroy(p);
- p = NULL;
- }
- }
- return rc;
+ channel->size = channel_bytes;
+ channel->guid = guid;
+ return channel;
+
+cleanup:
+ visorchannel_destroy(channel);
+ return NULL;
}
struct visorchannel *
-visorchannel_create(HOSTADDRESS physaddr, ulong channel_bytes, uuid_le guid)
+visorchannel_create(u64 physaddr, unsigned long channel_bytes,
+ gfp_t gfp, uuid_le guid)
{
- return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
- FALSE);
+ return visorchannel_create_guts(physaddr, channel_bytes, gfp, 0, guid,
+ false);
}
EXPORT_SYMBOL_GPL(visorchannel_create);
struct visorchannel *
-visorchannel_create_with_lock(HOSTADDRESS physaddr, ulong channel_bytes,
- uuid_le guid)
+visorchannel_create_with_lock(u64 physaddr, unsigned long channel_bytes,
+ gfp_t gfp, uuid_le guid)
{
- return visorchannel_create_guts(physaddr, channel_bytes, NULL, 0, guid,
- TRUE);
+ return visorchannel_create_guts(physaddr, channel_bytes, gfp, 0, guid,
+ true);
}
EXPORT_SYMBOL_GPL(visorchannel_create_with_lock);
-struct visorchannel *
-visorchannel_create_overlapped(ulong channel_bytes,
- struct visorchannel *parent, ulong off,
- uuid_le guid)
-{
- return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
- FALSE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_overlapped);
-
-struct visorchannel *
-visorchannel_create_overlapped_with_lock(ulong channel_bytes,
- struct visorchannel *parent, ulong off,
- uuid_le guid)
-{
- return visorchannel_create_guts(0, channel_bytes, parent, off, guid,
- TRUE);
-}
-EXPORT_SYMBOL_GPL(visorchannel_create_overlapped_with_lock);
-
void
visorchannel_destroy(struct visorchannel *channel)
{
if (!channel)
return;
- if (channel->memregion) {
- visor_memregion_destroy(channel->memregion);
- channel->memregion = NULL;
+ if (channel->mapped) {
+ iounmap(channel->mapped);
+ release_mem_region(channel->physaddr, channel->nbytes);
}
kfree(channel);
}
EXPORT_SYMBOL_GPL(visorchannel_destroy);
-HOSTADDRESS
+u64
visorchannel_get_physaddr(struct visorchannel *channel)
{
- return visor_memregion_get_physaddr(channel->memregion);
+ return channel->physaddr;
}
EXPORT_SYMBOL_GPL(visorchannel_get_physaddr);
@@ -196,13 +185,22 @@ visorchannel_zoneid(struct visorchannel *channel, char *s)
}
EXPORT_SYMBOL_GPL(visorchannel_zoneid);
-HOSTADDRESS
+u64
visorchannel_get_clientpartition(struct visorchannel *channel)
{
return channel->chan_hdr.partition_handle;
}
EXPORT_SYMBOL_GPL(visorchannel_get_clientpartition);
+int
+visorchannel_set_clientpartition(struct visorchannel *channel,
+ u64 partition_handle)
+{
+ channel->chan_hdr.partition_handle = partition_handle;
+ return 0;
+}
+EXPORT_SYMBOL_GPL(visorchannel_set_clientpartition);
+
uuid_le
visorchannel_get_uuid(struct visorchannel *channel)
{
@@ -210,25 +208,16 @@ visorchannel_get_uuid(struct visorchannel *channel)
}
EXPORT_SYMBOL_GPL(visorchannel_get_uuid);
-struct memregion *
-visorchannel_get_memregion(struct visorchannel *channel)
-{
- return channel->memregion;
-}
-EXPORT_SYMBOL_GPL(visorchannel_get_memregion);
-
int
visorchannel_read(struct visorchannel *channel, ulong offset,
void *local, ulong nbytes)
{
- int rc = visor_memregion_read(channel->memregion, offset,
- local, nbytes);
- if ((rc >= 0) && (offset == 0) &&
- (nbytes >= sizeof(struct channel_header))) {
- memcpy(&channel->chan_hdr, local,
- sizeof(struct channel_header));
- }
- return rc;
+ if (offset + nbytes > channel->nbytes)
+ return -EIO;
+
+ memcpy_fromio(local, channel->mapped + offset, nbytes);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(visorchannel_read);
@@ -236,10 +225,20 @@ int
visorchannel_write(struct visorchannel *channel, ulong offset,
void *local, ulong nbytes)
{
- if (offset == 0 && nbytes >= sizeof(struct channel_header))
- memcpy(&channel->chan_hdr, local,
- sizeof(struct channel_header));
- return visor_memregion_write(channel->memregion, offset, local, nbytes);
+ size_t chdr_size = sizeof(struct channel_header);
+ size_t copy_size;
+
+ if (offset + nbytes > channel->nbytes)
+ return -EIO;
+
+ if (offset < chdr_size) {
+ copy_size = min(chdr_size, nbytes) - offset;
+ memcpy(&channel->chan_hdr + offset, local, copy_size);
+ }
+
+ memcpy_toio(channel->mapped + offset, local, nbytes);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(visorchannel_write);
@@ -247,38 +246,35 @@ int
visorchannel_clear(struct visorchannel *channel, ulong offset, u8 ch,
ulong nbytes)
{
- int rc = -1;
- int bufsize = 65536;
+ int err;
+ int bufsize = PAGE_SIZE;
int written = 0;
- u8 *buf = vmalloc(bufsize);
+ u8 *buf;
+ buf = (u8 *) __get_free_page(GFP_KERNEL);
if (!buf)
- goto cleanup;
+ return -ENOMEM;
memset(buf, ch, bufsize);
+
while (nbytes > 0) {
- ulong thisbytes = bufsize;
- int x = -1;
+ int thisbytes = bufsize;
if (nbytes < thisbytes)
thisbytes = nbytes;
- x = visor_memregion_write(channel->memregion, offset + written,
- buf, thisbytes);
- if (x < 0) {
- rc = x;
+ err = visorchannel_write(channel, offset + written,
+ buf, thisbytes);
+ if (err)
goto cleanup;
- }
+
written += thisbytes;
nbytes -= thisbytes;
}
- rc = 0;
+ err = 0;
cleanup:
- if (buf) {
- vfree(buf);
- buf = NULL;
- }
- return rc;
+ free_page((unsigned long) buf);
+ return err;
}
EXPORT_SYMBOL_GPL(visorchannel_clear);
@@ -306,108 +302,77 @@ EXPORT_SYMBOL_GPL(visorchannel_get_header);
/** Write the contents of a specific field within a SIGNAL_QUEUE_HEADER back
* into host memory
*/
-#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \
- (visor_memregion_write(channel->memregion, \
- SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
- offsetof(struct signal_queue_header, FIELD),\
- &((sig_hdr)->FIELD), \
- sizeof((sig_hdr)->FIELD)) >= 0)
-
-static BOOL
+#define SIG_WRITE_FIELD(channel, queue, sig_hdr, FIELD) \
+ (visorchannel_write(channel, \
+ SIG_QUEUE_OFFSET(&channel->chan_hdr, queue)+ \
+ offsetof(struct signal_queue_header, FIELD), \
+ &((sig_hdr)->FIELD), \
+ sizeof((sig_hdr)->FIELD)) >= 0)
+
+static bool
sig_read_header(struct visorchannel *channel, u32 queue,
struct signal_queue_header *sig_hdr)
{
- BOOL rc = FALSE;
+ int err;
if (channel->chan_hdr.ch_space_offset < sizeof(struct channel_header))
- goto cleanup;
+ return false;
/* Read the appropriate SIGNAL_QUEUE_HEADER into local memory. */
+ err = visorchannel_read(channel,
+ SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
+ sig_hdr, sizeof(struct signal_queue_header));
+ if (err)
+ return false;
- if (visor_memregion_read(channel->memregion,
- SIG_QUEUE_OFFSET(&channel->chan_hdr, queue),
- sig_hdr,
- sizeof(struct signal_queue_header)) < 0) {
- goto cleanup;
- }
- rc = TRUE;
-cleanup:
- return rc;
+ return true;
}
-static BOOL
-sig_do_data(struct visorchannel *channel, u32 queue,
- struct signal_queue_header *sig_hdr, u32 slot, void *data,
- BOOL is_write)
+static inline bool
+sig_read_data(struct visorchannel *channel, u32 queue,
+ struct signal_queue_header *sig_hdr, u32 slot, void *data)
{
- BOOL rc = FALSE;
+ int err;
int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
sig_hdr, slot);
- if (is_write) {
- if (visor_memregion_write(channel->memregion,
- signal_data_offset,
- data, sig_hdr->signal_size) < 0) {
- goto cleanup;
- }
- } else {
- if (visor_memregion_read(channel->memregion, signal_data_offset,
- data, sig_hdr->signal_size) < 0) {
- goto cleanup;
- }
- }
- rc = TRUE;
-cleanup:
- return rc;
-}
-static inline BOOL
-sig_read_data(struct visorchannel *channel, u32 queue,
- struct signal_queue_header *sig_hdr, u32 slot, void *data)
-{
- return sig_do_data(channel, queue, sig_hdr, slot, data, FALSE);
+ err = visorchannel_read(channel, signal_data_offset,
+ data, sig_hdr->signal_size);
+ if (err)
+ return false;
+
+ return true;
}
-static inline BOOL
+static inline bool
sig_write_data(struct visorchannel *channel, u32 queue,
struct signal_queue_header *sig_hdr, u32 slot, void *data)
{
- return sig_do_data(channel, queue, sig_hdr, slot, data, TRUE);
-}
-
-static inline unsigned char
-safe_sig_queue_validate(struct signal_queue_header *psafe_sqh,
- struct signal_queue_header *punsafe_sqh,
- u32 *phead, u32 *ptail)
-{
- if ((*phead >= psafe_sqh->max_slots) ||
- (*ptail >= psafe_sqh->max_slots)) {
- /* Choose 0 or max, maybe based on current tail value */
- *phead = 0;
- *ptail = 0;
+ int err;
+ int signal_data_offset = SIG_DATA_OFFSET(&channel->chan_hdr, queue,
+ sig_hdr, slot);
- /* Sync with client as necessary */
- punsafe_sqh->head = *phead;
- punsafe_sqh->tail = *ptail;
+ err = visorchannel_write(channel, signal_data_offset,
+ data, sig_hdr->signal_size);
+ if (err)
+ return false;
- return 0;
- }
- return 1;
-} /* end safe_sig_queue_validate */
+ return true;
+}
-static BOOL
+static bool
signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
{
struct signal_queue_header sig_hdr;
if (!sig_read_header(channel, queue, &sig_hdr))
- return FALSE;
+ return false;
if (sig_hdr.head == sig_hdr.tail)
- return FALSE; /* no signals to remove */
+ return false; /* no signals to remove */
sig_hdr.tail = (sig_hdr.tail + 1) % sig_hdr.max_slots;
- if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg)) {
- return FALSE;
- }
+ if (!sig_read_data(channel, queue, &sig_hdr, sig_hdr.tail, msg))
+ return false;
sig_hdr.num_received++;
/* For each data field in SIGNAL_QUEUE_HEADER that was modified,
@@ -415,16 +380,16 @@ signalremove_inner(struct visorchannel *channel, u32 queue, void *msg)
*/
mb(); /* required for channel synch */
if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, tail))
- return FALSE;
+ return false;
if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_received))
- return FALSE;
- return TRUE;
+ return false;
+ return true;
}
-BOOL
+bool
visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
{
- BOOL rc;
+ bool rc;
if (channel->needs_lock) {
spin_lock(&channel->remove_lock);
@@ -438,29 +403,28 @@ visorchannel_signalremove(struct visorchannel *channel, u32 queue, void *msg)
}
EXPORT_SYMBOL_GPL(visorchannel_signalremove);
-static BOOL
+static bool
signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
{
struct signal_queue_header sig_hdr;
if (!sig_read_header(channel, queue, &sig_hdr))
- return FALSE;
+ return false;
sig_hdr.head = ((sig_hdr.head + 1) % sig_hdr.max_slots);
if (sig_hdr.head == sig_hdr.tail) {
sig_hdr.num_overflows++;
- visor_memregion_write(channel->memregion,
- SIG_QUEUE_OFFSET(&channel->chan_hdr,
- queue) +
- offsetof(struct signal_queue_header,
- num_overflows),
- &(sig_hdr.num_overflows),
- sizeof(sig_hdr.num_overflows));
- return FALSE;
+ visorchannel_write(channel,
+ SIG_QUEUE_OFFSET(&channel->chan_hdr, queue) +
+ offsetof(struct signal_queue_header,
+ num_overflows),
+ &(sig_hdr.num_overflows),
+ sizeof(sig_hdr.num_overflows));
+ return false;
}
if (!sig_write_data(channel, queue, &sig_hdr, sig_hdr.head, msg))
- return FALSE;
+ return false;
sig_hdr.num_sent++;
@@ -469,18 +433,17 @@ signalinsert_inner(struct visorchannel *channel, u32 queue, void *msg)
*/
mb(); /* required for channel synch */
if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, head))
- return FALSE;
- if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent)) {
- return FALSE;
- }
+ return false;
+ if (!SIG_WRITE_FIELD(channel, queue, &sig_hdr, num_sent))
+ return false;
- return TRUE;
+ return true;
}
-BOOL
+bool
visorchannel_signalinsert(struct visorchannel *channel, u32 queue, void *msg)
{
- BOOL rc;
+ bool rc;
if (channel->needs_lock) {
spin_lock(&channel->insert_lock);
@@ -552,9 +515,8 @@ void
visorchannel_debug(struct visorchannel *channel, int num_queues,
struct seq_file *seq, u32 off)
{
- HOSTADDRESS addr = 0;
+ u64 addr = 0;
ulong nbytes = 0, nbytes_region = 0;
- struct memregion *memregion = NULL;
struct channel_header hdr;
struct channel_header *phdr = &hdr;
int i = 0;
@@ -562,12 +524,9 @@ visorchannel_debug(struct visorchannel *channel, int num_queues,
if (!channel)
return;
- memregion = channel->memregion;
- if (!memregion)
- return;
- addr = visor_memregion_get_physaddr(memregion);
- nbytes_region = visor_memregion_get_nbytes(memregion);
+ addr = visorchannel_get_physaddr(channel);
+ nbytes_region = visorchannel_get_nbytes(channel);
errcode = visorchannel_read(channel, off,
phdr, sizeof(struct channel_header));
if (errcode < 0) {
@@ -626,40 +585,3 @@ visorchannel_debug(struct visorchannel *channel, int num_queues,
addr + off, nbytes);
}
EXPORT_SYMBOL_GPL(visorchannel_debug);
-
-void
-visorchannel_dump_section(struct visorchannel *chan, char *s,
- int off, int len, struct seq_file *seq)
-{
- char *buf, *tbuf, *fmtbuf;
- int fmtbufsize = 0;
- int i;
- int errcode = 0;
-
- fmtbufsize = 100 * COVQ(len, 16);
- buf = kmalloc(len, GFP_KERNEL|__GFP_NORETRY);
- if (!buf)
- return;
- fmtbuf = kmalloc(fmtbufsize, GFP_KERNEL|__GFP_NORETRY);
- if (!fmtbuf)
- goto fmt_failed;
-
- errcode = visorchannel_read(chan, off, buf, len);
- if (errcode < 0)
- goto read_failed;
- seq_printf(seq, "channel %s:\n", s);
- tbuf = buf;
- while (len > 0) {
- i = (len < 16) ? len : 16;
- hex_dump_to_buffer(tbuf, i, 16, 1, fmtbuf, fmtbufsize, TRUE);
- seq_printf(seq, "%s\n", fmtbuf);
- tbuf += 16;
- len -= 16;
- }
-
-read_failed:
- kfree(fmtbuf);
-fmt_failed:
- kfree(buf);
-}
-EXPORT_SYMBOL_GPL(visorchannel_dump_section);
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_main.c b/drivers/staging/unisys/visorbus/visorchipset.c
index f2663d2c753003..247888970d91e1 100644
--- a/drivers/staging/unisys/visorchipset/visorchipset_main.c
+++ b/drivers/staging/unisys/visorbus/visorchipset.c
@@ -15,27 +15,28 @@
* details.
*/
-#include "globals.h"
-#include "visorchipset.h"
-#include "procobjecttree.h"
-#include "visorchannel.h"
-#include "periodic_work.h"
-#include "file.h"
-#include "parser.h"
-#include "uisutils.h"
-#include "controlvmcompletionstatus.h"
-#include "guestlinuxdebug.h"
-
+#include <linux/acpi.h>
+#include <linux/cdev.h>
+#include <linux/ctype.h>
+#include <linux/fs.h>
+#include <linux/mm.h>
#include <linux/nls.h>
#include <linux/netdevice.h>
#include <linux/platform_device.h>
#include <linux/uuid.h>
+#include <linux/crash_dump.h>
+
+#include "channel_guid.h"
+#include "controlvmchannel.h"
+#include "controlvmcompletionstatus.h"
+#include "guestlinuxdebug.h"
+#include "periodic_work.h"
+#include "version.h"
+#include "visorbus.h"
+#include "visorbus_private.h"
+#include "vmcallinterface.h"
#define CURRENT_FILE_PC VISOR_CHIPSET_PC_visorchipset_main_c
-#define TEST_VNIC_PHYSITF "eth0" /* physical network itf for
- * vnic loopback test */
-#define TEST_VNIC_SWITCHNO 1
-#define TEST_VNIC_BUSNO 9
#define MAX_NAME_SIZE 128
#define MAX_IP_SIZE 50
@@ -43,52 +44,79 @@
#define POLLJIFFIES_CONTROLVMCHANNEL_FAST 1
#define POLLJIFFIES_CONTROLVMCHANNEL_SLOW 100
+#define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128)
+
+#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET 0x00000000
+
+
+#define UNISYS_SPAR_LEAF_ID 0x40000000
+
+/* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */
+#define UNISYS_SPAR_ID_EBX 0x73696e55
+#define UNISYS_SPAR_ID_ECX 0x70537379
+#define UNISYS_SPAR_ID_EDX 0x34367261
+
+/*
+ * Module parameters
+ */
+static int visorchipset_major;
+static int visorchipset_visorbusregwait = 1; /* default is on */
+static int visorchipset_holdchipsetready;
+static unsigned long controlvm_payload_bytes_buffered;
+
+static int
+visorchipset_open(struct inode *inode, struct file *file)
+{
+ unsigned minor_number = iminor(inode);
+
+ if (minor_number)
+ return -ENODEV;
+ file->private_data = NULL;
+ return 0;
+}
+
+static int
+visorchipset_release(struct inode *inode, struct file *file)
+{
+ return 0;
+}
+
/* When the controlvm channel is idle for at least MIN_IDLE_SECONDS,
* we switch to slow polling mode. As soon as we get a controlvm
* message, we switch back to fast polling mode.
*/
#define MIN_IDLE_SECONDS 10
-static ulong poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
-static ulong most_recent_message_jiffies; /* when we got our last
+static unsigned long poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+static unsigned long most_recent_message_jiffies; /* when we got our last
* controlvm message */
-static inline char *
-NONULLSTR(char *s)
-{
- if (s)
- return s;
- return "";
-}
-
-static int serverregistered;
-static int clientregistered;
+static int visorbusregistered;
#define MAX_CHIPSET_EVENTS 2
static u8 chipset_events[MAX_CHIPSET_EVENTS] = { 0, 0 };
+struct parser_context {
+ unsigned long allocbytes;
+ unsigned long param_bytes;
+ u8 *curr;
+ unsigned long bytes_remaining;
+ bool byte_stream;
+ char data[0];
+};
+
static struct delayed_work periodic_controlvm_work;
static struct workqueue_struct *periodic_controlvm_workqueue;
static DEFINE_SEMAPHORE(notifier_lock);
-static struct controlvm_message_header g_diag_msg_hdr;
+static struct cdev file_cdev;
+static struct visorchannel **file_controlvm_channel;
static struct controlvm_message_header g_chipset_msg_hdr;
-static struct controlvm_message_header g_del_dump_msg_hdr;
static const uuid_le spar_diag_pool_channel_protocol_uuid =
SPAR_DIAG_POOL_CHANNEL_PROTOCOL_UUID;
/* 0xffffff is an invalid Bus/Device number */
-static ulong g_diagpool_bus_no = 0xffffff;
-static ulong g_diagpool_dev_no = 0xffffff;
+static u32 g_diagpool_bus_no = 0xffffff;
+static u32 g_diagpool_dev_no = 0xffffff;
static struct controlvm_message_packet g_devicechangestate_packet;
-/* Only VNIC and VHBA channels are sent to visorclientbus (aka
- * "visorhackbus")
- */
-#define FOR_VISORHACKBUS(channel_type_guid) \
- (((uuid_le_cmp(channel_type_guid,\
- spar_vnic_channel_protocol_uuid) == 0) ||\
- (uuid_le_cmp(channel_type_guid,\
- spar_vhba_channel_protocol_uuid) == 0)))
-#define FOR_VISORBUS(channel_type_guid) (!(FOR_VISORHACKBUS(channel_type_guid)))
-
#define is_diagpool_channel(channel_type_guid) \
(uuid_le_cmp(channel_type_guid,\
spar_diag_pool_channel_protocol_uuid) == 0)
@@ -99,26 +127,14 @@ static LIST_HEAD(dev_info_list);
static struct visorchannel *controlvm_channel;
/* Manages the request payload in the controlvm channel */
-static struct controlvm_payload_info {
+struct visor_controlvm_payload_info {
u8 __iomem *ptr; /* pointer to base address of payload pool */
u64 offset; /* offset from beginning of controlvm
* channel to beginning of payload * pool */
u32 bytes; /* number of bytes in payload pool */
-} controlvm_payload_info;
+};
-/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
- * CONTROLVM_DUMP_GETTEXTDUMP / CONTROLVM_DUMP_COMPLETE conversation.
- */
-static struct livedump_info {
- struct controlvm_message_header dumpcapture_header;
- struct controlvm_message_header gettextdump_header;
- struct controlvm_message_header dumpcomplete_header;
- BOOL gettextdump_outstanding;
- u32 crc32;
- ulong length;
- atomic_t buffers_in_use;
- ulong destination;
-} livedump_info;
+static struct visor_controlvm_payload_info controlvm_payload_info;
/* The following globals are used to handle the scenario where we are unable to
* offload the payload from a controlvm message due to memory requirements. In
@@ -126,14 +142,7 @@ static struct livedump_info {
* process it again the next time controlvm_periodic_work() runs.
*/
static struct controlvm_message controlvm_pending_msg;
-static BOOL controlvm_pending_msg_valid = FALSE;
-
-/* Pool of struct putfile_buffer_entry, for keeping track of pending (incoming)
- * TRANSMIT_FILE PutFile payloads.
- */
-static struct kmem_cache *putfile_buffer_list_pool;
-static const char putfile_buffer_list_pool_name[] =
- "controlvm_putfile_buffer_list_pool";
+static bool controlvm_pending_msg_valid;
/* This identifies a data buffer that has been received via a controlvm messages
* in a remote --> local CONTROLVM_TRANSMIT_FILE conversation.
@@ -203,8 +212,6 @@ struct putfile_request {
int completion_status;
};
-static atomic_t visorchipset_cache_buffers_in_use = ATOMIC_INIT(0);
-
struct parahotplug_request {
struct list_head list;
int id;
@@ -219,14 +226,20 @@ static void parahotplug_process_list(void);
/* Manages the info for a CONTROLVM_DUMP_CAPTURESTATE /
* CONTROLVM_REPORTEVENT.
*/
-static struct visorchipset_busdev_notifiers busdev_server_notifiers;
-static struct visorchipset_busdev_notifiers busdev_client_notifiers;
+static struct visorchipset_busdev_notifiers busdev_notifiers;
-static void bus_create_response(ulong bus_no, int response);
-static void bus_destroy_response(ulong bus_no, int response);
-static void device_create_response(ulong bus_no, ulong dev_no, int response);
-static void device_destroy_response(ulong bus_no, ulong dev_no, int response);
-static void device_resume_response(ulong bus_no, ulong dev_no, int response);
+static void bus_create_response(struct visorchipset_bus_info *p, int response);
+static void bus_destroy_response(struct visorchipset_bus_info *p, int response);
+static void device_create_response(struct visorchipset_device_info *p,
+ int response);
+static void device_destroy_response(struct visorchipset_device_info *p,
+ int response);
+static void device_resume_response(struct visorchipset_device_info *p,
+ int response);
+
+static void
+visorchipset_device_pause_response(struct visorchipset_device_info *p,
+ int response);
static struct visorchipset_busdev_responders busdev_responders = {
.bus_create = bus_create_response,
@@ -348,6 +361,183 @@ static void controlvm_respond_physdev_changestate(
struct controlvm_message_header *msg_hdr, int response,
struct spar_segment_state state);
+
+static void parser_done(struct parser_context *ctx);
+
+static struct parser_context *
+parser_init_byte_stream(u64 addr, u32 bytes, bool local, bool *retry)
+{
+ int allocbytes = sizeof(struct parser_context) + bytes;
+ struct parser_context *rc = NULL;
+ struct parser_context *ctx = NULL;
+
+ if (retry)
+ *retry = false;
+
+ /*
+ * alloc an 0 extra byte to ensure payload is
+ * '\0'-terminated
+ */
+ allocbytes++;
+ if ((controlvm_payload_bytes_buffered + bytes)
+ > MAX_CONTROLVM_PAYLOAD_BYTES) {
+ if (retry)
+ *retry = true;
+ rc = NULL;
+ goto cleanup;
+ }
+ ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
+ if (!ctx) {
+ if (retry)
+ *retry = true;
+ rc = NULL;
+ goto cleanup;
+ }
+
+ ctx->allocbytes = allocbytes;
+ ctx->param_bytes = bytes;
+ ctx->curr = NULL;
+ ctx->bytes_remaining = 0;
+ ctx->byte_stream = false;
+ if (local) {
+ void *p;
+
+ if (addr > virt_to_phys(high_memory - 1)) {
+ rc = NULL;
+ goto cleanup;
+ }
+ p = __va((unsigned long) (addr));
+ memcpy(ctx->data, p, bytes);
+ } else {
+ void __iomem *mapping;
+
+ if (!request_mem_region(addr, bytes, "visorchipset")) {
+ rc = NULL;
+ goto cleanup;
+ }
+
+ mapping = ioremap_cache(addr, bytes);
+ if (!mapping) {
+ release_mem_region(addr, bytes);
+ rc = NULL;
+ goto cleanup;
+ }
+ memcpy_fromio(ctx->data, mapping, bytes);
+ release_mem_region(addr, bytes);
+ }
+
+ ctx->byte_stream = true;
+ rc = ctx;
+cleanup:
+ if (rc) {
+ controlvm_payload_bytes_buffered += ctx->param_bytes;
+ } else {
+ if (ctx) {
+ parser_done(ctx);
+ ctx = NULL;
+ }
+ }
+ return rc;
+}
+
+static uuid_le
+parser_id_get(struct parser_context *ctx)
+{
+ struct spar_controlvm_parameters_header *phdr = NULL;
+
+ if (ctx == NULL)
+ return NULL_UUID_LE;
+ phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+ return phdr->id;
+}
+
+/** Describes the state from the perspective of which controlvm messages have
+ * been received for a bus or device.
+ */
+
+enum PARSER_WHICH_STRING {
+ PARSERSTRING_INITIATOR,
+ PARSERSTRING_TARGET,
+ PARSERSTRING_CONNECTION,
+ PARSERSTRING_NAME, /* TODO: only PARSERSTRING_NAME is used ? */
+};
+
+static void
+parser_param_start(struct parser_context *ctx,
+ enum PARSER_WHICH_STRING which_string)
+{
+ struct spar_controlvm_parameters_header *phdr = NULL;
+
+ if (ctx == NULL)
+ goto Away;
+ phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
+ switch (which_string) {
+ case PARSERSTRING_INITIATOR:
+ ctx->curr = ctx->data + phdr->initiator_offset;
+ ctx->bytes_remaining = phdr->initiator_length;
+ break;
+ case PARSERSTRING_TARGET:
+ ctx->curr = ctx->data + phdr->target_offset;
+ ctx->bytes_remaining = phdr->target_length;
+ break;
+ case PARSERSTRING_CONNECTION:
+ ctx->curr = ctx->data + phdr->connection_offset;
+ ctx->bytes_remaining = phdr->connection_length;
+ break;
+ case PARSERSTRING_NAME:
+ ctx->curr = ctx->data + phdr->name_offset;
+ ctx->bytes_remaining = phdr->name_length;
+ break;
+ default:
+ break;
+ }
+
+Away:
+ return;
+}
+
+static void parser_done(struct parser_context *ctx)
+{
+ if (!ctx)
+ return;
+ controlvm_payload_bytes_buffered -= ctx->param_bytes;
+ kfree(ctx);
+}
+
+static void *
+parser_string_get(struct parser_context *ctx)
+{
+ u8 *pscan;
+ unsigned long nscan;
+ int value_length = -1;
+ void *value = NULL;
+ int i;
+
+ if (!ctx)
+ return NULL;
+ pscan = ctx->curr;
+ nscan = ctx->bytes_remaining;
+ if (nscan == 0)
+ return NULL;
+ if (!pscan)
+ return NULL;
+ for (i = 0, value_length = -1; i < nscan; i++)
+ if (pscan[i] == '\0') {
+ value_length = i;
+ break;
+ }
+ if (value_length < 0) /* '\0' was not included in the length */
+ value_length = nscan;
+ value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
+ if (value == NULL)
+ return NULL;
+ if (value_length > 0)
+ memcpy(value, pscan, value_length);
+ ((u8 *) (value))[value_length] = '\0';
+ return value;
+}
+
+
static ssize_t toolaction_show(struct device *dev,
struct device_attribute *attr,
char *buf)
@@ -367,7 +557,7 @@ static ssize_t toolaction_store(struct device *dev,
u8 tool_action;
int ret;
- if (kstrtou8(buf, 10, &tool_action) != 0)
+ if (kstrtou8(buf, 10, &tool_action))
return -EINVAL;
ret = visorchannel_write(controlvm_channel,
@@ -401,7 +591,7 @@ static ssize_t boottotool_store(struct device *dev,
int val, ret;
struct efi_spar_indication efi_spar_indication;
- if (kstrtoint(buf, 10, &val) != 0)
+ if (kstrtoint(buf, 10, &val))
return -EINVAL;
efi_spar_indication.boot_to_tool = val;
@@ -433,7 +623,7 @@ static ssize_t error_store(struct device *dev, struct device_attribute *attr,
u32 error;
int ret;
- if (kstrtou32(buf, 10, &error) != 0)
+ if (kstrtou32(buf, 10, &error))
return -EINVAL;
ret = visorchannel_write(controlvm_channel,
@@ -463,7 +653,7 @@ static ssize_t textid_store(struct device *dev, struct device_attribute *attr,
u32 text_id;
int ret;
- if (kstrtou32(buf, 10, &text_id) != 0)
+ if (kstrtou32(buf, 10, &text_id))
return -EINVAL;
ret = visorchannel_write(controlvm_channel,
@@ -494,7 +684,7 @@ static ssize_t remaining_steps_store(struct device *dev,
u16 remaining_steps;
int ret;
- if (kstrtou16(buf, 10, &remaining_steps) != 0)
+ if (kstrtou16(buf, 10, &remaining_steps))
return -EINVAL;
ret = visorchannel_write(controlvm_channel,
@@ -509,15 +699,10 @@ static ssize_t remaining_steps_store(struct device *dev,
static void
bus_info_clear(void *v)
{
- struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) (v);
+ struct visorchipset_bus_info *p = (struct visorchipset_bus_info *) v;
kfree(p->name);
- p->name = NULL;
-
kfree(p->description);
- p->description = NULL;
-
- p->state.created = 0;
memset(p, 0, sizeof(struct visorchipset_bus_info));
}
@@ -525,12 +710,88 @@ static void
dev_info_clear(void *v)
{
struct visorchipset_device_info *p =
- (struct visorchipset_device_info *)(v);
+ (struct visorchipset_device_info *) v;
- p->state.created = 0;
memset(p, 0, sizeof(struct visorchipset_device_info));
}
+struct visor_busdev {
+ u32 bus_no;
+ u32 dev_no;
+};
+
+static int match_visorbus_dev_by_id(struct device *dev, void *data)
+{
+ struct visor_device *vdev = to_visor_device(dev);
+ struct visor_busdev *id = (struct visor_busdev *)data;
+ u32 bus_no = id->bus_no;
+ u32 dev_no = id->dev_no;
+
+ if (((bus_no == -1) || (vdev->chipset_bus_no == bus_no)) &&
+ ((dev_no == -1) || (vdev->chipset_dev_no == dev_no)))
+ return 1;
+
+ return 0;
+}
+struct visor_device *visorbus_get_device_by_id(u32 bus_no, u32 dev_no,
+ struct visor_device *from)
+{
+ struct device *dev;
+ struct device *dev_start = NULL;
+ struct visor_device *vdev = NULL;
+ struct visor_busdev id = {
+ .bus_no = bus_no,
+ .dev_no = dev_no
+ };
+
+ if (from)
+ dev_start = &from->device;
+ dev = bus_find_device(&visorbus_type, dev_start, (void *)&id,
+ match_visorbus_dev_by_id);
+ if (dev)
+ vdev = to_visor_device(dev);
+ return vdev;
+}
+EXPORT_SYMBOL(visorbus_get_device_by_id);
+
+static struct visorchipset_bus_info *
+bus_find(struct list_head *list, u32 bus_no)
+{
+ struct visorchipset_bus_info *p;
+
+ list_for_each_entry(p, list, entry) {
+ if (p->bus_no == bus_no)
+ return p;
+ }
+
+ return NULL;
+}
+
+static struct visorchipset_device_info *
+device_find(struct list_head *list, u32 bus_no, u32 dev_no)
+{
+ struct visorchipset_device_info *p;
+
+ list_for_each_entry(p, list, entry) {
+ if (p->bus_no == bus_no && p->dev_no == dev_no)
+ return p;
+ }
+
+ return NULL;
+}
+
+static void busdevices_del(struct list_head *list, u32 bus_no)
+{
+ struct visorchipset_device_info *p, *tmp;
+
+ list_for_each_entry_safe(p, tmp, list, entry) {
+ if (p->bus_no == bus_no) {
+ list_del(&p->entry);
+ kfree(p);
+ }
+ }
+}
+
static u8
check_chipset_events(void)
{
@@ -552,19 +813,19 @@ clear_chipset_events(void)
}
void
-visorchipset_register_busdev_server(
+visorchipset_register_busdev(
struct visorchipset_busdev_notifiers *notifiers,
struct visorchipset_busdev_responders *responders,
struct ultra_vbus_deviceinfo *driver_info)
{
down(&notifier_lock);
if (!notifiers) {
- memset(&busdev_server_notifiers, 0,
- sizeof(busdev_server_notifiers));
- serverregistered = 0; /* clear flag */
+ memset(&busdev_notifiers, 0,
+ sizeof(busdev_notifiers));
+ visorbusregistered = 0; /* clear flag */
} else {
- busdev_server_notifiers = *notifiers;
- serverregistered = 1; /* set flag */
+ busdev_notifiers = *notifiers;
+ visorbusregistered = 1; /* set flag */
}
if (responders)
*responders = busdev_responders;
@@ -574,31 +835,7 @@ visorchipset_register_busdev_server(
up(&notifier_lock);
}
-EXPORT_SYMBOL_GPL(visorchipset_register_busdev_server);
-
-void
-visorchipset_register_busdev_client(
- struct visorchipset_busdev_notifiers *notifiers,
- struct visorchipset_busdev_responders *responders,
- struct ultra_vbus_deviceinfo *driver_info)
-{
- down(&notifier_lock);
- if (!notifiers) {
- memset(&busdev_client_notifiers, 0,
- sizeof(busdev_client_notifiers));
- clientregistered = 0; /* clear flag */
- } else {
- busdev_client_notifiers = *notifiers;
- clientregistered = 1; /* set flag */
- }
- if (responders)
- *responders = busdev_responders;
- if (driver_info)
- bus_device_info_init(driver_info, "chipset(bolts)",
- "visorchipset", VERSION, NULL);
- up(&notifier_lock);
-}
-EXPORT_SYMBOL_GPL(visorchipset_register_busdev_client);
+EXPORT_SYMBOL_GPL(visorchipset_register_busdev);
static void
cleanup_controlvm_structures(void)
@@ -719,113 +956,40 @@ static void controlvm_respond_physdev_changestate(
}
}
-void
-visorchipset_save_message(struct controlvm_message *msg,
- enum crash_obj_type type)
-{
- u32 crash_msg_offset;
- u16 crash_msg_count;
-
- /* get saved message count */
- if (visorchannel_read(controlvm_channel,
- offsetof(struct spar_controlvm_channel_protocol,
- saved_crash_message_count),
- &crash_msg_count, sizeof(u16)) < 0) {
- POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
- POSTCODE_SEVERITY_ERR);
- return;
- }
-
- if (crash_msg_count != CONTROLVM_CRASHMSG_MAX) {
- POSTCODE_LINUX_3(CRASH_DEV_COUNT_FAILURE_PC,
- crash_msg_count,
- POSTCODE_SEVERITY_ERR);
- return;
- }
-
- /* get saved crash message offset */
- if (visorchannel_read(controlvm_channel,
- offsetof(struct spar_controlvm_channel_protocol,
- saved_crash_message_offset),
- &crash_msg_offset, sizeof(u32)) < 0) {
- POSTCODE_LINUX_2(CRASH_DEV_CTRL_RD_FAILURE_PC,
- POSTCODE_SEVERITY_ERR);
- return;
- }
-
- if (type == CRASH_BUS) {
- if (visorchannel_write(controlvm_channel,
- crash_msg_offset,
- msg,
- sizeof(struct controlvm_message)) < 0) {
- POSTCODE_LINUX_2(SAVE_MSG_BUS_FAILURE_PC,
- POSTCODE_SEVERITY_ERR);
- return;
- }
- } else {
- if (visorchannel_write(controlvm_channel,
- crash_msg_offset +
- sizeof(struct controlvm_message), msg,
- sizeof(struct controlvm_message)) < 0) {
- POSTCODE_LINUX_2(SAVE_MSG_DEV_FAILURE_PC,
- POSTCODE_SEVERITY_ERR);
- return;
- }
- }
-}
-EXPORT_SYMBOL_GPL(visorchipset_save_message);
+enum crash_obj_type {
+ CRASH_DEV,
+ CRASH_BUS,
+};
static void
-bus_responder(enum controlvm_id cmd_id, ulong bus_no, int response)
+bus_responder(enum controlvm_id cmd_id,
+ struct controlvm_message_header *pending_msg_hdr,
+ int response)
{
- struct visorchipset_bus_info *p = NULL;
- BOOL need_clear = FALSE;
+ if (pending_msg_hdr == NULL)
+ return; /* no controlvm response needed */
- p = findbus(&bus_info_list, bus_no);
- if (!p)
+ if (pending_msg_hdr->id != (u32)cmd_id)
return;
- if (response < 0) {
- if ((cmd_id == CONTROLVM_BUS_CREATE) &&
- (response != (-CONTROLVM_RESP_ERROR_ALREADY_DONE)))
- /* undo the row we just created... */
- delbusdevices(&dev_info_list, bus_no);
- } else {
- if (cmd_id == CONTROLVM_BUS_CREATE)
- p->state.created = 1;
- if (cmd_id == CONTROLVM_BUS_DESTROY)
- need_clear = TRUE;
- }
-
- if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
- return; /* no controlvm response needed */
- if (p->pending_msg_hdr.id != (u32)cmd_id)
- return;
- controlvm_respond(&p->pending_msg_hdr, response);
- p->pending_msg_hdr.id = CONTROLVM_INVALID;
- if (need_clear) {
- bus_info_clear(p);
- delbusdevices(&dev_info_list, bus_no);
- }
+ controlvm_respond(pending_msg_hdr, response);
}
static void
device_changestate_responder(enum controlvm_id cmd_id,
- ulong bus_no, ulong dev_no, int response,
+ struct visorchipset_device_info *p, int response,
struct spar_segment_state response_state)
{
- struct visorchipset_device_info *p = NULL;
struct controlvm_message outmsg;
+ u32 bus_no = p->bus_no;
+ u32 dev_no = p->dev_no;
- p = finddevice(&dev_info_list, bus_no, dev_no);
- if (!p)
- return;
- if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
+ if (p->pending_msg_hdr == NULL)
return; /* no controlvm response needed */
- if (p->pending_msg_hdr.id != cmd_id)
+ if (p->pending_msg_hdr->id != cmd_id)
return;
- controlvm_init_response(&outmsg, &p->pending_msg_hdr, response);
+ controlvm_init_response(&outmsg, p->pending_msg_hdr, response);
outmsg.cmd.device_change_state.bus_no = bus_no;
outmsg.cmd.device_change_state.dev_no = dev_no;
@@ -834,96 +998,74 @@ device_changestate_responder(enum controlvm_id cmd_id,
if (!visorchannel_signalinsert(controlvm_channel,
CONTROLVM_QUEUE_REQUEST, &outmsg))
return;
-
- p->pending_msg_hdr.id = CONTROLVM_INVALID;
}
static void
-device_responder(enum controlvm_id cmd_id, ulong bus_no, ulong dev_no,
+device_responder(enum controlvm_id cmd_id,
+ struct controlvm_message_header *pending_msg_hdr,
int response)
{
- struct visorchipset_device_info *p = NULL;
- BOOL need_clear = FALSE;
-
- p = finddevice(&dev_info_list, bus_no, dev_no);
- if (!p)
- return;
- if (response >= 0) {
- if (cmd_id == CONTROLVM_DEVICE_CREATE)
- p->state.created = 1;
- if (cmd_id == CONTROLVM_DEVICE_DESTROY)
- need_clear = TRUE;
- }
-
- if (p->pending_msg_hdr.id == CONTROLVM_INVALID)
+ if (pending_msg_hdr == NULL)
return; /* no controlvm response needed */
- if (p->pending_msg_hdr.id != (u32)cmd_id)
+ if (pending_msg_hdr->id != (u32)cmd_id)
return;
- controlvm_respond(&p->pending_msg_hdr, response);
- p->pending_msg_hdr.id = CONTROLVM_INVALID;
- if (need_clear)
- dev_info_clear(p);
+ controlvm_respond(pending_msg_hdr, response);
}
static void
-bus_epilog(u32 bus_no,
+bus_epilog(struct visorchipset_bus_info *bus_info,
u32 cmd, struct controlvm_message_header *msg_hdr,
- int response, BOOL need_response)
+ int response, bool need_response)
{
- BOOL notified = FALSE;
+ bool notified = false;
+ struct controlvm_message_header *pmsg_hdr = NULL;
- struct visorchipset_bus_info *bus_info = findbus(&bus_info_list,
- bus_no);
+ if (!bus_info) {
+ /* relying on a valid passed in response code */
+ /* be lazy and re-use msg_hdr for this failure, is this ok?? */
+ pmsg_hdr = msg_hdr;
+ goto away;
+ }
- if (!bus_info)
- return;
+ if (bus_info->pending_msg_hdr) {
+ /* only non-NULL if dev is still waiting on a response */
+ response = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
+ pmsg_hdr = bus_info->pending_msg_hdr;
+ goto away;
+ }
if (need_response) {
- memcpy(&bus_info->pending_msg_hdr, msg_hdr,
+ pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
+ if (!pmsg_hdr) {
+ response = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
+ goto away;
+ }
+
+ memcpy(pmsg_hdr, msg_hdr,
sizeof(struct controlvm_message_header));
- } else {
- bus_info->pending_msg_hdr.id = CONTROLVM_INVALID;
+ bus_info->pending_msg_hdr = pmsg_hdr;
}
down(&notifier_lock);
if (response == CONTROLVM_RESP_SUCCESS) {
switch (cmd) {
case CONTROLVM_BUS_CREATE:
- /* We can't tell from the bus_create
- * information which of our 2 bus flavors the
- * devices on this bus will ultimately end up.
- * FORTUNATELY, it turns out it is harmless to
- * send the bus_create to both of them. We can
- * narrow things down a little bit, though,
- * because we know: - BusDev_Server can handle
- * either server or client devices
- * - BusDev_Client can handle ONLY client
- * devices */
- if (busdev_server_notifiers.bus_create) {
- (*busdev_server_notifiers.bus_create) (bus_no);
- notified = TRUE;
- }
- if ((!bus_info->flags.server) /*client */ &&
- busdev_client_notifiers.bus_create) {
- (*busdev_client_notifiers.bus_create) (bus_no);
- notified = TRUE;
+ if (busdev_notifiers.bus_create) {
+ (*busdev_notifiers.bus_create) (bus_info);
+ notified = true;
}
break;
case CONTROLVM_BUS_DESTROY:
- if (busdev_server_notifiers.bus_destroy) {
- (*busdev_server_notifiers.bus_destroy) (bus_no);
- notified = TRUE;
- }
- if ((!bus_info->flags.server) /*client */ &&
- busdev_client_notifiers.bus_destroy) {
- (*busdev_client_notifiers.bus_destroy) (bus_no);
- notified = TRUE;
+ if (busdev_notifiers.bus_destroy) {
+ (*busdev_notifiers.bus_destroy) (bus_info);
+ notified = true;
}
break;
}
}
+away:
if (notified)
/* The callback function just called above is responsible
* for calling the appropriate visorchipset_busdev_responders
@@ -931,37 +1073,58 @@ bus_epilog(u32 bus_no,
*/
;
else
- bus_responder(cmd, bus_no, response);
+ /*
+ * Do not kfree(pmsg_hdr) as this is the failure path.
+ * The success path ('notified') will call the responder
+ * directly and kfree() there.
+ */
+ bus_responder(cmd, pmsg_hdr, response);
up(&notifier_lock);
}
static void
-device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
+device_epilog(struct visorchipset_device_info *dev_info,
+ struct spar_segment_state state, u32 cmd,
struct controlvm_message_header *msg_hdr, int response,
- BOOL need_response, BOOL for_visorbus)
+ bool need_response, bool for_visorbus)
{
- struct visorchipset_busdev_notifiers *notifiers = NULL;
- BOOL notified = FALSE;
+ struct visorchipset_busdev_notifiers *notifiers;
+ bool notified = false;
+ u32 bus_no = dev_info->bus_no;
+ u32 dev_no = dev_info->dev_no;
+ struct controlvm_message_header *pmsg_hdr = NULL;
- struct visorchipset_device_info *dev_info =
- finddevice(&dev_info_list, bus_no, dev_no);
char *envp[] = {
"SPARSP_DIAGPOOL_PAUSED_STATE = 1",
NULL
};
- if (!dev_info)
- return;
+ notifiers = &busdev_notifiers;
+
+ if (!dev_info) {
+ /* relying on a valid passed in response code */
+ /* be lazy and re-use msg_hdr for this failure, is this ok?? */
+ pmsg_hdr = msg_hdr;
+ goto away;
+ }
+
+ if (dev_info->pending_msg_hdr) {
+ /* only non-NULL if dev is still waiting on a response */
+ response = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
+ pmsg_hdr = dev_info->pending_msg_hdr;
+ goto away;
+ }
- if (for_visorbus)
- notifiers = &busdev_server_notifiers;
- else
- notifiers = &busdev_client_notifiers;
if (need_response) {
- memcpy(&dev_info->pending_msg_hdr, msg_hdr,
+ pmsg_hdr = kzalloc(sizeof(*pmsg_hdr), GFP_KERNEL);
+ if (!pmsg_hdr) {
+ response = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
+ goto away;
+ }
+
+ memcpy(pmsg_hdr, msg_hdr,
sizeof(struct controlvm_message_header));
- } else {
- dev_info->pending_msg_hdr.id = CONTROLVM_INVALID;
+ dev_info->pending_msg_hdr = pmsg_hdr;
}
down(&notifier_lock);
@@ -969,8 +1132,8 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
switch (cmd) {
case CONTROLVM_DEVICE_CREATE:
if (notifiers->device_create) {
- (*notifiers->device_create) (bus_no, dev_no);
- notified = TRUE;
+ (*notifiers->device_create) (dev_info);
+ notified = true;
}
break;
case CONTROLVM_DEVICE_CHANGESTATE:
@@ -979,9 +1142,8 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
state.operating ==
segment_state_running.operating) {
if (notifiers->device_resume) {
- (*notifiers->device_resume) (bus_no,
- dev_no);
- notified = TRUE;
+ (*notifiers->device_resume) (dev_info);
+ notified = true;
}
}
/* ServerNotReady / ServerLost / SegmentStateStandby */
@@ -992,9 +1154,8 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
* where server is lost
*/
if (notifiers->device_pause) {
- (*notifiers->device_pause) (bus_no,
- dev_no);
- notified = TRUE;
+ (*notifiers->device_pause) (dev_info);
+ notified = true;
}
} else if (state.alive == segment_state_paused.alive &&
state.operating ==
@@ -1015,12 +1176,13 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
break;
case CONTROLVM_DEVICE_DESTROY:
if (notifiers->device_destroy) {
- (*notifiers->device_destroy) (bus_no, dev_no);
- notified = TRUE;
+ (*notifiers->device_destroy) (dev_info);
+ notified = true;
}
break;
}
}
+away:
if (notified)
/* The callback function just called above is responsible
* for calling the appropriate visorchipset_busdev_responders
@@ -1028,7 +1190,12 @@ device_epilog(u32 bus_no, u32 dev_no, struct spar_segment_state state, u32 cmd,
*/
;
else
- device_responder(cmd, bus_no, dev_no, response);
+ /*
+ * Do not kfree(pmsg_hdr) as this is the failure path.
+ * The success path ('notified') will call the responder
+ * directly and kfree() there.
+ */
+ device_responder(cmd, pmsg_hdr, response);
up(&notifier_lock);
}
@@ -1036,11 +1203,12 @@ static void
bus_create(struct controlvm_message *inmsg)
{
struct controlvm_message_packet *cmd = &inmsg->cmd;
- ulong bus_no = cmd->create_bus.bus_no;
+ u32 bus_no = cmd->create_bus.bus_no;
int rc = CONTROLVM_RESP_SUCCESS;
- struct visorchipset_bus_info *bus_info = NULL;
+ struct visorchipset_bus_info *bus_info;
+ struct visorchannel *visorchannel;
- bus_info = findbus(&bus_info_list, bus_no);
+ bus_info = bus_find(&bus_info_list, bus_no);
if (bus_info && (bus_info->state.created == 1)) {
POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
POSTCODE_SEVERITY_ERR);
@@ -1057,28 +1225,31 @@ bus_create(struct controlvm_message *inmsg)
INIT_LIST_HEAD(&bus_info->entry);
bus_info->bus_no = bus_no;
- bus_info->dev_no = cmd->create_bus.dev_count;
POSTCODE_LINUX_3(BUS_CREATE_ENTRY_PC, bus_no, POSTCODE_SEVERITY_INFO);
- if (inmsg->hdr.flags.test_message == 1)
- bus_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
- else
- bus_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
-
bus_info->flags.server = inmsg->hdr.flags.server;
- bus_info->chan_info.channel_addr = cmd->create_bus.channel_addr;
- bus_info->chan_info.n_channel_bytes = cmd->create_bus.channel_bytes;
- bus_info->chan_info.channel_type_uuid =
- cmd->create_bus.bus_data_type_uuid;
- bus_info->chan_info.channel_inst_uuid = cmd->create_bus.bus_inst_uuid;
+ visorchannel = visorchannel_create(cmd->create_bus.channel_addr,
+ cmd->create_bus.channel_bytes,
+ GFP_KERNEL,
+ cmd->create_bus.bus_data_type_uuid);
+
+ if (!visorchannel) {
+ POSTCODE_LINUX_3(BUS_CREATE_FAILURE_PC, bus_no,
+ POSTCODE_SEVERITY_ERR);
+ rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
+ kfree(bus_info);
+ bus_info = NULL;
+ goto cleanup;
+ }
+ bus_info->visorchannel = visorchannel;
list_add(&bus_info->entry, &bus_info_list);
POSTCODE_LINUX_3(BUS_CREATE_EXIT_PC, bus_no, POSTCODE_SEVERITY_INFO);
cleanup:
- bus_epilog(bus_no, CONTROLVM_BUS_CREATE, &inmsg->hdr,
+ bus_epilog(bus_info, CONTROLVM_BUS_CREATE, &inmsg->hdr,
rc, inmsg->hdr.flags.response_expected == 1);
}
@@ -1086,17 +1257,17 @@ static void
bus_destroy(struct controlvm_message *inmsg)
{
struct controlvm_message_packet *cmd = &inmsg->cmd;
- ulong bus_no = cmd->destroy_bus.bus_no;
+ u32 bus_no = cmd->destroy_bus.bus_no;
struct visorchipset_bus_info *bus_info;
int rc = CONTROLVM_RESP_SUCCESS;
- bus_info = findbus(&bus_info_list, bus_no);
+ bus_info = bus_find(&bus_info_list, bus_no);
if (!bus_info)
rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
else if (bus_info->state.created == 0)
rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
- bus_epilog(bus_no, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
+ bus_epilog(bus_info, CONTROLVM_BUS_DESTROY, &inmsg->hdr,
rc, inmsg->hdr.flags.response_expected == 1);
}
@@ -1105,8 +1276,8 @@ bus_configure(struct controlvm_message *inmsg,
struct parser_context *parser_ctx)
{
struct controlvm_message_packet *cmd = &inmsg->cmd;
- ulong bus_no = cmd->configure_bus.bus_no;
- struct visorchipset_bus_info *bus_info = NULL;
+ u32 bus_no;
+ struct visorchipset_bus_info *bus_info;
int rc = CONTROLVM_RESP_SUCCESS;
char s[99];
@@ -1114,7 +1285,7 @@ bus_configure(struct controlvm_message *inmsg,
POSTCODE_LINUX_3(BUS_CONFIGURE_ENTRY_PC, bus_no,
POSTCODE_SEVERITY_INFO);
- bus_info = findbus(&bus_info_list, bus_no);
+ bus_info = bus_find(&bus_info_list, bus_no);
if (!bus_info) {
POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
POSTCODE_SEVERITY_ERR);
@@ -1123,12 +1294,13 @@ bus_configure(struct controlvm_message *inmsg,
POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
POSTCODE_SEVERITY_ERR);
rc = -CONTROLVM_RESP_ERROR_BUS_INVALID;
- } else if (bus_info->pending_msg_hdr.id != CONTROLVM_INVALID) {
+ } else if (bus_info->pending_msg_hdr != NULL) {
POSTCODE_LINUX_3(BUS_CONFIGURE_FAILURE_PC, bus_no,
POSTCODE_SEVERITY_ERR);
rc = -CONTROLVM_RESP_ERROR_MESSAGE_ID_INVALID_FOR_CLIENT;
} else {
- bus_info->partition_handle = cmd->configure_bus.guest_handle;
+ visorchannel_set_clientpartition(bus_info->visorchannel,
+ cmd->configure_bus.guest_handle);
bus_info->partition_uuid = parser_id_get(parser_ctx);
parser_param_start(parser_ctx, PARSERSTRING_NAME);
bus_info->name = parser_string_get(parser_ctx);
@@ -1137,7 +1309,7 @@ bus_configure(struct controlvm_message *inmsg,
POSTCODE_LINUX_3(BUS_CONFIGURE_EXIT_PC, bus_no,
POSTCODE_SEVERITY_INFO);
}
- bus_epilog(bus_no, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
+ bus_epilog(bus_info, CONTROLVM_BUS_CONFIGURE, &inmsg->hdr,
rc, inmsg->hdr.flags.response_expected == 1);
}
@@ -1145,20 +1317,21 @@ static void
my_device_create(struct controlvm_message *inmsg)
{
struct controlvm_message_packet *cmd = &inmsg->cmd;
- ulong bus_no = cmd->create_device.bus_no;
- ulong dev_no = cmd->create_device.dev_no;
- struct visorchipset_device_info *dev_info = NULL;
- struct visorchipset_bus_info *bus_info = NULL;
+ u32 bus_no = cmd->create_device.bus_no;
+ u32 dev_no = cmd->create_device.dev_no;
+ struct visorchipset_device_info *dev_info;
+ struct visorchipset_bus_info *bus_info;
+ struct visorchannel *visorchannel;
int rc = CONTROLVM_RESP_SUCCESS;
- dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+ dev_info = device_find(&dev_info_list, bus_no, dev_no);
if (dev_info && (dev_info->state.created == 1)) {
POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
POSTCODE_SEVERITY_ERR);
rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
goto cleanup;
}
- bus_info = findbus(&bus_info_list, bus_no);
+ bus_info = bus_find(&bus_info_list, bus_no);
if (!bus_info) {
POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
POSTCODE_SEVERITY_ERR);
@@ -1186,42 +1359,47 @@ my_device_create(struct controlvm_message *inmsg)
POSTCODE_LINUX_4(DEVICE_CREATE_ENTRY_PC, dev_no, bus_no,
POSTCODE_SEVERITY_INFO);
- if (inmsg->hdr.flags.test_message == 1)
- dev_info->chan_info.addr_type = ADDRTYPE_LOCALTEST;
- else
- dev_info->chan_info.addr_type = ADDRTYPE_LOCALPHYSICAL;
- dev_info->chan_info.channel_addr = cmd->create_device.channel_addr;
- dev_info->chan_info.n_channel_bytes = cmd->create_device.channel_bytes;
- dev_info->chan_info.channel_type_uuid =
- cmd->create_device.data_type_uuid;
- dev_info->chan_info.intr = cmd->create_device.intr;
+ visorchannel = visorchannel_create(cmd->create_device.channel_addr,
+ cmd->create_device.channel_bytes,
+ GFP_KERNEL,
+ cmd->create_device.data_type_uuid);
+
+ if (!visorchannel) {
+ POSTCODE_LINUX_4(DEVICE_CREATE_FAILURE_PC, dev_no, bus_no,
+ POSTCODE_SEVERITY_ERR);
+ rc = -CONTROLVM_RESP_ERROR_KMALLOC_FAILED;
+ kfree(dev_info);
+ dev_info = NULL;
+ goto cleanup;
+ }
+ dev_info->visorchannel = visorchannel;
+ dev_info->channel_type_guid = cmd->create_device.data_type_uuid;
list_add(&dev_info->entry, &dev_info_list);
POSTCODE_LINUX_4(DEVICE_CREATE_EXIT_PC, dev_no, bus_no,
POSTCODE_SEVERITY_INFO);
cleanup:
/* get the bus and devNo for DiagPool channel */
if (dev_info &&
- is_diagpool_channel(dev_info->chan_info.channel_type_uuid)) {
+ is_diagpool_channel(cmd->create_device.data_type_uuid)) {
g_diagpool_bus_no = bus_no;
g_diagpool_dev_no = dev_no;
}
- device_epilog(bus_no, dev_no, segment_state_running,
+ device_epilog(dev_info, segment_state_running,
CONTROLVM_DEVICE_CREATE, &inmsg->hdr, rc,
- inmsg->hdr.flags.response_expected == 1,
- FOR_VISORBUS(dev_info->chan_info.channel_type_uuid));
+ inmsg->hdr.flags.response_expected == 1, 1);
}
static void
my_device_changestate(struct controlvm_message *inmsg)
{
struct controlvm_message_packet *cmd = &inmsg->cmd;
- ulong bus_no = cmd->device_change_state.bus_no;
- ulong dev_no = cmd->device_change_state.dev_no;
+ u32 bus_no = cmd->device_change_state.bus_no;
+ u32 dev_no = cmd->device_change_state.dev_no;
struct spar_segment_state state = cmd->device_change_state.state;
- struct visorchipset_device_info *dev_info = NULL;
+ struct visorchipset_device_info *dev_info;
int rc = CONTROLVM_RESP_SUCCESS;
- dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+ dev_info = device_find(&dev_info_list, bus_no, dev_no);
if (!dev_info) {
POSTCODE_LINUX_4(DEVICE_CHANGESTATE_FAILURE_PC, dev_no, bus_no,
POSTCODE_SEVERITY_ERR);
@@ -1232,45 +1410,41 @@ my_device_changestate(struct controlvm_message *inmsg)
rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
}
if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
- device_epilog(bus_no, dev_no, state,
+ device_epilog(dev_info, state,
CONTROLVM_DEVICE_CHANGESTATE, &inmsg->hdr, rc,
- inmsg->hdr.flags.response_expected == 1,
- FOR_VISORBUS(
- dev_info->chan_info.channel_type_uuid));
+ inmsg->hdr.flags.response_expected == 1, 1);
}
static void
my_device_destroy(struct controlvm_message *inmsg)
{
struct controlvm_message_packet *cmd = &inmsg->cmd;
- ulong bus_no = cmd->destroy_device.bus_no;
- ulong dev_no = cmd->destroy_device.dev_no;
- struct visorchipset_device_info *dev_info = NULL;
+ u32 bus_no = cmd->destroy_device.bus_no;
+ u32 dev_no = cmd->destroy_device.dev_no;
+ struct visorchipset_device_info *dev_info;
int rc = CONTROLVM_RESP_SUCCESS;
- dev_info = finddevice(&dev_info_list, bus_no, dev_no);
+ dev_info = device_find(&dev_info_list, bus_no, dev_no);
if (!dev_info)
rc = -CONTROLVM_RESP_ERROR_DEVICE_INVALID;
else if (dev_info->state.created == 0)
rc = -CONTROLVM_RESP_ERROR_ALREADY_DONE;
if ((rc >= CONTROLVM_RESP_SUCCESS) && dev_info)
- device_epilog(bus_no, dev_no, segment_state_running,
+ device_epilog(dev_info, segment_state_running,
CONTROLVM_DEVICE_DESTROY, &inmsg->hdr, rc,
- inmsg->hdr.flags.response_expected == 1,
- FOR_VISORBUS(
- dev_info->chan_info.channel_type_uuid));
+ inmsg->hdr.flags.response_expected == 1, 1);
}
/* When provided with the physical address of the controlvm channel
* (phys_addr), the offset to the payload area we need to manage
* (offset), and the size of this payload area (bytes), fills in the
- * controlvm_payload_info struct. Returns TRUE for success or FALSE
+ * controlvm_payload_info struct. Returns true for success or false
* for failure.
*/
static int
-initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
- struct controlvm_payload_info *info)
+initialize_controlvm_payload_info(u64 phys_addr, u64 offset, u32 bytes,
+ struct visor_controlvm_payload_info *info)
{
u8 __iomem *payload = NULL;
int rc = CONTROLVM_RESP_SUCCESS;
@@ -1279,7 +1453,7 @@ initialize_controlvm_payload_info(HOSTADDRESS phys_addr, u64 offset, u32 bytes,
rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
goto cleanup;
}
- memset(info, 0, sizeof(struct controlvm_payload_info));
+ memset(info, 0, sizeof(struct visor_controlvm_payload_info));
if ((offset == 0) || (bytes == 0)) {
rc = -CONTROLVM_RESP_ERROR_PAYLOAD_INVALID;
goto cleanup;
@@ -1305,19 +1479,19 @@ cleanup:
}
static void
-destroy_controlvm_payload_info(struct controlvm_payload_info *info)
+destroy_controlvm_payload_info(struct visor_controlvm_payload_info *info)
{
if (info->ptr) {
iounmap(info->ptr);
info->ptr = NULL;
}
- memset(info, 0, sizeof(struct controlvm_payload_info));
+ memset(info, 0, sizeof(struct visor_controlvm_payload_info));
}
static void
initialize_controlvm_payload(void)
{
- HOSTADDRESS phys_addr = visorchannel_get_physaddr(controlvm_channel);
+ u64 phys_addr = visorchannel_get_physaddr(controlvm_channel);
u64 payload_offset = 0;
u32 payload_bytes = 0;
@@ -1345,15 +1519,14 @@ initialize_controlvm_payload(void)
/* Send ACTION=online for DEVPATH=/sys/devices/platform/visorchipset.
* Returns CONTROLVM_RESP_xxx code.
*/
-int
+static int
visorchipset_chipset_ready(void)
{
kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_ONLINE);
return CONTROLVM_RESP_SUCCESS;
}
-EXPORT_SYMBOL_GPL(visorchipset_chipset_ready);
-int
+static int
visorchipset_chipset_selftest(void)
{
char env_selftest[20];
@@ -1364,18 +1537,16 @@ visorchipset_chipset_selftest(void)
envp);
return CONTROLVM_RESP_SUCCESS;
}
-EXPORT_SYMBOL_GPL(visorchipset_chipset_selftest);
/* Send ACTION=offline for DEVPATH=/sys/devices/platform/visorchipset.
* Returns CONTROLVM_RESP_xxx code.
*/
-int
+static int
visorchipset_chipset_notready(void)
{
kobject_uevent(&visorchipset_platform_device.dev.kobj, KOBJ_OFFLINE);
return CONTROLVM_RESP_SUCCESS;
}
-EXPORT_SYMBOL_GPL(visorchipset_chipset_notready);
static void
chipset_ready(struct controlvm_message_header *msg_hdr)
@@ -1419,17 +1590,17 @@ chipset_notready(struct controlvm_message_header *msg_hdr)
/* This is your "one-stop" shop for grabbing the next message from the
* CONTROLVM_QUEUE_EVENT queue in the controlvm channel.
*/
-static BOOL
+static bool
read_controlvm_event(struct controlvm_message *msg)
{
if (visorchannel_signalremove(controlvm_channel,
CONTROLVM_QUEUE_EVENT, msg)) {
/* got a message */
if (msg->hdr.flags.test_message == 1)
- return FALSE;
- return TRUE;
+ return false;
+ return true;
}
- return FALSE;
+ return false;
}
/*
@@ -1535,8 +1706,8 @@ parahotplug_request_kickoff(struct parahotplug_request *req)
static void
parahotplug_process_list(void)
{
- struct list_head *pos = NULL;
- struct list_head *tmp = NULL;
+ struct list_head *pos;
+ struct list_head *tmp;
spin_lock(&parahotplug_request_list_lock);
@@ -1567,8 +1738,8 @@ parahotplug_process_list(void)
static int
parahotplug_request_complete(int id, u16 active)
{
- struct list_head *pos = NULL;
- struct list_head *tmp = NULL;
+ struct list_head *pos;
+ struct list_head *tmp;
spin_lock(&parahotplug_request_list_lock);
@@ -1640,29 +1811,29 @@ parahotplug_process_message(struct controlvm_message *inmsg)
/* Process a controlvm message.
* Return result:
- * FALSE - this function will return FALSE only in the case where the
+ * false - this function will return false only in the case where the
* controlvm message was NOT processed, but processing must be
* retried before reading the next controlvm message; a
* scenario where this can occur is when we need to throttle
* the allocation of memory in which to copy out controlvm
* payload data
- * TRUE - processing of the controlvm message completed,
+ * true - processing of the controlvm message completed,
* either successfully or with an error.
*/
-static BOOL
-handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
+static bool
+handle_command(struct controlvm_message inmsg, u64 channel_addr)
{
struct controlvm_message_packet *cmd = &inmsg.cmd;
- u64 parm_addr = 0;
- u32 parm_bytes = 0;
+ u64 parm_addr;
+ u32 parm_bytes;
struct parser_context *parser_ctx = NULL;
- bool local_addr = false;
+ bool local_addr;
struct controlvm_message ackmsg;
/* create parsing context if necessary */
local_addr = (inmsg.hdr.flags.test_message == 1);
if (channel_addr == 0)
- return TRUE;
+ return true;
parm_addr = channel_addr + inmsg.hdr.payload_vm_offset;
parm_bytes = inmsg.hdr.payload_bytes;
@@ -1670,14 +1841,14 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
* within our OS-controlled memory. We need to know that, because it
* makes a difference in how we compute the virtual address.
*/
- if (parm_addr != 0 && parm_bytes != 0) {
- BOOL retry = FALSE;
+ if (parm_addr && parm_bytes) {
+ bool retry = false;
parser_ctx =
parser_init_byte_stream(parm_addr, parm_bytes,
local_addr, &retry);
if (!parser_ctx && retry)
- return FALSE;
+ return false;
}
if (!local_addr) {
@@ -1711,7 +1882,6 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
/* save the hdr and cmd structures for later use */
/* when sending back the response to Command */
my_device_changestate(&inmsg);
- g_diag_msg_hdr = inmsg.hdr;
g_devicechangestate_packet = inmsg.cmd;
break;
}
@@ -1744,10 +1914,26 @@ handle_command(struct controlvm_message inmsg, HOSTADDRESS channel_addr)
parser_done(parser_ctx);
parser_ctx = NULL;
}
- return TRUE;
+ return true;
+}
+
+static inline unsigned int
+issue_vmcall_io_controlvm_addr(u64 *control_addr, u32 *control_bytes)
+{
+ struct vmcall_io_controlvm_addr_params params;
+ int result = VMCALL_SUCCESS;
+ u64 physaddr;
+
+ physaddr = virt_to_phys(&params);
+ ISSUE_IO_VMCALL(VMCALL_IO_CONTROLVM_ADDR, physaddr, result);
+ if (VMCALL_SUCCESSFUL(result)) {
+ *control_addr = params.address;
+ *control_bytes = params.channel_bytes;
+ }
+ return result;
}
-static HOSTADDRESS controlvm_get_channel_address(void)
+static u64 controlvm_get_channel_address(void)
{
u64 addr = 0;
u32 size = 0;
@@ -1762,17 +1948,12 @@ static void
controlvm_periodic_work(struct work_struct *work)
{
struct controlvm_message inmsg;
- BOOL got_command = FALSE;
- BOOL handle_command_failed = FALSE;
+ bool got_command = false;
+ bool handle_command_failed = false;
static u64 poll_count;
/* make sure visorbus server is registered for controlvm callbacks */
- if (visorchipset_serverregwait && !serverregistered)
- goto cleanup;
- /* make sure visorclientbus server is regsitered for controlvm
- * callbacks
- */
- if (visorchipset_clientregwait && !clientregistered)
+ if (visorchipset_visorbusregwait && !visorbusregistered)
goto cleanup;
poll_count++;
@@ -1805,14 +1986,14 @@ controlvm_periodic_work(struct work_struct *work)
* rather than reading a new one
*/
inmsg = controlvm_pending_msg;
- controlvm_pending_msg_valid = FALSE;
+ controlvm_pending_msg_valid = false;
got_command = true;
} else {
got_command = read_controlvm_event(&inmsg);
}
}
- handle_command_failed = FALSE;
+ handle_command_failed = false;
while (got_command && (!handle_command_failed)) {
most_recent_message_jiffies = jiffies;
if (handle_command(inmsg,
@@ -1826,9 +2007,9 @@ controlvm_periodic_work(struct work_struct *work)
* controlvm msg so we will attempt to
* reprocess it on our next loop
*/
- handle_command_failed = TRUE;
+ handle_command_failed = true;
controlvm_pending_msg = inmsg;
- controlvm_pending_msg_valid = TRUE;
+ controlvm_pending_msg_valid = true;
}
}
@@ -1863,14 +2044,8 @@ setup_crash_devices_work_queue(struct work_struct *work)
u32 local_crash_msg_offset;
u16 local_crash_msg_count;
- /* make sure visorbus server is registered for controlvm callbacks */
- if (visorchipset_serverregwait && !serverregistered)
- goto cleanup;
-
- /* make sure visorclientbus server is regsitered for controlvm
- * callbacks
- */
- if (visorchipset_clientregwait && !clientregistered)
+ /* make sure visorbus is registered for controlvm callbacks */
+ if (visorchipset_visorbusregwait && !visorbusregistered)
goto cleanup;
POSTCODE_LINUX_2(CRASH_DEV_ENTRY_PC, POSTCODE_SEVERITY_INFO);
@@ -1931,7 +2106,7 @@ setup_crash_devices_work_queue(struct work_struct *work)
}
/* reuse IOVM create bus message */
- if (local_crash_bus_msg.cmd.create_bus.channel_addr != 0) {
+ if (local_crash_bus_msg.cmd.create_bus.channel_addr) {
bus_create(&local_crash_bus_msg);
} else {
POSTCODE_LINUX_2(CRASH_DEV_BUS_NULL_FAILURE_PC,
@@ -1940,7 +2115,7 @@ setup_crash_devices_work_queue(struct work_struct *work)
}
/* reuse create device message for storage device */
- if (local_crash_dev_msg.cmd.create_device.channel_addr != 0) {
+ if (local_crash_dev_msg.cmd.create_device.channel_addr) {
my_device_create(&local_crash_dev_msg);
} else {
POSTCODE_LINUX_2(CRASH_DEV_DEV_NULL_FAILURE_PC,
@@ -1959,137 +2134,130 @@ cleanup:
}
static void
-bus_create_response(ulong bus_no, int response)
+bus_create_response(struct visorchipset_bus_info *bus_info, int response)
{
- bus_responder(CONTROLVM_BUS_CREATE, bus_no, response);
+ if (response >= 0) {
+ bus_info->state.created = 1;
+ } else {
+ if (response != -CONTROLVM_RESP_ERROR_ALREADY_DONE)
+ /* undo the row we just created... */
+ busdevices_del(&dev_info_list, bus_info->bus_no);
+ }
+
+ bus_responder(CONTROLVM_BUS_CREATE, bus_info->pending_msg_hdr,
+ response);
+
+ kfree(bus_info->pending_msg_hdr);
+ bus_info->pending_msg_hdr = NULL;
}
static void
-bus_destroy_response(ulong bus_no, int response)
+bus_destroy_response(struct visorchipset_bus_info *bus_info, int response)
{
- bus_responder(CONTROLVM_BUS_DESTROY, bus_no, response);
+ bus_responder(CONTROLVM_BUS_DESTROY, bus_info->pending_msg_hdr,
+ response);
+
+ kfree(bus_info->pending_msg_hdr);
+ bus_info->pending_msg_hdr = NULL;
+
+ bus_info_clear(bus_info);
+ busdevices_del(&dev_info_list, bus_info->bus_no);
}
static void
-device_create_response(ulong bus_no, ulong dev_no, int response)
+device_create_response(struct visorchipset_device_info *dev_info, int response)
{
- device_responder(CONTROLVM_DEVICE_CREATE, bus_no, dev_no, response);
+ if (response >= 0)
+ dev_info->state.created = 1;
+
+ device_responder(CONTROLVM_DEVICE_CREATE, dev_info->pending_msg_hdr,
+ response);
+
+ kfree(dev_info->pending_msg_hdr);
+ dev_info->pending_msg_hdr = NULL;
}
static void
-device_destroy_response(ulong bus_no, ulong dev_no, int response)
+device_destroy_response(struct visorchipset_device_info *dev_info, int response)
{
- device_responder(CONTROLVM_DEVICE_DESTROY, bus_no, dev_no, response);
+ device_responder(CONTROLVM_DEVICE_DESTROY, dev_info->pending_msg_hdr,
+ response);
+
+ kfree(dev_info->pending_msg_hdr);
+ dev_info->pending_msg_hdr = NULL;
+
+ dev_info_clear(dev_info);
}
-void
-visorchipset_device_pause_response(ulong bus_no, ulong dev_no, int response)
+static void
+visorchipset_device_pause_response(struct visorchipset_device_info *dev_info,
+ int response)
{
device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
- bus_no, dev_no, response,
+ dev_info, response,
segment_state_standby);
+
+ kfree(dev_info->pending_msg_hdr);
+ dev_info->pending_msg_hdr = NULL;
}
-EXPORT_SYMBOL_GPL(visorchipset_device_pause_response);
static void
-device_resume_response(ulong bus_no, ulong dev_no, int response)
+device_resume_response(struct visorchipset_device_info *dev_info, int response)
{
device_changestate_responder(CONTROLVM_DEVICE_CHANGESTATE,
- bus_no, dev_no, response,
+ dev_info, response,
segment_state_running);
+
+ kfree(dev_info->pending_msg_hdr);
+ dev_info->pending_msg_hdr = NULL;
}
-BOOL
-visorchipset_get_bus_info(ulong bus_no, struct visorchipset_bus_info *bus_info)
+bool
+visorchipset_get_bus_info(u32 bus_no, struct visorchipset_bus_info *bus_info)
{
- void *p = findbus(&bus_info_list, bus_no);
+ void *p = bus_find(&bus_info_list, bus_no);
if (!p)
- return FALSE;
+ return false;
memcpy(bus_info, p, sizeof(struct visorchipset_bus_info));
- return TRUE;
+ return true;
}
EXPORT_SYMBOL_GPL(visorchipset_get_bus_info);
-BOOL
-visorchipset_set_bus_context(ulong bus_no, void *context)
+bool
+visorchipset_set_bus_context(struct visorchipset_bus_info *p, void *context)
{
- struct visorchipset_bus_info *p = findbus(&bus_info_list, bus_no);
-
if (!p)
- return FALSE;
+ return false;
p->bus_driver_context = context;
- return TRUE;
+ return true;
}
EXPORT_SYMBOL_GPL(visorchipset_set_bus_context);
-BOOL
-visorchipset_get_device_info(ulong bus_no, ulong dev_no,
+bool
+visorchipset_get_device_info(u32 bus_no, u32 dev_no,
struct visorchipset_device_info *dev_info)
{
- void *p = finddevice(&dev_info_list, bus_no, dev_no);
+ void *p = device_find(&dev_info_list, bus_no, dev_no);
if (!p)
- return FALSE;
+ return false;
memcpy(dev_info, p, sizeof(struct visorchipset_device_info));
- return TRUE;
+ return true;
}
EXPORT_SYMBOL_GPL(visorchipset_get_device_info);
-BOOL
-visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context)
+bool
+visorchipset_set_device_context(struct visorchipset_device_info *p,
+ void *context)
{
- struct visorchipset_device_info *p =
- finddevice(&dev_info_list, bus_no, dev_no);
-
if (!p)
- return FALSE;
+ return false;
p->bus_driver_context = context;
- return TRUE;
+ return true;
}
EXPORT_SYMBOL_GPL(visorchipset_set_device_context);
-/* Generic wrapper function for allocating memory from a kmem_cache pool.
- */
-void *
-visorchipset_cache_alloc(struct kmem_cache *pool, BOOL ok_to_block,
- char *fn, int ln)
-{
- gfp_t gfp;
- void *p;
-
- if (ok_to_block)
- gfp = GFP_KERNEL;
- else
- gfp = GFP_ATOMIC;
- /* __GFP_NORETRY means "ok to fail", meaning
- * kmem_cache_alloc() can return NULL, implying the caller CAN
- * cope with failure. If you do NOT specify __GFP_NORETRY,
- * Linux will go to extreme measures to get memory for you
- * (like, invoke oom killer), which will probably cripple the
- * system.
- */
- gfp |= __GFP_NORETRY;
- p = kmem_cache_alloc(pool, gfp);
- if (!p)
- return NULL;
-
- atomic_inc(&visorchipset_cache_buffers_in_use);
- return p;
-}
-
-/* Generic wrapper function for freeing memory from a kmem_cache pool.
- */
-void
-visorchipset_cache_free(struct kmem_cache *pool, void *p, char *fn, int ln)
-{
- if (!p)
- return;
-
- atomic_dec(&visorchipset_cache_buffers_in_use);
- kmem_cache_free(pool, p);
-}
-
static ssize_t chipsetready_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
@@ -2099,10 +2267,10 @@ static ssize_t chipsetready_store(struct device *dev,
if (sscanf(buf, "%63s", msgtype) != 1)
return -EINVAL;
- if (strcmp(msgtype, "CALLHOMEDISK_MOUNTED") == 0) {
+ if (!strcmp(msgtype, "CALLHOMEDISK_MOUNTED")) {
chipset_events[0] = 1;
return count;
- } else if (strcmp(msgtype, "MODULES_LOADED") == 0) {
+ } else if (!strcmp(msgtype, "MODULES_LOADED")) {
chipset_events[1] = 1;
return count;
}
@@ -2117,9 +2285,9 @@ static ssize_t devicedisabled_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- uint id;
+ unsigned int id;
- if (kstrtouint(buf, 10, &id) != 0)
+ if (kstrtouint(buf, 10, &id))
return -EINVAL;
parahotplug_request_complete(id, 0);
@@ -2134,52 +2302,158 @@ static ssize_t deviceenabled_store(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
- uint id;
+ unsigned int id;
- if (kstrtouint(buf, 10, &id) != 0)
+ if (kstrtouint(buf, 10, &id))
return -EINVAL;
parahotplug_request_complete(id, 1);
return count;
}
-static int __init
-visorchipset_init(void)
+static int
+visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
{
- int rc = 0, x = 0;
- HOSTADDRESS addr;
+ unsigned long physaddr = 0;
+ unsigned long offset = vma->vm_pgoff << PAGE_SHIFT;
+ u64 addr = 0;
- if (!unisys_spar_platform)
- return -ENODEV;
+ /* sv_enable_dfp(); */
+ if (offset & (PAGE_SIZE - 1))
+ return -ENXIO; /* need aligned offsets */
- memset(&busdev_server_notifiers, 0, sizeof(busdev_server_notifiers));
- memset(&busdev_client_notifiers, 0, sizeof(busdev_client_notifiers));
- memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
- memset(&livedump_info, 0, sizeof(livedump_info));
- atomic_set(&livedump_info.buffers_in_use, 0);
+ switch (offset) {
+ case VISORCHIPSET_MMAP_CONTROLCHANOFFSET:
+ vma->vm_flags |= VM_IO;
+ if (!*file_controlvm_channel)
+ return -ENXIO;
- if (visorchipset_testvnic) {
- POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, x, DIAG_SEVERITY_ERR);
- rc = x;
- goto cleanup;
+ visorchannel_read(*file_controlvm_channel,
+ offsetof(struct spar_controlvm_channel_protocol,
+ gp_control_channel),
+ &addr, sizeof(addr));
+ if (!addr)
+ return -ENXIO;
+
+ physaddr = (unsigned long)addr;
+ if (remap_pfn_range(vma, vma->vm_start,
+ physaddr >> PAGE_SHIFT,
+ vma->vm_end - vma->vm_start,
+ /*pgprot_noncached */
+ (vma->vm_page_prot))) {
+ return -EAGAIN;
+ }
+ break;
+ default:
+ return -ENXIO;
}
+ return 0;
+}
- addr = controlvm_get_channel_address();
- if (addr != 0) {
- controlvm_channel =
- visorchannel_create_with_lock
- (addr,
- sizeof(struct spar_controlvm_channel_protocol),
- spar_controlvm_channel_protocol_uuid);
- if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
- visorchannel_get_header(controlvm_channel))) {
- initialize_controlvm_payload();
- } else {
- visorchannel_destroy(controlvm_channel);
- controlvm_channel = NULL;
- return -ENODEV;
+static inline s64 issue_vmcall_query_guest_virtual_time_offset(void)
+{
+ u64 result = VMCALL_SUCCESS;
+ u64 physaddr = 0;
+
+ ISSUE_IO_VMCALL(VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET, physaddr,
+ result);
+ return result;
+}
+
+static inline int issue_vmcall_update_physical_time(u64 adjustment)
+{
+ int result = VMCALL_SUCCESS;
+
+ ISSUE_IO_VMCALL(VMCALL_UPDATE_PHYSICAL_TIME, adjustment, result);
+ return result;
+}
+
+static long visorchipset_ioctl(struct file *file, unsigned int cmd,
+ unsigned long arg)
+{
+ s64 adjustment;
+ s64 vrtc_offset;
+
+ switch (cmd) {
+ case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET:
+ /* get the physical rtc offset */
+ vrtc_offset = issue_vmcall_query_guest_virtual_time_offset();
+ if (copy_to_user((void __user *)arg, &vrtc_offset,
+ sizeof(vrtc_offset))) {
+ return -EFAULT;
+ }
+ return 0;
+ case VMCALL_UPDATE_PHYSICAL_TIME:
+ if (copy_from_user(&adjustment, (void __user *)arg,
+ sizeof(adjustment))) {
+ return -EFAULT;
}
+ return issue_vmcall_update_physical_time(adjustment);
+ default:
+ return -EFAULT;
+ }
+}
+
+static const struct file_operations visorchipset_fops = {
+ .owner = THIS_MODULE,
+ .open = visorchipset_open,
+ .read = NULL,
+ .write = NULL,
+ .unlocked_ioctl = visorchipset_ioctl,
+ .release = visorchipset_release,
+ .mmap = visorchipset_mmap,
+};
+
+static int
+visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
+{
+ int rc = 0;
+
+ file_controlvm_channel = controlvm_channel;
+ cdev_init(&file_cdev, &visorchipset_fops);
+ file_cdev.owner = THIS_MODULE;
+ if (MAJOR(major_dev) == 0) {
+ rc = alloc_chrdev_region(&major_dev, 0, 1, "visorchipset");
+ /* dynamic major device number registration required */
+ if (rc < 0)
+ return rc;
+ } else {
+ /* static major device number registration required */
+ rc = register_chrdev_region(major_dev, 1, "visorchipset");
+ if (rc < 0)
+ return rc;
+ }
+ rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1);
+ if (rc < 0) {
+ unregister_chrdev_region(major_dev, 1);
+ return rc;
+ }
+ return 0;
+}
+
+static int
+visorchipset_init(struct acpi_device *acpi_device)
+{
+ int rc = 0;
+ u64 addr;
+ int tmp_sz = sizeof(struct spar_controlvm_channel_protocol);
+ uuid_le uuid = SPAR_CONTROLVM_CHANNEL_PROTOCOL_UUID;
+
+ addr = controlvm_get_channel_address();
+ if (!addr)
+ return -ENODEV;
+
+ memset(&busdev_notifiers, 0, sizeof(busdev_notifiers));
+ memset(&controlvm_payload_info, 0, sizeof(controlvm_payload_info));
+
+ controlvm_channel = visorchannel_create_with_lock(addr, tmp_sz,
+ GFP_KERNEL, uuid);
+ if (SPAR_CONTROLVM_CHANNEL_OK_CLIENT(
+ visorchannel_get_header(controlvm_channel))) {
+ initialize_controlvm_payload();
} else {
+ visorchannel_destroy(controlvm_channel);
+ controlvm_channel = NULL;
return -ENODEV;
}
@@ -2190,47 +2464,32 @@ visorchipset_init(void)
goto cleanup;
}
- memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
- memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
- putfile_buffer_list_pool =
- kmem_cache_create(putfile_buffer_list_pool_name,
- sizeof(struct putfile_buffer_entry),
- 0, SLAB_HWCACHE_ALIGN, NULL);
- if (!putfile_buffer_list_pool) {
- POSTCODE_LINUX_2(CHIPSET_INIT_FAILURE_PC, DIAG_SEVERITY_ERR);
- rc = -1;
+ /* if booting in a crash kernel */
+ if (is_kdump_kernel())
+ INIT_DELAYED_WORK(&periodic_controlvm_work,
+ setup_crash_devices_work_queue);
+ else
+ INIT_DELAYED_WORK(&periodic_controlvm_work,
+ controlvm_periodic_work);
+ periodic_controlvm_workqueue =
+ create_singlethread_workqueue("visorchipset_controlvm");
+
+ if (!periodic_controlvm_workqueue) {
+ POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
+ DIAG_SEVERITY_ERR);
+ rc = -ENOMEM;
goto cleanup;
}
- if (!visorchipset_disable_controlvm) {
- /* if booting in a crash kernel */
- if (visorchipset_crash_kernel)
- INIT_DELAYED_WORK(&periodic_controlvm_work,
- setup_crash_devices_work_queue);
- else
- INIT_DELAYED_WORK(&periodic_controlvm_work,
- controlvm_periodic_work);
- periodic_controlvm_workqueue =
- create_singlethread_workqueue("visorchipset_controlvm");
-
- if (!periodic_controlvm_workqueue) {
- POSTCODE_LINUX_2(CREATE_WORKQUEUE_FAILED_PC,
- DIAG_SEVERITY_ERR);
- rc = -ENOMEM;
- goto cleanup;
- }
- most_recent_message_jiffies = jiffies;
- poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
- rc = queue_delayed_work(periodic_controlvm_workqueue,
- &periodic_controlvm_work, poll_jiffies);
- if (rc < 0) {
- POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
- DIAG_SEVERITY_ERR);
- goto cleanup;
- }
+ most_recent_message_jiffies = jiffies;
+ poll_jiffies = POLLJIFFIES_CONTROLVMCHANNEL_FAST;
+ rc = queue_delayed_work(periodic_controlvm_workqueue,
+ &periodic_controlvm_work, poll_jiffies);
+ if (rc < 0) {
+ POSTCODE_LINUX_2(QUEUE_DELAYED_WORK_PC,
+ DIAG_SEVERITY_ERR);
+ goto cleanup;
}
visorchipset_platform_device.dev.devt = major_dev;
@@ -2240,7 +2499,8 @@ visorchipset_init(void)
goto cleanup;
}
POSTCODE_LINUX_2(CHIPSET_INIT_SUCCESS_PC, POSTCODE_SEVERITY_INFO);
- rc = 0;
+
+ rc = visorbus_init();
cleanup:
if (rc) {
POSTCODE_LINUX_3(CHIPSET_INIT_FAILURE_PC, rc,
@@ -2250,83 +2510,101 @@ cleanup:
}
static void
-visorchipset_exit(void)
+visorchipset_file_cleanup(dev_t major_dev)
+{
+ if (file_cdev.ops)
+ cdev_del(&file_cdev);
+ file_cdev.ops = NULL;
+ unregister_chrdev_region(major_dev, 1);
+}
+
+static int
+visorchipset_exit(struct acpi_device *acpi_device)
{
POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
- if (visorchipset_disable_controlvm) {
- ;
- } else {
- cancel_delayed_work(&periodic_controlvm_work);
- flush_workqueue(periodic_controlvm_workqueue);
- destroy_workqueue(periodic_controlvm_workqueue);
- periodic_controlvm_workqueue = NULL;
- destroy_controlvm_payload_info(&controlvm_payload_info);
- }
- if (putfile_buffer_list_pool) {
- kmem_cache_destroy(putfile_buffer_list_pool);
- putfile_buffer_list_pool = NULL;
- }
+ visorbus_exit();
- cleanup_controlvm_structures();
+ cancel_delayed_work(&periodic_controlvm_work);
+ flush_workqueue(periodic_controlvm_workqueue);
+ destroy_workqueue(periodic_controlvm_workqueue);
+ periodic_controlvm_workqueue = NULL;
+ destroy_controlvm_payload_info(&controlvm_payload_info);
- memset(&g_diag_msg_hdr, 0, sizeof(struct controlvm_message_header));
+ cleanup_controlvm_structures();
memset(&g_chipset_msg_hdr, 0, sizeof(struct controlvm_message_header));
- memset(&g_del_dump_msg_hdr, 0, sizeof(struct controlvm_message_header));
-
visorchannel_destroy(controlvm_channel);
visorchipset_file_cleanup(visorchipset_platform_device.dev.devt);
POSTCODE_LINUX_2(DRIVER_EXIT_PC, POSTCODE_SEVERITY_INFO);
+
+ return 0;
+}
+
+static const struct acpi_device_id unisys_device_ids[] = {
+ {"PNP0A07", 0},
+ {"", 0},
+};
+
+static struct acpi_driver unisys_acpi_driver = {
+ .name = "unisys_acpi",
+ .class = "unisys_acpi_class",
+ .owner = THIS_MODULE,
+ .ids = unisys_device_ids,
+ .ops = {
+ .add = visorchipset_init,
+ .remove = visorchipset_exit,
+ },
+};
+static __init uint32_t visorutil_spar_detect(void)
+{
+ unsigned int eax, ebx, ecx, edx;
+
+ if (cpu_has_hypervisor) {
+ /* check the ID */
+ cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx);
+ return (ebx == UNISYS_SPAR_ID_EBX) &&
+ (ecx == UNISYS_SPAR_ID_ECX) &&
+ (edx == UNISYS_SPAR_ID_EDX);
+ } else {
+ return 0;
+ }
}
-module_param_named(testvnic, visorchipset_testvnic, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testvnic, "1 to test vnic, using dummy VNIC connected via a loopback to a physical ethernet");
-int visorchipset_testvnic = 0;
+static int init_unisys(void)
+{
+ int result;
+ if (!visorutil_spar_detect())
+ return -ENODEV;
+
+ result = acpi_bus_register_driver(&unisys_acpi_driver);
+ if (result)
+ return -ENODEV;
-module_param_named(testvnicclient, visorchipset_testvnicclient, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testvnicclient, "1 to test vnic, using real VNIC channel attached to a separate IOVM guest");
-int visorchipset_testvnicclient = 0;
+ pr_info("Unisys Visorchipset Driver Loaded.\n");
+ return 0;
+};
-module_param_named(testmsg, visorchipset_testmsg, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testmsg,
- "1 to manufacture the chipset, bus, and switch messages");
-int visorchipset_testmsg = 0;
+static void exit_unisys(void)
+{
+ acpi_bus_unregister_driver(&unisys_acpi_driver);
+}
module_param_named(major, visorchipset_major, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_major, "major device number to use for the device node");
-int visorchipset_major = 0;
-
-module_param_named(serverregwait, visorchipset_serverregwait, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_serverreqwait,
+MODULE_PARM_DESC(visorchipset_major,
+ "major device number to use for the device node");
+module_param_named(visorbusregwait, visorchipset_visorbusregwait, int, S_IRUGO);
+MODULE_PARM_DESC(visorchipset_visorbusreqwait,
"1 to have the module wait for the visor bus to register");
-int visorchipset_serverregwait = 0; /* default is off */
-module_param_named(clientregwait, visorchipset_clientregwait, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_clientregwait, "1 to have the module wait for the visorclientbus to register");
-int visorchipset_clientregwait = 1; /* default is on */
-module_param_named(testteardown, visorchipset_testteardown, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_testteardown,
- "1 to test teardown of the chipset, bus, and switch");
-int visorchipset_testteardown = 0; /* default is off */
-module_param_named(disable_controlvm, visorchipset_disable_controlvm, int,
- S_IRUGO);
-MODULE_PARM_DESC(visorchipset_disable_controlvm,
- "1 to disable polling of controlVm channel");
-int visorchipset_disable_controlvm = 0; /* default is off */
-module_param_named(crash_kernel, visorchipset_crash_kernel, int, S_IRUGO);
-MODULE_PARM_DESC(visorchipset_crash_kernel,
- "1 means we are running in crash kernel");
-int visorchipset_crash_kernel = 0; /* default is running in non-crash kernel */
module_param_named(holdchipsetready, visorchipset_holdchipsetready,
int, S_IRUGO);
MODULE_PARM_DESC(visorchipset_holdchipsetready,
"1 to hold response to CHIPSET_READY");
-int visorchipset_holdchipsetready = 0; /* default is to send CHIPSET_READY
- * response immediately */
-module_init(visorchipset_init);
-module_exit(visorchipset_exit);
+
+module_init(init_unisys);
+module_exit(exit_unisys);
MODULE_AUTHOR("Unisys");
MODULE_LICENSE("GPL");
diff --git a/drivers/staging/unisys/common-spar/include/vmcallinterface.h b/drivers/staging/unisys/visorbus/vmcallinterface.h
index 59a7459eb96243..dc09caf7d07524 100644
--- a/drivers/staging/unisys/common-spar/include/vmcallinterface.h
+++ b/drivers/staging/unisys/visorbus/vmcallinterface.h
@@ -85,10 +85,8 @@ enum vmcall_monitor_interface_method_tuple { /* VMCALL identification tuples */
/* The following uses VMCALL_POST_CODE_LOGEVENT interface but is currently
* not used much */
#define ISSUE_IO_VMCALL_POSTCODE_SEVERITY(postcode, severity) \
-do { \
ISSUE_IO_EXTENDED_VMCALL(VMCALL_POST_CODE_LOGEVENT, severity, \
- MDS_APPOS, postcode); \
-} while (0)
+ MDS_APPOS, postcode)
#endif
/* Structures for IO VMCALLs */
diff --git a/drivers/staging/unisys/visorchannel/Kconfig b/drivers/staging/unisys/visorchannel/Kconfig
index 8d31bebf039abf..3148f6b2a2e91e 100644
--- a/drivers/staging/unisys/visorchannel/Kconfig
+++ b/drivers/staging/unisys/visorchannel/Kconfig
@@ -4,7 +4,6 @@
config UNISYS_VISORCHANNEL
tristate "Unisys visorchannel driver"
- select UNISYS_VISORUTIL
---help---
If you say Y here, you will enable the Unisys visorchannel driver.
diff --git a/drivers/staging/unisys/visorchannel/Makefile b/drivers/staging/unisys/visorchannel/Makefile
index e079c96b1cdf8d..0c0cacbd8843ed 100644
--- a/drivers/staging/unisys/visorchannel/Makefile
+++ b/drivers/staging/unisys/visorchannel/Makefile
@@ -7,6 +7,4 @@ obj-$(CONFIG_UNISYS_VISORCHANNEL) += visorchannel.o
visorchannel-y := visorchannel_main.o visorchannel_funcs.o
ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
ccflags-y += -Idrivers/staging/unisys/visorutil
diff --git a/drivers/staging/unisys/visorchannel/globals.h b/drivers/staging/unisys/visorchannel/globals.h
index 0ed8e1d8033a8d..1c3c427e3e138e 100644
--- a/drivers/staging/unisys/visorchannel/globals.h
+++ b/drivers/staging/unisys/visorchannel/globals.h
@@ -18,8 +18,6 @@
#ifndef __VISORCHANNEL_GLOBALS_H__
#define __VISORCHANNEL_GLOBALS_H__
-#include "timskmod.h"
-#include "memregion.h"
#include "version.h"
#define MYDRVNAME "visorchannel"
diff --git a/drivers/staging/unisys/visorchannel/visorchannel.h b/drivers/staging/unisys/visorchannel/visorchannel.h
deleted file mode 100644
index 63f1b976037364..00000000000000
--- a/drivers/staging/unisys/visorchannel/visorchannel.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/* visorchannel.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORCHANNEL_H__
-#define __VISORCHANNEL_H__
-
-#include <linux/uuid.h>
-
-#include "memregion.h"
-#include "channel.h"
-#ifndef HOSTADDRESS
-#define HOSTADDRESS u64
-#endif
-#ifndef BOOL
-#define BOOL int
-#endif
-
-/* Note that for visorchannel_create() and visorchannel_create_overlapped(),
- * <channel_bytes> and <guid> arguments may be 0 if we are a channel CLIENT.
- * In this case, the values can simply be read from the channel header.
- */
-struct visorchannel *visorchannel_create(HOSTADDRESS physaddr,
- ulong channel_bytes, uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped(ulong channel_bytes,
- struct visorchannel *parent,
- ulong off, uuid_le guid);
-struct visorchannel *visorchannel_create_with_lock(HOSTADDRESS physaddr,
- ulong channel_bytes,
- uuid_le guid);
-struct visorchannel *visorchannel_create_overlapped_with_lock(
- ulong channel_bytes,
- struct visorchannel *parent,
- ulong off, uuid_le guid);
-void visorchannel_destroy(struct visorchannel *channel);
-int visorchannel_read(struct visorchannel *channel, ulong offset,
- void *local, ulong nbytes);
-int visorchannel_write(struct visorchannel *channel, ulong offset,
- void *local, ulong nbytes);
-int visorchannel_clear(struct visorchannel *channel, ulong offset,
- u8 ch, ulong nbytes);
-BOOL visorchannel_signalremove(struct visorchannel *channel, u32 queue,
- void *msg);
-BOOL visorchannel_signalinsert(struct visorchannel *channel, u32 queue,
- void *msg);
-int visorchannel_signalqueue_slots_avail(struct visorchannel *channel,
- u32 queue);
-int visorchannel_signalqueue_max_slots(struct visorchannel *channel, u32 queue);
-HOSTADDRESS visorchannel_get_physaddr(struct visorchannel *channel);
-ulong visorchannel_get_nbytes(struct visorchannel *channel);
-char *visorchannel_id(struct visorchannel *channel, char *s);
-char *visorchannel_zoneid(struct visorchannel *channel, char *s);
-u64 visorchannel_get_clientpartition(struct visorchannel *channel);
-uuid_le visorchannel_get_uuid(struct visorchannel *channel);
-struct memregion *visorchannel_get_memregion(struct visorchannel *channel);
-char *visorchannel_uuid_id(uuid_le *guid, char *s);
-void visorchannel_debug(struct visorchannel *channel, int num_queues,
- struct seq_file *seq, u32 off);
-void visorchannel_dump_section(struct visorchannel *chan, char *s,
- int off, int len, struct seq_file *seq);
-void __iomem *visorchannel_get_header(struct visorchannel *channel);
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/Kconfig b/drivers/staging/unisys/visorchipset/Kconfig
deleted file mode 100644
index b03bfc5c3043f1..00000000000000
--- a/drivers/staging/unisys/visorchipset/Kconfig
+++ /dev/null
@@ -1,11 +0,0 @@
-#
-# Unisys visorchipset configuration
-#
-
-config UNISYS_VISORCHIPSET
- tristate "Unisys visorchipset driver"
- select UNISYS_VISORUTIL
- select UNISYS_VISORCHANNEL
- ---help---
- If you say Y here, you will enable the Unisys visorchipset driver.
-
diff --git a/drivers/staging/unisys/visorchipset/Makefile b/drivers/staging/unisys/visorchipset/Makefile
deleted file mode 100644
index 12686906bef3d5..00000000000000
--- a/drivers/staging/unisys/visorchipset/Makefile
+++ /dev/null
@@ -1,15 +0,0 @@
-#
-# Makefile for Unisys visorchipset
-#
-
-obj-$(CONFIG_UNISYS_VISORCHIPSET) += visorchipset.o
-
-visorchipset-y := visorchipset_main.o file.o parser.o
-
-ccflags-y += -Idrivers/staging/unisys/include
-ccflags-y += -Idrivers/staging/unisys/uislib
-ccflags-y += -Idrivers/staging/unisys/visorchannel
-ccflags-y += -Idrivers/staging/unisys/common-spar/include
-ccflags-y += -Idrivers/staging/unisys/common-spar/include/channels
-ccflags-y += -Idrivers/staging/unisys/visorutil
-ccflags-y += -Iinclude/generated
diff --git a/drivers/staging/unisys/visorchipset/file.c b/drivers/staging/unisys/visorchipset/file.c
deleted file mode 100644
index 203de0b5f6071f..00000000000000
--- a/drivers/staging/unisys/visorchipset/file.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* file.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/* This contains the implementation that allows a usermode program to
- * communicate with the visorchipset driver using a device/file interface.
- */
-
-#include "globals.h"
-#include "visorchannel.h"
-#include <linux/mm.h>
-#include <linux/fs.h>
-#include "uisutils.h"
-#include "file.h"
-
-#define CURRENT_FILE_PC VISOR_CHIPSET_PC_file_c
-
-static struct cdev file_cdev;
-static struct visorchannel **file_controlvm_channel;
-
-void
-visorchipset_file_cleanup(dev_t major_dev)
-{
- if (file_cdev.ops != NULL)
- cdev_del(&file_cdev);
- file_cdev.ops = NULL;
- unregister_chrdev_region(major_dev, 1);
-}
-
-static int
-visorchipset_open(struct inode *inode, struct file *file)
-{
- unsigned minor_number = iminor(inode);
-
- if (minor_number != 0)
- return -ENODEV;
- file->private_data = NULL;
- return 0;
-}
-
-static int
-visorchipset_release(struct inode *inode, struct file *file)
-{
- return 0;
-}
-
-static int
-visorchipset_mmap(struct file *file, struct vm_area_struct *vma)
-{
- ulong physaddr = 0;
- ulong offset = vma->vm_pgoff << PAGE_SHIFT;
- GUEST_PHYSICAL_ADDRESS addr = 0;
-
- /* sv_enable_dfp(); */
- if (offset & (PAGE_SIZE - 1))
- return -ENXIO; /* need aligned offsets */
-
- switch (offset) {
- case VISORCHIPSET_MMAP_CONTROLCHANOFFSET:
- vma->vm_flags |= VM_IO;
- if (*file_controlvm_channel == NULL) {
- return -ENXIO;
- }
- visorchannel_read(*file_controlvm_channel,
- offsetof(struct spar_controlvm_channel_protocol,
- gp_control_channel),
- &addr, sizeof(addr));
- if (addr == 0) {
- return -ENXIO;
- }
- physaddr = (ulong)addr;
- if (remap_pfn_range(vma, vma->vm_start,
- physaddr >> PAGE_SHIFT,
- vma->vm_end - vma->vm_start,
- /*pgprot_noncached */
- (vma->vm_page_prot))) {
- return -EAGAIN;
- }
- break;
- default:
- return -ENOSYS;
- }
- return 0;
-}
-
-static long visorchipset_ioctl(struct file *file, unsigned int cmd,
- unsigned long arg)
-{
- s64 adjustment;
- s64 vrtc_offset;
-
- switch (cmd) {
- case VMCALL_QUERY_GUEST_VIRTUAL_TIME_OFFSET:
- /* get the physical rtc offset */
- vrtc_offset = issue_vmcall_query_guest_virtual_time_offset();
- if (copy_to_user
- ((void __user *)arg, &vrtc_offset, sizeof(vrtc_offset))) {
- return -EFAULT;
- }
- return SUCCESS;
- case VMCALL_UPDATE_PHYSICAL_TIME:
- if (copy_from_user
- (&adjustment, (void __user *)arg, sizeof(adjustment))) {
- return -EFAULT;
- }
- return issue_vmcall_update_physical_time(adjustment);
- default:
- return -EFAULT;
- }
-}
-
-static const struct file_operations visorchipset_fops = {
- .owner = THIS_MODULE,
- .open = visorchipset_open,
- .read = NULL,
- .write = NULL,
- .unlocked_ioctl = visorchipset_ioctl,
- .release = visorchipset_release,
- .mmap = visorchipset_mmap,
-};
-
-int
-visorchipset_file_init(dev_t major_dev, struct visorchannel **controlvm_channel)
-{
- int rc = 0;
-
- file_controlvm_channel = controlvm_channel;
- cdev_init(&file_cdev, &visorchipset_fops);
- file_cdev.owner = THIS_MODULE;
- if (MAJOR(major_dev) == 0) {
- rc = alloc_chrdev_region(&major_dev, 0, 1, MYDRVNAME);
- /* dynamic major device number registration required */
- if (rc < 0)
- return rc;
- } else {
- /* static major device number registration required */
- rc = register_chrdev_region(major_dev, 1, MYDRVNAME);
- if (rc < 0)
- return rc;
- }
- rc = cdev_add(&file_cdev, MKDEV(MAJOR(major_dev), 0), 1);
- if (rc < 0) {
- unregister_chrdev_region(major_dev, 1);
- return rc;
- }
- return 0;
-}
diff --git a/drivers/staging/unisys/visorchipset/file.h b/drivers/staging/unisys/visorchipset/file.h
deleted file mode 100644
index 51f7699b744bd3..00000000000000
--- a/drivers/staging/unisys/visorchipset/file.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/* file.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __FILE_H__
-#define __FILE_H__
-
-#include "globals.h"
-
-int visorchipset_file_init(dev_t majorDev,
- struct visorchannel **pControlVm_channel);
-void visorchipset_file_cleanup(dev_t major_dev);
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/globals.h b/drivers/staging/unisys/visorchipset/globals.h
deleted file mode 100644
index f76e498a36b5f0..00000000000000
--- a/drivers/staging/unisys/visorchipset/globals.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* globals.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORCHIPSET_GLOBALS_H__
-#define __VISORCHIPSET_GLOBALS_H__
-
-#include "diagnostics/appos_subsystems.h"
-#include "timskmod.h"
-#include "visorchipset.h"
-#include "visorchipset_umode.h"
-#include "version.h"
-
-#define MYDRVNAME "visorchipset"
-
-/* module parameters */
-
-extern int visorchipset_testvnic;
-extern int visorchipset_testvnicclient;
-extern int visorchipset_testmsg;
-extern int visorchipset_major;
-extern int visorchipset_serverregwait;
-extern int visorchipset_clientregwait;
-extern int visorchipset_testteardown;
-extern int visorchipset_disable_controlvm;
-extern int visorchipset_crash_kernel;
-extern int visorchipset_holdchipsetready;
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/parser.c b/drivers/staging/unisys/visorchipset/parser.c
deleted file mode 100644
index d8a2d6f5a75d7a..00000000000000
--- a/drivers/staging/unisys/visorchipset/parser.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/* parser.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#include "parser.h"
-#include "memregion.h"
-#include "controlvmchannel.h"
-#include <linux/ctype.h>
-#include <linux/mm.h>
-#include <linux/uuid.h>
-
-#define MYDRVNAME "visorchipset_parser"
-#define CURRENT_FILE_PC VISOR_CHIPSET_PC_parser_c
-
-/* We will refuse to allocate more than this many bytes to copy data from
- * incoming payloads. This serves as a throttling mechanism.
- */
-#define MAX_CONTROLVM_PAYLOAD_BYTES (1024*128)
-static ulong controlvm_payload_bytes_buffered;
-
-struct parser_context {
- ulong allocbytes;
- ulong param_bytes;
- u8 *curr;
- ulong bytes_remaining;
- BOOL byte_stream;
- char data[0];
-};
-
-static struct parser_context *
-parser_init_guts(u64 addr, u32 bytes, BOOL local,
- BOOL standard_payload_header, BOOL *retry)
-{
- int allocbytes = sizeof(struct parser_context) + bytes;
- struct parser_context *rc = NULL;
- struct parser_context *ctx = NULL;
- struct memregion *rgn = NULL;
- struct spar_controlvm_parameters_header *phdr = NULL;
-
- if (retry)
- *retry = FALSE;
- if (!standard_payload_header)
- /* alloc and 0 extra byte to ensure payload is
- * '\0'-terminated
- */
- allocbytes++;
- if ((controlvm_payload_bytes_buffered + bytes)
- > MAX_CONTROLVM_PAYLOAD_BYTES) {
- if (retry)
- *retry = TRUE;
- rc = NULL;
- goto cleanup;
- }
- ctx = kzalloc(allocbytes, GFP_KERNEL|__GFP_NORETRY);
- if (!ctx) {
- if (retry)
- *retry = TRUE;
- rc = NULL;
- goto cleanup;
- }
-
- ctx->allocbytes = allocbytes;
- ctx->param_bytes = bytes;
- ctx->curr = NULL;
- ctx->bytes_remaining = 0;
- ctx->byte_stream = FALSE;
- if (local) {
- void *p;
-
- if (addr > virt_to_phys(high_memory - 1)) {
- rc = NULL;
- goto cleanup;
- }
- p = __va((ulong) (addr));
- memcpy(ctx->data, p, bytes);
- } else {
- rgn = visor_memregion_create(addr, bytes);
- if (!rgn) {
- rc = NULL;
- goto cleanup;
- }
- if (visor_memregion_read(rgn, 0, ctx->data, bytes) < 0) {
- rc = NULL;
- goto cleanup;
- }
- }
- if (!standard_payload_header) {
- ctx->byte_stream = TRUE;
- rc = ctx;
- goto cleanup;
- }
- phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
- if (phdr->total_length != bytes) {
- rc = NULL;
- goto cleanup;
- }
- if (phdr->total_length < phdr->header_length) {
- rc = NULL;
- goto cleanup;
- }
- if (phdr->header_length <
- sizeof(struct spar_controlvm_parameters_header)) {
- rc = NULL;
- goto cleanup;
- }
-
- rc = ctx;
-cleanup:
- if (rgn) {
- visor_memregion_destroy(rgn);
- rgn = NULL;
- }
- if (rc) {
- controlvm_payload_bytes_buffered += ctx->param_bytes;
- } else {
- if (ctx) {
- parser_done(ctx);
- ctx = NULL;
- }
- }
- return rc;
-}
-
-struct parser_context *
-parser_init(u64 addr, u32 bytes, BOOL local, BOOL *retry)
-{
- return parser_init_guts(addr, bytes, local, TRUE, retry);
-}
-
-/* Call this instead of parser_init() if the payload area consists of just
- * a sequence of bytes, rather than a struct spar_controlvm_parameters_header
- * structures. Afterwards, you can call parser_simpleString_get() or
- * parser_byteStream_get() to obtain the data.
- */
-struct parser_context *
-parser_init_byte_stream(u64 addr, u32 bytes, BOOL local, BOOL *retry)
-{
- return parser_init_guts(addr, bytes, local, FALSE, retry);
-}
-
-/* Obtain '\0'-terminated copy of string in payload area.
- */
-char *
-parser_simpleString_get(struct parser_context *ctx)
-{
- if (!ctx->byte_stream)
- return NULL;
- return ctx->data; /* note this IS '\0'-terminated, because of
- * the num of bytes we alloc+clear in
- * parser_init_byteStream() */
-}
-
-/* Obtain a copy of the buffer in the payload area.
- */
-void *parser_byte_stream_get(struct parser_context *ctx, ulong *nbytes)
-{
- if (!ctx->byte_stream)
- return NULL;
- if (nbytes)
- *nbytes = ctx->param_bytes;
- return (void *)ctx->data;
-}
-
-uuid_le
-parser_id_get(struct parser_context *ctx)
-{
- struct spar_controlvm_parameters_header *phdr = NULL;
-
- if (ctx == NULL)
- return NULL_UUID_LE;
- phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
- return phdr->id;
-}
-
-void
-parser_param_start(struct parser_context *ctx, PARSER_WHICH_STRING which_string)
-{
- struct spar_controlvm_parameters_header *phdr = NULL;
-
- if (ctx == NULL)
- goto Away;
- phdr = (struct spar_controlvm_parameters_header *)(ctx->data);
- switch (which_string) {
- case PARSERSTRING_INITIATOR:
- ctx->curr = ctx->data + phdr->initiator_offset;
- ctx->bytes_remaining = phdr->initiator_length;
- break;
- case PARSERSTRING_TARGET:
- ctx->curr = ctx->data + phdr->target_offset;
- ctx->bytes_remaining = phdr->target_length;
- break;
- case PARSERSTRING_CONNECTION:
- ctx->curr = ctx->data + phdr->connection_offset;
- ctx->bytes_remaining = phdr->connection_length;
- break;
- case PARSERSTRING_NAME:
- ctx->curr = ctx->data + phdr->name_offset;
- ctx->bytes_remaining = phdr->name_length;
- break;
- default:
- break;
- }
-
-Away:
- return;
-}
-
-void
-parser_done(struct parser_context *ctx)
-{
- if (!ctx)
- return;
- controlvm_payload_bytes_buffered -= ctx->param_bytes;
- kfree(ctx);
-}
-
-/** Return length of string not counting trailing spaces. */
-static int
-string_length_no_trail(char *s, int len)
-{
- int i = len - 1;
-
- while (i >= 0) {
- if (!isspace(s[i]))
- return i + 1;
- i--;
- }
- return 0;
-}
-
-/** Grab the next name and value out of the parameter buffer.
- * The entire parameter buffer looks like this:
- * <name>=<value>\0
- * <name>=<value>\0
- * ...
- * \0
- * If successful, the next <name> value is returned within the supplied
- * <nam> buffer (the value is always upper-cased), and the corresponding
- * <value> is returned within a kmalloc()ed buffer, whose pointer is
- * provided as the return value of this function.
- * (The total number of bytes allocated is strlen(<value>)+1.)
- *
- * NULL is returned to indicate failure, which can occur for several reasons:
- * - all <name>=<value> pairs have already been processed
- * - bad parameter
- * - parameter buffer ends prematurely (couldn't find an '=' or '\0' within
- * the confines of the parameter buffer)
- * - the <nam> buffer is not large enough to hold the <name> of the next
- * parameter
- */
-void *
-parser_param_get(struct parser_context *ctx, char *nam, int namesize)
-{
- u8 *pscan, *pnam = nam;
- ulong nscan;
- int value_length = -1, orig_value_length = -1;
- void *value = NULL;
- int i;
- int closing_quote = 0;
-
- if (!ctx)
- return NULL;
- pscan = ctx->curr;
- nscan = ctx->bytes_remaining;
- if (nscan == 0)
- return NULL;
- if (*pscan == '\0')
- /* This is the normal return point after you have processed
- * all of the <name>=<value> pairs in a syntactically-valid
- * parameter buffer.
- */
- return NULL;
-
- /* skip whitespace */
- while (isspace(*pscan)) {
- pscan++;
- nscan--;
- if (nscan == 0)
- return NULL;
- }
-
- while (*pscan != ':') {
- if (namesize <= 0)
- return NULL;
- *pnam = toupper(*pscan);
- pnam++;
- namesize--;
- pscan++;
- nscan--;
- if (nscan == 0)
- return NULL;
- }
- if (namesize <= 0)
- return NULL;
- *pnam = '\0';
- nam[string_length_no_trail(nam, strlen(nam))] = '\0';
-
- /* point to char immediately after ":" in "<name>:<value>" */
- pscan++;
- nscan--;
- /* skip whitespace */
- while (isspace(*pscan)) {
- pscan++;
- nscan--;
- if (nscan == 0)
- return NULL;
- }
- if (nscan == 0)
- return NULL;
- if (*pscan == '\'' || *pscan == '"') {
- closing_quote = *pscan;
- pscan++;
- nscan--;
- if (nscan == 0)
- return NULL;
- }
-
- /* look for a separator character, terminator character, or
- * end of data
- */
- for (i = 0, value_length = -1; i < nscan; i++) {
- if (closing_quote) {
- if (pscan[i] == '\0')
- return NULL;
- if (pscan[i] == closing_quote) {
- value_length = i;
- break;
- }
- } else
- if (pscan[i] == ',' || pscan[i] == ';'
- || pscan[i] == '\0') {
- value_length = i;
- break;
- }
- }
- if (value_length < 0) {
- if (closing_quote)
- return NULL;
- value_length = nscan;
- }
- orig_value_length = value_length;
- if (closing_quote == 0)
- value_length = string_length_no_trail(pscan, orig_value_length);
- value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
- if (value == NULL)
- return NULL;
- memcpy(value, pscan, value_length);
- ((u8 *) (value))[value_length] = '\0';
-
- pscan += orig_value_length;
- nscan -= orig_value_length;
-
- /* skip past separator or closing quote */
- if (nscan > 0) {
- if (*pscan != '\0') {
- pscan++;
- nscan--;
- }
- }
-
- if (closing_quote && (nscan > 0)) {
- /* we still need to skip around the real separator if present */
- /* first, skip whitespace */
- while (isspace(*pscan)) {
- pscan++;
- nscan--;
- if (nscan == 0)
- break;
- }
- if (nscan > 0) {
- if (*pscan == ',' || *pscan == ';') {
- pscan++;
- nscan--;
- } else if (*pscan != '\0') {
- kfree(value);
- value = NULL;
- return NULL;
- }
- }
- }
- ctx->curr = pscan;
- ctx->bytes_remaining = nscan;
- return value;
-}
-
-void *
-parser_string_get(struct parser_context *ctx)
-{
- u8 *pscan;
- ulong nscan;
- int value_length = -1;
- void *value = NULL;
- int i;
-
- if (!ctx)
- return NULL;
- pscan = ctx->curr;
- nscan = ctx->bytes_remaining;
- if (nscan == 0)
- return NULL;
- if (!pscan)
- return NULL;
- for (i = 0, value_length = -1; i < nscan; i++)
- if (pscan[i] == '\0') {
- value_length = i;
- break;
- }
- if (value_length < 0) /* '\0' was not included in the length */
- value_length = nscan;
- value = kmalloc(value_length + 1, GFP_KERNEL|__GFP_NORETRY);
- if (value == NULL)
- return NULL;
- if (value_length > 0)
- memcpy(value, pscan, value_length);
- ((u8 *) (value))[value_length] = '\0';
- return value;
-}
diff --git a/drivers/staging/unisys/visorchipset/parser.h b/drivers/staging/unisys/visorchipset/parser.h
deleted file mode 100644
index 2b903f1beff2e3..00000000000000
--- a/drivers/staging/unisys/visorchipset/parser.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* parser.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __PARSER_H__
-#define __PARSER_H__
-
-#include <linux/uuid.h>
-
-#include "timskmod.h"
-#include "channel.h"
-
-typedef enum {
- PARSERSTRING_INITIATOR,
- PARSERSTRING_TARGET,
- PARSERSTRING_CONNECTION,
- PARSERSTRING_NAME,
-} PARSER_WHICH_STRING;
-
-struct parser_context *parser_init(u64 addr, u32 bytes, BOOL isLocal,
- BOOL *tryAgain);
-struct parser_context *parser_init_byte_stream(u64 addr, u32 bytes, BOOL local,
- BOOL *retry);
-void parser_param_start(struct parser_context *ctx,
- PARSER_WHICH_STRING which_string);
-void *parser_param_get(struct parser_context *ctx, char *nam, int namesize);
-void *parser_string_get(struct parser_context *ctx);
-uuid_le parser_id_get(struct parser_context *ctx);
-char *parser_simpleString_get(struct parser_context *ctx);
-void *parser_byte_stream_get(struct parser_context *ctx, ulong *nbytes);
-void parser_done(struct parser_context *ctx);
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset.h b/drivers/staging/unisys/visorchipset/visorchipset.h
deleted file mode 100644
index bd46df9ef45a36..00000000000000
--- a/drivers/staging/unisys/visorchipset/visorchipset.h
+++ /dev/null
@@ -1,236 +0,0 @@
-/* visorchipset.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __VISORCHIPSET_H__
-#define __VISORCHIPSET_H__
-
-#include <linux/uuid.h>
-
-#include "timskmod.h"
-#include "channel.h"
-#include "controlvmchannel.h"
-#include "parser.h"
-#include "procobjecttree.h"
-#include "vbusdeviceinfo.h"
-#include "vbushelper.h"
-
-/** Describes the state from the perspective of which controlvm messages have
- * been received for a bus or device.
- */
-struct visorchipset_state {
- u32 created:1;
- u32 attached:1;
- u32 configured:1;
- u32 running:1;
- /* Add new fields above. */
- /* Remaining bits in this 32-bit word are unused. */
-};
-
-enum visorchipset_addresstype {
- /** address is guest physical, but outside of the physical memory
- * region that is controlled by the running OS (this is the normal
- * address type for Supervisor channels)
- */
- ADDRTYPE_LOCALPHYSICAL,
-
- /** address is guest physical, and withIN the confines of the
- * physical memory controlled by the running OS.
- */
- ADDRTYPE_LOCALTEST,
-};
-
-enum crash_obj_type {
- CRASH_DEV,
- CRASH_BUS,
-};
-
-/** Attributes for a particular Supervisor channel.
- */
-struct visorchipset_channel_info {
- enum visorchipset_addresstype addr_type;
- HOSTADDRESS channel_addr;
- struct irq_info intr;
- u64 n_channel_bytes;
- uuid_le channel_type_uuid;
- uuid_le channel_inst_uuid;
-
-};
-
-/** Attributes for a particular Supervisor device.
- * Any visorchipset client can query these attributes using
- * visorchipset_get_client_device_info() or
- * visorchipset_get_server_device_info().
- */
-struct visorchipset_device_info {
- struct list_head entry;
- u32 bus_no;
- u32 dev_no;
- uuid_le dev_inst_uuid;
- struct visorchipset_state state;
- struct visorchipset_channel_info chan_info;
- u32 reserved1; /* control_vm_id */
- u64 reserved2;
- u32 switch_no; /* when devState.attached==1 */
- u32 internal_port_no; /* when devState.attached==1 */
- struct controlvm_message_header pending_msg_hdr;/* CONTROLVM_MESSAGE */
- /** For private use by the bus driver */
- void *bus_driver_context;
-
-};
-
-static inline struct visorchipset_device_info *finddevice(
- struct list_head *list, u32 bus_no, u32 dev_no)
-{
- struct visorchipset_device_info *p;
-
- list_for_each_entry(p, list, entry) {
- if (p->bus_no == bus_no && p->dev_no == dev_no)
- return p;
- }
- return NULL;
-}
-
-static inline void delbusdevices(struct list_head *list, u32 bus_no)
-{
- struct visorchipset_device_info *p, *tmp;
-
- list_for_each_entry_safe(p, tmp, list, entry) {
- if (p->bus_no == bus_no) {
- list_del(&p->entry);
- kfree(p);
- }
- }
-}
-
-/** Attributes for a particular Supervisor bus.
- * (For a service partition acting as the server for buses/devices, there
- * is a 1-to-1 relationship between busses and guest partitions.)
- * Any visorchipset client can query these attributes using
- * visorchipset_get_client_bus_info() or visorchipset_get_bus_info().
- */
-struct visorchipset_bus_info {
- struct list_head entry;
- u32 bus_no;
- struct visorchipset_state state;
- struct visorchipset_channel_info chan_info;
- uuid_le partition_uuid;
- u64 partition_handle;
- u8 *name; /* UTF8 */
- u8 *description; /* UTF8 */
- u64 reserved1;
- u32 reserved2;
- struct {
- u32 server:1;
- /* Add new fields above. */
- /* Remaining bits in this 32-bit word are unused. */
- } flags;
- struct controlvm_message_header pending_msg_hdr;/* CONTROLVM MsgHdr */
- /** For private use by the bus driver */
- void *bus_driver_context;
- u64 dev_no;
-
-};
-
-static inline struct visorchipset_bus_info *
-findbus(struct list_head *list, u32 bus_no)
-{
- struct visorchipset_bus_info *p;
-
- list_for_each_entry(p, list, entry) {
- if (p->bus_no == bus_no)
- return p;
- }
- return NULL;
-}
-
-/* These functions will be called from within visorchipset when certain
- * events happen. (The implementation of these functions is outside of
- * visorchipset.)
- */
-struct visorchipset_busdev_notifiers {
- void (*bus_create)(ulong bus_no);
- void (*bus_destroy)(ulong bus_no);
- void (*device_create)(ulong bus_no, ulong dev_no);
- void (*device_destroy)(ulong bus_no, ulong dev_no);
- void (*device_pause)(ulong bus_no, ulong dev_no);
- void (*device_resume)(ulong bus_no, ulong dev_no);
- int (*get_channel_info)(uuid_le type_uuid, ulong *min_size,
- ulong *max_size);
-};
-
-/* These functions live inside visorchipset, and will be called to indicate
- * responses to specific events (by code outside of visorchipset).
- * For now, the value for each response is simply either:
- * 0 = it worked
- * -1 = it failed
- */
-struct visorchipset_busdev_responders {
- void (*bus_create)(ulong bus_no, int response);
- void (*bus_destroy)(ulong bus_no, int response);
- void (*device_create)(ulong bus_no, ulong dev_no, int response);
- void (*device_destroy)(ulong bus_no, ulong dev_no, int response);
- void (*device_pause)(ulong bus_no, ulong dev_no, int response);
- void (*device_resume)(ulong bus_no, ulong dev_no, int response);
-};
-
-/** Register functions (in the bus driver) to get called by visorchipset
- * whenever a bus or device appears for which this service partition is
- * to be the server for. visorchipset will fill in <responders>, to
- * indicate functions the bus driver should call to indicate message
- * responses.
- */
-void
-visorchipset_register_busdev_client(
- struct visorchipset_busdev_notifiers *notifiers,
- struct visorchipset_busdev_responders *responders,
- struct ultra_vbus_deviceinfo *driver_info);
-
-/** Register functions (in the bus driver) to get called by visorchipset
- * whenever a bus or device appears for which this service partition is
- * to be the client for. visorchipset will fill in <responders>, to
- * indicate functions the bus driver should call to indicate message
- * responses.
- */
-void
-visorchipset_register_busdev_server(
- struct visorchipset_busdev_notifiers *notifiers,
- struct visorchipset_busdev_responders *responders,
- struct ultra_vbus_deviceinfo *driver_info);
-
-typedef void (*SPARREPORTEVENT_COMPLETE_FUNC) (struct controlvm_message *msg,
- int status);
-
-void visorchipset_device_pause_response(ulong bus_no, ulong dev_no,
- int response);
-
-BOOL visorchipset_get_bus_info(ulong bus_no,
- struct visorchipset_bus_info *bus_info);
-BOOL visorchipset_get_device_info(ulong bus_no, ulong dev_no,
- struct visorchipset_device_info *dev_info);
-BOOL visorchipset_set_bus_context(ulong bus_no, void *context);
-BOOL visorchipset_set_device_context(ulong bus_no, ulong dev_no, void *context);
-int visorchipset_chipset_ready(void);
-int visorchipset_chipset_selftest(void);
-int visorchipset_chipset_notready(void);
-void visorchipset_save_message(struct controlvm_message *msg,
- enum crash_obj_type type);
-void *visorchipset_cache_alloc(struct kmem_cache *pool,
- BOOL ok_to_block, char *fn, int ln);
-void visorchipset_cache_free(struct kmem_cache *pool, void *p,
- char *fn, int ln);
-
-#endif
diff --git a/drivers/staging/unisys/visorchipset/visorchipset_umode.h b/drivers/staging/unisys/visorchipset/visorchipset_umode.h
deleted file mode 100644
index 6cf6eccb3f4a41..00000000000000
--- a/drivers/staging/unisys/visorchipset/visorchipset_umode.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* visorchipset_umode.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/** @file *********************************************************************
- *
- * This describes structures needed for the interface between the
- * visorchipset driver and a user-mode component that opens the device.
- *
- ******************************************************************************
- */
-
-#ifndef __VISORCHIPSET_UMODE_H
-#define __VISORCHIPSET_UMODE_H
-
-/** The user-mode program can access the control channel buffer directly
- * via this memory map.
- */
-#define VISORCHIPSET_MMAP_CONTROLCHANOFFSET (0x00000000)
-#define VISORCHIPSET_MMAP_CONTROLCHANSIZE (0x00400000) /* 4MB */
-
-#endif /* __VISORCHIPSET_UMODE_H */
diff --git a/drivers/staging/unisys/visorutil/Kconfig b/drivers/staging/unisys/visorutil/Kconfig
deleted file mode 100644
index be9c2cf890ccd7..00000000000000
--- a/drivers/staging/unisys/visorutil/Kconfig
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Unisys timskmod configuration
-#
-
-config UNISYS_VISORUTIL
- tristate "Unisys visorutil driver"
- ---help---
- If you say Y here, you will enable the Unisys visorutil driver.
-
diff --git a/drivers/staging/unisys/visorutil/Makefile b/drivers/staging/unisys/visorutil/Makefile
deleted file mode 100644
index d9ab5a36e3bf0b..00000000000000
--- a/drivers/staging/unisys/visorutil/Makefile
+++ /dev/null
@@ -1,9 +0,0 @@
-#
-# Makefile for Unisys timskmod
-#
-
-obj-$(CONFIG_UNISYS_VISORUTIL) += visorutil.o
-
-visorutil-y := charqueue.o periodic_work.o memregion_direct.o visorkmodutils.o
-
-ccflags-y += -Idrivers/staging/unisys/include
diff --git a/drivers/staging/unisys/visorutil/charqueue.c b/drivers/staging/unisys/visorutil/charqueue.c
deleted file mode 100644
index c91752a2d06b6f..00000000000000
--- a/drivers/staging/unisys/visorutil/charqueue.c
+++ /dev/null
@@ -1,127 +0,0 @@
-/* charqueue.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/*
- * Simple character queue implementation for Linux kernel mode.
- */
-
-#include "charqueue.h"
-
-#define MYDRVNAME "charqueue"
-
-#define IS_EMPTY(charqueue) (charqueue->head == charqueue->tail)
-
-struct charqueue {
- int alloc_size;
- int nslots;
- spinlock_t lock; /* read/write lock for this structure */
- int head, tail;
- unsigned char buf[0];
-};
-
-struct charqueue *visor_charqueue_create(ulong nslots)
-{
- int alloc_size = sizeof(struct charqueue) + nslots + 1;
- struct charqueue *cq;
-
- cq = kmalloc(alloc_size, GFP_KERNEL|__GFP_NORETRY);
- if (cq == NULL)
- return NULL;
- cq->alloc_size = alloc_size;
- cq->nslots = nslots;
- cq->head = 0;
- cq->tail = 0;
- spin_lock_init(&cq->lock);
- return cq;
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_create);
-
-void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c)
-{
- int alloc_slots = charqueue->nslots+1; /* 1 slot is always empty */
-
- spin_lock(&charqueue->lock);
- charqueue->head = (charqueue->head+1) % alloc_slots;
- if (charqueue->head == charqueue->tail)
- /* overflow; overwrite the oldest entry */
- charqueue->tail = (charqueue->tail+1) % alloc_slots;
- charqueue->buf[charqueue->head] = c;
- spin_unlock(&charqueue->lock);
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_enqueue);
-
-BOOL visor_charqueue_is_empty(struct charqueue *charqueue)
-{
- BOOL b;
-
- spin_lock(&charqueue->lock);
- b = IS_EMPTY(charqueue);
- spin_unlock(&charqueue->lock);
- return b;
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_is_empty);
-
-static int charqueue_dequeue_1(struct charqueue *charqueue)
-{
- int alloc_slots = charqueue->nslots + 1; /* 1 slot is always empty */
-
- if (IS_EMPTY(charqueue))
- return -1;
- charqueue->tail = (charqueue->tail+1) % alloc_slots;
- return charqueue->buf[charqueue->tail];
-}
-
-int charqueue_dequeue(struct charqueue *charqueue)
-{
- int rc;
-
- spin_lock(&charqueue->lock);
- rc = charqueue_dequeue_1(charqueue);
- spin_unlock(&charqueue->lock);
- return rc;
-}
-
-int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf,
- int n)
-{
- int rc, counter = 0, c;
-
- spin_lock(&charqueue->lock);
- for (;;) {
- if (n <= 0)
- break; /* no more buffer space */
- c = charqueue_dequeue_1(charqueue);
- if (c < 0)
- break; /* no more input */
- *buf = (unsigned char)(c);
- buf++;
- n--;
- counter++;
- }
- rc = counter;
- spin_unlock(&charqueue->lock);
- return rc;
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_dequeue_n);
-
-void visor_charqueue_destroy(struct charqueue *charqueue)
-{
- if (charqueue == NULL)
- return;
- kfree(charqueue);
-}
-EXPORT_SYMBOL_GPL(visor_charqueue_destroy);
diff --git a/drivers/staging/unisys/visorutil/charqueue.h b/drivers/staging/unisys/visorutil/charqueue.h
deleted file mode 100644
index f46a776b935bd4..00000000000000
--- a/drivers/staging/unisys/visorutil/charqueue.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* charqueue.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __CHARQUEUE_H__
-#define __CHARQUEUE_H__
-
-#include "timskmod.h"
-
-/* struct charqueue is an opaque structure to users.
- * Fields are declared only in the implementation .c files.
- */
-struct charqueue;
-
-struct charqueue *visor_charqueue_create(ulong nslots);
-void visor_charqueue_enqueue(struct charqueue *charqueue, unsigned char c);
-int charqueue_dequeue(struct charqueue *charqueue);
-int visor_charqueue_dequeue_n(struct charqueue *charqueue, unsigned char *buf,
- int n);
-BOOL visor_charqueue_is_empty(struct charqueue *charqueue);
-void visor_charqueue_destroy(struct charqueue *charqueue);
-
-#endif
-
diff --git a/drivers/staging/unisys/visorutil/memregion.h b/drivers/staging/unisys/visorutil/memregion.h
deleted file mode 100644
index 0c3eebcf6d5039..00000000000000
--- a/drivers/staging/unisys/visorutil/memregion.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* memregion.h
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#ifndef __MEMREGION_H__
-#define __MEMREGION_H__
-
-#include "timskmod.h"
-
-/* struct memregion is an opaque structure to users.
- * Fields are declared only in the implementation .c files.
- */
-struct memregion;
-
-struct memregion *visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes);
-struct memregion *visor_memregion_create_overlapped(struct memregion *parent,
- ulong offset, ulong nbytes);
-int visor_memregion_resize(struct memregion *memregion, ulong newsize);
-int visor_memregion_read(struct memregion *memregion,
- ulong offset, void *dest, ulong nbytes);
-int visor_memregion_write(struct memregion *memregion,
- ulong offset, void *src, ulong nbytes);
-void visor_memregion_destroy(struct memregion *memregion);
-HOSTADDRESS visor_memregion_get_physaddr(struct memregion *memregion);
-ulong visor_memregion_get_nbytes(struct memregion *memregion);
-void memregion_dump(struct memregion *memregion, char *s,
- ulong off, ulong len, struct seq_file *seq);
-void __iomem *visor_memregion_get_pointer(struct memregion *memregion);
-
-#endif
diff --git a/drivers/staging/unisys/visorutil/memregion_direct.c b/drivers/staging/unisys/visorutil/memregion_direct.c
deleted file mode 100644
index eb7422fbe20f4f..00000000000000
--- a/drivers/staging/unisys/visorutil/memregion_direct.c
+++ /dev/null
@@ -1,207 +0,0 @@
-/* memregion_direct.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-/*
- * This is an implementation of memory regions that can be used to read/write
- * channel memory (in main memory of the host system) from code running in
- * a virtual partition.
- */
-#include "timskmod.h"
-#include "memregion.h"
-
-#define MYDRVNAME "memregion"
-
-struct memregion {
- HOSTADDRESS physaddr;
- ulong nbytes;
- void __iomem *mapped;
- BOOL requested;
- BOOL overlapped;
-};
-
-static BOOL mapit(struct memregion *memregion);
-static void unmapit(struct memregion *memregion);
-
-struct memregion *
-visor_memregion_create(HOSTADDRESS physaddr, ulong nbytes)
-{
- struct memregion *rc = NULL;
- struct memregion *memregion;
-
- memregion = kzalloc(sizeof(*memregion), GFP_KERNEL | __GFP_NORETRY);
- if (memregion == NULL)
- return NULL;
-
- memregion->physaddr = physaddr;
- memregion->nbytes = nbytes;
- memregion->overlapped = FALSE;
- if (!mapit(memregion)) {
- rc = NULL;
- goto cleanup;
- }
- rc = memregion;
-cleanup:
- if (rc == NULL) {
- visor_memregion_destroy(memregion);
- memregion = NULL;
- }
- return rc;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_create);
-
-struct memregion *
-visor_memregion_create_overlapped(struct memregion *parent, ulong offset,
- ulong nbytes)
-{
- struct memregion *memregion = NULL;
-
- if (parent == NULL)
- return NULL;
-
- if (parent->mapped == NULL)
- return NULL;
-
- if ((offset >= parent->nbytes) ||
- ((offset + nbytes) >= parent->nbytes))
- return NULL;
-
- memregion = kzalloc(sizeof(*memregion), GFP_KERNEL|__GFP_NORETRY);
- if (memregion == NULL)
- return NULL;
-
- memregion->physaddr = parent->physaddr + offset;
- memregion->nbytes = nbytes;
- memregion->mapped = ((u8 __iomem *)(parent->mapped)) + offset;
- memregion->requested = FALSE;
- memregion->overlapped = TRUE;
- return memregion;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_create_overlapped);
-
-static BOOL
-mapit(struct memregion *memregion)
-{
- ulong physaddr = (ulong)(memregion->physaddr);
- ulong nbytes = memregion->nbytes;
-
- memregion->requested = FALSE;
- if (request_mem_region(physaddr, nbytes, MYDRVNAME))
- memregion->requested = TRUE;
- memregion->mapped = ioremap_cache(physaddr, nbytes);
- if (!memregion->mapped)
- return FALSE;
- return TRUE;
-}
-
-static void
-unmapit(struct memregion *memregion)
-{
- if (memregion->mapped != NULL) {
- iounmap(memregion->mapped);
- memregion->mapped = NULL;
- }
- if (memregion->requested) {
- release_mem_region((ulong)(memregion->physaddr),
- memregion->nbytes);
- memregion->requested = FALSE;
- }
-}
-
-HOSTADDRESS
-visor_memregion_get_physaddr(struct memregion *memregion)
-{
- return memregion->physaddr;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_get_physaddr);
-
-ulong
-visor_memregion_get_nbytes(struct memregion *memregion)
-{
- return memregion->nbytes;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_get_nbytes);
-
-void __iomem *
-visor_memregion_get_pointer(struct memregion *memregion)
-{
- return memregion->mapped;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_get_pointer);
-
-int
-visor_memregion_resize(struct memregion *memregion, ulong newsize)
-{
- if (newsize == memregion->nbytes)
- return 0;
- if (memregion->overlapped)
- /* no error check here - we no longer know the
- * parent's range!
- */
- memregion->nbytes = newsize;
- else {
- unmapit(memregion);
- memregion->nbytes = newsize;
- if (!mapit(memregion))
- return -1;
- }
- return 0;
-}
-EXPORT_SYMBOL_GPL(visor_memregion_resize);
-
-static int
-memregion_readwrite(BOOL is_write,
- struct memregion *memregion, ulong offset,
- void *local, ulong nbytes)
-{
- if (offset + nbytes > memregion->nbytes)
- return -EIO;
-
- if (is_write)
- memcpy_toio(memregion->mapped + offset, local, nbytes);
- else
- memcpy_fromio(local, memregion->mapped + offset, nbytes);
-
- return 0;
-}
-
-int
-visor_memregion_read(struct memregion *memregion, ulong offset, void *dest,
- ulong nbytes)
-{
- return memregion_readwrite(FALSE, memregion, offset, dest, nbytes);
-}
-EXPORT_SYMBOL_GPL(visor_memregion_read);
-
-int
-visor_memregion_write(struct memregion *memregion, ulong offset, void *src,
- ulong nbytes)
-{
- return memregion_readwrite(TRUE, memregion, offset, src, nbytes);
-}
-EXPORT_SYMBOL_GPL(visor_memregion_write);
-
-void
-visor_memregion_destroy(struct memregion *memregion)
-{
- if (memregion == NULL)
- return;
- if (!memregion->overlapped)
- unmapit(memregion);
- kfree(memregion);
-}
-EXPORT_SYMBOL_GPL(visor_memregion_destroy);
-
diff --git a/drivers/staging/unisys/visorutil/visorkmodutils.c b/drivers/staging/unisys/visorutil/visorkmodutils.c
deleted file mode 100644
index 62f0f7046e1734..00000000000000
--- a/drivers/staging/unisys/visorutil/visorkmodutils.c
+++ /dev/null
@@ -1,71 +0,0 @@
-/* timskmodutils.c
- *
- * Copyright (C) 2010 - 2013 UNISYS CORPORATION
- * 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 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, GOOD TITLE or
- * NON INFRINGEMENT. See the GNU General Public License for more
- * details.
- */
-
-#include "timskmod.h"
-
-#define MYDRVNAME "timskmodutils"
-
-/* s-Par uses the Intel processor's VT-X features to separate groups of
- * processors into partitions. The firmware sets the hypervisor bit and
- * reports an ID in the HV capabilities leaf so that the partition's OS
- * knows s-Par is present and managing the processors.
- */
-
-#define UNISYS_SPAR_LEAF_ID 0x40000000
-
-/* The s-Par leaf ID returns "UnisysSpar64" encoded across ebx, ecx, edx */
-#define UNISYS_SPAR_ID_EBX 0x73696e55
-#define UNISYS_SPAR_ID_ECX 0x70537379
-#define UNISYS_SPAR_ID_EDX 0x34367261
-
-int unisys_spar_platform;
-EXPORT_SYMBOL_GPL(unisys_spar_platform);
-
-static __init uint32_t visorutil_spar_detect(void)
-{
- unsigned int eax, ebx, ecx, edx;
-
- if (cpu_has_hypervisor) {
- /* check the ID */
- cpuid(UNISYS_SPAR_LEAF_ID, &eax, &ebx, &ecx, &edx);
- return (ebx == UNISYS_SPAR_ID_EBX) &&
- (ecx == UNISYS_SPAR_ID_ECX) &&
- (edx == UNISYS_SPAR_ID_EDX);
- } else {
- return 0;
- }
-}
-
-static __init int visorutil_mod_init(void)
-{
- if (visorutil_spar_detect()) {
- unisys_spar_platform = TRUE;
- return 0;
- } else {
- return -ENODEV;
- }
-}
-
-static __exit void
-visorutil_mod_exit(void)
-{
-}
-
-module_init(visorutil_mod_init);
-module_exit(visorutil_mod_exit);
-
-MODULE_LICENSE("GPL");
diff --git a/drivers/staging/vt6655/Makefile b/drivers/staging/vt6655/Makefile
index 115b951bf0d954..d55c3baade5327 100644
--- a/drivers/staging/vt6655/Makefile
+++ b/drivers/staging/vt6655/Makefile
@@ -11,7 +11,6 @@ vt6655_stage-y += device_main.o \
dpc.o \
power.o \
srom.o \
- mib.o \
key.o \
rf.o
diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h
index 440537e47121b9..5cf1b337cba7e6 100644
--- a/drivers/staging/vt6655/device.h
+++ b/drivers/staging/vt6655/device.h
@@ -68,7 +68,6 @@
#include "device_cfg.h"
#include "card.h"
-#include "mib.h"
#include "srom.h"
#include "desc.h"
#include "key.h"
@@ -239,7 +238,6 @@ struct vnt_private {
CHIP_TYPE chip_id;
void __iomem *PortOffset;
- unsigned long dwIsr;
u32 memaddr;
u32 ioaddr;
u32 io_size;
@@ -286,11 +284,6 @@ struct vnt_private {
unsigned char abyCurrentNetAddr[ETH_ALEN]; __aligned(2)
bool bLinkPass; /* link status: OK or fail */
- /* Adapter statistics */
- SStatCounter scStatistic;
- /* 802.11 counter */
- SDot11Counters s802_11Counter;
-
unsigned int uCurrRSSI;
unsigned char byCurrSQ;
@@ -410,6 +403,10 @@ struct vnt_private {
unsigned char abyEEPROM[EEP_MAX_CONTEXT_SIZE]; /* unsigned long alignment */
unsigned short wBeaconInterval;
+
+ struct work_struct interrupt_work;
+
+ struct ieee80211_low_level_stats low_stats;
};
static inline PDEVICE_RD_INFO alloc_rd_info(void)
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c
index ecd7c0f8248175..fb8d16122b49ae 100644
--- a/drivers/staging/vt6655/device_main.c
+++ b/drivers/staging/vt6655/device_main.c
@@ -32,7 +32,6 @@
* device_free_info - device structure resource free function
* device_get_pci_info - get allocated pci io/mem resource
* device_print_info - print out resource
- * device_intr - interrupt handle function
* device_rx_srv - rx service function
* device_alloc_rx_buf - rx buffer pre-allocated function
* device_free_tx_buf - free tx buffer function
@@ -148,7 +147,6 @@ static void vt6655_init_info(struct pci_dev *pcid,
static void device_free_info(struct vnt_private *pDevice);
static bool device_get_pci_info(struct vnt_private *, struct pci_dev *pcid);
static void device_print_info(struct vnt_private *pDevice);
-static irqreturn_t device_intr(int irq, void *dev_instance);
#ifdef CONFIG_PM
static int device_notify_reboot(struct notifier_block *, unsigned long event, void *ptr);
@@ -807,6 +805,10 @@ static int device_rx_srv(struct vnt_private *pDevice, unsigned int uIdx)
pRD = pRD->next) {
if (works++ > 15)
break;
+
+ if (!pRD->pRDInfo->skb)
+ break;
+
if (vnt_receive_frame(pDevice, pRD)) {
if (!device_alloc_rx_buf(pDevice, pRD)) {
dev_err(&pDevice->pcid->dev,
@@ -1053,129 +1055,135 @@ static void vnt_check_bb_vga(struct vnt_private *priv)
}
}
-static irqreturn_t device_intr(int irq, void *dev_instance)
+static void vnt_interrupt_process(struct vnt_private *priv)
{
- struct vnt_private *pDevice = dev_instance;
+ struct ieee80211_low_level_stats *low_stats = &priv->low_stats;
int max_count = 0;
- unsigned long dwMIBCounter = 0;
- unsigned char byOrgPageSel = 0;
- int handled = 0;
+ u32 mib_counter;
+ u32 isr;
unsigned long flags;
- MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
+ MACvReadISR(priv->PortOffset, &isr);
- if (pDevice->dwIsr == 0)
- return IRQ_RETVAL(handled);
+ if (isr == 0)
+ return;
- if (pDevice->dwIsr == 0xffffffff) {
- pr_debug("dwIsr = 0xffff\n");
- return IRQ_RETVAL(handled);
+ if (isr == 0xffffffff) {
+ pr_debug("isr = 0xffff\n");
+ return;
}
- handled = 1;
- MACvIntDisable(pDevice->PortOffset);
+ MACvIntDisable(priv->PortOffset);
- spin_lock_irqsave(&pDevice->lock, flags);
+ spin_lock_irqsave(&priv->lock, flags);
- /* Make sure current page is 0 */
- VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel);
- if (byOrgPageSel == 1)
- MACvSelectPage0(pDevice->PortOffset);
- else
- byOrgPageSel = 0;
+ /* Read low level stats */
+ MACvReadMIBCounter(priv->PortOffset, &mib_counter);
+
+ low_stats->dot11RTSSuccessCount += mib_counter & 0xff;
+ low_stats->dot11RTSFailureCount += (mib_counter >> 8) & 0xff;
+ low_stats->dot11ACKFailureCount += (mib_counter >> 16) & 0xff;
+ low_stats->dot11FCSErrorCount += (mib_counter >> 24) & 0xff;
- MACvReadMIBCounter(pDevice->PortOffset, &dwMIBCounter);
/*
* TBD....
* Must do this after doing rx/tx, cause ISR bit is slow
* than RD/TD write back
* update ISR counter
*/
- STAvUpdate802_11Counter(&pDevice->s802_11Counter, &pDevice->scStatistic, dwMIBCounter);
- while (pDevice->dwIsr != 0) {
- STAvUpdateIsrStatCounter(&pDevice->scStatistic, pDevice->dwIsr);
- MACvWriteISR(pDevice->PortOffset, pDevice->dwIsr);
+ while (isr && priv->vif) {
+ MACvWriteISR(priv->PortOffset, isr);
- if (pDevice->dwIsr & ISR_FETALERR) {
+ if (isr & ISR_FETALERR) {
pr_debug(" ISR_FETALERR\n");
- VNSvOutPortB(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, 0);
- VNSvOutPortW(pDevice->PortOffset + MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI);
- device_error(pDevice, pDevice->dwIsr);
+ VNSvOutPortB(priv->PortOffset + MAC_REG_SOFTPWRCTL, 0);
+ VNSvOutPortW(priv->PortOffset +
+ MAC_REG_SOFTPWRCTL, SOFTPWRCTL_SWPECTI);
+ device_error(priv, isr);
}
- if (pDevice->dwIsr & ISR_TBTT) {
- if (pDevice->vif &&
- pDevice->op_mode != NL80211_IFTYPE_ADHOC)
- vnt_check_bb_vga(pDevice);
+ if (isr & ISR_TBTT) {
+ if (priv->op_mode != NL80211_IFTYPE_ADHOC)
+ vnt_check_bb_vga(priv);
- pDevice->bBeaconSent = false;
- if (pDevice->bEnablePSMode)
- PSbIsNextTBTTWakeUp((void *)pDevice);
+ priv->bBeaconSent = false;
+ if (priv->bEnablePSMode)
+ PSbIsNextTBTTWakeUp((void *)priv);
- if ((pDevice->op_mode == NL80211_IFTYPE_AP ||
- pDevice->op_mode == NL80211_IFTYPE_ADHOC) &&
- pDevice->vif->bss_conf.enable_beacon) {
- MACvOneShotTimer1MicroSec(pDevice->PortOffset,
- (pDevice->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10);
+ if ((priv->op_mode == NL80211_IFTYPE_AP ||
+ priv->op_mode == NL80211_IFTYPE_ADHOC) &&
+ priv->vif->bss_conf.enable_beacon) {
+ MACvOneShotTimer1MicroSec(priv->PortOffset,
+ (priv->vif->bss_conf.beacon_int - MAKE_BEACON_RESERVED) << 10);
}
/* TODO: adhoc PS mode */
}
- if (pDevice->dwIsr & ISR_BNTX) {
- if (pDevice->op_mode == NL80211_IFTYPE_ADHOC) {
- pDevice->bIsBeaconBufReadySet = false;
- pDevice->cbBeaconBufReadySetCnt = 0;
+ if (isr & ISR_BNTX) {
+ if (priv->op_mode == NL80211_IFTYPE_ADHOC) {
+ priv->bIsBeaconBufReadySet = false;
+ priv->cbBeaconBufReadySetCnt = 0;
}
- pDevice->bBeaconSent = true;
+ priv->bBeaconSent = true;
}
- if (pDevice->dwIsr & ISR_RXDMA0)
- max_count += device_rx_srv(pDevice, TYPE_RXDMA0);
+ if (isr & ISR_RXDMA0)
+ max_count += device_rx_srv(priv, TYPE_RXDMA0);
- if (pDevice->dwIsr & ISR_RXDMA1)
- max_count += device_rx_srv(pDevice, TYPE_RXDMA1);
+ if (isr & ISR_RXDMA1)
+ max_count += device_rx_srv(priv, TYPE_RXDMA1);
- if (pDevice->dwIsr & ISR_TXDMA0)
- max_count += device_tx_srv(pDevice, TYPE_TXDMA0);
+ if (isr & ISR_TXDMA0)
+ max_count += device_tx_srv(priv, TYPE_TXDMA0);
- if (pDevice->dwIsr & ISR_AC0DMA)
- max_count += device_tx_srv(pDevice, TYPE_AC0DMA);
+ if (isr & ISR_AC0DMA)
+ max_count += device_tx_srv(priv, TYPE_AC0DMA);
- if (pDevice->dwIsr & ISR_SOFTTIMER1) {
- if (pDevice->vif) {
- if (pDevice->vif->bss_conf.enable_beacon)
- vnt_beacon_make(pDevice, pDevice->vif);
- }
+ if (isr & ISR_SOFTTIMER1) {
+ if (priv->vif->bss_conf.enable_beacon)
+ vnt_beacon_make(priv, priv->vif);
}
/* If both buffers available wake the queue */
- if (pDevice->vif) {
- if (AVAIL_TD(pDevice, TYPE_TXDMA0) &&
- AVAIL_TD(pDevice, TYPE_AC0DMA) &&
- ieee80211_queue_stopped(pDevice->hw, 0))
- ieee80211_wake_queues(pDevice->hw);
- }
+ if (AVAIL_TD(priv, TYPE_TXDMA0) &&
+ AVAIL_TD(priv, TYPE_AC0DMA) &&
+ ieee80211_queue_stopped(priv->hw, 0))
+ ieee80211_wake_queues(priv->hw);
- MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr);
+ MACvReadISR(priv->PortOffset, &isr);
- MACvReceive0(pDevice->PortOffset);
- MACvReceive1(pDevice->PortOffset);
+ MACvReceive0(priv->PortOffset);
+ MACvReceive1(priv->PortOffset);
- if (max_count > pDevice->sOpts.int_works)
+ if (max_count > priv->sOpts.int_works)
break;
}
- if (byOrgPageSel == 1)
- MACvSelectPage1(pDevice->PortOffset);
+ spin_unlock_irqrestore(&priv->lock, flags);
- spin_unlock_irqrestore(&pDevice->lock, flags);
+ MACvIntEnable(priv->PortOffset, IMR_MASK_VALUE);
+}
+
+static void vnt_interrupt_work(struct work_struct *work)
+{
+ struct vnt_private *priv =
+ container_of(work, struct vnt_private, interrupt_work);
+
+ if (priv->vif)
+ vnt_interrupt_process(priv);
+}
+
+static irqreturn_t vnt_interrupt(int irq, void *arg)
+{
+ struct vnt_private *priv = arg;
- MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE);
+ if (priv->vif)
+ schedule_work(&priv->interrupt_work);
- return IRQ_RETVAL(handled);
+ return IRQ_HANDLED;
}
static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb)
@@ -1267,7 +1275,7 @@ static int vnt_start(struct ieee80211_hw *hw)
if (!device_init_rings(priv))
return -ENOMEM;
- ret = request_irq(priv->pcid->irq, &device_intr,
+ ret = request_irq(priv->pcid->irq, &vnt_interrupt,
IRQF_SHARED, "vt6655", priv);
if (ret) {
dev_dbg(&priv->pcid->dev, "failed to start irq\n");
@@ -1296,6 +1304,8 @@ static void vnt_stop(struct ieee80211_hw *hw)
ieee80211_stop_queues(hw);
+ cancel_work_sync(&priv->interrupt_work);
+
MACbShutdown(priv->PortOffset);
MACbSoftwareReset(priv->PortOffset);
CARDbRadioPowerOff(priv);
@@ -1600,6 +1610,16 @@ static int vnt_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
return 0;
}
+static int vnt_get_stats(struct ieee80211_hw *hw,
+ struct ieee80211_low_level_stats *stats)
+{
+ struct vnt_private *priv = hw->priv;
+
+ memcpy(stats, &priv->low_stats, sizeof(*stats));
+
+ return 0;
+}
+
static u64 vnt_get_tsf(struct ieee80211_hw *hw, struct ieee80211_vif *vif)
{
struct vnt_private *priv = hw->priv;
@@ -1637,6 +1657,7 @@ static const struct ieee80211_ops vnt_mac_ops = {
.prepare_multicast = vnt_prepare_multicast,
.configure_filter = vnt_configure,
.set_key = vnt_set_key,
+ .get_stats = vnt_get_stats,
.get_tsf = vnt_get_tsf,
.set_tsf = vnt_set_tsf,
.reset_tsf = vnt_reset_tsf,
@@ -1762,6 +1783,8 @@ vt6655_probe(struct pci_dev *pcid, const struct pci_device_id *ent)
return -ENODEV;
}
+ INIT_WORK(&priv->interrupt_work, vnt_interrupt_work);
+
/* do reset */
if (!MACbSoftwareReset(priv->PortOffset)) {
dev_err(&pcid->dev, ": Failed to access MAC hardware..\n");
diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c
index 8048b326336082..aed530f022b8cf 100644
--- a/drivers/staging/vt6655/mac.c
+++ b/drivers/staging/vt6655/mac.c
@@ -70,7 +70,8 @@
* Return Value: true if all test bits On; otherwise false
*
*/
-bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits)
+bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs,
+ unsigned char byTestBits)
{
unsigned char byData;
@@ -93,7 +94,8 @@ bool MACbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned ch
* Return Value: true if all test bits Off; otherwise false
*
*/
-bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs, unsigned char byTestBits)
+bool MACbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byRegOfs,
+ unsigned char byTestBits)
{
unsigned char byData;
@@ -218,7 +220,8 @@ void MACvSaveContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf)
/* read page1 register */
for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++)
- VNSvInPortB((dwIoBase + ii), (pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii));
+ VNSvInPortB((dwIoBase + ii),
+ (pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii));
MACvSelectPage0(dwIoBase);
}
@@ -244,7 +247,8 @@ void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf)
MACvSelectPage1(dwIoBase);
/* restore page1 */
for (ii = 0; ii < MAC_MAX_CONTEXT_SIZE_PAGE1; ii++)
- VNSvOutPortB((dwIoBase + ii), *(pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii));
+ VNSvOutPortB((dwIoBase + ii),
+ *(pbyCxtBuf + MAC_MAX_CONTEXT_SIZE_PAGE0 + ii));
MACvSelectPage0(dwIoBase);
@@ -263,13 +267,18 @@ void MACvRestoreContext(void __iomem *dwIoBase, unsigned char *pbyCxtBuf)
VNSvOutPortB(dwIoBase + ii, *(pbyCxtBuf + ii));
/* restore CURR_RX_DESC_ADDR, CURR_TX_DESC_ADDR */
- VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0));
- VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR));
- VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR, *(unsigned long *)(pbyCxtBuf + MAC_REG_BCNDMAPTR));
-
- VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0));
-
- VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1, *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1));
+ VNSvOutPortD(dwIoBase + MAC_REG_TXDMAPTR0,
+ *(unsigned long *)(pbyCxtBuf + MAC_REG_TXDMAPTR0));
+ VNSvOutPortD(dwIoBase + MAC_REG_AC0DMAPTR,
+ *(unsigned long *)(pbyCxtBuf + MAC_REG_AC0DMAPTR));
+ VNSvOutPortD(dwIoBase + MAC_REG_BCNDMAPTR,
+ *(unsigned long *)(pbyCxtBuf + MAC_REG_BCNDMAPTR));
+
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR0,
+ *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR0));
+
+ VNSvOutPortD(dwIoBase + MAC_REG_RXDMAPTR1,
+ *(unsigned long *)(pbyCxtBuf + MAC_REG_RXDMAPTR1));
}
/*
@@ -641,7 +650,8 @@ void MACvSetCurrRx1DescAddr(void __iomem *dwIoBase, unsigned long dwCurrDescAddr
* Return Value: none
*
*/
-void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
+void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase,
+ unsigned long dwCurrDescAddr)
{
unsigned short ww;
unsigned char byData;
@@ -679,7 +689,8 @@ void MACvSetCurrTx0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAd
*
*/
/* TxDMA1 = AC0DMA */
-void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
+void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase,
+ unsigned long dwCurrDescAddr)
{
unsigned short ww;
unsigned char byData;
@@ -703,7 +714,8 @@ void MACvSetCurrAC0DescAddrEx(void __iomem *dwIoBase, unsigned long dwCurrDescAd
VNSvOutPortB(dwIoBase + MAC_REG_AC0DMACTL, DMACTL_RUN);
}
-void MACvSetCurrTXDescAddr(int iTxType, void __iomem *dwIoBase, unsigned long dwCurrDescAddr)
+void MACvSetCurrTXDescAddr(int iTxType, void __iomem *dwIoBase,
+ unsigned long dwCurrDescAddr)
{
if (iTxType == TYPE_AC0DMA)
MACvSetCurrAC0DescAddrEx(dwIoBase, dwCurrDescAddr);
@@ -767,7 +779,8 @@ void MACvOneShotTimer1MicroSec(void __iomem *dwIoBase, unsigned int uDelayTime)
VNSvOutPortB(dwIoBase + MAC_REG_TMCTL1, (TMCTL_TMD | TMCTL_TE));
}
-void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset, unsigned long dwData)
+void MACvSetMISCFifo(void __iomem *dwIoBase, unsigned short wOffset,
+ unsigned long dwData)
{
if (wOffset > 273)
return;
@@ -816,8 +829,10 @@ bool MACbPSWakeup(void __iomem *dwIoBase)
*
*/
-void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl, unsigned int uEntryIdx,
- unsigned int uKeyIdx, unsigned char *pbyAddr, u32 *pdwKey, unsigned char byLocalID)
+void MACvSetKeyEntry(void __iomem *dwIoBase, unsigned short wKeyCtl,
+ unsigned int uEntryIdx, unsigned int uKeyIdx,
+ unsigned char *pbyAddr, u32 *pdwKey,
+ unsigned char byLocalID)
{
unsigned short wOffset;
u32 dwData;
diff --git a/drivers/staging/vt6655/mib.c b/drivers/staging/vt6655/mib.c
deleted file mode 100644
index d55c762027ed4f..00000000000000
--- a/drivers/staging/vt6655/mib.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * 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 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, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: mib.c
- *
- * Purpose: Implement MIB Data Structure
- *
- * Author: Tevin Chen
- *
- * Date: May 21, 1996
- *
- * Functions:
- * STAvUpdateIstStatCounter - Update ISR statistic counter
- * STAvUpdate802_11Counter - Update 802.11 mib counter
- *
- * Revision History:
- *
- */
-
-#include "mac.h"
-#include "mib.h"
-
-/*--------------------- Static Classes ----------------------------*/
-
-/*--------------------- Static Variables --------------------------*/
-
-/*--------------------- Static Functions --------------------------*/
-
-/*--------------------- Export Variables --------------------------*/
-
-/*--------------------- Export Functions --------------------------*/
-
-/*
- * Description: Update Isr Statistic Counter
- *
- * Parameters:
- * In:
- * pStatistic - Pointer to Statistic Counter Data Structure
- * wisr - Interrupt status
- * Out:
- * none
- *
- * Return Value: none
- *
- */
-void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr)
-{
- /**********************/
- /* ABNORMAL interrupt */
- /**********************/
- /* not any IMR bit invoke irq */
-
- if (dwIsr == 0) {
- pStatistic->ISRStat.dwIsrUnknown++;
- return;
- }
-
-/* Added by Kyle */
- if (dwIsr & ISR_TXDMA0) /* ISR, bit0 */
- pStatistic->ISRStat.dwIsrTx0OK++; /* TXDMA0 successful */
-
- if (dwIsr & ISR_AC0DMA) /* ISR, bit1 */
- pStatistic->ISRStat.dwIsrAC0TxOK++; /* AC0DMA successful */
-
- if (dwIsr & ISR_BNTX) /* ISR, bit2 */
- pStatistic->ISRStat.dwIsrBeaconTxOK++; /* BeaconTx successful */
-
- if (dwIsr & ISR_RXDMA0) /* ISR, bit3 */
- pStatistic->ISRStat.dwIsrRx0OK++; /* Rx0 successful */
-
- if (dwIsr & ISR_TBTT) /* ISR, bit4 */
- pStatistic->ISRStat.dwIsrTBTTInt++; /* TBTT successful */
-
- if (dwIsr & ISR_SOFTTIMER) /* ISR, bit6 */
- pStatistic->ISRStat.dwIsrSTIMERInt++;
-
- if (dwIsr & ISR_WATCHDOG) /* ISR, bit7 */
- pStatistic->ISRStat.dwIsrWatchDog++;
-
- if (dwIsr & ISR_FETALERR) /* ISR, bit8 */
- pStatistic->ISRStat.dwIsrUnrecoverableError++;
-
- if (dwIsr & ISR_SOFTINT) /* ISR, bit9 */
- pStatistic->ISRStat.dwIsrSoftInterrupt++; /* software interrupt */
-
- if (dwIsr & ISR_MIBNEARFULL) /* ISR, bit10 */
- pStatistic->ISRStat.dwIsrMIBNearfull++;
-
- if (dwIsr & ISR_RXNOBUF) /* ISR, bit11 */
- pStatistic->ISRStat.dwIsrRxNoBuf++; /* Rx No Buff */
-
- if (dwIsr & ISR_RXDMA1) /* ISR, bit12 */
- pStatistic->ISRStat.dwIsrRx1OK++; /* Rx1 successful */
-
- if (dwIsr & ISR_SOFTTIMER1) /* ISR, bit21 */
- pStatistic->ISRStat.dwIsrSTIMER1Int++;
-}
-
-/*
- * Description: Update 802.11 mib counter
- *
- * Parameters:
- * In:
- * p802_11Counter - Pointer to 802.11 mib counter
- * pStatistic - Pointer to Statistic Counter Data Structure
- * dwCounter - hardware counter for 802.11 mib
- * Out:
- * none
- *
- * Return Value: none
- *
- */
-void
-STAvUpdate802_11Counter(
- PSDot11Counters p802_11Counter,
- PSStatCounter pStatistic,
- unsigned long dwCounter
-)
-{
- p802_11Counter->RTSSuccessCount += (unsigned long long) (dwCounter & 0x000000ff);
- p802_11Counter->RTSFailureCount += (unsigned long long) ((dwCounter & 0x0000ff00) >> 8);
- p802_11Counter->ACKFailureCount += (unsigned long long) ((dwCounter & 0x00ff0000) >> 16);
- p802_11Counter->FCSErrorCount += (unsigned long long) ((dwCounter & 0xff000000) >> 24);
-}
diff --git a/drivers/staging/vt6655/mib.h b/drivers/staging/vt6655/mib.h
deleted file mode 100644
index 5cb59b8a1c7c0c..00000000000000
--- a/drivers/staging/vt6655/mib.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
- * 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 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, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * File: mib.h
- *
- * Purpose: Implement MIB Data Structure
- *
- * Author: Tevin Chen
- *
- * Date: May 21, 1996
- *
- */
-
-#ifndef __MIB_H__
-#define __MIB_H__
-
-#include "desc.h"
-
-//
-// 802.11 counter
-//
-
-typedef struct tagSDot11Counters {
- unsigned long long RTSSuccessCount;
- unsigned long long RTSFailureCount;
- unsigned long long ACKFailureCount;
- unsigned long long FCSErrorCount;
-} SDot11Counters, *PSDot11Counters;
-
-//
-// Custom counter
-//
-typedef struct tagSISRCounters {
- unsigned long dwIsrTx0OK;
- unsigned long dwIsrAC0TxOK;
- unsigned long dwIsrBeaconTxOK;
- unsigned long dwIsrRx0OK;
- unsigned long dwIsrTBTTInt;
- unsigned long dwIsrSTIMERInt;
- unsigned long dwIsrWatchDog;
- unsigned long dwIsrUnrecoverableError;
- unsigned long dwIsrSoftInterrupt;
- unsigned long dwIsrMIBNearfull;
- unsigned long dwIsrRxNoBuf;
-
- unsigned long dwIsrUnknown;
-
- unsigned long dwIsrRx1OK;
- unsigned long dwIsrSTIMER1Int;
-} SISRCounters, *PSISRCounters;
-
-//
-// statistic counter
-//
-typedef struct tagSStatCounter {
- SISRCounters ISRStat;
-} SStatCounter, *PSStatCounter;
-
-void STAvUpdateIsrStatCounter(PSStatCounter pStatistic, unsigned long dwIsr);
-
-void STAvUpdate802_11Counter(
- PSDot11Counters p802_11Counter,
- PSStatCounter pStatistic,
- unsigned long dwCounter
-);
-
-#endif // __MIB_H__
diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c
index 74687761bd2ee0..33c4aa49946d33 100644
--- a/drivers/staging/vt6655/rxtx.c
+++ b/drivers/staging/vt6655/rxtx.c
@@ -656,7 +656,7 @@ s_vFillRTSHead(
uRTSFrameLen -= 4;
}
- /* Note: So far RTSHead dosen't appear in ATIM & Beacom DMA, so we don't need to take them into account.
+ /* Note: So far RTSHead doesn't appear in ATIM & Beacom DMA, so we don't need to take them into account.
Otherwise, we need to modify codes for them. */
if (byPktType == PK_TYPE_11GB || byPktType == PK_TYPE_11GA) {
if (byFBOption == AUTO_FB_NONE) {
diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index f71d59fa3b21ec..635d931de40908 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -364,7 +364,7 @@ struct vnt_private {
/* Power save */
u16 current_aid;
- /* Beacon releated */
+ /* Beacon related */
u16 seq_counter;
enum vnt_cmd_state command_state;
diff --git a/drivers/staging/wilc1000/Kconfig b/drivers/staging/wilc1000/Kconfig
new file mode 100644
index 00000000000000..dc09e9e667d0f1
--- /dev/null
+++ b/drivers/staging/wilc1000/Kconfig
@@ -0,0 +1,59 @@
+config WILC1000
+ tristate "WILC1000 support (WiFi only)"
+ depends on !S390
+ depends on CFG80211 && WEXT_CORE && INET
+ depends on MMC || SPI
+ depends on BROKEN
+ ---help---
+ This module only support IEEE 802.11n WiFi.
+
+choice
+ prompt "Memory Allocation"
+ depends on WILC1000
+ default WILC1000_PREALLOCATE_AT_LOADING_DRIVER
+
+config WILC1000_PREALLOCATE_AT_LOADING_DRIVER
+ bool "Preallocate memory at loading driver"
+ ---help---
+ This choice supports static allocation of the memory
+ for the receive buffer. The driver will allocate the RX buffer
+ during initial time. The driver will also free the buffer
+ by calling network device stop.
+
+config WILC1000_DYNAMICALLY_ALLOCATE_MEMROY
+ bool "Dynamically allocate memory in real time"
+ ---help---
+ This choice supports dynamic allocation of the memory
+ for the receive buffer. The driver will allocate the RX buffer
+ when it is required.
+endchoice
+
+choice
+ prompt "Bus Type"
+ depends on WILC1000
+ default WILC1000_SDIO
+
+ config WILC1000_SDIO
+ bool "SDIO support"
+ depends on MMC
+ ---help---
+ This module adds support for the SDIO interface
+ of adapters using WILC chipset. Select this if
+ your platform is using the SDIO bus.
+
+ config WILC1000_SPI
+ depends on SPI
+ bool "SPI support"
+ ---help---
+ This module adds support for the SPI interface
+ of adapters using WILC chipset. Select this if
+ your platform is using the SPI bus.
+endchoice
+
+config WILC1000_HW_OOB_INTR
+ bool "Use out of band interrupt"
+ depends on WILC1000 && WILC1000_SDIO
+ default n
+ ---help---
+ If your platform don't recognize SDIO IRQ, connect chipset external IRQ pin
+ and check this option. Or, Use this to get all interrupts including SDIO interrupts.
diff --git a/drivers/staging/wilc1000/Makefile b/drivers/staging/wilc1000/Makefile
new file mode 100644
index 00000000000000..a78c4d529a58af
--- /dev/null
+++ b/drivers/staging/wilc1000/Makefile
@@ -0,0 +1,34 @@
+obj-$(CONFIG_WILC1000) += wilc1000.o
+obj-$(CONFIG_WILC1000_PREALLOCATE_DURING_SYSTEM_BOOT) += wilc_exported_buf.o
+
+
+ccflags-$(CONFIG_WILC1000_SDIO) += -DWILC_SDIO -DCOMPLEMENT_BOOT
+ccflags-$(CONFIG_WILC1000_HW_OOB_INTR) += -DWILC_SDIO_IRQ_GPIO
+ccflags-$(CONFIG_WILC1000_SPI) += -DWILC_SPI
+
+ccflags-y += -DSTA_FIRMWARE=\"atmel/wilc1000_fw.bin\" \
+ -DAP_FIRMWARE=\"atmel/wilc1000_ap_fw.bin\" \
+ -DP2P_CONCURRENCY_FIRMWARE=\"atmel/wilc1000_p2p_fw.bin\"
+
+ccflags-y += -I$(src)/ -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 \
+ -DPLL_WORKAROUND -DCONNECT_DIRECT -DAGING_ALG \
+ -DWILC_PARSE_SCAN_IN_HOST -DDISABLE_PWRSAVE_AND_SCAN_DURING_IP \
+ -Wno-unused-function -DUSE_WIRELESS -DWILC_DEBUGFS
+#ccflags-y += -DTCP_ACK_FILTER
+
+ccflags-$(CONFIG_WILC1000_PREALLOCATE_DURING_SYSTEM_BOOT) += -DMEMORY_STATIC \
+ -DWILC_PREALLOC_AT_BOOT
+
+ccflags-$(CONFIG_WILC1000_PREALLOCATE_AT_LOADING_DRIVER) += -DMEMORY_STATIC \
+ -DWILC_PREALLOC_AT_INSMOD
+
+ccflags-$(CONFIG_WILC1000_DYNAMICALLY_ALLOCATE_MEMROY) += -DWILC_NORMAL_ALLOC
+
+
+wilc1000-objs := wilc_wfi_netdevice.o wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \
+ wilc_memory.o wilc_msgqueue.o wilc_sleep.o wilc_strutils.o \
+ wilc_timer.o coreconfigurator.o host_interface.o \
+ fifo_buffer.o wilc_sdio.o wilc_spi.o wilc_wlan_cfg.o wilc_debugfs.o
+
+wilc1000-$(CONFIG_WILC1000_SDIO) += linux_wlan_sdio.o
+wilc1000-$(CONFIG_WILC1000_SPI) += linux_wlan_spi.o
diff --git a/drivers/staging/wilc1000/TODO b/drivers/staging/wilc1000/TODO
new file mode 100644
index 00000000000000..95199d80a3e49d
--- /dev/null
+++ b/drivers/staging/wilc1000/TODO
@@ -0,0 +1,14 @@
+TODO:
+- remove the defined feature as kernel versions
+- remove OS wrapper functions
+- remove custom debug and tracing functions
+- rework comments and function headers(also coding style)
+- replace all semaphores with mutexes or completions
+- make spi and sdio components coexist in one build
+- turn compile-time platform configuration (BEAGLE_BOARD,
+ PANDA_BOARD, PLAT_WMS8304, PLAT_RKXXXX, CUSTOMER_PLATFORM, ...)
+ into run-time options that are read from DT
+- support soft-ap and p2p mode
+- support resume/suspend function
+- replace SIOCDEVPRIVATE commands with generic API functions
+- use wext-core handling instead of private SIOCSIWPRIV implementation
diff --git a/drivers/staging/wilc1000/coreconfigsimulator.h b/drivers/staging/wilc1000/coreconfigsimulator.h
new file mode 100644
index 00000000000000..6c3f431314faeb
--- /dev/null
+++ b/drivers/staging/wilc1000/coreconfigsimulator.h
@@ -0,0 +1,20 @@
+
+/*!
+ * @file coreconfigsimulator.h
+ * @brief
+ * @author
+ * @sa coreconfigsimulator.c
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+
+
+#ifndef CORECONFIGSIMULATOR_H
+#define CORECONFIGSIMULATOR_H
+
+
+extern WILC_Sint32 CoreConfigSimulatorInit (void);
+extern WILC_Sint32 CoreConfigSimulatorDeInit (void);
+
+
+#endif \ No newline at end of file
diff --git a/drivers/staging/wilc1000/coreconfigurator.c b/drivers/staging/wilc1000/coreconfigurator.c
new file mode 100644
index 00000000000000..e3e3f204624e7f
--- /dev/null
+++ b/drivers/staging/wilc1000/coreconfigurator.c
@@ -0,0 +1,2186 @@
+
+/*!
+ * @file coreconfigurator.c
+ * @brief
+ * @author
+ * @sa coreconfigurator.h
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+
+
+/*****************************************************************************/
+/* File Includes */
+/*****************************************************************************/
+#include "itypes.h"
+#include "coreconfigurator.h"
+/*****************************************************************************/
+/* Constants */
+/*****************************************************************************/
+#define INLINE static __inline
+#define PHY_802_11n
+#define MAX_CFG_PKTLEN 1450
+#define MSG_HEADER_LEN 4
+#define QUERY_MSG_TYPE 'Q'
+#define WRITE_MSG_TYPE 'W'
+#define RESP_MSG_TYPE 'R'
+#define WRITE_RESP_SUCCESS 1
+#define INVALID 255
+#define MAC_ADDR_LEN 6
+#define TAG_PARAM_OFFSET (MAC_HDR_LEN + TIME_STAMP_LEN + \
+ BEACON_INTERVAL_LEN + CAP_INFO_LEN)
+
+/*****************************************************************************/
+/* Function Macros */
+/*****************************************************************************/
+
+
+/*****************************************************************************/
+/* Type Definitions */
+/*****************************************************************************/
+
+/* Basic Frame Type Codes (2-bit) */
+typedef enum {FRAME_TYPE_CONTROL = 0x04,
+ FRAME_TYPE_DATA = 0x08,
+ FRAME_TYPE_MANAGEMENT = 0x00,
+ FRAME_TYPE_RESERVED = 0x0C,
+ FRAME_TYPE_FORCE_32BIT = 0xFFFFFFFF
+} tenuBasicFrmType;
+
+/* Frame Type and Subtype Codes (6-bit) */
+typedef enum {
+ ASSOC_REQ = 0x00,
+ ASSOC_RSP = 0x10,
+ REASSOC_REQ = 0x20,
+ REASSOC_RSP = 0x30,
+ PROBE_REQ = 0x40,
+ PROBE_RSP = 0x50,
+ BEACON = 0x80,
+ ATIM = 0x90,
+ DISASOC = 0xA0,
+ AUTH = 0xB0,
+ DEAUTH = 0xC0,
+ ACTION = 0xD0,
+ PS_POLL = 0xA4,
+ RTS = 0xB4,
+ CTS = 0xC4,
+ ACK = 0xD4,
+ CFEND = 0xE4,
+ CFEND_ACK = 0xF4,
+ DATA = 0x08,
+ DATA_ACK = 0x18,
+ DATA_POLL = 0x28,
+ DATA_POLL_ACK = 0x38,
+ NULL_FRAME = 0x48,
+ CFACK = 0x58,
+ CFPOLL = 0x68,
+ CFPOLL_ACK = 0x78,
+ QOS_DATA = 0x88,
+ QOS_DATA_ACK = 0x98,
+ QOS_DATA_POLL = 0xA8,
+ QOS_DATA_POLL_ACK = 0xB8,
+ QOS_NULL_FRAME = 0xC8,
+ QOS_CFPOLL = 0xE8,
+ QOS_CFPOLL_ACK = 0xF8,
+ BLOCKACK_REQ = 0x84,
+ BLOCKACK = 0x94,
+ FRAME_SUBTYPE_FORCE_32BIT = 0xFFFFFFFF
+} tenuFrmSubtype;
+
+/* Basic Frame Classes */
+typedef enum {
+ CLASS1_FRAME_TYPE = 0x00,
+ CLASS2_FRAME_TYPE = 0x01,
+ CLASS3_FRAME_TYPE = 0x02,
+ FRAME_CLASS_FORCE_32BIT = 0xFFFFFFFF
+} tenuFrameClass;
+
+/* Element ID of various Information Elements */
+typedef enum {
+ ISSID = 0, /* Service Set Identifier */
+ ISUPRATES = 1, /* Supported Rates */
+ IFHPARMS = 2, /* FH parameter set */
+ IDSPARMS = 3, /* DS parameter set */
+ ICFPARMS = 4, /* CF parameter set */
+ ITIM = 5, /* Traffic Information Map */
+ IIBPARMS = 6, /* IBSS parameter set */
+ ICOUNTRY = 7, /* Country element */
+ IEDCAPARAMS = 12, /* EDCA parameter set */
+ ITSPEC = 13, /* Traffic Specification */
+ ITCLAS = 14, /* Traffic Classification */
+ ISCHED = 15, /* Schedule */
+ ICTEXT = 16, /* Challenge Text */
+ IPOWERCONSTRAINT = 32, /* Power Constraint */
+ IPOWERCAPABILITY = 33, /* Power Capability */
+ ITPCREQUEST = 34, /* TPC Request */
+ ITPCREPORT = 35, /* TPC Report */
+ ISUPCHANNEL = 36, /* Supported channel list */
+ ICHSWANNOUNC = 37, /* Channel Switch Announcement */
+ IMEASUREMENTREQUEST = 38, /* Measurement request */
+ IMEASUREMENTREPORT = 39, /* Measurement report */
+ IQUIET = 40, /* Quiet element Info */
+ IIBSSDFS = 41, /* IBSS DFS */
+ IERPINFO = 42, /* ERP Information */
+ ITSDELAY = 43, /* TS Delay */
+ ITCLASPROCESS = 44, /* TCLAS Processing */
+ IHTCAP = 45, /* HT Capabilities */
+ IQOSCAP = 46, /* QoS Capability */
+ IRSNELEMENT = 48, /* RSN Information Element */
+ IEXSUPRATES = 50, /* Extended Supported Rates */
+ IEXCHSWANNOUNC = 60, /* Extended Ch Switch Announcement*/
+ IHTOPERATION = 61, /* HT Information */
+ ISECCHOFF = 62, /* Secondary Channel Offeset */
+ I2040COEX = 72, /* 20/40 Coexistence IE */
+ I2040INTOLCHREPORT = 73, /* 20/40 Intolerant channel report*/
+ IOBSSSCAN = 74, /* OBSS Scan parameters */
+ IEXTCAP = 127, /* Extended capability */
+ IWMM = 221, /* WMM parameters */
+ IWPAELEMENT = 221, /* WPA Information Element */
+ INFOELEM_ID_FORCE_32BIT = 0xFFFFFFFF
+} tenuInfoElemID;
+
+
+typedef struct {
+ WILC_Char *pcRespBuffer;
+ WILC_Sint32 s32MaxRespBuffLen;
+ WILC_Sint32 s32BytesRead;
+ WILC_Bool bRespRequired;
+} tstrConfigPktInfo;
+
+
+
+/*****************************************************************************/
+/* Extern Variable Declarations */
+/*****************************************************************************/
+
+
+/*****************************************************************************/
+/* Extern Function Declarations */
+/*****************************************************************************/
+extern WILC_Sint32 SendRawPacket(WILC_Sint8 *ps8Packet, WILC_Sint32 s32PacketLen);
+extern void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length);
+extern void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length);
+extern void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length);
+/*****************************************************************************/
+/* Global Variables */
+/*****************************************************************************/
+static struct semaphore SemHandleSendPkt;
+static struct semaphore SemHandlePktResp;
+
+static WILC_Sint8 *gps8ConfigPacket;
+
+static tstrConfigPktInfo gstrConfigPktInfo;
+
+static u8 g_seqno;
+
+static WILC_Sint16 g_wid_num = -1;
+
+static WILC_Uint16 Res_Len;
+
+static u8 g_oper_mode = SET_CFG;
+
+/* WID Switches */
+static tstrWID gastrWIDs[] = {
+ {WID_FIRMWARE_VERSION, WID_STR},
+ {WID_PHY_VERSION, WID_STR},
+ {WID_HARDWARE_VERSION, WID_STR},
+ {WID_BSS_TYPE, WID_CHAR},
+ {WID_QOS_ENABLE, WID_CHAR},
+ {WID_11I_MODE, WID_CHAR},
+ {WID_CURRENT_TX_RATE, WID_CHAR},
+ {WID_LINKSPEED, WID_CHAR},
+ {WID_RTS_THRESHOLD, WID_SHORT},
+ {WID_FRAG_THRESHOLD, WID_SHORT},
+ {WID_SSID, WID_STR},
+ {WID_BSSID, WID_ADR},
+ {WID_BEACON_INTERVAL, WID_SHORT},
+ {WID_POWER_MANAGEMENT, WID_CHAR},
+ {WID_LISTEN_INTERVAL, WID_CHAR},
+ {WID_DTIM_PERIOD, WID_CHAR},
+ {WID_CURRENT_CHANNEL, WID_CHAR},
+ {WID_TX_POWER_LEVEL_11A, WID_CHAR},
+ {WID_TX_POWER_LEVEL_11B, WID_CHAR},
+ {WID_PREAMBLE, WID_CHAR},
+ {WID_11G_OPERATING_MODE, WID_CHAR},
+ {WID_MAC_ADDR, WID_ADR},
+ {WID_IP_ADDRESS, WID_ADR},
+ {WID_ACK_POLICY, WID_CHAR},
+ {WID_PHY_ACTIVE_REG, WID_CHAR},
+ {WID_AUTH_TYPE, WID_CHAR},
+ {WID_REKEY_POLICY, WID_CHAR},
+ {WID_REKEY_PERIOD, WID_INT},
+ {WID_REKEY_PACKET_COUNT, WID_INT},
+#if 0
+ {WID_WEP_KEY_VALUE0, WID_STR},
+#endif
+ {WID_11I_PSK, WID_STR},
+ {WID_1X_KEY, WID_STR},
+ {WID_1X_SERV_ADDR, WID_IP},
+ {WID_SUPP_USERNAME, WID_STR},
+ {WID_SUPP_PASSWORD, WID_STR},
+ {WID_USER_CONTROL_ON_TX_POWER, WID_CHAR},
+ {WID_MEMORY_ADDRESS, WID_INT},
+ {WID_MEMORY_ACCESS_32BIT, WID_INT},
+ {WID_MEMORY_ACCESS_16BIT, WID_SHORT},
+ {WID_MEMORY_ACCESS_8BIT, WID_CHAR},
+ {WID_SITE_SURVEY_RESULTS, WID_STR},
+ {WID_PMKID_INFO, WID_STR},
+ {WID_ASSOC_RES_INFO, WID_STR},
+ {WID_MANUFACTURER, WID_STR}, /* 4 Wids added for the CAPI tool*/
+ {WID_MODEL_NAME, WID_STR},
+ {WID_MODEL_NUM, WID_STR},
+ {WID_DEVICE_NAME, WID_STR},
+ {WID_SSID_PROBE_REQ, WID_STR},
+
+#ifdef MAC_802_11N
+ {WID_11N_ENABLE, WID_CHAR},
+ {WID_11N_CURRENT_TX_MCS, WID_CHAR},
+ {WID_TX_POWER_LEVEL_11N, WID_CHAR},
+ {WID_11N_OPERATING_MODE, WID_CHAR},
+ {WID_11N_SMPS_MODE, WID_CHAR},
+ {WID_11N_PROT_MECH, WID_CHAR},
+ {WID_11N_ERP_PROT_TYPE, WID_CHAR},
+ {WID_11N_HT_PROT_TYPE, WID_CHAR},
+ {WID_11N_PHY_ACTIVE_REG_VAL, WID_INT},
+ {WID_11N_PRINT_STATS, WID_CHAR},
+ {WID_11N_AUTORATE_TABLE, WID_BIN_DATA},
+ {WID_HOST_CONFIG_IF_TYPE, WID_CHAR},
+ {WID_HOST_DATA_IF_TYPE, WID_CHAR},
+ {WID_11N_SIG_QUAL_VAL, WID_SHORT},
+ {WID_11N_IMMEDIATE_BA_ENABLED, WID_CHAR},
+ {WID_11N_TXOP_PROT_DISABLE, WID_CHAR},
+ {WID_11N_SHORT_GI_20MHZ_ENABLE, WID_CHAR},
+ {WID_SHORT_SLOT_ALLOWED, WID_CHAR},
+ {WID_11W_ENABLE, WID_CHAR},
+ {WID_11W_MGMT_PROT_REQ, WID_CHAR},
+ {WID_2040_ENABLE, WID_CHAR},
+ {WID_2040_COEXISTENCE, WID_CHAR},
+ {WID_USER_SEC_CHANNEL_OFFSET, WID_CHAR},
+ {WID_2040_CURR_CHANNEL_OFFSET, WID_CHAR},
+ {WID_2040_40MHZ_INTOLERANT, WID_CHAR},
+ {WID_HUT_RESTART, WID_CHAR},
+ {WID_HUT_NUM_TX_PKTS, WID_INT},
+ {WID_HUT_FRAME_LEN, WID_SHORT},
+ {WID_HUT_TX_FORMAT, WID_CHAR},
+ {WID_HUT_BANDWIDTH, WID_CHAR},
+ {WID_HUT_OP_BAND, WID_CHAR},
+ {WID_HUT_STBC, WID_CHAR},
+ {WID_HUT_ESS, WID_CHAR},
+ {WID_HUT_ANTSET, WID_CHAR},
+ {WID_HUT_HT_OP_MODE, WID_CHAR},
+ {WID_HUT_RIFS_MODE, WID_CHAR},
+ {WID_HUT_SMOOTHING_REC, WID_CHAR},
+ {WID_HUT_SOUNDING_PKT, WID_CHAR},
+ {WID_HUT_HT_CODING, WID_CHAR},
+ {WID_HUT_TEST_DIR, WID_CHAR},
+ {WID_HUT_TXOP_LIMIT, WID_SHORT},
+ {WID_HUT_DEST_ADDR, WID_ADR},
+ {WID_HUT_TX_PATTERN, WID_BIN_DATA},
+ {WID_HUT_TX_TIME_TAKEN, WID_INT},
+ {WID_HUT_PHY_TEST_MODE, WID_CHAR},
+ {WID_HUT_PHY_TEST_RATE_HI, WID_CHAR},
+ {WID_HUT_PHY_TEST_RATE_LO, WID_CHAR},
+ {WID_HUT_TX_TEST_TIME, WID_INT},
+ {WID_HUT_LOG_INTERVAL, WID_INT},
+ {WID_HUT_DISABLE_RXQ_REPLENISH, WID_CHAR},
+ {WID_HUT_TEST_ID, WID_STR},
+ {WID_HUT_KEY_ORIGIN, WID_CHAR},
+ {WID_HUT_BCST_PERCENT, WID_CHAR},
+ {WID_HUT_GROUP_CIPHER_TYPE, WID_CHAR},
+ {WID_HUT_STATS, WID_BIN_DATA},
+ {WID_HUT_TSF_TEST_MODE, WID_CHAR},
+ {WID_HUT_SIG_QUAL_AVG, WID_SHORT},
+ {WID_HUT_SIG_QUAL_AVG_CNT, WID_SHORT},
+ {WID_HUT_TSSI_VALUE, WID_CHAR},
+ {WID_HUT_MGMT_PERCENT, WID_CHAR},
+ {WID_HUT_MGMT_BCST_PERCENT, WID_CHAR},
+ {WID_HUT_MGMT_ALLOW_HT, WID_CHAR},
+ {WID_HUT_UC_MGMT_TYPE, WID_CHAR},
+ {WID_HUT_BC_MGMT_TYPE, WID_CHAR},
+ {WID_HUT_UC_MGMT_FRAME_LEN, WID_SHORT},
+ {WID_HUT_BC_MGMT_FRAME_LEN, WID_SHORT},
+ {WID_HUT_11W_MFP_REQUIRED_TX, WID_CHAR},
+ {WID_HUT_11W_MFP_PEER_CAPABLE, WID_CHAR},
+ {WID_HUT_11W_TX_IGTK_ID, WID_CHAR},
+ {WID_HUT_FC_TXOP_MOD, WID_CHAR},
+ {WID_HUT_FC_PROT_TYPE, WID_CHAR},
+ {WID_HUT_SEC_CCA_ASSERT, WID_CHAR},
+#endif /* MAC_802_11N */
+};
+
+WILC_Uint16 g_num_total_switches = (sizeof(gastrWIDs) / sizeof(tstrWID));
+/*****************************************************************************/
+/* Static Function Declarations */
+/*****************************************************************************/
+
+
+
+/*****************************************************************************/
+/* Functions */
+/*****************************************************************************/
+INLINE u8 ascii_hex_to_dec(u8 num)
+{
+ if ((num >= '0') && (num <= '9'))
+ return (num - '0');
+ else if ((num >= 'A') && (num <= 'F'))
+ return (10 + (num - 'A'));
+ else if ((num >= 'a') && (num <= 'f'))
+ return (10 + (num - 'a'));
+
+ return INVALID;
+}
+
+INLINE u8 get_hex_char(u8 inp)
+{
+ u8 *d2htab = "0123456789ABCDEF";
+
+ return d2htab[inp & 0xF];
+}
+
+/* This function extracts the MAC address held in a string in standard format */
+/* into another buffer as integers. */
+INLINE WILC_Uint16 extract_mac_addr(WILC_Char *str, u8 *buff)
+{
+ *buff = 0;
+ while (*str != '\0') {
+ if ((*str == ':') || (*str == '-'))
+ *(++buff) = 0;
+ else
+ *buff = (*buff << 4) + ascii_hex_to_dec(*str);
+
+ str++;
+ }
+
+ return MAC_ADDR_LEN;
+}
+
+/* This function creates MAC address in standard format from a buffer of */
+/* integers. */
+INLINE void create_mac_addr(u8 *str, u8 *buff)
+{
+ WILC_Uint32 i = 0;
+ WILC_Uint32 j = 0;
+
+ for (i = 0; i < MAC_ADDR_LEN; i++) {
+ str[j++] = get_hex_char((u8)((buff[i] >> 4) & 0x0F));
+ str[j++] = get_hex_char((u8)(buff[i] & 0x0F));
+ str[j++] = ':';
+ }
+ str[--j] = '\0';
+}
+
+/* This function converts the IP address string in dotted decimal format to */
+/* unsigned integer. This functionality is similar to the library function */
+/* inet_addr() but is reimplemented here since I could not confirm that */
+/* inet_addr is platform independent. */
+/* ips=>IP Address String in dotted decimal format */
+/* ipn=>Pointer to IP Address in integer format */
+INLINE u8 conv_ip_to_int(u8 *ips, WILC_Uint32 *ipn)
+{
+ u8 i = 0;
+ u8 ipb = 0;
+ *ipn = 0;
+ /* Integer to string for each component */
+ while (ips[i] != '\0') {
+ if (ips[i] == '.') {
+ *ipn = ((*ipn) << 8) | ipb;
+ ipb = 0;
+ } else {
+ ipb = ipb * 10 + ascii_hex_to_dec(ips[i]);
+ }
+
+ i++;
+ }
+
+ /* The last byte of the IP address is read in here */
+ *ipn = ((*ipn) << 8) | ipb;
+
+ return 0;
+}
+
+/* This function converts the IP address from integer format to dotted */
+/* decimal string format. Alternative to std library fn inet_ntoa(). */
+/* ips=>Buffer to hold IP Address String dotted decimal format (Min 17B) */
+/* ipn=>IP Address in integer format */
+INLINE u8 conv_int_to_ip(u8 *ips, WILC_Uint32 ipn)
+{
+ u8 i = 0;
+ u8 ipb = 0;
+ u8 cnt = 0;
+ u8 ipbsize = 0;
+
+ for (cnt = 4; cnt > 0; cnt--) {
+ ipb = (ipn >> (8 * (cnt - 1))) & 0xFF;
+
+ if (ipb >= 100)
+ ipbsize = 2;
+ else if (ipb >= 10)
+ ipbsize = 1;
+ else
+ ipbsize = 0;
+
+ switch (ipbsize) {
+ case 2:
+ ips[i++] = get_hex_char(ipb / 100);
+ ipb %= 100;
+
+ case 1:
+ ips[i++] = get_hex_char(ipb / 10);
+ ipb %= 10;
+
+ default:
+ ips[i++] = get_hex_char(ipb);
+ }
+
+ if (cnt > 1)
+ ips[i++] = '.';
+ }
+
+ ips[i] = '\0';
+
+ return i;
+}
+
+INLINE tenuWIDtype get_wid_type(WILC_Uint32 wid_num)
+{
+ /* Check for iconfig specific WID types first */
+ if ((wid_num == WID_BSSID) ||
+ (wid_num == WID_MAC_ADDR) ||
+ (wid_num == WID_IP_ADDRESS) ||
+ (wid_num == WID_HUT_DEST_ADDR)) {
+ return WID_ADR;
+ }
+
+ if ((WID_1X_SERV_ADDR == wid_num) ||
+ (WID_STACK_IP_ADDR == wid_num) ||
+ (WID_STACK_NETMASK_ADDR == wid_num)) {
+ return WID_IP;
+ }
+
+ /* Next check for standard WID types */
+ if (wid_num < 0x1000)
+ return WID_CHAR;
+ else if (wid_num < 0x2000)
+ return WID_SHORT;
+ else if (wid_num < 0x3000)
+ return WID_INT;
+ else if (wid_num < 0x4000)
+ return WID_STR;
+ else if (wid_num < 0x5000)
+ return WID_BIN_DATA;
+
+ return WID_UNDEF;
+}
+
+
+/* This function extracts the beacon period field from the beacon or probe */
+/* response frame. */
+INLINE WILC_Uint16 get_beacon_period(u8 *data)
+{
+ WILC_Uint16 bcn_per = 0;
+
+ bcn_per = data[0];
+ bcn_per |= (data[1] << 8);
+
+ return bcn_per;
+}
+
+INLINE WILC_Uint32 get_beacon_timestamp_lo(u8 *data)
+{
+ WILC_Uint32 time_stamp = 0;
+ WILC_Uint32 index = MAC_HDR_LEN;
+
+ time_stamp |= data[index++];
+ time_stamp |= (data[index++] << 8);
+ time_stamp |= (data[index++] << 16);
+ time_stamp |= (data[index] << 24);
+
+ return time_stamp;
+}
+
+INLINE UWORD32 get_beacon_timestamp_hi(UWORD8 *data)
+{
+ UWORD32 time_stamp = 0;
+ UWORD32 index = (MAC_HDR_LEN + 4);
+
+ time_stamp |= data[index++];
+ time_stamp |= (data[index++] << 8);
+ time_stamp |= (data[index++] << 16);
+ time_stamp |= (data[index] << 24);
+
+ return time_stamp;
+}
+
+/* This function extracts the 'frame type' bits from the MAC header of the */
+/* input frame. */
+/* Returns the value in the LSB of the returned value. */
+INLINE tenuBasicFrmType get_type(u8 *header)
+{
+ return ((tenuBasicFrmType)(header[0] & 0x0C));
+}
+
+/* This function extracts the 'frame type and sub type' bits from the MAC */
+/* header of the input frame. */
+/* Returns the value in the LSB of the returned value. */
+INLINE tenuFrmSubtype get_sub_type(u8 *header)
+{
+ return ((tenuFrmSubtype)(header[0] & 0xFC));
+}
+
+/* This function extracts the 'to ds' bit from the MAC header of the input */
+/* frame. */
+/* Returns the value in the LSB of the returned value. */
+INLINE u8 get_to_ds(u8 *header)
+{
+ return (header[1] & 0x01);
+}
+
+/* This function extracts the 'from ds' bit from the MAC header of the input */
+/* frame. */
+/* Returns the value in the LSB of the returned value. */
+INLINE u8 get_from_ds(u8 *header)
+{
+ return ((header[1] & 0x02) >> 1);
+}
+
+/* This function extracts the MAC Address in 'address1' field of the MAC */
+/* header and updates the MAC Address in the allocated 'addr' variable. */
+INLINE void get_address1(u8 *pu8msa, u8 *addr)
+{
+ WILC_memcpy(addr, pu8msa + 4, 6);
+}
+
+/* This function extracts the MAC Address in 'address2' field of the MAC */
+/* header and updates the MAC Address in the allocated 'addr' variable. */
+INLINE void get_address2(u8 *pu8msa, u8 *addr)
+{
+ WILC_memcpy(addr, pu8msa + 10, 6);
+}
+
+/* This function extracts the MAC Address in 'address3' field of the MAC */
+/* header and updates the MAC Address in the allocated 'addr' variable. */
+INLINE void get_address3(u8 *pu8msa, u8 *addr)
+{
+ WILC_memcpy(addr, pu8msa + 16, 6);
+}
+
+/* This function extracts the BSSID from the incoming WLAN packet based on */
+/* the 'from ds' bit, and updates the MAC Address in the allocated 'addr' */
+/* variable. */
+INLINE void get_BSSID(u8 *data, u8 *bssid)
+{
+ if (get_from_ds(data) == 1)
+ get_address2(data, bssid);
+ else if (get_to_ds(data) == 1)
+ get_address1(data, bssid);
+ else
+ get_address3(data, bssid);
+}
+
+/* This function extracts the SSID from a beacon/probe response frame */
+INLINE void get_ssid(u8 *data, u8 *ssid, u8 *p_ssid_len)
+{
+ u8 len = 0;
+ u8 i = 0;
+ u8 j = 0;
+
+ len = data[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN +
+ CAP_INFO_LEN + 1];
+ j = MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN +
+ CAP_INFO_LEN + 2;
+
+ /* If the SSID length field is set wrongly to a value greater than the */
+ /* allowed maximum SSID length limit, reset the length to 0 */
+ if (len >= MAX_SSID_LEN)
+ len = 0;
+
+ for (i = 0; i < len; i++, j++)
+ ssid[i] = data[j];
+
+ ssid[len] = '\0';
+
+ *p_ssid_len = len;
+}
+
+/* This function extracts the capability info field from the beacon or probe */
+/* response frame. */
+INLINE WILC_Uint16 get_cap_info(u8 *data)
+{
+ WILC_Uint16 cap_info = 0;
+ WILC_Uint16 index = MAC_HDR_LEN;
+ tenuFrmSubtype st = BEACON;
+
+ st = get_sub_type(data);
+
+ /* Location of the Capability field is different for Beacon and */
+ /* Association frames. */
+ if ((st == BEACON) || (st == PROBE_RSP))
+ index += TIME_STAMP_LEN + BEACON_INTERVAL_LEN;
+
+ cap_info = data[index];
+ cap_info |= (data[index + 1] << 8);
+
+ return cap_info;
+}
+
+/* This function extracts the capability info field from the Association */
+/* response frame. */
+INLINE WILC_Uint16 get_assoc_resp_cap_info(u8 *data)
+{
+ WILC_Uint16 cap_info = 0;
+
+ cap_info = data[0];
+ cap_info |= (data[1] << 8);
+
+ return cap_info;
+}
+
+/* This funcion extracts the association status code from the incoming */
+/* association response frame and returns association status code */
+INLINE WILC_Uint16 get_asoc_status(u8 *data)
+{
+ WILC_Uint16 asoc_status = 0;
+
+ asoc_status = data[3];
+ asoc_status = (asoc_status << 8) | data[2];
+
+ return asoc_status;
+}
+
+/* This function extracts association ID from the incoming association */
+/* response frame */
+INLINE WILC_Uint16 get_asoc_id(u8 *data)
+{
+ WILC_Uint16 asoc_id = 0;
+
+ asoc_id = data[4];
+ asoc_id |= (data[5] << 8);
+
+ return asoc_id;
+}
+
+/**
+ * @brief initializes the Core Configurator
+ * @details
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 CoreConfiguratorInit(void)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ PRINT_D(CORECONFIG_DBG, "CoreConfiguratorInit() \n");
+
+ sema_init(&SemHandleSendPkt, 1);
+ sema_init(&SemHandlePktResp, 0);
+
+ gps8ConfigPacket = (WILC_Sint8 *)WILC_MALLOC(MAX_PACKET_BUFF_SIZE);
+ if (gps8ConfigPacket == NULL) {
+ PRINT_ER("failed in gps8ConfigPacket allocation \n");
+ s32Error = WILC_NO_MEM;
+ goto _fail_;
+ }
+
+ WILC_memset((void *)gps8ConfigPacket, 0, MAX_PACKET_BUFF_SIZE);
+
+ WILC_memset((void *)(&gstrConfigPktInfo), 0, sizeof(tstrConfigPktInfo));
+_fail_:
+ return s32Error;
+}
+
+u8 *get_tim_elm(u8 *pu8msa, WILC_Uint16 u16RxLen, WILC_Uint16 u16TagParamOffset)
+{
+ WILC_Uint16 u16index = 0;
+
+ /*************************************************************************/
+ /* Beacon Frame - Frame Body */
+ /* --------------------------------------------------------------------- */
+ /* |Timestamp |BeaconInt |CapInfo |SSID |SupRates |DSParSet |TIM elm | */
+ /* --------------------------------------------------------------------- */
+ /* |8 |2 |2 |2-34 |3-10 |3 |4-256 | */
+ /* --------------------------------------------------------------------- */
+ /* */
+ /*************************************************************************/
+
+ u16index = u16TagParamOffset;
+
+ /* Search for the TIM Element Field and return if the element is found */
+ while (u16index < (u16RxLen - FCS_LEN)) {
+ if (pu8msa[u16index] == ITIM) {
+ return(&pu8msa[u16index]);
+ } else {
+ u16index += (IE_HDR_LEN + pu8msa[u16index + 1]);
+ }
+ }
+
+ return(0);
+}
+
+/* This function gets the current channel information from
+ * the 802.11n beacon/probe response frame */
+u8 get_current_channel_802_11n(u8 *pu8msa, WILC_Uint16 u16RxLen)
+{
+ WILC_Uint16 index;
+
+ index = TAG_PARAM_OFFSET;
+ while (index < (u16RxLen - FCS_LEN)) {
+ if (pu8msa[index] == IDSPARMS)
+ return (pu8msa[index + 2]);
+ else
+ /* Increment index by length information and header */
+ index += pu8msa[index + 1] + IE_HDR_LEN;
+ }
+
+ /* Return current channel information from the MIB, if beacon/probe */
+ /* response frame does not contain the DS parameter set IE */
+ /* return (mget_CurrentChannel() + 1); */
+ return 0; /* no MIB here */
+}
+
+u8 get_current_channel(u8 *pu8msa, WILC_Uint16 u16RxLen)
+{
+#ifdef PHY_802_11n
+#ifdef FIVE_GHZ_BAND
+ /* Get the current channel as its not set in */
+ /* 802.11a beacons/probe response */
+ return (get_rf_channel() + 1);
+#else /* FIVE_GHZ_BAND */
+ /* Extract current channel information from */
+ /* the beacon/probe response frame */
+ return (get_current_channel_802_11n(pu8msa, u16RxLen));
+#endif /* FIVE_GHZ_BAND */
+#else
+ return 0;
+#endif /* PHY_802_11n */
+}
+
+/**
+ * @brief parses the received 'N' message
+ * @details
+ * @param[in] pu8MsgBuffer The message to be parsed
+ * @param[out] ppstrNetworkInfo pointer to pointer to the structure containing the parsed Network Info
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrNetworkInfo *pstrNetworkInfo = NULL;
+ u8 u8MsgType = 0;
+ u8 u8MsgID = 0;
+ WILC_Uint16 u16MsgLen = 0;
+
+ WILC_Uint16 u16WidID = (WILC_Uint16)WID_NIL;
+ WILC_Uint16 u16WidLen = 0;
+ u8 *pu8WidVal = 0;
+
+ u8MsgType = pu8MsgBuffer[0];
+
+ /* Check whether the received message type is 'N' */
+ if ('N' != u8MsgType) {
+ PRINT_ER("Received Message format incorrect.\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ /* Extract message ID */
+ u8MsgID = pu8MsgBuffer[1];
+
+ /* Extract message Length */
+ u16MsgLen = MAKE_WORD16(pu8MsgBuffer[2], pu8MsgBuffer[3]);
+
+ /* Extract WID ID */
+ u16WidID = MAKE_WORD16(pu8MsgBuffer[4], pu8MsgBuffer[5]);
+
+ /* Extract WID Length */
+ u16WidLen = MAKE_WORD16(pu8MsgBuffer[6], pu8MsgBuffer[7]);
+
+ /* Assign a pointer to the WID value */
+ pu8WidVal = &pu8MsgBuffer[8];
+
+ /* parse the WID value of the WID "WID_NEWORK_INFO" */
+ {
+ u8 *pu8msa = 0;
+ WILC_Uint16 u16RxLen = 0;
+ u8 *pu8TimElm = 0;
+ u8 *pu8IEs = 0;
+ WILC_Uint16 u16IEsLen = 0;
+ u8 u8index = 0;
+ WILC_Uint32 u32Tsf_Lo;
+ WILC_Uint32 u32Tsf_Hi;
+
+ pstrNetworkInfo = (tstrNetworkInfo *)WILC_MALLOC(sizeof(tstrNetworkInfo));
+ WILC_memset((void *)(pstrNetworkInfo), 0, sizeof(tstrNetworkInfo));
+
+ pstrNetworkInfo->s8rssi = pu8WidVal[0];
+
+ /* Assign a pointer to msa "Mac Header Start Address" */
+ pu8msa = &pu8WidVal[1];
+
+ u16RxLen = u16WidLen - 1;
+
+ /* parse msa*/
+
+ /* Get the cap_info */
+ pstrNetworkInfo->u16CapInfo = get_cap_info(pu8msa);
+ #ifdef WILC_P2P
+ /* Get time-stamp [Low only 32 bit] */
+ pstrNetworkInfo->u32Tsf = get_beacon_timestamp_lo(pu8msa);
+ PRINT_D(CORECONFIG_DBG, "TSF :%x\n", pstrNetworkInfo->u32Tsf);
+ #endif
+
+ /* Get full time-stamp [Low and High 64 bit] */
+ u32Tsf_Lo = get_beacon_timestamp_lo(pu8msa);
+ u32Tsf_Hi = get_beacon_timestamp_hi(pu8msa);
+
+ pstrNetworkInfo->u64Tsf = u32Tsf_Lo | ((WILC_Uint64)u32Tsf_Hi << 32);
+
+ /* Get SSID */
+ get_ssid(pu8msa, pstrNetworkInfo->au8ssid, &(pstrNetworkInfo->u8SsidLen));
+
+ /* Get BSSID */
+ get_BSSID(pu8msa, pstrNetworkInfo->au8bssid);
+
+ /* Get the current channel */
+ pstrNetworkInfo->u8channel = get_current_channel(pu8msa, (u16RxLen + FCS_LEN));
+
+ /* Get beacon period */
+ u8index = (MAC_HDR_LEN + TIME_STAMP_LEN);
+
+ pstrNetworkInfo->u16BeaconPeriod = get_beacon_period(pu8msa + u8index);
+
+ u8index += BEACON_INTERVAL_LEN + CAP_INFO_LEN;
+
+ /* Get DTIM Period */
+ pu8TimElm = get_tim_elm(pu8msa, (u16RxLen + FCS_LEN), u8index);
+ if (pu8TimElm != 0) {
+ pstrNetworkInfo->u8DtimPeriod = pu8TimElm[3];
+ }
+ pu8IEs = &pu8msa[MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN];
+ u16IEsLen = u16RxLen - (MAC_HDR_LEN + TIME_STAMP_LEN + BEACON_INTERVAL_LEN + CAP_INFO_LEN);
+
+ if (u16IEsLen > 0) {
+ pstrNetworkInfo->pu8IEs = (u8 *)WILC_MALLOC(u16IEsLen);
+ WILC_memset((void *)(pstrNetworkInfo->pu8IEs), 0, u16IEsLen);
+
+ WILC_memcpy(pstrNetworkInfo->pu8IEs, pu8IEs, u16IEsLen);
+ }
+ pstrNetworkInfo->u16IEsLen = u16IEsLen;
+
+ }
+
+ *ppstrNetworkInfo = pstrNetworkInfo;
+
+ERRORHANDLER:
+ return s32Error;
+}
+
+/**
+ * @brief Deallocates the parsed Network Info
+ * @details
+ * @param[in] pstrNetworkInfo Network Info to be deallocated
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ if (pstrNetworkInfo != NULL) {
+ if (pstrNetworkInfo->pu8IEs != NULL) {
+ WILC_FREE(pstrNetworkInfo->pu8IEs);
+ pstrNetworkInfo->pu8IEs = NULL;
+ } else {
+ s32Error = WILC_FAIL;
+ }
+
+ WILC_FREE(pstrNetworkInfo);
+ pstrNetworkInfo = NULL;
+
+ } else {
+ s32Error = WILC_FAIL;
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief parses the received Association Response frame
+ * @details
+ * @param[in] pu8Buffer The Association Response frame to be parsed
+ * @param[out] ppstrConnectRespInfo pointer to pointer to the structure containing the parsed Association Response Info
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 2 Apr 2012
+ * @version 1.0
+ */
+WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, WILC_Uint32 u32BufferLen,
+ tstrConnectRespInfo **ppstrConnectRespInfo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrConnectRespInfo *pstrConnectRespInfo = NULL;
+ WILC_Uint16 u16AssocRespLen = 0;
+ u8 *pu8IEs = 0;
+ WILC_Uint16 u16IEsLen = 0;
+
+ pstrConnectRespInfo = (tstrConnectRespInfo *)WILC_MALLOC(sizeof(tstrConnectRespInfo));
+ WILC_memset((void *)(pstrConnectRespInfo), 0, sizeof(tstrConnectRespInfo));
+
+ /* u16AssocRespLen = pu8Buffer[0]; */
+ u16AssocRespLen = (WILC_Uint16)u32BufferLen;
+
+ /* get the status code */
+ pstrConnectRespInfo->u16ConnectStatus = get_asoc_status(pu8Buffer);
+ if (pstrConnectRespInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
+
+ /* get the capability */
+ pstrConnectRespInfo->u16capability = get_assoc_resp_cap_info(pu8Buffer);
+
+ /* get the Association ID */
+ pstrConnectRespInfo->u16AssocID = get_asoc_id(pu8Buffer);
+
+ /* get the Information Elements */
+ pu8IEs = &pu8Buffer[CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN];
+ u16IEsLen = u16AssocRespLen - (CAP_INFO_LEN + STATUS_CODE_LEN + AID_LEN);
+
+ pstrConnectRespInfo->pu8RespIEs = (u8 *)WILC_MALLOC(u16IEsLen);
+ WILC_memset((void *)(pstrConnectRespInfo->pu8RespIEs), 0, u16IEsLen);
+
+ WILC_memcpy(pstrConnectRespInfo->pu8RespIEs, pu8IEs, u16IEsLen);
+ pstrConnectRespInfo->u16RespIEsLen = u16IEsLen;
+ }
+
+ *ppstrConnectRespInfo = pstrConnectRespInfo;
+
+
+ return s32Error;
+}
+
+/**
+ * @brief Deallocates the parsed Association Response Info
+ * @details
+ * @param[in] pstrNetworkInfo Network Info to be deallocated
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 2 Apr 2012
+ * @version 1.0
+ */
+WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ if (pstrConnectRespInfo != NULL) {
+ if (pstrConnectRespInfo->pu8RespIEs != NULL) {
+ WILC_FREE(pstrConnectRespInfo->pu8RespIEs);
+ pstrConnectRespInfo->pu8RespIEs = NULL;
+ } else {
+ s32Error = WILC_FAIL;
+ }
+
+ WILC_FREE(pstrConnectRespInfo);
+ pstrConnectRespInfo = NULL;
+
+ } else {
+ s32Error = WILC_FAIL;
+ }
+
+ return s32Error;
+}
+
+#ifndef CONNECT_DIRECT
+WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
+ wid_site_survey_reslts_s **ppstrSurveyResults,
+ WILC_Uint32 *pu32SurveyResultsCount)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ wid_site_survey_reslts_s *pstrSurveyResults = NULL;
+ WILC_Uint32 u32SurveyResultsCount = 0;
+ WILC_Uint32 u32SurveyBytesLength = 0;
+ u8 *pu8BufferPtr;
+ WILC_Uint32 u32RcvdSurveyResultsNum = 2;
+ u8 u8ReadSurveyResFragNum;
+ WILC_Uint32 i;
+ WILC_Uint32 j;
+
+ for (i = 0; i < u32RcvdSurveyResultsNum; i++) {
+ u32SurveyBytesLength = ppu8RcvdSiteSurveyResults[i][0];
+
+
+ for (j = 0; j < u32SurveyBytesLength; j += SURVEY_RESULT_LENGTH) {
+ u32SurveyResultsCount++;
+ }
+ }
+
+ pstrSurveyResults = (wid_site_survey_reslts_s *)WILC_MALLOC(u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s));
+ if (pstrSurveyResults == NULL) {
+ u32SurveyResultsCount = 0;
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ WILC_memset((void *)(pstrSurveyResults), 0, u32SurveyResultsCount * sizeof(wid_site_survey_reslts_s));
+
+ u32SurveyResultsCount = 0;
+
+ for (i = 0; i < u32RcvdSurveyResultsNum; i++) {
+ pu8BufferPtr = ppu8RcvdSiteSurveyResults[i];
+
+ u32SurveyBytesLength = pu8BufferPtr[0];
+
+ /* TODO: mostafa: pu8BufferPtr[1] contains the fragment num */
+ u8ReadSurveyResFragNum = pu8BufferPtr[1];
+
+ pu8BufferPtr += 2;
+
+ for (j = 0; j < u32SurveyBytesLength; j += SURVEY_RESULT_LENGTH) {
+ WILC_memcpy(&pstrSurveyResults[u32SurveyResultsCount], pu8BufferPtr, SURVEY_RESULT_LENGTH);
+ pu8BufferPtr += SURVEY_RESULT_LENGTH;
+ u32SurveyResultsCount++;
+ }
+ }
+
+ERRORHANDLER:
+ *ppstrSurveyResults = pstrSurveyResults;
+ *pu32SurveyResultsCount = u32SurveyResultsCount;
+
+ return s32Error;
+}
+
+
+WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ if (pstrSurveyResults != NULL) {
+ WILC_FREE(pstrSurveyResults);
+ }
+
+ return s32Error;
+}
+#endif
+
+/*****************************************************************************/
+/* */
+/* Function Name : ProcessCharWid */
+/* */
+/* Description : This function processes a WID of type WID_CHAR and */
+/* updates the cfg packet with the supplied value. */
+/* */
+/* Inputs : 1) Pointer to WID cfg structure */
+/* 2) Value to set */
+/* */
+/* Globals : */
+/* */
+/* Processing : */
+/* */
+/* Outputs : None */
+/* */
+/* Returns : None */
+/* */
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2008 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+void ProcessCharWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen,
+ tstrWID *pstrWID, WILC_Sint8 *ps8WidVal)
+{
+ u8 *pu8val = (u8 *)ps8WidVal;
+ u8 u8val = 0;
+ WILC_Sint32 s32PktLen = *ps32PktLen;
+ if (pstrWID == NULL) {
+ PRINT_WRN(CORECONFIG_DBG, "Can't set CHAR val 0x%x ,NULL structure\n", u8val);
+ return;
+ }
+
+ /* WID */
+ pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
+ pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid >> 8) & 0xFF;
+ if (g_oper_mode == SET_CFG) {
+ u8val = *pu8val;
+
+ /* Length */
+ pcPacket[s32PktLen++] = sizeof(u8);
+
+
+ /* Value */
+ pcPacket[s32PktLen++] = u8val;
+ }
+ *ps32PktLen = s32PktLen;
+}
+
+/*****************************************************************************/
+/* */
+/* Function Name : ProcessShortWid */
+/* */
+/* Description : This function processes a WID of type WID_SHORT and */
+/* updates the cfg packet with the supplied value. */
+/* */
+/* Inputs : 1) Pointer to WID cfg structure */
+/* 2) Value to set */
+/* */
+/* Globals : */
+/* */
+/* Processing : */
+/* */
+/* Outputs : None */
+/* */
+/* Returns : None */
+/* */
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2008 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+void ProcessShortWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen,
+ tstrWID *pstrWID, WILC_Sint8 *ps8WidVal)
+{
+ WILC_Uint16 *pu16val = (WILC_Uint16 *)ps8WidVal;
+ WILC_Uint16 u16val = 0;
+ WILC_Sint32 s32PktLen = *ps32PktLen;
+ if (pstrWID == NULL) {
+ PRINT_WRN(CORECONFIG_DBG, "Can't set SHORT val 0x%x ,NULL structure\n", u16val);
+ return;
+ }
+
+ /* WID */
+ pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
+
+ if (g_oper_mode == SET_CFG) {
+ u16val = *pu16val;
+
+ /* Length */
+ pcPacket[s32PktLen++] = sizeof(WILC_Uint16);
+
+ /* Value */
+ pcPacket[s32PktLen++] = (u8)(u16val & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((u16val >> 8) & 0xFF);
+ }
+ *ps32PktLen = s32PktLen;
+}
+
+/*****************************************************************************/
+/* */
+/* Function Name : ProcessIntWid */
+/* */
+/* Description : This function processes a WID of type WID_INT and */
+/* updates the cfg packet with the supplied value. */
+/* */
+/* Inputs : 1) Pointer to WID cfg structure */
+/* 2) Value to set */
+/* */
+/* Globals : */
+/* */
+/* Processing : */
+/* */
+/* Outputs : None */
+/* */
+/* Returns : None */
+/* */
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2008 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+void ProcessIntWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen,
+ tstrWID *pstrWID, WILC_Sint8 *ps8WidVal)
+{
+ WILC_Uint32 *pu32val = (WILC_Uint32 *)ps8WidVal;
+ WILC_Uint32 u32val = 0;
+ WILC_Sint32 s32PktLen = *ps32PktLen;
+ if (pstrWID == NULL) {
+ PRINT_WRN(CORECONFIG_DBG, "Can't set INT val 0x%x , NULL structure\n", u32val);
+ return;
+ }
+
+ /* WID */
+ pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
+
+ if (g_oper_mode == SET_CFG) {
+ u32val = *pu32val;
+
+ /* Length */
+ pcPacket[s32PktLen++] = sizeof(WILC_Uint32);
+
+ /* Value */
+ pcPacket[s32PktLen++] = (u8)(u32val & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((u32val >> 8) & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((u32val >> 16) & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((u32val >> 24) & 0xFF);
+ }
+ *ps32PktLen = s32PktLen;
+}
+
+/*****************************************************************************/
+/* */
+/* Function Name : ProcessIPwid */
+/* */
+/* Description : This function processes a WID of type WID_IP and */
+/* updates the cfg packet with the supplied value. */
+/* */
+/* Inputs : 1) Pointer to WID cfg structure */
+/* 2) Value to set */
+/* */
+/* Globals : */
+/* */
+/* */
+/* Processing : */
+/* */
+/* Outputs : None */
+/* */
+/* Returns : None */
+/* */
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2008 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+void ProcessIPwid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen,
+ tstrWID *pstrWID, u8 *pu8ip)
+{
+ WILC_Uint32 u32val = 0;
+ WILC_Sint32 s32PktLen = *ps32PktLen;
+
+ if (pstrWID == NULL) {
+ PRINT_WRN(CORECONFIG_DBG, "Can't set IP Addr , NULL structure\n");
+ return;
+ }
+
+ /* WID */
+ pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
+
+ if (g_oper_mode == SET_CFG) {
+ /* Length */
+ pcPacket[s32PktLen++] = sizeof(WILC_Uint32);
+
+ /* Convert the IP Address String to Integer */
+ conv_ip_to_int(pu8ip, &u32val);
+
+ /* Value */
+ pcPacket[s32PktLen++] = (u8)(u32val & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((u32val >> 8) & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((u32val >> 16) & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((u32val >> 24) & 0xFF);
+ }
+ *ps32PktLen = s32PktLen;
+}
+
+/*****************************************************************************/
+/* */
+/* Function Name : ProcessStrWid */
+/* */
+/* Description : This function processes a WID of type WID_STR and */
+/* updates the cfg packet with the supplied value. */
+/* */
+/* Inputs : 1) Pointer to WID cfg structure */
+/* 2) Value to set */
+/* */
+/* Globals : */
+/* */
+/* Processing : */
+/* */
+/* Outputs : None */
+/* */
+/* Returns : None */
+/* */
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2008 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+void ProcessStrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen,
+ tstrWID *pstrWID, u8 *pu8val, WILC_Sint32 s32ValueSize)
+{
+ WILC_Uint16 u16MsgLen = 0;
+ WILC_Uint16 idx = 0;
+ WILC_Sint32 s32PktLen = *ps32PktLen;
+ if (pstrWID == NULL) {
+ PRINT_WRN(CORECONFIG_DBG, "Can't set STR val, NULL structure\n");
+ return;
+ }
+
+ /* WID */
+ pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
+
+ if (g_oper_mode == SET_CFG) {
+ /* Message Length */
+ /* u16MsgLen = WILC_strlen(pu8val); */
+ u16MsgLen = (WILC_Uint16)s32ValueSize;
+
+ /* Length */
+ pcPacket[s32PktLen++] = (u8)u16MsgLen;
+
+ /* Value */
+ for (idx = 0; idx < u16MsgLen; idx++)
+ pcPacket[s32PktLen++] = pu8val[idx];
+ }
+ *ps32PktLen = s32PktLen;
+}
+
+/*****************************************************************************/
+/* */
+/* Function Name : ProcessAdrWid */
+/* */
+/* Description : This function processes a WID of type WID_ADR and */
+/* updates the cfg packet with the supplied value. */
+/* */
+/* Inputs : 1) Pointer to WID cfg structure */
+/* 2) Value to set */
+/* */
+/* Globals : */
+/* */
+/* Processing : */
+/* */
+/* Outputs : None */
+/* */
+/* Returns : None */
+/* */
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2008 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+void ProcessAdrWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen,
+ tstrWID *pstrWID, u8 *pu8val)
+{
+ WILC_Uint16 u16MsgLen = 0;
+ WILC_Sint32 s32PktLen = *ps32PktLen;
+
+ if (pstrWID == NULL) {
+ PRINT_WRN(CORECONFIG_DBG, "Can't set Addr WID, NULL structure\n");
+ return;
+ }
+
+ /* WID */
+ pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
+
+ if (g_oper_mode == SET_CFG) {
+ /* Message Length */
+ u16MsgLen = MAC_ADDR_LEN;
+
+ /* Length */
+ pcPacket[s32PktLen++] = (u8)u16MsgLen;
+
+ /* Value */
+ extract_mac_addr(pu8val, pcPacket + s32PktLen);
+ s32PktLen += u16MsgLen;
+ }
+ *ps32PktLen = s32PktLen;
+}
+
+/*****************************************************************************/
+/* */
+/* Function Name : ProcessBinWid */
+/* */
+/* Description : This function processes a WID of type WID_BIN_DATA and */
+/* updates the cfg packet with the supplied value. */
+/* */
+/* Inputs : 1) Pointer to WID cfg structure */
+/* 2) Name of file containing the binary data in text mode */
+/* */
+/* Globals : */
+/* */
+/* Processing : The binary data is expected to be supplied through a */
+/* file in text mode. This file is expected to be in the */
+/* finject format. It is parsed, converted to binary format */
+/* and copied into g_cfg_pkt for further processing. This */
+/* is obviously a round-about way of processing involving */
+/* multiple (re)conversions between bin & ascii formats. */
+/* But it is done nevertheless to retain uniformity and for */
+/* ease of debugging. */
+/* */
+/* Outputs : None */
+/* */
+/* Returns : None */
+/* */
+
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2008 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+void ProcessBinWid(WILC_Char *pcPacket, WILC_Sint32 *ps32PktLen,
+ tstrWID *pstrWID, u8 *pu8val, WILC_Sint32 s32ValueSize)
+{
+ /* WILC_ERROR("processing Binary WIDs is not supported \n"); */
+
+ WILC_Uint16 u16MsgLen = 0;
+ WILC_Uint16 idx = 0;
+ WILC_Sint32 s32PktLen = *ps32PktLen;
+ u8 u8checksum = 0;
+
+ if (pstrWID == NULL) {
+ PRINT_WRN(CORECONFIG_DBG, "Can't set BIN val, NULL structure\n");
+ return;
+ }
+
+ /* WID */
+ pcPacket[s32PktLen++] = (u8)(pstrWID->u16WIDid & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((pstrWID->u16WIDid >> 8) & 0xFF);
+
+ if (g_oper_mode == SET_CFG) {
+ /* Message Length */
+ u16MsgLen = (WILC_Uint16)s32ValueSize;
+
+ /* Length */
+ /* pcPacket[s32PktLen++] = (u8)u16MsgLen; */
+ pcPacket[s32PktLen++] = (u8)(u16MsgLen & 0xFF);
+ pcPacket[s32PktLen++] = (u8)((u16MsgLen >> 8) & 0xFF);
+
+ /* Value */
+ for (idx = 0; idx < u16MsgLen; idx++)
+ pcPacket[s32PktLen++] = pu8val[idx];
+
+ /* checksum */
+ for (idx = 0; idx < u16MsgLen; idx++)
+ u8checksum += pcPacket[MSG_HEADER_LEN + idx + 4];
+
+ pcPacket[s32PktLen++] = u8checksum;
+ }
+ *ps32PktLen = s32PktLen;
+}
+
+
+/*****************************************************************************/
+/* */
+/* Function Name : further_process_response */
+/* */
+/* Description : This function parses the response frame got from the */
+/* device. */
+/* */
+/* Inputs : 1) The received response frame */
+/* 2) WID */
+/* 3) WID Length */
+/* 4) Output file handle */
+/* 5) Process Wid Number(i.e wid from --widn switch) */
+/* 6) Index the array in the Global Wid Structure. */
+/* */
+/* Globals : g_wid_num, gastrWIDs */
+/* */
+/* Processing : This function parses the response of the device depending*/
+/* WID type and writes it to the output file in Hex or */
+/* decimal notation depending on the --getx or --get switch.*/
+/* */
+/* Outputs : None */
+/* */
+/* Returns : 0 on Success & -2 on Failure */
+/* */
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2009 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+WILC_Sint32 further_process_response(u8 *resp,
+ WILC_Uint16 u16WIDid,
+ WILC_Uint16 cfg_len,
+ WILC_Bool process_wid_num,
+ WILC_Uint32 cnt,
+ tstrWID *pstrWIDresult)
+{
+ WILC_Uint32 retval = 0;
+ WILC_Uint32 idx = 0;
+ u8 cfg_chr = 0;
+ WILC_Uint16 cfg_sht = 0;
+ WILC_Uint32 cfg_int = 0;
+ u8 cfg_str[256] = {0};
+ tenuWIDtype enuWIDtype = WID_UNDEF;
+
+ if (process_wid_num) {
+ enuWIDtype = get_wid_type(g_wid_num);
+ } else {
+ enuWIDtype = gastrWIDs[cnt].enuWIDtype;
+ }
+
+
+ switch (enuWIDtype) {
+ case WID_CHAR:
+ cfg_chr = resp[idx];
+ /*Set local copy of WID*/
+ *(pstrWIDresult->ps8WidVal) = cfg_chr;
+ break;
+
+ case WID_SHORT:
+ {
+ WILC_Uint16 *pu16val = (WILC_Uint16 *)(pstrWIDresult->ps8WidVal);
+ cfg_sht = MAKE_WORD16(resp[idx], resp[idx + 1]);
+ /*Set local copy of WID*/
+ /* pstrWIDresult->ps8WidVal = (WILC_Sint8*)(WILC_Sint32)cfg_sht; */
+ *pu16val = cfg_sht;
+ break;
+ }
+
+ case WID_INT:
+ {
+ WILC_Uint32 *pu32val = (WILC_Uint32 *)(pstrWIDresult->ps8WidVal);
+ cfg_int = MAKE_WORD32(
+ MAKE_WORD16(resp[idx], resp[idx + 1]),
+ MAKE_WORD16(resp[idx + 2], resp[idx + 3])
+ );
+ /*Set local copy of WID*/
+ /* pstrWIDresult->ps8WidVal = (WILC_Sint8*)cfg_int; */
+ *pu32val = cfg_int;
+ break;
+ }
+
+ case WID_STR:
+ WILC_memcpy(cfg_str, resp + idx, cfg_len);
+ /* cfg_str[cfg_len] = '\0'; //mostafa: no need currently for NULL termination */
+ if (process_wid_num) {
+ /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num,
+ * cfg_str);*/
+ } else {
+ /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch,
+ * cfg_str);*/
+ }
+
+ if (pstrWIDresult->s32ValueSize >= cfg_len) {
+ WILC_memcpy(pstrWIDresult->ps8WidVal, cfg_str, cfg_len); /* mostafa: no need currently for the extra NULL byte */
+ pstrWIDresult->s32ValueSize = cfg_len;
+ } else {
+ PRINT_ER("allocated WID buffer length is smaller than the received WID Length \n");
+ retval = -2;
+ }
+
+ break;
+
+ case WID_ADR:
+ create_mac_addr(cfg_str, resp + idx);
+
+ WILC_strncpy(pstrWIDresult->ps8WidVal, cfg_str, WILC_strlen(cfg_str));
+ pstrWIDresult->ps8WidVal[WILC_strlen(cfg_str)] = '\0';
+ if (process_wid_num) {
+ /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num,
+ * cfg_str);*/
+ } else {
+ /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch,
+ * cfg_str);*/
+ }
+ break;
+
+ case WID_IP:
+ cfg_int = MAKE_WORD32(
+ MAKE_WORD16(resp[idx], resp[idx + 1]),
+ MAKE_WORD16(resp[idx + 2], resp[idx + 3])
+ );
+ conv_int_to_ip(cfg_str, cfg_int);
+ if (process_wid_num) {
+ /*fprintf(out_file,"0x%4.4x = %s\n",g_wid_num,
+ * cfg_str);*/
+ } else {
+ /*fprintf(out_file,"%s = %s\n",gastrWIDs[cnt].cfg_switch,
+ * cfg_str);*/
+ }
+ break;
+
+ case WID_BIN_DATA:
+ #if 0
+ /* FILE *fp_bin = NULL; */
+ u8 first_bin_wid = 1;
+ if (first_bin_wid) {
+ /* fp_bin = fopen("wid_response.bin","wb"); */
+ first_bin_wid = 0;
+ } else {
+ /* fp_bin = fopen("wid_response.bin","ab"); */
+ }
+
+ if (/*fp_bin == NULL*/ 0) {
+ PRINT_ER("Error: Could not open wid_response.bin for write\n");
+ return -2;
+ }
+
+ /* fwrite(resp + idx, cfg_len, 1, fp_bin); */
+
+ /* fclose(fp_bin); */
+ #endif
+
+ if (pstrWIDresult->s32ValueSize >= cfg_len) {
+ WILC_memcpy(pstrWIDresult->ps8WidVal, resp + idx, cfg_len);
+ pstrWIDresult->s32ValueSize = cfg_len;
+ } else {
+ PRINT_ER("Allocated WID buffer length is smaller than the received WID Length Err(%d)\n", retval);
+ retval = -2;
+ }
+ break;
+
+ default:
+ PRINT_ER("ERROR: Check config database: Error(%d)\n", retval);
+ retval = -2;
+ break;
+ }
+
+ return retval;
+}
+
+/*****************************************************************************/
+/* */
+/* Function Name : ParseResponse */
+/* */
+/* Description : This function parses the command-line options and */
+/* creates the config packets which can be sent to the WLAN */
+/* station. */
+/* */
+/* Inputs : 1) The received response frame */
+/* */
+/* Globals : g_opt_list, gastrWIDs */
+/* */
+/* Processing : This function parses the options and creates different */
+/* types of packets depending upon the WID-type */
+/* corresponding to the option. */
+/* */
+/* Outputs : None */
+/* */
+/* Returns : 0 on Success & -1 on Failure */
+/* */
+/* Issues : None */
+/* */
+/* Revision History: */
+/* */
+/* DD MM YYYY Author(s) Changes (Describe the changes made) */
+/* 08 01 2008 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+WILC_Sint32 ParseResponse(u8 *resp, tstrWID *pstrWIDcfgResult)
+{
+ WILC_Uint16 u16RespLen = 0;
+ WILC_Uint16 u16WIDid = 0;
+ WILC_Uint16 cfg_len = 0;
+ tenuWIDtype enuWIDtype = WID_UNDEF;
+ WILC_Bool num_wid_processed = WILC_FALSE;
+ WILC_Uint32 cnt = 0;
+ WILC_Uint32 idx = 0;
+ WILC_Uint32 ResCnt = 0;
+ /* Check whether the received frame is a valid response */
+ if (RESP_MSG_TYPE != resp[0]) {
+ PRINT_INFO(CORECONFIG_DBG, "Received Message format incorrect.\n");
+ return -1;
+ }
+
+ /* Extract Response Length */
+ u16RespLen = MAKE_WORD16(resp[2], resp[3]);
+ Res_Len = u16RespLen;
+
+ for (idx = MSG_HEADER_LEN; idx < u16RespLen; ) {
+ u16WIDid = MAKE_WORD16(resp[idx], resp[idx + 1]);
+ cfg_len = resp[idx + 2];
+ /* Incase of Bin Type Wid, the length is given by two byte field */
+ enuWIDtype = get_wid_type(u16WIDid);
+ if (WID_BIN_DATA == enuWIDtype) {
+ cfg_len |= ((WILC_Uint16)resp[idx + 3] << 8) & 0xFF00;
+ idx++;
+ }
+ idx += 3;
+ if ((u16WIDid == g_wid_num) && (num_wid_processed == WILC_FALSE)) {
+ num_wid_processed = WILC_TRUE;
+
+ if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, WILC_TRUE, 0, &pstrWIDcfgResult[ResCnt])) {
+ return -2;
+ }
+ ResCnt++;
+ } else {
+ for (cnt = 0; cnt < g_num_total_switches; cnt++) {
+ if (gastrWIDs[cnt].u16WIDid == u16WIDid) {
+ if (-2 == further_process_response(&resp[idx], u16WIDid, cfg_len, WILC_FALSE, cnt,
+ &pstrWIDcfgResult[ResCnt])) {
+ return -2;
+ }
+ ResCnt++;
+ }
+ }
+ }
+ idx += cfg_len;
+ /* In case if BIN type Wid, The last byte of the Cfg packet is the */
+ /* Checksum. The WID Length field does not accounts for the checksum. */
+ /* The Checksum is discarded. */
+ if (WID_BIN_DATA == enuWIDtype) {
+ idx++;
+ }
+ }
+
+ return 0;
+}
+
+/**
+ * @brief parses the write response [just detects its status: success or failure]
+ * @details
+ * @param[in] pu8RespBuffer The Response to be parsed
+ * @return Error code indicating Write Operation status:
+ * WRITE_RESP_SUCCESS (1) => Write Success.
+ * WILC_FAIL (-100) => Write Failure.
+ * @note
+ * @author Ittiam
+ * @date 11 Aug 2009
+ * @version 1.0
+ */
+
+WILC_Sint32 ParseWriteResponse(u8 *pu8RespBuffer)
+{
+ WILC_Sint32 s32Error = WILC_FAIL;
+ WILC_Uint16 u16RespLen = 0;
+ WILC_Uint16 u16WIDtype = (WILC_Uint16)WID_NIL;
+
+ /* Check whether the received frame is a valid response */
+ if (RESP_MSG_TYPE != pu8RespBuffer[0]) {
+ PRINT_ER("Received Message format incorrect.\n");
+ return WILC_FAIL;
+ }
+
+ /* Extract Response Length */
+ u16RespLen = MAKE_WORD16(pu8RespBuffer[2], pu8RespBuffer[3]);
+
+ u16WIDtype = MAKE_WORD16(pu8RespBuffer[4], pu8RespBuffer[5]);
+
+ /* Check for WID_STATUS ID and then check the length and status value */
+ if ((u16WIDtype == WID_STATUS) &&
+ (pu8RespBuffer[6] == 1) &&
+ (pu8RespBuffer[7] == WRITE_RESP_SUCCESS)) {
+ s32Error = WRITE_RESP_SUCCESS;
+ return s32Error;
+ }
+
+ /* If the length or status are not as expected return failure */
+ s32Error = WILC_FAIL;
+ return s32Error;
+
+}
+
+/**
+ * @brief creates the header of the Configuration Packet
+ * @details
+ * @param[in,out] pcpacket The Configuration Packet
+ * @param[in,out] ps32PacketLength Length of the Configuration Packet
+ * @return Error code indicating success/failure
+ * @note
+ * @author aismail
+ * @date 18 Feb 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 CreatePacketHeader(WILC_Char *pcpacket, WILC_Sint32 *ps32PacketLength)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ WILC_Uint16 u16MsgLen = (WILC_Uint16)(*ps32PacketLength);
+ WILC_Uint16 u16MsgInd = 0;
+
+ /* The format of the message is: */
+ /* +-------------------------------------------------------------------+ */
+ /* | Message Type | Message ID | Message Length |Message body | */
+ /* +-------------------------------------------------------------------+ */
+ /* | 1 Byte | 1 Byte | 2 Bytes | Message Length - 4 | */
+ /* +-------------------------------------------------------------------+ */
+
+ /* The format of a message body of a message type 'W' is: */
+ /* +-------------------------------------------------------------------+ */
+ /* | WID0 | WID0 Length | WID0 Value | ......................... | */
+ /* +-------------------------------------------------------------------+ */
+ /* | 2 Bytes | 1 Byte | WID0 Length | ......................... | */
+ /* +-------------------------------------------------------------------+ */
+
+
+
+ /* Message Type */
+ if (g_oper_mode == SET_CFG)
+ pcpacket[u16MsgInd++] = WRITE_MSG_TYPE;
+ else
+ pcpacket[u16MsgInd++] = QUERY_MSG_TYPE;
+
+ /* Sequence Number */
+ pcpacket[u16MsgInd++] = g_seqno++;
+
+ /* Message Length */
+ pcpacket[u16MsgInd++] = (u8)(u16MsgLen & 0xFF);
+ pcpacket[u16MsgInd++] = (u8)((u16MsgLen >> 8) & 0xFF);
+
+ *ps32PacketLength = u16MsgLen;
+
+ return s32Error;
+}
+
+/**
+ * @brief creates Configuration packet based on the Input WIDs
+ * @details
+ * @param[in] pstrWIDs WIDs to be sent in the configuration packet
+ * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet
+ * @param[out] ps8packet The created Configuration Packet
+ * @param[out] ps32PacketLength Length of the created Configuration Packet
+ * @return Error code indicating success/failure
+ * @note
+ * @author
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 CreateConfigPacket(WILC_Sint8 *ps8packet, WILC_Sint32 *ps32PacketLength,
+ tstrWID *pstrWIDs, WILC_Uint32 u32WIDsCount)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ WILC_Uint32 u32idx = 0;
+ *ps32PacketLength = MSG_HEADER_LEN;
+ for (u32idx = 0; u32idx < u32WIDsCount; u32idx++) {
+ switch (pstrWIDs[u32idx].enuWIDtype) {
+ case WID_CHAR:
+ ProcessCharWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
+ pstrWIDs[u32idx].ps8WidVal);
+ break;
+
+ case WID_SHORT:
+ ProcessShortWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
+ pstrWIDs[u32idx].ps8WidVal);
+ break;
+
+ case WID_INT:
+ ProcessIntWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
+ pstrWIDs[u32idx].ps8WidVal);
+ break;
+
+ case WID_STR:
+ ProcessStrWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
+ pstrWIDs[u32idx].ps8WidVal, pstrWIDs[u32idx].s32ValueSize);
+ break;
+
+ #if 0
+ case WID_ADR:
+ ProcessAdrWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
+ pstrWIDs[u32idx].ps8WidVal);
+ break;
+
+ #endif
+ case WID_IP:
+ ProcessIPwid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
+ pstrWIDs[u32idx].ps8WidVal);
+ break;
+
+ case WID_BIN_DATA:
+ ProcessBinWid(ps8packet, ps32PacketLength, &pstrWIDs[u32idx],
+ pstrWIDs[u32idx].ps8WidVal, pstrWIDs[u32idx].s32ValueSize);
+ break;
+
+ default:
+ PRINT_ER("ERROR: Check Config database\n");
+ }
+ }
+
+ CreatePacketHeader(ps8packet, ps32PacketLength);
+
+ return s32Error;
+}
+
+WILC_Sint32 ConfigWaitResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32MaxRespBuffLen, WILC_Sint32 *ps32BytesRead,
+ WILC_Bool bRespRequired)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ /*bug 3878*/
+ /*removed to caller function*/
+ /*gstrConfigPktInfo.pcRespBuffer = pcRespBuffer;
+ * gstrConfigPktInfo.s32MaxRespBuffLen = s32MaxRespBuffLen;
+ * gstrConfigPktInfo.bRespRequired = bRespRequired;*/
+
+
+ if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) {
+ down(&SemHandlePktResp);
+
+ *ps32BytesRead = gstrConfigPktInfo.s32BytesRead;
+ }
+
+ WILC_memset((void *)(&gstrConfigPktInfo), 0, sizeof(tstrConfigPktInfo));
+
+ return s32Error;
+}
+
+/**
+ * @brief sends certain Configuration Packet based on the input WIDs pstrWIDs
+ * and retrieves the packet response pu8RxResp
+ * @details
+ * @param[in] pstrWIDs WIDs to be sent in the configuration packet
+ * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet
+ * @param[out] pu8RxResp The received Packet Response
+ * @param[out] ps32RxRespLen Length of the received Packet Response
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+#ifdef SIMULATION
+WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs,
+ WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ WILC_Sint32 err = WILC_SUCCESS;
+ WILC_Sint32 s32ConfigPacketLen = 0;
+ WILC_Sint32 s32RcvdRespLen = 0;
+
+ down(&SemHandleSendPkt);
+
+ /*set the packet mode*/
+ g_oper_mode = u8Mode;
+
+ WILC_memset((void *)gps8ConfigPacket, 0, MAX_PACKET_BUFF_SIZE);
+
+ if (CreateConfigPacket(gps8ConfigPacket, &s32ConfigPacketLen, pstrWIDs, u32WIDsCount) != WILC_SUCCESS) {
+ s32Error = WILC_FAIL;
+ goto End_ConfigPkt;
+ }
+ /*bug 3878*/
+ gstrConfigPktInfo.pcRespBuffer = gps8ConfigPacket;
+ gstrConfigPktInfo.s32MaxRespBuffLen = MAX_PACKET_BUFF_SIZE;
+ PRINT_INFO(CORECONFIG_DBG, "GLOBAL =bRespRequired =%d\n", bRespRequired);
+ gstrConfigPktInfo.bRespRequired = bRespRequired;
+
+ s32Error = SendRawPacket(gps8ConfigPacket, s32ConfigPacketLen);
+ if (s32Error != WILC_SUCCESS) {
+ goto End_ConfigPkt;
+ }
+
+ WILC_memset((void *)gps8ConfigPacket, 0, MAX_PACKET_BUFF_SIZE);
+
+ ConfigWaitResponse(gps8ConfigPacket, MAX_PACKET_BUFF_SIZE, &s32RcvdRespLen, bRespRequired);
+
+
+ if (bRespRequired == WILC_TRUE) {
+ /* If the operating Mode is GET, then we expect a response frame from */
+ /* the driver. Hence start listening to the port for response */
+ if (g_oper_mode == GET_CFG) {
+ #if 1
+ err = ParseResponse(gps8ConfigPacket, pstrWIDs);
+ if (err != 0) {
+ s32Error = WILC_FAIL;
+ goto End_ConfigPkt;
+ } else {
+ s32Error = WILC_SUCCESS;
+ }
+ #endif
+ } else {
+ err = ParseWriteResponse(gps8ConfigPacket);
+ if (err != WRITE_RESP_SUCCESS) {
+ s32Error = WILC_FAIL;
+ goto End_ConfigPkt;
+ } else {
+ s32Error = WILC_SUCCESS;
+ }
+ }
+
+
+ }
+
+
+End_ConfigPkt:
+ up(&SemHandleSendPkt);
+
+ return s32Error;
+}
+#endif
+WILC_Sint32 ConfigProvideResponse(WILC_Char *pcRespBuffer, WILC_Sint32 s32RespLen)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ if (gstrConfigPktInfo.bRespRequired == WILC_TRUE) {
+ if (s32RespLen <= gstrConfigPktInfo.s32MaxRespBuffLen) {
+ WILC_memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, s32RespLen);
+ gstrConfigPktInfo.s32BytesRead = s32RespLen;
+ } else {
+ WILC_memcpy(gstrConfigPktInfo.pcRespBuffer, pcRespBuffer, gstrConfigPktInfo.s32MaxRespBuffLen);
+ gstrConfigPktInfo.s32BytesRead = gstrConfigPktInfo.s32MaxRespBuffLen;
+ PRINT_ER("BusProvideResponse() Response greater than the prepared Buffer Size \n");
+ }
+
+ up(&SemHandlePktResp);
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief writes the received packet pu8RxPacket in the global Rx FIFO buffer
+ * @details
+ * @param[in] pu8RxPacket The received packet
+ * @param[in] s32RxPacketLen Length of the received packet
+ * @return Error code indicating success/failure
+ * @note
+ *
+ * @author mabubakr
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 ConfigPktReceived(u8 *pu8RxPacket, WILC_Sint32 s32RxPacketLen)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ u8 u8MsgType = 0;
+
+ u8MsgType = pu8RxPacket[0];
+
+ switch (u8MsgType) {
+ case 'R':
+ ConfigProvideResponse(pu8RxPacket, s32RxPacketLen);
+
+ break;
+
+ case 'N':
+ PRINT_INFO(CORECONFIG_DBG, "NetworkInfo packet received\n");
+ NetworkInfoReceived(pu8RxPacket, s32RxPacketLen);
+ break;
+
+ case 'I':
+ GnrlAsyncInfoReceived(pu8RxPacket, s32RxPacketLen);
+ break;
+
+ case 'S':
+ host_int_ScanCompleteReceived(pu8RxPacket, s32RxPacketLen);
+ break;
+
+ default:
+ PRINT_ER("ConfigPktReceived(): invalid received msg type at the Core Configurator \n");
+ break;
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Deinitializes the Core Configurator
+ * @details
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 CoreConfiguratorDeInit(void)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ PRINT_D(CORECONFIG_DBG, "CoreConfiguratorDeInit() \n");
+
+ if (gps8ConfigPacket != NULL) {
+
+ WILC_FREE(gps8ConfigPacket);
+ gps8ConfigPacket = NULL;
+ }
+
+ return s32Error;
+}
+
+
+#ifndef SIMULATION
+/*Using the global handle of the driver*/
+extern wilc_wlan_oup_t *gpstrWlanOps;
+/**
+ * @brief sends certain Configuration Packet based on the input WIDs pstrWIDs
+ * using driver config layer
+ *
+ * @details
+ * @param[in] pstrWIDs WIDs to be sent in the configuration packet
+ * @param[in] u32WIDsCount number of WIDs to be sent in the configuration packet
+ * @param[out] pu8RxResp The received Packet Response
+ * @param[out] ps32RxRespLen Length of the received Packet Response
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs,
+ WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler)
+{
+ WILC_Sint32 counter = 0, ret = 0;
+ if (gpstrWlanOps == NULL) {
+ PRINT_D(CORECONFIG_DBG, "Net Dev is still not initialized\n");
+ return 1;
+ } else {
+ PRINT_D(CORECONFIG_DBG, "Net Dev is initialized\n");
+ }
+ if (gpstrWlanOps->wlan_cfg_set == NULL ||
+ gpstrWlanOps->wlan_cfg_get == NULL) {
+ PRINT_D(CORECONFIG_DBG, "Set and Get is still not initialized\n");
+ return 1;
+ } else {
+ PRINT_D(CORECONFIG_DBG, "SET is initialized\n");
+ }
+ if (u8Mode == GET_CFG) {
+ for (counter = 0; counter < u32WIDsCount; counter++) {
+ PRINT_INFO(CORECONFIG_DBG, "Sending CFG packet [%d][%d]\n", !counter,
+ (counter == u32WIDsCount - 1));
+ if (!gpstrWlanOps->wlan_cfg_get(!counter,
+ pstrWIDs[counter].u16WIDid,
+ (counter == u32WIDsCount - 1), drvHandler)) {
+ ret = -1;
+ printk("[Sendconfigpkt]Get Timed out\n");
+ break;
+ }
+ }
+ /**
+ * get the value
+ **/
+ /* WILC_Sleep(1000); */
+ counter = 0;
+ for (counter = 0; counter < u32WIDsCount; counter++) {
+ pstrWIDs[counter].s32ValueSize = gpstrWlanOps->wlan_cfg_get_value(
+ pstrWIDs[counter].u16WIDid,
+ pstrWIDs[counter].ps8WidVal, pstrWIDs[counter].s32ValueSize);
+
+ }
+ } else if (u8Mode == SET_CFG) {
+ for (counter = 0; counter < u32WIDsCount; counter++) {
+ PRINT_D(CORECONFIG_DBG, "Sending config SET PACKET WID:%x\n", pstrWIDs[counter].u16WIDid);
+ if (!gpstrWlanOps->wlan_cfg_set(!counter,
+ pstrWIDs[counter].u16WIDid, pstrWIDs[counter].ps8WidVal,
+ pstrWIDs[counter].s32ValueSize,
+ (counter == u32WIDsCount - 1), drvHandler)) {
+ ret = -1;
+ printk("[Sendconfigpkt]Set Timed out\n");
+ break;
+ }
+ }
+ }
+
+ return ret;
+}
+#endif
diff --git a/drivers/staging/wilc1000/coreconfigurator.h b/drivers/staging/wilc1000/coreconfigurator.h
new file mode 100644
index 00000000000000..73cdbef653abd7
--- /dev/null
+++ b/drivers/staging/wilc1000/coreconfigurator.h
@@ -0,0 +1,498 @@
+
+/*!
+ * @file coreconfigurator.h
+ * @brief
+ * @author
+ * @sa coreconfigurator.c
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+
+
+#ifndef CORECONFIGURATOR_H
+#define CORECONFIGURATOR_H
+
+#include "wilc_oswrapper.h"
+#include "wilc_wlan_if.h"
+/*****************************************************************************/
+/* Constants */
+/*****************************************************************************/
+/* Number of WID Options Supported */
+#define NUM_BASIC_SWITCHES 45
+#define NUM_FHSS_SWITCHES 0
+
+#define NUM_RSSI 5
+
+#ifdef MAC_802_11N
+#define NUM_11N_BASIC_SWITCHES 25
+#define NUM_11N_HUT_SWITCHES 47
+#else /* MAC_802_11N */
+#define NUM_11N_BASIC_SWITCHES 0
+#define NUM_11N_HUT_SWITCHES 0
+#endif /* MAC_802_11N */
+
+extern WILC_Uint16 g_num_total_switches;
+
+#define MAC_HDR_LEN 24 /* No Address4 - non-ESS */
+#define MAX_SSID_LEN 33
+#define FCS_LEN 4
+#define TIME_STAMP_LEN 8
+#define BEACON_INTERVAL_LEN 2
+#define CAP_INFO_LEN 2
+#define STATUS_CODE_LEN 2
+#define AID_LEN 2
+#define IE_HDR_LEN 2
+
+
+/* Operating Mode: SET */
+#define SET_CFG 0
+/* Operating Mode: GET */
+#define GET_CFG 1
+
+#define MAX_PACKET_BUFF_SIZE 1596
+
+#define MAX_STRING_LEN 256
+#define MAX_SURVEY_RESULT_FRAG_SIZE MAX_STRING_LEN
+#define SURVEY_RESULT_LENGTH 44
+#define MAX_ASSOC_RESP_FRAME_SIZE MAX_STRING_LEN
+
+#define STATUS_MSG_LEN 12
+#define MAC_CONNECTED 1
+#define MAC_DISCONNECTED 0
+
+
+
+/*****************************************************************************/
+/* Function Macros */
+/*****************************************************************************/
+#define MAKE_WORD16(lsb, msb) ((((WILC_Uint16)(msb) << 8) & 0xFF00) | (lsb))
+#define MAKE_WORD32(lsw, msw) ((((WILC_Uint32)(msw) << 16) & 0xFFFF0000) | (lsw))
+
+
+/*****************************************************************************/
+/* Type Definitions */
+/*****************************************************************************/
+/* WID Data Types */
+#if 0
+typedef enum {
+ WID_CHAR = 0,
+ WID_SHORT = 1,
+ WID_INT = 2,
+ WID_STR = 3,
+ WID_ADR = 4,
+ WID_BIN = 5,
+ WID_IP = 6,
+ WID_UNDEF = 7,
+ WID_TYPE_FORCE_32BIT = 0xFFFFFFFF
+} tenuWIDtype;
+
+/* WLAN Identifiers */
+typedef enum {
+ WID_NIL = -1,
+ /* EMAC Character WID list */
+ WID_BSS_TYPE = 0x0000,
+ WID_CURRENT_TX_RATE = 0x0001,
+ WID_CURRENT_CHANNEL = 0x0002,
+ WID_PREAMBLE = 0x0003,
+ WID_11G_OPERATING_MODE = 0x0004,
+ WID_STATUS = 0x0005,
+ WID_11G_PROT_MECH = 0x0006,
+ WID_SCAN_TYPE = 0x0007,
+ WID_PRIVACY_INVOKED = 0x0008,
+ WID_KEY_ID = 0x0009,
+ WID_QOS_ENABLE = 0x000A,
+ WID_POWER_MANAGEMENT = 0x000B,
+ WID_11I_MODE = 0x000C,
+ WID_AUTH_TYPE = 0x000D,
+ WID_SITE_SURVEY = 0x000E,
+ WID_LISTEN_INTERVAL = 0x000F,
+ WID_DTIM_PERIOD = 0x0010,
+ WID_ACK_POLICY = 0x0011,
+ WID_RESET = 0x0012,
+ WID_PCF_MODE = 0x0013,
+ WID_CFP_PERIOD = 0x0014,
+ WID_BCAST_SSID = 0x0015,
+ WID_PHY_TEST_PATTERN = 0x0016,
+ WID_DISCONNECT = 0x0016,
+ WID_READ_ADDR_SDRAM = 0x0017,
+ WID_TX_POWER_LEVEL_11A = 0x0018,
+ WID_REKEY_POLICY = 0x0019,
+ WID_SHORT_SLOT_ALLOWED = 0x001A,
+ WID_PHY_ACTIVE_REG = 0x001B,
+ WID_PHY_ACTIVE_REG_VAL = 0x001C,
+ WID_TX_POWER_LEVEL_11B = 0x001D,
+ WID_START_SCAN_REQ = 0x001E,
+ WID_RSSI = 0x001F,
+ WID_JOIN_REQ = 0x0020,
+ WID_ANTENNA_SELECTION = 0x0021,
+ WID_USER_CONTROL_ON_TX_POWER = 0x0027,
+ WID_MEMORY_ACCESS_8BIT = 0x0029,
+ WID_UAPSD_SUPPORT_AP = 0x002A,
+ WID_CURRENT_MAC_STATUS = 0x0031,
+ WID_AUTO_RX_SENSITIVITY = 0x0032,
+ WID_DATAFLOW_CONTROL = 0x0033,
+ WID_SCAN_FILTER = 0x0036,
+ WID_LINK_LOSS_THRESHOLD = 0x0037,
+ WID_AUTORATE_TYPE = 0x0038,
+ WID_CCA_THRESHOLD = 0x0039,
+ WID_802_11H_DFS_MODE = 0x003B,
+ WID_802_11H_TPC_MODE = 0x003C,
+ WID_DEVICE_READY = 0x003D,
+ WID_PM_NULL_FRAME_INTERVAL = 0x003E,
+ WID_PM_ACTIVITY_TIMER = 0x003F,
+ WID_PM_NULL_FRAME_WAIT_ENABLE = 0x0040,
+ WID_SCAN_WAIT_TIME = 0x0041,
+ WID_WSC_IE_EN = 0x0042,
+ WID_WPS_START = 0x0043,
+ WID_WPS_DEV_MODE = 0x0044,
+ WID_BT_COEXISTENCE = 0x0050,
+ WID_TRACKING_ROAMING = 0x0070,
+ WID_NUM_PKTS_FOR_RSSI_AVG = 0x0071,
+ WID_FHSS_SCAN_CHAN_INDEX = 0x0072,
+ WID_FHSS_SCAN_STEP_INDEX = 0x0073,
+
+ /* NMAC Character WID list */
+ WID_11N_PROT_MECH = 0x0080,
+ WID_11N_ERP_PROT_TYPE = 0x0081,
+ WID_11N_ENABLE = 0x0082,
+ WID_11N_OPERATING_MODE = 0x0083,
+ WID_11N_OBSS_NONHT_DETECTION = 0x0084,
+ WID_11N_HT_PROT_TYPE = 0x0085,
+ WID_11N_RIFS_PROT_ENABLE = 0x0086,
+ WID_11N_SMPS_MODE = 0x0087,
+ WID_11N_CURRENT_TX_MCS = 0x0088,
+ WID_11N_PRINT_STATS = 0x0089,
+ WID_HUT_FCS_CORRUPT_MODE = 0x008A,
+ WID_HUT_RESTART = 0x008B,
+ WID_HUT_TX_FORMAT = 0x008C,
+ WID_11N_SHORT_GI_20MHZ_ENABLE = 0x008D,
+ WID_HUT_BANDWIDTH = 0x008E,
+ WID_HUT_OP_BAND = 0x008F,
+ WID_HUT_STBC = 0x0090,
+ WID_HUT_ESS = 0x0091,
+ WID_HUT_ANTSET = 0x0092,
+ WID_HUT_HT_OP_MODE = 0x0093,
+ WID_HUT_RIFS_MODE = 0x0094,
+ WID_HUT_SMOOTHING_REC = 0x0095,
+ WID_HUT_SOUNDING_PKT = 0x0096,
+ WID_HUT_HT_CODING = 0x0097,
+ WID_HUT_TEST_DIR = 0x0098,
+ WID_HUT_CAPTURE_MODE = 0x0099,
+ WID_HUT_PHY_TEST_MODE = 0x009A,
+ WID_HUT_PHY_TEST_RATE_HI = 0x009B,
+ WID_HUT_PHY_TEST_RATE_LO = 0x009C,
+ WID_HUT_DISABLE_RXQ_REPLENISH = 0x009D,
+ WID_HUT_KEY_ORIGIN = 0x009E,
+ WID_HUT_BCST_PERCENT = 0x009F,
+ WID_HUT_GROUP_CIPHER_TYPE = 0x00A0,
+ WID_TX_ABORT_CONFIG = 0x00A1,
+ WID_HOST_DATA_IF_TYPE = 0x00A2,
+ WID_HOST_CONFIG_IF_TYPE = 0x00A3,
+ WID_HUT_TSF_TEST_MODE = 0x00A4,
+ WID_HUT_TSSI_VALUE = 0x00A5,
+ WID_HUT_PKT_TSSI_VALUE = 0x00A5,
+ WID_REG_TSSI_11B_VALUE = 0x00A6,
+ WID_REG_TSSI_11G_VALUE = 0x00A7,
+ WID_REG_TSSI_11N_VALUE = 0x00A8,
+ WID_TX_CALIBRATION = 0x00A9,
+ WID_DSCR_TSSI_11B_VALUE = 0x00AA,
+ WID_DSCR_TSSI_11G_VALUE = 0x00AB,
+ WID_DSCR_TSSI_11N_VALUE = 0x00AC,
+ WID_HUT_RSSI_EX = 0x00AD,
+ WID_HUT_ADJ_RSSI_EX = 0x00AE,
+ WID_11N_IMMEDIATE_BA_ENABLED = 0x00AF,
+ WID_11N_TXOP_PROT_DISABLE = 0x00B0,
+ WID_TX_POWER_LEVEL_11N = 0x00B1,
+ WID_HUT_MGMT_PERCENT = 0x00B3,
+ WID_HUT_MGMT_BCST_PERCENT = 0x00B4,
+ WID_HUT_MGMT_ALLOW_HT = 0x00B5,
+ WID_HUT_UC_MGMT_TYPE = 0x00B6,
+ WID_HUT_BC_MGMT_TYPE = 0x00B7,
+ WID_HUT_11W_MFP_REQUIRED_TX = 0x00B8,
+ WID_HUT_11W_MFP_PEER_CAPABLE = 0x00B9,
+ WID_HUT_11W_TX_IGTK_ID = 0x00BA,
+ WID_11W_ENABLE = 0x00BB,
+ WID_11W_MGMT_PROT_REQ = 0x00BC,
+ WID_USER_SEC_CHANNEL_OFFSET = 0x00C0,
+ WID_2040_COEXISTENCE = 0x00C1,
+ WID_HUT_FC_TXOP_MOD = 0x00C2,
+ WID_HUT_FC_PROT_TYPE = 0x00C3,
+ WID_HUT_SEC_CCA_ASSERT = 0x00C4,
+ WID_2040_ENABLE = 0x00C5,
+ WID_2040_CURR_CHANNEL_OFFSET = 0x00C6,
+ WID_2040_40MHZ_INTOLERANT = 0x00C7,
+
+
+ /* Custom Character WID list */
+ WID_POWER_SAVE = 0x0100,
+ WID_WAKE_STATUS = 0x0101,
+ WID_WAKE_CONTROL = 0x0102,
+ WID_CCA_BUSY_START = 0x0103,
+
+ /* EMAC Short WID list */
+ WID_RTS_THRESHOLD = 0x1000,
+ WID_FRAG_THRESHOLD = 0x1001,
+ WID_SHORT_RETRY_LIMIT = 0x1002,
+ WID_LONG_RETRY_LIMIT = 0x1003,
+ WID_CFP_MAX_DUR = 0x1004,
+ WID_PHY_TEST_FRAME_LEN = 0x1005,
+ WID_BEACON_INTERVAL = 0x1006,
+ WID_MEMORY_ACCESS_16BIT = 0x1008,
+ WID_RX_SENSE = 0x100B,
+ WID_ACTIVE_SCAN_TIME = 0x100C,
+ WID_PASSIVE_SCAN_TIME = 0x100D,
+ WID_SITE_SURVEY_SCAN_TIME = 0x100E,
+ WID_JOIN_START_TIMEOUT = 0x100F,
+ WID_AUTH_TIMEOUT = 0x1010,
+ WID_ASOC_TIMEOUT = 0x1011,
+ WID_11I_PROTOCOL_TIMEOUT = 0x1012,
+ WID_EAPOL_RESPONSE_TIMEOUT = 0x1013,
+ WID_WPS_PASS_ID = 0x1017,
+ WID_WPS_CONFIG_METHOD = 0x1018,
+ WID_FHSS_INIT_SCAN_TIME = 0x1070,
+ WID_FHSS_ROAM_SCAN_TIME = 0x1071,
+
+ /* NMAC Short WID list */
+ WID_11N_RF_REG_VAL = 0x1080,
+ WID_HUT_FRAME_LEN = 0x1081,
+ WID_HUT_TXOP_LIMIT = 0x1082,
+ WID_HUT_SIG_QUAL_AVG = 0x1083,
+ WID_HUT_SIG_QUAL_AVG_CNT = 0x1084,
+ WID_11N_SIG_QUAL_VAL = 0x1085,
+ WID_HUT_RSSI_EX_COUNT = 0x1086,
+ WID_HUT_UC_MGMT_FRAME_LEN = 0x1088,
+ WID_HUT_BC_MGMT_FRAME_LEN = 0x1089,
+
+ /* Custom Short WID list */
+
+ WID_CCA_BUSY_STATUS = 0x1100,
+
+ /* EMAC Integer WID list */
+ WID_FAILED_COUNT = 0x2000,
+ WID_RETRY_COUNT = 0x2001,
+ WID_MULTIPLE_RETRY_COUNT = 0x2002,
+ WID_FRAME_DUPLICATE_COUNT = 0x2003,
+ WID_ACK_FAILURE_COUNT = 0x2004,
+ WID_RECEIVED_FRAGMENT_COUNT = 0x2005,
+ WID_MCAST_RECEIVED_FRAME_COUNT = 0x2006,
+ WID_FCS_ERROR_COUNT = 0x2007,
+ WID_SUCCESS_FRAME_COUNT = 0x2008,
+ WID_PHY_TEST_PKT_CNT = 0x2009,
+ WID_HUT_TX_COUNT = 0x200A,
+ WID_TX_FRAGMENT_COUNT = 0x200B,
+ WID_TX_MULTICAST_FRAME_COUNT = 0x200C,
+ WID_RTS_SUCCESS_COUNT = 0x200D,
+ WID_RTS_FAILURE_COUNT = 0x200E,
+ WID_WEP_UNDECRYPTABLE_COUNT = 0x200F,
+ WID_REKEY_PERIOD = 0x2010,
+ WID_REKEY_PACKET_COUNT = 0x2011,
+ WID_1X_SERV_ADDR = 0x2012,
+ WID_STACK_IP_ADDR = 0x2013,
+ WID_STACK_NETMASK_ADDR = 0x2014,
+ WID_HW_RX_COUNT = 0x2015,
+ WID_MEMORY_ADDRESS = 0x201E,
+ WID_MEMORY_ACCESS_32BIT = 0x201F,
+ WID_RF_REG_VAL = 0x2021,
+ WID_FIRMWARE_INFO = 0x2023,
+ WID_DEV_OS_VERSION = 0x2025,
+ WID_ROAM_RSSI_THESHOLDS = 0x2070,
+ WID_TRACK_INTERVAL_SEC = 0x2071,
+ WID_FHSS_HOPPING_PARAMS = 0x2072,
+ WID_FHSS_HOP_DWELL_TIME = 0x2073,
+
+ /* NMAC Integer WID list */
+ WID_11N_PHY_ACTIVE_REG_VAL = 0x2080,
+ WID_HUT_NUM_TX_PKTS = 0x2081,
+ WID_HUT_TX_TIME_TAKEN = 0x2082,
+ WID_HUT_TX_TEST_TIME = 0x2083,
+ WID_HUT_LOG_INTERVAL = 0x2084,
+
+ /* EMAC String WID list */
+ WID_SSID = 0x3000,
+ WID_FIRMWARE_VERSION = 0x3001,
+ WID_OPERATIONAL_RATE_SET = 0x3002,
+ WID_BSSID = 0x3003,
+ #if 0
+ WID_WEP_KEY_VALUE0 = 0x3004,
+ #endif
+ WID_11I_PSK = 0x3008,
+ WID_11E_P_ACTION_REQ = 0x3009,
+ WID_1X_KEY = 0x300A,
+ WID_HARDWARE_VERSION = 0x300B,
+ WID_MAC_ADDR = 0x300C,
+ WID_HUT_DEST_ADDR = 0x300D,
+ /*WID_HUT_STATS = 0x300E,*/
+ WID_PHY_VERSION = 0x300F,
+ WID_SUPP_USERNAME = 0x3010,
+ WID_SUPP_PASSWORD = 0x3011,
+ WID_SITE_SURVEY_RESULTS = 0x3012,
+ WID_RX_POWER_LEVEL = 0x3013,
+ WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */
+ WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */
+ WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */
+ WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */
+
+ WID_ASSOC_RES_INFO = 0x3020,
+
+ /* NMAC String WID list */
+ WID_11N_P_ACTION_REQ = 0x3080,
+ WID_HUT_TEST_ID = 0x3081,
+ WID_PMKID_INFO = 0x3082,
+
+ /* Custom String WID list */
+ WID_FLASH_DATA = 0x3100,
+ WID_EEPROM_DATA = 0x3101,
+ WID_SERIAL_NUMBER = 0x3102,
+
+ /* EMAC Binary WID list */
+ WID_UAPSD_CONFIG = 0x4001,
+ WID_UAPSD_STATUS = 0x4002,
+ WID_AC_PARAMS_AP = 0x4003,
+ WID_AC_PARAMS_STA = 0x4004,
+ WID_NEWORK_INFO = 0x4005,
+ WID_WPS_CRED_LIST = 0x4006,
+ WID_PRIM_DEV_TYPE = 0x4007,
+ WID_STA_JOIN_INFO = 0x4008,
+ WID_CONNECTED_STA_LIST = 0x4009,
+
+ /* NMAC Binary WID list */
+ WID_11N_AUTORATE_TABLE = 0x4080,
+ WID_HUT_TX_PATTERN = 0x4081,
+ WID_HUT_STATS = 0x4082,
+ WID_HUT_LOG_STATS = 0x4083,
+
+ /*BugID_3746 WID to add IE to be added in next probe request*/
+ WID_INFO_ELEMENT_PROBE = 0x4085,
+ /*BugID_3746 WID to add IE to be added in next associate request*/
+ WID_INFO_ELEMENT_ASSOCIATE = 0x4086,
+
+ /* Miscellaneous WIDs */
+ WID_ALL = 0x7FFE,
+ WID_MAX = 0xFFFF
+} tenuWIDid;
+#endif
+
+/* Status Codes for Authentication and Association Frames */
+typedef enum {
+ SUCCESSFUL_STATUSCODE = 0,
+ UNSPEC_FAIL = 1,
+ UNSUP_CAP = 10,
+ REASOC_NO_ASOC = 11,
+ FAIL_OTHER = 12,
+ UNSUPT_ALG = 13,
+ AUTH_SEQ_FAIL = 14,
+ CHLNG_FAIL = 15,
+ AUTH_TIMEOUT = 16,
+ AP_FULL = 17,
+ UNSUP_RATE = 18,
+ SHORT_PREAMBLE_UNSUP = 19,
+ PBCC_UNSUP = 20,
+ CHANNEL_AGIL_UNSUP = 21,
+ SHORT_SLOT_UNSUP = 25,
+ OFDM_DSSS_UNSUP = 26,
+ CONNECT_STS_FORCE_16_BIT = 0xFFFF
+} tenuConnectSts;
+
+typedef struct {
+ WILC_Uint16 u16WIDid;
+ tenuWIDtype enuWIDtype;
+ WILC_Sint32 s32ValueSize;
+ WILC_Sint8 *ps8WidVal;
+
+} tstrWID;
+
+typedef struct {
+ u8 u8Full;
+ u8 u8Index;
+ WILC_Sint8 as8RSSI[NUM_RSSI];
+} tstrRSSI;
+/* This structure is used to support parsing of the received 'N' message */
+typedef struct {
+ WILC_Sint8 s8rssi;
+ WILC_Uint16 u16CapInfo;
+ u8 au8ssid[MAX_SSID_LEN];
+ u8 u8SsidLen;
+ u8 au8bssid[6];
+ WILC_Uint16 u16BeaconPeriod;
+ u8 u8DtimPeriod;
+ u8 u8channel;
+ unsigned long u32TimeRcvdInScanCached; /* of type unsigned long to be accepted by the linux kernel macro time_after() */
+ unsigned long u32TimeRcvdInScan;
+ WILC_Bool bNewNetwork;
+#ifdef AGING_ALG
+ u8 u8Found;
+#endif
+#ifdef WILC_P2P
+ WILC_Uint32 u32Tsf; /* time-stamp [Low only 32 bit] */
+#endif
+ u8 *pu8IEs;
+ WILC_Uint16 u16IEsLen;
+ void *pJoinParams;
+ tstrRSSI strRssi;
+ WILC_Uint64 u64Tsf; /* time-stamp [Low and High 64 bit] */
+} tstrNetworkInfo;
+
+/* This structure is used to support parsing of the received Association Response frame */
+typedef struct {
+ WILC_Uint16 u16capability;
+ WILC_Uint16 u16ConnectStatus;
+ WILC_Uint16 u16AssocID;
+ u8 *pu8RespIEs;
+ WILC_Uint16 u16RespIEsLen;
+} tstrConnectRespInfo;
+
+
+typedef struct {
+ u8 au8bssid[6];
+ u8 *pu8ReqIEs;
+ size_t ReqIEsLen;
+ u8 *pu8RespIEs;
+ WILC_Uint16 u16RespIEsLen;
+ WILC_Uint16 u16ConnectStatus;
+} tstrConnectInfo;
+
+
+
+typedef struct {
+ WILC_Uint16 u16reason;
+ u8 *ie;
+ size_t ie_len;
+} tstrDisconnectNotifInfo;
+
+#ifndef CONNECT_DIRECT
+typedef struct wid_site_survey_reslts {
+ WILC_Char SSID[MAX_SSID_LEN];
+ u8 BssType;
+ u8 Channel;
+ u8 SecurityStatus;
+ u8 BSSID[6];
+ WILC_Char RxPower;
+ u8 Reserved;
+
+} wid_site_survey_reslts_s;
+#endif
+
+extern WILC_Sint32 CoreConfiguratorInit(void);
+extern WILC_Sint32 CoreConfiguratorDeInit(void);
+
+extern WILC_Sint32 SendConfigPkt(u8 u8Mode, tstrWID *pstrWIDs,
+ WILC_Uint32 u32WIDsCount, WILC_Bool bRespRequired, WILC_Uint32 drvHandler);
+extern WILC_Sint32 ParseNetworkInfo(u8 *pu8MsgBuffer, tstrNetworkInfo **ppstrNetworkInfo);
+extern WILC_Sint32 DeallocateNetworkInfo(tstrNetworkInfo *pstrNetworkInfo);
+
+extern WILC_Sint32 ParseAssocRespInfo(u8 *pu8Buffer, WILC_Uint32 u32BufferLen,
+ tstrConnectRespInfo **ppstrConnectRespInfo);
+extern WILC_Sint32 DeallocateAssocRespInfo(tstrConnectRespInfo *pstrConnectRespInfo);
+
+#ifndef CONNECT_DIRECT
+extern WILC_Sint32 ParseSurveyResults(u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
+ wid_site_survey_reslts_s **ppstrSurveyResults, WILC_Uint32 *pu32SurveyResultsCount);
+extern WILC_Sint32 DeallocateSurveyResults(wid_site_survey_reslts_s *pstrSurveyResults);
+#endif
+
+extern WILC_Sint32 SendRawPacket(WILC_Sint8 *pspacket, WILC_Sint32 s32PacketLen);
+extern void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length);
+void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length);
+void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length);
+
+#endif
diff --git a/drivers/staging/wilc1000/fifo_buffer.c b/drivers/staging/wilc1000/fifo_buffer.c
new file mode 100644
index 00000000000000..f807bfb7253991
--- /dev/null
+++ b/drivers/staging/wilc1000/fifo_buffer.c
@@ -0,0 +1,134 @@
+
+
+#include "wilc_oswrapper.h"
+#include "fifo_buffer.h"
+
+
+
+WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer, WILC_Uint32 u32BufferLength)
+{
+ WILC_Uint32 u32Error = 0;
+ tstrFifoHandler *pstrFifoHandler = WILC_MALLOC (sizeof (tstrFifoHandler));
+ if (pstrFifoHandler) {
+ WILC_memset (pstrFifoHandler, 0, sizeof (tstrFifoHandler));
+ pstrFifoHandler->pu8Buffer = WILC_MALLOC (u32BufferLength);
+ if (pstrFifoHandler->pu8Buffer) {
+ pstrFifoHandler->u32BufferLength = u32BufferLength;
+ WILC_memset (pstrFifoHandler->pu8Buffer, 0, u32BufferLength);
+ /* create semaphore */
+ sema_init(&pstrFifoHandler->SemBuffer, 1);
+ *hBuffer = pstrFifoHandler;
+ } else {
+ *hBuffer = NULL;
+ u32Error = 1;
+ }
+ } else {
+ u32Error = 1;
+ }
+ return u32Error;
+}
+WILC_Uint32 FIFO_DeInit(tHANDLE hFifo)
+{
+ WILC_Uint32 u32Error = 0;
+ tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo;
+ if (pstrFifoHandler) {
+ if (pstrFifoHandler->pu8Buffer) {
+ WILC_FREE (pstrFifoHandler->pu8Buffer);
+ } else {
+ u32Error = 1;
+ }
+
+ WILC_FREE (pstrFifoHandler);
+ } else {
+ u32Error = 1;
+ }
+ return u32Error;
+}
+
+WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead)
+{
+ WILC_Uint32 u32Error = 0;
+ tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo;
+ if (pstrFifoHandler && pu32BytesRead) {
+ if (pstrFifoHandler->u32TotalBytes) {
+ down(&pstrFifoHandler->SemBuffer);
+
+ if (u32BytesToRead > pstrFifoHandler->u32TotalBytes) {
+ *pu32BytesRead = pstrFifoHandler->u32TotalBytes;
+ } else {
+ *pu32BytesRead = u32BytesToRead;
+ }
+ if ((pstrFifoHandler->u32ReadOffset + u32BytesToRead) <= pstrFifoHandler->u32BufferLength) {
+ WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset,
+ *pu32BytesRead);
+ /* update read offset and total bytes */
+ pstrFifoHandler->u32ReadOffset += u32BytesToRead;
+ pstrFifoHandler->u32TotalBytes -= u32BytesToRead;
+
+ } else {
+ WILC_Uint32 u32FirstPart =
+ pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32ReadOffset;
+ WILC_memcpy(pu8Buffer, pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32ReadOffset,
+ u32FirstPart);
+ WILC_memcpy(pu8Buffer + u32FirstPart, pstrFifoHandler->pu8Buffer,
+ u32BytesToRead - u32FirstPart);
+ /* update read offset and total bytes */
+ pstrFifoHandler->u32ReadOffset = u32BytesToRead - u32FirstPart;
+ pstrFifoHandler->u32TotalBytes -= u32BytesToRead;
+ }
+ up(&pstrFifoHandler->SemBuffer);
+ } else {
+ u32Error = 1;
+ }
+ } else {
+ u32Error = 1;
+ }
+ return u32Error;
+}
+
+WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer, WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite)
+{
+ WILC_Uint32 u32Error = 0;
+ tstrFifoHandler *pstrFifoHandler = (tstrFifoHandler *) hFifo;
+ if (pstrFifoHandler) {
+ if (u32BytesToWrite < pstrFifoHandler->u32BufferLength) {
+ if ((pstrFifoHandler->u32TotalBytes + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength ||
+ bForceOverWrite) {
+ down(&pstrFifoHandler->SemBuffer);
+ if ((pstrFifoHandler->u32WriteOffset + u32BytesToWrite) <= pstrFifoHandler->u32BufferLength) {
+ WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer,
+ u32BytesToWrite);
+ /* update read offset and total bytes */
+ pstrFifoHandler->u32WriteOffset += u32BytesToWrite;
+ pstrFifoHandler->u32TotalBytes += u32BytesToWrite;
+
+ } else {
+ WILC_Uint32 u32FirstPart =
+ pstrFifoHandler->u32BufferLength - pstrFifoHandler->u32WriteOffset;
+ WILC_memcpy(pstrFifoHandler->pu8Buffer + pstrFifoHandler->u32WriteOffset, pu8Buffer,
+ u32FirstPart);
+ WILC_memcpy(pstrFifoHandler->pu8Buffer, pu8Buffer + u32FirstPart,
+ u32BytesToWrite - u32FirstPart);
+ /* update read offset and total bytes */
+ pstrFifoHandler->u32WriteOffset = u32BytesToWrite - u32FirstPart;
+ pstrFifoHandler->u32TotalBytes += u32BytesToWrite;
+ }
+ /* if data overwriten */
+ if (pstrFifoHandler->u32TotalBytes > pstrFifoHandler->u32BufferLength) {
+ /* adjust read offset to the oldest data available */
+ pstrFifoHandler->u32ReadOffset = pstrFifoHandler->u32WriteOffset;
+ /* data availabe is the buffer length */
+ pstrFifoHandler->u32TotalBytes = pstrFifoHandler->u32BufferLength;
+ }
+ up(&pstrFifoHandler->SemBuffer);
+ } else {
+ u32Error = 1;
+ }
+ } else {
+ u32Error = 1;
+ }
+ } else {
+ u32Error = 1;
+ }
+ return u32Error;
+}
diff --git a/drivers/staging/wilc1000/fifo_buffer.h b/drivers/staging/wilc1000/fifo_buffer.h
new file mode 100644
index 00000000000000..4d120503c4b2e2
--- /dev/null
+++ b/drivers/staging/wilc1000/fifo_buffer.h
@@ -0,0 +1,23 @@
+
+#include "wilc_oswrapper.h"
+
+
+#define tHANDLE void *
+
+typedef struct {
+ u8 *pu8Buffer;
+ WILC_Uint32 u32BufferLength;
+ WILC_Uint32 u32WriteOffset;
+ WILC_Uint32 u32ReadOffset;
+ WILC_Uint32 u32TotalBytes;
+ struct semaphore SemBuffer;
+} tstrFifoHandler;
+
+
+extern WILC_Uint32 FIFO_InitBuffer(tHANDLE *hBuffer,
+ WILC_Uint32 u32BufferLength);
+extern WILC_Uint32 FIFO_DeInit(tHANDLE hFifo);
+extern WILC_Uint32 FIFO_ReadBytes(tHANDLE hFifo, u8 *pu8Buffer,
+ WILC_Uint32 u32BytesToRead, WILC_Uint32 *pu32BytesRead);
+extern WILC_Uint32 FIFO_WriteBytes(tHANDLE hFifo, u8 *pu8Buffer,
+ WILC_Uint32 u32BytesToWrite, WILC_Bool bForceOverWrite);
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
new file mode 100644
index 00000000000000..afe5126f3655aa
--- /dev/null
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -0,0 +1,8043 @@
+#include "host_interface.h"
+#include "wilc_oswrapper.h"
+#include "itypes.h"
+#include "coreconfigurator.h"
+
+extern WILC_Sint32 TransportInit(void);
+extern WILC_Sint32 TransportDeInit(void);
+extern u8 connecting;
+
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+extern WILC_TimerHandle hDuringIpTimer;
+#endif
+
+extern WILC_Bool bEnablePS;
+/*BugID_5137*/
+extern u8 g_wilc_initialized;
+/*****************************************************************************/
+/* Macros */
+/*****************************************************************************/
+
+/* Message types of the Host IF Message Queue*/
+#define HOST_IF_MSG_SCAN ((WILC_Uint16)0)
+#define HOST_IF_MSG_CONNECT ((WILC_Uint16)1)
+#define HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO ((WILC_Uint16)2)
+#define HOST_IF_MSG_KEY ((WILC_Uint16)3)
+#define HOST_IF_MSG_RCVD_NTWRK_INFO ((WILC_Uint16)4)
+#define HOST_IF_MSG_RCVD_SCAN_COMPLETE ((WILC_Uint16)5)
+#define HOST_IF_MSG_CFG_PARAMS ((WILC_Uint16)6)
+#define HOST_IF_MSG_SET_CHANNEL ((WILC_Uint16)7)
+#define HOST_IF_MSG_DISCONNECT ((WILC_Uint16)8)
+#define HOST_IF_MSG_GET_RSSI ((WILC_Uint16)9)
+#define HOST_IF_MSG_GET_CHNL ((WILC_Uint16)10)
+#define HOST_IF_MSG_ADD_BEACON ((WILC_Uint16)11)
+#define HOST_IF_MSG_DEL_BEACON ((WILC_Uint16)12)
+#define HOST_IF_MSG_ADD_STATION ((WILC_Uint16)13)
+#define HOST_IF_MSG_DEL_STATION ((WILC_Uint16)14)
+#define HOST_IF_MSG_EDIT_STATION ((WILC_Uint16)15)
+#define HOST_IF_MSG_SCAN_TIMER_FIRED ((WILC_Uint16)16)
+#define HOST_IF_MSG_CONNECT_TIMER_FIRED ((WILC_Uint16)17)
+#define HOST_IF_MSG_POWER_MGMT ((WILC_Uint16)18)
+#define HOST_IF_MSG_GET_INACTIVETIME ((WILC_Uint16)19)
+#define HOST_IF_MSG_REMAIN_ON_CHAN ((WILC_Uint16)20)
+#define HOST_IF_MSG_REGISTER_FRAME ((WILC_Uint16)21)
+#define HOST_IF_MSG_LISTEN_TIMER_FIRED ((WILC_Uint16)22)
+#define HOST_IF_MSG_GET_LINKSPEED ((WILC_Uint16)23)
+#define HOST_IF_MSG_SET_WFIDRV_HANDLER ((WILC_Uint16)24)
+#define HOST_IF_MSG_SET_MAC_ADDRESS ((WILC_Uint16)25)
+#define HOST_IF_MSG_GET_MAC_ADDRESS ((WILC_Uint16)26)
+#define HOST_IF_MSG_SET_OPERATION_MODE ((WILC_Uint16)27)
+#define HOST_IF_MSG_SET_IPADDRESS ((WILC_Uint16)28)
+#define HOST_IF_MSG_GET_IPADDRESS ((WILC_Uint16)29)
+#define HOST_IF_MSG_FLUSH_CONNECT ((WILC_Uint16)30)
+#define HOST_IF_MSG_GET_STATISTICS ((WILC_Uint16)31)
+#define HOST_IF_MSG_SET_MULTICAST_FILTER ((WILC_Uint16)32)
+#define HOST_IF_MSG_ADD_BA_SESSION ((WILC_Uint16)33)
+#define HOST_IF_MSG_DEL_BA_SESSION ((WILC_Uint16)34)
+#define HOST_IF_MSG_Q_IDLE ((WILC_Uint16)35)
+#define HOST_IF_MSG_DEL_ALL_STA ((WILC_Uint16)36)
+#define HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS ((WILC_Uint16)34)
+
+#define HOST_IF_MSG_EXIT ((WILC_Uint16)100)
+
+#define HOST_IF_SCAN_TIMEOUT 4000
+#define HOST_IF_CONNECT_TIMEOUT 9500
+
+#define BA_SESSION_DEFAULT_BUFFER_SIZE 16
+#define BA_SESSION_DEFAULT_TIMEOUT 1000
+#define BLOCK_ACK_REQ_SIZE 0x14
+/*****************************************************************************/
+/* Type Definitions */
+/*****************************************************************************/
+
+/*!
+ * @struct tstrHostIFCfgParamAttr
+ * @brief Structure to hold Host IF CFG Params Attributes
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 02 April 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFCfgParamAttr {
+ tstrCfgParamVal pstrCfgParamVal;
+
+} tstrHostIFCfgParamAttr;
+
+/*!
+ * @struct tstrHostIFwpaAttr
+ * @brief Structure to hold Host IF Scan Attributes
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFwpaAttr {
+ u8 *pu8key;
+ const u8 *pu8macaddr;
+ u8 *pu8seq;
+ u8 u8seqlen;
+ u8 u8keyidx;
+ u8 u8Keylen;
+ u8 u8Ciphermode;
+} tstrHostIFwpaAttr;
+
+
+/*!
+ * @struct tstrHostIFwepAttr
+ * @brief Structure to hold Host IF Scan Attributes
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFwepAttr {
+ u8 *pu8WepKey;
+ u8 u8WepKeylen;
+ u8 u8Wepidx;
+ u8 u8mode;
+ AUTHTYPE_T tenuAuth_type;
+
+} tstrHostIFwepAttr;
+
+/*!
+ * @struct tuniHostIFkeyAttr
+ * @brief Structure to hold Host IF Scan Attributes
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef union _tuniHostIFkeyAttr {
+ tstrHostIFwepAttr strHostIFwepAttr;
+ tstrHostIFwpaAttr strHostIFwpaAttr;
+ tstrHostIFpmkidAttr strHostIFpmkidAttr;
+} tuniHostIFkeyAttr;
+
+/*!
+ * @struct tstrHostIFkeyAttr
+ * @brief Structure to hold Host IF Scan Attributes
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFkeyAttr {
+ tenuKeyType enuKeyType;
+ u8 u8KeyAction;
+ tuniHostIFkeyAttr uniHostIFkeyAttr;
+} tstrHostIFkeyAttr;
+
+
+
+
+/*!
+ * @struct tstrHostIFscanAttr
+ * @brief Structure to hold Host IF Scan Attributes
+ * @details
+ * @todo
+ * @sa
+ * @author Mostafa Abu Bakr
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFscanAttr {
+ u8 u8ScanSource;
+ u8 u8ScanType;
+ u8 *pu8ChnlFreqList;
+ u8 u8ChnlListLen;
+ u8 *pu8IEs;
+ size_t IEsLen;
+ tWILCpfScanResult pfScanResult;
+ void *pvUserArg;
+ /*BugID_4189*/
+ tstrHiddenNetwork strHiddenNetwork;
+
+} tstrHostIFscanAttr;
+
+/*!
+ * @struct tstrHostIFconnectAttr
+ * @brief Structure to hold Host IF Connect Attributes
+ * @details
+ * @todo
+ * @sa
+ * @author Mostafa Abu Bakr
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFconnectAttr {
+ u8 *pu8bssid;
+ u8 *pu8ssid;
+ size_t ssidLen;
+ u8 *pu8IEs;
+ size_t IEsLen;
+ u8 u8security;
+ tWILCpfConnectResult pfConnectResult;
+ void *pvUserArg;
+ AUTHTYPE_T tenuAuth_type;
+ u8 u8channel;
+ void *pJoinParams;
+} tstrHostIFconnectAttr;
+
+/*!
+ * @struct tstrRcvdGnrlAsyncInfo
+ * @brief Structure to hold Received General Asynchronous info
+ * @details
+ * @todo
+ * @sa
+ * @author Mostafa Abu Bakr
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrRcvdGnrlAsyncInfo {
+ u8 *pu8Buffer;
+ WILC_Uint32 u32Length;
+} tstrRcvdGnrlAsyncInfo;
+
+/*!
+ * @struct tstrHostIFSetChan
+ * @brief Set Channel message body
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFSetChan {
+ u8 u8SetChan;
+} tstrHostIFSetChan;
+
+/*!
+ * @struct tstrHostIFSetChan
+ * @brief Get Channel message body
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 01 Jule 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFGetChan {
+ u8 u8GetChan;
+} tstrHostIFGetChan;
+
+/*bug3819: Add Scan acomplete notification to host*/
+/*!
+ * @struct tstrScanComplete
+ * @brief hold received Async. Scan Complete message body
+ * @details
+ * @todo
+ * @sa
+ * @author zsalah
+ * @date 25 March 2012
+ * @version 1.0
+ */
+/*typedef struct _tstrScanComplete
+ * {
+ * u8* pu8Buffer;
+ * WILC_Uint32 u32Length;
+ * } tstrScanComplete;*/
+
+/*!
+ * @struct tstrHostIFSetBeacon
+ * @brief Set Beacon message body
+ * @details
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 10 July 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFSetBeacon {
+ WILC_Uint32 u32Interval; /*!< Beacon Interval. Period between two successive beacons on air */
+ WILC_Uint32 u32DTIMPeriod; /*!< DTIM Period. Indicates how many Beacon frames
+ * (including the current frame) appear before the next DTIM */
+ WILC_Uint32 u32HeadLen; /*!< Length of the head buffer in bytes */
+ u8 *pu8Head; /*!< Pointer to the beacon's head buffer. Beacon's head is the part
+ * from the beacon's start till the TIM element, NOT including the TIM */
+ WILC_Uint32 u32TailLen; /*!< Length of the tail buffer in bytes */
+ u8 *pu8Tail; /*!< Pointer to the beacon's tail buffer. Beacon's tail starts just
+ * after the TIM inormation element */
+} tstrHostIFSetBeacon;
+
+
+
+/*!
+ * @struct tstrHostIFDelBeacon
+ * @brief Del Beacon message body
+ * @details
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 15 July 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFDelBeacon {
+ u8 u8dummy;
+} tstrHostIFDelBeacon;
+
+/*!
+ * @struct tstrHostIFSetMulti
+ * @brief set Multicast filter Address
+ * @details
+ * @todo
+ * @sa
+ * @author Abdelrahman Sobhy
+ * @date 30 August 2013
+ * @version 1.0 Description
+ */
+
+typedef struct {
+ WILC_Bool bIsEnabled;
+ WILC_Uint32 u32count;
+} tstrHostIFSetMulti;
+
+/*!
+ * @struct tstrHostIFDelAllSta
+ * @brief Deauth station message body
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 09 April 2014
+ * @version 1.0 Description
+ */
+
+typedef struct {
+ u8 au8Sta_DelAllSta[MAX_NUM_STA][ETH_ALEN];
+ u8 u8Num_AssocSta;
+} tstrHostIFDelAllSta;
+
+/*!
+ * @struct tstrHostIFDelSta
+ * @brief Delete station message body
+ * @details
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 15 July 2012
+ * @version 1.0 Description
+ */
+
+typedef struct {
+ u8 au8MacAddr[ETH_ALEN];
+} tstrHostIFDelSta;
+
+/*!
+ * @struct tstrTimerCb
+ * @brief Timer callback message body
+ * @details
+ * @todo
+ * @sa
+ * @author Mostafa Abu Bakr
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrTimerCb {
+ void *pvUsrArg; /*!< Private data passed at timer start */
+} tstrTimerCb;
+
+/*!
+ * @struct tstrHostIfPowerMgmtParam
+ * @brief Power management message body
+ * @details
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 24 November 2012
+ * @version 1.0
+ */
+typedef struct {
+
+ WILC_Bool bIsEnabled;
+ WILC_Uint32 u32Timeout;
+} tstrHostIfPowerMgmtParam;
+
+/*!
+ * @struct tstrHostIFSetIPAddr
+ * @brief set IP Address message body
+ * @details
+ * @todo
+ * @sa
+ * @author Abdelrahman Sobhy
+ * @date 30 August 2013
+ * @version 1.0 Description
+ */
+
+typedef struct {
+ u8 *au8IPAddr;
+ u8 idx;
+} tstrHostIFSetIPAddr;
+
+/*!
+ * @struct tstrHostIfStaInactiveT
+ * @brief Get station message body
+ * @details
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 16 April 2013
+ * @version 1.0
+ */
+typedef struct {
+ u8 mac[6];
+
+} tstrHostIfStaInactiveT;
+/**/
+/*!
+ * @union tuniHostIFmsgBody
+ * @brief Message body for the Host Interface message_q
+ * @details
+ * @todo
+ * @sa
+ * @author Mostafa Abu Bakr
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef union _tuniHostIFmsgBody {
+ tstrHostIFscanAttr strHostIFscanAttr; /*!< Host IF Scan Request Attributes message body */
+ tstrHostIFconnectAttr strHostIFconnectAttr; /*!< Host IF Connect Request Attributes message body */
+ tstrRcvdNetworkInfo strRcvdNetworkInfo; /*!< Received Asynchronous Network Info message body */
+ tstrRcvdGnrlAsyncInfo strRcvdGnrlAsyncInfo; /*!< Received General Asynchronous Info message body */
+ tstrHostIFkeyAttr strHostIFkeyAttr; /*!<>*/
+ tstrHostIFCfgParamAttr strHostIFCfgParamAttr; /*! <CFG Parameter message Body> */
+ tstrHostIFSetChan strHostIFSetChan;
+ tstrHostIFGetChan strHostIFGetChan;
+ tstrHostIFSetBeacon strHostIFSetBeacon; /*!< Set beacon message body */
+ tstrHostIFDelBeacon strHostIFDelBeacon; /*!< Del beacon message body */
+ tstrWILC_AddStaParam strAddStaParam; /*!< Add station message body */
+ tstrHostIFDelSta strDelStaParam; /*!< Del Station message body */
+ tstrWILC_AddStaParam strEditStaParam; /*!< Edit station message body */
+ /* tstrScanComplete strScanComplete; / *Received Async. Scan Complete message body* / */
+ tstrTimerCb strTimerCb; /*!< Timer callback message body */
+ tstrHostIfPowerMgmtParam strPowerMgmtparam; /*!< Power Management message body */
+ tstrHostIfStaInactiveT strHostIfStaInactiveT;
+ tstrHostIFSetIPAddr strHostIfSetIP;
+ tstrHostIfSetDrvHandler strHostIfSetDrvHandler;
+ tstrHostIFSetMulti strHostIfSetMulti;
+ tstrHostIfSetOperationMode strHostIfSetOperationMode;
+ tstrHostIfSetMacAddress strHostIfSetMacAddress;
+ tstrHostIfGetMacAddress strHostIfGetMacAddress;
+ tstrHostIfBASessionInfo strHostIfBASessionInfo;
+ #ifdef WILC_P2P
+ tstrHostIfRemainOnChan strHostIfRemainOnChan;
+ tstrHostIfRegisterFrame strHostIfRegisterFrame;
+ #endif
+ WILC_Char *pUserData;
+ tstrHostIFDelAllSta strHostIFDelAllSta;
+} tuniHostIFmsgBody;
+
+/*!
+ * @struct tstrHostIFmsg
+ * @brief Host Interface message
+ * @details
+ * @todo
+ * @sa
+ * @author Mostafa Abu Bakr
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrHostIFmsg {
+ WILC_Uint16 u16MsgId; /*!< Message ID */
+ tuniHostIFmsgBody uniHostIFmsgBody; /*!< Message body */
+ void *drvHandler;
+} tstrHostIFmsg;
+
+#ifdef CONNECT_DIRECT
+typedef struct _tstrWidJoinReqExt {
+ WILC_Char SSID[MAX_SSID_LEN];
+ u8 u8channel;
+ u8 BSSID[6];
+} tstrWidJoinReqExt;
+#endif
+
+/*Bug4218: Parsing Join Param*/
+#ifdef WILC_PARSE_SCAN_IN_HOST
+/*Struct containg joinParam of each AP*/
+typedef struct _tstrJoinBssParam {
+ BSSTYPE_T bss_type;
+ u8 dtim_period;
+ WILC_Uint16 beacon_period;
+ WILC_Uint16 cap_info;
+ u8 au8bssid[6];
+ WILC_Char ssid[MAX_SSID_LEN];
+ u8 ssidLen;
+ u8 supp_rates[MAX_RATES_SUPPORTED + 1];
+ u8 ht_capable;
+ u8 wmm_cap;
+ u8 uapsd_cap;
+ WILC_Bool rsn_found;
+ u8 rsn_grp_policy;
+ u8 mode_802_11i;
+ u8 rsn_pcip_policy[3];
+ u8 rsn_auth_policy[3];
+ u8 rsn_cap[2];
+ struct _tstrJoinParam *nextJoinBss;
+ #ifdef WILC_P2P
+ WILC_Uint32 tsf;
+ u8 u8NoaEnbaled;
+ u8 u8OppEnable;
+ u8 u8CtWindow;
+ u8 u8Count;
+ u8 u8Index;
+ u8 au8Duration[4];
+ u8 au8Interval[4];
+ u8 au8StartTime[4];
+ #endif
+} tstrJoinBssParam;
+/*Bug4218: Parsing Join Param*/
+/*a linked list table containing needed join parameters entries for each AP found in most recent scan*/
+typedef struct _tstrBssTable {
+ u8 u8noBssEntries;
+ tstrJoinBssParam *head;
+ tstrJoinBssParam *tail;
+} tstrBssTable;
+#endif /*WILC_PARSE_SCAN_IN_HOST*/
+
+typedef enum {
+ SCAN_TIMER = 0,
+ CONNECT_TIMER = 1,
+ SCAN_CONNECT_TIMER_FORCE_32BIT = 0xFFFFFFFF
+} tenuScanConnTimer;
+
+/*****************************************************************************/
+/* */
+/* Global Variabls */
+/* */
+/*****************************************************************************/
+
+
+tstrWILC_WFIDrv *terminated_handle = NULL;
+tstrWILC_WFIDrv *gWFiDrvHandle = NULL;
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+WILC_Bool g_obtainingIP = WILC_FALSE;
+#endif
+u8 P2P_LISTEN_STATE;
+static struct task_struct *HostIFthreadHandler;
+static WILC_MsgQueueHandle gMsgQHostIF;
+static struct semaphore hSemHostIFthrdEnd;
+
+struct semaphore hSemDeinitDrvHandle;
+static struct semaphore hWaitResponse;
+struct semaphore hSemHostIntDeinit;
+WILC_TimerHandle g_hPeriodicRSSI;
+
+
+
+u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
+
+#ifndef CONNECT_DIRECT
+static u8 gapu8RcvdSurveyResults[2][MAX_SURVEY_RESULT_FRAG_SIZE];
+#endif
+
+static u8 gapu8RcvdAssocResp[MAX_ASSOC_RESP_FRAME_SIZE];
+
+WILC_Bool gbScanWhileConnected = WILC_FALSE;
+
+static WILC_Sint8 gs8Rssi;
+static WILC_Sint8 gs8lnkspd;
+static u8 gu8Chnl;
+static u8 gs8SetIP[2][4];
+static u8 gs8GetIP[2][4];
+#ifdef WILC_AP_EXTERNAL_MLME
+static WILC_Uint32 gu32InactiveTime;
+static u8 gu8DelBcn;
+#endif
+#ifndef SIMULATION
+static WILC_Uint32 gu32WidConnRstHack;
+#endif
+
+/*BugID_5137*/
+u8 *gu8FlushedJoinReq;
+u8 *gu8FlushedInfoElemAsoc;
+u8 gu8Flushed11iMode;
+u8 gu8FlushedAuthType;
+WILC_Uint32 gu32FlushedJoinReqSize;
+WILC_Uint32 gu32FlushedInfoElemAsocSize;
+WILC_Uint32 gu8FlushedJoinReqDrvHandler;
+#define REAL_JOIN_REQ 0
+#define FLUSHED_JOIN_REQ 1
+#define FLUSHED_BYTE_POS 79 /* Position the byte indicating flushing in the flushed request */
+
+/*Bug4218: Parsing Join Param*/
+#ifdef WILC_PARSE_SCAN_IN_HOST
+/*Bug4218: Parsing Join Param*/
+static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo);
+#endif /*WILC_PARSE_SCAN_IN_HOST*/
+
+extern void chip_sleep_manually(WILC_Uint32 u32SleepTime);
+extern int linux_wlan_get_num_conn_ifcs(void);
+
+/**
+ * @brief Handle_SetChannel
+ * @details Sending config packet to firmware to set channel
+ * @param[in] tstrHostIFSetChan* pstrHostIFSetChan
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_SetChannel(void *drvHandler, tstrHostIFSetChan *pstrHostIFSetChan)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_CURRENT_CHANNEL;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Char *)&(pstrHostIFSetChan->u8SetChan);
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ PRINT_D(HOSTINF_DBG, "Setting channel\n");
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to set channel\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+/**
+ * @brief Handle_SetWfiDrvHandler
+ * @details Sending config packet to firmware to set driver handler
+ * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_SetWfiDrvHandler(tstrHostIfSetDrvHandler *pstrHostIfSetDrvHandler)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)((pstrHostIfSetDrvHandler->u32Address));
+
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_SET_DRV_HANDLER;
+ strWID.enuWIDtype = WID_INT;
+ strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetDrvHandler->u32Address);
+ strWID.s32ValueSize = sizeof(WILC_Uint32);
+
+ /*Sending Cfg*/
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+
+ if ((pstrHostIfSetDrvHandler->u32Address) == (WILC_Uint32)NULL) {
+ up(&hSemDeinitDrvHandle);
+ }
+
+
+ if (s32Error) {
+ PRINT_ER("Failed to set driver handler\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Handle_SetWfiAPDrvHandler
+ * @details Sending config packet to firmware to set driver handler
+ * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_SetOperationMode(void *drvHandler, tstrHostIfSetOperationMode *pstrHostIfSetOperationMode)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_SET_OPERATION_MODE;
+ strWID.enuWIDtype = WID_INT;
+ strWID.ps8WidVal = (WILC_Sint8 *)&(pstrHostIfSetOperationMode->u32Mode);
+ strWID.s32ValueSize = sizeof(WILC_Uint32);
+
+ /*Sending Cfg*/
+ PRINT_INFO(HOSTINF_DBG, "(WILC_Uint32)pstrWFIDrv= %x \n", (WILC_Uint32)pstrWFIDrv);
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+
+ if ((pstrHostIfSetOperationMode->u32Mode) == (WILC_Uint32)NULL) {
+ up(&hSemDeinitDrvHandle);
+ }
+
+
+ if (s32Error) {
+ PRINT_ER("Failed to set driver handler\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief host_int_set_IPAddress
+ * @details Setting IP address params in message queue
+ * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 Handle_set_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ char firmwareIPAddress[4] = {0};
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ if (pu8IPAddr[0] < 192)
+ pu8IPAddr[0] = 0;
+
+ PRINT_INFO(HOSTINF_DBG, "Indx = %d, Handling set IP = %d.%d.%d.%d \n", idx, pu8IPAddr[0], pu8IPAddr[1], pu8IPAddr[2], pu8IPAddr[3]);
+
+ WILC_memcpy(gs8SetIP[idx], pu8IPAddr, IP_ALEN);
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_IP_ADDRESS;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (u8 *)pu8IPAddr;
+ strWID.s32ValueSize = IP_ALEN;
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+
+
+ host_int_get_ipaddress((WILC_WFIDrvHandle)drvHandler, firmwareIPAddress, idx);
+
+ if (s32Error) {
+ PRINT_D(HOSTINF_DBG, "Failed to set IP address\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ } else {
+ PRINT_INFO(HOSTINF_DBG, "IP address set\n");
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+
+/**
+ * @brief Handle_get_IPAddress
+ * @details Setting IP address params in message queue
+ * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8IPAddr
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 Handle_get_IPAddress(void *drvHandler, u8 *pu8IPAddr, u8 idx)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_IP_ADDRESS;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (u8 *)WILC_MALLOC(IP_ALEN);
+ strWID.s32ValueSize = IP_ALEN;
+
+ s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+ PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", (u8)(strWID.ps8WidVal[0]), (u8)(strWID.ps8WidVal[1]), (u8)(strWID.ps8WidVal[2]), (u8)(strWID.ps8WidVal[3]));
+
+ WILC_memcpy(gs8GetIP[idx], strWID.ps8WidVal, IP_ALEN);
+
+ /*get the value by searching the local copy*/
+ WILC_FREE(strWID.ps8WidVal);
+
+ if (WILC_memcmp(gs8GetIP[idx], gs8SetIP[idx], IP_ALEN) != 0)
+ host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, gs8SetIP[idx], idx);
+
+ if (s32Error != WILC_SUCCESS) {
+ PRINT_ER("Failed to get IP address\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ } else {
+ PRINT_INFO(HOSTINF_DBG, "IP address retrieved:: u8IfIdx = %d \n", idx);
+ PRINT_INFO(HOSTINF_DBG, "%d.%d.%d.%d\n", gs8GetIP[idx][0], gs8GetIP[idx][1], gs8GetIP[idx][2], gs8GetIP[idx][3]);
+ PRINT_INFO(HOSTINF_DBG, "\n");
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+
+/*BugId_5077*/
+/**
+ * @brief Handle_SetMacAddress
+ * @details Setting mac address
+ * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
+ * @return Error code.
+ * @author Amr Abdel-Moghny
+ * @date November 2013
+ * @version 7.0
+ */
+static WILC_Sint32 Handle_SetMacAddress(void *drvHandler, tstrHostIfSetMacAddress *pstrHostIfSetMacAddress)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ u8 *mac_buf = (u8 *)WILC_MALLOC(ETH_ALEN);
+ if (mac_buf == NULL) {
+ PRINT_ER("No buffer to send mac address\n");
+ return WILC_FAIL;
+ }
+ WILC_memcpy(mac_buf, pstrHostIfSetMacAddress->u8MacAddress, ETH_ALEN);
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_MAC_ADDR;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = mac_buf;
+ strWID.s32ValueSize = ETH_ALEN;
+ PRINT_D(GENERIC_DBG, "mac addr = :%x:%x:%x:%x:%x:%x\n", strWID.ps8WidVal[0], strWID.ps8WidVal[1], strWID.ps8WidVal[2], strWID.ps8WidVal[3], strWID.ps8WidVal[4], strWID.ps8WidVal[5]);
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to set mac address\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ WILC_FREE(mac_buf);
+ return s32Error;
+}
+
+
+/*BugID_5213*/
+/**
+ * @brief Handle_GetMacAddress
+ * @details Getting mac address
+ * @param[in] void * drvHandler,tstrHostIfSetDrvHandler* pstrHostIfSetDrvHandler
+ * @return Error code.
+ * @author Amr Abdel-Moghny
+ * @date JAN 2013
+ * @version 8.0
+ */
+static WILC_Sint32 Handle_GetMacAddress(void *drvHandler, tstrHostIfGetMacAddress *pstrHostIfGetMacAddress)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_MAC_ADDR;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = pstrHostIfGetMacAddress->u8MacAddress;
+ strWID.s32ValueSize = ETH_ALEN;
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)drvHandler);
+ if (s32Error) {
+ PRINT_ER("Failed to get mac address\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ up(&hWaitResponse);
+
+ return s32Error;
+}
+
+
+/**
+ * @brief Handle_CfgParam
+ * @details Sending config packet to firmware to set CFG params
+ * @param[in] tstrHostIFCfgParamAttr* strHostIFCfgParamAttr
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_CfgParam(void *drvHandler, tstrHostIFCfgParamAttr *strHostIFCfgParamAttr)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWIDList[32];
+ u8 u8WidCnt = 0;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+ down(&(pstrWFIDrv->gtOsCfgValuesSem));
+
+
+ PRINT_D(HOSTINF_DBG, "Setting CFG params\n");
+
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BSS_TYPE) {
+ /*----------------------------------------------------------*/
+ /*Input Value: INFRASTRUCTURE = 1, */
+ /* INDEPENDENT= 2, */
+ /* ANY_BSS= 3 */
+ /*----------------------------------------------------------*/
+ /* validate input then copy>> need to check value 4 and 5 */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.bss_type < 6) {
+ strWIDList[u8WidCnt].u16WIDid = WID_BSS_TYPE;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
+ strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char);
+ pstrWFIDrv->strCfgValues.bss_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.bss_type;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTH_TYPE) {
+ /*------------------------------------------------------*/
+ /*Input Values: OPEN_SYSTEM = 0, */
+ /* SHARED_KEY = 1, */
+ /* ANY = 2 */
+ /*------------------------------------------------------*/
+ /*validate Possible values*/
+ if ((strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 1 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 2 || (strHostIFCfgParamAttr->pstrCfgParamVal.auth_type) == 5) {
+ strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TYPE;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
+ strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char);
+ pstrWFIDrv->strCfgValues.auth_type = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.auth_type;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & AUTHEN_TIMEOUT) {
+ /* range is 1 to 65535. */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout < 65536) {
+ strWIDList[u8WidCnt].u16WIDid = WID_AUTH_TIMEOUT;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.auth_timeout = strHostIFCfgParamAttr->pstrCfgParamVal.auth_timeout;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & POWER_MANAGEMENT) {
+ /*-----------------------------------------------------------*/
+ /*Input Values: NO_POWERSAVE = 0, */
+ /* MIN_FAST_PS = 1, */
+ /* MAX_FAST_PS = 2, */
+ /* MIN_PSPOLL_PS = 3, */
+ /* MAX_PSPOLL_PS = 4 */
+ /*----------------------------------------------------------*/
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode < 5) {
+ strWIDList[u8WidCnt].u16WIDid = WID_POWER_MANAGEMENT;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
+ strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char);
+ pstrWFIDrv->strCfgValues.power_mgmt_mode = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.power_mgmt_mode;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_SHORT) {
+ /* range from 1 to 256 */
+ if ((strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit < 256)) {
+ strWIDList[u8WidCnt].u16WIDid = WID_SHORT_RETRY_LIMIT;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.short_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.short_retry_limit;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RETRY_LONG) {
+ /* range from 1 to 256 */
+ if ((strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit > 0) && (strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit < 256)) {
+ strWIDList[u8WidCnt].u16WIDid = WID_LONG_RETRY_LIMIT;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
+
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.long_retry_limit = strHostIFCfgParamAttr->pstrCfgParamVal.long_retry_limit;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & FRAG_THRESHOLD) {
+
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold < 7937) {
+ strWIDList[u8WidCnt].u16WIDid = WID_FRAG_THRESHOLD;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.frag_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.frag_threshold;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & RTS_THRESHOLD) {
+ /* range 256 to 65535 */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold > 255 && strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold < 65536) {
+ strWIDList[u8WidCnt].u16WIDid = WID_RTS_THRESHOLD;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.rts_threshold = strHostIFCfgParamAttr->pstrCfgParamVal.rts_threshold;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PREAMBLE) {
+ /*-----------------------------------------------------*/
+ /*Input Values: Short= 0, */
+ /* Long= 1, */
+ /* Auto= 2 */
+ /*------------------------------------------------------*/
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type < 3) {
+ strWIDList[u8WidCnt].u16WIDid = WID_PREAMBLE;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
+ strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char);
+ pstrWFIDrv->strCfgValues.preamble_type = strHostIFCfgParamAttr->pstrCfgParamVal.preamble_type;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SHORT_SLOT_ALLOWED) {
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed < 2) {
+ strWIDList[u8WidCnt].u16WIDid = WID_SHORT_SLOT_ALLOWED;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
+ strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char);
+ pstrWFIDrv->strCfgValues.short_slot_allowed = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.short_slot_allowed;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & TXOP_PROT_DISABLE) {
+ /*Description: used to Disable RTS-CTS protection for TXOP burst*/
+ /*transmission when the acknowledgement policy is No-Ack or Block-Ack */
+ /* this information is useful for external supplicant */
+ /*Input Values: 1 for enable and 0 for disable. */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled < 2) {
+ strWIDList[u8WidCnt].u16WIDid = WID_11N_TXOP_PROT_DISABLE;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
+ strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char);
+ pstrWFIDrv->strCfgValues.txop_prot_disabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.txop_prot_disabled;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & BEACON_INTERVAL) {
+ /* range is 1 to 65535. */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval < 65536) {
+ strWIDList[u8WidCnt].u16WIDid = WID_BEACON_INTERVAL;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.beacon_interval = strHostIFCfgParamAttr->pstrCfgParamVal.beacon_interval;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & DTIM_PERIOD) {
+ /* range is 1 to 255. */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period < 256) {
+ strWIDList[u8WidCnt].u16WIDid = WID_DTIM_PERIOD;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
+ strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char);
+ pstrWFIDrv->strCfgValues.dtim_period = strHostIFCfgParamAttr->pstrCfgParamVal.dtim_period;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY) {
+ /*----------------------------------------------------------------------*/
+ /*Input Values: SITE_SURVEY_1CH = 0, i.e.: currently set channel */
+ /* SITE_SURVEY_ALL_CH = 1, */
+ /* SITE_SURVEY_OFF = 2 */
+ /*----------------------------------------------------------------------*/
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled < 3) {
+ strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
+ strWIDList[u8WidCnt].enuWIDtype = WID_CHAR;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Char);
+ pstrWFIDrv->strCfgValues.site_survey_enabled = (u8)strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_enabled;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & SITE_SURVEY_SCAN_TIME) {
+ /* range is 1 to 65535. */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time < 65536) {
+ strWIDList[u8WidCnt].u16WIDid = WID_SITE_SURVEY_SCAN_TIME;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.site_survey_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.site_survey_scan_time;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & ACTIVE_SCANTIME) {
+ /* range is 1 to 65535. */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time < 65536) {
+ strWIDList[u8WidCnt].u16WIDid = WID_ACTIVE_SCAN_TIME;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.active_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.active_scan_time;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & PASSIVE_SCANTIME) {
+ /* range is 1 to 65535. */
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time > 0 && strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time < 65536) {
+ strWIDList[u8WidCnt].u16WIDid = WID_PASSIVE_SCAN_TIME;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.passive_scan_time = strHostIFCfgParamAttr->pstrCfgParamVal.passive_scan_time;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ if (strHostIFCfgParamAttr->pstrCfgParamVal.u32SetCfgFlag & CURRENT_TX_RATE) {
+ CURRENT_TX_RATE_T curr_tx_rate = strHostIFCfgParamAttr->pstrCfgParamVal.curr_tx_rate;
+ /*----------------------------------------------------------------------*/
+ /*Rates: 1 2 5.5 11 6 9 12 18 24 36 48 54 Auto */
+ /*InputValues: 1 2 3 4 5 6 7 8 9 10 11 12 0 */
+ /*----------------------------------------------------------------------*/
+ /* validate rate */
+ if (curr_tx_rate == AUTORATE || curr_tx_rate == MBPS_1
+ || curr_tx_rate == MBPS_2 || curr_tx_rate == MBPS_5_5
+ || curr_tx_rate == MBPS_11 || curr_tx_rate == MBPS_6
+ || curr_tx_rate == MBPS_9 || curr_tx_rate == MBPS_12
+ || curr_tx_rate == MBPS_18 || curr_tx_rate == MBPS_24
+ || curr_tx_rate == MBPS_36 || curr_tx_rate == MBPS_48 || curr_tx_rate == MBPS_54) {
+ strWIDList[u8WidCnt].u16WIDid = WID_CURRENT_TX_RATE;
+ strWIDList[u8WidCnt].ps8WidVal = (WILC_Sint8 *)&curr_tx_rate;
+ strWIDList[u8WidCnt].enuWIDtype = WID_SHORT;
+ strWIDList[u8WidCnt].s32ValueSize = sizeof(WILC_Uint16);
+ pstrWFIDrv->strCfgValues.curr_tx_rate = (u8)curr_tx_rate;
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ u8WidCnt++;
+ }
+ s32Error = SendConfigPkt(SET_CFG, strWIDList, u8WidCnt, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+
+ if (s32Error) {
+ PRINT_ER("Error in setting CFG params\n");
+
+ }
+ WILC_CATCH(s32Error)
+ {
+ }
+ up(&(pstrWFIDrv->gtOsCfgValuesSem));
+ return s32Error;
+}
+
+
+/**
+ * @brief Handle_wait_msg_q_empty
+ * @details this should be the last msg and then the msg Q becomes idle
+ * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_wait_msg_q_empty(void)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ g_wilc_initialized = 0;
+ up(&hWaitResponse);
+ return s32Error;
+}
+
+/**
+ * @brief Handle_Scan
+ * @details Sending config packet to firmware to set the scan params
+ * @param[in] tstrHostIFscanAttr* pstrHostIFscanAttr
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_Scan(void *drvHandler, tstrHostIFscanAttr *pstrHostIFscanAttr)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWIDList[5];
+ WILC_Uint32 u32WidsCount = 0;
+ WILC_Uint32 i;
+ u8 *pu8Buffer;
+ u8 valuesize = 0;
+ u8 *pu8HdnNtwrksWidVal = NULL;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
+
+ PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
+ PRINT_D(HOSTINF_DBG, "Scanning: In [%d] state \n", pstrWFIDrv->enuHostIFstate);
+
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = pstrHostIFscanAttr->pfScanResult;
+ pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid = pstrHostIFscanAttr->pvUserArg;
+
+ #ifdef WILC_P2P
+ #if 0
+ if (pstrWFIDrv->enuHostIFstate == HOST_IF_P2P_LISTEN || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED && pstrWFIDrv->u8P2PConnect)) {
+ PRINT_INFO(GENERIC_DBG, "Busy: State: %d\n", pstrWFIDrv->enuHostIFstate);
+ PRINT_INFO(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
+ WILC_ERRORREPORT(s32Error, WILC_BUSY);
+ }
+ #endif
+ #endif
+
+ if ((pstrWFIDrv->enuHostIFstate >= HOST_IF_SCANNING) && (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTED)) {
+ /* here we either in HOST_IF_SCANNING, HOST_IF_WAITING_CONN_REQ or HOST_IF_WAITING_CONN_RESP */
+ PRINT_D(GENERIC_DBG, "Don't scan we are already in [%d] state\n", pstrWFIDrv->enuHostIFstate);
+ WILC_ERRORREPORT(s32Error, WILC_BUSY);
+ }
+
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ if (g_obtainingIP || connecting) {
+ PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
+ WILC_ERRORREPORT(s32Error, WILC_BUSY);
+ }
+ #endif
+
+ PRINT_D(HOSTINF_DBG, "Setting SCAN params\n");
+
+
+ pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount = 0;
+
+ /*BugID_4189*/
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_SSID_PROBE_REQ;
+ strWIDList[u32WidsCount].enuWIDtype = WID_STR;
+
+ for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
+ valuesize += ((pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen) + 1);
+ }
+ pu8HdnNtwrksWidVal = WILC_MALLOC(valuesize + 1);
+ strWIDList[u32WidsCount].ps8WidVal = pu8HdnNtwrksWidVal;
+ if (strWIDList[u32WidsCount].ps8WidVal != NULL) {
+ pu8Buffer = strWIDList[u32WidsCount].ps8WidVal;
+
+ *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum;
+
+ PRINT_D(HOSTINF_DBG, "In Handle_ProbeRequest number of ssid %d\n", pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum);
+
+ for (i = 0; i < pstrHostIFscanAttr->strHiddenNetwork.u8ssidnum; i++) {
+ *pu8Buffer++ = pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
+ WILC_memcpy(pu8Buffer, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen);
+ pu8Buffer += pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen;
+ }
+
+
+
+ strWIDList[u32WidsCount].s32ValueSize = (WILC_Sint32)(valuesize + 1);
+ u32WidsCount++;
+ }
+
+ /*filling cfg param array*/
+
+ /* if((pstrHostIFscanAttr->pu8IEs != NULL) && (pstrHostIFscanAttr->IEsLen != 0)) */
+ {
+ /* IEs to be inserted in Probe Request */
+ strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_PROBE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
+ strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8IEs;
+ strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->IEsLen;
+ u32WidsCount++;
+ }
+
+ /*Scan Type*/
+ strWIDList[u32WidsCount].u16WIDid = WID_SCAN_TYPE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFscanAttr->u8ScanType));
+ u32WidsCount++;
+
+ /*list of channels to be scanned*/
+ strWIDList[u32WidsCount].u16WIDid = WID_SCAN_CHANNEL_LIST;
+ strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
+
+ /* Bug 4648: Convert channel numbers to start from 0 not 1. */
+ if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL && pstrHostIFscanAttr->u8ChnlListLen > 0) {
+ int i;
+
+ for (i = 0; i < pstrHostIFscanAttr->u8ChnlListLen; i++) {
+ if (pstrHostIFscanAttr->pu8ChnlFreqList[i] > 0) {
+ pstrHostIFscanAttr->pu8ChnlFreqList[i] = pstrHostIFscanAttr->pu8ChnlFreqList[i] - 1;
+ }
+ }
+ }
+
+ strWIDList[u32WidsCount].ps8WidVal = pstrHostIFscanAttr->pu8ChnlFreqList;
+ strWIDList[u32WidsCount].s32ValueSize = pstrHostIFscanAttr->u8ChnlListLen;
+ u32WidsCount++;
+
+ /*Scan Request*/
+ strWIDList[u32WidsCount].u16WIDid = WID_START_SCAN_REQ;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFscanAttr->u8ScanSource));
+ u32WidsCount++;
+
+ /*keep the state as is , no need to change it*/
+ /* gWFiDrvHandle->enuHostIFstate = HOST_IF_SCANNING; */
+
+ if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
+ gbScanWhileConnected = WILC_TRUE;
+ } else if (pstrWFIDrv->enuHostIFstate == HOST_IF_IDLE) {
+ gbScanWhileConnected = WILC_FALSE;
+ }
+
+ s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+
+ if (s32Error) {
+ PRINT_ER("Failed to send scan paramters config packet\n");
+ WILC_ERRORREPORT(s32Error, s32Error);
+ } else {
+ PRINT_D(HOSTINF_DBG, "Successfully sent SCAN params config packet\n");
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
+ /*if there is an ongoing scan request*/
+ Handle_ScanDone(drvHandler, SCAN_EVENT_ABORTED);
+ }
+
+ /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
+ if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
+ WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList);
+ pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
+ }
+
+ /* Deallocate pstrHostIFscanAttr->pu8IEs which was previously allocated by the sending thread */
+ if (pstrHostIFscanAttr->pu8IEs != NULL) {
+ WILC_FREE(pstrHostIFscanAttr->pu8IEs);
+ pstrHostIFscanAttr->pu8IEs = NULL;
+ }
+ if (pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo != NULL) {
+ WILC_FREE(pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo);
+ pstrHostIFscanAttr->strHiddenNetwork.pstrHiddenNetworkInfo = NULL;
+ }
+
+ /* Deallocate pstrHostIFscanAttr->u8ChnlListLen which was prevoisuly allocated by the sending thread */
+ if (pstrHostIFscanAttr->pu8ChnlFreqList != NULL) {
+ WILC_FREE(pstrHostIFscanAttr->pu8ChnlFreqList);
+ pstrHostIFscanAttr->pu8ChnlFreqList = NULL;
+ }
+
+ if (pu8HdnNtwrksWidVal != NULL) {
+ WILC_FREE(pu8HdnNtwrksWidVal);
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Handle_ScanDone
+ * @details Call scan notification callback function
+ * @param[in] NONE
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+ u8 u8abort_running_scan;
+ tstrWID strWID;
+
+
+ PRINT_D(HOSTINF_DBG, "in Handle_ScanDone()\n");
+
+ /*BugID_4978*/
+ /*Ask FW to abort the running scan, if any*/
+ if (enuEvent == SCAN_EVENT_ABORTED) {
+ PRINT_D(GENERIC_DBG, "Abort running scan\n");
+ u8abort_running_scan = 1;
+ strWID.u16WIDid = (WILC_Uint16)WID_ABORT_RUNNING_SCAN;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Sint8 *)&u8abort_running_scan;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error != WILC_SUCCESS) {
+ PRINT_ER("Failed to set abort running scan\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+ WILC_CATCH(s32Error)
+ {
+ }
+ }
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver handler is NULL\n");
+ return s32Error;
+ }
+
+ /*if there is an ongoing scan request*/
+ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(enuEvent, NULL,
+ pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
+ /*delete current scan request*/
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Handle_Connect
+ * @details Sending config packet to firmware to starting connection
+ * @param[in] tstrHostIFconnectAttr* pstrHostIFconnectAttr
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+u8 u8ConnectedSSID[6] = {0};
+static WILC_Sint32 Handle_Connect(void *drvHandler, tstrHostIFconnectAttr *pstrHostIFconnectAttr)
+{
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWIDList[8];
+ WILC_Uint32 u32WidsCount = 0, dummyval = 0;
+ /* char passphrase[] = "12345678"; */
+ #ifndef CONNECT_DIRECT
+ WILC_Sint32 s32Err = WILC_SUCCESS;
+ WILC_Uint32 i;
+ u8 u8bssDscListIndex;
+ wid_site_survey_reslts_s *pstrSurveyResults = NULL;
+ #else
+ u8 *pu8CurrByte = NULL;
+ /*Bug4218: Parsing Join Param*/
+ #ifdef WILC_PARSE_SCAN_IN_HOST
+ tstrJoinBssParam *ptstrJoinBssParam;
+ #endif /*WILC_PARSE_SCAN_IN_HOST*/
+
+ #endif
+
+ PRINT_D(GENERIC_DBG, "Handling connect request\n");
+
+ #ifndef CONNECT_DIRECT
+ WILC_memset(gapu8RcvdSurveyResults[0], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
+ WILC_memset(gapu8RcvdSurveyResults[1], 0, MAX_SURVEY_RESULT_FRAG_SIZE);
+
+
+ PRINT_D(HOSTINF_DBG, "Getting site survey results\n");
+ s32Err = host_int_get_site_survey_results((WILC_WFIDrvHandle)pstrWFIDrv,
+ gapu8RcvdSurveyResults,
+ MAX_SURVEY_RESULT_FRAG_SIZE);
+ if (s32Err) {
+ PRINT_ER("Failed to get site survey results\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+
+ }
+ s32Err = ParseSurveyResults(gapu8RcvdSurveyResults, &pstrSurveyResults,
+ &pstrWFIDrv->u32SurveyResultsCount);
+
+
+ if (s32Err == WILC_SUCCESS) {
+ /* use the parsed info in pstrSurveyResults, then deallocate it */
+ PRINT_D(HOSTINF_DBG, "Copying site survey results in global structure, then deallocate\n");
+ for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
+ WILC_memcpy(&pstrWFIDrv->astrSurveyResults[i], &pstrSurveyResults[i],
+ sizeof(wid_site_survey_reslts_s));
+ }
+
+ DeallocateSurveyResults(pstrSurveyResults);
+ } else {
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ PRINT_ER("ParseSurveyResults() Error(%d) \n", s32Err);
+ }
+
+
+ for (i = 0; i < pstrWFIDrv->u32SurveyResultsCount; i++) {
+ if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].SSID,
+ pstrHostIFconnectAttr->pu8ssid,
+ pstrHostIFconnectAttr->ssidLen) == 0) {
+ PRINT_INFO(HOSTINF_DBG, "Network with required SSID is found %s\n", pstrHostIFconnectAttr->pu8ssid);
+ if (pstrHostIFconnectAttr->pu8bssid == NULL) {
+ /* BSSID is not passed from the user, so decision of matching
+ * is done by SSID only */
+ PRINT_INFO(HOSTINF_DBG, "BSSID is not passed from the user\n");
+ break;
+ } else {
+ /* BSSID is also passed from the user, so decision of matching
+ * should consider also this passed BSSID */
+
+ if (WILC_memcmp(pstrWFIDrv->astrSurveyResults[i].BSSID,
+ pstrHostIFconnectAttr->pu8bssid,
+ 6) == 0) {
+ PRINT_INFO(HOSTINF_DBG, "BSSID is passed from the user and matched\n");
+ break;
+ }
+ }
+ }
+ }
+
+ if (i < pstrWFIDrv->u32SurveyResultsCount) {
+ u8bssDscListIndex = i;
+
+ PRINT_INFO(HOSTINF_DBG, "Connecting to network of Bss Idx %d and SSID %s and channel %d \n",
+ u8bssDscListIndex, pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].SSID,
+ pstrWFIDrv->astrSurveyResults[u8bssDscListIndex].Channel);
+
+ PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
+
+ if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+ pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6);
+ WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
+ if (pstrHostIFconnectAttr->pu8ssid != NULL) {
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
+ WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
+ pstrHostIFconnectAttr->ssidLen);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
+ if (pstrHostIFconnectAttr->pu8IEs != NULL) {
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
+ WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
+ pstrHostIFconnectAttr->IEsLen);
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
+ pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
+ pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
+ pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
+
+
+ /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
+ /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
+ {
+ /* IEs to be inserted in Association Request */
+ strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
+ strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
+ strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
+ u32WidsCount++;
+ }
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
+ u32WidsCount++;
+
+ PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
+
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
+ u32WidsCount++;
+
+ PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
+ /*
+ * strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_PSK;
+ * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
+ * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
+ * strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8*)(passphrase);
+ * u32WidsCount++;
+ */
+
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)&u8bssDscListIndex;
+ u32WidsCount++;
+
+ #ifndef SIMULATION
+ /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
+ * firmware at chip reset when processing the WIDs of the Connect Request.
+ * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
+ /* ////////////////////// */
+ gu32WidConnRstHack = 0;
+ /* ////////////////////// */
+ #endif
+
+ s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Handle_Connect()] failed to send config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ } else {
+ pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
+ }
+
+ } else {
+ PRINT_ER("Required BSSID not found\n");
+ WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
+ }
+
+ #else
+
+ /* if we try to connect to an already connected AP then discard the request */
+
+ if (WILC_memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
+
+ s32Error = WILC_SUCCESS;
+ PRINT_ER("Trying to connect to an already connected AP, Discard connect request\n");
+ return s32Error;
+ }
+
+ PRINT_INFO(HOSTINF_DBG, "Saving connection parameters in global structure\n");
+
+ /*Bug4218: Parsing Join Param*/
+ #ifdef WILC_PARSE_SCAN_IN_HOST
+ ptstrJoinBssParam = (tstrJoinBssParam *)pstrHostIFconnectAttr->pJoinParams;
+ if (ptstrJoinBssParam == NULL) {
+ PRINT_ER("Required BSSID not found\n");
+ WILC_ERRORREPORT(s32Error, WILC_NOT_FOUND);
+ }
+ #endif /*WILC_PARSE_SCAN_IN_HOST*/
+
+#if 0
+ /* if we try to connect to an already connected AP then discard the request */
+ PRINT_D(GENERIC_DBG, "Bssid = %x:%x:%x:%x:%x:%x\n", (pstrHostIFconnectAttr->pu8bssid[0]), (pstrHostIFconnectAttr->pu8bssid[1]), (pstrHostIFconnectAttr->pu8bssid[2]), (pstrHostIFconnectAttr->pu8bssid[3]), (pstrHostIFconnectAttr->pu8bssid[4]), (pstrHostIFconnectAttr->pu8bssid[5]));
+ PRINT_D(GENERIC_DBG, "bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5]));
+ if (WILC_memcmp(pstrHostIFconnectAttr->pu8bssid, u8ConnectedSSID, ETH_ALEN) == 0) {
+ PRINT_ER("Discard connect request\n");
+ s32Error = WILC_FAIL;
+ return s32Error;
+ }
+#endif
+
+ if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+ pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = (u8 *)WILC_MALLOC(6);
+ WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.ssidLen = pstrHostIFconnectAttr->ssidLen;
+ if (pstrHostIFconnectAttr->pu8ssid != NULL) {
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->ssidLen + 1);
+ WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->pu8ssid,
+ pstrHostIFconnectAttr->ssidLen);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid[pstrHostIFconnectAttr->ssidLen] = '\0';
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = pstrHostIFconnectAttr->IEsLen;
+ if (pstrHostIFconnectAttr->pu8IEs != NULL) {
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
+ WILC_memcpy(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs, pstrHostIFconnectAttr->pu8IEs,
+ pstrHostIFconnectAttr->IEsLen);
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.u8security = pstrHostIFconnectAttr->u8security;
+ pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type = pstrHostIFconnectAttr->tenuAuth_type;
+ pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult = pstrHostIFconnectAttr->pfConnectResult;
+ pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid = pstrHostIFconnectAttr->pvUserArg;
+
+ strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
+ strWIDList[u32WidsCount].enuWIDtype = WID_INT;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval));
+ u32WidsCount++;
+
+ strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
+ strWIDList[u32WidsCount].enuWIDtype = WID_INT;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval));
+ u32WidsCount++;
+
+ strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
+ strWIDList[u32WidsCount].enuWIDtype = WID_INT;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(dummyval));
+ u32WidsCount++;
+
+ /* if((gWFiDrvHandle->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) && */
+ /* (gWFiDrvHandle->strWILC_UsrConnReq.ConnReqIEsLen != 0)) */
+ {
+ /* IEs to be inserted in Association Request */
+ strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
+ strWIDList[u32WidsCount].ps8WidVal = pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs;
+ strWIDList[u32WidsCount].s32ValueSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
+ u32WidsCount++;
+
+ /*BugID_5137*/
+ if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
+
+ gu32FlushedInfoElemAsocSize = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
+ gu8FlushedInfoElemAsoc = WILC_MALLOC(gu32FlushedInfoElemAsocSize);
+ memcpy(gu8FlushedInfoElemAsoc, pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
+ gu32FlushedInfoElemAsocSize);
+ }
+ }
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrWFIDrv->strWILC_UsrConnReq.u8security));
+ u32WidsCount++;
+
+ /*BugID_5137*/
+ if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
+ gu8Flushed11iMode = pstrWFIDrv->strWILC_UsrConnReq.u8security;
+
+ PRINT_INFO(HOSTINF_DBG, "Encrypt Mode = %x\n", pstrWFIDrv->strWILC_UsrConnReq.u8security);
+
+
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
+ u32WidsCount++;
+
+ /*BugID_5137*/
+ if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7))
+ gu8FlushedAuthType = (u8)pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type;
+
+ PRINT_INFO(HOSTINF_DBG, "Authentication Type = %x\n", pstrWFIDrv->strWILC_UsrConnReq.tenuAuth_type);
+ /*
+ * strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_PSK;
+ * strWIDList[u32WidsCount].enuWIDtype = WID_STR;
+ * strWIDList[u32WidsCount].s32ValueSize = sizeof(passphrase);
+ * strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8*)(passphrase);
+ * u32WidsCount++;
+ */
+
+ PRINT_D(HOSTINF_DBG, "Connecting to network of SSID %s on channel %d\n",
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid, pstrHostIFconnectAttr->u8channel);
+
+
+#ifndef WILC_PARSE_SCAN_IN_HOST
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED;
+ strWIDList[u32WidsCount].enuWIDtype = WID_STR;
+ strWIDList[u32WidsCount].s32ValueSize = MAX_SSID_LEN + 7;
+ strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
+
+ if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
+
+ if (pstrHostIFconnectAttr->pu8ssid != NULL) {
+ WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
+ pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
+ }
+ pu8CurrByte += MAX_SSID_LEN;
+ if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
+ *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
+ } else {
+ PRINT_ER("Channel out of range\n");
+ *(pu8CurrByte++) = 0xFF;
+ }
+ if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+ WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
+ }
+ pu8CurrByte += 6;
+
+ /* keep the buffer at the start of the allocated pointer to use it with the free*/
+ pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
+
+ #else
+
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED;
+ strWIDList[u32WidsCount].enuWIDtype = WID_STR;
+
+ /*Sending NoA attributes during connection*/
+ strWIDList[u32WidsCount].s32ValueSize = 112; /* 79; */
+ strWIDList[u32WidsCount].ps8WidVal = WILC_MALLOC(strWIDList[u32WidsCount].s32ValueSize);
+
+ /*BugID_5137*/
+ if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
+ gu32FlushedJoinReqSize = strWIDList[u32WidsCount].s32ValueSize;
+ gu8FlushedJoinReq = WILC_MALLOC(gu32FlushedJoinReqSize);
+ }
+ if (strWIDList[u32WidsCount].ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
+
+
+ if (pstrHostIFconnectAttr->pu8ssid != NULL) {
+ WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8ssid, pstrHostIFconnectAttr->ssidLen);
+ pu8CurrByte[pstrHostIFconnectAttr->ssidLen] = '\0';
+ }
+ pu8CurrByte += MAX_SSID_LEN;
+
+ /* BSS type*/
+ *(pu8CurrByte++) = INFRASTRUCTURE;
+ /* Channel*/
+ if ((pstrHostIFconnectAttr->u8channel >= 1) && (pstrHostIFconnectAttr->u8channel <= 14)) {
+ *(pu8CurrByte++) = pstrHostIFconnectAttr->u8channel;
+ } else {
+ PRINT_ER("Channel out of range\n");
+ *(pu8CurrByte++) = 0xFF;
+ }
+ /* Cap Info*/
+ *(pu8CurrByte++) = (ptstrJoinBssParam->cap_info) & 0xFF;
+ *(pu8CurrByte++) = ((ptstrJoinBssParam->cap_info) >> 8) & 0xFF;
+ PRINT_D(HOSTINF_DBG, "* Cap Info %0x*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
+
+ /* sa*/
+ if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+ WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
+ }
+ pu8CurrByte += 6;
+
+ /* bssid*/
+ if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+ WILC_memcpy(pu8CurrByte, pstrHostIFconnectAttr->pu8bssid, 6);
+ }
+ pu8CurrByte += 6;
+
+ /* Beacon Period*/
+ *(pu8CurrByte++) = (ptstrJoinBssParam->beacon_period) & 0xFF;
+ *(pu8CurrByte++) = ((ptstrJoinBssParam->beacon_period) >> 8) & 0xFF;
+ PRINT_D(HOSTINF_DBG, "* Beacon Period %d*\n", (*(pu8CurrByte - 2) | ((*(pu8CurrByte - 1)) << 8)));
+ /* DTIM Period*/
+ *(pu8CurrByte++) = ptstrJoinBssParam->dtim_period;
+ PRINT_D(HOSTINF_DBG, "* DTIM Period %d*\n", (*(pu8CurrByte - 1)));
+ /* Supported rates*/
+ WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->supp_rates, MAX_RATES_SUPPORTED + 1);
+ pu8CurrByte += (MAX_RATES_SUPPORTED + 1);
+
+ /* wmm cap*/
+ *(pu8CurrByte++) = ptstrJoinBssParam->wmm_cap;
+ PRINT_D(HOSTINF_DBG, "* wmm cap%d*\n", (*(pu8CurrByte - 1)));
+ /* uapsd cap*/
+ *(pu8CurrByte++) = ptstrJoinBssParam->uapsd_cap;
+
+ /* ht cap*/
+ *(pu8CurrByte++) = ptstrJoinBssParam->ht_capable;
+ /* copy this information to the user request */
+ pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable = ptstrJoinBssParam->ht_capable;
+
+ /* rsn found*/
+ *(pu8CurrByte++) = ptstrJoinBssParam->rsn_found;
+ PRINT_D(HOSTINF_DBG, "* rsn found %d*\n", *(pu8CurrByte - 1));
+ /* rsn group policy*/
+ *(pu8CurrByte++) = ptstrJoinBssParam->rsn_grp_policy;
+ PRINT_D(HOSTINF_DBG, "* rsn group policy %0x*\n", (*(pu8CurrByte - 1)));
+ /* mode_802_11i*/
+ *(pu8CurrByte++) = ptstrJoinBssParam->mode_802_11i;
+ PRINT_D(HOSTINF_DBG, "* mode_802_11i %d*\n", (*(pu8CurrByte - 1)));
+ /* rsn pcip policy*/
+ WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_pcip_policy, sizeof(ptstrJoinBssParam->rsn_pcip_policy));
+ pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_pcip_policy);
+
+ /* rsn auth policy*/
+ WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_auth_policy, sizeof(ptstrJoinBssParam->rsn_auth_policy));
+ pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_auth_policy);
+
+ /* rsn auth policy*/
+ WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->rsn_cap, sizeof(ptstrJoinBssParam->rsn_cap));
+ pu8CurrByte += sizeof(ptstrJoinBssParam->rsn_cap);
+
+ /*BugID_5137*/
+ *(pu8CurrByte++) = REAL_JOIN_REQ;
+
+ #ifdef WILC_P2P
+ *(pu8CurrByte++) = ptstrJoinBssParam->u8NoaEnbaled;
+ if (ptstrJoinBssParam->u8NoaEnbaled) {
+ PRINT_D(HOSTINF_DBG, "NOA present\n");
+
+ *(pu8CurrByte++) = (ptstrJoinBssParam->tsf) & 0xFF;
+ *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 8) & 0xFF;
+ *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 16) & 0xFF;
+ *(pu8CurrByte++) = ((ptstrJoinBssParam->tsf) >> 24) & 0xFF;
+
+ *(pu8CurrByte++) = ptstrJoinBssParam->u8Index;
+
+ *(pu8CurrByte++) = ptstrJoinBssParam->u8OppEnable;
+
+ if (ptstrJoinBssParam->u8OppEnable)
+ *(pu8CurrByte++) = ptstrJoinBssParam->u8CtWindow;
+
+ *(pu8CurrByte++) = ptstrJoinBssParam->u8Count;
+
+ WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Duration, sizeof(ptstrJoinBssParam->au8Duration));
+
+ pu8CurrByte += sizeof(ptstrJoinBssParam->au8Duration);
+
+ WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8Interval, sizeof(ptstrJoinBssParam->au8Interval));
+
+ pu8CurrByte += sizeof(ptstrJoinBssParam->au8Interval);
+
+ WILC_memcpy(pu8CurrByte, ptstrJoinBssParam->au8StartTime, sizeof(ptstrJoinBssParam->au8StartTime));
+
+ pu8CurrByte += sizeof(ptstrJoinBssParam->au8StartTime);
+
+ } else
+ PRINT_D(HOSTINF_DBG, "NOA not present\n");
+ #endif
+
+
+ /* keep the buffer at the start of the allocated pointer to use it with the free*/
+ pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
+
+
+ #endif /* #ifdef WILC_PARSE_SCAN_IN_HOST*/
+ u32WidsCount++;
+
+ #ifndef SIMULATION
+ /* A temporary workaround to avoid handling the misleading MAC_DISCONNECTED raised from the
+ * firmware at chip reset when processing the WIDs of the Connect Request.
+ * (This workaround should be removed in the future when the Chip reset of the Connect WIDs is disabled) */
+ /* ////////////////////// */
+ gu32WidConnRstHack = 0;
+ /* ////////////////////// */
+ #endif
+
+ /*BugID_5137*/
+ if (WILC_memcmp("DIRECT-", pstrHostIFconnectAttr->pu8ssid, 7)) {
+ memcpy(gu8FlushedJoinReq, pu8CurrByte, gu32FlushedJoinReqSize);
+ gu8FlushedJoinReqDrvHandler = (WILC_Uint32)pstrWFIDrv;
+ }
+
+ PRINT_D(GENERIC_DBG, "send HOST_IF_WAITING_CONN_RESP\n");
+
+ if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+ WILC_memcpy(u8ConnectedSSID, pstrHostIFconnectAttr->pu8bssid, ETH_ALEN);
+
+ PRINT_D(GENERIC_DBG, "save Bssid = %x:%x:%x:%x:%x:%x\n", (pstrHostIFconnectAttr->pu8bssid[0]), (pstrHostIFconnectAttr->pu8bssid[1]), (pstrHostIFconnectAttr->pu8bssid[2]), (pstrHostIFconnectAttr->pu8bssid[3]), (pstrHostIFconnectAttr->pu8bssid[4]), (pstrHostIFconnectAttr->pu8bssid[5]));
+ PRINT_D(GENERIC_DBG, "save bssid = %x:%x:%x:%x:%x:%x\n", (u8ConnectedSSID[0]), (u8ConnectedSSID[1]), (u8ConnectedSSID[2]), (u8ConnectedSSID[3]), (u8ConnectedSSID[4]), (u8ConnectedSSID[5]));
+ }
+
+ s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Handle_Connect()] failed to send config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ } else {
+ PRINT_D(GENERIC_DBG, "set HOST_IF_WAITING_CONN_RESP\n");
+ pstrWFIDrv->enuHostIFstate = HOST_IF_WAITING_CONN_RESP;
+ }
+ #endif
+
+ WILC_CATCH(s32Error)
+ {
+ tstrConnectInfo strConnectInfo;
+
+ WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
+
+ PRINT_D(HOSTINF_DBG, "could not start connecting to the required network\n");
+
+ WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
+
+ if (pstrHostIFconnectAttr->pfConnectResult != NULL) {
+ if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+ WILC_memcpy(strConnectInfo.au8bssid, pstrHostIFconnectAttr->pu8bssid, 6);
+ }
+
+ if (pstrHostIFconnectAttr->pu8IEs != NULL) {
+ strConnectInfo.ReqIEsLen = pstrHostIFconnectAttr->IEsLen;
+ strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrHostIFconnectAttr->IEsLen);
+ WILC_memcpy(strConnectInfo.pu8ReqIEs,
+ pstrHostIFconnectAttr->pu8IEs,
+ pstrHostIFconnectAttr->IEsLen);
+ }
+
+ pstrHostIFconnectAttr->pfConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
+ &strConnectInfo,
+ MAC_DISCONNECTED,
+ NULL,
+ pstrHostIFconnectAttr->pvUserArg);
+ /*Change state to idle*/
+ pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
+ /* Deallocation */
+ if (strConnectInfo.pu8ReqIEs != NULL) {
+ WILC_FREE(strConnectInfo.pu8ReqIEs);
+ strConnectInfo.pu8ReqIEs = NULL;
+ }
+
+ } else {
+ PRINT_ER("Connect callback function pointer is NULL \n");
+ }
+ }
+
+ PRINT_D(HOSTINF_DBG, "Deallocating connection parameters\n");
+ /* Deallocate pstrHostIFconnectAttr->pu8bssid which was prevoisuly allocated by the sending thread */
+ if (pstrHostIFconnectAttr->pu8bssid != NULL) {
+ WILC_FREE(pstrHostIFconnectAttr->pu8bssid);
+ pstrHostIFconnectAttr->pu8bssid = NULL;
+ }
+
+ /* Deallocate pstrHostIFconnectAttr->pu8ssid which was prevoisuly allocated by the sending thread */
+ if (pstrHostIFconnectAttr->pu8ssid != NULL) {
+ WILC_FREE(pstrHostIFconnectAttr->pu8ssid);
+ pstrHostIFconnectAttr->pu8ssid = NULL;
+ }
+
+ /* Deallocate pstrHostIFconnectAttr->pu8IEs which was prevoisuly allocated by the sending thread */
+ if (pstrHostIFconnectAttr->pu8IEs != NULL) {
+ WILC_FREE(pstrHostIFconnectAttr->pu8IEs);
+ pstrHostIFconnectAttr->pu8IEs = NULL;
+ }
+
+ if (pu8CurrByte != NULL) {
+ WILC_FREE(pu8CurrByte);
+ }
+ return s32Error;
+}
+
+/**
+ * @brief Handle_FlushConnect
+ * @details Sending config packet to firmware to flush an old connection
+ * after switching FW from station one to hybrid one
+ * @param[in] void * drvHandler
+ * @return Error code.
+ * @author Amr Abdel-Moghny
+ * @date 19 DEC 2013
+ * @version 8.0
+ */
+
+static WILC_Sint32 Handle_FlushConnect(void *drvHandler)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWIDList[5];
+ WILC_Uint32 u32WidsCount = 0;
+ u8 *pu8CurrByte = NULL;
+
+
+ /* IEs to be inserted in Association Request */
+ strWIDList[u32WidsCount].u16WIDid = WID_INFO_ELEMENT_ASSOCIATE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_BIN_DATA;
+ strWIDList[u32WidsCount].ps8WidVal = gu8FlushedInfoElemAsoc;
+ strWIDList[u32WidsCount].s32ValueSize = gu32FlushedInfoElemAsocSize;
+ u32WidsCount++;
+
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_11I_MODE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(gu8Flushed11iMode));
+ u32WidsCount++;
+
+
+
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_AUTH_TYPE;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&gu8FlushedAuthType);
+ u32WidsCount++;
+
+
+ #ifdef WILC_PARSE_SCAN_IN_HOST
+ strWIDList[u32WidsCount].u16WIDid = (WILC_Uint16)WID_JOIN_REQ_EXTENDED;
+ strWIDList[u32WidsCount].enuWIDtype = WID_STR;
+ strWIDList[u32WidsCount].s32ValueSize = gu32FlushedJoinReqSize;
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)gu8FlushedJoinReq;
+ pu8CurrByte = strWIDList[u32WidsCount].ps8WidVal;
+
+ pu8CurrByte += FLUSHED_BYTE_POS;
+ *(pu8CurrByte) = FLUSHED_JOIN_REQ;
+
+ u32WidsCount++;
+
+ #endif
+
+ s32Error = SendConfigPkt(SET_CFG, strWIDList, u32WidsCount, WILC_FALSE, gu8FlushedJoinReqDrvHandler);
+ if (s32Error) {
+ PRINT_ER("Handle_Flush_Connect()] failed to send config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Handle_ConnectTimeout
+ * @details Call connect notification callback function indicating connection failure
+ * @param[in] NONE
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_ConnectTimeout(void *drvHandler)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrConnectInfo strConnectInfo;
+ tstrWID strWID;
+ WILC_Uint16 u16DummyReasonCode = 0;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver handler is NULL\n");
+ return s32Error;
+ }
+
+ pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
+
+ gbScanWhileConnected = WILC_FALSE;
+
+
+ WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
+
+
+ /* First, we will notify the upper layer with the Connection failure {through the Connect Callback function},
+ * then we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
+ * WID_DISCONNECT} */
+ if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
+ WILC_memcpy(strConnectInfo.au8bssid,
+ pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
+ }
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
+ strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
+ strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
+ WILC_memcpy(strConnectInfo.pu8ReqIEs,
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
+ pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
+ &strConnectInfo,
+ MAC_DISCONNECTED,
+ NULL,
+ pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
+
+ /* Deallocation of strConnectInfo.pu8ReqIEs */
+ if (strConnectInfo.pu8ReqIEs != NULL) {
+ WILC_FREE(strConnectInfo.pu8ReqIEs);
+ strConnectInfo.pu8ReqIEs = NULL;
+ }
+ } else {
+ PRINT_ER("Connect callback function pointer is NULL \n");
+ }
+
+ /* Here we will notify our firmware also with the Connection failure {through sending to it Cfg packet carrying
+ * WID_DISCONNECT} */
+ strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Sint8 *)&u16DummyReasonCode;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to send dissconect config packet\n");
+ }
+
+ /* Deallocation of the Saved Connect Request in the global Handle */
+ pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
+ }
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
+ }
+
+ WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
+ /*BugID_5213*/
+ /*Freeing flushed join request params on connect timeout*/
+ if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) {
+ WILC_FREE(gu8FlushedJoinReq);
+ gu8FlushedJoinReq = NULL;
+ }
+ if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) {
+ WILC_FREE(gu8FlushedInfoElemAsoc);
+ gu8FlushedInfoElemAsoc = NULL;
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Handle_RcvdNtwrkInfo
+ * @details Handling received network information
+ * @param[in] tstrRcvdNetworkInfo* pstrRcvdNetworkInfo
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_RcvdNtwrkInfo(void *drvHandler, tstrRcvdNetworkInfo *pstrRcvdNetworkInfo)
+{
+ WILC_Uint32 i;
+ WILC_Bool bNewNtwrkFound;
+
+
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrNetworkInfo *pstrNetworkInfo = NULL;
+ void *pJoinParams = NULL;
+
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+
+ bNewNtwrkFound = WILC_TRUE;
+ PRINT_INFO(HOSTINF_DBG, "Handling received network info\n");
+
+ /*if there is a an ongoing scan request*/
+ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+ PRINT_D(HOSTINF_DBG, "State: Scanning, parsing network information received\n");
+ ParseNetworkInfo(pstrRcvdNetworkInfo->pu8Buffer, &pstrNetworkInfo);
+ if ((pstrNetworkInfo == NULL)
+ || (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult == NULL)) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* check whether this network is discovered before */
+ for (i = 0; i < pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount; i++) {
+
+ if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid != NULL) &&
+ (pstrNetworkInfo->au8bssid != NULL)) {
+ if (WILC_memcmp(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].au8bssid,
+ pstrNetworkInfo->au8bssid, 6) == 0) {
+ if (pstrNetworkInfo->s8rssi <= pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi) {
+ /*we have already found this network with better rssi, so keep the old cached one and don't
+ * send anything to the upper layer */
+ PRINT_D(HOSTINF_DBG, "Network previously discovered\n");
+ goto done;
+ } else {
+ /* here the same already found network is found again but with a better rssi, so just update
+ * the rssi for this cached network and send this updated network to the upper layer but
+ * don't add a new record for it */
+ pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[i].s8rssi = pstrNetworkInfo->s8rssi;
+ bNewNtwrkFound = WILC_FALSE;
+ break;
+ }
+ }
+ }
+ }
+
+ if (bNewNtwrkFound == WILC_TRUE) {
+ /* here it is confirmed that it is a new discovered network,
+ * so add its record then call the User CallBack function */
+
+ PRINT_D(HOSTINF_DBG, "New network found\n");
+
+ if (pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) {
+ pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].s8rssi = pstrNetworkInfo->s8rssi;
+
+ if ((pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid != NULL)
+ && (pstrNetworkInfo->au8bssid != NULL)) {
+ WILC_memcpy(pstrWFIDrv->strWILC_UsrScanReq.astrFoundNetworkInfo[pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount].au8bssid,
+ pstrNetworkInfo->au8bssid, 6);
+
+ pstrWFIDrv->strWILC_UsrScanReq.u32RcvdChCount++;
+
+ pstrNetworkInfo->bNewNetwork = WILC_TRUE;
+ /*Bug4218: Parsing Join Param*/
+ /* add new BSS to JoinBssTable */
+ #ifdef WILC_PARSE_SCAN_IN_HOST
+ pJoinParams = host_int_ParseJoinBssParam(pstrNetworkInfo);
+ #endif /*WILC_PARSE_SCAN_IN_HOST*/
+
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
+ pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid,
+ pJoinParams);
+
+
+ }
+ } else {
+ PRINT_WRN(HOSTINF_DBG, "Discovered networks exceeded max. limit \n");
+ }
+ } else {
+ pstrNetworkInfo->bNewNetwork = WILC_FALSE;
+ /* just call the User CallBack function to send the same discovered network with its updated RSSI */
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_NETWORK_FOUND, pstrNetworkInfo,
+ pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
+ }
+ }
+
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+done:
+ /* Deallocate pstrRcvdNetworkInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
+ if (pstrRcvdNetworkInfo->pu8Buffer != NULL) {
+ WILC_FREE(pstrRcvdNetworkInfo->pu8Buffer);
+ pstrRcvdNetworkInfo->pu8Buffer = NULL;
+ }
+
+ /*free structure allocated*/
+ if (pstrNetworkInfo != NULL) {
+ DeallocateNetworkInfo(pstrNetworkInfo);
+ pstrNetworkInfo = NULL;
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Handle_RcvdGnrlAsyncInfo
+ * @details Handling received asynchrous general network information
+ * @param[in] tstrRcvdGnrlAsyncInfo* pstrRcvdGnrlAsyncInfo
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_RcvdGnrlAsyncInfo(void *drvHandler, tstrRcvdGnrlAsyncInfo *pstrRcvdGnrlAsyncInfo)
+{
+ /* TODO: mostafa: till now, this function just handles only the received mac status msg, */
+ /* which carries only 1 WID which have WID ID = WID_STATUS */
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ u8 u8MsgType = 0;
+ u8 u8MsgID = 0;
+ WILC_Uint16 u16MsgLen = 0;
+ WILC_Uint16 u16WidID = (WILC_Uint16)WID_NIL;
+ u8 u8WidLen = 0;
+ u8 u8MacStatus;
+ u8 u8MacStatusReasonCode;
+ u8 u8MacStatusAdditionalInfo;
+ tstrConnectInfo strConnectInfo;
+ tstrDisconnectNotifInfo strDisconnectNotifInfo;
+ WILC_Sint32 s32Err = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver handler is NULL\n");
+ }
+ PRINT_D(GENERIC_DBG, "Current State = %d,Received state = %d\n", pstrWFIDrv->enuHostIFstate,
+ pstrRcvdGnrlAsyncInfo->pu8Buffer[7]);
+
+ if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) ||
+ (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) ||
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+ if ((pstrRcvdGnrlAsyncInfo->pu8Buffer == NULL) ||
+ (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL)) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ u8MsgType = pstrRcvdGnrlAsyncInfo->pu8Buffer[0];
+
+ /* Check whether the received message type is 'I' */
+ if ('I' != u8MsgType) {
+ PRINT_ER("Received Message format incorrect.\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ /* Extract message ID */
+ u8MsgID = pstrRcvdGnrlAsyncInfo->pu8Buffer[1];
+
+ /* Extract message Length */
+ u16MsgLen = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[2], pstrRcvdGnrlAsyncInfo->pu8Buffer[3]);
+
+ /* Extract WID ID [expected to be = WID_STATUS] */
+ u16WidID = MAKE_WORD16(pstrRcvdGnrlAsyncInfo->pu8Buffer[4], pstrRcvdGnrlAsyncInfo->pu8Buffer[5]);
+
+ /* Extract WID Length [expected to be = 1] */
+ u8WidLen = pstrRcvdGnrlAsyncInfo->pu8Buffer[6];
+
+ /* get the WID value [expected to be one of two values: either MAC_CONNECTED = (1) or MAC_DISCONNECTED = (0)] */
+ u8MacStatus = pstrRcvdGnrlAsyncInfo->pu8Buffer[7];
+ u8MacStatusReasonCode = pstrRcvdGnrlAsyncInfo->pu8Buffer[8];
+ u8MacStatusAdditionalInfo = pstrRcvdGnrlAsyncInfo->pu8Buffer[9];
+ PRINT_INFO(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Info = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
+ if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
+ /* our station had sent Association Request frame, so here it will get the Association Response frame then parse it */
+ WILC_Uint32 u32RcvdAssocRespInfoLen;
+ tstrConnectRespInfo *pstrConnectRespInfo = NULL;
+
+ PRINT_D(HOSTINF_DBG, "Recieved MAC status = %d with Reason = %d , Code = %d\n", u8MacStatus, u8MacStatusReasonCode, u8MacStatusAdditionalInfo);
+
+ WILC_memset(&strConnectInfo, 0, sizeof(tstrConnectInfo));
+
+ if (u8MacStatus == MAC_CONNECTED) {
+ WILC_memset(gapu8RcvdAssocResp, 0, MAX_ASSOC_RESP_FRAME_SIZE);
+
+ host_int_get_assoc_res_info((WILC_WFIDrvHandle)pstrWFIDrv,
+ gapu8RcvdAssocResp,
+ MAX_ASSOC_RESP_FRAME_SIZE,
+ &u32RcvdAssocRespInfoLen);
+
+ PRINT_INFO(HOSTINF_DBG, "Received association response with length = %d\n", u32RcvdAssocRespInfoLen);
+
+ if (u32RcvdAssocRespInfoLen != 0) {
+
+ PRINT_D(HOSTINF_DBG, "Parsing association response\n");
+ s32Err = ParseAssocRespInfo(gapu8RcvdAssocResp, u32RcvdAssocRespInfoLen,
+ &pstrConnectRespInfo);
+ if (s32Err) {
+ PRINT_ER("ParseAssocRespInfo() returned error %d \n", s32Err);
+ } else {
+ /* use the necessary parsed Info from the Received Association Response */
+ strConnectInfo.u16ConnectStatus = pstrConnectRespInfo->u16ConnectStatus;
+
+ if (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE) {
+ PRINT_INFO(HOSTINF_DBG, "Association response received : Successful connection status\n");
+ if (pstrConnectRespInfo->pu8RespIEs != NULL) {
+ strConnectInfo.u16RespIEsLen = pstrConnectRespInfo->u16RespIEsLen;
+
+
+ strConnectInfo.pu8RespIEs = (u8 *)WILC_MALLOC(pstrConnectRespInfo->u16RespIEsLen);
+ WILC_memcpy(strConnectInfo.pu8RespIEs, pstrConnectRespInfo->pu8RespIEs,
+ pstrConnectRespInfo->u16RespIEsLen);
+ }
+ }
+
+ /* deallocate the Assoc. Resp. parsed structure as it is not needed anymore */
+ if (pstrConnectRespInfo != NULL) {
+ DeallocateAssocRespInfo(pstrConnectRespInfo);
+ pstrConnectRespInfo = NULL;
+ }
+ }
+ }
+ }
+
+ /* The station has just received mac status and it also received assoc. response which
+ * it was waiting for.
+ * So check first the matching between the received mac status and the received status code in Asoc Resp */
+ if ((u8MacStatus == MAC_CONNECTED) &&
+ (strConnectInfo.u16ConnectStatus != SUCCESSFUL_STATUSCODE)) {
+ PRINT_ER("Received MAC status is MAC_CONNECTED while the received status code in Asoc Resp is not SUCCESSFUL_STATUSCODE \n");
+ WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
+
+ } else if (u8MacStatus == MAC_DISCONNECTED) {
+ PRINT_ER("Received MAC status is MAC_DISCONNECTED\n");
+ WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
+ }
+
+ /* TODO: mostafa: correct BSSID should be retrieved from actual BSSID received from AP */
+ /* through a structure of type tstrConnectRespInfo */
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
+ PRINT_D(HOSTINF_DBG, "Retrieving actual BSSID from AP\n");
+ WILC_memcpy(strConnectInfo.au8bssid, pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, 6);
+
+ if ((u8MacStatus == MAC_CONNECTED) &&
+ (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
+ WILC_memcpy(pstrWFIDrv->au8AssociatedBSSID,
+ pstrWFIDrv->strWILC_UsrConnReq.pu8bssid, ETH_ALEN);
+ }
+ }
+
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
+ strConnectInfo.ReqIEsLen = pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen;
+ strConnectInfo.pu8ReqIEs = (u8 *)WILC_MALLOC(pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
+ WILC_memcpy(strConnectInfo.pu8ReqIEs,
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs,
+ pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen);
+ }
+
+
+ WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
+ pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_CONN_RESP,
+ &strConnectInfo,
+ u8MacStatus,
+ NULL,
+ pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
+
+
+ /* if received mac status is MAC_CONNECTED and
+ * received status code in Asoc Resp is SUCCESSFUL_STATUSCODE, change state to CONNECTED
+ * else change state to IDLE */
+ if ((u8MacStatus == MAC_CONNECTED) &&
+ (strConnectInfo.u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+
+ host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
+ #endif
+
+ PRINT_D(HOSTINF_DBG, "MAC status : CONNECTED and Connect Status : Successful\n");
+ pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTED;
+
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ PRINT_D(GENERIC_DBG, "Obtaining an IP, Disable Scan\n");
+ g_obtainingIP = WILC_TRUE;
+ WILC_TimerStart(&hDuringIpTimer, 10000, NULL, NULL);
+ #endif
+
+ #ifdef WILC_PARSE_SCAN_IN_HOST
+ /* open a BA session if possible */
+ /* if(pstrWFIDrv->strWILC_UsrConnReq.IsHTCapable) */
+
+ #endif
+
+ /* host_int_addBASession(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid,0, */
+ /* BA_SESSION_DEFAULT_BUFFER_SIZE,BA_SESSION_DEFAULT_TIMEOUT); */
+ } else {
+ PRINT_D(HOSTINF_DBG, "MAC status : %d and Connect Status : %d\n", u8MacStatus, strConnectInfo.u16ConnectStatus);
+ pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
+ gbScanWhileConnected = WILC_FALSE;
+ }
+
+ /* Deallocation */
+ if (strConnectInfo.pu8RespIEs != NULL) {
+ WILC_FREE(strConnectInfo.pu8RespIEs);
+ strConnectInfo.pu8RespIEs = NULL;
+ }
+
+ if (strConnectInfo.pu8ReqIEs != NULL) {
+ WILC_FREE(strConnectInfo.pu8ReqIEs);
+ strConnectInfo.pu8ReqIEs = NULL;
+ }
+
+
+ pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
+ }
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
+ }
+
+ } else if ((u8MacStatus == MAC_DISCONNECTED) &&
+ (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED)) {
+ /* Disassociation or Deauthentication frame has been received */
+ PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW\n");
+
+ WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
+
+ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+ PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running OBSS Scan >> \n\n");
+ WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
+ Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
+ }
+
+ strDisconnectNotifInfo.u16reason = 0;
+ strDisconnectNotifInfo.ie = NULL;
+ strDisconnectNotifInfo.ie_len = 0;
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+
+ g_obtainingIP = WILC_FALSE;
+ host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
+ #endif
+
+ pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF,
+ NULL,
+ 0,
+ &strDisconnectNotifInfo,
+ pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
+
+ } else {
+ PRINT_ER("Connect result callback function is NULL \n");
+ }
+
+ WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
+
+
+ /* Deallocation */
+
+ /* if Information Elements were retrieved from the Received deauth/disassoc frame, then they
+ * should be deallocated here */
+ /*
+ * if(strDisconnectNotifInfo.ie != NULL)
+ * {
+ * WILC_FREE(strDisconnectNotifInfo.ie);
+ * strDisconnectNotifInfo.ie = NULL;
+ * }
+ */
+
+ pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
+ }
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
+ }
+
+ /*BugID_5213*/
+ /*Freeing flushed join request params on receiving*/
+ /*MAC_DISCONNECTED while connected*/
+ if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) {
+ WILC_FREE(gu8FlushedJoinReq);
+ gu8FlushedJoinReq = NULL;
+ }
+ if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) {
+ WILC_FREE(gu8FlushedInfoElemAsoc);
+ gu8FlushedInfoElemAsoc = NULL;
+ }
+
+ pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
+ gbScanWhileConnected = WILC_FALSE;
+
+ } else if ((u8MacStatus == MAC_DISCONNECTED) &&
+ (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL)) {
+ PRINT_D(HOSTINF_DBG, "Received MAC_DISCONNECTED from the FW while scanning\n");
+ PRINT_D(HOSTINF_DBG, "\n\n<< Abort the running Scan >> \n\n");
+ /*Abort the running scan*/
+ WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
+ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+ Handle_ScanDone((void *)pstrWFIDrv, SCAN_EVENT_ABORTED);
+
+ }
+ }
+
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ /* Deallocate pstrRcvdGnrlAsyncInfo->pu8Buffer which was prevoisuly allocated by the sending thread */
+ if (pstrRcvdGnrlAsyncInfo->pu8Buffer != NULL) {
+ WILC_FREE(pstrRcvdGnrlAsyncInfo->pu8Buffer);
+ pstrRcvdGnrlAsyncInfo->pu8Buffer = NULL;
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Handle_Key
+ * @details Sending config packet to firmware to set key
+ * @param[in] tstrHostIFkeyAttr* pstrHostIFkeyAttr
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static int Handle_Key(void *drvHandler, tstrHostIFkeyAttr *pstrHostIFkeyAttr)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ #ifdef WILC_AP_EXTERNAL_MLME
+ tstrWID strWIDList[5];
+ #endif
+ u8 i;
+ u8 *pu8keybuf;
+ WILC_Sint8 s8idxarray[1];
+ WILC_Sint8 ret = 0;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+ switch (pstrHostIFkeyAttr->enuKeyType) {
+
+
+ case WEP:
+
+#ifdef WILC_AP_EXTERNAL_MLME
+ if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
+
+ PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
+ PRINT_D(GENERIC_DBG, "ID Hostint is %d\n", (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
+ strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE;
+ strWIDList[0].enuWIDtype = WID_CHAR;
+ strWIDList[0].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8mode));
+
+ strWIDList[1].u16WIDid = WID_AUTH_TYPE;
+ strWIDList[1].enuWIDtype = WID_CHAR;
+ strWIDList[1].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[1].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type));
+
+ strWIDList[2].u16WIDid = (WILC_Uint16)WID_KEY_ID;
+ strWIDList[2].enuWIDtype = WID_CHAR;
+
+ strWIDList[2].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
+ strWIDList[2].s32ValueSize = sizeof(WILC_Char);
+
+
+ pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
+
+
+ if (pu8keybuf == NULL) {
+ PRINT_ER("No buffer to send Key\n");
+ return -1;
+ }
+
+ WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
+ pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
+
+
+ WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
+
+ strWIDList[3].u16WIDid = (WILC_Uint16)WID_WEP_KEY_VALUE;
+ strWIDList[3].enuWIDtype = WID_STR;
+ strWIDList[3].s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen;
+ strWIDList[3].ps8WidVal = (WILC_Sint8 *)pu8keybuf;
+
+
+ s32Error = SendConfigPkt(SET_CFG, strWIDList, 4, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ WILC_FREE(pu8keybuf);
+
+
+ }
+#endif
+
+ if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
+ PRINT_D(HOSTINF_DBG, "Handling WEP key\n");
+ pu8keybuf = (u8 *)WILC_MALLOC(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2);
+ if (pu8keybuf == NULL) {
+ PRINT_ER("No buffer to send Key\n");
+ return -1;
+ }
+ pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
+
+ WILC_memcpy(pu8keybuf + 1, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen, 1);
+
+ WILC_memcpy(pu8keybuf + 2, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
+ pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen);
+
+ WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey);
+
+ strWID.u16WIDid = (WILC_Uint16)WID_ADD_WEP_KEY;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf;
+ strWID.s32ValueSize = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen + 2;
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ WILC_FREE(pu8keybuf);
+ } else if (pstrHostIFkeyAttr->u8KeyAction & REMOVEKEY) {
+
+ PRINT_D(HOSTINF_DBG, "Removing key\n");
+ strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_WEP_KEY;
+ strWID.enuWIDtype = WID_STR;
+
+ s8idxarray[0] = (WILC_Sint8)pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx;
+ strWID.ps8WidVal = s8idxarray;
+ strWID.s32ValueSize = 1;
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ } else {
+ strWID.u16WIDid = (WILC_Uint16)WID_KEY_ID;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx));
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ PRINT_D(HOSTINF_DBG, "Setting default key index\n");
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ }
+ up(&(pstrWFIDrv->hSemTestKeyBlock));
+ break;
+
+ case WPARxGtk:
+ #ifdef WILC_AP_EXTERNAL_MLME
+ if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
+ pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
+ if (pu8keybuf == NULL) {
+ PRINT_ER("No buffer to send RxGTK Key\n");
+ ret = -1;
+ goto _WPARxGtk_end_case_;
+ }
+
+ WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
+
+
+ /*|----------------------------------------------------------------------------|
+ * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
+ * |------------|---------|-------|------------|---------------|----------------|
+ | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
+
+
+
+ if (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq != NULL)
+ WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
+
+
+ WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
+
+ WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
+
+ WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
+ pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
+ /* pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = 0X51; */
+ strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE;
+ strWIDList[0].enuWIDtype = WID_CHAR;
+ strWIDList[0].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
+
+ strWIDList[1].u16WIDid = (WILC_Uint16)WID_ADD_RX_GTK;
+ strWIDList[1].enuWIDtype = WID_STR;
+ strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf;
+ strWIDList[1].s32ValueSize = RX_MIC_KEY_MSG_LEN;
+
+ s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+ WILC_FREE(pu8keybuf);
+
+ /* ////////////////////////// */
+ up(&(pstrWFIDrv->hSemTestKeyBlock));
+ /* ///////////////////////// */
+ }
+
+ #endif
+ if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
+ PRINT_D(HOSTINF_DBG, "Handling group key(Rx) function\n");
+
+ pu8keybuf = (u8 *)WILC_MALLOC(RX_MIC_KEY_MSG_LEN);
+ if (pu8keybuf == NULL) {
+ PRINT_ER("No buffer to send RxGTK Key\n");
+ ret = -1;
+ goto _WPARxGtk_end_case_;
+ }
+
+ WILC_memset(pu8keybuf, 0, RX_MIC_KEY_MSG_LEN);
+
+
+ /*|----------------------------------------------------------------------------|
+ * |Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
+ * |------------|---------|-------|------------|---------------|----------------|
+ | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |*/
+
+ if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
+ WILC_memcpy(pu8keybuf, pstrWFIDrv->au8AssociatedBSSID, ETH_ALEN);
+ } else {
+ PRINT_ER("Couldn't handle WPARxGtk while enuHostIFstate is not HOST_IF_CONNECTED \n");
+ }
+
+ WILC_memcpy(pu8keybuf + 6, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq, 8);
+
+ WILC_memcpy(pu8keybuf + 14, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
+
+ WILC_memcpy(pu8keybuf + 15, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
+ WILC_memcpy(pu8keybuf + 16, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
+ pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
+
+ strWID.u16WIDid = (WILC_Uint16)WID_ADD_RX_GTK;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf;
+ strWID.s32ValueSize = RX_MIC_KEY_MSG_LEN;
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+ WILC_FREE(pu8keybuf);
+
+ /* ////////////////////////// */
+ up(&(pstrWFIDrv->hSemTestKeyBlock));
+ /* ///////////////////////// */
+ }
+_WPARxGtk_end_case_:
+ WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
+ WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq);
+ if (ret == -1)
+ return ret;
+
+ break;
+
+ case WPAPtk:
+ #ifdef WILC_AP_EXTERNAL_MLME
+ if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY_AP) {
+
+
+ pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN + 1);
+
+
+
+ if (pu8keybuf == NULL) {
+ PRINT_ER("No buffer to send PTK Key\n");
+ ret = -1;
+ goto _WPAPtk_end_case_;
+
+ }
+
+ /*|-----------------------------------------------------------------------------|
+ * |Station address | keyidx |Key Length |Temporal Key | Rx Michael Key |Tx Michael Key |
+ * |----------------|------------ |--------------|----------------|---------------|
+ | 6 bytes | 1 byte | 1byte | 16 bytes | 8 bytes | 8 bytes |
+ |-----------------------------------------------------------------------------|*/
+
+ WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
+
+ WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx, 1);
+ WILC_memcpy(pu8keybuf + 7, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
+ /*16 byte TK*/
+ WILC_memcpy(pu8keybuf + 8, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
+ pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
+
+
+ strWIDList[0].u16WIDid = (WILC_Uint16)WID_11I_MODE;
+ strWIDList[0].enuWIDtype = WID_CHAR;
+ strWIDList[0].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[0].ps8WidVal = (WILC_Sint8 *)(&(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode));
+
+ strWIDList[1].u16WIDid = (WILC_Uint16)WID_ADD_PTK;
+ strWIDList[1].enuWIDtype = WID_STR;
+ strWIDList[1].ps8WidVal = (WILC_Sint8 *)pu8keybuf;
+ strWIDList[1].s32ValueSize = PTK_KEY_MSG_LEN + 1;
+
+ s32Error = SendConfigPkt(SET_CFG, strWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ WILC_FREE(pu8keybuf);
+
+ /* ////////////////////////// */
+ up(&(pstrWFIDrv->hSemTestKeyBlock));
+ /* ///////////////////////// */
+ }
+ #endif
+ if (pstrHostIFkeyAttr->u8KeyAction & ADDKEY) {
+
+
+ pu8keybuf = (u8 *)WILC_MALLOC(PTK_KEY_MSG_LEN);
+
+
+
+ if (pu8keybuf == NULL) {
+ PRINT_ER("No buffer to send PTK Key\n");
+ ret = -1;
+ goto _WPAPtk_end_case_;
+
+ }
+
+ /*|-----------------------------------------------------------------------------|
+ * |Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
+ * |----------------|------------|--------------|----------------|---------------|
+ | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
+ |-----------------------------------------------------------------------------|*/
+
+ WILC_memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr, 6); /*1 bytes Key Length */
+
+ WILC_memcpy(pu8keybuf + 6, &pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen, 1);
+ /*16 byte TK*/
+ WILC_memcpy(pu8keybuf + 7, pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
+ pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen);
+
+
+ strWID.u16WIDid = (WILC_Uint16)WID_ADD_PTK;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf;
+ strWID.s32ValueSize = PTK_KEY_MSG_LEN;
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ WILC_FREE(pu8keybuf);
+
+ /* ////////////////////////// */
+ up(&(pstrWFIDrv->hSemTestKeyBlock));
+ /* ///////////////////////// */
+ }
+
+_WPAPtk_end_case_:
+ WILC_FREE(pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFwpaAttr.pu8key);
+ if (ret == -1)
+ return ret;
+
+ break;
+
+
+ case PMKSA:
+
+ PRINT_D(HOSTINF_DBG, "Handling PMKSA key\n");
+
+ pu8keybuf = (u8 *)WILC_MALLOC((pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1);
+ if (pu8keybuf == NULL) {
+ PRINT_ER("No buffer to send PMKSA Key\n");
+ return -1;
+ }
+
+ pu8keybuf[0] = pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid;
+
+ for (i = 0; i < pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid; i++) {
+
+ WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, ETH_ALEN);
+ WILC_memcpy(pu8keybuf + ((PMKSA_KEY_LEN * i) + ETH_ALEN + 1), pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, PMKID_LEN);
+ }
+
+ strWID.u16WIDid = (WILC_Uint16)WID_PMKID_INFO;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (WILC_Sint8 *)pu8keybuf;
+ strWID.s32ValueSize = (pstrHostIFkeyAttr->uniHostIFkeyAttr.strHostIFpmkidAttr.numpmkid * PMKSA_KEY_LEN) + 1;
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+ WILC_FREE(pu8keybuf);
+ break;
+ }
+
+ if (s32Error)
+ PRINT_ER("Failed to send key config packet\n");
+
+
+ return s32Error;
+}
+
+
+/**
+ * @brief Handle_Disconnect
+ * @details Sending config packet to firmware to disconnect
+ * @param[in] NONE
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_Disconnect(void *drvHandler)
+{
+ tstrWID strWID;
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ WILC_Uint16 u16DummyReasonCode = 0;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+ strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Sint8 *)&u16DummyReasonCode;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+
+
+ PRINT_D(HOSTINF_DBG, "Sending disconnect request\n");
+
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+
+ g_obtainingIP = WILC_FALSE;
+ host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
+ #endif
+
+ WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+
+ if (s32Error) {
+ PRINT_ER("Failed to send dissconect config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ } else {
+ tstrDisconnectNotifInfo strDisconnectNotifInfo;
+
+ WILC_memset(&strDisconnectNotifInfo, 0, sizeof(tstrDisconnectNotifInfo));
+
+ strDisconnectNotifInfo.u16reason = 0;
+ strDisconnectNotifInfo.ie = NULL;
+ strDisconnectNotifInfo.ie_len = 0;
+
+ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+ WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
+ pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
+
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
+ }
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult != NULL) {
+
+ /*BugID_5193*/
+ /*Stop connect timer, if connection in progress*/
+ if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
+ PRINT_D(HOSTINF_DBG, "Upper layer requested termination of connection\n");
+ WILC_TimerStop(&(pstrWFIDrv->hConnectTimer), NULL);
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult(CONN_DISCONN_EVENT_DISCONN_NOTIF, NULL,
+ 0, &strDisconnectNotifInfo, pstrWFIDrv->strWILC_UsrConnReq.u32UserConnectPvoid);
+ } else {
+ PRINT_ER("strWILC_UsrConnReq.pfUserConnectResult = NULL \n");
+ }
+
+ gbScanWhileConnected = WILC_FALSE;
+
+ pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
+
+ WILC_memset(pstrWFIDrv->au8AssociatedBSSID, 0, ETH_ALEN);
+
+
+ /* Deallocation */
+ pstrWFIDrv->strWILC_UsrConnReq.ssidLen = 0;
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ssid != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ssid);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ssid = NULL;
+ }
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8bssid != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8bssid);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8bssid = NULL;
+ }
+
+ pstrWFIDrv->strWILC_UsrConnReq.ConnReqIEsLen = 0;
+ if (pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs != NULL) {
+ WILC_FREE(pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs);
+ pstrWFIDrv->strWILC_UsrConnReq.pu8ConnReqIEs = NULL;
+ }
+
+
+ /*BugID_5137*/
+ if (gu8FlushedJoinReq != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) {
+ WILC_FREE(gu8FlushedJoinReq);
+ gu8FlushedJoinReq = NULL;
+ }
+ if (gu8FlushedInfoElemAsoc != NULL && gu8FlushedJoinReqDrvHandler == (WILC_Uint32)drvHandler) {
+ WILC_FREE(gu8FlushedInfoElemAsoc);
+ gu8FlushedInfoElemAsoc = NULL;
+ }
+
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ /* ////////////////////////// */
+ up(&(pstrWFIDrv->hSemTestDisconnectBlock));
+ /* ///////////////////////// */
+
+}
+
+
+void resolve_disconnect_aberration(void *drvHandler)
+{
+ tstrWILC_WFIDrv *pstrWFIDrv;
+
+ pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ if (pstrWFIDrv == NULL)
+ return;
+ if ((pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) || (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTING)) {
+ PRINT_D(HOSTINF_DBG, "\n\n<< correcting Supplicant state machine >>\n\n");
+ host_int_disconnect((WILC_WFIDrvHandle)pstrWFIDrv, 1);
+ }
+}
+static WILC_Sint32 Switch_Log_Terminal(void *drvHandler)
+{
+
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ static char dummy = 9;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ strWID.u16WIDid = (WILC_Uint16)WID_LOGTerminal_Switch;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = &dummy;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+
+ if (s32Error) {
+ PRINT_D(HOSTINF_DBG, "Failed to switch log terminal\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ } else {
+ PRINT_INFO(HOSTINF_DBG, "MAC address set :: \n");
+
+
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Handle_GetChnl
+ * @details Sending config packet to get channel
+ * @param[in] NONE
+ * @return NONE
+ *
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_GetChnl(void *drvHandler)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ strWID.u16WIDid = (WILC_Uint16)WID_CURRENT_CHANNEL;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Sint8 *)&gu8Chnl;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ PRINT_D(HOSTINF_DBG, "Getting channel value\n");
+
+ s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ /*get the value by searching the local copy*/
+ if (s32Error) {
+ PRINT_ER("Failed to get channel number\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ up(&(pstrWFIDrv->hSemGetCHNL));
+
+ return s32Error;
+
+
+
+}
+
+
+/**
+ * @brief Handle_GetRssi
+ * @details Sending config packet to get RSSI
+ * @param[in] NONE
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_GetRssi(void *drvHandler)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ strWID.u16WIDid = (WILC_Uint16)WID_RSSI;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = &gs8Rssi;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ /*Sending Cfg*/
+ PRINT_D(HOSTINF_DBG, "Getting RSSI value\n");
+
+ s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to get RSSI value\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ up(&(pstrWFIDrv->hSemGetRSSI));
+
+
+}
+
+
+static void Handle_GetLinkspeed(void *drvHandler)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ gs8lnkspd = 0;
+
+ strWID.u16WIDid = (WILC_Uint16)WID_LINKSPEED;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = &gs8lnkspd;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+ /*Sending Cfg*/
+ PRINT_D(HOSTINF_DBG, "Getting LINKSPEED value\n");
+
+ s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to get LINKSPEED value\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ up(&(pstrWFIDrv->hSemGetLINKSPEED));
+
+
+}
+
+WILC_Sint32 Handle_GetStatistics(void *drvHandler, tstrStatistics *pstrStatistics)
+{
+ tstrWID strWIDList[5];
+ uint32_t u32WidsCount = 0, s32Error = 0;
+
+ strWIDList[u32WidsCount].u16WIDid = WID_LINKSPEED;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u8LinkSpeed));
+ u32WidsCount++;
+
+ strWIDList[u32WidsCount].u16WIDid = WID_RSSI;
+ strWIDList[u32WidsCount].enuWIDtype = WID_CHAR;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Char);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->s8RSSI));
+ u32WidsCount++;
+
+ strWIDList[u32WidsCount].u16WIDid = WID_SUCCESS_FRAME_COUNT;
+ strWIDList[u32WidsCount].enuWIDtype = WID_INT;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32TxCount));
+ u32WidsCount++;
+
+ strWIDList[u32WidsCount].u16WIDid = WID_RECEIVED_FRAGMENT_COUNT;
+ strWIDList[u32WidsCount].enuWIDtype = WID_INT;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32RxCount));
+ u32WidsCount++;
+
+ strWIDList[u32WidsCount].u16WIDid = WID_FAILED_COUNT;
+ strWIDList[u32WidsCount].enuWIDtype = WID_INT;
+ strWIDList[u32WidsCount].s32ValueSize = sizeof(WILC_Uint32);
+ strWIDList[u32WidsCount].ps8WidVal = (WILC_Sint8 *)(&(pstrStatistics->u32TxFailureCount));
+ u32WidsCount++;
+
+ s32Error = SendConfigPkt(GET_CFG, strWIDList, u32WidsCount, WILC_FALSE, (WILC_Uint32)drvHandler);
+
+ if (s32Error) {
+ PRINT_ER("Failed to send scan paramters config packet\n");
+ /* WILC_ERRORREPORT(s32Error, s32Error); */
+ }
+ up(&hWaitResponse);
+ return 0;
+
+}
+
+
+#ifdef WILC_AP_EXTERNAL_MLME
+
+
+/**
+ * @brief Handle_Get_InActiveTime
+ * @details Sending config packet to set mac adddress for station and
+ * get inactive time
+ * @param[in] NONE
+ * @return NONE
+ *
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Sint32 Handle_Get_InActiveTime(void *drvHandler, tstrHostIfStaInactiveT *strHostIfStaInactiveT)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ u8 *stamac;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+ strWID.u16WIDid = (WILC_Uint16)WID_SET_STA_MAC_INACTIVE_TIME;
+ strWID.enuWIDtype = WID_STR;
+ strWID.s32ValueSize = ETH_ALEN;
+ strWID.ps8WidVal = (u8 *)WILC_MALLOC(strWID.s32ValueSize);
+
+
+ stamac = strWID.ps8WidVal;
+ WILC_memcpy(stamac, strHostIfStaInactiveT->mac, ETH_ALEN);
+
+
+ PRINT_D(CFG80211_DBG, "SETING STA inactive time\n");
+
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ /*get the value by searching the local copy*/
+ if (s32Error) {
+ PRINT_ER("Failed to SET incative time\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+
+ strWID.u16WIDid = (WILC_Uint16)WID_GET_INACTIVE_TIME;
+ strWID.enuWIDtype = WID_INT;
+ strWID.ps8WidVal = (WILC_Sint8 *)&gu32InactiveTime;
+ strWID.s32ValueSize = sizeof(WILC_Uint32);
+
+
+ s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ /*get the value by searching the local copy*/
+ if (s32Error) {
+ PRINT_ER("Failed to get incative time\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+
+ PRINT_D(CFG80211_DBG, "Getting inactive time : %d\n", gu32InactiveTime);
+
+ up(&(pstrWFIDrv->hSemInactiveTime));
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+
+ return s32Error;
+
+
+
+}
+
+
+/**
+ * @brief Handle_AddBeacon
+ * @details Sending config packet to add beacon
+ * @param[in] tstrHostIFSetBeacon* pstrSetBeaconParam
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_AddBeacon(void *drvHandler, tstrHostIFSetBeacon *pstrSetBeaconParam)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ u8 *pu8CurrByte;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ PRINT_D(HOSTINF_DBG, "Adding BEACON\n");
+
+ strWID.u16WIDid = (WILC_Uint16)WID_ADD_BEACON;
+ strWID.enuWIDtype = WID_BIN;
+ strWID.s32ValueSize = pstrSetBeaconParam->u32HeadLen + pstrSetBeaconParam->u32TailLen + 16;
+ strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWID.ps8WidVal;
+ *pu8CurrByte++ = (pstrSetBeaconParam->u32Interval & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 8) & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 16) & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32Interval >> 24) & 0xFF);
+
+ *pu8CurrByte++ = (pstrSetBeaconParam->u32DTIMPeriod & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 8) & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 16) & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32DTIMPeriod >> 24) & 0xFF);
+
+ *pu8CurrByte++ = (pstrSetBeaconParam->u32HeadLen & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 8) & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 16) & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32HeadLen >> 24) & 0xFF);
+
+ memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Head, pstrSetBeaconParam->u32HeadLen);
+ pu8CurrByte += pstrSetBeaconParam->u32HeadLen;
+
+ *pu8CurrByte++ = (pstrSetBeaconParam->u32TailLen & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 8) & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 16) & 0xFF);
+ *pu8CurrByte++ = ((pstrSetBeaconParam->u32TailLen >> 24) & 0xFF);
+
+ /* Bug 4599 : if tail length = 0 skip copying */
+ if (pstrSetBeaconParam->pu8Tail > 0)
+ memcpy(pu8CurrByte, pstrSetBeaconParam->pu8Tail, pstrSetBeaconParam->u32TailLen);
+ pu8CurrByte += pstrSetBeaconParam->u32TailLen;
+
+
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to send add beacon config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ WILC_FREE_IF_TRUE(strWID.ps8WidVal);
+ WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Head);
+ WILC_FREE_IF_TRUE(pstrSetBeaconParam->pu8Tail);
+}
+
+
+/**
+ * @brief Handle_AddBeacon
+ * @details Sending config packet to delete beacon
+ * @param[in] tstrHostIFDelBeacon* pstrDelBeacon
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_DelBeacon(void *drvHandler, tstrHostIFDelBeacon *pstrDelBeacon)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ u8 *pu8CurrByte;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ strWID.u16WIDid = (WILC_Uint16)WID_DEL_BEACON;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+ strWID.ps8WidVal = &gu8DelBcn;
+
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWID.ps8WidVal;
+
+ PRINT_D(HOSTINF_DBG, "Deleting BEACON\n");
+ /* TODO: build del beacon message*/
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+
+ PRINT_ER("Failed to send delete beacon config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+}
+
+
+/**
+ * @brief WILC_HostIf_PackStaParam
+ * @details Handling packing of the station params in a buffer
+ * @param[in] u8* pu8Buffer, tstrWILC_AddStaParam* pstrStationParam
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static WILC_Uint32 WILC_HostIf_PackStaParam(u8 *pu8Buffer, tstrWILC_AddStaParam *pstrStationParam)
+{
+ u8 *pu8CurrByte;
+
+ pu8CurrByte = pu8Buffer;
+
+ PRINT_D(HOSTINF_DBG, "Packing STA params\n");
+ WILC_memcpy(pu8CurrByte, pstrStationParam->au8BSSID, ETH_ALEN);
+ pu8CurrByte += ETH_ALEN;
+
+ *pu8CurrByte++ = pstrStationParam->u16AssocID & 0xFF;
+ *pu8CurrByte++ = (pstrStationParam->u16AssocID >> 8) & 0xFF;
+
+ *pu8CurrByte++ = pstrStationParam->u8NumRates;
+ if (pstrStationParam->u8NumRates > 0) {
+ WILC_memcpy(pu8CurrByte, pstrStationParam->pu8Rates, pstrStationParam->u8NumRates);
+ }
+ pu8CurrByte += pstrStationParam->u8NumRates;
+
+ *pu8CurrByte++ = pstrStationParam->bIsHTSupported;
+ *pu8CurrByte++ = pstrStationParam->u16HTCapInfo & 0xFF;
+ *pu8CurrByte++ = (pstrStationParam->u16HTCapInfo >> 8) & 0xFF;
+
+ *pu8CurrByte++ = pstrStationParam->u8AmpduParams;
+ WILC_memcpy(pu8CurrByte, pstrStationParam->au8SuppMCsSet, WILC_SUPP_MCS_SET_SIZE);
+ pu8CurrByte += WILC_SUPP_MCS_SET_SIZE;
+
+ *pu8CurrByte++ = pstrStationParam->u16HTExtParams & 0xFF;
+ *pu8CurrByte++ = (pstrStationParam->u16HTExtParams >> 8) & 0xFF;
+
+ *pu8CurrByte++ = pstrStationParam->u32TxBeamformingCap & 0xFF;
+ *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 8) & 0xFF;
+ *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 16) & 0xFF;
+ *pu8CurrByte++ = (pstrStationParam->u32TxBeamformingCap >> 24) & 0xFF;
+
+ *pu8CurrByte++ = pstrStationParam->u8ASELCap;
+
+ *pu8CurrByte++ = pstrStationParam->u16FlagsMask & 0xFF;
+ *pu8CurrByte++ = (pstrStationParam->u16FlagsMask >> 8) & 0xFF;
+
+ *pu8CurrByte++ = pstrStationParam->u16FlagsSet & 0xFF;
+ *pu8CurrByte++ = (pstrStationParam->u16FlagsSet >> 8) & 0xFF;
+
+ return pu8CurrByte - pu8Buffer;
+}
+
+/**
+ * @brief Handle_AddStation
+ * @details Sending config packet to add station
+ * @param[in] tstrWILC_AddStaParam* pstrStationParam
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_AddStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ u8 *pu8CurrByte;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ PRINT_D(HOSTINF_DBG, "Handling add station\n");
+ strWID.u16WIDid = (WILC_Uint16)WID_ADD_STA;
+ strWID.enuWIDtype = WID_BIN;
+ strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
+
+ strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWID.ps8WidVal;
+ pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error != WILC_SUCCESS) {
+
+ PRINT_ER("Failed to send add station config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates);
+ WILC_FREE_IF_TRUE(strWID.ps8WidVal);
+}
+
+/**
+ * @brief Handle_DelAllSta
+ * @details Sending config packet to delete station
+ * @param[in] tstrHostIFDelSta* pstrDelStaParam
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_DelAllSta(void *drvHandler, tstrHostIFDelAllSta *pstrDelAllStaParam)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ u8 *pu8CurrByte;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ u8 i;
+ UWORD8 au8Zero_Buff[6] = {0};
+ strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_STA;
+ strWID.enuWIDtype = WID_STR;
+ strWID.s32ValueSize = (pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1;
+
+ PRINT_D(HOSTINF_DBG, "Handling delete station \n");
+
+ strWID.ps8WidVal = WILC_MALLOC((pstrDelAllStaParam->u8Num_AssocSta * ETH_ALEN) + 1);
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWID.ps8WidVal;
+
+ *(pu8CurrByte++) = pstrDelAllStaParam->u8Num_AssocSta;
+
+ for (i = 0; i < MAX_NUM_STA; i++) {
+ if (memcmp(pstrDelAllStaParam->au8Sta_DelAllSta[i], au8Zero_Buff, ETH_ALEN))
+ WILC_memcpy(pu8CurrByte, pstrDelAllStaParam->au8Sta_DelAllSta[i], ETH_ALEN);
+ else
+ continue;
+
+ pu8CurrByte += ETH_ALEN;
+ }
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+
+ PRINT_ER("Failed to send add station config packe\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ WILC_FREE_IF_TRUE(strWID.ps8WidVal);
+
+ up(&hWaitResponse);
+}
+
+
+/**
+ * @brief Handle_DelStation
+ * @details Sending config packet to delete station
+ * @param[in] tstrHostIFDelSta* pstrDelStaParam
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_DelStation(void *drvHandler, tstrHostIFDelSta *pstrDelStaParam)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ u8 *pu8CurrByte;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_STA;
+ strWID.enuWIDtype = WID_BIN;
+ strWID.s32ValueSize = ETH_ALEN;
+
+ PRINT_D(HOSTINF_DBG, "Handling delete station \n");
+
+ strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWID.ps8WidVal;
+
+ WILC_memcpy(pu8CurrByte, pstrDelStaParam->au8MacAddr, ETH_ALEN);
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+
+ PRINT_ER("Failed to send add station config packe\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ WILC_FREE_IF_TRUE(strWID.ps8WidVal);
+}
+
+
+/**
+ * @brief Handle_EditStation
+ * @details Sending config packet to edit station
+ * @param[in] tstrWILC_AddStaParam* pstrStationParam
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_EditStation(void *drvHandler, tstrWILC_AddStaParam *pstrStationParam)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ u8 *pu8CurrByte;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ strWID.u16WIDid = (WILC_Uint16)WID_EDIT_STA;
+ strWID.enuWIDtype = WID_BIN;
+ strWID.s32ValueSize = WILC_ADD_STA_LENGTH + pstrStationParam->u8NumRates;
+
+ PRINT_D(HOSTINF_DBG, "Handling edit station\n");
+ strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWID.ps8WidVal;
+ pu8CurrByte += WILC_HostIf_PackStaParam(pu8CurrByte, pstrStationParam);
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+
+ PRINT_ER("Failed to send edit station config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ WILC_FREE_IF_TRUE(pstrStationParam->pu8Rates);
+ WILC_FREE_IF_TRUE(strWID.ps8WidVal);
+}
+#endif /*WILC_AP_EXTERNAL_MLME*/
+
+#ifdef WILC_P2P
+/**
+ * @brief Handle_RemainOnChan
+ * @details Sending config packet to edit station
+ * @param[in] tstrWILC_AddStaParam* pstrStationParam
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static int Handle_RemainOnChan(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ u8 u8remain_on_chan_flag;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
+
+ /*If it's a pendig remain-on-channel, don't overwrite gWFiDrvHandle values (since incoming msg is garbbage)*/
+ if (!pstrWFIDrv->u8RemainOnChan_pendingreq) {
+ pstrWFIDrv->strHostIfRemainOnChan.pVoid = pstrHostIfRemainOnChan->pVoid;
+ pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired = pstrHostIfRemainOnChan->pRemainOnChanExpired;
+ pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady = pstrHostIfRemainOnChan->pRemainOnChanReady;
+ pstrWFIDrv->strHostIfRemainOnChan.u16Channel = pstrHostIfRemainOnChan->u16Channel;
+ pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID = pstrHostIfRemainOnChan->u32ListenSessionID;
+ } else {
+ /*Set the channel to use it as a wid val*/
+ pstrHostIfRemainOnChan->u16Channel = pstrWFIDrv->strHostIfRemainOnChan.u16Channel;
+ }
+
+ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
+ PRINT_INFO(GENERIC_DBG, "Required to remain on chan while scanning return\n");
+ pstrWFIDrv->u8RemainOnChan_pendingreq = 1;
+ WILC_ERRORREPORT(s32Error, WILC_BUSY);
+ }
+ if (pstrWFIDrv->enuHostIFstate == HOST_IF_WAITING_CONN_RESP) {
+ PRINT_INFO(GENERIC_DBG, "Required to remain on chan while connecting return\n");
+ WILC_ERRORREPORT(s32Error, WILC_BUSY);
+ }
+
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ if (g_obtainingIP || connecting) {
+ PRINT_D(GENERIC_DBG, "[handle_scan]: Don't do obss scan until IP adresss is obtained\n");
+ WILC_ERRORREPORT(s32Error, WILC_BUSY);
+ }
+ #endif
+
+ PRINT_D(HOSTINF_DBG, "Setting channel :%d\n", pstrHostIfRemainOnChan->u16Channel);
+
+ u8remain_on_chan_flag = WILC_TRUE;
+ strWID.u16WIDid = (WILC_Uint16)WID_REMAIN_ON_CHAN;
+ strWID.enuWIDtype = WID_STR;
+ strWID.s32ValueSize = 2;
+ strWID.ps8WidVal = (WILC_Sint8 *)WILC_MALLOC(strWID.s32ValueSize);
+
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ strWID.ps8WidVal[0] = u8remain_on_chan_flag;
+ strWID.ps8WidVal[1] = (WILC_Sint8)pstrHostIfRemainOnChan->u16Channel;
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error != WILC_SUCCESS) {
+ PRINT_ER("Failed to set remain on channel\n");
+ }
+
+ WILC_CATCH(-1)
+ {
+ P2P_LISTEN_STATE = 1;
+ WILC_TimerStart(&(pstrWFIDrv->hRemainOnChannel), pstrHostIfRemainOnChan->u32duration, (void *)pstrWFIDrv, NULL);
+
+ /*Calling CFG ready_on_channel*/
+ if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady) {
+ pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanReady(pstrWFIDrv->strHostIfRemainOnChan.pVoid);
+ }
+
+ if (pstrWFIDrv->u8RemainOnChan_pendingreq)
+ pstrWFIDrv->u8RemainOnChan_pendingreq = 0;
+ }
+ return s32Error;
+}
+
+/**
+ * @brief Handle_RegisterFrame
+ * @details
+ * @param[in]
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static int Handle_RegisterFrame(void *drvHandler, tstrHostIfRegisterFrame *pstrHostIfRegisterFrame)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ u8 *pu8CurrByte;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ PRINT_D(HOSTINF_DBG, "Handling frame register Flag : %d FrameType: %d\n", pstrHostIfRegisterFrame->bReg, pstrHostIfRegisterFrame->u16FrameType);
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_REGISTER_FRAME;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = WILC_MALLOC(sizeof(WILC_Uint16) + 2);
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWID.ps8WidVal;
+
+ *pu8CurrByte++ = pstrHostIfRegisterFrame->bReg;
+ *pu8CurrByte++ = pstrHostIfRegisterFrame->u8Regid;
+ WILC_memcpy(pu8CurrByte, &(pstrHostIfRegisterFrame->u16FrameType), sizeof(WILC_Uint16));
+
+
+ strWID.s32ValueSize = sizeof(WILC_Uint16) + 2;
+
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to frame register config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ }
+
+
+ WILC_CATCH(s32Error)
+ {
+ }
+
+ return s32Error;
+
+}
+
+/**
+ * @brief Handle_ListenStateExpired
+ * @details Handle of listen state expiration
+ * @param[in] NONE
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+#define FALSE_FRMWR_CHANNEL 100
+static WILC_Uint32 Handle_ListenStateExpired(void *drvHandler, tstrHostIfRemainOnChan *pstrHostIfRemainOnChan)
+{
+ u8 u8remain_on_chan_flag;
+ tstrWID strWID;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *) drvHandler;
+
+ PRINT_D(HOSTINF_DBG, "CANCEL REMAIN ON CHAN\n");
+
+ /*BugID_5477*/
+ /*Make sure we are already in listen state*/
+ /*This is to handle duplicate expiry messages (listen timer fired and supplicant called cancel_remain_on_channel())*/
+ if (P2P_LISTEN_STATE) {
+ u8remain_on_chan_flag = WILC_FALSE;
+ strWID.u16WIDid = (WILC_Uint16)WID_REMAIN_ON_CHAN;
+ strWID.enuWIDtype = WID_STR;
+ strWID.s32ValueSize = 2;
+ strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
+
+ if (strWID.ps8WidVal == NULL) {
+ PRINT_ER("Failed to allocate memory\n");
+ }
+
+ strWID.ps8WidVal[0] = u8remain_on_chan_flag;
+ strWID.ps8WidVal[1] = FALSE_FRMWR_CHANNEL;
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error != WILC_SUCCESS) {
+ PRINT_ER("Failed to set remain on channel\n");
+ goto _done_;
+ }
+
+ if (pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired) {
+ pstrWFIDrv->strHostIfRemainOnChan.pRemainOnChanExpired(pstrWFIDrv->strHostIfRemainOnChan.pVoid
+ , pstrHostIfRemainOnChan->u32ListenSessionID);
+ }
+ P2P_LISTEN_STATE = 0;
+ } else {
+ PRINT_D(GENERIC_DBG, "Not in listen state\n");
+ s32Error = WILC_FAIL;
+ }
+
+_done_:
+ return s32Error;
+}
+
+
+/**
+ * @brief ListenTimerCB
+ * @details Callback function of remain-on-channel timer
+ * @param[in] NONE
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void ListenTimerCB(void *pvArg)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
+ /*Stopping remain-on-channel timer*/
+ WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
+
+ /* prepare the Timer Callback message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
+ strHostIFmsg.drvHandler = pstrWFIDrv;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = pstrWFIDrv->strHostIfRemainOnChan.u32ListenSessionID;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+}
+#endif
+
+
+/**
+ * @brief Handle_EditStation
+ * @details Sending config packet to edit station
+ * @param[in] tstrWILC_AddStaParam* pstrStationParam
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static void Handle_PowerManagement(void *drvHandler, tstrHostIfPowerMgmtParam *strPowerMgmtParam)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ WILC_Sint8 s8PowerMode;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ strWID.u16WIDid = (WILC_Uint16)WID_POWER_MANAGEMENT;
+
+ if (strPowerMgmtParam->bIsEnabled == WILC_TRUE) {
+ s8PowerMode = MIN_FAST_PS;
+ } else {
+ s8PowerMode = NO_POWERSAVE;
+ }
+ PRINT_D(HOSTINF_DBG, "Handling power mgmt to %d\n", s8PowerMode);
+ strWID.ps8WidVal = &s8PowerMode;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ PRINT_D(HOSTINF_DBG, "Handling Power Management\n");
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to send power management config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+}
+
+/**
+ * @brief Handle_SetMulticastFilter
+ * @details Set Multicast filter in firmware
+ * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
+ * @return NONE
+ * @author asobhy
+ * @date
+ * @version 1.0
+ */
+static void Handle_SetMulticastFilter(void *drvHandler, tstrHostIFSetMulti *strHostIfSetMulti)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ u8 *pu8CurrByte;
+
+ PRINT_D(HOSTINF_DBG, "Setup Multicast Filter\n");
+
+ strWID.u16WIDid = (WILC_Uint16)WID_SETUP_MULTICAST_FILTER;
+ strWID.enuWIDtype = WID_BIN;
+ strWID.s32ValueSize = sizeof(tstrHostIFSetMulti) + ((strHostIfSetMulti->u32count) * ETH_ALEN);
+ strWID.ps8WidVal = WILC_MALLOC(strWID.s32ValueSize);
+ if (strWID.ps8WidVal == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+
+ pu8CurrByte = strWID.ps8WidVal;
+ *pu8CurrByte++ = (strHostIfSetMulti->bIsEnabled & 0xFF);
+ *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 8) & 0xFF);
+ *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 16) & 0xFF);
+ *pu8CurrByte++ = ((strHostIfSetMulti->bIsEnabled >> 24) & 0xFF);
+
+ *pu8CurrByte++ = (strHostIfSetMulti->u32count & 0xFF);
+ *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 8) & 0xFF);
+ *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 16) & 0xFF);
+ *pu8CurrByte++ = ((strHostIfSetMulti->u32count >> 24) & 0xFF);
+
+ if ((strHostIfSetMulti->u32count) > 0)
+ memcpy(pu8CurrByte, gau8MulticastMacAddrList, ((strHostIfSetMulti->u32count) * ETH_ALEN));
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_FALSE, (WILC_Uint32)drvHandler);
+ if (s32Error) {
+ PRINT_ER("Failed to send setup multicast config packet\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ WILC_FREE_IF_TRUE(strWID.ps8WidVal);
+
+}
+
+
+/*BugID_5222*/
+/**
+ * @brief Handle_AddBASession
+ * @details Add block ack session
+ * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
+ * @return NONE
+ * @author Amr Abdel-Moghny
+ * @date Feb. 2014
+ * @version 9.0
+ */
+static WILC_Sint32 Handle_AddBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ int AddbaTimeout = 100;
+ char *ptr = NULL;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ PRINT_D(HOSTINF_DBG, "Opening Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d \nBufferSize == %d \nSessionTimeOut = %d\n",
+ strHostIfBASessionInfo->au8Bssid[0],
+ strHostIfBASessionInfo->au8Bssid[1],
+ strHostIfBASessionInfo->au8Bssid[2],
+ strHostIfBASessionInfo->u16BufferSize,
+ strHostIfBASessionInfo->u16SessionTimeout,
+ strHostIfBASessionInfo->u8Ted);
+
+ strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
+ strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
+ ptr = strWID.ps8WidVal;
+ /* *ptr++ = 0x14; */
+ *ptr++ = 0x14;
+ *ptr++ = 0x3;
+ *ptr++ = 0x0;
+ WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
+ ptr += ETH_ALEN;
+ *ptr++ = strHostIfBASessionInfo->u8Ted;
+ /* BA Policy*/
+ *ptr++ = 1;
+ /* Buffer size*/
+ *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
+ *ptr++ = ((strHostIfBASessionInfo->u16BufferSize >> 16) & 0xFF);
+ /* BA timeout*/
+ *ptr++ = (strHostIfBASessionInfo->u16SessionTimeout & 0xFF);
+ *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
+ /* ADDBA timeout*/
+ *ptr++ = (AddbaTimeout & 0xFF);
+ *ptr++ = ((AddbaTimeout >> 16) & 0xFF);
+ /* Group Buffer Max Frames*/
+ *ptr++ = 8;
+ /* Group Buffer Timeout */
+ *ptr++ = 0;
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error)
+ PRINT_D(HOSTINF_DBG, "Couldn't open BA Session\n");
+
+
+ strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ;
+ strWID.enuWIDtype = WID_STR;
+ strWID.s32ValueSize = 15;
+ ptr = strWID.ps8WidVal;
+ /* *ptr++ = 0x14; */
+ *ptr++ = 15;
+ *ptr++ = 7;
+ *ptr++ = 0x2;
+ WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
+ ptr += ETH_ALEN;
+ /* TID*/
+ *ptr++ = strHostIfBASessionInfo->u8Ted;
+ /* Max Num MSDU */
+ *ptr++ = 8;
+ /* BA timeout*/
+ *ptr++ = (strHostIfBASessionInfo->u16BufferSize & 0xFF);
+ *ptr++ = ((strHostIfBASessionInfo->u16SessionTimeout >> 16) & 0xFF);
+ /*Ack-Policy */
+ *ptr++ = 3;
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+ if (strWID.ps8WidVal != NULL)
+ WILC_FREE(strWID.ps8WidVal);
+
+ return s32Error;
+
+}
+
+
+/*BugID_5222*/
+/**
+ * @brief Handle_DelBASession
+ * @details Delete block ack session
+ * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
+ * @return NONE
+ * @author Amr Abdel-Moghny
+ * @date Feb. 2013
+ * @version 9.0
+ */
+static WILC_Sint32 Handle_DelBASession(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ char *ptr = NULL;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
+ strHostIfBASessionInfo->au8Bssid[0],
+ strHostIfBASessionInfo->au8Bssid[1],
+ strHostIfBASessionInfo->au8Bssid[2],
+ strHostIfBASessionInfo->u8Ted);
+
+ strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
+ strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
+ ptr = strWID.ps8WidVal;
+ /* *ptr++ = 0x14; */
+ *ptr++ = 0x14;
+ *ptr++ = 0x3;
+ *ptr++ = 0x2;
+ WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
+ ptr += ETH_ALEN;
+ *ptr++ = strHostIfBASessionInfo->u8Ted;
+ /* BA direction = recipent*/
+ *ptr++ = 0;
+ /* Delba Reason */
+ *ptr++ = 32; /* Unspecific QOS reason */
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error)
+ PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
+
+
+ strWID.u16WIDid = (WILC_Uint16)WID_11E_P_ACTION_REQ;
+ strWID.enuWIDtype = WID_STR;
+ strWID.s32ValueSize = 15;
+ ptr = strWID.ps8WidVal;
+ /* *ptr++ = 0x14; */
+ *ptr++ = 15;
+ *ptr++ = 7;
+ *ptr++ = 0x3;
+ WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
+ ptr += ETH_ALEN;
+ /* TID*/
+ *ptr++ = strHostIfBASessionInfo->u8Ted;
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+ if (strWID.ps8WidVal != NULL)
+ WILC_FREE(strWID.ps8WidVal);
+
+ /*BugID_5222*/
+ up(&hWaitResponse);
+
+ return s32Error;
+
+}
+
+
+/**
+ * @brief Handle_DelAllRxBASessions
+ * @details Delete all Rx BA sessions
+ * @param[in] tstrHostIFSetMulti* strHostIfSetMulti
+ * @return NONE
+ * @author Abdelrahman Sobhy
+ * @date Feb. 2013
+ * @version 9.0
+ */
+static WILC_Sint32 Handle_DelAllRxBASessions(void *drvHandler, tstrHostIfBASessionInfo *strHostIfBASessionInfo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ char *ptr = NULL;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+ PRINT_D(GENERIC_DBG, "Delete Block Ack session with\nBSSID = %.2x:%.2x:%.2x \nTID=%d\n",
+ strHostIfBASessionInfo->au8Bssid[0],
+ strHostIfBASessionInfo->au8Bssid[1],
+ strHostIfBASessionInfo->au8Bssid[2],
+ strHostIfBASessionInfo->u8Ted);
+
+ strWID.u16WIDid = (WILC_Uint16)WID_DEL_ALL_RX_BA;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (u8 *)WILC_MALLOC(BLOCK_ACK_REQ_SIZE);
+ strWID.s32ValueSize = BLOCK_ACK_REQ_SIZE;
+ ptr = strWID.ps8WidVal;
+ *ptr++ = 0x14;
+ *ptr++ = 0x3;
+ *ptr++ = 0x2;
+ WILC_memcpy(ptr, strHostIfBASessionInfo->au8Bssid, ETH_ALEN);
+ ptr += ETH_ALEN;
+ *ptr++ = strHostIfBASessionInfo->u8Ted;
+ /* BA direction = recipent*/
+ *ptr++ = 0;
+ /* Delba Reason */
+ *ptr++ = 32; /* Unspecific QOS reason */
+
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error)
+ PRINT_D(HOSTINF_DBG, "Couldn't delete BA Session\n");
+
+
+ if (strWID.ps8WidVal != NULL)
+ WILC_FREE(strWID.ps8WidVal);
+
+ /*BugID_5222*/
+ up(&hWaitResponse);
+
+ return s32Error;
+
+}
+
+/**
+ * @brief hostIFthread
+ * @details Main thread to handle message queue requests
+ * @param[in] void* pvArg
+ * @return NONE
+ * @author
+ * @date
+ * @version 1.0
+ */
+static int hostIFthread(void *pvArg)
+{
+ WILC_Uint32 u32Ret;
+ tstrHostIFmsg strHostIFmsg;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ while (1) {
+ WILC_MsgQueueRecv(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), &u32Ret, NULL);
+ pstrWFIDrv = (tstrWILC_WFIDrv *)strHostIFmsg.drvHandler;
+ if (strHostIFmsg.u16MsgId == HOST_IF_MSG_EXIT) {
+ PRINT_D(GENERIC_DBG, "THREAD: Exiting HostIfThread\n");
+ break;
+ }
+
+
+ /*Re-Queue HIF message*/
+ if ((!g_wilc_initialized)) {
+ PRINT_D(GENERIC_DBG, "--WAIT--");
+ WILC_Sleep(200);
+ WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ continue;
+ }
+
+ if (strHostIFmsg.u16MsgId == HOST_IF_MSG_CONNECT && pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult != NULL) {
+ PRINT_D(HOSTINF_DBG, "Requeue connect request till scan done received\n");
+ WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ WILC_Sleep(2);
+ continue;
+ }
+
+ switch (strHostIFmsg.u16MsgId) {
+ case HOST_IF_MSG_Q_IDLE:
+ Handle_wait_msg_q_empty();
+ break;
+
+ case HOST_IF_MSG_SCAN:
+ Handle_Scan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr);
+ break;
+
+ case HOST_IF_MSG_CONNECT:
+ Handle_Connect(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr);
+ break;
+
+ /*BugID_5137*/
+ case HOST_IF_MSG_FLUSH_CONNECT:
+ Handle_FlushConnect(strHostIFmsg.drvHandler);
+ break;
+
+ case HOST_IF_MSG_RCVD_NTWRK_INFO:
+ Handle_RcvdNtwrkInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo);
+ break;
+
+ case HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO:
+ Handle_RcvdGnrlAsyncInfo(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo);
+ break;
+
+ case HOST_IF_MSG_KEY:
+ Handle_Key(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr);
+ break;
+
+ case HOST_IF_MSG_CFG_PARAMS:
+
+ Handle_CfgParam(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr);
+ break;
+
+ case HOST_IF_MSG_SET_CHANNEL:
+ Handle_SetChannel(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan);
+ break;
+
+ case HOST_IF_MSG_DISCONNECT:
+ Handle_Disconnect(strHostIFmsg.drvHandler);
+ break;
+
+ case HOST_IF_MSG_RCVD_SCAN_COMPLETE:
+ WILC_TimerStop(&(pstrWFIDrv->hScanTimer), NULL);
+ PRINT_D(HOSTINF_DBG, "scan completed successfully\n");
+
+ /*BugID_5213*/
+ /*Allow chip sleep, only if both interfaces are not connected*/
+ if (!linux_wlan_get_num_conn_ifcs()) {
+ chip_sleep_manually(INFINITE_SLEEP_TIME);
+ }
+
+ Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_DONE);
+
+ #ifdef WILC_P2P
+ if (pstrWFIDrv->u8RemainOnChan_pendingreq)
+ Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
+ #endif
+
+ break;
+
+ case HOST_IF_MSG_GET_RSSI:
+ Handle_GetRssi(strHostIFmsg.drvHandler);
+ break;
+
+ case HOST_IF_MSG_GET_LINKSPEED:
+ Handle_GetLinkspeed(strHostIFmsg.drvHandler);
+ break;
+
+ case HOST_IF_MSG_GET_STATISTICS:
+ Handle_GetStatistics(strHostIFmsg.drvHandler, (tstrStatistics *)strHostIFmsg.uniHostIFmsgBody.pUserData);
+ break;
+
+ case HOST_IF_MSG_GET_CHNL:
+ Handle_GetChnl(strHostIFmsg.drvHandler);
+ break;
+
+#ifdef WILC_AP_EXTERNAL_MLME
+ case HOST_IF_MSG_ADD_BEACON:
+ Handle_AddBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon);
+ break;
+
+ case HOST_IF_MSG_DEL_BEACON:
+ Handle_DelBeacon(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelBeacon);
+ break;
+
+ case HOST_IF_MSG_ADD_STATION:
+ Handle_AddStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strAddStaParam);
+ break;
+
+ case HOST_IF_MSG_DEL_STATION:
+ Handle_DelStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strDelStaParam);
+ break;
+
+ case HOST_IF_MSG_EDIT_STATION:
+ Handle_EditStation(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strEditStaParam);
+ break;
+
+ case HOST_IF_MSG_GET_INACTIVETIME:
+ Handle_Get_InActiveTime(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT);
+ break;
+
+#endif /*WILC_AP_EXTERNAL_MLME*/
+ case HOST_IF_MSG_SCAN_TIMER_FIRED:
+ PRINT_D(HOSTINF_DBG, "Scan Timeout\n");
+
+ Handle_ScanDone(strHostIFmsg.drvHandler, SCAN_EVENT_ABORTED);
+ break;
+
+ case HOST_IF_MSG_CONNECT_TIMER_FIRED:
+ PRINT_D(HOSTINF_DBG, "Connect Timeout \n");
+ Handle_ConnectTimeout(strHostIFmsg.drvHandler);
+ break;
+
+ case HOST_IF_MSG_POWER_MGMT:
+ Handle_PowerManagement(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam);
+ break;
+
+ case HOST_IF_MSG_SET_WFIDRV_HANDLER:
+ Handle_SetWfiDrvHandler(&strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler);
+ break;
+
+ case HOST_IF_MSG_SET_OPERATION_MODE:
+ Handle_SetOperationMode(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode);
+ break;
+
+ case HOST_IF_MSG_SET_IPADDRESS:
+ PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
+ Handle_set_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
+ break;
+
+ case HOST_IF_MSG_GET_IPADDRESS:
+ PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_IPADDRESS\n");
+ Handle_get_IPAddress(strHostIFmsg.drvHandler, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr, strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx);
+ break;
+
+ /*BugID_5077*/
+ case HOST_IF_MSG_SET_MAC_ADDRESS:
+ Handle_SetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress);
+ break;
+
+ /*BugID_5213*/
+ case HOST_IF_MSG_GET_MAC_ADDRESS:
+ Handle_GetMacAddress(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress);
+ break;
+
+#ifdef WILC_P2P
+ case HOST_IF_MSG_REMAIN_ON_CHAN:
+ PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REMAIN_ON_CHAN\n");
+ Handle_RemainOnChan(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
+ break;
+
+ case HOST_IF_MSG_REGISTER_FRAME:
+ PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_REGISTER_FRAME\n");
+ Handle_RegisterFrame(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame);
+ break;
+
+ case HOST_IF_MSG_LISTEN_TIMER_FIRED:
+ Handle_ListenStateExpired(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan);
+ break;
+
+ #endif
+ case HOST_IF_MSG_SET_MULTICAST_FILTER:
+ PRINT_D(HOSTINF_DBG, "HOST_IF_MSG_SET_MULTICAST_FILTER\n");
+ Handle_SetMulticastFilter(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti);
+ break;
+
+ /*BugID_5222*/
+ case HOST_IF_MSG_ADD_BA_SESSION:
+ Handle_AddBASession(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
+ break;
+
+ case HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS:
+ Handle_DelAllRxBASessions(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo);
+ break;
+
+ case HOST_IF_MSG_DEL_ALL_STA:
+ Handle_DelAllSta(strHostIFmsg.drvHandler, &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta);
+ break;
+
+ default:
+ PRINT_ER("[Host Interface] undefined Received Msg ID \n");
+ break;
+ }
+ }
+
+ PRINT_D(HOSTINF_DBG, "Releasing thread exit semaphore\n");
+ up(&hSemHostIFthrdEnd);
+ return 0;
+}
+
+static void TimerCB_Scan(void *pvArg)
+{
+ tstrHostIFmsg strHostIFmsg;
+
+ /* prepare the Timer Callback message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.drvHandler = pvArg;
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN_TIMER_FIRED;
+
+ /* send the message */
+ WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+}
+
+static void TimerCB_Connect(void *pvArg)
+{
+ tstrHostIFmsg strHostIFmsg;
+
+ /* prepare the Timer Callback message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.drvHandler = pvArg;
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT_TIMER_FIRED;
+
+ /* send the message */
+ WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+}
+
+
+/**
+ * @brief removes wpa/wpa2 keys
+ * @details only in BSS STA mode if External Supplicant support is enabled.
+ * removes all WPA/WPA2 station key entries from MAC hardware.
+ * @param[in,out] handle to the wifi driver
+ * @param[in] 6 bytes of Station Adress in the station entry table
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+/* Check implementation in core adding 9 bytes to the input! */
+WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ strWID.u16WIDid = (WILC_Uint16)WID_REMOVE_KEY;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = (WILC_Sint8 *)pu8StaAddress;
+ strWID.s32ValueSize = 6;
+
+ return s32Error;
+
+}
+
+/**
+ * @brief removes WEP key
+ * @details valid only in BSS STA mode if External Supplicant support is enabled.
+ * remove a WEP key entry from MAC HW.
+ * The BSS Station automatically finds the index of the entry using its
+ * BSS ID and removes that entry from the MAC hardware.
+ * @param[in,out] handle to the wifi driver
+ * @param[in] 6 bytes of Station Adress in the station entry table
+ * @return Error code indicating success/failure
+ * @note NO need for the STA add since it is not used for processing
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8keyIdx)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* prepare the Remove Wep Key Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = REMOVEKEY;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8keyIdx;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER("Error in sending message queue : Request to remove WEP key \n");
+ down(&(pstrWFIDrv->hSemTestKeyBlock));
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+}
+
+/**
+ * @brief sets WEP default key
+ * @details Sets the index of the WEP encryption key in use,
+ * in the key table
+ * @param[in,out] handle to the wifi driver
+ * @param[in] key index ( 0, 1, 2, 3)
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* prepare the Key Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = DEFAULTKEY;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Index;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER("Error in sending message queue : Default key index\n");
+ down(&(pstrWFIDrv->hSemTestKeyBlock));
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief sets WEP deafault key
+ * @details valid only in BSS STA mode if External Supplicant support is enabled.
+ * sets WEP key entry into MAC hardware when it receives the
+ * corresponding request from NDIS.
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing WEP Key in the following format
+ *|---------------------------------------|
+ *|Key ID Value | Key Length | Key |
+ *|-------------|------------|------------|
+ | 1byte | 1byte | Key Length |
+ ||---------------------------------------|
+ |
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+
+ }
+
+ /* prepare the Key Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC(u8WepKeylen);
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
+ pu8WepKey, u8WepKeylen);
+
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER("Error in sending message queue :WEP Key\n");
+ down(&(pstrWFIDrv->hSemTestKeyBlock));
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+
+}
+
+#ifdef WILC_AP_EXTERNAL_MLME
+/**
+ *
+ * @brief host_int_add_wep_key_bss_ap
+ * @details valid only in BSS AP mode if External Supplicant support is enabled.
+ * sets WEP key entry into MAC hardware when it receives the
+ *
+ * corresponding request from NDIS.
+ * @param[in,out] handle to the wifi driver
+ *
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author mdaftedar
+ * @date 28 FEB 2013
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ u8 i;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+
+ }
+
+ /* prepare the Key Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ if (INFO) {
+ for (i = 0; i < u8WepKeylen; i++)
+ PRINT_INFO(HOSTAPD_DBG, "KEY is %x\n", pu8WepKey[i]);
+ }
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WEP;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey = (u8 *)WILC_MALLOC((u8WepKeylen));
+
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwepAttr.pu8WepKey,
+ pu8WepKey, (u8WepKeylen));
+
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.u8WepKeylen = (u8WepKeylen);
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.u8Wepidx = u8Keyidx;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.u8mode = u8mode;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwepAttr.tenuAuth_type = tenuAuth_type;
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+
+ if (s32Error)
+ PRINT_ER("Error in sending message queue :WEP Key\n");
+ down(&(pstrWFIDrv->hSemTestKeyBlock));
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+
+}
+#endif
+/**
+ * @brief adds ptk Key
+ * @details
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing PTK Key in the following format
+ *|-----------------------------------------------------------------------------|
+ *|Station address | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
+ *|----------------|------------|--------------|----------------|---------------|
+ | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
+ ||-----------------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
+ const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ u8 u8KeyLen = u8PtkKeylen;
+ WILC_Uint32 i;
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ if (pu8RxMic != NULL) {
+ u8KeyLen += RX_MIC_KEY_LEN;
+ }
+ if (pu8TxMic != NULL) {
+ u8KeyLen += TX_MIC_KEY_LEN;
+ }
+
+ /* prepare the Key Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPAPtk;
+ #ifdef WILC_AP_EXTERNAL_MLME
+ if (mode == AP_MODE) {
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8Idx;
+ }
+ #endif
+ if (mode == STATION_MODE)
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
+
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8PtkKeylen);
+
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
+ pu8Ptk, u8PtkKeylen);
+
+ if (pu8RxMic != NULL) {
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
+ pu8RxMic, RX_MIC_KEY_LEN);
+ if (INFO) {
+ for (i = 0; i < RX_MIC_KEY_LEN; i++)
+ PRINT_INFO(CFG80211_DBG, "PairwiseRx[%d] = %x\n", i, pu8RxMic[i]);
+ }
+ }
+ if (pu8TxMic != NULL) {
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
+ pu8TxMic, TX_MIC_KEY_LEN);
+ if (INFO) {
+ for (i = 0; i < TX_MIC_KEY_LEN; i++)
+ PRINT_INFO(CFG80211_DBG, "PairwiseTx[%d] = %x\n", i, pu8TxMic[i]);
+ }
+ }
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.pu8macaddr = mac_addr;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+
+ if (s32Error)
+ PRINT_ER("Error in sending message queue: PTK Key\n");
+
+ /* ////////////// */
+ down(&(pstrWFIDrv->hSemTestKeyBlock));
+ /* WILC_Sleep(100); */
+ /* /////// */
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief adds Rx GTk Key
+ * @details
+ * @param[in,out] handle to the wifi driver
+ * @param[in] pu8RxGtk : contains temporal key | Rx Mic | Tx Mic
+ * u8GtkKeylen :The total key length
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
+ u8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, const u8 *KeyRSC,
+ const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ u8 u8KeyLen = u8GtkKeylen;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ /* prepare the Key Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ if (pu8RxMic != NULL) {
+ u8KeyLen += RX_MIC_KEY_LEN;
+ }
+ if (pu8TxMic != NULL) {
+ u8KeyLen += TX_MIC_KEY_LEN;
+ }
+ if (KeyRSC != NULL) {
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq = (u8 *)WILC_MALLOC(u32KeyRSClen);
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8seq,
+ KeyRSC, u32KeyRSClen);
+ }
+
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPARxGtk;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ #ifdef WILC_AP_EXTERNAL_MLME
+ if (mode == AP_MODE) {
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY_AP;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Ciphermode = u8Ciphermode;
+ }
+ #endif
+ if (mode == STATION_MODE)
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
+
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8KeyLen);
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
+ pu8RxGtk, u8GtkKeylen);
+
+ if (pu8RxMic != NULL) {
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 16,
+ pu8RxMic, RX_MIC_KEY_LEN);
+
+ }
+ if (pu8TxMic != NULL) {
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key + 24,
+ pu8TxMic, TX_MIC_KEY_LEN);
+
+ }
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.u8keyidx = u8KeyIdx;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.u8seqlen = u32KeyRSClen;
+
+
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER("Error in sending message queue: RX GTK\n");
+ /* ////////////// */
+ down(&(pstrWFIDrv->hSemTestKeyBlock));
+ /* WILC_Sleep(100); */
+ /* /////// */
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+}
+#if 0
+/**
+ * @brief host_int_add_tx_gtk
+ * @details adds Tx GTk Key
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing Tx GTK Key in the following format
+ *|----------------------------------------------------|
+ | KeyID | Key Length | Temporal Key | Tx Michael Key |
+ ||-------|------------|--------------|----------------|
+ ||1 byte | 1 byte | 16 bytes | 8 bytes |
+ ||----------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8TxGtk, u8 u8KeyIdx)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* prepare the Key Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = WPATxGtk;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.
+ uniHostIFkeyAttr.strHostIFwpaAttr.pu8key = (u8 *)WILC_MALLOC(u8KeyLen);
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.pu8key,
+ pu8TxGtk, u8KeyLen);
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFwpaAttr.u8Keylen = u8KeyLen;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER("Error in sending message queue: TX GTK\n");
+
+ /* ////////////// */
+ down(&hSemTestKeyBlock);
+ WILC_Sleep(100);
+ /* /////// */
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+}
+#endif
+/**
+ * @brief host_int_set_pmkid_info
+ * @details caches the pmkid valid only in BSS STA mode if External Supplicant
+ * support is enabled. This Function sets the PMKID in firmware
+ * when host drivr receives the corresponding request from NDIS.
+ * The firmware then includes theset PMKID in the appropriate
+ * management frames
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing PMKID Info in the following format
+ *|-----------------------------------------------------------------|
+ *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
+ *|-----------|------------|----------|-------|----------|----------|
+ | 1 | 6 | 16 | ... | 6 | 16 |
+ ||-----------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ WILC_Uint32 i;
+
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* prepare the Key Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_KEY;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.enuKeyType = PMKSA;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.u8KeyAction = ADDKEY;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ for (i = 0; i < pu8PmkidInfoArray->numpmkid; i++) {
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].bssid, &pu8PmkidInfoArray->pmkidlist[i].bssid,
+ ETH_ALEN);
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFkeyAttr.uniHostIFkeyAttr.strHostIFpmkidAttr.pmkidlist[i].pmkid, &pu8PmkidInfoArray->pmkidlist[i].pmkid,
+ PMKID_LEN);
+ }
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER(" Error in sending messagequeue: PMKID Info\n");
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief gets the cached the pmkid info
+ * @details valid only in BSS STA mode if External Supplicant
+ * support is enabled. This Function sets the PMKID in firmware
+ * when host drivr receives the corresponding request from NDIS.
+ * The firmware then includes theset PMKID in the appropriate
+ * management frames
+ * @param[in,out] handle to the wifi driver,
+ * message containing PMKID Info in the following format
+ *|-----------------------------------------------------------------|
+ *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
+ *|-----------|------------|----------|-------|----------|----------|
+ | 1 | 6 | 16 | ... | 6 | 16 |
+ ||-----------------------------------------------------------------|
+ * @param[in]
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray,
+ WILC_Uint32 u32PmkidInfoLen)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ strWID.u16WIDid = (WILC_Uint16)WID_PMKID_INFO;
+ strWID.enuWIDtype = WID_STR;
+ strWID.s32ValueSize = u32PmkidInfoLen;
+ strWID.ps8WidVal = pu8PmkidInfoArray;
+
+ return s32Error;
+}
+
+/**
+ * @brief sets the pass phrase
+ * @details AP/STA mode. This function gives the pass phrase used to
+ * generate the Pre-Shared Key when WPA/WPA2 is enabled
+ * The length of the field can vary from 8 to 64 bytes,
+ * the lower layer should get the
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] String containing PSK
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase,
+ u8 u8Psklength)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ /* u8 u8Psklength = WILC_strlen(pu8PassPhrase); */
+ /*validating psk length*/
+ if ((u8Psklength > 7) && (u8Psklength < 65)) {
+ strWID.u16WIDid = (WILC_Uint16)WID_11I_PSK;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = pu8PassPhrase;
+ strWID.s32ValueSize = u8Psklength;
+ }
+
+ return s32Error;
+}
+/**
+ * @brief host_int_get_MacAddress
+ * @details gets mac address
+ * @param[in,out] handle to the wifi driver,
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author mdaftedar
+ * @date 19 April 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+
+
+ /* prepare the Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_MAC_ADDRESS;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfGetMacAddress.u8MacAddress = pu8MacAddress;
+ strHostIFmsg.drvHandler = hWFIDrv;
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Failed to send get mac address\n");
+ return WILC_FAIL;
+ }
+
+ down(&hWaitResponse);
+ return s32Error;
+}
+
+/**
+ * @brief host_int_set_MacAddress
+ * @details sets mac address
+ * @param[in,out] handle to the wifi driver,
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 16 July 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+
+ PRINT_D(GENERIC_DBG, "mac addr = %x:%x:%x\n", pu8MacAddress[0], pu8MacAddress[1], pu8MacAddress[2]);
+
+ /* prepare setting mac address message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MAC_ADDRESS;
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfSetMacAddress.u8MacAddress, pu8MacAddress, ETH_ALEN);
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Failed to send message queue: Set mac address\n");
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+
+}
+
+/**
+ * @brief host_int_get_RSNAConfigPSKPassPhrase
+ * @details gets the pass phrase:AP/STA mode. This function gets the pass phrase used to
+ * generate the Pre-Shared Key when WPA/WPA2 is enabled
+ * The length of the field can vary from 8 to 64 bytes,
+ * the lower layer should get the
+ * @param[in,out] handle to the wifi driver,
+ * String containing PSK
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv,
+ u8 *pu8PassPhrase, u8 u8Psklength)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ strWID.u16WIDid = (WILC_Uint16)WID_11I_PSK;
+ strWID.enuWIDtype = WID_STR;
+ strWID.s32ValueSize = u8Psklength;
+ strWID.ps8WidVal = pu8PassPhrase;
+
+ return s32Error;
+}
+
+/**
+ * @brief host_int_get_site_survey_results
+ * @details gets the site survey results
+ * @param[in,out] handle to the wifi driver,
+ * Message containing site survey results in the
+ * following format
+ *|---------------------------------------------------|
+ | MsgLength | fragNo. | MsgBodyLength | MsgBody |
+ ||-----------|-----------|---------------|-----------|
+ | 1 | 1 | 1 | 1 |
+ | ----------------------------------------- | ----------------
+ |
+ ||---------------------------------------|
+ | Network1 | Netweork2 | ... | Network5 |
+ ||---------------------------------------|
+ | 44 | 44 | ... | 44 |
+ | -------------------------- | ---------------------------------------
+ |
+ ||---------------------------------------------------------------------|
+ | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
+ |
+ |
+ ||------|----------|---------|----------------|-------|------|---------|
+ | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
+ ||---------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+#ifndef CONNECT_DIRECT
+WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv,
+ u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
+ WILC_Uint32 u32MaxSiteSrvyFragLen)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID astrWIDList[2];
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+ astrWIDList[0].u16WIDid = (WILC_Uint16)WID_SITE_SURVEY_RESULTS;
+ astrWIDList[0].enuWIDtype = WID_STR;
+ astrWIDList[0].ps8WidVal = ppu8RcvdSiteSurveyResults[0];
+ astrWIDList[0].s32ValueSize = u32MaxSiteSrvyFragLen;
+
+ astrWIDList[1].u16WIDid = (WILC_Uint16)WID_SITE_SURVEY_RESULTS;
+ astrWIDList[1].enuWIDtype = WID_STR;
+ astrWIDList[1].ps8WidVal = ppu8RcvdSiteSurveyResults[1];
+ astrWIDList[1].s32ValueSize = u32MaxSiteSrvyFragLen;
+
+ s32Error = SendConfigPkt(GET_CFG, astrWIDList, 2, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+
+ /*get the value by searching the local copy*/
+ if (s32Error) {
+ PRINT_ER("Failed to send config packet to get survey results\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+#endif
+
+/**
+ * @brief sets a start scan request
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Scan Source one of the following values
+ * DEFAULT_SCAN 0
+ * USER_SCAN BIT0
+ * OBSS_PERIODIC_SCAN BIT1
+ * OBSS_ONETIME_SCAN BIT2
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ strWID.u16WIDid = (WILC_Uint16)WID_START_SCAN_REQ;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Sint8 *)&scanSource;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ return s32Error;
+}
+
+/**
+ * @brief host_int_get_start_scan_req
+ * @details gets a start scan request
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Scan Source one of the following values
+ * DEFAULT_SCAN 0
+ * USER_SCAN BIT0
+ * OBSS_PERIODIC_SCAN BIT1
+ * OBSS_ONETIME_SCAN BIT2
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ strWID.u16WIDid = (WILC_Uint16)WID_START_SCAN_REQ;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Sint8 *)pu8ScanSource;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ return s32Error;
+}
+
+/**
+ * @brief host_int_set_join_req
+ * @details sets a join request
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Index of the bss descriptor
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid,
+ const u8 *pu8ssid, size_t ssidLen,
+ const u8 *pu8IEs, size_t IEsLen,
+ tWILCpfConnectResult pfConnectResult, void *pvUserArg,
+ u8 u8security, AUTHTYPE_T tenuAuth_type,
+ u8 u8channel,
+ void *pJoinParams)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tenuScanConnTimer enuScanConnTimer;
+
+ if (pstrWFIDrv == NULL || pfConnectResult == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ if (hWFIDrv == NULL) {
+ PRINT_ER("Driver not initialized: gWFiDrvHandle = NULL\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ if (pJoinParams == NULL) {
+ PRINT_ER("Unable to Join - JoinParams is NULL\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+
+ }
+/*
+ * if(gWFiDrvHandle->strWILC_UsrScanReq.u32RcvdChCount == 0)
+ * {
+ * PRINT_ER("No scan results exist: Scanning should be done\n");
+ * WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ * }
+ */
+ /* prepare the Connect Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_CONNECT;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8security = u8security;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.tenuAuth_type = tenuAuth_type;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.u8channel = u8channel;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pfConnectResult = pfConnectResult;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pvUserArg = pvUserArg;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pJoinParams = pJoinParams;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ if (pu8bssid != NULL) {
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid = (u8 *)WILC_MALLOC(6); /* will be deallocated by the receiving thread */
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8bssid,
+ pu8bssid, 6);
+ }
+
+ if (pu8ssid != NULL) {
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.ssidLen = ssidLen;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid = (u8 *)WILC_MALLOC(ssidLen); /* will be deallocated by the receiving thread */
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8ssid,
+
+ pu8ssid, ssidLen);
+ }
+
+ if (pu8IEs != NULL) {
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.IEsLen = IEsLen;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFconnectAttr.pu8IEs,
+ pu8IEs, IEsLen);
+ }
+ if (pstrWFIDrv->enuHostIFstate < HOST_IF_CONNECTING) {
+ pstrWFIDrv->enuHostIFstate = HOST_IF_CONNECTING;
+ } else
+ PRINT_D(GENERIC_DBG, "Don't set state to 'connecting' as state is %d\n", pstrWFIDrv->enuHostIFstate);
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Failed to send message queue: Set join request\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ enuScanConnTimer = CONNECT_TIMER;
+ WILC_TimerStart(&(pstrWFIDrv->hConnectTimer), HOST_IF_CONNECT_TIMEOUT, (void *) hWFIDrv, NULL);
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief Flush a join request parameters to FW, but actual connection
+ * @details The function is called in situation where WILC is connected to AP and
+ * required to switch to hybrid FW for P2P connection
+ * @param[in] handle to the wifi driver,
+ * @return Error code indicating success/failure
+ * @note
+ * @author Amr Abdel-Moghny
+ * @date 19 DEC 2013
+ * @version 8.0
+ */
+
+WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (!gu8FlushedJoinReq) {
+ s32Error = WILC_FAIL;
+ return s32Error;
+ }
+
+
+ if (hWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_FLUSH_CONNECT;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Failed to send message queue: Flush join request\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+}
+
+/**
+ * @brief host_int_disconnect
+ * @details disconnects from the currently associated network
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Reason Code of the Disconnection
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16ReasonCode)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("gWFiDrvHandle = NULL\n");
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ /* prepare the Disconnect Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_DISCONNECT;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER("Failed to send message queue: disconnect\n");
+ /* ////////////// */
+ down(&(pstrWFIDrv->hSemTestDisconnectBlock));
+ /* /////// */
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief host_int_disconnect_station
+ * @details disconnects a sta
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Association Id of the station to be disconnected
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ strWID.u16WIDid = (WILC_Uint16)WID_DISCONNECT;
+ strWID.enuWIDtype = WID_CHAR;
+ strWID.ps8WidVal = (WILC_Sint8 *)&assoc_id;
+ strWID.s32ValueSize = sizeof(WILC_Char);
+
+ return s32Error;
+}
+
+/**
+ * @brief host_int_get_assoc_req_info
+ * @details gets a Association request info
+ * @param[in,out] handle to the wifi driver,
+ * Message containg assoc. req info in the following format
+ * ------------------------------------------------------------------------
+ | Management Frame Format |
+ ||-------------------------------------------------------------------|
+ ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
+ ||-------------|--------|--|--|-----|----------------|----------|----|
+ | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
+ ||-------------------------------------------------------------------|
+ | |
+ | Association Request Frame - Frame Body |
+ ||-------------------------------------------------------------------|
+ | Capability Information | Listen Interval | SSID | Supported Rates |
+ ||------------------------|-----------------|------|-----------------|
+ | 2 | 2 | 2-34 | 3-10 |
+ | ---------------------------------------------------------------------
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo,
+ WILC_Uint32 u32AssocReqInfoLen)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ strWID.u16WIDid = (WILC_Uint16)WID_ASSOC_REQ_INFO;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = pu8AssocReqInfo;
+ strWID.s32ValueSize = u32AssocReqInfoLen;
+
+
+ return s32Error;
+}
+
+/**
+ * @brief gets a Association Response info
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * Message containg assoc. resp info
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo,
+ WILC_Uint32 u32MaxAssocRespInfoLen, WILC_Uint32 *pu32RcvdAssocRespInfoLen)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ strWID.u16WIDid = (WILC_Uint16)WID_ASSOC_RES_INFO;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = pu8AssocRespInfo;
+ strWID.s32ValueSize = u32MaxAssocRespInfoLen;
+
+
+ /* Sending Configuration packet */
+ s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Failed to send association response config packet\n");
+ *pu32RcvdAssocRespInfoLen = 0;
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ } else {
+ *pu32RcvdAssocRespInfoLen = strWID.s32ValueSize;
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+}
+
+/**
+ * @brief gets a Association Response info
+ * @details Valid only in STA mode. This function gives the RSSI
+ * values observed in all the channels at the time of scanning.
+ * The length of the field is 1 greater that the total number of
+ * channels supported. Byte 0 contains the number of channels while
+ * each of Byte N contains the observed RSSI value for the channel index N.
+ * @param[in,out] handle to the wifi driver,
+ * array of scanned channels' RSSI
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel,
+ WILC_Uint32 u32RxPowerLevelLen)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ /* tstrWILC_WFIDrv * pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv; */
+
+ strWID.u16WIDid = (WILC_Uint16)WID_RX_POWER_LEVEL;
+ strWID.enuWIDtype = WID_STR;
+ strWID.ps8WidVal = pu8RxPowerLevel;
+ strWID.s32ValueSize = u32RxPowerLevelLen;
+
+
+ return s32Error;
+}
+
+/**
+ * @brief sets a channel
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Index of the channel to be set
+ *|-------------------------------------------------------------------|
+ | CHANNEL1 CHANNEL2 .... CHANNEL14 |
+ | Input: 1 2 14 |
+ ||-------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* prepare the set channel message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_CHANNEL;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFSetChan.u8SetChan = u8ChNum;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+
+WILC_Sint32 host_int_wait_msg_queue_idle(void)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ tstrHostIFmsg strHostIFmsg;
+
+ /* prepare the set driver handler message */
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_Q_IDLE;
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ /* wait untill MSG Q is empty */
+ down(&hWaitResponse);
+
+ return s32Error;
+
+}
+
+WILC_Sint32 host_int_set_wfi_drv_handler(WILC_Uint32 u32address)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ tstrHostIFmsg strHostIFmsg;
+
+
+ /* prepare the set driver handler message */
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_WFIDRV_HANDLER;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfSetDrvHandler.u32Address = u32address;
+ /* strHostIFmsg.drvHandler=hWFIDrv; */
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+
+
+WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32mode)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ tstrHostIFmsg strHostIFmsg;
+
+
+ /* prepare the set driver handler message */
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_OPERATION_MODE;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfSetOperationMode.u32Mode = u32mode;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief gets the current channel index
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * current channel index
+ *|-----------------------------------------------------------------------|
+ | CHANNEL1 CHANNEL2 .... CHANNEL14 |
+ | Input: 1 2 14 |
+ ||-----------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* prepare the Get Channel Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_CHNL;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER("Failed to send get host channel param's message queue ");
+ down(&(pstrWFIDrv->hSemGetCHNL));
+ /* gu8Chnl = 11; */
+
+ *pu8ChNo = gu8Chnl;
+
+ WILC_CATCH(s32Error)
+ {
+ }
+
+ return s32Error;
+
+
+}
+
+
+/**
+ * @brief host_int_test_set_int_wid
+ * @details Test function for setting wids
+ * @param[in,out] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32TestMemAddr
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_test_set_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32TestMemAddr)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /*prepare configuration packet*/
+ strWID.u16WIDid = (WILC_Uint16)WID_MEMORY_ADDRESS;
+ strWID.enuWIDtype = WID_INT;
+ strWID.ps8WidVal = (WILC_Char *)&u32TestMemAddr;
+ strWID.s32ValueSize = sizeof(WILC_Uint32);
+
+ /*Sending Cfg*/
+ s32Error = SendConfigPkt(SET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ if (s32Error) {
+ PRINT_ER("Test Function: Failed to set wid value\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ } else {
+ PRINT_D(HOSTINF_DBG, "Successfully set wid value\n");
+
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+}
+
+#ifdef WILC_AP_EXTERNAL_MLME
+/**
+ * @brief host_int_get_inactive_time
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * current sta macaddress, inactive_time
+ * @return
+ * @note
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, WILC_Uint32 *pu32InactiveTime)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIfStaInactiveT.mac,
+ mac, ETH_ALEN);
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_INACTIVETIME;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error)
+ PRINT_ER("Failed to send get host channel param's message queue ");
+
+ down(&(pstrWFIDrv->hSemInactiveTime));
+
+ *pu32InactiveTime = gu32InactiveTime;
+
+ WILC_CATCH(s32Error)
+ {
+ }
+
+ return s32Error;
+}
+#endif
+/**
+ * @brief host_int_test_get_int_wid
+ * @details Test function for getting wids
+ * @param[in,out] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32* pu32TestMemAddr
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_test_get_int_wid(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 *pu32TestMemAddr)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWID strWID;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ strWID.u16WIDid = (WILC_Uint16)WID_MEMORY_ADDRESS;
+ strWID.enuWIDtype = WID_INT;
+ strWID.ps8WidVal = (WILC_Sint8 *)pu32TestMemAddr;
+ strWID.s32ValueSize = sizeof(WILC_Uint32);
+
+ s32Error = SendConfigPkt(GET_CFG, &strWID, 1, WILC_TRUE, (WILC_Uint32)pstrWFIDrv);
+ /*get the value by searching the local copy*/
+ if (s32Error) {
+ PRINT_ER("Test Function: Failed to get wid value\n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_STATE);
+ } else {
+ PRINT_D(HOSTINF_DBG, "Successfully got wid value\n");
+
+ }
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+}
+
+
+/**
+ * @brief host_int_get_rssi
+ * @details gets the currently maintained RSSI value for the station.
+ * The received signal strength value in dB.
+ * The range of valid values is -128 to 0.
+ * @param[in,out] handle to the wifi driver,
+ * rssi value in dB
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+
+ /* prepare the Get RSSI Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Failed to send get host channel param's message queue ");
+ return WILC_FAIL;
+ }
+
+ down(&(pstrWFIDrv->hSemGetRSSI));
+
+
+ if (ps8Rssi == NULL) {
+ PRINT_ER("RSS pointer value is null");
+ return WILC_FAIL;
+ }
+
+
+ *ps8Rssi = gs8Rssi;
+
+
+ return s32Error;
+}
+
+WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8lnkspd)
+{
+ tstrHostIFmsg strHostIFmsg;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+
+
+ /* prepare the Get LINKSPEED Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_LINKSPEED;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Failed to send GET_LINKSPEED to message queue ");
+ return WILC_FAIL;
+ }
+
+ down(&(pstrWFIDrv->hSemGetLINKSPEED));
+
+
+ if (ps8lnkspd == NULL) {
+ PRINT_ER("LINKSPEED pointer value is null");
+ return WILC_FAIL;
+ }
+
+
+ *ps8lnkspd = gs8lnkspd;
+
+
+ return s32Error;
+}
+
+WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+
+
+ /* prepare the Get RSSI Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_STATISTICS;
+ strHostIFmsg.uniHostIFmsgBody.pUserData = (WILC_Char *)pstrStatistics;
+ strHostIFmsg.drvHandler = hWFIDrv;
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Failed to send get host channel param's message queue ");
+ return WILC_FAIL;
+ }
+
+ down(&hWaitResponse);
+ return s32Error;
+}
+
+
+/**
+ * @brief host_int_scan
+ * @details scans a set of channels
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Scan source
+ * Scan Type PASSIVE_SCAN = 0,
+ * ACTIVE_SCAN = 1
+ * Channels Array
+ * Channels Array length
+ * Scan Callback function
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource,
+ u8 u8ScanType, u8 *pu8ChnlFreqList,
+ u8 u8ChnlListLen, const u8 *pu8IEs,
+ size_t IEsLen, tWILCpfScanResult ScanResult,
+ void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tenuScanConnTimer enuScanConnTimer;
+
+ if (pstrWFIDrv == NULL || ScanResult == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+
+ /* prepare the Scan Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_SCAN;
+
+ if (pstrHiddenNetwork != NULL) {
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.pstrHiddenNetworkInfo = pstrHiddenNetwork->pstrHiddenNetworkInfo;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.strHiddenNetwork.u8ssidnum = pstrHiddenNetwork->u8ssidnum;
+
+ } else
+ PRINT_D(HOSTINF_DBG, "pstrHiddenNetwork IS EQUAL TO NULL\n");
+
+ strHostIFmsg.drvHandler = hWFIDrv;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanSource = u8ScanSource;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ScanType = u8ScanType;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pfScanResult = ScanResult;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pvUserArg = pvUserArg;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.u8ChnlListLen = u8ChnlListLen;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList = (u8 *)WILC_MALLOC(u8ChnlListLen); /* will be deallocated by the receiving thread */
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8ChnlFreqList,
+ pu8ChnlFreqList, u8ChnlListLen);
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.IEsLen = IEsLen;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs = (u8 *)WILC_MALLOC(IEsLen); /* will be deallocated by the receiving thread */
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strHostIFscanAttr.pu8IEs,
+ pu8IEs, IEsLen);
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Error in sending message queue scanning parameters: Error(%d)\n", s32Error);
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ enuScanConnTimer = SCAN_TIMER;
+ PRINT_D(HOSTINF_DBG, ">> Starting the SCAN timer\n");
+ WILC_TimerStart(&(pstrWFIDrv->hScanTimer), HOST_IF_SCAN_TIMEOUT, (void *) hWFIDrv, NULL);
+
+
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+
+}
+/**
+ * @brief hif_set_cfg
+ * @details sets configuration wids values
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] WID, WID value
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+ tstrHostIFmsg strHostIFmsg;
+
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ /* prepare the WiphyParams Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_CFG_PARAMS;
+ strHostIFmsg.uniHostIFmsgBody.strHostIFCfgParamAttr.pstrCfgParamVal = *pstrCfgParamVal;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+
+ WILC_CATCH(s32Error)
+ {
+ }
+
+ return s32Error;
+
+}
+
+
+/**
+ * @brief hif_get_cfg
+ * @details gets configuration wids values
+ * @param[in,out] handle to the wifi driver,
+ * WID value
+ * @param[in] WID,
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ *
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint16 *pu16WID_Value)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+
+ down(&(pstrWFIDrv->gtOsCfgValuesSem));
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver not initialized: pstrWFIDrv = NULL \n");
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+ PRINT_D(HOSTINF_DBG, "Getting configuration parameters\n");
+ switch (u16WID) {
+
+ case WID_BSS_TYPE:
+ *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.bss_type;
+ break;
+
+ case WID_AUTH_TYPE:
+ *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.auth_type;
+ break;
+
+ case WID_AUTH_TIMEOUT:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.auth_timeout;
+ break;
+
+ case WID_POWER_MANAGEMENT:
+ *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.power_mgmt_mode;
+ break;
+
+ case WID_SHORT_RETRY_LIMIT:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.short_retry_limit;
+ break;
+
+ case WID_LONG_RETRY_LIMIT:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.long_retry_limit;
+ break;
+
+ case WID_FRAG_THRESHOLD:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.frag_threshold;
+ break;
+
+ case WID_RTS_THRESHOLD:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.rts_threshold;
+ break;
+
+ case WID_PREAMBLE:
+ *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.preamble_type;
+ break;
+
+ case WID_SHORT_SLOT_ALLOWED:
+ *pu16WID_Value = (WILC_Uint16) pstrWFIDrv->strCfgValues.short_slot_allowed;
+ break;
+
+ case WID_11N_TXOP_PROT_DISABLE:
+ *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.txop_prot_disabled;
+ break;
+
+ case WID_BEACON_INTERVAL:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.beacon_interval;
+ break;
+
+ case WID_DTIM_PERIOD:
+ *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.dtim_period;
+ break;
+
+ case WID_SITE_SURVEY:
+ *pu16WID_Value = (WILC_Uint16)pstrWFIDrv->strCfgValues.site_survey_enabled;
+ break;
+
+ case WID_SITE_SURVEY_SCAN_TIME:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.site_survey_scan_time;
+ break;
+
+ case WID_ACTIVE_SCAN_TIME:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.active_scan_time;
+ break;
+
+ case WID_PASSIVE_SCAN_TIME:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.passive_scan_time;
+ break;
+
+ case WID_CURRENT_TX_RATE:
+ *pu16WID_Value = pstrWFIDrv->strCfgValues.curr_tx_rate;
+ break;
+
+ default:
+ break;
+ }
+
+ up(&(pstrWFIDrv->gtOsCfgValuesSem));
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+
+}
+
+/*****************************************************************************/
+/* Notification Functions */
+/*****************************************************************************/
+/**
+ * @brief notifies host with join and leave requests
+ * @details This function prepares an Information frame having the
+ * information about a joining/leaving station.
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] 6 byte Sta Adress
+ * Join or leave flag:
+ * Join = 1,
+ * Leave =0
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+void host_int_send_join_leave_info_to_host
+ (WILC_Uint16 assocId, u8 *stationAddr, WILC_Bool joining)
+{
+}
+/**
+ * @brief notifies host with stations found in scan
+ * @details sends the beacon/probe response from scan
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Sta Address,
+ * Frame length,
+ * Rssi of the Station found
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+void GetPeriodicRSSI(void *pvArg)
+{
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)pvArg;
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("Driver handler is NULL\n");
+ return;
+ }
+
+ if (pstrWFIDrv->enuHostIFstate == HOST_IF_CONNECTED) {
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+
+ /* prepare the Get RSSI Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_RSSI;
+ strHostIFmsg.drvHandler = pstrWFIDrv;
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Failed to send get host channel param's message queue ");
+ return;
+ }
+ }
+ WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL);
+}
+
+
+void host_int_send_network_info_to_host
+ (u8 *macStartAddress, WILC_Uint16 u16RxFrameLen, WILC_Sint8 s8Rssi)
+{
+}
+/**
+ * @brief host_int_init
+ * @details host interface initialization function
+ * @param[in,out] handle to the wifi driver,
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+static WILC_Uint32 u32Intialized;
+static WILC_Uint32 msgQ_created;
+static WILC_Uint32 clients_count;
+
+WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+
+ /*if(u32Intialized == 1)
+ * {
+ * PRINT_D(HOSTINF_DBG,"Host interface is previously initialized\n");
+ * *phWFIDrv = (WILC_WFIDrvHandle)gWFiDrvHandle; //Will be adjusted later for P2P
+ * return 0;
+ * } */
+ PRINT_D(HOSTINF_DBG, "Initializing host interface for client %d\n", clients_count + 1);
+
+ gbScanWhileConnected = WILC_FALSE;
+
+ sema_init(&hWaitResponse, 0);
+
+
+
+ /*Allocate host interface private structure*/
+ pstrWFIDrv = (tstrWILC_WFIDrv *)WILC_MALLOC(sizeof(tstrWILC_WFIDrv));
+ if (pstrWFIDrv == NULL) {
+ /* WILC_ERRORREPORT(s32Error,WILC_NO_MEM); */
+ s32Error = WILC_NO_MEM;
+ PRINT_ER("Failed to allocate memory\n");
+ goto _fail_timer_2;
+ }
+ WILC_memset(pstrWFIDrv, 0, sizeof(tstrWILC_WFIDrv));
+ /*return driver handle to user*/
+ *phWFIDrv = (WILC_WFIDrvHandle)pstrWFIDrv;
+ /*save into globl handle*/
+
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+
+ g_obtainingIP = WILC_FALSE;
+ #endif
+
+ PRINT_D(HOSTINF_DBG, "Global handle pointer value=%x\n", (WILC_Uint32)pstrWFIDrv);
+ /* /////////////////////////////////////// */
+ if (clients_count == 0) {
+ sema_init(&hSemHostIFthrdEnd, 0);
+ sema_init(&hSemDeinitDrvHandle, 0);
+ /*BugID_5348*/
+ sema_init(&hSemHostIntDeinit, 1);
+ }
+
+ sema_init(&(pstrWFIDrv->hSemTestKeyBlock), 0);
+ sema_init(&(pstrWFIDrv->hSemTestDisconnectBlock), 0);
+ sema_init(&(pstrWFIDrv->hSemGetRSSI), 0);
+ sema_init(&(pstrWFIDrv->hSemGetLINKSPEED), 0);
+ sema_init(&(pstrWFIDrv->hSemGetCHNL), 0);
+ sema_init(&(pstrWFIDrv->hSemInactiveTime), 0);
+
+ /* /////////////////////////////////////// */
+
+
+
+ PRINT_D(HOSTINF_DBG, "INIT: CLIENT COUNT %d\n", clients_count);
+
+ if (clients_count == 0) {
+
+ s32Error = WILC_MsgQueueCreate(&gMsgQHostIF, NULL);
+
+
+ if (s32Error < 0) {
+ PRINT_ER("Failed to creat MQ\n");
+ goto _fail_;
+ }
+ msgQ_created = 1;
+ HostIFthreadHandler = kthread_run(hostIFthread, NULL, "WILC_kthread");
+ if (IS_ERR(HostIFthreadHandler)) {
+ PRINT_ER("Failed to creat Thread\n");
+ s32Error = WILC_FAIL;
+ goto _fail_mq_;
+ }
+ s32Error = WILC_TimerCreate(&(g_hPeriodicRSSI), GetPeriodicRSSI, NULL);
+ if (s32Error < 0) {
+ PRINT_ER("Failed to creat Timer\n");
+ goto _fail_timer_1;
+ }
+ WILC_TimerStart(&(g_hPeriodicRSSI), 5000, (void *)pstrWFIDrv, NULL);
+
+ }
+
+
+ s32Error = WILC_TimerCreate(&(pstrWFIDrv->hScanTimer), TimerCB_Scan, NULL);
+ if (s32Error < 0) {
+ PRINT_ER("Failed to creat Timer\n");
+ goto _fail_thread_;
+ }
+
+ s32Error = WILC_TimerCreate(&(pstrWFIDrv->hConnectTimer), TimerCB_Connect, NULL);
+ if (s32Error < 0) {
+ PRINT_ER("Failed to creat Timer\n");
+ goto _fail_timer_1;
+ }
+
+
+ #ifdef WILC_P2P
+ /*Remain on channel timer*/
+ s32Error = WILC_TimerCreate(&(pstrWFIDrv->hRemainOnChannel), ListenTimerCB, NULL);
+ if (s32Error < 0) {
+ PRINT_ER("Failed to creat Remain-on-channel Timer\n");
+ goto _fail_timer_3;
+ }
+ #endif
+
+ sema_init(&(pstrWFIDrv->gtOsCfgValuesSem), 1);
+ down(&(pstrWFIDrv->gtOsCfgValuesSem));
+
+
+
+#ifdef SIMULATION
+ TransportInit();
+#endif
+
+ pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
+ /* gWFiDrvHandle->bPendingConnRequest = WILC_FALSE; */
+
+ /*Initialize CFG WIDS Defualt Values*/
+
+ pstrWFIDrv->strCfgValues.site_survey_enabled = SITE_SURVEY_OFF;
+ pstrWFIDrv->strCfgValues.scan_source = DEFAULT_SCAN;
+ pstrWFIDrv->strCfgValues.active_scan_time = ACTIVE_SCAN_TIME;
+ pstrWFIDrv->strCfgValues.passive_scan_time = PASSIVE_SCAN_TIME;
+ pstrWFIDrv->strCfgValues.curr_tx_rate = AUTORATE;
+
+
+ #ifdef WILC_P2P
+
+ pstrWFIDrv->u64P2p_MgmtTimeout = 0;
+
+ #endif
+
+ PRINT_INFO(HOSTINF_DBG, "Initialization values, Site survey value: %d\n Scan source: %d\n Active scan time: %d\n Passive scan time: %d\nCurrent tx Rate = %d\n",
+
+ pstrWFIDrv->strCfgValues.site_survey_enabled, pstrWFIDrv->strCfgValues.scan_source,
+ pstrWFIDrv->strCfgValues.active_scan_time, pstrWFIDrv->strCfgValues.passive_scan_time,
+ pstrWFIDrv->strCfgValues.curr_tx_rate);
+
+
+ up(&(pstrWFIDrv->gtOsCfgValuesSem));
+
+ /*TODO Code to setup simulation to be removed later*/
+ /*Intialize configurator module*/
+ s32Error = CoreConfiguratorInit();
+ if (s32Error < 0) {
+ PRINT_ER("Failed to initialize core configurator\n");
+ goto _fail_mem_;
+ }
+
+#ifdef SIMULATION
+ /*Initialize Simulaor*/
+ CoreConfigSimulatorInit();
+#endif
+
+ u32Intialized = 1;
+ clients_count++; /* increase number of created entities */
+
+ return s32Error;
+
+
+_fail_mem_:
+ if (pstrWFIDrv != NULL)
+ WILC_FREE(pstrWFIDrv);
+#ifdef WILC_P2P
+_fail_timer_3:
+ WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL);
+#endif
+_fail_timer_2:
+ up(&(pstrWFIDrv->gtOsCfgValuesSem));
+ WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL);
+_fail_timer_1:
+ WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL);
+_fail_thread_:
+ kthread_stop(HostIFthreadHandler);
+_fail_mq_:
+ WILC_MsgQueueDestroy(&gMsgQHostIF, NULL);
+_fail_:
+ return s32Error;
+
+
+}
+/**
+ * @brief host_int_deinit
+ * @details host interface initialization function
+ * @param[in,out] handle to the wifi driver,
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+
+
+ /*obtain driver handle*/
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ /*if(u32Intialized == 0)
+ * {
+ * PRINT_ER("Host Interface is not initialized\n");
+ * return 0;
+ * }*/
+
+ /*BugID_5348*/
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("pstrWFIDrv = NULL\n");
+ return 0;
+ }
+
+ down(&hSemHostIntDeinit);
+
+ terminated_handle = pstrWFIDrv;
+ PRINT_D(HOSTINF_DBG, "De-initializing host interface for client %d\n", clients_count);
+
+ /*BugID_5348*/
+ /*Destroy all timers before acquiring hSemDeinitDrvHandle*/
+ /*to guarantee handling all messages befor proceeding*/
+ if (WILC_TimerDestroy(&(pstrWFIDrv->hScanTimer), NULL)) {
+ PRINT_D(HOSTINF_DBG, ">> Scan timer is active \n");
+ /* msleep(HOST_IF_SCAN_TIMEOUT+1000); */
+ }
+
+ if (WILC_TimerDestroy(&(pstrWFIDrv->hConnectTimer), NULL)) {
+ PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
+ /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
+ }
+
+
+ if (WILC_TimerDestroy(&(g_hPeriodicRSSI), NULL)) {
+ PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
+ /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
+ }
+
+ #ifdef WILC_P2P
+ /*Destroy Remain-onchannel Timer*/
+ WILC_TimerDestroy(&(pstrWFIDrv->hRemainOnChannel), NULL);
+ #endif
+
+ host_int_set_wfi_drv_handler((WILC_Uint32)NULL);
+ down(&hSemDeinitDrvHandle);
+
+
+ /*Calling the CFG80211 scan done function with the abort flag set to true*/
+ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult(SCAN_EVENT_ABORTED, NULL,
+ pstrWFIDrv->strWILC_UsrScanReq.u32UserScanPvoid, NULL);
+
+ pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult = NULL;
+ }
+ /*deinit configurator and simulator*/
+#ifdef SIMULATION
+ CoreConfigSimulatorDeInit();
+#endif
+ CoreConfiguratorDeInit();
+#ifdef SIMULATION
+ TransportDeInit();
+#endif
+
+ pstrWFIDrv->enuHostIFstate = HOST_IF_IDLE;
+
+ gbScanWhileConnected = WILC_FALSE;
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ if (clients_count == 1) {
+ if (WILC_TimerDestroy(&g_hPeriodicRSSI, NULL)) {
+ PRINT_D(HOSTINF_DBG, ">> Connect timer is active \n");
+ /* msleep(HOST_IF_CONNECT_TIMEOUT+1000); */
+ }
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_EXIT;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error != WILC_SUCCESS) {
+ PRINT_ER("Error in sending deinit's message queue message function: Error(%d)\n", s32Error);
+ }
+
+ down(&hSemHostIFthrdEnd);
+
+
+
+ WILC_MsgQueueDestroy(&gMsgQHostIF, NULL);
+ msgQ_created = 0;
+ }
+
+ down(&(pstrWFIDrv->gtOsCfgValuesSem));
+
+ /*Setting the gloabl driver handler with NULL*/
+ u32Intialized = 0;
+ /* gWFiDrvHandle = NULL; */
+ if (pstrWFIDrv != NULL) {
+ WILC_FREE(pstrWFIDrv);
+ /* pstrWFIDrv=NULL; */
+
+ }
+
+ clients_count--; /* Decrease number of created entities */
+ terminated_handle = NULL;
+ up(&hSemHostIntDeinit);
+ return s32Error;
+}
+
+
+/**
+ * @brief NetworkInfoReceived
+ * @details function to to be called when network info packet is received
+ * @param[in] pu8Buffer the received packet
+ * @param[in] u32Length length of the received packet
+ * @return none
+ * @note
+ * @author
+ * @date 1 Mar 2012
+ * @version 1.0
+ */
+void NetworkInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+ WILC_Uint32 drvHandler;
+ tstrWILC_WFIDrv *pstrWFIDrv = NULL;
+
+ drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
+ pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+
+
+ if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
+ PRINT_ER("NetworkInfo received but driver not init[%x]\n", (WILC_Uint32)pstrWFIDrv);
+ return;
+ }
+
+ /* prepare the Asynchronous Network Info message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_NTWRK_INFO;
+ strHostIFmsg.drvHandler = pstrWFIDrv;
+
+ strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.u32Length = u32Length;
+ strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdNetworkInfo.pu8Buffer,
+ pu8Buffer, u32Length);
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Error in sending network info message queue message parameters: Error(%d)\n", s32Error);
+ }
+
+
+ return;
+}
+
+/**
+ * @brief GnrlAsyncInfoReceived
+ * @details function to be called when general Asynchronous info packet is received
+ * @param[in] pu8Buffer the received packet
+ * @param[in] u32Length length of the received packet
+ * @return none
+ * @note
+ * @author
+ * @date 15 Mar 2012
+ * @version 1.0
+ */
+void GnrlAsyncInfoReceived(u8 *pu8Buffer, WILC_Uint32 u32Length)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+ WILC_Uint32 drvHandler;
+ tstrWILC_WFIDrv *pstrWFIDrv = NULL;
+
+ /*BugID_5348*/
+ down(&hSemHostIntDeinit);
+
+ drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
+ pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+ PRINT_D(HOSTINF_DBG, "General asynchronous info packet received \n");
+
+
+ if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
+ PRINT_D(HOSTINF_DBG, "Wifi driver handler is equal to NULL\n");
+ /*BugID_5348*/
+ up(&hSemHostIntDeinit);
+ return;
+ }
+
+ if (pstrWFIDrv->strWILC_UsrConnReq.pfUserConnectResult == NULL) {
+ /* received mac status is not needed when there is no current Connect Request */
+ PRINT_ER("Received mac status is not needed when there is no current Connect Reques\n");
+ /*BugID_5348*/
+ up(&hSemHostIntDeinit);
+ return;
+ }
+
+ /* prepare the General Asynchronous Info message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_GNRL_ASYNC_INFO;
+ strHostIFmsg.drvHandler = pstrWFIDrv;
+
+
+ strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.u32Length = u32Length;
+ strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer = (u8 *)WILC_MALLOC(u32Length); /* will be deallocated by the receiving thread */
+ WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strRcvdGnrlAsyncInfo.pu8Buffer,
+ pu8Buffer, u32Length);
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Error in sending message queue asynchronous message info: Error(%d)\n", s32Error);
+ }
+
+ /*BugID_5348*/
+ up(&hSemHostIntDeinit);
+ return;
+}
+
+/**
+ * @brief host_int_ScanCompleteReceived
+ * @details Setting scan complete received notifcation in message queue
+ * @param[in] u8* pu8Buffer, WILC_Uint32 u32Length
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+void host_int_ScanCompleteReceived(u8 *pu8Buffer, WILC_Uint32 u32Length)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrHostIFmsg strHostIFmsg;
+ WILC_Uint32 drvHandler;
+ tstrWILC_WFIDrv *pstrWFIDrv = NULL;
+ drvHandler = ((pu8Buffer[u32Length - 4]) | (pu8Buffer[u32Length - 3] << 8) | (pu8Buffer[u32Length - 2] << 16) | (pu8Buffer[u32Length - 1] << 24));
+ pstrWFIDrv = (tstrWILC_WFIDrv *)drvHandler;
+
+
+ PRINT_D(GENERIC_DBG, "Scan notification received %x\n", (WILC_Uint32)pstrWFIDrv);
+
+ if (pstrWFIDrv == NULL || pstrWFIDrv == terminated_handle) {
+ return;
+ }
+
+ /*if there is an ongoing scan request*/
+ if (pstrWFIDrv->strWILC_UsrScanReq.pfUserScanResult) {
+ /* prepare theScan Done message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_RCVD_SCAN_COMPLETE;
+ strHostIFmsg.drvHandler = pstrWFIDrv;
+
+
+ /* will be deallocated by the receiving thread */
+ /*no need to send message body*/
+
+ /*strHostIFmsg.uniHostIFmsgBody.strScanComplete.u32Length = u32Length;
+ * strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer = (u8*)WILC_MALLOC(u32Length);
+ * WILC_memcpy(strHostIFmsg.uniHostIFmsgBody.strScanComplete.pu8Buffer,
+ * pu8Buffer, u32Length); */
+
+ /* send the message */
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ PRINT_ER("Error in sending message queue scan complete parameters: Error(%d)\n", s32Error);
+ }
+ }
+
+
+ return;
+
+}
+
+#ifdef WILC_P2P
+/**
+ * @brief host_int_remain_on_channel
+ * @details
+ * @param[in] Handle to wifi driver
+ * Duration to remain on channel
+ * Channel to remain on
+ * Pointer to fn to be called on receive frames in listen state
+ * Pointer to remain-on-channel expired fn
+ * Priv
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID, WILC_Uint32 u32duration, WILC_Uint16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* prepare the remainonchan Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_REMAIN_ON_CHAN;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u16Channel = chan;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanExpired = RemainOnChanExpired;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pRemainOnChanReady = RemainOnChanReady;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.pVoid = pvUserArg;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32duration = u32duration;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief host_int_ListenStateExpired
+ * @details
+ * @param[in] Handle to wifi driver
+ * Duration to remain on channel
+ * Channel to remain on
+ * Pointer to fn to be called on receive frames in listen state
+ * Pointer to remain-on-channel expired fn
+ * Priv
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /*Stopping remain-on-channel timer*/
+ WILC_TimerStop(&(pstrWFIDrv->hRemainOnChannel), NULL);
+
+ /* prepare the timer fire Message */
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_LISTEN_TIMER_FIRED;
+ strHostIFmsg.drvHandler = hWFIDrv;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRemainOnChan.u32ListenSessionID = u32SessionID;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ return s32Error;
+}
+
+/**
+ * @brief host_int_frame_register
+ * @details
+ * @param[in] Handle to wifi driver
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0*/
+WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16FrameType, WILC_Bool bReg)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_REGISTER_FRAME;
+ switch (u16FrameType) {
+ case ACTION:
+ PRINT_D(HOSTINF_DBG, "ACTION\n");
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = ACTION_FRM_IDX;
+ break;
+
+ case PROBE_REQ:
+ PRINT_D(HOSTINF_DBG, "PROBE REQ\n");
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u8Regid = PROBE_REQ_IDX;
+ break;
+
+ default:
+ PRINT_D(HOSTINF_DBG, "Not valid frame type\n");
+ break;
+ }
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.u16FrameType = u16FrameType;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfRegisterFrame.bReg = bReg;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+
+
+}
+#endif
+
+#ifdef WILC_AP_EXTERNAL_MLME
+/**
+ * @brief host_int_add_beacon
+ * @details Setting add beacon params in message queue
+ * @param[in] WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval,
+ * WILC_Uint32 u32DTIMPeriod,WILC_Uint32 u32HeadLen, u8* pu8Head,
+ * WILC_Uint32 u32TailLen, u8* pu8Tail
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval,
+ WILC_Uint32 u32DTIMPeriod,
+ WILC_Uint32 u32HeadLen, u8 *pu8Head,
+ WILC_Uint32 u32TailLen, u8 *pu8Tail)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrHostIFSetBeacon *pstrSetBeaconParam = &strHostIFmsg.uniHostIFmsgBody.strHostIFSetBeacon;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ PRINT_D(HOSTINF_DBG, "Setting adding beacon message queue params\n");
+
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BEACON;
+ strHostIFmsg.drvHandler = hWFIDrv;
+ pstrSetBeaconParam->u32Interval = u32Interval;
+ pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
+ pstrSetBeaconParam->u32HeadLen = u32HeadLen;
+ pstrSetBeaconParam->pu8Head = (u8 *)WILC_MALLOC(u32HeadLen);
+ if (pstrSetBeaconParam->pu8Head == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+ WILC_memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
+ pstrSetBeaconParam->u32TailLen = u32TailLen;
+
+ /* Bug 4599 : if tail length = 0 skip allocating & copying */
+ if (u32TailLen > 0) {
+ pstrSetBeaconParam->pu8Tail = (u8 *)WILC_MALLOC(u32TailLen);
+ if (pstrSetBeaconParam->pu8Tail == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_NO_MEM);
+ }
+ WILC_memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
+ } else {
+ pstrSetBeaconParam->pu8Tail = NULL;
+ }
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ if (pstrSetBeaconParam->pu8Head != NULL) {
+ WILC_FREE(pstrSetBeaconParam->pu8Head);
+ }
+
+ if (pstrSetBeaconParam->pu8Tail != NULL) {
+ WILC_FREE(pstrSetBeaconParam->pu8Tail);
+ }
+ }
+
+ return s32Error;
+
+}
+
+
+/**
+ * @brief host_int_del_beacon
+ * @details Setting add beacon params in message queue
+ * @param[in] WILC_WFIDrvHandle hWFIDrv
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BEACON;
+ strHostIFmsg.drvHandler = hWFIDrv;
+ PRINT_D(HOSTINF_DBG, "Setting deleting beacon message queue params\n");
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ WILC_ERRORCHECK(s32Error);
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+
+
+/**
+ * @brief host_int_add_station
+ * @details Setting add station params in message queue
+ * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
+
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ PRINT_D(HOSTINF_DBG, "Setting adding station message queue params\n");
+
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_STATION;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
+ if (pstrAddStationMsg->u8NumRates > 0) {
+ u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
+ WILC_NULLCHECK(s32Error, rates);
+
+ WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
+ pstrAddStationMsg->pu8Rates = rates;
+ }
+
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+
+/**
+ * @brief host_int_del_station
+ * @details Setting delete station params in message queue
+ * @param[in] WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrHostIFDelSta *pstrDelStationMsg = &strHostIFmsg.uniHostIFmsgBody.strDelStaParam;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ PRINT_D(HOSTINF_DBG, "Setting deleting station message queue params\n");
+
+
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_STATION;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /*BugID_4795: Handling situation of deleting all stations*/
+ if (pu8MacAddr == NULL)
+ WILC_memset(pstrDelStationMsg->au8MacAddr, 255, ETH_ALEN);
+ else
+ WILC_memcpy(pstrDelStationMsg->au8MacAddr, pu8MacAddr, ETH_ALEN);
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+/**
+ * @brief host_int_del_allstation
+ * @details Setting del station params in message queue
+ * @param[in] WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]s
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN])
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrHostIFDelAllSta *pstrDelAllStationMsg = &strHostIFmsg.uniHostIFmsgBody.strHostIFDelAllSta;
+ u8 au8Zero_Buff[ETH_ALEN] = {0};
+ WILC_Uint32 i;
+ u8 u8AssocNumb = 0;
+
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ PRINT_D(HOSTINF_DBG, "Setting deauthenticating station message queue params\n");
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_STA;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ /* Handling situation of deauthenticing all associated stations*/
+ for (i = 0; i < MAX_NUM_STA; i++) {
+ if (memcmp(pu8MacAddr[i], au8Zero_Buff, ETH_ALEN)) {
+ WILC_memcpy(pstrDelAllStationMsg->au8Sta_DelAllSta[i], pu8MacAddr[i], ETH_ALEN);
+ PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", pstrDelAllStationMsg->au8Sta_DelAllSta[i][0], pstrDelAllStationMsg->au8Sta_DelAllSta[i][1], pstrDelAllStationMsg->au8Sta_DelAllSta[i][2], pstrDelAllStationMsg->au8Sta_DelAllSta[i][3], pstrDelAllStationMsg->au8Sta_DelAllSta[i][4],
+ pstrDelAllStationMsg->au8Sta_DelAllSta[i][5]);
+ u8AssocNumb++;
+ }
+ }
+ if (!u8AssocNumb) {
+ PRINT_D(CFG80211_DBG, "NO ASSOCIATED STAS\n");
+ return s32Error;
+ }
+
+ pstrDelAllStationMsg->u8Num_AssocSta = u8AssocNumb;
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+
+
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+ down(&hWaitResponse);
+
+ return s32Error;
+
+}
+
+/**
+ * @brief host_int_edit_station
+ * @details Setting edit station params in message queue
+ * @param[in] WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam* pstrStaParams
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrWILC_AddStaParam *pstrAddStationMsg = &strHostIFmsg.uniHostIFmsgBody.strAddStaParam;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ PRINT_D(HOSTINF_DBG, "Setting editing station message queue params\n");
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_EDIT_STATION;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ WILC_memcpy(pstrAddStationMsg, pstrStaParams, sizeof(tstrWILC_AddStaParam));
+ if (pstrAddStationMsg->u8NumRates > 0) {
+ u8 *rates = WILC_MALLOC(pstrAddStationMsg->u8NumRates);
+ WILC_NULLCHECK(s32Error, rates);
+ WILC_memcpy(rates, pstrStaParams->pu8Rates, pstrAddStationMsg->u8NumRates);
+ pstrAddStationMsg->pu8Rates = rates;
+ }
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+#endif /*WILC_AP_EXTERNAL_MLME*/
+uint32_t wilc_get_chipid(uint8_t);
+
+WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32Timeout)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrHostIfPowerMgmtParam *pstrPowerMgmtParam = &strHostIFmsg.uniHostIFmsgBody.strPowerMgmtparam;
+
+ PRINT_INFO(HOSTINF_DBG, "\n\n>> Setting PS to %d << \n\n", bIsEnabled);
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ PRINT_D(HOSTINF_DBG, "Setting Power management message queue params\n");
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_POWER_MGMT;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ pstrPowerMgmtParam->bIsEnabled = bIsEnabled;
+ pstrPowerMgmtParam->u32Timeout = u32Timeout;
+
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+
+WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32count)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrHostIFSetMulti *pstrMulticastFilterParam = &strHostIFmsg.uniHostIFmsgBody.strHostIfSetMulti;
+
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ PRINT_D(HOSTINF_DBG, "Setting Multicast Filter params\n");
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_MULTICAST_FILTER;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ pstrMulticastFilterParam->bIsEnabled = bIsEnabled;
+ pstrMulticastFilterParam->u32count = u32count;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+
+
+
+/*Bug4218: Parsing Join Param*/
+#ifdef WILC_PARSE_SCAN_IN_HOST
+
+/*Bug4218: Parsing Join Param*/
+/**
+ * @brief host_int_ParseJoinBssParam
+ * @details Parse Needed Join Parameters and save it in a new JoinBssParam entry
+ * @param[in] tstrNetworkInfo* ptstrNetworkInfo
+ * @return
+ * @author zsalah
+ * @date
+ * @version 1.0**/
+static void *host_int_ParseJoinBssParam(tstrNetworkInfo *ptstrNetworkInfo)
+{
+ tstrJoinBssParam *pNewJoinBssParam = NULL;
+ u8 *pu8IEs;
+ WILC_Uint16 u16IEsLen;
+ WILC_Uint16 index = 0;
+ u8 suppRatesNo = 0;
+ u8 extSuppRatesNo;
+ WILC_Uint16 jumpOffset;
+ u8 pcipherCount;
+ u8 authCount;
+ u8 pcipherTotalCount = 0;
+ u8 authTotalCount = 0;
+ u8 i, j;
+
+ pu8IEs = ptstrNetworkInfo->pu8IEs;
+ u16IEsLen = ptstrNetworkInfo->u16IEsLen;
+
+ pNewJoinBssParam = WILC_MALLOC(sizeof(tstrJoinBssParam));
+ if (pNewJoinBssParam != NULL) {
+ WILC_memset(pNewJoinBssParam, 0, sizeof(tstrJoinBssParam));
+ pNewJoinBssParam->dtim_period = ptstrNetworkInfo->u8DtimPeriod;
+ pNewJoinBssParam->beacon_period = ptstrNetworkInfo->u16BeaconPeriod;
+ pNewJoinBssParam->cap_info = ptstrNetworkInfo->u16CapInfo;
+ WILC_memcpy(pNewJoinBssParam->au8bssid, ptstrNetworkInfo->au8bssid, 6);
+ /*for(i=0; i<6;i++)
+ * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->au8bssid[i]);*/
+ WILC_memcpy((u8 *)pNewJoinBssParam->ssid, ptstrNetworkInfo->au8ssid, ptstrNetworkInfo->u8SsidLen + 1);
+ pNewJoinBssParam->ssidLen = ptstrNetworkInfo->u8SsidLen;
+ WILC_memset(pNewJoinBssParam->rsn_pcip_policy, 0xFF, 3);
+ WILC_memset(pNewJoinBssParam->rsn_auth_policy, 0xFF, 3);
+ /*for(i=0; i<pNewJoinBssParam->ssidLen;i++)
+ * PRINT_D(HOSTINF_DBG,"%c",pNewJoinBssParam->ssid[i]);*/
+
+ /* parse supported rates: */
+ while (index < u16IEsLen) {
+ /* supportedRates IE */
+ if (pu8IEs[index] == SUPP_RATES_IE) {
+ /* PRINT_D(HOSTINF_DBG, "Supported Rates\n"); */
+ suppRatesNo = pu8IEs[index + 1];
+ pNewJoinBssParam->supp_rates[0] = suppRatesNo;
+ index += 2; /* skipping ID and length bytes; */
+
+ for (i = 0; i < suppRatesNo; i++) {
+ pNewJoinBssParam->supp_rates[i + 1] = pu8IEs[index + i];
+ /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[i+1]); */
+ }
+ index += suppRatesNo;
+ continue;
+ }
+ /* Ext SupportedRates IE */
+ else if (pu8IEs[index] == EXT_SUPP_RATES_IE) {
+ /* PRINT_D(HOSTINF_DBG, "Extended Supported Rates\n"); */
+ /* checking if no of ext. supp and supp rates < max limit */
+ extSuppRatesNo = pu8IEs[index + 1];
+ if (extSuppRatesNo > (MAX_RATES_SUPPORTED - suppRatesNo))
+ pNewJoinBssParam->supp_rates[0] = MAX_RATES_SUPPORTED;
+ else
+ pNewJoinBssParam->supp_rates[0] += extSuppRatesNo;
+ index += 2;
+ /* pNewJoinBssParam.supp_rates[0] contains now old number not the ext. no */
+ for (i = 0; i < (pNewJoinBssParam->supp_rates[0] - suppRatesNo); i++) {
+ pNewJoinBssParam->supp_rates[suppRatesNo + i + 1] = pu8IEs[index + i];
+ /* PRINT_D(HOSTINF_DBG,"%0x ",pNewJoinBssParam->supp_rates[suppRatesNo+i+1]); */
+ }
+ index += extSuppRatesNo;
+ continue;
+ }
+ /* HT Cap. IE */
+ else if (pu8IEs[index] == HT_CAPABILITY_IE) {
+ /* if IE found set the flag */
+ pNewJoinBssParam->ht_capable = BTRUE;
+ index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
+ /* PRINT_D(HOSTINF_DBG,"HT_CAPABALE\n"); */
+ continue;
+ } else if ((pu8IEs[index] == WMM_IE) && /* WMM Element ID */
+ (pu8IEs[index + 2] == 0x00) && (pu8IEs[index + 3] == 0x50) &&
+ (pu8IEs[index + 4] == 0xF2) && /* OUI */
+ (pu8IEs[index + 5] == 0x02) && /* OUI Type */
+ ((pu8IEs[index + 6] == 0x00) || (pu8IEs[index + 6] == 0x01)) && /* OUI Sub Type */
+ (pu8IEs[index + 7] == 0x01)) {
+ /* Presence of WMM Info/Param element indicates WMM capability */
+ pNewJoinBssParam->wmm_cap = BTRUE;
+
+ /* Check if Bit 7 is set indicating U-APSD capability */
+ if (pu8IEs[index + 8] & (1 << 7)) {
+ pNewJoinBssParam->uapsd_cap = BTRUE;
+ }
+ index += pu8IEs[index + 1] + 2;
+ continue;
+ }
+ #ifdef WILC_P2P
+ else if ((pu8IEs[index] == P2P_IE) && /* P2P Element ID */
+ (pu8IEs[index + 2] == 0x50) && (pu8IEs[index + 3] == 0x6f) &&
+ (pu8IEs[index + 4] == 0x9a) && /* OUI */
+ (pu8IEs[index + 5] == 0x09) && (pu8IEs[index + 6] == 0x0c)) { /* OUI Type */
+ WILC_Uint16 u16P2P_count;
+ pNewJoinBssParam->tsf = ptstrNetworkInfo->u32Tsf;
+ pNewJoinBssParam->u8NoaEnbaled = 1;
+ pNewJoinBssParam->u8Index = pu8IEs[index + 9];
+
+ /* Check if Bit 7 is set indicating Opss capability */
+ if (pu8IEs[index + 10] & (1 << 7)) {
+ pNewJoinBssParam->u8OppEnable = 1;
+ pNewJoinBssParam->u8CtWindow = pu8IEs[index + 10];
+ } else
+ pNewJoinBssParam->u8OppEnable = 0;
+ /* HOSTINF_DBG */
+ PRINT_D(GENERIC_DBG, "P2P Dump \n");
+ for (i = 0; i < pu8IEs[index + 7]; i++)
+ PRINT_D(GENERIC_DBG, " %x \n", pu8IEs[index + 9 + i]);
+
+ pNewJoinBssParam->u8Count = pu8IEs[index + 11];
+ u16P2P_count = index + 12;
+
+ WILC_memcpy(pNewJoinBssParam->au8Duration, pu8IEs + u16P2P_count, 4);
+ u16P2P_count += 4;
+
+ WILC_memcpy(pNewJoinBssParam->au8Interval, pu8IEs + u16P2P_count, 4);
+ u16P2P_count += 4;
+
+ WILC_memcpy(pNewJoinBssParam->au8StartTime, pu8IEs + u16P2P_count, 4);
+
+ index += pu8IEs[index + 1] + 2;
+ continue;
+
+ }
+ #endif
+ else if ((pu8IEs[index] == RSN_IE) ||
+ ((pu8IEs[index] == WPA_IE) && (pu8IEs[index + 2] == 0x00) &&
+ (pu8IEs[index + 3] == 0x50) && (pu8IEs[index + 4] == 0xF2) &&
+ (pu8IEs[index + 5] == 0x01))) {
+ WILC_Uint16 rsnIndex = index;
+ /*PRINT_D(HOSTINF_DBG,"RSN IE Length:%d\n",pu8IEs[rsnIndex+1]);
+ * for(i=0; i<pu8IEs[rsnIndex+1]; i++)
+ * {
+ * PRINT_D(HOSTINF_DBG,"%0x ",pu8IEs[rsnIndex+2+i]);
+ * }*/
+ if (pu8IEs[rsnIndex] == RSN_IE) {
+ pNewJoinBssParam->mode_802_11i = 2;
+ /* PRINT_D(HOSTINF_DBG,"\nRSN_IE\n"); */
+ } else { /* check if rsn was previously parsed */
+ if (pNewJoinBssParam->mode_802_11i == 0)
+ pNewJoinBssParam->mode_802_11i = 1;
+ /* PRINT_D(HOSTINF_DBG,"\nWPA_IE\n"); */
+ rsnIndex += 4;
+ }
+ rsnIndex += 7; /* skipping id, length, version(2B) and first 3 bytes of gcipher */
+ pNewJoinBssParam->rsn_grp_policy = pu8IEs[rsnIndex];
+ rsnIndex++;
+ /* PRINT_D(HOSTINF_DBG,"Group Policy: %0x \n",pNewJoinBssParam->rsn_grp_policy); */
+ /* initialize policies with invalid values */
+
+ jumpOffset = pu8IEs[rsnIndex] * 4; /* total no.of bytes of pcipher field (count*4) */
+
+ /*parsing pairwise cipher*/
+
+ /* saving 3 pcipher max. */
+ pcipherCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
+ rsnIndex += 2; /* jump 2 bytes of pcipher count */
+
+ /* PRINT_D(HOSTINF_DBG,"\npcipher:%d \n",pcipherCount); */
+ for (i = pcipherTotalCount, j = 0; i < pcipherCount + pcipherTotalCount && i < 3; i++, j++) {
+ /* each count corresponds to 4 bytes, only last byte is saved */
+ pNewJoinBssParam->rsn_pcip_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
+ /* PRINT_D(HOSTINF_DBG,"PAIR policy = [%0x,%0x]\n",pNewJoinBssParam->rsn_pcip_policy[i],i); */
+ }
+ pcipherTotalCount += pcipherCount;
+ rsnIndex += jumpOffset;
+
+ jumpOffset = pu8IEs[rsnIndex] * 4;
+
+ /*parsing AKM suite (auth_policy)*/
+ /* saving 3 auth policies max. */
+ authCount = (pu8IEs[rsnIndex] > 3) ? 3 : pu8IEs[rsnIndex];
+ rsnIndex += 2; /* jump 2 bytes of pcipher count */
+
+ for (i = authTotalCount, j = 0; i < authTotalCount + authCount; i++, j++) {
+ /* each count corresponds to 4 bytes, only last byte is saved */
+ pNewJoinBssParam->rsn_auth_policy[i] = pu8IEs[rsnIndex + ((j + 1) * 4) - 1];
+ }
+ authTotalCount += authCount;
+ rsnIndex += jumpOffset;
+ /*pasring rsn cap. only if rsn IE*/
+ if (pu8IEs[index] == RSN_IE) {
+ pNewJoinBssParam->rsn_cap[0] = pu8IEs[rsnIndex];
+ pNewJoinBssParam->rsn_cap[1] = pu8IEs[rsnIndex + 1];
+ rsnIndex += 2;
+ }
+ pNewJoinBssParam->rsn_found = 1;
+ index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
+ continue;
+ } else
+ index += pu8IEs[index + 1] + 2; /* ID,Length bytes and IE body */
+
+ }
+
+
+ }
+
+ return (void *)pNewJoinBssParam;
+
+}
+
+void host_int_freeJoinParams(void *pJoinParams)
+{
+ if ((tstrJoinBssParam *)pJoinParams != NULL)
+ WILC_FREE((tstrJoinBssParam *)pJoinParams);
+ else
+ PRINT_ER("Unable to FREE null pointer\n");
+}
+#endif /*WILC_PARSE_SCAN_IN_HOST*/
+
+
+/**
+ * @brief host_int_addBASession
+ * @details Open a block Ack session with the given parameters
+ * @param[in] tstrNetworkInfo* ptstrNetworkInfo
+ * @return
+ * @author anoureldin
+ * @date
+ * @version 1.0**/
+
+static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID, short int BufferSize,
+ short int SessionTimeout, void *drvHandler)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_ADD_BA_SESSION;
+
+ memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
+ pBASessionInfo->u8Ted = TID;
+ pBASessionInfo->u16BufferSize = BufferSize;
+ pBASessionInfo->u16SessionTimeout = SessionTimeout;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+}
+
+
+WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_BA_SESSION;
+
+ memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
+ pBASessionInfo->u8Ted = TID;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ /*BugID_5222*/
+ down(&hWaitResponse);
+
+ return s32Error;
+}
+
+WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+ tstrHostIfBASessionInfo *pBASessionInfo = &strHostIFmsg.uniHostIFmsgBody.strHostIfBASessionInfo;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_DEL_ALL_RX_BA_SESSIONS;
+
+ memcpy(pBASessionInfo->au8Bssid, pBSSID, ETH_ALEN);
+ pBASessionInfo->u8Ted = TID;
+ strHostIFmsg.drvHandler = hWFIDrv;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ /*BugID_5222*/
+ down(&hWaitResponse);
+
+ return s32Error;
+}
+
+/**
+ * @brief host_int_setup_ipaddress
+ * @details setup IP in firmware
+ * @param[in] Handle to wifi driver
+ * @return Error code.
+ * @author Abdelrahman Sobhy
+ * @date
+ * @version 1.0*/
+WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ /* TODO: Enable This feature on softap firmware */
+ return 0;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_SET_IPADDRESS;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
+ strHostIFmsg.drvHandler = hWFIDrv;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx = idx;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+
+
+}
+
+/**
+ * @brief host_int_get_ipaddress
+ * @details Get IP from firmware
+ * @param[in] Handle to wifi driver
+ * @return Error code.
+ * @author Abdelrahman Sobhy
+ * @date
+ * @version 1.0*/
+WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *u16ipadd, u8 idx)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv = (tstrWILC_WFIDrv *)hWFIDrv;
+ tstrHostIFmsg strHostIFmsg;
+
+ if (pstrWFIDrv == NULL) {
+ WILC_ERRORREPORT(s32Error, WILC_INVALID_ARGUMENT);
+ }
+
+ WILC_memset(&strHostIFmsg, 0, sizeof(tstrHostIFmsg));
+
+ /* prepare the WiphyParams Message */
+ strHostIFmsg.u16MsgId = HOST_IF_MSG_GET_IPADDRESS;
+
+ strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.au8IPAddr = u16ipadd;
+ strHostIFmsg.drvHandler=hWFIDrv;
+ strHostIFmsg.uniHostIFmsgBody.strHostIfSetIP.idx= idx;
+
+ s32Error = WILC_MsgQueueSend(&gMsgQHostIF, &strHostIFmsg, sizeof(tstrHostIFmsg), NULL);
+ if (s32Error) {
+ WILC_ERRORREPORT(s32Error, s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+
+ }
+
+ return s32Error;
+
+
+}
+
diff --git a/drivers/staging/wilc1000/host_interface.h b/drivers/staging/wilc1000/host_interface.h
new file mode 100644
index 00000000000000..d03a5753cb33b2
--- /dev/null
+++ b/drivers/staging/wilc1000/host_interface.h
@@ -0,0 +1,1344 @@
+/*!
+ * @file host_interface.h
+ * @brief File containg host interface APIs
+ * @author zsalah
+ * @sa host_interface.c
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+#ifndef HOST_INT_H
+#define HOST_INT_H
+
+#include "coreconfigurator.h"
+#include "coreconfigsimulator.h"
+/*****************************************************************************/
+/* Macros */
+/*****************************************************************************/
+#if 0
+#define WID_BSS_TYPE 0x0000
+#define WID_CURRENT_TX_RATE 0x0001
+#define WID_CURRENT_CHANNEL 0x0002
+#define WID_PREAMBLE 0x0003
+#define WID_STATUS 0x0005
+#define WID_SCAN_TYPE 0x0007
+#define WID_KEY_ID 0x0009
+#define WID_DTIM_PERIOD 0x0010
+#define WID_POWER_MANAGEMENT 0x000B
+#define WID_AUTH_TYPE 0x000D
+#define WID_SITE_SURVEY 0x000E
+#define WID_DTIM_PERIOD 0x0010
+#define WID_DISCONNECT 0x0016
+#define WID_SHORT_SLOT_ALLOWED 0x001A
+#define WID_START_SCAN_REQ 0x001E
+#define WID_RSSI 0x001F
+#define WID_JOIN_REQ 0x0020
+#define WID_11N_TXOP_PROT_DISABLE 0x00B0
+#define WID_RTS_THRESHOLD 0x1000
+#define WID_FRAG_THRESHOLD 0x1001
+#define WID_SHORT_RETRY_LIMIT 0x1002
+#define WID_LONG_RETRY_LIMIT 0x1003
+#define WID_BEACON_INTERVAL 0x1006
+#define WID_ACTIVE_SCAN_TIME 0x100C
+#define WID_PASSIVE_SCAN_TIME 0x100D
+#define WID_SITE_SURVEY_SCAN_TIME 0x100E
+#define WID_AUTH_TIMEOUT 0x1010
+#define WID_11I_PSK 0x3008
+#define WID_SITE_SURVEY_RESULTS 0x3012
+#define WID_ADD_PTK 0x301B
+#define WID_ADD_RX_GTK 0x301C
+#define WID_ADD_TX_GTK 0x301D
+#define WID_ADD_WEP_KEY 0x3019
+#define WID_REMOVE_WEP_KEY 0x301A
+#define WID_REMOVE_KEY 0x301E
+#define WID_ASSOC_REQ_INFO 0x301F
+#define WID_ASSOC_RES_INFO 0x3020
+#define WID_PMKID_INFO 0x3082
+#define WID_SCAN_CHANNEL_LIST 0x4084
+#define WID_11I_MODE 0x000C
+#endif
+#define FAIL 0x0000
+#define SUCCESS 0x0001
+
+#define IP_ALEN 4
+
+#define BIT2 ((WILC_Uint32)(1 << 2))
+#define BIT1 ((WILC_Uint32)(1 << 1))
+#define BIT0 ((WILC_Uint32)(1 << 0))
+
+#define AP_MODE 0x01
+#define STATION_MODE 0x02
+#define GO_MODE 0x03
+#define CLIENT_MODE 0x04
+
+
+#define MAX_NUM_STA 9
+#define ACTIVE_SCAN_TIME 10
+#define PASSIVE_SCAN_TIME 1200
+#define MIN_SCAN_TIME 10
+#define MAX_SCAN_TIME 1200
+#define DEFAULT_SCAN 0
+#define USER_SCAN BIT0
+#define OBSS_PERIODIC_SCAN BIT1
+#define OBSS_ONETIME_SCAN BIT2
+#define GTK_RX_KEY_BUFF_LEN 24
+#define ADDKEY 0x1
+#define REMOVEKEY 0x2
+#define DEFAULTKEY 0x4
+#define ADDKEY_AP 0x8
+#define MAX_NUM_SCANNED_NETWORKS 100 /* 30 // rachel */
+#define MAX_NUM_SCANNED_NETWORKS_SHADOW 130
+#define MAX_NUM_PROBED_SSID 10 /*One more than the number of scanned ssids*/
+#define CHANNEL_SCAN_TIME 250 /* 250 */
+
+#define TX_MIC_KEY_LEN 8
+#define RX_MIC_KEY_LEN 8
+#define PTK_KEY_LEN 16
+
+#define TX_MIC_KEY_MSG_LEN 26
+#define RX_MIC_KEY_MSG_LEN 48
+#define PTK_KEY_MSG_LEN 39
+
+#define PMKSA_KEY_LEN 22
+#define ETH_ALEN 6
+#define PMKID_LEN 16
+#define WILC_MAX_NUM_PMKIDS 16
+#define WILC_SUPP_MCS_SET_SIZE 16
+#define WILC_ADD_STA_LENGTH 40 /* Not including the rates field cause it has variable length*/
+#define SCAN_EVENT_DONE_ABORTED
+/*****************************************************************************/
+/* Data Types */
+/*****************************************************************************/
+/* typedef unsigned char uint8; */
+/* typedef signed char int8; */
+/* typedef unsigned short uint16; */
+/* typedef unsigned long uint32; */
+/* typedef uint32 Bool; */
+
+#if 0
+typedef enum {WID_CHAR = 0,
+ WID_SHORT = 1,
+ WID_INT = 2,
+ WID_STR = 3,
+ WID_ADR = 4,
+ WID_BIN = 5,
+ WID_IP = 6,
+ WID_UNDEF = 7} WID_TYPE_T;
+#endif
+typedef struct {
+ WILC_Uint16 cfg_wid;
+ WID_TYPE_T cfg_type;
+ WILC_Sint8 *pu8Para;
+} cfg_param_t;
+
+typedef struct _tstrStatistics {
+ u8 u8LinkSpeed;
+ WILC_Sint8 s8RSSI;
+ WILC_Uint32 u32TxCount;
+ WILC_Uint32 u32RxCount;
+ WILC_Uint32 u32TxFailureCount;
+
+} tstrStatistics;
+
+
+typedef enum {
+ HOST_IF_IDLE = 0,
+ HOST_IF_SCANNING = 1,
+ HOST_IF_CONNECTING = 2,
+ HOST_IF_WAITING_CONN_RESP = 3,
+ HOST_IF_CONNECTED = 4,
+ HOST_IF_P2P_LISTEN = 5,
+ HOST_IF_FORCE_32BIT = 0xFFFFFFFF
+} tenuHostIFstate;
+
+typedef struct _tstrHostIFpmkid {
+ u8 bssid[ETH_ALEN];
+ u8 pmkid[PMKID_LEN];
+} tstrHostIFpmkid;
+
+typedef struct _tstrHostIFpmkidAttr {
+ u8 numpmkid;
+ tstrHostIFpmkid pmkidlist[WILC_MAX_NUM_PMKIDS];
+} tstrHostIFpmkidAttr;
+#if 0
+/* Scan type parameter for scan request */
+typedef enum {
+ PASSIVE_SCAN = 0,
+ ACTIVE_SCAN = 1,
+ NUM_SCANTYPE
+} tenuScanType;
+
+typedef enum {SITE_SURVEY_1CH = 0,
+ SITE_SURVEY_ALL_CH = 1,
+ SITE_SURVEY_OFF = 2} SITE_SURVEY_T;
+#endif
+typedef enum {
+ AUTORATE = 0,
+ MBPS_1 = 1,
+ MBPS_2 = 2,
+ MBPS_5_5 = 5,
+ MBPS_11 = 11,
+ MBPS_6 = 6,
+ MBPS_9 = 9,
+ MBPS_12 = 12,
+ MBPS_18 = 18,
+ MBPS_24 = 24,
+ MBPS_36 = 36,
+ MBPS_48 = 48,
+ MBPS_54 = 54
+} CURRENT_TX_RATE_T;
+
+typedef struct {
+ WILC_Uint32 u32SetCfgFlag;
+ u8 ht_enable;
+ u8 bss_type;
+ u8 auth_type;
+ WILC_Uint16 auth_timeout;
+ u8 power_mgmt_mode;
+ WILC_Uint16 short_retry_limit;
+ WILC_Uint16 long_retry_limit;
+ WILC_Uint16 frag_threshold;
+ WILC_Uint16 rts_threshold;
+ WILC_Uint16 preamble_type;
+ u8 short_slot_allowed;
+ u8 txop_prot_disabled;
+ WILC_Uint16 beacon_interval;
+ WILC_Uint16 dtim_period;
+ SITE_SURVEY_T site_survey_enabled;
+ WILC_Uint16 site_survey_scan_time;
+ u8 scan_source;
+ WILC_Uint16 active_scan_time;
+ WILC_Uint16 passive_scan_time;
+ CURRENT_TX_RATE_T curr_tx_rate;
+
+} tstrCfgParamVal;
+
+typedef enum {
+ RETRY_SHORT = 1 << 0,
+ RETRY_LONG = 1 << 1,
+ FRAG_THRESHOLD = 1 << 2,
+ RTS_THRESHOLD = 1 << 3,
+ BSS_TYPE = 1 << 4,
+ AUTH_TYPE = 1 << 5,
+ AUTHEN_TIMEOUT = 1 << 6,
+ POWER_MANAGEMENT = 1 << 7,
+ PREAMBLE = 1 << 8,
+ SHORT_SLOT_ALLOWED = 1 << 9,
+ TXOP_PROT_DISABLE = 1 << 10,
+ BEACON_INTERVAL = 1 << 11,
+ DTIM_PERIOD = 1 << 12,
+ SITE_SURVEY = 1 << 13,
+ SITE_SURVEY_SCAN_TIME = 1 << 14,
+ ACTIVE_SCANTIME = 1 << 15,
+ PASSIVE_SCANTIME = 1 << 16,
+ CURRENT_TX_RATE = 1 << 17,
+ HT_ENABLE = 1 << 18,
+} tenuCfgParam;
+
+typedef struct {
+ u8 au8bssid[6];
+ WILC_Sint8 s8rssi;
+} tstrFoundNetworkInfo;
+
+typedef enum {SCAN_EVENT_NETWORK_FOUND = 0,
+ SCAN_EVENT_DONE = 1,
+ SCAN_EVENT_ABORTED = 2,
+ SCAN_EVENT_FORCE_32BIT = 0xFFFFFFFF} tenuScanEvent;
+
+typedef enum {
+ CONN_DISCONN_EVENT_CONN_RESP = 0,
+ CONN_DISCONN_EVENT_DISCONN_NOTIF = 1,
+ CONN_DISCONN_EVENT_FORCE_32BIT = 0xFFFFFFFF
+} tenuConnDisconnEvent;
+
+typedef enum {
+ WEP,
+ WPARxGtk,
+ /* WPATxGtk, */
+ WPAPtk,
+ PMKSA,
+} tenuKeyType;
+
+
+/*Scan callBack function definition*/
+typedef void (*tWILCpfScanResult)(tenuScanEvent, tstrNetworkInfo *, void *, void *);
+
+/*Connect callBack function definition*/
+typedef void (*tWILCpfConnectResult)(tenuConnDisconnEvent,
+ tstrConnectInfo *,
+ u8,
+ tstrDisconnectNotifInfo *,
+ void *);
+
+#ifdef WILC_P2P
+typedef void (*tWILCpfRemainOnChanExpired)(void *, WILC_Uint32); /*Remain on channel expiration callback function*/
+typedef void (*tWILCpfRemainOnChanReady)(void *); /*Remain on channel callback function*/
+#endif
+
+/* typedef WILC_Uint32 WILC_WFIDrvHandle; */
+typedef struct {
+ WILC_Sint32 s32Dummy;
+} *WILC_WFIDrvHandle;
+
+/*!
+ * @struct tstrRcvdNetworkInfo
+ * @brief Structure to hold Received Asynchronous Network info
+ * @details
+ * @todo
+ * @sa
+ * @author Mostafa Abu Bakr
+ * @date 25 March 2012
+ * @version 1.0
+ */
+typedef struct _tstrRcvdNetworkInfo {
+ u8 *pu8Buffer;
+ WILC_Uint32 u32Length;
+} tstrRcvdNetworkInfo;
+
+/*BugID_4156*/
+typedef struct _tstrHiddenNetworkInfo {
+ u8 *pu8ssid;
+ u8 u8ssidlen;
+
+} tstrHiddenNetworkInfo;
+
+typedef struct _tstrHiddenNetwork {
+ /* MAX_SSID_LEN */
+ tstrHiddenNetworkInfo *pstrHiddenNetworkInfo;
+ u8 u8ssidnum;
+
+} tstrHiddenNetwork;
+
+typedef struct {
+ /* Scan user call back function */
+ tWILCpfScanResult pfUserScanResult;
+
+ /* User specific parameter to be delivered through the Scan User Callback function */
+ void *u32UserScanPvoid;
+
+ WILC_Uint32 u32RcvdChCount;
+ tstrFoundNetworkInfo astrFoundNetworkInfo[MAX_NUM_SCANNED_NETWORKS];
+} tstrWILC_UsrScanReq;
+
+typedef struct {
+ u8 *pu8bssid;
+ u8 *pu8ssid;
+ u8 u8security;
+ AUTHTYPE_T tenuAuth_type;
+ size_t ssidLen;
+ u8 *pu8ConnReqIEs;
+ size_t ConnReqIEsLen;
+ /* Connect user call back function */
+ tWILCpfConnectResult pfUserConnectResult;
+ WILC_Bool IsHTCapable;
+ /* User specific parameter to be delivered through the Connect User Callback function */
+ void *u32UserConnectPvoid;
+} tstrWILC_UsrConnReq;
+
+typedef struct {
+ WILC_Uint32 u32Address;
+} tstrHostIfSetDrvHandler;
+
+typedef struct {
+ WILC_Uint32 u32Mode;
+} tstrHostIfSetOperationMode;
+
+/*BugID_5077*/
+typedef struct {
+ u8 u8MacAddress[ETH_ALEN];
+} tstrHostIfSetMacAddress;
+
+/*BugID_5213*/
+typedef struct {
+ u8 *u8MacAddress;
+} tstrHostIfGetMacAddress;
+
+/*BugID_5222*/
+typedef struct {
+ u8 au8Bssid[ETH_ALEN];
+ u8 u8Ted;
+ WILC_Uint16 u16BufferSize;
+ WILC_Uint16 u16SessionTimeout;
+} tstrHostIfBASessionInfo;
+
+#ifdef WILC_P2P
+typedef struct {
+ WILC_Uint16 u16Channel;
+ WILC_Uint32 u32duration;
+ tWILCpfRemainOnChanExpired pRemainOnChanExpired;
+ tWILCpfRemainOnChanReady pRemainOnChanReady;
+ void *pVoid;
+ WILC_Uint32 u32ListenSessionID;
+} tstrHostIfRemainOnChan;
+
+typedef struct {
+
+ WILC_Bool bReg;
+ WILC_Uint16 u16FrameType;
+ u8 u8Regid;
+
+
+} tstrHostIfRegisterFrame;
+
+
+#define ACTION 0xD0
+#define PROBE_REQ 0x40
+#define PROBE_RESP 0x50
+#define ACTION_FRM_IDX 0
+#define PROBE_REQ_IDX 1
+
+
+enum p2p_listen_state {
+ P2P_IDLE,
+ P2P_LISTEN,
+ P2P_GRP_FORMATION
+};
+
+#endif
+typedef struct {
+ /* Scan user structure */
+ tstrWILC_UsrScanReq strWILC_UsrScanReq;
+
+ /* Connect User structure */
+ tstrWILC_UsrConnReq strWILC_UsrConnReq;
+
+ #ifdef WILC_P2P
+ /*Remain on channel struvture*/
+ tstrHostIfRemainOnChan strHostIfRemainOnChan;
+ u8 u8RemainOnChan_pendingreq;
+ WILC_Uint64 u64P2p_MgmtTimeout;
+ u8 u8P2PConnect;
+ #endif
+
+ tenuHostIFstate enuHostIFstate;
+
+ /* WILC_Bool bPendingConnRequest; */
+
+ #ifndef CONNECT_DIRECT
+ WILC_Uint32 u32SurveyResultsCount;
+ wid_site_survey_reslts_s astrSurveyResults[MAX_NUM_SCANNED_NETWORKS];
+ #endif
+
+ u8 au8AssociatedBSSID[ETH_ALEN];
+ tstrCfgParamVal strCfgValues;
+/* semaphores */
+ struct semaphore gtOsCfgValuesSem;
+ struct semaphore hSemTestKeyBlock;
+
+ struct semaphore hSemTestDisconnectBlock;
+ struct semaphore hSemGetRSSI;
+ struct semaphore hSemGetLINKSPEED;
+ struct semaphore hSemGetCHNL;
+ struct semaphore hSemInactiveTime;
+/* timer handlers */
+ WILC_TimerHandle hScanTimer;
+ WILC_TimerHandle hConnectTimer;
+ #ifdef WILC_P2P
+ WILC_TimerHandle hRemainOnChannel;
+ #endif
+
+ WILC_Bool IFC_UP;
+} tstrWILC_WFIDrv;
+
+/*!
+ * @enum tenuWILC_StaFlag
+ * @brief Used to decode the station flag set and mask in tstrWILC_AddStaParam
+ * @details
+ * @todo
+ * @sa tstrWILC_AddStaParam, enum nl80211_sta_flags
+ * @author Enumeraion's creator
+ * @date 12 July 2012
+ * @version 1.0 Description
+ */
+
+typedef enum {
+ WILC_STA_FLAG_INVALID = 0,
+ WILC_STA_FLAG_AUTHORIZED, /*!< station is authorized (802.1X)*/
+ WILC_STA_FLAG_SHORT_PREAMBLE, /*!< station is capable of receiving frames with short barker preamble*/
+ WILC_STA_FLAG_WME, /*!< station is WME/QoS capable*/
+ WILC_STA_FLAG_MFP, /*!< station uses management frame protection*/
+ WILC_STA_FLAG_AUTHENTICATED /*!< station is authenticated*/
+} tenuWILC_StaFlag;
+
+typedef struct {
+ u8 au8BSSID[ETH_ALEN];
+ WILC_Uint16 u16AssocID;
+ u8 u8NumRates;
+ const u8 *pu8Rates;
+ WILC_Bool bIsHTSupported;
+ WILC_Uint16 u16HTCapInfo;
+ u8 u8AmpduParams;
+ u8 au8SuppMCsSet[16];
+ WILC_Uint16 u16HTExtParams;
+ WILC_Uint32 u32TxBeamformingCap;
+ u8 u8ASELCap;
+ WILC_Uint16 u16FlagsMask; /*<! Determines which of u16FlagsSet were changed>*/
+ WILC_Uint16 u16FlagsSet; /*<! Decoded according to tenuWILC_StaFlag */
+} tstrWILC_AddStaParam;
+
+/* extern void CfgDisconnected(void* pUserVoid, WILC_Uint16 u16reason, u8 * ie, size_t ie_len); */
+
+/*****************************************************************************/
+/* */
+/* Host Interface API */
+/* */
+/*****************************************************************************/
+
+/**
+ * @brief removes wpa/wpa2 keys
+ * @details only in BSS STA mode if External Supplicant support is enabled.
+ * removes all WPA/WPA2 station key entries from MAC hardware.
+ * @param[in,out] handle to the wifi driver
+ * @param[in] 6 bytes of Station Adress in the station entry table
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_remove_key(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8StaAddress);
+/**
+ * @brief removes WEP key
+ * @details valid only in BSS STA mode if External Supplicant support is enabled.
+ * remove a WEP key entry from MAC HW.
+ * The BSS Station automatically finds the index of the entry using its
+ * BSS ID and removes that entry from the MAC hardware.
+ * @param[in,out] handle to the wifi driver
+ * @param[in] 6 bytes of Station Adress in the station entry table
+ * @return Error code indicating success/failure
+ * @note NO need for the STA add since it is not used for processing
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_remove_wep_key(WILC_WFIDrvHandle hWFIDrv, u8 u8Index);
+/**
+ * @brief sets WEP deafault key
+ * @details Sets the index of the WEP encryption key in use,
+ * in the key table
+ * @param[in,out] handle to the wifi driver
+ * @param[in] key index ( 0, 1, 2, 3)
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_WEPDefaultKeyID(WILC_WFIDrvHandle hWFIDrv, u8 u8Index);
+
+/**
+ * @brief sets WEP deafault key
+ * @details valid only in BSS STA mode if External Supplicant support is enabled.
+ * sets WEP key entry into MAC hardware when it receives the
+ * corresponding request from NDIS.
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing WEP Key in the following format
+ *|---------------------------------------|
+ *|Key ID Value | Key Length | Key |
+ *|-------------|------------|------------|
+ | 1byte | 1byte | Key Length |
+ ||---------------------------------------|
+ |
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_wep_key_bss_sta(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx);
+/**
+ * @brief host_int_add_wep_key_bss_ap
+ * @details valid only in AP mode if External Supplicant support is enabled.
+ * sets WEP key entry into MAC hardware when it receives the
+ * corresponding request from NDIS.
+ * @param[in,out] handle to the wifi driver
+ *
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author mdaftedar
+ * @date 28 Feb 2013
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_wep_key_bss_ap(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8WepKey, u8 u8WepKeylen, u8 u8Keyidx, u8 u8mode, AUTHTYPE_T tenuAuth_type);
+
+/**
+ * @brief adds ptk Key
+ * @details
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing PTK Key in the following format
+ *|-------------------------------------------------------------------------|
+ *|Sta Adress | Key Length | Temporal Key | Rx Michael Key |Tx Michael Key |
+ *|-----------|------------|---------------|----------------|---------------|
+ | 6 bytes | 1byte | 16 bytes | 8 bytes | 8 bytes |
+ ||-------------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_ptk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8Ptk, u8 u8PtkKeylen,
+ const u8 *mac_addr, const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode, u8 u8Idx);
+
+/**
+ * @brief host_int_get_inactive_time
+ * @details
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing inactive time
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author mdaftedar
+ * @date 15 April 2013
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_inactive_time(WILC_WFIDrvHandle hWFIDrv, const u8 *mac, WILC_Uint32 *pu32InactiveTime);
+
+/**
+ * @brief adds Rx GTk Key
+ * @details
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing Rx GTK Key in the following format
+ *|----------------------------------------------------------------------------|
+ *|Sta Address | Key RSC | KeyID | Key Length | Temporal Key | Rx Michael Key |
+ *|------------|---------|-------|------------|---------------|----------------|
+ | 6 bytes | 8 byte |1 byte | 1 byte | 16 bytes | 8 bytes |
+ ||----------------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_rx_gtk(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8RxGtk, u8 u8GtkKeylen,
+ u8 u8KeyIdx, WILC_Uint32 u32KeyRSClen, const u8 *KeyRSC,
+ const u8 *pu8RxMic, const u8 *pu8TxMic, u8 mode, u8 u8Ciphermode);
+
+
+/**
+ * @brief adds Tx GTk Key
+ * @details
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing Tx GTK Key in the following format
+ *|----------------------------------------------------|
+ | KeyID | Key Length | Temporal Key | Tx Michael Key |
+ ||-------|------------|--------------|----------------|
+ ||1 byte | 1 byte | 16 bytes | 8 bytes |
+ ||----------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_add_tx_gtk(WILC_WFIDrvHandle hWFIDrv, u8 u8KeyLen, u8 *pu8TxGtk, u8 u8KeyIdx);
+
+/**
+ * @brief caches the pmkid
+ * @details valid only in BSS STA mode if External Supplicant
+ * support is enabled. This Function sets the PMKID in firmware
+ * when host drivr receives the corresponding request from NDIS.
+ * The firmware then includes theset PMKID in the appropriate
+ * management frames
+ * @param[in,out] handle to the wifi driver
+ * @param[in] message containing PMKID Info in the following format
+ *|-----------------------------------------------------------------|
+ *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
+ *|-----------|------------|----------|-------|----------|----------|
+ | 1 | 6 | 16 | ... | 6 | 16 |
+ ||-----------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_set_pmkid_info(WILC_WFIDrvHandle hWFIDrv, tstrHostIFpmkidAttr *pu8PmkidInfoArray);
+/**
+ * @brief gets the cached the pmkid info
+ * @details valid only in BSS STA mode if External Supplicant
+ * support is enabled. This Function sets the PMKID in firmware
+ * when host drivr receives the corresponding request from NDIS.
+ * The firmware then includes theset PMKID in the appropriate
+ * management frames
+ * @param[in,out] handle to the wifi driver,
+ *
+ * message containing PMKID Info in the following format
+ *|-----------------------------------------------------------------|
+ *|NumEntries | BSSID[1] | PMKID[1] | ... | BSSID[K] | PMKID[K] |
+ *|-----------|------------|----------|-------|----------|----------|
+ | 1 | 6 | 16 | ... | 6 | 16 |
+ ||-----------------------------------------------------------------|
+ * @param[in]
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_get_pmkid_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PmkidInfoArray,
+ WILC_Uint32 u32PmkidInfoLen);
+
+/**
+ * @brief sets the pass phrase
+ * @details AP/STA mode. This function gives the pass phrase used to
+ * generate the Pre-Shared Key when WPA/WPA2 is enabled
+ * The length of the field can vary from 8 to 64 bytes,
+ * the lower layer should get the
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] String containing PSK
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv, u8 *pu8PassPhrase,
+ u8 u8Psklength);
+/**
+ * @brief gets the pass phrase
+ * @details AP/STA mode. This function gets the pass phrase used to
+ * generate the Pre-Shared Key when WPA/WPA2 is enabled
+ * The length of the field can vary from 8 to 64 bytes,
+ * the lower layer should get the
+ * @param[in,out] handle to the wifi driver,
+ * String containing PSK
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_RSNAConfigPSKPassPhrase(WILC_WFIDrvHandle hWFIDrv,
+ u8 *pu8PassPhrase, u8 u8Psklength);
+
+/**
+ * @brief gets mac address
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author mdaftedar
+ * @date 19 April 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress);
+
+/**
+ * @brief sets mac address
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author mabubakr
+ * @date 16 July 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_MacAddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8MacAddress);
+
+/**
+ * @brief wait until msg q is empty
+ * @details
+ * @param[in,out]
+ *
+ * @return Error code indicating success/failure
+ * @note
+ * @author asobhy
+ * @date 19 march 2014
+ * @version 1.0
+ */
+WILC_Sint32 host_int_wait_msg_queue_idle(void);
+
+/**
+ * @brief gets the site survey results
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * Message containing site survey results in the
+ * following formate
+ *|---------------------------------------------------|
+ | MsgLength | fragNo. | MsgBodyLength | MsgBody |
+ ||-----------|-----------|---------------|-----------|
+ | 1 | 1 | 1 | 1 |
+ | ----------------------------------------- | ----------------
+ |
+ ||---------------------------------------|
+ | Network1 | Netweork2 | ... | Network5 |
+ ||---------------------------------------|
+ | 44 | 44 | ... | 44 |
+ | -------------------------- | ---------------------------------------
+ |
+ ||---------------------------------------------------------------------|
+ | SSID | BSS Type | Channel | Security Status| BSSID | RSSI |Reserved |
+ ||------|----------|---------|----------------|-------|------|---------|
+ | 33 | 1 | 1 | 1 | 6 | 1 | 1 |
+ ||---------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+#ifndef CONNECT_DIRECT
+WILC_Sint32 host_int_get_site_survey_results(WILC_WFIDrvHandle hWFIDrv,
+ u8 ppu8RcvdSiteSurveyResults[][MAX_SURVEY_RESULT_FRAG_SIZE],
+ WILC_Uint32 u32MaxSiteSrvyFragLen);
+#endif
+
+/**
+ * @brief sets a start scan request
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Scan Source one of the following values
+ * DEFAULT_SCAN 0
+ * USER_SCAN BIT0
+ * OBSS_PERIODIC_SCAN BIT1
+ * OBSS_ONETIME_SCAN BIT2
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_set_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 scanSource);
+/**
+ * @brief gets scan source of the last scan
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * Scan Source one of the following values
+ * DEFAULT_SCAN 0
+ * USER_SCAN BIT0
+ * OBSS_PERIODIC_SCAN BIT1
+ * OBSS_ONETIME_SCAN BIT2
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_start_scan_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ScanSource);
+
+/**
+ * @brief sets a join request
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Index of the bss descriptor
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_set_join_req(WILC_WFIDrvHandle hWFIDrv, u8 *pu8bssid,
+ const u8 *pu8ssid, size_t ssidLen,
+ const u8 *pu8IEs, size_t IEsLen,
+ tWILCpfConnectResult pfConnectResult, void *pvUserArg,
+ u8 u8security, AUTHTYPE_T tenuAuth_type,
+ u8 u8channel,
+ void *pJoinParams);
+
+/**
+ * @brief Flush a join request parameters to FW, but actual connection
+ * @details The function is called in situation where WILC is connected to AP and
+ * required to switch to hybrid FW for P2P connection
+ * @param[in] handle to the wifi driver,
+ * @return Error code indicating success/failure
+ * @note
+ * @author Amr Abdel-Moghny
+ * @date 19 DEC 2013
+ * @version 8.0
+ */
+
+WILC_Sint32 host_int_flush_join_req(WILC_WFIDrvHandle hWFIDrv);
+
+
+/**
+ * @brief disconnects from the currently associated network
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Reason Code of the Disconnection
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_disconnect(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16ReasonCode);
+
+/**
+ * @brief disconnects a sta
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Association Id of the station to be disconnected
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_disconnect_station(WILC_WFIDrvHandle hWFIDrv, u8 assoc_id);
+/**
+ * @brief gets a Association request info
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * Message containg assoc. req info in the following format
+ * ------------------------------------------------------------------------
+ | Management Frame Format |
+ ||-------------------------------------------------------------------|
+ ||Frame Control|Duration|DA|SA|BSSID|Sequence Control|Frame Body|FCS |
+ ||-------------|--------|--|--|-----|----------------|----------|----|
+ | 2 |2 |6 |6 |6 | 2 |0 - 2312 | 4 |
+ ||-------------------------------------------------------------------|
+ | |
+ | Association Request Frame - Frame Body |
+ ||-------------------------------------------------------------------|
+ | Capability Information | Listen Interval | SSID | Supported Rates |
+ ||------------------------|-----------------|------|-----------------|
+ | 2 | 2 | 2-34 | 3-10 |
+ | ---------------------------------------------------------------------
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_get_assoc_req_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocReqInfo,
+ WILC_Uint32 u32AssocReqInfoLen);
+/**
+ * @brief gets a Association Response info
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * Message containg assoc. resp info
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+
+WILC_Sint32 host_int_get_assoc_res_info(WILC_WFIDrvHandle hWFIDrv, u8 *pu8AssocRespInfo,
+ WILC_Uint32 u32MaxAssocRespInfoLen, WILC_Uint32 *pu32RcvdAssocRespInfoLen);
+/**
+ * @brief gets a Association Response info
+ * @details Valid only in STA mode. This function gives the RSSI
+ * values observed in all the channels at the time of scanning.
+ * The length of the field is 1 greater that the total number of
+ * channels supported. Byte 0 contains the number of channels while
+ * each of Byte N contains the observed RSSI value for the channel index N.
+ * @param[in,out] handle to the wifi driver,
+ * array of scanned channels' RSSI
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_rx_power_level(WILC_WFIDrvHandle hWFIDrv, u8 *pu8RxPowerLevel,
+ WILC_Uint32 u32RxPowerLevelLen);
+
+/**
+ * @brief sets a channel
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Index of the channel to be set
+ *|-------------------------------------------------------------------|
+ | CHANNEL1 CHANNEL2 .... CHANNEL14 |
+ | Input: 1 2 14 |
+ ||-------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_mac_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 u8ChNum);
+
+/**
+ * @brief gets the current channel index
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * current channel index
+ *|-----------------------------------------------------------------------|
+ | CHANNEL1 CHANNEL2 .... CHANNEL14 |
+ | Input: 1 2 14 |
+ ||-----------------------------------------------------------------------|
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_host_chnl_num(WILC_WFIDrvHandle hWFIDrv, u8 *pu8ChNo);
+/**
+ * @brief gets the sta rssi
+ * @details gets the currently maintained RSSI value for the station.
+ * The received signal strength value in dB.
+ * The range of valid values is -128 to 0.
+ * @param[in,out] handle to the wifi driver,
+ * rssi value in dB
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_rssi(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8Rssi);
+WILC_Sint32 host_int_get_link_speed(WILC_WFIDrvHandle hWFIDrv, WILC_Sint8 *ps8lnkspd);
+/**
+ * @brief scans a set of channels
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Scan source
+ * Scan Type PASSIVE_SCAN = 0,
+ * ACTIVE_SCAN = 1
+ * Channels Array
+ * Channels Array length
+ * Scan Callback function
+ * User Argument to be delivered back through the Scan Cllback function
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_scan(WILC_WFIDrvHandle hWFIDrv, u8 u8ScanSource,
+ u8 u8ScanType, u8 *pu8ChnlFreqList,
+ u8 u8ChnlListLen, const u8 *pu8IEs,
+ size_t IEsLen, tWILCpfScanResult ScanResult,
+ void *pvUserArg, tstrHiddenNetwork *pstrHiddenNetwork);
+/**
+ * @brief sets configuration wids values
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] WID, WID value
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 hif_set_cfg(WILC_WFIDrvHandle hWFIDrv, tstrCfgParamVal *pstrCfgParamVal);
+
+/**
+ * @brief gets configuration wids values
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * WID value
+ * @param[in] WID,
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 hif_get_cfg(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16WID, WILC_Uint16 *pu16WID_Value);
+/*****************************************************************************/
+/* Notification Functions */
+/*****************************************************************************/
+/**
+ * @brief notifies host with join and leave requests
+ * @details This function prepares an Information frame having the
+ * information about a joining/leaving station.
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] 6 byte Sta Adress
+ * Join or leave flag:
+ * Join = 1,
+ * Leave =0
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+void host_int_send_join_leave_info_to_host
+ (WILC_Uint16 assocId, u8 *stationAddr, WILC_Bool joining);
+
+/**
+ * @brief notifies host with stations found in scan
+ * @details sends the beacon/probe response from scan
+ * @param[in,out] handle to the wifi driver,
+ * @param[in] Sta Address,
+ * Frame length,
+ * Rssi of the Station found
+ * @return Error code indicating success/failure
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+void host_int_send_network_info_to_host
+ (u8 *macStartAddress, WILC_Uint16 u16RxFrameLen, WILC_Sint8 s8Rssi);
+
+/**
+ * @brief host interface initialization function
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_init(WILC_WFIDrvHandle *phWFIDrv);
+
+/**
+ * @brief host interface initialization function
+ * @details
+ * @param[in,out] handle to the wifi driver,
+ * @note
+ * @author zsalah
+ * @date 8 March 2012
+ * @version 1.0
+ */
+WILC_Sint32 host_int_deinit(WILC_WFIDrvHandle hWFIDrv);
+
+
+/*!
+ * @fn WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv,u8 u8Index)
+ * @brief Sends a beacon to the firmware to be transmitted over the air
+ * @details
+ * @param[in,out] hWFIDrv handle to the wifi driver
+ * @param[in] u32Interval Beacon Interval. Period between two successive beacons on air
+ * @param[in] u32DTIMPeriod DTIM Period. Indicates how many Beacon frames
+ * (including the current frame) appear before the next DTIM
+ * @param[in] u32Headlen Length of the head buffer in bytes
+ * @param[in] pu8Head Pointer to the beacon's head buffer. Beacon's head
+ * is the part from the beacon's start till the TIM element, NOT including the TIM
+ * @param[in] u32Taillen Length of the tail buffer in bytes
+ * @param[in] pu8Tail Pointer to the beacon's tail buffer. Beacon's tail
+ * starts just after the TIM inormation element
+ * @return 0 for Success, error otherwise
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 10 Julys 2012
+ * @version 1.0 Description
+ *
+ */
+WILC_Sint32 host_int_add_beacon(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32Interval,
+ WILC_Uint32 u32DTIMPeriod,
+ WILC_Uint32 u32HeadLen, u8 *pu8Head,
+ WILC_Uint32 u32TailLen, u8 *pu8tail);
+
+
+/*!
+ * @fn WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv)
+ * @brief Removes the beacon and stops trawilctting it over the air
+ * @details
+ * @param[in,out] hWFIDrv handle to the wifi driver
+ * @return 0 for Success, error otherwise
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 10 Julys 2012
+ * @version 1.0 Description
+ */
+WILC_Sint32 host_int_del_beacon(WILC_WFIDrvHandle hWFIDrv);
+
+/*!
+ * @fn WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam strStaParams)
+ * @brief Notifies the firmware with a new associated stations
+ * @details
+ * @param[in,out] hWFIDrv handle to the wifi driver
+ * @param[in] pstrStaParams Station's parameters
+ * @return 0 for Success, error otherwise
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 12 July 2012
+ * @version 1.0 Description
+ */
+WILC_Sint32 host_int_add_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams);
+
+/*!
+ * @fn WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, const u8* pu8MacAddr)
+ * @brief Deauthenticates clients when group is terminating
+ * @details
+ * @param[in,out] hWFIDrv handle to the wifi driver
+ * @param[in] pu8MacAddr Station's mac address
+ * @return 0 for Success, error otherwise
+ * @todo
+ * @sa
+ * @author Mai Daftedar
+ * @date 09 April 2014
+ * @version 1.0 Description
+ */
+WILC_Sint32 host_int_del_allstation(WILC_WFIDrvHandle hWFIDrv, u8 pu8MacAddr[][ETH_ALEN]);
+
+/*!
+ * @fn WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, u8* pu8MacAddr)
+ * @brief Notifies the firmware with a new deleted station
+ * @details
+ * @param[in,out] hWFIDrv handle to the wifi driver
+ * @param[in] pu8MacAddr Station's mac address
+ * @return 0 for Success, error otherwise
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 15 July 2012
+ * @version 1.0 Description
+ */
+WILC_Sint32 host_int_del_station(WILC_WFIDrvHandle hWFIDrv, const u8 *pu8MacAddr);
+
+/*!
+ * @fn WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam strStaParams)
+ * @brief Notifies the firmware with new parameters of an already associated station
+ * @details
+ * @param[in,out] hWFIDrv handle to the wifi driver
+ * @param[in] pstrStaParams Station's parameters
+ * @return 0 for Success, error otherwise
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 15 July 2012
+ * @version 1.0 Description
+ */
+WILC_Sint32 host_int_edit_station(WILC_WFIDrvHandle hWFIDrv, tstrWILC_AddStaParam *pstrStaParams);
+
+/*!
+ * @fn WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32Timeout)
+ * @brief Set the power management mode to enabled or disabled
+ * @details
+ * @param[in,out] hWFIDrv handle to the wifi driver
+ * @param[in] bIsEnabled TRUE if enabled, FALSE otherwise
+ * @param[in] u32Timeout A timeout value of -1 allows the driver to adjust
+ * the dynamic ps timeout value
+ * @return 0 for Success, error otherwise
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 24 November 2012
+ * @version 1.0 Description
+ */
+WILC_Sint32 host_int_set_power_mgmt(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32Timeout);
+/* @param[in,out] hWFIDrv handle to the wifi driver
+ * @param[in] bIsEnabled TRUE if enabled, FALSE otherwise
+ * @param[in] u8count count of mac address entries in the filter table
+ *
+ * @return 0 for Success, error otherwise
+ * @todo
+ * @sa
+ * @author Adham Abozaeid
+ * @date 24 November 2012
+ * @version 1.0 Description
+ */
+WILC_Sint32 host_int_setup_multicast_filter(WILC_WFIDrvHandle hWFIDrv, WILC_Bool bIsEnabled, WILC_Uint32 u32count);
+/**
+ * @brief host_int_setup_ipaddress
+ * @details set IP address on firmware
+ * @param[in]
+ * @return Error code.
+ * @author Abdelrahman Sobhy
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_setup_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8IPAddr, u8 idx);
+
+
+/**
+ * @brief host_int_delBASession
+ * @details Delete single Rx BA session
+ * @param[in]
+ * @return Error code.
+ * @author Abdelrahman Sobhy
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_delBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID);
+
+/**
+ * @brief host_int_delBASession
+ * @details Delete all Rx BA session
+ * @param[in]
+ * @return Error code.
+ * @author Abdelrahman Sobhy
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_del_All_Rx_BASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID);
+
+
+/**
+ * @brief host_int_get_ipaddress
+ * @details get IP address on firmware
+ * @param[in]
+ * @return Error code.
+ * @author Abdelrahman Sobhy
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_get_ipaddress(WILC_WFIDrvHandle hWFIDrv, u8 *pu8IPAddr, u8 idx);
+
+#ifdef WILC_P2P
+/**
+ * @brief host_int_remain_on_channel
+ * @details
+ * @param[in]
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_remain_on_channel(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID, WILC_Uint32 u32duration, WILC_Uint16 chan, tWILCpfRemainOnChanExpired RemainOnChanExpired, tWILCpfRemainOnChanReady RemainOnChanReady, void *pvUserArg);
+
+/**
+ * @brief host_int_ListenStateExpired
+ * @details
+ * @param[in] Handle to wifi driver
+ * Duration to remain on channel
+ * Channel to remain on
+ * Pointer to fn to be called on receive frames in listen state
+ * Pointer to remain-on-channel expired fn
+ * Priv
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_ListenStateExpired(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32SessionID);
+
+/**
+ * @brief host_int_frame_register
+ * @details
+ * @param[in]
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_frame_register(WILC_WFIDrvHandle hWFIDrv, WILC_Uint16 u16FrameType, WILC_Bool bReg);
+#endif
+/**
+ * @brief host_int_set_wfi_drv_handler
+ * @details
+ * @param[in]
+ * @return Error code.
+ * @author
+ * @date
+ * @version 1.0
+ */
+WILC_Sint32 host_int_set_wfi_drv_handler(WILC_Uint32 u32address);
+WILC_Sint32 host_int_set_operation_mode(WILC_WFIDrvHandle hWFIDrv, WILC_Uint32 u32mode);
+
+static WILC_Sint32 Handle_ScanDone(void *drvHandler, tenuScanEvent enuEvent);
+
+static int host_int_addBASession(WILC_WFIDrvHandle hWFIDrv, char *pBSSID, char TID, short int BufferSize,
+ short int SessionTimeout, void *drvHandler);
+
+
+void host_int_freeJoinParams(void *pJoinParams);
+
+WILC_Sint32 host_int_get_statistics(WILC_WFIDrvHandle hWFIDrv, tstrStatistics *pstrStatistics);
+
+/*****************************************************************************/
+/* */
+/* EOF */
+/* */
+/*****************************************************************************/
+#endif
diff --git a/drivers/staging/wilc1000/itypes.h b/drivers/staging/wilc1000/itypes.h
new file mode 100644
index 00000000000000..6c2bd791a0b153
--- /dev/null
+++ b/drivers/staging/wilc1000/itypes.h
@@ -0,0 +1,60 @@
+/*****************************************************************************/
+/* */
+/* Ittiam 802.11 MAC SOFTWARE */
+/* */
+/* ITTIAM SYSTEMS PVT LTD, BANGALORE */
+/* COPYRIGHT(C) 2005 */
+/* */
+/* This program is proprietary to Ittiam Systems Private Limited and */
+/* is protected under Indian Copyright Law as an unpublished work. Its use */
+/* and disclosure is limited by the terms and conditions of a license */
+/* agreement. It may not be copied or otherwise reproduced or disclosed to */
+/* persons outside the licensee's organization except in accordance with the*/
+/* terms and conditions of such an agreement. All copies and */
+/* reproductions shall be the property of Ittiam Systems Private Limited and*/
+/* must bear this notice in its entirety. */
+/* */
+/*****************************************************************************/
+
+/*****************************************************************************/
+/* */
+/* File Name : itypes.h */
+/* */
+/* Description : This file contains all the data type definitions for */
+/* MAC implementation. */
+/* */
+/* List of Functions : None */
+/* Issues / Problems : None */
+/* */
+/* Revision History : */
+/* */
+/* DD MM YYYY Author(s) Changes */
+/* 01 05 2005 Ittiam Draft */
+/* */
+/*****************************************************************************/
+
+#ifndef ITYPES_H
+#define ITYPES_H
+
+
+/*****************************************************************************/
+/* Data Types */
+/*****************************************************************************/
+
+typedef int WORD32;
+typedef short WORD16;
+typedef char WORD8;
+typedef unsigned int UWORD32;
+typedef unsigned short UWORD16;
+typedef unsigned char UWORD8;
+
+/*****************************************************************************/
+/* Enums */
+/*****************************************************************************/
+
+typedef enum {
+ BFALSE = 0,
+ BTRUE = 1
+} BOOL_T;
+
+#endif /* ITYPES_H */
diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
new file mode 100644
index 00000000000000..cd6dc48b4b3310
--- /dev/null
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -0,0 +1,643 @@
+/*!
+ * @file linux_mon.c
+ * @brief File Operations OS wrapper functionality
+ * @author mdaftedar
+ * @sa wilc_wfi_netdevice.h
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+
+#ifndef SIMULATION
+#include "wilc_wfi_cfgoperations.h"
+#include "linux_wlan_common.h"
+#include "wilc_wlan_if.h"
+#include "wilc_wlan.h"
+#endif
+#ifdef WILC_FULLY_HOSTING_AP
+#include "wilc_host_ap.h"
+#endif
+#ifdef WILC_AP_EXTERNAL_MLME
+#ifdef SIMULATION
+#include "wilc_wfi_cfgoperations.h"
+#endif
+
+struct wilc_wfi_radiotap_hdr {
+ struct ieee80211_radiotap_header hdr;
+ u8 rate;
+ /* u32 channel; */
+} __attribute__((packed));
+
+struct wilc_wfi_radiotap_cb_hdr {
+ struct ieee80211_radiotap_header hdr;
+ u8 rate;
+ u8 dump;
+ u16 tx_flags;
+ /* u32 channel; */
+} __attribute__((packed));
+
+extern linux_wlan_t *g_linux_wlan;
+
+static struct net_device *wilc_wfi_mon; /* global monitor netdev */
+
+#ifdef SIMULATION
+extern int WILC_WFI_Tx(struct sk_buff *skb, struct net_device *dev);
+#elif USE_WIRELESS
+extern int mac_xmit(struct sk_buff *skb, struct net_device *dev);
+#endif
+
+
+u8 srcAdd[6];
+u8 bssid[6];
+u8 broadcast[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+/**
+ * @brief WILC_WFI_monitor_rx
+ * @details
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 12 JUL 2012
+ * @version 1.0
+ */
+
+#define IEEE80211_RADIOTAP_F_TX_RTS 0x0004 /* used rts/cts handshake */
+#define IEEE80211_RADIOTAP_F_TX_FAIL 0x0001 /* failed due to excessive*/
+#define IS_MANAGMEMENT 0x100
+#define IS_MANAGMEMENT_CALLBACK 0x080
+#define IS_MGMT_STATUS_SUCCES 0x040
+#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
+
+void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size)
+{
+ uint32_t header, pkt_offset;
+ struct sk_buff *skb = NULL;
+ struct wilc_wfi_radiotap_hdr *hdr;
+ struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+
+ PRINT_INFO(HOSTAPD_DBG, "In monitor interface receive function\n");
+
+ /* struct WILC_WFI_priv *priv = netdev_priv(dev); */
+
+ /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */
+
+ /* Bug 4601 */
+ if (wilc_wfi_mon == NULL)
+ return;
+
+ if (!netif_running(wilc_wfi_mon)) {
+ PRINT_INFO(HOSTAPD_DBG, "Monitor interface already RUNNING\n");
+ return;
+ }
+
+ /* Get WILC header */
+ memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
+
+ /* The packet offset field conain info about what type of managment frame */
+ /* we are dealing with and ack status */
+ pkt_offset = GET_PKT_OFFSET(header);
+
+ if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
+
+ /* hostapd callback mgmt frame */
+
+ skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ if (skb == NULL) {
+ PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb");
+ return;
+ }
+
+ memcpy(skb_put(skb, size), buff, size);
+
+ cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb, sizeof(*cb_hdr));
+ memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
+
+ cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+
+ cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
+
+ cb_hdr->hdr.it_present = cpu_to_le32(
+ (1 << IEEE80211_RADIOTAP_RATE) |
+ (1 << IEEE80211_RADIOTAP_TX_FLAGS));
+
+ cb_hdr->rate = 5; /* txrate->bitrate / 5; */
+
+ if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
+ /* success */
+ cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
+ } else {
+ cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
+ }
+
+ } else {
+
+ skb = dev_alloc_skb(size + sizeof(struct wilc_wfi_radiotap_hdr));
+
+ if (skb == NULL) {
+ PRINT_INFO(HOSTAPD_DBG, "Monitor if : No memory to allocate skb");
+ return;
+ }
+
+ /* skb = skb_copy_expand(tx_skb, sizeof(*hdr), 0, GFP_ATOMIC); */
+ /* if (skb == NULL) */
+ /* return; */
+
+ memcpy(skb_put(skb, size), buff, size);
+ hdr = (struct wilc_wfi_radiotap_hdr *) skb_push(skb, sizeof(*hdr));
+ memset(hdr, 0, sizeof(struct wilc_wfi_radiotap_hdr));
+ hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+ /* hdr->hdr.it_pad = 0; */
+ hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_hdr));
+ PRINT_INFO(HOSTAPD_DBG, "Radiotap len %d\n", hdr->hdr.it_len);
+ hdr->hdr.it_present = cpu_to_le32
+ (1 << IEEE80211_RADIOTAP_RATE); /* | */
+ /* (1 << IEEE80211_RADIOTAP_CHANNEL)); */
+ PRINT_INFO(HOSTAPD_DBG, "Presentflags %d\n", hdr->hdr.it_present);
+ hdr->rate = 5; /* txrate->bitrate / 5; */
+
+ }
+
+/* if(INFO || if(skb->data[9] == 0x00 || skb->data[9] == 0xb0))
+ * {
+ * for(i=0;i<skb->len;i++)
+ * PRINT_INFO(HOSTAPD_DBG,"Mon RxData[%d] = %02x\n",i,skb->data[i]);
+ * }*/
+
+
+ skb->dev = wilc_wfi_mon;
+ skb_set_mac_header(skb, 0);
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+
+ netif_rx(skb);
+
+
+}
+
+struct tx_complete_mon_data {
+ int size;
+ void *buff;
+};
+
+static void mgmt_tx_complete(void *priv, int status)
+{
+
+ /* struct sk_buff *skb2; */
+ /* struct wilc_wfi_radiotap_cb_hdr *cb_hdr; */
+
+ struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv;
+ u8 *buf = pv_data->buff;
+
+
+
+ if (status == 1) {
+ if (INFO || buf[0] == 0x10 || buf[0] == 0xb0)
+ PRINT_INFO(HOSTAPD_DBG, "Packet sent successfully - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff);
+ } else {
+ PRINT_INFO(HOSTAPD_DBG, "Couldn't send packet - Size = %d - Address = %p.\n", pv_data->size, pv_data->buff);
+ }
+
+
+/* //(skb->data[9] == 0x00 || skb->data[9] == 0xb0 || skb->data[9] == 0x40 || skb->data[9] == 0xd0 )
+ * {
+ * skb2 = dev_alloc_skb(pv_data->size+sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ *
+ * memcpy(skb_put(skb2,pv_data->size),pv_data->buff, pv_data->size);
+ *
+ * cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr));
+ * memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ *
+ * cb_hdr->hdr.it_version = 0;//PKTHDR_RADIOTAP_VERSION;
+ *
+ * cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
+ *
+ * cb_hdr->hdr.it_present = cpu_to_le32(
+ * (1 << IEEE80211_RADIOTAP_RATE) |
+ * (1 << IEEE80211_RADIOTAP_TX_FLAGS));
+ *
+ * cb_hdr->rate = 5;//txrate->bitrate / 5;
+ * cb_hdr->tx_flags = 0x0004;
+ *
+ * skb2->dev = wilc_wfi_mon;
+ * skb_set_mac_header(skb2, 0);
+ * skb2->ip_summed = CHECKSUM_UNNECESSARY;
+ * skb2->pkt_type = PACKET_OTHERHOST;
+ * skb2->protocol = htons(ETH_P_802_2);
+ * memset(skb2->cb, 0, sizeof(skb2->cb));
+ *
+ * netif_rx(skb2);
+ * }*/
+
+ /* incase of fully hosting mode, the freeing will be done in response to the cfg packet */
+ #ifndef WILC_FULLY_HOSTING_AP
+ kfree(pv_data->buff);
+
+ kfree(pv_data);
+ #endif
+}
+static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
+{
+ linux_wlan_t *nic;
+ struct tx_complete_mon_data *mgmt_tx = NULL;
+
+ if (dev == NULL) {
+ PRINT_D(HOSTAPD_DBG, "ERROR: dev == NULL\n");
+ return WILC_FAIL;
+ }
+ nic = netdev_priv(dev);
+
+ netif_stop_queue(dev);
+ mgmt_tx = (struct tx_complete_mon_data *)kmalloc(sizeof(struct tx_complete_mon_data), GFP_ATOMIC);
+ if (mgmt_tx == NULL) {
+ PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
+ return WILC_FAIL;
+ }
+
+ #ifdef WILC_FULLY_HOSTING_AP
+ /* add space for the pointer to tx_complete_mon_data */
+ len += sizeof(struct tx_complete_mon_data *);
+ #endif
+
+ mgmt_tx->buff = (char *)kmalloc(len, GFP_ATOMIC);
+ if (mgmt_tx->buff == NULL) {
+ PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
+ return WILC_FAIL;
+
+ }
+
+ mgmt_tx->size = len;
+
+ #ifndef WILC_FULLY_HOSTING_AP
+ memcpy(mgmt_tx->buff, buf, len);
+ #else
+ memcpy(mgmt_tx->buff, buf, len - sizeof(struct tx_complete_mon_data *));
+ memcpy((mgmt_tx->buff) + (len - sizeof(struct tx_complete_mon_data *)), &mgmt_tx, sizeof(struct tx_complete_mon_data *));
+
+ /* filter data frames to handle it's PS */
+ if (filter_monitor_data_frames((mgmt_tx->buff), len) == WILC_TRUE) {
+ return;
+ }
+
+ #endif /* WILC_FULLY_HOSTING_AP */
+
+ g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, mgmt_tx_complete);
+
+ netif_wake_queue(dev);
+ return 0;
+}
+
+/**
+ * @brief WILC_WFI_mon_xmit
+ * @details
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 12 JUL 2012
+ * @version 1.0
+ */
+static netdev_tx_t WILC_WFI_mon_xmit(struct sk_buff *skb,
+ struct net_device *dev)
+{
+ struct ieee80211_radiotap_header *rtap_hdr;
+ WILC_Uint32 rtap_len, i, ret = 0;
+ struct WILC_WFI_mon_priv *mon_priv;
+
+ struct sk_buff *skb2;
+ struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+
+ /* Bug 4601 */
+ if (wilc_wfi_mon == NULL)
+ return WILC_FAIL;
+
+ /* if(skb->data[3] == 0x10 || skb->data[3] == 0xb0) */
+
+ mon_priv = netdev_priv(wilc_wfi_mon);
+
+ if (mon_priv == NULL) {
+ PRINT_ER("Monitor interface private structure is NULL\n");
+ return WILC_FAIL;
+ }
+
+ rtap_hdr = (struct ieee80211_radiotap_header *)skb->data;
+
+ rtap_len = ieee80211_get_radiotap_len(skb->data);
+ if (skb->len < rtap_len) {
+ PRINT_ER("Error in radiotap header\n");
+ return -1;
+ }
+ /* skip the radiotap header */
+ PRINT_INFO(HOSTAPD_DBG, "Radiotap len: %d\n", rtap_len);
+
+ if (INFO) {
+ for (i = 0; i < rtap_len; i++)
+ PRINT_INFO(HOSTAPD_DBG, "Radiotap_hdr[%d] %02x\n", i, skb->data[i]);
+ }
+ /* Skip the ratio tap header */
+ skb_pull(skb, rtap_len);
+
+ if (skb->data[0] == 0xc0)
+ PRINT_INFO(HOSTAPD_DBG, "%x:%x:%x:%x:%x%x\n", skb->data[4], skb->data[5], skb->data[6], skb->data[7], skb->data[8], skb->data[9]);
+
+ if (skb->data[0] == 0xc0 && (!(memcmp(broadcast, &skb->data[4], 6)))) {
+ skb2 = dev_alloc_skb(skb->len + sizeof(struct wilc_wfi_radiotap_cb_hdr));
+
+ memcpy(skb_put(skb2, skb->len), skb->data, skb->len);
+
+ cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb2, sizeof(*cb_hdr));
+ memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
+
+ cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+
+ cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
+
+ cb_hdr->hdr.it_present = cpu_to_le32(
+ (1 << IEEE80211_RADIOTAP_RATE) |
+ (1 << IEEE80211_RADIOTAP_TX_FLAGS));
+
+ cb_hdr->rate = 5; /* txrate->bitrate / 5; */
+ cb_hdr->tx_flags = 0x0004;
+
+ skb2->dev = wilc_wfi_mon;
+ skb_set_mac_header(skb2, 0);
+ skb2->ip_summed = CHECKSUM_UNNECESSARY;
+ skb2->pkt_type = PACKET_OTHERHOST;
+ skb2->protocol = htons(ETH_P_802_2);
+ memset(skb2->cb, 0, sizeof(skb2->cb));
+
+ netif_rx(skb2);
+
+ return 0;
+ }
+ skb->dev = mon_priv->real_ndev;
+
+ PRINT_INFO(HOSTAPD_DBG, "Skipping the radiotap header\n");
+
+
+
+ /* actual deliver of data is device-specific, and not shown here */
+ PRINT_INFO(HOSTAPD_DBG, "SKB netdevice name = %s\n", skb->dev->name);
+ PRINT_INFO(HOSTAPD_DBG, "MONITOR real dev name = %s\n", mon_priv->real_ndev->name);
+
+ #ifdef SIMULATION
+ ret = WILC_WFI_Tx(skb, mon_priv->real_ndev);
+ #elif USE_WIRELESS
+ /* Identify if Ethernet or MAC header (data or mgmt) */
+ memcpy(srcAdd, &skb->data[10], 6);
+ memcpy(bssid, &skb->data[16], 6);
+ /* if source address and bssid fields are equal>>Mac header */
+ /*send it to mgmt frames handler */
+ if (!(memcmp(srcAdd, bssid, 6))) {
+ mon_mgmt_tx(mon_priv->real_ndev, skb->data, skb->len);
+ dev_kfree_skb(skb);
+ } else
+ ret = mac_xmit(skb, mon_priv->real_ndev);
+ #endif
+
+ /* return NETDEV_TX_OK; */
+ return ret;
+}
+
+static const struct net_device_ops wilc_wfi_netdev_ops = {
+ .ndo_start_xmit = WILC_WFI_mon_xmit,
+
+};
+
+#ifdef WILC_FULLY_HOSTING_AP
+/*
+ * @brief WILC_mgm_HOSTAPD_ACK
+ * @details report the status of transmitted mgmt frames to HOSTAPD
+ * @param[in] priv : pointer to tx_complete_mon_data struct
+ * bStatus : status of transmission
+ * @author Abd Al-Rahman Diab
+ * @date 9 May 2013
+ * @version 1.0
+ */
+void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus)
+{
+ struct sk_buff *skb;
+ struct wilc_wfi_radiotap_cb_hdr *cb_hdr;
+
+ struct tx_complete_mon_data *pv_data = (struct tx_complete_mon_data *)priv;
+ u8 *buf = pv_data->buff;
+
+ /* len of the original frame without the added pointer at the tail */
+ WILC_Uint16 u16len = (pv_data->size) - sizeof(struct tx_complete_mon_data *);
+
+
+ /*if(bStatus == 1){
+ * if(INFO || buf[0] == 0x10 || buf[0] == 0xb0)
+ * PRINT_D(HOSTAPD_DBG,"Packet sent successfully - Size = %d - Address = %p.\n",u16len,pv_data->buff);
+ * }else{
+ * PRINT_D(HOSTAPD_DBG,"Couldn't send packet - Size = %d - Address = %p.\n",u16len,pv_data->buff);
+ * }
+ */
+
+ /* (skb->data[9] == 0x00 || skb->data[9] == 0xb0 || skb->data[9] == 0x40 || skb->data[9] == 0xd0 ) */
+ {
+ skb = dev_alloc_skb(u16len + sizeof(struct wilc_wfi_radiotap_cb_hdr));
+
+ memcpy(skb_put(skb, u16len), pv_data->buff, u16len);
+
+ cb_hdr = (struct wilc_wfi_radiotap_cb_hdr *) skb_push(skb, sizeof(*cb_hdr));
+ memset(cb_hdr, 0, sizeof(struct wilc_wfi_radiotap_cb_hdr));
+
+ cb_hdr->hdr.it_version = 0; /* PKTHDR_RADIOTAP_VERSION; */
+
+ cb_hdr->hdr.it_len = cpu_to_le16(sizeof(struct wilc_wfi_radiotap_cb_hdr));
+
+ cb_hdr->hdr.it_present = cpu_to_le32(
+ (1 << IEEE80211_RADIOTAP_RATE) |
+ (1 << IEEE80211_RADIOTAP_TX_FLAGS));
+
+ cb_hdr->rate = 5; /* txrate->bitrate / 5; */
+
+
+ if (WILC_TRUE == bStatus) {
+ /* success */
+ cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_RTS;
+ } else {
+ cb_hdr->tx_flags = IEEE80211_RADIOTAP_F_TX_FAIL;
+ }
+
+ skb->dev = wilc_wfi_mon;
+ skb_set_mac_header(skb, 0);
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ skb->pkt_type = PACKET_OTHERHOST;
+ skb->protocol = htons(ETH_P_802_2);
+ memset(skb->cb, 0, sizeof(skb->cb));
+
+ netif_rx(skb);
+ }
+
+ /* incase of fully hosting mode, the freeing will be done in response to the cfg packet */
+ kfree(pv_data->buff);
+
+ kfree(pv_data);
+
+}
+#endif /* WILC_FULLY_HOSTING_AP */
+
+/**
+ * @brief WILC_WFI_mon_setup
+ * @details
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 12 JUL 2012
+ * @version 1.0
+ */
+static void WILC_WFI_mon_setup(struct net_device *dev)
+{
+
+ dev->netdev_ops = &wilc_wfi_netdev_ops;
+ /* dev->destructor = free_netdev; */
+ PRINT_INFO(CORECONFIG_DBG, "In Ethernet setup function\n");
+ ether_setup(dev);
+ dev->tx_queue_len = 0;
+ dev->type = ARPHRD_IEEE80211_RADIOTAP;
+ memset(dev->dev_addr, 0, ETH_ALEN);
+
+ #ifdef USE_WIRELESS
+ {
+ /* u8 * mac_add; */
+ unsigned char mac_add[] = {0x00, 0x50, 0xc2, 0x5e, 0x10, 0x8f};
+ /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */
+ /* mac_add = (u8*)WILC_MALLOC(ETH_ALEN); */
+ /* status = host_int_get_MacAddress(priv->hWILCWFIDrv,mac_add); */
+ /* mac_add[ETH_ALEN-1]+=1; */
+ memcpy(dev->dev_addr, mac_add, ETH_ALEN);
+ }
+ #else
+ dev->dev_addr[0] = 0x12;
+ #endif
+
+}
+
+/**
+ * @brief WILC_WFI_init_mon_interface
+ * @details
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 12 JUL 2012
+ * @version 1.0
+ */
+struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_device *real_dev)
+{
+
+
+ WILC_Uint32 ret = WILC_SUCCESS;
+ struct WILC_WFI_mon_priv *priv;
+
+ /*If monitor interface is already initialized, return it*/
+ if (wilc_wfi_mon) {
+ return wilc_wfi_mon;
+ }
+#if 0
+ wilc_wfi_mon = alloc_netdev(sizeof(struct WILC_WFI_mon_priv), name, WILC_WFI_mon_setup);
+ if (wilc_wfi_mon == NULL) {
+ PRINT_ER("Failed to allocate netdevice\n");
+ goto failed;
+ }
+
+ /* rtnl_lock(); */
+ PRINT_INFO(HOSTAPD_DBG, "Monitor interface name %s\n", wilc_wfi_mon->name);
+
+
+ ret = dev_alloc_name(wilc_wfi_mon, wilc_wfi_mon->name);
+ if (ret < 0)
+ goto failed_mon;
+
+
+ priv = netdev_priv(wilc_wfi_mon);
+ if (priv == NULL) {
+ PRINT_ER("private structure is NULL\n");
+ return WILC_FAIL;
+ }
+
+ priv->real_ndev = real_dev;
+
+
+ ret = register_netdevice(wilc_wfi_mon);
+
+
+ if (ret < 0) {
+ PRINT_ER("Failed to register netdevice\n");
+ goto failed_mon;
+ }
+
+
+ return WILC_SUCCESS;
+ /* rtnl_unlock(); */
+
+failed:
+ return ret;
+
+failed_mon:
+ /* rtnl_unlock(); */
+ free_netdev(wilc_wfi_mon);
+ return ret;
+#endif
+
+ wilc_wfi_mon = alloc_etherdev(sizeof(struct WILC_WFI_mon_priv));
+ if (!wilc_wfi_mon) {
+ PRINT_ER("failed to allocate memory\n");
+ return NULL;
+
+ }
+
+ wilc_wfi_mon->type = ARPHRD_IEEE80211_RADIOTAP;
+ strncpy(wilc_wfi_mon->name, name, IFNAMSIZ);
+ wilc_wfi_mon->name[IFNAMSIZ - 1] = 0;
+ wilc_wfi_mon->netdev_ops = &wilc_wfi_netdev_ops;
+
+ ret = register_netdevice(wilc_wfi_mon);
+ if (ret) {
+ PRINT_ER(" register_netdevice failed (%d)\n", ret);
+ return NULL;
+ }
+ priv = netdev_priv(wilc_wfi_mon);
+ if (priv == NULL) {
+ PRINT_ER("private structure is NULL\n");
+ return NULL;
+ }
+
+ priv->real_ndev = real_dev;
+
+ return wilc_wfi_mon;
+}
+
+/**
+ * @brief WILC_WFI_deinit_mon_interface
+ * @details
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 12 JUL 2012
+ * @version 1.0
+ */
+int WILC_WFI_deinit_mon_interface()
+{
+ bool rollback_lock = false;
+
+ if (wilc_wfi_mon != NULL) {
+ PRINT_D(HOSTAPD_DBG, "In Deinit monitor interface\n");
+ PRINT_D(HOSTAPD_DBG, "RTNL is being locked\n");
+ if (rtnl_is_locked()) {
+ rtnl_unlock();
+ rollback_lock = true;
+ }
+ PRINT_D(HOSTAPD_DBG, "Unregister netdev\n");
+ unregister_netdev(wilc_wfi_mon);
+ /* free_netdev(wilc_wfi_mon); */
+
+ if (rollback_lock) {
+ rtnl_lock();
+ rollback_lock = false;
+ }
+ wilc_wfi_mon = NULL;
+ }
+ return WILC_SUCCESS;
+
+}
+#endif /* WILC_AP_EXTERNAL_MLME */
diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c
new file mode 100644
index 00000000000000..b033eb879ca1c1
--- /dev/null
+++ b/drivers/staging/wilc1000/linux_wlan.c
@@ -0,0 +1,2871 @@
+#ifndef SIMULATION
+#include "wilc_wfi_cfgoperations.h"
+#include "linux_wlan_common.h"
+#include "wilc_wlan_if.h"
+#include "wilc_wlan.h"
+#ifdef USE_WIRELESS
+#include "wilc_wfi_cfgoperations.h"
+#endif
+
+#include "linux_wlan_common.h"
+
+#include <linux/slab.h>
+#include <linux/sched.h>
+#include <linux/delay.h>
+#include <linux/workqueue.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/gpio.h>
+
+#include <linux/kthread.h>
+#include <linux/firmware.h>
+#include <linux/delay.h>
+
+#include <linux/init.h>
+#include <linux/netdevice.h>
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+#include <linux/inetdevice.h>
+#endif
+#include <linux/etherdevice.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/skbuff.h>
+
+#include <linux/version.h>
+#include <linux/semaphore.h>
+
+#ifdef WILC_SDIO
+#include "linux_wlan_sdio.h"
+#else
+#include "linux_wlan_spi.h"
+#endif
+
+#ifdef WILC_FULLY_HOSTING_AP
+#include "wilc_host_ap.h"
+#endif
+
+#ifdef STATIC_MACADDRESS /* brandy_0724 [[ */
+#include <linux/vmalloc.h>
+#include <linux/fs.h>
+struct task_struct *wilc_mac_thread;
+unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xb2};
+#endif /* brandy_0724 ]] */
+
+#if defined(CUSTOMER_PLATFORM)
+/*
+ TODO : Write power control functions as customer platform.
+ */
+#else
+
+ #define _linux_wlan_device_power_on() {}
+ #define _linux_wlan_device_power_off() {}
+
+ #define _linux_wlan_device_detection() {}
+ #define _linux_wlan_device_removal() {}
+#endif
+
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+extern WILC_Bool g_obtainingIP;
+#endif
+extern WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue);
+extern void resolve_disconnect_aberration(void *drvHandler);
+extern u8 gau8MulticastMacAddrList[WILC_MULTICAST_TABLE_SIZE][ETH_ALEN];
+void wilc1000_wlan_deinit(linux_wlan_t *nic);
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+extern WILC_TimerHandle hDuringIpTimer;
+#endif
+
+static int linux_wlan_device_power(int on_off)
+{
+ PRINT_D(INIT_DBG, "linux_wlan_device_power.. (%d)\n", on_off);
+
+ if (on_off) {
+ _linux_wlan_device_power_on();
+ } else {
+ _linux_wlan_device_power_off();
+ }
+
+ return 0;
+}
+
+static int linux_wlan_device_detection(int on_off)
+{
+ PRINT_D(INIT_DBG, "linux_wlan_device_detection.. (%d)\n", on_off);
+
+#ifdef WILC_SDIO
+ if (on_off) {
+ _linux_wlan_device_detection();
+ } else {
+ _linux_wlan_device_removal();
+ }
+#endif
+
+ return 0;
+}
+
+
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr);
+
+static struct notifier_block g_dev_notifier = {
+ .notifier_call = dev_state_ev_handler
+};
+#endif
+
+#define wilc_wlan_deinit(nic) { if (&g_linux_wlan->oup != NULL) \
+ if (g_linux_wlan->oup.wlan_cleanup != NULL) \
+ g_linux_wlan->oup.wlan_cleanup(); }
+
+
+#ifndef STA_FIRMWARE
+#define STA_FIRMWARE "wifi_firmware.bin"
+#endif
+
+#ifndef AP_FIRMWARE
+#define AP_FIRMWARE "wifi_firmware_ap.bin"
+#endif
+
+#ifndef P2P_CONCURRENCY_FIRMWARE
+#define P2P_CONCURRENCY_FIRMWARE "wifi_firmware_p2p_concurrency.bin"
+#endif
+
+
+
+typedef struct android_wifi_priv_cmd {
+ char *buf;
+ int used_len;
+ int total_len;
+} android_wifi_priv_cmd;
+
+
+#define IRQ_WAIT 1
+#define IRQ_NO_WAIT 0
+/*
+ * to sync between mac_close and module exit.
+ * don't initialize or de-initialize from init/deinitlocks
+ * to be initialized from module wilc_netdev_init and
+ * deinitialized from mdoule_exit
+ */
+static struct semaphore close_exit_sync;
+unsigned int int_rcvdU;
+unsigned int int_rcvdB;
+unsigned int int_clrd;
+
+static int wlan_deinit_locks(linux_wlan_t *nic);
+static void wlan_deinitialize_threads(linux_wlan_t *nic);
+static void linux_wlan_lock(void *vp);
+void linux_wlan_unlock(void *vp);
+extern void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size);
+extern void WILC_WFI_p2p_rx(struct net_device *dev, uint8_t *buff, uint32_t size);
+
+
+static void *internal_alloc(uint32_t size, uint32_t flag);
+static void linux_wlan_tx_complete(void *priv, int status);
+void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset);
+static int mac_init_fn(struct net_device *ndev);
+int mac_xmit(struct sk_buff *skb, struct net_device *dev);
+int mac_open(struct net_device *ndev);
+int mac_close(struct net_device *ndev);
+static struct net_device_stats *mac_stats(struct net_device *dev);
+static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd);
+static void wilc_set_multicast_list(struct net_device *dev);
+
+
+
+/*
+ * for now - in frmw_to_linux there should be private data to be passed to it
+ * and this data should be pointer to net device
+ */
+linux_wlan_t *g_linux_wlan;
+wilc_wlan_oup_t *gpstrWlanOps;
+WILC_Bool bEnablePS = WILC_TRUE;
+
+static const struct net_device_ops wilc_netdev_ops = {
+ .ndo_init = mac_init_fn,
+ .ndo_open = mac_open,
+ .ndo_stop = mac_close,
+ .ndo_start_xmit = mac_xmit,
+ .ndo_do_ioctl = mac_ioctl,
+ .ndo_get_stats = mac_stats,
+ .ndo_set_rx_mode = wilc_set_multicast_list,
+
+};
+
+#ifdef DEBUG_MODE
+
+extern volatile int timeNo;
+
+#define DEGUG_BUFFER_LENGTH 1000
+volatile int WatchDogdebuggerCounter;
+char DebugBuffer[DEGUG_BUFFER_LENGTH + 20] = {0};
+static char *ps8current = DebugBuffer;
+
+
+
+void printk_later(const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ ps8current += vsprintf (ps8current, format, args);
+ va_end (args);
+ if ((ps8current - DebugBuffer) > DEGUG_BUFFER_LENGTH) {
+ ps8current = DebugBuffer;
+ }
+
+}
+
+
+void dump_logs()
+{
+ if (DebugBuffer[0]) {
+ DebugBuffer[DEGUG_BUFFER_LENGTH] = 0;
+ PRINT_INFO(GENERIC_DBG, "early printed\n");
+ PRINT_D(GENERIC_DBG, ps8current + 1);
+ ps8current[1] = 0;
+ PRINT_INFO(GENERIC_DBG, "latest printed\n");
+ PRINT_D(GENERIC_DBG, DebugBuffer);
+ DebugBuffer[0] = 0;
+ ps8current = DebugBuffer;
+ }
+}
+
+void Reset_WatchDogdebugger()
+{
+ WatchDogdebuggerCounter = 0;
+}
+
+static int DebuggingThreadTask(void *vp)
+{
+ while (1) {
+ while (!WatchDogdebuggerCounter) {
+ PRINT_D(GENERIC_DBG, "Debug Thread Running %d\n", timeNo);
+ WatchDogdebuggerCounter = 1;
+ msleep(10000);
+ }
+ dump_logs();
+ WatchDogdebuggerCounter = 0;
+ }
+}
+
+
+#endif
+
+
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+static int dev_state_ev_handler(struct notifier_block *this, unsigned long event, void *ptr)
+{
+ struct in_ifaddr *dev_iface = (struct in_ifaddr *)ptr;
+ struct WILC_WFI_priv *priv;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+ struct net_device *dev;
+ u8 *pIP_Add_buff;
+ WILC_Sint32 s32status = WILC_FAIL;
+ perInterface_wlan_t *nic;
+ u8 null_ip[4] = {0};
+ char wlan_dev_name[5] = "wlan0";
+
+ if (dev_iface == NULL || dev_iface->ifa_dev == NULL || dev_iface->ifa_dev->dev == NULL) {
+ PRINT_D(GENERIC_DBG, "dev_iface = NULL\n");
+ return NOTIFY_DONE;
+ }
+
+ if ((memcmp(dev_iface->ifa_label, "wlan0", 5)) && (memcmp(dev_iface->ifa_label, "p2p0", 4))) {
+ PRINT_D(GENERIC_DBG, "Interface is neither WLAN0 nor P2P0\n");
+ return NOTIFY_DONE;
+ }
+
+ dev = (struct net_device *)dev_iface->ifa_dev->dev;
+ if (dev->ieee80211_ptr == NULL || dev->ieee80211_ptr->wiphy == NULL) {
+ PRINT_D(GENERIC_DBG, "No Wireless registerd\n");
+ return NOTIFY_DONE;
+ }
+ priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
+ if (priv == NULL) {
+ PRINT_D(GENERIC_DBG, "No Wireless Priv\n");
+ return NOTIFY_DONE;
+ }
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+ nic = netdev_priv(dev);
+ if (nic == NULL || pstrWFIDrv == NULL) {
+ PRINT_D(GENERIC_DBG, "No Wireless Priv\n");
+ return NOTIFY_DONE;
+ }
+
+ PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler +++\n"); /* tony */
+
+ switch (event) {
+ case NETDEV_UP:
+ PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_UP %p\n", dev); /* tony */
+
+ PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Obtained ===============\n\n");
+
+
+ /*If we are in station mode or client mode*/
+ if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) {
+ pstrWFIDrv->IFC_UP = 1;
+ g_obtainingIP = WILC_FALSE;
+ WILC_TimerStop(&hDuringIpTimer, NULL);
+ PRINT_D(GENERIC_DBG, "IP obtained , enable scan\n");
+ }
+
+
+
+ if (bEnablePS == WILC_TRUE)
+ host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 1, 0);
+
+ PRINT_D(GENERIC_DBG, "[%s] Up IP\n", dev_iface->ifa_label);
+
+ pIP_Add_buff = (char *) (&(dev_iface->ifa_address));
+ PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d \n", pIP_Add_buff[0], pIP_Add_buff[1], pIP_Add_buff[2], pIP_Add_buff[3]);
+ s32status = host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx);
+
+ break;
+
+ case NETDEV_DOWN:
+ PRINT_D(GENERIC_DBG, "dev_state_ev_handler event=NETDEV_DOWN %p\n", dev); /* tony */
+
+ PRINT_INFO(GENERIC_DBG, "\n ============== IP Address Released ===============\n\n");
+ if (nic->iftype == STATION_MODE || nic->iftype == CLIENT_MODE) {
+ pstrWFIDrv->IFC_UP = 0;
+ g_obtainingIP = WILC_FALSE;
+ }
+
+ if (memcmp(dev_iface->ifa_label, wlan_dev_name, 5) == 0)
+ host_int_set_power_mgmt((WILC_WFIDrvHandle)pstrWFIDrv, 0, 0);
+
+ resolve_disconnect_aberration(pstrWFIDrv);
+
+
+ PRINT_D(GENERIC_DBG, "[%s] Down IP\n", dev_iface->ifa_label);
+
+ pIP_Add_buff = null_ip;
+ PRINT_D(GENERIC_DBG, "IP add=%d:%d:%d:%d \n", pIP_Add_buff[0], pIP_Add_buff[1], pIP_Add_buff[2], pIP_Add_buff[3]);
+
+ s32status = host_int_setup_ipaddress((WILC_WFIDrvHandle)pstrWFIDrv, pIP_Add_buff, nic->u8IfIdx);
+
+ break;
+
+ default:
+ PRINT_INFO(GENERIC_DBG, "dev_state_ev_handler event=default\n"); /* tony */
+ PRINT_INFO(GENERIC_DBG, "[%s] unknown dev event: %lu\n", dev_iface->ifa_label, event);
+
+ break;
+ }
+
+ return NOTIFY_DONE;
+
+}
+#endif
+
+/*
+ * Interrupt initialization and handling functions
+ */
+
+void linux_wlan_enable_irq(void)
+{
+
+#if (RX_BH_TYPE != RX_BH_THREADED_IRQ)
+#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
+ PRINT_D(INT_DBG, "Enabling IRQ ...\n");
+ enable_irq(g_linux_wlan->dev_irq_num);
+#endif
+#endif
+}
+
+void linux_wlan_disable_irq(int wait)
+{
+#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
+ if (wait) {
+ PRINT_D(INT_DBG, "Disabling IRQ ...\n");
+ disable_irq(g_linux_wlan->dev_irq_num);
+ } else {
+ PRINT_D(INT_DBG, "Disabling IRQ ...\n");
+ disable_irq_nosync(g_linux_wlan->dev_irq_num);
+ }
+#endif
+}
+
+#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
+static irqreturn_t isr_uh_routine(int irq, void *user_data)
+{
+
+
+ int_rcvdU++;
+#if (RX_BH_TYPE != RX_BH_THREADED_IRQ)
+ linux_wlan_disable_irq(IRQ_NO_WAIT);
+#endif
+ PRINT_D(INT_DBG, "Interrupt received UH\n");
+
+ /*While mac is closing cacncel the handling of any interrupts received*/
+ if (g_linux_wlan->close) {
+ PRINT_ER("Driver is CLOSING: Can't handle UH interrupt\n");
+ #if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
+ return IRQ_HANDLED;
+ #else
+ return IRQ_NONE;
+ #endif
+
+ }
+#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
+ schedule_work(&g_linux_wlan->rx_work_queue);
+ return IRQ_HANDLED;
+#elif (RX_BH_TYPE == RX_BH_KTHREAD)
+ linux_wlan_unlock(&g_linux_wlan->rx_sem);
+ return IRQ_HANDLED;
+#elif (RX_BH_TYPE == RX_BH_THREADED_IRQ)
+ return IRQ_WAKE_THREAD;
+#endif
+
+}
+#endif
+
+#if (RX_BH_TYPE == RX_BH_WORK_QUEUE || RX_BH_TYPE == RX_BH_THREADED_IRQ)
+
+#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
+irqreturn_t isr_bh_routine(int irq, void *userdata)
+{
+ linux_wlan_t *nic;
+ nic = (linux_wlan_t *)userdata;
+#else
+static void isr_bh_routine(struct work_struct *work)
+{
+ perInterface_wlan_t *nic;
+ nic = (perInterface_wlan_t *)container_of(work, linux_wlan_t, rx_work_queue);
+#endif
+
+ /*While mac is closing cacncel the handling of any interrupts received*/
+ if (g_linux_wlan->close) {
+ PRINT_ER("Driver is CLOSING: Can't handle BH interrupt\n");
+ #if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
+ return IRQ_HANDLED;
+ #else
+ return;
+ #endif
+
+
+
+ }
+
+ int_rcvdB++;
+ PRINT_D(INT_DBG, "Interrupt received BH\n");
+ if (g_linux_wlan->oup.wlan_handle_rx_isr != 0) {
+ g_linux_wlan->oup.wlan_handle_rx_isr();
+ } else {
+ PRINT_ER("wlan_handle_rx_isr() hasn't been initialized\n");
+ }
+
+
+#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
+ return IRQ_HANDLED;
+#endif
+}
+#elif (RX_BH_TYPE == RX_BH_KTHREAD)
+static int isr_bh_routine(void *vp)
+{
+ linux_wlan_t *nic;
+
+ nic = (linux_wlan_t *)vp;
+
+ while (1) {
+ linux_wlan_lock(&nic->rx_sem);
+ if (g_linux_wlan->close) {
+
+ while (!kthread_should_stop())
+ schedule();
+
+ break;
+ }
+ int_rcvdB++;
+ PRINT_D(INT_DBG, "Interrupt received BH\n");
+ if (g_linux_wlan->oup.wlan_handle_rx_isr != 0) {
+ g_linux_wlan->oup.wlan_handle_rx_isr();
+ } else {
+ PRINT_ER("wlan_handle_rx_isr() hasn't been initialized\n");
+ }
+ }
+
+ return 0;
+}
+#endif
+
+
+#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
+static int init_irq(linux_wlan_t *p_nic)
+{
+ int ret = 0;
+ linux_wlan_t *nic = p_nic;
+
+ /*initialize GPIO and register IRQ num*/
+ /*GPIO request*/
+ if ((gpio_request(GPIO_NUM, "WILC_INTR") == 0) &&
+ (gpio_direction_input(GPIO_NUM) == 0)) {
+#if defined(CUSTOMER_PLATFORM)
+/*
+ TODO : save the registerd irq number to the private wilc context in kernel.
+ *
+ * ex) nic->dev_irq_num = gpio_to_irq(GPIO_NUM);
+ */
+#elif defined (NM73131_0_BOARD)
+ nic->dev_irq_num = IRQ_WILC1000;
+#elif defined (PANDA_BOARD)
+ gpio_export(GPIO_NUM, 1);
+ nic->dev_irq_num = OMAP_GPIO_IRQ(GPIO_NUM);
+ irq_set_irq_type(nic->dev_irq_num, IRQ_TYPE_LEVEL_LOW);
+#else
+ nic->dev_irq_num = gpio_to_irq(GPIO_NUM);
+#endif
+ } else {
+ ret = -1;
+ PRINT_ER("could not obtain gpio for WILC_INTR\n");
+ }
+
+
+#if (RX_BH_TYPE == RX_BH_THREADED_IRQ)
+ if ((ret != -1) && (request_threaded_irq(nic->dev_irq_num, isr_uh_routine, isr_bh_routine,
+ IRQF_TRIGGER_LOW | IRQF_ONESHOT, /*Without IRQF_ONESHOT the uh will remain kicked in and dont gave a chance to bh*/
+ "WILC_IRQ", nic)) < 0) {
+
+#else
+ /*Request IRQ*/
+ if ((ret != -1) && (request_irq(nic->dev_irq_num, isr_uh_routine,
+ IRQF_TRIGGER_LOW, "WILC_IRQ", nic) < 0)) {
+
+#endif
+ PRINT_ER("Failed to request IRQ for GPIO: %d\n", GPIO_NUM);
+ ret = -1;
+ } else {
+
+ PRINT_D(INIT_DBG, "IRQ request succeeded IRQ-NUM= %d on GPIO: %d\n",
+ nic->dev_irq_num, GPIO_NUM);
+ }
+
+ return ret;
+}
+#endif
+
+static void deinit_irq(linux_wlan_t *nic)
+{
+#if (defined WILC_SPI) || (defined WILC_SDIO_IRQ_GPIO)
+ /* Deintialize IRQ */
+ if (&nic->dev_irq_num != 0) {
+ free_irq(nic->dev_irq_num, g_linux_wlan);
+
+ gpio_free(GPIO_NUM);
+ }
+#endif
+}
+
+
+/*
+ * OS functions
+ */
+static void linux_wlan_msleep(uint32_t msc)
+{
+ if (msc <= 4000000) {
+ WILC_Uint32 u32Temp = msc * 1000;
+ usleep_range(u32Temp, u32Temp);
+ } else {
+ msleep(msc);
+ }
+}
+
+static void linux_wlan_atomic_msleep(uint32_t msc)
+{
+ mdelay(msc);
+}
+static void linux_wlan_dbg(uint8_t *buff)
+{
+ PRINT_D(INIT_DBG, "%d\n", *buff);
+}
+
+static void *linux_wlan_malloc_atomic(uint32_t sz)
+{
+ char *pntr = NULL;
+ pntr = (char *)kmalloc(sz, GFP_ATOMIC);
+ PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
+ return (void *)pntr;
+
+}
+static void *linux_wlan_malloc(uint32_t sz)
+{
+ char *pntr = NULL;
+ pntr = (char *)kmalloc(sz, GFP_KERNEL);
+ PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", sz, pntr);
+ return (void *)pntr;
+}
+
+void linux_wlan_free(void *vp)
+{
+ if (vp != NULL) {
+ PRINT_D(MEM_DBG, "Freeing %p\n", vp);
+ kfree(vp);
+ }
+}
+
+
+static void *internal_alloc(uint32_t size, uint32_t flag)
+{
+ char *pntr = NULL;
+ pntr = (char *)kmalloc(size, flag);
+ PRINT_D(MEM_DBG, "Allocating %d bytes at address %p\n", size, pntr);
+ return (void *)pntr;
+}
+
+
+static void linux_wlan_init_lock(char *lockName, void *plock, int count)
+{
+ sema_init((struct semaphore *)plock, count);
+ PRINT_D(LOCK_DBG, "Initializing [%s][%p]\n", lockName, plock);
+
+}
+
+static void linux_wlan_deinit_lock(void *plock)
+{
+ /* mutex_destroy((struct mutex*)plock); */
+}
+
+static void linux_wlan_lock(void *vp)
+{
+ PRINT_D(LOCK_DBG, "Locking %p\n", vp);
+ if (vp != NULL) {
+ while (down_interruptible((struct semaphore *) vp))
+ ;
+ } else {
+ PRINT_ER("Failed, mutex is NULL\n");
+ }
+}
+
+static int linux_wlan_lock_timeout(void *vp, WILC_Uint32 timeout)
+{
+ int error = -1;
+ PRINT_D(LOCK_DBG, "Locking %p\n", vp);
+ if (vp != NULL) {
+ error = down_timeout((struct semaphore *)vp, msecs_to_jiffies(timeout));
+ } else {
+ PRINT_ER("Failed, mutex is NULL\n");
+ }
+ return error;
+}
+
+void linux_wlan_unlock(void *vp)
+{
+ PRINT_D(LOCK_DBG, "Unlocking %p\n", vp);
+ if (vp != NULL) {
+ up((struct semaphore *)vp);
+ } else {
+ PRINT_ER("Failed, mutex is NULL\n");
+ }
+}
+
+
+static void linux_wlan_init_mutex(char *lockName, void *plock, int count)
+{
+ mutex_init((struct mutex *)plock);
+ PRINT_D(LOCK_DBG, "Initializing mutex [%s][%p]\n", lockName, plock);
+
+}
+
+static void linux_wlan_deinit_mutex(void *plock)
+{
+ mutex_destroy((struct mutex *)plock);
+}
+
+static void linux_wlan_lock_mutex(void *vp)
+{
+ PRINT_D(LOCK_DBG, "Locking mutex %p\n", vp);
+ if (vp != NULL) {
+ /*
+ * if(mutex_is_locked((struct mutex*)vp))
+ * {
+ * //PRINT_ER("Mutex already locked - %p \n",vp);
+ * }
+ */
+ mutex_lock((struct mutex *)vp);
+
+ } else {
+ PRINT_ER("Failed, mutex is NULL\n");
+ }
+}
+
+static void linux_wlan_unlock_mutex(void *vp)
+{
+ PRINT_D(LOCK_DBG, "Unlocking mutex %p\n", vp);
+ if (vp != NULL) {
+
+ if (mutex_is_locked((struct mutex *)vp)) {
+ mutex_unlock((struct mutex *)vp);
+ } else {
+ /* PRINT_ER("Mutex already unlocked - %p\n",vp); */
+ }
+
+ } else {
+ PRINT_ER("Failed, mutex is NULL\n");
+ }
+}
+
+
+/*Added by Amr - BugID_4720*/
+static void linux_wlan_init_spin_lock(char *lockName, void *plock, int count)
+{
+ spin_lock_init((spinlock_t *)plock);
+ PRINT_D(SPIN_DEBUG, "Initializing mutex [%s][%p]\n", lockName, plock);
+
+}
+
+static void linux_wlan_deinit_spin_lock(void *plock)
+{
+
+}
+static void linux_wlan_spin_lock(void *vp, unsigned long *flags)
+{
+ unsigned long lflags;
+ PRINT_D(SPIN_DEBUG, "Lock spin %p\n", vp);
+ if (vp != NULL) {
+ spin_lock_irqsave((spinlock_t *)vp, lflags);
+ *flags = lflags;
+ } else {
+ PRINT_ER("Failed, spin lock is NULL\n");
+ }
+}
+static void linux_wlan_spin_unlock(void *vp, unsigned long *flags)
+{
+ unsigned long lflags = *flags;
+ PRINT_D(SPIN_DEBUG, "Unlock spin %p\n", vp);
+ if (vp != NULL) {
+ spin_unlock_irqrestore((spinlock_t *)vp, lflags);
+ *flags = lflags;
+ } else {
+ PRINT_ER("Failed, spin lock is NULL\n");
+ }
+}
+
+static void linux_wlan_mac_indicate(int flag)
+{
+ /*I have to do it that way becuase there is no mean to encapsulate device pointer
+ * as a parameter
+ */
+ linux_wlan_t *pd = g_linux_wlan;
+ int status;
+
+ if (flag == WILC_MAC_INDICATE_STATUS) {
+ pd->oup.wlan_cfg_get_value(WID_STATUS, (unsigned char *)&status, 4);
+ if (pd->mac_status == WILC_MAC_STATUS_INIT) {
+ pd->mac_status = status;
+ linux_wlan_unlock(&pd->sync_event);
+ } else {
+ pd->mac_status = status;
+ }
+
+ if (pd->mac_status == WILC_MAC_STATUS_CONNECT) { /* Connect */
+#if 0
+ /**
+ * get the mac and bssid address
+ **/
+ PRINT_D(RX_DBG, "Calling cfg_get to get MAC_ADDR\n");
+ pd->oup.wlan_cfg_get(1, WID_MAC_ADDR, 0);
+ PRINT_D(RX_DBG, "Calling cfg_get to get BSSID\n");
+ pd->oup.wlan_cfg_get(0, WID_BSSID, 1);
+
+ /**
+ * get the value
+ **/
+ pd->oup.wlan_cfg_get_value(WID_MAC_ADDR, pd->eth_src_address, 6);
+ pd->oup.wlan_cfg_get_value(WID_BSSID, pd->eth_dst_address, 6);
+
+ PRINT_D(GENERIC_DBG, "Source Address = %s", pd->eth_src_address);
+ PRINT_D(GENERIC_DBG, "Destiation Address = %s", pd->eth_dst_address);
+
+ /**
+ * launch ndis
+ **/
+#endif
+ }
+
+ } else if (flag == WILC_MAC_INDICATE_SCAN) {
+ PRINT_D(GENERIC_DBG, "Scanning ...\n");
+
+ }
+
+}
+
+struct net_device *GetIfHandler(uint8_t *pMacHeader)
+{
+ uint8_t *Bssid, *Bssid1;
+ int i = 0;
+
+ Bssid = pMacHeader + 10;
+ Bssid1 = pMacHeader + 4;
+
+ for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
+ if (!memcmp(Bssid1, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN) ||
+ !memcmp(Bssid, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN)) {
+ return g_linux_wlan->strInterfaceInfo[i].wilc_netdev;
+ }
+ }
+ PRINT_INFO(INIT_DBG, "Invalide handle\n");
+ for (i = 0; i < 25; i++) {
+ PRINT_D(INIT_DBG, "%02x ", pMacHeader[i]);
+ }
+ Bssid = pMacHeader + 18;
+ Bssid1 = pMacHeader + 12;
+ for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
+ if (!memcmp(Bssid1, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN) ||
+ !memcmp(Bssid, g_linux_wlan->strInterfaceInfo[i].aBSSID, ETH_ALEN)) {
+ PRINT_D(INIT_DBG, "Ctx [%p]\n", g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ return g_linux_wlan->strInterfaceInfo[i].wilc_netdev;
+ }
+ }
+ PRINT_INFO(INIT_DBG, "\n");
+ return NULL;
+}
+
+int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID)
+{
+ int i = 0;
+ int ret = -1;
+
+ PRINT_D(INIT_DBG, "set bssid on[%p]\n", wilc_netdev);
+ for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
+ if (g_linux_wlan->strInterfaceInfo[i].wilc_netdev == wilc_netdev) {
+ PRINT_D(INIT_DBG, "set bssid [%x][%x][%x]\n", pBSSID[0], pBSSID[1], pBSSID[2]);
+ memcpy(g_linux_wlan->strInterfaceInfo[i].aBSSID, pBSSID, 6);
+ ret = 0;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*BugID_5213*/
+/*Function to get number of connected interfaces*/
+int linux_wlan_get_num_conn_ifcs(void)
+{
+ uint8_t i = 0;
+ uint8_t null_bssid[6] = {0};
+ uint8_t ret_val = 0;
+
+ for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
+ if (memcmp(g_linux_wlan->strInterfaceInfo[i].aBSSID, null_bssid, 6)) {
+ ret_val++;
+ }
+ }
+ return ret_val;
+}
+
+static int linux_wlan_rxq_task(void *vp)
+{
+
+ /* inform wilc1000_wlan_init that RXQ task is started. */
+ linux_wlan_unlock(&g_linux_wlan->rxq_thread_started);
+ while (1) {
+ linux_wlan_lock(&g_linux_wlan->rxq_event);
+ /* wait_for_completion(&g_linux_wlan->rxq_event); */
+
+ if (g_linux_wlan->close) {
+ /*Unlock the mutex in the mac_close function to indicate the exiting of the RX thread */
+ linux_wlan_unlock(&g_linux_wlan->rxq_thread_started);
+
+ while (!kthread_should_stop())
+ schedule();
+
+ PRINT_D(RX_DBG, " RX thread stopped\n");
+ break;
+ }
+ PRINT_D(RX_DBG, "Calling wlan_handle_rx_que()\n");
+
+ g_linux_wlan->oup.wlan_handle_rx_que();
+ }
+ return 0;
+}
+
+#define USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
+
+static int linux_wlan_txq_task(void *vp)
+{
+ int ret, txq_count;
+
+#if defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
+#define TX_BACKOFF_WEIGHT_INCR_STEP (1)
+#define TX_BACKOFF_WEIGHT_DECR_STEP (1)
+#define TX_BACKOFF_WEIGHT_MAX (7)
+#define TX_BACKOFF_WEIGHT_MIN (0)
+#define TX_BACKOFF_WEIGHT_UNIT_MS (10)
+ int backoff_weight = TX_BACKOFF_WEIGHT_MIN;
+ signed long timeout;
+#endif
+
+ /* inform wilc1000_wlan_init that TXQ task is started. */
+ linux_wlan_unlock(&g_linux_wlan->txq_thread_started);
+ while (1) {
+
+ PRINT_D(TX_DBG, "txq_task Taking a nap :)\n");
+ linux_wlan_lock(&g_linux_wlan->txq_event);
+ /* wait_for_completion(&pd->txq_event); */
+ PRINT_D(TX_DBG, "txq_task Who waked me up :$\n");
+
+ if (g_linux_wlan->close) {
+ /*Unlock the mutex in the mac_close function to indicate the exiting of the TX thread */
+ linux_wlan_unlock(&g_linux_wlan->txq_thread_started);
+
+ while (!kthread_should_stop())
+ schedule();
+
+ PRINT_D(TX_DBG, "TX thread stopped\n");
+ break;
+ }
+ PRINT_D(TX_DBG, "txq_task handle the sending packet and let me go to sleep.\n");
+#if !defined USE_TX_BACKOFF_DELAY_IF_NO_BUFFERS
+ g_linux_wlan->oup.wlan_handle_tx_que();
+#else
+ do {
+ ret = g_linux_wlan->oup.wlan_handle_tx_que(&txq_count);
+ if (txq_count < FLOW_CONTROL_LOWER_THRESHOLD /* && netif_queue_stopped(pd->wilc_netdev)*/) {
+ PRINT_D(TX_DBG, "Waking up queue\n");
+ /* netif_wake_queue(pd->wilc_netdev); */
+ if (netif_queue_stopped(g_linux_wlan->strInterfaceInfo[0].wilc_netdev))
+ netif_wake_queue(g_linux_wlan->strInterfaceInfo[0].wilc_netdev);
+ if (netif_queue_stopped(g_linux_wlan->strInterfaceInfo[1].wilc_netdev))
+ netif_wake_queue(g_linux_wlan->strInterfaceInfo[1].wilc_netdev);
+ }
+
+ if (ret == WILC_TX_ERR_NO_BUF) { /* failed to allocate buffers in chip. */
+ timeout = msecs_to_jiffies(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight);
+ do {
+ /* Back off from sending packets for some time. */
+ /* schedule_timeout will allow RX task to run and free buffers.*/
+ /* set_current_state(TASK_UNINTERRUPTIBLE); */
+ /* timeout = schedule_timeout(timeout); */
+ msleep(TX_BACKOFF_WEIGHT_UNIT_MS << backoff_weight);
+ } while (/*timeout*/ 0);
+ backoff_weight += TX_BACKOFF_WEIGHT_INCR_STEP;
+ if (backoff_weight > TX_BACKOFF_WEIGHT_MAX) {
+ backoff_weight = TX_BACKOFF_WEIGHT_MAX;
+ }
+ } else {
+ if (backoff_weight > TX_BACKOFF_WEIGHT_MIN) {
+ backoff_weight -= TX_BACKOFF_WEIGHT_DECR_STEP;
+ if (backoff_weight < TX_BACKOFF_WEIGHT_MIN) {
+ backoff_weight = TX_BACKOFF_WEIGHT_MIN;
+ }
+ }
+ }
+ /*TODO: drop packets after a certain time/number of retry count. */
+ } while (ret == WILC_TX_ERR_NO_BUF && !g_linux_wlan->close); /* retry sending packets if no more buffers in chip. */
+#endif
+ }
+ return 0;
+}
+
+static void linux_wlan_rx_complete(void)
+{
+ PRINT_D(RX_DBG, "RX completed\n");
+}
+
+int linux_wlan_get_firmware(perInterface_wlan_t *p_nic)
+{
+
+ perInterface_wlan_t *nic = p_nic;
+ int ret = 0;
+ const struct firmware *wilc_firmware;
+ char *firmware;
+
+
+ if (nic->iftype == AP_MODE)
+ firmware = AP_FIRMWARE;
+ else if (nic->iftype == STATION_MODE)
+ firmware = STA_FIRMWARE;
+
+ /*BugID_5137*/
+ else {
+ PRINT_D(INIT_DBG, "Get P2P_CONCURRENCY_FIRMWARE\n");
+ firmware = P2P_CONCURRENCY_FIRMWARE;
+ }
+
+
+
+ if (nic == NULL) {
+ PRINT_ER("NIC is NULL\n");
+ goto _fail_;
+ }
+
+ if (&nic->wilc_netdev->dev == NULL) {
+ PRINT_ER("&nic->wilc_netdev->dev is NULL\n");
+ goto _fail_;
+ }
+
+
+ /* the firmare should be located in /lib/firmware in
+ * root file system with the name specified above */
+
+#ifdef WILC_SDIO
+ if (request_firmware(&wilc_firmware, firmware, &g_linux_wlan->wilc_sdio_func->dev) != 0) {
+ PRINT_ER("%s - firmare not available\n", firmware);
+ ret = -1;
+ goto _fail_;
+ }
+#else
+ if (request_firmware(&wilc_firmware, firmware, &g_linux_wlan->wilc_spidev->dev) != 0) {
+ PRINT_ER("%s - firmare not available\n", firmware);
+ ret = -1;
+ goto _fail_;
+ }
+#endif
+ g_linux_wlan->wilc_firmware = wilc_firmware; /* Bug 4703 */
+
+_fail_:
+
+ return ret;
+
+}
+
+#ifdef COMPLEMENT_BOOT
+int repeat_power_cycle(perInterface_wlan_t *nic);
+#endif
+
+static int linux_wlan_start_firmware(perInterface_wlan_t *nic)
+{
+
+ int ret = 0;
+ /* start firmware */
+ PRINT_D(INIT_DBG, "Starting Firmware ...\n");
+ ret = g_linux_wlan->oup.wlan_start();
+ if (ret < 0) {
+ PRINT_ER("Failed to start Firmware\n");
+ goto _fail_;
+ }
+
+ /* wait for mac ready */
+ PRINT_D(INIT_DBG, "Waiting for Firmware to get ready ...\n");
+ ret = linux_wlan_lock_timeout(&g_linux_wlan->sync_event, 5000);
+ if (ret) {
+#ifdef COMPLEMENT_BOOT
+ static int timeout = 5;
+
+ if (timeout--) {
+ PRINT_D(INIT_DBG, "repeat power cycle[%d]", timeout);
+ ret = repeat_power_cycle(nic);
+ } else {
+ timeout = 5;
+ ret = -1;
+ goto _fail_;
+ }
+#endif
+ PRINT_D(INIT_DBG, "Firmware start timed out");
+ goto _fail_;
+ }
+ /*
+ * TODO: Driver shouoldn't wait forever for firmware to get started -
+ * in case of timeout this should be handled properly
+ */
+ PRINT_D(INIT_DBG, "Firmware successfully started\n");
+
+_fail_:
+ return ret;
+}
+static int linux_wlan_firmware_download(linux_wlan_t *p_nic)
+{
+
+ int ret = 0;
+
+ if (g_linux_wlan->wilc_firmware == NULL) {
+ PRINT_ER("Firmware buffer is NULL\n");
+ ret = -ENOBUFS;
+ goto _FAIL_;
+ }
+ /**
+ * do the firmware download
+ **/
+ PRINT_D(INIT_DBG, "Downloading Firmware ...\n");
+ ret = g_linux_wlan->oup.wlan_firmware_download(g_linux_wlan->wilc_firmware->data, g_linux_wlan->wilc_firmware->size);
+ if (ret < 0) {
+ goto _FAIL_;
+ }
+
+ /* Freeing FW buffer */
+ PRINT_D(INIT_DBG, "Freeing FW buffer ...\n");
+ PRINT_D(INIT_DBG, "Releasing firmware\n");
+ release_firmware(g_linux_wlan->wilc_firmware);
+ g_linux_wlan->wilc_firmware = NULL;
+
+ PRINT_D(INIT_DBG, "Download Succeeded \n");
+
+_FAIL_:
+ return ret;
+}
+
+
+/* startup configuration - could be changed later using iconfig*/
+static int linux_wlan_init_test_config(struct net_device *dev, linux_wlan_t *p_nic)
+{
+
+ unsigned char c_val[64];
+ #ifndef STATIC_MACADDRESS
+ unsigned char mac_add[] = {0x00, 0x80, 0xC2, 0x5E, 0xa2, 0xff};
+ #endif
+ unsigned int chipid = 0;
+
+ /*BugID_5077*/
+ struct WILC_WFI_priv *priv;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+
+ PRINT_D(TX_DBG, "Start configuring Firmware\n");
+ #ifndef STATIC_MACADDRESS
+ get_random_bytes(&mac_add[5], 1);
+ get_random_bytes(&mac_add[4], 1);
+ #endif
+ priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+ PRINT_D(INIT_DBG, "Host = %x\n", (WILC_Uint32)pstrWFIDrv);
+
+ PRINT_D(INIT_DBG, "MAC address is : %02x-%02x-%02x-%02x-%02x-%02x\n", mac_add[0], mac_add[1], mac_add[2], mac_add[3], mac_add[4], mac_add[5]);
+ chipid = wilc_get_chipid(0);
+
+
+ if (g_linux_wlan->oup.wlan_cfg_set == NULL) {
+ PRINT_D(INIT_DBG, "Null p[ointer\n");
+ goto _fail_;
+ }
+
+ *(int *)c_val = (WILC_Uint32)pstrWFIDrv;
+
+ if (!g_linux_wlan->oup.wlan_cfg_set(1, WID_SET_DRV_HANDLER, c_val, 4, 0, 0))
+ goto _fail_;
+
+ /*to tell fw that we are going to use PC test - WILC specific*/
+ c_val[0] = 0;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_PC_TEST_MODE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = INFRASTRUCTURE;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BSS_TYPE, c_val, 1, 0, 0))
+ goto _fail_;
+
+
+ /* c_val[0] = RATE_AUTO; / * bug 4275: Enable autorate and limit it to 24Mbps * / */
+ c_val[0] = RATE_AUTO;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_CURRENT_TX_RATE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = G_MIXED_11B_2_MODE;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11G_OPERATING_MODE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 1;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_CURRENT_CHANNEL, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = G_SHORT_PREAMBLE;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_PREAMBLE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = AUTO_PROT;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_PROT_MECH, c_val, 1, 0, 0))
+ goto _fail_;
+
+#ifdef SWITCH_LOG_TERMINAL
+ c_val[0] = AUTO_PROT;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_LOGTerminal_Switch, c_val, 1, 0, 0))
+ goto _fail_;
+#endif
+
+ c_val[0] = ACTIVE_SCAN;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SCAN_TYPE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = SITE_SURVEY_OFF;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SITE_SURVEY, c_val, 1, 0, 0))
+ goto _fail_;
+
+ *((int *)c_val) = 0xffff; /* Never use RTS-CTS */
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_RTS_THRESHOLD, c_val, 2, 0, 0))
+ goto _fail_;
+
+ *((int *)c_val) = 2346;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_FRAG_THRESHOLD, c_val, 2, 0, 0))
+ goto _fail_;
+
+ /* SSID */
+ /* -------------------------------------------------------------- */
+ /* Configuration : String with length less than 32 bytes */
+ /* Values to set : Any string with length less than 32 bytes */
+ /* ( In BSS Station Set SSID to "" (null string) */
+ /* to enable Broadcast SSID suppport ) */
+ /* -------------------------------------------------------------- */
+#ifndef USE_WIRELESS
+ strcpy(c_val, "nwifi");
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SSID, c_val, (strlen(c_val) + 1), 0, 0))
+ goto _fail_;
+#endif
+
+ c_val[0] = 0;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BCAST_SSID, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 1;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_QOS_ENABLE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = NO_POWERSAVE;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_POWER_MANAGEMENT, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = NO_ENCRYPT; /* NO_ENCRYPT, 0x79 */
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11I_MODE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = OPEN_SYSTEM;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_AUTH_TYPE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ /* WEP/802 11I Configuration */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : WEP Key */
+ /* Values (0x) : 5 byte for WEP40 and 13 bytes for WEP104 */
+ /* In case more than 5 bytes are passed on for WEP 40 */
+ /* only first 5 bytes will be used as the key */
+ /* ------------------------------------------------------------------ */
+
+ strcpy(c_val, "123456790abcdef1234567890");
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_WEP_KEY_VALUE, c_val, (strlen(c_val) + 1), 0, 0))
+ goto _fail_;
+
+ /* WEP/802 11I Configuration */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : AES/TKIP WPA/RSNA Pre-Shared Key */
+ /* Values to set : Any string with length greater than equal to 8 bytes */
+ /* and less than 64 bytes */
+ /* ------------------------------------------------------------------ */
+ strcpy(c_val, "12345678");
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11I_PSK, c_val, (strlen(c_val)), 0, 0))
+ goto _fail_;
+
+ /* IEEE802.1X Key Configuration */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : Radius Server Access Secret Key */
+ /* Values to set : Any string with length greater than equal to 8 bytes */
+ /* and less than 65 bytes */
+ /* ------------------------------------------------------------------ */
+ strcpy(c_val, "password");
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_1X_KEY, c_val, (strlen(c_val) + 1), 0, 0))
+ goto _fail_;
+
+ /* IEEE802.1X Server Address Configuration */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : Radius Server IP Address */
+ /* Values to set : Any valid IP Address */
+ /* ------------------------------------------------------------------ */
+ c_val[0] = 192;
+ c_val[1] = 168;
+ c_val[2] = 1;
+ c_val[3] = 112;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_1X_SERV_ADDR, c_val, 4, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 3;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_LISTEN_INTERVAL, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 3;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_DTIM_PERIOD, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = NORMAL_ACK;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_ACK_POLICY, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 0;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_USER_CONTROL_ON_TX_POWER, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 48;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_TX_POWER_LEVEL_11A, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 28;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_TX_POWER_LEVEL_11B, c_val, 1, 0, 0))
+ goto _fail_;
+
+ /* Beacon Interval */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Sets the beacon interval value */
+ /* Values to set : Any 16-bit value */
+ /* -------------------------------------------------------------------- */
+
+ *((int *)c_val) = 100;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_BEACON_INTERVAL, c_val, 2, 0, 0))
+ goto _fail_;
+
+ c_val[0] = REKEY_DISABLE;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_POLICY, c_val, 1, 0, 0))
+ goto _fail_;
+
+ /* Rekey Time (s) (Used only when the Rekey policy is 2 or 4) */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Sets the Rekey Time (s) */
+ /* Values to set : 32-bit value */
+ /* -------------------------------------------------------------------- */
+ *((int *)c_val) = 84600;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_PERIOD, c_val, 4, 0, 0))
+ goto _fail_;
+
+ /* Rekey Packet Count (in 1000s; used when Rekey Policy is 3) */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Sets Rekey Group Packet count */
+ /* Values to set : 32-bit Value */
+ /* -------------------------------------------------------------------- */
+ *((int *)c_val) = 500;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_REKEY_PACKET_COUNT, c_val, 4, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 1;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_SHORT_SLOT_ALLOWED, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = G_SELF_CTS_PROT;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_ERP_PROT_TYPE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 1; /* Enable N */
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_ENABLE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = HT_MIXED_MODE;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_OPERATING_MODE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 1; /* TXOP Prot disable in N mode: No RTS-CTS on TX A-MPDUs to save air-time. */
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_TXOP_PROT_DISABLE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ memcpy(c_val, mac_add, 6);
+
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_MAC_ADDR, c_val, 6, 0, 0))
+ goto _fail_;
+
+ /**
+ * AP only
+ **/
+ c_val[0] = DETECT_PROTECT_REPORT;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_OBSS_NONHT_DETECTION, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = RTS_CTS_NONHT_PROT;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_HT_PROT_TYPE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 0;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_RIFS_PROT_ENABLE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = MIMO_MODE;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_SMPS_MODE, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 7;
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_CURRENT_TX_MCS, c_val, 1, 0, 0))
+ goto _fail_;
+
+ c_val[0] = 1; /* Enable N with immediate block ack. */
+ if (!g_linux_wlan->oup.wlan_cfg_set(0, WID_11N_IMMEDIATE_BA_ENABLED, c_val, 1, 1, (WILC_Uint32)pstrWFIDrv))
+ goto _fail_;
+
+ return 0;
+
+_fail_:
+ return -1;
+}
+
+
+/**************************/
+void wilc1000_wlan_deinit(linux_wlan_t *nic)
+{
+
+ if (g_linux_wlan->wilc1000_initialized) {
+
+ printk("Deinitializing wilc1000 ...\n");
+
+ if (nic == NULL) {
+ PRINT_ER("nic is NULL\n");
+ return;
+ }
+
+#if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
+ /* johnny : remove */
+ PRINT_D(INIT_DBG, "skip wilc_bus_set_default_speed\n");
+#else
+ wilc_bus_set_default_speed();
+#endif
+
+ PRINT_D(INIT_DBG, "Disabling IRQ\n");
+ #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
+ linux_wlan_disable_irq(IRQ_WAIT);
+ #else
+ #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
+
+ #else
+ linux_wlan_lock_mutex((void *)&g_linux_wlan->hif_cs);
+ disable_sdio_interrupt();
+ linux_wlan_unlock_mutex((void *)&g_linux_wlan->hif_cs);
+ #endif
+ #endif
+
+
+ /* not sure if the following unlocks are needed or not*/
+ if (&g_linux_wlan->rxq_event != NULL) {
+ linux_wlan_unlock(&g_linux_wlan->rxq_event);
+ }
+
+ if (&g_linux_wlan->txq_event != NULL) {
+ linux_wlan_unlock(&g_linux_wlan->txq_event);
+ }
+
+
+ #if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
+ /*Removing the work struct from the linux kernel workqueue*/
+ if (&g_linux_wlan->rx_work_queue != NULL)
+ flush_work(&g_linux_wlan->rx_work_queue);
+
+ #elif (RX_BH_TYPE == RX_BH_KTHREAD)
+ /* if(&nic->rx_sem != NULL) */
+ /* linux_wlan_unlock(&nic->rx_sem); */
+ #endif
+
+ PRINT_D(INIT_DBG, "Deinitializing Threads\n");
+ wlan_deinitialize_threads(nic);
+
+ PRINT_D(INIT_DBG, "Deinitializing IRQ\n");
+ deinit_irq(g_linux_wlan);
+
+
+ if (&g_linux_wlan->oup != NULL) {
+ if (g_linux_wlan->oup.wlan_stop != NULL)
+ g_linux_wlan->oup.wlan_stop();
+ }
+
+ PRINT_D(INIT_DBG, "Deinitializing WILC Wlan\n");
+ wilc_wlan_deinit(nic);
+#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
+ #if defined(PLAT_ALLWINNER_A20) || defined(PLAT_ALLWINNER_A23) || defined(PLAT_ALLWINNER_A31)
+ PRINT_D(INIT_DBG, "Disabling IRQ 2\n");
+
+ linux_wlan_lock_mutex((void *)&g_linux_wlan->hif_cs);
+ disable_sdio_interrupt();
+ linux_wlan_unlock_mutex((void *)&g_linux_wlan->hif_cs);
+ #endif
+#endif
+
+ /*De-Initialize locks*/
+ PRINT_D(INIT_DBG, "Deinitializing Locks\n");
+ wlan_deinit_locks(g_linux_wlan);
+
+ /* announce that wilc1000 is not initialized */
+ g_linux_wlan->wilc1000_initialized = 0;
+
+ PRINT_D(INIT_DBG, "wilc1000 deinitialization Done\n");
+
+ } else {
+ PRINT_D(INIT_DBG, "wilc1000 is not initialized\n");
+ }
+ return;
+}
+
+int wlan_init_locks(linux_wlan_t *p_nic)
+{
+
+ PRINT_D(INIT_DBG, "Initializing Locks ...\n");
+
+ /*initialize mutexes*/
+ linux_wlan_init_mutex("hif_lock/hif_cs", &g_linux_wlan->hif_cs, 1);
+ linux_wlan_init_mutex("rxq_lock/rxq_cs", &g_linux_wlan->rxq_cs, 1);
+ linux_wlan_init_mutex("txq_lock/txq_cs", &g_linux_wlan->txq_cs, 1);
+
+ /*Added by Amr - BugID_4720*/
+ linux_wlan_init_spin_lock("txq_spin_lock/txq_cs", &g_linux_wlan->txq_spinlock, 1);
+
+ /*Added by Amr - BugID_4720*/
+ linux_wlan_init_lock("txq_add_to_head_lock/txq_cs", &g_linux_wlan->txq_add_to_head_cs, 1);
+
+ linux_wlan_init_lock("txq_wait/txq_event", &g_linux_wlan->txq_event, 0);
+ linux_wlan_init_lock("rxq_wait/rxq_event", &g_linux_wlan->rxq_event, 0);
+
+ linux_wlan_init_lock("cfg_wait/cfg_event", &g_linux_wlan->cfg_event, 0);
+ linux_wlan_init_lock("sync_event", &g_linux_wlan->sync_event, 0);
+
+ linux_wlan_init_lock("rxq_lock/rxq_started", &g_linux_wlan->rxq_thread_started, 0);
+ linux_wlan_init_lock("rxq_lock/txq_started", &g_linux_wlan->txq_thread_started, 0);
+
+ #if (RX_BH_TYPE == RX_BH_KTHREAD)
+ linux_wlan_init_lock("BH_SEM", &g_linux_wlan->rx_sem, 0);
+ #endif
+
+ return 0;
+}
+
+static int wlan_deinit_locks(linux_wlan_t *nic)
+{
+ PRINT_D(INIT_DBG, "De-Initializing Locks\n");
+
+ if (&g_linux_wlan->hif_cs != NULL)
+ linux_wlan_deinit_mutex(&g_linux_wlan->hif_cs);
+
+ if (&g_linux_wlan->rxq_cs != NULL)
+ linux_wlan_deinit_mutex(&g_linux_wlan->rxq_cs);
+
+ if (&g_linux_wlan->txq_cs != NULL)
+ linux_wlan_deinit_mutex(&g_linux_wlan->txq_cs);
+
+ /*Added by Amr - BugID_4720*/
+ if (&g_linux_wlan->txq_spinlock != NULL)
+ linux_wlan_deinit_spin_lock(&g_linux_wlan->txq_spinlock);
+
+ if (&g_linux_wlan->rxq_event != NULL)
+ linux_wlan_deinit_lock(&g_linux_wlan->rxq_event);
+
+ if (&g_linux_wlan->txq_event != NULL)
+ linux_wlan_deinit_lock(&g_linux_wlan->txq_event);
+
+ /*Added by Amr - BugID_4720*/
+ if (&g_linux_wlan->txq_add_to_head_cs != NULL)
+ linux_wlan_deinit_lock(&g_linux_wlan->txq_add_to_head_cs);
+
+ if (&g_linux_wlan->rxq_thread_started != NULL)
+ linux_wlan_deinit_lock(&g_linux_wlan->rxq_thread_started);
+
+ if (&g_linux_wlan->txq_thread_started != NULL)
+ linux_wlan_deinit_lock(&g_linux_wlan->txq_thread_started);
+
+ if (&g_linux_wlan->cfg_event != NULL)
+ linux_wlan_deinit_lock(&g_linux_wlan->cfg_event);
+
+ if (&g_linux_wlan->sync_event != NULL)
+ linux_wlan_deinit_lock(&g_linux_wlan->sync_event);
+
+ return 0;
+}
+void linux_to_wlan(wilc_wlan_inp_t *nwi, linux_wlan_t *nic)
+{
+
+ PRINT_D(INIT_DBG, "Linux to Wlan services ...\n");
+
+ nwi->os_context.hif_critical_section = (void *)&g_linux_wlan->hif_cs;
+ nwi->os_context.os_private = (void *)nic;
+ nwi->os_context.tx_buffer_size = LINUX_TX_SIZE;
+ nwi->os_context.txq_critical_section = (void *)&g_linux_wlan->txq_cs;
+
+ /*Added by Amr - BugID_4720*/
+ nwi->os_context.txq_add_to_head_critical_section = (void *)&g_linux_wlan->txq_add_to_head_cs;
+
+ /*Added by Amr - BugID_4720*/
+ nwi->os_context.txq_spin_lock = (void *)&g_linux_wlan->txq_spinlock;
+
+ nwi->os_context.txq_wait_event = (void *)&g_linux_wlan->txq_event;
+
+#if defined (MEMORY_STATIC)
+ nwi->os_context.rx_buffer_size = LINUX_RX_SIZE;
+#endif
+ nwi->os_context.rxq_critical_section = (void *)&g_linux_wlan->rxq_cs;
+ nwi->os_context.rxq_wait_event = (void *)&g_linux_wlan->rxq_event;
+ nwi->os_context.cfg_wait_event = (void *)&g_linux_wlan->cfg_event;
+
+ nwi->os_func.os_sleep = linux_wlan_msleep;
+ nwi->os_func.os_atomic_sleep = linux_wlan_atomic_msleep;
+ nwi->os_func.os_debug = linux_wlan_dbg;
+ nwi->os_func.os_malloc = linux_wlan_malloc;
+ nwi->os_func.os_malloc_atomic = linux_wlan_malloc_atomic;
+ nwi->os_func.os_free = linux_wlan_free;
+ nwi->os_func.os_lock = linux_wlan_lock;
+ nwi->os_func.os_unlock = linux_wlan_unlock;
+ nwi->os_func.os_wait = linux_wlan_lock_timeout;
+ nwi->os_func.os_signal = linux_wlan_unlock;
+ nwi->os_func.os_enter_cs = linux_wlan_lock_mutex;
+ nwi->os_func.os_leave_cs = linux_wlan_unlock_mutex;
+
+ /*Added by Amr - BugID_4720*/
+ nwi->os_func.os_spin_lock = linux_wlan_spin_lock;
+ nwi->os_func.os_spin_unlock = linux_wlan_spin_unlock;
+
+#ifdef WILC_SDIO
+ nwi->io_func.io_type = HIF_SDIO;
+ nwi->io_func.io_init = linux_sdio_init;
+ nwi->io_func.io_deinit = linux_sdio_deinit;
+ nwi->io_func.u.sdio.sdio_cmd52 = linux_sdio_cmd52;
+ nwi->io_func.u.sdio.sdio_cmd53 = linux_sdio_cmd53;
+ nwi->io_func.u.sdio.sdio_set_max_speed = linux_sdio_set_max_speed;
+ nwi->io_func.u.sdio.sdio_set_default_speed = linux_sdio_set_default_speed;
+#else
+ nwi->io_func.io_type = HIF_SPI;
+ nwi->io_func.io_init = linux_spi_init;
+ nwi->io_func.io_deinit = linux_spi_deinit;
+ nwi->io_func.u.spi.spi_tx = linux_spi_write;
+ nwi->io_func.u.spi.spi_rx = linux_spi_read;
+ nwi->io_func.u.spi.spi_trx = linux_spi_write_read;
+ nwi->io_func.u.spi.spi_max_speed = linux_spi_set_max_speed;
+#endif
+
+ /*for now - to be revised*/
+ #ifdef WILC_FULLY_HOSTING_AP
+ /* incase of Fully hosted AP, all non cfg pkts are processed here*/
+ nwi->net_func.rx_indicate = WILC_Process_rx_frame;
+ #else
+ nwi->net_func.rx_indicate = frmw_to_linux;
+ #endif
+ nwi->net_func.rx_complete = linux_wlan_rx_complete;
+ nwi->indicate_func.mac_indicate = linux_wlan_mac_indicate;
+}
+
+int wlan_initialize_threads(perInterface_wlan_t *nic)
+{
+
+ int ret = 0;
+ PRINT_D(INIT_DBG, "Initializing Threads ...\n");
+
+#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
+ /*Initialize rx work queue task*/
+ INIT_WORK(&g_linux_wlan->rx_work_queue, isr_bh_routine);
+#elif (RX_BH_TYPE == RX_BH_KTHREAD)
+ PRINT_D(INIT_DBG, "Creating kthread for Rxq BH\n");
+ g_linux_wlan->rx_bh_thread = kthread_run(isr_bh_routine, (void *)g_linux_wlan, "K_RXQ_BH");
+ if (g_linux_wlan->rx_bh_thread == 0) {
+ PRINT_ER("couldn't create RX BH thread\n");
+ ret = -ENOBUFS;
+ goto _fail_;
+ }
+#endif
+
+#ifndef TCP_ENHANCEMENTS
+ /* create rx task */
+ PRINT_D(INIT_DBG, "Creating kthread for reception\n");
+ g_linux_wlan->rxq_thread = kthread_run(linux_wlan_rxq_task, (void *)g_linux_wlan, "K_RXQ_TASK");
+ if (g_linux_wlan->rxq_thread == 0) {
+ PRINT_ER("couldn't create RXQ thread\n");
+ ret = -ENOBUFS;
+ goto _fail_1;
+ }
+
+ /* wait for RXQ task to start. */
+ linux_wlan_lock(&g_linux_wlan->rxq_thread_started);
+
+#endif
+
+ /* create tx task */
+ PRINT_D(INIT_DBG, "Creating kthread for transmission\n");
+ g_linux_wlan->txq_thread = kthread_run(linux_wlan_txq_task, (void *)g_linux_wlan, "K_TXQ_TASK");
+ if (g_linux_wlan->txq_thread == 0) {
+ PRINT_ER("couldn't create TXQ thread\n");
+ ret = -ENOBUFS;
+ goto _fail_2;
+ }
+#ifdef DEBUG_MODE
+ PRINT_D(INIT_DBG, "Creating kthread for Debugging\n");
+ g_linux_wlan->txq_thread = kthread_run(DebuggingThreadTask, (void *)g_linux_wlan, "DebugThread");
+ if (g_linux_wlan->txq_thread == 0) {
+ PRINT_ER("couldn't create TXQ thread\n");
+ ret = -ENOBUFS;
+ goto _fail_2;
+ }
+#endif
+ /* wait for TXQ task to start. */
+ linux_wlan_lock(&g_linux_wlan->txq_thread_started);
+
+ return 0;
+
+_fail_2:
+ /*De-Initialize 2nd thread*/
+ g_linux_wlan->close = 1;
+ linux_wlan_unlock(&g_linux_wlan->rxq_event);
+ kthread_stop(g_linux_wlan->rxq_thread);
+
+#ifndef TCP_ENHANCEMENTS
+_fail_1:
+#endif
+ #if (RX_BH_TYPE == RX_BH_KTHREAD)
+ /*De-Initialize 1st thread*/
+ g_linux_wlan->close = 1;
+ linux_wlan_unlock(&g_linux_wlan->rx_sem);
+ kthread_stop(g_linux_wlan->rx_bh_thread);
+_fail_:
+ #endif
+ g_linux_wlan->close = 0;
+ return ret;
+}
+
+static void wlan_deinitialize_threads(linux_wlan_t *nic)
+{
+
+ g_linux_wlan->close = 1;
+ PRINT_D(INIT_DBG, "Deinitializing Threads\n");
+ if (&g_linux_wlan->rxq_event != NULL)
+ linux_wlan_unlock(&g_linux_wlan->rxq_event);
+
+
+ if (g_linux_wlan->rxq_thread != NULL) {
+ kthread_stop(g_linux_wlan->rxq_thread);
+ g_linux_wlan->rxq_thread = NULL;
+ }
+
+
+ if (&g_linux_wlan->txq_event != NULL)
+ linux_wlan_unlock(&g_linux_wlan->txq_event);
+
+
+ if (g_linux_wlan->txq_thread != NULL) {
+ kthread_stop(g_linux_wlan->txq_thread);
+ g_linux_wlan->txq_thread = NULL;
+ }
+
+ #if (RX_BH_TYPE == RX_BH_KTHREAD)
+ if (&g_linux_wlan->rx_sem != NULL)
+ linux_wlan_unlock(&g_linux_wlan->rx_sem);
+
+ if (g_linux_wlan->rx_bh_thread != NULL) {
+ kthread_stop(g_linux_wlan->rx_bh_thread);
+ g_linux_wlan->rx_bh_thread = NULL;
+ }
+ #endif
+}
+
+#ifdef STATIC_MACADDRESS
+const char *path_string[] = {
+ "/etc/wlan",
+ "/data/wlan",
+};
+
+static int linux_wlan_read_mac_addr(void *vp)
+{
+ int ret = 0;
+ struct file *fp = (struct file *)-ENOENT;
+ mm_segment_t old_fs;
+ loff_t pos = 0;
+ int index;
+ int array_size = sizeof(path_string) / sizeof(path_string[0]);
+
+ /* change to KERNEL_DS address limit */
+ old_fs = get_fs();
+ set_fs(KERNEL_DS);
+
+ for (index = 0; index < array_size; index++) {
+ fp = filp_open(path_string[index], O_WRONLY, 0640);
+ if (!fp) {
+ ret = -1;
+ goto exit;
+ }
+
+ /*No such file or directory */
+ if (IS_ERR(fp) || !fp->f_op) {
+ get_random_bytes(&mac_add[3], 3);
+ /* open file to write */
+ fp = filp_open(path_string[index], O_WRONLY | O_CREAT, 0640);
+
+ if (!fp || IS_ERR(fp)) {
+ ret = -1;
+ continue;
+ } else {
+ /* write buf to file */
+ fp->f_op->write(fp, mac_add, 6, &pos);
+ break;
+ }
+ } else {
+ /* read file to buf */
+ fp->f_op->read(fp, mac_add, 6, &pos);
+ break;
+ }
+ }
+
+ if (index == array_size) {
+ PRINT_ER("random MAC\n");
+ }
+
+exit:
+ if (fp && !IS_ERR(fp)) {
+ filp_close(fp, NULL);
+ }
+
+ set_fs(old_fs);
+
+ return ret;
+}
+#endif
+
+#ifdef COMPLEMENT_BOOT
+
+extern volatile int probe;
+extern uint8_t core_11b_ready(void);
+
+#define READY_CHECK_THRESHOLD 30
+extern void wilc_wlan_global_reset(void);
+uint8_t wilc1000_prepare_11b_core(wilc_wlan_inp_t *nwi, wilc_wlan_oup_t *nwo, linux_wlan_t *nic)
+{
+ uint8_t trials = 0;
+ while ((core_11b_ready() && (READY_CHECK_THRESHOLD > (trials++)))) {
+ PRINT_D(INIT_DBG, "11b core not ready yet: %u\n", trials);
+ wilc_wlan_deinit(nic);
+ wilc_wlan_global_reset();
+ sdio_unregister_driver(&wilc_bus);
+
+ linux_wlan_device_detection(0);
+
+ mdelay(100);
+
+ linux_wlan_device_detection(1);
+
+ sdio_register_driver(&wilc_bus);
+
+ while (!probe) {
+ msleep(100);
+ }
+ probe = 0;
+ g_linux_wlan->wilc_sdio_func = local_sdio_func;
+ linux_to_wlan(nwi, nic);
+ wilc_wlan_init(nwi, nwo);
+ }
+
+ if (READY_CHECK_THRESHOLD <= trials)
+ return 1;
+ else
+ return 0;
+
+}
+
+int repeat_power_cycle(perInterface_wlan_t *nic)
+{
+ int ret = 0;
+ wilc_wlan_inp_t nwi;
+ wilc_wlan_oup_t nwo;
+ sdio_unregister_driver(&wilc_bus);
+
+ linux_wlan_device_detection(0);
+ linux_wlan_device_power(0);
+ msleep(100);
+ linux_wlan_device_power(1);
+ msleep(80);
+ linux_wlan_device_detection(1);
+ msleep(20);
+
+ sdio_register_driver(&wilc_bus);
+
+ /* msleep(1000); */
+ while (!probe) {
+ msleep(100);
+ }
+ probe = 0;
+ g_linux_wlan->wilc_sdio_func = local_sdio_func;
+ linux_to_wlan(&nwi, g_linux_wlan);
+ ret = wilc_wlan_init(&nwi, &nwo);
+
+ g_linux_wlan->mac_status = WILC_MAC_STATUS_INIT;
+ #if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
+ enable_sdio_interrupt();
+ #endif
+
+ if (linux_wlan_get_firmware(nic)) {
+ PRINT_ER("Can't get firmware \n");
+ ret = -1;
+ goto __fail__;
+ }
+
+ /*Download firmware*/
+ ret = linux_wlan_firmware_download(g_linux_wlan);
+ if (ret < 0) {
+ PRINT_ER("Failed to download firmware\n");
+ goto __fail__;
+ }
+ /* Start firmware*/
+ ret = linux_wlan_start_firmware(nic);
+ if (ret < 0) {
+ PRINT_ER("Failed to start firmware\n");
+ }
+__fail__:
+ return ret;
+}
+#endif
+
+int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic)
+{
+ wilc_wlan_inp_t nwi;
+ wilc_wlan_oup_t nwo;
+ perInterface_wlan_t *nic = p_nic;
+ int ret = 0;
+
+ if (!g_linux_wlan->wilc1000_initialized) {
+ g_linux_wlan->mac_status = WILC_MAC_STATUS_INIT;
+ g_linux_wlan->close = 0;
+ g_linux_wlan->wilc1000_initialized = 0;
+
+ wlan_init_locks(g_linux_wlan);
+
+#ifdef STATIC_MACADDRESS
+ wilc_mac_thread = kthread_run(linux_wlan_read_mac_addr, NULL, "wilc_mac_thread");
+ if (wilc_mac_thread < 0) {
+ PRINT_ER("couldn't create Mac addr thread\n");
+ }
+#endif
+
+ linux_to_wlan(&nwi, g_linux_wlan);
+
+ ret = wilc_wlan_init(&nwi, &nwo);
+ if (ret < 0) {
+ PRINT_ER("Initializing WILC_Wlan FAILED\n");
+ ret = -EIO;
+ goto _fail_locks_;
+ }
+ memcpy(&g_linux_wlan->oup, &nwo, sizeof(wilc_wlan_oup_t));
+
+ /*Save the oup structre into global pointer*/
+ gpstrWlanOps = &g_linux_wlan->oup;
+
+
+ ret = wlan_initialize_threads(nic);
+ if (ret < 0) {
+ PRINT_ER("Initializing Threads FAILED\n");
+ ret = -EIO;
+ goto _fail_wilc_wlan_;
+ }
+
+#if (defined WILC_SDIO) && (defined COMPLEMENT_BOOT)
+ if (wilc1000_prepare_11b_core(&nwi, &nwo, g_linux_wlan)) {
+ PRINT_ER("11b Core is not ready\n");
+ ret = -EIO;
+ goto _fail_threads_;
+ }
+#endif
+
+#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
+ if (init_irq(g_linux_wlan)) {
+ PRINT_ER("couldn't initialize IRQ\n");
+ ret = -EIO;
+ goto _fail_threads_;
+ }
+#endif
+
+#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
+ if (enable_sdio_interrupt()) {
+ PRINT_ER("couldn't initialize IRQ\n");
+ ret = -EIO;
+ goto _fail_irq_init_;
+ }
+#endif
+
+ if (linux_wlan_get_firmware(nic)) {
+ PRINT_ER("Can't get firmware \n");
+ ret = -EIO;
+ goto _fail_irq_enable_;
+ }
+
+
+ /*Download firmware*/
+ ret = linux_wlan_firmware_download(g_linux_wlan);
+ if (ret < 0) {
+ PRINT_ER("Failed to download firmware\n");
+ ret = -EIO;
+ goto _fail_irq_enable_;
+ }
+
+ /* Start firmware*/
+ ret = linux_wlan_start_firmware(nic);
+ if (ret < 0) {
+ PRINT_ER("Failed to start firmware\n");
+ ret = -EIO;
+ goto _fail_irq_enable_;
+ }
+
+ wilc_bus_set_max_speed();
+
+ if (g_linux_wlan->oup.wlan_cfg_get(1, WID_FIRMWARE_VERSION, 1, 0)) {
+ int size;
+ char Firmware_ver[20];
+ size = g_linux_wlan->oup.wlan_cfg_get_value(
+ WID_FIRMWARE_VERSION,
+ Firmware_ver, sizeof(Firmware_ver));
+ Firmware_ver[size] = '\0';
+ PRINT_D(INIT_DBG, "***** Firmware Ver = %s *******\n", Firmware_ver);
+ }
+ /* Initialize firmware with default configuration */
+ ret = linux_wlan_init_test_config(dev, g_linux_wlan);
+
+ if (ret < 0) {
+ PRINT_ER("Failed to configure firmware\n");
+ ret = -EIO;
+ goto _fail_fw_start_;
+ }
+
+ g_linux_wlan->wilc1000_initialized = 1;
+ return 0; /*success*/
+
+
+_fail_fw_start_:
+ if (&g_linux_wlan->oup != NULL) {
+ if (g_linux_wlan->oup.wlan_stop != NULL)
+ g_linux_wlan->oup.wlan_stop();
+ }
+
+_fail_irq_enable_:
+#if (defined WILC_SDIO) && (!defined WILC_SDIO_IRQ_GPIO)
+ disable_sdio_interrupt();
+_fail_irq_init_:
+#endif
+#if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
+ deinit_irq(g_linux_wlan);
+
+#endif
+_fail_threads_:
+ wlan_deinitialize_threads(g_linux_wlan);
+_fail_wilc_wlan_:
+ wilc_wlan_deinit(g_linux_wlan);
+_fail_locks_:
+ wlan_deinit_locks(g_linux_wlan);
+ PRINT_ER("WLAN Iinitialization FAILED\n");
+ } else {
+ PRINT_D(INIT_DBG, "wilc1000 already initialized\n");
+ }
+ return ret;
+}
+
+
+/*
+ * - this function will be called automatically by OS when module inserted.
+ */
+
+#if !defined (NM73131_0_BOARD)
+int mac_init_fn(struct net_device *ndev)
+{
+
+ /*Why we do this !!!*/
+ netif_start_queue(ndev); /* ma */
+ netif_stop_queue(ndev); /* ma */
+
+ return 0;
+}
+#else
+int mac_init_fn(struct net_device *ndev)
+{
+
+ unsigned char mac_add[] = {0x00, 0x50, 0xc2, 0x5e, 0x10, 0x00};
+ /* TODO: get MAC address whenever the source is EPROM - hardcoded and copy it to ndev*/
+ memcpy(ndev->dev_addr, mac_add, 6);
+
+ if (!is_valid_ether_addr(ndev->dev_addr)) {
+ PRINT_ER("Error: Wrong MAC address\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+#endif
+
+
+void WILC_WFI_frame_register(struct wiphy *wiphy, struct net_device *dev,
+ u16 frame_type, bool reg);
+
+/* This fn is called, when this device is setup using ifconfig */
+#if !defined (NM73131_0_BOARD)
+int mac_open(struct net_device *ndev)
+{
+ perInterface_wlan_t *nic;
+
+ /*BugID_5213*/
+ /*No need for setting mac address here anymore,*/
+ /*Just set it in init_test_config()*/
+ unsigned char mac_add[ETH_ALEN] = {0};
+ int status;
+ int ret = 0;
+ int i = 0;
+ struct WILC_WFI_priv *priv;
+
+ nic = netdev_priv(ndev);
+ priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy);
+ PRINT_D(INIT_DBG, "MAC OPEN[%p]\n", ndev);
+
+ #ifdef USE_WIRELESS
+ ret = WILC_WFI_InitHostInt(ndev);
+ if (ret < 0) {
+ PRINT_ER("Failed to initialize host interface\n");
+
+ return ret;
+ }
+ #endif
+
+ /*initialize platform*/
+ PRINT_D(INIT_DBG, "*** re-init ***\n");
+ ret = wilc1000_wlan_init(ndev, nic);
+ if (ret < 0) {
+ PRINT_ER("Failed to initialize wilc1000\n");
+ WILC_WFI_DeInitHostInt(ndev);
+ return ret;
+ }
+
+ Set_machw_change_vir_if(WILC_FALSE);
+
+ status = host_int_get_MacAddress(priv->hWILCWFIDrv, mac_add);
+ PRINT_D(INIT_DBG, "Mac address: %x:%x:%x:%x:%x:%x\n", mac_add[0], mac_add[1], mac_add[2],
+ mac_add[3], mac_add[4], mac_add[5]);
+
+ /* loop through the NUM of supported devices and set the MAC address */
+ for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
+ if (ndev == g_linux_wlan->strInterfaceInfo[i].wilc_netdev) {
+ memcpy(g_linux_wlan->strInterfaceInfo[i].aSrcAddress, mac_add, ETH_ALEN);
+ g_linux_wlan->strInterfaceInfo[i].drvHandler = (WILC_Uint32)priv->hWILCWFIDrv;
+ break;
+ }
+ }
+
+ /* TODO: get MAC address whenever the source is EPROM - hardcoded and copy it to ndev*/
+ memcpy(ndev->dev_addr, g_linux_wlan->strInterfaceInfo[i].aSrcAddress, ETH_ALEN);
+
+ if (!is_valid_ether_addr(ndev->dev_addr)) {
+ PRINT_ER("Error: Wrong MAC address\n");
+ ret = -EINVAL;
+ goto _err_;
+ }
+
+
+ WILC_WFI_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev,
+ nic->g_struct_frame_reg[0].frame_type, nic->g_struct_frame_reg[0].reg);
+ WILC_WFI_frame_register(nic->wilc_netdev->ieee80211_ptr->wiphy, nic->wilc_netdev,
+ nic->g_struct_frame_reg[1].frame_type, nic->g_struct_frame_reg[1].reg);
+ netif_wake_queue(ndev);
+ g_linux_wlan->open_ifcs++;
+ nic->mac_opened = 1;
+ return 0;
+
+_err_:
+ WILC_WFI_DeInitHostInt(ndev);
+ wilc1000_wlan_deinit(g_linux_wlan);
+ return ret;
+}
+#else
+int mac_open(struct net_device *ndev)
+{
+
+ linux_wlan_t *nic;
+ nic = netdev_priv(ndev);
+
+ /*initialize platform*/
+ if (wilc1000_wlan_init(nic)) {
+ PRINT_ER("Failed to initialize platform\n");
+ return 1;
+ }
+ /* Start the network interface queue for this device */
+ PRINT_D(INIT_DBG, "Starting netifQ\n");
+ netif_start_queue(ndev);
+/* linux_wlan_lock(&close_exit_sync); */
+ return 0;
+}
+#endif
+
+struct net_device_stats *mac_stats(struct net_device *dev)
+{
+ perInterface_wlan_t *nic = netdev_priv(dev);
+
+
+ return &nic->netstats;
+}
+
+/* Setup the multicast filter */
+static void wilc_set_multicast_list(struct net_device *dev)
+{
+
+ struct netdev_hw_addr *ha;
+ struct WILC_WFI_priv *priv;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+ int i = 0;
+ priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+
+
+ if (!dev)
+ return;
+
+ PRINT_D(INIT_DBG, "Setting Multicast List with count = %d. \n", dev->mc.count);
+
+ if (dev->flags & IFF_PROMISC) {
+ /* Normally, we should configure the chip to retrive all packets
+ * but we don't wanna support this right now */
+ /* TODO: add promiscuous mode support */
+ PRINT_D(INIT_DBG, "Set promiscuous mode ON, retrive all packets \n");
+ return;
+ }
+
+ /* If there's more addresses than we handle, get all multicast
+ * packets and sort them out in software. */
+ if ((dev->flags & IFF_ALLMULTI) || (dev->mc.count) > WILC_MULTICAST_TABLE_SIZE) {
+ PRINT_D(INIT_DBG, "Disable multicast filter, retrive all multicast packets\n");
+ /* get all multicast packets */
+ host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_FALSE, 0);
+ return;
+ }
+
+ /* No multicast? Just get our own stuff */
+ if ((dev->mc.count) == 0) {
+ PRINT_D(INIT_DBG, "Enable multicast filter, retrive directed packets only.\n");
+ host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_TRUE, 0);
+ return;
+ }
+
+ /* Store all of the multicast addresses in the hardware filter */
+ netdev_for_each_mc_addr(ha, dev)
+ {
+ WILC_memcpy(gau8MulticastMacAddrList[i], ha->addr, ETH_ALEN);
+ PRINT_D(INIT_DBG, "Entry[%d]: %x:%x:%x:%x:%x:%x\n", i,
+ gau8MulticastMacAddrList[i][0], gau8MulticastMacAddrList[i][1], gau8MulticastMacAddrList[i][2], gau8MulticastMacAddrList[i][3], gau8MulticastMacAddrList[i][4], gau8MulticastMacAddrList[i][5]);
+ i++;
+ }
+
+ host_int_setup_multicast_filter((WILC_WFIDrvHandle)pstrWFIDrv, WILC_TRUE, (dev->mc.count));
+
+ return;
+
+}
+
+static void linux_wlan_tx_complete(void *priv, int status)
+{
+
+ struct tx_complete_data *pv_data = (struct tx_complete_data *)priv;
+ if (status == 1) {
+ PRINT_D(TX_DBG, "Packet sent successfully - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb);
+ } else {
+ PRINT_D(TX_DBG, "Couldn't send packet - Size = %d - Address = %p - SKB = %p\n", pv_data->size, pv_data->buff, pv_data->skb);
+ }
+ /* Free the SK Buffer, its work is done */
+ dev_kfree_skb(pv_data->skb);
+ linux_wlan_free(pv_data);
+}
+
+int mac_xmit(struct sk_buff *skb, struct net_device *ndev)
+{
+ perInterface_wlan_t *nic;
+ struct tx_complete_data *tx_data = NULL;
+ int QueueCount;
+ char *pu8UdpBuffer;
+ struct iphdr *ih;
+ struct ethhdr *eth_h;
+ nic = netdev_priv(ndev);
+
+ PRINT_D(INT_DBG, "\n========\n IntUH: %d - IntBH: %d - IntCld: %d \n========\n", int_rcvdU, int_rcvdB, int_clrd);
+ PRINT_D(TX_DBG, "Sending packet just received from TCP/IP\n");
+
+ /* Stop the network interface queue */
+ if (skb->dev != ndev) {
+ PRINT_ER("Packet not destined to this device\n");
+ return 0;
+ }
+
+ tx_data = (struct tx_complete_data *)internal_alloc(sizeof(struct tx_complete_data), GFP_ATOMIC);
+ if (tx_data == NULL) {
+ PRINT_ER("Failed to allocate memory for tx_data structure\n");
+ dev_kfree_skb(skb);
+ netif_wake_queue(ndev);
+ return 0;
+ }
+
+ tx_data->buff = skb->data;
+ tx_data->size = skb->len;
+ tx_data->skb = skb;
+
+ eth_h = (struct ethhdr *)(skb->data);
+ if (eth_h->h_proto == 0x8e88) {
+ PRINT_D(INIT_DBG, "EAPOL transmitted\n");
+ }
+
+ /*get source and dest ip addresses*/
+ ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr));
+
+ pu8UdpBuffer = (char *)ih + sizeof(struct iphdr);
+ if ((pu8UdpBuffer[1] == 68 && pu8UdpBuffer[3] == 67) || (pu8UdpBuffer[1] == 67 && pu8UdpBuffer[3] == 68)) {
+ PRINT_D(GENERIC_DBG, "DHCP Message transmitted, type:%x %x %x\n", pu8UdpBuffer[248], pu8UdpBuffer[249], pu8UdpBuffer[250]);
+
+ }
+ PRINT_D(TX_DBG, "Sending packet - Size = %d - Address = %p - SKB = %p\n", tx_data->size, tx_data->buff, tx_data->skb);
+
+ /* Send packet to MAC HW - for now the tx_complete function will be just status
+ * indicator. still not sure if I need to suspend host transmission till the tx_complete
+ * function called or not?
+ * allocated buffer will be freed in tx_complete function.
+ */
+ PRINT_D(TX_DBG, "Adding tx packet to TX Queue\n");
+ nic->netstats.tx_packets++;
+ nic->netstats.tx_bytes += tx_data->size;
+ tx_data->pBssid = g_linux_wlan->strInterfaceInfo[nic->u8IfIdx].aBSSID;
+ #ifndef WILC_FULLY_HOSTING_AP
+ QueueCount = g_linux_wlan->oup.wlan_add_to_tx_que((void *)tx_data,
+ tx_data->buff,
+ tx_data->size,
+ linux_wlan_tx_complete);
+ #else
+ QueueCount = WILC_Xmit_data((void *)tx_data, HOST_TO_WLAN);
+ #endif /* WILC_FULLY_HOSTING_AP */
+
+
+ if (QueueCount > FLOW_CONTROL_UPPER_THRESHOLD) {
+ netif_stop_queue(g_linux_wlan->strInterfaceInfo[0].wilc_netdev);
+ netif_stop_queue(g_linux_wlan->strInterfaceInfo[1].wilc_netdev);
+ }
+
+ return 0;
+}
+
+
+int mac_close(struct net_device *ndev)
+{
+ struct WILC_WFI_priv *priv;
+ perInterface_wlan_t *nic;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+
+ nic = netdev_priv(ndev);
+
+ if ((nic == NULL) || (nic->wilc_netdev == NULL) || (nic->wilc_netdev->ieee80211_ptr == NULL) || (nic->wilc_netdev->ieee80211_ptr->wiphy == NULL)) {
+ PRINT_ER("nic = NULL\n");
+ return 0;
+ }
+
+ priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy);
+
+ if (priv == NULL) {
+ PRINT_ER("priv = NULL\n");
+ return 0;
+ }
+
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+
+
+
+ PRINT_D(GENERIC_DBG, "Mac close\n");
+
+ if (g_linux_wlan == NULL) {
+ PRINT_ER("g_linux_wlan = NULL\n");
+ return 0;
+ }
+
+ if (pstrWFIDrv == NULL) {
+ PRINT_ER("pstrWFIDrv = NULL\n");
+ return 0;
+ }
+
+ if ((g_linux_wlan->open_ifcs) > 0) {
+ g_linux_wlan->open_ifcs--;
+ } else {
+ PRINT_ER("ERROR: MAC close called while number of opened interfaces is zero\n");
+ return 0;
+ }
+
+ if (nic->wilc_netdev != NULL) {
+ /* Stop the network interface queue */
+ netif_stop_queue(nic->wilc_netdev);
+
+ #ifdef USE_WIRELESS
+ WILC_WFI_DeInitHostInt(nic->wilc_netdev);
+ #endif
+ }
+
+ if (g_linux_wlan->open_ifcs == 0) {
+ PRINT_D(GENERIC_DBG, "Deinitializing wilc1000\n");
+ g_linux_wlan->close = 1;
+ wilc1000_wlan_deinit(g_linux_wlan);
+ #ifdef USE_WIRELESS
+ #ifdef WILC_AP_EXTERNAL_MLME
+ WILC_WFI_deinit_mon_interface();
+ #endif
+ #endif
+ }
+
+ linux_wlan_unlock(&close_exit_sync);
+ nic->mac_opened = 0;
+
+ return 0;
+}
+
+
+int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
+{
+
+ u8 *buff = NULL;
+ WILC_Sint8 rssi;
+ WILC_Uint32 size = 0, length = 0;
+ perInterface_wlan_t *nic;
+ struct WILC_WFI_priv *priv;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+
+
+ /* struct iwreq *wrq = (struct iwreq *) req; // tony moved to case SIOCSIWPRIV */
+ #ifdef USE_WIRELESS
+ nic = netdev_priv(ndev);
+
+ if (!g_linux_wlan->wilc1000_initialized)
+ return 0;
+
+ #endif
+
+ switch (cmd) {
+ /* [[ added by tony for SIOCDEVPRIVATE */
+ case SIOCDEVPRIVATE + 1:
+ {
+ android_wifi_priv_cmd priv_cmd;
+
+ PRINT_INFO(GENERIC_DBG, "in SIOCDEVPRIVATE+1\n");
+
+ if (copy_from_user(&priv_cmd, req->ifr_data, sizeof(android_wifi_priv_cmd))) {
+ s32Error = -EFAULT;
+ goto done;
+ }
+
+ buff = kmalloc(priv_cmd.total_len, GFP_KERNEL);
+ if (!buff) {
+ s32Error = -ENOMEM;
+ goto done;
+ }
+
+ if (copy_from_user(buff, priv_cmd.buf, priv_cmd.total_len)) {
+ s32Error = -EFAULT;
+ goto done;
+ }
+
+ PRINT_INFO(GENERIC_DBG, "%s: Android private cmd \"%s\" on %s\n", __FUNCTION__, buff, req->ifr_name);
+
+ if (strncasecmp(buff, "SCAN-ACTIVE", strlen("SCAN-ACTIVE")) == 0) {
+ PRINT_INFO(GENERIC_DBG, "%s, SCAN-ACTIVE command\n", __FUNCTION__);
+ } else if (strncasecmp(buff, "SCAN-PASSIVE", strlen("SCAN-PASSIVE")) == 0) {
+ PRINT_INFO(GENERIC_DBG, "%s, SCAN-PASSIVE command\n", __FUNCTION__);
+ } else if (strncasecmp(buff, "RXFILTER-START", strlen("RXFILTER-START")) == 0) {
+ PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-START command\n", __FUNCTION__);
+ } else if (strncasecmp(buff, "RXFILTER-STOP", strlen("RXFILTER-STOP")) == 0) {
+ PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-STOP command\n", __FUNCTION__);
+ } else if (strncasecmp(buff, "RXFILTER-ADD", strlen("RXFILTER-ADD")) == 0) {
+ int filter_num = *(buff + strlen("RXFILTER-ADD") + 1) - '0';
+ PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-ADD command, filter_num=%d\n", __FUNCTION__, filter_num);
+ } else if (strncasecmp(buff, "RXFILTER-REMOVE", strlen("RXFILTER-REMOVE")) == 0) {
+ int filter_num = *(buff + strlen("RXFILTER-REMOVE") + 1) - '0';
+ PRINT_INFO(GENERIC_DBG, "%s, RXFILTER-REMOVE command, filter_num=%d\n", __FUNCTION__, filter_num);
+ } else if (strncasecmp(buff, "BTCOEXSCAN-START", strlen("BTCOEXSCAN-START")) == 0) {
+ PRINT_INFO(GENERIC_DBG, "%s, BTCOEXSCAN-START command\n", __FUNCTION__);
+ } else if (strncasecmp(buff, "BTCOEXSCAN-STOP", strlen("BTCOEXSCAN-STOP")) == 0) {
+ PRINT_INFO(GENERIC_DBG, "%s, BTCOEXSCAN-STOP command\n", __FUNCTION__);
+ } else if (strncasecmp(buff, "BTCOEXMODE", strlen("BTCOEXMODE")) == 0) {
+ PRINT_INFO(GENERIC_DBG, "%s, BTCOEXMODE command\n", __FUNCTION__);
+ } else if (strncasecmp(buff, "SETBAND", strlen("SETBAND")) == 0) {
+ uint band = *(buff + strlen("SETBAND") + 1) - '0';
+ PRINT_INFO(GENERIC_DBG, "%s, SETBAND command, band=%d\n", __FUNCTION__, band);
+ } else if (strncasecmp(buff, "GETBAND", strlen("GETBAND")) == 0) {
+ PRINT_INFO(GENERIC_DBG, "%s, GETBAND command\n", __FUNCTION__);
+ } else if (strncasecmp(buff, "COUNTRY", strlen("COUNTRY")) == 0) {
+ char *country_code = buff + strlen("COUNTRY") + 1;
+ PRINT_INFO(GENERIC_DBG, "%s, COUNTRY command, country_code=%s\n", __FUNCTION__, country_code);
+ } else {
+ PRINT_INFO(GENERIC_DBG, "%s, Unknown command\n", __FUNCTION__);
+ }
+ } break;
+
+ /* ]] 2013-06-24 */
+ case SIOCSIWPRIV:
+ {
+ struct iwreq *wrq = (struct iwreq *) req; /* added by tony */
+
+ size = wrq->u.data.length;
+
+ if (size && wrq->u.data.pointer) {
+ buff = kmalloc(size, GFP_KERNEL);
+ if (!buff) {
+ s32Error = -ENOMEM;
+ goto done;
+ }
+
+ if (copy_from_user
+ (buff, wrq->u.data.pointer,
+ wrq->u.data.length)) {
+ s32Error = -EFAULT;
+ goto done;
+ }
+
+ if (strncasecmp(buff, "RSSI", length) == 0) {
+
+ #ifdef USE_WIRELESS
+ priv = wiphy_priv(nic->wilc_netdev->ieee80211_ptr->wiphy);
+ s32Error = host_int_get_rssi(priv->hWILCWFIDrv, &(rssi));
+ if (s32Error)
+ PRINT_ER("Failed to send get rssi param's message queue ");
+ #endif
+ PRINT_INFO(GENERIC_DBG, "RSSI :%d\n", rssi);
+
+ /*Rounding up the rssi negative value*/
+ rssi += 5;
+
+ snprintf(buff, size, "rssi %d", rssi);
+
+ if (copy_to_user(wrq->u.data.pointer, buff, size)) {
+ PRINT_ER("%s: failed to copy data to user buffer\n", __FUNCTION__);
+ s32Error = -EFAULT;
+ goto done;
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ {
+ PRINT_INFO(GENERIC_DBG, "Command - %d - has been received\n", cmd);
+ s32Error = -EOPNOTSUPP;
+ goto done;
+ }
+ }
+
+done:
+
+ if (buff != NULL) {
+ kfree(buff);
+ }
+
+ return s32Error;
+}
+
+void frmw_to_linux(uint8_t *buff, uint32_t size, uint32_t pkt_offset)
+{
+
+ unsigned int frame_len = 0;
+ int stats;
+ unsigned char *buff_to_send = NULL;
+ struct sk_buff *skb;
+#ifndef TCP_ENHANCEMENTS
+ char *pu8UdpBuffer;
+ struct iphdr *ih;
+#endif
+ struct net_device *wilc_netdev;
+ perInterface_wlan_t *nic;
+
+ wilc_netdev = GetIfHandler(buff);
+ if (wilc_netdev == NULL)
+ return;
+
+ buff += pkt_offset;
+ nic = netdev_priv(wilc_netdev);
+
+ if (size > 0) {
+
+ frame_len = size;
+ buff_to_send = buff;
+
+
+ /* Need to send the packet up to the host, allocate a skb buffer */
+ skb = dev_alloc_skb(frame_len);
+ if (skb == NULL) {
+ PRINT_ER("Low memory - packet droped\n");
+ return;
+ }
+
+ skb_reserve(skb, (unsigned int)skb->data & 0x3);
+
+ if (g_linux_wlan == NULL || wilc_netdev == NULL) {
+ PRINT_ER("wilc_netdev in g_linux_wlan is NULL");
+ }
+ skb->dev = wilc_netdev;
+
+ if (skb->dev == NULL) {
+ PRINT_ER("skb->dev is NULL\n");
+ }
+
+ /*
+ * for(i=0;i<40;i++)
+ * {
+ * if(i<frame_len)
+ * WILC_PRINTF("buff_to_send[%d]=%2x\n",i,buff_to_send[i]);
+ *
+ * }*/
+
+ /* skb_put(skb, frame_len); */
+ memcpy(skb_put(skb, frame_len), buff_to_send, frame_len);
+
+ /* WILC_PRINTF("After MEM_CPY\n"); */
+
+ /* nic = netdev_priv(wilc_netdev); */
+
+#ifdef USE_WIRELESS
+ /* if(nic->monitor_flag)
+ * {
+ * WILC_WFI_monitor_rx(nic->wilc_netdev,skb);
+ * return;
+ * }*/
+#endif
+ skb->protocol = eth_type_trans(skb, wilc_netdev);
+ #ifndef TCP_ENHANCEMENTS
+ /*get source and dest ip addresses*/
+ ih = (struct iphdr *)(skb->data + sizeof(struct ethhdr));
+
+ pu8UdpBuffer = (char *)ih + sizeof(struct iphdr);
+ if (buff_to_send[35] == 67 && buff_to_send[37] == 68) {
+ PRINT_D(RX_DBG, "DHCP Message received\n");
+ }
+ if (buff_to_send[12] == 0x88 && buff_to_send[13] == 0x8e)
+ PRINT_D(GENERIC_DBG, "eapol received\n");
+ #endif
+ /* Send the packet to the stack by giving it to the bridge */
+ nic->netstats.rx_packets++;
+ nic->netstats.rx_bytes += frame_len;
+ skb->ip_summed = CHECKSUM_UNNECESSARY;
+ stats = netif_rx(skb);
+ PRINT_D(RX_DBG, "netif_rx ret value is: %d\n", stats);
+ }
+ #ifndef TCP_ENHANCEMENTS
+ else {
+ PRINT_ER("Discard sending packet with len = %d\n", size);
+ }
+ #endif
+}
+
+void WILC_WFI_mgmt_rx(uint8_t *buff, uint32_t size)
+{
+ int i = 0;
+ perInterface_wlan_t *nic;
+
+ /*BugID_5450*/
+ /*Pass the frame on the monitor interface, if any.*/
+ /*Otherwise, pass it on p2p0 netdev, if registered on it*/
+ for (i = 0; i < g_linux_wlan->u8NoIfcs; i++) {
+ nic = netdev_priv(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ if (nic->monitor_flag) {
+ WILC_WFI_monitor_rx(buff, size);
+ return;
+ }
+ }
+
+ #ifdef WILC_P2P
+ nic = netdev_priv(g_linux_wlan->strInterfaceInfo[1].wilc_netdev); /* p2p0 */
+ if ((buff[0] == nic->g_struct_frame_reg[0].frame_type && nic->g_struct_frame_reg[0].reg) ||
+ (buff[0] == nic->g_struct_frame_reg[1].frame_type && nic->g_struct_frame_reg[1].reg)) {
+ WILC_WFI_p2p_rx(g_linux_wlan->strInterfaceInfo[1].wilc_netdev, buff, size);
+ }
+ #endif
+}
+
+int wilc_netdev_init(void)
+{
+
+ int i;
+ perInterface_wlan_t *nic;
+ struct net_device *ndev;
+
+ linux_wlan_init_lock("close_exit_sync", &close_exit_sync, 0);
+
+ /*create the common structure*/
+ g_linux_wlan = (linux_wlan_t *)WILC_MALLOC(sizeof(linux_wlan_t));
+ memset(g_linux_wlan, 0, sizeof(linux_wlan_t));
+
+ /*Reset interrupt count debug*/
+ int_rcvdU = 0;
+ int_rcvdB = 0;
+ int_clrd = 0;
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ register_inetaddr_notifier(&g_dev_notifier);
+ #endif
+
+ for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
+ /*allocate first ethernet device with perinterface_wlan_t as its private data*/
+ ndev = alloc_etherdev(sizeof(perInterface_wlan_t));
+ if (!ndev) {
+ PRINT_ER("Failed to allocate ethernet dev\n");
+ return -1;
+ }
+
+ nic = netdev_priv(ndev);
+ memset(nic, 0, sizeof(perInterface_wlan_t));
+
+ /*Name the Devices*/
+ if (i == 0) {
+ #if defined(NM73131) /* tony, 2012-09-20 */
+ strcpy(ndev->name, "wilc_eth%d");
+ #elif defined(PLAT_CLM9722) /* rachel */
+ strcpy(ndev->name, "eth%d");
+ #else /* PANDA_BOARD, PLAT_ALLWINNER_A10, PLAT_ALLWINNER_A20, PLAT_ALLWINNER_A31, PLAT_AML8726_M3 or PLAT_WMS8304 */
+ strcpy(ndev->name, "wlan%d");
+ #endif
+ } else
+ strcpy(ndev->name, "p2p%d");
+
+ nic->u8IfIdx = g_linux_wlan->u8NoIfcs;
+ nic->wilc_netdev = ndev;
+ g_linux_wlan->strInterfaceInfo[g_linux_wlan->u8NoIfcs].wilc_netdev = ndev;
+ g_linux_wlan->u8NoIfcs++;
+ ndev->netdev_ops = &wilc_netdev_ops;
+
+ #ifdef USE_WIRELESS
+ {
+ struct wireless_dev *wdev;
+ /*Register WiFi*/
+ wdev = WILC_WFI_WiphyRegister(ndev);
+
+ #ifdef WILC_SDIO
+ /* set netdev, tony */
+ SET_NETDEV_DEV(ndev, &local_sdio_func->dev);
+ #endif
+
+ if (wdev == NULL) {
+ PRINT_ER("Can't register WILC Wiphy\n");
+ return -1;
+ }
+
+ /*linking the wireless_dev structure with the netdevice*/
+ nic->wilc_netdev->ieee80211_ptr = wdev;
+ nic->wilc_netdev->ml_priv = nic;
+ wdev->netdev = nic->wilc_netdev;
+ nic->netstats.rx_packets = 0;
+ nic->netstats.tx_packets = 0;
+ nic->netstats.rx_bytes = 0;
+ nic->netstats.tx_bytes = 0;
+
+ }
+ #endif
+
+
+ if (register_netdev(ndev)) {
+ PRINT_ER("Device couldn't be registered - %s\n", ndev->name);
+ return -1; /* ERROR */
+ }
+
+ nic->iftype = STATION_MODE;
+ nic->mac_opened = 0;
+
+ }
+
+ #ifndef WILC_SDIO
+ if (!linux_spi_init(&g_linux_wlan->wilc_spidev)) {
+ PRINT_ER("Can't initialize SPI \n");
+ return -1; /* ERROR */
+ }
+ g_linux_wlan->wilc_spidev = wilc_spi_dev;
+ #else
+ g_linux_wlan->wilc_sdio_func = local_sdio_func;
+ #endif
+
+ return 0;
+}
+
+
+/*The 1st function called after module inserted*/
+static int __init init_wilc_driver(void)
+{
+
+
+#if defined (WILC_DEBUGFS)
+ if (wilc_debugfs_init() < 0) {
+ PRINT_D(GENERIC_DBG, "fail to create debugfs for wilc driver\n");
+ return -1;
+ }
+#endif
+
+ printk("IN INIT FUNCTION\n");
+ printk("*** WILC1000 driver VERSION=[10.2] FW_VER=[10.2] ***\n");
+
+ linux_wlan_device_power(1);
+ msleep(100);
+ linux_wlan_device_detection(1);
+
+#ifdef WILC_SDIO
+ {
+ int ret;
+
+ ret = sdio_register_driver(&wilc_bus);
+ if (ret < 0) {
+ PRINT_D(INIT_DBG, "init_wilc_driver: Failed register sdio driver\n");
+ }
+
+ return ret;
+ }
+#else
+ PRINT_D(INIT_DBG, "Initializing netdev\n");
+ if (wilc_netdev_init()) {
+ PRINT_ER("Couldn't initialize netdev\n");
+ }
+ return 0;
+#endif
+}
+late_initcall(init_wilc_driver);
+
+static void __exit exit_wilc_driver(void)
+{
+ int i = 0;
+ perInterface_wlan_t *nic[NUM_CONCURRENT_IFC];
+ #define CLOSE_TIMEOUT (12 * 1000)
+
+ if ((g_linux_wlan != NULL) && (((g_linux_wlan->strInterfaceInfo[0].wilc_netdev) != NULL)
+ || ((g_linux_wlan->strInterfaceInfo[1].wilc_netdev) != NULL))) {
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ unregister_inetaddr_notifier(&g_dev_notifier);
+ #endif
+
+ for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
+ nic[i] = netdev_priv(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ }
+ }
+
+
+ if ((g_linux_wlan != NULL) && g_linux_wlan->wilc_firmware != NULL) {
+ release_firmware(g_linux_wlan->wilc_firmware);
+ g_linux_wlan->wilc_firmware = NULL;
+ }
+
+
+ if ((g_linux_wlan != NULL) && (((g_linux_wlan->strInterfaceInfo[0].wilc_netdev) != NULL)
+ || ((g_linux_wlan->strInterfaceInfo[1].wilc_netdev) != NULL))) {
+ PRINT_D(INIT_DBG, "Waiting for mac_close ....\n");
+
+ if (linux_wlan_lock_timeout(&close_exit_sync, CLOSE_TIMEOUT) < 0)
+ PRINT_D(INIT_DBG, "Closed TimedOUT\n");
+ else
+ PRINT_D(INIT_DBG, "mac_closed\n");
+
+
+ for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
+ /* close all opened interfaces */
+ if (g_linux_wlan->strInterfaceInfo[i].wilc_netdev != NULL) {
+ if (nic[i]->mac_opened) {
+ mac_close(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ }
+ }
+ }
+ for (i = 0; i < NUM_CONCURRENT_IFC; i++) {
+ PRINT_D(INIT_DBG, "Unregistering netdev %p \n", g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ unregister_netdev(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ #ifdef USE_WIRELESS
+ PRINT_D(INIT_DBG, "Freeing Wiphy...\n");
+ WILC_WFI_WiphyFree(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ #endif
+ PRINT_D(INIT_DBG, "Freeing netdev...\n");
+ free_netdev(g_linux_wlan->strInterfaceInfo[i].wilc_netdev);
+ }
+ }
+
+
+#ifdef USE_WIRELESS
+#ifdef WILC_AP_EXTERNAL_MLME
+ /* Bug 4600 : WILC_WFI_deinit_mon_interface was already called at mac_close */
+ /* WILC_WFI_deinit_mon_interface(); */
+#endif
+#endif
+
+ /* if(g_linux_wlan->open_ifcs==0) */
+ {
+ #ifndef WILC_SDIO
+ PRINT_D(INIT_DBG, "SPI unregsiter...\n");
+ spi_unregister_driver(&wilc_bus);
+ #else
+ PRINT_D(INIT_DBG, "SDIO unregsiter...\n");
+ sdio_unregister_driver(&wilc_bus);
+ #endif
+
+ linux_wlan_deinit_lock(&close_exit_sync);
+ if (g_linux_wlan != NULL) {
+ WILC_FREE(g_linux_wlan);
+ g_linux_wlan = NULL;
+ }
+ printk("Module_exit Done.\n");
+
+#if defined (WILC_DEBUGFS)
+ wilc_debugfs_remove();
+#endif
+
+ linux_wlan_device_detection(0);
+ linux_wlan_device_power(0);
+ }
+}
+module_exit(exit_wilc_driver);
+
+MODULE_LICENSE("GPL");
+#endif
diff --git a/drivers/staging/wilc1000/linux_wlan_common.h b/drivers/staging/wilc1000/linux_wlan_common.h
new file mode 100644
index 00000000000000..541f19cf44ae49
--- /dev/null
+++ b/drivers/staging/wilc1000/linux_wlan_common.h
@@ -0,0 +1,170 @@
+#ifndef LINUX_WLAN_COMMON_H
+#define LINUX_WLAN_COMMON_H
+
+enum debug_region {
+ Generic_debug = 0,
+ Hostapd_debug,
+ Hostinf_debug,
+ CFG80211_debug,
+ Coreconfig_debug,
+ Interrupt_debug,
+ TX_debug,
+ RX_debug,
+ Lock_debug,
+ Tcp_enhance,
+ /*Added by amr - BugID_4720*/
+ Spin_debug,
+
+ Init_debug,
+ Bus_debug,
+ Mem_debug,
+ Firmware_debug,
+ COMP = 0xFFFFFFFF,
+};
+
+#define GENERIC_DBG (1 << Generic_debug)
+#define HOSTAPD_DBG (1 << Hostapd_debug)
+#define HOSTINF_DBG (1 << Hostinf_debug)
+#define CORECONFIG_DBG (1 << Coreconfig_debug)
+#define CFG80211_DBG (1 << CFG80211_debug)
+#define INT_DBG (1 << Interrupt_debug)
+#define TX_DBG (1 << TX_debug)
+#define RX_DBG (1 << RX_debug)
+#define LOCK_DBG (1 << Lock_debug)
+#define TCP_ENH (1 << Tcp_enhance)
+
+
+/*Added by Amr - BugID_4720*/
+#define SPIN_DEBUG (1 << Spin_debug)
+
+#define INIT_DBG (1 << Init_debug)
+#define BUS_DBG (1 << Bus_debug)
+#define MEM_DBG (1 << Mem_debug)
+#define FIRM_DBG (1 << Firmware_debug)
+
+#if defined (WILC_DEBUGFS)
+extern int wilc_debugfs_init(void);
+extern void wilc_debugfs_remove(void);
+
+extern atomic_t REGION;
+extern atomic_t DEBUG_LEVEL;
+
+#define DEBUG (1 << 0)
+#define INFO (1 << 1)
+#define WRN (1 << 2)
+#define ERR (1 << 3)
+
+#define PRINT_D(region, ...) do { \
+ if ((atomic_read(&DEBUG_LEVEL) & DEBUG) && ((atomic_read(&REGION)) & (region))) { \
+ printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \
+ printk(__VA_ARGS__); \
+ } \
+} while (0)
+
+#define PRINT_INFO(region, ...) do { \
+ if ((atomic_read(&DEBUG_LEVEL) & INFO) && ((atomic_read(&REGION)) & (region))) { \
+ printk("INFO [%s]", __FUNCTION__); \
+ printk(__VA_ARGS__); \
+ } \
+} while (0)
+
+#define PRINT_WRN(region, ...) do { \
+ if ((atomic_read(&DEBUG_LEVEL) & WRN) && ((atomic_read(&REGION)) & (region))) { \
+ printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \
+ printk(__VA_ARGS__); \
+ } \
+} while (0)
+
+#define PRINT_ER(...) do { \
+ if ((atomic_read(&DEBUG_LEVEL) & ERR)) { \
+ printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \
+ printk(__VA_ARGS__); \
+ } \
+} while (0)
+
+#else
+
+#define REGION (INIT_DBG | GENERIC_DBG | CFG80211_DBG | FIRM_DBG | HOSTAPD_DBG)
+
+#define DEBUG 1
+#define INFO 0
+#define WRN 0
+#define PRINT_D(region, ...) do { if (DEBUG == 1 && ((REGION)&(region))) { \
+ printk("DBG [%s: %d]", __FUNCTION__, __LINE__); \
+ printk(__VA_ARGS__); \
+ } \
+ } while (0)
+
+#define PRINT_INFO(region, ...) do { if (INFO == 1 && ((REGION)&(region))) { \
+ printk("INFO [%s]", __FUNCTION__); \
+ printk(__VA_ARGS__); \
+ } \
+ } while (0)
+
+#define PRINT_WRN(region, ...) do { if (WRN == 1 && ((REGION)&(region))) { \
+ printk("WRN [%s: %d]", __FUNCTION__, __LINE__); \
+ printk(__VA_ARGS__); \
+ } \
+ } while (0)
+
+#define PRINT_ER(...) do { printk("ERR [%s: %d]", __FUNCTION__, __LINE__); \
+ printk(__VA_ARGS__); \
+ } while (0)
+#endif
+
+#define FN_IN /* PRINT_D(">>> \n") */
+#define FN_OUT /* PRINT_D("<<<\n") */
+
+#ifdef MEMORY_STATIC
+#define LINUX_RX_SIZE (96 * 1024)
+#endif
+#define LINUX_TX_SIZE (64 * 1024)
+
+
+#define WILC_MULTICAST_TABLE_SIZE 8
+
+#if defined (NM73131_0_BOARD)
+
+#define MODALIAS "wilc_spi"
+#define GPIO_NUM IRQ_WILC1000_GPIO
+
+#elif defined (BEAGLE_BOARD)
+ #define SPI_CHANNEL 4
+
+ #if SPI_CHANNEL == 4
+ #define MODALIAS "wilc_spi4"
+ #define GPIO_NUM 162
+ #else
+ #define MODALIAS "wilc_spi3"
+ #define GPIO_NUM 133
+ #endif
+#elif defined(PANDA_BOARD)
+ #define MODALIAS "WILC_SPI"
+ #define GPIO_NUM 139
+#elif defined(PLAT_WMS8304) /* rachel */
+ #define MODALIAS "wilc_spi"
+ #define GPIO_NUM 139
+#elif defined (PLAT_RKXXXX)
+ #define MODALIAS "WILC_IRQ"
+ #define GPIO_NUM RK30_PIN3_PD2 /* RK30_PIN3_PA1 */
+/* RK30_PIN3_PD2 */
+/* RK2928_PIN1_PA7 */
+
+#elif defined(CUSTOMER_PLATFORM)
+/*
+ TODO : specify MODALIAS name and GPIO number. This is certainly necessary for SPI interface.
+ *
+ * ex)
+ * #define MODALIAS "WILC_SPI"
+ * #define GPIO_NUM 139
+ */
+
+#else
+/* base on SAMA5D3_Xplained Board */
+ #define MODALIAS "WILC_SPI"
+ #define GPIO_NUM 0x44
+#endif
+
+
+void linux_wlan_enable_irq(void);
+#endif
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.c b/drivers/staging/wilc1000/linux_wlan_sdio.c
new file mode 100644
index 00000000000000..858e3a191bce8b
--- /dev/null
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.c
@@ -0,0 +1,249 @@
+#include "wilc_wfi_netdevice.h"
+
+#include <linux/mmc/sdio_func.h>
+#include <linux/mmc/card.h>
+#include <linux/mmc/sdio_ids.h>
+#include <linux/mmc/sdio.h>
+#include <linux/mmc/host.h>
+
+
+
+#if defined (NM73131_0_BOARD)
+#define SDIO_MODALIAS "wilc_sdio"
+#else
+#define SDIO_MODALIAS "wilc1000_sdio"
+#endif
+
+#if defined (NM73131_0_BOARD)
+ #define MAX_SPEED 50000000
+#elif defined(CUSTOMER_PLATFORM)
+/* TODO : User have to stable bus clock as user's environment. */
+ #ifdef MAX_BUS_SPEED
+ #define MAX_SPEED MAX_BUS_SPEED
+ #else
+ #define MAX_SPEED 50000000
+ #endif
+#else
+ #define MAX_SPEED (6 * 1000000) /* Max 50M */
+#endif
+
+
+struct sdio_func *local_sdio_func;
+extern linux_wlan_t *g_linux_wlan;
+extern int wilc_netdev_init(void);
+extern int sdio_clear_int(void);
+extern void wilc_handle_isr(void);
+
+static unsigned int sdio_default_speed;
+
+#define SDIO_VENDOR_ID_WILC 0x0296
+#define SDIO_DEVICE_ID_WILC 0x5347
+
+static const struct sdio_device_id wilc_sdio_ids[] = {
+ { SDIO_DEVICE(SDIO_VENDOR_ID_WILC, SDIO_DEVICE_ID_WILC) },
+};
+
+
+static void wilc_sdio_interrupt(struct sdio_func *func)
+{
+#ifndef WILC_SDIO_IRQ_GPIO
+ sdio_release_host(func);
+ wilc_handle_isr();
+ sdio_claim_host(func);
+#endif
+}
+
+
+int linux_sdio_cmd52(sdio_cmd52_t *cmd)
+{
+ struct sdio_func *func = g_linux_wlan->wilc_sdio_func;
+ int ret;
+ u8 data;
+
+ sdio_claim_host(func);
+
+ func->num = cmd->function;
+ if (cmd->read_write) { /* write */
+ if (cmd->raw) {
+ sdio_writeb(func, cmd->data, cmd->address, &ret);
+ data = sdio_readb(func, cmd->address, &ret);
+ cmd->data = data;
+ } else {
+ sdio_writeb(func, cmd->data, cmd->address, &ret);
+ }
+ } else { /* read */
+ data = sdio_readb(func, cmd->address, &ret);
+ cmd->data = data;
+ }
+
+ sdio_release_host(func);
+
+ if (ret < 0) {
+ PRINT_ER("wilc_sdio_cmd52..failed, err(%d)\n", ret);
+ return 0;
+ }
+ return 1;
+}
+
+
+int linux_sdio_cmd53(sdio_cmd53_t *cmd)
+{
+ struct sdio_func *func = g_linux_wlan->wilc_sdio_func;
+ int size, ret;
+
+ sdio_claim_host(func);
+
+ func->num = cmd->function;
+ func->cur_blksize = cmd->block_size;
+ if (cmd->block_mode)
+ size = cmd->count * cmd->block_size;
+ else
+ size = cmd->count;
+
+ if (cmd->read_write) { /* write */
+ ret = sdio_memcpy_toio(func, cmd->address, (void *)cmd->buffer, size);
+ } else { /* read */
+ ret = sdio_memcpy_fromio(func, (void *)cmd->buffer, cmd->address, size);
+ }
+
+ sdio_release_host(func);
+
+
+ if (ret < 0) {
+ PRINT_ER("wilc_sdio_cmd53..failed, err(%d)\n", ret);
+ return 0;
+ }
+
+ return 1;
+}
+
+volatile int probe; /* COMPLEMENT_BOOT */
+static int linux_sdio_probe(struct sdio_func *func, const struct sdio_device_id *id)
+{
+ PRINT_D(INIT_DBG, "probe function\n");
+
+#ifdef COMPLEMENT_BOOT
+ if (local_sdio_func != NULL) {
+ local_sdio_func = func;
+ probe = 1;
+ PRINT_D(INIT_DBG, "local_sdio_func isn't NULL\n");
+ return 0;
+ }
+#endif
+ PRINT_D(INIT_DBG, "Initializing netdev\n");
+ local_sdio_func = func;
+ if (wilc_netdev_init()) {
+ PRINT_ER("Couldn't initialize netdev\n");
+ return -1;
+ }
+
+ printk("Driver Initializing success\n");
+ return 0;
+}
+
+static void linux_sdio_remove(struct sdio_func *func)
+{
+ /**
+ * TODO
+ **/
+
+}
+
+struct sdio_driver wilc_bus = {
+ .name = SDIO_MODALIAS,
+ .id_table = wilc_sdio_ids,
+ .probe = linux_sdio_probe,
+ .remove = linux_sdio_remove,
+};
+
+int enable_sdio_interrupt(void)
+{
+ int ret = 0;
+#ifndef WILC_SDIO_IRQ_GPIO
+
+ sdio_claim_host(local_sdio_func);
+ ret = sdio_claim_irq(local_sdio_func, wilc_sdio_interrupt);
+ sdio_release_host(local_sdio_func);
+
+ if (ret < 0) {
+ PRINT_ER("can't claim sdio_irq, err(%d)\n", ret);
+ ret = -EIO;
+ }
+#endif
+ return ret;
+}
+
+void disable_sdio_interrupt(void)
+{
+
+#ifndef WILC_SDIO_IRQ_GPIO
+ int ret;
+
+ PRINT_D(INIT_DBG, "disable_sdio_interrupt IN\n");
+
+ sdio_claim_host(local_sdio_func);
+ ret = sdio_release_irq(local_sdio_func);
+ if (ret < 0) {
+ PRINT_ER("can't release sdio_irq, err(%d)\n", ret);
+ }
+ sdio_release_host(local_sdio_func);
+
+ PRINT_D(INIT_DBG, "disable_sdio_interrupt OUT\n");
+#endif
+}
+
+static int linux_sdio_set_speed(int speed)
+{
+ struct mmc_ios ios;
+ sdio_claim_host(local_sdio_func);
+
+ memcpy((void *)&ios, (void *)&local_sdio_func->card->host->ios, sizeof(struct mmc_ios));
+ local_sdio_func->card->host->ios.clock = speed;
+ ios.clock = speed;
+ local_sdio_func->card->host->ops->set_ios(local_sdio_func->card->host, &ios);
+ sdio_release_host(local_sdio_func);
+ PRINT_INFO(INIT_DBG, "@@@@@@@@@@@@ change SDIO speed to %d @@@@@@@@@\n", speed);
+
+ return 1;
+}
+
+static int linux_sdio_get_speed(void)
+{
+ return local_sdio_func->card->host->ios.clock;
+}
+
+int linux_sdio_init(void *pv)
+{
+
+ /**
+ * TODO :
+ **/
+
+
+ sdio_default_speed = linux_sdio_get_speed();
+ return 1;
+}
+
+void linux_sdio_deinit(void *pv)
+{
+
+ /**
+ * TODO :
+ **/
+
+
+ sdio_unregister_driver(&wilc_bus);
+}
+
+int linux_sdio_set_max_speed(void)
+{
+ return linux_sdio_set_speed(MAX_SPEED);
+}
+
+int linux_sdio_set_default_speed(void)
+{
+ return linux_sdio_set_speed(sdio_default_speed);
+}
+
+
+
diff --git a/drivers/staging/wilc1000/linux_wlan_sdio.h b/drivers/staging/wilc1000/linux_wlan_sdio.h
new file mode 100644
index 00000000000000..4b515f5108e7f0
--- /dev/null
+++ b/drivers/staging/wilc1000/linux_wlan_sdio.h
@@ -0,0 +1,14 @@
+extern struct sdio_func *local_sdio_func;
+extern struct sdio_driver wilc_bus;
+
+#include <linux/mmc/sdio_func.h>
+
+int linux_sdio_init(void *);
+void linux_sdio_deinit(void *);
+int linux_sdio_cmd52(sdio_cmd52_t *cmd);
+int linux_sdio_cmd53(sdio_cmd53_t *cmd);
+int enable_sdio_interrupt(void);
+void disable_sdio_interrupt(void);
+int linux_sdio_set_max_speed(void);
+int linux_sdio_set_default_speed(void);
+
diff --git a/drivers/staging/wilc1000/linux_wlan_spi.c b/drivers/staging/wilc1000/linux_wlan_spi.c
new file mode 100644
index 00000000000000..e5d794590f00b1
--- /dev/null
+++ b/drivers/staging/wilc1000/linux_wlan_spi.c
@@ -0,0 +1,507 @@
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/fs.h>
+#include <linux/slab.h>
+#include <linux/types.h>
+#include <linux/cdev.h>
+#include <asm/uaccess.h>
+#include <linux/device.h>
+#include <linux/spi/spi.h>
+
+#include "linux_wlan_common.h"
+
+#define USE_SPI_DMA 0 /* johnny add */
+
+#ifdef WILC_ASIC_A0
+ #if defined(PLAT_PANDA_ES_OMAP4460)
+ #define MIN_SPEED 12000000
+ #define MAX_SPEED 24000000
+ #elif defined(PLAT_WMS8304)
+ #define MIN_SPEED 12000000
+ #define MAX_SPEED 24000000 /* 4000000 */
+ #elif defined(CUSTOMER_PLATFORM)
+/*
+ TODO : define Clock speed under 48M.
+ *
+ * ex)
+ * #define MIN_SPEED 24000000
+ * #define MAX_SPEED 48000000
+ */
+ #else
+ #define MIN_SPEED 24000000
+ #define MAX_SPEED 48000000
+ #endif
+#else /* WILC_ASIC_A0 */
+/* Limit clk to 6MHz on FPGA. */
+ #define MIN_SPEED 6000000
+ #define MAX_SPEED 6000000
+#endif /* WILC_ASIC_A0 */
+
+static uint32_t SPEED = MIN_SPEED;
+
+struct spi_device *wilc_spi_dev;
+void linux_spi_deinit(void *vp);
+
+static int __init wilc_bus_probe(struct spi_device *spi)
+{
+
+ PRINT_D(BUS_DBG, "spiModalias: %s\n", spi->modalias);
+ PRINT_D(BUS_DBG, "spiMax-Speed: %d\n", spi->max_speed_hz);
+ wilc_spi_dev = spi;
+
+ printk("Driver Initializing success\n");
+ return 0;
+}
+
+static int __exit wilc_bus_remove(struct spi_device *spi)
+{
+
+ /* linux_spi_deinit(NULL); */
+
+ return 0;
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id wilc1000_of_match[] = {
+ { .compatible = "atmel,wilc_spi", },
+ {}
+};
+MODULE_DEVICE_TABLE(of, wilc1000_of_match);
+#endif
+
+struct spi_driver wilc_bus __refdata = {
+ .driver = {
+ .name = MODALIAS,
+#ifdef CONFIG_OF
+ .of_match_table = wilc1000_of_match,
+#endif
+ },
+ .probe = wilc_bus_probe,
+ .remove = __exit_p(wilc_bus_remove),
+};
+
+
+void linux_spi_deinit(void *vp)
+{
+
+ spi_unregister_driver(&wilc_bus);
+
+ SPEED = MIN_SPEED;
+ PRINT_ER("@@@@@@@@@@@@ restore SPI speed to %d @@@@@@@@@\n", SPEED);
+
+}
+
+
+
+int linux_spi_init(void *vp)
+{
+ int ret = 1;
+ static int called;
+
+
+ if (called == 0) {
+ called++;
+ ret = spi_register_driver(&wilc_bus);
+ }
+
+ /* change return value to match WILC interface */
+ (ret < 0) ? (ret = 0) : (ret = 1);
+
+ return ret;
+}
+
+#if defined(PLAT_WMS8304)
+#define TXRX_PHASE_SIZE (4096)
+#endif
+
+#if defined (NM73131_0_BOARD)
+
+int linux_spi_write(uint8_t *b, uint32_t len)
+{
+
+ int ret;
+
+ if (len > 0 && b != NULL) {
+ struct spi_message msg;
+ PRINT_D(BUS_DBG, "Request writing %d bytes\n", len);
+ struct spi_transfer tr = {
+ .tx_buf = b,
+ .len = len,
+ .speed_hz = SPEED,
+ .delay_usecs = 0,
+ };
+
+ spi_message_init(&msg);
+ spi_message_add_tail(&tr, &msg);
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+
+ } else {
+ PRINT_ER("can't write data with the following length: %d\n", len);
+ PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len);
+ ret = -1;
+ }
+
+ /* change return value to match WILC interface */
+ (ret < 0) ? (ret = 0) : (ret = 1);
+
+
+ return ret;
+}
+
+#elif defined(TXRX_PHASE_SIZE)
+
+int linux_spi_write(uint8_t *b, uint32_t len)
+{
+ int ret;
+ if (len > 0 && b != NULL) {
+ int i = 0;
+ int blk = len / TXRX_PHASE_SIZE;
+ int remainder = len % TXRX_PHASE_SIZE;
+
+ char *r_buffer = (char *) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL);
+ if (!r_buffer) {
+ PRINT_ER("Failed to allocate memory for r_buffer\n");
+ }
+
+ if (blk) {
+ while (i < blk) {
+ struct spi_message msg;
+ struct spi_transfer tr = {
+ .tx_buf = b + (i * TXRX_PHASE_SIZE),
+ /* .rx_buf = NULL, */
+ .len = TXRX_PHASE_SIZE,
+ .speed_hz = SPEED,
+ .bits_per_word = 8,
+ .delay_usecs = 0,
+ };
+ /*
+ * char *r_buffer = (char*) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL);
+ * if(! r_buffer){
+ * PRINT_ER("Failed to allocate memory for r_buffer\n");
+ * }
+ */
+ tr.rx_buf = r_buffer;
+
+ memset(&msg, 0, sizeof(msg));
+ spi_message_init(&msg);
+ msg.spi = wilc_spi_dev;
+ msg.is_dma_mapped = USE_SPI_DMA;
+
+ spi_message_add_tail(&tr, &msg);
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+ /* i += MJ_WRITE_SIZE; */
+ i++;
+
+ }
+ }
+ if (remainder) {
+ struct spi_message msg;
+ struct spi_transfer tr = {
+ .tx_buf = b + (blk * TXRX_PHASE_SIZE),
+ /* .rx_buf = NULL, */
+ .len = remainder,
+ .speed_hz = SPEED,
+ .bits_per_word = 8,
+ .delay_usecs = 0,
+ };
+ /*
+ * char *r_buffer = (char*) kzalloc(remainder, GFP_KERNEL);
+ * if(! r_buffer){
+ * PRINT_ER("Failed to allocate memory for r_buffer\n");
+ * }
+ */
+ tr.rx_buf = r_buffer;
+
+ memset(&msg, 0, sizeof(msg));
+ spi_message_init(&msg);
+ msg.spi = wilc_spi_dev;
+ msg.is_dma_mapped = USE_SPI_DMA; /* rachel */
+
+ spi_message_add_tail(&tr, &msg);
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+ }
+ if (r_buffer)
+ kfree(r_buffer);
+ } else {
+ PRINT_ER("can't write data with the following length: %d\n", len);
+ PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len);
+ ret = -1;
+ }
+
+ /* change return value to match WILC interface */
+ (ret < 0) ? (ret = 0) : (ret = 1);
+
+ return ret;
+
+}
+
+#else
+int linux_spi_write(uint8_t *b, uint32_t len)
+{
+
+ int ret;
+ struct spi_message msg;
+
+ if (len > 0 && b != NULL) {
+ struct spi_transfer tr = {
+ .tx_buf = b,
+ /* .rx_buf = r_buffer, */
+ .len = len,
+ .speed_hz = SPEED,
+ .delay_usecs = 0,
+ };
+ char *r_buffer = (char *) kzalloc(len, GFP_KERNEL);
+ if (!r_buffer) {
+ PRINT_ER("Failed to allocate memory for r_buffer\n");
+ }
+ tr.rx_buf = r_buffer;
+ PRINT_D(BUS_DBG, "Request writing %d bytes\n", len);
+
+ memset(&msg, 0, sizeof(msg));
+ spi_message_init(&msg);
+/* [[johnny add */
+ msg.spi = wilc_spi_dev;
+ msg.is_dma_mapped = USE_SPI_DMA;
+/* ]] */
+ spi_message_add_tail(&tr, &msg);
+
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+
+ kfree(r_buffer);
+ } else {
+ PRINT_ER("can't write data with the following length: %d\n", len);
+ PRINT_ER("FAILED due to NULL buffer or ZERO length check the following length: %d\n", len);
+ ret = -1;
+ }
+
+ /* change return value to match WILC interface */
+ (ret < 0) ? (ret = 0) : (ret = 1);
+
+
+ return ret;
+}
+
+#endif
+
+#if defined (NM73131_0_BOARD)
+
+int linux_spi_read(unsigned char *rb, unsigned long rlen)
+{
+
+ int ret;
+
+ if (rlen > 0) {
+ struct spi_message msg;
+ struct spi_transfer tr = {
+ .rx_buf = rb,
+ .len = rlen,
+ .speed_hz = SPEED,
+ .delay_usecs = 0,
+
+ };
+
+ spi_message_init(&msg);
+ spi_message_add_tail(&tr, &msg);
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+ } else {
+ PRINT_ER("can't read data with the following length: %ld\n", rlen);
+ ret = -1;
+ }
+ /* change return value to match WILC interface */
+ (ret < 0) ? (ret = 0) : (ret = 1);
+
+ return ret;
+}
+
+#elif defined(TXRX_PHASE_SIZE)
+
+int linux_spi_read(unsigned char *rb, unsigned long rlen)
+{
+ int ret;
+
+ if (rlen > 0) {
+ int i = 0;
+
+ int blk = rlen / TXRX_PHASE_SIZE;
+ int remainder = rlen % TXRX_PHASE_SIZE;
+
+ char *t_buffer = (char *) kzalloc(TXRX_PHASE_SIZE, GFP_KERNEL);
+ if (!t_buffer) {
+ PRINT_ER("Failed to allocate memory for t_buffer\n");
+ }
+
+ if (blk) {
+ while (i < blk) {
+ struct spi_message msg;
+ struct spi_transfer tr = {
+ /* .tx_buf = NULL, */
+ .rx_buf = rb + (i * TXRX_PHASE_SIZE),
+ .len = TXRX_PHASE_SIZE,
+ .speed_hz = SPEED,
+ .bits_per_word = 8,
+ .delay_usecs = 0,
+ };
+ tr.tx_buf = t_buffer;
+
+ memset(&msg, 0, sizeof(msg));
+ spi_message_init(&msg);
+ msg.spi = wilc_spi_dev;
+ msg.is_dma_mapped = USE_SPI_DMA;
+
+ spi_message_add_tail(&tr, &msg);
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+ i++;
+ }
+ }
+ if (remainder) {
+ struct spi_message msg;
+ struct spi_transfer tr = {
+ /* .tx_buf = NULL, */
+ .rx_buf = rb + (blk * TXRX_PHASE_SIZE),
+ .len = remainder,
+ .speed_hz = SPEED,
+ .bits_per_word = 8,
+ .delay_usecs = 0,
+ };
+ /*
+ * char *t_buffer = (char*) kzalloc(remainder, GFP_KERNEL);
+ * if(! t_buffer){
+ * PRINT_ER("Failed to allocate memory for t_buffer\n");
+ * }
+ */
+ tr.tx_buf = t_buffer;
+
+ memset(&msg, 0, sizeof(msg));
+ spi_message_init(&msg);
+ msg.spi = wilc_spi_dev;
+ msg.is_dma_mapped = USE_SPI_DMA; /* rachel */
+
+ spi_message_add_tail(&tr, &msg);
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+ }
+
+ if (t_buffer)
+ kfree(t_buffer);
+ } else {
+ PRINT_ER("can't read data with the following length: %ld\n", rlen);
+ ret = -1;
+ }
+ /* change return value to match WILC interface */
+ (ret < 0) ? (ret = 0) : (ret = 1);
+
+ return ret;
+}
+
+#else
+int linux_spi_read(unsigned char *rb, unsigned long rlen)
+{
+
+ int ret;
+
+ if (rlen > 0) {
+ struct spi_message msg;
+ struct spi_transfer tr = {
+ /* .tx_buf = t_buffer, */
+ .rx_buf = rb,
+ .len = rlen,
+ .speed_hz = SPEED,
+ .delay_usecs = 0,
+
+ };
+ char *t_buffer = (char *) kzalloc(rlen, GFP_KERNEL);
+ if (!t_buffer) {
+ PRINT_ER("Failed to allocate memory for t_buffer\n");
+ }
+ tr.tx_buf = t_buffer;
+
+ memset(&msg, 0, sizeof(msg));
+ spi_message_init(&msg);
+/* [[ johnny add */
+ msg.spi = wilc_spi_dev;
+ msg.is_dma_mapped = USE_SPI_DMA;
+/* ]] */
+ spi_message_add_tail(&tr, &msg);
+
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+ kfree(t_buffer);
+ } else {
+ PRINT_ER("can't read data with the following length: %ld\n", rlen);
+ ret = -1;
+ }
+ /* change return value to match WILC interface */
+ (ret < 0) ? (ret = 0) : (ret = 1);
+
+ return ret;
+}
+
+#endif
+
+int linux_spi_write_read(unsigned char *wb, unsigned char *rb, unsigned int rlen)
+{
+
+ int ret;
+
+ if (rlen > 0) {
+ struct spi_message msg;
+ struct spi_transfer tr = {
+ .rx_buf = rb,
+ .tx_buf = wb,
+ .len = rlen,
+ .speed_hz = SPEED,
+ .bits_per_word = 8,
+ .delay_usecs = 0,
+
+ };
+
+ memset(&msg, 0, sizeof(msg));
+ spi_message_init(&msg);
+ msg.spi = wilc_spi_dev;
+ msg.is_dma_mapped = USE_SPI_DMA;
+
+ spi_message_add_tail(&tr, &msg);
+ ret = spi_sync(wilc_spi_dev, &msg);
+ if (ret < 0) {
+ PRINT_ER("SPI transaction failed\n");
+ }
+ } else {
+ PRINT_ER("can't read data with the following length: %d\n", rlen);
+ ret = -1;
+ }
+ /* change return value to match WILC interface */
+ (ret < 0) ? (ret = 0) : (ret = 1);
+
+ return ret;
+}
+
+int linux_spi_set_max_speed(void)
+{
+ SPEED = MAX_SPEED;
+
+ PRINT_INFO(BUS_DBG, "@@@@@@@@@@@@ change SPI speed to %d @@@@@@@@@\n", SPEED);
+ return 1;
+}
diff --git a/drivers/staging/wilc1000/linux_wlan_spi.h b/drivers/staging/wilc1000/linux_wlan_spi.h
new file mode 100644
index 00000000000000..0ecad477de1c5f
--- /dev/null
+++ b/drivers/staging/wilc1000/linux_wlan_spi.h
@@ -0,0 +1,14 @@
+#ifndef LINUX_WLAN_SPI_H
+#define LINUX_WLAN_SPI_H
+
+#include <linux/spi/spi.h>
+extern struct spi_device *wilc_spi_dev;
+extern struct spi_driver wilc_bus;
+
+int linux_spi_init(void *vp);
+void linux_spi_deinit(void *vp);
+int linux_spi_write(uint8_t *b, uint32_t len);
+int linux_spi_read(uint8_t *rb, uint32_t rlen);
+int linux_spi_write_read(unsigned char *wb, unsigned char *rb, unsigned int rlen);
+int linux_spi_set_max_speed(void);
+#endif
diff --git a/drivers/staging/wilc1000/wilc_debugfs.c b/drivers/staging/wilc1000/wilc_debugfs.c
new file mode 100644
index 00000000000000..74b9fd5ba27b81
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_debugfs.c
@@ -0,0 +1,185 @@
+/*
+ * NewportMedia WiFi chipset driver test tools - wilc-debug
+ * Copyright (c) 2012 NewportMedia Inc.
+ * Author: SSW <sswd@wilcsemic.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.
+ *
+ */
+
+#if defined(WILC_DEBUGFS)
+#include <linux/module.h>
+#include <linux/debugfs.h>
+#include <linux/poll.h>
+#include <linux/sched.h>
+
+#include "wilc_wlan_if.h"
+
+
+static struct dentry *wilc_dir;
+
+/*
+ * --------------------------------------------------------------------------------
+ */
+
+#define DBG_REGION_ALL (GENERIC_DBG | HOSTAPD_DBG | HOSTINF_DBG | CORECONFIG_DBG | CFG80211_DBG | INT_DBG | TX_DBG | RX_DBG | LOCK_DBG | INIT_DBG | BUS_DBG | MEM_DBG)
+#define DBG_LEVEL_ALL (DEBUG | INFO | WRN | ERR)
+atomic_t REGION = ATOMIC_INIT(INIT_DBG | GENERIC_DBG | CFG80211_DBG | FIRM_DBG | HOSTAPD_DBG);
+atomic_t DEBUG_LEVEL = ATOMIC_INIT(ERR);
+
+/*
+ * --------------------------------------------------------------------------------
+ */
+
+
+static ssize_t wilc_debug_level_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos)
+{
+ char buf[128];
+ int res = 0;
+
+ /* only allow read from start */
+ if (*ppos > 0)
+ return 0;
+
+ res = scnprintf(buf, sizeof(buf), "Debug Level: %x\n", atomic_read(&DEBUG_LEVEL));
+
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+
+static ssize_t wilc_debug_level_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
+{
+ char buffer[128] = {};
+ int flag = 0;
+
+ if (copy_from_user(buffer, buf, count)) {
+ return -EFAULT;
+ }
+
+ flag = buffer[0] - '0';
+
+ if (flag > 0) {
+ flag = DEBUG | ERR;
+ } else if (flag < 0) {
+ flag = 100;
+ }
+
+ if (flag > DBG_LEVEL_ALL) {
+ printk("%s, value (0x%08x) is out of range, stay previous flag (0x%08x)\n", __func__, flag, atomic_read(&DEBUG_LEVEL));
+ return -EFAULT;
+ }
+
+ atomic_set(&DEBUG_LEVEL, (int)flag);
+
+ if (flag == 0) {
+ printk("Debug-level disabled\n");
+ } else {
+ printk("Debug-level enabled\n");
+ }
+ return count;
+}
+
+static ssize_t wilc_debug_region_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos)
+{
+ char buf[128];
+ int res = 0;
+
+ /* only allow read from start */
+ if (*ppos > 0)
+ return 0;
+
+ res = scnprintf(buf, sizeof(buf), "Debug region: %x\n", atomic_read(&REGION));
+
+ return simple_read_from_buffer(userbuf, count, ppos, buf, res);
+}
+
+static ssize_t wilc_debug_region_write(struct file *filp, const char *buf, size_t count, loff_t *ppos)
+{
+ char buffer[128] = {};
+ int flag;
+
+ if (copy_from_user(buffer, buf, count)) {
+ return -EFAULT;
+ }
+
+ flag = buffer[0] - '0';
+
+ if (flag > DBG_REGION_ALL) {
+ printk("%s, value (0x%08x) is out of range, stay previous flag (0x%08x)\n", __func__, flag, atomic_read(&REGION));
+ return -EFAULT;
+ }
+
+ atomic_set(&REGION, (int)flag);
+ printk("new debug-region is %x\n", atomic_read(&REGION));
+
+ return count;
+}
+
+/*
+ * --------------------------------------------------------------------------------
+ */
+
+#define FOPS(_open, _read, _write, _poll) { \
+ .owner = THIS_MODULE, \
+ .open = (_open), \
+ .read = (_read), \
+ .write = (_write), \
+ .poll = (_poll), \
+}
+
+struct wilc_debugfs_info_t {
+ const char *name;
+ int perm;
+ unsigned int data;
+ struct file_operations fops;
+};
+
+static struct wilc_debugfs_info_t debugfs_info[] = {
+ { "wilc_debug_level", 0666, (DEBUG | ERR), FOPS(NULL, wilc_debug_level_read, wilc_debug_level_write, NULL), },
+ { "wilc_debug_region", 0666, (INIT_DBG | GENERIC_DBG | CFG80211_DBG), FOPS(NULL, wilc_debug_region_read, wilc_debug_region_write, NULL), },
+};
+
+int wilc_debugfs_init(void)
+{
+ int i;
+
+ struct dentry *debugfs_files;
+ struct wilc_debugfs_info_t *info;
+
+ wilc_dir = debugfs_create_dir("wilc_wifi", NULL);
+ if (wilc_dir == ERR_PTR(-ENODEV)) {
+ /* it's not error. the debugfs is just not being enabled. */
+ printk("ERR, kernel has built without debugfs support\n");
+ return 0;
+ }
+
+ if (!wilc_dir) {
+ printk("ERR, debugfs create dir\n");
+ return -1;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(debugfs_info); i++) {
+ info = &debugfs_info[i];
+ debugfs_files = debugfs_create_file(info->name,
+ info->perm,
+ wilc_dir,
+ &info->data,
+ &info->fops);
+
+ if (!debugfs_files) {
+ printk("ERR fail to create the debugfs file, %s\n", info->name);
+ debugfs_remove_recursive(wilc_dir);
+ return -1;
+ }
+ }
+ return 0;
+}
+
+void wilc_debugfs_remove(void)
+{
+ debugfs_remove_recursive(wilc_dir);
+}
+
+#endif
+
diff --git a/drivers/staging/wilc1000/wilc_errorsupport.h b/drivers/staging/wilc1000/wilc_errorsupport.h
new file mode 100644
index 00000000000000..dd8affabc80d69
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_errorsupport.h
@@ -0,0 +1,67 @@
+#ifndef __WILC_ERRORSUPPORT_H__
+#define __WILC_ERRORSUPPORT_H__
+
+/*!
+ * @file wilc_errorsupport.h
+ * @brief Error reporting and handling support
+ * @author syounan
+ * @sa wilc_oswrapper.h top level OS wrapper file
+ * @date 10 Aug 2010
+ * @version 1.0
+ */
+
+#include "linux_wlan_common.h"
+
+/* Psitive Numbers to indicate sucess with special status */
+#define WILC_ALREADY_EXSIT (+100) /** The requested object already exists */
+
+/* Generic success will return 0 */
+#define WILC_SUCCESS 0 /** Generic success */
+
+/* Negative numbers to indicate failures */
+#define WILC_FAIL -100 /** Generic Fail */
+#define WILC_BUSY -101 /** Busy with another operation*/
+#define WILC_INVALID_ARGUMENT -102 /** A given argument is invalid*/
+#define WILC_INVALID_STATE -103 /** An API request would violate the Driver state machine (i.e. to start PID while not camped)*/
+#define WILC_BUFFER_OVERFLOW -104 /** In copy operations if the copied data is larger than the allocated buffer*/
+#define WILC_NULL_PTR -105 /** null pointer is passed or used */
+#define WILC_EMPTY -107
+#define WILC_FULL -108
+#define WILC_TIMEOUT -109
+#define WILC_CANCELED -110 /** The required operation have been canceled by the user*/
+#define WILC_INVALID_FILE -112 /** The Loaded file is corruped or having an invalid format */
+#define WILC_NOT_FOUND -113 /** Cant find the file to load */
+#define WILC_NO_MEM -114
+#define WILC_UNSUPPORTED_VERSION -115
+#define WILC_FILE_EOF -116
+
+
+/* Error type */
+typedef WILC_Sint32 WILC_ErrNo;
+
+#define WILC_IS_ERR(__status__) (__status__ < WILC_SUCCESS)
+
+#define WILC_ERRORCHECK(__status__) do { \
+ if (WILC_IS_ERR(__status__)) { \
+ PRINT_ER("PRINT_ER(%d)\n", __status__); \
+ goto ERRORHANDLER; \
+ } \
+} while (0)
+
+#define WILC_ERRORREPORT(__status__, __err__) do { \
+ PRINT_ER("PRINT_ER(%d)\n", __err__); \
+ __status__ = __err__; \
+ goto ERRORHANDLER; \
+} while (0)
+
+#define WILC_NULLCHECK(__status__, __ptr__) do { \
+ if (__ptr__ == NULL) { \
+ WILC_ERRORREPORT(__status__, WILC_NULL_PTR); \
+ } \
+} while (0)
+
+#define WILC_CATCH(__status__) \
+ERRORHANDLER: \
+ if (WILC_IS_ERR(__status__)) \
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_exported_buf.c b/drivers/staging/wilc1000/wilc_exported_buf.c
new file mode 100644
index 00000000000000..529457816f655c
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_exported_buf.c
@@ -0,0 +1,76 @@
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+
+#define LINUX_RX_SIZE (96 * 1024)
+#define LINUX_TX_SIZE (64 * 1024)
+#define WILC1000_FW_SIZE (4 * 1024)
+
+#define DECLARE_WILC_BUFFER(name) \
+ void *exported_ ## name = NULL;
+
+#define MALLOC_WILC_BUFFER(name, size) \
+ exported_ ## name = kmalloc(size, GFP_KERNEL); \
+ if (!exported_ ## name) { \
+ printk("fail to alloc: %s memory\n", exported_ ## name); \
+ return -ENOBUFS; \
+ }
+
+#define FREE_WILC_BUFFER(name) \
+ kfree(exported_ ## name);
+
+/*
+ * Add necessary buffer pointers
+ */
+DECLARE_WILC_BUFFER(g_tx_buf)
+DECLARE_WILC_BUFFER(g_rx_buf)
+DECLARE_WILC_BUFFER(g_fw_buf)
+
+void *get_tx_buffer(void)
+{
+ return exported_g_tx_buf;
+}
+EXPORT_SYMBOL(get_tx_buffer);
+
+void *get_rx_buffer(void)
+{
+ return exported_g_rx_buf;
+}
+EXPORT_SYMBOL(get_rx_buffer);
+
+void *get_fw_buffer(void)
+{
+ return exported_g_fw_buf;
+}
+EXPORT_SYMBOL(get_fw_buffer);
+
+static int __init wilc_module_init(void)
+{
+ printk("wilc_module_init\n");
+ /*
+ * alloc necessary memory
+ */
+ MALLOC_WILC_BUFFER(g_tx_buf, LINUX_TX_SIZE)
+ MALLOC_WILC_BUFFER(g_rx_buf, LINUX_RX_SIZE)
+ MALLOC_WILC_BUFFER(g_fw_buf, WILC1000_FW_SIZE)
+
+ return 0;
+}
+
+static void __exit wilc_module_deinit(void)
+{
+ printk("wilc_module_deinit\n");
+ FREE_WILC_BUFFER(g_tx_buf)
+ FREE_WILC_BUFFER(g_rx_buf)
+ FREE_WILC_BUFFER(g_fw_buf)
+
+ return;
+}
+
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_AUTHOR("Tony Cho");
+MODULE_DESCRIPTION("WILC1xxx Memory Manager");
+pure_initcall(wilc_module_init);
+module_exit(wilc_module_deinit); \ No newline at end of file
diff --git a/drivers/staging/wilc1000/wilc_log.h b/drivers/staging/wilc1000/wilc_log.h
new file mode 100644
index 00000000000000..2269ebdec129ca
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_log.h
@@ -0,0 +1,47 @@
+#ifndef __WILC_LOG_H__
+#define __WILC_LOG_H__
+
+/* Errors will always get printed */
+#define WILC_ERROR(...) do { WILC_PRINTF("(ERR)(%s:%d) ", __WILC_FUNCTION__, __WILC_LINE__); \
+ WILC_PRINTF(__VA_ARGS__); \
+ } while (0)
+
+/* Wraning only printed if verbosity is 1 or more */
+#if (WILC_LOG_VERBOSITY_LEVEL > 0)
+#define WILC_WARN(...) do { WILC_PRINTF("(WRN)"); \
+ WILC_PRINTF(__VA_ARGS__); \
+ } while (0)
+#else
+#define WILC_WARN(...) (0)
+#endif
+
+/* Info only printed if verbosity is 2 or more */
+#if (WILC_LOG_VERBOSITY_LEVEL > 1)
+#define WILC_INFO(...) do { WILC_PRINTF("(INF)"); \
+ WILC_PRINTF(__VA_ARGS__); \
+ } while (0)
+#else
+#define WILC_INFO(...) (0)
+#endif
+
+/* Debug is only printed if verbosity is 3 or more */
+#if (WILC_LOG_VERBOSITY_LEVEL > 2)
+#define WILC_DBG(...) do { WILC_PRINTF("(DBG)(%s:%d) ", __WILC_FUNCTION__, __WILC_LINE__); \
+ WILC_PRINTF(__VA_ARGS__); \
+ } while (0)
+
+#else
+#define WILC_DBG(...) (0)
+#endif
+
+/* Function In/Out is only printed if verbosity is 4 or more */
+#if (WILC_LOG_VERBOSITY_LEVEL > 3)
+#define WILC_FN_IN do { WILC_PRINTF("(FIN) (%s:%d) \n", __WILC_FUNCTION__, __WILC_LINE__); } while (0)
+#define WILC_FN_OUT(ret) do { WILC_PRINTF("(FOUT) (%s:%d) %d.\n", __WILC_FUNCTION__, __WILC_LINE__, (ret)); } while (0)
+#else
+#define WILC_FN_IN (0)
+#define WILC_FN_OUT(ret) (0)
+#endif
+
+
+#endif \ No newline at end of file
diff --git a/drivers/staging/wilc1000/wilc_memory.c b/drivers/staging/wilc1000/wilc_memory.c
new file mode 100644
index 00000000000000..f4482752866731
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_memory.c
@@ -0,0 +1,58 @@
+
+#include "wilc_oswrapper.h"
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
+ WILC_Char *pcFileName, WILC_Uint32 u32LineNo)
+{
+ if (u32Size > 0) {
+ return kmalloc(u32Size, GFP_ATOMIC);
+ } else {
+ return NULL;
+ }
+}
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
+ WILC_Char *pcFileName, WILC_Uint32 u32LineNo)
+{
+ return kcalloc(u32Size, 1, GFP_KERNEL);
+}
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize,
+ tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo)
+{
+ if (u32NewSize == 0) {
+ kfree(pvOldBlock);
+ return NULL;
+ } else if (pvOldBlock == NULL) {
+ return kmalloc(u32NewSize, GFP_KERNEL);
+ } else {
+ return krealloc(pvOldBlock, u32NewSize, GFP_KERNEL);
+ }
+
+}
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs,
+ WILC_Char *pcFileName, WILC_Uint32 u32LineNo)
+{
+ kfree(pvBlock);
+}
diff --git a/drivers/staging/wilc1000/wilc_memory.h b/drivers/staging/wilc1000/wilc_memory.h
new file mode 100644
index 00000000000000..6f404ac272a175
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_memory.h
@@ -0,0 +1,237 @@
+#ifndef __WILC_MEMORY_H__
+#define __WILC_MEMORY_H__
+
+/*!
+ * @file wilc_memory.h
+ * @brief Memory OS wrapper functionality
+ * @author syounan
+ * @sa wilc_oswrapper.h top level OS wrapper file
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+
+/*!
+ * @struct tstrWILC_MemoryAttrs
+ * @brief Memory API options
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+typedef struct {
+} tstrWILC_MemoryAttrs;
+
+/*!
+ * @brief Allocates a given size of bytes
+ * @param[in] u32Size size of memory in bytes to be allocated
+ * @param[in] strAttrs Optional attributes, NULL for default
+ * if not NULL, pAllocationPool should point to the pool to use for
+ * this allocation. if NULL memory will be allocated directly from
+ * the system
+ * @param[in] pcFileName file name of the calling code for debugging
+ * @param[in] u32LineNo line number of the calling code for debugging
+ * @return The new allocated block, NULL if allocation fails
+ * @note It is recommended to use of of the wrapper macros instead of
+ * calling this function directly
+ * @sa sttrWILC_MemoryAttrs
+ * @sa WILC_MALLOC
+ * @sa WILC_MALLOC_EX
+ * @sa WILC_NEW
+ * @sa WILC_NEW_EX
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+void *WILC_MemoryAlloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
+ WILC_Char *pcFileName, WILC_Uint32 u32LineNo);
+
+/*!
+ * @brief Allocates a given size of bytes and zero filling it
+ * @param[in] u32Size size of memory in bytes to be allocated
+ * @param[in] strAttrs Optional attributes, NULL for default
+ * if not NULL, pAllocationPool should point to the pool to use for
+ * this allocation. if NULL memory will be allocated directly from
+ * the system
+ * @param[in] pcFileName file name of the calling code for debugging
+ * @param[in] u32LineNo line number of the calling code for debugging
+ * @return The new allocated block, NULL if allocation fails
+ * @note It is recommended to use of of the wrapper macros instead of
+ * calling this function directly
+ * @sa sttrWILC_MemoryAttrs
+ * @sa WILC_CALLOC
+ * @sa WILC_CALLOC_EX
+ * @sa WILC_NEW_0
+ * @sa WILC_NEW_0_EX
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+void *WILC_MemoryCalloc(WILC_Uint32 u32Size, tstrWILC_MemoryAttrs *strAttrs,
+ WILC_Char *pcFileName, WILC_Uint32 u32LineNo);
+
+/*!
+ * @brief Reallocates a given block to a new size
+ * @param[in] pvOldBlock the old memory block, if NULL then this function
+ * behaves as a new allocation function
+ * @param[in] u32NewSize size of the new memory block in bytes, if zero then
+ * this function behaves as a free function
+ * @param[in] strAttrs Optional attributes, NULL for default
+ * if pAllocationPool!=NULL and pvOldBlock==NULL, pAllocationPool
+ * should point to the pool to use for this allocation.
+ * if pAllocationPool==NULL and pvOldBlock==NULL memory will be
+ * allocated directly from the system
+ * if and pvOldBlock!=NULL, pAllocationPool will not be inspected
+ * and reallocation is done from the same pool as the original block
+ * @param[in] pcFileName file name of the calling code for debugging
+ * @param[in] u32LineNo line number of the calling code for debugging
+ * @return The new allocated block, possibly same as pvOldBlock
+ * @note It is recommended to use of of the wrapper macros instead of
+ * calling this function directly
+ * @sa sttrWILC_MemoryAttrs
+ * @sa WILC_REALLOC
+ * @sa WILC_REALLOC_EX
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+void *WILC_MemoryRealloc(void *pvOldBlock, WILC_Uint32 u32NewSize,
+ tstrWILC_MemoryAttrs *strAttrs, WILC_Char *pcFileName, WILC_Uint32 u32LineNo);
+
+/*!
+ * @brief Frees given block
+ * @param[in] pvBlock the memory block to be freed
+ * @param[in] strAttrs Optional attributes, NULL for default
+ * @param[in] pcFileName file name of the calling code for debugging
+ * @param[in] u32LineNo line number of the calling code for debugging
+ * @note It is recommended to use of of the wrapper macros instead of
+ * calling this function directly
+ * @sa sttrWILC_MemoryAttrs
+ * @sa WILC_FREE
+ * @sa WILC_FREE_EX
+ * @sa WILC_FREE_SET_NULL
+ * @sa WILC_FREE_IF_TRUE
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+void WILC_MemoryFree(const void *pvBlock, tstrWILC_MemoryAttrs *strAttrs,
+ WILC_Char *pcFileName, WILC_Uint32 u32LineNo);
+
+/*!
+ * @brief standrad malloc wrapper with custom attributes
+ */
+ #define WILC_MALLOC_EX(__size__, __attrs__) \
+ (WILC_MemoryAlloc( \
+ (__size__), __attrs__, NULL, 0))
+
+/*!
+ * @brief standrad calloc wrapper with custom attributes
+ */
+ #define WILC_CALLOC_EX(__size__, __attrs__) \
+ (WILC_MemoryCalloc( \
+ (__size__), __attrs__, NULL, 0))
+
+/*!
+ * @brief standrad realloc wrapper with custom attributes
+ */
+ #define WILC_REALLOC_EX(__ptr__, __new_size__, __attrs__) \
+ (WILC_MemoryRealloc( \
+ (__ptr__), (__new_size__), __attrs__, NULL, 0))
+/*!
+ * @brief standrad free wrapper with custom attributes
+ */
+ #define WILC_FREE_EX(__ptr__, __attrs__) \
+ (WILC_MemoryFree( \
+ (__ptr__), __attrs__, NULL, 0))
+
+/*!
+ * @brief Allocates a block (with custom attributes) of given type and number of
+ * elements
+ */
+#define WILC_NEW_EX(__struct_type__, __n_structs__, __attrs__) \
+ ((__struct_type__ *)WILC_MALLOC_EX( \
+ sizeof(__struct_type__) * (WILC_Uint32)(__n_structs__), __attrs__))
+
+/*!
+ * @brief Allocates a block (with custom attributes) of given type and number of
+ * elements and Zero-fills it
+ */
+#define WILC_NEW_0_EX(__struct_type__, __n_structs__, __attrs__) \
+ ((__struct_type__ *)WILC_CALLOC_EX( \
+ sizeof(__struct_type__) * (WILC_Uint32)(__n_structs__), __attrs__))
+
+/*!
+ * @brief Frees a block (with custom attributes), also setting the original pointer
+ * to NULL
+ */
+#define WILC_FREE_SET_NULL_EX(__ptr__, __attrs__) do { \
+ if (__ptr__ != NULL) { \
+ WILC_FREE_EX(__ptr__, __attrs__); \
+ __ptr__ = NULL; \
+ } \
+} while (0)
+
+/*!
+ * @brief Frees a block (with custom attributes) if the pointer expression evaluates
+ * to true
+ */
+#define WILC_FREE_IF_TRUE_EX(__ptr__, __attrs__) do { \
+ if (__ptr__ != NULL) { \
+ WILC_FREE_EX(__ptr__, __attrs__); \
+ } \
+} while (0)
+
+/*!
+ * @brief standrad malloc wrapper with default attributes
+ */
+#define WILC_MALLOC(__size__) \
+ WILC_MALLOC_EX(__size__, NULL)
+
+/*!
+ * @brief standrad calloc wrapper with default attributes
+ */
+#define WILC_CALLOC(__size__) \
+ WILC_CALLOC_EX(__size__, NULL)
+
+/*!
+ * @brief standrad realloc wrapper with default attributes
+ */
+#define WILC_REALLOC(__ptr__, __new_size__) \
+ WILC_REALLOC_EX(__ptr__, __new_size__, NULL)
+
+/*!
+ * @brief standrad free wrapper with default attributes
+ */
+#define WILC_FREE(__ptr__) \
+ WILC_FREE_EX(__ptr__, NULL)
+
+/*!
+ * @brief Allocates a block (with default attributes) of given type and number of
+ * elements
+ */
+#define WILC_NEW(__struct_type__, __n_structs__) \
+ WILC_NEW_EX(__struct_type__, __n_structs__, NULL)
+
+/*!
+ * @brief Allocates a block (with default attributes) of given type and number of
+ * elements and Zero-fills it
+ */
+#define WILC_NEW_0(__struct_type__, __n_structs__) \
+ WILC_NEW_O_EX(__struct_type__, __n_structs__, NULL)
+
+/*!
+ * @brief Frees a block (with default attributes), also setting the original pointer
+ * to NULL
+ */
+#define WILC_FREE_SET_NULL(__ptr__) \
+ WILC_FREE_SET_NULL_EX(__ptr__, NULL)
+
+/*!
+ * @brief Frees a block (with default attributes) if the pointer expression evaluates
+ * to true
+ */
+#define WILC_FREE_IF_TRUE(__ptr__) \
+ WILC_FREE_IF_TRUE_EX(__ptr__, NULL)
+
+
+#endif
+
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.c b/drivers/staging/wilc1000/wilc_msgqueue.c
new file mode 100644
index 00000000000000..ebbba8b24de0b3
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_msgqueue.c
@@ -0,0 +1,190 @@
+
+#include "wilc_oswrapper.h"
+#include <linux/spinlock.h>
+
+/*!
+ * @author syounan
+ * @date 1 Sep 2010
+ * @note copied from FLO glue implementatuion
+ * @version 1.0
+ */
+WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle,
+ tstrWILC_MsgQueueAttrs *pstrAttrs)
+{
+ spin_lock_init(&pHandle->strCriticalSection);
+ sema_init(&pHandle->hSem, 0);
+ pHandle->pstrMessageList = NULL;
+ pHandle->u32ReceiversCount = 0;
+ pHandle->bExiting = WILC_FALSE;
+ return WILC_SUCCESS;
+}
+
+/*!
+ * @author syounan
+ * @date 1 Sep 2010
+ * @note copied from FLO glue implementatuion
+ * @version 1.0
+ */
+WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle,
+ tstrWILC_MsgQueueAttrs *pstrAttrs)
+{
+
+ pHandle->bExiting = WILC_TRUE;
+
+ /* Release any waiting receiver thread. */
+ while (pHandle->u32ReceiversCount > 0) {
+ up(&(pHandle->hSem));
+ pHandle->u32ReceiversCount--;
+ }
+
+ while (pHandle->pstrMessageList != NULL) {
+ Message *pstrMessge = pHandle->pstrMessageList->pstrNext;
+ WILC_FREE(pHandle->pstrMessageList);
+ pHandle->pstrMessageList = pstrMessge;
+ }
+
+ return WILC_SUCCESS;
+}
+
+/*!
+ * @author syounan
+ * @date 1 Sep 2010
+ * @note copied from FLO glue implementatuion
+ * @version 1.0
+ */
+WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle,
+ const void *pvSendBuffer, WILC_Uint32 u32SendBufferSize,
+ tstrWILC_MsgQueueAttrs *pstrAttrs)
+{
+ WILC_ErrNo s32RetStatus = WILC_SUCCESS;
+ unsigned long flags;
+ Message *pstrMessage = NULL;
+
+ if ((pHandle == NULL) || (u32SendBufferSize == 0) || (pvSendBuffer == NULL)) {
+ WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT);
+ }
+
+ if (pHandle->bExiting == WILC_TRUE) {
+ WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
+ }
+
+ spin_lock_irqsave(&pHandle->strCriticalSection, flags);
+
+ /* construct a new message */
+ pstrMessage = WILC_NEW(Message, 1);
+ WILC_NULLCHECK(s32RetStatus, pstrMessage);
+ pstrMessage->u32Length = u32SendBufferSize;
+ pstrMessage->pstrNext = NULL;
+ pstrMessage->pvBuffer = WILC_MALLOC(u32SendBufferSize);
+ WILC_NULLCHECK(s32RetStatus, pstrMessage->pvBuffer);
+ WILC_memcpy(pstrMessage->pvBuffer, pvSendBuffer, u32SendBufferSize);
+
+
+ /* add it to the message queue */
+ if (pHandle->pstrMessageList == NULL) {
+ pHandle->pstrMessageList = pstrMessage;
+ } else {
+ Message *pstrTailMsg = pHandle->pstrMessageList;
+ while (pstrTailMsg->pstrNext != NULL) {
+ pstrTailMsg = pstrTailMsg->pstrNext;
+ }
+ pstrTailMsg->pstrNext = pstrMessage;
+ }
+
+ spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+
+ up(&pHandle->hSem);
+
+ WILC_CATCH(s32RetStatus)
+ {
+ /* error occured, free any allocations */
+ if (pstrMessage != NULL) {
+ if (pstrMessage->pvBuffer != NULL) {
+ WILC_FREE(pstrMessage->pvBuffer);
+ }
+ WILC_FREE(pstrMessage);
+ }
+ }
+
+ return s32RetStatus;
+}
+
+
+
+/*!
+ * @author syounan
+ * @date 1 Sep 2010
+ * @note copied from FLO glue implementatuion
+ * @version 1.0
+ */
+WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle,
+ void *pvRecvBuffer, WILC_Uint32 u32RecvBufferSize,
+ WILC_Uint32 *pu32ReceivedLength,
+ tstrWILC_MsgQueueAttrs *pstrAttrs)
+{
+
+ Message *pstrMessage;
+ WILC_ErrNo s32RetStatus = WILC_SUCCESS;
+ unsigned long flags;
+ if ((pHandle == NULL) || (u32RecvBufferSize == 0)
+ || (pvRecvBuffer == NULL) || (pu32ReceivedLength == NULL)) {
+ WILC_ERRORREPORT(s32RetStatus, WILC_INVALID_ARGUMENT);
+ }
+
+ if (pHandle->bExiting == WILC_TRUE) {
+ WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
+ }
+
+ spin_lock_irqsave(&pHandle->strCriticalSection, flags);
+ pHandle->u32ReceiversCount++;
+ spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+
+ down(&(pHandle->hSem));
+
+ if (s32RetStatus == WILC_TIMEOUT) {
+ /* timed out, just exit without consumeing the message */
+ spin_lock_irqsave(&pHandle->strCriticalSection, flags);
+ pHandle->u32ReceiversCount--;
+ spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+ } else {
+ /* other non-timeout scenarios */
+ WILC_ERRORCHECK(s32RetStatus);
+
+ if (pHandle->bExiting) {
+ WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
+ }
+
+ spin_lock_irqsave(&pHandle->strCriticalSection, flags);
+
+ pstrMessage = pHandle->pstrMessageList;
+ if (pstrMessage == NULL) {
+ spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+ WILC_ERRORREPORT(s32RetStatus, WILC_FAIL);
+ }
+ /* check buffer size */
+ if (u32RecvBufferSize < pstrMessage->u32Length) {
+ spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+ up(&pHandle->hSem);
+ WILC_ERRORREPORT(s32RetStatus, WILC_BUFFER_OVERFLOW);
+ }
+
+ /* consume the message */
+ pHandle->u32ReceiversCount--;
+ WILC_memcpy(pvRecvBuffer, pstrMessage->pvBuffer, pstrMessage->u32Length);
+ *pu32ReceivedLength = pstrMessage->u32Length;
+
+ pHandle->pstrMessageList = pstrMessage->pstrNext;
+
+ WILC_FREE(pstrMessage->pvBuffer);
+ WILC_FREE(pstrMessage);
+
+ spin_unlock_irqrestore(&pHandle->strCriticalSection, flags);
+
+ }
+
+ WILC_CATCH(s32RetStatus)
+ {
+ }
+
+ return s32RetStatus;
+}
diff --git a/drivers/staging/wilc1000/wilc_msgqueue.h b/drivers/staging/wilc1000/wilc_msgqueue.h
new file mode 100644
index 00000000000000..d7e4b1ce349765
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_msgqueue.h
@@ -0,0 +1,103 @@
+#ifndef __WILC_MSG_QUEUE_H__
+#define __WILC_MSG_QUEUE_H__
+
+/*!
+ * @file wilc_msgqueue.h
+ * @brief Message Queue OS wrapper functionality
+ * @author syounan
+ * @sa wilc_oswrapper.h top level OS wrapper file
+ * @date 30 Aug 2010
+ * @version 1.0
+ */
+
+/*!
+ * @struct tstrWILC_MsgQueueAttrs
+ * @brief Message Queue API options
+ * @author syounan
+ * @date 30 Aug 2010
+ * @version 1.0
+ */
+typedef struct {
+ /* a dummy member to avoid compiler errors*/
+ u8 dummy;
+
+} tstrWILC_MsgQueueAttrs;
+
+/*!
+ * @brief Creates a new Message queue
+ * @details Creates a new Message queue, if the feature
+ * CONFIG_WILC_MSG_QUEUE_IPC_NAME is enabled and pstrAttrs->pcName
+ * is not Null, then this message queue can be used for IPC with
+ * any other message queue having the same name in the system
+ * @param[in,out] pHandle handle to the message queue object
+ * @param[in] pstrAttrs Optional attributes, NULL for default
+ * @return Error code indicating sucess/failure
+ * @sa tstrWILC_MsgQueueAttrs
+ * @author syounan
+ * @date 30 Aug 2010
+ * @version 1.0
+ */
+WILC_ErrNo WILC_MsgQueueCreate(WILC_MsgQueueHandle *pHandle,
+ tstrWILC_MsgQueueAttrs *pstrAttrs);
+
+
+/*!
+ * @brief Sends a message
+ * @details Sends a message, this API will block unil the message is
+ * actually sent or until it is timedout (as long as the feature
+ * CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout
+ * is not set to WILC_OS_INFINITY), zero timeout is a valid value
+ * @param[in] pHandle handle to the message queue object
+ * @param[in] pvSendBuffer pointer to the data to send
+ * @param[in] u32SendBufferSize the size of the data to send
+ * @param[in] pstrAttrs Optional attributes, NULL for default
+ * @return Error code indicating sucess/failure
+ * @sa tstrWILC_MsgQueueAttrs
+ * @author syounan
+ * @date 30 Aug 2010
+ * @version 1.0
+ */
+WILC_ErrNo WILC_MsgQueueSend(WILC_MsgQueueHandle *pHandle,
+ const void *pvSendBuffer, WILC_Uint32 u32SendBufferSize,
+ tstrWILC_MsgQueueAttrs *pstrAttrs);
+
+
+/*!
+ * @brief Receives a message
+ * @details Receives a message, this API will block unil a message is
+ * received or until it is timedout (as long as the feature
+ * CONFIG_WILC_MSG_QUEUE_TIMEOUT is enabled and pstrAttrs->u32Timeout
+ * is not set to WILC_OS_INFINITY), zero timeout is a valid value
+ * @param[in] pHandle handle to the message queue object
+ * @param[out] pvRecvBuffer pointer to a buffer to fill with the received message
+ * @param[in] u32RecvBufferSize the size of the receive buffer
+ * @param[out] pu32ReceivedLength the length of received data
+ * @param[in] pstrAttrs Optional attributes, NULL for default
+ * @return Error code indicating sucess/failure
+ * @sa tstrWILC_MsgQueueAttrs
+ * @author syounan
+ * @date 30 Aug 2010
+ * @version 1.0
+ */
+WILC_ErrNo WILC_MsgQueueRecv(WILC_MsgQueueHandle *pHandle,
+ void *pvRecvBuffer, WILC_Uint32 u32RecvBufferSize,
+ WILC_Uint32 *pu32ReceivedLength,
+ tstrWILC_MsgQueueAttrs *pstrAttrs);
+
+
+/*!
+ * @brief Destroys an existing Message queue
+ * @param[in] pHandle handle to the message queue object
+ * @param[in] pstrAttrs Optional attributes, NULL for default
+ * @return Error code indicating sucess/failure
+ * @sa tstrWILC_MsgQueueAttrs
+ * @author syounan
+ * @date 30 Aug 2010
+ * @version 1.0
+ */
+WILC_ErrNo WILC_MsgQueueDestroy(WILC_MsgQueueHandle *pHandle,
+ tstrWILC_MsgQueueAttrs *pstrAttrs);
+
+
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_osconfig.h b/drivers/staging/wilc1000/wilc_osconfig.h
new file mode 100644
index 00000000000000..f9c25140393ef0
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_osconfig.h
@@ -0,0 +1,9 @@
+/* Logs options */
+#define WILC_LOGS_NOTHING 0
+#define WILC_LOGS_WARN 1
+#define WILC_LOGS_WARN_INFO 2
+#define WILC_LOGS_WARN_INFO_DBG 3
+#define WILC_LOGS_WARN_INFO_DBG_FN 4
+#define WILC_LOGS_ALL 5
+
+#define WILC_LOG_VERBOSITY_LEVEL WILC_LOGS_ALL
diff --git a/drivers/staging/wilc1000/wilc_oswrapper.h b/drivers/staging/wilc1000/wilc_oswrapper.h
new file mode 100644
index 00000000000000..4b4cfa202043ff
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_oswrapper.h
@@ -0,0 +1,59 @@
+#ifndef __WILC_OSWRAPPER_H__
+#define __WILC_OSWRAPPER_H__
+
+/*!
+ * @file wilc_oswrapper.h
+ * @brief Top level OS Wrapper, include this file and it will include all
+ * other files as necessary
+ * @author syounan
+ * @date 10 Aug 2010
+ * @version 1.0
+ */
+
+/* OS Wrapper interface version */
+#define WILC_OSW_INTERFACE_VER 2
+
+/* Integer Types */
+typedef unsigned short WILC_Uint16;
+typedef unsigned int WILC_Uint32;
+typedef unsigned long long WILC_Uint64;
+typedef signed char WILC_Sint8;
+typedef signed short WILC_Sint16;
+typedef signed int WILC_Sint32;
+typedef signed long long WILC_Sint64;
+
+/* Boolean type */
+typedef enum {
+ WILC_FALSE = 0,
+ WILC_TRUE = 1
+} WILC_Bool;
+
+/* Character types */
+typedef char WILC_Char;
+
+/* Os Configuration File */
+#include "wilc_osconfig.h"
+#include "wilc_platform.h"
+
+/* Logging Functions */
+#include "wilc_log.h"
+
+/* Error reporting and handling support */
+#include "wilc_errorsupport.h"
+
+/* Sleep support */
+#include "wilc_sleep.h"
+
+/* Timer support */
+#include "wilc_timer.h"
+
+/* Memory support */
+#include "wilc_memory.h"
+
+/* String Utilities */
+#include "wilc_strutils.h"
+
+/* Message Queue */
+#include "wilc_msgqueue.h"
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_platform.h b/drivers/staging/wilc1000/wilc_platform.h
new file mode 100644
index 00000000000000..ae42bbcbd5eb02
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_platform.h
@@ -0,0 +1,52 @@
+#ifndef __WILC_platfrom_H__
+#define __WILC_platfrom_H__
+
+#include <linux/kthread.h>
+#include <linux/semaphore.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <linux/kernel.h>
+#include <linux/delay.h>
+#include <linux/types.h>
+#include <linux/stat.h>
+#include <linux/time.h>
+#include <linux/version.h>
+#include "linux/string.h"
+/******************************************************************
+ * OS specific types
+ *******************************************************************/
+
+typedef struct timer_list WILC_TimerHandle;
+
+
+
+/* Message Queue type is a structure */
+typedef struct __Message_struct {
+ void *pvBuffer;
+ WILC_Uint32 u32Length;
+ struct __Message_struct *pstrNext;
+} Message;
+
+typedef struct __MessageQueue_struct {
+ struct semaphore hSem;
+ spinlock_t strCriticalSection;
+ WILC_Bool bExiting;
+ WILC_Uint32 u32ReceiversCount;
+ Message *pstrMessageList;
+} WILC_MsgQueueHandle;
+
+
+
+/*Time represented in 64 bit format*/
+typedef time_t WILC_Time;
+
+
+/*******************************************************************
+ * others
+ ********************************************************************/
+
+/* Generic printf function */
+#define __WILC_FILE__ __FILE__
+#define __WILC_FUNCTION__ __FUNCTION__
+#define __WILC_LINE__ __LINE__
+#endif
diff --git a/drivers/staging/wilc1000/wilc_sdio.c b/drivers/staging/wilc1000/wilc_sdio.c
new file mode 100644
index 00000000000000..d96abb05a83e05
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_sdio.c
@@ -0,0 +1,1298 @@
+/* ////////////////////////////////////////////////////////////////////////// */
+/* */
+/* Copyright (c) Atmel Corporation. All rights reserved. */
+/* */
+/* Module Name: wilc_sdio.c */
+/* */
+/* */
+/* //////////////////////////////////////////////////////////////////////////// */
+
+#include "wilc_wlan_if.h"
+#include "wilc_wlan.h"
+
+
+#ifdef WILC1000_SINGLE_TRANSFER
+#define WILC_SDIO_BLOCK_SIZE 256
+#else
+ #if defined(PLAT_AML8726_M3) /* johnny */
+ #define WILC_SDIO_BLOCK_SIZE 512
+ #define MAX_SEG_SIZE (1 << 12) /* 4096 */
+ #else
+ #define WILC_SDIO_BLOCK_SIZE 512
+ #endif
+#endif
+
+typedef struct {
+ void *os_context;
+ wilc_wlan_os_func_t os_func;
+ uint32_t block_size;
+ int (*sdio_cmd52)(sdio_cmd52_t *);
+ int (*sdio_cmd53)(sdio_cmd53_t *);
+ int (*sdio_set_max_speed)(void);
+ int (*sdio_set_default_speed)(void);
+ wilc_debug_func dPrint;
+ int nint;
+#define MAX_NUN_INT_THRPT_ENH2 (5) /* Max num interrupts allowed in registers 0xf7, 0xf8 */
+ int has_thrpt_enh3;
+} wilc_sdio_t;
+
+static wilc_sdio_t g_sdio;
+
+#ifdef WILC_SDIO_IRQ_GPIO
+static int sdio_write_reg(uint32_t addr, uint32_t data);
+static int sdio_read_reg(uint32_t addr, uint32_t *data);
+#endif
+extern unsigned int int_clrd;
+
+/********************************************
+ *
+ * Function 0
+ *
+ ********************************************/
+
+static int sdio_set_func0_csa_address(uint32_t adr)
+{
+ sdio_cmd52_t cmd;
+
+ /**
+ * Review: BIG ENDIAN
+ **/
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0x10c;
+ cmd.data = (uint8_t)adr;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10c data...\n");
+ goto _fail_;
+ }
+
+ cmd.address = 0x10d;
+ cmd.data = (uint8_t)(adr >> 8);
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10d data...\n");
+ goto _fail_;
+ }
+
+ cmd.address = 0x10e;
+ cmd.data = (uint8_t)(adr >> 16);
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10e data...\n");
+ goto _fail_;
+ }
+
+ return 1;
+_fail_:
+ return 0;
+}
+
+static int sdio_set_func0_csa_address_byte0(uint32_t adr)
+{
+ sdio_cmd52_t cmd;
+
+
+ /**
+ * Review: BIG ENDIAN
+ **/
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0x10c;
+ cmd.data = (uint8_t)adr;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10c data...\n");
+ goto _fail_;
+ }
+
+ return 1;
+_fail_:
+ return 0;
+}
+static int sdio_set_func0_block_size(uint32_t block_size)
+{
+ sdio_cmd52_t cmd;
+
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0x10;
+ cmd.data = (uint8_t)block_size;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x10 data...\n");
+ goto _fail_;
+ }
+
+ cmd.address = 0x11;
+ cmd.data = (uint8_t)(block_size >> 8);
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x11 data...\n");
+ goto _fail_;
+ }
+
+ return 1;
+_fail_:
+ return 0;
+}
+
+/********************************************
+ *
+ * Function 1
+ *
+ ********************************************/
+
+static int sdio_set_func1_block_size(uint32_t block_size)
+{
+ sdio_cmd52_t cmd;
+
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0x110;
+ cmd.data = (uint8_t)block_size;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x110 data...\n");
+ goto _fail_;
+ }
+ cmd.address = 0x111;
+ cmd.data = (uint8_t)(block_size >> 8);
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0x111 data...\n");
+ goto _fail_;
+ }
+
+ return 1;
+_fail_:
+ return 0;
+}
+
+static int sdio_clear_int(void)
+{
+#ifndef WILC_SDIO_IRQ_GPIO
+ /* uint32_t sts; */
+ sdio_cmd52_t cmd;
+ cmd.read_write = 0;
+ cmd.function = 1;
+ cmd.raw = 0;
+ cmd.address = 0x4;
+ cmd.data = 0;
+ g_sdio.sdio_cmd52(&cmd);
+ int_clrd++;
+
+ return cmd.data;
+#else
+ uint32_t reg;
+ if (!sdio_read_reg(WILC_HOST_RX_CTRL_0, &reg)) {
+ g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_HOST_RX_CTRL_0);
+ return 0;
+ }
+ reg &= ~0x1;
+ sdio_write_reg(WILC_HOST_RX_CTRL_0, reg);
+ int_clrd++;
+ return 1;
+#endif
+
+}
+
+uint32_t sdio_xfer_cnt(void)
+{
+ uint32_t cnt = 0;
+ sdio_cmd52_t cmd;
+ cmd.read_write = 0;
+ cmd.function = 1;
+ cmd.raw = 0;
+ cmd.address = 0x1C;
+ cmd.data = 0;
+ g_sdio.sdio_cmd52(&cmd);
+ cnt = cmd.data;
+
+ cmd.read_write = 0;
+ cmd.function = 1;
+ cmd.raw = 0;
+ cmd.address = 0x1D;
+ cmd.data = 0;
+ g_sdio.sdio_cmd52(&cmd);
+ cnt |= (cmd.data << 8);
+
+ cmd.read_write = 0;
+ cmd.function = 1;
+ cmd.raw = 0;
+ cmd.address = 0x1E;
+ cmd.data = 0;
+ g_sdio.sdio_cmd52(&cmd);
+ cnt |= (cmd.data << 16);
+
+ return cnt;
+
+
+}
+
+/********************************************
+ *
+ * Sdio interfaces
+ *
+ ********************************************/
+int sdio_check_bs(void)
+{
+ sdio_cmd52_t cmd;
+
+ /**
+ * poll until BS is 0
+ **/
+ cmd.read_write = 0;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0xc;
+ cmd.data = 0;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, get BS register...\n");
+ goto _fail_;
+ }
+
+ return 1;
+
+_fail_:
+
+ return 0;
+}
+
+static int sdio_write_reg(uint32_t addr, uint32_t data)
+{
+#ifdef BIG_ENDIAN
+ data = BYTE_SWAP(data);
+#endif
+
+ if ((addr >= 0xf0) && (addr <= 0xff)) {
+ sdio_cmd52_t cmd;
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = addr;
+ cmd.data = data;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd 52, read reg (%08x) ...\n", addr);
+ goto _fail_;
+ }
+ } else {
+ sdio_cmd53_t cmd;
+
+ /**
+ * set the AHB address
+ **/
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.address = 0x10f;
+ cmd.block_mode = 0;
+ cmd.increment = 1;
+ cmd.count = 4;
+ cmd.buffer = (uint8_t *)&data;
+ cmd.block_size = g_sdio.block_size; /* johnny : prevent it from setting unexpected value */
+
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53, write reg (%08x)...\n", addr);
+ goto _fail_;
+ }
+
+#if 0
+ if (!sdio_check_bs())
+ goto _fail_;
+#else
+ /* g_sdio.os_func.os_sleep(1); */
+#endif
+ }
+
+ return 1;
+
+_fail_:
+
+ return 0;
+}
+
+static int sdio_write(uint32_t addr, uint8_t *buf, uint32_t size)
+{
+ uint32_t block_size = g_sdio.block_size;
+ sdio_cmd53_t cmd;
+ int nblk, nleft;
+
+ cmd.read_write = 1;
+ if (addr > 0) {
+ /**
+ * has to be word aligned...
+ **/
+ if (size & 0x3) {
+ size += 4;
+ size &= ~0x3;
+ }
+
+ /**
+ * func 0 access
+ **/
+ cmd.function = 0;
+ cmd.address = 0x10f;
+ } else {
+#ifdef WILC1000_SINGLE_TRANSFER
+ /**
+ * has to be block aligned...
+ **/
+ nleft = size % block_size;
+ if (nleft > 0) {
+ size += block_size;
+ size &= ~(block_size - 1);
+ }
+#else
+ /**
+ * has to be word aligned...
+ **/
+ if (size & 0x3) {
+ size += 4;
+ size &= ~0x3;
+ }
+#endif
+
+ /**
+ * func 1 access
+ **/
+ cmd.function = 1;
+ cmd.address = 0;
+ }
+
+ nblk = size / block_size;
+ nleft = size % block_size;
+
+ if (nblk > 0) {
+
+#if defined(PLAT_AML8726_M3_BACKUP) /* johnny */
+ int i;
+
+ for (i = 0; i < nblk; i++) {
+ cmd.block_mode = 0; /* 1; */
+ cmd.increment = 1;
+ cmd.count = block_size; /* nblk; */
+ cmd.buffer = buf;
+ cmd.block_size = block_size;
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block send...\n", addr);
+ goto _fail_;
+ }
+
+ if (addr > 0)
+ addr += block_size; /* addr += nblk*block_size; */
+
+ buf += block_size; /* buf += nblk*block_size; */
+ }
+
+#elif defined(PLAT_AML8726_M3) /* johnny */
+
+ int i;
+ int rest;
+ int seg_cnt;
+
+ seg_cnt = (nblk * block_size) / MAX_SEG_SIZE;
+ rest = (nblk * block_size) & (MAX_SEG_SIZE - 1);
+
+ for (i = 0; i < seg_cnt; i++) {
+ cmd.block_mode = 1;
+ cmd.increment = 1;
+ cmd.count = MAX_SEG_SIZE / block_size;
+ cmd.buffer = buf;
+ cmd.block_size = block_size;
+
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block send...\n", addr);
+ goto _fail_;
+ }
+
+ if (addr > 0)
+ addr += MAX_SEG_SIZE;
+
+ buf += MAX_SEG_SIZE;
+
+ }
+
+
+ if (rest > 0) {
+ cmd.block_mode = 1;
+ cmd.increment = 1;
+ cmd.count = rest / block_size;
+ cmd.buffer = buf;
+ cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */
+
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], bytes send...\n", addr);
+ goto _fail_;
+ }
+
+ if (addr > 0)
+ addr += rest;
+
+ buf += rest;
+
+ }
+
+#else
+
+ cmd.block_mode = 1;
+ cmd.increment = 1;
+ cmd.count = nblk;
+ cmd.buffer = buf;
+ cmd.block_size = block_size;
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block send...\n", addr);
+ goto _fail_;
+ }
+ if (addr > 0)
+ addr += nblk * block_size;
+ buf += nblk * block_size;
+
+#endif /* platform */
+
+#if 0
+ if (!sdio_check_bs())
+ goto _fail_;
+#else
+ /* g_sdio.os_func.os_sleep(1); */
+#endif
+
+ }
+
+
+ if (nleft > 0) {
+ cmd.block_mode = 0;
+ cmd.increment = 1;
+ cmd.count = nleft;
+ cmd.buffer = buf;
+
+ cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */
+
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], bytes send...\n", addr);
+ goto _fail_;
+ }
+
+#if 0
+ if (!sdio_check_bs())
+ goto _fail_;
+#else
+ /* g_sdio.os_func.os_sleep(1); */
+#endif
+ }
+
+ return 1;
+
+_fail_:
+
+ return 0;
+}
+
+static int sdio_read_reg(uint32_t addr, uint32_t *data)
+{
+ if ((addr >= 0xf0) && (addr <= 0xff)) {
+ sdio_cmd52_t cmd;
+ cmd.read_write = 0;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = addr;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd 52, read reg (%08x) ...\n", addr);
+ goto _fail_;
+ }
+ *data = cmd.data;
+ } else {
+ sdio_cmd53_t cmd;
+
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+
+ cmd.read_write = 0;
+ cmd.function = 0;
+ cmd.address = 0x10f;
+ cmd.block_mode = 0;
+ cmd.increment = 1;
+ cmd.count = 4;
+ cmd.buffer = (uint8_t *)data;
+
+ cmd.block_size = g_sdio.block_size; /* johnny : prevent it from setting unexpected value */
+
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53, read reg (%08x)...\n", addr);
+ goto _fail_;
+ }
+
+#if 0
+ if (!sdio_check_bs())
+ goto _fail_;
+#else
+ /* g_sdio.os_func.os_sleep(1); */
+#endif
+ }
+
+#ifdef BIG_ENDIAN
+ *data = BYTE_SWAP(*data);
+#endif
+
+ return 1;
+
+_fail_:
+
+ return 0;
+}
+
+static int sdio_read(uint32_t addr, uint8_t *buf, uint32_t size)
+{
+ uint32_t block_size = g_sdio.block_size;
+ sdio_cmd53_t cmd;
+ int nblk, nleft;
+
+ cmd.read_write = 0;
+ if (addr > 0) {
+ /**
+ * has to be word aligned...
+ **/
+ if (size & 0x3) {
+ size += 4;
+ size &= ~0x3;
+ }
+
+ /**
+ * func 0 access
+ **/
+ cmd.function = 0;
+ cmd.address = 0x10f;
+ } else {
+#ifdef WILC1000_SINGLE_TRANSFER
+ /**
+ * has to be block aligned...
+ **/
+ nleft = size % block_size;
+ if (nleft > 0) {
+ size += block_size;
+ size &= ~(block_size - 1);
+ }
+#else
+ /**
+ * has to be word aligned...
+ **/
+ if (size & 0x3) {
+ size += 4;
+ size &= ~0x3;
+ }
+#endif
+
+ /**
+ * func 1 access
+ **/
+ cmd.function = 1;
+ cmd.address = 0;
+ }
+
+ nblk = size / block_size;
+ nleft = size % block_size;
+
+ if (nblk > 0) {
+
+#if defined(PLAT_AML8726_M3_BACKUP) /* johnny */
+
+ int i;
+
+ for (i = 0; i < nblk; i++) {
+ cmd.block_mode = 0; /* 1; */
+ cmd.increment = 1;
+ cmd.count = block_size; /* nblk; */
+ cmd.buffer = buf;
+ cmd.block_size = block_size;
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr);
+ goto _fail_;
+ }
+ if (addr > 0)
+ addr += block_size; /* addr += nblk*block_size; */
+ buf += block_size; /* buf += nblk*block_size; */
+ }
+
+#elif defined(PLAT_AML8726_M3) /* johnny */
+
+ int i;
+ int rest;
+ int seg_cnt;
+
+ seg_cnt = (nblk * block_size) / MAX_SEG_SIZE;
+ rest = (nblk * block_size) & (MAX_SEG_SIZE - 1);
+
+ for (i = 0; i < seg_cnt; i++) {
+ cmd.block_mode = 1;
+ cmd.increment = 1;
+ cmd.count = MAX_SEG_SIZE / block_size;
+ cmd.buffer = buf;
+ cmd.block_size = block_size;
+
+
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr);
+ goto _fail_;
+ }
+
+ if (addr > 0)
+ addr += MAX_SEG_SIZE;
+
+ buf += MAX_SEG_SIZE;
+
+ }
+
+
+ if (rest > 0) {
+ cmd.block_mode = 1;
+ cmd.increment = 1;
+ cmd.count = rest / block_size;
+ cmd.buffer = buf;
+ cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */
+
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr);
+ goto _fail_;
+ }
+
+ if (addr > 0)
+ addr += rest;
+
+ buf += rest;
+
+ }
+
+#else
+
+ cmd.block_mode = 1;
+ cmd.increment = 1;
+ cmd.count = nblk;
+ cmd.buffer = buf;
+ cmd.block_size = block_size;
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], block read...\n", addr);
+ goto _fail_;
+ }
+ if (addr > 0)
+ addr += nblk * block_size;
+ buf += nblk * block_size;
+
+#endif /* platform */
+
+#if 0
+ if (!sdio_check_bs())
+ goto _fail_;
+#else
+ /* g_sdio.os_func.os_sleep(1); */
+#endif
+
+ } /* if (nblk > 0) */
+
+ if (nleft > 0) {
+ cmd.block_mode = 0;
+ cmd.increment = 1;
+ cmd.count = nleft;
+ cmd.buffer = buf;
+
+ cmd.block_size = block_size; /* johnny : prevent it from setting unexpected value */
+
+ if (addr > 0) {
+ if (!sdio_set_func0_csa_address(addr))
+ goto _fail_;
+ }
+ if (!g_sdio.sdio_cmd53(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd53 [%x], bytes read...\n", addr);
+ goto _fail_;
+ }
+
+#if 0
+ if (!sdio_check_bs())
+ goto _fail_;
+#else
+ /* g_sdio.os_func.os_sleep(1); */
+#endif
+ }
+
+ return 1;
+
+_fail_:
+
+ return 0;
+}
+
+/********************************************
+ *
+ * Bus interfaces
+ *
+ ********************************************/
+
+static int sdio_deinit(void *pv)
+{
+ return 1;
+}
+
+static int sdio_sync(void)
+{
+ uint32_t reg;
+
+ /**
+ * Disable power sequencer
+ **/
+ if (!sdio_read_reg(WILC_MISC, &reg)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read misc reg...\n");
+ return 0;
+ }
+
+ reg &= ~(1 << 8);
+ if (!sdio_write_reg(WILC_MISC, reg)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write misc reg...\n");
+ return 0;
+ }
+
+#ifdef WILC_SDIO_IRQ_GPIO
+ {
+ uint32_t reg;
+ int ret;
+
+ /**
+ * interrupt pin mux select
+ **/
+ ret = sdio_read_reg(WILC_PIN_MUX_0, &reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0);
+ return 0;
+ }
+ reg |= (1 << 8);
+ ret = sdio_write_reg(WILC_PIN_MUX_0, reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0);
+ return 0;
+ }
+
+ /**
+ * interrupt enable
+ **/
+ ret = sdio_read_reg(WILC_INTR_ENABLE, &reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE);
+ return 0;
+ }
+ reg |= (1 << 16);
+ ret = sdio_write_reg(WILC_INTR_ENABLE, reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE);
+ return 0;
+ }
+ }
+#endif
+
+ return 1;
+}
+
+static int sdio_init(wilc_wlan_inp_t *inp, wilc_debug_func func)
+{
+ sdio_cmd52_t cmd;
+ int loop;
+ uint32_t chipid;
+ memset(&g_sdio, 0, sizeof(wilc_sdio_t));
+
+ g_sdio.dPrint = func;
+ g_sdio.os_context = inp->os_context.os_private;
+ memcpy((void *)&g_sdio.os_func, (void *)&inp->os_func, sizeof(wilc_wlan_os_func_t));
+
+ if (inp->io_func.io_init) {
+ if (!inp->io_func.io_init(g_sdio.os_context)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed io init bus...\n");
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+
+ g_sdio.sdio_cmd52 = inp->io_func.u.sdio.sdio_cmd52;
+ g_sdio.sdio_cmd53 = inp->io_func.u.sdio.sdio_cmd53;
+ g_sdio.sdio_set_max_speed = inp->io_func.u.sdio.sdio_set_max_speed;
+ g_sdio.sdio_set_default_speed = inp->io_func.u.sdio.sdio_set_default_speed;
+
+ /**
+ * function 0 csa enable
+ **/
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 1;
+ cmd.address = 0x100;
+ cmd.data = 0x80;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, enable csa...\n");
+ goto _fail_;
+ }
+
+ /**
+ * function 0 block size
+ **/
+ if (!sdio_set_func0_block_size(WILC_SDIO_BLOCK_SIZE)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, set func 0 block size...\n");
+ goto _fail_;
+ }
+ g_sdio.block_size = WILC_SDIO_BLOCK_SIZE;
+
+ /**
+ * enable func1 IO
+ **/
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 1;
+ cmd.address = 0x2;
+ cmd.data = 0x2;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio] Fail cmd 52, set IOE register...\n");
+ goto _fail_;
+ }
+
+ /**
+ * make sure func 1 is up
+ **/
+ cmd.read_write = 0;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0x3;
+ loop = 3;
+ do {
+ cmd.data = 0;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, get IOR register...\n");
+ goto _fail_;
+ }
+ if (cmd.data == 0x2)
+ break;
+ } while (loop--);
+
+ if (loop <= 0) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail func 1 is not ready...\n");
+ goto _fail_;
+ }
+
+ /**
+ * func 1 is ready, set func 1 block size
+ **/
+ if (!sdio_set_func1_block_size(WILC_SDIO_BLOCK_SIZE)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail set func 1 block size...\n");
+ goto _fail_;
+ }
+
+ /**
+ * func 1 interrupt enable
+ **/
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 1;
+ cmd.address = 0x4;
+ cmd.data = 0x3;
+ if (!g_sdio.sdio_cmd52(&cmd)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd 52, set IEN register...\n");
+ goto _fail_;
+ }
+
+ /**
+ * make sure can read back chip id correctly
+ **/
+ if (!sdio_read_reg(0x1000, &chipid)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Fail cmd read chip id...\n");
+ goto _fail_;
+ }
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: chipid (%08x)\n", chipid);
+ if ((chipid & 0xfff) > 0x2a0) {
+ g_sdio.has_thrpt_enh3 = 1;
+ } else {
+ g_sdio.has_thrpt_enh3 = 0;
+ }
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: has_thrpt_enh3 = %d...\n", g_sdio.has_thrpt_enh3);
+
+
+ return 1;
+
+_fail_:
+
+ return 0;
+}
+
+static void sdio_set_max_speed(void)
+{
+ g_sdio.sdio_set_max_speed();
+}
+
+static void sdio_set_default_speed(void)
+{
+ g_sdio.sdio_set_default_speed();
+}
+
+static int sdio_read_size(uint32_t *size)
+{
+
+ uint32_t tmp;
+ sdio_cmd52_t cmd;
+
+ /**
+ * Read DMA count in words
+ **/
+ {
+ cmd.read_write = 0;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0xf2;
+ cmd.data = 0;
+ g_sdio.sdio_cmd52(&cmd);
+ tmp = cmd.data;
+
+ /* cmd.read_write = 0; */
+ /* cmd.function = 0; */
+ /* cmd.raw = 0; */
+ cmd.address = 0xf3;
+ cmd.data = 0;
+ g_sdio.sdio_cmd52(&cmd);
+ tmp |= (cmd.data << 8);
+ }
+
+ *size = tmp;
+ return 1;
+}
+
+static int sdio_read_int(uint32_t *int_status)
+{
+
+ uint32_t tmp;
+ sdio_cmd52_t cmd;
+
+ sdio_read_size(&tmp);
+
+ /**
+ * Read IRQ flags
+ **/
+#ifndef WILC_SDIO_IRQ_GPIO
+ /* cmd.read_write = 0; */
+ cmd.function = 1;
+ /* cmd.raw = 0; */
+ cmd.address = 0x04;
+ cmd.data = 0;
+ g_sdio.sdio_cmd52(&cmd);
+
+ if (cmd.data & (1 << 0)) {
+ tmp |= INT_0;
+ }
+ if (cmd.data & (1 << 2)) {
+ tmp |= INT_1;
+ }
+ if (cmd.data & (1 << 3)) {
+ tmp |= INT_2;
+ }
+ if (cmd.data & (1 << 4)) {
+ tmp |= INT_3;
+ }
+ if (cmd.data & (1 << 5)) {
+ tmp |= INT_4;
+ }
+ if (cmd.data & (1 << 6)) {
+ tmp |= INT_5;
+ }
+ {
+ int i;
+ for (i = g_sdio.nint; i < MAX_NUM_INT; i++) {
+ if ((tmp >> (IRG_FLAGS_OFFSET + i)) & 0x1) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Unexpected interrupt (1) : tmp=%x, data=%x\n", tmp, cmd.data);
+ break;
+ }
+ }
+ }
+#else
+ {
+ uint32_t irq_flags;
+
+ cmd.read_write = 0;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0xf7;
+ cmd.data = 0;
+ g_sdio.sdio_cmd52(&cmd);
+ irq_flags = cmd.data & 0x1f;
+ tmp |= ((irq_flags >> 0) << IRG_FLAGS_OFFSET);
+ }
+
+#endif
+
+ *int_status = tmp;
+
+ return 1;
+}
+
+static int sdio_clear_int_ext(uint32_t val)
+{
+ int ret;
+
+ if (g_sdio.has_thrpt_enh3) {
+ uint32_t reg;
+
+#ifdef WILC_SDIO_IRQ_GPIO
+ {
+ uint32_t flags;
+ flags = val & ((1 << MAX_NUN_INT_THRPT_ENH2) - 1);
+ reg = flags;
+ }
+#else
+ reg = 0;
+#endif
+ /* select VMM table 0 */
+ if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+ reg |= (1 << 5);
+ /* select VMM table 1 */
+ if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+ reg |= (1 << 6);
+ /* enable VMM */
+ if ((val & EN_VMM) == EN_VMM)
+ reg |= (1 << 7);
+ if (reg) {
+ sdio_cmd52_t cmd;
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0xf8;
+ cmd.data = reg;
+
+ ret = g_sdio.sdio_cmd52(&cmd);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf8 data (%d) ...\n", __LINE__);
+ goto _fail_;
+ }
+
+ }
+ } else {
+#ifdef WILC_SDIO_IRQ_GPIO
+ {
+ /* see below. has_thrpt_enh2 uses register 0xf8 to clear interrupts. */
+ /* Cannot clear multiple interrupts. Must clear each interrupt individually */
+ uint32_t flags;
+ flags = val & ((1 << MAX_NUM_INT) - 1);
+ if (flags) {
+ int i;
+
+ ret = 1;
+ for (i = 0; i < g_sdio.nint; i++) {
+ if (flags & 1) {
+ sdio_cmd52_t cmd;
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0xf8;
+ cmd.data = (1 << i);
+
+ ret = g_sdio.sdio_cmd52(&cmd);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf8 data (%d) ...\n", __LINE__);
+ goto _fail_;
+ }
+
+ }
+ if (!ret)
+ break;
+ flags >>= 1;
+ }
+ if (!ret) {
+ goto _fail_;
+ }
+ for (i = g_sdio.nint; i < MAX_NUM_INT; i++) {
+ if (flags & 1)
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Unexpected interrupt cleared %d...\n", i);
+ flags >>= 1;
+ }
+ }
+ }
+#endif /* WILC_SDIO_IRQ_GPIO */
+
+
+ {
+ uint32_t vmm_ctl;
+
+ vmm_ctl = 0;
+ /* select VMM table 0 */
+ if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+ vmm_ctl |= (1 << 0);
+ /* select VMM table 1 */
+ if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+ vmm_ctl |= (1 << 1);
+ /* enable VMM */
+ if ((val & EN_VMM) == EN_VMM)
+ vmm_ctl |= (1 << 2);
+
+ if (vmm_ctl) {
+ sdio_cmd52_t cmd;
+
+ cmd.read_write = 1;
+ cmd.function = 0;
+ cmd.raw = 0;
+ cmd.address = 0xf6;
+ cmd.data = vmm_ctl;
+ ret = g_sdio.sdio_cmd52(&cmd);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed cmd52, set 0xf6 data (%d) ...\n", __LINE__);
+ goto _fail_;
+ }
+ }
+ }
+ }
+
+ return 1;
+_fail_:
+ return 0;
+}
+
+static int sdio_sync_ext(int nint /* how mant interrupts to enable. */)
+{
+ uint32_t reg;
+
+
+ if (nint > MAX_NUM_INT) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Too many interupts (%d)...\n", nint);
+ return 0;
+ }
+ if (nint > MAX_NUN_INT_THRPT_ENH2) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Error: Cannot support more than 5 interrupts when has_thrpt_enh2=1.\n");
+ return 0;
+ }
+
+
+ g_sdio.nint = nint;
+
+ /**
+ * Disable power sequencer
+ **/
+ if (!sdio_read_reg(WILC_MISC, &reg)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read misc reg...\n");
+ return 0;
+ }
+
+ reg &= ~(1 << 8);
+ if (!sdio_write_reg(WILC_MISC, reg)) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write misc reg...\n");
+ return 0;
+ }
+
+#ifdef WILC_SDIO_IRQ_GPIO
+ {
+ uint32_t reg;
+ int ret, i;
+
+
+ /**
+ * interrupt pin mux select
+ **/
+ ret = sdio_read_reg(WILC_PIN_MUX_0, &reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0);
+ return 0;
+ }
+ reg |= (1 << 8);
+ ret = sdio_write_reg(WILC_PIN_MUX_0, reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0);
+ return 0;
+ }
+
+ /**
+ * interrupt enable
+ **/
+ ret = sdio_read_reg(WILC_INTR_ENABLE, &reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE);
+ return 0;
+ }
+
+ for (i = 0; (i < 5) && (nint > 0); i++, nint--) {
+ reg |= (1 << (27 + i));
+ }
+ ret = sdio_write_reg(WILC_INTR_ENABLE, reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE);
+ return 0;
+ }
+ if (nint) {
+ ret = sdio_read_reg(WILC_INTR2_ENABLE, &reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed read reg (%08x)...\n", WILC_INTR2_ENABLE);
+ return 0;
+ }
+
+ for (i = 0; (i < 3) && (nint > 0); i++, nint--) {
+ reg |= (1 << i);
+ }
+
+ ret = sdio_read_reg(WILC_INTR2_ENABLE, &reg);
+ if (!ret) {
+ g_sdio.dPrint(N_ERR, "[wilc sdio]: Failed write reg (%08x)...\n", WILC_INTR2_ENABLE);
+ return 0;
+ }
+ }
+ }
+#endif /* WILC_SDIO_IRQ_GPIO */
+ return 1;
+}
+
+
+/********************************************
+ *
+ * Global sdio HIF function table
+ *
+ ********************************************/
+
+wilc_hif_func_t hif_sdio = {
+ sdio_init,
+ sdio_deinit,
+ sdio_read_reg,
+ sdio_write_reg,
+ sdio_read,
+ sdio_write,
+ sdio_sync,
+ sdio_clear_int,
+ sdio_read_int,
+ sdio_clear_int_ext,
+ sdio_read_size,
+ sdio_write,
+ sdio_read,
+ sdio_sync_ext,
+
+ sdio_set_max_speed,
+ sdio_set_default_speed,
+};
+
diff --git a/drivers/staging/wilc1000/wilc_sleep.c b/drivers/staging/wilc1000/wilc_sleep.c
new file mode 100644
index 00000000000000..98a079f3d6c978
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_sleep.c
@@ -0,0 +1,18 @@
+
+#include "wilc_oswrapper.h"
+
+/*
+ * @author mdaftedar
+ * @date 10 Aug 2010
+ * @version 1.0
+ */
+void WILC_Sleep(WILC_Uint32 u32TimeMilliSec)
+{
+ if (u32TimeMilliSec <= 4000000) {
+ WILC_Uint32 u32Temp = u32TimeMilliSec * 1000;
+ usleep_range(u32Temp, u32Temp);
+ } else {
+ msleep(u32TimeMilliSec);
+ }
+
+}
diff --git a/drivers/staging/wilc1000/wilc_sleep.h b/drivers/staging/wilc1000/wilc_sleep.h
new file mode 100644
index 00000000000000..2865c8e44346b5
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_sleep.h
@@ -0,0 +1,17 @@
+#ifndef __WILC_SLEEP_H__
+#define __WILC_SLEEP_H__
+
+/*!
+ * @brief forces the current thread to sleep until the given time has elapsed
+ * @param[in] u32TimeMilliSec Time to sleep in Milli seconds
+ * @sa WILC_SleepMicrosec
+ * @author syounan
+ * @date 10 Aug 2010
+ * @version 1.0
+ * @note This function offers a relatively innacurate and low resolution
+ * sleep, for accurate high resolution sleep use u32TimeMicoSec
+ */
+/* TODO: remove and open-code in callers */
+void WILC_Sleep(WILC_Uint32 u32TimeMilliSec);
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_spi.c b/drivers/staging/wilc1000/wilc_spi.c
new file mode 100644
index 00000000000000..d0e761080ca5ff
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -0,0 +1,1475 @@
+/* ////////////////////////////////////////////////////////////////////////// */
+/* */
+/* Copyright (c) Atmel Corporation. All rights reserved. */
+/* */
+/* Module Name: wilc_spi.c */
+/* */
+/* */
+/* //////////////////////////////////////////////////////////////////////////// */
+
+#include "wilc_wlan_if.h"
+#include "wilc_wlan.h"
+
+extern unsigned int int_clrd;
+
+/*
+ * #include <linux/kernel.h>
+ * #include <linux/string.h>
+ */
+typedef struct {
+ void *os_context;
+ int (*spi_tx)(uint8_t *, uint32_t);
+ int (*spi_rx)(uint8_t *, uint32_t);
+ int (*spi_trx)(uint8_t *, uint8_t *, uint32_t);
+ int (*spi_max_speed)(void);
+ wilc_debug_func dPrint;
+ int crc_off;
+ int nint;
+ int has_thrpt_enh;
+} wilc_spi_t;
+
+static wilc_spi_t g_spi;
+
+static int spi_read(uint32_t, uint8_t *, uint32_t);
+static int spi_write(uint32_t, uint8_t *, uint32_t);
+
+/********************************************
+ *
+ * Crc7
+ *
+ ********************************************/
+
+static const uint8_t crc7_syndrome_table[256] = {
+ 0x00, 0x09, 0x12, 0x1b, 0x24, 0x2d, 0x36, 0x3f,
+ 0x48, 0x41, 0x5a, 0x53, 0x6c, 0x65, 0x7e, 0x77,
+ 0x19, 0x10, 0x0b, 0x02, 0x3d, 0x34, 0x2f, 0x26,
+ 0x51, 0x58, 0x43, 0x4a, 0x75, 0x7c, 0x67, 0x6e,
+ 0x32, 0x3b, 0x20, 0x29, 0x16, 0x1f, 0x04, 0x0d,
+ 0x7a, 0x73, 0x68, 0x61, 0x5e, 0x57, 0x4c, 0x45,
+ 0x2b, 0x22, 0x39, 0x30, 0x0f, 0x06, 0x1d, 0x14,
+ 0x63, 0x6a, 0x71, 0x78, 0x47, 0x4e, 0x55, 0x5c,
+ 0x64, 0x6d, 0x76, 0x7f, 0x40, 0x49, 0x52, 0x5b,
+ 0x2c, 0x25, 0x3e, 0x37, 0x08, 0x01, 0x1a, 0x13,
+ 0x7d, 0x74, 0x6f, 0x66, 0x59, 0x50, 0x4b, 0x42,
+ 0x35, 0x3c, 0x27, 0x2e, 0x11, 0x18, 0x03, 0x0a,
+ 0x56, 0x5f, 0x44, 0x4d, 0x72, 0x7b, 0x60, 0x69,
+ 0x1e, 0x17, 0x0c, 0x05, 0x3a, 0x33, 0x28, 0x21,
+ 0x4f, 0x46, 0x5d, 0x54, 0x6b, 0x62, 0x79, 0x70,
+ 0x07, 0x0e, 0x15, 0x1c, 0x23, 0x2a, 0x31, 0x38,
+ 0x41, 0x48, 0x53, 0x5a, 0x65, 0x6c, 0x77, 0x7e,
+ 0x09, 0x00, 0x1b, 0x12, 0x2d, 0x24, 0x3f, 0x36,
+ 0x58, 0x51, 0x4a, 0x43, 0x7c, 0x75, 0x6e, 0x67,
+ 0x10, 0x19, 0x02, 0x0b, 0x34, 0x3d, 0x26, 0x2f,
+ 0x73, 0x7a, 0x61, 0x68, 0x57, 0x5e, 0x45, 0x4c,
+ 0x3b, 0x32, 0x29, 0x20, 0x1f, 0x16, 0x0d, 0x04,
+ 0x6a, 0x63, 0x78, 0x71, 0x4e, 0x47, 0x5c, 0x55,
+ 0x22, 0x2b, 0x30, 0x39, 0x06, 0x0f, 0x14, 0x1d,
+ 0x25, 0x2c, 0x37, 0x3e, 0x01, 0x08, 0x13, 0x1a,
+ 0x6d, 0x64, 0x7f, 0x76, 0x49, 0x40, 0x5b, 0x52,
+ 0x3c, 0x35, 0x2e, 0x27, 0x18, 0x11, 0x0a, 0x03,
+ 0x74, 0x7d, 0x66, 0x6f, 0x50, 0x59, 0x42, 0x4b,
+ 0x17, 0x1e, 0x05, 0x0c, 0x33, 0x3a, 0x21, 0x28,
+ 0x5f, 0x56, 0x4d, 0x44, 0x7b, 0x72, 0x69, 0x60,
+ 0x0e, 0x07, 0x1c, 0x15, 0x2a, 0x23, 0x38, 0x31,
+ 0x46, 0x4f, 0x54, 0x5d, 0x62, 0x6b, 0x70, 0x79
+};
+
+static uint8_t crc7_byte(uint8_t crc, uint8_t data)
+{
+ return crc7_syndrome_table[(crc << 1) ^ data];
+}
+
+static uint8_t crc7(uint8_t crc, const uint8_t *buffer, uint32_t len)
+{
+ while (len--)
+ crc = crc7_byte(crc, *buffer++);
+ return crc;
+}
+
+/********************************************
+ *
+ * Spi protocol Function
+ *
+ ********************************************/
+
+#define CMD_DMA_WRITE 0xc1
+#define CMD_DMA_READ 0xc2
+#define CMD_INTERNAL_WRITE 0xc3
+#define CMD_INTERNAL_READ 0xc4
+#define CMD_TERMINATE 0xc5
+#define CMD_REPEAT 0xc6
+#define CMD_DMA_EXT_WRITE 0xc7
+#define CMD_DMA_EXT_READ 0xc8
+#define CMD_SINGLE_WRITE 0xc9
+#define CMD_SINGLE_READ 0xca
+#define CMD_RESET 0xcf
+
+#define N_OK 1
+#define N_FAIL 0
+#define N_RESET -1
+#define N_RETRY -2
+
+#define DATA_PKT_SZ_256 256
+#define DATA_PKT_SZ_512 512
+#define DATA_PKT_SZ_1K 1024
+#define DATA_PKT_SZ_4K (4 * 1024)
+#define DATA_PKT_SZ_8K (8 * 1024)
+#define DATA_PKT_SZ DATA_PKT_SZ_8K
+
+static int spi_cmd(uint8_t cmd, uint32_t adr, uint32_t data, uint32_t sz, uint8_t clockless)
+{
+ uint8_t bc[9];
+ int len = 5;
+ int result = N_OK;
+
+ bc[0] = cmd;
+ switch (cmd) {
+ case CMD_SINGLE_READ: /* single word (4 bytes) read */
+ bc[1] = (uint8_t)(adr >> 16);
+ bc[2] = (uint8_t)(adr >> 8);
+ bc[3] = (uint8_t)adr;
+ len = 5;
+ break;
+
+ case CMD_INTERNAL_READ: /* internal register read */
+ bc[1] = (uint8_t)(adr >> 8);
+ if (clockless)
+ bc[1] |= (1 << 7);
+ bc[2] = (uint8_t)adr;
+ bc[3] = 0x00;
+ len = 5;
+ break;
+
+ case CMD_TERMINATE: /* termination */
+ bc[1] = 0x00;
+ bc[2] = 0x00;
+ bc[3] = 0x00;
+ len = 5;
+ break;
+
+ case CMD_REPEAT: /* repeat */
+ bc[1] = 0x00;
+ bc[2] = 0x00;
+ bc[3] = 0x00;
+ len = 5;
+ break;
+
+ case CMD_RESET: /* reset */
+ bc[1] = 0xff;
+ bc[2] = 0xff;
+ bc[3] = 0xff;
+ len = 5;
+ break;
+
+ case CMD_DMA_WRITE: /* dma write */
+ case CMD_DMA_READ: /* dma read */
+ bc[1] = (uint8_t)(adr >> 16);
+ bc[2] = (uint8_t)(adr >> 8);
+ bc[3] = (uint8_t)adr;
+ bc[4] = (uint8_t)(sz >> 8);
+ bc[5] = (uint8_t)(sz);
+ len = 7;
+ break;
+
+ case CMD_DMA_EXT_WRITE: /* dma extended write */
+ case CMD_DMA_EXT_READ: /* dma extended read */
+ bc[1] = (uint8_t)(adr >> 16);
+ bc[2] = (uint8_t)(adr >> 8);
+ bc[3] = (uint8_t)adr;
+ bc[4] = (uint8_t)(sz >> 16);
+ bc[5] = (uint8_t)(sz >> 8);
+ bc[6] = (uint8_t)(sz);
+ len = 8;
+ break;
+
+ case CMD_INTERNAL_WRITE: /* internal register write */
+ bc[1] = (uint8_t)(adr >> 8);
+ if (clockless)
+ bc[1] |= (1 << 7);
+ bc[2] = (uint8_t)(adr);
+ bc[3] = (uint8_t)(data >> 24);
+ bc[4] = (uint8_t)(data >> 16);
+ bc[5] = (uint8_t)(data >> 8);
+ bc[6] = (uint8_t)(data);
+ len = 8;
+ break;
+
+ case CMD_SINGLE_WRITE: /* single word write */
+ bc[1] = (uint8_t)(adr >> 16);
+ bc[2] = (uint8_t)(adr >> 8);
+ bc[3] = (uint8_t)(adr);
+ bc[4] = (uint8_t)(data >> 24);
+ bc[5] = (uint8_t)(data >> 16);
+ bc[6] = (uint8_t)(data >> 8);
+ bc[7] = (uint8_t)(data);
+ len = 9;
+ break;
+
+ default:
+ result = N_FAIL;
+ break;
+ }
+
+ if (result) {
+ if (!g_spi.crc_off)
+ bc[len - 1] = (crc7(0x7f, (const uint8_t *)&bc[0], len - 1)) << 1;
+ else
+ len -= 1;
+
+ if (!g_spi.spi_tx(bc, len)) {
+ PRINT_ER("[wilc spi]: Failed cmd write, bus error...\n");
+ result = N_FAIL;
+ }
+ }
+
+ return result;
+}
+
+static int spi_cmd_rsp(uint8_t cmd)
+{
+ uint8_t rsp;
+ int result = N_OK;
+
+ /**
+ * Command/Control response
+ **/
+ if ((cmd == CMD_RESET) ||
+ (cmd == CMD_TERMINATE) ||
+ (cmd == CMD_REPEAT)) {
+ if (!g_spi.spi_rx(&rsp, 1)) {
+ result = N_FAIL;
+ goto _fail_;
+ }
+ }
+
+ if (!g_spi.spi_rx(&rsp, 1)) {
+ PRINT_ER("[wilc spi]: Failed cmd response read, bus error...\n");
+ result = N_FAIL;
+ goto _fail_;
+ }
+
+ if (rsp != cmd) {
+ PRINT_ER("[wilc spi]: Failed cmd response, cmd (%02x), resp (%02x)\n", cmd, rsp);
+ result = N_FAIL;
+ goto _fail_;
+ }
+
+ /**
+ * State response
+ **/
+ if (!g_spi.spi_rx(&rsp, 1)) {
+ PRINT_ER("[wilc spi]: Failed cmd state read, bus error...\n");
+ result = N_FAIL;
+ goto _fail_;
+ }
+
+ if (rsp != 0x00) {
+ PRINT_ER("[wilc spi]: Failed cmd state response state (%02x)\n", rsp);
+ result = N_FAIL;
+ }
+
+_fail_:
+
+ return result;
+}
+
+static int spi_cmd_complete(uint8_t cmd, uint32_t adr, uint8_t *b, uint32_t sz, uint8_t clockless)
+{
+ uint8_t wb[32], rb[32];
+ uint8_t wix, rix;
+ uint32_t len2;
+ uint8_t rsp;
+ int len = 0;
+ int result = N_OK;
+
+ wb[0] = cmd;
+ switch (cmd) {
+ case CMD_SINGLE_READ: /* single word (4 bytes) read */
+ wb[1] = (uint8_t)(adr >> 16);
+ wb[2] = (uint8_t)(adr >> 8);
+ wb[3] = (uint8_t)adr;
+ len = 5;
+ break;
+
+ case CMD_INTERNAL_READ: /* internal register read */
+ wb[1] = (uint8_t)(adr >> 8);
+ if (clockless == 1)
+ wb[1] |= (1 << 7);
+ wb[2] = (uint8_t)adr;
+ wb[3] = 0x00;
+ len = 5;
+ break;
+
+ case CMD_TERMINATE: /* termination */
+ wb[1] = 0x00;
+ wb[2] = 0x00;
+ wb[3] = 0x00;
+ len = 5;
+ break;
+
+ case CMD_REPEAT: /* repeat */
+ wb[1] = 0x00;
+ wb[2] = 0x00;
+ wb[3] = 0x00;
+ len = 5;
+ break;
+
+ case CMD_RESET: /* reset */
+ wb[1] = 0xff;
+ wb[2] = 0xff;
+ wb[3] = 0xff;
+ len = 5;
+ break;
+
+ case CMD_DMA_WRITE: /* dma write */
+ case CMD_DMA_READ: /* dma read */
+ wb[1] = (uint8_t)(adr >> 16);
+ wb[2] = (uint8_t)(adr >> 8);
+ wb[3] = (uint8_t)adr;
+ wb[4] = (uint8_t)(sz >> 8);
+ wb[5] = (uint8_t)(sz);
+ len = 7;
+ break;
+
+ case CMD_DMA_EXT_WRITE: /* dma extended write */
+ case CMD_DMA_EXT_READ: /* dma extended read */
+ wb[1] = (uint8_t)(adr >> 16);
+ wb[2] = (uint8_t)(adr >> 8);
+ wb[3] = (uint8_t)adr;
+ wb[4] = (uint8_t)(sz >> 16);
+ wb[5] = (uint8_t)(sz >> 8);
+ wb[6] = (uint8_t)(sz);
+ len = 8;
+ break;
+
+ case CMD_INTERNAL_WRITE: /* internal register write */
+ wb[1] = (uint8_t)(adr >> 8);
+ if (clockless == 1)
+ wb[1] |= (1 << 7);
+ wb[2] = (uint8_t)(adr);
+ wb[3] = b[3];
+ wb[4] = b[2];
+ wb[5] = b[1];
+ wb[6] = b[0];
+ len = 8;
+ break;
+
+ case CMD_SINGLE_WRITE: /* single word write */
+ wb[1] = (uint8_t)(adr >> 16);
+ wb[2] = (uint8_t)(adr >> 8);
+ wb[3] = (uint8_t)(adr);
+ wb[4] = b[3];
+ wb[5] = b[2];
+ wb[6] = b[1];
+ wb[7] = b[0];
+ len = 9;
+ break;
+
+ default:
+ result = N_FAIL;
+ break;
+ }
+
+ if (result != N_OK) {
+ return result;
+ }
+
+ if (!g_spi.crc_off) {
+ wb[len - 1] = (crc7(0x7f, (const uint8_t *)&wb[0], len - 1)) << 1;
+ } else {
+ len -= 1;
+ }
+
+#define NUM_SKIP_BYTES (1)
+#define NUM_RSP_BYTES (2)
+#define NUM_DATA_HDR_BYTES (1)
+#define NUM_DATA_BYTES (4)
+#define NUM_CRC_BYTES (2)
+#define NUM_DUMMY_BYTES (3)
+ if ((cmd == CMD_RESET) ||
+ (cmd == CMD_TERMINATE) ||
+ (cmd == CMD_REPEAT)) {
+ len2 = len + (NUM_SKIP_BYTES + NUM_RSP_BYTES + NUM_DUMMY_BYTES);
+ } else if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ)) {
+ if (!g_spi.crc_off) {
+ len2 = len + (NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES
+ + NUM_CRC_BYTES + NUM_DUMMY_BYTES);
+ } else {
+ len2 = len + (NUM_RSP_BYTES + NUM_DATA_HDR_BYTES + NUM_DATA_BYTES
+ + NUM_DUMMY_BYTES);
+ }
+ } else {
+ len2 = len + (NUM_RSP_BYTES + NUM_DUMMY_BYTES);
+ }
+#undef NUM_DUMMY_BYTES
+
+ if (len2 > (sizeof(wb) / sizeof(wb[0]))) {
+ PRINT_ER("[wilc spi]: spi buffer size too small (%d) (%d)\n",
+ len2, (sizeof(wb) / sizeof(wb[0])));
+ result = N_FAIL;
+ return result;
+ }
+ /* zero spi write buffers. */
+ for (wix = len; wix < len2; wix++) {
+ wb[wix] = 0;
+ }
+ rix = len;
+
+ if (!g_spi.spi_trx(wb, rb, len2)) {
+ PRINT_ER("[wilc spi]: Failed cmd write, bus error...\n");
+ result = N_FAIL;
+ return result;
+ }
+
+#if 0
+ {
+ int jj;
+ PRINT_D(BUS_DBG, "--- cnd = %x, len=%d, len2=%d\n", cmd, len, len2);
+ for (jj = 0; jj < sizeof(wb) / sizeof(wb[0]); jj++) {
+
+ if (jj >= len2)
+ break;
+ if (((jj + 1) % 16) != 0) {
+ if ((jj % 16) == 0) {
+ PRINT_D(BUS_DBG, "wb[%02x]: %02x ", jj, wb[jj]);
+ } else {
+ PRINT_D(BUS_DBG, "%02x ", wb[jj]);
+ }
+ } else {
+ PRINT_D(BUS_DBG, "%02x\n", wb[jj]);
+ }
+ }
+
+ for (jj = 0; jj < sizeof(rb) / sizeof(rb[0]); jj++) {
+
+ if (jj >= len2)
+ break;
+ if (((jj + 1) % 16) != 0) {
+ if ((jj % 16) == 0) {
+ PRINT_D(BUS_DBG, "rb[%02x]: %02x ", jj, rb[jj]);
+ } else {
+ PRINT_D(BUS_DBG, "%02x ", rb[jj]);
+ }
+ } else {
+ PRINT_D(BUS_DBG, "%02x\n", rb[jj]);
+ }
+ }
+ }
+#endif
+
+ /**
+ * Command/Control response
+ **/
+ if ((cmd == CMD_RESET) ||
+ (cmd == CMD_TERMINATE) ||
+ (cmd == CMD_REPEAT)) {
+ rix++; /* skip 1 byte */
+ }
+
+ /* do { */
+ rsp = rb[rix++];
+ /* if(rsp == cmd) break; */
+ /* } while(&rptr[1] <= &rb[len2]); */
+
+ if (rsp != cmd) {
+ PRINT_ER("[wilc spi]: Failed cmd response, cmd (%02x)"
+ ", resp (%02x)\n", cmd, rsp);
+ result = N_FAIL;
+ return result;
+ }
+
+ /**
+ * State response
+ **/
+ rsp = rb[rix++];
+ if (rsp != 0x00) {
+ PRINT_ER("[wilc spi]: Failed cmd state response "
+ "state (%02x)\n", rsp);
+ result = N_FAIL;
+ return result;
+ }
+
+ if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ)
+ || (cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) {
+ int retry;
+ /* uint16_t crc1, crc2; */
+ uint8_t crc[2];
+ /**
+ * Data Respnose header
+ **/
+ retry = 100;
+ do {
+ /* ensure there is room in buffer later to read data and crc */
+ if (rix < len2) {
+ rsp = rb[rix++];
+ } else {
+ retry = 0;
+ break;
+ }
+ if (((rsp >> 4) & 0xf) == 0xf)
+ break;
+ } while (retry--);
+
+ if (retry <= 0) {
+ PRINT_ER("[wilc spi]: Error, data read "
+ "response (%02x)\n", rsp);
+ result = N_RESET;
+ return result;
+ }
+
+ if ((cmd == CMD_INTERNAL_READ) || (cmd == CMD_SINGLE_READ)) {
+ /**
+ * Read bytes
+ **/
+ if ((rix + 3) < len2) {
+ b[0] = rb[rix++];
+ b[1] = rb[rix++];
+ b[2] = rb[rix++];
+ b[3] = rb[rix++];
+ } else {
+ PRINT_ER("[wilc spi]: buffer overrun when reading data.\n");
+ result = N_FAIL;
+ return result;
+ }
+
+ if (!g_spi.crc_off) {
+ /**
+ * Read Crc
+ **/
+ if ((rix + 1) < len2) {
+ crc[0] = rb[rix++];
+ crc[1] = rb[rix++];
+ } else {
+ PRINT_ER("[wilc spi]: buffer overrun when reading crc.\n");
+ result = N_FAIL;
+ return result;
+ }
+ }
+ } else if ((cmd == CMD_DMA_READ) || (cmd == CMD_DMA_EXT_READ)) {
+ int ix;
+
+ /* some data may be read in response to dummy bytes. */
+ for (ix = 0; (rix < len2) && (ix < sz); ) {
+ b[ix++] = rb[rix++];
+ }
+#if 0
+ if (ix)
+ PRINT_D(BUS_DBG, "ttt %d %d\n", sz, ix);
+#endif
+ sz -= ix;
+
+ if (sz > 0) {
+ int nbytes;
+
+ if (sz <= (DATA_PKT_SZ - ix)) {
+ nbytes = sz;
+ } else {
+ nbytes = DATA_PKT_SZ - ix;
+ }
+
+ /**
+ * Read bytes
+ **/
+ if (!g_spi.spi_rx(&b[ix], nbytes)) {
+ PRINT_ER("[wilc spi]: Failed data block read, bus error...\n");
+ result = N_FAIL;
+ goto _error_;
+ }
+
+ /**
+ * Read Crc
+ **/
+ if (!g_spi.crc_off) {
+ if (!g_spi.spi_rx(crc, 2)) {
+ PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n");
+ result = N_FAIL;
+ goto _error_;
+ }
+ }
+
+
+ ix += nbytes;
+ sz -= nbytes;
+ }
+
+ /* if any data in left unread, then read the rest using normal DMA code.*/
+ while (sz > 0) {
+ int nbytes;
+
+#if 0
+ PRINT_INFO(BUS_DBG, "rrr %d %d\n", sz, ix);
+#endif
+ if (sz <= DATA_PKT_SZ) {
+ nbytes = sz;
+ } else {
+ nbytes = DATA_PKT_SZ;
+ }
+
+ /**
+ * read data response only on the next DMA cycles not
+ * the first DMA since data response header is already
+ * handled above for the first DMA.
+ **/
+ /**
+ * Data Respnose header
+ **/
+ retry = 10;
+ do {
+ if (!g_spi.spi_rx(&rsp, 1)) {
+ PRINT_ER("[wilc spi]: Failed data response read, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+ if (((rsp >> 4) & 0xf) == 0xf)
+ break;
+ } while (retry--);
+
+ if (result == N_FAIL)
+ break;
+
+
+ /**
+ * Read bytes
+ **/
+ if (!g_spi.spi_rx(&b[ix], nbytes)) {
+ PRINT_ER("[wilc spi]: Failed data block read, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+
+ /**
+ * Read Crc
+ **/
+ if (!g_spi.crc_off) {
+ if (!g_spi.spi_rx(crc, 2)) {
+ PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+ }
+
+ ix += nbytes;
+ sz -= nbytes;
+ }
+ }
+ }
+_error_:
+ return result;
+}
+
+static int spi_data_read(uint8_t *b, uint32_t sz)
+{
+ int retry, ix, nbytes;
+ int result = N_OK;
+ uint8_t crc[2];
+ uint8_t rsp;
+
+ /**
+ * Data
+ **/
+ ix = 0;
+ do {
+ if (sz <= DATA_PKT_SZ)
+ nbytes = sz;
+ else
+ nbytes = DATA_PKT_SZ;
+
+ /**
+ * Data Respnose header
+ **/
+ retry = 10;
+ do {
+ if (!g_spi.spi_rx(&rsp, 1)) {
+ PRINT_ER("[wilc spi]: Failed data response read, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+ if (((rsp >> 4) & 0xf) == 0xf)
+ break;
+ } while (retry--);
+
+ if (result == N_FAIL)
+ break;
+
+ if (retry <= 0) {
+ PRINT_ER("[wilc spi]: Failed data response read...(%02x)\n", rsp);
+ result = N_FAIL;
+ break;
+ }
+
+ /**
+ * Read bytes
+ **/
+ if (!g_spi.spi_rx(&b[ix], nbytes)) {
+ PRINT_ER("[wilc spi]: Failed data block read, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+
+ /**
+ * Read Crc
+ **/
+ if (!g_spi.crc_off) {
+ if (!g_spi.spi_rx(crc, 2)) {
+ PRINT_ER("[wilc spi]: Failed data block crc read, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+ }
+
+ ix += nbytes;
+ sz -= nbytes;
+
+ } while (sz);
+
+ return result;
+}
+
+static int spi_data_write(uint8_t *b, uint32_t sz)
+{
+ int ix, nbytes;
+ int result = 1;
+ uint8_t cmd, order, crc[2] = {0};
+ /* uint8_t rsp; */
+
+ /**
+ * Data
+ **/
+ ix = 0;
+ do {
+ if (sz <= DATA_PKT_SZ)
+ nbytes = sz;
+ else
+ nbytes = DATA_PKT_SZ;
+
+ /**
+ * Write command
+ **/
+ cmd = 0xf0;
+ if (ix == 0) {
+ if (sz <= DATA_PKT_SZ)
+
+ order = 0x3;
+ else
+ order = 0x1;
+ } else {
+ if (sz <= DATA_PKT_SZ)
+ order = 0x3;
+ else
+ order = 0x2;
+ }
+ cmd |= order;
+ if (!g_spi.spi_tx(&cmd, 1)) {
+ PRINT_ER("[wilc spi]: Failed data block cmd write, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+
+ /**
+ * Write data
+ **/
+ if (!g_spi.spi_tx(&b[ix], nbytes)) {
+ PRINT_ER("[wilc spi]: Failed data block write, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+
+ /**
+ * Write Crc
+ **/
+ if (!g_spi.crc_off) {
+ if (!g_spi.spi_tx(crc, 2)) {
+ PRINT_ER("[wilc spi]: Failed data block crc write, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+ }
+
+ /**
+ * No need to wait for response
+ **/
+#if 0
+ /**
+ * Respnose
+ **/
+ if (!g_spi.spi_rx(&rsp, 1)) {
+ PRINT_ER("[wilc spi]: Failed data block write, response read, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+
+ if (((rsp >> 4) & 0xf) != 0xc) {
+ result = N_FAIL;
+ PRINT_ER("[wilc spi]: Failed data block write response...(%02x)\n", rsp);
+ break;
+ }
+
+ /**
+ * State
+ **/
+ if (!g_spi.spi_rx(&rsp, 1)) {
+ PRINT_ER("[wilc spi]: Failed data block write, read state, bus error...\n");
+ result = N_FAIL;
+ break;
+ }
+#endif
+
+ ix += nbytes;
+ sz -= nbytes;
+ } while (sz);
+
+
+ return result;
+}
+
+/********************************************
+ *
+ * Spi Internal Read/Write Function
+ *
+ ********************************************/
+
+static int spi_internal_write(uint32_t adr, uint32_t dat)
+{
+ int result;
+
+#if defined USE_OLD_SPI_SW
+ /**
+ * Command
+ **/
+ result = spi_cmd(CMD_INTERNAL_WRITE, adr, dat, 4, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed internal write cmd...\n");
+ return 0;
+ }
+
+ result = spi_cmd_rsp(CMD_INTERNAL_WRITE, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed internal write cmd response...\n");
+ }
+#else
+
+#ifdef BIG_ENDIAN
+ dat = BYTE_SWAP(dat);
+#endif
+ result = spi_cmd_complete(CMD_INTERNAL_WRITE, adr, (uint8_t *)&dat, 4, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed internal write cmd...\n");
+ }
+
+#endif
+ return result;
+}
+
+static int spi_internal_read(uint32_t adr, uint32_t *data)
+{
+ int result;
+
+#if defined USE_OLD_SPI_SW
+ result = spi_cmd(CMD_INTERNAL_READ, adr, 0, 4, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed internal read cmd...\n");
+ return 0;
+ }
+
+ result = spi_cmd_rsp(CMD_INTERNAL_READ, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed internal read cmd response...\n");
+ return 0;
+ }
+
+ /**
+ * Data
+ **/
+ result = spi_data_read((uint8_t *)data, 4);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed internal read data...\n");
+ return 0;
+ }
+#else
+ result = spi_cmd_complete(CMD_INTERNAL_READ, adr, (uint8_t *)data, 4, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed internal read cmd...\n");
+ return 0;
+ }
+#endif
+
+
+#ifdef BIG_ENDIAN
+ *data = BYTE_SWAP(*data);
+#endif
+
+ return 1;
+}
+
+/********************************************
+ *
+ * Spi interfaces
+ *
+ ********************************************/
+
+static int spi_write_reg(uint32_t addr, uint32_t data)
+{
+ int result = N_OK;
+ uint8_t cmd = CMD_SINGLE_WRITE;
+ uint8_t clockless = 0;
+
+
+#if defined USE_OLD_SPI_SW
+ {
+ result = spi_cmd(cmd, addr, data, 4, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd, write reg (%08x)...\n", addr);
+ return 0;
+ }
+
+ result = spi_cmd_rsp(cmd, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd response, write reg (%08x)...\n", addr);
+ return 0;
+ }
+
+ return 1;
+ }
+#else
+#ifdef BIG_ENDIAN
+ data = BYTE_SWAP(data);
+#endif
+ if (addr < 0x30) {
+ /* Clockless register*/
+ cmd = CMD_INTERNAL_WRITE;
+ clockless = 1;
+ }
+
+ result = spi_cmd_complete(cmd, addr, (uint8_t *)&data, 4, clockless);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd, write reg (%08x)...\n", addr);
+ }
+
+ return result;
+#endif
+
+}
+
+static int spi_write(uint32_t addr, uint8_t *buf, uint32_t size)
+{
+ int result;
+ uint8_t cmd = CMD_DMA_EXT_WRITE;
+
+ /**
+ * has to be greated than 4
+ **/
+ if (size <= 4)
+ return 0;
+
+#if defined USE_OLD_SPI_SW
+ /**
+ * Command
+ **/
+ result = spi_cmd(cmd, addr, 0, size, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd, write block (%08x)...\n", addr);
+ return 0;
+ }
+
+ result = spi_cmd_rsp(cmd, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi ]: Failed cmd response, write block (%08x)...\n", addr);
+ return 0;
+ }
+#else
+ result = spi_cmd_complete(cmd, addr, NULL, size, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd, write block (%08x)...\n", addr);
+ return 0;
+ }
+#endif
+
+ /**
+ * Data
+ **/
+ result = spi_data_write(buf, size);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed block data write...\n");
+ }
+
+ return 1;
+}
+
+static int spi_read_reg(uint32_t addr, uint32_t *data)
+{
+ int result = N_OK;
+ uint8_t cmd = CMD_SINGLE_READ;
+ uint8_t clockless = 0;
+
+#if defined USE_OLD_SPI_SW
+ result = spi_cmd(cmd, addr, 0, 4, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd, read reg (%08x)...\n", addr);
+ return 0;
+ }
+ result = spi_cmd_rsp(cmd, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd response, read reg (%08x)...\n", addr);
+ return 0;
+ }
+
+ result = spi_data_read((uint8_t *)data, 4);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed data read...\n");
+ return 0;
+ }
+#else
+ if (addr < 0x30) {
+ /* PRINT_ER("***** read addr %d\n\n", addr); */
+ /* Clockless register*/
+ cmd = CMD_INTERNAL_READ;
+ clockless = 1;
+ }
+
+ result = spi_cmd_complete(cmd, addr, (uint8_t *)data, 4, clockless);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd, read reg (%08x)...\n", addr);
+ return 0;
+ }
+#endif
+
+
+#ifdef BIG_ENDIAN
+ *data = BYTE_SWAP(*data);
+#endif
+
+ return 1;
+}
+
+static int spi_read(uint32_t addr, uint8_t *buf, uint32_t size)
+{
+ uint8_t cmd = CMD_DMA_EXT_READ;
+ int result;
+
+ if (size <= 4)
+ return 0;
+
+#if defined USE_OLD_SPI_SW
+ /**
+ * Command
+ **/
+ result = spi_cmd(cmd, addr, 0, size, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd, read block (%08x)...\n", addr);
+ return 0;
+ }
+
+ result = spi_cmd_rsp(cmd, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd response, read block (%08x)...\n", addr);
+ return 0;
+ }
+
+ /**
+ * Data
+ **/
+ result = spi_data_read(buf, size);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed block data read...\n");
+ return 0;
+ }
+#else
+ result = spi_cmd_complete(cmd, addr, buf, size, 0);
+ if (result != N_OK) {
+ PRINT_ER("[wilc spi]: Failed cmd, read block (%08x)...\n", addr);
+ return 0;
+ }
+#endif
+
+
+ return 1;
+}
+
+/********************************************
+ *
+ * Bus interfaces
+ *
+ ********************************************/
+
+static int spi_clear_int(void)
+{
+ uint32_t reg;
+ if (!spi_read_reg(WILC_HOST_RX_CTRL_0, &reg)) {
+ PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_HOST_RX_CTRL_0);
+ return 0;
+ }
+ reg &= ~0x1;
+ spi_write_reg(WILC_HOST_RX_CTRL_0, reg);
+ int_clrd++;
+ return 1;
+}
+
+static int spi_deinit(void *pv)
+{
+ /**
+ * TODO:
+ **/
+ return 1;
+}
+
+static int spi_sync(void)
+{
+ uint32_t reg;
+ int ret;
+
+ /**
+ * interrupt pin mux select
+ **/
+ ret = spi_read_reg(WILC_PIN_MUX_0, &reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0);
+ return 0;
+ }
+ reg |= (1 << 8);
+ ret = spi_write_reg(WILC_PIN_MUX_0, reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0);
+ return 0;
+ }
+
+ /**
+ * interrupt enable
+ **/
+ ret = spi_read_reg(WILC_INTR_ENABLE, &reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE);
+ return 0;
+ }
+ reg |= (1 << 16);
+ ret = spi_write_reg(WILC_INTR_ENABLE, reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE);
+ return 0;
+ }
+
+ return 1;
+}
+
+static int spi_init(wilc_wlan_inp_t *inp, wilc_debug_func func)
+{
+ uint32_t reg;
+ uint32_t chipid;
+
+ static int isinit;
+
+ if (isinit) {
+
+ if (!spi_read_reg(0x1000, &chipid)) {
+ PRINT_ER("[wilc spi]: Fail cmd read chip id...\n");
+ return 0;
+ }
+ return 1;
+ }
+
+ memset(&g_spi, 0, sizeof(wilc_spi_t));
+
+ g_spi.dPrint = func;
+ g_spi.os_context = inp->os_context.os_private;
+ if (inp->io_func.io_init) {
+ if (!inp->io_func.io_init(g_spi.os_context)) {
+ PRINT_ER("[wilc spi]: Failed io init bus...\n");
+ return 0;
+ }
+ } else {
+ return 0;
+ }
+ g_spi.spi_tx = inp->io_func.u.spi.spi_tx;
+ g_spi.spi_rx = inp->io_func.u.spi.spi_rx;
+ g_spi.spi_trx = inp->io_func.u.spi.spi_trx;
+ g_spi.spi_max_speed = inp->io_func.u.spi.spi_max_speed;
+
+ /**
+ * configure protocol
+ **/
+ g_spi.crc_off = 0;
+
+ /* TODO: We can remove the CRC trials if there is a definite way to reset */
+ /* the SPI to it's initial value. */
+ if (!spi_internal_read(WILC_SPI_PROTOCOL_OFFSET, &reg)) {
+ /* Read failed. Try with CRC off. This might happen when module
+ * is removed but chip isn't reset*/
+ g_spi.crc_off = 1;
+ PRINT_ER("[wilc spi]: Failed internal read protocol with CRC on, retyring with CRC off...\n");
+ if (!spi_internal_read(WILC_SPI_PROTOCOL_OFFSET, &reg)) {
+ /* Reaad failed with both CRC on and off, something went bad */
+ PRINT_ER("[wilc spi]: Failed internal read protocol...\n");
+ return 0;
+ }
+ }
+ if (g_spi.crc_off == 0) {
+ reg &= ~0xc; /* disable crc checking */
+ reg &= ~0x70;
+ reg |= (0x5 << 4);
+ if (!spi_internal_write(WILC_SPI_PROTOCOL_OFFSET, reg)) {
+ PRINT_ER("[wilc spi %d]: Failed internal write protocol reg...\n", __LINE__);
+ return 0;
+ }
+ g_spi.crc_off = 1;
+ }
+
+
+ /**
+ * make sure can read back chip id correctly
+ **/
+ if (!spi_read_reg(0x1000, &chipid)) {
+ PRINT_ER("[wilc spi]: Fail cmd read chip id...\n");
+ return 0;
+ }
+ /* PRINT_ER("[wilc spi]: chipid (%08x)\n", chipid); */
+
+ g_spi.has_thrpt_enh = 1;
+
+ isinit = 1;
+
+ return 1;
+}
+
+static void spi_max_bus_speed(void)
+{
+ g_spi.spi_max_speed();
+}
+
+static void spi_default_bus_speed(void)
+{
+}
+
+static int spi_read_size(uint32_t *size)
+{
+ int ret;
+ if (g_spi.has_thrpt_enh) {
+ ret = spi_internal_read(0xe840 - WILC_SPI_REG_BASE, size);
+ *size = *size & IRQ_DMA_WD_CNT_MASK;
+ } else {
+ uint32_t tmp;
+ uint32_t byte_cnt;
+
+ ret = spi_read_reg(WILC_VMM_TO_HOST_SIZE, &byte_cnt);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed read WILC_VMM_TO_HOST_SIZE ...\n");
+ goto _fail_;
+ }
+ tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
+ *size = tmp;
+ }
+
+
+
+_fail_:
+ return ret;
+}
+
+
+
+static int spi_read_int(uint32_t *int_status)
+{
+ int ret;
+ if (g_spi.has_thrpt_enh) {
+ ret = spi_internal_read(0xe840 - WILC_SPI_REG_BASE, int_status);
+ } else {
+ uint32_t tmp;
+ uint32_t byte_cnt;
+
+ ret = spi_read_reg(WILC_VMM_TO_HOST_SIZE, &byte_cnt);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed read WILC_VMM_TO_HOST_SIZE ...\n");
+ goto _fail_;
+ }
+ tmp = (byte_cnt >> 2) & IRQ_DMA_WD_CNT_MASK;
+
+ {
+ int happended, j;
+
+ j = 0;
+ do {
+ uint32_t irq_flags;
+
+ happended = 0;
+
+ spi_read_reg(0x1a90, &irq_flags);
+ tmp |= ((irq_flags >> 27) << IRG_FLAGS_OFFSET);
+
+ if (g_spi.nint > 5) {
+ spi_read_reg(0x1a94, &irq_flags);
+ tmp |= (((irq_flags >> 0) & 0x7) << (IRG_FLAGS_OFFSET + 5));
+ }
+
+ {
+ uint32_t unkmown_mask;
+
+ unkmown_mask = ~((1ul << g_spi.nint) - 1);
+
+ if ((tmp >> IRG_FLAGS_OFFSET) & unkmown_mask) {
+ PRINT_ER("[wilc spi]: Unexpected interrupt (2): j=%d, tmp=%x, mask=%x\n", j, tmp, unkmown_mask);
+ happended = 1;
+ }
+ }
+ j++;
+ } while (happended);
+ }
+
+ *int_status = tmp;
+
+ }
+
+_fail_:
+ return ret;
+}
+
+static int spi_clear_int_ext(uint32_t val)
+{
+ int ret;
+
+ if (g_spi.has_thrpt_enh) {
+ ret = spi_internal_write(0xe844 - WILC_SPI_REG_BASE, val);
+ } else {
+ uint32_t flags;
+ flags = val & ((1 << MAX_NUM_INT) - 1);
+ if (flags) {
+ int i;
+
+ ret = 1;
+ for (i = 0; i < g_spi.nint; i++) {
+ /* No matter what you write 1 or 0, it will clear interrupt. */
+ if (flags & 1)
+ ret = spi_write_reg(0x10c8 + i * 4, 1);
+ if (!ret)
+ break;
+ flags >>= 1;
+ }
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed spi_write_reg, set reg %x ...\n", 0x10c8 + i * 4);
+ goto _fail_;
+ }
+ for (i = g_spi.nint; i < MAX_NUM_INT; i++) {
+ if (flags & 1)
+ PRINT_ER("[wilc spi]: Unexpected interrupt cleared %d...\n", i);
+ flags >>= 1;
+ }
+ }
+
+ {
+ uint32_t tbl_ctl;
+
+ tbl_ctl = 0;
+ /* select VMM table 0 */
+ if ((val & SEL_VMM_TBL0) == SEL_VMM_TBL0)
+ tbl_ctl |= (1 << 0);
+ /* select VMM table 1 */
+ if ((val & SEL_VMM_TBL1) == SEL_VMM_TBL1)
+ tbl_ctl |= (1 << 1);
+
+ ret = spi_write_reg(WILC_VMM_TBL_CTL, tbl_ctl);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: fail write reg vmm_tbl_ctl...\n");
+ goto _fail_;
+ }
+
+ if ((val & EN_VMM) == EN_VMM) {
+ /**
+ * enable vmm transfer.
+ **/
+ ret = spi_write_reg(WILC_VMM_CORE_CTL, 1);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: fail write reg vmm_core_ctl...\n");
+ goto _fail_;
+ }
+ }
+ }
+ }
+_fail_:
+ return ret;
+}
+
+static int spi_sync_ext(int nint /* how mant interrupts to enable. */)
+{
+ uint32_t reg;
+ int ret, i;
+
+ if (nint > MAX_NUM_INT) {
+ PRINT_ER("[wilc spi]: Too many interupts (%d)...\n", nint);
+ return 0;
+ }
+
+ g_spi.nint = nint;
+
+ /**
+ * interrupt pin mux select
+ **/
+ ret = spi_read_reg(WILC_PIN_MUX_0, &reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_PIN_MUX_0);
+ return 0;
+ }
+ reg |= (1 << 8);
+ ret = spi_write_reg(WILC_PIN_MUX_0, reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_PIN_MUX_0);
+ return 0;
+ }
+
+ /**
+ * interrupt enable
+ **/
+ ret = spi_read_reg(WILC_INTR_ENABLE, &reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR_ENABLE);
+ return 0;
+ }
+
+ for (i = 0; (i < 5) && (nint > 0); i++, nint--) {
+ reg |= (1 << (27 + i));
+ }
+ ret = spi_write_reg(WILC_INTR_ENABLE, reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR_ENABLE);
+ return 0;
+ }
+ if (nint) {
+ ret = spi_read_reg(WILC_INTR2_ENABLE, &reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed read reg (%08x)...\n", WILC_INTR2_ENABLE);
+ return 0;
+ }
+
+ for (i = 0; (i < 3) && (nint > 0); i++, nint--) {
+ reg |= (1 << i);
+ }
+
+ ret = spi_read_reg(WILC_INTR2_ENABLE, &reg);
+ if (!ret) {
+ PRINT_ER("[wilc spi]: Failed write reg (%08x)...\n", WILC_INTR2_ENABLE);
+ return 0;
+ }
+ }
+
+ return 1;
+}
+/********************************************
+ *
+ * Global spi HIF function table
+ *
+ ********************************************/
+wilc_hif_func_t hif_spi = {
+ spi_init,
+ spi_deinit,
+ spi_read_reg,
+ spi_write_reg,
+ spi_read,
+ spi_write,
+ spi_sync,
+ spi_clear_int,
+ spi_read_int,
+ spi_clear_int_ext,
+ spi_read_size,
+ spi_write,
+ spi_read,
+ spi_sync_ext,
+ spi_max_bus_speed,
+ spi_default_bus_speed,
+};
+
diff --git a/drivers/staging/wilc1000/wilc_strutils.c b/drivers/staging/wilc1000/wilc_strutils.c
new file mode 100644
index 00000000000000..c6af13cba54397
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_strutils.c
@@ -0,0 +1,80 @@
+
+#define _CRT_SECURE_NO_DEPRECATE
+
+#include "wilc_oswrapper.h"
+
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32Count)
+{
+ return memcmp(pvArg1, pvArg2, u32Count);
+}
+
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count)
+{
+ memcpy(pvTarget, pvSource, u32Count);
+}
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+void *WILC_memset(void *pvTarget, u8 u8SetValue, WILC_Uint32 u32Count)
+{
+ return memset(pvTarget, u8SetValue, u32Count);
+}
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource,
+ WILC_Uint32 u32Count)
+{
+ return strncpy(pcTarget, pcSource, u32Count);
+}
+
+WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2,
+ WILC_Uint32 u32Count)
+{
+ WILC_Sint32 s32Result;
+
+ if (pcStr1 == NULL && pcStr2 == NULL) {
+ s32Result = 0;
+ } else if (pcStr1 == NULL) {
+ s32Result = -1;
+ } else if (pcStr2 == NULL) {
+ s32Result = 1;
+ } else {
+ s32Result = strncmp(pcStr1, pcStr2, u32Count);
+ if (s32Result < 0) {
+ s32Result = -1;
+ } else if (s32Result > 0) {
+ s32Result = 1;
+ }
+ }
+
+ return s32Result;
+}
+
+/*!
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+WILC_Uint32 WILC_strlen(const WILC_Char *pcStr)
+{
+ return (WILC_Uint32)strlen(pcStr);
+}
diff --git a/drivers/staging/wilc1000/wilc_strutils.h b/drivers/staging/wilc1000/wilc_strutils.h
new file mode 100644
index 00000000000000..ddc54ab21f67bd
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_strutils.h
@@ -0,0 +1,130 @@
+#ifndef __WILC_STRUTILS_H__
+#define __WILC_STRUTILS_H__
+
+/*!
+ * @file wilc_strutils.h
+ * @brief Basic string utilities
+ * @author syounan
+ * @sa wilc_oswrapper.h top level OS wrapper file
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+
+/*!
+ * @brief Compares two memory buffers
+ * @param[in] pvArg1 pointer to the first memory location
+ * @param[in] pvArg2 pointer to the second memory location
+ * @param[in] u32Count the size of the memory buffers
+ * @return 0 if the 2 buffers are equal, 1 if pvArg1 is bigger than pvArg2,
+ * -1 if pvArg1 smaller than pvArg2
+ * @note this function repeats the functionality of standard memcmp
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+WILC_Sint32 WILC_memcmp(const void *pvArg1, const void *pvArg2, WILC_Uint32 u32Count);
+
+/*!
+ * @brief Internal implementation for memory copy
+ * @param[in] pvTarget the target buffer to which the data is copied into
+ * @param[in] pvSource pointer to the second memory location
+ * @param[in] u32Count the size of the data to copy
+ * @note this function should not be used directly, use WILC_memcpy instead
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+void WILC_memcpy_INTERNAL(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count);
+
+/*!
+ * @brief Copies the contents of a memory buffer into another
+ * @param[in] pvTarget the target buffer to which the data is copied into
+ * @param[in] pvSource pointer to the second memory location
+ * @param[in] u32Count the size of the data to copy
+ * @return WILC_SUCCESS if copy is successfully handeled
+ * WILC_FAIL if copy failed
+ * @note this function repeats the functionality of standard memcpy,
+ * however memcpy is undefined if the two buffers overlap but this
+ * implementation will check for overlap and report error
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+static WILC_ErrNo WILC_memcpy(void *pvTarget, const void *pvSource, WILC_Uint32 u32Count)
+{
+ if (
+ (((u8 *)pvTarget <= (u8 *)pvSource)
+ && (((u8 *)pvTarget + u32Count) > (u8 *)pvSource))
+
+ || (((u8 *)pvSource <= (u8 *)pvTarget)
+ && (((u8 *)pvSource + u32Count) > (u8 *)pvTarget))
+ ) {
+ /* ovelapped memory, return Error */
+ return WILC_FAIL;
+ } else {
+ WILC_memcpy_INTERNAL(pvTarget, pvSource, u32Count);
+ return WILC_SUCCESS;
+ }
+}
+
+/*!
+ * @brief Sets the contents of a memory buffer with the given value
+ * @param[in] pvTarget the target buffer which contsnts will be set
+ * @param[in] u8SetValue the value to be used
+ * @param[in] u32Count the size of the memory buffer
+ * @return value of pvTarget
+ * @note this function repeats the functionality of standard memset
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+void *WILC_memset(void *pvTarget, u8 u8SetValue, WILC_Uint32 u32Count);
+
+/*!
+ * @brief copies the contents of source string into the target string
+ * @param[in] pcTarget the target string buffer
+ * @param[in] pcSource the source string the will be copied
+ * @param[in] u32Count copying will proceed until a null character in pcSource
+ * is encountered or u32Count of bytes copied
+ * @return value of pcTarget
+ * @note this function repeats the functionality of standard strncpy
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+WILC_Char *WILC_strncpy(WILC_Char *pcTarget, const WILC_Char *pcSource,
+ WILC_Uint32 u32Count);
+
+/*!
+ * @brief Compares two strings up to u32Count characters
+ * @details Compares 2 strings reporting which is bigger, NULL is considered
+ * the smallest string, then a zero length string then all other
+ * strings depending on thier ascii characters order with small case
+ * converted to uppder case
+ * @param[in] pcStr1 the first string, NULL is valid and considered smaller
+ * than any other non-NULL string (incliding zero lenght strings)
+ * @param[in] pcStr2 the second string, NULL is valid and considered smaller
+ * than any other non-NULL string (incliding zero lenght strings)
+ * @param[in] u32Count copying will proceed until a null character in pcStr1 or
+ * pcStr2 is encountered or u32Count of bytes copied
+ * @return 0 if the 2 strings are equal, 1 if pcStr1 is bigger than pcStr2,
+ * -1 if pcStr1 smaller than pcStr2
+ * @author aabozaeid
+ * @date 7 Dec 2010
+ * @version 1.0
+ */
+WILC_Sint32 WILC_strncmp(const WILC_Char *pcStr1, const WILC_Char *pcStr2,
+ WILC_Uint32 u32Count);
+
+/*!
+ * @brief gets the length of a string
+ * @param[in] pcStr the string
+ * @return the length
+ * @note this function repeats the functionality of standard strlen
+ * @author syounan
+ * @date 18 Aug 2010
+ * @version 1.0
+ */
+WILC_Uint32 WILC_strlen(const WILC_Char *pcStr);
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_timer.c b/drivers/staging/wilc1000/wilc_timer.c
new file mode 100644
index 00000000000000..7d2e6f19c00b2d
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_timer.c
@@ -0,0 +1,45 @@
+
+#include "wilc_oswrapper.h"
+
+WILC_ErrNo WILC_TimerCreate(WILC_TimerHandle *pHandle,
+ tpfWILC_TimerFunction pfCallback, tstrWILC_TimerAttrs *pstrAttrs)
+{
+ WILC_ErrNo s32RetStatus = WILC_SUCCESS;
+ setup_timer(pHandle, (void(*)(unsigned long))pfCallback, 0);
+
+ return s32RetStatus;
+}
+
+WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle,
+ tstrWILC_TimerAttrs *pstrAttrs)
+{
+ WILC_ErrNo s32RetStatus = WILC_FAIL;
+ if (pHandle != NULL) {
+ s32RetStatus = del_timer_sync(pHandle);
+ pHandle = NULL;
+ }
+
+ return s32RetStatus;
+}
+
+
+WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, WILC_Uint32 u32Timeout,
+ void *pvArg, tstrWILC_TimerAttrs *pstrAttrs)
+{
+ WILC_ErrNo s32RetStatus = WILC_FAIL;
+ if (pHandle != NULL) {
+ pHandle->data = (unsigned long)pvArg;
+ s32RetStatus = mod_timer(pHandle, (jiffies + msecs_to_jiffies(u32Timeout)));
+ }
+ return s32RetStatus;
+}
+
+WILC_ErrNo WILC_TimerStop(WILC_TimerHandle *pHandle,
+ tstrWILC_TimerAttrs *pstrAttrs)
+{
+ WILC_ErrNo s32RetStatus = WILC_FAIL;
+ if (pHandle != NULL)
+ s32RetStatus = del_timer(pHandle);
+
+ return s32RetStatus;
+}
diff --git a/drivers/staging/wilc1000/wilc_timer.h b/drivers/staging/wilc1000/wilc_timer.h
new file mode 100644
index 00000000000000..72b27155293ed8
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_timer.h
@@ -0,0 +1,126 @@
+#ifndef __WILC_TIMER_H__
+#define __WILC_TIMER_H__
+
+/*!
+ * @file wilc_timer.h
+ * @brief Timer (One Shot and Periodic) OS wrapper functionality
+ * @author syounan
+ * @sa wilc_oswrapper.h top level OS wrapper file
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+
+typedef void (*tpfWILC_TimerFunction)(void *);
+
+/*!
+ * @struct tstrWILC_TimerAttrs
+ * @brief Timer API options
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+typedef struct {
+ /* a dummy member to avoid compiler errors*/
+ u8 dummy;
+} tstrWILC_TimerAttrs;
+
+/*!
+ * @brief Creates a new timer
+ * @details Timers are a useful utility to execute some callback function
+ * in the future.
+ * A timer object has 3 states : IDLE, PENDING and EXECUTING
+ * IDLE : initial timer state after creation, no execution for the
+ * callback function is planned
+ * PENDING : a request to execute the callback function is made
+ * using WILC_TimerStart.
+ * EXECUTING : the timer has expired and its callback is now
+ * executing, when execution is done the timer returns to PENDING
+ * if the feature CONFIG_WILC_TIMER_PERIODIC is enabled and
+ * the flag tstrWILC_TimerAttrs.bPeriodicTimer is set. otherwise the
+ * timer will return to IDLE
+ * @param[out] pHandle handle to the newly created timer object
+ * @param[in] pfEntry pointer to the callback function to be called when the
+ * timer expires
+ * the underlaying OS may put many restrictions on what can be
+ * called inside a timer's callback, as a general rule no blocking
+ * operations (IO or semaphore Acquision) should be perfomred
+ * It is recommended that the callback will be as short as possible
+ * and only flags other threads to do the actual work
+ * also it should be noted that the underlaying OS maynot give any
+ * guarentees on which contect this callback will execute in
+ * @param[in] pstrAttrs Optional attributes, NULL for default
+ * @return Error code indicating sucess/failure
+ * @sa WILC_TimerAttrs
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+WILC_ErrNo WILC_TimerCreate(WILC_TimerHandle *pHandle,
+ tpfWILC_TimerFunction pfCallback, tstrWILC_TimerAttrs *pstrAttrs);
+
+
+/*!
+ * @brief Destroys a given timer
+ * @details This will destroy a given timer freeing any resources used by it
+ * if the timer was PENDING Then must be cancelled as well(i.e.
+ * goes to IDLE, same effect as calling WILC_TimerCancel first)
+ * if the timer was EXECUTING then the callback will be allowed to
+ * finish first then all resources are freed
+ * @param[in] pHandle handle to the timer object
+ * @param[in] pstrAttrs Optional attributes, NULL for default
+ * @return Error code indicating sucess/failure
+ * @sa WILC_TimerAttrs
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+WILC_ErrNo WILC_TimerDestroy(WILC_TimerHandle *pHandle,
+ tstrWILC_TimerAttrs *pstrAttrs);
+
+/*!
+ * @brief Starts a given timer
+ * @details This function will move the timer to the PENDING state until the
+ * given time expires (in msec) then the callback function will be
+ * executed (timer in EXECUTING state) after execution is dene the
+ * timer either goes to IDLE (if bPeriodicTimer==WILC_FALSE) or
+ * PENDING with same timeout value (if bPeriodicTimer==WILC_TRUE)
+ * @param[in] pHandle handle to the timer object
+ * @param[in] u32Timeout timeout value in msec after witch the callback
+ * function will be executed. Timeout value of 0 is not allowed for
+ * periodic timers
+ * @param[in] pstrAttrs Optional attributes, NULL for default,
+ * set bPeriodicTimer to run this timer as a periodic timer
+ * @return Error code indicating sucess/failure
+ * @sa WILC_TimerAttrs
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+WILC_ErrNo WILC_TimerStart(WILC_TimerHandle *pHandle, WILC_Uint32 u32Timeout, void *pvArg,
+ tstrWILC_TimerAttrs *pstrAttrs);
+
+
+/*!
+ * @brief Stops a given timer
+ * @details This function will move the timer to the IDLE state cancelling
+ * any sheduled callback execution.
+ * if this function is called on a timer already in the IDLE state
+ * it will have no effect.
+ * if this function is called on a timer in EXECUTING state
+ * (callback has already started) it will wait until executing is
+ * done then move the timer to the IDLE state (which is trivial
+ * work if the timer is non periodic)
+ * @param[in] pHandle handle to the timer object
+ * @param[in] pstrAttrs Optional attributes, NULL for default,
+ * @return Error code indicating sucess/failure
+ * @sa WILC_TimerAttrs
+ * @author syounan
+ * @date 16 Aug 2010
+ * @version 1.0
+ */
+WILC_ErrNo WILC_TimerStop(WILC_TimerHandle *pHandle,
+ tstrWILC_TimerAttrs *pstrAttrs);
+
+
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_type.h b/drivers/staging/wilc1000/wilc_type.h
new file mode 100644
index 00000000000000..5f36e7f92cd115
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_type.h
@@ -0,0 +1,34 @@
+/* ////////////////////////////////////////////////////////////////////////// */
+/* */
+/* Copyright (c) Atmel Corporation. All rights reserved. */
+/* */
+/* Module Name: wilc_type.h */
+/* */
+/* */
+/* //////////////////////////////////////////////////////////////////////////// */
+#ifndef WILC_TYPE_H
+#define WILC_TYPE_H
+
+/********************************************
+ *
+ * Type Defines
+ *
+ ********************************************/
+#ifdef WIN32
+typedef char int8_t;
+typedef short int16_t;
+typedef long int32_t;
+typedef unsigned char uint8_t;
+typedef unsigned short uint16_t;
+typedef unsigned long uint32_t;
+#else
+#ifdef _linux_
+/*typedef unsigned char uint8_t;
+ * typedef unsigned short uint16_t;
+ * typedef unsigned long uint32_t;*/
+#include <stdint.h>
+#else
+#include "wilc_oswrapper.h"
+#endif
+#endif
+#endif
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
new file mode 100644
index 00000000000000..30f7b68be8f1ad
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -0,0 +1,4097 @@
+/*!
+ * @file wilc_wfi_cfgopertaions.c
+ * @brief CFG80211 Function Implementation functionality
+ * @author aabouzaeid
+ * mabubakr
+ * mdaftedar
+ * zsalah
+ * @sa wilc_wfi_cfgopertaions.h top level OS wrapper file
+ * @date 31 Aug 2010
+ * @version 1.0
+ */
+
+#include "wilc_wfi_cfgoperations.h"
+#include "wilc_wlan.c"
+#ifdef WILC_SDIO
+#include "linux_wlan_sdio.h" /* tony : for set_wiphy_dev() */
+#endif
+
+
+#define IS_MANAGMEMENT 0x100
+#define IS_MANAGMEMENT_CALLBACK 0x080
+#define IS_MGMT_STATUS_SUCCES 0x040
+#define GET_PKT_OFFSET(a) (((a) >> 22) & 0x1ff)
+
+extern void linux_wlan_free(void *vp);
+extern int linux_wlan_get_firmware(perInterface_wlan_t *p_nic);
+extern void linux_wlan_unlock(void *vp);
+extern WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue);
+
+extern int mac_open(struct net_device *ndev);
+extern int mac_close(struct net_device *ndev);
+
+tstrNetworkInfo astrLastScannedNtwrksShadow[MAX_NUM_SCANNED_NETWORKS_SHADOW];
+WILC_Uint32 u32LastScannedNtwrksCountShadow;
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+WILC_TimerHandle hDuringIpTimer;
+#endif
+WILC_TimerHandle hAgingTimer;
+static u8 op_ifcs;
+extern u8 u8ConnectedSSID[6];
+
+/*BugID_5137*/
+u8 g_wilc_initialized = 1;
+extern linux_wlan_t *g_linux_wlan;
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+extern WILC_Bool g_obtainingIP;
+#endif
+
+#define CHAN2G(_channel, _freq, _flags) { \
+ .band = IEEE80211_BAND_2GHZ, \
+ .center_freq = (_freq), \
+ .hw_value = (_channel), \
+ .flags = (_flags), \
+ .max_antenna_gain = 0, \
+ .max_power = 30, \
+}
+
+/*Frequency range for channels*/
+static struct ieee80211_channel WILC_WFI_2ghz_channels[] = {
+ CHAN2G(1, 2412, 0),
+ CHAN2G(2, 2417, 0),
+ CHAN2G(3, 2422, 0),
+ CHAN2G(4, 2427, 0),
+ CHAN2G(5, 2432, 0),
+ CHAN2G(6, 2437, 0),
+ CHAN2G(7, 2442, 0),
+ CHAN2G(8, 2447, 0),
+ CHAN2G(9, 2452, 0),
+ CHAN2G(10, 2457, 0),
+ CHAN2G(11, 2462, 0),
+ CHAN2G(12, 2467, 0),
+ CHAN2G(13, 2472, 0),
+ CHAN2G(14, 2484, 0),
+};
+
+#define RATETAB_ENT(_rate, _hw_value, _flags) { \
+ .bitrate = (_rate), \
+ .hw_value = (_hw_value), \
+ .flags = (_flags), \
+}
+
+
+/* Table 6 in section 3.2.1.1 */
+static struct ieee80211_rate WILC_WFI_rates[] = {
+ RATETAB_ENT(10, 0, 0),
+ RATETAB_ENT(20, 1, 0),
+ RATETAB_ENT(55, 2, 0),
+ RATETAB_ENT(110, 3, 0),
+ RATETAB_ENT(60, 9, 0),
+ RATETAB_ENT(90, 6, 0),
+ RATETAB_ENT(120, 7, 0),
+ RATETAB_ENT(180, 8, 0),
+ RATETAB_ENT(240, 9, 0),
+ RATETAB_ENT(360, 10, 0),
+ RATETAB_ENT(480, 11, 0),
+ RATETAB_ENT(540, 12, 0),
+};
+
+#ifdef WILC_P2P
+struct p2p_mgmt_data {
+ int size;
+ u8 *buff;
+};
+
+/*Global variable used to state the current connected STA channel*/
+u8 u8WLANChannel = INVALID_CHANNEL;
+
+/*BugID_5442*/
+u8 u8CurrChannel;
+
+u8 u8P2P_oui[] = {0x50, 0x6f, 0x9A, 0x09};
+u8 u8P2Plocalrandom = 0x01;
+u8 u8P2Precvrandom = 0x00;
+u8 u8P2P_vendorspec[] = {0xdd, 0x05, 0x00, 0x08, 0x40, 0x03};
+WILC_Bool bWilc_ie = WILC_FALSE;
+#endif
+
+static struct ieee80211_supported_band WILC_WFI_band_2ghz = {
+ .channels = WILC_WFI_2ghz_channels,
+ .n_channels = ARRAY_SIZE(WILC_WFI_2ghz_channels),
+ .bitrates = WILC_WFI_rates,
+ .n_bitrates = ARRAY_SIZE(WILC_WFI_rates),
+};
+
+
+/*BugID_5137*/
+struct add_key_params {
+ u8 key_idx;
+ bool pairwise;
+ u8 *mac_addr;
+};
+struct add_key_params g_add_gtk_key_params;
+struct wilc_wfi_key g_key_gtk_params;
+struct add_key_params g_add_ptk_key_params;
+struct wilc_wfi_key g_key_ptk_params;
+struct wilc_wfi_wep_key g_key_wep_params;
+u8 g_flushing_in_progress;
+WILC_Bool g_ptk_keys_saved = WILC_FALSE;
+WILC_Bool g_gtk_keys_saved = WILC_FALSE;
+WILC_Bool g_wep_keys_saved = WILC_FALSE;
+
+#define AGING_TIME (9 * 1000)
+#define duringIP_TIME 15000
+
+void clear_shadow_scan(void *pUserVoid)
+{
+ struct WILC_WFI_priv *priv;
+ int i;
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+ if (op_ifcs == 0) {
+ WILC_TimerDestroy(&hAgingTimer, NULL);
+ PRINT_INFO(CORECONFIG_DBG, "destroy aging timer\n");
+
+ for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
+ if (astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs != NULL) {
+ WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs);
+ astrLastScannedNtwrksShadow[u32LastScannedNtwrksCountShadow].pu8IEs = NULL;
+ }
+
+ host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
+ astrLastScannedNtwrksShadow[i].pJoinParams = NULL;
+ }
+ u32LastScannedNtwrksCountShadow = 0;
+ }
+
+}
+
+uint32_t get_rssi_avg(tstrNetworkInfo *pstrNetworkInfo)
+{
+ uint8_t i;
+ int rssi_v = 0;
+ uint8_t num_rssi = (pstrNetworkInfo->strRssi.u8Full) ? NUM_RSSI : (pstrNetworkInfo->strRssi.u8Index);
+
+ for (i = 0; i < num_rssi; i++)
+ rssi_v += pstrNetworkInfo->strRssi.as8RSSI[i];
+
+ rssi_v /= num_rssi;
+ return rssi_v;
+}
+
+void refresh_scan(void *pUserVoid, uint8_t all, WILC_Bool bDirectScan)
+{
+ struct WILC_WFI_priv *priv;
+ struct wiphy *wiphy;
+ struct cfg80211_bss *bss = NULL;
+ int i;
+ int rssi = 0;
+
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+ wiphy = priv->dev->ieee80211_ptr->wiphy;
+
+ for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
+ tstrNetworkInfo *pstrNetworkInfo;
+ pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
+
+
+ if ((!pstrNetworkInfo->u8Found) || all) {
+ WILC_Sint32 s32Freq;
+ struct ieee80211_channel *channel;
+
+ if (pstrNetworkInfo != NULL) {
+
+ s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
+ channel = ieee80211_get_channel(wiphy, s32Freq);
+
+ rssi = get_rssi_avg(pstrNetworkInfo);
+ if (WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7) || bDirectScan) {
+ bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
+ pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
+ (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)rssi) * 100), GFP_KERNEL);
+ cfg80211_put_bss(wiphy, bss);
+ }
+ }
+
+ }
+ }
+
+}
+
+void reset_shadow_found(void *pUserVoid)
+{
+ struct WILC_WFI_priv *priv;
+ int i;
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+ for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
+ astrLastScannedNtwrksShadow[i].u8Found = 0;
+
+ }
+}
+
+void update_scan_time(void *pUserVoid)
+{
+ struct WILC_WFI_priv *priv;
+ int i;
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+ for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
+ astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
+ }
+}
+
+void remove_network_from_shadow(void *pUserVoid)
+{
+ struct WILC_WFI_priv *priv;
+ unsigned long now = jiffies;
+ int i, j;
+
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+
+ for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
+ if (time_after(now, astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan + (unsigned long)(SCAN_RESULT_EXPIRE))) {
+ PRINT_D(CFG80211_DBG, "Network expired in ScanShadow: %s \n", astrLastScannedNtwrksShadow[i].au8ssid);
+
+ if (astrLastScannedNtwrksShadow[i].pu8IEs != NULL) {
+ WILC_FREE(astrLastScannedNtwrksShadow[i].pu8IEs);
+ astrLastScannedNtwrksShadow[i].pu8IEs = NULL;
+ }
+
+ host_int_freeJoinParams(astrLastScannedNtwrksShadow[i].pJoinParams);
+
+ for (j = i; (j < u32LastScannedNtwrksCountShadow - 1); j++) {
+ astrLastScannedNtwrksShadow[j] = astrLastScannedNtwrksShadow[j + 1];
+ }
+ u32LastScannedNtwrksCountShadow--;
+ }
+ }
+
+ PRINT_D(CFG80211_DBG, "Number of cached networks: %d\n", u32LastScannedNtwrksCountShadow);
+ if (u32LastScannedNtwrksCountShadow != 0)
+ WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
+ else
+ PRINT_D(CFG80211_DBG, "No need to restart Aging timer\n");
+}
+
+#ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+void clear_duringIP(void *pUserVoid)
+{
+ PRINT_D(GENERIC_DBG, "GO:IP Obtained , enable scan\n");
+ g_obtainingIP = WILC_FALSE;
+}
+#endif
+
+int8_t is_network_in_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid)
+{
+ struct WILC_WFI_priv *priv;
+ int8_t state = -1;
+ int i;
+
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+ if (u32LastScannedNtwrksCountShadow == 0) {
+ PRINT_D(CFG80211_DBG, "Starting Aging timer\n");
+ WILC_TimerStart(&(hAgingTimer), AGING_TIME, pUserVoid, NULL);
+ state = -1;
+ } else {
+ /* Linear search for now */
+ for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
+ if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
+ pstrNetworkInfo->au8bssid, 6) == 0) {
+ state = i;
+ break;
+ }
+ }
+ }
+ return state;
+}
+
+void add_network_to_shadow(tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
+{
+ struct WILC_WFI_priv *priv;
+ int8_t ap_found = is_network_in_shadow(pstrNetworkInfo, pUserVoid);
+ uint32_t ap_index = 0;
+ uint8_t rssi_index = 0;
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+
+ if (u32LastScannedNtwrksCountShadow >= MAX_NUM_SCANNED_NETWORKS_SHADOW) {
+ PRINT_D(CFG80211_DBG, "Shadow network reached its maximum limit\n");
+ return;
+ }
+ if (ap_found == -1) {
+ ap_index = u32LastScannedNtwrksCountShadow;
+ u32LastScannedNtwrksCountShadow++;
+
+ } else {
+ ap_index = ap_found;
+ }
+ rssi_index = astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index;
+ astrLastScannedNtwrksShadow[ap_index].strRssi.as8RSSI[rssi_index++] = pstrNetworkInfo->s8rssi;
+ if (rssi_index == NUM_RSSI) {
+ rssi_index = 0;
+ astrLastScannedNtwrksShadow[ap_index].strRssi.u8Full = 1;
+ }
+ astrLastScannedNtwrksShadow[ap_index].strRssi.u8Index = rssi_index;
+
+ astrLastScannedNtwrksShadow[ap_index].s8rssi = pstrNetworkInfo->s8rssi;
+ astrLastScannedNtwrksShadow[ap_index].u16CapInfo = pstrNetworkInfo->u16CapInfo;
+
+ astrLastScannedNtwrksShadow[ap_index].u8SsidLen = pstrNetworkInfo->u8SsidLen;
+ WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8ssid,
+ pstrNetworkInfo->au8ssid, pstrNetworkInfo->u8SsidLen);
+
+ WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].au8bssid,
+ pstrNetworkInfo->au8bssid, ETH_ALEN);
+
+ astrLastScannedNtwrksShadow[ap_index].u16BeaconPeriod = pstrNetworkInfo->u16BeaconPeriod;
+ astrLastScannedNtwrksShadow[ap_index].u8DtimPeriod = pstrNetworkInfo->u8DtimPeriod;
+ astrLastScannedNtwrksShadow[ap_index].u8channel = pstrNetworkInfo->u8channel;
+
+ astrLastScannedNtwrksShadow[ap_index].u16IEsLen = pstrNetworkInfo->u16IEsLen;
+ astrLastScannedNtwrksShadow[ap_index].u64Tsf = pstrNetworkInfo->u64Tsf;
+ if (ap_found != -1)
+ WILC_FREE(astrLastScannedNtwrksShadow[ap_index].pu8IEs);
+ astrLastScannedNtwrksShadow[ap_index].pu8IEs =
+ (u8 *)WILC_MALLOC(pstrNetworkInfo->u16IEsLen); /* will be deallocated by the WILC_WFI_CfgScan() function */
+ WILC_memcpy(astrLastScannedNtwrksShadow[ap_index].pu8IEs,
+ pstrNetworkInfo->pu8IEs, pstrNetworkInfo->u16IEsLen);
+
+ astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScan = jiffies;
+ astrLastScannedNtwrksShadow[ap_index].u32TimeRcvdInScanCached = jiffies;
+ astrLastScannedNtwrksShadow[ap_index].u8Found = 1;
+ if (ap_found != -1)
+ host_int_freeJoinParams(astrLastScannedNtwrksShadow[ap_index].pJoinParams);
+ astrLastScannedNtwrksShadow[ap_index].pJoinParams = pJoinParams;
+
+}
+
+
+/**
+ * @brief CfgScanResult
+ * @details Callback function which returns the scan results found
+ *
+ * @param[in] tenuScanEvent enuScanEvent: enum, indicating the scan event triggered, whether that is
+ * SCAN_EVENT_NETWORK_FOUND or SCAN_EVENT_DONE
+ * tstrNetworkInfo* pstrNetworkInfo: structure holding the scan results information
+ * void* pUserVoid: Private structure associated with the wireless interface
+ * @return NONE
+ * @author mabubakr
+ * @date
+ * @version 1.0
+ */
+static void CfgScanResult(tenuScanEvent enuScanEvent, tstrNetworkInfo *pstrNetworkInfo, void *pUserVoid, void *pJoinParams)
+{
+ struct WILC_WFI_priv *priv;
+ struct wiphy *wiphy;
+ WILC_Sint32 s32Freq;
+ struct ieee80211_channel *channel;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct cfg80211_bss *bss = NULL;
+
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+ if (priv->bCfgScanning == WILC_TRUE) {
+ if (enuScanEvent == SCAN_EVENT_NETWORK_FOUND) {
+ wiphy = priv->dev->ieee80211_ptr->wiphy;
+ WILC_NULLCHECK(s32Error, wiphy);
+ if (wiphy->signal_type == CFG80211_SIGNAL_TYPE_UNSPEC
+ &&
+ ((((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100) < 0
+ ||
+ (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100) > 100)
+ ) {
+ WILC_ERRORREPORT(s32Error, WILC_FAIL);
+ }
+
+ if (pstrNetworkInfo != NULL) {
+ s32Freq = ieee80211_channel_to_frequency((WILC_Sint32)pstrNetworkInfo->u8channel, IEEE80211_BAND_2GHZ);
+ channel = ieee80211_get_channel(wiphy, s32Freq);
+
+ WILC_NULLCHECK(s32Error, channel);
+
+ PRINT_INFO(CFG80211_DBG, "Network Info:: CHANNEL Frequency: %d, RSSI: %d, CapabilityInfo: %d,"
+ "BeaconPeriod: %d \n", channel->center_freq, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100),
+ pstrNetworkInfo->u16CapInfo, pstrNetworkInfo->u16BeaconPeriod);
+
+ if (pstrNetworkInfo->bNewNetwork == WILC_TRUE) {
+ if (priv->u32RcvdChCount < MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
+ /* max_scan_ssids */
+ PRINT_D(CFG80211_DBG, "Network %s found\n", pstrNetworkInfo->au8ssid);
+
+
+ priv->u32RcvdChCount++;
+
+
+
+ if (pJoinParams == NULL) {
+ PRINT_INFO(CORECONFIG_DBG, ">> Something really bad happened\n");
+ }
+ add_network_to_shadow(pstrNetworkInfo, priv, pJoinParams);
+
+ /*P2P peers are sent to WPA supplicant and added to shadow table*/
+
+ if (!(WILC_memcmp("DIRECT-", pstrNetworkInfo->au8ssid, 7))) {
+ bss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, pstrNetworkInfo->au8bssid, pstrNetworkInfo->u64Tsf, pstrNetworkInfo->u16CapInfo,
+ pstrNetworkInfo->u16BeaconPeriod, (const u8 *)pstrNetworkInfo->pu8IEs,
+ (size_t)pstrNetworkInfo->u16IEsLen, (((WILC_Sint32)pstrNetworkInfo->s8rssi) * 100), GFP_KERNEL);
+ cfg80211_put_bss(wiphy, bss);
+ }
+
+
+ } else {
+ PRINT_ER("Discovered networks exceeded the max limit\n");
+ }
+ } else {
+ WILC_Uint32 i;
+ /* So this network is discovered before, we'll just update its RSSI */
+ for (i = 0; i < priv->u32RcvdChCount; i++) {
+ if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid, pstrNetworkInfo->au8bssid, 6) == 0) {
+ PRINT_D(CFG80211_DBG, "Update RSSI of %s \n", astrLastScannedNtwrksShadow[i].au8ssid);
+
+ astrLastScannedNtwrksShadow[i].s8rssi = pstrNetworkInfo->s8rssi;
+ astrLastScannedNtwrksShadow[i].u32TimeRcvdInScan = jiffies;
+ break;
+ }
+ }
+ }
+ }
+ } else if (enuScanEvent == SCAN_EVENT_DONE) {
+ PRINT_D(CFG80211_DBG, "Scan Done[%p] \n", priv->dev);
+ PRINT_D(CFG80211_DBG, "Refreshing Scan ... \n");
+ refresh_scan(priv, 1, WILC_FALSE);
+
+ if (priv->u32RcvdChCount > 0) {
+ PRINT_D(CFG80211_DBG, "%d Network(s) found \n", priv->u32RcvdChCount);
+ } else {
+ PRINT_D(CFG80211_DBG, "No networks found \n");
+ }
+
+ down(&(priv->hSemScanReq));
+
+ if (priv->pstrScanReq != NULL) {
+ cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE);
+ priv->u32RcvdChCount = 0;
+ priv->bCfgScanning = WILC_FALSE;
+ priv->pstrScanReq = NULL;
+ }
+ up(&(priv->hSemScanReq));
+
+ }
+ /*Aborting any scan operation during mac close*/
+ else if (enuScanEvent == SCAN_EVENT_ABORTED) {
+ down(&(priv->hSemScanReq));
+
+ PRINT_D(CFG80211_DBG, "Scan Aborted \n");
+ if (priv->pstrScanReq != NULL) {
+
+ update_scan_time(priv);
+ refresh_scan(priv, 1, WILC_FALSE);
+
+ cfg80211_scan_done(priv->pstrScanReq, WILC_FALSE);
+ priv->bCfgScanning = WILC_FALSE;
+ priv->pstrScanReq = NULL;
+ }
+ up(&(priv->hSemScanReq));
+ }
+ }
+
+
+ WILC_CATCH(s32Error)
+ {
+ }
+}
+
+
+/**
+ * @brief WILC_WFI_Set_PMKSA
+ * @details Check if pmksa is cached and set it.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_Set_PMKSA(u8 *bssid, struct WILC_WFI_priv *priv)
+{
+ WILC_Uint32 i;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+
+ for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
+
+ if (!WILC_memcmp(bssid, priv->pmkid_list.pmkidlist[i].bssid,
+ ETH_ALEN)) {
+ PRINT_D(CFG80211_DBG, "PMKID successful comparison");
+
+ /*If bssid is found, set the values*/
+ s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
+
+ if (s32Error != WILC_SUCCESS)
+ PRINT_ER("Error in pmkid\n");
+
+ break;
+ }
+ }
+
+ return s32Error;
+
+
+}
+int linux_wlan_set_bssid(struct net_device *wilc_netdev, uint8_t *pBSSID);
+
+
+/**
+ * @brief CfgConnectResult
+ * @details
+ * @param[in] tenuConnDisconnEvent enuConnDisconnEvent: Type of connection response either
+ * connection response or disconnection notification.
+ * tstrConnectInfo* pstrConnectInfo: COnnection information.
+ * u8 u8MacStatus: Mac Status from firmware
+ * tstrDisconnectNotifInfo* pstrDisconnectNotifInfo: Disconnection Notification
+ * void* pUserVoid: Private data associated with wireless interface
+ * @return NONE
+ * @author mabubakr
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int connecting;
+
+static void CfgConnectResult(tenuConnDisconnEvent enuConnDisconnEvent,
+ tstrConnectInfo *pstrConnectInfo,
+ u8 u8MacStatus,
+ tstrDisconnectNotifInfo *pstrDisconnectNotifInfo,
+ void *pUserVoid)
+{
+ struct WILC_WFI_priv *priv;
+ struct net_device *dev;
+ #ifdef WILC_P2P
+ tstrWILC_WFIDrv *pstrWFIDrv;
+ #endif
+ u8 NullBssid[ETH_ALEN] = {0};
+ connecting = 0;
+
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+ dev = priv->dev;
+ #ifdef WILC_P2P
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+ #endif
+
+ if (enuConnDisconnEvent == CONN_DISCONN_EVENT_CONN_RESP) {
+ /*Initialization*/
+ WILC_Uint16 u16ConnectStatus = WLAN_STATUS_SUCCESS;
+
+ u16ConnectStatus = pstrConnectInfo->u16ConnectStatus;
+
+ PRINT_D(CFG80211_DBG, " Connection response received = %d\n", u8MacStatus);
+
+ if ((u8MacStatus == MAC_DISCONNECTED) &&
+ (pstrConnectInfo->u16ConnectStatus == SUCCESSFUL_STATUSCODE)) {
+ /* The case here is that our station was waiting for association response frame and has just received it containing status code
+ * = SUCCESSFUL_STATUSCODE, while mac status is MAC_DISCONNECTED (which means something wrong happened) */
+ u16ConnectStatus = WLAN_STATUS_UNSPECIFIED_FAILURE;
+ linux_wlan_set_bssid(priv->dev, NullBssid);
+ WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
+
+ /*BugID_5457*/
+ /*Invalidate u8WLANChannel value on wlan0 disconnect*/
+ #ifdef WILC_P2P
+ if (!pstrWFIDrv->u8P2PConnect)
+ u8WLANChannel = INVALID_CHANNEL;
+ #endif
+
+ PRINT_ER("Unspecified failure: Connection status %d : MAC status = %d \n", u16ConnectStatus, u8MacStatus);
+ }
+
+ if (u16ConnectStatus == WLAN_STATUS_SUCCESS) {
+ WILC_Bool bNeedScanRefresh = WILC_FALSE;
+ WILC_Uint32 i;
+
+ PRINT_INFO(CFG80211_DBG, "Connection Successful:: BSSID: %x%x%x%x%x%x\n", pstrConnectInfo->au8bssid[0],
+ pstrConnectInfo->au8bssid[1], pstrConnectInfo->au8bssid[2], pstrConnectInfo->au8bssid[3], pstrConnectInfo->au8bssid[4], pstrConnectInfo->au8bssid[5]);
+ WILC_memcpy(priv->au8AssociatedBss, pstrConnectInfo->au8bssid, ETH_ALEN);
+
+ /* set bssid in frame filter */
+ /* linux_wlan_set_bssid(dev,pstrConnectInfo->au8bssid); */
+
+ /* BugID_4209: if this network has expired in the scan results in the above nl80211 layer, refresh them here by calling
+ * cfg80211_inform_bss() with the last Scan results before calling cfg80211_connect_result() to avoid
+ * Linux kernel warning generated at the nl80211 layer */
+
+ for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
+ if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
+ pstrConnectInfo->au8bssid, ETH_ALEN) == 0) {
+ unsigned long now = jiffies;
+
+ if (time_after(now,
+ astrLastScannedNtwrksShadow[i].u32TimeRcvdInScanCached + (unsigned long)(nl80211_SCAN_RESULT_EXPIRE - (1 * HZ)))) {
+ bNeedScanRefresh = WILC_TRUE;
+ }
+
+ break;
+ }
+ }
+
+ if (bNeedScanRefresh == WILC_TRUE) {
+ /* RefreshScanResult(priv); */
+ /*BugID_5418*/
+ /*Also, refrsh DIRECT- results if */
+ refresh_scan(priv, 1, WILC_TRUE);
+
+ }
+
+ }
+
+
+ PRINT_D(CFG80211_DBG, "Association request info elements length = %d\n", pstrConnectInfo->ReqIEsLen);
+
+ PRINT_D(CFG80211_DBG, "Association response info elements length = %d\n", pstrConnectInfo->u16RespIEsLen);
+
+ cfg80211_connect_result(dev, pstrConnectInfo->au8bssid,
+ pstrConnectInfo->pu8ReqIEs, pstrConnectInfo->ReqIEsLen,
+ pstrConnectInfo->pu8RespIEs, pstrConnectInfo->u16RespIEsLen,
+ u16ConnectStatus, GFP_KERNEL); /* TODO: mostafa: u16ConnectStatus to */
+ /* be replaced by pstrConnectInfo->u16ConnectStatus */
+ } else if (enuConnDisconnEvent == CONN_DISCONN_EVENT_DISCONN_NOTIF) {
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ g_obtainingIP = WILC_FALSE;
+ #endif
+ PRINT_ER("Received MAC_DISCONNECTED from firmware with reason %d on dev [%p]\n",
+ pstrDisconnectNotifInfo->u16reason, priv->dev);
+ u8P2Plocalrandom = 0x01;
+ u8P2Precvrandom = 0x00;
+ bWilc_ie = WILC_FALSE;
+ WILC_memset(priv->au8AssociatedBss, 0, ETH_ALEN);
+ linux_wlan_set_bssid(priv->dev, NullBssid);
+ WILC_memset(u8ConnectedSSID, 0, ETH_ALEN);
+
+ /*BugID_5457*/
+ /*Invalidate u8WLANChannel value on wlan0 disconnect*/
+ #ifdef WILC_P2P
+ if (!pstrWFIDrv->u8P2PConnect)
+ u8WLANChannel = INVALID_CHANNEL;
+ #endif
+ /*BugID_5315*/
+ /*Incase "P2P CLIENT Connected" send deauthentication reason by 3 to force the WPA_SUPPLICANT to directly change
+ * virtual interface to station*/
+ if ((pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
+ pstrDisconnectNotifInfo->u16reason = 3;
+ }
+ /*BugID_5315*/
+ /*Incase "P2P CLIENT during connection(not connected)" send deauthentication reason by 1 to force the WPA_SUPPLICANT
+ * to scan again and retry the connection*/
+ else if ((!pstrWFIDrv->IFC_UP) && (dev == g_linux_wlan->strInterfaceInfo[1].wilc_netdev)) {
+ pstrDisconnectNotifInfo->u16reason = 1;
+ }
+ cfg80211_disconnected(dev, pstrDisconnectNotifInfo->u16reason, pstrDisconnectNotifInfo->ie,
+ pstrDisconnectNotifInfo->ie_len, true, GFP_KERNEL);
+
+ }
+
+}
+
+
+/**
+ * @brief WILC_WFI_CfgSetChannel
+ * @details Set channel for a given wireless interface. Some devices
+ * may support multi-channel operation (by channel hopping) so cfg80211
+ * doesn't verify much. Note, however, that the passed netdev may be
+ * %NULL as well if the user requested changing the channel for the
+ * device itself, or for a monitor interface.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_CfgSetChannel(struct wiphy *wiphy,
+ struct cfg80211_chan_def *chandef)
+{
+
+ WILC_Uint32 channelnum = 0;
+ struct WILC_WFI_priv *priv;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ priv = wiphy_priv(wiphy);
+
+ channelnum = ieee80211_frequency_to_channel(chandef->chan->center_freq);
+ PRINT_D(CFG80211_DBG, "Setting channel %d with frequency %d\n", channelnum, chandef->chan->center_freq);
+
+ u8CurrChannel = channelnum;
+ s32Error = host_int_set_mac_chnl_num(priv->hWILCWFIDrv, channelnum);
+
+ if (s32Error != WILC_SUCCESS)
+ PRINT_ER("Error in setting channel %d\n", channelnum);
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_CfgScan
+ * @details Request to do a scan. If returning zero, the scan request is given
+ * the driver, and will be valid until passed to cfg80211_scan_done().
+ * For scan results, call cfg80211_inform_bss(); you can call this outside
+ * the scan/scan_done bracket too.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mabubakr
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+
+/*
+ * kernel version 3.8.8 supported
+ * tony, sswd, WILC-KR, 2013-10-29
+ */
+static int WILC_WFI_CfgScan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
+{
+ struct WILC_WFI_priv *priv;
+ WILC_Uint32 i;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ u8 au8ScanChanList[MAX_NUM_SCANNED_NETWORKS];
+ tstrHiddenNetwork strHiddenNetwork;
+
+ priv = wiphy_priv(wiphy);
+
+ /*if(connecting)
+ * return -EBUSY; */
+
+ /*BugID_4800: if in AP mode, return.*/
+ /*This check is to handle the situation when user*/
+ /*requests "create group" during a running scan*/
+ /* host_int_set_wfi_drv_handler(priv->hWILCWFIDrv); */
+#if 0
+ if (priv->dev->ieee80211_ptr->iftype == NL80211_IFTYPE_AP) {
+ PRINT_D(GENERIC_DBG, "Required scan while in AP mode");
+ return s32Error;
+ }
+#endif /* end of if 0 */
+ priv->pstrScanReq = request;
+
+ priv->u32RcvdChCount = 0;
+
+ host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv);
+
+
+ reset_shadow_found(priv);
+
+ priv->bCfgScanning = WILC_TRUE;
+ if (request->n_channels <= MAX_NUM_SCANNED_NETWORKS) { /* TODO: mostafa: to be replaced by */
+ /* max_scan_ssids */
+ for (i = 0; i < request->n_channels; i++) {
+ au8ScanChanList[i] = (u8)ieee80211_frequency_to_channel(request->channels[i]->center_freq);
+ PRINT_INFO(CFG80211_DBG, "ScanChannel List[%d] = %d,", i, au8ScanChanList[i]);
+ }
+
+ PRINT_D(CFG80211_DBG, "Requested num of scan channel %d\n", request->n_channels);
+ PRINT_D(CFG80211_DBG, "Scan Request IE len = %d\n", request->ie_len);
+
+ PRINT_D(CFG80211_DBG, "Number of SSIDs %d\n", request->n_ssids);
+
+ if (request->n_ssids >= 1) {
+
+
+ strHiddenNetwork.pstrHiddenNetworkInfo = WILC_MALLOC(request->n_ssids * sizeof(tstrHiddenNetwork));
+ strHiddenNetwork.u8ssidnum = request->n_ssids;
+
+
+ /*BugID_4156*/
+ for (i = 0; i < request->n_ssids; i++) {
+
+ if (request->ssids[i].ssid != NULL && request->ssids[i].ssid_len != 0) {
+ strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid = WILC_MALLOC(request->ssids[i].ssid_len);
+ WILC_memcpy(strHiddenNetwork.pstrHiddenNetworkInfo[i].pu8ssid, request->ssids[i].ssid, request->ssids[i].ssid_len);
+ strHiddenNetwork.pstrHiddenNetworkInfo[i].u8ssidlen = request->ssids[i].ssid_len;
+ } else {
+ PRINT_D(CFG80211_DBG, "Received one NULL SSID \n");
+ strHiddenNetwork.u8ssidnum -= 1;
+ }
+ }
+ PRINT_D(CFG80211_DBG, "Trigger Scan Request \n");
+ s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
+ au8ScanChanList, request->n_channels,
+ (const u8 *)request->ie, request->ie_len,
+ CfgScanResult, (void *)priv, &strHiddenNetwork);
+ } else {
+ PRINT_D(CFG80211_DBG, "Trigger Scan Request \n");
+ s32Error = host_int_scan(priv->hWILCWFIDrv, USER_SCAN, ACTIVE_SCAN,
+ au8ScanChanList, request->n_channels,
+ (const u8 *)request->ie, request->ie_len,
+ CfgScanResult, (void *)priv, NULL);
+ }
+
+ } else {
+ PRINT_ER("Requested num of scanned channels is greater than the max, supported"
+ " channels \n");
+ }
+
+ if (s32Error != WILC_SUCCESS) {
+ s32Error = -EBUSY;
+ PRINT_WRN(CFG80211_DBG, "Device is busy: Error(%d)\n", s32Error);
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_CfgConnect
+ * @details Connect to the ESS with the specified parameters. When connected,
+ * call cfg80211_connect_result() with status code %WLAN_STATUS_SUCCESS.
+ * If the connection fails for some reason, call cfg80211_connect_result()
+ * with the status from the AP.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mabubakr
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_CfgConnect(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_connect_params *sme)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ WILC_Uint32 i;
+ /* SECURITY_T tenuSecurity_t = NO_SECURITY; */
+ u8 u8security = NO_ENCRYPT;
+ AUTHTYPE_T tenuAuth_type = ANY;
+ WILC_Char *pcgroup_encrypt_val;
+ WILC_Char *pccipher_group;
+ WILC_Char *pcwpa_version;
+
+ struct WILC_WFI_priv *priv;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+ tstrNetworkInfo *pstrNetworkInfo = NULL;
+
+
+ connecting = 1;
+ priv = wiphy_priv(wiphy);
+ pstrWFIDrv = (tstrWILC_WFIDrv *)(priv->hWILCWFIDrv);
+
+ host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv);
+
+ /* host_int_set_wfi_drv_handler((WILC_Uint32)priv->hWILCWFIDrv); */
+ PRINT_D(CFG80211_DBG, "Connecting to SSID [%s] on netdev [%p] host if [%x]\n", sme->ssid, dev, (WILC_Uint32)priv->hWILCWFIDrv);
+ #ifdef WILC_P2P
+ if (!(WILC_strncmp(sme->ssid, "DIRECT-", 7))) {
+ PRINT_D(CFG80211_DBG, "Connected to Direct network,OBSS disabled\n");
+ pstrWFIDrv->u8P2PConnect = 1;
+ } else
+ pstrWFIDrv->u8P2PConnect = 0;
+ #endif
+ PRINT_INFO(CFG80211_DBG, "Required SSID = %s\n , AuthType = %d \n", sme->ssid, sme->auth_type);
+
+ for (i = 0; i < u32LastScannedNtwrksCountShadow; i++) {
+ if ((sme->ssid_len == astrLastScannedNtwrksShadow[i].u8SsidLen) &&
+ WILC_memcmp(astrLastScannedNtwrksShadow[i].au8ssid,
+ sme->ssid,
+ sme->ssid_len) == 0) {
+ PRINT_INFO(CFG80211_DBG, "Network with required SSID is found %s\n", sme->ssid);
+ if (sme->bssid == NULL) {
+ /* BSSID is not passed from the user, so decision of matching
+ * is done by SSID only */
+ PRINT_INFO(CFG80211_DBG, "BSSID is not passed from the user\n");
+ break;
+ } else {
+ /* BSSID is also passed from the user, so decision of matching
+ * should consider also this passed BSSID */
+ if (WILC_memcmp(astrLastScannedNtwrksShadow[i].au8bssid,
+ sme->bssid,
+ ETH_ALEN) == 0) {
+ PRINT_INFO(CFG80211_DBG, "BSSID is passed from the user and matched\n");
+ break;
+ }
+ }
+ }
+ }
+
+ if (i < u32LastScannedNtwrksCountShadow) {
+ PRINT_D(CFG80211_DBG, "Required bss is in scan results\n");
+
+ pstrNetworkInfo = &(astrLastScannedNtwrksShadow[i]);
+
+ PRINT_INFO(CFG80211_DBG, "network BSSID to be associated: %x%x%x%x%x%x\n",
+ pstrNetworkInfo->au8bssid[0], pstrNetworkInfo->au8bssid[1],
+ pstrNetworkInfo->au8bssid[2], pstrNetworkInfo->au8bssid[3],
+ pstrNetworkInfo->au8bssid[4], pstrNetworkInfo->au8bssid[5]);
+ } else {
+ s32Error = -ENOENT;
+ if (u32LastScannedNtwrksCountShadow == 0)
+ PRINT_D(CFG80211_DBG, "No Scan results yet\n");
+ else
+ PRINT_D(CFG80211_DBG, "Required bss not in scan results: Error(%d)\n", s32Error);
+
+ goto done;
+ }
+
+ priv->WILC_WFI_wep_default = 0;
+ WILC_memset(priv->WILC_WFI_wep_key, 0, sizeof(priv->WILC_WFI_wep_key));
+ WILC_memset(priv->WILC_WFI_wep_key_len, 0, sizeof(priv->WILC_WFI_wep_key_len));
+
+ PRINT_INFO(CFG80211_DBG, "sme->crypto.wpa_versions=%x\n", sme->crypto.wpa_versions);
+ PRINT_INFO(CFG80211_DBG, "sme->crypto.cipher_group=%x\n", sme->crypto.cipher_group);
+
+ PRINT_INFO(CFG80211_DBG, "sme->crypto.n_ciphers_pairwise=%d\n", sme->crypto.n_ciphers_pairwise);
+
+ if (INFO) {
+ for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++)
+ PRINT_D(CORECONFIG_DBG, "sme->crypto.ciphers_pairwise[%d]=%x\n", i, sme->crypto.ciphers_pairwise[i]);
+ }
+
+ if (sme->crypto.cipher_group != NO_ENCRYPT) {
+ /* To determine the u8security value, first we check the group cipher suite then {in case of WPA or WPA2}
+ * we will add to it the pairwise cipher suite(s) */
+ pcwpa_version = "Default";
+ PRINT_D(CORECONFIG_DBG, ">> sme->crypto.wpa_versions: %x\n", sme->crypto.wpa_versions);
+ /* case NL80211_WPA_VERSION_1: */
+ if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP40) {
+ /* tenuSecurity_t = WEP_40; */
+ u8security = ENCRYPT_ENABLED | WEP;
+ pcgroup_encrypt_val = "WEP40";
+ pccipher_group = "WLAN_CIPHER_SUITE_WEP40";
+ PRINT_INFO(CFG80211_DBG, "WEP Default Key Idx = %d\n", sme->key_idx);
+
+ if (INFO) {
+ for (i = 0; i < sme->key_len; i++)
+ PRINT_D(CORECONFIG_DBG, "WEP Key Value[%d] = %d\n", i, sme->key[i]);
+ }
+ priv->WILC_WFI_wep_default = sme->key_idx;
+ priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
+ WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
+
+ /*BugID_5137*/
+ g_key_wep_params.key_len = sme->key_len;
+ g_key_wep_params.key = WILC_MALLOC(sme->key_len);
+ memcpy(g_key_wep_params.key, sme->key, sme->key_len);
+ g_key_wep_params.key_idx = sme->key_idx;
+ g_wep_keys_saved = WILC_TRUE;
+
+ host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
+ host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
+ } else if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_WEP104) {
+ /* tenuSecurity_t = WEP_104; */
+ u8security = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
+ pcgroup_encrypt_val = "WEP104";
+ pccipher_group = "WLAN_CIPHER_SUITE_WEP104";
+
+ priv->WILC_WFI_wep_default = sme->key_idx;
+ priv->WILC_WFI_wep_key_len[sme->key_idx] = sme->key_len;
+ WILC_memcpy(priv->WILC_WFI_wep_key[sme->key_idx], sme->key, sme->key_len);
+
+ /*BugID_5137*/
+ g_key_wep_params.key_len = sme->key_len;
+ g_key_wep_params.key = WILC_MALLOC(sme->key_len);
+ memcpy(g_key_wep_params.key, sme->key, sme->key_len);
+ g_key_wep_params.key_idx = sme->key_idx;
+ g_wep_keys_saved = WILC_TRUE;
+
+ host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, sme->key_idx);
+ host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, sme->key, sme->key_len, sme->key_idx);
+ } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2) {
+ /* case NL80211_WPA_VERSION_2: */
+ if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
+ /* tenuSecurity_t = WPA2_TKIP; */
+ u8security = ENCRYPT_ENABLED | WPA2 | TKIP;
+ pcgroup_encrypt_val = "WPA2_TKIP";
+ pccipher_group = "TKIP";
+ } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
+ /* tenuSecurity_t = WPA2_AES; */
+ u8security = ENCRYPT_ENABLED | WPA2 | AES;
+ pcgroup_encrypt_val = "WPA2_AES";
+ pccipher_group = "AES";
+ }
+ pcwpa_version = "WPA_VERSION_2";
+ } else if (sme->crypto.wpa_versions & NL80211_WPA_VERSION_1) {
+ if (sme->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP) {
+ /* tenuSecurity_t = WPA_TKIP; */
+ u8security = ENCRYPT_ENABLED | WPA | TKIP;
+ pcgroup_encrypt_val = "WPA_TKIP";
+ pccipher_group = "TKIP";
+ } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
+ /* tenuSecurity_t = WPA_AES; */
+ u8security = ENCRYPT_ENABLED | WPA | AES;
+ pcgroup_encrypt_val = "WPA_AES";
+ pccipher_group = "AES";
+
+ }
+ pcwpa_version = "WPA_VERSION_1";
+
+ /* break; */
+ } else {
+ s32Error = -ENOTSUPP;
+ PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
+
+ goto done;
+ }
+
+ }
+
+ /* After we set the u8security value from checking the group cipher suite, {in case of WPA or WPA2} we will
+ * add to it the pairwise cipher suite(s) */
+ if ((sme->crypto.wpa_versions & NL80211_WPA_VERSION_1)
+ || (sme->crypto.wpa_versions & NL80211_WPA_VERSION_2)) {
+ for (i = 0; i < sme->crypto.n_ciphers_pairwise; i++) {
+ if (sme->crypto.ciphers_pairwise[i] == WLAN_CIPHER_SUITE_TKIP) {
+ u8security = u8security | TKIP;
+ } else { /* TODO: mostafa: here we assume that any other encryption type is AES */
+ u8security = u8security | AES;
+ }
+ }
+ }
+
+ PRINT_D(CFG80211_DBG, "Adding key with cipher group = %x\n", sme->crypto.cipher_group);
+
+ PRINT_D(CFG80211_DBG, "Authentication Type = %d\n", sme->auth_type);
+ switch (sme->auth_type) {
+ case NL80211_AUTHTYPE_OPEN_SYSTEM:
+ PRINT_D(CFG80211_DBG, "In OPEN SYSTEM\n");
+ tenuAuth_type = OPEN_SYSTEM;
+ break;
+
+ case NL80211_AUTHTYPE_SHARED_KEY:
+ tenuAuth_type = SHARED_KEY;
+ PRINT_D(CFG80211_DBG, "In SHARED KEY\n");
+ break;
+
+ default:
+ PRINT_D(CFG80211_DBG, "Automatic Authentation type = %d\n", sme->auth_type);
+ }
+
+
+ /* ai: key_mgmt: enterprise case */
+ if (sme->crypto.n_akm_suites) {
+ switch (sme->crypto.akm_suites[0]) {
+ case WLAN_AKM_SUITE_8021X:
+ tenuAuth_type = IEEE8021;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+
+ PRINT_INFO(CFG80211_DBG, "Required Channel = %d\n", pstrNetworkInfo->u8channel);
+
+ PRINT_INFO(CFG80211_DBG, "Group encryption value = %s\n Cipher Group = %s\n WPA version = %s\n",
+ pcgroup_encrypt_val, pccipher_group, pcwpa_version);
+
+ /*BugID_5442*/
+ u8CurrChannel = pstrNetworkInfo->u8channel;
+
+ if (!pstrWFIDrv->u8P2PConnect) {
+ u8WLANChannel = pstrNetworkInfo->u8channel;
+ }
+
+ linux_wlan_set_bssid(dev, pstrNetworkInfo->au8bssid);
+
+ s32Error = host_int_set_join_req(priv->hWILCWFIDrv, pstrNetworkInfo->au8bssid, sme->ssid,
+ sme->ssid_len, sme->ie, sme->ie_len,
+ CfgConnectResult, (void *)priv, u8security,
+ tenuAuth_type, pstrNetworkInfo->u8channel,
+ pstrNetworkInfo->pJoinParams);
+ if (s32Error != WILC_SUCCESS) {
+ PRINT_ER("host_int_set_join_req(): Error(%d) \n", s32Error);
+ s32Error = -ENOENT;
+ goto done;
+ }
+
+done:
+
+ return s32Error;
+}
+
+
+/**
+ * @brief WILC_WFI_disconnect
+ * @details Disconnect from the BSS/ESS.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_disconnect(struct wiphy *wiphy, struct net_device *dev, u16 reason_code)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ #ifdef WILC_P2P
+ tstrWILC_WFIDrv *pstrWFIDrv;
+ #endif
+ uint8_t NullBssid[ETH_ALEN] = {0};
+ connecting = 0;
+ priv = wiphy_priv(wiphy);
+
+ /*BugID_5457*/
+ /*Invalidate u8WLANChannel value on wlan0 disconnect*/
+ #ifdef WILC_P2P
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+ if (!pstrWFIDrv->u8P2PConnect)
+ u8WLANChannel = INVALID_CHANNEL;
+ #endif
+ linux_wlan_set_bssid(priv->dev, NullBssid);
+
+ PRINT_D(CFG80211_DBG, "Disconnecting with reason code(%d)\n", reason_code);
+
+ u8P2Plocalrandom = 0x01;
+ u8P2Precvrandom = 0x00;
+ bWilc_ie = WILC_FALSE;
+ #ifdef WILC_P2P
+ pstrWFIDrv->u64P2p_MgmtTimeout = 0;
+ #endif
+
+ s32Error = host_int_disconnect(priv->hWILCWFIDrv, reason_code);
+ if (s32Error != WILC_SUCCESS) {
+ PRINT_ER("Error in disconnecting: Error(%d)\n", s32Error);
+ s32Error = -EINVAL;
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_add_key
+ * @details Add a key with the given parameters. @mac_addr will be %NULL
+ * when adding a group key.
+ * @param[in] key : key buffer; TKIP: 16-byte temporal key, 8-byte Tx Mic key, 8-byte Rx Mic Key
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_add_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
+ bool pairwise,
+ const u8 *mac_addr, struct key_params *params)
+
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS, KeyLen = params->key_len;
+ WILC_Uint32 i;
+ struct WILC_WFI_priv *priv;
+ const u8 *pu8RxMic = NULL;
+ const u8 *pu8TxMic = NULL;
+ u8 u8mode = NO_ENCRYPT;
+ #ifdef WILC_AP_EXTERNAL_MLME
+ u8 u8gmode = NO_ENCRYPT;
+ u8 u8pmode = NO_ENCRYPT;
+ AUTHTYPE_T tenuAuth_type = ANY;
+ #endif
+
+ priv = wiphy_priv(wiphy);
+
+ PRINT_D(CFG80211_DBG, "Adding key with cipher suite = %x\n", params->cipher);
+
+ /*BugID_5137*/
+ PRINT_D(CFG80211_DBG, "%x %x %d\n", (WILC_Uint32)wiphy, (WILC_Uint32)netdev, key_index);
+
+ PRINT_D(CFG80211_DBG, "key %x %x %x\n", params->key[0],
+ params->key[1],
+ params->key[2]);
+
+
+ switch (params->cipher) {
+ case WLAN_CIPHER_SUITE_WEP40:
+ case WLAN_CIPHER_SUITE_WEP104:
+ #ifdef WILC_AP_EXTERNAL_MLME
+ if (priv->wdev->iftype == NL80211_IFTYPE_AP) {
+
+ priv->WILC_WFI_wep_default = key_index;
+ priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
+ WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
+
+ PRINT_D(CFG80211_DBG, "Adding AP WEP Default key Idx = %d\n", key_index);
+ PRINT_D(CFG80211_DBG, "Adding AP WEP Key len= %d\n", params->key_len);
+
+ for (i = 0; i < params->key_len; i++)
+ PRINT_D(CFG80211_DBG, "WEP AP key val[%d] = %x\n", i, params->key[i]);
+
+ tenuAuth_type = OPEN_SYSTEM;
+
+ if (params->cipher == WLAN_CIPHER_SUITE_WEP40)
+ u8mode = ENCRYPT_ENABLED | WEP;
+ else
+ u8mode = ENCRYPT_ENABLED | WEP | WEP_EXTENDED;
+
+ host_int_add_wep_key_bss_ap(priv->hWILCWFIDrv, params->key, params->key_len, key_index, u8mode, tenuAuth_type);
+ break;
+ }
+ #endif
+ if (WILC_memcmp(params->key, priv->WILC_WFI_wep_key[key_index], params->key_len)) {
+ priv->WILC_WFI_wep_default = key_index;
+ priv->WILC_WFI_wep_key_len[key_index] = params->key_len;
+ WILC_memcpy(priv->WILC_WFI_wep_key[key_index], params->key, params->key_len);
+
+ PRINT_D(CFG80211_DBG, "Adding WEP Default key Idx = %d\n", key_index);
+ PRINT_D(CFG80211_DBG, "Adding WEP Key length = %d\n", params->key_len);
+ if (INFO) {
+ for (i = 0; i < params->key_len; i++)
+ PRINT_INFO(CFG80211_DBG, "WEP key value[%d] = %d\n", i, params->key[i]);
+ }
+ host_int_add_wep_key_bss_sta(priv->hWILCWFIDrv, params->key, params->key_len, key_index);
+ }
+
+ break;
+
+ case WLAN_CIPHER_SUITE_TKIP:
+ case WLAN_CIPHER_SUITE_CCMP:
+ #ifdef WILC_AP_EXTERNAL_MLME
+ if (priv->wdev->iftype == NL80211_IFTYPE_AP || priv->wdev->iftype == NL80211_IFTYPE_P2P_GO) {
+
+ if (priv->wilc_gtk[key_index] == NULL) {
+ priv->wilc_gtk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key));
+ priv->wilc_gtk[key_index]->key = NULL;
+ priv->wilc_gtk[key_index]->seq = NULL;
+
+ }
+ if (priv->wilc_ptk[key_index] == NULL) {
+ priv->wilc_ptk[key_index] = (struct wilc_wfi_key *)WILC_MALLOC(sizeof(struct wilc_wfi_key));
+ priv->wilc_ptk[key_index]->key = NULL;
+ priv->wilc_ptk[key_index]->seq = NULL;
+ }
+
+
+
+ if (!pairwise)
+ {
+ if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
+ u8gmode = ENCRYPT_ENABLED | WPA | TKIP;
+ else
+ u8gmode = ENCRYPT_ENABLED | WPA2 | AES;
+
+ priv->wilc_groupkey = u8gmode;
+
+ if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
+
+ pu8TxMic = params->key + 24;
+ pu8RxMic = params->key + 16;
+ KeyLen = params->key_len - 16;
+ }
+ /* if there has been previous allocation for the same index through its key, free that memory and allocate again*/
+ if (priv->wilc_gtk[key_index]->key)
+ WILC_FREE(priv->wilc_gtk[key_index]->key);
+
+ priv->wilc_gtk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len);
+ WILC_memcpy(priv->wilc_gtk[key_index]->key, params->key, params->key_len);
+
+ /* if there has been previous allocation for the same index through its seq, free that memory and allocate again*/
+ if (priv->wilc_gtk[key_index]->seq)
+ WILC_FREE(priv->wilc_gtk[key_index]->seq);
+
+ if ((params->seq_len) > 0) {
+ priv->wilc_gtk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len);
+ WILC_memcpy(priv->wilc_gtk[key_index]->seq, params->seq, params->seq_len);
+ }
+
+ priv->wilc_gtk[key_index]->cipher = params->cipher;
+ priv->wilc_gtk[key_index]->key_len = params->key_len;
+ priv->wilc_gtk[key_index]->seq_len = params->seq_len;
+
+ if (INFO) {
+ for (i = 0; i < params->key_len; i++)
+ PRINT_INFO(CFG80211_DBG, "Adding group key value[%d] = %x\n", i, params->key[i]);
+ for (i = 0; i < params->seq_len; i++)
+ PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
+ }
+
+
+ host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
+ key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, AP_MODE, u8gmode);
+
+ } else {
+ PRINT_INFO(CFG80211_DBG, "STA Address: %x%x%x%x%x\n", mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4]);
+
+ if (params->cipher == WLAN_CIPHER_SUITE_TKIP)
+ u8pmode = ENCRYPT_ENABLED | WPA | TKIP;
+ else
+ u8pmode = priv->wilc_groupkey | AES;
+
+
+ if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
+
+ pu8TxMic = params->key + 24;
+ pu8RxMic = params->key + 16;
+ KeyLen = params->key_len - 16;
+ }
+
+ if (priv->wilc_ptk[key_index]->key)
+ WILC_FREE(priv->wilc_ptk[key_index]->key);
+
+ priv->wilc_ptk[key_index]->key = (u8 *)WILC_MALLOC(params->key_len);
+
+ if (priv->wilc_ptk[key_index]->seq)
+ WILC_FREE(priv->wilc_ptk[key_index]->seq);
+
+ if ((params->seq_len) > 0)
+ priv->wilc_ptk[key_index]->seq = (u8 *)WILC_MALLOC(params->seq_len);
+
+ if (INFO) {
+ for (i = 0; i < params->key_len; i++)
+ PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %x\n", i, params->key[i]);
+
+ for (i = 0; i < params->seq_len; i++)
+ PRINT_INFO(CFG80211_DBG, "Adding group seq value[%d] = %x\n", i, params->seq[i]);
+ }
+
+ WILC_memcpy(priv->wilc_ptk[key_index]->key, params->key, params->key_len);
+
+ if ((params->seq_len) > 0)
+ WILC_memcpy(priv->wilc_ptk[key_index]->seq, params->seq, params->seq_len);
+
+ priv->wilc_ptk[key_index]->cipher = params->cipher;
+ priv->wilc_ptk[key_index]->key_len = params->key_len;
+ priv->wilc_ptk[key_index]->seq_len = params->seq_len;
+
+ host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
+ pu8RxMic, pu8TxMic, AP_MODE, u8pmode, key_index);
+ }
+ break;
+ }
+ #endif
+
+ {
+ u8mode = 0;
+ if (!pairwise)
+ {
+ if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
+ /* swap the tx mic by rx mic */
+ pu8RxMic = params->key + 24;
+ pu8TxMic = params->key + 16;
+ KeyLen = params->key_len - 16;
+ }
+
+ /*BugID_5137*/
+ /*save keys only on interface 0 (wifi interface)*/
+ if (!g_gtk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
+ g_add_gtk_key_params.key_idx = key_index;
+ g_add_gtk_key_params.pairwise = pairwise;
+ if (!mac_addr) {
+ g_add_gtk_key_params.mac_addr = NULL;
+ } else {
+ g_add_gtk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
+ memcpy(g_add_gtk_key_params.mac_addr, mac_addr, ETH_ALEN);
+ }
+ g_key_gtk_params.key_len = params->key_len;
+ g_key_gtk_params.seq_len = params->seq_len;
+ g_key_gtk_params.key = WILC_MALLOC(params->key_len);
+ memcpy(g_key_gtk_params.key, params->key, params->key_len);
+ if (params->seq_len > 0) {
+ g_key_gtk_params.seq = WILC_MALLOC(params->seq_len);
+ memcpy(g_key_gtk_params.seq, params->seq, params->seq_len);
+ }
+ g_key_gtk_params.cipher = params->cipher;
+
+ PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_gtk_params.key[0],
+ g_key_gtk_params.key[1],
+ g_key_gtk_params.key[2]);
+ g_gtk_keys_saved = WILC_TRUE;
+ }
+
+ host_int_add_rx_gtk(priv->hWILCWFIDrv, params->key, KeyLen,
+ key_index, params->seq_len, params->seq, pu8RxMic, pu8TxMic, STATION_MODE, u8mode);
+ /* host_int_add_tx_gtk(priv->hWILCWFIDrv,params->key_len,params->key,key_index); */
+ } else {
+ if (params->key_len > 16 && params->cipher == WLAN_CIPHER_SUITE_TKIP) {
+ /* swap the tx mic by rx mic */
+ pu8RxMic = params->key + 24;
+ pu8TxMic = params->key + 16;
+ KeyLen = params->key_len - 16;
+ }
+
+ /*BugID_5137*/
+ /*save keys only on interface 0 (wifi interface)*/
+ if (!g_ptk_keys_saved && netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
+ g_add_ptk_key_params.key_idx = key_index;
+ g_add_ptk_key_params.pairwise = pairwise;
+ if (!mac_addr) {
+ g_add_ptk_key_params.mac_addr = NULL;
+ } else {
+ g_add_ptk_key_params.mac_addr = WILC_MALLOC(ETH_ALEN);
+ memcpy(g_add_ptk_key_params.mac_addr, mac_addr, ETH_ALEN);
+ }
+ g_key_ptk_params.key_len = params->key_len;
+ g_key_ptk_params.seq_len = params->seq_len;
+ g_key_ptk_params.key = WILC_MALLOC(params->key_len);
+ memcpy(g_key_ptk_params.key, params->key, params->key_len);
+ if (params->seq_len > 0) {
+ g_key_ptk_params.seq = WILC_MALLOC(params->seq_len);
+ memcpy(g_key_ptk_params.seq, params->seq, params->seq_len);
+ }
+ g_key_ptk_params.cipher = params->cipher;
+
+ PRINT_D(CFG80211_DBG, "key %x %x %x\n", g_key_ptk_params.key[0],
+ g_key_ptk_params.key[1],
+ g_key_ptk_params.key[2]);
+ g_ptk_keys_saved = WILC_TRUE;
+ }
+
+ host_int_add_ptk(priv->hWILCWFIDrv, params->key, KeyLen, mac_addr,
+ pu8RxMic, pu8TxMic, STATION_MODE, u8mode, key_index);
+ PRINT_D(CFG80211_DBG, "Adding pairwise key\n");
+ if (INFO) {
+ for (i = 0; i < params->key_len; i++)
+ PRINT_INFO(CFG80211_DBG, "Adding pairwise key value[%d] = %d\n", i, params->key[i]);
+ }
+ }
+ }
+ break;
+
+ default:
+ PRINT_ER("Not supported cipher: Error(%d)\n", s32Error);
+ s32Error = -ENOTSUPP;
+
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_del_key
+ * @details Remove a key given the @mac_addr (%NULL for a group key)
+ * and @key_index, return -ENOENT if the key doesn't exist.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_del_key(struct wiphy *wiphy, struct net_device *netdev,
+ u8 key_index,
+ bool pairwise,
+ const u8 *mac_addr)
+{
+ struct WILC_WFI_priv *priv;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ priv = wiphy_priv(wiphy);
+
+ /*BugID_5137*/
+ /*delete saved keys, if any*/
+ if (netdev == g_linux_wlan->strInterfaceInfo[0].wilc_netdev) {
+ g_ptk_keys_saved = WILC_FALSE;
+ g_gtk_keys_saved = WILC_FALSE;
+ g_wep_keys_saved = WILC_FALSE;
+
+ /*Delete saved WEP keys params, if any*/
+ if (g_key_wep_params.key != NULL) {
+ WILC_FREE(g_key_wep_params.key);
+ g_key_wep_params.key = NULL;
+ }
+
+ /*freeing memory allocated by "wilc_gtk" and "wilc_ptk" in "WILC_WIFI_ADD_KEY"*/
+
+ #ifdef WILC_AP_EXTERNAL_MLME
+ if ((priv->wilc_gtk[key_index]) != NULL) {
+
+ if (priv->wilc_gtk[key_index]->key != NULL) {
+
+ WILC_FREE(priv->wilc_gtk[key_index]->key);
+ priv->wilc_gtk[key_index]->key = NULL;
+ }
+ if (priv->wilc_gtk[key_index]->seq) {
+
+ WILC_FREE(priv->wilc_gtk[key_index]->seq);
+ priv->wilc_gtk[key_index]->seq = NULL;
+ }
+
+ WILC_FREE(priv->wilc_gtk[key_index]);
+ priv->wilc_gtk[key_index] = NULL;
+
+ }
+
+ if ((priv->wilc_ptk[key_index]) != NULL) {
+
+ if (priv->wilc_ptk[key_index]->key) {
+
+ WILC_FREE(priv->wilc_ptk[key_index]->key);
+ priv->wilc_ptk[key_index]->key = NULL;
+ }
+ if (priv->wilc_ptk[key_index]->seq) {
+
+ WILC_FREE(priv->wilc_ptk[key_index]->seq);
+ priv->wilc_ptk[key_index]->seq = NULL;
+ }
+ WILC_FREE(priv->wilc_ptk[key_index]);
+ priv->wilc_ptk[key_index] = NULL;
+ }
+ #endif
+
+ /*Delete saved PTK and GTK keys params, if any*/
+ if (g_key_ptk_params.key != NULL) {
+ WILC_FREE(g_key_ptk_params.key);
+ g_key_ptk_params.key = NULL;
+ }
+ if (g_key_ptk_params.seq != NULL) {
+ WILC_FREE(g_key_ptk_params.seq);
+ g_key_ptk_params.seq = NULL;
+ }
+
+ if (g_key_gtk_params.key != NULL) {
+ WILC_FREE(g_key_gtk_params.key);
+ g_key_gtk_params.key = NULL;
+ }
+ if (g_key_gtk_params.seq != NULL) {
+ WILC_FREE(g_key_gtk_params.seq);
+ g_key_gtk_params.seq = NULL;
+ }
+
+ /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
+ Set_machw_change_vir_if(WILC_FALSE);
+ }
+
+ if (key_index >= 0 && key_index <= 3) {
+ WILC_memset(priv->WILC_WFI_wep_key[key_index], 0, priv->WILC_WFI_wep_key_len[key_index]);
+ priv->WILC_WFI_wep_key_len[key_index] = 0;
+
+ PRINT_D(CFG80211_DBG, "Removing WEP key with index = %d\n", key_index);
+ host_int_remove_wep_key(priv->hWILCWFIDrv, key_index);
+ } else {
+ PRINT_D(CFG80211_DBG, "Removing all installed keys\n");
+ host_int_remove_key(priv->hWILCWFIDrv, mac_addr);
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_get_key
+ * @details Get information about the key with the given parameters.
+ * @mac_addr will be %NULL when requesting information for a group
+ * key. All pointers given to the @callback function need not be valid
+ * after it returns. This function should return an error if it is
+ * not possible to retrieve the key, -ENOENT if it doesn't exist.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_get_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
+ bool pairwise,
+ const u8 *mac_addr, void *cookie, void (*callback)(void *cookie, struct key_params *))
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ struct WILC_WFI_priv *priv;
+ struct key_params key_params;
+ WILC_Uint32 i;
+ priv = wiphy_priv(wiphy);
+
+
+ if (!pairwise)
+ {
+ PRINT_D(CFG80211_DBG, "Getting group key idx: %x\n", key_index);
+
+ key_params.key = priv->wilc_gtk[key_index]->key;
+ key_params.cipher = priv->wilc_gtk[key_index]->cipher;
+ key_params.key_len = priv->wilc_gtk[key_index]->key_len;
+ key_params.seq = priv->wilc_gtk[key_index]->seq;
+ key_params.seq_len = priv->wilc_gtk[key_index]->seq_len;
+ if (INFO) {
+ for (i = 0; i < key_params.key_len; i++)
+ PRINT_INFO(CFG80211_DBG, "Retrieved key value %x\n", key_params.key[i]);
+ }
+ } else {
+ PRINT_D(CFG80211_DBG, "Getting pairwise key\n");
+
+ key_params.key = priv->wilc_ptk[key_index]->key;
+ key_params.cipher = priv->wilc_ptk[key_index]->cipher;
+ key_params.key_len = priv->wilc_ptk[key_index]->key_len;
+ key_params.seq = priv->wilc_ptk[key_index]->seq;
+ key_params.seq_len = priv->wilc_ptk[key_index]->seq_len;
+ }
+
+ callback(cookie, &key_params);
+
+ return s32Error; /* priv->wilc_gtk->key_len ?0 : -ENOENT; */
+}
+
+/**
+ * @brief WILC_WFI_set_default_key
+ * @details Set the default management frame key on an interface
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_set_default_key(struct wiphy *wiphy, struct net_device *netdev, u8 key_index,
+ bool unicast, bool multicast)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+
+
+ priv = wiphy_priv(wiphy);
+
+ PRINT_D(CFG80211_DBG, "Setting default key with idx = %d \n", key_index);
+
+ if (key_index != priv->WILC_WFI_wep_default) {
+
+ host_int_set_WEPDefaultKeyID(priv->hWILCWFIDrv, key_index);
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_dump_survey
+ * @details Get site survey information
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_dump_survey(struct wiphy *wiphy, struct net_device *netdev,
+ int idx, struct survey_info *info)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+
+ if (idx != 0) {
+ s32Error = -ENOENT;
+ PRINT_ER("Error Idx value doesn't equal zero: Error(%d)\n", s32Error);
+
+ }
+
+ return s32Error;
+}
+
+
+/**
+ * @brief WILC_WFI_get_station
+ * @details Get station information for the station identified by @mac
+ * @param[in] NONE
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+
+extern uint32_t Statisitcs_totalAcks, Statisitcs_DroppedAcks;
+static int WILC_WFI_get_station(struct wiphy *wiphy, struct net_device *dev,
+ const u8 *mac, struct station_info *sinfo)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ perInterface_wlan_t *nic;
+ #ifdef WILC_AP_EXTERNAL_MLME
+ WILC_Uint32 i = 0;
+ WILC_Uint32 associatedsta = 0;
+ WILC_Uint32 inactive_time = 0;
+ #endif
+ priv = wiphy_priv(wiphy);
+ nic = netdev_priv(dev);
+
+ #ifdef WILC_AP_EXTERNAL_MLME
+ if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
+ PRINT_D(HOSTAPD_DBG, "Getting station parameters\n");
+
+ PRINT_INFO(HOSTAPD_DBG, ": %x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4]);
+
+ for (i = 0; i < NUM_STA_ASSOCIATED; i++) {
+
+ if (!(memcmp(mac, priv->assoc_stainfo.au8Sta_AssociatedBss[i], ETH_ALEN))) {
+ associatedsta = i;
+ break;
+ }
+
+ }
+
+ if (associatedsta == -1) {
+ s32Error = -ENOENT;
+ PRINT_ER("Station required is not associated : Error(%d)\n", s32Error);
+
+ return s32Error;
+ }
+
+ sinfo->filled |= BIT(NL80211_STA_INFO_INACTIVE_TIME);
+
+ host_int_get_inactive_time(priv->hWILCWFIDrv, mac, &(inactive_time));
+ sinfo->inactive_time = 1000 * inactive_time;
+ PRINT_D(CFG80211_DBG, "Inactive time %d\n", sinfo->inactive_time);
+
+ }
+ #endif
+
+ if (nic->iftype == STATION_MODE) {
+ tstrStatistics strStatistics;
+ host_int_get_statistics(priv->hWILCWFIDrv, &strStatistics);
+
+ /*
+ * tony: 2013-11-13
+ * tx_failed introduced more than
+ * kernel version 3.0.0
+ */
+ sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL) |
+ BIT( NL80211_STA_INFO_RX_PACKETS) |
+ BIT(NL80211_STA_INFO_TX_PACKETS) |
+ BIT(NL80211_STA_INFO_TX_FAILED) |
+ BIT(NL80211_STA_INFO_TX_BITRATE);
+
+ sinfo->signal = strStatistics.s8RSSI;
+ sinfo->rx_packets = strStatistics.u32RxCount;
+ sinfo->tx_packets = strStatistics.u32TxCount + strStatistics.u32TxFailureCount;
+ sinfo->tx_failed = strStatistics.u32TxFailureCount;
+ sinfo->txrate.legacy = strStatistics.u8LinkSpeed * 10;
+
+#ifdef TCP_ENHANCEMENTS
+ if ((strStatistics.u8LinkSpeed > TCP_ACK_FILTER_LINK_SPEED_THRESH) && (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED)) {
+ Enable_TCP_ACK_Filter(WILC_TRUE);
+ } else if (strStatistics.u8LinkSpeed != DEFAULT_LINK_SPEED) {
+ Enable_TCP_ACK_Filter(WILC_FALSE);
+ }
+#endif
+
+ PRINT_D(CORECONFIG_DBG, "*** stats[%d][%d][%d][%d][%d]\n", sinfo->signal, sinfo->rx_packets, sinfo->tx_packets,
+ sinfo->tx_failed, sinfo->txrate.legacy);
+ }
+ return s32Error;
+}
+
+
+/**
+ * @brief WILC_WFI_change_bss
+ * @details Modify parameters for a given BSS.
+ * @param[in]
+ * -use_cts_prot: Whether to use CTS protection
+ * (0 = no, 1 = yes, -1 = do not change)
+ * -use_short_preamble: Whether the use of short preambles is allowed
+ * (0 = no, 1 = yes, -1 = do not change)
+ * -use_short_slot_time: Whether the use of short slot time is allowed
+ * (0 = no, 1 = yes, -1 = do not change)
+ * -basic_rates: basic rates in IEEE 802.11 format
+ * (or NULL for no change)
+ * -basic_rates_len: number of basic rates
+ * -ap_isolate: do not forward packets between connected stations
+ * -ht_opmode: HT Operation mode
+ * (u16 = opmode, -1 = do not change)
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_change_bss(struct wiphy *wiphy, struct net_device *dev,
+ struct bss_parameters *params)
+{
+ PRINT_D(CFG80211_DBG, "Changing Bss parametrs\n");
+ return 0;
+}
+
+/**
+ * @brief WILC_WFI_auth
+ * @details Request to authenticate with the specified peer
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_auth(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_auth_request *req)
+{
+ PRINT_D(CFG80211_DBG, "In Authentication Function\n");
+ return 0;
+}
+
+/**
+ * @brief WILC_WFI_assoc
+ * @details Request to (re)associate with the specified peer
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_assoc(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_assoc_request *req)
+{
+ PRINT_D(CFG80211_DBG, "In Association Function\n");
+ return 0;
+}
+
+/**
+ * @brief WILC_WFI_deauth
+ * @details Request to deauthenticate from the specified peer
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_deauth(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_deauth_request *req, void *cookie)
+{
+ PRINT_D(CFG80211_DBG, "In De-authentication Function\n");
+ return 0;
+}
+
+/**
+ * @brief WILC_WFI_disassoc
+ * @details Request to disassociate from the specified peer
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_disassoc(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_disassoc_request *req, void *cookie)
+{
+ PRINT_D(CFG80211_DBG, "In Disassociation Function\n");
+ return 0;
+}
+
+/**
+ * @brief WILC_WFI_set_wiphy_params
+ * @details Notify that wiphy parameters have changed;
+ * @param[in] Changed bitfield (see &enum wiphy_params_flags) describes which values
+ * have changed.
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_set_wiphy_params(struct wiphy *wiphy, u32 changed)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrCfgParamVal pstrCfgParamVal;
+ struct WILC_WFI_priv *priv;
+
+ priv = wiphy_priv(wiphy);
+/* priv = netdev_priv(priv->wdev->netdev); */
+
+ pstrCfgParamVal.u32SetCfgFlag = 0;
+ PRINT_D(CFG80211_DBG, "Setting Wiphy params \n");
+
+ if (changed & WIPHY_PARAM_RETRY_SHORT) {
+ PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_SHORT %d\n",
+ priv->dev->ieee80211_ptr->wiphy->retry_short);
+ pstrCfgParamVal.u32SetCfgFlag |= RETRY_SHORT;
+ pstrCfgParamVal.short_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_short;
+ }
+ if (changed & WIPHY_PARAM_RETRY_LONG) {
+
+ PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RETRY_LONG %d\n", priv->dev->ieee80211_ptr->wiphy->retry_long);
+ pstrCfgParamVal.u32SetCfgFlag |= RETRY_LONG;
+ pstrCfgParamVal.long_retry_limit = priv->dev->ieee80211_ptr->wiphy->retry_long;
+
+ }
+ if (changed & WIPHY_PARAM_FRAG_THRESHOLD) {
+ PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_FRAG_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->frag_threshold);
+ pstrCfgParamVal.u32SetCfgFlag |= FRAG_THRESHOLD;
+ pstrCfgParamVal.frag_threshold = priv->dev->ieee80211_ptr->wiphy->frag_threshold;
+
+ }
+
+ if (changed & WIPHY_PARAM_RTS_THRESHOLD) {
+ PRINT_D(CFG80211_DBG, "Setting WIPHY_PARAM_RTS_THRESHOLD %d\n", priv->dev->ieee80211_ptr->wiphy->rts_threshold);
+
+ pstrCfgParamVal.u32SetCfgFlag |= RTS_THRESHOLD;
+ pstrCfgParamVal.rts_threshold = priv->dev->ieee80211_ptr->wiphy->rts_threshold;
+
+ }
+
+ PRINT_D(CFG80211_DBG, "Setting CFG params in the host interface\n");
+ s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
+ if (s32Error)
+ PRINT_ER("Error in setting WIPHY PARAMS\n");
+
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_set_bitrate_mask
+ * @details set the bitrate mask configuration
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_set_bitrate_mask(struct wiphy *wiphy,
+ struct net_device *dev, const u8 *peer,
+ const struct cfg80211_bitrate_mask *mask)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ /* strCfgParamVal pstrCfgParamVal; */
+ /* struct WILC_WFI_priv* priv; */
+
+ PRINT_D(CFG80211_DBG, "Setting Bitrate mask function\n");
+#if 0
+ priv = wiphy_priv(wiphy);
+ /* priv = netdev_priv(priv->wdev->netdev); */
+
+ pstrCfgParamVal.curr_tx_rate = mask->control[IEEE80211_BAND_2GHZ].legacy;
+
+ PRINT_D(CFG80211_DBG, "Tx rate = %d\n", pstrCfgParamVal.curr_tx_rate);
+ s32Error = hif_set_cfg(priv->hWILCWFIDrv, &pstrCfgParamVal);
+
+ if (s32Error)
+ PRINT_ER("Error in setting bitrate\n");
+#endif
+ return s32Error;
+
+}
+
+/**
+ * @brief WILC_WFI_set_pmksa
+ * @details Cache a PMKID for a BSSID. This is mostly useful for fullmac
+ * devices running firmwares capable of generating the (re) association
+ * RSN IE. It allows for faster roaming between WPA2 BSSIDs.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_set_pmksa(struct wiphy *wiphy, struct net_device *netdev,
+ struct cfg80211_pmksa *pmksa)
+{
+ WILC_Uint32 i;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ u8 flag = 0;
+
+ struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
+
+ PRINT_D(CFG80211_DBG, "Setting PMKSA\n");
+
+
+ for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
+ if (!WILC_memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
+ ETH_ALEN)) {
+ /*If bssid already exists and pmkid value needs to reset*/
+ flag = PMKID_FOUND;
+ PRINT_D(CFG80211_DBG, "PMKID already exists\n");
+ break;
+ }
+ }
+ if (i < WILC_MAX_NUM_PMKIDS) {
+ PRINT_D(CFG80211_DBG, "Setting PMKID in private structure\n");
+ WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid, pmksa->bssid,
+ ETH_ALEN);
+ WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid, pmksa->pmkid,
+ PMKID_LEN);
+ if (!(flag == PMKID_FOUND))
+ priv->pmkid_list.numpmkid++;
+ } else {
+ PRINT_ER("Invalid PMKID index\n");
+ s32Error = -EINVAL;
+ }
+
+ if (!s32Error) {
+ PRINT_D(CFG80211_DBG, "Setting pmkid in the host interface\n");
+ s32Error = host_int_set_pmkid_info(priv->hWILCWFIDrv, &priv->pmkid_list);
+ }
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_del_pmksa
+ * @details Delete a cached PMKID.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_del_pmksa(struct wiphy *wiphy, struct net_device *netdev,
+ struct cfg80211_pmksa *pmksa)
+{
+
+ WILC_Uint32 i;
+ u8 flag = 0;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
+ /* priv = netdev_priv(priv->wdev->netdev); */
+
+ PRINT_D(CFG80211_DBG, "Deleting PMKSA keys\n");
+
+ for (i = 0; i < priv->pmkid_list.numpmkid; i++) {
+ if (!WILC_memcmp(pmksa->bssid, priv->pmkid_list.pmkidlist[i].bssid,
+ ETH_ALEN)) {
+ /*If bssid is found, reset the values*/
+ PRINT_D(CFG80211_DBG, "Reseting PMKID values\n");
+ WILC_memset(&priv->pmkid_list.pmkidlist[i], 0, sizeof(tstrHostIFpmkid));
+ flag = PMKID_FOUND;
+ break;
+ }
+ }
+
+ if (i < priv->pmkid_list.numpmkid && priv->pmkid_list.numpmkid > 0) {
+ for (; i < (priv->pmkid_list.numpmkid - 1); i++) {
+ WILC_memcpy(priv->pmkid_list.pmkidlist[i].bssid,
+ priv->pmkid_list.pmkidlist[i + 1].bssid,
+ ETH_ALEN);
+ WILC_memcpy(priv->pmkid_list.pmkidlist[i].pmkid,
+ priv->pmkid_list.pmkidlist[i].pmkid,
+ PMKID_LEN);
+ }
+ priv->pmkid_list.numpmkid--;
+ } else {
+ s32Error = -EINVAL;
+ }
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_flush_pmksa
+ * @details Flush all cached PMKIDs.
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_flush_pmksa(struct wiphy *wiphy, struct net_device *netdev)
+{
+ struct WILC_WFI_priv *priv = wiphy_priv(wiphy);
+ /* priv = netdev_priv(priv->wdev->netdev); */
+
+ PRINT_D(CFG80211_DBG, "Flushing PMKID key values\n");
+
+ /*Get cashed Pmkids and set all with zeros*/
+ WILC_memset(&priv->pmkid_list, 0, sizeof(tstrHostIFpmkidAttr));
+
+ return 0;
+}
+
+#ifdef WILC_P2P
+
+/**
+ * @brief WILC_WFI_CfgParseRxAction
+ * @details Function parses the received frames and modifies the following attributes:
+ * -GO Intent
+ * -Channel list
+ * -Operating Channel
+ *
+ * @param[in] u8* Buffer, u32 length
+ * @return NONE.
+ * @author mdaftedar
+ * @date 12 DEC 2012
+ * @version
+ */
+
+void WILC_WFI_CfgParseRxAction(u8 *buf, WILC_Uint32 len)
+{
+ WILC_Uint32 index = 0;
+ WILC_Uint32 i = 0, j = 0;
+
+ /*BugID_5460*/
+ #ifdef USE_SUPPLICANT_GO_INTENT
+ u8 intent;
+ u8 tie_breaker;
+ WILC_Bool is_wilc_go = WILC_TRUE;
+ #endif
+ u8 op_channel_attr_index = 0;
+ u8 channel_list_attr_index = 0;
+
+ while (index < len) {
+ if (buf[index] == GO_INTENT_ATTR_ID) {
+ #ifdef USE_SUPPLICANT_GO_INTENT
+ /*BugID_5460*/
+ /*Case 1: If we are going to be p2p client, no need to modify channels attributes*/
+ /*In negotiation frames, go intent attr value determines who will be GO*/
+ intent = GET_GO_INTENT(buf[index + 3]);
+ tie_breaker = GET_TIE_BREAKER(buf[index + 3]);
+ if (intent > SUPPLICANT_GO_INTENT
+ || (intent == SUPPLICANT_GO_INTENT && tie_breaker == 1)) {
+ PRINT_D(GENERIC_DBG, "WILC will be client (intent %d tie breaker %d)\n", intent, tie_breaker);
+ is_wilc_go = WILC_FALSE;
+ } else {
+ PRINT_D(GENERIC_DBG, "WILC will be GO (intent %d tie breaker %d)\n", intent, tie_breaker);
+ is_wilc_go = WILC_TRUE;
+ }
+
+ #else /* USE_SUPPLICANT_GO_INTENT */
+ #ifdef FORCE_P2P_CLIENT
+ buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
+ #else
+ buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
+ #endif
+ #endif /* USE_SUPPLICANT_GO_INTENT */
+ }
+
+ #ifdef USE_SUPPLICANT_GO_INTENT
+ /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
+ /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
+ if (buf[index] == GROUP_BSSID_ATTR_ID) {
+ PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
+ , buf[index + 4]
+ , buf[index + 5]);
+ is_wilc_go = WILC_FALSE;
+ }
+ #endif /* USE_SUPPLICANT_GO_INTENT */
+
+ if (buf[index] == CHANLIST_ATTR_ID) {
+ channel_list_attr_index = index;
+ } else if (buf[index] == OPERCHAN_ATTR_ID) {
+ op_channel_attr_index = index;
+ }
+ index += buf[index + 1] + 3; /* ID,Length byte */
+ }
+
+ #ifdef USE_SUPPLICANT_GO_INTENT
+ if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
+ #else
+ if (u8WLANChannel != INVALID_CHANNEL)
+ #endif
+ {
+ /*Modify channel list attribute*/
+ if (channel_list_attr_index) {
+ PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
+ for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
+ if (buf[i] == 0x51) {
+ for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
+ buf[j] = u8WLANChannel;
+ }
+ break;
+ }
+ }
+ }
+ /*Modify operating channel attribute*/
+ if (op_channel_attr_index) {
+ PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
+ buf[op_channel_attr_index + 6] = 0x51;
+ buf[op_channel_attr_index + 7] = u8WLANChannel;
+ }
+ }
+}
+
+/**
+ * @brief WILC_WFI_CfgParseTxAction
+ * @details Function parses the transmitted action frames and modifies the
+ * GO Intent attribute
+ * @param[in] u8* Buffer, u32 length, bool bOperChan, u8 iftype
+ * @return NONE.
+ * @author mdaftedar
+ * @date 12 DEC 2012
+ * @version
+ */
+void WILC_WFI_CfgParseTxAction(u8 *buf, WILC_Uint32 len, WILC_Bool bOperChan, u8 iftype)
+{
+ WILC_Uint32 index = 0;
+ WILC_Uint32 i = 0, j = 0;
+
+ u8 op_channel_attr_index = 0;
+ u8 channel_list_attr_index = 0;
+ #ifdef USE_SUPPLICANT_GO_INTENT
+ WILC_Bool is_wilc_go = WILC_FALSE;
+
+ /*BugID_5460*/
+ /*Case 1: If we are already p2p client, no need to modify channels attributes*/
+ /*This to handle the case of inviting a p2p peer to join an existing group which we are a member in*/
+ if (iftype == CLIENT_MODE)
+ return;
+ #endif
+
+ while (index < len) {
+ #ifdef USE_SUPPLICANT_GO_INTENT
+ /*Case 2: If group bssid attribute is present, no need to modify channels attributes*/
+ /*In invitation req and rsp, group bssid attr presence determines who will be GO*/
+ /*Note: If we are already p2p client, group bssid attr may also be present (handled in Case 1)*/
+ if (buf[index] == GROUP_BSSID_ATTR_ID) {
+ PRINT_D(GENERIC_DBG, "Group BSSID: %2x:%2x:%2x\n", buf[index + 3]
+ , buf[index + 4]
+ , buf[index + 5]);
+ is_wilc_go = WILC_TRUE;
+ }
+
+ #else /* USE_SUPPLICANT_GO_INTENT */
+ if (buf[index] == GO_INTENT_ATTR_ID) {
+ #ifdef FORCE_P2P_CLIENT
+ buf[index + 3] = (buf[index + 3] & 0x01) | (0x00 << 1);
+ #else
+ buf[index + 3] = (buf[index + 3] & 0x01) | (0x0f << 1);
+ #endif
+
+ break;
+ }
+ #endif
+
+ if (buf[index] == CHANLIST_ATTR_ID) {
+ channel_list_attr_index = index;
+ } else if (buf[index] == OPERCHAN_ATTR_ID) {
+ op_channel_attr_index = index;
+ }
+ index += buf[index + 1] + 3; /* ID,Length byte */
+ }
+
+ #ifdef USE_SUPPLICANT_GO_INTENT
+ /*No need to check bOperChan since only transmitted invitation frames are parsed*/
+ if (u8WLANChannel != INVALID_CHANNEL && is_wilc_go)
+ #else
+ if (u8WLANChannel != INVALID_CHANNEL && bOperChan)
+ #endif
+ {
+ /*Modify channel list attribute*/
+ if (channel_list_attr_index) {
+ PRINT_D(GENERIC_DBG, "Modify channel list attribute\n");
+ for (i = channel_list_attr_index + 3; i < ((channel_list_attr_index + 3) + buf[channel_list_attr_index + 1]); i++) {
+ if (buf[i] == 0x51) {
+ for (j = i + 2; j < ((i + 2) + buf[i + 1]); j++) {
+ buf[j] = u8WLANChannel;
+ }
+ break;
+ }
+ }
+ }
+ /*Modify operating channel attribute*/
+ if (op_channel_attr_index) {
+ PRINT_D(GENERIC_DBG, "Modify operating channel attribute\n");
+ buf[op_channel_attr_index + 6] = 0x51;
+ buf[op_channel_attr_index + 7] = u8WLANChannel;
+ }
+ }
+}
+
+/* @brief WILC_WFI_p2p_rx
+ * @details
+ * @param[in]
+ *
+ * @return None
+ * @author Mai Daftedar
+ * @date 2 JUN 2013
+ * @version 1.0
+ */
+
+void WILC_WFI_p2p_rx (struct net_device *dev, uint8_t *buff, uint32_t size)
+{
+
+ struct WILC_WFI_priv *priv;
+ WILC_Uint32 header, pkt_offset;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+ WILC_Uint32 i = 0;
+ WILC_Sint32 s32Freq;
+ priv = wiphy_priv(dev->ieee80211_ptr->wiphy);
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+
+ /* Get WILC header */
+ WILC_memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
+
+ /* The packet offset field conain info about what type of managment frame */
+ /* we are dealing with and ack status */
+ pkt_offset = GET_PKT_OFFSET(header);
+
+ if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
+ if (buff[FRAME_TYPE_ID] == IEEE80211_STYPE_PROBE_RESP) {
+ PRINT_D(GENERIC_DBG, "Probe response ACK\n");
+ cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
+ return;
+ } else {
+ if (pkt_offset & IS_MGMT_STATUS_SUCCES) {
+ PRINT_D(GENERIC_DBG, "Success Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID],
+ buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
+ cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, true, GFP_KERNEL);
+ } else {
+ PRINT_D(GENERIC_DBG, "Fail Ack - Action frame category: %x Action Subtype: %d Dialog T: %x OR %x\n", buff[ACTION_CAT_ID], buff[ACTION_SUBTYPE_ID],
+ buff[ACTION_SUBTYPE_ID + 1], buff[P2P_PUB_ACTION_SUBTYPE + 1]);
+ cfg80211_mgmt_tx_status(priv->wdev, priv->u64tx_cookie, buff, size, false, GFP_KERNEL);
+ }
+ return;
+ }
+ } else {
+
+ PRINT_D(GENERIC_DBG, "Rx Frame Type:%x\n", buff[FRAME_TYPE_ID]);
+
+ /*BugID_5442*/
+ /*Upper layer is informed that the frame is received on this freq*/
+ s32Freq = ieee80211_channel_to_frequency(u8CurrChannel, IEEE80211_BAND_2GHZ);
+
+ if (ieee80211_is_action(buff[FRAME_TYPE_ID])) {
+ PRINT_D(GENERIC_DBG, "Rx Action Frame Type: %x %x\n", buff[ACTION_SUBTYPE_ID], buff[P2P_PUB_ACTION_SUBTYPE]);
+
+ if (priv->bCfgScanning == WILC_TRUE && jiffies >= pstrWFIDrv->u64P2p_MgmtTimeout) {
+ PRINT_D(GENERIC_DBG, "Receiving action frames from wrong channels\n");
+ return;
+ }
+ if (buff[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
+
+ switch (buff[ACTION_SUBTYPE_ID]) {
+ case GAS_INTIAL_REQ:
+ PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buff[ACTION_SUBTYPE_ID]);
+ break;
+
+ case GAS_INTIAL_RSP:
+ PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buff[ACTION_SUBTYPE_ID]);
+ break;
+
+ case PUBLIC_ACT_VENDORSPEC:
+ /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
+ * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
+ if (!WILC_memcmp(u8P2P_oui, &buff[ACTION_SUBTYPE_ID + 1], 4)) {
+ if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
+ if (!bWilc_ie) {
+ for (i = P2P_PUB_ACTION_SUBTYPE; i < size; i++) {
+ if (!WILC_memcmp(u8P2P_vendorspec, &buff[i], 6)) {
+ u8P2Precvrandom = buff[i + 6];
+ bWilc_ie = WILC_TRUE;
+ PRINT_D(GENERIC_DBG, "WILC Vendor specific IE:%02x\n", u8P2Precvrandom);
+ break;
+ }
+ }
+ }
+ }
+ if (u8P2Plocalrandom > u8P2Precvrandom) {
+ if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
+ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
+ for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < size; i++) {
+ if (buff[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buff[i + 2], 4))) {
+ WILC_WFI_CfgParseRxAction(&buff[i + 6], size - (i + 6));
+ break;
+ }
+ }
+ }
+ } else
+ PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
+ }
+
+
+ if ((buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buff[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP) && (bWilc_ie)) {
+ PRINT_D(GENERIC_DBG, "Sending P2P to host without extra elemnt\n");
+ /* extra attribute for sig_dbm: signal strength in mBm, or 0 if unknown */
+ cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
+ return;
+ }
+ break;
+
+ default:
+ PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buff[ACTION_SUBTYPE_ID]);
+ break;
+ }
+ }
+ }
+
+ cfg80211_rx_mgmt(priv->wdev, s32Freq, 0, buff, size - 7, 0);
+ }
+}
+
+/**
+ * @brief WILC_WFI_mgmt_tx_complete
+ * @details Returns result of writing mgmt frame to VMM (Tx buffers are freed here)
+ * @param[in] priv
+ * transmitting status
+ * @return None
+ * @author Amr Abdelmoghny
+ * @date 20 MAY 2013
+ * @version 1.0
+ */
+static void WILC_WFI_mgmt_tx_complete(void *priv, int status)
+{
+ struct p2p_mgmt_data *pv_data = (struct p2p_mgmt_data *)priv;
+
+
+ kfree(pv_data->buff);
+ kfree(pv_data);
+}
+
+/**
+ * @brief WILC_WFI_RemainOnChannelReady
+ * @details Callback function, called from handle_remain_on_channel on being ready on channel
+ * @param
+ * @return none
+ * @author Amr abdelmoghny
+ * @date 9 JUNE 2013
+ * @version
+ */
+
+static void WILC_WFI_RemainOnChannelReady(void *pUserVoid)
+{
+ struct WILC_WFI_priv *priv;
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+
+ PRINT_D(HOSTINF_DBG, "Remain on channel ready \n");
+
+ priv->bInP2PlistenState = WILC_TRUE;
+
+ cfg80211_ready_on_channel(priv->wdev,
+ priv->strRemainOnChanParams.u64ListenCookie,
+ priv->strRemainOnChanParams.pstrListenChan,
+ priv->strRemainOnChanParams.u32ListenDuration,
+ GFP_KERNEL);
+}
+
+/**
+ * @brief WILC_WFI_RemainOnChannelExpired
+ * @details Callback function, called on expiration of remain-on-channel duration
+ * @param
+ * @return none
+ * @author Amr abdelmoghny
+ * @date 15 MAY 2013
+ * @version
+ */
+
+static void WILC_WFI_RemainOnChannelExpired(void *pUserVoid, WILC_Uint32 u32SessionID)
+{
+ struct WILC_WFI_priv *priv;
+ priv = (struct WILC_WFI_priv *)pUserVoid;
+
+ /*BugID_5477*/
+ if (u32SessionID == priv->strRemainOnChanParams.u32ListenSessionID) {
+ PRINT_D(GENERIC_DBG, "Remain on channel expired \n");
+
+ priv->bInP2PlistenState = WILC_FALSE;
+
+ /*Inform wpas of remain-on-channel expiration*/
+ cfg80211_remain_on_channel_expired(priv->wdev,
+ priv->strRemainOnChanParams.u64ListenCookie,
+ priv->strRemainOnChanParams.pstrListenChan,
+ GFP_KERNEL);
+ } else {
+ PRINT_D(GENERIC_DBG, "Received ID 0x%x Expected ID 0x%x (No match)\n", u32SessionID
+ , priv->strRemainOnChanParams.u32ListenSessionID);
+ }
+}
+
+
+/**
+ * @brief WILC_WFI_remain_on_channel
+ * @details Request the driver to remain awake on the specified
+ * channel for the specified duration to complete an off-channel
+ * operation (e.g., public action frame exchange). When the driver is
+ * ready on the requested channel, it must indicate this with an event
+ * notification by calling cfg80211_ready_on_channel().
+ * @param[in]
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_remain_on_channel(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct ieee80211_channel *chan,
+ unsigned int duration, u64 *cookie)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ priv = wiphy_priv(wiphy);
+
+ PRINT_D(GENERIC_DBG, "Remaining on channel %d\n", chan->hw_value);
+
+ /*BugID_4800: if in AP mode, return.*/
+ /*This check is to handle the situation when user*/
+ /*requests "create group" during a running scan*/
+
+ if (wdev->iftype == NL80211_IFTYPE_AP) {
+ PRINT_D(GENERIC_DBG, "Required remain-on-channel while in AP mode");
+ return s32Error;
+ }
+
+ u8CurrChannel = chan->hw_value;
+
+ /*Setting params needed by WILC_WFI_RemainOnChannelExpired()*/
+ priv->strRemainOnChanParams.pstrListenChan = chan;
+ priv->strRemainOnChanParams.u64ListenCookie = *cookie;
+ priv->strRemainOnChanParams.u32ListenDuration = duration;
+ priv->strRemainOnChanParams.u32ListenSessionID++;
+
+ s32Error = host_int_remain_on_channel(priv->hWILCWFIDrv
+ , priv->strRemainOnChanParams.u32ListenSessionID
+ , duration
+ , chan->hw_value
+ , WILC_WFI_RemainOnChannelExpired
+ , WILC_WFI_RemainOnChannelReady
+ , (void *)priv);
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_cancel_remain_on_channel
+ * @details Cancel an on-going remain-on-channel operation.
+ * This allows the operation to be terminated prior to timeout based on
+ * the duration value.
+ * @param[in] struct wiphy *wiphy,
+ * @param[in] struct net_device *dev
+ * @param[in] u64 cookie,
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_cancel_remain_on_channel(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ u64 cookie)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ priv = wiphy_priv(wiphy);
+
+ PRINT_D(CFG80211_DBG, "Cancel remain on channel\n");
+
+ s32Error = host_int_ListenStateExpired(priv->hWILCWFIDrv, priv->strRemainOnChanParams.u32ListenSessionID);
+ return s32Error;
+}
+/**
+ * @brief WILC_WFI_add_wilcvendorspec
+ * @details Adding WILC information elemet to allow two WILC devices to
+ * identify each other and connect
+ * @param[in] u8 * buf
+ * @return void
+ * @author mdaftedar
+ * @date 01 JAN 2014
+ * @version 1.0
+ */
+void WILC_WFI_add_wilcvendorspec(u8 *buff)
+{
+ WILC_memcpy(buff, u8P2P_vendorspec, sizeof(u8P2P_vendorspec));
+}
+/**
+ * @brief WILC_WFI_mgmt_tx_frame
+ * @details
+ *
+ * @param[in]
+ * @return NONE.
+ * @author mdaftedar
+ * @date 01 JUL 2012
+ * @version
+ */
+extern linux_wlan_t *g_linux_wlan;
+extern WILC_Bool bEnablePS;
+int WILC_WFI_mgmt_tx(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ struct cfg80211_mgmt_tx_params *params,
+ u64 *cookie)
+{
+ struct ieee80211_channel *chan = params->chan;
+ unsigned int wait = params->wait;
+ const u8 *buf = params->buf;
+ size_t len = params->len;
+ const struct ieee80211_mgmt *mgmt;
+ struct p2p_mgmt_data *mgmt_tx;
+ struct WILC_WFI_priv *priv;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+ WILC_Uint32 i;
+ perInterface_wlan_t *nic;
+ WILC_Uint32 buf_len = len + sizeof(u8P2P_vendorspec) + sizeof(u8P2Plocalrandom);
+
+ nic = netdev_priv(wdev->netdev);
+ priv = wiphy_priv(wiphy);
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+
+ *cookie = (unsigned long)buf;
+ priv->u64tx_cookie = *cookie;
+ mgmt = (const struct ieee80211_mgmt *) buf;
+
+ if (ieee80211_is_mgmt(mgmt->frame_control)) {
+
+ /*mgmt frame allocation*/
+ mgmt_tx = (struct p2p_mgmt_data *)WILC_MALLOC(sizeof(struct p2p_mgmt_data));
+ if (mgmt_tx == NULL) {
+ PRINT_ER("Failed to allocate memory for mgmt_tx structure\n");
+ return WILC_FAIL;
+ }
+ mgmt_tx->buff = (char *)WILC_MALLOC(buf_len);
+ if (mgmt_tx->buff == NULL) {
+ PRINT_ER("Failed to allocate memory for mgmt_tx buff\n");
+ return WILC_FAIL;
+ }
+ WILC_memcpy(mgmt_tx->buff, buf, len);
+ mgmt_tx->size = len;
+
+
+ if (ieee80211_is_probe_resp(mgmt->frame_control)) {
+ PRINT_D(GENERIC_DBG, "TX: Probe Response\n");
+ PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
+ host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
+ /*Save the current channel after we tune to it*/
+ u8CurrChannel = chan->hw_value;
+ } else if (ieee80211_is_action(mgmt->frame_control)) {
+ PRINT_D(GENERIC_DBG, "ACTION FRAME:%x\n", (WILC_Uint16)mgmt->frame_control);
+
+
+ /*BugID_4847*/
+ if (buf[ACTION_CAT_ID] == PUB_ACTION_ATTR_ID) {
+ /*BugID_4847*/
+ /*Only set the channel, if not a negotiation confirmation frame
+ * (If Negotiation confirmation frame, force it
+ * to be transmitted on the same negotiation channel)*/
+
+ if (buf[ACTION_SUBTYPE_ID] != PUBLIC_ACT_VENDORSPEC ||
+ buf[P2P_PUB_ACTION_SUBTYPE] != GO_NEG_CONF) {
+ PRINT_D(GENERIC_DBG, "Setting channel: %d\n", chan->hw_value);
+ host_int_set_mac_chnl_num(priv->hWILCWFIDrv, chan->hw_value);
+ /*Save the current channel after we tune to it*/
+ u8CurrChannel = chan->hw_value;
+ }
+ switch (buf[ACTION_SUBTYPE_ID]) {
+ case GAS_INTIAL_REQ:
+ {
+ PRINT_D(GENERIC_DBG, "GAS INITIAL REQ %x\n", buf[ACTION_SUBTYPE_ID]);
+ break;
+ }
+
+ case GAS_INTIAL_RSP:
+ {
+ PRINT_D(GENERIC_DBG, "GAS INITIAL RSP %x\n", buf[ACTION_SUBTYPE_ID]);
+ break;
+ }
+
+ case PUBLIC_ACT_VENDORSPEC:
+ {
+ /*Now we have a public action vendor specific action frame, check if its a p2p public action frame
+ * based on the standard its should have the p2p_oui attribute with the following values 50 6f 9A 09*/
+ if (!WILC_memcmp(u8P2P_oui, &buf[ACTION_SUBTYPE_ID + 1], 4)) {
+ /*For the connection of two WILC's connection generate a rand number to determine who will be a GO*/
+ if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP)) {
+ if (u8P2Plocalrandom == 1 && u8P2Precvrandom < u8P2Plocalrandom) {
+ get_random_bytes(&u8P2Plocalrandom, 1);
+ /*Increment the number to prevent if its 0*/
+ u8P2Plocalrandom++;
+ }
+ }
+
+ if ((buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == GO_NEG_RSP
+ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)) {
+ if (u8P2Plocalrandom > u8P2Precvrandom) {
+ PRINT_D(GENERIC_DBG, "LOCAL WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
+
+ /*Search for the p2p information information element , after the Public action subtype theres a byte for teh dialog token, skip that*/
+ for (i = P2P_PUB_ACTION_SUBTYPE + 2; i < len; i++) {
+ if (buf[i] == P2PELEM_ATTR_ID && !(WILC_memcmp(u8P2P_oui, &buf[i + 2], 4))) {
+ if (buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_REQ || buf[P2P_PUB_ACTION_SUBTYPE] == P2P_INV_RSP)
+ WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), WILC_TRUE, nic->iftype);
+
+ /*BugID_5460*/
+ /*If using supplicant go intent, no need at all*/
+ /*to parse transmitted negotiation frames*/
+ #ifndef USE_SUPPLICANT_GO_INTENT
+ else
+ WILC_WFI_CfgParseTxAction(&mgmt_tx->buff[i + 6], len - (i + 6), WILC_FALSE, nic->iftype);
+ #endif
+ break;
+ }
+ }
+
+ if (buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_REQ && buf[P2P_PUB_ACTION_SUBTYPE] != P2P_INV_RSP) {
+ WILC_WFI_add_wilcvendorspec(&mgmt_tx->buff[len]);
+ mgmt_tx->buff[len + sizeof(u8P2P_vendorspec)] = u8P2Plocalrandom;
+ mgmt_tx->size = buf_len;
+ }
+ } else
+ PRINT_D(GENERIC_DBG, "PEER WILL BE GO LocaRand=%02x RecvRand %02x\n", u8P2Plocalrandom, u8P2Precvrandom);
+ }
+
+ } else {
+ PRINT_D(GENERIC_DBG, "Not a P2P public action frame\n");
+ }
+
+ break;
+ }
+
+ default:
+ {
+ PRINT_D(GENERIC_DBG, "NOT HANDLED PUBLIC ACTION FRAME TYPE:%x\n", buf[ACTION_SUBTYPE_ID]);
+ break;
+ }
+ }
+
+ }
+
+ PRINT_D(GENERIC_DBG, "TX: ACTION FRAME Type:%x : Chan:%d\n", buf[ACTION_SUBTYPE_ID], chan->hw_value);
+ pstrWFIDrv->u64P2p_MgmtTimeout = (jiffies + msecs_to_jiffies(wait));
+
+ PRINT_D(GENERIC_DBG, "Current Jiffies: %lu Timeout:%llu\n", jiffies, pstrWFIDrv->u64P2p_MgmtTimeout);
+
+ }
+
+ g_linux_wlan->oup.wlan_add_mgmt_to_tx_que(mgmt_tx, mgmt_tx->buff, mgmt_tx->size, WILC_WFI_mgmt_tx_complete);
+ } else {
+ PRINT_D(GENERIC_DBG, "This function transmits only management frames\n");
+ }
+ return s32Error;
+}
+
+int WILC_WFI_mgmt_tx_cancel_wait(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ u64 cookie)
+{
+ struct WILC_WFI_priv *priv;
+ tstrWILC_WFIDrv *pstrWFIDrv;
+ priv = wiphy_priv(wiphy);
+ pstrWFIDrv = (tstrWILC_WFIDrv *)priv->hWILCWFIDrv;
+
+
+ PRINT_D(GENERIC_DBG, "Tx Cancel wait :%lu\n", jiffies);
+ pstrWFIDrv->u64P2p_MgmtTimeout = jiffies;
+
+ if (priv->bInP2PlistenState == WILC_FALSE) {
+ /* Bug 5504: This is just to avoid connection failure when getting stuck when the supplicant
+ * considers the driver falsely that it is in Listen state */
+ cfg80211_remain_on_channel_expired(priv->wdev,
+ priv->strRemainOnChanParams.u64ListenCookie,
+ priv->strRemainOnChanParams.pstrListenChan,
+ GFP_KERNEL);
+ }
+
+ return 0;
+}
+
+/**
+ * @brief WILC_WFI_frame_register
+ * @details Notify driver that a management frame type was
+ * registered. Note that this callback may not sleep, and cannot run
+ * concurrently with itself.
+ * @param[in]
+ * @return NONE.
+ * @author mdaftedar
+ * @date 01 JUL 2012
+ * @version
+ */
+void WILC_WFI_frame_register(struct wiphy *wiphy,
+ struct wireless_dev *wdev,
+ u16 frame_type, bool reg)
+{
+
+ struct WILC_WFI_priv *priv;
+ perInterface_wlan_t *nic;
+
+
+ priv = wiphy_priv(wiphy);
+ nic = netdev_priv(priv->wdev->netdev);
+
+
+
+ /*BugID_5137*/
+ if (!frame_type)
+ return;
+
+ PRINT_D(GENERIC_DBG, "Frame registering Frame Type: %x: Boolean: %d\n", frame_type, reg);
+ switch (frame_type) {
+ case PROBE_REQ:
+ {
+ nic->g_struct_frame_reg[0].frame_type = frame_type;
+ nic->g_struct_frame_reg[0].reg = reg;
+ }
+ break;
+
+ case ACTION:
+ {
+ nic->g_struct_frame_reg[1].frame_type = frame_type;
+ nic->g_struct_frame_reg[1].reg = reg;
+ }
+ break;
+
+ default:
+ {
+ break;
+ }
+
+ }
+ /*If mac is closed, then return*/
+ if (!g_linux_wlan->wilc1000_initialized) {
+ PRINT_D(GENERIC_DBG, "Return since mac is closed\n");
+ return;
+ }
+ host_int_frame_register(priv->hWILCWFIDrv, frame_type, reg);
+
+
+}
+#endif /*WILC_P2P*/
+
+/**
+ * @brief WILC_WFI_set_cqm_rssi_config
+ * @details Configure connection quality monitor RSSI threshold.
+ * @param[in] struct wiphy *wiphy:
+ * @param[in] struct net_device *dev:
+ * @param[in] s32 rssi_thold:
+ * @param[in] u32 rssi_hyst:
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_set_cqm_rssi_config(struct wiphy *wiphy,
+ struct net_device *dev, s32 rssi_thold, u32 rssi_hyst)
+{
+ PRINT_D(CFG80211_DBG, "Setting CQM RSSi Function\n");
+ return 0;
+
+}
+/**
+ * @brief WILC_WFI_dump_station
+ * @details Configure connection quality monitor RSSI threshold.
+ * @param[in] struct wiphy *wiphy:
+ * @param[in] struct net_device *dev
+ * @param[in] int idx
+ * @param[in] u8 *mac
+ * @param[in] struct station_info *sinfo
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_dump_station(struct wiphy *wiphy, struct net_device *dev,
+ int idx, u8 *mac, struct station_info *sinfo)
+{
+ struct WILC_WFI_priv *priv;
+ PRINT_D(CFG80211_DBG, "Dumping station information\n");
+
+ if (idx != 0)
+ return -ENOENT;
+
+ priv = wiphy_priv(wiphy);
+ /* priv = netdev_priv(priv->wdev->netdev); */
+
+ sinfo->filled |= BIT(NL80211_STA_INFO_SIGNAL);
+
+ host_int_get_rssi(priv->hWILCWFIDrv, &(sinfo->signal));
+
+#if 0
+ sinfo->filled |= STATION_INFO_TX_BYTES |
+ STATION_INFO_TX_PACKETS |
+ STATION_INFO_RX_BYTES |
+ STATION_INFO_RX_PACKETS | STATION_INFO_SIGNAL | STATION_INFO_INACTIVE_TIME;
+
+ down(&SemHandleUpdateStats);
+ sinfo->inactive_time = priv->netstats.rx_time > priv->netstats.tx_time ? jiffies_to_msecs(jiffies - priv->netstats.tx_time) : jiffies_to_msecs(jiffies - priv->netstats.rx_time);
+ sinfo->rx_bytes = priv->netstats.rx_bytes;
+ sinfo->tx_bytes = priv->netstats.tx_bytes;
+ sinfo->rx_packets = priv->netstats.rx_packets;
+ sinfo->tx_packets = priv->netstats.tx_packets;
+ up(&SemHandleUpdateStats);
+#endif
+ return 0;
+
+}
+
+
+/**
+ * @brief WILC_WFI_set_power_mgmt
+ * @details
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 JUL 2012
+ * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
+ */
+int WILC_WFI_set_power_mgmt(struct wiphy *wiphy, struct net_device *dev,
+ bool enabled, int timeout)
+{
+ struct WILC_WFI_priv *priv;
+ PRINT_D(CFG80211_DBG, " Power save Enabled= %d , TimeOut = %d\n", enabled, timeout);
+
+ if (wiphy == NULL)
+ return -ENOENT;
+
+ priv = wiphy_priv(wiphy);
+ if (priv->hWILCWFIDrv == NULL) {
+ PRINT_ER("Driver is NULL\n");
+ return -EIO;
+ }
+
+ if (bEnablePS == WILC_TRUE)
+ host_int_set_power_mgmt(priv->hWILCWFIDrv, enabled, timeout);
+
+
+ return WILC_SUCCESS;
+
+}
+#ifdef WILC_AP_EXTERNAL_MLME
+/**
+ * @brief WILC_WFI_change_virt_intf
+ * @details Change type/configuration of virtual interface,
+ * keep the struct wireless_dev's iftype updated.
+ * @param[in] NONE
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void wilc1000_wlan_deinit(linux_wlan_t *nic);
+int wilc1000_wlan_init(struct net_device *dev, perInterface_wlan_t *p_nic);
+
+static int WILC_WFI_change_virt_intf(struct wiphy *wiphy, struct net_device *dev,
+ enum nl80211_iftype type, u32 *flags, struct vif_params *params)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ /* struct WILC_WFI_mon_priv* mon_priv; */
+ perInterface_wlan_t *nic;
+ u8 interface_type;
+ WILC_Uint16 TID = 0;
+ #ifdef WILC_P2P
+ u8 i;
+ #endif
+
+ nic = netdev_priv(dev);
+ priv = wiphy_priv(wiphy);
+
+ PRINT_D(HOSTAPD_DBG, "In Change virtual interface function\n");
+ PRINT_D(HOSTAPD_DBG, "Wireless interface name =%s\n", dev->name);
+ u8P2Plocalrandom = 0x01;
+ u8P2Precvrandom = 0x00;
+
+ bWilc_ie = WILC_FALSE;
+
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ g_obtainingIP = WILC_FALSE;
+ WILC_TimerStop(&hDuringIpTimer, NULL);
+ PRINT_D(GENERIC_DBG, "Changing virtual interface, enable scan\n");
+ #endif
+ /*BugID_5137*/
+ /*Set WILC_CHANGING_VIR_IF register to disallow adding futrue keys to CE H/W*/
+ if (g_ptk_keys_saved && g_gtk_keys_saved) {
+ Set_machw_change_vir_if(WILC_TRUE);
+ }
+
+ switch (type) {
+ case NL80211_IFTYPE_STATION:
+ connecting = 0;
+ PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_STATION\n");
+ /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */
+
+ /* send delba over wlan interface */
+
+
+ dev->ieee80211_ptr->iftype = type;
+ priv->wdev->iftype = type;
+ nic->monitor_flag = 0;
+ nic->iftype = STATION_MODE;
+
+ /*Remove the enteries of the previously connected clients*/
+ memset(priv->assoc_stainfo.au8Sta_AssociatedBss, 0, MAX_NUM_STA * ETH_ALEN);
+ #ifndef SIMULATION
+ #ifdef WILC_P2P
+ interface_type = nic->iftype;
+ nic->iftype = STATION_MODE;
+
+ if (g_linux_wlan->wilc1000_initialized) {
+ host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
+ /* ensure that the message Q is empty */
+ host_int_wait_msg_queue_idle();
+
+ /*BugID_5213*/
+ /*Eliminate host interface blocking state*/
+ linux_wlan_unlock((void *)&g_linux_wlan->cfg_event);
+
+ wilc1000_wlan_deinit(g_linux_wlan);
+ wilc1000_wlan_init(dev, nic);
+ g_wilc_initialized = 1;
+ nic->iftype = interface_type;
+
+ /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
+ host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
+ host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
+ host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
+
+ /*Add saved WEP keys, if any*/
+ if (g_wep_keys_saved) {
+ host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_key_wep_params.key_idx);
+ host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_key_wep_params.key,
+ g_key_wep_params.key_len,
+ g_key_wep_params.key_idx);
+ }
+
+ /*No matter the driver handler passed here, it will be overwriiten*/
+ /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
+ host_int_flush_join_req(priv->hWILCWFIDrv);
+
+ /*Add saved PTK and GTK keys, if any*/
+ if (g_ptk_keys_saved && g_gtk_keys_saved) {
+ PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
+ g_key_ptk_params.key[1],
+ g_key_ptk_params.key[2]);
+ PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
+ g_key_gtk_params.key[1],
+ g_key_gtk_params.key[2]);
+ WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
+ g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+ g_add_ptk_key_params.key_idx,
+ g_add_ptk_key_params.pairwise,
+ g_add_ptk_key_params.mac_addr,
+ (struct key_params *)(&g_key_ptk_params));
+
+ WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
+ g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+ g_add_gtk_key_params.key_idx,
+ g_add_gtk_key_params.pairwise,
+ g_add_gtk_key_params.mac_addr,
+ (struct key_params *)(&g_key_gtk_params));
+ }
+
+ /*BugID_4847: registered frames in firmware are now*/
+ /*lost due to mac close. So re-register those frames*/
+ if (g_linux_wlan->wilc1000_initialized) {
+ for (i = 0; i < num_reg_frame; i++) {
+ PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
+ nic->g_struct_frame_reg[i].reg);
+ host_int_frame_register(priv->hWILCWFIDrv,
+ nic->g_struct_frame_reg[i].frame_type,
+ nic->g_struct_frame_reg[i].reg);
+ }
+ }
+
+ bEnablePS = WILC_TRUE;
+ host_int_set_power_mgmt(priv->hWILCWFIDrv, 1, 0);
+ }
+ #endif
+ #endif
+ break;
+
+ case NL80211_IFTYPE_P2P_CLIENT:
+ bEnablePS = WILC_FALSE;
+ host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
+ connecting = 0;
+ PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_P2P_CLIENT\n");
+ /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */
+
+ host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
+
+ dev->ieee80211_ptr->iftype = type;
+ priv->wdev->iftype = type;
+ nic->monitor_flag = 0;
+
+ #ifndef SIMULATION
+ #ifdef WILC_P2P
+
+ PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
+ nic->iftype = CLIENT_MODE;
+
+
+ if (g_linux_wlan->wilc1000_initialized) {
+ /* ensure that the message Q is empty */
+ host_int_wait_msg_queue_idle();
+
+ wilc1000_wlan_deinit(g_linux_wlan);
+ wilc1000_wlan_init(dev, nic);
+ g_wilc_initialized = 1;
+
+ host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
+ host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
+ host_int_set_operation_mode(priv->hWILCWFIDrv, STATION_MODE);
+
+ /*Add saved WEP keys, if any*/
+ if (g_wep_keys_saved) {
+ host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_key_wep_params.key_idx);
+ host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_key_wep_params.key,
+ g_key_wep_params.key_len,
+ g_key_wep_params.key_idx);
+ }
+
+ /*No matter the driver handler passed here, it will be overwriiten*/
+ /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
+ host_int_flush_join_req(priv->hWILCWFIDrv);
+
+ /*Add saved PTK and GTK keys, if any*/
+ if (g_ptk_keys_saved && g_gtk_keys_saved) {
+ PRINT_D(CFG80211_DBG, "ptk %x %x %x\n", g_key_ptk_params.key[0],
+ g_key_ptk_params.key[1],
+ g_key_ptk_params.key[2]);
+ PRINT_D(CFG80211_DBG, "gtk %x %x %x\n", g_key_gtk_params.key[0],
+ g_key_gtk_params.key[1],
+ g_key_gtk_params.key[2]);
+ WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
+ g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+ g_add_ptk_key_params.key_idx,
+ g_add_ptk_key_params.pairwise,
+ g_add_ptk_key_params.mac_addr,
+ (struct key_params *)(&g_key_ptk_params));
+
+ WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
+ g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+ g_add_gtk_key_params.key_idx,
+ g_add_gtk_key_params.pairwise,
+ g_add_gtk_key_params.mac_addr,
+ (struct key_params *)(&g_key_gtk_params));
+ }
+
+ /*Refresh scan, to refresh the scan results to the wpa_supplicant. Set MachHw to false to enable further key installments*/
+ refresh_scan(priv, 1, WILC_TRUE);
+ Set_machw_change_vir_if(WILC_FALSE);
+
+ /*BugID_4847: registered frames in firmware are now lost
+ * due to mac close. So re-register those frames */
+ if (g_linux_wlan->wilc1000_initialized) {
+ for (i = 0; i < num_reg_frame; i++) {
+ PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
+ nic->g_struct_frame_reg[i].reg);
+ host_int_frame_register(priv->hWILCWFIDrv,
+ nic->g_struct_frame_reg[i].frame_type,
+ nic->g_struct_frame_reg[i].reg);
+ }
+ }
+ }
+ #endif
+ #endif
+ break;
+
+ case NL80211_IFTYPE_AP:
+ /* connecting = 1; */
+ bEnablePS = WILC_FALSE;
+ PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_AP %d\n", type);
+ /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */
+ /* mon_priv = netdev_priv(dev); */
+ /* mon_priv->real_ndev = dev; */
+ dev->ieee80211_ptr->iftype = type;
+ priv->wdev->iftype = type;
+ nic->iftype = AP_MODE;
+ PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv);
+
+ #ifndef SIMULATION
+ PRINT_D(HOSTAPD_DBG, "Downloading AP firmware\n");
+ linux_wlan_get_firmware(nic);
+ #ifdef WILC_P2P
+ /*If wilc is running, then close-open to actually get new firmware running (serves P2P)*/
+ if (g_linux_wlan->wilc1000_initialized) {
+ nic->iftype = AP_MODE;
+ g_linux_wlan->wilc1000_initialized = 1;
+ mac_close(dev);
+ mac_open(dev);
+
+ /* wilc1000_wlan_deinit(g_linux_wlan); */
+ /* wilc1000_wlan_init(dev,nic); */
+ /* repeat_power_cycle(nic); */
+ /* nic->iftype = STATION_MODE; */
+
+ /*BugID_4847: registered frames in firmware are now lost
+ * due to mac close. So re-register those frames */
+ for (i = 0; i < num_reg_frame; i++) {
+ PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
+ nic->g_struct_frame_reg[i].reg);
+ host_int_frame_register(priv->hWILCWFIDrv,
+ nic->g_struct_frame_reg[i].frame_type,
+ nic->g_struct_frame_reg[i].reg);
+ }
+ }
+ #endif
+ #endif
+ break;
+
+ case NL80211_IFTYPE_P2P_GO:
+ PRINT_D(GENERIC_DBG, "start duringIP timer\n");
+
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ g_obtainingIP = WILC_TRUE;
+ WILC_TimerStart(&hDuringIpTimer, duringIP_TIME, NULL, NULL);
+ #endif
+ host_int_set_power_mgmt(priv->hWILCWFIDrv, 0, 0);
+ /*BugID_5222*/
+ /*Delete block ack has to be the latest config packet*/
+ /*sent before downloading new FW. This is because it blocks on*/
+ /*hWaitResponse semaphore, which allows previous config*/
+ /*packets to actually take action on old FW*/
+ host_int_del_All_Rx_BASession(priv->hWILCWFIDrv, g_linux_wlan->strInterfaceInfo[0].aBSSID, TID);
+ bEnablePS = WILC_FALSE;
+ PRINT_D(HOSTAPD_DBG, "Interface type = NL80211_IFTYPE_GO\n");
+ /* linux_wlan_set_bssid(dev,g_linux_wlan->strInterfaceInfo[0].aSrcAddress); */
+ /* mon_priv = netdev_priv(dev); */
+ /* mon_priv->real_ndev = dev; */
+ dev->ieee80211_ptr->iftype = type;
+ priv->wdev->iftype = type;
+
+ PRINT_D(CORECONFIG_DBG, "(WILC_Uint32)priv->hWILCWFIDrv[%x]\n", (WILC_Uint32)priv->hWILCWFIDrv);
+ /* host_int_set_operation_mode((WILC_Uint32)priv->hWILCWFIDrv,AP_MODE); */
+
+ #ifndef SIMULATION
+ #ifdef WILC_P2P
+ PRINT_D(HOSTAPD_DBG, "Downloading P2P_CONCURRENCY_FIRMWARE\n");
+
+
+ #if 1
+ nic->iftype = GO_MODE;
+
+ /* ensure that the message Q is empty */
+ host_int_wait_msg_queue_idle();
+
+ /*while(!g_hif_thread_idle)
+ * {
+ * PRINT_D(GENERIC_DBG, "Wait for host IF idle\n");
+ * WILC_Sleep(10);
+ * }*/
+ wilc1000_wlan_deinit(g_linux_wlan);
+ /* repeat_power_cycle_partially(g_linux_wlan); */
+ wilc1000_wlan_init(dev, nic);
+ g_wilc_initialized = 1;
+
+
+ /*Setting interface 1 drv handler and mac address in newly downloaded FW*/
+ host_int_set_wfi_drv_handler(g_linux_wlan->strInterfaceInfo[0].drvHandler);
+ host_int_set_MacAddress((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
+ host_int_set_operation_mode(priv->hWILCWFIDrv, AP_MODE);
+
+ /*Add saved WEP keys, if any*/
+ if (g_wep_keys_saved) {
+ host_int_set_WEPDefaultKeyID((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_key_wep_params.key_idx);
+ host_int_add_wep_key_bss_sta((WILC_WFIDrvHandle)(g_linux_wlan->strInterfaceInfo[0].drvHandler),
+ g_key_wep_params.key,
+ g_key_wep_params.key_len,
+ g_key_wep_params.key_idx);
+ }
+
+ /*No matter the driver handler passed here, it will be overwriiten*/
+ /*in Handle_FlushConnect() with gu8FlushedJoinReqDrvHandler*/
+ host_int_flush_join_req(priv->hWILCWFIDrv);
+
+ /*Add saved PTK and GTK keys, if any*/
+ if (g_ptk_keys_saved && g_gtk_keys_saved) {
+ PRINT_D(CFG80211_DBG, "ptk %x %x %x cipher %x\n", g_key_ptk_params.key[0],
+ g_key_ptk_params.key[1],
+ g_key_ptk_params.key[2],
+ g_key_ptk_params.cipher);
+ PRINT_D(CFG80211_DBG, "gtk %x %x %x cipher %x\n", g_key_gtk_params.key[0],
+ g_key_gtk_params.key[1],
+ g_key_gtk_params.key[2],
+ g_key_gtk_params.cipher);
+ #if 1
+ WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
+ g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+ g_add_ptk_key_params.key_idx,
+ g_add_ptk_key_params.pairwise,
+ g_add_ptk_key_params.mac_addr,
+ (struct key_params *)(&g_key_ptk_params));
+
+ WILC_WFI_add_key(g_linux_wlan->strInterfaceInfo[0].wilc_netdev->ieee80211_ptr->wiphy,
+ g_linux_wlan->strInterfaceInfo[0].wilc_netdev,
+ g_add_gtk_key_params.key_idx,
+ g_add_gtk_key_params.pairwise,
+ g_add_gtk_key_params.mac_addr,
+ (struct key_params *)(&g_key_gtk_params));
+ #endif
+ }
+ #endif
+
+ /*BugID_4847: registered frames in firmware are now*/
+ /*lost due to mac close. So re-register those frames*/
+ if (g_linux_wlan->wilc1000_initialized) {
+ for (i = 0; i < num_reg_frame; i++) {
+ PRINT_D(INIT_DBG, "Frame registering Type: %x - Reg: %d\n", nic->g_struct_frame_reg[i].frame_type,
+ nic->g_struct_frame_reg[i].reg);
+ host_int_frame_register(priv->hWILCWFIDrv,
+ nic->g_struct_frame_reg[i].frame_type,
+ nic->g_struct_frame_reg[i].reg);
+ }
+ }
+ #endif
+ #endif
+ break;
+
+ default:
+ PRINT_ER("Unknown interface type= %d\n", type);
+ s32Error = -EINVAL;
+ return s32Error;
+ break;
+ }
+
+ return s32Error;
+}
+
+/* (austin.2013-07-23)
+ *
+ * To support revised cfg80211_ops
+ *
+ * add_beacon --> start_ap
+ * set_beacon --> change_beacon
+ * del_beacon --> stop_ap
+ *
+ * beacon_parameters --> cfg80211_ap_settings
+ * cfg80211_beacon_data
+ *
+ * applicable for linux kernel 3.4+
+ */
+
+/**
+ * @brief WILC_WFI_start_ap
+ * @details Add a beacon with given parameters, @head, @interval
+ * and @dtim_period will be valid, @tail is optional.
+ * @param[in] wiphy
+ * @param[in] dev The net device structure
+ * @param[in] settings cfg80211_ap_settings parameters for the beacon to be added
+ * @return int : Return 0 on Success.
+ * @author austin
+ * @date 23 JUL 2013
+ * @version 1.0
+ */
+static int WILC_WFI_start_ap(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_ap_settings *settings)
+{
+ struct cfg80211_beacon_data *beacon = &(settings->beacon);
+ struct WILC_WFI_priv *priv;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ priv = wiphy_priv(wiphy);
+ PRINT_D(HOSTAPD_DBG, "Starting ap\n");
+
+ PRINT_D(HOSTAPD_DBG, "Interval = %d \n DTIM period = %d\n Head length = %d Tail length = %d\n",
+ settings->beacon_interval, settings->dtim_period, beacon->head_len, beacon->tail_len);
+
+ s32Error = WILC_WFI_CfgSetChannel(wiphy, &settings->chandef);
+
+ if (s32Error != WILC_SUCCESS)
+ PRINT_ER("Error in setting channel\n");
+
+ linux_wlan_set_bssid(dev, g_linux_wlan->strInterfaceInfo[0].aSrcAddress);
+
+ #ifndef WILC_FULLY_HOSTING_AP
+ s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
+ settings->beacon_interval,
+ settings->dtim_period,
+ beacon->head_len, (u8 *)beacon->head,
+ beacon->tail_len, (u8 *)beacon->tail);
+ #else
+ s32Error = host_add_beacon(priv->hWILCWFIDrv,
+ settings->beacon_interval,
+ settings->dtim_period,
+ beacon->head_len, (u8 *)beacon->head,
+ beacon->tail_len, (u8 *)beacon->tail);
+ #endif
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_change_beacon
+ * @details Add a beacon with given parameters, @head, @interval
+ * and @dtim_period will be valid, @tail is optional.
+ * @param[in] wiphy
+ * @param[in] dev The net device structure
+ * @param[in] beacon cfg80211_beacon_data for the beacon to be changed
+ * @return int : Return 0 on Success.
+ * @author austin
+ * @date 23 JUL 2013
+ * @version 1.0
+ */
+static int WILC_WFI_change_beacon(struct wiphy *wiphy, struct net_device *dev,
+ struct cfg80211_beacon_data *beacon)
+{
+ struct WILC_WFI_priv *priv;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ priv = wiphy_priv(wiphy);
+ PRINT_D(HOSTAPD_DBG, "Setting beacon\n");
+
+
+#ifndef WILC_FULLY_HOSTING_AP
+ s32Error = host_int_add_beacon(priv->hWILCWFIDrv,
+ 0,
+ 0,
+ beacon->head_len, (u8 *)beacon->head,
+ beacon->tail_len, (u8 *)beacon->tail);
+#else
+ s32Error = host_add_beacon(priv->hWILCWFIDrv,
+ 0,
+ 0,
+ beacon->head_len, (u8 *)beacon->head,
+ beacon->tail_len, (u8 *)beacon->tail);
+#endif
+
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_stop_ap
+ * @details Remove beacon configuration and stop sending the beacon.
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author austin
+ * @date 23 JUL 2013
+ * @version 1.0
+ */
+static int WILC_WFI_stop_ap(struct wiphy *wiphy, struct net_device *dev)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ u8 NullBssid[ETH_ALEN] = {0};
+
+
+ WILC_NULLCHECK(s32Error, wiphy);
+
+ priv = wiphy_priv(wiphy);
+
+ PRINT_D(HOSTAPD_DBG, "Deleting beacon\n");
+
+ /*BugID_5188*/
+ linux_wlan_set_bssid(dev, NullBssid);
+
+ #ifndef WILC_FULLY_HOSTING_AP
+ s32Error = host_int_del_beacon(priv->hWILCWFIDrv);
+ #else
+ s32Error = host_del_beacon(priv->hWILCWFIDrv);
+ #endif
+
+ WILC_ERRORCHECK(s32Error);
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_add_station
+ * @details Add a new station.
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_add_station(struct wiphy *wiphy, struct net_device *dev,
+ const u8 *mac, struct station_parameters *params)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ tstrWILC_AddStaParam strStaParams = {{0}};
+ perInterface_wlan_t *nic;
+
+
+ WILC_NULLCHECK(s32Error, wiphy);
+
+ priv = wiphy_priv(wiphy);
+ nic = netdev_priv(dev);
+
+ if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
+ #ifndef WILC_FULLY_HOSTING_AP
+
+ WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
+ WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
+ strStaParams.u16AssocID = params->aid;
+ strStaParams.u8NumRates = params->supported_rates_len;
+ strStaParams.pu8Rates = params->supported_rates;
+
+ PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
+
+ PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4],
+ priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
+ PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
+ PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
+
+ if (params->ht_capa == NULL) {
+ strStaParams.bIsHTSupported = WILC_FALSE;
+ } else {
+ strStaParams.bIsHTSupported = WILC_TRUE;
+ strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
+ strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
+ WILC_memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
+ strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
+ strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
+ strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
+ }
+
+ strStaParams.u16FlagsMask = params->sta_flags_mask;
+ strStaParams.u16FlagsSet = params->sta_flags_set;
+
+ PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
+ PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
+ PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
+ PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
+ PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
+ PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
+ PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
+ PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
+
+ s32Error = host_int_add_station(priv->hWILCWFIDrv, &strStaParams);
+ WILC_ERRORCHECK(s32Error);
+
+ #else
+ PRINT_D(CFG80211_DBG, "Adding station parameters %d\n", params->aid);
+ WILC_memcpy(priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid], mac, ETH_ALEN);
+
+ PRINT_D(CFG80211_DBG, "BSSID = %x%x%x%x%x%x\n", priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][0], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][1], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][2], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][3], priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][4],
+ priv->assoc_stainfo.au8Sta_AssociatedBss[params->aid][5]);
+
+ WILC_AP_AddSta(mac, params);
+ WILC_ERRORCHECK(s32Error);
+ #endif /* WILC_FULLY_HOSTING_AP */
+
+ }
+
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_del_station
+ * @details Remove a station; @mac may be NULL to remove all stations.
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_del_station(struct wiphy *wiphy, struct net_device *dev,
+ struct station_del_parameters *params)
+{
+ const u8 *mac = params->mac;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ perInterface_wlan_t *nic;
+ WILC_NULLCHECK(s32Error, wiphy);
+ /*BugID_4795: mac may be null pointer to indicate deleting all stations, so avoid null check*/
+ /* WILC_NULLCHECK(s32Error, mac); */
+
+ priv = wiphy_priv(wiphy);
+ nic = netdev_priv(dev);
+
+ if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
+ PRINT_D(HOSTAPD_DBG, "Deleting station\n");
+
+
+ if (mac == NULL) {
+ PRINT_D(HOSTAPD_DBG, "All associated stations \n");
+ s32Error = host_int_del_allstation(priv->hWILCWFIDrv, priv->assoc_stainfo.au8Sta_AssociatedBss);
+ } else {
+ PRINT_D(HOSTAPD_DBG, "With mac address: %x%x%x%x%x%x\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
+ }
+
+ #ifndef WILC_FULLY_HOSTING_AP
+ s32Error = host_int_del_station(priv->hWILCWFIDrv, mac);
+ #else
+ WILC_AP_RemoveSta(mac);
+ #endif /* WILC_FULLY_HOSTING_AP */
+
+ WILC_ERRORCHECK(s32Error);
+ }
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_change_station
+ * @details Modify a given station.
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_change_station(struct wiphy *wiphy, struct net_device *dev,
+ const u8 *mac, struct station_parameters *params)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+ struct WILC_WFI_priv *priv;
+ tstrWILC_AddStaParam strStaParams = {{0}};
+ perInterface_wlan_t *nic;
+
+
+ PRINT_D(HOSTAPD_DBG, "Change station paramters\n");
+
+ WILC_NULLCHECK(s32Error, wiphy);
+
+ priv = wiphy_priv(wiphy);
+ nic = netdev_priv(dev);
+
+ if (nic->iftype == AP_MODE || nic->iftype == GO_MODE) {
+ #ifndef WILC_FULLY_HOSTING_AP
+
+ WILC_memcpy(strStaParams.au8BSSID, mac, ETH_ALEN);
+ strStaParams.u16AssocID = params->aid;
+ strStaParams.u8NumRates = params->supported_rates_len;
+ strStaParams.pu8Rates = params->supported_rates;
+
+ PRINT_D(HOSTAPD_DBG, "BSSID = %x%x%x%x%x%x\n", strStaParams.au8BSSID[0], strStaParams.au8BSSID[1], strStaParams.au8BSSID[2], strStaParams.au8BSSID[3], strStaParams.au8BSSID[4],
+ strStaParams.au8BSSID[5]);
+ PRINT_D(HOSTAPD_DBG, "ASSOC ID = %d\n", strStaParams.u16AssocID);
+ PRINT_D(HOSTAPD_DBG, "Number of supported rates = %d\n", strStaParams.u8NumRates);
+
+ if (params->ht_capa == NULL) {
+ strStaParams.bIsHTSupported = WILC_FALSE;
+ } else {
+ strStaParams.bIsHTSupported = WILC_TRUE;
+ strStaParams.u16HTCapInfo = params->ht_capa->cap_info;
+ strStaParams.u8AmpduParams = params->ht_capa->ampdu_params_info;
+ WILC_memcpy(strStaParams.au8SuppMCsSet, &params->ht_capa->mcs, WILC_SUPP_MCS_SET_SIZE);
+ strStaParams.u16HTExtParams = params->ht_capa->extended_ht_cap_info;
+ strStaParams.u32TxBeamformingCap = params->ht_capa->tx_BF_cap_info;
+ strStaParams.u8ASELCap = params->ht_capa->antenna_selection_info;
+
+ }
+
+ strStaParams.u16FlagsMask = params->sta_flags_mask;
+ strStaParams.u16FlagsSet = params->sta_flags_set;
+
+ PRINT_D(HOSTAPD_DBG, "IS HT supported = %d\n", strStaParams.bIsHTSupported);
+ PRINT_D(HOSTAPD_DBG, "Capability Info = %d\n", strStaParams.u16HTCapInfo);
+ PRINT_D(HOSTAPD_DBG, "AMPDU Params = %d\n", strStaParams.u8AmpduParams);
+ PRINT_D(HOSTAPD_DBG, "HT Extended params = %d\n", strStaParams.u16HTExtParams);
+ PRINT_D(HOSTAPD_DBG, "Tx Beamforming Cap = %d\n", strStaParams.u32TxBeamformingCap);
+ PRINT_D(HOSTAPD_DBG, "Antenna selection info = %d\n", strStaParams.u8ASELCap);
+ PRINT_D(HOSTAPD_DBG, "Flag Mask = %d\n", strStaParams.u16FlagsMask);
+ PRINT_D(HOSTAPD_DBG, "Flag Set = %d\n", strStaParams.u16FlagsSet);
+
+ s32Error = host_int_edit_station(priv->hWILCWFIDrv, &strStaParams);
+ WILC_ERRORCHECK(s32Error);
+
+ #else
+ WILC_AP_EditSta(mac, params);
+ WILC_ERRORCHECK(s32Error);
+ #endif /* WILC_FULLY_HOSTING_AP */
+
+ }
+ WILC_CATCH(s32Error)
+ {
+ }
+ return s32Error;
+}
+
+
+/**
+ * @brief WILC_WFI_add_virt_intf
+ * @details
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 JUL 2012
+ * @version 1.0
+ */
+struct wireless_dev *WILC_WFI_add_virt_intf(struct wiphy *wiphy, const char *name,
+ unsigned char name_assign_type,
+ enum nl80211_iftype type, u32 *flags,
+ struct vif_params *params)
+{
+ perInterface_wlan_t *nic;
+ struct WILC_WFI_priv *priv;
+ /* struct WILC_WFI_mon_priv* mon_priv; */
+ struct net_device *new_ifc = NULL;
+ priv = wiphy_priv(wiphy);
+
+
+
+ PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", priv->wdev->netdev);
+
+ nic = netdev_priv(priv->wdev->netdev);
+
+
+ if (type == NL80211_IFTYPE_MONITOR) {
+ PRINT_D(HOSTAPD_DBG, "Monitor interface mode: Initializing mon interface virtual device driver\n");
+ PRINT_D(HOSTAPD_DBG, "Adding monitor interface[%p]\n", nic->wilc_netdev);
+ new_ifc = WILC_WFI_init_mon_interface(name, nic->wilc_netdev);
+ if (new_ifc != NULL) {
+ PRINT_D(HOSTAPD_DBG, "Setting monitor flag in private structure\n");
+ #ifdef SIMULATION
+ priv = netdev_priv(priv->wdev->netdev);
+ priv->monitor_flag = 1;
+ #else
+ nic = netdev_priv(priv->wdev->netdev);
+ nic->monitor_flag = 1;
+ #endif
+ } else
+ PRINT_ER("Error in initializing monitor interface\n ");
+ }
+ return priv->wdev;
+}
+
+/**
+ * @brief WILC_WFI_del_virt_intf
+ * @details
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 JUL 2012
+ * @version 1.0
+ */
+int WILC_WFI_del_virt_intf(struct wiphy *wiphy, struct wireless_dev *wdev) /* tony for v3.8 support */
+{
+ PRINT_D(HOSTAPD_DBG, "Deleting virtual interface\n");
+ return WILC_SUCCESS;
+}
+
+
+
+#endif /*WILC_AP_EXTERNAL_MLME*/
+static struct cfg80211_ops WILC_WFI_cfg80211_ops = {
+
+ .set_monitor_channel = WILC_WFI_CfgSetChannel,
+ .scan = WILC_WFI_CfgScan,
+ .connect = WILC_WFI_CfgConnect,
+ .disconnect = WILC_WFI_disconnect,
+ .add_key = WILC_WFI_add_key,
+ .del_key = WILC_WFI_del_key,
+ .get_key = WILC_WFI_get_key,
+ .set_default_key = WILC_WFI_set_default_key,
+ /* .dump_survey = WILC_WFI_dump_survey, */
+ #ifdef WILC_AP_EXTERNAL_MLME
+ .add_virtual_intf = WILC_WFI_add_virt_intf,
+ .del_virtual_intf = WILC_WFI_del_virt_intf,
+ .change_virtual_intf = WILC_WFI_change_virt_intf,
+
+ .start_ap = WILC_WFI_start_ap,
+ .change_beacon = WILC_WFI_change_beacon,
+ .stop_ap = WILC_WFI_stop_ap,
+ .add_station = WILC_WFI_add_station,
+ .del_station = WILC_WFI_del_station,
+ .change_station = WILC_WFI_change_station,
+ #endif /* WILC_AP_EXTERNAL_MLME*/
+ #ifndef WILC_FULLY_HOSTING_AP
+ .get_station = WILC_WFI_get_station,
+ #endif
+ .dump_station = WILC_WFI_dump_station,
+ .change_bss = WILC_WFI_change_bss,
+ /* .auth = WILC_WFI_auth, */
+ /* .assoc = WILC_WFI_assoc, */
+ /* .deauth = WILC_WFI_deauth, */
+ /* .disassoc = WILC_WFI_disassoc, */
+ .set_wiphy_params = WILC_WFI_set_wiphy_params,
+
+ /* .set_bitrate_mask = WILC_WFI_set_bitrate_mask, */
+ .set_pmksa = WILC_WFI_set_pmksa,
+ .del_pmksa = WILC_WFI_del_pmksa,
+ .flush_pmksa = WILC_WFI_flush_pmksa,
+#ifdef WILC_P2P
+ .remain_on_channel = WILC_WFI_remain_on_channel,
+ .cancel_remain_on_channel = WILC_WFI_cancel_remain_on_channel,
+ .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait,
+ .mgmt_tx = WILC_WFI_mgmt_tx,
+ .mgmt_frame_register = WILC_WFI_frame_register,
+ /* .mgmt_tx_cancel_wait = WILC_WFI_mgmt_tx_cancel_wait, */
+ .set_power_mgmt = WILC_WFI_set_power_mgmt,
+ .set_cqm_rssi_config = WILC_WFI_set_cqm_rssi_config,
+#endif
+
+};
+
+
+
+
+
+/**
+ * @brief WILC_WFI_update_stats
+ * @details Modify parameters for a given BSS.
+ * @param[in]
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0WILC_WFI_set_cqmWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_configWILC_WFI_set_cqm_rssi_config_rssi_config
+ */
+int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed)
+{
+
+ struct WILC_WFI_priv *priv;
+
+ priv = wiphy_priv(wiphy);
+ /* down(&SemHandleUpdateStats); */
+#if 1
+ switch (changed) {
+
+ case WILC_WFI_RX_PKT:
+ {
+ /* MI_PRINTF("In Rx Receive Packet\n"); */
+ priv->netstats.rx_packets++;
+ priv->netstats.rx_bytes += pktlen;
+ priv->netstats.rx_time = get_jiffies_64();
+ }
+ break;
+
+ case WILC_WFI_TX_PKT:
+ {
+ priv->netstats.tx_packets++;
+ priv->netstats.tx_bytes += pktlen;
+ priv->netstats.tx_time = get_jiffies_64();
+
+ }
+ break;
+
+ default:
+ break;
+ }
+ /* down(&SemHandleUpdateStats); */
+#endif
+ return 0;
+}
+/**
+ * @brief WILC_WFI_InitPriv
+ * @details Initialization of the net device, private data
+ * @param[in] NONE
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_InitPriv(struct net_device *dev)
+{
+
+ struct WILC_WFI_priv *priv;
+ priv = netdev_priv(dev);
+
+ priv->netstats.rx_packets = 0;
+ priv->netstats.tx_packets = 0;
+ priv->netstats.rx_bytes = 0;
+ priv->netstats.rx_bytes = 0;
+ priv->netstats.rx_time = 0;
+ priv->netstats.tx_time = 0;
+
+
+}
+/**
+ * @brief WILC_WFI_CfgAlloc
+ * @details Allocation of the wireless device structure and assigning it
+ * to the cfg80211 operations structure.
+ * @param[in] NONE
+ * @return wireless_dev : Returns pointer to wireless_dev structure.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+struct wireless_dev *WILC_WFI_CfgAlloc(void)
+{
+
+ struct wireless_dev *wdev;
+
+
+ PRINT_D(CFG80211_DBG, "Allocating wireless device\n");
+ /*Allocating the wireless device structure*/
+ wdev = kzalloc(sizeof(struct wireless_dev), GFP_KERNEL);
+ if (!wdev) {
+ PRINT_ER("Cannot allocate wireless device\n");
+ goto _fail_;
+ }
+
+ /*Creating a new wiphy, linking wireless structure with the wiphy structure*/
+ wdev->wiphy = wiphy_new(&WILC_WFI_cfg80211_ops, sizeof(struct WILC_WFI_priv));
+ if (!wdev->wiphy) {
+ PRINT_ER("Cannot allocate wiphy\n");
+ goto _fail_mem_;
+
+ }
+
+ #ifdef WILC_AP_EXTERNAL_MLME
+ /* enable 802.11n HT */
+ WILC_WFI_band_2ghz.ht_cap.ht_supported = 1;
+ WILC_WFI_band_2ghz.ht_cap.cap |= (1 << IEEE80211_HT_CAP_RX_STBC_SHIFT);
+ WILC_WFI_band_2ghz.ht_cap.mcs.rx_mask[0] = 0xff;
+ WILC_WFI_band_2ghz.ht_cap.ampdu_factor = IEEE80211_HT_MAX_AMPDU_8K;
+ WILC_WFI_band_2ghz.ht_cap.ampdu_density = IEEE80211_HT_MPDU_DENSITY_NONE;
+ #endif
+
+ /*wiphy bands*/
+ wdev->wiphy->bands[IEEE80211_BAND_2GHZ] = &WILC_WFI_band_2ghz;
+
+ return wdev;
+
+_fail_mem_:
+ kfree(wdev);
+_fail_:
+ return NULL;
+
+}
+/**
+ * @brief WILC_WFI_WiphyRegister
+ * @details Registering of the wiphy structure and interface modes
+ * @param[in] NONE
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net)
+{
+ struct WILC_WFI_priv *priv;
+ struct wireless_dev *wdev;
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ PRINT_D(CFG80211_DBG, "Registering wifi device\n");
+
+ wdev = WILC_WFI_CfgAlloc();
+ if (wdev == NULL) {
+ PRINT_ER("CfgAlloc Failed\n");
+ return NULL;
+ }
+
+
+ /*Return hardware description structure (wiphy)'s priv*/
+ priv = wdev_priv(wdev);
+ sema_init(&(priv->SemHandleUpdateStats), 1);
+
+ /*Link the wiphy with wireless structure*/
+ priv->wdev = wdev;
+
+ /*Maximum number of probed ssid to be added by user for the scan request*/
+ wdev->wiphy->max_scan_ssids = MAX_NUM_PROBED_SSID;
+ /*Maximum number of pmkids to be cashed*/
+ wdev->wiphy->max_num_pmkids = WILC_MAX_NUM_PMKIDS;
+ PRINT_INFO(CFG80211_DBG, "Max number of PMKIDs = %d\n", wdev->wiphy->max_num_pmkids);
+
+ wdev->wiphy->max_scan_ie_len = 1000;
+
+ /*signal strength in mBm (100*dBm) */
+ wdev->wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM;
+
+ /*Set the availaible cipher suites*/
+ wdev->wiphy->cipher_suites = cipher_suites;
+ wdev->wiphy->n_cipher_suites = ARRAY_SIZE(cipher_suites);
+ /*Setting default managment types: for register action frame: */
+ wdev->wiphy->mgmt_stypes = wilc_wfi_cfg80211_mgmt_types;
+
+#ifdef WILC_P2P
+ wdev->wiphy->max_remain_on_channel_duration = 500;
+ /*Setting the wiphy interfcae mode and type before registering the wiphy*/
+ wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR) | BIT(NL80211_IFTYPE_P2P_GO) |
+ BIT(NL80211_IFTYPE_P2P_CLIENT);
+ wdev->wiphy->flags |= WIPHY_FLAG_HAS_REMAIN_ON_CHANNEL;
+#else
+ wdev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | BIT(NL80211_IFTYPE_AP) | BIT(NL80211_IFTYPE_MONITOR);
+#endif
+ wdev->iftype = NL80211_IFTYPE_STATION;
+
+
+
+ PRINT_INFO(CFG80211_DBG, "Max scan ids = %d,Max scan IE len = %d,Signal Type = %d,Interface Modes = %d,Interface Type = %d\n",
+ wdev->wiphy->max_scan_ssids, wdev->wiphy->max_scan_ie_len, wdev->wiphy->signal_type,
+ wdev->wiphy->interface_modes, wdev->iftype);
+
+ #ifdef WILC_SDIO
+ set_wiphy_dev(wdev->wiphy, &local_sdio_func->dev); /* tony */
+ #endif
+
+ /*Register wiphy structure*/
+ s32Error = wiphy_register(wdev->wiphy);
+ if (s32Error) {
+ PRINT_ER("Cannot register wiphy device\n");
+ /*should define what action to be taken in such failure*/
+ } else {
+ PRINT_D(CFG80211_DBG, "Successful Registering\n");
+ }
+
+#if 0
+ /*wdev[i]->wiphy->interface_modes =
+ * BIT(NL80211_IFTYPE_AP);
+ * wdev[i]->iftype = NL80211_IFTYPE_AP;
+ */
+
+ /*Pointing the priv structure the netdev*/
+ priv = netdev_priv(net);
+
+ /*linking the wireless_dev structure with the netdevice*/
+ priv->dev->ieee80211_ptr = wdev;
+ priv->dev->ml_priv = priv;
+ wdev->netdev = priv->dev;
+#endif
+ priv->dev = net;
+#if 0
+ ret = host_int_init(&priv->hWILCWFIDrv);
+ if (ret) {
+ PRINT_ER("Error Init Driver\n");
+ }
+#endif
+ return wdev;
+
+
+}
+/**
+ * @brief WILC_WFI_WiphyFree
+ * @details Freeing allocation of the wireless device structure
+ * @param[in] NONE
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_InitHostInt(struct net_device *net)
+{
+
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ struct WILC_WFI_priv *priv;
+
+ PRINT_D(INIT_DBG, "Host[%p][%p]\n", net, net->ieee80211_ptr);
+ priv = wdev_priv(net->ieee80211_ptr);
+ if (op_ifcs == 0) {
+ s32Error = WILC_TimerCreate(&(hAgingTimer), remove_network_from_shadow, NULL);
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ s32Error = WILC_TimerCreate(&(hDuringIpTimer), clear_duringIP, NULL);
+ #endif
+ }
+ op_ifcs++;
+ if (s32Error < 0) {
+ PRINT_ER("Failed to creat refresh Timer\n");
+ return s32Error;
+ }
+
+ priv->gbAutoRateAdjusted = WILC_FALSE;
+
+ priv->bInP2PlistenState = WILC_FALSE;
+
+ sema_init(&(priv->hSemScanReq), 1);
+ s32Error = host_int_init(&priv->hWILCWFIDrv);
+ /* s32Error = host_int_init(&priv->hWILCWFIDrv_2); */
+ if (s32Error) {
+ PRINT_ER("Error while initializing hostinterface\n");
+ }
+ return s32Error;
+}
+
+/**
+ * @brief WILC_WFI_WiphyFree
+ * @details Freeing allocation of the wireless device structure
+ * @param[in] NONE
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_DeInitHostInt(struct net_device *net)
+{
+ WILC_Sint32 s32Error = WILC_SUCCESS;
+
+ struct WILC_WFI_priv *priv;
+ priv = wdev_priv(net->ieee80211_ptr);
+
+ priv->gbAutoRateAdjusted = WILC_FALSE;
+
+ priv->bInP2PlistenState = WILC_FALSE;
+
+ op_ifcs--;
+
+ s32Error = host_int_deinit(priv->hWILCWFIDrv);
+ /* s32Error = host_int_deinit(priv->hWILCWFIDrv_2); */
+
+ /* Clear the Shadow scan */
+ clear_shadow_scan(priv);
+ #ifdef DISABLE_PWRSAVE_AND_SCAN_DURING_IP
+ if (op_ifcs == 0) {
+ PRINT_D(CORECONFIG_DBG, "destroy during ip\n");
+ WILC_TimerDestroy(&hDuringIpTimer, NULL);
+ }
+ #endif
+
+ if (s32Error) {
+ PRINT_ER("Error while deintializing host interface\n");
+ }
+ return s32Error;
+}
+
+
+/**
+ * @brief WILC_WFI_WiphyFree
+ * @details Freeing allocation of the wireless device structure
+ * @param[in] NONE
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_WiphyFree(struct net_device *net)
+{
+
+ PRINT_D(CFG80211_DBG, "Unregistering wiphy\n");
+
+ if (net == NULL) {
+ PRINT_D(INIT_DBG, "net_device is NULL\n");
+ return;
+ }
+
+ if (net->ieee80211_ptr == NULL) {
+ PRINT_D(INIT_DBG, "ieee80211_ptr is NULL\n");
+ return;
+ }
+
+ if (net->ieee80211_ptr->wiphy == NULL) {
+ PRINT_D(INIT_DBG, "wiphy is NULL\n");
+ return;
+ }
+
+ wiphy_unregister(net->ieee80211_ptr->wiphy);
+
+ PRINT_D(INIT_DBG, "Freeing wiphy\n");
+ wiphy_free(net->ieee80211_ptr->wiphy);
+ kfree(net->ieee80211_ptr);
+
+}
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h
new file mode 100644
index 00000000000000..f45a15f4650ff1
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.h
@@ -0,0 +1,129 @@
+/*!
+ * @file wilc_wfi_cfgoperations.h
+ * @brief Definitions for the network module
+ * @author syounan
+ * @sa wilc_oswrapper.h top level OS wrapper file
+ * @date 31 Aug 2010
+ * @version 1.0
+ */
+#ifndef NM_WFI_CFGOPERATIONS
+#define NM_WFI_CFGOPERATIONS
+#include "wilc_wfi_netdevice.h"
+
+#ifdef WILC_FULLY_HOSTING_AP
+#include "wilc_host_ap.h"
+#endif
+
+
+/* The following macros describe the bitfield map used by the firmware to determine its 11i mode */
+#define NO_ENCRYPT 0
+#define ENCRYPT_ENABLED (1 << 0)
+#define WEP (1 << 1)
+#define WEP_EXTENDED (1 << 2)
+#define WPA (1 << 3)
+#define WPA2 (1 << 4)
+#define AES (1 << 5)
+#define TKIP (1 << 6)
+
+#ifdef WILC_P2P
+/* #define USE_SUPPLICANT_GO_INTENT */
+
+/*Public action frame index IDs*/
+#define FRAME_TYPE_ID 0
+#define ACTION_CAT_ID 24
+#define ACTION_SUBTYPE_ID 25
+#define P2P_PUB_ACTION_SUBTYPE 30
+
+/*Public action frame Attribute IDs*/
+#define ACTION_FRAME 0xd0
+#define GO_INTENT_ATTR_ID 0x04
+#define CHANLIST_ATTR_ID 0x0b
+#define OPERCHAN_ATTR_ID 0x11
+#ifdef USE_SUPPLICANT_GO_INTENT
+#define GROUP_BSSID_ATTR_ID 0x07
+#endif
+#define PUB_ACTION_ATTR_ID 0x04
+#define P2PELEM_ATTR_ID 0xdd
+
+/*Public action subtype values*/
+#define GO_NEG_REQ 0x00
+#define GO_NEG_RSP 0x01
+#define GO_NEG_CONF 0x02
+#define P2P_INV_REQ 0x03
+#define P2P_INV_RSP 0x04
+#define PUBLIC_ACT_VENDORSPEC 0x09
+#define GAS_INTIAL_REQ 0x0a
+#define GAS_INTIAL_RSP 0x0b
+
+#define INVALID_CHANNEL 0
+#ifdef USE_SUPPLICANT_GO_INTENT
+#define SUPPLICANT_GO_INTENT 6
+#define GET_GO_INTENT(a) (((a) >> 1) & 0x0f)
+#define GET_TIE_BREAKER(a) (((a)) & 0x01)
+#else
+/* #define FORCE_P2P_CLIENT */
+#endif
+#endif
+
+#define nl80211_SCAN_RESULT_EXPIRE (3 * HZ)
+#define SCAN_RESULT_EXPIRE (40 * HZ)
+
+static const u32 cipher_suites[] = {
+ WLAN_CIPHER_SUITE_WEP40,
+ WLAN_CIPHER_SUITE_WEP104,
+ WLAN_CIPHER_SUITE_TKIP,
+ WLAN_CIPHER_SUITE_CCMP,
+ WLAN_CIPHER_SUITE_AES_CMAC,
+};
+
+static const struct ieee80211_txrx_stypes
+ wilc_wfi_cfg80211_mgmt_types[NUM_NL80211_IFTYPES] = {
+ [NL80211_IFTYPE_STATION] = {
+ .tx = 0xffff,
+ .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+ BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
+ },
+ [NL80211_IFTYPE_AP] = {
+ .tx = 0xffff,
+ .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+ BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+ BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+ BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+ BIT(IEEE80211_STYPE_AUTH >> 4) |
+ BIT(IEEE80211_STYPE_DEAUTH >> 4) |
+ BIT(IEEE80211_STYPE_ACTION >> 4)
+ },
+ [NL80211_IFTYPE_P2P_CLIENT] = {
+ .tx = 0xffff,
+ .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+ BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+ BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
+ BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
+ BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
+ BIT(IEEE80211_STYPE_DISASSOC >> 4) |
+ BIT(IEEE80211_STYPE_AUTH >> 4) |
+ BIT(IEEE80211_STYPE_DEAUTH >> 4)
+ }
+};
+
+/* Time to stay on the channel */
+#define WILC_WFI_DWELL_PASSIVE 100
+#define WILC_WFI_DWELL_ACTIVE 40
+
+struct wireless_dev *WILC_WFI_CfgAlloc(void);
+struct wireless_dev *WILC_WFI_WiphyRegister(struct net_device *net);
+void WILC_WFI_WiphyFree(struct net_device *net);
+int WILC_WFI_update_stats(struct wiphy *wiphy, u32 pktlen, u8 changed);
+int WILC_WFI_DeInitHostInt(struct net_device *net);
+int WILC_WFI_InitHostInt(struct net_device *net);
+void WILC_WFI_monitor_rx(uint8_t *buff, uint32_t size);
+int WILC_WFI_deinit_mon_interface(void);
+struct net_device *WILC_WFI_init_mon_interface(const char *name, struct net_device *real_dev);
+
+#ifdef TCP_ENHANCEMENTS
+#define TCP_ACK_FILTER_LINK_SPEED_THRESH 54
+#define DEFAULT_LINK_SPEED 72
+extern void Enable_TCP_ACK_Filter(WILC_Bool value);
+#endif
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.c b/drivers/staging/wilc1000/wilc_wfi_netdevice.c
new file mode 100644
index 00000000000000..fbc4b857aa3582
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.c
@@ -0,0 +1,960 @@
+/*!
+ * @file wilc_wfi_netdevice.c
+ * @brief File Operations OS wrapper functionality
+ * @author mdaftedar
+ * @sa wilc_wfi_netdevice.h
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+
+#ifdef SIMULATION
+
+#include "wilc_wfi_cfgoperations.h"
+#include "host_interface.h"
+
+
+MODULE_AUTHOR("Mai Daftedar");
+MODULE_LICENSE("Dual BSD/GPL");
+
+
+struct net_device *WILC_WFI_devs[2];
+
+/*
+ * Transmitter lockup simulation, normally disabled.
+ */
+static int lockup;
+module_param(lockup, int, 0);
+
+static int timeout = WILC_WFI_TIMEOUT;
+module_param(timeout, int, 0);
+
+/*
+ * Do we run in NAPI mode?
+ */
+static int use_napi ;
+module_param(use_napi, int, 0);
+
+
+/*
+ * A structure representing an in-flight packet.
+ */
+struct WILC_WFI_packet {
+ struct WILC_WFI_packet *next;
+ struct net_device *dev;
+ int datalen;
+ u8 data[ETH_DATA_LEN];
+};
+
+
+
+int pool_size = 8;
+module_param(pool_size, int, 0);
+
+
+static void WILC_WFI_TxTimeout(struct net_device *dev);
+static void (*WILC_WFI_Interrupt)(int, void *, struct pt_regs *);
+
+/**
+ * @brief WILC_WFI_SetupPool
+ * @details Set up a device's packet pool.
+ * @param[in] struct net_device *dev : Network Device Pointer
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_SetupPool(struct net_device *dev)
+{
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+ int i;
+ struct WILC_WFI_packet *pkt;
+
+ priv->ppool = NULL;
+ for (i = 0; i < pool_size; i++) {
+ pkt = kmalloc (sizeof (struct WILC_WFI_packet), GFP_KERNEL);
+ if (pkt == NULL) {
+ PRINT_D(RX_DBG, "Ran out of memory allocating packet pool\n");
+ return;
+ }
+ pkt->dev = dev;
+ pkt->next = priv->ppool;
+ priv->ppool = pkt;
+ }
+}
+
+/**
+ * @brief WILC_WFI_TearDownPool
+ * @details Internal cleanup function that's called after the network device
+ * driver is unregistered
+ * @param[in] struct net_device *dev : Network Device Driver
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_TearDownPool(struct net_device *dev)
+{
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+ struct WILC_WFI_packet *pkt;
+
+ while ((pkt = priv->ppool)) {
+ priv->ppool = pkt->next;
+ kfree (pkt);
+ /* FIXME - in-flight packets ? */
+ }
+}
+
+/**
+ * @brief WILC_WFI_GetTxBuffer
+ * @details Buffer/pool management
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @return struct WILC_WFI_packet
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+struct WILC_WFI_packet *WILC_WFI_GetTxBuffer(struct net_device *dev)
+{
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+ unsigned long flags;
+ struct WILC_WFI_packet *pkt;
+
+ spin_lock_irqsave(&priv->lock, flags);
+ pkt = priv->ppool;
+ priv->ppool = pkt->next;
+ if (priv->ppool == NULL) {
+ PRINT_INFO(RX_DBG, "Pool empty\n");
+ netif_stop_queue(dev);
+ }
+ spin_unlock_irqrestore(&priv->lock, flags);
+ return pkt;
+}
+/**
+ * @brief WILC_WFI_ReleaseBuffer
+ * @details Buffer/pool management
+ * @param[in] WILC_WFI_packet *pkt : Structure holding in-flight packet
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_ReleaseBuffer(struct WILC_WFI_packet *pkt)
+{
+ unsigned long flags;
+ struct WILC_WFI_priv *priv = netdev_priv(pkt->dev);
+
+ spin_lock_irqsave(&priv->lock, flags);
+ pkt->next = priv->ppool;
+ priv->ppool = pkt;
+ spin_unlock_irqrestore(&priv->lock, flags);
+ if (netif_queue_stopped(pkt->dev) && pkt->next == NULL)
+ netif_wake_queue(pkt->dev);
+}
+
+/**
+ * @brief WILC_WFI_EnqueueBuf
+ * @details Enqueuing packets in an RX buffer queue
+ * @param[in] WILC_WFI_packet *pkt : Structure holding in-flight packet
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_EnqueueBuf(struct net_device *dev, struct WILC_WFI_packet *pkt)
+{
+ unsigned long flags;
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+
+ spin_lock_irqsave(&priv->lock, flags);
+ pkt->next = priv->rx_queue; /* FIXME - misorders packets */
+ priv->rx_queue = pkt;
+ spin_unlock_irqrestore(&priv->lock, flags);
+}
+
+/**
+ * @brief WILC_WFI_DequeueBuf
+ * @details Dequeuing packets from the RX buffer queue
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @return WILC_WFI_packet *pkt : Structure holding in-flight pac
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+struct WILC_WFI_packet *WILC_WFI_DequeueBuf(struct net_device *dev)
+{
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+ struct WILC_WFI_packet *pkt;
+ unsigned long flags;
+
+ spin_lock_irqsave(&priv->lock, flags);
+ pkt = priv->rx_queue;
+ if (pkt != NULL)
+ priv->rx_queue = pkt->next;
+ spin_unlock_irqrestore(&priv->lock, flags);
+ return pkt;
+}
+/**
+ * @brief WILC_WFI_RxInts
+ * @details Enable and disable receive interrupts.
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @param[in] enable : Enable/Disable flag
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static void WILC_WFI_RxInts(struct net_device *dev, int enable)
+{
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+ priv->rx_int_enabled = enable;
+}
+
+/**
+ * @brief WILC_WFI_Open
+ * @details Open Network Device Driver, called when the network
+ * interface is opened. It starts the interface's transmit queue.
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @param[in] enable : Enable/Disable flag
+ * @return int : Returns 0 upon success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_Open(struct net_device *dev)
+{
+ /* request_region(), request_irq(), .... (like fops->open) */
+ /*
+ * Assign the hardware address of the board: use "\0SNULx", where
+ * x is 0 or 1. The first byte is '\0' to avoid being a multicast
+ * address (the first byte of multicast addrs is odd).
+ */
+ memcpy(dev->dev_addr, "\0WLAN0", ETH_ALEN);
+ if (dev == WILC_WFI_devs[1])
+ dev->dev_addr[ETH_ALEN - 1]++; /* \0SNUL1 */
+
+ WILC_WFI_InitHostInt(dev);
+ netif_start_queue(dev);
+ return 0;
+}
+/**
+ * @brief WILC_WFI_Release
+ * @details Release Network Device Driver, called when the network
+ * interface is stopped or brought down. This function marks
+ * the network driver as not being able to transmit
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_Release(struct net_device *dev)
+{
+ /* release ports, irq and such -- like fops->close */
+
+ netif_stop_queue(dev); /* can't transmit any more */
+
+ return 0;
+}
+/**
+ * @brief WILC_WFI_Config
+ * @details Configuration changes (passed on by ifconfig)
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @param[in] struct ifmap *map : Contains the ioctl implementation for the
+ * network driver.
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_Config(struct net_device *dev, struct ifmap *map)
+{
+ if (dev->flags & IFF_UP) /* can't act on a running interface */
+ return -EBUSY;
+
+ /* Don't allow changing the I/O address */
+ if (map->base_addr != dev->base_addr) {
+ PRINT_D(RX_DBG, KERN_WARNING "WILC_WFI: Can't change I/O address\n");
+ return -EOPNOTSUPP;
+ }
+
+ /* Allow changing the IRQ */
+ if (map->irq != dev->irq) {
+ dev->irq = map->irq;
+ /* request_irq() is delayed to open-time */
+ }
+
+ /* ignore other fields */
+ return 0;
+}
+/**
+ * @brief WILC_WFI_Rx
+ * @details Receive a packet: retrieve, encapsulate and pass over to upper
+ * levels
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @param[in] WILC_WFI_packet :
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_Rx(struct net_device *dev, struct WILC_WFI_packet *pkt)
+{
+ int i;
+ struct sk_buff *skb;
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+ s8 rssi;
+ /*
+ * The packet has been retrieved from the transmission
+ * medium. Build an skb around it, so upper layers can handle it
+ */
+
+
+ skb = dev_alloc_skb(pkt->datalen + 2);
+ if (!skb) {
+ if (printk_ratelimit())
+ PRINT_D(RX_DBG, "WILC_WFI rx: low on mem - packet dropped\n");
+ priv->stats.rx_dropped++;
+ goto out;
+ }
+ skb_reserve(skb, 2); /* align IP on 16B boundary */
+ memcpy(skb_put(skb, pkt->datalen), pkt->data, pkt->datalen);
+
+ if (priv->monitor_flag) {
+ PRINT_INFO(RX_DBG, "In monitor device name %s\n", dev->name);
+ priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy);
+ PRINT_D(RX_DBG, "VALUE PASSED IN OF HRWD %p\n", priv->hWILCWFIDrv);
+ /* host_int_get_rssi(priv->hWILCWFIDrv, &(rssi)); */
+ if (INFO) {
+ for (i = 14; i < skb->len; i++)
+ PRINT_INFO(RX_DBG, "RXdata[%d] %02x\n", i, skb->data[i]);
+ }
+ WILC_WFI_monitor_rx(dev, skb);
+ return;
+ }
+#if 0
+ PRINT_D(RX_DBG, "In RX NORMAl Device name %s\n", dev->name);
+ /* Write metadata, and then pass to the receive level */
+ skb->dev = dev;
+ skb->protocol = eth_type_trans(skb, dev);
+ skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */
+ WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, pkt->datalen, WILC_WFI_RX_PKT);
+ netif_rx(skb);
+#endif
+out:
+ return;
+}
+
+/**
+ * @brief WILC_WFI_Poll
+ * @details The poll implementation
+ * @param[in] struct napi_struct *napi :
+ * @param[in] int budget :
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static int WILC_WFI_Poll(struct napi_struct *napi, int budget)
+{
+ int npackets = 0;
+ struct sk_buff *skb;
+ struct WILC_WFI_priv *priv = container_of(napi, struct WILC_WFI_priv, napi);
+ struct net_device *dev = priv->dev;
+ struct WILC_WFI_packet *pkt;
+
+ while (npackets < budget && priv->rx_queue) {
+ pkt = WILC_WFI_DequeueBuf(dev);
+ skb = dev_alloc_skb(pkt->datalen + 2);
+ if (!skb) {
+ if (printk_ratelimit())
+ PRINT_D(RX_DBG, "WILC_WFI: packet dropped\n");
+ priv->stats.rx_dropped++;
+ WILC_WFI_ReleaseBuffer(pkt);
+ continue;
+ }
+ skb_reserve(skb, 2); /* align IP on 16B boundary */
+ memcpy(skb_put(skb, pkt->datalen), pkt->data, pkt->datalen);
+ skb->dev = dev;
+ skb->protocol = eth_type_trans(skb, dev);
+ skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */
+ netif_receive_skb(skb);
+ /* Maintain stats */
+ npackets++;
+ WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, pkt->datalen, WILC_WFI_RX_PKT);
+ WILC_WFI_ReleaseBuffer(pkt);
+ }
+ /* If we processed all packets, we're done; tell the kernel and re-enable ints */
+ if (npackets < budget) {
+ napi_complete(napi);
+ WILC_WFI_RxInts(dev, 1);
+ }
+ return npackets;
+}
+
+/**
+ * @brief WILC_WFI_Poll
+ * @details The typical interrupt entry point
+ * @param[in] struct napi_struct *napi :
+ * @param[in] int budget :
+ * @return int : Return 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static void WILC_WFI_RegularInterrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ int statusword;
+ struct WILC_WFI_priv *priv;
+ struct WILC_WFI_packet *pkt = NULL;
+ /*
+ * As usual, check the "device" pointer to be sure it is
+ * really interrupting.
+ * Then assign "struct device *dev"
+ */
+ struct net_device *dev = (struct net_device *)dev_id;
+ /* ... and check with hw if it's really ours */
+
+ /* paranoid */
+ if (!dev)
+ return;
+
+ /* Lock the device */
+ priv = netdev_priv(dev);
+ spin_lock(&priv->lock);
+
+ /* retrieve statusword: real netdevices use I/O instructions */
+ statusword = priv->status;
+ priv->status = 0;
+ if (statusword & WILC_WFI_RX_INTR) {
+ /* send it to WILC_WFI_rx for handling */
+ pkt = priv->rx_queue;
+ if (pkt) {
+ priv->rx_queue = pkt->next;
+ WILC_WFI_Rx(dev, pkt);
+ }
+ }
+ if (statusword & WILC_WFI_TX_INTR) {
+ /* a transmission is over: free the skb */
+ WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, priv->tx_packetlen, WILC_WFI_TX_PKT);
+ dev_kfree_skb(priv->skb);
+ }
+
+ /* Unlock the device and we are done */
+ spin_unlock(&priv->lock);
+ if (pkt)
+ WILC_WFI_ReleaseBuffer(pkt); /* Do this outside the lock! */
+ return;
+}
+/**
+ * @brief WILC_WFI_NapiInterrupt
+ * @details A NAPI interrupt handler
+ * @param[in] irq:
+ * @param[in] dev_id:
+ * @param[in] pt_regs:
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+static void WILC_WFI_NapiInterrupt(int irq, void *dev_id, struct pt_regs *regs)
+{
+ int statusword;
+ struct WILC_WFI_priv *priv;
+
+ /*
+ * As usual, check the "device" pointer for shared handlers.
+ * Then assign "struct device *dev"
+ */
+ struct net_device *dev = (struct net_device *)dev_id;
+ /* ... and check with hw if it's really ours */
+
+ /* paranoid */
+ if (!dev)
+ return;
+
+ /* Lock the device */
+ priv = netdev_priv(dev);
+ spin_lock(&priv->lock);
+
+ /* retrieve statusword: real netdevices use I/O instructions */
+ statusword = priv->status;
+ priv->status = 0;
+ if (statusword & WILC_WFI_RX_INTR) {
+ WILC_WFI_RxInts(dev, 0); /* Disable further interrupts */
+ napi_schedule(&priv->napi);
+ }
+ if (statusword & WILC_WFI_TX_INTR) {
+ /* a transmission is over: free the skb */
+
+ WILC_WFI_update_stats(priv->dev->ieee80211_ptr->wiphy, priv->tx_packetlen, WILC_WFI_TX_PKT);
+ dev_kfree_skb(priv->skb);
+ }
+
+ /* Unlock the device and we are done */
+ spin_unlock(&priv->lock);
+ return;
+}
+
+/**
+ * @brief MI_WFI_HwTx
+ * @details Transmit a packet (low level interface)
+ * @param[in] buf:
+ * @param[in] len:
+ * @param[in] net_device *dev:
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_HwTx(char *buf, int len, struct net_device *dev)
+{
+ /*
+ * This function deals with hw details. This interface loops
+ * back the packet to the other WILC_WFI interface (if any).
+ * In other words, this function implements the WILC_WFI behaviour,
+ * while all other procedures are rather device-independent
+ */
+ struct iphdr *ih;
+ struct net_device *dest;
+ struct WILC_WFI_priv *priv;
+ u32 *saddr, *daddr;
+ struct WILC_WFI_packet *tx_buffer;
+
+
+ /* I am paranoid. Ain't I? */
+ if (len < sizeof(struct ethhdr) + sizeof(struct iphdr)) {
+ PRINT_D(RX_DBG, "WILC_WFI: Hmm... packet too short (%i octets)\n",
+ len);
+ return;
+ }
+
+ if (0) { /* enable this conditional to look at the data */
+ int i;
+ PRINT_D(RX_DBG, "len is %i", len);
+ for (i = 14; i < len; i++)
+ PRINT_D(RX_DBG, "TXdata[%d] %02x\n", i, buf[i] & 0xff);
+ /* PRINT_D(RX_DBG, "\n"); */
+ }
+ /*
+ * Ethhdr is 14 bytes, but the kernel arranges for iphdr
+ * to be aligned (i.e., ethhdr is unaligned)
+ */
+ ih = (struct iphdr *)(buf + sizeof(struct ethhdr));
+ saddr = &ih->saddr;
+ daddr = &ih->daddr;
+
+ ((u8 *)saddr)[2] ^= 1; /* change the third octet (class C) */
+ ((u8 *)daddr)[2] ^= 1;
+
+ ih->check = 0; /* and rebuild the checksum (ip needs it) */
+ ih->check = ip_fast_csum((unsigned char *)ih, ih->ihl);
+
+
+ if (dev == WILC_WFI_devs[0])
+ PRINT_D(RX_DBG, "%08x:%05i --> %08x:%05i\n",
+ ntohl(ih->saddr), ntohs(((struct tcphdr *)(ih + 1))->source),
+ ntohl(ih->daddr), ntohs(((struct tcphdr *)(ih + 1))->dest));
+ else
+ PRINT_D(RX_DBG, "%08x:%05i <-- %08x:%05i\n",
+ ntohl(ih->daddr), ntohs(((struct tcphdr *)(ih + 1))->dest),
+ ntohl(ih->saddr), ntohs(((struct tcphdr *)(ih + 1))->source));
+
+ /*
+ * Ok, now the packet is ready for transmission: first simulate a
+ * receive interrupt on the twin device, then a
+ * transmission-done on the transmitting device
+ */
+ dest = WILC_WFI_devs[dev == WILC_WFI_devs[0] ? 1 : 0];
+ priv = netdev_priv(dest);
+
+ tx_buffer = WILC_WFI_GetTxBuffer(dev);
+ tx_buffer->datalen = len;
+ memcpy(tx_buffer->data, buf, len);
+ WILC_WFI_EnqueueBuf(dest, tx_buffer);
+ if (priv->rx_int_enabled) {
+ priv->status |= WILC_WFI_RX_INTR;
+ WILC_WFI_Interrupt(0, dest, NULL);
+ }
+
+ priv = netdev_priv(dev);
+ priv->tx_packetlen = len;
+ priv->tx_packetdata = buf;
+ priv->status |= WILC_WFI_TX_INTR;
+ if (lockup && ((priv->stats.tx_packets + 1) % lockup) == 0) {
+ /* Simulate a dropped transmit interrupt */
+ netif_stop_queue(dev);
+ PRINT_D(RX_DBG, "Simulate lockup at %ld, txp %ld\n", jiffies,
+ (unsigned long) priv->stats.tx_packets);
+ } else
+ WILC_WFI_Interrupt(0, dev, NULL);
+
+}
+
+/**
+ * @brief WILC_WFI_Tx
+ * @details Transmit a packet (called by the kernel)
+ * @param[in] sk_buff *skb:
+ * @param[in] net_device *dev:
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_Tx(struct sk_buff *skb, struct net_device *dev)
+{
+ int len;
+ char *data, shortpkt[ETH_ZLEN];
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+
+ /* priv = wiphy_priv(priv->dev->ieee80211_ptr->wiphy); */
+
+ /* if(priv->monitor_flag) */
+ /* mac80211_hwsim_monitor_rx(skb); */
+
+
+ data = skb->data;
+ len = skb->len;
+
+ if (len < ETH_ZLEN) {
+ memset(shortpkt, 0, ETH_ZLEN);
+ memcpy(shortpkt, skb->data, skb->len);
+ len = ETH_ZLEN;
+ data = shortpkt;
+ }
+ dev->trans_start = jiffies; /* save the timestamp */
+
+ /* Remember the skb, so we can free it at interrupt time */
+ priv->skb = skb;
+
+ /* actual deliver of data is device-specific, and not shown here */
+ WILC_WFI_HwTx(data, len, dev);
+
+ return 0; /* Our simple device can not fail */
+}
+
+/**
+ * @brief WILC_WFI_TxTimeout
+ * @details Deal with a transmit timeout.
+ * @param[in] net_device *dev:
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_TxTimeout(struct net_device *dev)
+{
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+
+ PRINT_D(RX_DBG, "Transmit timeout at %ld, latency %ld\n", jiffies,
+ jiffies - dev->trans_start);
+ /* Simulate a transmission interrupt to get things moving */
+ priv->status = WILC_WFI_TX_INTR;
+ WILC_WFI_Interrupt(0, dev, NULL);
+ priv->stats.tx_errors++;
+ netif_wake_queue(dev);
+ return;
+}
+
+/**
+ * @brief WILC_WFI_Ioctl
+ * @details Ioctl commands
+ * @param[in] net_device *dev:
+ * @param[in] ifreq *rq
+ * @param[in] cmd:
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_Ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
+{
+ PRINT_D(RX_DBG, "ioctl\n");
+ return 0;
+}
+
+/**
+ * @brief WILC_WFI_Stat
+ * @details Return statistics to the caller
+ * @param[in] net_device *dev:
+ * @return WILC_WFI_Stats : Return net_device_stats stucture with the
+ * network device driver private data contents.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+struct net_device_stats *WILC_WFI_Stats(struct net_device *dev)
+{
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+ return &priv->stats;
+}
+
+/**
+ * @brief WILC_WFI_RebuildHeader
+ * @details This function is called to fill up an eth header, since arp is not
+ * available on the interface
+ * @param[in] sk_buff *skb:
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_RebuildHeader(struct sk_buff *skb)
+{
+ struct ethhdr *eth = (struct ethhdr *) skb->data;
+ struct net_device *dev = skb->dev;
+
+ memcpy(eth->h_source, dev->dev_addr, dev->addr_len);
+ memcpy(eth->h_dest, dev->dev_addr, dev->addr_len);
+ eth->h_dest[ETH_ALEN - 1] ^= 0x01; /* dest is us xor 1 */
+ return 0;
+}
+/**
+ * @brief WILC_WFI_RebuildHeader
+ * @details This function is called to fill up an eth header, since arp is not
+ * available on the interface
+ * @param[in] sk_buff *skb:
+ * @param[in] struct net_device *dev:
+ * @param[in] unsigned short type:
+ * @param[in] const void *saddr,
+ * @param[in] const void *daddr:
+ * @param[in] unsigned int len
+ * @return int : Return 0 on Success
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_Header(struct sk_buff *skb, struct net_device *dev,
+ unsigned short type, const void *daddr, const void *saddr,
+ unsigned int len)
+{
+ struct ethhdr *eth = (struct ethhdr *)skb_push(skb, ETH_HLEN);
+
+ eth->h_proto = htons(type);
+ memcpy(eth->h_source, saddr ? saddr : dev->dev_addr, dev->addr_len);
+ memcpy(eth->h_dest, daddr ? daddr : dev->dev_addr, dev->addr_len);
+ eth->h_dest[ETH_ALEN - 1] ^= 0x01; /* dest is us xor 1 */
+ return dev->hard_header_len;
+}
+
+/**
+ * @brief WILC_WFI_ChangeMtu
+ * @details The "change_mtu" method is usually not needed.
+ * If you need it, it must be like this.
+ * @param[in] net_device *dev : Network Device Driver Structure
+ * @param[in] new_mtu :
+ * @return int : Returns 0 on Success.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_ChangeMtu(struct net_device *dev, int new_mtu)
+{
+ unsigned long flags;
+ struct WILC_WFI_priv *priv = netdev_priv(dev);
+ spinlock_t *lock = &priv->lock;
+
+ /* check ranges */
+ if ((new_mtu < 68) || (new_mtu > 1500))
+ return -EINVAL;
+ /*
+ * Do anything you need, and the accept the value
+ */
+ spin_lock_irqsave(lock, flags);
+ dev->mtu = new_mtu;
+ spin_unlock_irqrestore(lock, flags);
+ return 0; /* success */
+}
+
+static const struct header_ops WILC_WFI_header_ops = {
+ .create = WILC_WFI_Header,
+ .rebuild = WILC_WFI_RebuildHeader,
+ .cache = NULL, /* disable caching */
+};
+
+
+static const struct net_device_ops WILC_WFI_netdev_ops = {
+ .ndo_open = WILC_WFI_Open,
+ .ndo_stop = WILC_WFI_Release,
+ .ndo_set_config = WILC_WFI_Config,
+ .ndo_start_xmit = WILC_WFI_Tx,
+ .ndo_do_ioctl = WILC_WFI_Ioctl,
+ .ndo_get_stats = WILC_WFI_Stats,
+ .ndo_change_mtu = WILC_WFI_ChangeMtu,
+ .ndo_tx_timeout = WILC_WFI_TxTimeout,
+};
+
+/**
+ * @brief WILC_WFI_Init
+ * @details The init function (sometimes called probe).
+ * It is invoked by register_netdev()
+ * @param[in] net_device *dev:
+ * @return NONE
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+void WILC_WFI_Init(struct net_device *dev)
+{
+ struct WILC_WFI_priv *priv;
+
+
+ /*
+ * Then, assign other fields in dev, using ether_setup() and some
+ * hand assignments
+ */
+ ether_setup(dev); /* assign some of the fields */
+ /* 1- Allocate space */
+
+ dev->netdev_ops = &WILC_WFI_netdev_ops;
+ dev->header_ops = &WILC_WFI_header_ops;
+ dev->watchdog_timeo = timeout;
+ /* keep the default flags, just add NOARP */
+ dev->flags |= IFF_NOARP;
+ dev->features |= NETIF_F_NO_CSUM;
+ /*
+ * Then, initialize the priv field. This encloses the statistics
+ * and a few private fields.
+ */
+ priv = netdev_priv(dev);
+ memset(priv, 0, sizeof(struct WILC_WFI_priv));
+ priv->dev = dev;
+ netif_napi_add(dev, &priv->napi, WILC_WFI_Poll, 2);
+ /* The last parameter above is the NAPI "weight". */
+ spin_lock_init(&priv->lock);
+ WILC_WFI_RxInts(dev, 1); /* enable receive interrupts */
+ WILC_WFI_SetupPool(dev);
+}
+
+/**
+ * @brief WILC_WFI_Stat
+ * @details Return statistics to the caller
+ * @param[in] net_device *dev:
+ * @return WILC_WFI_Stats : Return net_device_stats stucture with the
+ * network device driver private data contents.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+
+void WILC_WFI_Cleanup(void)
+{
+ int i;
+ struct WILC_WFI_priv *priv[2];
+
+ /*if(hwsim_mon!=NULL)
+ * {
+ * PRINT_D(RX_DBG, "Freeing monitor interface\n");
+ * unregister_netdev(hwsim_mon);
+ * free_netdev(hwsim_mon);
+ * }*/
+ for (i = 0; i < 2; i++) {
+ priv[i] = netdev_priv(WILC_WFI_devs[i]);
+
+ if (WILC_WFI_devs[i]) {
+ PRINT_D(RX_DBG, "Unregistering\n");
+ unregister_netdev(WILC_WFI_devs[i]);
+ WILC_WFI_TearDownPool(WILC_WFI_devs[i]);
+ free_netdev(WILC_WFI_devs[i]);
+ PRINT_D(RX_DBG, "[NETDEV]Stopping interface\n");
+ WILC_WFI_DeInitHostInt(WILC_WFI_devs[i]);
+ WILC_WFI_WiphyFree(WILC_WFI_devs[i]);
+ }
+
+ }
+ /* unregister_netdev(hwsim_mon); */
+ WILC_WFI_deinit_mon_interface();
+ return;
+}
+
+
+void StartConfigSim(void);
+
+
+
+
+
+
+
+/**
+ * @brief WILC_WFI_Stat
+ * @details Return statistics to the caller
+ * @param[in] net_device *dev:
+ * @return WILC_WFI_Stats : Return net_device_stats stucture with the
+ * network device driver private data contents.
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+int WILC_WFI_InitModule(void)
+{
+
+ int result, i, ret = -ENOMEM;
+ struct WILC_WFI_priv *priv[2], *netpriv;
+ struct wireless_dev *wdev;
+ WILC_WFI_Interrupt = use_napi ? WILC_WFI_NapiInterrupt : WILC_WFI_RegularInterrupt;
+ char buf[IFNAMSIZ];
+
+ for (i = 0; i < 2; i++) {
+
+ /* Allocate the net devices */
+ WILC_WFI_devs[i] = alloc_netdev(sizeof(struct WILC_WFI_priv), "wlan%d",
+ WILC_WFI_Init);
+ if (WILC_WFI_devs[i] == NULL)
+ goto out;
+ /* priv[i] = netdev_priv(WILC_WFI_devs[i]); */
+
+ wdev = WILC_WFI_WiphyRegister(WILC_WFI_devs[i]);
+ WILC_WFI_devs[i]->ieee80211_ptr = wdev;
+ netpriv = netdev_priv(WILC_WFI_devs[i]);
+ netpriv->dev->ieee80211_ptr = wdev;
+ netpriv->dev->ml_priv = netpriv;
+ wdev->netdev = netpriv->dev;
+
+ /*Registering the net device*/
+ result = register_netdev(WILC_WFI_devs[i]);
+ if (result)
+ PRINT_D(RX_DBG, "WILC_WFI: error %i registering device \"%s\"\n",
+ result, WILC_WFI_devs[i]->name);
+ else
+ ret = 0;
+ }
+
+
+ /*init atmel driver */
+ priv[0] = netdev_priv(WILC_WFI_devs[0]);
+ priv[1] = netdev_priv(WILC_WFI_devs[1]);
+
+ if (priv[1]->dev->ieee80211_ptr->wiphy->interface_modes && BIT(NL80211_IFTYPE_MONITOR)) {
+ /* snprintf(buf, IFNAMSIZ, "mon.%s", priv[1]->dev->name); */
+ /* WILC_WFI_init_mon_interface(); */
+ /* priv[1]->monitor_flag = 1; */
+
+ }
+ priv[0]->bCfgScanning = WILC_FALSE;
+ priv[0]->u32RcvdChCount = 0;
+
+ WILC_memset(priv[0]->au8AssociatedBss, 0xFF, ETH_ALEN);
+
+
+ /* ret = host_int_init(&priv[0]->hWILCWFIDrv); */
+ /*copy handle to the other driver*/
+ /* priv[1]->hWILCWFIDrv = priv[0]->hWILCWFIDrv; */
+ if (ret) {
+ PRINT_ER("Error Init Driver\n");
+ }
+
+
+out:
+ if (ret)
+ WILC_WFI_Cleanup();
+ return ret;
+
+
+}
+
+
+module_init(WILC_WFI_InitModule);
+module_exit(WILC_WFI_Cleanup);
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_wfi_netdevice.h b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
new file mode 100644
index 00000000000000..b322f0f956ea2f
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wfi_netdevice.h
@@ -0,0 +1,269 @@
+/*!
+ * @file wilc_wfi_netdevice.h
+ * @brief Definitions for the network module
+ * @author mdaftedar
+ * @date 01 MAR 2012
+ * @version 1.0
+ */
+#ifndef WILC_WFI_NETDEVICE
+#define WILC_WFI_NETDEVICE
+
+/* These are the flags in the statusword */
+#define WILC_WFI_RX_INTR 0x0001
+#define WILC_WFI_TX_INTR 0x0002
+
+/* Default timeout period */
+#define WILC_WFI_TIMEOUT 5 /* In jiffies */
+#define WILC_MAX_NUM_PMKIDS 16
+#define PMKID_LEN 16
+#define PMKID_FOUND 1
+ #define NUM_STA_ASSOCIATED 8
+
+#include <linux/module.h>
+#include <linux/init.h>
+#include <linux/moduleparam.h>
+#include <linux/sched.h>
+#include <linux/kernel.h>
+#include <linux/slab.h> /* kmalloc() */
+#include <linux/errno.h> /* error codes */
+#include <linux/types.h> /* size_t */
+#include <linux/interrupt.h> /* mark_bh */
+#include <linux/time.h>
+#include <linux/in.h>
+#include <linux/netdevice.h> /* struct device, and other headers */
+#include <linux/etherdevice.h> /* eth_type_trans */
+#include <linux/ip.h> /* struct iphdr */
+#include <linux/tcp.h> /* struct tcphdr */
+#include <linux/skbuff.h>
+
+#include <linux/ieee80211.h>
+#include <net/cfg80211.h>
+
+#include <linux/ieee80211.h>
+#include <net/cfg80211.h>
+#include <net/ieee80211_radiotap.h>
+#include <linux/if_arp.h>
+
+
+#include <linux/in6.h>
+#include <asm/checksum.h>
+#include "host_interface.h"
+#include "wilc_wlan.h"
+#include <linux/wireless.h> /* tony, 2013-06-12 */
+
+#define FLOW_CONTROL_LOWER_THRESHOLD 128
+#define FLOW_CONTROL_UPPER_THRESHOLD 256
+
+/*iftype*/
+
+
+enum stats_flags {
+ WILC_WFI_RX_PKT = 1 << 0,
+ WILC_WFI_TX_PKT = 1 << 1,
+};
+
+struct WILC_WFI_stats {
+
+ unsigned long rx_packets;
+ unsigned long tx_packets;
+ unsigned long rx_bytes;
+ unsigned long tx_bytes;
+ u64 rx_time;
+ u64 tx_time;
+
+};
+
+/*
+ * This structure is private to each device. It is used to pass
+ * packets in and out, so there is place for a packet
+ */
+
+#define RX_BH_KTHREAD 0
+#define RX_BH_WORK_QUEUE 1
+#define RX_BH_THREADED_IRQ 2
+#define num_reg_frame 2
+/*
+ * If you use RX_BH_WORK_QUEUE on LPC3131: You may lose the first interrupt on
+ * LPC3131 which is important to get the MAC start status when you are blocked inside
+ * linux_wlan_firmware_download() which blocks mac_open().
+ */
+#if defined (NM73131_0_BOARD)
+ #define RX_BH_TYPE RX_BH_KTHREAD
+#elif defined (PANDA_BOARD)
+ #define RX_BH_TYPE RX_BH_THREADED_IRQ
+#else
+ #define RX_BH_TYPE RX_BH_KTHREAD
+#endif
+
+struct wilc_wfi_key {
+ u8 *key;
+ u8 *seq;
+ int key_len;
+ int seq_len;
+ u32 cipher;
+};
+struct wilc_wfi_wep_key {
+ u8 *key;
+ u8 key_len;
+ u8 key_idx;
+};
+
+struct sta_info {
+ u8 au8Sta_AssociatedBss[MAX_NUM_STA][ETH_ALEN];
+};
+
+#ifdef WILC_P2P
+/*Parameters needed for host interface for remaining on channel*/
+struct wilc_wfi_p2pListenParams {
+ struct ieee80211_channel *pstrListenChan;
+ enum nl80211_channel_type tenuChannelType;
+ WILC_Uint32 u32ListenDuration;
+ WILC_Uint64 u64ListenCookie;
+ WILC_Uint32 u32ListenSessionID;
+};
+
+#endif /*WILC_P2P*/
+
+struct WILC_WFI_priv {
+ struct wireless_dev *wdev;
+ struct cfg80211_scan_request *pstrScanReq;
+
+ #ifdef WILC_P2P
+ struct wilc_wfi_p2pListenParams strRemainOnChanParams;
+ WILC_Uint64 u64tx_cookie;
+
+ #endif
+
+ WILC_Bool bCfgScanning;
+ WILC_Uint32 u32RcvdChCount;
+
+
+
+ u8 au8AssociatedBss[ETH_ALEN];
+ struct sta_info assoc_stainfo;
+ struct net_device_stats stats;
+ u8 monitor_flag;
+ int status;
+ struct WILC_WFI_packet *ppool;
+ struct WILC_WFI_packet *rx_queue; /* List of incoming packets */
+ int rx_int_enabled;
+ int tx_packetlen;
+ u8 *tx_packetdata;
+ struct sk_buff *skb;
+ spinlock_t lock;
+ struct net_device *dev;
+ struct napi_struct napi;
+ WILC_WFIDrvHandle hWILCWFIDrv;
+ WILC_WFIDrvHandle hWILCWFIDrv_2;
+ tstrHostIFpmkidAttr pmkid_list;
+ struct WILC_WFI_stats netstats;
+ u8 WILC_WFI_wep_default;
+ u8 WILC_WFI_wep_key[4][WLAN_KEY_LEN_WEP104];
+ u8 WILC_WFI_wep_key_len[4];
+ struct net_device *real_ndev; /* The real interface that the monitor is on */
+ struct wilc_wfi_key *wilc_gtk[MAX_NUM_STA];
+ struct wilc_wfi_key *wilc_ptk[MAX_NUM_STA];
+ u8 wilc_groupkey;
+ /* semaphores */
+ struct semaphore SemHandleUpdateStats;
+ struct semaphore hSemScanReq;
+ /* */
+ WILC_Bool gbAutoRateAdjusted;
+
+ WILC_Bool bInP2PlistenState;
+
+};
+
+typedef struct {
+ WILC_Uint16 frame_type;
+ WILC_Bool reg;
+
+} struct_frame_reg;
+
+
+#define NUM_CONCURRENT_IFC 2
+typedef struct {
+ uint8_t aSrcAddress[ETH_ALEN];
+ uint8_t aBSSID[ETH_ALEN];
+ uint32_t drvHandler;
+ struct net_device *wilc_netdev;
+} tstrInterfaceInfo;
+typedef struct {
+ int mac_status;
+ int wilc1000_initialized;
+
+
+ #if (!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO)
+ unsigned short dev_irq_num;
+ #endif
+ wilc_wlan_oup_t oup;
+ int close;
+ uint8_t u8NoIfcs;
+ tstrInterfaceInfo strInterfaceInfo[NUM_CONCURRENT_IFC];
+ uint8_t open_ifcs;
+ struct mutex txq_cs;
+
+ /*Added by Amr - BugID_4720*/
+ struct mutex txq_add_to_head_cs;
+ spinlock_t txq_spinlock;
+
+ struct mutex rxq_cs;
+ struct mutex hif_cs;
+
+ /* struct mutex txq_event; */
+ struct semaphore rxq_event;
+ struct semaphore cfg_event;
+ struct semaphore sync_event;
+
+ struct semaphore txq_event;
+ /* struct completion txq_event; */
+
+#if (RX_BH_TYPE == RX_BH_WORK_QUEUE)
+ struct work_struct rx_work_queue;
+#elif (RX_BH_TYPE == RX_BH_KTHREAD)
+ struct task_struct *rx_bh_thread;
+ struct semaphore rx_sem;
+#endif
+
+
+
+ struct semaphore rxq_thread_started;
+ struct semaphore txq_thread_started;
+
+ struct task_struct *rxq_thread;
+ struct task_struct *txq_thread;
+
+ unsigned char eth_src_address[NUM_CONCURRENT_IFC][6];
+ /* unsigned char eth_dst_address[6]; */
+
+ const struct firmware *wilc_firmware; /* Bug 4703 */
+
+ struct net_device *real_ndev;
+#ifdef WILC_SDIO
+ int already_claim;
+ struct sdio_func *wilc_sdio_func;
+#else
+ struct spi_device *wilc_spidev;
+#endif
+
+} linux_wlan_t;
+
+typedef struct {
+ uint8_t u8IfIdx;
+ u8 iftype;
+ int monitor_flag;
+ int mac_opened;
+ #ifdef WILC_P2P
+ struct_frame_reg g_struct_frame_reg[num_reg_frame];
+ #endif
+ struct net_device *wilc_netdev;
+ struct net_device_stats netstats;
+
+} perInterface_wlan_t;
+
+struct WILC_WFI_mon_priv {
+ struct net_device *real_ndev;
+};
+extern struct net_device *WILC_WFI_devs[];
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_wlan.c b/drivers/staging/wilc1000/wilc_wlan.c
new file mode 100644
index 00000000000000..e63788f17b5be8
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -0,0 +1,2432 @@
+/* ////////////////////////////////////////////////////////////////////////// */
+/* */
+/* Copyright (c) Atmel Corporation. All rights reserved. */
+/* */
+/* Module Name: wilc_wlan.c */
+/* */
+/* */
+/* //////////////////////////////////////////////////////////////////////////// */
+
+#include "wilc_wlan_if.h"
+#include "wilc_wlan.h"
+#define INLINE static __inline
+
+/********************************************
+ *
+ * Global
+ *
+ ********************************************/
+extern unsigned int int_clrd;
+extern wilc_hif_func_t hif_sdio;
+extern wilc_hif_func_t hif_spi;
+extern wilc_cfg_func_t mac_cfg;
+#if defined(PLAT_RK3026_TCHIP)
+extern u8 g_wilc_initialized; /* AMR : 0422 RK3026 Crash issue */
+#endif
+extern void WILC_WFI_mgmt_rx(uint8_t *buff, uint32_t size);
+extern void frmw_to_linux(uint8_t *buff, uint32_t size);
+int sdio_xfer_cnt(void);
+uint32_t wilc_get_chipid(uint8_t update);
+WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue);
+
+/* static uint32_t vmm_table[WILC_VMM_TBL_SIZE]; */
+/* static uint32_t vmm_table_rbk[WILC_VMM_TBL_SIZE]; */
+
+/* static uint32_t vmm_table_rbk[WILC_VMM_TBL_SIZE]; */
+
+
+typedef struct {
+ int quit;
+
+ /**
+ * input interface functions
+ **/
+ wilc_wlan_os_func_t os_func;
+ wilc_wlan_io_func_t io_func;
+ wilc_wlan_net_func_t net_func;
+ wilc_wlan_indicate_func_t indicate_func;
+
+ /**
+ * host interface functions
+ **/
+ wilc_hif_func_t hif_func;
+ void *hif_lock;
+
+ /**
+ * configuration interface functions
+ **/
+ wilc_cfg_func_t cif_func;
+ int cfg_frame_in_use;
+ wilc_cfg_frame_t cfg_frame;
+ uint32_t cfg_frame_offset;
+ int cfg_seq_no;
+ void *cfg_wait;
+
+ /**
+ * RX buffer
+ **/
+ #ifdef MEMORY_STATIC
+ uint32_t rx_buffer_size;
+ uint8_t *rx_buffer;
+ uint32_t rx_buffer_offset;
+ #endif
+ /**
+ * TX buffer
+ **/
+ uint32_t tx_buffer_size;
+ uint8_t *tx_buffer;
+ uint32_t tx_buffer_offset;
+
+ /**
+ * TX queue
+ **/
+ void *txq_lock;
+
+ /*Added by Amr - BugID_4720*/
+ void *txq_add_to_head_lock;
+ void *txq_spinlock;
+ unsigned long txq_spinlock_flags;
+
+ struct txq_entry_t *txq_head;
+ struct txq_entry_t *txq_tail;
+ int txq_entries;
+ void *txq_wait;
+ int txq_exit;
+
+ /**
+ * RX queue
+ **/
+ void *rxq_lock;
+ struct rxq_entry_t *rxq_head;
+ struct rxq_entry_t *rxq_tail;
+ int rxq_entries;
+ void *rxq_wait;
+ int rxq_exit;
+
+
+} wilc_wlan_dev_t;
+
+static wilc_wlan_dev_t g_wlan;
+
+INLINE void chip_allow_sleep(void);
+INLINE void chip_wakeup(void);
+/********************************************
+ *
+ * Debug
+ *
+ ********************************************/
+
+static uint32_t dbgflag = N_INIT | N_ERR | N_INTR | N_TXQ | N_RXQ;
+
+static void wilc_debug(uint32_t flag, char *fmt, ...)
+{
+ char buf[256];
+ va_list args;
+ int len;
+
+ if (flag & dbgflag) {
+ va_start(args, fmt);
+ len = vsprintf(buf, fmt, args);
+ va_end(args);
+
+ if (g_wlan.os_func.os_debug)
+ g_wlan.os_func.os_debug(buf);
+ }
+
+ return;
+}
+
+static CHIP_PS_STATE_T genuChipPSstate = CHIP_WAKEDUP;
+
+/*BugID_5213*/
+/*acquire_bus() and release_bus() are made INLINE functions*/
+/*as a temporary workaround to fix a problem of receiving*/
+/*unknown interrupt from FW*/
+INLINE void acquire_bus(BUS_ACQUIRE_T acquire)
+{
+
+ g_wlan.os_func.os_enter_cs(g_wlan.hif_lock);
+ #ifndef WILC_OPTIMIZE_SLEEP_INT
+ if (genuChipPSstate != CHIP_WAKEDUP)
+ #endif
+ {
+ if (acquire == ACQUIRE_AND_WAKEUP)
+ chip_wakeup();
+ }
+
+}
+INLINE void release_bus(BUS_RELEASE_T release)
+{
+ #ifdef WILC_OPTIMIZE_SLEEP_INT
+ if (release == RELEASE_ALLOW_SLEEP)
+ chip_allow_sleep();
+ #endif
+ g_wlan.os_func.os_leave_cs(g_wlan.hif_lock);
+}
+/********************************************
+ *
+ * Queue
+ *
+ ********************************************/
+
+static void wilc_wlan_txq_remove(struct txq_entry_t *tqe)
+{
+
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ /* unsigned long flags; */
+ /* p->os_func.os_spin_lock(p->txq_spinlock, &flags); */
+ if (tqe == p->txq_head) {
+
+ p->txq_head = tqe->next;
+ if (p->txq_head)
+ p->txq_head->prev = NULL;
+
+
+ } else if (tqe == p->txq_tail) {
+ p->txq_tail = (tqe->prev);
+ if (p->txq_tail)
+ p->txq_tail->next = NULL;
+ } else {
+ tqe->prev->next = tqe->next;
+ tqe->next->prev = tqe->prev;
+ }
+ p->txq_entries -= 1;
+ /* p->os_func.os_spin_unlock(p->txq_spinlock, &flags); */
+
+}
+
+static struct txq_entry_t *wilc_wlan_txq_remove_from_head(void)
+{
+ struct txq_entry_t *tqe;
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ unsigned long flags;
+ p->os_func.os_spin_lock(p->txq_spinlock, &flags);
+ if (p->txq_head) {
+ /* p->os_func.os_enter_cs(p->txq_lock); */
+ tqe = p->txq_head;
+ p->txq_head = tqe->next;
+ if (p->txq_head) {
+ p->txq_head->prev = NULL;
+ }
+ p->txq_entries -= 1;
+
+ /*Added by Amr - BugID_4720*/
+
+
+ /* p->os_func.os_leave_cs(p->txq_lock); */
+
+ } else {
+ tqe = NULL;
+ }
+ p->os_func.os_spin_unlock(p->txq_spinlock, &flags);
+ return tqe;
+}
+
+static void wilc_wlan_txq_add_to_tail(struct txq_entry_t *tqe)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ unsigned long flags;
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_spin_lock(p->txq_spinlock, &flags);
+
+/* p->os_func.os_enter_cs(p->txq_lock); */
+ if (p->txq_head == NULL) {
+ tqe->next = NULL;
+ tqe->prev = NULL;
+ p->txq_head = tqe;
+ p->txq_tail = tqe;
+ /* p->os_func.os_signal(p->txq_wait); */
+ } else {
+ tqe->next = NULL;
+ tqe->prev = p->txq_tail;
+ p->txq_tail->next = tqe;
+ p->txq_tail = tqe;
+ }
+ p->txq_entries += 1;
+ PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", p->txq_entries);
+/* p->os_func.os_leave_cs(p->txq_lock); */
+
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_spin_unlock(p->txq_spinlock, &flags);
+
+ /**
+ * wake up TX queue
+ **/
+ PRINT_D(TX_DBG, "Wake the txq_handling\n");
+
+ p->os_func.os_signal(p->txq_wait);
+
+
+}
+
+static int wilc_wlan_txq_add_to_head(struct txq_entry_t *tqe)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ unsigned long flags;
+ /*Added by Amr - BugID_4720*/
+ if (p->os_func.os_wait(p->txq_add_to_head_lock, CFG_PKTS_TIMEOUT))
+ return -1;
+
+ p->os_func.os_spin_lock(p->txq_spinlock, &flags);
+
+ /* p->os_func.os_enter_cs(p->txq_lock); */
+ if (p->txq_head == NULL) {
+ tqe->next = NULL;
+ tqe->prev = NULL;
+ p->txq_head = tqe;
+ p->txq_tail = tqe;
+ } else {
+ tqe->next = p->txq_head;
+ tqe->prev = NULL;
+ p->txq_head->prev = tqe;
+ p->txq_head = tqe;
+ }
+ p->txq_entries += 1;
+ PRINT_D(TX_DBG, "Number of entries in TxQ = %d\n", p->txq_entries);
+ /* p->os_func.os_leave_cs(p->txq_lock); */
+
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_spin_unlock(p->txq_spinlock, &flags);
+ p->os_func.os_signal(p->txq_add_to_head_lock);
+
+
+ /**
+ * wake up TX queue
+ **/
+ p->os_func.os_signal(p->txq_wait);
+ PRINT_D(TX_DBG, "Wake up the txq_handler\n");
+/* complete(p->txq_wait); */
+
+ /*Added by Amr - BugID_4720*/
+ return 0;
+
+}
+
+uint32_t Statisitcs_totalAcks = 0, Statisitcs_DroppedAcks = 0;
+
+#ifdef TCP_ACK_FILTER
+struct Ack_session_info;
+typedef struct Ack_session_info {
+ uint32_t Ack_seq_num;
+ uint32_t Bigger_Ack_num;
+ uint16_t src_port;
+ uint16_t dst_port;
+ uint16_t status;
+ /* struct Ack_session_info * next; */
+ /* struct Ack_session_info * prev; */
+} Ack_session_info_t;
+
+typedef struct {
+ uint32_t ack_num;
+ /* uint32_t seq_num; */
+ /* uint16_t src_port; */
+ /* uint16_t dst_port; */
+ /* uint32_t dst_ip_addr; */
+ uint32_t Session_index;
+ struct txq_entry_t *txqe;
+ /* Ack_session_info * Ack_session; */
+} Pending_Acks_info_t /*Ack_info_t*/;
+
+
+
+
+struct Ack_session_info *Free_head;
+struct Ack_session_info *Alloc_head;
+
+#define TCP_FIN_MASK (1 << 0)
+#define TCP_SYN_MASK (1 << 1)
+#define TCP_Ack_MASK (1 << 4)
+#define NOT_TCP_ACK (-1)
+
+#define MAX_TCP_SESSION 25
+#define MAX_PENDING_ACKS 256
+Ack_session_info_t Acks_keep_track_info[2 * MAX_TCP_SESSION];
+Pending_Acks_info_t Pending_Acks_info[MAX_PENDING_ACKS];
+
+uint32_t PendingAcks_arrBase;
+uint32_t Opened_TCP_session;
+uint32_t Pending_Acks;
+
+
+
+static __inline int Init_TCP_tracking(void)
+{
+
+ /*uint32_t i;
+ * Free_head=&Acks_keep_track_info[0];
+ * i=1;
+ * Acks_keep_track_info[0].next=&Acks_keep_track_info[1];
+ * for(i=1<;i<MAX_TCP_SESSION-1;i++)
+ * {
+ * Acks_keep_track_info[i].next=&Acks_keep_track_info[i+1];
+ * Acks_keep_track_info[i].prev=&Acks_keep_track_info[i-1];
+ * }
+ * Acks_keep_track_info[49].prev=&Acks_keep_track_info[48];
+ */
+ return 0;
+
+}
+static __inline int add_TCP_track_session(uint32_t src_prt, uint32_t dst_prt, uint32_t seq)
+{
+ Acks_keep_track_info[Opened_TCP_session].Ack_seq_num = seq;
+ Acks_keep_track_info[Opened_TCP_session].Bigger_Ack_num = 0;
+ Acks_keep_track_info[Opened_TCP_session].src_port = src_prt;
+ Acks_keep_track_info[Opened_TCP_session].dst_port = dst_prt;
+ Opened_TCP_session++;
+
+ PRINT_D(TCP_ENH, "TCP Session %d to Ack %d\n", Opened_TCP_session, seq);
+ return 0;
+}
+
+static __inline int Update_TCP_track_session(uint32_t index, uint32_t Ack)
+{
+
+ if (Ack > Acks_keep_track_info[index].Bigger_Ack_num) {
+ Acks_keep_track_info[index].Bigger_Ack_num = Ack;
+ }
+ return 0;
+
+}
+static __inline int add_TCP_Pending_Ack(uint32_t Ack, uint32_t Session_index, struct txq_entry_t *txqe)
+{
+ Statisitcs_totalAcks++;
+ if (Pending_Acks < MAX_PENDING_ACKS) {
+ Pending_Acks_info[PendingAcks_arrBase + Pending_Acks].ack_num = Ack;
+ Pending_Acks_info[PendingAcks_arrBase + Pending_Acks].txqe = txqe;
+ Pending_Acks_info[PendingAcks_arrBase + Pending_Acks].Session_index = Session_index;
+ txqe->tcp_PendingAck_index = PendingAcks_arrBase + Pending_Acks;
+ Pending_Acks++;
+
+ } else {
+
+ }
+ return 0;
+}
+static __inline int remove_TCP_related(void)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ unsigned long flags;
+ p->os_func.os_spin_lock(p->txq_spinlock, &flags);
+
+ p->os_func.os_spin_unlock(p->txq_spinlock, &flags);
+ return 0;
+}
+
+static __inline int tcp_process(struct txq_entry_t *tqe)
+{
+ int ret;
+ uint8_t *eth_hdr_ptr;
+ uint8_t *buffer = tqe->buffer;
+ unsigned short h_proto;
+ int i;
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ unsigned long flags;
+ p->os_func.os_spin_lock(p->txq_spinlock, &flags);
+
+ eth_hdr_ptr = &buffer[0];
+ h_proto = ntohs(*((unsigned short *)&eth_hdr_ptr[12]));
+ if (h_proto == 0x0800) { /* IP */
+ uint8_t *ip_hdr_ptr;
+ uint8_t protocol;
+
+ ip_hdr_ptr = &buffer[ETHERNET_HDR_LEN];
+ protocol = ip_hdr_ptr[9];
+
+
+ if (protocol == 0x06) {
+ uint8_t *tcp_hdr_ptr;
+ uint32_t IHL, Total_Length, Data_offset;
+ tcp_hdr_ptr = &ip_hdr_ptr[IP_HDR_LEN];
+ IHL = (ip_hdr_ptr[0] & 0xf) << 2;
+ Total_Length = (((uint32_t)ip_hdr_ptr[2]) << 8) + ((uint32_t)ip_hdr_ptr[3]);
+ Data_offset = (((uint32_t)tcp_hdr_ptr[12] & 0xf0) >> 2);
+ if (Total_Length == (IHL + Data_offset)) { /*we want to recognize the clear Acks(packet only carry Ack infos not with data) so data size must be equal zero*/
+ uint32_t seq_no, Ack_no;
+ seq_no = (((uint32_t)tcp_hdr_ptr[4]) << 24) + (((uint32_t)tcp_hdr_ptr[5]) << 16) + (((uint32_t)tcp_hdr_ptr[6]) << 8) + ((uint32_t)tcp_hdr_ptr[7]);
+
+ Ack_no = (((uint32_t)tcp_hdr_ptr[8]) << 24) + (((uint32_t)tcp_hdr_ptr[9]) << 16) + (((uint32_t)tcp_hdr_ptr[10]) << 8) + ((uint32_t)tcp_hdr_ptr[11]);
+
+
+ for (i = 0; i < Opened_TCP_session; i++) {
+ if (Acks_keep_track_info[i].Ack_seq_num == seq_no) {
+ Update_TCP_track_session(i, Ack_no);
+ break;
+ }
+ }
+ if (i == Opened_TCP_session) {
+ add_TCP_track_session(0, 0, seq_no);
+ }
+ add_TCP_Pending_Ack(Ack_no, i, tqe);
+
+
+ }
+
+ } else {
+ ret = 0;
+ }
+ } else {
+ ret = 0;
+ }
+ p->os_func.os_spin_unlock(p->txq_spinlock, &flags);
+ return ret;
+}
+
+
+static int wilc_wlan_txq_filter_dup_tcp_ack(void)
+{
+
+ uint32_t i = 0;
+ uint32_t Dropped = 0;
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+
+ p->os_func.os_spin_lock(p->txq_spinlock, &p->txq_spinlock_flags);
+ for (i = PendingAcks_arrBase; i < (PendingAcks_arrBase + Pending_Acks); i++) {
+ if (Pending_Acks_info[i].ack_num < Acks_keep_track_info[Pending_Acks_info[i].Session_index].Bigger_Ack_num) {
+ struct txq_entry_t *tqe;
+ PRINT_D(TCP_ENH, "DROP ACK: %u \n", Pending_Acks_info[i].ack_num);
+ tqe = Pending_Acks_info[i].txqe;
+ if (tqe) {
+ wilc_wlan_txq_remove(tqe);
+ Statisitcs_DroppedAcks++;
+ tqe->status = 1; /* mark the packet send */
+ if (tqe->tx_complete_func)
+ tqe->tx_complete_func(tqe->priv, tqe->status);
+ p->os_func.os_free(tqe);
+ Dropped++;
+ /* p->txq_entries -= 1; */
+ }
+ }
+ }
+ Pending_Acks = 0;
+ Opened_TCP_session = 0;
+
+ if (PendingAcks_arrBase == 0) {
+ PendingAcks_arrBase = MAX_TCP_SESSION;
+ } else {
+ PendingAcks_arrBase = 0;
+ }
+
+
+ p->os_func.os_spin_unlock(p->txq_spinlock, &p->txq_spinlock_flags);
+
+ while (Dropped > 0) {
+ /*consume the semaphore count of the removed packet*/
+ p->os_func.os_wait(p->txq_wait, 1);
+ Dropped--;
+ }
+
+ return 1;
+}
+#endif
+
+#ifdef TCP_ENHANCEMENTS
+WILC_Bool EnableTCPAckFilter = WILC_FALSE;
+
+void Enable_TCP_ACK_Filter(WILC_Bool value)
+{
+ EnableTCPAckFilter = value;
+}
+
+WILC_Bool is_TCP_ACK_Filter_Enabled(void)
+{
+ return EnableTCPAckFilter;
+}
+#endif
+
+static int wilc_wlan_txq_add_cfg_pkt(uint8_t *buffer, uint32_t buffer_size)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ struct txq_entry_t *tqe;
+
+ PRINT_D(TX_DBG, "Adding config packet ...\n");
+ if (p->quit) {
+ PRINT_D(TX_DBG, "Return due to clear function\n");
+ p->os_func.os_signal(p->cfg_wait);
+ return 0;
+ }
+
+ tqe = (struct txq_entry_t *)p->os_func.os_malloc_atomic(sizeof(struct txq_entry_t));
+ if (tqe == NULL) {
+ PRINT_ER("Failed to allocate memory\n");
+ return 0;
+ }
+
+ tqe->type = WILC_CFG_PKT;
+ tqe->buffer = buffer;
+ tqe->buffer_size = buffer_size;
+ tqe->tx_complete_func = NULL;
+ tqe->priv = NULL;
+#ifdef TCP_ACK_FILTER
+ tqe->tcp_PendingAck_index = NOT_TCP_ACK;
+#endif
+ /**
+ * Configuration packet always at the front
+ **/
+ PRINT_D(TX_DBG, "Adding the config packet at the Queue tail\n");
+
+ /*Edited by Amr - BugID_4720*/
+ if (wilc_wlan_txq_add_to_head(tqe))
+ return 0;
+ /* wilc_wlan_txq_add_to_tail(tqe); */
+ return 1;
+}
+
+static int wilc_wlan_txq_add_net_pkt(void *priv, uint8_t *buffer, uint32_t buffer_size, wilc_tx_complete_func_t func)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ struct txq_entry_t *tqe;
+
+ if (p->quit)
+ return 0;
+
+ tqe = (struct txq_entry_t *)p->os_func.os_malloc_atomic(sizeof(struct txq_entry_t));
+
+ if (tqe == NULL)
+ return 0;
+ tqe->type = WILC_NET_PKT;
+ tqe->buffer = buffer;
+ tqe->buffer_size = buffer_size;
+ tqe->tx_complete_func = func;
+ tqe->priv = priv;
+
+ PRINT_D(TX_DBG, "Adding mgmt packet at the Queue tail\n");
+#ifdef TCP_ACK_FILTER
+ tqe->tcp_PendingAck_index = NOT_TCP_ACK;
+#ifdef TCP_ENHANCEMENTS
+ if (is_TCP_ACK_Filter_Enabled() == WILC_TRUE)
+#endif
+ tcp_process(tqe);
+#endif
+ wilc_wlan_txq_add_to_tail(tqe);
+ /*return number of itemes in the queue*/
+ return p->txq_entries;
+}
+/*Bug3959: transmitting mgmt frames received from host*/
+#if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P)
+int wilc_wlan_txq_add_mgmt_pkt(void *priv, uint8_t *buffer, uint32_t buffer_size, wilc_tx_complete_func_t func)
+{
+
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ struct txq_entry_t *tqe;
+
+ if (p->quit)
+ return 0;
+
+ tqe = (struct txq_entry_t *)p->os_func.os_malloc_atomic(sizeof(struct txq_entry_t));
+
+ if (tqe == NULL)
+ return 0;
+ tqe->type = WILC_MGMT_PKT;
+ tqe->buffer = buffer;
+ tqe->buffer_size = buffer_size;
+ tqe->tx_complete_func = func;
+ tqe->priv = priv;
+#ifdef TCP_ACK_FILTER
+ tqe->tcp_PendingAck_index = NOT_TCP_ACK;
+#endif
+ PRINT_D(TX_DBG, "Adding Network packet at the Queue tail\n");
+ wilc_wlan_txq_add_to_tail(tqe);
+ return 1;
+}
+
+#ifdef WILC_FULLY_HOSTING_AP
+int wilc_FH_wlan_txq_add_net_pkt(void *priv, uint8_t *buffer, uint32_t buffer_size, wilc_tx_complete_func_t func)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ struct txq_entry_t *tqe;
+
+ if (p->quit)
+ return 0;
+
+ tqe = (struct txq_entry_t *)p->os_func.os_malloc_atomic(sizeof(struct txq_entry_t));
+
+ if (tqe == NULL)
+ return 0;
+ tqe->type = WILC_FH_DATA_PKT;
+ tqe->buffer = buffer;
+ tqe->buffer_size = buffer_size;
+ tqe->tx_complete_func = func;
+ tqe->priv = priv;
+ PRINT_D(TX_DBG, "Adding mgmt packet at the Queue tail\n");
+ wilc_wlan_txq_add_to_tail(tqe);
+ /*return number of itemes in the queue*/
+ return p->txq_entries;
+}
+#endif /* WILC_FULLY_HOSTING_AP*/
+#endif /*WILC_AP_EXTERNAL_MLME*/
+static struct txq_entry_t *wilc_wlan_txq_get_first(void)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ struct txq_entry_t *tqe;
+ unsigned long flags;
+
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_spin_lock(p->txq_spinlock, &flags);
+
+ /* p->os_func.os_enter_cs(p->txq_lock); */
+ tqe = p->txq_head;
+
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_spin_unlock(p->txq_spinlock, &flags);
+
+ /* p->os_func.os_leave_cs(p->txq_lock); */
+
+ return tqe;
+}
+
+static struct txq_entry_t *wilc_wlan_txq_get_next(struct txq_entry_t *tqe)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ unsigned long flags;
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_spin_lock(p->txq_spinlock, &flags);
+
+ /* p->os_func.os_enter_cs(p->txq_lock); */
+ tqe = tqe->next;
+
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_spin_unlock(p->txq_spinlock, &flags);
+
+ /* p->os_func.os_leave_cs(p->txq_lock); */
+
+ return tqe;
+}
+
+static int wilc_wlan_rxq_add(struct rxq_entry_t *rqe)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+
+ if (p->quit)
+ return 0;
+
+ p->os_func.os_enter_cs(p->rxq_lock);
+ if (p->rxq_head == NULL) {
+ PRINT_D(RX_DBG, "Add to Queue head\n");
+ rqe->next = NULL;
+ p->rxq_head = rqe;
+ p->rxq_tail = rqe;
+ } else {
+ PRINT_D(RX_DBG, "Add to Queue tail\n");
+ p->rxq_tail->next = rqe;
+ rqe->next = NULL;
+ p->rxq_tail = rqe;
+ }
+ p->rxq_entries += 1;
+ PRINT_D(RX_DBG, "Number of queue entries: %d\n", p->rxq_entries);
+ p->os_func.os_leave_cs(p->rxq_lock);
+ return p->rxq_entries;
+}
+
+static struct rxq_entry_t *wilc_wlan_rxq_remove(void)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+
+ PRINT_D(RX_DBG, "Getting rxQ element\n");
+ if (p->rxq_head) {
+ struct rxq_entry_t *rqe;
+
+ p->os_func.os_enter_cs(p->rxq_lock);
+ rqe = p->rxq_head;
+ p->rxq_head = p->rxq_head->next;
+ p->rxq_entries -= 1;
+ PRINT_D(RX_DBG, "RXQ entries decreased\n");
+ p->os_func.os_leave_cs(p->rxq_lock);
+ return rqe;
+ }
+ PRINT_D(RX_DBG, "Nothing to get from Q\n");
+ return NULL;
+}
+
+
+/********************************************
+ *
+ * Power Save handle functions
+ *
+ ********************************************/
+
+
+
+#ifdef WILC_OPTIMIZE_SLEEP_INT
+
+INLINE void chip_allow_sleep(void)
+{
+ uint32_t reg = 0;
+
+ /* Clear bit 1 */
+ g_wlan.hif_func.hif_read_reg(0xf0, &reg);
+
+ g_wlan.hif_func.hif_write_reg(0xf0, reg & ~(1 << 0));
+}
+
+INLINE void chip_wakeup(void)
+{
+ uint32_t reg, clk_status_reg, trials = 0;
+ uint32_t sleep_time;
+
+ if ((g_wlan.io_func.io_type & 0x1) == HIF_SPI) {
+ do {
+ g_wlan.hif_func.hif_read_reg(1, &reg);
+ /* Set bit 1 */
+ g_wlan.hif_func.hif_write_reg(1, reg | (1 << 1));
+
+ /* Clear bit 1*/
+ g_wlan.hif_func.hif_write_reg(1, reg & ~(1 << 1));
+
+ do {
+ /* Wait for the chip to stabilize*/
+ WILC_Sleep(2);
+ /* Make sure chip is awake. This is an extra step that can be removed */
+ /* later to avoid the bus access overhead */
+ if ((wilc_get_chipid(WILC_TRUE) == 0)) {
+ wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");
+ }
+ } while ((wilc_get_chipid(WILC_TRUE) == 0) && ((++trials % 3) == 0));
+
+ } while (wilc_get_chipid(WILC_TRUE) == 0);
+ } else if ((g_wlan.io_func.io_type & 0x1) == HIF_SDIO) {
+ g_wlan.hif_func.hif_read_reg(0xf0, &reg);
+ do {
+ /* Set bit 1 */
+ g_wlan.hif_func.hif_write_reg(0xf0, reg | (1 << 0));
+
+ /* Check the clock status */
+ g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg);
+
+ /* in case of clocks off, wait 2ms, and check it again. */
+ /* if still off, wait for another 2ms, for a total wait of 6ms. */
+ /* If still off, redo the wake up sequence */
+ while (((clk_status_reg & 0x1) == 0) && (((++trials) % 3) == 0)) {
+ /* Wait for the chip to stabilize*/
+ WILC_Sleep(2);
+
+ /* Make sure chip is awake. This is an extra step that can be removed */
+ /* later to avoid the bus access overhead */
+ g_wlan.hif_func.hif_read_reg(0xf1, &clk_status_reg);
+
+ if ((clk_status_reg & 0x1) == 0) {
+ wilc_debug(N_ERR, "clocks still OFF. Wake up failed\n");
+ }
+ }
+ /* in case of failure, Reset the wakeup bit to introduce a new edge on the next loop */
+ if ((clk_status_reg & 0x1) == 0) {
+ /* Reset bit 0 */
+ g_wlan.hif_func.hif_write_reg(0xf0, reg & (~(1 << 0)));
+ }
+ } while ((clk_status_reg & 0x1) == 0);
+ }
+
+
+ if (genuChipPSstate == CHIP_SLEEPING_MANUAL) {
+ g_wlan.hif_func.hif_read_reg(0x1C0C, &reg);
+ reg &= ~(1 << 0);
+ g_wlan.hif_func.hif_write_reg(0x1C0C, reg);
+
+ if (wilc_get_chipid(WILC_FALSE) >= 0x1002b0) {
+ /* Enable PALDO back right after wakeup */
+ uint32_t val32;
+ g_wlan.hif_func.hif_read_reg(0x1e1c, &val32);
+ val32 |= (1 << 6);
+ g_wlan.hif_func.hif_write_reg(0x1e1c, val32);
+
+ g_wlan.hif_func.hif_read_reg(0x1e9c, &val32);
+ val32 |= (1 << 6);
+ g_wlan.hif_func.hif_write_reg(0x1e9c, val32);
+ }
+ }
+ genuChipPSstate = CHIP_WAKEDUP;
+}
+#else
+INLINE void chip_wakeup(void)
+{
+ uint32_t reg, trials = 0;
+ do {
+ if ((g_wlan.io_func.io_type & 0x1) == HIF_SPI) {
+ g_wlan.hif_func.hif_read_reg(1, &reg);
+ /* Make sure bit 1 is 0 before we start. */
+ g_wlan.hif_func.hif_write_reg(1, reg & ~(1 << 1));
+ /* Set bit 1 */
+ g_wlan.hif_func.hif_write_reg(1, reg | (1 << 1));
+ /* Clear bit 1*/
+ g_wlan.hif_func.hif_write_reg(1, reg & ~(1 << 1));
+ } else if ((g_wlan.io_func.io_type & 0x1) == HIF_SDIO) {
+ /* Make sure bit 0 is 0 before we start. */
+ g_wlan.hif_func.hif_read_reg(0xf0, &reg);
+ g_wlan.hif_func.hif_write_reg(0xf0, reg & ~(1 << 0));
+ /* Set bit 1 */
+ g_wlan.hif_func.hif_write_reg(0xf0, reg | (1 << 0));
+ /* Clear bit 1 */
+ g_wlan.hif_func.hif_write_reg(0xf0, reg & ~(1 << 0));
+ }
+
+ do {
+ /* Wait for the chip to stabilize*/
+/* WILC_Sleep(2); */
+ mdelay(3);
+
+ /* Make sure chip is awake. This is an extra step that can be removed */
+ /* later to avoid the bus access overhead */
+ if ((wilc_get_chipid(WILC_TRUE) == 0)) {
+ wilc_debug(N_ERR, "Couldn't read chip id. Wake up failed\n");
+ }
+ } while ((wilc_get_chipid(WILC_TRUE) == 0) && ((++trials % 3) == 0));
+
+ } while (wilc_get_chipid(WILC_TRUE) == 0);
+
+ if (genuChipPSstate == CHIP_SLEEPING_MANUAL) {
+ g_wlan.hif_func.hif_read_reg(0x1C0C, &reg);
+ reg &= ~(1 << 0);
+ g_wlan.hif_func.hif_write_reg(0x1C0C, reg);
+
+ if (wilc_get_chipid(WILC_FALSE) >= 0x1002b0) {
+ /* Enable PALDO back right after wakeup */
+ uint32_t val32;
+ g_wlan.hif_func.hif_read_reg(0x1e1c, &val32);
+ val32 |= (1 << 6);
+ g_wlan.hif_func.hif_write_reg(0x1e1c, val32);
+
+ g_wlan.hif_func.hif_read_reg(0x1e9c, &val32);
+ val32 |= (1 << 6);
+ g_wlan.hif_func.hif_write_reg(0x1e9c, val32);
+ }
+ }
+ genuChipPSstate = CHIP_WAKEDUP;
+}
+#endif
+void chip_sleep_manually(WILC_Uint32 u32SleepTime)
+{
+ if (genuChipPSstate != CHIP_WAKEDUP) {
+ /* chip is already sleeping. Do nothing */
+ return;
+ }
+ acquire_bus(ACQUIRE_ONLY);
+
+#ifdef WILC_OPTIMIZE_SLEEP_INT
+ chip_allow_sleep();
+#endif
+
+ /* Trigger the manual sleep interrupt */
+ g_wlan.hif_func.hif_write_reg(0x10a8, 1);
+
+ genuChipPSstate = CHIP_SLEEPING_MANUAL;
+ release_bus(RELEASE_ONLY);
+
+}
+
+
+/********************************************
+ *
+ * Tx, Rx queue handle functions
+ *
+ ********************************************/
+static int wilc_wlan_handle_txq(uint32_t *pu32TxqCount)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ int i, entries = 0;
+ uint32_t sum;
+ uint32_t reg;
+ uint8_t *txb = p->tx_buffer;
+ uint32_t offset = 0;
+ int vmm_sz = 0;
+ struct txq_entry_t *tqe;
+ int ret = 0;
+ int counter;
+ int timeout;
+ uint32_t vmm_table[WILC_VMM_TBL_SIZE];
+ p->txq_exit = 0;
+ do {
+ if (p->quit)
+ break;
+
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_wait(p->txq_add_to_head_lock, CFG_PKTS_TIMEOUT);
+#ifdef TCP_ACK_FILTER
+ wilc_wlan_txq_filter_dup_tcp_ack();
+#endif
+ /**
+ * build the vmm list
+ **/
+ PRINT_D(TX_DBG, "Getting the head of the TxQ\n");
+ tqe = wilc_wlan_txq_get_first();
+ i = 0;
+ sum = 0;
+ do {
+ /* if ((tqe != NULL) && (i < (8)) && */
+ /* if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE-1)) && */
+ if ((tqe != NULL) && (i < (WILC_VMM_TBL_SIZE - 1)) /* reserve last entry to 0 */) {
+
+ if (tqe->type == WILC_CFG_PKT) {
+ vmm_sz = ETH_CONFIG_PKT_HDR_OFFSET;
+ }
+ /*Bug3959: transmitting mgmt frames received from host*/
+ /*vmm_sz will only be equal to tqe->buffer_size + 4 bytes (HOST_HDR_OFFSET)*/
+ /* in other cases WILC_MGMT_PKT and WILC_DATA_PKT_MAC_HDR*/
+ else if (tqe->type == WILC_NET_PKT) {
+ vmm_sz = ETH_ETHERNET_HDR_OFFSET;
+ }
+#ifdef WILC_FULLY_HOSTING_AP
+ else if (tqe->type == WILC_FH_DATA_PKT) {
+ vmm_sz = FH_TX_HOST_HDR_OFFSET;
+ }
+#endif
+#ifdef WILC_AP_EXTERNAL_MLME
+ else {
+ vmm_sz = HOST_HDR_OFFSET;
+ }
+#endif
+ vmm_sz += tqe->buffer_size;
+ PRINT_D(TX_DBG, "VMM Size before alignment = %d\n", vmm_sz);
+ if (vmm_sz & 0x3) { /* has to be word aligned */
+ vmm_sz = (vmm_sz + 4) & ~0x3;
+ }
+ if ((sum + vmm_sz) > p->tx_buffer_size) {
+ break;
+ }
+ PRINT_D(TX_DBG, "VMM Size AFTER alignment = %d\n", vmm_sz);
+ vmm_table[i] = vmm_sz / 4; /* table take the word size */
+ PRINT_D(TX_DBG, "VMMTable entry size = %d\n", vmm_table[i]);
+
+ if (tqe->type == WILC_CFG_PKT) {
+ vmm_table[i] |= (1 << 10);
+ PRINT_D(TX_DBG, "VMMTable entry changed for CFG packet = %d\n", vmm_table[i]);
+ }
+#ifdef BIG_ENDIAN
+ vmm_table[i] = BYTE_SWAP(vmm_table[i]);
+#endif
+ /* p->hif_func.hif_write_reg(0x1160,vmm_table[0]); */
+
+ /* wilc_debug(N_TXQ, "[wilc txq]: vmm table[%d] = %08x\n", i, vmm_table[i]); */
+ i++;
+ sum += vmm_sz;
+ PRINT_D(TX_DBG, "sum = %d\n", sum);
+ tqe = wilc_wlan_txq_get_next(tqe);
+ } else {
+ break;
+ }
+ } while (1);
+
+ if (i == 0) { /* nothing in the queue */
+ PRINT_D(TX_DBG, "Nothing in TX-Q\n");
+ break;
+ } else {
+ PRINT_D(TX_DBG, "Mark the last entry in VMM table - number of previous entries = %d\n", i);
+ vmm_table[i] = 0x0; /* mark the last element to 0 */
+ }
+ acquire_bus(ACQUIRE_AND_WAKEUP);
+ counter = 0;
+ do {
+
+ ret = p->hif_func.hif_read_reg(WILC_HOST_TX_CTRL, &reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc txq]: fail can't read reg vmm_tbl_entry..\n");
+ break;
+ }
+
+ if ((reg & 0x1) == 0) {
+ /**
+ * write to vmm table
+ **/
+ PRINT_D(TX_DBG, "Writing VMM table ... with Size = %d\n", ((i + 1) * 4));
+ break;
+ } else {
+ counter++;
+ if (counter > 200) {
+ counter = 0;
+ PRINT_D(TX_DBG, "Looping in tx ctrl , forcce quit\n");
+ ret = p->hif_func.hif_write_reg(WILC_HOST_TX_CTRL, 0);
+ break;
+ }
+ /**
+ * wait for vmm table is ready
+ **/
+ PRINT_WRN(GENERIC_DBG, "[wilc txq]: warn, vmm table not clear yet, wait... \n");
+ release_bus(RELEASE_ALLOW_SLEEP);
+ p->os_func.os_sleep(3); /* wait 3 ms */
+ acquire_bus(ACQUIRE_AND_WAKEUP);
+ }
+ } while (!p->quit);
+
+ if (!ret) {
+ goto _end_;
+ }
+
+ timeout = 200;
+ do {
+
+ /**
+ * write to vmm table
+ **/
+ ret = p->hif_func.hif_block_tx(WILC_VMM_TBL_RX_SHADOW_BASE, (uint8_t *)vmm_table, ((i + 1) * 4)); /* Bug 4477 fix */
+ if (!ret) {
+ wilc_debug(N_ERR, "ERR block TX of VMM table.\n");
+ break;
+ }
+
+
+ /**
+ * interrupt firmware
+ **/
+ ret = p->hif_func.hif_write_reg(WILC_HOST_VMM_CTL, 0x2);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc txq]: fail can't write reg host_vmm_ctl..\n");
+ break;
+ }
+
+ /**
+ * wait for confirm...
+ **/
+
+ do {
+ ret = p->hif_func.hif_read_reg(WILC_HOST_VMM_CTL, &reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc txq]: fail can't read reg host_vmm_ctl..\n");
+ break;
+ }
+ if ((reg >> 2) & 0x1) {
+ /**
+ * Get the entries
+ **/
+ entries = ((reg >> 3) & 0x3f);
+ /* entries = ((reg>>3)&0x2f); */
+ break;
+ } else {
+ release_bus(RELEASE_ALLOW_SLEEP);
+ p->os_func.os_sleep(3); /* wait 3 ms */
+ acquire_bus(ACQUIRE_AND_WAKEUP);
+ PRINT_WRN(GENERIC_DBG, "Can't get VMM entery - reg = %2x\n", reg);
+ }
+ } while (--timeout);
+ if (timeout <= 0) {
+ ret = p->hif_func.hif_write_reg(WILC_HOST_VMM_CTL, 0x0);
+ break;
+ }
+
+ if (!ret) {
+ break;
+ }
+
+ if (entries == 0) {
+ PRINT_WRN(GENERIC_DBG, "[wilc txq]: no more buffer in the chip (reg: %08x), retry later [[ %d, %x ]] \n", reg, i, vmm_table[i - 1]);
+
+ /* undo the transaction. */
+ ret = p->hif_func.hif_read_reg(WILC_HOST_TX_CTRL, &reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc txq]: fail can't read reg WILC_HOST_TX_CTRL..\n");
+ break;
+ }
+ reg &= ~(1ul << 0);
+ ret = p->hif_func.hif_write_reg(WILC_HOST_TX_CTRL, reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc txq]: fail can't write reg WILC_HOST_TX_CTRL..\n");
+ break;
+ }
+ break;
+ } else {
+ break;
+ }
+ } while (1);
+
+ if (!ret) {
+ goto _end_;
+ }
+ if (entries == 0) {
+ ret = WILC_TX_ERR_NO_BUF;
+ goto _end_;
+ }
+
+ /* since copying data into txb takes some time, then
+ * allow the bus lock to be released let the RX task go. */
+ release_bus(RELEASE_ALLOW_SLEEP);
+
+ /**
+ * Copy data to the TX buffer
+ **/
+ offset = 0;
+ i = 0;
+ do {
+ tqe = wilc_wlan_txq_remove_from_head();
+ if (tqe != NULL && (vmm_table[i] != 0)) {
+ uint32_t header, buffer_offset;
+
+#ifdef BIG_ENDIAN
+ vmm_table[i] = BYTE_SWAP(vmm_table[i]);
+#endif
+ vmm_sz = (vmm_table[i] & 0x3ff); /* in word unit */
+ vmm_sz *= 4;
+ header = (tqe->type << 31) | (tqe->buffer_size << 15) | vmm_sz;
+ /*Bug3959: transmitting mgmt frames received from host*/
+ /*setting bit 30 in the host header to indicate mgmt frame*/
+#ifdef WILC_AP_EXTERNAL_MLME
+ if (tqe->type == WILC_MGMT_PKT) {
+ header |= (1 << 30);
+ } else {
+ header &= ~(1 << 30);
+ }
+#endif
+ /*else if(tqe->type == WILC_DATA_PKT_MAC_HDR)
+ * {
+ * header |= (1<< 29);
+ * }*/
+ /* wilc_debug(N_TXQ, "[wilc txq]: header (%08x), real size (%d), vmm size (%d)\n", header, tqe->buffer_size, vmm_sz); */
+
+#ifdef BIG_ENDIAN
+ header = BYTE_SWAP(header);
+#endif
+ memcpy(&txb[offset], &header, 4);
+ if (tqe->type == WILC_CFG_PKT) {
+ buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET;
+ }
+ /*Bug3959: transmitting mgmt frames received from host*/
+ /*buffer offset = HOST_HDR_OFFSET in other cases: WILC_MGMT_PKT*/
+ /* and WILC_DATA_PKT_MAC_HDR*/
+ else if (tqe->type == WILC_NET_PKT) {
+ char *pBSSID = ((struct tx_complete_data *)(tqe->priv))->pBssid;
+ buffer_offset = ETH_ETHERNET_HDR_OFFSET;
+ /* copy the bssid at the sart of the buffer */
+ memcpy(&txb[offset + 4], pBSSID, 6);
+ }
+#ifdef WILC_FULLY_HOSTING_AP
+ else if (tqe->type == WILC_FH_DATA_PKT) {
+ buffer_offset = FH_TX_HOST_HDR_OFFSET;
+ }
+#endif
+ else {
+ buffer_offset = HOST_HDR_OFFSET;
+ }
+
+ memcpy(&txb[offset + buffer_offset], tqe->buffer, tqe->buffer_size);
+ offset += vmm_sz;
+ i++;
+ tqe->status = 1; /* mark the packet send */
+ if (tqe->tx_complete_func)
+ tqe->tx_complete_func(tqe->priv, tqe->status);
+ #ifdef TCP_ACK_FILTER
+ if (tqe->tcp_PendingAck_index != NOT_TCP_ACK) {
+ Pending_Acks_info[tqe->tcp_PendingAck_index].txqe = NULL;
+ }
+ #endif
+ p->os_func.os_free(tqe);
+ } else {
+ break;
+ }
+ } while (--entries);
+
+ /**
+ * lock the bus
+ **/
+ acquire_bus(ACQUIRE_AND_WAKEUP);
+
+ ret = p->hif_func.hif_clear_int_ext(ENABLE_TX_VMM);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc txq]: fail can't start tx VMM ...\n");
+ goto _end_;
+ }
+
+ /**
+ * transfer
+ **/
+ ret = p->hif_func.hif_block_tx_ext(0, txb, offset);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc txq]: fail can't block tx ext...\n");
+ goto _end_;
+ }
+
+_end_:
+
+ release_bus(RELEASE_ALLOW_SLEEP);
+ if (ret != 1)
+ break;
+ } while (0);
+ /* remove_TCP_related(); */
+ /*Added by Amr - BugID_4720*/
+ p->os_func.os_signal(p->txq_add_to_head_lock);
+
+ p->txq_exit = 1;
+ PRINT_D(TX_DBG, "THREAD: Exiting txq\n");
+ /* return tx[]q count */
+ *pu32TxqCount = p->txq_entries;
+ return ret;
+}
+
+static void wilc_wlan_handle_rxq(void)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ int offset = 0, size, has_packet = 0;
+ uint8_t *buffer;
+ struct rxq_entry_t *rqe;
+
+ p->rxq_exit = 0;
+
+
+
+
+ do {
+ if (p->quit) {
+ PRINT_D(RX_DBG, "exit 1st do-while due to Clean_UP function \n");
+ p->os_func.os_signal(p->cfg_wait);
+ break;
+ }
+ rqe = wilc_wlan_rxq_remove();
+ if (rqe == NULL) {
+ PRINT_D(RX_DBG, "nothing in the queue - exit 1st do-while\n");
+ break;
+ }
+ buffer = rqe->buffer;
+ size = rqe->buffer_size;
+ PRINT_D(RX_DBG, "rxQ entery Size = %d - Address = %p\n", size, buffer);
+ offset = 0;
+
+
+
+ do {
+ uint32_t header;
+ uint32_t pkt_len, pkt_offset, tp_len;
+ int is_cfg_packet;
+ PRINT_D(RX_DBG, "In the 2nd do-while\n");
+ memcpy(&header, &buffer[offset], 4);
+#ifdef BIG_ENDIAN
+ header = BYTE_SWAP(header);
+#endif
+ PRINT_D(RX_DBG, "Header = %04x - Offset = %d\n", header, offset);
+
+
+
+ is_cfg_packet = (header >> 31) & 0x1;
+ pkt_offset = (header >> 22) & 0x1ff;
+ tp_len = (header >> 11) & 0x7ff;
+ pkt_len = header & 0x7ff;
+
+ if (pkt_len == 0 || tp_len == 0) {
+ wilc_debug(N_RXQ, "[wilc rxq]: data corrupt, packet len or tp_len is 0 [%d][%d]\n", pkt_len, tp_len);
+ break;
+ }
+
+/*bug 3887: [AP] Allow Management frames to be passed to the host*/
+ #if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P)
+ #define IS_MANAGMEMENT 0x100
+ #define IS_MANAGMEMENT_CALLBACK 0x080
+ #define IS_MGMT_STATUS_SUCCES 0x040
+
+
+ if (pkt_offset & IS_MANAGMEMENT) {
+ /* reset mgmt indicator bit, to use pkt_offeset in furthur calculations */
+ pkt_offset &= ~(IS_MANAGMEMENT | IS_MANAGMEMENT_CALLBACK | IS_MGMT_STATUS_SUCCES);
+
+#ifdef USE_WIRELESS
+ WILC_WFI_mgmt_rx(&buffer[offset + HOST_HDR_OFFSET], pkt_len);
+
+#endif
+
+ }
+ /* BUG4530 fix */
+ else
+ #endif
+ {
+ /* wilc_debug(N_RXQ, "[wilc rxq]: packet, tp len(%d), len (%d), offset (%d), cfg (%d)\n", tp_len, pkt_len, pkt_offset, is_cfg_packet); */
+
+ if (!is_cfg_packet) {
+
+ if (p->net_func.rx_indicate) {
+ if (pkt_len > 0) {
+ p->net_func.rx_indicate(&buffer[offset], pkt_len, pkt_offset);
+ has_packet = 1;
+ }
+ }
+ } else {
+ wilc_cfg_rsp_t rsp;
+
+
+
+ p->cif_func.rx_indicate(&buffer[pkt_offset + offset], pkt_len, &rsp);
+ if (rsp.type == WILC_CFG_RSP) {
+ /**
+ * wake up the waiting task...
+ **/
+ PRINT_D(RX_DBG, "p->cfg_seq_no = %d - rsp.seq_no = %d\n", p->cfg_seq_no, rsp.seq_no);
+ if (p->cfg_seq_no == rsp.seq_no) {
+ p->os_func.os_signal(p->cfg_wait);
+ }
+ /* p->os_func.os_signal(p->cfg_wait); */
+ } else if (rsp.type == WILC_CFG_RSP_STATUS) {
+ /**
+ * Call back to indicate status...
+ **/
+ if (p->indicate_func.mac_indicate) {
+ p->indicate_func.mac_indicate(WILC_MAC_INDICATE_STATUS);
+ }
+
+ } else if (rsp.type == WILC_CFG_RSP_SCAN) {
+ if (p->indicate_func.mac_indicate)
+ p->indicate_func.mac_indicate(WILC_MAC_INDICATE_SCAN);
+ }
+ }
+ }
+ offset += tp_len;
+ if (offset >= size)
+ break;
+ } while (1);
+
+
+#ifndef MEMORY_STATIC
+ if (buffer != NULL)
+ p->os_func.os_free((void *)buffer);
+#endif
+ if (rqe != NULL)
+ p->os_func.os_free((void *)rqe);
+
+ if (has_packet) {
+ if (p->net_func.rx_complete)
+ p->net_func.rx_complete();
+ }
+ } while (1);
+
+ p->rxq_exit = 1;
+ PRINT_D(RX_DBG, "THREAD: Exiting RX thread \n");
+ return;
+}
+
+/********************************************
+ *
+ * Fast DMA Isr
+ *
+ ********************************************/
+static void wilc_unknown_isr_ext(void)
+{
+ g_wlan.hif_func.hif_clear_int_ext(0);
+}
+static void wilc_pllupdate_isr_ext(uint32_t int_stats)
+{
+
+ int trials = 10;
+
+ g_wlan.hif_func.hif_clear_int_ext(PLL_INT_CLR);
+
+ /* Waiting for PLL */
+ g_wlan.os_func.os_atomic_sleep(WILC_PLL_TO);
+
+ /* poll till read a valid data */
+ while (!(ISWILC1000(wilc_get_chipid(WILC_TRUE)) && --trials)) {
+ PRINT_D(TX_DBG, "PLL update retrying\n");
+ g_wlan.os_func.os_atomic_sleep(1);
+ }
+}
+
+static void wilc_sleeptimer_isr_ext(uint32_t int_stats1)
+{
+ g_wlan.hif_func.hif_clear_int_ext(SLEEP_INT_CLR);
+#ifndef WILC_OPTIMIZE_SLEEP_INT
+ genuChipPSstate = CHIP_SLEEPING_AUTO;
+#endif
+}
+
+static void wilc_wlan_handle_isr_ext(uint32_t int_status)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+#ifdef MEMORY_STATIC
+ uint32_t offset = p->rx_buffer_offset;
+#endif
+ uint8_t *buffer = NULL;
+ uint32_t size;
+ uint32_t retries = 0;
+ int ret = 0;
+ struct rxq_entry_t *rqe;
+
+
+ /**
+ * Get the rx size
+ **/
+
+ size = ((int_status & 0x7fff) << 2);
+
+ while (!size && retries < 10) {
+ uint32_t time = 0;
+ /*looping more secure*/
+ /*zero size make a crashe because the dma will not happen and that will block the firmware*/
+ wilc_debug(N_ERR, "RX Size equal zero ... Trying to read it again for %d time\n", time++);
+ p->hif_func.hif_read_size(&size);
+ size = ((size & 0x7fff) << 2);
+ retries++;
+
+ }
+
+ if (size > 0) {
+#ifdef MEMORY_STATIC
+ if (p->rx_buffer_size - offset < size)
+ offset = 0;
+
+ if (p->rx_buffer)
+ buffer = &p->rx_buffer[offset];
+ else {
+ wilc_debug(N_ERR, "[wilc isr]: fail Rx Buffer is NULL...drop the packets (%d)\n", size);
+ goto _end_;
+ }
+
+#else
+ buffer = p->os_func.os_malloc(size);
+ if (buffer == NULL) {
+ wilc_debug(N_ERR, "[wilc isr]: fail alloc host memory...drop the packets (%d)\n", size);
+ WILC_Sleep(100);
+ goto _end_;
+ }
+#endif
+
+ /**
+ * clear the chip's interrupt after getting size some register getting corrupted after clear the interrupt
+ **/
+ p->hif_func.hif_clear_int_ext(DATA_INT_CLR | ENABLE_RX_VMM);
+
+
+ /**
+ * start transfer
+ **/
+ ret = p->hif_func.hif_block_rx_ext(0, buffer, size);
+
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc isr]: fail block rx...\n");
+ goto _end_;
+ }
+_end_:
+
+
+ if (ret) {
+#ifdef MEMORY_STATIC
+ offset += size;
+ p->rx_buffer_offset = offset;
+#endif
+ /**
+ * add to rx queue
+ **/
+ rqe = (struct rxq_entry_t *)p->os_func.os_malloc(sizeof(struct rxq_entry_t));
+ if (rqe != NULL) {
+ rqe->buffer = buffer;
+ rqe->buffer_size = size;
+ PRINT_D(RX_DBG, "rxq entery Size= %d - Address = %p\n", rqe->buffer_size, rqe->buffer);
+ wilc_wlan_rxq_add(rqe);
+ p->os_func.os_signal(p->rxq_wait);
+ }
+ } else {
+#ifndef MEMORY_STATIC
+ if (buffer != NULL)
+ p->os_func.os_free(buffer);
+#endif
+ }
+ }
+#ifdef TCP_ENHANCEMENTS
+ wilc_wlan_handle_rxq();
+#endif
+}
+
+void wilc_handle_isr(void)
+{
+ uint32_t int_status;
+
+ acquire_bus(ACQUIRE_AND_WAKEUP);
+ g_wlan.hif_func.hif_read_int(&int_status);
+
+ if (int_status & PLL_INT_EXT) {
+ wilc_pllupdate_isr_ext(int_status);
+ }
+ if (int_status & DATA_INT_EXT) {
+ wilc_wlan_handle_isr_ext(int_status);
+ #ifndef WILC_OPTIMIZE_SLEEP_INT
+ /* Chip is up and talking*/
+ genuChipPSstate = CHIP_WAKEDUP;
+ #endif
+ }
+ if (int_status & SLEEP_INT_EXT) {
+ wilc_sleeptimer_isr_ext(int_status);
+ }
+
+ if (!(int_status & (ALL_INT_EXT))) {
+#ifdef WILC_SDIO
+ PRINT_D(TX_DBG, ">> UNKNOWN_INTERRUPT - 0x%08x\n", int_status);
+#endif
+ wilc_unknown_isr_ext();
+ }
+#if ((!defined WILC_SDIO) || (defined WILC_SDIO_IRQ_GPIO))
+ linux_wlan_enable_irq();
+#endif
+ release_bus(RELEASE_ALLOW_SLEEP);
+}
+
+/********************************************
+ *
+ * Firmware download
+ *
+ ********************************************/
+static int wilc_wlan_firmware_download(const uint8_t *buffer, uint32_t buffer_size)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ uint32_t offset;
+ uint32_t addr, size, size2, blksz;
+ uint8_t *dma_buffer;
+ int ret = 0;
+
+ blksz = (1ul << 12); /* Bug 4703: 4KB Good enough size for most platforms = PAGE_SIZE. */
+ /* Allocate a DMA coherent buffer. */
+
+#if (defined WILC_PREALLOC_AT_BOOT)
+ {
+ extern void *get_fw_buffer(void);
+ dma_buffer = (uint8_t *)get_fw_buffer();
+ PRINT_D(TX_DBG, "fw_buffer = 0x%x\n", dma_buffer);
+ }
+#else
+ dma_buffer = (uint8_t *)g_wlan.os_func.os_malloc(blksz);
+#endif
+ if (dma_buffer == NULL) {
+ /*EIO 5*/
+ ret = -5;
+ PRINT_ER("Can't allocate buffer for firmware download IO error\n ");
+ goto _fail_1;
+ }
+
+ PRINT_D(INIT_DBG, "Downloading firmware size = %d ...\n", buffer_size);
+ /**
+ * load the firmware
+ **/
+ offset = 0;
+ do {
+ memcpy(&addr, &buffer[offset], 4);
+ memcpy(&size, &buffer[offset + 4], 4);
+#ifdef BIG_ENDIAN
+ addr = BYTE_SWAP(addr);
+ size = BYTE_SWAP(size);
+#endif
+ acquire_bus(ACQUIRE_ONLY);
+ offset += 8;
+ while (((int)size) && (offset < buffer_size)) {
+ if (size <= blksz) {
+ size2 = size;
+ } else {
+ size2 = blksz;
+ }
+ /* Copy firmware into a DMA coherent buffer */
+ memcpy(dma_buffer, &buffer[offset], size2);
+ ret = p->hif_func.hif_block_tx(addr, dma_buffer, size2);
+ if (!ret)
+ break;
+
+ addr += size2;
+ offset += size2;
+ size -= size2;
+ }
+ release_bus(RELEASE_ONLY);
+
+ if (!ret) {
+ /*EIO 5*/
+ ret = -5;
+ PRINT_ER("Can't download firmware IO error\n ");
+ goto _fail_;
+ }
+ PRINT_D(INIT_DBG, "Offset = %d\n", offset);
+ } while (offset < buffer_size);
+
+_fail_:
+
+#if (defined WILC_PREALLOC_AT_BOOT)
+
+#else
+ if (dma_buffer)
+ g_wlan.os_func.os_free(dma_buffer);
+#endif
+
+_fail_1:
+
+ return (ret < 0) ? ret : 0;
+}
+
+/********************************************
+ *
+ * Common
+ *
+ ********************************************/
+static int wilc_wlan_start(void)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ uint32_t reg = 0;
+ int ret;
+ uint32_t chipid;
+
+ /**
+ * Set the host interface
+ **/
+#ifdef OLD_FPGA_BITFILE
+ acquire_bus(ACQUIRE_ONLY);
+ ret = p->hif_func.hif_read_reg(WILC_VMM_CORE_CTL, &reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc start]: fail read reg vmm_core_ctl...\n");
+ release_bus(RELEASE_ALLOW_SLEEP);
+ return ret;
+ }
+ reg |= (p->io_func.io_type << 2);
+ ret = p->hif_func.hif_write_reg(WILC_VMM_CORE_CTL, reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc start]: fail write reg vmm_core_ctl...\n");
+ release_bus(RELEASE_ONLY);
+ return ret;
+ }
+#else
+ if (p->io_func.io_type == HIF_SDIO) {
+ reg = 0;
+ reg |= (1 << 3); /* bug 4456 and 4557 */
+ } else if (p->io_func.io_type == HIF_SPI) {
+ reg = 1;
+ }
+ acquire_bus(ACQUIRE_ONLY);
+ ret = p->hif_func.hif_write_reg(WILC_VMM_CORE_CFG, reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc start]: fail write reg vmm_core_cfg...\n");
+ release_bus(RELEASE_ONLY);
+ /* EIO 5*/
+ ret = -5;
+ return ret;
+ }
+ reg = 0;
+#ifdef WILC_SDIO_IRQ_GPIO
+ reg |= WILC_HAVE_SDIO_IRQ_GPIO;
+#endif
+
+#ifdef WILC_DISABLE_PMU
+#else
+ reg |= WILC_HAVE_USE_PMU;
+#endif
+
+#ifdef WILC_SLEEP_CLK_SRC_XO
+ reg |= WILC_HAVE_SLEEP_CLK_SRC_XO;
+#elif defined WILC_SLEEP_CLK_SRC_RTC
+ reg |= WILC_HAVE_SLEEP_CLK_SRC_RTC;
+#endif
+
+#ifdef WILC_EXT_PA_INV_TX_RX
+ reg |= WILC_HAVE_EXT_PA_INV_TX_RX;
+#endif
+
+ reg |= WILC_HAVE_LEGACY_RF_SETTINGS;
+
+
+/*BugID_5257*/
+/*Set oscillator frequency*/
+#ifdef XTAL_24
+ reg |= WILC_HAVE_XTAL_24;
+#endif
+
+/*BugID_5271*/
+/*Enable/Disable GPIO configuration for FW logs*/
+#ifdef DISABLE_WILC_UART
+ reg |= WILC_HAVE_DISABLE_WILC_UART;
+#endif
+
+ ret = p->hif_func.hif_write_reg(WILC_GP_REG_1, reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc start]: fail write WILC_GP_REG_1 ...\n");
+ release_bus(RELEASE_ONLY);
+ /* EIO 5*/
+ ret = -5;
+ return ret;
+ }
+#endif
+
+
+ /**
+ * Bus related
+ **/
+ p->hif_func.hif_sync_ext(NUM_INT_EXT);
+
+ ret = p->hif_func.hif_read_reg(0x1000, &chipid);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1000 ...\n");
+ release_bus(RELEASE_ONLY);
+ /* EIO 5*/
+ ret = -5;
+ return ret;
+ }
+
+ /**
+ * Go...
+ **/
+
+ /* p->hif_func.hif_write_reg(0x150014, reg); */
+
+ p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ if ((reg & (1ul << 10)) == (1ul << 10)) {
+ reg &= ~(1ul << 10);
+ p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+ p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ }
+
+ reg |= (1ul << 10);
+ ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+ p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ release_bus(RELEASE_ONLY);
+
+ return (ret < 0) ? ret : 0;
+}
+
+void wilc_wlan_global_reset(void)
+{
+
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ acquire_bus(ACQUIRE_AND_WAKEUP);
+ p->hif_func.hif_write_reg(WILC_GLB_RESET_0, 0x0);
+ release_bus(RELEASE_ONLY);
+}
+static int wilc_wlan_stop(void)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ uint32_t reg = 0;
+ int ret;
+ uint8_t timeout = 10;
+ /**
+ * TODO: stop the firmware, need a re-download
+ **/
+ acquire_bus(ACQUIRE_AND_WAKEUP);
+
+ ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ if (!ret) {
+ PRINT_ER("Error while reading reg\n");
+ release_bus(RELEASE_ALLOW_SLEEP);
+ return ret;
+ }
+
+ reg &= ~(1 << 10);
+
+
+ ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+ if (!ret) {
+ PRINT_ER("Error while writing reg\n");
+ release_bus(RELEASE_ALLOW_SLEEP);
+ return ret;
+ }
+
+
+
+ do {
+ ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ if (!ret) {
+ PRINT_ER("Error while reading reg\n");
+ release_bus(RELEASE_ALLOW_SLEEP);
+ return ret;
+ }
+ PRINT_D(GENERIC_DBG, "Read RESET Reg %x : Retry%d\n", reg, timeout);
+ /*Workaround to ensure that the chip is actually reset*/
+ if ((reg & (1 << 10))) {
+ PRINT_D(GENERIC_DBG, "Bit 10 not reset : Retry %d\n", timeout);
+ reg &= ~(1 << 10);
+ ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg);
+ timeout--;
+ } else {
+ PRINT_D(GENERIC_DBG, "Bit 10 reset after : Retry %d\n", timeout);
+ ret = p->hif_func.hif_read_reg(WILC_GLB_RESET_0, &reg);
+ if (!ret) {
+ PRINT_ER("Error while reading reg\n");
+ release_bus(RELEASE_ALLOW_SLEEP);
+ return ret;
+ }
+ PRINT_D(GENERIC_DBG, "Read RESET Reg %x : Retry%d\n", reg, timeout);
+ break;
+ }
+
+ } while (timeout);
+#if 1
+/******************************************************************************/
+/* This was add at Bug 4595 to reset the chip while maintaining the bus state */
+/******************************************************************************/
+ reg = ((1 << 0) | (1 << 1) | (1 << 2) | (1 << 3) | (1 << 8) | (1 << 9) | (1 << 26) | (1 << 29) | (1 << 30) | (1 << 31)); /**/
+ /**/
+ ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg); /**/
+ reg = ~(1 << 10); /**/
+ /**/
+ ret = p->hif_func.hif_write_reg(WILC_GLB_RESET_0, reg); /**/
+/******************************************************************************/
+#endif
+
+ release_bus(RELEASE_ALLOW_SLEEP);
+
+ return ret;
+}
+
+static void wilc_wlan_cleanup(void)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ struct txq_entry_t *tqe;
+ struct rxq_entry_t *rqe;
+ uint32_t reg = 0;
+ int ret;
+
+ p->quit = 1;
+ /**
+ * wait for queue end
+ **/
+ /* p->os_func.os_signal(p->txq_wait); */
+ /* p->os_func.os_signal(p->rxq_wait); */
+
+ /* complete(p->txq_wait); */
+ /* complete(p->rxq_wait); */
+ /*do {
+ * if (p->txq_exit && p->rxq_exit)
+ * break;
+ * } while (1);*/
+
+ /**
+ * clean up the queue
+ **/
+ do {
+ tqe = wilc_wlan_txq_remove_from_head();
+ if (tqe == NULL)
+ break;
+ if (tqe->tx_complete_func)
+ tqe->tx_complete_func(tqe->priv, 0);
+ p->os_func.os_free((void *)tqe);
+ } while (1);
+
+ do {
+ rqe = wilc_wlan_rxq_remove();
+ if (rqe == NULL)
+ break;
+#ifdef MEMORY_DYNAMIC
+ p->os_func.os_free((void *)tqe->buffer);
+#endif
+ p->os_func.os_free((void *)rqe);
+ } while (1);
+
+ /**
+ * clean up buffer
+ **/
+
+#if (defined WILC_PREALLOC_AT_BOOT)
+
+#else
+ #ifdef MEMORY_STATIC
+ if (p->rx_buffer) {
+ p->os_func.os_free(p->rx_buffer);
+ p->rx_buffer = NULL;
+ }
+ #endif
+ if (p->tx_buffer) {
+ p->os_func.os_free(p->tx_buffer);
+ p->tx_buffer = NULL;
+ }
+#endif
+
+ acquire_bus(ACQUIRE_AND_WAKEUP);
+
+
+ ret = p->hif_func.hif_read_reg(WILC_GP_REG_0, &reg);
+ if (!ret) {
+ PRINT_ER("Error while reading reg\n");
+ release_bus(RELEASE_ALLOW_SLEEP);
+ }
+ PRINT_ER("Writing ABORT reg\n");
+ ret = p->hif_func.hif_write_reg(WILC_GP_REG_0, (reg | ABORT_INT));
+ if (!ret) {
+ PRINT_ER("Error while writing reg\n");
+ release_bus(RELEASE_ALLOW_SLEEP);
+ }
+ release_bus(RELEASE_ALLOW_SLEEP);
+ /**
+ * io clean up
+ **/
+ p->hif_func.hif_deinit(NULL);
+
+}
+
+static int wilc_wlan_cfg_commit(int type, uint32_t drvHandler)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ wilc_cfg_frame_t *cfg = &p->cfg_frame;
+ int total_len = p->cfg_frame_offset + 4 + DRIVER_HANDLER_SIZE;
+ int seq_no = p->cfg_seq_no % 256;
+ int driver_handler = (WILC_Uint32)drvHandler;
+
+
+ /**
+ * Set up header
+ **/
+ if (type == WILC_CFG_SET) { /* Set */
+ cfg->wid_header[0] = 'W';
+ } else { /* Query */
+ cfg->wid_header[0] = 'Q';
+ }
+ cfg->wid_header[1] = seq_no; /* sequence number */
+ cfg->wid_header[2] = (uint8_t)total_len;
+ cfg->wid_header[3] = (uint8_t)(total_len >> 8);
+ cfg->wid_header[4] = (uint8_t)driver_handler;
+ cfg->wid_header[5] = (uint8_t)(driver_handler >> 8);
+ cfg->wid_header[6] = (uint8_t)(driver_handler >> 16);
+ cfg->wid_header[7] = (uint8_t)(driver_handler >> 24);
+ p->cfg_seq_no = seq_no;
+
+ /**
+ * Add to TX queue
+ **/
+
+ /*Edited by Amr - BugID_4720*/
+ if (!wilc_wlan_txq_add_cfg_pkt(&cfg->wid_header[0], total_len))
+ return -1;
+
+ return 0;
+}
+
+static int wilc_wlan_cfg_set(int start, uint32_t wid, uint8_t *buffer, uint32_t buffer_size, int commit, uint32_t drvHandler)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ uint32_t offset;
+ int ret_size;
+
+
+ if (p->cfg_frame_in_use)
+ return 0;
+
+ if (start)
+ p->cfg_frame_offset = 0;
+
+ offset = p->cfg_frame_offset;
+ ret_size = p->cif_func.cfg_wid_set(p->cfg_frame.frame, offset, (uint16_t)wid, buffer, buffer_size);
+ offset += ret_size;
+ p->cfg_frame_offset = offset;
+
+ if (commit) {
+ PRINT_D(TX_DBG, "[WILC]PACKET Commit with sequence number %d\n", p->cfg_seq_no);
+ PRINT_D(RX_DBG, "Processing cfg_set()\n");
+ p->cfg_frame_in_use = 1;
+
+ /*Edited by Amr - BugID_4720*/
+ if (wilc_wlan_cfg_commit(WILC_CFG_SET, drvHandler))
+ ret_size = 0; /* BugID_5213 */
+
+ if (p->os_func.os_wait(p->cfg_wait, CFG_PKTS_TIMEOUT)) {
+ PRINT_D(TX_DBG, "Set Timed Out\n");
+ ret_size = 0;
+ }
+ p->cfg_frame_in_use = 0;
+ p->cfg_frame_offset = 0;
+ p->cfg_seq_no += 1;
+
+ }
+
+ return ret_size;
+}
+static int wilc_wlan_cfg_get(int start, uint32_t wid, int commit, uint32_t drvHandler)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ uint32_t offset;
+ int ret_size;
+
+
+ if (p->cfg_frame_in_use)
+ return 0;
+
+ if (start)
+ p->cfg_frame_offset = 0;
+
+ offset = p->cfg_frame_offset;
+ ret_size = p->cif_func.cfg_wid_get(p->cfg_frame.frame, offset, (uint16_t)wid);
+ offset += ret_size;
+ p->cfg_frame_offset = offset;
+
+ if (commit) {
+ p->cfg_frame_in_use = 1;
+
+ /*Edited by Amr - BugID_4720*/
+ if (wilc_wlan_cfg_commit(WILC_CFG_QUERY, drvHandler))
+ ret_size = 0; /* BugID_5213 */
+
+
+ if (p->os_func.os_wait(p->cfg_wait, CFG_PKTS_TIMEOUT)) {
+ PRINT_D(TX_DBG, "Get Timed Out\n");
+ ret_size = 0;
+ }
+ PRINT_D(GENERIC_DBG, "[WILC]Get Response received\n");
+ p->cfg_frame_in_use = 0;
+ p->cfg_frame_offset = 0;
+ p->cfg_seq_no += 1;
+ }
+
+ return ret_size;
+}
+
+static int wilc_wlan_cfg_get_val(uint32_t wid, uint8_t *buffer, uint32_t buffer_size)
+{
+ wilc_wlan_dev_t *p = (wilc_wlan_dev_t *)&g_wlan;
+ int ret;
+
+ ret = p->cif_func.cfg_wid_get_val((uint16_t)wid, buffer, buffer_size);
+
+ return ret;
+}
+
+void wilc_bus_set_max_speed(void)
+{
+
+ /* Increase bus speed to max possible. */
+ g_wlan.hif_func.hif_set_max_bus_speed();
+}
+
+void wilc_bus_set_default_speed(void)
+{
+
+ /* Restore bus speed to default. */
+ g_wlan.hif_func.hif_set_default_bus_speed();
+}
+uint32_t init_chip(void)
+{
+ uint32_t chipid;
+ uint32_t reg, ret = 0;
+
+#if defined(PLAT_RK3026_TCHIP)
+ acquire_bus(ACQUIRE_AND_WAKEUP); /* AMR : 0422 RK3026 Crash issue */
+#else
+ acquire_bus(ACQUIRE_ONLY);
+#endif
+
+ chipid = wilc_get_chipid(WILC_TRUE);
+
+
+
+ if ((chipid & 0xfff) != 0xa0) {
+ /**
+ * Avoid booting from boot ROM. Make sure that Drive IRQN [SDIO platform]
+ * or SD_DAT3 [SPI platform] to ?1?
+ **/
+ /* Set cortus reset register to register control. */
+ ret = g_wlan.hif_func.hif_read_reg(0x1118, &reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc start]: fail read reg 0x1118 ...\n");
+ return ret;
+ }
+ reg |= (1 << 0);
+ ret = g_wlan.hif_func.hif_write_reg(0x1118, reg);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc start]: fail write reg 0x1118 ...\n");
+ return ret;
+ }
+ /**
+ * Write branch intruction to IRAM (0x71 trap) at location 0xFFFF0000
+ * (Cortus map) or C0000 (AHB map).
+ **/
+ ret = g_wlan.hif_func.hif_write_reg(0xc0000, 0x71);
+ if (!ret) {
+ wilc_debug(N_ERR, "[wilc start]: fail write reg 0xc0000 ...\n");
+ return ret;
+ }
+ }
+
+
+ #if 0
+ if ((chipid & 0xfff) < 0xf0) {
+ /* Setting MUX to probe sleep signal on pin 6 of J216*/
+ g_wlan.hif_func.hif_write_reg(0x1060, 0x1);
+ g_wlan.hif_func.hif_write_reg(0x1180, 0x33333333);
+ g_wlan.hif_func.hif_write_reg(0x1184, 0x33333333);
+ g_wlan.hif_func.hif_read_reg(0x1408, &reg);
+ /* set MUX for GPIO_4 (pin 4) to cortus GPIO*/
+ reg &= ~((0x7 << 16));
+ g_wlan.hif_func.hif_write_reg(0x1408, (reg | (0x7 << 12)));
+ } else {
+ /* Enable test bus*/
+ g_wlan.hif_func.hif_write_reg(0x1060, 0x1);
+ /* Rotate bus signals to get sleep signal on pin 6 like it was on previous chips*/
+ g_wlan.hif_func.hif_write_reg(0x1188, 0x70);
+ /* Set output of pin 6 to test bus 0x1*/
+ /* Set output of pin 9 to test bus 0x2*/
+ g_wlan.hif_func.hif_write_reg(0x1180, 0x200100);
+ g_wlan.hif_func.hif_read_reg(0x1408, &reg);
+
+ /* set MUX for GPIO_4 (pin 4) to cortus GPIO*/
+ reg &= ~((0x7 << 16));
+ /* set MUX for GPIO_3 (pin 6) to test bus*/
+ reg |= (0x7 << 12) | (0x7 << 24);
+ g_wlan.hif_func.hif_write_reg(0x1408, reg);
+ }
+ #endif
+
+
+
+ release_bus(RELEASE_ONLY);
+
+ return ret;
+
+}
+
+uint32_t wilc_get_chipid(uint8_t update)
+{
+ static uint32_t chipid;
+ /* SDIO can't read into global variables */
+ /* Use this variable as a temp, then copy to the global */
+ uint32_t tempchipid = 0;
+ uint32_t rfrevid;
+
+ if (chipid == 0 || update != 0) {
+ g_wlan.hif_func.hif_read_reg(0x1000, &tempchipid);
+ g_wlan.hif_func.hif_read_reg(0x13f4, &rfrevid);
+ if (!ISWILC1000(tempchipid)) {
+ chipid = 0;
+ goto _fail_;
+ }
+ if (tempchipid == 0x1002a0) {
+ if (rfrevid == 0x1) { /* 1002A0 */
+ } else { /* if (rfrevid == 0x2) */ /* 1002A1 */
+ tempchipid = 0x1002a1;
+ }
+ } else if (tempchipid == 0x1002b0) {
+ if (rfrevid == 3) { /* 1002B0 */
+ } else if (rfrevid == 4) { /* 1002B1 */
+ tempchipid = 0x1002b1;
+ } else { /* if(rfrevid == 5) */ /* 1002B2 */
+ tempchipid = 0x1002b2;
+ }
+ } else {
+ }
+
+ chipid = tempchipid;
+ }
+_fail_:
+ return chipid;
+}
+
+#ifdef COMPLEMENT_BOOT
+uint8_t core_11b_ready(void)
+{
+ uint32_t reg_val;
+
+ acquire_bus(ACQUIRE_ONLY);
+ g_wlan.hif_func.hif_write_reg(0x16082c, 1);
+ g_wlan.hif_func.hif_write_reg(0x161600, 0x90);
+ g_wlan.hif_func.hif_read_reg(0x161600, &reg_val);
+ release_bus(RELEASE_ONLY);
+
+ if (reg_val == 0x90)
+ return 0;
+ else
+ return 1;
+}
+#endif
+
+int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup)
+{
+
+ int ret = 0;
+
+ PRINT_D(INIT_DBG, "Initializing WILC_Wlan ...\n");
+
+ memset((void *)&g_wlan, 0, sizeof(wilc_wlan_dev_t));
+
+ /**
+ * store the input
+ **/
+ memcpy((void *)&g_wlan.os_func, (void *)&inp->os_func, sizeof(wilc_wlan_os_func_t));
+ memcpy((void *)&g_wlan.io_func, (void *)&inp->io_func, sizeof(wilc_wlan_io_func_t));
+ memcpy((void *)&g_wlan.net_func, (void *)&inp->net_func, sizeof(wilc_wlan_net_func_t));
+ memcpy((void *)&g_wlan.indicate_func, (void *)&inp->indicate_func, sizeof(wilc_wlan_net_func_t));
+ g_wlan.hif_lock = inp->os_context.hif_critical_section;
+ g_wlan.txq_lock = inp->os_context.txq_critical_section;
+
+ /*Added by Amr - BugID_4720*/
+ g_wlan.txq_add_to_head_lock = inp->os_context.txq_add_to_head_critical_section;
+
+ /*Added by Amr - BugID_4720*/
+ g_wlan.txq_spinlock = inp->os_context.txq_spin_lock;
+
+ g_wlan.rxq_lock = inp->os_context.rxq_critical_section;
+ g_wlan.txq_wait = inp->os_context.txq_wait_event;
+ g_wlan.rxq_wait = inp->os_context.rxq_wait_event;
+ g_wlan.cfg_wait = inp->os_context.cfg_wait_event;
+ g_wlan.tx_buffer_size = inp->os_context.tx_buffer_size;
+#if defined (MEMORY_STATIC)
+ g_wlan.rx_buffer_size = inp->os_context.rx_buffer_size;
+#endif
+ /* g_wlan.os_func.os_lock(g_wlan.cfg_wait); */
+ /***
+ * host interface init
+ **/
+#if defined(PLAT_RK3026_TCHIP) /* AMR : 0422 RK3026 Crash issue */
+ if (!g_wilc_initialized) {
+ custom_lock_bus(g_mac_open);
+ custom_wakeup(g_mac_open);
+ }
+#endif
+
+ if ((inp->io_func.io_type & 0x1) == HIF_SDIO) {
+ if (!hif_sdio.hif_init(inp, wilc_debug)) {
+ /* EIO 5 */
+ ret = -5;
+ goto _fail_;
+ }
+ memcpy((void *)&g_wlan.hif_func, &hif_sdio, sizeof(wilc_hif_func_t));
+ } else {
+ if ((inp->io_func.io_type & 0x1) == HIF_SPI) {
+ /**
+ * TODO:
+ **/
+ if (!hif_spi.hif_init(inp, wilc_debug)) {
+ /* EIO 5 */
+ ret = -5;
+ goto _fail_;
+ }
+ memcpy((void *)&g_wlan.hif_func, &hif_spi, sizeof(wilc_hif_func_t));
+ } else {
+ /* EIO 5 */
+ ret = -5;
+ goto _fail_;
+ }
+ }
+
+ /***
+ * mac interface init
+ **/
+ if (!mac_cfg.cfg_init(wilc_debug)) {
+ /* ENOBUFS 105 */
+ ret = -105;
+ goto _fail_;
+ }
+ memcpy((void *)&g_wlan.cif_func, &mac_cfg, sizeof(wilc_cfg_func_t));
+
+
+ /**
+ * alloc tx, rx buffer
+ **/
+#if (defined WILC_PREALLOC_AT_BOOT)
+ extern void *get_tx_buffer(void);
+ extern void *get_rx_buffer(void);
+
+ PRINT_D(TX_DBG, "malloc before, g_wlan.tx_buffer = 0x%x, g_wlan.rx_buffer = 0x%x\n", g_wlan.tx_buffer, g_wlan.rx_buffer);
+#endif
+
+
+
+ if (g_wlan.tx_buffer == NULL)
+#if (defined WILC_PREALLOC_AT_BOOT)
+ g_wlan.tx_buffer = (uint8_t *)get_tx_buffer();
+#else
+ g_wlan.tx_buffer = (uint8_t *)g_wlan.os_func.os_malloc(g_wlan.tx_buffer_size);
+#endif
+ PRINT_D(TX_DBG, "g_wlan.tx_buffer = %p\n", g_wlan.tx_buffer);
+
+ if (g_wlan.tx_buffer == NULL) {
+ /* ENOBUFS 105 */
+ ret = -105;
+ PRINT_ER("Can't allocate Tx Buffer");
+ goto _fail_;
+ }
+
+/* rx_buffer is not used unless we activate USE_MEM STATIC which is not applicable, allocating such memory is useless*/
+#if defined (MEMORY_STATIC)
+ if (g_wlan.rx_buffer == NULL)
+ #if (defined WILC_PREALLOC_AT_BOOT)
+ g_wlan.rx_buffer = (uint8_t *)get_rx_buffer();
+ #else
+ g_wlan.rx_buffer = (uint8_t *)g_wlan.os_func.os_malloc(g_wlan.rx_buffer_size);
+ #endif
+ PRINT_D(TX_DBG, "g_wlan.rx_buffer =%p\n", g_wlan.rx_buffer);
+ if (g_wlan.rx_buffer == NULL) {
+ /* ENOBUFS 105 */
+ ret = -105;
+ PRINT_ER("Can't allocate Rx Buffer");
+ goto _fail_;
+ }
+#endif
+
+ /**
+ * export functions
+ **/
+ oup->wlan_firmware_download = wilc_wlan_firmware_download;
+ oup->wlan_start = wilc_wlan_start;
+ oup->wlan_stop = wilc_wlan_stop;
+ oup->wlan_add_to_tx_que = wilc_wlan_txq_add_net_pkt;
+ oup->wlan_handle_tx_que = wilc_wlan_handle_txq;
+ oup->wlan_handle_rx_que = wilc_wlan_handle_rxq;
+ /* oup->wlan_handle_rx_isr = wilc_wlan_handle_isr; */
+ oup->wlan_handle_rx_isr = wilc_handle_isr;
+ oup->wlan_cleanup = wilc_wlan_cleanup;
+ oup->wlan_cfg_set = wilc_wlan_cfg_set;
+ oup->wlan_cfg_get = wilc_wlan_cfg_get;
+ oup->wlan_cfg_get_value = wilc_wlan_cfg_get_val;
+
+ /*Bug3959: transmitting mgmt frames received from host*/
+ #if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P)
+ oup->wlan_add_mgmt_to_tx_que = wilc_wlan_txq_add_mgmt_pkt;
+
+ #ifdef WILC_FULLY_HOSTING_AP
+ oup->wlan_add_data_to_tx_que = wilc_FH_wlan_txq_add_net_pkt;
+ #endif
+ #endif
+
+ if (!init_chip()) {
+ /* EIO 5 */
+ ret = -5;
+ goto _fail_;
+ }
+#ifdef TCP_ACK_FILTER
+ Init_TCP_tracking();
+#endif
+
+#if defined(PLAT_RK3026_TCHIP) /* AMR : 0422 RK3026 Crash issue */
+ if (!g_wilc_initialized)
+ custom_unlock_bus(g_mac_open);
+#endif
+
+ return 1;
+
+_fail_:
+
+#if (defined WILC_PREALLOC_AT_BOOT)
+
+#else
+ #ifdef MEMORY_STATIC
+ if (g_wlan.rx_buffer) {
+ g_wlan.os_func.os_free(g_wlan.rx_buffer);
+ g_wlan.rx_buffer = NULL;
+ }
+ #endif
+ if (g_wlan.tx_buffer) {
+ g_wlan.os_func.os_free(g_wlan.tx_buffer);
+ g_wlan.tx_buffer = NULL;
+ }
+#endif
+
+#if defined(PLAT_RK3026_TCHIP) /* AMR : 0422 RK3026 Crash issue */
+ if (!g_wilc_initialized)
+ custom_unlock_bus(g_mac_open);
+#endif
+
+ return ret;
+
+}
+
+#define BIT31 (1 << 31)
+WILC_Uint16 Set_machw_change_vir_if(WILC_Bool bValue)
+{
+ WILC_Uint16 ret;
+ WILC_Uint32 reg;
+
+ /*Reset WILC_CHANGING_VIR_IF register to allow adding futrue keys to CE H/W*/
+ (&g_wlan)->os_func.os_enter_cs((&g_wlan)->hif_lock);
+ ret = (&g_wlan)->hif_func.hif_read_reg(WILC_CHANGING_VIR_IF, &reg);
+ if (!ret) {
+ PRINT_ER("Error while Reading reg WILC_CHANGING_VIR_IF\n");
+ }
+
+ if (bValue == WILC_TRUE) {
+ reg |= (BIT31);
+ } else {
+ reg &= ~(BIT31);
+ }
+
+ ret = (&g_wlan)->hif_func.hif_write_reg(WILC_CHANGING_VIR_IF, reg);
+
+ if (!ret) {
+ PRINT_ER("Error while writing reg WILC_CHANGING_VIR_IF\n");
+ }
+ (&g_wlan)->os_func.os_leave_cs((&g_wlan)->hif_lock);
+
+ return ret;
+}
+
+#ifdef WILC_FULLY_HOSTING_AP
+wilc_wlan_dev_t *Get_wlan_context(WILC_Uint16 *pu16size)
+{
+ *pu16size = sizeof(wilc_wlan_dev_t);
+ return &g_wlan;
+}
+#endif
+
diff --git a/drivers/staging/wilc1000/wilc_wlan.h b/drivers/staging/wilc1000/wilc_wlan.h
new file mode 100644
index 00000000000000..0ba7ec69e2b411
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wlan.h
@@ -0,0 +1,321 @@
+#ifndef WILC_WLAN_H
+#define WILC_WLAN_H
+
+#include "wilc_type.h"
+
+
+#define ISWILC1000(id) (((id & 0xfffff000) == 0x100000) ? 1 : 0)
+
+
+/********************************************
+ *
+ * Mac eth header length
+ *
+ ********************************************/
+#define DRIVER_HANDLER_SIZE 4
+#define MAX_MAC_HDR_LEN 26 /* QOS_MAC_HDR_LEN */
+#define SUB_MSDU_HEADER_LENGTH 14
+#define SNAP_HDR_LEN 8
+#define ETHERNET_HDR_LEN 14
+#define WORD_ALIGNMENT_PAD 0
+
+#define ETH_ETHERNET_HDR_OFFSET (MAX_MAC_HDR_LEN + SUB_MSDU_HEADER_LENGTH + \
+ SNAP_HDR_LEN - ETHERNET_HDR_LEN + WORD_ALIGNMENT_PAD)
+
+/*Bug3959: transmitting mgmt frames received from host*/
+#define HOST_HDR_OFFSET 4
+#define ETHERNET_HDR_LEN 14
+#define IP_HDR_LEN 20
+#define IP_HDR_OFFSET ETHERNET_HDR_LEN
+#define UDP_HDR_OFFSET (IP_HDR_LEN + IP_HDR_OFFSET)
+#define UDP_HDR_LEN 8
+#define UDP_DATA_OFFSET (UDP_HDR_OFFSET + UDP_HDR_LEN)
+#define ETH_CONFIG_PKT_HDR_LEN UDP_DATA_OFFSET
+
+#define ETH_CONFIG_PKT_HDR_OFFSET (ETH_ETHERNET_HDR_OFFSET + \
+ ETH_CONFIG_PKT_HDR_LEN)
+#define ACTION 0xD0
+#define PROBE_REQ 0x40
+#ifdef WILC_FULLY_HOSTING_AP
+#define FH_TX_HOST_HDR_OFFSET 24
+#endif
+
+/********************************************
+ *
+ * Endian Conversion
+ *
+ ********************************************/
+
+#define BYTE_SWAP(val) ((((val) & 0x000000FF) << 24) + \
+ (((val) & 0x0000FF00) << 8) + \
+ (((val) & 0x00FF0000) >> 8) + \
+ (((val) & 0xFF000000) >> 24))
+
+/********************************************
+ *
+ * Register Defines
+ *
+ ********************************************/
+#define WILC_PERIPH_REG_BASE 0x1000
+/*BugID_5137*/
+#define WILC_CHANGING_VIR_IF (0x108c)
+#define WILC_CHIPID (WILC_PERIPH_REG_BASE)
+#define WILC_GLB_RESET_0 (WILC_PERIPH_REG_BASE + 0x400)
+#define WILC_PIN_MUX_0 (WILC_PERIPH_REG_BASE + 0x408)
+#define WILC_HOST_TX_CTRL (WILC_PERIPH_REG_BASE + 0x6c)
+#define WILC_HOST_RX_CTRL_0 (WILC_PERIPH_REG_BASE + 0x70)
+#define WILC_HOST_RX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x74)
+#define WILC_HOST_VMM_CTL (WILC_PERIPH_REG_BASE + 0x78)
+#define WILC_HOST_RX_CTRL (WILC_PERIPH_REG_BASE + 0x80)
+#define WILC_HOST_RX_EXTRA_SIZE (WILC_PERIPH_REG_BASE + 0x84)
+#define WILC_HOST_TX_CTRL_1 (WILC_PERIPH_REG_BASE + 0x88)
+#define WILC_MISC (WILC_PERIPH_REG_BASE + 0x428)
+#define WILC_INTR_REG_BASE (WILC_PERIPH_REG_BASE + 0xa00)
+#define WILC_INTR_ENABLE (WILC_INTR_REG_BASE)
+#define WILC_INTR2_ENABLE (WILC_INTR_REG_BASE + 4)
+
+#define WILC_INTR_POLARITY (WILC_INTR_REG_BASE + 0x10)
+#define WILC_INTR_TYPE (WILC_INTR_REG_BASE + 0x20)
+#define WILC_INTR_CLEAR (WILC_INTR_REG_BASE + 0x30)
+#define WILC_INTR_STATUS (WILC_INTR_REG_BASE + 0x40)
+
+#define WILC_VMM_TBL_SIZE 64
+#define WILC_VMM_TX_TBL_BASE (0x150400)
+#define WILC_VMM_RX_TBL_BASE (0x150500)
+
+#define WILC_VMM_BASE 0x150000
+#define WILC_VMM_CORE_CTL (WILC_VMM_BASE)
+#define WILC_VMM_TBL_CTL (WILC_VMM_BASE + 0x4)
+#define WILC_VMM_TBL_ENTRY (WILC_VMM_BASE + 0x8)
+#define WILC_VMM_TBL0_SIZE (WILC_VMM_BASE + 0xc)
+#define WILC_VMM_TO_HOST_SIZE (WILC_VMM_BASE + 0x10)
+#define WILC_VMM_CORE_CFG (WILC_VMM_BASE + 0x14)
+#define WILC_VMM_TBL_ACTIVE (WILC_VMM_BASE + 040)
+#define WILC_VMM_TBL_STATUS (WILC_VMM_BASE + 0x44)
+
+#define WILC_SPI_REG_BASE 0xe800
+#define WILC_SPI_CTL (WILC_SPI_REG_BASE)
+#define WILC_SPI_MASTER_DMA_ADDR (WILC_SPI_REG_BASE + 0x4)
+#define WILC_SPI_MASTER_DMA_COUNT (WILC_SPI_REG_BASE + 0x8)
+#define WILC_SPI_SLAVE_DMA_ADDR (WILC_SPI_REG_BASE + 0xc)
+#define WILC_SPI_SLAVE_DMA_COUNT (WILC_SPI_REG_BASE + 0x10)
+#define WILC_SPI_TX_MODE (WILC_SPI_REG_BASE + 0x20)
+#define WILC_SPI_PROTOCOL_CONFIG (WILC_SPI_REG_BASE + 0x24)
+#define WILC_SPI_INTR_CTL (WILC_SPI_REG_BASE + 0x2c)
+
+#define WILC_SPI_PROTOCOL_OFFSET (WILC_SPI_PROTOCOL_CONFIG - WILC_SPI_REG_BASE)
+
+#define WILC_AHB_DATA_MEM_BASE 0x30000
+#define WILC_AHB_SHARE_MEM_BASE 0xd0000
+
+#define WILC_VMM_TBL_RX_SHADOW_BASE WILC_AHB_SHARE_MEM_BASE /* Bug 4477 fix */
+#define WILC_VMM_TBL_RX_SHADOW_SIZE (256) /* Bug 4477 fix */
+
+#define WILC_GP_REG_0 0x149c
+#define WILC_GP_REG_1 0x14a0
+
+#define rHAVE_SDIO_IRQ_GPIO_BIT (0)
+#define rHAVE_USE_PMU_BIT (1)
+#define rHAVE_SLEEP_CLK_SRC_RTC_BIT (2)
+#define rHAVE_SLEEP_CLK_SRC_XO_BIT (3)
+#define rHAVE_EXT_PA_INV_TX_RX_BIT (4)
+#define rHAVE_LEGACY_RF_SETTINGS_BIT (5)
+#define rHAVE_XTAL_24_BIT (6)
+#define rHAVE_DISABLE_WILC_UART_BIT (7)
+
+
+#define WILC_HAVE_SDIO_IRQ_GPIO (1 << rHAVE_SDIO_IRQ_GPIO_BIT)
+#define WILC_HAVE_USE_PMU (1 << rHAVE_USE_PMU_BIT)
+#define WILC_HAVE_SLEEP_CLK_SRC_RTC (1 << rHAVE_SLEEP_CLK_SRC_RTC_BIT)
+#define WILC_HAVE_SLEEP_CLK_SRC_XO (1 << rHAVE_SLEEP_CLK_SRC_XO_BIT)
+#define WILC_HAVE_EXT_PA_INV_TX_RX (1 << rHAVE_EXT_PA_INV_TX_RX_BIT)
+#define WILC_HAVE_LEGACY_RF_SETTINGS (1 << rHAVE_LEGACY_RF_SETTINGS_BIT)
+#define WILC_HAVE_XTAL_24 (1 << rHAVE_XTAL_24_BIT)
+#define WILC_HAVE_DISABLE_WILC_UART (1 << rHAVE_DISABLE_WILC_UART_BIT)
+
+
+/********************************************
+ *
+ * Wlan Defines
+ *
+ ********************************************/
+#define WILC_CFG_PKT 1
+#define WILC_NET_PKT 0
+/*Bug3959: transmitting mgmt frames received from host*/
+#ifdef WILC_AP_EXTERNAL_MLME
+#define WILC_MGMT_PKT 2
+
+#ifdef WILC_FULLY_HOSTING_AP
+#define WILC_FH_DATA_PKT 4
+#endif
+
+#endif /*WILC_AP_EXTERNAL_MLME*/
+#define WILC_CFG_SET 1
+#define WILC_CFG_QUERY 0
+
+#define WILC_CFG_RSP 1
+#define WILC_CFG_RSP_STATUS 2
+#define WILC_CFG_RSP_SCAN 3
+
+#ifdef WILC_SDIO
+#define WILC_PLL_TO 4
+#else
+#define WILC_PLL_TO 2
+#endif
+
+
+#define ABORT_INT (1 << 31)
+
+/*******************************************/
+/* E0 and later Interrupt flags. */
+/*******************************************/
+/*******************************************/
+/* E0 and later Interrupt flags. */
+/* IRQ Status word */
+/* 15:0 = DMA count in words. */
+/* 16: INT0 flag */
+/* 17: INT1 flag */
+/* 18: INT2 flag */
+/* 19: INT3 flag */
+/* 20: INT4 flag */
+/* 21: INT5 flag */
+/*******************************************/
+#define IRG_FLAGS_OFFSET 16
+#define IRQ_DMA_WD_CNT_MASK ((1ul << IRG_FLAGS_OFFSET) - 1)
+#define INT_0 (1 << (IRG_FLAGS_OFFSET))
+#define INT_1 (1 << (IRG_FLAGS_OFFSET + 1))
+#define INT_2 (1 << (IRG_FLAGS_OFFSET + 2))
+#define INT_3 (1 << (IRG_FLAGS_OFFSET + 3))
+#define INT_4 (1 << (IRG_FLAGS_OFFSET + 4))
+#define INT_5 (1 << (IRG_FLAGS_OFFSET + 5))
+#define MAX_NUM_INT (6)
+
+/*******************************************/
+/* E0 and later Interrupt flags. */
+/* IRQ Clear word */
+/* 0: Clear INT0 */
+/* 1: Clear INT1 */
+/* 2: Clear INT2 */
+/* 3: Clear INT3 */
+/* 4: Clear INT4 */
+/* 5: Clear INT5 */
+/* 6: Select VMM table 1 */
+/* 7: Select VMM table 2 */
+/* 8: Enable VMM */
+/*******************************************/
+#define CLR_INT0 (1 << 0)
+#define CLR_INT1 (1 << 1)
+#define CLR_INT2 (1 << 2)
+#define CLR_INT3 (1 << 3)
+#define CLR_INT4 (1 << 4)
+#define CLR_INT5 (1 << 5)
+#define SEL_VMM_TBL0 (1 << 6)
+#define SEL_VMM_TBL1 (1 << 7)
+#define EN_VMM (1 << 8)
+
+#define DATA_INT_EXT INT_0
+#define PLL_INT_EXT INT_1
+#define SLEEP_INT_EXT INT_2
+#define ALL_INT_EXT (DATA_INT_EXT | PLL_INT_EXT | SLEEP_INT_EXT)
+#define NUM_INT_EXT (3)
+
+#define DATA_INT_CLR CLR_INT0
+#define PLL_INT_CLR CLR_INT1
+#define SLEEP_INT_CLR CLR_INT2
+
+#define ENABLE_RX_VMM (SEL_VMM_TBL1 | EN_VMM)
+#define ENABLE_TX_VMM (SEL_VMM_TBL0 | EN_VMM)
+
+
+/*time for expiring the semaphores of cfg packets*/
+#define CFG_PKTS_TIMEOUT 2000
+/********************************************
+ *
+ * Debug Type
+ *
+ ********************************************/
+typedef void (*wilc_debug_func)(uint32_t, char *, ...);
+
+/********************************************
+ *
+ * Tx/Rx Queue Structure
+ *
+ ********************************************/
+
+struct txq_entry_t {
+ struct txq_entry_t *next;
+ struct txq_entry_t *prev;
+ int type;
+ int tcp_PendingAck_index;
+ uint8_t *buffer;
+ int buffer_size;
+ void *priv;
+ int status;
+ void (*tx_complete_func)(void *, int);
+};
+
+struct rxq_entry_t {
+ struct rxq_entry_t *next;
+ uint8_t *buffer;
+ int buffer_size;
+};
+
+/********************************************
+ *
+ * Host IF Structure
+ *
+ ********************************************/
+
+typedef struct {
+ int (*hif_init)(wilc_wlan_inp_t *, wilc_debug_func);
+ int (*hif_deinit)(void *);
+ int (*hif_read_reg)(uint32_t, uint32_t *);
+ int (*hif_write_reg)(uint32_t, uint32_t);
+ int (*hif_block_rx)(uint32_t, uint8_t *, uint32_t);
+ int (*hif_block_tx)(uint32_t, uint8_t *, uint32_t);
+ int (*hif_sync)(void);
+ int (*hif_clear_int)(void);
+ int (*hif_read_int)(uint32_t *);
+ int (*hif_clear_int_ext)(uint32_t);
+ int (*hif_read_size)(uint32_t *);
+ int (*hif_block_tx_ext)(uint32_t, uint8_t *, uint32_t);
+ int (*hif_block_rx_ext)(uint32_t, uint8_t *, uint32_t);
+ int (*hif_sync_ext)(int);
+ void (*hif_set_max_bus_speed)(void);
+ void (*hif_set_default_bus_speed)(void);
+} wilc_hif_func_t;
+
+/********************************************
+ *
+ * Configuration Structure
+ *
+ ********************************************/
+
+#define MAX_CFG_FRAME_SIZE 1468
+
+typedef struct {
+ uint8_t ether_header[14];
+ uint8_t ip_header[20];
+ uint8_t udp_header[8];
+ uint8_t wid_header[8];
+ uint8_t frame[MAX_CFG_FRAME_SIZE];
+} wilc_cfg_frame_t;
+
+typedef struct {
+ int (*wlan_tx)(uint8_t *, uint32_t, wilc_tx_complete_func_t);
+} wilc_wlan_cfg_func_t;
+
+typedef struct {
+ int type;
+ uint32_t seq_no;
+} wilc_cfg_rsp_t;
+
+typedef struct {
+ int (*cfg_wid_set)(uint8_t *, uint32_t, uint16_t, uint8_t *, int);
+ int (*cfg_wid_get)(uint8_t *, uint32_t, uint16_t);
+ int (*cfg_wid_get_val)(uint16_t, uint8_t *, uint32_t);
+ int (*rx_indicate)(uint8_t *, int, wilc_cfg_rsp_t *);
+ int (*cfg_init)(wilc_debug_func);
+} wilc_cfg_func_t;
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.c b/drivers/staging/wilc1000/wilc_wlan_cfg.c
new file mode 100644
index 00000000000000..a627c587096089
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.c
@@ -0,0 +1,643 @@
+/* ////////////////////////////////////////////////////////////////////////// */
+/* */
+/* Copyright (c) Atmel Corporation. All rights reserved. */
+/* */
+/* Module Name: wilc_wlan_cfg.c */
+/* */
+/* */
+/* ///////////////////////////////////////////////////////////////////////// */
+
+#include "wilc_wlan_if.h"
+#include "wilc_wlan.h"
+#include "wilc_wlan_cfg.h"
+#include "coreconfigurator.h"
+
+#ifdef WILC_FULLY_HOSTING_AP
+#include "wilc_host_ap.h"
+void WILC_mgm_HOSTAPD_ACK(void *priv, WILC_Bool bStatus);
+#endif
+
+/********************************************
+ *
+ * Global Data
+ *
+ ********************************************/
+
+typedef struct {
+ wilc_debug_func dPrint;
+
+ int mac_status;
+ uint8_t mac_address[7];
+ uint8_t ip_address[5];
+ uint8_t bssid[7];
+ uint8_t ssid[34];
+ uint8_t firmware_version[129];
+ uint8_t supp_rate[24];
+ uint8_t wep_key[28];
+ uint8_t i_psk[66];
+ uint8_t hardwareProductVersion[33];
+ uint8_t phyversion[17];
+ uint8_t supp_username[21];
+ uint8_t supp_password[64];
+ uint8_t assoc_req[256];
+ uint8_t assoc_rsp[256];
+ uint8_t firmware_info[8];
+ uint8_t scan_result[256];
+ uint8_t scan_result1[256];
+} wilc_mac_cfg_t;
+
+static wilc_mac_cfg_t g_mac;
+
+static wilc_cfg_byte_t g_cfg_byte[] = {
+ {WID_BSS_TYPE, 0},
+ {WID_CURRENT_TX_RATE, 0},
+ {WID_CURRENT_CHANNEL, 0},
+ {WID_PREAMBLE, 0},
+ {WID_11G_OPERATING_MODE, 0},
+ {WID_STATUS, 0},
+ {WID_SCAN_TYPE, 0},
+ {WID_KEY_ID, 0},
+ {WID_QOS_ENABLE, 0},
+ {WID_POWER_MANAGEMENT, 0},
+ {WID_11I_MODE, 0},
+ {WID_AUTH_TYPE, 0},
+ {WID_SITE_SURVEY, 0},
+ {WID_LISTEN_INTERVAL, 0},
+ {WID_DTIM_PERIOD, 0},
+ {WID_ACK_POLICY, 0},
+ {WID_BCAST_SSID, 0},
+ {WID_REKEY_POLICY, 0},
+ {WID_SHORT_SLOT_ALLOWED, 0},
+ {WID_START_SCAN_REQ, 0},
+ {WID_RSSI, 0},
+ {WID_LINKSPEED, 0},
+ {WID_AUTO_RX_SENSITIVITY, 0},
+ {WID_DATAFLOW_CONTROL, 0},
+ {WID_SCAN_FILTER, 0},
+ {WID_11N_PROT_MECH, 0},
+ {WID_11N_ERP_PROT_TYPE, 0},
+ {WID_11N_ENABLE, 0},
+ {WID_11N_OPERATING_MODE, 0},
+ {WID_11N_OBSS_NONHT_DETECTION, 0},
+ {WID_11N_HT_PROT_TYPE, 0},
+ {WID_11N_RIFS_PROT_ENABLE, 0},
+ {WID_11N_SMPS_MODE, 0},
+ {WID_11N_CURRENT_TX_MCS, 0},
+ {WID_11N_SHORT_GI_ENABLE, 0},
+ {WID_RIFS_MODE, 0},
+ {WID_TX_ABORT_CONFIG, 0},
+ {WID_11N_IMMEDIATE_BA_ENABLED, 0},
+ {WID_11N_TXOP_PROT_DISABLE, 0},
+ {WID_NIL, 0}
+};
+
+static wilc_cfg_hword_t g_cfg_hword[] = {
+ {WID_LINK_LOSS_THRESHOLD, 0},
+ {WID_RTS_THRESHOLD, 0},
+ {WID_FRAG_THRESHOLD, 0},
+ {WID_SHORT_RETRY_LIMIT, 0},
+ {WID_LONG_RETRY_LIMIT, 0},
+ {WID_BEACON_INTERVAL, 0},
+ {WID_RX_SENSE, 0},
+ {WID_ACTIVE_SCAN_TIME, 0},
+ {WID_PASSIVE_SCAN_TIME, 0},
+ {WID_SITE_SURVEY_SCAN_TIME, 0},
+ {WID_JOIN_START_TIMEOUT, 0},
+ {WID_AUTH_TIMEOUT, 0},
+ {WID_ASOC_TIMEOUT, 0},
+ {WID_11I_PROTOCOL_TIMEOUT, 0},
+ {WID_EAPOL_RESPONSE_TIMEOUT, 0},
+ {WID_11N_SIG_QUAL_VAL, 0},
+ {WID_CCA_THRESHOLD, 0},
+ {WID_NIL, 0}
+};
+
+static wilc_cfg_word_t g_cfg_word[] = {
+ {WID_FAILED_COUNT, 0},
+ {WID_RETRY_COUNT, 0},
+ {WID_MULTIPLE_RETRY_COUNT, 0},
+ {WID_FRAME_DUPLICATE_COUNT, 0},
+ {WID_ACK_FAILURE_COUNT, 0},
+ {WID_RECEIVED_FRAGMENT_COUNT, 0},
+ {WID_MCAST_RECEIVED_FRAME_COUNT, 0},
+ {WID_FCS_ERROR_COUNT, 0},
+ {WID_SUCCESS_FRAME_COUNT, 0},
+ {WID_TX_FRAGMENT_COUNT, 0},
+ {WID_TX_MULTICAST_FRAME_COUNT, 0},
+ {WID_RTS_SUCCESS_COUNT, 0},
+ {WID_RTS_FAILURE_COUNT, 0},
+ {WID_WEP_UNDECRYPTABLE_COUNT, 0},
+ {WID_REKEY_PERIOD, 0},
+ {WID_REKEY_PACKET_COUNT, 0},
+ {WID_HW_RX_COUNT, 0},
+ {WID_GET_INACTIVE_TIME, 0},
+ {WID_NIL, 0}
+
+};
+
+static wilc_cfg_str_t g_cfg_str[] = {
+ {WID_SSID, g_mac.ssid}, /* 33 + 1 bytes */
+ {WID_FIRMWARE_VERSION, g_mac.firmware_version},
+ {WID_OPERATIONAL_RATE_SET, g_mac.supp_rate},
+ {WID_BSSID, g_mac.bssid}, /* 6 bytes */
+ {WID_WEP_KEY_VALUE, g_mac.wep_key}, /* 27 bytes */
+ {WID_11I_PSK, g_mac.i_psk}, /* 65 bytes */
+ /* {WID_11E_P_ACTION_REQ, g_mac.action_req}, */
+ {WID_HARDWARE_VERSION, g_mac.hardwareProductVersion},
+ {WID_MAC_ADDR, g_mac.mac_address},
+ {WID_PHY_VERSION, g_mac.phyversion},
+ {WID_SUPP_USERNAME, g_mac.supp_username},
+ {WID_SUPP_PASSWORD, g_mac.supp_password},
+ {WID_SITE_SURVEY_RESULTS, g_mac.scan_result},
+ {WID_SITE_SURVEY_RESULTS, g_mac.scan_result1},
+ /* {WID_RX_POWER_LEVEL, g_mac.channel_rssi}, */
+ {WID_ASSOC_REQ_INFO, g_mac.assoc_req},
+ {WID_ASSOC_RES_INFO, g_mac.assoc_rsp},
+ /* {WID_11N_P_ACTION_REQ, g_mac.action_req}, */
+ {WID_FIRMWARE_INFO, g_mac.firmware_version},
+ {WID_IP_ADDRESS, g_mac.ip_address},
+ {WID_NIL, NULL}
+};
+
+/********************************************
+ *
+ * Configuration Functions
+ *
+ ********************************************/
+
+static int wilc_wlan_cfg_set_byte(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t val8)
+{
+ uint8_t *buf;
+
+ if ((offset + 4) >= MAX_CFG_FRAME_SIZE)
+ return 0;
+
+ buf = &frame[offset];
+
+ buf[0] = (uint8_t)id;
+ buf[1] = (uint8_t)(id >> 8);
+ buf[2] = 1;
+ buf[3] = val8;
+ return 4;
+}
+
+static int wilc_wlan_cfg_set_hword(uint8_t *frame, uint32_t offset, uint16_t id, uint16_t val16)
+{
+ uint8_t *buf;
+
+ if ((offset + 5) >= MAX_CFG_FRAME_SIZE)
+ return 0;
+
+ buf = &frame[offset];
+
+ buf[0] = (uint8_t)id;
+ buf[1] = (uint8_t)(id >> 8);
+ buf[2] = 2;
+ buf[3] = (uint8_t)val16;
+ buf[4] = (uint8_t)(val16 >> 8);
+
+ return 5;
+}
+
+static int wilc_wlan_cfg_set_word(uint8_t *frame, uint32_t offset, uint16_t id, uint32_t val32)
+{
+ uint8_t *buf;
+
+ if ((offset + 7) >= MAX_CFG_FRAME_SIZE)
+ return 0;
+
+ buf = &frame[offset];
+
+ buf[0] = (uint8_t)id;
+ buf[1] = (uint8_t)(id >> 8);
+ buf[2] = 4;
+ buf[3] = (uint8_t)val32;
+ buf[4] = (uint8_t)(val32 >> 8);
+ buf[5] = (uint8_t)(val32 >> 16);
+ buf[6] = (uint8_t)(val32 >> 24);
+
+ return 7;
+}
+
+static int wilc_wlan_cfg_set_str(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *str, uint32_t size)
+{
+ uint8_t *buf;
+
+ if ((offset + size + 3) >= MAX_CFG_FRAME_SIZE)
+ return 0;
+
+ buf = &frame[offset];
+
+ buf[0] = (uint8_t)id;
+ buf[1] = (uint8_t)(id >> 8);
+ buf[2] = (uint8_t)size;
+
+ if ((str != NULL) && (size != 0))
+ memcpy(&buf[3], str, size);
+
+ return (size + 3);
+}
+
+static int wilc_wlan_cfg_set_bin(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *b, uint32_t size)
+{
+ uint8_t *buf;
+ uint32_t i;
+ uint8_t checksum = 0;
+
+ if ((offset + size + 5) >= MAX_CFG_FRAME_SIZE)
+ return 0;
+
+ buf = &frame[offset];
+ buf[0] = (uint8_t)id;
+ buf[1] = (uint8_t)(id >> 8);
+ buf[2] = (uint8_t)size;
+ buf[3] = (uint8_t)(size >> 8);
+
+ if ((b != NULL) && (size != 0)) {
+ memcpy(&buf[4], b, size);
+ for (i = 0; i < size; i++) {
+ checksum += buf[i + 4];
+ }
+ }
+
+ buf[size + 4] = checksum;
+
+ return (size + 5);
+}
+
+/********************************************
+ *
+ * Configuration Response Functions
+ *
+ ********************************************/
+
+static void wilc_wlan_parse_response_frame(uint8_t *info, int size)
+{
+ uint32_t wid, len = 0, i = 0;
+ static int seq;
+
+ while (size > 0) {
+ i = 0;
+ wid = info[0] | (info[1] << 8);
+#ifdef BIG_ENDIAN
+ wid = BYTE_SWAP(wid);
+#endif
+ PRINT_INFO(GENERIC_DBG, "Processing response for %d seq %d\n", wid, seq++);
+ switch ((wid >> 12) & 0x7) {
+ case WID_CHAR:
+ do {
+ if (g_cfg_byte[i].id == WID_NIL)
+ break;
+
+ if (g_cfg_byte[i].id == wid) {
+ g_cfg_byte[i].val = info[3];
+ break;
+ }
+ i++;
+ } while (1);
+ len = 2;
+ break;
+
+ case WID_SHORT:
+ do {
+ if (g_cfg_hword[i].id == WID_NIL)
+ break;
+
+ if (g_cfg_hword[i].id == wid) {
+#ifdef BIG_ENDIAN
+ g_cfg_hword[i].val = (info[3] << 8) | (info[4]);
+#else
+ g_cfg_hword[i].val = info[3] | (info[4] << 8);
+#endif
+ break;
+ }
+ i++;
+ } while (1);
+ len = 3;
+ break;
+
+ case WID_INT:
+ do {
+ if (g_cfg_word[i].id == WID_NIL)
+ break;
+
+ if (g_cfg_word[i].id == wid) {
+#ifdef BIG_ENDIAN
+ g_cfg_word[i].val = (info[3] << 24) | (info[4] << 16) | (info[5] << 8) | (info[6]);
+#else
+ g_cfg_word[i].val = info[3] | (info[4] << 8) | (info[5] << 16) | (info[6] << 24);
+#endif
+ break;
+ }
+ i++;
+ } while (1);
+ len = 5;
+ break;
+
+ case WID_STR:
+ do {
+ if (g_cfg_str[i].id == WID_NIL)
+ break;
+
+ if (g_cfg_str[i].id == wid) {
+ if (wid == WID_SITE_SURVEY_RESULTS) {
+ static int toggle;
+ PRINT_INFO(GENERIC_DBG, "Site survey results received[%d]\n",
+ size);
+
+ PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]toggle[%d]\n", size, toggle);
+ i += toggle;
+ toggle ^= 1;
+ }
+ memcpy(g_cfg_str[i].str, &info[2], (info[2] + 1));
+ break;
+ }
+ i++;
+ } while (1);
+ len = 1 + info[2];
+ break;
+
+ default:
+ break;
+ }
+ size -= (2 + len);
+ info += (2 + len);
+ }
+
+ return;
+}
+
+static int wilc_wlan_parse_info_frame(uint8_t *info, int size)
+{
+ wilc_mac_cfg_t *pd = (wilc_mac_cfg_t *)&g_mac;
+ uint32_t wid, len;
+ int type = WILC_CFG_RSP_STATUS;
+
+ wid = info[0] | (info[1] << 8);
+#if 0
+#ifdef BIG_ENDIAN
+ wid = BYTE_SWAP(wid);
+#endif
+#endif
+
+ len = info[2];
+ PRINT_INFO(GENERIC_DBG, "Status Len = %d Id= %d\n", len, wid);
+ if ((len == 1) && (wid == WID_STATUS)) {
+ pd->mac_status = info[3];
+ type = WILC_CFG_RSP_STATUS;
+ }
+
+ return type;
+}
+
+#if 0
+static int wilc_wlan_parse_network_frame(uint8_t *info, int size)
+{
+ wilc_mac_cfg_t *priv = (wilc_mac_cfg_t *)&g_mac;
+ uint32_t wid, len;
+
+ wid = info[0] | (info[1] << 8);
+ len = info[2] | (info[3] << 8);
+
+ /**
+ * Review: this message is only for AP mode.
+ * TBD
+ **/
+ if (wid == WID_NETWORK_INFO) { /* not send by the firmware */
+
+ }
+
+ return;
+}
+#endif
+
+/********************************************
+ *
+ * Configuration Exported Functions
+ *
+ ********************************************/
+
+static int wilc_wlan_cfg_set_wid(uint8_t *frame, uint32_t offset, uint16_t id, uint8_t *buf, int size)
+{
+ uint8_t type = (id >> 12) & 0xf;
+ int ret = 0;
+
+ if (type == 0) { /* byte command */
+ if (size >= 1)
+ ret = wilc_wlan_cfg_set_byte(frame, offset, id, *buf);
+ } else if (type == 1) { /* half word command */
+ if (size >= 2)
+ ret = wilc_wlan_cfg_set_hword(frame, offset, id, *((uint16_t *)buf));
+ } else if (type == 2) { /* word command */
+ if (size >= 4)
+ ret = wilc_wlan_cfg_set_word(frame, offset, id, *((uint32_t *)buf));
+ } else if (type == 3) { /* string command */
+ ret = wilc_wlan_cfg_set_str(frame, offset, id, buf, size);
+ } else if (type == 4) { /* binary command */
+ ret = wilc_wlan_cfg_set_bin(frame, offset, id, buf, size);
+ } else {
+ g_mac.dPrint(N_ERR, "illegal id\n");
+ }
+
+ return ret;
+}
+
+static int wilc_wlan_cfg_get_wid(uint8_t *frame, uint32_t offset, uint16_t id)
+{
+ uint8_t *buf;
+
+ if ((offset + 2) >= MAX_CFG_FRAME_SIZE)
+ return 0;
+
+ buf = &frame[offset];
+
+ buf[0] = (uint8_t)id;
+ buf[1] = (uint8_t)(id >> 8);
+
+ return 2;
+}
+
+static int wilc_wlan_cfg_get_wid_value(uint16_t wid, uint8_t *buffer, uint32_t buffer_size)
+{
+ uint32_t type = (wid >> 12) & 0xf;
+ int i, ret = 0;
+
+ if (wid == WID_STATUS) {
+ *((uint32_t *)buffer) = g_mac.mac_status;
+ return 4;
+ }
+
+ i = 0;
+ if (type == 0) { /* byte command */
+ do {
+ if (g_cfg_byte[i].id == WID_NIL)
+ break;
+
+ if (g_cfg_byte[i].id == wid) {
+ memcpy(buffer, &g_cfg_byte[i].val, 1);
+ ret = 1;
+ break;
+ }
+ i++;
+ } while (1);
+ } else if (type == 1) { /* half word command */
+ do {
+ if (g_cfg_hword[i].id == WID_NIL)
+ break;
+
+ if (g_cfg_hword[i].id == wid) {
+ memcpy(buffer, &g_cfg_hword[i].val, 2);
+ ret = 2;
+ break;
+ }
+ i++;
+ } while (1);
+ } else if (type == 2) { /* word command */
+ do {
+ if (g_cfg_word[i].id == WID_NIL)
+ break;
+
+ if (g_cfg_word[i].id == wid) {
+ memcpy(buffer, &g_cfg_word[i].val, 4);
+ ret = 4;
+ break;
+ }
+ i++;
+ } while (1);
+ } else if (type == 3) { /* string command */
+ do {
+ if (g_cfg_str[i].id == WID_NIL)
+ break;
+
+ if (g_cfg_str[i].id == wid) {
+ uint32_t size = g_cfg_str[i].str[0];
+ if (buffer_size >= size) {
+ if (g_cfg_str[i].id == WID_SITE_SURVEY_RESULTS) {
+ static int toggle;
+ PRINT_INFO(GENERIC_DBG, "Site survey results value[%d]\n",
+ size);
+ i += toggle;
+ toggle ^= 1;
+
+ }
+ memcpy(buffer, &g_cfg_str[i].str[1], size);
+ ret = size;
+ }
+ break;
+ }
+ i++;
+ } while (1);
+ } else {
+ g_mac.dPrint(N_ERR, "[CFG]: illegal type (%08x)\n", wid);
+ }
+
+ return ret;
+}
+
+static int wilc_wlan_cfg_indicate_rx(uint8_t *frame, int size, wilc_cfg_rsp_t *rsp)
+{
+ int ret = 1;
+ uint8_t msg_type;
+ uint8_t msg_id;
+ uint16_t msg_len;
+ #ifdef WILC_FULLY_HOSTING_AP
+ WILC_Uint32 *ptru32Frame;
+ WILC_Bool bStatus = frame[2];
+
+ #ifdef BIG_ENDIAN
+ ptru32Frame = (frame[4] << 24) | (frame[5] << 16) | (frame[6] << 8) | frame[7];
+ #else
+ ptru32Frame = (frame[7] << 24) | (frame[6] << 16) | (frame[5] << 8) | frame[4];
+ #endif /* BIG_ENDIAN */
+
+ #endif /* WILC_FULLY_HOSTING_AP */
+
+ msg_type = frame[0];
+ msg_id = frame[1]; /* seq no */
+#ifdef BIG_ENDIAN
+ msg_len = (frame[2] << 8) | frame[3];
+#else
+ msg_len = (frame[3] << 8) | frame[2];
+#endif
+ frame += 4;
+ size -= 4;
+
+ /**
+ * The valid types of response messages are 'R' (Response), 'I' (Information), and 'N' (Network Information)
+ **/
+
+ switch (msg_type) {
+ case 'R':
+ wilc_wlan_parse_response_frame(frame, size);
+ rsp->type = WILC_CFG_RSP;
+ rsp->seq_no = msg_id;
+ break;
+
+ case 'I':
+ rsp->type = wilc_wlan_parse_info_frame(frame, size);
+ rsp->seq_no = msg_id;
+ /*call host interface info parse as well*/
+ PRINT_INFO(RX_DBG, "Info message received\n");
+ GnrlAsyncInfoReceived(frame - 4, size + 4);
+ break;
+
+ case 'L':
+#ifndef SWITCH_LOG_TERMINAL
+ PRINT_ER("Unexpected firmware log message received \n");
+#else
+ PRINT_D(FIRM_DBG, "\nFIRMWARE LOGS :\n<<\n%s\n>>\n", frame);
+ break;
+
+#endif
+#if 1
+ case 'N':
+ NetworkInfoReceived(frame - 4, size + 4);
+ rsp->type = 0;
+ break;
+
+#endif
+/*bug3819:*/
+ case 'S':
+ PRINT_INFO(RX_DBG, "Scan Notification Received \n");
+ host_int_ScanCompleteReceived(frame - 4, size + 4);
+ break;
+
+#ifdef WILC_FULLY_HOSTING_AP
+ case 'T':
+ PRINT_INFO(RX_DBG, "TBTT Notification Received \n");
+ process_tbtt_isr();
+ break;
+
+ case 'A':
+ PRINT_INFO(RX_DBG, "HOSTAPD ACK Notification Received \n");
+ WILC_mgm_HOSTAPD_ACK(ptru32Frame, bStatus);
+ break;
+#endif
+
+ default:
+ PRINT_INFO(RX_DBG, "Receive unknown message type[%d-%d-%d-%d-%d-%d-%d-%d]\n",
+ frame[0], frame[1], frame[2], frame[3], frame[4],
+ frame[5], frame[6], frame[7]);
+ rsp->type = 0;
+ rsp->seq_no = msg_id;
+ ret = 0;
+ break;
+ }
+
+ return ret;
+}
+
+static int wilc_wlan_cfg_init(wilc_debug_func func)
+{
+ memset((void *)&g_mac, 0, sizeof(wilc_mac_cfg_t));
+ g_mac.dPrint = func;
+ return 1;
+}
+
+wilc_cfg_func_t mac_cfg = {
+ wilc_wlan_cfg_set_wid,
+ wilc_wlan_cfg_get_wid,
+ wilc_wlan_cfg_get_wid_value,
+ wilc_wlan_cfg_indicate_rx,
+ wilc_wlan_cfg_init,
+};
diff --git a/drivers/staging/wilc1000/wilc_wlan_cfg.h b/drivers/staging/wilc1000/wilc_wlan_cfg.h
new file mode 100644
index 00000000000000..8906611b29304c
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wlan_cfg.h
@@ -0,0 +1,33 @@
+/* ////////////////////////////////////////////////////////////////////////// */
+/* */
+/* Copyright (c) Atmel Corporation. All rights reserved. */
+/* */
+/* Module Name: wilc_wlan_cfg.h */
+/* */
+/* */
+/* ///////////////////////////////////////////////////////////////////////// */
+
+#ifndef WILC_WLAN_CFG_H
+#define WILC_WLAN_CFG_H
+
+typedef struct {
+ uint16_t id;
+ uint16_t val;
+} wilc_cfg_byte_t;
+
+typedef struct {
+ uint16_t id;
+ uint16_t val;
+} wilc_cfg_hword_t;
+
+typedef struct {
+ uint32_t id;
+ uint32_t val;
+} wilc_cfg_word_t;
+
+typedef struct {
+ uint32_t id;
+ uint8_t *str;
+} wilc_cfg_str_t;
+
+#endif
diff --git a/drivers/staging/wilc1000/wilc_wlan_if.h b/drivers/staging/wilc1000/wilc_wlan_if.h
new file mode 100644
index 00000000000000..dd86ca7dd3f3ff
--- /dev/null
+++ b/drivers/staging/wilc1000/wilc_wlan_if.h
@@ -0,0 +1,991 @@
+/* ////////////////////////////////////////////////////////////////////////// */
+/* */
+/* Copyright (c) Atmel Corporation. All rights reserved. */
+/* */
+/* Module Name: wilc_wlan_if.h */
+/* */
+/* */
+/* ///////////////////////////////////////////////////////////////////////// */
+
+
+#ifndef WILC_WLAN_IF_H
+#define WILC_WLAN_IF_H
+
+/*bug 3887: [AP] Allow Management frames to be passed to the host*/
+#define WILC_AP_EXTERNAL_MLME
+#define WILC_P2P
+#define TCP_ENHANCEMENTS
+/* #define MEMORY_STATIC */
+/* #define WILC_FULLY_HOSTING_AP */
+/* #define USE_OLD_SPI_SW */
+
+
+#include "wilc_type.h"
+#include "linux_wlan_common.h"
+
+
+/********************************************
+ *
+ * Debug Flags
+ *
+ ********************************************/
+
+#define N_INIT 0x00000001
+#define N_ERR 0x00000002
+#define N_TXQ 0x00000004
+#define N_INTR 0x00000008
+#define N_RXQ 0x00000010
+
+/********************************************
+ *
+ * Host Interface Defines
+ *
+ ********************************************/
+
+#define HIF_SDIO (0)
+#define HIF_SPI (1 << 0)
+#define HIF_SDIO_GPIO_IRQ (1 << 2)
+
+
+/********************************************
+ *
+ * Tx/Rx Buffer Size Defines
+ *
+ ********************************************/
+
+#define CE_TX_BUFFER_SIZE (64 * 1024)
+#define CE_RX_BUFFER_SIZE (384 * 1024)
+
+/********************************************
+ *
+ * Wlan Interface Defines
+ *
+ ********************************************/
+
+typedef struct {
+ uint32_t read_write: 1;
+ uint32_t function: 3;
+ uint32_t raw: 1;
+ uint32_t address: 17;
+ uint32_t data: 8;
+} sdio_cmd52_t;
+
+typedef struct {
+ /* struct { */
+ uint32_t read_write: 1;
+ uint32_t function: 3;
+ uint32_t block_mode: 1;
+ uint32_t increment: 1;
+ uint32_t address: 17;
+ uint32_t count: 9;
+ /* } bit; */
+ uint8_t *buffer;
+ uint32_t block_size;
+} sdio_cmd53_t;
+
+typedef struct {
+ void (*os_sleep)(uint32_t);
+ void (*os_atomic_sleep)(uint32_t);
+ void (*os_debug)(uint8_t *);
+ void *(*os_malloc)(uint32_t);
+ void *(*os_malloc_atomic)(uint32_t);
+ void (*os_free)(void *);
+ void (*os_lock)(void *);
+ void (*os_unlock)(void *);
+ int (*os_wait)(void *, WILC_Uint32);
+ void (*os_signal)(void *);
+ void (*os_enter_cs)(void *);
+ void (*os_leave_cs)(void *);
+
+ /*Added by Amr - BugID_4720*/
+ void (*os_spin_lock)(void *, unsigned long *);
+ void (*os_spin_unlock)(void *, unsigned long *);
+
+} wilc_wlan_os_func_t;
+
+typedef struct {
+ int io_type;
+ int (*io_init)(void *);
+ void (*io_deinit)(void *);
+ union {
+ struct {
+ int (*sdio_cmd52)(sdio_cmd52_t *);
+ int (*sdio_cmd53)(sdio_cmd53_t *);
+ int (*sdio_set_max_speed)(void);
+ int (*sdio_set_default_speed)(void);
+ } sdio;
+ struct {
+ int (*spi_max_speed)(void);
+ int (*spi_tx)(uint8_t *, uint32_t);
+ int (*spi_rx)(uint8_t *, uint32_t);
+ int (*spi_trx)(uint8_t *, uint8_t *, uint32_t);
+ } spi;
+ } u;
+} wilc_wlan_io_func_t;
+
+typedef struct {
+ void (*rx_indicate)(uint8_t *, uint32_t, uint32_t);
+ void (*rx_complete)(void);
+} wilc_wlan_net_func_t;
+
+typedef struct {
+ void (*mac_indicate)(int);
+} wilc_wlan_indicate_func_t;
+#define WILC_MAC_INDICATE_STATUS 0x1
+#define WILC_MAC_STATUS_INIT -1
+#define WILC_MAC_STATUS_READY 0
+#define WILC_MAC_STATUS_CONNECT 1
+
+#define WILC_MAC_INDICATE_SCAN 0x2
+
+typedef struct {
+ void *os_private;
+
+ void *hif_critical_section;
+
+ uint32_t tx_buffer_size;
+ void *txq_critical_section;
+
+ /*Added by Amr - BugID_4720*/
+ void *txq_add_to_head_critical_section;
+ void *txq_spin_lock;
+
+ void *txq_wait_event;
+
+#if defined(MEMORY_STATIC)
+ uint32_t rx_buffer_size;
+#endif
+ void *rxq_critical_section;
+ void *rxq_wait_event;
+
+ void *cfg_wait_event;
+} wilc_wlan_os_context_t;
+
+typedef struct {
+ wilc_wlan_os_context_t os_context;
+ wilc_wlan_os_func_t os_func;
+ wilc_wlan_io_func_t io_func;
+ wilc_wlan_net_func_t net_func;
+ wilc_wlan_indicate_func_t indicate_func;
+} wilc_wlan_inp_t;
+
+#if 0
+typedef struct {
+ int start;
+ uint32_t id;
+ void *buffer;
+ uint32_t buffer_size;
+ int commit;
+} wilc_wlan_cfg_set_t;
+
+typedef struct {
+ int start;
+ uint32_t id;
+ int commit;
+} wilc_wlan_cfg_get_t;
+
+typedef struct {
+ uint32_t id;
+ void *buffer;
+ uint32_t buffer_size;
+} wilc_wlan_cfg_val_t;
+#endif
+
+struct tx_complete_data {
+ #ifdef WILC_FULLY_HOSTING_AP
+ struct tx_complete_data *next;
+ #endif
+ int size;
+ void *buff;
+ uint8_t *pBssid;
+ struct sk_buff *skb;
+};
+
+
+typedef void (*wilc_tx_complete_func_t)(void *, int);
+
+#define WILC_TX_ERR_NO_BUF (-2)
+
+typedef struct {
+ int (*wlan_firmware_download)(const uint8_t *, uint32_t);
+ int (*wlan_start)(void);
+ int (*wlan_stop)(void);
+ int (*wlan_add_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t);
+ int (*wlan_handle_tx_que)(uint32_t *);
+ void (*wlan_handle_rx_que)(void);
+ void (*wlan_handle_rx_isr)(void);
+ void (*wlan_cleanup)(void);
+ int (*wlan_cfg_set)(int, uint32_t, uint8_t *, uint32_t, int, uint32_t);
+ int (*wlan_cfg_get)(int, uint32_t, int, uint32_t);
+ int (*wlan_cfg_get_value)(uint32_t, uint8_t *, uint32_t);
+ /*Bug3959: transmitting mgmt frames received from host*/
+ #if defined(WILC_AP_EXTERNAL_MLME) || defined(WILC_P2P)
+ int (*wlan_add_mgmt_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t);
+
+ #ifdef WILC_FULLY_HOSTING_AP
+ int (*wlan_add_data_to_tx_que)(void *, uint8_t *, uint32_t, wilc_tx_complete_func_t);
+ #endif
+
+ #endif
+} wilc_wlan_oup_t;
+
+/********************************************
+ *
+ * Wlan Configuration ID
+ *
+ ********************************************/
+
+#define MAX_SSID_LEN 33
+#define MAX_RATES_SUPPORTED 12
+
+#define INFINITE_SLEEP_TIME ((WILC_Uint32)0xFFFFFFFF)
+
+#ifdef WILC_PARSE_SCAN_IN_HOST
+typedef enum {
+ SUPP_RATES_IE = 1,
+ EXT_SUPP_RATES_IE = 50,
+ HT_CAPABILITY_IE = 45,
+ RSN_IE = 48,
+ WPA_IE = 221,
+ WMM_IE = 221,
+ #ifdef WILC_P2P
+ P2P_IE = 221,
+ #endif
+} BEACON_IE;
+#endif
+typedef enum {
+ INFRASTRUCTURE = 0,
+ INDEPENDENT,
+ AP,
+} BSSTYPE_T;
+
+typedef enum {
+ RATE_AUTO = 0,
+ RATE_1MB = 1,
+ RATE_2MB = 2,
+ RATE_5MB = 5,
+ RATE_6MB = 6,
+ RATE_9MB = 9,
+ RATE_11MB = 11,
+ RATE_12MB = 12,
+ RATE_18MB = 18,
+ RATE_24MB = 24,
+ RATE_26MB = 36,
+ RATE_48MB = 48,
+ RATE_54MB = 54
+} TX_RATE_T;
+
+typedef enum {
+ B_ONLY_MODE = 0, /* basic rate: 1, 2 Mbps, otherwise: 5, 11 Mbps */
+ G_ONLY_MODE, /* basic rate: 6, 12, 24 Mbps, otherwise: 9, 18, 36, 48, 54 Mbps */
+ G_MIXED_11B_1_MODE, /* basic rate: 1, 2, 5.5, 11 Mbps, otherwise: all on */
+ G_MIXED_11B_2_MODE, /* basic rate: 1, 2, 5, 11, 6, 12, 24 Mbps, otherwise: all on */
+} G_OPERATING_MODE_T;
+
+typedef enum {
+ G_SHORT_PREAMBLE = 0, /* Short Preamble */
+ G_LONG_PREAMBLE = 1, /* Long Preamble */
+ G_AUTO_PREAMBLE = 2, /* Auto Preamble Selection */
+} G_PREAMBLE_T;
+
+#define MAC_CONNECTED 1
+#define MAC_DISCONNECTED 0
+
+/*bug3819: */
+#define SCAN_DONE TRUE
+typedef enum {
+ PASSIVE_SCAN = 0,
+ ACTIVE_SCAN = 1,
+} SCANTYPE_T;
+
+typedef enum {
+ NO_POWERSAVE = 0,
+ MIN_FAST_PS = 1,
+ MAX_FAST_PS = 2,
+ MIN_PSPOLL_PS = 3,
+ MAX_PSPOLL_PS = 4
+} USER_PS_MODE_T;
+
+typedef enum {
+ CHIP_WAKEDUP = 0,
+ CHIP_SLEEPING_AUTO = 1,
+ CHIP_SLEEPING_MANUAL = 2
+} CHIP_PS_STATE_T;
+
+typedef enum {
+ ACQUIRE_ONLY = 0,
+ ACQUIRE_AND_WAKEUP = 1,
+} BUS_ACQUIRE_T;
+
+typedef enum {
+ RELEASE_ONLY = 0,
+ RELEASE_ALLOW_SLEEP = 1,
+} BUS_RELEASE_T;
+
+typedef enum {
+ NO_SECURITY = 0,
+ WEP_40 = 0x3,
+ WEP_104 = 0x7,
+ WPA_AES = 0x29,
+ WPA_TKIP = 0x49,
+ WPA_AES_TKIP = 0x69, /* Aes or Tkip */
+ WPA2_AES = 0x31,
+ WPA2_TKIP = 0x51,
+ WPA2_AES_TKIP = 0x71, /* Aes or Tkip */
+} SECURITY_T;
+
+typedef enum {
+ OPEN_SYSTEM = 1,
+ SHARED_KEY = 2,
+ ANY = 3,
+ IEEE8021 = 5
+} AUTHTYPE_T;
+
+typedef enum {
+ SITE_SURVEY_1CH = 0,
+ SITE_SURVEY_ALL_CH = 1,
+ SITE_SURVEY_OFF = 2
+} SITE_SURVEY_T;
+
+typedef enum {
+ NORMAL_ACK = 0,
+ NO_ACK,
+} ACK_POLICY_T;
+
+typedef enum {
+ DONT_RESET = 0,
+ DO_RESET = 1,
+ NO_REQUEST = 2,
+} RESET_REQ_T;
+
+typedef enum {
+ REKEY_DISABLE = 1,
+ REKEY_TIME_BASE,
+ REKEY_PKT_BASE,
+ REKEY_TIME_PKT_BASE
+} RSNA_REKEY_POLICY_T;
+
+typedef enum {
+ FILTER_NO = 0x00,
+ FILTER_AP_ONLY = 0x01,
+ FILTER_STA_ONLY = 0x02
+} SCAN_CLASS_FITLER_T;
+
+typedef enum {
+ PRI_HIGH_RSSI = 0x00,
+ PRI_LOW_RSSI = 0x04,
+ PRI_DETECT = 0x08
+} SCAN_PRI_T;
+
+typedef enum {
+ CH_FILTER_OFF = 0x00,
+ CH_FILTER_ON = 0x10
+} CH_FILTER_T;
+
+typedef enum {
+ AUTO_PROT = 0, /* Auto */
+ NO_PROT, /* Do not use any protection */
+ ERP_PROT, /* Protect all ERP frame exchanges */
+ HT_PROT, /* Protect all HT frame exchanges */
+ GF_PROT, /* Protect all GF frame exchanges */
+} N_PROTECTION_MODE_T;
+
+typedef enum {
+ G_SELF_CTS_PROT,
+ G_RTS_CTS_PROT,
+} G_PROTECTION_MODE_T;
+
+typedef enum {
+ HT_MIXED_MODE = 1,
+ HT_ONLY_20MHZ_MODE,
+ HT_ONLY_20_40MHZ_MODE,
+} N_OPERATING_MODE_T;
+
+typedef enum {
+ NO_DETECT = 0,
+ DETECT_ONLY = 1,
+ DETECT_PROTECT = 2,
+ DETECT_PROTECT_REPORT = 3,
+} N_OBSS_DETECTION_T;
+
+typedef enum {
+ RTS_CTS_NONHT_PROT = 0, /* RTS-CTS at non-HT rate */
+ FIRST_FRAME_NONHT_PROT, /* First frame at non-HT rate */
+ LSIG_TXOP_PROT, /* LSIG TXOP Protection */
+ FIRST_FRAME_MIXED_PROT, /* First frame at Mixed format */
+} N_PROTECTION_TYPE_T;
+
+typedef enum {
+ STATIC_MODE = 1,
+ DYNAMIC_MODE = 2,
+ MIMO_MODE = 3, /* power save disable */
+} N_SMPS_MODE_T;
+
+typedef enum {
+ DISABLE_SELF_CTS,
+ ENABLE_SELF_CTS,
+ DISABLE_TX_ABORT,
+ ENABLE_TX_ABORT,
+ HW_TRIGGER_ABORT,
+ SW_TRIGGER_ABORT,
+} TX_ABORT_OPTION_T;
+
+typedef enum {
+ WID_CHAR = 0,
+ WID_SHORT = 1,
+ WID_INT = 2,
+ WID_STR = 3,
+ WID_BIN_DATA = 4,
+ WID_BIN = 5,
+ WID_IP = 6,
+ WID_ADR = 7,
+ WID_UNDEF = 8,
+ WID_TYPE_FORCE_32BIT = 0xFFFFFFFF
+
+} WID_TYPE_T, tenuWIDtype;
+
+typedef enum {
+ WID_NIL = 0xffff,
+
+
+ /* BSS Type */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Infrastructure Independent Access Point */
+ /* Values to set : 0 1 2 */
+ /* -------------------------------------------------------------- */
+ WID_BSS_TYPE = 0x0000,
+
+ /* Transmit Rate */
+ /* -------------------------------------------------------------- */
+ /* Configuration : 1 2 5.5 11 6 9 12 18 24 36 48 54 */
+ /* Values to set : 1 2 5 11 6 9 12 18 24 36 48 54 */
+ /* -------------------------------------------------------------- */
+ WID_CURRENT_TX_RATE = 0x0001,
+
+ /* Channel */
+ /* ------------------------------------------------------------------- */
+ /* Configuration(g) : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
+ /* Values to set : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
+ /* -------------------------------------------------------------------- */
+ WID_CURRENT_CHANNEL = 0x0002,
+
+ /* Preamble */
+ /* -------------------------------------------------------------- */
+ /* Configuration : short long Auto */
+ /* Values to set : 0 1 2 */
+ /* -------------------------------------------------------------- */
+ WID_PREAMBLE = 0x0003,
+
+ /* 11g operating mode (ignored if 11g not present) */
+ /* -------------------------------------------------------------- */
+ /* Configuration : HighPerf Compat(RSet #1) Compat(RSet #2) */
+ /* Values to set : 1 2 3 */
+ /* -------------------------------------------------------------- */
+ WID_11G_OPERATING_MODE = 0x0004,
+
+ /* Mac status (response only) */
+ /* -------------------------------------------------------------- */
+ /* Configuration : disconnect connect */
+ /* Values to get : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_STATUS = 0x0005,
+
+ /* Scan type */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Passive Scanning Active Scanning */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_SCAN_TYPE = 0x0007,
+
+ /* Key Id (WEP default key Id) */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Any value between 0 to 3 */
+ /* Values to set : Same value. Default is 0 */
+ /* -------------------------------------------------------------- */
+ WID_KEY_ID = 0x0009,
+
+ /* QoS Enable */
+ /* -------------------------------------------------------------- */
+ /* Configuration : QoS Disable WMM Enable */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_QOS_ENABLE = 0x000A,
+
+ /* Power Management */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : NO_POWERSAVE MIN_POWERSAVE MAX_POWERSAVE */
+ /* Values to set : 0 1 2 */
+ /* ------------------------------------------------------------------ */
+ WID_POWER_MANAGEMENT = 0x000B,
+
+ /* WEP/802 11I Configuration */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : Disable WP40 WP104 WPA-AES WPA-TKIP RSN-AES RSN-TKIP */
+ /* Values (0x) : 00 03 07 29 49 31 51 */
+ /* */
+ /* Configuration : WPA-AES+TKIP RSN-AES+TKIP */
+ /* Values (0x) : 69 71 */
+ /* ------------------------------------------------------------------ */
+ WID_11I_MODE = 0x000C,
+
+ /* WEP Configuration: Used in BSS STA mode only when WEP is enabled */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : Open System Shared Key Any Type | 802.1x Auth */
+ /* Values (0x) : 01 02 03 | BIT2 */
+ /* ------------------------------------------------------------------ */
+ WID_AUTH_TYPE = 0x000D,
+
+ /* Site Survey Type */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Values to set */
+ /* Survey 1 Channel : 0 */
+ /* survey all Channels : 1 */
+ /* Disable Site Survey : 2 */
+ /* -------------------------------------------------------------- */
+ WID_SITE_SURVEY = 0x000E,
+
+ /* Listen Interval */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Any value between 1 to 255 */
+ /* Values to set : Same value. Default is 3 */
+ /* -------------------------------------------------------------- */
+ WID_LISTEN_INTERVAL = 0x000F,
+
+ /* DTIM Period */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Any value between 1 to 255 */
+ /* Values to set : Same value. Default is 3 */
+ /* -------------------------------------------------------------- */
+ WID_DTIM_PERIOD = 0x0010,
+
+ /* ACK Policy */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Normal Ack No Ack */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_ACK_POLICY = 0x0011,
+
+ /* Reset MAC (Set only) */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Don't Reset Reset No Request */
+ /* Values to set : 0 1 2 */
+ /* -------------------------------------------------------------- */
+ WID_RESET = 0x0012,
+
+ /* Broadcast SSID Option: Setting this will adhere to "" SSID element */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : Enable Disable */
+ /* Values to set : 1 0 */
+ /* ------------------------------------------------------------------ */
+ WID_BCAST_SSID = 0x0015,
+
+ /* Disconnect (Station) */
+ /* ------------------------------------------------------------------ */
+ /* Configuration : Association ID */
+ /* Values to set : Association ID */
+ /* ------------------------------------------------------------------ */
+ WID_DISCONNECT = 0x0016,
+
+ /* 11a Tx Power Level */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Sets TX Power (Higher the value greater the power) */
+ /* Values to set : Any value between 0 and 63 (inclusive; Default is 48)*/
+ /* -------------------------------------------------------------------- */
+ WID_TX_POWER_LEVEL_11A = 0x0018,
+
+ /* Group Key Update Policy Selection */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Disabled timeBased packetBased timePacketBased */
+ /* Values to set : 1 2 3 4 */
+ /* -------------------------------------------------------------------- */
+ WID_REKEY_POLICY = 0x0019,
+
+ /* Allow Short Slot */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Disallow Short Slot Allow Short Slot */
+ /* (Enable Only Long Slot) (Enable Short Slot if applicable)*/
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_SHORT_SLOT_ALLOWED = 0x001A,
+
+ WID_PHY_ACTIVE_REG = 0x001B,
+
+ /* 11b Tx Power Level */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Sets TX Power (Higher the value greater the power) */
+ /* Values to set : Any value between 0 and 63 (inclusive; Default is 48)*/
+ /* -------------------------------------------------------------------- */
+ WID_TX_POWER_LEVEL_11B = 0x001D,
+
+ /* Scan Request */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Request default scan */
+ /* Values to set : 0 */
+ /* -------------------------------------------------------------------- */
+ WID_START_SCAN_REQ = 0x001E,
+
+ /* Rssi (get only) */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : */
+ /* Values to get : Rssi value */
+ /* -------------------------------------------------------------------- */
+ WID_RSSI = 0x001F,
+
+ /* Join Request */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Request to join */
+ /* Values to set : index of scan result */
+ /* -------------------------------------------------------------------- */
+ WID_JOIN_REQ = 0x0020,
+
+ WID_LINKSPEED = 0x0026,
+
+ /* Enable User Control of TX Power */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Disable Enable */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------------- */
+ WID_USER_CONTROL_ON_TX_POWER = 0x0027,
+
+ WID_MEMORY_ACCESS_8BIT = 0x0029,
+
+ /* Enable Auto RX Sensitivity feature */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Disable Enable */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------------- */
+ WID_AUTO_RX_SENSITIVITY = 0x0032,
+
+ /* Receive Buffer Based Ack */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Disable Enable */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------------- */
+ WID_DATAFLOW_CONTROL = 0x0033,
+
+ /* Scan Filter */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Class No filter AP only Station Only */
+ /* Values to set : 0 1 2 */
+ /* Configuration : Priority High Rssi Low Rssi Detect */
+ /* Values to set : 0 0x4 0x08 */
+ /* Configuration : Channel filter off filter on */
+ /* Values to set : 0 0x10 */
+ /* -------------------------------------------------------------------- */
+ WID_SCAN_FILTER = 0x0036,
+
+ /* Link Loss Threshold (measure in the beacon period) */
+ /* -------------------------------------------------------------------- */
+ /* Configuration : Any value between 10 and 254 (Set to 255 to disable it) */
+ /* Values to set : Same value. Default is 10 */
+ /* -------------------------------------------------------------------- */
+ WID_LINK_LOSS_THRESHOLD = 0x0037,
+
+ /*BugID_4978*/
+ WID_ABORT_RUNNING_SCAN = 0x003E,
+
+ /* NMAC Character WID list */
+ WID_WPS_START = 0x0043,
+
+ /* Protection mode for MAC */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Auto No protection ERP HT GF */
+ /* Values to set : 0 1 2 3 4 */
+ /* -------------------------------------------------------------- */
+ WID_11N_PROT_MECH = 0x0080,
+
+ /* ERP Protection type for MAC */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Self-CTS RTS-CTS */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_11N_ERP_PROT_TYPE = 0x0081,
+
+ /* HT Option Enable */
+ /* -------------------------------------------------------------- */
+ /* Configuration : HT Enable HT Disable */
+ /* Values to set : 1 0 */
+ /* -------------------------------------------------------------- */
+ WID_11N_ENABLE = 0x0082,
+
+ /* 11n Operating mode (Note that 11g operating mode will also be */
+ /* used in addition to this, if this is set to HT Mixed mode) */
+ /* -------------------------------------------------------------- */
+ /* Configuration : HT Mixed HT Only-20MHz HT Only-20/40MHz */
+ /* Values to set : 1 2 3 */
+ /* -------------------------------------------------------------- */
+ WID_11N_OPERATING_MODE = 0x0083,
+
+ /* 11n OBSS non-HT STA Detection flag */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Do not detect */
+ /* Values to set : 0 */
+ /* Configuration : Detect, do not protect or report */
+ /* Values to set : 1 */
+ /* Configuration : Detect, protect and do not report */
+ /* Values to set : 2 */
+ /* Configuration : Detect, protect and report to other BSS */
+ /* Values to set : 3 */
+ /* -------------------------------------------------------------- */
+ WID_11N_OBSS_NONHT_DETECTION = 0x0084,
+
+ /* 11n HT Protection Type */
+ /* -------------------------------------------------------------- */
+ /* Configuration : RTS-CTS First Frame Exchange at non-HT-rate */
+ /* Values to set : 0 1 */
+ /* Configuration : LSIG TXOP First Frame Exchange in Mixed Fmt */
+ /* Values to set : 2 3 */
+ /* -------------------------------------------------------------- */
+ WID_11N_HT_PROT_TYPE = 0x0085,
+
+ /* 11n RIFS Protection Enable Flag */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Disable Enable */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_11N_RIFS_PROT_ENABLE = 0x0086,
+
+ /* SMPS Mode */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Static Dynamic MIMO (Power Save Disabled) */
+ /* Values to set : 1 2 3 */
+ /* -------------------------------------------------------------- */
+ WID_11N_SMPS_MODE = 0x0087,
+
+ /* Current transmit MCS */
+ /* -------------------------------------------------------------- */
+ /* Configuration : MCS Index for data rate */
+ /* Values to set : 0 to 7 */
+ /* -------------------------------------------------------------- */
+ WID_11N_CURRENT_TX_MCS = 0x0088,
+
+ WID_11N_PRINT_STATS = 0x0089,
+
+ /* 11n Short GI Enable Flag */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Disable Enable */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_11N_SHORT_GI_ENABLE = 0x008D,
+
+ /* 11n RIFS Enable Flag */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Disable Enable */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_RIFS_MODE = 0x0094,
+
+ /* TX Abort Feature */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Disable Self CTS Enable Self CTS */
+ /* Values to set : 0 1 */
+ /* Configuration : Disable TX Abort Enable TX Abort */
+ /* Values to set : 2 3 */
+ /* Configuration : Enable HW TX Abort Enable SW TX Abort */
+ /* Values to set : 4 5 */
+ /* -------------------------------------------------------------- */
+ WID_TX_ABORT_CONFIG = 0x00A1,
+
+ WID_REG_TSSI_11B_VALUE = 0x00A6,
+ WID_REG_TSSI_11G_VALUE = 0x00A7,
+ WID_REG_TSSI_11N_VALUE = 0x00A8,
+ WID_TX_CALIBRATION = 0x00A9,
+ WID_DSCR_TSSI_11B_VALUE = 0x00AA,
+ WID_DSCR_TSSI_11G_VALUE = 0x00AB,
+ WID_DSCR_TSSI_11N_VALUE = 0x00AC,
+
+ /* Immediate Block-Ack Support */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Disable Enable */
+ /* Values to set : 0 1 */
+ /* -------------------------------------------------------------- */
+ WID_11N_IMMEDIATE_BA_ENABLED = 0x00AF,
+
+ /* TXOP Disable Flag */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Disable Enable */
+ /* Values to set : 1 0 */
+ /* -------------------------------------------------------------- */
+ WID_11N_TXOP_PROT_DISABLE = 0x00B0,
+
+
+ WID_TX_POWER_LEVEL_11N = 0x00B1,
+
+ /* Custom Character WID list */
+ WID_PC_TEST_MODE = 0x00C8,
+ /*bug3819: */
+ /* SCAN Complete notification WID*/
+ WID_SCAN_COMPLETE = 0x00C9,
+
+#ifdef WILC_AP_EXTERNAL_MLME
+ WID_DEL_BEACON = 0x00CA,
+#endif
+
+ WID_LOGTerminal_Switch = 0x00CD,
+ /* EMAC Short WID list */
+ /* RTS Threshold */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Any value between 256 to 2347 */
+ /* Values to set : Same value. Default is 2347 */
+ /* -------------------------------------------------------------- */
+ WID_RTS_THRESHOLD = 0x1000,
+
+ /* Fragmentation Threshold */
+ /* -------------------------------------------------------------- */
+ /* Configuration : Any value between 256 to 2346 */
+ /* Values to set : Same value. Default is 2346 */
+ /* -------------------------------------------------------------- */
+ WID_FRAG_THRESHOLD = 0x1001,
+
+ WID_SHORT_RETRY_LIMIT = 0x1002,
+ WID_LONG_RETRY_LIMIT = 0x1003,
+ WID_BEACON_INTERVAL = 0x1006,
+ WID_MEMORY_ACCESS_16BIT = 0x1008,
+ WID_RX_SENSE = 0x100B,
+ WID_ACTIVE_SCAN_TIME = 0x100C,
+ WID_PASSIVE_SCAN_TIME = 0x100D,
+
+ WID_SITE_SURVEY_SCAN_TIME = 0x100E,
+ WID_JOIN_START_TIMEOUT = 0x100F,
+ WID_AUTH_TIMEOUT = 0x1010,
+ WID_ASOC_TIMEOUT = 0x1011,
+ WID_11I_PROTOCOL_TIMEOUT = 0x1012,
+ WID_EAPOL_RESPONSE_TIMEOUT = 0x1013,
+
+ /* NMAC Short WID list */
+ WID_11N_SIG_QUAL_VAL = 0x1085,
+ WID_CCA_THRESHOLD = 0x1087,
+
+ /* Custom Short WID list */
+
+ /* EMAC Integer WID list */
+ WID_FAILED_COUNT = 0x2000,
+ WID_RETRY_COUNT = 0x2001,
+ WID_MULTIPLE_RETRY_COUNT = 0x2002,
+ WID_FRAME_DUPLICATE_COUNT = 0x2003,
+ WID_ACK_FAILURE_COUNT = 0x2004,
+ WID_RECEIVED_FRAGMENT_COUNT = 0x2005,
+ WID_MCAST_RECEIVED_FRAME_COUNT = 0x2006,
+ WID_FCS_ERROR_COUNT = 0x2007,
+ WID_SUCCESS_FRAME_COUNT = 0x2008,
+ WID_HUT_TX_COUNT = 0x200A,
+ WID_TX_FRAGMENT_COUNT = 0x200B,
+ WID_TX_MULTICAST_FRAME_COUNT = 0x200C,
+ WID_RTS_SUCCESS_COUNT = 0x200D,
+ WID_RTS_FAILURE_COUNT = 0x200E,
+ WID_WEP_UNDECRYPTABLE_COUNT = 0x200F,
+ WID_REKEY_PERIOD = 0x2010,
+ WID_REKEY_PACKET_COUNT = 0x2011,
+ WID_1X_SERV_ADDR = 0x2012,
+ WID_STACK_IP_ADDR = 0x2013,
+ WID_STACK_NETMASK_ADDR = 0x2014,
+ WID_HW_RX_COUNT = 0x2015,
+ WID_MEMORY_ADDRESS = 0x201E,
+ WID_MEMORY_ACCESS_32BIT = 0x201F,
+ WID_RF_REG_VAL = 0x2021,
+
+
+ /* NMAC Integer WID list */
+ WID_11N_PHY_ACTIVE_REG_VAL = 0x2080,
+
+ /* Custom Integer WID list */
+ WID_GET_INACTIVE_TIME = 0x2084,
+ WID_SET_DRV_HANDLER = 0X2085,
+ WID_SET_OPERATION_MODE = 0X2086,
+ /* EMAC String WID list */
+ WID_SSID = 0x3000,
+ WID_FIRMWARE_VERSION = 0x3001,
+ WID_OPERATIONAL_RATE_SET = 0x3002,
+ WID_BSSID = 0x3003,
+ WID_WEP_KEY_VALUE = 0x3004,
+ WID_11I_PSK = 0x3008,
+ WID_11E_P_ACTION_REQ = 0x3009,
+ WID_1X_KEY = 0x300A,
+ WID_HARDWARE_VERSION = 0x300B,
+ WID_MAC_ADDR = 0x300C,
+ WID_HUT_DEST_ADDR = 0x300D,
+ WID_PHY_VERSION = 0x300F,
+ WID_SUPP_USERNAME = 0x3010,
+ WID_SUPP_PASSWORD = 0x3011,
+ WID_SITE_SURVEY_RESULTS = 0x3012,
+ WID_RX_POWER_LEVEL = 0x3013,
+ WID_DEL_ALL_RX_BA = 0x3014,
+ WID_SET_STA_MAC_INACTIVE_TIME = 0x3017,
+ WID_ADD_WEP_KEY = 0x3019,
+ WID_REMOVE_WEP_KEY = 0x301A,
+ WID_ADD_PTK = 0x301B,
+ WID_ADD_RX_GTK = 0x301C,
+ WID_ADD_TX_GTK = 0x301D,
+ WID_REMOVE_KEY = 0x301E,
+ WID_ASSOC_REQ_INFO = 0x301F,
+ WID_ASSOC_RES_INFO = 0x3020,
+ WID_MANUFACTURER = 0x3026, /*Added for CAPI tool */
+ WID_MODEL_NAME = 0x3027, /*Added for CAPI tool */
+ WID_MODEL_NUM = 0x3028, /*Added for CAPI tool */
+ WID_DEVICE_NAME = 0x3029, /*Added for CAPI tool */
+
+ /* NMAC String WID list */
+ WID_11N_P_ACTION_REQ = 0x3080,
+ WID_HUT_TEST_ID = 0x3081,
+ WID_PMKID_INFO = 0x3082,
+ WID_FIRMWARE_INFO = 0x3083,
+ #ifdef WILC_P2P
+ WID_REGISTER_FRAME = 0x3084,
+ #endif
+ WID_DEL_ALL_STA = 0x3085,
+ #ifdef WILC_P2P
+ WID_REMAIN_ON_CHAN = 0x3996,
+ #endif
+ /*BugID_4156*/
+ WID_SSID_PROBE_REQ = 0x3997,
+ /*BugID_4124 WID to trigger modified Join Request using SSID and BSSID instead of bssListIdx (used by WID_JOIN_REQ)*/
+ WID_JOIN_REQ_EXTENDED = 0x3998,
+
+ /* BugID 4951: WID toset IP address in firmware */
+ WID_IP_ADDRESS = 0x3999,
+
+
+
+ /* Custom String WID list */
+
+ /* EMAC Binary WID list */
+ WID_UAPSD_CONFIG = 0x4001,
+ WID_UAPSD_STATUS = 0x4002,
+ WID_WMM_AP_AC_PARAMS = 0x4003,
+ WID_WMM_STA_AC_PARAMS = 0x4004,
+ WID_NETWORK_INFO = 0x4005,
+ WID_STA_JOIN_INFO = 0x4006,
+ WID_CONNECTED_STA_LIST = 0x4007,
+
+ /* NMAC Binary WID list */
+ WID_11N_AUTORATE_TABLE = 0x4080,
+
+
+ /*Added here by Amr - BugID 4134*/
+ WID_SCAN_CHANNEL_LIST = 0x4084,
+
+ /*BugID_3746 WID to add IE to be added in next probe request*/
+ WID_INFO_ELEMENT_PROBE = 0x4085,
+ /*BugID_3746 WID to add IE to be added in next associate request*/
+ WID_INFO_ELEMENT_ASSOCIATE = 0x4086,
+ WID_ADD_STA = 0X4087,
+ WID_REMOVE_STA = 0X4088,
+ WID_EDIT_STA = 0X4089,
+ WID_ADD_BEACON = 0x408a,
+
+ /* BugID 5108 */
+ WID_SETUP_MULTICAST_FILTER = 0x408b,
+
+ /* Miscellaneous WIDs */
+ WID_ALL = 0x7FFE,
+ WID_MAX = 0xFFFF
+} WID_T;
+
+int wilc_wlan_init(wilc_wlan_inp_t *inp, wilc_wlan_oup_t *oup);
+
+void wilc_bus_set_max_speed(void);
+void wilc_bus_set_default_speed(void);
+uint32_t wilc_get_chipid(uint8_t update);
+
+
+#endif
diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c
index bd69e8cf200fe9..c0e6ac8a28eb40 100644
--- a/drivers/staging/wlan-ng/p80211conv.c
+++ b/drivers/staging/wlan-ng/p80211conv.c
@@ -207,6 +207,8 @@ int skb_ether_to_p80211(wlandevice_t *wlandev, u32 ethconv,
/* XXXX need to pick keynum other than default? */
p80211_wep->data = kmalloc(skb->len, GFP_ATOMIC);
+ if (!p80211_wep->data)
+ return -ENOMEM;
foo = wep_encrypt(wlandev, skb->data, p80211_wep->data,
skb->len,
(wlandev->hostwep & HOSTWEP_DEFAULTKEY_MASK),
diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index ddb294e7044ff1..0329c521d17c5c 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -428,7 +428,8 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate)
result = hfa384x_drvr_start(hw);
if (result) {
netdev_err(wlandev->netdev,
- "hfa384x_drvr_start() failed,result=%d\n", (int)result);
+ "hfa384x_drvr_start() failed,result=%d\n",
+ (int)result);
result =
P80211ENUM_resultcode_implementation_failure;
wlandev->msdstate = WLAN_MSD_HWPRESENT;
@@ -471,7 +472,8 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate)
result = hfa384x_drvr_start(hw);
if (result) {
netdev_err(wlandev->netdev,
- "hfa384x_drvr_start() failed,result=%d\n", (int)result);
+ "hfa384x_drvr_start() failed,result=%d\n",
+ (int)result);
result =
P80211ENUM_resultcode_implementation_failure;
wlandev->msdstate = WLAN_MSD_HWPRESENT;
@@ -481,7 +483,8 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate)
result = prism2sta_getcardinfo(wlandev);
if (result) {
netdev_err(wlandev->netdev,
- "prism2sta_getcardinfo() failed,result=%d\n", (int)result);
+ "prism2sta_getcardinfo() failed,result=%d\n",
+ (int)result);
result =
P80211ENUM_resultcode_implementation_failure;
hfa384x_drvr_stop(hw);
@@ -491,7 +494,8 @@ u32 prism2sta_ifstate(wlandevice_t *wlandev, u32 ifstate)
result = prism2sta_globalsetup(wlandev);
if (result) {
netdev_err(wlandev->netdev,
- "prism2sta_globalsetup() failed,result=%d\n", (int)result);
+ "prism2sta_globalsetup() failed,result=%d\n",
+ (int)result);
result =
P80211ENUM_resultcode_implementation_failure;
hfa384x_drvr_stop(hw);
@@ -1244,9 +1248,9 @@ void prism2sta_processing_defer(struct work_struct *data)
HFA384x_RID_CURRENTSSID, result);
return;
}
- prism2mgmt_bytestr2pstr((struct hfa384x_bytestr *) &ssid,
- (p80211pstrd_t *) &
- wlandev->ssid);
+ prism2mgmt_bytestr2pstr(
+ (struct hfa384x_bytestr *) &ssid,
+ (p80211pstrd_t *) &wlandev->ssid);
/* Collect the port status */
result = hfa384x_drvr_getconfig16(hw,
@@ -1658,8 +1662,9 @@ static void prism2sta_inf_authreq_defer(wlandevice_t *wlandev,
if (hw->authlist.cnt >= WLAN_AUTH_MAX) {
rec.status = P80211ENUM_status_ap_full;
} else {
- ether_addr_copy(hw->authlist.addr[hw->authlist.cnt],
- rec.address);
+ ether_addr_copy(
+ hw->authlist.addr[hw->authlist.cnt],
+ rec.address);
hw->authlist.cnt++;
added = 1;
}
diff --git a/drivers/staging/xgifb/XGI_main_26.c b/drivers/staging/xgifb/XGI_main_26.c
index 74e88200726ccd..943d463cf1931c 100644
--- a/drivers/staging/xgifb/XGI_main_26.c
+++ b/drivers/staging/xgifb/XGI_main_26.c
@@ -8,10 +8,7 @@
#include <linux/sizes.h>
#include <linux/module.h>
-
-#ifdef CONFIG_MTRR
-#include <asm/mtrr.h>
-#endif
+#include <linux/pci.h>
#include "XGI_main.h"
#include "vb_init.h"
@@ -1770,7 +1767,7 @@ static int xgifb_probe(struct pci_dev *pdev,
}
xgifb_info->video_vbase = hw_info->pjVideoMemoryAddress =
- ioremap(xgifb_info->video_base, xgifb_info->video_size);
+ ioremap_wc(xgifb_info->video_base, xgifb_info->video_size);
xgifb_info->mmio_vbase = ioremap(xgifb_info->mmio_base,
xgifb_info->mmio_size);
@@ -2014,12 +2011,8 @@ static int xgifb_probe(struct pci_dev *pdev,
fb_alloc_cmap(&fb_info->cmap, 256, 0);
-#ifdef CONFIG_MTRR
- xgifb_info->mtrr = mtrr_add(xgifb_info->video_base,
- xgifb_info->video_size, MTRR_TYPE_WRCOMB, 1);
- if (xgifb_info->mtrr >= 0)
- dev_info(&pdev->dev, "Added MTRR\n");
-#endif
+ xgifb_info->mtrr = arch_phys_wc_add(xgifb_info->video_base,
+ xgifb_info->video_size);
if (register_framebuffer(fb_info) < 0) {
ret = -EINVAL;
@@ -2031,11 +2024,7 @@ static int xgifb_probe(struct pci_dev *pdev,
return 0;
error_mtrr:
-#ifdef CONFIG_MTRR
- if (xgifb_info->mtrr >= 0)
- mtrr_del(xgifb_info->mtrr, xgifb_info->video_base,
- xgifb_info->video_size);
-#endif /* CONFIG_MTRR */
+ arch_phys_wc_del(xgifb_info->mtrr);
error_1:
iounmap(xgifb_info->mmio_vbase);
iounmap(xgifb_info->video_vbase);
@@ -2059,11 +2048,7 @@ static void xgifb_remove(struct pci_dev *pdev)
struct fb_info *fb_info = xgifb_info->fb_info;
unregister_framebuffer(fb_info);
-#ifdef CONFIG_MTRR
- if (xgifb_info->mtrr >= 0)
- mtrr_del(xgifb_info->mtrr, xgifb_info->video_base,
- xgifb_info->video_size);
-#endif /* CONFIG_MTRR */
+ arch_phys_wc_del(xgifb_info->mtrr);
iounmap(xgifb_info->mmio_vbase);
iounmap(xgifb_info->video_vbase);
release_mem_region(xgifb_info->mmio_base, xgifb_info->mmio_size);
diff --git a/drivers/staging/xgifb/vb_setmode.c b/drivers/staging/xgifb/vb_setmode.c
index a47395e92d20ae..c886dd2892a486 100644
--- a/drivers/staging/xgifb/vb_setmode.c
+++ b/drivers/staging/xgifb/vb_setmode.c
@@ -940,7 +940,7 @@ static void XGI_SetCRT1FIFO(struct xgi_hw_device_info *HwDeviceExtension,
data = xgifb_reg_get(pVBInfo->P3c4, 0x3D);
data &= 0xfe;
- xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* diable auto-threshold */
+ xgifb_reg_set(pVBInfo->P3c4, 0x3D, data); /* disable auto-threshold */
xgifb_reg_set(pVBInfo->P3c4, 0x08, 0x34);
data = xgifb_reg_get(pVBInfo->P3c4, 0x09);
@@ -1081,24 +1081,17 @@ static void XGI_WriteDAC(unsigned short dl,
unsigned short dh,
struct vb_device_info *pVBInfo)
{
- unsigned short temp, bh, bl;
+ unsigned short bh, bl;
bh = ah;
bl = al;
if (dl != 0) {
- temp = bh;
- bh = dh;
- dh = temp;
- if (dl == 1) {
- temp = bl;
- bl = dh;
- dh = temp;
- } else {
- temp = bl;
- bl = bh;
- bh = temp;
- }
+ swap(bh, dh);
+ if (dl == 1)
+ swap(bl, dh);
+ else
+ swap(bl, bh);
}
outb((unsigned short) dh, pVBInfo->P3c9);
outb((unsigned short) bh, pVBInfo->P3c9);
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c
index 0655fecf824059..0f82c0b146f6d8 100644
--- a/drivers/tty/goldfish.c
+++ b/drivers/tty/goldfish.c
@@ -59,7 +59,7 @@ static void goldfish_tty_do_write(int line, const char *buf, unsigned count)
struct goldfish_tty *qtty = &goldfish_ttys[line];
void __iomem *base = qtty->base;
spin_lock_irqsave(&qtty->lock, irq_flags);
- gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR,
+ gf_write_ptr(buf, base + GOLDFISH_TTY_DATA_PTR,
base + GOLDFISH_TTY_DATA_PTR_HIGH);
writel(count, base + GOLDFISH_TTY_DATA_LEN);
writel(GOLDFISH_TTY_CMD_WRITE_BUFFER, base + GOLDFISH_TTY_CMD);
@@ -81,7 +81,7 @@ static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id)
count = tty_prepare_flip_string(&qtty->port, &buf, count);
spin_lock_irqsave(&qtty->lock, irq_flags);
- gf_write64((u64)buf, base + GOLDFISH_TTY_DATA_PTR,
+ gf_write_ptr(buf, base + GOLDFISH_TTY_DATA_PTR,
base + GOLDFISH_TTY_DATA_PTR_HIGH);
writel(count, base + GOLDFISH_TTY_DATA_LEN);
writel(GOLDFISH_TTY_CMD_READ_BUFFER, base + GOLDFISH_TTY_CMD);
diff --git a/include/linux/goldfish.h b/include/linux/goldfish.h
index 569236e6b2bc99..93e080b39cf6c0 100644
--- a/include/linux/goldfish.h
+++ b/include/linux/goldfish.h
@@ -3,13 +3,24 @@
/* Helpers for Goldfish virtual platform */
-static inline void gf_write64(unsigned long data,
- void __iomem *portl, void __iomem *porth)
+static inline void gf_write_ptr(const void *ptr, void __iomem *portl,
+ void __iomem *porth)
{
- writel((u32)data, portl);
+ writel((u32)(unsigned long)ptr, portl);
#ifdef CONFIG_64BIT
- writel(data>>32, porth);
+ writel((unsigned long)ptr >> 32, porth);
#endif
}
+static inline void gf_write_dma_addr(const dma_addr_t addr,
+ void __iomem *portl,
+ void __iomem *porth)
+{
+ writel((u32)addr, portl);
+#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
+ writel(addr >> 32, porth);
+#endif
+}
+
+
#endif /* __LINUX_GOLDFISH_H */
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index d86b753e9b3016..f79148261d16c3 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -32,6 +32,7 @@ enum iio_chan_info_enum {
IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW,
IIO_CHAN_INFO_AVERAGE_RAW,
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY,
+ IIO_CHAN_INFO_HIGH_PASS_FILTER_3DB_FREQUENCY,
IIO_CHAN_INFO_SAMP_FREQ,
IIO_CHAN_INFO_FREQUENCY,
IIO_CHAN_INFO_PHASE,
@@ -43,6 +44,8 @@ enum iio_chan_info_enum {
IIO_CHAN_INFO_CALIBWEIGHT,
IIO_CHAN_INFO_DEBOUNCE_COUNT,
IIO_CHAN_INFO_DEBOUNCE_TIME,
+ IIO_CHAN_INFO_CALIBEMISSIVITY,
+ IIO_CHAN_INFO_OVERSAMPLING_RATIO,
};
enum iio_shared_by {
diff --git a/include/linux/iio/types.h b/include/linux/iio/types.h
index 942b6de68e2f38..32b57952500449 100644
--- a/include/linux/iio/types.h
+++ b/include/linux/iio/types.h
@@ -17,6 +17,8 @@ enum iio_event_info {
IIO_EV_INFO_VALUE,
IIO_EV_INFO_HYSTERESIS,
IIO_EV_INFO_PERIOD,
+ IIO_EV_INFO_HIGH_PASS_FILTER_3DB,
+ IIO_EV_INFO_LOW_PASS_FILTER_3DB,
};
#define IIO_VAL_INT 1
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index 5c460193500544..2f8b11722204dc 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -70,6 +70,8 @@ enum iio_modifier {
IIO_MOD_WALKING,
IIO_MOD_STILL,
IIO_MOD_ROOT_SUM_SQUARED_X_Y_Z,
+ IIO_MOD_I,
+ IIO_MOD_Q,
};
enum iio_event_type {
diff --git a/tools/Makefile b/tools/Makefile
index b35102721cbbc8..291a1a7424d8e9 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -13,6 +13,7 @@ help:
@echo ' cpupower - a tool for all things x86 CPU power'
@echo ' firewire - the userspace part of nosy, an IEEE-1394 traffic sniffer'
@echo ' hv - tools used when in Hyper-V clients'
+ @echo ' iio - IIO tools'
@echo ' lguest - a minimal 32-bit x86 hypervisor'
@echo ' perf - Linux performance measurement and analysis tool'
@echo ' selftests - various kernel selftests'
@@ -46,7 +47,7 @@ acpi: FORCE
cpupower: FORCE
$(call descend,power/$@)
-cgroup firewire hv guest usb virtio vm net: FORCE
+cgroup firewire hv guest usb virtio vm net iio: FORCE
$(call descend,$@)
liblockdep: FORCE
@@ -101,7 +102,7 @@ acpi_clean:
cpupower_clean:
$(call descend,power/cpupower,clean)
-cgroup_clean hv_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean:
+cgroup_clean hv_clean firewire_clean lguest_clean usb_clean virtio_clean vm_clean net_clean iio_clean:
$(call descend,$(@:_clean=),clean)
liblockdep_clean:
@@ -124,6 +125,6 @@ tmon_clean:
clean: acpi_clean cgroup_clean cpupower_clean hv_clean firewire_clean lguest_clean \
perf_clean selftests_clean turbostat_clean usb_clean virtio_clean \
- vm_clean net_clean x86_energy_perf_policy_clean tmon_clean
+ vm_clean net_clean iio_clean x86_energy_perf_policy_clean tmon_clean
.PHONY: FORCE
diff --git a/tools/iio/Makefile b/tools/iio/Makefile
index bf7ae6d6612a1b..3a7a54f5971380 100644
--- a/tools/iio/Makefile
+++ b/tools/iio/Makefile
@@ -1,5 +1,5 @@
-CC = gcc
-CFLAGS = -Wall -g -D_GNU_SOURCE
+CC = $(CROSS_COMPILE)gcc
+CFLAGS += -Wall -g -D_GNU_SOURCE
all: iio_event_monitor lsiio generic_buffer