Re: [PATCH v3 net-next 8/8] net: qualcomm: add QCA7000 UART driver

2016-10-21 Thread Stefan Wahren
Am 18.10.2016 um 20:30 schrieb David Miller:
> From: Stefan Wahren 
> Date: Tue, 18 Oct 2016 13:27:34 +0200
>
>> +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 = >net_dev->stats;
>> +int dropped = 0;
> Please order local variable declarations from longest to shortest line.

Even if the current second init depends on the first one?





Re: [PATCH v3 net-next 8/8] net: qualcomm: add QCA7000 UART driver

2016-10-21 Thread Stefan Wahren
Am 18.10.2016 um 20:30 schrieb David Miller:
> From: Stefan Wahren 
> Date: Tue, 18 Oct 2016 13:27:34 +0200
>
>> +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 = >net_dev->stats;
>> +int dropped = 0;
> Please order local variable declarations from longest to shortest line.

Even if the current second init depends on the first one?





Re: [PATCH v3 net-next 8/8] net: qualcomm: add QCA7000 UART driver

2016-10-18 Thread David Miller
From: Stefan Wahren 
Date: Tue, 18 Oct 2016 13:27:34 +0200

> +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 = >net_dev->stats;
> + int dropped = 0;

Please order local variable declarations from longest to shortest line.

> +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 = >stats;
> + u8 *pos;
> + u8 pad_len = 0;
> + int written;

Likewise.


Re: [PATCH v3 net-next 8/8] net: qualcomm: add QCA7000 UART driver

2016-10-18 Thread David Miller
From: Stefan Wahren 
Date: Tue, 18 Oct 2016 13:27:34 +0200

> +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 = >net_dev->stats;
> + int dropped = 0;

Please order local variable declarations from longest to shortest line.

> +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 = >stats;
> + u8 *pos;
> + u8 pad_len = 0;
> + int written;

Likewise.


[PATCH v3 net-next 8/8] net: qualcomm: add QCA7000 UART driver

2016-10-18 Thread Stefan Wahren
This patch adds the Ethernet over UART driver for the
Qualcomm QCA7000 HomePlug GreenPHY.

Signed-off-by: Stefan Wahren 
---
 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 b4c369d..8c3a5b0 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"
depends on HAS_DMA && HAS_IOMEM
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 000..0a8dd6d
--- /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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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 = >net_dev->stats;
+   int dropped = 0;
+
+   if (!qca->rx_skb) {
+

[PATCH v3 net-next 8/8] net: qualcomm: add QCA7000 UART driver

2016-10-18 Thread Stefan Wahren
This patch adds the Ethernet over UART driver for the
Qualcomm QCA7000 HomePlug GreenPHY.

Signed-off-by: Stefan Wahren 
---
 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 b4c369d..8c3a5b0 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"
depends on HAS_DMA && HAS_IOMEM
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 000..0a8dd6d
--- /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 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#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 = >net_dev->stats;
+   int dropped = 0;
+
+   if (!qca->rx_skb) {
+   qca->rx_skb