* Re: [PATCH net-next v2 00/21] net/ipv6: Separate data structures for FIB and data path
From: David Miller @ 2018-04-18 3:45 UTC (permalink / raw)
To: dsahern; +Cc: netdev, idosch, roopa, eric.dumazet, weiwan, kafai, yoshfuji
In-Reply-To: <20180418003327.19992-1-dsahern@gmail.com>
From: David Ahern <dsahern@gmail.com>
Date: Tue, 17 Apr 2018 17:33:06 -0700
> IPv6 uses the same data struct for both control plane (FIB entries) and
> data path (dst entries). This struct has elements needed for both paths
> adding memory overhead and complexity (taking a dst hold in most places
> but an additional reference on rt6i_ref in a few). Furthermore, because
> of the dst_alloc tie, all FIB entries are allocated with GFP_ATOMIC.
>
> This patch set separates FIB entries from dst entries, better aligning
> IPv6 code with IPv4, simplifying the reference counting and allowing
> FIB entries added by userspace (not autoconf) to use GFP_KERNEL. It is
> first step to a number of performance and scalability changes.
>
> The end result of this patch set:
> - FIB entries (fib6_info):
> /* size: 208, cachelines: 4, members: 25 */
> /* sum members: 207, holes: 1, sum holes: 1 */
>
> - dst entries (rt6_info)
> /* size: 240, cachelines: 4, members: 11 */
>
> Versus the the single rt6_info struct today for both paths:
> /* size: 320, cachelines: 5, members: 28 */
>
> This amounts to a 35% reduction in memory use for FIB entries and a
> 25% reduction for dst entries.
Looks great, series applied, thanks David!
^ permalink raw reply
* Re: [PATCH 04/10] net: ax88796: Add block_input/output hooks to ax_plat_data
From: Michael Schmitz @ 2018-04-18 3:46 UTC (permalink / raw)
To: Finn Thain
Cc: kbuild test robot, kbuild-all, netdev, Linux/m68k,
Michael Karcher, Michael Karcher
In-Reply-To: <alpine.LNX.2.21.1804181109040.8@nippy.intranet>
Hi Finn,
On Wed, Apr 18, 2018 at 1:23 PM, Finn Thain <fthain@telegraphics.com.au> wrote:
> On Wed, 18 Apr 2018, Michael Schmitz wrote:
>
>> I think this is a false positive - we're encouraged to provide the
>> full parameter list for functions, so the sreuct sk_buff* can't be
>> avoided.
>>
>
> I don't think it's a false positive. I think ax88796.h would need to
> #include <linux/skbuff.h>.
>
> You may be able to get away with a forward declaration, as in,
> struct skbuff;
> but I'm not sure about that. I would have to build mach-anubis.c to check.
I've added a forward declaration for now - worked for struct
net_device as well (would have been missing from the mach-anubis.c
build as well because of the missing netdevice header).
> But why do you need to pass an skbuff pointer here? xs100_block_input()
> only accesses skb->data.
I'm forced to use the same interface as ax_block_input()
(xs100_block_input is a plug-in replacement for that). But both could
be changed. Let's leave that for later please.
> BTW, this patch has an unrelated whitespace change.
Fixed, thanks.
Cheers,
Michael
>
> --
>
>> Cheers,
>>
>> Michael
>>
>>
>> On Wed, Apr 18, 2018 at 6:46 AM, kbuild test robot <lkp@intel.com> wrote:
>> > Hi Michael,
>> >
>> > I love your patch! Perhaps something to improve:
>> >
>> > [auto build test WARNING on v4.16]
>> > [cannot apply to net-next/master net/master v4.17-rc1 next-20180417]
>> > [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/Michael-Schmitz/New-network-driver-for-Amiga-X-Surf-100-m68k/20180417-141150
>> > config: arm-samsung (attached as .config)
>> > compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
>> > reproduce:
>> > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>> > chmod +x ~/bin/make.cross
>> > # save the attached .config to linux build tree
>> > make.cross ARCH=arm
>> >
>> > All warnings (new ones prefixed by >>):
>> >
>> > In file included from arch/arm/mach-s3c24xx/mach-anubis.c:42:0:
>> >>> include/net/ax88796.h:35:11: warning: 'struct sk_buff' declared inside parameter list will not be visible outside of this definition or declaration
>> > struct sk_buff *skb, int ring_offset);
>> > ^~~~~~~
>> >
>> > vim +35 include/net/ax88796.h
>> >
>> > 20
>> > 21 struct ax_plat_data {
>> > 22 unsigned int flags;
>> > 23 unsigned char wordlength; /* 1 or 2 */
>> > 24 unsigned char dcr_val; /* default value for DCR */
>> > 25 unsigned char rcr_val; /* default value for RCR */
>> > 26 unsigned char gpoc_val; /* default value for GPOC */
>> > 27 u32 *reg_offsets; /* register offsets */
>> > 28 u8 *mac_addr; /* MAC addr (only used when
>> > 29 AXFLG_MAC_FROMPLATFORM is used */
>> > 30
>> > 31 /* uses default ax88796 buffer if set to NULL */
>> > 32 void (*block_output)(struct net_device *dev, int count,
>> > 33 const unsigned char *buf, int star_page);
>> > 34 void (*block_input)(struct net_device *dev, int count,
>> > > 35 struct sk_buff *skb, int ring_offset);
>> > 36 };
>> > 37
>> >
>> > ---
>> > 0-DAY kernel test infrastructure Open Source Technology Center
>> > https://lists.01.org/pipermail/kbuild-all Intel Corporation
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-m68k" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] VSOCK: make af_vsock.ko removable again
From: Stefan Hajnoczi @ 2018-04-18 4:14 UTC (permalink / raw)
To: David Miller; +Cc: netdev, xiyou.wangcong, jhansen
In-Reply-To: <20180417.094512.321362741144442657.davem@davemloft.net>
[-- Attachment #1: Type: text/plain, Size: 1210 bytes --]
On Tue, Apr 17, 2018 at 09:45:12AM -0400, David Miller wrote:
> From: Stefan Hajnoczi <stefanha@redhat.com>
> Date: Tue, 17 Apr 2018 14:25:58 +0800
>
> > Commit c1eef220c1760762753b602c382127bfccee226d ("vsock: always call
> > vsock_init_tables()") introduced a module_init() function without a
> > corresponding module_exit() function.
> >
> > Modules with an init function can only be removed if they also have an
> > exit function. Therefore the vsock module was considered "permanent"
> > and could not be removed.
> >
> > This patch adds an empty module_exit() function so that "rmmod vsock"
> > works. No explicit cleanup is required because:
> >
> > 1. Transports call vsock_core_exit() upon exit and cannot be removed
> > while sockets are still alive.
> > 2. vsock_diag.ko does not perform any action that requires cleanup by
> > vsock.ko.
> >
> > Reported-by: Xiumei Mu <xmu@redhat.com>
> > Cc: Cong Wang <xiyou.wangcong@gmail.com>
> > Cc: Jorgen Hansen <jhansen@vmware.com>
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
>
> Applied, but please provide a proper Fixes: tag next time. I added it
> for you this time.
Will do. Thanks!
Stefan
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]
^ permalink raw reply
* [PATCH v3 2/9] net: ax88796: Fix MAC address reading
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
To read the MAC address from the (virtual) SAprom, the remote DMA
unit needs to be set up like for every other process access to card-local
memory.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/ethernet/8390/ax88796.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 2455547..2a256aa 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -671,10 +671,16 @@ static int ax_init_dev(struct net_device *dev)
if (ax->plat->flags & AXFLG_HAS_EEPROM) {
unsigned char SA_prom[32];
+ ei_outb(6, ioaddr + EN0_RCNTLO);
+ ei_outb(0, ioaddr + EN0_RCNTHI);
+ ei_outb(0, ioaddr + EN0_RSARLO);
+ ei_outb(0, ioaddr + EN0_RSARHI);
+ ei_outb(E8390_RREAD + E8390_START, ioaddr + NE_CMD);
for (i = 0; i < sizeof(SA_prom); i += 2) {
SA_prom[i] = ei_inb(ioaddr + NE_DATAPORT);
SA_prom[i + 1] = ei_inb(ioaddr + NE_DATAPORT);
}
+ ei_outb(ENISR_RDC, ioaddr + EN0_ISR); /* Ack intr. */
if (ax->plat->wordlength == 2)
for (i = 0; i < 16; i++)
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 4/9] net: ax88796: Do not free IRQ in ax_remove() (already freed in ax_close()).
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
This complements the fix in 82533ad9a1c ("net: ethernet: ax88796:
don't call free_irq without request_irq first") that removed the
free_irq call in the error path of probe, to also not call free_irq
when remove is called to revert the effects of probe.
Fixes: 82533ad9a1c (net: ethernet: ax88796: don't call free_irq without request_irq first)
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
drivers/net/ethernet/8390/ax88796.c | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 83e59ae..ecf104c 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -793,7 +793,6 @@ static int ax_remove(struct platform_device *pdev)
struct resource *mem;
unregister_netdev(dev);
- free_irq(dev->irq, dev);
iounmap(ei_local->mem);
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 00/10] New network driver for Amiga X-Surf 100 (m68k)
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev; +Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
This patch series adds support for the Individual Computers X-Surf 100
network card for m68k Amiga, a network adapter based on the AX88796 chip set.
The driver was originally written for kernel version 3.19 by Michael Karcher
(see CC:), and adapted to 4.16 for submission to netdev by me. Questions
regarding motivation for some of the changes are probably best directed at
Michael Karcher.
The driver has been tested by Adrian <glaubitz@physik.fu-berlin.de> who will
send his Tested-by tag separately.
A few changes to the ax88796 driver were required:
- to read the MAC address, some setup of the ax99796 chip must be done,
- attach to the MII bus only on device open to allow module unloading,
- allow to supersede ax_block_input/ax_block_output by card-specific
optimized code,
- use an optional interrupt status callback to allow easier sharing of the
card interrupt,
- set IRQF_SHARED if platform IRQ resource is marked shareable,
The Asix Electronix PHY used on the X-Surf 100 is buggy, and causes the
software reset to hang if the previous command sent to the PHY was also
a soft reset. This bug requires addition of a PHY driver for Asix PHYs
to provide a fixed .soft_reset function, included in this series.
Some additional cleanup:
- do not attempt to free IRQ in ax_remove (complements 82533ad9a1c),
- clear platform drvdata on probe fail and module remove.
Changes since v1:
Raised in review by Andrew Lunn:
- move MII code around to avoid need for forward declaration
- combine patches 2 and 7 to add cleanup in error path
Changes since v2:
- corrected authorship attribution to Michael Karcher
Suggested by Geert Uytterhoeven:
- use ei_local->reset_8390() instead of duplicating ax_reset_8390()
- use %pR to format struct resource pointers
- assign pdev and xs100 pointers in declaration
- don't split error messages
- change Kconfig logic to only require XSURF100 set on Amiga
Suggested by Andrew Lunn:
- add COMPILE_TEST to ax88796 Kconfig options
- use new Asix PHY driver for X-Surf 100
Suggested by Andrew Lunn/Finn Thain:
- declare struct sk_buff in ax88796.h
- correct whitespace error in ax88796.h
This series' patches, in order:
1/9 net: phy: new Asix Electronics PHY driver
2/9 net: ax88796: Fix MAC address reading
3/9 net: ax88796: Attach MII bus only when open
4/9 net: ax88796: Do not free IRQ in ax_remove() (already freed in ax_close()).
5/9 net: ax88796: Add block_input/output hooks to ax_plat_data
6/9 net: ax88796: add interrupt status callback to platform data
7/9 net: ax88796: set IRQF_SHARED flag when IRQ resource is marked as shareable
8/9 net: ax88796: release platform device drvdata on probe error and module remove
9/9 net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)
drivers/net/ethernet/8390/Kconfig | 17 ++-
drivers/net/ethernet/8390/Makefile | 1 +
drivers/net/ethernet/8390/ax88796.c | 228 ++++++++++++--------
drivers/net/ethernet/8390/xsurf100.c | 381 ++++++++++++++++++++++++++++++++++
drivers/net/phy/Kconfig | 6 +
drivers/net/phy/Makefile | 1 +
drivers/net/phy/asix.c | 65 ++++++
drivers/net/phy/phy_device.c | 3 +-
include/linux/phy.h | 1 +
include/net/ax88796.h | 14 ++
10 files changed, 621 insertions(+), 96 deletions(-)
Cheers,
Michael
^ permalink raw reply
* [PATCH v3 1/9] net: phy: new Asix Electronics PHY driver
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
The Asix Electronics PHY found on the X-Surf 100 Amiga Zorro network
card by Individual Computers is buggy, and needs the reset bit toggled
as workaround to make a PHY soft reset succed.
Add workaround driver just for this special case. Export phy_poll_reset()
from core phy_device driver to avoid code duplication.
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/phy/Kconfig | 6 ++++
drivers/net/phy/Makefile | 1 +
drivers/net/phy/asix.c | 65 ++++++++++++++++++++++++++++++++++++++++++
drivers/net/phy/phy_device.c | 3 +-
include/linux/phy.h | 1 +
5 files changed, 75 insertions(+), 1 deletions(-)
create mode 100644 drivers/net/phy/asix.c
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index bdfbabb..f5b484c 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -218,6 +218,12 @@ config AQUANTIA_PHY
---help---
Currently supports the Aquantia AQ1202, AQ2104, AQR105, AQR405
+config ASIX_PHY
+ tristate "Asix PHYs"
+ ---help---
+ Currently supports the Asix Electronics PHY found in the X-Surf 100
+ AX88796 package.
+
config AT803X_PHY
tristate "AT803X PHYs"
---help---
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile
index 01acbcb..701ca0b 100644
--- a/drivers/net/phy/Makefile
+++ b/drivers/net/phy/Makefile
@@ -45,6 +45,7 @@ obj-y += $(sfp-obj-y) $(sfp-obj-m)
obj-$(CONFIG_AMD_PHY) += amd.o
obj-$(CONFIG_AQUANTIA_PHY) += aquantia.o
+obj-$(CONFIG_ASIX_PHY) += asix.o
obj-$(CONFIG_AT803X_PHY) += at803x.o
obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o
obj-$(CONFIG_BCM7XXX_PHY) += bcm7xxx.o
diff --git a/drivers/net/phy/asix.c b/drivers/net/phy/asix.c
new file mode 100644
index 0000000..15e8a0e
--- /dev/null
+++ b/drivers/net/phy/asix.c
@@ -0,0 +1,65 @@
+/*
+ * Driver for Asix PHYs
+ *
+ * Author: Michael Schmitz <schmitzmic@gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/mii.h>
+#include <linux/phy.h>
+
+#define PHY_ID_ASIX 0x003b1841
+
+MODULE_DESCRIPTION("Asix PHY driver");
+MODULE_AUTHOR("Michael Schmitz <schmitzmic@gmail.com>");
+MODULE_LICENSE("GPL");
+
+/**
+ * asix_soft_reset - software reset the PHY via BMCR_RESET bit
+ * @phydev: target phy_device struct
+ *
+ * Description: Perform a software PHY reset using the standard
+ * BMCR_RESET bit and poll for the reset bit to be cleared.
+ * Toggle BMCR_RESET bit off to accomodate broken PHY implementations
+ * such as used on the Individual Computers' X-Surf 100 Zorro card.
+ *
+ * Returns: 0 on success, < 0 on failure
+ */
+static int asix_soft_reset(struct phy_device *phydev)
+{
+ int ret;
+
+ /* Asix PHY won't reset unless reset bit toggles */
+ ret = phy_write(phydev, MII_BMCR, 0);
+ if (ret < 0)
+ return ret;
+
+ phy_write(phydev, MII_BMCR, BMCR_RESET);
+
+ return phy_poll_reset(phydev);
+}
+
+static struct phy_driver asix_driver[] = { {
+ .phy_id = PHY_ID_ASIX,
+ .name = "Asix Electronics",
+ .phy_id_mask = 0xfffffff0,
+ .features = PHY_BASIC_FEATURES,
+ .soft_reset = asix_soft_reset,
+} };
+
+module_phy_driver(asix_driver);
+
+static struct mdio_device_id __maybe_unused asix_tbl[] = {
+ { PHY_ID_ASIX, 0xfffffff0 },
+ { }
+};
+
+MODULE_DEVICE_TABLE(mdio, asix_tbl);
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 777912b..fb8c13b 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -833,7 +833,7 @@ void phy_disconnect(struct phy_device *phydev)
* standard phy_init_hw() which will zero all the other bits in the BMCR
* and reapply all driver-specific and board-specific fixups.
*/
-static int phy_poll_reset(struct phy_device *phydev)
+int phy_poll_reset(struct phy_device *phydev)
{
/* Poll until the reset bit clears (50ms per retry == 0.6 sec) */
unsigned int retries = 12;
@@ -854,6 +854,7 @@ static int phy_poll_reset(struct phy_device *phydev)
msleep(1);
return 0;
}
+EXPORT_SYMBOL(phy_poll_reset);
int phy_init_hw(struct phy_device *phydev)
{
diff --git a/include/linux/phy.h b/include/linux/phy.h
index 7c4c237..fa0c4fd 100644
--- a/include/linux/phy.h
+++ b/include/linux/phy.h
@@ -980,6 +980,7 @@ void phy_attached_print(struct phy_device *phydev, const char *fmt, ...)
int genphy_resume(struct phy_device *phydev);
int genphy_loopback(struct phy_device *phydev, bool enable);
int genphy_soft_reset(struct phy_device *phydev);
+int phy_poll_reset(struct phy_device *phydev);
static inline int genphy_no_soft_reset(struct phy_device *phydev)
{
return 0;
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 3/9] net: ax88796: Attach MII bus only when open
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Call ax_mii_init in ax_open(), and unregister/remove mdiobus resources
in ax_close().
This is needed to be able to unload the module, as the module is busy
while the MII bus is attached.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
---
drivers/net/ethernet/8390/ax88796.c | 183 ++++++++++++++++++-----------------
1 files changed, 95 insertions(+), 88 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 2a256aa..83e59ae 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -389,6 +389,90 @@ static void ax_phy_switch(struct net_device *dev, int on)
ei_outb(reg_gpoc, ei_local->mem + EI_SHIFT(0x17));
}
+static void ax_bb_mdc(struct mdiobb_ctrl *ctrl, int level)
+{
+ struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+ if (level)
+ ax->reg_memr |= AX_MEMR_MDC;
+ else
+ ax->reg_memr &= ~AX_MEMR_MDC;
+
+ ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static void ax_bb_dir(struct mdiobb_ctrl *ctrl, int output)
+{
+ struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+ if (output)
+ ax->reg_memr &= ~AX_MEMR_MDIR;
+ else
+ ax->reg_memr |= AX_MEMR_MDIR;
+
+ ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static void ax_bb_set_data(struct mdiobb_ctrl *ctrl, int value)
+{
+ struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+
+ if (value)
+ ax->reg_memr |= AX_MEMR_MDO;
+ else
+ ax->reg_memr &= ~AX_MEMR_MDO;
+
+ ei_outb(ax->reg_memr, ax->addr_memr);
+}
+
+static int ax_bb_get_data(struct mdiobb_ctrl *ctrl)
+{
+ struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
+ int reg_memr = ei_inb(ax->addr_memr);
+
+ return reg_memr & AX_MEMR_MDI ? 1 : 0;
+}
+
+static const struct mdiobb_ops bb_ops = {
+ .owner = THIS_MODULE,
+ .set_mdc = ax_bb_mdc,
+ .set_mdio_dir = ax_bb_dir,
+ .set_mdio_data = ax_bb_set_data,
+ .get_mdio_data = ax_bb_get_data,
+};
+
+static int ax_mii_init(struct net_device *dev)
+{
+ struct platform_device *pdev = to_platform_device(dev->dev.parent);
+ struct ei_device *ei_local = netdev_priv(dev);
+ struct ax_device *ax = to_ax_dev(dev);
+ int err;
+
+ ax->bb_ctrl.ops = &bb_ops;
+ ax->addr_memr = ei_local->mem + AX_MEMR;
+ ax->mii_bus = alloc_mdio_bitbang(&ax->bb_ctrl);
+ if (!ax->mii_bus) {
+ err = -ENOMEM;
+ goto out;
+ }
+
+ ax->mii_bus->name = "ax88796_mii_bus";
+ ax->mii_bus->parent = dev->dev.parent;
+ snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
+ pdev->name, pdev->id);
+
+ err = mdiobus_register(ax->mii_bus);
+ if (err)
+ goto out_free_mdio_bitbang;
+
+ return 0;
+
+ out_free_mdio_bitbang:
+ free_mdio_bitbang(ax->mii_bus);
+ out:
+ return err;
+}
+
static int ax_open(struct net_device *dev)
{
struct ax_device *ax = to_ax_dev(dev);
@@ -396,6 +480,10 @@ static int ax_open(struct net_device *dev)
netdev_dbg(dev, "open\n");
+ ret = ax_mii_init(dev);
+ if (ret)
+ goto failed_mii;
+
ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
dev->name, dev);
if (ret)
@@ -423,6 +511,10 @@ static int ax_open(struct net_device *dev)
ax_phy_switch(dev, 0);
free_irq(dev->irq, dev);
failed_request_irq:
+ /* unregister mdiobus */
+ mdiobus_unregister(ax->mii_bus);
+ free_mdio_bitbang(ax->mii_bus);
+ failed_mii:
return ret;
}
@@ -442,6 +534,9 @@ static int ax_close(struct net_device *dev)
phy_disconnect(dev->phydev);
free_irq(dev->irq, dev);
+
+ mdiobus_unregister(ax->mii_bus);
+ free_mdio_bitbang(ax->mii_bus);
return 0;
}
@@ -541,92 +636,8 @@ static void ax_eeprom_register_write(struct eeprom_93cx6 *eeprom)
#endif
};
-static void ax_bb_mdc(struct mdiobb_ctrl *ctrl, int level)
-{
- struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
- if (level)
- ax->reg_memr |= AX_MEMR_MDC;
- else
- ax->reg_memr &= ~AX_MEMR_MDC;
-
- ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static void ax_bb_dir(struct mdiobb_ctrl *ctrl, int output)
-{
- struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
- if (output)
- ax->reg_memr &= ~AX_MEMR_MDIR;
- else
- ax->reg_memr |= AX_MEMR_MDIR;
-
- ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static void ax_bb_set_data(struct mdiobb_ctrl *ctrl, int value)
-{
- struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
-
- if (value)
- ax->reg_memr |= AX_MEMR_MDO;
- else
- ax->reg_memr &= ~AX_MEMR_MDO;
-
- ei_outb(ax->reg_memr, ax->addr_memr);
-}
-
-static int ax_bb_get_data(struct mdiobb_ctrl *ctrl)
-{
- struct ax_device *ax = container_of(ctrl, struct ax_device, bb_ctrl);
- int reg_memr = ei_inb(ax->addr_memr);
-
- return reg_memr & AX_MEMR_MDI ? 1 : 0;
-}
-
-static const struct mdiobb_ops bb_ops = {
- .owner = THIS_MODULE,
- .set_mdc = ax_bb_mdc,
- .set_mdio_dir = ax_bb_dir,
- .set_mdio_data = ax_bb_set_data,
- .get_mdio_data = ax_bb_get_data,
-};
-
/* setup code */
-static int ax_mii_init(struct net_device *dev)
-{
- struct platform_device *pdev = to_platform_device(dev->dev.parent);
- struct ei_device *ei_local = netdev_priv(dev);
- struct ax_device *ax = to_ax_dev(dev);
- int err;
-
- ax->bb_ctrl.ops = &bb_ops;
- ax->addr_memr = ei_local->mem + AX_MEMR;
- ax->mii_bus = alloc_mdio_bitbang(&ax->bb_ctrl);
- if (!ax->mii_bus) {
- err = -ENOMEM;
- goto out;
- }
-
- ax->mii_bus->name = "ax88796_mii_bus";
- ax->mii_bus->parent = dev->dev.parent;
- snprintf(ax->mii_bus->id, MII_BUS_ID_SIZE, "%s-%x",
- pdev->name, pdev->id);
-
- err = mdiobus_register(ax->mii_bus);
- if (err)
- goto out_free_mdio_bitbang;
-
- return 0;
-
- out_free_mdio_bitbang:
- free_mdio_bitbang(ax->mii_bus);
- out:
- return err;
-}
-
static void ax_initial_setup(struct net_device *dev, struct ei_device *ei_local)
{
void __iomem *ioaddr = ei_local->mem;
@@ -758,10 +769,6 @@ static int ax_init_dev(struct net_device *dev)
dev->netdev_ops = &ax_netdev_ops;
dev->ethtool_ops = &ax_ethtool_ops;
- ret = ax_mii_init(dev);
- if (ret)
- goto err_out;
-
ax_NS8390_init(dev, 0);
ret = register_netdev(dev);
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 5/9] net: ax88796: Add block_input/output hooks to ax_plat_data
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Add platform specific hooks for block transfer reads/writes of packet
buffer data, superseding the default provided ax_block_input/output.
Currently used for m68k Amiga XSurf100.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
Changes in v3:
Suggested by Andrew Lunn/Finn Thain:
- declare struct sk_buff in ax88796.h
- correct whitespace error
---
drivers/net/ethernet/8390/ax88796.c | 10 ++++++++--
include/net/ax88796.h | 9 +++++++++
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index ecf104c..29cde38 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -760,8 +760,14 @@ static int ax_init_dev(struct net_device *dev)
#endif
ei_local->reset_8390 = &ax_reset_8390;
- ei_local->block_input = &ax_block_input;
- ei_local->block_output = &ax_block_output;
+ if (ax->plat->block_input)
+ ei_local->block_input = ax->plat->block_input;
+ else
+ ei_local->block_input = &ax_block_input;
+ if (ax->plat->block_output)
+ ei_local->block_output = ax->plat->block_output;
+ else
+ ei_local->block_output = &ax_block_output;
ei_local->get_8390_hdr = &ax_get_8390_hdr;
ei_local->priv = 0;
ei_local->msg_enable = ax_msg_enable;
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index b9a3bec..363b0ca 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -12,6 +12,9 @@
#ifndef __NET_AX88796_PLAT_H
#define __NET_AX88796_PLAT_H
+struct sk_buff;
+struct net_device;
+
#define AXFLG_HAS_EEPROM (1<<0)
#define AXFLG_MAC_FROMDEV (1<<1) /* device already has MAC */
#define AXFLG_HAS_93CX6 (1<<2) /* use eeprom_93cx6 driver */
@@ -26,6 +29,12 @@ struct ax_plat_data {
u32 *reg_offsets; /* register offsets */
u8 *mac_addr; /* MAC addr (only used when
AXFLG_MAC_FROMPLATFORM is used */
+
+ /* uses default ax88796 buffer if set to NULL */
+ void (*block_output)(struct net_device *dev, int count,
+ const unsigned char *buf, int star_page);
+ void (*block_input)(struct net_device *dev, int count,
+ struct sk_buff *skb, int ring_offset);
};
#endif /* __NET_AX88796_PLAT_H */
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 7/9] net: ax88796: set IRQF_SHARED flag when IRQ resource is marked as shareable
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
On the Amiga X-Surf100, the network card interrupt is shared with many
other interrupt sources, so requires the IRQF_SHARED flag to register.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/ethernet/8390/ax88796.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index c799441..a72dfbc 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -875,6 +875,9 @@ static int ax_probe(struct platform_device *pdev)
dev->irq = irq->start;
ax->irqflags = irq->flags & IRQF_TRIGGER_MASK;
+ if (irq->flags & IORESOURCE_IRQ_SHAREABLE)
+ ax->irqflags |= IRQF_SHARED;
+
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!mem) {
dev_err(&pdev->dev, "no MEM specified\n");
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 6/9] net: ax88796: add interrupt status callback to platform data
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
To be able to tell the ax88796 driver whether it is sensible to enter
the 8390 interrupt handler, an "is this interrupt caused by the 88796"
callback has been added to the ax_plat_data structure (with NULL being
compatible to the previous behaviour).
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/ethernet/8390/ax88796.c | 23 +++++++++++++++++++++--
include/net/ax88796.h | 5 +++++
2 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index 29cde38..c799441 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -165,6 +165,21 @@ static void ax_reset_8390(struct net_device *dev)
ei_outb(ENISR_RESET, addr + EN0_ISR); /* Ack intr. */
}
+/* Wrapper for __ei_interrupt for platforms that have a platform-specific
+ * way to find out whether the interrupt request might be caused by
+ * the ax88796 chip.
+ */
+static irqreturn_t ax_ei_interrupt_filtered(int irq, void *dev_id)
+{
+ struct net_device *dev = dev_id;
+ struct ax_device *ax = to_ax_dev(dev);
+ struct platform_device *pdev = to_platform_device(dev->dev.parent);
+
+ if (!ax->plat->check_irq(pdev))
+ return IRQ_NONE;
+
+ return ax_ei_interrupt(irq, dev_id);
+}
static void ax_get_8390_hdr(struct net_device *dev, struct e8390_pkt_hdr *hdr,
int ring_page)
@@ -484,8 +499,12 @@ static int ax_open(struct net_device *dev)
if (ret)
goto failed_mii;
- ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
- dev->name, dev);
+ if (ax->plat->check_irq)
+ ret = request_irq(dev->irq, ax_ei_interrupt_filtered,
+ ax->irqflags, dev->name, dev);
+ else
+ ret = request_irq(dev->irq, ax_ei_interrupt, ax->irqflags,
+ dev->name, dev);
if (ret)
goto failed_request_irq;
diff --git a/include/net/ax88796.h b/include/net/ax88796.h
index 363b0ca..84b3785 100644
--- a/include/net/ax88796.h
+++ b/include/net/ax88796.h
@@ -14,6 +14,7 @@
struct sk_buff;
struct net_device;
+struct platform_device;
#define AXFLG_HAS_EEPROM (1<<0)
#define AXFLG_MAC_FROMDEV (1<<1) /* device already has MAC */
@@ -35,6 +36,10 @@ struct ax_plat_data {
const unsigned char *buf, int star_page);
void (*block_input)(struct net_device *dev, int count,
struct sk_buff *skb, int ring_offset);
+ /* returns nonzero if a pending interrupt request might by caused by
+ * the ax88786. Handles all interrupts if set to NULL
+ */
+ int (*check_irq)(struct platform_device *pdev);
};
#endif /* __NET_AX88796_PLAT_H */
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 8/9] net: ax88796: release platform device drvdata on probe error and module remove
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
The net device struct pointer is stored as platform device drvdata on
module probe - clear the drvdata entry on probe fail there, as well as
when unloading the module.
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
drivers/net/ethernet/8390/ax88796.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index a72dfbc..eb72282 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -829,6 +829,7 @@ static int ax_remove(struct platform_device *pdev)
release_mem_region(mem->start, resource_size(mem));
}
+ platform_set_drvdata(pdev, NULL);
free_netdev(dev);
return 0;
@@ -962,6 +963,7 @@ static int ax_probe(struct platform_device *pdev)
release_mem_region(mem->start, mem_size);
exit_mem:
+ platform_set_drvdata(pdev, NULL);
free_netdev(dev);
return ret;
--
1.7.0.4
^ permalink raw reply related
* [PATCH v3 9/9] net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)
From: Michael Schmitz @ 2018-04-18 4:26 UTC (permalink / raw)
To: netdev
Cc: andrew, fthain, geert, f.fainelli, linux-m68k, Michael.Karcher,
Michael Karcher, Michael Schmitz
In-Reply-To: <1523930895-6973-1-git-send-email-schmitzmic@gmail.com>
From: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Add platform device driver to populate the ax88796 platform data from
information provided by the XSurf100 zorro device driver. The ax88796
module will be loaded through this module's probe function.
Signed-off-by: Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>
Signed-off-by: Michael Schmitz <schmitzmic@gmail.com>
---
Changes in v3:
Suggested by Geert Uytterhoeven:
- use ei_local->reset_8390() instead of duplicating ax_reset_8390()
- use %pR to format struct resource pointers
- assign pdev and xs100 pointers in declaration
- don't split error messages
- change Kconfig logic to only require XSURF100 set on Amiga
Suggested by Andrew Lunn:
- add COMPILE_TEST to ax88796 Kconfig options
- use new Asix PHY driver for X-Surf 100
---
drivers/net/ethernet/8390/Kconfig | 17 ++-
drivers/net/ethernet/8390/Makefile | 1 +
drivers/net/ethernet/8390/xsurf100.c | 381 ++++++++++++++++++++++++++++++++++
3 files changed, 397 insertions(+), 2 deletions(-)
create mode 100644 drivers/net/ethernet/8390/xsurf100.c
diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index fdc6734..607dc00 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -29,8 +29,8 @@ config PCMCIA_AXNET
called axnet_cs. If unsure, say N.
config AX88796
- tristate "ASIX AX88796 NE2000 clone support"
- depends on (ARM || MIPS || SUPERH)
+ tristate "ASIX AX88796 NE2000 clone support" if !ZORRO
+ depends on (ARM || MIPS || SUPERH || ZORRO || COMPILE_TEST)
select CRC32
select PHYLIB
select MDIO_BITBANG
@@ -45,6 +45,19 @@ config AX88796_93CX6
---help---
Select this if your platform comes with an external 93CX6 eeprom.
+config XSURF100
+ tristate "Amiga XSurf 100 AX88796/NE2000 clone support"
+ depends on ZORRO
+ select AX88796
+ select ASIX_PHY
+ ---help---
+ This driver is for the Individual Computers X-Surf 100 Ethernet
+ card (based on the Asix AX88796 chip). If you have such a card,
+ say Y. Otherwise, say N.
+
+ To compile this driver as a module, choose M here: the module
+ will be called xsurf100.
+
config HYDRA
tristate "Hydra support"
depends on ZORRO
diff --git a/drivers/net/ethernet/8390/Makefile b/drivers/net/ethernet/8390/Makefile
index f975c2f..3715f8d 100644
--- a/drivers/net/ethernet/8390/Makefile
+++ b/drivers/net/ethernet/8390/Makefile
@@ -16,4 +16,5 @@ obj-$(CONFIG_PCMCIA_PCNET) += pcnet_cs.o 8390.o
obj-$(CONFIG_STNIC) += stnic.o 8390.o
obj-$(CONFIG_ULTRA) += smc-ultra.o 8390.o
obj-$(CONFIG_WD80x3) += wd.o 8390.o
+obj-$(CONFIG_XSURF100) += xsurf100.o
obj-$(CONFIG_ZORRO8390) += zorro8390.o 8390.o
diff --git a/drivers/net/ethernet/8390/xsurf100.c b/drivers/net/ethernet/8390/xsurf100.c
new file mode 100644
index 0000000..7ab5ca0
--- /dev/null
+++ b/drivers/net/ethernet/8390/xsurf100.c
@@ -0,0 +1,381 @@
+#include <linux/module.h>
+#include <linux/netdevice.h>
+#include <linux/platform_device.h>
+#include <linux/zorro.h>
+#include <net/ax88796.h>
+#include <asm/amigaints.h>
+
+#define ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100 \
+ ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x64, 0)
+
+#define XS100_IRQSTATUS_BASE 0x40
+#define XS100_8390_BASE 0x800
+
+/* Longword-access area. Translated to 2 16-bit access cycles by the
+ * X-Surf 100 FPGA
+ */
+#define XS100_8390_DATA32_BASE 0x8000
+#define XS100_8390_DATA32_SIZE 0x2000
+/* Sub-Areas for fast data register access; addresses relative to area begin */
+#define XS100_8390_DATA_READ32_BASE 0x0880
+#define XS100_8390_DATA_WRITE32_BASE 0x0C80
+#define XS100_8390_DATA_AREA_SIZE 0x80
+
+#define __NS8390_init ax_NS8390_init
+
+/* force unsigned long back to 'void __iomem *' */
+#define ax_convert_addr(_a) ((void __force __iomem *)(_a))
+
+#define ei_inb(_a) z_readb(ax_convert_addr(_a))
+#define ei_outb(_v, _a) z_writeb(_v, ax_convert_addr(_a))
+
+#define ei_inw(_a) z_readw(ax_convert_addr(_a))
+#define ei_outw(_v, _a) z_writew(_v, ax_convert_addr(_a))
+
+#define ei_inb_p(_a) ei_inb(_a)
+#define ei_outb_p(_v, _a) ei_outb(_v, _a)
+
+/* define EI_SHIFT() to take into account our register offsets */
+#define EI_SHIFT(x) (ei_local->reg_offset[(x)])
+
+/* Ensure we have our RCR base value */
+#define AX88796_PLATFORM
+
+static unsigned char version[] =
+ "ax88796.c: Copyright 2005,2007 Simtec Electronics\n";
+
+#include "lib8390.c"
+
+/* from ne.c */
+#define NE_CMD EI_SHIFT(0x00)
+#define NE_RESET EI_SHIFT(0x1f)
+#define NE_DATAPORT EI_SHIFT(0x10)
+
+struct xsurf100_ax_plat_data {
+ struct ax_plat_data ax;
+ void __iomem *base_regs;
+ void __iomem *data_area;
+};
+
+static int is_xsurf100_network_irq(struct platform_device *pdev)
+{
+ struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+
+ return (readw(xs100->base_regs + XS100_IRQSTATUS_BASE) & 0xaaaa) != 0;
+}
+
+/* These functions guarantee that the iomem is accessed with 32 bit
+ * cycles only. z_memcpy_fromio / z_memcpy_toio don't
+ */
+static void z_memcpy_fromio32(void *dst, const void __iomem *src, size_t bytes)
+{
+ while (bytes > 32) {
+ asm __volatile__
+ ("movem.l (%0)+,%%d0-%%d7\n"
+ "movem.l %%d0-%%d7,(%1)\n"
+ "adda.l #32,%1" : "=a"(src), "=a"(dst)
+ : "0"(src), "1"(dst) : "d0", "d1", "d2", "d3", "d4",
+ "d5", "d6", "d7", "memory");
+ bytes -= 32;
+ }
+ while (bytes) {
+ *(uint32_t *)dst = z_readl(src);
+ src += 4;
+ dst += 4;
+ bytes -= 4;
+ }
+}
+
+static void z_memcpy_toio32(void __iomem *dst, const void *src, size_t bytes)
+{
+ while (bytes) {
+ z_writel(*(const uint32_t *)src, dst);
+ src += 4;
+ dst += 4;
+ bytes -= 4;
+ }
+}
+
+static void xs100_write(struct net_device *dev, const void *src,
+ unsigned int count)
+{
+ struct ei_device *ei_local = netdev_priv(dev);
+ struct platform_device *pdev = to_platform_device(dev->dev.parent);
+ struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+
+ /* copy whole blocks */
+ while (count > XS100_8390_DATA_AREA_SIZE) {
+ z_memcpy_toio32(xs100->data_area +
+ XS100_8390_DATA_WRITE32_BASE, src,
+ XS100_8390_DATA_AREA_SIZE);
+ src += XS100_8390_DATA_AREA_SIZE;
+ count -= XS100_8390_DATA_AREA_SIZE;
+ }
+ /* copy whole dwords */
+ z_memcpy_toio32(xs100->data_area + XS100_8390_DATA_WRITE32_BASE,
+ src, count & ~3);
+ src += count & ~3;
+ if (count & 2) {
+ ei_outw(*(uint16_t *)src, ei_local->mem + NE_DATAPORT);
+ src += 2;
+ }
+ if (count & 1)
+ ei_outb(*(uint8_t *)src, ei_local->mem + NE_DATAPORT);
+}
+
+static void xs100_read(struct net_device *dev, void *dst, unsigned int count)
+{
+ struct ei_device *ei_local = netdev_priv(dev);
+ struct platform_device *pdev = to_platform_device(dev->dev.parent);
+ struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+
+ /* copy whole blocks */
+ while (count > XS100_8390_DATA_AREA_SIZE) {
+ z_memcpy_fromio32(dst, xs100->data_area +
+ XS100_8390_DATA_READ32_BASE,
+ XS100_8390_DATA_AREA_SIZE);
+ dst += XS100_8390_DATA_AREA_SIZE;
+ count -= XS100_8390_DATA_AREA_SIZE;
+ }
+ /* copy whole dwords */
+ z_memcpy_fromio32(dst, xs100->data_area + XS100_8390_DATA_READ32_BASE,
+ count & ~3);
+ dst += count & ~3;
+ if (count & 2) {
+ *(uint16_t *)dst = ei_inw(ei_local->mem + NE_DATAPORT);
+ dst += 2;
+ }
+ if (count & 1)
+ *(uint8_t *)dst = ei_inb(ei_local->mem + NE_DATAPORT);
+}
+
+/* Block input and output, similar to the Crynwr packet driver. If
+ * you are porting to a new ethercard, look at the packet driver
+ * source for hints. The NEx000 doesn't share the on-board packet
+ * memory -- you have to put the packet out through the "remote DMA"
+ * dataport using ei_outb.
+ */
+static void xs100_block_input(struct net_device *dev, int count,
+ struct sk_buff *skb, int ring_offset)
+{
+ struct ei_device *ei_local = netdev_priv(dev);
+ void __iomem *nic_base = ei_local->mem;
+ char *buf = skb->data;
+
+ if (ei_local->dmaing) {
+ netdev_err(dev,
+ "DMAing conflict in %s [DMAstat:%d][irqlock:%d]\n",
+ __func__,
+ ei_local->dmaing, ei_local->irqlock);
+ return;
+ }
+
+ ei_local->dmaing |= 0x01;
+
+ ei_outb(E8390_NODMA + E8390_PAGE0 + E8390_START, nic_base + NE_CMD);
+ ei_outb(count & 0xff, nic_base + EN0_RCNTLO);
+ ei_outb(count >> 8, nic_base + EN0_RCNTHI);
+ ei_outb(ring_offset & 0xff, nic_base + EN0_RSARLO);
+ ei_outb(ring_offset >> 8, nic_base + EN0_RSARHI);
+ ei_outb(E8390_RREAD + E8390_START, nic_base + NE_CMD);
+
+ xs100_read(dev, buf, count);
+
+ ei_local->dmaing &= ~1;
+}
+
+static void xs100_block_output(struct net_device *dev, int count,
+ const unsigned char *buf, const int start_page)
+{
+ struct ei_device *ei_local = netdev_priv(dev);
+ void __iomem *nic_base = ei_local->mem;
+ unsigned long dma_start;
+
+ /* Round the count up for word writes. Do we need to do this?
+ * What effect will an odd byte count have on the 8390? I
+ * should check someday.
+ */
+ if (ei_local->word16 && (count & 0x01))
+ count++;
+
+ /* This *shouldn't* happen. If it does, it's the last thing
+ * you'll see
+ */
+ if (ei_local->dmaing) {
+ netdev_err(dev,
+ "DMAing conflict in %s [DMAstat:%d][irqlock:%d]\n",
+ __func__,
+ ei_local->dmaing, ei_local->irqlock);
+ return;
+ }
+
+ ei_local->dmaing |= 0x01;
+ /* We should already be in page 0, but to be safe... */
+ ei_outb(E8390_PAGE0 + E8390_START + E8390_NODMA, nic_base + NE_CMD);
+
+ ei_outb(ENISR_RDC, nic_base + EN0_ISR);
+
+ /* Now the normal output. */
+ ei_outb(count & 0xff, nic_base + EN0_RCNTLO);
+ ei_outb(count >> 8, nic_base + EN0_RCNTHI);
+ ei_outb(0x00, nic_base + EN0_RSARLO);
+ ei_outb(start_page, nic_base + EN0_RSARHI);
+
+ ei_outb(E8390_RWRITE + E8390_START, nic_base + NE_CMD);
+
+ xs100_write(dev, buf, count);
+
+ dma_start = jiffies;
+
+ while ((ei_inb(nic_base + EN0_ISR) & ENISR_RDC) == 0) {
+ if (jiffies - dma_start > 2 * HZ / 100) { /* 20ms */
+ netdev_warn(dev, "timeout waiting for Tx RDC.\n");
+ ei_local->reset_8390(dev);
+ ax_NS8390_init(dev, 1);
+ break;
+ }
+ }
+
+ ei_outb(ENISR_RDC, nic_base + EN0_ISR); /* Ack intr. */
+ ei_local->dmaing &= ~0x01;
+}
+
+static int xsurf100_probe(struct zorro_dev *zdev,
+ const struct zorro_device_id *ent)
+{
+ struct platform_device *pdev;
+ struct xsurf100_ax_plat_data ax88796_data;
+ struct resource res[2] = {
+ DEFINE_RES_NAMED(IRQ_AMIGA_PORTS, 1, NULL,
+ IORESOURCE_IRQ | IORESOURCE_IRQ_SHAREABLE),
+ DEFINE_RES_MEM(zdev->resource.start + XS100_8390_BASE,
+ 4 * 0x20)
+ };
+ int reg;
+ /* This table is referenced in the device structure, so it must
+ * outlive the scope of xsurf100_probe.
+ */
+ static u32 reg_offsets[32];
+ int ret = 0;
+
+ /* X-Surf 100 control and 32 bit ring buffer data access areas.
+ * These resources are not used by the ax88796 driver, so must
+ * be requested here and passed via platform data.
+ */
+
+ if (!request_mem_region(zdev->resource.start, 0x100, zdev->name)) {
+ dev_err(&zdev->dev, "cannot reserve X-Surf 100 control registers\n");
+ return -ENXIO;
+ }
+
+ if (!request_mem_region(zdev->resource.start +
+ XS100_8390_DATA32_BASE,
+ XS100_8390_DATA32_SIZE,
+ "X-Surf 100 32-bit data access")) {
+ dev_err(&zdev->dev, "cannot reserve 32-bit area\n");
+ ret = -ENXIO;
+ goto exit_req;
+ }
+
+ for (reg = 0; reg < 0x20; reg++)
+ reg_offsets[reg] = 4 * reg;
+
+ memset(&ax88796_data, 0, sizeof(ax88796_data));
+ ax88796_data.ax.flags = AXFLG_HAS_EEPROM;
+ ax88796_data.ax.wordlength = 2;
+ ax88796_data.ax.dcr_val = 0x48;
+ ax88796_data.ax.rcr_val = 0x40;
+ ax88796_data.ax.reg_offsets = reg_offsets;
+ ax88796_data.ax.check_irq = is_xsurf100_network_irq;
+ ax88796_data.base_regs = ioremap(zdev->resource.start, 0x100);
+
+ /* error handling for ioremap regs */
+ if (!ax88796_data.base_regs) {
+ dev_err(&zdev->dev, "Cannot ioremap area %pR (registers)\n",
+ &zdev->resource);
+
+ ret = -ENXIO;
+ goto exit_req2;
+ }
+
+ ax88796_data.data_area = ioremap(zdev->resource.start +
+ XS100_8390_DATA32_BASE, XS100_8390_DATA32_SIZE);
+
+ /* error handling for ioremap data */
+ if (!ax88796_data.data_area) {
+ dev_err(&zdev->dev,
+ "Cannot ioremap area %pR offset %x (32-bit access)\n",
+ &zdev->resource, XS100_8390_DATA32_BASE);
+
+ ret = -ENXIO;
+ goto exit_mem;
+ }
+
+ ax88796_data.ax.block_output = xs100_block_output;
+ ax88796_data.ax.block_input = xs100_block_input;
+
+ pdev = platform_device_register_resndata(&zdev->dev, "ax88796",
+ zdev->slotaddr, res, 2,
+ &ax88796_data,
+ sizeof(ax88796_data));
+
+ if (IS_ERR(pdev)) {
+ dev_err(&zdev->dev, "cannot register platform device\n");
+ ret = -ENXIO;
+ goto exit_mem2;
+ }
+
+ zorro_set_drvdata(zdev, pdev);
+
+ if (!ret)
+ return 0;
+
+ exit_mem2:
+ iounmap(ax88796_data.data_area);
+
+ exit_mem:
+ iounmap(ax88796_data.base_regs);
+
+ exit_req2:
+ release_mem_region(zdev->resource.start + XS100_8390_DATA32_BASE,
+ XS100_8390_DATA32_SIZE);
+
+ exit_req:
+ release_mem_region(zdev->resource.start, 0x100);
+
+ return ret;
+}
+
+static void xsurf100_remove(struct zorro_dev *zdev)
+{
+ struct platform_device *pdev = zorro_get_drvdata(zdev);
+ struct xsurf100_ax_plat_data *xs100 = dev_get_platdata(&pdev->dev);
+
+ platform_device_unregister(pdev);
+
+ iounmap(xs100->base_regs);
+ release_mem_region(zdev->resource.start, 0x100);
+ iounmap(xs100->data_area);
+ release_mem_region(zdev->resource.start + XS100_8390_DATA32_BASE,
+ XS100_8390_DATA32_SIZE);
+}
+
+static const struct zorro_device_id xsurf100_zorro_tbl[] = {
+ { ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100, },
+ { 0 }
+};
+
+MODULE_DEVICE_TABLE(zorro, xsurf100_zorro_tbl);
+
+static struct zorro_driver xsurf100_driver = {
+ .name = "xsurf100",
+ .id_table = xsurf100_zorro_tbl,
+ .probe = xsurf100_probe,
+ .remove = xsurf100_remove,
+};
+
+module_driver(xsurf100_driver, zorro_register_driver, zorro_unregister_driver);
+
+MODULE_DESCRIPTION("X-Surf 100 driver");
+MODULE_AUTHOR("Michael Karcher <kernel@mkarcher.dialup.fu-berlin.de>");
+MODULE_LICENSE("GPL v2");
--
1.7.0.4
^ permalink raw reply related
* Re: [PATCH 10/10] net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)
From: Michael Schmitz @ 2018-04-18 4:32 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: netdev, Linux/m68k, Michael Karcher, Michael Karcher
In-Reply-To: <CAMuHMdUnonyL93AmF3TdPcUPj5ZEuTb59ZgArH5BjLjcx8LcvA@mail.gmail.com>
Hi Geert,
On Wed, Apr 18, 2018 at 1:53 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
>> --- /dev/null
>> +++ b/drivers/net/ethernet/8390/xsurf100.c
>> @@ -0,0 +1,411 @@
>> +#include <linux/module.h>
>> +#include <linux/netdevice.h>
>> +#include <linux/platform_device.h>
>> +#include <linux/zorro.h>
>> +#include <net/ax88796.h>
>> +#include <asm/amigaints.h>
>> +
>> +#define ZORRO_PROD_INDIVIDUAL_COMPUTERS_X_SURF100 \
>> + ZORRO_ID(INDIVIDUAL_COMPUTERS, 0x64, 0)
>
> Another long define to get rid of? ;-)
I decided to leave it that way - it doesn't stick out quite as badly
as the one in the ESP driver. Give me a yell if you insist.
Cheers,
Michael
^ permalink raw reply
* Re: [PATCH net-next] net: introduce a new tracepoint for tcp_rcv_space_adjust
From: Yafang Shao @ 2018-04-18 4:42 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: Eric Dumazet, David Miller, Song Liu, netdev, LKML
In-Reply-To: <20180417234455.q6fgn7oroehmxk6l@ast-mbp>
On Wed, Apr 18, 2018 at 7:44 AM, Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
> On Mon, Apr 16, 2018 at 08:43:31AM -0700, Eric Dumazet wrote:
>>
>>
>> On 04/16/2018 08:33 AM, Yafang Shao wrote:
>> > tcp_rcv_space_adjust is called every time data is copied to user space,
>> > introducing a tcp tracepoint for which could show us when the packet is
>> > copied to user.
>> > This could help us figure out whether there's latency in user process.
>> >
>> > When a tcp packet arrives, tcp_rcv_established() will be called and with
>> > the existed tracepoint tcp_probe we could get the time when this packet
>> > arrives.
>> > Then this packet will be copied to user, and tcp_rcv_space_adjust will
>> > be called and with this new introduced tracepoint we could get the time
>> > when this packet is copied to user.
>> >
>> > arrives time : user process time => latency caused by user
>> > tcp_probe tcp_rcv_space_adjust
>> >
>> > Hence in the prink message, sk is printed as a key to connect these two
>> > tracepoints.
>> >
>>
>> socket pointer is not a key.
>>
>> TCP sockets can be reused pretty fast after free.
>>
>> I suggest you go for cookie instead, this is an unique 64bit identifier.
>> ( sock_gen_cookie() for details )
>
> I think would be even better if the stack would do this sock_gen_cookie()
> on its own in some way that user cannnot infere the order.
> In many cases we wanted to use socket cookie, but since it's not inited
> by default it's kinda useless.
> Turning this tracepoint on just to get cookie would be an ugly workaround.
>
Could we init it in sk_alloc() ?
Then in other code paths, for example sock_getsockopt or tracepoints,
we only read the value through a new inline function named
sock_read_cookie().
Thanks
Yafang
^ permalink raw reply
* Re: [PATCH ipsec-next] selftests: add xfrm state-policy-monitor to rtnetlink.sh
From: Steffen Klassert @ 2018-04-18 4:43 UTC (permalink / raw)
To: Shannon Nelson; +Cc: netdev
In-Reply-To: <1523573999-17411-1-git-send-email-shannon.nelson@oracle.com>
On Thu, Apr 12, 2018 at 03:59:59PM -0700, Shannon Nelson wrote:
> Add a simple set of tests for the IPsec xfrm commands.
>
> Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
Applied to ipsec-next, thanks Shannon!
^ permalink raw reply
* [PATCH iproute2 net-next] vxlan: fix ttl inherit behavior
From: Hangbin Liu @ 2018-04-18 5:05 UTC (permalink / raw)
To: netdev; +Cc: Stephen Hemminger, Jiri Benc, Hangbin Liu
Like kernel net-next commit 72f6d71e491e6 ("vxlan: add ttl inherit support"),
vxlan ttl inherit should means inherit the inner protocol's ttl value.
But currently when we add vxlan with "ttl inherit", we only set ttl 0,
which is actually use whatever default value instead of inherit the inner
protocol's ttl value.
To make a difference with ttl inherit and ttl == 0, we add an attribute
IFLA_VXLAN_TTL_INHERIT when "ttl inherit" specified. And use "ttl auto"
to means "use whatever default value", the same behavior with ttl == 0.
Reported-by: Jianlin Shi <jishi@redhat.com>
Suggested-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
include/uapi/linux/if_link.h | 1 +
ip/iplink_vxlan.c | 8 ++++++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index dab5246..387f873 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -511,6 +511,7 @@ enum {
IFLA_VXLAN_COLLECT_METADATA,
IFLA_VXLAN_LABEL,
IFLA_VXLAN_GPE,
+ IFLA_VXLAN_TTL_INHERIT,
__IFLA_VXLAN_MAX
};
#define IFLA_VXLAN_MAX (__IFLA_VXLAN_MAX - 1)
diff --git a/ip/iplink_vxlan.c b/ip/iplink_vxlan.c
index 661eaa7..5804db3 100644
--- a/ip/iplink_vxlan.c
+++ b/ip/iplink_vxlan.c
@@ -165,14 +165,18 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
NEXT_ARG();
check_duparg(&attrs, IFLA_VXLAN_TTL, "ttl", *argv);
- if (strcmp(*argv, "inherit") != 0) {
+ if (strcmp(*argv, "inherit") == 0) {
+ addattr_l(n, 1024, IFLA_VXLAN_TTL_INHERIT, NULL, 0);
+ } else if (strcmp(*argv, "auto") == 0) {
+ addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
+ } else {
if (get_unsigned(&uval, *argv, 0))
invarg("invalid TTL", *argv);
if (uval > 255)
invarg("TTL must be <= 255", *argv);
ttl = uval;
+ addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
}
- addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
} else if (!matches(*argv, "tos") ||
!matches(*argv, "dsfield")) {
__u32 uval;
--
2.5.5
^ permalink raw reply related
* Re: [Regression] net/phy/micrel.c v4.9.94
From: Chris Ruehl @ 2018-04-18 5:09 UTC (permalink / raw)
To: f.fainelli, netdev
In-Reply-To: <3bd29bdd-b5ab-03d5-ea53-292f9150ee4c@gtsys.com.hk>
On Wednesday, April 18, 2018 09:34 AM, Chris Ruehl wrote:
> Hello,
>
> I like to get your heads up at a regression introduced in 4.9.94
> commitment lead to a kernel ops and make the network unusable on my MX6DL
> customized board.
>
> Race condition resume is called on startup and the phy not yet initialized.
>
> [ 7.313366] Unable to handle kernel NULL pointer dereference at virtual
> address 00000008
> [ 7.321602] pgd = ecfc0000
>
> [ 7.324950] [00000008] *pgd=8e901831
>
> [ 7.328652] Internal error: Oops: 17 [#1] PREEMPT SMP ARM
>
> [ 7.334061] Modules linked in:
>
> [ 7.337146] CPU: 0 PID: 269 Comm: ip Not tainted 4.9.94 #11
>
> [ 7.342725] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree)
>
> [ 7.349259] task: ece59900 task.stack: ec9ea000
>
> [ 7.353809] PC is at kszphy_config_reset+0x14/0x148
>
> [ 7.358703] LR is at kszphy_resume+0x1c/0x6c
>
> [ 7.362983] pc : [<c056a24c>] lr : [<c056a4fc>] psr: 60030013
>
> [ 7.362983] sp : ec9eb918 ip : ec9eb938 fp : ec9eb934
>
> [ 7.374467] r10: 00000007 r9 : 00000000 r8 : ee693c00
>
> [ 7.379700] r7 : 00000000 r6 : 00000000 r5 : 00000000 r4 : ee6fc000
>
> [ 7.386234] r3 : 00000001 r2 : 00000000 r1 : 00000110 r0 : ee6fc000
>
> [ 7.392768] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment none
>
> [ 7.399911] Control: 10c5387d Table: 3cfc004a DAC: 00000051
>
> [ 7.405663] Process ip (pid: 269, stack limit = 0xec9ea210)
>
> [ 7.411244] Stack: (0xec9eb918 to 0xec9ec000)
>
> [ 7.415611] b900: ee6fc000 00000000
> [ 7.423800] b920: ee031000 00000000 ec9eb94c ec9eb938 c056a4fc c056a244
> ee6fc000 00000000
> [ 7.431988] b940: ec9eb97c ec9eb950 c05681e4 c056a4ec 00000007 ee6fc000
> ee6fc000 c056ce7c
> [ 7.440174] b960: c056ce7c ee031000 ee55c818 00000000 ec9eb99c ec9eb980
> c05683cc c0568134
> [ 7.448364] b980: 00000007 ec9eba10 ee6fc000 00000007 ec9eb9c4 ec9eb9a0
> c0568450 c05683bc
> [ 7.456550] b9a0: 00000007 00000005 ee031000 ec9eb9d3 00000200 c1508da4
> ec9eba6c ec9eb9c8
> [ 7.464736] b9c0: c056ce24 c0568410 00000005 ee03162c 32000001 30383831
> 652e3030 72656874
> [ 7.472921] b9e0: 2d74656e 00000031 000003e8 000000c8 c01732ec c0172adc
> 000003e8 000000c8
> [ 7.481109] ba00: 024000c0 ee55c000 c150e454 024000c0 38383132 2e303030
> 65687465 74656e72
> [ 7.489296] ba20: 303a312d ee000035 ec9eba6c ec9eba38 c0224b50 c0175eb8
> ec9eba6c c056eb44
> [ 7.497482] ba40: c056bbe0 f0c16000 ee031000 ee55c000 00000200 f0c16000
> ee031000 ee55c000
> [ 7.505667] ba60: ec9ebaa4 ec9eba70 c056eba4 c056cd1c 00000001 ee03162c
> ec9ebaa4 ee031000
> [ 7.513855] ba80: 00000000 c09566ec ee031030 00000000 ec9ccd10 ecb39900
> ec9ebacc ec9ebaa8
> [ 7.522043] baa0: c06ad6e0 c056e92c ec9ebacc ee031000 ee031000 00000001
> 00001003 00001002
> [ 7.530229] bac0: ec9ebaf4 ec9ebad0 c06ad99c c06ad63c 00001002 ee031000
> ee031148 00001002
> [ 7.538414] bae0: 00000000 00000000 ec9ebb1c ec9ebaf8 c06ada6c c06ad90c
> 00001002 00000000
> [ 7.546601] bb00: ee031000 ec9ebc28 00000000 c09566ec ec9ebb94 ec9ebb20
> c06c1034 c06ada58
> [ 7.554787] bb20: c0c50df8 2e184000 ec9ebb44 ec9ebb38 c0173528 c0173320
> ec9ebbd4 c0e82b6c
> [ 7.562972] bb40: 00000000 ece59dc8 ebb4e9d0 c9eae3f3 ece59900 00000003
> ece59900 0000005e
> [ 7.571157] bb60: c14e30ec c0d1e51c ece59900 00000000 ee031000 ec9ccd00
> 00000000 00000000
> [ 7.579346] bb80: ec9ebb98 00000000 ec9ebd04 ec9ebb98 c06c30cc c06c0d68
> ec9ebbc4 00000000
> [ 7.587531] bba0: c01758bc ecb39900 c09eb3a0 ec9ccd20 00000000 ec9ccd10
> 00000001 ece59900
> [ 7.595715] bbc0: c01e0e64 00000000 00000000 00000001 ec9ebbfc 00000000
> 00000000 00000000
> [ 7.603900] bbe0: 00000000 00000000 00000000 ffffff00 ec9ebc0c ec9ebc00
> c0173528 c0173320
> [ 7.612084] bc00: ec9ebc9c ec9ebc10 c01e0e64 c0173520 00000000 0000000e
> ece59900 00000096
> [ 7.620269] bc20: c14e30ec c0d1e51c 00000000 00000000 00000000 00000000
> 00000000 00000000
> [ 7.628452] bc40: 00000000 00000000 00000000 00000000 00000000 00000000
> 00000000 00000000
> [ 7.636636] bc60: 00000000 00000000 00000000 00000000 00000000 00000000
> 00000000 00000000
> [ 7.644819] bc80: 00000000 00000000 00000000 00000000 00000000 00000000
> 00000000 00000000
> [ 7.653003] bca0: 00000000 00000000 00000000 00000000 00000000 00000000
> 00000000 00000000
> [ 7.661186] bcc0: 00000000 00000000 00000000 00000000 00000000 00000000
> c06d3870 00000000
> [ 7.669372] bce0: ec9ccd00 ecb39900 c15226e4 00000000 00000000 ecb39900
> ec9ebd44 ec9ebd08
> [ 7.677556] bd00: c06c343c c06c2bdc c0869c2c c0173520 00000001 00000000
> c06c06e4 00000000
> [ 7.685741] bd20: 00000000 ec9ccd00 c06c32b8 ecb39900 ecb39900 00000000
> ec9ebd64 ec9ebd48
> [ 7.693926] bd40: c06d86cc c06c32c4 00000000 ecb39900 00000020 ec970400
> ec9ebd7c ec9ebd68
> [ 7.702110] bd60: c06c06f4 c06d8630 c06c06c4 ee15f400 ec9ebdac ec9ebd80
> c06d802c c06c06d0
> [ 7.710294] bd80: ec9ebf50 7fffffff ec970400 ec9ebf48 ec970400 00000000
> 00000020 00000000
> [ 7.718477] bda0: ec9ebe0c ec9ebdb0 c06d84e8 c06d7ec8 0000000c ec9ebe48
> 0000000c 00000000
> [ 7.726661] bdc0: beee97bc 00000008 00000000 ee0cbd80 00000000 0000010d
> 00000000 00000000
> [ 7.734845] bde0: ec9ebe24 ec9ebf48 00000000 eda478c0 00000128 00000000
> 00000000 ec9ebe28
> [ 7.743029] be00: ec9ebe1c ec9ebe10 c068b124 c06d8180 ec9ebf34 ec9ebe20
> c068bcac c068b114
> [ 7.751213] be20: ec9ebe8c 00000000 c01759cc c01704b0 ec9ebea4 ec9ebe40
> c0209960 c01187ac
> [ 7.759396] be40: 00000000 00000000 beeed828 00000020 00000000 00000000
> 600f0113 ec98ce70
> [ 7.767580] be60: beee9000 ed7ac714 ece59900 ed7ac6c0 00000817 beee977c
> ed7ac714 00000055
> [ 7.775764] be80: ec9ebea4 ec9ebe90 00000010 00000000 00000000 ec9ebfb0
> ec9ebefc ec9ebea8
> [ 7.783948] bea0: c0115b74 c016ec18 00000000 c0d55a61 c025e178 ffffffea
> ee022f10 00000000
> [ 7.792131] bec0: 00000000 00000000 00000800 00000000 c025ddc0 c0d0a44c
> 00000817 c0115990
> [ 7.800315] bee0: beee977c ec9ebfb0 00054694 beeedec0 ec9ebfac ec9ebf00
> c0101368 c011599c
> [ 7.808500] bf00: ec9ebf1c ec9ebf10 c025a578 eda478c0 00000000 beee97a4
> 00000128 c0107ee4
> [ 7.816685] bf20: ec9ea000 00000000 ec9ebf94 ec9ebf38 c068ca54 c068bad4
> 00000000 00000000
> [ 7.824868] bf40: 00000000 fffffff7 ec9ebe88 0000000c 00000001 00000000
> 00000000 ec9ebe50
> [ 7.833052] bf60: 00000000 00000001 00000000 00000000 00000000 00000000
> ec9ebf94 0000000c
> [ 7.841235] bf80: 00000010 beee9790 ec9ebfa4 ec9ebf98 c068ca94 c068ca18
> 00000000 ec9ebfa8
> [ 7.849419] bfa0: c0107d20 c068ca90 0000000c 00000010 00000003 beee97a4
> 00000000 00000005
> [ 7.857604] bfc0: 0000000c 00000010 beee9790 00000128 00000000 00054694
> beee97a4 beee97c0
> [ 7.865789] bfe0: 00000000 beee9774 00034d1d b6eaaf16 400f0030 00000003
> 3fffd861 3fffdc61
> [ 7.873968] Backtrace:
>
> [ 7.876450] [<c056a238>] (kszphy_config_reset) from [<c056a4fc>]
> (kszphy_resume+0x1c/0x6c)
> [ 7.884723] r7:00000000 r6:ee031000 r5:00000000 r4:ee6fc000
>
> [ 7.890392] [<c056a4e0>] (kszphy_resume) from [<c05681e4>]
> (phy_attach_direct+0xbc/0x1bc)
> [ 7.898575] r5:00000000 r4:ee6fc000
>
> [ 7.902158] [<c0568128>] (phy_attach_direct) from [<c05683cc>]
> (phy_connect_direct+0x1c/0x54)
> [ 7.910691] r10:00000000 r9:ee55c818 r8:ee031000 r7:c056ce7c r6:c056ce7c
> r5:ee6fc000
> [ 7.918525] r4:ee6fc000 r3:00000007
>
> [ 7.922108] [<c05683b0>] (phy_connect_direct) from [<c0568450>]
> (phy_connect+0x4c/0x80)
> [ 7.930117] r6:00000007 r5:ee6fc000 r4:ec9eba10 r3:00000007
>
> [ 7.935785] [<c0568404>] (phy_connect) from [<c056ce24>]
> (fec_enet_mii_probe+0x114/0x16c)
> [ 7.943969] r8:c1508da4 r7:00000200 r6:ec9eb9d3 r5:ee031000 r4:00000005
> r3:00000007
> [ 7.951720] [<c056cd10>] (fec_enet_mii_probe) from [<c056eba4>]
> (fec_enet_open+0x284/0x320)
> [ 7.960076] r6:ee55c000 r5:ee031000 r4:f0c16000
>
> [ 7.964704] [<c056e920>] (fec_enet_open) from [<c06ad6e0>]
> (__dev_open+0xb0/0x114)
> [ 7.972281] r10:ecb39900 r9:ec9ccd10 r8:00000000 r7:ee031030 r6:c09566ec
> r5:00000000
> [ 7.980113] r4:ee031000
>
> [ 7.982655] [<c06ad630>] (__dev_open) from [<c06ad99c>]
> (__dev_change_flags+0x9c/0x14c)
> [ 7.990665] r7:00001002 r6:00001003 r5:00000001 r4:ee031000
>
> [ 7.996333] [<c06ad900>] (__dev_change_flags) from [<c06ada6c>]
> (dev_change_flags+0x20/0x50)
> [ 8.004777] r8:00000000 r7:00000000 r6:00001002 r5:ee031148 r4:ee031000
> r3:00001002
> [ 8.012533] [<c06ada4c>] (dev_change_flags) from [<c06c1034>]
> (do_setlink+0x2d8/0x838)
> [ 8.020456] r8:c09566ec r7:00000000 r6:ec9ebc28 r5:ee031000 r4:00000000
> r3:00001002
> [ 8.028207] [<c06c0d5c>] (do_setlink) from [<c06c30cc>]
> (rtnl_newlink+0x4fc/0x6e8)
> [ 8.035784] r10:00000000 r9:ec9ebb98 r8:00000000 r7:00000000 r6:ec9ccd00
> r5:ee031000
> [ 8.043616] r4:00000000
>
> [ 8.046159] [<c06c2bd0>] (rtnl_newlink) from [<c06c343c>]
> (rtnetlink_rcv_msg+0x184/0x234)
> [ 8.054343] r10:ecb39900 r9:00000000 r8:00000000 r7:c15226e4 r6:ecb39900
> r5:ec9ccd00
> [ 8.062175] r4:00000000
>
> [ 8.064720] [<c06c32b8>] (rtnetlink_rcv_msg) from [<c06d86cc>]
> (netlink_rcv_skb+0xa8/0xc4)
> [ 8.072990] r8:00000000 r7:ecb39900 r6:ecb39900 r5:c06c32b8 r4:ec9ccd00
> [ 8.079701] [<c06d8624>] (netlink_rcv_skb) from [<c06c06f4>]
> (rtnetlink_rcv+0x30/0x38)
> [ 8.087622] r6:ec970400 r5:00000020 r4:ecb39900 r3:00000000
> [ 8.093291] [<c06c06c4>] (rtnetlink_rcv) from [<c06d802c>]
> (netlink_unicast+0x170/0x1f8)
> [ 8.101384] r4:ee15f400 r3:c06c06c4
> [ 8.104968] [<c06d7ebc>] (netlink_unicast) from [<c06d84e8>]
> (netlink_sendmsg+0x374/0x388)
> [ 8.113238] r8:00000000 r7:00000020 r6:00000000 r5:ec970400 r4:ec9ebf48
> [ 8.119952] [<c06d8174>] (netlink_sendmsg) from [<c068b124>]
> (sock_sendmsg+0x1c/0x2c)
> [ 8.127789] r10:ec9ebe28 r9:00000000 r8:00000000 r7:00000128 r6:eda478c0
> r5:00000000
> [ 8.135621] r4:ec9ebf48
> [ 8.138167] [<c068b108>] (sock_sendmsg) from [<c068bcac>]
> (___sys_sendmsg+0x1e4/0x20c)
> [ 8.146095] [<c068bac8>] (___sys_sendmsg) from [<c068ca54>]
> (__sys_sendmsg+0x48/0x78)
> [ 8.153932] r10:00000000 r9:ec9ea000 r8:c0107ee4 r7:00000128 r6:beee97a4
> r5:00000000
> [ 8.161764] r4:eda478c0
> [ 8.164304] [<c068ca0c>] (__sys_sendmsg) from [<c068ca94>]
> (SyS_sendmsg+0x10/0x14)
> [ 8.171880] r6:beee9790 r5:00000010 r4:0000000c
> [ 8.176510] [<c068ca84>] (SyS_sendmsg) from [<c0107d20>]
> (ret_fast_syscall+0x0/0x1c)
> [ 8.184261] Code: e92dd8f0 e24cb004 e590628c e1a04000 (e5d63008)
> [ 8.192713] ---[ end trace 07c02ee14784bc48 ]---
>
> Kind regards
> Chris
>
>
If I look at the patch I think it should call kszphy_config_init() not _reset()
in the resume function:
@@ -715,8 +723,14 @@ static int kszphy_suspend(struct phy_device *phydev)
static int kszphy_resume(struct phy_device *phydev)
{
+ int ret;
+
genphy_resume(phydev);
- ret = kszphy_config_reset(phydev);
+ ret = kszphy_config_init(phydev);
+ if (ret)
+ return ret;
+
^ permalink raw reply
* Re: [PATCH v3 00/10] New network driver for Amiga X-Surf 100 (m68k)
From: Michael Schmitz @ 2018-04-18 5:10 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, Finn Thain, Geert Uytterhoeven, Florian Fainelli,
Linux/m68k, Michael Karcher
In-Reply-To: <1524025616-3722-1-git-send-email-schmitzmic@gmail.com>
All,
just noticed belatedly that the Makefile hunk of patch 9 does no
longer apply cleanly in 4.17-rc1, sorry. My series was based on 4.16.
I'll resend that one, OK?
Cheers,
Michael
On Wed, Apr 18, 2018 at 4:26 PM, Michael Schmitz <schmitzmic@gmail.com> wrote:
> This patch series adds support for the Individual Computers X-Surf 100
> network card for m68k Amiga, a network adapter based on the AX88796 chip set.
>
> The driver was originally written for kernel version 3.19 by Michael Karcher
> (see CC:), and adapted to 4.16 for submission to netdev by me. Questions
> regarding motivation for some of the changes are probably best directed at
> Michael Karcher.
>
> The driver has been tested by Adrian <glaubitz@physik.fu-berlin.de> who will
> send his Tested-by tag separately.
>
> A few changes to the ax88796 driver were required:
> - to read the MAC address, some setup of the ax99796 chip must be done,
> - attach to the MII bus only on device open to allow module unloading,
> - allow to supersede ax_block_input/ax_block_output by card-specific
> optimized code,
> - use an optional interrupt status callback to allow easier sharing of the
> card interrupt,
> - set IRQF_SHARED if platform IRQ resource is marked shareable,
>
> The Asix Electronix PHY used on the X-Surf 100 is buggy, and causes the
> software reset to hang if the previous command sent to the PHY was also
> a soft reset. This bug requires addition of a PHY driver for Asix PHYs
> to provide a fixed .soft_reset function, included in this series.
>
> Some additional cleanup:
> - do not attempt to free IRQ in ax_remove (complements 82533ad9a1c),
> - clear platform drvdata on probe fail and module remove.
>
> Changes since v1:
>
> Raised in review by Andrew Lunn:
> - move MII code around to avoid need for forward declaration
> - combine patches 2 and 7 to add cleanup in error path
>
> Changes since v2:
>
> - corrected authorship attribution to Michael Karcher
>
> Suggested by Geert Uytterhoeven:
> - use ei_local->reset_8390() instead of duplicating ax_reset_8390()
> - use %pR to format struct resource pointers
> - assign pdev and xs100 pointers in declaration
> - don't split error messages
> - change Kconfig logic to only require XSURF100 set on Amiga
>
> Suggested by Andrew Lunn:
> - add COMPILE_TEST to ax88796 Kconfig options
> - use new Asix PHY driver for X-Surf 100
>
> Suggested by Andrew Lunn/Finn Thain:
> - declare struct sk_buff in ax88796.h
> - correct whitespace error in ax88796.h
>
> This series' patches, in order:
>
> 1/9 net: phy: new Asix Electronics PHY driver
> 2/9 net: ax88796: Fix MAC address reading
> 3/9 net: ax88796: Attach MII bus only when open
> 4/9 net: ax88796: Do not free IRQ in ax_remove() (already freed in ax_close()).
> 5/9 net: ax88796: Add block_input/output hooks to ax_plat_data
> 6/9 net: ax88796: add interrupt status callback to platform data
> 7/9 net: ax88796: set IRQF_SHARED flag when IRQ resource is marked as shareable
> 8/9 net: ax88796: release platform device drvdata on probe error and module remove
> 9/9 net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)
>
> drivers/net/ethernet/8390/Kconfig | 17 ++-
> drivers/net/ethernet/8390/Makefile | 1 +
> drivers/net/ethernet/8390/ax88796.c | 228 ++++++++++++--------
> drivers/net/ethernet/8390/xsurf100.c | 381 ++++++++++++++++++++++++++++++++++
> drivers/net/phy/Kconfig | 6 +
> drivers/net/phy/Makefile | 1 +
> drivers/net/phy/asix.c | 65 ++++++
> drivers/net/phy/phy_device.c | 3 +-
> include/linux/phy.h | 1 +
> include/net/ax88796.h | 14 ++
> 10 files changed, 621 insertions(+), 96 deletions(-)
>
> Cheers,
>
> Michael
^ permalink raw reply
* Re: [PATCH iproute2 net-next] vxlan: fix ttl inherit behavior
From: Hangbin Liu @ 2018-04-18 5:10 UTC (permalink / raw)
To: network dev; +Cc: Stephen Hemminger, Jiri Benc, Hangbin Liu
In-Reply-To: <1524027948-5395-1-git-send-email-liuhangbin@gmail.com>
Hi Stephen,
The patch's subject contains fix. But the kernel feature is applied on net-next.
So I'm not sure if iproute2 net-next is suitable. If you are OK with the patch,
please feel free to apply it on the branch which you think is suitable.
Thanks
Hangbin
On 18 April 2018 at 13:05, Hangbin Liu <liuhangbin@gmail.com> wrote:
> Like kernel net-next commit 72f6d71e491e6 ("vxlan: add ttl inherit support"),
> vxlan ttl inherit should means inherit the inner protocol's ttl value.
>
> But currently when we add vxlan with "ttl inherit", we only set ttl 0,
> which is actually use whatever default value instead of inherit the inner
> protocol's ttl value.
>
> To make a difference with ttl inherit and ttl == 0, we add an attribute
> IFLA_VXLAN_TTL_INHERIT when "ttl inherit" specified. And use "ttl auto"
> to means "use whatever default value", the same behavior with ttl == 0.
>
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Suggested-by: Jiri Benc <jbenc@redhat.com>
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
^ permalink raw reply
* Re: [PATCH v3 00/10] New network driver for Amiga X-Surf 100 (m68k)
From: Finn Thain @ 2018-04-18 5:45 UTC (permalink / raw)
To: Michael Schmitz
Cc: netdev, Andrew Lunn, Geert Uytterhoeven, Florian Fainelli,
Linux/m68k, Michael Karcher
In-Reply-To: <CAOmrzk+zUTmSzXWU9WoXYauBx2Z4qkAh+Y4d49faA8Tu5RRQnQ@mail.gmail.com>
On Wed, 18 Apr 2018, Michael Schmitz wrote:
> All,
>
> just noticed belatedly that the Makefile hunk of patch 9 does no
> longer apply cleanly in 4.17-rc1, sorry. My series was based on 4.16.
> I'll resend that one, OK?
>
I might end up simpler to resend the whole series --
> Cheers,
>
> Michael
>
>
> > 1/9 net: phy: new Asix Electronics PHY driver
> > 2/9 net: ax88796: Fix MAC address reading
> > 3/9 net: ax88796: Attach MII bus only when open
> > 4/9 net: ax88796: Do not free IRQ in ax_remove() (already freed in ax_close()).
> > 5/9 net: ax88796: Add block_input/output hooks to ax_plat_data
I found that git am rejects this one, though 'patch' applies it with fuzz.
> > 6/9 net: ax88796: add interrupt status callback to platform data
> > 7/9 net: ax88796: set IRQF_SHARED flag when IRQ resource is marked as shareable
> > 8/9 net: ax88796: release platform device drvdata on probe error and module remove
> > 9/9 net: New ax88796 platform driver for Amiga X-Surf 100 Zorro board (m68k)
git am rejected this one and also complained about trailing whitespace.
I'd rebase on v4.17-rc1 and also run checkpatch over the results.
--
> >
> > drivers/net/ethernet/8390/Kconfig | 17 ++-
> > drivers/net/ethernet/8390/Makefile | 1 +
> > drivers/net/ethernet/8390/ax88796.c | 228 ++++++++++++--------
> > drivers/net/ethernet/8390/xsurf100.c | 381 ++++++++++++++++++++++++++++++++++
> > drivers/net/phy/Kconfig | 6 +
> > drivers/net/phy/Makefile | 1 +
> > drivers/net/phy/asix.c | 65 ++++++
> > drivers/net/phy/phy_device.c | 3 +-
> > include/linux/phy.h | 1 +
> > include/net/ax88796.h | 14 ++
> > 10 files changed, 621 insertions(+), 96 deletions(-)
> >
> > Cheers,
> >
> > Michael
^ permalink raw reply
* Re: [PATCH 1/1] net/mlx4_core: avoid resetting HCA when accessing an offline device
From: Yanjun Zhu @ 2018-04-18 5:46 UTC (permalink / raw)
To: Tariq Toukan, netdev, linux-rdma, haakon.bugge
In-Reply-To: <6dd17e45-e27e-8451-42ab-1a4551d3a651@mellanox.com>
On 2018/4/17 23:37, Tariq Toukan wrote:
>
>
> On 16/04/2018 4:02 AM, Zhu Yanjun wrote:
>> While a faulty cable is used or HCA firmware error, HCA device will
>> be offline. When the driver is accessing this offline device, the
>> following call trace will pop out.
>>
>> "
>> ...
>> [<ffffffff816e4842>] dump_stack+0x63/0x81
>> [<ffffffff816e459e>] panic+0xcc/0x21b
>> [<ffffffffa03e5f8a>] mlx4_enter_error_state+0xba/0xf0 [mlx4_core]
>> [<ffffffffa03e7298>] mlx4_cmd_reset_flow+0x38/0x60 [mlx4_core]
>> [<ffffffffa03e7381>] mlx4_cmd_poll+0xc1/0x2e0 [mlx4_core]
>> [<ffffffffa03e9f00>] __mlx4_cmd+0xb0/0x160 [mlx4_core]
>> [<ffffffffa0406934>] mlx4_SENSE_PORT+0x54/0xd0 [mlx4_core]
>> [<ffffffffa03f5f54>] mlx4_dev_cap+0x4a4/0xb50 [mlx4_core]
>> ...
>> "
>> In the above call trace, the function mlx4_cmd_poll calls the function
>> mlx4_cmd_post to access the HCA while HCA is offline. Then mlx4_cmd_post
>> returns an error -EIO. Per -EIO, the function mlx4_cmd_poll calls
>> mlx4_cmd_reset_flow to reset HCA. And the above call trace pops out.
>>
>> This is not reasonable. Since HCA device is offline when it is being
>> accessed, it should not be reset again.
>>
>> In this patch, since HCA is offline, the function mlx4_cmd_post returns
>> an error -EINVAL. Per -EINVAL, the function mlx4_cmd_poll directly
>> returns
>> instead of resetting HCA.
>>
>> CC: Srinivas Eeda <srinivas.eeda@oracle.com>
>> CC: Junxiao Bi <junxiao.bi@oracle.com>
>> Suggested-by: Håkon Bugge <haakon.bugge@oracle.com>
>> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
>> ---
>> drivers/net/ethernet/mellanox/mlx4/cmd.c | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>>
>> diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c
>> b/drivers/net/ethernet/mellanox/mlx4/cmd.c
>> index 6a9086d..f1c8c42 100644
>> --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
>> +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
>> @@ -451,6 +451,8 @@ static int mlx4_cmd_post(struct mlx4_dev *dev,
>> u64 in_param, u64 out_param,
>> * Device is going through error recovery
>> * and cannot accept commands.
>> */
>> + mlx4_err(dev, "%s : Device is in error recovery.\n", __func__);
>> + ret = -EINVAL;
>> goto out;
>> }
>> @@ -657,6 +659,9 @@ static int mlx4_cmd_poll(struct mlx4_dev *dev,
>> u64 in_param, u64 *out_param,
>> }
>> out_reset:
>> + if (err == -EINVAL)
>> + goto out;
>> +
>
> See below.
>
>> if (err)
>> err = mlx4_cmd_reset_flow(dev, op, op_modifier, err);
>> out:
>> @@ -766,6 +771,9 @@ static int mlx4_cmd_wait(struct mlx4_dev *dev,
>> u64 in_param, u64 *out_param,
>> *out_param = context->out_param;
>> out_reset:
>> + if (err == -EINVAL)
>> + goto out;
>> +
>> if (err)
>
> Instead, just do here: if (err && err != -EINVAL)
>
>> err = mlx4_cmd_reset_flow(dev, op, op_modifier, err);
>> out:
>>
>
> I am not sure this does not mistakenly cover other cases that already
> exist and have (err == -EINVAL).
>
> For example, this line is hard to predict:
> err = mlx4_status_to_errno
> and later on, we might get into
> if (mlx4_closing_cmd_fatal_error(op, stat))
> which leads to out_reset.
Thanks a lot.
Sure. I agree with you that "err = mlx4_status_to_errno" and "if
(mlx4_closing_cmd_fatal_error(op, stat))" will also make "err=-EINVAL".
This will mistakenly go to out instead of resetting HCA device.
I will make a new patch to avoid the above error.
Zhu Yanjun
>
> We must have a deeper look at this.
> But a better option is, change the error indication to uniquely
> indicate "already in error recovery".
>
^ permalink raw reply
* [PATCH bpf-next v2 00/11] introduction of bpf_xdp_adjust_tail
From: Nikita V. Shirokov @ 2018-04-18 4:29 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev, Nikita V. Shirokov
In this patch series i'm add new bpf helper which allow to manupulate
xdp's data_end pointer. right now only "shrinking" (reduce packet's size
by moving pointer) is supported (and i see no use case for "growing").
Main use case for such helper is to be able to generate controll (ICMP)
messages from XDP context. such messages usually contains first N bytes
from original packets as a payload, and this is exactly what this helper
would allow us to do (see patch 3 for sample program, where we generate
ICMP "packet too big" message). This helper could be usefull for load
balancing applications where after additional encapsulation, resulting
packet could be bigger then interface MTU.
Aside from new helper this patch series contains minor changes in device
drivers (for ones which requires), so they would recal packet's length
not only when head pointer was adjusted, but if tail's one as well.
v1->v2:
* fixed kbuild warning
* made offset eq 0 invalid for xdp_bpf_adjust_tail
* splitted bpf_prog_test_run fix and selftests in sep commits
* added SPDX licence where applicable
* some reshuffling in patches order (tests now in the end)
Nikita V. Shirokov (11):
bpf: making bpf_prog_test run aware of possible data_end ptr change
bpf: adding tests for bpf_xdp_adjust_tail
bpf: adding bpf_xdp_adjust_tail helper
bpf: make generic xdp compatible w/ bpf_xdp_adjust_tail
bpf: make mlx4 compatible w/ bpf_xdp_adjust_tail
bpf: make bnxt compatible w/ bpf_xdp_adjust_tail
bpf: make cavium thunder compatible w/ bpf_xdp_adjust_tail
bpf: make netronome nfp compatible w/ bpf_xdp_adjust_tail
bpf: make tun compatible w/ bpf_xdp_adjust_tail
bpf: make virtio compatible w/ bpf_xdp_adjust_tail
bpf: add bpf_xdp_adjust_tail sample prog
drivers/net/ethernet/broadcom/bnxt/bnxt_xdp.c | 2 +-
drivers/net/ethernet/cavium/thunder/nicvf_main.c | 2 +-
drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +-
.../net/ethernet/netronome/nfp/nfp_net_common.c | 2 +-
drivers/net/tun.c | 3 +-
drivers/net/virtio_net.c | 7 +-
include/uapi/linux/bpf.h | 10 +-
net/bpf/test_run.c | 3 +-
net/core/dev.c | 10 +-
net/core/filter.c | 29 +++-
samples/bpf/Makefile | 4 +
samples/bpf/xdp_adjust_tail_kern.c | 152 +++++++++++++++++++++
samples/bpf/xdp_adjust_tail_user.c | 142 +++++++++++++++++++
tools/include/uapi/linux/bpf.h | 10 +-
tools/testing/selftests/bpf/Makefile | 2 +-
tools/testing/selftests/bpf/bpf_helpers.h | 5 +
tools/testing/selftests/bpf/test_adjust_tail.c | 30 ++++
tools/testing/selftests/bpf/test_progs.c | 32 +++++
18 files changed, 435 insertions(+), 12 deletions(-)
create mode 100644 samples/bpf/xdp_adjust_tail_kern.c
create mode 100644 samples/bpf/xdp_adjust_tail_user.c
create mode 100644 tools/testing/selftests/bpf/test_adjust_tail.c
--
2.15.1
^ permalink raw reply
* [PATCH bpf-next v2 01/11] bpf: adding bpf_xdp_adjust_tail helper
From: Nikita V. Shirokov @ 2018-04-18 4:29 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann; +Cc: netdev, Nikita V. Shirokov
In-Reply-To: <20180418042951.17183-1-tehnerd@tehnerd.com>
Adding new bpf helper which would allow us to manipulate
xdp's data_end pointer, and allow us to reduce packet's size
indended use case: to generate ICMP messages from XDP context,
where such message would contain truncated original packet.
---
include/uapi/linux/bpf.h | 10 +++++++++-
net/core/filter.c | 29 ++++++++++++++++++++++++++++-
2 files changed, 37 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index c5ec89732a8d..9a2d1a04eb24 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -755,6 +755,13 @@ union bpf_attr {
* @addr: pointer to struct sockaddr to bind socket to
* @addr_len: length of sockaddr structure
* Return: 0 on success or negative error code
+ *
+ * int bpf_xdp_adjust_tail(xdp_md, delta)
+ * Adjust the xdp_md.data_end by delta. Only shrinking of packet's
+ * size is supported.
+ * @xdp_md: pointer to xdp_md
+ * @delta: A negative integer to be added to xdp_md.data_end
+ * Return: 0 on success or negative on error
*/
#define __BPF_FUNC_MAPPER(FN) \
FN(unspec), \
@@ -821,7 +828,8 @@ union bpf_attr {
FN(msg_apply_bytes), \
FN(msg_cork_bytes), \
FN(msg_pull_data), \
- FN(bind),
+ FN(bind), \
+ FN(xdp_adjust_tail),
/* integer value in 'imm' field of BPF_CALL instruction selects which helper
* function eBPF program intends to call
diff --git a/net/core/filter.c b/net/core/filter.c
index a374b8560bc4..29318598fd60 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2725,6 +2725,30 @@ static const struct bpf_func_proto bpf_xdp_adjust_head_proto = {
.arg2_type = ARG_ANYTHING,
};
+BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *, xdp, int, offset)
+{
+ void *data_end = xdp->data_end + offset;
+
+ /* only shrinking is allowed for now. */
+ if (unlikely(offset >= 0))
+ return -EINVAL;
+
+ if (unlikely(data_end < xdp->data + ETH_HLEN))
+ return -EINVAL;
+
+ xdp->data_end = data_end;
+
+ return 0;
+}
+
+static const struct bpf_func_proto bpf_xdp_adjust_tail_proto = {
+ .func = bpf_xdp_adjust_tail,
+ .gpl_only = false,
+ .ret_type = RET_INTEGER,
+ .arg1_type = ARG_PTR_TO_CTX,
+ .arg2_type = ARG_ANYTHING,
+};
+
BPF_CALL_2(bpf_xdp_adjust_meta, struct xdp_buff *, xdp, int, offset)
{
void *meta = xdp->data_meta + offset;
@@ -3074,7 +3098,8 @@ bool bpf_helper_changes_pkt_data(void *func)
func == bpf_l4_csum_replace ||
func == bpf_xdp_adjust_head ||
func == bpf_xdp_adjust_meta ||
- func == bpf_msg_pull_data)
+ func == bpf_msg_pull_data ||
+ func == bpf_xdp_adjust_tail)
return true;
return false;
@@ -3888,6 +3913,8 @@ xdp_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
return &bpf_xdp_redirect_proto;
case BPF_FUNC_redirect_map:
return &bpf_xdp_redirect_map_proto;
+ case BPF_FUNC_xdp_adjust_tail:
+ return &bpf_xdp_adjust_tail_proto;
default:
return bpf_base_func_proto(func_id);
}
--
2.15.1
^ permalink raw reply related
* [PATCH bpf-next v2 02/11] bpf: make generic xdp compatible w/ bpf_xdp_adjust_tail
From: Nikita V. Shirokov @ 2018-04-18 4:29 UTC (permalink / raw)
To: Alexei Starovoitov, Daniel Borkmann, David S. Miller
Cc: netdev, Nikita V. Shirokov
In-Reply-To: <20180418042951.17183-1-tehnerd@tehnerd.com>
w/ bpf_xdp_adjust_tail helper xdp's data_end pointer could be changed as
well (only "decrease" of pointer's location is going to be supported).
changing of this pointer will change packet's size.
for generic XDP we need to reflect this packet's length change by
adjusting skb's tail pointer
Acked-by: Alexei Starovoitov <ast@kernel.org>
---
net/core/dev.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/net/core/dev.c b/net/core/dev.c
index 969462ebb296..11c789231a03 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3996,9 +3996,9 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
struct bpf_prog *xdp_prog)
{
struct netdev_rx_queue *rxqueue;
+ void *orig_data, *orig_data_end;
u32 metalen, act = XDP_DROP;
struct xdp_buff xdp;
- void *orig_data;
int hlen, off;
u32 mac_len;
@@ -4037,6 +4037,7 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
xdp.data_meta = xdp.data;
xdp.data_end = xdp.data + hlen;
xdp.data_hard_start = skb->data - skb_headroom(skb);
+ orig_data_end = xdp.data_end;
orig_data = xdp.data;
rxqueue = netif_get_rxqueue(skb);
@@ -4051,6 +4052,13 @@ static u32 netif_receive_generic_xdp(struct sk_buff *skb,
__skb_push(skb, -off);
skb->mac_header += off;
+ /* check if bpf_xdp_adjust_tail was used. it can only "shrink"
+ * pckt.
+ */
+ off = orig_data_end - xdp.data_end;
+ if (off != 0)
+ skb_set_tail_pointer(skb, xdp.data_end - xdp.data);
+
switch (act) {
case XDP_REDIRECT:
case XDP_TX:
--
2.15.1
^ 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