firefly-linux-kernel-4.4.55.git
9 years agoNFC: nci: Add support for different NCI_DEACTIVATE_TYPE
Christophe Ricard [Tue, 2 Dec 2014 20:27:49 +0000 (21:27 +0100)]
NFC: nci: Add support for different NCI_DEACTIVATE_TYPE

nci_rf_deactivate_req only support NCI_DEACTIVATE_TYPE_IDLE_MODE.
In some situation, it might be necessary to be able to support other
NCI_DEACTIVATE_TYPE such as NCI_DEACTIVATE_TYPE_SLEEP_MODE in order for
example to reactivate the selected target.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: nci: Add management for NCI state for machine rf_deactivate_ntf
Christophe Ricard [Tue, 2 Dec 2014 20:27:48 +0000 (21:27 +0100)]
NFC: nci: Add management for NCI state for machine rf_deactivate_ntf

A notification for rf deaction can be IDLE_MODE, SLEEP_MODE,
SLEEP_AF_MODE and DISCOVERY. According to each type and the NCI
state machine is different (see figure 10 RF Communication State
Machine in NCI specification)

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: nci: Add status byte management in case of error.
Christophe Ricard [Tue, 2 Dec 2014 20:27:47 +0000 (21:27 +0100)]
NFC: nci: Add status byte management in case of error.

The nci status byte was ignored. In case of tag reading for example,
if the tag is removed from the antenna there is no way for the upper
layers (aka: stack) to get inform about such event.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: st21nfcb: Remove useless pr_info
Christophe Ricard [Tue, 2 Dec 2014 20:27:46 +0000 (21:27 +0100)]
NFC: st21nfcb: Remove useless pr_info

- pr_info in st21nfcb_nci_i2c_disable is not necessary

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: hci: Add support for NOTIFY_ALL_PIPE_CLEARED
Christophe Ricard [Wed, 12 Nov 2014 23:30:43 +0000 (00:30 +0100)]
NFC: hci: Add support for NOTIFY_ALL_PIPE_CLEARED

When switching from UICC to another, the CLF may signals to the Terminal
Host that some existing pipe are cleared for future update.

This notification needs to be "acked" by the Terminal Host with a ANY_OK
message.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: hci: Add open pipe command handler
Christophe Ricard [Wed, 12 Nov 2014 23:30:42 +0000 (00:30 +0100)]
NFC: hci: Add open pipe command handler

If our terminal connect with other host like UICC, it may create
a pipe with us, the host controller will notify us new pipe
created, after that UICC will open that pipe, if we don't handle
that request, UICC may failed to continue initialize which may
lead to card emulation feature failed to work

Signed-off-by: Arron Wang <arron.wang@intel.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: st21nfcb: Improve ndlc comment
Christophe Ricard [Wed, 12 Nov 2014 23:30:40 +0000 (00:30 +0100)]
NFC: st21nfcb: Improve ndlc comment

In ndlc_probe function we initialize timers. They are not started.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: st21nfca: Rework st21nfca_hci_event_received to route event to relevent gate.
Christophe Ricard [Wed, 12 Nov 2014 23:30:39 +0000 (00:30 +0100)]
NFC: st21nfca: Rework st21nfca_hci_event_received to route event to relevent gate.

As many event with the same id can come from several gates,
it will be easier to manage each of them by gate.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: nci: Add se_io NCI operand
Christophe Ricard [Wed, 12 Nov 2014 23:30:38 +0000 (00:30 +0100)]
NFC: nci: Add se_io NCI operand

se_io allows to send apdu over the CLF to the embedded Secure Element.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: nci: Update nci_disable_se to run proprietary commands to disable a secure element
Christophe Ricard [Wed, 12 Nov 2014 23:30:37 +0000 (00:30 +0100)]
NFC: nci: Update nci_disable_se to run proprietary commands to disable a secure element

Some NFC controller using NCI protocols may need a proprietary commands
flow to disable a secure element

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: nci: Update nci_enable_se to run proprietary commands to enable a secure element
Christophe Ricard [Wed, 12 Nov 2014 23:30:36 +0000 (00:30 +0100)]
NFC: nci: Update nci_enable_se to run proprietary commands to enable a secure element

Some NFC controller using NCI protocols may need a proprietary commands
flow to enable a secure element

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: nci: Update nci_discover_se to run proprietary commands to discover all availabl...
Christophe Ricard [Wed, 12 Nov 2014 23:30:35 +0000 (00:30 +0100)]
NFC: nci: Update nci_discover_se to run proprietary commands to discover all available secure element

Some NFC controller using NCI protocols may need a proprietary commands
flow to discover all available secure element

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: nci: Fix sparse: symbol 'nci_get_prop_rf_protocol' was not declared.
Christophe Ricard [Wed, 12 Nov 2014 23:30:32 +0000 (00:30 +0100)]
NFC: nci: Fix sparse: symbol 'nci_get_prop_rf_protocol' was not declared.

Fix sparse warning introduced by commit: 9e87f9a9c4c4754508b2c2638fbde9e10c7a103b

It was generating the following warning:
net/nfc/nci/ntf.c:170:7: sparse: symbol 'nci_get_prop_rf_protocol' was not declared. Should it be static?

Procedure to reproduce it:
# apt-get install sparse
  git checkout 9e87f9a9c4c4754508b2c2638fbde9e10c7a103b
  make ARCH=x86_64 allmodconfig
  make C=1 CF=-D__CHECK_ENDIAN__

Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: hci: Add se_io HCI operand
Christophe Ricard [Wed, 12 Nov 2014 23:30:34 +0000 (00:30 +0100)]
NFC: hci: Add se_io HCI operand

se_io allows to send apdu over the CLF to the embedded Secure Element.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: st21nfcb: Remove gpio_irq field in static and dts configuration
Christophe Ricard [Wed, 12 Nov 2014 23:30:26 +0000 (00:30 +0100)]
NFC: st21nfcb: Remove gpio_irq field in static and dts configuration

