usb: rmnet: Add support to communicate with modem over bam

Rmnet is an alternative to CDC-ECM and Windows RNDIS.
It uses Qualcomm Modem Interface(QMI) protocol to communicate
with modem. Control info goes through EP0 and DATA is on bulk
in/out. On 8960, USB Rmnet driver communicates with modem over
SMD(Shared Memory Driver) and BAM(bridge access manager). SMD
is used for control info and BAM is used for DATA exchange.

Change-Id: I98c5924bcc8d9e9b82558f18e6eca45167daa08e
Signed-off-by: Vamsi Krishna <vskrishn@codeaurora.org>
msm: bam_dmux: initial version of BAM Data Mux driver

The BAM Data Mux driver serves as a muxing interface layer to the SPS BAM
driver for RMNET.

Change-Id: Ia8aabb1874955342b4829ddb4e70a01a84c16d5f
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: add logical channel for USB

Change-Id: I37c9491ffbbcd47592cfa62663f8d0e948c4312f
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: fix compiler warning

Change-Id: I4ac3bb8fcbad1397ff0ed14b0df3d0150880de9e
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: remove dependency on BAM-DMA

Remove the dependency on the BAM-DMA feature which is unsupported and
switch to using System Mode BAM.

Change-Id: I35a0ceecb1af8dc0eca385117f4140056087e4d6
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
[P350] Updated defconfig

Change-Id: Ibd8acb788a1bbf2e9eea24a695eb5b0dcef1d7b1
Signed-off-by: RonGokhale <cips173@gmail.com>
msm: bam_dmux: DL BAM descriptor performance optimization

Maintain a pool of 32 BAM descriptors so that BAM can fill descriptors
with downlink data while the bam_dmux is processing other descriptors.

Change-Id: I5529dbb8dd13e3e7315c2e60fa43976be59a8361
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: UL work performance optimization

Reduce the amount of work sent to the workqueue for each uplink packet
from two in the normal case to one work per packet always.

Change-Id: Ie0570eda0d3573028d5b483c0447b93a0a7cd4a2
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: split workqueue performance optimization

Split the workqueue into two workqueues, one dedicated for uplink packet
processing and the other for downlink.

Change-Id: Ie8b98f0feab13eaa9d89ce443f5f307a28789f76
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: remove shared linkedlist

Remove a linkedlist that is shared between interrupt context and task
context to promote concurrency.

Change-Id: I773a80a916fb2e5859f76490be3c09e61a283833
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: remove unnecessary spinlock

Remove an unnecessary spinlock to allow interrupts to be processed while
an uplink packet is being processed.

Change-Id: I80aa22724908db90851a01bffca5d2ff3b88186c
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: Configure BAM to auto-ack consumed descriptors

Configure the BAM to automatically acknowledge consumed descriptors
so that the BAM does not need to wait for bam_dmux to ack them before
reusing the fifo space.

Change-Id: If683b3aa2059aea91f5f8fbdaeecd3c94a0a42de
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: switch to polling on DL

The number of interrupts on the downlink data path is restricting the
maximum throughput, thus polling is needed.

Change-Id: Ia3d4dba330d05922a05fd246f83b1baab2c6990d
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: prevent open before remote is ready

Prevent a logical channel from being opened before it is opened on the
remote side because the remote side will not be expecting packets.

Change-Id: Idfe040ce1ac21a37331fe1002a0d0fc3b4874880
CRs-Fixed: 294407
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
usb: gbam: Free usb req memory if usb is disconnected

Free USB request and socket buffers(if any) if usb cable is
disconnected while queuing data to usb controller. Also,
replace list_for_each_safe with explicit check list_empty as
list is being deleted when usb cable is disconnected.

Change-Id: I6463923e43f551c91e0935fba62e6ac14fdcac09
Signed-off-by: Vamsi Krishna <vskrishn@codeaurora.org>
msm: bam_dmux: consolidate callback functions

Consolidate the multiple client callback function into a single callback
that is able to handle multiple event types.  This minimizes API changes
for future event types.

Change-Id: I7634d9c776fcc28d993cc8d4016ce7e481f0694d
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: add platform device registrations

Register a platform device when the remote open message is received and the
logical channel is ready to be locally opened.

Change-Id: I8fcda01e1d7c880b15c7545646eea5f408087311
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: bam_dmux: remove hardcoded delay

Remove the hardcoded 40 second delay and instead use a SMSM notification
from modem as acknowledgement that the A2 is powered on and ready.

Change-Id: I6344d84a94315a557ee6de5debde18f4edd25cf1
CRs-Fixed: 296336
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
Revert "msm: bam_dmux: switch to polling on DL"

This reverts commit 54d6f481f288753b653b52dc55e8ca96cb7ad14a.

Change-Id: I5817daa4ffa762c7fe943fa3ed7410e8ef2e3ace
CRs-Fixed: 302704
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
usb: rmnet: open BAM data channel only when ready

Add platform driver to be notified of when the BAM channel is ready to
be opened. This fixes the case of when a USB cable is connected on
device startup and the RmNet driver fails when attempting to open the
BAM MUX channel prematurely due to the configuration delay of around 40
seconds. Thus until the channel is ready, do not allow the call to open.
Also fix port cleanup for both data and SMD control channels.

Change-Id: Idba84504c41596b8fa9f55e731a59b41d7906966
Signed-off-by: Jack Pham <jackp@codeaurora.org>
Signed-off-by: Vamsi Krishna <vskrishn@codeaurora.org>