GitHub/MotorolaMobilityLLC/kernel-slsi.git
14 years agowimax: checking ERR_PTR vs null
Dan Carpenter [Thu, 22 Apr 2010 09:50:10 +0000 (02:50 -0700)]
wimax: checking ERR_PTR vs null

stch_skb is allocated with wimax_gnl_re_state_change_alloc().  That
function returns ERR_PTRs on failure and doesn't return NULL.

Signed-off-by: Dan Carpenter <error27@gmail.com>
14 years agowimax/i2400m: USB specific TX queue's minimum buffer room required for new message
Prasanna S. Panchamukhi [Tue, 13 Apr 2010 23:36:33 +0000 (16:36 -0700)]
wimax/i2400m: USB specific TX queue's minimum buffer room required for new message

This patch specifies the TX queue's buffer room required by the
USB bus driver while allocating header space for a new message.
Please refer the documentation in the code.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: SDIO specific TX queue's minimum buffer room for new message
Prasanna S. Panchamukhi [Tue, 13 Apr 2010 23:36:26 +0000 (16:36 -0700)]
wimax/i2400m: SDIO specific TX queue's minimum buffer room for new message

This patch specifies the TX queue's minimum buffer room required to
accommodate one smallest SDIO payload.
Please refer the documentation in the code.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: reserve additional space in the TX queue's buffer while allocating...
Prasanna S. Panchamukhi [Tue, 13 Apr 2010 23:36:19 +0000 (16:36 -0700)]
wimax/i2400m: reserve additional space in the TX queue's buffer while allocating space for a new message header

Increase the possibilities of including at least one payload by reserving
some additional space in the TX queue while allocating TX queue's space
for new message header. Please refer the documentation in the code for details.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: fix incorrect handling of type 2 and 3 RX messages
Prasanna S. Panchamukhi [Tue, 13 Apr 2010 23:36:10 +0000 (16:36 -0700)]
wimax/i2400m: fix incorrect handling of type 2 and 3 RX messages

According to Intel Wimax i3200, i5x50 and i6x60 device specification documents,
the host driver must not reset the device if the normalized sequence numbers
are greater than 1023 for type 2 and type 3 RX messages.
This patch removes the code that incorrectly used to reset the device.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax i2400m: fix race condition while accessing rx_roq by using kref count
Prasanna S. Panchamukhi [Tue, 13 Apr 2010 23:35:58 +0000 (16:35 -0700)]
wimax i2400m: fix race condition while accessing rx_roq by using kref count

This patch fixes the race condition when one thread tries to destroy
the memory allocated for rx_roq, while another thread still happen
to access rx_roq.
Such a race condition occurs when i2400m-sdio kernel module gets
unloaded, destroying the memory allocated for rx_roq while rx_roq
is accessed by i2400m_rx_edata(), as explained below:
$thread1                                $thread2
$ void i2400m_rx_edata()                $
$Access rx_roq[]                        $
$roq = &i2400m->rx_roq[ro_cin]          $
$ i2400m_roq_[reset/queue/update_ws]    $
$                                       $ void i2400m_rx_release();
$                                       $kfree(rx->roq);
$                                       $rx->roq = NULL;
$Oops! rx_roq is NULL

This patch fixes the race condition using refcount approach.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: increase tx queue length from 5 to 20 [v1]
Prasanna S. Panchamukhi [Thu, 8 Apr 2010 23:24:32 +0000 (16:24 -0700)]
wimax/i2400m: increase tx queue length from 5 to 20 [v1]

This patch increases the tx_queue_len to 20 so as to
minimize the jitter in the throughput.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: fix system freeze caused by an infinite loop [v1]
Prasanna S. Panchamukhi [Thu, 8 Apr 2010 23:24:31 +0000 (16:24 -0700)]
wimax/i2400m: fix system freeze caused by an infinite loop [v1]

This patch fixes an infinite loop caused by i2400m_tx_fifo_push() due
to a corner case where there is no tail space in the TX FIFO.
Please refer the documentation in the code for details.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: modify i2400m_tx_fifo_push() to check for head room space in the TX...
Prasanna S. Panchamukhi [Thu, 8 Apr 2010 23:24:30 +0000 (16:24 -0700)]
wimax/i2400m: modify i2400m_tx_fifo_push() to check for head room space in the TX FIFO [v1]

This fixes i2400m_tx_fifo_push(); the check for having enough
space in the TX FIFO's tail was obscure and broken in certain
corner cases. The new check works in all cases and is way
clearer. Please refer the documentation in the code for details.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: fix BUILD_BUG_ON() to use the maximum message size constant [v1]
Prasanna S. Panchamukhi [Thu, 8 Apr 2010 23:24:29 +0000 (16:24 -0700)]
wimax/i2400m: fix BUILD_BUG_ON() to use the maximum message size constant [v1]

The older method of computing the maximum PDU size relied
on a method that doesn't work when we prop the maximum
number of payloads up to the physical limit, and thus we kill
the whole computation and just verify that the constants are
congruent.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: limit the message size upto 16KiB [v1]
Prasanna S. Panchamukhi [Thu, 8 Apr 2010 23:24:28 +0000 (16:24 -0700)]
wimax/i2400m: limit the message size upto 16KiB [v1]

According to Intel Wimax i3200, i5x50 and i6x50 specification
documents, the maximum size of each TX message can be upto 16KiB.
This patch modifies the i2400m_tx() routine to check that the
message size does not exceed the 16KiB limit.
Please refer the documentation in the code for details.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: increase the maximum number of payloads per message to 60 [v1]
Prasanna S. Panchamukhi [Thu, 8 Apr 2010 23:24:27 +0000 (16:24 -0700)]
wimax/i2400m: increase the maximum number of payloads per message to 60 [v1]

According to Intel Wimax i3200, i5x50 and i6x50 device specification
documents, the maximum number of payloads per message can be up to 60.

Increasing the number of payloads to 60 per message helps to
accommodate smaller payloads in a single transaction. This patch
increases the maximum number of payloads from 12 to 60 per message.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agowimax/i2400m: Reset the TX FIFO indices when allocating the TX FIFO in tx_setup()
Cindy H Kao [Sat, 24 Apr 2010 00:19:06 +0000 (17:19 -0700)]
wimax/i2400m: Reset the TX FIFO indices when allocating the TX FIFO in tx_setup()

This patch makes sure whenever tx_setup() is invoked during driver
initialization or device reset where TX FIFO is released and re-allocated,
the indices tx_in, tx_out, tx_msg_size, tx_sequence, tx_msg are properly
initialized.

When a device reset happens and the TX FIFO is released/re-allocated,
a new block of memory may be allocated for the TX FIFO, therefore tx_msg
should be cleared so that no any TX threads (tx_worker, tx) would access
to the out-of-date addresses.

Also, the TX threads use tx_in and tx_out to decide where to put the new
host-to-device messages and from where to copy them to the device HW FIFO,
these indices have to be cleared so after the TX FIFO is re-allocated during
the reset, the indices both refer to the head of the FIFO, ie. a new start.
The same rational applies to tx_msg_size and tx_sequence.

To protect the indices from being accessed by multiple threads simultaneously,
the lock tx_lock has to be obtained before the initializations and released
afterwards.

Signed-off-by: Cindy H Kao <cindy.h.kao@intel.com>
14 years agowimax/i2400m: Correct the error path handlers order in i2400m_post_reset()
Cindy H Kao [Thu, 8 Apr 2010 23:03:12 +0000 (16:03 -0700)]
wimax/i2400m: Correct the error path handlers order in i2400m_post_reset()

When bus_setup fails in i2400m_post_reset(), it falls to the error path handler
"error_bus_setup:" which includes unlock the mutext. However, we didn't ever
try to the obtain the lock when running bus_setup.

The patch is to fix the misplaced error path handler "error_bus_setup:".

Signed-off-by: Cindy H Kao <cindy.h.kao@intel.com>
14 years agowimax/i2400m: add the error recovery mechanism on TX path
Cindy H Kao [Thu, 8 Apr 2010 03:07:47 +0000 (20:07 -0700)]
wimax/i2400m: add the error recovery mechanism on TX path

This patch adds an error recovery mechanism on TX path.
The intention is to bring back the device to some known state
whenever TX sees -110 (-ETIMEOUT) on copying the data to the HW FIFO.

The TX failure could mean a device bus stuck or function stuck, so
the current error recovery implementation is to trigger a bus reset
and expect this can bring back the device.

Since the TX work is done in a thread context, there may be a queue of TX works
already that all hit the -ETIMEOUT error condition because the device has
somewhat stuck already. We don't want any consecutive bus resets simply because
multiple TX works in the queue all hit the same device erratum, the flag
"error_recovery" is introduced to denote if we are ready for taking any
error recovery. See @error_recovery doc in i2400m.h.

Signed-off-by: Cindy H Kao <cindy.h.kao@intel.com>
14 years agowimax/i2400m: fix for missed reset events if triggered by dev_reset_handle()
Cindy H Kao [Thu, 8 Apr 2010 02:42:42 +0000 (19:42 -0700)]
wimax/i2400m: fix for missed reset events if triggered by dev_reset_handle()

The problem is only seen on SDIO interface since on USB, a bus reset would
really re-probe the driver, but on SDIO interface, a bus reset will not
re-enumerate the SDIO bus, so no driver re-probe is happening. Therefore,
on SDIO interface, the reset event should be still detected and handled by
dev_reset_handle().

Problem description:
Whenever a reboot barker is received during operational mode (i2400m->boot_mode == 0),
dev_reset_handle() is invoked to handle that function reset event.
dev_reset_handle() then sets the flag i2400m->boot_mode to 1 indicating the device is
back to bootmode before proceeding to dev_stop() and dev_start().
If dev_start() returns failure, a bus reset is triggered by dev_reset_handle().

The flag i2400m->boot_mode then remains 1 when the second reboot barker arrives.
However the interrupt service routine i2400ms_rx() instead of invoking dev_reset_handle()
to handle that reset event, it filters out that boot event to bootmode because it sees
the flag i2400m->boot_mode equal to 1.

The fix:
Maintain the flag i2400m->boot_mode within dev_reset_handle() and set the flag
i2400m->boot_mode to 1 when entering dev_reset_handle(). It remains 1
until the dev_reset_handle() issues a bus reset. ie: the bus reset is
taking place just like it happens for the first time during operational mode.

To denote the actual device state and the state we expect, a flag i2400m->alive
is introduced in addition to the existing flag i2400m->updown.
It's maintained with the same way for i2400m->updown but instead of reflecting
the actual state like i2400m->updown does, i2400m->alive maintains the state
we expect. i2400m->alive is set 1 just like whenever i2400m->updown is set 1.
Yet i2400m->alive remains 1 since we expect the device to be up all the time
until the driver is removed. See the doc for @alive in i2400m.h.

An enumeration I2400M_BUS_RESET_RETRIES is added to define the maximum number of
bus resets that a device reboot can retry.

A counter i2400m->bus_reset_retries is added to track how many bus resets
have been retried in one device reboot. If I2400M_BUS_RESET_RETRIES bus resets
were retried in this boot, we give up any further retrying so the device would enter
low power state. The counter i2400m->bus_reset_retries is incremented whenever
dev_reset_handle() is issuing a bus reset and is cleared to 0 when dev_start() is
successfully done, ie: a successful reboot.

Signed-off-by: Cindy H Kao <cindy.h.kao@intel.com>
14 years agowimax/i2400m: correct the error path handlers in dev_start()
Cindy H Kao [Wed, 31 Mar 2010 02:19:37 +0000 (19:19 -0700)]
wimax/i2400m: correct the error path handlers in dev_start()

This fix is to correct order of the handlers in the error path
of dev_start(). When i2400m_firmware_check fails, all the works done
before it should be released or cleared.

Signed-off-by: Cindy H Kao <cindy.h.kao@intel.com>
14 years agowimax/i2400m: fix the race condition for accessing TX queue
Cindy H Kao [Sat, 30 Jan 2010 09:26:54 +0000 (01:26 -0800)]
wimax/i2400m: fix the race condition for accessing TX queue

The race condition happens when the TX queue is accessed by
the TX work while the same TX queue is being destroyed because
a bus reset is triggered either by debugfs entry or simply
by failing waking up the device from WiMAX IDLE mode.

This fix is to prevent the TX queue from being accessed by
multiple threads

Signed-off-by: Cindy H Kao <cindy.h.kao@intel.com>
14 years agowimax/i2400m: fix insufficient size of Tx buffer for 12 payload of 1400 MTU.
Prasanna S. Panchamukhi [Wed, 27 Jan 2010 02:44:45 +0000 (19:44 -0700)]
wimax/i2400m: fix insufficient size of Tx buffer for 12 payload of 1400 MTU.

This patch increases the Tx buffer size so as to accommodate 12 payloads
of 1408 (1400 MTU 16 bytes aligned). Currently Tx buffer is 32 KiB which
is insufficient to accommodate 12 payloads of 1408 size.
This patch
 - increases I2400M_TX_BUF_SIZE from 32KiB to 64KiB
 - Adds a BUILD_BUG_ON if the calculated buffer size based
   on the given MTU exceeds the I2400M_TX_BUF_SIZE.

Below is how we calculate the size of the Tx buffer.
Payload + 4 bytes prefix for each payload (1400 MTU 16 bytes boundary aligned)
= (1408 + sizeof(struct i2400m_pl_data_hdr)) * I2400M_TX_PLD_MAX
Adding 16 byte message header = + sizeof(struct i2400m_msg_hdr)
Aligning to 256 byte boundary
Total Tx buffer = (((((1408 + sizeof(struct i2400m_pl_data_hdr))
* I2400M_TX_PLD_MAX )+ sizeof(struct i2400m_msg_hdr))
/ 256) + 1) * 256 * 2

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
14 years agowimax/i2400m: move I2400M_MAX_MTU enum from netdev.c to i2400m.h
Prasanna S. Panchamukhi [Wed, 27 Jan 2010 02:44:44 +0000 (19:44 -0700)]
wimax/i2400m: move I2400M_MAX_MTU enum from netdev.c to i2400m.h

This patch moves I2400M_MAX_MTU enum defined in netdev.c to i2400m.h.
Follow up changes will make use of this value in other location,
thus requiring it to be moved to a global header file i2400m.h.

Signed-off-by: Prasanna S. Panchamukhi <prasannax.s.panchamukhi@intel.com>
Signed-off-by: Inaky Perez-Gonzalez <inaky@linux.intel.com>
14 years agowimax/i2400m: fix incorrect return -ESHUTDOWN when there is no Tx buffer available
Prasanna S.Panchamukhi [Mon, 18 Jan 2010 22:28:23 +0000 (14:28 -0800)]
wimax/i2400m: fix incorrect return -ESHUTDOWN when there is no Tx buffer available

i2400m_tx() routine was returning -ESHUTDOWN even when there was no Tx buffer
available. This patch fixes the i2400m_tx() to return -ESHUTDOWN only when
the device is down(i2400m->tx_buf is NULL) and also to return -ENOSPC
when there is no Tx buffer. Error seen in the kernel log.
kernel: i2400m_sdio mmc0:0001:1: can't send message 0x5606: -108
kernel: i2400m_sdio mmc0:0001:1: Failed to issue 'Enter power save'command: -108

Signed-off-by: Prasanna S.Panchamukhi <prasannax.s.panchamukhi@intel.com>
14 years agoBluetooth: Fix issues where sk_sleep() helper is needed now
Marcel Holtmann [Mon, 10 May 2010 09:33:10 +0000 (11:33 +0200)]
Bluetooth: Fix issues where sk_sleep() helper is needed now

There were some left-overs that used sk->sk_sleep instead of the new
sk_sleep() helper.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Use strict_strtoul instead of simple_strtoul
Tomas Winkler [Tue, 9 Mar 2010 19:38:03 +0000 (21:38 +0200)]
Bluetooth: Use strict_strtoul instead of simple_strtoul

Use strict_strtoul as suggested by checkpatch.pl for more strict input
checking.

Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Set hdev->dev_type based on Marvell device type
Bing Zhao [Wed, 3 Mar 2010 22:37:37 +0000 (14:37 -0800)]
Bluetooth: Set hdev->dev_type based on Marvell device type