- phy->gpio_irq is never done out of the request resources.
- irq_of_parse_and_map is already done in the i2c core so client->irq is
already set when entering in st21nfcb_hci_i2c_of_request_resources
- In case of static platform configuration client->irq can be set directly.
- It simplifies the code a bit.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: st21nfcb: Add of_st21nfcb_i2c_match to MODULE_DEVICE_TABLE
Christophe Ricard [Wed, 12 Nov 2014 23:30:25 +0000 (00:30 +0100)]
NFC: st21nfcb: Add of_st21nfcb_i2c_match to MODULE_DEVICE_TABLE

When CONFIG_OF is define add of_st21nfcb_i2c_match to
MODULE_DEVICE_TABLE

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: st21nfca: Remove gpio_irq field in static and dts configuration
Christophe Ricard [Wed, 12 Nov 2014 23:30:23 +0000 (00:30 +0100)]
NFC: st21nfca: Remove gpio_irq field in static and dts configuration

- phy->gpio_irq is never done out of the request resources.
- irq_of_parse_and_map is already done in the i2c core so client->irq is
already set when entering in st21nfca_hci_i2c_of_request_resources
- In case of static platform configuration client->irq can be set directly
- It simplifies the code a bit.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: st21nfca: Add of_st21nfca_i2c_match to MODULE_DEVICE_TABLE
Christophe Ricard [Wed, 12 Nov 2014 23:30:22 +0000 (00:30 +0100)]
NFC: st21nfca: Add of_st21nfca_i2c_match to MODULE_DEVICE_TABLE

When CONFIG_OF is define add of_st21nfca_i2c_match to
MODULE_DEVICE_TABLE.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: NCI: Signal deactivation in Target mode
Julien Lefrique [Tue, 21 Oct 2014 14:52:53 +0000 (16:52 +0200)]
NFC: NCI: Signal deactivation in Target mode

Before signaling the deactivation, send a deactivation request if in
RFST_DISCOVERY state because neard assumes polling is stopped and will
try to restart it.

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: NCI: Handle Discovery deactivation type
Julien Lefrique [Tue, 21 Oct 2014 14:52:52 +0000 (16:52 +0200)]
NFC: NCI: Handle Discovery deactivation type

When the deactivation type reported by RF_DEACTIVATE_NTF is Discovery, go in
RFST_DISCOVERY state. The NFCC stays in Poll mode and/or Listen mode.

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: Fix a memory leak
Julien Lefrique [Tue, 21 Oct 2014 14:52:50 +0000 (16:52 +0200)]
NFC: Fix a memory leak

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: NCI: Forward data received in Target mode to nfc core
Julien Lefrique [Tue, 21 Oct 2014 14:52:49 +0000 (16:52 +0200)]
NFC: NCI: Forward data received in Target mode to nfc core

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: NCI: Implement Target mode send function
Julien Lefrique [Tue, 21 Oct 2014 14:52:48 +0000 (16:52 +0200)]
NFC: NCI: Implement Target mode send function

As specified in NCI 1.0 and NCI 1.1, when using the NFC-DEP RF Interface, the
DH and the NFCC shall only use the Static RF Connection for data communication
with a Remote NFC Endpoint.

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: NCI: Configure ATR_RES general bytes
Julien Lefrique [Tue, 21 Oct 2014 14:52:47 +0000 (16:52 +0200)]
NFC: NCI: Configure ATR_RES general bytes

The Target responds to the ATR_REQ with the ATR_RES. Configure the General
Bytes in ATR_RES with the first three octets equal to the NFC Forum LLCP
magic number, followed by some LLC Parameters TLVs described in section
4.5 of [LLCP].

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: NCI: Handle Target mode activation
Julien Lefrique [Tue, 21 Oct 2014 14:52:46 +0000 (16:52 +0200)]
NFC: NCI: Handle Target mode activation

Changes:

 * Extract the Listen mode activation parameters from RF_INTF_ACTIVATED_NTF.

 * Store the General Bytes of ATR_REQ.

 * Signal that Target mode is activated in case of an activation in NFC-DEP.

 * Update the NCI state accordingly.

 * Use the various constants defined in nfc.h.

 * Fix the ATR_REQ and ATR_RES maximum size. As per NCI 1.0 and NCI 1.1, the
   Activation Parameters for both Poll and Listen mode contain all the bytes of
   ATR_REQ/ATR_RES starting and including Byte 3 as defined in [DIGITAL].
   In [DIGITAL], the maximum size of ATR_REQ/ATR_RES is 64 bytes and they are
   numbered starting from Byte 1.

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: NCI: Enable NFC-DEP in Listen A and Listen F
Julien Lefrique [Tue, 21 Oct 2014 14:52:45 +0000 (16:52 +0200)]
NFC: NCI: Enable NFC-DEP in Listen A and Listen F

Send LA_SEL_INFO and LF_PROTOCOL_TYPE with NFC-DEP protocol enabled.
Configure 212 Kbit/s and 412 Kbit/s bit rates for Listen F.

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: NCI: Add passive Listen modes in discover request
Julien Lefrique [Tue, 21 Oct 2014 14:52:44 +0000 (16:52 +0200)]
NFC: NCI: Add passive Listen modes in discover request

The Target mode protocols are given to the nci_start_poll() function
but were previously ignored.
To enable P2P Target, when NFC-DEP is requested as a Target mode protocol, add
NFC-A and NFC-F Passive Listen modes in RF_DISCOVER_CMD command.

Signed-off-by: Julien Lefrique <lefrique@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: llcp: Use list_for_each_entry in llcp_accept_poll
Axel Lin [Thu, 6 Nov 2014 10:20:41 +0000 (18:20 +0800)]
NFC: llcp: Use list_for_each_entry in llcp_accept_poll

list_for_each_entry_safe() is necessary if list objects are deleted from
the list while traversing it. Not the case here, so we can use the base
list_for_each_entry variant.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: Don't include linux/unaligned/access_ok.h
Johannes Berg [Wed, 19 Nov 2014 20:17:22 +0000 (21:17 +0100)]
NFC: Don't include linux/unaligned/access_ok.h

This is a specific implementation, <asm/unaligned.h> is the
multiplexer that has the arch-specific knowledge of which
of the implementations needs to be used, so include that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Add NFC-DEP Target-side ATN Support
Mark A. Greer [Tue, 23 Sep 2014 23:38:14 +0000 (16:38 -0700)]
NFC: digital: Add NFC-DEP Target-side ATN Support

When an NFC-DEP target receives an ATN PDU, its
supposed to respond with a similar ATN PDU.
When the Target receives an I PDU with the PNI
one less than the current PNI and the last PDU
sent was an ATN PDU, the Target is to resend the
last non-ATN PDU that it has sent.  This is
described in section 14.12.3.4 of the NFC Digital
Protocol Spec.

The digital layer's NFC-DEP code doesn't implement
this so add that support.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Add NFC-DEP Initiator-side ATN Support
Mark A. Greer [Tue, 23 Sep 2014 23:38:13 +0000 (16:38 -0700)]
NFC: digital: Add NFC-DEP Initiator-side ATN Support

When an NFC-DEP Initiator times out when waiting for
a DEP_RES from the Target, its supposed to send an
ATN to the Target.  The Target should respond to the
ATN with a similar ATN PDU and the Initiator can then
resend the last non-ATN PDU that it sent.  No more
than 'N(retry,atn)' are to be send where
2 <= 'N(retry,atn)' <= 5.  If the Initiator had just
sent a NACK PDU when the timeout occurred, it is to
continue sending NACKs until 'N(retry,nack)' NACKs
have been send.  This is described in section
14.12.5.6 of the NFC-DEP Digital Protocol Spec.

The digital layer's NFC-DEP code doesn't implement
this so add that support.

The value chosen for 'N(retry,atn)' is 2.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Add NFC-DEP Target-side NACK Support
Mark A. Greer [Tue, 23 Sep 2014 23:38:12 +0000 (16:38 -0700)]
NFC: digital: Add NFC-DEP Target-side NACK Support

When an NFC-DEP Target receives a NACK PDU with
a PNI equal to 1 less than the current PNI, it
is supposed to re-send the last PDU.  This is
implied in section 14.12.5.4 of the NFC Digital
Protocol Spec.

The digital layer's NFC-DEP code doesn't implement
Target-side NACK handing so add it.  The last PDU
that was sent is saved in the 'nfc_digital_dev'
structure's 'saved_skb' member.  The skb will have
an additional reference taken to ensure that the skb
isn't freed when the driver performs a kfree_skb()
on the skb.  The length of the skb/PDU is also saved
so the length can be restored when re-sending the PDU
in the skb (the driver will perform an skb_pull() so
an skb_push() needs to be done to restore the skb's
data pointer/length).

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Add NFC-DEP Initiator-side NACK Support
Mark A. Greer [Tue, 23 Sep 2014 23:38:11 +0000 (16:38 -0700)]
NFC: digital: Add NFC-DEP Initiator-side NACK Support

When an NFC-DEP Initiator receives a frame with
an incorrect CRC or with a parity error, and the
frame is at least 4 bytes long, its supposed to
send a NACK to the Target.  The Initiator can
send up to 'N(retry,nack)' consecutive NACKs
where 2 <= 'N(retry,nack)' <= 5.  When the limit
is exceeded, a PROTOCOL EXCEPTION is raised.
Any other type of transmission error is to be
ignored and the Initiator should continue
waiting for a new frame.  This is described
in section 14.12.5.4 of the NFC Digital Protocol
Spec.

The digital layer's NFC-DEP code doesn't implement
any of this so add it.  This support diverges from
the spec in two significant ways:

a) NACKs will be sent for ANY error reported by the
   driver except a timeout.  This is done because
   there is currently no way for the digital layer
   to distinguish a CRC or parity error from any
   other type of error reported by the driver.

b) All other errors will cause a PROTOCOL EXCEPTION
   even frames with CRC errors that are less than 4
   bytes.

The value chosen for 'N(retry,nack)' is 2.

Targets do not send NACK PDUs.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Add NFC-DEP Receive Chaining Support
Mark A. Greer [Tue, 23 Sep 2014 23:38:10 +0000 (16:38 -0700)]
NFC: digital: Add NFC-DEP Receive Chaining Support

When the peer in an NFC-DEP exchange has a
packet to send that is larger than the local
maximum payload, it sets the 'MI' bit in the
'I' PDU.  This indicates that NFC-DEP chaining
is to occur.

When such a PDU is received, the local side
responds with an 'ACK' PDU and this continues
until the peer sends an 'I' PDU with the 'MI'
bit cleared.  This indicates that the chaining
sequence is complete and the entire packet has
been transferred.

Receiving chained PDUs is currently not supported
by the digital layer so add that support.  When a
chaining sequence is initiated by the peer, the
digital layer will allocate an skb large enough
to hold 8 maximum sized frame payloads.  The maximum
payload can range from 64 to 254 bytes so 8 * 254 =
2032 seems like a reasonable compromise between
potentially wasting memory and constantly reallocating
new, larger skbs.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Add NFC-DEP Send Chaining Support
Mark A. Greer [Tue, 23 Sep 2014 23:38:09 +0000 (16:38 -0700)]
NFC: digital: Add NFC-DEP Send Chaining Support

When the NFC-DEP code is given a packet to send
that is larger than the peer's maximum payload,
its supposed to set the 'MI' bit in the 'I' PDU's
Protocol Frame Byte (PFB).  Setting this bit
indicates that NFC-DEP chaining is to occur.

When NFC-DEP chaining is progress, sender 'I' PDUs
are acknowledged with 'ACK' PDUs until the last 'I'
PDU in the chain (which has the 'MI' bit cleared)
is responded to with a normal 'I' PDU.  This can
occur while in Initiator mode or in Target mode.

Sender NFC-DEP chaining is currently not implemented
in the digital layer so add that support.  Unfortunately,
since sending a frame may require writing the CRC to the
end of the data, the relevant data part of the original
skb must be copied for each intermediate frame.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Implement NFC-DEP max payload lengths
Mark A. Greer [Tue, 23 Sep 2014 23:38:08 +0000 (16:38 -0700)]
NFC: digital: Implement NFC-DEP max payload lengths

The maximum payload for NFC-DEP exchanges (i.e., the
number of bytes between SoD and EoD) is negotiated
using the ATR_REQ, ATR_RES, and PSL_REQ commands.
The valid maximum lengths are 64, 128, 192, and 254
bytes.

