Use alloc_skb_with_frags for skb allocation to keep it uniform
throughout the rx path.
Change-Id: Id38eeea0a7d422b50c1ad6a90b9b569f26c45917
Signed-off-by: Jay Jayanna <jayanna@codeaurora.org>
Add a pool of SKBs that can be used when the system is in low memory
conditions. This pool will be shared between all nodes and replenished
by a worker function.
Change-Id: I639a9ac76db726dc8ad46b12d3b3d560c674939c
Signed-off-by: Chris Lew <clew@codeaurora.org>
Signed-off-by: Vivek Golani <vgolani@codeaurora.org>
While copying more bytes in a partial packet, the buffer pointer was
incorrectly shifted. So, only the last part of the packet was posted
to the qrtr core, resulting in invalid packet error.
Change-Id: I9823ea5cec1befa55917a0450adacb8e7233d94d
Signed-off-by: Jay Jayanna <jayanna@codeaurora.org>
Add the QRTR ethernet transport that facilitates sending and
receiving of IPC Router messages between targets that use
QTI ethernet adaption layer as the underlying transport.
Change-Id: Ie2ab1eeb7225617c8eedcebca62467d99e315eec
Signed-off-by: Jay Jayanna <jayanna@codeaurora.org>
[ Upstream commit d28ea1fbbf437054ef339afec241019f2c4e2bb6 ]
Once the traversal of the list is completed with list_for_each_entry(),
the iterator (node) will point to an invalid object. So passing this to
qrtr_local_enqueue() which is outside of the iterator block is erroneous
eventhough the object is not used.
So fix this by passing NULL to qrtr_local_enqueue().
Fixes: bdabad3e36 ("net: Add Qualcomm IPC router")
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Handle -EEXIST error case while register state callback
with mhi device. If channel is open during registration
no callback will issue instead mhi stack return -EEXIST
to notify the client. Further state change notification
will be informed via registered callback.
Change-Id: Icf60de35d23393a0808ef90058c1108e950d02b9
Signed-off-by: Arun Prakash <app@codeaurora.org>
Return from kthread work function only when kthread_should_stop
becomes true.
Change-Id: I73e91a8128405c79c54894f0cb96899bba344441
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
[ Upstream commit 6dbf02acef69b0742c238574583b3068afbd227c ]
If the local node id(qrtr_local_nid) is not modified after its
initialization, it equals to the broadcast node id(QRTR_NODE_BCAST).
So the messages from local node should not be taken as broadcast
and keep the process going to send them out anyway.
The definitions are as follow:
static unsigned int qrtr_local_nid = NUMA_NO_NODE;
Fixes: fdf5fd397566 ("net: qrtr: Broadcast messages only from control port")
Signed-off-by: Wang Wenhu <wenhu.wang@vivo.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Registering only for endpoint RX channel to complete enumeration and
starting to open both RX/TX channels leads to race condition on TX channel.
Since the host does TX followed by RX init.
Wait for endpoint TX channel init to synchronise with host.
Change-Id: Ied002a89b51f71fa30cb7557f7dce27cfe1fd202
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Add host driver support for the new telematics PIDs
such as 910A, 910B, 910C and 910D.
Change-Id: Ic872ed72a943818eb9e24a68b69dde34b8f1a326
Signed-off-by: Aniket Randive <arandive@codeaurora.org>
Converting DEL_PROC control command to BYE command to
cleanup service/client details of MSM.
Change-Id: I08d22d47b092e0124f5e9a58451f1dbcaaf14ed1
Signed-off-by: Arun Prakash <app@codeaurora.org>
Add global variable __qdev in the driver for ease of debugging.
Make other miscellaneous changes.
Change-Id: I503c2a9e0e3ded6bc56819663c78d661d4a25c91
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
After MHI device receives a reset command the internal
state machine suspends all activity on the channel and
processes the device reset. Clients are notified on
the channel close. Existing close function checks if
there are pending data to be read but since the device
is in the process of cleaning the transfer buffers
and the channels are suspended this check is not required.
Change-Id: Iafc5249762b1468ee2cca4ac141522ce0356d403
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
mhi_dev_read_channel returns the number of bytes read. Do not post a
packet to qrtr if the length returned is 0. This prevents an issue
where qrtr receives duplicates packets from the mhi_dev transport.
Change-Id: Ib1a31665730293baa9af61a9ae61bd8bdf6cab6f
Signed-off-by: Sricharan R <sricharan@codeaurora.org>
Signed-off-by: Chris Lew <clew@codeaurora.org>
The current QRTR transport feature set does not support fragmented skbs
which is a problem for packets that are forwarded from the rx path.
In order to linearize the skb, skb_put_padto() and skb_linearize() try
to allocate enough memory with GFP_ATOMIC but are prone to failure.
Pre-allocate enough headroom with GFP_KERNEL on forwarded packets. If
there are still problems with allocation, then continue and drop the
packet in qrtr_node_enqueue().
Change-Id: I7de6620bba26746698237d913ce064ea5725f921
Signed-off-by: Chris Lew <clew@codeaurora.org>
skb_put_padto() will free the skb if it fails to add the requested
padding to the skb. Drop the packet if we are unable to allocate a new
skb with the requested padding.
Change-Id: I5503c99679c7e6ecf767d3f632d72da5315988f1
Signed-off-by: Chris Lew <clew@codeaurora.org>
This reverts commit 088f93d00b.
This is a preparation change for merging android-4.14-q.147 into
msm-4.14 branch. Equivalent logic is already committed via:
31df2523b3 net: qrtr: Move rx worker to separate worker thread
05cc454885 net: qrtr: Flush work during release
Change-Id: Icdc4dbbe647c92251d67dbe140391bd1317235d1
Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
Add 05c6 VID and 9102-9107 PIDs with proper interface numbers to
device ID tables of diag_bridge, qrtr USB and rmnet_usb drivers,
so that the diag, IPC and RmNet functions can be probed by host.
Change-Id: I770a2772ebbc7d904161edad9946cd155d84d631
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
net_dev_alloc() fails for high order allocations in system where memory
is fragmented and cause communication stall due to packet drops.
Use alloc_skb_with_frag() to avoid packet drops in memory fragmented case.
Change-Id: If6de7857deb82e080281ad8ca76fc17a13ce6dca
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
[ Upstream commit 73f0c11d11329a0d6d205d4312b6e5d2512af7c5 ]
As the endpoint is unregistered there might still be work pending to
handle incoming messages, which will result in a use after free
scenario. The plan is to remove the rx_worker, but until then (and for
stable@) ensure that the work is stopped before the node is freed.
Fixes: bdabad3e36 ("net: Add Qualcomm IPC router")
Cc: stable@vger.kernel.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Hello message is currently sent in response to a hello message received
by the ns. When two procs operate in this slave model, then neither of
them exchange the Hello message. This will halt further communication
from happening. Update QRTR to send a hello message once a new endpoint
is registered.
Prevent duplicate Hello messages from reaching the NS because NS will
echo the packet back. On two systems running QRTR, this will loopback
infinitely.
Change-Id: Ibc84fc46658e8c6cedb0d6e84bb1a56d739d5a30
Signed-off-by: Chris Lew <clew@codeaurora.org>
Rename API prefix to qrtr_usb_dev throughout the
file.
Change-Id: I3464149af8571ab48310cd7ecefa6a347925434e
Signed-off-by: Gustavo Solaira <gustavos@codeaurora.org>
Add a transport that uses the USB device ipc_bridge APIs.
The USB device IPC APIs are used to transfer data from a
device to the host over USB. The modem will generally be
configured as a device and this transport is intended to
be used on the modem controller co-processor.
Change-Id: I8871fef55b266bb4f749e7963bf12e9fe1ae7281
Signed-off-by: Gustavo Solaira <gustavos@codeaurora.org>
This reverts commit d33025a786.
Originally MHI Host API's assumed the client would not send until it
first received a packet from the device. This assumption is broken with
the change to queue hello work.
The MHI driver should split the channel initialization so that probe
occurs after the UL channel is started. This will allow the QRTR driver
to send immediately after probe. Revert this change until the channel
initialization change from MHI is ready.
Change-Id: I174d8c204eb1c36b0519005f15d79080fed8139f
Signed-off-by: Chris Lew <clew@codeaurora.org>
qrtr_mhi_dev_event_cb will be called only once if there is
more than one packet at that time. Hence, call mhi_dev_read_channel
in a loop until it returns zero.
Change-Id: I2f171cb45e66c1c439fcc7d0027c22d0edb4fb19
Signed-off-by: Jay Jayanna <jayanna@codeaurora.org>
MHI's IN channel is QRTR's OUT channel and vice-versa.
Change-Id: If16790e629263cfa2787a08326c079b58f42617b
Signed-off-by: Chris Lew <clew@codeaurora.org>
Hello message is currently sent in response to a hello message received
by the ns. When two procs operate in this slave model, then neither of
them exchange the Hello message. This will halt further communication
from happening. Update QRTR to send a hello message once a new endpoint
is registered.
Prevent duplicate Hello messages from reaching the NS because NS will
echo the packet back. On two systems running QRTR, this will loopback
infinitely.
Change-Id: Id8483341717ed3075b426b142b21e018cefbd580
Signed-off-by: Chris Lew <clew@codeaurora.org>
Add support to configure the node id through defconfig. This is useful
for targets that are unable to configure the node id through qrtr-ns
because of security reasons. The local node id can still be overridden
by the ns if it is capable.
Change-Id: Ie9fec2ae276948340f4f5a7e0374d554502a0ee1
Signed-off-by: Chris Lew <clew@codeaurora.org>
Add a transport that uses the mhi device APIs. The mhi device APIs are
used to transfer data from a device to the host over MHI. The modem
will generally be configured as a device and this transport is intended
to be used on the modem controller co-processor.
Change-Id: Ie9276fe6c0846581192aff881e59baa5fecf1ca4
Signed-off-by: Chris Lew <clew@codeaurora.org>
Use spin_lock_bh in qcom_mhi_qrtr_send as this is sufficient
to avoid recursive spin lock issue.
Change-Id: I214c056f66831837b7589940fe1789d0e9edc00c
Signed-off-by: Jay Jayanna <jayanna@codeaurora.org>
Register for status callback to receive fatal error notifications.
Cancel any pending transactions and assume all future transactions
will return immediately with an error.
Early notification can be called from atomic context, change spin_lock
APIs to irqsave/irqrestore variants.
Change-Id: I17ed3a800411eef1bdcaf22c088cb1c9dbd393a6
Signed-off-by: Chris Lew <clew@codeaurora.org>
While forwarding a packet, if the node lookup fails, qrtr_fwd_pkt returns
without freeing the socket buffer. This results in memory leak. Make sure
this memory is freed to prevent this memory leak.
Change-Id: Ia17ceaaa8da7ec7b08ea0982928502c52316e8c0
Signed-off-by: Jay Jayanna <jayanna@codeaurora.org>
Add 05c6 VID and 90fd PID with proper interface numbers to device
ID tables of diag_bridge, qrtr USB and rmnet_usb drivers, so that
the diag, IPC and RmNet functions can be probed by host on cable
connect.
Change-Id: Icbbd3578c6192eff267cf4610002b739601f0644
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
In system with fragmented memory allocation of bigger RX buffers
are failed and results in packet drop issue.
In failure cases use skb allocations with fragmented pages to avoid
packet drops and serve the use case.
CRs-Fixed: 2455559
Change-Id: Iac507bfa9b17ae0278e8cddafdfa5ec87fd7f80c
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
In some cases system enters into suspend state before handling
incoming packets and cause delay in communication.
Add pm_wakup_event() to abort the suspend when a packet is received.
CRs-Fixed: 2432846
Change-Id: I5cec4f9273362e8e2c1df1dae159a6bb5e54d16d
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
To support high priority clients like sensor use cases in all system
conditions elevating the router reader threads to RT priorities based
on configuration.
Change-Id: I6f46097f6678f2e00c3ec8872b208d773c377224
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Forwarding of control packets are not reaching the destination because
of replacing all control packets node id with node_id instead of
packet destination node_id.
Replace dst_node_id only when node id is broadcast node ID.
Change-Id: I544f52613fbf8b0973f3188d2acc03f5487d6bac
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
If a node_enqueue is called on a node that has not finished the hello
packet negotiation, the packet to be enqueued will be dropped. Make
sure to free this dropped packet.
Change-Id: I52a6f5d6b07fff272e3912d85221e7f6540cfa33
Signed-off-by: Chris Lew <clew@codeaurora.org>
Qrtr node list lock can be taken recursively by a thread and
in between other thread can contend the same lock for write,
this marks the lock as write biased and results in deadlock.
Changed qrtr code to avoid taking node list lock recursively
and prevent possible deadlock scenario.
CR-Fixed: 2384092
Change-Id: Idcdd1b3dbc8c19867c8afcde40ae4dcf08d87d66
Signed-off-by: Deepak Kumar Singh <deesin@codeaurora.org>
Add the DEL_PROC control message for forwarding usecases. If this proc
acts as a gateway between two procs then they need a notification to
clean up servers and client ports when either goes down. This message
acts as notification to clean up all resources associated with the node
in the message.
Change-Id: I3514f54aa0221e104196e2120e929cc9f351847d
Signed-off-by: Chris Lew <clew@codeaurora.org>
Add support for QRTR to forward messages between network clusters. The
network subnet id's are attached to the QRTR subnodes in the MHI and
RPMSG/GLINK nodes.
The current forwarding decisions are done based on the net ids and are
wrapped in a single function for easier maintenance of forwarding
decisions later on. The function will return true once it determines
a subnet has no connection to another subnet.
The NEW_SERVER, DEL_SERVER, and DEL_CLIENT control messages should be
forwarded while the DATA and RESUME_TX commands should be passed along
to their destination node.
The nameservice is expected to send NEW_SERVER commands for it's entire
database instead of just the local service database with these changes.
This is to make sure new nodes get service notifications that came
earlier and were meant to be forwarded to the new node.
Change-Id: Ia6a1e952430f7d63bf361bc3f2427d492e982d96
Signed-off-by: Chris Lew <clew@codeaurora.org>
sk_error_report callback function called without validating cause the NULL
pointer dereference.
Validate function pointer before using for error report.
Change-Id: I19d04f85a5457f3857623088f8e0578514f0c395
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Add QRTR communication support between two virtual machines
by using shared FIFO and virtual IRQs.
Change-Id: I8fd2115a6ad5acd9a6dac2fa511860a8a68c16ee
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
Some transports need to know qrtr packet to read complete packet
from underlying transport.
Add API support to get the incoming packet size form qrtr header.
Change-Id: I4e4e4ab2e4c1fe0e1e1261af85a8b8618ce65bb3
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>
The destination port value in the IPCR control buffer on older
targets is 0xFFFF. Handle the same by updating the dst_port to
QRTR_PORT_CTRL.
Change-Id: Ia70ce1c078ea84f0de47240f6fc3e764f4ae7a6f
Signed-off-by: Ajay Agarwal <ajaya@codeaurora.org>
Add QRTR communication support between two virtual machines
by using shared FIFO and virtual IRQs.
Change-Id: I8fd2115a6ad5acd9a6dac2fa511860a8a68c16ee
Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org>