* imaging services
From: Jeremy @ 2018-07-27 22:32 UTC (permalink / raw)
To: netdev
I would like to contact the person who manages your images for your
company?
We services such as background image cut out, clipping path, shadow adding
(drop shadow, reflection shadow, natural shadow, mirror effect), image
masking, product image editing.
The following are the kind of services together:
Clipping Path Service
Cut out image,Image Clipping, Clip image
Photo Masking Service
Crop image, Photo cut out
Beauty Retouching, Model retouching
We can give you editing test on your photos.
Also, we also use the most recent application as well as techniques such as
Adobe Photoshop.
Thanks,
Jeremy
^ permalink raw reply
* [PATCH net-next] xfrm: Make function xfrmi_get_link_net() static
From: Wei Yongjun @ 2018-07-28 6:49 UTC (permalink / raw)
To: Steffen Klassert, Lorenzo Colitti, Benedict Wong
Cc: Wei Yongjun, netdev, kernel-janitors
Fixes the following sparse warning:
net/xfrm/xfrm_interface.c:745:12: warning:
symbol 'xfrmi_get_link_net' was not declared. Should it be static?
Fixes: f203b76d7809 ("xfrm: Add virtual xfrm interfaces")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
net/xfrm/xfrm_interface.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c
index 31acc6f..2c0a5c5 100644
--- a/net/xfrm/xfrm_interface.c
+++ b/net/xfrm/xfrm_interface.c
@@ -742,7 +742,7 @@ static int xfrmi_fill_info(struct sk_buff *skb, const struct net_device *dev)
return -EMSGSIZE;
}
-struct net *xfrmi_get_link_net(const struct net_device *dev)
+static struct net *xfrmi_get_link_net(const struct net_device *dev)
{
struct xfrm_if *xi = netdev_priv(dev);
^ permalink raw reply related
* Re: [PATCH net-next 1/2] tcp: call tcp_drop() in tcp collapse
From: Yafang Shao @ 2018-07-28 7:42 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, LKML
In-Reply-To: <CANn89iKXPu=RKkLop4NJWZLixE__qYV2S=PngSj6ienuvWWL8g@mail.gmail.com>
On Sat, Jul 28, 2018 at 11:38 AM, Eric Dumazet <edumazet@google.com> wrote:
> On Fri, Jul 27, 2018 at 8:35 PM Yafang Shao <laoar.shao@gmail.com> wrote:
>
>> So what about LINUX_MIB_TCPOFOMERGE ?
>> Regarding LINUX_MIB_TCPOFOMERGE, a skb is already covered by another
>> skb, is that dropping the packet or simply lowering the memory
>> overhead ?
>
> What do you think ?
>
> If you receive two times the same payload, don't you have to drop one
> of the duplicate ?
>
> There is a a big difference between the two cases.
If the drop caused some data lost (which may then cause retransmition
or something), then this is a really DROP.
While if the drop won't cause any data lost, meaning it is a
non-harmful behavior, I think it should not be defined as DROP.
This is my suggestion anyway.
Thanks
Yafang
^ permalink raw reply
* Re: [PATCH] bpf, x32: Fix regression caused by commit 24dea04767e6
From: mroos @ 2018-07-28 7:23 UTC (permalink / raw)
To: Wang YanQing
Cc: daniel, ast, davem, illusionist.neo, tglx, mingo, hpa, x86,
netdev, Linux Kernel list, arnd
In-Reply-To: <20180725164611.GA12441@udknight>
> Commit 24dea04767e6 ("bpf, x32: remove ld_abs/ld_ind")
> removed the 4 /* Extra space for skb_copy_bits buffer */
> from _STACK_SIZE, but it didn't fix the concerned code
> in emit_prologue and emit_epilogue, and this error will
> bring very strange kernel runtime errors.
>
> This patch fix it.
For the record:
Tested it on top of 4.18.0-rc6-00192-g864af0d40cdc on the affected
machine and it worked.
--
Meelis Roos (mroos@linux.ee)
^ permalink raw reply
* Re: About the V9fs-developer list (Was: [PATCH] 9p: fix multiple
From: Dominique Martinet @ 2018-07-28 6:32 UTC (permalink / raw)
To: piaojun
Cc: Eric Van Hensbergen, Ron Minnich, Latchesar Ionkov,
v9fs-developer, linux-kernel, netdev
In-Reply-To: <5B5C0D12.3070208@huawei.com>
piaojun wrote on Sat, Jul 28, 2018:
> Could we cancel the limitation of recipients' number?
I think it's hard-coded by source-forge...
I'm not list admin for v9fs-developer but we've had problems with
another sf list on another project and the options are fairly limited
from what I can recall...
And sourceforge is currently down so no way to check right now!
--
Dominique Martinet
^ permalink raw reply
* Re: About the V9fs-developer list (Was: [PATCH] 9p: fix multiple
From: piaojun @ 2018-07-28 6:28 UTC (permalink / raw)
To: Dominique Martinet, Eric Van Hensbergen, Ron Minnich,
Latchesar Ionkov
Cc: v9fs-developer, linux-kernel, netdev
In-Reply-To: <20180728055945.GA16684@nautica>
Hi,
Could we cancel the limitation of recipients' number?
Thanks,
Jun
On 2018/7/28 13:59, Dominique Martinet wrote:
> NULL-pointer-dereferences)
> Reply-To:
> In-Reply-To: <5B5BBFCE.50002@huawei.com>
>
>
> (Re-added Eric, ron, Latchesar to the recipients and removed a few
> others to make v9fs accept this mail without moderation, sorry Thomas &
> others)
>
>
> TL;DR: should we move the list, and should I send a patch adding myself
> to maintainers?
>
>
> piaojun wrote on Sat, Jul 28, 2018:
>> I could not recieve the original patch. Did the patch CC v9fs developer
>> maillist?
>
> Yes, but as usual there were too many recipients (I removed some like
> you did previously), so the patch is probably queued for moderation
> somewhere.
>
> For this specific patch, you can find the original message here from the
> lkml archives:
> http://lkml.kernel.org/r/20180727110558.5479-1-tomasbortoli@gmail.com
>
>
> (Or more generally for patches I say I've accepted, my current process
> is to push them to my 9p-test branch[1] then once they have been tested
> push the same thing to my 9p-next branch[2] that will be taken into
> linux-next; this is already in 9p-next now :
> https://github.com/martinetd/linux/commit/49fd386d1e67d7876770d46b57359c6891d4cb70
>
> [1] https://github.com/martinetd/linux/commits/9p-test
> [2] https://github.com/martinetd/linux/commits/9p-next
>
> I always check that linux-kernel@vger was in copy and insert the Link:
> tag as appropriate if you need to reply)
>
>
>
>
> In general though I'd realy like to bring up the subject of this mailing
> list as I feel it's been a burden lately.
> I'm not even an admin of the list so I feel a little out of place here
> but should I go around snooping to ask if we could make a new
> v9fs@vger.kernel.org mailing list and abandon the ship here?
>
> A second question that's been on my mind lately is if I'm going to be
> gathering 9p patchs from now I should probably start considering sending
> a patch to add myself to MAINTAINER.
>
> I've had a quick look at the file though and there aren't many
> subsystems with 4+ maintainer (breakdown if I can count: 1301 with 1,
> 342 with 2, 104 with 3, 31 with 4, 4 with 5, 1 with 6 and 10
> maintainers) and more to the point I also think having too many
> maintainers is a nuisance, which is why I've been reluctant to add
> myself.
>
> I however don't want to forcefully remove anyone either, Eric has been
> somewhat active with three messages in may at least, and Latchesar akced
> patchs this past year as well (September but still within 12 months) so
> he's definitely still reading these emails a bit...
> That being said, it's not like retiring from maintainers means one won't
> be able to look and comment at patches, just that patches will get less
> recipients and might go to through to the list more easily.
>
> To be honest I wouldn't care at all if the list worked well, but in the
> state things are in it's easy for me to miss a patch unless someone
> redirects it to me like Greg did recently.
>
> There isn't any hurry, but let's discuss this and move forward.
>
>
> What do you three think about this?
> What do others think?
>
> Thanks!
>
^ permalink raw reply
* About the V9fs-developer list (Was: [PATCH] 9p: fix multiple
From: Dominique Martinet @ 2018-07-28 5:59 UTC (permalink / raw)
To: Eric Van Hensbergen, Ron Minnich, Latchesar Ionkov, piaojun
Cc: v9fs-developer, linux-kernel, netdev
NULL-pointer-dereferences)
Reply-To:
In-Reply-To: <5B5BBFCE.50002@huawei.com>
(Re-added Eric, ron, Latchesar to the recipients and removed a few
others to make v9fs accept this mail without moderation, sorry Thomas &
others)
TL;DR: should we move the list, and should I send a patch adding myself
to maintainers?
piaojun wrote on Sat, Jul 28, 2018:
> I could not recieve the original patch. Did the patch CC v9fs developer
> maillist?
Yes, but as usual there were too many recipients (I removed some like
you did previously), so the patch is probably queued for moderation
somewhere.
For this specific patch, you can find the original message here from the
lkml archives:
http://lkml.kernel.org/r/20180727110558.5479-1-tomasbortoli@gmail.com
(Or more generally for patches I say I've accepted, my current process
is to push them to my 9p-test branch[1] then once they have been tested
push the same thing to my 9p-next branch[2] that will be taken into
linux-next; this is already in 9p-next now :
https://github.com/martinetd/linux/commit/49fd386d1e67d7876770d46b57359c6891d4cb70
[1] https://github.com/martinetd/linux/commits/9p-test
[2] https://github.com/martinetd/linux/commits/9p-next
I always check that linux-kernel@vger was in copy and insert the Link:
tag as appropriate if you need to reply)
In general though I'd realy like to bring up the subject of this mailing
list as I feel it's been a burden lately.
I'm not even an admin of the list so I feel a little out of place here
but should I go around snooping to ask if we could make a new
v9fs@vger.kernel.org mailing list and abandon the ship here?
A second question that's been on my mind lately is if I'm going to be
gathering 9p patchs from now I should probably start considering sending
a patch to add myself to MAINTAINER.
I've had a quick look at the file though and there aren't many
subsystems with 4+ maintainer (breakdown if I can count: 1301 with 1,
342 with 2, 104 with 3, 31 with 4, 4 with 5, 1 with 6 and 10
maintainers) and more to the point I also think having too many
maintainers is a nuisance, which is why I've been reluctant to add
myself.
I however don't want to forcefully remove anyone either, Eric has been
somewhat active with three messages in may at least, and Latchesar akced
patchs this past year as well (September but still within 12 months) so
he's definitely still reading these emails a bit...
That being said, it's not like retiring from maintainers means one won't
be able to look and comment at patches, just that patches will get less
recipients and might go to through to the list more easily.
To be honest I wouldn't care at all if the list worked well, but in the
state things are in it's easy for me to miss a patch unless someone
redirects it to me like Greg did recently.
There isn't any hurry, but let's discuss this and move forward.
What do you three think about this?
What do others think?
Thanks!
--
Dominique Martinet
^ permalink raw reply
* [PATCH net-next 2/2] net-next: mediatek: cleanup unnecessary get chip id and its user
From: sean.wang @ 2018-07-28 5:35 UTC (permalink / raw)
To: john, davem; +Cc: nbd, netdev, linux-kernel, linux-mediatek, Sean Wang
In-Reply-To: <658dfd485c035cdae5452bc5d572125076b47a48.1532755541.git.sean.wang@mediatek.com>
From: Sean Wang <sean.wang@mediatek.com>
Since driver is devicetree-based, all device type and charateristic can be
determined by the compatible string and its data. It's unnecessary to
create another dependent function to check chip ID and then decide whether
the specific funciton is being supported on a certain device. It can be
totally replaced by the existing flag, so a cleanup is made by removing
the function and the only user, HWLRO.
MT2701 also have a missing HWLRO support in old code, so add it the same
patch.
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 48 +++--------------------------
drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 +-
2 files changed, 5 insertions(+), 45 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index 8c85a4b..6e6abdc 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -2458,42 +2458,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
return err;
}
-static int mtk_get_chip_id(struct mtk_eth *eth, u32 *chip_id)
-{
- u32 val[2], id[4];
-
- regmap_read(eth->ethsys, ETHSYS_CHIPID0_3, &val[0]);
- regmap_read(eth->ethsys, ETHSYS_CHIPID4_7, &val[1]);
-
- id[3] = ((val[0] >> 16) & 0xff) - '0';
- id[2] = ((val[0] >> 24) & 0xff) - '0';
- id[1] = (val[1] & 0xff) - '0';
- id[0] = ((val[1] >> 8) & 0xff) - '0';
-
- *chip_id = (id[3] * 1000) + (id[2] * 100) +
- (id[1] * 10) + id[0];
-
- if (!(*chip_id)) {
- dev_err(eth->dev, "failed to get chip id\n");
- return -ENODEV;
- }
-
- dev_info(eth->dev, "chip id = %d\n", *chip_id);
-
- return 0;
-}
-
-static bool mtk_is_hwlro_supported(struct mtk_eth *eth)
-{
- switch (eth->chip_id) {
- case MT7622_ETH:
- case MT7623_ETH:
- return true;
- }
-
- return false;
-}
-
static int mtk_probe(struct platform_device *pdev)
{
struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -2572,11 +2536,7 @@ static int mtk_probe(struct platform_device *pdev)
if (err)
return err;
- err = mtk_get_chip_id(eth, ð->chip_id);
- if (err)
- return err;
-
- eth->hwlro = mtk_is_hwlro_supported(eth);
+ eth->hwlro = MTK_HAS_CAPS(eth->soc->caps, MTK_HWLRO);
for_each_child_of_node(pdev->dev.of_node, mac_np) {
if (!of_device_is_compatible(mac_np,
@@ -2665,19 +2625,19 @@ static int mtk_remove(struct platform_device *pdev)
}
static const struct mtk_soc_data mt2701_data = {
- .caps = MTK_GMAC1_TRGMII,
+ .caps = MTK_GMAC1_TRGMII | MTK_HWLRO,
.required_clks = MT7623_CLKS_BITMAP,
.required_pctl = true,
};
static const struct mtk_soc_data mt7622_data = {
- .caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW,
+ .caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW | MTK_HWLRO,
.required_clks = MT7622_CLKS_BITMAP,
.required_pctl = false,
};
static const struct mtk_soc_data mt7623_data = {
- .caps = MTK_GMAC1_TRGMII,
+ .caps = MTK_GMAC1_TRGMII | MTK_HWLRO,
.required_clks = MT7623_CLKS_BITMAP,
.required_pctl = true,
};
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
index 672b8c3..4681929 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -566,6 +566,7 @@ struct mtk_rx_ring {
#define MTK_GMAC2_SGMII (BIT(10) | MTK_SGMII)
#define MTK_DUAL_GMAC_SHARED_SGMII (BIT(11) | MTK_GMAC1_SGMII | \
MTK_GMAC2_SGMII)
+#define MTK_HWLRO BIT(12)
#define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x))
/* struct mtk_eth_data - This is the structure holding all differences
@@ -635,7 +636,6 @@ struct mtk_eth {
struct regmap *ethsys;
struct regmap *sgmiisys;
struct regmap *pctl;
- u32 chip_id;
bool hwlro;
refcount_t dma_refcnt;
struct mtk_tx_ring tx_ring;
--
2.7.4
^ permalink raw reply related
* [PATCH net-next 1/2] net-next: mediatek: improve more with using dma_zalloc_coherent
From: sean.wang @ 2018-07-28 5:35 UTC (permalink / raw)
To: john, davem; +Cc: nbd, netdev, linux-kernel, linux-mediatek, Sean Wang
From: Sean Wang <sean.wang@mediatek.com>
Improve more in the existing code by reusing dma_zalloc_coherent instead
of dma_alloc_coherent with __GFP_ZERO or superfluous zeroing buffer.
Signed-off-by: Sean Wang <sean.wang@mediatek.com>
---
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
index c30aea2..8c85a4b 100644
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -605,10 +605,10 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
dma_addr_t dma_addr;
int i;
- eth->scratch_ring = dma_alloc_coherent(eth->dev,
- cnt * sizeof(struct mtk_tx_dma),
- ð->phy_scratch_ring,
- GFP_ATOMIC | __GFP_ZERO);
+ eth->scratch_ring = dma_zalloc_coherent(eth->dev,
+ cnt * sizeof(struct mtk_tx_dma),
+ ð->phy_scratch_ring,
+ GFP_ATOMIC);
if (unlikely(!eth->scratch_ring))
return -ENOMEM;
@@ -623,7 +623,6 @@ static int mtk_init_fq_dma(struct mtk_eth *eth)
if (unlikely(dma_mapping_error(eth->dev, dma_addr)))
return -ENOMEM;
- memset(eth->scratch_ring, 0x0, sizeof(struct mtk_tx_dma) * cnt);
phy_ring_tail = eth->phy_scratch_ring +
(sizeof(struct mtk_tx_dma) * (cnt - 1));
@@ -1318,10 +1317,9 @@ static int mtk_rx_alloc(struct mtk_eth *eth, int ring_no, int rx_flag)
return -ENOMEM;
}
- ring->dma = dma_alloc_coherent(eth->dev,
- rx_dma_size * sizeof(*ring->dma),
- &ring->phys,
- GFP_ATOMIC | __GFP_ZERO);
+ ring->dma = dma_zalloc_coherent(eth->dev,
+ rx_dma_size * sizeof(*ring->dma),
+ &ring->phys, GFP_ATOMIC);
if (!ring->dma)
return -ENOMEM;
--
2.7.4
^ permalink raw reply related
* [PATCH net] nfp: flower: fix port metadata conversion bug
From: Jakub Kicinski @ 2018-07-28 3:56 UTC (permalink / raw)
To: davem; +Cc: oss-drivers, netdev, John Hurley, Jakub Kicinski
From: John Hurley <john.hurley@netronome.com>
Function nfp_flower_repr_get_type_and_port expects an enum nfp_repr_type
return value but, if the repr type is unknown, returns a value of type
enum nfp_flower_cmsg_port_type. This means that if FW encodes the port
ID in a way the driver does not understand instead of dropping the frame
driver may attribute it to a physical port (uplink) provided the port
number is less than physical port count.
Fix this and ensure a net_device of NULL is returned if the repr can not
be determined.
Fixes: 1025351a88a4 ("nfp: add flower app")
Signed-off-by: John Hurley <john.hurley@netronome.com>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
This is low impact and unlikely, but also fix is trivial so either
net or net-next works.
drivers/net/ethernet/netronome/nfp/flower/main.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/netronome/nfp/flower/main.c b/drivers/net/ethernet/netronome/nfp/flower/main.c
index 1decf3a1cad3..e57d23746585 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/main.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/main.c
@@ -80,7 +80,7 @@ nfp_flower_repr_get_type_and_port(struct nfp_app *app, u32 port_id, u8 *port)
return NFP_REPR_TYPE_VF;
}
- return NFP_FLOWER_CMSG_PORT_TYPE_UNSPEC;
+ return __NFP_REPR_TYPE_MAX;
}
static struct net_device *
@@ -91,6 +91,8 @@ nfp_flower_repr_get(struct nfp_app *app, u32 port_id)
u8 port = 0;
repr_type = nfp_flower_repr_get_type_and_port(app, port_id, &port);
+ if (repr_type > NFP_REPR_TYPE_MAX)
+ return NULL;
reprs = rcu_dereference(app->reprs[repr_type]);
if (!reprs)
--
2.17.1
^ permalink raw reply related
* Re: [PATCH net-next 2/2] tcp: propagate GSO to the new skb built in tcp collapse
From: Yafang Shao @ 2018-07-28 3:22 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, LKML
In-Reply-To: <CANn89iKFH_F0_Ri76Zsez2Nn8JZ9obprsk+OE7i+enGC=n8Syw@mail.gmail.com>
On Sat, Jul 28, 2018 at 11:13 AM, Eric Dumazet <edumazet@google.com> wrote:
> On Fri, Jul 27, 2018 at 8:02 PM Yafang Shao <laoar.shao@gmail.com> wrote:
>>
>> Currently the collapsed SKB doesn't propagate the GSO information to the
>> new SKB.
>> The GSO should be propagated for better tracking, i.e. when this SKB is
>> dropped we could know how many network segments are dropped.
>
> What is "the GSO" ?
>
I mean gso_segs, gso_type and gso_size, which are all set in GRO.
>>
>> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
>> ---
>> net/ipv4/tcp_input.c | 12 ++++++++++--
>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
>> index 90f83eb..af52e4e 100644
>> --- a/net/ipv4/tcp_input.c
>> +++ b/net/ipv4/tcp_input.c
>> @@ -4893,6 +4893,8 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
>> if (!nskb)
>> break;
>>
>> + skb_shinfo(nskb)->gso_size = skb_shinfo(skb)->gso_size;
>> + skb_shinfo(nskb)->gso_type = skb_shinfo(skb)->gso_type;
>
> Why gso_size and gso_type are important ?
>
> Where later in the stack these values are used ?
>
I'm not sure it is important or not.
I just worry it may be used latter.
>> memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
>> #ifdef CONFIG_TLS_DEVICE
>> nskb->decrypted = skb->decrypted;
>> @@ -4906,18 +4908,24 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
>>
>> /* Copy data, releasing collapsed skbs. */
>> while (copy > 0) {
>> - int offset = start - TCP_SKB_CB(skb)->seq;
>> int size = TCP_SKB_CB(skb)->end_seq - start;
>> + int offset = start - TCP_SKB_CB(skb)->seq;
>
>>
>> BUG_ON(offset < 0);
>> if (size > 0) {
>> - size = min(copy, size);
>> + if (copy >= size)
>> + skb_shinfo(nskb)->gso_segs +=
>> + max_t(u16, 1, skb_shinfo(skb)->gso_segs);
>> + else
>> + size = copy;
>> +
>
> So... what happens if copy was partial ?
>
In the current patch, if copy was parial, the gso_segs are in the
orignal SKB as it will not be freed now.
If that is not ok, what about the bellow change ?
else {
size = copy;
skb_shinfo(nskb)->gso_segs += DIV_ROUND_UP(size,
skb_shinfo(nskb)->gso_size);
}
> Your patch does not really fix the uncertainty, it merely shifts it a bit.
^ permalink raw reply
* [PATCH bpf] net: xsk: don't return frames via the allocator on error
From: Jakub Kicinski @ 2018-07-28 3:20 UTC (permalink / raw)
To: alexei.starovoitov, daniel
Cc: oss-drivers, netdev, bjorn.topel, Jakub Kicinski
xdp_return_buff() is used when frame has been successfully
handled (transmitted) or if an error occurred during delayed
processing and there is no way to report it back to
xdp_do_redirect().
In case of __xsk_rcv_zc() error is propagated all the way
back to the driver, so there is no need to call
xdp_return_buff(). Driver will recycle the frame anyway
after seeing that error happened.
Fixes: 173d3adb6f43 ("xsk: add zero-copy support for Rx")
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
Patch could as well be applied to bpf-next, since there are no drivers
for AF_XDP in tree, yet. xdp_umem_get_dma() and xdp_umem_get_data() are
not even exported. But one could reimplent those...
As I mentioned I think this makes the entire MEM_TYPE_ZERO_COPY allocator
handling dead code now :(
net/xdp/xsk.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 72335c2e8108..4e937cd7c17d 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -84,10 +84,8 @@ static int __xsk_rcv_zc(struct xdp_sock *xs, struct xdp_buff *xdp, u32 len)
{
int err = xskq_produce_batch_desc(xs->rx, (u64)xdp->handle, len);
- if (err) {
- xdp_return_buff(xdp);
+ if (err)
xs->rx_dropped++;
- }
return err;
}
--
2.17.1
^ permalink raw reply related
* [PATCH net-next 1/2] tcp: call tcp_drop() in tcp collapse
From: Yafang Shao @ 2018-07-28 3:01 UTC (permalink / raw)
To: edumazet, davem; +Cc: netdev, linux-kernel, Yafang Shao
When this SKB is dropped, we should add the counter sk_drops.
That could help us better tracking this behavior.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
net/ipv4/tcp_input.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index d51fa35..90f83eb 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4802,7 +4802,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
else
rb_erase(&skb->rbnode, root);
- __kfree_skb(skb);
+ tcp_drop(sk, skb);
NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPRCVCOLLAPSED);
return next;
--
1.8.3.1
^ permalink raw reply related
* linux-next: Signed-off-by missing for commit in the net-next tree
From: Stephen Rothwell @ 2018-07-28 4:21 UTC (permalink / raw)
To: David Miller, Networking
Cc: Linux-Next Mailing List, Linux Kernel Mailing List, Dave Taht
[-- Attachment #1: Type: text/plain, Size: 177 bytes --]
Hi all,
Commit
2db6dc2662ba ("sch_cake: Make gso-splitting configurable from userspace")
is missing a Signed-off-by from its author.
--
Cheers,
Stephen Rothwell
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [PATCH net-next 1/2] tcp: call tcp_drop() in tcp collapse
From: Eric Dumazet @ 2018-07-28 3:38 UTC (permalink / raw)
To: Yafang Shao; +Cc: David Miller, netdev, LKML
In-Reply-To: <CALOAHbC4Rs7w1RwZRBsw_fjGSDvuHV37=nguzJNZzkreR5f4Dw@mail.gmail.com>
On Fri, Jul 27, 2018 at 8:35 PM Yafang Shao <laoar.shao@gmail.com> wrote:
> So what about LINUX_MIB_TCPOFOMERGE ?
> Regarding LINUX_MIB_TCPOFOMERGE, a skb is already covered by another
> skb, is that dropping the packet or simply lowering the memory
> overhead ?
What do you think ?
If you receive two times the same payload, don't you have to drop one
of the duplicate ?
There is a a big difference between the two cases.
^ permalink raw reply
* Re: [PATCH net-next 1/2] tcp: call tcp_drop() in tcp collapse
From: Yafang Shao @ 2018-07-28 3:34 UTC (permalink / raw)
To: Eric Dumazet; +Cc: David Miller, netdev, LKML
In-Reply-To: <CANn89iJ=Ad7sVWr3zBmXNSyePJJZaxgnMymN8S7x6fCSvG2jTQ@mail.gmail.com>
On Sat, Jul 28, 2018 at 11:06 AM, Eric Dumazet <edumazet@google.com> wrote:
> On Fri, Jul 27, 2018 at 8:02 PM Yafang Shao <laoar.shao@gmail.com> wrote:
>>
>> When this SKB is dropped, we should add the counter sk_drops.
>> That could help us better tracking this behavior.
>>
>> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
>> ---
>> net/ipv4/tcp_input.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
>> index d51fa35..90f83eb 100644
>> --- a/net/ipv4/tcp_input.c
>> +++ b/net/ipv4/tcp_input.c
>> @@ -4802,7 +4802,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
>> else
>> rb_erase(&skb->rbnode, root);
>>
>> - __kfree_skb(skb);
>> + tcp_drop(sk, skb);
>
>
> Absolutely not.
>
> We do not drop the packet, we have simply lowered the memory overhead.
So what about LINUX_MIB_TCPOFOMERGE ?
Regarding LINUX_MIB_TCPOFOMERGE, a skb is already covered by another
skb, is that dropping the packet or simply lowering the memory
overhead ?
Thanks
Yafang
^ permalink raw reply
* Re: [PATCH net-next 2/2] tcp: propagate GSO to the new skb built in tcp collapse
From: Eric Dumazet @ 2018-07-28 3:13 UTC (permalink / raw)
To: Yafang Shao; +Cc: David Miller, netdev, LKML
In-Reply-To: <1532746900-11710-2-git-send-email-laoar.shao@gmail.com>
On Fri, Jul 27, 2018 at 8:02 PM Yafang Shao <laoar.shao@gmail.com> wrote:
>
> Currently the collapsed SKB doesn't propagate the GSO information to the
> new SKB.
> The GSO should be propagated for better tracking, i.e. when this SKB is
> dropped we could know how many network segments are dropped.
What is "the GSO" ?
>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
> net/ipv4/tcp_input.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index 90f83eb..af52e4e 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4893,6 +4893,8 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
> if (!nskb)
> break;
>
> + skb_shinfo(nskb)->gso_size = skb_shinfo(skb)->gso_size;
> + skb_shinfo(nskb)->gso_type = skb_shinfo(skb)->gso_type;
Why gso_size and gso_type are important ?
Where later in the stack these values are used ?
> memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
> #ifdef CONFIG_TLS_DEVICE
> nskb->decrypted = skb->decrypted;
> @@ -4906,18 +4908,24 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
>
> /* Copy data, releasing collapsed skbs. */
> while (copy > 0) {
> - int offset = start - TCP_SKB_CB(skb)->seq;
> int size = TCP_SKB_CB(skb)->end_seq - start;
> + int offset = start - TCP_SKB_CB(skb)->seq;
>
> BUG_ON(offset < 0);
> if (size > 0) {
> - size = min(copy, size);
> + if (copy >= size)
> + skb_shinfo(nskb)->gso_segs +=
> + max_t(u16, 1, skb_shinfo(skb)->gso_segs);
> + else
> + size = copy;
> +
So... what happens if copy was partial ?
Your patch does not really fix the uncertainty, it merely shifts it a bit.
^ permalink raw reply
* Re: [PATCH net-next 1/2] tcp: call tcp_drop() in tcp collapse
From: Eric Dumazet @ 2018-07-28 3:06 UTC (permalink / raw)
To: Yafang Shao; +Cc: David Miller, netdev, LKML
In-Reply-To: <1532746900-11710-1-git-send-email-laoar.shao@gmail.com>
On Fri, Jul 27, 2018 at 8:02 PM Yafang Shao <laoar.shao@gmail.com> wrote:
>
> When this SKB is dropped, we should add the counter sk_drops.
> That could help us better tracking this behavior.
>
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
> net/ipv4/tcp_input.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
> index d51fa35..90f83eb 100644
> --- a/net/ipv4/tcp_input.c
> +++ b/net/ipv4/tcp_input.c
> @@ -4802,7 +4802,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
> else
> rb_erase(&skb->rbnode, root);
>
> - __kfree_skb(skb);
> + tcp_drop(sk, skb);
Absolutely not.
We do not drop the packet, we have simply lowered the memory overhead.
^ permalink raw reply
* [PATCH net-next 2/2] tcp: propagate GSO to the new skb built in tcp collapse
From: Yafang Shao @ 2018-07-28 3:01 UTC (permalink / raw)
To: edumazet, davem; +Cc: netdev, linux-kernel, Yafang Shao
In-Reply-To: <1532746900-11710-1-git-send-email-laoar.shao@gmail.com>
Currently the collapsed SKB doesn't propagate the GSO information to the
new SKB.
The GSO should be propagated for better tracking, i.e. when this SKB is
dropped we could know how many network segments are dropped.
Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
net/ipv4/tcp_input.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index 90f83eb..af52e4e 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -4893,6 +4893,8 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
if (!nskb)
break;
+ skb_shinfo(nskb)->gso_size = skb_shinfo(skb)->gso_size;
+ skb_shinfo(nskb)->gso_type = skb_shinfo(skb)->gso_type;
memcpy(nskb->cb, skb->cb, sizeof(skb->cb));
#ifdef CONFIG_TLS_DEVICE
nskb->decrypted = skb->decrypted;
@@ -4906,18 +4908,24 @@ void tcp_rbtree_insert(struct rb_root *root, struct sk_buff *skb)
/* Copy data, releasing collapsed skbs. */
while (copy > 0) {
- int offset = start - TCP_SKB_CB(skb)->seq;
int size = TCP_SKB_CB(skb)->end_seq - start;
+ int offset = start - TCP_SKB_CB(skb)->seq;
BUG_ON(offset < 0);
if (size > 0) {
- size = min(copy, size);
+ if (copy >= size)
+ skb_shinfo(nskb)->gso_segs +=
+ max_t(u16, 1, skb_shinfo(skb)->gso_segs);
+ else
+ size = copy;
+
if (skb_copy_bits(skb, offset, skb_put(nskb, size), size))
BUG();
TCP_SKB_CB(nskb)->end_seq += size;
copy -= size;
start += size;
}
+
if (!before(start, TCP_SKB_CB(skb)->end_seq)) {
skb = tcp_collapse_one(sk, skb, list, root);
if (!skb ||
--
1.8.3.1
^ permalink raw reply related
* [PATCH net] enic: handle mtu change for vf properly
From: Govindarajulu Varadarajan @ 2018-07-27 18:19 UTC (permalink / raw)
To: davem, netdev; +Cc: benve, Govindarajulu Varadarajan
When driver gets notification for mtu change, driver does not handle it for
all RQs. It handles only RQ[0].
Fix is to use enic_change_mtu() interface to change mtu for vf.
Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
---
drivers/net/ethernet/cisco/enic/enic_main.c | 78 +++++++--------------
1 file changed, 27 insertions(+), 51 deletions(-)
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 90c645b8538e..6b0376123cde 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2047,28 +2047,42 @@ static int enic_stop(struct net_device *netdev)
return 0;
}
+static int _enic_change_mtu(struct net_device *netdev, int new_mtu)
+{
+ bool running = netif_running(netdev);
+ int err = 0;
+
+ ASSERT_RTNL();
+ if (running) {
+ err = enic_stop(netdev);
+ if (err)
+ return err;
+ }
+
+ netdev->mtu = new_mtu;
+
+ if (running) {
+ err = enic_open(netdev);
+ if (err)
+ return err;
+ }
+
+ return 0;
+}
+
static int enic_change_mtu(struct net_device *netdev, int new_mtu)
{
struct enic *enic = netdev_priv(netdev);
- int running = netif_running(netdev);
if (enic_is_dynamic(enic) || enic_is_sriov_vf(enic))
return -EOPNOTSUPP;
- if (running)
- enic_stop(netdev);
-
- netdev->mtu = new_mtu;
-
if (netdev->mtu > enic->port_mtu)
netdev_warn(netdev,
- "interface MTU (%d) set higher than port MTU (%d)\n",
- netdev->mtu, enic->port_mtu);
+ "interface MTU (%d) set higher than port MTU (%d)\n",
+ netdev->mtu, enic->port_mtu);
- if (running)
- enic_open(netdev);
-
- return 0;
+ return _enic_change_mtu(netdev, new_mtu);
}
static void enic_change_mtu_work(struct work_struct *work)
@@ -2076,47 +2090,9 @@ static void enic_change_mtu_work(struct work_struct *work)
struct enic *enic = container_of(work, struct enic, change_mtu_work);
struct net_device *netdev = enic->netdev;
int new_mtu = vnic_dev_mtu(enic->vdev);
- int err;
- unsigned int i;
-
- new_mtu = max_t(int, ENIC_MIN_MTU, min_t(int, ENIC_MAX_MTU, new_mtu));
rtnl_lock();
-
- /* Stop RQ */
- del_timer_sync(&enic->notify_timer);
-
- for (i = 0; i < enic->rq_count; i++)
- napi_disable(&enic->napi[i]);
-
- vnic_intr_mask(&enic->intr[0]);
- enic_synchronize_irqs(enic);
- err = vnic_rq_disable(&enic->rq[0]);
- if (err) {
- rtnl_unlock();
- netdev_err(netdev, "Unable to disable RQ.\n");
- return;
- }
- vnic_rq_clean(&enic->rq[0], enic_free_rq_buf);
- vnic_cq_clean(&enic->cq[0]);
- vnic_intr_clean(&enic->intr[0]);
-
- /* Fill RQ with new_mtu-sized buffers */
- netdev->mtu = new_mtu;
- vnic_rq_fill(&enic->rq[0], enic_rq_alloc_buf);
- /* Need at least one buffer on ring to get going */
- if (vnic_rq_desc_used(&enic->rq[0]) == 0) {
- rtnl_unlock();
- netdev_err(netdev, "Unable to alloc receive buffers.\n");
- return;
- }
-
- /* Start RQ */
- vnic_rq_enable(&enic->rq[0]);
- napi_enable(&enic->napi[0]);
- vnic_intr_unmask(&enic->intr[0]);
- enic_notify_timer_start(enic);
-
+ (void)_enic_change_mtu(netdev, new_mtu);
rtnl_unlock();
netdev_info(netdev, "interface MTU set as %d\n", netdev->mtu);
--
2.17.1
^ permalink raw reply related
* [net-next V2 11/12] net/mlx5e: Vxlan, move vxlan logic to core driver
From: Saeed Mahameed @ 2018-07-28 0:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
In-Reply-To: <20180728000622.4123-1-saeedm@mellanox.com>
Move vxlan logic and objects to mlx5 core dirver.
Since it going to be used from different mlx5 interfaces.
e.g. mlx5e PF NIC netdev and mlx5e E-Switch representors.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
.../net/ethernet/mellanox/mlx5/core/Makefile | 4 ++--
drivers/net/ethernet/mellanox/mlx5/core/en.h | 2 --
.../net/ethernet/mellanox/mlx5/core/en_main.c | 21 ++++++++-----------
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 6 +++---
.../mellanox/mlx5/core/{ => lib}/vxlan.c | 0
.../mellanox/mlx5/core/{ => lib}/vxlan.h | 0
.../net/ethernet/mellanox/mlx5/core/main.c | 5 +++++
include/linux/mlx5/driver.h | 2 ++
8 files changed, 21 insertions(+), 19 deletions(-)
rename drivers/net/ethernet/mellanox/mlx5/core/{ => lib}/vxlan.c (100%)
rename drivers/net/ethernet/mellanox/mlx5/core/{ => lib}/vxlan.h (100%)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Makefile b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
index ae2bdcb1647c..f20fda1ced4f 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Makefile
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Makefile
@@ -14,8 +14,8 @@ mlx5_core-$(CONFIG_MLX5_FPGA) += fpga/cmd.o fpga/core.o fpga/conn.o fpga/sdk.o \
fpga/ipsec.o fpga/tls.o
mlx5_core-$(CONFIG_MLX5_CORE_EN) += en_main.o en_common.o en_fs.o en_ethtool.o \
- en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o vxlan.o \
- en_arfs.o en_fs_ethtool.o en_selftest.o en/port.o
+ en_tx.o en_rx.o en_dim.o en_txrx.o en/xdp.o en_stats.o \
+ en_arfs.o en_fs_ethtool.o en_selftest.o en/port.o lib/vxlan.o
mlx5_core-$(CONFIG_MLX5_MPFS) += lib/mpfs.o
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 1bd4536b9061..c7ed3d20fd54 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -52,7 +52,6 @@
#include "wq.h"
#include "mlx5_core.h"
#include "en_stats.h"
-#include "vxlan.h"
struct page_pool;
@@ -812,7 +811,6 @@ struct mlx5e_priv {
u32 tx_rates[MLX5E_MAX_NUM_SQS];
struct mlx5e_flow_steering fs;
- struct mlx5_vxlan *vxlan;
struct workqueue_struct *wq;
struct work_struct update_carrier_work;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index ef4b2f0c427c..fde35021a257 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -45,7 +45,7 @@
#include "en_accel/tls.h"
#include "accel/ipsec.h"
#include "accel/tls.h"
-#include "vxlan.h"
+#include "lib/vxlan.h"
#include "en/port.h"
#include "en/xdp.h"
@@ -2974,7 +2974,7 @@ int mlx5e_open(struct net_device *netdev)
mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP);
mutex_unlock(&priv->state_lock);
- if (mlx5_vxlan_allowed(priv->vxlan))
+ if (mlx5_vxlan_allowed(priv->mdev->vxlan))
udp_tunnel_get_rx_info(netdev);
return err;
@@ -3983,7 +3983,7 @@ static void mlx5e_vxlan_add_work(struct work_struct *work)
u16 port = vxlan_work->port;
mutex_lock(&priv->state_lock);
- mlx5_vxlan_add_port(priv->vxlan, port);
+ mlx5_vxlan_add_port(priv->mdev->vxlan, port);
mutex_unlock(&priv->state_lock);
kfree(vxlan_work);
@@ -3997,7 +3997,7 @@ static void mlx5e_vxlan_del_work(struct work_struct *work)
u16 port = vxlan_work->port;
mutex_lock(&priv->state_lock);
- mlx5_vxlan_del_port(priv->vxlan, port);
+ mlx5_vxlan_del_port(priv->mdev->vxlan, port);
mutex_unlock(&priv->state_lock);
kfree(vxlan_work);
}
@@ -4028,7 +4028,7 @@ static void mlx5e_add_vxlan_port(struct net_device *netdev,
if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
return;
- if (!mlx5_vxlan_allowed(priv->vxlan))
+ if (!mlx5_vxlan_allowed(priv->mdev->vxlan))
return;
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 1);
@@ -4042,7 +4042,7 @@ static void mlx5e_del_vxlan_port(struct net_device *netdev,
if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
return;
- if (!mlx5_vxlan_allowed(priv->vxlan))
+ if (!mlx5_vxlan_allowed(priv->mdev->vxlan))
return;
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 0);
@@ -4076,7 +4076,7 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
port = be16_to_cpu(udph->dest);
/* Verify if UDP port is being offloaded by HW */
- if (mlx5_vxlan_lookup_port(priv->vxlan, port))
+ if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, port))
return features;
}
@@ -4648,7 +4648,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
netdev->hw_features |= NETIF_F_HW_VLAN_STAG_TX;
- if (mlx5_vxlan_allowed(priv->vxlan) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
+ if (mlx5_vxlan_allowed(mdev->vxlan) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
netdev->hw_enc_features |= NETIF_F_IP_CSUM;
netdev->hw_enc_features |= NETIF_F_IPV6_CSUM;
netdev->hw_enc_features |= NETIF_F_TSO;
@@ -4656,7 +4656,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
netdev->hw_enc_features |= NETIF_F_GSO_PARTIAL;
}
- if (mlx5_vxlan_allowed(priv->vxlan)) {
+ if (mlx5_vxlan_allowed(mdev->vxlan)) {
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_GSO_UDP_TUNNEL_CSUM;
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL |
@@ -4758,8 +4758,6 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
struct mlx5e_priv *priv = netdev_priv(netdev);
int err;
- priv->vxlan = mlx5_vxlan_create(mdev);
-
mlx5e_build_nic_netdev_priv(mdev, netdev, profile, ppriv);
err = mlx5e_ipsec_init(priv);
if (err)
@@ -4773,7 +4771,6 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
{
- mlx5_vxlan_destroy(priv->vxlan);
mlx5e_tls_cleanup(priv);
mlx5e_ipsec_cleanup(priv);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 1b4931b62094..288a57f76e84 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -50,7 +50,7 @@
#include "en_rep.h"
#include "en_tc.h"
#include "eswitch.h"
-#include "vxlan.h"
+#include "lib/vxlan.h"
#include "fs_core.h"
#include "en/port.h"
@@ -1133,7 +1133,7 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
goto vxlan_match_offload_err;
- if (mlx5_vxlan_lookup_port(up_priv->vxlan, be16_to_cpu(key->dst)) &&
+ if (mlx5_vxlan_lookup_port(up_priv->mdev->vxlan, be16_to_cpu(key->dst)) &&
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
parse_vxlan_attr(spec, f);
else {
@@ -2557,7 +2557,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
return -EOPNOTSUPP;
}
- if (mlx5_vxlan_lookup_port(up_priv->vxlan, be16_to_cpu(key->tp_dst)) &&
+ if (mlx5_vxlan_lookup_port(up_priv->mdev->vxlan, be16_to_cpu(key->tp_dst)) &&
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
tunnel_type = MLX5_HEADER_TYPE_VXLAN;
} else {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
similarity index 100%
rename from drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
rename to drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.c
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h b/drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h
similarity index 100%
rename from drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
rename to drivers/net/ethernet/mellanox/mlx5/core/lib/vxlan.h
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index 6ddbb70e95de..03b9c6733eed 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -62,6 +62,7 @@
#include "accel/ipsec.h"
#include "accel/tls.h"
#include "lib/clock.h"
+#include "lib/vxlan.h"
#include "diag/fw_tracer.h"
MODULE_AUTHOR("Eli Cohen <eli@mellanox.com>");
@@ -961,6 +962,8 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
mlx5_init_clock(dev);
+ dev->vxlan = mlx5_vxlan_create(dev);
+
err = mlx5_init_rl_table(dev);
if (err) {
dev_err(&pdev->dev, "Failed to init rate limiting\n");
@@ -1004,6 +1007,7 @@ static int mlx5_init_once(struct mlx5_core_dev *dev, struct mlx5_priv *priv)
err_rl_cleanup:
mlx5_cleanup_rl_table(dev);
err_tables_cleanup:
+ mlx5_vxlan_destroy(dev->vxlan);
mlx5_cleanup_mkey_table(dev);
mlx5_cleanup_srq_table(dev);
mlx5_cleanup_qp_table(dev);
@@ -1024,6 +1028,7 @@ static void mlx5_cleanup_once(struct mlx5_core_dev *dev)
mlx5_eswitch_cleanup(dev->priv.eswitch);
mlx5_mpfs_cleanup(dev);
mlx5_cleanup_rl_table(dev);
+ mlx5_vxlan_destroy(dev->vxlan);
mlx5_cleanup_clock(dev);
mlx5_cleanup_reserved_gids(dev);
mlx5_cleanup_mkey_table(dev);
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h
index fd0aaa5568fe..54f385cc8811 100644
--- a/include/linux/mlx5/driver.h
+++ b/include/linux/mlx5/driver.h
@@ -818,6 +818,7 @@ struct mlx5_clock {
};
struct mlx5_fw_tracer;
+struct mlx5_vxlan;
struct mlx5_core_dev {
struct pci_dev *pdev;
@@ -850,6 +851,7 @@ struct mlx5_core_dev {
atomic_t num_qps;
u32 issi;
struct mlx5e_resources mlx5e_res;
+ struct mlx5_vxlan *vxlan;
struct {
struct mlx5_rsvd_gids reserved_gids;
u32 roce_en;
--
2.17.0
^ permalink raw reply related
* [net-next V2 08/12] net/mlx5e: Vxlan, rename from mlx5e to mlx5
From: Saeed Mahameed @ 2018-07-28 0:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
In-Reply-To: <20180728000622.4123-1-saeedm@mellanox.com>
Rename vxlan functions from mlx5e_vxlan_* to mlx5_vxlan_*.
Rename mlx5e_vxlan_db to mlx5_vxlan and move it from en.h to vxlan.c
since it is not related to mlx5e anymore.
Allocate mlx5_vxlan structure dynamically in order to make it easier to
move later to core driver and to make it private in vxlan.c.
This is in preparation to move vxlan API to mlx5 core.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en.h | 10 +-
.../net/ethernet/mellanox/mlx5/core/en_main.c | 21 ++--
.../net/ethernet/mellanox/mlx5/core/en_tc.c | 4 +-
.../net/ethernet/mellanox/mlx5/core/vxlan.c | 118 ++++++++++--------
.../net/ethernet/mellanox/mlx5/core/vxlan.h | 30 +++--
5 files changed, 104 insertions(+), 79 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
index 6878925c3abf..1bd4536b9061 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@ -52,6 +52,7 @@
#include "wq.h"
#include "mlx5_core.h"
#include "en_stats.h"
+#include "vxlan.h"
struct page_pool;
@@ -654,13 +655,6 @@ enum {
MLX5E_STATE_DESTROYING,
};
-struct mlx5e_vxlan_db {
- spinlock_t lock; /* protect vxlan table */
- /* max_num_ports is usuallly 4, 16 buckets is more than enough */
- DECLARE_HASHTABLE(htable, 4);
- int num_ports;
-};
-
struct mlx5e_l2_rule {
u8 addr[ETH_ALEN + 2];
struct mlx5_flow_handle *rule;
@@ -818,7 +812,7 @@ struct mlx5e_priv {
u32 tx_rates[MLX5E_MAX_NUM_SQS];
struct mlx5e_flow_steering fs;
- struct mlx5e_vxlan_db vxlan;
+ struct mlx5_vxlan *vxlan;
struct workqueue_struct *wq;
struct work_struct update_carrier_work;
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 7a6b78e3b5f7..ef4b2f0c427c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@ -2974,7 +2974,7 @@ int mlx5e_open(struct net_device *netdev)
mlx5_set_port_admin_status(priv->mdev, MLX5_PORT_UP);
mutex_unlock(&priv->state_lock);
- if (mlx5e_vxlan_allowed(priv->mdev))
+ if (mlx5_vxlan_allowed(priv->vxlan))
udp_tunnel_get_rx_info(netdev);
return err;
@@ -3983,7 +3983,7 @@ static void mlx5e_vxlan_add_work(struct work_struct *work)
u16 port = vxlan_work->port;
mutex_lock(&priv->state_lock);
- mlx5e_vxlan_add_port(priv, port);
+ mlx5_vxlan_add_port(priv->vxlan, port);
mutex_unlock(&priv->state_lock);
kfree(vxlan_work);
@@ -3997,7 +3997,7 @@ static void mlx5e_vxlan_del_work(struct work_struct *work)
u16 port = vxlan_work->port;
mutex_lock(&priv->state_lock);
- mlx5e_vxlan_del_port(priv, port);
+ mlx5_vxlan_del_port(priv->vxlan, port);
mutex_unlock(&priv->state_lock);
kfree(vxlan_work);
}
@@ -4028,7 +4028,7 @@ static void mlx5e_add_vxlan_port(struct net_device *netdev,
if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
return;
- if (!mlx5e_vxlan_allowed(priv->mdev))
+ if (!mlx5_vxlan_allowed(priv->vxlan))
return;
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 1);
@@ -4042,7 +4042,7 @@ static void mlx5e_del_vxlan_port(struct net_device *netdev,
if (ti->type != UDP_TUNNEL_TYPE_VXLAN)
return;
- if (!mlx5e_vxlan_allowed(priv->mdev))
+ if (!mlx5_vxlan_allowed(priv->vxlan))
return;
mlx5e_vxlan_queue_work(priv, be16_to_cpu(ti->port), 0);
@@ -4076,7 +4076,7 @@ static netdev_features_t mlx5e_tunnel_features_check(struct mlx5e_priv *priv,
port = be16_to_cpu(udph->dest);
/* Verify if UDP port is being offloaded by HW */
- if (mlx5e_vxlan_lookup_port(priv, port))
+ if (mlx5_vxlan_lookup_port(priv->vxlan, port))
return features;
}
@@ -4648,7 +4648,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
netdev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER;
netdev->hw_features |= NETIF_F_HW_VLAN_STAG_TX;
- if (mlx5e_vxlan_allowed(mdev) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
+ if (mlx5_vxlan_allowed(priv->vxlan) || MLX5_CAP_ETH(mdev, tunnel_stateless_gre)) {
netdev->hw_enc_features |= NETIF_F_IP_CSUM;
netdev->hw_enc_features |= NETIF_F_IPV6_CSUM;
netdev->hw_enc_features |= NETIF_F_TSO;
@@ -4656,7 +4656,7 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev)
netdev->hw_enc_features |= NETIF_F_GSO_PARTIAL;
}
- if (mlx5e_vxlan_allowed(mdev)) {
+ if (mlx5_vxlan_allowed(priv->vxlan)) {
netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL |
NETIF_F_GSO_UDP_TUNNEL_CSUM;
netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL |
@@ -4758,6 +4758,8 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
struct mlx5e_priv *priv = netdev_priv(netdev);
int err;
+ priv->vxlan = mlx5_vxlan_create(mdev);
+
mlx5e_build_nic_netdev_priv(mdev, netdev, profile, ppriv);
err = mlx5e_ipsec_init(priv);
if (err)
@@ -4767,14 +4769,13 @@ static void mlx5e_nic_init(struct mlx5_core_dev *mdev,
mlx5_core_err(mdev, "TLS initialization failed, %d\n", err);
mlx5e_build_nic_netdev(netdev);
mlx5e_build_tc2txq_maps(priv);
- mlx5e_vxlan_init(priv);
}
static void mlx5e_nic_cleanup(struct mlx5e_priv *priv)
{
+ mlx5_vxlan_destroy(priv->vxlan);
mlx5e_tls_cleanup(priv);
mlx5e_ipsec_cleanup(priv);
- mlx5e_vxlan_cleanup(priv);
}
static int mlx5e_init_nic_rx(struct mlx5e_priv *priv)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 1010ee983ab7..1b4931b62094 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1133,7 +1133,7 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
goto vxlan_match_offload_err;
- if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->dst)) &&
+ if (mlx5_vxlan_lookup_port(up_priv->vxlan, be16_to_cpu(key->dst)) &&
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
parse_vxlan_attr(spec, f);
else {
@@ -2557,7 +2557,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
return -EOPNOTSUPP;
}
- if (mlx5e_vxlan_lookup_port(up_priv, be16_to_cpu(key->tp_dst)) &&
+ if (mlx5_vxlan_lookup_port(up_priv->vxlan, be16_to_cpu(key->tp_dst)) &&
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
tunnel_type = MLX5_HEADER_TYPE_VXLAN;
} else {
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
index a2b48ad77f26..759260f52bdd 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
@@ -36,32 +36,26 @@
#include "mlx5_core.h"
#include "vxlan.h"
+struct mlx5_vxlan {
+ struct mlx5_core_dev *mdev;
+ spinlock_t lock; /* protect vxlan table */
+ int num_ports;
+ /* max_num_ports is usuallly 4, 16 buckets is more than enough */
+ DECLARE_HASHTABLE(htable, 4);
+};
+
struct mlx5_vxlan_port {
struct hlist_node hlist;
atomic_t refcount;
u16 udp_port;
};
-void mlx5e_vxlan_init(struct mlx5e_priv *priv)
-{
- struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
-
- spin_lock_init(&vxlan_db->lock);
- hash_init(vxlan_db->htable);
-
- if (mlx5e_vxlan_allowed(priv->mdev))
- /* Hardware adds 4789 by default.
- * Lockless since we are the only hash table consumers, wq and TX are disabled.
- */
- mlx5e_vxlan_add_port(priv, 4789);
-}
-
-static inline u8 mlx5e_vxlan_max_udp_ports(struct mlx5_core_dev *mdev)
+static inline u8 mlx5_vxlan_max_udp_ports(struct mlx5_core_dev *mdev)
{
return MLX5_CAP_ETH(mdev, max_vxlan_udp_ports) ?: 4;
}
-static int mlx5e_vxlan_core_add_port_cmd(struct mlx5_core_dev *mdev, u16 port)
+static int mlx5_vxlan_core_add_port_cmd(struct mlx5_core_dev *mdev, u16 port)
{
u32 in[MLX5_ST_SZ_DW(add_vxlan_udp_dport_in)] = {0};
u32 out[MLX5_ST_SZ_DW(add_vxlan_udp_dport_out)] = {0};
@@ -72,7 +66,7 @@ static int mlx5e_vxlan_core_add_port_cmd(struct mlx5_core_dev *mdev, u16 port)
return mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
}
-static int mlx5e_vxlan_core_del_port_cmd(struct mlx5_core_dev *mdev, u16 port)
+static int mlx5_vxlan_core_del_port_cmd(struct mlx5_core_dev *mdev, u16 port)
{
u32 in[MLX5_ST_SZ_DW(delete_vxlan_udp_dport_in)] = {0};
u32 out[MLX5_ST_SZ_DW(delete_vxlan_udp_dport_out)] = {0};
@@ -84,12 +78,11 @@ static int mlx5e_vxlan_core_del_port_cmd(struct mlx5_core_dev *mdev, u16 port)
}
static struct mlx5_vxlan_port*
-mlx5e_vxlan_lookup_port_locked(struct mlx5e_priv *priv, u16 port)
+mlx5_vxlan_lookup_port_locked(struct mlx5_vxlan *vxlan, u16 port)
{
- struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
struct mlx5_vxlan_port *vxlanp;
- hash_for_each_possible(vxlan_db->htable, vxlanp, hlist, port) {
+ hash_for_each_possible(vxlan->htable, vxlanp, hlist, port) {
if (vxlanp->udp_port == port)
return vxlanp;
}
@@ -97,37 +90,38 @@ mlx5e_vxlan_lookup_port_locked(struct mlx5e_priv *priv, u16 port)
return NULL;
}
-struct mlx5_vxlan_port *mlx5e_vxlan_lookup_port(struct mlx5e_priv *priv, u16 port)
+struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port)
{
- struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
struct mlx5_vxlan_port *vxlanp;
- spin_lock_bh(&vxlan_db->lock);
- vxlanp = mlx5e_vxlan_lookup_port_locked(priv, port);
- spin_unlock_bh(&vxlan_db->lock);
+ if (!mlx5_vxlan_allowed(vxlan))
+ return NULL;
+
+ spin_lock_bh(&vxlan->lock);
+ vxlanp = mlx5_vxlan_lookup_port_locked(vxlan, port);
+ spin_unlock_bh(&vxlan->lock);
return vxlanp;
}
-void mlx5e_vxlan_add_port(struct mlx5e_priv *priv, u16 port)
+void mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port)
{
- struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
struct mlx5_vxlan_port *vxlanp;
- vxlanp = mlx5e_vxlan_lookup_port(priv, port);
+ vxlanp = mlx5_vxlan_lookup_port(vxlan, port);
if (vxlanp) {
atomic_inc(&vxlanp->refcount);
return;
}
- if (vxlan_db->num_ports >= mlx5e_vxlan_max_udp_ports(priv->mdev)) {
- netdev_info(priv->netdev,
- "UDP port (%d) not offloaded, max number of UDP ports (%d) are already offloaded\n",
- port, mlx5e_vxlan_max_udp_ports(priv->mdev));
+ if (vxlan->num_ports >= mlx5_vxlan_max_udp_ports(vxlan->mdev)) {
+ mlx5_core_info(vxlan->mdev,
+ "UDP port (%d) not offloaded, max number of UDP ports (%d) are already offloaded\n",
+ port, mlx5_vxlan_max_udp_ports(vxlan->mdev));
return;
}
- if (mlx5e_vxlan_core_add_port_cmd(priv->mdev, port))
+ if (mlx5_vxlan_core_add_port_cmd(vxlan->mdev, port))
return;
vxlanp = kzalloc(sizeof(*vxlanp), GFP_KERNEL);
@@ -137,25 +131,24 @@ void mlx5e_vxlan_add_port(struct mlx5e_priv *priv, u16 port)
vxlanp->udp_port = port;
atomic_set(&vxlanp->refcount, 1);
- spin_lock_bh(&vxlan_db->lock);
- hash_add(vxlan_db->htable, &vxlanp->hlist, port);
- spin_unlock_bh(&vxlan_db->lock);
+ spin_lock_bh(&vxlan->lock);
+ hash_add(vxlan->htable, &vxlanp->hlist, port);
+ spin_unlock_bh(&vxlan->lock);
- vxlan_db->num_ports++;
+ vxlan->num_ports++;
return;
err_delete_port:
- mlx5e_vxlan_core_del_port_cmd(priv->mdev, port);
+ mlx5_vxlan_core_del_port_cmd(vxlan->mdev, port);
}
-void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port)
+void mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port)
{
- struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
struct mlx5_vxlan_port *vxlanp;
bool remove = false;
- spin_lock_bh(&vxlan_db->lock);
- vxlanp = mlx5e_vxlan_lookup_port_locked(priv, port);
+ spin_lock_bh(&vxlan->lock);
+ vxlanp = mlx5_vxlan_lookup_port_locked(vxlan, port);
if (!vxlanp)
goto out_unlock;
@@ -165,26 +158,51 @@ void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port)
}
out_unlock:
- spin_unlock_bh(&vxlan_db->lock);
+ spin_unlock_bh(&vxlan->lock);
if (remove) {
- mlx5e_vxlan_core_del_port_cmd(priv->mdev, port);
+ mlx5_vxlan_core_del_port_cmd(vxlan->mdev, port);
kfree(vxlanp);
- vxlan_db->num_ports--;
+ vxlan->num_ports--;
}
}
-void mlx5e_vxlan_cleanup(struct mlx5e_priv *priv)
+struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev)
+{
+ struct mlx5_vxlan *vxlan;
+
+ if (!MLX5_CAP_ETH(mdev, tunnel_stateless_vxlan) || !mlx5_core_is_pf(mdev))
+ return ERR_PTR(-ENOTSUPP);
+
+ vxlan = kzalloc(sizeof(*vxlan), GFP_KERNEL);
+ if (!vxlan)
+ return ERR_PTR(-ENOMEM);
+
+ vxlan->mdev = mdev;
+ spin_lock_init(&vxlan->lock);
+ hash_init(vxlan->htable);
+
+ /* Hardware adds 4789 by default */
+ mlx5_vxlan_add_port(vxlan, 4789);
+
+ return vxlan;
+}
+
+void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan)
{
- struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
struct mlx5_vxlan_port *vxlanp;
struct hlist_node *tmp;
int bkt;
- /* Lockless since we are the only hash table consumers, wq and TX are disabled */
- hash_for_each_safe(vxlan_db->htable, bkt, tmp, vxlanp, hlist) {
+ if (!mlx5_vxlan_allowed(vxlan))
+ return;
+
+ /* Lockless since we are the only hash table consumers*/
+ hash_for_each_safe(vxlan->htable, bkt, tmp, vxlanp, hlist) {
hash_del(&vxlanp->hlist);
- mlx5e_vxlan_core_del_port_cmd(priv->mdev, vxlanp->udp_port);
+ mlx5_vxlan_core_del_port_cmd(vxlan->mdev, vxlanp->udp_port);
kfree(vxlanp);
}
+
+ kfree(vxlan);
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
index 6b38b6fbd030..9d6327321814 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
@@ -33,20 +33,32 @@
#define __MLX5_VXLAN_H__
#include <linux/mlx5/driver.h>
-#include "en.h"
+struct mlx5_vxlan;
struct mlx5_vxlan_port;
-static inline bool mlx5e_vxlan_allowed(struct mlx5_core_dev *mdev)
+#ifdef CONFIG_MLX5_CORE_EN
+
+static inline bool mlx5_vxlan_allowed(struct mlx5_vxlan *vxlan)
{
- return (MLX5_CAP_ETH(mdev, tunnel_stateless_vxlan) &&
- mlx5_core_is_pf(mdev));
+ /* not allowed reason is encoded in vxlan pointer as error,
+ * on mlx5_vxlan_create
+ */
+ return !IS_ERR_OR_NULL(vxlan);
}
-void mlx5e_vxlan_init(struct mlx5e_priv *priv);
-void mlx5e_vxlan_cleanup(struct mlx5e_priv *priv);
-void mlx5e_vxlan_add_port(struct mlx5e_priv *priv, u16 port);
-void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port);
-struct mlx5_vxlan_port *mlx5e_vxlan_lookup_port(struct mlx5e_priv *priv, u16 port);
+struct mlx5_vxlan *mlx5_vxlan_create(struct mlx5_core_dev *mdev);
+void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan);
+void mlx5_vxlan_add_port(struct mlx5_vxlan *vxlan, u16 port);
+void mlx5_vxlan_del_port(struct mlx5_vxlan *vxlan, u16 port);
+struct mlx5_vxlan_port *mlx5_vxlan_lookup_port(struct mlx5_vxlan *vxlan, u16 port);
+
+#else
+
+static inline struct mlx5_vxlan*
+mlx5_vxlan_create(struct mlx5_core_dev *mdev) { return ERR_PTR(-ENOTSUPP); }
+static inline void mlx5_vxlan_destroy(struct mlx5_vxlan *vxlan) { return; }
+
+#endif
#endif /* __MLX5_VXLAN_H__ */
--
2.17.0
^ permalink raw reply related
* [net-next V2 07/12] net/mlx5e: Vxlan, rename struct mlx5e_vxlan to mlx5_vxlan_port
From: Saeed Mahameed @ 2018-07-28 0:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
In-Reply-To: <20180728000622.4123-1-saeedm@mellanox.com>
The name mlx5e_vxlan will be used in downstream patch to describe
mlx5 vxlan structure that will replace mlx5e_vxlan_db.
Hence we rename struct mlx5e_vxlan to mlx5_vxlan_port which describes a
mlx5 vxlan port.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
.../net/ethernet/mellanox/mlx5/core/vxlan.c | 63 +++++++++----------
.../net/ethernet/mellanox/mlx5/core/vxlan.h | 4 +-
2 files changed, 33 insertions(+), 34 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
index 9a8ca532a443..a2b48ad77f26 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
@@ -36,7 +36,7 @@
#include "mlx5_core.h"
#include "vxlan.h"
-struct mlx5e_vxlan {
+struct mlx5_vxlan_port {
struct hlist_node hlist;
atomic_t refcount;
u16 udp_port;
@@ -83,40 +83,40 @@ static int mlx5e_vxlan_core_del_port_cmd(struct mlx5_core_dev *mdev, u16 port)
return mlx5_cmd_exec(mdev, in, sizeof(in), out, sizeof(out));
}
-static struct mlx5e_vxlan *mlx5e_vxlan_lookup_port_locked(struct mlx5e_priv *priv,
- u16 port)
+static struct mlx5_vxlan_port*
+mlx5e_vxlan_lookup_port_locked(struct mlx5e_priv *priv, u16 port)
{
struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
- struct mlx5e_vxlan *vxlan;
+ struct mlx5_vxlan_port *vxlanp;
- hash_for_each_possible(vxlan_db->htable, vxlan, hlist, port) {
- if (vxlan->udp_port == port)
- return vxlan;
+ hash_for_each_possible(vxlan_db->htable, vxlanp, hlist, port) {
+ if (vxlanp->udp_port == port)
+ return vxlanp;
}
return NULL;
}
-struct mlx5e_vxlan *mlx5e_vxlan_lookup_port(struct mlx5e_priv *priv, u16 port)
+struct mlx5_vxlan_port *mlx5e_vxlan_lookup_port(struct mlx5e_priv *priv, u16 port)
{
struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
- struct mlx5e_vxlan *vxlan;
+ struct mlx5_vxlan_port *vxlanp;
spin_lock_bh(&vxlan_db->lock);
- vxlan = mlx5e_vxlan_lookup_port_locked(priv, port);
+ vxlanp = mlx5e_vxlan_lookup_port_locked(priv, port);
spin_unlock_bh(&vxlan_db->lock);
- return vxlan;
+ return vxlanp;
}
void mlx5e_vxlan_add_port(struct mlx5e_priv *priv, u16 port)
{
struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
- struct mlx5e_vxlan *vxlan;
+ struct mlx5_vxlan_port *vxlanp;
- vxlan = mlx5e_vxlan_lookup_port(priv, port);
- if (vxlan) {
- atomic_inc(&vxlan->refcount);
+ vxlanp = mlx5e_vxlan_lookup_port(priv, port);
+ if (vxlanp) {
+ atomic_inc(&vxlanp->refcount);
return;
}
@@ -130,15 +130,15 @@ void mlx5e_vxlan_add_port(struct mlx5e_priv *priv, u16 port)
if (mlx5e_vxlan_core_add_port_cmd(priv->mdev, port))
return;
- vxlan = kzalloc(sizeof(*vxlan), GFP_KERNEL);
- if (!vxlan)
+ vxlanp = kzalloc(sizeof(*vxlanp), GFP_KERNEL);
+ if (!vxlanp)
goto err_delete_port;
- vxlan->udp_port = port;
- atomic_set(&vxlan->refcount, 1);
+ vxlanp->udp_port = port;
+ atomic_set(&vxlanp->refcount, 1);
spin_lock_bh(&vxlan_db->lock);
- hash_add(vxlan_db->htable, &vxlan->hlist, port);
+ hash_add(vxlan_db->htable, &vxlanp->hlist, port);
spin_unlock_bh(&vxlan_db->lock);
vxlan_db->num_ports++;
@@ -151,17 +151,16 @@ void mlx5e_vxlan_add_port(struct mlx5e_priv *priv, u16 port)
void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port)
{
struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
- struct mlx5e_vxlan *vxlan;
+ struct mlx5_vxlan_port *vxlanp;
bool remove = false;
spin_lock_bh(&vxlan_db->lock);
-
- vxlan = mlx5e_vxlan_lookup_port_locked(priv, port);
- if (!vxlan)
+ vxlanp = mlx5e_vxlan_lookup_port_locked(priv, port);
+ if (!vxlanp)
goto out_unlock;
- if (atomic_dec_and_test(&vxlan->refcount)) {
- hash_del(&vxlan->hlist);
+ if (atomic_dec_and_test(&vxlanp->refcount)) {
+ hash_del(&vxlanp->hlist);
remove = true;
}
@@ -170,7 +169,7 @@ void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port)
if (remove) {
mlx5e_vxlan_core_del_port_cmd(priv->mdev, port);
- kfree(vxlan);
+ kfree(vxlanp);
vxlan_db->num_ports--;
}
}
@@ -178,14 +177,14 @@ void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port)
void mlx5e_vxlan_cleanup(struct mlx5e_priv *priv)
{
struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
- struct mlx5e_vxlan *vxlan;
+ struct mlx5_vxlan_port *vxlanp;
struct hlist_node *tmp;
int bkt;
/* Lockless since we are the only hash table consumers, wq and TX are disabled */
- hash_for_each_safe(vxlan_db->htable, bkt, tmp, vxlan, hlist) {
- hash_del(&vxlan->hlist);
- mlx5e_vxlan_core_del_port_cmd(priv->mdev, vxlan->udp_port);
- kfree(vxlan);
+ hash_for_each_safe(vxlan_db->htable, bkt, tmp, vxlanp, hlist) {
+ hash_del(&vxlanp->hlist);
+ mlx5e_vxlan_core_del_port_cmd(priv->mdev, vxlanp->udp_port);
+ kfree(vxlanp);
}
}
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
index 1a02f5b38009..6b38b6fbd030 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.h
@@ -35,7 +35,7 @@
#include <linux/mlx5/driver.h>
#include "en.h"
-struct mlx5e_vxlan;
+struct mlx5_vxlan_port;
static inline bool mlx5e_vxlan_allowed(struct mlx5_core_dev *mdev)
{
@@ -47,6 +47,6 @@ void mlx5e_vxlan_init(struct mlx5e_priv *priv);
void mlx5e_vxlan_cleanup(struct mlx5e_priv *priv);
void mlx5e_vxlan_add_port(struct mlx5e_priv *priv, u16 port);
void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port);
-struct mlx5e_vxlan *mlx5e_vxlan_lookup_port(struct mlx5e_priv *priv, u16 port);
+struct mlx5_vxlan_port *mlx5e_vxlan_lookup_port(struct mlx5e_priv *priv, u16 port);
#endif /* __MLX5_VXLAN_H__ */
--
2.17.0
^ permalink raw reply related
* [net-next V2 12/12] net/mlx5e: Issue direct lookup on vxlan ports by vport representors
From: Saeed Mahameed @ 2018-07-28 0:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
In-Reply-To: <20180728000622.4123-1-saeedm@mellanox.com>
Remove uplink representor netdevice private structure lookup, and use
mlx5 core handle directly from representor private structure to lookup
vxlan ports.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
index 288a57f76e84..c28fe469b04a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
@@ -1124,16 +1124,12 @@ static int parse_tunnel_attr(struct mlx5e_priv *priv,
skb_flow_dissector_target(f->dissector,
FLOW_DISSECTOR_KEY_ENC_PORTS,
f->mask);
- struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
- struct mlx5e_rep_priv *uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw, REP_ETH);
- struct net_device *up_dev = uplink_rpriv->netdev;
- struct mlx5e_priv *up_priv = netdev_priv(up_dev);
/* Full udp dst port must be given */
if (memchr_inv(&mask->dst, 0xff, sizeof(mask->dst)))
goto vxlan_match_offload_err;
- if (mlx5_vxlan_lookup_port(up_priv->mdev->vxlan, be16_to_cpu(key->dst)) &&
+ if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, be16_to_cpu(key->dst)) &&
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap))
parse_vxlan_attr(spec, f);
else {
@@ -2533,11 +2529,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
struct mlx5e_tc_flow *flow)
{
struct mlx5_eswitch *esw = priv->mdev->priv.eswitch;
- struct mlx5e_rep_priv *uplink_rpriv = mlx5_eswitch_get_uplink_priv(esw,
- REP_ETH);
- struct net_device *up_dev = uplink_rpriv->netdev;
unsigned short family = ip_tunnel_info_af(tun_info);
- struct mlx5e_priv *up_priv = netdev_priv(up_dev);
struct mlx5_esw_flow_attr *attr = flow->esw_attr;
struct ip_tunnel_key *key = &tun_info->key;
struct mlx5e_encap_entry *e;
@@ -2557,7 +2549,7 @@ static int mlx5e_attach_encap(struct mlx5e_priv *priv,
return -EOPNOTSUPP;
}
- if (mlx5_vxlan_lookup_port(up_priv->mdev->vxlan, be16_to_cpu(key->tp_dst)) &&
+ if (mlx5_vxlan_lookup_port(priv->mdev->vxlan, be16_to_cpu(key->tp_dst)) &&
MLX5_CAP_ESW(priv->mdev, vxlan_encap_decap)) {
tunnel_type = MLX5_HEADER_TYPE_VXLAN;
} else {
--
2.17.0
^ permalink raw reply related
* [net-next V2 05/12] net/mlx5e: Vxlan, add direct delete function
From: Saeed Mahameed @ 2018-07-28 0:06 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Saeed Mahameed
In-Reply-To: <20180728000622.4123-1-saeedm@mellanox.com>
Add direct vxlan delete function to be called from vxlan_delete_work.
Needed in downstream patch.
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
Reviewed-by: Or Gerlitz <ogerlitz@mellanox.com>
---
.../net/ethernet/mellanox/mlx5/core/vxlan.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
index 4b9190d677fc..baeac5922e8c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/vxlan.c
@@ -158,18 +158,14 @@ static void mlx5e_vxlan_add_work(struct work_struct *work)
kfree(vxlan_work);
}
-static void mlx5e_vxlan_del_work(struct work_struct *work)
+static void mlx5e_vxlan_del_port(struct mlx5e_priv *priv, u16 port)
{
- struct mlx5e_vxlan_work *vxlan_work =
- container_of(work, struct mlx5e_vxlan_work, work);
- struct mlx5e_priv *priv = vxlan_work->priv;
struct mlx5e_vxlan_db *vxlan_db = &priv->vxlan;
- u16 port = vxlan_work->port;
struct mlx5e_vxlan *vxlan;
bool remove = false;
- mutex_lock(&priv->state_lock);
spin_lock_bh(&vxlan_db->lock);
+
vxlan = mlx5e_vxlan_lookup_port_locked(priv, port);
if (!vxlan)
goto out_unlock;
@@ -187,6 +183,17 @@ static void mlx5e_vxlan_del_work(struct work_struct *work)
kfree(vxlan);
vxlan_db->num_ports--;
}
+}
+
+static void mlx5e_vxlan_del_work(struct work_struct *work)
+{
+ struct mlx5e_vxlan_work *vxlan_work =
+ container_of(work, struct mlx5e_vxlan_work, work);
+ struct mlx5e_priv *priv = vxlan_work->priv;
+ u16 port = vxlan_work->port;
+
+ mutex_lock(&priv->state_lock);
+ mlx5e_vxlan_del_port(priv, port);
mutex_unlock(&priv->state_lock);
kfree(vxlan_work);
}
--
2.17.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox