* [PATCH v2 net] sctp: potential read out of bounds in sctp_ulpevent_type_enabled()
From: Dan Carpenter @ 2017-09-13 23:00 UTC (permalink / raw)
To: Vlad Yasevich
Cc: Neil Horman, David S. Miller, linux-sctp, netdev, kernel-janitors
In-Reply-To: <20170913.092522.934509429497822082.davem@davemloft.net>
This code causes a static checker warning because Smatch doesn't trust
anything that comes from skb->data. I've reviewed this code and I do
think skb->data can be controlled by the user here.
The sctp_event_subscribe struct has 13 __u8 fields and we want to see
if ours is non-zero. sn_type can be any value in the 0-USHRT_MAX range.
We're subtracting SCTP_SN_TYPE_BASE which is 1 << 15 so we could read
either before the start of the struct or after the end.
This is a very old bug and it's surprising that it would go undetected
for so long but my theory is that it just doesn't have a big impact so
it would be hard to notice.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
v2: Use reverse-christmas-tree local variable ordering.
diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h
index 1060494ac230..b8c86ec1a8f5 100644
--- a/include/net/sctp/ulpevent.h
+++ b/include/net/sctp/ulpevent.h
@@ -153,8 +153,12 @@ __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event);
static inline int sctp_ulpevent_type_enabled(__u16 sn_type,
struct sctp_event_subscribe *mask)
{
+ int offset = sn_type - SCTP_SN_TYPE_BASE;
char *amask = (char *) mask;
- return amask[sn_type - SCTP_SN_TYPE_BASE];
+
+ if (offset >= sizeof(struct sctp_event_subscribe))
+ return 0;
+ return amask[offset];
}
/* Given an event subscription, is this event enabled? */
^ permalink raw reply related
* Re: [PATCH v2] net: smsc911x: Quieten netif during suspend
From: Florian Fainelli @ 2017-09-13 23:28 UTC (permalink / raw)
To: Geert Uytterhoeven, David S . Miller, Steve Glendinning
Cc: Andrew Lunn, netdev, linux-pm, linux-renesas-soc, linux-kernel
In-Reply-To: <1505324525-9998-1-git-send-email-geert+renesas@glider.be>
On 09/13/2017 10:42 AM, Geert Uytterhoeven wrote:
> If the network interface is kept running during suspend, the net core
> may call net_device_ops.ndo_start_xmit() while the Ethernet device is
> still suspended, which may lead to a system crash.
>
> E.g. on sh73a0/kzm9g and r8a73a4/ape6evm, the external Ethernet chip is
> driven by a PM controlled clock. If the Ethernet registers are accessed
> while the clock is not running, the system will crash with an imprecise
> external abort.
>
> As this is a race condition with a small time window, it is not so easy
> to trigger at will. Using pm_test may increase your chances:
>
> # echo 0 > /sys/module/printk/parameters/console_suspend
> # echo platform > /sys/power/pm_test
> # echo mem > /sys/power/state
>
> To fix this, make sure the network interface is quietened during
> suspend.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
You may want to take the opportunity to suspend the PHY device
(conversely resume it) if WoL is not enabled on this device.
Thanks!
> ---
> This is v2 of the series "[PATCH 0/2] net: Fix crashes due to activity
> during suspend", which degenerated into a single patch after commit
> ebc8254aeae34226 ("Revert "net: phy: Correctly process PHY_HALTED in
> phy_stop_machine()"") made "[PATCH 1/2] net: phy: Freeze PHY polling before
> suspending devices" no longer needed.
>
> v2:
> - Spelling s/quit/quiet/g.
>
> No stacktrace is provided, as the imprecise external abort is usually
> reported from an innocent looking and unrelated function like
> __loop_delay(), cpu_idle_poll(), or arch_timer_read_counter_long().
> ---
> drivers/net/ethernet/smsc/smsc911x.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c
> index 0b6a39b003a4e188..012fb66eed8dd618 100644
> --- a/drivers/net/ethernet/smsc/smsc911x.c
> +++ b/drivers/net/ethernet/smsc/smsc911x.c
> @@ -2595,6 +2595,11 @@ static int smsc911x_suspend(struct device *dev)
> struct net_device *ndev = dev_get_drvdata(dev);
> struct smsc911x_data *pdata = netdev_priv(ndev);
>
> + if (netif_running(ndev)) {
> + netif_stop_queue(ndev);
> + netif_device_detach(ndev);
> + }
> +
> /* enable wake on LAN, energy detection and the external PME
> * signal. */
> smsc911x_reg_write(pdata, PMT_CTRL,
> @@ -2628,7 +2633,15 @@ static int smsc911x_resume(struct device *dev)
> while (!(smsc911x_reg_read(pdata, PMT_CTRL) & PMT_CTRL_READY_) && --to)
> udelay(1000);
>
> - return (to == 0) ? -EIO : 0;
> + if (to == 0)
> + return -EIO;
> +
> + if (netif_running(ndev)) {
> + netif_device_attach(ndev);
> + netif_start_queue(ndev);
> + }
> +
> + return 0;
> }
>
> static const struct dev_pm_ops smsc911x_pm_ops = {
>
--
Florian
^ permalink raw reply
* Job Offer In USA
From: Valero Energy Recruitment @ 2017-09-13 16:24 UTC (permalink / raw)
To: Recipients
Valero Energy Oil & Gas Company USA
Employment Opportunity in Texas, USA.
Oil & Gas Sector ( NEW PLANT RIG )
Salary Range $7,000 USD - $11,700 Per Month
Kindly send your CV/RESUME for more details regarding our Job Program, Employment offers for all Offices.
CC: Forward All Documents/Certificates & Resume to: valeroenergy.recruit@gmail.com
^ permalink raw reply
* Re: [PATCH v2 net] sctp: potential read out of bounds in sctp_ulpevent_type_enabled()
From: David Miller @ 2017-09-14 0:00 UTC (permalink / raw)
To: dan.carpenter; +Cc: vyasevich, nhorman, linux-sctp, netdev, kernel-janitors
In-Reply-To: <20170913230054.fmtidvfi2swvy2mm@mwanda>
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Thu, 14 Sep 2017 02:00:54 +0300
> This code causes a static checker warning because Smatch doesn't trust
> anything that comes from skb->data. I've reviewed this code and I do
> think skb->data can be controlled by the user here.
>
> The sctp_event_subscribe struct has 13 __u8 fields and we want to see
> if ours is non-zero. sn_type can be any value in the 0-USHRT_MAX range.
> We're subtracting SCTP_SN_TYPE_BASE which is 1 << 15 so we could read
> either before the start of the struct or after the end.
>
> This is a very old bug and it's surprising that it would go undetected
> for so long but my theory is that it just doesn't have a big impact so
> it would be hard to notice.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> v2: Use reverse-christmas-tree local variable ordering.
Applied and queued up for -stable, thanks.
^ permalink raw reply
* [PATCH] dt-bindings: net: renesas-ravb: Add support for R8A77995 RAVB
From: Yoshihiro Shimoda @ 2017-09-14 0:06 UTC (permalink / raw)
To: davem, robh+dt, mark.rutland
Cc: netdev, linux-renesas-soc, devicetree, Yoshihiro Shimoda
Add a new compatible string for the R8A77995 (R-Car D3) RAVB.
Acked-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
---
Changes from v1:
- Based on r8a77970 patch.
https://marc.info/?l=linux-renesas-soc&m=150524655515476
- Add Acked-by (Thanks Geert-san!).
Documentation/devicetree/bindings/net/renesas,ravb.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/net/renesas,ravb.txt b/Documentation/devicetree/bindings/net/renesas,ravb.txt
index 2689211..c902261 100644
--- a/Documentation/devicetree/bindings/net/renesas,ravb.txt
+++ b/Documentation/devicetree/bindings/net/renesas,ravb.txt
@@ -18,6 +18,7 @@ Required properties:
- "renesas,etheravb-r8a7795" for the R8A7795 SoC.
- "renesas,etheravb-r8a7796" for the R8A7796 SoC.
- "renesas,etheravb-r8a77970" for the R8A77970 SoC.
+ - "renesas,etheravb-r8a77995" for the R8A77995 SoC.
- "renesas,etheravb-rcar-gen3" as a fallback for the above
R-Car Gen3 devices.
--
1.9.1
^ permalink raw reply related
* RE: [PATCH] dt-bindings: net: renesas-ravb: Add support for R8A77995 RAVB
From: Yoshihiro Shimoda @ 2017-09-14 0:11 UTC (permalink / raw)
To: Sergei Shtylyov, davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
mark.rutland-5wv7dgnIgG8@public.gmane.org
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-renesas-soc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
In-Reply-To: <1f4763ea-9f8a-03a6-1215-69b96c404590-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1568 bytes --]
Hello!
> From: Sergei Shtylyov
> Sent: Thursday, September 14, 2017 1:02 AM
>
> Hello!
>
> On 09/13/2017 03:17 PM, Yoshihiro Shimoda wrote:
>
> > Add a new compatible string for the R8A77995 (R-Car D3) RAVB.
> >
> > Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
> > ---
> > Documentation/devicetree/bindings/net/renesas,ravb.txt | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/Documentation/devicetree/bindings/net/renesas,ravb.txt
> b/Documentation/devicetree/bindings/net/renesas,ravb.txt
> > index 1672353..ae2213f 100644
> > --- a/Documentation/devicetree/bindings/net/renesas,ravb.txt
> > +++ b/Documentation/devicetree/bindings/net/renesas,ravb.txt
> > @@ -17,6 +17,7 @@ Required properties:
> >
> > - "renesas,etheravb-r8a7795" for the R8A7795 SoC.
> > - "renesas,etheravb-r8a7796" for the R8A7796 SoC.
> > + - "renesas,etheravb-r8a77995" for the R8A77995 SoC.
>
> That would conflict with the R8A77970 bindings patch posted by me
> yesterday. Please respin atop of it.
Yes, I submitted v2 patch now.
> > - "renesas,etheravb-rcar-gen3" as a fallback for the above
> > R-Car Gen3 devices.
> >
>
> One more fragment is needed here, about the mandatory 'interrupt-names"
> prop. My patch makes this change unnecessary, however...
I understood it.
Best regards,
Yoshihiro Shimoda
> MBR, Sergei
N§²æìr¸yúèØb²X¬¶Ç§vØ^)Þº{.nÇ+·zøzÚÞz)í
æèw*\x1fjg¬±¨\x1e¶Ý¢j.ïÛ°\½½MúgjÌæa×\x02' ©Þ¢¸\f¢·¦j:+v¨wèjØm¶ÿ¾\a«êçzZ+ùÝ¢j"ú!¶i
^ permalink raw reply
* [PATCH] net: ipv4: fix l3slave check for index returned in IP_PKTINFO
From: David Ahern @ 2017-09-14 0:11 UTC (permalink / raw)
To: netdev; +Cc: David Ahern
rt_iif is only set to the actual egress device for the output path. The
recent change to consider the l3slave flag when returning IP_PKTINFO
works for local traffic (the correct device index is returned), but it
broke the more typical use case of packets received from a remote host
always returning the VRF index rather than the original ingress device.
Update the fixup to consider l3slave and rt_iif actually getting set.
Fixes: 1dfa76390bf05 ("net: ipv4: add check for l3slave for index returned in IP_PKTINFO")
Signed-off-by: David Ahern <dsahern@gmail.com>
---
net/ipv4/ip_sockglue.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index e558e4f9597b..a599aa83fdad 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -1207,7 +1207,6 @@ static int do_ip_setsockopt(struct sock *sk, int level,
void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
{
struct in_pktinfo *pktinfo = PKTINFO_SKB_CB(skb);
- bool l3slave = ipv4_l3mdev_skb(IPCB(skb)->flags);
bool prepare = (inet_sk(sk)->cmsg_flags & IP_CMSG_PKTINFO) ||
ipv6_sk_rxinfo(sk);
@@ -1221,8 +1220,13 @@ void ipv4_pktinfo_prepare(const struct sock *sk, struct sk_buff *skb)
* (e.g., process binds socket to eth0 for Tx which is
* redirected to loopback in the rtable/dst).
*/
- if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX || l3slave)
+ struct rtable *rt = skb_rtable(skb);
+ bool l3slave = ipv4_l3mdev_skb(IPCB(skb)->flags);
+
+ if (pktinfo->ipi_ifindex == LOOPBACK_IFINDEX)
pktinfo->ipi_ifindex = inet_iif(skb);
+ else if (l3slave && rt && rt->rt_iif)
+ pktinfo->ipi_ifindex = rt->rt_iif;
pktinfo->ipi_spec_dst.s_addr = fib_compute_spec_dst(skb);
} else {
--
2.1.4
^ permalink raw reply related
* Re: [RFC net-next 2/5] net/sched: Introduce Credit Based Shaper (CBS) qdisc
From: Vinicius Costa Gomes @ 2017-09-14 0:39 UTC (permalink / raw)
To: Henrik Austad
Cc: netdev, jhs, xiyou.wangcong, jiri, intel-wired-lan, andre.guedes,
ivan.briano, jesus.sanchez-palencia, boon.leong.ong,
richardcochran
In-Reply-To: <20170908134332.GD9064@sisyphus.home.austad.us>
Hi Henrik,
Henrik Austad <henrik@austad.us> writes:
> On Thu, Aug 31, 2017 at 06:26:22PM -0700, Vinicius Costa Gomes wrote:
>> This queueing discipline implements the shaper algorithm defined by
>> the 802.1Q-2014 Section 8.6.8.2 and detailed in Annex L.
>>
>> It's primary usage is to apply some bandwidth reservation to user
>> defined traffic classes, which are mapped to different queues via the
>> mqprio qdisc.
>>
>> Initially, it only supports offloading the traffic shaping work to
>> supporting controllers.
>>
>> Later, when a software implementation is added, the current dependency
>> on being installed "under" mqprio can be lifted.
>>
>> Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@intel.com>
>> Signed-off-by: Jesus Sanchez-Palencia <jesus.sanchez-palencia@intel.com>
>
> So, I started testing this in my VM to make sure I didn't do anything silly
> and it exploded spectacularly as it used the underlying e1000 driver which
> does not have a ndo_setup_tc present.
>
> I commented inline below, but as a tl;dr
>
> The cbs_init() would call into cbs_change() that would correctly detect
> that ndo_setup_tc is missing and abort. However, at this stage it would try
> to desroy the qdisc and in cbs_destroy() there's no such guard leading to a
>
> BUG: unable to handle kernel NULL pointer dereference at 0000000000000010
>
> Fixing that, another NULL would be found when the code walks into
> qdisc_destroy(q->qdisc).
>
> Apart from this, it loaded fine after some wrestling with tc :)
>
> Awesome! :D
>
>> ---
>> include/linux/netdevice.h | 1 +
>> net/sched/Kconfig | 11 ++
>> net/sched/Makefile | 1 +
>> net/sched/sch_cbs.c | 286 ++++++++++++++++++++++++++++++++++++++++++++++
>> 4 files changed, 299 insertions(+)
>> create mode 100644 net/sched/sch_cbs.c
>>
>> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
>> index 35de8312e0b5..dd9a2ecd0c03 100644
>> --- a/include/linux/netdevice.h
>> +++ b/include/linux/netdevice.h
>> @@ -775,6 +775,7 @@ enum tc_setup_type {
>> TC_SETUP_CLSFLOWER,
>> TC_SETUP_CLSMATCHALL,
>> TC_SETUP_CLSBPF,
>> + TC_SETUP_CBS,
>> };
>>
>> /* These structures hold the attributes of xdp state that are being passed
>> diff --git a/net/sched/Kconfig b/net/sched/Kconfig
>> index e70ed26485a2..c03d86a7775e 100644
>> --- a/net/sched/Kconfig
>> +++ b/net/sched/Kconfig
>> @@ -172,6 +172,17 @@ config NET_SCH_TBF
>> To compile this code as a module, choose M here: the
>> module will be called sch_tbf.
>>
>> +config NET_SCH_CBS
>
> Shouldn't this depend on NET_SCH_MQPRIO as it is supposed to hook into
> that?
Right now, the CBS shaper only makes sense with mqprio, later it may use
some other qdisc (like "taprio" mentioned in the cover letter) to hook
into, so, yes, you are right, there's a dependency here, better make it
clear. Will fix.
>
> @@ -173,6 +173,7 @@ config NET_SCH_TBF
> module will be called sch_tbf.
>
> config NET_SCH_CBS
> + depends on NET_SCH_MQPRIO
> tristate "Credit Based Shaper (CBS)"
> ---help---
> Say Y here if you want to use the Credit Based Shaper (CBS) packet
>
>> + tristate "Credit Based Shaper (CBS)"
>> + ---help---
>> + Say Y here if you want to use the Credit Based Shaper (CBS) packet
>> + scheduling algorithm.
>> +
>> + See the top of <file:net/sched/sch_cbs.c> for more details.
>> +
>> + To compile this code as a module, choose M here: the
>> + module will be called sch_cbs.
>> +
>> config NET_SCH_GRED
>> tristate "Generic Random Early Detection (GRED)"
>> ---help---
>> diff --git a/net/sched/Makefile b/net/sched/Makefile
>> index 7b915d226de7..80c8f92d162d 100644
>> --- a/net/sched/Makefile
>> +++ b/net/sched/Makefile
>> @@ -52,6 +52,7 @@ obj-$(CONFIG_NET_SCH_FQ_CODEL) += sch_fq_codel.o
>> obj-$(CONFIG_NET_SCH_FQ) += sch_fq.o
>> obj-$(CONFIG_NET_SCH_HHF) += sch_hhf.o
>> obj-$(CONFIG_NET_SCH_PIE) += sch_pie.o
>> +obj-$(CONFIG_NET_SCH_CBS) += sch_cbs.o
>>
>> obj-$(CONFIG_NET_CLS_U32) += cls_u32.o
>> obj-$(CONFIG_NET_CLS_ROUTE4) += cls_route.o
>> diff --git a/net/sched/sch_cbs.c b/net/sched/sch_cbs.c
>> new file mode 100644
>> index 000000000000..1c86a9e14150
>> --- /dev/null
>> +++ b/net/sched/sch_cbs.c
>> @@ -0,0 +1,286 @@
>> +/*
>> + * net/sched/sch_cbs.c Credit Based Shaper
>> + *
>> + * This program is free software; you can redistribute it and/or
>> + * modify it under the terms of the GNU General Public License
>> + * as published by the Free Software Foundation; either version
>> + * 2 of the License, or (at your option) any later version.
>> + *
>> + * Authors: Vininicius Costa Gomes <vinicius.gomes@intel.com>
>> + *
>> + */
>> +
>> +#include <linux/module.h>
>> +#include <linux/types.h>
>> +#include <linux/kernel.h>
>> +#include <linux/string.h>
>> +#include <linux/errno.h>
>> +#include <linux/skbuff.h>
>> +#include <net/netlink.h>
>> +#include <net/sch_generic.h>
>> +#include <net/pkt_sched.h>
>> +
>> +struct cbs_sched_data {
>> + struct Qdisc *qdisc; /* Inner qdisc, default - pfifo queue */
>> + s32 queue;
>> + s32 locredit;
>> + s32 hicredit;
>> + s32 sendslope;
>> + s32 idleslope;
>> +};
>> +
>> +static int cbs_enqueue(struct sk_buff *skb, struct Qdisc *sch,
>> + struct sk_buff **to_free)
>> +{
>> + struct cbs_sched_data *q = qdisc_priv(sch);
>> + int ret;
>> +
>> + ret = qdisc_enqueue(skb, q->qdisc, to_free);
>> + if (ret != NET_XMIT_SUCCESS) {
>> + if (net_xmit_drop_count(ret))
>> + qdisc_qstats_drop(sch);
>> + return ret;
>> + }
>> +
>> + qdisc_qstats_backlog_inc(sch, skb);
>> + sch->q.qlen++;
>> + return NET_XMIT_SUCCESS;
>> +}
>> +
>> +static struct sk_buff *cbs_dequeue(struct Qdisc *sch)
>> +{
>> + struct cbs_sched_data *q = qdisc_priv(sch);
>> + struct sk_buff *skb;
>> +
>> + skb = q->qdisc->ops->peek(q->qdisc);
>> + if (skb) {
>> + skb = qdisc_dequeue_peeked(q->qdisc);
>> + if (unlikely(!skb))
>> + return NULL;
>> +
>> + qdisc_qstats_backlog_dec(sch, skb);
>> + sch->q.qlen--;
>> + qdisc_bstats_update(sch, skb);
>> +
>> + return skb;
>> + }
>> + return NULL;
>> +}
>> +
>> +static void cbs_reset(struct Qdisc *sch)
>> +{
>> + struct cbs_sched_data *q = qdisc_priv(sch);
>> +
>> + qdisc_reset(q->qdisc);
>> +}
>> +
>> +static const struct nla_policy cbs_policy[TCA_CBS_MAX + 1] = {
>> + [TCA_CBS_PARMS] = { .len = sizeof(struct tc_cbs_qopt) },
>> +};
>> +
>> +static int cbs_change(struct Qdisc *sch, struct nlattr *opt)
>> +{
>> + struct cbs_sched_data *q = qdisc_priv(sch);
>> + struct tc_cbs_qopt_offload cbs = { };
>> + struct nlattr *tb[TCA_CBS_MAX + 1];
>> + const struct net_device_ops *ops;
>> + struct tc_cbs_qopt *qopt;
>> + struct net_device *dev;
>> + int err;
>> +
>> + err = nla_parse_nested(tb, TCA_CBS_MAX, opt, cbs_policy, NULL);
>> + if (err < 0)
>> + return err;
>> +
>> + err = -EINVAL;
>> + if (!tb[TCA_CBS_PARMS])
>> + goto done;
>> +
>> + qopt = nla_data(tb[TCA_CBS_PARMS]);
>> +
>> + dev = qdisc_dev(sch);
>> + ops = dev->netdev_ops;
>> +
>> + /* FIXME: this means that we can only install this qdisc
>> + * "under" mqprio. Do we need a more generic way to retrieve
>> + * the queue, or do we pass the netdev_queue to the driver?
>> + */
>> + cbs.queue = TC_H_MIN(sch->parent) - 1 - netdev_get_num_tc(dev);
>> +
>> + cbs.enable = 1;
>> + cbs.hicredit = qopt->hicredit;
>> + cbs.locredit = qopt->locredit;
>> + cbs.idleslope = qopt->idleslope;
>> + cbs.sendslope = qopt->sendslope;
>> +
>> + err = -ENOTSUPP;
>> + if (!ops->ndo_setup_tc)
>> + goto done;
>
> This confuses tc a bit, and looking at other qdisc schedulers, it seems
> like EOPNOTSUPP is an alternative, this changes the output from
>
> RTNETLINK answers: Unknown error 524
> - to
> RTNETLINK answers: Operation not supported
>
Yeah, I missed this. Thanks for catching this.
> which perhaps is more informative.
>
>> +
>> + err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CBS, &cbs);
>> + if (err < 0)
>> + goto done;
>> +
>> + q->queue = cbs.queue;
>> + q->hicredit = cbs.hicredit;
>> + q->locredit = cbs.locredit;
>> + q->idleslope = cbs.idleslope;
>> + q->sendslope = cbs.sendslope;
>> +
>> +done:
>> + return err;
>> +}
>> +
>> +static int cbs_init(struct Qdisc *sch, struct nlattr *opt)
>> +{
>> + struct cbs_sched_data *q = qdisc_priv(sch);
>> +
>> + if (!opt)
>> + return -EINVAL;
>> +
>> + q->qdisc = fifo_create_dflt(sch, &pfifo_qdisc_ops, 1024);
>> + qdisc_hash_add(q->qdisc, true);
>> +
>> + return cbs_change(sch, opt);
>> +}
>> +
>> +static void cbs_destroy(struct Qdisc *sch)
>> +{
>> + struct cbs_sched_data *q = qdisc_priv(sch);
>> + struct tc_cbs_qopt_offload cbs = { };
>> + struct net_device *dev;
>> + int err;
>> +
>> + q->hicredit = 0;
>> + q->locredit = 0;
>> + q->idleslope = 0;
>> + q->sendslope = 0;
>> +
>> + dev = qdisc_dev(sch);
>> +
>> + cbs.queue = q->queue;
>> + cbs.enable = 0;
>> +
>> + err = dev->netdev_ops->ndo_setup_tc(dev, TC_SETUP_CBS, &cbs);
>
> This can lead to NULL pointer deref if it is not set (tested for in
> cbs_change and error there leads us here, which then explodes).
Fixed.
>
>> + if (err < 0)
>> + pr_warn("Couldn't reset queue %d to default values\n",
>> + cbs.queue);
>> +
>> + qdisc_destroy(q->qdisc);
>
> Same, q->qdisc was NULL when cbs_init() failed.
>
Fixed the error path, thanks.
Cheers,
^ permalink raw reply
* [PATCH net] udpv6: Fix the checksum computation when HW checksum does not apply
From: Subash Abhinov Kasiviswanathan @ 2017-09-14 1:30 UTC (permalink / raw)
To: netdev, vyasevic; +Cc: Subash Abhinov Kasiviswanathan
While trying an ESP transport mode encryption for UDPv6 packets of
datagram size 1436 with MTU 1500, checksum error was observed in
the secondary fragment.
This error occurs due to the UDP payload checksum being missed out
when computing the full checksum for these packets in
udp6_hwcsum_outgoing().
Fixes: d39d938c8228 ("ipv6: Introduce udpv6_send_skb()")
Signed-off-by: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
---
net/ipv6/udp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index e2ecfb1..40d7234 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1015,6 +1015,7 @@ static void udp6_hwcsum_outgoing(struct sock *sk, struct sk_buff *skb,
*/
offset = skb_transport_offset(skb);
skb->csum = skb_checksum(skb, offset, skb->len - offset, 0);
+ csum = skb->csum;
skb->ip_summed = CHECKSUM_NONE;
--
1.9.1
^ permalink raw reply related
* RE: [Intel-wired-lan] [PATCH] igb: check memory allocation failure
From: Brown, Aaron F @ 2017-09-14 2:24 UTC (permalink / raw)
To: Christophe JAILLET, Waskiewicz Jr, Peter, Kirsher, Jeffrey T
Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org,
intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org
In-Reply-To: <95a0bc80-8b41-d74f-8059-ae7181493120@wanadoo.fr>
> From: Intel-wired-lan [mailto:intel-wired-lan-bounces@osuosl.org] On Behalf
> Of Christophe JAILLET
> Sent: Monday, August 28, 2017 10:13 AM
> To: Waskiewicz Jr, Peter <peter.waskiewicz.jr@intel.com>; Kirsher, Jeffrey T
> <jeffrey.t.kirsher@intel.com>
> Cc: netdev@vger.kernel.org; kernel-janitors@vger.kernel.org; intel-wired-
> lan@lists.osuosl.org; linux-kernel@vger.kernel.org
> Subject: Re: [Intel-wired-lan] [PATCH] igb: check memory allocation failure
>
> Le 28/08/2017 à 01:09, Waskiewicz Jr, Peter a écrit :
> > On 8/27/17 2:42 AM, Christophe JAILLET wrote:
> >> Check memory allocation failures and return -ENOMEM in such cases, as
> >> already done for other memory allocations in this function.
> >>
> >> This avoids NULL pointers dereference.
> >>
> >> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> >> ---
> >> drivers/net/ethernet/intel/igb/igb_main.c | 2 ++
> >> 1 file changed, 2 insertions(+)
> >>
This seems to be fine from a "it does not break in testing" perspective, so...
Tested-by: Aaron Brown <aaron.f.brown@intel.com
> > -PJ
> >
> Hi,
>
> in fact, there is no leak because the only caller of 'igb_sw_init()'
> (i.e. 'igb_probe()'), already frees these resources in case of error,
> see [1]
>
> These resources are also freed in 'igb_remove()'.
>
> Best reagrds,
> CJ
>
> [1]:
> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-
> next.git/tree/drivers/net/ethernet/intel/igb/igb_main.c#n2775
But is PJ's comment saying that it is not really necessary? If so I tend to lean towards the don't touch it if it's not broken perspective.
^ permalink raw reply
* [PATCH] net/packet: fix race condition between fanout_add and __unregister_prot_hook
From: nixiaoming @ 2017-09-14 2:40 UTC (permalink / raw)
To: davem, edumazet, waltje, gw4pts, andreyknvl, tklauser,
philip.pettersson, glider
Cc: netdev, linux-kernel, nixiaoming, dede.wu
If fanout_add is preempted after running po-> fanout = match
and before running __fanout_link,
it will cause BUG_ON when __unregister_prot_hook call __fanout_unlink
so, we need add mutex_lock(&fanout_mutex) to __unregister_prot_hook
or add spin_lock(&po->bind_lock) before po-> fanout = match
test on linux 4.1.42:
./trinity -c setsockopt -C 2 -X &
BUG: failure at net/packet/af_packet.c:1414/__fanout_unlink()!
Kernel panic - not syncing: BUG!
CPU: 2 PID: 2271 Comm: trinity-c0 Tainted: G W O 4.1.12 #1
Hardware name: Hisilicon PhosphorHi1382 FPGA (DT)
Call trace:
[<ffffffc000209414>] dump_backtrace+0x0/0xf8
[<ffffffc00020952c>] show_stack+0x20/0x28
[<ffffffc000635574>] dump_stack+0xac/0xe4
[<ffffffc000633fb8>] panic+0xf8/0x268
[<ffffffc0005fa778>] __unregister_prot_hook+0xa0/0x144
[<ffffffc0005fba48>] packet_set_ring+0x280/0x5b4
[<ffffffc0005fc33c>] packet_setsockopt+0x320/0x950
[<ffffffc000554a04>] SyS_setsockopt+0xa4/0xd4
Signed-off-by: nixiaoming <nixiaoming@huawei.com>
Tested-by: wudesheng <dede.wu@huawei.com>
---
net/packet/af_packet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 008a45c..0300146 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -365,10 +365,12 @@ static void __unregister_prot_hook(struct sock *sk, bool sync)
po->running = 0;
+ mutex_lock(&fanout_mutex);
if (po->fanout)
__fanout_unlink(sk, po);
else
__dev_remove_pack(&po->prot_hook);
+ mutex_unlock(&fanout_mutex);
__sock_put(sk);
--
2.11.0.1
^ permalink raw reply related
* [PATCH] net/packet: fix race condition between fanout_add and __unregister_prot_hook
From: nixiaoming @ 2017-09-14 2:44 UTC (permalink / raw)
To: davem, edumazet, waltje, gw4pts, andreyknvl, tklauser,
philip.pettersson, glider
Cc: netdev, linux-kernel, nixiaoming, dede.wu
If fanout_add is preempted after running po-> fanout = match
and before running __fanout_link,
it will cause BUG_ON when __unregister_prot_hook call __fanout_unlink
so, we need add mutex_lock(&fanout_mutex) to __unregister_prot_hook
or add spin_lock(&po->bind_lock) before po-> fanout = match
test on linux 4.1.12:
./trinity -c setsockopt -C 2 -X &
BUG: failure at net/packet/af_packet.c:1414/__fanout_unlink()!
Kernel panic - not syncing: BUG!
CPU: 2 PID: 2271 Comm: trinity-c0 Tainted: G W O 4.1.12 #1
Hardware name: Hisilicon PhosphorHi1382 FPGA (DT)
Call trace:
[<ffffffc000209414>] dump_backtrace+0x0/0xf8
[<ffffffc00020952c>] show_stack+0x20/0x28
[<ffffffc000635574>] dump_stack+0xac/0xe4
[<ffffffc000633fb8>] panic+0xf8/0x268
[<ffffffc0005fa778>] __unregister_prot_hook+0xa0/0x144
[<ffffffc0005fba48>] packet_set_ring+0x280/0x5b4
[<ffffffc0005fc33c>] packet_setsockopt+0x320/0x950
[<ffffffc000554a04>] SyS_setsockopt+0xa4/0xd4
Signed-off-by: nixiaoming <nixiaoming@huawei.com>
Tested-by: wudesheng <dede.wu@huawei.com>
---
net/packet/af_packet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 008a45c..0300146 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -365,10 +365,12 @@ static void __unregister_prot_hook(struct sock *sk, bool sync)
po->running = 0;
+ mutex_lock(&fanout_mutex);
if (po->fanout)
__fanout_unlink(sk, po);
else
__dev_remove_pack(&po->prot_hook);
+ mutex_unlock(&fanout_mutex);
__sock_put(sk);
--
2.11.0.1
^ permalink raw reply related
* [PATCH net] tcp: update skb->skb_mstamp more carefully
From: Eric Dumazet @ 2017-09-14 3:30 UTC (permalink / raw)
To: liujian, David Miller
Cc: edumazet, ycheng, hkchu, netdev, weiyongjun1, wangkefeng 00227729
In-Reply-To: <1505313647.15310.165.camel@edumazet-glaptop3.roam.corp.google.com>
From: Eric Dumazet <edumazet@googl.com>
liujian reported a problem in TCP_USER_TIMEOUT processing with a patch
in tcp_probe_timer() :
https://www.spinics.net/lists/netdev/msg454496.html
After investigations, the root cause of the problem is that we update
skb->skb_mstamp of skbs in write queue, even if the attempt to send a
clone or copy of it failed. One reason being a routing problem.
This patch prevents this, solving liujian issue.
It also removes a potential RTT miscalculation, since
__tcp_retransmit_skb() is not OR-ing TCP_SKB_CB(skb)->sacked with
TCPCB_EVER_RETRANS if a failure happens, but skb->skb_mstamp has
been changed.
A future ACK would then lead to a very small RTT sample and min_rtt
would then be lowered to this too small value.
Tested:
# cat user_timeout.pkt
--local_ip=192.168.102.64
0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
+0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
+0 bind(3, ..., ...) = 0
+0 listen(3, 1) = 0
+0 `ifconfig tun0 192.168.102.64/16; ip ro add 192.0.2.1 dev tun0`
+0 < S 0:0(0) win 0 <mss 1460>
+0 > S. 0:0(0) ack 1 <mss 1460>
+.1 < . 1:1(0) ack 1 win 65530
+0 accept(3, ..., ...) = 4
+0 setsockopt(4, SOL_TCP, TCP_USER_TIMEOUT, [3000], 4) = 0
+0 write(4, ..., 24) = 24
+0 > P. 1:25(24) ack 1 win 29200
+.1 < . 1:1(0) ack 25 win 65530
//change the ipaddress
+1 `ifconfig tun0 192.168.0.10/16`
+1 write(4, ..., 24) = 24
+1 write(4, ..., 24) = 24
+1 write(4, ..., 24) = 24
+1 write(4, ..., 24) = 24
+0 `ifconfig tun0 192.168.102.64/16`
+0 < . 1:2(1) ack 25 win 65530
+0 `ifconfig tun0 192.168.0.10/16`
+3 write(4, ..., 24) = -1
# ./packetdrill user_timeout.pkt
Signed-off-by: Eric Dumazet <edumazet@googl.com>
Reported-by: liujian <liujian56@huawei.com>
---
net/ipv4/tcp_output.c | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index 5b6690d05abb98884adfa1693f97d896dd202893..a85a8c2948e54b931f8cd956aa7938f7efd355bd 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -991,6 +991,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
struct tcp_skb_cb *tcb;
struct tcp_out_options opts;
unsigned int tcp_options_size, tcp_header_size;
+ struct sk_buff *oskb = NULL;
struct tcp_md5sig_key *md5;
struct tcphdr *th;
int err;
@@ -998,12 +999,12 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
BUG_ON(!skb || !tcp_skb_pcount(skb));
tp = tcp_sk(sk);
- skb->skb_mstamp = tp->tcp_mstamp;
if (clone_it) {
TCP_SKB_CB(skb)->tx.in_flight = TCP_SKB_CB(skb)->end_seq
- tp->snd_una;
tcp_rate_skb_sent(sk, skb);
+ oskb = skb;
if (unlikely(skb_cloned(skb)))
skb = pskb_copy(skb, gfp_mask);
else
@@ -1011,6 +1012,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
if (unlikely(!skb))
return -ENOBUFS;
}
+ skb->skb_mstamp = tp->tcp_mstamp;
inet = inet_sk(sk);
tcb = TCP_SKB_CB(skb);
@@ -1122,12 +1124,14 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
err = icsk->icsk_af_ops->queue_xmit(sk, skb, &inet->cork.fl);
- if (likely(err <= 0))
- return err;
-
- tcp_enter_cwr(sk);
+ if (unlikely(err > 0)) {
+ tcp_enter_cwr(sk);
+ err = net_xmit_eval(err);
+ }
+ if (!err && oskb)
+ oskb->skb_mstamp = tp->tcp_mstamp;
- return net_xmit_eval(err);
+ return err;
}
/* This routine just queues the buffer for sending.
@@ -2869,10 +2873,11 @@ int __tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb, int segs)
skb_headroom(skb) >= 0xFFFF)) {
struct sk_buff *nskb;
- skb->skb_mstamp = tp->tcp_mstamp;
nskb = __pskb_copy(skb, MAX_TCP_HEADER, GFP_ATOMIC);
err = nskb ? tcp_transmit_skb(sk, nskb, 0, GFP_ATOMIC) :
-ENOBUFS;
+ if (!err)
+ skb->skb_mstamp = tp->tcp_mstamp;
} else {
err = tcp_transmit_skb(sk, skb, 1, GFP_ATOMIC);
}
^ permalink raw reply related
* Re: [PATCH RFC v1 0/3] Support for tap user-space access with veth interfaces
From: Jason Wang @ 2017-09-14 4:12 UTC (permalink / raw)
To: sainath.grandhi, netdev; +Cc: davem
In-Reply-To: <1504744467-79590-1-git-send-email-sainath.grandhi@intel.com>
On 2017年09月07日 08:34, sainath.grandhi@intel.com wrote:
> From: Sainath Grandhi <sainath.grandhi@intel.com>
>
> This patchset adds a tap device driver for veth virtual network interface.
> With this implementation, tap character interface can be added only to the
> peer veth interface. Adding tap interface to veth is for usecases that forwards
> packets between host and VMs. This eliminates the need for an additional
> software bridge. This can be extended to create both the peer interfaces as
> tap interfaces. These patches are a step in that direction.
>
> Sainath Grandhi (3):
> net: Adding API to parse IFLA_LINKINFO attribute
> net: Abstracting out common routines from veth for use by vethtap
> vethtap: veth based tap driver
>
> drivers/net/Kconfig | 1 +
> drivers/net/Makefile | 2 +
> drivers/net/{veth.c => veth_main.c} | 80 ++++++++++---
> drivers/net/vethtap.c | 216 ++++++++++++++++++++++++++++++++++++
> include/linux/if_veth.h | 13 +++
> include/net/rtnetlink.h | 3 +
> net/core/rtnetlink.c | 8 ++
> 7 files changed, 308 insertions(+), 15 deletions(-)
> rename drivers/net/{veth.c => veth_main.c} (89%)
> create mode 100644 drivers/net/vethtap.c
> create mode 100644 include/linux/if_veth.h
>
Interesting, plan to add vhost support for this? And we can enable
zerocopy without any worries I think.
Thanks
^ permalink raw reply
* Re: Regression in throughput between kvm guests over virtual bridge
From: Jason Wang @ 2017-09-14 4:21 UTC (permalink / raw)
To: Matthew Rosato, netdev; +Cc: davem, mst
In-Reply-To: <627d0c7a-dce5-3094-d5d4-c1507fcb8080@linux.vnet.ibm.com>
On 2017年09月14日 00:59, Matthew Rosato wrote:
> On 09/13/2017 04:13 AM, Jason Wang wrote:
>>
>> On 2017年09月13日 09:16, Jason Wang wrote:
>>>
>>> On 2017年09月13日 01:56, Matthew Rosato wrote:
>>>> We are seeing a regression for a subset of workloads across KVM guests
>>>> over a virtual bridge between host kernel 4.12 and 4.13. Bisecting
>>>> points to c67df11f "vhost_net: try batch dequing from skb array"
>>>>
>>>> In the regressed environment, we are running 4 kvm guests, 2 running as
>>>> uperf servers and 2 running as uperf clients, all on a single host.
>>>> They are connected via a virtual bridge. The uperf client profile looks
>>>> like:
>>>>
>>>> <?xml version="1.0"?>
>>>> <profile name="TCP_STREAM">
>>>> <group nprocs="1">
>>>> <transaction iterations="1">
>>>> <flowop type="connect" options="remotehost=192.168.122.103
>>>> protocol=tcp"/>
>>>> </transaction>
>>>> <transaction duration="300">
>>>> <flowop type="write" options="count=16 size=30000"/>
>>>> </transaction>
>>>> <transaction iterations="1">
>>>> <flowop type="disconnect"/>
>>>> </transaction>
>>>> </group>
>>>> </profile>
>>>>
>>>> So, 1 tcp streaming instance per client. When upgrading the host kernel
>>>> from 4.12->4.13, we see about a 30% drop in throughput for this
>>>> scenario. After the bisect, I further verified that reverting c67df11f
>>>> on 4.13 "fixes" the throughput for this scenario.
>>>>
>>>> On the other hand, if we increase the load by upping the number of
>>>> streaming instances to 50 (nprocs="50") or even 10, we see instead a
>>>> ~10% increase in throughput when upgrading host from 4.12->4.13.
>>>>
>>>> So it may be the issue is specific to "light load" scenarios. I would
>>>> expect some overhead for the batching, but 30% seems significant... Any
>>>> thoughts on what might be happening here?
>>>>
>>> Hi, thanks for the bisecting. Will try to see if I can reproduce.
>>> Various factors could have impact on stream performance. If possible,
>>> could you collect the #pkts and average packet size during the test?
>>> And if you guest version is above 4.12, could you please retry with
>>> napi_tx=true?
> Original runs were done with guest kernel 4.4 (from ubuntu 16.04.3 -
> 4.4.0-93-generic specifically). Here's a throughput report (uperf) and
> #pkts and average packet size (tcpstat) for one of the uperf clients:
>
> host 4.12 / guest 4.4:
> throughput: 29.98Gb/s
> #pkts=33465571 avg packet size=33755.70
>
> host 4.13 / guest 4.4:
> throughput: 20.36Gb/s
> #pkts=21233399 avg packet size=36130.69
I test guest 4.4 on Intel machine, still can reproduce :(
>
> I ran the test again using net-next.git as guest kernel, with and
> without napi_tx=true. napi_tx did not seem to have any significant
> impact on throughput. However, the guest kernel shift from
> 4.4->net-next improved things. I can still see a regression between
> host 4.12 and 4.13, but it's more on the order of 10-15% - another sample:
>
> host 4.12 / guest net-next (without napi_tx):
> throughput: 28.88Gb/s
> #pkts=31743116 avg packet size=33779.78
>
> host 4.13 / guest net-next (without napi_tx):
> throughput: 24.34Gb/s
> #pkts=25532724 avg packet size=35963.20
Thanks for the numbers. I originally suspect batching will lead more
pkts but less size, but looks not. The less packets is also a hint that
there's delay somewhere.
>
>>> Thanks
>> Unfortunately, I could not reproduce it locally. I'm using net-next.git
>> as guest. I can get ~42Gb/s on Intel(R) Xeon(R) CPU E5-2650 0 @ 2.00GHz
>> for both before and after the commit. I use 1 vcpu and 1 queue, and pin
>> vcpu and vhost threads into separate cpu on host manually (in same numa
>> node).
> The environment is quite a bit different -- I'm running in an LPAR on a
> z13 (s390x). We've seen the issue in various configurations, the
> smallest thus far was a host partition w/ 40G and 20 CPUs defined (the
> numbers above were gathered w/ this configuration). Each guest has 4GB
> and 4 vcpus. No pinning / affinity configured.
Unfortunately, I don't have s390x on hand. Will try to get one.
>
>> Can you hit this regression constantly and what's you qemu command line
> Yes, the regression seems consistent. I can try tweaking some of the
> host and guest definitions to see if it makes a difference.
Is the issue gone if you reduce VHOST_RX_BATCH to 1? And it would be
also helpful to collect perf diff to see if anything interesting.
(Consider 4.4 shows more obvious regression, please use 4.4).
>
> The guests are instantiated from libvirt - Here's one of the resulting
> qemu command lines:
>
> /usr/bin/qemu-system-s390x -name guest=mjrs34g1,debug-threads=on -S
> -object
> secret,id=masterKey0,format=raw,file=/var/lib/libvirt/qemu/domain-1-mjrs34g1/master-key.aes
> -machine s390-ccw-virtio-2.10,accel=kvm,usb=off,dump-guest-core=off -m
> 4096 -realtime mlock=off -smp 4,sockets=4,cores=1,threads=1 -uuid
> 44710587-e783-4bd8-8590-55ff421431b1 -display none -no-user-config
> -nodefaults -chardev
> socket,id=charmonitor,path=/var/lib/libvirt/qemu/domain-1-mjrs34g1/monitor.sock,server,nowait
> -mon chardev=charmonitor,id=monitor,mode=control -rtc base=utc
> -no-shutdown -boot strict=on -drive
> file=/dev/disk/by-id/scsi-3600507630bffc0380000000000001803,format=raw,if=none,id=drive-virtio-disk0
> -device
> virtio-blk-ccw,scsi=off,devno=fe.0.0000,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1
> -netdev tap,fd=25,id=hostnet0,vhost=on,vhostfd=27 -device
> virtio-net-ccw,netdev=hostnet0,id=net0,mac=02:de:26:53:14:01,devno=fe.0.0001
> -netdev tap,fd=28,id=hostnet1,vhost=on,vhostfd=29 -device
> virtio-net-ccw,netdev=hostnet1,id=net1,mac=02:54:00:89:d4:01,devno=fe.0.00a1
> -chardev pty,id=charconsole0 -device
> sclpconsole,chardev=charconsole0,id=console0 -device
> virtio-balloon-ccw,id=balloon0,devno=fe.0.0002 -msg timestamp=on
>
> In the above, net0 is used for a macvtap connection (not used in the
> experiment, just for a reliable ssh connection - can remove if needed).
> net1 is the bridge connection used for the uperf tests.
>
>
>> and #cpus on host? Is zerocopy enabled?
> Host info provided above.
>
> cat /sys/module/vhost_net/parameters/experimental_zcopytx
> 1
May worth to try disable zerocopy or do the test form host to guest
instead of guest to guest to exclude the possible issue of sender.
Thanks
^ permalink raw reply
* Re: [PATCH 01/10] arch:powerpc: return -ENOMEM on failed allocation
From: Allen @ 2017-09-14 4:43 UTC (permalink / raw)
To: Joe Perches
Cc: linux-kernel, nouveau, linux-crypto, dri-devel,
MPT-FusionLinux.pdl, linux-scsi, netdev, megaraidlinux.pdl,
target-devel, linux-fbdev, linux-btrfs
In-Reply-To: <1505314401.8969.11.camel@perches.com>
> I think the changelog for this series of conversions
> should show that you've validated the change by
> inspecting the return call chain at each modified line.
>
> Also, it seems you've cc'd the same mailing lists for
> all of the patches modified by this series.
>
> It would be better to individually address each patch
> in the series only cc'ing the appropriate maintainers
> and mailing lists.
>
> A cover letter would be good too.
Point noted. Thanks.
- Allen
^ permalink raw reply
* [PATCH] staging: irda: Remove typedef struct
From: Haneen Mohammed @ 2017-09-14 4:55 UTC (permalink / raw)
To: outreachy-kernel
Cc: Samuel Ortiz, Greg Kroah-Hartman, netdev, devel, linux-kernel
This patch remove typedef from a structure with all its ocurrences
since using typedefs for structures is discouraged.
Issue found using Coccinelle:
@r1@
type T;
@@
typedef struct { ... } T;
@script:python c1@
T2;
T << r1.T;
@@
if T[-2:] =="_t" or T[-2:] == "_T":
coccinelle.T2 = T[:-2];
else:
coccinelle.T2 = T;
print T, coccinelle.T2
@r2@
type r1.T;
identifier c1.T2;
@@
-typedef
struct
+ T2
{ ... }
-T
;
@r3@
type r1.T;
identifier c1.T2;
@@
-T
+struct T2
Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
---
drivers/staging/irda/include/net/irda/qos.h | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/drivers/staging/irda/include/net/irda/qos.h b/drivers/staging/irda/include/net/irda/qos.h
index 05a5a24..a0315b5 100644
--- a/drivers/staging/irda/include/net/irda/qos.h
+++ b/drivers/staging/irda/include/net/irda/qos.h
@@ -58,23 +58,23 @@
#define IR_16000000 0x02
/* Quality of Service information */
-typedef struct {
+struct qos_value {
__u32 value;
__u16 bits; /* LSB is first byte, MSB is second byte */
-} qos_value_t;
+};
struct qos_info {
magic_t magic;
- qos_value_t baud_rate; /* IR_11520O | ... */
- qos_value_t max_turn_time;
- qos_value_t data_size;
- qos_value_t window_size;
- qos_value_t additional_bofs;
- qos_value_t min_turn_time;
- qos_value_t link_disc_time;
+ struct qos_value baud_rate; /* IR_11520O | ... */
+ struct qos_value max_turn_time;
+ struct qos_value data_size;
+ struct qos_value window_size;
+ struct qos_value additional_bofs;
+ struct qos_value min_turn_time;
+ struct qos_value link_disc_time;
- qos_value_t power;
+ struct qos_value power;
};
extern int sysctl_max_baud_rate;
--
2.7.4
^ permalink raw reply related
* Re: [RFC PATCH] can: m_can: Support higher speed CAN-FD bitrates
From: Sekhar Nori @ 2017-09-14 5:06 UTC (permalink / raw)
To: Franklin S Cooper Jr, wg, mkl, mario.huettel, socketcan,
quentin.schulz, edumazet, linux-can, netdev, linux-kernel
Cc: Wenyou Yang, Dong Aisheng
In-Reply-To: <4f8f6b64-b2a2-b9dc-665c-f1c155daf994@ti.com>
On Thursday 14 September 2017 03:28 AM, Franklin S Cooper Jr wrote:
>
>
> On 08/18/2017 02:39 PM, Franklin S Cooper Jr wrote:
>> During test transmitting using CAN-FD at high bitrates (4 Mbps) only
>> resulted in errors. Scoping the signals I noticed that only a single bit
>> was being transmitted and with a bit more investigation realized the actual
>> MCAN IP would go back to initialization mode automatically.
>>
>> It appears this issue is due to the MCAN needing to use the Transmitter
>> Delay Compensation Mode as defined in the MCAN User's Guide. When this
>> mode is used the User's Guide indicates that the Transmitter Delay
>> Compensation Offset register should be set. The document mentions that this
>> register should be set to (1/dbitrate)/2*(Func Clk Freq).
>>
>> Additional CAN-CIA's "Bit Time Requirements for CAN FD" document indicates
>> that this TDC mode is only needed for data bit rates above 2.5 Mbps.
>> Therefore, only enable this mode and only set TDCO when the data bit rate
>> is above 2.5 Mbps.
>>
>> Signed-off-by: Franklin S Cooper Jr <fcooper@ti.com>
>> ---
>> I'm pretty surprised that this hasn't been implemented already since
>> the primary purpose of CAN-FD is to go beyond 1 Mbps and the MCAN IP
>> supports up to 10 Mbps.
>>
>> So it will be nice to get comments from users of this driver to understand
>> if they have been able to use CAN-FD beyond 2.5 Mbps without this patch.
>> If they haven't what did they do to get around it if they needed higher
>> speeds.
>>
>> Meanwhile I plan on testing this using a more "realistic" CAN bus to insure
>> everything still works at 5 Mbps which is the max speed of my CAN
>> transceiver.
>
> ping. Anyone has any thoughts on this?
I added Dong who authored the m_can driver and Wenyou who added the only
in-kernel user of the driver for any help.
Thanks,
Sekhar
>>
>> drivers/net/can/m_can/m_can.c | 24 +++++++++++++++++++++++-
>> 1 file changed, 23 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
>> index f4947a7..720e073 100644
>> --- a/drivers/net/can/m_can/m_can.c
>> +++ b/drivers/net/can/m_can/m_can.c
>> @@ -126,6 +126,12 @@ enum m_can_mram_cfg {
>> #define DBTP_DSJW_SHIFT 0
>> #define DBTP_DSJW_MASK (0xf << DBTP_DSJW_SHIFT)
>>
>> +/* Transmitter Delay Compensation Register (TDCR) */
>> +#define TDCR_TDCO_SHIFT 8
>> +#define TDCR_TDCO_MASK (0x7F << TDCR_TDCO_SHIFT)
>> +#define TDCR_TDCF_SHIFT 0
>> +#define TDCR_TDCF_MASK (0x7F << TDCR_TDCO_SHIFT)
>> +
>> /* Test Register (TEST) */
>> #define TEST_LBCK BIT(4)
>>
>> @@ -977,6 +983,8 @@ static int m_can_set_bittiming(struct net_device *dev)
>> const struct can_bittiming *dbt = &priv->can.data_bittiming;
>> u16 brp, sjw, tseg1, tseg2;
>> u32 reg_btp;
>> + u32 enable_tdc = 0;
>> + u32 tdco;
>>
>> brp = bt->brp - 1;
>> sjw = bt->sjw - 1;
>> @@ -991,9 +999,23 @@ static int m_can_set_bittiming(struct net_device *dev)
>> sjw = dbt->sjw - 1;
>> tseg1 = dbt->prop_seg + dbt->phase_seg1 - 1;
>> tseg2 = dbt->phase_seg2 - 1;
>> +
>> + /* TDC is only needed for bitrates beyond 2.5 MBit/s
>> + * Specified in the "Bit Time Requirements for CAN FD" document
>> + */
>> + if (dbt->bitrate > 2500000) {
>> + enable_tdc = DBTP_TDC;
>> + /* Equation based on Bosch's M_CAN User Manual's
>> + * Transmitter Delay Compensation Section
>> + */
>> + tdco = priv->can.clock.freq / (dbt->bitrate * 2);
>> + m_can_write(priv, M_CAN_TDCR, tdco << TDCR_TDCO_SHIFT);
>> + }
>> +
>> reg_btp = (brp << DBTP_DBRP_SHIFT) | (sjw << DBTP_DSJW_SHIFT) |
>> (tseg1 << DBTP_DTSEG1_SHIFT) |
>> - (tseg2 << DBTP_DTSEG2_SHIFT);
>> + (tseg2 << DBTP_DTSEG2_SHIFT) | enable_tdc;
>> +
>> m_can_write(priv, M_CAN_DBTP, reg_btp);
>> }
>>
>>
^ permalink raw reply
* Re: RFC: Audit Kernel Container IDs
From: Richard Guy Briggs @ 2017-09-14 5:30 UTC (permalink / raw)
To: Carlos O'Donell
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, Linux Containers, Linux API,
Linux Audit, Linux FS Devel, Linux Kernel,
Linux Network Development, Aristeu Rozanski, David Howells,
Eric W. Biederman, Eric Paris, jlayton-H+wXaHxf7aLQT0dZR+AlfA,
Andy Lutomirski, mszeredi-H+wXaHxf7aLQT0dZR+AlfA, Paul Moore,
Serge E. Hallyn, Steve Grubb, trondmy-7I+n7zu2hftEKMMhf/gKZA,
Al Viro
In-Reply-To: <9043cc5a-e624-10c9-1906-f29010c5f57c-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
On 2017-09-13 14:33, Carlos O'Donell wrote:
> On 09/13/2017 12:13 PM, Richard Guy Briggs wrote:
> > Containers are a userspace concept. The kernel knows nothing of them.
>
> I am looking at this RFC from a userspace perspective, particularly from
> the loader's point of view and the unshare syscall and the semantics that
> arise from the use of it.
>
> At a high level what you are doing is providing a way to group, without
> hierarchy, processes and namespaces. The processes can move between
> container's if they have CAP_CONTAINER_ADMIN and can open and write to
> a special proc file.
>
> * With unshare a thread may dissociate part of its execution context and
> therefore see a distinct mount namespace. When you say "process" in this
> particular RFC do you exclude the fact that a thread might be in a
> distinct container from the rest of the threads in the process?
>
> > The Linux audit system needs a way to be able to track the container
> > provenance of events and actions. Audit needs the kernel's help to do
> > this.
>
> * Why does the Linux audit system need to tracker container provenance?
- ability to filter unwanted, irrelevant or unimportant messages before
they fill queue so important messages don't get lost. This is a
certification requirement.
- ability to make security claims about containers, require tracking of
actions within those containers to ensure compliance with established
security policies.
- ability to route messages from events to relevant audit daemon
instance or host audit daemon instance or both, as required or
determined by user-initiated rules
> - How does it help to provide better audit messages?
>
> - Is it be enough to list the namespace that a process occupies?
We started with that approach back more than 4 years ago and found it
helped, but didn't go far enough in terms of quick and inexpensive
record filtering and left some doubt about provenance of events in the
case of non-user context events (incoming network packets).
> * Why does it need the kernel's help?
>
> - Is there a race condition that is only fixable with kernel support?
This was a concern, but relatively minor compared with the other benefits.
> - Or is it easier with kernel help but not required?
It is much easier and much less expensive.
> Providing background on these questions would help clarify the
> design requirements.
Here are some references that should help provide some background:
https://github.com/linux-audit/audit-kernel/issues/32
RFE: add namespace IDs to audit records
https://github.com/linux-audit/audit-documentation/wiki/SPEC-Virtualization-Manager-Guest-Lifecycle-Events
SPEC Virtualization Manager Guest Lifecycle Events
https://lwn.net/Articles/699819/
Audit, namespaces, and containers
https://lwn.net/Articles/723561/
Containers as kernel objects
(my reply, with references: https://lkml.org/lkml/2017/8/14/15 )
https://bugzilla.redhat.com/show_bug.cgi?id=1045666
audit: add namespace IDs to log records
> > Since the concept of a container is entirely a userspace concept, a
> > trigger signal from the userspace container orchestration system
> > initiates this. This will define a point in time and a set of resources
> > associated with a particular container with an audit container ID.
>
> Please don't use the word 'signal', I suggest 'register' since you are
> writing to a filesystem.
Ok, that's a very reasonable request. 'signal' has a previous meaning.
> > The trigger is a pseudo filesystem (proc, since PID tree already exists)
> > write of a u64 representing the container ID to a file representing a
> > process that will become the first process in a new container.
> > This might place restrictions on mount namespaces required to define a
> > container, or at least careful checking of namespaces in the kernel to
> > verify permissions of the orchestrator so it can't change its own
> > container ID.
> > A bind mount of nsfs may be necessary in the container orchestrator's
> > mntNS.
> >
> > Require a new CAP_CONTAINER_ADMIN to be able to write to the pseudo
> > filesystem to have this action permitted. At that time, record the
> > child container's user-supplied 64-bit container identifier along with
>
> What is a "child container?" Containers don't have any hierarchy.
Maybe some don't, but that's not likely to last long given the
abstraction and nesting of orchestration tools. This must be nestable.
> I assume that if you don't have CAP_CONTAINER_ADMIN, that nothing prevents
> your continued operation as we have today?
Correct. It won't prevent processes that otherwise have permissions
today from creating all the namespaces it wishes.
> > the child container's first process (which may become the container's
> > "init" process) process ID (referenced from the initial PID namespace),
> > all namespace IDs (in the form of a nsfs device number and inode number
> > tuple) in a new auxilliary record AUDIT_CONTAINER with a qualifying
> > op=$action field.
>
> What kind of requirement is there on the first tid/pid registering
> the container ID? What if the 8th tid/pid does the registration?
> Would that mean that the first process of the container did not
> register? It seems like you are suggesting that the registration
> by the 8th tid/pid causes a cascading registration progress,
> registering all tid/pids in the same grouping? Is that true?
Ah, good question, I forgot to address that fact. The intent is that
either threaded processes after initiating threading will not have
permission to execute this, or all the processes in the thread group
will be forced into the same container. I don't have a strong opinion
on whether or not it must be the lead thread process that must be the
one to receive that registration, but I suspect that would be wise.
> > Issue a new auxilliary record AUDIT_CONTAINER_INFO for each valid
> > container ID present on an auditable action or event.
> >
> > Forked and cloned processes inherit their parent's container ID,
> > referenced in the process' audit_context struct.
>
> So a cloned process with CLONE_NEWNS has the came container ID
> as the parent process that called clone, at least until the clone
> has time to change to a new container ID?
Yes.
> Do you forsee any case where someone might need a semantic that is
> slightly different? For example wanting to set the container ID on
> clone?
I could envision that situation and I think that might be workable but
for the synchronicity of having one initiated by a specific syscall and
the other initiated by a /proc write.
> > Log the creation of every namespace, inheriting/adding its spawning
> > process' containerID(s), if applicable. Include the spawning and
> > spawned namespace IDs (device and inode number tuples).
> > [AUDIT_NS_CREATE, AUDIT_NS_DESTROY] [clone(2), unshare(2), setns(2)]
> > Note: At this point it appears only network namespaces may need to track
> > container IDs apart from processes since incoming packets may cause an
> > auditable event before being associated with a process.
>
> OK.
>
> > Log the destruction of every namespace when it is no longer used by any
> > process, include the namespace IDs (device and inode number tuples).
> > [AUDIT_NS_DESTROY] [process exit, unshare(2), setns(2)]
> >
> > Issue a new auxilliary record AUDIT_NS_CHANGE listing (opt: op=$action)
> > the parent and child namespace IDs for any changes to a process'
> > namespaces. [setns(2)]
> > Note: It may be possible to combine AUDIT_NS_* record formats and
> > distinguish them with an op=$action field depending on the fields
> > required for each message type.
> >
> > A process can be moved from one container to another by using the
> > container assignment method outlined above a second time.
>
> OK.
>
> > When a container ceases to exist because the last process in that
> > container has exited and hence the last namespace has been destroyed and
> > its refcount dropping to zero, log the fact.
> > (This latter is likely needed for certification accountability.) A
> > container object may need a list of processes and/or namespaces.
>
> OK.
>
> > A namespace cannot directly migrate from one container to another but
> > could be assigned to a newly spawned container. A namespace can be
> > moved from one container to another indirectly by having that namespace
> > used in a second process in another container and then ending all the
> > processes in the first container.
>
> OK.
>
> > Feedback please.
Thank you sir!
> Carlos.
- RGB
--
Richard Guy Briggs <rgb-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635
^ permalink raw reply
* Re: [Outreachy kernel] [PATCH] staging: irda: Remove typedef struct
From: Julia Lawall @ 2017-09-14 5:59 UTC (permalink / raw)
To: Haneen Mohammed
Cc: devel, Samuel Ortiz, netdev, linux-kernel, outreachy-kernel,
Greg Kroah-Hartman
In-Reply-To: <20170914045538.GA24121@Haneen>
On Wed, 13 Sep 2017, Haneen Mohammed wrote:
> This patch remove typedef from a structure with all its ocurrences
> since using typedefs for structures is discouraged.
> Issue found using Coccinelle:
>
> @r1@
> type T;
> @@
>
> typedef struct { ... } T;
>
> @script:python c1@
> T2;
> T << r1.T;
> @@
> if T[-2:] =="_t" or T[-2:] == "_T":
> coccinelle.T2 = T[:-2];
> else:
> coccinelle.T2 = T;
>
> print T, coccinelle.T2
>
> @r2@
> type r1.T;
> identifier c1.T2;
> @@
> -typedef
> struct
> + T2
> { ... }
> -T
> ;
>
> @r3@
> type r1.T;
> identifier c1.T2;
> @@
> -T
> +struct T2
>
> Signed-off-by: Haneen Mohammed <hamohammed.sa@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
> ---
> drivers/staging/irda/include/net/irda/qos.h | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/staging/irda/include/net/irda/qos.h b/drivers/staging/irda/include/net/irda/qos.h
> index 05a5a24..a0315b5 100644
> --- a/drivers/staging/irda/include/net/irda/qos.h
> +++ b/drivers/staging/irda/include/net/irda/qos.h
> @@ -58,23 +58,23 @@
> #define IR_16000000 0x02
>
> /* Quality of Service information */
> -typedef struct {
> +struct qos_value {
> __u32 value;
> __u16 bits; /* LSB is first byte, MSB is second byte */
> -} qos_value_t;
> +};
>
> struct qos_info {
> magic_t magic;
>
> - qos_value_t baud_rate; /* IR_11520O | ... */
> - qos_value_t max_turn_time;
> - qos_value_t data_size;
> - qos_value_t window_size;
> - qos_value_t additional_bofs;
> - qos_value_t min_turn_time;
> - qos_value_t link_disc_time;
> + struct qos_value baud_rate; /* IR_11520O | ... */
> + struct qos_value max_turn_time;
> + struct qos_value data_size;
> + struct qos_value window_size;
> + struct qos_value additional_bofs;
> + struct qos_value min_turn_time;
> + struct qos_value link_disc_time;
>
> - qos_value_t power;
> + struct qos_value power;
> };
>
> extern int sysctl_max_baud_rate;
> --
> 2.7.4
>
> --
> You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to outreachy-kernel+unsubscribe@googlegroups.com.
> To post to this group, send email to outreachy-kernel@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20170914045538.GA24121%40Haneen.
> For more options, visit https://groups.google.com/d/optout.
>
^ permalink raw reply
* Re: [PATCH v2] ipv4: Namespaceify tcp_fastopen knob
From: 严海双 @ 2017-09-14 6:19 UTC (permalink / raw)
To: Eric Dumazet
Cc: David S. Miller, Alexey Kuznetsov, Eric Dumazet, Luca BRUNO,
netdev, linux-kernel
In-Reply-To: <1505307779.15310.157.camel@edumazet-glaptop3.roam.corp.google.com>
> On 2017年9月13日, at 下午9:02, Eric Dumazet <eric.dumazet@gmail.com> wrote:
>
> On Wed, 2017-09-13 at 05:44 -0700, Eric Dumazet wrote:
>> On Wed, 2017-09-13 at 19:19 +0800, Haishuang Yan wrote:
>>> Different namespace application might require enable TCP Fast Open
>>> feature independently of the host.
>>>
>>
>> Poor changelog, no actual description / list of sysctls that are moved
>> to per netns.
>>
>> And looking at the patch, it seems your conversion is not complete.
>>
>> So I will ask you to provide more evidence that you tested your patch
>> next time you submit it.
>
> I suggest you move one sysctl at a time, in a patch series.
>
> It will be easier to document and test for you, and review for us.
>
> Thanks.
>
Okay, I will split my patch for each sysctl change. Thanks.
^ permalink raw reply
* [PATCH] net: phy: Fix mask value write on gmii2rgmii converter speed register.
From: Fahad Kunnathadi @ 2017-09-14 7:16 UTC (permalink / raw)
To: f.fainelli
Cc: netdev, michal.simek, linux-kernel, Fahad Kunnathadi,
soren.brinkmann, linux-arm-kernel
To clear Speed Selection in MDIO control register(0x10),
ie, clear bits 6 and 13 to zero while keeping other bits same.
Before AND operation,The Mask value has to be perform with bitwise NOT
operation (ie, ~ operator)
This patch clears current speed selection before writing the
new speed settings to gmii2rgmii converter
Signed-off-by: Fahad Kunnathadi <fahad.kunnathadi@dexceldesigns.com>
---
drivers/net/phy/xilinx_gmii2rgmii.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/xilinx_gmii2rgmii.c b/drivers/net/phy/xilinx_gmii2rgmii.c
index d15dd39..2e5150b 100644
--- a/drivers/net/phy/xilinx_gmii2rgmii.c
+++ b/drivers/net/phy/xilinx_gmii2rgmii.c
@@ -44,7 +44,7 @@ static int xgmiitorgmii_read_status(struct phy_device *phydev)
priv->phy_drv->read_status(phydev);
val = mdiobus_read(phydev->mdio.bus, priv->addr, XILINX_GMII2RGMII_REG);
- val &= XILINX_GMII2RGMII_SPEED_MASK;
+ val &= ~XILINX_GMII2RGMII_SPEED_MASK;
if (phydev->speed == SPEED_1000)
val |= BMCR_SPEED1000;
--
1.9.1
^ permalink raw reply related
* Re: [PATCH 1/1] forcedeth: remove tx_stop variable
From: Yanjun Zhu @ 2017-09-14 7:55 UTC (permalink / raw)
To: davem, netdev
In-Reply-To: <1504873725-30180-1-git-send-email-yanjun.zhu@oracle.com>
Hi, all
After this patch is applied, the TCP && UDP tests are made.
The TCP bandwidth is 939 Mbits/sec. The UDP bandwidth is 806 Mbits/sec.
So I think this patch can work well.
host1 <-----> host2
host1: forcedeth NIC
IP: 1.1.1.107
iperf -s
host2: forcedeth NIC
IP:1.1.1.105
iperf -c 1.1.1.107
The TCP Bandwidth is as below:
------------------------------------------------------------
Client connecting to 1.1.1.107, TCP port 5001
TCP window size: 85.0 KByte (default)
------------------------------------------------------------
[ 3] local 1.1.1.105 port 46092 connected with 1.1.1.107 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 1.09 GBytes 939 Mbits/sec
The UDP is as below:
iperf -c 1.1.1.107 -u -b 1000m
------------------------------------------------------------
Client connecting to 1.1.1.107, UDP port 5001
Sending 1470 byte datagrams
UDP buffer size: 208 KByte (default)
------------------------------------------------------------
[ 3] local 1.1.1.105 port 47265 connected with 1.1.1.107 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-10.0 sec 964 MBytes 809 Mbits/sec
[ 3] Sent 687990 datagrams
[ 3] Server Report:
[ 3] 0.0-10.0 sec 960 MBytes 806 Mbits/sec 0.019 ms 2942/687989
(0.43%)
[ 3] 0.0-10.0 sec 1 datagrams received out-of-order
Zhu Yanjun
On 2017/9/8 20:28, Zhu Yanjun wrote:
> The variable tx_stop is used to indicate the tx queue state: started
> or stopped. In fact, the inline function netif_queue_stopped can do
> the same work. So replace the variable tx_stop with the
> function netif_queue_stopped.
>
> Signed-off-by: Zhu Yanjun <yanjun.zhu@oracle.com>
> ---
> drivers/net/ethernet/nvidia/forcedeth.c | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
> index 994a83a..e6e0de4 100644
> --- a/drivers/net/ethernet/nvidia/forcedeth.c
> +++ b/drivers/net/ethernet/nvidia/forcedeth.c
> @@ -834,7 +834,6 @@ struct fe_priv {
> u32 tx_pkts_in_progress;
> struct nv_skb_map *tx_change_owner;
> struct nv_skb_map *tx_end_flip;
> - int tx_stop;
>
> /* TX software stats */
> struct u64_stats_sync swstats_tx_syncp;
> @@ -1939,7 +1938,6 @@ static void nv_init_tx(struct net_device *dev)
> np->tx_pkts_in_progress = 0;
> np->tx_change_owner = NULL;
> np->tx_end_flip = NULL;
> - np->tx_stop = 0;
>
> for (i = 0; i < np->tx_ring_size; i++) {
> if (!nv_optimized(np)) {
> @@ -2211,7 +2209,6 @@ static netdev_tx_t nv_start_xmit(struct sk_buff *skb, struct net_device *dev)
> empty_slots = nv_get_empty_tx_slots(np);
> if (unlikely(empty_slots <= entries)) {
> netif_stop_queue(dev);
> - np->tx_stop = 1;
> spin_unlock_irqrestore(&np->lock, flags);
> return NETDEV_TX_BUSY;
> }
> @@ -2359,7 +2356,6 @@ static netdev_tx_t nv_start_xmit_optimized(struct sk_buff *skb,
> empty_slots = nv_get_empty_tx_slots(np);
> if (unlikely(empty_slots <= entries)) {
> netif_stop_queue(dev);
> - np->tx_stop = 1;
> spin_unlock_irqrestore(&np->lock, flags);
> return NETDEV_TX_BUSY;
> }
> @@ -2583,8 +2579,8 @@ static int nv_tx_done(struct net_device *dev, int limit)
>
> netdev_completed_queue(np->dev, tx_work, bytes_compl);
>
> - if (unlikely((np->tx_stop == 1) && (np->get_tx.orig != orig_get_tx))) {
> - np->tx_stop = 0;
> + if (unlikely(netif_queue_stopped(dev) &&
> + (np->get_tx.orig != orig_get_tx))) {
> netif_wake_queue(dev);
> }
> return tx_work;
> @@ -2637,8 +2633,8 @@ static int nv_tx_done_optimized(struct net_device *dev, int limit)
>
> netdev_completed_queue(np->dev, tx_work, bytes_cleaned);
>
> - if (unlikely((np->tx_stop == 1) && (np->get_tx.ex != orig_get_tx))) {
> - np->tx_stop = 0;
> + if (unlikely(netif_queue_stopped(dev) &&
> + (np->get_tx.ex != orig_get_tx))) {
> netif_wake_queue(dev);
> }
> return tx_work;
> @@ -2724,7 +2720,6 @@ static void nv_tx_timeout(struct net_device *dev)
> /* 2) complete any outstanding tx and do not give HW any limited tx pkts */
> saved_tx_limit = np->tx_limit;
> np->tx_limit = 0; /* prevent giving HW any limited pkts */
> - np->tx_stop = 0; /* prevent waking tx queue */
> if (!nv_optimized(np))
> nv_tx_done(dev, np->tx_ring_size);
> else
^ permalink raw reply
* Re: [RFC PATCH v3 2/7] sched: act_mirred: Traffic class option for mirror/redirect action
From: Nambiar, Amritha @ 2017-09-14 7:58 UTC (permalink / raw)
To: Jiri Pirko
Cc: intel-wired-lan, jeffrey.t.kirsher, alexander.h.duyck, netdev,
mlxsw
In-Reply-To: <20170913131843.GB1981@nanopsycho>
On 9/13/2017 6:18 AM, Jiri Pirko wrote:
> Wed, Sep 13, 2017 at 11:59:24AM CEST, amritha.nambiar@intel.com wrote:
>> Adds optional traffic class parameter to the mirror/redirect action.
>> The mirror/redirect action is extended to forward to a traffic
>> class on the device if the traffic class index is provided in
>> addition to the device's ifindex.
>
> Do I understand it correctly that you just abuse mirred to pas tcclass
> index down to the driver, without actually doing anything with the value
> inside mirred-code ? That is a bit confusing for me.
>
I think I get your point, I was looking at it more from a hardware
angle, and the 'redirect' action looked quite close to how this actually
works in the hardware. I agree the tclass value in the mirred-code is
not very useful other than offloading it.
^ permalink raw reply
* Re: [RFC PATCH v3 7/7] i40e: Enable cloud filters via tc-flower
From: Nambiar, Amritha @ 2017-09-14 8:00 UTC (permalink / raw)
To: Jiri Pirko
Cc: intel-wired-lan, jeffrey.t.kirsher, alexander.h.duyck, netdev,
mlxsw
In-Reply-To: <20170913132611.GC1981@nanopsycho>
On 9/13/2017 6:26 AM, Jiri Pirko wrote:
> Wed, Sep 13, 2017 at 11:59:50AM CEST, amritha.nambiar@intel.com wrote:
>> This patch enables tc-flower based hardware offloads. tc flower
>> filter provided by the kernel is configured as driver specific
>> cloud filter. The patch implements functions and admin queue
>> commands needed to support cloud filters in the driver and
>> adds cloud filters to configure these tc-flower filters.
>>
>> The only action supported is to redirect packets to a traffic class
>> on the same device.
>
> So basically you are not doing redirect, you are just setting tclass for
> matched packets, right? Why you use mirred for this? I think that
> you might consider extending g_act for that:
>
> # tc filter add dev eth0 protocol ip ingress \
> prio 1 flower dst_mac 3c:fd:fe:a0:d6:70 skip_sw \
> action tclass 0
>
Yes, this doesn't work like a typical egress redirect, but is aimed at
forwarding the matched packets to a different queue-group/traffic class
on the same device, so some sort-of ingress redirect in the hardware. I
possibly may not need the mirred-redirect as you say, I'll look into the
g_act way of doing this with a new gact tc action.
>
>>
>> # tc qdisc add dev eth0 ingress
>> # ethtool -K eth0 hw-tc-offload on
>>
>> # tc filter add dev eth0 protocol ip parent ffff:\
>> prio 1 flower dst_mac 3c:fd:fe:a0:d6:70 skip_sw\
>> action mirred ingress redirect dev eth0 tclass 0
>>
>> # tc filter add dev eth0 protocol ip parent ffff:\
>> prio 2 flower dst_ip 192.168.3.5/32\
>> ip_proto udp dst_port 25 skip_sw\
>> action mirred ingress redirect dev eth0 tclass 1
>>
>> # tc filter add dev eth0 protocol ipv6 parent ffff:\
>> prio 3 flower dst_ip fe8::200:1\
>> ip_proto udp dst_port 66 skip_sw\
>> action mirred ingress redirect dev eth0 tclass 1
>>
>> Delete tc flower filter:
>> Example:
>>
>> # tc filter del dev eth0 parent ffff: prio 3 handle 0x1 flower
>> # tc filter del dev eth0 parent ffff:
>>
>> Flow Director Sideband is disabled while configuring cloud filters
>> via tc-flower and until any cloud filter exists.
>>
>> Unsupported matches when cloud filters are added using enhanced
>> big buffer cloud filter mode of underlying switch include:
>> 1. source port and source IP
>> 2. Combined MAC address and IP fields.
>> 3. Not specifying L4 port
>>
>> These filter matches can however be used to redirect traffic to
>> the main VSI (tc 0) which does not require the enhanced big buffer
>> cloud filter support.
>>
>> v3: Cleaned up some lengthy function names. Changed ipv6 address to
>> __be32 array instead of u8 array. Used macro for IP version. Minor
>> formatting changes.
>> v2:
>> 1. Moved I40E_SWITCH_MODE_MASK definition to i40e_type.h
>> 2. Moved dev_info for add/deleting cloud filters in else condition
>> 3. Fixed some format specifier in dev_err logs
>> 4. Refactored i40e_get_capabilities to take an additional
>> list_type parameter and use it to query device and function
>> level capabilities.
>> 5. Fixed parsing tc redirect action to check for the is_tcf_mirred_tc()
>> to verify if redirect to a traffic class is supported.
>> 6. Added comments for Geneve fix in cloud filter big buffer AQ
>> function definitions.
>> 7. Cleaned up setup_tc interface to rebase and work with Jiri's
>> updates, separate function to process tc cls flower offloads.
>> 8. Changes to make Flow Director Sideband and Cloud filters mutually
>> exclusive.
>>
>> Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>
>> Signed-off-by: Kiran Patil <kiran.patil@intel.com>
>> Signed-off-by: Anjali Singhai Jain <anjali.singhai@intel.com>
>> Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
>> ---
>> drivers/net/ethernet/intel/i40e/i40e.h | 49 +
>> drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h | 3
>> drivers/net/ethernet/intel/i40e/i40e_common.c | 189 ++++
>> drivers/net/ethernet/intel/i40e/i40e_main.c | 971 +++++++++++++++++++-
>> drivers/net/ethernet/intel/i40e/i40e_prototype.h | 16
>> drivers/net/ethernet/intel/i40e/i40e_type.h | 1
>> .../net/ethernet/intel/i40evf/i40e_adminq_cmd.h | 3
>> 7 files changed, 1202 insertions(+), 30 deletions(-)
>>
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
>> index 6018fb6..b110519 100644
>> --- a/drivers/net/ethernet/intel/i40e/i40e.h
>> +++ b/drivers/net/ethernet/intel/i40e/i40e.h
>> @@ -55,6 +55,8 @@
>> #include <linux/net_tstamp.h>
>> #include <linux/ptp_clock_kernel.h>
>> #include <net/pkt_cls.h>
>> +#include <net/tc_act/tc_gact.h>
>> +#include <net/tc_act/tc_mirred.h>
>> #include "i40e_type.h"
>> #include "i40e_prototype.h"
>> #include "i40e_client.h"
>> @@ -252,9 +254,52 @@ struct i40e_fdir_filter {
>> u32 fd_id;
>> };
>>
>> +#define IPV4_VERSION 4
>> +#define IPV6_VERSION 6
>> +
>> +#define I40E_CLOUD_FIELD_OMAC 0x01
>> +#define I40E_CLOUD_FIELD_IMAC 0x02
>> +#define I40E_CLOUD_FIELD_IVLAN 0x04
>> +#define I40E_CLOUD_FIELD_TEN_ID 0x08
>> +#define I40E_CLOUD_FIELD_IIP 0x10
>> +
>> +#define I40E_CLOUD_FILTER_FLAGS_OMAC I40E_CLOUD_FIELD_OMAC
>> +#define I40E_CLOUD_FILTER_FLAGS_IMAC I40E_CLOUD_FIELD_IMAC
>> +#define I40E_CLOUD_FILTER_FLAGS_IMAC_IVLAN (I40E_CLOUD_FIELD_IMAC | \
>> + I40E_CLOUD_FIELD_IVLAN)
>> +#define I40E_CLOUD_FILTER_FLAGS_IMAC_TEN_ID (I40E_CLOUD_FIELD_IMAC | \
>> + I40E_CLOUD_FIELD_TEN_ID)
>> +#define I40E_CLOUD_FILTER_FLAGS_OMAC_TEN_ID_IMAC (I40E_CLOUD_FIELD_OMAC | \
>> + I40E_CLOUD_FIELD_IMAC | \
>> + I40E_CLOUD_FIELD_TEN_ID)
>> +#define I40E_CLOUD_FILTER_FLAGS_IMAC_IVLAN_TEN_ID (I40E_CLOUD_FIELD_IMAC | \
>> + I40E_CLOUD_FIELD_IVLAN | \
>> + I40E_CLOUD_FIELD_TEN_ID)
>> +#define I40E_CLOUD_FILTER_FLAGS_IIP I40E_CLOUD_FIELD_IIP
>> +
>> struct i40e_cloud_filter {
>> struct hlist_node cloud_node;
>> unsigned long cookie;
>> + /* cloud filter input set follows */
>> + u8 dst_mac[ETH_ALEN];
>> + u8 src_mac[ETH_ALEN];
>> + __be16 vlan_id;
>> + __be32 dst_ip;
>> + __be32 src_ip;
>> + __be32 dst_ipv6[4];
>> + __be32 src_ipv6[4];
>> + __be16 dst_port;
>> + __be16 src_port;
>> + u32 ip_version;
>> + u8 ip_proto; /* IPPROTO value */
>> + /* L4 port type: src or destination port */
>> +#define I40E_CLOUD_FILTER_PORT_SRC 0x01
>> +#define I40E_CLOUD_FILTER_PORT_DEST 0x02
>> + u8 port_type;
>> + u32 tenant_id;
>> + u8 flags;
>> +#define I40E_CLOUD_TNL_TYPE_NONE 0xff
>> + u8 tunnel_type;
>> u16 seid; /* filter control */
>> };
>>
>> @@ -491,6 +536,8 @@ struct i40e_pf {
>> #define I40E_FLAG_LINK_DOWN_ON_CLOSE_ENABLED BIT(27)
>> #define I40E_FLAG_SOURCE_PRUNING_DISABLED BIT(28)
>> #define I40E_FLAG_TC_MQPRIO BIT(29)
>> +#define I40E_FLAG_FD_SB_INACTIVE BIT(30)
>> +#define I40E_FLAG_FD_SB_TO_CLOUD_FILTER BIT(31)
>>
>> struct i40e_client_instance *cinst;
>> bool stat_offsets_loaded;
>> @@ -573,6 +620,8 @@ struct i40e_pf {
>> u16 phy_led_val;
>>
>> u16 override_q_count;
>> + u16 last_sw_conf_flags;
>> + u16 last_sw_conf_valid_flags;
>> };
>>
>> /**
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
>> index 2e567c2..feb3d42 100644
>> --- a/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
>> +++ b/drivers/net/ethernet/intel/i40e/i40e_adminq_cmd.h
>> @@ -1392,6 +1392,9 @@ struct i40e_aqc_cloud_filters_element_data {
>> struct {
>> u8 data[16];
>> } v6;
>> + struct {
>> + __le16 data[8];
>> + } raw_v6;
>> } ipaddr;
>> __le16 flags;
>> #define I40E_AQC_ADD_CLOUD_FILTER_SHIFT 0
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_common.c b/drivers/net/ethernet/intel/i40e/i40e_common.c
>> index 9567702..d9c9665 100644
>> --- a/drivers/net/ethernet/intel/i40e/i40e_common.c
>> +++ b/drivers/net/ethernet/intel/i40e/i40e_common.c
>> @@ -5434,5 +5434,194 @@ i40e_add_pinfo_to_list(struct i40e_hw *hw,
>>
>> status = i40e_aq_write_ppp(hw, (void *)sec, sec->data_end,
>> track_id, &offset, &info, NULL);
>> +
>> + return status;
>> +}
>> +
>> +/**
>> + * i40e_aq_add_cloud_filters
>> + * @hw: pointer to the hardware structure
>> + * @seid: VSI seid to add cloud filters from
>> + * @filters: Buffer which contains the filters to be added
>> + * @filter_count: number of filters contained in the buffer
>> + *
>> + * Set the cloud filters for a given VSI. The contents of the
>> + * i40e_aqc_cloud_filters_element_data are filled in by the caller
>> + * of the function.
>> + *
>> + **/
>> +enum i40e_status_code
>> +i40e_aq_add_cloud_filters(struct i40e_hw *hw, u16 seid,
>> + struct i40e_aqc_cloud_filters_element_data *filters,
>> + u8 filter_count)
>> +{
>> + struct i40e_aq_desc desc;
>> + struct i40e_aqc_add_remove_cloud_filters *cmd =
>> + (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
>> + enum i40e_status_code status;
>> + u16 buff_len;
>> +
>> + i40e_fill_default_direct_cmd_desc(&desc,
>> + i40e_aqc_opc_add_cloud_filters);
>> +
>> + buff_len = filter_count * sizeof(*filters);
>> + desc.datalen = cpu_to_le16(buff_len);
>> + desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
>> + cmd->num_filters = filter_count;
>> + cmd->seid = cpu_to_le16(seid);
>> +
>> + status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
>> +
>> + return status;
>> +}
>> +
>> +/**
>> + * i40e_aq_add_cloud_filters_bb
>> + * @hw: pointer to the hardware structure
>> + * @seid: VSI seid to add cloud filters from
>> + * @filters: Buffer which contains the filters in big buffer to be added
>> + * @filter_count: number of filters contained in the buffer
>> + *
>> + * Set the big buffer cloud filters for a given VSI. The contents of the
>> + * i40e_aqc_cloud_filters_element_bb are filled in by the caller of the
>> + * function.
>> + *
>> + **/
>> +i40e_status
>> +i40e_aq_add_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
>> + struct i40e_aqc_cloud_filters_element_bb *filters,
>> + u8 filter_count)
>> +{
>> + struct i40e_aq_desc desc;
>> + struct i40e_aqc_add_remove_cloud_filters *cmd =
>> + (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
>> + i40e_status status;
>> + u16 buff_len;
>> + int i;
>> +
>> + i40e_fill_default_direct_cmd_desc(&desc,
>> + i40e_aqc_opc_add_cloud_filters);
>> +
>> + buff_len = filter_count * sizeof(*filters);
>> + desc.datalen = cpu_to_le16(buff_len);
>> + desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
>> + cmd->num_filters = filter_count;
>> + cmd->seid = cpu_to_le16(seid);
>> + cmd->big_buffer_flag = I40E_AQC_ADD_CLOUD_CMD_BB;
>> +
>> + for (i = 0; i < filter_count; i++) {
>> + u16 tnl_type;
>> + u32 ti;
>> +
>> + tnl_type = (le16_to_cpu(filters[i].element.flags) &
>> + I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
>> + I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
>> +
>> + /* For Geneve, the VNI should be placed in offset shifted by a
>> + * byte than the offset for the Tenant ID for rest of the
>> + * tunnels.
>> + */
>> + if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
>> + ti = le32_to_cpu(filters[i].element.tenant_id);
>> + filters[i].element.tenant_id = cpu_to_le32(ti << 8);
>> + }
>> + }
>> +
>> + status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
>> +
>> + return status;
>> +}
>> +
>> +/**
>> + * i40e_aq_rem_cloud_filters
>> + * @hw: pointer to the hardware structure
>> + * @seid: VSI seid to remove cloud filters from
>> + * @filters: Buffer which contains the filters to be removed
>> + * @filter_count: number of filters contained in the buffer
>> + *
>> + * Remove the cloud filters for a given VSI. The contents of the
>> + * i40e_aqc_cloud_filters_element_data are filled in by the caller
>> + * of the function.
>> + *
>> + **/
>> +enum i40e_status_code
>> +i40e_aq_rem_cloud_filters(struct i40e_hw *hw, u16 seid,
>> + struct i40e_aqc_cloud_filters_element_data *filters,
>> + u8 filter_count)
>> +{
>> + struct i40e_aq_desc desc;
>> + struct i40e_aqc_add_remove_cloud_filters *cmd =
>> + (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
>> + enum i40e_status_code status;
>> + u16 buff_len;
>> +
>> + i40e_fill_default_direct_cmd_desc(&desc,
>> + i40e_aqc_opc_remove_cloud_filters);
>> +
>> + buff_len = filter_count * sizeof(*filters);
>> + desc.datalen = cpu_to_le16(buff_len);
>> + desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
>> + cmd->num_filters = filter_count;
>> + cmd->seid = cpu_to_le16(seid);
>> +
>> + status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
>> +
>> + return status;
>> +}
>> +
>> +/**
>> + * i40e_aq_rem_cloud_filters_bb
>> + * @hw: pointer to the hardware structure
>> + * @seid: VSI seid to remove cloud filters from
>> + * @filters: Buffer which contains the filters in big buffer to be removed
>> + * @filter_count: number of filters contained in the buffer
>> + *
>> + * Remove the big buffer cloud filters for a given VSI. The contents of the
>> + * i40e_aqc_cloud_filters_element_bb are filled in by the caller of the
>> + * function.
>> + *
>> + **/
>> +i40e_status
>> +i40e_aq_rem_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
>> + struct i40e_aqc_cloud_filters_element_bb *filters,
>> + u8 filter_count)
>> +{
>> + struct i40e_aq_desc desc;
>> + struct i40e_aqc_add_remove_cloud_filters *cmd =
>> + (struct i40e_aqc_add_remove_cloud_filters *)&desc.params.raw;
>> + i40e_status status;
>> + u16 buff_len;
>> + int i;
>> +
>> + i40e_fill_default_direct_cmd_desc(&desc,
>> + i40e_aqc_opc_remove_cloud_filters);
>> +
>> + buff_len = filter_count * sizeof(*filters);
>> + desc.datalen = cpu_to_le16(buff_len);
>> + desc.flags |= cpu_to_le16((u16)(I40E_AQ_FLAG_BUF | I40E_AQ_FLAG_RD));
>> + cmd->num_filters = filter_count;
>> + cmd->seid = cpu_to_le16(seid);
>> + cmd->big_buffer_flag = I40E_AQC_ADD_CLOUD_CMD_BB;
>> +
>> + for (i = 0; i < filter_count; i++) {
>> + u16 tnl_type;
>> + u32 ti;
>> +
>> + tnl_type = (le16_to_cpu(filters[i].element.flags) &
>> + I40E_AQC_ADD_CLOUD_TNL_TYPE_MASK) >>
>> + I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT;
>> +
>> + /* For Geneve, the VNI should be placed in offset shifted by a
>> + * byte than the offset for the Tenant ID for rest of the
>> + * tunnels.
>> + */
>> + if (tnl_type == I40E_AQC_ADD_CLOUD_TNL_TYPE_GENEVE) {
>> + ti = le32_to_cpu(filters[i].element.tenant_id);
>> + filters[i].element.tenant_id = cpu_to_le32(ti << 8);
>> + }
>> + }
>> +
>> + status = i40e_asq_send_command(hw, &desc, filters, buff_len, NULL);
>> +
>> return status;
>> }
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
>> index afcf08a..96ee608 100644
>> --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
>> +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
>> @@ -69,6 +69,15 @@ static int i40e_reset(struct i40e_pf *pf);
>> static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired);
>> static void i40e_fdir_sb_setup(struct i40e_pf *pf);
>> static int i40e_veb_get_bw_info(struct i40e_veb *veb);
>> +static int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,
>> + struct i40e_cloud_filter *filter,
>> + bool add);
>> +static int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,
>> + struct i40e_cloud_filter *filter,
>> + bool add);
>> +static int i40e_get_capabilities(struct i40e_pf *pf,
>> + enum i40e_admin_queue_opc list_type);
>> +
>>
>> /* i40e_pci_tbl - PCI Device ID Table
>> *
>> @@ -5478,7 +5487,11 @@ int i40e_set_bw_limit(struct i40e_vsi *vsi, u16 seid, u64 max_tx_rate)
>> **/
>> static void i40e_remove_queue_channels(struct i40e_vsi *vsi)
>> {
>> + enum i40e_admin_queue_err last_aq_status;
>> + struct i40e_cloud_filter *cfilter;
>> struct i40e_channel *ch, *ch_tmp;
>> + struct i40e_pf *pf = vsi->back;
>> + struct hlist_node *node;
>> int ret, i;
>>
>> /* Reset rss size that was stored when reconfiguring rss for
>> @@ -5519,6 +5532,29 @@ static void i40e_remove_queue_channels(struct i40e_vsi *vsi)
>> "Failed to reset tx rate for ch->seid %u\n",
>> ch->seid);
>>
>> + /* delete cloud filters associated with this channel */
>> + hlist_for_each_entry_safe(cfilter, node,
>> + &pf->cloud_filter_list, cloud_node) {
>> + if (cfilter->seid != ch->seid)
>> + continue;
>> +
>> + hash_del(&cfilter->cloud_node);
>> + if (cfilter->dst_port)
>> + ret = i40e_add_del_cloud_filter_big_buf(vsi,
>> + cfilter,
>> + false);
>> + else
>> + ret = i40e_add_del_cloud_filter(vsi, cfilter,
>> + false);
>> + last_aq_status = pf->hw.aq.asq_last_status;
>> + if (ret)
>> + dev_info(&pf->pdev->dev,
>> + "Failed to delete cloud filter, err %s aq_err %s\n",
>> + i40e_stat_str(&pf->hw, ret),
>> + i40e_aq_str(&pf->hw, last_aq_status));
>> + kfree(cfilter);
>> + }
>> +
>> /* delete VSI from FW */
>> ret = i40e_aq_delete_element(&vsi->back->hw, ch->seid,
>> NULL);
>> @@ -5970,6 +6006,74 @@ static bool i40e_setup_channel(struct i40e_pf *pf, struct i40e_vsi *vsi,
>> }
>>
>> /**
>> + * i40e_validate_and_set_switch_mode - sets up switch mode correctly
>> + * @vsi: ptr to VSI which has PF backing
>> + * @l4type: true for TCP ond false for UDP
>> + * @port_type: true if port is destination and false if port is source
>> + *
>> + * Sets up switch mode correctly if it needs to be changed and perform
>> + * what are allowed modes.
>> + **/
>> +static int i40e_validate_and_set_switch_mode(struct i40e_vsi *vsi, bool l4type,
>> + bool port_type)
>> +{
>> + u8 mode;
>> + struct i40e_pf *pf = vsi->back;
>> + struct i40e_hw *hw = &pf->hw;
>> + int ret;
>> +
>> + ret = i40e_get_capabilities(pf, i40e_aqc_opc_list_dev_capabilities);
>> + if (ret)
>> + return -EINVAL;
>> +
>> + if (hw->dev_caps.switch_mode) {
>> + /* if switch mode is set, support mode2 (non-tunneled for
>> + * cloud filter) for now
>> + */
>> + u32 switch_mode = hw->dev_caps.switch_mode &
>> + I40E_SWITCH_MODE_MASK;
>> + if (switch_mode >= I40E_NVM_IMAGE_TYPE_MODE1) {
>> + if (switch_mode == I40E_NVM_IMAGE_TYPE_MODE2)
>> + return 0;
>> + dev_err(&pf->pdev->dev,
>> + "Invalid switch_mode (%d), only non-tunneled mode for cloud filter is supported\n",
>> + hw->dev_caps.switch_mode);
>> + return -EINVAL;
>> + }
>> + }
>> +
>> + /* port_type: true for destination port and false for source port
>> + * For now, supports only destination port type
>> + */
>> + if (!port_type) {
>> + dev_err(&pf->pdev->dev, "src port type not supported\n");
>> + return -EINVAL;
>> + }
>> +
>> + /* Set Bit 7 to be valid */
>> + mode = I40E_AQ_SET_SWITCH_BIT7_VALID;
>> +
>> + /* Set L4type to both TCP and UDP support */
>> + mode |= I40E_AQ_SET_SWITCH_L4_TYPE_BOTH;
>> +
>> + /* Set cloud filter mode */
>> + mode |= I40E_AQ_SET_SWITCH_MODE_NON_TUNNEL;
>> +
>> + /* Prep mode field for set_switch_config */
>> + ret = i40e_aq_set_switch_config(hw, pf->last_sw_conf_flags,
>> + pf->last_sw_conf_valid_flags,
>> + mode, NULL);
>> + if (ret && hw->aq.asq_last_status != I40E_AQ_RC_ESRCH)
>> + dev_err(&pf->pdev->dev,
>> + "couldn't set switch config bits, err %s aq_err %s\n",
>> + i40e_stat_str(hw, ret),
>> + i40e_aq_str(hw,
>> + hw->aq.asq_last_status));
>> +
>> + return ret;
>> +}
>> +
>> +/**
>> * i40e_create_queue_channel - function to create channel
>> * @vsi: VSI to be configured
>> * @ch: ptr to channel (it contains channel specific params)
>> @@ -6735,13 +6839,726 @@ static int i40e_setup_tc(struct net_device *netdev, void *type_data)
>> return ret;
>> }
>>
>> +/**
>> + * i40e_set_cld_element - sets cloud filter element data
>> + * @filter: cloud filter rule
>> + * @cld: ptr to cloud filter element data
>> + *
>> + * This is helper function to copy data into cloud filter element
>> + **/
>> +static inline void
>> +i40e_set_cld_element(struct i40e_cloud_filter *filter,
>> + struct i40e_aqc_cloud_filters_element_data *cld)
>> +{
>> + int i, j;
>> + u32 ipa;
>> +
>> + memset(cld, 0, sizeof(*cld));
>> + ether_addr_copy(cld->outer_mac, filter->dst_mac);
>> + ether_addr_copy(cld->inner_mac, filter->src_mac);
>> +
>> + if (filter->ip_version == IPV6_VERSION) {
>> +#define IPV6_MAX_INDEX (ARRAY_SIZE(filter->dst_ipv6) - 1)
>> + for (i = 0, j = 0; i < 4; i++, j += 2) {
>> + ipa = be32_to_cpu(filter->dst_ipv6[IPV6_MAX_INDEX - i]);
>> + ipa = cpu_to_le32(ipa);
>> + memcpy(&cld->ipaddr.raw_v6.data[j], &ipa, 4);
>> + }
>> + } else {
>> + ipa = be32_to_cpu(filter->dst_ip);
>> + memcpy(&cld->ipaddr.v4.data, &ipa, 4);
>> + }
>> +
>> + cld->inner_vlan = cpu_to_le16(ntohs(filter->vlan_id));
>> +
>> + /* tenant_id is not supported by FW now, once the support is enabled
>> + * fill the cld->tenant_id with cpu_to_le32(filter->tenant_id)
>> + */
>> + if (filter->tenant_id)
>> + return;
>> +}
>> +
>> +/**
>> + * i40e_add_del_cloud_filter - Add/del cloud filter
>> + * @vsi: pointer to VSI
>> + * @filter: cloud filter rule
>> + * @add: if true, add, if false, delete
>> + *
>> + * Add or delete a cloud filter for a specific flow spec.
>> + * Returns 0 if the filter were successfully added.
>> + **/
>> +static int i40e_add_del_cloud_filter(struct i40e_vsi *vsi,
>> + struct i40e_cloud_filter *filter, bool add)
>> +{
>> + struct i40e_aqc_cloud_filters_element_data cld_filter;
>> + struct i40e_pf *pf = vsi->back;
>> + int ret;
>> + static const u16 flag_table[128] = {
>> + [I40E_CLOUD_FILTER_FLAGS_OMAC] =
>> + I40E_AQC_ADD_CLOUD_FILTER_OMAC,
>> + [I40E_CLOUD_FILTER_FLAGS_IMAC] =
>> + I40E_AQC_ADD_CLOUD_FILTER_IMAC,
>> + [I40E_CLOUD_FILTER_FLAGS_IMAC_IVLAN] =
>> + I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN,
>> + [I40E_CLOUD_FILTER_FLAGS_IMAC_TEN_ID] =
>> + I40E_AQC_ADD_CLOUD_FILTER_IMAC_TEN_ID,
>> + [I40E_CLOUD_FILTER_FLAGS_OMAC_TEN_ID_IMAC] =
>> + I40E_AQC_ADD_CLOUD_FILTER_OMAC_TEN_ID_IMAC,
>> + [I40E_CLOUD_FILTER_FLAGS_IMAC_IVLAN_TEN_ID] =
>> + I40E_AQC_ADD_CLOUD_FILTER_IMAC_IVLAN_TEN_ID,
>> + [I40E_CLOUD_FILTER_FLAGS_IIP] =
>> + I40E_AQC_ADD_CLOUD_FILTER_IIP,
>> + };
>> +
>> + if (filter->flags >= ARRAY_SIZE(flag_table))
>> + return I40E_ERR_CONFIG;
>> +
>> + /* copy element needed to add cloud filter from filter */
>> + i40e_set_cld_element(filter, &cld_filter);
>> +
>> + if (filter->tunnel_type != I40E_CLOUD_TNL_TYPE_NONE)
>> + cld_filter.flags = cpu_to_le16(filter->tunnel_type <<
>> + I40E_AQC_ADD_CLOUD_TNL_TYPE_SHIFT);
>> +
>> + if (filter->ip_version == IPV6_VERSION)
>> + cld_filter.flags |= cpu_to_le16(flag_table[filter->flags] |
>> + I40E_AQC_ADD_CLOUD_FLAGS_IPV6);
>> + else
>> + cld_filter.flags |= cpu_to_le16(flag_table[filter->flags] |
>> + I40E_AQC_ADD_CLOUD_FLAGS_IPV4);
>> +
>> + if (add)
>> + ret = i40e_aq_add_cloud_filters(&pf->hw, filter->seid,
>> + &cld_filter, 1);
>> + else
>> + ret = i40e_aq_rem_cloud_filters(&pf->hw, filter->seid,
>> + &cld_filter, 1);
>> + if (ret)
>> + dev_dbg(&pf->pdev->dev,
>> + "Failed to %s cloud filter using l4 port %u, err %d aq_err %d\n",
>> + add ? "add" : "delete", filter->dst_port, ret,
>> + pf->hw.aq.asq_last_status);
>> + else
>> + dev_info(&pf->pdev->dev,
>> + "%s cloud filter for VSI: %d\n",
>> + add ? "Added" : "Deleted", filter->seid);
>> + return ret;
>> +}
>> +
>> +/**
>> + * i40e_add_del_cloud_filter_big_buf - Add/del cloud filter using big_buf
>> + * @vsi: pointer to VSI
>> + * @filter: cloud filter rule
>> + * @add: if true, add, if false, delete
>> + *
>> + * Add or delete a cloud filter for a specific flow spec using big buffer.
>> + * Returns 0 if the filter were successfully added.
>> + **/
>> +static int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi,
>> + struct i40e_cloud_filter *filter,
>> + bool add)
>> +{
>> + struct i40e_aqc_cloud_filters_element_bb cld_filter;
>> + struct i40e_pf *pf = vsi->back;
>> + int ret;
>> +
>> + /* Both (Outer/Inner) valid mac_addr are not supported */
>> + if (is_valid_ether_addr(filter->dst_mac) &&
>> + is_valid_ether_addr(filter->src_mac))
>> + return -EINVAL;
>> +
>> + /* Make sure port is specified, otherwise bail out, for channel
>> + * specific cloud filter needs 'L4 port' to be non-zero
>> + */
>> + if (!filter->dst_port)
>> + return -EINVAL;
>> +
>> + /* adding filter using src_port/src_ip is not supported at this stage */
>> + if (filter->src_port || filter->src_ip ||
>> + !ipv6_addr_any((struct in6_addr *)&filter->src_ipv6))
>> + return -EINVAL;
>> +
>> + /* copy element needed to add cloud filter from filter */
>> + i40e_set_cld_element(filter, &cld_filter.element);
>> +
>> + if (is_valid_ether_addr(filter->dst_mac) ||
>> + is_valid_ether_addr(filter->src_mac) ||
>> + is_multicast_ether_addr(filter->dst_mac) ||
>> + is_multicast_ether_addr(filter->src_mac)) {
>> + /* MAC + IP : unsupported mode */
>> + if (filter->dst_ip)
>> + return -EINVAL;
>> +
>> + /* since we validated that L4 port must be valid before
>> + * we get here, start with respective "flags" value
>> + * and update if vlan is present or not
>> + */
>> + cld_filter.element.flags =
>> + cpu_to_le16(I40E_AQC_ADD_CLOUD_FILTER_MAC_PORT);
>> +
>> + if (filter->vlan_id) {
>> + cld_filter.element.flags =
>> + cpu_to_le16(I40E_AQC_ADD_CLOUD_FILTER_MAC_VLAN_PORT);
>> + }
>> +
>> + } else if (filter->dst_ip || filter->ip_version == IPV6_VERSION) {
>> + cld_filter.element.flags =
>> + cpu_to_le16(I40E_AQC_ADD_CLOUD_FILTER_IP_PORT);
>> + if (filter->ip_version == IPV6_VERSION)
>> + cld_filter.element.flags |=
>> + cpu_to_le16(I40E_AQC_ADD_CLOUD_FLAGS_IPV6);
>> + else
>> + cld_filter.element.flags |=
>> + cpu_to_le16(I40E_AQC_ADD_CLOUD_FLAGS_IPV4);
>> + } else {
>> + dev_err(&pf->pdev->dev,
>> + "either mac or ip has to be valid for cloud filter\n");
>> + return -EINVAL;
>> + }
>> +
>> + /* Now copy L4 port in Byte 6..7 in general fields */
>> + cld_filter.general_fields[I40E_AQC_ADD_CLOUD_FV_FLU_0X16_WORD0] =
>> + be16_to_cpu(filter->dst_port);
>> +
>> + if (add) {
>> + bool proto_type, port_type;
>> +
>> + proto_type = (filter->ip_proto == IPPROTO_TCP) ? true : false;
>> + port_type = (filter->port_type & I40E_CLOUD_FILTER_PORT_DEST) ?
>> + true : false;
>> +
>> + /* For now, src port based cloud filter for channel is not
>> + * supported
>> + */
>> + if (!port_type) {
>> + dev_err(&pf->pdev->dev,
>> + "unsupported port type (src port)\n");
>> + return -EOPNOTSUPP;
>> + }
>> +
>> + /* Validate current device switch mode, change if necessary */
>> + ret = i40e_validate_and_set_switch_mode(vsi, proto_type,
>> + port_type);
>> + if (ret) {
>> + dev_err(&pf->pdev->dev,
>> + "failed to set switch mode, ret %d\n",
>> + ret);
>> + return ret;
>> + }
>> +
>> + ret = i40e_aq_add_cloud_filters_bb(&pf->hw, filter->seid,
>> + &cld_filter, 1);
>> + } else {
>> + ret = i40e_aq_rem_cloud_filters_bb(&pf->hw, filter->seid,
>> + &cld_filter, 1);
>> + }
>> +
>> + if (ret)
>> + dev_dbg(&pf->pdev->dev,
>> + "Failed to %s cloud filter(big buffer) err %d aq_err %d\n",
>> + add ? "add" : "delete", ret, pf->hw.aq.asq_last_status);
>> + else
>> + dev_info(&pf->pdev->dev,
>> + "%s cloud filter for VSI: %d, L4 port: %d\n",
>> + add ? "add" : "delete", filter->seid,
>> + ntohs(filter->dst_port));
>> + return ret;
>> +}
>> +
>> +/**
>> + * i40e_parse_cls_flower - Parse tc flower filters provided by kernel
>> + * @vsi: Pointer to VSI
>> + * @cls_flower: Pointer to struct tc_cls_flower_offload
>> + * @filter: Pointer to cloud filter structure
>> + *
>> + **/
>> +static int i40e_parse_cls_flower(struct i40e_vsi *vsi,
>> + struct tc_cls_flower_offload *f,
>> + struct i40e_cloud_filter *filter)
>> +{
>> + struct i40e_pf *pf = vsi->back;
>> + u16 addr_type = 0;
>> + u8 field_flags = 0;
>> +
>> + if (f->dissector->used_keys &
>> + ~(BIT(FLOW_DISSECTOR_KEY_CONTROL) |
>> + BIT(FLOW_DISSECTOR_KEY_BASIC) |
>> + BIT(FLOW_DISSECTOR_KEY_ETH_ADDRS) |
>> + BIT(FLOW_DISSECTOR_KEY_VLAN) |
>> + BIT(FLOW_DISSECTOR_KEY_IPV4_ADDRS) |
>> + BIT(FLOW_DISSECTOR_KEY_IPV6_ADDRS) |
>> + BIT(FLOW_DISSECTOR_KEY_PORTS) |
>> + BIT(FLOW_DISSECTOR_KEY_ENC_KEYID))) {
>> + dev_err(&pf->pdev->dev, "Unsupported key used: 0x%x\n",
>> + f->dissector->used_keys);
>> + return -EOPNOTSUPP;
>> + }
>> +
>> + if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_ENC_KEYID)) {
>> + struct flow_dissector_key_keyid *key =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_ENC_KEYID,
>> + f->key);
>> +
>> + struct flow_dissector_key_keyid *mask =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_ENC_KEYID,
>> + f->mask);
>> +
>> + if (mask->keyid != 0)
>> + field_flags |= I40E_CLOUD_FIELD_TEN_ID;
>> +
>> + filter->tenant_id = be32_to_cpu(key->keyid);
>> + }
>> +
>> + if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_BASIC)) {
>> + struct flow_dissector_key_basic *key =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_BASIC,
>> + f->key);
>> +
>> + filter->ip_proto = key->ip_proto;
>> + }
>> +
>> + if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
>> + struct flow_dissector_key_eth_addrs *key =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_ETH_ADDRS,
>> + f->key);
>> +
>> + struct flow_dissector_key_eth_addrs *mask =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_ETH_ADDRS,
>> + f->mask);
>> +
>> + /* use is_broadcast and is_zero to check for all 0xf or 0 */
>> + if (!is_zero_ether_addr(mask->dst)) {
>> + if (is_broadcast_ether_addr(mask->dst)) {
>> + field_flags |= I40E_CLOUD_FIELD_OMAC;
>> + } else {
>> + dev_err(&pf->pdev->dev, "Bad ether dest mask %pM\n",
>> + mask->dst);
>> + return I40E_ERR_CONFIG;
>> + }
>> + }
>> +
>> + if (!is_zero_ether_addr(mask->src)) {
>> + if (is_broadcast_ether_addr(mask->src)) {
>> + field_flags |= I40E_CLOUD_FIELD_IMAC;
>> + } else {
>> + dev_err(&pf->pdev->dev, "Bad ether src mask %pM\n",
>> + mask->src);
>> + return I40E_ERR_CONFIG;
>> + }
>> + }
>> + ether_addr_copy(filter->dst_mac, key->dst);
>> + ether_addr_copy(filter->src_mac, key->src);
>> + }
>> +
>> + if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_VLAN)) {
>> + struct flow_dissector_key_vlan *key =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_VLAN,
>> + f->key);
>> + struct flow_dissector_key_vlan *mask =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_VLAN,
>> + f->mask);
>> +
>> + if (mask->vlan_id) {
>> + if (mask->vlan_id == VLAN_VID_MASK) {
>> + field_flags |= I40E_CLOUD_FIELD_IVLAN;
>> +
>> + } else {
>> + dev_err(&pf->pdev->dev, "Bad vlan mask 0x%04x\n",
>> + mask->vlan_id);
>> + return I40E_ERR_CONFIG;
>> + }
>> + }
>> +
>> + filter->vlan_id = cpu_to_be16(key->vlan_id);
>> + }
>> +
>> + if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_CONTROL)) {
>> + struct flow_dissector_key_control *key =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_CONTROL,
>> + f->key);
>> +
>> + addr_type = key->addr_type;
>> + }
>> +
>> + if (addr_type == FLOW_DISSECTOR_KEY_IPV4_ADDRS) {
>> + struct flow_dissector_key_ipv4_addrs *key =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_IPV4_ADDRS,
>> + f->key);
>> + struct flow_dissector_key_ipv4_addrs *mask =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_IPV4_ADDRS,
>> + f->mask);
>> +
>> + if (mask->dst) {
>> + if (mask->dst == cpu_to_be32(0xffffffff)) {
>> + field_flags |= I40E_CLOUD_FIELD_IIP;
>> + } else {
>> + dev_err(&pf->pdev->dev, "Bad ip dst mask 0x%08x\n",
>> + be32_to_cpu(mask->dst));
>> + return I40E_ERR_CONFIG;
>> + }
>> + }
>> +
>> + if (mask->src) {
>> + if (mask->src == cpu_to_be32(0xffffffff)) {
>> + field_flags |= I40E_CLOUD_FIELD_IIP;
>> + } else {
>> + dev_err(&pf->pdev->dev, "Bad ip src mask 0x%08x\n",
>> + be32_to_cpu(mask->dst));
>> + return I40E_ERR_CONFIG;
>> + }
>> + }
>> +
>> + if (field_flags & I40E_CLOUD_FIELD_TEN_ID) {
>> + dev_err(&pf->pdev->dev, "Tenant id not allowed for ip filter\n");
>> + return I40E_ERR_CONFIG;
>> + }
>> + filter->dst_ip = key->dst;
>> + filter->src_ip = key->src;
>> + filter->ip_version = IPV4_VERSION;
>> + }
>> +
>> + if (addr_type == FLOW_DISSECTOR_KEY_IPV6_ADDRS) {
>> + struct flow_dissector_key_ipv6_addrs *key =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_IPV6_ADDRS,
>> + f->key);
>> + struct flow_dissector_key_ipv6_addrs *mask =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_IPV6_ADDRS,
>> + f->mask);
>> +
>> + /* src and dest IPV6 address should not be LOOPBACK
>> + * (0:0:0:0:0:0:0:1), which can be represented as ::1
>> + */
>> + if (ipv6_addr_loopback(&key->dst) ||
>> + ipv6_addr_loopback(&key->src)) {
>> + dev_err(&pf->pdev->dev,
>> + "Bad ipv6, addr is LOOPBACK\n");
>> + return I40E_ERR_CONFIG;
>> + }
>> + if (!ipv6_addr_any(&mask->dst) || !ipv6_addr_any(&mask->src))
>> + field_flags |= I40E_CLOUD_FIELD_IIP;
>> +
>> + memcpy(&filter->src_ipv6, &key->src.s6_addr32,
>> + sizeof(filter->src_ipv6));
>> + memcpy(&filter->dst_ipv6, &key->dst.s6_addr32,
>> + sizeof(filter->dst_ipv6));
>> +
>> + /* mark it as IPv6 filter, to be used later */
>> + filter->ip_version = IPV6_VERSION;
>> + }
>> +
>> + if (dissector_uses_key(f->dissector, FLOW_DISSECTOR_KEY_PORTS)) {
>> + struct flow_dissector_key_ports *key =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_PORTS,
>> + f->key);
>> + struct flow_dissector_key_ports *mask =
>> + skb_flow_dissector_target(f->dissector,
>> + FLOW_DISSECTOR_KEY_PORTS,
>> + f->mask);
>> +
>> + if (mask->src) {
>> + if (mask->src == cpu_to_be16(0xffff)) {
>> + field_flags |= I40E_CLOUD_FIELD_IIP;
>> + } else {
>> + dev_err(&pf->pdev->dev, "Bad src port mask 0x%04x\n",
>> + be16_to_cpu(mask->src));
>> + return I40E_ERR_CONFIG;
>> + }
>> + }
>> +
>> + if (mask->dst) {
>> + if (mask->dst == cpu_to_be16(0xffff)) {
>> + field_flags |= I40E_CLOUD_FIELD_IIP;
>> + } else {
>> + dev_err(&pf->pdev->dev, "Bad dst port mask 0x%04x\n",
>> + be16_to_cpu(mask->dst));
>> + return I40E_ERR_CONFIG;
>> + }
>> + }
>> +
>> + filter->dst_port = key->dst;
>> + filter->src_port = key->src;
>> +
>> + /* For now, only supports destination port*/
>> + filter->port_type |= I40E_CLOUD_FILTER_PORT_DEST;
>> +
>> + switch (filter->ip_proto) {
>> + case IPPROTO_TCP:
>> + case IPPROTO_UDP:
>> + break;
>> + default:
>> + dev_err(&pf->pdev->dev,
>> + "Only UDP and TCP transport are supported\n");
>> + return -EINVAL;
>> + }
>> + }
>> + filter->flags = field_flags;
>> + return 0;
>> +}
>> +
>> +/**
>> + * i40e_handle_redirect_action: Forward to a traffic class on the device
>> + * @vsi: Pointer to VSI
>> + * @ifindex: ifindex of the device to forwared to
>> + * @tc: traffic class index on the device
>> + * @filter: Pointer to cloud filter structure
>> + *
>> + **/
>> +static int i40e_handle_redirect_action(struct i40e_vsi *vsi, int ifindex, u8 tc,
>> + struct i40e_cloud_filter *filter)
>> +{
>> + struct i40e_channel *ch, *ch_tmp;
>> +
>> + /* redirect to a traffic class on the same device */
>> + if (vsi->netdev->ifindex == ifindex) {
>> + if (tc == 0) {
>> + filter->seid = vsi->seid;
>> + return 0;
>> + } else if (vsi->tc_config.enabled_tc & BIT(tc)) {
>> + if (!filter->dst_port) {
>> + dev_err(&vsi->back->pdev->dev,
>> + "Specify destination port to redirect to traffic class that is not default\n");
>> + return -EINVAL;
>> + }
>> + if (list_empty(&vsi->ch_list))
>> + return -EINVAL;
>> + list_for_each_entry_safe(ch, ch_tmp, &vsi->ch_list,
>> + list) {
>> + if (ch->seid == vsi->tc_seid_map[tc])
>> + filter->seid = ch->seid;
>> + }
>> + return 0;
>> + }
>> + }
>> + return -EINVAL;
>> +}
>> +
>> +/**
>> + * i40e_parse_tc_actions - Parse tc actions
>> + * @vsi: Pointer to VSI
>> + * @cls_flower: Pointer to struct tc_cls_flower_offload
>> + * @filter: Pointer to cloud filter structure
>> + *
>> + **/
>> +static int i40e_parse_tc_actions(struct i40e_vsi *vsi, struct tcf_exts *exts,
>> + struct i40e_cloud_filter *filter)
>> +{
>> + const struct tc_action *a;
>> + LIST_HEAD(actions);
>> + int err;
>> +
>> + if (!tcf_exts_has_actions(exts))
>> + return -EINVAL;
>> +
>> + tcf_exts_to_list(exts, &actions);
>> + list_for_each_entry(a, &actions, list) {
>> + /* Drop action */
>> + if (is_tcf_gact_shot(a)) {
>> + dev_err(&vsi->back->pdev->dev,
>> + "Cloud filters do not support the drop action.\n");
>> + return -EOPNOTSUPP;
>> + }
>> +
>> + /* Redirect to a traffic class on the same device */
>> + if (!is_tcf_mirred_egress_redirect(a) && is_tcf_mirred_tc(a)) {
>> + int ifindex = tcf_mirred_ifindex(a);
>> + u8 tc = tcf_mirred_tc(a);
>> +
>> + err = i40e_handle_redirect_action(vsi, ifindex, tc,
>> + filter);
>> + if (err == 0)
>> + return err;
>> + }
>> + }
>> + return -EINVAL;
>> +}
>> +
>> +/**
>> + * i40e_configure_clsflower - Configure tc flower filters
>> + * @vsi: Pointer to VSI
>> + * @cls_flower: Pointer to struct tc_cls_flower_offload
>> + *
>> + **/
>> +static int i40e_configure_clsflower(struct i40e_vsi *vsi,
>> + struct tc_cls_flower_offload *cls_flower)
>> +{
>> + struct i40e_cloud_filter *filter = NULL;
>> + struct i40e_pf *pf = vsi->back;
>> + int err = 0;
>> +
>> + if (test_bit(__I40E_RESET_RECOVERY_PENDING, pf->state) ||
>> + test_bit(__I40E_RESET_INTR_RECEIVED, pf->state))
>> + return -EBUSY;
>> +
>> + if (pf->fdir_pf_active_filters ||
>> + (!hlist_empty(&pf->fdir_filter_list))) {
>> + dev_err(&vsi->back->pdev->dev,
>> + "Flow Director Sideband filters exists, turn ntuple off to configure cloud filters\n");
>> + return -EINVAL;
>> + }
>> +
>> + if (vsi->back->flags & I40E_FLAG_FD_SB_ENABLED) {
>> + dev_err(&vsi->back->pdev->dev,
>> + "Disable Flow Director Sideband, configuring Cloud filters via tc-flower\n");
>> + vsi->back->flags &= ~I40E_FLAG_FD_SB_ENABLED;
>> + vsi->back->flags |= I40E_FLAG_FD_SB_TO_CLOUD_FILTER;
>> + }
>> +
>> + filter = kzalloc(sizeof(*filter), GFP_KERNEL);
>> + if (!filter)
>> + return -ENOMEM;
>> +
>> + filter->cookie = cls_flower->cookie;
>> +
>> + err = i40e_parse_cls_flower(vsi, cls_flower, filter);
>> + if (err < 0)
>> + goto err;
>> +
>> + err = i40e_parse_tc_actions(vsi, cls_flower->exts, filter);
>> + if (err < 0)
>> + goto err;
>> +
>> + /* Add cloud filter */
>> + if (filter->dst_port)
>> + err = i40e_add_del_cloud_filter_big_buf(vsi, filter, true);
>> + else
>> + err = i40e_add_del_cloud_filter(vsi, filter, true);
>> +
>> + if (err) {
>> + dev_err(&pf->pdev->dev,
>> + "Failed to add cloud filter, err %s\n",
>> + i40e_stat_str(&pf->hw, err));
>> + err = i40e_aq_rc_to_posix(err, pf->hw.aq.asq_last_status);
>> + goto err;
>> + }
>> +
>> + /* add filter to the ordered list */
>> + INIT_HLIST_NODE(&filter->cloud_node);
>> +
>> + hlist_add_head(&filter->cloud_node, &pf->cloud_filter_list);
>> +
>> + pf->num_cloud_filters++;
>> +
>> + return err;
>> +err:
>> + kfree(filter);
>> + return err;
>> +}
>> +
>> +/**
>> + * i40e_find_cloud_filter - Find the could filter in the list
>> + * @vsi: Pointer to VSI
>> + * @cookie: filter specific cookie
>> + *
>> + **/
>> +static struct i40e_cloud_filter *i40e_find_cloud_filter(struct i40e_vsi *vsi,
>> + unsigned long *cookie)
>> +{
>> + struct i40e_cloud_filter *filter = NULL;
>> + struct hlist_node *node2;
>> +
>> + hlist_for_each_entry_safe(filter, node2,
>> + &vsi->back->cloud_filter_list, cloud_node)
>> + if (!memcmp(cookie, &filter->cookie, sizeof(filter->cookie)))
>> + return filter;
>> + return NULL;
>> +}
>> +
>> +/**
>> + * i40e_delete_clsflower - Remove tc flower filters
>> + * @vsi: Pointer to VSI
>> + * @cls_flower: Pointer to struct tc_cls_flower_offload
>> + *
>> + **/
>> +static int i40e_delete_clsflower(struct i40e_vsi *vsi,
>> + struct tc_cls_flower_offload *cls_flower)
>> +{
>> + struct i40e_cloud_filter *filter = NULL;
>> + struct i40e_pf *pf = vsi->back;
>> + int err = 0;
>> +
>> + filter = i40e_find_cloud_filter(vsi, &cls_flower->cookie);
>> +
>> + if (!filter)
>> + return -EINVAL;
>> +
>> + hash_del(&filter->cloud_node);
>> +
>> + if (filter->dst_port)
>> + err = i40e_add_del_cloud_filter_big_buf(vsi, filter, false);
>> + else
>> + err = i40e_add_del_cloud_filter(vsi, filter, false);
>> + if (err) {
>> + kfree(filter);
>> + dev_err(&pf->pdev->dev,
>> + "Failed to delete cloud filter, err %s\n",
>> + i40e_stat_str(&pf->hw, err));
>> + return i40e_aq_rc_to_posix(err, pf->hw.aq.asq_last_status);
>> + }
>> +
>> + kfree(filter);
>> + pf->num_cloud_filters--;
>> +
>> + if (!pf->num_cloud_filters)
>> + if ((pf->flags & I40E_FLAG_FD_SB_TO_CLOUD_FILTER) &&
>> + !(pf->flags & I40E_FLAG_FD_SB_INACTIVE)) {
>> + pf->flags |= I40E_FLAG_FD_SB_ENABLED;
>> + pf->flags &= ~I40E_FLAG_FD_SB_TO_CLOUD_FILTER;
>> + pf->flags &= ~I40E_FLAG_FD_SB_INACTIVE;
>> + }
>> + return 0;
>> +}
>> +
>> +/**
>> + * i40e_setup_tc_cls_flower - flower classifier offloads
>> + * @netdev: net device to configure
>> + * @type_data: offload data
>> + **/
>> +static int i40e_setup_tc_cls_flower(struct net_device *netdev,
>> + struct tc_cls_flower_offload *cls_flower)
>> +{
>> + struct i40e_netdev_priv *np = netdev_priv(netdev);
>> + struct i40e_vsi *vsi = np->vsi;
>> +
>> + if (!is_classid_clsact_ingress(cls_flower->common.classid) ||
>> + cls_flower->common.chain_index)
>> + return -EOPNOTSUPP;
>> +
>> + switch (cls_flower->command) {
>> + case TC_CLSFLOWER_REPLACE:
>> + return i40e_configure_clsflower(vsi, cls_flower);
>> + case TC_CLSFLOWER_DESTROY:
>> + return i40e_delete_clsflower(vsi, cls_flower);
>> + case TC_CLSFLOWER_STATS:
>> + return -EOPNOTSUPP;
>> + default:
>> + return -EINVAL;
>> + }
>> +}
>> +
>> static int __i40e_setup_tc(struct net_device *netdev, enum tc_setup_type type,
>> void *type_data)
>> {
>> - if (type != TC_SETUP_MQPRIO)
>> + switch (type) {
>> + case TC_SETUP_MQPRIO:
>> + return i40e_setup_tc(netdev, type_data);
>> + case TC_SETUP_CLSFLOWER:
>> + return i40e_setup_tc_cls_flower(netdev, type_data);
>> + default:
>> return -EOPNOTSUPP;
>> -
>> - return i40e_setup_tc(netdev, type_data);
>> + }
>> }
>>
>> /**
>> @@ -6939,6 +7756,13 @@ static void i40e_cloud_filter_exit(struct i40e_pf *pf)
>> kfree(cfilter);
>> }
>> pf->num_cloud_filters = 0;
>> +
>> + if ((pf->flags & I40E_FLAG_FD_SB_TO_CLOUD_FILTER) &&
>> + !(pf->flags & I40E_FLAG_FD_SB_INACTIVE)) {
>> + pf->flags |= I40E_FLAG_FD_SB_ENABLED;
>> + pf->flags &= ~I40E_FLAG_FD_SB_TO_CLOUD_FILTER;
>> + pf->flags &= ~I40E_FLAG_FD_SB_INACTIVE;
>> + }
>> }
>>
>> /**
>> @@ -8046,7 +8870,8 @@ static int i40e_reconstitute_veb(struct i40e_veb *veb)
>> * i40e_get_capabilities - get info about the HW
>> * @pf: the PF struct
>> **/
>> -static int i40e_get_capabilities(struct i40e_pf *pf)
>> +static int i40e_get_capabilities(struct i40e_pf *pf,
>> + enum i40e_admin_queue_opc list_type)
>> {
>> struct i40e_aqc_list_capabilities_element_resp *cap_buf;
>> u16 data_size;
>> @@ -8061,9 +8886,8 @@ static int i40e_get_capabilities(struct i40e_pf *pf)
>>
>> /* this loads the data into the hw struct for us */
>> err = i40e_aq_discover_capabilities(&pf->hw, cap_buf, buf_len,
>> - &data_size,
>> - i40e_aqc_opc_list_func_capabilities,
>> - NULL);
>> + &data_size, list_type,
>> + NULL);
>> /* data loaded, buffer no longer needed */
>> kfree(cap_buf);
>>
>> @@ -8080,26 +8904,44 @@ static int i40e_get_capabilities(struct i40e_pf *pf)
>> }
>> } while (err);
>>
>> - if (pf->hw.debug_mask & I40E_DEBUG_USER)
>> - dev_info(&pf->pdev->dev,
>> - "pf=%d, num_vfs=%d, msix_pf=%d, msix_vf=%d, fd_g=%d, fd_b=%d, pf_max_q=%d num_vsi=%d\n",
>> - pf->hw.pf_id, pf->hw.func_caps.num_vfs,
>> - pf->hw.func_caps.num_msix_vectors,
>> - pf->hw.func_caps.num_msix_vectors_vf,
>> - pf->hw.func_caps.fd_filters_guaranteed,
>> - pf->hw.func_caps.fd_filters_best_effort,
>> - pf->hw.func_caps.num_tx_qp,
>> - pf->hw.func_caps.num_vsis);
>> -
>> + if (pf->hw.debug_mask & I40E_DEBUG_USER) {
>> + if (list_type == i40e_aqc_opc_list_func_capabilities) {
>> + dev_info(&pf->pdev->dev,
>> + "pf=%d, num_vfs=%d, msix_pf=%d, msix_vf=%d, fd_g=%d, fd_b=%d, pf_max_q=%d num_vsi=%d\n",
>> + pf->hw.pf_id, pf->hw.func_caps.num_vfs,
>> + pf->hw.func_caps.num_msix_vectors,
>> + pf->hw.func_caps.num_msix_vectors_vf,
>> + pf->hw.func_caps.fd_filters_guaranteed,
>> + pf->hw.func_caps.fd_filters_best_effort,
>> + pf->hw.func_caps.num_tx_qp,
>> + pf->hw.func_caps.num_vsis);
>> + } else if (list_type == i40e_aqc_opc_list_dev_capabilities) {
>> + dev_info(&pf->pdev->dev,
>> + "switch_mode=0x%04x, function_valid=0x%08x\n",
>> + pf->hw.dev_caps.switch_mode,
>> + pf->hw.dev_caps.valid_functions);
>> + dev_info(&pf->pdev->dev,
>> + "SR-IOV=%d, num_vfs for all function=%u\n",
>> + pf->hw.dev_caps.sr_iov_1_1,
>> + pf->hw.dev_caps.num_vfs);
>> + dev_info(&pf->pdev->dev,
>> + "num_vsis=%u, num_rx:%u, num_tx=%u\n",
>> + pf->hw.dev_caps.num_vsis,
>> + pf->hw.dev_caps.num_rx_qp,
>> + pf->hw.dev_caps.num_tx_qp);
>> + }
>> + }
>> + if (list_type == i40e_aqc_opc_list_func_capabilities) {
>> #define DEF_NUM_VSI (1 + (pf->hw.func_caps.fcoe ? 1 : 0) \
>> + pf->hw.func_caps.num_vfs)
>> - if (pf->hw.revision_id == 0 && (DEF_NUM_VSI > pf->hw.func_caps.num_vsis)) {
>> - dev_info(&pf->pdev->dev,
>> - "got num_vsis %d, setting num_vsis to %d\n",
>> - pf->hw.func_caps.num_vsis, DEF_NUM_VSI);
>> - pf->hw.func_caps.num_vsis = DEF_NUM_VSI;
>> + if (pf->hw.revision_id == 0 &&
>> + (pf->hw.func_caps.num_vsis < DEF_NUM_VSI)) {
>> + dev_info(&pf->pdev->dev,
>> + "got num_vsis %d, setting num_vsis to %d\n",
>> + pf->hw.func_caps.num_vsis, DEF_NUM_VSI);
>> + pf->hw.func_caps.num_vsis = DEF_NUM_VSI;
>> + }
>> }
>> -
>> return 0;
>> }
>>
>> @@ -8141,6 +8983,7 @@ static void i40e_fdir_sb_setup(struct i40e_pf *pf)
>> if (!vsi) {
>> dev_info(&pf->pdev->dev, "Couldn't create FDir VSI\n");
>> pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
>> + pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
>> return;
>> }
>> }
>> @@ -8163,6 +9006,48 @@ static void i40e_fdir_teardown(struct i40e_pf *pf)
>> }
>>
>> /**
>> + * i40e_rebuild_cloud_filters - Rebuilds cloud filters for VSIs
>> + * @vsi: PF main vsi
>> + * @seid: seid of main or channel VSIs
>> + *
>> + * Rebuilds cloud filters associated with main VSI and channel VSIs if they
>> + * existed before reset
>> + **/
>> +static int i40e_rebuild_cloud_filters(struct i40e_vsi *vsi, u16 seid)
>> +{
>> + struct i40e_cloud_filter *cfilter;
>> + struct i40e_pf *pf = vsi->back;
>> + struct hlist_node *node;
>> + i40e_status ret;
>> +
>> + /* Add cloud filters back if they exist */
>> + if (hlist_empty(&pf->cloud_filter_list))
>> + return 0;
>> +
>> + hlist_for_each_entry_safe(cfilter, node, &pf->cloud_filter_list,
>> + cloud_node) {
>> + if (cfilter->seid != seid)
>> + continue;
>> +
>> + if (cfilter->dst_port)
>> + ret = i40e_add_del_cloud_filter_big_buf(vsi, cfilter,
>> + true);
>> + else
>> + ret = i40e_add_del_cloud_filter(vsi, cfilter, true);
>> +
>> + if (ret) {
>> + dev_dbg(&pf->pdev->dev,
>> + "Failed to rebuild cloud filter, err %s aq_err %s\n",
>> + i40e_stat_str(&pf->hw, ret),
>> + i40e_aq_str(&pf->hw,
>> + pf->hw.aq.asq_last_status));
>> + return ret;
>> + }
>> + }
>> + return 0;
>> +}
>> +
>> +/**
>> * i40e_rebuild_channels - Rebuilds channel VSIs if they existed before reset
>> * @vsi: PF main vsi
>> *
>> @@ -8199,6 +9084,13 @@ static int i40e_rebuild_channels(struct i40e_vsi *vsi)
>> I40E_BW_CREDIT_DIVISOR,
>> ch->seid);
>> }
>> + ret = i40e_rebuild_cloud_filters(vsi, ch->seid);
>> + if (ret) {
>> + dev_dbg(&vsi->back->pdev->dev,
>> + "Failed to rebuild cloud filters for channel VSI %u\n",
>> + ch->seid);
>> + return ret;
>> + }
>> }
>> return 0;
>> }
>> @@ -8365,7 +9257,7 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
>> i40e_verify_eeprom(pf);
>>
>> i40e_clear_pxe_mode(hw);
>> - ret = i40e_get_capabilities(pf);
>> + ret = i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities);
>> if (ret)
>> goto end_core_reset;
>>
>> @@ -8482,6 +9374,10 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired)
>> goto end_unlock;
>> }
>>
>> + ret = i40e_rebuild_cloud_filters(vsi, vsi->seid);
>> + if (ret)
>> + goto end_unlock;
>> +
>> /* PF Main VSI is rebuild by now, go ahead and rebuild channel VSIs
>> * for this main VSI if they exist
>> */
>> @@ -9404,6 +10300,7 @@ static int i40e_init_msix(struct i40e_pf *pf)
>> (pf->num_fdsb_msix == 0)) {
>> dev_info(&pf->pdev->dev, "Sideband Flowdir disabled, not enough MSI-X vectors\n");
>> pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
>> + pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
>> }
>> if ((pf->flags & I40E_FLAG_VMDQ_ENABLED) &&
>> (pf->num_vmdq_msix == 0)) {
>> @@ -9521,6 +10418,7 @@ static int i40e_init_interrupt_scheme(struct i40e_pf *pf)
>> I40E_FLAG_FD_SB_ENABLED |
>> I40E_FLAG_FD_ATR_ENABLED |
>> I40E_FLAG_VMDQ_ENABLED);
>> + pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
>>
>> /* rework the queue expectations without MSIX */
>> i40e_determine_queue_usage(pf);
>> @@ -10263,9 +11161,13 @@ bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features)
>> /* Enable filters and mark for reset */
>> if (!(pf->flags & I40E_FLAG_FD_SB_ENABLED))
>> need_reset = true;
>> - /* enable FD_SB only if there is MSI-X vector */
>> - if (pf->num_fdsb_msix > 0)
>> + /* enable FD_SB only if there is MSI-X vector and no cloud
>> + * filters exist
>> + */
>> + if (pf->num_fdsb_msix > 0 && !pf->num_cloud_filters) {
>> pf->flags |= I40E_FLAG_FD_SB_ENABLED;
>> + pf->flags &= ~I40E_FLAG_FD_SB_INACTIVE;
>> + }
>> } else {
>> /* turn off filters, mark for reset and clear SW filter list */
>> if (pf->flags & I40E_FLAG_FD_SB_ENABLED) {
>> @@ -10274,6 +11176,8 @@ bool i40e_set_ntuple(struct i40e_pf *pf, netdev_features_t features)
>> }
>> pf->flags &= ~(I40E_FLAG_FD_SB_ENABLED |
>> I40E_FLAG_FD_SB_AUTO_DISABLED);
>> + pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
>> +
>> /* reset fd counters */
>> pf->fd_add_err = 0;
>> pf->fd_atr_cnt = 0;
>> @@ -10857,7 +11761,8 @@ static int i40e_config_netdev(struct i40e_vsi *vsi)
>> netdev->hw_features |= NETIF_F_NTUPLE;
>> hw_features = hw_enc_features |
>> NETIF_F_HW_VLAN_CTAG_TX |
>> - NETIF_F_HW_VLAN_CTAG_RX;
>> + NETIF_F_HW_VLAN_CTAG_RX |
>> + NETIF_F_HW_TC;
>>
>> netdev->hw_features |= hw_features;
>>
>> @@ -12159,8 +13064,10 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
>> */
>>
>> if ((pf->hw.pf_id == 0) &&
>> - !(pf->flags & I40E_FLAG_TRUE_PROMISC_SUPPORT))
>> + !(pf->flags & I40E_FLAG_TRUE_PROMISC_SUPPORT)) {
>> flags = I40E_AQ_SET_SWITCH_CFG_PROMISC;
>> + pf->last_sw_conf_flags = flags;
>> + }
>>
>> if (pf->hw.pf_id == 0) {
>> u16 valid_flags;
>> @@ -12176,6 +13083,7 @@ static int i40e_setup_pf_switch(struct i40e_pf *pf, bool reinit)
>> pf->hw.aq.asq_last_status));
>> /* not a fatal problem, just keep going */
>> }
>> + pf->last_sw_conf_valid_flags = valid_flags;
>> }
>>
>> /* first time setup */
>> @@ -12273,6 +13181,7 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf)
>> I40E_FLAG_DCB_ENABLED |
>> I40E_FLAG_SRIOV_ENABLED |
>> I40E_FLAG_VMDQ_ENABLED);
>> + pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
>> } else if (!(pf->flags & (I40E_FLAG_RSS_ENABLED |
>> I40E_FLAG_FD_SB_ENABLED |
>> I40E_FLAG_FD_ATR_ENABLED |
>> @@ -12287,6 +13196,7 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf)
>> I40E_FLAG_FD_ATR_ENABLED |
>> I40E_FLAG_DCB_ENABLED |
>> I40E_FLAG_VMDQ_ENABLED);
>> + pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
>> } else {
>> /* Not enough queues for all TCs */
>> if ((pf->flags & I40E_FLAG_DCB_CAPABLE) &&
>> @@ -12310,6 +13220,7 @@ static void i40e_determine_queue_usage(struct i40e_pf *pf)
>> queues_left -= 1; /* save 1 queue for FD */
>> } else {
>> pf->flags &= ~I40E_FLAG_FD_SB_ENABLED;
>> + pf->flags |= I40E_FLAG_FD_SB_INACTIVE;
>> dev_info(&pf->pdev->dev, "not enough queues for Flow Director. Flow Director feature is disabled\n");
>> }
>> }
>> @@ -12613,7 +13524,7 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
>> dev_warn(&pdev->dev, "This device is a pre-production adapter/LOM. Please be aware there may be issues with your hardware. If you are experiencing problems please contact your Intel or hardware representative who provided you with this hardware.\n");
>>
>> i40e_clear_pxe_mode(hw);
>> - err = i40e_get_capabilities(pf);
>> + err = i40e_get_capabilities(pf, i40e_aqc_opc_list_func_capabilities);
>> if (err)
>> goto err_adminq_setup;
>>
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_prototype.h b/drivers/net/ethernet/intel/i40e/i40e_prototype.h
>> index 92869f5..3bb6659 100644
>> --- a/drivers/net/ethernet/intel/i40e/i40e_prototype.h
>> +++ b/drivers/net/ethernet/intel/i40e/i40e_prototype.h
>> @@ -283,6 +283,22 @@ i40e_status i40e_aq_query_switch_comp_bw_config(struct i40e_hw *hw,
>> struct i40e_asq_cmd_details *cmd_details);
>> i40e_status i40e_aq_resume_port_tx(struct i40e_hw *hw,
>> struct i40e_asq_cmd_details *cmd_details);
>> +i40e_status
>> +i40e_aq_add_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
>> + struct i40e_aqc_cloud_filters_element_bb *filters,
>> + u8 filter_count);
>> +enum i40e_status_code
>> +i40e_aq_add_cloud_filters(struct i40e_hw *hw, u16 vsi,
>> + struct i40e_aqc_cloud_filters_element_data *filters,
>> + u8 filter_count);
>> +enum i40e_status_code
>> +i40e_aq_rem_cloud_filters(struct i40e_hw *hw, u16 vsi,
>> + struct i40e_aqc_cloud_filters_element_data *filters,
>> + u8 filter_count);
>> +i40e_status
>> +i40e_aq_rem_cloud_filters_bb(struct i40e_hw *hw, u16 seid,
>> + struct i40e_aqc_cloud_filters_element_bb *filters,
>> + u8 filter_count);
>> i40e_status i40e_read_lldp_cfg(struct i40e_hw *hw,
>> struct i40e_lldp_variables *lldp_cfg);
>> /* i40e_common */
>> diff --git a/drivers/net/ethernet/intel/i40e/i40e_type.h b/drivers/net/ethernet/intel/i40e/i40e_type.h
>> index c019f46..af38881 100644
>> --- a/drivers/net/ethernet/intel/i40e/i40e_type.h
>> +++ b/drivers/net/ethernet/intel/i40e/i40e_type.h
>> @@ -287,6 +287,7 @@ struct i40e_hw_capabilities {
>> #define I40E_NVM_IMAGE_TYPE_MODE1 0x6
>> #define I40E_NVM_IMAGE_TYPE_MODE2 0x7
>> #define I40E_NVM_IMAGE_TYPE_MODE3 0x8
>> +#define I40E_SWITCH_MODE_MASK 0xF
>>
>> u32 management_mode;
>> u32 mng_protocols_over_mctp;
>> diff --git a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
>> index b8c78bf..4fe27f0 100644
>> --- a/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
>> +++ b/drivers/net/ethernet/intel/i40evf/i40e_adminq_cmd.h
>> @@ -1360,6 +1360,9 @@ struct i40e_aqc_cloud_filters_element_data {
>> struct {
>> u8 data[16];
>> } v6;
>> + struct {
>> + __le16 data[8];
>> + } raw_v6;
>> } ipaddr;
>> __le16 flags;
>> #define I40E_AQC_ADD_CLOUD_FILTER_SHIFT 0
>>
^ permalink raw reply
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