Currently, NFC-DEP code assumes that both sides are
always using 254 byte maximums and ignores attempts
by the peer to change it.  Instead, implement the
negotiation code, enforce the local maximum when
receiving data from the peer, and don't send payloads
that exceed the remote's maximum.  The default local
maximum is 254 bytes.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Enforce NFC-DEP PNI sequencing
Mark A. Greer [Tue, 23 Sep 2014 23:38:07 +0000 (16:38 -0700)]
NFC: digital: Enforce NFC-DEP PNI sequencing

NFC-DEP DEP_REQ and DEP_RES exchanges using 'I'
and 'ACK/NACK' PDUs have a sequence number called
the Packet Number Information (PNI).  The PNI
is incremented (modulo 4) after every DEP_REQ/
DEP_RES pair and should be verified by the digital
layer code.  That verification isn't always done,
though, so add code to make sure that it is done.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Ensure no NAD byte in DEP_REQ and DEP_RES frames
Mark A. Greer [Tue, 23 Sep 2014 23:38:06 +0000 (16:38 -0700)]
NFC: digital: Ensure no NAD byte in DEP_REQ and DEP_RES frames

According to chapter 14 of the NFC-DEP Digital
Protocol Spec., the NAD byte should never be
present in DEP_REQ or DEP_RES frames.  However,
this is not enforced so add that enforcement code.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Add Target-mode NFC-DEP DID Support
Mark A. Greer [Tue, 23 Sep 2014 23:38:05 +0000 (16:38 -0700)]
NFC: digital: Add Target-mode NFC-DEP DID Support

When in Target mode, the Initiator specifies whether
subsequent DEP_REQ and DEP_RES frames will include
a DID byte by the value passed in the ATR_REQ.  If
the DID value in the ATR_REQ is '0' then no DID
byte will be included.  If the DID value is between
'1' and '14' then a DID byte containing the same
value must be included in subsequent DEP_REQ and
DEP_RES frames.  Any other DID value is invalid.
This is specified in sections 14.8.1.2 and 14.8.2.2
of the NFC Digital Protocol Spec.

Checking the DID value (if it should be there at all),
is not currently supported by the digital layer's
NFC-DEP code.  Add this support by remembering the
DID value in the ATR_REQ, checking the DID value of
received DEP_REQ frames (if it should be there at all),
and including the remembered DID value in DEP_RES
frames when appropriate.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Ensure no DID in NFC-DEP responses
Mark A. Greer [Tue, 23 Sep 2014 23:38:04 +0000 (16:38 -0700)]
NFC: digital: Ensure no DID in NFC-DEP responses

When in Initiator mode, the digital layer's
NFC-DEP code always sets the Device ID (DID)
value in the ATR_REQ to '0'.  This means that
subsequent DEP_REQ and DEP_RES frames must
never include a DID byte.  This is specified
in sections 14.8.1.1 and 14.8.2.1 of the NFC
Digital Protocol Spec.

Currently, the digital layer's NFC-DEP code
doesn't enforce this rule so add code to ensure
that there is no DID byte in DEP_RES frames.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Rearrange NFC-DEP DEP_REQ/DEP_RES Code
Mark A. Greer [Tue, 23 Sep 2014 23:38:03 +0000 (16:38 -0700)]
NFC: digital: Rearrange NFC-DEP DEP_REQ/DEP_RES Code

Rearrange some of the code in digital_in_recv_dep_res()
and digital_tg_recv_dep_req() so the initial code looks
similar.  The real reason is prepare the code for some
upcoming patches that require these changes.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agoNFC: digital: Fix potential skb leaks in NFC-DEP code
Mark A. Greer [Tue, 23 Sep 2014 23:38:02 +0000 (16:38 -0700)]
NFC: digital: Fix potential skb leaks in NFC-DEP code

When digital_in_send_cmd() or digital_tg_send_cmd()
fail, they do not free the skb that was passed to
them so the routine that allocated the skb should
free it.  Currently, there are several routines in
the NFC-DEP code that don't do this so make them.

Reviewed-by: Thierry Escande <thierry.escande@linux.intel.com>
Tested-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Mark A. Greer <mgreer@animalcreek.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
9 years agomwifiex: add Tx status support for ACTION frames
Amitkumar Karwar [Tue, 25 Nov 2014 14:43:06 +0000 (06:43 -0800)]
mwifiex: add Tx status support for ACTION frames

ACK status (0/1) for ACTION frames is informed to cfg80211. We
will extend existing logic used for EAPOL frames. The cfg80211
API is different here. Also, we need to explicitly free cloned
skb.

Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agomwifiex: add Tx status support for EAPOL packets
Amitkumar Karwar [Tue, 25 Nov 2014 14:43:05 +0000 (06:43 -0800)]
mwifiex: add Tx status support for EAPOL packets

Firmware notifies the driver through event if EAPOL data packet
has been acked or not. We will inform this status to userspace
listening on a socket.

Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agomwifiex: skip delay main work logic for USB interface.
Amitkumar Karwar [Tue, 25 Nov 2014 14:43:04 +0000 (06:43 -0800)]
mwifiex: skip delay main work logic for USB interface.

We had introduced delay main work logic to avoid processing
interrupts when Rx pending packet count reaches high threshold.
interrupt processing is restarted later when packet count
reduces lower threashold. This helped to reduce unnecessary
overhead and improve throughput for SD and PCIe chipsets.

As there are no interrupts for USB, we will skip this logic for
USB chipsets.

Signed-off-by: Cathy Luo <cluo@marvell.com>
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agomwifiex: fix scan problem on big endian platforms
Amitkumar Karwar [Tue, 25 Nov 2014 14:43:03 +0000 (06:43 -0800)]
mwifiex: fix scan problem on big endian platforms

This patch adds missing endian conversion for beacon size while
processing scan response.

Reported-by: Daniel Mosquera <daniel.mosquera@ctag.com>
Tested-by: Daniel Mosquera <daniel.mosquera@ctag.com>
Signed-off-by: Avinash Patil <patila@marvell.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agomwifiex: fix sparse warning
Amitkumar Karwar [Tue, 25 Nov 2014 14:43:02 +0000 (06:43 -0800)]
mwifiex: fix sparse warning

This patch fixes following sparse warnings:

drivers/net/wireless/mwifiex/util.c:152:19: warning: cast from restricted __le16
drivers/net/wireless/mwifiex/util.c:152:19: warning: restricted __le16 degrades to integer

Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agoath9k: add TPC capability to TX descriptor path
Lorenzo Bianconi [Mon, 24 Nov 2014 23:21:41 +0000 (00:21 +0100)]
ath9k: add TPC capability to TX descriptor path

Add TPC capability to TX descriptor path. Cap per-packet TX power according to
TX power per-rate tables. Currently TPC is supported just by AR9003 based chips

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agoath9k: add TX power per-rate tables
Lorenzo Bianconi [Mon, 24 Nov 2014 23:21:40 +0000 (00:21 +0100)]
ath9k: add TX power per-rate tables

Add TX power per-rate tables for different MIMO modes (e.g STBC) in order to
cap the maximum TX power value per-rate in the TX descriptor path.
Cap TX power for self generated frames (ACK, RTS/CTS).
Currently TPC is supported just by AR9003 based chips

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agobrcmfmac: correct .disconnect() callback while connecting
Arend van Spriel [Thu, 20 Nov 2014 21:27:02 +0000 (22:27 +0100)]
brcmfmac: correct .disconnect() callback while connecting

When the driver has sent a join iovar to the firmware it waits
for the events to report result of the connection. However, the
wpa_supplicant will request a .disconnect() after a timeout. So
upon calling .disconnect() the interface state may still be
CONNECTING. Clear the CONNECTING bit as well.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agonet: wireless: rtlwifi: rtl8192ee: Fix compilation of the driver
Andreas Ruprecht [Mon, 24 Nov 2014 18:34:32 +0000 (19:34 +0100)]
net: wireless: rtlwifi: rtl8192ee: Fix compilation of the driver

In the Makefile for this driver, the wrong Kconfig option is used
to trigger the compilation of the object file. This leads to the
driver only being included into the kernel when both CONFIG_RTL8821AE
and CONFIG_RTL8192AE are set to "y".

Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agonet: wireless: rtlwifi: Do not always include drivers in obj-m
Andreas Ruprecht [Mon, 24 Nov 2014 18:34:31 +0000 (19:34 +0100)]
net: wireless: rtlwifi: Do not always include drivers in obj-m

In four of the rtlwifi drivers, the Makefile contains superfluous
statements indicating the compilation of the driver as an LKM
regardless of the corresponding Kconfig option.

If the corresponding option is set to 'y', the build system will then
see the object file in obj-m and obj-y, which leads to a compilation
as a built-in only. Even though this leads to the desired behavior,
the unconditional appearance in obj-m is confusing for someone reading
the Makefile.

This patch removes the superfluous Makefile statements.

Signed-off-by: Andreas Ruprecht <rupran@einserver.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agoath: Fix a false radar detection pattern
Vivek Natarajan [Mon, 24 Nov 2014 11:56:22 +0000 (17:26 +0530)]
ath: Fix a false radar detection pattern

For FCC and JP, in one of the radar patterns, PPB and PRF seems to be
interchanged leading to frequent incorrect radar detections.

Signed-off-by: Vivek Natarajan <nataraja@qti.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agowireless/p54: Remove duplicated net2280 header
Ricardo Ribalda Delgado [Mon, 24 Nov 2014 10:19:51 +0000 (11:19 +0100)]
wireless/p54: Remove duplicated net2280 header

The usb gadget driver net2280 has exported a header file with the
register definition of the net2280 chip.

Remove the custom/duplicated header file in favor of that header file
in include/linux

Signed-off-by: Ricardo Ribalda Delgado <ricardo.ribalda@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agortlwifi: update RCR register in rtl_op_configure_filter()
Lorenzo Bianconi [Sat, 22 Nov 2014 11:18:26 +0000 (12:18 +0100)]
rtlwifi: update RCR register in rtl_op_configure_filter()

Reconfigure RCR register in rtl_op_configure_filter() in order to apply RX
filter configuration

Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agobrcmfmac: fix static checker warning in pmklist handling
Arend van Spriel [Thu, 20 Nov 2014 21:26:59 +0000 (22:26 +0100)]
brcmfmac: fix static checker warning in pmklist handling

The patch fixes a static checker warning:

   drivers/net/wireless/brcm80211/brcmfmac/cfg80211.c:2965
      brcmf_cfg80211_set_pmksa()
warn: can 'pmkid_len' be negative?

The answer to the question above is likely no so changing its
type to unsigned is sufficient.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: Daniel (Deognyoun) Kim <dekim@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agoMerge tag 'iwlwifi-next-for-john-2014-11-24' of git://git.kernel.org/pub/scm/linux...
John W. Linville [Mon, 24 Nov 2014 18:59:37 +0000 (13:59 -0500)]
Merge tag 'iwlwifi-next-for-john-2014-11-24' of git://git./linux/kernel/git/iwlwifi/iwlwifi-next

Emmanuel Grumbach <egrumbach@gmail.com> says:

"Major works are CSA and TDLS. On top of that I have a new
firmware API for scan and a few rate control improvements.
Johannes find a few tricks to improve our CPU utilization
and adds support for a new spin of 7265 called 7265D.
Along with this a few random things that don't stand out."

Signed-off-by: John W. Linville <linville@tuxdriver.com>
9 years agoiwlwifi: update the secure mem space and for the CPUs
Emmanuel Grumbach [Sun, 23 Nov 2014 19:39:50 +0000 (21:39 +0200)]
iwlwifi: update the secure mem space and for the CPUs

Also update the timeout for the data verification.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: sdio: new SDIO card id for 4165 series
Oren Givon [Tue, 14 Oct 2014 08:26:52 +0000 (11:26 +0300)]
iwlwifi: sdio: new SDIO card id for 4165 series

Add a new SDIO card id intended for the new 4165 series.

Signed-off-by: Oren Givon <oren.givon@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: declare d0i3 support for IWL_DEVICE_8000
Eliad Peller [Wed, 25 Jun 2014 15:09:58 +0000 (18:09 +0300)]
iwlwifi: declare d0i3 support for IWL_DEVICE_8000

