* [PATCH v6 net-next 13/17] dt-bindings: qca7000-spi: Rework binding
From: Stefan Wahren @ 2017-05-23 13:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1495545173-22150-1-git-send-email-stefan.wahren@i2se.com>
In preparation for the QCA7000 UART binding rework the binding document.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
.../devicetree/bindings/net/qca-qca7000-spi.txt | 49 +++++++++++++---------
1 file changed, 29 insertions(+), 20 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/qca-qca7000-spi.txt b/Documentation/devicetree/bindings/net/qca-qca7000-spi.txt
index c74989c..a37f656 100644
--- a/Documentation/devicetree/bindings/net/qca-qca7000-spi.txt
+++ b/Documentation/devicetree/bindings/net/qca-qca7000-spi.txt
@@ -1,29 +1,38 @@
-* Qualcomm QCA7000 (Ethernet over SPI protocol)
+* Qualcomm QCA7000
-Note: The QCA7000 is useable as a SPI device. In this case it must be defined
-as a child of a SPI master in the device tree.
+The QCA7000 is a serial-to-powerline bridge with a host interface which could
+be configured either as SPI or UART slave. This configuration is done by
+the QCA7000 firmware.
+
+(a) Ethernet over SPI
+
+In order to use the QCA7000 as SPI device it must be defined as a child of a
+SPI master in the device tree.
Required properties:
-- compatible : Should be "qca,qca7000"
-- reg : Should specify the SPI chip select
-- interrupts : The first cell should specify the index of the source interrupt
- and the second cell should specify the trigger type as rising edge
-- spi-cpha : Must be set
-- spi-cpol: Must be set
+- compatible : Should be "qca,qca7000"
+- reg : Should specify the SPI chip select
+- interrupts : The first cell should specify the index of the source
+ interrupt and the second cell should specify the trigger
+ type as rising edge
+- spi-cpha : Must be set
+- spi-cpol : Must be set
Optional properties:
-- interrupt-parent : Specify the pHandle of the source interrupt
+- interrupt-parent : Specify the pHandle of the source interrupt
- spi-max-frequency : Maximum frequency of the SPI bus the chip can operate at.
- Numbers smaller than 1000000 or greater than 16000000 are invalid. Missing
- the property will set the SPI frequency to 8000000 Hertz.
-- local-mac-address: 6 bytes, MAC address
-- qca,legacy-mode : Set the SPI data transfer of the QCA7000 to legacy mode.
- In this mode the SPI master must toggle the chip select between each data
- word. In burst mode these gaps aren't necessary, which is faster.
- This setting depends on how the QCA7000 is setup via GPIO pin strapping.
- If the property is missing the driver defaults to burst mode.
-
-Example:
+ Numbers smaller than 1000000 or greater than 16000000
+ are invalid. Missing the property will set the SPI
+ frequency to 8000000 Hertz.
+- local-mac-address : see ./ethernet.txt
+- qca,legacy-mode : Set the SPI data transfer of the QCA7000 to legacy mode.
+ In this mode the SPI master must toggle the chip select
+ between each data word. In burst mode these gaps aren't
+ necessary, which is faster. This setting depends on how
+ the QCA7000 is setup via GPIO pin strapping. If the
+ property is missing the driver defaults to burst mode.
+
+SPI Example:
/* Freescale i.MX28 SPI master*/
ssp2: spi@80014000 {
--
2.1.4
^ permalink raw reply related
* [PATCH v6 net-next 14/17] dt-bindings: qca7000: rename binding
From: Stefan Wahren @ 2017-05-23 13:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1495545173-22150-1-git-send-email-stefan.wahren@i2se.com>
Before we can merge the QCA7000 UART binding the document needs to be
renamed.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
.../devicetree/bindings/net/{qca-qca7000-spi.txt => qca,qca7000.txt} | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename Documentation/devicetree/bindings/net/{qca-qca7000-spi.txt => qca,qca7000.txt} (100%)
diff --git a/Documentation/devicetree/bindings/net/qca-qca7000-spi.txt b/Documentation/devicetree/bindings/net/qca,qca7000.txt
similarity index 100%
rename from Documentation/devicetree/bindings/net/qca-qca7000-spi.txt
rename to Documentation/devicetree/bindings/net/qca,qca7000.txt
--
2.1.4
^ permalink raw reply
* [PATCH v6 net-next 16/17] dt-bindings: qca7000: append UART interface to binding
From: Stefan Wahren @ 2017-05-23 13:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Wahren
In-Reply-To: <1495545173-22150-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org>
This merges the serdev binding for the QCA7000 UART driver (Ethernet over
UART) into the existing document.
Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
---
.../devicetree/bindings/net/qca,qca7000.txt | 32 ++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/Documentation/devicetree/bindings/net/qca,qca7000.txt b/Documentation/devicetree/bindings/net/qca,qca7000.txt
index a37f656..6d9efb2 100644
--- a/Documentation/devicetree/bindings/net/qca,qca7000.txt
+++ b/Documentation/devicetree/bindings/net/qca,qca7000.txt
@@ -54,3 +54,35 @@ ssp2: spi@80014000 {
local-mac-address = [ A0 B0 C0 D0 E0 F0 ];
};
};
+
+(b) Ethernet over UART
+
+In order to use the QCA7000 as UART slave it must be defined as a child of a
+UART master in the device tree. It is possible to preconfigure the UART
+settings of the QCA7000 firmware, but it's not possible to change them during
+runtime.
+
+Required properties:
+- compatible : Should be "qca,qca7000"
+
+Optional properties:
+- local-mac-address : see ./ethernet.txt
+- current-speed : current baud rate of QCA7000 which defaults to 115200
+ if absent, see also ../serial/slave-device.txt
+
+UART Example:
+
+/* Freescale i.MX28 UART */
+auart0: serial@8006a000 {
+ compatible = "fsl,imx28-auart", "fsl,imx23-auart";
+ reg = <0x8006a000 0x2000>;
+ pinctrl-names = "default";
+ pinctrl-0 = <&auart0_2pins_a>;
+ status = "okay";
+
+ qca7000: ethernet {
+ compatible = "qca,qca7000";
+ local-mac-address = [ A0 B0 C0 D0 E0 F0 ];
+ current-speed = <38400>;
+ };
+};
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" 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 related
* [PATCH v6 net-next 17/17] net: qualcomm: add QCA7000 UART driver
From: Stefan Wahren @ 2017-05-23 13:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree-u79uwXL29TY76Z2rM5mHXA, netdev-u79uwXL29TY76Z2rM5mHXA,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, Stefan Wahren
In-Reply-To: <1495545173-22150-1-git-send-email-stefan.wahren-eS4NqCHxEME@public.gmane.org>
This patch adds the Ethernet over UART driver for the
Qualcomm QCA7000 HomePlug GreenPHY.
Signed-off-by: Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>
---
drivers/net/ethernet/qualcomm/Kconfig | 16 +
drivers/net/ethernet/qualcomm/Makefile | 2 +
drivers/net/ethernet/qualcomm/qca_7k_common.h | 6 +
drivers/net/ethernet/qualcomm/qca_uart.c | 423 ++++++++++++++++++++++++++
4 files changed, 447 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..877675a 100644
--- a/drivers/net/ethernet/qualcomm/Kconfig
+++ b/drivers/net/ethernet/qualcomm/Kconfig
@@ -30,6 +30,22 @@ 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 SERIAL_DEV_BUS && OF
+ ---help---
+ This UART protocol driver supports the Qualcomm Atheros QCA7000.
+
+ Currently the driver assumes these device UART settings:
+ Data bits: 8
+ Parity: None
+ Stop bits: 1
+ Flow control: None
+
+ 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 65556ca..92fa7c4 100644
--- a/drivers/net/ethernet/qualcomm/Makefile
+++ b/drivers/net/ethernet/qualcomm/Makefile
@@ -5,5 +5,7 @@
obj-$(CONFIG_QCA7000) += qca_7k_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_7k_common.h b/drivers/net/ethernet/qualcomm/qca_7k_common.h
index 07bdd6c..928554f 100644
--- a/drivers/net/ethernet/qualcomm/qca_7k_common.h
+++ b/drivers/net/ethernet/qualcomm/qca_7k_common.h
@@ -122,6 +122,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..43d91ba
--- /dev/null
+++ b/drivers/net/ethernet/qualcomm/qca_uart.c
@@ -0,0 +1,423 @@
+/*
+ * Copyright (c) 2011, 2012, Qualcomm Atheros Communications Inc.
+ * Copyright (c) 2017, 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/device.h>
+#include <linux/errno.h>
+#include <linux/etherdevice.h>
+#include <linux/if_arp.h>
+#include <linux/if_ether.h>
+#include <linux/jiffies.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_net.h>
+#include <linux/sched.h>
+#include <linux/serdev.h>
+#include <linux/skbuff.h>
+#include <linux/types.h>
+
+#include "qca_7k_common.h"
+
+#define QCAUART_DRV_VERSION "0.1.0"
+#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 serdev_device *serdev;
+ struct qcafrm_handle frm_handle;
+ struct sk_buff *rx_skb;
+
+ unsigned char *tx_head; /* pointer to next XMIT byte */
+ int tx_left; /* bytes left in XMIT queue */
+ unsigned char *tx_buffer;
+};
+
+static int
+qca_tty_receive(struct serdev_device *serdev, const unsigned char *data,
+ size_t count)
+{
+ struct qcauart *qca = serdev_device_get_drvdata(serdev);
+ struct net_device *netdev = qca->net_dev;
+ struct net_device_stats *n_stats = &netdev->stats;
+ size_t i;
+
+ if (!qca->rx_skb) {
+ qca->rx_skb = netdev_alloc_skb_ip_align(netdev,
+ netdev->mtu +
+ VLAN_ETH_HLEN);
+ if (!qca->rx_skb) {
+ n_stats->rx_errors++;
+ n_stats->rx_dropped++;
+ return 0;
+ }
+ }
+
+ for (i = 0; i < count; i++) {
+ s32 retcode;
+
+ retcode = qcafrm_fsm_decode(&qca->frm_handle,
+ qca->rx_skb->data,
+ skb_tailroom(qca->rx_skb),
+ data[i]);
+
+ switch (retcode) {
+ case QCAFRM_GATHER:
+ case QCAFRM_NOHEAD:
+ break;
+ case QCAFRM_NOTAIL:
+ netdev_dbg(netdev, "recv: no RX tail\n");
+ n_stats->rx_errors++;
+ n_stats->rx_dropped++;
+ break;
+ case QCAFRM_INVLEN:
+ netdev_dbg(netdev, "recv: invalid RX length\n");
+ n_stats->rx_errors++;
+ n_stats->rx_dropped++;
+ break;
+ default:
+ 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_ip_align(netdev,
+ netdev->mtu +
+ VLAN_ETH_HLEN);
+ if (!qca->rx_skb) {
+ netdev_dbg(netdev, "recv: out of RX resources\n");
+ n_stats->rx_errors++;
+ return i;
+ }
+ }
+ }
+
+ return i;
+}
+
+/* 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 (!netif_running(qca->net_dev)) {
+ spin_unlock_bh(&qca->lock);
+ return;
+ }
+
+ if (qca->tx_left <= 0) {
+ /* Now serial buffer is almost free & we can start
+ * transmission of another packet
+ */
+ n_stats->tx_packets++;
+ spin_unlock_bh(&qca->lock);
+ netif_wake_queue(qca->net_dev);
+ return;
+ }
+
+ written = serdev_device_write_buf(qca->serdev, qca->tx_head,
+ qca->tx_left);
+ if (written > 0) {
+ qca->tx_left -= written;
+ qca->tx_head += 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 serdev_device *serdev)
+{
+ struct qcauart *qca = serdev_device_get_drvdata(serdev);
+
+ schedule_work(&qca->tx_work);
+}
+
+static struct serdev_device_ops qca_serdev_ops = {
+ .receive_buf = qca_tty_receive,
+ .write_wakeup = qca_tty_wakeup,
+};
+
+static int qcauart_netdev_open(struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+
+ netif_start_queue(qca->net_dev);
+
+ return 0;
+}
+
+static int qcauart_netdev_close(struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+
+ netif_stop_queue(dev);
+ flush_work(&qca->tx_work);
+
+ spin_lock_bh(&qca->lock);
+ qca->tx_left = 0;
+ spin_unlock_bh(&qca->lock);
+
+ return 0;
+}
+
+static netdev_tx_t
+qcauart_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct net_device_stats *n_stats = &dev->stats;
+ struct qcauart *qca = netdev_priv(dev);
+ u8 pad_len = 0;
+ int written;
+ u8 *pos;
+
+ spin_lock(&qca->lock);
+
+ WARN_ON(qca->tx_left);
+
+ if (!netif_running(dev)) {
+ spin_unlock(&qca->lock);
+ netdev_warn(qca->net_dev, "xmit: iface is down\n");
+ goto out;
+ }
+
+ pos = qca->tx_buffer;
+
+ if (skb->len < QCAFRM_MIN_LEN)
+ pad_len = QCAFRM_MIN_LEN - 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);
+
+ written = serdev_device_write_buf(qca->serdev, qca->tx_buffer,
+ pos - qca->tx_buffer);
+ if (written > 0) {
+ qca->tx_left = (pos - qca->tx_buffer) - written;
+ qca->tx_head = qca->tx_buffer + written;
+ n_stats->tx_bytes += written;
+ }
+ spin_unlock(&qca->lock);
+
+ netif_trans_update(dev);
+out:
+ dev_kfree_skb_any(skb);
+ return NETDEV_TX_OK;
+}
+
+static 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, dev_trans_start(dev));
+ dev->stats.tx_errors++;
+ dev->stats.tx_dropped++;
+}
+
+static int qcauart_netdev_init(struct net_device *dev)
+{
+ struct qcauart *qca = netdev_priv(dev);
+ size_t len;
+
+ /* Finish setting up the device info. */
+ dev->mtu = QCAFRM_MAX_MTU;
+ dev->type = ARPHRD_ETHER;
+
+ len = QCAFRM_HEADER_LEN + QCAFRM_MAX_LEN + QCAFRM_FOOTER_LEN;
+ qca->tx_buffer = devm_kmalloc(&qca->serdev->dev, len, GFP_KERNEL);
+ if (!qca->tx_buffer)
+ return -ENOMEM;
+
+ qca->rx_skb = netdev_alloc_skb_ip_align(qca->net_dev,
+ qca->net_dev->mtu +
+ VLAN_ETH_HLEN);
+ if (!qca->rx_skb)
+ return -ENOBUFS;
+
+ 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_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)
+{
+ dev->netdev_ops = &qcauart_netdev_ops;
+ dev->watchdog_timeo = QCAUART_TX_TIMEOUT;
+ dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+ dev->tx_queue_len = 100;
+
+ /* MTU range: 46 - 1500 */
+ dev->min_mtu = QCAFRM_MIN_MTU;
+ dev->max_mtu = QCAFRM_MAX_MTU;
+}
+
+static const struct of_device_id qca_uart_of_match[] = {
+ {
+ .compatible = "qca,qca7000",
+ },
+ {}
+};
+MODULE_DEVICE_TABLE(of, qca_uart_of_match);
+
+static int qca_uart_probe(struct serdev_device *serdev)
+{
+ struct net_device *qcauart_dev = alloc_etherdev(sizeof(struct qcauart));
+ struct qcauart *qca;
+ const char *mac;
+ u32 speed = 115200;
+ int ret;
+
+ if (!qcauart_dev)
+ return -ENOMEM;
+
+ qcauart_netdev_setup(qcauart_dev);
+ SET_NETDEV_DEV(qcauart_dev, &serdev->dev);
+
+ qca = netdev_priv(qcauart_dev);
+ if (!qca) {
+ pr_err("qca_uart: Fail to retrieve private structure\n");
+ ret = -ENOMEM;
+ goto free;
+ }
+ qca->net_dev = qcauart_dev;
+ qca->serdev = serdev;
+ qcafrm_fsm_init_uart(&qca->frm_handle);
+
+ spin_lock_init(&qca->lock);
+ INIT_WORK(&qca->tx_work, qcauart_transmit);
+
+ of_property_read_u32(serdev->dev.of_node, "current-speed", &speed);
+
+ mac = of_get_mac_address(serdev->dev.of_node);
+
+ if (mac)
+ ether_addr_copy(qca->net_dev->dev_addr, mac);
+
+ if (!is_valid_ether_addr(qca->net_dev->dev_addr)) {
+ eth_hw_addr_random(qca->net_dev);
+ dev_info(&serdev->dev, "Using random MAC address: %pM\n",
+ qca->net_dev->dev_addr);
+ }
+
+ netif_carrier_on(qca->net_dev);
+ serdev_device_set_drvdata(serdev, qca);
+ serdev_device_set_client_ops(serdev, &qca_serdev_ops);
+
+ ret = serdev_device_open(serdev);
+ if (ret) {
+ dev_err(&serdev->dev, "Unable to open device %s\n",
+ qcauart_dev->name);
+ goto free;
+ }
+
+ speed = serdev_device_set_baudrate(serdev, speed);
+ dev_info(&serdev->dev, "Using baudrate: %u\n", speed);
+
+ serdev_device_set_flow_control(serdev, false);
+
+ ret = register_netdev(qcauart_dev);
+ if (ret) {
+ dev_err(&serdev->dev, "Unable to register net device %s\n",
+ qcauart_dev->name);
+ serdev_device_close(serdev);
+ goto free;
+ }
+
+ return 0;
+
+free:
+ free_netdev(qcauart_dev);
+ return ret;
+}
+
+static void qca_uart_remove(struct serdev_device *serdev)
+{
+ struct qcauart *qca = serdev_device_get_drvdata(serdev);
+
+ netif_carrier_off(qca->net_dev);
+ cancel_work_sync(&qca->tx_work);
+ unregister_netdev(qca->net_dev);
+
+ /* Flush any pending characters in the driver. */
+ serdev_device_close(serdev);
+
+ free_netdev(qca->net_dev);
+}
+
+static struct serdev_device_driver qca_uart_driver = {
+ .probe = qca_uart_probe,
+ .remove = qca_uart_remove,
+ .driver = {
+ .name = QCAUART_DRV_NAME,
+ .of_match_table = of_match_ptr(qca_uart_of_match),
+ },
+};
+
+module_serdev_device_driver(qca_uart_driver);
+
+MODULE_DESCRIPTION("Qualcomm Atheros QCA7000 UART Driver");
+MODULE_AUTHOR("Qualcomm Atheros Communications");
+MODULE_AUTHOR("Stefan Wahren <stefan.wahren-eS4NqCHxEME@public.gmane.org>");
+MODULE_LICENSE("Dual BSD/GPL");
+MODULE_VERSION(QCAUART_DRV_VERSION);
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" 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 related
* [PATCH v6 net-next 04/17] net: qca_spi: Use SET_NETDEV_DEV()
From: Stefan Wahren @ 2017-05-23 13:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1495545173-22150-1-git-send-email-stefan.wahren@i2se.com>
Use SET_NETDEV_DEV() in qca_spi to create the "/sys/class/net/<if>/device"
symlink.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_spi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 24ca7df..0c3fdee 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -894,6 +894,7 @@ qca_spi_probe(struct spi_device *spi)
return -ENOMEM;
qcaspi_netdev_setup(qcaspi_devs);
+ SET_NETDEV_DEV(qcaspi_devs, &spi->dev);
qca = netdev_priv(qcaspi_devs);
if (!qca) {
--
2.1.4
^ permalink raw reply related
* [PATCH v6 net-next 00/17] net: qualcomm: add QCA7000 UART driver
From: Stefan Wahren @ 2017-05-23 13:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, 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)
* use new serial device bus instead of ldisc
The patches 1 - 3 are just for clean up and are not related to
the UART support. Patch 4 adds SET_NETDEV_DEV() to qca_spi.
Patches 5 - 16 prepare the existing QCA7000 code for UART support.
The last patch contains the new driver.
The code itself has been tested on a Freescale i.MX28 board and
a Raspberry Pi Zero.
Changes in v6:
* rebase to current linux-next
* use SET_NETDEV_DEV() for qca_spi and qca_uart
* rename binding to qca,qca7000.txt
* use qca,qca7000 compatible for both driver
* handle error cases in qca_uart_probe properly
* fix skb leak in error path of qcauart_netdev_init
* use dev_kfree_skb_any instead of kfree_skb
* take care of tx_work on close / remove
* use devm_kmalloc for tx buffer
* minor cleanups
Changes in v5:
* rebase to current linux-next
* fix alignment issues in rx path
* fix buffer overrun with big ethernet frames
* fix init of UART decoding fsm
* add device UART settings to Kconfig help
* add current-speed to slave-device binding
* merge SPI and UART binding document
* rename qca_common to qca_7k_common
* drop patch for retrieving UART settings
* several cleanups
Changes in v4:
* rebase to current linux-next
* use parameter -M for git format-patch
* change order of local variables where possible
* implement basic serdev support (without hardware flow control)
Changes in v3:
* rebase to current net-next
Changes in v2:
* fix build issue by using netif_trans_update() and dev_trans_start()
[1] - https://github.com/IoE/qca7000
Stefan Wahren (17):
net: qualcomm: remove unnecessary includes
net: qca_framing: use u16 for frame offset
net: qca_7k: Use BIT macro
net: qca_spi: Use SET_NETDEV_DEV()
net: qualcomm: use net_device_ops instead of direct call
net: qualcomm: Improve readability of length defines
net: qca_spi: remove QCASPI_MTU
net: qualcomm: move qcaspi_tx_cmd to qca_spi.c
net: qca_spi: Clarify MODULE_DESCRIPTION
net: qualcomm: rename qca_framing.c to qca_7k_common.c
net: qualcomm: prepare frame decoding for UART driver
net: qualcomm: make qca_7k_common a separate kernel module
dt-bindings: qca7000-spi: Rework binding
dt-bindings: qca7000: rename binding
dt-bindings: slave-device: add current-speed property
dt-bindings: qca7000: append UART interface to binding
net: qualcomm: add QCA7000 UART driver
.../devicetree/bindings/net/qca,qca7000.txt | 88 +++++
.../devicetree/bindings/net/qca-qca7000-spi.txt | 47 ---
.../devicetree/bindings/serial/slave-device.txt | 9 +
drivers/net/ethernet/qualcomm/Kconfig | 24 +-
drivers/net/ethernet/qualcomm/Makefile | 7 +-
drivers/net/ethernet/qualcomm/qca_7k.c | 28 --
drivers/net/ethernet/qualcomm/qca_7k.h | 15 +-
.../qualcomm/{qca_framing.c => qca_7k_common.c} | 26 +-
.../qualcomm/{qca_framing.h => qca_7k_common.h} | 24 +-
drivers/net/ethernet/qualcomm/qca_debug.c | 5 +-
drivers/net/ethernet/qualcomm/qca_spi.c | 48 ++-
drivers/net/ethernet/qualcomm/qca_spi.h | 5 +-
drivers/net/ethernet/qualcomm/qca_uart.c | 423 +++++++++++++++++++++
13 files changed, 630 insertions(+), 119 deletions(-)
create mode 100644 Documentation/devicetree/bindings/net/qca,qca7000.txt
delete mode 100644 Documentation/devicetree/bindings/net/qca-qca7000-spi.txt
rename drivers/net/ethernet/qualcomm/{qca_framing.c => qca_7k_common.c} (85%)
rename drivers/net/ethernet/qualcomm/{qca_framing.h => qca_7k_common.h} (86%)
create mode 100644 drivers/net/ethernet/qualcomm/qca_uart.c
--
2.1.4
^ permalink raw reply
* [PATCH v6 net-next 15/17] dt-bindings: slave-device: add current-speed property
From: Stefan Wahren @ 2017-05-23 13:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1495545173-22150-1-git-send-email-stefan.wahren@i2se.com>
This adds a new DT property to define the current baud rate of the
slave device.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/serial/slave-device.txt | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Documentation/devicetree/bindings/serial/slave-device.txt b/Documentation/devicetree/bindings/serial/slave-device.txt
index f660379..40110e0 100644
--- a/Documentation/devicetree/bindings/serial/slave-device.txt
+++ b/Documentation/devicetree/bindings/serial/slave-device.txt
@@ -21,6 +21,15 @@ Optional Properties:
can support. For example, a particular board has some signal
quality issue or the host processor can't support higher
baud rates.
+- current-speed : The current baud rate the device operates at. This should
+ only be present in case a driver has no chance to know
+ the baud rate of the slave device.
+ Examples:
+ * device supports auto-baud
+ * the rate is setup by a bootloader and there is no
+ way to reset the device
+ * device baud rate is configured by its firmware but
+ there is no way to request the actual settings
Example:
--
2.1.4
^ permalink raw reply related
* [PATCH v6 net-next 06/17] net: qualcomm: Improve readability of length defines
From: Stefan Wahren @ 2017-05-23 13:12 UTC (permalink / raw)
To: Rob Herring, Mark Rutland, David S. Miller
Cc: Greg Kroah-Hartman, Jiri Slaby, Lino Sanfilippo, Jakub Kicinski,
devicetree, netdev, linux-serial, linux-kernel, Stefan Wahren
In-Reply-To: <1495545173-22150-1-git-send-email-stefan.wahren@i2se.com>
In order to avoid mixing things up, make the MTU and frame length
defines easier to read.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
---
drivers/net/ethernet/qualcomm/qca_framing.c | 2 +-
drivers/net/ethernet/qualcomm/qca_framing.h | 8 ++++----
drivers/net/ethernet/qualcomm/qca_spi.c | 12 ++++++------
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.c b/drivers/net/ethernet/qualcomm/qca_framing.c
index faa924c..2341f2b 100644
--- a/drivers/net/ethernet/qualcomm/qca_framing.c
+++ b/drivers/net/ethernet/qualcomm/qca_framing.c
@@ -117,7 +117,7 @@ qcafrm_fsm_decode(struct qcafrm_handle *handle, u8 *buf, u16 buf_len, u8 recv_by
break;
case QCAFRM_WAIT_RSVD_BYTE2:
len = handle->offset;
- if (len > buf_len || len < QCAFRM_ETHMINLEN) {
+ if (len > buf_len || len < QCAFRM_MIN_LEN) {
ret = QCAFRM_INVLEN;
handle->state = QCAFRM_HW_LEN0;
} else {
diff --git a/drivers/net/ethernet/qualcomm/qca_framing.h b/drivers/net/ethernet/qualcomm/qca_framing.h
index 8b385e6..5df7c65 100644
--- a/drivers/net/ethernet/qualcomm/qca_framing.h
+++ b/drivers/net/ethernet/qualcomm/qca_framing.h
@@ -44,12 +44,12 @@
#define QCAFRM_INVFRAME (QCAFRM_ERR_BASE - 4)
/* Min/Max Ethernet MTU: 46/1500 */
-#define QCAFRM_ETHMINMTU (ETH_ZLEN - ETH_HLEN)
-#define QCAFRM_ETHMAXMTU ETH_DATA_LEN
+#define QCAFRM_MIN_MTU (ETH_ZLEN - ETH_HLEN)
+#define QCAFRM_MAX_MTU ETH_DATA_LEN
/* Min/Max frame lengths */
-#define QCAFRM_ETHMINLEN (QCAFRM_ETHMINMTU + ETH_HLEN)
-#define QCAFRM_ETHMAXLEN (QCAFRM_ETHMAXMTU + VLAN_ETH_HLEN)
+#define QCAFRM_MIN_LEN (QCAFRM_MIN_MTU + ETH_HLEN)
+#define QCAFRM_MAX_LEN (QCAFRM_MAX_MTU + VLAN_ETH_HLEN)
/* QCA7K header len */
#define QCAFRM_HEADER_LEN 8
diff --git a/drivers/net/ethernet/qualcomm/qca_spi.c b/drivers/net/ethernet/qualcomm/qca_spi.c
index 7e039e3..f155548 100644
--- a/drivers/net/ethernet/qualcomm/qca_spi.c
+++ b/drivers/net/ethernet/qualcomm/qca_spi.c
@@ -69,7 +69,7 @@ static int qcaspi_pluggable = QCASPI_PLUGGABLE_MIN;
module_param(qcaspi_pluggable, int, 0);
MODULE_PARM_DESC(qcaspi_pluggable, "Pluggable SPI connection (yes/no).");
-#define QCASPI_MTU QCAFRM_ETHMAXMTU
+#define QCASPI_MTU QCAFRM_MAX_MTU
#define QCASPI_TX_TIMEOUT (1 * HZ)
#define QCASPI_QCA7K_REBOOT_TIME_MS 1000
@@ -403,7 +403,7 @@ qcaspi_tx_ring_has_space(struct tx_ring *txr)
if (txr->skb[txr->tail])
return 0;
- return (txr->size + QCAFRM_ETHMAXLEN < QCASPI_HW_BUF_LEN) ? 1 : 0;
+ return (txr->size + QCAFRM_MAX_LEN < QCASPI_HW_BUF_LEN) ? 1 : 0;
}
/* Flush the tx ring. This function is only safe to
@@ -667,8 +667,8 @@ qcaspi_netdev_xmit(struct sk_buff *skb, struct net_device *dev)
struct sk_buff *tskb;
u8 pad_len = 0;
- if (skb->len < QCAFRM_ETHMINLEN)
- pad_len = QCAFRM_ETHMINLEN - skb->len;
+ if (skb->len < QCAFRM_MIN_LEN)
+ pad_len = QCAFRM_MIN_LEN - skb->len;
if (qca->txr.skb[qca->txr.tail]) {
netdev_warn(qca->net_dev, "queue was unexpectedly full!\n");
@@ -805,8 +805,8 @@ qcaspi_netdev_setup(struct net_device *dev)
dev->tx_queue_len = 100;
/* MTU range: 46 - 1500 */
- dev->min_mtu = QCAFRM_ETHMINMTU;
- dev->max_mtu = QCAFRM_ETHMAXMTU;
+ dev->min_mtu = QCAFRM_MIN_MTU;
+ dev->max_mtu = QCAFRM_MAX_MTU;
qca = netdev_priv(dev);
memset(qca, 0, sizeof(struct qcaspi));
--
2.1.4
^ permalink raw reply related
* Re: [PATCH net] net/mlx4: Fix the check in attaching steering rules
From: Leon Romanovsky @ 2017-05-23 13:15 UTC (permalink / raw)
To: Tariq Toukan
Cc: David S. Miller, netdev, Eran Ben Elisha, Or Gerlitz,
Talat Batheesh
In-Reply-To: <1495543807-14956-1-git-send-email-tariqt@mellanox.com>
[-- Attachment #1: Type: text/plain, Size: 2958 bytes --]
On Tue, May 23, 2017 at 03:50:07PM +0300, Tariq Toukan wrote:
> From: Talat Batheesh <talatb@mellanox.com>
>
> Our previous patch (cited below) introduced a regression
> for RAW Eth QPs.
>
> Fix it by checking if the QP number provided by user-space
> exists, hence allowing steering rules to be added for valid
> QPs only.
>
> Fixes: 89c557687a32 ("net/mlx4_en: Avoid adding steering rules with ...")
> Reported-by: Or Gerlitz <gerlitz.or@gmail.com>
> Signed-off-by: Talat Batheesh <talatb@mellanox.com>
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> ---
> drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 3 +--
> drivers/net/ethernet/mellanox/mlx4/qp.c | 14 ++++++++++++++
> include/linux/mlx4/qp.h | 1 +
> 3 files changed, 16 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> index ae5fdc2df654..00a7cd3dcc2e 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> @@ -1562,8 +1562,7 @@ static int mlx4_en_flow_replace(struct net_device *dev,
> qpn = priv->drop_qp.qpn;
> else if (cmd->fs.ring_cookie & EN_ETHTOOL_QP_ATTACH) {
> qpn = cmd->fs.ring_cookie & (EN_ETHTOOL_QP_ATTACH - 1);
> - if (qpn < priv->rss_map.base_qpn ||
> - qpn >= priv->rss_map.base_qpn + priv->rx_ring_num) {
> + if (!mlx4_qp_lookup(priv->mdev->dev, qpn)) {
> en_warn(priv, "rxnfc: QP (0x%x) doesn't exist\n", qpn);
> return -EINVAL;
> }
> diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
> index 2d6abd4662b1..1eff2fe32a8b 100644
> --- a/drivers/net/ethernet/mellanox/mlx4/qp.c
> +++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
> @@ -384,6 +384,20 @@ static void mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn)
> __mlx4_qp_free_icm(dev, qpn);
> }
>
> +struct mlx4_qp *mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn)
> +{
> + struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table;
> + struct mlx4_qp *qp;
> +
> + spin_lock(&qp_table->lock);
> +
> + qp = __mlx4_qp_lookup(dev, qpn);
> +
> + spin_unlock(&qp_table->lock);
> + return qp;
> +}
> +EXPORT_SYMBOL_GPL(mlx4_qp_lookup);
Tariq,
Why do you need this export and header fils? You are using this function in one place only.
Thanks
> +
> int mlx4_qp_alloc(struct mlx4_dev *dev, int qpn, struct mlx4_qp *qp, gfp_t gfp)
> {
> struct mlx4_priv *priv = mlx4_priv(dev);
> diff --git a/include/linux/mlx4/qp.h b/include/linux/mlx4/qp.h
> index b4ee8f62ce8d..8e2828d48d7f 100644
> --- a/include/linux/mlx4/qp.h
> +++ b/include/linux/mlx4/qp.h
> @@ -470,6 +470,7 @@ struct mlx4_update_qp_params {
> u16 rate_val;
> };
>
> +struct mlx4_qp *mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn);
> int mlx4_update_qp(struct mlx4_dev *dev, u32 qpn,
> enum mlx4_update_qp_attr attr,
> struct mlx4_update_qp_params *params);
> --
> 1.8.3.1
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* RE: [patch net-next 0/9] mlxsw: Support firmware flash
From: Mintz, Yuval @ 2017-05-23 13:18 UTC (permalink / raw)
To: Jiri Pirko, netdev@vger.kernel.org
Cc: davem@davemloft.net, idosch@mellanox.com, yotamg@mellanox.com,
mlxsw@mellanox.com, Ben Hutchings
In-Reply-To: <20170523065301.1091-1-jiri@resnulli.us>
> Add support for device firmware flash on mlxsw spectrum. The firmware files
> are expected to be in the Mellanox Firmware Archive version 2 (MFA2)
> format.
>
> The firmware flash can be triggered via "ethtool -f" or on driver initialization
> time if the device firmware version does not meet the minimum firmware
> version supported by the driver.
>
> Currently, to activate the newly flashed firmware, the user needs to reboot
> his system.
>
> The first patch introduces the mlxfw module, which implements common
> logic needed for the firmware flash process on Mellanox products, such as
> the
> MFA2 format parsing and the firmware flash state machine logic. As the
> module implements common logic which will be needed by various different
> Mellanox drivers, it defines a set of callbacks needed to interact with the
> specific device.
>
> Patches 1-5 implement the needed mlxfw callbacks in the mlxsw spectrum
> driver.
>
> Patches 6-8 add the "ethtool -f" and the boot-time firmware upgrade on the
> mlxsw spectrum driver.
When we tried using `ethtool -E' for qed we got burned for trying to use the magic
value [1]. When we suggested extending it to allow some private data indications,
Ben claimed that this entire ethtool infrastructure is a thing of the past,
and we should try using MTD instead - a claim no one bothered to counter.
Creating proprietary file-formats, filling them with metadata and
complementary driver state-machines could easily overcome the original
obstacle we faced. But it raises the question of whether these APIs are
valid or obsolete.
[1] http://marc.info/?l=linux-netdev&m=146093513926921&w=4
[2] http://marc.info/?l=linux-netdev&m=146514461214421&w=2
> Patch 9 adds a fix needed for new firmware versions.
>
> Ido Schimmel (1):
> mlxsw: spectrum_router: Adjust RIF configuration for new firmware
> versions
>
> Yotam Gigi (8):
> Add the mlxfw module for Mellanox firmware flash process
> mlxsw: reg: Add Management Component Query Information register
> mlxsw: reg: Add Management Component Control register
> mlxsw: reg: Add Management Component Data Access register
> mlxsw: spectrum: Add the needed callbacks for mlxfw integration
> mlxsw: spectrum: Implement the ethtool flash_device callback
> mlxsw: core: Create the mlxsw_fw_rev struct
> mlxsw: spectrum: Validate firmware revision on init
>
> MAINTAINERS | 8 +
> drivers/net/ethernet/mellanox/Kconfig | 1 +
> drivers/net/ethernet/mellanox/Makefile | 1 +
> drivers/net/ethernet/mellanox/mlxfw/Kconfig | 6 +
> drivers/net/ethernet/mellanox/mlxfw/Makefile | 2 +
> drivers/net/ethernet/mellanox/mlxfw/mlxfw.h | 102 ++++
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c | 273 +++++++++
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c | 620
> +++++++++++++++++++++
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h | 66 +++
> .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h | 60 ++
> .../ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h | 103 ++++
> .../net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h | 98 ++++
> .../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c | 126 +++++
> .../ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h | 71 +++
> drivers/net/ethernet/mellanox/mlxsw/Kconfig | 1 +
> drivers/net/ethernet/mellanox/mlxsw/core.h | 12 +-
> drivers/net/ethernet/mellanox/mlxsw/reg.h | 219 ++++++++
> drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 266 +++++++++
> .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 22 +
> 19 files changed, 2052 insertions(+), 5 deletions(-) create mode 100644
> drivers/net/ethernet/mellanox/mlxfw/Kconfig
> create mode 100644 drivers/net/ethernet/mellanox/mlxfw/Makefile
> create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw.h
> create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_fsm.c
> create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.c
> create mode 100644 drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2.h
> create mode 100644
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_file.h
> create mode 100644
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_format.h
> create mode 100644
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv.h
> create mode 100644
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.c
> create mode 100644
> drivers/net/ethernet/mellanox/mlxfw/mlxfw_mfa2_tlv_multi.h
>
> --
> 2.9.3
^ permalink raw reply
* Re: stmmac tx timeout
From: Pavel Machek @ 2017-05-23 13:39 UTC (permalink / raw)
To: Niklas Cassel
Cc: Alexandre Torgue, Giuseppe Cavallaro, Joao Pinto, Lars Persson,
netdev
In-Reply-To: <fc8e5141-5815-9a6d-51ed-ddd7e5c2bbc8@axis.com>
[-- Attachment #1: Type: text/plain, Size: 1909 bytes --]
Hi!
> I'm debugging a transmit queue 0 timeout on stmmac with DWMAC4 (4.10a).
> I'm using kernel v4.9.23, which is before multi queue support was added.
> I've cherry-picked
> 98a29944774a ("net: ethernet: stmmac: remove private tx queue lock")
> 84c53b4baef8 ("stmmac: fix memory barriers")
> but I still get tx timeouts with these patches.
>
> I've managed to reproduce the problem several times,
> mainly by transmitting the syslog over HTTP.
How long does it take till timeout? Umm. And if you go through the
list... I believe we understood what was wrong with the timeout
handling and how to fix it...
You may want to tweak tx coalescing parameters. If you set them
"right" you should get timeouts every 5 minutes or so. That makes it
easier to debug. This should do the trick:
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
-#define STMMAC_COAL_TX_TIMER 40000
+#define STMMAC_COAL_TX_TIMER 1000
Now that you have driver that crashes early, you might want to do some
voodoo to stop the crashing. This worked for me:
@@ -2043,7 +2063,11 @@ static netdev_tx_t stmmac_xmit(struct sk_buff
*skb, stru\
ct net_device *dev)
} else
priv->tx_count_frames = 0;
+ dma_rmb();
+ dma_wmb();
/* To avoid raise condition */
+ BUG_ON(first->des01.etx.own); /* This BUG_ON seems to be enough.
+ Replacing it with barriers is _not_enough. */
priv->hw->desc->set_tx_owner(first);
wmb();
No, the BUG_ON() does not trigger. Yes, it still fixes the driver for
me. You may want to verify it has same effect for you.
At that point I ran out of time, and out of goats to sacrifice. You
may be more lucky :-).
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]
^ permalink raw reply
* Re: [patch iproute2 v2 repost 1/3] tc_filter: add support for chain index
From: Jiri Pirko @ 2017-05-23 13:40 UTC (permalink / raw)
To: Stephen Hemminger
Cc: netdev, davem, jhs, xiyou.wangcong, dsa, edumazet, daniel,
alexander.h.duyck, simon.horman, mlxsw
In-Reply-To: <20170522133315.3490fe0a@xeon-e3>
Mon, May 22, 2017 at 10:33:15PM CEST, stephen@networkplumber.org wrote:
>On Tue, 16 May 2017 19:29:35 +0200
>Jiri Pirko <jiri@resnulli.us> wrote:
>
>> From: Jiri Pirko <jiri@mellanox.com>
>>
>> Allow user to put filter to a specific chain identified by index.
>>
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>
>Applied to net-next branch of iproute2
Looks like you missed the uapi part:
CC tc_filter.o
tc_filter.c: In function ‘tc_filter_modify’:
tc_filter.c:159:34: error: ‘TCA_CHAIN’ undeclared (first use in this function)
addattr32(&req.n, sizeof(req), TCA_CHAIN, chain_index);
^~~~~~~~~
^ permalink raw reply
* [iproute PATCH] tc: m_xt: Prevent a segfault in libipt
From: Phil Sutter @ 2017-05-23 13:40 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev, Phil Sutter
From: Phil Sutter <psutter@redhat.com>
This happens with NAT targets, such as SNAT, DNAT and MASQUERADE. These
are still not usable with this patch, but at least tc doesn't crash
anymore when one tries to use them.
Signed-off-by: Phil Sutter <phil@nwl.cc>
---
tc/m_xt.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tc/m_xt.c b/tc/m_xt.c
index e59df8e10afef..ad52d239caf61 100644
--- a/tc/m_xt.c
+++ b/tc/m_xt.c
@@ -146,6 +146,9 @@ static int parse_ipt(struct action_util *a, int *argc_p,
char ***argv_p, int tca_id, struct nlmsghdr *n)
{
struct xtables_target *m = NULL;
+#if XTABLES_VERSION_CODE >= 6
+ struct ipt_entry fw = {};
+#endif
struct rtattr *tail;
int c;
@@ -206,7 +209,7 @@ static int parse_ipt(struct action_util *a, int *argc_p,
default:
#if XTABLES_VERSION_CODE >= 6
if (m != NULL && m->x6_parse != NULL) {
- xtables_option_tpcall(c, argv, 0, m, NULL);
+ xtables_option_tpcall(c, argv, 0, m, &fw);
#else
if (m != NULL && m->parse != NULL) {
m->parse(c - m->option_offset, argv, 0,
--
2.11.0
^ permalink raw reply related
* Re: [net PATCH] mlx5: fix bug reading rss_hash_type from CQE
From: Saeed Mahameed @ 2017-05-23 13:41 UTC (permalink / raw)
To: Jesper Dangaard Brouer
Cc: Saeed Mahameed, Daniel Borkmann, Linux Netdev List, Tariq Toukan,
Alexei Starovoitov, Arnaldo Carvalho de Melo
In-Reply-To: <20170523150420.770f6c4e@redhat.com>
On Tue, May 23, 2017 at 4:04 PM, Jesper Dangaard Brouer
<brouer@redhat.com> wrote:
> On Tue, 23 May 2017 13:58:44 +0300
> Saeed Mahameed <saeedm@dev.mellanox.co.il> wrote:
>
>> On Mon, May 22, 2017 at 9:13 PM, Jesper Dangaard Brouer
>> <brouer@redhat.com> wrote:
>> > Masks for extracting part of the Completion Queue Entry (CQE)
>> > field rss_hash_type was swapped, namely CQE_RSS_HTYPE_IP and
>> > CQE_RSS_HTYPE_L4.
>> >
>> > The bug resulted in setting skb->l4_hash, even-though the
>> > rss_hash_type indicated that hash was NOT computed over the
>> > L4 (UDP or TCP) part of the packet.
>> >
>> > Added comments from the datasheet, to make it more clear what
>> > these masks are selecting.
>> >
>> > Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
>> > ---
>> > include/linux/mlx5/device.h | 10 ++++++++--
>> > 1 file changed, 8 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h
>> > index dd9a263ed368..a940ec6a046c 100644
>> > --- a/include/linux/mlx5/device.h
>> > +++ b/include/linux/mlx5/device.h
>> > @@ -787,8 +787,14 @@ enum {
>> > };
>> >
>> > enum {
>> > - CQE_RSS_HTYPE_IP = 0x3 << 6,
>> > - CQE_RSS_HTYPE_L4 = 0x3 << 2,
>> > + CQE_RSS_HTYPE_IP = 0x3 << 2,
>> > + /* cqe->rss_hash_type[3:2] - IP destination selected for hash
>> > + * (00 = none, 01 = IPv4, 10 = IPv6, 11 = Reserved)
>> > + */
>> > + CQE_RSS_HTYPE_L4 = 0x3 << 6,
>> > + /* cqe->rss_hash_type[7:6] - L4 destination selected for hash
>> > + * (00 = none, 01 = TCP. 10 = UDP, 11 = IPSEC.SPI
>> > + */
>> > };
>> >
>>
>> Acked-by: Saeed Mahameed <saeedm@mellanox.com>
>>
>> Nice catch Jesper !!
>>
>> Can I ask how did you find the hash was wrong ?
>> any counters/indicators we can look for in internal testing ?
>
> Found this when developing the XDP rxhash RFC patches[1][2]. And I used my
> xdp_rxhash[3] program to inspect the hash values, but I guess that
> doesn't help for internal testing.
>
> [1] http://patchwork.ozlabs.org/patch/764057/
> [2] http://patchwork.ozlabs.org/patch/764060/
> [3] https://github.com/netoptimizer/prototype-kernel/tree/master/kernel/samples/bpf
>
> I also have a trafgen script that generate fake packets, but for your
> purpose you can just use ping. A standard ICMP ping packet should be
> categorized as
> CQE_RSS_HTYPE_IP == (IPv4=01) and
> CQE_RSS_HTYPE_L4 == (none=00).
>
> I was going to recommend using a cls_bpf program to inspect the same,
> but it looks like it doesn't expose the skb->l4_hash bit, which shows
> the bug.
>
> I guess, Alexie would say use kprobes. I tried, but everything gets
> inlined in the driver. I did find a reliable inspection point, which
> is napi_gro_receive().
>
> Basically follow my blogpost:
> http://netoptimizer.blogspot.dk/2016/12/reading-live-runtime-kernel-variables.html
>
> This is how you can verify my patch works with perf probe:
>
> perf probe -a 'napi_gro_receive hash=skb->hash htype=skb->ooo_okay:u8 skb->dev->name:string'
>
> perf record -e probe:napi_gro_receive -aR
> # send traffic
> perf script # results
> perf probe -d napi_gro_receive
>
Thanks Jesper, will try that soon.
> Notice (acme), that I had to do an ugly trick: "htype=skb->ooo_okay:u8"
> because perf didn't correctly decode bit the field skb->l4_hash. Thus,
> I'm type casting "ooo_okay" to u8, and skb->l4_hash is set if htype=2,
> as skb->l4_hash is the second bit in that byte. Maybe ACME can fix that? ;-)
>
> --
> Best regards,
> Jesper Dangaard Brouer
> MSc.CS, Principal Kernel Engineer at Red Hat
> LinkedIn: http://www.linkedin.com/in/brouer
>
> This is how a ping flood looks like with xdp_rxhash
>
> [jbrouer@skylake prototype-kernel]$ sudo ./xdp_rxhash --dev mlx5p2 --sec 2
>
> xdp-action pps pps-human-readable mem
> XDP_ABORTED 0 0 2.000273 read
> XDP_DROP 0 0 2.000272 read
> XDP_PASS 95626 95,626 2.000272 read
> XDP_TX 0 0 2.000272 read
> rx_total 95626 95,626 2.000272 read
>
> hash_type:L3 pps pps-human-readable sample-period
> Unknown 0 0 2.000270
> IPv4 95626 95,626 2.000272
> IPv6 0 0 2.000272
>
> hash_type:L4 pps pps-human-readable sample-period
> Unknown 95627 95,627 2.000272
> TCP 0 0 2.000272
> UDP 0 0 2.000270
>
> ^CInterrupted: Removing XDP program on ifindex:5 device:mlx5p2
^ permalink raw reply
* Re: [PATCH net] net/mlx4: Fix the check in attaching steering rules
From: Or Gerlitz @ 2017-05-23 13:46 UTC (permalink / raw)
To: Tariq Toukan, David S. Miller; +Cc: netdev, Eran Ben Elisha, Talat Batheesh
In-Reply-To: <1495543807-14956-1-git-send-email-tariqt@mellanox.com>
On 5/23/2017 3:50 PM, Tariq Toukan wrote:
> From: Talat Batheesh <talatb@mellanox.com>
>
> Our previous patch (cited below) introduced a regression
> for RAW Eth QPs.
>
> Fix it by checking if the QP number provided by user-space
> exists, hence allowing steering rules to be added for valid
> QPs only.
>
> Fixes: 89c557687a32 ("net/mlx4_en: Avoid adding steering rules with ...")
> Reported-by: Or Gerlitz <gerlitz.or@gmail.com>
> Signed-off-by: Talat Batheesh <talatb@mellanox.com>
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Acked-by: Or Gerlitz <ogerlitz@mellanox.com>
^ permalink raw reply
* Re: [PATCH 1/3] stmmac: pci: Overcome stmmac_pci_info structure
From: kbuild test robot @ 2017-05-23 13:48 UTC (permalink / raw)
To: Jan Kiszka
Cc: kbuild-all, Giuseppe Cavallaro, Alexandre Torgue, David Miller,
netdev, linux-kernel, Andy Shevchenko
In-Reply-To: <5d7b7aa99a04e86196ff7eea11f0ede7a95deac1.1495451529.git.jan.kiszka@siemens.com>
[-- Attachment #1: Type: text/plain, Size: 1695 bytes --]
Hi Jan,
[auto build test ERROR on net-next/master]
[also build test ERROR on v4.12-rc2 next-20170523]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Jan-Kiszka/stmmac-pci-Refactor-DMI-probing/20170523-165305
config: x86_64-allmodconfig (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All errors (new ones prefixed by >>):
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:267:3: error: initializer element is not computable at load time
(kernel_ulong_t)&stmmac_default_setup,
^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:267:3: note: (near initialization for 'stmmac_id_table[0].class')
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:271:3: error: initializer element is not computable at load time
(kernel_ulong_t)&stmmac_default_setup,
^
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:271:3: note: (near initialization for 'stmmac_id_table[1].class')
vim +267 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
261 #define STMMAC_QUARK_ID 0x0937
262 #define STMMAC_DEVICE_ID 0x1108
263
264 static const struct pci_device_id stmmac_id_table[] = {
265 {
266 PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID),
> 267 (kernel_ulong_t)&stmmac_default_setup,
268 },
269 {
270 PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC),
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 60065 bytes --]
^ permalink raw reply
* Re: [PATCH v2 netdev] net: phy: marvell: Limit errata to 88m1101
From: Daniel Walker @ 2017-05-23 14:00 UTC (permalink / raw)
To: Andrew Lunn, David Miller; +Cc: Harini Katakam, Florian Fainelli, netdev
In-Reply-To: <1495495713-28374-1-git-send-email-andrew@lunn.ch>
On 05/22/2017 04:28 PM, Andrew Lunn wrote:
> The 88m1101 has an errata when configuring autoneg. However, it was
> being applied to many other Marvell PHYs as well. Limit its scope to
> just the 88m1101.
>
> Fixes: 76884679c644 ("phylib: Add support for Marvell 88e1111S and 88e1145")
> Reported-by: Daniel Walker <danielwa@cisco.com>
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>
> ---
>
> v2:
> Forgot netdev
>
> drivers/net/phy/marvell.c | 67 ++++++++++++++++++++++++++---------------------
> 1 file changed, 37 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c
> index 88cd97b44ba6..77221d3f254f 100644
> --- a/drivers/net/phy/marvell.c
> +++ b/drivers/net/phy/marvell.c
> @@ -267,35 +267,6 @@ static int marvell_config_aneg(struct phy_device *phydev)
> {
> int err;
>
> - /* The Marvell PHY has an errata which requires
> - * that certain registers get written in order
> - * to restart autonegotiation
> - */
> - err = phy_write(phydev, MII_BMCR, BMCR_RESET);
> -
It looks fine to me, but I'm not sure if this line BMCR_RESET was part
of the errata or the comment. I guess it's OK to assume it tho.
Danie.
^ permalink raw reply
* Re: [PATCH] tipc: Delete error messages for failed memory allocations in three functions
From: Joe Perches @ 2017-05-23 14:02 UTC (permalink / raw)
To: SF Markus Elfring, tipc-discussion, netdev, David S. Miller,
Jon Maloy, Ying Xue
Cc: LKML, kernel-janitors
In-Reply-To: <7ac9d513-6f9f-a096-e68f-81a722c2723c@users.sourceforge.net>
On Tue, 2017-05-23 at 15:07 +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 23 May 2017 14:45:25 +0200
>
> Omit four extra messages for memory allocation failures in these functions.
This is fine but you should look to optimize or figure out
whether optimization is desirable for the effective realloc.
> diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
[]
> @@ -270,11 +268,9 @@ static struct publication *tipc_nameseq_insert_publ(struct net *net,
> if (nseq->first_free == nseq->alloc) {
> struct sub_seq *sseqs = tipc_subseq_alloc(nseq->alloc * 2);
>
> - if (!sseqs) {
> - pr_warn("Cannot publish {%u,%u,%u}, no memory\n",
> - type, lower, upper);
> + if (!sseqs)
> return NULL;
> - }
> +
> memcpy(sseqs, nseq->sseqs,
> nseq->alloc * sizeof(struct sub_seq));
tipc_subseq_alloc does a kcalloc (memset to 0),
half of which is immediately overwritten.
In other words, don't just blindly remove stuff,
understand what it does and improve it.
^ permalink raw reply
* Re: [PATCH net] net/mlx4: Fix the check in attaching steering rules
From: Leon Romanovsky @ 2017-05-23 14:10 UTC (permalink / raw)
To: Tariq Toukan
Cc: David S. Miller, netdev, Eran Ben Elisha, Or Gerlitz,
Talat Batheesh
In-Reply-To: <20170523131513.GN17751@mtr-leonro.local>
[-- Attachment #1: Type: text/plain, Size: 2660 bytes --]
On Tue, May 23, 2017 at 04:15:13PM +0300, Leon Romanovsky wrote:
> On Tue, May 23, 2017 at 03:50:07PM +0300, Tariq Toukan wrote:
> > From: Talat Batheesh <talatb@mellanox.com>
> >
> > Our previous patch (cited below) introduced a regression
> > for RAW Eth QPs.
> >
> > Fix it by checking if the QP number provided by user-space
> > exists, hence allowing steering rules to be added for valid
> > QPs only.
> >
> > Fixes: 89c557687a32 ("net/mlx4_en: Avoid adding steering rules with ...")
> > Reported-by: Or Gerlitz <gerlitz.or@gmail.com>
> > Signed-off-by: Talat Batheesh <talatb@mellanox.com>
> > Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
> > ---
> > drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | 3 +--
> > drivers/net/ethernet/mellanox/mlx4/qp.c | 14 ++++++++++++++
> > include/linux/mlx4/qp.h | 1 +
> > 3 files changed, 16 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> > index ae5fdc2df654..00a7cd3dcc2e 100644
> > --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> > +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c
> > @@ -1562,8 +1562,7 @@ static int mlx4_en_flow_replace(struct net_device *dev,
> > qpn = priv->drop_qp.qpn;
> > else if (cmd->fs.ring_cookie & EN_ETHTOOL_QP_ATTACH) {
> > qpn = cmd->fs.ring_cookie & (EN_ETHTOOL_QP_ATTACH - 1);
> > - if (qpn < priv->rss_map.base_qpn ||
> > - qpn >= priv->rss_map.base_qpn + priv->rx_ring_num) {
> > + if (!mlx4_qp_lookup(priv->mdev->dev, qpn)) {
> > en_warn(priv, "rxnfc: QP (0x%x) doesn't exist\n", qpn);
> > return -EINVAL;
> > }
> > diff --git a/drivers/net/ethernet/mellanox/mlx4/qp.c b/drivers/net/ethernet/mellanox/mlx4/qp.c
> > index 2d6abd4662b1..1eff2fe32a8b 100644
> > --- a/drivers/net/ethernet/mellanox/mlx4/qp.c
> > +++ b/drivers/net/ethernet/mellanox/mlx4/qp.c
> > @@ -384,6 +384,20 @@ static void mlx4_qp_free_icm(struct mlx4_dev *dev, int qpn)
> > __mlx4_qp_free_icm(dev, qpn);
> > }
> >
> > +struct mlx4_qp *mlx4_qp_lookup(struct mlx4_dev *dev, u32 qpn)
> > +{
> > + struct mlx4_qp_table *qp_table = &mlx4_priv(dev)->qp_table;
> > + struct mlx4_qp *qp;
> > +
> > + spin_lock(&qp_table->lock);
> > +
> > + qp = __mlx4_qp_lookup(dev, qpn);
> > +
> > + spin_unlock(&qp_table->lock);
> > + return qp;
> > +}
> > +EXPORT_SYMBOL_GPL(mlx4_qp_lookup);
>
> Tariq,
>
> Why do you need this export and header fils? You are using this function in one place only.
>
Let's keep it as you proposed for better separation of en vs. core modules.
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Thanks
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* [net 2/8] net/sched: act_csum: Add accessors for offloading drivers
From: Saeed Mahameed @ 2017-05-23 14:16 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed
In-Reply-To: <20170523141610.27833-1-saeedm@mellanox.com>
From: Or Gerlitz <ogerlitz@mellanox.com>
Add the accessors for realizing if this is a csum action,
and for which fields checksum is needed.
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
include/net/tc_act/tc_csum.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/net/tc_act/tc_csum.h b/include/net/tc_act/tc_csum.h
index f31fb6331a53..3248beaf16b0 100644
--- a/include/net/tc_act/tc_csum.h
+++ b/include/net/tc_act/tc_csum.h
@@ -3,6 +3,7 @@
#include <linux/types.h>
#include <net/act_api.h>
+#include <linux/tc_act/tc_csum.h>
struct tcf_csum {
struct tc_action common;
@@ -11,4 +12,18 @@ struct tcf_csum {
};
#define to_tcf_csum(a) ((struct tcf_csum *)a)
+static inline bool is_tcf_csum(const struct tc_action *a)
+{
+#ifdef CONFIG_NET_CLS_ACT
+ if (a->ops && a->ops->type == TCA_ACT_CSUM)
+ return true;
+#endif
+ return false;
+}
+
+static inline u32 tcf_csum_update_flags(const struct tc_action *a)
+{
+ return to_tcf_csum(a)->update_flags;
+}
+
#endif /* __NET_TC_CSUM_H */
--
2.11.0
^ permalink raw reply related
* [net 4/8] net/mlx5e: Properly enforce disallowing of partial field re-write offload
From: Saeed Mahameed @ 2017-05-23 14:16 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed
In-Reply-To: <20170523141610.27833-1-saeedm@mellanox.com>
From: Or Gerlitz <ogerlitz@mellanox.com>
Currently we don't support partial header re-writes through TC pedit
action offloading. However, the code that enforces that wasn't err-ing
on cases where the first and last bits of the mask are set but there is
some zero bit between them, such as in the below example, fix that!
tc filter add dev enp1s0 protocol ip parent ffff: prio 10 flower
ip_proto udp dst_port 2001 skip_sw
action pedit munge ip src set 1.0.0.1 retain 0xff0000ff
Fixes: d79b6df6b10a ('net/mlx5e: Add parsing of TC pedit actions to HW format')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 9dd83c7e4c51..0387c321f0a2 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -926,7 +926,7 @@ static int offload_pedit_fields(struct pedit_headers *masks,
struct mlx5e_tc_flow_parse_attr *parse_attr)
{
struct pedit_headers *set_masks, *add_masks, *set_vals, *add_vals;
- int i, action_size, nactions, max_actions, first, last;
+ int i, action_size, nactions, max_actions, first, last, first_z;
void *s_masks_p, *a_masks_p, *vals_p;
u32 s_mask, a_mask, val;
struct mlx5_fields *f;
@@ -985,9 +985,10 @@ static int offload_pedit_fields(struct pedit_headers *masks,
memcpy(&val, vals_p, f->size);
field_bsize = f->size * BITS_PER_BYTE;
+ first_z = find_first_zero_bit(&mask, field_bsize);
first = find_first_bit(&mask, field_bsize);
last = find_last_bit(&mask, field_bsize);
- if (first > 0 || last != (field_bsize - 1)) {
+ if (first > 0 || last != (field_bsize - 1) || first_z < last) {
printk(KERN_WARNING "mlx5: partial rewrite (mask %lx) is currently not offloaded\n",
mask);
return -EOPNOTSUPP;
--
2.11.0
^ permalink raw reply related
* [net 3/8] net/mlx5e: Allow TC csum offload if applied together with pedit action
From: Saeed Mahameed @ 2017-05-23 14:16 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed
In-Reply-To: <20170523141610.27833-1-saeedm@mellanox.com>
From: Or Gerlitz <ogerlitz@mellanox.com>
When offloading header re-writes, the HW re-calculates the relevant L3/L4
checksums. Hence, when upper layers (as done by OVS) ask for TC checksum action
offload together with pedit offload, don't err. This command now works:
tc filter add dev ens1f0 protocol ip parent ffff: prio 20 flower skip_sw
ip_proto tcp dst_port 9001
action pedit ex munge tcp dport set 0x1234 pipe
action csum tcp
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 39 +++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index a90dd26ea51c..9dd83c7e4c51 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -43,6 +43,7 @@
#include <net/tc_act/tc_vlan.h>
#include <net/tc_act/tc_tunnel_key.h>
#include <net/tc_act/tc_pedit.h>
+#include <net/tc_act/tc_csum.h>
#include <net/vxlan.h>
#include <net/arp.h>
#include "en.h"
@@ -1109,6 +1110,28 @@ static int parse_tc_pedit_action(struct mlx5e_priv *priv,
return err;
}
+static bool csum_offload_supported(struct mlx5e_priv *priv, u32 action, u32 update_flags)
+{
+ u32 prot_flags = TCA_CSUM_UPDATE_FLAG_IPV4HDR | TCA_CSUM_UPDATE_FLAG_TCP |
+ TCA_CSUM_UPDATE_FLAG_UDP;
+
+ /* The HW recalcs checksums only if re-writing headers */
+ if (!(action & MLX5_FLOW_CONTEXT_ACTION_MOD_HDR)) {
+ netdev_warn(priv->netdev,
+ "TC csum action is only offloaded with pedit\n");
+ return false;
+ }
+
+ if (update_flags & ~prot_flags) {
+ netdev_warn(priv->netdev,
+ "can't offload TC csum action for some header/s - flags %#x\n",
+ update_flags);
+ return false;
+ }
+
+ return true;
+}
+
static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
struct mlx5e_tc_flow_parse_attr *parse_attr,
struct mlx5e_tc_flow *flow)
@@ -1149,6 +1172,14 @@ static int parse_tc_nic_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
continue;
}
+ if (is_tcf_csum(a)) {
+ if (csum_offload_supported(priv, attr->action,
+ tcf_csum_update_flags(a)))
+ continue;
+
+ return -EOPNOTSUPP;
+ }
+
if (is_tcf_skbedit_mark(a)) {
u32 mark = tcf_skbedit_mark(a);
@@ -1651,6 +1682,14 @@ static int parse_tc_fdb_actions(struct mlx5e_priv *priv, struct tcf_exts *exts,
continue;
}
+ if (is_tcf_csum(a)) {
+ if (csum_offload_supported(priv, attr->action,
+ tcf_csum_update_flags(a)))
+ continue;
+
+ return -EOPNOTSUPP;
+ }
+
if (is_tcf_mirred_egress_redirect(a)) {
int ifindex = tcf_mirred_ifindex(a);
struct net_device *out_dev, *encap_dev = NULL;
--
2.11.0
^ permalink raw reply related
* [pull request][net 0/8] Mellanox, mlx5 fixes 2017-05-23
From: Saeed Mahameed @ 2017-05-23 14:16 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
Hi Dave,
This series contains some fixes for the mlx5 driver and one small patch that
adds csum actions accessors in include/net/tc_act/tc_csum.h needed by some of
mlx5 fixes patches.
Details are below.
Please pull and let me know if there's any problem.
Note: This series doesn't introduce any merge conflict with the ongoing mlx5
for-next submission.
For -stable kernels >= 4.7:
("net/mlx5: Avoid using pending command interface slots")
("net/mlx5: Tolerate irq_set_affinity_hint() failures")
Thanks,
Saeed.
--
The following changes since commit fadd2ce5a3680fb265694f573cbfb8bcb7d6c9d5:
Merge tag 'pstore-v4.12-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux (2017-05-22 19:31:07 -0700)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/saeed/linux.git tags/mlx5-fixes-2017-05-23
for you to fetch changes up to b665d98edc9ab295169be2fc5bb4e89a46de0a1a:
net/mlx5: Tolerate irq_set_affinity_hint() failures (2017-05-23 16:23:32 +0300)
----------------------------------------------------------------
mlx5-fixes-2017-05-23
Some TC offloads fixes from Or Gerlitz.
>From Erez, mlx5 IPoIB RX fix to improve GRO.
>From Mohamad, Command interface fix to improve mitigation against FW
commands timeouts.
>From Tariq, Driver load Tolerance against affinity settings failures.
Thanks,
Saeed.
----------------------------------------------------------------
Erez Shitrit (1):
net/mlx5e: IPoIB, handle RX packet correctly
Mohamad Haj Yahia (1):
net/mlx5: Avoid using pending command interface slots
Or Gerlitz (5):
net/mlx5e: Use the correct delete call on offloaded TC encap entry detach
net/sched: act_csum: Add accessors for offloading drivers
net/mlx5e: Allow TC csum offload if applied together with pedit action
net/mlx5e: Properly enforce disallowing of partial field re-write offload
net/mlx5e: Fix warnings around parsing of TC pedit actions
Tariq Toukan (1):
net/mlx5: Tolerate irq_set_affinity_hint() failures
drivers/net/ethernet/mellanox/mlx5/core/cmd.c | 41 ++++++++++++++--
drivers/net/ethernet/mellanox/mlx5/core/en_rx.c | 8 +++-
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 60 ++++++++++++++++++++----
drivers/net/ethernet/mellanox/mlx5/core/eq.c | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/health.c | 2 +-
drivers/net/ethernet/mellanox/mlx5/core/main.c | 15 ++----
include/linux/mlx5/driver.h | 7 ++-
include/net/tc_act/tc_csum.h | 15 ++++++
8 files changed, 120 insertions(+), 30 deletions(-)
^ permalink raw reply
* [net 1/8] net/mlx5e: Use the correct delete call on offloaded TC encap entry detach
From: Saeed Mahameed @ 2017-05-23 14:16 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed
In-Reply-To: <20170523141610.27833-1-saeedm@mellanox.com>
From: Or Gerlitz <ogerlitz@mellanox.com>
We wrongly direcly invoke hlist_del_rcu() and not hash_del_rcu() which
does a slightly different call now and may change later, fix that.
Fixes: a54e20b4fcae ('net/mlx5e: Add basic TC tunnel set action for SRIOV offloads')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Paul Blakey <paulb@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 11c27e4fadf6..a90dd26ea51c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -384,7 +384,7 @@ static void mlx5e_detach_encap(struct mlx5e_priv *priv,
if (e->flags & MLX5_ENCAP_ENTRY_VALID)
mlx5_encap_dealloc(priv->mdev, e->encap_id);
- hlist_del_rcu(&e->encap_hlist);
+ hash_del_rcu(&e->encap_hlist);
kfree(e->encap_header);
kfree(e);
}
--
2.11.0
^ permalink raw reply related
* [net 5/8] net/mlx5e: Fix warnings around parsing of TC pedit actions
From: Saeed Mahameed @ 2017-05-23 14:16 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Or Gerlitz, Saeed Mahameed
In-Reply-To: <20170523141610.27833-1-saeedm@mellanox.com>
From: Or Gerlitz <ogerlitz@mellanox.com>
The sparse tool emits these correct complaints:
drivers/net/ethernet/mellanox/mlx5/core//en_tc.c:1005:25: warning: cast to restricted __be32
drivers/net/ethernet/mellanox/mlx5/core//en_tc.c:1007:25: warning: cast to restricted __be16
The value is provided from user-space in network order, but there's
no way for them to realize that, avoid the warnings by casting to the
appropriate type.
Fixes: d79b6df6b10a ('net/mlx5e: Add parsing of TC pedit actions to HW format')
Signed-off-by: Or Gerlitz <ogerlitz@mellanox.com>
Reported-by: Leon Romanovsky <leonro@mellanox.com>
Reviewed-by: Paul Blakey <paulb@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 0387c321f0a2..ec63158ab643 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -928,9 +928,9 @@ static int offload_pedit_fields(struct pedit_headers *masks,
struct pedit_headers *set_masks, *add_masks, *set_vals, *add_vals;
int i, action_size, nactions, max_actions, first, last, first_z;
void *s_masks_p, *a_masks_p, *vals_p;
- u32 s_mask, a_mask, val;
struct mlx5_fields *f;
u8 cmd, field_bsize;
+ u32 s_mask, a_mask;
unsigned long mask;
void *action;
@@ -947,7 +947,8 @@ static int offload_pedit_fields(struct pedit_headers *masks,
for (i = 0; i < ARRAY_SIZE(fields); i++) {
f = &fields[i];
/* avoid seeing bits set from previous iterations */
- s_mask = a_mask = mask = val = 0;
+ s_mask = 0;
+ a_mask = 0;
s_masks_p = (void *)set_masks + f->offset;
a_masks_p = (void *)add_masks + f->offset;
@@ -982,9 +983,8 @@ static int offload_pedit_fields(struct pedit_headers *masks,
memset(a_masks_p, 0, f->size);
}
- memcpy(&val, vals_p, f->size);
-
field_bsize = f->size * BITS_PER_BYTE;
+
first_z = find_first_zero_bit(&mask, field_bsize);
first = find_first_bit(&mask, field_bsize);
last = find_last_bit(&mask, field_bsize);
@@ -1004,11 +1004,11 @@ static int offload_pedit_fields(struct pedit_headers *masks,
}
if (field_bsize == 32)
- MLX5_SET(set_action_in, action, data, ntohl(val));
+ MLX5_SET(set_action_in, action, data, ntohl(*(__be32 *)vals_p));
else if (field_bsize == 16)
- MLX5_SET(set_action_in, action, data, ntohs(val));
+ MLX5_SET(set_action_in, action, data, ntohs(*(__be16 *)vals_p));
else if (field_bsize == 8)
- MLX5_SET(set_action_in, action, data, val);
+ MLX5_SET(set_action_in, action, data, *(u8 *)vals_p);
action += action_size;
nactions++;
--
2.11.0
^ permalink raw reply related
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