Get the device type from MODULE_BRINGUP_REQ command response.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Separate btmrvl_register_hdev() from btmrvl_add_card()
Bing Zhao [Wed, 3 Mar 2010 22:37:36 +0000 (14:37 -0800)]
Bluetooth: Separate btmrvl_register_hdev() from btmrvl_add_card()

Move btmrvl hdev registration code out of btmrvl_add_card().
New function btmrvl_register_hdev() is added.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Decode btmrvl MODULE_BRINGUP_REG response correctly
Bing Zhao [Wed, 3 Mar 2010 22:37:35 +0000 (14:37 -0800)]
Bluetooth: Decode btmrvl MODULE_BRINGUP_REG response correctly

The MODULE_BRINGUP_REQ command response returns success with
either 0x00 or 0x0c.

Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix storing negative values as unsigned char
Dan Carpenter [Mon, 8 Mar 2010 12:15:59 +0000 (15:15 +0300)]
Bluetooth: Fix storing negative values as unsigned char

This is mostly cleanup. There is only one caller and it just checks for
non-zero return values. Still "ret" should be int because we want to return
-EINVAL on errors.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Create per controller workqueue
Marcel Holtmann [Sat, 20 Mar 2010 14:20:04 +0000 (15:20 +0100)]
Bluetooth: Create per controller workqueue

Instead of having a global workqueue for all controllers, it makes
more sense to have a workqueue per controller.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix spec error in the RemoteBusy Logic
Gustavo F. Padovan [Wed, 5 May 2010 02:16:01 +0000 (23:16 -0300)]
Bluetooth: Fix spec error in the RemoteBusy Logic

On the receipt of an RR(P=1) under RemoteBusy set to TRUE(on the RECV
state table) we have to call sendIorRRorRNR(F=1) and just after set
RemoteBusy to False. This leads to a freeze in the sending process since
it's not allowed send data with RemoteBusy set to true and no one
call SendPending-I-Frames after set RemoteBusy to false(The last action
for that event).

Actually sendIorRRorRNR() calls SendPending-I-Frames but at that moment
RemoteBusy is still True and we cannot send any frame, after, no one
calls SendPending-I-Frames again and the sending process stops.

The solution here is to set RemoteBusy to false inside
SendPending-I-Frames just before call SendPending-I-Frames. That will
make SendPending-I-Frames able to send frames. This solution is similar
to what RR(P=0)(F=0) on the RECV table and RR(P=1) on the SREJ_SENT
table do.

Actually doesn't make any sense call SendPending-I-Frames if we can send
any frame, i. e., RemoteBusy is True.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Prevents buffer overflow on l2cap_ertm_reassembly_sdu()
Gustavo F. Padovan [Sat, 1 May 2010 19:15:45 +0000 (16:15 -0300)]
Bluetooth: Prevents buffer overflow on l2cap_ertm_reassembly_sdu()

The checks should be done before the the memcpy to avoid buffer
overflow.

Reported-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix race condition on l2cap_ertm_send()
Gustavo F. Padovan [Sat, 1 May 2010 19:15:45 +0000 (16:15 -0300)]
Bluetooth: Fix race condition on l2cap_ertm_send()

l2cap_ertm_send() can be called both from user context and bottom half
context. The socket locks for that contexts are different, the user
context uses a mutex(which can sleep) and the second one uses a
spinlock_bh. That creates a race condition when we have interruptions on
both contexts at the same time.

The better way to solve this is to add a new spinlock to lock
l2cap_ertm_send() and the vars it access. The other solution was to defer
l2cap_ertm_send() with a workqueue, but we the sending process already
has one defer on the hci layer. It's not a good idea add another one.

The patch refactor the code to create l2cap_retransmit_frames(), then we
encapulate the lock of l2cap_ertm_send() for some call. It also changes
l2cap_retransmit_frame() to l2cap_retransmit_one_frame() to avoid
confusion

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Add wait_queue to wait ack of all sent packets
Gustavo F. Padovan [Sat, 1 May 2010 19:15:44 +0000 (16:15 -0300)]
Bluetooth: Add wait_queue to wait ack of all sent packets

To guarantee that all packets we sent were received we need to wait for
theirs ack before shutdown the socket.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Implement Local Busy Condition handling
Gustavo F. Padovan [Sat, 1 May 2010 19:15:44 +0000 (16:15 -0300)]
Bluetooth: Implement Local Busy Condition handling

Supports Local Busy condition handling through a waitqueue that wake ups
each 200ms and try to push the packets to the upper layer. If it can
push all the queue then it leaves the Local Busy state.

The patch modifies the behaviour of l2cap_ertm_reassembly_sdu() to
support retry of the push operation.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Completes the I-frame tx_seq check logic on RECV
João Paulo Rechi Vita [Sat, 1 May 2010 19:15:44 +0000 (16:15 -0300)]
Bluetooth: Completes the I-frame tx_seq check logic on RECV

Add checks for invalid tx_seq and fixes the duplicated tx_seq check.

Signed-off-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Implement missing parts of the Invalid Frame Detection
Gustavo F. Padovan [Sat, 1 May 2010 19:15:44 +0000 (16:15 -0300)]
Bluetooth: Implement missing parts of the Invalid Frame Detection

There is a plenty of situation where ERTM shall close the channel, this
commit treats the cases regarding Invalid Frame Detection.
It create one reassembly SDU function for ERTM and other for Streaming
Mode to make the Invalid Frame Detection handling less complex.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Refactor l2cap_retransmit_frame()
Gustavo F. Padovan [Sat, 1 May 2010 19:15:44 +0000 (16:15 -0300)]
Bluetooth: Refactor l2cap_retransmit_frame()

Make the code flow cleaner and changes the function to void.
It also fixes a potential NULL dereference with skb.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Make hci_send_acl() void
Gustavo F. Padovan [Sat, 1 May 2010 19:15:43 +0000 (16:15 -0300)]
Bluetooth: Make hci_send_acl() void

hci_send_acl can't fail, so we can make it void. This patch changes
that and all the funcions that use hci_send_acl().
That change exposed a bug on sending connectionless data. We were not
reporting the lenght send back to the user space.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix lockdep annotation on ERTM
Gustavo F. Padovan [Thu, 6 May 2010 01:09:15 +0000 (22:09 -0300)]
Bluetooth: Fix lockdep annotation on ERTM

A spin_lock_init() call was missing. :)

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Check if we really are in WAIT_F when F bit comes
Gustavo F. Padovan [Wed, 5 May 2010 23:05:57 +0000 (20:05 -0300)]
Bluetooth: Check if we really are in WAIT_F when F bit comes

F-bit set should be processed only if we are in the WAIT_F state.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Remove unneeded control vars
Gustavo F. Padovan [Wed, 5 May 2010 22:58:27 +0000 (19:58 -0300)]
Bluetooth: Remove unneeded control vars

Trivial clean up.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Remove set of SrejSaveReqSeq under receipt of REJ frame
Gustavo F. Padovan [Wed, 5 May 2010 23:56:43 +0000 (20:56 -0300)]
Bluetooth: Remove set of SrejSaveReqSeq under receipt of REJ frame

That action is not specified by the ERTM spec, so removing it.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix errors reported by checkpatch.pl
Gustavo F. Padovan [Sat, 1 May 2010 19:15:43 +0000 (16:15 -0300)]
Bluetooth: Fix errors reported by checkpatch.pl

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Don't set control bits to zero first
Gustavo F. Padovan [Sat, 1 May 2010 19:15:43 +0000 (16:15 -0300)]
Bluetooth: Don't set control bits to zero first

We can set the SAR bits in the control field directly.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Close L2CAP channel on invalid ReqSeq
João Paulo Rechi Vita [Sat, 1 May 2010 19:15:43 +0000 (16:15 -0300)]
Bluetooth: Close L2CAP channel on invalid ReqSeq

Signed-off-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix SDU reassembly under SREJ
Gustavo F. Padovan [Sat, 1 May 2010 19:15:43 +0000 (16:15 -0300)]
Bluetooth: Fix SDU reassembly under SREJ

The code was reusing the control var without its reinitialization.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Check if mode is supported on getsockopt
João Paulo Rechi Vita [Sat, 1 May 2010 19:15:42 +0000 (16:15 -0300)]
Bluetooth: Check if mode is supported on getsockopt

Add this check to getsockopt makes possible to fail early instead of
waiting until listen / connect.

Signed-off-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Acked-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Add SOCK_STREAM support to L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:42 +0000 (16:15 -0300)]
Bluetooth: Add SOCK_STREAM support to L2CAP

if enable_ertm is true and we have SOCK_STREAM the default mode will be
ERTM, otherwise Basic Mode.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Add Kconfig option for L2CAP Extended Features
Gustavo F. Padovan [Sat, 1 May 2010 19:15:42 +0000 (16:15 -0300)]
Bluetooth: Add Kconfig option for L2CAP Extended Features

The L2CAP Extended Features are still unstable and under development,
so we are adding them under the EXPERIMENTAL flag to get more feedback
on them. L2CAP Extended Features includes the Enhanced Retransmission
and Streaming Modes, Frame Check Sequence (FCS), and Segmentation and
Reassemby (SAR).

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Optimize SREJ_QUEUE append
Gustavo F. Padovan [Sat, 1 May 2010 19:15:42 +0000 (16:15 -0300)]
Bluetooth: Optimize SREJ_QUEUE append

When the I-frame received is the expected, i.e., its tx_seq is equal to
expected_tx_seq and we are under a SREJ, we can just add it to the tail
of the list. Doing that we change the complexity from O(n) to O(1).

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix drop of acked packets on ERTM
Gustavo F. Padovan [Sat, 1 May 2010 19:15:42 +0000 (16:15 -0300)]
Bluetooth: Fix drop of acked packets on ERTM

l2cap_drop_acked_frames() was droping not sent packets, causing them to
be not transmitted.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix crash when monitor timeout expires
Gustavo F. Padovan [Sat, 1 May 2010 19:15:41 +0000 (16:15 -0300)]
Bluetooth: Fix crash when monitor timeout expires

The code was crashing due to a invalid access to hci_conn after the
channel disconnect.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix bug when retransmitting I-frames
Gustavo F. Padovan [Sat, 1 May 2010 19:15:41 +0000 (16:15 -0300)]
Bluetooth: Fix bug when retransmitting I-frames

If there is no frames to retransmit l2cap was crashing the kernel, now
we check if the queue is empty first.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Enable option to configure Max Transmission value via sockopt
Gustavo F. Padovan [Sat, 1 May 2010 19:15:41 +0000 (16:15 -0300)]
Bluetooth: Enable option to configure Max Transmission value via sockopt

With the sockopt extension we can set a per-channel MaxTx value.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Add module parameter for txWindow size on L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:41 +0000 (16:15 -0300)]
Bluetooth: Add module parameter for txWindow size on L2CAP

Very useful for testing purposes.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
[jprvita@profusion.mobi: improved parameter description]
Signed-off-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Change acknowledgement to use the value of txWindow
Gustavo F. Padovan [Sat, 1 May 2010 19:15:41 +0000 (16:15 -0300)]
Bluetooth: Change acknowledgement to use the value of txWindow

Now that we can set the txWindow we need to change the acknowledgement
procedure to ack after each (pi->txWindow/6 + 1). The plus 1 is to avoid
the zero value.
It also renames pi->num_to_ack to a better name: pi->num_acked.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Add sockopt configuration for txWindow on L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:40 +0000 (16:15 -0300)]
Bluetooth: Add sockopt configuration for txWindow on L2CAP

Now we can set/get Transmission Window size via sockopt.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Send Ack after clear the SREJ list
Gustavo F. Padovan [Sat, 1 May 2010 19:15:40 +0000 (16:15 -0300)]
Bluetooth: Send Ack after clear the SREJ list

As specified by Bluetooth 3.0 spec we shall send an acknowledgment using
the Send-Ack() after clear the SREJ list.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Check the SDU size against the MTU value
Gustavo F. Padovan [Sat, 1 May 2010 19:15:40 +0000 (16:15 -0300)]
Bluetooth: Check the SDU size against the MTU value

If the SDU size is greater than the MTU something is wrong, so report
an error.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
[jprvita@profusion.mobi: set err to appropriate errno value]
Signed-off-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Add le16 macro to Retransmission and Monitor Timeouts values
Gustavo F. Padovan [Sat, 1 May 2010 19:15:40 +0000 (16:15 -0300)]
Bluetooth: Add le16 macro to Retransmission and Monitor Timeouts values

Fix a possible problem with Big Endian machines.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix configuration of the MPS value
Gustavo F. Padovan [Sat, 1 May 2010 19:15:40 +0000 (16:15 -0300)]
Bluetooth: Fix configuration of the MPS value

We were accepting values bigger than we can accept. This was leading
ERTM to drop packets because of wrong FCS checks.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Read RFC conf option on a successful Conf RSP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:39 +0000 (16:15 -0300)]
Bluetooth: Read RFC conf option on a successful Conf RSP

On Enhanced Retransmission Mode and Streaming Mode a entity can send, on
a successful Conf RSP, new values for the RFC fields. For example, the
entity can send txWindow and MPS values less than the value received on
a Conf REQ.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Ignore Tx Window value with Streaming mode
Gustavo F. Padovan [Sat, 1 May 2010 19:15:39 +0000 (16:15 -0300)]
Bluetooth: Ignore Tx Window value with Streaming mode

Tx Window value shall not be used with Streaming Mode and the receiver
of the config Request shall ignore its value.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Add timer to Acknowledge I-frames
Gustavo F. Padovan [Sat, 1 May 2010 19:15:39 +0000 (16:15 -0300)]
Bluetooth: Add timer to Acknowledge I-frames

We ack I-frames on each txWindow/5 I-frames received, but if the sender
stop to send I-frames and it's not a txWindow multiple we can leave some
frames unacked.
So I added a timer to ack I-frames on this case. The timer expires in
200ms.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Finish implementation for Rec RR (P=1) on ERTM
Gustavo F. Padovan [Sat, 1 May 2010 19:15:39 +0000 (16:15 -0300)]
Bluetooth: Finish implementation for Rec RR (P=1) on ERTM

Now the code handles the case under SREJ_SENT state.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Remove duplicate use of __get_reqseq() macro on L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:38 +0000 (16:15 -0300)]
Bluetooth: Remove duplicate use of __get_reqseq() macro on L2CAP

tx_seq var already has the value of __get_reqseq().

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Group the ack of I-frames into l2cap_data_channel_rrframe()
Gustavo F. Padovan [Sat, 1 May 2010 19:15:38 +0000 (16:15 -0300)]
Bluetooth: Group the ack of I-frames into l2cap_data_channel_rrframe()

It also fix a bug: we weren't acknowledging I-frames when P=1.
Note that when F=1 we are acknowledging packets before setting
RemoteBusy to False. The spec says we should do that in the opposite
order, but acknowledment of packets doesn't care about RemoteBusy flag
so we can do that in the order we want.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Handle all cases of receipt of RNR-frames into L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:38 +0000 (16:15 -0300)]
Bluetooth: Handle all cases of receipt of RNR-frames into L2CAP

We weren't handling the receipt under SREJ_SENT state table.
It also introduce l2cap_send_srejtail(). It will be used in the nexts
commits too.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Split l2cap_data_channel_sframe()
Gustavo F. Padovan [Sat, 1 May 2010 19:15:38 +0000 (16:15 -0300)]
Bluetooth: Split l2cap_data_channel_sframe()

Create a function for each type fo S-frame and avoid a lot of nested
code.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Add Recv RR (P=0)(F=0) for SREJ_SENT state on ERTM
Gustavo F. Padovan [Sat, 1 May 2010 19:15:38 +0000 (16:15 -0300)]
Bluetooth: Add Recv RR (P=0)(F=0) for SREJ_SENT state on ERTM

This finishes the implementation of Recv RR (P=0)(F=0) for the Enhanced
Retransmission Mode on L2CAP.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Move set of P-bit to l2cap_send_sframe()
Gustavo F. Padovan [Sat, 1 May 2010 19:15:37 +0000 (16:15 -0300)]
Bluetooth: Move set of P-bit to l2cap_send_sframe()

Abstract the send of of P-bit and avoids code duplication like we
did with the setting of F-bit.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Implement SendAck() Action on ERTM.
Gustavo F. Padovan [Sat, 1 May 2010 19:15:37 +0000 (16:15 -0300)]
Bluetooth: Implement SendAck() Action on ERTM.

Shall be used to ack received frames, It must decide type of
acknowledgment between a RR frame, a RNR frame or transmission of
pending I-frames.
It also modifies l2cap_ertm_send() to report the number of frames sent.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Check if SDU size is greater than MTU on L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:37 +0000 (16:15 -0300)]
Bluetooth: Check if SDU size is greater than MTU on L2CAP

After reassembly the SDU we need to check his size. It can't overflow
the MTU size.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Check the minimum {I,S}-frame size into L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:37 +0000 (16:15 -0300)]
Bluetooth: Check the minimum {I,S}-frame size into L2CAP

All packets with size fewer than the minimum specified is dropped.
Note that the size of the l2cap basic header, FCS and SAR fields are
already subtracted of len at the moment of the size check.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Support case with F bit set under WAIT_F state.
Gustavo F. Padovan [Sat, 1 May 2010 19:15:37 +0000 (16:15 -0300)]
Bluetooth: Support case with F bit set under WAIT_F state.

On receipt of a F=1 under WAIT_F state ERTM shall stop monitor timer and
start retransmission timer (if there are unacked frames).

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Implement 'Send IorRRorRNR' event
Gustavo F. Padovan [Sat, 1 May 2010 19:15:36 +0000 (16:15 -0300)]
Bluetooth: Implement 'Send IorRRorRNR' event

After receive a RR with P bit set ERTM shall use this funcion to choose
what type of frame to reply with F bit = 1.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Use a l2cap_pinfo struct instead l2cap_pi() macro
Gustavo F. Padovan [Sat, 1 May 2010 19:15:36 +0000 (16:15 -0300)]
Bluetooth: Use a l2cap_pinfo struct instead l2cap_pi() macro

Trivial clean up.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix ACL MTU issue
Gustavo F. Padovan [Sat, 1 May 2010 19:15:36 +0000 (16:15 -0300)]
Bluetooth: Fix ACL MTU issue

ERTM and Streaming Modes was having problems when the ACL MTU is lower
than MPS. The 'minus 10' is to take in account the header and fcs
lenghts.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix expected_tx_seq calculation on L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:36 +0000 (16:15 -0300)]
Bluetooth: Fix expected_tx_seq calculation on L2CAP

All operation related to the txWindow should be modulo 64.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix memory leak of S-frames into L2CAP
Gustavo F. Padovan [Sat, 1 May 2010 19:15:35 +0000 (16:15 -0300)]
Bluetooth: Fix memory leak of S-frames into L2CAP

l2cap_data_channel do not free the S-frame, so we free it here.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Move specific Basic Mode code to the right place
Gustavo F. Padovan [Sat, 1 May 2010 19:15:35 +0000 (16:15 -0300)]
Bluetooth: Move specific Basic Mode code to the right place

Inside "case L2CAP_MODE_BASIC:" we don't need to check for sk_type and
L2CAP mode. So only the length check is fine.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Trivial clean ups to SCO
Gustavo F. Padovan [Sat, 1 May 2010 19:15:35 +0000 (16:15 -0300)]
Bluetooth: Trivial clean ups to SCO

Remove extra braces and labels, break over column 80 lines, etc

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Make hci_send_sco() void
Gustavo F. Padovan [Sat, 1 May 2010 19:15:35 +0000 (16:15 -0300)]
Bluetooth: Make hci_send_sco() void

It also removes an unneeded check for the MTU. The check is done before
on sco_send_frame()

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: João Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix wrong packet type count increment
Gustavo F. Padovan [Sat, 1 May 2010 19:15:34 +0000 (16:15 -0300)]
Bluetooth: Fix wrong packet type count increment

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Use the proper function cast to get hdr data
Gustavo F. Padovan [Sat, 1 May 2010 19:15:34 +0000 (16:15 -0300)]
Bluetooth: Use the proper function cast to get hdr data

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoBluetooth: Fix return value when bt_skb_alloc fails
Gustavo F. Padovan [Sat, 1 May 2010 19:15:34 +0000 (16:15 -0300)]
Bluetooth: Fix return value when bt_skb_alloc fails

Set the proper error(ENOMEM), instead of just return 0.

Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
14 years agoipv4: remove ip_rt_secret timer (v4)
Neil Horman [Sat, 8 May 2010 08:57:52 +0000 (01:57 -0700)]
ipv4: remove ip_rt_secret timer (v4)

A while back there was a discussion regarding the rt_secret_interval timer.
Given that we've had the ability to do emergency route cache rebuilds for awhile
now, based on a statistical analysis of the various hash chain lengths in the
cache, the use of the flush timer is somewhat redundant.  This patch removes the
rt_secret_interval sysctl, allowing us to rely solely on the statistical
analysis mechanism to determine the need for route cache flushes.

Signed-off-by: Neil Horman <nhorman@tuxdriver.com>
Acked-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agoRevert "microblaze: Kill NET_SKB_PAD and NET_IP_ALIGN overrides."
David S. Miller [Fri, 7 May 2010 09:55:33 +0000 (02:55 -0700)]
Revert "microblaze: Kill NET_SKB_PAD and NET_IP_ALIGN overrides."

This reverts commit 39e0786d3cf39c6d2f47b4818ae2da8b8ebc9ce2.