Signed-off-by: Eliad Peller <eliadx.peller@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: disconnect TDLS peers before channel switch
Arik Nemtsov [Sun, 14 Sep 2014 16:13:54 +0000 (19:13 +0300)]
iwlwifi: mvm: disconnect TDLS peers before channel switch

In case of channel switch, we need to teardown the TDLS peers.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: declare support for VHT BF info in radiotap
Eyal Shapira [Tue, 18 Nov 2014 14:43:55 +0000 (16:43 +0200)]
iwlwifi: mvm: declare support for VHT BF info in radiotap

The driver knows whether an rx frame was beamformed and marks
it in the radiotap VHT flags. However it should also declare
that it knows to extract this info otherwise this gets discarded
by sniffers like Wireshark.

Signed-off-by: Eyal Shapira <eyalx.shapira@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: add support to MFUART loading notification
Chaya Rachel Ivgy [Sat, 15 Nov 2014 19:08:29 +0000 (21:08 +0200)]
iwlwifi: mvm: add support to MFUART loading notification

Add support to MFUART loading notification (print notification
data with IWL_DEBUG_INFO)

Signed-off-by: Chaya Rachel Ivgy <chaya.rachel.ivgi@intel.com>
Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: call iwl_trans_suspend/resume
Eliad Peller [Tue, 30 Sep 2014 07:02:13 +0000 (10:02 +0300)]
iwlwifi: mvm: call iwl_trans_suspend/resume

call the appropriate iwl_trans_suspend/resume ops
on iwl_mvm_suspend/resume calls.

Signed-off-by: Eliad Peller <eliadx.peller@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: trans: add suspend/resume ops
Eliad Peller [Wed, 1 Oct 2014 12:21:28 +0000 (15:21 +0300)]
iwlwifi: trans: add suspend/resume ops

Add suspend/resume trans ops that will be called from
mac80211's suspend/resume ops.

Signed-off-by: Eliad Peller <eliadx.peller@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: treat netdetect wake up separately
Luciano Coelho [Thu, 20 Nov 2014 06:59:51 +0000 (08:59 +0200)]
iwlwifi: mvm: treat netdetect wake up separately

When the device wakes up due to netdetect, we need to query different
things from the firmware than when it wakes up with a normal WoWLAN.
To make this easier, separate the netdetect wake up handling from the
rest.  For now, we don't send netdetect as a wake up reason, treating
it as a non-wireless wake up.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: refactor iwl_mvm_query_wakeup_reasons()
Luciano Coelho [Thu, 20 Nov 2014 08:14:44 +0000 (10:14 +0200)]
iwlwifi: mvm: refactor iwl_mvm_query_wakeup_reasons()

Refactor the iwl_mvm_query_wakeup_reasons() function to split the part
that gets the firmware status from the part that sets up the WoWLAN
status.  This will allow netdetect to reuse the code.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: refactor wowlan and netdetect configuration when suspending
Luciano Coelho [Wed, 19 Nov 2014 20:35:37 +0000 (22:35 +0200)]
iwlwifi: mvm: refactor wowlan and netdetect configuration when suspending

We need to send a WOWLAN_CONFIGURATION command also for netdetect and
configure the rfkill release trigger if needed.  To do so, refactor
the code that configures wowlan and netdetect when suspending and send
the WOWLAN_CONFIGURATION command also for net_detect.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: add support for net detect
Luciano Coelho [Fri, 24 Oct 2014 07:39:51 +0000 (10:39 +0300)]
iwlwifi: mvm: add support for net detect

Add the net detect WoWLAN flag to indicate support and use the
nd_config from the WoWLAN configuration to start net detect, if it is
set.  The WoWLAN configuration takes precedence over the debugfs
configuration.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: protect session during CSA
Luciano Coelho [Mon, 10 Nov 2014 09:10:21 +0000 (11:10 +0200)]
iwlwifi: mvm: protect session during CSA

When another vif is also running during a channel switch, we need to
use a session protection when we move to the new channel, so that we
don't miss the beacons.  Without this, sometimes the other vif
repeatedly gets time exactly when we should be hearing the beacons,
preventing channel switch from completing.  Adding a session
protection that lasts from the moment the channel changes until 2
TBTTs later, ensures that we will hear the beacons on the destination
channel.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: clear TE data if CSA time event fails to start
Luciano Coelho [Mon, 10 Nov 2014 09:10:20 +0000 (11:10 +0200)]
iwlwifi: mvm: clear TE data if CSA time event fails to start

If setting the CSA time event fails, we must clear the TE data,
otherwise we'll try to remove it when, for instance, a disconnection
occurs, causing a SYSASSERT.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: disable beacon filtering during CSA
Luciano Coelho [Mon, 10 Nov 2014 09:10:18 +0000 (11:10 +0200)]
iwlwifi: mvm: disable beacon filtering during CSA

After a channel switch, transmission on the new channel is only
started once we see a beacon on it.  Thus, beacon filtering needs to
be disabled during channel switch so that mac80211 receives this
beacon and finishes the process.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: add a channel_switch op to bypass mac80211 timer
Luciano Coelho [Mon, 10 Nov 2014 09:10:17 +0000 (11:10 +0200)]
iwlwifi: mvm: add a channel_switch op to bypass mac80211 timer

We need to call ieee80211_chswitch_done() ourselves just when the
absence TE started, so we perform the actual context switch early
enough.  To do so, add a dummy channel_switch op, which will cause
mac80211 to skip the countdown timer and allow us to call
ieee80211_chswitch_done() to complete the operation.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: finalize on post_switch instead of unassign
Luciano Coelho [Mon, 10 Nov 2014 09:10:16 +0000 (11:10 +0200)]
iwlwifi: mvm: finalize on post_switch instead of unassign

Now that mac80211 waits for the first beacon on the new channel before
calling post_channel_switch, the reconfiguration of the firmware
should be done in the post_channel_switch operation instead of when
assigning the vif to the new context.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: schedule CSA time event a bit before beacon 1
Luciano Coelho [Mon, 10 Nov 2014 09:10:15 +0000 (11:10 +0200)]
iwlwifi: mvm: schedule CSA time event a bit before beacon 1

Instead of using a hardcoded number of TUs before beacon 0 as the time
to start the absence and actual channel switch, calculate it in
relation to the beacon interval.  We use 10 TUs + beacon interval
before beacon 0 to target a bit before beacon 1.  This gives us enough
time to switch to the new channel before the AP/GO switches.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: add CSA absent time event for clients
Luciano Coelho [Mon, 10 Nov 2014 09:10:14 +0000 (11:10 +0200)]
iwlwifi: mvm: add CSA absent time event for clients

Add an absent time event when pre_channel_switch is called and use the
time event started indication to set the disable_tx bit instead of
doing it in unassign_vif().  This is done so that the firmware queues
are stopped before the actual switch takes place to avoid losing
packets while the AP/GO is performing its actual switch.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: use switching_chanctx argument instead of csa_active
Luciano Coelho [Mon, 10 Nov 2014 09:10:13 +0000 (11:10 +0200)]
iwlwifi: mvm: use switching_chanctx argument instead of csa_active

Now that all CSA flows are using the switch_vif_chanctx op, we can
rely on the switching_chanctx boolean that is passed to the
__iwl_mvm_assign_vif_chanctx() and __iwl_mvm_unassign_vif_chanctx()
functions to decide whether the context switch flows need to be
executed.  In this way we make the chanctx switch flow more generic,
without having to rely on the csa_active flag being set.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: disable PS during channel switch
Luciano Coelho [Mon, 10 Nov 2014 09:10:12 +0000 (11:10 +0200)]
iwlwifi: mvm: disable PS during channel switch

Disable PS when pre_channel_switch is called and add the
post_channel_switch operation to re-enable PS when the channel switch
is completed.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: Handle failed beacon transmissions during CSA
Andrei Otcheretianski [Mon, 10 Nov 2014 09:10:11 +0000 (11:10 +0200)]
iwlwifi: mvm: Handle failed beacon transmissions during CSA

The spec requires to decrement the CSA counters based on TBTT,
regardless if the beacon was actually transmitted. Previously, the fw
would send beacon notifications only for successfully transmitted
beacons. This behavior resulted in inaccurate CSA countdown. In order
to address this issue, the fw was changed to send beacon
notifications also for not transmitted beacons. Such notifications
have TX_STATUS_INTERNAL_ABORT (0x92).
Don't start the CSA countdown before first successfully transmitted
beacon, in order to guarantee that the CSA is announced for a
required period.

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
9 years agoiwlwifi: mvm: return the actual error code when switch_vif_chanctx fails
Luciano Coelho [Mon, 10 Nov 2014 09:10:10 +0000 (11:10 +0200)]
iwlwifi: mvm: return the actual error code when switch_vif_chanctx fails

We have code to recover and go back to the original channel context if
something fails in the middle of switch_vif_chanctx, but we return the
error code of the recover calls instead of the original code, so if
the recovery succeeds, we will return 0 (success).  Fix this by not
assigning the return value of the recovery calls to ret.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: add support for CHANCTX_SWMODE_REASSIGN_VIF
Luciano Coelho [Mon, 10 Nov 2014 09:10:09 +0000 (11:10 +0200)]
iwlwifi: mvm: add support for CHANCTX_SWMODE_REASSIGN_VIF

Add support to reassign vif in switch_vif_chanctx.  This is similar to
the existing CHANCTX_SWMODE_SWAP_CONTEXTS mode, but doesn't delete the
old context nor creates a new one, doing to switch between two
existing contexts.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: refactor iwl_mvm_switch_vif_chanctx to support other modes
Luciano Coelho [Mon, 10 Nov 2014 09:10:08 +0000 (11:10 +0200)]
iwlwifi: mvm: refactor iwl_mvm_switch_vif_chanctx to support other modes

Currently we only support the CHANCTX_SWMODE_SWAP_CONTEXTS mode, but
we need to support other modes as well.  Spin a new function off in
order to make it easier to support other modes.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: only save csa_vif in AP/GO mode
Luciano Coelho [Mon, 10 Nov 2014 09:10:07 +0000 (11:10 +0200)]
iwlwifi: mvm: only save csa_vif in AP/GO mode

We only need the csa_vif in AP/GO modes, and assigning for other
interfaces may cause problems, because csa_vif is never cleared.  To
prevent this, only assign the value if the iftype is
NL80211_IFTYPE_AP.  Use a switch to do this, even though, for now,
only the AP interface type is handled, because soon other interface
types will be added as well.

Additionally, convert the WARN() in the error case when a
channel-switch is already running to WARN_ONCE().

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: use new pre_channel_switch op instead of channel_switch_beacon
Luciano Coelho [Mon, 10 Nov 2014 09:10:06 +0000 (11:10 +0200)]
iwlwifi: mvm: use new pre_channel_switch op instead of channel_switch_beacon

A new callback has been added to prepare the device for a channel
switch.  Use the new callback instead of the old channel_switch_beacon
operation.

This makes it possible to remove the channel_switch_beacon operation
from mac80211.

Signed-off-by: Luciano Coelho <luciano.coelho@intel.com>
9 years agoiwlwifi: mvm: implement mac80211 TDLS channel-switch APIs
Arik Nemtsov [Thu, 23 Oct 2014 15:03:10 +0000 (18:03 +0300)]
iwlwifi: mvm: implement mac80211 TDLS channel-switch APIs

Maintain a TDLS channel-switch state and update it according to
notifications from FW and timeouts. Explicitly check all state
transitions are valid.
When switching is initiated by mac80211, use a delayed work to
periodically reschedule it from iwlwifi.
Give the FW mac80211 generated TDLS channel-switch request/response
templates. It will change appropriate values (switch timings) and Tx
them at appropriate times.

Enable the channel switch wiphy capability bit when the FW supports it.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: block TID when using TDLS
Liad Kaufman [Mon, 6 Oct 2014 17:08:56 +0000 (19:08 +0200)]
iwlwifi: mvm: block TID when using TDLS

Block TID 4 (VI) on a vif when using TDLS. This TID will be used by FW
for TDLS channel-switch requests and PTI requests.

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: use private TFD queues for TDLS stations
Arik Nemtsov [Sun, 21 Sep 2014 16:10:04 +0000 (19:10 +0300)]
iwlwifi: mvm: use private TFD queues for TDLS stations

When adding a TDLS station, allocate 4 new queues for it. Configure them
to FW and enable them. On station removal, drain the queues if needed
and disable them when empty.

Make sure to flush all packets in the private queues of TDLS stations in
the mac80211 flush() callback.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: disconnect TDLS peers on reconfig
Arik Nemtsov [Sun, 14 Sep 2014 16:13:54 +0000 (19:13 +0300)]
iwlwifi: mvm: disconnect TDLS peers on reconfig

When TDLS peers are present the FW will send packets on a dedicated
TID vs. the peer when performing TDLS channel-switches. The driver
configures the TID on connection to the peer and the FW is responsible
for maintaining the state of QoS seqno and PN/IV for encryption.

If the FW asserts, the driver cannot correctly reconfigure the starting
seqno/PN to the reloaded FW, thus forcing us to reconnect the peer.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: allow private per-STA TFD queues
Arik Nemtsov [Sun, 21 Sep 2014 16:07:30 +0000 (19:07 +0300)]
iwlwifi: mvm: allow private per-STA TFD queues

TDLS stations will have private queues, so consider them as well when
allocating a new one. Consolidate the HW-queue iterating code into
a single exported function, to be used by the TDLS code in the future.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: configure TDLS peers to FW
Arik Nemtsov [Mon, 15 Sep 2014 15:48:59 +0000 (18:48 +0300)]
iwlwifi: mvm: configure TDLS peers to FW

Send a dedicated TDLS_CONFIG command when a TDLS peer joins/leaves. The
fields for the command are mostly place-holders, as most of the FW
functionality is not implemented. In the future the dedicated FW TID
will be used for channel-switching and buffer-sta functionality.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: add TDLS channel switch FW APIs
Arik Nemtsov [Thu, 11 Sep 2014 10:10:08 +0000 (13:10 +0300)]
iwlwifi: mvm: add TDLS channel switch FW APIs

Add a channel-switch command and a switch-start notification. Also add a
FW TLV bit indicating TDLS channel switching support.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: declare TDLS support
Arik Nemtsov [Sun, 11 May 2014 15:13:04 +0000 (18:13 +0300)]
iwlwifi: mvm: declare TDLS support

The driver/FW combination now support TDLS.
Check the FW support with the TLV bit.

Signed-off-by: Arik Nemtsov <arikx.nemtsov@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: pull SNAP header into skb->head
Johannes Berg [Thu, 13 Nov 2014 10:06:43 +0000 (11:06 +0100)]
iwlwifi: mvm: pull SNAP header into skb->head

When we pre-populate the skb->head for the stack, we only pull
in the 802.11 header including crypto (assuming the packet isn't
short enough to be in there completely.) This is fine, but in
ieee80211_data_to_8023() we later unconditionally pull 8 more
bytes for the SNAP header and ethertype field (except for mesh
or 4-addr, where it's even more, but we don't care as much about
them).

Avoid the additional later pull by pulling in those 8 bytes here.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: IdoX Yariv <ido@wizery.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: pull crypto header into skb->head
Johannes Berg [Wed, 12 Nov 2014 16:12:05 +0000 (17:12 +0100)]
iwlwifi: mvm: pull crypto header into skb->head

When we pre-populate the skb->head for the stack, we only pull
in the 802.11 header (assuming the packet isn't short enough to
be in there completely.) This is fine, but in many cases we'll
pull in the crypto headers pretty much immediately afterwards,
so to avoid that pull in the crypto header early.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: IdoX Yariv <ido@wizery.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: build mac80211 rx_status in place
Johannes Berg [Wed, 12 Nov 2014 15:45:12 +0000 (16:45 +0100)]
iwlwifi: build mac80211 rx_status in place

Instead of building the rx_status on the stack and then
copying it to the skb, allocate the skb a bit earlier
and then build the rx_status in place.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: IdoX Yariv <ido@wizery.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: add WEP RX hardware offload support
Johannes Berg [Wed, 12 Nov 2014 22:54:48 +0000 (23:54 +0100)]
iwlwifi: mvm: add WEP RX hardware offload support

In the original driver, we decided to not implement WEP RX hardware
offload because of a quirk with the firmware API - it allows setting
global WEP keys that then get used for all virtual interfaces, which
is clearly wrong if more than one exists, and it allows setting per-
station keys but then separates multicast and unicast keys.

In order to implement WEP RX hardware offload, work around these
limitations by uploading each WEP key twice, once as multicast and
once as unicast, but point them both to the same key slot (offset)
and use the same key material so the slot overwrite on the second
upload doesn't actually change anything. Upon removal, also remove
the key twice so the station no longer references it.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: refactor key add/remove functions
Johannes Berg [Wed, 12 Nov 2014 22:39:56 +0000 (23:39 +0100)]
iwlwifi: mvm: refactor key add/remove functions

Refactor the key add/remove functions to be able to reuse parts
of them later for RX WEP keys, which need to be uploaded twice.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: add remove flow for AUX ROC time events
Matti Gottlieb [Sun, 16 Nov 2014 08:25:12 +0000 (10:25 +0200)]
iwlwifi: mvm: add remove flow for AUX ROC time events

Add a flow that handles the requests to cancel the roc time event,
that has been triggered via the aux framework.

The roc for bss is different than the roc for p2p devices, and  is done
via the aux framework using the aux queue, thus requires a different flow
to cancel the time event.

Signed-off-by: Matti Gottlieb <matti.gottlieb@intel.com>
Reviewed-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: remove warning on unknown scan complete
David Spinadel [Mon, 10 Nov 2014 09:16:53 +0000 (11:16 +0200)]
iwlwifi: mvm: remove warning on unknown scan complete

Remove warning on scan complete with unknown ID, since this
scan could be already cleared in abort flow.

Signed-off-by: David Spinadel <david.spinadel@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
9 years agoiwlwifi: mvm: use unsigned for ssid_bitmap
Johannes Berg [Mon, 17 Nov 2014 14:06:52 +0000 (15:06 +0100)]
iwlwifi: mvm: use unsigned for ssid_bitmap

The ssid_bitmap should be unsigned, though it doesn't matter
much as the high bits aren't used.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>