* Re: [net PATCH v5 6/6] virtio_net: XDP support for adjust_head
From: Jason Wang @ 2017-01-18 3:35 UTC (permalink / raw)
To: John Fastabend, mst; +Cc: john.r.fastabend, netdev, alexei.starovoitov, daniel
In-Reply-To: <20170117222259.20280.24625.stgit@john-Precision-Tower-5810>
On 2017年01月18日 06:22, John Fastabend wrote:
>
> +static int virtnet_reset(struct virtnet_info *vi)
> +{
> + struct virtio_device *dev = vi->vdev;
> + int ret;
> +
> + virtio_config_disable(dev);
> + dev->failed = dev->config->get_status(dev) & VIRTIO_CONFIG_S_FAILED;
> + virtnet_freeze_down(dev);
> + _remove_vq_common(vi);
> +
> + dev->config->reset(dev);
> + virtio_add_status(dev, VIRTIO_CONFIG_S_ACKNOWLEDGE);
> + virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER);
> +
> + ret = virtio_finalize_features(dev);
> + if (ret)
> + goto err;
> +
> + ret = virtnet_restore_up(dev);
> + if (ret)
> + goto err;
> + ret = _virtnet_set_queues(vi, vi->curr_queue_pairs);
> + if (ret)
> + goto err;
> +
> + virtio_add_status(dev, VIRTIO_CONFIG_S_DRIVER_OK);
> + virtio_config_enable(dev);
> + return 0;
> +err:
> + virtio_add_status(dev, VIRTIO_CONFIG_S_FAILED);
> + return ret;
> +}
> +
Hi John:
I still prefer not open code (part of) virtio_device_freeze() and
virtio_device_restore() here. How about:
1) introduce __virtio_device_freeze/__virtio_device_restore which
accepts a function pointer of free/restore
2) for virtio_device_freeze/virtio_device_restore just pass
drv->freeze/drv->restore (locked version)
3) for virtnet_reset(), we can pass unlocked version of freeze and restore
Just my preference, if both Michael and you stick to this, I'm also fine.
Thanks
^ permalink raw reply
* RE: [PATCH] net: fec: Fixed panic problem with non-tso
From: Ashizuka, Yuusuke @ 2017-01-18 3:12 UTC (permalink / raw)
To: Andy Duan; +Cc: netdev@vger.kernel.org
In-Reply-To: <AM4PR0401MB2260E5BE096D7B86EDF4F04FFF7C0@AM4PR0401MB2260.eurprd04.prod.outlook.com>
> -----Original Message-----
> From: Andy Duan [mailto:fugang.duan@nxp.com]
> Sent: Tuesday, January 17, 2017 8:02 PM
> To: Ashizuka, Yuusuke/芦塚 雄介
> Cc: netdev@vger.kernel.org
> Subject: RE: [PATCH] net: fec: Fixed panic problem with non-tso
>
> From: Yuusuke Ashiduka <ashiduka@jp.fujitsu.com> Sent: Tuesday, January
> 17, 2017 3:48 PM
> >To: Andy Duan <fugang.duan@nxp.com>
> >Cc: netdev@vger.kernel.org; Yuusuke Ashiduka <ashiduka@jp.fujitsu.com>
> >Subject: [PATCH] net: fec: Fixed panic problem with non-tso
> >
> >If highmem and 2GB or more of memory are valid, "this_frag-> page.p"
> >indicates the highmem area, so the result of page_address() is NULL and
> >panic occurs.
> >
> >This commit fixes this by using the skb_frag_dma_map() helper, which
> >takes care of mapping the skb fragment properly. Additionally, the type
> >of mapping is now tracked, so it can be unmapped using dma_unmap_page
> >or dma_unmap_single when appropriate.
> >---
> > drivers/net/ethernet/freescale/fec.h | 1 +
> > drivers/net/ethernet/freescale/fec_main.c | 48
> >+++++++++++++++++++++++--------
> > 2 files changed, 37 insertions(+), 12 deletions(-)
> >
> The patch itself seems fine.
> The driver doesn't support skb from highmem, if to support highmem, it should
> add frag_skb (highmem) support for tso and non-tso.
> In driver net/core/tso.c, it also add highmem support, right ?
indeed.
In the case of TSO with i.MX6 system (highmem enabled) with 2GB memory,
"this_frag->page.p" did not become highmem area.
(We confirmed by transferring about 100MB of files)
However, in the case of non-tso on an i.MX6 system with 2GB of memory,
"this_frag->page.p" may become a highmem area.
(Occurred with approximately 2MB of file transfer)
For non-tso only, I do not know the reason why "this_frag-> page.p"
in this driver shows highmem area.
Thanks.
>
> Thanks.
>
> >diff --git a/drivers/net/ethernet/freescale/fec.h
> >b/drivers/net/ethernet/freescale/fec.h
> >index 5ea740b4cf14..5b187e8aacf0 100644
> >--- a/drivers/net/ethernet/freescale/fec.h
> >+++ b/drivers/net/ethernet/freescale/fec.h
> >@@ -463,6 +463,7 @@ struct bufdesc_prop { struct fec_enet_priv_tx_q {
> > struct bufdesc_prop bd;
> > unsigned char *tx_bounce[TX_RING_SIZE];
> >+ int tx_page_mapping[TX_RING_SIZE];
> > struct sk_buff *tx_skbuff[TX_RING_SIZE];
> >
> > unsigned short tx_stop_threshold;
> >diff --git a/drivers/net/ethernet/freescale/fec_main.c
> >b/drivers/net/ethernet/freescale/fec_main.c
> >index 38160c2bebcb..b1562107e337 100644
> >--- a/drivers/net/ethernet/freescale/fec_main.c
> >+++ b/drivers/net/ethernet/freescale/fec_main.c
> >@@ -60,6 +60,7 @@
> > #include <linux/if_vlan.h>
> > #include <linux/pinctrl/consumer.h>
> > #include <linux/prefetch.h>
> >+#include <linux/highmem.h>
> > #include <soc/imx/cpuidle.h>
> >
> > #include <asm/cacheflush.h>
> >@@ -377,20 +378,28 @@ fec_enet_txq_submit_frag_skb(struct
> >fec_enet_priv_tx_q *txq,
> > ebdp->cbd_esc = cpu_to_fec32(estatus);
> > }
> >
> >- bufaddr = page_address(this_frag->page.p) + this_frag-
> >>page_offset;
> >-
> > index = fec_enet_get_bd_index(bdp, &txq->bd);
> >- if (((unsigned long) bufaddr) & fep->tx_align ||
> >+ txq->tx_page_mapping[index] = 0;
> >+ if (this_frag->page_offset & fep->tx_align ||
> > fep->quirks & FEC_QUIRK_SWAP_FRAME) {
> >+ bufaddr = kmap_atomic(this_frag->page.p) +
> >+
> this_frag->page_offset;
> > memcpy(txq->tx_bounce[index], bufaddr,
> frag_len);
> >+ kunmap_atomic(bufaddr);
> > bufaddr = txq->tx_bounce[index];
> >
> > if (fep->quirks & FEC_QUIRK_SWAP_FRAME)
> > swap_buffer(bufaddr, frag_len);
> >+ addr = dma_map_single(&fep->pdev->dev,
> >+ bufaddr,
> >+ frag_len,
> >+ DMA_TO_DEVICE);
> >+ } else {
> >+ txq->tx_page_mapping[index] = 1;
> >+ addr = skb_frag_dma_map(&fep->pdev->dev,
> >this_frag, 0,
> >+ frag_len,
> DMA_TO_DEVICE);
> > }
> >
> >- addr = dma_map_single(&fep->pdev->dev, bufaddr,
> frag_len,
> >- DMA_TO_DEVICE);
> > if (dma_mapping_error(&fep->pdev->dev, addr)) {
> > if (net_ratelimit())
> > netdev_err(ndev, "Tx DMA memory map
> failed\n"); @@ -411,8 +420,16
> >@@ fec_enet_txq_submit_frag_skb(struct
> >fec_enet_priv_tx_q *txq,
> > bdp = txq->bd.cur;
> > for (i = 0; i < frag; i++) {
> > bdp = fec_enet_get_nextdesc(bdp, &txq->bd);
> >- dma_unmap_single(&fep->pdev->dev, fec32_to_cpu(bdp-
> >>cbd_bufaddr),
> >- fec16_to_cpu(bdp->cbd_datlen),
> >DMA_TO_DEVICE);
> >+ if (txq->tx_page_mapping[index])
> >+ dma_unmap_page(&fep->pdev->dev,
> >+ fec32_to_cpu(bdp->cbd_bufaddr),
> >+ fec16_to_cpu(bdp->cbd_datlen),
> >+ DMA_TO_DEVICE);
> >+ else
> >+ dma_unmap_single(&fep->pdev->dev,
> >+
> fec32_to_cpu(bdp->cbd_bufaddr),
> >+
> fec16_to_cpu(bdp->cbd_datlen),
> >+ DMA_TO_DEVICE);
> > }
> > return ERR_PTR(-ENOMEM);
> > }
> >@@ -1201,11 +1218,18 @@ fec_enet_tx_queue(struct net_device *ndev, u16
> >queue_id)
> >
> > skb = txq->tx_skbuff[index];
> > txq->tx_skbuff[index] = NULL;
> >- if (!IS_TSO_HEADER(txq,
> fec32_to_cpu(bdp->cbd_bufaddr)))
> >- dma_unmap_single(&fep->pdev->dev,
> >-
> fec32_to_cpu(bdp->cbd_bufaddr),
> >-
> fec16_to_cpu(bdp->cbd_datlen),
> >- DMA_TO_DEVICE);
> >+ if (!IS_TSO_HEADER(txq,
> fec32_to_cpu(bdp->cbd_bufaddr)))
> >{
> >+ if (txq->tx_page_mapping[index])
> >+ dma_unmap_page(&fep->pdev->dev,
> >+
> fec32_to_cpu(bdp->cbd_bufaddr),
> >+
> fec16_to_cpu(bdp->cbd_datlen),
> >+ DMA_TO_DEVICE);
> >+ else
> >+ dma_unmap_single(&fep->pdev->dev,
> >+ fec32_to_cpu(bdp-
> >>cbd_bufaddr),
> >+ fec16_to_cpu(bdp-
> >>cbd_datlen),
> >+ DMA_TO_DEVICE);
> >+ }
> > bdp->cbd_bufaddr = cpu_to_fec32(0);
> > if (!skb)
> > goto skb_done;
> >--
> >2.11.0
^ permalink raw reply
* RE: [PATCH] net: fec: Fixed panic problem with non-tso
From: Ashizuka, Yuusuke @ 2017-01-18 3:20 UTC (permalink / raw)
To: David Miller; +Cc: fugang.duan@nxp.com, netdev@vger.kernel.org
In-Reply-To: <20170117.154512.612465430064515761.davem@davemloft.net>
> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Wednesday, January 18, 2017 5:45 AM
> To: Ashizuka, Yuusuke/芦塚 雄介
> Cc: fugang.duan@nxp.com; netdev@vger.kernel.org
> Subject: Re: [PATCH] net: fec: Fixed panic problem with non-tso
>
> From: Yuusuke Ashiduka <ashiduka@jp.fujitsu.com>
> Date: Tue, 17 Jan 2017 16:48:20 +0900
>
> > If highmem and 2GB or more of memory are valid, "this_frag-> page.p"
> > indicates the highmem area, so the result of page_address() is NULL
> > and panic occurs.
> >
> > This commit fixes this by using the skb_frag_dma_map() helper, which
> > takes care of mapping the skb fragment properly. Additionally, the
> > type of mapping is now tracked, so it can be unmapped using
> > dma_unmap_page or dma_unmap_single when appropriate.
>
> This patch submission is lacking a proper signoff.
Thank you for pointing out my mistake.
I will submit the patch again.
^ permalink raw reply
* [PATCH net] bnxt_en: Fix "uninitialized variable" bug in TPA code path.
From: Michael Chan @ 2017-01-18 3:07 UTC (permalink / raw)
To: davem; +Cc: netdev, andrew.gospodarek
In the TPA GRO code path, initialize the tcp_opt_len variable to 0 so
that it will be correct for packets without TCP timestamps. The bug
caused the SKB fields to be incorrectly set up for packets without
TCP timestamps, leading to these packets being rejected by the stack.
Reported-by: Andy Gospodarek <andrew.gospodarek@broadocm.com>
Acked-by: Andy Gospodarek <andrew.gospodarek@broadocm.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 9608cb4..53e686f 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -1099,7 +1099,7 @@ static struct sk_buff *bnxt_gro_func_5730x(struct bnxt_tpa_info *tpa_info,
{
#ifdef CONFIG_INET
struct tcphdr *th;
- int len, nw_off, tcp_opt_len;
+ int len, nw_off, tcp_opt_len = 0;
if (tcp_ts)
tcp_opt_len = 12;
--
1.8.3.1
^ permalink raw reply related
* Re: [PATCH] net: ethernet: stmmac: add ARP management
From: kbuild test robot @ 2017-01-18 2:51 UTC (permalink / raw)
To: Christophe Roullier
Cc: kbuild-all, Alexandre Torgue, Giuseppe Cavallaro, netdev,
linux-kernel, Christophe Roullier
In-Reply-To: <1484672200-7755-1-git-send-email-christophe.roullier@st.com>
[-- Attachment #1: Type: text/plain, Size: 2222 bytes --]
Hi Christophe,
[auto build test WARNING on net-next/master]
[also build test WARNING on next-20170117]
[cannot apply to v4.10-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Christophe-Roullier/net-ethernet-stmmac-add-ARP-management/20170118-084026
config: x86_64-kexec (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
All warnings (new ones prefixed by >>):
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c: In function 'stmmac_dvr_probe':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3296:11: warning: passing argument 3 of 'priv->hw->dma->set_arp_addr' makes integer from pointer without a cast [-Wint-conversion]
priv->dev->dev_addr);
^~~~
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c:3296:11: note: expected 'u32 {aka unsigned int}' but argument is of type 'unsigned char *'
vim +3296 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
3280 NETIF_F_RXCSUM;
3281
3282 if ((priv->plat->tso_en) && (priv->dma_cap.tsoen)) {
3283 ndev->hw_features |= NETIF_F_TSO;
3284 priv->tso = true;
3285 dev_info(priv->device, "TSO feature enabled\n");
3286 }
3287
3288 if ((priv->plat->arp_en) && (priv->dma_cap.arpoffsel)) {
3289 ret = priv->hw->mac->arp_en(priv->hw);
3290 if (!ret) {
3291 pr_warn(" ARP feature disabled\n");
3292 } else {
3293 pr_info(" ARP feature enabled\n");
3294 /* Copy MAC addr into MAC_ARP_ADDRESS register*/
3295 priv->hw->dma->set_arp_addr(priv->ioaddr, 1,
> 3296 priv->dev->dev_addr);
3297 }
3298 }
3299
3300 ndev->features |= ndev->hw_features | NETIF_F_HIGHDMA;
3301 ndev->watchdog_timeo = msecs_to_jiffies(watchdog);
3302 #ifdef STMMAC_VLAN_TAG_USED
3303 /* Both mac100 and gmac support receive VLAN tag detection */
3304 ndev->features |= NETIF_F_HW_VLAN_CTAG_RX;
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 24430 bytes --]
^ permalink raw reply
* [PATCH net-next 2/2] net: dsa: use cpu_switch instead of ds[0]
From: Vivien Didelot @ 2017-01-18 1:41 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
In-Reply-To: <20170118014139.31417-1-vivien.didelot@savoirfairelinux.com>
Now that the DSA Ethernet switches are true Linux devices, the CPU
switch is not necessarily the first one. If its address is higher than
the second switch on the same MDIO bus, its index will be 1, not 0.
Avoid any confusion by using dst->cpu_switch instead of dst->ds[0].
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
net/dsa/dsa.c | 2 +-
net/dsa/dsa2.c | 8 ++++----
net/dsa/slave.c | 6 +++---
net/dsa/tag_brcm.c | 2 +-
net/dsa/tag_qca.c | 2 +-
net/dsa/tag_trailer.c | 2 +-
6 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index cb42655ba7da..87f2a9c9fa12 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -868,7 +868,7 @@ static void dsa_remove_dst(struct dsa_switch_tree *dst)
dsa_switch_destroy(ds);
}
- dsa_cpu_port_ethtool_restore(dst->ds[0]);
+ dsa_cpu_port_ethtool_restore(dst->cpu_switch);
dev_put(dst->master_netdev);
}
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index a9bf28d9f41f..634c6700a179 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -381,8 +381,8 @@ static int dsa_dst_apply(struct dsa_switch_tree *dst)
return err;
}
- if (dst->ds[0]) {
- err = dsa_cpu_port_ethtool_setup(dst->ds[0]);
+ if (dst->cpu_switch) {
+ err = dsa_cpu_port_ethtool_setup(dst->cpu_switch);
if (err)
return err;
}
@@ -426,8 +426,8 @@ static void dsa_dst_unapply(struct dsa_switch_tree *dst)
dsa_ds_unapply(dst, ds);
}
- if (dst->ds[0])
- dsa_cpu_port_ethtool_restore(dst->ds[0]);
+ if (dst->cpu_switch)
+ dsa_cpu_port_ethtool_restore(dst->cpu_switch);
pr_info("DSA: tree %d unapplied\n", dst->tree);
dst->applied = false;
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 0cdcaf526987..b8e58689a9a1 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -781,7 +781,7 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
uint64_t *data)
{
struct dsa_switch_tree *dst = dev->dsa_ptr;
- struct dsa_switch *ds = dst->ds[0];
+ struct dsa_switch *ds = dst->cpu_switch;
s8 cpu_port = dst->cpu_port;
int count = 0;
@@ -798,7 +798,7 @@ static void dsa_cpu_port_get_ethtool_stats(struct net_device *dev,
static int dsa_cpu_port_get_sset_count(struct net_device *dev, int sset)
{
struct dsa_switch_tree *dst = dev->dsa_ptr;
- struct dsa_switch *ds = dst->ds[0];
+ struct dsa_switch *ds = dst->cpu_switch;
int count = 0;
if (dst->master_ethtool_ops.get_sset_count)
@@ -814,7 +814,7 @@ static void dsa_cpu_port_get_strings(struct net_device *dev,
uint32_t stringset, uint8_t *data)
{
struct dsa_switch_tree *dst = dev->dsa_ptr;
- struct dsa_switch *ds = dst->ds[0];
+ struct dsa_switch *ds = dst->cpu_switch;
s8 cpu_port = dst->cpu_port;
int len = ETH_GSTRING_LEN;
int mcount = 0, count;
diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c
index 21bffde6e4bf..af82927674e0 100644
--- a/net/dsa/tag_brcm.c
+++ b/net/dsa/tag_brcm.c
@@ -102,7 +102,7 @@ static int brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
if (unlikely(dst == NULL))
goto out_drop;
- ds = dst->ds[0];
+ ds = dst->cpu_switch;
skb = skb_unshare(skb, GFP_ATOMIC);
if (skb == NULL)
diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c
index 0c90cacee7aa..736ca8e8c31e 100644
--- a/net/dsa/tag_qca.c
+++ b/net/dsa/tag_qca.c
@@ -104,7 +104,7 @@ static int qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
/* This protocol doesn't support cascading multiple switches so it's
* safe to assume the switch is first in the tree
*/
- ds = dst->ds[0];
+ ds = dst->cpu_switch;
if (!ds)
goto out_drop;
diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c
index 5e3903eb1afa..271128a2dc64 100644
--- a/net/dsa/tag_trailer.c
+++ b/net/dsa/tag_trailer.c
@@ -67,7 +67,7 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev,
if (unlikely(dst == NULL))
goto out_drop;
- ds = dst->ds[0];
+ ds = dst->cpu_switch;
skb = skb_unshare(skb, GFP_ATOMIC);
if (skb == NULL)
--
2.11.0
^ permalink raw reply related
* [PATCH net-next 1/2] net: dsa: store CPU switch structure in the tree
From: Vivien Didelot @ 2017-01-18 1:41 UTC (permalink / raw)
To: netdev
Cc: linux-kernel, kernel, David S. Miller, Florian Fainelli,
Andrew Lunn, Vivien Didelot
Store a dsa_switch pointer to the CPU switch in the tree instead of only
its index. This avoids the need to initialize it to -1.
Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
include/net/dsa.h | 8 ++++----
net/dsa/dsa.c | 7 +++----
net/dsa/dsa2.c | 5 ++---
3 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/include/net/dsa.h b/include/net/dsa.h
index 454667952d6d..82f7019f27f2 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -124,7 +124,7 @@ struct dsa_switch_tree {
/*
* The switch and port to which the CPU is attached.
*/
- s8 cpu_switch;
+ struct dsa_switch *cpu_switch;
s8 cpu_port;
/*
@@ -211,7 +211,7 @@ struct dsa_switch {
static inline bool dsa_is_cpu_port(struct dsa_switch *ds, int p)
{
- return !!(ds->index == ds->dst->cpu_switch && p == ds->dst->cpu_port);
+ return !!(ds == ds->dst->cpu_switch && p == ds->dst->cpu_port);
}
static inline bool dsa_is_dsa_port(struct dsa_switch *ds, int p)
@@ -234,10 +234,10 @@ static inline u8 dsa_upstream_port(struct dsa_switch *ds)
* Else return the (DSA) port number that connects to the
* switch that is one hop closer to the cpu.
*/
- if (dst->cpu_switch == ds->index)
+ if (dst->cpu_switch == ds)
return dst->cpu_port;
else
- return ds->rtable[dst->cpu_switch];
+ return ds->rtable[dst->cpu_switch->index];
}
struct switchdev_trans;
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 96d1544df518..cb42655ba7da 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -225,12 +225,12 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
continue;
if (!strcmp(name, "cpu")) {
- if (dst->cpu_switch != -1) {
+ if (!dst->cpu_switch) {
netdev_err(dst->master_netdev,
"multiple cpu ports?!\n");
return -EINVAL;
}
- dst->cpu_switch = index;
+ dst->cpu_switch = ds;
dst->cpu_port = i;
ds->cpu_port_mask |= 1 << i;
} else if (!strcmp(name, "dsa")) {
@@ -254,7 +254,7 @@ static int dsa_switch_setup_one(struct dsa_switch *ds, struct device *parent)
* tagging protocol to the preferred tagging format of this
* switch.
*/
- if (dst->cpu_switch == index) {
+ if (dst->cpu_switch == ds) {
enum dsa_tag_protocol tag_protocol;
tag_protocol = ops->get_tag_protocol(ds);
@@ -757,7 +757,6 @@ static int dsa_setup_dst(struct dsa_switch_tree *dst, struct net_device *dev,
dst->pd = pd;
dst->master_netdev = dev;
- dst->cpu_switch = -1;
dst->cpu_port = -1;
for (i = 0; i < pd->nr_chips; i++) {
diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index a1f26fc0f585..a9bf28d9f41f 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -57,7 +57,6 @@ static struct dsa_switch_tree *dsa_add_dst(u32 tree)
if (!dst)
return NULL;
dst->tree = tree;
- dst->cpu_switch = -1;
INIT_LIST_HEAD(&dst->list);
list_add_tail(&dsa_switch_trees, &dst->list);
kref_init(&dst->refcount);
@@ -456,8 +455,8 @@ static int dsa_cpu_parse(struct device_node *port, u32 index,
if (!dst->master_netdev)
dst->master_netdev = ethernet_dev;
- if (dst->cpu_switch == -1) {
- dst->cpu_switch = ds->index;
+ if (!dst->cpu_switch) {
+ dst->cpu_switch = ds;
dst->cpu_port = index;
}
--
2.11.0
^ permalink raw reply related
* Re: [PATCH 3/4] net: ethernet: ti: cpsw: don't duplicate ndev_running
From: Ivan Khoronzhuk @ 2017-01-18 1:30 UTC (permalink / raw)
To: Grygorii Strashko
Cc: netdev, Eric Dumazet, David S. Miller, mugunthanvnm, linux-omap,
linux-kernel, Florian Fainelli
In-Reply-To: <2eb8a083-41e8-e7ec-17dc-36626ac68f00@ti.com>
On Thu, Jan 12, 2017 at 11:34:47AM -0600, Grygorii Strashko wrote:
Hi Grygorii,
Sorry for late reply.
>
>
> On 01/10/2017 07:56 PM, Ivan Khoronzhuk wrote:
> > On Mon, Jan 09, 2017 at 11:25:38AM -0600, Grygorii Strashko wrote:
> >>
> >>
> >> On 01/08/2017 10:41 AM, Ivan Khoronzhuk wrote:
> >>> No need to create additional vars to identify if interface is running.
> >>> So simplify code by removing redundant var and checking usage counter
> >>> instead.
> >>>
> >>> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
> >>> ---
> >>> drivers/net/ethernet/ti/cpsw.c | 14 ++++----------
> >>> 1 file changed, 4 insertions(+), 10 deletions(-)
> >>>
> >>> diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
> >>> index 40d7fc9..daae87f 100644
> >>> --- a/drivers/net/ethernet/ti/cpsw.c
> >>> +++ b/drivers/net/ethernet/ti/cpsw.c
> >>> @@ -357,7 +357,6 @@ struct cpsw_slave {
> >>> struct phy_device *phy;
> >>> struct net_device *ndev;
> >>> u32 port_vlan;
> >>> - u32 open_stat;
> >>> };
> >>>
> >>> static inline u32 slave_read(struct cpsw_slave *slave, u32 offset)
> >>> @@ -1241,7 +1240,7 @@ static int cpsw_common_res_usage_state(struct cpsw_common *cpsw)
> >>> u32 usage_count = 0;
> >>>
> >>> for (i = 0; i < cpsw->data.slaves; i++)
> >>> - if (cpsw->slaves[i].open_stat)
> >>> + if (netif_running(cpsw->slaves[i].ndev))
> >>> usage_count++;
> >>
> >> Not sure this will work as you expected, but may be I've missed smth :(
> > I've changed conditions, will work.
> >
> >>
> >> code in static int __dev_open(struct net_device *dev)
> >> ..
> >> set_bit(__LINK_STATE_START, &dev->state);
> >>
> >> if (ops->ndo_validate_addr)
> >> ret = ops->ndo_validate_addr(dev);
> >>
> >> if (!ret && ops->ndo_open)
> >> ret = ops->ndo_open(dev);
> >>
> >> netpoll_poll_enable(dev);
> >>
> >> if (ret)
> >> clear_bit(__LINK_STATE_START, &dev->state);
> >> ..
> >>
> >> so, netif_running(ndev) will start returning true before calling ops->ndo_open(dev);
> > Yes, It's done bearing it in mind of course.
> >
> >>
> >>>
> >>> return usage_count;
> >>> @@ -1502,7 +1501,7 @@ static int cpsw_ndo_open(struct net_device *ndev)
> >>> CPSW_RTL_VERSION(reg));
> >>>
> >>> /* initialize host and slave ports */
> >>> - if (!cpsw_common_res_usage_state(cpsw))
> >>> + if (cpsw_common_res_usage_state(cpsw) < 2)
> >>
> >> Ah. You've changed the condition here.
> >>
> >> I think it might be reasonable to hide this inside cpsw_common_res_usage_state()
> >> and seems it can be renamed to smth like cpsw_is_running().
> > It probably needs to be renamed to smth a little different,
> > like cpsw_get_usage_count ...or cpsw_get_open_ndev_count
>
> cpsw_get_usage_count () sounds good
Like it more also. Will change it.
>
> >
> >>
> >>
> >>> cpsw_init_host_port(priv);
> >>> for_each_slave(priv, cpsw_slave_open, priv);
> >>>
> >>> @@ -1513,7 +1512,7 @@ static int cpsw_ndo_open(struct net_device *ndev)
> >>> cpsw_ale_add_vlan(cpsw->ale, cpsw->data.default_vlan,
> >>> ALE_ALL_PORTS, ALE_ALL_PORTS, 0, 0);
> >>>
> >>> - if (!cpsw_common_res_usage_state(cpsw)) {
> >>> + if (cpsw_common_res_usage_state(cpsw) < 2) {
> >>> /* disable priority elevation */
> >>> __raw_writel(0, &cpsw->regs->ptype);
> >>>
> >>> @@ -1556,9 +1555,6 @@ static int cpsw_ndo_open(struct net_device *ndev)
> >>> cpdma_ctlr_start(cpsw->dma);
> >>> cpsw_intr_enable(cpsw);
> >>>
> >>> - if (cpsw->data.dual_emac)
> >>> - cpsw->slaves[priv->emac_port].open_stat = true;
> >>> -
> >>> return 0;
> >>>
> >>> err_cleanup:
> >>> @@ -1578,7 +1574,7 @@ static int cpsw_ndo_stop(struct net_device *ndev)
> >>> netif_tx_stop_all_queues(priv->ndev);
> >>> netif_carrier_off(priv->ndev);
> >>>
> >>> - if (cpsw_common_res_usage_state(cpsw) <= 1) {
> >>> + if (!cpsw_common_res_usage_state(cpsw)) {
> >>
> >> and here __LINK_STATE_START will be cleared before calling ops->ndo_stop(dev);
> > Actually it's changed because of it.
> >
> >> So, from one side netif_running(ndev) usage will simplify cpsw_common_res_usage_state() internals,
> >> but from another side - it will make places where it's used even more entangled :( as for me,
> >> because when cpsw_common_res_usage_state() will return 1 in cpsw_ndo_open() it will mean
> >> "no interfaces is really running yet", but the same value 1 in cpsw_ndo_stop()
> > why not? no interfaces running, except the one excuting ndo_open now.
> > It's more clear then duplicating it and using two different ways in
> > different places for identifing running devices. Current way more
> > close to some testing code, not final version. Just to be consistent
> > better to change it.
> >
> > Yes, it returns different results when it's called from ndo_close and
> > ndo_open. Maybe name for the function is not very close to an action
> > it's doing, it declares more intention, and even not for every case.
> > What about to rename it to some cpsw_get_open_ndev_count and add
> > comments in several places explaining what it actually do.
>
> yes. please. comments are required at least.
>
> its actually a question why __LINK_STATE_START is managed this way in ./net/core/dev.c
>
> __dev_open()
> set_bit(__LINK_STATE_START, &dev->state); <---- before .ndo_open()
>
> if (!ret && ops->ndo_open)
> ret = ops->ndo_open(dev);
>
> <---- shouldn't set_bit(__LINK_STATE_START, &dev->state) be after calling .ndo_open() ??
By logic yes, but in another way it looks like it 's done intentionally.
Some code can be based on it, some that can be executed while .ndo_open
and after. And it should act the same in both cases. In case of cpsw, at least
cpsw_adjust_link() can be called while .ndo_open and also after, but in both
cases it's supposed that flag is set. In case of cpsw_adjust_link() there is no
way to predict when it will be called, so here only one way - set
__LINK_STATE_START before .ndo_open(), result - flag is set in any case already.
Maybe that is one of the reasons of such sequence.
Changing the logic can bring a lot of headache, don't want to touch it here.
>
> __dev_close_many()
>
> clear_bit(__LINK_STATE_START, &dev->state); <-stop sequence is differ from open.
Yes, and it doens't have postponed tasks like .ndo_open.
>
> if (ops->ndo_stop)
> ops->ndo_stop(dev);
>
>
> --
> regards,
> -grygorii
^ permalink raw reply
* Re: [PATCH v3 net-next] net:add one common config ARCH_WANT_RELAX_ORDER to support relax ordering
From: Alexander Duyck @ 2017-01-18 1:24 UTC (permalink / raw)
To: Mao Wenan; +Cc: Netdev, Jeff Kirsher
In-Reply-To: <1484700605-2412-1-git-send-email-maowenan@huawei.com>
On Tue, Jan 17, 2017 at 4:50 PM, Mao Wenan <maowenan@huawei.com> wrote:
> Relax ordering(RO) is one feature of 82599 NIC, to enable this feature can
> enhance the performance for some cpu architecure, such as SPARC and so on.
> 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 patch add one common config CONFIG_ARCH_WANT_RELAX_ORDER to set RO feature,
> and should define CONFIG_ARCH_WANT_RELAX_ORDER in sparc Kconfig firstly.
>
> Signed-off-by: Mao Wenan <maowenan@huawei.com>
> Reviewed-by: Alexander Duyck <alexander.duyck@gmail.com>
Reviewed-by: Alexander Duyck <alexander.h.duyck@intel.com>
> ---
> v2 -> v3: add reviewed information.
> ---
> arch/Kconfig | 3 +++
> arch/sparc/Kconfig | 1 +
> drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 2 +-
> 3 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/Kconfig b/arch/Kconfig
> index 99839c2..bd04eac 100644
> --- a/arch/Kconfig
> +++ b/arch/Kconfig
> @@ -781,4 +781,7 @@ config VMAP_STACK
> the stack to map directly to the KASAN shadow map using a formula
> that is incorrect if the stack is in vmalloc space.
>
> +config ARCH_WANT_RELAX_ORDER
> + bool
> +
> source "kernel/gcov/Kconfig"
> diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
> index cf4034c..68ac5c7 100644
> --- a/arch/sparc/Kconfig
> +++ b/arch/sparc/Kconfig
> @@ -44,6 +44,7 @@ config SPARC
> select CPU_NO_EFFICIENT_FFS
> select HAVE_ARCH_HARDENED_USERCOPY
> select PROVE_LOCKING_SMALL if PROVE_LOCKING
> + select ARCH_WANT_RELAX_ORDER
>
> config SPARC32
> def_bool !64BIT
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
> index 094e1d6..c38d50c 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
> @@ -350,7 +350,7 @@ s32 ixgbe_start_hw_gen2(struct ixgbe_hw *hw)
> }
> IXGBE_WRITE_FLUSH(hw);
>
> -#ifndef CONFIG_SPARC
> +#ifndef CONFIG_ARCH_WANT_RELAX_ORDER
> /* Disable relaxed ordering */
> for (i = 0; i < hw->mac.max_tx_queues; i++) {
> u32 regval;
> --
> 2.7.0
>
>
^ permalink raw reply
* RE: GOOD NEWS
From: Khokhar, Kashif @ 2017-01-18 0:47 UTC (permalink / raw)
In-Reply-To: <EE27FBD0E42D5749B421597090D4581AA771D40C@SMESEXCP014041.msnyuhealth.org>
A donation was made to you . Contact ( antoiaxjohnson@yahoo.com ) for details...
^ permalink raw reply
* Re: [PATCH RFC] net: dsa: remove unnecessary phy.h include
From: Florian Fainelli @ 2017-01-18 1:13 UTC (permalink / raw)
To: Russell King - ARM Linux, Andrew Lunn, Vivien Didelot
Cc: David S. Miller, netdev, linux-kernel
In-Reply-To: <20170118001403.GJ27312@n2100.armlinux.org.uk>
On 01/17/2017 04:14 PM, Russell King - ARM Linux wrote:
> Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
> unnecessary dependency for quite a large amount of the kernel. There's
> very little which actually requires definitions from phy.h in net/dsa.h
> - the include itself only wants the declaration of a couple of
> structures and IFNAMSIZ.
>
> Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
> mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
> and phy_fixed.h from net/dsa.h.
>
> This patch reduces from around 800 files rebuilt to around 40 - even
> with ccache, the time difference is noticable.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> I noticed when I touched linux/phy.h that a lot of the kernel ended up
> being unexpectedly rebuilt, as linux/netdevice.h includes net/dsa.h,
> which then then includes linux/phy.h. I've tested this change on both
> ARM and ARM64, but I'd suggest letting the 0-day builder have a bite
> at this, and then only taking it if everyone is confident that there's
> a slim chance of any problems. Also, it may need some rework to apply
> to davem's tree. All of the above makes this RFC only.
>
> drivers/net/dsa/mv88e6xxx/mv88e6xxx.h | 1 +
> include/net/dsa.h | 6 ++++--
> 2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
> index a319c06d82e3..d247b0639ed4 100644
> --- a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
> +++ b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
> @@ -15,6 +15,7 @@
> #include <linux/if_vlan.h>
> #include <linux/irq.h>
> #include <linux/gpio/consumer.h>
> +#include <linux/phy.h>
>
> #ifndef UINT64_MAX
> #define UINT64_MAX (u64)(~((u64)0))
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index b122196d5a1f..887b2f98f9ea 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -11,15 +11,17 @@
> #ifndef __LINUX_NET_DSA_H
> #define __LINUX_NET_DSA_H
>
> +#include <linux/if.h>
> #include <linux/if_ether.h>
> #include <linux/list.h>
> #include <linux/timer.h>
> #include <linux/workqueue.h>
> #include <linux/of.h>
> -#include <linux/phy.h>
> -#include <linux/phy_fixed.h>
> #include <linux/ethtool.h>
>
> +struct phy_device;
> +struct fixed_phy_status;
> +
> enum dsa_tag_protocol {
> DSA_TAG_PROTO_NONE = 0,
> DSA_TAG_PROTO_DSA,
>
--
Florian
^ permalink raw reply
* Re: [PATCH RFC] net: dsa: remove unnecessary phy.h include
From: Vivien Didelot @ 2017-01-18 1:11 UTC (permalink / raw)
To: Russell King - ARM Linux, Andrew Lunn
Cc: Florian Fainelli, David S. Miller, netdev, linux-kernel
In-Reply-To: <20170118001403.GJ27312@n2100.armlinux.org.uk>
Hi Russell,
Russell King - ARM Linux <linux@armlinux.org.uk> writes:
> Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
> unnecessary dependency for quite a large amount of the kernel. There's
> very little which actually requires definitions from phy.h in net/dsa.h
> - the include itself only wants the declaration of a couple of
> structures and IFNAMSIZ.
>
> Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
> mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
> and phy_fixed.h from net/dsa.h.
>
> This patch reduces from around 800 files rebuilt to around 40 - even
> with ccache, the time difference is noticable.
>
> Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
This patch applies cleanly on net-next and builds correctly after
touching include/linux/phy.h. My boards work fine with it.
Tested-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
Thanks,
Vivien
^ permalink raw reply
* RE: [PATCH v2 net-next] net:add one common config ARCH_WANT_RELAX_ORDER to support relax ordering.
From: maowenan @ 2017-01-18 1:07 UTC (permalink / raw)
To: Alexander Duyck, David Miller; +Cc: Netdev, Jeff Kirsher
In-Reply-To: <CAKgT0UcXFk3_LfsWyVeh6X_91mfVLJt3VRBSY_2r+ebjxfW7iQ@mail.gmail.com>
> -----Original Message-----
> From: Alexander Duyck [mailto:alexander.duyck@gmail.com]
> Sent: Wednesday, January 18, 2017 3:28 AM
> To: David Miller
> Cc: maowenan; Netdev; Jeff Kirsher
> Subject: Re: [PATCH v2 net-next] net:add one common config
> ARCH_WANT_RELAX_ORDER to support relax ordering.
>
> On Tue, Jan 17, 2017 at 11:15 AM, David Miller <davem@davemloft.net>
> wrote:
> > From: Mao Wenan <maowenan@huawei.com>
> > Date: Mon, 9 Jan 2017 13:32:34 +0800
> >
> >> Relax ordering(RO) is one feature of 82599 NIC, to enable this
> >> feature can enhance the performance for some cpu architecure, such as
> SPARC and so on.
> >> 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 patch add one common config CONFIG_ARCH_WANT_RELAX_ORDER to
> set
> >> RO feature, and should define CONFIG_ARCH_WANT_RELAX_ORDER in
> sparc Kconfig firstly.
> >>
> >> Signed-off-by: Mao Wenan <maowenan@huawei.com>
> >
> > Since no-one has reviewed this patch, and I do not feel comfortable
> > with applying it without such review, I am tossing this patch.
> >
> > If someone eventually reviews it, repost this patch.
>
> Mao,
>
> Go ahead and repost the patch and feel free to add my Reviewed-by.
> Sorry I didn't reply to this earlier but I have been getting over the flu for the last
> week or so.
>
> - Alex
Hi Alex,
I have reposted the patch(V3), thanks a lot.
^ permalink raw reply
* Re: [PATCHv2 5/7] TAP: Extending tap device create/destroy APIs
From: Andy Shevchenko @ 2017-01-18 1:00 UTC (permalink / raw)
To: Sainath Grandhi
Cc: netdev, David S. Miller, Mahesh Bandewar,
linux-kernel@vger.kernel.org
In-Reply-To: <1484697786-50323-6-git-send-email-sainath.grandhi@intel.com>
On Wed, Jan 18, 2017 at 2:03 AM, Sainath Grandhi
<sainath.grandhi@intel.com> wrote:
> Extending tap APIs get/free_minor and create/destroy_cdev to handle more than one
> type of virtual interface.
>
Yes, looks better now.
FWIW:
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
> ---
> drivers/net/macvtap_main.c | 6 +--
> drivers/net/tap.c | 98 +++++++++++++++++++++++++++++++++++-----------
> include/linux/if_tap.h | 4 +-
> 3 files changed, 80 insertions(+), 28 deletions(-)
>
> diff --git a/drivers/net/macvtap_main.c b/drivers/net/macvtap_main.c
> index 6326a82..3f047b4 100644
> --- a/drivers/net/macvtap_main.c
> +++ b/drivers/net/macvtap_main.c
> @@ -160,7 +160,7 @@ static int macvtap_device_event(struct notifier_block *unused,
> * been registered but before register_netdevice has
> * finished running.
> */
> - err = tap_get_minor(&vlantap->tap);
> + err = tap_get_minor(macvtap_major, &vlantap->tap);
> if (err)
> return notifier_from_errno(err);
>
> @@ -168,7 +168,7 @@ static int macvtap_device_event(struct notifier_block *unused,
> classdev = device_create(&macvtap_class, &dev->dev, devt,
> dev, tap_name);
> if (IS_ERR(classdev)) {
> - tap_free_minor(&vlantap->tap);
> + tap_free_minor(macvtap_major, &vlantap->tap);
> return notifier_from_errno(PTR_ERR(classdev));
> }
> err = sysfs_create_link(&dev->dev.kobj, &classdev->kobj,
> @@ -183,7 +183,7 @@ static int macvtap_device_event(struct notifier_block *unused,
> sysfs_remove_link(&dev->dev.kobj, tap_name);
> devt = MKDEV(MAJOR(macvtap_major), vlantap->tap.minor);
> device_destroy(&macvtap_class, devt);
> - tap_free_minor(&vlantap->tap);
> + tap_free_minor(macvtap_major, &vlantap->tap);
> break;
> case NETDEV_CHANGE_TX_QUEUE_LEN:
> if (tap_queue_resize(&vlantap->tap))
> diff --git a/drivers/net/tap.c b/drivers/net/tap.c
> index 43d9d54..7f38dbe 100644
> --- a/drivers/net/tap.c
> +++ b/drivers/net/tap.c
> @@ -99,12 +99,16 @@ static struct proto tap_proto = {
> };
>
> #define TAP_NUM_DEVS (1U << MINORBITS)
> +
> +static LIST_HEAD(major_list);
> +
> struct major_info {
> dev_t major;
> struct idr minor_idr;
> struct mutex minor_lock;
> const char *device_name;
> -} macvtap_major;
> + struct list_head next;
> +};
>
> #define GOODCOPY_LEN 128
>
> @@ -385,44 +389,73 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
> return RX_HANDLER_CONSUMED;
> }
>
> -int tap_get_minor(struct tap_dev *tap)
> +static struct major_info *tap_get_major(int major)
> +{
> + struct major_info *tap_major, *tmp;
> +
> + list_for_each_entry_safe(tap_major, tmp, &major_list, next) {
> + if (tap_major->major == major) {
> + return tap_major;
> + }
> + }
> +
> + return NULL;
> +}
> +
> +int tap_get_minor(dev_t major, struct tap_dev *tap)
> {
> int retval = -ENOMEM;
> + struct major_info *tap_major;
> +
> + tap_major = tap_get_major(MAJOR(major));
> + if (!tap_major)
> + return -EINVAL;
>
> - mutex_lock(&macvtap_major.minor_lock);
> - retval = idr_alloc(&macvtap_major.minor_idr, tap, 1, TAP_NUM_DEVS, GFP_KERNEL);
> + mutex_lock(&tap_major->minor_lock);
> + retval = idr_alloc(&tap_major->minor_idr, tap, 1, TAP_NUM_DEVS, GFP_KERNEL);
> if (retval >= 0) {
> tap->minor = retval;
> } else if (retval == -ENOSPC) {
> netdev_err(tap->dev, "Too many tap devices\n");
> retval = -EINVAL;
> }
> - mutex_unlock(&macvtap_major.minor_lock);
> + mutex_unlock(&tap_major->minor_lock);
> return retval < 0 ? retval : 0;
> }
>
> -void tap_free_minor(struct tap_dev *tap)
> +void tap_free_minor(dev_t major, struct tap_dev *tap)
> {
> - mutex_lock(&macvtap_major.minor_lock);
> + struct major_info *tap_major;
> +
> + tap_major = tap_get_major(MAJOR(major));
> + if (!tap_major)
> + return;
> +
> + mutex_lock(&tap_major->minor_lock);
> if (tap->minor) {
> - idr_remove(&macvtap_major.minor_idr, tap->minor);
> + idr_remove(&tap_major->minor_idr, tap->minor);
> tap->minor = 0;
> }
> - mutex_unlock(&macvtap_major.minor_lock);
> + mutex_unlock(&tap_major->minor_lock);
> }
>
> -static struct tap_dev *dev_get_by_tap_minor(int minor)
> +static struct tap_dev *dev_get_by_tap_file(int major, int minor)
> {
> struct net_device *dev = NULL;
> struct tap_dev *tap;
> + struct major_info *tap_major;
> +
> + tap_major = tap_get_major(major);
> + if (!tap_major)
> + return NULL;
>
> - mutex_lock(&macvtap_major.minor_lock);
> - tap = idr_find(&macvtap_major.minor_idr, minor);
> + mutex_lock(&tap_major->minor_lock);
> + tap = idr_find(&tap_major->minor_idr, minor);
> if (tap) {
> dev = tap->dev;
> dev_hold(dev);
> }
> - mutex_unlock(&macvtap_major.minor_lock);
> + mutex_unlock(&tap_major->minor_lock);
> return tap;
> }
>
> @@ -454,7 +487,7 @@ static int tap_open(struct inode *inode, struct file *file)
> int err = -ENODEV;
>
> rtnl_lock();
> - tap = dev_get_by_tap_minor(iminor(inode));
> + tap = dev_get_by_tap_file(imajor(inode), iminor(inode));
> if (!tap)
> goto err;
>
> @@ -1161,6 +1194,26 @@ int tap_queue_resize(struct tap_dev *tap)
> return ret;
> }
>
> +static int tap_list_add(dev_t major, const char *device_name)
> +{
> + struct major_info *tap_major;
> + int err = 0;
> +
> + tap_major = kzalloc(sizeof(*tap_major), GFP_ATOMIC);
> + if (!tap_major)
> + return -ENOMEM;
> +
> + tap_major->major = MAJOR(major);
> +
> + idr_init(&tap_major->minor_idr);
> + mutex_init(&tap_major->minor_lock);
> +
> + tap_major->device_name = device_name;
> +
> + list_add_tail(&tap_major->next, &major_list);
> + return err;
> +}
> +
> int tap_create_cdev(struct cdev *tap_cdev,
> dev_t *tap_major, const char *device_name)
> {
> @@ -1176,14 +1229,7 @@ int tap_create_cdev(struct cdev *tap_cdev,
> if (err)
> goto out2;
>
> - macvtap_major.major = MAJOR(*tap_major);
> -
> - idr_init(&macvtap_major.minor_idr);
> - mutex_init(&macvtap_major.minor_lock);
> -
> - macvtap_major.device_name = device_name;
> -
> - return err;
> + return tap_list_add(*tap_major, device_name);
>
> out2:
> unregister_chrdev_region(*tap_major, TAP_NUM_DEVS);
> @@ -1193,7 +1239,13 @@ int tap_create_cdev(struct cdev *tap_cdev,
>
> void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev)
> {
> + struct major_info *tap_major;
> +
> + tap_major = tap_get_major(MAJOR(major));
> + if (!tap_major)
> + return;
> +
> cdev_del(tap_cdev);
> unregister_chrdev_region(major, TAP_NUM_DEVS);
> - idr_destroy(&macvtap_major.minor_idr);
> + idr_destroy(&tap_major->minor_idr);
> }
> diff --git a/include/linux/if_tap.h b/include/linux/if_tap.h
> index 75031e5..362e71c 100644
> --- a/include/linux/if_tap.h
> +++ b/include/linux/if_tap.h
> @@ -65,8 +65,8 @@ struct tap_queue {
>
> rx_handler_result_t tap_handle_frame(struct sk_buff **pskb);
> void tap_del_queues(struct tap_dev *tap);
> -int tap_get_minor(struct tap_dev *tap);
> -void tap_free_minor(struct tap_dev *tap);
> +int tap_get_minor(dev_t major, struct tap_dev *tap);
> +void tap_free_minor(dev_t major, struct tap_dev *tap);
> int tap_queue_resize(struct tap_dev *tap);
> int tap_create_cdev(struct cdev *tap_cdev,
> dev_t *tap_major, const char *device_name);
> --
> 2.7.4
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* [PATCH v3 net-next] net:add one common config ARCH_WANT_RELAX_ORDER to support relax ordering
From: Mao Wenan @ 2017-01-18 0:50 UTC (permalink / raw)
To: netdev, alexander.duyck, jeffrey.t.kirsher
Relax ordering(RO) is one feature of 82599 NIC, to enable this feature can
enhance the performance for some cpu architecure, such as SPARC and so on.
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 patch add one common config CONFIG_ARCH_WANT_RELAX_ORDER to set RO feature,
and should define CONFIG_ARCH_WANT_RELAX_ORDER in sparc Kconfig firstly.
Signed-off-by: Mao Wenan <maowenan@huawei.com>
Reviewed-by: Alexander Duyck <alexander.duyck@gmail.com>
---
v2 -> v3: add reviewed information.
---
arch/Kconfig | 3 +++
arch/sparc/Kconfig | 1 +
drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 2 +-
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/Kconfig b/arch/Kconfig
index 99839c2..bd04eac 100644
--- a/arch/Kconfig
+++ b/arch/Kconfig
@@ -781,4 +781,7 @@ config VMAP_STACK
the stack to map directly to the KASAN shadow map using a formula
that is incorrect if the stack is in vmalloc space.
+config ARCH_WANT_RELAX_ORDER
+ bool
+
source "kernel/gcov/Kconfig"
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig
index cf4034c..68ac5c7 100644
--- a/arch/sparc/Kconfig
+++ b/arch/sparc/Kconfig
@@ -44,6 +44,7 @@ config SPARC
select CPU_NO_EFFICIENT_FFS
select HAVE_ARCH_HARDENED_USERCOPY
select PROVE_LOCKING_SMALL if PROVE_LOCKING
+ select ARCH_WANT_RELAX_ORDER
config SPARC32
def_bool !64BIT
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
index 094e1d6..c38d50c 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
@@ -350,7 +350,7 @@ s32 ixgbe_start_hw_gen2(struct ixgbe_hw *hw)
}
IXGBE_WRITE_FLUSH(hw);
-#ifndef CONFIG_SPARC
+#ifndef CONFIG_ARCH_WANT_RELAX_ORDER
/* Disable relaxed ordering */
for (i = 0; i < hw->mac.max_tx_queues; i++) {
u32 regval;
--
2.7.0
^ permalink raw reply related
* Darlehen angebot 3 %
From: Frau SCHMIDT @ 2017-01-17 20:21 UTC (permalink / raw)
To: neumann_mario
Sehr geehrte Damen und Herren,
Haben Sie Interesse über einer finanziellen Darlehen zu 3%???
kontaktieren Sie mich für mehr Details und Bedingungen. ich kann all
jenen helfen, wer ein Darlehen benötigen.
Ich kann Ihnen biete ein darlehen in hohe von 10.000.000 Euro
Meine mail: info@rschmidt.online
Mit freundlichen Grüßen
^ permalink raw reply
* linux-next: build warnings after merge of the net-next tree
From: Stephen Rothwell @ 2017-01-18 0:37 UTC (permalink / raw)
To: David Miller, Networking; +Cc: linux-next, linux-kernel, Ganesh Goudar
Hi all,
After merging the net-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced these warnings:
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c: In function 'init_one':
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:4646:9: warning: unused variable 'port_vec' [-Wunused-variable]
u32 v, port_vec;
^
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c:4646:6: warning: unused variable 'v' [-Wunused-variable]
u32 v, port_vec;
^
Introduced by commit
96fe11f27b70 ("cxgb4: Implement ndo_get_phys_port_id for mgmt dev")
--
Cheers,
Stephen Rothwell
^ permalink raw reply
* [PATCH net] net: phy: bcm63xx: Utilize correct config_intr function
From: Florian Fainelli @ 2017-01-18 0:26 UTC (permalink / raw)
To: netdev; +Cc: jonas.gorski, Daniel Gonzalez Cabanelas, Florian Fainelli
From: Daniel Gonzalez Cabanelas <dgcbueu@gmail.com>
Commit a1cba5613edf ("net: phy: Add Broadcom phy library for common
interfaces") make the BCM63xx PHY driver utilize bcm_phy_config_intr()
which would appear to do the right thing, except that it does not write
to the MII_BCM63XX_IR register but to MII_BCM54XX_ECR which is
different.
This would be causing invalid link parameters and events from being
generated by the PHY interrupt.
Fixes: a1cba5613edf ("net: phy: Add Broadcom phy library for common interfaces")
Signed-off-by: Daniel Gonzalez Cabanelas <dgcbueu@gmail.com>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/net/phy/bcm63xx.c | 21 +++++++++++++++++++--
1 file changed, 19 insertions(+), 2 deletions(-)
diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c
index e741bf614c4e..b0492ef2cdaa 100644
--- a/drivers/net/phy/bcm63xx.c
+++ b/drivers/net/phy/bcm63xx.c
@@ -21,6 +21,23 @@ MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>");
MODULE_LICENSE("GPL");
+static int bcm63xx_config_intr(struct phy_device *phydev)
+{
+ int reg, err;
+
+ reg = phy_read(phydev, MII_BCM63XX_IR);
+ if (reg < 0)
+ return reg;
+
+ if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
+ reg &= ~MII_BCM63XX_IR_GMASK;
+ else
+ reg |= MII_BCM63XX_IR_GMASK;
+
+ err = phy_write(phydev, MII_BCM63XX_IR, reg);
+ return err;
+}
+
static int bcm63xx_config_init(struct phy_device *phydev)
{
int reg, err;
@@ -55,7 +72,7 @@ static struct phy_driver bcm63xx_driver[] = {
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
.ack_interrupt = bcm_phy_ack_intr,
- .config_intr = bcm_phy_config_intr,
+ .config_intr = bcm63xx_config_intr,
}, {
/* same phy as above, with just a different OUI */
.phy_id = 0x002bdc00,
@@ -67,7 +84,7 @@ static struct phy_driver bcm63xx_driver[] = {
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
.ack_interrupt = bcm_phy_ack_intr,
- .config_intr = bcm_phy_config_intr,
+ .config_intr = bcm63xx_config_intr,
} };
module_phy_driver(bcm63xx_driver);
--
2.9.3
^ permalink raw reply related
* [PATCH] net: ethernet: ti: davinci_cpdma: correct check on NULL in set rate
From: Ivan Khoronzhuk @ 2017-01-18 0:28 UTC (permalink / raw)
To: mugunthanvnm
Cc: grygorii.strashko, netdev, linux-omap, linux-kernel,
Ivan Khoronzhuk
Check "ch" on NULL first, then get ctlr.
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
Based on net-next/master
drivers/net/ethernet/ti/davinci_cpdma.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/ti/davinci_cpdma.c b/drivers/net/ethernet/ti/davinci_cpdma.c
index d80bff1..7ecc6b7 100644
--- a/drivers/net/ethernet/ti/davinci_cpdma.c
+++ b/drivers/net/ethernet/ti/davinci_cpdma.c
@@ -835,8 +835,8 @@ EXPORT_SYMBOL_GPL(cpdma_chan_get_min_rate);
*/
int cpdma_chan_set_rate(struct cpdma_chan *ch, u32 rate)
{
- struct cpdma_ctlr *ctlr = ch->ctlr;
unsigned long flags, ch_flags;
+ struct cpdma_ctlr *ctlr;
int ret, prio_mode;
u32 rmask;
@@ -846,6 +846,7 @@ int cpdma_chan_set_rate(struct cpdma_chan *ch, u32 rate)
if (ch->rate == rate)
return rate;
+ ctlr = ch->ctlr;
spin_lock_irqsave(&ctlr->lock, flags);
spin_lock_irqsave(&ch->lock, ch_flags);
--
2.7.4
^ permalink raw reply related
* [PATCH RFC] net: dsa: remove unnecessary phy.h include
From: Russell King - ARM Linux @ 2017-01-18 0:14 UTC (permalink / raw)
To: Andrew Lunn, Vivien Didelot
Cc: Florian Fainelli, David S. Miller, netdev, linux-kernel
Including phy.h and phy_fixed.h into net/dsa.h causes phy*.h to be an
unnecessary dependency for quite a large amount of the kernel. There's
very little which actually requires definitions from phy.h in net/dsa.h
- the include itself only wants the declaration of a couple of
structures and IFNAMSIZ.
Add linux/if.h for IFNAMSIZ, declarations for the structures, phy.h to
mv88e6xxx.h as it needs it for phy_interface_t, and remove both phy.h
and phy_fixed.h from net/dsa.h.
This patch reduces from around 800 files rebuilt to around 40 - even
with ccache, the time difference is noticable.
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
I noticed when I touched linux/phy.h that a lot of the kernel ended up
being unexpectedly rebuilt, as linux/netdevice.h includes net/dsa.h,
which then then includes linux/phy.h. I've tested this change on both
ARM and ARM64, but I'd suggest letting the 0-day builder have a bite
at this, and then only taking it if everyone is confident that there's
a slim chance of any problems. Also, it may need some rework to apply
to davem's tree. All of the above makes this RFC only.
drivers/net/dsa/mv88e6xxx/mv88e6xxx.h | 1 +
include/net/dsa.h | 6 ++++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
index a319c06d82e3..d247b0639ed4 100644
--- a/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
+++ b/drivers/net/dsa/mv88e6xxx/mv88e6xxx.h
@@ -15,6 +15,7 @@
#include <linux/if_vlan.h>
#include <linux/irq.h>
#include <linux/gpio/consumer.h>
+#include <linux/phy.h>
#ifndef UINT64_MAX
#define UINT64_MAX (u64)(~((u64)0))
diff --git a/include/net/dsa.h b/include/net/dsa.h
index b122196d5a1f..887b2f98f9ea 100644
--- a/include/net/dsa.h
+++ b/include/net/dsa.h
@@ -11,15 +11,17 @@
#ifndef __LINUX_NET_DSA_H
#define __LINUX_NET_DSA_H
+#include <linux/if.h>
#include <linux/if_ether.h>
#include <linux/list.h>
#include <linux/timer.h>
#include <linux/workqueue.h>
#include <linux/of.h>
-#include <linux/phy.h>
-#include <linux/phy_fixed.h>
#include <linux/ethtool.h>
+struct phy_device;
+struct fixed_phy_status;
+
enum dsa_tag_protocol {
DSA_TAG_PROTO_NONE = 0,
DSA_TAG_PROTO_DSA,
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
^ permalink raw reply related
* Re: [PATCH net-next v4 05/10] drivers: base: Add device_find_in_class_name()
From: Florian Fainelli @ 2017-01-18 0:13 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Andrew Lunn, Jason Cooper, Vivien Didelot, netdev, Russell King,
open list, Greg Kroah-Hartman, Gregory Clement, David S. Miller,
moderated list:ARM/Marvell Dove/MV78xx0/Orion SOC support,
Sebastian Hesselbarth
In-Reply-To: <CAHp75VeqLb2hDgj2jfWzQgw4wa31gckSw=jZS0UhUAnZgNA14Q@mail.gmail.com>
On 01/17/2017 04:07 PM, Andy Shevchenko wrote:
> On Wed, Jan 18, 2017 at 2:04 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>> On 01/17/2017 04:00 PM, Andy Shevchenko wrote:
>>> On Wed, Jan 18, 2017 at 1:43 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>>>> On 01/17/2017 03:34 PM, Andy Shevchenko wrote:
>>>>> On Wed, Jan 18, 2017 at 1:21 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>>> But why not to use void *class_name to be consistent with callback and
>>> device_find_child()?
>>
>> The top-level function: device_find_in_class_name() should have a
>> stronger typing of its argument even if it internally uses
>> device_find_child() and a callback that takes a void * argument, that's
>> how I see it.
>
> Fair enough.
>
>>> Btw,
>>> return get_device(parent);
>>
>> Not sure I follow what that means here?
>
> Missed remark. Instead of
>
> get_device(parent);
> return parent;
>
> you can use
>
> return get_device(parent);
Seems reasonable, if I have to respin a v5, will add that, thanks!
--
Florian
^ permalink raw reply
* Re: [PATCH net-next v4 05/10] drivers: base: Add device_find_in_class_name()
From: Andy Shevchenko @ 2017-01-18 0:07 UTC (permalink / raw)
To: Florian Fainelli
Cc: netdev, Jason Cooper, Andrew Lunn, Sebastian Hesselbarth,
Gregory Clement, Russell King, Vivien Didelot, David S. Miller,
Greg Kroah-Hartman,
moderated list:ARM/Marvell Dove/MV78xx0/Orion SOC support,
open list
In-Reply-To: <e3132d31-f94f-8794-1121-0fe25be2f61b@gmail.com>
On Wed, Jan 18, 2017 at 2:04 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
> On 01/17/2017 04:00 PM, Andy Shevchenko wrote:
>> On Wed, Jan 18, 2017 at 1:43 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>>> On 01/17/2017 03:34 PM, Andy Shevchenko wrote:
>>>> On Wed, Jan 18, 2017 at 1:21 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>> But why not to use void *class_name to be consistent with callback and
>> device_find_child()?
>
> The top-level function: device_find_in_class_name() should have a
> stronger typing of its argument even if it internally uses
> device_find_child() and a callback that takes a void * argument, that's
> how I see it.
Fair enough.
>> Btw,
>> return get_device(parent);
>
> Not sure I follow what that means here?
Missed remark. Instead of
get_device(parent);
return parent;
you can use
return get_device(parent);
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* [PATCHv2 0/7] Refactor macvtap to re-use tap functionality by other virtual intefaces
From: Sainath Grandhi @ 2017-01-18 0:02 UTC (permalink / raw)
To: netdev; +Cc: davem, mahesh, linux-kernel, sainath.grandhi
Tap character devices can be implemented on other virtual interfaces like
ipvlan, similar to macvtap. Source code for tap functionality in macvtap
can be re-used for this purpose.
This patch series splits macvtap source into two modules, macvtap and tap.
This patch series also includes a patch for implementing tap character
device driver based on the IP-VLAN network interface, called ipvtap.
These patches are tested on x86 platform.
Sainath Grandhi (7):
TAP: Refactoring macvtap.c
TAP: Renaming tap related APIs, data structures, macros
TAP: Tap character device creation/destroy API
TAP: Abstract type of virtual interface from tap implementation
TAP: Extending tap device create/destroy APIs
TAP: tap as an independent module
IPVTAP: IP-VLAN based tap driver
drivers/net/Kconfig | 28 +
drivers/net/Makefile | 2 +
drivers/net/ipvlan/Makefile | 1 +
drivers/net/ipvlan/ipvlan.h | 7 +
drivers/net/ipvlan/ipvlan_core.c | 5 +-
drivers/net/ipvlan/ipvlan_main.c | 27 +-
drivers/net/ipvlan/ipvtap.c | 238 +++++++
drivers/net/macvlan.c | 2 +-
drivers/net/macvtap.c | 1226 ++----------------------------------
drivers/net/tap.c | 1262 ++++++++++++++++++++++++++++++++++++++
drivers/vhost/Kconfig | 2 +-
drivers/vhost/net.c | 3 +-
include/linux/if_macvlan.h | 17 +-
include/linux/if_tap.h | 75 +++
14 files changed, 1686 insertions(+), 1209 deletions(-)
create mode 100644 drivers/net/ipvlan/ipvtap.c
create mode 100644 drivers/net/tap.c
create mode 100644 include/linux/if_tap.h
--
2.7.4
^ permalink raw reply
* Re: [PATCH net-next v4 05/10] drivers: base: Add device_find_in_class_name()
From: Florian Fainelli @ 2017-01-18 0:04 UTC (permalink / raw)
To: Andy Shevchenko
Cc: netdev, Jason Cooper, Andrew Lunn, Sebastian Hesselbarth,
Gregory Clement, Russell King, Vivien Didelot, David S. Miller,
Greg Kroah-Hartman,
moderated list:ARM/Marvell Dove/MV78xx0/Orion SOC support,
open list
In-Reply-To: <CAHp75Ve9xn6wDxFwnkPDyY8yVwVysK3-pUsoxv3GfVbbEVZoBg@mail.gmail.com>
On 01/17/2017 04:00 PM, Andy Shevchenko wrote:
> On Wed, Jan 18, 2017 at 1:43 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>> On 01/17/2017 03:34 PM, Andy Shevchenko wrote:
>>> On Wed, Jan 18, 2017 at 1:21 AM, Florian Fainelli <f.fainelli@gmail.com> wrote:
>
>>>> +static int device_class_name_match(struct device *dev, void *class)
>>>
>>> And why not const char *class?
>>
>> This was raised back in v2, and the same response applies:
>>
>> https://www.mail-archive.com/netdev@vger.kernel.org/msg147559.html
>>
>> Changing the signature of a callback is out of the scope of this patch
>> series.
>
> Ah, right.
>
> But why not to use void *class_name to be consistent with callback and
> device_find_child()?
The top-level function: device_find_in_class_name() should have a
stronger typing of its argument even if it internally uses
device_find_child() and a callback that takes a void * argument, that's
how I see it.
>
> Btw,
>
> return get_device(parent);
Not sure I follow what that means here?
--
Florian
^ permalink raw reply
* [PATCHv2 5/7] TAP: Extending tap device create/destroy APIs
From: Sainath Grandhi @ 2017-01-18 0:03 UTC (permalink / raw)
To: netdev; +Cc: davem, mahesh, linux-kernel, sainath.grandhi
In-Reply-To: <1484697786-50323-1-git-send-email-sainath.grandhi@intel.com>
Extending tap APIs get/free_minor and create/destroy_cdev to handle more than one
type of virtual interface.
Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com>
---
drivers/net/macvtap_main.c | 6 +--
drivers/net/tap.c | 98 +++++++++++++++++++++++++++++++++++-----------
include/linux/if_tap.h | 4 +-
3 files changed, 80 insertions(+), 28 deletions(-)
diff --git a/drivers/net/macvtap_main.c b/drivers/net/macvtap_main.c
index 6326a82..3f047b4 100644
--- a/drivers/net/macvtap_main.c
+++ b/drivers/net/macvtap_main.c
@@ -160,7 +160,7 @@ static int macvtap_device_event(struct notifier_block *unused,
* been registered but before register_netdevice has
* finished running.
*/
- err = tap_get_minor(&vlantap->tap);
+ err = tap_get_minor(macvtap_major, &vlantap->tap);
if (err)
return notifier_from_errno(err);
@@ -168,7 +168,7 @@ static int macvtap_device_event(struct notifier_block *unused,
classdev = device_create(&macvtap_class, &dev->dev, devt,
dev, tap_name);
if (IS_ERR(classdev)) {
- tap_free_minor(&vlantap->tap);
+ tap_free_minor(macvtap_major, &vlantap->tap);
return notifier_from_errno(PTR_ERR(classdev));
}
err = sysfs_create_link(&dev->dev.kobj, &classdev->kobj,
@@ -183,7 +183,7 @@ static int macvtap_device_event(struct notifier_block *unused,
sysfs_remove_link(&dev->dev.kobj, tap_name);
devt = MKDEV(MAJOR(macvtap_major), vlantap->tap.minor);
device_destroy(&macvtap_class, devt);
- tap_free_minor(&vlantap->tap);
+ tap_free_minor(macvtap_major, &vlantap->tap);
break;
case NETDEV_CHANGE_TX_QUEUE_LEN:
if (tap_queue_resize(&vlantap->tap))
diff --git a/drivers/net/tap.c b/drivers/net/tap.c
index 43d9d54..7f38dbe 100644
--- a/drivers/net/tap.c
+++ b/drivers/net/tap.c
@@ -99,12 +99,16 @@ static struct proto tap_proto = {
};
#define TAP_NUM_DEVS (1U << MINORBITS)
+
+static LIST_HEAD(major_list);
+
struct major_info {
dev_t major;
struct idr minor_idr;
struct mutex minor_lock;
const char *device_name;
-} macvtap_major;
+ struct list_head next;
+};
#define GOODCOPY_LEN 128
@@ -385,44 +389,73 @@ rx_handler_result_t tap_handle_frame(struct sk_buff **pskb)
return RX_HANDLER_CONSUMED;
}
-int tap_get_minor(struct tap_dev *tap)
+static struct major_info *tap_get_major(int major)
+{
+ struct major_info *tap_major, *tmp;
+
+ list_for_each_entry_safe(tap_major, tmp, &major_list, next) {
+ if (tap_major->major == major) {
+ return tap_major;
+ }
+ }
+
+ return NULL;
+}
+
+int tap_get_minor(dev_t major, struct tap_dev *tap)
{
int retval = -ENOMEM;
+ struct major_info *tap_major;
+
+ tap_major = tap_get_major(MAJOR(major));
+ if (!tap_major)
+ return -EINVAL;
- mutex_lock(&macvtap_major.minor_lock);
- retval = idr_alloc(&macvtap_major.minor_idr, tap, 1, TAP_NUM_DEVS, GFP_KERNEL);
+ mutex_lock(&tap_major->minor_lock);
+ retval = idr_alloc(&tap_major->minor_idr, tap, 1, TAP_NUM_DEVS, GFP_KERNEL);
if (retval >= 0) {
tap->minor = retval;
} else if (retval == -ENOSPC) {
netdev_err(tap->dev, "Too many tap devices\n");
retval = -EINVAL;
}
- mutex_unlock(&macvtap_major.minor_lock);
+ mutex_unlock(&tap_major->minor_lock);
return retval < 0 ? retval : 0;
}
-void tap_free_minor(struct tap_dev *tap)
+void tap_free_minor(dev_t major, struct tap_dev *tap)
{
- mutex_lock(&macvtap_major.minor_lock);
+ struct major_info *tap_major;
+
+ tap_major = tap_get_major(MAJOR(major));
+ if (!tap_major)
+ return;
+
+ mutex_lock(&tap_major->minor_lock);
if (tap->minor) {
- idr_remove(&macvtap_major.minor_idr, tap->minor);
+ idr_remove(&tap_major->minor_idr, tap->minor);
tap->minor = 0;
}
- mutex_unlock(&macvtap_major.minor_lock);
+ mutex_unlock(&tap_major->minor_lock);
}
-static struct tap_dev *dev_get_by_tap_minor(int minor)
+static struct tap_dev *dev_get_by_tap_file(int major, int minor)
{
struct net_device *dev = NULL;
struct tap_dev *tap;
+ struct major_info *tap_major;
+
+ tap_major = tap_get_major(major);
+ if (!tap_major)
+ return NULL;
- mutex_lock(&macvtap_major.minor_lock);
- tap = idr_find(&macvtap_major.minor_idr, minor);
+ mutex_lock(&tap_major->minor_lock);
+ tap = idr_find(&tap_major->minor_idr, minor);
if (tap) {
dev = tap->dev;
dev_hold(dev);
}
- mutex_unlock(&macvtap_major.minor_lock);
+ mutex_unlock(&tap_major->minor_lock);
return tap;
}
@@ -454,7 +487,7 @@ static int tap_open(struct inode *inode, struct file *file)
int err = -ENODEV;
rtnl_lock();
- tap = dev_get_by_tap_minor(iminor(inode));
+ tap = dev_get_by_tap_file(imajor(inode), iminor(inode));
if (!tap)
goto err;
@@ -1161,6 +1194,26 @@ int tap_queue_resize(struct tap_dev *tap)
return ret;
}
+static int tap_list_add(dev_t major, const char *device_name)
+{
+ struct major_info *tap_major;
+ int err = 0;
+
+ tap_major = kzalloc(sizeof(*tap_major), GFP_ATOMIC);
+ if (!tap_major)
+ return -ENOMEM;
+
+ tap_major->major = MAJOR(major);
+
+ idr_init(&tap_major->minor_idr);
+ mutex_init(&tap_major->minor_lock);
+
+ tap_major->device_name = device_name;
+
+ list_add_tail(&tap_major->next, &major_list);
+ return err;
+}
+
int tap_create_cdev(struct cdev *tap_cdev,
dev_t *tap_major, const char *device_name)
{
@@ -1176,14 +1229,7 @@ int tap_create_cdev(struct cdev *tap_cdev,
if (err)
goto out2;
- macvtap_major.major = MAJOR(*tap_major);
-
- idr_init(&macvtap_major.minor_idr);
- mutex_init(&macvtap_major.minor_lock);
-
- macvtap_major.device_name = device_name;
-
- return err;
+ return tap_list_add(*tap_major, device_name);
out2:
unregister_chrdev_region(*tap_major, TAP_NUM_DEVS);
@@ -1193,7 +1239,13 @@ int tap_create_cdev(struct cdev *tap_cdev,
void tap_destroy_cdev(dev_t major, struct cdev *tap_cdev)
{
+ struct major_info *tap_major;
+
+ tap_major = tap_get_major(MAJOR(major));
+ if (!tap_major)
+ return;
+
cdev_del(tap_cdev);
unregister_chrdev_region(major, TAP_NUM_DEVS);
- idr_destroy(&macvtap_major.minor_idr);
+ idr_destroy(&tap_major->minor_idr);
}
diff --git a/include/linux/if_tap.h b/include/linux/if_tap.h
index 75031e5..362e71c 100644
--- a/include/linux/if_tap.h
+++ b/include/linux/if_tap.h
@@ -65,8 +65,8 @@ struct tap_queue {
rx_handler_result_t tap_handle_frame(struct sk_buff **pskb);
void tap_del_queues(struct tap_dev *tap);
-int tap_get_minor(struct tap_dev *tap);
-void tap_free_minor(struct tap_dev *tap);
+int tap_get_minor(dev_t major, struct tap_dev *tap);
+void tap_free_minor(dev_t major, struct tap_dev *tap);
int tap_queue_resize(struct tap_dev *tap);
int tap_create_cdev(struct cdev *tap_cdev,
dev_t *tap_major, const char *device_name);
--
2.7.4
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox