* [PATCH net] net/mlx4_core: Fix to clean devlink resources
From: Tariq Toukan @ 2016-09-20 11:55 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Eran Ben Elisha, Kamal Heib, Tariq Toukan
From: Kamal Heib <kamalh@mellanox.com>
This patch cleans devlink resources by calling devlink_port_unregister()
to avoid the following issues:
- Kernel panic when triggering reset flow.
- Memory leak due to unfreed resources in mlx4_init_port_info().
Fixes: 09d4d087cd48 ("mlx4: Implement devlink interface")
Signed-off-by: Kamal Heib <kamalh@mellanox.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
Please push it to -stable >= 4.6 as well. Thanks.
drivers/net/ethernet/mellanox/mlx4/main.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 75dd2e3d3059..7183ac4135d2 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -2970,6 +2970,7 @@ static int mlx4_init_port_info(struct mlx4_dev *dev, int port)
mlx4_err(dev, "Failed to create mtu file for port %d\n", port);
device_remove_file(&info->dev->persist->pdev->dev,
&info->port_attr);
+ devlink_port_unregister(&info->devlink_port);
info->port = -1;
}
@@ -2984,6 +2985,8 @@ static void mlx4_cleanup_port_info(struct mlx4_port_info *info)
device_remove_file(&info->dev->persist->pdev->dev, &info->port_attr);
device_remove_file(&info->dev->persist->pdev->dev,
&info->port_mtu_attr);
+ devlink_port_unregister(&info->devlink_port);
+
#ifdef CONFIG_RFS_ACCEL
free_irq_cpu_rmap(info->rmap);
info->rmap = NULL;
--
1.8.3.1
^ permalink raw reply related
* UBSAN reports issue in ip_idents_reserve
From: Jiri Pirko @ 2016-09-20 12:00 UTC (permalink / raw)
To: netdev, eric.dumazet
Hi.
I'm consistently getting following UBSAN warning on every bootup:
[ 47.545820] ================================================================================
[ 47.554340] UBSAN: Undefined behaviour in ./arch/x86/include/asm/atomic.h:156:11
[ 47.561808] signed integer overflow:
[ 47.565420] -2117905507 + -695755206 cannot be represented in type 'int'
[ 47.572226] CPU: 0 PID: 389 Comm: ntpd Not tainted 4.8.0-rc6jiri+ #1
[ 47.578636] Hardware name: Mellanox Technologies Ltd. Mellanox switch/Mellanox switch, BIOS 4.6.5 05/21/2015
[ 47.588586] ffffffff847bf8c0 00000000987b8f47 ffff8803829af5a8 ffffffff818354e3
[ 47.596165] 0000000041b58ab3 ffffffff8277e711 ffffffff81835431 ffff8803829af5d0
[ 47.603722] ffff8803829af580 ffffffffd6879e3a 1ffffffff08f8214 ffffed0070535e6c
[ 47.611298] Call Trace:
[ 47.613795] [<ffffffff818354e3>] dump_stack+0xb2/0x10f
[ 47.619077] [<ffffffff81835431>] ? _atomic_dec_and_lock+0xa1/0xa1
[ 47.625327] [<ffffffff818a884f>] ubsan_epilogue+0xd/0x4e
[ 47.630811] [<ffffffff818a9821>] handle_overflow+0x190/0x1de
[ 47.636627] [<ffffffff818a9691>] ? __ubsan_handle_negate_overflow+0x140/0x140
[ 47.643914] [<ffffffff81863130>] ? iov_iter_copy_from_user_atomic+0x6e0/0x6e0
[ 47.651219] [<ffffffff811e6f79>] ? __lock_acquire.isra.17+0xb79/0xe50
[ 47.657832] [<ffffffff81e581f2>] ? ip_generic_getfrag+0xd2/0x190
[ 47.664011] [<ffffffff81e58120>] ? ip_setup_cork+0x320/0x320
[ 47.669827] [<ffffffff818a987d>] __ubsan_handle_add_overflow+0xe/0x10
[ 47.676444] [<ffffffff81e41d52>] ip_idents_reserve+0xb2/0xe0
[ 47.682254] [<ffffffff81e443e9>] __ip_select_ident+0x159/0x1b0
[ 47.688248] [<ffffffff81e44290>] ? update_or_create_fnhe+0x850/0x850
[ 47.694782] [<ffffffff81e58120>] ? ip_setup_cork+0x320/0x320
[ 47.700624] [<ffffffff81e5ef40>] __ip_make_skb+0x8a0/0xab0
[ 47.706259] [<ffffffff81e5f3fd>] ip_make_skb+0x17d/0x1d0
[ 47.711717] [<ffffffff81e58120>] ? ip_setup_cork+0x320/0x320
[ 47.717526] [<ffffffff81e5f280>] ? ip_flush_pending_frames+0x20/0x20
[ 47.724032] [<ffffffff81e46ef0>] ? ip_rt_update_pmtu+0x4f0/0x4f0
[ 47.730231] [<ffffffff81f35291>] ? xfrm_lookup_route+0x21/0xe0
[ 47.736216] [<ffffffff81ec0cdb>] udp_sendmsg+0x9db/0xf60
[ 47.741668] [<ffffffff81e58120>] ? ip_setup_cork+0x320/0x320
[ 47.747472] [<ffffffff81ec0300>] ? udp_abort+0x70/0x70
[ 47.752763] [<ffffffff81ede3d8>] inet_sendmsg+0x198/0x220
[ 47.758324] [<ffffffff81ede292>] ? inet_sendmsg+0x52/0x220
[ 47.763982] [<ffffffff81ede240>] ? inet_recvmsg+0x300/0x300
[ 47.769728] [<ffffffff81d6fd25>] sock_sendmsg+0xa5/0xd0
[ 47.775100] [<ffffffff81d72f70>] SYSC_sendto+0x1d0/0x280
[ 47.780551] [<ffffffff81d72da0>] ? SYSC_connect+0x200/0x200
[ 47.786283] [<ffffffff814f66df>] ? poll_select_copy_remaining+0x2af/0x310
[ 47.793265] [<ffffffff814f6430>] ? set_fd_set+0x60/0x60
[ 47.798665] [<ffffffff811ee360>] ? do_raw_spin_trylock+0x90/0x90
[ 47.804853] [<ffffffff814f80e3>] ? SyS_select+0x1a3/0x200
[ 47.810399] [<ffffffff814f7f40>] ? core_sys_select+0x570/0x570
[ 47.816415] [<ffffffff8100467c>] ? exit_to_usermode_loop+0xec/0x110
[ 47.822842] [<ffffffff811e8abd>] ? lockdep_sys_exit+0x2d/0xb0
[ 47.828769] [<ffffffff81004016>] ? lockdep_sys_exit_thunk+0x16/0x30
[ 47.835199] [<ffffffff81d7433e>] SyS_sendto+0xe/0x10
[ 47.840321] [<ffffffff820381f2>] entry_SYSCALL_64_fastpath+0x1a/0xa9
[ 47.846826] ================================================================================
Looks like this might be result of following commit:
commit 04ca6973f7c1a0d8537f2d9906a0cf8e69886d75
Author: Eric Dumazet <edumazet@google.com>
Date: Sat Jul 26 08:58:10 2014 +0200
ip: make IP identifiers less predictable
Eric, could you please take look at that?
Thanks.
Jiri
^ permalink raw reply
* Re: [RFC v2 00/11] QLogic RDMA Driver (qedr) RFC
From: Leon Romanovsky @ 2016-09-20 12:11 UTC (permalink / raw)
To: Ram Amrani
Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q, dledford-H+wXaHxf7aLQT0dZR+AlfA,
Ariel.Elior-YGCgFSpz5w/QT0dZR+AlfA,
Michal.Kalderon-YGCgFSpz5w/QT0dZR+AlfA,
Yuval.Mintz-YGCgFSpz5w/QT0dZR+AlfA,
rajesh.borundia-YGCgFSpz5w/QT0dZR+AlfA,
linux-rdma-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1474367764-9555-1-git-send-email-Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 1476 bytes --]
On Tue, Sep 20, 2016 at 01:35:52PM +0300, Ram Amrani wrote:
> From: Ram amrani <Ram.Amrani-YGCgFSpz5w/QT0dZR+AlfA@public.gmane.org>
>
> This series introduces RoCE RDMA driver for the 579xx RDMA products by Qlogic.
> The RDMA support is added as an additional loadable module (qedr) over the
> Ethernet qede driver.
> The qedr module will support both RoCE and iWarp, although this series only
> adds RoCE support.
> The qed and qede drivers are enhanced with functionality required for RDMA
> support.
>
> Based on net-next 4c73195edbe3a5d7e14ea549bb261cf35c29f0cc.
>
> The series adds on top of RFC v1:
> * a check for all drivers that IB_ACCESS_MW_BIND isn't set for ib_get_dma_mr
> * relocation of qedr user API to include/rdma/uapi/providers/
> * removal of qedr_devlist_local
> * fixed error handling in qedr_alloc_resources()
> * configuration of PBL in ib_map_mr_sg() driver implementation,
> rather than post_send's IB_WR_REG_MR
> * misc.: placed code in proper patch, fixed a few comments,
> removed extra parentheses
>
> Thanks for everyone which pointed out problems in the driver.
>
> Any review/comment is appreciated.
Very nice,
Any reason why didn't you drop debug module parameter and decided to
mimic already available kernel core functionality?
You got technical explanations why it is bad idea to use it. If you need additional voices
to support my claims, you will find them in thread about VERBOSE flag and responses from
Doug, and Dennis.
Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply
* Re: [PATCH net-next 6/7] net/faraday: Fix phy link irq on Aspeed G5 SoCs
From: Benjamin Herrenschmidt @ 2016-09-20 12:13 UTC (permalink / raw)
To: Joel Stanley, davem; +Cc: gwshan, andrew, andrew, netdev, linux-kernel
In-Reply-To: <20160920063007.24291-7-joel@jms.id.au>
On Tue, 2016-09-20 at 16:00 +0930, Joel Stanley wrote:
> On Aspeed SoC with a direct PHY connection (non-NSCI), we receive
> continual PHYSTS interrupts:
>
> [ 20.280000] ftgmac100 1e660000.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
> [ 20.280000] ftgmac100 1e660000.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
> [ 20.280000] ftgmac100 1e660000.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
> [ 20.300000] ftgmac100 1e660000.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
>
> This is because the driver was enabling low-level sensitive interrupt
> generation where the systems are wired for high-level. All CPU cycles
> are spent servicing this interrupt.
If this is a system wiring issue, should it be represented by a DT
property ?
Cheers,
Ben.
^ permalink raw reply
* Re: [PATCH net-next 6/7] net/faraday: Fix phy link irq on Aspeed G5 SoCs
From: Sergei Shtylyov @ 2016-09-20 12:14 UTC (permalink / raw)
To: Joel Stanley, davem; +Cc: gwshan, andrew, andrew, netdev, linux-kernel, benh
In-Reply-To: <20160920063007.24291-7-joel@jms.id.au>
Hello.
On 9/20/2016 9:30 AM, Joel Stanley wrote:
> On Aspeed SoC with a direct PHY connection (non-NSCI), we receive
> continual PHYSTS interrupts:
>
> [ 20.280000] ftgmac100 1e660000.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
> [ 20.280000] ftgmac100 1e660000.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
> [ 20.280000] ftgmac100 1e660000.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
> [ 20.300000] ftgmac100 1e660000.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
>
> This is because the driver was enabling low-level sensitive interrupt
> generation where the systems are wired for high-level. All CPU cycles
> are spent servicing this interrupt.
>
> Signed-off-by: Joel Stanley <joel@jms.id.au>
> ---
> drivers/net/ethernet/faraday/ftgmac100.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
> index 7ba0f2d58a8b..5466df028381 100644
> --- a/drivers/net/ethernet/faraday/ftgmac100.c
> +++ b/drivers/net/ethernet/faraday/ftgmac100.c
> @@ -223,6 +223,10 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv, int speed)
> {
> int maccr = MACCR_ENABLE_ALL;
>
> + if (of_machine_is_compatible("aspeed,ast2500")) {
> + maccr &= ~FTGMAC100_MACCR_PHY_LINK_LEVEL;
> + }
{} not needed here.
[...]
MBR, Sergei
^ permalink raw reply
* Re: [PATCH net-next V2 3/4] net/mlx4_core: Use RCU to perform radix tree lookup for SRQ
From: Sergei Shtylyov @ 2016-09-20 12:47 UTC (permalink / raw)
To: Tariq Toukan, David S. Miller; +Cc: netdev, Eran Ben Elisha, Leon Romanovsky
In-Reply-To: <1474371582-998-4-git-send-email-tariqt@mellanox.com>
Hello.
On 9/20/2016 2:39 PM, Tariq Toukan wrote:
> From: Leon Romanovsky <leonro@mellanox.com>
>
> Radix tree lookup can be performed without locking.
>
> Fixes: 225c7b1feef1 ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters")
> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> Suggested-by: Sagi Grimberg <sagi@grimberg.me>
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/srq.c | 14 +++++---------
> 1 file changed, 5 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c
> index 67146624eb58..f44d089e2ca6 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/srq.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/srq.c
> @@ -45,15 +45,12 @@ void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type)
> struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
> struct mlx4_srq *srq;
>
> - spin_lock(&srq_table->lock);
> -
> + rcu_read_lock();
> srq = radix_tree_lookup(&srq_table->tree, srqn & (dev->caps.num_srqs - 1));
> + rcu_read_unlock();
> if (srq)
> atomic_inc(&srq->refcount);
> -
> - spin_unlock(&srq_table->lock);
> -
> - if (!srq) {
> + else {
> mlx4_warn(dev, "Async event for bogus SRQ %08x\n", srqn);
> return;
> }
CodingStyle: all branches of the *if* statement should have {} if at least
one has.
[...]
MBR, Sergei
^ permalink raw reply
* Re: [PATCH v3] iproute2: build nsid-name cache only for commands that need it
From: Nicolas Dichtel @ 2016-09-20 12:52 UTC (permalink / raw)
To: Anton Aksola, netdev; +Cc: vadim4j
In-Reply-To: <20160920060123.GA17211@toys.tundra.dog-lvm.novalocal>
Le 20/09/2016 à 08:01, Anton Aksola a écrit :
> The calling of netns_map_init() before command parsing introduced
> a performance issue with large number of namespaces.
>
> As commands such as add, del and exec do not need to iterate through
> /var/run/netns it would be good not no build the cache before executing
> these commands.
>
> Example:
> unpatched:
> time seq 1 1000 | xargs -n 1 ip netns add
>
> real 0m16.832s
> user 0m1.350s
> sys 0m15.029s
>
> patched:
> time seq 1 1000 | xargs -n 1 ip netns add
>
> real 0m3.859s
> user 0m0.132s
> sys 0m3.205s
>
> Signed-off-by: Anton Aksola <aakso@iki.fi>
Acked-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
^ permalink raw reply
* Re: [PATCH net-next 7/8] net/mlx5e: XDP TX forwarding support
From: Tariq Toukan @ 2016-09-20 12:53 UTC (permalink / raw)
To: Jesper Dangaard Brouer, Tariq Toukan
Cc: David S. Miller, netdev, Eran Ben Elisha, Saeed Mahameed,
Rana Shahout
In-Reply-To: <20160920133300.144037fd@redhat.com>
On 20/09/2016 2:33 PM, Jesper Dangaard Brouer wrote:
> Resending, email didn't reach the list (used wrong sender email)
>
> On Tue, 20 Sep 2016 10:29:43 +0200 Jesper Dangaard Brouer <netdev@brouer.com> wrote:
>
>> On Mon, 19 Sep 2016 16:58:58 +0300 Tariq Toukan <tariqt@mellanox.com> wrote:
>>
>>> + act = bpf_prog_run_xdp(prog, &xdp);
>>> + switch (act) {
>>> + case XDP_PASS:
>>> + return false;
>>> + case XDP_TX:
>>> + consumed = mlx5e_xmit_xdp_frame(&rq->channel->xdp_sq, di,
>>> + MLX5_RX_HEADROOM,
>>> + len);
>>> + rq->stats.xdp_tx += consumed;
>>> + return consumed;
>>> + default:
>>> + bpf_warn_invalid_xdp_action(act);
>>> + return false;
>> This looks wrong. According to the specification[1] and comment in the
>> code /include/uapi/linux/bpf.h: "Unknown return codes will result in
>> packet drop"
I'll fix this.
>>> + case XDP_ABORTED:
>> It is not clearly defined, but I believe XDP_ABORTED should also result
>> in a warning (calling bpf_warn_invalid_xdp_action(act)).
I'll add this.
>>
>>
>>> + case XDP_DROP:
>>> + rq->stats.xdp_drop++;
>>> + mlx5e_page_release(rq, di, true);
>>> + return true;
>>> + }
>>
>> I've started documenting XDP[2], as this patch clearly shows there is a
>> need to have a specification, given already the second driver
>> supporting XDP gets these details wrong.
Indeed. Thanks for doing this.
>> [1] https://prototype-kernel.readthedocs.io/en/latest/networking/XDP/implementation/xdp_actions.html#xdp-aborted
>>
>> [2] https://prototype-kernel.readthedocs.io/en/latest/networking/XDP/index.html
>>
Regards,
Tariq
^ permalink raw reply
* [PATCH net-next 0/8] net: qualcomm: add QCA7000 UART driver
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
The Qualcomm QCA7000 HomePlug GreenPHY supports two interfaces:
UART and SPI. This patch series adds the missing support for UART.
This driver based on the Qualcomm code [1], but contains some changes:
* use random MAC address per default
* use net_device_stats from device
* share frame decoding between SPI and UART driver
* improve error handling
* reimplement tty_wakeup with work queue (based on slcan)
The patches 1 - 3 are just for clean up and are not related to
the UART support. Patches 4 - 7 prepare the existing QCA7000
code for UART support. The last patch contains the new driver.
In order to test the driver a modified slattach in userspace is also
required. A prepared busybox (includes slattach) can be found here [2].
The code itself has been tested on a Freescale i.MX28 board.
[1] - https://github.com/IoE/qca7000
[2] - https://github.com/lategoodbye/busybox/commits/qca7k_support_1_24
Stefan Wahren (8):
net: qualcomm: remove unnecessary includes
net: qca_debug: use net_device_ops instead of direct call
net: qualcomm: move qcaspi_tx_cmd to qca_spi.c
net: qualcomm: rename qca_framing.c to qca_common.c
net: qualcomm: move MTU handling to qca_common
net: qualcomm: prepare frame decoding for UART driver
net: qualcomm: make qca_common a separate kernel module
net: qualcomm: add QCA7000 UART driver
drivers/net/ethernet/qualcomm/Kconfig | 20 +-
drivers/net/ethernet/qualcomm/Makefile | 7 +-
drivers/net/ethernet/qualcomm/qca_7k.c | 28 --
drivers/net/ethernet/qualcomm/qca_7k.h | 1 -
drivers/net/ethernet/qualcomm/qca_common.c | 178 +++++++++++
drivers/net/ethernet/qualcomm/qca_common.h | 147 +++++++++
drivers/net/ethernet/qualcomm/qca_debug.c | 5 +-
drivers/net/ethernet/qualcomm/qca_framing.c | 156 ----------
drivers/net/ethernet/qualcomm/qca_framing.h | 134 ---------
drivers/net/ethernet/qualcomm/qca_spi.c | 41 ++-
drivers/net/ethernet/qualcomm/qca_spi.h | 5 +-
drivers/net/ethernet/qualcomm/qca_uart.c | 447 ++++++++++++++++++++++++++++
include/uapi/linux/tty.h | 1 +
13 files changed, 828 insertions(+), 342 deletions(-)
create mode 100644 drivers/net/ethernet/qualcomm/qca_common.c
create mode 100644 drivers/net/ethernet/qualcomm/qca_common.h
delete mode 100644 drivers/net/ethernet/qualcomm/qca_framing.c
delete mode 100644 drivers/net/ethernet/qualcomm/qca_framing.h
create mode 100644 drivers/net/ethernet/qualcomm/qca_uart.c
--
2.1.4
^ permalink raw reply
* [PATCH net-next 1/8] net: qualcomm: remove unnecessary includes
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
In-Reply-To: <1474376544-20515-1-git-send-email-stefan.wahren@i2se.com>
Most of the includes in qca_7k.c are unnecessary so we better remove them.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_7k.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_7k.c b/drivers/net/ethernet/qualcomm/qca_7k.c
index f0066fb..557d53c 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.c
+++ b/drivers/net/ethernet/qualcomm/qca_7k.c
@@ -23,11 +23,7 @@
* kernel-based SPI device.
*/
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/moduleparam.h>
#include <linux/spi/spi.h>
-#include <linux/version.h>
#include "qca_7k.h"
--
2.1.4
^ permalink raw reply related
* [PATCH net-next 2/8] net: qca_debug: use net_device_ops instead of direct call
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
In-Reply-To: <1474376544-20515-1-git-send-email-stefan.wahren@i2se.com>
There is no need to export qcaspi_netdev_open and qcaspi_netdev_close
because they are also accessible via the net_device_ops.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_debug.c | 5 +++--
drivers/net/ethernet/qualcomm/qca_spi.h | 3 ---
2 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_debug.c b/drivers/net/ethernet/qualcomm/qca_debug.c
index 8e28234..851bf07 100644
--- a/drivers/net/ethernet/qualcomm/qca_debug.c
+++ b/drivers/net/ethernet/qualcomm/qca_debug.c
@@ -273,6 +273,7 @@ qcaspi_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
static int
qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
{
+ const struct net_device_ops *ops = dev->netdev_ops;
struct qcaspi *qca = netdev_priv(dev);
if ((ring->rx_pending) ||
@@ -281,13 +282,13 @@ qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)
return -EINVAL;
if (netif_running(dev))
- qcaspi_netdev_close(dev);
+ ops->ndo_stop(dev);
qca->txr.count = max_t(u32, ring->tx_pending, TX_RING_MIN_LEN);
qca->txr.count = min_t(u16, qca->txr.count, TX_RING_MAX_LEN);
if (netif_running(dev))
- qcaspi_netdev_open(dev);
+ ops->ndo_open(dev);
return 0;
}
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h
index 6e31a0e..064853d 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.h
+++ b/drivers/net/ethernet/qualcomm/qca_spi.h
@@ -108,7 +108,4 @@ struct qcaspi {
u16 burst_len;
};
-int qcaspi_netdev_open(struct net_device *dev);
-int qcaspi_netdev_close(struct net_device *dev);
-
#endif /* _QCA_SPI_H */
--
2.1.4
^ permalink raw reply related
* [PATCH net-next 3/8] net: qualcomm: move qcaspi_tx_cmd to qca_spi.c
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
In-Reply-To: <1474376544-20515-1-git-send-email-stefan.wahren@i2se.com>
The function qcaspi_tx_cmd() is only called from qca_spi.c. So we better
move it there.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_7k.c | 24 ------------------------
drivers/net/ethernet/qualcomm/qca_7k.h | 1 -
drivers/net/ethernet/qualcomm/qca_spi.c | 24 ++++++++++++++++++++++++
3 files changed, 24 insertions(+), 25 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_7k.c b/drivers/net/ethernet/qualcomm/qca_7k.c
index 557d53c..aa90a1d 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.c
+++ b/drivers/net/ethernet/qualcomm/qca_7k.c
@@ -119,27 +119,3 @@ qcaspi_write_register(struct qcaspi *qca, u16 reg, u16 value)
return ret;
}
-
-int
-qcaspi_tx_cmd(struct qcaspi *qca, u16 cmd)
-{
- __be16 tx_data;
- struct spi_message *msg = &qca->spi_msg1;
- struct spi_transfer *transfer = &qca->spi_xfer1;
- int ret;
-
- tx_data = cpu_to_be16(cmd);
- transfer->len = sizeof(tx_data);
- transfer->tx_buf = &tx_data;
- transfer->rx_buf = NULL;
-
- ret = spi_sync(qca->spi_dev, msg);
-
- if (!ret)
- ret = msg->status;
-
- if (ret)
- qcaspi_spi_error(qca);
-
- return ret;
-}
diff --git a/drivers/net/ethernet/qualcomm/qca_7k.h b/drivers/net/ethernet/qualcomm/qca_7k.h
index 1cad851..b390b1f 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k.h
+++ b/drivers/net/ethernet/qualcomm/qca_7k.h
@@ -67,6 +67,5 @@
void qcaspi_spi_error(struct qcaspi *qca);
int qcaspi_read_register(struct qcaspi *qca, u16 reg, u16 *result);
int qcaspi_write_register(struct qcaspi *qca, u16 reg, u16 value);
-int qcaspi_tx_cmd(struct qcaspi *qca, u16 cmd);
#endif /* _QCA_7K_H */
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 6e2add9..5bcac62 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -192,6 +192,30 @@ qcaspi_read_legacy(struct qcaspi *qca, u8 *dst, u32 len)
return len;
}
+int
+qcaspi_tx_cmd(struct qcaspi *qca, u16 cmd)
+{
+ __be16 tx_data;
+ struct spi_message *msg = &qca->spi_msg1;
+ struct spi_transfer *transfer = &qca->spi_xfer1;
+ int ret;
+
+ tx_data = cpu_to_be16(cmd);
+ transfer->len = sizeof(tx_data);
+ transfer->tx_buf = &tx_data;
+ transfer->rx_buf = NULL;
+
+ ret = spi_sync(qca->spi_dev, msg);
+
+ if (!ret)
+ ret = msg->status;
+
+ if (ret)
+ qcaspi_spi_error(qca);
+
+ return ret;
+}
+
static int
qcaspi_tx_frame(struct qcaspi *qca, struct sk_buff *skb)
{
--
2.1.4
^ permalink raw reply related
* [PATCH net-next 4/8] net: qualcomm: rename qca_framing.c to qca_common.c
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
In-Reply-To: <1474376544-20515-1-git-send-email-stefan.wahren@i2se.com>
As preparation for the upcoming UART driver we need a module
which contains common functions for both interfaces. The module
qca_framing is a good candidate but renaming to qca_common would
make it clear.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/Makefile | 2 +-
drivers/net/ethernet/qualcomm/qca_common.c | 156 ++++++++++++++++++++++++++++
drivers/net/ethernet/qualcomm/qca_common.h | 134 ++++++++++++++++++++++++
drivers/net/ethernet/qualcomm/qca_framing.c | 156 ----------------------------
drivers/net/ethernet/qualcomm/qca_framing.h | 134 ------------------------
drivers/net/ethernet/qualcomm/qca_spi.c | 2 +-
drivers/net/ethernet/qualcomm/qca_spi.h | 2 +-
7 files changed, 293 insertions(+), 293 deletions(-)
create mode 100644 drivers/net/ethernet/qualcomm/qca_common.c
create mode 100644 drivers/net/ethernet/qualcomm/qca_common.h
delete mode 100644 drivers/net/ethernet/qualcomm/qca_framing.c
delete mode 100644 drivers/net/ethernet/qualcomm/qca_framing.h
diff --git a/drivers/net/ethernet/qualcomm/Makefile b/drivers/net/ethernet/qualcomm/Makefile
index aacb0a5..8080570 100644
--- a/drivers/net/ethernet/qualcomm/Makefile
+++ b/drivers/net/ethernet/qualcomm/Makefile
@@ -3,6 +3,6 @@
#
obj-$(CONFIG_QCA7000) += qcaspi.o
-qcaspi-objs := qca_spi.o qca_framing.o qca_7k.o qca_debug.o
+qcaspi-objs := qca_spi.o qca_common.o qca_7k.o qca_debug.o
obj-y += emac/
diff --git a/drivers/net/ethernet/qualcomm/qca_common.c b/drivers/net/ethernet/qualcomm/qca_common.c
new file mode 100644
index 0000000..26453a9
--- /dev/null
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2011, 2012, Atheros Communications Inc.
+ * Copyright (c) 2014, I2SE GmbH
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Atheros ethernet framing. Every Ethernet frame is surrounded
+ * by an atheros frame while transmitted over a serial channel;
+ */
+
+#include <linux/kernel.h>
+
+#include "qca_common.h"
+
+u16
+qcafrm_create_header(u8 *buf, u16 length)
+{
+ __le16 len;
+
+ if (!buf)
+ return 0;
+
+ len = cpu_to_le16(length);
+
+ buf[0] = 0xAA;
+ buf[1] = 0xAA;
+ buf[2] = 0xAA;
+ buf[3] = 0xAA;
+ buf[4] = len & 0xff;
+ buf[5] = (len >> 8) & 0xff;
+ buf[6] = 0;
+ buf[7] = 0;
+
+ return QCAFRM_HEADER_LEN;
+}
+
+u16
+qcafrm_create_footer(u8 *buf)
+{
+ if (!buf)
+ return 0;
+
+ buf[0] = 0x55;
+ buf[1] = 0x55;
+ return QCAFRM_FOOTER_LEN;
+}
+
+/* Gather received bytes and try to extract a full ethernet frame by
+ * following a simple state machine.
+ *
+ * Return: QCAFRM_GATHER No ethernet frame fully received yet.
+ * QCAFRM_NOHEAD Header expected but not found.
+ * QCAFRM_INVLEN Atheros frame length is invalid
+ * QCAFRM_NOTAIL Footer expected but not found.
+ * > 0 Number of byte in the fully received
+ * Ethernet frame
+ */
+
+s32
+qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_byte)
+{
+ s32 ret = QCAFRM_GATHER;
+ u16 len;
+
+ switch (handle->state) {
+ case QCAFRM_HW_LEN0:
+ case QCAFRM_HW_LEN1:
+ /* by default, just go to next state */
+ handle->state--;
+
+ if (recv_byte != 0x00) {
+ /* first two bytes of length must be 0 */
+ handle->state = QCAFRM_HW_LEN0;
+ }
+ break;
+ case QCAFRM_HW_LEN2:
+ case QCAFRM_HW_LEN3:
+ handle->state--;
+ break;
+ /* 4 bytes header pattern */
+ case QCAFRM_WAIT_AA1:
+ case QCAFRM_WAIT_AA2:
+ case QCAFRM_WAIT_AA3:
+ case QCAFRM_WAIT_AA4:
+ if (recv_byte != 0xAA) {
+ ret = QCAFRM_NOHEAD;
+ handle->state = QCAFRM_HW_LEN0;
+ } else {
+ handle->state--;
+ }
+ break;
+ /* 2 bytes length. */
+ /* Borrow offset field to hold length for now. */
+ case QCAFRM_WAIT_LEN_BYTE0:
+ handle->offset = recv_byte;
+ handle->state = QCAFRM_WAIT_LEN_BYTE1;
+ break;
+ case QCAFRM_WAIT_LEN_BYTE1:
+ handle->offset = handle->offset | (recv_byte << 8);
+ handle->state = QCAFRM_WAIT_RSVD_BYTE1;
+ break;
+ case QCAFRM_WAIT_RSVD_BYTE1:
+ handle->state = QCAFRM_WAIT_RSVD_BYTE2;
+ break;
+ case QCAFRM_WAIT_RSVD_BYTE2:
+ len = handle->offset;
+ if (len > buf_len || len < QCAFRM_ETHMINLEN) {
+ ret = QCAFRM_INVLEN;
+ handle->state = QCAFRM_HW_LEN0;
+ } else {
+ handle->state = (enum qcafrm_state)(len + 1);
+ /* Remaining number of bytes. */
+ handle->offset = 0;
+ }
+ break;
+ default:
+ /* Receiving Ethernet frame itself. */
+ buf[handle->offset] = recv_byte;
+ handle->offset++;
+ handle->state--;
+ break;
+ case QCAFRM_WAIT_551:
+ if (recv_byte != 0x55) {
+ ret = QCAFRM_NOTAIL;
+ handle->state = QCAFRM_HW_LEN0;
+ } else {
+ handle->state = QCAFRM_WAIT_552;
+ }
+ break;
+ case QCAFRM_WAIT_552:
+ if (recv_byte != 0x55) {
+ ret = QCAFRM_NOTAIL;
+ handle->state = QCAFRM_HW_LEN0;
+ } else {
+ ret = handle->offset;
+ /* Frame is fully received. */
+ handle->state = QCAFRM_HW_LEN0;
+ }
+ break;
+ }
+
+ return ret;
+}
diff --git a/drivers/net/ethernet/qualcomm/qca_common.h b/drivers/net/ethernet/qualcomm/qca_common.h
new file mode 100644
index 0000000..8c9b713
--- /dev/null
+++ b/drivers/net/ethernet/qualcomm/qca_common.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (c) 2011, 2012, Atheros Communications Inc.
+ * Copyright (c) 2014, I2SE GmbH
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* Atheros Ethernet framing. Every Ethernet frame is surrounded by an atheros
+ * frame while transmitted over a serial channel.
+ */
+
+#ifndef _QCA_COMMON_H
+#define _QCA_COMMON_H
+
+#include <linux/if_ether.h>
+#include <linux/if_vlan.h>
+#include <linux/types.h>
+
+/* Frame is currently being received */
+#define QCAFRM_GATHER 0
+
+/* No header byte while expecting it */
+#define QCAFRM_NOHEAD (QCAFRM_ERR_BASE - 1)
+
+/* No tailer byte while expecting it */
+#define QCAFRM_NOTAIL (QCAFRM_ERR_BASE - 2)
+
+/* Frame length is invalid */
+#define QCAFRM_INVLEN (QCAFRM_ERR_BASE - 3)
+
+/* Frame length is invalid */
+#define QCAFRM_INVFRAME (QCAFRM_ERR_BASE - 4)
+
+/* Min/Max Ethernet MTU */
+#define QCAFRM_ETHMINMTU 46
+#define QCAFRM_ETHMAXMTU 1500
+
+/* Min/Max frame lengths */
+#define QCAFRM_ETHMINLEN (QCAFRM_ETHMINMTU + ETH_HLEN)
+#define QCAFRM_ETHMAXLEN (QCAFRM_ETHMAXMTU + VLAN_ETH_HLEN)
+
+/* QCA7K header len */
+#define QCAFRM_HEADER_LEN 8
+
+/* QCA7K footer len */
+#define QCAFRM_FOOTER_LEN 2
+
+/* QCA7K Framing. */
+#define QCAFRM_ERR_BASE -1000
+
+enum qcafrm_state {
+ QCAFRM_HW_LEN0 = 0x8000,
+ QCAFRM_HW_LEN1 = QCAFRM_HW_LEN0 - 1,
+ QCAFRM_HW_LEN2 = QCAFRM_HW_LEN1 - 1,
+ QCAFRM_HW_LEN3 = QCAFRM_HW_LEN2 - 1,
+
+ /* Waiting first 0xAA of header */
+ QCAFRM_WAIT_AA1 = QCAFRM_HW_LEN3 - 1,
+
+ /* Waiting second 0xAA of header */
+ QCAFRM_WAIT_AA2 = QCAFRM_WAIT_AA1 - 1,
+
+ /* Waiting third 0xAA of header */
+ QCAFRM_WAIT_AA3 = QCAFRM_WAIT_AA2 - 1,
+
+ /* Waiting fourth 0xAA of header */
+ QCAFRM_WAIT_AA4 = QCAFRM_WAIT_AA3 - 1,
+
+ /* Waiting Byte 0-1 of length (litte endian) */
+ QCAFRM_WAIT_LEN_BYTE0 = QCAFRM_WAIT_AA4 - 1,
+ QCAFRM_WAIT_LEN_BYTE1 = QCAFRM_WAIT_AA4 - 2,
+
+ /* Reserved bytes */
+ QCAFRM_WAIT_RSVD_BYTE1 = QCAFRM_WAIT_AA4 - 3,
+ QCAFRM_WAIT_RSVD_BYTE2 = QCAFRM_WAIT_AA4 - 4,
+
+ /* The frame length is used as the state until
+ * the end of the Ethernet frame
+ * Waiting for first 0x55 of footer
+ */
+ QCAFRM_WAIT_551 = 1,
+
+ /* Waiting for second 0x55 of footer */
+ QCAFRM_WAIT_552 = QCAFRM_WAIT_551 - 1
+};
+
+/* Structure to maintain the frame decoding during reception. */
+
+struct qcafrm_handle {
+ /* Current decoding state */
+ enum qcafrm_state state;
+
+ /* Offset in buffer (borrowed for length too) */
+ s16 offset;
+
+ /* Frame length as kept by this module */
+ u16 len;
+};
+
+u16 qcafrm_create_header(u8 *buf, u16 len);
+
+u16 qcafrm_create_footer(u8 *buf);
+
+static inline void qcafrm_fsm_init(struct qcafrm_handle *handle)
+{
+ handle->state = QCAFRM_HW_LEN0;
+}
+
+/* Gather received bytes and try to extract a full Ethernet frame
+ * by following a simple state machine.
+ *
+ * Return: QCAFRM_GATHER No Ethernet frame fully received yet.
+ * QCAFRM_NOHEAD Header expected but not found.
+ * QCAFRM_INVLEN QCA7K frame length is invalid
+ * QCAFRM_NOTAIL Footer expected but not found.
+ * > 0 Number of byte in the fully received
+ * Ethernet frame
+ */
+
+s32 qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_byte);
+
+#endif /* _QCA_COMMON_H */
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.c b/drivers/net/ethernet/qualcomm/qca_framing.c
deleted file mode 100644
index faa924c..0000000
--- a/drivers/net/ethernet/qualcomm/qca_framing.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Atheros Communications Inc.
- * Copyright (c) 2014, I2SE GmbH
- *
- * Permission to use, copy, modify, and/or distribute this software
- * for any purpose with or without fee is hereby granted, provided
- * that the above copyright notice and this permission notice appear
- * in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* Atheros ethernet framing. Every Ethernet frame is surrounded
- * by an atheros frame while transmitted over a serial channel;
- */
-
-#include <linux/kernel.h>
-
-#include "qca_framing.h"
-
-u16
-qcafrm_create_header(u8 *buf, u16 length)
-{
- __le16 len;
-
- if (!buf)
- return 0;
-
- len = cpu_to_le16(length);
-
- buf[0] = 0xAA;
- buf[1] = 0xAA;
- buf[2] = 0xAA;
- buf[3] = 0xAA;
- buf[4] = len & 0xff;
- buf[5] = (len >> 8) & 0xff;
- buf[6] = 0;
- buf[7] = 0;
-
- return QCAFRM_HEADER_LEN;
-}
-
-u16
-qcafrm_create_footer(u8 *buf)
-{
- if (!buf)
- return 0;
-
- buf[0] = 0x55;
- buf[1] = 0x55;
- return QCAFRM_FOOTER_LEN;
-}
-
-/* Gather received bytes and try to extract a full ethernet frame by
- * following a simple state machine.
- *
- * Return: QCAFRM_GATHER No ethernet frame fully received yet.
- * QCAFRM_NOHEAD Header expected but not found.
- * QCAFRM_INVLEN Atheros frame length is invalid
- * QCAFRM_NOTAIL Footer expected but not found.
- * > 0 Number of byte in the fully received
- * Ethernet frame
- */
-
-s32
-qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_byte)
-{
- s32 ret = QCAFRM_GATHER;
- u16 len;
-
- switch (handle->state) {
- case QCAFRM_HW_LEN0:
- case QCAFRM_HW_LEN1:
- /* by default, just go to next state */
- handle->state--;
-
- if (recv_byte != 0x00) {
- /* first two bytes of length must be 0 */
- handle->state = QCAFRM_HW_LEN0;
- }
- break;
- case QCAFRM_HW_LEN2:
- case QCAFRM_HW_LEN3:
- handle->state--;
- break;
- /* 4 bytes header pattern */
- case QCAFRM_WAIT_AA1:
- case QCAFRM_WAIT_AA2:
- case QCAFRM_WAIT_AA3:
- case QCAFRM_WAIT_AA4:
- if (recv_byte != 0xAA) {
- ret = QCAFRM_NOHEAD;
- handle->state = QCAFRM_HW_LEN0;
- } else {
- handle->state--;
- }
- break;
- /* 2 bytes length. */
- /* Borrow offset field to hold length for now. */
- case QCAFRM_WAIT_LEN_BYTE0:
- handle->offset = recv_byte;
- handle->state = QCAFRM_WAIT_LEN_BYTE1;
- break;
- case QCAFRM_WAIT_LEN_BYTE1:
- handle->offset = handle->offset | (recv_byte << 8);
- handle->state = QCAFRM_WAIT_RSVD_BYTE1;
- break;
- case QCAFRM_WAIT_RSVD_BYTE1:
- handle->state = QCAFRM_WAIT_RSVD_BYTE2;
- break;
- case QCAFRM_WAIT_RSVD_BYTE2:
- len = handle->offset;
- if (len > buf_len || len < QCAFRM_ETHMINLEN) {
- ret = QCAFRM_INVLEN;
- handle->state = QCAFRM_HW_LEN0;
- } else {
- handle->state = (enum qcafrm_state)(len + 1);
- /* Remaining number of bytes. */
- handle->offset = 0;
- }
- break;
- default:
- /* Receiving Ethernet frame itself. */
- buf[handle->offset] = recv_byte;
- handle->offset++;
- handle->state--;
- break;
- case QCAFRM_WAIT_551:
- if (recv_byte != 0x55) {
- ret = QCAFRM_NOTAIL;
- handle->state = QCAFRM_HW_LEN0;
- } else {
- handle->state = QCAFRM_WAIT_552;
- }
- break;
- case QCAFRM_WAIT_552:
- if (recv_byte != 0x55) {
- ret = QCAFRM_NOTAIL;
- handle->state = QCAFRM_HW_LEN0;
- } else {
- ret = handle->offset;
- /* Frame is fully received. */
- handle->state = QCAFRM_HW_LEN0;
- }
- break;
- }
-
- return ret;
-}
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.h b/drivers/net/ethernet/qualcomm/qca_framing.h
deleted file mode 100644
index 5d96595..0000000
--- a/drivers/net/ethernet/qualcomm/qca_framing.h
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2011, 2012, Atheros Communications Inc.
- * Copyright (c) 2014, I2SE GmbH
- *
- * Permission to use, copy, modify, and/or distribute this software
- * for any purpose with or without fee is hereby granted, provided
- * that the above copyright notice and this permission notice appear
- * in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
- * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
- * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
- * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-/* Atheros Ethernet framing. Every Ethernet frame is surrounded by an atheros
- * frame while transmitted over a serial channel.
- */
-
-#ifndef _QCA_FRAMING_H
-#define _QCA_FRAMING_H
-
-#include <linux/if_ether.h>
-#include <linux/if_vlan.h>
-#include <linux/types.h>
-
-/* Frame is currently being received */
-#define QCAFRM_GATHER 0
-
-/* No header byte while expecting it */
-#define QCAFRM_NOHEAD (QCAFRM_ERR_BASE - 1)
-
-/* No tailer byte while expecting it */
-#define QCAFRM_NOTAIL (QCAFRM_ERR_BASE - 2)
-
-/* Frame length is invalid */
-#define QCAFRM_INVLEN (QCAFRM_ERR_BASE - 3)
-
-/* Frame length is invalid */
-#define QCAFRM_INVFRAME (QCAFRM_ERR_BASE - 4)
-
-/* Min/Max Ethernet MTU */
-#define QCAFRM_ETHMINMTU 46
-#define QCAFRM_ETHMAXMTU 1500
-
-/* Min/Max frame lengths */
-#define QCAFRM_ETHMINLEN (QCAFRM_ETHMINMTU + ETH_HLEN)
-#define QCAFRM_ETHMAXLEN (QCAFRM_ETHMAXMTU + VLAN_ETH_HLEN)
-
-/* QCA7K header len */
-#define QCAFRM_HEADER_LEN 8
-
-/* QCA7K footer len */
-#define QCAFRM_FOOTER_LEN 2
-
-/* QCA7K Framing. */
-#define QCAFRM_ERR_BASE -1000
-
-enum qcafrm_state {
- QCAFRM_HW_LEN0 = 0x8000,
- QCAFRM_HW_LEN1 = QCAFRM_HW_LEN0 - 1,
- QCAFRM_HW_LEN2 = QCAFRM_HW_LEN1 - 1,
- QCAFRM_HW_LEN3 = QCAFRM_HW_LEN2 - 1,
-
- /* Waiting first 0xAA of header */
- QCAFRM_WAIT_AA1 = QCAFRM_HW_LEN3 - 1,
-
- /* Waiting second 0xAA of header */
- QCAFRM_WAIT_AA2 = QCAFRM_WAIT_AA1 - 1,
-
- /* Waiting third 0xAA of header */
- QCAFRM_WAIT_AA3 = QCAFRM_WAIT_AA2 - 1,
-
- /* Waiting fourth 0xAA of header */
- QCAFRM_WAIT_AA4 = QCAFRM_WAIT_AA3 - 1,
-
- /* Waiting Byte 0-1 of length (litte endian) */
- QCAFRM_WAIT_LEN_BYTE0 = QCAFRM_WAIT_AA4 - 1,
- QCAFRM_WAIT_LEN_BYTE1 = QCAFRM_WAIT_AA4 - 2,
-
- /* Reserved bytes */
- QCAFRM_WAIT_RSVD_BYTE1 = QCAFRM_WAIT_AA4 - 3,
- QCAFRM_WAIT_RSVD_BYTE2 = QCAFRM_WAIT_AA4 - 4,
-
- /* The frame length is used as the state until
- * the end of the Ethernet frame
- * Waiting for first 0x55 of footer
- */
- QCAFRM_WAIT_551 = 1,
-
- /* Waiting for second 0x55 of footer */
- QCAFRM_WAIT_552 = QCAFRM_WAIT_551 - 1
-};
-
-/* Structure to maintain the frame decoding during reception. */
-
-struct qcafrm_handle {
- /* Current decoding state */
- enum qcafrm_state state;
-
- /* Offset in buffer (borrowed for length too) */
- s16 offset;
-
- /* Frame length as kept by this module */
- u16 len;
-};
-
-u16 qcafrm_create_header(u8 *buf, u16 len);
-
-u16 qcafrm_create_footer(u8 *buf);
-
-static inline void qcafrm_fsm_init(struct qcafrm_handle *handle)
-{
- handle->state = QCAFRM_HW_LEN0;
-}
-
-/* Gather received bytes and try to extract a full Ethernet frame
- * by following a simple state machine.
- *
- * Return: QCAFRM_GATHER No Ethernet frame fully received yet.
- * QCAFRM_NOHEAD Header expected but not found.
- * QCAFRM_INVLEN QCA7K frame length is invalid
- * QCAFRM_NOTAIL Footer expected but not found.
- * > 0 Number of byte in the fully received
- * Ethernet frame
- */
-
-s32 qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_byte);
-
-#endif /* _QCA_FRAMING_H */
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 5bcac62..551591d 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -43,8 +43,8 @@
#include <linux/types.h>
#include "qca_7k.h"
+#include "qca_common.h"
#include "qca_debug.h"
-#include "qca_framing.h"
#include "qca_spi.h"
#define MAX_DMA_BURST_LEN 5000
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.h b/drivers/net/ethernet/qualcomm/qca_spi.h
index 064853d..cce4802 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.h
+++ b/drivers/net/ethernet/qualcomm/qca_spi.h
@@ -32,7 +32,7 @@
#include <linux/spi/spi.h>
#include <linux/types.h>
-#include "qca_framing.h"
+#include "qca_common.h"
#define QCASPI_DRV_VERSION "0.2.7-i"
#define QCASPI_DRV_NAME "qcaspi"
--
2.1.4
^ permalink raw reply related
* [PATCH net-next 6/8] net: qualcomm: prepare frame decoding for UART driver
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
In-Reply-To: <1474376544-20515-1-git-send-email-stefan.wahren@i2se.com>
Unfortunately the frame format is not exactly identical between SPI
and UART. In case of SPI there is an additional HW length at the
beginning. So store the initial state to make the decoding state machine
more flexible and easy to extend for UART support.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_common.c | 12 ++++++------
drivers/net/ethernet/qualcomm/qca_common.h | 8 ++++++--
drivers/net/ethernet/qualcomm/qca_spi.c | 2 +-
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_common.c b/drivers/net/ethernet/qualcomm/qca_common.c
index 9020c57..7eefdad 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.c
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -83,7 +83,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
if (recv_byte != 0x00) {
/* first two bytes of length must be 0 */
- handle->state = QCAFRM_HW_LEN0;
+ handle->state = handle->init;
}
break;
case QCAFRM_HW_LEN2:
@@ -97,7 +97,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
case QCAFRM_WAIT_AA4:
if (recv_byte != 0xAA) {
ret = QCAFRM_NOHEAD;
- handle->state = QCAFRM_HW_LEN0;
+ handle->state = handle->init;
} else {
handle->state--;
}
@@ -119,7 +119,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
len = handle->offset;
if (len > buf_len || len < QCAFRM_ETHMINLEN) {
ret = QCAFRM_INVLEN;
- handle->state = QCAFRM_HW_LEN0;
+ handle->state = handle->init;
} else {
handle->state = (enum qcafrm_state)(len + 1);
/* Remaining number of bytes. */
@@ -135,7 +135,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
case QCAFRM_WAIT_551:
if (recv_byte != 0x55) {
ret = QCAFRM_NOTAIL;
- handle->state = QCAFRM_HW_LEN0;
+ handle->state = handle->init;
} else {
handle->state = QCAFRM_WAIT_552;
}
@@ -143,11 +143,11 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
case QCAFRM_WAIT_552:
if (recv_byte != 0x55) {
ret = QCAFRM_NOTAIL;
- handle->state = QCAFRM_HW_LEN0;
+ handle->state = handle->init;
} else {
ret = handle->offset;
/* Frame is fully received. */
- handle->state = QCAFRM_HW_LEN0;
+ handle->state = handle->init;
}
break;
}
diff --git a/drivers/net/ethernet/qualcomm/qca_common.h b/drivers/net/ethernet/qualcomm/qca_common.h
index 0fafaaf..c93cfdf07 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.h
+++ b/drivers/net/ethernet/qualcomm/qca_common.h
@@ -62,6 +62,7 @@
#define QCAFRM_ERR_BASE -1000
enum qcafrm_state {
+ /* HW length is only available on SPI */
QCAFRM_HW_LEN0 = 0x8000,
QCAFRM_HW_LEN1 = QCAFRM_HW_LEN0 - 1,
QCAFRM_HW_LEN2 = QCAFRM_HW_LEN1 - 1,
@@ -102,6 +103,8 @@ enum qcafrm_state {
struct qcafrm_handle {
/* Current decoding state */
enum qcafrm_state state;
+ /* Initial state depends on connection type */
+ enum qcafrm_state init;
/* Offset in buffer (borrowed for length too) */
s16 offset;
@@ -114,9 +117,10 @@ u16 qcafrm_create_header(u8 *buf, u16 len);
u16 qcafrm_create_footer(u8 *buf);
-static inline void qcafrm_fsm_init(struct qcafrm_handle *handle)
+static inline void qcafrm_fsm_init_spi(struct qcafrm_handle *handle)
{
- handle->state = QCAFRM_HW_LEN0;
+ handle->init = QCAFRM_HW_LEN0;
+ handle->state = handle->init;
}
/* Gather received bytes and try to extract a full Ethernet frame
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index e0a5020..36ac07d 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -638,7 +638,7 @@ qcaspi_netdev_open(struct net_device *dev)
qca->intr_req = 1;
qca->intr_svc = 0;
qca->sync = QCASPI_SYNC_UNKNOWN;
- qcafrm_fsm_init(&qca->frm_handle);
+ qcafrm_fsm_init_spi(&qca->frm_handle);
qca->spi_thread = kthread_run((void *)qcaspi_spi_thread,
qca, "%s", dev->name);
--
2.1.4
^ permalink raw reply related
* [PATCH net-next 7/8] net: qualcomm: make qca_common a separate kernel module
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
In-Reply-To: <1474376544-20515-1-git-send-email-stefan.wahren@i2se.com>
In order to share common functions between QCA7000 SPI and UART protocol
driver the qca_common needs to be a separate kernel module.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/Kconfig | 8 +++++++-
drivers/net/ethernet/qualcomm/Makefile | 5 +++--
drivers/net/ethernet/qualcomm/qca_common.c | 11 +++++++++++
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig
index 9ba568d..0d33728 100644
--- a/drivers/net/ethernet/qualcomm/Kconfig
+++ b/drivers/net/ethernet/qualcomm/Kconfig
@@ -16,7 +16,13 @@ config NET_VENDOR_QUALCOMM
if NET_VENDOR_QUALCOMM
config QCA7000
- tristate "Qualcomm Atheros QCA7000 support"
+ tristate
+ help
+ This enables support for the Qualcomm Atheros QCA7000.
+
+config QCA7000_SPI
+ tristate "Qualcomm Atheros QCA7000 SPI support"
+ select QCA7000
depends on SPI_MASTER && OF
---help---
This SPI protocol driver supports the Qualcomm Atheros QCA7000.
diff --git a/drivers/net/ethernet/qualcomm/Makefile b/drivers/net/ethernet/qualcomm/Makefile
index 8080570..00d8729 100644
--- a/drivers/net/ethernet/qualcomm/Makefile
+++ b/drivers/net/ethernet/qualcomm/Makefile
@@ -2,7 +2,8 @@
# Makefile for the Qualcomm network device drivers.
#
-obj-$(CONFIG_QCA7000) += qcaspi.o
-qcaspi-objs := qca_spi.o qca_common.o qca_7k.o qca_debug.o
+obj-$(CONFIG_QCA7000) += qca_common.o
+obj-$(CONFIG_QCA7000_SPI) += qcaspi.o
+qcaspi-objs := qca_7k.o qca_debug.o qca_spi.o
obj-y += emac/
diff --git a/drivers/net/ethernet/qualcomm/qca_common.c b/drivers/net/ethernet/qualcomm/qca_common.c
index 7eefdad..2fa8c18 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.c
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -21,7 +21,9 @@
* by an atheros frame while transmitted over a serial channel;
*/
+#include <linux/init.h>
#include <linux/kernel.h>
+#include <linux/module.h>
#include "qca_common.h"
@@ -46,6 +48,7 @@ qcafrm_create_header(u8 *buf, u16 length)
return QCAFRM_HEADER_LEN;
}
+EXPORT_SYMBOL_GPL(qcafrm_create_header);
u16
qcafrm_create_footer(u8 *buf)
@@ -57,6 +60,7 @@ qcafrm_create_footer(u8 *buf)
buf[1] = 0x55;
return QCAFRM_FOOTER_LEN;
}
+EXPORT_SYMBOL_GPL(qcafrm_create_footer);
/* Gather received bytes and try to extract a full ethernet frame by
* following a simple state machine.
@@ -154,6 +158,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
return ret;
}
+EXPORT_SYMBOL_GPL(qcafrm_fsm_decode);
int
qcacmn_netdev_change_mtu(struct net_device *dev, int new_mtu)
@@ -165,3 +170,9 @@ qcacmn_netdev_change_mtu(struct net_device *dev, int new_mtu)
return 0;
}
+EXPORT_SYMBOL_GPL(qcacmn_netdev_change_mtu);
+
+MODULE_DESCRIPTION("Qualcomm Atheros Common");
+MODULE_AUTHOR("Qualcomm Atheros Communications");
+MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
+MODULE_LICENSE("Dual BSD/GPL");
--
2.1.4
^ permalink raw reply related
* RE: [PATCH net] ipmr, ip6mr: return lastuse relative to now
From: David Laight @ 2016-09-20 12:59 UTC (permalink / raw)
To: 'Nikolay Aleksandrov', netdev@vger.kernel.org
Cc: roopa@cumulusnetworks.com, sashok@cumulusnetworks.com,
davem@davemloft.net
In-Reply-To: <1474362377-22627-1-git-send-email-nikolay@cumulusnetworks.com>
From: Nikolay Aleksandrov
> Sent: 20 September 2016 10:06
> When I introduced the lastuse member I made a subtle error because it was
> returned as an absolute value but that is meaningless to user-space as it
> doesn't allow to see how old exactly an entry is. Let's make it similar to
> how the bridge returns such values and make it relative to "now" (jiffies).
> This allows us to show the actual age of the entries and is much more
> useful (e.g. user-space daemons can age out entries, iproute2 can display
> the lastuse properly).
>
...
> + jiffies_to_clock_t(jiffies -
> + c->mfc_un.res.lastuse),
You probably need to ensure the 'age' isn't negative because
'lastuse' got updated after 'jiffies' was read and there was
a clock interrupt in the gap.
David
^ permalink raw reply
* [PATCH net-next 5/8] net: qualcomm: move MTU handling to qca_common
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
In-Reply-To: <1474376544-20515-1-git-send-email-stefan.wahren@i2se.com>
The MTU of the QCA7000 is independent from it's host interface (UART,SPI).
So move the change_mtu function to qca_common.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_common.c | 11 +++++++++++
drivers/net/ethernet/qualcomm/qca_common.h | 3 +++
drivers/net/ethernet/qualcomm/qca_spi.c | 13 +------------
3 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_common.c b/drivers/net/ethernet/qualcomm/qca_common.c
index 26453a9..9020c57 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.c
+++ b/drivers/net/ethernet/qualcomm/qca_common.c
@@ -154,3 +154,14 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
return ret;
}
+
+int
+qcacmn_netdev_change_mtu(struct net_device *dev, int new_mtu)
+{
+ if ((new_mtu < QCAFRM_ETHMINMTU) || (new_mtu > QCAFRM_ETHMAXMTU))
+ return -EINVAL;
+
+ dev->mtu = new_mtu;
+
+ return 0;
+}
diff --git a/drivers/net/ethernet/qualcomm/qca_common.h b/drivers/net/ethernet/qualcomm/qca_common.h
index 8c9b713..0fafaaf 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.h
+++ b/drivers/net/ethernet/qualcomm/qca_common.h
@@ -26,6 +26,7 @@
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
+#include <linux/netdevice.h>
#include <linux/types.h>
/* Frame is currently being received */
@@ -131,4 +132,6 @@ static inline void qcafrm_fsm_init(struct qcafrm_handle *handle)
s32 qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_byte);
+int qcacmn_netdev_change_mtu(struct net_device *dev, int new_mtu);
+
#endif /* _QCA_COMMON_H */
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 551591d..e0a5020 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -804,24 +804,13 @@ qcaspi_netdev_uninit(struct net_device *dev)
dev_kfree_skb(qca->rx_skb);
}
-static int
-qcaspi_netdev_change_mtu(struct net_device *dev, int new_mtu)
-{
- if ((new_mtu < QCAFRM_ETHMINMTU) || (new_mtu > QCAFRM_ETHMAXMTU))
- return -EINVAL;
-
- dev->mtu = new_mtu;
-
- return 0;
-}
-
static const struct net_device_ops qcaspi_netdev_ops = {
.ndo_init = qcaspi_netdev_init,
.ndo_uninit = qcaspi_netdev_uninit,
.ndo_open = qcaspi_netdev_open,
.ndo_stop = qcaspi_netdev_close,
.ndo_start_xmit = qcaspi_netdev_xmit,
- .ndo_change_mtu = qcaspi_netdev_change_mtu,
+ .ndo_change_mtu = qcacmn_netdev_change_mtu,
.ndo_set_mac_address = eth_mac_addr,
.ndo_tx_timeout = qcaspi_netdev_tx_timeout,
.ndo_validate_addr = eth_validate_addr,
--
2.1.4
^ permalink raw reply related
* [PATCH net-next 8/8] net: qualcomm: add QCA7000 UART driver
From: Stefan Wahren @ 2016-09-20 13:02 UTC (permalink / raw)
To: David S. Miller, Greg Kroah-Hartman, Jiri Slaby
Cc: netdev, linux-kernel, Stefan Wahren
In-Reply-To: <1474376544-20515-1-git-send-email-stefan.wahren@i2se.com>
This patch adds the Ethernet over UART driver for the
Qualcomm QCA7000 HomePlug GreenPHY.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/Kconfig | 12 +
drivers/net/ethernet/qualcomm/Makefile | 2 +
drivers/net/ethernet/qualcomm/qca_common.h | 6 +
drivers/net/ethernet/qualcomm/qca_uart.c | 447 +++++++++++++++++++++++++++++
include/uapi/linux/tty.h | 1 +
5 files changed, 468 insertions(+)
create mode 100644 drivers/net/ethernet/qualcomm/qca_uart.c
diff --git a/drivers/net/ethernet/qualcomm/Kconfig b/drivers/net/ethernet/qualcomm/Kconfig
index 0d33728..0ede46e 100644
--- a/drivers/net/ethernet/qualcomm/Kconfig
+++ b/drivers/net/ethernet/qualcomm/Kconfig
@@ -30,6 +30,18 @@ config QCA7000_SPI
To compile this driver as a module, choose M here. The module
will be called qcaspi.
+config QCA7000_UART
+ tristate "Qualcomm Atheros QCA7000 UART support"
+ select QCA7000
+ depends on TTY
+ ---help---
+ This UART protocol driver supports the Qualcomm Atheros QCA7000.
+ The driver implements the tty line discipline N_QCA7K and supports
+ only one netdevice.
+
+ To compile this driver as a module, choose M here. The module
+ will be called qcauart.
+
config QCOM_EMAC
tristate "Qualcomm Technologies, Inc. EMAC Gigabit Ethernet support"
select CRC32
diff --git a/drivers/net/ethernet/qualcomm/Makefile b/drivers/net/ethernet/qualcomm/Makefile
index 00d8729..8847db7 100644
--- a/drivers/net/ethernet/qualcomm/Makefile
+++ b/drivers/net/ethernet/qualcomm/Makefile
@@ -5,5 +5,7 @@
obj-$(CONFIG_QCA7000) += qca_common.o
obj-$(CONFIG_QCA7000_SPI) += qcaspi.o
qcaspi-objs := qca_7k.o qca_debug.o qca_spi.o
+obj-$(CONFIG_QCA7000_UART) += qcauart.o
+qcauart-objs := qca_uart.o
obj-y += emac/
diff --git a/drivers/net/ethernet/qualcomm/qca_common.h b/drivers/net/ethernet/qualcomm/qca_common.h
index c93cfdf07..bc38689 100644
--- a/drivers/net/ethernet/qualcomm/qca_common.h
+++ b/drivers/net/ethernet/qualcomm/qca_common.h
@@ -123,6 +123,12 @@ static inline void qcafrm_fsm_init_spi(struct qcafrm_handle *handle)
handle->state = handle->init;
}
+static inline void qcafrm_fsm_init_uart(struct qcafrm_handle *handle)
+{
+ handle->init = QCAFRM_WAIT_AA1;
+ handle->state = handle->init;
+}
+
/* Gather received bytes and try to extract a full Ethernet frame
* by following a simple state machine.
*
diff --git a/drivers/net/ethernet/qualcomm/qca_uart.c b/drivers/net/ethernet/qualcomm/qca_uart.c
new file mode 100644
index 0000000..f956c83
--- /dev/null
+++ b/drivers/net/ethernet/qualcomm/qca_uart.c
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2011, 2012, Qualcomm Atheros Communications Inc.
+ * Copyright (c) 2016, I2SE GmbH
+ *
+ * Permission to use, copy, modify, and/or distribute this software
+ * for any purpose with or without fee is hereby granted, provided
+ * that the above copyright notice and this permission notice appear
+ * in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/* This module implements the Qualcomm Atheros UART protocol for
+ * kernel-based UART device; it is essentially an Ethernet-to-UART
+ * serial converter;
+ */
+
+#include <linux/errno.h>
+#include <linux/etherdevice.h>
+#include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/init.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/moduleparam.h>
+#include <linux/netdevice.h>
+#include <linux/sched.h>
+#include <linux/skbuff.h>
+#include <linux/tty.h>
+#include <linux/types.h>
+
+#include "qca_common.h"
+
+#define QCAUART_DRV_VERSION "0.0.6"
+#define QCAUART_DRV_NAME "qcauart"
+#define QCAUART_TX_TIMEOUT (1 * HZ)
+
+struct qcauart {
+ struct net_device *net_dev;
+ spinlock_t lock; /* transmit lock */
+ struct work_struct tx_work; /* Flushes transmit buffer */
+
+ struct tty_struct *tty;
+
+ unsigned char xbuff[QCAFRM_ETHMAXMTU]; /* transmitter buffer */
+ unsigned char *xhead; /* pointer to next XMIT byte */
+ int xleft; /* bytes left in XMIT queue */
+
+ struct qcafrm_handle frm_handle;
+
+ struct sk_buff *rx_skb;
+};
+
+static struct net_device *qcauart_dev;
+
+void
+qca_tty_receive(struct tty_struct *tty, const unsigned char *cp, char *fp,
+ int count)
+{
+ struct qcauart *qca = tty->disc_data;
+ struct net_device_stats *n_stats = &qca->net_dev->stats;
+ int dropped = 0;
+
+ if (!qca->rx_skb) {
+ qca->rx_skb = netdev_alloc_skb(qca->net_dev, qca->net_dev->mtu +
+ VLAN_ETH_HLEN);
+ if (!qca->rx_skb) {
+ n_stats->rx_errors++;
+ n_stats->rx_dropped++;
+ return;
+ }
+ }
+
+ while (count--) {
+ s32 retcode;
+
+ if (fp && *fp++) {
+ n_stats->rx_errors++;
+ cp++;
+ dropped++;
+ continue;
+ }
+
+ retcode = qcafrm_fsm_decode(&qca->frm_handle,
+ qca->rx_skb->data,
+ skb_tailroom(qca->rx_skb),
+ *cp);
+
+ cp++;
+ switch (retcode) {
+ case QCAFRM_GATHER:
+ case QCAFRM_NOHEAD:
+ break;
+ case QCAFRM_NOTAIL:
+ netdev_dbg(qca->net_dev, "recv: no RX tail\n");
+ n_stats->rx_errors++;
+ n_stats->rx_dropped++;
+ break;
+ case QCAFRM_INVLEN:
+ netdev_dbg(qca->net_dev, "recv: invalid RX length\n");
+ n_stats->rx_errors++;
+ n_stats->rx_dropped++;
+ break;
+ default:
+ qca->rx_skb->dev = qca->net_dev;
+ n_stats->rx_packets++;
+ n_stats->rx_bytes += retcode;
+ skb_put(qca->rx_skb, retcode);
+ qca->rx_skb->protocol = eth_type_trans(
+ qca->rx_skb, qca->rx_skb->dev);
+ qca->rx_skb->ip_summed = CHECKSUM_UNNECESSARY;
+ netif_rx_ni(qca->rx_skb);
+ qca->rx_skb = netdev_alloc_skb(qca->net_dev,
+ qca->net_dev->mtu +
+ VLAN_ETH_HLEN);
+ if (!qca->rx_skb) {
+ netdev_dbg(qca->net_dev, "recv: out of RX resources\n");
+ n_stats->rx_errors++;
+ break;
+ }
+ }
+ }
+
+ if (dropped)
+ dev_dbg_ratelimited(&qca->net_dev->dev, "recv: invalid %d bytes\n",
+ dropped);
+}
+
+/* Write out any remaining transmit buffer. Scheduled when tty is writable */
+static void qcauart_transmit(struct work_struct *work)
+{
+ struct qcauart *qca = container_of(work, struct qcauart, tx_work);
+ struct net_device_stats *n_stats = &qca->net_dev->stats;
+ int written;
+
+ spin_lock_bh(&qca->lock);
+ /* First make sure we're connected. */
+ if (!qca->tty || !netif_running(qca->net_dev)) {
+ spin_unlock_bh(&qca->lock);
+ return;
+ }
+
+ if (qca->xleft <= 0) {
+ /* Now serial buffer is almost free & we can start
+ * transmission of another packet
+ */
+ n_stats->tx_packets++;
+ clear_bit(TTY_DO_WRITE_WAKEUP, &qca->tty->flags);
+ spin_unlock_bh(&qca->lock);
+ netif_wake_queue(qca->net_dev);
+ return;
+ }
+
+ written = qca->tty->ops->write(qca->tty, qca->xhead, qca->xleft);
+ qca->xleft -= written;
+ qca->xhead += written;
+ spin_unlock_bh(&qca->lock);
+}
+
+/* Called by the driver when there's room for more data.
+ * Schedule the transmit.
+ */
+static void qca_tty_wakeup(struct tty_struct *tty)
+{
+ struct qcauart *qca = tty->disc_data;
+
+ schedule_work(&qca->tx_work);
+}
+
+int
+qca_tty_open(struct tty_struct *tty)
+{
+ struct qcauart *qca;
+
+ if (!capable(CAP_NET_ADMIN))
+ return -EPERM;
+
+ if (!tty->ops->write)
+ return -EOPNOTSUPP;
+
+ if (tty->disc_data)
+ return -EEXIST;
+
+ qca = netdev_priv(qcauart_dev);
+ qca->tty = tty;
+ tty->disc_data = qca;
+ tty->receive_room = 4096;
+ netif_carrier_on(qca->net_dev);
+
+ return 0;
+}
+
+void
+qca_tty_close(struct tty_struct *tty)
+{
+ struct qcauart *qca = (void *)tty->disc_data;
+
+ if (!qca)
+ return;
+
+ netif_carrier_off(qca->net_dev);
+ qca->tty = NULL;
+
+ /* Detach from the tty */
+ tty->disc_data = NULL;
+}
+
+static struct tty_ldisc_ops qca_ldisc = {
+ .owner = THIS_MODULE,
+ .magic = TTY_LDISC_MAGIC,
+ .name = "qca",
+ .open = qca_tty_open,
+ .close = qca_tty_close,
+ .ioctl = n_tty_ioctl_helper,
+ .receive_buf = qca_tty_receive,
+ .write_wakeup = qca_tty_wakeup,
+};
+
+int
+qcauart_netdev_open(struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+
+ qcafrm_fsm_init_uart(&qca->frm_handle);
+ netif_start_queue(qca->net_dev);
+
+ return 0;
+}
+
+int
+qcauart_netdev_close(struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+
+ spin_lock_bh(&qca->lock);
+ if (qca->tty) {
+ /* TTY discipline is running. */
+ clear_bit(TTY_DO_WRITE_WAKEUP, &qca->tty->flags);
+ }
+ netif_stop_queue(dev);
+ qca->xleft = 0;
+ spin_unlock_bh(&qca->lock);
+
+ return 0;
+}
+
+netdev_tx_t
+qcauart_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+ struct net_device_stats *n_stats = &dev->stats;
+ u8 *pos;
+ u8 pad_len = 0;
+ int written;
+
+ spin_lock(&qca->lock);
+
+ if (!netif_running(dev)) {
+ spin_unlock(&qca->lock);
+ netdev_warn(qca->net_dev, "xmit: iface is down\n");
+ goto out;
+ }
+ if (!qca->tty) {
+ spin_unlock(&qca->lock);
+ goto out;
+ }
+
+ pos = qca->xbuff;
+
+ if (skb->len < QCAFRM_ETHMINLEN)
+ pad_len = QCAFRM_ETHMINLEN - skb->len;
+
+ pos += qcafrm_create_header(pos, skb->len + pad_len);
+
+ memcpy(pos, skb->data, skb->len);
+ pos += skb->len;
+
+ if (pad_len) {
+ memset(pos, 0, pad_len);
+ pos += pad_len;
+ }
+
+ pos += qcafrm_create_footer(pos);
+
+ netif_stop_queue(qca->net_dev);
+
+ set_bit(TTY_DO_WRITE_WAKEUP, &qca->tty->flags);
+ written = qca->tty->ops->write(qca->tty, qca->xbuff, pos - qca->xbuff);
+ qca->xleft = (pos - qca->xbuff) - written;
+ qca->xhead = qca->xbuff + written;
+ n_stats->tx_bytes += written;
+ spin_unlock(&qca->lock);
+
+ dev->trans_start = jiffies;
+out:
+ kfree_skb(skb);
+ return NETDEV_TX_OK;
+}
+
+void
+qcauart_netdev_tx_timeout(struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+
+ netdev_info(qca->net_dev, "Transmit timeout at %ld, latency %ld\n",
+ jiffies, jiffies - dev->trans_start);
+ dev->stats.tx_errors++;
+ dev->stats.tx_dropped++;
+
+ clear_bit(TTY_DO_WRITE_WAKEUP, &qca->tty->flags);
+}
+
+static int
+qcauart_netdev_init(struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+
+ /* Finish setting up the device info. */
+ dev->mtu = QCAFRM_ETHMAXMTU;
+ dev->type = ARPHRD_ETHER;
+
+ qca->rx_skb = netdev_alloc_skb(qca->net_dev,
+ qca->net_dev->mtu + VLAN_ETH_HLEN);
+ if (!qca->rx_skb)
+ return -ENOMEM;
+
+ return 0;
+}
+
+static void
+qcauart_netdev_uninit(struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+
+ if (qca->rx_skb)
+ dev_kfree_skb(qca->rx_skb);
+}
+
+static const struct net_device_ops qcauart_netdev_ops = {
+ .ndo_init = qcauart_netdev_init,
+ .ndo_uninit = qcauart_netdev_uninit,
+ .ndo_open = qcauart_netdev_open,
+ .ndo_stop = qcauart_netdev_close,
+ .ndo_start_xmit = qcauart_netdev_xmit,
+ .ndo_change_mtu = qcacmn_netdev_change_mtu,
+ .ndo_set_mac_address = eth_mac_addr,
+ .ndo_tx_timeout = qcauart_netdev_tx_timeout,
+ .ndo_validate_addr = eth_validate_addr,
+};
+
+static void
+qcauart_netdev_setup(struct net_device *dev)
+{
+ struct qcauart *qca;
+
+ dev->netdev_ops = &qcauart_netdev_ops;
+ dev->watchdog_timeo = QCAUART_TX_TIMEOUT;
+ dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+ dev->tx_queue_len = 100;
+
+ qca = netdev_priv(dev);
+ memset(qca, 0, sizeof(struct qcauart));
+}
+
+static int __init qcauart_mod_init(void)
+{
+ struct qcauart *qca;
+ int ret;
+
+ ret = tty_register_ldisc(N_QCA7K, &qca_ldisc);
+ if (ret) {
+ pr_err("qca_uart: Can't register line discipline (ret %d)\n",
+ ret);
+ return ret;
+ }
+
+ qcauart_dev = alloc_etherdev(sizeof(struct qcauart));
+ if (!qcauart_dev)
+ return -ENOMEM;
+
+ qcauart_netdev_setup(qcauart_dev);
+
+ qca = netdev_priv(qcauart_dev);
+ if (!qca) {
+ pr_err("qca_uart: Fail to retrieve private structure\n");
+ free_netdev(qcauart_dev);
+ return -ENOMEM;
+ }
+ qca->net_dev = qcauart_dev;
+ spin_lock_init(&qca->lock);
+ INIT_WORK(&qca->tx_work, qcauart_transmit);
+
+ eth_hw_addr_random(qca->net_dev);
+ pr_info("qca_uart: ver=%s, using random MAC address: %pM\n",
+ QCAUART_DRV_VERSION, qca->net_dev->dev_addr);
+
+ netif_carrier_off(qca->net_dev);
+
+ if (register_netdev(qcauart_dev)) {
+ pr_err("qca_uart: Unable to register net device %s\n",
+ qcauart_dev->name);
+ free_netdev(qcauart_dev);
+ return -EFAULT;
+ }
+
+ return 0;
+}
+
+static void __exit qcauart_mod_exit(void)
+{
+ struct qcauart *qca;
+ int ret;
+
+ qca = netdev_priv(qcauart_dev);
+ spin_lock_bh(&qca->lock);
+ if (qca->tty)
+ tty_hangup(qca->tty);
+ spin_unlock_bh(&qca->lock);
+
+ unregister_netdev(qcauart_dev);
+
+ free_netdev(qcauart_dev);
+ qcauart_dev = NULL;
+
+ ret = tty_unregister_ldisc(N_QCA7K);
+ if (ret)
+ pr_err("qca_uart: can't unregister line discipline (ret %d)\n",
+ ret);
+}
+
+module_init(qcauart_mod_init);
+module_exit(qcauart_mod_exit);
+
+MODULE_DESCRIPTION("Qualcomm Atheros UART Driver");
+MODULE_AUTHOR("Qualcomm Atheros Communications");
+MODULE_AUTHOR("Stefan Wahren <stefan.wahren@i2se.com>");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_VERSION(QCAUART_DRV_VERSION);
+MODULE_ALIAS_LDISC(N_QCA7K);
diff --git a/include/uapi/linux/tty.h b/include/uapi/linux/tty.h
index 01c4410..53c2760 100644
--- a/include/uapi/linux/tty.h
+++ b/include/uapi/linux/tty.h
@@ -35,5 +35,6 @@
#define N_TRACESINK 23 /* Trace data routing for MIPI P1149.7 */
#define N_TRACEROUTER 24 /* Trace data routing for MIPI P1149.7 */
#define N_NCI 25 /* NFC NCI UART */
+#define N_QCA7K 26 /* Qualcomm QCA7000 Ethernet to UART */
#endif /* _UAPI_LINUX_TTY_H */
--
2.1.4
^ permalink raw reply related
* Re: [PATCH net-next V2 3/4] net/mlx4_core: Use RCU to perform radix tree lookup for SRQ
From: Leon Romanovsky @ 2016-09-20 13:05 UTC (permalink / raw)
To: Sergei Shtylyov; +Cc: Tariq Toukan, David S. Miller, netdev, Eran Ben Elisha
In-Reply-To: <33b95e3f-ae37-4635-1810-c8e65d075e4d@cogentembedded.com>
[-- Attachment #1: Type: text/plain, Size: 2406 bytes --]
On Tue, Sep 20, 2016 at 03:47:49PM +0300, Sergei Shtylyov wrote:
> Hello.
>
> On 9/20/2016 2:39 PM, Tariq Toukan wrote:
>
> >From: Leon Romanovsky <leonro@mellanox.com>
> >
> >Radix tree lookup can be performed without locking.
> >
> >Fixes: 225c7b1feef1 ("IB/mlx4: Add a driver Mellanox ConnectX InfiniBand adapters")
> >Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
> >Suggested-by: Sagi Grimberg <sagi@grimberg.me>
> >Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> >---
> > drivers/net/ethernet/mellanox/mlx4/srq.c | 14 +++++---------
> > 1 file changed, 5 insertions(+), 9 deletions(-)
> >
> >diff --git a/drivers/net/ethernet/mellanox/mlx4/srq.c b/drivers/net/ethernet/mellanox/mlx4/srq.c
> >index 67146624eb58..f44d089e2ca6 100644
> >--- a/drivers/net/ethernet/mellanox/mlx4/srq.c
> >+++ b/drivers/net/ethernet/mellanox/mlx4/srq.c
> >@@ -45,15 +45,12 @@ void mlx4_srq_event(struct mlx4_dev *dev, u32 srqn, int event_type)
> > struct mlx4_srq_table *srq_table = &mlx4_priv(dev)->srq_table;
> > struct mlx4_srq *srq;
> >
> >- spin_lock(&srq_table->lock);
> >-
> >+ rcu_read_lock();
> > srq = radix_tree_lookup(&srq_table->tree, srqn & (dev->caps.num_srqs - 1));
> >+ rcu_read_unlock();
> > if (srq)
> > atomic_inc(&srq->refcount);
> >-
> >- spin_unlock(&srq_table->lock);
> >-
> >- if (!srq) {
> >+ else {
> > mlx4_warn(dev, "Async event for bogus SRQ %08x\n", srqn);
> > return;
> > }
>
> CodingStyle: all branches of the *if* statement should have {} if at
> least one has.
I'm not arguing, but wanted to raise attention that checkpatch.pl
doesn't warn about it.
➜ /tmp wget https://patchwork.ozlabs.org/patch/672216/mbox/
➜ linux-rdma git:(master) ./scripts/checkpatch.pl /tmp/index.html
total: 0 errors, 0 warnings, 0 checks, 32 lines checked
/tmp/index.html has no obvious style problems and is ready for
submission.
And CodingStyle presents a little bit different case
----
This does not apply if only one branch of a conditional statement is a
single statement; in the latter case use braces in both branches:
if (condition) {
do_this();
do_that();
} else {
otherwise();
}
and not
if (condition)
do_that();
else {
otherwise();
otherwise();
}
Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply
* Re: [PATCH 1/1] ixgbe: replace defined with IS_ENABLED
From: zhuyj @ 2016-09-20 13:09 UTC (permalink / raw)
To: Tantilov, Emil S
Cc: e1000-devel@lists.sourceforge.net, netdev@vger.kernel.org,
intel-wired-lan@lists.osuosl.org
In-Reply-To: <87618083B2453E4A8714035B62D67992506E6E4B@FMSMSX105.amr.corp.intel.com>
how about this patch "ixgbe: remove the useless header file ixgbe_type.h"?
On Tue, Sep 20, 2016 at 1:00 AM, Tantilov, Emil S
<emil.s.tantilov@intel.com> wrote:
>>-----Original Message-----
>>From: netdev-owner@vger.kernel.org [mailto:netdev-owner@vger.kernel.org] On
>>Behalf Of zyjzyj2000@gmail.com
>>Sent: Wednesday, September 14, 2016 8:27 AM
>>To: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org; Kirsher,
>>Jeffrey T <jeffrey.t.kirsher@intel.com>; zyjzyj2000@gmail.com; e1000-
>>devel@lists.sourceforge.net
>>Subject: [PATCH 1/1] ixgbe: replace defined with IS_ENABLED
>>
>>From: Zhu Yanjun <zyjzyj2000@gmail.com>
>>
>>Replace defined macro with IS_ENABLED in ixgbe.h file
>>
>>Signed-off-by: Zhu Yanjun <zyjzyj2000@gmail.com>
>>---
>> drivers/net/ethernet/intel/ixgbe/ixgbe.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>>diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
>>b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
>>index 9475ff9..f8bc1d0 100644
>>--- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h
>>+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h
>>@@ -45,7 +45,7 @@
>> #include "ixgbe_type.h"
>> #include "ixgbe_common.h"
>> #include "ixgbe_dcb.h"
>>-#if defined(CONFIG_FCOE) || defined(CONFIG_FCOE_MODULE)
>>+#if IS_ENABLED(CONFIG_FCOE)
>> #define IXGBE_FCOE
>> #include "ixgbe_fcoe.h"
>> #endif /* CONFIG_FCOE or CONFIG_FCOE_MODULE */
>>--
>>2.7.4
>
> Already taken care of by the following patch:
> http://patchwork.ozlabs.org/patch/668894/
>
> Thanks,
> Emil
>
------------------------------------------------------------------------------
_______________________________________________
E1000-devel mailing list
E1000-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/e1000-devel
To learn more about Intel® Ethernet, visit http://communities.intel.com/community/wired
^ permalink raw reply
* Re: UBSAN reports issue in ip_idents_reserve
From: Eric Dumazet @ 2016-09-20 13:28 UTC (permalink / raw)
To: Jiri Pirko; +Cc: netdev
In-Reply-To: <20160920120000.GI1843@nanopsycho.orion>
On Tue, 2016-09-20 at 14:00 +0200, Jiri Pirko wrote:
> Hi.
>
> I'm consistently getting following UBSAN warning on every bootup:
>
> [ 47.545820] ================================================================================
> [ 47.554340] UBSAN: Undefined behaviour in ./arch/x86/include/asm/atomic.h:156:11
> [ 47.561808] signed integer overflow:
> [ 47.565420] -2117905507 + -695755206 cannot be represented in type 'int'
> [ 47.572226] CPU: 0 PID: 389 Comm: ntpd Not tainted 4.8.0-rc6jiri+ #1
> [ 47.578636] Hardware name: Mellanox Technologies Ltd. Mellanox switch/Mellanox switch, BIOS 4.6.5 05/21/2015
> [ 47.588586] ffffffff847bf8c0 00000000987b8f47 ffff8803829af5a8 ffffffff818354e3
> [ 47.596165] 0000000041b58ab3 ffffffff8277e711 ffffffff81835431 ffff8803829af5d0
> [ 47.603722] ffff8803829af580 ffffffffd6879e3a 1ffffffff08f8214 ffffed0070535e6c
> [ 47.611298] Call Trace:
> [ 47.613795] [<ffffffff818354e3>] dump_stack+0xb2/0x10f
> [ 47.619077] [<ffffffff81835431>] ? _atomic_dec_and_lock+0xa1/0xa1
> [ 47.625327] [<ffffffff818a884f>] ubsan_epilogue+0xd/0x4e
> [ 47.630811] [<ffffffff818a9821>] handle_overflow+0x190/0x1de
> [ 47.636627] [<ffffffff818a9691>] ? __ubsan_handle_negate_overflow+0x140/0x140
> [ 47.643914] [<ffffffff81863130>] ? iov_iter_copy_from_user_atomic+0x6e0/0x6e0
> [ 47.651219] [<ffffffff811e6f79>] ? __lock_acquire.isra.17+0xb79/0xe50
> [ 47.657832] [<ffffffff81e581f2>] ? ip_generic_getfrag+0xd2/0x190
> [ 47.664011] [<ffffffff81e58120>] ? ip_setup_cork+0x320/0x320
> [ 47.669827] [<ffffffff818a987d>] __ubsan_handle_add_overflow+0xe/0x10
> [ 47.676444] [<ffffffff81e41d52>] ip_idents_reserve+0xb2/0xe0
> [ 47.682254] [<ffffffff81e443e9>] __ip_select_ident+0x159/0x1b0
> [ 47.688248] [<ffffffff81e44290>] ? update_or_create_fnhe+0x850/0x850
> [ 47.694782] [<ffffffff81e58120>] ? ip_setup_cork+0x320/0x320
> [ 47.700624] [<ffffffff81e5ef40>] __ip_make_skb+0x8a0/0xab0
> [ 47.706259] [<ffffffff81e5f3fd>] ip_make_skb+0x17d/0x1d0
> [ 47.711717] [<ffffffff81e58120>] ? ip_setup_cork+0x320/0x320
> [ 47.717526] [<ffffffff81e5f280>] ? ip_flush_pending_frames+0x20/0x20
> [ 47.724032] [<ffffffff81e46ef0>] ? ip_rt_update_pmtu+0x4f0/0x4f0
> [ 47.730231] [<ffffffff81f35291>] ? xfrm_lookup_route+0x21/0xe0
> [ 47.736216] [<ffffffff81ec0cdb>] udp_sendmsg+0x9db/0xf60
> [ 47.741668] [<ffffffff81e58120>] ? ip_setup_cork+0x320/0x320
> [ 47.747472] [<ffffffff81ec0300>] ? udp_abort+0x70/0x70
> [ 47.752763] [<ffffffff81ede3d8>] inet_sendmsg+0x198/0x220
> [ 47.758324] [<ffffffff81ede292>] ? inet_sendmsg+0x52/0x220
> [ 47.763982] [<ffffffff81ede240>] ? inet_recvmsg+0x300/0x300
> [ 47.769728] [<ffffffff81d6fd25>] sock_sendmsg+0xa5/0xd0
> [ 47.775100] [<ffffffff81d72f70>] SYSC_sendto+0x1d0/0x280
> [ 47.780551] [<ffffffff81d72da0>] ? SYSC_connect+0x200/0x200
> [ 47.786283] [<ffffffff814f66df>] ? poll_select_copy_remaining+0x2af/0x310
> [ 47.793265] [<ffffffff814f6430>] ? set_fd_set+0x60/0x60
> [ 47.798665] [<ffffffff811ee360>] ? do_raw_spin_trylock+0x90/0x90
> [ 47.804853] [<ffffffff814f80e3>] ? SyS_select+0x1a3/0x200
> [ 47.810399] [<ffffffff814f7f40>] ? core_sys_select+0x570/0x570
> [ 47.816415] [<ffffffff8100467c>] ? exit_to_usermode_loop+0xec/0x110
> [ 47.822842] [<ffffffff811e8abd>] ? lockdep_sys_exit+0x2d/0xb0
> [ 47.828769] [<ffffffff81004016>] ? lockdep_sys_exit_thunk+0x16/0x30
> [ 47.835199] [<ffffffff81d7433e>] SyS_sendto+0xe/0x10
> [ 47.840321] [<ffffffff820381f2>] entry_SYSCALL_64_fastpath+0x1a/0xa9
> [ 47.846826] ================================================================================
>
> Looks like this might be result of following commit:
>
> commit 04ca6973f7c1a0d8537f2d9906a0cf8e69886d75
> Author: Eric Dumazet <edumazet@google.com>
> Date: Sat Jul 26 08:58:10 2014 +0200
>
> ip: make IP identifiers less predictable
>
> Eric, could you please take look at that?
Sure
I do not think we have to worry here.
These is best effort, and unfortunately atomic_t are int.
Adding uatomic_t helpers in the kernel with unsigned int would be a huge
effort, given this would touch all arches.
^ permalink raw reply
* RE: [RFC v2 00/11] QLogic RDMA Driver (qedr) RFC
From: Elior, Ariel @ 2016-09-20 13:33 UTC (permalink / raw)
To: Leon Romanovsky, Amrani, Ram
Cc: davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
Kalderon, Michal, Mintz, Yuval, Borundia, Rajesh,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <20160920121151.GK26673-2ukJVAZIZ/Y@public.gmane.org>
> On Tue, Sep 20, 2016 at 01:35:52PM +0300, Ram Amrani wrote:
...
> > The series adds on top of RFC v1:
> > * a check for all drivers that IB_ACCESS_MW_BIND isn't set for ib_get_dma_mr
> > * relocation of qedr user API to include/rdma/uapi/providers/
> > * removal of qedr_devlist_local
> > * fixed error handling in qedr_alloc_resources()
> > * configuration of PBL in ib_map_mr_sg() driver implementation,
> > rather than post_send's IB_WR_REG_MR
> > * misc.: placed code in proper patch, fixed a few comments,
> > removed extra parentheses
> >
> > Thanks for everyone which pointed out problems in the driver.
> >
> > Any review/comment is appreciated.
>
> Very nice,
> Any reason why didn't you drop debug module parameter and decided to
> mimic already available kernel core functionality?
>
> You got technical explanations why it is bad idea to use it. If you need additional
> voices
> to support my claims, you will find them in thread about VERBOSE flag and responses
> from
> Doug, and Dennis.
>
> Thanks
Hi Leon,
The RFC cover letter lists what has been addressed. Debug printouts are not addressed in V2 as the discussion on that topic is not concluded (more thoughts from us on debug printouts incoming on the thread). There were many comments to V1 which are not relevant to debug printouts which are addressed by V2. We are requesting further comment, hence RFC V2. Rest assured, if it is the final opinion in the relevant discussion that pr_debug is the way to go, that's what we'll do.
Thanks,
Ariel
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH v4 01/16] vmxnet3: Move PCI Id to pci_ids.h
From: Bjorn Helgaas @ 2016-09-20 13:37 UTC (permalink / raw)
To: Adit Ranadive
Cc: Yuval Shaia, dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org,
linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, pv-drivers,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Jorgen S. Hansen, Aditya Sarwade, George Zhang, Bryan Tan
In-Reply-To: <DM2PR0501MB84422A1029EE72FC727F960C5F10-SXUgMXdxDSdudfUQJyYm35LWcSx1hRipwIZJ9u9yWa8oOQlpcoRfSA@public.gmane.org>
On Wed, Sep 14, 2016 at 07:36:34PM +0000, Adit Ranadive wrote:
> On Wed, Sep 14, 2016 at 09:25:18 -0700, Yuval Shaia wrote:
> > On Wed, Sep 14, 2016 at 04:00:25PM +0000, Adit Ranadive wrote:
> > > On Wed, Sep 14, 2016 at 04:09:12 -0700, Yuval Shaia wrote:
> > > > Please update vmxnet3_drv.c accordingly.
> > >
> > > Any reason why? I don't think we need to. Vmxnet3 should just pick up
> > > the moved PCI device id from pci_ids.h file.
> >
> > So now you need to include it from vmxnet3_drv.c.
> > Same with pvrdma_main.c
>
> If you're asking me to include pci_ids.h in our drivers we already do that
> by including pci.h in both the drivers.
> pci.h already includes pci_ids.h -
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/include/linux/pci.h#n35
>
> If that's going to change maybe someone from the PCI group can comment on.
I don't contemplate a change there. It's fine to get pci_ids.h via pci.h.
Almost all drivers do that today. If we do change it someday, we can
change this driver along with all the rest.
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: DSA: Suspicious RCU usage (via rtnl_bridge_getlink)
From: Andrew Lunn @ 2016-09-20 13:38 UTC (permalink / raw)
To: Russell King - ARM Linux; +Cc: netdev, Vivien Didelot, Paul E. McKenney
In-Reply-To: <20160920102611.GO1041@n2100.armlinux.org.uk>
On Tue, Sep 20, 2016 at 11:26:12AM +0100, Russell King - ARM Linux wrote:
> Issuing "bridge vlan show" on clearfog provokes a "suspicious RCU usage"
> warning from the kernel (see below).
>
> As it's illegal to schedule while holding the RCU read lock, there's the
> possibility for this happening much earlier in the call sequence -
> mv88e6xxx_port_vlan_dump() takes a mutex, and if that mutex were already
> held, we'd schedule at that point. The RCU read lock was taken by
> rtnl_bridge_getlink().
>
> It looks horrible to fix - mvmdio.c as well as DSA locking are involved.
Hi Russell
I would say this needs fixing higher up, in the bridge code. DSA has
to be able to sleep, since the switch can be on any arbitrary bus,
MDIO, SPI, etc. This will affect pure switchdev devices as well, since
they often need to send a request to the switch and wait for a reply.
Andrew
^ permalink raw reply
* RE: UBSAN reports issue in ip_idents_reserve
From: David Laight @ 2016-09-20 13:36 UTC (permalink / raw)
To: 'Eric Dumazet', Jiri Pirko; +Cc: netdev@vger.kernel.org
In-Reply-To: <1474378115.23058.2.camel@edumazet-glaptop3.roam.corp.google.com>
From: Eric Dumazet
> Sent: 20 September 2016 14:29
...
> > [ 47.565420] -2117905507 + -695755206 cannot be represented in type 'int'
...
> I do not think we have to worry here.
>
> These is best effort, and unfortunately atomic_t are int.
Not until we compile on a cpu where int arithmetic doesn't wrap.
While I expect that various other parts of the kernel (and userspace)
wouldn't like such cpu, they do exist.
David
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox