Re: [1/2] wireless: ath9k_htc: fix NULL-deref at probe
Johan Hovold wrote: > Make sure to check the number of endpoints to avoid dereferencing a > NULL-pointer or accessing memory beyond the endpoint array should a > malicious device lack the expected endpoints. > > Fixes: 36bcce430657 ("ath9k_htc: Handle storage devices") > Cc: Sujith Manoharan > Signed-off-by: Johan Hovold Patch applied to ath-next branch of ath.git, thanks. ebeb36670eca ath9k_htc: fix NULL-deref at probe -- https://patchwork.kernel.org/patch/9620723/ Documentation about submitting wireless patches and checking status from patchwork: https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
[PATCH 2/4] mm: introduce memalloc_noreclaim_{save,restore}
The previous patch has shown that simply setting and clearing PF_MEMALLOC in current->flags can result in wrongly clearing a pre-existing PF_MEMALLOC flag and potentially lead to recursive reclaim. Let's introduce helpers that support proper nesting by saving the previous stat of the flag, similar to the existing memalloc_noio_* and memalloc_nofs_* helpers. Convert existing setting/clearing of PF_MEMALLOC within mm to the new helpers. There are no known issues with the converted code, but the change makes it more robust. Suggested-by: Michal Hocko Signed-off-by: Vlastimil Babka --- include/linux/sched/mm.h | 12 mm/page_alloc.c | 11 ++- mm/vmscan.c | 17 +++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h index 9daabe138c99..2b24a6974847 100644 --- a/include/linux/sched/mm.h +++ b/include/linux/sched/mm.h @@ -191,4 +191,16 @@ static inline void memalloc_nofs_restore(unsigned int flags) current->flags = (current->flags & ~PF_MEMALLOC_NOFS) | flags; } +static inline unsigned int memalloc_noreclaim_save(void) +{ + unsigned int flags = current->flags & PF_MEMALLOC; + current->flags |= PF_MEMALLOC; + return flags; +} + +static inline void memalloc_noreclaim_restore(unsigned int flags) +{ + current->flags = (current->flags & ~PF_MEMALLOC) | flags; +} + #endif /* _LINUX_SCHED_MM_H */ diff --git a/mm/page_alloc.c b/mm/page_alloc.c index b84e6ffbe756..037e32dccd7a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3288,15 +3288,15 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, enum compact_priority prio, enum compact_result *compact_result) { struct page *page; - unsigned int noreclaim_flag = current->flags & PF_MEMALLOC; + unsigned int noreclaim_flag; if (!order) return NULL; - current->flags |= PF_MEMALLOC; + noreclaim_flag = memalloc_noreclaim_save(); *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac, prio); - current->flags = (current->flags & ~PF_MEMALLOC) | noreclaim_flag; + memalloc_noreclaim_restore(noreclaim_flag); if (*compact_result <= COMPACT_INACTIVE) return NULL; @@ -3443,12 +3443,13 @@ __perform_reclaim(gfp_t gfp_mask, unsigned int order, { struct reclaim_state reclaim_state; int progress; + unsigned int noreclaim_flag; cond_resched(); /* We now go into synchronous reclaim */ cpuset_memory_pressure_bump(); - current->flags |= PF_MEMALLOC; + noreclaim_flag = memalloc_noreclaim_save(); lockdep_set_current_reclaim_state(gfp_mask); reclaim_state.reclaimed_slab = 0; current->reclaim_state = &reclaim_state; @@ -3458,7 +3459,7 @@ __perform_reclaim(gfp_t gfp_mask, unsigned int order, current->reclaim_state = NULL; lockdep_clear_current_reclaim_state(); - current->flags &= ~PF_MEMALLOC; + memalloc_noreclaim_restore(noreclaim_flag); cond_resched(); diff --git a/mm/vmscan.c b/mm/vmscan.c index 58615bb27f2f..ff63b91a0f48 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2992,6 +2992,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, struct zonelist *zonelist; unsigned long nr_reclaimed; int nid; + unsigned int noreclaim_flag; struct scan_control sc = { .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), .gfp_mask = (current_gfp_context(gfp_mask) & GFP_RECLAIM_MASK) | @@ -3018,9 +3019,9 @@ unsigned long try_to_free_mem_cgroup_pages(struct mem_cgroup *memcg, sc.gfp_mask, sc.reclaim_idx); - current->flags |= PF_MEMALLOC; + noreclaim_flag = memalloc_noreclaim_save(); nr_reclaimed = do_try_to_free_pages(zonelist, &sc); - current->flags &= ~PF_MEMALLOC; + memalloc_noreclaim_restore(noreclaim_flag); trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); @@ -3544,8 +3545,9 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim) struct zonelist *zonelist = node_zonelist(numa_node_id(), sc.gfp_mask); struct task_struct *p = current; unsigned long nr_reclaimed; + unsigned int noreclaim_flag; - p->flags |= PF_MEMALLOC; + noreclaim_flag = memalloc_noreclaim_save(); lockdep_set_current_reclaim_state(sc.gfp_mask); reclaim_state.reclaimed_slab = 0; p->reclaim_state = &reclaim_state; @@ -3554,7 +3556,7 @@ unsigned long shrink_all_memory(unsigned long nr_to_reclaim) p->reclaim_state = NULL; lockdep_clear_current_reclaim_state(); - p->flags &= ~PF_MEMALLOC; + memalloc_noreclaim_re
[PATCH 3/4] treewide: convert PF_MEMALLOC manipulations to new helpers
We now have memalloc_noreclaim_{save,restore} helpers for robust setting and clearing of PF_MEMALLOC. Let's convert the code which was using the generic tsk_restore_flags(). No functional change. Signed-off-by: Vlastimil Babka Cc: Josef Bacik Cc: Lee Duncan Cc: Chris Leech Cc: "David S. Miller" Cc: Eric Dumazet --- drivers/block/nbd.c | 7 --- drivers/scsi/iscsi_tcp.c | 7 --- net/core/dev.c | 7 --- net/core/sock.c | 7 --- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c index 03ae72985c79..929fc548c7fb 100644 --- a/drivers/block/nbd.c +++ b/drivers/block/nbd.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -210,7 +211,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send, struct socket *sock = nbd->socks[index]->sock; int result; struct msghdr msg; - unsigned long pflags = current->flags; + unsigned int noreclaim_flag; if (unlikely(!sock)) { dev_err_ratelimited(disk_to_dev(nbd->disk), @@ -221,7 +222,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send, msg.msg_iter = *iter; - current->flags |= PF_MEMALLOC; + noreclaim_flag = memalloc_noreclaim_save(); do { sock->sk->sk_allocation = GFP_NOIO | __GFP_MEMALLOC; msg.msg_name = NULL; @@ -244,7 +245,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, int send, *sent += result; } while (msg_data_left(&msg)); - tsk_restore_flags(current, pflags, PF_MEMALLOC); + memalloc_noreclaim_restore(noreclaim_flag); return result; } diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 4228aba1f654..4842fc0e809d 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -371,10 +372,10 @@ static inline int iscsi_sw_tcp_xmit_qlen(struct iscsi_conn *conn) static int iscsi_sw_tcp_pdu_xmit(struct iscsi_task *task) { struct iscsi_conn *conn = task->conn; - unsigned long pflags = current->flags; + unsigned int noreclaim_flag; int rc = 0; - current->flags |= PF_MEMALLOC; + noreclaim_flag = memalloc_noreclaim_save(); while (iscsi_sw_tcp_xmit_qlen(conn)) { rc = iscsi_sw_tcp_xmit(conn); @@ -387,7 +388,7 @@ static int iscsi_sw_tcp_pdu_xmit(struct iscsi_task *task) rc = 0; } - tsk_restore_flags(current, pflags, PF_MEMALLOC); + memalloc_noreclaim_restore(noreclaim_flag); return rc; } diff --git a/net/core/dev.c b/net/core/dev.c index fde8b3f7136b..e0705a126b24 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -81,6 +81,7 @@ #include #include #include +#include #include #include #include @@ -4227,7 +4228,7 @@ static int __netif_receive_skb(struct sk_buff *skb) int ret; if (sk_memalloc_socks() && skb_pfmemalloc(skb)) { - unsigned long pflags = current->flags; + unsigned int noreclaim_flag; /* * PFMEMALLOC skbs are special, they should @@ -4238,9 +4239,9 @@ static int __netif_receive_skb(struct sk_buff *skb) * Use PF_MEMALLOC as this saves us from propagating the allocation * context down to all allocation sites. */ - current->flags |= PF_MEMALLOC; + noreclaim_flag = memalloc_noreclaim_save(); ret = __netif_receive_skb_core(skb, true); - tsk_restore_flags(current, pflags, PF_MEMALLOC); + memalloc_noreclaim_restore(noreclaim_flag); } else ret = __netif_receive_skb_core(skb, false); diff --git a/net/core/sock.c b/net/core/sock.c index 392f9b6f96e2..0b2d06b4c308 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -102,6 +102,7 @@ #include #include #include +#include #include #include #include @@ -372,14 +373,14 @@ EXPORT_SYMBOL_GPL(sk_clear_memalloc); int __sk_backlog_rcv(struct sock *sk, struct sk_buff *skb) { int ret; - unsigned long pflags = current->flags; + unsigned int noreclaim_flag; /* these should have been dropped before queueing */ BUG_ON(!sock_flag(sk, SOCK_MEMALLOC)); - current->flags |= PF_MEMALLOC; + noreclaim_flag = memalloc_noreclaim_save(); ret = sk->sk_backlog_rcv(sk, skb); - tsk_restore_flags(current, pflags, PF_MEMALLOC); + memalloc_noreclaim_restore(noreclaim_flag); return ret; } -- 2.12.2
[PATCH 1/4] mm: prevent potential recursive reclaim due to clearing PF_MEMALLOC
The function __alloc_pages_direct_compact() sets PF_MEMALLOC to prevent deadlock during page migration by lock_page() (see the comment in __unmap_and_move()). Then it unconditionally clears the flag, which can clear a pre-existing PF_MEMALLOC flag and result in recursive reclaim. This was not a problem until commit a8161d1ed609 ("mm, page_alloc: restructure direct compaction handling in slowpath"), because direct compation was called only after direct reclaim, which was skipped when PF_MEMALLOC flag was set. Even now it's only a theoretical issue, as the new callsite of __alloc_pages_direct_compact() is reached only for costly orders and when gfp_pfmemalloc_allowed() is true, which means either __GFP_NOMEMALLOC is in gfp_flags or in_interrupt() is true. There is no such known context, but let's play it safe and make __alloc_pages_direct_compact() robust for cases where PF_MEMALLOC is already set. Fixes: a8161d1ed609 ("mm, page_alloc: restructure direct compaction handling in slowpath") Reported-by: Andrey Ryabinin Signed-off-by: Vlastimil Babka Cc: --- mm/page_alloc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3589f8be53be..b84e6ffbe756 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3288,6 +3288,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, enum compact_priority prio, enum compact_result *compact_result) { struct page *page; + unsigned int noreclaim_flag = current->flags & PF_MEMALLOC; if (!order) return NULL; @@ -3295,7 +3296,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned int order, current->flags |= PF_MEMALLOC; *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac, prio); - current->flags &= ~PF_MEMALLOC; + current->flags = (current->flags & ~PF_MEMALLOC) | noreclaim_flag; if (*compact_result <= COMPACT_INACTIVE) return NULL; -- 2.12.2
[PATCH 4/4] mtd: nand: nandsim: convert to memalloc_noreclaim_*()
Nandsim has own functions set_memalloc() and clear_memalloc() for robust setting and clearing of PF_MEMALLOC. Replace them by the new generic helpers. No functional change. Signed-off-by: Vlastimil Babka Cc: Boris Brezillon Cc: Richard Weinberger --- drivers/mtd/nand/nandsim.c | 29 + 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index cef818f535ed..03a0d057bf2f 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -1368,31 +1369,18 @@ static int get_pages(struct nandsim *ns, struct file *file, size_t count, loff_t return 0; } -static int set_memalloc(void) -{ - if (current->flags & PF_MEMALLOC) - return 0; - current->flags |= PF_MEMALLOC; - return 1; -} - -static void clear_memalloc(int memalloc) -{ - if (memalloc) - current->flags &= ~PF_MEMALLOC; -} - static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t pos) { ssize_t tx; - int err, memalloc; + int err; + unsigned int noreclaim_flag; err = get_pages(ns, file, count, pos); if (err) return err; - memalloc = set_memalloc(); + noreclaim_flag = memalloc_noreclaim_save(); tx = kernel_read(file, pos, buf, count); - clear_memalloc(memalloc); + memalloc_noreclaim_restore(noreclaim_flag); put_pages(ns); return tx; } @@ -1400,14 +1388,15 @@ static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, size_ static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, size_t count, loff_t pos) { ssize_t tx; - int err, memalloc; + int err; + unsigned int noreclaim_flag; err = get_pages(ns, file, count, pos); if (err) return err; - memalloc = set_memalloc(); + noreclaim_flag = memalloc_noreclaim_save(); tx = kernel_write(file, buf, count, pos); - clear_memalloc(memalloc); + memalloc_noreclaim_restore(noreclaim_flag); put_pages(ns); return tx; } -- 2.12.2
[PATCH 0/4] more robust PF_MEMALLOC handling
Hi, this series aims to unify the setting and clearing of PF_MEMALLOC, which prevents recursive reclaim. There are some places that clear the flag unconditionally from current->flags, which may result in clearing a pre-existing flag. This already resulted in a bug report that Patch 1 fixes (without the new helpers, to make backporting easier). Patch 2 introduces the new helpers, modelled after existing memalloc_noio_* and memalloc_nofs_* helpers, and converts mm core to use them. Patches 3 and 4 convert non-mm code. Based on next-20170404. Vlastimil Babka (4): mm: prevent potential recursive reclaim due to clearing PF_MEMALLOC mm: introduce memalloc_noreclaim_{save,restore} treewide: convert PF_MEMALLOC manipulations to new helpers mtd: nand: nandsim: convert to memalloc_noreclaim_*() drivers/block/nbd.c| 7 --- drivers/mtd/nand/nandsim.c | 29 + drivers/scsi/iscsi_tcp.c | 7 --- include/linux/sched/mm.h | 12 mm/page_alloc.c| 10 ++ mm/vmscan.c| 17 +++-- net/core/dev.c | 7 --- net/core/sock.c| 7 --- 8 files changed, 54 insertions(+), 42 deletions(-) -- 2.12.2
Re: [PATCH v1] NFC: netlink: Use error code from nfc_activate_target()
Hi Andy, On Wed, Mar 22, 2017 at 09:20:58PM +0200, Andy Shevchenko wrote: > It looks like a typo to assign a return code to a variable which is not > used. Found due to a compiler warning: > > net/nfc/netlink.c: In function ‘nfc_genl_activate_target’: > net/nfc/netlink.c:903:6: warning: variable ‘rc’ set but not used > [-Wunused-but-set-variable] > int rc; > ^~ > > Signed-off-by: Andy Shevchenko > --- > net/nfc/netlink.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Applied, thanks. Cheers, Samuel.
Re: [PATCH v1] NFC: Add nfc_dbg() macro
On Wed, Mar 22, 2017 at 09:22:51PM +0200, Andy Shevchenko wrote: > In some cases nfc_dbg() is useful. Add such macro to a header. > > Signed-off-by: Andy Shevchenko > --- > include/net/nfc/nfc.h | 1 + > 1 file changed, 1 insertion(+) Applied as well. Cheers, Samuel.
[PATCH] net: davinci_mdio: add GPIO reset logic
Some boards [1] leave the PHYs at an invalid state during system power-up or reset thus causing unreliability issues with the PHY like not being detected by the mdio bus or link not functional. To work around these boards have a GPIO connected to the PHY's reset pin. Implement GPIO reset handling for such cases. [1] - am572x-idk, am571x-idk, a437x-idk. Signed-off-by: Roger Quadros Signed-off-by: Sekhar Nori --- .../devicetree/bindings/net/davinci-mdio.txt | 2 + drivers/net/ethernet/ti/davinci_mdio.c | 68 +++--- 2 files changed, 62 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/net/davinci-mdio.txt b/Documentation/devicetree/bindings/net/davinci-mdio.txt index 621156c..fd6ebe7 100644 --- a/Documentation/devicetree/bindings/net/davinci-mdio.txt +++ b/Documentation/devicetree/bindings/net/davinci-mdio.txt @@ -12,6 +12,8 @@ Required properties: Optional properties: - ti,hwmods: Must be "davinci_mdio" +- reset-gpios : array of GPIO specifier for PHY hardware reset control +- reset-delay-us : reset assertion time [in microseconds] Note: "ti,hwmods" field is used to fetch the base address and irq resources from TI, omap hwmod data base during device registration. diff --git a/drivers/net/ethernet/ti/davinci_mdio.c b/drivers/net/ethernet/ti/davinci_mdio.c index 33df340..c6f9e55 100644 --- a/drivers/net/ethernet/ti/davinci_mdio.c +++ b/drivers/net/ethernet/ti/davinci_mdio.c @@ -40,6 +40,9 @@ #include #include #include +#include +#include +#include /* * This timeout definition is a worst-case ultra defensive measure against @@ -53,6 +56,8 @@ #define DEF_OUT_FREQ 220 /* 2.2 MHz */ +#define DEFAULT_GPIO_RESET_DELAY 10 /* in microseconds */ + struct davinci_mdio_of_param { int autosuspend_delay_ms; }; @@ -104,6 +109,9 @@ struct davinci_mdio_data { */ boolskip_scan; u32 clk_div; + struct gpio_desc **gpio_reset; + int num_gpios; + int reset_delay_us; }; static void davinci_mdio_init_clk(struct davinci_mdio_data *data) @@ -142,6 +150,20 @@ static void davinci_mdio_enable(struct davinci_mdio_data *data) __raw_writel(data->clk_div | CONTROL_ENABLE, &data->regs->control); } +static void __davinci_gpio_reset(struct davinci_mdio_data *data) +{ + int i; + + for (i = 0; i < data->num_gpios; i++) { + if (!data->gpio_reset[i]) + continue; + + gpiod_set_value_cansleep(data->gpio_reset[i], 1); + udelay(data->reset_delay_us); + gpiod_set_value_cansleep(data->gpio_reset[i], 0); + } +} + static int davinci_mdio_reset(struct mii_bus *bus) { struct davinci_mdio_data *data = bus->priv; @@ -317,20 +339,50 @@ static int davinci_mdio_write(struct mii_bus *bus, int phy_id, } #if IS_ENABLED(CONFIG_OF) -static int davinci_mdio_probe_dt(struct mdio_platform_data *data, -struct platform_device *pdev) +static int davinci_mdio_probe_dt(struct davinci_mdio_data *data, +struct platform_device *pdev) { struct device_node *node = pdev->dev.of_node; u32 prop; - - if (!node) - return -EINVAL; + int error; + int i; + struct gpio_desc *gpiod; if (of_property_read_u32(node, "bus_freq", &prop)) { dev_err(&pdev->dev, "Missing bus_freq property in the DT.\n"); - return -EINVAL; + data->pdata = default_pdata; + } else { + data->pdata.bus_freq = prop; + } + + i = of_gpio_named_count(node, "reset-gpios"); + if (i > 0) { + data->num_gpios = i; + data->gpio_reset = devm_kcalloc(&pdev->dev, i, + sizeof(struct gpio_desc *), + GFP_KERNEL); + if (!data->gpio_reset) + return -ENOMEM; + + for (i = 0; i < data->num_gpios; i++) { + gpiod = devm_gpiod_get_index(&pdev->dev, "reset", i, +GPIOD_OUT_LOW); + if (IS_ERR(gpiod)) { + error = PTR_ERR(gpiod); + if (error == -ENOENT) + continue; + else + return error; + } + data->gpio_reset[i] = gpiod; + } + + if (of_property_read_u32(node, "reset-delay-us", +&data->reset_delay_us)) + data->reset_delay_us = DEFAULT_GPIO_RESET_DELAY; + + __davinci_gpio_reset(data); } - d
Re: [PATCH 0/2] ARM: am335x-icev2: Add ethernet support
On 04/04/17 19:01, Tony Lindgren wrote: > * Roger Quadros [170330 05:37]: >> Hi Tony & Dave, >> >> On 13/03/17 15:42, Roger Quadros wrote: >>> Hi, >>> >>> This series adds ethernet support to am335x-icev2 board. >>> >>> The ethernet PHYs on the board need an explicit GPIO reset pulse >>> to ensure they bootstrap to the correct mode. Without the >>> GPIO reset they just don't work. >>> >>> cheers, >>> -roger >> >> Any comments on this series. Patch 1 is at version 2. > > I think you meant patch 2/3 is at version2. I've picked > patches 2 and 3 for v4.12 into dt and defconfig branches. Thanks Tony. > > You may need to resend the davinci_mdio.c patch alone > for Dave as he usually won't pick individual patches I > think. OK, I'll send that one separately. cheers, -roger > > Regards, > > Tony > >>> Roger Quadros (2): >>> net: davinci_mdio: add GPIO reset logic >>> ARM: dts: am335x-icev2: Add CPSW ethernet0 and ethernet1 >>> >>> .../devicetree/bindings/net/davinci-mdio.txt | 2 + >>> arch/arm/boot/dts/am335x-icev2.dts | 113 >>> + >>> drivers/net/ethernet/ti/davinci_mdio.c | 68 +++-- >>> 3 files changed, 175 insertions(+), 8 deletions(-) >>> >>
[PATCH net-next 3/7] s390/qeth: remove unused return value
From: Julian Wiedmann qeth_qdio_output_handler() is the only caller of qeth_handle_send_error() and doesn't care about the return value. Signed-off-by: Julian Wiedmann Signed-off-by: Ursula Braun Reviewed-by: Thomas Richter --- drivers/s390/net/qeth_core.h | 7 --- drivers/s390/net/qeth_core_main.c | 7 +++ 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index e7addea..77f7cfd 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -503,13 +503,6 @@ struct qeth_qdio_info { int default_out_queue; }; -enum qeth_send_errors { - QETH_SEND_ERROR_NONE, - QETH_SEND_ERROR_LINK_FAILURE, - QETH_SEND_ERROR_RETRY, - QETH_SEND_ERROR_KICK_IT, -}; - #define QETH_ETH_MAC_V4 0x0100 /* like v4 */ #define QETH_ETH_MAC_V6 0x /* like v6 */ /* tr mc mac is longer, but that will be enough to detect mc frames */ diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 95bd5d8..639b92b 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -3322,7 +3322,7 @@ void qeth_queue_input_buffer(struct qeth_card *card, int index) } EXPORT_SYMBOL_GPL(qeth_queue_input_buffer); -static int qeth_handle_send_error(struct qeth_card *card, +static void qeth_handle_send_error(struct qeth_card *card, struct qeth_qdio_out_buffer *buffer, unsigned int qdio_err) { int sbalf15 = buffer->buffer->element[15].sflags; @@ -3338,15 +3338,14 @@ static int qeth_handle_send_error(struct qeth_card *card, qeth_check_qdio_errors(card, buffer->buffer, qdio_err, "qouterr"); if (!qdio_err) - return QETH_SEND_ERROR_NONE; + return; if ((sbalf15 >= 15) && (sbalf15 <= 31)) - return QETH_SEND_ERROR_RETRY; + return; QETH_CARD_TEXT(card, 1, "lnkfail"); QETH_CARD_TEXT_(card, 1, "%04x %02x", (u16)qdio_err, (u8)sbalf15); - return QETH_SEND_ERROR_LINK_FAILURE; } /* -- 2.10.2
[PATCH net-next 0/7] s390 patches for net-next
Hi Dave, here are some cleanup patches for drivers/s390/net. Thanks, Ursula Hans Wippel (3): s390/qeth: improve endianness handling s390/ctcm: improve endianness handling s390/netiucv: improve endianness handling Julian Wiedmann (4): s390/qeth: use QDIO_*_QFMT defines s390/qeth: fix up ssqd tracing s390/qeth: remove unused return value s390/qeth: Remove unused code drivers/s390/net/ctcm_fsms.c | 2 +- drivers/s390/net/ctcm_main.c | 12 +- drivers/s390/net/netiucv.c| 2 +- drivers/s390/net/qeth_core.h | 16 ++--- drivers/s390/net/qeth_core_main.c | 35 +-- drivers/s390/net/qeth_core_mpc.h | 17 - drivers/s390/net/qeth_l2_main.c | 1 - drivers/s390/net/qeth_l2_sys.c| 3 --- drivers/s390/net/qeth_l3_main.c | 50 ++- drivers/s390/net/qeth_l3_sys.c| 4 ++-- 10 files changed, 51 insertions(+), 91 deletions(-) -- 2.10.2
[PATCH net-next 6/7] s390/ctcm: improve endianness handling
From: Hans Wippel Use endianness conversions for SKB protocol assignments and usage to avoid endianness warnings reported by sparse. No functional changes. Signed-off-by: Hans Wippel Signed-off-by: Ursula Braun --- drivers/s390/net/ctcm_fsms.c | 2 +- drivers/s390/net/ctcm_main.c | 12 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/s390/net/ctcm_fsms.c b/drivers/s390/net/ctcm_fsms.c index fd5944b..730d961 100644 --- a/drivers/s390/net/ctcm_fsms.c +++ b/drivers/s390/net/ctcm_fsms.c @@ -1283,7 +1283,7 @@ static void ctcmpc_chx_txdone(fsm_instance *fi, int event, void *arg) p_header = (struct pdu *) (skb_tail_pointer(ch->trans_skb) - skb->len); p_header->pdu_flag = 0x00; - if (skb->protocol == ntohs(ETH_P_SNAP)) + if (be16_to_cpu(skb->protocol) == ETH_P_SNAP) p_header->pdu_flag |= 0x60; else p_header->pdu_flag |= 0x20; diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index ac65f12..198842c 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c @@ -106,7 +106,7 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) priv->stats.rx_frame_errors++; return; } - pskb->protocol = ntohs(header->type); + pskb->protocol = cpu_to_be16(header->type); if ((header->length <= LL_HEADER_LENGTH) || (len <= LL_HEADER_LENGTH)) { if (!(ch->logflags & LOG_FLAG_ILLEGALSIZE)) { @@ -125,7 +125,7 @@ void ctcm_unpack_skb(struct channel *ch, struct sk_buff *pskb) header->length -= LL_HEADER_LENGTH; len -= LL_HEADER_LENGTH; if ((header->length > skb_tailroom(pskb)) || - (header->length > len)) { + (header->length > len)) { if (!(ch->logflags & LOG_FLAG_OVERRUN)) { CTCM_DBF_TEXT_(ERROR, CTC_DBF_ERROR, "%s(%s): Packet size %d (overrun)" @@ -485,7 +485,7 @@ static int ctcm_transmit_skb(struct channel *ch, struct sk_buff *skb) } else { atomic_inc(&skb->users); header.length = l; - header.type = skb->protocol; + header.type = be16_to_cpu(skb->protocol); header.unused = 0; memcpy(skb_push(skb, LL_HEADER_LENGTH), &header, LL_HEADER_LENGTH); @@ -503,7 +503,7 @@ static int ctcm_transmit_skb(struct channel *ch, struct sk_buff *skb) atomic_inc(&skb->users); ch->prof.txlen += skb->len; header.length = skb->len + LL_HEADER_LENGTH; - header.type = skb->protocol; + header.type = be16_to_cpu(skb->protocol); header.unused = 0; memcpy(skb_push(skb, LL_HEADER_LENGTH), &header, LL_HEADER_LENGTH); block_len = skb->len + 2; @@ -690,7 +690,7 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) p_header->pdu_offset = skb->len; p_header->pdu_proto = 0x01; p_header->pdu_flag = 0x00; - if (skb->protocol == ntohs(ETH_P_SNAP)) { + if (be16_to_cpu(skb->protocol) == ETH_P_SNAP) { p_header->pdu_flag |= PDU_FIRST | PDU_CNTL; } else { p_header->pdu_flag |= PDU_FIRST; @@ -745,7 +745,7 @@ static int ctcmpc_transmit_skb(struct channel *ch, struct sk_buff *skb) p_header->pdu_proto = 0x01; p_header->pdu_flag = 0x00; p_header->pdu_seq = 0; - if (skb->protocol == ntohs(ETH_P_SNAP)) { + if (be16_to_cpu(skb->protocol) == ETH_P_SNAP) { p_header->pdu_flag |= PDU_FIRST | PDU_CNTL; } else { p_header->pdu_flag |= PDU_FIRST; -- 2.10.2
[PATCH net-next 5/7] s390/qeth: improve endianness handling
From: Hans Wippel Avoid endianness warnings reported by sparse by (1) using endianness conversions for assigning and using network packet fields, and (2) removing unnecessary endianness conversions from qeth_l3_rebuild_skb. No functional changes. Signed-off-by: Hans Wippel Signed-off-by: Ursula Braun --- drivers/s390/net/qeth_core.h | 4 ++-- drivers/s390/net/qeth_core_main.c | 11 +- drivers/s390/net/qeth_l3_main.c | 46 +++ drivers/s390/net/qeth_l3_sys.c| 4 ++-- 4 files changed, 33 insertions(+), 32 deletions(-) diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 22aa2cd..6764ab9 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -844,9 +844,9 @@ static inline int qeth_get_ip_version(struct sk_buff *skb) { __be16 *p = &((struct ethhdr *)skb->data)->h_proto; - if (*p == ETH_P_8021Q) + if (be16_to_cpu(*p) == ETH_P_8021Q) p += 2; - switch (*p) { + switch (be16_to_cpu(*p)) { case ETH_P_IPV6: return 6; case ETH_P_IP: diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 194f9d8..e76b764 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -1201,7 +1201,7 @@ static void qeth_notify_skbs(struct qeth_qdio_out_q *q, while (skb) { QETH_CARD_TEXT_(q->card, 5, "skbn%d", notification); QETH_CARD_TEXT_(q->card, 5, "%lx", (long) skb); - if (skb->protocol == ETH_P_AF_IUCV) { + if (be16_to_cpu(skb->protocol) == ETH_P_AF_IUCV) { if (skb->sk) { struct iucv_sock *iucv = iucv_sk(skb->sk); iucv->sk_txnotify(skb, notification); @@ -1232,7 +1232,8 @@ static void qeth_release_skbs(struct qeth_qdio_out_buffer *buf) while (skb) { QETH_CARD_TEXT(buf->q->card, 5, "skbr"); QETH_CARD_TEXT_(buf->q->card, 5, "%lx", (long) skb); - if (notify_general_error && skb->protocol == ETH_P_AF_IUCV) { + if (notify_general_error && + be16_to_cpu(skb->protocol) == ETH_P_AF_IUCV) { if (skb->sk) { iucv = iucv_sk(skb->sk); iucv->sk_txnotify(skb, TX_NOTIFY_GENERALERROR); @@ -3796,9 +3797,9 @@ int qeth_get_priority_queue(struct qeth_card *card, struct sk_buff *skb, return qeth_cut_iqd_prio(card, ~skb->priority >> 1 & 3); case QETH_PRIO_Q_ING_VLAN: tci = &((struct ethhdr *)skb->data)->h_proto; - if (*tci == ETH_P_8021Q) - return qeth_cut_iqd_prio(card, ~*(tci + 1) >> - (VLAN_PRIO_SHIFT + 1) & 3); + if (be16_to_cpu(*tci) == ETH_P_8021Q) + return qeth_cut_iqd_prio(card, + ~be16_to_cpu(*(tci + 1)) >> (VLAN_PRIO_SHIFT + 1) & 3); break; default: break; diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c index 8de5f74..91060fb 100644 --- a/drivers/s390/net/qeth_l3_main.c +++ b/drivers/s390/net/qeth_l3_main.c @@ -1337,7 +1337,7 @@ qeth_diags_trace(struct qeth_card *card, enum qeth_diags_trace_cmds diags_cmd) return qeth_send_ipa_cmd(card, iob, qeth_diags_trace_cb, NULL); } -static void qeth_l3_get_mac_for_ipm(__u32 ipm, char *mac) +static void qeth_l3_get_mac_for_ipm(__be32 ipm, char *mac) { ip_eth_mc_map(ipm, mac); } @@ -1410,7 +1410,7 @@ qeth_l3_add_mc_to_hash(struct qeth_card *card, struct in_device *in4_dev) im4 = rcu_dereference(im4->next_rcu)) { qeth_l3_get_mac_for_ipm(im4->multiaddr, buf); - tmp->u.a4.addr = im4->multiaddr; + tmp->u.a4.addr = be32_to_cpu(im4->multiaddr); memcpy(tmp->mac, buf, sizeof(tmp->mac)); ipm = qeth_l3_ip_from_hash(card, tmp); @@ -1421,7 +1421,7 @@ qeth_l3_add_mc_to_hash(struct qeth_card *card, struct in_device *in4_dev) if (!ipm) continue; memcpy(ipm->mac, buf, sizeof(tmp->mac)); - ipm->u.a4.addr = im4->multiaddr; + ipm->u.a4.addr = be32_to_cpu(im4->multiaddr); ipm->is_multicast = 1; ipm->disp_flag = QETH_DISP_ADDR_ADD; hash_add(card->ip_mc_htable, @@ -1594,8 +1594,8 @@ static void qeth_l3_free_vlan_addresses4(struct qeth_card *card, spin_lock_bh(&card->ip_lock); for (ifa = in_dev->ifa_list; ifa; ifa = ifa->ifa_next) { - addr->u.a4.addr = ifa->ifa_address; - addr->u.a4.mask = ifa->ifa_mask; + addr->u.a4.addr = be32_to_cpu(ifa->ifa_address); +
[PATCH net-next 4/7] s390/qeth: Remove unused code
From: Julian Wiedmann 1. options.add_hhlen is set but never used, drop it 2. clean up no longer required forward declarations 3. delete all sorts of unused defines Signed-off-by: Julian Wiedmann Reviewed-by: Thomas Richter --- drivers/s390/net/qeth_core.h | 5 - drivers/s390/net/qeth_core_main.c | 2 -- drivers/s390/net/qeth_core_mpc.h | 17 - drivers/s390/net/qeth_l2_main.c | 1 - drivers/s390/net/qeth_l2_sys.c| 3 --- drivers/s390/net/qeth_l3_main.c | 4 6 files changed, 32 deletions(-) diff --git a/drivers/s390/net/qeth_core.h b/drivers/s390/net/qeth_core.h index 77f7cfd..22aa2cd 100644 --- a/drivers/s390/net/qeth_core.h +++ b/drivers/s390/net/qeth_core.h @@ -509,9 +509,6 @@ struct qeth_qdio_info { #define QETH_TR_MAC_NC 0xc000 /* non-canonical */ #define QETH_TR_MAC_C0x0300 /* canonical */ -#define DEFAULT_ADD_HHLEN 0 -#define MAX_ADD_HHLEN 1024 - /** * buffer stuff for read channel */ @@ -637,7 +634,6 @@ struct qeth_reply { atomic_t refcnt; }; - struct qeth_card_blkt { int time_total; int inter_packet; @@ -678,7 +674,6 @@ struct qeth_card_options { struct qeth_ipa_info ipa6; struct qeth_sbp_info sbp; /* SETBRIDGEPORT options */ int fake_broadcast; - int add_hhlen; int layer2; int performance_stats; int rx_sg_cb; diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 639b92b..194f9d8 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -55,7 +55,6 @@ static struct mutex qeth_mod_mutex; static void qeth_send_control_data_cb(struct qeth_channel *, struct qeth_cmd_buffer *); -static int qeth_issue_next_read(struct qeth_card *); static struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *); static void qeth_setup_ccw(struct qeth_channel *, unsigned char *, __u32); static void qeth_free_buffer_pool(struct qeth_card *); @@ -1396,7 +1395,6 @@ static void qeth_set_intial_options(struct qeth_card *card) card->options.route4.type = NO_ROUTER; card->options.route6.type = NO_ROUTER; card->options.fake_broadcast = 0; - card->options.add_hhlen = DEFAULT_ADD_HHLEN; card->options.performance_stats = 0; card->options.rx_sg_cb = QETH_RX_SG_CB; card->options.isolation = ISOLATION_MODE_NONE; diff --git a/drivers/s390/net/qeth_core_mpc.h b/drivers/s390/net/qeth_core_mpc.h index bc69d0a..4accb0a 100644 --- a/drivers/s390/net/qeth_core_mpc.h +++ b/drivers/s390/net/qeth_core_mpc.h @@ -29,7 +29,6 @@ extern unsigned char IPA_PDU_HEADER[]; #define QETH_TIMEOUT (10 * HZ) #define QETH_IPA_TIMEOUT (45 * HZ) #define QETH_IDX_COMMAND_SEQNO 0x -#define SR_INFO_LEN16 #define QETH_CLEAR_CHANNEL_PARM-10 #define QETH_HALT_CHANNEL_PARM -11 @@ -65,7 +64,6 @@ enum qeth_link_types { QETH_LINK_TYPE_LANE_TR = 0x82, QETH_LINK_TYPE_LANE_ETH1000 = 0x83, QETH_LINK_TYPE_LANE = 0x88, - QETH_LINK_TYPE_ATM_NATIVE = 0x90, }; /* @@ -185,8 +183,6 @@ enum qeth_ipa_return_codes { IPA_RC_ENOMEM = 0xfffe, IPA_RC_ = 0x }; -/* for DELIP */ -#define IPA_RC_IP_ADDRESS_NOT_DEFINED IPA_RC_PRIMARY_ALREADY_DEFINED /* for SET_DIAGNOSTIC_ASSIST */ #define IPA_RC_INVALID_SUBCMD IPA_RC_IP_TABLE_FULL #define IPA_RC_HARDWARE_AUTH_ERROR IPA_RC_UNKNOWN_ERROR @@ -631,14 +627,6 @@ enum qeth_ipa_addr_change_code { IPA_ADDR_CHANGE_CODE_MACADDR= 0x02, IPA_ADDR_CHANGE_CODE_REMOVAL= 0x80, /* else addition */ }; -enum qeth_ipa_addr_change_retcode { - IPA_ADDR_CHANGE_RETCODE_OK = 0x, - IPA_ADDR_CHANGE_RETCODE_LOSTEVENTS = 0x0010, -}; -enum qeth_ipa_addr_change_lostmask { - IPA_ADDR_CHANGE_MASK_OVERFLOW = 0x01, - IPA_ADDR_CHANGE_MASK_STATECHANGE= 0x02, -}; struct qeth_ipacmd_addr_change_entry { struct net_if_token token; @@ -817,9 +805,4 @@ extern unsigned char IDX_ACTIVATE_WRITE[]; ((buffer) && \ (*(buffer + ((*(buffer + 0x0b)) + 4)) == 0xc1)) -#define ADDR_FRAME_TYPE_DIX 1 -#define ADDR_FRAME_TYPE_802_3 2 -#define ADDR_FRAME_TYPE_TR_WITHOUT_SR 0x10 -#define ADDR_FRAME_TYPE_TR_WITH_SR 0x20 - #endif diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c index bea4833..5917982 100644 --- a/drivers/s390/net/qeth_l2_main.c +++ b/drivers/s390/net/qeth_l2_main.c @@ -28,7 +28,6 @@ static int qeth_l2_set_offline(struct ccwgroup_device *); static int qeth_l2_stop(struct net_device *); static void qeth_l2_set_rx_mode(struct net_device *); -static int qeth_l2_recover(void *); static void qeth_bridgeport_query_support(struct qeth_card *card); static void qeth_bridge_state_change(struct qeth_card *card,
[PATCH net-next 7/7] s390/netiucv: improve endianness handling
From: Hans Wippel Replace ntohs with endianness conversion for the SKB protocol assignment to avoid an endianness warning reported by sparse. No functional change. Signed-off-by: Hans Wippel Signed-off-by: Ursula Braun --- drivers/s390/net/netiucv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/s390/net/netiucv.c b/drivers/s390/net/netiucv.c index 3f85b97..dba94b4 100644 --- a/drivers/s390/net/netiucv.c +++ b/drivers/s390/net/netiucv.c @@ -635,7 +635,7 @@ static void netiucv_unpack_skb(struct iucv_connection *conn, skb_put(pskb, NETIUCV_HDRLEN); pskb->dev = dev; pskb->ip_summed = CHECKSUM_NONE; - pskb->protocol = ntohs(ETH_P_IP); + pskb->protocol = cpu_to_be16(ETH_P_IP); while (1) { struct sk_buff *skb; -- 2.10.2
[PATCH net-next 1/7] s390/qeth: use QDIO_*_QFMT defines
From: Julian Wiedmann better use the constant definitions. Signed-off-by: Julian Wiedmann Signed-off-by: Ursula Braun Reviewed-by: Thomas Richter --- drivers/s390/net/qeth_core_main.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 315d8a2..3b3cb3b 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -4774,12 +4774,10 @@ static int qeth_query_card_info(struct qeth_card *card, static inline int qeth_get_qdio_q_format(struct qeth_card *card) { - switch (card->info.type) { - case QETH_CARD_TYPE_IQD: - return 2; - default: - return 0; - } + if (card->info.type == QETH_CARD_TYPE_IQD) + return QDIO_IQDIO_QFMT; + else + return QDIO_QETH_QFMT; } static void qeth_determine_capabilities(struct qeth_card *card) -- 2.10.2
[PATCH net-next 2/7] s390/qeth: fix up ssqd tracing
From: Julian Wiedmann The ac fields are bitmaps, so format them as hex. While at it, also print the ac2 field. Signed-off-by: Julian Wiedmann Signed-off-by: Ursula Braun Reviewed-by: Thomas Richter --- drivers/s390/net/qeth_core_main.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 3b3cb3b..95bd5d8 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c @@ -4816,8 +4816,9 @@ static void qeth_determine_capabilities(struct qeth_card *card) QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc); QETH_DBF_TEXT_(SETUP, 2, "qfmt%d", card->ssqd.qfmt); - QETH_DBF_TEXT_(SETUP, 2, "%d", card->ssqd.qdioac1); - QETH_DBF_TEXT_(SETUP, 2, "%d", card->ssqd.qdioac3); + QETH_DBF_TEXT_(SETUP, 2, "ac1:%02x", card->ssqd.qdioac1); + QETH_DBF_TEXT_(SETUP, 2, "ac2:%04x", card->ssqd.qdioac2); + QETH_DBF_TEXT_(SETUP, 2, "ac3:%04x", card->ssqd.qdioac3); QETH_DBF_TEXT_(SETUP, 2, "icnt%d", card->ssqd.icnt); if (!((card->ssqd.qfmt != QDIO_IQDIO_QFMT) || ((card->ssqd.qdioac1 & CHSC_AC1_INITIATE_INPUTQ) == 0) || -- 2.10.2
Re: [PATCH 1/4] net: stmmac: break some functions into RX and TX scopes
Hi Thierry, Às 7:57 PM de 4/4/2017, Thierry Reding escreveu: > On Tue, Apr 04, 2017 at 06:54:24PM +0100, Joao Pinto wrote: >> This patch breaks several functions into RX and TX scopes, which >> will be useful when adding multiple buffers mechanism. >> >> Signed-off-by: Joao Pinto >> --- >> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 350 >> +- >> 1 file changed, 268 insertions(+), 82 deletions(-) > > A couple of small nits below. > >> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c >> b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > [...] >> @@ -924,16 +941,16 @@ static int stmmac_set_bfsize(int mtu, int bufsize) >> } >> >> /** >> - * stmmac_clear_descriptors - clear descriptors >> + * stmmac_clear_rx_descriptors - clear RX descriptors >> * @priv: driver private structure >> - * Description: this function is called to clear the tx and rx descriptors >> + * Description: this function is called to clear the rx descriptors > > You seem to be transitioning to "RX" and "TX" everywhere, maybe do the > same in this comment for consistency? > > Also, on a general note: there's no need for "Description:" here. The > kerneldoc format mandates that you leave a blank line after the block > of parameter descriptions, and the paragraph that follows becomes the > description. I know that these are static functions and are therefore > not parsed by kerneldoc, but since you already use the syntax anyway, > you might as well get it right. > >> * in case of both basic and extended descriptors are used. >> */ >> -static void stmmac_clear_descriptors(struct stmmac_priv *priv) >> +static void stmmac_clear_rx_descriptors(struct stmmac_priv *priv) >> { >> int i; > > This could be unsigned. > >> >> -/* Clear the Rx/Tx descriptors */ >> +/* Clear the RX descriptors */ >> for (i = 0; i < DMA_RX_SIZE; i++) >> if (priv->extend_desc) >> priv->hw->desc->init_rx_desc(&priv->dma_erx[i].basic, >> @@ -943,6 +960,19 @@ static void stmmac_clear_descriptors(struct stmmac_priv >> *priv) >> priv->hw->desc->init_rx_desc(&priv->dma_rx[i], >> priv->use_riwt, priv->mode, >> (i == DMA_RX_SIZE - 1)); >> +} >> + >> +/** >> + * stmmac_clear_tx_descriptors - clear tx descriptors >> + * @priv: driver private structure >> + * Description: this function is called to clear the tx descriptors >> + * in case of both basic and extended descriptors are used. >> + */ >> +static void stmmac_clear_tx_descriptors(struct stmmac_priv *priv) >> +{ >> +int i; > > Same here. There are a couple of other such occurrences throughout the > file. This already exists in many places in the driver, so I don't think > this needs to be changed. Or at least it could be a follow-up patch. > >> + >> +/* Clear the TX descriptors */ >> for (i = 0; i < DMA_TX_SIZE; i++) >> if (priv->extend_desc) >> priv->hw->desc->init_tx_desc(&priv->dma_etx[i].basic, >> @@ -955,6 +985,21 @@ static void stmmac_clear_descriptors(struct stmmac_priv >> *priv) >> } >> >> /** >> + * stmmac_clear_descriptors - clear descriptors >> + * @priv: driver private structure >> + * Description: this function is called to clear the tx and rx descriptors >> + * in case of both basic and extended descriptors are used. >> + */ >> +static void stmmac_clear_descriptors(struct stmmac_priv *priv) >> +{ >> +/* Clear the RX descriptors */ >> +stmmac_clear_rx_descriptors(priv); >> + >> +/* Clear the TX descriptors */ >> +stmmac_clear_tx_descriptors(priv); >> +} >> + >> +/** >> * stmmac_init_rx_buffers - init the RX descriptor buffer. >> * @priv: driver private structure >> * @p: descriptor pointer >> @@ -996,6 +1041,11 @@ static int stmmac_init_rx_buffers(struct stmmac_priv >> *priv, struct dma_desc *p, >> return 0; >> } >> >> +/** >> + * stmmac_free_rx_buffers - free RX dma buffers >> + * @priv: private structure >> + * @i: buffer index. > > If this operates on a single buffer, as specified by the buffer index, > maybe this should be named singular stmmac_free_rx_buffer()? > >> + */ >> static void stmmac_free_rx_buffers(struct stmmac_priv *priv, int i) > > The index could be unsigned. > >> { >> if (priv->rx_skbuff[i]) { >> @@ -1007,14 +1057,42 @@ static void stmmac_free_rx_buffers(struct >> stmmac_priv *priv, int i) >> } >> >> /** >> - * init_dma_desc_rings - init the RX/TX descriptor rings >> + * stmmac_free_tx_buffers - free RX dma buffers >> + * @priv: private structure >> + * @i: buffer index. >> + */ >> +static void stmmac_free_tx_buffers(struct stmmac_priv *priv, int i) >> +{ >> +if (priv->tx_skbuff_dma[i].buf) { >> +if (priv->tx_skbuff_dma[i].map_as_page) >> +dma_unmap_page(priv->device, >> + priv->tx_skbuff_d
Re: [Intel-wired-lan] [PATCH] igb: Allow to remove administratively set MAC on VFs
Hi Alex, On Apr 4 10:33, Alexander Duyck wrote: > On Tue, Apr 4, 2017 at 10:16 AM, Duyck, Alexander H > wrote: > >> -Original Message- > >> From: Intel-wired-lan [mailto:intel-wired-lan-boun...@lists.osuosl.org] On > >> Behalf Of Corinna Vinschen > >> Sent: Tuesday, April 4, 2017 8:11 AM > >> To: intel-wired-...@lists.osuosl.org > >> Cc: netdev@vger.kernel.org > >> Subject: [Intel-wired-lan] [PATCH] igb: Allow to remove administratively > >> set MAC > >> on VFs > >> [...] > > So I just realized there is one other minor issue I just found. In > igb_rar_set_qsel you should probably add a check for > "is_valid_ether_addr(addr)" before you set the E1000_RAH_AV bit. For > the zeroed MAC address it should be cleared so that we aren't > filtering on a MAC address of all 0's for the VF. > > - Alex I see your point, but I'm a bit reluctant to do that because igb_vf_configure() calls igb_set_vf_mac() with addr set to the zeroed MAC explicitely: eth_zero_addr(mac_addr); igb_set_vf_mac(adapter, vf, mac_addr); So in this case the zero MAC is already treated as valid address and the E1000_RAH_AV bit is set. Is that just a bug? Corinna signature.asc Description: PGP signature
[PATCH net-next] net/mlx5e: fix build error without CONFIG_SYSFS
Commit 9008ae074885 ("net/mlx5e: Minimize mlx5e_{open/close}_locked") copied the calls to netif_set_real_num_{tx,rx}_queues from mlx5e_open_locked to mlx5e_activate_priv_channels and wraps them in an if condition to test for netdev->real_num_{tx,rx}_queues. But netdev->real_num_rx_queues is conditionally compiled in if CONFIG_SYSFS is set. Without CONFIG_SYSFS the build fails: drivers/net/ethernet/mellanox/mlx5/core/en_main.c: In function 'mlx5e_activate_priv_channels': drivers/net/ethernet/mellanox/mlx5/core/en_main.c:2515:12: error: 'struct net_device' has no member named 'real_num_rx_queues'; did you mean 'real_num_tx_queues'? Fix this by unconditionally call netif_set_real_num{tx,rx}_queues like before commit 9008ae074885. Fixes: 9008ae074885 ("net/mlx5e: Minimize mlx5e_{open/close}_locked") Signed-off-by: Tobias Regnery --- drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index ec389b1b51cb..d5248637d44f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -2510,10 +2510,8 @@ static void mlx5e_activate_priv_channels(struct mlx5e_priv *priv) struct net_device *netdev = priv->netdev; mlx5e_netdev_set_tcs(netdev); - if (netdev->real_num_tx_queues != num_txqs) - netif_set_real_num_tx_queues(netdev, num_txqs); - if (netdev->real_num_rx_queues != priv->channels.num) - netif_set_real_num_rx_queues(netdev, priv->channels.num); + netif_set_real_num_tx_queues(netdev, num_txqs); + netif_set_real_num_rx_queues(netdev, priv->channels.num); mlx5e_build_channels_tx_maps(priv); mlx5e_activate_channels(&priv->channels); -- 2.11.0
net: dsa: add SMSC/Microchip LAN9303 three port ethernet switch driver
The LAN9303 is a three port 10/100 ethernet switch with integrated phys for the two external ethernet ports. The third port is an RMII/MII interface to a host master network interface (e.g. fixed link). While the LAN9303 device itself supports offload packet processing, this driver does not make use of it yet. This driver just configures the device to provide two separate network interfaces (which is the default state of a DSA device). Please note: the "MDIO managed mode" driver part isn't tested yet. I have used and tested the "I2C managed mode" only. Comments are welcome. jb
[PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging format
To define the outgoing port and to discover the incoming port a regular VLAN tag is used by the LAN9303. But its VID meaning is 'special'. This tag handler/filter depends on some hardware features which must be enabled in the device to provide and make use of this special VLAN tag to control the destination and the source of an ethernet packet. Signed-off-by: Juergen Borleis --- include/net/dsa.h | 1 + net/dsa/Kconfig | 3 + net/dsa/Makefile | 1 + net/dsa/dsa.c | 3 + net/dsa/dsa_priv.h| 3 + net/dsa/tag_lan9303.c | 155 ++ 6 files changed, 166 insertions(+) create mode 100644 net/dsa/tag_lan9303.c diff --git a/include/net/dsa.h b/include/net/dsa.h index 4e13e695f0251..4fb1f2b086b05 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -31,6 +31,7 @@ enum dsa_tag_protocol { DSA_TAG_PROTO_EDSA, DSA_TAG_PROTO_BRCM, DSA_TAG_PROTO_QCA, + DSA_TAG_PROTO_LAN9303, DSA_TAG_LAST, /* MUST BE LAST */ }; diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig index 9649238eef404..22c8bd69ff71c 100644 --- a/net/dsa/Kconfig +++ b/net/dsa/Kconfig @@ -31,4 +31,7 @@ config NET_DSA_TAG_TRAILER config NET_DSA_TAG_QCA bool +config NET_DSA_TAG_LAN9303 + bool + endif diff --git a/net/dsa/Makefile b/net/dsa/Makefile index 31d343796251d..aafc74f2cb193 100644 --- a/net/dsa/Makefile +++ b/net/dsa/Makefile @@ -8,3 +8,4 @@ dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o dsa_core-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o +dsa_core-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index b6d4f6a23f06c..f93f78de23af3 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -53,6 +53,9 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = { #ifdef CONFIG_NET_DSA_TAG_QCA [DSA_TAG_PROTO_QCA] = &qca_netdev_ops, #endif +#ifdef CONFIG_NET_DSA_TAG_LAN9303 + [DSA_TAG_PROTO_LAN9303] = &lan9303_netdev_ops, +#endif [DSA_TAG_PROTO_NONE] = &none_ops, }; diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h index 0706a511244e9..a54cfc8aefa83 100644 --- a/net/dsa/dsa_priv.h +++ b/net/dsa/dsa_priv.h @@ -85,4 +85,7 @@ extern const struct dsa_device_ops brcm_netdev_ops; /* tag_qca.c */ extern const struct dsa_device_ops qca_netdev_ops; +/* tag_lan9303.c */ +extern const struct dsa_device_ops lan9303_netdev_ops; + #endif diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c new file mode 100644 index 0..ad04c6d447f77 --- /dev/null +++ b/net/dsa/tag_lan9303.c @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2017 Pengutronix, Juergen Borleis + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include +#include +#include "dsa_priv.h" + +/* To define the outgoing port and to discover the incoming port a regular + * VLAN tag is used by the LAN9303. But its VID meaning is 'special': + * + * Dest MAC Src MACTAGType + * ...| 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 | 1 2 |... + *|<--->| + * TAG: + *|<->| + *| 1 2 | 3 4 | + * TPIDVID + * 0x8100 + * + * VID bit 3 indicates a request for an ALR lookup. + * + * If VID bit 3 is zero, then bits 0 and 1 specify the destination port + * (0, 1, 2) or broadcast (3) or the source port (1, 2). + * + * VID bit 4 is used to specify if the STP port state should be overridden. + * Required when no forwarding between the external ports should happen. + */ + +#define LAN9303_TAG_LEN 4 + +static struct sk_buff *lan9303_xmit(struct sk_buff *skb, struct net_device *dev) +{ + struct dsa_slave_priv *p = netdev_priv(dev); + u16 *lan9303_tag; + + /* insert a special VLAN tag between the MAC addresses +* and the current ethertype field. +*/ + if (skb_cow_head(skb, LAN9303_TAG_LEN) < 0) { + dev_dbg(&dev->dev, + "Cannot make room for the special tag. Dropping packet\n"); + goto out_free; + } + + /* provide 'LAN9303_TAG_LEN' bytes additional space */ + skb_push(skb, LAN9303_TAG_LEN); + + /* make room between MACs and Ether-Type */ + memmove(skb->data, skb->data + LAN9303_TAG_LEN, 2 * ETH_ALEN); + + lan9303_tag = (u16 *)(skb->data + 2 * ETH_ALEN); + lan9303_tag[0] = htons(ETH_P_8021Q); + lan9303_tag[1] = htons(p->dp->index | BIT(4)); + + return skb; +out_free:
[PATCH 3/4] net: dsa: LAN9303: add I2C managed mode support
In this mode the switch device and the internal phys will be managed via I2C interface. The MDIO interface is still supported, but for the (emulated) CPU port only. Signed-off-by: Juergen Borleis --- .../devicetree/bindings/net/dsa/lan9303.txt| 74 ++ drivers/net/phy/Kconfig| 17 drivers/net/phy/Makefile | 5 + drivers/net/phy/lan9303_i2c.c | 109 + 4 files changed, 205 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/dsa/lan9303.txt create mode 100644 drivers/net/phy/lan9303_i2c.c diff --git a/Documentation/devicetree/bindings/net/dsa/lan9303.txt b/Documentation/devicetree/bindings/net/dsa/lan9303.txt new file mode 100644 index 0..2c8a466065a27 --- /dev/null +++ b/Documentation/devicetree/bindings/net/dsa/lan9303.txt @@ -0,0 +1,74 @@ +SMSC/MicroChip LAN9303 three port ethernet switch +- + +Required properties: + +- compatible: should be "smsc,lan9303" +- #size-cells: must be 0 +- #address-cells: must be 1 + +Optional properties: + +- phy-reset-gpios: GPIO to be used to reset the whole device, always low active +- phy-reset-duration: reset duration, defaults to 200 ms + +Subnodes: + +The integrated switch subnode should be specified according to the binding +described in dsa/dsa.txt. The CPU port of this switch is always port 0. + +Example: + +I2C managed mode: + + master: masterdevice@X { + phy-handle = <ðphy>; + status = "okay"; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + ethphy: ethernet-phy@0 { + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <0>; + max-speed = <100>; + }; + }; + + }; + + switch: switch@a { + compatible = "smsc,lan9303"; + reg = <0xa>; + status = "okay"; + interrupts-extended = <&gpio2 7 IRQ_TYPE_LEVEL_LOW>; + phy-reset-gpios = <&gpio7 6 GPIO_ACTIVE_LOW>; + phy-reset-duration = <200>; + + dsa,member = <0 0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { /* RMII fixed link to master */ + reg = <0>; + label = "cpu"; + ethernet = <&master>; + max-speed = <100>; + }; + + port@1 { /* external port 1 */ + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <1>; + label = "lan1; + }; + + port@2 { /* external port 2 */ + compatible = "ethernet-phy-ieee802.3-c22"; + reg = <2>; + label = "lan2"; + }; + }; + }; diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 8dbd59baa34d5..acbc73adbf8c3 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -345,3 +345,20 @@ endif # PHYLIB config MICREL_KS8995MA tristate "Micrel KS8995MA 5-ports 10/100 managed Ethernet switch" depends on SPI + +config SMSC_LAN9303 + tristate "SMSC LAN9303 3-ports 10/100 ethernet switch" + depends on NET_DSA + select NET_DSA_TAG_LAN9303 + help + This module provides a driver for SMSC LAN9303 3 port ethernet + switch. + +config SMSC_LAN9303_I2C + bool "I2C managed mode" + depends on SMSC_LAN9303 + depends on I2C && OF + select REGMAP_I2C + help + Provide access functions if the SMSC LAN9303 is configured for I2C + managed mode. diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 407b0b601ea82..4313adec2e8b6 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -7,6 +7,10 @@ libphy-$(CONFIG_LED_TRIGGER_PHY) += phy_led_triggers.o obj-$(CONFIG_PHYLIB) += libphy.o +lan9303-objs-y := lan9303-core.o +lan9303-objs-$(CONFIG_SMSC_LAN9303_I2C) += lan9303_i2c.o +lan9303-objs := $(lan9303-objs-y) + obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o obj-$(CONFIG_MDIO_BCM_UNIMAC) += mdio-bcm-unimac.o obj-$(CONFIG_MDIO_BITBANG) += mdio-bitbang.o @@ -52,6 +56,7 @@ obj-$(CONFIG_NATIONAL_PHY)+= national.o obj-$(CONFIG_QSEMI_PHY)+= qsemi.o obj-$(CONFIG_REALTEK_PHY) += realtek.o obj-$(CONFIG_SMSC_PHY) += smsc.o +obj-$(CONFIG_SMSC_LAN9303) += lan9303.o obj-$(CONFIG_STE10XP) += ste10Xp.o obj-$(CONFIG_TERANET
[PATCH 4/4] net: dsa: LAN9303: add MDIO managed mode support
When the LAN9303 device is in MDIO manged mode, all register accesse must be done via MDIO. Please note: this code is *untested* yet due to the absence of such configured hardware. It is based on a patch of Stefan Roese from 2014. Signed-off-by: Juergen Borleis --- .../devicetree/bindings/net/dsa/lan9303.txt| 4 + drivers/net/phy/Kconfig| 8 ++ drivers/net/phy/Makefile | 1 + drivers/net/phy/lan9303_mdio.c | 144 + 4 files changed, 157 insertions(+) create mode 100644 drivers/net/phy/lan9303_mdio.c diff --git a/Documentation/devicetree/bindings/net/dsa/lan9303.txt b/Documentation/devicetree/bindings/net/dsa/lan9303.txt index 2c8a466065a27..fa2672400cd58 100644 --- a/Documentation/devicetree/bindings/net/dsa/lan9303.txt +++ b/Documentation/devicetree/bindings/net/dsa/lan9303.txt @@ -72,3 +72,7 @@ I2C managed mode: }; }; }; + +MDIO managed mode: + + *TODO* diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index acbc73adbf8c3..dfff1794d4f7d 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -362,3 +362,11 @@ config SMSC_LAN9303_I2C help Provide access functions if the SMSC LAN9303 is configured for I2C managed mode. + +config SMSC_LAN9303_MDIO + bool "MDIO managed mode" + depends on SMSC_LAN9303 + depends on OF_MDIO + help + Provide access functions if the SMSC LAN9303 is configured for MDIO + managed mode. diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 4313adec2e8b6..30a528e084ea5 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile @@ -9,6 +9,7 @@ obj-$(CONFIG_PHYLIB)+= libphy.o lan9303-objs-y := lan9303-core.o lan9303-objs-$(CONFIG_SMSC_LAN9303_I2C) += lan9303_i2c.o +lan9303-objs-$(CONFIG_SMSC_LAN9303_MDIO) += lan9303_mdio.o lan9303-objs := $(lan9303-objs-y) obj-$(CONFIG_MDIO_BCM_IPROC) += mdio-bcm-iproc.o diff --git a/drivers/net/phy/lan9303_mdio.c b/drivers/net/phy/lan9303_mdio.c new file mode 100644 index 0..8230b4e215f42 --- /dev/null +++ b/drivers/net/phy/lan9303_mdio.c @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2017 Pengutronix, Juergen Borleis + * + * Partially based on a patch from + * Copyright (c) 2014 Stefan Roese + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include +#include +#include +#include + +#include "lan9303.h" + +/* Generate phy-addr and -reg from the input address */ +#define PHY_ADDR(x) x) >> 6) + 0x10) & 0x1f) +#define PHY_REG(x) (((x) >> 1) & 0x1f) + +struct lan9303_mdio { + struct mdio_device *device; + struct lan9303 chip; +}; + +static void lan9303_mdio_real_write(struct mdio_device *mdio, int reg, u16 val) +{ + mdio->bus->write(mdio->bus, PHY_ADDR(reg), PHY_REG(reg), val); +} + +static int lan9303_mdio_write(void *ctx, uint32_t reg, uint32_t val) +{ + struct lan9303_mdio *sw_dev = (struct lan9303_mdio *)ctx; + + mutex_lock(&sw_dev->device->bus->mdio_lock); + lan9303_mdio_real_write(sw_dev->device, reg, val & 0x); + lan9303_mdio_real_write(sw_dev->device, reg + 2, (val >> 16) & 0x); + mutex_unlock(&sw_dev->device->bus->mdio_lock); + + return 0; +} + +static u16 lan9303_mdio_real_read(struct mdio_device *mdio, int reg) +{ + return mdio->bus->read(mdio->bus, PHY_ADDR(reg), PHY_REG(reg)); +} + +static int lan9303_mdio_read(void *ctx, uint32_t reg, uint32_t *val) +{ + struct lan9303_mdio *sw_dev = (struct lan9303_mdio *)ctx; + + mutex_lock(&sw_dev->device->bus->mdio_lock); + *val = lan9303_mdio_real_read(sw_dev->device, reg); + *val |= (lan9303_mdio_real_read(sw_dev->device, reg + 2) << 16); + mutex_unlock(&sw_dev->device->bus->mdio_lock); + + return 0; +} + +static const struct regmap_config lan9303_mdio_regmap_config = { + .reg_bits = 8, + .val_bits = 32, + .reg_stride = 1, + .can_multi_write = true, + .max_register = 0x0ff, /* address bits 0..1 are not used */ + .reg_format_endian = REGMAP_ENDIAN_LITTLE, + + .volatile_table = &lan9303_register_set, + .wr_table = &lan9303_register_set, + .rd_table = &lan9303_register_set, + + .reg_read = lan9303_mdio_read, + .reg_write = lan9303_mdio_write, + + .cache_type = REGCACHE_NONE, +}; + +static int lan9303_mdio_probe(struct mdio_device *mdiodev) +{ + struct lan9303_mdio *sw_dev; + int ret; + +
[PATCH 2/4] net: dsa: add new DSA switch driver for the SMSC-LAN9303
The SMSC/Microchip LAN9303 is an ethernet switch device with one CPU port and two external ethernet ports with built-in phys. This driver uses the DSA framework, but is currently only capable of separating the two external ports. There is no offload support yet. Signed-off-by: Juergen Borleis --- drivers/net/phy/lan9303-core.c | 924 + drivers/net/phy/lan9303.h | 21 + 2 files changed, 945 insertions(+) create mode 100644 drivers/net/phy/lan9303-core.c create mode 100644 drivers/net/phy/lan9303.h diff --git a/drivers/net/phy/lan9303-core.c b/drivers/net/phy/lan9303-core.c new file mode 100644 index 0..1c4698f0e13dc --- /dev/null +++ b/drivers/net/phy/lan9303-core.c @@ -0,0 +1,924 @@ +/* + * Copyright (C) 2017 Pengutronix, Juergen Borleis + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#include +#include +#include +#include +#include + +#include "lan9303.h" + +#define LAN9303_CHIP_REV 0x14 +#define LAN9303_IRQ_CFG 0x15 +# define LAN9303_IRQ_CFG_IRQ_ENABLE BIT(8) +# define LAN9303_IRQ_CFG_IRQ_POL BIT(4) +# define LAN9303_IRQ_CFG_IRQ_TYPE BIT(0) +#define LAN9303_INT_STS 0x16 +# define LAN9303_INT_STS_PHY_INT2 BIT(27) +# define LAN9303_INT_STS_PHY_INT1 BIT(26) +#define LAN9303_INT_EN 0x17 +# define LAN9303_INT_EN_PHY_INT2_EN BIT(27) +# define LAN9303_INT_EN_PHY_INT1_EN BIT(26) +#define LAN9303_HW_CFG 0x1D +# define LAN9303_HW_CFG_READY BIT(27) +# define LAN9303_HW_CFG_AMDX_EN_PORT2 BIT(26) +# define LAN9303_HW_CFG_AMDX_EN_PORT1 BIT(25) +#define LAN9303_PMI_DATA 0x29 +#define LAN9303_PMI_ACCESS 0x2A +# define LAN9303_PMI_ACCESS_MII_BUSY BIT(0) +# define LAN9303_PMI_ACCESS_MII_WRITE BIT(1) +#define LAN9303_MANUAL_FC_1 0x68 +#define LAN9303_MANUAL_FC_2 0x69 +#define LAN9303_MANUAL_FC_0 0x6a +#define LAN9303_SWITCH_CSR_DATA 0x6b +#define LAN9303_SWITCH_CSR_CMD 0x6c +#define LAN9303_SWITCH_CSR_CMD_BUSY BIT(31) +#define LAN9303_SWITCH_CSR_CMD_RW BIT(30) +#define LAN9303_SWITCH_CSR_CMD_LANES (BIT(19) | BIT(18) | BIT(17) | BIT(16)) +#define LAN9303_VIRT_PHY_BASE 0x70 +#define LAN9303_VIRT_SPECIAL_CTRL 0x77 + +#define LAN9303_SW_DEV_ID 0x +#define LAN9303_SW_RESET 0x0001 +#define LAN9303_SW_RESET_RESET BIT(0) +#define LAN9303_SW_IMR 0x0004 +#define LAN9303_SW_IPR 0x0005 +#define LAN9303_MAC_VER_ID_0 0x0400 +#define LAN9303_MAC_RX_CFG_0 0x0401 +#define LAN9303_MAC_RX_UNDSZE_CNT_0 0x0410 +#define LAN9303_MAC_RX_64_CNT_0 0x0411 +#define LAN9303_MAC_RX_127_CNT_0 0x0412 +#define LAN9303_MAC_RX_255_CNT_0 0x413 +#define LAN9303_MAC_RX_511_CNT_0 0x0414 +#define LAN9303_MAC_RX_1023_CNT_0 0x0415 +#define LAN9303_MAC_RX_MAX_CNT_0 0x0416 +#define LAN9303_MAC_RX_OVRSZE_CNT_0 0x0417 +#define LAN9303_MAC_RX_PKTOK_CNT_0 0x0418 +#define LAN9303_MAC_RX_CRCERR_CNT_0 0x0419 +#define LAN9303_MAC_RX_MULCST_CNT_0 0x041a +#define LAN9303_MAC_RX_BRDCST_CNT_0 0x041b +#define LAN9303_MAC_RX_PAUSE_CNT_0 0x041c +#define LAN9303_MAC_RX_FRAG_CNT_0 0x041d +#define LAN9303_MAC_RX_JABB_CNT_0 0x041e +#define LAN9303_MAC_RX_ALIGN_CNT_0 0x041f +#define LAN9303_MAC_RX_PKTLEN_CNT_0 0x0420 +#define LAN9303_MAC_RX_GOODPKTLEN_CNT_0 0x0421 +#define LAN9303_MAC_RX_SYMBL_CNT_0 0x0422 +#define LAN9303_MAC_RX_CTLFRM_CNT_0 0x0423 + +#define LAN9303_MAC_TX_CFG_0 0x0440 +#define LAN9303_MAC_TX_DEFER_CNT_0 0x0451 +#define LAN9303_MAC_TX_PAUSE_CNT_0 0x0452 +#define LAN9303_MAC_TX_PKTOK_CNT_0 0x0453 +#define LAN9303_MAC_TX_64_CNT_0 0x0454 +#define LAN9303_MAC_TX_127_CNT_0 0x0455 +#define LAN9303_MAC_TX_255_CNT_0 0x0456 +#define LAN9303_MAC_TX_511_CNT_0 0x0457 +#define LAN9303_MAC_TX_1023_CNT_0 0x0458 +#define LAN9303_MAC_TX_MAX_CNT_0 0x0459 +#define LAN9303_MAC_TX_UNDSZE_CNT_0 0x045a +#define LAN9303_MAC_TX_PKTLEN_CNT_0 0x045c +#define LAN9303_MAC_TX_BRDCST_CNT_0 0x045d +#define LAN9303_MAC_TX_MULCST_CNT_0 0x045e +#define LAN9303_MAC_TX_LATECOL_0 0x045f +#define LAN9303_MAC_TX_EXCOL_CNT_0 0x0460 +#define LAN9303_MAC_TX_SNGLECOL_CNT_0 0x0461 +#define LAN9303_MAC_TX_MULTICOL_CNT_0 0x0462 +#define LAN9303_MAC_TX_TOTALCOL_CNT_0 0x0463 + +#define LAN9303_MAC_VER_ID_1 0x0800 +#define LAN9303_MAC_RX_CFG_1 0x0801 +#define LAN9303_MAC_TX_CFG_1 0x0840 +#define LAN9303_MAC_VER_ID_2 0x0c00 +#define LAN9303_MAC_RX_CFG_2 0x0c01 +#define LAN9303_MAC_TX_CFG_2 0x0c40 +#define LAN9303_SWE_ALR_CMD 0x1800 +#define LAN9303_SWE_VLAN_CMD 0x180b +# define LAN9303_SWE_VLAN_CMD_RNW BIT(5) +# define LAN9303_SWE_VLAN_CMD_PVIDNVLAN BIT(4) +#define LAN9303_SWE_VLAN_WR_DATA 0x180c +#define LAN9303_SWE_VLAN_RD_DATA 0x180e +# define LAN9303_SWE_VLAN_MEMBER_PORT2 BIT(17) +# define LAN9303_SWE_VLAN_UNTAG_PORT2 BIT(16) +# define
Re: [PATCH 1/7] Documentation: dt: net: Update the ath9k binding for SoC devices
Alban writes: > The current binding only cover PCI devices so extend it for SoC devices. > > Most SoC platforms use an MTD partition for the calibration data > instead of an EEPROM. The qca,no-eeprom property was added to allow > loading the EEPROM content using firmware loading. This new binding > replace this hack with NVMEM cells, so we also mark the qca,no-eeprom > property as deprecated in case anyone ever used it. A patchset like this should definitely have a cover letter and explain the backround and reasoning for this patchset. Currently I'm just guessing. > Signed-off-by: Alban Please use your full name both in From and S-o-b lines. -- Kalle Valo
Re: [PATCH 16/16] drivers, net, intersil: convert request_context.refcount from atomic_t to refcount_t
"Reshetova, Elena" writes: >> Elena Reshetova writes: >> >> > refcount_t type and corresponding API should be >> > used instead of atomic_t when the variable is used as >> > a reference counter. This allows to avoid accidental >> > refcounter overflows that might lead to use-after-free >> > situations. >> > >> > Signed-off-by: Elena Reshetova >> > Signed-off-by: Hans Liljestrand >> > Signed-off-by: Kees Cook >> > Signed-off-by: David Windsor >> > --- >> > drivers/net/wireless/intersil/orinoco/orinoco_usb.c | 15 --- >> > 1 file changed, 8 insertions(+), 7 deletions(-) >> >> The prefix should be "orinoco_usb:", I'll fix that. > > Thanks for both! Will you take the patches in? You mean patches 15 and 16? I didn't even look rest of the patches. But not sure yet because Dave doesn't seem to like the interface and I want to follow the discussion first. -- Kalle Valo
Re: net/sctp: list double add warning in sctp_endpoint_add_asoc
On Wed, Apr 5, 2017 at 5:14 AM, Marcelo Ricardo Leitner wrote: > On Wed, Apr 05, 2017 at 01:29:19AM +0800, Xin Long wrote: >> On Tue, Apr 4, 2017 at 9:28 PM, Andrey Konovalov >> wrote: >> > Hi, >> > >> > I've got the following error report while fuzzing the kernel with >> > syzkaller. >> > >> > On commit a71c9a1c779f2499fb2afc0553e543f18aff6edf (4.11-rc5). >> > >> > A reproducer and .config are attached. >> The script is pretty hard to reproduce the issue in my env. > > I didn't try running it but I also found the reproducer very complicated > to follow. Do you have any plans on having some PoC optimizer, so we can > have a more readable code? > strace is handy for filtering the noise, yes, but sometimes it doesn't > cut it. I got the script now: 1. create sk 2. set sk->sndbuf = x 3. sendmsg with size s1 (s1 < x) 4. sendmsg with size s2 (s1+s2 > x) 5. sendmsg with size s3 (wspace < 0), wait sndbuf, schedule out. 6. listen sk (abnormal operation on sctp client) 7. accept sk. In step 6, sk->sk_state = listening, then step 7 could get the first asoc from ep->asoc_list and alloc a new sk2, attach the asoc to sk2. after a while, sendmsg schedule in, but asoc->sk is sk2, !=sk. the same issue we fix for peeloff on commit dfcb9f4f99f1 ("sctp: deny peeloff operation on asocs with threads sleeping on it") happens. But we should not fix it by the same way as for peeloff. the real reason causes this issue is on step 6, it should disallow listen on the established sk. The following fix should work for this, just similar with what inet_listen() did. @@ -7174,6 +7175,9 @@ int sctp_inet_listen(struct socket *sock, int backlog) if (sock->state != SS_UNCONNECTED) goto out; + if (!sctp_sstate(sk, LISTENING) && !sctp_sstate(sk,CLOSED)) + goto out; + what do you think ?
Re: [PATCH 1/4] mm: prevent potential recursive reclaim due to clearing PF_MEMALLOC
On Wed 05-04-17 09:46:57, Vlastimil Babka wrote: > The function __alloc_pages_direct_compact() sets PF_MEMALLOC to prevent > deadlock during page migration by lock_page() (see the comment in > __unmap_and_move()). Then it unconditionally clears the flag, which can clear > a > pre-existing PF_MEMALLOC flag and result in recursive reclaim. This was not a > problem until commit a8161d1ed609 ("mm, page_alloc: restructure direct > compaction handling in slowpath"), because direct compation was called only > after direct reclaim, which was skipped when PF_MEMALLOC flag was set. > > Even now it's only a theoretical issue, as the new callsite of > __alloc_pages_direct_compact() is reached only for costly orders and when > gfp_pfmemalloc_allowed() is true, which means either __GFP_NOMEMALLOC is in > gfp_flags or in_interrupt() is true. There is no such known context, but let's > play it safe and make __alloc_pages_direct_compact() robust for cases where > PF_MEMALLOC is already set. > > Fixes: a8161d1ed609 ("mm, page_alloc: restructure direct compaction handling > in slowpath") > Reported-by: Andrey Ryabinin > Signed-off-by: Vlastimil Babka > Cc: Acked-by: Michal Hocko > --- > mm/page_alloc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3589f8be53be..b84e6ffbe756 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3288,6 +3288,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned > int order, > enum compact_priority prio, enum compact_result *compact_result) > { > struct page *page; > + unsigned int noreclaim_flag = current->flags & PF_MEMALLOC; > > if (!order) > return NULL; > @@ -3295,7 +3296,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned > int order, > current->flags |= PF_MEMALLOC; > *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac, > prio); > - current->flags &= ~PF_MEMALLOC; > + current->flags = (current->flags & ~PF_MEMALLOC) | noreclaim_flag; > > if (*compact_result <= COMPACT_INACTIVE) > return NULL; > -- > 2.12.2 -- Michal Hocko SUSE Labs
Re: [PATCH 3/4] treewide: convert PF_MEMALLOC manipulations to new helpers
On Wed 05-04-17 09:46:59, Vlastimil Babka wrote: > We now have memalloc_noreclaim_{save,restore} helpers for robust setting and > clearing of PF_MEMALLOC. Let's convert the code which was using the generic > tsk_restore_flags(). No functional change. It would be really great to revisit why those places outside of the mm proper really need this flag. I know this is a painful exercise but I wouldn't be surprised if there were abusers there. > Signed-off-by: Vlastimil Babka > Cc: Josef Bacik > Cc: Lee Duncan > Cc: Chris Leech > Cc: "David S. Miller" > Cc: Eric Dumazet Acked-by: Michal Hocko > --- > drivers/block/nbd.c | 7 --- > drivers/scsi/iscsi_tcp.c | 7 --- > net/core/dev.c | 7 --- > net/core/sock.c | 7 --- > 4 files changed, 16 insertions(+), 12 deletions(-) > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > index 03ae72985c79..929fc548c7fb 100644 > --- a/drivers/block/nbd.c > +++ b/drivers/block/nbd.c > @@ -18,6 +18,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -210,7 +211,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, > int send, > struct socket *sock = nbd->socks[index]->sock; > int result; > struct msghdr msg; > - unsigned long pflags = current->flags; > + unsigned int noreclaim_flag; > > if (unlikely(!sock)) { > dev_err_ratelimited(disk_to_dev(nbd->disk), > @@ -221,7 +222,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, > int send, > > msg.msg_iter = *iter; > > - current->flags |= PF_MEMALLOC; > + noreclaim_flag = memalloc_noreclaim_save(); > do { > sock->sk->sk_allocation = GFP_NOIO | __GFP_MEMALLOC; > msg.msg_name = NULL; > @@ -244,7 +245,7 @@ static int sock_xmit(struct nbd_device *nbd, int index, > int send, > *sent += result; > } while (msg_data_left(&msg)); > > - tsk_restore_flags(current, pflags, PF_MEMALLOC); > + memalloc_noreclaim_restore(noreclaim_flag); > > return result; > } > diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c > index 4228aba1f654..4842fc0e809d 100644 > --- a/drivers/scsi/iscsi_tcp.c > +++ b/drivers/scsi/iscsi_tcp.c > @@ -30,6 +30,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -371,10 +372,10 @@ static inline int iscsi_sw_tcp_xmit_qlen(struct > iscsi_conn *conn) > static int iscsi_sw_tcp_pdu_xmit(struct iscsi_task *task) > { > struct iscsi_conn *conn = task->conn; > - unsigned long pflags = current->flags; > + unsigned int noreclaim_flag; > int rc = 0; > > - current->flags |= PF_MEMALLOC; > + noreclaim_flag = memalloc_noreclaim_save(); > > while (iscsi_sw_tcp_xmit_qlen(conn)) { > rc = iscsi_sw_tcp_xmit(conn); > @@ -387,7 +388,7 @@ static int iscsi_sw_tcp_pdu_xmit(struct iscsi_task *task) > rc = 0; > } > > - tsk_restore_flags(current, pflags, PF_MEMALLOC); > + memalloc_noreclaim_restore(noreclaim_flag); > return rc; > } > > diff --git a/net/core/dev.c b/net/core/dev.c > index fde8b3f7136b..e0705a126b24 100644 > --- a/net/core/dev.c > +++ b/net/core/dev.c > @@ -81,6 +81,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -4227,7 +4228,7 @@ static int __netif_receive_skb(struct sk_buff *skb) > int ret; > > if (sk_memalloc_socks() && skb_pfmemalloc(skb)) { > - unsigned long pflags = current->flags; > + unsigned int noreclaim_flag; > > /* >* PFMEMALLOC skbs are special, they should > @@ -4238,9 +4239,9 @@ static int __netif_receive_skb(struct sk_buff *skb) >* Use PF_MEMALLOC as this saves us from propagating the > allocation >* context down to all allocation sites. >*/ > - current->flags |= PF_MEMALLOC; > + noreclaim_flag = memalloc_noreclaim_save(); > ret = __netif_receive_skb_core(skb, true); > - tsk_restore_flags(current, pflags, PF_MEMALLOC); > + memalloc_noreclaim_restore(noreclaim_flag); > } else > ret = __netif_receive_skb_core(skb, false); > > diff --git a/net/core/sock.c b/net/core/sock.c > index 392f9b6f96e2..0b2d06b4c308 100644 > --- a/net/core/sock.c > +++ b/net/core/sock.c > @@ -102,6 +102,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -372,14 +373,14 @@ EXPORT_SYMBOL_GPL(sk_clear_memalloc); > int __sk_backlog_rcv(struct sock *sk, struct sk_buff *skb) > { > int ret; > - unsigned long pflags = current->flags; > + unsigned int noreclaim_flag; > > /* these should have been dropped before queueing */ > BUG_ON(!sock_flag(sk, SOCK_MEMALLOC)); > > - current->flags |= PF_MEMALLOC; > +
Re: [PATCH 2/4] mm: introduce memalloc_noreclaim_{save,restore}
On Wed 05-04-17 09:46:58, Vlastimil Babka wrote: > The previous patch has shown that simply setting and clearing PF_MEMALLOC in > current->flags can result in wrongly clearing a pre-existing PF_MEMALLOC flag > and potentially lead to recursive reclaim. Let's introduce helpers that > support > proper nesting by saving the previous stat of the flag, similar to the > existing > memalloc_noio_* and memalloc_nofs_* helpers. Convert existing setting/clearing > of PF_MEMALLOC within mm to the new helpers. > > There are no known issues with the converted code, but the change makes it > more > robust. > > Suggested-by: Michal Hocko > Signed-off-by: Vlastimil Babka One could argue that tsk_restore_flags() could be extended to provide tsk_set_flags() and use it for all allocation related PF flags. I do not have a strong opinion on that but explicit API sounds a bit better to me because is easier to follow (at least for me). If others think that generic API would be better then I won't have any objections. Anyway this looks good to me. Acked-by: Michal Hocko > --- > include/linux/sched/mm.h | 12 > mm/page_alloc.c | 11 ++- > mm/vmscan.c | 17 +++-- > 3 files changed, 29 insertions(+), 11 deletions(-) > > diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h > index 9daabe138c99..2b24a6974847 100644 > --- a/include/linux/sched/mm.h > +++ b/include/linux/sched/mm.h > @@ -191,4 +191,16 @@ static inline void memalloc_nofs_restore(unsigned int > flags) > current->flags = (current->flags & ~PF_MEMALLOC_NOFS) | flags; > } > > +static inline unsigned int memalloc_noreclaim_save(void) > +{ > + unsigned int flags = current->flags & PF_MEMALLOC; > + current->flags |= PF_MEMALLOC; > + return flags; > +} > + > +static inline void memalloc_noreclaim_restore(unsigned int flags) > +{ > + current->flags = (current->flags & ~PF_MEMALLOC) | flags; > +} > + > #endif /* _LINUX_SCHED_MM_H */ > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index b84e6ffbe756..037e32dccd7a 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3288,15 +3288,15 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned > int order, > enum compact_priority prio, enum compact_result *compact_result) > { > struct page *page; > - unsigned int noreclaim_flag = current->flags & PF_MEMALLOC; > + unsigned int noreclaim_flag; > > if (!order) > return NULL; > > - current->flags |= PF_MEMALLOC; > + noreclaim_flag = memalloc_noreclaim_save(); > *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac, > prio); > - current->flags = (current->flags & ~PF_MEMALLOC) | noreclaim_flag; > + memalloc_noreclaim_restore(noreclaim_flag); > > if (*compact_result <= COMPACT_INACTIVE) > return NULL; > @@ -3443,12 +3443,13 @@ __perform_reclaim(gfp_t gfp_mask, unsigned int order, > { > struct reclaim_state reclaim_state; > int progress; > + unsigned int noreclaim_flag; > > cond_resched(); > > /* We now go into synchronous reclaim */ > cpuset_memory_pressure_bump(); > - current->flags |= PF_MEMALLOC; > + noreclaim_flag = memalloc_noreclaim_save(); > lockdep_set_current_reclaim_state(gfp_mask); > reclaim_state.reclaimed_slab = 0; > current->reclaim_state = &reclaim_state; > @@ -3458,7 +3459,7 @@ __perform_reclaim(gfp_t gfp_mask, unsigned int order, > > current->reclaim_state = NULL; > lockdep_clear_current_reclaim_state(); > - current->flags &= ~PF_MEMALLOC; > + memalloc_noreclaim_restore(noreclaim_flag); > > cond_resched(); > > diff --git a/mm/vmscan.c b/mm/vmscan.c > index 58615bb27f2f..ff63b91a0f48 100644 > --- a/mm/vmscan.c > +++ b/mm/vmscan.c > @@ -2992,6 +2992,7 @@ unsigned long try_to_free_mem_cgroup_pages(struct > mem_cgroup *memcg, > struct zonelist *zonelist; > unsigned long nr_reclaimed; > int nid; > + unsigned int noreclaim_flag; > struct scan_control sc = { > .nr_to_reclaim = max(nr_pages, SWAP_CLUSTER_MAX), > .gfp_mask = (current_gfp_context(gfp_mask) & GFP_RECLAIM_MASK) | > @@ -3018,9 +3019,9 @@ unsigned long try_to_free_mem_cgroup_pages(struct > mem_cgroup *memcg, > sc.gfp_mask, > sc.reclaim_idx); > > - current->flags |= PF_MEMALLOC; > + noreclaim_flag = memalloc_noreclaim_save(); > nr_reclaimed = do_try_to_free_pages(zonelist, &sc); > - current->flags &= ~PF_MEMALLOC; > + memalloc_noreclaim_restore(noreclaim_flag); > > trace_mm_vmscan_memcg_reclaim_end(nr_reclaimed); > > @@ -3544,8 +3545,9 @@ unsigned long shrink_all_memory(unsigned long > nr_to_reclaim) > struct zonelist *zonelist = node_zonelist(numa_node
Re: [PATCH 4/4] mtd: nand: nandsim: convert to memalloc_noreclaim_*()
On Wed 05-04-17 09:47:00, Vlastimil Babka wrote: > Nandsim has own functions set_memalloc() and clear_memalloc() for robust > setting and clearing of PF_MEMALLOC. Replace them by the new generic helpers. > No functional change. This one smells like an abuser. Why the hell should read/write path touch memory reserves at all! > > Signed-off-by: Vlastimil Babka > Cc: Boris Brezillon > Cc: Richard Weinberger > --- > drivers/mtd/nand/nandsim.c | 29 + > 1 file changed, 9 insertions(+), 20 deletions(-) > > diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c > index cef818f535ed..03a0d057bf2f 100644 > --- a/drivers/mtd/nand/nandsim.c > +++ b/drivers/mtd/nand/nandsim.c > @@ -40,6 +40,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1368,31 +1369,18 @@ static int get_pages(struct nandsim *ns, struct file > *file, size_t count, loff_t > return 0; > } > > -static int set_memalloc(void) > -{ > - if (current->flags & PF_MEMALLOC) > - return 0; > - current->flags |= PF_MEMALLOC; > - return 1; > -} > - > -static void clear_memalloc(int memalloc) > -{ > - if (memalloc) > - current->flags &= ~PF_MEMALLOC; > -} > - > static ssize_t read_file(struct nandsim *ns, struct file *file, void *buf, > size_t count, loff_t pos) > { > ssize_t tx; > - int err, memalloc; > + int err; > + unsigned int noreclaim_flag; > > err = get_pages(ns, file, count, pos); > if (err) > return err; > - memalloc = set_memalloc(); > + noreclaim_flag = memalloc_noreclaim_save(); > tx = kernel_read(file, pos, buf, count); > - clear_memalloc(memalloc); > + memalloc_noreclaim_restore(noreclaim_flag); > put_pages(ns); > return tx; > } > @@ -1400,14 +1388,15 @@ static ssize_t read_file(struct nandsim *ns, struct > file *file, void *buf, size_ > static ssize_t write_file(struct nandsim *ns, struct file *file, void *buf, > size_t count, loff_t pos) > { > ssize_t tx; > - int err, memalloc; > + int err; > + unsigned int noreclaim_flag; > > err = get_pages(ns, file, count, pos); > if (err) > return err; > - memalloc = set_memalloc(); > + noreclaim_flag = memalloc_noreclaim_save(); > tx = kernel_write(file, buf, count, pos); > - clear_memalloc(memalloc); > + memalloc_noreclaim_restore(noreclaim_flag); > put_pages(ns); > return tx; > } > -- > 2.12.2 -- Michal Hocko SUSE Labs
Re: [PATCH 4/4] mtd: nand: nandsim: convert to memalloc_noreclaim_*()
Michal, Am 05.04.2017 um 13:31 schrieb Michal Hocko: > On Wed 05-04-17 09:47:00, Vlastimil Babka wrote: >> Nandsim has own functions set_memalloc() and clear_memalloc() for robust >> setting and clearing of PF_MEMALLOC. Replace them by the new generic helpers. >> No functional change. > > This one smells like an abuser. Why the hell should read/write path > touch memory reserves at all! Could be. Let's ask Adrian, AFAIK he wrote that code. Adrian, can you please clarify why nandsim needs to play with PF_MEMALLOC? Thanks, //richard
Re: [PATCH 1/4] mm: prevent potential recursive reclaim due to clearing PF_MEMALLOC
On 04/05/2017 10:46 AM, Vlastimil Babka wrote: > The function __alloc_pages_direct_compact() sets PF_MEMALLOC to prevent > deadlock during page migration by lock_page() (see the comment in > __unmap_and_move()). Then it unconditionally clears the flag, which can clear > a > pre-existing PF_MEMALLOC flag and result in recursive reclaim. This was not a > problem until commit a8161d1ed609 ("mm, page_alloc: restructure direct > compaction handling in slowpath"), because direct compation was called only > after direct reclaim, which was skipped when PF_MEMALLOC flag was set. > > Even now it's only a theoretical issue, as the new callsite of > __alloc_pages_direct_compact() is reached only for costly orders and when > gfp_pfmemalloc_allowed() is true, which means either __GFP_NOMEMALLOC is in is false > gfp_flags or in_interrupt() is true. There is no such known context, but let's > play it safe and make __alloc_pages_direct_compact() robust for cases where > PF_MEMALLOC is already set. > > Fixes: a8161d1ed609 ("mm, page_alloc: restructure direct compaction handling > in slowpath") > Reported-by: Andrey Ryabinin > Signed-off-by: Vlastimil Babka > Cc: > --- > mm/page_alloc.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3589f8be53be..b84e6ffbe756 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -3288,6 +3288,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned > int order, > enum compact_priority prio, enum compact_result *compact_result) > { > struct page *page; > + unsigned int noreclaim_flag = current->flags & PF_MEMALLOC; > > if (!order) > return NULL; > @@ -3295,7 +3296,7 @@ __alloc_pages_direct_compact(gfp_t gfp_mask, unsigned > int order, > current->flags |= PF_MEMALLOC; > *compact_result = try_to_compact_pages(gfp_mask, order, alloc_flags, ac, > prio); > - current->flags &= ~PF_MEMALLOC; > + current->flags = (current->flags & ~PF_MEMALLOC) | noreclaim_flag; Perhaps this would look better: tsk_restore_flags(current, noreclaim_flag, PF_MEMALLOC); ? > if (*compact_result <= COMPACT_INACTIVE) > return NULL; >
Re: [PATCH 4/4] mtd: nand: nandsim: convert to memalloc_noreclaim_*()
On 04/05/2017 01:36 PM, Richard Weinberger wrote: > Michal, > > Am 05.04.2017 um 13:31 schrieb Michal Hocko: >> On Wed 05-04-17 09:47:00, Vlastimil Babka wrote: >>> Nandsim has own functions set_memalloc() and clear_memalloc() for robust >>> setting and clearing of PF_MEMALLOC. Replace them by the new generic >>> helpers. >>> No functional change. >> >> This one smells like an abuser. Why the hell should read/write path >> touch memory reserves at all! > > Could be. Let's ask Adrian, AFAIK he wrote that code. > Adrian, can you please clarify why nandsim needs to play with PF_MEMALLOC? I was thinking about it and concluded that since the simulator can be used as a block device where reclaimed pages go to, writing the data out is a memalloc operation. Then reading can be called as part of r-m-w cycle, so reading as well. But it would be great if somebody more knowledgeable confirmed this. > Thanks, > //richard >
[PATCH] batman-adv: Use net_device_stats from struct net_device
Instead of using a private copy of struct net_device_stats in struct batadv_priv, use stats from struct net_device. Signed-off-by: Tobias Klauser --- net/batman-adv/distributed-arp-table.c | 9 + net/batman-adv/soft-interface.c| 2 +- net/batman-adv/types.h | 2 -- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index 1bfd1dbc2feb..936b08ee5b45 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -1002,6 +1002,7 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, bool ret = false; struct batadv_dat_entry *dat_entry = NULL; struct sk_buff *skb_new; + struct net_device *soft_iface = bat_priv->soft_iface; int hdr_size = 0; unsigned short vid; @@ -1046,10 +1047,10 @@ bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv, if (!skb_new) goto out; - skb_new->protocol = eth_type_trans(skb_new, - bat_priv->soft_iface); - bat_priv->stats.rx_packets++; - bat_priv->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size; + skb_new->protocol = eth_type_trans(skb_new, soft_iface); + + soft_iface->stats.rx_packets++; + soft_iface->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size; netif_rx(skb_new); batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n"); diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index d042c99af028..71895c58e6d8 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -140,7 +140,7 @@ static u64 batadv_sum_counter(struct batadv_priv *bat_priv, size_t idx) static struct net_device_stats *batadv_interface_stats(struct net_device *dev) { struct batadv_priv *bat_priv = netdev_priv(dev); - struct net_device_stats *stats = &bat_priv->stats; + struct net_device_stats *stats = &dev->stats; stats->tx_packets = batadv_sum_counter(bat_priv, BATADV_CNT_TX); stats->tx_bytes = batadv_sum_counter(bat_priv, BATADV_CNT_TX_BYTES); diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 246f21b4973b..5c55e48d8941 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h @@ -1000,7 +1000,6 @@ struct batadv_priv_bat_v { * struct batadv_priv - per mesh interface data * @mesh_state: current status of the mesh (inactive/active/deactivating) * @soft_iface: net device which holds this struct as private data - * @stats: structure holding the data for the ndo_get_stats() call * @bat_counters: mesh internal traffic statistic counters (see batadv_counters) * @aggregated_ogms: bool indicating whether OGM aggregation is enabled * @bonding: bool indicating whether traffic bonding is enabled @@ -1055,7 +1054,6 @@ struct batadv_priv_bat_v { struct batadv_priv { atomic_t mesh_state; struct net_device *soft_iface; - struct net_device_stats stats; u64 __percpu *bat_counters; /* Per cpu counters */ atomic_t aggregated_ogms; atomic_t bonding; -- 2.12.2.399.g034667a45805
Re: [PATCH v3 1/3] NFC: trf7970a: add device tree option for 27MHz clock
Hi Geoff, On Wed, Dec 21, 2016 at 11:18:32PM -0500, Geoff Lansberry wrote: > The TRF7970A has configuration options to support hardware designs > which use a 27.12MHz clock. This commit adds a device tree option > 'clock-frequency' to support configuring the this chip for default > 13.56MHz clock or the optional 27.12MHz clock. > > Signed-off-by: Geoff Lansberry > --- > .../devicetree/bindings/net/nfc/trf7970a.txt | 2 + > drivers/nfc/trf7970a.c | 50 > +- > 2 files changed, 41 insertions(+), 11 deletions(-) Patches #1 and #2 applied to nfc-next. I'll wait for you to rework #3 before merging. Cheers, Samuel.
Re: [PATCH 4/4] mtd: nand: nandsim: convert to memalloc_noreclaim_*()
On Wed 05-04-17 13:39:16, Vlastimil Babka wrote: > On 04/05/2017 01:36 PM, Richard Weinberger wrote: > > Michal, > > > > Am 05.04.2017 um 13:31 schrieb Michal Hocko: > >> On Wed 05-04-17 09:47:00, Vlastimil Babka wrote: > >>> Nandsim has own functions set_memalloc() and clear_memalloc() for robust > >>> setting and clearing of PF_MEMALLOC. Replace them by the new generic > >>> helpers. > >>> No functional change. > >> > >> This one smells like an abuser. Why the hell should read/write path > >> touch memory reserves at all! > > > > Could be. Let's ask Adrian, AFAIK he wrote that code. > > Adrian, can you please clarify why nandsim needs to play with PF_MEMALLOC? > > I was thinking about it and concluded that since the simulator can be > used as a block device where reclaimed pages go to, writing the data out > is a memalloc operation. Then reading can be called as part of r-m-w > cycle, so reading as well. But it would be great if somebody more > knowledgeable confirmed this. then this deserves a big fat comment explaining all the details, including how the complete depletion of reserves is prevented. -- Michal Hocko SUSE Labs
[PATCH] usbnet: make sure no NULL pointer is passed through
Coverity reports: ** CID 751368: Null pointer dereferences (FORWARD_NULL) /drivers/net/usb/usbnet.c: 1925 in __usbnet_read_cmd() *** CID 751368: Null pointer dereferences (FORWARD_NULL) /drivers/net/usb/usbnet.c: 1925 in __usbnet_read_cmd() 1919 EXPORT_SYMBOL(usbnet_link_change); 1920 1921 /*-*/ 1922 static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, 1923 u16 value, u16 index, void *data, u16 size) 1924 { >>> CID 751368: Null pointer dereferences (FORWARD_NULL) >>> Assigning: "buf" = "NULL". 1925void *buf = NULL; 1926int err = -ENOMEM; 1927 1928netdev_dbg(dev->net, "usbnet_read_cmd cmd=0x%02x reqtype=%02x" 1929 " value=0x%04x index=0x%04x size=%d\n", 1930 cmd, reqtype, value, index, size); ** CID 751370: Null pointer dereferences (FORWARD_NULL) /drivers/net/usb/usbnet.c: 1952 in __usbnet_write_cmd() *** CID 751370: Null pointer dereferences (FORWARD_NULL) /drivers/net/usb/usbnet.c: 1952 in __usbnet_write_cmd() 1946 } 1947 1948 static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, 1949 u16 value, u16 index, const void *data, 1950 u16 size) 1951 { >>> CID 751370: Null pointer dereferences (FORWARD_NULL) >>> Assigning: "buf" = "NULL". 1952void *buf = NULL; 1953int err = -ENOMEM; 1954 1955netdev_dbg(dev->net, "usbnet_write_cmd cmd=0x%02x reqtype=%02x" 1956 " value=0x%04x index=0x%04x size=%d\n", 1957 cmd, reqtype, value, index, size); ** CID 1325026: Null pointer dereferences (FORWARD_NULL) /drivers/net/usb/ch9200.c: 143 in control_write() It is valid to offer commands without a buffer, but then you need a size of zero. This should actually be checked. Signed-off-by: Oliver Neukum --- drivers/net/usb/usbnet.c | 19 +++ 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 3de65ea..4532448 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1929,7 +1929,7 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, " value=0x%04x index=0x%04x size=%d\n", cmd, reqtype, value, index, size); - if (data) { + if (size) { buf = kmalloc(size, GFP_KERNEL); if (!buf) goto out; @@ -1938,8 +1938,13 @@ static int __usbnet_read_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, err = usb_control_msg(dev->udev, usb_rcvctrlpipe(dev->udev, 0), cmd, reqtype, value, index, buf, size, USB_CTRL_GET_TIMEOUT); - if (err > 0 && err <= size) - memcpy(data, buf, err); + if (err > 0 && err <= size) { +if (data) +memcpy(data, buf, err); +else +netdev_dbg(dev->net, +"Huh? Data requested but thrown away.\n"); +} kfree(buf); out: return err; @@ -1960,7 +1965,13 @@ static int __usbnet_write_cmd(struct usbnet *dev, u8 cmd, u8 reqtype, buf = kmemdup(data, size, GFP_KERNEL); if (!buf) goto out; - } + } else { +if (size) { +WARN_ON_ONCE(1); +err = -EINVAL; +goto out; +} +} err = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), cmd, reqtype, value, index, buf, size, -- 2.10.2
Re: [iproute2 net-next v2 0/3] ip netconf improvements
On 4/4/17 5:39 PM, Stephen Hemminger wrote: > On Tue, 4 Apr 2017 17:07:31 -0400 > David Ahern wrote: > >> On 3/23/17 10:51 PM, David Ahern wrote: >>> Currently, ip netconf only shows data for ipv4 and ipv6 for dumps >>> and just ipv4 for device requests. Improve the user experience by >>> using the new kernel patch to dump all address families that have >>> registered. For example, if mpls_router module is loaded then mpls >>> values are displayed along with ipv4 and ipv6. >>> >>> If the new feature is not supported (new iproute2 on older kernel) >>> the kernel returns the nlmsg error EOPNOTSUPP which can be trapped >>> and fallback to existing behavior. >>> >>> v2 >>> - fixed index conversion in patch 3 per nicholas' comment >>> >>> David Ahern (3): >>> netlink: Add flag to suppress print of nlmsg error >>> ip netconf: Show all address families by default in dumps >>> ip netconf: show all families on dev request >>> >>> include/libnetlink.h | 1 + >>> ip/ipnetconf.c | 36 +--- >>> lib/libnetlink.c | 3 ++- >>> 3 files changed, 28 insertions(+), 12 deletions(-) >>> >> >> Hi Stephen: any comments? are you ok with this change? > > I was holding off until all the upstream commits went through. Other than > that fine. > I'm not aware of any kernel commits that not in net-next, so I think we good to go on the kernel side.
[PATCH] qed: fix missing break in OOO_LB_TC case
From: Colin Ian King There seems to be a missing break on the OOO_LB_TC case, pq_id is being assigned and then re-assigned on the fall through default case and that seems suspect. Detected by CoverityScan, CID#1424402 ("Missing break in switch") Fixes: b5a9ee7cf3be1 ("qed: Revise QM cofiguration") Signed-off-by: Colin Ian King --- drivers/net/ethernet/qlogic/qed/qed_ll2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/qlogic/qed/qed_ll2.c b/drivers/net/ethernet/qlogic/qed/qed_ll2.c index 708c601e8ccf..13e65d446ab3 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_ll2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_ll2.c @@ -1132,6 +1132,7 @@ static int qed_sp_ll2_tx_queue_start(struct qed_hwfn *p_hwfn, break; case OOO_LB_TC: pq_id = qed_get_cm_pq_idx(p_hwfn, PQ_FLAGS_OOO); + break; default: pq_id = qed_get_cm_pq_idx(p_hwfn, PQ_FLAGS_OFLD); break; -- 2.11.0
Re: net/sctp: list double add warning in sctp_endpoint_add_asoc
On Wed, Apr 05, 2017 at 06:48:45PM +0800, Xin Long wrote: > On Wed, Apr 5, 2017 at 5:14 AM, Marcelo Ricardo Leitner > wrote: > > On Wed, Apr 05, 2017 at 01:29:19AM +0800, Xin Long wrote: > >> On Tue, Apr 4, 2017 at 9:28 PM, Andrey Konovalov > >> wrote: > >> > Hi, > >> > > >> > I've got the following error report while fuzzing the kernel with > >> > syzkaller. > >> > > >> > On commit a71c9a1c779f2499fb2afc0553e543f18aff6edf (4.11-rc5). > >> > > >> > A reproducer and .config are attached. > >> The script is pretty hard to reproduce the issue in my env. > > > > I didn't try running it but I also found the reproducer very complicated > > to follow. Do you have any plans on having some PoC optimizer, so we can > > have a more readable code? > > strace is handy for filtering the noise, yes, but sometimes it doesn't > > cut it. > I got the script now: > 1. create sk > 2. set sk->sndbuf = x > 3. sendmsg with size s1 (s1 < x) > 4. sendmsg with size s2 (s1+s2 > x) > 5. sendmsg with size s3 (wspace < 0), wait sndbuf, schedule out. > 6. listen sk (abnormal operation on sctp client) > 7. accept sk. > > In step 6, sk->sk_state = listening, then step 7 could get the first asoc > from ep->asoc_list and alloc a new sk2, attach the asoc to sk2. > > after a while, sendmsg schedule in, but asoc->sk is sk2, !=sk. > the same issue we fix for peeloff on commit dfcb9f4f99f1 ("sctp: deny > peeloff operation on asocs with threads sleeping on it") happens. Yes. That explains why the asoc isn't dead by when sendmsg comes back, and avoid that dead check. > > But we should not fix it by the same way as for peeloff. the real reason > causes this issue is on step 6, it should disallow listen on the established > sk. Agreed. > > The following fix should work for this, just similar with what > inet_listen() did. > > @@ -7174,6 +7175,9 @@ int sctp_inet_listen(struct socket *sock, int backlog) > if (sock->state != SS_UNCONNECTED) > goto out; > > + if (!sctp_sstate(sk, LISTENING) && !sctp_sstate(sk,CLOSED)) > + goto out; > + > > what do you think ? Yes, agreed. Thanks! Marcelo
RE: [PATCH] qed: fix missing break in OOO_LB_TC case
> There seems to be a missing break on the OOO_LB_TC case, pq_id is being > assigned and then re-assigned on the fall through default case and that > seems suspect. > > Detected by CoverityScan, CID#1424402 ("Missing break in switch") > > Fixes: b5a9ee7cf3be1 ("qed: Revise QM cofiguration") > > Signed-off-by: Colin Ian King Thanks! Acked-by: Yuval Mintz
Re: [V2] wlcore: fix spelling mistakes in wl1271_warning
Colin Ian King wrote: > From: Colin Ian King > > trivial fix to spelling mistakes in wl1271_warning error message, change > iligal to invalid and opperation to operation. > > Signed-off-by: Colin Ian King Patch applied to wireless-drivers-next.git, thanks. 5ea807896160 wlcore: fix spelling mistakes in wl1271_warning -- https://patchwork.kernel.org/patch/9659173/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
Re: [PATCH net-next 1/4] ixgbe: sparc: rename the ARCH_WANT_RELAX_ORDER to IXGBE_ALLOW_RELAXED_ORDER
On 02/04/2017 07:49, Ding Tianhong wrote: On 2017/4/2 2:26, David Miller wrote: From: Ding Tianhong Date: Sat, 1 Apr 2017 15:25:51 +0800 Till now only the Intel ixgbe could support enable Relaxed ordering in the drivers for special architecture, but the ARCH_WANT_RELAX_ORDER is looks like a general name for all arch, so rename to a specific name for intel card looks more appropriate. Signed-off-by: Ding Tianhong This is not a driver specific facility. Any driver can test this symbol and act accordingly. Just because IXGBE is the first and only user, doesn't mean the facility is driver specific. Understand clearly,but the ARCH_WANT_RELAX_ORDER is really too generic and simple, cause much misleading to indicate that it looks like the hack code for some architecture. what do you think of the ETHERNET_ALLOW_RELAXED_ORDER in the drivers/net/ethernet/*, it will only affect ethernet and not only for Ixgbe. Hi Ding, I think the actual original config ARCH_WANT_RELAX_ORDER is quite dubious, and it does not really tell us which feature(s) of the architecture supports this (if indeed it is arch specific). According to the original commit, 1a8b6d76dc5b net:add one common config ARCH_WANT_RELAX_ORDER to support relax ordering, this is specific to SPARC only: "Currently it only supports one special cpu architecture(SPARC) in 82599 driver to enable RO feature, this is not very common for other cpu architecture which really needs RO feature". This sounds wooly. So I think that we need to know which specific architecture, memory model, or PCI host/port/EP features, or combination of them, allows this so called relaxed ordering. And a config option is probably not even the proper check. John Thanks Ding Thank you. . .
Re: [PATCH net-next 00/12] bnxt_en: Updates for net-next.
From: Michael Chan Date: Tue, 4 Apr 2017 18:14:05 -0400 > Main changes are to add WoL and selftest features, optimize XDP_TX by > using short BDs, and to cap the usage of MSIX. Series applied, thanks Michael.
Re: [PATCH net-next 1/1] skbuff: Extend gso_type to unsigned int.
From: Steffen Klassert Date: Mon, 3 Apr 2017 10:15:52 +0200 > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 9f78109..8796b93 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -257,7 +257,7 @@ struct sk_buff *__alloc_skb(unsigned int size, gfp_t > gfp_mask, > > /* make sure we initialize shinfo sequentially */ > shinfo = skb_shinfo(skb); > - memset(shinfo, 0, offsetof(struct skb_shared_info, dataref)); > + memset(shinfo, 0, offsetof(struct skb_shared_info, _unused)); > atomic_set(&shinfo->dataref, 1); > kmemcheck_annotate_variable(shinfo->destructor_arg); > There is another memset() that needs this conversion in __build_skb().
Re: [Intel-wired-lan] [next-queue v6 PATCH 2/7] i40e: Introduce Port Representor netdevs and switchdev mode.
On Tue, Apr 4, 2017 at 6:29 PM, Alexander Duyck wrote: > On Tue, Apr 4, 2017 at 4:58 AM, Or Gerlitz wrote: >> I was asking on frames getting in from the uplink and not getting out >> the uplink. > Frames coming from the uplink will by default be routed to the PF. So > are you saying you want a representor for the uplink to handle the > packets that don't have any rules set up for them, correct? In our impl, currently the PF serves the uplink representor when we are in the switchdev mode. > I think we could set something like this up as we do have the concept > of a "default" entity that everything falls back into. It is just a > bit muddled since that current exists as a part of the PF. >> This is about offloading to HW a switching model where the steering >> (matching and actions) comes into play on the port ingress. E.g >> VF NIC xmit ---> VF vport e-switch rep recv --> SW or HW steering > So this bit we can't really support very well with the i40e hardware. > The problem is that unless there is a rule that exists to route it to > another PF/VF there is a default rule in the hardware that would send > it out the uplink port. The only data we can really catch on the port > representors is broadcast/multicast because it does replication. Can't you put a black hole (matching on nothing) rule saying that if source is VF send it to the PF RX queues and not to the wire, from the PF recv descriptor somehow realize from what VF the packet originated and then inject it to the host kernel as it was received from the rep of that VF? Later when you add offloads, you make this rule with the lowest prio. >> other node xmit --> UPLINK vport e-switch rep recv --> SW or HW steering > This part I think we can do. The default behavior would be to send a > packet to the default entity which in this case is the PF. good >> Can you please elaborate on such use-cases, so the bigger picture is more >> clear? > So the main goal with all of this is to support TC offloads so that we > can program filters to route packets from the default entity to the VF. This is somehow too limited and I don't see what use case it can serve :( > I agree that I think we are missing the uplink port. We probably > just need to add it as the "default" handler for packets that > originate with a source MAC address that is not the PF or one of the VFs. > We can discuss this further at netdev/netconf. yeah, but I will not be there (still asked everyone to get me a pack of maple cookies), so feel free to discuss with the MLNX folks, Rony and Jiri Or.
Re: [PATCH] phy/ethtool: Add missing SPEED_ strings
From: Joe Perches Date: Sun, 2 Apr 2017 14:30:06 -0700 > Add all the currently available SPEED_ strings. > > Signed-off-by: Joe Perches I'll apply this for now, thanks.
[PATCH v2] igb: Allow to remove administratively set MAC on VFs
Before libvirt modifies the MAC address and vlan tag for an SRIOV VF for use by a virtual machine (either using vfio device assignment or macvtap passthru mode), it saves the current MAC address and vlan tag so that it can reset them to their original value when the guest is done. Libvirt can't leave the VF MAC set to the value used by the now-defunct guest since it may be started again later using a different VF, but it certainly shouldn't just pick any random value, either. So it saves the state of everything prior to using the VF, and resets it to that. The igb driver initializes the MAC addresses of all VFs to 00:00:00:00:00:00, and reports that when asked (via an RTM_GETLINK netlink message, also visible in the list of VFs in the output of "ip link show"). But when libvirt attempts to restore the MAC address back to 00:00:00:00:00:00 (using an RTM_SETLINK netlink message) the kernel responds with "Invalid argument". Forbidding a reset back to the original value leaves the VF MAC at the value set for the now-defunct virtual machine. Especially on a system with NetworkManager enabled, this has very bad consequences, since NetworkManager forces all interfacess to be IFF_UP all the time - if the same virtual machine is restarted using a different VF (or even on a different host), there will be multiple interfaces watching for traffic with the same MAC address. To allow libvirt to revert to the original state, we need a way to remove the administrative set MAC on a VF, to allow normal host operation again, and to reset/overwrite the VF MAC via VF netdev. This patch implements the outlined scenario by allowing to set the VF MAC to 00:00:00:00:00:00 via RTM_SETLINK on the PF. igb_ndo_set_vf_mac resets the IGB_VF_FLAG_PF_SET_MAC flag to 0, so it's possible to reset the VF MAC back to the original value via the VF netdev. Note: Recent patches to libvirt allow for a workaround if the NIC isn't capable of resetting the administrative MAC back to all 0, but in theory the NIC should allow resetting the MAC in the first place. Signed-off-by: Corinna Vinschen --- drivers/net/ethernet/intel/igb/igb_main.c | 42 +++ 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 26a821f..c7673a2 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -8093,7 +8093,8 @@ static void igb_rar_set_qsel(struct igb_adapter *adapter, u8 *addr, u32 index, rar_high = le16_to_cpup((__le16 *)(addr + 4)); /* Indicate to hardware the Address is Valid. */ - rar_high |= E1000_RAH_AV; + if (is_valid_ether_addr(addr)) + rar_high |= E1000_RAH_AV; if (hw->mac.type == e1000_82575) rar_high |= E1000_RAH_POOL_1 * qsel; @@ -8125,17 +8126,36 @@ static int igb_set_vf_mac(struct igb_adapter *adapter, static int igb_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) { struct igb_adapter *adapter = netdev_priv(netdev); - if (!is_valid_ether_addr(mac) || (vf >= adapter->vfs_allocated_count)) + + if (vf >= adapter->vfs_allocated_count) + return -EINVAL; + + /* Setting the VF MAC to 0 reverts the IGB_VF_FLAG_PF_SET_MAC +* flag and allows to overwrite the MAC via VF netdev. This +* is necessary to allow libvirt a way to restore the original +* MAC after unbinding vfio-pci and reloading igbvf after shutting +* down a VM. +*/ + if (is_zero_ether_addr(mac)) { + adapter->vf_data[vf].flags &= ~IGB_VF_FLAG_PF_SET_MAC; + dev_info(&adapter->pdev->dev, +"remove administratively set MAC on VF %d\n", +vf); + } else if (is_valid_ether_addr (mac)) { + adapter->vf_data[vf].flags |= IGB_VF_FLAG_PF_SET_MAC; + dev_info(&adapter->pdev->dev, "setting MAC %pM on VF %d\n", +mac, vf); + dev_info(&adapter->pdev->dev, +"Reload the VF driver to make this change effective."); + /* Generate additional warning if PF is down */ + if (test_bit(__IGB_DOWN, &adapter->state)) { + dev_warn(&adapter->pdev->dev, +"The VF MAC address has been set, but the PF device is not up.\n"); + dev_warn(&adapter->pdev->dev, +"Bring the PF device up before attempting to use the VF device.\n"); + } + } else { return -EINVAL; - adapter->vf_data[vf].flags |= IGB_VF_FLAG_PF_SET_MAC; - dev_info(&adapter->pdev->dev, "setting MAC %pM on VF %d\n", mac, vf); - dev_info(&adapter->pdev->dev, -"Reload the VF driver to make this chan
Re: [PATCH net-next] macb: Add hardware PTP support.
From: Rafal Ozieblo Date: Mon, 3 Apr 2017 14:10:15 +0100 > This patch is based on original Harini's patch and Andrei's patch, > implemented in aseparate file to ease the review/maintanance > and integration with other platforms. > > In case that macb is compiled as a module, it has been renamed to > cadence-macb.ko to avoid naming confusion in Makefile. > > This driver does support GEM-GXL: > - Enable HW time stamp > - Register ptp clock framework > - Initialize PTP related registers > - Updated dma buffer descriptor read/write mechanism > - HW time stamp on the PTP Ethernet packets are received using the > SO_TIMESTAMPING API. Where timers are obtained from the dma buffer > descriptors > - Added tsu_clk to device tree > > Note: Patch on net-next, on April 3rd. > Signed-off-by: Rafal Ozieblo This patch does too many things at one time. Each entry in that list of changes above should be a separate change, all posted together as a group as a proper patch series. Thank you.
Re: [PATCH net-next] net: stmmac: rx queue to dma channel mapping fix
From: Joao Pinto Date: Mon, 3 Apr 2017 16:34:04 +0100 > In hardware configurations where multiple queues are active, > the rx queue needs to be mapped into a dma channel, even if > a single rx queue is used. > > Signed-off-by: Joao Pinto Applied, thanks.
Re: [PATCH -next] qed: Add a missing error code
From: Dan Carpenter Date: Mon, 3 Apr 2017 21:25:22 +0300 > We should be returning -ENOMEM if qed_mcp_cmd_add_elem() fails. The > current code returns success. > > Fixes: 4ed1eea82a21 ("qed: Revise MFW command locking") > Signed-off-by: Dan Carpenter Applied.
Re: [PATCH -next] liquidio: clear the correct memory
From: Dan Carpenter Date: Mon, 3 Apr 2017 21:18:27 +0300 > There is a cut and paste bug here so we accidentally clear the first > few bytes of "resp" a second time instead clearing "ctx". > > Fixes: 50c0add534d2 ("liquidio: refactor interrupt moderation code") > Signed-off-by: Dan Carpenter Applied.
Re: [PATCH -next] net: sched: choke: remove some dead code
From: Dan Carpenter Date: Mon, 3 Apr 2017 21:18:41 +0300 > We accidentally left this dead code behind after commit 5952fde10c35 > ("net: sched: choke: remove dead filter classify code"). > > Signed-off-by: Dan Carpenter Applied.
Re: ethtool-4.8.tar.gz checksum change
On Mon, Apr 03, 2017 at 11:25:54AM +0100, Paul Barker wrote: > Hi, > > It looks like the checksum of the following file has changed recently: > https://www.kernel.org/pub/software/network/ethtool/ethtool-4.8.tar.gz > > Original checksum from around 23/10/2016: > md5sum = 28c4a4d85c33f573c49ff6d81ec094fd > sha256sum = > 1bd82ebe3d41de1b7b0d8f4fb18a8e8466fba934c952bc5c5002836ffa8bb606 > > Current checksum: > md5sum = 992eab97607c64b7848edfd37f23da22 > sha256sum = > c8ea20b8d85898377ec130066008f9241ebcdd95ac85dbcc2d50b32fe2e2f934 > > Is this change intentional? > > I've spotted this when doing an OpenEmbedded build, it's rejecting the > ethtool-4.8.tar.gz file as corrupted since the checksums do not match those > originally recorded. > > Thanks, > Paul Barker Yes, the .tar.gz file got regenerated locally as I was tinkering with the release scripts that I inherited from the former ethtool maintainer, and the regenerated .tar.gz file got uploaded. The newly updated one is properly signed and the signature is there to verify. (Note that the signature is against the .tar file and not the .tar.gz file.) I downloaded the file from the website and verified against the matching version of the git tree locally as well. If you have any idea as to who is in charge of the OpenEmbedded build and can correct/remove this complaint, then please let me know and/or have them contact me. (Ditto for Yocto builds...) Thanks, John -- John W. LinvilleSomeday the world will need a hero, and you linvi...@tuxdriver.com might be all we have. Be ready.
Re: net/sctp: list double add warning in sctp_endpoint_add_asoc
On Tue, Apr 4, 2017 at 11:14 PM, Marcelo Ricardo Leitner wrote: > On Wed, Apr 05, 2017 at 01:29:19AM +0800, Xin Long wrote: >> On Tue, Apr 4, 2017 at 9:28 PM, Andrey Konovalov >> wrote: >> > Hi, >> > >> > I've got the following error report while fuzzing the kernel with >> > syzkaller. >> > >> > On commit a71c9a1c779f2499fb2afc0553e543f18aff6edf (4.11-rc5). >> > >> > A reproducer and .config are attached. >> The script is pretty hard to reproduce the issue in my env. > > I didn't try running it but I also found the reproducer very complicated > to follow. Do you have any plans on having some PoC optimizer, so we can > have a more readable code? > strace is handy for filtering the noise, yes, but sometimes it doesn't > cut it. We do have some plans (like to remote all those unnecessary helper functions), but it's probably not going to become much better. You mostly only need to look at the thr() function to understand what's going on. What I sometimes do is run each of the switch cases under strace separately to understand what each of them do. I've also attached a program in syzkaller format. You can take a look at it, if you find it useful, I can start attaching them for subsequent reports. > >> But there seems a case to cause a use-after-free when out of snd_buf. >> >> the case is like: >> --- >> one thread: another thread: >> sctp_rcv hold asoc (hold transport) >> enqueue the chunk to backlog queue >> [refcnt=2] >> >> sctp_close free assoc >> [refcnt=1] >> >> sctp_sendmsg find asoc >> but not hold it >> >> out of snd_buf >> hold asoc, schedule out >> [refcnt = 2] >> >> process backlog and put asoc/transport >> [refcnt=1] >> >> schedule in, put asoc >> [refcnt=0] <--- destroyed >> >> sctp_sendmsg continue > > It shouldn't be continuing here because sctp_wait_for_sndbuf and > sctp_wait_for_connect functions are checking if the asoc is dead > already when it schedules in, even though sctp_wait_for_connect return > value is ignored and sctp_sendmsg() simply returns after that. > Or the checks for dead asocs in there aren't enough somehow. > >> using asoc, panic > > > -- > You received this message because you are subscribed to the Google Groups > "syzkaller" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to syzkaller+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. log Description: Binary data
Re: net/sctp: list double add warning in sctp_endpoint_add_asoc
On Wed, Apr 5, 2017 at 2:44 PM, Marcelo Ricardo Leitner wrote: > On Wed, Apr 05, 2017 at 06:48:45PM +0800, Xin Long wrote: >> On Wed, Apr 5, 2017 at 5:14 AM, Marcelo Ricardo Leitner >> wrote: >> > On Wed, Apr 05, 2017 at 01:29:19AM +0800, Xin Long wrote: >> >> On Tue, Apr 4, 2017 at 9:28 PM, Andrey Konovalov >> >> wrote: >> >> > Hi, >> >> > >> >> > I've got the following error report while fuzzing the kernel with >> >> > syzkaller. >> >> > >> >> > On commit a71c9a1c779f2499fb2afc0553e543f18aff6edf (4.11-rc5). >> >> > >> >> > A reproducer and .config are attached. >> >> The script is pretty hard to reproduce the issue in my env. >> > >> > I didn't try running it but I also found the reproducer very complicated >> > to follow. Do you have any plans on having some PoC optimizer, so we can >> > have a more readable code? >> > strace is handy for filtering the noise, yes, but sometimes it doesn't >> > cut it. >> I got the script now: >> 1. create sk >> 2. set sk->sndbuf = x >> 3. sendmsg with size s1 (s1 < x) >> 4. sendmsg with size s2 (s1+s2 > x) >> 5. sendmsg with size s3 (wspace < 0), wait sndbuf, schedule out. >> 6. listen sk (abnormal operation on sctp client) >> 7. accept sk. >> >> In step 6, sk->sk_state = listening, then step 7 could get the first asoc >> from ep->asoc_list and alloc a new sk2, attach the asoc to sk2. >> >> after a while, sendmsg schedule in, but asoc->sk is sk2, !=sk. >> the same issue we fix for peeloff on commit dfcb9f4f99f1 ("sctp: deny >> peeloff operation on asocs with threads sleeping on it") happens. > > Yes. That explains why the asoc isn't dead by when sendmsg comes back, > and avoid that dead check. > >> >> But we should not fix it by the same way as for peeloff. the real reason >> causes this issue is on step 6, it should disallow listen on the established >> sk. > > Agreed. > >> >> The following fix should work for this, just similar with what >> inet_listen() did. >> >> @@ -7174,6 +7175,9 @@ int sctp_inet_listen(struct socket *sock, int backlog) >> if (sock->state != SS_UNCONNECTED) >> goto out; >> >> + if (!sctp_sstate(sk, LISTENING) && !sctp_sstate(sk,CLOSED)) >> + goto out; >> + This fixes the report. Tested-by: Andrey Konovalov Thanks! >> >> what do you think ? > > Yes, agreed. > Thanks! > > Marcelo
Re: [B.A.T.M.A.N.] [PATCH] batman-adv: Use net_device_stats from struct net_device
On Mittwoch, 5. April 2017 13:46:31 CEST Tobias Klauser wrote: > Instead of using a private copy of struct net_device_stats in struct > batadv_priv, use stats from struct net_device. > > Signed-off-by: Tobias Klauser > --- > net/batman-adv/distributed-arp-table.c | 9 + > net/batman-adv/soft-interface.c| 2 +- > net/batman-adv/types.h | 2 -- > 3 files changed, 6 insertions(+), 7 deletions(-) Nice find. I had to look up when the code was introduced and when the common netdev stats member was added. Interestingly, both were from 2007 :) Applied in ab044f8e3eaf84c4cc95d7606fadfdfa006dc8ec [1] Thanks, Sven [1] https://git.open-mesh.org/linux-merge.git/commit/ab044f8e3eaf84c4cc95d7606fadfdfa006dc8ec signature.asc Description: This is a digitally signed message part.
Re: [PATCH net-next] netlink/diag: report flags for netlink sockets
From: Andrei Vagin Date: Mon, 3 Apr 2017 18:13:32 -0700 > From: Andrey Vagin > > cb_running is reported in /proc/self/net/netlink and it is reported by > the ss tool, when it gets information from the proc files. > > sock_diag is a new interface which is used instead of proc files, so it > looks reasonable that this interface has to report no less information > about sockets than proc files. > > We use these flags to dump and restore netlink sockets. > > Signed-off-by: Andrei Vagin Ok, applied, thanks Andrei.
Re: [PATCH next] bonding: fix active-backup transition
From: Mahesh Bandewar Date: Mon, 3 Apr 2017 18:38:39 -0700 > From: Mahesh Bandewar > > Earlier patch c4adfc822bf5 ("bonding: make speed, duplex setting > consistent with link state") made an attempt to keep slave state > consistent with speed and duplex settings. Unfortunately link-state > transition is used to change the active link especially when used > in conjunction with mii-mon. The above mentioned patch broke that > logic. Also when speed and duplex settings for a link are updated > during a link-event, the link-status should not be changed to > invoke correct transition logic. > > This patch fixes this issue by moving the link-state update outside > of the bond_update_speed_duplex() fn and to the places where this fn > is called and update link-state selectively. > > Fixes: c4adfc822bf5 ("bonding: make speed, duplex setting consistent > with link state") > Signed-off-by: Mahesh Bandewar Applied, thanks.
Re: [PATCH rfc 5/6] block: Add rdma affinity based queue mapping helper
On 04/02/2017 07:41 AM, Sagi Grimberg wrote: > Like pci and virtio, we add a rdma helper for affinity > spreading. This achieves optimal mq affinity assignments > according to the underlying rdma device affinity maps. Reviewed-by: Jens Axboe -- Jens Axboe
Re: [PATCH net] sctp: get sock from transport in sctp_transport_update_pmtu
From: Xin Long Date: Tue, 4 Apr 2017 13:39:55 +0800 > This patch is almost to revert commit 02f3d4ce9e81 ("sctp: Adjust PMTU > updates to accomodate route invalidation."). As t->asoc can't be NULL > in sctp_transport_update_pmtu, it could get sk from asoc, and no need > to pass sk into that function. > > It is also to remove some duplicated codes from that function. > > Signed-off-by: Xin Long Applied, thanks.
Re: net/sctp: list double add warning in sctp_endpoint_add_asoc
On Wed, Apr 05, 2017 at 04:02:44PM +0200, Andrey Konovalov wrote: > On Tue, Apr 4, 2017 at 11:14 PM, Marcelo Ricardo Leitner > wrote: > > On Wed, Apr 05, 2017 at 01:29:19AM +0800, Xin Long wrote: > >> On Tue, Apr 4, 2017 at 9:28 PM, Andrey Konovalov > >> wrote: > >> > Hi, > >> > > >> > I've got the following error report while fuzzing the kernel with > >> > syzkaller. > >> > > >> > On commit a71c9a1c779f2499fb2afc0553e543f18aff6edf (4.11-rc5). > >> > > >> > A reproducer and .config are attached. > >> The script is pretty hard to reproduce the issue in my env. > > > > I didn't try running it but I also found the reproducer very complicated > > to follow. Do you have any plans on having some PoC optimizer, so we can > > have a more readable code? > > strace is handy for filtering the noise, yes, but sometimes it doesn't > > cut it. > > We do have some plans (like to remote all those unnecessary helper > functions), but it's probably not going to become much better. > > You mostly only need to look at the thr() function to understand > what's going on. Okay. > > What I sometimes do is run each of the switch cases under strace > separately to understand what each of them do. > > I've also attached a program in syzkaller format. > You can take a look at it, if you find it useful, I can start > attaching them for subsequent reports. Comparing it to thr() they look very close, at least for this one. But when you cannot extract a reproducer, it will certainly help. Thanks, Marcelo
Re: [PATCH] net: ibm: emac: remove unused sysrq handler for 'c' key
From: Eric Biggers Date: Mon, 3 Apr 2017 22:50:20 -0700 > From: Eric Biggers > > Since commit d6580a9f1523 ("kexec: sysrq: simplify sysrq-c handler"), > the sysrq handler for the 'c' key has been sysrq_crash_op. Debugging > code in the ibm_emac driver also tries to register a handler for the 'c' > key, but this has no effect because register_sysrq_key() doesn't replace > existing handlers. Since evidently no one has cared enough to fix this > in the last 8 years, and it's very rare for drivers to register sysrq > handlers (for good reason), just remove the dead code. > > Signed-off-by: Eric Biggers Applied to net-next, thanks.
[PATCH net] l2tp: define SOL_PPPOL2TP in uapi
Userspace needs SOL_PPPOL2TP to be defined for using PPPOL2TP_SO_* socket options. Signed-off-by: Guillaume Nault --- include/uapi/linux/if_pppol2tp.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/uapi/linux/if_pppol2tp.h b/include/uapi/linux/if_pppol2tp.h index 6418c4d10241..90ce1abd2c4b 100644 --- a/include/uapi/linux/if_pppol2tp.h +++ b/include/uapi/linux/if_pppol2tp.h @@ -73,6 +73,8 @@ struct pppol2tpv3in6_addr { struct sockaddr_in6 addr; /* IP address and port to send to */ }; +#define SOL_PPPOL2TP 273 + /* Socket options: * DEBUG - bitmask of debug message categories * SENDSEQ - 0 => don't send packets with sequence numbers -- 2.11.0
Re: [PATCH net-next v2 1/1] net: tcp: Define the TCP_MAX_WSCALE instead of literal number 14
From: gfree.w...@foxmail.com Date: Tue, 4 Apr 2017 21:09:48 +0800 > From: Gao Feng > > Define one new macro TCP_MAX_WSCALE instead of literal number '14', > and use U16_MAX instead of 65535 as the max value of TCP window. > There is another minor change, use rounddown(space, mss) instead of > (space / mss) * mss; > > Signed-off-by: Gao Feng > --- > v2: Correct the literal 14 in comment and log too, per Neal > v1: initial version Applied, thank you.
Re: [PATCH net-next] net: stmmac: allow changing the MTU while the interface is running
From: Niklas Cassel Date: Tue, 4 Apr 2017 14:18:54 +0200 > From: Niklas Cassel > > Setting ethtool ops for stmmac is only allowed when the interface is up. > Setting MTU (a netdev op) for stmmac is only allowed when the interface > is down. > > It seems that the only reason why MTU cannot be changed when running is > that we have not bothered to implement a nice way to dealloc/alloc the > descriptor rings. > > To make it less confusing for the user, call ndo_stop() and ndo_open() > from ndo_change_mtu(). This is not a nice way to dealloc/alloc the > descriptor rings, since it will announce that the interface is being > brought down/up to user space, but there are several other drivers doing > it this way, and it is arguably better than just returning -EBUSY. > > Signed-off-by: Niklas Cassel You can't do this with no error handling. Instead, you must do this using a "prepare", "commit" sequence. First making sure you can reallocate all necessary resources, and make the config change, before actually doing so. You're not even checking if the re-open fails, meaning that an MTU change can cause the interface to shut down. That is simply not acceptable.
Re: [PATCH iproute2] man: fix man page warnings
On Sun, Mar 26, 2017 at 09:11:14PM +0200, Alexander Alemayhu wrote: > While generating PDFs from the man pages, I saw the warning below from > several files. Compared the tc-matchall.8 with bridge.8 and used .RI > instead of .R. It should have no effect on the man page rendering. > > `R' is a string (producing the registered sign), not a macro. > > Signed-off-by: Alexander Alemayhu I know this has been applied already, but let me get this straight: People using '.R' try to force "normal" font, like for every second parameter to '.IR' but in fact they could just leave the macro away since lines starting without any macro will get normal font settings anyway. With this in mind, I see better solutions for the changes in this patch: [...] > @@ -20,7 +20,7 @@ flower \- flow based traffic control filter > .B indev > .IR ifname " | " > .BR skip_sw " | " skip_hw > -.R " | { " > +.RI " | { " Just merge this into previous line: | .BR skip_sw " | " skip_hw " | {" Note the missing space at the end, as that comes for free anyway. :) [...] > @@ -13,7 +13,7 @@ IFE - encapsulate/decapsulate metadata > .IR SMAC " ] " > .RB "[ " type > .IR TYPE " ] " > -.R "[ " > +.RI "[ " Same here: | .IR TYPE " ] [" [...] > @@ -7,7 +7,7 @@ matchall \- traffic control filter that matches every packet > .ti -8 > .BR tc " " filter " ... " matchall " [ " > .BR skip_sw " | " skip_hw > -.R " ] [ " > +.RI " ] [ " And here as well: | .BR skip_sw " | " skip_hw " ] [" Cheers, Phil
Re: [PATCH net-next] net/mlx5e: fix build error without CONFIG_SYSFS
On Wed, Apr 5, 2017 at 5:11 AM, Tobias Regnery wrote: > Commit 9008ae074885 ("net/mlx5e: Minimize mlx5e_{open/close}_locked") > copied the calls to netif_set_real_num_{tx,rx}_queues from > mlx5e_open_locked to mlx5e_activate_priv_channels and wraps them in an > if condition to test for netdev->real_num_{tx,rx}_queues. > > But netdev->real_num_rx_queues is conditionally compiled in if CONFIG_SYSFS > is set. Without CONFIG_SYSFS the build fails: > > drivers/net/ethernet/mellanox/mlx5/core/en_main.c: In function > 'mlx5e_activate_priv_channels': > drivers/net/ethernet/mellanox/mlx5/core/en_main.c:2515:12: error: 'struct > net_device' has no member named 'real_num_rx_queues'; did you mean > 'real_num_tx_queues'? > > Fix this by unconditionally call netif_set_real_num{tx,rx}_queues like before > commit 9008ae074885. > > Fixes: 9008ae074885 ("net/mlx5e: Minimize mlx5e_{open/close}_locked") > Signed-off-by: Tobias Regnery > --- > drivers/net/ethernet/mellanox/mlx5/core/en_main.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > index ec389b1b51cb..d5248637d44f 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c > @@ -2510,10 +2510,8 @@ static void mlx5e_activate_priv_channels(struct > mlx5e_priv *priv) > struct net_device *netdev = priv->netdev; > > mlx5e_netdev_set_tcs(netdev); > - if (netdev->real_num_tx_queues != num_txqs) > - netif_set_real_num_tx_queues(netdev, num_txqs); > - if (netdev->real_num_rx_queues != priv->channels.num) > - netif_set_real_num_rx_queues(netdev, priv->channels.num); > + netif_set_real_num_tx_queues(netdev, num_txqs); > + netif_set_real_num_rx_queues(netdev, priv->channels.num); > Acked-by: Saeed Mahameed Thanks Tobias for the fix, although it is redundant for most of the reconfiguration options of mlx5 to call set_real_num_{rx,tx} queues every time, but it is not that big of a deal, so it is ok with me to align the code with the previous behavior we had before ("net/mlx5e: Minimize mlx5e_{open/close}_locked").
Re: [PATCH v2 05/13] ftgmac100: Cleanup speed/duplex tracking and fix duplex config
On Wed, Apr 05, 2017 at 12:28:45PM +1000, Benjamin Herrenschmidt wrote: > Keep track of both the current speed and duplex settings > instead of only speed and properly apply the duplex setting > to the HW. > > This reworks the adjust_link() function to also avoid trying > to reconfigure the HW when there is no link and to display > the link state to the user. > > Signed-off-by: Benjamin Herrenschmidt Reviewed-by: Andrew Lunn Andrew
Re: [PATCH v2 10/13] ftgmac100: Add a reset task and use it for link changes
On Wed, Apr 05, 2017 at 12:28:50PM +1000, Benjamin Herrenschmidt wrote: > Link speed changes require a full HW reset. This isn't done > properly at the moment. It will involve delays and thus isn't > suitable to do from the link poll callback. > > So let's create a reset_task that we can queue up when the > link changes. It will be useful for various cases of error > handling as well. > > Signed-off-by: Benjamin Herrenschmidt Reviewed-by: Andrew Lunn Andrew
Re: [PATCH] net: davinci_mdio: add GPIO reset logic
On Wed, Apr 05, 2017 at 11:33:57AM +0300, Roger Quadros wrote: > Some boards [1] leave the PHYs at an invalid state > during system power-up or reset thus causing unreliability > issues with the PHY like not being detected by the mdio bus > or link not functional. To work around these boards have > a GPIO connected to the PHY's reset pin. > > Implement GPIO reset handling for such cases. > > [1] - am572x-idk, am571x-idk, a437x-idk. > > Signed-off-by: Roger Quadros > Signed-off-by: Sekhar Nori > --- > .../devicetree/bindings/net/davinci-mdio.txt | 2 + > drivers/net/ethernet/ti/davinci_mdio.c | 68 > +++--- > 2 files changed, 62 insertions(+), 8 deletions(-) > > diff --git a/Documentation/devicetree/bindings/net/davinci-mdio.txt > b/Documentation/devicetree/bindings/net/davinci-mdio.txt > index 621156c..fd6ebe7 100644 > --- a/Documentation/devicetree/bindings/net/davinci-mdio.txt > +++ b/Documentation/devicetree/bindings/net/davinci-mdio.txt > @@ -12,6 +12,8 @@ Required properties: > > Optional properties: > - ti,hwmods : Must be "davinci_mdio" > +- reset-gpios: array of GPIO specifier for PHY hardware > reset control > +- reset-delay-us : reset assertion time [in microseconds] > > Note: "ti,hwmods" field is used to fetch the base address and irq > resources from TI, omap hwmod data base during device registration. > diff --git a/drivers/net/ethernet/ti/davinci_mdio.c > b/drivers/net/ethernet/ti/davinci_mdio.c > index 33df340..c6f9e55 100644 > --- a/drivers/net/ethernet/ti/davinci_mdio.c > +++ b/drivers/net/ethernet/ti/davinci_mdio.c > @@ -40,6 +40,9 @@ > #include > #include > #include > +#include > +#include > +#include > > /* > * This timeout definition is a worst-case ultra defensive measure against > @@ -53,6 +56,8 @@ > > #define DEF_OUT_FREQ 220 /* 2.2 MHz */ > > +#define DEFAULT_GPIO_RESET_DELAY 10 /* in microseconds */ > + > struct davinci_mdio_of_param { > int autosuspend_delay_ms; > }; > @@ -104,6 +109,9 @@ struct davinci_mdio_data { >*/ > boolskip_scan; > u32 clk_div; > + struct gpio_desc **gpio_reset; > + int num_gpios; > + int reset_delay_us; > }; > > static void davinci_mdio_init_clk(struct davinci_mdio_data *data) > @@ -142,6 +150,20 @@ static void davinci_mdio_enable(struct davinci_mdio_data > *data) > __raw_writel(data->clk_div | CONTROL_ENABLE, &data->regs->control); > } > > +static void __davinci_gpio_reset(struct davinci_mdio_data *data) > +{ > + int i; > + > + for (i = 0; i < data->num_gpios; i++) { > + if (!data->gpio_reset[i]) > + continue; > + > + gpiod_set_value_cansleep(data->gpio_reset[i], 1); > + udelay(data->reset_delay_us); > + gpiod_set_value_cansleep(data->gpio_reset[i], 0); > + } > +} Do you really need more than one GPIO? A single gpio would make all this code a lot simpler. Andrew
Re: [PATCH v2 net-next 0/2] rtnetlink: Updates to rtnetlink_event()
From: Vladislav Yasevich Date: Tue, 4 Apr 2017 09:23:40 -0400 > This series came out of the conversation that started as a result > my first attempt to add netdevice event info to netlink messages. > > This series converts event processing to a 'white list', where > we explicitely permit events to generate netlink messages. This > is meant to make people take a closer look and determine wheter > these events should really trigger netlink messages. > > I am also adding a V2 of my patch to add event type to the netlink > message. This version supports all events that we currently generate. > > I will also update my patch to iproute that will show this data > through 'ip monitor'. > > I actually need the ability to trap NETDEV_NOTIFY_PEERS event > (as well as possible NETDEV_RESEND_IGMP) to support hanlding of > macvtap on top of bonding. I hope others will also find this info usefull. > > V2: Added missed events (from David Ahern) Series applied, thanks Vlad.
Re: [PATCH v2] selftests: add a generic testsuite for ethernet device
From: Corentin Labbe Date: Tue, 4 Apr 2017 15:32:47 +0200 > This patch add a generic testsuite for testing ethernet network device driver. > > Signed-off-by: Corentin Labbe > --- > > Changes since v1: > - Test for starting master interface > - Changed printing format to "RESULT: $netdev: line" > - Use "ip link" to get device list Applied, thanks.
RE: [PATCH] soreuseport: use "unsigned int" in __reuseport_alloc()
From: Alexey Dobriyan > Sent: 04 April 2017 12:36 > On Mon, Apr 3, 2017 at 4:56 PM, Craig Gallek wrote: > > On Sun, Apr 2, 2017 at 6:18 PM, Alexey Dobriyan wrote: > >> Number of sockets is limited by 16-bit, so 64-bit allocation will never > >> happen. > >> > >> 16-bit ops are the worst code density-wise on x86_64 because of > >> additional prefix (66). > > So this boils down to a compiled code density vs a > > readability/maintainability argument? I'm not familiar with the 16 > > bit problem you're referring to, but I'd argue that using the > > self-documenting u16 as an input parameter to define the range > > expectations is more useful that the micro optimization that this > > change may buy you in the assembly of one platform. Especially given > > that this is a rare-use function. > > It's not a problem as in "create trouble". > 16-bit operations are the worst on x86_64: they require additional prefix, > compiler often has to extend it to 32-bit to do anything useful > (MOVZX = 1 cycle, 3 bytes) because of cast-everything-to-int > behaviour enabled by the language. It is worse for almost everything except x86. Do arithmetic on anything smaller than an 'int' and the compiler has to generate instructions to mask the result to the smaller size. On x86 is can often use the 'as if' rule to update only %al (etc). You really, really don't want to use 'char' or 'short' for local variables, function arguments or function results. (If you care about code size or execution time.) David
[PATCH net-next] mlx4: trust shinfo->gso_segs
From: Eric Dumazet mlx4 is the only driver in the tree making a point to recompute shinfo->gso_segs. Lets remove superfluous code. Signed-off-by: Eric Dumazet Cc: Tariq Toukan Cc: Saeed Mahameed --- drivers/net/ethernet/mellanox/mlx4/en_tx.c |3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index e0c5ffb3e3a6607456e1f191b0b8c8becfc71219..3ba89bc43d74d8c023776079bcd0bbadd70fb5c6 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c @@ -978,8 +978,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) ring->tso_packets++; - i = ((skb->len - lso_header_size) / shinfo->gso_size) + - !!((skb->len - lso_header_size) % shinfo->gso_size); + i = shinfo->gso_segs; tx_info->nr_bytes = skb->len + (i - 1) * lso_header_size; ring->packets += i; } else {
Re: [PATCH net-next] mlx4: trust shinfo->gso_segs
On Wed, Apr 5, 2017 at 11:49 AM, Eric Dumazet wrote: > From: Eric Dumazet > > mlx4 is the only driver in the tree making a point to recompute > shinfo->gso_segs. > > Lets remove superfluous code. > > Signed-off-by: Eric Dumazet > Cc: Tariq Toukan > Cc: Saeed Mahameed > --- > drivers/net/ethernet/mellanox/mlx4/en_tx.c |3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c > b/drivers/net/ethernet/mellanox/mlx4/en_tx.c > index > e0c5ffb3e3a6607456e1f191b0b8c8becfc71219..3ba89bc43d74d8c023776079bcd0bbadd70fb5c6 > 100644 > --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c > +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c > @@ -978,8 +978,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct > net_device *dev) > > ring->tso_packets++; > > - i = ((skb->len - lso_header_size) / shinfo->gso_size) + > - !!((skb->len - lso_header_size) % shinfo->gso_size); > + i = shinfo->gso_segs; > tx_info->nr_bytes = skb->len + (i - 1) * lso_header_size; > ring->packets += i; > } else { > > Reviewed-by: Saeed Mahameed
Re: in_irq_or_nmi() and RFC patch
On Mon, Apr 03, 2017 at 01:05:06PM +0100, Mel Gorman wrote: > > Started performance benchmarking: > > 163 cycles = current state > > 183 cycles = with BH disable + in_irq > > 218 cycles = with BH disable + in_irq + irqs_disabled > > > > Thus, the performance numbers unfortunately looks bad, once we add the > > test for irqs_disabled(). The slowdown by replacing preempt_disable > > with BH-disable is still a win (we saved 29 cycles before, and loose > > 20, I was expecting regression to be only 10 cycles). > > > > This surprises me because I'm not seeing the same severity of problems > with irqs_disabled. Your path is slower than what's currently upstream > but it's still far better than a revert. The softirq column in the > middle is your patch versus a full revert which is the last columnm > Any objection to resending the local_bh_enable/disable patch with the in_interrupt() check based on this data or should I post the revert and go back to the drawing board? -- Mel Gorman SUSE Labs
[PATCH net-next] net/sched: Removed unused vlan actions definition
Commit c7e2b9689ef "sched: introduce vlan action" added both the UAPI values for the vlan actions (TCA_VLAN_ACT_) and these two in-kernel ones which are not used, remove them. Signed-off-by: Or Gerlitz Acked-by: Jiri Pirko --- include/net/tc_act/tc_vlan.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/net/tc_act/tc_vlan.h b/include/net/tc_act/tc_vlan.h index 9690c04..c2090df 100644 --- a/include/net/tc_act/tc_vlan.h +++ b/include/net/tc_act/tc_vlan.h @@ -13,9 +13,6 @@ #include #include -#define VLAN_F_POP 0x1 -#define VLAN_F_PUSH0x2 - struct tcf_vlan { struct tc_actioncommon; int tcfv_action; -- 2.3.7
[PATCH 4/4 v2 net-next] net: stmmac: adding multiple napi mechanism
This patch adds the napi variable to the stmmac_rx_queue structure and forces that operations like netif_queue_stopped, netif_wake_queue, netif_stop_queue, netdev_reset_queue and netdev_sent_queue be made by queue. Signed-off-by: Joao Pinto --- changes v1->v2: - init_dma_desc_rings() and alloc_dma_desc_resources() placed back to stmmac_open(), since they are not necessary anymore in probe() (old mechanism). drivers/net/ethernet/stmicro/stmmac/stmmac.h | 3 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 158 -- 2 files changed, 120 insertions(+), 41 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index 359f8fd..33efe70 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -72,6 +72,7 @@ struct stmmac_rx_queue { u32 rx_zeroc_thresh; dma_addr_t dma_rx_phy; u32 rx_tail_addr; + struct napi_struct napi cacheline_aligned_in_smp; }; struct stmmac_priv { @@ -91,8 +92,6 @@ struct stmmac_priv { u32 rx_riwt; int hwts_rx_en; - struct napi_struct napi cacheline_aligned_in_smp; - void __iomem *ioaddr; struct net_device *dev; struct device *device; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 487f702..3d22473 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -139,6 +139,64 @@ static void stmmac_verify_args(void) } /** + * stmmac_disable_all_queues - Disable all queues + * @priv: driver private structure + */ +static void stmmac_disable_all_queues(struct stmmac_priv *priv) +{ + u32 rx_queues_cnt = priv->plat->rx_queues_to_use; + u32 queue; + + for (queue = 0; queue < rx_queues_cnt; queue++) { + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + + napi_disable(&rx_q->napi); + } +} + +/** + * stmmac_enable_all_queues - Enable all queues + * @priv: driver private structure + */ +static void stmmac_enable_all_queues(struct stmmac_priv *priv) +{ + u32 rx_queues_cnt = priv->plat->rx_queues_to_use; + u32 queue; + + for (queue = 0; queue < rx_queues_cnt; queue++) { + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; + + napi_enable(&rx_q->napi); + } +} + +/** + * stmmac_stop_all_queues - Stop all queues + * @priv: driver private structure + */ +static void stmmac_stop_all_queues(struct stmmac_priv *priv) +{ + u32 tx_queues_cnt = priv->plat->tx_queues_to_use; + u32 queue; + + for (queue = 0; queue < tx_queues_cnt; queue++) + netif_tx_stop_queue(netdev_get_tx_queue(priv->dev, queue)); +} + +/** + * stmmac_start_all_queues - Start all queues + * @priv: driver private structure + */ +static void stmmac_start_all_queues(struct stmmac_priv *priv) +{ + u32 tx_queues_cnt = priv->plat->tx_queues_to_use; + u32 queue; + + for (queue = 0; queue < tx_queues_cnt; queue++) + netif_tx_start_queue(netdev_get_tx_queue(priv->dev, queue)); +} + +/** * stmmac_clk_csr_set - dynamically set the MDC clock * @priv: driver private structure * Description: this is to dynamically set the MDC clock according to the csr @@ -1259,7 +1317,6 @@ static int init_dma_tx_desc_rings(struct net_device *dev) for (i = 0; i < DMA_TX_SIZE; i++) { struct dma_desc *p; - if (priv->extend_desc) p = &((tx_q->dma_etx + i)->basic); else @@ -1283,9 +1340,9 @@ static int init_dma_tx_desc_rings(struct net_device *dev) tx_q->dirty_tx = 0; tx_q->cur_tx = 0; - } - netdev_reset_queue(priv->dev); + netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); + } return 0; } @@ -1802,13 +1859,16 @@ static void stmmac_tx_clean(struct stmmac_priv *priv, u32 queue) } tx_q->dirty_tx = entry; - netdev_completed_queue(priv->dev, pkts_compl, bytes_compl); + netdev_tx_completed_queue(netdev_get_tx_queue(priv->dev, queue), + pkts_compl, bytes_compl); + + if (unlikely(netif_tx_queue_stopped(netdev_get_tx_queue(priv->dev, + queue))) && + stmmac_tx_avail(priv, queue) > STMMAC_TX_THRESH) { - if (unlikely(netif_queue_stopped(priv->dev) && - stmmac_tx_avail(priv, queue) > STMMAC_TX_THRESH)) { netif_dbg(priv, tx_done, priv->dev, "%s: restart transmit\n", __func__); - netif_wake_queue(priv->dev); + netif_tx_wake_queue(netdev_get_tx_queue(priv->dev, queue)); } if ((priv->eee_enabl
[PATCH 3/4 v2 net-next] net: stmmac: adding multiple buffers for TX
This patch adds the structure stmmac_tx_queue which contains tx queues specific data (previously in stmmac_priv). Signed-off-by: Joao Pinto --- changes v1->v2: - just to keep up with patch-set version drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 38 +- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 46 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 26 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 519 +- 4 files changed, 374 insertions(+), 255 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index 8db5a80..37881f8 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -26,12 +26,15 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) { - struct stmmac_priv *priv = (struct stmmac_priv *)p; - unsigned int entry = priv->cur_tx; - struct dma_desc *desc = priv->dma_tx + entry; + struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)p; unsigned int nopaged_len = skb_headlen(skb); + struct stmmac_priv *priv = tx_q->priv_data; + unsigned int entry = tx_q->cur_tx; unsigned int bmax, des2; unsigned int i = 1, len; + struct dma_desc *desc; + + desc = tx_q->dma_tx + entry; if (priv->plat->enh_desc) bmax = BUF_SIZE_8KiB; @@ -45,16 +48,16 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - priv->tx_skbuff_dma[entry].buf = des2; - priv->tx_skbuff_dma[entry].len = bmax; + tx_q->tx_skbuff_dma[entry].buf = des2; + tx_q->tx_skbuff_dma[entry].len = bmax; /* do not close the descriptor and do not set own bit */ priv->hw->desc->prepare_tx_desc(desc, 1, bmax, csum, STMMAC_CHAIN_MODE, 0, false); while (len != 0) { - priv->tx_skbuff[entry] = NULL; + tx_q->tx_skbuff[entry] = NULL; entry = STMMAC_GET_ENTRY(entry, DMA_TX_SIZE); - desc = priv->dma_tx + entry; + desc = tx_q->dma_tx + entry; if (len > bmax) { des2 = dma_map_single(priv->device, @@ -63,8 +66,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - priv->tx_skbuff_dma[entry].buf = des2; - priv->tx_skbuff_dma[entry].len = bmax; + tx_q->tx_skbuff_dma[entry].buf = des2; + tx_q->tx_skbuff_dma[entry].len = bmax; priv->hw->desc->prepare_tx_desc(desc, 0, bmax, csum, STMMAC_CHAIN_MODE, 1, false); @@ -77,8 +80,8 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) desc->des2 = cpu_to_le32(des2); if (dma_mapping_error(priv->device, des2)) return -1; - priv->tx_skbuff_dma[entry].buf = des2; - priv->tx_skbuff_dma[entry].len = len; + tx_q->tx_skbuff_dma[entry].buf = des2; + tx_q->tx_skbuff_dma[entry].len = len; /* last descriptor can be set now */ priv->hw->desc->prepare_tx_desc(desc, 0, len, csum, STMMAC_CHAIN_MODE, 1, @@ -87,7 +90,7 @@ static int stmmac_jumbo_frm(void *p, struct sk_buff *skb, int csum) } } - priv->cur_tx = entry; + tx_q->cur_tx = entry; return entry; } @@ -152,17 +155,18 @@ static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p) static void stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p) { - struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; - unsigned int entry = priv->dirty_tx; + struct stmmac_tx_queue *tx_q = (struct stmmac_tx_queue *)priv_ptr; + struct stmmac_priv *priv = tx_q->priv_data; + unsigned int entry = tx_q->dirty_tx; - if (priv->tx_skbuff_dma[entry].last_segment && !priv->extend_desc && + if (tx_q->tx_skbuff_dma[entry].last_segment && !priv->extend_desc && priv->hwts_tx_en) /* NOTE: Device will overwrite des3 with timestamp value if * 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. */ - p->des3 = cpu_to_le32((unsigned int)((priv->dma_tx_phy
[PATCH 0/4 v2 net-next] net: stmmac: adding multiple buffers
This patch adds multiple buffers to stmmac in a more fragmented way, in order to make problem debug easier. I would kindly request to people to test this patch in their HWs in order to check if everything's functional. Thank you. Joao Pinto (4): net: stmmac: break some functions into RX and TX scopes net: stmmac: adding multiple buffers for RX net: stmmac: adding multiple buffers for TX net: stmmac: adding multiple napi mechanism drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 45 +- drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 46 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 49 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1257 ++--- 4 files changed, 947 insertions(+), 450 deletions(-) -- 2.9.3
[PATCH 2/4 v2 net-next] net: stmmac: adding multiple buffers for RX
This patch adds the structure stmmac_rx_queue which contains rx queues specific data (previously in stmmac_priv). Signed-off-by: Joao Pinto --- changes v1->v2: - %d replaced by %u when printing unsigned - err_init_rx_buffers treatment fixed drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 7 +- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 26 +- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 454 ++ 3 files changed, 303 insertions(+), 184 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c index 01a8c02..8db5a80 100644 --- a/drivers/net/ethernet/stmicro/stmmac/chain_mode.c +++ b/drivers/net/ethernet/stmicro/stmmac/chain_mode.c @@ -136,15 +136,16 @@ static void stmmac_init_dma_chain(void *des, dma_addr_t phy_addr, static void stmmac_refill_desc3(void *priv_ptr, struct dma_desc *p) { - struct stmmac_priv *priv = (struct stmmac_priv *)priv_ptr; + struct stmmac_rx_queue *rx_q = (struct stmmac_rx_queue *)priv_ptr; + struct stmmac_priv *priv = rx_q->priv_data; if (priv->hwts_rx_en && !priv->extend_desc) /* NOTE: Device will overwrite des3 with timestamp value if * 1588-2002 time stamping is enabled, hence reinitialize it * to keep explicit chaining in the descriptor. */ - p->des3 = cpu_to_le32((unsigned int)(priv->dma_rx_phy + - (((priv->dirty_rx) + 1) % + p->des3 = cpu_to_le32((unsigned int)(rx_q->dma_rx_phy + + (((rx_q->dirty_rx) + 1) % DMA_RX_SIZE) * sizeof(struct dma_desc))); } diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index cd8fb61..c7ad9e4 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -46,6 +46,20 @@ struct stmmac_tx_info { bool is_jumbo; }; +struct stmmac_rx_queue { + u32 queue_index; + struct stmmac_priv *priv_data; + struct dma_extended_desc *dma_erx; + struct dma_desc *dma_rx cacheline_aligned_in_smp; + struct sk_buff **rx_skbuff; + dma_addr_t *rx_skbuff_dma; + unsigned int cur_rx; + unsigned int dirty_rx; + u32 rx_zeroc_thresh; + dma_addr_t dma_rx_phy; + u32 rx_tail_addr; +}; + struct stmmac_priv { /* Frequently used values are kept adjacent for cache effect */ struct dma_extended_desc *dma_etx cacheline_aligned_in_smp; @@ -64,18 +78,10 @@ struct stmmac_priv { struct timer_list txtimer; bool tso; - struct dma_desc *dma_rx cacheline_aligned_in_smp; - struct dma_extended_desc *dma_erx; - struct sk_buff **rx_skbuff; - unsigned int cur_rx; - unsigned int dirty_rx; unsigned int dma_buf_sz; unsigned int rx_copybreak; - unsigned int rx_zeroc_thresh; u32 rx_riwt; int hwts_rx_en; - dma_addr_t *rx_skbuff_dma; - dma_addr_t dma_rx_phy; struct napi_struct napi cacheline_aligned_in_smp; @@ -85,6 +91,9 @@ struct stmmac_priv { struct mac_device_info *hw; spinlock_t lock; + /* RX Queue */ + struct stmmac_rx_queue rx_queue[MTL_MAX_RX_QUEUES]; + int oldlink; int speed; int oldduplex; @@ -119,7 +128,6 @@ struct stmmac_priv { spinlock_t ptp_lock; void __iomem *mmcaddr; void __iomem *ptpaddr; - u32 rx_tail_addr; u32 tx_tail_addr; u32 mss; diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index ff839e1..5892796 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -197,14 +197,20 @@ static inline u32 stmmac_tx_avail(struct stmmac_priv *priv) return avail; } -static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv) +/** + * stmmac_rx_dirty - Get RX queue dirty + * @priv: driver private structure + * @queue: RX queue index + */ +static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv, u32 queue) { + struct stmmac_rx_queue *rx_q = &priv->rx_queue[queue]; u32 dirty; - if (priv->dirty_rx <= priv->cur_rx) - dirty = priv->cur_rx - priv->dirty_rx; + if (rx_q->dirty_rx <= rx_q->cur_rx) + dirty = rx_q->cur_rx - rx_q->dirty_rx; else - dirty = DMA_RX_SIZE - priv->dirty_rx + priv->cur_rx; + dirty = DMA_RX_SIZE - rx_q->dirty_rx + rx_q->cur_rx; return dirty; } @@ -891,15 +897,24 @@ static int stmmac_init_phy(struct net_device *dev) static void stmmac_display_rx_rings(struct stmmac_priv *priv) { + u32 rx_cnt = priv->plat->rx_queues_to_use;
[PATCH 1/4 v2 net-next] net: stmmac: break some functions into RX and TX scopes
This patch breaks several functions into RX and TX scopes, which will be useful when adding multiple buffers mechanism. Signed-off-by: Joao Pinto --- changes v1->v2: - RX and TX inconsistency - stmmac_free_rx_buffers renamed to stmmac_free_rx_buffer - stmmac_free_tx_buffers renamed to stmmac_free_tx_buffer - some useless comments were removed drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 352 -- 1 file changed, 266 insertions(+), 86 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index 7cbda41..ff839e1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -889,24 +889,41 @@ static int stmmac_init_phy(struct net_device *dev) return 0; } -static void stmmac_display_rings(struct stmmac_priv *priv) +static void stmmac_display_rx_rings(struct stmmac_priv *priv) { - void *head_rx, *head_tx; + void *head_rx; - if (priv->extend_desc) { + if (priv->extend_desc) head_rx = (void *)priv->dma_erx; - head_tx = (void *)priv->dma_etx; - } else { + else head_rx = (void *)priv->dma_rx; - head_tx = (void *)priv->dma_tx; - } - /* Display Rx ring */ + /* Display RX ring */ priv->hw->desc->display_ring(head_rx, DMA_RX_SIZE, true); - /* Display Tx ring */ +} + +static void stmmac_display_tx_rings(struct stmmac_priv *priv) +{ + void *head_tx; + + if (priv->extend_desc) + head_tx = (void *)priv->dma_etx; + else + head_tx = (void *)priv->dma_tx; + + /* Display TX ring */ priv->hw->desc->display_ring(head_tx, DMA_TX_SIZE, false); } +static void stmmac_display_rings(struct stmmac_priv *priv) +{ + /* Display RX ring */ + stmmac_display_rx_rings(priv); + + /* Display TX ring */ + stmmac_display_tx_rings(priv); +} + static int stmmac_set_bfsize(int mtu, int bufsize) { int ret = bufsize; @@ -924,16 +941,16 @@ static int stmmac_set_bfsize(int mtu, int bufsize) } /** - * stmmac_clear_descriptors - clear descriptors + * stmmac_clear_rx_descriptors - clear RX descriptors * @priv: driver private structure - * Description: this function is called to clear the tx and rx descriptors + * Description: this function is called to clear the RX descriptors * in case of both basic and extended descriptors are used. */ -static void stmmac_clear_descriptors(struct stmmac_priv *priv) +static void stmmac_clear_rx_descriptors(struct stmmac_priv *priv) { int i; - /* Clear the Rx/Tx descriptors */ + /* Clear the RX descriptors */ for (i = 0; i < DMA_RX_SIZE; i++) if (priv->extend_desc) priv->hw->desc->init_rx_desc(&priv->dma_erx[i].basic, @@ -943,6 +960,19 @@ static void stmmac_clear_descriptors(struct stmmac_priv *priv) priv->hw->desc->init_rx_desc(&priv->dma_rx[i], priv->use_riwt, priv->mode, (i == DMA_RX_SIZE - 1)); +} + +/** + * stmmac_clear_tx_descriptors - clear tx descriptors + * @priv: driver private structure + * Description: this function is called to clear the TX descriptors + * in case of both basic and extended descriptors are used. + */ +static void stmmac_clear_tx_descriptors(struct stmmac_priv *priv) +{ + int i; + + /* Clear the TX descriptors */ for (i = 0; i < DMA_TX_SIZE; i++) if (priv->extend_desc) priv->hw->desc->init_tx_desc(&priv->dma_etx[i].basic, @@ -955,6 +985,21 @@ static void stmmac_clear_descriptors(struct stmmac_priv *priv) } /** + * stmmac_clear_descriptors - clear descriptors + * @priv: driver private structure + * Description: this function is called to clear the TX and RX descriptors + * in case of both basic and extended descriptors are used. + */ +static void stmmac_clear_descriptors(struct stmmac_priv *priv) +{ + /* Clear the RX descriptors */ + stmmac_clear_rx_descriptors(priv); + + /* Clear the TX descriptors */ + stmmac_clear_tx_descriptors(priv); +} + +/** * stmmac_init_rx_buffers - init the RX descriptor buffer. * @priv: driver private structure * @p: descriptor pointer @@ -996,7 +1041,12 @@ static int stmmac_init_rx_buffers(struct stmmac_priv *priv, struct dma_desc *p, return 0; } -static void stmmac_free_rx_buffers(struct stmmac_priv *priv, int i) +/** + * stmmac_free_rx_buffer - free RX dma buffers + * @priv: private structure + * @i: buffer index. + */ +static void stmmac_free_rx_buffer(struct stmmac_priv *priv, int i) { if (priv->rx_skbuff[i]) { dma_unmap_single(priv->device, priv->rx_skbuff_dma[i], @@ -1007,14 +1057,42 @@ static void stmmac_free_rx_buffers(struc
[PATCH 12/38] Annotate hardware config module parameters in drivers/isdn/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/isdn/. Suggested-by: Alan Cox Signed-off-by: David Howells cc: Karsten Keil cc: netdev@vger.kernel.org --- drivers/isdn/hardware/avm/b1isa.c |4 ++-- drivers/isdn/hardware/avm/t1isa.c |4 ++-- drivers/isdn/hisax/config.c | 10 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/isdn/hardware/avm/b1isa.c b/drivers/isdn/hardware/avm/b1isa.c index 31ef8130a87f..54e871a47387 100644 --- a/drivers/isdn/hardware/avm/b1isa.c +++ b/drivers/isdn/hardware/avm/b1isa.c @@ -169,8 +169,8 @@ static struct pci_dev isa_dev[MAX_CARDS]; static int io[MAX_CARDS]; static int irq[MAX_CARDS]; -module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); MODULE_PARM_DESC(io, "I/O base address(es)"); MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); diff --git a/drivers/isdn/hardware/avm/t1isa.c b/drivers/isdn/hardware/avm/t1isa.c index 72ef18853951..9516203c735f 100644 --- a/drivers/isdn/hardware/avm/t1isa.c +++ b/drivers/isdn/hardware/avm/t1isa.c @@ -516,8 +516,8 @@ static int io[MAX_CARDS]; static int irq[MAX_CARDS]; static int cardnr[MAX_CARDS]; -module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); module_param_array(cardnr, int, NULL, 0); MODULE_PARM_DESC(io, "I/O base address(es)"); MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); diff --git a/drivers/isdn/hisax/config.c b/drivers/isdn/hisax/config.c index 2d12c6ceeb89..c7d68675b028 100644 --- a/drivers/isdn/hisax/config.c +++ b/drivers/isdn/hisax/config.c @@ -350,13 +350,13 @@ MODULE_AUTHOR("Karsten Keil"); MODULE_LICENSE("GPL"); module_param_array(type, int, NULL, 0); module_param_array(protocol, int, NULL, 0); -module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); -module_param_array(mem, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); +module_param_hw_array(mem, int, iomem, NULL, 0); module_param(id, charp, 0); #ifdef IO0_IO1 -module_param_array(io0, int, NULL, 0); -module_param_array(io1, int, NULL, 0); +module_param_hw_array(io0, int, ioport, NULL, 0); +module_param_hw_array(io1, int, ioport, NULL, 0); #endif #endif /* MODULE */
[PATCH 20/38] Annotate hardware config module parameters in drivers/net/hamradio/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/net/hamradio/. Suggested-by: Alan Cox Signed-off-by: David Howells cc: Thomas Sailer cc: Joerg Reuter cc: linux-h...@vger.kernel.org cc: netdev@vger.kernel.org --- drivers/net/hamradio/baycom_epp.c |2 +- drivers/net/hamradio/baycom_par.c |2 +- drivers/net/hamradio/baycom_ser_fdx.c |4 ++-- drivers/net/hamradio/baycom_ser_hdx.c |4 ++-- drivers/net/hamradio/dmascc.c |2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 594fa1407e29..1503f10122f7 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c @@ -1176,7 +1176,7 @@ static int iobase[NR_PORTS] = { 0x378, }; module_param_array(mode, charp, NULL, 0); MODULE_PARM_DESC(mode, "baycom operating mode"); -module_param_array(iobase, int, NULL, 0); +module_param_hw_array(iobase, int, ioport, NULL, 0); MODULE_PARM_DESC(iobase, "baycom io base address"); MODULE_AUTHOR("Thomas M. Sailer, sai...@ife.ee.ethz.ch, hb9...@hb9w.che.eu"); diff --git a/drivers/net/hamradio/baycom_par.c b/drivers/net/hamradio/baycom_par.c index 809dc25909d1..92b13b39f426 100644 --- a/drivers/net/hamradio/baycom_par.c +++ b/drivers/net/hamradio/baycom_par.c @@ -481,7 +481,7 @@ static int iobase[NR_PORTS] = { 0x378, }; module_param_array(mode, charp, NULL, 0); MODULE_PARM_DESC(mode, "baycom operating mode; eg. par96 or picpar"); -module_param_array(iobase, int, NULL, 0); +module_param_hw_array(iobase, int, ioport, NULL, 0); MODULE_PARM_DESC(iobase, "baycom io base address"); MODULE_AUTHOR("Thomas M. Sailer, sai...@ife.ee.ethz.ch, hb9...@hb9w.che.eu"); diff --git a/drivers/net/hamradio/baycom_ser_fdx.c b/drivers/net/hamradio/baycom_ser_fdx.c index ebc06822fd4d..d9a646acca20 100644 --- a/drivers/net/hamradio/baycom_ser_fdx.c +++ b/drivers/net/hamradio/baycom_ser_fdx.c @@ -614,9 +614,9 @@ static int baud[NR_PORTS] = { [0 ... NR_PORTS-1] = 1200 }; module_param_array(mode, charp, NULL, 0); MODULE_PARM_DESC(mode, "baycom operating mode; * for software DCD"); -module_param_array(iobase, int, NULL, 0); +module_param_hw_array(iobase, int, ioport, NULL, 0); MODULE_PARM_DESC(iobase, "baycom io base address"); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); MODULE_PARM_DESC(irq, "baycom irq number"); module_param_array(baud, int, NULL, 0); MODULE_PARM_DESC(baud, "baycom baud rate (300 to 4800)"); diff --git a/drivers/net/hamradio/baycom_ser_hdx.c b/drivers/net/hamradio/baycom_ser_hdx.c index 60fcf512c208..f1c8a9ff3891 100644 --- a/drivers/net/hamradio/baycom_ser_hdx.c +++ b/drivers/net/hamradio/baycom_ser_hdx.c @@ -642,9 +642,9 @@ static int irq[NR_PORTS] = { 4, }; module_param_array(mode, charp, NULL, 0); MODULE_PARM_DESC(mode, "baycom operating mode; * for software DCD"); -module_param_array(iobase, int, NULL, 0); +module_param_hw_array(iobase, int, ioport, NULL, 0); MODULE_PARM_DESC(iobase, "baycom io base address"); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); MODULE_PARM_DESC(irq, "baycom irq number"); MODULE_AUTHOR("Thomas M. Sailer, sai...@ife.ee.ethz.ch, hb9...@hb9w.che.eu"); diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c index 2479072981a1..dec6b76bc0fb 100644 --- a/drivers/net/hamradio/dmascc.c +++ b/drivers/net/hamradio/dmascc.c @@ -274,7 +274,7 @@ static unsigned long rand; MODULE_AUTHOR("Klaus Kudielka"); MODULE_DESCRIPTION("Driver for high-speed SCC boards"); -module_param_array(io, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); MODULE_LICENSE("GPL"); static void __exit dmascc_exit(void)
[PATCH 21/38] Annotate hardware config module parameters in drivers/net/irda/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/net/irda/. Suggested-by: Alan Cox Signed-off-by: David Howells cc: Samuel Ortiz cc: netdev@vger.kernel.org --- drivers/net/irda/ali-ircc.c|6 +++--- drivers/net/irda/nsc-ircc.c|6 +++--- drivers/net/irda/smsc-ircc2.c | 10 +- drivers/net/irda/w83977af_ir.c |4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c index c285eafd3f1c..35f198d83701 100644 --- a/drivers/net/irda/ali-ircc.c +++ b/drivers/net/irda/ali-ircc.c @@ -2207,11 +2207,11 @@ MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:" ALI_IRCC_DRIVER_NAME); -module_param_array(io, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); MODULE_PARM_DESC(io, "Base I/O addresses"); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); MODULE_PARM_DESC(irq, "IRQ lines"); -module_param_array(dma, int, NULL, 0); +module_param_hw_array(dma, int, dma, NULL, 0); MODULE_PARM_DESC(dma, "DMA channels"); module_init(ali_ircc_init); diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c index aaecc3baaf30..7beae147be11 100644 --- a/drivers/net/irda/nsc-ircc.c +++ b/drivers/net/irda/nsc-ircc.c @@ -2396,11 +2396,11 @@ MODULE_LICENSE("GPL"); module_param(qos_mtt_bits, int, 0); MODULE_PARM_DESC(qos_mtt_bits, "Minimum Turn Time"); -module_param_array(io, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); MODULE_PARM_DESC(io, "Base I/O addresses"); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); MODULE_PARM_DESC(irq, "IRQ lines"); -module_param_array(dma, int, NULL, 0); +module_param_hw_array(dma, int, dma, NULL, 0); MODULE_PARM_DESC(dma, "DMA channels"); module_param(dongle_id, int, 0); MODULE_PARM_DESC(dongle_id, "Type-id of used dongle"); diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c index dcf92ba80872..23ed89ae5ddc 100644 --- a/drivers/net/irda/smsc-ircc2.c +++ b/drivers/net/irda/smsc-ircc2.c @@ -82,24 +82,24 @@ MODULE_PARM_DESC(nopnp, "Do not use PNP to detect controller settings, defaults #define DMA_INVAL 255 static int ircc_dma = DMA_INVAL; -module_param(ircc_dma, int, 0); +module_param_hw(ircc_dma, int, dma, 0); MODULE_PARM_DESC(ircc_dma, "DMA channel"); #define IRQ_INVAL 255 static int ircc_irq = IRQ_INVAL; -module_param(ircc_irq, int, 0); +module_param_hw(ircc_irq, int, irq, 0); MODULE_PARM_DESC(ircc_irq, "IRQ line"); static int ircc_fir; -module_param(ircc_fir, int, 0); +module_param_hw(ircc_fir, int, ioport, 0); MODULE_PARM_DESC(ircc_fir, "FIR Base Address"); static int ircc_sir; -module_param(ircc_sir, int, 0); +module_param_hw(ircc_sir, int, ioport, 0); MODULE_PARM_DESC(ircc_sir, "SIR Base Address"); static int ircc_cfg; -module_param(ircc_cfg, int, 0); +module_param_hw(ircc_cfg, int, ioport, 0); MODULE_PARM_DESC(ircc_cfg, "Configuration register base address"); static int ircc_transceiver; diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c index 8d5b903d1d9d..282b6c9ae05b 100644 --- a/drivers/net/irda/w83977af_ir.c +++ b/drivers/net/irda/w83977af_ir.c @@ -1263,9 +1263,9 @@ MODULE_LICENSE("GPL"); module_param(qos_mtt_bits, int, 0); MODULE_PARM_DESC(qos_mtt_bits, "Mimimum Turn Time"); -module_param_array(io, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); MODULE_PARM_DESC(io, "Base I/O addresses"); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); MODULE_PARM_DESC(irq, "IRQ lines"); /*
[PATCH 23/38] Annotate hardware config module parameters in drivers/net/wireless/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/net/wireless/. Suggested-by: Alan Cox Signed-off-by: David Howells cc: Kalle Valo cc: linux-wirel...@vger.kernel.org cc: netdev@vger.kernel.org --- drivers/net/wireless/cisco/airo.c |4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index 4b040451a9b8..1b7e125a28e2 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c @@ -246,8 +246,8 @@ MODULE_DESCRIPTION("Support for Cisco/Aironet 802.11 wireless ethernet cards. " "Direct support for ISA/PCI/MPI cards and support for PCMCIA when used with airo_cs."); MODULE_LICENSE("Dual BSD/GPL"); MODULE_SUPPORTED_DEVICE("Aironet 4500, 4800 and Cisco 340/350"); -module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); module_param_array(rates, int, NULL, 0); module_param_array(ssids, charp, NULL, 0); module_param(auto_wep, int, 0);
[PATCH 22/38] Annotate hardware config module parameters in drivers/net/wan/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/net/wan/. Suggested-by: Alan Cox Signed-off-by: David Howells cc: "Jan \"Yenya\" Kasprzak" cc: netdev@vger.kernel.org --- drivers/net/wan/cosa.c |6 +++--- drivers/net/wan/hostess_sv11.c |6 +++--- drivers/net/wan/sbni.c |4 ++-- drivers/net/wan/sealevel.c |8 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c index 4ca71bca39ac..6ea16260ec76 100644 --- a/drivers/net/wan/cosa.c +++ b/drivers/net/wan/cosa.c @@ -232,11 +232,11 @@ static int irq[MAX_CARDS+1] = { -1, -1, -1, -1, -1, -1, 0, }; static struct class *cosa_class; #ifdef MODULE -module_param_array(io, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); MODULE_PARM_DESC(io, "The I/O bases of the COSA or SRP cards"); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); MODULE_PARM_DESC(irq, "The IRQ lines of the COSA or SRP cards"); -module_param_array(dma, int, NULL, 0); +module_param_hw_array(dma, int, dma, NULL, 0); MODULE_PARM_DESC(dma, "The DMA channels of the COSA or SRP cards"); MODULE_AUTHOR("Jan \"Yenya\" Kasprzak, "); diff --git a/drivers/net/wan/hostess_sv11.c b/drivers/net/wan/hostess_sv11.c index dd6bb3364ad2..4de0737fbf8a 100644 --- a/drivers/net/wan/hostess_sv11.c +++ b/drivers/net/wan/hostess_sv11.c @@ -324,11 +324,11 @@ static void sv11_shutdown(struct z8530_dev *dev) static int io = 0x200; static int irq = 9; -module_param(io, int, 0); +module_param_hw(io, int, ioport, 0); MODULE_PARM_DESC(io, "The I/O base of the Comtrol Hostess SV11 card"); -module_param(dma, int, 0); +module_param_hw(dma, int, dma, 0); MODULE_PARM_DESC(dma, "Set this to 1 to use DMA1/DMA3 for TX/RX"); -module_param(irq, int, 0); +module_param_hw(irq, int, irq, 0); MODULE_PARM_DESC(irq, "The interrupt line setting for the Comtrol Hostess SV11 card"); MODULE_AUTHOR("Alan Cox"); diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c index 3ca3419c54a0..bde8c0339831 100644 --- a/drivers/net/wan/sbni.c +++ b/drivers/net/wan/sbni.c @@ -1463,8 +1463,8 @@ set_multicast_list( struct net_device *dev ) #ifdef MODULE -module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); module_param_array(baud, int, NULL, 0); module_param_array(rxl, int, NULL, 0); module_param_array(mac, int, NULL, 0); diff --git a/drivers/net/wan/sealevel.c b/drivers/net/wan/sealevel.c index fbb5aa2c4d8f..c56f2c252113 100644 --- a/drivers/net/wan/sealevel.c +++ b/drivers/net/wan/sealevel.c @@ -363,13 +363,13 @@ static int rxdma=3; static int irq=5; static bool slow=false; -module_param(io, int, 0); +module_param_hw(io, int, ioport, 0); MODULE_PARM_DESC(io, "The I/O base of the Sealevel card"); -module_param(txdma, int, 0); +module_param_hw(txdma, int, dma, 0); MODULE_PARM_DESC(txdma, "Transmit DMA channel"); -module_param(rxdma, int, 0); +module_param_hw(rxdma, int, dma, 0); MODULE_PARM_DESC(rxdma, "Receive DMA channel"); -module_param(irq, int, 0); +module_param_hw(irq, int, irq, 0); MODULE_PARM_DESC(irq, "The interrupt line setting for the SeaLevel card"); module_param(slow, bool, 0); MODULE_PARM_DESC(slow, "Set this for an older Sealevel card such as the 4012");
[iproute PATCH] ip-route: Prevent some other double spaces in output
Print spaces only after text. CC: Phil Sutter Signed-off-by: Timothy Redaelli --- ip/iproute.c | 77 ++-- 1 file changed, 39 insertions(+), 38 deletions(-) Fixed all the problems reported in V2 Tested with improved script https://da.gd/tUVso that tests ip route and ip get for both ipv4 and ipv6. If it's OK I'd like to send it upstream diff --git a/ip/iproute.c b/ip/iproute.c index 7cdf072..5e23613 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -298,12 +298,12 @@ static void print_rtax_features(FILE *fp, unsigned int features) unsigned int of = features; if (features & RTAX_FEATURE_ECN) { - fprintf(fp, " ecn"); + fprintf(fp, "ecn "); features &= ~RTAX_FEATURE_ECN; } if (features) - fprintf(fp, " 0x%x", of); + fprintf(fp, "0x%x ", of); } int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) @@ -511,21 +511,21 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) if (!hz) hz = get_user_hz(); if (ci->rta_expires != 0) - fprintf(fp, " expires %dsec", ci->rta_expires/hz); + fprintf(fp, "expires %dsec ", ci->rta_expires/hz); if (ci->rta_error != 0) - fprintf(fp, " error %d", ci->rta_error); + fprintf(fp, "error %d ", ci->rta_error); if (show_stats) { if (ci->rta_clntref) - fprintf(fp, " users %d", ci->rta_clntref); + fprintf(fp, "users %d ", ci->rta_clntref); if (ci->rta_used != 0) - fprintf(fp, " used %d", ci->rta_used); + fprintf(fp, "used %d ", ci->rta_used); if (ci->rta_lastuse != 0) - fprintf(fp, " age %dsec", ci->rta_lastuse/hz); + fprintf(fp, "age %dsec ", ci->rta_lastuse/hz); } if (ci->rta_id) - fprintf(fp, " ipid 0x%04x", ci->rta_id); + fprintf(fp, "ipid 0x%04x ", ci->rta_id); if (ci->rta_ts || ci->rta_tsage) - fprintf(fp, " ts 0x%x tsage %dsec", + fprintf(fp, "ts 0x%x tsage %dsec ", ci->rta_ts, ci->rta_tsage); } } else if (r->rtm_family == AF_INET6) { @@ -539,20 +539,20 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) if (r->rtm_flags & RTM_F_CLONED) fprintf(fp, "%scache ", _SL_); if (ci->rta_expires) - fprintf(fp, " expires %dsec", ci->rta_expires/hz); + fprintf(fp, "expires %dsec ", ci->rta_expires/hz); if (ci->rta_error != 0) - fprintf(fp, " error %d", ci->rta_error); + fprintf(fp, "error %d ", ci->rta_error); if (show_stats) { if (ci->rta_clntref) - fprintf(fp, " users %d", ci->rta_clntref); + fprintf(fp, "users %d ", ci->rta_clntref); if (ci->rta_used != 0) - fprintf(fp, " used %d", ci->rta_used); + fprintf(fp, "used %d ", ci->rta_used); if (ci->rta_lastuse != 0) - fprintf(fp, " age %dsec", ci->rta_lastuse/hz); + fprintf(fp, "age %dsec ", ci->rta_lastuse/hz); } } else if (ci) { if (ci->rta_error != 0) - fprintf(fp, " error %d", ci->rta_error); + fprintf(fp, "error %d ", ci->rta_error); } } if (tb[RTA_METRICS]) { @@ -578,19 +578,19 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) continue; if (i < sizeof(mx_names)/sizeof(char *) && mx_names[i]) - fprintf(fp, " %s", mx_names[i]); + fprintf(fp, "%s ", mx_names[i]); else - fprintf(fp, " metric %d", i); + fprintf(fp, "metri
Re: [PATCH 1/4] net: dsa: add support for the SMSC-LAN9303 tagging format
On Wed, Apr 05, 2017 at 11:20:21AM +0200, Juergen Borleis wrote: > To define the outgoing port and to discover the incoming port a regular > VLAN tag is used by the LAN9303. But its VID meaning is 'special'. > > This tag handler/filter depends on some hardware features which must be > enabled in the device to provide and make use of this special VLAN tag > to control the destination and the source of an ethernet packet. > > Signed-off-by: Juergen Borleis > --- > include/net/dsa.h | 1 + > net/dsa/Kconfig | 3 + > net/dsa/Makefile | 1 + > net/dsa/dsa.c | 3 + > net/dsa/dsa_priv.h| 3 + > net/dsa/tag_lan9303.c | 155 > ++ > 6 files changed, 166 insertions(+) > create mode 100644 net/dsa/tag_lan9303.c > > diff --git a/include/net/dsa.h b/include/net/dsa.h > index 4e13e695f0251..4fb1f2b086b05 100644 > --- a/include/net/dsa.h > +++ b/include/net/dsa.h > @@ -31,6 +31,7 @@ enum dsa_tag_protocol { > DSA_TAG_PROTO_EDSA, > DSA_TAG_PROTO_BRCM, > DSA_TAG_PROTO_QCA, > + DSA_TAG_PROTO_LAN9303, > DSA_TAG_LAST, /* MUST BE LAST */ > }; > > diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig > index 9649238eef404..22c8bd69ff71c 100644 > --- a/net/dsa/Kconfig > +++ b/net/dsa/Kconfig > @@ -31,4 +31,7 @@ config NET_DSA_TAG_TRAILER > config NET_DSA_TAG_QCA > bool > > +config NET_DSA_TAG_LAN9303 > + bool > + > endif > diff --git a/net/dsa/Makefile b/net/dsa/Makefile > index 31d343796251d..aafc74f2cb193 100644 > --- a/net/dsa/Makefile > +++ b/net/dsa/Makefile > @@ -8,3 +8,4 @@ dsa_core-$(CONFIG_NET_DSA_TAG_DSA) += tag_dsa.o > dsa_core-$(CONFIG_NET_DSA_TAG_EDSA) += tag_edsa.o > dsa_core-$(CONFIG_NET_DSA_TAG_TRAILER) += tag_trailer.o > dsa_core-$(CONFIG_NET_DSA_TAG_QCA) += tag_qca.o > +dsa_core-$(CONFIG_NET_DSA_TAG_LAN9303) += tag_lan9303.o > diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c > index b6d4f6a23f06c..f93f78de23af3 100644 > --- a/net/dsa/dsa.c > +++ b/net/dsa/dsa.c > @@ -53,6 +53,9 @@ const struct dsa_device_ops *dsa_device_ops[DSA_TAG_LAST] = > { > #ifdef CONFIG_NET_DSA_TAG_QCA > [DSA_TAG_PROTO_QCA] = &qca_netdev_ops, > #endif > +#ifdef CONFIG_NET_DSA_TAG_LAN9303 > + [DSA_TAG_PROTO_LAN9303] = &lan9303_netdev_ops, > +#endif > [DSA_TAG_PROTO_NONE] = &none_ops, > }; > > diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h > index 0706a511244e9..a54cfc8aefa83 100644 > --- a/net/dsa/dsa_priv.h > +++ b/net/dsa/dsa_priv.h > @@ -85,4 +85,7 @@ extern const struct dsa_device_ops brcm_netdev_ops; > /* tag_qca.c */ > extern const struct dsa_device_ops qca_netdev_ops; > > +/* tag_lan9303.c */ > +extern const struct dsa_device_ops lan9303_netdev_ops; > + > #endif > diff --git a/net/dsa/tag_lan9303.c b/net/dsa/tag_lan9303.c > new file mode 100644 > index 0..ad04c6d447f77 > --- /dev/null > +++ b/net/dsa/tag_lan9303.c > @@ -0,0 +1,155 @@ > +/* > + * Copyright (C) 2017 Pengutronix, Juergen Borleis > + * > + * This program is free software; you can redistribute it and/or > + * modify it under the terms of the GNU General Public License > + * version 2, as published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > + * GNU General Public License for more details. > + * > + */ > +#include > +#include > +#include > +#include "dsa_priv.h" > + > +/* To define the outgoing port and to discover the incoming port a regular > + * VLAN tag is used by the LAN9303. But its VID meaning is 'special': > + * > + * Dest MAC Src MACTAGType > + * ...| 1 2 3 4 5 6 | 1 2 3 4 5 6 | 1 2 3 4 | 1 2 |... > + *|<--->| > + * TAG: > + *|<->| > + *| 1 2 | 3 4 | > + * TPIDVID > + * 0x8100 > + * > + * VID bit 3 indicates a request for an ALR lookup. > + * > + * If VID bit 3 is zero, then bits 0 and 1 specify the destination port > + * (0, 1, 2) or broadcast (3) or the source port (1, 2). > + * > + * VID bit 4 is used to specify if the STP port state should be overridden. > + * Required when no forwarding between the external ports should happen. > + */ Hi Juergen Nice comment, thanks. > + > +#define LAN9303_TAG_LEN 4 > + > +static struct sk_buff *lan9303_xmit(struct sk_buff *skb, struct net_device > *dev) > +{ ... > + /* make room between MACs and Ether-Type */ > + memmove(skb->data, skb->data + LAN9303_TAG_LEN, 2 * ETH_ALEN); > + > + lan9303_tag = (u16 *)(skb->data + 2 * ETH_ALEN); > + lan9303_tag[0] = htons(ETH_P_8021Q); > + lan9303_tag[1] = htons(p->dp->index | BIT(4)); > +static int lan9303_rcv(struct sk_buff *skb, struct net_device *dev, > +struct packet_type *pt, struct net_device *orig_dev) > +{ > + u16 *lan9303_tag; > + struct dsa_switch_
[PATCH 19/38] Annotate hardware config module parameters in drivers/net/ethernet/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/net/ethernet/. Suggested-by: Alan Cox Signed-off-by: David Howells cc: Steffen Klassert cc: Jaroslav Kysela cc: netdev@vger.kernel.org cc: linux-par...@vger.kernel.org --- drivers/net/ethernet/3com/3c509.c |2 +- drivers/net/ethernet/3com/3c59x.c |4 ++-- drivers/net/ethernet/8390/ne.c |4 ++-- drivers/net/ethernet/8390/smc-ultra.c |4 ++-- drivers/net/ethernet/8390/wd.c |8 drivers/net/ethernet/amd/lance.c |6 +++--- drivers/net/ethernet/amd/ni65.c|6 +++--- drivers/net/ethernet/cirrus/cs89x0.c |6 +++--- drivers/net/ethernet/dec/tulip/de4x5.c |2 +- drivers/net/ethernet/hp/hp100.c|2 +- drivers/net/ethernet/realtek/atp.c |4 ++-- drivers/net/ethernet/smsc/smc9194.c|4 ++-- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/net/ethernet/3com/3c509.c b/drivers/net/ethernet/3com/3c509.c index c7f9f2c77da7..db8592d412ab 100644 --- a/drivers/net/ethernet/3com/3c509.c +++ b/drivers/net/ethernet/3com/3c509.c @@ -1371,7 +1371,7 @@ el3_resume(struct device *pdev) #endif /* CONFIG_PM */ module_param(debug,int, 0); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); module_param(max_interrupt_work, int, 0); MODULE_PARM_DESC(debug, "debug level (0-6)"); MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c index 40196f41768a..e41245a54f8b 100644 --- a/drivers/net/ethernet/3com/3c59x.c +++ b/drivers/net/ethernet/3com/3c59x.c @@ -813,8 +813,8 @@ module_param(global_enable_wol, int, 0); module_param_array(enable_wol, int, NULL, 0); module_param(rx_copybreak, int, 0); module_param(max_interrupt_work, int, 0); -module_param(compaq_ioaddr, int, 0); -module_param(compaq_irq, int, 0); +module_param_hw(compaq_ioaddr, int, ioport, 0); +module_param_hw(compaq_irq, int, irq, 0); module_param(compaq_device_id, int, 0); module_param(watchdog, int, 0); module_param(global_use_mmio, int, 0); diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c index c063b410a163..66f47987e2a2 100644 --- a/drivers/net/ethernet/8390/ne.c +++ b/drivers/net/ethernet/8390/ne.c @@ -74,8 +74,8 @@ static int bad[MAX_NE_CARDS]; static u32 ne_msg_enable; #ifdef MODULE -module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); module_param_array(bad, int, NULL, 0); module_param_named(msg_enable, ne_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH)); MODULE_PARM_DESC(io, "I/O base address(es),required"); diff --git a/drivers/net/ethernet/8390/smc-ultra.c b/drivers/net/ethernet/8390/smc-ultra.c index 364b6514f65f..4e02f6a23575 100644 --- a/drivers/net/ethernet/8390/smc-ultra.c +++ b/drivers/net/ethernet/8390/smc-ultra.c @@ -561,8 +561,8 @@ static struct net_device *dev_ultra[MAX_ULTRA_CARDS]; static int io[MAX_ULTRA_CARDS]; static int irq[MAX_ULTRA_CARDS]; -module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); +module_param_hw_array(io, int, ioport, NULL, 0); +module_param_hw_array(irq, int, irq, NULL, 0); module_param_named(msg_enable, ultra_msg_enable, uint, (S_IRUSR|S_IRGRP|S_IROTH)); MODULE_PARM_DESC(io, "I/O base address(es)"); MODULE_PARM_DESC(irq, "IRQ number(s) (assigned)"); diff --git a/drivers/net/ethernet/8390/wd.c b/drivers/net/ethernet/8390/wd.c index ad019cbc698f..6efa2722f850 100644 --- a/drivers/net/ethernet/8390/wd.c +++ b/drivers/net/ethernet/8390/wd.c @@ -503,10 +503,10 @@ static int irq[MAX_WD_CARDS]; static int mem[MAX_WD_CARDS]; static int mem_end[MAX_WD_CARDS]; /* for non std. mem size */ -module_param_array(io, int, NULL, 0); -module_param_array(irq, int, NULL, 0); -module_param_array(mem, int, NULL, 0); -module_param_array(mem_end, int, NULL, 0); +module_param_hw_a
[PATCH 16/38] Annotate hardware config module parameters in drivers/net/appletalk/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/net/appletalk/. Suggested-by: Alan Cox Signed-off-by: David Howells cc: Arnaldo Carvalho de Melo cc: netdev@vger.kernel.org --- drivers/net/appletalk/cops.c |6 +++--- drivers/net/appletalk/ltpc.c |6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c index 1b2e9217ec78..486e1e6997fc 100644 --- a/drivers/net/appletalk/cops.c +++ b/drivers/net/appletalk/cops.c @@ -986,9 +986,9 @@ static int cops_close(struct net_device *dev) static struct net_device *cops_dev; MODULE_LICENSE("GPL"); -module_param(io, int, 0); -module_param(irq, int, 0); -module_param(board_type, int, 0); +module_param_hw(io, int, ioport, 0); +module_param_hw(irq, int, irq, 0); +module_param_hw(board_type, int, other, 0); static int __init cops_module_init(void) { diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c index 01e2ac55c137..ac755d2950a6 100644 --- a/drivers/net/appletalk/ltpc.c +++ b/drivers/net/appletalk/ltpc.c @@ -1231,9 +1231,9 @@ static struct net_device *dev_ltpc; MODULE_LICENSE("GPL"); module_param(debug, int, 0); -module_param(io, int, 0); -module_param(irq, int, 0); -module_param(dma, int, 0); +module_param_hw(io, int, ioport, 0); +module_param_hw(irq, int, irq, 0); +module_param_hw(dma, int, dma, 0); static int __init ltpc_module_init(void)
Re: [PATCH 0/4 v2 net-next] net: stmmac: adding multiple buffers
On Wed, Apr 05, 2017 at 05:43:00PM +0100, Joao Pinto wrote: > This patch adds multiple buffers to stmmac in a more fragmented > way, in order to make problem debug easier. > > I would kindly request to people to test this patch in their HWs in > order to check if everything's functional. Thank you. > > Joao Pinto (4): > net: stmmac: break some functions into RX and TX scopes > net: stmmac: adding multiple buffers for RX > net: stmmac: adding multiple buffers for TX > net: stmmac: adding multiple napi mechanism > > drivers/net/ethernet/stmicro/stmmac/chain_mode.c | 45 +- > drivers/net/ethernet/stmicro/stmmac/ring_mode.c | 46 +- > drivers/net/ethernet/stmicro/stmmac/stmmac.h | 49 +- > drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1257 > ++--- > 4 files changed, 947 insertions(+), 450 deletions(-) > > -- > 2.9.3 > Hello I have tested v1 and didn't hit any issue on dwmac-sunxi/dwmac-sun8i. I will test the v2 and send just after my tested-by Regards
[PATCH 18/38] Annotate hardware config module parameters in drivers/net/can/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/net/can/. Suggested-by: Alan Cox Signed-off-by: David Howells Acked-by: Marc Kleine-Budde cc: Wolfgang Grandegger cc: linux-...@vger.kernel.org cc: netdev@vger.kernel.org --- drivers/net/can/cc770/cc770_isa.c |8 drivers/net/can/sja1000/sja1000_isa.c |8 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/net/can/cc770/cc770_isa.c b/drivers/net/can/cc770/cc770_isa.c index e0d15711e9ac..3a30fd3b4498 100644 --- a/drivers/net/can/cc770/cc770_isa.c +++ b/drivers/net/can/cc770/cc770_isa.c @@ -82,16 +82,16 @@ static u8 cor[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff}; static u8 bcr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff}; static int indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1}; -module_param_array(port, ulong, NULL, S_IRUGO); +module_param_hw_array(port, ulong, ioport, NULL, S_IRUGO); MODULE_PARM_DESC(port, "I/O port number"); -module_param_array(mem, ulong, NULL, S_IRUGO); +module_param_hw_array(mem, ulong, iomem, NULL, S_IRUGO); MODULE_PARM_DESC(mem, "I/O memory address"); -module_param_array(indirect, int, NULL, S_IRUGO); +module_param_hw_array(indirect, int, ioport, NULL, S_IRUGO); MODULE_PARM_DESC(indirect, "Indirect access via address and data port"); -module_param_array(irq, int, NULL, S_IRUGO); +module_param_hw_array(irq, int, irq, NULL, S_IRUGO); MODULE_PARM_DESC(irq, "IRQ number"); module_param_array(clk, int, NULL, S_IRUGO); diff --git a/drivers/net/can/sja1000/sja1000_isa.c b/drivers/net/can/sja1000/sja1000_isa.c index e97e6d35b300..a89c1e92554d 100644 --- a/drivers/net/can/sja1000/sja1000_isa.c +++ b/drivers/net/can/sja1000/sja1000_isa.c @@ -48,16 +48,16 @@ static unsigned char ocr[MAXDEV] = {[0 ... (MAXDEV - 1)] = 0xff}; static int indirect[MAXDEV] = {[0 ... (MAXDEV - 1)] = -1}; static spinlock_t indirect_lock[MAXDEV]; /* lock for indirect access mode */ -module_param_array(port, ulong, NULL, S_IRUGO); +module_param_hw_array(port, ulong, ioport, NULL, S_IRUGO); MODULE_PARM_DESC(port, "I/O port number"); -module_param_array(mem, ulong, NULL, S_IRUGO); +module_param_hw_array(mem, ulong, iomem, NULL, S_IRUGO); MODULE_PARM_DESC(mem, "I/O memory address"); -module_param_array(indirect, int, NULL, S_IRUGO); +module_param_hw_array(indirect, int, ioport, NULL, S_IRUGO); MODULE_PARM_DESC(indirect, "Indirect access via address and data port"); -module_param_array(irq, int, NULL, S_IRUGO); +module_param_hw_array(irq, int, irq, NULL, S_IRUGO); MODULE_PARM_DESC(irq, "IRQ number"); module_param_array(clk, int, NULL, S_IRUGO);
Re: [PATCH net-next 3/3] vxlan: allow multiple VXLANs with same VNI for IPv6 link-local addresses
On 03/15/2017 04:22 PM, Jiri Benc wrote: > On Wed, 15 Mar 2017 15:29:29 +0100, Matthias Schiffer wrote: >> While ensuring that the destination address is link-local iff the source >> address is would also be an option, it didn't seem too useful as the >> destination address will be a multicast address anyways in "normal" VXLAN >> configurations. If we really want to check this, I guess the valid >> combinations are: >> >> source link-local - destination link-local UC >> source link-local - destination link-local MC >> source global/... - destination global/... UC >> source global/... - destination any MC >> >> Does this make sense? > > It does. > > Thanks! > > Jiri > While trying to integrate the additional checks, I noticed that the vxlan_dev_configure() function has some serious issues in the changelink case. An (probably incomplete) list of things that can go wrong: - vxlan_dev_configure may return with an error as late the "if (conf->mtu)" branch, after some settings have already been applied to the vxlan_dev or net_device, leading to partial application in some error cases - at the moment, changelink is allowed to change the address family of the source/destionation addresses, but VXLAN_F_IPV6 is never removed, and sockets are not recreated; I think changing the AF should just be disallowed - conf->mtu will be re-applied in changelink even when the lowerdev has not changed, possibly overwriting other MTU changes that have been made after device creation (having conf->mtu in addition to dev->mtu might be a bad idea in general?) Each of the issues could be fixed separately, but at the moment, I'm rather considering cleaning up the code by factoring out a vxlan_cfg_validate() from vxlan_dev_configure(), to clearly separate validation and application of the configuration. Is this the way to go, or do you have other suggestions? -- Matthias signature.asc Description: OpenPGP digital signature
[PATCH 17/38] Annotate hardware config module parameters in drivers/net/arcnet/
When the kernel is running in secure boot mode, we lock down the kernel to prevent userspace from modifying the running kernel image. Whilst this includes prohibiting access to things like /dev/mem, it must also prevent access by means of configuring driver modules in such a way as to cause a device to access or modify the kernel image. To this end, annotate module_param* statements that refer to hardware configuration and indicate for future reference what type of parameter they specify. The parameter parser in the core sees this information and can skip such parameters with an error message if the kernel is locked down. The module initialisation then runs as normal, but just sees whatever the default values for those parameters is. Note that we do still need to do the module initialisation because some drivers have viable defaults set in case parameters aren't specified and some drivers support automatic configuration (e.g. PNP or PCI) in addition to manually coded parameters. This patch annotates drivers in drivers/net/arcnet/. Suggested-by: Alan Cox Signed-off-by: David Howells cc: Michael Grzeschik cc: netdev@vger.kernel.org --- drivers/net/arcnet/com20020-isa.c |4 ++-- drivers/net/arcnet/com90io.c |4 ++-- drivers/net/arcnet/com90xx.c |4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/net/arcnet/com20020-isa.c b/drivers/net/arcnet/com20020-isa.c index b9e9931353b2..38fa60ddaf2e 100644 --- a/drivers/net/arcnet/com20020-isa.c +++ b/drivers/net/arcnet/com20020-isa.c @@ -129,8 +129,8 @@ static int clockp = 0; static int clockm = 0; module_param(node, int, 0); -module_param(io, int, 0); -module_param(irq, int, 0); +module_param_hw(io, int, ioport, 0); +module_param_hw(irq, int, irq, 0); module_param_string(device, device, sizeof(device), 0); module_param(timeout, int, 0); module_param(backplane, int, 0); diff --git a/drivers/net/arcnet/com90io.c b/drivers/net/arcnet/com90io.c index b57863df5bf5..4e56aaf2b984 100644 --- a/drivers/net/arcnet/com90io.c +++ b/drivers/net/arcnet/com90io.c @@ -347,8 +347,8 @@ static int io; /* use the insmod io= irq= shmem= options */ static int irq; static char device[9]; /* use eg. device=arc1 to change name */ -module_param(io, int, 0); -module_param(irq, int, 0); +module_param_hw(io, int, ioport, 0); +module_param_hw(irq, int, irq, 0); module_param_string(device, device, sizeof(device), 0); MODULE_LICENSE("GPL"); diff --git a/drivers/net/arcnet/com90xx.c b/drivers/net/arcnet/com90xx.c index 81f90c4703ae..ca4a57c30bf8 100644 --- a/drivers/net/arcnet/com90xx.c +++ b/drivers/net/arcnet/com90xx.c @@ -88,8 +88,8 @@ static int irq; static int shmem; static char device[9]; /* use eg. device=arc1 to change name */ -module_param(io, int, 0); -module_param(irq, int, 0); +module_param_hw(io, int, ioport, 0); +module_param_hw(irq, int, irq, 0); module_param(shmem, int, 0); module_param_string(device, device, sizeof(device), 0);
Re: pull-request: can-next 2017-03-03,pull-request: can-next 2017-03-03
From: Marc Kleine-Budde Date: Tue, 4 Apr 2017 17:47:28 +0200 > this is a pull request of 5 patches for net-next/master. > > There are two patches by Yegor Yefremov which convert the ti_hecc > driver into a DT only driver, as there is no in-tree user of the old > platform driver interface anymore. The next patch by Mario Kicherer > adds network namespace support to the can subsystem. The last two > patches by Akshay Bhat add support for the holt_hi311x SPI CAN driver. Pulled, thanks Marc.