On request from microblaze developers, they are going to handle
this differently.

Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agobnx2: Add prefetches to rx path.
Michael Chan [Thu, 6 May 2010 08:58:13 +0000 (08:58 +0000)]
bnx2: Add prefetches to rx path.

Add prefetches of the skb and the next rx descriptor to speed up rx path.

Use prefetchw() for the skb [suggested by Eric Dumazet].

The rx descriptor is in skb->data which is mapped for streaming mode DMA.
Eric Dumazet pointed out that we should not prefetch the data before
dma_sync.  So we prefetch only if dma_sync is no_op on the system.

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agobnx2: Add GRO support.
Michael Chan [Thu, 6 May 2010 08:58:12 +0000 (08:58 +0000)]
bnx2: Add GRO support.

And turn on NETIF_F_GRO by default [requested by DaveM].

Signed-off-by: Michael Chan <mchan@broadcom.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agotehuti: Remove unnecessary memset of netdev private data
Tobias Klauser [Thu, 6 May 2010 05:43:04 +0000 (05:43 +0000)]
tehuti: Remove unnecessary memset of netdev private data

The memory for the private data is allocated using kzalloc in
alloc_etherdev (or alloc_netdev_mq respectively) so there is no need to
set it to 0 again.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agosunhme: Remove unnecessary memset of netdev private data
Tobias Klauser [Thu, 6 May 2010 05:41:44 +0000 (05:41 +0000)]
sunhme: Remove unnecessary memset of netdev private data

The memory for the private data is allocated using kzalloc in
alloc_etherdev (or alloc_netdev_mq respectively) so there is no need to
set it to 0 again.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agosmc9194: Remove unnecessary memset of netdev private data
Tobias Klauser [Thu, 6 May 2010 05:41:31 +0000 (05:41 +0000)]
smc9194: Remove unnecessary memset of netdev private data

The memory for the private data is allocated using kzalloc in
alloc_etherdev (or alloc_netdev_mq respectively) so there is no need to
set it to 0 again.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agoethoc: Remove unnecessary memset of napi member in netdev private data
Tobias Klauser [Thu, 6 May 2010 05:41:12 +0000 (05:41 +0000)]
ethoc: Remove unnecessary memset of napi member in netdev private data

The memory for the private data is allocated using kzalloc in
alloc_etherdev (or alloc_netdev_mq respectively) so there is no need to
set the napi member it to 0 explicitely.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agobcm63xx_enet: Remove unnecessary memset of netdev private data
Tobias Klauser [Thu, 6 May 2010 05:40:58 +0000 (05:40 +0000)]
bcm63xx_enet: Remove unnecessary memset of netdev private data

The memory for the private data is allocated using kzalloc in
alloc_etherdev (or alloc_netdev_mq respectively) so there is no need to
set it to 0 again.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agoKS8695: Remove unnecessary memset of netdev private data
Tobias Klauser [Thu, 6 May 2010 05:40:29 +0000 (05:40 +0000)]
KS8695: Remove unnecessary memset of netdev private data

The memory for the private data is allocated using kzalloc in
alloc_etherdev (or alloc_netdev_mq respectively) so there is no need to
set it to 0 again.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years ago3c523: Remove unnecessary memset of netdev private data
Tobias Klauser [Thu, 6 May 2010 05:39:46 +0000 (05:39 +0000)]
3c523: Remove unnecessary memset of netdev private data

The memory for the private data is allocated using kzalloc in
alloc_etherdev (or alloc_netdev_mq respectively) so there is no need to
set it to 0 again.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years ago3c507: Remove unnecessary memset of netdev private data
Tobias Klauser [Thu, 6 May 2010 05:39:11 +0000 (05:39 +0000)]
3c507: Remove unnecessary memset of netdev private data

The memory for the private data is allocated using kzalloc in
alloc_etherdev (or alloc_netdev_mq respectively) so there is no need to
set it to 0 again.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agorps: Various optimizations
Eric Dumazet [Fri, 7 May 2010 05:07:48 +0000 (22:07 -0700)]
rps: Various optimizations

Introduce ____napi_schedule() helper for callers in irq disabled
contexts. rps_trigger_softirq() becomes a leaf function.

Use container_of() in process_backlog() instead of accessing per_cpu
address.

Use a custom inlined version of __napi_complete() in process_backlog()
to avoid one locked instruction :

 only current cpu owns and manipulates this napi,
 and NAPI_STATE_SCHED is the only possible flag set on backlog.
 we can use a plain write instead of clear_bit(),
 and we dont need an smp_mb() memory barrier, since RPS is on,
 backlog is protected by a spinlock.

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agomicroblaze: Kill NET_SKB_PAD and NET_IP_ALIGN overrides.
David S. Miller [Fri, 7 May 2010 05:01:53 +0000 (22:01 -0700)]
microblaze: Kill NET_SKB_PAD and NET_IP_ALIGN overrides.

NET_IP_ALIGN defaults to 2, no need to override.

NET_SKB_PAD is now 64, which is much larger than microblaze's
L1_CACHE_SIZE so no need to override that either.

Signed-off-by: David S. Miller <davem@davemloft.net>
14 years agonet: Increase NET_SKB_PAD to 64 bytes
Eric Dumazet [Fri, 7 May 2010 04:58:51 +0000 (21:58 -0700)]
net: Increase NET_SKB_PAD to 64 bytes

eth_type_trans() & get_rps_cpus() currently need two 64bytes cache
lines in packet to compute rxhash.

Increasing NET_SKB_PAD from 32 to 64 reduces the need to one cache
line only, and makes RPS faster.

NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)

Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>